Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

[skip ci] Release new versions

github-actions[bot]32664ea0fe12
diff --git a/.changeset/tasty-candles-leave.md b/.changeset/tasty-candles-leave.md
deleted file mode 100644
index e0f5e1e33..000000000
--- a/.changeset/tasty-candles-leave.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@e2b/cli': patch
----
-
-fixes an issue building templates on Windows
diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/cli/v1.3.2/auth/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v1.3.2/auth/page.mdx
new file mode 100644
index 000000000..2c82afa69
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v1.3.2/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/v1.3.2/sandbox/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v1.3.2/sandbox/page.mdx
new file mode 100644
index 000000000..53c9a5b35
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v1.3.2/sandbox/page.mdx
@@ -0,0 +1,89 @@
+## 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 running sandboxes
+
+### Usage
+
+```bash
+e2b sandbox list [options]
+```
+
+
+## e2b sandbox kill
+
+
+kill sandbox
+
+### Usage
+
+```bash
+e2b sandbox kill [options] [sandboxID]
+```
+
+### Options
+
+
+ - `-a, --all: kill all running sandboxes `
+
+
+## e2b sandbox spawn
+
+
+spawn 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. `
+
+
diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/cli/v1.3.2/template/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v1.3.2/template/page.mdx
new file mode 100644
index 000000000..1211bb3b0
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/cli/v1.3.2/template/page.mdx
@@ -0,0 +1,132 @@
+## e2b template
+
+
+manage sandbox templates
+
+### Usage
+
+```bash
+e2b template [options] [command]
+```
+## 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. `
+ - `-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>. `
+
+
+## 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). `
+
+
+## e2b template init
+
+
+create basic E2B Dockerfile (./e2b.Dockerfile) in root directory. You can then run e2b template build to build sandbox template from this Dockerfile
+
+### Usage
+
+```bash
+e2b template init [options]
+```
+
+### Options
+
+
+ - `-p, --path <path>: change root directory where command is executed to <path> directory `
+
+
+## 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 `
+
+
diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.2/sandbox_async/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.2/sandbox_async/page.mdx
index 5ae21cb43..802eb4bdb 100644
--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.2/sandbox_async/page.mdx
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.2/sandbox_async/page.mdx
@@ -1,209 +1,343 @@
+## SandboxApi
+```python
+class SandboxApi(SandboxApiBase)
+```
-## AsyncCommandHandle
+
+### list
```python
-class AsyncCommandHandle()
+@classmethod
+async def list(cls,
+ api_key: Optional[str] = None,
+ query: Optional[SandboxQuery] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> List[SandboxInfo]
```
-Command execution handle.
+List all running sandboxes.
-It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
+**Arguments**:
+- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `query`: Filter the list of sandboxes, e.g. by metadata `SandboxQuery(metadata={"key": "value"})`, if there are multiple filters they are combined with AND.
+- `domain`: Domain to use for the request, only relevant for self-hosted environments
+- `debug`: Enable debug mode, all requested are then sent to localhost
+- `request_timeout`: Timeout for the request in **seconds**
-### pid
+**Returns**:
+
+List of running sandboxes
+
+
+### get\_info
```python
-@property
-def pid()
+@classmethod
+async def get_info(cls,
+ sandbox_id: str,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> SandboxInfo
```
-Command process ID.
+Get the sandbox info.
+**Arguments**:
-### stdout
+- `sandbox_id`: Sandbox ID
+- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `domain`: Domain to use for the request, defaults to `E2B_DOMAIN` environment variable
+- `debug`: Debug mode, defaults to `E2B_DEBUG` environment variable
+- `request_timeout`: Timeout for the request in **seconds**
+
+**Returns**:
+
+Sandbox info
+
+
+
+
+## AsyncSandbox
```python
-@property
-def stdout()
+class AsyncSandbox(SandboxSetup, SandboxApi)
```
-Command stdout output.
+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).
-### stderr
+Use the `AsyncSandbox.create()` to create a new sandbox.
+
+**Example**:
+
+```python
+from e2b import AsyncSandbox
+
+sandbox = await AsyncSandbox.create()
+```
+
+
+### files
```python
@property
-def stderr()
+def files() -> Filesystem
```
-Command stderr output.
+Module for interacting with the sandbox filesystem.
-### error
+### commands
```python
@property
-def error()
+def commands() -> Commands
```
-Command execution error message.
+Module for running commands in the sandbox.
-### exit\_code
+### pty
```python
@property
-def exit_code()
+def pty() -> Pty
```
-Command execution exit code.
+Module for interacting with the sandbox pseudo-terminal.
-`0` if the command finished successfully.
-It is `None` if the command is still running.
+### sandbox\_id
+```python
+@property
+def sandbox_id() -> str
+```
+
+Unique identifier of the sandbox.
-### disconnect
+
+### \_\_init\_\_
```python
-async def disconnect() -> None
+def __init__(**opts: Unpack[AsyncSandboxOpts])
```
-Disconnects from the command.
-
-The command is not killed, but SDK stops receiving events from the command.
-You can reconnect to the command using `sandbox.commands.connect` method.
+Use `AsyncSandbox.create()` to create a new sandbox instead.
-### wait
+### is\_running
```python
-async def wait() -> CommandResult
+async def is_running(request_timeout: Optional[float] = None) -> bool
```
-Wait for the command to finish and return the result.
+Check if the sandbox is running.
-If the command exits with a non-zero exit code, it throws a `CommandExitException`.
+**Arguments**:
+
+- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-`CommandResult` result of command execution
+`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
+```
-### kill
+### create
```python
-async def kill() -> bool
+@classmethod
+async def create(cls,
+ template: Optional[str] = None,
+ timeout: Optional[int] = None,
+ metadata: Optional[Dict[str, str]] = None,
+ envs: Optional[Dict[str, str]] = None,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None)
```
-Kills the command.
+Create a new sandbox.
-It uses `SIGKILL` signal to kill the command
+By default, the sandbox is created from the default `base` sandbox template.
-**Returns**:
+**Arguments**:
-`True` if the command was killed successfully, `False` if the command was not found
+- `template`: Sandbox template name or ID
+- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
+- `metadata`: Custom metadata for the sandbox
+- `envs`: Custom environment variables for the sandbox
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `request_timeout`: Timeout for the request in **seconds**
+**Returns**:
+sandbox instance for the new sandbox
+Use this method instead of using the constructor to create a new sandbox.
-## Pty
+### connect
```python
-class Pty()
+@classmethod
+async def connect(cls,
+ sandbox_id: str,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None)
```
-Module for interacting with PTYs (pseudo-terminals) in the sandbox.
+Connect to an existing sandbox.
+
+With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).
+
+**Arguments**:
+
+- `sandbox_id`: Sandbox ID
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+
+**Returns**:
+
+sandbox instance for the existing sandbox
+@example
+```python
+sandbox = await AsyncSandbox.create()
+sandbox_id = sandbox.sandbox_id
+
+same_sandbox = await AsyncSandbox.connect(sandbox_id)
### kill
```python
-async def kill(pid: int, request_timeout: Optional[float] = None) -> bool
+@overload
+async def kill(request_timeout: Optional[float] = None) -> bool
```
-Kill PTY.
+Kill the sandbox.
**Arguments**:
-- `pid`: Process ID of the PTY
- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-`true` if the PTY was killed, `false` if the PTY was not found
+`True` if the sandbox was killed, `False` if the sandbox was not found
-### send\_stdin
+### kill
```python
-async def send_stdin(pid: int,
- data: bytes,
- request_timeout: Optional[float] = None) -> None
+@overload
+@staticmethod
+async def kill(sandbox_id: str,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> bool
```
-Send input to a PTY.
+Kill the sandbox specified by sandbox ID.
**Arguments**:
-- `pid`: Process ID of the PTY
-- `data`: Input data to send
+- `sandbox_id`: Sandbox ID
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
- `request_timeout`: Timeout for the request in **seconds**
+**Returns**:
-### create
+`True` if the sandbox was killed, `False` if the sandbox was not found
+
+
+### set\_timeout
```python
-async def create(
- size: PtySize,
- on_data: OutputHandler[PtyOutput],
- user: Username = "user",
- cwd: Optional[str] = None,
- envs: Optional[Dict[str, str]] = None,
- timeout: Optional[float] = 60,
- request_timeout: Optional[float] = None) -> AsyncCommandHandle
+@overload
+async def set_timeout(timeout: int,
+ request_timeout: Optional[float] = None) -> None
```
-Start a new PTY (pseudo-terminal).
+Set the timeout of the sandbox.
+
+After the timeout expires the sandbox will be automatically killed.
+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
+
+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
**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**
+- `timeout`: Timeout for the sandbox in **seconds**
- `request_timeout`: Timeout for the request in **seconds**
-**Returns**:
-Handle to interact with the PTY
+### set\_timeout
+```python
+@overload
+@staticmethod
+async def set_timeout(sandbox_id: str,
+ timeout: int,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> None
+```
-### resize
+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`.
+
+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**
+- `request_timeout`: Timeout for the request in **seconds**
+
+
+### get\_info
```python
-async def resize(pid: int,
- size: PtySize,
- request_timeout: Optional[float] = None)
+async def get_info(request_timeout: Optional[float] = None) -> SandboxInfo
```
-Resize PTY.
-
-Call this when the terminal window is resized and the number of columns and rows has changed.
+Get sandbox information like sandbox ID, template, metadata, started at/end at date.
**Arguments**:
-- `pid`: Process ID of the PTY
-- `size`: New size of the PTY
- `request_timeout`: Timeout for the request in **seconds**
+**Returns**:
+
+Sandbox info
+
@@ -367,365 +501,209 @@ You can use `AsyncCommandHandle.wait()` to wait for the command to finish and ge
-
-## SandboxApi
-
-```python
-class SandboxApi(SandboxApiBase)
-```
-
-
-### list
-
-```python
-@classmethod
-async def list(cls,
- api_key: Optional[str] = None,
- query: Optional[SandboxQuery] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> List[SandboxInfo]
-```
-
-List all running sandboxes.
-
-**Arguments**:
-
-- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `query`: Filter the list of sandboxes, e.g. by metadata `SandboxQuery(metadata={"key": "value"})`, if there are multiple filters they are combined with AND.
-- `domain`: Domain to use for the request, only relevant for self-hosted environments
-- `debug`: Enable debug mode, all requested are then sent to localhost
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
-
-List of running sandboxes
-
-
-### get\_info
-
-```python
-@classmethod
-async def get_info(cls,
- sandbox_id: str,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> SandboxInfo
-```
-
-Get the sandbox info.
-
-**Arguments**:
-
-- `sandbox_id`: Sandbox ID
-- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `domain`: Domain to use for the request, defaults to `E2B_DOMAIN` environment variable
-- `debug`: Debug mode, defaults to `E2B_DEBUG` environment variable
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
-
-Sandbox info
-
-
-
-
-## AsyncSandbox
-
-```python
-class AsyncSandbox(SandboxSetup, 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
+
+## AsyncCommandHandle
```python
-@property
-def files() -> Filesystem
+class AsyncCommandHandle()
```
-Module for interacting with the sandbox filesystem.
+Command execution handle.
+It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
-### commands
+
+### pid
```python
@property
-def commands() -> Commands
+def pid()
```
-Module for running commands in the sandbox.
+Command process ID.
-### pty
+### stdout
```python
@property
-def pty() -> Pty
+def stdout()
```
-Module for interacting with the sandbox pseudo-terminal.
+Command stdout output.
-### sandbox\_id
+### stderr
```python
@property
-def sandbox_id() -> str
+def stderr()
```
-Unique identifier of the sandbox.
+Command stderr output.
-### \_\_init\_\_
+### error
```python
-def __init__(**opts: Unpack[AsyncSandboxOpts])
+@property
+def error()
```
-Use `AsyncSandbox.create()` to create a new sandbox instead.
+Command execution error message.
-### is\_running
+### exit\_code
```python
-async def is_running(request_timeout: Optional[float] = None) -> bool
+@property
+def exit_code()
```
-Check if the sandbox is running.
+Command execution exit code.
-**Arguments**:
+`0` if the command finished successfully.
-- `request_timeout`: Timeout for the request in **seconds**
+It is `None` if the command is still running.
-**Returns**:
-`True` if the sandbox is running, `False` otherwise
-Example
-```python
-sandbox = await AsyncSandbox.create()
-await sandbox.is_running() # Returns True
+### disconnect
-await sandbox.kill()
-await sandbox.is_running() # Returns False
+```python
+async def disconnect() -> None
```
+Disconnects from the command.
-### create
+The command is not killed, but SDK stops receiving events from the command.
+You can reconnect to the command using `sandbox.commands.connect` method.
-```python
-@classmethod
-async def create(cls,
- template: Optional[str] = None,
- timeout: Optional[int] = None,
- metadata: Optional[Dict[str, str]] = None,
- envs: Optional[Dict[str, str]] = None,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None)
-```
-Create a new sandbox.
+### wait
-By default, the sandbox is created from the default `base` sandbox template.
+```python
+async def wait() -> CommandResult
+```
-**Arguments**:
+Wait for the command to finish and return the result.
-- `template`: Sandbox template name or ID
-- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
-- `metadata`: Custom metadata for the sandbox
-- `envs`: Custom environment variables for the sandbox
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `request_timeout`: Timeout for the request in **seconds**
+If the command exits with a non-zero exit code, it throws a `CommandExitException`.
**Returns**:
-sandbox instance for the new sandbox
-Use this method instead of using the constructor to create a new sandbox.
+`CommandResult` result of command execution
-### connect
+### kill
```python
-@classmethod
-async def connect(cls,
- sandbox_id: str,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None)
+async def kill() -> bool
```
-Connect to an existing sandbox.
-
-With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).
-
-**Arguments**:
+Kills the command.
-- `sandbox_id`: Sandbox ID
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+It uses `SIGKILL` signal to kill the command
**Returns**:
-sandbox instance for the existing sandbox
-@example
-```python
-sandbox = await AsyncSandbox.create()
-sandbox_id = sandbox.sandbox_id
+`True` if the command was killed successfully, `False` if the command was not found
-same_sandbox = await AsyncSandbox.connect(sandbox_id)
-### kill
+
+## Pty
```python
-@overload
-async def kill(request_timeout: Optional[float] = None) -> bool
+class Pty()
```
-Kill the sandbox.
-
-**Arguments**:
-
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
-
-`True` if the sandbox was killed, `False` if the sandbox was not found
+Module for interacting with PTYs (pseudo-terminals) in the sandbox.
### kill
```python
-@overload
-@staticmethod
-async def kill(sandbox_id: str,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> bool
+async def kill(pid: int, request_timeout: Optional[float] = None) -> bool
```
-Kill the sandbox specified by sandbox ID.
+Kill PTY.
**Arguments**:
-- `sandbox_id`: Sandbox ID
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `pid`: Process ID of the PTY
- `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,
- request_timeout: Optional[float] = None) -> None
-```
-
-Set the timeout of the sandbox.
-
-After the timeout expires the sandbox will be automatically killed.
-This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
-
-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**
-- `request_timeout`: Timeout for the request in **seconds**
+`true` if the PTY was killed, `false` if the PTY was not found
-### set\_timeout
+### send\_stdin
```python
-@overload
-@staticmethod
-async def set_timeout(sandbox_id: str,
- timeout: int,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> None
+async def send_stdin(pid: int,
+ data: bytes,
+ request_timeout: Optional[float] = None) -> 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`.
-
-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.
+Send input to a PTY.
**Arguments**:
-- `sandbox_id`: Sandbox ID
-- `timeout`: Timeout for the sandbox in **seconds**
+- `pid`: Process ID of the PTY
+- `data`: Input data to send
- `request_timeout`: Timeout for the request in **seconds**
-### get\_info
+### create
```python
-async def get_info(request_timeout: Optional[float] = None) -> SandboxInfo
+async def create(
+ size: PtySize,
+ on_data: OutputHandler[PtyOutput],
+ user: Username = "user",
+ cwd: Optional[str] = None,
+ envs: Optional[Dict[str, str]] = None,
+ timeout: Optional[float] = 60,
+ request_timeout: Optional[float] = None) -> AsyncCommandHandle
```
-Get sandbox information like sandbox ID, template, metadata, started at/end at date.
+Start a new PTY (pseudo-terminal).
**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**
**Returns**:
-Sandbox info
-
-
+Handle to interact with the PTY
-## AsyncWatchHandle
+### resize
```python
-class AsyncWatchHandle()
+async def resize(pid: int,
+ size: PtySize,
+ request_timeout: Optional[float] = None)
```
-Handle for watching a directory in the sandbox filesystem.
+Resize PTY.
-Use `.stop()` to stop watching the directory.
+Call this when the terminal window is resized and the number of columns and rows has changed.
+**Arguments**:
-### stop
+- `pid`: Process ID of the PTY
+- `size`: New size of the PTY
+- `request_timeout`: Timeout for the request in **seconds**
-```python
-async def stop()
-```
-Stop watching the directory.
@@ -1012,3 +990,25 @@ Watch directory for filesystem events.
`AsyncWatchHandle` object for stopping watching directory
+
+
+
+## AsyncWatchHandle
+
+```python
+class AsyncWatchHandle()
+```
+
+Handle for watching a directory in the sandbox filesystem.
+
+Use `.stop()` to stop watching the directory.
+
+
+### stop
+
+```python
+async def stop()
+```
+
+Stop watching the directory.
+
diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.2/sandbox_sync/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.2/sandbox_sync/page.mdx
index 95cb3ce1e..228cc4cad 100644
--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.2/sandbox_sync/page.mdx
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.2/sandbox_sync/page.mdx
@@ -1,200 +1,234 @@
-## CommandHandle
+## SandboxApi
```python
-class CommandHandle()
+class SandboxApi(SandboxApiBase)
```
-Command execution handle.
-
-It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
-
-### pid
+### list
```python
-@property
-def pid()
+@classmethod
+def list(cls,
+ api_key: Optional[str] = None,
+ query: Optional[SandboxQuery] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> List[SandboxInfo]
```
-Command process ID.
-
-
-### \_\_iter\_\_
+List all running sandboxes.
-```python
-def __iter__()
-```
+**Arguments**:
-Iterate over the command output.
+- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `query`: Filter the list of sandboxes, e.g. by metadata `SandboxQuery(metadata={"key": "value"})`, if there are multiple filters they are combined with AND.
+- `domain`: Domain to use for the request, only relevant for self-hosted environments
+- `debug`: Enable debug mode, all requested are then sent to localhost
+- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-Generator of command outputs
+List of running sandboxes
-### disconnect
+### get\_info
```python
-def disconnect() -> None
+@classmethod
+def get_info(cls,
+ sandbox_id: str,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> SandboxInfo
```
-Disconnect from the command.
+Get the sandbox info.
-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
+- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `domain`: Domain to use for the request, defaults to `E2B_DOMAIN` environment variable
+- `debug`: Debug mode, defaults to `E2B_DEBUG` environment variable
+- `request_timeout`: Timeout for the request in **seconds**
-### wait
+**Returns**:
-```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
-```
+Sandbox info
-Wait for the command to finish and returns the result.
-If the command exits with a non-zero exit code, it throws a `CommandExitException`.
-**Arguments**:
-- `on_pty`: Callback for pty output
-- `on_stdout`: Callback for stdout output
-- `on_stderr`: Callback for stderr output
+## Sandbox
-**Returns**:
+```python
+class Sandbox(SandboxSetup, SandboxApi)
+```
-`CommandResult` result of command execution
+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
-### kill
+Check docs [here](https://e2b.dev/docs).
-```python
-def kill() -> bool
-```
+Use the `Sandbox()` to create a new sandbox.
-Kills the command.
+**Example**:
-It uses `SIGKILL` signal to kill the command.
+```python
+from e2b import Sandbox
-**Returns**:
+sandbox = Sandbox()
+```
-Whether the command was killed successfully
+### files
+
+```python
+@property
+def files() -> Filesystem
+```
+Module for interacting with the sandbox filesystem.
-## Pty
+### commands
```python
-class Pty()
+@property
+def commands() -> Commands
```
-Module for interacting with PTYs (pseudo-terminals) in the sandbox.
+Module for running commands in the sandbox.
-### kill
+### pty
```python
-def kill(pid: int, request_timeout: Optional[float] = None) -> bool
+@property
+def pty() -> Pty
```
-Kill PTY.
+Module for interacting with the sandbox pseudo-terminal.
-**Arguments**:
-- `pid`: Process ID of the PTY
-- `request_timeout`: Timeout for the request in **seconds**
+### sandbox\_id
-**Returns**:
+```python
+@property
+def sandbox_id() -> str
+```
-`true` if the PTY was killed, `false` if the PTY was not found
+Unique identifier of the sandbox
-### send\_stdin
+### \_\_init\_\_
```python
-def send_stdin(pid: int,
- data: bytes,
- request_timeout: Optional[float] = None) -> None
+def __init__(template: Optional[str] = None,
+ timeout: Optional[int] = None,
+ metadata: Optional[Dict[str, str]] = None,
+ envs: Optional[Dict[str, str]] = None,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ sandbox_id: Optional[str] = None,
+ request_timeout: Optional[float] = None)
```
-Send input to a PTY.
+Create a new sandbox.
+
+By default, the sandbox is created from the default `base` sandbox template.
**Arguments**:
-- `pid`: Process ID of the PTY
-- `data`: Input data to send
+- `template`: Sandbox template name or ID
+- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users
+- `metadata`: Custom metadata for the sandbox
+- `envs`: Custom environment variables for the sandbox
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
- `request_timeout`: Timeout for the request in **seconds**
+**Returns**:
-### create
+sandbox instance for the new sandbox
+
+
+### is\_running
```python
-def create(size: PtySize,
- user: Username = "user",
- cwd: Optional[str] = None,
- envs: Optional[Dict[str, str]] = None,
- timeout: Optional[float] = 60,
- request_timeout: Optional[float] = None) -> CommandHandle
+def is_running(request_timeout: Optional[float] = None) -> bool
```
-Start a new PTY (pseudo-terminal).
+Check if the sandbox is running.
**Arguments**:
-- `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**:
-Handle to interact with the PTY
+`True` if the sandbox is running, `False` otherwise
+Example
+```python
+sandbox = Sandbox()
+sandbox.is_running() # Returns True
+sandbox.kill()
+sandbox.is_running() # Returns False
+```
-### resize
+
+### connect
```python
-def resize(pid: int,
- size: PtySize,
- request_timeout: Optional[float] = None) -> None
+@classmethod
+def connect(cls,
+ sandbox_id: str,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None)
```
-Resize PTY.
+Connects to an existing Sandbox.
-Call this when the terminal window is resized and the number of columns and rows has changed.
+With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).
**Arguments**:
-- `pid`: Process ID of the PTY
-- `size`: New size of the PTY
-- `request_timeout`: Timeout for the request in **seconds**s
-
-
-
+- `sandbox_id`: Sandbox ID
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-## Commands
+**Returns**:
+sandbox instance for the existing sandbox
+@example
```python
-class Commands()
-```
+sandbox = Sandbox()
+sandbox_id = sandbox.sandbox_id
-Module for executing commands in the sandbox.
+same_sandbox = Sandbox.connect(sandbox_id)
+```
-### list
+### kill
```python
-def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]
+@overload
+def kill(request_timeout: Optional[float] = None) -> bool
```
-Lists all running commands and PTY sessions.
+Kill the sandbox.
**Arguments**:
@@ -202,515 +236,444 @@ Lists all running commands and PTY sessions.
**Returns**:
-List of running commands and PTY sessions
+`True` if the sandbox was killed, `False` if the sandbox was not found
### kill
```python
-def kill(pid: int, request_timeout: Optional[float] = None) -> bool
+@overload
+@staticmethod
+def kill(sandbox_id: str,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> bool
```
-Kills a running command specified by its process ID.
-
-It uses `SIGKILL` signal to kill the command.
+Kill the sandbox specified by sandbox ID.
**Arguments**:
-- `pid`: Process ID of the command. You can get the list of processes using `sandbox.commands.list()`
+- `sandbox_id`: Sandbox ID
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-`True` if the command was killed, `False` if the command was not found
+`True` if the sandbox was killed, `False` if the sandbox was not found
-### send\_stdin
+### kill
```python
-def send_stdin(pid: int, data: str, request_timeout: Optional[float] = None)
+@class_method_variant("_cls_kill")
+def kill(request_timeout: Optional[float] = None) -> bool
```
-Send data to command stdin.
+Kill the 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**
+**Arguments**:
+- `request_timeout`: Timeout for the request
+**Returns**:
-### run
+`True` if the sandbox was killed, `False` if the sandbox was not found
+
+
+### set\_timeout
```python
@overload
-def run(cmd: str,
- background: Union[Literal[False], None] = None,
- envs: Optional[Dict[str, str]] = None,
- user: Username = "user",
- cwd: Optional[str] = None,
- on_stdout: Optional[Callable[[str], None]] = None,
- on_stderr: Optional[Callable[[str], None]] = None,
- timeout: Optional[float] = 60,
- request_timeout: Optional[float] = None) -> CommandResult
+def set_timeout(timeout: int, request_timeout: Optional[float] = None) -> None
```
-Start a new command and wait until it finishes executing.
+Set the timeout of the sandbox.
-**Arguments**:
+After the timeout expires the sandbox will be automatically killed.
+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
-- `cmd`: Command to execute
-- `background`: **`False` if the command should be executed in the foreground**, `True` if the command should be executed in the background
-- `envs`: Environment variables used for the command
-- `user`: User to run the command as
-- `cwd`: Working directory to run the command
-- `on_stdout`: Callback for command stdout output
-- `on_stderr`: Callback for command stderr output
-- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time
-- `request_timeout`: Timeout for the request in **seconds**
+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
-**Returns**:
+**Arguments**:
-`CommandResult` result of the command execution
+- `timeout`: Timeout for the sandbox in **seconds**
+- `request_timeout`: Timeout for the request in **seconds**
-### run
+### set\_timeout
```python
@overload
-def run(cmd: str,
- background: Literal[True],
- envs: Optional[Dict[str, str]] = None,
- user: Username = "user",
- cwd: Optional[str] = None,
- on_stdout: None = None,
- on_stderr: None = None,
- timeout: Optional[float] = 60,
- request_timeout: Optional[float] = None) -> CommandHandle
+@staticmethod
+def set_timeout(sandbox_id: str,
+ timeout: int,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> None
```
-Start a new command and return a handle to interact with it.
+Set the timeout of the sandbox specified by sandbox ID.
-**Arguments**:
+After the timeout expires the sandbox will be automatically killed.
+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
-- `cmd`: Command to execute
-- `background`: `False` if the command should be executed in the foreground, **`True` if the command should be executed in the background**
-- `envs`: Environment variables used for the command
-- `user`: User to run the command as
-- `cwd`: Working directory to run the command
-- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time
-- `request_timeout`: Timeout for the request in **seconds**
+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
-**Returns**:
+**Arguments**:
-`CommandHandle` handle to interact with the running command
+- `sandbox_id`: Sandbox ID
+- `timeout`: Timeout for the sandbox in **seconds**
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `request_timeout`: Timeout for the request in **seconds**
-### connect
+### get\_info
```python
-def connect(pid: int,
- timeout: Optional[float] = 60,
- request_timeout: Optional[float] = None)
+def get_info(request_timeout: Optional[float] = None) -> SandboxInfo
```
-Connects to a running command.
-
-You can use `CommandHandle.wait()` to wait for the command to finish and get execution results.
+Get sandbox information like sandbox ID, template, metadata, started at/end at date.
**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**
**Returns**:
-`CommandHandle` handle to interact with the running command
+Sandbox info
-## SandboxApi
+## Commands
```python
-class SandboxApi(SandboxApiBase)
+class Commands()
```
+Module for executing commands in the sandbox.
+
### list
```python
-@classmethod
-def list(cls,
- api_key: Optional[str] = None,
- query: Optional[SandboxQuery] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> List[SandboxInfo]
+def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]
```
-List all running sandboxes.
+Lists all running commands and PTY sessions.
**Arguments**:
-- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `query`: Filter the list of sandboxes, e.g. by metadata `SandboxQuery(metadata={"key": "value"})`, if there are multiple filters they are combined with AND.
-- `domain`: Domain to use for the request, only relevant for self-hosted environments
-- `debug`: Enable debug mode, all requested are then sent to localhost
- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-List of running sandboxes
+List of running commands and PTY sessions
-### get\_info
+### kill
```python
-@classmethod
-def get_info(cls,
- sandbox_id: str,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> SandboxInfo
+def kill(pid: int, request_timeout: Optional[float] = None) -> bool
```
-Get the sandbox info.
+Kills a running command specified by its process ID.
+
+It uses `SIGKILL` signal to kill the command.
**Arguments**:
-- `sandbox_id`: Sandbox ID
-- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `domain`: Domain to use for the request, defaults to `E2B_DOMAIN` environment variable
-- `debug`: Debug mode, defaults to `E2B_DEBUG` environment variable
+- `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**:
-Sandbox info
-
-
-
-
-## Sandbox
-
-```python
-class Sandbox(SandboxSetup, 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()` to create a new sandbox.
-
-**Example**:
-
-```python
-from e2b import Sandbox
-
-sandbox = Sandbox()
-```
+`True` if the command was killed, `False` if the command was not found
-### files
+### send\_stdin
```python
-@property
-def files() -> Filesystem
+def send_stdin(pid: int, data: str, request_timeout: Optional[float] = None)
```
-Module for interacting with the sandbox filesystem.
-
-
-### commands
+Send data to command stdin.
-```python
-@property
-def commands() -> Commands
-```
+:param pid Process ID of the command. You can get the list of processes using `sandbox.commands.list()`.
+:param data: Data to send to the command
+:param request_timeout: Timeout for the request in **seconds**
-Module for running commands in the sandbox.
-### pty
+### run
```python
-@property
-def pty() -> Pty
+@overload
+def run(cmd: str,
+ background: Union[Literal[False], None] = None,
+ envs: Optional[Dict[str, str]] = None,
+ user: Username = "user",
+ cwd: Optional[str] = None,
+ on_stdout: Optional[Callable[[str], None]] = None,
+ on_stderr: Optional[Callable[[str], None]] = None,
+ timeout: Optional[float] = 60,
+ request_timeout: Optional[float] = None) -> CommandResult
```
-Module for interacting with the sandbox pseudo-terminal.
+Start a new command and wait until it finishes executing.
+**Arguments**:
-### 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
+- `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**
-```python
-@property
-def sandbox_id() -> str
-```
+**Returns**:
-Unique identifier of the sandbox
+`CommandResult` result of the command execution
-### \_\_init\_\_
+### run
```python
-def __init__(template: Optional[str] = None,
- timeout: Optional[int] = None,
- metadata: Optional[Dict[str, str]] = None,
- envs: Optional[Dict[str, str]] = None,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- sandbox_id: Optional[str] = None,
- request_timeout: Optional[float] = None)
+@overload
+def run(cmd: str,
+ background: Literal[True],
+ envs: Optional[Dict[str, str]] = None,
+ user: Username = "user",
+ cwd: Optional[str] = None,
+ on_stdout: None = None,
+ on_stderr: None = None,
+ timeout: Optional[float] = 60,
+ request_timeout: Optional[float] = None) -> CommandHandle
```
-Create a new sandbox.
-
-By default, the sandbox is created from the default `base` sandbox template.
+Start a new command and return a handle to interact with it.
**Arguments**:
-- `template`: Sandbox template name or ID
-- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users
-- `metadata`: Custom metadata for the sandbox
-- `envs`: Custom environment variables for the sandbox
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `cmd`: Command to execute
+- `background`: `False` if the command should be executed in the foreground, **`True` if the command should be executed in the background**
+- `envs`: Environment variables used for the command
+- `user`: User to run the command as
+- `cwd`: Working directory to run the command
+- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time
- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-sandbox instance for the new sandbox
+`CommandHandle` handle to interact with the running command
-### is\_running
+### connect
```python
-def is_running(request_timeout: Optional[float] = None) -> bool
+def connect(pid: int,
+ timeout: Optional[float] = 60,
+ request_timeout: Optional[float] = None)
```
-Check if the sandbox is running.
+Connects to a running command.
+
+You can use `CommandHandle.wait()` to wait for the command to finish and get execution results.
**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**
**Returns**:
-`True` if the sandbox is running, `False` otherwise
-Example
-```python
-sandbox = Sandbox()
-sandbox.is_running() # Returns True
+`CommandHandle` handle to interact with the running command
-sandbox.kill()
-sandbox.is_running() # Returns False
-```
-### connect
+
+## CommandHandle
```python
-@classmethod
-def connect(cls,
- sandbox_id: str,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None)
+class CommandHandle()
```
-Connects to an existing Sandbox.
-
-With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).
+Command execution handle.
-**Arguments**:
+It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
-- `sandbox_id`: Sandbox ID
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-**Returns**:
+### pid
-sandbox instance for the existing sandbox
-@example
```python
-sandbox = Sandbox()
-sandbox_id = sandbox.sandbox_id
-
-same_sandbox = Sandbox.connect(sandbox_id)
+@property
+def pid()
```
+Command process ID.
+
-### kill
+### \_\_iter\_\_
```python
-@overload
-def kill(request_timeout: Optional[float] = None) -> bool
+def __iter__()
```
-Kill the sandbox.
-
-**Arguments**:
-
-- `request_timeout`: Timeout for the request in **seconds**
+Iterate over the command output.
**Returns**:
-`True` if the sandbox was killed, `False` if the sandbox was not found
+Generator of command outputs
-### kill
+### disconnect
```python
-@overload
-@staticmethod
-def kill(sandbox_id: str,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> bool
+def disconnect() -> None
```
-Kill the sandbox specified by sandbox ID.
-
-**Arguments**:
-
-- `sandbox_id`: Sandbox ID
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
+Disconnect from the command.
-`True` if the sandbox was killed, `False` if the sandbox was not found
+The command is not killed, but SDK stops receiving events from the command.
+You can reconnect to the command using `sandbox.commands.connect` method.
-### kill
+### wait
```python
-@class_method_variant("_cls_kill")
-def kill(request_timeout: Optional[float] = None) -> bool
+def wait(on_pty: Optional[Callable[[PtyOutput], None]] = None,
+ on_stdout: Optional[Callable[[str], None]] = None,
+ on_stderr: Optional[Callable[[str], None]] = None) -> CommandResult
```
-Kill the sandbox.
+Wait for the command to finish and returns the result.
+
+If the command exits with a non-zero exit code, it throws a `CommandExitException`.
**Arguments**:
-- `request_timeout`: Timeout for the request
+- `on_pty`: Callback for pty output
+- `on_stdout`: Callback for stdout output
+- `on_stderr`: Callback for stderr output
**Returns**:
-`True` if the sandbox was killed, `False` if the sandbox was not found
+`CommandResult` result of command execution
-### set\_timeout
+### kill
```python
-@overload
-def set_timeout(timeout: int, request_timeout: Optional[float] = None) -> None
+def kill() -> bool
```
-Set the timeout of the sandbox.
+Kills 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`.
+It uses `SIGKILL` signal to kill the command.
-Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
+**Returns**:
-**Arguments**:
+Whether the command was killed successfully
-- `timeout`: Timeout for the sandbox in **seconds**
-- `request_timeout`: Timeout for the request in **seconds**
-### set\_timeout
+
+## Pty
```python
-@overload
-@staticmethod
-def set_timeout(sandbox_id: str,
- timeout: int,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> None
+class Pty()
```
-Set the timeout of the sandbox specified by sandbox ID.
-
-After the timeout expires the sandbox will be automatically killed.
-This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
-
-Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
-
-**Arguments**:
-
-- `sandbox_id`: Sandbox ID
-- `timeout`: Timeout for the sandbox in **seconds**
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `request_timeout`: Timeout for the request in **seconds**
+Module for interacting with PTYs (pseudo-terminals) in the sandbox.
-### get\_info
+### kill
```python
-def get_info(request_timeout: Optional[float] = None) -> 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**:
+- `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
-## WatchHandle
+### send\_stdin
```python
-class WatchHandle()
+def send_stdin(pid: int,
+ data: bytes,
+ request_timeout: Optional[float] = None) -> None
```
-Handle for watching filesystem events.
-It is used to get the latest events that have occurred in the watched directory.
+Send input to a PTY.
-Use `.stop()` to stop watching the directory.
+**Arguments**:
+
+- `pid`: Process ID of the PTY
+- `data`: Input data to send
+- `request_timeout`: Timeout for the request in **seconds**
-### stop
+### create
```python
-def stop()
+def create(size: PtySize,
+ user: Username = "user",
+ cwd: Optional[str] = None,
+ envs: Optional[Dict[str, str]] = None,
+ timeout: Optional[float] = 60,
+ request_timeout: Optional[float] = None) -> CommandHandle
```
-Stop watching the directory.
-After you stop the watcher you won't be able to get the events anymore.
+Start a new PTY (pseudo-terminal).
+**Arguments**:
-### get\_new\_events
+- `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**:
+
+Handle to interact with the PTY
+
+
+### resize
```python
-def get_new_events() -> List[FilesystemEvent]
+def resize(pid: int,
+ size: PtySize,
+ request_timeout: Optional[float] = None) -> None
```
-Get the latest events that have occurred in the watched directory since the last call, or from the beginning of the watching, up until now.
+Resize PTY.
-**Returns**:
+Call this when the terminal window is resized and the number of columns and rows has changed.
-List of filesystem events
+**Arguments**:
+
+- `pid`: Process ID of the PTY
+- `size`: New size of the PTY
+- `request_timeout`: Timeout for the request in **seconds**s
@@ -977,3 +940,40 @@ Watch directory for filesystem events.
`WatchHandle` object for stopping watching directory
+
+
+
+## WatchHandle
+
+```python
+class WatchHandle()
+```
+
+Handle for watching filesystem events.
+It is used to get the latest events that have occurred in the watched directory.
+
+Use `.stop()` to stop watching the directory.
+
+
+### stop
+
+```python
+def stop()
+```
+
+Stop watching the directory.
+After you stop the watcher you won't be able to get the events anymore.
+
+
+### get\_new\_events
+
+```python
+def get_new_events() -> List[FilesystemEvent]
+```
+
+Get the latest events that have occurred in the watched directory since the last call, or from the beginning of the watching, up until now.
+
+**Returns**:
+
+List of filesystem events
+
diff --git a/packages/cli/package.json b/packages/cli/package.json
index e307f22a0..2fc3b757b 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@e2b/cli",
- "version": "1.3.1",
+ "version": "1.3.2",
"description": "CLI for managing e2b sandbox templates",
"homepage": "https://e2b.dev",
"license": "MIT",