import { SandboxChannel, SandboxHandle } from '@tanstack/ai-sandbox'; import { AcpMessageFraming } from '../transport/types.js'; import { AcpWebSocketConnection } from '../transport/websocket.js'; export interface AcpSandboxServer { /** WebSocket URL the orchestrator uses to reach the in-sandbox ACP server. */ wsUrl: string; /** Sandbox channel used to build {@link wsUrl} (auth headers, when issued). */ channel: SandboxChannel; /** Open the ACP JSON-RPC stream over WebSocket. */ connect: (signal?: AbortSignal) => Promise; /** Stop the in-sandbox server process. */ dispose: () => Promise; } export interface StartAcpServerOptions { port: number; cwd: string; /** Full shell command that starts the harness ACP server inside the sandbox. */ command: string; /** Build the WebSocket URL once the server is ready and the port is exposed. */ buildWsUrl: (input: { channel: SandboxChannel; port: number; stdout: string; }) => string; /** * Return true once {@link buildWsUrl} can be called. Receives accumulated * stdout from the server process. */ isReady?: (stdout: string) => boolean; /** Substring/regex marker used when {@link isReady} is omitted. */ readyMarker?: string; env?: Record; timeoutMs?: number; signal?: AbortSignal; framing?: AcpMessageFraming; hostname?: string; } /** * Boot a harness ACP WebSocket server inside a sandbox and expose its port via * {@link SandboxHandle.ports.connect}. Mirrors the `opencode serve` pattern. */ export declare function startAcpServerInSandbox(sandbox: SandboxHandle, options: StartAcpServerOptions): Promise; /** Parse a `WebSocket URL: ws://…` line printed by `grok agent serve`. */ export declare function parseWebSocketUrlFromServeOutput(output: string): string | undefined; /** Build a Grok `agent serve` WebSocket URL from a sandbox channel + secret. */ export declare function buildGrokServeWebSocketUrl(channelUrl: string, secret: string): string;