/** * Daytona Sandbox Provider * * @requires @daytonaio/sdk >= 0.134.0 * * Design principles: * - Mirror E2B provider interface for SDK compatibility * - Uses public Docker images via IMAGE_MAP * - Parallel structure to E2B provider */ /** * Wrap command with cwd and envs shell prefixes. * * Daytona's executeSessionCommand doesn't support cwd or envs natively, * so we inline them as shell commands. Values are single-quoted to handle * spaces and special characters safely. */ declare function wrapCommand(command: string, cwd?: string, envs?: Record): string; /** @internal Test-only export for unit testing wrapCommand logic. */ declare const _testWrapCommand: typeof wrapCommand; /** Result of a completed sandbox command */ interface SandboxCommandResult { exitCode: number; stdout: string; stderr: string; } /** Handle to a running background process in sandbox */ interface SandboxCommandHandle { readonly processId: string; wait(): Promise; kill(): Promise; } /** Information about a running process */ interface ProcessInfo { processId: string; cmd: string; args: string[]; envs: Record; cwd?: string; tag?: string; } /** Sandbox metadata and lifecycle info */ interface SandboxInfo { sandboxId: string; image: string; name?: string; metadata: Record; startedAt: string; endAt?: string; } /** File or directory entry info */ interface FileInfo { name: string; path: string; type: "file" | "dir"; } /** Options for blocking sandbox command execution */ interface SandboxRunOptions { timeoutMs?: number; envs?: Record; cwd?: string; onStdout?: (data: string) => void; onStderr?: (data: string) => void; } /** Options for spawning background sandbox processes */ interface SandboxSpawnOptions extends SandboxRunOptions { stdin?: boolean; } /** Resource configuration for sandbox */ interface SandboxResources { /** CPU cores (default: 4) */ cpu?: number; /** Memory in GB (default: 4) */ memory?: number; /** Disk in GB (default: 10) */ disk?: number; } /** Options for creating a sandbox */ interface SandboxCreateOptions { image?: string; envs?: Record; metadata?: Record; timeoutMs?: number; workingDirectory?: string; /** Resource allocation for the sandbox */ resources?: SandboxResources; } /** Options for listing sandboxes */ interface SandboxListOptions { state?: ("running" | "paused")[]; metadata?: Record; limit?: number; } /** Command execution capabilities */ interface SandboxCommands { run(command: string, options?: SandboxRunOptions): Promise; spawn(command: string, options?: SandboxSpawnOptions): Promise; list(): Promise; kill(processId: string): Promise; } /** File system operations */ interface SandboxFiles { read(path: string): Promise; write(path: string, content: string | Buffer | ArrayBuffer | Uint8Array): Promise; writeBatch(files: Array<{ path: string; data: string | Buffer | ArrayBuffer | Uint8Array; }>): Promise; makeDir(path: string): Promise; exists(path: string): Promise; list(path: string): Promise; remove(path: string): Promise; rename(oldPath: string, newPath: string): Promise; } /** Sandbox instance */ interface SandboxInstance { readonly sandboxId: string; readonly commands: SandboxCommands; readonly files: SandboxFiles; getHost(port: number): Promise; isRunning(): Promise; getInfo(): Promise; kill(): Promise; pause(): Promise; } /** Sandbox lifecycle management */ interface SandboxProvider { readonly providerType: string; readonly name?: string; create(options: SandboxCreateOptions): Promise; connect(sandboxId: string, timeoutMs?: number): Promise; list(options?: SandboxListOptions): Promise; } interface DaytonaConfig { /** Daytona API key. Default: reads from DAYTONA_API_KEY env var */ apiKey?: string; /** API URL. Default: https://app.daytona.io/api */ apiUrl?: string; /** Target region. Default: us */ target?: string; /** Default timeout in ms */ defaultTimeoutMs?: number; /** Daytona snapshot name (default: 'evolve-all'). Create custom snapshots via `cd assets && ./build.sh daytona` */ snapshotName?: string; } interface ResolvedDaytonaConfig { apiKey: string; apiUrl?: string; target?: string; defaultTimeoutMs?: number; snapshotName?: string; } declare class DaytonaProvider implements SandboxProvider { readonly providerType: "daytona"; readonly name = "Daytona"; private readonly client; private readonly defaultTimeoutMs; private readonly snapshotName; constructor(config: ResolvedDaytonaConfig); create(options: SandboxCreateOptions): Promise; connect(sandboxId: string, _timeoutMs?: number): Promise; list(options?: SandboxListOptions): Promise; } /** * Create Daytona sandbox provider. * * @param config - Optional configuration. If apiKey not provided, reads from DAYTONA_API_KEY env var. * @throws Error if apiKey cannot be resolved */ declare function createDaytonaProvider(config?: DaytonaConfig): SandboxProvider; export { type DaytonaConfig, DaytonaProvider, type FileInfo, type ProcessInfo, type SandboxCommandHandle, type SandboxCommandResult, type SandboxCommands, type SandboxCreateOptions, type SandboxFiles, type SandboxInfo, type SandboxInstance, type SandboxListOptions, type SandboxProvider, type SandboxResources, type SandboxRunOptions, type SandboxSpawnOptions, _testWrapCommand, createDaytonaProvider };