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.
exec()
Executes a shell command inside the sandbox and waits for it to finish. execute_command is an exact alias, kept for Daytona parity — the two names call the same implementation.
| Parameter | Type | Default | Description |
|---|---|---|---|
command | str | — | Shell command to run. |
cwd | str | None | Working directory. |
env | Dict[str, str] | None | Extra environment variables for this command. |
timeout | int | None | Seconds before the command is killed. |
Returns: ExecuteResponse with exit_code: int, result: str (combined output), and artifacts (a dict containing stdout).
code_run()
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 raises ValueError.
| Parameter | Type | Default | Description |
|---|---|---|---|
code | str | — | Source code to run. |
params | CodeRunParams | None | argv: List[str] and/or env: Dict[str, str]. |
timeout | int | None | Seconds before the run is killed. |
Returns: ExecuteResponse (same shape as exec). Raises: ValueError when the sandbox has no configured code language.
Sessions
Sessions are long-running background shells: create one, execute commands in it (synchronously or async), stream logs, send input, and delete it when done. State (working directory, environment) persists between commands in the same session.
create_session()
Creates a new background session with the id you choose.
get_session()
Fetches a session and its command history.
list_sessions()
Lists all active sessions in the sandbox.
execute_session_command()
Executes a command inside an existing session. With run_async=True in the request, the call returns immediately with a command id you can poll via get_session_command() / get_session_command_logs().
| Parameter | Type | Default | Description |
|---|---|---|---|
session_id | str | — | Target session. |
req | SessionExecuteRequest | — | command: str, run_async: bool = False, suppress_input_echo: bool = False. |
timeout | int | None | Request timeout in seconds. |
Returns: a dict including cmdId, plus stdout/stderr (defaulted to "") and exitCode/output when the command ran synchronously.
get_session_command()
Fetches metadata (command line, exit code) for one command previously executed in a session.
get_session_command_logs()
Fetches the accumulated logs of a session command.
Returns: a dict with output, stdout, and stderr (each defaulted to "").
send_session_command_input()
Sends input to a running session command's stdin — for interactive programs awaiting input.
delete_session()
Deletes a session and terminates anything still running in it.