Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Update async Python docstrings
Tomas Valenta95baca5d1ba9
diff --git a/packages/js-sdk/src/connectionConfig.ts b/packages/js-sdk/src/connectionConfig.tsindex 7ef358109..2c7ae03fd 100644--- a/packages/js-sdk/src/connectionConfig.ts+++ b/packages/js-sdk/src/connectionConfig.ts@@ -29,8 +29,8 @@ export interface ConnectionOpts {*/domain?: string/**- * If true the SDK starts in the debug mode and **connects to the local envd API server**.- *+ * If true the SDK starts in the debug mode and connects to the local envd API server.+ * @internal* @default E2B_DEBUG // environment variable or `false`*/debug?: booleandiff --git a/packages/js-sdk/src/sandbox/commands/index.ts b/packages/js-sdk/src/sandbox/commands/index.tsindex 1324ed286..e274d822f 100644--- a/packages/js-sdk/src/sandbox/commands/index.ts+++ b/packages/js-sdk/src/sandbox/commands/index.ts@@ -215,7 +215,7 @@ export class Commands {}/**- * Connect to an existing command.+ * Connect to a running command.* You can use {@link CommandHandle.wait} to wait for the command to finish and get execution results.** @param pid process ID of the command to connect to. You can get the list of running commands using {@link Commands.list}.diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.tsindex 2a1106b8e..eed1978df 100644--- a/packages/js-sdk/src/sandbox/index.ts+++ b/packages/js-sdk/src/sandbox/index.ts@@ -32,6 +32,7 @@ export interface SandboxOpts extends ConnectionOpts {envs?: Record<string, string>/*** 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 300_000 // 5 minutes*/@@ -281,6 +282,7 @@ export class Sandbox extends SandboxApi {* 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.** @param timeoutMs timeout in **milliseconds**.* @param opts connection options.diff --git a/packages/js-sdk/src/sandbox/sandboxApi.ts b/packages/js-sdk/src/sandbox/sandboxApi.tsindex 3a8299ced..9d4cd1fcd 100644--- a/packages/js-sdk/src/sandbox/sandboxApi.ts+++ b/packages/js-sdk/src/sandbox/sandboxApi.ts@@ -45,7 +45,7 @@ export class SandboxApi {protected constructor() { }/**- * Kill sandbox specified by sandbox ID.+ * Kill the sandbox specified by sandbox ID.** @param sandboxId sandbox ID.* @param opts connection options.@@ -119,7 +119,9 @@ export class SandboxApi {* 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 {@link 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.+ ** @param sandboxId sandbox ID.* @param timeoutMs timeout in **milliseconds**.* @param opts connection options.diff --git a/packages/python-sdk/e2b/__init__.py b/packages/python-sdk/e2b/__init__.pyindex 2945e35d0..8aedd8081 100644--- a/packages/python-sdk/e2b/__init__.py+++ b/packages/python-sdk/e2b/__init__.py@@ -1,3 +1,30 @@+"""+Secure sandboxed cloud environments made for AI agents and AI apps.++Check docs [here](https://e2b.dev/docs).++E2B Sandbox is a secure cloud sandbox environment made for AI agents and AI+apps.+Sandboxes allow AI agents and apps to have long running cloud secure environments.+In these environments, large language models can use the same tools as humans do.++E2B Python SDK supports both sync and async API:++```py+from e2b import Sandbox++# Create sandbox+sandbox = Sandbox()+```++```py+from e2b import AsyncSandbox++# Create sandbox+sandbox = await AsyncSandbox.create()+```+"""+from .api import (ApiClient,client,@@ -15,15 +42,15 @@ from .exceptions import (TemplateException,)from .sandbox.sandbox_api import SandboxInfo-from .sandbox.process.process_handle import (- ProcessResult,+from .sandbox.commands.main import ProcessInfo+from .sandbox.commands.command_handle import (+ CommandResult,Stderr,Stdout,- ProcessExitException,+ CommandExitException,PtyOutput,PtySize,)-from .sandbox.process.main import ProcessInfofrom .sandbox.filesystem.watch_handle import (FilesystemEvent,FilesystemEventType,@@ -32,9 +59,9 @@ from .sandbox.filesystem.filesystem import EntryInfo, FileTypefrom .sandbox_sync.main import Sandboxfrom .sandbox_sync.filesystem.watch_handle import WatchHandle-from .sandbox_sync.process.process_handle import ProcessHandle+from .sandbox_sync.commands.command_handle import CommandHandle-from .sandbox_async.utilts import OutputHandler+from .sandbox_async.utils import OutputHandlerfrom .sandbox_async.main import AsyncSandboxfrom .sandbox_async.filesystem.watch_handle import AsyncWatchHandle-from .sandbox_async.process.process_handle import AsyncProcessHandle+from .sandbox_async.commands.command_handle import AsyncCommandHandlediff --git a/packages/python-sdk/e2b/api/client/api/auth/__init__.py b/packages/python-sdk/e2b/api/client/api/auth/__init__.pynew file mode 100644index 000000000..e69de29bbdiff --git a/packages/python-sdk/e2b/api/client/api/auth/get_teams.py b/packages/python-sdk/e2b/api/client/api/auth/get_teams.pynew file mode 100644index 000000000..d26eb508b--- /dev/null+++ b/packages/python-sdk/e2b/api/client/api/auth/get_teams.py@@ -0,0 +1,137 @@+from http import HTTPStatus+from typing import Any, Dict, List, Optional, Union, cast++import httpx++from ... import errors+from ...client import AuthenticatedClient, Client+from ...models.team import Team+from ...types import Response+++def _get_kwargs() -> Dict[str, Any]:+ _kwargs: Dict[str, Any] = {+ "method": "get",+ "url": "/teams",+ }++ return _kwargs+++def _parse_response(+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response+) -> Optional[Union[Any, List["Team"]]]:+ if response.status_code == HTTPStatus.OK:+ response_200 = []+ _response_200 = response.json()+ for response_200_item_data in _response_200:+ response_200_item = Team.from_dict(response_200_item_data)++ response_200.append(response_200_item)++ return response_200+ if response.status_code == HTTPStatus.UNAUTHORIZED:+ response_401 = cast(Any, None)+ return response_401+ if response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR:+ response_500 = cast(Any, None)+ return response_500+ if client.raise_on_unexpected_status:+ raise errors.UnexpectedStatus(response.status_code, response.content)+ else:+ return None+++def _build_response(+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response+) -> Response[Union[Any, List["Team"]]]:+ return Response(+ status_code=HTTPStatus(response.status_code),+ content=response.content,+ headers=response.headers,+ parsed=_parse_response(client=client, response=response),+ )+++def sync_detailed(+ *,+ client: AuthenticatedClient,+) -> Response[Union[Any, List["Team"]]]:+ """List all teams++ Raises:+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.+ httpx.TimeoutException: If the request takes longer than Client.timeout.++ Returns:+ Response[Union[Any, List['Team']]]+ """++ kwargs = _get_kwargs()++ response = client.get_httpx_client().request(+ **kwargs,+ )++ return _build_response(client=client, response=response)+++def sync(+ *,+ client: AuthenticatedClient,+) -> Optional[Union[Any, List["Team"]]]:+ """List all teams++ Raises:+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.+ httpx.TimeoutException: If the request takes longer than Client.timeout.++ Returns:+ Union[Any, List['Team']]+ """++ return sync_detailed(+ client=client,+ ).parsed+++async def asyncio_detailed(+ *,+ client: AuthenticatedClient,+) -> Response[Union[Any, List["Team"]]]:+ """List all teams++ Raises:+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.+ httpx.TimeoutException: If the request takes longer than Client.timeout.++ Returns:+ Response[Union[Any, List['Team']]]+ """++ kwargs = _get_kwargs()++ response = await client.get_async_httpx_client().request(**kwargs)++ return _build_response(client=client, response=response)+++async def asyncio(+ *,+ client: AuthenticatedClient,+) -> Optional[Union[Any, List["Team"]]]:+ """List all teams++ Raises:+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.+ httpx.TimeoutException: If the request takes longer than Client.timeout.++ Returns:+ Union[Any, List['Team']]+ """++ return (+ await asyncio_detailed(+ client=client,+ )+ ).parseddiff --git a/packages/python-sdk/e2b/api/client/api/default/get_health.py b/packages/python-sdk/e2b/api/client/api/default/get_health.pyindex c295ec3c2..339a6905f 100644--- a/packages/python-sdk/e2b/api/client/api/default/get_health.py+++ b/packages/python-sdk/e2b/api/client/api/default/get_health.py@@ -17,9 +17,7 @@ def _get_kwargs() -> Dict[str, Any]:return _kwargs-def _parse_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Optional[Any]:+def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:if response.status_code == HTTPStatus.OK:return Noneif response.status_code == HTTPStatus.UNAUTHORIZED:@@ -30,9 +28,7 @@ def _parse_response(return None-def _build_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Response[Any]:+def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]:return Response(status_code=HTTPStatus(response.status_code),content=response.content,diff --git a/packages/python-sdk/e2b/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py b/packages/python-sdk/e2b/api/client/api/sandboxes/delete_sandboxes_sandbox_id.pyindex 974f2d687..fa9f37750 100644--- a/packages/python-sdk/e2b/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py+++ b/packages/python-sdk/e2b/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py@@ -19,9 +19,7 @@ def _get_kwargs(return _kwargs-def _parse_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Optional[Any]:+def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:if response.status_code == HTTPStatus.NO_CONTENT:return Noneif response.status_code == HTTPStatus.NOT_FOUND:@@ -36,9 +34,7 @@ def _parse_response(return None-def _build_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Response[Any]:+def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]:return Response(status_code=HTTPStatus(response.status_code),content=response.content,diff --git a/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py b/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.pyindex 39dfc678a..163bcf177 100644--- a/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py+++ b/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py@@ -5,9 +5,7 @@ import httpxfrom ... import errorsfrom ...client import AuthenticatedClient, Client-from ...models.post_sandboxes_sandbox_id_refreshes_body import (- PostSandboxesSandboxIDRefreshesBody,-)+from ...models.post_sandboxes_sandbox_id_refreshes_body import PostSandboxesSandboxIDRefreshesBodyfrom ...types import Response@@ -32,9 +30,7 @@ def _get_kwargs(return _kwargs-def _parse_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Optional[Any]:+def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:if response.status_code == HTTPStatus.NO_CONTENT:return Noneif response.status_code == HTTPStatus.UNAUTHORIZED:@@ -47,9 +43,7 @@ def _parse_response(return None-def _build_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Response[Any]:+def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]:return Response(status_code=HTTPStatus(response.status_code),content=response.content,diff --git a/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py b/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.pyindex 615963abf..148d97c87 100644--- a/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py+++ b/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py@@ -5,9 +5,7 @@ import httpxfrom ... import errorsfrom ...client import AuthenticatedClient, Client-from ...models.post_sandboxes_sandbox_id_timeout_body import (- PostSandboxesSandboxIDTimeoutBody,-)+from ...models.post_sandboxes_sandbox_id_timeout_body import PostSandboxesSandboxIDTimeoutBodyfrom ...types import Response@@ -32,9 +30,7 @@ def _get_kwargs(return _kwargs-def _parse_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Optional[Any]:+def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:if response.status_code == HTTPStatus.NO_CONTENT:return Noneif response.status_code == HTTPStatus.UNAUTHORIZED:@@ -49,9 +45,7 @@ def _parse_response(return None-def _build_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Response[Any]:+def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]:return Response(status_code=HTTPStatus(response.status_code),content=response.content,diff --git a/packages/python-sdk/e2b/api/client/api/templates/delete_templates_template_id.py b/packages/python-sdk/e2b/api/client/api/templates/delete_templates_template_id.pyindex b7c162b27..d493420f3 100644--- a/packages/python-sdk/e2b/api/client/api/templates/delete_templates_template_id.py+++ b/packages/python-sdk/e2b/api/client/api/templates/delete_templates_template_id.py@@ -19,9 +19,7 @@ def _get_kwargs(return _kwargs-def _parse_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Optional[Any]:+def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:if response.status_code == HTTPStatus.NO_CONTENT:return Noneif response.status_code == HTTPStatus.UNAUTHORIZED:@@ -34,9 +32,7 @@ def _parse_response(return None-def _build_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Response[Any]:+def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]:return Response(status_code=HTTPStatus(response.status_code),content=response.content,diff --git a/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id_builds_build_id.py b/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id_builds_build_id.pyindex 754229875..67e21c739 100644--- a/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id_builds_build_id.py+++ b/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id_builds_build_id.py@@ -20,9 +20,7 @@ def _get_kwargs(return _kwargs-def _parse_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Optional[Any]:+def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:if response.status_code == HTTPStatus.ACCEPTED:return Noneif response.status_code == HTTPStatus.UNAUTHORIZED:@@ -35,9 +33,7 @@ def _parse_response(return None-def _build_response(- *, client: Union[AuthenticatedClient, Client], response: httpx.Response-) -> Response[Any]:+def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]:return Response(status_code=HTTPStatus(response.status_code),content=response.content,diff --git a/packages/python-sdk/e2b/api/client/client.py b/packages/python-sdk/e2b/api/client/client.pyindex 38b07d057..63a2493b9 100644--- a/packages/python-sdk/e2b/api/client/client.py+++ b/packages/python-sdk/e2b/api/client/client.py@@ -38,15 +38,9 @@ class Client:_base_url: str = field(alias="base_url")_cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")_headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers")- _timeout: Optional[httpx.Timeout] = field(- default=None, kw_only=True, alias="timeout"- )- _verify_ssl: Union[str, bool, ssl.SSLContext] = field(- default=True, kw_only=True, alias="verify_ssl"- )- _follow_redirects: bool = field(- default=False, kw_only=True, alias="follow_redirects"- )+ _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")+ _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")+ _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")_httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")_client: Optional[httpx.Client] = field(default=None, init=False)_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)@@ -174,15 +168,9 @@ class AuthenticatedClient:_base_url: str = field(alias="base_url")_cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")_headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers")- _timeout: Optional[httpx.Timeout] = field(- default=None, kw_only=True, alias="timeout"- )- _verify_ssl: Union[str, bool, ssl.SSLContext] = field(- default=True, kw_only=True, alias="verify_ssl"- )- _follow_redirects: bool = field(- default=False, kw_only=True, alias="follow_redirects"- )+ _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")+ _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")+ _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")_httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")_client: Optional[httpx.Client] = field(default=None, init=False)_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)@@ -226,9 +214,7 @@ class AuthenticatedClient:def get_httpx_client(self) -> httpx.Client:"""Get the underlying httpx.Client, constructing a new one if not previously set"""if self._client is None:- self._headers[self.auth_header_name] = (- f"{self.prefix} {self.token}" if self.prefix else self.token- )+ self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.tokenself._client = httpx.Client(base_url=self._base_url,cookies=self._cookies,@@ -249,9 +235,7 @@ class AuthenticatedClient:"""Exit a context manager for internal httpx.Client (see httpx docs)"""self.get_httpx_client().__exit__(*args, **kwargs)- def set_async_httpx_client(- self, async_client: httpx.AsyncClient- ) -> "AuthenticatedClient":+ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient":"""Manually the underlying httpx.AsyncClient**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.@@ -262,9 +246,7 @@ class AuthenticatedClient:def get_async_httpx_client(self) -> httpx.AsyncClient:"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""if self._async_client is None:- self._headers[self.auth_header_name] = (- f"{self.prefix} {self.token}" if self.prefix else self.token- )+ self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.tokenself._async_client = httpx.AsyncClient(base_url=self._base_url,cookies=self._cookies,diff --git a/packages/python-sdk/e2b/api/client/models/__init__.py b/packages/python-sdk/e2b/api/client/models/__init__.pyindex 85275a6de..d55b958c2 100644--- a/packages/python-sdk/e2b/api/client/models/__init__.py+++ b/packages/python-sdk/e2b/api/client/models/__init__.py@@ -2,9 +2,7 @@from .error import Errorfrom .new_sandbox import NewSandbox-from .post_sandboxes_sandbox_id_refreshes_body import (- PostSandboxesSandboxIDRefreshesBody,-)+from .post_sandboxes_sandbox_id_refreshes_body import PostSandboxesSandboxIDRefreshesBodyfrom .post_sandboxes_sandbox_id_timeout_body import PostSandboxesSandboxIDTimeoutBodyfrom .running_sandbox import RunningSandboxfrom .sandbox import Sandboxdiff --git a/packages/python-sdk/e2b/connection_config.py b/packages/python-sdk/e2b/connection_config.pyindex 31a587cd6..e1e610e72 100644--- a/packages/python-sdk/e2b/connection_config.py+++ b/packages/python-sdk/e2b/connection_config.py@@ -2,15 +2,15 @@ import osfrom typing import Literal, Optional-REQUEST_TIMEOUT: float = 30.0 # 30s+REQUEST_TIMEOUT: float = 30.0 # 30 seconds-KEEPALIVE_PING_INTERVAL_SEC = 50 # 50s+KEEPALIVE_PING_INTERVAL_SEC = 50 # 50 secondsKEEPALIVE_PING_HEADER = "Keepalive-Ping-Interval"class ConnectionConfig:"""- Configuration for the connection to the E2B API.+ Configuration for the connection to the API."""@staticmethod@@ -75,5 +75,11 @@ class ConnectionConfig:Username = Literal["root", "user"]+"""+User used for the operation in the sandbox.+"""default_username: Username = "user"+"""+Default user used for the operation in the sandbox.+"""diff --git a/packages/python-sdk/e2b/exceptions.py b/packages/python-sdk/e2b/exceptions.pyindex d785367ab..ad1484ff1 100644--- a/packages/python-sdk/e2b/exceptions.py+++ b/packages/python-sdk/e2b/exceptions.py@@ -18,9 +18,9 @@ def format_execution_timeout_error() -> Exception:class SandboxException(Exception):"""- Raised when a sandbox exception occurs.-Base class for all sandbox errors.++ Raised when a general sandbox exception occurs."""pass@@ -39,25 +39,25 @@ class TimeoutException(SandboxException):pass-class NotEnoughSpaceException(SandboxException):+class InvalidArgumentException(SandboxException):"""- Raised when there is not enough disk space.+ Raised when an invalid argument is provided."""pass-class NotFoundException(SandboxException):+class NotEnoughSpaceException(SandboxException):"""- Raised when a resource is not found.+ Raised when there is not enough disk space."""pass-class InvalidArgumentException(SandboxException):+class NotFoundException(SandboxException):"""- Raised when an invalid argument is provided.+ Raised when a resource is not found."""passdiff --git a/packages/python-sdk/e2b/sandbox/commands/command_handle.py b/packages/python-sdk/e2b/sandbox/commands/command_handle.pynew file mode 100644index 000000000..043f871c2--- /dev/null+++ b/packages/python-sdk/e2b/sandbox/commands/command_handle.py@@ -0,0 +1,69 @@+from dataclasses import dataclass+from typing import Optional++from e2b.exceptions import SandboxException++Stdout = str+"""+Command stdout output.+"""+Stderr = str+"""+Command stderr output.+"""+PtyOutput = bytes+"""+Pty output.+"""+++@dataclass+class PtySize:+ """+ Pseudo-terminal size.+ """++ rows: int+ """+ Number of rows.+ """+ cols: int+ """+ Number of columns.+ """+++@dataclass+class CommandResult:+ """+ Command execution result.+ """++ stderr: str+ """+ Command stderr output.+ """+ stdout: str+ """+ Command stdout output.+ """+ exit_code: int+ """+ Command exit code.++ `0` if the command finished successfully.+ """+ error: Optional[str]+ """+ Error message from command execution if it failed.+ """+++@dataclass+class CommandExitException(SandboxException, CommandResult):+ """+ Exception raised when a command exits with a non-zero exit code.+ """++ def __str__(self):+ return f"Command exited with code {self.exit_code} and error:\n{self.stderr}"diff --git a/packages/python-sdk/e2b/sandbox/commands/main.py b/packages/python-sdk/e2b/sandbox/commands/main.pynew file mode 100644index 000000000..67d52ed35--- /dev/null+++ b/packages/python-sdk/e2b/sandbox/commands/main.py@@ -0,0 +1,39 @@+from dataclasses import dataclass+from typing import Dict, List, Optional+++@dataclass+class ProcessInfo:+ """+ Information about a command, PTY session or start command running in the sandbox as process.+ """++ pid: int+ """+ Process ID.+ """++ tag: Optional[str]+ """+ Custom tag used for identifying special commands like start command in the custom template.+ """++ cmd: str+ """+ Command that was executed.+ """++ args: List[str]+ """+ Command arguments.+ """++ envs: Dict[str, str]+ """+ Environment variables used for the command.+ """++ cwd: Optional[str]+ """+ Executed command working directory.+ """diff --git a/packages/python-sdk/e2b/sandbox/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox/filesystem/filesystem.pyindex eb13d43d5..9e04a3975 100644--- a/packages/python-sdk/e2b/sandbox/filesystem/filesystem.py+++ b/packages/python-sdk/e2b/sandbox/filesystem/filesystem.py@@ -11,7 +11,13 @@ class FileType(Enum):"""FILE = "file"+ """+ Filesystem object is a file.+ """DIR = "dir"+ """+ Filesystem object is a directory.+ """def map_file_type(ft: filesystem_pb2.FileType):@@ -24,9 +30,18 @@ def map_file_type(ft: filesystem_pb2.FileType):@dataclassclass EntryInfo:"""- Contains information about the filesystem object (file or directory).+ Sandbox filesystem object information."""name: str+ """+ Name of the filesystem object.+ """type: Optional[FileType]+ """+ Type of the filesystem object.+ """path: str+ """+ Path to the filesystem object.+ """diff --git a/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py b/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.pyindex 03d350e23..c92f07df7 100644--- a/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py+++ b/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py@@ -10,10 +10,25 @@ class FilesystemEventType(Enum):"""CHMOD = "chmod"+ """+ Filesystem object permissions were changed.+ """CREATE = "create"+ """+ Filesystem object was created.+ """REMOVE = "remove"+ """+ Filesystem object was removed.+ """RENAME = "rename"+ """+ Filesystem object was renamed.+ """WRITE = "write"+ """+ Filesystem object was written to.+ """def map_event_type(event: EventType):@@ -36,4 +51,10 @@ class FilesystemEvent:"""name: str+ """+ Relative path to the filesystem object.+ """type: FilesystemEventType+ """+ Filesystem operation event type.+ """diff --git a/packages/python-sdk/e2b/sandbox/main.py b/packages/python-sdk/e2b/sandbox/main.pyindex bc64807c0..a87cbe07e 100644--- a/packages/python-sdk/e2b/sandbox/main.py+++ b/packages/python-sdk/e2b/sandbox/main.py@@ -22,18 +22,15 @@ class SandboxSetup(ABC):@property@abstractmethod- def connection_config(self) -> ConnectionConfig:- ...+ def connection_config(self) -> ConnectionConfig: ...@property@abstractmethod- def envd_api_url(self) -> str:- ...+ def envd_api_url(self) -> str: ...@property@abstractmethod- def sandbox_id(self) -> str:- ...+ def sandbox_id(self) -> str: ...def _file_url(self, path: Optional[str] = None) -> str:url = urllib.parse.urljoin(self.envd_api_url, ENVD_API_FILES_ROUTE)@@ -49,12 +46,36 @@ class SandboxSetup(ABC):return urldef download_url(self, path: str) -> str:+ """+ Get the URL to download a file from the sandbox.++ :param path: Path to the file to download++ :return: URL for downloading file+ """return self._file_url(path)def upload_url(self, path: Optional[str] = None) -> str:+ """+ 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.++ :param path: Path to the file to upload++ :return: URL for uploading file+ """return self._file_url(path)def get_host(self, port: int) -> str:+ """+ Get the host address to connect to the sandbox.+ You can then use this address to connect to the sandbox port from outside the sandbox via HTTP or WebSocket.++ :param port: Port to connect to++ :return: Host address to connect to+ """if self.connection_config.debug:return f"localhost:{port}"diff --git a/packages/python-sdk/e2b/sandbox/process/main.py b/packages/python-sdk/e2b/sandbox/process/main.pydeleted file mode 100644index 44c94c9ae..000000000--- a/packages/python-sdk/e2b/sandbox/process/main.py+++ /dev/null@@ -1,16 +0,0 @@-from dataclasses import dataclass-from typing import Dict, List, Optional---@dataclass-class ProcessInfo:- """- Contains information about the process.- """-- pid: int- tag: Optional[str]- cmd: str- args: List[str]- envs: Dict[str, str]- cwd: Optional[str]diff --git a/packages/python-sdk/e2b/sandbox/process/process_handle.py b/packages/python-sdk/e2b/sandbox/process/process_handle.pydeleted file mode 100644index e801fff77..000000000--- a/packages/python-sdk/e2b/sandbox/process/process_handle.py+++ /dev/null@@ -1,40 +0,0 @@-from dataclasses import dataclass-from typing import Optional--from e2b.exceptions import SandboxException--Stdout = str-Stderr = str-PtyOutput = bytes---@dataclass-class PtySize:- """- Contains information about the size of the pseudo-terminal- """-- rows: int- cols: int---@dataclass-class ProcessResult:- """- Contains information about the process execution result.- """-- stderr: str- stdout: str- exit_code: int- error: Optional[str]---@dataclass-class ProcessExitException(SandboxException, ProcessResult):- """- Exception raised when a process exits with a non-zero exit code.- """-- def __str__(self):- return f"Process exited with code {self.exit_code} and error:\n{self.stderr}"diff --git a/packages/python-sdk/e2b/sandbox/sandbox_api.py b/packages/python-sdk/e2b/sandbox/sandbox_api.pyindex 8af3418e0..cbf876053 100644--- a/packages/python-sdk/e2b/sandbox/sandbox_api.py+++ b/packages/python-sdk/e2b/sandbox/sandbox_api.py@@ -14,7 +14,7 @@ class SandboxInfo:template_id: str"""Template ID."""name: Optional[str]- """Sandbox name."""+ """Template name."""metadata: Dict[str, str]"""Saved sandbox metadata."""started_at: datetimediff --git a/packages/python-sdk/e2b/sandbox_async/process/process.py b/packages/python-sdk/e2b/sandbox_async/commands/command.pysimilarity index 68%rename from packages/python-sdk/e2b/sandbox_async/process/process.pyrename to packages/python-sdk/e2b/sandbox_async/commands/command.pyindex 4111fd4ef..f4ecc4c4b 100644--- a/packages/python-sdk/e2b/sandbox_async/process/process.py+++ b/packages/python-sdk/e2b/sandbox_async/commands/command.py@@ -11,15 +11,15 @@ from e2b.connection_config import (from e2b.envd.process import process_connect, process_pb2from e2b.envd.rpc import authentication_header, handle_rpc_exceptionfrom e2b.exceptions import SandboxException-from e2b.sandbox.process.main import ProcessInfo-from e2b.sandbox.process.process_handle import ProcessResult-from e2b.sandbox_async.process.process_handle import AsyncProcessHandle, Stderr, Stdout-from e2b.sandbox_async.utilts import OutputHandler+from e2b.sandbox.commands.main import ProcessInfo+from e2b.sandbox.commands.command_handle import CommandResult+from e2b.sandbox_async.commands.command_handle import AsyncCommandHandle, Stderr, Stdout+from e2b.sandbox_async.utils import OutputHandler-class Process:+class Commands:"""- Manager for starting and interacting with processes in the sandbox.+ Module for executing commands in the sandbox."""def __init__(@@ -42,10 +42,11 @@ class Process:request_timeout: Optional[float] = None,) -> List[ProcessInfo]:"""- Lists all running processes.+ Lists all running commands and PTY sessions.- :param request_timeout: Request timeout- :return: List of running processes+ :param request_timeout: Timeout for the request in **seconds**++ :return: List of running commands and PTY sessions"""try:res = await self._rpc.alist(@@ -74,11 +75,13 @@ class Process:request_timeout: Optional[float] = None,) -> bool:"""- Kills a process.+ Kill a running command specified by its process ID.+ It uses `SIGKILL` signal to kill the command.- :param pid: Process ID to connect to. You can get the list of processes using `sandbox.commands.list()`.- :param request_timeout: Request timeout- :return: `True` if the process was killed, `False` if the process was not found+ :param pid: Process ID of the command. You can get the list of processes using `sandbox.commands.list()`+ :param request_timeout: Timeout for the request in **seconds**++ :return: `True` if the command was killed, `False` if the command was not found"""try:await self._rpc.asend_signal(@@ -104,10 +107,10 @@ class Process:request_timeout: Optional[float] = None,) -> None:"""- Sends data to the stdin of a process.+ Send data to command stdin.- :param pid Process ID to send data to. You can get the list of processes using `sandbox.commands.list()`.- :param data: Data to send to the process+ :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: Request timeout"""try:@@ -137,7 +140,22 @@ class Process:on_stderr: Optional[OutputHandler[Stderr]] = None,timeout: Optional[float] = 60,request_timeout: Optional[float] = None,- ) -> ProcessResult:+ ) -> CommandResult:+ """+ Start a new command and wait until it finishes executing.++ :param cmd: Command to execute+ :param background: **`False` if the command should be executed in the foreground**, `True` if the command should be executed in the background+ :param envs: Environment variables used for the command+ :param user: User to run the command as+ :param cwd: Working directory to run the command+ :param on_stdout: Callback for command stdout output+ :param on_stderr: Callback for command stderr output+ :param timeout: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time+ :param request_timeout: Timeout for the request in **seconds**++ :return: `CommandResult` result of the command execution+ """...@overload@@ -152,7 +170,22 @@ class Process:on_stderr: Optional[OutputHandler[Stderr]] = None,timeout: Optional[float] = 60,request_timeout: Optional[float] = None,- ) -> AsyncProcessHandle:+ ) -> AsyncCommandHandle:+ """+ Start a new command and return a handle to interact with it.++ :param cmd: Command to execute+ :param background: `False` if the command should be executed in the foreground, **`True` if the command should be executed in the background**+ :param envs: Environment variables used for the command+ :param user: User to run the command as+ :param cwd: Working directory to run the command+ :param on_stdout: Callback for command stdout output+ :param on_stderr: Callback for command stderr output+ :param timeout: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time+ :param request_timeout: Timeout for the request in **seconds**++ :return: `CommandHandle` handle to interact with the running command+ """...async def run(@@ -167,21 +200,6 @@ class Process:timeout: Optional[float] = 60,request_timeout: Optional[float] = None,):- """- Starts a new process and depending on the `background` parameter, waits for the process to finish or not.- :param cmd Command to execute- :param background:- If `True`, the function will return a `ProcessHandle` object that can be used to interact with the process.- If `False`, the function will wait for the process to finish and return a `ProcessResult` object.- :param envs: Environment variables- :param user: User to run the process as- :param cwd: Working directory- :param on_stdout: Callback for stdout- :param on_stderr: Callback for stderr- :param timeout: Timeout for the maximum time the process is allowed to run- :param request_timeout: Timeout for the request- :return: `ProcessHandle` if `background` is `True`, `ProcessResult` if `background` is `False`- """proc = await self._start(cmd,envs,@@ -205,7 +223,7 @@ class Process:request_timeout: Optional[float] = None,on_stdout: Optional[OutputHandler[Stdout]] = None,on_stderr: Optional[OutputHandler[Stderr]] = None,- ) -> AsyncProcessHandle:+ ) -> AsyncCommandHandle:events = self._rpc.astart(process_pb2.StartRequest(process=process_pb2.ProcessConfig(@@ -233,7 +251,7 @@ class Process:f"Failed to start process: expected start event, got {start_event}")- return AsyncProcessHandle(+ return AsyncCommandHandle(pid=start_event.event.start.pid,handle_kill=lambda: self.kill(start_event.event.start.pid),events=events,@@ -250,15 +268,18 @@ class Process:request_timeout: Optional[float] = None,on_stdout: Optional[OutputHandler[Stdout]] = None,on_stderr: Optional[OutputHandler[Stderr]] = None,- ) -> AsyncProcessHandle:+ ) -> AsyncCommandHandle:"""- Connects to an existing process.+ Connects to a running command.+ You can use `CommandHandle.wait()` to wait for the command to finish and get execution results.- :param pid: Process ID to connect to. You can get the list of processes using `sandbox.commands.list()`.- :param timeout: Timeout for the connection- :param request_timeout: Request timeout- :param on_stdout: Callback for stdout- :param on_stderr: Callback for stderr+ :param pid: Process ID of the command to connect to. You can get the list of processes using `sandbox.commands.list()`+ :param request_timeout: Request timeout in **seconds**+ :param timeout: Timeout for the command connection in **seconds**. Using `0` will not limit the command connection time+ :param on_stdout: Callback for command stdout output+ :param on_stderr: Callback for command stderr output++ :return: `CommandHandle` handle to interact with the running command"""events = self._rpc.aconnect(process_pb2.ConnectRequest(@@ -281,7 +302,7 @@ class Process:f"Failed to connect to process: expected start event, got {start_event}")- return AsyncProcessHandle(+ return AsyncCommandHandle(pid=start_event.event.start.pid,handle_kill=lambda: self.kill(start_event.event.start.pid),events=events,diff --git a/packages/python-sdk/e2b/sandbox_async/process/process_handle.py b/packages/python-sdk/e2b/sandbox_async/commands/command_handle.pysimilarity index 74%rename from packages/python-sdk/e2b/sandbox_async/process/process_handle.pyrename to packages/python-sdk/e2b/sandbox_async/commands/command_handle.pyindex 45c4bb5f2..0523432bc 100644--- a/packages/python-sdk/e2b/sandbox_async/process/process_handle.py+++ b/packages/python-sdk/e2b/sandbox_async/commands/command_handle.py@@ -12,46 +12,48 @@ from typing import (from e2b.envd.rpc import handle_rpc_exceptionfrom e2b.envd.process import process_pb2-from e2b.sandbox.process.process_handle import (- ProcessExitException,- ProcessResult,+from e2b.sandbox.commands.command_handle import (+ CommandExitException,+ CommandResult,Stderr,Stdout,PtyOutput,)-from e2b.sandbox_async.utilts import OutputHandler+from e2b.sandbox_async.utils import OutputHandler-class AsyncProcessHandle:+class AsyncCommandHandle:"""- Class representing a process. It provides methods for waiting and killing the process.+ Command execution handle.++ It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command."""@propertydef pid(self):"""- Get the process ID.+ Command process ID."""return self._pid@propertydef stdout(self):"""- Stdout of the process.+ Command stdout output."""return self._stdout@propertydef stderr(self):"""- Stderr of the process.+ Command stderr output."""return self._stderr@propertydef error(self):"""- Error message of the process. It is `None` if the process is still running.+ Command execution error message."""if self._result is None:return None@@ -60,7 +62,11 @@ class AsyncProcessHandle:@propertydef exit_code(self):"""- Exit code of the process. It is `None` if the process is still running.+ Command execution exit code.++ `0` if the command finished successfully.++ It is `None` if the command is still running."""if self._result is None:return None@@ -88,7 +94,7 @@ class AsyncProcessHandle:self._on_stderr = on_stderrself._on_pty = on_pty- self._result: Optional[ProcessResult] = None+ self._result: Optional[CommandResult] = Noneself._iteration_exception: Optional[Exception] = Noneself._wait = asyncio.create_task(self._handle_events())@@ -116,7 +122,7 @@ class AsyncProcessHandle:if event.event.data.pty:yield None, None, event.event.data.ptyif event.event.HasField("end"):- self._result = ProcessResult(+ self._result = CommandResult(stdout=self._stdout,stderr=self._stderr,exit_code=event.event.end.exit_code,@@ -125,7 +131,10 @@ class AsyncProcessHandle:async def disconnect(self) -> None:"""- Disconnects from the process. It does not kill the process. It only stops receiving events from the process.+ 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."""self._wait.cancel()# BUG: In Python 3.8 closing async generator can throw RuntimeError.@@ -151,12 +160,12 @@ class AsyncProcessHandle:except Exception as e:self._iteration_exception = handle_rpc_exception(e)- async def wait(self) -> ProcessResult:+ async def wait(self) -> CommandResult:"""- Waits for the process to finish and returns the result.- If the process exits with a non-zero exit code, it throws a `ProcessExitException`.+ Wait for the command to finish and return the result.+ If the command exits with a non-zero exit code, it throws a `CommandExitException`.- :return: Process result+ :return: `CommandResult` result of command execution"""await self._waitif self._iteration_exception:@@ -166,7 +175,7 @@ class AsyncProcessHandle:raise Exception("Process ended without an end event")if self._result.exit_code != 0:- raise ProcessExitException(+ raise CommandExitException(stdout=self._stdout,stderr=self._stderr,exit_code=self._result.exit_code,@@ -177,7 +186,11 @@ class AsyncProcessHandle:async def kill(self) -> bool:"""- Kills the process.- :return: Whether the process was killed successfully+ Kills the command.++ It uses `SIGKILL` signal to kill the command++ :return: `True` if the command was killed successfully, `False` if the command was not found"""- await self._handle_kill()+ result = await self._handle_kill()+ return resultdiff --git a/packages/python-sdk/e2b/sandbox_async/process/pty.py b/packages/python-sdk/e2b/sandbox_async/commands/pty.pysimilarity index 78%rename from packages/python-sdk/e2b/sandbox_async/process/pty.pyrename to packages/python-sdk/e2b/sandbox_async/commands/pty.pyindex baa970903..740a03202 100644--- a/packages/python-sdk/e2b/sandbox_async/process/pty.py+++ b/packages/python-sdk/e2b/sandbox_async/commands/pty.py@@ -1,4 +1,4 @@-from typing import Callable, Dict, Optional+from typing import Dict, Optionalimport e2b_connectimport httpcore@@ -15,9 +15,9 @@ from e2b.connection_config import (from e2b.exceptions import SandboxExceptionfrom e2b.envd.rpc import authentication_header, handle_rpc_exceptionfrom e2b.exceptions import SandboxException-from e2b.sandbox.process.process_handle import PtySize-from e2b.sandbox_async.process.process_handle import (- AsyncProcessHandle,+from e2b.sandbox.commands.command_handle import PtySize+from e2b.sandbox_async.commands.command_handle import (+ AsyncCommandHandle,OutputHandler,PtyOutput,)@@ -25,7 +25,7 @@ from e2b.sandbox_async.process.process_handle import (class Pty:"""- Manager for starting and interacting with PTY (pseudo-terminal) processes in the sandbox.+ Module for interacting with PTYs (pseudo-terminals) in the sandbox."""def __init__(@@ -49,11 +49,12 @@ class Pty:request_timeout: Optional[float] = None,) -> bool:"""- Kills a process.+ Kill PTY.++ :param pid: Process ID of the PTY+ :param request_timeout: Timeout for the request in **seconds**- :param pid: Process ID to kill. You can get the list of processes using `sandbox.commands.list()`.- :param request_timeout: Timeout for the request- :return: `true` if the process was killed, `false` if the process was not found+ :return: `true` if the PTY was killed, `false` if the PTY was not found"""try:await self._rpc.asend_signal(@@ -79,11 +80,11 @@ class Pty:request_timeout: Optional[float] = None,) -> None:"""- Sends input to a PTY process.+ Send input to a PTY.- :param pid: Process ID of the PTY process+ :param pid: Process ID of the PTY:param data: Input data to send- :param request_timeout: Timeout for the request+ :param request_timeout: Timeout for the request in **seconds**"""try:await self._rpc.asend_input(@@ -109,18 +110,19 @@ class Pty:envs: Optional[Dict[str, str]] = None,timeout: Optional[float] = 60,request_timeout: Optional[float] = None,- ) -> AsyncProcessHandle:+ ) -> AsyncCommandHandle:"""- Starts a new process with a PTY (pseudo-terminal).+ Start a new PTY (pseudo-terminal).:param size: Size of the PTY- :param on_data: Callback for handling PTY output- :param user: User to start the process as- :param cwd: Current working directory- :param envs: Environment variables- :param timeout: Timeout for the request- :param request_timeout: Timeout for the request- :return: New process+ :param on_data: Callback to handle PTY data+ :param user: User to use for the PTY+ :param cwd: Working directory for the PTY+ :param envs: Environment variables for the PTY+ :param timeout: Timeout for the PTY in **seconds**+ :param request_timeout: Timeout for the request in **seconds**++ :return: Handle to interact with the PTY"""envs = envs or {}envs["TERM"] = "xterm-256color"@@ -154,7 +156,7 @@ class Pty:f"Failed to start process: expected start event, got {start_event}")- return AsyncProcessHandle(+ return AsyncCommandHandle(pid=start_event.event.start.pid,handle_kill=lambda: self.kill(start_event.event.start.pid),events=events,@@ -170,11 +172,12 @@ class Pty:request_timeout: Optional[float] = None,):"""- Resizes a PTY process (changes the number of columns and rows in the terminal).+ Resize PTY.+ Call this when the terminal window is resized and the number of columns and rows has changed.- :param pid: Process ID of the PTY process+ :param pid: Process ID of the PTY:param size: New size of the PTY- :param request_timeout: Timeout for the request+ :param request_timeout: Timeout for the request in **seconds**"""await self._rpc.aupdate(process_pb2.UpdateRequest(diff --git a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.pyindex 949e282fb..1f16104c6 100644--- a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py+++ b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py@@ -17,12 +17,12 @@ from e2b.exceptions import SandboxExceptionfrom e2b.sandbox.filesystem.filesystem import EntryInfo, map_file_typefrom e2b.sandbox.filesystem.watch_handle import FilesystemEventfrom e2b.sandbox_async.filesystem.watch_handle import AsyncWatchHandle-from e2b.sandbox_async.utilts import OutputHandler+from e2b.sandbox_async.utils import OutputHandlerclass Filesystem:"""- Manager for interacting with the filesystem in the sandbox.+ Module for interacting with the filesystem in the sandbox."""def __init__(@@ -53,6 +53,16 @@ class Filesystem:user: Username = "user",request_timeout: Optional[float] = None,) -> str:+ """+ Read file content as a `str`.++ :param path: Path to the file+ :param user: Run the operation as this user+ :param format: Format of the file content—`text` by default+ :param request_timeout: Timeout for the request in **seconds**++ :return: File content as a `str`+ """...@overload@@ -63,7 +73,16 @@ class Filesystem:user: Username = "user",request_timeout: Optional[float] = None,) -> bytearray:- ...+ """+ Read file content as a `bytearray`.++ :param path: Path to the file+ :param user: Run the operation as this user+ :param format: Format of the file content—`bytes`+ :param request_timeout: Timeout for the request in **seconds**++ :return: File content as a `bytearray`+ """@overloadasync def read(@@ -73,6 +92,16 @@ class Filesystem:user: Username = "user",request_timeout: Optional[float] = None,) -> AsyncIterator[bytes]:+ """+ Read file content as a `AsyncIterator[bytes]`.++ :param path: Path to the file+ :param user: Run the operation as this user+ :param format: Format of the file content—`stream`+ :param request_timeout: Timeout for the request in **seconds**++ :return: File content as an `AsyncIterator[bytes]`+ """...async def read(@@ -82,15 +111,6 @@ class Filesystem:user: Username = "user",request_timeout: Optional[float] = None,):- """- Reads a whole file content and returns it in requested format (text by default).-- :param path: Path to the file- :param format: Format of the file content- :param user: Run the operation as this user- :param request_timeout: Timeout for the request- :return File content in requested format- """r = await self._envd_api.get(ENVD_API_FILES_ROUTE,params={"path": path, "username": user},@@ -116,15 +136,19 @@ class Filesystem:request_timeout: Optional[float] = None,) -> EntryInfo:"""- 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, the directory will get created.+ 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.:param path: Path to the file- :param data: Data to write to the file+ :param data: Data to write to the file, can be a `str`, `bytes`, or `IO`.:param user: Run the operation as this user- :param request_timeout: Timeout for the request+ :param request_timeout: Timeout for the request in **seconds**+:return: Information about the written file"""if isinstance(data, TextIOBase):@@ -156,11 +180,12 @@ class Filesystem:request_timeout: Optional[float] = None,) -> List[EntryInfo]:"""- Lists entries in a directory.+ List entries in a directory.:param path: Path to the directory:param user: Run the operation as this user- :param request_timeout: Timeout for the request+ :param request_timeout: Timeout for the request in **seconds**+:return: List of entries in the directory"""try:@@ -192,11 +217,13 @@ class Filesystem:request_timeout: Optional[float] = None,) -> bool:"""- Checks if a file or a directory exists.+ Check if a file or a directory exists.:param path: Path to a file or a directory- :param user Run the operation as this user- :param request_timeout Timeout for the request+ :param user: Run the operation as this user+ :param request_timeout: Timeout for the request in **seconds**++ :return: `True` if the file or directory exists, `False` otherwise"""try:await self._rpc.astat(@@ -222,10 +249,11 @@ class Filesystem:request_timeout: Optional[float] = None,) -> None:"""- Removes a file or a directory.+ Remove a file or a directory.+:param path: Path to a file or a directory:param user: Run the operation as this user- :param request_timeout: Timeout for the request+ :param request_timeout: Timeout for the request in **seconds**"""try:await self._rpc.aremove(@@ -246,12 +274,12 @@ class Filesystem:request_timeout: Optional[float] = None,) -> EntryInfo:"""- Renames a file or directory from one path to another.+ Rename a file or directory.- :param old_path Path to the file or directory to move- :param new_path Path to move the file or directory to- :param user Run the operation as this user- :param request_timeout Timeout for the request+ :param old_path: Path to the file or directory to rename+ :param new_path: New path to the file or directory+ :param user: Run the operation as this user+ :param request_timeout: Timeout for the request in **seconds**:return: Information about the renamed file or directory"""@@ -282,12 +310,13 @@ class Filesystem:request_timeout: Optional[float] = None,) -> bool:"""- Creates a new directory and all directories along the way if needed on the specified path.+ Create a new directory and all directories along the way if needed on the specified path.:param path: Path to a new directory. For example '/dirA/dirB' when creating 'dirB'.:param user: Run the operation as this user- :param request_timeout: Timeout for the request- :return: True if the directory was created, False if the directory already exists+ :param request_timeout: Timeout for the request in **seconds**++ :return: `True` if the directory was created, `False` if the directory already exists"""try:await self._rpc.amake_dir(@@ -315,15 +344,16 @@ class Filesystem:timeout: Optional[float] = 60,) -> AsyncWatchHandle:"""- Watches directory for filesystem events.+ Watch directory for filesystem events.- :param path: Path to a directory that will be watched- :param on_event: Callback that will be called on each event- :param on_exit: Callback that will be called when the watch is closed+ :param path: Path to a directory to watch+ :param on_event: Callback to call on each event in the directory+ :param on_exit: Callback to call when the watching ends:param user: Run the operation as this user- :param request_timeout: Timeout for the request- :param timeout: Timeout for the watch, after which the watch will be closed- :return: Watcher handle+ :param request_timeout: Timeout for the request in **seconds**+ :param timeout: Timeout for the watch operation in **seconds**. Using `0` will not limit the watch time++ :return: `AsyncWatchHandle` object for stopping watching directory"""events = self._rpc.awatch_dir(filesystem_pb2.WatchDirRequest(path=path),diff --git a/packages/python-sdk/e2b/sandbox_async/filesystem/watch_handle.py b/packages/python-sdk/e2b/sandbox_async/filesystem/watch_handle.pyindex 283b2534b..33759d88c 100644--- a/packages/python-sdk/e2b/sandbox_async/filesystem/watch_handle.py+++ b/packages/python-sdk/e2b/sandbox_async/filesystem/watch_handle.py@@ -6,12 +6,14 @@ from typing import Any, AsyncGenerator, Optionalfrom e2b.envd.rpc import handle_rpc_exceptionfrom e2b.envd.filesystem.filesystem_pb2 import WatchDirResponsefrom e2b.sandbox.filesystem.watch_handle import FilesystemEvent, map_event_type-from e2b.sandbox_async.utilts import OutputHandler+from e2b.sandbox_async.utils import OutputHandlerclass AsyncWatchHandle:"""- Class representing the watch operation. It provides method to stop the watch operation.+ Handle for watching a directory in the sandbox filesystem.++ Use `.stop()` to stop watching the directory."""def __init__(diff --git a/packages/python-sdk/e2b/sandbox_async/main.py b/packages/python-sdk/e2b/sandbox_async/main.pyindex 74627e297..cb31e3cb1 100644--- a/packages/python-sdk/e2b/sandbox_async/main.py+++ b/packages/python-sdk/e2b/sandbox_async/main.py@@ -1,17 +1,18 @@import logging+import httpx+from typing import Dict, Optional, TypedDict, overload+from typing_extensions import Unpack-import httpxfrom e2b.connection_config import ConnectionConfigfrom e2b.envd.api import ENVD_API_HEALTH_ROUTE, ahandle_envd_api_exceptionfrom e2b.exceptions import format_request_timeout_errorfrom e2b.sandbox.main import SandboxSetupfrom e2b.sandbox.utils import class_method_variantfrom e2b.sandbox_async.filesystem.filesystem import Filesystem-from e2b.sandbox_async.process.process import Process-from e2b.sandbox_async.process.pty import Pty+from e2b.sandbox_async.commands.command import Commands+from e2b.sandbox_async.commands.pty import Ptyfrom e2b.sandbox_async.sandbox_api import SandboxApi-from typing_extensions import Unpacklogger = logging.getLogger(__name__)@@ -35,23 +36,22 @@ class AsyncSandboxOpts(TypedDict):class AsyncSandbox(SandboxSetup, SandboxApi):"""- E2B cloud sandbox gives your agent a full cloud development environment that's sandboxed.+ E2B cloud sandbox is a secure and isolated cloud environment.- That means:- - Access to Linux OS- - Using filesystem (create, list, and delete files and dirs)+ The sandbox allows you to:+ - Access Linux OS+ - Create, list, and delete files and directories- Run commands- - Sandboxed - you can run any code- - Access to the internet-- Check usage docs - https://e2b.dev/docs/sandbox/overview+ - Run isolated code+ - Access the internet- These cloud sandboxes are meant to be used for agents. Like a sandboxed playgrounds, where the agent can do whatever it wants.+ Check docs [here](https://e2b.dev/docs).Use the `AsyncSandbox.create()` to create a new sandbox.Example:```python+ from e2b import AsyncSandboxsandbox = await AsyncSandbox.create()```"""@@ -59,48 +59,42 @@ class AsyncSandbox(SandboxSetup, SandboxApi):@propertydef files(self) -> Filesystem:"""- Filesystem module for interacting with the sandbox's filesystem+ Module for interacting with the sandbox filesystem.."""return self._filesystem@property- def commands(self) -> Process:+ def commands(self) -> Commands:"""- Commands module for interacting with the sandbox's processes+ Module for running commands in the sandbox."""- return self._process+ return self._commands@propertydef pty(self) -> Pty:"""- PTY module for interacting with the sandbox's pseudo-terminal.+ Module for interacting with the sandbox pseudo-terminal."""return self._pty@propertydef sandbox_id(self) -> str:"""- Get the sandbox ID+ Unique identifier of the sandbox."""return self._sandbox_id@propertydef envd_api_url(self) -> str:- """- Get the sandbox API URL- """return self._envd_api_url@propertydef connection_config(self) -> ConnectionConfig:- """- Get the ConnectionConfig object- """return self._connection_configdef __init__(self, **opts: Unpack[AsyncSandboxOpts]):"""- Use `Sandbox.create()` instead.+ Use `AsyncSandbox.create()` to create a new sandbox instead."""super().__init__()@@ -121,7 +115,7 @@ class AsyncSandbox(SandboxSetup, SandboxApi):self._transport._pool,self._envd_api,)- self._process = Process(+ self._commands = Commands(self.envd_api_url,self.connection_config,self._transport._pool,@@ -136,6 +130,8 @@ class AsyncSandbox(SandboxSetup, SandboxApi):"""Check if the sandbox is running.+ :param request_timeout: Timeout for the request in **seconds**+:return: `True` if the sandbox is running, `False` otherwiseExample@@ -179,10 +175,20 @@ class AsyncSandbox(SandboxSetup, SandboxApi):request_timeout: Optional[float] = None,):"""- Creates a new sandbox.+ Create a new sandbox.++ By default, the sandbox is created from the default `base` sandbox template.- This method creates a new sandbox in the async version,- you have to use this method instead of using the constructor.+ :param template: Sandbox template name or ID+ :param timeout: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.+ :param metadata: Custom metadata for the sandbox+ :param envs: Custom environment variables for the sandbox+ :param api_key: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+ :param request_timeout: Timeout for the request in **seconds**++ :return: sandbox instance for the new sandbox++ Use this method instead of using the constructor to create a new sandbox."""connection_config = ConnectionConfig(api_key=api_key,@@ -220,12 +226,13 @@ class AsyncSandbox(SandboxSetup, SandboxApi):debug: Optional[bool] = None,):"""- Connects to an existing Sandbox.+ Connect to an existing sandbox.+ With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).+:param sandbox_id: Sandbox ID- :param api_key: E2B API Key- :param domain: E2B Domain (use only if you self-host E2B)- :param debug: For developing purposes, uses a local sandbox- :return: Sandbox object+ :param api_key: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable++ :return: sandbox instance for the existing sandbox@example```python@@ -254,6 +261,13 @@ class AsyncSandbox(SandboxSetup, SandboxApi):@overloadasync def kill(self, request_timeout: Optional[float] = None) -> bool:+ """+ Kill the sandbox.++ :param request_timeout: Timeout for the request in **seconds**++ :return: `True` if the sandbox was killed, `False` if the sandbox was not found+ """...@overload@@ -265,16 +279,19 @@ class AsyncSandbox(SandboxSetup, SandboxApi):debug: Optional[bool] = None,request_timeout: Optional[float] = None,) -> bool:- ...-- @class_method_variant("_cls_kill")- async def kill(self, request_timeout: Optional[float] = None) -> bool: # type: ignore"""- Kill the sandbox.+ Kill the sandbox specified by sandbox ID.++ :param sandbox_id: Sandbox ID+ :param api_key: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable+ :param request_timeout: Timeout for the request in **seconds**- :param request_timeout: Timeout for the request:return: `True` if the sandbox was killed, `False` if the sandbox was not found"""+ ...++ @class_method_variant("_cls_kill")+ async def kill(self, request_timeout: Optional[float] = None) -> bool: # type: ignoreconfig_dict = self.connection_config.__dict__config_dict.pop("access_token", None)config_dict.pop("api_url", None)@@ -293,6 +310,16 @@ class AsyncSandbox(SandboxSetup, SandboxApi):timeout: int,request_timeout: Optional[float] = None,) -> None:+ """+ Set the timeout of the sandbox.+ After the timeout expires the sandbox will be automatically killed.+ This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.++ Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.++ :param timeout: Timeout for the sandbox in **seconds**+ :param request_timeout: Timeout for the request in **seconds**+ """...@overload@@ -305,6 +332,17 @@ class AsyncSandbox(SandboxSetup, SandboxApi):debug: Optional[bool] = None,request_timeout: Optional[float] = None,) -> None:+ """+ Set the timeout of the specified sandbox.+ After the timeout expires the sandbox will be automatically killed.+ This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.++ Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.++ :param sandbox_id: Sandbox ID+ :param timeout: Timeout for the sandbox in **seconds**+ :param request_timeout: Timeout for the request in **seconds**+ """...@class_method_variant("_cls_set_timeout")@@ -313,14 +351,6 @@ class AsyncSandbox(SandboxSetup, SandboxApi):timeout: int,request_timeout: Optional[float] = None,) -> None:- """- Set the sandbox's timeout, after which the sandbox will be automatically killed.- The sandbox can be kept alive for a maximum of 24 hours from the time of creation.- If you try to set the timeout to a period, which exceeds the maximum limit, the timeout will be set to the maximum limit.-- :param timeout: Duration in milliseconds. Must be between 0 and 86400000 milliseconds (24 hours).- :param request_timeout: Timeout for the request- """config_dict = self.connection_config.__dict__config_dict.pop("access_token", None)config_dict.pop("api_url", None)diff --git a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py b/packages/python-sdk/e2b/sandbox_async/sandbox_api.pyindex 256ed5ece..ea99105cc 100644--- a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py+++ b/packages/python-sdk/e2b/sandbox_async/sandbox_api.py@@ -24,6 +24,14 @@ class SandboxApi(SandboxApiBase):debug: Optional[bool] = None,request_timeout: Optional[float] = None,) -> List[SandboxInfo]:+ """+ List all running sandboxes.++ :param api_key: API key to use for authentication, defaults to `E2B_API_KEY` environment variable+ :param request_timeout: Timeout for the request in **seconds**++ :return: List of running sandboxes+ """config = ConnectionConfig(api_key=api_key,domain=domain,diff --git a/packages/python-sdk/e2b/sandbox_async/utilts.py b/packages/python-sdk/e2b/sandbox_async/utils.pysimilarity index 100%rename from packages/python-sdk/e2b/sandbox_async/utilts.pyrename to packages/python-sdk/e2b/sandbox_async/utils.pydiff --git a/packages/python-sdk/e2b/sandbox_sync/process/process.py b/packages/python-sdk/e2b/sandbox_sync/commands/command.pysimilarity index 96%rename from packages/python-sdk/e2b/sandbox_sync/process/process.pyrename to packages/python-sdk/e2b/sandbox_sync/commands/command.pyindex a20d14d8f..d933cb499 100644--- a/packages/python-sdk/e2b/sandbox_sync/process/process.py+++ b/packages/python-sdk/e2b/sandbox_sync/commands/command.py@@ -11,12 +11,12 @@ from e2b.connection_config import (from e2b.envd.process import process_connect, process_pb2from e2b.envd.rpc import authentication_header, handle_rpc_exceptionfrom e2b.exceptions import SandboxException-from e2b.sandbox.process.main import ProcessInfo-from e2b.sandbox.process.process_handle import ProcessResult-from e2b.sandbox_sync.process.process_handle import ProcessHandle+from e2b.sandbox.commands.main import ProcessInfo+from e2b.sandbox.commands.command_handle import CommandResult+from e2b.sandbox_sync.commands.command_handle import CommandHandle-class Process:+class Commands:def __init__(self,envd_api_url: str,@@ -132,8 +132,7 @@ class Process:on_stderr: Optional[Callable[[str], None]] = None,timeout: Optional[float] = 60,request_timeout: Optional[float] = None,- ) -> ProcessResult:- ...+ ) -> CommandResult: ...@overloaddef run(@@ -147,8 +146,7 @@ class Process:on_stderr: None = None,timeout: Optional[float] = 60,request_timeout: Optional[float] = None,- ) -> ProcessHandle:- ...+ ) -> CommandHandle: ...def run(self,@@ -231,7 +229,7 @@ class Process:f"Failed to start process: expected start event, got {start_event}")- return ProcessHandle(+ return CommandHandle(pid=start_event.event.start.pid,handle_kill=lambda: self.kill(start_event.event.start.pid),events=events,@@ -273,7 +271,7 @@ class Process:f"Failed to connect to process: expected start event, got {start_event}")- return ProcessHandle(+ return CommandHandle(pid=start_event.event.start.pid,handle_kill=lambda: self.kill(start_event.event.start.pid),events=events,diff --git a/packages/python-sdk/e2b/sandbox_sync/process/process_handle.py b/packages/python-sdk/e2b/sandbox_sync/commands/command_handle.pysimilarity index 92%rename from packages/python-sdk/e2b/sandbox_sync/process/process_handle.pyrename to packages/python-sdk/e2b/sandbox_sync/commands/command_handle.pyindex 5de9af4bd..16d6021a1 100644--- a/packages/python-sdk/e2b/sandbox_sync/process/process_handle.py+++ b/packages/python-sdk/e2b/sandbox_sync/commands/command_handle.py@@ -2,16 +2,16 @@ from typing import Optional, Callable, Any, Generator, Union, Tuplefrom e2b.envd.rpc import handle_rpc_exceptionfrom e2b.envd.process import process_pb2-from e2b.sandbox.process.process_handle import (- ProcessExitException,- ProcessResult,+from e2b.sandbox.commands.command_handle import (+ CommandExitException,+ CommandResult,Stderr,Stdout,PtyOutput,)-class ProcessHandle:+class CommandHandle:"""Class representing a process. It provides methods for waiting and killing the process.It is also used to iterate over the process output.@@ -39,7 +39,7 @@ class ProcessHandle:self._stdout: str = ""self._stderr: str = ""- self._result: Optional[ProcessResult] = None+ self._result: Optional[CommandResult] = Noneself._iteration_exception: Optional[Exception] = Nonedef __iter__(self):@@ -69,7 +69,7 @@ class ProcessHandle:if event.event.data.pty:yield None, None, event.event.data.ptyif event.event.HasField("end"):- self._result = ProcessResult(+ self._result = CommandResult(stdout=self._stdout,stderr=self._stderr,exit_code=event.event.end.exit_code,@@ -87,10 +87,10 @@ class ProcessHandle:on_pty: Optional[Callable[[PtyOutput], None]] = None,on_stdout: Optional[Callable[[str], None]] = None,on_stderr: Optional[Callable[[str], None]] = None,- ) -> ProcessResult:+ ) -> CommandResult:"""Waits for the process to finish and returns the result.- If the process exits with a non-zero exit code, it throws a `ProcessExitException`.+ If the process exits with a non-zero exit code, it throws a `CommandExitException`.:param on_pty: Callback for pty output:param on_stdout: Callback for stdout output@@ -117,7 +117,7 @@ class ProcessHandle:raise Exception("Process ended without an end event")if self._result.exit_code != 0:- raise ProcessExitException(+ raise CommandExitException(stdout=self._stdout,stderr=self._stderr,exit_code=self._result.exit_code,diff --git a/packages/python-sdk/e2b/sandbox_sync/process/pty.py b/packages/python-sdk/e2b/sandbox_sync/commands/pty.pysimilarity index 79%rename from packages/python-sdk/e2b/sandbox_sync/process/pty.pyrename to packages/python-sdk/e2b/sandbox_sync/commands/pty.pyindex 92099f5d3..6e7af290c 100644--- a/packages/python-sdk/e2b/sandbox_sync/process/pty.py+++ b/packages/python-sdk/e2b/sandbox_sync/commands/pty.py@@ -12,13 +12,13 @@ from e2b.connection_config import ()from e2b.exceptions import SandboxExceptionfrom e2b.envd.rpc import authentication_header, handle_rpc_exception-from e2b.sandbox.process.process_handle import PtySize-from e2b.sandbox_sync.process.process_handle import ProcessHandle+from e2b.sandbox.commands.command_handle import PtySize+from e2b.sandbox_sync.commands.command_handle import CommandHandleclass Pty:"""- Manager for starting and interacting with PTY (pseudo-terminal) processes in the sandbox.+ Module for interacting with PTYs (pseudo-terminals) in the sandbox."""def __init__(@@ -42,11 +42,12 @@ class Pty:request_timeout: Optional[float] = None,) -> bool:"""- Kills a process.+ Kill PTY.- :param pid: Process ID to kill. You can get the list of processes using `sandbox.commands.list()`.- :param request_timeout: Timeout for the request- :return: `true` if the process was killed, `false` if the process was not found+ :param pid: Process ID of the PTY+ :param request_timeout: Timeout for the request in **seconds**++ :return: `true` if the PTY was killed, `false` if the PTY was not found"""try:self._rpc.send_signal(@@ -72,11 +73,11 @@ class Pty:request_timeout: Optional[float] = None,) -> None:"""- Sends input to a PTY process.+ Send input to a PTY.- :param pid: Process ID of the PTY process+ :param pid: Process ID of the PTY:param data: Input data to send- :param request_timeout: Timeout for the request+ :param request_timeout: Timeout for the request in **seconds**"""try:self._rpc.send_input(@@ -101,17 +102,18 @@ class Pty:envs: Optional[Dict[str, str]] = None,timeout: Optional[float] = 60,request_timeout: Optional[float] = None,- ) -> ProcessHandle:+ ) -> CommandHandle:"""- Starts a new process with a PTY (pseudo-terminal).+ Start a new PTY (pseudo-terminal).:param size: Size of the PTY- :param user: User to start the process as- :param cwd: Current working directory- :param envs: Environment variables- :param timeout: Timeout for the request- :param request_timeout: Timeout for the request- :return: New process+ :param user: User to use for the PTY+ :param cwd: Working directory for the PTY+ :param envs: Environment variables for the PTY+ :param timeout: Timeout for the PTY in **seconds**+ :param request_timeout: Timeout for the request in **seconds**++ :return: Handle to interact with the PTY"""envs = envs or {}envs["TERM"] = "xterm-256color"@@ -145,7 +147,7 @@ class Pty:f"Failed to start process: expected start event, got {start_event}")- return ProcessHandle(+ return CommandHandle(pid=start_event.event.start.pid,handle_kill=lambda: self.kill(start_event.event.start.pid),events=events,@@ -160,11 +162,12 @@ class Pty:request_timeout: Optional[float] = None,) -> None:"""- Resizes a PTY process (changes the number of columns and rows in the terminal).+ Resize PTY.+ Call this when the terminal window is resized and the number of columns and rows has changed.- :param pid: Process ID of the PTY process+ :param pid: Process ID of the PTY:param size: New size of the PTY- :param request_timeout: Timeout for the request+ :param request_timeout: Timeout for the request in **seconds**s"""self._rpc.update(process_pb2.UpdateRequest(diff --git a/packages/python-sdk/e2b/sandbox_sync/main.py b/packages/python-sdk/e2b/sandbox_sync/main.pyindex 6910d836a..a0132ae25 100644--- a/packages/python-sdk/e2b/sandbox_sync/main.py+++ b/packages/python-sdk/e2b/sandbox_sync/main.py@@ -8,8 +8,8 @@ from e2b.exceptions import SandboxException, format_request_timeout_errorfrom e2b.sandbox.main import SandboxSetupfrom e2b.sandbox.utils import class_method_variantfrom e2b.sandbox_sync.filesystem.filesystem import Filesystem-from e2b.sandbox_sync.process.process import Process-from e2b.sandbox_sync.process.pty import Pty+from e2b.sandbox_sync.commands.command import Commands+from e2b.sandbox_sync.commands.pty import Ptyfrom e2b.sandbox_sync.sandbox_api import SandboxApilogger = logging.getLogger(__name__)@@ -33,7 +33,7 @@ class Sandbox(SandboxSetup, SandboxApi):That means:- Access to Linux OS- - Using filesystem (create, list, and delete files and dirs)+ - Using filesystem (create, list, and delete files and directories)- Run commands- Sandboxed - you can run any code- Access to the internet@@ -58,11 +58,11 @@ class Sandbox(SandboxSetup, SandboxApi):return self._filesystem@property- def commands(self) -> Process:+ def commands(self) -> Commands:"""Commands module for interacting with the sandbox's processes"""- return self._process+ return self._commands@propertydef pty(self) -> Pty:@@ -152,7 +152,7 @@ class Sandbox(SandboxSetup, SandboxApi):self._transport._pool,self._envd_api,)- self._process = Process(+ self._commands = Commands(self.envd_api_url,self.connection_config,self._transport._pool,@@ -235,8 +235,7 @@ class Sandbox(SandboxSetup, SandboxApi):self.kill()@overload- def kill(self, request_timeout: Optional[float] = None) -> bool:- ...+ def kill(self, request_timeout: Optional[float] = None) -> bool: ...@overload@staticmethod@@ -246,8 +245,7 @@ class Sandbox(SandboxSetup, SandboxApi):domain: Optional[str] = None,debug: Optional[bool] = None,request_timeout: Optional[float] = None,- ) -> bool:- ...+ ) -> bool: ...@class_method_variant("_cls_kill")def kill(self, request_timeout: Optional[float] = None) -> bool: # type: ignore@@ -274,8 +272,7 @@ class Sandbox(SandboxSetup, SandboxApi):self,timeout: int,request_timeout: Optional[float] = None,- ) -> None:- ...+ ) -> None: ...@overload@staticmethod@@ -286,8 +283,7 @@ class Sandbox(SandboxSetup, SandboxApi):domain: Optional[str] = None,debug: Optional[bool] = None,request_timeout: Optional[float] = None,- ) -> None:- ...+ ) -> None: ...@class_method_variant("_cls_set_timeout")def set_timeout( # type: ignorediff --git a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.pyindex bf03b05d5..8e37aab02 100644--- a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py+++ b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py@@ -25,6 +25,14 @@ class SandboxApi(SandboxApiBase):debug: Optional[bool] = None,request_timeout: Optional[float] = None,) -> List[SandboxInfo]:+ """+ List all running sandboxes.++ :param api_key: API key to use for authentication, defaults to `E2B_API_KEY` environment variable+ :param request_timeout: Timeout for the request in **seconds**++ :return: List of sandbox info+ """config = ConnectionConfig(api_key=api_key,domain=domain,diff --git a/packages/python-sdk/example.py b/packages/python-sdk/example.pyindex 98a7fcf17..bbc9e6c67 100644--- a/packages/python-sdk/example.py+++ b/packages/python-sdk/example.py@@ -12,15 +12,7 @@ logging.basicConfig(level=logging.ERROR)async def main():sbx = await AsyncSandbox.create(timeout=10, debug=True)- await sbx.files.make_dir("test")- with open("Makefile", "rb") as f, open("Makefile", "rb") as f2:- await sbx.files.write("/home/user/test/a.txt", f, f2)- print(await sbx.files.list("test"))- print(await sbx.files.list("/home/user/test"))- # for _ in range(10):- # start = time.time()- # end = time.time()- # print(f"Time taken: {end - start}")+ await sbx.set_timeout(20)if __name__ == "__main__":diff --git a/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_kill.py b/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_kill.pyindex c121e8c57..e49005c3b 100644--- a/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_kill.py+++ b/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_kill.py@@ -1,6 +1,6 @@import pytest-from e2b import AsyncSandbox, ProcessExitException+from e2b import AsyncSandbox, CommandExitExceptionasync def test_kill_process(async_sandbox: AsyncSandbox):@@ -9,7 +9,7 @@ async def test_kill_process(async_sandbox: AsyncSandbox):await async_sandbox.commands.kill(pid)- with pytest.raises(ProcessExitException):+ with pytest.raises(CommandExitException):await async_sandbox.commands.run(f"kill -0 {pid}")diff --git a/packages/python-sdk/tests/async/sandbox_async/pty/test_pty_create.py b/packages/python-sdk/tests/async/sandbox_async/pty/test_pty_create.pyindex 12eb76f58..eec044dec 100644--- a/packages/python-sdk/tests/async/sandbox_async/pty/test_pty_create.py+++ b/packages/python-sdk/tests/async/sandbox_async/pty/test_pty_create.py@@ -1,5 +1,5 @@from e2b import AsyncSandbox-from e2b.sandbox.process.process_handle import PtySize+from e2b.sandbox.commands.command_handle import PtySizeasync def test_pty_create(async_sandbox: AsyncSandbox):diff --git a/packages/python-sdk/tests/async/sandbox_async/pty/test_resize.py b/packages/python-sdk/tests/async/sandbox_async/pty/test_resize.pyindex 3e91805de..ca91ff64a 100644--- a/packages/python-sdk/tests/async/sandbox_async/pty/test_resize.py+++ b/packages/python-sdk/tests/async/sandbox_async/pty/test_resize.py@@ -1,5 +1,5 @@from e2b import AsyncSandbox-from e2b.sandbox.process.process_handle import PtySize+from e2b.sandbox.commands.command_handle import PtySizeasync def test_resize(async_sandbox: AsyncSandbox):diff --git a/packages/python-sdk/tests/async/sandbox_async/pty/test_send_input.py b/packages/python-sdk/tests/async/sandbox_async/pty/test_send_input.pyindex bd5d2dd84..d54eeaa09 100644--- a/packages/python-sdk/tests/async/sandbox_async/pty/test_send_input.py+++ b/packages/python-sdk/tests/async/sandbox_async/pty/test_send_input.py@@ -1,5 +1,5 @@from e2b import AsyncSandbox-from e2b.sandbox.process.process_handle import PtySize+from e2b.sandbox.commands.command_handle import PtySizeasync def test_send_input(async_sandbox: AsyncSandbox):diff --git a/packages/python-sdk/tests/bugs/test_envelope_decode.py b/packages/python-sdk/tests/bugs/test_envelope_decode.pyindex a7a18dc8b..58af3bd90 100644--- a/packages/python-sdk/tests/bugs/test_envelope_decode.py+++ b/packages/python-sdk/tests/bugs/test_envelope_decode.py@@ -1,5 +1,5 @@import uuid-from e2b.sandbox.process.process_handle import ProcessExitException+from e2b.sandbox.commands.command_handle import CommandExitExceptionimport pytest@@ -38,7 +38,7 @@ exit(0)def test_envelope_decode():with Desktop(timeout=30) as desktop:for _ in range(10):- with pytest.raises(ProcessExitException):+ with pytest.raises(CommandExitException):desktop.pyautogui("""pyautogui.write("Hello, ")diff --git a/packages/python-sdk/tests/sync/sandbox_sync/commands/test_cmd_kill.py b/packages/python-sdk/tests/sync/sandbox_sync/commands/test_cmd_kill.pyindex ed9e21bd3..9ae629d8e 100644--- a/packages/python-sdk/tests/sync/sandbox_sync/commands/test_cmd_kill.py+++ b/packages/python-sdk/tests/sync/sandbox_sync/commands/test_cmd_kill.py@@ -1,6 +1,6 @@import pytest-from e2b import Sandbox, ProcessExitException+from e2b import Sandbox, CommandExitExceptiondef test_kill_process(sandbox: Sandbox):@@ -9,7 +9,7 @@ def test_kill_process(sandbox: Sandbox):sandbox.commands.kill(pid)- with pytest.raises(ProcessExitException):+ with pytest.raises(CommandExitException):sandbox.commands.run(f"kill -0 {pid}")diff --git a/packages/python-sdk/tests/sync/sandbox_sync/pty/test_pty.py b/packages/python-sdk/tests/sync/sandbox_sync/pty/test_pty.pyindex 9f815e02c..1dd6255ba 100644--- a/packages/python-sdk/tests/sync/sandbox_sync/pty/test_pty.py+++ b/packages/python-sdk/tests/sync/sandbox_sync/pty/test_pty.py@@ -1,5 +1,5 @@from e2b import Sandbox-from e2b.sandbox.process.process_handle import PtySize+from e2b.sandbox.commands.command_handle import PtySizedef test_pty(sandbox: Sandbox):diff --git a/packages/python-sdk/tests/sync/sandbox_sync/pty/test_resize.py b/packages/python-sdk/tests/sync/sandbox_sync/pty/test_resize.pyindex dba9fad6c..726b34ee1 100644--- a/packages/python-sdk/tests/sync/sandbox_sync/pty/test_resize.py+++ b/packages/python-sdk/tests/sync/sandbox_sync/pty/test_resize.py@@ -1,5 +1,5 @@from e2b import Sandbox-from e2b.sandbox.process.process_handle import PtySize+from e2b.sandbox.commands.command_handle import PtySizedef test_resize(sandbox: Sandbox):diff --git a/packages/python-sdk/tests/sync/sandbox_sync/pty/test_send_input.py b/packages/python-sdk/tests/sync/sandbox_sync/pty/test_send_input.pyindex dbb62923f..15c5df034 100644--- a/packages/python-sdk/tests/sync/sandbox_sync/pty/test_send_input.py+++ b/packages/python-sdk/tests/sync/sandbox_sync/pty/test_send_input.py@@ -1,5 +1,5 @@from e2b import Sandbox-from e2b.sandbox.process.process_handle import PtySize+from e2b.sandbox.commands.command_handle import PtySizedef test_send_input(sandbox: Sandbox):