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]5b7b3f6a2511
diff --git a/.changeset/itchy-apples-walk.md b/.changeset/itchy-apples-walk.mddeleted file mode 100644index fb847ac98..000000000--- a/.changeset/itchy-apples-walk.md+++ /dev/null@@ -1,5 +0,0 @@-----'@e2b/python-sdk': patch------Remove logdiff --git a/apps/web/src/app/(docs)/docs/sdk-reference/desktop-js-sdk/v2.0.2/sandbox/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/desktop-js-sdk/v2.0.2/sandbox/page.mdxnew file mode 100644index 000000000..e67cc1d52--- /dev/null+++ b/apps/web/src/app/(docs)/docs/sdk-reference/desktop-js-sdk/v2.0.2/sandbox/page.mdx@@ -0,0 +1,692 @@+### Sandbox++#### Properties++| Property | Modifier | Type | Default value |+| ------ | ------ | ------ | ------ |+| `display` | `public` | `string` | `':0'` |+| `stream` | `public` | `VNCServer` | `undefined` |++#### Methods++### doubleClick()++```ts+doubleClick(x?: number, y?: number): Promise<void>+```++Double left click on the mouse position.++###### Parameters++| Parameter | Type |+| ------ | ------ |+| `x`? | `number` |+| `y`? | `number` |++###### Returns++`Promise`\<`void`\>++### drag()++```ts+drag(from: [number, number], to: [number, number]): Promise<void>+```++Drag the mouse from the given position to the given position.++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `from` | [`number`, `number`] | The starting position. |+| `to` | [`number`, `number`] | The ending position. |++###### Returns++`Promise`\<`void`\>++### getApplicationWindows()++```ts+getApplicationWindows(application: string): Promise<string[]>+```++Get the window ID of the window with the given title.++###### Parameters++| Parameter | Type |+| ------ | ------ |+| `application` | `string` |++###### Returns++`Promise`\<`string`[]\>++The ID of the window.++### getCurrentWindowId()++```ts+getCurrentWindowId(): Promise<string>+```++Get the current window ID.++###### Returns++`Promise`\<`string`\>++The ID of the current window.++### getCursorPosition()++```ts+getCursorPosition(): Promise<CursorPosition>+```++Get the current cursor position.++###### Returns++`Promise`\<`CursorPosition`\>++A object with the x and y coordinates++###### Throws++Error if cursor position cannot be determined++### getScreenSize()++```ts+getScreenSize(): Promise<ScreenSize>+```++Get the current screen size.++###### Returns++`Promise`\<`ScreenSize`\>++An ScreenSize object++###### Throws++Error if screen size cannot be determined++### getWindowTitle()++```ts+getWindowTitle(windowId: string): Promise<string>+```++Get the title of the window with the given ID.++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `windowId` | `string` | The ID of the window. |++###### Returns++`Promise`\<`string`\>++The title of the window.++### launch()++```ts+launch(application: string, uri?: string): Promise<void>+```++Launch an application.++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `application` | `string` | The application to launch. |+| `uri`? | `string` | The URI to open in the application. |++###### Returns++`Promise`\<`void`\>++### leftClick()++```ts+leftClick(x?: number, y?: number): Promise<void>+```++Left click on the mouse position.++###### Parameters++| Parameter | Type |+| ------ | ------ |+| `x`? | `number` |+| `y`? | `number` |++###### Returns++`Promise`\<`void`\>++### middleClick()++```ts+middleClick(x?: number, y?: number): Promise<void>+```++Middle click on the mouse position.++###### Parameters++| Parameter | Type |+| ------ | ------ |+| `x`? | `number` |+| `y`? | `number` |++###### Returns++`Promise`\<`void`\>++### mousePress()++```ts+mousePress(button: "left" | "right" | "middle"): Promise<void>+```++Press the mouse button.++###### Parameters++| Parameter | Type | Default value |+| ------ | ------ | ------ |+| `button` | `"left"` \| `"right"` \| `"middle"` | `'left'` |++###### Returns++`Promise`\<`void`\>++### mouseRelease()++```ts+mouseRelease(button: "left" | "right" | "middle"): Promise<void>+```++Release the mouse button.++###### Parameters++| Parameter | Type | Default value |+| ------ | ------ | ------ |+| `button` | `"left"` \| `"right"` \| `"middle"` | `'left'` |++###### Returns++`Promise`\<`void`\>++### moveMouse()++```ts+moveMouse(x: number, y: number): Promise<void>+```++Move the mouse to the given coordinates.++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `x` | `number` | The x coordinate. |+| `y` | `number` | The y coordinate. |++###### Returns++`Promise`\<`void`\>++### open()++```ts+open(fileOrUrl: string): Promise<void>+```++Open a file or a URL in the default application.++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `fileOrUrl` | `string` | The file or URL to open. |++###### Returns++`Promise`\<`void`\>++### press()++```ts+press(key: string | string[]): Promise<void>+```++Press a key.++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `key` | `string` \| `string`[] | The key to press (e.g. "enter", "space", "backspace", etc.). Can be a single key or an array of keys. |++###### Returns++`Promise`\<`void`\>++### rightClick()++```ts+rightClick(x?: number, y?: number): Promise<void>+```++Right click on the mouse position.++###### Parameters++| Parameter | Type |+| ------ | ------ |+| `x`? | `number` |+| `y`? | `number` |++###### Returns++`Promise`\<`void`\>++### screenshot()++###### screenshot()++```ts+screenshot(): Promise<Uint8Array<ArrayBufferLike>>+```++Take a screenshot and save it to the given name.++###### Returns++`Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>++A Uint8Array bytes representation of the screenshot.++###### screenshot(format)++```ts+screenshot(format: "bytes"): Promise<Uint8Array<ArrayBufferLike>>+```++Take a screenshot and save it to the given name.++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `format` | `"bytes"` | The format of the screenshot. |++###### Returns++`Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>++A Uint8Array bytes representation of the screenshot.++###### screenshot(format)++```ts+screenshot(format: "blob"): Promise<Blob>+```++Take a screenshot and save it to the given name.++###### Parameters++| Parameter | Type |+| ------ | ------ |+| `format` | `"blob"` |++###### Returns++`Promise`\<`Blob`\>++A Blob representation of the screenshot.++###### screenshot(format)++```ts+screenshot(format: "stream"): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>+```++Take a screenshot and save it to the given name.++###### Parameters++| Parameter | Type |+| ------ | ------ |+| `format` | `"stream"` |++###### Returns++`Promise`\<`ReadableStream`\<`Uint8Array`\<`ArrayBufferLike`\>\>\>++A ReadableStream of bytes representation of the screenshot.++### scroll()++```ts+scroll(direction: "down" | "up", amount: number): Promise<void>+```++Scroll the mouse wheel by the given amount.++###### Parameters++| Parameter | Type | Default value | Description |+| ------ | ------ | ------ | ------ |+| `direction` | `"down"` \| `"up"` | `'down'` | The direction to scroll. Can be "up" or "down". |+| `amount` | `number` | `1` | The amount to scroll. |++###### Returns++`Promise`\<`void`\>++### wait()++```ts+wait(ms: number): Promise<void>+```++Wait for the given amount of time.++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `ms` | `number` | The amount of time to wait in milliseconds. |++###### Returns++`Promise`\<`void`\>++### waitAndVerify()++```ts+waitAndVerify(+ cmd: string,+ onResult: (result: CommandResult) => boolean,+ timeout: number,+interval: number): Promise<boolean>+```++Wait for a command to return a specific result.++###### Parameters++| Parameter | Type | Default value | Description |+| ------ | ------ | ------ | ------ |+| `cmd` | `string` | `undefined` | The command to run. |+| `onResult` | (`result`: `CommandResult`) => `boolean` | `undefined` | The function to check the result of the command. |+| `timeout` | `number` | `10` | The maximum time to wait for the command to return the result. |+| `interval` | `number` | `0.5` | The interval to wait between checks. |++###### Returns++`Promise`\<`boolean`\>++`true` if the command returned the result within the timeout, otherwise `false`.++### write()++```ts+write(text: string, options: object): Promise<void>+```++Write the given text at the current cursor position.++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `text` | `string` | The text to write. |+| `options` | `object` | An object containing the chunk size and delay between each chunk of text. |+| `options.chunkSize` | `number` | The size of each chunk of text to write. Default is 25 characters. |+| `options.delayInMs` | `number` | The delay between each chunk of text. Default is 75 ms. |++###### Returns++`Promise`\<`void`\>++### betaCreate()++###### betaCreate(this, opts)++```ts+static betaCreate<S>(this: S, opts?: SandboxBetaCreateOpts): Promise<InstanceType<S>>+```++Create a new sandbox from the default `desktop` sandbox template.++###### Type Parameters++| Type Parameter |+| ------ |+| `S` *extends* *typeof* `Sandbox` |++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `this` | `S` | - |+| `opts`? | `SandboxBetaCreateOpts` | connection options. |++###### Returns++`Promise`\<`InstanceType`\<`S`\>\>++sandbox instance for the new sandbox.++###### Example++```ts+const sandbox = await Sandbox.create()+```++###### Constructs++Sandbox++###### betaCreate(this, template, opts)++```ts+static betaCreate<S>(+ this: S,+ template: string,+opts?: SandboxBetaCreateOpts): Promise<InstanceType<S>>+```++Create a new sandbox from the specified sandbox template.++###### Type Parameters++| Type Parameter |+| ------ |+| `S` *extends* *typeof* `Sandbox` |++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `this` | `S` | - |+| `template` | `string` | sandbox template name or ID. |+| `opts`? | `SandboxBetaCreateOpts` | connection options. |++###### Returns++`Promise`\<`InstanceType`\<`S`\>\>++sandbox instance for the new sandbox.++###### Example++```ts+const sandbox = await Sandbox.create('<template-name-or-id>')+```++###### Constructs++Sandbox++### create()++###### create(this, opts)++```ts+static create<S>(this: S, opts?: SandboxOpts): Promise<InstanceType<S>>+```++Create a new sandbox from the default `desktop` sandbox template.++###### Type Parameters++| Type Parameter |+| ------ |+| `S` *extends* *typeof* `Sandbox` |++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `this` | `S` | - |+| `opts`? | `SandboxOpts` | connection options. |++###### Returns++`Promise`\<`InstanceType`\<`S`\>\>++sandbox instance for the new sandbox.++###### Example++```ts+const sandbox = await Sandbox.create()+```++###### Constructs++Sandbox++###### create(this, template, opts)++```ts+static create<S>(+ this: S,+ template: string,+opts?: SandboxOpts): Promise<InstanceType<S>>+```++Create a new sandbox from the specified sandbox template.++###### Type Parameters++| Type Parameter |+| ------ |+| `S` *extends* *typeof* `Sandbox` |++###### Parameters++| Parameter | Type | Description |+| ------ | ------ | ------ |+| `this` | `S` | - |+| `template` | `string` | sandbox template name or ID. |+| `opts`? | `SandboxOpts` | connection options. |++###### Returns++`Promise`\<`InstanceType`\<`S`\>\>++sandbox instance for the new sandbox.++###### Example++```ts+const sandbox = await Sandbox.create('<template-name-or-id>')+```++###### Constructs++Sandbox++## Interfaces++### SandboxBetaCreateOpts++Configuration options for the Sandbox environment.+ SandboxOpts++#### Properties++### display?++```ts+optional display: string;+```++Display identifier.++### dpi?++```ts+optional dpi: number;+```++Dots per inch (DPI) setting for the display.++### resolution?++```ts+optional resolution: [number, number];+```++The screen resolution in pixels, specified as [width, height].++***++### SandboxOpts++Configuration options for the Sandbox environment.+ SandboxOpts++#### Properties++### display?++```ts+optional display: string;+```++Display identifier.++### dpi?++```ts+optional dpi: number;+```++Dots per inch (DPI) setting for the display.++### resolution?++```ts+optional resolution: [number, number];+```++The screen resolution in pixels, specified as [width, height].diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.2.5/exceptions/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.2.5/exceptions/page.mdxnew file mode 100644index 000000000..393977a9f--- /dev/null+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.2.5/exceptions/page.mdx@@ -0,0 +1,84 @@++++## SandboxException++```python+class SandboxException(Exception)+```++Base class for all sandbox errors.++Raised when a general sandbox exception occurs.+++## TimeoutException++```python+class TimeoutException(SandboxException)+```++Raised when a timeout occurs.++The `unavailable` exception type is caused by sandbox timeout.++The `canceled` exception type is caused by exceeding request timeout.++The `deadline_exceeded` exception type is caused by exceeding the timeout for process, watch, etc.++The `unknown` exception type is sometimes caused by the sandbox timeout when the request is not processed correctly.+++## InvalidArgumentException++```python+class InvalidArgumentException(SandboxException)+```++Raised when an invalid argument is provided.+++## NotEnoughSpaceException++```python+class NotEnoughSpaceException(SandboxException)+```++Raised when there is not enough disk space.+++## NotFoundException++```python+class NotFoundException(SandboxException)+```++Raised when a resource is not found.+++## AuthenticationException++```python+class AuthenticationException(Exception)+```++Raised when authentication fails.+++## TemplateException++```python+class TemplateException(SandboxException)+```++Exception raised when the template uses old envd version. It isn't compatible with the new SDK.+++## RateLimitException++```python+class RateLimitException(SandboxException)+```++Raised when the API rate limit is exceeded.+diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.2.5/sandbox_async/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.2.5/sandbox_async/page.mdxnew file mode 100644index 000000000..c1624c0c0--- /dev/null+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.2.5/sandbox_async/page.mdx@@ -0,0 +1,1287 @@++++## SandboxApi++```python+class SandboxApi(SandboxBase)+```+++### list++```python+@staticmethod+def list(query: Optional[SandboxQuery] = None,+ limit: Optional[int] = None,+ next_token: Optional[str] = None,+ **opts: Unpack[ApiParams]) -> AsyncSandboxPaginator+```++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 sandboxes+++++## Commands++```python+class Commands()+```++Module for executing commands in the sandbox.+++### list++```python+async def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]+```++Lists all running commands and PTY sessions.++**Arguments**:++- `request_timeout`: Timeout for the request in **seconds**++**Returns**:++List of running commands and PTY sessions+++### kill++```python+async def kill(pid: int, request_timeout: Optional[float] = None) -> bool+```++Kill a running command specified by its process ID.++It uses `SIGKILL` signal to kill the command.++**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+++### send\_stdin++```python+async def send_stdin(pid: int,+ data: str,+ request_timeout: Optional[float] = None) -> None+```++Send data to command stdin.++:param pid Process ID of the command. You can get the list of processes using `sandbox.commands.list()`.+:param data: Data to send to the command+:param request_timeout: Timeout for the request in **seconds**++++### run++```python+@overload+async def run(cmd: str,+ background: Union[Literal[False], None] = None,+ envs: Optional[Dict[str, str]] = None,+ user: Username = "user",+ cwd: Optional[str] = None,+ on_stdout: Optional[OutputHandler[Stdout]] = None,+ on_stderr: Optional[OutputHandler[Stderr]] = None,+ stdin: Optional[bool] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> CommandResult+```++Start a new command and wait until it finishes executing.++**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**++**Returns**:++`CommandResult` result of the command execution+++### run++```python+@overload+async def run(cmd: str,+ background: Literal[True],+ envs: Optional[Dict[str, str]] = None,+ user: Username = "user",+ cwd: Optional[str] = None,+ on_stdout: Optional[OutputHandler[Stdout]] = None,+ on_stderr: Optional[OutputHandler[Stderr]] = None,+ stdin: Optional[bool] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> AsyncCommandHandle+```++Start a new command and return a handle to interact with it.++**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**++**Returns**:++`AsyncCommandHandle` handle to interact with the running command+++### 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+```++Connects to a running command.++You can use `AsyncCommandHandle.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()`+- `request_timeout`: Request timeout in **seconds**+- `timeout`: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time+- `on_stdout`: Callback for command stdout output+- `on_stderr`: Callback for command stderr output++**Returns**:++`AsyncCommandHandle` handle to interact with the running command+++++## AsyncCommandHandle++```python+class AsyncCommandHandle()+```++Command execution handle.++It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.+++### pid++```python+@property+def pid()+```++Command process ID.+++### stdout++```python+@property+def stdout()+```++Command stdout output.+++### stderr++```python+@property+def stderr()+```++Command stderr output.+++### error++```python+@property+def error()+```++Command execution error message.+++### exit\_code++```python+@property+def exit_code()+```++Command execution exit code.++`0` if the command finished successfully.++It is `None` if the command is still running.+++### disconnect++```python+async def disconnect() -> None+```++Disconnects from the command.++The command is not killed, but SDK stops receiving events from the command.+You can reconnect to the command using `sandbox.commands.connect` method.+++### wait++```python+async def wait() -> CommandResult+```++Wait for the command to finish and return the result.++If the command exits with a non-zero exit code, it throws a `CommandExitException`.++**Returns**:++`CommandResult` result of command execution+++### kill++```python+async def kill() -> bool+```++Kills the command.++It uses `SIGKILL` signal to kill the command++**Returns**:++`True` if the command was killed successfully, `False` if the command was not found+++++## Pty++```python+class Pty()+```++Module for interacting with PTYs (pseudo-terminals) in the sandbox.+++### kill++```python+async def kill(pid: int, request_timeout: Optional[float] = None) -> bool+```++Kill PTY.++**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+++### send\_stdin++```python+async def send_stdin(pid: int,+ data: bytes,+ request_timeout: Optional[float] = None) -> None+```++Send input to a PTY.++**Arguments**:++- `pid`: Process ID of the PTY+- `data`: Input data to send+- `request_timeout`: Timeout for the request in **seconds**+++### create++```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+```++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**:++Handle to interact with the PTY+++### resize++```python+async def resize(pid: int,+ size: PtySize,+ request_timeout: Optional[float] = None)+```++Resize PTY.++Call this when the terminal window is resized and the number of columns and rows has changed.++**Arguments**:++- `pid`: Process ID of the PTY+- `size`: New size of the PTY+- `request_timeout`: Timeout for the request in **seconds**+++++## 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: Username = "user",+ 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: Username = "user",+ 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**++**Returns**:++File content as a `bytearray`+++### read++```python+@overload+async def read(+ path: str,+ format: Literal["stream"],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> AsyncIterator[bytes]+```++Read file content as a `AsyncIterator[bytes]`.++**Arguments**:++- `path`: Path to the file+- `user`: Run the operation as this user+- `format`: Format of the file content—`stream`+- `request_timeout`: Timeout for the request in **seconds**++**Returns**:++File content as an `AsyncIterator[bytes]`+++### write++```python+async def write(path: str,+ data: Union[str, bytes, IO],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> WriteInfo+```++Write content to a file on the path.++Writing to a file that doesn't exist creates the file.+Writing to a file that already exists overwrites the file.+Writing to a file at path that doesn't exist creates the necessary directories.++**Arguments**:++- `path`: Path to the file+- `data`: Data to write to the file, can be a `str`, `bytes`, or `IO`.+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request in **seconds**++**Returns**:++Information about the written file+++### write\_files++```python+async def write_files(+ files: List[WriteEntry],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> List[WriteInfo]+```++Writes multiple files.++Writes a list of files to the filesystem.+When writing to a file that doesn't exist, the file will get created.+When writing to a file that already exists, the file will get overwritten.+When writing to a file that's in a directory that doesn't exist, you'll get an error.++**Arguments**:++- `files`: list of files to write as `WriteEntry` objects, each containing `path` and `data`+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request++**Returns**:++Information about the written files+++### list++```python+async def list(path: str,+ depth: Optional[int] = 1,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> List[EntryInfo]+```++List entries in a directory.++**Arguments**:++- `path`: Path to the directory+- `depth`: Depth of the directory to list+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request in **seconds**++**Returns**:++List of entries in the directory+++### exists++```python+async def exists(path: str,+ user: Username = "user",+ 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+async def get_info(path: str,+ user: Username = "user",+ 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+async def remove(path: str,+ user: Username = "user",+ 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+async def rename(old_path: str,+ new_path: str,+ user: Username = "user",+ 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+async def make_dir(path: str,+ user: Username = "user",+ 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+async def watch_dir(path: str,+ on_event: OutputHandler[FilesystemEvent],+ on_exit: Optional[OutputHandler[Exception]] = None,+ user: Username = "user",+ request_timeout: Optional[float] = None,+ timeout: Optional[float] = 60,+ recursive: bool = False) -> AsyncWatchHandle+```++Watch directory for filesystem events.++**Arguments**:++- `path`: Path to a directory to watch+- `on_event`: Callback to call on each event in the directory+- `on_exit`: Callback to call when the watching ends+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request in **seconds**+- `timeout`: Timeout for the watch operation in **seconds**. Using `0` will not limit the watch time+- `recursive`: Watch directory recursively++**Returns**:++`AsyncWatchHandle` object for stopping watching directory+++++## 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\_\_++```python+def __init__(**opts: Unpack[SandboxOpts])+```++Use `AsyncSandbox.create()` to create a new sandbox instead.+++### is\_running++```python+async def is_running(request_timeout: Optional[float] = None) -> bool+```++Check if the sandbox is running.++**Arguments**:++- `request_timeout`: Timeout for the request in **seconds**++**Returns**:++`True` if the sandbox is running, `False` otherwise+Example+```python+sandbox = await AsyncSandbox.create()+await sandbox.is_running() # Returns True++await sandbox.kill()+await sandbox.is_running() # Returns False+```+++### create++```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+```++Create a new sandbox.++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**:++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 connect(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**:++- `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()+```+++### connect++```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+```++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**:++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.++**Returns**:++`True` if the sandbox was killed, `False` if the sandbox was not found+++### kill++```python+@overload+@staticmethod+async def kill(sandbox_id: str, **opts: Unpack[ApiParams]) -> bool+```++Kill the sandbox specified by sandbox ID.++**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.++**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**+++### set\_timeout++```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**+++### set\_timeout++```python+@class_method_variant("_cls_set_timeout")+async def set_timeout(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**:++- `timeout`: Timeout for the sandbox in **seconds**+++### get\_info++```python+@overload+async def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo+```++Get sandbox information like sandbox ID, template, metadata, started at/end at date.++**Returns**:++Sandbox info+++### get\_info++```python+@overload+@staticmethod+async def get_info(sandbox_id: str, **opts: Unpack[ApiParams]) -> SandboxInfo+```++Get sandbox information like sandbox ID, template, metadata, started at/end at date.++**Arguments**:++- `sandbox_id`: Sandbox ID++**Returns**:++Sandbox info+++### get\_info++```python+@class_method_variant("_cls_get_info")+async def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo+```++Get sandbox information like sandbox ID, template, metadata, started at/end at date.++**Returns**:++Sandbox info+++### get\_metrics++```python+@overload+async 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**:++- `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+++### get\_metrics++```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]+```++Get the metrics of the sandbox specified by sandbox ID.++**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**:++List of sandbox metrics containing CPU, memory and disk usage information+++### get\_metrics++```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]+```++Get the metrics of the current sandbox.++**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+@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+```++[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**:++- `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+@overload+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\_pause++```python+@overload+@staticmethod+async def beta_pause(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**:++- `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+++diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.2.5/sandbox_sync/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.2.5/sandbox_sync/page.mdxnew file mode 100644index 000000000..a5962cfd8--- /dev/null+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v2.2.5/sandbox_sync/page.mdx@@ -0,0 +1,1246 @@++++## SandboxApi++```python+class SandboxApi(SandboxBase)+```+++### 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**:++List of running sandboxes+++++## Commands++```python+class Commands()+```++Module for executing commands in the sandbox.+++### list++```python+def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]+```++Lists all running commands and PTY sessions.++**Arguments**:++- `request_timeout`: Timeout for the request in **seconds**++**Returns**:++List of running commands and PTY sessions+++### kill++```python+def kill(pid: int, request_timeout: Optional[float] = None) -> bool+```++Kills a running command specified by its process ID.++It uses `SIGKILL` signal to kill the command.++**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+++### send\_stdin++```python+def send_stdin(pid: int, data: str, request_timeout: Optional[float] = None)+```++Send data to command stdin.++:param pid Process ID of the command. You can get the list of processes using `sandbox.commands.list()`.+:param data: Data to send to the command+:param request_timeout: Timeout for the request in **seconds**++++### run++```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,+ stdin: Optional[bool] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> CommandResult+```++Start a new command and wait until it finishes executing.++**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**++**Returns**:++`CommandResult` result of the command execution+++### run++```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,+ stdin: Optional[bool] = None,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None) -> CommandHandle+```++Start a new command and return a handle to interact with it.++**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**++**Returns**:++`CommandHandle` handle to interact with the running command+++### connect++```python+def connect(pid: int,+ timeout: Optional[float] = 60,+ request_timeout: Optional[float] = None)+```++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**:++`CommandHandle` handle to interact with the running command+++++## CommandHandle++```python+class CommandHandle()+```++Command execution handle.++It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.+++### pid++```python+@property+def pid()+```++Command process ID.+++### \_\_iter\_\_++```python+def __iter__()+```++Iterate over the command output.++**Returns**:++Generator of command outputs+++### disconnect++```python+def disconnect() -> None+```++Disconnect from the command.++The command is not killed, but SDK stops receiving events from the command.+You can reconnect to the command using `sandbox.commands.connect` method.+++### wait++```python+def wait(on_pty: Optional[Callable[[PtyOutput], None]] = None,+ on_stdout: Optional[Callable[[str], None]] = None,+ on_stderr: Optional[Callable[[str], None]] = None) -> CommandResult+```++Wait for the command to finish and returns the result.++If the command exits with a non-zero exit code, it throws a `CommandExitException`.++**Arguments**:++- `on_pty`: Callback for pty output+- `on_stdout`: Callback for stdout output+- `on_stderr`: Callback for stderr output++**Returns**:++`CommandResult` result of command execution+++### kill++```python+def kill() -> bool+```++Kills the command.++It uses `SIGKILL` signal to kill the command.++**Returns**:++Whether the command was killed successfully+++++## Pty++```python+class Pty()+```++Module for interacting with PTYs (pseudo-terminals) in the sandbox.+++### kill++```python+def kill(pid: int, request_timeout: Optional[float] = None) -> bool+```++Kill PTY.++**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+++### send\_stdin++```python+def send_stdin(pid: int,+ data: bytes,+ request_timeout: Optional[float] = None) -> None+```++Send input to a PTY.++**Arguments**:++- `pid`: Process ID of the PTY+- `data`: Input data to send+- `request_timeout`: Timeout for the request in **seconds**+++### create++```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+```++Start a new PTY (pseudo-terminal).++**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+++### resize++```python+def resize(pid: int,+ size: PtySize,+ request_timeout: Optional[float] = None) -> None+```++Resize PTY.++Call this when the terminal window is resized and the number of columns and rows has changed.++**Arguments**:++- `pid`: Process ID of the PTY+- `size`: New size of the PTY+- `request_timeout`: Timeout for the request in **seconds**s+++++## 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+++++## Filesystem++```python+class Filesystem()+```++Module for interacting with the filesystem in the sandbox.+++### read++```python+@overload+def read(path: str,+ format: Literal["text"] = "text",+ user: Username = "user",+ 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+def read(path: str,+ format: Literal["bytes"],+ user: Username = "user",+ 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**++**Returns**:++File content as a `bytearray`+++### read++```python+@overload+def read(path: str,+ format: Literal["stream"],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> Iterator[bytes]+```++Read file content as a `Iterator[bytes]`.++**Arguments**:++- `path`: Path to the file+- `user`: Run the operation as this user+- `format`: Format of the file content—`stream`+- `request_timeout`: Timeout for the request in **seconds**++**Returns**:++File content as an `Iterator[bytes]`+++### write++```python+def write(path: str,+ data: Union[str, bytes, IO],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> WriteInfo+```++Write content to a file on the path.++Writing to a file that doesn't exist creates the file.+Writing to a file that already exists overwrites the file.+Writing to a file at path that doesn't exist creates the necessary directories.++**Arguments**:++- `path`: Path to the file+- `data`: Data to write to the file, can be a `str`, `bytes`, or `IO`.+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request in **seconds**++**Returns**:++Information about the written file+++### write\_files++```python+def write_files(files: List[WriteEntry],+ user: Username = "user",+ request_timeout: Optional[float] = None) -> List[WriteInfo]+```++Writes a list of files to the filesystem.++When writing to a file that doesn't exist, the file will get created.+When writing to a file that already exists, the file will get overwritten.+When writing to a file that's in a directory that doesn't exist, you'll get an error.++**Arguments**:++- `files`: list of files to write as `WriteEntry` objects, each containing `path` and `data`+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request++**Returns**:++Information about the written files+++### list++```python+def list(path: str,+ depth: Optional[int] = 1,+ user: Username = "user",+ request_timeout: Optional[float] = None) -> List[EntryInfo]+```++List entries in a directory.++**Arguments**:++- `path`: Path to the directory+- `depth`: Depth of the directory to list+- `user`: Run the operation as this user+- `request_timeout`: Timeout for the request in **seconds**++**Returns**:++List of entries in the directory+++### exists++```python+def exists(path: str,+ user: Username = "user",+ 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: Username = "user",+ 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: Username = "user",+ 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: Username = "user",+ 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: Username = "user",+ 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: Username = "user",+ 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.+++### 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\_\_++```python+def __init__(**opts: Unpack[SandboxOpts])+```++: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**:++- `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++```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+```++Create a new sandbox.++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**:++A Sandbox instance for the new sandbox+Use this method instead of using the constructor to create a new sandbox.+++### connect++```python+@overload+def connect(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**:++- `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+@classmethod+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 = Sandbox.create()+Sandbox.beta_pause(sandbox.sandbox_id)++same_sandbox = Sandbox.connect(sandbox.sandbox_id)+```+++### connect++```python+@class_method_variant("_cls_connect")+def connect(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**:++- `timeout`: Timeout for the sandbox in **seconds**++**Returns**:++A running sandbox instance+@example+```python+sandbox = Sandbox.create()+sandbox.beta_pause()++same_sandbox = sandbox.connect()+```+++### kill++```python+@overload+def kill(**opts: Unpack[ApiParams]) -> bool+```++Kill the sandbox.++**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**:++- `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")+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+++### set\_timeout++```python+@overload+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**+++### set\_timeout++```python+@overload+@staticmethod+def set_timeout(sandbox_id: str, timeout: int,+ **opts: Unpack[ApiParams]) -> None+```++Set the timeout of the sandbox specified by sandbox ID.++After the timeout expires, the sandbox will be automatically killed.+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.++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**+++### set\_timeout++```python+@class_method_variant("_cls_set_timeout")+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**+++### 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**:++Sandbox info+++### get\_info++```python+@overload+@staticmethod+def get_info(sandbox_id: str, **opts: Unpack[ApiParams]) -> SandboxInfo+```++Get sandbox information like sandbox ID, template, metadata, started at/end at date.++**Arguments**:++- `sandbox_id`: Sandbox ID++**Returns**:++Sandbox info+++### get\_info++```python+@class_method_variant("_cls_get_info")+def get_info(**opts: Unpack[ApiParams]) -> SandboxInfo+```++Get sandbox information like sandbox ID, template, metadata, started at/end at date.++**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**:++- `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+++### get\_metrics++```python+@overload+@staticmethod+def get_metrics(sandbox_id: str,+ start: Optional[datetime.datetime] = None,+ end: Optional[datetime.datetime] = None,+ **opts: Unpack[ApiParams]) -> List[SandboxMetrics]+```++Get the metrics of the sandbox specified by sandbox ID.++**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**:++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]+```++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+@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+```++[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**:++- `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+@overload+def beta_pause(**opts: Unpack[ApiParams]) -> None+```++[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**:++- `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**:++Sandbox ID that can be used to resume the sandbox+diff --git a/packages/python-sdk/package.json b/packages/python-sdk/package.jsonindex 6db55e95a..0a85cb421 100644--- a/packages/python-sdk/package.json+++ b/packages/python-sdk/package.json@@ -1,7 +1,7 @@{"name": "@e2b/python-sdk","private": true,- "version": "2.2.4",+ "version": "2.2.5","scripts": {"example": "poetry run python example.py","test": "poetry run pytest -n 4 --verbose -x",diff --git a/packages/python-sdk/pyproject.toml b/packages/python-sdk/pyproject.tomlindex b9e50529f..0602af429 100644--- a/packages/python-sdk/pyproject.toml+++ b/packages/python-sdk/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "e2b"-version = "2.2.4"+version = "2.2.5"description = "E2B SDK that give agents cloud environments"authors = ["e2b <[email protected]>"]license = "MIT"