DAIMONMCP sandbox, kernel-isolated
by Linux nsjail
Python SDK

Exec

Run commands, background tasks, and interactive sessions inside the sandbox.

ExecAPI.bash

async exec.bash(command, *, timeout_ms=None, description=None, run_in_background=False, dangerously_disable_sandbox=False) -> BashResult
ParameterTypeDefaultDescription
commandstrBash command to execute.
timeout_msint | NoneNoneCommand timeout in milliseconds.
descriptionstr | NoneNoneHuman-readable description of the command.
run_in_backgroundboolFalseRun the command as a background task.
dangerously_disable_sandboxboolFalseDisable sandbox for this command.
result = await client.exec.bash("printf 'hello\n'")
print(result.stdout)

background = await client.exec.bash(
    "sleep 1; echo done",
    run_in_background=True,
)
print(background.background_task_id)

Sessions

Start a persistent TTY session, then write input, poll output, and wait for the process to exit.

async exec.start_session(cmd, *, workdir=None, tty=False, ...) -> SessionHandle

ParameterTypeDefaultDescription
cmdstrCommand to start (e.g. '/bin/cat').
workdirstr | NoneNoneWorking directory for the session.
ttyboolFalseAllocate a TTY for the session.
session = await client.exec.start_session("/bin/cat", tty=True)

echoed = await session.write("hello session\n")
print(echoed.output)

final = await session.wait_for_exit()
print(final.exit_code)

async session.write(chars='', *, yield_time_ms=None, max_output_tokens=None) -> ExecResult

Write characters to the session's stdin.

async session.poll(*, yield_time_ms=None, max_output_tokens=None) -> ExecResult

Poll the session for new output without writing any input.

async session.wait_for_exit(*, timeout_s=10.0, yield_time_ms=5000, ...) -> ExecResult

Poll until the session process exits or timeout is reached.

ParameterTypeDefaultDescription
timeout_sfloat10.0Max wait time in seconds.
yield_time_msint5000Time to yield for output per poll.

async session.close(*, exit_payload='__EXIT__\\n', yield_time_ms=500, ...) -> ExecResult

Send exit signal to the session.

On this page