From 0cc558a07973eeade773bad2346fc143fb63682a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 18 Apr 2025 22:59:06 +0000 Subject: [PATCH 01/27] [skip ci] Release new versions --- .changeset/dull-bobcats-tie.md | 5 - python/package.json | 2 +- python/pyproject.toml | 2 +- .../v1.2.1/sandbox/page.mdx | 722 ++++++++++++++++++ 4 files changed, 724 insertions(+), 7 deletions(-) delete mode 100644 .changeset/dull-bobcats-tie.md create mode 100644 sdk-reference/code-interpreter-python-sdk/v1.2.1/sandbox/page.mdx diff --git a/.changeset/dull-bobcats-tie.md b/.changeset/dull-bobcats-tie.md deleted file mode 100644 index dc436d61..00000000 --- a/.changeset/dull-bobcats-tie.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@e2b/code-interpreter-python': patch ---- - -Update core SDK to add proxy parameter diff --git a/python/package.json b/python/package.json index 7591c0da..69ebbb04 100644 --- a/python/package.json +++ b/python/package.json @@ -1,7 +1,7 @@ { "name": "@e2b/code-interpreter-python", "private": true, - "version": "1.2.0", + "version": "1.2.1", "packageManager": "pnpm@8.7.6", "scripts": { "test": "poetry run pytest -n 4 --verbose -x", diff --git a/python/pyproject.toml b/python/pyproject.toml index ad48765f..27f4982d 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "e2b-code-interpreter" -version = "1.2.0" +version = "1.2.1" description = "E2B Code Interpreter - Stateful code execution" authors = ["e2b "] license = "Apache-2.0" diff --git a/sdk-reference/code-interpreter-python-sdk/v1.2.1/sandbox/page.mdx b/sdk-reference/code-interpreter-python-sdk/v1.2.1/sandbox/page.mdx new file mode 100644 index 00000000..86e0dfaf --- /dev/null +++ b/sdk-reference/code-interpreter-python-sdk/v1.2.1/sandbox/page.mdx @@ -0,0 +1,722 @@ + + + + + +## ChartType + +```python +class ChartType(str, enum.Enum) +``` + +Chart types + + +## ScaleType + +```python +class ScaleType(str, enum.Enum) +``` + +Ax scale types + + +## Chart + +```python +class Chart() +``` + +Extracted data from a chart. It's useful for building an interactive charts or custom visualizations. + + + + + + +## OutputMessage + +```python +@dataclass +class OutputMessage() +``` + +Represents an output message from the sandbox code execution. + + +### line + +The output line. + + +### timestamp + +Unix epoch in nanoseconds + + +### error + +Whether the output is an error. + + +## ExecutionError + +```python +@dataclass +class ExecutionError() +``` + +Represents an error that occurred during the execution of a cell. +The error contains the name of the error, the value of the error, and the traceback. + + +### name + +Name of the error. + + +### value + +Value of the error. + + +### traceback + +The raw traceback of the error. + + +### to\_json + +```python +def to_json() -> str +``` + +Returns the JSON representation of the Error object. + + +## MIMEType + +```python +class MIMEType(str) +``` + +Represents a MIME type. + + +## Result + +```python +@dataclass +class Result() +``` + +Represents the data to be displayed as a result of executing a cell in a Jupyter notebook. +The result is similar to the structure returned by ipython kernel: https://ipython.readthedocs.io/en/stable/development/execution.html#execution-semantics + +The result can contain multiple types of data, such as text, images, plots, etc. Each type of data is represented +as a string, and the result can contain multiple types of data. The display calls don't have to have text representation, +for the actual result the representation is always present for the result, the other representations are always optional. + + +### is\_main\_result + +Whether this data is the result of the cell. Data can be produced by display calls of which can be multiple in a cell. + + +### extra + +Extra data that can be included. Not part of the standard types. + + +### formats + +```python +def formats() -> Iterable[str] +``` + +Returns all available formats of the result. + +**Returns**: + +All available formats of the result in MIME types. + + +### \_\_str\_\_ + +```python +def __str__() -> Optional[str] +``` + +Returns the text representation of the data. + +**Returns**: + +The text representation of the data. + + +### \_repr\_html\_ + +```python +def _repr_html_() -> Optional[str] +``` + +Returns the HTML representation of the data. + +**Returns**: + +The HTML representation of the data. + + +### \_repr\_markdown\_ + +```python +def _repr_markdown_() -> Optional[str] +``` + +Returns the Markdown representation of the data. + +**Returns**: + +The Markdown representation of the data. + + +### \_repr\_svg\_ + +```python +def _repr_svg_() -> Optional[str] +``` + +Returns the SVG representation of the data. + +**Returns**: + +The SVG representation of the data. + + +### \_repr\_png\_ + +```python +def _repr_png_() -> Optional[str] +``` + +Returns the base64 representation of the PNG data. + +**Returns**: + +The base64 representation of the PNG data. + + +### \_repr\_jpeg\_ + +```python +def _repr_jpeg_() -> Optional[str] +``` + +Returns the base64 representation of the JPEG data. + +**Returns**: + +The base64 representation of the JPEG data. + + +### \_repr\_pdf\_ + +```python +def _repr_pdf_() -> Optional[str] +``` + +Returns the PDF representation of the data. + +**Returns**: + +The PDF representation of the data. + + +### \_repr\_latex\_ + +```python +def _repr_latex_() -> Optional[str] +``` + +Returns the LaTeX representation of the data. + +**Returns**: + +The LaTeX representation of the data. + + +### \_repr\_json\_ + +```python +def _repr_json_() -> Optional[dict] +``` + +Returns the JSON representation of the data. + +**Returns**: + +The JSON representation of the data. + + +### \_repr\_javascript\_ + +```python +def _repr_javascript_() -> Optional[str] +``` + +Returns the JavaScript representation of the data. + +**Returns**: + +The JavaScript representation of the data. + + +## Logs + +```python +@dataclass(repr=False) +class Logs() +``` + +Data printed to stdout and stderr during execution, usually by print statements, logs, warnings, subprocesses, etc. + + +### stdout + +List of strings printed to stdout by prints, subprocesses, etc. + + +### stderr + +List of strings printed to stderr by prints, subprocesses, etc. + + +### to\_json + +```python +def to_json() -> str +``` + +Returns the JSON representation of the Logs object. + + +### serialize\_results + +```python +def serialize_results(results: List[Result]) -> List[Dict[str, str]] +``` + +Serializes the results to JSON. + + +## Execution + +```python +@dataclass(repr=False) +class Execution() +``` + +Represents the result of a cell execution. + + +### results + +List of the result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots). + + +### logs + +Logs printed to stdout and stderr during execution. + + +### error + +Error object if an error occurred, None otherwise. + + +### execution\_count + +Execution count of the cell. + + +### text + +```python +@property +def text() -> Optional[str] +``` + +Returns the text representation of the result. + +**Returns**: + +The text representation of the result. + + +### to\_json + +```python +def to_json() -> str +``` + +Returns the JSON representation of the Execution object. + + +## Context + +```python +@dataclass +class Context() +``` + +Represents a context for code execution. + + +### id + +The ID of the context. + + +### language + +The language of the context. + + +### cwd + +The working directory of the context. + + + + + + +## AsyncSandbox + +```python +class AsyncSandbox(BaseAsyncSandbox) +``` + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs [here](https://e2b.dev/docs). + +Use the `AsyncSandbox.create()` to create a new sandbox. + +**Example**: + +```python +from e2b_code_interpreter import AsyncSandbox +sandbox = await AsyncSandbox.create() +``` + + +### run\_code + +```python +@overload +async def run_code(code: str, + language: Union[Literal["python"], None] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +async def run_code(code: str, + language: Optional[str] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +async def run_code(code: str, + context: Optional[Context] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `context`: Concrete context to run the code in. If not specified, the default context for the language is used. It's mutually exclusive with the language. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### create\_code\_context + +```python +async def create_code_context( + cwd: Optional[str] = None, + language: Optional[str] = None, + request_timeout: Optional[float] = None) -> Context +``` + +Creates a new context to run code in. + +**Arguments**: + +- `cwd`: Set the current working directory for the context, defaults to `/home/user` +- `language`: Language of the context. If not specified, defaults to Python +- `request_timeout`: Timeout for the request in **milliseconds** + +**Returns**: + +Context object + + + + +## Sandbox + +```python +class Sandbox(BaseSandbox) +``` + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs [here](https://e2b.dev/docs). + +Use the `Sandbox()` to create a new sandbox. + +**Example**: + +```python +from e2b_code_interpreter import Sandbox + +sandbox = Sandbox() +``` + + +### run\_code + +```python +@overload +def run_code(code: str, + language: Union[Literal["python"], None] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +def run_code(code: str, + language: Optional[str] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +def run_code(code: str, + context: Optional[Context] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `context`: Concrete context to run the code in. If not specified, the default context for the language is used. It's mutually exclusive with the language. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### create\_code\_context + +```python +def create_code_context(cwd: Optional[str] = None, + language: Optional[str] = None, + request_timeout: Optional[float] = None) -> Context +``` + +Creates a new context to run code in. + +**Arguments**: + +- `cwd`: Set the current working directory for the context, defaults to `/home/user` +- `language`: Language of the context. If not specified, defaults to Python +- `request_timeout`: Timeout for the request in **milliseconds** + +**Returns**: + +Context object + From d4f1d0b56ecf53f0b51667e99c88362c82c51637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Nov=C3=A1k?= Date: Fri, 25 Apr 2025 14:20:45 +0200 Subject: [PATCH 02/27] Refactor workflows to run tests on PRs (#89) --- .github/workflows/charts_tests.yml | 2 +- .github/workflows/js_tests.yml | 2 +- .github/workflows/pull_request.yml | 26 ++++++++++++++++++++++++++ .github/workflows/python_tests.yml | 2 +- .github/workflows/release.yml | 12 +++--------- 5 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/charts_tests.yml b/.github/workflows/charts_tests.yml index c94d2fa4..985e7d99 100644 --- a/.github/workflows/charts_tests.yml +++ b/.github/workflows/charts_tests.yml @@ -11,7 +11,7 @@ jobs: defaults: run: working-directory: ./chart_data_extractor - name: Build and test Chart Data Extractor + name: Chart Data Extractor - Build and test runs-on: ubuntu-22.04 steps: - name: Checkout repository diff --git a/.github/workflows/js_tests.yml b/.github/workflows/js_tests.yml index 49cdefef..f791115a 100644 --- a/.github/workflows/js_tests.yml +++ b/.github/workflows/js_tests.yml @@ -14,7 +14,7 @@ jobs: defaults: run: working-directory: ./js - name: Build and test SDK + name: JS SDK - Build and test runs-on: ubuntu-22.04 steps: - name: Checkout repository diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 00000000..78b42016 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,26 @@ +name: Pull Request + +permissions: + contents: read + id-token: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + pull_request: + branches: + - main + +jobs: + js-sdk: + uses: ./.github/workflows/js_tests.yml + secrets: + E2B_API_KEY: ${{ secrets.E2B_API_KEY }} + python-sdk: + uses: ./.github/workflows/python_tests.yml + secrets: + E2B_API_KEY: ${{ secrets.E2B_API_KEY }} + charts-tests: + uses: ./.github/workflows/charts_tests.yml diff --git a/.github/workflows/python_tests.yml b/.github/workflows/python_tests.yml index a54b2d51..5bb46fea 100644 --- a/.github/workflows/python_tests.yml +++ b/.github/workflows/python_tests.yml @@ -14,7 +14,7 @@ jobs: defaults: run: working-directory: ./python - name: Build and test SDK + name: Python SDK - Build and test runs-on: ubuntu-22.04 steps: - name: Checkout repository diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ce12a1b2..523f8531 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -108,15 +108,9 @@ jobs: IS_RELEASE=$(./.github/scripts/is_release_for_package.sh "@e2b/code-interpreter-template") echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT" - charts-tests: - name: Charts tests - needs: [changes] - if: needs.changes.outputs.charts == 'true' - uses: ./.github/workflows/charts_tests.yml charts-release: name: Charts release - needs: [charts-tests] if: needs.changes.outputs.charts == 'true' runs-on: ubuntu-latest outputs: @@ -243,8 +237,8 @@ jobs: needs: [changes, build-template] if: always() && !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') && - (needs.changes.outputs.python == 'true' || needs.changes.outputs.template == 'true') + !contains(needs.*.result, 'cancelled') && + needs.changes.outputs.template == 'true' uses: ./.github/workflows/python_tests.yml secrets: inherit @@ -254,7 +248,7 @@ jobs: if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && - (needs.changes.outputs.js == 'true' || needs.changes.outputs.template == 'true') + needs.changes.outputs.template == 'true' uses: ./.github/workflows/js_tests.yml secrets: inherit From c70f06eb35371feb90bf1676644f3125f8ac72fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Apr 2025 02:56:46 -0700 Subject: [PATCH 03/27] Bump h11 in /python in the pip group across 1 directory (#90) Bumps the pip group with 1 update in the /python directory: [h11](https://github.com/python-hyper/h11). Updates `h11` from 0.14.0 to 0.16.0 - [Commits](https://github.com/python-hyper/h11/compare/v0.14.0...v0.16.0) --- updated-dependencies: - dependency-name: h11 dependency-version: 0.16.0 dependency-type: indirect dependency-group: pip ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- python/poetry.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/python/poetry.lock b/python/poetry.lock index 9c85df98..1bd62420 100644 --- a/python/poetry.lock +++ b/python/poetry.lock @@ -239,7 +239,7 @@ description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" groups = ["dev"] -markers = "sys_platform == \"win32\" or platform_system == \"Windows\"" +markers = "platform_system == \"Windows\" or sys_platform == \"win32\"" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, @@ -415,37 +415,37 @@ testing = ["hatch", "pre-commit", "pytest", "tox"] [[package]] name = "h11" -version = "0.14.0" +version = "0.16.0" description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" groups = ["main"] files = [ - {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, - {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, + {file = "h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86"}, + {file = "h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1"}, ] [[package]] name = "httpcore" -version = "1.0.5" +version = "1.0.9" description = "A minimal low-level HTTP client." optional = false python-versions = ">=3.8" groups = ["main"] files = [ - {file = "httpcore-1.0.5-py3-none-any.whl", hash = "sha256:421f18bac248b25d310f3cacd198d55b8e6125c107797b609ff9b7a6ba7991b5"}, - {file = "httpcore-1.0.5.tar.gz", hash = "sha256:34a38e2f9291467ee3b44e89dd52615370e152954ba21721378a87b2960f7a61"}, + {file = "httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55"}, + {file = "httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8"}, ] [package.dependencies] certifi = "*" -h11 = ">=0.13,<0.15" +h11 = ">=0.16" [package.extras] asyncio = ["anyio (>=4.0,<5.0)"] http2 = ["h2 (>=3,<5)"] socks = ["socksio (==1.*)"] -trio = ["trio (>=0.22.0,<0.26.0)"] +trio = ["trio (>=0.22.0,<1.0)"] [[package]] name = "httpx" From 2bfcfbb6154508cfed25a296424ee77b04371364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Nov=C3=A1k?= Date: Tue, 29 Apr 2025 12:32:50 +0200 Subject: [PATCH 04/27] Security patches (#95) * Update Jinja2 * Update esbuild + vite --- pnpm-lock.yaml | 296 +++------------------------------------------ python/poetry.lock | 6 +- 2 files changed, 22 insertions(+), 280 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 77250e38..34d8ce5a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,7 +40,7 @@ importers: version: 17.1.14 tsup: specifier: ^8.4.0 - version: 8.4.0(jiti@2.4.2)(postcss@8.5.1)(typescript@5.7.3)(yaml@2.7.0) + version: 8.4.0(jiti@2.4.2)(postcss@8.5.3)(typescript@5.7.3)(yaml@2.7.0) typedoc: specifier: 0.26.8 version: 0.26.8(typescript@5.7.3) @@ -133,300 +133,150 @@ packages: peerDependencies: '@bufbuild/protobuf': ^2.2.0 - '@esbuild/aix-ppc64@0.24.2': - resolution: {integrity: sha512-thpVCb/rhxE/BnMLQ7GReQLLN8q9qbHmI55F4489/ByVg2aQaQ6kbcLb6FHkocZzQhxc4gx0sCk0tJkKBFzDhA==} - engines: {node: '>=18'} - cpu: [ppc64] - os: [aix] - '@esbuild/aix-ppc64@0.25.0': resolution: {integrity: sha512-O7vun9Sf8DFjH2UtqK8Ku3LkquL9SZL8OLY1T5NZkA34+wG3OQF7cl4Ql8vdNzM6fzBbYfLaiRLIOZ+2FOCgBQ==} engines: {node: '>=18'} cpu: [ppc64] os: [aix] - '@esbuild/android-arm64@0.24.2': - resolution: {integrity: sha512-cNLgeqCqV8WxfcTIOeL4OAtSmL8JjcN6m09XIgro1Wi7cF4t/THaWEa7eL5CMoMBdjoHOTh/vwTO/o2TRXIyzg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [android] - '@esbuild/android-arm64@0.25.0': resolution: {integrity: sha512-grvv8WncGjDSyUBjN9yHXNt+cq0snxXbDxy5pJtzMKGmmpPxeAmAhWxXI+01lU5rwZomDgD3kJwulEnhTRUd6g==} engines: {node: '>=18'} cpu: [arm64] os: [android] - '@esbuild/android-arm@0.24.2': - resolution: {integrity: sha512-tmwl4hJkCfNHwFB3nBa8z1Uy3ypZpxqxfTQOcHX+xRByyYgunVbZ9MzUUfb0RxaHIMnbHagwAxuTL+tnNM+1/Q==} - engines: {node: '>=18'} - cpu: [arm] - os: [android] - '@esbuild/android-arm@0.25.0': resolution: {integrity: sha512-PTyWCYYiU0+1eJKmw21lWtC+d08JDZPQ5g+kFyxP0V+es6VPPSUhM6zk8iImp2jbV6GwjX4pap0JFbUQN65X1g==} engines: {node: '>=18'} cpu: [arm] os: [android] - '@esbuild/android-x64@0.24.2': - resolution: {integrity: sha512-B6Q0YQDqMx9D7rvIcsXfmJfvUYLoP722bgfBlO5cGvNVb5V/+Y7nhBE3mHV9OpxBf4eAS2S68KZztiPaWq4XYw==} - engines: {node: '>=18'} - cpu: [x64] - os: [android] - '@esbuild/android-x64@0.25.0': resolution: {integrity: sha512-m/ix7SfKG5buCnxasr52+LI78SQ+wgdENi9CqyCXwjVR2X4Jkz+BpC3le3AoBPYTC9NHklwngVXvbJ9/Akhrfg==} engines: {node: '>=18'} cpu: [x64] os: [android] - '@esbuild/darwin-arm64@0.24.2': - resolution: {integrity: sha512-kj3AnYWc+CekmZnS5IPu9D+HWtUI49hbnyqk0FLEJDbzCIQt7hg7ucF1SQAilhtYpIujfaHr6O0UHlzzSPdOeA==} - engines: {node: '>=18'} - cpu: [arm64] - os: [darwin] - '@esbuild/darwin-arm64@0.25.0': resolution: {integrity: sha512-mVwdUb5SRkPayVadIOI78K7aAnPamoeFR2bT5nszFUZ9P8UpK4ratOdYbZZXYSqPKMHfS1wdHCJk1P1EZpRdvw==} engines: {node: '>=18'} cpu: [arm64] os: [darwin] - '@esbuild/darwin-x64@0.24.2': - resolution: {integrity: sha512-WeSrmwwHaPkNR5H3yYfowhZcbriGqooyu3zI/3GGpF8AyUdsrrP0X6KumITGA9WOyiJavnGZUwPGvxvwfWPHIA==} - engines: {node: '>=18'} - cpu: [x64] - os: [darwin] - '@esbuild/darwin-x64@0.25.0': resolution: {integrity: sha512-DgDaYsPWFTS4S3nWpFcMn/33ZZwAAeAFKNHNa1QN0rI4pUjgqf0f7ONmXf6d22tqTY+H9FNdgeaAa+YIFUn2Rg==} engines: {node: '>=18'} cpu: [x64] os: [darwin] - '@esbuild/freebsd-arm64@0.24.2': - resolution: {integrity: sha512-UN8HXjtJ0k/Mj6a9+5u6+2eZ2ERD7Edt1Q9IZiB5UZAIdPnVKDoG7mdTVGhHJIeEml60JteamR3qhsr1r8gXvg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [freebsd] - '@esbuild/freebsd-arm64@0.25.0': resolution: {integrity: sha512-VN4ocxy6dxefN1MepBx/iD1dH5K8qNtNe227I0mnTRjry8tj5MRk4zprLEdG8WPyAPb93/e4pSgi1SoHdgOa4w==} engines: {node: '>=18'} cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-x64@0.24.2': - resolution: {integrity: sha512-TvW7wE/89PYW+IevEJXZ5sF6gJRDY/14hyIGFXdIucxCsbRmLUcjseQu1SyTko+2idmCw94TgyaEZi9HUSOe3Q==} - engines: {node: '>=18'} - cpu: [x64] - os: [freebsd] - '@esbuild/freebsd-x64@0.25.0': resolution: {integrity: sha512-mrSgt7lCh07FY+hDD1TxiTyIHyttn6vnjesnPoVDNmDfOmggTLXRv8Id5fNZey1gl/V2dyVK1VXXqVsQIiAk+A==} engines: {node: '>=18'} cpu: [x64] os: [freebsd] - '@esbuild/linux-arm64@0.24.2': - resolution: {integrity: sha512-7HnAD6074BW43YvvUmE/35Id9/NB7BeX5EoNkK9obndmZBUk8xmJJeU7DwmUeN7tkysslb2eSl6CTrYz6oEMQg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [linux] - '@esbuild/linux-arm64@0.25.0': resolution: {integrity: sha512-9QAQjTWNDM/Vk2bgBl17yWuZxZNQIF0OUUuPZRKoDtqF2k4EtYbpyiG5/Dk7nqeK6kIJWPYldkOcBqjXjrUlmg==} engines: {node: '>=18'} cpu: [arm64] os: [linux] - '@esbuild/linux-arm@0.24.2': - resolution: {integrity: sha512-n0WRM/gWIdU29J57hJyUdIsk0WarGd6To0s+Y+LwvlC55wt+GT/OgkwoXCXvIue1i1sSNWblHEig00GBWiJgfA==} - engines: {node: '>=18'} - cpu: [arm] - os: [linux] - '@esbuild/linux-arm@0.25.0': resolution: {integrity: sha512-vkB3IYj2IDo3g9xX7HqhPYxVkNQe8qTK55fraQyTzTX/fxaDtXiEnavv9geOsonh2Fd2RMB+i5cbhu2zMNWJwg==} engines: {node: '>=18'} cpu: [arm] os: [linux] - '@esbuild/linux-ia32@0.24.2': - resolution: {integrity: sha512-sfv0tGPQhcZOgTKO3oBE9xpHuUqguHvSo4jl+wjnKwFpapx+vUDcawbwPNuBIAYdRAvIDBfZVvXprIj3HA+Ugw==} - engines: {node: '>=18'} - cpu: [ia32] - os: [linux] - '@esbuild/linux-ia32@0.25.0': resolution: {integrity: sha512-43ET5bHbphBegyeqLb7I1eYn2P/JYGNmzzdidq/w0T8E2SsYL1U6un2NFROFRg1JZLTzdCoRomg8Rvf9M6W6Gg==} engines: {node: '>=18'} cpu: [ia32] os: [linux] - '@esbuild/linux-loong64@0.24.2': - resolution: {integrity: sha512-CN9AZr8kEndGooS35ntToZLTQLHEjtVB5n7dl8ZcTZMonJ7CCfStrYhrzF97eAecqVbVJ7APOEe18RPI4KLhwQ==} - engines: {node: '>=18'} - cpu: [loong64] - os: [linux] - '@esbuild/linux-loong64@0.25.0': resolution: {integrity: sha512-fC95c/xyNFueMhClxJmeRIj2yrSMdDfmqJnyOY4ZqsALkDrrKJfIg5NTMSzVBr5YW1jf+l7/cndBfP3MSDpoHw==} engines: {node: '>=18'} cpu: [loong64] os: [linux] - '@esbuild/linux-mips64el@0.24.2': - resolution: {integrity: sha512-iMkk7qr/wl3exJATwkISxI7kTcmHKE+BlymIAbHO8xanq/TjHaaVThFF6ipWzPHryoFsesNQJPE/3wFJw4+huw==} - engines: {node: '>=18'} - cpu: [mips64el] - os: [linux] - '@esbuild/linux-mips64el@0.25.0': resolution: {integrity: sha512-nkAMFju7KDW73T1DdH7glcyIptm95a7Le8irTQNO/qtkoyypZAnjchQgooFUDQhNAy4iu08N79W4T4pMBwhPwQ==} engines: {node: '>=18'} cpu: [mips64el] os: [linux] - '@esbuild/linux-ppc64@0.24.2': - resolution: {integrity: sha512-shsVrgCZ57Vr2L8mm39kO5PPIb+843FStGt7sGGoqiiWYconSxwTiuswC1VJZLCjNiMLAMh34jg4VSEQb+iEbw==} - engines: {node: '>=18'} - cpu: [ppc64] - os: [linux] - '@esbuild/linux-ppc64@0.25.0': resolution: {integrity: sha512-NhyOejdhRGS8Iwv+KKR2zTq2PpysF9XqY+Zk77vQHqNbo/PwZCzB5/h7VGuREZm1fixhs4Q/qWRSi5zmAiO4Fw==} engines: {node: '>=18'} cpu: [ppc64] os: [linux] - '@esbuild/linux-riscv64@0.24.2': - resolution: {integrity: sha512-4eSFWnU9Hhd68fW16GD0TINewo1L6dRrB+oLNNbYyMUAeOD2yCK5KXGK1GH4qD/kT+bTEXjsyTCiJGHPZ3eM9Q==} - engines: {node: '>=18'} - cpu: [riscv64] - os: [linux] - '@esbuild/linux-riscv64@0.25.0': resolution: {integrity: sha512-5S/rbP5OY+GHLC5qXp1y/Mx//e92L1YDqkiBbO9TQOvuFXM+iDqUNG5XopAnXoRH3FjIUDkeGcY1cgNvnXp/kA==} engines: {node: '>=18'} cpu: [riscv64] os: [linux] - '@esbuild/linux-s390x@0.24.2': - resolution: {integrity: sha512-S0Bh0A53b0YHL2XEXC20bHLuGMOhFDO6GN4b3YjRLK//Ep3ql3erpNcPlEFed93hsQAjAQDNsvcK+hV90FubSw==} - engines: {node: '>=18'} - cpu: [s390x] - os: [linux] - '@esbuild/linux-s390x@0.25.0': resolution: {integrity: sha512-XM2BFsEBz0Fw37V0zU4CXfcfuACMrppsMFKdYY2WuTS3yi8O1nFOhil/xhKTmE1nPmVyvQJjJivgDT+xh8pXJA==} engines: {node: '>=18'} cpu: [s390x] os: [linux] - '@esbuild/linux-x64@0.24.2': - resolution: {integrity: sha512-8Qi4nQcCTbLnK9WoMjdC9NiTG6/E38RNICU6sUNqK0QFxCYgoARqVqxdFmWkdonVsvGqWhmm7MO0jyTqLqwj0Q==} - engines: {node: '>=18'} - cpu: [x64] - os: [linux] - '@esbuild/linux-x64@0.25.0': resolution: {integrity: sha512-9yl91rHw/cpwMCNytUDxwj2XjFpxML0y9HAOH9pNVQDpQrBxHy01Dx+vaMu0N1CKa/RzBD2hB4u//nfc+Sd3Cw==} engines: {node: '>=18'} cpu: [x64] os: [linux] - '@esbuild/netbsd-arm64@0.24.2': - resolution: {integrity: sha512-wuLK/VztRRpMt9zyHSazyCVdCXlpHkKm34WUyinD2lzK07FAHTq0KQvZZlXikNWkDGoT6x3TD51jKQ7gMVpopw==} - engines: {node: '>=18'} - cpu: [arm64] - os: [netbsd] - '@esbuild/netbsd-arm64@0.25.0': resolution: {integrity: sha512-RuG4PSMPFfrkH6UwCAqBzauBWTygTvb1nxWasEJooGSJ/NwRw7b2HOwyRTQIU97Hq37l3npXoZGYMy3b3xYvPw==} engines: {node: '>=18'} cpu: [arm64] os: [netbsd] - '@esbuild/netbsd-x64@0.24.2': - resolution: {integrity: sha512-VefFaQUc4FMmJuAxmIHgUmfNiLXY438XrL4GDNV1Y1H/RW3qow68xTwjZKfj/+Plp9NANmzbH5R40Meudu8mmw==} - engines: {node: '>=18'} - cpu: [x64] - os: [netbsd] - '@esbuild/netbsd-x64@0.25.0': resolution: {integrity: sha512-jl+qisSB5jk01N5f7sPCsBENCOlPiS/xptD5yxOx2oqQfyourJwIKLRA2yqWdifj3owQZCL2sn6o08dBzZGQzA==} engines: {node: '>=18'} cpu: [x64] os: [netbsd] - '@esbuild/openbsd-arm64@0.24.2': - resolution: {integrity: sha512-YQbi46SBct6iKnszhSvdluqDmxCJA+Pu280Av9WICNwQmMxV7nLRHZfjQzwbPs3jeWnuAhE9Jy0NrnJ12Oz+0A==} - engines: {node: '>=18'} - cpu: [arm64] - os: [openbsd] - '@esbuild/openbsd-arm64@0.25.0': resolution: {integrity: sha512-21sUNbq2r84YE+SJDfaQRvdgznTD8Xc0oc3p3iW/a1EVWeNj/SdUCbm5U0itZPQYRuRTW20fPMWMpcrciH2EJw==} engines: {node: '>=18'} cpu: [arm64] os: [openbsd] - '@esbuild/openbsd-x64@0.24.2': - resolution: {integrity: sha512-+iDS6zpNM6EnJyWv0bMGLWSWeXGN/HTaF/LXHXHwejGsVi+ooqDfMCCTerNFxEkM3wYVcExkeGXNqshc9iMaOA==} - engines: {node: '>=18'} - cpu: [x64] - os: [openbsd] - '@esbuild/openbsd-x64@0.25.0': resolution: {integrity: sha512-2gwwriSMPcCFRlPlKx3zLQhfN/2WjJ2NSlg5TKLQOJdV0mSxIcYNTMhk3H3ulL/cak+Xj0lY1Ym9ysDV1igceg==} engines: {node: '>=18'} cpu: [x64] os: [openbsd] - '@esbuild/sunos-x64@0.24.2': - resolution: {integrity: sha512-hTdsW27jcktEvpwNHJU4ZwWFGkz2zRJUz8pvddmXPtXDzVKTTINmlmga3ZzwcuMpUvLw7JkLy9QLKyGpD2Yxig==} - engines: {node: '>=18'} - cpu: [x64] - os: [sunos] - '@esbuild/sunos-x64@0.25.0': resolution: {integrity: sha512-bxI7ThgLzPrPz484/S9jLlvUAHYMzy6I0XiU1ZMeAEOBcS0VePBFxh1JjTQt3Xiat5b6Oh4x7UC7IwKQKIJRIg==} engines: {node: '>=18'} cpu: [x64] os: [sunos] - '@esbuild/win32-arm64@0.24.2': - resolution: {integrity: sha512-LihEQ2BBKVFLOC9ZItT9iFprsE9tqjDjnbulhHoFxYQtQfai7qfluVODIYxt1PgdoyQkz23+01rzwNwYfutxUQ==} - engines: {node: '>=18'} - cpu: [arm64] - os: [win32] - '@esbuild/win32-arm64@0.25.0': resolution: {integrity: sha512-ZUAc2YK6JW89xTbXvftxdnYy3m4iHIkDtK3CLce8wg8M2L+YZhIvO1DKpxrd0Yr59AeNNkTiic9YLf6FTtXWMw==} engines: {node: '>=18'} cpu: [arm64] os: [win32] - '@esbuild/win32-ia32@0.24.2': - resolution: {integrity: sha512-q+iGUwfs8tncmFC9pcnD5IvRHAzmbwQ3GPS5/ceCyHdjXubwQWI12MKWSNSMYLJMq23/IUCvJMS76PDqXe1fxA==} - engines: {node: '>=18'} - cpu: [ia32] - os: [win32] - '@esbuild/win32-ia32@0.25.0': resolution: {integrity: sha512-eSNxISBu8XweVEWG31/JzjkIGbGIJN/TrRoiSVZwZ6pkC6VX4Im/WV2cz559/TXLcYbcrDN8JtKgd9DJVIo8GA==} engines: {node: '>=18'} cpu: [ia32] os: [win32] - '@esbuild/win32-x64@0.24.2': - resolution: {integrity: sha512-7VTgWzgMGvup6aSqDPLiW5zHaxYJGTO4OokMjIlrCtf+VpEL+cXKtCvg723iguPYI5oaUNdS+/V7OU2gvXVWEg==} - engines: {node: '>=18'} - cpu: [x64] - os: [win32] - '@esbuild/win32-x64@0.25.0': resolution: {integrity: sha512-ZENoHJBxA20C2zFzh6AI4fT6RraMzjYw4xKWemRTRmRVtN9c5DcH9r/f2ihEkMjOW5eGgrwCslG/+Y/3bL+DHQ==} engines: {node: '>=18'} @@ -863,11 +713,6 @@ packages: es-module-lexer@1.6.0: resolution: {integrity: sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==} - esbuild@0.24.2: - resolution: {integrity: sha512-+9egpBW8I3CD5XPe0n6BfT5fxLzxrlDzqydF3aviG+9ni1lDC/OvMHcxqEFV0+LANZG5R1bFMWfUrjVsdwxJvA==} - engines: {node: '>=18'} - hasBin: true - esbuild@0.25.0: resolution: {integrity: sha512-BXq5mqc8ltbaN34cDqWuYKyNhX8D/Z0J1xdtdQ8UcIIIyJyz+ZMKUt58tF3SrZ85jcfN/PZYhjR5uDQAYNVbuw==} engines: {node: '>=18'} @@ -1249,8 +1094,8 @@ packages: yaml: optional: true - postcss@8.5.1: - resolution: {integrity: sha512-6oz2beyjc5VMn/KV1pPw8fliQkhBXrVn1Z3TVyqZxU8kZpzEKhBdmCFqI6ZbmGtamQvQGuU1sgPTk8ZrXDD7jQ==} + postcss@8.5.3: + resolution: {integrity: sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==} engines: {node: ^10 || ^12 || >=14} prettier@2.8.8: @@ -1541,8 +1386,8 @@ packages: engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true - vite@6.1.0: - resolution: {integrity: sha512-RjjMipCKVoR4hVfPY6GQTgveinjNuyLw+qruksLDvA5ktI1150VmcMBKmQaEWJhg/j6Uaf6dNCNA0AfdzUb/hQ==} + vite@6.2.6: + resolution: {integrity: sha512-9xpjNl3kR4rVDZgPNdTL0/c6ao4km69a/2ihNQbcANz8RuCOK3hQBmLSJf3bRKVQjVMda+YvizNE8AwvogcPbw==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true peerDependencies: @@ -1815,153 +1660,78 @@ snapshots: dependencies: '@bufbuild/protobuf': 2.2.2 - '@esbuild/aix-ppc64@0.24.2': - optional: true - '@esbuild/aix-ppc64@0.25.0': optional: true - '@esbuild/android-arm64@0.24.2': - optional: true - '@esbuild/android-arm64@0.25.0': optional: true - '@esbuild/android-arm@0.24.2': - optional: true - '@esbuild/android-arm@0.25.0': optional: true - '@esbuild/android-x64@0.24.2': - optional: true - '@esbuild/android-x64@0.25.0': optional: true - '@esbuild/darwin-arm64@0.24.2': - optional: true - '@esbuild/darwin-arm64@0.25.0': optional: true - '@esbuild/darwin-x64@0.24.2': - optional: true - '@esbuild/darwin-x64@0.25.0': optional: true - '@esbuild/freebsd-arm64@0.24.2': - optional: true - '@esbuild/freebsd-arm64@0.25.0': optional: true - '@esbuild/freebsd-x64@0.24.2': - optional: true - '@esbuild/freebsd-x64@0.25.0': optional: true - '@esbuild/linux-arm64@0.24.2': - optional: true - '@esbuild/linux-arm64@0.25.0': optional: true - '@esbuild/linux-arm@0.24.2': - optional: true - '@esbuild/linux-arm@0.25.0': optional: true - '@esbuild/linux-ia32@0.24.2': - optional: true - '@esbuild/linux-ia32@0.25.0': optional: true - '@esbuild/linux-loong64@0.24.2': - optional: true - '@esbuild/linux-loong64@0.25.0': optional: true - '@esbuild/linux-mips64el@0.24.2': - optional: true - '@esbuild/linux-mips64el@0.25.0': optional: true - '@esbuild/linux-ppc64@0.24.2': - optional: true - '@esbuild/linux-ppc64@0.25.0': optional: true - '@esbuild/linux-riscv64@0.24.2': - optional: true - '@esbuild/linux-riscv64@0.25.0': optional: true - '@esbuild/linux-s390x@0.24.2': - optional: true - '@esbuild/linux-s390x@0.25.0': optional: true - '@esbuild/linux-x64@0.24.2': - optional: true - '@esbuild/linux-x64@0.25.0': optional: true - '@esbuild/netbsd-arm64@0.24.2': - optional: true - '@esbuild/netbsd-arm64@0.25.0': optional: true - '@esbuild/netbsd-x64@0.24.2': - optional: true - '@esbuild/netbsd-x64@0.25.0': optional: true - '@esbuild/openbsd-arm64@0.24.2': - optional: true - '@esbuild/openbsd-arm64@0.25.0': optional: true - '@esbuild/openbsd-x64@0.24.2': - optional: true - '@esbuild/openbsd-x64@0.25.0': optional: true - '@esbuild/sunos-x64@0.24.2': - optional: true - '@esbuild/sunos-x64@0.25.0': optional: true - '@esbuild/win32-arm64@0.24.2': - optional: true - '@esbuild/win32-arm64@0.25.0': optional: true - '@esbuild/win32-ia32@0.24.2': - optional: true - '@esbuild/win32-ia32@0.25.0': optional: true - '@esbuild/win32-x64@0.24.2': - optional: true - '@esbuild/win32-x64@0.25.0': optional: true @@ -2162,13 +1932,13 @@ snapshots: chai: 5.2.0 tinyrainbow: 2.0.0 - '@vitest/mocker@3.1.1(vite@6.1.0(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0))': + '@vitest/mocker@3.1.1(vite@6.2.6(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0))': dependencies: '@vitest/spy': 3.1.1 estree-walker: 3.0.3 magic-string: 0.30.17 optionalDependencies: - vite: 6.1.0(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0) + vite: 6.2.6(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0) '@vitest/pretty-format@3.1.1': dependencies: @@ -2361,34 +2131,6 @@ snapshots: es-module-lexer@1.6.0: {} - esbuild@0.24.2: - optionalDependencies: - '@esbuild/aix-ppc64': 0.24.2 - '@esbuild/android-arm': 0.24.2 - '@esbuild/android-arm64': 0.24.2 - '@esbuild/android-x64': 0.24.2 - '@esbuild/darwin-arm64': 0.24.2 - '@esbuild/darwin-x64': 0.24.2 - '@esbuild/freebsd-arm64': 0.24.2 - '@esbuild/freebsd-x64': 0.24.2 - '@esbuild/linux-arm': 0.24.2 - '@esbuild/linux-arm64': 0.24.2 - '@esbuild/linux-ia32': 0.24.2 - '@esbuild/linux-loong64': 0.24.2 - '@esbuild/linux-mips64el': 0.24.2 - '@esbuild/linux-ppc64': 0.24.2 - '@esbuild/linux-riscv64': 0.24.2 - '@esbuild/linux-s390x': 0.24.2 - '@esbuild/linux-x64': 0.24.2 - '@esbuild/netbsd-arm64': 0.24.2 - '@esbuild/netbsd-x64': 0.24.2 - '@esbuild/openbsd-arm64': 0.24.2 - '@esbuild/openbsd-x64': 0.24.2 - '@esbuild/sunos-x64': 0.24.2 - '@esbuild/win32-arm64': 0.24.2 - '@esbuild/win32-ia32': 0.24.2 - '@esbuild/win32-x64': 0.24.2 - esbuild@0.25.0: optionalDependencies: '@esbuild/aix-ppc64': 0.25.0 @@ -2763,15 +2505,15 @@ snapshots: platform@1.3.6: {} - postcss-load-config@6.0.1(jiti@2.4.2)(postcss@8.5.1)(yaml@2.7.0): + postcss-load-config@6.0.1(jiti@2.4.2)(postcss@8.5.3)(yaml@2.7.0): dependencies: lilconfig: 3.1.2 optionalDependencies: jiti: 2.4.2 - postcss: 8.5.1 + postcss: 8.5.3 yaml: 2.7.0 - postcss@8.5.1: + postcss@8.5.3: dependencies: nanoid: 3.3.8 picocolors: 1.1.1 @@ -2983,7 +2725,7 @@ snapshots: ts-interface-checker@0.1.13: {} - tsup@8.4.0(jiti@2.4.2)(postcss@8.5.1)(typescript@5.7.3)(yaml@2.7.0): + tsup@8.4.0(jiti@2.4.2)(postcss@8.5.3)(typescript@5.7.3)(yaml@2.7.0): dependencies: bundle-require: 5.1.0(esbuild@0.25.0) cac: 6.7.14 @@ -2993,7 +2735,7 @@ snapshots: esbuild: 0.25.0 joycon: 3.1.1 picocolors: 1.1.1 - postcss-load-config: 6.0.1(jiti@2.4.2)(postcss@8.5.1)(yaml@2.7.0) + postcss-load-config: 6.0.1(jiti@2.4.2)(postcss@8.5.3)(yaml@2.7.0) resolve-from: 5.0.0 rollup: 4.39.0 source-map: 0.8.0-beta.0 @@ -3002,7 +2744,7 @@ snapshots: tinyglobby: 0.2.12 tree-kill: 1.2.2 optionalDependencies: - postcss: 8.5.1 + postcss: 8.5.3 typescript: 5.7.3 transitivePeerDependencies: - jiti @@ -3074,7 +2816,7 @@ snapshots: debug: 4.4.0 es-module-lexer: 1.6.0 pathe: 2.0.3 - vite: 6.1.0(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0) + vite: 6.2.6(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0) transitivePeerDependencies: - '@types/node' - jiti @@ -3089,10 +2831,10 @@ snapshots: - tsx - yaml - vite@6.1.0(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0): + vite@6.2.6(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0): dependencies: - esbuild: 0.24.2 - postcss: 8.5.1 + esbuild: 0.25.0 + postcss: 8.5.3 rollup: 4.39.0 optionalDependencies: '@types/node': 18.19.75 @@ -3103,7 +2845,7 @@ snapshots: vitest@3.1.1(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0): dependencies: '@vitest/expect': 3.1.1 - '@vitest/mocker': 3.1.1(vite@6.1.0(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0)) + '@vitest/mocker': 3.1.1(vite@6.2.6(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0)) '@vitest/pretty-format': 3.1.1 '@vitest/runner': 3.1.1 '@vitest/snapshot': 3.1.1 @@ -3119,7 +2861,7 @@ snapshots: tinyexec: 0.3.2 tinypool: 1.0.2 tinyrainbow: 2.0.0 - vite: 6.1.0(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0) + vite: 6.2.6(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0) vite-node: 3.1.1(@types/node@18.19.75)(jiti@2.4.2)(yaml@2.7.0) why-is-node-running: 2.3.0 optionalDependencies: diff --git a/python/poetry.lock b/python/poetry.lock index 1bd62420..cc005e6e 100644 --- a/python/poetry.lock +++ b/python/poetry.lock @@ -498,14 +498,14 @@ files = [ [[package]] name = "jinja2" -version = "3.1.5" +version = "3.1.6" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" groups = ["dev"] files = [ - {file = "jinja2-3.1.5-py3-none-any.whl", hash = "sha256:aba0f4dc9ed8013c424088f68a5c226f7d6097ed89b246d7749c2ec4175c6adb"}, - {file = "jinja2-3.1.5.tar.gz", hash = "sha256:8fefff8dc3034e27bb80d67c671eb8a9bc424c0ef4c0826edbff304cceff43bb"}, + {file = "jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67"}, + {file = "jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"}, ] [package.dependencies] From 2ee6ffb9aa6cae3f48cb230898dcc08ba0fcb535 Mon Sep 17 00:00:00 2001 From: Jakub Dobry Date: Wed, 30 Apr 2025 09:27:51 +0200 Subject: [PATCH 05/27] Update JS SDK target to es2017 (#96) * Update JS SDK target to es2017 * Add changeset --- .changeset/salty-ideas-own.md | 5 +++++ js/tsup.config.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/salty-ideas-own.md diff --git a/.changeset/salty-ideas-own.md b/.changeset/salty-ideas-own.md new file mode 100644 index 00000000..4eaae97e --- /dev/null +++ b/.changeset/salty-ideas-own.md @@ -0,0 +1,5 @@ +--- +'@e2b/code-interpreter': minor +--- + +Update JS SDK target to es2017 diff --git a/js/tsup.config.js b/js/tsup.config.js index 80616774..c63b850f 100644 --- a/js/tsup.config.js +++ b/js/tsup.config.js @@ -2,7 +2,7 @@ import { defineConfig } from 'tsup' export default defineConfig({ minify: false, - target: ['es2015'], + target: ['es2017'], sourcemap: true, dts: true, format: ['esm', 'cjs'], From 3be5d224f8678fcac7c77757593fb5700dc945b7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 30 Apr 2025 07:29:28 +0000 Subject: [PATCH 06/27] [skip ci] Release new versions --- .changeset/salty-ideas-own.md | 5 - js/package.json | 2 +- .../v1.2.0/charts/page.mdx | 240 +++++++++++++ .../v1.2.0/consts/page.mdx | 13 + .../v1.2.0/index/page.mdx | 103 ++++++ .../v1.2.0/messaging/page.mdx | 326 +++++++++++++++++ .../v1.2.0/sandbox/page.mdx | 312 ++++++++++++++++ .../v1.2.1/sandbox/page.mdx | 336 +++++++++--------- 8 files changed, 1163 insertions(+), 174 deletions(-) delete mode 100644 .changeset/salty-ideas-own.md create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.2.0/charts/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.2.0/consts/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.2.0/index/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.2.0/messaging/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.2.0/sandbox/page.mdx diff --git a/.changeset/salty-ideas-own.md b/.changeset/salty-ideas-own.md deleted file mode 100644 index 4eaae97e..00000000 --- a/.changeset/salty-ideas-own.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@e2b/code-interpreter': minor ---- - -Update JS SDK target to es2017 diff --git a/js/package.json b/js/package.json index 9c3f546f..868606d3 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "@e2b/code-interpreter", - "version": "1.1.1", + "version": "1.2.0", "packageManager": "pnpm@8.7.6", "description": "E2B Code Interpreter - Stateful code execution", "homepage": "https://e2b.dev", diff --git a/sdk-reference/code-interpreter-js-sdk/v1.2.0/charts/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.2.0/charts/page.mdx new file mode 100644 index 00000000..f3176d3b --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.2.0/charts/page.mdx @@ -0,0 +1,240 @@ +### ChartType + +Chart types + +#### Enumeration Members + +| Enumeration Member | Value | +| ------ | ------ | +| `BAR` | `"bar"` | +| `BOX_AND_WHISKER` | `"box_and_whisker"` | +| `LINE` | `"line"` | +| `PIE` | `"pie"` | +| `SCATTER` | `"scatter"` | +| `SUPERCHART` | `"superchart"` | +| `UNKNOWN` | `"unknown"` | + +*** + +### ScaleType + +Ax scale types + +#### Enumeration Members + +| Enumeration Member | Value | +| ------ | ------ | +| `ASINH` | `"asinh"` | +| `CATEGORICAL` | `"categorical"` | +| `DATETIME` | `"datetime"` | +| `FUNCTION` | `"function"` | +| `FUNCTIONLOG` | `"functionlog"` | +| `LINEAR` | `"linear"` | +| `LOG` | `"log"` | +| `LOGIT` | `"logit"` | +| `SYMLOG` | `"symlog"` | + +## Type Aliases + +### BarChart + +```ts +type BarChart: Chart2D & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `BarData`[] | +| `type` | `ChartType.BAR` | + +*** + +### BarData + +```ts +type BarData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `group` | `string` | +| `label` | `string` | +| `value` | `string` | + +*** + +### BoxAndWhiskerChart + +```ts +type BoxAndWhiskerChart: Chart2D & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `BoxAndWhiskerData`[] | +| `type` | `ChartType.BOX_AND_WHISKER` | + +*** + +### BoxAndWhiskerData + +```ts +type BoxAndWhiskerData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `first_quartile` | `number` | +| `label` | `string` | +| `max` | `number` | +| `median` | `number` | +| `min` | `number` | +| `outliers` | `number`[] | +| `third_quartile` | `number` | + +*** + +### Chart + +```ts +type Chart: object; +``` + +Represents a chart. + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `any`[] | +| `title` | `string` | +| `type` | `ChartType` | + +*** + +### ChartTypes + +```ts +type ChartTypes: + | LineChart + | ScatterChart + | BarChart + | PieChart + | BoxAndWhiskerChart + | SuperChart; +``` + +*** + +### LineChart + +```ts +type LineChart: PointChart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `type` | `ChartType.LINE` | + +*** + +### PieChart + +```ts +type PieChart: Chart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `PieData`[] | +| `type` | `ChartType.PIE` | + +*** + +### PieData + +```ts +type PieData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `angle` | `number` | +| `label` | `string` | +| `radius` | `number` | + +*** + +### PointData + +```ts +type PointData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `label` | `string` | +| `points` | [`number` \| `string`, `number` \| `string`][] | + +*** + +### ScatterChart + +```ts +type ScatterChart: PointChart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `type` | `ChartType.SCATTER` | + +*** + +### SuperChart + +```ts +type SuperChart: Chart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `Chart`[] | +| `type` | `ChartType.SUPERCHART` | + +## Functions + +### deserializeChart() + +```ts +function deserializeChart(data: any): Chart +``` + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| `data` | `any` | + +#### Returns + +`Chart` diff --git a/sdk-reference/code-interpreter-js-sdk/v1.2.0/consts/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.2.0/consts/page.mdx new file mode 100644 index 00000000..d1ee2e76 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.2.0/consts/page.mdx @@ -0,0 +1,13 @@ +### DEFAULT\_TIMEOUT\_MS + +```ts +const DEFAULT_TIMEOUT_MS: 60000 = 60_000; +``` + +*** + +### JUPYTER\_PORT + +```ts +const JUPYTER_PORT: 49999 = 49999; +``` diff --git a/sdk-reference/code-interpreter-js-sdk/v1.2.0/index/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.2.0/index/page.mdx new file mode 100644 index 00000000..dc55fcc7 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.2.0/index/page.mdx @@ -0,0 +1,103 @@ +### BarChart + +Re-exports BarChart + +### BarData + +Re-exports BarData + +### BoxAndWhiskerChart + +Re-exports BoxAndWhiskerChart + +### BoxAndWhiskerData + +Re-exports BoxAndWhiskerData + +### Chart + +Re-exports Chart + +### ChartType + +Re-exports ChartType + +### ChartTypes + +Re-exports ChartTypes + +### Context + +Re-exports Context + +### CreateCodeContextOpts + +Re-exports CreateCodeContextOpts + +### default + +Renames and re-exports Sandbox + +### Execution + +Re-exports Execution + +### ExecutionError + +Re-exports ExecutionError + +### LineChart + +Re-exports LineChart + +### Logs + +Re-exports Logs + +### MIMEType + +Re-exports MIMEType + +### OutputMessage + +Re-exports OutputMessage + +### PieChart + +Re-exports PieChart + +### PieData + +Re-exports PieData + +### PointData + +Re-exports PointData + +### RawData + +Re-exports RawData + +### Result + +Re-exports Result + +### RunCodeOpts + +Re-exports RunCodeOpts + +### Sandbox + +Re-exports Sandbox + +### ScaleType + +Re-exports ScaleType + +### ScatterChart + +Re-exports ScatterChart + +### SuperChart + +Re-exports SuperChart diff --git a/sdk-reference/code-interpreter-js-sdk/v1.2.0/messaging/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.2.0/messaging/page.mdx new file mode 100644 index 00000000..4b3c4ed9 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.2.0/messaging/page.mdx @@ -0,0 +1,326 @@ +### Execution + +Represents the result of a cell execution. + +#### Constructors + +```ts +new Execution( + results: Result[], + logs: Logs, + error?: ExecutionError, + executionCount?: number): Execution +``` + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `results` | `Result`[] | `[]` | List of result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots). | +| `logs` | `Logs` | `...` | Logs printed to stdout and stderr during execution. | +| `error`? | `ExecutionError` | `undefined` | An Error object if an error occurred, null otherwise. | +| `executionCount`? | `number` | `undefined` | Execution count of the cell. | + +###### Returns + +`Execution` + +#### Properties + +| Property | Modifier | Type | Default value | Description | +| ------ | ------ | ------ | ------ | ------ | +| `error?` | `public` | `ExecutionError` | `undefined` | An Error object if an error occurred, null otherwise. | +| `executionCount?` | `public` | `number` | `undefined` | Execution count of the cell. | +| `logs` | `public` | `Logs` | `undefined` | Logs printed to stdout and stderr during execution. | +| `results` | `public` | `Result`[] | `[]` | List of result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots). | + +#### Accessors + +### text + +```ts +get text(): undefined | string +``` + +Returns the text representation of the main result of the cell. + +###### Returns + +`undefined` \| `string` + +#### Methods + +### toJSON() + +```ts +toJSON(): object +``` + +Returns the serializable representation of the execution result. + +###### Returns + +`object` + +| Name | Type | +| ------ | ------ | +| `error` | `undefined` \| `ExecutionError` | +| `logs` | `Logs` | +| `results` | `Result`[] | + +*** + +### ExecutionError + +Represents an error that occurred during the execution of a cell. +The error contains the name of the error, the value of the error, and the traceback. + +#### Constructors + +```ts +new ExecutionError( + name: string, + value: string, + traceback: string): ExecutionError +``` + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `name` | `string` | Name of the error. | +| `value` | `string` | Value of the error. | +| `traceback` | `string` | The raw traceback of the error. | + +###### Returns + +`ExecutionError` + +#### Properties + +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `name` | `public` | `string` | Name of the error. | +| `traceback` | `public` | `string` | The raw traceback of the error. | +| `value` | `public` | `string` | Value of the error. | + +*** + +### OutputMessage + +Represents an output message from the sandbox code execution. + +#### Constructors + +```ts +new OutputMessage( + line: string, + timestamp: number, + error: boolean): OutputMessage +``` + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `line` | `string` | The output line. | +| `timestamp` | `number` | Unix epoch in nanoseconds. | +| `error` | `boolean` | Whether the output is an error. | + +###### Returns + +`OutputMessage` + +#### Properties + +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `error` | `readonly` | `boolean` | Whether the output is an error. | +| `line` | `readonly` | `string` | The output line. | +| `timestamp` | `readonly` | `number` | Unix epoch in nanoseconds. | + +#### Methods + +### toString() + +```ts +toString(): string +``` + +###### Returns + +`string` + +*** + +### Result + +Represents the data to be displayed as a result of executing a cell in a Jupyter notebook. +The result is similar to the structure returned by ipython kernel: https://ipython.readthedocs.io/en/stable/development/execution.html#execution-semantics + +The result can contain multiple types of data, such as text, images, plots, etc. Each type of data is represented +as a string, and the result can contain multiple types of data. The display calls don't have to have text representation, +for the actual result the representation is always present for the result, the other representations are always optional. + +#### Constructors + +```ts +new Result(rawData: RawData, isMainResult: boolean): Result +``` + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `rawData` | `RawData` | +| `isMainResult` | `boolean` | + +###### Returns + +`Result` + +#### Properties + +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `chart?` | `readonly` | `ChartTypes` | Contains the chart data. | +| `data?` | `readonly` | `Record`\<`string`, `unknown`\> | Contains the data from DataFrame. | +| `extra?` | `readonly` | `any` | Extra data that can be included. Not part of the standard types. | +| `html?` | `readonly` | `string` | HTML representation of the data. | +| `isMainResult` | `readonly` | `boolean` | - | +| `javascript?` | `readonly` | `string` | JavaScript representation of the data. | +| `jpeg?` | `readonly` | `string` | JPEG representation of the data. | +| `json?` | `readonly` | `string` | JSON representation of the data. | +| `latex?` | `readonly` | `string` | LaTeX representation of the data. | +| `markdown?` | `readonly` | `string` | Markdown representation of the data. | +| `pdf?` | `readonly` | `string` | PDF representation of the data. | +| `png?` | `readonly` | `string` | PNG representation of the data. | +| `raw` | `readonly` | `RawData` | - | +| `svg?` | `readonly` | `string` | SVG representation of the data. | +| `text?` | `readonly` | `string` | Text representation of the result. | + +#### Methods + +### formats() + +```ts +formats(): string[] +``` + +Returns all the formats available for the result. + +###### Returns + +`string`[] + +Array of strings representing the formats available for the result. + +### toJSON() + +```ts +toJSON(): object +``` + +Returns the serializable representation of the result. + +###### Returns + +`object` + +| Name | Type | +| ------ | ------ | +| `extra`? | `any` | +| `html` | `undefined` \| `string` | +| `javascript` | `undefined` \| `string` | +| `jpeg` | `undefined` \| `string` | +| `json` | `undefined` \| `string` | +| `latex` | `undefined` \| `string` | +| `markdown` | `undefined` \| `string` | +| `pdf` | `undefined` \| `string` | +| `png` | `undefined` \| `string` | +| `svg` | `undefined` \| `string` | +| `text` | `undefined` \| `string` | + +## Type Aliases + +### Logs + +```ts +type Logs: object; +``` + +Data printed to stdout and stderr during execution, usually by print statements, logs, warnings, subprocesses, etc. + +#### Type declaration + +| Name | Type | Description | +| ------ | ------ | ------ | +| `stderr` | `string`[] | List of strings printed to stderr by prints, subprocesses, etc. | +| `stdout` | `string`[] | List of strings printed to stdout by prints, subprocesses, etc. | + +*** + +### MIMEType + +```ts +type MIMEType: string; +``` + +Represents a MIME type. + +*** + +### RawData + +```ts +type RawData: object & E2BData; +``` + +Dictionary that maps MIME types to their corresponding representations of the data. + +## Functions + +### extractError() + +```ts +function extractError(res: Response): Promise +``` + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| `res` | `Response` | + +#### Returns + +`Promise`\<`undefined` \| `SandboxError`\> + +*** + +### parseOutput() + +```ts +function parseOutput( + execution: Execution, + line: string, + onStdout?: (output: OutputMessage) => any, + onStderr?: (output: OutputMessage) => any, + onResult?: (data: Result) => any, +onError?: (error: ExecutionError) => any): Promise +``` + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| `execution` | `Execution` | +| `line` | `string` | +| `onStdout`? | (`output`: `OutputMessage`) => `any` | +| `onStderr`? | (`output`: `OutputMessage`) => `any` | +| `onResult`? | (`data`: `Result`) => `any` | +| `onError`? | (`error`: `ExecutionError`) => `any` | + +#### Returns + +`Promise`\<`void`\> diff --git a/sdk-reference/code-interpreter-js-sdk/v1.2.0/sandbox/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.2.0/sandbox/page.mdx new file mode 100644 index 00000000..96eafec5 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.2.0/sandbox/page.mdx @@ -0,0 +1,312 @@ +### Sandbox + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs here. + +Use Sandbox.create to create a new sandbox. + +#### Example + +```ts +import { Sandbox } from '@e2b/code-interpreter' + +const sandbox = await Sandbox.create() +``` + +#### Methods + +### createCodeContext() + +```ts +createCodeContext(opts?: CreateCodeContextOpts): Promise +``` + +Creates a new context to run code in. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `opts`? | `CreateCodeContextOpts` | options for creating the context. | + +###### Returns + +`Promise`\<`Context`\> + +context object. + +### runCode() + +###### runCode(code, opts) + +```ts +runCode(code: string, opts?: RunCodeOpts & object): Promise +``` + +Run the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `code` | `string` | code to execute. | +| `opts`? | `RunCodeOpts` & `object` | options for executing the code. | + +###### Returns + +`Promise`\<`Execution`\> + +`Execution` result object. + +###### runCode(code, opts) + +```ts +runCode(code: string, opts?: RunCodeOpts & object): Promise +``` + +Run the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `code` | `string` | code to execute. | +| `opts`? | `RunCodeOpts` & `object` | options for executing the code. | + +###### Returns + +`Promise`\<`Execution`\> + +`Execution` result object. + +###### runCode(code, opts) + +```ts +runCode(code: string, opts?: RunCodeOpts & object): Promise +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `code` | `string` | code to execute. | +| `opts`? | `RunCodeOpts` & `object` | options for executing the code | + +###### Returns + +`Promise`\<`Execution`\> + +`Execution` result object + +## Interfaces + +### CreateCodeContextOpts + +Options for creating a code context. + +#### Properties + +### cwd? + +```ts +optional cwd: string; +``` + +Working directory for the context. + +###### Default + +```ts +/home/user +``` + +### language? + +```ts +optional language: string; +``` + +Language for the context. + +###### Default + +```ts +python +``` + +### requestTimeoutMs? + +```ts +optional requestTimeoutMs: number; +``` + +Timeout for the request in **milliseconds**. + +###### Default + +```ts +30_000 // 30 seconds +``` + +*** + +### RunCodeOpts + +Options for running code. + +#### Properties + +### envs? + +```ts +optional envs: Record; +``` + +Custom environment variables for code execution. + +###### Default + +```ts +{} +``` + +### onError()? + +```ts +optional onError: (error: ExecutionError) => any; +``` + +Callback for handling the `ExecutionError` object. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `error` | `ExecutionError` | + +###### Returns + +`any` + +### onResult()? + +```ts +optional onResult: (data: Result) => any; +``` + +Callback for handling the final execution result. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `data` | `Result` | + +###### Returns + +`any` + +### onStderr()? + +```ts +optional onStderr: (output: OutputMessage) => any; +``` + +Callback for handling stderr messages. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `output` | `OutputMessage` | + +###### Returns + +`any` + +### onStdout()? + +```ts +optional onStdout: (output: OutputMessage) => any; +``` + +Callback for handling stdout messages. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `output` | `OutputMessage` | + +###### Returns + +`any` + +### requestTimeoutMs? + +```ts +optional requestTimeoutMs: number; +``` + +Timeout for the request in **milliseconds**. + +###### Default + +```ts +30_000 // 30 seconds +``` + +### timeoutMs? + +```ts +optional timeoutMs: number; +``` + +Timeout for the code execution in **milliseconds**. + +###### Default + +```ts +60_000 // 60 seconds +``` + +## Type Aliases + +### Context + +```ts +type Context: object; +``` + +Represents a context for code execution. + +#### Type declaration + +| Name | Type | Description | +| ------ | ------ | ------ | +| `cwd` | `string` | The working directory of the context. | +| `id` | `string` | The ID of the context. | +| `language` | `string` | The language of the context. | diff --git a/sdk-reference/code-interpreter-python-sdk/v1.2.1/sandbox/page.mdx b/sdk-reference/code-interpreter-python-sdk/v1.2.1/sandbox/page.mdx index 86e0dfaf..19778c89 100644 --- a/sdk-reference/code-interpreter-python-sdk/v1.2.1/sandbox/page.mdx +++ b/sdk-reference/code-interpreter-python-sdk/v1.2.1/sandbox/page.mdx @@ -3,6 +3,174 @@ +## Sandbox + +```python +class Sandbox(BaseSandbox) +``` + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs [here](https://e2b.dev/docs). + +Use the `Sandbox()` to create a new sandbox. + +**Example**: + +```python +from e2b_code_interpreter import Sandbox + +sandbox = Sandbox() +``` + + +### run\_code + +```python +@overload +def run_code(code: str, + language: Union[Literal["python"], None] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +def run_code(code: str, + language: Optional[str] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +def run_code(code: str, + context: Optional[Context] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `context`: Concrete context to run the code in. If not specified, the default context for the language is used. It's mutually exclusive with the language. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### create\_code\_context + +```python +def create_code_context(cwd: Optional[str] = None, + language: Optional[str] = None, + request_timeout: Optional[float] = None) -> Context +``` + +Creates a new context to run code in. + +**Arguments**: + +- `cwd`: Set the current working directory for the context, defaults to `/home/user` +- `language`: Language of the context. If not specified, defaults to Python +- `request_timeout`: Timeout for the request in **milliseconds** + +**Returns**: + +Context object + + + + + + ## ChartType ```python @@ -32,8 +200,6 @@ Extracted data from a chart. It's useful for building an interactive charts or c - - ## OutputMessage ```python @@ -389,8 +555,6 @@ The working directory of the context. - - ## AsyncSandbox ```python @@ -556,167 +720,3 @@ Context object - -## Sandbox - -```python -class Sandbox(BaseSandbox) -``` - -E2B cloud sandbox is a secure and isolated cloud environment. - -The sandbox allows you to: -- Access Linux OS -- Create, list, and delete files and directories -- Run commands -- Run isolated code -- Access the internet - -Check docs [here](https://e2b.dev/docs). - -Use the `Sandbox()` to create a new sandbox. - -**Example**: - -```python -from e2b_code_interpreter import Sandbox - -sandbox = Sandbox() -``` - - -### run\_code - -```python -@overload -def run_code(code: str, - language: Union[Literal["python"], None] = None, - on_stdout: Optional[OutputHandler[OutputMessage]] = None, - on_stderr: Optional[OutputHandler[OutputMessage]] = None, - on_result: Optional[OutputHandler[Result]] = None, - on_error: Optional[OutputHandler[ExecutionError]] = None, - envs: Optional[Dict[str, str]] = None, - timeout: Optional[float] = None, - request_timeout: Optional[float] = None) -> Execution -``` - -Runs the code as Python. - -Specify the `language` or `context` option to run the code as a different language or in a different `Context`. - -You can reference previously defined variables, imports, and functions in the code. - -**Arguments**: - -- `code`: Code to execute -- `language`: Language to use for code execution. If not defined, the default Python context is used. -- `on_stdout`: Callback for stdout messages -- `on_stderr`: Callback for stderr messages -- `on_result`: Callback for the `Result` object -- `on_error`: Callback for the `ExecutionError` object -- `envs`: Custom environment variables -- `timeout`: Timeout for the code execution in **seconds** -- `request_timeout`: Timeout for the request in **seconds** - -**Returns**: - -`Execution` result object - - -### run\_code - -```python -@overload -def run_code(code: str, - language: Optional[str] = None, - on_stdout: Optional[OutputHandler[OutputMessage]] = None, - on_stderr: Optional[OutputHandler[OutputMessage]] = None, - on_result: Optional[OutputHandler[Result]] = None, - on_error: Optional[OutputHandler[ExecutionError]] = None, - envs: Optional[Dict[str, str]] = None, - timeout: Optional[float] = None, - request_timeout: Optional[float] = None) -> Execution -``` - -Runs the code for the specified language. - -Specify the `language` or `context` option to run the code as a different language or in a different `Context`. -If no language is specified, Python is used. - -You can reference previously defined variables, imports, and functions in the code. - -**Arguments**: - -- `code`: Code to execute -- `language`: Language to use for code execution. If not defined, the default Python context is used. -- `on_stdout`: Callback for stdout messages -- `on_stderr`: Callback for stderr messages -- `on_result`: Callback for the `Result` object -- `on_error`: Callback for the `ExecutionError` object -- `envs`: Custom environment variables -- `timeout`: Timeout for the code execution in **seconds** -- `request_timeout`: Timeout for the request in **seconds** - -**Returns**: - -`Execution` result object - - -### run\_code - -```python -@overload -def run_code(code: str, - context: Optional[Context] = None, - on_stdout: Optional[OutputHandler[OutputMessage]] = None, - on_stderr: Optional[OutputHandler[OutputMessage]] = None, - on_result: Optional[OutputHandler[Result]] = None, - on_error: Optional[OutputHandler[ExecutionError]] = None, - envs: Optional[Dict[str, str]] = None, - timeout: Optional[float] = None, - request_timeout: Optional[float] = None) -> Execution -``` - -Runs the code in the specified context, if not specified, the default context is used. - -Specify the `language` or `context` option to run the code as a different language or in a different `Context`. - -You can reference previously defined variables, imports, and functions in the code. - -**Arguments**: - -- `code`: Code to execute -- `context`: Concrete context to run the code in. If not specified, the default context for the language is used. It's mutually exclusive with the language. -- `on_stdout`: Callback for stdout messages -- `on_stderr`: Callback for stderr messages -- `on_result`: Callback for the `Result` object -- `on_error`: Callback for the `ExecutionError` object -- `envs`: Custom environment variables -- `timeout`: Timeout for the code execution in **seconds** -- `request_timeout`: Timeout for the request in **seconds** - -**Returns**: - -`Execution` result object - - -### create\_code\_context - -```python -def create_code_context(cwd: Optional[str] = None, - language: Optional[str] = None, - request_timeout: Optional[float] = None) -> Context -``` - -Creates a new context to run code in. - -**Arguments**: - -- `cwd`: Set the current working directory for the context, defaults to `/home/user` -- `language`: Language of the context. If not specified, defaults to Python -- `request_timeout`: Timeout for the request in **milliseconds** - -**Returns**: - -Context object - From 9f9a423e45b253f106f2548dda25f5dc15fd99ab Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Fri, 2 May 2025 13:27:53 +0200 Subject: [PATCH 07/27] Updated template with SWC compiler for TypeScript (#97) * updated template with SWC compiler * added changeset --- .changeset/dull-flies-bow.md | 5 +++++ template/.ts.swcrc | 15 +++++++++++++++ template/Dockerfile | 11 +++++++++-- template/test.Dockerfile | 11 +++++++++-- 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 .changeset/dull-flies-bow.md create mode 100644 template/.ts.swcrc diff --git a/.changeset/dull-flies-bow.md b/.changeset/dull-flies-bow.md new file mode 100644 index 00000000..28c24a35 --- /dev/null +++ b/.changeset/dull-flies-bow.md @@ -0,0 +1,5 @@ +--- +'@e2b/code-interpreter-template': patch +--- + +added swc compiler for TypeScript diff --git a/template/.ts.swcrc b/template/.ts.swcrc new file mode 100644 index 00000000..da515cd2 --- /dev/null +++ b/template/.ts.swcrc @@ -0,0 +1,15 @@ +{ + "$schema": "https://swc.rs/schema.json", + "jsc": { + "parser": { + "syntax": "typescript" + } + }, + "module": { + "type": "commonjs" + }, + "env": { + "targets": "node 20" + }, + "isModule": false +} \ No newline at end of file diff --git a/template/Dockerfile b/template/Dockerfile index b023150d..199a5cb0 100644 --- a/template/Dockerfile +++ b/template/Dockerfile @@ -1,7 +1,11 @@ FROM python:3.10.14 RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \ - build-essential curl git util-linux jq sudo nodejs npm fonts-noto-cjk + build-essential curl git util-linux jq sudo fonts-noto-cjk + +# Install Node.js 20.x from NodeSource +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ + apt-get install -y nodejs ENV PIP_DEFAULT_TIMEOUT=100 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ @@ -24,10 +28,13 @@ RUN R -e "install.packages('IRkernel', repos='https://cloud.r-project.org')" RUN R -e "IRkernel::installspec(user = FALSE, name = 'r', displayname = 'R')" # Javascript Kernel -RUN npm install -g node-gyp RUN npm install -g --unsafe-perm ijavascript RUN ijsinstall --install=global +## TypeScript compiler +RUN npm install -g @swc/cli @swc/core +COPY .ts.swcrc $SERVER_PATH/.ts.swcrc + # Deno Kernel COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno RUN chmod +x /usr/bin/deno diff --git a/template/test.Dockerfile b/template/test.Dockerfile index f3647911..f9302081 100644 --- a/template/test.Dockerfile +++ b/template/test.Dockerfile @@ -5,7 +5,11 @@ COPY --from=eclipse-temurin:11-jdk $JAVA_HOME $JAVA_HOME ENV PATH="${JAVA_HOME}/bin:${PATH}" RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \ - build-essential curl git util-linux jq sudo nodejs npm fonts-noto-cjk + build-essential curl git util-linux jq sudo fonts-noto-cjk + +# Install Node.js 20.x from NodeSource +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ + apt-get install -y nodejs ENV PIP_DEFAULT_TIMEOUT=100 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ @@ -19,10 +23,13 @@ COPY ./template/requirements.txt requirements.txt RUN pip install --no-cache-dir -r requirements.txt && ipython kernel install --name "python3" --user # Javascript Kernel -RUN npm install -g node-gyp RUN npm install -g --unsafe-perm ijavascript RUN ijsinstall --install=global +## TypeScript compiler +RUN npm install -g @swc/cli @swc/core +COPY ./template/.ts.swcrc $SERVER_PATH/.ts.swcrc + # Deno Kernel COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno RUN chmod +x /usr/bin/deno From 120d097e247fb69d3b55808eb11538ea60b478f3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 2 May 2025 11:45:08 +0000 Subject: [PATCH 08/27] [skip ci] Release new versions --- .changeset/dull-flies-bow.md | 5 ----- template/package.json | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 .changeset/dull-flies-bow.md diff --git a/.changeset/dull-flies-bow.md b/.changeset/dull-flies-bow.md deleted file mode 100644 index 28c24a35..00000000 --- a/.changeset/dull-flies-bow.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@e2b/code-interpreter-template': patch ---- - -added swc compiler for TypeScript diff --git a/template/package.json b/template/package.json index 8c91626e..8d675f86 100644 --- a/template/package.json +++ b/template/package.json @@ -1,5 +1,5 @@ { "name": "@e2b/code-interpreter-template", "private": true, - "version": "0.0.6" + "version": "0.0.7" } From 95163ce29497afb9c1072c899517d0d9002fa2f3 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Fri, 2 May 2025 14:10:27 +0200 Subject: [PATCH 09/27] Added TypeScript support to the code interpreter (#91) * added typescript support via SWC * added ts tests * changed target node version * minor nits by @0div * added test for typescript kernel failure * changed swc path in prod Dockerfile * added changeset * skip test here so that the template can be built --- .changeset/tiny-adults-breathe.md | 5 +++++ js/tests/defaultKernels.test.ts | 4 +++- template/.ts.swcrc | 2 +- template/server/contexts.py | 10 +++++++++- template/server/messaging.py | 28 +++++++++++++++++++++++++++- 5 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 .changeset/tiny-adults-breathe.md diff --git a/.changeset/tiny-adults-breathe.md b/.changeset/tiny-adults-breathe.md new file mode 100644 index 00000000..38bb961f --- /dev/null +++ b/.changeset/tiny-adults-breathe.md @@ -0,0 +1,5 @@ +--- +'@e2b/code-interpreter-template': patch +--- + +added typescript support diff --git a/js/tests/defaultKernels.test.ts b/js/tests/defaultKernels.test.ts index 8a7b7f65..d8120267 100644 --- a/js/tests/defaultKernels.test.ts +++ b/js/tests/defaultKernels.test.ts @@ -3,6 +3,8 @@ import { expect } from 'vitest' import { sandboxTest } from './setup' sandboxTest('test js kernel', async ({ sandbox }) => { - const output = await sandbox.runCode('console.log("Hello World!")', { language: 'js' }) + const output = await sandbox.runCode('console.log("Hello World!")', { + language: 'js', + }) expect(output.logs.stdout).toEqual(['Hello World!\n']) }) diff --git a/template/.ts.swcrc b/template/.ts.swcrc index da515cd2..cf7cb8d3 100644 --- a/template/.ts.swcrc +++ b/template/.ts.swcrc @@ -12,4 +12,4 @@ "targets": "node 20" }, "isModule": false -} \ No newline at end of file +} diff --git a/template/server/contexts.py b/template/server/contexts.py index 3af317d3..d078dc6e 100644 --- a/template/server/contexts.py +++ b/template/server/contexts.py @@ -11,6 +11,11 @@ logger = logging.Logger(__name__) +def get_kernel_for_language(language: str) -> str: + if language == "typescript": + return "javascript" + + return language def normalize_language(language: Optional[str]) -> str: if not language: @@ -21,13 +26,16 @@ def normalize_language(language: Optional[str]) -> str: if language == "js": return "javascript" + if language == "ts": + return "typescript" + return language async def create_context(client, websockets: dict, language: str, cwd: str) -> Context: data = { "path": str(uuid.uuid4()), - "kernel": {"name": language}, + "kernel": {"name": get_kernel_for_language(language)}, "type": "notebook", "name": str(uuid.uuid4()), } diff --git a/template/server/messaging.py b/template/server/messaging.py index 4f537aa8..d2894d92 100644 --- a/template/server/messaging.py +++ b/template/server/messaging.py @@ -3,6 +3,7 @@ import logging import uuid import asyncio +import subprocess from asyncio import Queue from envs import get_envs @@ -27,7 +28,6 @@ logger = logging.getLogger(__name__) - class Execution: def __init__(self, in_background: bool = False): self.queue = Queue[ @@ -199,6 +199,32 @@ async def execute( + code ) + if self.language == "typescript": + logger.info("Compiling TypeScript: %s", code) + + # call SWC to compile the typescript code + try: + compile_result = subprocess.run("swc --config-file .ts.swcrc --filename index.ts".split(), input=code.encode(), capture_output=True) + + if compile_result.returncode != 0: + logger.error("Error during TypeScript compilation: %s", compile_result.stderr.decode()) + yield Error( + name="TypeScriptCompilerError", + value=compile_result.stderr.decode(), + traceback="", + ) + return + + code = compile_result.stdout.decode() + except Exception as e: + logger.error("Error starting SWC process: %s", e) + yield Error( + name="TypeScriptCompilerError", + value=str(e), + traceback="", + ) + return + logger.info(code) request = self._get_execute_request(message_id, code, False) From 8251c2fb3ceffac251f84f67815946b9df73246f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 2 May 2025 12:28:01 +0000 Subject: [PATCH 10/27] [skip ci] Release new versions --- .changeset/tiny-adults-breathe.md | 5 ----- template/package.json | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 .changeset/tiny-adults-breathe.md diff --git a/.changeset/tiny-adults-breathe.md b/.changeset/tiny-adults-breathe.md deleted file mode 100644 index 38bb961f..00000000 --- a/.changeset/tiny-adults-breathe.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@e2b/code-interpreter-template': patch ---- - -added typescript support diff --git a/template/package.json b/template/package.json index 8d675f86..b541ecc7 100644 --- a/template/package.json +++ b/template/package.json @@ -1,5 +1,5 @@ { "name": "@e2b/code-interpreter-template", "private": true, - "version": "0.0.7" + "version": "0.0.8" } From e80eb185ddc64b62cabc6dcac484ff9a33b86a12 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Fri, 2 May 2025 14:36:34 +0200 Subject: [PATCH 11/27] added ts-kernel tests (#99) --- js/tests/defaultKernels.test.ts | 15 +++++++++++++++ python/tests/async/test_async_default_kernels.py | 15 +++++++++++++++ python/tests/sync/test_default_kernels.py | 12 ++++++++++++ 3 files changed, 42 insertions(+) diff --git a/js/tests/defaultKernels.test.ts b/js/tests/defaultKernels.test.ts index d8120267..5750644a 100644 --- a/js/tests/defaultKernels.test.ts +++ b/js/tests/defaultKernels.test.ts @@ -8,3 +8,18 @@ sandboxTest('test js kernel', async ({ sandbox }) => { }) expect(output.logs.stdout).toEqual(['Hello World!\n']) }) + +sandboxTest('test ts kernel', async ({ sandbox }) => { + const output = await sandbox.runCode( + 'const message: string = "Hello World!"; console.log(message)', + { language: 'ts' } + ) + expect(output.logs.stdout).toEqual(['Hello World!\n']) +}) + +sandboxTest('test ts kernel errors', async ({ sandbox }) => { + const output = await sandbox.runCode('import x from "module";', { + language: 'typescript', + }) + expect(output.error?.name).toEqual('TypeScriptCompilerError') +}) diff --git a/python/tests/async/test_async_default_kernels.py b/python/tests/async/test_async_default_kernels.py index a632bda6..83f92746 100644 --- a/python/tests/async/test_async_default_kernels.py +++ b/python/tests/async/test_async_default_kernels.py @@ -6,3 +6,18 @@ async def test_js_kernel(async_sandbox: AsyncSandbox): "console.log('Hello, World!')", language="js" ) assert execution.logs.stdout == ["Hello, World!\n"] + + +async def test_ts_kernel(async_sandbox: AsyncSandbox): + execution = await async_sandbox.run_code( + "const message: string = 'Hello, World!'; console.log(message);", language="ts" + ) + assert execution.logs.stdout == ["Hello, World!\n"] + + +async def test_ts_kernel_errors(async_sandbox: AsyncSandbox): + execution = await async_sandbox.run_code( + "import x from 'module';", language="ts" + ) + assert execution.error is not None + assert execution.error.name == "TypeScriptCompilerError" diff --git a/python/tests/sync/test_default_kernels.py b/python/tests/sync/test_default_kernels.py index d0daf820..0695defd 100644 --- a/python/tests/sync/test_default_kernels.py +++ b/python/tests/sync/test_default_kernels.py @@ -18,3 +18,15 @@ def test_r_kernel(sandbox: Sandbox): def test_java_kernel(sandbox: Sandbox): execution = sandbox.run_code('System.out.println("Hello, World!")', language="java") assert execution.logs.stdout[0] == "Hello, World!" + + +@pytest.mark.skip_debug() +def test_ts_kernel(sandbox: Sandbox): + execution = sandbox.run_code("const message: string = 'Hello, World!'; console.log(message)", language="ts") + assert execution.logs.stdout == ["Hello, World!\n"] + + +def test_ts_kernel_errors(sandbox: Sandbox): + execution = sandbox.run_code("import x from 'module';", language="ts") + assert execution.error is not None + assert execution.error.name == "TypeScriptCompilerError" From 0ba58b4a9794ff1810fb62d531565518d4830b89 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Fri, 2 May 2025 16:33:13 +0200 Subject: [PATCH 12/27] vitest: continue after failing test (#100) --- js/vitest.config.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/vitest.config.mts b/js/vitest.config.mts index 1705595d..0a5def20 100644 --- a/js/vitest.config.mts +++ b/js/vitest.config.mts @@ -16,7 +16,7 @@ export default defineConfig({ globals: false, testTimeout: 30000, environment: 'node', - bail: 1, + bail: 0, server: {}, deps: { interopDefault: true, From c590c0918856e33a69fea75435a9107e0bbfcca5 Mon Sep 17 00:00:00 2001 From: 0div <98087403+0div@users.noreply.github.com> Date: Mon, 5 May 2025 10:36:06 -0700 Subject: [PATCH 13/27] Bump e2b core to 1.4.0 (#101) * bump e2b core to 1.4.0 in js sdk * bump e2b core to 1.4.0 in python sdk * add changeset --- .changeset/fluffy-turkeys-promise.md | 6 ++++++ js/package.json | 4 ++-- pnpm-lock.yaml | 10 +++++----- python/package.json | 2 +- python/poetry.lock | 14 +++++++------- python/pyproject.toml | 4 ++-- 6 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 .changeset/fluffy-turkeys-promise.md diff --git a/.changeset/fluffy-turkeys-promise.md b/.changeset/fluffy-turkeys-promise.md new file mode 100644 index 00000000..77b7b63c --- /dev/null +++ b/.changeset/fluffy-turkeys-promise.md @@ -0,0 +1,6 @@ +--- +'@e2b/code-interpreter-python': minor +'@e2b/code-interpreter': minor +--- + +bump e2b core to 1.4.0 diff --git a/js/package.json b/js/package.json index 868606d3..fb2301ca 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "@e2b/code-interpreter", - "version": "1.2.0", + "version": "1.4.0", "packageManager": "pnpm@8.7.6", "description": "E2B Code Interpreter - Stateful code execution", "homepage": "https://e2b.dev", @@ -66,7 +66,7 @@ "vm" ], "dependencies": { - "e2b": "^1.2.3" + "e2b": "^1.4.0" }, "engines": { "node": ">=18" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 34d8ce5a..78e23697 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,8 +23,8 @@ importers: js: dependencies: e2b: - specifier: ^1.2.3 - version: 1.2.3 + specifier: ^1.4.0 + version: 1.4.0 devDependencies: '@types/node': specifier: ^18.18.6 @@ -679,8 +679,8 @@ packages: resolution: {integrity: sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==} engines: {node: '>=12'} - e2b@1.2.3: - resolution: {integrity: sha512-1IJOnqrlDaT/5vn5IzRvkabJ8DIlJ5YGi17TDFhjiBcUgVsBIozPBDyYeQO4BnCxYeLzvLnTJ2zUbXcN57Qnng==} + e2b@1.4.0: + resolution: {integrity: sha512-KGe5F5UI+1PZ82OBjPHsYqpbw33ck7j0xgcJRSS56mAOWMX/Z6xllXqbZj66Xg6kkO32GmSGXjCAZL4FMSfyug==} engines: {node: '>=18'} eastasianwidth@0.2.0: @@ -2094,7 +2094,7 @@ snapshots: dotenv@16.4.7: {} - e2b@1.2.3: + e2b@1.4.0: dependencies: '@bufbuild/protobuf': 2.2.2 '@connectrpc/connect': 2.0.0-rc.3(@bufbuild/protobuf@2.2.2) diff --git a/python/package.json b/python/package.json index 69ebbb04..5bb17035 100644 --- a/python/package.json +++ b/python/package.json @@ -1,7 +1,7 @@ { "name": "@e2b/code-interpreter-python", "private": true, - "version": "1.2.1", + "version": "1.4.0", "packageManager": "pnpm@8.7.6", "scripts": { "test": "poetry run pytest -n 4 --verbose -x", diff --git a/python/poetry.lock b/python/poetry.lock index cc005e6e..efda3671 100644 --- a/python/poetry.lock +++ b/python/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand. [[package]] name = "anyio" @@ -239,7 +239,7 @@ description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" groups = ["dev"] -markers = "platform_system == \"Windows\" or sys_platform == \"win32\"" +markers = "sys_platform == \"win32\" or platform_system == \"Windows\"" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, @@ -363,14 +363,14 @@ test = ["black", "pytest"] [[package]] name = "e2b" -version = "1.3.5" +version = "1.4.0" description = "E2B SDK that give agents cloud environments" optional = false python-versions = "<4.0,>=3.9" groups = ["main"] files = [ - {file = "e2b-1.3.5-py3-none-any.whl", hash = "sha256:d2f54e1782b0bdf7f87e4855fdf952ba78848ba7b3b2dde984fe8101f0b95724"}, - {file = "e2b-1.3.5.tar.gz", hash = "sha256:dff2cfdec5ebea715b545f940934c9f42e200ef1e869e4c726e5cadf630efc1e"}, + {file = "e2b-1.4.0-py3-none-any.whl", hash = "sha256:a489015ece78ecabfdc281463ed495b6e4adf8c66278bb7312069d8ded21ab52"}, + {file = "e2b-1.4.0.tar.gz", hash = "sha256:6a4596d4f91df32340bdbfac429591980a8dedd7ac509aae73f1bbc128175245"}, ] [package.dependencies] @@ -943,7 +943,7 @@ description = "Easily download, build, install, upgrade, and uninstall Python pa optional = false python-versions = ">=3.8" groups = ["dev"] -markers = "python_version < \"3.10\"" +markers = "python_version == \"3.9\"" files = [ {file = "setuptools-75.3.0-py3-none-any.whl", hash = "sha256:f2504966861356aa38616760c0f66568e535562374995367b4e69c7143cf6bcd"}, {file = "setuptools-75.3.0.tar.gz", hash = "sha256:fba5dd4d766e97be1b1681d98712680ae8f2f26d7881245f2ce9e40714f1a686"}, @@ -1193,4 +1193,4 @@ tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""} [metadata] lock-version = "2.1" python-versions = "^3.9" -content-hash = "b06afa63f39a566dbd0ab49c1a258977ab169a3ce33b04e5c4bd75056e5dc13a" +content-hash = "e2b926469f1010c15bc330c9866099bbfad8dbcdc157d5e5174a07886945b3bf" diff --git a/python/pyproject.toml b/python/pyproject.toml index 27f4982d..a1c9f982 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "e2b-code-interpreter" -version = "1.2.1" +version = "1.4.0" description = "E2B Code Interpreter - Stateful code execution" authors = ["e2b "] license = "Apache-2.0" @@ -14,7 +14,7 @@ python = "^3.9" httpx = ">=0.20.0, <1.0.0" attrs = ">=21.3.0" -e2b = "^1.3.5" +e2b = "^1.4.0" [tool.poetry.group.dev.dependencies] pytest = "^7.4.0" From 286361a57d1164c1f011d43cab63823ea33c6f18 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 5 May 2025 17:37:50 +0000 Subject: [PATCH 14/27] [skip ci] Release new versions --- .changeset/fluffy-turkeys-promise.md | 6 - js/package.json | 2 +- python/package.json | 2 +- python/pyproject.toml | 2 +- .../v1.5.0/charts/page.mdx | 240 ++++++ .../v1.5.0/consts/page.mdx | 13 + .../v1.5.0/index/page.mdx | 103 +++ .../v1.5.0/messaging/page.mdx | 326 ++++++++ .../v1.5.0/sandbox/page.mdx | 312 ++++++++ .../v1.5.0/sandbox/page.mdx | 722 ++++++++++++++++++ 10 files changed, 1719 insertions(+), 9 deletions(-) delete mode 100644 .changeset/fluffy-turkeys-promise.md create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.5.0/charts/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.5.0/consts/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.5.0/index/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.5.0/messaging/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.5.0/sandbox/page.mdx create mode 100644 sdk-reference/code-interpreter-python-sdk/v1.5.0/sandbox/page.mdx diff --git a/.changeset/fluffy-turkeys-promise.md b/.changeset/fluffy-turkeys-promise.md deleted file mode 100644 index 77b7b63c..00000000 --- a/.changeset/fluffy-turkeys-promise.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@e2b/code-interpreter-python': minor -'@e2b/code-interpreter': minor ---- - -bump e2b core to 1.4.0 diff --git a/js/package.json b/js/package.json index fb2301ca..27c76fd4 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "@e2b/code-interpreter", - "version": "1.4.0", + "version": "1.5.0", "packageManager": "pnpm@8.7.6", "description": "E2B Code Interpreter - Stateful code execution", "homepage": "https://e2b.dev", diff --git a/python/package.json b/python/package.json index 5bb17035..cee595b9 100644 --- a/python/package.json +++ b/python/package.json @@ -1,7 +1,7 @@ { "name": "@e2b/code-interpreter-python", "private": true, - "version": "1.4.0", + "version": "1.5.0", "packageManager": "pnpm@8.7.6", "scripts": { "test": "poetry run pytest -n 4 --verbose -x", diff --git a/python/pyproject.toml b/python/pyproject.toml index a1c9f982..d1d859cf 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "e2b-code-interpreter" -version = "1.4.0" +version = "1.5.0" description = "E2B Code Interpreter - Stateful code execution" authors = ["e2b "] license = "Apache-2.0" diff --git a/sdk-reference/code-interpreter-js-sdk/v1.5.0/charts/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.5.0/charts/page.mdx new file mode 100644 index 00000000..f3176d3b --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.5.0/charts/page.mdx @@ -0,0 +1,240 @@ +### ChartType + +Chart types + +#### Enumeration Members + +| Enumeration Member | Value | +| ------ | ------ | +| `BAR` | `"bar"` | +| `BOX_AND_WHISKER` | `"box_and_whisker"` | +| `LINE` | `"line"` | +| `PIE` | `"pie"` | +| `SCATTER` | `"scatter"` | +| `SUPERCHART` | `"superchart"` | +| `UNKNOWN` | `"unknown"` | + +*** + +### ScaleType + +Ax scale types + +#### Enumeration Members + +| Enumeration Member | Value | +| ------ | ------ | +| `ASINH` | `"asinh"` | +| `CATEGORICAL` | `"categorical"` | +| `DATETIME` | `"datetime"` | +| `FUNCTION` | `"function"` | +| `FUNCTIONLOG` | `"functionlog"` | +| `LINEAR` | `"linear"` | +| `LOG` | `"log"` | +| `LOGIT` | `"logit"` | +| `SYMLOG` | `"symlog"` | + +## Type Aliases + +### BarChart + +```ts +type BarChart: Chart2D & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `BarData`[] | +| `type` | `ChartType.BAR` | + +*** + +### BarData + +```ts +type BarData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `group` | `string` | +| `label` | `string` | +| `value` | `string` | + +*** + +### BoxAndWhiskerChart + +```ts +type BoxAndWhiskerChart: Chart2D & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `BoxAndWhiskerData`[] | +| `type` | `ChartType.BOX_AND_WHISKER` | + +*** + +### BoxAndWhiskerData + +```ts +type BoxAndWhiskerData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `first_quartile` | `number` | +| `label` | `string` | +| `max` | `number` | +| `median` | `number` | +| `min` | `number` | +| `outliers` | `number`[] | +| `third_quartile` | `number` | + +*** + +### Chart + +```ts +type Chart: object; +``` + +Represents a chart. + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `any`[] | +| `title` | `string` | +| `type` | `ChartType` | + +*** + +### ChartTypes + +```ts +type ChartTypes: + | LineChart + | ScatterChart + | BarChart + | PieChart + | BoxAndWhiskerChart + | SuperChart; +``` + +*** + +### LineChart + +```ts +type LineChart: PointChart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `type` | `ChartType.LINE` | + +*** + +### PieChart + +```ts +type PieChart: Chart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `PieData`[] | +| `type` | `ChartType.PIE` | + +*** + +### PieData + +```ts +type PieData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `angle` | `number` | +| `label` | `string` | +| `radius` | `number` | + +*** + +### PointData + +```ts +type PointData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `label` | `string` | +| `points` | [`number` \| `string`, `number` \| `string`][] | + +*** + +### ScatterChart + +```ts +type ScatterChart: PointChart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `type` | `ChartType.SCATTER` | + +*** + +### SuperChart + +```ts +type SuperChart: Chart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `Chart`[] | +| `type` | `ChartType.SUPERCHART` | + +## Functions + +### deserializeChart() + +```ts +function deserializeChart(data: any): Chart +``` + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| `data` | `any` | + +#### Returns + +`Chart` diff --git a/sdk-reference/code-interpreter-js-sdk/v1.5.0/consts/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.5.0/consts/page.mdx new file mode 100644 index 00000000..d1ee2e76 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.5.0/consts/page.mdx @@ -0,0 +1,13 @@ +### DEFAULT\_TIMEOUT\_MS + +```ts +const DEFAULT_TIMEOUT_MS: 60000 = 60_000; +``` + +*** + +### JUPYTER\_PORT + +```ts +const JUPYTER_PORT: 49999 = 49999; +``` diff --git a/sdk-reference/code-interpreter-js-sdk/v1.5.0/index/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.5.0/index/page.mdx new file mode 100644 index 00000000..dc55fcc7 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.5.0/index/page.mdx @@ -0,0 +1,103 @@ +### BarChart + +Re-exports BarChart + +### BarData + +Re-exports BarData + +### BoxAndWhiskerChart + +Re-exports BoxAndWhiskerChart + +### BoxAndWhiskerData + +Re-exports BoxAndWhiskerData + +### Chart + +Re-exports Chart + +### ChartType + +Re-exports ChartType + +### ChartTypes + +Re-exports ChartTypes + +### Context + +Re-exports Context + +### CreateCodeContextOpts + +Re-exports CreateCodeContextOpts + +### default + +Renames and re-exports Sandbox + +### Execution + +Re-exports Execution + +### ExecutionError + +Re-exports ExecutionError + +### LineChart + +Re-exports LineChart + +### Logs + +Re-exports Logs + +### MIMEType + +Re-exports MIMEType + +### OutputMessage + +Re-exports OutputMessage + +### PieChart + +Re-exports PieChart + +### PieData + +Re-exports PieData + +### PointData + +Re-exports PointData + +### RawData + +Re-exports RawData + +### Result + +Re-exports Result + +### RunCodeOpts + +Re-exports RunCodeOpts + +### Sandbox + +Re-exports Sandbox + +### ScaleType + +Re-exports ScaleType + +### ScatterChart + +Re-exports ScatterChart + +### SuperChart + +Re-exports SuperChart diff --git a/sdk-reference/code-interpreter-js-sdk/v1.5.0/messaging/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.5.0/messaging/page.mdx new file mode 100644 index 00000000..4b3c4ed9 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.5.0/messaging/page.mdx @@ -0,0 +1,326 @@ +### Execution + +Represents the result of a cell execution. + +#### Constructors + +```ts +new Execution( + results: Result[], + logs: Logs, + error?: ExecutionError, + executionCount?: number): Execution +``` + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `results` | `Result`[] | `[]` | List of result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots). | +| `logs` | `Logs` | `...` | Logs printed to stdout and stderr during execution. | +| `error`? | `ExecutionError` | `undefined` | An Error object if an error occurred, null otherwise. | +| `executionCount`? | `number` | `undefined` | Execution count of the cell. | + +###### Returns + +`Execution` + +#### Properties + +| Property | Modifier | Type | Default value | Description | +| ------ | ------ | ------ | ------ | ------ | +| `error?` | `public` | `ExecutionError` | `undefined` | An Error object if an error occurred, null otherwise. | +| `executionCount?` | `public` | `number` | `undefined` | Execution count of the cell. | +| `logs` | `public` | `Logs` | `undefined` | Logs printed to stdout and stderr during execution. | +| `results` | `public` | `Result`[] | `[]` | List of result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots). | + +#### Accessors + +### text + +```ts +get text(): undefined | string +``` + +Returns the text representation of the main result of the cell. + +###### Returns + +`undefined` \| `string` + +#### Methods + +### toJSON() + +```ts +toJSON(): object +``` + +Returns the serializable representation of the execution result. + +###### Returns + +`object` + +| Name | Type | +| ------ | ------ | +| `error` | `undefined` \| `ExecutionError` | +| `logs` | `Logs` | +| `results` | `Result`[] | + +*** + +### ExecutionError + +Represents an error that occurred during the execution of a cell. +The error contains the name of the error, the value of the error, and the traceback. + +#### Constructors + +```ts +new ExecutionError( + name: string, + value: string, + traceback: string): ExecutionError +``` + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `name` | `string` | Name of the error. | +| `value` | `string` | Value of the error. | +| `traceback` | `string` | The raw traceback of the error. | + +###### Returns + +`ExecutionError` + +#### Properties + +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `name` | `public` | `string` | Name of the error. | +| `traceback` | `public` | `string` | The raw traceback of the error. | +| `value` | `public` | `string` | Value of the error. | + +*** + +### OutputMessage + +Represents an output message from the sandbox code execution. + +#### Constructors + +```ts +new OutputMessage( + line: string, + timestamp: number, + error: boolean): OutputMessage +``` + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `line` | `string` | The output line. | +| `timestamp` | `number` | Unix epoch in nanoseconds. | +| `error` | `boolean` | Whether the output is an error. | + +###### Returns + +`OutputMessage` + +#### Properties + +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `error` | `readonly` | `boolean` | Whether the output is an error. | +| `line` | `readonly` | `string` | The output line. | +| `timestamp` | `readonly` | `number` | Unix epoch in nanoseconds. | + +#### Methods + +### toString() + +```ts +toString(): string +``` + +###### Returns + +`string` + +*** + +### Result + +Represents the data to be displayed as a result of executing a cell in a Jupyter notebook. +The result is similar to the structure returned by ipython kernel: https://ipython.readthedocs.io/en/stable/development/execution.html#execution-semantics + +The result can contain multiple types of data, such as text, images, plots, etc. Each type of data is represented +as a string, and the result can contain multiple types of data. The display calls don't have to have text representation, +for the actual result the representation is always present for the result, the other representations are always optional. + +#### Constructors + +```ts +new Result(rawData: RawData, isMainResult: boolean): Result +``` + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `rawData` | `RawData` | +| `isMainResult` | `boolean` | + +###### Returns + +`Result` + +#### Properties + +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `chart?` | `readonly` | `ChartTypes` | Contains the chart data. | +| `data?` | `readonly` | `Record`\<`string`, `unknown`\> | Contains the data from DataFrame. | +| `extra?` | `readonly` | `any` | Extra data that can be included. Not part of the standard types. | +| `html?` | `readonly` | `string` | HTML representation of the data. | +| `isMainResult` | `readonly` | `boolean` | - | +| `javascript?` | `readonly` | `string` | JavaScript representation of the data. | +| `jpeg?` | `readonly` | `string` | JPEG representation of the data. | +| `json?` | `readonly` | `string` | JSON representation of the data. | +| `latex?` | `readonly` | `string` | LaTeX representation of the data. | +| `markdown?` | `readonly` | `string` | Markdown representation of the data. | +| `pdf?` | `readonly` | `string` | PDF representation of the data. | +| `png?` | `readonly` | `string` | PNG representation of the data. | +| `raw` | `readonly` | `RawData` | - | +| `svg?` | `readonly` | `string` | SVG representation of the data. | +| `text?` | `readonly` | `string` | Text representation of the result. | + +#### Methods + +### formats() + +```ts +formats(): string[] +``` + +Returns all the formats available for the result. + +###### Returns + +`string`[] + +Array of strings representing the formats available for the result. + +### toJSON() + +```ts +toJSON(): object +``` + +Returns the serializable representation of the result. + +###### Returns + +`object` + +| Name | Type | +| ------ | ------ | +| `extra`? | `any` | +| `html` | `undefined` \| `string` | +| `javascript` | `undefined` \| `string` | +| `jpeg` | `undefined` \| `string` | +| `json` | `undefined` \| `string` | +| `latex` | `undefined` \| `string` | +| `markdown` | `undefined` \| `string` | +| `pdf` | `undefined` \| `string` | +| `png` | `undefined` \| `string` | +| `svg` | `undefined` \| `string` | +| `text` | `undefined` \| `string` | + +## Type Aliases + +### Logs + +```ts +type Logs: object; +``` + +Data printed to stdout and stderr during execution, usually by print statements, logs, warnings, subprocesses, etc. + +#### Type declaration + +| Name | Type | Description | +| ------ | ------ | ------ | +| `stderr` | `string`[] | List of strings printed to stderr by prints, subprocesses, etc. | +| `stdout` | `string`[] | List of strings printed to stdout by prints, subprocesses, etc. | + +*** + +### MIMEType + +```ts +type MIMEType: string; +``` + +Represents a MIME type. + +*** + +### RawData + +```ts +type RawData: object & E2BData; +``` + +Dictionary that maps MIME types to their corresponding representations of the data. + +## Functions + +### extractError() + +```ts +function extractError(res: Response): Promise +``` + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| `res` | `Response` | + +#### Returns + +`Promise`\<`undefined` \| `SandboxError`\> + +*** + +### parseOutput() + +```ts +function parseOutput( + execution: Execution, + line: string, + onStdout?: (output: OutputMessage) => any, + onStderr?: (output: OutputMessage) => any, + onResult?: (data: Result) => any, +onError?: (error: ExecutionError) => any): Promise +``` + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| `execution` | `Execution` | +| `line` | `string` | +| `onStdout`? | (`output`: `OutputMessage`) => `any` | +| `onStderr`? | (`output`: `OutputMessage`) => `any` | +| `onResult`? | (`data`: `Result`) => `any` | +| `onError`? | (`error`: `ExecutionError`) => `any` | + +#### Returns + +`Promise`\<`void`\> diff --git a/sdk-reference/code-interpreter-js-sdk/v1.5.0/sandbox/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.5.0/sandbox/page.mdx new file mode 100644 index 00000000..96eafec5 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.5.0/sandbox/page.mdx @@ -0,0 +1,312 @@ +### Sandbox + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs here. + +Use Sandbox.create to create a new sandbox. + +#### Example + +```ts +import { Sandbox } from '@e2b/code-interpreter' + +const sandbox = await Sandbox.create() +``` + +#### Methods + +### createCodeContext() + +```ts +createCodeContext(opts?: CreateCodeContextOpts): Promise +``` + +Creates a new context to run code in. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `opts`? | `CreateCodeContextOpts` | options for creating the context. | + +###### Returns + +`Promise`\<`Context`\> + +context object. + +### runCode() + +###### runCode(code, opts) + +```ts +runCode(code: string, opts?: RunCodeOpts & object): Promise +``` + +Run the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `code` | `string` | code to execute. | +| `opts`? | `RunCodeOpts` & `object` | options for executing the code. | + +###### Returns + +`Promise`\<`Execution`\> + +`Execution` result object. + +###### runCode(code, opts) + +```ts +runCode(code: string, opts?: RunCodeOpts & object): Promise +``` + +Run the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `code` | `string` | code to execute. | +| `opts`? | `RunCodeOpts` & `object` | options for executing the code. | + +###### Returns + +`Promise`\<`Execution`\> + +`Execution` result object. + +###### runCode(code, opts) + +```ts +runCode(code: string, opts?: RunCodeOpts & object): Promise +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `code` | `string` | code to execute. | +| `opts`? | `RunCodeOpts` & `object` | options for executing the code | + +###### Returns + +`Promise`\<`Execution`\> + +`Execution` result object + +## Interfaces + +### CreateCodeContextOpts + +Options for creating a code context. + +#### Properties + +### cwd? + +```ts +optional cwd: string; +``` + +Working directory for the context. + +###### Default + +```ts +/home/user +``` + +### language? + +```ts +optional language: string; +``` + +Language for the context. + +###### Default + +```ts +python +``` + +### requestTimeoutMs? + +```ts +optional requestTimeoutMs: number; +``` + +Timeout for the request in **milliseconds**. + +###### Default + +```ts +30_000 // 30 seconds +``` + +*** + +### RunCodeOpts + +Options for running code. + +#### Properties + +### envs? + +```ts +optional envs: Record; +``` + +Custom environment variables for code execution. + +###### Default + +```ts +{} +``` + +### onError()? + +```ts +optional onError: (error: ExecutionError) => any; +``` + +Callback for handling the `ExecutionError` object. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `error` | `ExecutionError` | + +###### Returns + +`any` + +### onResult()? + +```ts +optional onResult: (data: Result) => any; +``` + +Callback for handling the final execution result. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `data` | `Result` | + +###### Returns + +`any` + +### onStderr()? + +```ts +optional onStderr: (output: OutputMessage) => any; +``` + +Callback for handling stderr messages. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `output` | `OutputMessage` | + +###### Returns + +`any` + +### onStdout()? + +```ts +optional onStdout: (output: OutputMessage) => any; +``` + +Callback for handling stdout messages. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `output` | `OutputMessage` | + +###### Returns + +`any` + +### requestTimeoutMs? + +```ts +optional requestTimeoutMs: number; +``` + +Timeout for the request in **milliseconds**. + +###### Default + +```ts +30_000 // 30 seconds +``` + +### timeoutMs? + +```ts +optional timeoutMs: number; +``` + +Timeout for the code execution in **milliseconds**. + +###### Default + +```ts +60_000 // 60 seconds +``` + +## Type Aliases + +### Context + +```ts +type Context: object; +``` + +Represents a context for code execution. + +#### Type declaration + +| Name | Type | Description | +| ------ | ------ | ------ | +| `cwd` | `string` | The working directory of the context. | +| `id` | `string` | The ID of the context. | +| `language` | `string` | The language of the context. | diff --git a/sdk-reference/code-interpreter-python-sdk/v1.5.0/sandbox/page.mdx b/sdk-reference/code-interpreter-python-sdk/v1.5.0/sandbox/page.mdx new file mode 100644 index 00000000..2fbc0e20 --- /dev/null +++ b/sdk-reference/code-interpreter-python-sdk/v1.5.0/sandbox/page.mdx @@ -0,0 +1,722 @@ + + + + + +## Sandbox + +```python +class Sandbox(BaseSandbox) +``` + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs [here](https://e2b.dev/docs). + +Use the `Sandbox()` to create a new sandbox. + +**Example**: + +```python +from e2b_code_interpreter import Sandbox + +sandbox = Sandbox() +``` + + +### run\_code + +```python +@overload +def run_code(code: str, + language: Union[Literal["python"], None] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +def run_code(code: str, + language: Optional[str] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +def run_code(code: str, + context: Optional[Context] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `context`: Concrete context to run the code in. If not specified, the default context for the language is used. It's mutually exclusive with the language. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### create\_code\_context + +```python +def create_code_context(cwd: Optional[str] = None, + language: Optional[str] = None, + request_timeout: Optional[float] = None) -> Context +``` + +Creates a new context to run code in. + +**Arguments**: + +- `cwd`: Set the current working directory for the context, defaults to `/home/user` +- `language`: Language of the context. If not specified, defaults to Python +- `request_timeout`: Timeout for the request in **milliseconds** + +**Returns**: + +Context object + + + + + + +## ChartType + +```python +class ChartType(str, enum.Enum) +``` + +Chart types + + +## ScaleType + +```python +class ScaleType(str, enum.Enum) +``` + +Ax scale types + + +## Chart + +```python +class Chart() +``` + +Extracted data from a chart. It's useful for building an interactive charts or custom visualizations. + + + + + + +## OutputMessage + +```python +@dataclass +class OutputMessage() +``` + +Represents an output message from the sandbox code execution. + + +### line + +The output line. + + +### timestamp + +Unix epoch in nanoseconds + + +### error + +Whether the output is an error. + + +## ExecutionError + +```python +@dataclass +class ExecutionError() +``` + +Represents an error that occurred during the execution of a cell. +The error contains the name of the error, the value of the error, and the traceback. + + +### name + +Name of the error. + + +### value + +Value of the error. + + +### traceback + +The raw traceback of the error. + + +### to\_json + +```python +def to_json() -> str +``` + +Returns the JSON representation of the Error object. + + +## MIMEType + +```python +class MIMEType(str) +``` + +Represents a MIME type. + + +## Result + +```python +@dataclass +class Result() +``` + +Represents the data to be displayed as a result of executing a cell in a Jupyter notebook. +The result is similar to the structure returned by ipython kernel: https://ipython.readthedocs.io/en/stable/development/execution.html#execution-semantics + +The result can contain multiple types of data, such as text, images, plots, etc. Each type of data is represented +as a string, and the result can contain multiple types of data. The display calls don't have to have text representation, +for the actual result the representation is always present for the result, the other representations are always optional. + + +### is\_main\_result + +Whether this data is the result of the cell. Data can be produced by display calls of which can be multiple in a cell. + + +### extra + +Extra data that can be included. Not part of the standard types. + + +### formats + +```python +def formats() -> Iterable[str] +``` + +Returns all available formats of the result. + +**Returns**: + +All available formats of the result in MIME types. + + +### \_\_str\_\_ + +```python +def __str__() -> Optional[str] +``` + +Returns the text representation of the data. + +**Returns**: + +The text representation of the data. + + +### \_repr\_html\_ + +```python +def _repr_html_() -> Optional[str] +``` + +Returns the HTML representation of the data. + +**Returns**: + +The HTML representation of the data. + + +### \_repr\_markdown\_ + +```python +def _repr_markdown_() -> Optional[str] +``` + +Returns the Markdown representation of the data. + +**Returns**: + +The Markdown representation of the data. + + +### \_repr\_svg\_ + +```python +def _repr_svg_() -> Optional[str] +``` + +Returns the SVG representation of the data. + +**Returns**: + +The SVG representation of the data. + + +### \_repr\_png\_ + +```python +def _repr_png_() -> Optional[str] +``` + +Returns the base64 representation of the PNG data. + +**Returns**: + +The base64 representation of the PNG data. + + +### \_repr\_jpeg\_ + +```python +def _repr_jpeg_() -> Optional[str] +``` + +Returns the base64 representation of the JPEG data. + +**Returns**: + +The base64 representation of the JPEG data. + + +### \_repr\_pdf\_ + +```python +def _repr_pdf_() -> Optional[str] +``` + +Returns the PDF representation of the data. + +**Returns**: + +The PDF representation of the data. + + +### \_repr\_latex\_ + +```python +def _repr_latex_() -> Optional[str] +``` + +Returns the LaTeX representation of the data. + +**Returns**: + +The LaTeX representation of the data. + + +### \_repr\_json\_ + +```python +def _repr_json_() -> Optional[dict] +``` + +Returns the JSON representation of the data. + +**Returns**: + +The JSON representation of the data. + + +### \_repr\_javascript\_ + +```python +def _repr_javascript_() -> Optional[str] +``` + +Returns the JavaScript representation of the data. + +**Returns**: + +The JavaScript representation of the data. + + +## Logs + +```python +@dataclass(repr=False) +class Logs() +``` + +Data printed to stdout and stderr during execution, usually by print statements, logs, warnings, subprocesses, etc. + + +### stdout + +List of strings printed to stdout by prints, subprocesses, etc. + + +### stderr + +List of strings printed to stderr by prints, subprocesses, etc. + + +### to\_json + +```python +def to_json() -> str +``` + +Returns the JSON representation of the Logs object. + + +### serialize\_results + +```python +def serialize_results(results: List[Result]) -> List[Dict[str, str]] +``` + +Serializes the results to JSON. + + +## Execution + +```python +@dataclass(repr=False) +class Execution() +``` + +Represents the result of a cell execution. + + +### results + +List of the result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots). + + +### logs + +Logs printed to stdout and stderr during execution. + + +### error + +Error object if an error occurred, None otherwise. + + +### execution\_count + +Execution count of the cell. + + +### text + +```python +@property +def text() -> Optional[str] +``` + +Returns the text representation of the result. + +**Returns**: + +The text representation of the result. + + +### to\_json + +```python +def to_json() -> str +``` + +Returns the JSON representation of the Execution object. + + +## Context + +```python +@dataclass +class Context() +``` + +Represents a context for code execution. + + +### id + +The ID of the context. + + +### language + +The language of the context. + + +### cwd + +The working directory of the context. + + + + +## AsyncSandbox + +```python +class AsyncSandbox(BaseAsyncSandbox) +``` + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs [here](https://e2b.dev/docs). + +Use the `AsyncSandbox.create()` to create a new sandbox. + +**Example**: + +```python +from e2b_code_interpreter import AsyncSandbox +sandbox = await AsyncSandbox.create() +``` + + +### run\_code + +```python +@overload +async def run_code(code: str, + language: Union[Literal["python"], None] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +async def run_code(code: str, + language: Optional[str] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +async def run_code(code: str, + context: Optional[Context] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `context`: Concrete context to run the code in. If not specified, the default context for the language is used. It's mutually exclusive with the language. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### create\_code\_context + +```python +async def create_code_context( + cwd: Optional[str] = None, + language: Optional[str] = None, + request_timeout: Optional[float] = None) -> Context +``` + +Creates a new context to run code in. + +**Arguments**: + +- `cwd`: Set the current working directory for the context, defaults to `/home/user` +- `language`: Language of the context. If not specified, defaults to Python +- `request_timeout`: Timeout for the request in **milliseconds** + +**Returns**: + +Context object + From cbe4a51b14078b05bb003a193f9d4f818f00f185 Mon Sep 17 00:00:00 2001 From: Tomas Valenta Date: Thu, 8 May 2025 01:57:28 -0700 Subject: [PATCH 15/27] Configure code interpreter server idle timeout (#102) * Configure server timeouts * Remove flag * Add changeset --------- Co-authored-by: Jakub Novak --- .changeset/stale-olives-cover.md | 5 +++++ template/start-up.sh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/stale-olives-cover.md diff --git a/.changeset/stale-olives-cover.md b/.changeset/stale-olives-cover.md new file mode 100644 index 00000000..111d4718 --- /dev/null +++ b/.changeset/stale-olives-cover.md @@ -0,0 +1,5 @@ +--- +'@e2b/code-interpreter-template': patch +--- + +Increase keep alive timeout diff --git a/template/start-up.sh b/template/start-up.sh index fb45f470..735e5811 100644 --- a/template/start-up.sh +++ b/template/start-up.sh @@ -26,7 +26,7 @@ function start_jupyter_server() { sudo echo "${response}" | sudo tee /root/.jupyter/.session_info >/dev/null cd /root/.server/ - /root/.server/.venv/bin/uvicorn main:app --host 0.0.0.0 --port 49999 --workers 1 --no-access-log --no-use-colors + /root/.server/.venv/bin/uvicorn main:app --host 0.0.0.0 --port 49999 --workers 1 --no-access-log --no-use-colors --timeout-keep-alive 640 } echo "Starting Code Interpreter server..." From 918ab8e91a62e79838a25a4dd41f49a62ce52ef6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 8 May 2025 09:15:09 +0000 Subject: [PATCH 16/27] [skip ci] Release new versions --- .changeset/stale-olives-cover.md | 5 ----- template/package.json | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 .changeset/stale-olives-cover.md diff --git a/.changeset/stale-olives-cover.md b/.changeset/stale-olives-cover.md deleted file mode 100644 index 111d4718..00000000 --- a/.changeset/stale-olives-cover.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@e2b/code-interpreter-template': patch ---- - -Increase keep alive timeout diff --git a/template/package.json b/template/package.json index b541ecc7..24a4e53e 100644 --- a/template/package.json +++ b/template/package.json @@ -1,5 +1,5 @@ { "name": "@e2b/code-interpreter-template", "private": true, - "version": "0.0.8" + "version": "0.0.9" } From c6dd986b2303cb3b50c629253b172f084d5c7142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Nov=C3=A1k?= Date: Mon, 12 May 2025 15:34:19 +0200 Subject: [PATCH 17/27] Update babel (#103) --- pnpm-lock.yaml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 78e23697..e90731f8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,8 +60,8 @@ importers: packages: - '@babel/runtime@7.24.4': - resolution: {integrity: sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==} + '@babel/runtime@7.27.1': + resolution: {integrity: sha512-1x3D2xEk2fRo3PAhwQwu5UubzgiVWSXTBfWpVd2Mx2AzRqJuDJCsgaDVZ7HB5iGzDW1Hl1sWN2mFyKjmR9uAog==} engines: {node: '>=6.9.0'} '@bufbuild/protobuf@2.2.2': @@ -1129,9 +1129,6 @@ packages: resolution: {integrity: sha512-h80JrZu/MHUZCyHu5ciuoI0+WxsCxzxJTILn6Fs8rxSnFPh+UVHYfeIxK1nVGugMqkfC4vJcBOYbkfkwYK0+gw==} engines: {node: '>= 14.18.0'} - regenerator-runtime@0.14.1: - resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} - regex-recursion@5.1.1: resolution: {integrity: sha512-ae7SBCbzVNrIjgSbh7wMznPcQel1DNlDtzensnFxpiNpXt1U2ju/bHugH422r+4LAVS1FpW1YCwilmnNsjum9w==} @@ -1503,9 +1500,7 @@ packages: snapshots: - '@babel/runtime@7.24.4': - dependencies: - regenerator-runtime: 0.14.1 + '@babel/runtime@7.27.1': {} '@bufbuild/protobuf@2.2.2': {} @@ -1763,14 +1758,14 @@ snapshots: '@manypkg/find-root@1.1.0': dependencies: - '@babel/runtime': 7.24.4 + '@babel/runtime': 7.27.1 '@types/node': 12.20.55 find-up: 4.1.0 fs-extra: 8.1.0 '@manypkg/get-packages@1.1.3': dependencies: - '@babel/runtime': 7.24.4 + '@babel/runtime': 7.27.1 '@changesets/types': 4.1.0 '@manypkg/find-root': 1.1.0 fs-extra: 8.1.0 @@ -2542,8 +2537,6 @@ snapshots: readdirp@4.1.1: {} - regenerator-runtime@0.14.1: {} - regex-recursion@5.1.1: dependencies: regex: 5.1.1 From fae4e6d105b1edee74a1308eebf0081eb87a0866 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 19 May 2025 18:33:50 +0200 Subject: [PATCH 18/27] Python 3.12 support + deps bump (#105) * bump python 3.12 and dependencies * added changeset --- .changeset/clever-berries-shave.md | 5 +++ template/Dockerfile | 2 +- template/requirements.txt | 65 +++++++++++++++--------------- template/test.Dockerfile | 2 +- 4 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 .changeset/clever-berries-shave.md diff --git a/.changeset/clever-berries-shave.md b/.changeset/clever-berries-shave.md new file mode 100644 index 00000000..ee6748b4 --- /dev/null +++ b/.changeset/clever-berries-shave.md @@ -0,0 +1,5 @@ +--- +'@e2b/code-interpreter-template': patch +--- + +python 3.12 support diff --git a/template/Dockerfile b/template/Dockerfile index 199a5cb0..c48f7df9 100644 --- a/template/Dockerfile +++ b/template/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10.14 +FROM python:3.12 RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \ build-essential curl git util-linux jq sudo fonts-noto-cjk diff --git a/template/requirements.txt b/template/requirements.txt index ca87be9a..3d185173 100644 --- a/template/requirements.txt +++ b/template/requirements.txt @@ -1,42 +1,43 @@ # Jupyter server requirements -jupyter-server==2.13.0 -ipykernel==6.29.3 -ipython==8.22.2 +jupyter-server==2.16.0 +ipykernel==6.29.5 +ipython==9.2.0 -orjson==3.9.15 -pandas==1.5.3 -matplotlib==3.9.2 -pillow==10.3.0 +orjson==3.10.18 +pandas==2.2.3 +matplotlib==3.10.3 +pillow==11.2.1 # Latest version for e2b_charts # Other packages -aiohttp==3.10.11 -beautifulsoup4==4.12.3 -bokeh==3.3.4 -gensim==4.3.2 -imageio==2.34.0 -joblib==1.3.2 -librosa==0.10.1 -nltk==3.9 -numpy==1.26.4 -opencv-python==4.9.0.80 -openpyxl==3.1.2 -plotly==5.19.0 -pytest==8.1.0 -python-docx==1.1.0 -pytz==2024.1 -requests==2.32.2 -scikit-image==0.22.0 -scikit-learn==1.5.0 -scipy==1.12.0 +aiohttp==3.11.18 +beautifulsoup4==4.13.4 +bokeh==3.7.3 +gensim==4.3.3 # unmaintained, blocking numpy and scipy bump +imageio==2.37.0 +joblib==1.5.0 +librosa==0.11.0 +nltk==3.9.1 +numpy==1.26.4 # bump blocked by gensim +numba==0.61.2 +opencv-python==4.11.0.86 +openpyxl==3.1.5 +plotly==6.0.1 +pytest==8.3.5 +python-docx==1.1.2 +pytz==2025.2 +requests==2.32.3 +scikit-image==0.25.2 +scikit-learn==1.6.1 +scipy==1.13.1 # bump blocked by gensim seaborn==0.13.2 -soundfile==0.12.1 -spacy==3.7.4 -textblob==0.18.0 +soundfile==0.13.1 +spacy==3.8.2 # doesn't work on 3.13.x +textblob==0.19.0 tornado==6.4.2 -urllib3==1.26.19 -xarray==2024.2.0 +urllib3==2.4.0 +xarray==2025.4.0 xlrd==2.0.1 -sympy==1.12 +sympy==1.14.0 diff --git a/template/test.Dockerfile b/template/test.Dockerfile index f9302081..9a6c2f21 100644 --- a/template/test.Dockerfile +++ b/template/test.Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10.14 +FROM python:3.12 ENV JAVA_HOME=/opt/java/openjdk COPY --from=eclipse-temurin:11-jdk $JAVA_HOME $JAVA_HOME From 85b729ffd6adb8cac1548815205710ece382f6f0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 19 May 2025 16:53:42 +0000 Subject: [PATCH 19/27] [skip ci] Release new versions --- .changeset/clever-berries-shave.md | 5 - .../v1.5.0/sandbox/page.mdx | 398 +++++++++--------- template/package.json | 2 +- 3 files changed, 200 insertions(+), 205 deletions(-) delete mode 100644 .changeset/clever-berries-shave.md diff --git a/.changeset/clever-berries-shave.md b/.changeset/clever-berries-shave.md deleted file mode 100644 index ee6748b4..00000000 --- a/.changeset/clever-berries-shave.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@e2b/code-interpreter-template': patch ---- - -python 3.12 support diff --git a/sdk-reference/code-interpreter-python-sdk/v1.5.0/sandbox/page.mdx b/sdk-reference/code-interpreter-python-sdk/v1.5.0/sandbox/page.mdx index 2fbc0e20..6bee4003 100644 --- a/sdk-reference/code-interpreter-python-sdk/v1.5.0/sandbox/page.mdx +++ b/sdk-reference/code-interpreter-python-sdk/v1.5.0/sandbox/page.mdx @@ -3,205 +3,6 @@ -## Sandbox - -```python -class Sandbox(BaseSandbox) -``` - -E2B cloud sandbox is a secure and isolated cloud environment. - -The sandbox allows you to: -- Access Linux OS -- Create, list, and delete files and directories -- Run commands -- Run isolated code -- Access the internet - -Check docs [here](https://e2b.dev/docs). - -Use the `Sandbox()` to create a new sandbox. - -**Example**: - -```python -from e2b_code_interpreter import Sandbox - -sandbox = Sandbox() -``` - - -### run\_code - -```python -@overload -def run_code(code: str, - language: Union[Literal["python"], None] = None, - on_stdout: Optional[OutputHandler[OutputMessage]] = None, - on_stderr: Optional[OutputHandler[OutputMessage]] = None, - on_result: Optional[OutputHandler[Result]] = None, - on_error: Optional[OutputHandler[ExecutionError]] = None, - envs: Optional[Dict[str, str]] = None, - timeout: Optional[float] = None, - request_timeout: Optional[float] = None) -> Execution -``` - -Runs the code as Python. - -Specify the `language` or `context` option to run the code as a different language or in a different `Context`. - -You can reference previously defined variables, imports, and functions in the code. - -**Arguments**: - -- `code`: Code to execute -- `language`: Language to use for code execution. If not defined, the default Python context is used. -- `on_stdout`: Callback for stdout messages -- `on_stderr`: Callback for stderr messages -- `on_result`: Callback for the `Result` object -- `on_error`: Callback for the `ExecutionError` object -- `envs`: Custom environment variables -- `timeout`: Timeout for the code execution in **seconds** -- `request_timeout`: Timeout for the request in **seconds** - -**Returns**: - -`Execution` result object - - -### run\_code - -```python -@overload -def run_code(code: str, - language: Optional[str] = None, - on_stdout: Optional[OutputHandler[OutputMessage]] = None, - on_stderr: Optional[OutputHandler[OutputMessage]] = None, - on_result: Optional[OutputHandler[Result]] = None, - on_error: Optional[OutputHandler[ExecutionError]] = None, - envs: Optional[Dict[str, str]] = None, - timeout: Optional[float] = None, - request_timeout: Optional[float] = None) -> Execution -``` - -Runs the code for the specified language. - -Specify the `language` or `context` option to run the code as a different language or in a different `Context`. -If no language is specified, Python is used. - -You can reference previously defined variables, imports, and functions in the code. - -**Arguments**: - -- `code`: Code to execute -- `language`: Language to use for code execution. If not defined, the default Python context is used. -- `on_stdout`: Callback for stdout messages -- `on_stderr`: Callback for stderr messages -- `on_result`: Callback for the `Result` object -- `on_error`: Callback for the `ExecutionError` object -- `envs`: Custom environment variables -- `timeout`: Timeout for the code execution in **seconds** -- `request_timeout`: Timeout for the request in **seconds** - -**Returns**: - -`Execution` result object - - -### run\_code - -```python -@overload -def run_code(code: str, - context: Optional[Context] = None, - on_stdout: Optional[OutputHandler[OutputMessage]] = None, - on_stderr: Optional[OutputHandler[OutputMessage]] = None, - on_result: Optional[OutputHandler[Result]] = None, - on_error: Optional[OutputHandler[ExecutionError]] = None, - envs: Optional[Dict[str, str]] = None, - timeout: Optional[float] = None, - request_timeout: Optional[float] = None) -> Execution -``` - -Runs the code in the specified context, if not specified, the default context is used. - -Specify the `language` or `context` option to run the code as a different language or in a different `Context`. - -You can reference previously defined variables, imports, and functions in the code. - -**Arguments**: - -- `code`: Code to execute -- `context`: Concrete context to run the code in. If not specified, the default context for the language is used. It's mutually exclusive with the language. -- `on_stdout`: Callback for stdout messages -- `on_stderr`: Callback for stderr messages -- `on_result`: Callback for the `Result` object -- `on_error`: Callback for the `ExecutionError` object -- `envs`: Custom environment variables -- `timeout`: Timeout for the code execution in **seconds** -- `request_timeout`: Timeout for the request in **seconds** - -**Returns**: - -`Execution` result object - - -### create\_code\_context - -```python -def create_code_context(cwd: Optional[str] = None, - language: Optional[str] = None, - request_timeout: Optional[float] = None) -> Context -``` - -Creates a new context to run code in. - -**Arguments**: - -- `cwd`: Set the current working directory for the context, defaults to `/home/user` -- `language`: Language of the context. If not specified, defaults to Python -- `request_timeout`: Timeout for the request in **milliseconds** - -**Returns**: - -Context object - - - - - - -## ChartType - -```python -class ChartType(str, enum.Enum) -``` - -Chart types - - -## ScaleType - -```python -class ScaleType(str, enum.Enum) -``` - -Ax scale types - - -## Chart - -```python -class Chart() -``` - -Extracted data from a chart. It's useful for building an interactive charts or custom visualizations. - - - - - - ## OutputMessage ```python @@ -557,6 +358,8 @@ The working directory of the context. + + ## AsyncSandbox ```python @@ -720,3 +523,200 @@ Creates a new context to run code in. Context object + + + +## ChartType + +```python +class ChartType(str, enum.Enum) +``` + +Chart types + + +## ScaleType + +```python +class ScaleType(str, enum.Enum) +``` + +Ax scale types + + +## Chart + +```python +class Chart() +``` + +Extracted data from a chart. It's useful for building an interactive charts or custom visualizations. + + + + + + +## Sandbox + +```python +class Sandbox(BaseSandbox) +``` + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs [here](https://e2b.dev/docs). + +Use the `Sandbox()` to create a new sandbox. + +**Example**: + +```python +from e2b_code_interpreter import Sandbox + +sandbox = Sandbox() +``` + + +### run\_code + +```python +@overload +def run_code(code: str, + language: Union[Literal["python"], None] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +def run_code(code: str, + language: Optional[str] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +def run_code(code: str, + context: Optional[Context] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `context`: Concrete context to run the code in. If not specified, the default context for the language is used. It's mutually exclusive with the language. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### create\_code\_context + +```python +def create_code_context(cwd: Optional[str] = None, + language: Optional[str] = None, + request_timeout: Optional[float] = None) -> Context +``` + +Creates a new context to run code in. + +**Arguments**: + +- `cwd`: Set the current working directory for the context, defaults to `/home/user` +- `language`: Language of the context. If not specified, defaults to Python +- `request_timeout`: Timeout for the request in **milliseconds** + +**Returns**: + +Context object + diff --git a/template/package.json b/template/package.json index 24a4e53e..222d0d21 100644 --- a/template/package.json +++ b/template/package.json @@ -1,5 +1,5 @@ { "name": "@e2b/code-interpreter-template", "private": true, - "version": "0.0.9" + "version": "0.0.10" } From 19af07f5ce78c2778dc86984442e4b1215fc4855 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 03:14:25 -0700 Subject: [PATCH 20/27] Bump setuptools in /python in the pip group across 1 directory (#110) Bumps the pip group with 1 update in the /python directory: [setuptools](https://github.com/pypa/setuptools). Updates `setuptools` from 75.3.0 to 78.1.1 - [Release notes](https://github.com/pypa/setuptools/releases) - [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst) - [Commits](https://github.com/pypa/setuptools/compare/v75.3.0...v78.1.1) --- updated-dependencies: - dependency-name: setuptools dependency-version: 78.1.1 dependency-type: indirect dependency-group: pip ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- python/poetry.lock | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/python/poetry.lock b/python/poetry.lock index efda3671..70a17901 100644 --- a/python/poetry.lock +++ b/python/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. [[package]] name = "anyio" @@ -239,7 +239,7 @@ description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" groups = ["dev"] -markers = "sys_platform == \"win32\" or platform_system == \"Windows\"" +markers = "platform_system == \"Windows\" or sys_platform == \"win32\"" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, @@ -938,25 +938,24 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "setuptools" -version = "75.3.0" +version = "78.1.1" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" groups = ["dev"] -markers = "python_version == \"3.9\"" files = [ - {file = "setuptools-75.3.0-py3-none-any.whl", hash = "sha256:f2504966861356aa38616760c0f66568e535562374995367b4e69c7143cf6bcd"}, - {file = "setuptools-75.3.0.tar.gz", hash = "sha256:fba5dd4d766e97be1b1681d98712680ae8f2f26d7881245f2ce9e40714f1a686"}, + {file = "setuptools-78.1.1-py3-none-any.whl", hash = "sha256:c3a9c4211ff4c309edb8b8c4f1cbfa7ae324c4ba9f91ff254e3d305b9fd54561"}, + {file = "setuptools-78.1.1.tar.gz", hash = "sha256:fcc17fd9cd898242f6b4adfaca46137a9edef687f43e6f78469692a5e70d851d"}, ] [package.extras] -check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\"", "ruff (>=0.5.2) ; sys_platform != \"cygwin\""] -core = ["importlib-metadata (>=6) ; python_version < \"3.10\"", "importlib-resources (>=5.10.2) ; python_version < \"3.9\"", "jaraco.collections", "jaraco.functools", "jaraco.text (>=3.7)", "more-itertools", "more-itertools (>=8.8)", "packaging", "packaging (>=24)", "platformdirs (>=4.2.2)", "tomli (>=2.0.1) ; python_version < \"3.11\"", "wheel (>=0.43.0)"] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\"", "ruff (>=0.8.0) ; sys_platform != \"cygwin\""] +core = ["importlib_metadata (>=6) ; python_version < \"3.10\"", "jaraco.functools (>=4)", "jaraco.text (>=3.7)", "more_itertools", "more_itertools (>=8.8)", "packaging (>=24.2)", "platformdirs (>=4.2.2)", "tomli (>=2.0.1) ; python_version < \"3.11\"", "wheel (>=0.43.0)"] cover = ["pytest-cov"] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "pyproject-hooks (!=1.1)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier", "towncrier (<24.7)"] enabler = ["pytest-enabler (>=2.2)"] -test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21) ; python_version >= \"3.9\" and sys_platform != \"cygwin\"", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "jaraco.test (>=5.5)", "packaging (>=23.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.*)", "pytest-home (>=0.5)", "pytest-perf ; sys_platform != \"cygwin\"", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel (>=0.44.0)"] -type = ["importlib-metadata (>=7.0.2) ; python_version < \"3.10\"", "jaraco.develop (>=7.21) ; sys_platform != \"cygwin\"", "mypy (==1.12.*)", "pytest-mypy"] +test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21) ; python_version >= \"3.9\" and sys_platform != \"cygwin\"", "jaraco.envs (>=2.2)", "jaraco.path (>=3.7.2)", "jaraco.test (>=5.5)", "packaging (>=24.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.*)", "pytest-home (>=0.5)", "pytest-perf ; sys_platform != \"cygwin\"", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel (>=0.44.0)"] +type = ["importlib_metadata (>=7.0.2) ; python_version < \"3.10\"", "jaraco.develop (>=7.21) ; sys_platform != \"cygwin\"", "mypy (==1.14.*)", "pytest-mypy"] [[package]] name = "six" From 8f381069366c899a6416afcafdd079fb5a3e3801 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 May 2025 13:27:45 -0700 Subject: [PATCH 21/27] Bump tornado in /template in the pip group across 1 directory (#112) Bumps the pip group with 1 update in the /template directory: [tornado](https://github.com/tornadoweb/tornado). Updates `tornado` from 6.4.2 to 6.5.1 - [Changelog](https://github.com/tornadoweb/tornado/blob/master/docs/releases.rst) - [Commits](https://github.com/tornadoweb/tornado/compare/v6.4.2...v6.5.1) --- updated-dependencies: - dependency-name: tornado dependency-version: 6.5.1 dependency-type: direct:production dependency-group: pip ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- template/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/requirements.txt b/template/requirements.txt index 3d185173..3adbfdb5 100644 --- a/template/requirements.txt +++ b/template/requirements.txt @@ -36,7 +36,7 @@ seaborn==0.13.2 soundfile==0.13.1 spacy==3.8.2 # doesn't work on 3.13.x textblob==0.19.0 -tornado==6.4.2 +tornado==6.5.1 urllib3==2.4.0 xarray==2025.4.0 xlrd==2.0.1 From e9e0903a4070eb21b2e2fe2473c5e23f47336936 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Wed, 28 May 2025 14:53:18 +0200 Subject: [PATCH 22/27] Updated JavaScript kernel with typescript, top-level async/await, es module import, promise resolution (#111) * e2b ijavascript kernel * removed compiler step * e2b ijavascript * removed ts compiler from dockerfile * removed tests that should no longer be failing * added changeset --- .changeset/breezy-bananas-lay.md | 5 ++++ js/tests/defaultKernels.test.ts | 7 ----- .../tests/async/test_async_default_kernels.py | 8 ------ python/tests/sync/test_default_kernels.py | 5 ---- template/.ts.swcrc | 15 ----------- template/Dockerfile | 6 +---- template/server/messaging.py | 26 ------------------- template/test.Dockerfile | 6 +---- 8 files changed, 7 insertions(+), 71 deletions(-) create mode 100644 .changeset/breezy-bananas-lay.md delete mode 100644 template/.ts.swcrc diff --git a/.changeset/breezy-bananas-lay.md b/.changeset/breezy-bananas-lay.md new file mode 100644 index 00000000..c7d185b0 --- /dev/null +++ b/.changeset/breezy-bananas-lay.md @@ -0,0 +1,5 @@ +--- +'@e2b/code-interpreter-template': patch +--- + +updated ijavascript kernel in the template diff --git a/js/tests/defaultKernels.test.ts b/js/tests/defaultKernels.test.ts index 5750644a..41bc245b 100644 --- a/js/tests/defaultKernels.test.ts +++ b/js/tests/defaultKernels.test.ts @@ -16,10 +16,3 @@ sandboxTest('test ts kernel', async ({ sandbox }) => { ) expect(output.logs.stdout).toEqual(['Hello World!\n']) }) - -sandboxTest('test ts kernel errors', async ({ sandbox }) => { - const output = await sandbox.runCode('import x from "module";', { - language: 'typescript', - }) - expect(output.error?.name).toEqual('TypeScriptCompilerError') -}) diff --git a/python/tests/async/test_async_default_kernels.py b/python/tests/async/test_async_default_kernels.py index 83f92746..88df4a94 100644 --- a/python/tests/async/test_async_default_kernels.py +++ b/python/tests/async/test_async_default_kernels.py @@ -13,11 +13,3 @@ async def test_ts_kernel(async_sandbox: AsyncSandbox): "const message: string = 'Hello, World!'; console.log(message);", language="ts" ) assert execution.logs.stdout == ["Hello, World!\n"] - - -async def test_ts_kernel_errors(async_sandbox: AsyncSandbox): - execution = await async_sandbox.run_code( - "import x from 'module';", language="ts" - ) - assert execution.error is not None - assert execution.error.name == "TypeScriptCompilerError" diff --git a/python/tests/sync/test_default_kernels.py b/python/tests/sync/test_default_kernels.py index 0695defd..71abadfc 100644 --- a/python/tests/sync/test_default_kernels.py +++ b/python/tests/sync/test_default_kernels.py @@ -25,8 +25,3 @@ def test_ts_kernel(sandbox: Sandbox): execution = sandbox.run_code("const message: string = 'Hello, World!'; console.log(message)", language="ts") assert execution.logs.stdout == ["Hello, World!\n"] - -def test_ts_kernel_errors(sandbox: Sandbox): - execution = sandbox.run_code("import x from 'module';", language="ts") - assert execution.error is not None - assert execution.error.name == "TypeScriptCompilerError" diff --git a/template/.ts.swcrc b/template/.ts.swcrc deleted file mode 100644 index cf7cb8d3..00000000 --- a/template/.ts.swcrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "https://swc.rs/schema.json", - "jsc": { - "parser": { - "syntax": "typescript" - } - }, - "module": { - "type": "commonjs" - }, - "env": { - "targets": "node 20" - }, - "isModule": false -} diff --git a/template/Dockerfile b/template/Dockerfile index c48f7df9..a4bb24d0 100644 --- a/template/Dockerfile +++ b/template/Dockerfile @@ -28,13 +28,9 @@ RUN R -e "install.packages('IRkernel', repos='https://cloud.r-project.org')" RUN R -e "IRkernel::installspec(user = FALSE, name = 'r', displayname = 'R')" # Javascript Kernel -RUN npm install -g --unsafe-perm ijavascript +RUN npm install -g --unsafe-perm git+https://github.com/e2b-dev/ijavascript.git RUN ijsinstall --install=global -## TypeScript compiler -RUN npm install -g @swc/cli @swc/core -COPY .ts.swcrc $SERVER_PATH/.ts.swcrc - # Deno Kernel COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno RUN chmod +x /usr/bin/deno diff --git a/template/server/messaging.py b/template/server/messaging.py index d2894d92..9fe4e081 100644 --- a/template/server/messaging.py +++ b/template/server/messaging.py @@ -199,32 +199,6 @@ async def execute( + code ) - if self.language == "typescript": - logger.info("Compiling TypeScript: %s", code) - - # call SWC to compile the typescript code - try: - compile_result = subprocess.run("swc --config-file .ts.swcrc --filename index.ts".split(), input=code.encode(), capture_output=True) - - if compile_result.returncode != 0: - logger.error("Error during TypeScript compilation: %s", compile_result.stderr.decode()) - yield Error( - name="TypeScriptCompilerError", - value=compile_result.stderr.decode(), - traceback="", - ) - return - - code = compile_result.stdout.decode() - except Exception as e: - logger.error("Error starting SWC process: %s", e) - yield Error( - name="TypeScriptCompilerError", - value=str(e), - traceback="", - ) - return - logger.info(code) request = self._get_execute_request(message_id, code, False) diff --git a/template/test.Dockerfile b/template/test.Dockerfile index 9a6c2f21..14eb0005 100644 --- a/template/test.Dockerfile +++ b/template/test.Dockerfile @@ -23,13 +23,9 @@ COPY ./template/requirements.txt requirements.txt RUN pip install --no-cache-dir -r requirements.txt && ipython kernel install --name "python3" --user # Javascript Kernel -RUN npm install -g --unsafe-perm ijavascript +RUN npm install -g --unsafe-perm git+https://github.com/e2b-dev/ijavascript.git RUN ijsinstall --install=global -## TypeScript compiler -RUN npm install -g @swc/cli @swc/core -COPY ./template/.ts.swcrc $SERVER_PATH/.ts.swcrc - # Deno Kernel COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno RUN chmod +x /usr/bin/deno From 585543f98d19d0273cc2cd38f1a51087bf397579 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 28 May 2025 13:08:52 +0000 Subject: [PATCH 23/27] [skip ci] Release new versions --- .changeset/breezy-bananas-lay.md | 5 ----- template/package.json | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 .changeset/breezy-bananas-lay.md diff --git a/.changeset/breezy-bananas-lay.md b/.changeset/breezy-bananas-lay.md deleted file mode 100644 index c7d185b0..00000000 --- a/.changeset/breezy-bananas-lay.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@e2b/code-interpreter-template': patch ---- - -updated ijavascript kernel in the template diff --git a/template/package.json b/template/package.json index 222d0d21..fd7d6236 100644 --- a/template/package.json +++ b/template/package.json @@ -1,5 +1,5 @@ { "name": "@e2b/code-interpreter-template", "private": true, - "version": "0.0.10" + "version": "0.0.11" } From 85cac9199b9ed5e4b59a4eb9afb7117ccb142640 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Wed, 28 May 2025 19:34:18 +0200 Subject: [PATCH 24/27] added tests for new js kernel (#113) --- js/tests/defaultKernels.test.ts | 28 +++++++++++++++++++ .../tests/async/test_async_default_kernels.py | 14 ++++++++++ python/tests/sync/test_default_kernels.py | 15 ++++++++++ 3 files changed, 57 insertions(+) diff --git a/js/tests/defaultKernels.test.ts b/js/tests/defaultKernels.test.ts index 41bc245b..f5fce337 100644 --- a/js/tests/defaultKernels.test.ts +++ b/js/tests/defaultKernels.test.ts @@ -9,6 +9,34 @@ sandboxTest('test js kernel', async ({ sandbox }) => { expect(output.logs.stdout).toEqual(['Hello World!\n']) }) +sandboxTest('test esm imports', async ({ sandbox }) => { + const output = await sandbox.runCode( + ` + import { readFileSync } from 'fs' + console.log(typeof readFileSync) + `, + { + language: 'js', + } + ) + expect(output.logs.stdout).toEqual(['function\n']) +}) + +sandboxTest( + 'test top-level await and promise resolution', + async ({ sandbox }) => { + const output = await sandbox.runCode( + ` + await Promise.resolve('Hello World!') + `, + { + language: 'js', + } + ) + expect(output.text).toEqual('Hello World!') + } +) + sandboxTest('test ts kernel', async ({ sandbox }) => { const output = await sandbox.runCode( 'const message: string = "Hello World!"; console.log(message)', diff --git a/python/tests/async/test_async_default_kernels.py b/python/tests/async/test_async_default_kernels.py index 88df4a94..23b01b35 100644 --- a/python/tests/async/test_async_default_kernels.py +++ b/python/tests/async/test_async_default_kernels.py @@ -7,6 +7,20 @@ async def test_js_kernel(async_sandbox: AsyncSandbox): ) assert execution.logs.stdout == ["Hello, World!\n"] +async def test_js_esm_imports(async_sandbox: AsyncSandbox): + execution = await async_sandbox.run_code(""" + import { readFileSync } from 'fs' + console.log(typeof readFileSync) + """, language="js") + assert execution.logs.stdout == ["function\n"] + + +async def test_js_top_level_await(async_sandbox: AsyncSandbox): + execution = await async_sandbox.run_code(""" + await Promise.resolve('Hello World!') + """, language="js") + assert execution.text == "Hello World!" + async def test_ts_kernel(async_sandbox: AsyncSandbox): execution = await async_sandbox.run_code( diff --git a/python/tests/sync/test_default_kernels.py b/python/tests/sync/test_default_kernels.py index 71abadfc..998a39e8 100644 --- a/python/tests/sync/test_default_kernels.py +++ b/python/tests/sync/test_default_kernels.py @@ -20,6 +20,21 @@ def test_java_kernel(sandbox: Sandbox): assert execution.logs.stdout[0] == "Hello, World!" +def test_js_esm_imports(sandbox: Sandbox): + execution = sandbox.run_code(""" + import { readFileSync } from 'fs' + console.log(typeof readFileSync) + """, language="js") + assert execution.logs.stdout == ["function\n"] + + +def test_js_top_level_await(sandbox: Sandbox): + execution = sandbox.run_code(""" + await Promise.resolve('Hello World!') + """, language="js") + assert execution.text == "Hello World!" + + @pytest.mark.skip_debug() def test_ts_kernel(sandbox: Sandbox): execution = sandbox.run_code("const message: string = 'Hello, World!'; console.log(message)", language="ts") From 2b7833b6b9ab413ecacd6926c1b2833b2ca278c2 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Thu, 5 Jun 2025 16:24:59 +0200 Subject: [PATCH 25/27] added MIT license to code-interpreter SDKs and charts library (#117) --- .changeset/shaggy-cups-compare.md | 7 +++++++ chart_data_extractor/LICENSE | 9 +++++++++ chart_data_extractor/pyproject.toml | 2 +- js/LICENSE | 9 +++++++++ python/LICENSE | 9 +++++++++ python/pyproject.toml | 2 +- 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 .changeset/shaggy-cups-compare.md create mode 100644 chart_data_extractor/LICENSE create mode 100644 js/LICENSE create mode 100644 python/LICENSE diff --git a/.changeset/shaggy-cups-compare.md b/.changeset/shaggy-cups-compare.md new file mode 100644 index 00000000..2242a953 --- /dev/null +++ b/.changeset/shaggy-cups-compare.md @@ -0,0 +1,7 @@ +--- +'@e2b/data-extractor': patch +'@e2b/code-interpreter-python': patch +'@e2b/code-interpreter': patch +--- + +added MIT License source diff --git a/chart_data_extractor/LICENSE b/chart_data_extractor/LICENSE new file mode 100644 index 00000000..4aa6529d --- /dev/null +++ b/chart_data_extractor/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2025 FOUNDRYLABS, INC. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/chart_data_extractor/pyproject.toml b/chart_data_extractor/pyproject.toml index 6ca00367..4694b151 100644 --- a/chart_data_extractor/pyproject.toml +++ b/chart_data_extractor/pyproject.toml @@ -3,7 +3,7 @@ name = "e2b-charts" version = "0.0.3" description = "Package for extracting data for E2B Code Interpreter" authors = ["e2b "] -license = "Apache-2.0" +license = "MIT" readme = "README.md" homepage = "https://e2b.dev/" repository = "https://github.com/e2b-dev/e2b-code-interpreter/tree/python" diff --git a/js/LICENSE b/js/LICENSE new file mode 100644 index 00000000..4aa6529d --- /dev/null +++ b/js/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2025 FOUNDRYLABS, INC. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/python/LICENSE b/python/LICENSE new file mode 100644 index 00000000..4aa6529d --- /dev/null +++ b/python/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2025 FOUNDRYLABS, INC. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/python/pyproject.toml b/python/pyproject.toml index d1d859cf..b8b857a2 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -3,7 +3,7 @@ name = "e2b-code-interpreter" version = "1.5.0" description = "E2B Code Interpreter - Stateful code execution" authors = ["e2b "] -license = "Apache-2.0" +license = "MIT" readme = "README.md" homepage = "https://e2b.dev/" repository = "https://github.com/e2b-dev/code-interpreter/tree/main/python" From c87f122de41b80e1458ffb0e50ea18df4583284a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 5 Jun 2025 14:38:09 +0000 Subject: [PATCH 26/27] [skip ci] Release new versions --- .changeset/shaggy-cups-compare.md | 7 - chart_data_extractor/package.json | 2 +- chart_data_extractor/pyproject.toml | 2 +- js/package.json | 2 +- python/package.json | 2 +- python/pyproject.toml | 2 +- .../v1.5.1/charts/page.mdx | 240 ++++++ .../v1.5.1/consts/page.mdx | 13 + .../v1.5.1/index/page.mdx | 103 +++ .../v1.5.1/messaging/page.mdx | 326 ++++++++ .../v1.5.1/sandbox/page.mdx | 312 ++++++++ .../v1.5.1/sandbox/page.mdx | 722 ++++++++++++++++++ 12 files changed, 1721 insertions(+), 12 deletions(-) delete mode 100644 .changeset/shaggy-cups-compare.md create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.5.1/charts/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.5.1/consts/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.5.1/index/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.5.1/messaging/page.mdx create mode 100644 sdk-reference/code-interpreter-js-sdk/v1.5.1/sandbox/page.mdx create mode 100644 sdk-reference/code-interpreter-python-sdk/v1.5.1/sandbox/page.mdx diff --git a/.changeset/shaggy-cups-compare.md b/.changeset/shaggy-cups-compare.md deleted file mode 100644 index 2242a953..00000000 --- a/.changeset/shaggy-cups-compare.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@e2b/data-extractor': patch -'@e2b/code-interpreter-python': patch -'@e2b/code-interpreter': patch ---- - -added MIT License source diff --git a/chart_data_extractor/package.json b/chart_data_extractor/package.json index 8135e77c..41cb32b8 100644 --- a/chart_data_extractor/package.json +++ b/chart_data_extractor/package.json @@ -1,7 +1,7 @@ { "name": "@e2b/data-extractor", "private": true, - "version": "0.0.3", + "version": "0.0.4", "scripts": { "test": "poetry run pytest -n 4 --verbose -x", "example": "poetry run python3 example.py", diff --git a/chart_data_extractor/pyproject.toml b/chart_data_extractor/pyproject.toml index 4694b151..745d7588 100644 --- a/chart_data_extractor/pyproject.toml +++ b/chart_data_extractor/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "e2b-charts" -version = "0.0.3" +version = "0.0.4" description = "Package for extracting data for E2B Code Interpreter" authors = ["e2b "] license = "MIT" diff --git a/js/package.json b/js/package.json index 27c76fd4..938d5c2e 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "@e2b/code-interpreter", - "version": "1.5.0", + "version": "1.5.1", "packageManager": "pnpm@8.7.6", "description": "E2B Code Interpreter - Stateful code execution", "homepage": "https://e2b.dev", diff --git a/python/package.json b/python/package.json index cee595b9..319c24d6 100644 --- a/python/package.json +++ b/python/package.json @@ -1,7 +1,7 @@ { "name": "@e2b/code-interpreter-python", "private": true, - "version": "1.5.0", + "version": "1.5.1", "packageManager": "pnpm@8.7.6", "scripts": { "test": "poetry run pytest -n 4 --verbose -x", diff --git a/python/pyproject.toml b/python/pyproject.toml index b8b857a2..4208cf65 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "e2b-code-interpreter" -version = "1.5.0" +version = "1.5.1" description = "E2B Code Interpreter - Stateful code execution" authors = ["e2b "] license = "MIT" diff --git a/sdk-reference/code-interpreter-js-sdk/v1.5.1/charts/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.5.1/charts/page.mdx new file mode 100644 index 00000000..f3176d3b --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.5.1/charts/page.mdx @@ -0,0 +1,240 @@ +### ChartType + +Chart types + +#### Enumeration Members + +| Enumeration Member | Value | +| ------ | ------ | +| `BAR` | `"bar"` | +| `BOX_AND_WHISKER` | `"box_and_whisker"` | +| `LINE` | `"line"` | +| `PIE` | `"pie"` | +| `SCATTER` | `"scatter"` | +| `SUPERCHART` | `"superchart"` | +| `UNKNOWN` | `"unknown"` | + +*** + +### ScaleType + +Ax scale types + +#### Enumeration Members + +| Enumeration Member | Value | +| ------ | ------ | +| `ASINH` | `"asinh"` | +| `CATEGORICAL` | `"categorical"` | +| `DATETIME` | `"datetime"` | +| `FUNCTION` | `"function"` | +| `FUNCTIONLOG` | `"functionlog"` | +| `LINEAR` | `"linear"` | +| `LOG` | `"log"` | +| `LOGIT` | `"logit"` | +| `SYMLOG` | `"symlog"` | + +## Type Aliases + +### BarChart + +```ts +type BarChart: Chart2D & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `BarData`[] | +| `type` | `ChartType.BAR` | + +*** + +### BarData + +```ts +type BarData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `group` | `string` | +| `label` | `string` | +| `value` | `string` | + +*** + +### BoxAndWhiskerChart + +```ts +type BoxAndWhiskerChart: Chart2D & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `BoxAndWhiskerData`[] | +| `type` | `ChartType.BOX_AND_WHISKER` | + +*** + +### BoxAndWhiskerData + +```ts +type BoxAndWhiskerData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `first_quartile` | `number` | +| `label` | `string` | +| `max` | `number` | +| `median` | `number` | +| `min` | `number` | +| `outliers` | `number`[] | +| `third_quartile` | `number` | + +*** + +### Chart + +```ts +type Chart: object; +``` + +Represents a chart. + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `any`[] | +| `title` | `string` | +| `type` | `ChartType` | + +*** + +### ChartTypes + +```ts +type ChartTypes: + | LineChart + | ScatterChart + | BarChart + | PieChart + | BoxAndWhiskerChart + | SuperChart; +``` + +*** + +### LineChart + +```ts +type LineChart: PointChart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `type` | `ChartType.LINE` | + +*** + +### PieChart + +```ts +type PieChart: Chart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `PieData`[] | +| `type` | `ChartType.PIE` | + +*** + +### PieData + +```ts +type PieData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `angle` | `number` | +| `label` | `string` | +| `radius` | `number` | + +*** + +### PointData + +```ts +type PointData: object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `label` | `string` | +| `points` | [`number` \| `string`, `number` \| `string`][] | + +*** + +### ScatterChart + +```ts +type ScatterChart: PointChart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `type` | `ChartType.SCATTER` | + +*** + +### SuperChart + +```ts +type SuperChart: Chart & object; +``` + +#### Type declaration + +| Name | Type | +| ------ | ------ | +| `elements` | `Chart`[] | +| `type` | `ChartType.SUPERCHART` | + +## Functions + +### deserializeChart() + +```ts +function deserializeChart(data: any): Chart +``` + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| `data` | `any` | + +#### Returns + +`Chart` diff --git a/sdk-reference/code-interpreter-js-sdk/v1.5.1/consts/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.5.1/consts/page.mdx new file mode 100644 index 00000000..d1ee2e76 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.5.1/consts/page.mdx @@ -0,0 +1,13 @@ +### DEFAULT\_TIMEOUT\_MS + +```ts +const DEFAULT_TIMEOUT_MS: 60000 = 60_000; +``` + +*** + +### JUPYTER\_PORT + +```ts +const JUPYTER_PORT: 49999 = 49999; +``` diff --git a/sdk-reference/code-interpreter-js-sdk/v1.5.1/index/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.5.1/index/page.mdx new file mode 100644 index 00000000..dc55fcc7 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.5.1/index/page.mdx @@ -0,0 +1,103 @@ +### BarChart + +Re-exports BarChart + +### BarData + +Re-exports BarData + +### BoxAndWhiskerChart + +Re-exports BoxAndWhiskerChart + +### BoxAndWhiskerData + +Re-exports BoxAndWhiskerData + +### Chart + +Re-exports Chart + +### ChartType + +Re-exports ChartType + +### ChartTypes + +Re-exports ChartTypes + +### Context + +Re-exports Context + +### CreateCodeContextOpts + +Re-exports CreateCodeContextOpts + +### default + +Renames and re-exports Sandbox + +### Execution + +Re-exports Execution + +### ExecutionError + +Re-exports ExecutionError + +### LineChart + +Re-exports LineChart + +### Logs + +Re-exports Logs + +### MIMEType + +Re-exports MIMEType + +### OutputMessage + +Re-exports OutputMessage + +### PieChart + +Re-exports PieChart + +### PieData + +Re-exports PieData + +### PointData + +Re-exports PointData + +### RawData + +Re-exports RawData + +### Result + +Re-exports Result + +### RunCodeOpts + +Re-exports RunCodeOpts + +### Sandbox + +Re-exports Sandbox + +### ScaleType + +Re-exports ScaleType + +### ScatterChart + +Re-exports ScatterChart + +### SuperChart + +Re-exports SuperChart diff --git a/sdk-reference/code-interpreter-js-sdk/v1.5.1/messaging/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.5.1/messaging/page.mdx new file mode 100644 index 00000000..4b3c4ed9 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.5.1/messaging/page.mdx @@ -0,0 +1,326 @@ +### Execution + +Represents the result of a cell execution. + +#### Constructors + +```ts +new Execution( + results: Result[], + logs: Logs, + error?: ExecutionError, + executionCount?: number): Execution +``` + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `results` | `Result`[] | `[]` | List of result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots). | +| `logs` | `Logs` | `...` | Logs printed to stdout and stderr during execution. | +| `error`? | `ExecutionError` | `undefined` | An Error object if an error occurred, null otherwise. | +| `executionCount`? | `number` | `undefined` | Execution count of the cell. | + +###### Returns + +`Execution` + +#### Properties + +| Property | Modifier | Type | Default value | Description | +| ------ | ------ | ------ | ------ | ------ | +| `error?` | `public` | `ExecutionError` | `undefined` | An Error object if an error occurred, null otherwise. | +| `executionCount?` | `public` | `number` | `undefined` | Execution count of the cell. | +| `logs` | `public` | `Logs` | `undefined` | Logs printed to stdout and stderr during execution. | +| `results` | `public` | `Result`[] | `[]` | List of result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots). | + +#### Accessors + +### text + +```ts +get text(): undefined | string +``` + +Returns the text representation of the main result of the cell. + +###### Returns + +`undefined` \| `string` + +#### Methods + +### toJSON() + +```ts +toJSON(): object +``` + +Returns the serializable representation of the execution result. + +###### Returns + +`object` + +| Name | Type | +| ------ | ------ | +| `error` | `undefined` \| `ExecutionError` | +| `logs` | `Logs` | +| `results` | `Result`[] | + +*** + +### ExecutionError + +Represents an error that occurred during the execution of a cell. +The error contains the name of the error, the value of the error, and the traceback. + +#### Constructors + +```ts +new ExecutionError( + name: string, + value: string, + traceback: string): ExecutionError +``` + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `name` | `string` | Name of the error. | +| `value` | `string` | Value of the error. | +| `traceback` | `string` | The raw traceback of the error. | + +###### Returns + +`ExecutionError` + +#### Properties + +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `name` | `public` | `string` | Name of the error. | +| `traceback` | `public` | `string` | The raw traceback of the error. | +| `value` | `public` | `string` | Value of the error. | + +*** + +### OutputMessage + +Represents an output message from the sandbox code execution. + +#### Constructors + +```ts +new OutputMessage( + line: string, + timestamp: number, + error: boolean): OutputMessage +``` + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `line` | `string` | The output line. | +| `timestamp` | `number` | Unix epoch in nanoseconds. | +| `error` | `boolean` | Whether the output is an error. | + +###### Returns + +`OutputMessage` + +#### Properties + +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `error` | `readonly` | `boolean` | Whether the output is an error. | +| `line` | `readonly` | `string` | The output line. | +| `timestamp` | `readonly` | `number` | Unix epoch in nanoseconds. | + +#### Methods + +### toString() + +```ts +toString(): string +``` + +###### Returns + +`string` + +*** + +### Result + +Represents the data to be displayed as a result of executing a cell in a Jupyter notebook. +The result is similar to the structure returned by ipython kernel: https://ipython.readthedocs.io/en/stable/development/execution.html#execution-semantics + +The result can contain multiple types of data, such as text, images, plots, etc. Each type of data is represented +as a string, and the result can contain multiple types of data. The display calls don't have to have text representation, +for the actual result the representation is always present for the result, the other representations are always optional. + +#### Constructors + +```ts +new Result(rawData: RawData, isMainResult: boolean): Result +``` + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `rawData` | `RawData` | +| `isMainResult` | `boolean` | + +###### Returns + +`Result` + +#### Properties + +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `chart?` | `readonly` | `ChartTypes` | Contains the chart data. | +| `data?` | `readonly` | `Record`\<`string`, `unknown`\> | Contains the data from DataFrame. | +| `extra?` | `readonly` | `any` | Extra data that can be included. Not part of the standard types. | +| `html?` | `readonly` | `string` | HTML representation of the data. | +| `isMainResult` | `readonly` | `boolean` | - | +| `javascript?` | `readonly` | `string` | JavaScript representation of the data. | +| `jpeg?` | `readonly` | `string` | JPEG representation of the data. | +| `json?` | `readonly` | `string` | JSON representation of the data. | +| `latex?` | `readonly` | `string` | LaTeX representation of the data. | +| `markdown?` | `readonly` | `string` | Markdown representation of the data. | +| `pdf?` | `readonly` | `string` | PDF representation of the data. | +| `png?` | `readonly` | `string` | PNG representation of the data. | +| `raw` | `readonly` | `RawData` | - | +| `svg?` | `readonly` | `string` | SVG representation of the data. | +| `text?` | `readonly` | `string` | Text representation of the result. | + +#### Methods + +### formats() + +```ts +formats(): string[] +``` + +Returns all the formats available for the result. + +###### Returns + +`string`[] + +Array of strings representing the formats available for the result. + +### toJSON() + +```ts +toJSON(): object +``` + +Returns the serializable representation of the result. + +###### Returns + +`object` + +| Name | Type | +| ------ | ------ | +| `extra`? | `any` | +| `html` | `undefined` \| `string` | +| `javascript` | `undefined` \| `string` | +| `jpeg` | `undefined` \| `string` | +| `json` | `undefined` \| `string` | +| `latex` | `undefined` \| `string` | +| `markdown` | `undefined` \| `string` | +| `pdf` | `undefined` \| `string` | +| `png` | `undefined` \| `string` | +| `svg` | `undefined` \| `string` | +| `text` | `undefined` \| `string` | + +## Type Aliases + +### Logs + +```ts +type Logs: object; +``` + +Data printed to stdout and stderr during execution, usually by print statements, logs, warnings, subprocesses, etc. + +#### Type declaration + +| Name | Type | Description | +| ------ | ------ | ------ | +| `stderr` | `string`[] | List of strings printed to stderr by prints, subprocesses, etc. | +| `stdout` | `string`[] | List of strings printed to stdout by prints, subprocesses, etc. | + +*** + +### MIMEType + +```ts +type MIMEType: string; +``` + +Represents a MIME type. + +*** + +### RawData + +```ts +type RawData: object & E2BData; +``` + +Dictionary that maps MIME types to their corresponding representations of the data. + +## Functions + +### extractError() + +```ts +function extractError(res: Response): Promise +``` + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| `res` | `Response` | + +#### Returns + +`Promise`\<`undefined` \| `SandboxError`\> + +*** + +### parseOutput() + +```ts +function parseOutput( + execution: Execution, + line: string, + onStdout?: (output: OutputMessage) => any, + onStderr?: (output: OutputMessage) => any, + onResult?: (data: Result) => any, +onError?: (error: ExecutionError) => any): Promise +``` + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| `execution` | `Execution` | +| `line` | `string` | +| `onStdout`? | (`output`: `OutputMessage`) => `any` | +| `onStderr`? | (`output`: `OutputMessage`) => `any` | +| `onResult`? | (`data`: `Result`) => `any` | +| `onError`? | (`error`: `ExecutionError`) => `any` | + +#### Returns + +`Promise`\<`void`\> diff --git a/sdk-reference/code-interpreter-js-sdk/v1.5.1/sandbox/page.mdx b/sdk-reference/code-interpreter-js-sdk/v1.5.1/sandbox/page.mdx new file mode 100644 index 00000000..96eafec5 --- /dev/null +++ b/sdk-reference/code-interpreter-js-sdk/v1.5.1/sandbox/page.mdx @@ -0,0 +1,312 @@ +### Sandbox + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs here. + +Use Sandbox.create to create a new sandbox. + +#### Example + +```ts +import { Sandbox } from '@e2b/code-interpreter' + +const sandbox = await Sandbox.create() +``` + +#### Methods + +### createCodeContext() + +```ts +createCodeContext(opts?: CreateCodeContextOpts): Promise +``` + +Creates a new context to run code in. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `opts`? | `CreateCodeContextOpts` | options for creating the context. | + +###### Returns + +`Promise`\<`Context`\> + +context object. + +### runCode() + +###### runCode(code, opts) + +```ts +runCode(code: string, opts?: RunCodeOpts & object): Promise +``` + +Run the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `code` | `string` | code to execute. | +| `opts`? | `RunCodeOpts` & `object` | options for executing the code. | + +###### Returns + +`Promise`\<`Execution`\> + +`Execution` result object. + +###### runCode(code, opts) + +```ts +runCode(code: string, opts?: RunCodeOpts & object): Promise +``` + +Run the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `code` | `string` | code to execute. | +| `opts`? | `RunCodeOpts` & `object` | options for executing the code. | + +###### Returns + +`Promise`\<`Execution`\> + +`Execution` result object. + +###### runCode(code, opts) + +```ts +runCode(code: string, opts?: RunCodeOpts & object): Promise +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `code` | `string` | code to execute. | +| `opts`? | `RunCodeOpts` & `object` | options for executing the code | + +###### Returns + +`Promise`\<`Execution`\> + +`Execution` result object + +## Interfaces + +### CreateCodeContextOpts + +Options for creating a code context. + +#### Properties + +### cwd? + +```ts +optional cwd: string; +``` + +Working directory for the context. + +###### Default + +```ts +/home/user +``` + +### language? + +```ts +optional language: string; +``` + +Language for the context. + +###### Default + +```ts +python +``` + +### requestTimeoutMs? + +```ts +optional requestTimeoutMs: number; +``` + +Timeout for the request in **milliseconds**. + +###### Default + +```ts +30_000 // 30 seconds +``` + +*** + +### RunCodeOpts + +Options for running code. + +#### Properties + +### envs? + +```ts +optional envs: Record; +``` + +Custom environment variables for code execution. + +###### Default + +```ts +{} +``` + +### onError()? + +```ts +optional onError: (error: ExecutionError) => any; +``` + +Callback for handling the `ExecutionError` object. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `error` | `ExecutionError` | + +###### Returns + +`any` + +### onResult()? + +```ts +optional onResult: (data: Result) => any; +``` + +Callback for handling the final execution result. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `data` | `Result` | + +###### Returns + +`any` + +### onStderr()? + +```ts +optional onStderr: (output: OutputMessage) => any; +``` + +Callback for handling stderr messages. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `output` | `OutputMessage` | + +###### Returns + +`any` + +### onStdout()? + +```ts +optional onStdout: (output: OutputMessage) => any; +``` + +Callback for handling stdout messages. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `output` | `OutputMessage` | + +###### Returns + +`any` + +### requestTimeoutMs? + +```ts +optional requestTimeoutMs: number; +``` + +Timeout for the request in **milliseconds**. + +###### Default + +```ts +30_000 // 30 seconds +``` + +### timeoutMs? + +```ts +optional timeoutMs: number; +``` + +Timeout for the code execution in **milliseconds**. + +###### Default + +```ts +60_000 // 60 seconds +``` + +## Type Aliases + +### Context + +```ts +type Context: object; +``` + +Represents a context for code execution. + +#### Type declaration + +| Name | Type | Description | +| ------ | ------ | ------ | +| `cwd` | `string` | The working directory of the context. | +| `id` | `string` | The ID of the context. | +| `language` | `string` | The language of the context. | diff --git a/sdk-reference/code-interpreter-python-sdk/v1.5.1/sandbox/page.mdx b/sdk-reference/code-interpreter-python-sdk/v1.5.1/sandbox/page.mdx new file mode 100644 index 00000000..6bee4003 --- /dev/null +++ b/sdk-reference/code-interpreter-python-sdk/v1.5.1/sandbox/page.mdx @@ -0,0 +1,722 @@ + + + + + +## OutputMessage + +```python +@dataclass +class OutputMessage() +``` + +Represents an output message from the sandbox code execution. + + +### line + +The output line. + + +### timestamp + +Unix epoch in nanoseconds + + +### error + +Whether the output is an error. + + +## ExecutionError + +```python +@dataclass +class ExecutionError() +``` + +Represents an error that occurred during the execution of a cell. +The error contains the name of the error, the value of the error, and the traceback. + + +### name + +Name of the error. + + +### value + +Value of the error. + + +### traceback + +The raw traceback of the error. + + +### to\_json + +```python +def to_json() -> str +``` + +Returns the JSON representation of the Error object. + + +## MIMEType + +```python +class MIMEType(str) +``` + +Represents a MIME type. + + +## Result + +```python +@dataclass +class Result() +``` + +Represents the data to be displayed as a result of executing a cell in a Jupyter notebook. +The result is similar to the structure returned by ipython kernel: https://ipython.readthedocs.io/en/stable/development/execution.html#execution-semantics + +The result can contain multiple types of data, such as text, images, plots, etc. Each type of data is represented +as a string, and the result can contain multiple types of data. The display calls don't have to have text representation, +for the actual result the representation is always present for the result, the other representations are always optional. + + +### is\_main\_result + +Whether this data is the result of the cell. Data can be produced by display calls of which can be multiple in a cell. + + +### extra + +Extra data that can be included. Not part of the standard types. + + +### formats + +```python +def formats() -> Iterable[str] +``` + +Returns all available formats of the result. + +**Returns**: + +All available formats of the result in MIME types. + + +### \_\_str\_\_ + +```python +def __str__() -> Optional[str] +``` + +Returns the text representation of the data. + +**Returns**: + +The text representation of the data. + + +### \_repr\_html\_ + +```python +def _repr_html_() -> Optional[str] +``` + +Returns the HTML representation of the data. + +**Returns**: + +The HTML representation of the data. + + +### \_repr\_markdown\_ + +```python +def _repr_markdown_() -> Optional[str] +``` + +Returns the Markdown representation of the data. + +**Returns**: + +The Markdown representation of the data. + + +### \_repr\_svg\_ + +```python +def _repr_svg_() -> Optional[str] +``` + +Returns the SVG representation of the data. + +**Returns**: + +The SVG representation of the data. + + +### \_repr\_png\_ + +```python +def _repr_png_() -> Optional[str] +``` + +Returns the base64 representation of the PNG data. + +**Returns**: + +The base64 representation of the PNG data. + + +### \_repr\_jpeg\_ + +```python +def _repr_jpeg_() -> Optional[str] +``` + +Returns the base64 representation of the JPEG data. + +**Returns**: + +The base64 representation of the JPEG data. + + +### \_repr\_pdf\_ + +```python +def _repr_pdf_() -> Optional[str] +``` + +Returns the PDF representation of the data. + +**Returns**: + +The PDF representation of the data. + + +### \_repr\_latex\_ + +```python +def _repr_latex_() -> Optional[str] +``` + +Returns the LaTeX representation of the data. + +**Returns**: + +The LaTeX representation of the data. + + +### \_repr\_json\_ + +```python +def _repr_json_() -> Optional[dict] +``` + +Returns the JSON representation of the data. + +**Returns**: + +The JSON representation of the data. + + +### \_repr\_javascript\_ + +```python +def _repr_javascript_() -> Optional[str] +``` + +Returns the JavaScript representation of the data. + +**Returns**: + +The JavaScript representation of the data. + + +## Logs + +```python +@dataclass(repr=False) +class Logs() +``` + +Data printed to stdout and stderr during execution, usually by print statements, logs, warnings, subprocesses, etc. + + +### stdout + +List of strings printed to stdout by prints, subprocesses, etc. + + +### stderr + +List of strings printed to stderr by prints, subprocesses, etc. + + +### to\_json + +```python +def to_json() -> str +``` + +Returns the JSON representation of the Logs object. + + +### serialize\_results + +```python +def serialize_results(results: List[Result]) -> List[Dict[str, str]] +``` + +Serializes the results to JSON. + + +## Execution + +```python +@dataclass(repr=False) +class Execution() +``` + +Represents the result of a cell execution. + + +### results + +List of the result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots). + + +### logs + +Logs printed to stdout and stderr during execution. + + +### error + +Error object if an error occurred, None otherwise. + + +### execution\_count + +Execution count of the cell. + + +### text + +```python +@property +def text() -> Optional[str] +``` + +Returns the text representation of the result. + +**Returns**: + +The text representation of the result. + + +### to\_json + +```python +def to_json() -> str +``` + +Returns the JSON representation of the Execution object. + + +## Context + +```python +@dataclass +class Context() +``` + +Represents a context for code execution. + + +### id + +The ID of the context. + + +### language + +The language of the context. + + +### cwd + +The working directory of the context. + + + + + + +## AsyncSandbox + +```python +class AsyncSandbox(BaseAsyncSandbox) +``` + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs [here](https://e2b.dev/docs). + +Use the `AsyncSandbox.create()` to create a new sandbox. + +**Example**: + +```python +from e2b_code_interpreter import AsyncSandbox +sandbox = await AsyncSandbox.create() +``` + + +### run\_code + +```python +@overload +async def run_code(code: str, + language: Union[Literal["python"], None] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +async def run_code(code: str, + language: Optional[str] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +async def run_code(code: str, + context: Optional[Context] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `context`: Concrete context to run the code in. If not specified, the default context for the language is used. It's mutually exclusive with the language. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### create\_code\_context + +```python +async def create_code_context( + cwd: Optional[str] = None, + language: Optional[str] = None, + request_timeout: Optional[float] = None) -> Context +``` + +Creates a new context to run code in. + +**Arguments**: + +- `cwd`: Set the current working directory for the context, defaults to `/home/user` +- `language`: Language of the context. If not specified, defaults to Python +- `request_timeout`: Timeout for the request in **milliseconds** + +**Returns**: + +Context object + + + + +## ChartType + +```python +class ChartType(str, enum.Enum) +``` + +Chart types + + +## ScaleType + +```python +class ScaleType(str, enum.Enum) +``` + +Ax scale types + + +## Chart + +```python +class Chart() +``` + +Extracted data from a chart. It's useful for building an interactive charts or custom visualizations. + + + + + + +## Sandbox + +```python +class Sandbox(BaseSandbox) +``` + +E2B cloud sandbox is a secure and isolated cloud environment. + +The sandbox allows you to: +- Access Linux OS +- Create, list, and delete files and directories +- Run commands +- Run isolated code +- Access the internet + +Check docs [here](https://e2b.dev/docs). + +Use the `Sandbox()` to create a new sandbox. + +**Example**: + +```python +from e2b_code_interpreter import Sandbox + +sandbox = Sandbox() +``` + + +### run\_code + +```python +@overload +def run_code(code: str, + language: Union[Literal["python"], None] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code as Python. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +def run_code(code: str, + language: Optional[str] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code for the specified language. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. +If no language is specified, Python is used. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `language`: Language to use for code execution. If not defined, the default Python context is used. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### run\_code + +```python +@overload +def run_code(code: str, + context: Optional[Context] = None, + on_stdout: Optional[OutputHandler[OutputMessage]] = None, + on_stderr: Optional[OutputHandler[OutputMessage]] = None, + on_result: Optional[OutputHandler[Result]] = None, + on_error: Optional[OutputHandler[ExecutionError]] = None, + envs: Optional[Dict[str, str]] = None, + timeout: Optional[float] = None, + request_timeout: Optional[float] = None) -> Execution +``` + +Runs the code in the specified context, if not specified, the default context is used. + +Specify the `language` or `context` option to run the code as a different language or in a different `Context`. + +You can reference previously defined variables, imports, and functions in the code. + +**Arguments**: + +- `code`: Code to execute +- `context`: Concrete context to run the code in. If not specified, the default context for the language is used. It's mutually exclusive with the language. +- `on_stdout`: Callback for stdout messages +- `on_stderr`: Callback for stderr messages +- `on_result`: Callback for the `Result` object +- `on_error`: Callback for the `ExecutionError` object +- `envs`: Custom environment variables +- `timeout`: Timeout for the code execution in **seconds** +- `request_timeout`: Timeout for the request in **seconds** + +**Returns**: + +`Execution` result object + + +### create\_code\_context + +```python +def create_code_context(cwd: Optional[str] = None, + language: Optional[str] = None, + request_timeout: Optional[float] = None) -> Context +``` + +Creates a new context to run code in. + +**Arguments**: + +- `cwd`: Set the current working directory for the context, defaults to `/home/user` +- `language`: Language of the context. If not specified, defaults to Python +- `request_timeout`: Timeout for the request in **milliseconds** + +**Returns**: + +Context object + From cef0e440ae901148958366a48e49ca925316cae6 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Fri, 6 Jun 2025 09:31:52 +0200 Subject: [PATCH 27/27] Added CI/CD for code interpreter template (#116) --- .github/workflows/build_test_template.yml | 55 ++++++++++++++++++++ .github/workflows/charts_tests.yml | 2 +- .github/workflows/cleanup_build_template.yml | 33 ++++++++++++ .github/workflows/js_tests.yml | 17 +++++- .github/workflows/pull_request.yml | 23 ++++++++ .github/workflows/python_tests.yml | 11 +++- .github/workflows/release.yml | 17 +++--- js/tests/setup.ts | 6 ++- python/tests/conftest.py | 17 +++--- 9 files changed, 159 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/build_test_template.yml create mode 100644 .github/workflows/cleanup_build_template.yml diff --git a/.github/workflows/build_test_template.yml b/.github/workflows/build_test_template.yml new file mode 100644 index 00000000..e8d6edb2 --- /dev/null +++ b/.github/workflows/build_test_template.yml @@ -0,0 +1,55 @@ +name: Build Template + +on: + workflow_call: + secrets: + E2B_TESTS_ACCESS_TOKEN: + required: true + inputs: + E2B_DOMAIN: + required: false + type: string + outputs: + template_id: + description: "The ID of the built template" + value: ${{ jobs.build.outputs.template_id }} + +permissions: + contents: read + +jobs: + build: + name: Build E2B Template + runs-on: ubuntu-latest + outputs: + template_id: ${{ steps.build-template.outputs.template_id }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set package version + working-directory: ./template + run: | + VERSION=$(cat ../chart_data_extractor/pyproject.toml | grep version | cut -d '"' -f 2) + echo "Version: $VERSION" + sed -i "s/e2b_charts/e2b_charts==${VERSION}/g" requirements.txt + + - name: Install E2B CLI + run: npm install -g @e2b/cli + + - name: Build E2B template + id: build-template + run: | + rm -f e2b.toml + e2b template build --memory-mb 1024 -c "/root/.jupyter/start-up.sh" -d "Dockerfile" + TEMPLATE_ID=$(grep "template_id" e2b.toml | cut -d '"' -f 2) + echo "Captured Template ID: $TEMPLATE_ID" + echo "template_id=$TEMPLATE_ID" >> $GITHUB_OUTPUT + working-directory: ./template + env: + E2B_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }} + E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }} + + - name: Output template ID + run: | + echo "Template ID from step output: ${{ steps.build-template.outputs.template_id }}" diff --git a/.github/workflows/charts_tests.yml b/.github/workflows/charts_tests.yml index 985e7d99..6cbc59e1 100644 --- a/.github/workflows/charts_tests.yml +++ b/.github/workflows/charts_tests.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 diff --git a/.github/workflows/cleanup_build_template.yml b/.github/workflows/cleanup_build_template.yml new file mode 100644 index 00000000..9878474c --- /dev/null +++ b/.github/workflows/cleanup_build_template.yml @@ -0,0 +1,33 @@ +name: Cleanup Build Template + +on: + workflow_call: + secrets: + E2B_TESTS_ACCESS_TOKEN: + required: true + inputs: + E2B_DOMAIN: + required: false + type: string + E2B_TESTS_TEMPLATE: + required: true + type: string + +permissions: + contents: read + +jobs: + cleanup: + name: Cleanup Build Template + runs-on: ubuntu-latest + steps: + - name: Install E2B CLI + run: npm install -g @e2b/cli + + - name: Cleanup E2B template + id: cleanup-template + run: | + e2b template delete -y "${{ inputs.E2B_TESTS_TEMPLATE }}" + env: + E2B_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }} + E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }} diff --git a/.github/workflows/js_tests.yml b/.github/workflows/js_tests.yml index f791115a..144603f6 100644 --- a/.github/workflows/js_tests.yml +++ b/.github/workflows/js_tests.yml @@ -5,6 +5,13 @@ on: secrets: E2B_API_KEY: required: true + inputs: + E2B_DOMAIN: + required: false + type: string + E2B_TESTS_TEMPLATE: + required: false + type: string permissions: contents: read @@ -18,7 +25,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v3 @@ -49,16 +56,20 @@ jobs: run: pnpm test env: E2B_API_KEY: ${{ secrets.E2B_API_KEY }} + E2B_DOMAIN: ${{ vars.E2B_DOMAIN }} + E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }} - name: Install Bun uses: oven-sh/setup-bun@v2 with: - version: 1.1.x + bun-version: 1.2.15 - name: Run Bun tests run: pnpm test:bun env: E2B_API_KEY: ${{ secrets.E2B_API_KEY }} + E2B_DOMAIN: ${{ vars.E2B_DOMAIN }} + E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }} - name: Install Deno uses: denoland/setup-deno@v1 @@ -69,3 +80,5 @@ jobs: run: pnpm test:deno env: E2B_API_KEY: ${{ secrets.E2B_API_KEY }} + E2B_DOMAIN: ${{ vars.E2B_DOMAIN }} + E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }} \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 78b42016..29aa1e15 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -14,13 +14,36 @@ on: - main jobs: + build-template: + uses: ./.github/workflows/build_test_template.yml + secrets: + E2B_TESTS_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }} + with: + E2B_DOMAIN: ${{ vars.E2B_DOMAIN }} js-sdk: uses: ./.github/workflows/js_tests.yml + needs: build-template secrets: E2B_API_KEY: ${{ secrets.E2B_API_KEY }} + with: + E2B_DOMAIN: ${{ vars.E2B_DOMAIN }} + E2B_TESTS_TEMPLATE: ${{ needs.build-template.outputs.template_id }} python-sdk: uses: ./.github/workflows/python_tests.yml + needs: build-template secrets: E2B_API_KEY: ${{ secrets.E2B_API_KEY }} + with: + E2B_DOMAIN: ${{ vars.E2B_DOMAIN }} + E2B_TESTS_TEMPLATE: ${{ needs.build-template.outputs.template_id }} + cleanup-build-template: + uses: ./.github/workflows/cleanup_build_template.yml + needs: [build-template, js-sdk, python-sdk] + if: always() && !contains(needs.build-template.result, 'failure') && !contains(needs.build-template.result, 'cancelled') + secrets: + E2B_TESTS_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }} + with: + E2B_DOMAIN: ${{ vars.E2B_DOMAIN }} + E2B_TESTS_TEMPLATE: ${{ needs.build-template.outputs.template_id }} charts-tests: uses: ./.github/workflows/charts_tests.yml diff --git a/.github/workflows/python_tests.yml b/.github/workflows/python_tests.yml index 5bb46fea..22c85536 100644 --- a/.github/workflows/python_tests.yml +++ b/.github/workflows/python_tests.yml @@ -5,6 +5,13 @@ on: secrets: E2B_API_KEY: required: true + inputs: + E2B_DOMAIN: + required: false + type: string + E2B_TESTS_TEMPLATE: + required: false + type: string permissions: contents: read @@ -18,7 +25,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 @@ -43,3 +50,5 @@ jobs: run: poetry run pytest --verbose -x env: E2B_API_KEY: ${{ secrets.E2B_API_KEY }} + E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }} + E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 523f8531..8ee6313b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: release: ${{ steps.version.outputs.release }} steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v3 @@ -60,7 +60,7 @@ jobs: template: ${{ steps.template.outputs.release }} steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v3 @@ -117,7 +117,7 @@ jobs: version: ${{ steps.output_version.outputs.version }} steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v3 @@ -177,9 +177,7 @@ jobs: (needs.changes.outputs.template == 'true' || needs.changes.outputs.charts == 'true') steps: - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 + uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -220,9 +218,7 @@ jobs: (needs.changes.outputs.template == 'true' || needs.changes.outputs.charts == 'true') steps: - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 + uses: actions/checkout@v4 - name: Install E2B CLI run: npm install -g @e2b/cli @@ -268,9 +264,8 @@ jobs: private-key: ${{ secrets.VERSION_BUMPER_SECRET }} - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - fetch-depth: 0 token: ${{ steps.app-token.outputs.token }} diff --git a/js/tests/setup.ts b/js/tests/setup.ts index b4466365..52cd7c65 100644 --- a/js/tests/setup.ts +++ b/js/tests/setup.ts @@ -3,6 +3,8 @@ import { test as base } from 'vitest' const timeoutMs = 60_000 +const template = process.env.E2B_TESTS_TEMPLATE || 'code-interpreter-v1' + interface SandboxFixture { sandbox: Sandbox } @@ -10,7 +12,9 @@ interface SandboxFixture { export const sandboxTest = base.extend({ sandbox: [ async ({}, use) => { - const sandbox = await Sandbox.create({ timeoutMs }) + const sandbox = await Sandbox.create(template, { + timeoutMs, + }) try { await use(sandbox) } finally { diff --git a/python/tests/conftest.py b/python/tests/conftest.py index efb6c1d7..796eab91 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -11,8 +11,13 @@ @pytest.fixture() -def sandbox(debug): - sandbox = Sandbox(timeout=timeout) +def template(): + return os.getenv("E2B_TESTS_TEMPLATE", "code-interpreter-v1") + + +@pytest.fixture() +def sandbox(template, debug): + sandbox = Sandbox(template, timeout=timeout) try: yield sandbox @@ -27,14 +32,14 @@ def sandbox(debug): @pytest_asyncio.fixture -async def async_sandbox(debug): - sandbox = await AsyncSandbox.create(timeout=timeout) +async def async_sandbox(template, debug): + async_sandbox = await AsyncSandbox.create(template, timeout=timeout) try: - yield sandbox + yield async_sandbox finally: try: - await sandbox.kill() + await async_sandbox.kill() except: if not debug: warning(