Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
move gen sdk workflow into publish package workflow
0div9350971f34e7
diff --git a/.github/workflows/generate_sdk_ref.yml b/.github/workflows/generate_sdk_ref.ymldeleted file mode 100644index 914e6b37e..000000000--- a/.github/workflows/generate_sdk_ref.yml+++ /dev/null@@ -1,130 +0,0 @@-name: Generate SDK references--on:- workflow_dispatch:- push:- branches:- - improved-api-refs- # - main--concurrency: ${{ github.workflow }}-${{ github.ref }}--permissions:- contents: write--jobs:- is_new_sdk_ref:- name: Is new SDK reference?- runs-on: ubuntu-latest- outputs:- new_sdk_ref: ${{ steps.sdk-changes.outputs.new_sdk_ref }}- steps:- - name: Checkout Repo- uses: actions/checkout@v3- with:- fetch-depth: 2-- - name: Check if SDK changes- id: sdk-changes- run: |- IS_NEW_sdk_REF=$(./.github/scripts/is_new_sdk_ref.sh)- echo "new_sdk_ref=$IS_NEW_sdk_REF" >> "$GITHUB_OUTPUT"-- sdk-changes:- name: SDK changes- needs: [is_new_sdk_ref]- if: always()- runs-on: ubuntu-latest- steps:- - name: Checkout repository- uses: actions/checkout@v3- with:- fetch-depth: 0-- - name: Install pnpm- uses: pnpm/action-setup@v3- id: pnpm-install- with:- version: 9.5-- - name: Setup Node- uses: actions/setup-node@v3- with:- node-version: "20.x"- registry-url: "https://registry.npmjs.org"- cache: pnpm- cache-dependency-path: pnpm-lock.yaml-- - name: Configure pnpm- run: |- pnpm config set auto-install-peers true- pnpm config set exclude-links-from-lockfile true-- - name: Install dependencies- run: pnpm install --frozen-lockfile-- - name: Set up Python- id: setup-python- uses: actions/setup-python@v5- with:- python-version: "3.8"-- - name: Install and configure Poetry- uses: snok/install-poetry@v1- with:- version: 1.5.1- virtualenvs-create: true- virtualenvs-in-project: true- installer-parallel: true-- - name: Install dependencies- working-directory: ./packages/python-sdk- run: poetry install --no-interaction --no-root-- - name: Generate Python SDK reference- id: python-sdk-ref- working-directory: ./packages/python-sdk- run: |- source .venv/bin/activate- ./scripts/generate_sdk_ref.sh-- - name: Generate JS SDK reference- id: js-sdk-ref- working-directory: packages/js-sdk- run: ./scripts/generate_sdk_ref.sh-- - name: Generate CLI reference- id: cli-sdk-ref- working-directory: packages/cli- run: ./scripts/generate_sdk_ref.sh-- - name: Clone Code Interpreter reference- run: |- git clone --depth 1 --filter=blob:none --sparse https://github.com/e2b-dev/code-interpreter -b generate-api-reference-for-code-interpreter-sdk-e2b-1235- cd code-interpreter- git sparse-checkout set sdk-reference- cp -r sdk-reference/* ../apps/web/src/app/\(docs\)/docs/sdk-reference/- cd ..- rm -rf code-interpreter-- - name: Clone Desktop reference- run: |- git clone --depth 1 --filter=blob:none --sparse https://github.com/e2b-dev/desktop -b generate-api-reference-for-desktop-sdk-e2b-1236- cd desktop- git sparse-checkout set sdk-reference- cp -r sdk-reference/* ../apps/web/src/app/\(docs\)/docs/sdk-reference/- cd ..- rm -rf desktop-- - name: Show docs file structure- run: tree apps/web/src/app/\(docs\)/docs/sdk-reference-- - name: Commit new SDK reference versions- env:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}- run: |- git config user.name "github-actions[bot]"- git config user.email "github-actions[bot]@users.noreply.github.com"- git add apps/web/src/app/\(docs\)/docs/sdk-reference- git commit -m "[skip ci] Release new SDK reference doc versions" || exit 0- git push\ No newline at end of filediff --git a/.github/workflows/publish_packages.yml b/.github/workflows/publish_packages.ymlindex 6818abea7..f218bf77d 100644--- a/.github/workflows/publish_packages.yml+++ b/.github/workflows/publish_packages.yml@@ -76,8 +76,12 @@ jobs:PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}- name: Generate SDK reference- run: pnpm run generate-sdk-reference-+ id: sdk-ref+ run: pnpm run --recursive generate-ref++ - name: Show docs file structure+ run: tree ./sdk-reference+- name: Update lock filerun: pnpm i --no-link --no-frozen-lockfilediff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.0.4/sandbox_async/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.0.4/sandbox_async/page.mdxindex ef2f8a7ee..e0973fd00 100644--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.0.4/sandbox_async/page.mdx+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.0.4/sandbox_async/page.mdx@@ -1,561 +1,571 @@-## SandboxApi+## AsyncWatchHandle```python-class SandboxApi(SandboxApiBase)+class AsyncWatchHandle()```+Handle for watching a directory in the sandbox filesystem.-### list+Use `.stop()` to stop watching the directory.-```python-@classmethod-async def list(cls,- api_key: Optional[str] = None,- domain: Optional[str] = None,- debug: Optional[bool] = None,- request_timeout: Optional[float] = None) -> List[SandboxInfo]-```-List all running sandboxes.+### stop-**Arguments**:+```python+async def stop()+```-- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable-- `request_timeout`: Timeout for the request in **seconds**+Stop watching the directory.-**Returns**:-List of running sandboxes+## Filesystem+```python+class Filesystem()+```+Module for interacting with the filesystem in the sandbox.-## AsyncSandbox+### read```python-class AsyncSandbox(SandboxSetup, SandboxApi)+@overload+async def read(path: str,+ format: Literal["text"] = "text",+ user: Username = "user",+ request_timeout: Optional[float] = None) -> str```-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).+Read file content as a `str`.-Use the `AsyncSandbox.create()` to create a new sandbox.+**Arguments**:-**Example**:+- `path`: Path to the file+- `user`: Run the operation as this user+- `format`: Format of the file content—`text` by default+- `request_timeout`: Timeout for the request in **seconds**-```python-from e2b import AsyncSandbox+**Returns**:-sandbox = await AsyncSandbox.create()-```+File content as a `str`-### files+### read```python-@property-def files() -> Filesystem+@overload+async def read(path: str,+ format: Literal["bytes"],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> bytearray```-Module for interacting with the sandbox filesystem.+Read file content as a `bytearray`.+**Arguments**:-### commands+- `path`: Path to the file+- `user`: Run the operation as this user+- `format`: Format of the file content—`bytes`+- `request_timeout`: Timeout for the request in **seconds**-```python-@property-def commands() -> Commands-```+**Returns**:-Module for running commands in the sandbox.+File content as a `bytearray`-### pty+### read```python-@property-def pty() -> Pty+@overload+async def read(+ path: str,+ format: Literal["stream"],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> AsyncIterator[bytes]```-Module for interacting with the sandbox pseudo-terminal.+Read file content as a `AsyncIterator[bytes]`.+**Arguments**:-### sandbox\_id+- `path`: Path to the file+- `user`: Run the operation as this user+- `format`: Format of the file content—`stream`+- `request_timeout`: Timeout for the request in **seconds**-```python-@property-def sandbox_id() -> str-```+**Returns**:-Unique identifier of the sandbox.+File content as an `AsyncIterator[bytes]`-### \_\_init\_\_+### write```python-def __init__(**opts: Unpack[AsyncSandboxOpts])+async def write(path: str,+ data: Union[str, bytes, IO],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> EntryInfo```-Use `AsyncSandbox.create()` to create a new sandbox instead.-+Write content to a file on the path.-### is\_running+Writing to a file that doesn't exist creates the file.-```python-async def is_running(request_timeout: Optional[float] = None) -> bool-```+Writing to a file that already exists overwrites the file.-Check if the sandbox is running.+Writing to a file at path that doesn't exist creates the necessary directories.**Arguments**:+- `path`: Path to the file+- `data`: Data to write to the file, can be a `str`, `bytes`, or `IO`.+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds****Returns**:-`True` if the sandbox is running, `False` otherwise-Example-```python-sandbox = await AsyncSandbox.create()-await sandbox.is_running() # Returns True--await sandbox.kill()-await sandbox.is_running() # Returns False-```+Information about the written file-### create+### list```python-@classmethod-async def create(cls,- template: Optional[str] = None,- timeout: Optional[int] = None,- metadata: Optional[Dict[str, str]] = None,- envs: Optional[Dict[str, str]] = None,- api_key: Optional[str] = None,- domain: Optional[str] = None,- debug: Optional[bool] = None,- request_timeout: Optional[float] = None)+async def list(path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> List[EntryInfo]```-Create a new sandbox.--By default, the sandbox is created from the default `base` sandbox template.+List entries in a directory.**Arguments**:-- `template`: Sandbox template name or ID-- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.-- `metadata`: Custom metadata for the sandbox-- `envs`: Custom environment variables for the sandbox-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `path`: Path to the directory+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds****Returns**:-sandbox instance for the new sandbox-Use this method instead of using the constructor to create a new sandbox.+List of entries in the directory-### connect+### exists```python-@classmethod-async def connect(cls,- sandbox_id: str,- api_key: Optional[str] = None,- domain: Optional[str] = None,- debug: Optional[bool] = None)+async def exists(path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> bool```-Connect to an existing sandbox.--With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).+Check if a file or a directory exists.**Arguments**:-- `sandbox_id`: Sandbox ID-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `path`: Path to a file or a directory+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request in **seconds****Returns**:-sandbox instance for the existing sandbox-@example-```python-sandbox = await AsyncSandbox.create()-sandbox_id = sandbox.sandbox_id--same_sandbox = await AsyncSandbox.connect(sandbox_id)+`True` if the file or directory exists, `False` otherwise-### kill+### remove```python-@overload-async def kill(request_timeout: Optional[float] = None) -> bool+async def remove(path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> None```-Kill the sandbox.+Remove a file or a directory.**Arguments**:+- `path`: Path to a file or a directory+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds**-**Returns**:--`True` if the sandbox was killed, `False` if the sandbox was not found--### kill+### rename```python-@overload-@staticmethod-async def kill(sandbox_id: str,- api_key: Optional[str] = None,- domain: Optional[str] = None,- debug: Optional[bool] = None,- request_timeout: Optional[float] = None) -> bool+async def rename(old_path: str,+ new_path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> EntryInfo```-Kill the sandbox specified by sandbox ID.+Rename a file or directory.**Arguments**:-- `sandbox_id`: Sandbox ID-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `old_path`: Path to the file or directory to rename+- `new_path`: New path to the file or directory+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds****Returns**:-`True` if the sandbox was killed, `False` if the sandbox was not found+Information about the renamed file or directory-### set\_timeout+### make\_dir```python-@overload-async def set_timeout(timeout: int,- request_timeout: Optional[float] = None) -> None+async def make_dir(path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> bool```-Set the timeout of the sandbox.--After the timeout expires the sandbox will be automatically killed.-This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.--Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.+Create a new directory and all directories along the way if needed on the specified path.**Arguments**:-- `timeout`: Timeout for the sandbox in **seconds**+- `path`: Path to a new directory. For example '/dirA/dirB' when creating 'dirB'.+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds**+**Returns**:-### set\_timeout+`True` if the directory was created, `False` if the directory already exists-```python-@overload-@staticmethod-async def set_timeout(sandbox_id: str,- timeout: int,- api_key: Optional[str] = None,- domain: Optional[str] = None,- debug: Optional[bool] = None,- request_timeout: Optional[float] = None) -> None-```-Set the timeout of the specified sandbox.+### watch\_dir-After the timeout expires the sandbox will be automatically killed.-This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.+```python+async def watch_dir(path: str,+ on_event: OutputHandler[FilesystemEvent],+ on_exit: Optional[OutputHandler[Exception]] = None,+ user: Username = "user",+ request_timeout: Optional[float] = None,+ timeout: Optional[float] = 60) -> AsyncWatchHandle+```-Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.+Watch directory for filesystem events.**Arguments**:-- `sandbox_id`: Sandbox ID-- `timeout`: Timeout for the sandbox in **seconds**+- `path`: Path to a directory to watch+- `on_event`: Callback to call on each event in the directory+- `on_exit`: Callback to call when the watching ends+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds**+- `timeout`: Timeout for the watch operation in **seconds**. Using `0` will not limit the watch time+**Returns**:+`AsyncWatchHandle` object for stopping watching directory-## AsyncWatchHandle-```python-class AsyncWatchHandle()-```-Handle for watching a directory in the sandbox filesystem.-Use `.stop()` to stop watching the directory.+## SandboxApi-### stop+```python+class SandboxApi(SandboxApiBase)+```+++### list```python-async def stop()+@classmethod+async def list(cls,+ api_key: Optional[str] = None,+ domain: Optional[str] = None,+ debug: Optional[bool] = None,+ request_timeout: Optional[float] = None) -> List[SandboxInfo]```-Stop watching the directory.+List all running sandboxes.+**Arguments**:+- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `request_timeout`: Timeout for the request in **seconds**+**Returns**:-## Filesystem+List of running sandboxes+++++## Commands```python-class Filesystem()+class Commands()```-Module for interacting with the filesystem in the sandbox.+Module for executing commands in the sandbox.-### read+### list```python-@overload-async def read(path: str,- format: Literal["text"] = "text",- user: Username = "user",- request_timeout: Optional[float] = None) -> str+async def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]```-Read file content as a `str`.+Lists all running commands and PTY sessions.**Arguments**:-- `path`: Path to the file-- `user`: Run the operation as this user-- `format`: Format of the file content—`text` by default- `request_timeout`: Timeout for the request in **seconds****Returns**:-File content as a `str`+List of running commands and PTY sessions-### read+### kill```python-@overload-async def read(path: str,- format: Literal["bytes"],- user: Username = "user",- request_timeout: Optional[float] = None) -> bytearray+async def kill(pid: int, request_timeout: Optional[float] = None) -> bool```-Read file content as a `bytearray`.+Kill a running command specified by its process ID.++It uses `SIGKILL` signal to kill the command.**Arguments**:-- `path`: Path to the file-- `user`: Run the operation as this user-- `format`: Format of the file content—`bytes`+- `pid`: Process ID of the command. You can get the list of processes using `sandbox.commands.list()`- `request_timeout`: Timeout for the request in **seconds****Returns**:-File content as a `bytearray`+`True` if the command was killed, `False` if the command was not found-### read+### send\_stdin```python-@overload-async def read(- path: str,- format: Literal["stream"],- user: Username = "user",- request_timeout: Optional[float] = None) -> AsyncIterator[bytes]+async def send_stdin(pid: int,+ data: str,+ request_timeout: Optional[float] = None) -> None```-Read file content as a `AsyncIterator[bytes]`.--**Arguments**:--- `path`: Path to the file-- `user`: Run the operation as this user-- `format`: Format of the file content—`stream`-- `request_timeout`: Timeout for the request in **seconds**+Send data to command stdin.-**Returns**:+:param pid Process ID of the command. You can get the list of processes using `sandbox.commands.list()`.+:param data: Data to send to the command+:param request_timeout: Timeout for the request in **seconds**-File content as an `AsyncIterator[bytes]`-### write+### run```python-async def write(path: str,- data: Union[str, bytes, IO],- user: Username = "user",- request_timeout: Optional[float] = None) -> EntryInfo+@overload+async def run(cmd: str,+ background: Union[Literal[False], None] = None,+ envs: Optional[Dict[str, str]] = None,+ user: Username = "user",+ cwd: Optional[str] = None,+ on_stdout: Optional[OutputHandler[Stdout]] = None,+ on_stderr: Optional[OutputHandler[Stderr]] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> CommandResult```-Write content to a file on the path.--Writing to a file that doesn't exist creates the file.--Writing to a file that already exists overwrites the file.--Writing to a file at path that doesn't exist creates the necessary directories.+Start a new command and wait until it finishes executing.**Arguments**:-- `path`: Path to the file-- `data`: Data to write to the file, can be a `str`, `bytes`, or `IO`.-- `user`: Run the operation as this user+- `cmd`: Command to execute+- `background`: **`False` if the command should be executed in the foreground**, `True` if the command should be executed in the background+- `envs`: Environment variables used for the command+- `user`: User to run the command as+- `cwd`: Working directory to run the command+- `on_stdout`: Callback for command stdout output+- `on_stderr`: Callback for command stderr output+- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time- `request_timeout`: Timeout for the request in **seconds****Returns**:-Information about the written file+`CommandResult` result of the command execution-### list+### run```python-async def list(path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> List[EntryInfo]+@overload+async def run(cmd: str,+ background: Literal[True],+ envs: Optional[Dict[str, str]] = None,+ user: Username = "user",+ cwd: Optional[str] = None,+ on_stdout: Optional[OutputHandler[Stdout]] = None,+ on_stderr: Optional[OutputHandler[Stderr]] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> AsyncCommandHandle```-List entries in a directory.+Start a new command and return a handle to interact with it.**Arguments**:-- `path`: Path to the directory-- `user`: Run the operation as this user+- `cmd`: Command to execute+- `background`: `False` if the command should be executed in the foreground, **`True` if the command should be executed in the background**+- `envs`: Environment variables used for the command+- `user`: User to run the command as+- `cwd`: Working directory to run the command+- `on_stdout`: Callback for command stdout output+- `on_stderr`: Callback for command stderr output+- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time- `request_timeout`: Timeout for the request in **seconds****Returns**:-List of entries in the directory+`AsyncCommandHandle` handle to interact with the running command-### exists+### connect```python-async def exists(path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> bool+async def connect(+ pid: int,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None,+ on_stdout: Optional[OutputHandler[Stdout]] = None,+ on_stderr: Optional[OutputHandler[Stderr]] = None+) -> AsyncCommandHandle```-Check if a file or a directory exists.+Connects to a running command.++You can use `AsyncCommandHandle.wait()` to wait for the command to finish and get execution results.**Arguments**:-- `path`: Path to a file or a directory-- `user`: Run the operation as this user-- `request_timeout`: Timeout for the request in **seconds**+- `pid`: Process ID of the command to connect to. You can get the list of processes using `sandbox.commands.list()`+- `request_timeout`: Request timeout in **seconds**+- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time+- `on_stdout`: Callback for command stdout output+- `on_stderr`: Callback for command stderr output**Returns**:-`True` if the file or directory exists, `False` otherwise+`AsyncCommandHandle` handle to interact with the running command-### remove+++## AsyncCommandHandle```python-async def remove(path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> None+class AsyncCommandHandle()```-Remove a file or a directory.--**Arguments**:+Command execution handle.-- `path`: Path to a file or a directory-- `user`: Run the operation as this user-- `request_timeout`: Timeout for the request in **seconds**+It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.-### rename+### pid```python-async def rename(old_path: str,- new_path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> EntryInfo+@property+def pid()```-Rename a file or directory.+Command process ID.-**Arguments**:-- `old_path`: Path to the file or directory to rename-- `new_path`: New path to the file or directory-- `user`: Run the operation as this user-- `request_timeout`: Timeout for the request in **seconds**+### stdout-**Returns**:+```python+@property+def stdout()+```-Information about the renamed file or directory+Command stdout output.-### make\_dir+### stderr```python-async def make_dir(path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> bool+@property+def stderr()```-Create a new directory and all directories along the way if needed on the specified path.+Command stderr output.-**Arguments**:-- `path`: Path to a new directory. For example '/dirA/dirB' when creating 'dirB'.-- `user`: Run the operation as this user-- `request_timeout`: Timeout for the request in **seconds**+### error-**Returns**:+```python+@property+def error()+```-`True` if the directory was created, `False` if the directory already exists+Command execution error message.-### watch\_dir+### exit\_code```python-async def watch_dir(path: str,- on_event: OutputHandler[FilesystemEvent],- on_exit: Optional[OutputHandler[Exception]] = None,- user: Username = "user",- request_timeout: Optional[float] = None,- timeout: Optional[float] = 60) -> AsyncWatchHandle+@property+def exit_code()```-Watch directory for filesystem events.+Command execution exit code.-**Arguments**:+`0` if the command finished successfully.-- `path`: Path to a directory to watch-- `on_event`: Callback to call on each event in the directory-- `on_exit`: Callback to call when the watching ends-- `user`: Run the operation as this user-- `request_timeout`: Timeout for the request in **seconds**-- `timeout`: Timeout for the watch operation in **seconds**. Using `0` will not limit the watch time+It is `None` if the command is still running.+++### disconnect++```python+async def disconnect() -> None+```++Disconnects from the command.++The command is not killed, but SDK stops receiving events from the command.+You can reconnect to the command using `sandbox.commands.connect` method.+++### wait++```python+async def wait() -> CommandResult+```++Wait for the command to finish and return the result.++If the command exits with a non-zero exit code, it throws a `CommandExitException`.**Returns**:-`AsyncWatchHandle` object for stopping watching directory+`CommandResult` result of command execution+++### kill++```python+async def kill() -> bool+```++Kills the command.++It uses `SIGKILL` signal to kill the command++**Returns**:++`True` if the command was killed successfully, `False` if the command was not found@@ -655,270 +665,260 @@ Call this when the terminal window is resized and the number of columns and rows-## Commands+## AsyncSandbox```python-class Commands()+class AsyncSandbox(SandboxSetup, SandboxApi)```-Module for executing commands in the sandbox.---### list+E2B cloud sandbox is a secure and isolated cloud environment.-```python-async def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]-```+The sandbox allows you to:+- Access Linux OS+- Create, list, and delete files and directories+- Run commands+- Run isolated code+- Access the internet-Lists all running commands and PTY sessions.+Check docs [here](https://e2b.dev/docs).-**Arguments**:+Use the `AsyncSandbox.create()` to create a new sandbox.-- `request_timeout`: Timeout for the request in **seconds**+**Example**:-**Returns**:+```python+from e2b import AsyncSandbox-List of running commands and PTY sessions+sandbox = await AsyncSandbox.create()+```-### kill+### files```python-async def kill(pid: int, request_timeout: Optional[float] = None) -> bool+@property+def files() -> Filesystem```-Kill a running command specified by its process ID.--It uses `SIGKILL` signal to kill the command.+Module for interacting with the sandbox filesystem.-**Arguments**:-- `pid`: Process ID of the command. You can get the list of processes using `sandbox.commands.list()`-- `request_timeout`: Timeout for the request in **seconds**+### commands-**Returns**:+```python+@property+def commands() -> Commands+```-`True` if the command was killed, `False` if the command was not found+Module for running commands in the sandbox.-### send\_stdin+### pty```python-async def send_stdin(pid: int,- data: str,- request_timeout: Optional[float] = None) -> None+@property+def pty() -> Pty```-Send data to command stdin.--:param pid Process ID of the command. You can get the list of processes using `sandbox.commands.list()`.-:param data: Data to send to the command-:param request_timeout: Timeout for the request in **seconds**-+Module for interacting with the sandbox pseudo-terminal.-### run+### sandbox\_id```python-@overload-async def run(cmd: str,- background: Union[Literal[False], None] = None,- envs: Optional[Dict[str, str]] = None,- user: Username = "user",- cwd: Optional[str] = None,- on_stdout: Optional[OutputHandler[Stdout]] = None,- on_stderr: Optional[OutputHandler[Stderr]] = None,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None) -> CommandResult+@property+def sandbox_id() -> str```-Start a new command and wait until it finishes executing.+Unique identifier of the sandbox.-**Arguments**:-- `cmd`: Command to execute-- `background`: **`False` if the command should be executed in the foreground**, `True` if the command should be executed in the background-- `envs`: Environment variables used for the command-- `user`: User to run the command as-- `cwd`: Working directory to run the command-- `on_stdout`: Callback for command stdout output-- `on_stderr`: Callback for command stderr output-- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time-- `request_timeout`: Timeout for the request in **seconds**+### \_\_init\_\_-**Returns**:+```python+def __init__(**opts: Unpack[AsyncSandboxOpts])+```-`CommandResult` result of the command execution+Use `AsyncSandbox.create()` to create a new sandbox instead.-### run+### is\_running```python-@overload-async def run(cmd: str,- background: Literal[True],- envs: Optional[Dict[str, str]] = None,- user: Username = "user",- cwd: Optional[str] = None,- on_stdout: Optional[OutputHandler[Stdout]] = None,- on_stderr: Optional[OutputHandler[Stderr]] = None,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None) -> AsyncCommandHandle+async def is_running(request_timeout: Optional[float] = None) -> bool```-Start a new command and return a handle to interact with it.+Check if the sandbox is running.**Arguments**:-- `cmd`: Command to execute-- `background`: `False` if the command should be executed in the foreground, **`True` if the command should be executed in the background**-- `envs`: Environment variables used for the command-- `user`: User to run the command as-- `cwd`: Working directory to run the command-- `on_stdout`: Callback for command stdout output-- `on_stderr`: Callback for command stderr output-- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time- `request_timeout`: Timeout for the request in **seconds****Returns**:-`AsyncCommandHandle` handle to interact with the running command+`True` if the sandbox is running, `False` otherwise+Example+```python+sandbox = await AsyncSandbox.create()+await sandbox.is_running() # Returns True++await sandbox.kill()+await sandbox.is_running() # Returns False+```-### connect+### create```python-async def connect(- pid: int,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None,- on_stdout: Optional[OutputHandler[Stdout]] = None,- on_stderr: Optional[OutputHandler[Stderr]] = None-) -> AsyncCommandHandle+@classmethod+async def create(cls,+ template: Optional[str] = None,+ timeout: Optional[int] = None,+ metadata: Optional[Dict[str, str]] = None,+ envs: Optional[Dict[str, str]] = None,+ api_key: Optional[str] = None,+ domain: Optional[str] = None,+ debug: Optional[bool] = None,+ request_timeout: Optional[float] = None)```-Connects to a running command.+Create a new sandbox.-You can use `AsyncCommandHandle.wait()` to wait for the command to finish and get execution results.+By default, the sandbox is created from the default `base` sandbox template.**Arguments**:-- `pid`: Process ID of the command to connect to. You can get the list of processes using `sandbox.commands.list()`-- `request_timeout`: Request timeout in **seconds**-- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time-- `on_stdout`: Callback for command stdout output-- `on_stderr`: Callback for command stderr output+- `template`: Sandbox template name or ID+- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.+- `metadata`: Custom metadata for the sandbox+- `envs`: Custom environment variables for the sandbox+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `request_timeout`: Timeout for the request in **seconds****Returns**:-`AsyncCommandHandle` handle to interact with the running command--+sandbox instance for the new sandbox+Use this method instead of using the constructor to create a new sandbox.-## AsyncCommandHandle+### connect```python-class AsyncCommandHandle()+@classmethod+async def connect(cls,+ sandbox_id: str,+ api_key: Optional[str] = None,+ domain: Optional[str] = None,+ debug: Optional[bool] = None)```-Command execution handle.--It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.---### pid+Connect to an existing sandbox.-```python-@property-def pid()-```+With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).-Command process ID.+**Arguments**:+- `sandbox_id`: Sandbox ID+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable-### stdout+**Returns**:+sandbox instance for the existing sandbox+@example```python-@property-def stdout()-```+sandbox = await AsyncSandbox.create()+sandbox_id = sandbox.sandbox_id-Command stdout output.+same_sandbox = await AsyncSandbox.connect(sandbox_id)-### stderr+### kill```python-@property-def stderr()+@overload+async def kill(request_timeout: Optional[float] = None) -> bool```-Command stderr output.+Kill the sandbox.+**Arguments**:-### error+- `request_timeout`: Timeout for the request in **seconds**-```python-@property-def error()-```+**Returns**:-Command execution error message.+`True` if the sandbox was killed, `False` if the sandbox was not found-### exit\_code+### kill```python-@property-def exit_code()+@overload+@staticmethod+async def kill(sandbox_id: str,+ api_key: Optional[str] = None,+ domain: Optional[str] = None,+ debug: Optional[bool] = None,+ request_timeout: Optional[float] = None) -> bool```-Command execution exit code.--`0` if the command finished successfully.--It is `None` if the command is still running.-+Kill the sandbox specified by sandbox ID.-### disconnect+**Arguments**:-```python-async def disconnect() -> None-```+- `sandbox_id`: Sandbox ID+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `request_timeout`: Timeout for the request in **seconds**-Disconnects from the command.+**Returns**:-The command is not killed, but SDK stops receiving events from the command.-You can reconnect to the command using `sandbox.commands.connect` method.+`True` if the sandbox was killed, `False` if the sandbox was not found-### wait+### set\_timeout```python-async def wait() -> CommandResult+@overload+async def set_timeout(timeout: int,+ request_timeout: Optional[float] = None) -> None```-Wait for the command to finish and return the result.+Set the timeout of the sandbox.-If the command exits with a non-zero exit code, it throws a `CommandExitException`.+After the timeout expires the sandbox will be automatically killed.+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.-**Returns**:+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.-`CommandResult` result of command execution+**Arguments**:+- `timeout`: Timeout for the sandbox in **seconds**+- `request_timeout`: Timeout for the request in **seconds**-### kill++### set\_timeout```python-async def kill() -> bool+@overload+@staticmethod+async def set_timeout(sandbox_id: str,+ timeout: int,+ api_key: Optional[str] = None,+ domain: Optional[str] = None,+ debug: Optional[bool] = None,+ request_timeout: Optional[float] = None) -> None```-Kills the command.+Set the timeout of the specified sandbox.-It uses `SIGKILL` signal to kill the command+After the timeout expires the sandbox will be automatically killed.+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.-**Returns**:+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.-`True` if the command was killed successfully, `False` if the command was not found+**Arguments**:++- `sandbox_id`: Sandbox ID+- `timeout`: Timeout for the sandbox in **seconds**+- `request_timeout`: Timeout for the request in **seconds**diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.0.4/sandbox_sync/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.0.4/sandbox_sync/page.mdxindex 35d3b0c5e..85edf462c 100644--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.0.4/sandbox_sync/page.mdx+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.0.4/sandbox_sync/page.mdx@@ -1,574 +1,544 @@-## SandboxApi+## WatchHandle```python-class SandboxApi(SandboxApiBase)+class WatchHandle()```+Handle for watching filesystem events.+It is used to get the latest events that have occurred in the watched directory.-### list+Use `.stop()` to stop watching the directory.+++### stop```python-@classmethod-def list(cls,- api_key: Optional[str] = None,- domain: Optional[str] = None,- debug: Optional[bool] = None,- request_timeout: Optional[float] = None) -> List[SandboxInfo]+def stop()```-List all running sandboxes.+Stop watching the directory.+After you stop the watcher you won't be able to get the events anymore.-**Arguments**:-- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable-- `request_timeout`: Timeout for the request in **seconds**+### get\_new\_events++```python+def get_new_events() -> List[FilesystemEvent]+```++Get the latest events that have occurred in the watched directory since the last call, or from the beginning of the watching, up until now.**Returns**:-List of sandbox info+List of filesystem events-## Sandbox+## Filesystem```python-class Sandbox(SandboxSetup, SandboxApi)+class Filesystem()```-E2B cloud sandbox is a secure and isolated cloud environment.+Module for interacting with the filesystem in the sandbox.-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).+### read-Use the `Sandbox()` to create a new sandbox.+```python+@overload+def read(path: str,+ format: Literal["text"] = "text",+ user: Username = "user",+ request_timeout: Optional[float] = None) -> str+```-**Example**:+Read file content as a `str`.-```python-from e2b import Sandbox+**Arguments**:-sandbox = Sandbox()-```+- `path`: Path to the file+- `user`: Run the operation as this user+- `format`: Format of the file content—`text` by default+- `request_timeout`: Timeout for the request in **seconds**+**Returns**:-### files+File content as a `str`+++### read```python-@property-def files() -> Filesystem+@overload+def read(path: str,+ format: Literal["bytes"],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> bytearray```-Module for interacting with the sandbox filesystem.+Read file content as a `bytearray`.+**Arguments**:-### commands+- `path`: Path to the file+- `user`: Run the operation as this user+- `format`: Format of the file content—`bytes`+- `request_timeout`: Timeout for the request in **seconds**-```python-@property-def commands() -> Commands-```+**Returns**:-Module for running commands in the sandbox.+File content as a `bytearray`-### pty+### read```python-@property-def pty() -> Pty+@overload+def read(path: str,+ format: Literal["stream"],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> Iterator[bytes]```-Module for interacting with the sandbox pseudo-terminal.+Read file content as a `Iterator[bytes]`.+**Arguments**:-### sandbox\_id+- `path`: Path to the file+- `user`: Run the operation as this user+- `format`: Format of the file content—`stream`+- `request_timeout`: Timeout for the request in **seconds**-```python-@property-def sandbox_id() -> str-```+**Returns**:-Unique identifier of the sandbox+File content as an `Iterator[bytes]`-### \_\_init\_\_+### write```python-def __init__(template: Optional[str] = None,- timeout: Optional[int] = None,- metadata: Optional[Dict[str, str]] = None,- envs: Optional[Dict[str, str]] = None,- api_key: Optional[str] = None,- domain: Optional[str] = None,- debug: Optional[bool] = None,- sandbox_id: Optional[str] = None,- request_timeout: Optional[float] = None)+def write(path: str,+ data: Union[str, bytes, IO],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> EntryInfo```-Create a new sandbox.+Write content to a file on the path.-By default, the sandbox is created from the default `base` sandbox template.+Writing to a file that doesn't exist creates the file.++Writing to a file that already exists overwrites the file.++Writing to a file at path that doesn't exist creates the necessary directories.**Arguments**:-- `template`: Sandbox template name or ID-- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users-- `metadata`: Custom metadata for the sandbox-- `envs`: Custom environment variables for the sandbox-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `path`: Path to the file+- `data`: Data to write to the file, can be a `str`, `bytes`, or `IO`.+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds****Returns**:-sandbox instance for the new sandbox+Information about the written file-### is\_running+### list```python-def is_running(request_timeout: Optional[float] = None) -> bool+def list(path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> List[EntryInfo]```-Check if the sandbox is running.+List entries in a directory.**Arguments**:+- `path`: Path to the directory+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds****Returns**:-`True` if the sandbox is running, `False` otherwise-Example-```python-sandbox = Sandbox()-sandbox.is_running() # Returns True--sandbox.kill()-sandbox.is_running() # Returns False-```+List of entries in the directory-### connect+### exists```python-@classmethod-def connect(cls,- sandbox_id: str,- api_key: Optional[str] = None,- domain: Optional[str] = None,- debug: Optional[bool] = None)+def exists(path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> bool```-Connects to an existing Sandbox.--With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).+Check if a file or a directory exists.**Arguments**:-- `sandbox_id`: Sandbox ID-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `path`: Path to a file or a directory+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request in **seconds****Returns**:-sandbox instance for the existing sandbox-@example-```python-sandbox = Sandbox()-sandbox_id = sandbox.sandbox_id--same_sandbox = Sandbox.connect(sandbox_id)+`True` if the file or directory exists, `False` otherwise-### kill+### remove```python-@overload-def kill(request_timeout: Optional[float] = None) -> bool+def remove(path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> None```-Kill the sandbox.+Remove a file or a directory.**Arguments**:+- `path`: Path to a file or a directory+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds**-**Returns**:--`True` if the sandbox was killed, `False` if the sandbox was not found--### kill+### rename```python-@overload-@staticmethod-def kill(sandbox_id: str,- api_key: Optional[str] = None,- domain: Optional[str] = None,- debug: Optional[bool] = None,- request_timeout: Optional[float] = None) -> bool+def rename(old_path: str,+ new_path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> EntryInfo```-Kill the sandbox specified by sandbox ID.+Rename a file or directory.**Arguments**:-- `sandbox_id`: Sandbox ID-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `old_path`: Path to the file or directory to rename+- `new_path`: New path to the file or directory+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds****Returns**:-`True` if the sandbox was killed, `False` if the sandbox was not found+Information about the renamed file or directory-### kill+### make\_dir```python-@class_method_variant("_cls_kill")-def kill(request_timeout: Optional[float] = None) -> bool+def make_dir(path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> bool```-Kill the sandbox.+Create a new directory and all directories along the way if needed on the specified path.**Arguments**:-- `request_timeout`: Timeout for the request+- `path`: Path to a new directory. For example '/dirA/dirB' when creating 'dirB'.+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request in **seconds****Returns**:-`True` if the sandbox was killed, `False` if the sandbox was not found+`True` if the directory was created, `False` if the directory already exists-### set\_timeout+### watch\_dir```python-@overload-def set_timeout(timeout: int, request_timeout: Optional[float] = None) -> None-```--Set the timeout of the sandbox.--After the timeout expires the sandbox will be automatically killed.-This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.+def watch_dir(path: str,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> WatchHandle+```-Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.+Watch directory for filesystem events.**Arguments**:-- `timeout`: Timeout for the sandbox in **seconds**+- `path`: Path to a directory to watch+- `user`: Run the operation as this user- `request_timeout`: Timeout for the request in **seconds**+**Returns**:-### set\_timeout--```python-@overload-@staticmethod-def set_timeout(sandbox_id: str,- timeout: int,- api_key: Optional[str] = None,- domain: Optional[str] = None,- debug: Optional[bool] = None,- request_timeout: Optional[float] = None) -> None-```--Set the timeout of the sandbox specified by sandbox ID.--After the timeout expires the sandbox will be automatically killed.-This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.--Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.--**Arguments**:--- `sandbox_id`: Sandbox ID-- `timeout`: Timeout for the sandbox in **seconds**-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable-- `request_timeout`: Timeout for the request in **seconds**+`WatchHandle` object for stopping watching directory-## WatchHandle+## SandboxApi```python-class WatchHandle()+class SandboxApi(SandboxApiBase)```-Handle for watching filesystem events.-It is used to get the latest events that have occurred in the watched directory.--Use `.stop()` to stop watching the directory.--### stop+### list```python-def stop()+@classmethod+def list(cls,+ api_key: Optional[str] = None,+ domain: Optional[str] = None,+ debug: Optional[bool] = None,+ request_timeout: Optional[float] = None) -> List[SandboxInfo]```-Stop watching the directory.-After you stop the watcher you won't be able to get the events anymore.---### get\_new\_events+List all running sandboxes.-```python-def get_new_events() -> List[FilesystemEvent]-```+**Arguments**:-Get the latest events that have occurred in the watched directory since the last call, or from the beginning of the watching, up until now.+- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `request_timeout`: Timeout for the request in **seconds****Returns**:-List of filesystem events+List of sandbox info-## Filesystem+## Commands```python-class Filesystem()+class Commands()```-Module for interacting with the filesystem in the sandbox.+Module for executing commands in the sandbox.-### read+### list```python-@overload-def read(path: str,- format: Literal["text"] = "text",- user: Username = "user",- request_timeout: Optional[float] = None) -> str+def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]```-Read file content as a `str`.+Lists all running commands and PTY sessions.**Arguments**:-- `path`: Path to the file-- `user`: Run the operation as this user-- `format`: Format of the file content—`text` by default- `request_timeout`: Timeout for the request in **seconds****Returns**:-File content as a `str`+List of running commands and PTY sessions-### read+### kill```python-@overload-def read(path: str,- format: Literal["bytes"],- user: Username = "user",- request_timeout: Optional[float] = None) -> bytearray+def kill(pid: int, request_timeout: Optional[float] = None) -> bool```-Read file content as a `bytearray`.+Kills a running command specified by its process ID.++It uses `SIGKILL` signal to kill the command.**Arguments**:-- `path`: Path to the file-- `user`: Run the operation as this user-- `format`: Format of the file content—`bytes`+- `pid`: Process ID of the command. You can get the list of processes using `sandbox.commands.list()`- `request_timeout`: Timeout for the request in **seconds****Returns**:-File content as a `bytearray`+`True` if the command was killed, `False` if the command was not found-### read+### send\_stdin```python-@overload-def read(path: str,- format: Literal["stream"],- user: Username = "user",- request_timeout: Optional[float] = None) -> Iterator[bytes]+def send_stdin(pid: int, data: str, request_timeout: Optional[float] = None)```-Read file content as a `Iterator[bytes]`.--**Arguments**:--- `path`: Path to the file-- `user`: Run the operation as this user-- `format`: Format of the file content—`stream`-- `request_timeout`: Timeout for the request in **seconds**+Send data to command stdin.-**Returns**:+:param pid Process ID of the command. You can get the list of processes using `sandbox.commands.list()`.+:param data: Data to send to the command+:param request_timeout: Timeout for the request in **seconds**-File content as an `Iterator[bytes]`-### write+### run```python-def write(path: str,- data: Union[str, bytes, IO],- user: Username = "user",- request_timeout: Optional[float] = None) -> EntryInfo+@overload+def run(cmd: str,+ background: Union[Literal[False], None] = None,+ envs: Optional[Dict[str, str]] = None,+ user: Username = "user",+ cwd: Optional[str] = None,+ on_stdout: Optional[Callable[[str], None]] = None,+ on_stderr: Optional[Callable[[str], None]] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> CommandResult```-Write content to a file on the path.--Writing to a file that doesn't exist creates the file.--Writing to a file that already exists overwrites the file.--Writing to a file at path that doesn't exist creates the necessary directories.+Start a new command and wait until it finishes executing.**Arguments**:-- `path`: Path to the file-- `data`: Data to write to the file, can be a `str`, `bytes`, or `IO`.-- `user`: Run the operation as this user+- `cmd`: Command to execute+- `background`: **`False` if the command should be executed in the foreground**, `True` if the command should be executed in the background+- `envs`: Environment variables used for the command+- `user`: User to run the command as+- `cwd`: Working directory to run the command+- `on_stdout`: Callback for command stdout output+- `on_stderr`: Callback for command stderr output+- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time- `request_timeout`: Timeout for the request in **seconds****Returns**:-Information about the written file+`CommandResult` result of the command execution-### list+### run```python-def list(path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> List[EntryInfo]+@overload+def run(cmd: str,+ background: Literal[True],+ envs: Optional[Dict[str, str]] = None,+ user: Username = "user",+ cwd: Optional[str] = None,+ on_stdout: None = None,+ on_stderr: None = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> CommandHandle```-List entries in a directory.+Start a new command and return a handle to interact with it.**Arguments**:-- `path`: Path to the directory-- `user`: Run the operation as this user+- `cmd`: Command to execute+- `background`: `False` if the command should be executed in the foreground, **`True` if the command should be executed in the background**+- `envs`: Environment variables used for the command+- `user`: User to run the command as+- `cwd`: Working directory to run the command+- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time- `request_timeout`: Timeout for the request in **seconds****Returns**:-List of entries in the directory+`CommandHandle` handle to interact with the running command-### exists+### connect```python-def exists(path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> bool+def connect(pid: int,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None)```-Check if a file or a directory exists.+Connects to a running command.++You can use `CommandHandle.wait()` to wait for the command to finish and get execution results.**Arguments**:-- `path`: Path to a file or a directory-- `user`: Run the operation as this user+- `pid`: Process ID of the command to connect to. You can get the list of processes using `sandbox.commands.list()`+- `timeout`: Timeout for the connection in **seconds**. Using `0` will not limit the connection time- `request_timeout`: Timeout for the request in **seconds****Returns**:-`True` if the file or directory exists, `False` otherwise+`CommandHandle` handle to interact with the running command+-### remove++## CommandHandle```python-def remove(path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> None+class CommandHandle()```-Remove a file or a directory.--**Arguments**:+Command execution handle.-- `path`: Path to a file or a directory-- `user`: Run the operation as this user-- `request_timeout`: Timeout for the request in **seconds**+It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.-### rename+### pid```python-def rename(old_path: str,- new_path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> EntryInfo+@property+def pid()```-Rename a file or directory.+Command process ID.-**Arguments**:-- `old_path`: Path to the file or directory to rename-- `new_path`: New path to the file or directory-- `user`: Run the operation as this user-- `request_timeout`: Timeout for the request in **seconds**+### \_\_iter\_\_-**Returns**:+```python+def __iter__()+```-Information about the renamed file or directory+Iterate over the command output.+**Returns**:-### make\_dir+Generator of command outputs+++### disconnect```python-def make_dir(path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> bool+def disconnect() -> None```-Create a new directory and all directories along the way if needed on the specified path.+Disconnect from the command.++The command is not killed, but SDK stops receiving events from the command.+You can reconnect to the command using `sandbox.commands.connect` method.+++### wait++```python+def wait(on_pty: Optional[Callable[[PtyOutput], None]] = None,+ on_stdout: Optional[Callable[[str], None]] = None,+ on_stderr: Optional[Callable[[str], None]] = None) -> CommandResult+```++Wait for the command to finish and returns the result.++If the command exits with a non-zero exit code, it throws a `CommandExitException`.**Arguments**:-- `path`: Path to a new directory. For example '/dirA/dirB' when creating 'dirB'.-- `user`: Run the operation as this user-- `request_timeout`: Timeout for the request in **seconds**+- `on_pty`: Callback for pty output+- `on_stdout`: Callback for stdout output+- `on_stderr`: Callback for stderr output**Returns**:-`True` if the directory was created, `False` if the directory already exists+`CommandResult` result of command execution-### watch\_dir+### kill```python-def watch_dir(path: str,- user: Username = "user",- request_timeout: Optional[float] = None) -> WatchHandle+def kill() -> bool```-Watch directory for filesystem events.--**Arguments**:+Kills the command.-- `path`: Path to a directory to watch-- `user`: Run the operation as this user-- `request_timeout`: Timeout for the request in **seconds**+It uses `SIGKILL` signal to kill the command.**Returns**:-`WatchHandle` object for stopping watching directory+Whether the command was killed successfully@@ -665,237 +635,267 @@ Call this when the terminal window is resized and the number of columns and rows-## Commands+## Sandbox```python-class Commands()+class Sandbox(SandboxSetup, SandboxApi)```-Module for executing commands in the 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](https://e2b.dev/docs).-### list+Use the `Sandbox()` to create a new sandbox.++**Example**:```python-def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]-```+from e2b import Sandbox-Lists all running commands and PTY sessions.+sandbox = Sandbox()+```-**Arguments**:-- `request_timeout`: Timeout for the request in **seconds**+### files-**Returns**:+```python+@property+def files() -> Filesystem+```-List of running commands and PTY sessions+Module for interacting with the sandbox filesystem.-### kill+### commands```python-def kill(pid: int, request_timeout: Optional[float] = None) -> bool+@property+def commands() -> Commands```-Kills a running command specified by its process ID.--It uses `SIGKILL` signal to kill the command.+Module for running commands in the sandbox.-**Arguments**:-- `pid`: Process ID of the command. You can get the list of processes using `sandbox.commands.list()`-- `request_timeout`: Timeout for the request in **seconds**+### pty-**Returns**:+```python+@property+def pty() -> Pty+```-`True` if the command was killed, `False` if the command was not found+Module for interacting with the sandbox pseudo-terminal.-### send\_stdin+### sandbox\_id```python-def send_stdin(pid: int, data: str, request_timeout: Optional[float] = None)+@property+def sandbox_id() -> str```-Send data to command stdin.--:param pid Process ID of the command. You can get the list of processes using `sandbox.commands.list()`.-:param data: Data to send to the command-:param request_timeout: Timeout for the request in **seconds**-+Unique identifier of the sandbox-### run+### \_\_init\_\_```python-@overload-def run(cmd: str,- background: Union[Literal[False], None] = None,- envs: Optional[Dict[str, str]] = None,- user: Username = "user",- cwd: Optional[str] = None,- on_stdout: Optional[Callable[[str], None]] = None,- on_stderr: Optional[Callable[[str], None]] = None,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None) -> CommandResult+def __init__(template: Optional[str] = None,+ timeout: Optional[int] = None,+ metadata: Optional[Dict[str, str]] = None,+ envs: Optional[Dict[str, str]] = None,+ api_key: Optional[str] = None,+ domain: Optional[str] = None,+ debug: Optional[bool] = None,+ sandbox_id: Optional[str] = None,+ request_timeout: Optional[float] = None)```-Start a new command and wait until it finishes executing.+Create a new sandbox.++By default, the sandbox is created from the default `base` sandbox template.**Arguments**:-- `cmd`: Command to execute-- `background`: **`False` if the command should be executed in the foreground**, `True` if the command should be executed in the background-- `envs`: Environment variables used for the command-- `user`: User to run the command as-- `cwd`: Working directory to run the command-- `on_stdout`: Callback for command stdout output-- `on_stderr`: Callback for command stderr output-- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time+- `template`: Sandbox template name or ID+- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users+- `metadata`: Custom metadata for the sandbox+- `envs`: Custom environment variables for the sandbox+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable- `request_timeout`: Timeout for the request in **seconds****Returns**:-`CommandResult` result of the command execution+sandbox instance for the new sandbox-### run+### is\_running```python-@overload-def run(cmd: str,- background: Literal[True],- envs: Optional[Dict[str, str]] = None,- user: Username = "user",- cwd: Optional[str] = None,- on_stdout: None = None,- on_stderr: None = None,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None) -> CommandHandle+def is_running(request_timeout: Optional[float] = None) -> bool```-Start a new command and return a handle to interact with it.+Check if the sandbox is running.**Arguments**:-- `cmd`: Command to execute-- `background`: `False` if the command should be executed in the foreground, **`True` if the command should be executed in the background**-- `envs`: Environment variables used for the command-- `user`: User to run the command as-- `cwd`: Working directory to run the command-- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time- `request_timeout`: Timeout for the request in **seconds****Returns**:-`CommandHandle` handle to interact with the running command+`True` if the sandbox is running, `False` otherwise+Example+```python+sandbox = Sandbox()+sandbox.is_running() # Returns True++sandbox.kill()+sandbox.is_running() # Returns False+```### connect```python-def connect(pid: int,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None)+@classmethod+def connect(cls,+ sandbox_id: str,+ api_key: Optional[str] = None,+ domain: Optional[str] = None,+ debug: Optional[bool] = None)```-Connects to a running command.+Connects to an existing Sandbox.-You can use `CommandHandle.wait()` to wait for the command to finish and get execution results.+With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).**Arguments**:-- `pid`: Process ID of the command to connect to. You can get the list of processes using `sandbox.commands.list()`-- `timeout`: Timeout for the connection in **seconds**. Using `0` will not limit the connection time-- `request_timeout`: Timeout for the request in **seconds**+- `sandbox_id`: Sandbox ID+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable**Returns**:-`CommandHandle` handle to interact with the running command-+sandbox instance for the existing sandbox+@example+```python+sandbox = Sandbox()+sandbox_id = sandbox.sandbox_id+same_sandbox = Sandbox.connect(sandbox_id)-## CommandHandle+### kill```python-class CommandHandle()+@overload+def kill(request_timeout: Optional[float] = None) -> bool```-Command execution handle.--It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.+Kill the sandbox.+**Arguments**:-### pid+- `request_timeout`: Timeout for the request in **seconds**-```python-@property-def pid()-```+**Returns**:-Command process ID.+`True` if the sandbox was killed, `False` if the sandbox was not found-### \_\_iter\_\_+### kill```python-def __iter__()+@overload+@staticmethod+def kill(sandbox_id: str,+ api_key: Optional[str] = None,+ domain: Optional[str] = None,+ debug: Optional[bool] = None,+ request_timeout: Optional[float] = None) -> bool```-Iterate over the command output.+Kill the sandbox specified by sandbox ID.++**Arguments**:++- `sandbox_id`: Sandbox ID+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `request_timeout`: Timeout for the request in **seconds****Returns**:-Generator of command outputs+`True` if the sandbox was killed, `False` if the sandbox was not found-### disconnect+### kill```python-def disconnect() -> None+@class_method_variant("_cls_kill")+def kill(request_timeout: Optional[float] = None) -> bool```-Disconnect from the command.+Kill the sandbox.-The command is not killed, but SDK stops receiving events from the command.-You can reconnect to the command using `sandbox.commands.connect` method.+**Arguments**:+- `request_timeout`: Timeout for the request-### wait+**Returns**:++`True` if the sandbox was killed, `False` if the sandbox was not found+++### set\_timeout```python-def wait(on_pty: Optional[Callable[[PtyOutput], None]] = None,- on_stdout: Optional[Callable[[str], None]] = None,- on_stderr: Optional[Callable[[str], None]] = None) -> CommandResult+@overload+def set_timeout(timeout: int, request_timeout: Optional[float] = None) -> None```-Wait for the command to finish and returns the result.--If the command exits with a non-zero exit code, it throws a `CommandExitException`.+Set the timeout of the sandbox.-**Arguments**:+After the timeout expires the sandbox will be automatically killed.+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.-- `on_pty`: Callback for pty output-- `on_stdout`: Callback for stdout output-- `on_stderr`: Callback for stderr output+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.-**Returns**:+**Arguments**:-`CommandResult` result of command execution+- `timeout`: Timeout for the sandbox in **seconds**+- `request_timeout`: Timeout for the request in **seconds**-### kill+### set\_timeout```python-def kill() -> bool+@overload+@staticmethod+def set_timeout(sandbox_id: str,+ timeout: int,+ api_key: Optional[str] = None,+ domain: Optional[str] = None,+ debug: Optional[bool] = None,+ request_timeout: Optional[float] = None) -> None```-Kills the command.+Set the timeout of the sandbox specified by sandbox ID.-It uses `SIGKILL` signal to kill the command.+After the timeout expires the sandbox will be automatically killed.+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.-**Returns**:+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.-Whether the command was killed successfully+**Arguments**:++- `sandbox_id`: Sandbox ID+- `timeout`: Timeout for the sandbox in **seconds**+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+- `request_timeout`: Timeout for the request in **seconds**diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex 2ec34043d..712938547 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -41,7 +41,7 @@"test": "pnpm build && cd testground/demo-basic && ../../dist/index.js template build","check-deps": "knip","update-deps": "ncu -u && pnpm i",- "generate-sdk-reference": "./scripts/generate_sdk_ref.sh"+ "generate-ref": "./scripts/generate_sdk_ref.sh"},"devDependencies": {"@types/command-exists": "^1.2.3",diff --git a/packages/js-sdk/package.json b/packages/js-sdk/package.jsonindex 5b46dc5f0..d57b08e15 100644--- a/packages/js-sdk/package.json+++ b/packages/js-sdk/package.json@@ -30,7 +30,7 @@"test": "vitest run","generate": "openapi-typescript ../../spec/openapi.yml -x api_key --support-array-length --alphabetize --output src/api/schema.gen.ts","generate-envd-api": "openapi-typescript ../../spec/envd/envd.yaml -x api_key --support-array-length --alphabetize --output src/envd/schema.gen.ts",- "generate-sdk-reference": "./scripts/generate_sdk_ref.sh",+ "generate-ref": "./scripts/generate_sdk_ref.sh","check-deps": "knip","update-deps": "ncu -u && pnpm i","postPublish": "./scripts/post-publish.sh || true",diff --git a/packages/python-sdk/package.json b/packages/python-sdk/package.jsonindex d5f570120..4ff164a5e 100644--- a/packages/python-sdk/package.json+++ b/packages/python-sdk/package.json@@ -8,6 +8,6 @@"postVersion": "poetry version $(pnpm pkg get version --workspaces=false | tr -d \\\")","postPublish": "poetry build && poetry config pypi-token.pypi ${PYPI_TOKEN} && poetry publish --skip-existing","pretest": "poetry install",- "generate-sdk-reference": "poetry install && ./scripts/generate_sdk_ref.sh"+ "generate-ref": "poetry install && ./scripts/generate_sdk_ref.sh"}}