exec#

SandboxRuntime.exec(instance_id: str, command: str | List[str], timeout: float | None = None, cwd: str | None = None, env: Dict[str, str] | None = None, shell: str | None = None, user: str | None = None) → ExecResult[source]#

Execute a command inside the specified sandbox.

Parameters:
  • instance_id (str) – Unique identifier of the sandbox instance.

  • command (str | List[str]) – Command to execute, either as a string or a list of arguments.

  • timeout (float | None) – Maximum execution time in seconds.

  • cwd (str | None) – Working directory inside the sandbox for command execution.

  • env (Dict[str, str] | None) – Environment variables to set for the command.

  • shell (str | None) – Optional shell for string commands, overriding the sandbox’s configured shell (default /bin/bash).

  • user (str | None) – Optional user to run as: a numeric uid, “uid:gid”, or a user (optionally “:group”) name, resolved against the /etc/passwd and /etc/group inside the running sandbox (default: the image user).

Returns:

ExecResult containing exit code, stdout, and stderr.

Return type:

ExecResult