zidane 6.6.3 → 6.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -40,6 +40,7 @@ interface DaytonaPtyHandle {
|
|
|
40
40
|
interface DaytonaSandbox {
|
|
41
41
|
id: string;
|
|
42
42
|
state?: string;
|
|
43
|
+
snapshot?: string;
|
|
43
44
|
process: {
|
|
44
45
|
executeCommand: (command: string, cwd?: string, env?: Record<string, string>, timeout?: number) => Promise<DaytonaExecuteResponse>; /** Present in recent SDKs; only `execStream` uses it. */
|
|
45
46
|
createPty?: (options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daytona.d.ts","names":[],"sources":["../../src/contexts/daytona.ts"],"mappings":";;;;;;UAgCU,sBAAA;EACR,QAAA;EACA,MAAA;EACA,MAAA;EACA,MAAA;EACA,MAAA;EACA,SAAA;IAAc,MAAA;EAAA;AAAA;AAAA,UAGN,gBAAA;EACR,IAAA;EAmByB;EAjBzB,KAAK;AAAA;;;;;;;;;UAWG,gBAAA;EACR,GAAA;EACA,iBAAA,QAAyB,OAAA;EACzB,SAAA,GAAY,IAAA,WAAe,UAAA,KAAe,OAAA;EAC1C,IAAA,QAAY,OAAA;IAAU,QAAA;EAAA;EACtB,IAAA,SAAa,OAAA;EACb,UAAA,QAAkB,OAAA;AAAA;AAAA,UAGV,cAAA;EACR,EAAA;EACA,KAAA;EACA,OAAA;IACE,cAAA,GAAiB,OAAA,UAAiB,GAAA,WAAc,GAAA,GAAM,MAAA,kBAAwB,OAAA,cAAqB,OAAA,CAAQ,sBAAA,
|
|
1
|
+
{"version":3,"file":"daytona.d.ts","names":[],"sources":["../../src/contexts/daytona.ts"],"mappings":";;;;;;UAgCU,sBAAA;EACR,QAAA;EACA,MAAA;EACA,MAAA;EACA,MAAA;EACA,MAAA;EACA,SAAA;IAAc,MAAA;EAAA;AAAA;AAAA,UAGN,gBAAA;EACR,IAAA;EAmByB;EAjBzB,K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?? options.apiUrl;
|
|
206
206
|
const target = takeString(sb.target) ?? options.target;
|
|
207
207
|
const connectId = takeString(sb.sandboxId) ?? options.sandboxId;
|
|
208
|
+
const snapshot = takeString(sb.snapshot) ?? options.snapshot;
|
|
208
209
|
const envVars = resolveDaytonaEnv(options.env, config.env);
|
|
209
210
|
const daytona = new Daytona(toClientConfig(apiKey, apiUrl, target));
|
|
210
|
-
|
|
211
|
+
let attached = connectId !== void 0;
|
|
212
|
+
let sandbox = connectId !== void 0 ? await daytona.get(connectId) : await daytona.create(resolveDaytonaCreateParams(sb, options, envVars));
|
|
213
|
+
if (attached && snapshot !== void 0 && sandbox.snapshot !== snapshot) {
|
|
214
|
+
logger.info("recreating Daytona sandbox: snapshot changed", {
|
|
215
|
+
sandboxId: sandbox.id,
|
|
216
|
+
previousSnapshot: sandbox.snapshot,
|
|
217
|
+
newSnapshot: snapshot
|
|
218
|
+
});
|
|
219
|
+
await deleteOwnedSandbox(sandbox);
|
|
220
|
+
attached = false;
|
|
221
|
+
sandbox = await daytona.create(resolveDaytonaCreateParams(sb, options, envVars));
|
|
222
|
+
}
|
|
211
223
|
const owned = !attached || options.ownAttached === true;
|
|
212
|
-
const sandbox = attached ? await daytona.get(connectId) : await daytona.create(resolveDaytonaCreateParams(sb, options, envVars));
|
|
213
224
|
if (attached) await startAttachedSandboxIfNeeded(sandbox);
|
|
214
225
|
live.set(sandbox.id, {
|
|
215
226
|
sandbox,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daytona.js","names":[],"sources":["../../src/contexts/daytona.ts"],"sourcesContent":["/**\n * Daytona sandbox provider.\n *\n * Implements {@link SandboxProvider} on top of Daytona sandboxes. Pair it with\n * {@link createSandboxContext} to run an agent's shell + filesystem tools\n * inside a Daytona sandbox:\n *\n * ```ts\n * import { createSandboxContext } from 'zidane/contexts'\n * import { createDaytonaProvider } from 'zidane/contexts/daytona'\n *\n * const execution = createSandboxContext(createDaytonaProvider())\n * ```\n *\n * Requires `@daytona/sdk` as an optional peer dependency:\n * `bun add @daytona/sdk`.\n */\n\nimport type { Logger } from '../logger'\nimport type { SandboxProvider } from './sandbox'\nimport type { ExecResult, SpawnConfig, StreamHandle } from './types'\nimport { Buffer } from 'node:buffer'\nimport { errorMessage } from '../errors'\nimport { consoleSink, createLogger } from '../logger'\nimport { capBufferedExecOutput } from './output-cap'\nimport { StreamQueue } from './stream-queue'\n\n// ---------------------------------------------------------------------------\n// Minimal structural views of the `@daytona/sdk` surface we touch. Declared\n// locally so zidane typechecks without the optional peer dependency installed.\n// ---------------------------------------------------------------------------\n\ninterface DaytonaExecuteResponse {\n exitCode?: number | null\n result?: string | null\n output?: string | null\n stdout?: string | null\n stderr?: string | null\n artifacts?: { stdout?: string | null }\n}\n\ninterface DaytonaFileEntry {\n name: string\n /** Present in the Daytona SDK's FileInfo; used for the `/` dir suffix. */\n isDir?: boolean\n}\n\n/**\n * Structural subset of Daytona's `PtyHandle`.\n *\n * Daytona's process/session API has NO stdin channel at all — sessions are\n * fire-and-forget with log streaming — so a PTY is the only way to reach a\n * long-lived process interactively. See the `execStream` implementation for\n * what that costs.\n */\ninterface DaytonaPtyHandle {\n pid?: number\n waitForConnection: () => Promise<unknown>\n sendInput: (data: string | Uint8Array) => Promise<unknown>\n wait: () => Promise<{ exitCode?: number }>\n kill?: () => Promise<unknown>\n disconnect: () => Promise<unknown>\n}\n\ninterface DaytonaSandbox {\n id: string\n state?: string\n process: {\n executeCommand: (command: string, cwd?: string, env?: Record<string, string>, timeout?: number) => Promise<DaytonaExecuteResponse>\n /** Present in recent SDKs; only `execStream` uses it. */\n createPty?: (options: {\n /**\n * REQUIRED by the API despite reading like a convenience handle: the\n * SDK forwards it as the session id and the control plane rejects the\n * create with 400 `session ID is required` when it is absent.\n */\n id: string\n cwd?: string\n envs?: Record<string, string>\n onData?: (data: Uint8Array) => void\n }) => Promise<DaytonaPtyHandle>\n }\n fs: {\n /**\n * A Node Buffer, not a bare Uint8Array — that is what the SDK declares and\n * what its download path actually materializes (`Buffer.concat` over the\n * response parts), so `readFile` decodes with `.toString('utf8')` instead\n * of guarding a union. Leaning on that is only safe because the\n * `@daytona/sdk` peer range pins `^0.187.0`: this interface is a\n * hand-rolled structural type over a lazily-imported SDK, so a wider\n * install returning a plain Uint8Array would decode to \"104,101,…\"\n * at runtime with nothing failing at compile time.\n */\n downloadFile: (path: string) => Promise<Buffer>\n uploadFile: (content: Uint8Array | Buffer, path: string) => Promise<unknown>\n listFiles: (path: string) => Promise<DaytonaFileEntry[]>\n }\n getWorkDir?: () => Promise<string>\n start?: (timeout?: number) => Promise<unknown>\n delete: (timeout?: number) => Promise<unknown>\n stop?: (timeout?: number) => Promise<unknown>\n archive?: () => Promise<unknown>\n}\n\ninterface DaytonaClientConfig {\n apiKey?: string\n apiUrl?: string\n target?: string\n}\n\ninterface DaytonaResources {\n cpu?: number\n memory?: number\n disk?: number\n gpu?: number\n [key: string]: unknown\n}\n\ninterface DaytonaCreateParams {\n language?: string\n snapshot?: string\n image?: unknown\n resources?: DaytonaResources\n envVars?: Record<string, string>\n [key: string]: unknown\n}\n\ninterface DaytonaClient {\n create: (params?: DaytonaCreateParams) => Promise<DaytonaSandbox>\n get: (sandboxIdOrName: string) => Promise<DaytonaSandbox>\n}\n\ntype DaytonaConstructor = new (config?: DaytonaClientConfig) => DaytonaClient\n\n// ---------------------------------------------------------------------------\n// Provider options\n// ---------------------------------------------------------------------------\n\nexport type DaytonaOnDestroy = 'delete' | 'kill' | 'stop' | 'pause' | 'archive' | 'leave'\n\nexport interface DaytonaProviderOptions {\n /** Daytona API key. Falls back to the `DAYTONA_API_KEY` env var when omitted. */\n apiKey?: string\n /** Daytona API URL. Falls back to `DAYTONA_API_URL`, then Daytona's hosted default. */\n apiUrl?: string\n /** Daytona target / region. Falls back to `DAYTONA_TARGET`, then the org default. */\n target?: string\n /**\n * Attach to a pre-existing sandbox by id or name instead of creating a fresh\n * one. By default the provider treats attached sandboxes as externally owned\n * and leaves them running on destroy/failure (set {@link ownAttached} to take\n * over the lifecycle).\n */\n sandboxId?: string\n /**\n * Take ownership of an attached ({@link sandboxId}) sandbox's lifecycle, so\n * `destroy()` applies {@link onDestroy} to it (stop / archive / delete)\n * instead of leaving it running.\n *\n * The intended caller is a durable host that *owns* the sandbox across\n * invocations: mint it once, journal its id, re-attach via `sandboxId` on\n * every replay/resume, and clean it up at the end of the logical run. Without\n * this an attached sandbox can never be stopped/deleted through the provider —\n * a leak for host-owned sandboxes. No effect when creating a fresh sandbox\n * (those are always owned). Spawn-time failures (readiness timeout, pregame\n * error) still never delete a pre-existing attached sandbox — only sandboxes\n * this provider *created* are auto-cleaned on spawn failure.\n *\n * Default: `false`.\n */\n ownAttached?: boolean\n /** Daytona snapshot used when creating a fresh sandbox. */\n snapshot?: string\n /** Runtime used for Daytona's code tooling. Shell execution works either way. */\n language?: string\n /** Daytona image/declarative builder input used when creating a fresh sandbox. */\n image?: unknown\n /** Daytona sandbox resources. */\n resources?: DaytonaResources\n /** Default working directory, applied when a spawn doesn't set `SpawnConfig.cwd`. */\n cwd?: string\n /** Environment variables baked into the sandbox and re-sent on every command. */\n env?: Record<string, string>\n /** Logger for provider-level lifecycle lines. */\n logger?: Logger\n /** Total deadline, in seconds, for the post-create readiness probe. Defaults to `60`. */\n readinessTimeoutSeconds?: number\n /** Setup script to upload and run once the sandbox is ready. */\n pregame?: { name: string, content: string }\n /**\n * What to do with an owned sandbox on destroy:\n *\n * - `'delete'` / `'kill'` (default) — call `sandbox.delete()`.\n * - `'stop'` / `'pause'` — call `sandbox.stop()` so Daytona preserves state\n * according to the runner's stop semantics.\n * - `'archive'` — stop, then archive for longer-term persistence.\n * - `'leave'` — make no API call.\n */\n onDestroy?: DaytonaOnDestroy\n}\n\n/** Per-probe timeout for the readiness `true` command. */\nconst READINESS_PROBE_TIMEOUT_SECONDS = 5\n/** Pause between readiness probes while the sandbox is still warming up. */\nconst READINESS_BACKOFF_MS = 250\n/** Setup scripts commonly install dependencies, so give them a generous cap. */\nconst PREGAME_TIMEOUT_SECONDS = 30 * 60\n\nexport interface DaytonaReadinessOptions {\n /** Total deadline in seconds. `<= 0` disables the probe entirely. */\n timeoutSeconds: number\n /** Optional cleanup for owned sandboxes that never become ready. */\n cleanupOnTimeout?: () => Promise<void>\n /** Clock source — injectable for deterministic tests. */\n now?: () => number\n /** Sleep between probes — injectable for deterministic tests. */\n sleep?: (ms: number) => Promise<void>\n}\n\nexport function resolveDaytonaEnv(\n optionEnv: Record<string, string> | undefined,\n perSpawnEnv: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n const merged = { ...optionEnv, ...perSpawnEnv }\n return Object.keys(merged).length > 0 ? merged : undefined\n}\n\nexport function normalizeDaytonaExecResult(response: DaytonaExecuteResponse): ExecResult {\n return {\n stdout: response.stdout ?? response.artifacts?.stdout ?? response.result ?? response.output ?? '',\n stderr: response.stderr ?? '',\n exitCode: typeof response.exitCode === 'number' ? response.exitCode : 0,\n }\n}\n\nfunction capExecResult(result: ExecResult): ExecResult {\n return { ...capBufferedExecOutput(result.stdout, result.stderr), exitCode: result.exitCode }\n}\n\nfunction normalizeDaytonaExecError(error: unknown): ExecResult {\n const err = error as { exitCode?: unknown, stdout?: unknown, stderr?: unknown, result?: unknown, output?: unknown, message?: unknown }\n if (typeof err.exitCode === 'number') {\n return {\n stdout: typeof err.stdout === 'string'\n ? err.stdout\n : typeof err.result === 'string'\n ? err.result\n : typeof err.output === 'string'\n ? err.output\n : '',\n stderr: typeof err.stderr === 'string' ? err.stderr : typeof err.message === 'string' ? err.message : '',\n exitCode: err.exitCode,\n }\n }\n return { stdout: '', stderr: error instanceof Error ? error.message : String(error), exitCode: 124 }\n}\n\nfunction toClientConfig(apiKey?: string, apiUrl?: string, target?: string): DaytonaClientConfig | undefined {\n const config: DaytonaClientConfig = {}\n if (apiKey !== undefined)\n config.apiKey = apiKey\n if (apiUrl !== undefined)\n config.apiUrl = apiUrl\n if (target !== undefined)\n config.target = target\n return Object.keys(config).length > 0 ? config : undefined\n}\n\nfunction takeString(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\nexport function resolveDaytonaCreateParams(\n sandboxConfig: Record<string, unknown>,\n options: DaytonaProviderOptions,\n envVars: Record<string, string> | undefined,\n): DaytonaCreateParams | undefined {\n const reserved = new Set(['provider', 'apiKey', 'apiUrl', 'target', 'sandboxId'])\n const params: DaytonaCreateParams = {}\n\n for (const [key, value] of Object.entries(sandboxConfig)) {\n if (!reserved.has(key) && value !== undefined)\n params[key] = value\n }\n\n const language = takeString(sandboxConfig.language) ?? options.language\n const snapshot = takeString(sandboxConfig.snapshot) ?? options.snapshot\n const image = sandboxConfig.image ?? options.image\n const resources = (sandboxConfig.resources as DaytonaResources | undefined) ?? options.resources\n const configEnvVars = sandboxConfig.envVars as Record<string, string> | undefined\n const mergedEnvVars = resolveDaytonaEnv(envVars, configEnvVars)\n\n if (language !== undefined)\n params.language = language\n if (snapshot !== undefined)\n params.snapshot = snapshot\n if (image !== undefined)\n params.image = image\n if (resources !== undefined)\n params.resources = resources\n if (mergedEnvVars !== undefined)\n params.envVars = mergedEnvVars\n\n return Object.keys(params).length > 0 ? params : undefined\n}\n\nexport async function waitForDaytonaReady(\n sandbox: DaytonaSandbox,\n logger: Logger,\n opts: DaytonaReadinessOptions,\n): Promise<void> {\n if (opts.timeoutSeconds <= 0)\n return\n\n const now = opts.now ?? Date.now\n const sleep = opts.sleep ?? (ms => new Promise<void>(resolve => setTimeout(resolve, ms)))\n const start = now()\n const deadline = start + opts.timeoutSeconds * 1000\n\n logger.info('waiting for Daytona sandbox to initialize', { sandboxId: sandbox.id })\n\n while (true) {\n try {\n await sandbox.process.executeCommand('true', undefined, undefined, READINESS_PROBE_TIMEOUT_SECONDS)\n logger.info('Daytona sandbox ready', { sandboxId: sandbox.id, elapsedMs: now() - start })\n return\n }\n catch {\n if (now() >= deadline) {\n await opts.cleanupOnTimeout?.().catch(() => {})\n throw new Error(`Daytona sandbox ${sandbox.id} did not become ready within ${opts.timeoutSeconds}s`)\n }\n await sleep(READINESS_BACKOFF_MS)\n }\n }\n}\n\nexport async function runDaytonaPregame(\n sandbox: DaytonaSandbox,\n logger: Logger,\n opts: { name: string, content: string, cwd?: string, envVars?: Record<string, string> },\n): Promise<void> {\n const path = `/tmp/${opts.name}`\n logger.info('running Daytona pregame script', { sandboxId: sandbox.id, path })\n await sandbox.fs.uploadFile(Buffer.from(opts.content), path)\n\n const quoted = JSON.stringify(path)\n let result: ExecResult\n try {\n result = normalizeDaytonaExecResult(\n await sandbox.process.executeCommand(`chmod +x ${quoted} && ${quoted}`, opts.cwd, opts.envVars, PREGAME_TIMEOUT_SECONDS),\n )\n }\n catch (err) {\n result = normalizeDaytonaExecError(err)\n }\n\n if (result.exitCode !== 0) {\n logger.error('Daytona pregame script failed', { sandboxId: sandbox.id, exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr })\n throw new Error(`Daytona pregame script ${opts.name} failed with exit code ${result.exitCode}`)\n }\n\n logger.info('Daytona pregame ready', { sandboxId: sandbox.id, stdout: result.stdout, stderr: result.stderr })\n}\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport function createDaytonaProvider(options: DaytonaProviderOptions = {}): SandboxProvider {\n const live = new Map<string, { sandbox: DaytonaSandbox, env?: Record<string, string>, owned: boolean }>()\n const logger = options.logger ?? createLogger(consoleSink())\n const readinessTimeoutSeconds = options.readinessTimeoutSeconds ?? 60\n\n async function loadSdk(): Promise<DaytonaConstructor> {\n try {\n const mod = await import('@daytona/sdk') as { Daytona: DaytonaConstructor }\n return mod.Daytona\n }\n catch (err) {\n // Distinguish \"not installed\" from \"installed but failed to load\". This\n // used to be a bare `catch` that reported the install hint either way,\n // which sent people to `bun add` a package that was already present. The\n // realistic load failure is a `tslib` hoist: `@daytona/sdk` declares no\n // tslib dependency of its own and reaches AWS SDK v3 through\n // `@aws-sdk/client-s3`, so a stale `@aws-crypto` v3/v4 floor\n // (`tslib: ^1.11.1`) can win the hoist and the SDK's initializer helpers\n // resolve against tslib 1.x, which lacks them. Fix with a root\n // `overrides: { \"tslib\": \"^2.8.1\" }` — see `docs/RESTATE.md`.\n const message = errorMessage(err)\n const notInstalled = /cannot find (?:module|package)|module not found|failed to resolve/i.test(message)\n throw new Error(\n notInstalled\n ? '@daytona/sdk is required for the Daytona sandbox provider. Install it with: bun add @daytona/sdk'\n : `@daytona/sdk is installed but failed to load: ${message}. If this mentions tslib, pin it with a root override: \"overrides\": { \"tslib\": \"^2.8.1\" } — see docs/RESTATE.md.`,\n { cause: err },\n )\n }\n }\n\n function get(sandboxId: string): { sandbox: DaytonaSandbox, env?: Record<string, string>, owned: boolean } {\n const entry = live.get(sandboxId)\n if (!entry)\n throw new Error(`Daytona sandbox ${sandboxId} is not tracked by this provider`)\n return entry\n }\n\n async function deleteOwnedSandbox(sandbox: DaytonaSandbox): Promise<void> {\n try {\n await sandbox.delete()\n }\n catch {\n // Already gone — nothing to clean up.\n }\n }\n\n async function stopOwnedSandbox(sandbox: DaytonaSandbox): Promise<void> {\n if (!sandbox.stop) {\n logger.error('cannot stop Daytona sandbox: this @daytona/sdk install exposes no stop() method; leaving it running', { sandboxId: sandbox.id })\n return\n }\n try {\n await sandbox.stop()\n logger.info('stopped Daytona sandbox; reconnect later via the sandboxId option (CLI: --sandbox)', { sandboxId: sandbox.id })\n }\n catch (err) {\n logger.error('failed to stop Daytona sandbox; it will run until Daytona lifecycle policy stops it', { sandboxId: sandbox.id, error: err instanceof Error ? err.message : String(err) })\n }\n }\n\n async function archiveOwnedSandbox(sandbox: DaytonaSandbox): Promise<void> {\n if (!sandbox.stop || !sandbox.archive) {\n logger.error('cannot archive Daytona sandbox: this @daytona/sdk install exposes no stop() and archive() pair; leaving it running', { sandboxId: sandbox.id })\n return\n }\n try {\n await sandbox.stop()\n await sandbox.archive()\n logger.info('archived Daytona sandbox; reconnect later via the sandboxId option (CLI: --sandbox)', { sandboxId: sandbox.id })\n }\n catch (err) {\n logger.error('failed to archive Daytona sandbox; it will run until Daytona lifecycle policy stops it', { sandboxId: sandbox.id, error: err instanceof Error ? err.message : String(err) })\n }\n }\n\n async function startAttachedSandboxIfNeeded(sandbox: DaytonaSandbox): Promise<void> {\n if (sandbox.state !== 'stopped' && sandbox.state !== 'archived')\n return\n if (!sandbox.start) {\n logger.error('cannot start Daytona sandbox before attach readiness probe: this @daytona/sdk install exposes no start() method', { sandboxId: sandbox.id, state: sandbox.state })\n return\n }\n logger.info('starting Daytona sandbox before attach readiness probe', { sandboxId: sandbox.id, state: sandbox.state })\n await sandbox.start(readinessTimeoutSeconds > 0 ? readinessTimeoutSeconds : undefined)\n }\n\n return {\n name: 'daytona',\n\n async spawn(config: SpawnConfig = {}): Promise<{ id: string, cwd: string }> {\n const Daytona = await loadSdk()\n const sb: Record<string, unknown> = config.sandbox ?? {}\n\n const apiKey = takeString(sb.apiKey) ?? options.apiKey\n const apiUrl = takeString(sb.apiUrl) ?? options.apiUrl\n const target = takeString(sb.target) ?? options.target\n const connectId = takeString(sb.sandboxId) ?? options.sandboxId\n const envVars = resolveDaytonaEnv(options.env, config.env)\n\n const daytona = new Daytona(toClientConfig(apiKey, apiUrl, target))\n const attached = connectId !== undefined\n // Lifecycle ownership drives `destroy()` (onDestroy). A created sandbox is\n // always owned; an attached one is owned only when the host opts in via\n // `ownAttached`. Spawn-FAILURE cleanup is separate (see below) and keyed\n // on `!attached` so a pre-existing sandbox is never auto-deleted.\n const owned = !attached || options.ownAttached === true\n const sandbox = attached\n ? await daytona.get(connectId)\n : await daytona.create(resolveDaytonaCreateParams(sb, options, envVars))\n\n if (attached)\n await startAttachedSandboxIfNeeded(sandbox)\n\n live.set(sandbox.id, { sandbox, env: envVars, owned })\n\n try {\n await waitForDaytonaReady(sandbox, logger, {\n timeoutSeconds: readinessTimeoutSeconds,\n // Only auto-delete a sandbox we CREATED on readiness failure — never a\n // pre-existing attached one, even when we own its lifecycle.\n ...(!attached ? { cleanupOnTimeout: () => deleteOwnedSandbox(sandbox) } : {}),\n })\n }\n catch (err) {\n live.delete(sandbox.id)\n throw err\n }\n\n const requestedCwd = config.cwd ?? options.cwd\n let cwd: string\n if (requestedCwd) {\n cwd = requestedCwd\n await sandbox.process.executeCommand(`mkdir -p ${JSON.stringify(cwd)}`).catch(() => {})\n }\n else if (sandbox.getWorkDir) {\n cwd = await sandbox.getWorkDir().catch(() => '')\n if (!cwd)\n cwd = await sandbox.process.executeCommand('pwd').then(r => normalizeDaytonaExecResult(r).stdout.trim()).catch(() => '') || '/home/daytona'\n }\n else {\n cwd = await sandbox.process.executeCommand('pwd').then(r => normalizeDaytonaExecResult(r).stdout.trim()).catch(() => '') || '/home/daytona'\n }\n\n if (options.pregame) {\n try {\n await runDaytonaPregame(sandbox, logger, { name: options.pregame.name, content: options.pregame.content, cwd, envVars })\n }\n catch (err) {\n // Spawn-failure cleanup: only delete a sandbox we created, never a\n // pre-existing attached one (the host owns its prior state).\n if (!attached)\n await deleteOwnedSandbox(sandbox)\n live.delete(sandbox.id)\n throw err\n }\n }\n\n return { id: sandbox.id, cwd }\n },\n\n async exec(sandboxId, command, opts): Promise<ExecResult> {\n const { sandbox, env } = get(sandboxId)\n const timeoutSeconds = opts?.timeout ?? 30\n try {\n // The SDK buffers the streams uncapped (see the KNOWN RESIDUAL note\n // on `ExecutionContext.fileSize`) — cap host-side before the strings\n // propagate into tool results and session history.\n return capExecResult(normalizeDaytonaExecResult(\n await sandbox.process.executeCommand(\n command,\n opts?.cwd,\n resolveDaytonaEnv(env, opts?.env),\n timeoutSeconds > 0 ? timeoutSeconds : undefined,\n ),\n ))\n }\n catch (err) {\n return capExecResult(normalizeDaytonaExecError(err))\n }\n },\n\n /**\n * Live bidirectional stream — see `ExecutionContext.execStream`.\n *\n * PTY-backed, and not by preference: Daytona's process + session API\n * exposes no stdin at all (sessions are fire-and-forget with log\n * streaming), so a pseudo-terminal is the only interactive channel the\n * platform offers. That forces three mitigations, all in the launch\n * wrapper below, because a PTY is a terminal and a protocol stream is\n * not:\n *\n * 1. `stty -echo` — a terminal echoes everything written to stdin back\n * onto stdout. Without this the caller reads its own requests back\n * as if they were responses.\n * 2. `stty raw` — canonical mode rewrites `\\n`→`\\r\\n` and caps a line\n * at ~4096 bytes. Protocol frames routinely exceed that and would\n * be silently truncated mid-message.\n * 3. `2><file>` — a PTY has ONE stream, so the child's stderr would\n * otherwise interleave into the protocol data and corrupt framing.\n * It is redirected to a file inside the sandbox and surfaced on the\n * returned handle by polling that file through the exec API.\n *\n * The mitigations must run before the child's first byte — but the\n * launch line ITSELF is typed into a canonical-mode terminal, so it is\n * echoed once (a short non-JSON line the transport's tolerant framing\n * discards) and subject to the ~4096-byte line cap. That is why the\n * real command lives in an uploaded script and the typed line stays\n * short and constant: a long command line would be truncated before\n * `stty` ever ran. The script also restores `sh` compound-command\n * semantics that a bare `exec <command>` would break.\n */\n async execStream(sandboxId, command, opts): Promise<StreamHandle> {\n const { sandbox, env } = get(sandboxId)\n\n if (!sandbox.process.createPty) {\n throw new Error(\n 'Daytona SDK is too old: `process.createPty` is required for execStream '\n + '(used to run stdio MCP servers inside the sandbox).',\n )\n }\n\n opts?.signal?.throwIfAborted()\n\n const token = Math.random().toString(36).slice(2, 10)\n const stderrPath = `/tmp/.zidane-stream-${token}.err`\n const scriptPath = `/tmp/.zidane-stream-${token}.sh`\n\n // `exec 2>` rebinds the shell's stderr before the command runs, so\n // the command text needs no rewriting and stays compound-safe.\n await sandbox.fs.uploadFile(\n Buffer.from(`exec 2>${stderrPath}\\n${command}\\n`),\n scriptPath,\n )\n\n // See the E2B counterpart: the PTY's `onData` is a sync `void`\n // callback, so a stalled consumer can only be reported, never slowed.\n const warnBacklog = (which: string) => (bytes: number) =>\n logger.warn('execStream consumer is not draining output', { sandboxId, stream: which, bufferedBytes: bytes })\n const stdout = new StreamQueue(warnBacklog('stdout'))\n const stderr = new StreamQueue(warnBacklog('stderr'))\n\n // Everything the shell emits before the child is actually running is\n // NOISE that must never reach the caller: the echo of our own launch\n // line (typed before `-echo` takes effect), the login shell's prompt,\n // and its line-editor redraw escapes. `createPty` is `lazyStart`, so\n // the shell frequently does not exist yet when we type — it boots\n // afterwards and REPLAYS the buffered input through its line editor.\n // Observed on a stock sandbox: the stream opened with the echoed\n // launch line, the echoed first request, `\\u001b[?2004h` bracketed\n // paste, and a `%` prompt. An MCP client parses that echoed request\n // as a message and the handshake collapses.\n //\n // So: gate the stream on a sentinel the CHILD side prints, and drop\n // every byte before it. The sentinel is assembled by `printf` at\n // runtime (`Z-%s-READY` + token) so the echoed *source* line, which\n // contains the format string rather than the result, cannot match it.\n const sentinel = `Z-${token}-READY`\n let gateOpen = false\n let gateBuffer = ''\n let openGate: () => void = () => {}\n const gateReady = new Promise<void>((r) => { openGate = r })\n\n const pty = await sandbox.process.createPty({\n id: `zidane-stream-${token}`,\n ...(opts?.cwd ? { cwd: opts.cwd } : {}),\n envs: resolveDaytonaEnv(env, opts?.env) ?? {},\n onData: (data: Uint8Array) => {\n if (gateOpen) {\n stdout.push(data)\n return\n }\n gateBuffer += Buffer.from(data).toString('utf8')\n const at = gateBuffer.indexOf(sentinel)\n if (at === -1) {\n // Bounded: never let pre-gate noise grow without limit, but keep\n // a tail longer than the sentinel so it can't be split away.\n if (gateBuffer.length > 64 * 1024)\n gateBuffer = gateBuffer.slice(-1024)\n return\n }\n gateOpen = true\n openGate()\n // Everything after the sentinel's trailing newline is real output.\n const rest = gateBuffer.slice(at + sentinel.length).replace(/^\\r?\\n/, '')\n gateBuffer = ''\n if (rest.length > 0)\n stdout.push(new TextEncoder().encode(rest))\n },\n })\n await pty.waitForConnection()\n\n // Short, constant, and under any canonical line cap. `exec` replaces\n // the login shell so the PTY's lifetime is the script's lifetime and\n // no shell prompt can reach stdout.\n await pty.sendInput(`stty raw -echo; printf 'Z-%s-READY\\\\n' ${token}; exec sh ${scriptPath}\\n`)\n\n // Block until the child is genuinely live. Without this the caller can\n // write its first frame into a shell that hasn't started, where it is\n // echoed back and misread as a response.\n let gateTimer: ReturnType<typeof setTimeout> | undefined\n await Promise.race([\n gateReady,\n new Promise<void>((r) => { gateTimer = setTimeout(r, 30_000) }),\n ])\n clearTimeout(gateTimer)\n if (!gateOpen) {\n // Full teardown, not just a disconnect: Daytona PTY sessions persist\n // server-side after the websocket drops, so a bare disconnect leaks\n // one login shell plus two /tmp files per attempt — a bootstrap\n // retry loop against a broken image would stack them until the\n // sandbox dies.\n await (pty.kill?.() ?? Promise.resolve()).catch(() => {})\n await pty.disconnect().catch(() => {})\n await sandbox.process.executeCommand(`rm -f ${scriptPath} ${stderrPath}`).catch(() => {})\n throw new Error(\n `Daytona execStream: PTY did not reach the ready sentinel within 30s `\n + `(sandbox ${sandboxId}). The login shell may not have started.`,\n )\n }\n\n // stderr file → handle.stderr. Poll rather than stream: the exec API\n // is the only other channel into the sandbox, and diagnostics don't\n // need latency. Byte offsets keep re-reads incremental.\n //\n // The offset comes from the FILE (`wc -c`), never from measuring the\n // returned content: an exec API that trims a trailing newline from\n // command output would make a content-derived offset under-advance by\n // one byte per poll, re-emitting the tail byte forever. The size rides\n // back on the same round trip as a `ZEOF-<token>:` suffix; content is\n // whatever precedes it, so content-side transforms can't drift the\n // cursor either.\n let stderrOffset = 0\n let torndown = false\n const eofMark = `ZEOF-${token}:`\n const drainStderr = async (): Promise<void> => {\n try {\n const res = normalizeDaytonaExecResult(await sandbox.process.executeCommand(\n `tail -c +${stderrOffset + 1} ${stderrPath} 2>/dev/null; printf '${eofMark}%s' \"$(wc -c < ${stderrPath} 2>/dev/null || echo 0)\"`,\n ))\n const at = res.stdout.lastIndexOf(eofMark)\n if (at === -1)\n return\n const content = res.stdout.slice(0, at)\n const size = Number.parseInt(res.stdout.slice(at + eofMark.length).trim(), 10)\n if (content.length > 0)\n stderr.push(new TextEncoder().encode(content))\n if (Number.isFinite(size) && size > stderrOffset)\n stderrOffset = size\n }\n catch {\n // Diagnostic channel — polling failures must never surface as\n // protocol errors.\n }\n }\n const stderrTimer = setInterval(() => { void drainStderr() }, 2000)\n // Guarded: Bun/Node timers support unref, test fakes may not.\n ;(stderrTimer as { unref?: () => void }).unref?.()\n\n // Shared teardown for both exit paths (natural exit and kill): one\n // final stderr drain so a crash message isn't lost, then remove the\n // script + stderr files that would otherwise accumulate in /tmp for\n // the sandbox's lifetime.\n const teardown = async (): Promise<void> => {\n if (torndown)\n return\n torndown = true\n clearInterval(stderrTimer)\n await drainStderr()\n await sandbox.process.executeCommand(`rm -f ${scriptPath} ${stderrPath}`).catch(() => {})\n stdout.close()\n stderr.close()\n }\n\n const exited = pty.wait()\n .then(result => result?.exitCode ?? 0)\n .catch(() => 137)\n .finally(teardown)\n\n const kill = async (): Promise<void> => {\n // A PTY login shell never exits on its own — killing it IS the\n // normal termination path here, not an error path.\n await (pty.kill?.() ?? Promise.resolve()).catch(() => {})\n await pty.disconnect().catch(() => {})\n await teardown()\n }\n\n if (opts?.signal) {\n if (opts.signal.aborted) {\n void kill()\n }\n else {\n // Detach on exit — the (typically run-long) signal otherwise\n // retains the `kill` closure and the PTY handle for the rest of\n // the run, one dead closure per exec.\n const onAbort = () => { void kill() }\n const detach = () => opts.signal!.removeEventListener('abort', onAbort)\n opts.signal.addEventListener('abort', onAbort, { once: true })\n exited.then(detach, detach)\n }\n }\n\n return {\n pid: pty.pid ?? -1,\n stdout,\n stderr,\n write: async (data: Uint8Array): Promise<void> => {\n await pty.sendInput(data)\n },\n kill,\n exited,\n }\n },\n\n async readFile(sandboxId, path): Promise<string> {\n const data = await get(sandboxId).sandbox.fs.downloadFile(path)\n return data.toString('utf8')\n },\n\n async writeFile(sandboxId, path, content, encoding: BufferEncoding = 'utf-8'): Promise<void> {\n const data = typeof content === 'string' ? Buffer.from(content, encoding) : content\n await get(sandboxId).sandbox.fs.uploadFile(data, path)\n },\n\n async listFiles(sandboxId, path): Promise<string[]> {\n const entries = await get(sandboxId).sandbox.fs.listFiles(path)\n // Trailing `/` on directories — parity with process/docker contexts.\n return entries.map(e => (e.isDir ? `${e.name}/` : e.name))\n },\n\n async destroy(sandboxId): Promise<void> {\n const entry = live.get(sandboxId)\n if (!entry)\n return\n if (entry.owned) {\n const action = options.onDestroy ?? 'delete'\n if (action === 'stop' || action === 'pause')\n await stopOwnedSandbox(entry.sandbox)\n else if (action === 'archive')\n await archiveOwnedSandbox(entry.sandbox)\n else if (action === 'delete' || action === 'kill')\n await deleteOwnedSandbox(entry.sandbox)\n }\n live.delete(sandboxId)\n },\n }\n}\n"],"mappings":";;;;;;;AA0MA,MAAM,kCAAkC;;AAExC,MAAM,uBAAuB;;AAE7B,MAAM,0BAA0B;AAahC,SAAgB,kBACd,WACA,aACoC;CACpC,MAAM,SAAS;EAAE,GAAG;EAAW,GAAG;CAAY;CAC9C,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS,IAAI,SAAS,KAAA;AACnD;AAEA,SAAgB,2BAA2B,UAA8C;CACvF,OAAO;EACL,QAAQ,SAAS,UAAU,SAAS,WAAW,UAAU,SAAS,UAAU,SAAS,UAAU;EAC/F,QAAQ,SAAS,UAAU;EAC3B,UAAU,OAAO,SAAS,aAAa,WAAW,SAAS,WAAW;CACxE;AACF;AAEA,SAAS,cAAc,QAAgC;CACrD,OAAO;EAAE,GAAG,sBAAsB,OAAO,QAAQ,OAAO,MAAM;EAAG,UAAU,OAAO;CAAS;AAC7F;AAEA,SAAS,0BAA0B,OAA4B;CAC7D,MAAM,MAAM;CACZ,IAAI,OAAO,IAAI,aAAa,UAC1B,OAAO;EACL,QAAQ,OAAO,IAAI,WAAW,WAC1B,IAAI,SACJ,OAAO,IAAI,WAAW,WACpB,IAAI,SACJ,OAAO,IAAI,WAAW,WACpB,IAAI,SACJ;EACR,QAAQ,OAAO,IAAI,WAAW,WAAW,IAAI,SAAS,OAAO,IAAI,YAAY,WAAW,IAAI,UAAU;EACtG,UAAU,IAAI;CAChB;CAEF,OAAO;EAAE,QAAQ;EAAI,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAAG,UAA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AC;IAC7D,OAAO,KAAK,QAAQ,MAAM;GAC5B;GAGF,OAAO;IACL,KAAK,IAAI,OAAO;IAChB;IACA;IACA,OAAO,OAAO,SAAoC;KAChD,MAAM,IAAI,UAAU,IAAI;IAC1B;IACA;IACA;GACF;EACF;EAEA,MAAM,SAAS,WAAW,MAAuB;GAE/C,QAAO,MADY,IAAI,SAAS,CAAC,CAAC,QAAQ,GAAG,aAAa,IAAI,EAAA,CAClD,SAAS,MAAM;EAC7B;EAEA,MAAM,UAAU,WAAW,MAAM,SAAS,WAA2B,SAAwB;GAC3F,MAAM,OAAO,OAAO,YAAY,WAAW,OAAO,KAAK,SAAS,QAAQ,IAAI;GAC5E,MAAM,IAAI,SAAS,CAAC,CAAC,QAAQ,GAAG,WAAW,MAAM,IAAI;EACvD;EAEA,MAAM,UAAU,WAAW,MAAyB;GAGlD,QAAO,MAFe,IAAI,SAAS,CAAC,CAAC,QAAQ,GAAG,UAAU,IAAI,EAAA,CAE/C,KAAI,MAAM,EAAE,QAAQ,GAAG,EAAE,KAAK,KAAK,EAAE,IAAK;EAC3D;EAEA,MAAM,QAAQ,WAA0B;GACtC,MAAM,QAAQ,KAAK,IAAI,SAAS;GAChC,IAAI,CAAC,OACH;GACF,IAAI,MAAM,OAAO;IACf,MAAM,SAAS,QAAQ,aAAa;IACpC,IAAI,WAAW,UAAU,WAAW,SAClC,MAAM,iBAAiB,MAAM,OAAO;SACjC,IAAI,WAAW,WAClB,MAAM,oBAAoB,MAAM,OAAO;SACpC,IAAI,WAAW,YAAY,WAAW,QACzC,MAAM,mBAAmB,MAAM,OAAO;GAC1C;GACA,KAAK,OAAO,SAAS;EACvB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"daytona.js","names":[],"sources":["../../src/contexts/daytona.ts"],"sourcesContent":["/**\n * Daytona sandbox provider.\n *\n * Implements {@link SandboxProvider} on top of Daytona sandboxes. Pair it with\n * {@link createSandboxContext} to run an agent's shell + filesystem tools\n * inside a Daytona sandbox:\n *\n * ```ts\n * import { createSandboxContext } from 'zidane/contexts'\n * import { createDaytonaProvider } from 'zidane/contexts/daytona'\n *\n * const execution = createSandboxContext(createDaytonaProvider())\n * ```\n *\n * Requires `@daytona/sdk` as an optional peer dependency:\n * `bun add @daytona/sdk`.\n */\n\nimport type { Logger } from '../logger'\nimport type { SandboxProvider } from './sandbox'\nimport type { ExecResult, SpawnConfig, StreamHandle } from './types'\nimport { Buffer } from 'node:buffer'\nimport { errorMessage } from '../errors'\nimport { consoleSink, createLogger } from '../logger'\nimport { capBufferedExecOutput } from './output-cap'\nimport { StreamQueue } from './stream-queue'\n\n// ---------------------------------------------------------------------------\n// Minimal structural views of the `@daytona/sdk` surface we touch. Declared\n// locally so zidane typechecks without the optional peer dependency installed.\n// ---------------------------------------------------------------------------\n\ninterface DaytonaExecuteResponse {\n exitCode?: number | null\n result?: string | null\n output?: string | null\n stdout?: string | null\n stderr?: string | null\n artifacts?: { stdout?: string | null }\n}\n\ninterface DaytonaFileEntry {\n name: string\n /** Present in the Daytona SDK's FileInfo; used for the `/` dir suffix. */\n isDir?: boolean\n}\n\n/**\n * Structural subset of Daytona's `PtyHandle`.\n *\n * Daytona's process/session API has NO stdin channel at all — sessions are\n * fire-and-forget with log streaming — so a PTY is the only way to reach a\n * long-lived process interactively. See the `execStream` implementation for\n * what that costs.\n */\ninterface DaytonaPtyHandle {\n pid?: number\n waitForConnection: () => Promise<unknown>\n sendInput: (data: string | Uint8Array) => Promise<unknown>\n wait: () => Promise<{ exitCode?: number }>\n kill?: () => Promise<unknown>\n disconnect: () => Promise<unknown>\n}\n\ninterface DaytonaSandbox {\n id: string\n state?: string\n snapshot?: string\n process: {\n executeCommand: (command: string, cwd?: string, env?: Record<string, string>, timeout?: number) => Promise<DaytonaExecuteResponse>\n /** Present in recent SDKs; only `execStream` uses it. */\n createPty?: (options: {\n /**\n * REQUIRED by the API despite reading like a convenience handle: the\n * SDK forwards it as the session id and the control plane rejects the\n * create with 400 `session ID is required` when it is absent.\n */\n id: string\n cwd?: string\n envs?: Record<string, string>\n onData?: (data: Uint8Array) => void\n }) => Promise<DaytonaPtyHandle>\n }\n fs: {\n /**\n * A Node Buffer, not a bare Uint8Array — that is what the SDK declares and\n * what its download path actually materializes (`Buffer.concat` over the\n * response parts), so `readFile` decodes with `.toString('utf8')` instead\n * of guarding a union. Leaning on that is only safe because the\n * `@daytona/sdk` peer range pins `^0.187.0`: this interface is a\n * hand-rolled structural type over a lazily-imported SDK, so a wider\n * install returning a plain Uint8Array would decode to \"104,101,…\"\n * at runtime with nothing failing at compile time.\n */\n downloadFile: (path: string) => Promise<Buffer>\n uploadFile: (content: Uint8Array | Buffer, path: string) => Promise<unknown>\n listFiles: (path: string) => Promise<DaytonaFileEntry[]>\n }\n getWorkDir?: () => Promise<string>\n start?: (timeout?: number) => Promise<unknown>\n delete: (timeout?: number) => Promise<unknown>\n stop?: (timeout?: number) => Promise<unknown>\n archive?: () => Promise<unknown>\n}\n\ninterface DaytonaClientConfig {\n apiKey?: string\n apiUrl?: string\n target?: string\n}\n\ninterface DaytonaResources {\n cpu?: number\n memory?: number\n disk?: number\n gpu?: number\n [key: string]: unknown\n}\n\ninterface DaytonaCreateParams {\n language?: string\n snapshot?: string\n image?: unknown\n resources?: DaytonaResources\n envVars?: Record<string, string>\n [key: string]: unknown\n}\n\ninterface DaytonaClient {\n create: (params?: DaytonaCreateParams) => Promise<DaytonaSandbox>\n get: (sandboxIdOrName: string) => Promise<DaytonaSandbox>\n}\n\ntype DaytonaConstructor = new (config?: DaytonaClientConfig) => DaytonaClient\n\n// ---------------------------------------------------------------------------\n// Provider options\n// ---------------------------------------------------------------------------\n\nexport type DaytonaOnDestroy = 'delete' | 'kill' | 'stop' | 'pause' | 'archive' | 'leave'\n\nexport interface DaytonaProviderOptions {\n /** Daytona API key. Falls back to the `DAYTONA_API_KEY` env var when omitted. */\n apiKey?: string\n /** Daytona API URL. Falls back to `DAYTONA_API_URL`, then Daytona's hosted default. */\n apiUrl?: string\n /** Daytona target / region. Falls back to `DAYTONA_TARGET`, then the org default. */\n target?: string\n /**\n * Attach to a pre-existing sandbox by id or name instead of creating a fresh\n * one. By default the provider treats attached sandboxes as externally owned\n * and leaves them running on destroy/failure (set {@link ownAttached} to take\n * over the lifecycle).\n */\n sandboxId?: string\n /**\n * Take ownership of an attached ({@link sandboxId}) sandbox's lifecycle, so\n * `destroy()` applies {@link onDestroy} to it (stop / archive / delete)\n * instead of leaving it running.\n *\n * The intended caller is a durable host that *owns* the sandbox across\n * invocations: mint it once, journal its id, re-attach via `sandboxId` on\n * every replay/resume, and clean it up at the end of the logical run. Without\n * this an attached sandbox can never be stopped/deleted through the provider —\n * a leak for host-owned sandboxes. No effect when creating a fresh sandbox\n * (those are always owned). Spawn-time failures (readiness timeout, pregame\n * error) still never delete a pre-existing attached sandbox — only sandboxes\n * this provider *created* are auto-cleaned on spawn failure.\n *\n * Default: `false`.\n */\n ownAttached?: boolean\n /** Daytona snapshot used when creating a fresh sandbox. */\n snapshot?: string\n /** Runtime used for Daytona's code tooling. Shell execution works either way. */\n language?: string\n /** Daytona image/declarative builder input used when creating a fresh sandbox. */\n image?: unknown\n /** Daytona sandbox resources. */\n resources?: DaytonaResources\n /** Default working directory, applied when a spawn doesn't set `SpawnConfig.cwd`. */\n cwd?: string\n /** Environment variables baked into the sandbox and re-sent on every command. */\n env?: Record<string, string>\n /** Logger for provider-level lifecycle lines. */\n logger?: Logger\n /** Total deadline, in seconds, for the post-create readiness probe. Defaults to `60`. */\n readinessTimeoutSeconds?: number\n /** Setup script to upload and run once the sandbox is ready. */\n pregame?: { name: string, content: string }\n /**\n * What to do with an owned sandbox on destroy:\n *\n * - `'delete'` / `'kill'` (default) — call `sandbox.delete()`.\n * - `'stop'` / `'pause'` — call `sandbox.stop()` so Daytona preserves state\n * according to the runner's stop semantics.\n * - `'archive'` — stop, then archive for longer-term persistence.\n * - `'leave'` — make no API call.\n */\n onDestroy?: DaytonaOnDestroy\n}\n\n/** Per-probe timeout for the readiness `true` command. */\nconst READINESS_PROBE_TIMEOUT_SECONDS = 5\n/** Pause between readiness probes while the sandbox is still warming up. */\nconst READINESS_BACKOFF_MS = 250\n/** Setup scripts commonly install dependencies, so give them a generous cap. */\nconst PREGAME_TIMEOUT_SECONDS = 30 * 60\n\nexport interface DaytonaReadinessOptions {\n /** Total deadline in seconds. `<= 0` disables the probe entirely. */\n timeoutSeconds: number\n /** Optional cleanup for owned sandboxes that never become ready. */\n cleanupOnTimeout?: () => Promise<void>\n /** Clock source — injectable for deterministic tests. */\n now?: () => number\n /** Sleep between probes — injectable for deterministic tests. */\n sleep?: (ms: number) => Promise<void>\n}\n\nexport function resolveDaytonaEnv(\n optionEnv: Record<string, string> | undefined,\n perSpawnEnv: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n const merged = { ...optionEnv, ...perSpawnEnv }\n return Object.keys(merged).length > 0 ? merged : undefined\n}\n\nexport function normalizeDaytonaExecResult(response: DaytonaExecuteResponse): ExecResult {\n return {\n stdout: response.stdout ?? response.artifacts?.stdout ?? response.result ?? response.output ?? '',\n stderr: response.stderr ?? '',\n exitCode: typeof response.exitCode === 'number' ? response.exitCode : 0,\n }\n}\n\nfunction capExecResult(result: ExecResult): ExecResult {\n return { ...capBufferedExecOutput(result.stdout, result.stderr), exitCode: result.exitCode }\n}\n\nfunction normalizeDaytonaExecError(error: unknown): ExecResult {\n const err = error as { exitCode?: unknown, stdout?: unknown, stderr?: unknown, result?: unknown, output?: unknown, message?: unknown }\n if (typeof err.exitCode === 'number') {\n return {\n stdout: typeof err.stdout === 'string'\n ? err.stdout\n : typeof err.result === 'string'\n ? err.result\n : typeof err.output === 'string'\n ? err.output\n : '',\n stderr: typeof err.stderr === 'string' ? err.stderr : typeof err.message === 'string' ? err.message : '',\n exitCode: err.exitCode,\n }\n }\n return { stdout: '', stderr: error instanceof Error ? error.message : String(error), exitCode: 124 }\n}\n\nfunction toClientConfig(apiKey?: string, apiUrl?: string, target?: string): DaytonaClientConfig | undefined {\n const config: DaytonaClientConfig = {}\n if (apiKey !== undefined)\n config.apiKey = apiKey\n if (apiUrl !== undefined)\n config.apiUrl = apiUrl\n if (target !== undefined)\n config.target = target\n return Object.keys(config).length > 0 ? config : undefined\n}\n\nfunction takeString(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\nexport function resolveDaytonaCreateParams(\n sandboxConfig: Record<string, unknown>,\n options: DaytonaProviderOptions,\n envVars: Record<string, string> | undefined,\n): DaytonaCreateParams | undefined {\n const reserved = new Set(['provider', 'apiKey', 'apiUrl', 'target', 'sandboxId'])\n const params: DaytonaCreateParams = {}\n\n for (const [key, value] of Object.entries(sandboxConfig)) {\n if (!reserved.has(key) && value !== undefined)\n params[key] = value\n }\n\n const language = takeString(sandboxConfig.language) ?? options.language\n const snapshot = takeString(sandboxConfig.snapshot) ?? options.snapshot\n const image = sandboxConfig.image ?? options.image\n const resources = (sandboxConfig.resources as DaytonaResources | undefined) ?? options.resources\n const configEnvVars = sandboxConfig.envVars as Record<string, string> | undefined\n const mergedEnvVars = resolveDaytonaEnv(envVars, configEnvVars)\n\n if (language !== undefined)\n params.language = language\n if (snapshot !== undefined)\n params.snapshot = snapshot\n if (image !== undefined)\n params.image = image\n if (resources !== undefined)\n params.resources = resources\n if (mergedEnvVars !== undefined)\n params.envVars = mergedEnvVars\n\n return Object.keys(params).length > 0 ? params : undefined\n}\n\nexport async function waitForDaytonaReady(\n sandbox: DaytonaSandbox,\n logger: Logger,\n opts: DaytonaReadinessOptions,\n): Promise<void> {\n if (opts.timeoutSeconds <= 0)\n return\n\n const now = opts.now ?? Date.now\n const sleep = opts.sleep ?? (ms => new Promise<void>(resolve => setTimeout(resolve, ms)))\n const start = now()\n const deadline = start + opts.timeoutSeconds * 1000\n\n logger.info('waiting for Daytona sandbox to initialize', { sandboxId: sandbox.id })\n\n while (true) {\n try {\n await sandbox.process.executeCommand('true', undefined, undefined, READINESS_PROBE_TIMEOUT_SECONDS)\n logger.info('Daytona sandbox ready', { sandboxId: sandbox.id, elapsedMs: now() - start })\n return\n }\n catch {\n if (now() >= deadline) {\n await opts.cleanupOnTimeout?.().catch(() => {})\n throw new Error(`Daytona sandbox ${sandbox.id} did not become ready within ${opts.timeoutSeconds}s`)\n }\n await sleep(READINESS_BACKOFF_MS)\n }\n }\n}\n\nexport async function runDaytonaPregame(\n sandbox: DaytonaSandbox,\n logger: Logger,\n opts: { name: string, content: string, cwd?: string, envVars?: Record<string, string> },\n): Promise<void> {\n const path = `/tmp/${opts.name}`\n logger.info('running Daytona pregame script', { sandboxId: sandbox.id, path })\n await sandbox.fs.uploadFile(Buffer.from(opts.content), path)\n\n const quoted = JSON.stringify(path)\n let result: ExecResult\n try {\n result = normalizeDaytonaExecResult(\n await sandbox.process.executeCommand(`chmod +x ${quoted} && ${quoted}`, opts.cwd, opts.envVars, PREGAME_TIMEOUT_SECONDS),\n )\n }\n catch (err) {\n result = normalizeDaytonaExecError(err)\n }\n\n if (result.exitCode !== 0) {\n logger.error('Daytona pregame script failed', { sandboxId: sandbox.id, exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr })\n throw new Error(`Daytona pregame script ${opts.name} failed with exit code ${result.exitCode}`)\n }\n\n logger.info('Daytona pregame ready', { sandboxId: sandbox.id, stdout: result.stdout, stderr: result.stderr })\n}\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport function createDaytonaProvider(options: DaytonaProviderOptions = {}): SandboxProvider {\n const live = new Map<string, { sandbox: DaytonaSandbox, env?: Record<string, string>, owned: boolean }>()\n const logger = options.logger ?? createLogger(consoleSink())\n const readinessTimeoutSeconds = options.readinessTimeoutSeconds ?? 60\n\n async function loadSdk(): Promise<DaytonaConstructor> {\n try {\n const mod = await import('@daytona/sdk') as { Daytona: DaytonaConstructor }\n return mod.Daytona\n }\n catch (err) {\n // Distinguish \"not installed\" from \"installed but failed to load\". This\n // used to be a bare `catch` that reported the install hint either way,\n // which sent people to `bun add` a package that was already present. The\n // realistic load failure is a `tslib` hoist: `@daytona/sdk` declares no\n // tslib dependency of its own and reaches AWS SDK v3 through\n // `@aws-sdk/client-s3`, so a stale `@aws-crypto` v3/v4 floor\n // (`tslib: ^1.11.1`) can win the hoist and the SDK's initializer helpers\n // resolve against tslib 1.x, which lacks them. Fix with a root\n // `overrides: { \"tslib\": \"^2.8.1\" }` — see `docs/RESTATE.md`.\n const message = errorMessage(err)\n const notInstalled = /cannot find (?:module|package)|module not found|failed to resolve/i.test(message)\n throw new Error(\n notInstalled\n ? '@daytona/sdk is required for the Daytona sandbox provider. Install it with: bun add @daytona/sdk'\n : `@daytona/sdk is installed but failed to load: ${message}. If this mentions tslib, pin it with a root override: \"overrides\": { \"tslib\": \"^2.8.1\" } — see docs/RESTATE.md.`,\n { cause: err },\n )\n }\n }\n\n function get(sandboxId: string): { sandbox: DaytonaSandbox, env?: Record<string, string>, owned: boolean } {\n const entry = live.get(sandboxId)\n if (!entry)\n throw new Error(`Daytona sandbox ${sandboxId} is not tracked by this provider`)\n return entry\n }\n\n async function deleteOwnedSandbox(sandbox: DaytonaSandbox): Promise<void> {\n try {\n await sandbox.delete()\n }\n catch {\n // Already gone — nothing to clean up.\n }\n }\n\n async function stopOwnedSandbox(sandbox: DaytonaSandbox): Promise<void> {\n if (!sandbox.stop) {\n logger.error('cannot stop Daytona sandbox: this @daytona/sdk install exposes no stop() method; leaving it running', { sandboxId: sandbox.id })\n return\n }\n try {\n await sandbox.stop()\n logger.info('stopped Daytona sandbox; reconnect later via the sandboxId option (CLI: --sandbox)', { sandboxId: sandbox.id })\n }\n catch (err) {\n logger.error('failed to stop Daytona sandbox; it will run until Daytona lifecycle policy stops it', { sandboxId: sandbox.id, error: err instanceof Error ? err.message : String(err) })\n }\n }\n\n async function archiveOwnedSandbox(sandbox: DaytonaSandbox): Promise<void> {\n if (!sandbox.stop || !sandbox.archive) {\n logger.error('cannot archive Daytona sandbox: this @daytona/sdk install exposes no stop() and archive() pair; leaving it running', { sandboxId: sandbox.id })\n return\n }\n try {\n await sandbox.stop()\n await sandbox.archive()\n logger.info('archived Daytona sandbox; reconnect later via the sandboxId option (CLI: --sandbox)', { sandboxId: sandbox.id })\n }\n catch (err) {\n logger.error('failed to archive Daytona sandbox; it will run until Daytona lifecycle policy stops it', { sandboxId: sandbox.id, error: err instanceof Error ? err.message : String(err) })\n }\n }\n\n async function startAttachedSandboxIfNeeded(sandbox: DaytonaSandbox): Promise<void> {\n if (sandbox.state !== 'stopped' && sandbox.state !== 'archived')\n return\n if (!sandbox.start) {\n logger.error('cannot start Daytona sandbox before attach readiness probe: this @daytona/sdk install exposes no start() method', { sandboxId: sandbox.id, state: sandbox.state })\n return\n }\n logger.info('starting Daytona sandbox before attach readiness probe', { sandboxId: sandbox.id, state: sandbox.state })\n await sandbox.start(readinessTimeoutSeconds > 0 ? readinessTimeoutSeconds : undefined)\n }\n\n return {\n name: 'daytona',\n\n async spawn(config: SpawnConfig = {}): Promise<{ id: string, cwd: string }> {\n const Daytona = await loadSdk()\n const sb: Record<string, unknown> = config.sandbox ?? {}\n\n const apiKey = takeString(sb.apiKey) ?? options.apiKey\n const apiUrl = takeString(sb.apiUrl) ?? options.apiUrl\n const target = takeString(sb.target) ?? options.target\n const connectId = takeString(sb.sandboxId) ?? options.sandboxId\n const snapshot = takeString(sb.snapshot) ?? options.snapshot\n const envVars = resolveDaytonaEnv(options.env, config.env)\n\n const daytona = new Daytona(toClientConfig(apiKey, apiUrl, target))\n let attached = connectId !== undefined\n let sandbox = connectId !== undefined\n ? await daytona.get(connectId)\n : await daytona.create(resolveDaytonaCreateParams(sb, options, envVars))\n\n // An attached sandbox built from a stale snapshot is recreated from\n // scratch: the caller's snapshot pin wins over the journaled sandbox.\n if (attached && snapshot !== undefined && sandbox.snapshot !== snapshot) {\n logger.info('recreating Daytona sandbox: snapshot changed', {\n sandboxId: sandbox.id,\n previousSnapshot: sandbox.snapshot,\n newSnapshot: snapshot,\n })\n await deleteOwnedSandbox(sandbox)\n attached = false\n sandbox = await daytona.create(resolveDaytonaCreateParams(sb, options, envVars))\n }\n\n // Lifecycle ownership drives `destroy()` (onDestroy). A created sandbox is\n // always owned; an attached one is owned only when the host opts in via\n // `ownAttached`. Spawn-FAILURE cleanup is separate (see below) and keyed\n // on `!attached` so a pre-existing sandbox is never auto-deleted.\n const owned = !attached || options.ownAttached === true\n\n if (attached)\n await startAttachedSandboxIfNeeded(sandbox)\n\n live.set(sandbox.id, { sandbox, env: envVars, owned })\n\n try {\n await waitForDaytonaReady(sandbox, logger, {\n timeoutSeconds: readinessTimeoutSeconds,\n // Only auto-delete a sandbox we CREATED on readiness failure — never a\n // pre-existing attached one, even when we own its lifecycle.\n ...(!attached ? { cleanupOnTimeout: () => deleteOwnedSandbox(sandbox) } : {}),\n })\n }\n catch (err) {\n live.delete(sandbox.id)\n throw err\n }\n\n const requestedCwd = config.cwd ?? options.cwd\n let cwd: string\n if (requestedCwd) {\n cwd = requestedCwd\n await sandbox.process.executeCommand(`mkdir -p ${JSON.stringify(cwd)}`).catch(() => {})\n }\n else if (sandbox.getWorkDir) {\n cwd = await sandbox.getWorkDir().catch(() => '')\n if (!cwd)\n cwd = await sandbox.process.executeCommand('pwd').then(r => normalizeDaytonaExecResult(r).stdout.trim()).catch(() => '') || '/home/daytona'\n }\n else {\n cwd = await sandbox.process.executeCommand('pwd').then(r => normalizeDaytonaExecResult(r).stdout.trim()).catch(() => '') || '/home/daytona'\n }\n\n if (options.pregame) {\n try {\n await runDaytonaPregame(sandbox, logger, { name: options.pregame.name, content: options.pregame.content, cwd, envVars })\n }\n catch (err) {\n // Spawn-failure cleanup: only delete a sandbox we created, never a\n // pre-existing attached one (the host owns its prior state).\n if (!attached)\n await deleteOwnedSandbox(sandbox)\n live.delete(sandbox.id)\n throw err\n }\n }\n\n return { id: sandbox.id, cwd }\n },\n\n async exec(sandboxId, command, opts): Promise<ExecResult> {\n const { sandbox, env } = get(sandboxId)\n const timeoutSeconds = opts?.timeout ?? 30\n try {\n // The SDK buffers the streams uncapped (see the KNOWN RESIDUAL note\n // on `ExecutionContext.fileSize`) — cap host-side before the strings\n // propagate into tool results and session history.\n return capExecResult(normalizeDaytonaExecResult(\n await sandbox.process.executeCommand(\n command,\n opts?.cwd,\n resolveDaytonaEnv(env, opts?.env),\n timeoutSeconds > 0 ? timeoutSeconds : undefined,\n ),\n ))\n }\n catch (err) {\n return capExecResult(normalizeDaytonaExecError(err))\n }\n },\n\n /**\n * Live bidirectional stream — see `ExecutionContext.execStream`.\n *\n * PTY-backed, and not by preference: Daytona's process + session API\n * exposes no stdin at all (sessions are fire-and-forget with log\n * streaming), so a pseudo-terminal is the only interactive channel the\n * platform offers. That forces three mitigations, all in the launch\n * wrapper below, because a PTY is a terminal and a protocol stream is\n * not:\n *\n * 1. `stty -echo` — a terminal echoes everything written to stdin back\n * onto stdout. Without this the caller reads its own requests back\n * as if they were responses.\n * 2. `stty raw` — canonical mode rewrites `\\n`→`\\r\\n` and caps a line\n * at ~4096 bytes. Protocol frames routinely exceed that and would\n * be silently truncated mid-message.\n * 3. `2><file>` — a PTY has ONE stream, so the child's stderr would\n * otherwise interleave into the protocol data and corrupt framing.\n * It is redirected to a file inside the sandbox and surfaced on the\n * returned handle by polling that file through the exec API.\n *\n * The mitigations must run before the child's first byte — but the\n * launch line ITSELF is typed into a canonical-mode terminal, so it is\n * echoed once (a short non-JSON line the transport's tolerant framing\n * discards) and subject to the ~4096-byte line cap. That is why the\n * real command lives in an uploaded script and the typed line stays\n * short and constant: a long command line would be truncated before\n * `stty` ever ran. The script also restores `sh` compound-command\n * semantics that a bare `exec <command>` would break.\n */\n async execStream(sandboxId, command, opts): Promise<StreamHandle> {\n const { sandbox, env } = get(sandboxId)\n\n if (!sandbox.process.createPty) {\n throw new Error(\n 'Daytona SDK is too old: `process.createPty` is required for execStream '\n + '(used to run stdio MCP servers inside the sandbox).',\n )\n }\n\n opts?.signal?.throwIfAborted()\n\n const token = Math.random().toString(36).slice(2, 10)\n const stderrPath = `/tmp/.zidane-stream-${token}.err`\n const scriptPath = `/tmp/.zidane-stream-${token}.sh`\n\n // `exec 2>` rebinds the shell's stderr before the command runs, so\n // the command text needs no rewriting and stays compound-safe.\n await sandbox.fs.uploadFile(\n Buffer.from(`exec 2>${stderrPath}\\n${command}\\n`),\n scriptPath,\n )\n\n // See the E2B counterpart: the PTY's `onData` is a sync `void`\n // callback, so a stalled consumer can only be reported, never slowed.\n const warnBacklog = (which: string) => (bytes: number) =>\n logger.warn('execStream consumer is not draining output', { sandboxId, stream: which, bufferedBytes: bytes })\n const stdout = new StreamQueue(warnBacklog('stdout'))\n const stderr = new StreamQueue(warnBacklog('stderr'))\n\n // Everything the shell emits before the child is actually running is\n // NOISE that must never reach the caller: the echo of our own launch\n // line (typed before `-echo` takes effect), the login shell's prompt,\n // and its line-editor redraw escapes. `createPty` is `lazyStart`, so\n // the shell frequently does not exist yet when we type — it boots\n // afterwards and REPLAYS the buffered input through its line editor.\n // Observed on a stock sandbox: the stream opened with the echoed\n // launch line, the echoed first request, `\\u001b[?2004h` bracketed\n // paste, and a `%` prompt. An MCP client parses that echoed request\n // as a message and the handshake collapses.\n //\n // So: gate the stream on a sentinel the CHILD side prints, and drop\n // every byte before it. The sentinel is assembled by `printf` at\n // runtime (`Z-%s-READY` + token) so the echoed *source* line, which\n // contains the format string rather than the result, cannot match it.\n const sentinel = `Z-${token}-READY`\n let gateOpen = false\n let gateBuffer = ''\n let openGate: () => void = () => {}\n const gateReady = new Promise<void>((r) => { openGate = r })\n\n const pty = await sandbox.process.createPty({\n id: `zidane-stream-${token}`,\n ...(opts?.cwd ? { cwd: opts.cwd } : {}),\n envs: resolveDaytonaEnv(env, opts?.env) ?? {},\n onData: (data: Uint8Array) => {\n if (gateOpen) {\n stdout.push(data)\n return\n }\n gateBuffer += Buffer.from(data).toString('utf8')\n const at = gateBuffer.indexOf(sentinel)\n if (at === -1) {\n // Bounded: never let pre-gate noise grow without limit, but keep\n // a tail longer than the sentinel so it can't be split away.\n if (gateBuffer.length > 64 * 1024)\n gateBuffer = gateBuffer.slice(-1024)\n return\n }\n gateOpen = true\n openGate()\n // Everything after the sentinel's trailing newline is real output.\n const rest = gateBuffer.slice(at + sentinel.length).replace(/^\\r?\\n/, '')\n gateBuffer = ''\n if (rest.length > 0)\n stdout.push(new TextEncoder().encode(rest))\n },\n })\n await pty.waitForConnection()\n\n // Short, constant, and under any canonical line cap. `exec` replaces\n // the login shell so the PTY's lifetime is the script's lifetime and\n // no shell prompt can reach stdout.\n await pty.sendInput(`stty raw -echo; printf 'Z-%s-READY\\\\n' ${token}; exec sh ${scriptPath}\\n`)\n\n // Block until the child is genuinely live. Without this the caller can\n // write its first frame into a shell that hasn't started, where it is\n // echoed back and misread as a response.\n let gateTimer: ReturnType<typeof setTimeout> | undefined\n await Promise.race([\n gateReady,\n new Promise<void>((r) => { gateTimer = setTimeout(r, 30_000) }),\n ])\n clearTimeout(gateTimer)\n if (!gateOpen) {\n // Full teardown, not just a disconnect: Daytona PTY sessions persist\n // server-side after the websocket drops, so a bare disconnect leaks\n // one login shell plus two /tmp files per attempt — a bootstrap\n // retry loop against a broken image would stack them until the\n // sandbox dies.\n await (pty.kill?.() ?? Promise.resolve()).catch(() => {})\n await pty.disconnect().catch(() => {})\n await sandbox.process.executeCommand(`rm -f ${scriptPath} ${stderrPath}`).catch(() => {})\n throw new Error(\n `Daytona execStream: PTY did not reach the ready sentinel within 30s `\n + `(sandbox ${sandboxId}). The login shell may not have started.`,\n )\n }\n\n // stderr file → handle.stderr. Poll rather than stream: the exec API\n // is the only other channel into the sandbox, and diagnostics don't\n // need latency. Byte offsets keep re-reads incremental.\n //\n // The offset comes from the FILE (`wc -c`), never from measuring the\n // returned content: an exec API that trims a trailing newline from\n // command output would make a content-derived offset under-advance by\n // one byte per poll, re-emitting the tail byte forever. The size rides\n // back on the same round trip as a `ZEOF-<token>:` suffix; content is\n // whatever precedes it, so content-side transforms can't drift the\n // cursor either.\n let stderrOffset = 0\n let torndown = false\n const eofMark = `ZEOF-${token}:`\n const drainStderr = async (): Promise<void> => {\n try {\n const res = normalizeDaytonaExecResult(await sandbox.process.executeCommand(\n `tail -c +${stderrOffset + 1} ${stderrPath} 2>/dev/null; printf '${eofMark}%s' \"$(wc -c < ${stderrPath} 2>/dev/null || echo 0)\"`,\n ))\n const at = res.stdout.lastIndexOf(eofMark)\n if (at === -1)\n return\n const content = res.stdout.slice(0, at)\n const size = Number.parseInt(res.stdout.slice(at + eofMark.length).trim(), 10)\n if (content.length > 0)\n stderr.push(new TextEncoder().encode(content))\n if (Number.isFinite(size) && size > stderrOffset)\n stderrOffset = size\n }\n catch {\n // Diagnostic channel — polling failures must never surface as\n // protocol errors.\n }\n }\n const stderrTimer = setInterval(() => { void drainStderr() }, 2000)\n // Guarded: Bun/Node timers support unref, test fakes may not.\n ;(stderrTimer as { unref?: () => void }).unref?.()\n\n // Shared teardown for both exit paths (natural exit and kill): one\n // final stderr drain so a crash message isn't lost, then remove the\n // script + stderr files that would otherwise accumulate in /tmp for\n // the sandbox's lifetime.\n const teardown = async (): Promise<void> => {\n if (torndown)\n return\n torndown = true\n clearInterval(stderrTimer)\n await drainStderr()\n await sandbox.process.executeCommand(`rm -f ${scriptPath} ${stderrPath}`).catch(() => {})\n stdout.close()\n stderr.close()\n }\n\n const exited = pty.wait()\n .then(result => result?.exitCode ?? 0)\n .catch(() => 137)\n .finally(teardown)\n\n const kill = async (): Promise<void> => {\n // A PTY login shell never exits on its own — killing it IS the\n // normal termination path here, not an error path.\n await (pty.kill?.() ?? Promise.resolve()).catch(() => {})\n await pty.disconnect().catch(() => {})\n await teardown()\n }\n\n if (opts?.signal) {\n if (opts.signal.aborted) {\n void kill()\n }\n else {\n // Detach on exit — the (typically run-long) signal otherwise\n // retains the `kill` closure and the PTY handle for the rest of\n // the run, one dead closure per exec.\n const onAbort = () => { void kill() }\n const detach = () => opts.signal!.removeEventListener('abort', onAbort)\n opts.signal.addEventListener('abort', onAbort, { once: true })\n exited.then(detach, detach)\n }\n }\n\n return {\n pid: pty.pid ?? -1,\n stdout,\n stderr,\n write: async (data: Uint8Array): Promise<void> => {\n await pty.sendInput(data)\n },\n kill,\n exited,\n }\n },\n\n async readFile(sandboxId, path): Promise<string> {\n const data = await get(sandboxId).sandbox.fs.downloadFile(path)\n return data.toString('utf8')\n },\n\n async writeFile(sandboxId, path, content, encoding: BufferEncoding = 'utf-8'): Promise<void> {\n const data = typeof content === 'string' ? Buffer.from(content, encoding) : content\n await get(sandboxId).sandbox.fs.uploadFile(data, path)\n },\n\n async listFiles(sandboxId, path): Promise<string[]> {\n const entries = await get(sandboxId).sandbox.fs.listFiles(path)\n // Trailing `/` on directories — parity with process/docker contexts.\n return entries.map(e => (e.isDir ? `${e.name}/` : e.name))\n },\n\n async destroy(sandboxId): Promise<void> {\n const entry = live.get(sandboxId)\n if (!entry)\n return\n if (entry.owned) {\n const action = options.onDestroy ?? 'delete'\n if (action === 'stop' || action === 'pause')\n await stopOwnedSandbox(entry.sandbox)\n else if (action === 'archive')\n await archiveOwnedSandbox(entry.sandbox)\n else if (action === 'delete' || action === 'kill')\n await deleteOwnedSandbox(entry.sandbox)\n }\n live.delete(sandboxId)\n },\n }\n}\n"],"mappings":";;;;;;;AA2MA,MAAM,kCAAkC;;AAExC,MAAM,uBAAuB;;AAE7B,MAAM,0BAA0B;AAahC,SAAgB,kBACd,WACA,aACoC;CACpC,MAAM,SAAS;EAAE,GAAG;EAAW,GAAG;CAAY;CAC9C,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS,IAAI,SAAS,KAAA;AACnD;AAEA,SAAgB,2BAA2B,UAA8C;CACvF,OAAO;EACL,QAAQ,SAAS,UAAU,SAAS,WAAW,UAAU,SAAS,UAAU,SAAS,UAAU;EAC/F,QAAQ,SAAS,UAAU;EAC3B,UAAU,OAAO,SAAS,aAAa,WAAW,SAAS,WAAW;CACxE;AACF;AAEA,SAAS,cAAc,QAAgC;CACrD,OAAO;EAAE,GAAG,sBAAsB,OA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