Process
Command execution, code runs, and sessions.
Process runs commands and code inside a sandbox, and manages long-running background sessions. Obtain it as sandbox.process — see the running commands guide for a task-oriented walkthrough.
executeCommand()
Executes a shell command inside the sandbox and waits for it to finish.
| Parameter | Type | Default | Description |
|---|---|---|---|
command | string | — | Shell command to run. |
cwd | string | — | Working directory. |
env | Record<string, string> | — | Extra environment variables for this command. |
timeout | number | — | Seconds before the command is killed. |
Returns: ExecuteResponse with exitCode: number, result: string (combined output), and artifacts: { stdout: string }.
codeRun()
Executes a code string using the sandbox's configured language runtime. The language comes from the code-toolbox-language label set at sandbox creation; without it this throws an Error.
| Parameter | Type | Default | Description |
|---|---|---|---|
code | string | — | Source code to run. |
params | CodeRunParams | — | argv?: string[] and/or env?: Record<string, string>. |
timeout | number | — | Seconds before the run is killed. |
Returns: ExecuteResponse (same shape as executeCommand). Throws: Error when the sandbox has no configured code language.
Sessions
Sessions are long-running background shells: create one, execute commands in it (synchronously or async), fetch logs, send input, and delete it when done. State (working directory, environment) persists between commands in the same session.
createSession()
Creates a new background session with the id you choose.
getSession()
Fetches a session and its command history.
Returns: Session — { sessionId, commands?: Command[] } where Command is { id?, command?, exitCode? }.
listSessions()
Lists all active sessions in the sandbox.
executeSessionCommand()
Executes a command inside an existing session. With runAsync: true in the request, the call returns immediately with a command id you can poll via getSessionCommand() / getSessionCommandLogs().
| Parameter | Type | Default | Description |
|---|---|---|---|
sessionId | string | — | Target session. |
req | SessionExecuteRequest | — | { command: string, runAsync?: boolean, suppressInputEcho?: boolean }. |
timeout | number | — | Request timeout in seconds. |
Returns: SessionExecuteResponse — { cmdId, exitCode?, output?, stdout, stderr } (stdout/stderr default to '').
getSessionCommand()
Fetches metadata (command line, exit code) for one command previously executed in a session.
getSessionCommandLogs()
Fetches the accumulated logs of a session command.
Returns: { output, stdout, stderr } (each defaulted to '').
sendSessionCommandInput()
Sends input to a running session command's stdin — for interactive programs awaiting input.
deleteSession()
Deletes a session and terminates anything still running in it.