Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
[skip ci] Release new versions
github-actions[bot]546a2282faa2
diff --git a/.changeset/hungry-carpets-sit.md b/.changeset/hungry-carpets-sit.mddeleted file mode 100644index 540f5fff6..000000000--- a/.changeset/hungry-carpets-sit.md+++ /dev/null@@ -1,5 +0,0 @@-----'@e2b/cli': patch------fixed --config option in e2b tpl publish and e2b tpl deletediff --git a/apps/web/src/app/(docs)/docs/sdk-reference/cli/v2.3.1/auth/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v2.3.1/auth/page.mdxnew file mode 100644index 000000000..2c82afa69--- /dev/null+++ b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v2.3.1/auth/page.mdx@@ -0,0 +1,58 @@+## e2b auth+++authentication commands++### Usage++```bash+e2b auth [options] [command]+```+## e2b auth login+++log in to CLI++### Usage++```bash+e2b auth login [options]+```+++## e2b auth logout+++log out of CLI++### Usage++```bash+e2b auth logout [options]+```+++## e2b auth info+++get information about the current user++### Usage++```bash+e2b auth info [options]+```+++## e2b auth configure+++configure user++### Usage++```bash+e2b auth configure [options]+```++diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/cli/v2.3.1/sandbox/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v2.3.1/sandbox/page.mdxnew file mode 100644index 000000000..7ab7f7a1e--- /dev/null+++ b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v2.3.1/sandbox/page.mdx@@ -0,0 +1,135 @@+## e2b sandbox+++work with sandboxes++### Usage++```bash+e2b sandbox [options] [command]+```+## e2b sandbox connect+++connect terminal to already running sandbox++### Usage++```bash+e2b sandbox connect [options] <sandboxID>+```+++## e2b sandbox list+++list all sandboxes, by default it list only running ones++### Usage++```bash+e2b sandbox list [options]+```++### Options+++ - `-s, --state <state>: filter by state, eg. running, paused. Defaults to running `+ - `-m, --metadata <metadata>: filter by metadata, eg. key1=value1 `+ - `-l, --limit <limit>: limit the number of sandboxes returned `+ - `-f, --format <format>: output format, eg. json, pretty `+++## e2b sandbox kill+++kill sandbox++### Usage++```bash+e2b sandbox kill [options] [sandboxIDs...]+```++### Options+++ - `-a, --all: kill all sandboxes `+ - `-s, --state <state>: when used with -a/--all flag, filter by state, eg. running, paused. Defaults to running `+ - `-m, --metadata <metadata>: when used with -a/--all flag, filter by metadata, eg. key1=value1 `+++## e2b sandbox create+++create sandbox and connect terminal to it++### Usage++```bash+e2b sandbox create [options] [template]+```++### Options+++ - `-p, --path <path>: change root directory where command is executed to <path> directory `+ - `--config <e2b-toml>: specify path to the E2B config toml. By default E2B tries to find ./e2b.toml in root directory. `+++## e2b sandbox spawn+++create sandbox and connect terminal to it++### Usage++```bash+e2b sandbox spawn [options] [template]+```++### Options+++ - `-p, --path <path>: change root directory where command is executed to <path> directory `+ - `--config <e2b-toml>: specify path to the E2B config toml. By default E2B tries to find ./e2b.toml in root directory. `+++## e2b sandbox logs+++show logs for sandbox++### Usage++```bash+e2b sandbox logs [options] <sandboxID>+```++### Options+++ - `--level <level>: filter logs by level (DEBUG, INFO, WARN, ERROR). The logs with the higher levels will be also shown. [default: INFO]`+ - `-f, --follow: keep streaming logs until the sandbox is closed `+ - `--format <format>: specify format for printing logs (json, pretty) [default: pretty]`+ - `--loggers [loggers]: filter logs by loggers. Specify multiple loggers by separating them with a comma. `+++## e2b sandbox metrics+++show metrics for sandbox++### Usage++```bash+e2b sandbox metrics [options] <sandboxID>+```++### Options+++ - `-f, --follow: keep streaming metrics until the sandbox is closed `+ - `--format <format>: specify format for printing metrics (json, pretty) [default: pretty]`++diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/cli/v2.3.1/template/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v2.3.1/template/page.mdxnew file mode 100644index 000000000..8129e44a9--- /dev/null+++ b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v2.3.1/template/page.mdx@@ -0,0 +1,180 @@+## e2b template+++manage sandbox templates++### Usage++```bash+e2b template [options] [command]+```+## e2b template create+++build Dockerfile as a Sandbox template. This command reads a Dockerfile and builds it directly.++### Usage++```bash+e2b template create [options] <template-name>+```++### Options+++ - `-p, --path <path>: change root directory where command is executed to <path> directory `+ - `-d, --dockerfile <file>: specify path to Dockerfile. By default E2B tries to find e2b.Dockerfile or Dockerfile in root directory. `+ - `-c, --cmd <start-command>: specify command that will be executed when the sandbox is started. `+ - `--ready-cmd <ready-command>: specify command that will need to exit 0 for the template to be ready. `+ - `--cpu-count <cpu-count>: specify the number of CPUs that will be used to run the sandbox. The default value is 2. `+ - `--memory-mb <memory-mb>: specify the amount of memory in megabytes that will be used to run the sandbox. Must be an even number. The default value is 512. `+ - `--no-cache: skip cache when building the template. `+++## e2b template build+++build sandbox template defined by ./e2b.Dockerfile or ./Dockerfile in root directory. By default the root directory is the current working directory. This command also creates e2b.toml config.++### Usage++```bash+e2b template build [options] [template]+```++### Options+++ - `-p, --path <path>: change root directory where command is executed to <path> directory `+ - `-d, --dockerfile <file>: specify path to Dockerfile. By default E2B tries to find e2b.Dockerfile or Dockerfile in root directory. `+ - `-n, --name <template-name>: specify sandbox template name. You can use the template name to start the sandbox with SDK. The template name must be lowercase and contain only letters, numbers, dashes and underscores. `+ - `-c, --cmd <start-command>: specify command that will be executed when the sandbox is started. `+ - `--ready-cmd <ready-command>: specify command that will need to exit 0 for the template to be ready. `+ - `-t, --team <team-id>: specify the team ID that the operation will be associated with. You can find team ID in the team settings in the E2B dashboard (https://e2b.dev/dashboard?tab=team). `+ - `--config <e2b-toml>: specify path to the E2B config toml. By default E2B tries to find ./e2b.toml in root directory. `+ - `--cpu-count <cpu-count>: specify the number of CPUs that will be used to run the sandbox. The default value is 2. `+ - `--memory-mb <memory-mb>: specify the amount of memory in megabytes that will be used to run the sandbox. Must be an even number. The default value is 512. `+ - `--build-arg <args...>: specify additional build arguments for the build command. The format should be <varname>=<value>. `+ - `--no-cache: skip cache when building the template. `+++## e2b template list+++list sandbox templates++### Usage++```bash+e2b template list [options]+```++### Options+++ - `-t, --team <team-id>: specify the team ID that the operation will be associated with. You can find team ID in the team settings in the E2B dashboard (https://e2b.dev/dashboard?tab=team). `+ - `-f, --format <format>: output format, eg. json, pretty `+++## e2b template init+++initialize a new sandbox template using the SDK++### Usage++```bash+e2b template init [options]+```++### Options+++ - `-p, --path <path>: change root directory where command is executed to <path> directory `+ - `-n, --name <name>: template name (alias) `+ - `-l, --language <language>: target language: typescript, python-sync, python-async `+++## e2b template delete+++delete sandbox template and e2b.toml config++### Usage++```bash+e2b template delete [options] [template]+```++### Options+++ - `-p, --path <path>: change root directory where command is executed to <path> directory `+ - `--config <e2b-toml>: specify path to the E2B config toml. By default E2B tries to find ./e2b.toml in root directory. `+ - `-s, --select: select sandbox template from interactive list `+ - `-t, --team <team-id>: specify the team ID that the operation will be associated with. You can find team ID in the team settings in the E2B dashboard (https://e2b.dev/dashboard?tab=team). `+ - `-y, --yes: skip manual delete confirmation `+++## e2b template publish+++publish sandbox template++### Usage++```bash+e2b template publish [options] [template]+```++### Options+++ - `-p, --path <path>: change root directory where command is executed to <path> directory `+ - `--config <e2b-toml>: specify path to the E2B config toml. By default E2B tries to find ./e2b.toml in root directory. `+ - `-s, --select: select sandbox template from interactive list `+ - `-t, --team <team-id>: specify the team ID that the operation will be associated with. You can find team ID in the team settings in the E2B dashboard (https://e2b.dev/dashboard?tab=team). `+ - `-y, --yes: skip manual publish confirmation `+++## e2b template unpublish+++unpublish sandbox template++### Usage++```bash+e2b template unpublish [options] [template]+```++### Options+++ - `-p, --path <path>: change root directory where command is executed to <path> directory `+ - `--config <e2b-toml>: specify path to the E2B config toml. By default E2B tries to find ./e2b.toml in root directory. `+ - `-s, --select: select sandbox template from interactive list `+ - `-t, --team <team-id>: specify the team ID that the operation will be associated with. You can find team ID in the team settings in the E2B dashboard (https://e2b.dev/dashboard?tab=team). `+ - `-y, --yes: skip manual unpublish confirmation `+++## e2b template migrate+++migrate e2b.Dockerfile and e2b.toml to new Template SDK format++### Usage++```bash+e2b template migrate [options]+```++### Options+++ - `-d, --dockerfile <file>: specify path to Dockerfile. Defaults to e2b.Dockerfile `+ - `--config <e2b-toml>: specify path to the E2B config toml. By default E2B tries to find ./e2b.toml in root directory. `+ - `-l, --language <language>: specify target language: typescript, python-sync, python-async `+ - `-p, --path <path>: change root directory where command is executed to <path> directory `++diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/sandbox_async/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/sandbox_async/page.mdxindex afe6ce27f..0e3318dab 100644--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/sandbox_async/page.mdx+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/sandbox_async/page.mdx@@ -1,478 +1,661 @@-## SandboxApi+## AsyncSandbox```python-class SandboxApi(SandboxBase)+class AsyncSandbox(SandboxApi)```+E2B cloud sandbox is a secure and isolated cloud environment.-### list+The sandbox allows you to:+- Access Linux OS+- Create, list, and delete files and directories+- Run commands+- Run isolated code+- Access the internet-```python-@staticmethod-def list(query: Optional[SandboxQuery] = None,- limit: Optional[int] = None,- next_token: Optional[str] = None,- **opts: Unpack[ApiParams]) -> AsyncSandboxPaginator-```+Check docs [here](https://e2b.dev/docs).-List all running sandboxes.+Use the `AsyncSandbox.create()` to create a new sandbox.-**Arguments**:+**Example**:-- `query`: Filter the list of sandboxes by metadata or state, e.g. `SandboxListQuery(metadata={"key": "value"})` or `SandboxListQuery(state=[SandboxState.RUNNING])`-- `limit`: Maximum number of sandboxes to return per page-- `next_token`: Token for pagination+```python+from e2b import AsyncSandbox-**Returns**:+sandbox = await AsyncSandbox.create()+```-List of running sandboxes+### files+```python+@property+def files() -> Filesystem+```+Module for interacting with the sandbox filesystem.-## Commands++### commands```python-class Commands()+@property+def commands() -> Commands```-Module for executing commands in the sandbox.+Module for running commands in the sandbox.-### list+### pty```python-async def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]+@property+def pty() -> Pty```-Lists all running commands and PTY sessions.+Module for interacting with the sandbox pseudo-terminal.-**Arguments**:-- `request_timeout`: Timeout for the request in **seconds**+### \_\_init\_\_-**Returns**:+```python+def __init__(**opts: Unpack[SandboxOpts])+```-List of running commands and PTY sessions+Use `AsyncSandbox.create()` to create a new sandbox instead.-### kill+### is\_running```python-async def kill(pid: int, request_timeout: Optional[float] = None) -> bool+async def is_running(request_timeout: Optional[float] = None) -> bool```-Kill a running command specified by its process ID.--It uses `SIGKILL` signal to kill the command.+Check if the sandbox is running.**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****Returns**:-`True` if the command was killed, `False` if the command was not found+`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+```-### send\_stdin+### create```python-async def send_stdin(pid: int,- data: str,- request_timeout: Optional[float] = None) -> None+@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,+ secure: Optional[bool] = True,+ allow_internet_access: bool = True,+ **opts: Unpack[ApiParams]) -> Self```-Send data to command stdin.+Create a new sandbox.-: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**+By default, the sandbox is created from the default `base` sandbox template.++**Arguments**:+- `template`: Sandbox template name or ID+- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. The 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+- `secure`: Envd is secured with access token and cannot be used without it, defaults to `True`.+- `allow_internet_access`: Allow sandbox to access the internet, defaults to `True`.+**Returns**:-### run+A Sandbox instance for the new sandbox+Use this method instead of using the constructor to create a new sandbox.+++### connect```python@overload-async def run(cmd: str,- background: Union[Literal[False], None] = None,- envs: Optional[Dict[str, str]] = None,- user: Optional[Username] = None,- cwd: Optional[str] = None,- on_stdout: Optional[OutputHandler[Stdout]] = None,- on_stderr: Optional[OutputHandler[Stderr]] = None,- stdin: Optional[bool] = None,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None) -> CommandResult+async def connect(timeout: Optional[int] = None,+ **opts: Unpack[ApiParams]) -> Self```-Start a new command and wait until it finishes executing.+Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.++Sandbox must be either running or be paused.++With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).**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-- `stdin`: If `True`, the command will have a stdin stream that you can send data to using `sandbox.commands.send_stdin()`-- `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**+- `timeout`: Timeout for the sandbox in **seconds****Returns**:-`CommandResult` result of the command execution+A running sandbox instance+@example+```python+sandbox = await AsyncSandbox.create()+await sandbox.beta_pause()+same_sandbox = await sandbox.connect()+```-### run++### connect```python@overload-async def run(cmd: str,- background: Literal[True],- envs: Optional[Dict[str, str]] = None,- user: Optional[Username] = None,- cwd: Optional[str] = None,- on_stdout: Optional[OutputHandler[Stdout]] = None,- on_stderr: Optional[OutputHandler[Stderr]] = None,- stdin: Optional[bool] = None,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None) -> AsyncCommandHandle+@classmethod+async def connect(cls,+ sandbox_id: str,+ timeout: Optional[int] = None,+ **opts: Unpack[ApiParams]) -> Self```-Start a new command and return a handle to interact with it.+Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.++Sandbox must be either running or be paused.++With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).**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-- `stdin`: If `True`, the command will have a stdin stream that you can send data to using `sandbox.commands.send_stdin()`-- `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**+- `sandbox_id`: Sandbox ID+- `timeout`: Timeout for the sandbox in **seconds****Returns**:-`AsyncCommandHandle` handle to interact with the running command+A running sandbox instance+@example+```python+sandbox = await AsyncSandbox.create()+await AsyncSandbox.beta_pause(sandbox.sandbox_id)++same_sandbox = await AsyncSandbox.connect(sandbox.sandbox_id))+```### connect```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+@class_method_variant("_cls_connect")+async def connect(timeout: Optional[int] = None,+ **opts: Unpack[ApiParams]) -> Self```-Connects to a running command.+Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.-You can use `AsyncCommandHandle.wait()` to wait for the command to finish and get execution results.+Sandbox must be either running or be paused.++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()`-- `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+- `timeout`: Timeout for the sandbox in **seconds****Returns**:-`AsyncCommandHandle` handle to interact with the running command-+A running sandbox instance+@example+```python+sandbox = await AsyncSandbox.create()+await sandbox.beta_pause()+same_sandbox = await sandbox.connect()+```-## AsyncCommandHandle+### kill```python-class AsyncCommandHandle()+@overload+async def kill(**opts: Unpack[ApiParams]) -> bool```-Command execution handle.+Kill the sandbox.-It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.+**Returns**:++`True` if the sandbox was killed, `False` if the sandbox was not found-### pid+### kill```python-@property-def pid()+@overload+@staticmethod+async def kill(sandbox_id: str, **opts: Unpack[ApiParams]) -> bool```-Command process ID.+Kill the sandbox specified by sandbox ID.+**Arguments**:-### stdout+- `sandbox_id`: Sandbox ID-```python-@property-def stdout()-```+**Returns**:-Command stdout output.+`True` if the sandbox was killed, `False` if the sandbox was not found-### stderr+### kill```python-@property-def stderr()+@class_method_variant("_cls_kill")+async def kill(**opts: Unpack[ApiParams]) -> bool```-Command stderr output.---### error+Kill the sandbox specified by sandbox ID.-```python-@property-def error()-```+**Returns**:-Command execution error message.+`True` if the sandbox was killed, `False` if the sandbox was not found-### exit\_code+### set\_timeout```python-@property-def exit_code()+@overload+async def set_timeout(timeout: int, **opts: Unpack[ApiParams]) -> None```-Command execution exit code.--`0` if the command finished successfully.--It is `None` if the command is still running.-+Set the timeout of the sandbox.-### disconnect+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 disconnect() -> None-```+The 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.-Disconnects from the command.+**Arguments**:-The command is not killed, but SDK stops receiving events from the command.-You can reconnect to the command using `sandbox.commands.connect` method.+- `timeout`: Timeout for the sandbox in **seconds**-### wait+### set\_timeout```python-async def wait() -> CommandResult+@overload+@staticmethod+async def set_timeout(sandbox_id: str, timeout: int,+ **opts: Unpack[ApiParams]) -> None```-Wait for the command to finish and return the result.+Set the timeout of the specified 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**:+The 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**:++- `sandbox_id`: Sandbox ID+- `timeout`: Timeout for the sandbox in **seconds**-### kill+### set\_timeout```python-async def kill() -> bool+@class_method_variant("_cls_set_timeout")+async def set_timeout(timeout: int, **opts: Unpack[ApiParams]) -> None```-Kills the command.--It uses `SIGKILL` signal to kill the command+Set the timeout of the specified sandbox.-**Returns**:+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`.-`True` if the command was killed successfully, `False` if the command was not found+The 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**:+- `timeout`: Timeout for the sandbox in **seconds**-## Pty+### get\_info```python-class Pty()+@overload+async def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo```-Module for interacting with PTYs (pseudo-terminals) in the sandbox.+Get sandbox information like sandbox ID, template, metadata, started at/end at date.+**Returns**:-### kill+Sandbox info+++### get\_info```python-async def kill(pid: int, request_timeout: Optional[float] = None) -> bool+@overload+@staticmethod+async def get_info(sandbox_id: str, **opts: Unpack[ApiParams]) -> SandboxInfo```-Kill PTY.+Get sandbox information like sandbox ID, template, metadata, started at/end at date.**Arguments**:-- `pid`: Process ID of the PTY-- `request_timeout`: Timeout for the request in **seconds**+- `sandbox_id`: Sandbox ID**Returns**:-`true` if the PTY was killed, `false` if the PTY was not found+Sandbox info-### send\_stdin+### get\_info```python-async def send_stdin(pid: int,- data: bytes,- request_timeout: Optional[float] = None) -> None+@class_method_variant("_cls_get_info")+async def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo```-Send input to a PTY.+Get sandbox information like sandbox ID, template, metadata, started at/end at date.-**Arguments**:+**Returns**:-- `pid`: Process ID of the PTY-- `data`: Input data to send-- `request_timeout`: Timeout for the request in **seconds**+Sandbox info-### create+### get\_metrics```python-async def create(- size: PtySize,- on_data: OutputHandler[PtyOutput],- user: Optional[Username] = None,- cwd: Optional[str] = None,- envs: Optional[Dict[str, str]] = None,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None) -> AsyncCommandHandle+@overload+async def get_metrics(start: Optional[datetime.datetime] = None,+ end: Optional[datetime.datetime] = None,+ **opts: Unpack[ApiParams]) -> List[SandboxMetrics]```-Start a new PTY (pseudo-terminal).+Get the metrics of the current sandbox.**Arguments**:-- `size`: Size of the PTY-- `on_data`: Callback to handle PTY data-- `user`: User to use for the PTY-- `cwd`: Working directory for the PTY-- `envs`: Environment variables for the PTY-- `timeout`: Timeout for the PTY in **seconds**-- `request_timeout`: Timeout for the request in **seconds**+- `start`: Start time for the metrics, defaults to the start of the sandbox+- `end`: End time for the metrics, defaults to the current time**Returns**:-Handle to interact with the PTY+List of sandbox metrics containing CPU, memory and disk usage information-### resize+### get\_metrics```python-async def resize(pid: int,- size: PtySize,- request_timeout: Optional[float] = None)+@overload+@staticmethod+async def get_metrics(sandbox_id: str,+ start: Optional[datetime.datetime] = None,+ end: Optional[datetime.datetime] = None,+ **opts: Unpack[ApiParams]) -> List[SandboxMetrics]```-Resize PTY.--Call this when the terminal window is resized and the number of columns and rows has changed.+Get the metrics of the sandbox specified by sandbox ID.**Arguments**:-- `pid`: Process ID of the PTY-- `size`: New size of the PTY-- `request_timeout`: Timeout for the request in **seconds**+- `sandbox_id`: Sandbox ID+- `start`: Start time for the metrics, defaults to the start of the sandbox+- `end`: End time for the metrics, defaults to the current time+**Returns**:+List of sandbox metrics containing CPU, memory and disk usage information-## AsyncWatchHandle+### get\_metrics```python-class AsyncWatchHandle()+@class_method_variant("_cls_get_metrics")+async def get_metrics(start: Optional[datetime.datetime] = None,+ end: Optional[datetime.datetime] = None,+ **opts: Unpack[ApiParams]) -> List[SandboxMetrics]```-Handle for watching a directory in the sandbox filesystem.+Get the metrics of the current sandbox.-Use `.stop()` to stop watching the directory.+**Arguments**:++- `start`: Start time for the metrics, defaults to the start of the sandbox+- `end`: End time for the metrics, defaults to the current time+**Returns**:-### stop+List of sandbox metrics containing CPU, memory and disk usage information+++### beta\_create```python-async def stop()+@classmethod+async def beta_create(cls,+ template: Optional[str] = None,+ timeout: Optional[int] = None,+ auto_pause: bool = False,+ metadata: Optional[Dict[str, str]] = None,+ envs: Optional[Dict[str, str]] = None,+ secure: bool = True,+ allow_internet_access: bool = True,+ mcp: Optional[McpServer] = None,+ **opts: Unpack[ApiParams]) -> Self```-Stop watching the directory.+[BETA] This feature is in beta and may change in the future.+Create a new sandbox.+By default, the sandbox is created from the default `base` sandbox template.+**Arguments**:-## Filesystem+- `template`: Sandbox template name or ID+- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. The 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.+- `auto_pause`: Automatically pause the sandbox after the timeout expires. Defaults to `False`.+- `metadata`: Custom metadata for the sandbox+- `envs`: Custom environment variables for the sandbox+- `secure`: Envd is secured with access token and cannot be used without it, defaults to `True`.+- `allow_internet_access`: Allow sandbox to access the internet, defaults to `True`.+- `mcp`: MCP server to enable in the sandbox-```python-class Filesystem()-```+**Returns**:-Module for interacting with the filesystem in the sandbox.+A Sandbox instance for the new sandbox+Use this method instead of using the constructor to create a new sandbox.-### read+### beta\_pause```python@overload-async def read(path: str,- format: Literal["text"] = "text",- user: Optional[Username] = None,- request_timeout: Optional[float] = None) -> str+async def beta_pause(**opts: Unpack[ApiParams]) -> None```-Read file content as a `str`.--**Arguments**:+[BETA] This feature is in beta and may change in the future.-- `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**+Pause the sandbox.**Returns**:-File content as a `str`+Sandbox ID that can be used to resume the sandbox-### read+### beta\_pause```python@overload-async def read(path: str,- format: Literal["bytes"],- user: Optional[Username] = None,- request_timeout: Optional[float] = None) -> bytearray+@staticmethod+async def beta_pause(sandbox_id: str, **opts: Unpack[ApiParams]) -> None```-Read file content as a `bytearray`.+[BETA] This feature is in beta and may change in the future.++Pause the sandbox specified by sandbox ID.**Arguments**:-- `path`: Path to the file-- `user`: Run the operation as this user+- `sandbox_id`: Sandbox ID++**Returns**:++Sandbox ID that can be used to resume the sandbox+++### beta\_pause++```python+@class_method_variant("_cls_pause")+async def beta_pause(**opts: Unpack[ApiParams]) -> None+```++[BETA] This feature is in beta and may change in the future.++Pause the sandbox.++**Returns**:++Sandbox ID that can be used to resume the sandbox+++### beta\_get\_mcp\_token++```python+async def beta_get_mcp_token() -> Optional[str]+```++[BETA] This feature is in beta and may change in the future.++Get the MCP token for the sandbox.++**Returns**:++MCP token for the sandbox, or None if MCP is not enabled.+++++## AsyncSandboxPaginator++```python+class AsyncSandboxPaginator(SandboxPaginatorBase)+```++Paginator for listing sandboxes.++**Example**:++```python+paginator = AsyncSandbox.list()++while paginator.has_next:+ sandboxes = await paginator.next_items()+ print(sandboxes)+```+++### next\_items++```python+async def next_items() -> List[SandboxInfo]+```++Returns the next page of sandboxes.++Call this method only if `has_next` is `True`, otherwise it will raise an exception.++**Returns**:++List of sandboxes+++++## AsyncWatchHandle++```python+class AsyncWatchHandle()+```++Handle for watching a directory in the sandbox filesystem.++Use `.stop()` to stop watching the directory.+++### stop++```python+async def stop()+```++Stop watching the directory.+++++## Filesystem++```python+class Filesystem()+```++Module for interacting with the filesystem in the sandbox.+++### read++```python+@overload+async def read(path: str,+ format: Literal["text"] = "text",+ user: Optional[Username] = None,+ request_timeout: Optional[float] = None) -> str+```++Read file content as a `str`.++**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`+++### read++```python+@overload+async def read(path: str,+ format: Literal["bytes"],+ user: Optional[Username] = None,+ request_timeout: Optional[float] = None) -> bytearray+```++Read file content as a `bytearray`.++**Arguments**:++- `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**@@ -717,116 +900,24 @@ Watch directory for filesystem events.-## AsyncSandboxPaginator--```python-class AsyncSandboxPaginator(SandboxPaginatorBase)-```--Paginator for listing sandboxes.--**Example**:--```python-paginator = AsyncSandbox.list()--while paginator.has_next:- sandboxes = await paginator.next_items()- print(sandboxes)-```---### next\_items-```python-async def next_items() -> List[SandboxInfo]-```-Returns the next page of sandboxes.--Call this method only if `has_next` is `True`, otherwise it will raise an exception.--**Returns**:--List of sandboxes-----## AsyncSandbox--```python-class AsyncSandbox(SandboxApi)-```--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 import AsyncSandbox--sandbox = await AsyncSandbox.create()-```---### files--```python-@property-def files() -> Filesystem-```--Module for interacting with the sandbox filesystem.---### commands--```python-@property-def commands() -> Commands-```--Module for running commands in the sandbox.---### pty--```python-@property-def pty() -> Pty-```--Module for interacting with the sandbox pseudo-terminal.---### \_\_init\_\_+## Commands```python-def __init__(**opts: Unpack[SandboxOpts])+class Commands()```-Use `AsyncSandbox.create()` to create a new sandbox instead.+Module for executing commands in the sandbox.-### is\_running+### list```python-async def is_running(request_timeout: Optional[float] = None) -> bool+async def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]```-Check if the sandbox is running.+Lists all running commands and PTY sessions.**Arguments**:@@ -834,469 +925,378 @@ Check if the sandbox is running.**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-```+List of running commands and PTY sessions-### create+### kill```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,- secure: Optional[bool] = True,- allow_internet_access: bool = True,- **opts: Unpack[ApiParams]) -> Self+async def kill(pid: int, request_timeout: Optional[float] = None) -> bool```-Create a new sandbox.+Kill a running command specified by its process ID.-By default, the sandbox is created from the default `base` sandbox template.+It uses `SIGKILL` signal to kill the command.**Arguments**:-- `template`: Sandbox template name or ID-- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. The 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-- `secure`: Envd is secured with access token and cannot be used without it, defaults to `True`.-- `allow_internet_access`: Allow sandbox to access the internet, defaults to `True`.+- `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**:-A Sandbox instance for the new sandbox-Use this method instead of using the constructor to create a new sandbox.+`True` if the command was killed, `False` if the command was not found-### connect+### send\_stdin```python-@overload-async def connect(timeout: Optional[int] = None,- **opts: Unpack[ApiParams]) -> Self+async def send_stdin(pid: int,+ data: str,+ request_timeout: Optional[float] = None) -> None```-Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.--Sandbox must be either running or be paused.--With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).--**Arguments**:--- `timeout`: Timeout for the sandbox in **seconds**--**Returns**:+Send data to command stdin.-A running sandbox instance-@example-```python-sandbox = await AsyncSandbox.create()-await sandbox.beta_pause()+: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**-same_sandbox = await sandbox.connect()-```-### connect+### run```python@overload-@classmethod-async def connect(cls,- sandbox_id: str,- timeout: Optional[int] = None,- **opts: Unpack[ApiParams]) -> Self-```--Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.--Sandbox must be either running or be paused.--With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).--**Arguments**:--- `sandbox_id`: Sandbox ID-- `timeout`: Timeout for the sandbox in **seconds**--**Returns**:--A running sandbox instance-@example-```python-sandbox = await AsyncSandbox.create()-await AsyncSandbox.beta_pause(sandbox.sandbox_id)--same_sandbox = await AsyncSandbox.connect(sandbox.sandbox_id))-```---### connect--```python-@class_method_variant("_cls_connect")-async def connect(timeout: Optional[int] = None,- **opts: Unpack[ApiParams]) -> Self+async def run(cmd: str,+ background: Union[Literal[False], None] = None,+ envs: Optional[Dict[str, str]] = None,+ user: Optional[Username] = None,+ cwd: Optional[str] = None,+ on_stdout: Optional[OutputHandler[Stdout]] = None,+ on_stderr: Optional[OutputHandler[Stderr]] = None,+ stdin: Optional[bool] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> CommandResult```-Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.--Sandbox must be either running or be paused.--With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).+Start a new command and wait until it finishes executing.**Arguments**:-- `timeout`: Timeout for the sandbox in **seconds**--**Returns**:--A running sandbox instance-@example-```python-sandbox = await AsyncSandbox.create()-await sandbox.beta_pause()--same_sandbox = await sandbox.connect()-```---### kill--```python-@overload-async def kill(**opts: Unpack[ApiParams]) -> bool-```--Kill the sandbox.+- `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+- `stdin`: If `True`, the command will have a stdin stream that you can send data to using `sandbox.commands.send_stdin()`+- `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**:-`True` if the sandbox was killed, `False` if the sandbox was not found+`CommandResult` result of the command execution-### kill+### run```python@overload-@staticmethod-async def kill(sandbox_id: str, **opts: Unpack[ApiParams]) -> bool+async def run(cmd: str,+ background: Literal[True],+ envs: Optional[Dict[str, str]] = None,+ user: Optional[Username] = None,+ cwd: Optional[str] = None,+ on_stdout: Optional[OutputHandler[Stdout]] = None,+ on_stderr: Optional[OutputHandler[Stderr]] = None,+ stdin: Optional[bool] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> AsyncCommandHandle```-Kill the sandbox specified by sandbox ID.+Start a new command and return a handle to interact with it.**Arguments**:-- `sandbox_id`: Sandbox ID--**Returns**:--`True` if the sandbox was killed, `False` if the sandbox was not found---### kill--```python-@class_method_variant("_cls_kill")-async def kill(**opts: Unpack[ApiParams]) -> bool-```--Kill the sandbox specified by sandbox ID.+- `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+- `stdin`: If `True`, the command will have a stdin stream that you can send data to using `sandbox.commands.send_stdin()`+- `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**:-`True` if the sandbox was killed, `False` if the sandbox was not found---### set\_timeout--```python-@overload-async def set_timeout(timeout: int, **opts: Unpack[ApiParams]) -> 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`.--The 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**:--- `timeout`: Timeout for the sandbox in **seconds**+`AsyncCommandHandle` handle to interact with the running command-### set\_timeout+### connect```python-@overload-@staticmethod-async def set_timeout(sandbox_id: str, timeout: int,- **opts: Unpack[ApiParams]) -> None-```--Set the timeout of the specified 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`.--The 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**+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+```+Connects to a running command.-### set\_timeout+You can use `AsyncCommandHandle.wait()` to wait for the command to finish and get execution results.-```python-@class_method_variant("_cls_set_timeout")-async def set_timeout(timeout: int, **opts: Unpack[ApiParams]) -> None-```+**Arguments**:-Set the timeout of the specified sandbox.+- `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-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**:-The 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.+`AsyncCommandHandle` handle to interact with the running command-**Arguments**:-- `timeout`: Timeout for the sandbox in **seconds**-### get\_info+## Pty```python-@overload-async def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo+class Pty()```-Get sandbox information like sandbox ID, template, metadata, started at/end at date.--**Returns**:--Sandbox info+Module for interacting with PTYs (pseudo-terminals) in the sandbox.-### get\_info+### kill```python-@overload-@staticmethod-async def get_info(sandbox_id: str, **opts: Unpack[ApiParams]) -> SandboxInfo+async def kill(pid: int, request_timeout: Optional[float] = None) -> bool```-Get sandbox information like sandbox ID, template, metadata, started at/end at date.+Kill PTY.**Arguments**:-- `sandbox_id`: Sandbox ID+- `pid`: Process ID of the PTY+- `request_timeout`: Timeout for the request in **seconds****Returns**:-Sandbox info+`true` if the PTY was killed, `false` if the PTY was not found-### get\_info+### send\_stdin```python-@class_method_variant("_cls_get_info")-async def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo+async def send_stdin(pid: int,+ data: bytes,+ request_timeout: Optional[float] = None) -> None```-Get sandbox information like sandbox ID, template, metadata, started at/end at date.+Send input to a PTY.-**Returns**:+**Arguments**:-Sandbox info+- `pid`: Process ID of the PTY+- `data`: Input data to send+- `request_timeout`: Timeout for the request in **seconds**-### get\_metrics+### create```python-@overload-async def get_metrics(start: Optional[datetime.datetime] = None,- end: Optional[datetime.datetime] = None,- **opts: Unpack[ApiParams]) -> List[SandboxMetrics]+async def create(+ size: PtySize,+ on_data: OutputHandler[PtyOutput],+ user: Optional[Username] = None,+ cwd: Optional[str] = None,+ envs: Optional[Dict[str, str]] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> AsyncCommandHandle```-Get the metrics of the current sandbox.+Start a new PTY (pseudo-terminal).**Arguments**:-- `start`: Start time for the metrics, defaults to the start of the sandbox-- `end`: End time for the metrics, defaults to the current time+- `size`: Size of the PTY+- `on_data`: Callback to handle PTY data+- `user`: User to use for the PTY+- `cwd`: Working directory for the PTY+- `envs`: Environment variables for the PTY+- `timeout`: Timeout for the PTY in **seconds**+- `request_timeout`: Timeout for the request in **seconds****Returns**:-List of sandbox metrics containing CPU, memory and disk usage information+Handle to interact with the PTY-### get\_metrics+### resize```python-@overload-@staticmethod-async def get_metrics(sandbox_id: str,- start: Optional[datetime.datetime] = None,- end: Optional[datetime.datetime] = None,- **opts: Unpack[ApiParams]) -> List[SandboxMetrics]+async def resize(pid: int,+ size: PtySize,+ request_timeout: Optional[float] = None)```-Get the metrics of the sandbox specified by sandbox ID.+Resize PTY.++Call this when the terminal window is resized and the number of columns and rows has changed.**Arguments**:-- `sandbox_id`: Sandbox ID-- `start`: Start time for the metrics, defaults to the start of the sandbox-- `end`: End time for the metrics, defaults to the current time+- `pid`: Process ID of the PTY+- `size`: New size of the PTY+- `request_timeout`: Timeout for the request in **seconds**-**Returns**:-List of sandbox metrics containing CPU, memory and disk usage information-### get\_metrics+## AsyncCommandHandle```python-@class_method_variant("_cls_get_metrics")-async def get_metrics(start: Optional[datetime.datetime] = None,- end: Optional[datetime.datetime] = None,- **opts: Unpack[ApiParams]) -> List[SandboxMetrics]+class AsyncCommandHandle()```-Get the metrics of the current sandbox.+Command execution handle.-**Arguments**:+It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.-- `start`: Start time for the metrics, defaults to the start of the sandbox-- `end`: End time for the metrics, defaults to the current time-**Returns**:+### pid-List of sandbox metrics containing CPU, memory and disk usage information+```python+@property+def pid()+```++Command process ID.-### beta\_create+### stdout```python-@classmethod-async def beta_create(cls,- template: Optional[str] = None,- timeout: Optional[int] = None,- auto_pause: bool = False,- metadata: Optional[Dict[str, str]] = None,- envs: Optional[Dict[str, str]] = None,- secure: bool = True,- allow_internet_access: bool = True,- mcp: Optional[McpServer] = None,- **opts: Unpack[ApiParams]) -> Self+@property+def stdout()```-[BETA] This feature is in beta and may change in the future.+Command stdout output.-Create a new sandbox.-By default, the sandbox is created from the default `base` sandbox template.+### stderr-**Arguments**:+```python+@property+def stderr()+```-- `template`: Sandbox template name or ID-- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. The 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.-- `auto_pause`: Automatically pause the sandbox after the timeout expires. Defaults to `False`.-- `metadata`: Custom metadata for the sandbox-- `envs`: Custom environment variables for the sandbox-- `secure`: Envd is secured with access token and cannot be used without it, defaults to `True`.-- `allow_internet_access`: Allow sandbox to access the internet, defaults to `True`.-- `mcp`: MCP server to enable in the sandbox+Command stderr output.-**Returns**:-A Sandbox instance for the new sandbox-Use this method instead of using the constructor to create a new sandbox.+### error++```python+@property+def error()+```+Command execution error message.-### beta\_pause++### exit\_code```python-@overload-async def beta_pause(**opts: Unpack[ApiParams]) -> None+@property+def exit_code()```-[BETA] This feature is in beta and may change in the future.--Pause the sandbox.+Command execution exit code.-**Returns**:+`0` if the command finished successfully.-Sandbox ID that can be used to resume the sandbox+It is `None` if the command is still running.-### beta\_pause+### disconnect```python-@overload-@staticmethod-async def beta_pause(sandbox_id: str, **opts: Unpack[ApiParams]) -> None+async def disconnect() -> None```-[BETA] This feature is in beta and may change in the future.+Disconnects from the command.-Pause the sandbox specified by sandbox ID.+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**:-- `sandbox_id`: Sandbox ID+### 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**:-Sandbox ID that can be used to resume the sandbox+`CommandResult` result of command execution-### beta\_pause+### kill```python-@class_method_variant("_cls_pause")-async def beta_pause(**opts: Unpack[ApiParams]) -> None+async def kill() -> bool```-[BETA] This feature is in beta and may change in the future.+Kills the command.-Pause the sandbox.+It uses `SIGKILL` signal to kill the command**Returns**:-Sandbox ID that can be used to resume the sandbox+`True` if the command was killed successfully, `False` if the command was not found-### beta\_get\_mcp\_token+++## SandboxApi```python-async def beta_get_mcp_token() -> Optional[str]+class SandboxApi(SandboxBase)```-[BETA] This feature is in beta and may change in the future.-Get the MCP token for the sandbox.+### list-**Returns**:+```python+@staticmethod+def list(query: Optional[SandboxQuery] = None,+ limit: Optional[int] = None,+ next_token: Optional[str] = None,+ **opts: Unpack[ApiParams]) -> AsyncSandboxPaginator+```-MCP token for the sandbox, or None if MCP is not enabled.+List all running sandboxes.+**Arguments**:++- `query`: Filter the list of sandboxes by metadata or state, e.g. `SandboxListQuery(metadata={"key": "value"})` or `SandboxListQuery(state=[SandboxState.RUNNING])`+- `limit`: Maximum number of sandboxes to return per page+- `next_token`: Token for pagination++**Returns**:+List of running sandboxesdiff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/sandbox_sync/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/sandbox_sync/page.mdxindex 3c5d40afe..95550f6b3 100644--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/sandbox_sync/page.mdx+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/sandbox_sync/page.mdx@@ -1,54 +1,82 @@-## SandboxApi+## Sandbox```python-class SandboxApi(SandboxBase)+class Sandbox(SandboxApi)```+E2B cloud sandbox is a secure and isolated cloud environment.-### list+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.create()` to create a new sandbox.++**Example**:```python-@staticmethod-def list(query: Optional[SandboxQuery] = None,- limit: Optional[int] = None,- next_token: Optional[str] = None,- **opts: Unpack[ApiParams]) -> SandboxPaginator+from e2b import Sandbox++sandbox = Sandbox.create()```-List all running sandboxes.-**Arguments**:+### files-- `query`: Filter the list of sandboxes by metadata or state, e.g. `SandboxListQuery(metadata={"key": "value"})` or `SandboxListQuery(state=[SandboxState.RUNNING])`-- `limit`: Maximum number of sandboxes to return per page-- `next_token`: Token for pagination+```python+@property+def files() -> Filesystem+```-**Returns**:+Module for interacting with the sandbox filesystem.-List of running sandboxes+### commands+```python+@property+def commands() -> Commands+```+Module for running commands in the sandbox.-## Commands++### pty```python-class Commands()+@property+def pty() -> Pty```-Module for executing commands in the sandbox.+Module for interacting with the sandbox pseudo-terminal.-### list+### \_\_init\_\_```python-def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]+def __init__(**opts: Unpack[SandboxOpts])```-Lists all running commands and PTY sessions.+:deprecated: This constructor is deprecated++Use `Sandbox.create()` to create a new sandbox instead.+++### is\_running++```python+def is_running(request_timeout: Optional[float] = None) -> bool+```++Check if the sandbox is running.**Arguments**:@@ -56,312 +84,494 @@ Lists all running commands and PTY sessions.**Returns**:-List of running commands and PTY sessions+`True` if the sandbox is running, `False` otherwise+Example+```python+sandbox = Sandbox.create()+sandbox.is_running() # Returns True+sandbox.kill()+sandbox.is_running() # Returns False+```-### kill++### create```python-def kill(pid: int, request_timeout: Optional[float] = None) -> bool+@classmethod+def create(cls,+ template: Optional[str] = None,+ timeout: Optional[int] = None,+ metadata: Optional[Dict[str, str]] = None,+ envs: Optional[Dict[str, str]] = None,+ secure: bool = True,+ allow_internet_access: bool = True,+ **opts: Unpack[ApiParams]) -> Self```-Kills a running command specified by its process ID.+Create a new sandbox.-It uses `SIGKILL` signal to kill the command.+By default, the sandbox is created from the default `base` sandbox template.**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**+- `template`: Sandbox template name or ID+- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. The 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+- `secure`: Envd is secured with access token and cannot be used without it, defaults to `True`.+- `allow_internet_access`: Allow sandbox to access the internet, defaults to `True`.**Returns**:-`True` if the command was killed, `False` if the command was not found+A Sandbox instance for the new sandbox+Use this method instead of using the constructor to create a new sandbox.-### send\_stdin+### connect```python-def send_stdin(pid: int, data: str, request_timeout: Optional[float] = None)+@overload+def connect(timeout: Optional[int] = None, **opts: Unpack[ApiParams]) -> Self```-Send data to command stdin.+Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.-: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**+Sandbox must be either running or be paused.+With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).+**Arguments**:-### run+- `timeout`: Timeout for the sandbox in **seconds**++**Returns**:++A running sandbox instance+@example+```python+sandbox = Sandbox.create()+sandbox.beta_pause()++same_sandbox = sandbox.connect()+++### connect```python@overload-def run(cmd: str,- background: Union[Literal[False], None] = None,- envs: Optional[Dict[str, str]] = None,- user: Optional[Username] = None,- cwd: Optional[str] = None,- on_stdout: Optional[Callable[[str], None]] = None,- on_stderr: Optional[Callable[[str], None]] = None,- stdin: Optional[bool] = None,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None) -> CommandResult+@classmethod+def connect(cls,+ sandbox_id: str,+ timeout: Optional[int] = None,+ **opts: Unpack[ApiParams]) -> Self```-Start a new command and wait until it finishes executing.+Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.++Sandbox must be either running or be paused.++With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).**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-- `stdin`: If `True`, the command will have a stdin stream that you can send data to using `sandbox.commands.send_stdin()`-- `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**+- `sandbox_id`: Sandbox ID+- `timeout`: Timeout for the sandbox in **seconds****Returns**:-`CommandResult` result of the command execution+A running sandbox instance+@example+```python+sandbox = Sandbox.create()+Sandbox.beta_pause(sandbox.sandbox_id)+same_sandbox = Sandbox.connect(sandbox.sandbox_id)+```-### run++### connect```python-@overload-def run(cmd: str,- background: Literal[True],- envs: Optional[Dict[str, str]] = None,- user: Optional[Username] = None,- cwd: Optional[str] = None,- on_stdout: None = None,- on_stderr: None = None,- stdin: Optional[bool] = None,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None) -> CommandHandle+@class_method_variant("_cls_connect")+def connect(timeout: Optional[int] = None, **opts: Unpack[ApiParams]) -> Self```-Start a new command and return a handle to interact with it.+Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.++Sandbox must be either running or be paused.++With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).**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-- `stdin`: If `True`, the command will have a stdin stream that you can send data to using `sandbox.commands.send_stdin()`-- `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**+- `timeout`: Timeout for the sandbox in **seconds****Returns**:-`CommandHandle` handle to interact with the running command+A running sandbox instance+@example+```python+sandbox = Sandbox.create()+sandbox.beta_pause()+same_sandbox = sandbox.connect()+```-### connect++### kill```python-def connect(pid: int,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None)+@overload+def kill(**opts: Unpack[ApiParams]) -> bool```-Connects to a running command.+Kill the sandbox.-You can use `CommandHandle.wait()` to wait for the command to finish and get execution results.+**Returns**:++`True` if the sandbox was killed, `False` if the sandbox was not found+++### kill++```python+@overload+@staticmethod+def kill(sandbox_id: str, **opts: Unpack[ApiParams]) -> bool+```++Kill the sandbox specified by sandbox ID.**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**Returns**:-`CommandHandle` handle to interact with the running command+`True` if the sandbox was killed, `False` if the sandbox was not found+### kill++```python+@class_method_variant("_cls_kill")+def kill(**opts: Unpack[ApiParams]) -> bool+```+Kill the sandbox specified by sandbox ID.++**Returns**:++`True` if the sandbox was killed, `False` if the sandbox was not found-## CommandHandle++### set\_timeout```python-class CommandHandle()+@overload+def set_timeout(timeout: int, **opts: Unpack[ApiParams]) -> None```-Command execution handle.+Set the timeout of the sandbox.-It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing 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`.+The 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**:++- `timeout`: Timeout for the sandbox in **seconds**-### pid++### set\_timeout```python-@property-def pid()+@overload+@staticmethod+def set_timeout(sandbox_id: str, timeout: int,+ **opts: Unpack[ApiParams]) -> None```-Command process ID.+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`.+The 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.-### \_\_iter\_\_+**Arguments**:++- `sandbox_id`: Sandbox ID+- `timeout`: Timeout for the sandbox in **seconds**+++### set\_timeout```python-def __iter__()+@class_method_variant("_cls_set_timeout")+def set_timeout(timeout: int, **opts: Unpack[ApiParams]) -> None```-Iterate over the command output.+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`.++The 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**:++- `timeout`: Timeout for the sandbox in **seconds**+++### get\_info++```python+@overload+def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo+```++Get sandbox information like sandbox ID, template, metadata, started at/end at date.**Returns**:-Generator of command outputs+Sandbox info-### disconnect+### get\_info```python-def disconnect() -> None+@overload+@staticmethod+def get_info(sandbox_id: str, **opts: Unpack[ApiParams]) -> SandboxInfo```-Disconnect from the command.+Get sandbox information like sandbox ID, template, metadata, started at/end at date.-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**:+- `sandbox_id`: Sandbox ID++**Returns**:++Sandbox info-### wait++### get\_info```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+@class_method_variant("_cls_get_info")+def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo```-Wait for the command to finish and returns the result.+Get sandbox information like sandbox ID, template, metadata, started at/end at date.-If the command exits with a non-zero exit code, it throws a `CommandExitException`.+**Returns**:++Sandbox info+++### get\_metrics++```python+@overload+def get_metrics(start: Optional[datetime.datetime] = None,+ end: Optional[datetime.datetime] = None,+ **opts: Unpack[ApiParams]) -> List[SandboxMetrics]+```++Get the metrics of the current sandbox.**Arguments**:-- `on_pty`: Callback for pty output-- `on_stdout`: Callback for stdout output-- `on_stderr`: Callback for stderr output+- `start`: Start time for the metrics, defaults to the start of the sandbox+- `end`: End time for the metrics, defaults to the current time**Returns**:-`CommandResult` result of command execution+List of sandbox metrics containing CPU, memory and disk usage information-### kill+### get\_metrics```python-def kill() -> bool+@overload+@staticmethod+def get_metrics(sandbox_id: str,+ start: Optional[datetime.datetime] = None,+ end: Optional[datetime.datetime] = None,+ **opts: Unpack[ApiParams]) -> List[SandboxMetrics]```-Kills the command.+Get the metrics of the sandbox specified by sandbox ID.-It uses `SIGKILL` signal to kill the command.+**Arguments**:++- `sandbox_id`: Sandbox ID+- `start`: Start time for the metrics, defaults to the start of the sandbox+- `end`: End time for the metrics, defaults to the current time**Returns**:-Whether the command was killed successfully+List of sandbox metrics containing CPU, memory and disk usage information+### get\_metrics+```python+@class_method_variant("_cls_get_metrics")+def get_metrics(start: Optional[datetime.datetime] = None,+ end: Optional[datetime.datetime] = None,+ **opts: Unpack[ApiParams]) -> List[SandboxMetrics]+```-## Pty+Get the metrics of the sandbox specified by sandbox ID.++**Arguments**:++- `start`: Start time for the metrics, defaults to the start of the sandbox+- `end`: End time for the metrics, defaults to the current time++**Returns**:++List of sandbox metrics containing CPU, memory and disk usage information+++### beta\_create```python-class Pty()+@classmethod+def beta_create(cls,+ template: Optional[str] = None,+ timeout: Optional[int] = None,+ auto_pause: bool = False,+ metadata: Optional[Dict[str, str]] = None,+ envs: Optional[Dict[str, str]] = None,+ secure: bool = True,+ allow_internet_access: bool = True,+ mcp: Optional[McpServer] = None,+ **opts: Unpack[ApiParams]) -> Self```-Module for interacting with PTYs (pseudo-terminals) in the sandbox.+[BETA] This feature is in beta and may change in the future.+Create a new sandbox.-### kill+By default, the sandbox is created from the default `base` sandbox template.++**Arguments**:++- `template`: Sandbox template name or ID+- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. The 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.+- `auto_pause`: Automatically pause the sandbox after the timeout expires. Defaults to `False`.+- `metadata`: Custom metadata for the sandbox+- `envs`: Custom environment variables for the sandbox+- `secure`: Envd is secured with access token and cannot be used without it, defaults to `True`.+- `allow_internet_access`: Allow sandbox to access the internet, defaults to `True`.+- `mcp`: MCP server to enable in the sandbox++**Returns**:++A Sandbox instance for the new sandbox+Use this method instead of using the constructor to create a new sandbox.+++### beta\_pause```python-def kill(pid: int, request_timeout: Optional[float] = None) -> bool+@overload+def beta_pause(**opts: Unpack[ApiParams]) -> None```-Kill PTY.+[BETA] This feature is in beta and may change in the future.++Pause the sandbox.+++### beta\_pause++```python+@overload+@classmethod+def beta_pause(cls, sandbox_id: str, **opts: Unpack[ApiParams]) -> None+```++[BETA] This feature is in beta and may change in the future.++Pause the sandbox specified by sandbox ID.**Arguments**:-- `pid`: Process ID of the PTY-- `request_timeout`: Timeout for the request in **seconds**+- `sandbox_id`: Sandbox ID+++### beta\_pause++```python+@class_method_variant("_cls_pause")+def beta_pause(**opts: Unpack[ApiParams]) -> None+```++[BETA] This feature is in beta and may change in the future.++Pause the sandbox.**Returns**:-`true` if the PTY was killed, `false` if the PTY was not found+Sandbox ID that can be used to resume the sandbox-### send\_stdin+### beta\_get\_mcp\_token```python-def send_stdin(pid: int,- data: bytes,- request_timeout: Optional[float] = None) -> None+def beta_get_mcp_token() -> Optional[str]```-Send input to a PTY.+[BETA] This feature is in beta and may change in the future.++Get the MCP token for the sandbox.-**Arguments**:+**Returns**:-- `pid`: Process ID of the PTY-- `data`: Input data to send-- `request_timeout`: Timeout for the request in **seconds**+MCP token for the sandbox, or None if MCP is not enabled.-### create+++## SandboxPaginator```python-def create(size: PtySize,- user: Optional[Username] = None,- cwd: Optional[str] = None,- envs: Optional[Dict[str, str]] = None,- timeout: Optional[float] = 60,- request_timeout: Optional[float] = None) -> CommandHandle+class SandboxPaginator(SandboxPaginatorBase)```-Start a new PTY (pseudo-terminal).--**Arguments**:+Paginator for listing sandboxes.-- `size`: Size of the PTY-- `user`: User to use for the PTY-- `cwd`: Working directory for the PTY-- `envs`: Environment variables for the PTY-- `timeout`: Timeout for the PTY in **seconds**-- `request_timeout`: Timeout for the request in **seconds**+**Example**:-**Returns**:+```python+paginator = Sandbox.list()-Handle to interact with the PTY+while paginator.has_next:+ sandboxes = paginator.next_items()+ print(sandboxes)+```-### resize+### next\_items```python-def resize(pid: int,- size: PtySize,- request_timeout: Optional[float] = None) -> None+def next_items() -> List[SandboxInfo]```-Resize PTY.+Returns the next page of sandboxes.-Call this when the terminal window is resized and the number of columns and rows has changed.+Call this method only if `has_next` is `True`, otherwise it will raise an exception.-**Arguments**:+**Returns**:-- `pid`: Process ID of the PTY-- `size`: New size of the PTY-- `request_timeout`: Timeout for the request in **seconds**s+List of sandboxes@@ -556,706 +766,496 @@ List entries in a directory.**Returns**:-List of entries in the directory---### exists--```python-def exists(path: str,- user: Optional[Username] = None,- request_timeout: Optional[float] = None) -> bool-```--Check if a file or a directory exists.--**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 file or directory exists, `False` otherwise---### get\_info--```python-def get_info(path: str,- user: Optional[Username] = None,- request_timeout: Optional[float] = None) -> EntryInfo-```--Get information about a file or 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**:--Information about the file or directory like name, type, and path---### remove--```python-def remove(path: str,- user: Optional[Username] = None,- request_timeout: Optional[float] = None) -> None-```--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**---### rename--```python-def rename(old_path: str,- new_path: str,- user: Optional[Username] = None,- request_timeout: Optional[float] = None) -> EntryInfo-```--Rename a file or directory.--**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**--**Returns**:--Information about the renamed file or directory---### make\_dir--```python-def make_dir(path: str,- user: Optional[Username] = None,- request_timeout: Optional[float] = None) -> bool-```--Create a new directory and all directories along the way if needed on the specified path.--**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**--**Returns**:--`True` if the directory was created, `False` if the directory already exists---### watch\_dir--```python-def watch_dir(path: str,- user: Optional[Username] = None,- request_timeout: Optional[float] = None,- recursive: bool = False) -> WatchHandle-```--Watch directory for filesystem events.--**Arguments**:--- `path`: Path to a directory to watch-- `user`: Run the operation as this user-- `request_timeout`: Timeout for the request in **seconds**-- `recursive`: Watch directory recursively--**Returns**:--`WatchHandle` object for stopping watching directory-----## SandboxPaginator--```python-class SandboxPaginator(SandboxPaginatorBase)-```--Paginator for listing sandboxes.--**Example**:--```python-paginator = Sandbox.list()--while paginator.has_next:- sandboxes = paginator.next_items()- print(sandboxes)-```---### next\_items--```python-def next_items() -> List[SandboxInfo]-```--Returns the next page of sandboxes.--Call this method only if `has_next` is `True`, otherwise it will raise an exception.--**Returns**:--List of sandboxes-----## Sandbox--```python-class Sandbox(SandboxApi)-```--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.create()` to create a new sandbox.--**Example**:--```python-from e2b import Sandbox--sandbox = Sandbox.create()-```---### files--```python-@property-def files() -> Filesystem-```--Module for interacting with the sandbox filesystem.+List of entries in the directory-### commands+### exists```python-@property-def commands() -> Commands+def exists(path: str,+ user: Optional[Username] = None,+ request_timeout: Optional[float] = None) -> bool```-Module for running commands in the sandbox.+Check if a file or a directory exists.+**Arguments**:-### pty+- `path`: Path to a file or a directory+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request in **seconds**-```python-@property-def pty() -> Pty-```+**Returns**:-Module for interacting with the sandbox pseudo-terminal.+`True` if the file or directory exists, `False` otherwise-### \_\_init\_\_+### get\_info```python-def __init__(**opts: Unpack[SandboxOpts])+def get_info(path: str,+ user: Optional[Username] = None,+ request_timeout: Optional[float] = None) -> EntryInfo```-:deprecated: This constructor is deprecated+Get information about a file or directory.-Use `Sandbox.create()` to create a new sandbox instead.+**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**:-### is\_running+Information about the file or directory like name, type, and path+++### remove```python-def is_running(request_timeout: Optional[float] = None) -> bool+def remove(path: str,+ user: Optional[Username] = None,+ request_timeout: Optional[float] = None) -> None```-Check if the sandbox is running.+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 is running, `False` otherwise-Example-```python-sandbox = Sandbox.create()-sandbox.is_running() # Returns True--sandbox.kill()-sandbox.is_running() # Returns False-```--### create+### rename```python-@classmethod-def create(cls,- template: Optional[str] = None,- timeout: Optional[int] = None,- metadata: Optional[Dict[str, str]] = None,- envs: Optional[Dict[str, str]] = None,- secure: bool = True,- allow_internet_access: bool = True,- **opts: Unpack[ApiParams]) -> Self+def rename(old_path: str,+ new_path: str,+ user: Optional[Username] = None,+ request_timeout: Optional[float] = None) -> EntryInfo```-Create a new sandbox.--By default, the sandbox is created from the default `base` sandbox template.+Rename a file or directory.**Arguments**:-- `template`: Sandbox template name or ID-- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. The 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-- `secure`: Envd is secured with access token and cannot be used without it, defaults to `True`.-- `allow_internet_access`: Allow sandbox to access the internet, defaults to `True`.+- `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**:-A Sandbox instance for the new sandbox-Use this method instead of using the constructor to create a new sandbox.+Information about the renamed file or directory-### connect+### make\_dir```python-@overload-def connect(timeout: Optional[int] = None, **opts: Unpack[ApiParams]) -> Self+def make_dir(path: str,+ user: Optional[Username] = None,+ request_timeout: Optional[float] = None) -> bool```-Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.--Sandbox must be either running or be paused.--With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).+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**:-A running sandbox instance-@example-```python-sandbox = Sandbox.create()-sandbox.beta_pause()--same_sandbox = sandbox.connect()+`True` if the directory was created, `False` if the directory already exists-### connect+### watch\_dir```python-@overload-@classmethod-def connect(cls,- sandbox_id: str,- timeout: Optional[int] = None,- **opts: Unpack[ApiParams]) -> Self+def watch_dir(path: str,+ user: Optional[Username] = None,+ request_timeout: Optional[float] = None,+ recursive: bool = False) -> WatchHandle```-Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.--Sandbox must be either running or be paused.--With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).+Watch directory for filesystem events.**Arguments**:-- `sandbox_id`: Sandbox ID-- `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**+- `recursive`: Watch directory recursively**Returns**:-A running sandbox instance-@example-```python-sandbox = Sandbox.create()-Sandbox.beta_pause(sandbox.sandbox_id)+`WatchHandle` object for stopping watching directory-same_sandbox = Sandbox.connect(sandbox.sandbox_id)-```-### connect++## Commands```python-@class_method_variant("_cls_connect")-def connect(timeout: Optional[int] = None, **opts: Unpack[ApiParams]) -> Self+class Commands()```-Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.--Sandbox must be either running or be paused.--With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).--**Arguments**:+Module for executing commands in the sandbox.-- `timeout`: Timeout for the sandbox in **seconds**-**Returns**:+### list-A running sandbox instance-@example```python-sandbox = Sandbox.create()-sandbox.beta_pause()--same_sandbox = sandbox.connect()+def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]```+Lists all running commands and PTY sessions.-### kill--```python-@overload-def kill(**opts: Unpack[ApiParams]) -> bool-```+**Arguments**:-Kill the sandbox.+- `request_timeout`: Timeout for the request in **seconds****Returns**:-`True` if the sandbox was killed, `False` if the sandbox was not found+List of running commands and PTY sessions### kill```python-@overload-@staticmethod-def kill(sandbox_id: str, **opts: Unpack[ApiParams]) -> bool+def kill(pid: int, request_timeout: Optional[float] = None) -> bool```-Kill the sandbox specified by sandbox ID.+Kills a running command specified by its process ID.++It uses `SIGKILL` signal to kill the command.**Arguments**:-- `sandbox_id`: Sandbox ID+- `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**:-`True` if the sandbox was killed, `False` if the sandbox was not found+`True` if the command was killed, `False` if the command was not found-### kill+### send\_stdin```python-@class_method_variant("_cls_kill")-def kill(**opts: Unpack[ApiParams]) -> bool+def send_stdin(pid: int, data: str, request_timeout: Optional[float] = None)```-Kill the sandbox specified by sandbox ID.+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**-`True` if the sandbox was killed, `False` if the sandbox was not found-### set\_timeout+### run```python@overload-def set_timeout(timeout: int, **opts: Unpack[ApiParams]) -> None+def run(cmd: str,+ background: Union[Literal[False], None] = None,+ envs: Optional[Dict[str, str]] = None,+ user: Optional[Username] = None,+ cwd: Optional[str] = None,+ on_stdout: Optional[Callable[[str], None]] = None,+ on_stderr: Optional[Callable[[str], None]] = None,+ stdin: Optional[bool] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> CommandResult```-Set the timeout of the sandbox.+Start a new command and wait until it finishes executing.-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`.+**Arguments**:-The 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.+- `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+- `stdin`: If `True`, the command will have a stdin stream that you can send data to using `sandbox.commands.send_stdin()`+- `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**-**Arguments**:+**Returns**:-- `timeout`: Timeout for the sandbox in **seconds**+`CommandResult` result of the command execution-### set\_timeout+### run```python@overload-@staticmethod-def set_timeout(sandbox_id: str, timeout: int,- **opts: Unpack[ApiParams]) -> None+def run(cmd: str,+ background: Literal[True],+ envs: Optional[Dict[str, str]] = None,+ user: Optional[Username] = None,+ cwd: Optional[str] = None,+ on_stdout: None = None,+ on_stderr: None = None,+ stdin: Optional[bool] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> CommandHandle```-Set the timeout of the sandbox specified by sandbox ID.+Start a new command and return a handle to interact with it.-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`.+**Arguments**:-The 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.+- `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+- `stdin`: If `True`, the command will have a stdin stream that you can send data to using `sandbox.commands.send_stdin()`+- `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**-**Arguments**:+**Returns**:-- `sandbox_id`: Sandbox ID-- `timeout`: Timeout for the sandbox in **seconds**+`CommandHandle` handle to interact with the running command-### set\_timeout+### connect```python-@class_method_variant("_cls_set_timeout")-def set_timeout(timeout: int, **opts: Unpack[ApiParams]) -> None+def connect(pid: int,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = 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`.+Connects to a running command.-The 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.+You can use `CommandHandle.wait()` to wait for the command to finish and get execution results.**Arguments**:-- `timeout`: Timeout for the sandbox in **seconds**+- `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**:-### get\_info+`CommandHandle` handle to interact with the running command-```python-@overload-def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo-```-Get sandbox information like sandbox ID, template, metadata, started at/end at date.-**Returns**:-Sandbox info+## Pty++```python+class Pty()+```++Module for interacting with PTYs (pseudo-terminals) in the sandbox.-### get\_info+### kill```python-@overload-@staticmethod-def get_info(sandbox_id: str, **opts: Unpack[ApiParams]) -> SandboxInfo+def kill(pid: int, request_timeout: Optional[float] = None) -> bool```-Get sandbox information like sandbox ID, template, metadata, started at/end at date.+Kill PTY.**Arguments**:-- `sandbox_id`: Sandbox ID+- `pid`: Process ID of the PTY+- `request_timeout`: Timeout for the request in **seconds****Returns**:-Sandbox info+`true` if the PTY was killed, `false` if the PTY was not found-### get\_info+### send\_stdin```python-@class_method_variant("_cls_get_info")-def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo+def send_stdin(pid: int,+ data: bytes,+ request_timeout: Optional[float] = None) -> None```-Get sandbox information like sandbox ID, template, metadata, started at/end at date.+Send input to a PTY.-**Returns**:+**Arguments**:-Sandbox info+- `pid`: Process ID of the PTY+- `data`: Input data to send+- `request_timeout`: Timeout for the request in **seconds**-### get\_metrics+### create```python-@overload-def get_metrics(start: Optional[datetime.datetime] = None,- end: Optional[datetime.datetime] = None,- **opts: Unpack[ApiParams]) -> List[SandboxMetrics]+def create(size: PtySize,+ user: Optional[Username] = None,+ cwd: Optional[str] = None,+ envs: Optional[Dict[str, str]] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> CommandHandle```-Get the metrics of the current sandbox.+Start a new PTY (pseudo-terminal).**Arguments**:-- `start`: Start time for the metrics, defaults to the start of the sandbox-- `end`: End time for the metrics, defaults to the current time+- `size`: Size of the PTY+- `user`: User to use for the PTY+- `cwd`: Working directory for the PTY+- `envs`: Environment variables for the PTY+- `timeout`: Timeout for the PTY in **seconds**+- `request_timeout`: Timeout for the request in **seconds****Returns**:-List of sandbox metrics containing CPU, memory and disk usage information+Handle to interact with the PTY-### get\_metrics+### resize```python-@overload-@staticmethod-def get_metrics(sandbox_id: str,- start: Optional[datetime.datetime] = None,- end: Optional[datetime.datetime] = None,- **opts: Unpack[ApiParams]) -> List[SandboxMetrics]+def resize(pid: int,+ size: PtySize,+ request_timeout: Optional[float] = None) -> None```-Get the metrics of the sandbox specified by sandbox ID.+Resize PTY.++Call this when the terminal window is resized and the number of columns and rows has changed.**Arguments**:-- `sandbox_id`: Sandbox ID-- `start`: Start time for the metrics, defaults to the start of the sandbox-- `end`: End time for the metrics, defaults to the current time+- `pid`: Process ID of the PTY+- `size`: New size of the PTY+- `request_timeout`: Timeout for the request in **seconds**s-**Returns**:-List of sandbox metrics containing CPU, memory and disk usage information-### get\_metrics+## CommandHandle```python-@class_method_variant("_cls_get_metrics")-def get_metrics(start: Optional[datetime.datetime] = None,- end: Optional[datetime.datetime] = None,- **opts: Unpack[ApiParams]) -> List[SandboxMetrics]+class CommandHandle()```-Get the metrics of the sandbox specified by sandbox ID.--**Arguments**:--- `start`: Start time for the metrics, defaults to the start of the sandbox-- `end`: End time for the metrics, defaults to the current time--**Returns**:+Command execution handle.-List of sandbox metrics containing CPU, memory and disk usage information+It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.-### beta\_create+### pid```python-@classmethod-def beta_create(cls,- template: Optional[str] = None,- timeout: Optional[int] = None,- auto_pause: bool = False,- metadata: Optional[Dict[str, str]] = None,- envs: Optional[Dict[str, str]] = None,- secure: bool = True,- allow_internet_access: bool = True,- mcp: Optional[McpServer] = None,- **opts: Unpack[ApiParams]) -> Self+@property+def pid()```-[BETA] This feature is in beta and may change in the future.+Command process ID.-Create a new sandbox.-By default, the sandbox is created from the default `base` sandbox template.+### \_\_iter\_\_-**Arguments**:+```python+def __iter__()+```-- `template`: Sandbox template name or ID-- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. The 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.-- `auto_pause`: Automatically pause the sandbox after the timeout expires. Defaults to `False`.-- `metadata`: Custom metadata for the sandbox-- `envs`: Custom environment variables for the sandbox-- `secure`: Envd is secured with access token and cannot be used without it, defaults to `True`.-- `allow_internet_access`: Allow sandbox to access the internet, defaults to `True`.-- `mcp`: MCP server to enable in the sandbox+Iterate over the command output.**Returns**:-A Sandbox instance for the new sandbox-Use this method instead of using the constructor to create a new sandbox.+Generator of command outputs-### beta\_pause+### disconnect```python-@overload-def beta_pause(**opts: Unpack[ApiParams]) -> None+def disconnect() -> None```-[BETA] This feature is in beta and may change in the future.+Disconnect from the command.-Pause 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.-### beta\_pause+### wait```python-@overload-@classmethod-def beta_pause(cls, sandbox_id: str, **opts: Unpack[ApiParams]) -> None+def wait(on_pty: Optional[Callable[[PtyOutput], None]] = None,+ on_stdout: Optional[Callable[[str], None]] = None,+ on_stderr: Optional[Callable[[str], None]] = None) -> CommandResult```-[BETA] This feature is in beta and may change in the future.+Wait for the command to finish and returns the result.-Pause the sandbox specified by sandbox ID.+If the command exits with a non-zero exit code, it throws a `CommandExitException`.**Arguments**:-- `sandbox_id`: Sandbox ID+- `on_pty`: Callback for pty output+- `on_stdout`: Callback for stdout output+- `on_stderr`: Callback for stderr output+**Returns**:-### beta\_pause+`CommandResult` result of command execution+++### kill```python-@class_method_variant("_cls_pause")-def beta_pause(**opts: Unpack[ApiParams]) -> None+def kill() -> bool```-[BETA] This feature is in beta and may change in the future.+Kills the command.-Pause the sandbox.+It uses `SIGKILL` signal to kill the command.**Returns**:-Sandbox ID that can be used to resume the sandbox+Whether the command was killed successfully-### beta\_get\_mcp\_token+++## SandboxApi```python-def beta_get_mcp_token() -> Optional[str]+class SandboxApi(SandboxBase)```-[BETA] This feature is in beta and may change in the future.-Get the MCP token for the sandbox.+### list++```python+@staticmethod+def list(query: Optional[SandboxQuery] = None,+ limit: Optional[int] = None,+ next_token: Optional[str] = None,+ **opts: Unpack[ApiParams]) -> SandboxPaginator+```++List all running sandboxes.++**Arguments**:++- `query`: Filter the list of sandboxes by metadata or state, e.g. `SandboxListQuery(metadata={"key": "value"})` or `SandboxListQuery(state=[SandboxState.RUNNING])`+- `limit`: Maximum number of sandboxes to return per page+- `next_token`: Token for pagination**Returns**:-MCP token for the sandbox, or None if MCP is not enabled.+List of running sandboxesdiff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template/page.mdxindex e644c4331..32e83abef 100644--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template/page.mdx+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template/page.mdx@@ -1,162 +1,5 @@--## ReadyCmd--```python-class ReadyCmd()-```--Wrapper class for ready check commands.---### wait\_for\_port--```python-def wait_for_port(port: int)-```--Wait for a port to be listening.--Uses `ss` command to check if a port is open and listening.--**Arguments**:--- `port`: Port number to wait for--**Returns**:--ReadyCmd that checks for the port-Example-```python-from e2b import Template, wait_for_port--template = (- Template()- .from_python_image()- .set_start_cmd('python -m http.server 8000', wait_for_port(8000))-)-```---### wait\_for\_url--```python-def wait_for_url(url: str, status_code: int = 200)-```--Wait for a URL to return a specific HTTP status code.--Uses `curl` to make HTTP requests and check the response status.--**Arguments**:--- `url`: URL to check (e.g., 'http://localhost:3000/health')-- `status_code`: Expected HTTP status code (default: 200)--**Returns**:--ReadyCmd that checks the URL-Example-```python-from e2b import Template, wait_for_url--template = (- Template()- .from_node_image()- .set_start_cmd('npm start', wait_for_url('http://localhost:3000/health'))-)-```---### wait\_for\_process--```python-def wait_for_process(process_name: str)-```--Wait for a process with a specific name to be running.--Uses `pgrep` to check if a process exists.--**Arguments**:--- `process_name`: Name of the process to wait for--**Returns**:--ReadyCmd that checks for the process-Example-```python-from e2b import Template, wait_for_process--template = (- Template()- .from_base_image()- .set_start_cmd('./my-daemon', wait_for_process('my-daemon'))-)-```---### wait\_for\_file--```python-def wait_for_file(filename: str)-```--Wait for a file to exist.--Uses shell test command to check file existence.--**Arguments**:--- `filename`: Path to the file to wait for--**Returns**:--ReadyCmd that checks for the file-Example-```python-from e2b import Template, wait_for_file--template = (- Template()- .from_base_image()- .set_start_cmd('./init.sh', wait_for_file('/tmp/ready'))-)-```---### wait\_for\_timeout--```python-def wait_for_timeout(timeout: int)-```--Wait for a specified timeout before considering the sandbox ready.--Uses `sleep` command to wait for a fixed duration.--**Arguments**:--- `timeout`: Time to wait in **milliseconds** (minimum: 1000ms / 1 second)--**Returns**:--ReadyCmd that waits for the specified duration-Example-```python-from e2b import Template, wait_for_timeout--template = (- Template()- .from_node_image()- .set_start_cmd('npm start', wait_for_timeout(5000)) # Wait 5 seconds-)-```---Special step name for the finalization phase of template building.This is the last step that runs after all user-defined instructions.@@ -164,194 +7,25 @@ This is the last step that runs after all user-defined instructions.### FINALIZE\_STEP\_NAMESpecial step name for the base image phase of template building.-This is the first step that sets up the base image.---### BASE\_STEP\_NAME--Stack trace depth for capturing caller information.--Depth levels:-1. TemplateClass-2. Caller method (e.g., copy(), from_image(), etc.)--This depth is used to determine the original caller's location-for stack traces.---### STACK\_TRACE\_DEPTH--Default setting for whether to resolve symbolic links when copying files.-When False, symlinks are copied as symlinks rather than following them.-----## InstructionType--```python-class InstructionType(str, Enum)-```--Types of instructions that can be used in a template.---## CopyItem--```python-class CopyItem(TypedDict)-```--Configuration for a single file/directory copy operation.---## Instruction--```python-class Instruction(TypedDict)-```--Represents a single instruction in the template build process.---## GenericDockerRegistry--```python-class GenericDockerRegistry(TypedDict)-```--Configuration for a generic Docker registry with basic authentication.---## AWSRegistry--```python-class AWSRegistry(TypedDict)-```--Configuration for AWS Elastic Container Registry (ECR).---## GCPRegistry--```python-class GCPRegistry(TypedDict)-```--Configuration for Google Container Registry (GCR) or Artifact Registry.---## TemplateType--```python-class TemplateType(TypedDict)-```--Internal representation of a template for the E2B build API.-----## DockerfFileFinalParserInterface--```python-class DockerfFileFinalParserInterface(Protocol)-```--Protocol defining the final interface for Dockerfile parsing callbacks.---## DockerfileParserInterface--```python-class DockerfileParserInterface(Protocol)-```--Protocol defining the interface for Dockerfile parsing callbacks.---### run\_cmd--```python-def run_cmd(command: Union[str, List[str]],- user: Optional[str] = None) -> "DockerfileParserInterface"-```--Handle RUN instruction.---### copy--```python-def copy(src: Union[str, List[CopyItem]],- dest: Optional[str] = None,- force_upload: Optional[Literal[True]] = None,- resolve_symlinks: Optional[bool] = None,- user: Optional[str] = None,- mode: Optional[int] = None) -> "DockerfileParserInterface"-```--Handle COPY instruction.---### set\_workdir--```python-def set_workdir(workdir: str) -> "DockerfileParserInterface"-```--Handle WORKDIR instruction.---### set\_user--```python-def set_user(user: str) -> "DockerfileParserInterface"-```--Handle USER instruction.---### set\_envs--```python-def set_envs(envs: Dict[str, str]) -> "DockerfileParserInterface"-```--Handle ENV instruction.---### set\_start\_cmd--```python-def set_start_cmd(start_cmd: str,- ready_cmd: str) -> "DockerfFileFinalParserInterface"-```--Handle CMD/ENTRYPOINT instruction.---### parse\_dockerfile--```python-def parse_dockerfile(dockerfile_content_or_path: str,- template_builder: DockerfileParserInterface) -> str-```+This is the first step that sets up the base image.-Parse a Dockerfile and convert it to Template SDK format.-**Arguments**:+### BASE\_STEP\_NAME-- `dockerfile_content_or_path`: Either the Dockerfile content as a string, or a path to a Dockerfile file-- `template_builder`: Interface providing template builder methods+Stack trace depth for capturing caller information.-**Raises**:+Depth levels:+1. TemplateClass+2. Caller method (e.g., copy(), from_image(), etc.)-- `ValueError`: If the Dockerfile is invalid or unsupported+This depth is used to determine the original caller's location+for stack traces.-**Returns**:-The base image from the Dockerfile+### STACK\_TRACE\_DEPTH++Default setting for whether to resolve symbolic links when copying files.+When False, symlinks are copied as symlinks rather than following them.@@ -931,199 +605,460 @@ Template().from_node_image('24')```-### from\_base\_image+### from\_base\_image++```python+def from_base_image() -> TemplateBuilder+```++Start template from the E2B base image (e2bdev/base:latest).++**Returns**:++`TemplateBuilder` class+Example+```python+Template().from_base_image()+```+++### from\_image++```python+def from_image(image: str,+ username: Optional[str] = None,+ password: Optional[str] = None) -> TemplateBuilder+```++Start template from a Docker image.++**Arguments**:++- `image`: Docker image name (e.g., 'ubuntu:24.04')+- `username`: Username for private registry authentication+- `password`: Password for private registry authentication++**Returns**:++`TemplateBuilder` class+Example+```python+Template().from_image('python:3')++Template().from_image('myregistry.com/myimage:latest', username='user', password='pass')+```+++### from\_template++```python+def from_template(template: str) -> TemplateBuilder+```++Start template from an existing E2B template.++**Arguments**:++- `template`: E2B template ID or alias++**Returns**:++`TemplateBuilder` class+Example+```python+Template().from_template('my-base-template')+```+++### from\_dockerfile++```python+def from_dockerfile(dockerfile_content_or_path: str) -> TemplateBuilder+```++Parse a Dockerfile and convert it to Template SDK format.++**Arguments**:++- `dockerfile_content_or_path`: Either the Dockerfile content as a string, or a path to a Dockerfile file++**Returns**:++`TemplateBuilder` class+Example+```python+Template().from_dockerfile('Dockerfile')+Template().from_dockerfile('FROM python:3\nRUN pip install numpy')+```+++### from\_aws\_registry++```python+def from_aws_registry(image: str, access_key_id: str, secret_access_key: str,+ region: str) -> TemplateBuilder+```++Start template from an AWS ECR registry image.++**Arguments**:++- `image`: Docker image name from AWS ECR+- `access_key_id`: AWS access key ID+- `secret_access_key`: AWS secret access key+- `region`: AWS region++**Returns**:++`TemplateBuilder` class+Example+```python+Template().from_aws_registry(+ '123456789.dkr.ecr.us-west-2.amazonaws.com/myimage:latest',+ access_key_id='AKIA...',+ secret_access_key='...',+ region='us-west-2'+)+```+++### from\_gcp\_registry++```python+def from_gcp_registry(+ image: str, service_account_json: Union[str, dict]) -> TemplateBuilder+```++Start template from a GCP Artifact Registry or Container Registry image.++**Arguments**:++- `image`: Docker image name from GCP registry+- `service_account_json`: Service account JSON string, dict, or path to JSON file++**Returns**:++`TemplateBuilder` class+Example+```python+Template().from_gcp_registry(+ 'gcr.io/myproject/myimage:latest',+ service_account_json='path/to/service-account.json'+)+```+++### to\_json++```python+@staticmethod+def to_json(template: "TemplateClass") -> str+```++Convert a template to JSON representation.++**Arguments**:++- `template`: The template to convert (TemplateBuilder or TemplateFinal instance)++**Returns**:++JSON string representation of the template+Example+```python+template = Template().from_python_image('3').copy('app.py', '/app/')+json_str = TemplateBase.to_json(template)+```+++### to\_dockerfile++```python+@staticmethod+def to_dockerfile(template: "TemplateClass") -> str+```++Convert a template to Dockerfile format.++Note: Templates based on other E2B templates cannot be converted to Dockerfile.++**Arguments**:++- `template`: The template to convert (TemplateBuilder or TemplateFinal instance)++**Raises**:++- `ValueError`: If the template is based on another E2B template or has no base image+Example+```python+template = Template().from_python_image('3').copy('app.py', '/app/')+dockerfile = TemplateBase.to_dockerfile(template)+```++**Returns**:++Dockerfile string representation+++++## DockerfFileFinalParserInterface++```python+class DockerfFileFinalParserInterface(Protocol)+```++Protocol defining the final interface for Dockerfile parsing callbacks.+++## DockerfileParserInterface++```python+class DockerfileParserInterface(Protocol)+```++Protocol defining the interface for Dockerfile parsing callbacks.+++### run\_cmd++```python+def run_cmd(command: Union[str, List[str]],+ user: Optional[str] = None) -> "DockerfileParserInterface"+```++Handle RUN instruction.+++### copy++```python+def copy(src: Union[str, List[CopyItem]],+ dest: Optional[str] = None,+ force_upload: Optional[Literal[True]] = None,+ resolve_symlinks: Optional[bool] = None,+ user: Optional[str] = None,+ mode: Optional[int] = None) -> "DockerfileParserInterface"+```++Handle COPY instruction.+++### set\_workdir```python-def from_base_image() -> TemplateBuilder+def set_workdir(workdir: str) -> "DockerfileParserInterface"```-Start template from the E2B base image (e2bdev/base:latest).+Handle WORKDIR instruction.-**Returns**:-`TemplateBuilder` class-Example+### set\_user+```python-Template().from_base_image()+def set_user(user: str) -> "DockerfileParserInterface"```+Handle USER instruction.-### from\_image++### set\_envs```python-def from_image(image: str,- username: Optional[str] = None,- password: Optional[str] = None) -> TemplateBuilder+def set_envs(envs: Dict[str, str]) -> "DockerfileParserInterface"```-Start template from a Docker image.--**Arguments**:+Handle ENV instruction.-- `image`: Docker image name (e.g., 'ubuntu:24.04')-- `username`: Username for private registry authentication-- `password`: Password for private registry authentication-**Returns**:+### set\_start\_cmd-`TemplateBuilder` class-Example```python-Template().from_image('python:3')--Template().from_image('myregistry.com/myimage:latest', username='user', password='pass')+def set_start_cmd(start_cmd: str,+ ready_cmd: str) -> "DockerfFileFinalParserInterface"```+Handle CMD/ENTRYPOINT instruction.-### from\_template++### parse\_dockerfile```python-def from_template(template: str) -> TemplateBuilder+def parse_dockerfile(dockerfile_content_or_path: str,+ template_builder: DockerfileParserInterface) -> str```-Start template from an existing E2B template.+Parse a Dockerfile and convert it to Template SDK format.**Arguments**:-- `template`: E2B template ID or alias+- `dockerfile_content_or_path`: Either the Dockerfile content as a string, or a path to a Dockerfile file+- `template_builder`: Interface providing template builder methods++**Raises**:++- `ValueError`: If the Dockerfile is invalid or unsupported**Returns**:-`TemplateBuilder` class-Example+The base image from the Dockerfile+++++## ReadyCmd+```python-Template().from_template('my-base-template')+class ReadyCmd()```+Wrapper class for ready check commands.+-### from\_dockerfile+### wait\_for\_port```python-def from_dockerfile(dockerfile_content_or_path: str) -> TemplateBuilder+def wait_for_port(port: int)```-Parse a Dockerfile and convert it to Template SDK format.+Wait for a port to be listening.++Uses `ss` command to check if a port is open and listening.**Arguments**:-- `dockerfile_content_or_path`: Either the Dockerfile content as a string, or a path to a Dockerfile file+- `port`: Port number to wait for**Returns**:-`TemplateBuilder` class+ReadyCmd that checks for the portExample```python-Template().from_dockerfile('Dockerfile')-Template().from_dockerfile('FROM python:3\nRUN pip install numpy')+from e2b import Template, wait_for_port++template = (+ Template()+ .from_python_image()+ .set_start_cmd('python -m http.server 8000', wait_for_port(8000))+)```-### from\_aws\_registry+### wait\_for\_url```python-def from_aws_registry(image: str, access_key_id: str, secret_access_key: str,- region: str) -> TemplateBuilder+def wait_for_url(url: str, status_code: int = 200)```-Start template from an AWS ECR registry image.+Wait for a URL to return a specific HTTP status code.++Uses `curl` to make HTTP requests and check the response status.**Arguments**:-- `image`: Docker image name from AWS ECR-- `access_key_id`: AWS access key ID-- `secret_access_key`: AWS secret access key-- `region`: AWS region+- `url`: URL to check (e.g., 'http://localhost:3000/health')+- `status_code`: Expected HTTP status code (default: 200)**Returns**:-`TemplateBuilder` class+ReadyCmd that checks the URLExample```python-Template().from_aws_registry(- '123456789.dkr.ecr.us-west-2.amazonaws.com/myimage:latest',- access_key_id='AKIA...',- secret_access_key='...',- region='us-west-2'+from e2b import Template, wait_for_url++template = (+ Template()+ .from_node_image()+ .set_start_cmd('npm start', wait_for_url('http://localhost:3000/health')))```-### from\_gcp\_registry+### wait\_for\_process```python-def from_gcp_registry(- image: str, service_account_json: Union[str, dict]) -> TemplateBuilder+def wait_for_process(process_name: str)```-Start template from a GCP Artifact Registry or Container Registry image.+Wait for a process with a specific name to be running.++Uses `pgrep` to check if a process exists.**Arguments**:-- `image`: Docker image name from GCP registry-- `service_account_json`: Service account JSON string, dict, or path to JSON file+- `process_name`: Name of the process to wait for**Returns**:-`TemplateBuilder` class+ReadyCmd that checks for the processExample```python-Template().from_gcp_registry(- 'gcr.io/myproject/myimage:latest',- service_account_json='path/to/service-account.json'+from e2b import Template, wait_for_process++template = (+ Template()+ .from_base_image()+ .set_start_cmd('./my-daemon', wait_for_process('my-daemon')))```-### to\_json+### wait\_for\_file```python-@staticmethod-def to_json(template: "TemplateClass") -> str+def wait_for_file(filename: str)```-Convert a template to JSON representation.+Wait for a file to exist.++Uses shell test command to check file existence.**Arguments**:-- `template`: The template to convert (TemplateBuilder or TemplateFinal instance)+- `filename`: Path to the file to wait for**Returns**:-JSON string representation of the template+ReadyCmd that checks for the fileExample```python-template = Template().from_python_image('3').copy('app.py', '/app/')-json_str = TemplateBase.to_json(template)+from e2b import Template, wait_for_file++template = (+ Template()+ .from_base_image()+ .set_start_cmd('./init.sh', wait_for_file('/tmp/ready'))+)```-### to\_dockerfile+### wait\_for\_timeout```python-@staticmethod-def to_dockerfile(template: "TemplateClass") -> str+def wait_for_timeout(timeout: int)```-Convert a template to Dockerfile format.+Wait for a specified timeout before considering the sandbox ready.-Note: Templates based on other E2B templates cannot be converted to Dockerfile.+Uses `sleep` command to wait for a fixed duration.**Arguments**:-- `template`: The template to convert (TemplateBuilder or TemplateFinal instance)+- `timeout`: Time to wait in **milliseconds** (minimum: 1000ms / 1 second)-**Raises**:+**Returns**:-- `ValueError`: If the template is based on another E2B template or has no base image+ReadyCmd that waits for the specified durationExample```python-template = Template().from_python_image('3').copy('app.py', '/app/')-dockerfile = TemplateBase.to_dockerfile(template)-```--**Returns**:+from e2b import Template, wait_for_timeout-Dockerfile string representation+template = (+ Template()+ .from_node_image()+ .set_start_cmd('npm start', wait_for_timeout(5000)) # Wait 5 seconds+)+```@@ -1390,3 +1325,68 @@ template = Template().from_python_image()```++++## InstructionType++```python+class InstructionType(str, Enum)+```++Types of instructions that can be used in a template.+++## CopyItem++```python+class CopyItem(TypedDict)+```++Configuration for a single file/directory copy operation.+++## Instruction++```python+class Instruction(TypedDict)+```++Represents a single instruction in the template build process.+++## GenericDockerRegistry++```python+class GenericDockerRegistry(TypedDict)+```++Configuration for a generic Docker registry with basic authentication.+++## AWSRegistry++```python+class AWSRegistry(TypedDict)+```++Configuration for AWS Elastic Container Registry (ECR).+++## GCPRegistry++```python+class GCPRegistry(TypedDict)+```++Configuration for Google Container Registry (GCR) or Artifact Registry.+++## TemplateType++```python+class TemplateType(TypedDict)+```++Internal representation of a template for the E2B build API.+diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template_async/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template_async/page.mdxindex 8a3c5962c..042727a52 100644--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template_async/page.mdx+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template_async/page.mdx@@ -1,8 +1,6 @@--## AsyncTemplate```python@@ -57,3 +55,5 @@ await AsyncTemplate.build()```++diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template_sync/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template_sync/page.mdxindex 41e22db82..c27f11547 100644--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template_sync/page.mdx+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.3.1/template_sync/page.mdx@@ -1,8 +1,6 @@--## Template```python@@ -57,3 +55,5 @@ Template.build()```++diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex f2115f9f6..a72c90afe 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -1,6 +1,6 @@{"name": "@e2b/cli",- "version": "2.3.0",+ "version": "2.3.1","description": "CLI for managing e2b sandbox templates","homepage": "https://e2b.dev","license": "MIT",