Install
[sandbox] extra for Python installs websockets, which enables real-time streaming and timeout=0. Without it, run() falls back to HTTP automatically. For TypeScript, install the optional ws package for WebSocket streaming:
Create and run a sandbox
Run commands
Everyrun() call returns an ExecutionResult with stdout, stderr, exit_code, and success.
Stream output
For long-running commands, stream output in real time using callbacks or aCommandHandle.
Stream with callbacks
Stream with CommandHandle
Setwait=False to get a CommandHandle for full control over the output stream.
Send stdin and kill commands
Reconnect to a running command
If a client disconnects, reconnect using the command ID:File operations
Read and write files in the sandbox:Command lifecycle and TTL
The sandbox daemon manages command session lifecycles with two timeout mechanisms:- Session TTL (finished commands): After a command finishes, its session remains in memory for a TTL period. During this window you can reconnect to retrieve output. After the TTL expires, the session is cleaned up.
- Idle timeout (running commands): Running commands with no connected clients are killed after an idle timeout (default: 5 minutes). The idle timer resets each time a client connects. Set to
-1for no idle timeout.
Combine lifecycle options
kill_on_disconnect=True (Python) or killOnDisconnect: true (TypeScript) to kill the command immediately when the last client disconnects, instead of waiting for the idle timeout.
TCP tunnels (Python)
Access any TCP service running inside a sandbox as if it were local. The tunnel opens a local TCP port and forwards connections through a WebSocket to the target port inside the sandbox.Async support (Python)
The Python SDK provides a full async client:Error handling
Both SDKs provide typed exceptions for specific error handling:For more details, see the sandbox SDK reference on GitHub for Python or TypeScript.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

