/** * Manages the lifecycle of the OpenCode headless server (`opencode serve`). * * On MCP startup: * 1. Check if an existing server is healthy → use it. * 2. Otherwise, spawn `opencode serve` as a child process. * 3. Wait for the "listening on" line in stderr → confirm via health check. * 4. If spawn fails after retries → throw so main() can abort MCP startup. * * On MCP shutdown: * - Kill the child process (SIGTERM → SIGKILL fallback). * * Mid-operation crash: * - Detected via circuit breaker in opencode-spawner.ts. * - Exports `restartIfManaged()` so the spawner can attempt a restart. */ import { type OpenCodeClient } from './opencode-client.js'; /** * Ensure the OpenCode server is running and healthy. * If an external server is already healthy, uses it (no child process). * Otherwise spawns `opencode serve` and waits for readiness. * * @returns The base URL of the healthy server. * @throws If the server cannot be started after retries. */ export declare function ensureOpenCodeServer(client: OpenCodeClient): Promise; /** * Attempt to restart the managed server (called from spawner on connection failure). * Returns true if restart succeeded, false if not managed or retry limit hit. */ export declare function restartIfManaged(): Promise; /** * Kill the managed server process (called during MCP shutdown). */ export declare function shutdownManagedServer(): void; /** * Whether we're managing the server process (vs using an external one). */ export declare function isManaged(): boolean; //# sourceMappingURL=opencode-server-manager.d.ts.map