/** * AgentSandbox - Unified sandbox wrapper for Modal * * This class consolidates all sandbox-related operations: * 1. Infrastructure primitives (exec, file I/O, etc.) * 2. SDK execution and message streaming * 3. File system setup and session state management * * It replaces the previous SessionFileManager and AgentSDKService, * providing a single cohesive interface for all sandbox operations. */ import { ModalContext } from '../lib/sandbox/modal/client.js'; import { AgentProfile } from '../types/agent-profiles.js'; import { AGENT_ARCHITECTURE_TYPE, PersistedSessionData, WorkspaceFile } from '../types/session/index.js'; import { ConversationBlock } from '../types/session/blocks.js'; import { StreamEvent } from '../types/session/streamEvents.js'; import type { EventBus } from './event-bus.js'; /** * Custom error message type (not in SDK) * Used for wrapping errors from SDK execution */ export interface SDKErrorMessage { type: 'error'; error: { message: string; stack?: string; name?: string; }; timestamp: number; } interface AgentSandboxProps { modalContext: ModalContext; agentProfile: AgentProfile; eventBus: EventBus; session: { newSessionId: string; architecture: AGENT_ARCHITECTURE_TYPE; } | { savedSessionData: PersistedSessionData; }; /** Optional callback for status updates during sandbox creation */ onStatusChange?: (message: string) => void; } /** * Unified wrapper around Modal Sandbox with all agent-related operations */ export declare class AgentSandbox { private readonly agentProfile; private readonly sessionId; private readonly sandboxId; private readonly sandbox; private readonly architectureAdapter; private readonly eventBus; /** * Create and initialize a new AgentSandbox * * @param modalContext - Modal client context * @param options - Sandbox configuration * @returns Initialized AgentSandbox instance */ static create(props: AgentSandboxProps): Promise; private constructor(); /** * Get the unique sandbox ID */ getId(): string; private initialize; terminate(): Promise; private setupAgentProfile; private setupSessionTranscripts; private setupWorkspaceFiles; /** * Start file watchers and wait for them to be ready. * This is called during initialize() to ensure watchers are in place * before any queries can be executed. */ private startWatchers; /** * Handle workspace file change events. * Emits file events to EventBus. */ private handleWorkspaceFileEvent; /** * Handle transcript file change events. * Emits transcript change events to EventBus. */ private handleTranscriptFileEvent; executeQuery(prompt: string): AsyncGenerator; /** * Check sandbox health * @returns null if running, exit code (number) if exited */ heartbeat(): Promise; readSessionTranscripts(): Promise<{ main: string | null; subagents: { id: string; transcript: string; }[]; }>; /** * Parse session transcripts into ConversationBlocks * * This method reads the raw transcripts from the sandbox and parses them * using the architecture adapter into a unified ConversationBlock format. * * @returns Parsed blocks for main conversation and subagents */ parseSessionTranscripts(): Promise<{ blocks: ConversationBlock[]; subagents: { id: string; blocks: import('../types/session/blocks.js').ConversationBlock[]; }[]; }>; readAllWorkspaceFiles(): Promise; } export {}; //# sourceMappingURL=agent-sandbox.d.ts.map