| Name | Type | Description |
|---|---|---|
command* | str | Shell command to execute. |
timeout | int | Default: 60Command timeout in seconds. |
env | Optional[dict[str, str]] | Default: None |
cwd | Optional[str] | Default: None |
run_config | Optional[Union[RunConfig, dict[str, Any]]] | Default: None |
close_input | Optional[bool] | Default: None |
shell | str | Default: '/bin/bash' |
on_stdout | Optional[Callable[[str], Any]] | Default: None |
on_stderr | Optional[Callable[[str], Any]] | Default: None |
idle_timeout | int | Default: 300 |
kill_on_disconnect | bool | Default: False |
ttl_seconds | int | Default: 600 |
pty | bool | Default: False |
wait | bool | Default: True |
Execute a command in the sandbox asynchronously.
Environment variables to set for the command. Deprecated in
favour of run_config.env_vars; the two cannot be combined.
Working directory for command execution. If None, uses sandbox
default. Deprecated in favour of run_config.work_dir; the
two cannot be combined.
User, working directory and environment for this one
command, layered over the sandbox's own. Accepts a
:class:RunConfig or a plain dict.
Half-close the command's stdin so a command that
reads it sees EOF rather than blocking until the timeout.
Defaults to True for a non-PTY command, which means
send_input() on the returned handle raises unless this is
set to False. Ignored under pty=True, where input and
output share one terminal file descriptor -- send an EOT byte
(0x04) as input instead.
Shell to use for command execution. Defaults to "/bin/bash".
Callback invoked with each stdout chunk as it arrives. Blocks until the command completes and returns ExecutionResult. Cannot be combined with wait=False.
Callback invoked with each stderr chunk as it arrives. Blocks until the command completes and returns ExecutionResult. Cannot be combined with wait=False.
Idle timeout in seconds. If the command has no connected clients for this duration, it is killed. Defaults to 300 (5 minutes). Set to -1 for no idle timeout. Only applies to WebSocket execution.
If True, kill the command immediately when the last client disconnects. Defaults to False (command continues running and can be reconnected to).
How long (in seconds) a finished command's session is kept for reconnection. Defaults to 600 (10 minutes). Set to -1 to keep indefinitely.
If True, allocate a pseudo-terminal for the command. Useful for commands that require a TTY (e.g., interactive programs, commands that use terminal control codes). Defaults to False.
If True (default), block until the command completes and return ExecutionResult. If False, return an AsyncCommandHandle immediately for streaming output, kill, stdin input, and reconnection. Cannot be combined with on_stdout/on_stderr callbacks.