runtime.run_cmd(command=...) accepts either a single shell string or a command + explicit args list:
Basic Usage
Install Packages
Run Shell Scripts
With Environment Variables
Setenv_vars at runtime creation so variables are available to every run_cmd / run_code call:
Streaming Output
For long-running commands, passon_stdout / on_stderr / on_exit callbacks to receive output incrementally as the process produces it. The transport switches to Server-Sent Events transparently; the returned CommandRunResponse still carries the aggregated stdout/stderr/exit_code so existing code keeps working.
agent user inside the runtime. sudo is configured for the agent user with NOPASSWD, so commands like sudo apt-get install -y ... work without prompting.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
command | string | Yes | Command to execute. May be a single shell string or a program name. |
args | list[string] | No | Additional arguments appended to command. |
working_dir | string | No | Working directory. |
timeout | integer | No | Timeout in seconds. |
on_stdout | callable(str) | No | Per-chunk stdout callback. Enables streaming mode. |
on_stderr | callable(str) | No | Per-chunk stderr callback. Enables streaming mode. |
on_exit | callable(int) | No | Final exit-code callback. Enables streaming mode. |
Response
| Field | Type | Description |
|---|---|---|
stdout | string | Standard output (aggregated when streaming) |
stderr | string | Standard error (aggregated when streaming) |
exit_code | integer | Process exit code |
duration_ms | integer | Execution duration in milliseconds |
success | boolean | True when exit code is 0 |
error | string | API-level error (if any) |