Run shell commands inside a sandbox viaDocumentation Index
Fetch the complete documentation index at: https://docs.superserve.ai/llms.txt
Use this file to discover all available pages before exploring further.
sandbox.commands. Running a command on a paused sandbox transparently resumes it and executes.
run (synchronous)
Execute a command and wait for it to finish. Returns a CommandResult.
run (streaming)
Pass onStdout / on_stdout and/or onStderr / on_stderr callbacks. Output is delivered over Server-Sent Events and flushed to your callback as it arrives. The final result still contains the full concatenated output.
Streaming uses an idle timeout - the timer resets on every chunk. A command that produces output regularly will not trip the timeout no matter how long it runs overall. A completely silent command still has to finish before the timeout.
Options
| Option | Type | Description |
|---|---|---|
cwd | string | Working directory. Server-side default when unset. |
env | Record<string, string> | Env vars for this command only (merged with sandbox-wide env vars). |
timeoutMs / timeout_seconds | number | Command timeout. Only sent when specified. |
onStdout / on_stdout | (data: string) => void | Stream stdout chunks. |
onStderr / on_stderr | (data: string) => void | Stream stderr chunks. |
signal | AbortSignal | TypeScript only - abort mid-execution. |
CommandResult
Non-zero exit codes
run() does not raise for non-zero exits. Inspect the exit code yourself.
Errors
Commonly raised:TimeoutError/SandboxTimeoutError- timeout elapsed before the command finishedNotFoundError- sandbox was deletedConflictError- sandbox is in an invalid stateSandboxError- connection dropped mid-stream without a terminalfinishedevent (streaming only)