/** * SandboxBridge - HTTP client for the WorkspaceAgent /agent-sandbox/* routes. * Runs inside vibe-app Workers/DOs (framework code) and uses the standard * Cloudflare Workers fetch API — no external dependencies. */ import type { PrepareSessionRequest, PrepareSessionResponse, ExecuteAgentRequest, ExecuteAgentResponse, ReadOutputsRequest, ReadOutputsResponse, DelegateWorkspaceContext } from './types'; export declare class SandboxBridge { private readonly baseUrl; private readonly apiKey; private readonly workspaceId; constructor(workspaceApiUrl: string, workspaceApiKey: string, workspaceId: string); private request; /** * Prepare (or resume) a sandbox session. * Must be called before executing code in a new session. */ prepareSession(req: PrepareSessionRequest): Promise; /** * Execute a Agent task inside the sandbox session. * Returns the full output once the run completes. */ executeAgent(req: ExecuteAgentRequest): Promise; /** * Execute a Agent task with SSE streaming output. * Returns the raw Response so the caller can parse the event stream. * The body contains `stream: true` and `Accept: text/event-stream` is set. */ executeAgentStream(req: ExecuteAgentRequest): Promise; /** * Read file contents back from the sandbox after execution. */ readOutputs(req: ReadOutputsRequest): Promise; /** * Query the current status of a sandbox session. * Returns whether the session process is still running and its exit code if finished. */ getSessionStatus(sessionId: string): Promise<{ running: boolean; exitCode?: number; }>; /** * Fetch workspace context (apps, MCP servers, skills) from the WorkspaceAgent. * Used to populate CLAUDE.md and MCP settings with real workspace data. */ getWorkspaceContext(): Promise; /** * Save the full event log for a completed execution to R2 for replay. */ saveExecutionStream(req: { sessionId: string; content: string; }): Promise; /** * Retrieve a previously saved execution stream from R2. * Returns null if the stream has not been persisted yet. */ getExecutionStream(sessionId: string): Promise<{ executionId: string; events: Array<{ type: string; [key: string]: unknown; }>; result: { response: string; usage: { inputTokens: number; outputTokens: number; cost: number; }; exitCode: number; }; timestamp: string; } | null>; /** * Read new content from the stream.log file for a running or completed execution. * Uses offset-based reads so callers only get new content each poll. * Returns the new content and the updated offset for the next poll. */ readStreamLog(sessionPath: string, offset?: number): Promise<{ content: string; offset: number; }>; /** * Send a keepalive ping to reset the sandbox idle timer. * Fire-and-forget: errors are silently swallowed to avoid disrupting the caller. */ sendKeepalive(): void; }