sandbox.commands for foreground and background execution inside a running
sandbox.
Use shell=True for authored shell snippets. Use args=[...] for exact argv;
shell=True cannot be combined with args.
Foreground commands
CommandResult includes exit_code, stdout, stderr, and optional pid.
Non-zero command exits are returned in exit_code; they are not raised as SDK
exceptions.
Background processes
BackgroundCommand exposes pid, wait(), kill(),
get_logs(), disconnect(), and iteration over new stdout/stderr chunks.
Pass callbacks with background=True when you want live output while the
process keeps running:
Streaming
on_stdout or on_stderr directly to
sandbox.commands.run(...) to use the streaming path.
Reconnect to an existing running PID:
Stdin and argv
cwd values must be valid sandbox paths and cannot target
runtime-managed paths under /workspace/.nullspace.
Process APIs return ProcessInfo(pid, command, running) and
CommandLogs(stdout, stderr, output, exit_code).
Async
AsyncSandbox exposes the same commands namespace with awaitable methods:
Git helpers
sandbox.git includes first-class helpers for common repository workflows:
clone(), pull(), checkout(), create_branch(),
delete_branch(), branches(), add(), commit(), push(), status(),
diff(), remote_add(), set_config(), get_config(), configure_user(),
add_ssh_key(), and dangerously_authenticate(). commit() uses the repo’s
configured Git identity unless you pass author_name and author_email for a
one-off commit.
Concept: Exec. API reference:
execCommand, listProcesses,
sendStdin, getProcessLogs, and
killProcess.