commands module on a sandbox lets you run shell commands inside the sandbox. Commands have access to the full Linux userspace, can read and write the sandbox filesystem, and respect environment variables set at the sandbox or command level.
Run a command (blocking)
run() executes the command and waits for it to complete, then returns a CommandResult.
- Python
- TypeScript
CommandResult model
Run options
- Python
- TypeScript
Run with output callbacks
run() accepts on_stdout/on_stderr callbacks that are invoked after the command completes, iterating over the collected output lines. Each callback receives a plain str.
For true real-time streaming as the command produces output, use
run_stream() / runStream() instead.- Python
- TypeScript
Background processes
Passbackground=True to start a long-running process and get a CommandHandle back immediately.
- Python
- TypeScript
CommandHandle
List running commands
- Python
- TypeScript
ProcessInfo model
Send stdin to a running process
- Python
- TypeScript
Kill a command
- Python
- TypeScript
Wait for a command by PID
If you lost theCommandHandle reference, reconnect using connect() and call wait().
- Python
Error handling
- Python
- TypeScript
commands.run() does not throw on non-zero exit codes — check result.exit_code yourself. However, handle.wait() (on background processes) always throws CommandExitException / CommandExitError on non-zero exit codes.