Skip to main content
Accessed via sandbox.exec.

await sandbox.exec.run(command, ...)

Run a command synchronously via sh -c. HTTP API →
command
str
required
Shell command
timeout
int
default:"60"
Timeout in seconds
env
dict[str, str]
Environment variables
cwd
str
Working directory
Returns: ProcessResult

await sandbox.exec.start(command, ...)

Start a long-running command with streaming I/O. HTTP API →
command
str
required
Command
args
list[str]
Arguments
env
dict[str, str]
Environment variables
cwd
str
Working directory
timeout
int
Timeout in seconds
max_run_after_disconnect
int
Seconds to keep running after disconnect
on_stdout
Callable[[bytes], None]
Stdout callback
on_stderr
Callable[[bytes], None]
Stderr callback
on_exit
Callable[[int], None]
Exit callback
Returns: ExecSession

await sandbox.exec.background(command, ...)

Alias for start. Same signature, same return type. Use when the intent is “run this in the background and observe it”.

await sandbox.exec.shell(...)

Open a stateful shell session. Subsequent .run() calls share the same bash process, so cwd, exported env vars, and shell functions persist — the ergonomics of a terminal tab. Backed by a long-running bash --noprofile --norc session. Foreground-only: concurrent .run() raises ShellBusyError.
cwd
str
Initial working directory
env
dict[str, str]
Initial environment variables
Returns: Shell

Shell

Per-call cwd, env, and timeout are intentionally not supported in v1. Use inline shell syntax (cd /x && cmd, FOO=bar cmd) — the shell state carries across calls.
Errors:
  • ShellBusyError — another run() is in flight (shell is foreground-only).
  • ShellClosedError — bash has exited (explicit close(), a command ran exit, or the session dropped).

await sandbox.exec.attach(session_id, ...)

Reconnect to a running exec session over WebSocket.
session_id
str
required
Session ID
on_stdout
Callable[[bytes], None]
Stdout callback
on_stderr
Callable[[bytes], None]
Stderr callback
on_exit
Callable[[int], None]
Exit callback
on_scrollback_end
Callable[[], None]
Scrollback replay done
Returns: ExecSession

await sandbox.exec.list()

List all exec sessions. HTTP API → Returns: list[ExecSessionInfo]

await sandbox.exec.kill(session_id, signal=9)

Kill an exec session. HTTP API → Returns: None

ExecSession


Types