daytona
A Sandbox on Daytona.
Pass it as agent({sandbox: daytona()}). Each sandbox is private, starts with no environment and its network blocked, and stops, then is deleted, after autoStopMinutes idle as a backstop to the ledger's cleanup. The API key authenticates the host's requests only.
Import from @threads/daytona (TypeScript) or threads.daytona (Python).
function daytona(options?: {
apiKey?: string | Secret;
apiUrl?: string;
snapshot?: string;
target?: string;
lifetimeMs?: number;
allowInternet?: boolean;
autoStopMinutes?: number;
fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
openSocket?: OpenSocket;
pollMs?: number;
waitMs?: number;
}): SandboxParameters
apiKey / api_keystring | SecretThe Daytona API key: a secret() or a string. Omitted: secret("DAYTONA_API_KEY"). Resolved on the host at setup (check() or the first run); unset is missing_secret naming the option and the variable. It never enters a sandbox.
apiUrl / api_urlstringdefault https://app.daytona.io/apiThe Daytona API URL.
snapshotstringThe Daytona snapshot a new sandbox starts from. Omitted: Daytona's default snapshot.
targetstringThe Daytona region (target) sandboxes are created in. Omitted: the organization's default.
lifetimeMs / lifetime_msnumberdefault 3600000How long a sandbox lives, in milliseconds, before Daytona deletes it (the declared expiry). Daytona counts whole minutes, so it is rounded up to a whole minute. A positive integer; anything else is invalid_config.
allowInternet / allow_internetbooleandefault falseLifts Daytona's network block. Egress is then unenforced, so the agent must also set egress: "unenforced".
autoStopMinutes / auto_stop_minutesnumberdefault 60Idle minutes before Daytona stops a sandbox, and minutes after that before it deletes it: a backstop for a leak, never the normal cleanup. A positive integer; anything else is invalid_config.
fetch(input: string | URL | Request, init?: RequestInit) => Promise<Response>TypeScript only. Seam: the fetch the API clients send through (a proxy, a test server); the run's fence wraps it either way. Omitted: the global fetch.
openSocketOpenSocketTypeScript only. Seam: opens the exec log WebSocket (tests). Omitted: the runtime's WebSocket with headers; the fence checks each open either way.
pollMsnumberdefault 1000TypeScript only. Seam: how often a wait for a sandbox state polls, in milliseconds.
waitMsnumberdefault 300000TypeScript only. Seam: how long a wait for a sandbox state polls before it fails, in milliseconds.
namestrdefault daytonaPython only. The provider name in SandboxInfo and the sandbox ledger ([a-z][a-z0-9_]*, else invalid_config); rows under another name are never touched.
Returns
Throws ConfigError with one of these codes: invalid_config, missing_secret.