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]2822c7bec04e
diff --git a/.changeset/tiny-ways-return.md b/.changeset/tiny-ways-return.md
deleted file mode 100644
index ee8d4a391..000000000
--- a/.changeset/tiny-ways-return.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'e2b': patch
----
-
-changed type of SandboxApiOpts
diff --git a/apps/web/package.json b/apps/web/package.json
index ebf7eaee2..26f82e3c5 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -41,7 +41,7 @@
"autoprefixer": "^10.4.7",
"class-variance-authority": "^0.7.0",
"clsx": "^1.2.1",
- "e2b": "^1.2.4",
+ "e2b": "^1.2.5",
"fast-glob": "^3.3.0",
"fast-xml-parser": "4.4.1",
"flexsearch": "^0.7.31",
diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/commands/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/commands/page.mdx
new file mode 100644
index 000000000..41f75547a
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/commands/page.mdx
@@ -0,0 +1,483 @@
+### Commands
+
+Module for starting and interacting with commands in the sandbox.
+
+#### Constructors
+
+```ts
+new Commands(transport: Transport, connectionConfig: ConnectionConfig): Commands
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `transport` | `Transport` |
+| `connectionConfig` | `ConnectionConfig` |
+
+###### Returns
+
+`Commands`
+
+#### Methods
+
+### connect()
+
+```ts
+connect(pid: number, opts?: CommandConnectOpts): Promise<CommandHandle>
+```
+
+Connect to a running command.
+You can use CommandHandle.wait to wait for the command to finish and get execution results.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `pid` | `number` | process ID of the command to connect to. You can get the list of running commands using Commands.list. |
+| `opts`? | `CommandConnectOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`CommandHandle`\>
+
+`CommandHandle` handle to interact with the running command.
+
+### kill()
+
+```ts
+kill(pid: number, opts?: CommandRequestOpts): Promise<boolean>
+```
+
+Kill a running command specified by its process ID.
+It uses `SIGKILL` signal to kill the command.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `pid` | `number` | process ID of the command. You can get the list of running commands using Commands.list. |
+| `opts`? | `CommandRequestOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`boolean`\>
+
+`true` if the command was killed, `false` if the command was not found.
+
+### list()
+
+```ts
+list(opts?: CommandRequestOpts): Promise<ProcessInfo[]>
+```
+
+List all running commands and PTY sessions.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `opts`? | `CommandRequestOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`ProcessInfo`[]\>
+
+list of running commands and PTY sessions.
+
+### run()
+
+###### run(cmd, opts)
+
+```ts
+run(cmd: string, opts?: CommandStartOpts & object): Promise<CommandResult>
+```
+
+Start a new command and wait until it finishes executing.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `cmd` | `string` | command to execute. |
+| `opts`? | `CommandStartOpts` & `object` | options for starting the command. |
+
+###### Returns
+
+`Promise`\<`CommandResult`\>
+
+`CommandResult` result of the command execution.
+
+###### run(cmd, opts)
+
+```ts
+run(cmd: string, opts?: CommandStartOpts & object): Promise<CommandHandle>
+```
+
+Start a new command in the background.
+You can use CommandHandle.wait to wait for the command to finish and get its result.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `cmd` | `string` | command to execute. |
+| `opts`? | `CommandStartOpts` & `object` | options for starting the command |
+
+###### Returns
+
+`Promise`\<`CommandHandle`\>
+
+`CommandHandle` handle to interact with the running command.
+
+### sendStdin()
+
+```ts
+sendStdin(
+ pid: number,
+ data: string,
+opts?: CommandRequestOpts): Promise<void>
+```
+
+Send data to command stdin.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `pid` | `number` | process ID of the command. You can get the list of running commands using Commands.list. |
+| `data` | `string` | data to send to the command. |
+| `opts`? | `CommandRequestOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`void`\>
+
+***
+
+### Pty
+
+Module for interacting with PTYs (pseudo-terminals) in the sandbox.
+
+#### Constructors
+
+```ts
+new Pty(transport: Transport, connectionConfig: ConnectionConfig): Pty
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `transport` | `Transport` |
+| `connectionConfig` | `ConnectionConfig` |
+
+###### Returns
+
+`Pty`
+
+#### Methods
+
+### create()
+
+```ts
+create(opts: PtyCreateOpts): Promise<CommandHandle>
+```
+
+Create a new PTY (pseudo-terminal).
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `opts` | `PtyCreateOpts` | options for creating the PTY. |
+
+###### Returns
+
+`Promise`\<`CommandHandle`\>
+
+handle to interact with the PTY.
+
+### kill()
+
+```ts
+kill(pid: number, opts?: Pick<ConnectionOpts, "requestTimeoutMs">): Promise<boolean>
+```
+
+Kill a running PTY specified by process ID.
+It uses `SIGKILL` signal to kill the PTY.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `pid` | `number` | process ID of the PTY. |
+| `opts`? | `Pick`\<`ConnectionOpts`, `"requestTimeoutMs"`\> | connection options. |
+
+###### Returns
+
+`Promise`\<`boolean`\>
+
+`true` if the PTY was killed, `false` if the PTY was not found.
+
+### resize()
+
+```ts
+resize(
+ pid: number,
+ size: object,
+opts?: Pick<ConnectionOpts, "requestTimeoutMs">): Promise<void>
+```
+
+Resize PTY.
+Call this when the terminal window is resized and the number of columns and rows has changed.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `pid` | `number` | process ID of the PTY. |
+| `size` | `object` | new size of the PTY. |
+| `size.cols` | `number` | - |
+| `size.rows`? | `number` | - |
+| `opts`? | `Pick`\<`ConnectionOpts`, `"requestTimeoutMs"`\> | connection options. |
+
+###### Returns
+
+`Promise`\<`void`\>
+
+### sendInput()
+
+```ts
+sendInput(
+ pid: number,
+ data: Uint8Array,
+opts?: Pick<ConnectionOpts, "requestTimeoutMs">): Promise<void>
+```
+
+Send input to a PTY.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `pid` | `number` | process ID of the PTY. |
+| `data` | `Uint8Array` | input data to send to the PTY. |
+| `opts`? | `Pick`\<`ConnectionOpts`, `"requestTimeoutMs"`\> | connection options. |
+
+###### Returns
+
+`Promise`\<`void`\>
+
+## Interfaces
+
+### CommandRequestOpts
+
+Options for sending a command request.
+
+#### Extended by
+
+- `CommandStartOpts`
+
+#### Properties
+
+### requestTimeoutMs?
+
+```ts
+optional requestTimeoutMs: number;
+```
+
+Timeout for requests to the API in **milliseconds**.
+
+###### Default
+
+```ts
+30_000 // 30 seconds
+```
+
+***
+
+### CommandStartOpts
+
+Options for starting a new command.
+
+#### Properties
+
+### background?
+
+```ts
+optional background: boolean;
+```
+
+If true, starts command in the background and the method returns immediately.
+You can use CommandHandle.wait to wait for the command to finish.
+
+### cwd?
+
+```ts
+optional cwd: string;
+```
+
+Working directory for the command.
+
+###### Default
+
+```ts
+// home directory of the user used to start the command
+```
+
+### envs?
+
+```ts
+optional envs: Record<string, string>;
+```
+
+Environment variables used for the command.
+
+This overrides the default environment variables from `Sandbox` constructor.
+
+###### Default
+
+`{}`
+
+### onStderr()?
+
+```ts
+optional onStderr: (data: string) => void | Promise<void>;
+```
+
+Callback for command stderr output.
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `data` | `string` |
+
+###### Returns
+
+`void` \| `Promise`\<`void`\>
+
+### onStdout()?
+
+```ts
+optional onStdout: (data: string) => void | Promise<void>;
+```
+
+Callback for command stdout output.
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `data` | `string` |
+
+###### Returns
+
+`void` \| `Promise`\<`void`\>
+
+### requestTimeoutMs?
+
+```ts
+optional requestTimeoutMs: number;
+```
+
+Timeout for requests to the API in **milliseconds**.
+
+###### Default
+
+```ts
+30_000 // 30 seconds
+```
+
+### timeoutMs?
+
+```ts
+optional timeoutMs: number;
+```
+
+Timeout for the command in **milliseconds**.
+
+###### Default
+
+```ts
+60_000 // 60 seconds
+```
+
+### user?
+
+```ts
+optional user: Username;
+```
+
+User to run the command as.
+
+###### Default
+
+`user`
+
+***
+
+### ProcessInfo
+
+Information about a command, PTY session or start command running in the sandbox as process.
+
+#### Properties
+
+### args
+
+```ts
+args: string[];
+```
+
+Command arguments.
+
+### cmd
+
+```ts
+cmd: string;
+```
+
+Command that was executed.
+
+### cwd?
+
+```ts
+optional cwd: string;
+```
+
+Executed command working directory.
+
+### envs
+
+```ts
+envs: Record<string, string>;
+```
+
+Environment variables used for the command.
+
+### pid
+
+```ts
+pid: number;
+```
+
+Process ID.
+
+### tag?
+
+```ts
+optional tag: string;
+```
+
+Custom tag used for identifying special commands like start command in the custom template.
+
+## Type Aliases
+
+### CommandConnectOpts
+
+```ts
+type CommandConnectOpts: Pick<CommandStartOpts, "onStderr" | "onStdout" | "timeoutMs"> & CommandRequestOpts;
+```
+
+Options for connecting to a command.
diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/errors/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/errors/page.mdx
new file mode 100644
index 000000000..c5aa2cc14
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/errors/page.mdx
@@ -0,0 +1,211 @@
+### AuthenticationError
+
+Thrown when authentication fails.
+
+#### Constructors
+
+```ts
+new AuthenticationError(message: any): AuthenticationError
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `message` | `any` |
+
+###### Returns
+
+`AuthenticationError`
+
+***
+
+### InvalidArgumentError
+
+Thrown when an invalid argument is provided.
+
+#### Constructors
+
+```ts
+new InvalidArgumentError(message: string): InvalidArgumentError
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `message` | `string` |
+
+###### Returns
+
+`InvalidArgumentError`
+
+***
+
+### NotEnoughSpaceError
+
+Thrown when there is not enough disk space.
+
+#### Constructors
+
+```ts
+new NotEnoughSpaceError(message: string): NotEnoughSpaceError
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `message` | `string` |
+
+###### Returns
+
+`NotEnoughSpaceError`
+
+***
+
+### NotFoundError
+
+Thrown when a resource is not found.
+
+#### Constructors
+
+```ts
+new NotFoundError(message: string): NotFoundError
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `message` | `string` |
+
+###### Returns
+
+`NotFoundError`
+
+***
+
+### RateLimitError
+
+Thrown when the API rate limit is exceeded.
+
+#### Constructors
+
+```ts
+new RateLimitError(message: any): RateLimitError
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `message` | `any` |
+
+###### Returns
+
+`RateLimitError`
+
+***
+
+### SandboxError
+
+Base class for all sandbox errors.
+
+Thrown when general sandbox errors occur.
+
+#### Extended by
+
+- `TimeoutError`
+- `InvalidArgumentError`
+- `NotEnoughSpaceError`
+- `NotFoundError`
+- `AuthenticationError`
+- `TemplateError`
+- `RateLimitError`
+
+#### Constructors
+
+```ts
+new SandboxError(message: any): SandboxError
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `message` | `any` |
+
+###### Returns
+
+`SandboxError`
+
+***
+
+### TemplateError
+
+Thrown when the template uses old envd version. It isn't compatible with the new SDK.
+
+#### Constructors
+
+```ts
+new TemplateError(message: string): TemplateError
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `message` | `string` |
+
+###### Returns
+
+`TemplateError`
+
+***
+
+### TimeoutError
+
+Thrown when a timeout error occurs.
+
+The [unavailable] error type is caused by sandbox timeout.
+
+The [canceled] error type is caused by exceeding request timeout.
+
+The [deadline_exceeded] error type is caused by exceeding the timeout for command execution, watch, etc.
+
+The [unknown] error type is sometimes caused by the sandbox timeout when the request is not processed correctly.
+
+#### Constructors
+
+```ts
+new TimeoutError(message: string): TimeoutError
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `message` | `string` |
+
+###### Returns
+
+`TimeoutError`
+
+## Functions
+
+### formatSandboxTimeoutError()
+
+```ts
+function formatSandboxTimeoutError(message: string): TimeoutError
+```
+
+#### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `message` | `string` |
+
+#### Returns
+
+`TimeoutError`
diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/filesystem/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/filesystem/page.mdx
new file mode 100644
index 000000000..71b13f788
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/filesystem/page.mdx
@@ -0,0 +1,469 @@
+### FileType
+
+Sandbox filesystem object type.
+
+#### Enumeration Members
+
+| Enumeration Member | Value | Description |
+| ------ | ------ | ------ |
+| `DIR` | `"dir"` | Filesystem object is a directory. |
+| `FILE` | `"file"` | Filesystem object is a file. |
+
+## Classes
+
+### Filesystem
+
+Module for interacting with the sandbox filesystem.
+
+#### Constructors
+
+```ts
+new Filesystem(
+ transport: Transport,
+ envdApi: EnvdApiClient,
+ connectionConfig: ConnectionConfig): Filesystem
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `transport` | `Transport` |
+| `envdApi` | `EnvdApiClient` |
+| `connectionConfig` | `ConnectionConfig` |
+
+###### Returns
+
+`Filesystem`
+
+#### Methods
+
+### exists()
+
+```ts
+exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>
+```
+
+Check if a file or a directory exists.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to a file or a directory |
+| `opts`? | `FilesystemRequestOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`boolean`\>
+
+`true` if the file or directory exists, `false` otherwise
+
+### list()
+
+```ts
+list(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo[]>
+```
+
+List entries in a directory.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to the directory. |
+| `opts`? | `FilesystemRequestOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`EntryInfo`[]\>
+
+list of entries in the sandbox filesystem directory.
+
+### makeDir()
+
+```ts
+makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean>
+```
+
+Create a new directory and all directories along the way if needed on the specified path.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to a new directory. For example '/dirA/dirB' when creating 'dirB'. |
+| `opts`? | `FilesystemRequestOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`boolean`\>
+
+`true` if the directory was created, `false` if it already exists.
+
+### read()
+
+###### read(path, opts)
+
+```ts
+read(path: string, opts?: FilesystemRequestOpts & object): Promise<string>
+```
+
+Read file content as a `string`.
+
+You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to the file. |
+| `opts`? | `FilesystemRequestOpts` & `object` | connection options. |
+
+###### Returns
+
+`Promise`\<`string`\>
+
+file content as string
+
+###### read(path, opts)
+
+```ts
+read(path: string, opts?: FilesystemRequestOpts & object): Promise<Uint8Array>
+```
+
+Read file content as a `Uint8Array`.
+
+You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to the file. |
+| `opts`? | `FilesystemRequestOpts` & `object` | connection options. |
+
+###### Returns
+
+`Promise`\<`Uint8Array`\>
+
+file content as `Uint8Array`
+
+###### read(path, opts)
+
+```ts
+read(path: string, opts?: FilesystemRequestOpts & object): Promise<Blob>
+```
+
+Read file content as a `Blob`.
+
+You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to the file. |
+| `opts`? | `FilesystemRequestOpts` & `object` | connection options. |
+
+###### Returns
+
+`Promise`\<`Blob`\>
+
+file content as `Blob`
+
+###### read(path, opts)
+
+```ts
+read(path: string, opts?: FilesystemRequestOpts & object): Promise<ReadableStream<Uint8Array>>
+```
+
+Read file content as a `ReadableStream`.
+
+You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to the file. |
+| `opts`? | `FilesystemRequestOpts` & `object` | connection options. |
+
+###### Returns
+
+`Promise`\<`ReadableStream`\<`Uint8Array`\>\>
+
+file content as `ReadableStream`
+
+### remove()
+
+```ts
+remove(path: string, opts?: FilesystemRequestOpts): Promise<void>
+```
+
+Remove a file or directory.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to a file or directory. |
+| `opts`? | `FilesystemRequestOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`void`\>
+
+### rename()
+
+```ts
+rename(
+ oldPath: string,
+ newPath: string,
+opts?: FilesystemRequestOpts): Promise<EntryInfo>
+```
+
+Rename a file or directory.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `oldPath` | `string` | path to the file or directory to rename. |
+| `newPath` | `string` | new path for the file or directory. |
+| `opts`? | `FilesystemRequestOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`EntryInfo`\>
+
+information about renamed file or directory.
+
+### watchDir()
+
+```ts
+watchDir(
+ path: string,
+ onEvent: (event: FilesystemEvent) => void | Promise<void>,
+opts?: WatchOpts & object): Promise<WatchHandle>
+```
+
+Start watching a directory for filesystem events.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to directory to watch. |
+| `onEvent` | (`event`: `FilesystemEvent`) => `void` \| `Promise`\<`void`\> | callback to call when an event in the directory occurs. |
+| `opts`? | `WatchOpts` & `object` | connection options. |
+
+###### Returns
+
+`Promise`\<`WatchHandle`\>
+
+`WatchHandle` object for stopping watching directory.
+
+### write()
+
+###### write(path, data, opts)
+
+```ts
+write(
+ path: string,
+ data: string | ArrayBuffer | Blob | ReadableStream<any>,
+opts?: FilesystemRequestOpts): Promise<EntryInfo>
+```
+
+Write content to a file.
+
+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.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to file. |
+| `data` | `string` \| `ArrayBuffer` \| `Blob` \| `ReadableStream`\<`any`\> | data to write to the file. Data can be a string, `ArrayBuffer`, `Blob`, or `ReadableStream`. |
+| `opts`? | `FilesystemRequestOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`EntryInfo`\>
+
+information about the written file
+
+###### write(files, opts)
+
+```ts
+write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<EntryInfo[]>
+```
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `files` | `WriteEntry`[] |
+| `opts`? | `FilesystemRequestOpts` |
+
+###### Returns
+
+`Promise`\<`EntryInfo`[]\>
+
+## Interfaces
+
+### EntryInfo
+
+Sandbox filesystem object information.
+
+#### Properties
+
+### name
+
+```ts
+name: string;
+```
+
+Name of the filesystem object.
+
+### path
+
+```ts
+path: string;
+```
+
+Path to the filesystem object.
+
+### type?
+
+```ts
+optional type: FileType;
+```
+
+Type of the filesystem object.
+
+***
+
+### FilesystemRequestOpts
+
+Options for the sandbox filesystem operations.
+
+#### Extended by
+
+- `WatchOpts`
+
+#### Properties
+
+### requestTimeoutMs?
+
+```ts
+optional requestTimeoutMs: number;
+```
+
+Timeout for requests to the API in **milliseconds**.
+
+###### Default
+
+```ts
+30_000 // 30 seconds
+```
+
+### user?
+
+```ts
+optional user: Username;
+```
+
+User to use for the operation in the sandbox.
+This affects the resolution of relative paths and ownership of the created filesystem objects.
+
+***
+
+### WatchOpts
+
+Options for watching a directory.
+
+#### Properties
+
+### onExit()?
+
+```ts
+optional onExit: (err?: Error) => void | Promise<void>;
+```
+
+Callback to call when the watch operation stops.
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `err`? | `Error` |
+
+###### Returns
+
+`void` \| `Promise`\<`void`\>
+
+### recursive?
+
+```ts
+optional recursive: boolean;
+```
+
+Watch the directory recursively
+
+### requestTimeoutMs?
+
+```ts
+optional requestTimeoutMs: number;
+```
+
+Timeout for requests to the API in **milliseconds**.
+
+###### Default
+
+```ts
+30_000 // 30 seconds
+```
+
+### timeoutMs?
+
+```ts
+optional timeoutMs: number;
+```
+
+Timeout for the watch operation in **milliseconds**.
+You can pass `0` to disable the timeout.
+
+###### Default
+
+```ts
+60_000 // 60 seconds
+```
+
+### user?
+
+```ts
+optional user: Username;
+```
+
+User to use for the operation in the sandbox.
+This affects the resolution of relative paths and ownership of the created filesystem objects.
+
+## Type Aliases
+
+### WriteEntry
+
+```ts
+type WriteEntry: object;
+```
+
+#### Type declaration
+
+| Name | Type |
+| ------ | ------ |
+| `data` | `string` \| `ArrayBuffer` \| `Blob` \| `ReadableStream` |
+| `path` | `string` |
diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/sandbox/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/sandbox/page.mdx
new file mode 100644
index 000000000..2662b633c
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/js-sdk/v1.2.5/sandbox/page.mdx
@@ -0,0 +1,547 @@
+### Sandbox
+
+E2B cloud sandbox is a secure and isolated cloud environment.
+
+The sandbox allows you to:
+- Access Linux OS
+- Create, list, and delete files and directories
+- Run commands
+- Run isolated code
+- Access the internet
+
+Check docs here.
+
+Use Sandbox.create to create a new sandbox.
+
+#### Example
+
+```ts
+import { Sandbox } from 'e2b'
+
+const sandbox = await Sandbox.create()
+```
+
+#### Properties
+
+| Property | Modifier | Type | Description |
+| ------ | ------ | ------ | ------ |
+| `commands` | `readonly` | `Commands` | Module for running commands in the sandbox |
+| `files` | `readonly` | `Filesystem` | Module for interacting with the sandbox filesystem |
+| `pty` | `readonly` | `Pty` | Module for interacting with the sandbox pseudo-terminals |
+| `sandboxId` | `readonly` | `string` | Unique identifier of the sandbox. |
+
+#### Methods
+
+### downloadUrl()
+
+```ts
+downloadUrl(path: string): string
+```
+
+Get the URL to download a file from the sandbox.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path` | `string` | path to the file to download. |
+
+###### Returns
+
+`string`
+
+URL for downloading file.
+
+### getHost()
+
+```ts
+getHost(port: number): string
+```
+
+Get the host address for the specified sandbox port.
+You can then use this address to connect to the sandbox port from outside the sandbox via HTTP or WebSocket.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `port` | `number` | number of the port in the sandbox. |
+
+###### Returns
+
+`string`
+
+host address of the sandbox port.
+
+###### Example
+
+```ts
+const sandbox = await Sandbox.create()
+// Start an HTTP server
+await sandbox.commands.exec('python3 -m http.server 3000')
+// Get the hostname of the HTTP server
+const serverURL = sandbox.getHost(3000)
+```
+
+### getInfo()
+
+```ts
+getInfo(opts?: Pick<SandboxOpts, "requestTimeoutMs">): Promise<SandboxInfo>
+```
+
+Get sandbox information like sandbox ID, template, metadata, started at/end at date.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `opts`? | `Pick`\<`SandboxOpts`, `"requestTimeoutMs"`\> | connection options. |
+
+###### Returns
+
+`Promise`\<`SandboxInfo`\>
+
+information about the sandbox
+
+### isRunning()
+
+```ts
+isRunning(opts?: Pick<ConnectionOpts, "requestTimeoutMs">): Promise<boolean>
+```
+
+Check if the sandbox is running.
+
+###### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `opts`? | `Pick`\<`ConnectionOpts`, `"requestTimeoutMs"`\> |
+
+###### Returns
+
+`Promise`\<`boolean`\>
+
+`true` if the sandbox is running, `false` otherwise.
+
+###### Example
+
+```ts
+const sandbox = await Sandbox.create()
+await sandbox.isRunning() // Returns true
+
+await sandbox.kill()
+await sandbox.isRunning() // Returns false
+```
+
+### kill()
+
+```ts
+kill(opts?: Pick<SandboxOpts, "requestTimeoutMs">): Promise<void>
+```
+
+Kill the sandbox.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `opts`? | `Pick`\<`SandboxOpts`, `"requestTimeoutMs"`\> | connection options. |
+
+###### Returns
+
+`Promise`\<`void`\>
+
+### setTimeout()
+
+```ts
+setTimeout(timeoutMs: number, opts?: Pick<SandboxOpts, "requestTimeoutMs">): Promise<void>
+```
+
+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 `.setTimeout`.
+Maximum time a sandbox can be kept alive is 24 hours (86_400_000 milliseconds) for Pro users and 1 hour (3_600_000 milliseconds) for Hobby users.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `timeoutMs` | `number` | timeout in **milliseconds**. |
+| `opts`? | `Pick`\<`SandboxOpts`, `"requestTimeoutMs"`\> | connection options. |
+
+###### Returns
+
+`Promise`\<`void`\>
+
+### uploadUrl()
+
+```ts
+uploadUrl(path?: string): string
+```
+
+Get the URL to upload a file to the sandbox.
+
+You have to send a POST request to this URL with the file as multipart/form-data.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `path`? | `string` | the directory where to upload the file, defaults to user's home directory. |
+
+###### Returns
+
+`string`
+
+URL for uploading file.
+
+### connect()
+
+```ts
+static connect<S>(
+ this: S,
+ sandboxId: string,
+opts?: Omit<SandboxOpts, "timeoutMs" | "metadata" | "envs">): Promise<InstanceType<S>>
+```
+
+Connect to an existing sandbox.
+With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).
+
+###### Type Parameters
+
+| Type Parameter |
+| ------ |
+| `S` *extends* *typeof* `Sandbox` |
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `this` | `S` | - |
+| `sandboxId` | `string` | sandbox ID. |
+| `opts`? | `Omit`\<`SandboxOpts`, `"timeoutMs"` \| `"metadata"` \| `"envs"`\> | connection options. |
+
+###### Returns
+
+`Promise`\<`InstanceType`\<`S`\>\>
+
+sandbox instance for the existing sandbox.
+
+###### Example
+
+```ts
+const sandbox = await Sandbox.create()
+const sandboxId = sandbox.sandboxId
+
+// Connect to the same sandbox.
+const sameSandbox = await Sandbox.connect(sandboxId)
+```
+
+### create()
+
+###### create(this, opts)
+
+```ts
+static create<S>(this: S, opts?: SandboxOpts): Promise<InstanceType<S>>
+```
+
+Create a new sandbox from the default `base` 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
+
+### getInfo()
+
+```ts
+static getInfo(sandboxId: string, opts?: SandboxApiOpts): Promise<SandboxInfo>
+```
+
+Get sandbox information like sandbox ID, template, metadata, started at/end at date.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `sandboxId` | `string` | sandbox ID. |
+| `opts`? | `SandboxApiOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`SandboxInfo`\>
+
+sandbox information.
+
+### kill()
+
+```ts
+static kill(sandboxId: string, opts?: SandboxApiOpts): Promise<boolean>
+```
+
+Kill the sandbox specified by sandbox ID.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `sandboxId` | `string` | sandbox ID. |
+| `opts`? | `SandboxApiOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`boolean`\>
+
+`true` if the sandbox was found and killed, `false` otherwise.
+
+### list()
+
+```ts
+static list(opts?: SandboxListOpts): Promise<SandboxInfo[]>
+```
+
+List all running sandboxes.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `opts`? | `SandboxListOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`SandboxInfo`[]\>
+
+list of running sandboxes.
+
+### setTimeout()
+
+```ts
+static setTimeout(
+ sandboxId: string,
+ timeoutMs: number,
+opts?: SandboxApiOpts): Promise<void>
+```
+
+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 Sandbox.setTimeout.
+
+Maximum time a sandbox can be kept alive is 24 hours (86_400_000 milliseconds) for Pro users and 1 hour (3_600_000 milliseconds) for Hobby users.
+
+###### Parameters
+
+| Parameter | Type | Description |
+| ------ | ------ | ------ |
+| `sandboxId` | `string` | sandbox ID. |
+| `timeoutMs` | `number` | timeout in **milliseconds**. |
+| `opts`? | `SandboxApiOpts` | connection options. |
+
+###### Returns
+
+`Promise`\<`void`\>
+
+## Interfaces
+
+### SandboxOpts
+
+Options for creating a new Sandbox.
+
+#### Properties
+
+### accessToken?
+
+```ts
+optional accessToken: string;
+```
+
+E2B access token to use for authentication.
+
+###### Default
+
+```ts
+E2B_ACCESS_TOKEN // environment variable
+```
+
+### apiKey?
+
+```ts
+optional apiKey: string;
+```
+
+E2B API key to use for authentication.
+
+###### Default
+
+```ts
+E2B_API_KEY // environment variable
+```
+
+### debug?
+
+```ts
+optional debug: boolean;
+```
+
+**`Internal`**
+
+If true the SDK starts in the debug mode and connects to the local envd API server.
+
+###### Default
+
+E2B_DEBUG // environment variable or `false`
+
+### domain?
+
+```ts
+optional domain: string;
+```
+
+Domain to use for the API.
+
+###### Default
+
+E2B_DOMAIN // environment variable or `e2b.app`
+
+### envs?
+
+```ts
+optional envs: Record<string, string>;
+```
+
+Custom environment variables for the sandbox.
+
+Used when executing commands and code in the sandbox.
+Can be overridden with the `envs` argument when executing commands or code.
+
+###### Default
+
+```ts
+{}
+```
+
+### headers?
+
+```ts
+optional headers: Record<string, string>;
+```
+
+Additional headers to send with the request.
+
+### logger?
+
+```ts
+optional logger: Logger;
+```
+
+Logger to use for logging messages. It can accept any object that implements `Logger` interface—for example, console.
+
+### metadata?
+
+```ts
+optional metadata: Record<string, string>;
+```
+
+Custom metadata for the sandbox.
+
+###### Default
+
+```ts
+{}
+```
+
+### requestTimeoutMs?
+
+```ts
+optional requestTimeoutMs: number;
+```
+
+Timeout for requests to the API in **milliseconds**.
+
+###### Default
+
+```ts
+30_000 // 30 seconds
+```
+
+### timeoutMs?
+
+```ts
+optional timeoutMs: number;
+```
+
+Timeout for the sandbox in **milliseconds**.
+Maximum time a sandbox can be kept alive is 24 hours (86_400_000 milliseconds) for Pro users and 1 hour (3_600_000 milliseconds) for Hobby users.
+
+###### Default
+
+```ts
+300_000 // 5 minutes
+```
diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.3/sandbox_async/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.3/sandbox_async/page.mdx
index d5a432638..9ea26a382 100644
--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.3/sandbox_async/page.mdx
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.3/sandbox_async/page.mdx
@@ -1,378 +1,206 @@
-
-
-## Filesystem
+## AsyncCommandHandle
```python
-class Filesystem()
+class AsyncCommandHandle()
```
-Module for interacting with the filesystem in the sandbox.
+Command execution handle.
+It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
-### read
+
+### pid
```python
-@overload
-async def read(path: str,
- format: Literal["text"] = "text",
- user: Username = "user",
- request_timeout: Optional[float] = None) -> str
+@property
+def pid()
```
-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`
+Command process ID.
-### read
+### stdout
```python
-@overload
-async def read(path: str,
- format: Literal["bytes"],
- user: Username = "user",
- request_timeout: Optional[float] = None) -> bytearray
+@property
+def stdout()
```
-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`
+Command stdout output.
-### read
+### stderr
```python
-@overload
-async def read(
- path: str,
- format: Literal["stream"],
- user: Username = "user",
- request_timeout: Optional[float] = None) -> AsyncIterator[bytes]
+@property
+def stderr()
```
-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]`
+Command stderr output.
-### write
+### error
```python
-@overload
-async def write(path: str,
- data: Union[str, bytes, IO],
- user: Username = "user",
- request_timeout: Optional[float] = None) -> EntryInfo
+@property
+def error()
```
-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
+Command execution error message.
-### write
+### exit\_code
```python
-@overload
-async def write(files: List[WriteEntry],
- user: Optional[Username] = "user",
- request_timeout: Optional[float] = None) -> List[EntryInfo]
+@property
+def exit_code()
```
-Writes multiple files.
-
-**Arguments**:
-
-- `files`: list of files to write
-- `user`: Run the operation as this user
-- `request_timeout`: Timeout for the request
+Command execution exit code.
-**Returns**:
+`0` if the command finished successfully.
-Information about the written files
+It is `None` if the command is still running.
-### write
+### disconnect
```python
-async def write(
- path_or_files: Union[str, List[WriteEntry]],
- data_or_user: Union[str, bytes, IO, Username] = "user",
- user_or_request_timeout: Optional[Union[float, Username]] = None,
- request_timeout_or_none: Optional[float] = None
-) -> Union[EntryInfo, List[EntryInfo]]
+async def disconnect() -> None
```
-Writes content to a file on the path.
-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.
+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.
-### list
+
+### wait
```python
-async def list(path: str,
- user: Username = "user",
- request_timeout: Optional[float] = None) -> List[EntryInfo]
+async def wait() -> CommandResult
```
-List entries in a directory.
-
-**Arguments**:
+Wait for the command to finish and return the result.
-- `path`: Path to the directory
-- `user`: Run the operation as this user
-- `request_timeout`: Timeout for the request in **seconds**
+If the command exits with a non-zero exit code, it throws a `CommandExitException`.
**Returns**:
-List of entries in the directory
+`CommandResult` result of command execution
-### exists
+### kill
```python
-async def exists(path: str,
- user: Username = "user",
- request_timeout: Optional[float] = None) -> bool
+async def kill() -> bool
```
-Check if a file or a directory exists.
-
-**Arguments**:
+Kills the command.
-- `path`: Path to a file or a directory
-- `user`: Run the operation as this user
-- `request_timeout`: Timeout for the request in **seconds**
+It uses `SIGKILL` signal to kill the command
**Returns**:
-`True` if the file or directory exists, `False` otherwise
+`True` if the command was killed successfully, `False` if the command was not found
-### 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
+## Pty
```python
-async def rename(old_path: str,
- new_path: str,
- user: Username = "user",
- request_timeout: Optional[float] = None) -> EntryInfo
+class Pty()
```
-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
+Module for interacting with PTYs (pseudo-terminals) in the sandbox.
-### make\_dir
+### kill
```python
-async def make_dir(path: str,
- user: Username = "user",
- request_timeout: Optional[float] = None) -> bool
+async def kill(pid: int, request_timeout: Optional[float] = None) -> bool
```
-Create a new directory and all directories along the way if needed on the specified path.
+Kill PTY.
**Arguments**:
-- `path`: Path to a new directory. For example '/dirA/dirB' when creating 'dirB'.
-- `user`: Run the operation as this user
+- `pid`: Process ID of the PTY
- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-`True` if the directory was created, `False` if the directory already exists
+`true` if the PTY was killed, `false` if the PTY was not found
-### watch\_dir
+### send\_stdin
```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
+async def send_stdin(pid: int,
+ data: bytes,
+ request_timeout: Optional[float] = None) -> None
```
-Watch directory for filesystem events.
+Send input to a PTY.
**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
+- `pid`: Process ID of the PTY
+- `data`: Input data to send
- `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
-
-
-
-
-## 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.
-
-
-
-
-## SandboxApi
-
-```python
-class SandboxApi(SandboxApiBase)
-```
-
-
-### list
+### create
```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,
- headers: Optional[Dict[str, str]] = None) -> List[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
```
-List all running sandboxes.
+Start a new PTY (pseudo-terminal).
**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
+- `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**
-- `headers`: Additional headers to send with the request
**Returns**:
-List of running sandboxes
+Handle to interact with the PTY
-### get\_info
+### resize
```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,
- headers: Optional[Dict[str, str]] = None) -> SandboxInfo
+async def resize(pid: int,
+ size: PtySize,
+ request_timeout: Optional[float] = None)
```
-Get the sandbox info.
+Resize PTY.
+
+Call this when the terminal window is resized and the number of columns and rows has changed.
**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 PTY
+- `size`: New size of the PTY
- `request_timeout`: Timeout for the request in **seconds**
-- `headers`: Additional headers to send with the request
-
-**Returns**:
-
-Sandbox info
@@ -538,206 +366,309 @@ You can use `AsyncCommandHandle.wait()` to wait for the command to finish and ge
-## Pty
+## Filesystem
```python
-class Pty()
+class Filesystem()
```
-Module for interacting with PTYs (pseudo-terminals) in the sandbox.
+Module for interacting with the filesystem in the sandbox.
-### kill
+### read
```python
-async def kill(pid: int, request_timeout: Optional[float] = None) -> bool
+@overload
+async def read(path: str,
+ format: Literal["text"] = "text",
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> str
```
-Kill PTY.
+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
+@overload
+async def write(path: str,
+ data: Union[str, bytes, IO],
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> EntryInfo
+```
+
+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
+
+```python
+@overload
+async def write(files: List[WriteEntry],
+ user: Optional[Username] = "user",
+ request_timeout: Optional[float] = None) -> List[EntryInfo]
+```
+
+Writes multiple files.
**Arguments**:
-- `pid`: Process ID of the PTY
-- `request_timeout`: Timeout for the request in **seconds**
+- `files`: list of files to write
+- `user`: Run the operation as this user
+- `request_timeout`: Timeout for the request
**Returns**:
-`true` if the PTY was killed, `false` if the PTY was not found
+Information about the written files
-### send\_stdin
+### write
```python
-async def send_stdin(pid: int,
- data: bytes,
- request_timeout: Optional[float] = None) -> None
+async def write(
+ path_or_files: Union[str, List[WriteEntry]],
+ data_or_user: Union[str, bytes, IO, Username] = "user",
+ user_or_request_timeout: Optional[Union[float, Username]] = None,
+ request_timeout_or_none: Optional[float] = None
+) -> Union[EntryInfo, List[EntryInfo]]
```
-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**
+Writes content to a file on the path.
+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.
-### create
+### list
```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
+async def list(path: str,
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> List[EntryInfo]
```
-Start a new PTY (pseudo-terminal).
+List entries in a directory.
**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**
+- `path`: Path to the directory
+- `user`: Run the operation as this user
- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-Handle to interact with the PTY
+List of entries in the directory
-### resize
+### exists
```python
-async def resize(pid: int,
- size: PtySize,
- request_timeout: Optional[float] = None)
+async def exists(path: str,
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> bool
```
-Resize PTY.
-
-Call this when the terminal window is resized and the number of columns and rows has changed.
+Check if a file or a directory exists.
**Arguments**:
-- `pid`: Process ID of the PTY
-- `size`: New size of the PTY
+- `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
-## AsyncCommandHandle
+### remove
```python
-class AsyncCommandHandle()
+async def remove(path: str,
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> None
```
-Command execution handle.
+Remove a file or a directory.
-It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
+**Arguments**:
+
+- `path`: Path to a file or a directory
+- `user`: Run the operation as this user
+- `request_timeout`: Timeout for the request in **seconds**
-### pid
+### rename
```python
-@property
-def pid()
+async def rename(old_path: str,
+ new_path: str,
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> EntryInfo
```
-Command process ID.
+Rename a file or directory.
+**Arguments**:
-### stdout
+- `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**
-```python
-@property
-def stdout()
-```
+**Returns**:
-Command stdout output.
+Information about the renamed file or directory
-### stderr
+### make\_dir
```python
-@property
-def stderr()
+async def make_dir(path: str,
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> bool
```
-Command stderr output.
+Create a new directory and all directories along the way if needed on the specified path.
+**Arguments**:
-### error
+- `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**
-```python
-@property
-def error()
-```
+**Returns**:
-Command execution error message.
+`True` if the directory was created, `False` if the directory already exists
-### exit\_code
+### watch\_dir
```python
-@property
-def exit_code()
+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
```
-Command execution exit code.
-
-`0` if the command finished successfully.
+Watch directory for filesystem events.
-It is `None` if the command is still running.
+**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
-### disconnect
+**Returns**:
-```python
-async def disconnect() -> None
-```
+`AsyncWatchHandle` object for stopping watching directory
-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
+## AsyncWatchHandle
```python
-async def wait() -> CommandResult
+class AsyncWatchHandle()
```
-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**:
+Handle for watching a directory in the sandbox filesystem.
-`CommandResult` result of command execution
+Use `.stop()` to stop watching the directory.
-### kill
+### stop
```python
-async def kill() -> bool
+async def stop()
```
-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
+Stop watching the directory.
@@ -1016,3 +947,72 @@ Get sandbox information like sandbox ID, template, metadata, started at/end at d
Sandbox info
+
+
+
+## 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,
+ headers: Optional[Dict[str, str]] = 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**
+- `headers`: Additional headers to send with the request
+
+**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,
+ headers: Optional[Dict[str, str]] = 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**
+- `headers`: Additional headers to send with the request
+
+**Returns**:
+
+Sandbox info
+
+
+
diff --git a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.3/sandbox_sync/page.mdx b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.3/sandbox_sync/page.mdx
index db8ec7514..f293d66fe 100644
--- a/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.3/sandbox_sync/page.mdx
+++ b/apps/web/src/app/(docs)/docs/sdk-reference/python-sdk/v1.3.3/sandbox_sync/page.mdx
@@ -1,371 +1,180 @@
-## Filesystem
-
-```python
-class Filesystem()
-```
-
-Module for interacting with the filesystem in the sandbox.
-
-
-### read
+## CommandHandle
```python
-@overload
-def read(path: str,
- format: Literal["text"] = "text",
- user: Username = "user",
- request_timeout: Optional[float] = None) -> str
+class CommandHandle()
```
-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**:
+Command execution handle.
-File content as a `str`
+It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
-### read
+### pid
```python
-@overload
-def read(path: str,
- format: Literal["bytes"],
- user: Username = "user",
- request_timeout: Optional[float] = None) -> bytearray
+@property
+def pid()
```
-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`
+Command process ID.
-### read
+### \_\_iter\_\_
```python
-@overload
-def read(path: str,
- format: Literal["stream"],
- user: Username = "user",
- request_timeout: Optional[float] = None) -> Iterator[bytes]
+def __iter__()
```
-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**
+Iterate over the command output.
**Returns**:
-File content as an `Iterator[bytes]`
+Generator of command outputs
-### write
+### disconnect
```python
-@overload
-def write(path: str,
- data: Union[str, bytes, IO],
- user: Username = "user",
- request_timeout: Optional[float] = None) -> EntryInfo
+def disconnect() -> None
```
-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**:
+Disconnect from the command.
-Information about the written file
+The command is not killed, but SDK stops receiving events from the command.
+You can reconnect to the command using `sandbox.commands.connect` method.
-### write
+### wait
```python
-@overload
-def write(files: List[WriteEntry],
- user: Optional[Username] = "user",
- request_timeout: Optional[float] = None) -> List[EntryInfo]
+def wait(on_pty: Optional[Callable[[PtyOutput], None]] = None,
+ on_stdout: Optional[Callable[[str], None]] = None,
+ on_stderr: Optional[Callable[[str], None]] = None) -> CommandResult
```
-Writes a list of files to the filesystem.
+Wait for the command to finish and returns the result.
-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.
+If the command exits with a non-zero exit code, it throws a `CommandExitException`.
**Arguments**:
-- `files`: list of files to write
-- `user`: Run the operation as this user
-- `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**:
-Information about the written files
+`CommandResult` result of command execution
-### list
+### kill
```python
-def list(path: str,
- user: Username = "user",
- request_timeout: Optional[float] = None) -> List[EntryInfo]
+def kill() -> bool
```
-List entries in a directory.
-
-**Arguments**:
+Kills the command.
-- `path`: Path to the directory
-- `user`: Run the operation as this user
-- `request_timeout`: Timeout for the request in **seconds**
+It uses `SIGKILL` signal to kill the command.
**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**
+Whether the command was killed successfully
-**Returns**:
-`True` if the file or directory exists, `False` otherwise
-### remove
+## Pty
```python
-def remove(path: str,
- user: Username = "user",
- request_timeout: Optional[float] = None) -> None
+class Pty()
```
-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**
+Module for interacting with PTYs (pseudo-terminals) in the sandbox.
-### rename
+### kill
```python
-def rename(old_path: str,
- new_path: str,
- user: Username = "user",
- request_timeout: Optional[float] = None) -> EntryInfo
+def kill(pid: int, request_timeout: Optional[float] = None) -> bool
```
-Rename a file or directory.
+Kill PTY.
**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
+- `pid`: Process ID of the PTY
- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-Information about the renamed file or directory
+`true` if the PTY was killed, `false` if the PTY was not found
-### make\_dir
+### send\_stdin
```python
-def make_dir(path: str,
- user: Username = "user",
- request_timeout: Optional[float] = None) -> bool
+def send_stdin(pid: int,
+ data: bytes,
+ request_timeout: Optional[float] = None) -> None
```
-Create a new directory and all directories along the way if needed on the specified path.
+Send input to a PTY.
**Arguments**:
-- `path`: Path to a new directory. For example '/dirA/dirB' when creating 'dirB'.
-- `user`: Run the operation as this user
+- `pid`: Process ID of the PTY
+- `data`: Input data to send
- `request_timeout`: Timeout for the request in **seconds**
-**Returns**:
-
-`True` if the directory was created, `False` if the directory already exists
-
-### watch\_dir
+### create
```python
-def watch_dir(path: str,
- user: Username = "user",
- request_timeout: Optional[float] = None,
- recursive: bool = False) -> WatchHandle
+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
```
-Watch directory for filesystem events.
+Start a new PTY (pseudo-terminal).
**Arguments**:
-- `path`: Path to a directory to watch
-- `user`: Run the operation as this user
+- `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**
-- `recursive`: Watch directory recursively
-
-**Returns**:
-
-`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
-
-
-
-
-## SandboxApi
-
-```python
-class SandboxApi(SandboxApiBase)
-```
+Handle to interact with the PTY
-### list
+### resize
```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,
- headers: Optional[Dict[str, str]] = None) -> List[SandboxInfo]
+def resize(pid: int,
+ size: PtySize,
+ request_timeout: Optional[float] = None) -> None
```
-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**
-- `headers`: Additional headers to send with the request
-
-**Returns**:
-
-List of running sandboxes
-
-
-### get\_info
-
-```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,
- headers: Optional[Dict[str, str]] = None) -> SandboxInfo
-```
+Resize PTY.
-Get the sandbox info.
+Call this when the terminal window is resized and the number of columns and rows has changed.
**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**
-- `headers`: Additional headers to send with the request
-
-**Returns**:
-
-Sandbox info
+- `pid`: Process ID of the PTY
+- `size`: New size of the PTY
+- `request_timeout`: Timeout for the request in **seconds**s
@@ -496,205 +305,329 @@ Start a new command and return a handle to interact with it.
`CommandHandle` handle to interact with the running command
-### connect
+### 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
+
+
+
+
+## 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
+@overload
+def write(path: str,
+ data: Union[str, bytes, IO],
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> EntryInfo
+```
+
+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
```python
-def connect(pid: int,
- timeout: Optional[float] = 60,
- request_timeout: Optional[float] = None)
+@overload
+def write(files: List[WriteEntry],
+ user: Optional[Username] = "user",
+ request_timeout: Optional[float] = None) -> List[EntryInfo]
```
-Connects to a running command.
+Writes a list of files to the filesystem.
-You can use `CommandHandle.wait()` to wait for the command to finish and get execution results.
+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**:
-- `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**
+- `files`: list of files to write
+- `user`: Run the operation as this user
+- `request_timeout`: Timeout for the request
**Returns**:
-`CommandHandle` handle to interact with the running command
-
-
+Information about the written files
-## Pty
+### list
```python
-class Pty()
+def list(path: str,
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> List[EntryInfo]
```
-Module for interacting with PTYs (pseudo-terminals) in the sandbox.
+List entries in a directory.
+**Arguments**:
+
+- `path`: Path to the directory
+- `user`: Run the operation as this user
+- `request_timeout`: Timeout for the request in **seconds**
+
+**Returns**:
+
+List of entries in the directory
-### kill
+
+### exists
```python
-def kill(pid: int, request_timeout: Optional[float] = None) -> bool
+def exists(path: str,
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> bool
```
-Kill PTY.
+Check if a file or a directory exists.
**Arguments**:
-- `pid`: Process ID of the PTY
+- `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 PTY was killed, `false` if the PTY was not found
+`True` if the file or directory exists, `False` otherwise
-### send\_stdin
+### remove
```python
-def send_stdin(pid: int,
- data: bytes,
- request_timeout: Optional[float] = None) -> None
+def remove(path: str,
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> None
```
-Send input to a PTY.
+Remove a file or a directory.
**Arguments**:
-- `pid`: Process ID of the PTY
-- `data`: Input data to send
+- `path`: Path to a file or a directory
+- `user`: Run the operation as this user
- `request_timeout`: Timeout for the request in **seconds**
-### create
+### rename
```python
-def create(size: PtySize,
+def rename(old_path: str,
+ new_path: str,
user: Username = "user",
- cwd: Optional[str] = None,
- envs: Optional[Dict[str, str]] = None,
- timeout: Optional[float] = 60,
- request_timeout: Optional[float] = None) -> CommandHandle
+ request_timeout: Optional[float] = None) -> EntryInfo
```
-Start a new PTY (pseudo-terminal).
+Rename a file or directory.
**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**
+- `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**:
-Handle to interact with the PTY
+Information about the renamed file or directory
-### resize
+### make\_dir
```python
-def resize(pid: int,
- size: PtySize,
- request_timeout: Optional[float] = None) -> None
+def make_dir(path: str,
+ user: Username = "user",
+ request_timeout: Optional[float] = None) -> bool
```
-Resize PTY.
-
-Call this when the terminal window is resized and the number of columns and rows has changed.
+Create a new directory and all directories along the way if needed on the specified path.
**Arguments**:
-- `pid`: Process ID of the PTY
-- `size`: New size of the PTY
-- `request_timeout`: Timeout for the request in **seconds**s
-
-
-
-
-## CommandHandle
-
-```python
-class CommandHandle()
-```
+- `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**
-Command execution handle.
+**Returns**:
-It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
+`True` if the directory was created, `False` if the directory already exists
-### pid
+### watch\_dir
```python
-@property
-def pid()
+def watch_dir(path: str,
+ user: Username = "user",
+ request_timeout: Optional[float] = None,
+ recursive: bool = False) -> WatchHandle
```
-Command process ID.
+Watch directory for filesystem events.
+**Arguments**:
-### \_\_iter\_\_
+- `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
-```python
-def __iter__()
-```
+**Returns**:
-Iterate over the command output.
+`WatchHandle` object for stopping watching directory
-**Returns**:
-Generator of command outputs
-### disconnect
+## WatchHandle
```python
-def disconnect() -> None
+class WatchHandle()
```
-Disconnect from the command.
+Handle for watching filesystem events.
+It is used to get the latest events that have occurred in the watched directory.
-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 `.stop()` to stop watching the directory.
-### wait
+### stop
```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
+def stop()
```
-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
+Stop watching the directory.
+After you stop the watcher you won't be able to get the events anymore.
-### kill
+### get\_new\_events
```python
-def kill() -> bool
+def get_new_events() -> List[FilesystemEvent]
```
-Kills the command.
-
-It uses `SIGKILL` signal to kill the command.
+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**:
-Whether the command was killed successfully
+List of filesystem events
@@ -981,3 +914,70 @@ Get sandbox information like sandbox ID, template, metadata, started at/end at d
Sandbox info
+
+
+
+## SandboxApi
+
+```python
+class SandboxApi(SandboxApiBase)
+```
+
+
+### 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,
+ headers: Optional[Dict[str, str]] = 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**
+- `headers`: Additional headers to send with the request
+
+**Returns**:
+
+List of running sandboxes
+
+
+### get\_info
+
+```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,
+ headers: Optional[Dict[str, str]] = 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**
+- `headers`: Additional headers to send with the request
+
+**Returns**:
+
+Sandbox info
+
diff --git a/packages/js-sdk/package.json b/packages/js-sdk/package.json
index e877e25e4..38d315064 100644
--- a/packages/js-sdk/package.json
+++ b/packages/js-sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "e2b",
- "version": "1.2.4",
+ "version": "1.2.5",
"description": "E2B SDK that give agents cloud environments",
"homepage": "https://e2b.dev",
"license": "MIT",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a5ab616e2..d83f7f184 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -118,8 +118,8 @@ importers:
specifier: ^1.2.1
version: 1.2.1
e2b:
- specifier: ^1.2.4
- version: 1.2.4
+ specifier: ^1.2.5
+ version: 1.2.5
fast-glob:
specifier: ^3.3.0
version: 3.3.1
@@ -392,7 +392,7 @@ importers:
vitest-browser-react:
specifier: ^0.1.1
packages/python-sdk: {}
@@ -3962,8 +3962,8 @@ packages:
resolution: {integrity: sha512-ii/Bw55ecxgORqkArKNbuVTwqLgVZ0rH1X3J/NOe4LMZaVETm3qNpPBjoPkpQAsQjw2ew0Ad2sd54epqm9nLCw==}
engines: {node: '>=18'}
- resolution: {integrity: sha512-JW+Jt8Qt4+ExM1Wy38p7iu3aoOi5wI/B9OliVxd8uXCxFbb5fYXxwjPcsr0Vuv1qewqL5jAbxIABCHWELpHeHw==}
+ resolution: {integrity: sha512-15oCJp1bi21AownAhTcub+3X8COXCzlACzCbPh4IqZPewbotObo5FRUWa7rOmYvC5LRpS9jMXTJHYqWcNQhWEg==}
engines: {node: '>=18'}
@@ -11536,7 +11536,7 @@ snapshots:
openapi-fetch: 0.9.8
platform: 1.3.6
dependencies:
'@bufbuild/protobuf': 2.2.2
'@connectrpc/connect': 2.0.0-rc.3(@bufbuild/[email protected])
@@ -11783,7 +11783,7 @@ snapshots:
debug: 4.4.0([email protected])
enhanced-resolve: 5.18.1
eslint: 8.57.1
fast-glob: 3.3.2
get-tsconfig: 4.7.0
@@ -11795,7 +11795,7 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
@@ -11816,7 +11816,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
has: 1.0.3
is-core-module: 2.13.0
is-glob: 4.0.3
@@ -15568,7 +15568,7 @@ snapshots:
terser: 5.39.0
yaml: 2.5.1
dependencies:
react: 18.3.1