import { spawn } from "node:child_process"; import { LspClient } from "./client.js"; import { type LanguageServerSpec } from "./discovery.js"; import type { LspPublishDiagnosticsParams, LspServerHealth, LspServerIdentity } from "./types.js"; /** * Authoritative LSP server lifecycle manager. * * - One reusable server per (workspace, language, executable); duplicate * server startup is prevented. * - Bounded startup/initialize/request timeouts. * - Graceful `shutdown` → `exit` and authoritative process cleanup (no leaks). * - Crash detection and typed degraded state with a bounded restart policy. * - Server stderr retained as bounded, sanitized diagnostic evidence. * - Server responses are untrusted and never adopted as an execution authority. */ export interface LspManagerOptions { workspaceRoot: string; specs?: LanguageServerSpec[]; startupTimeoutMs?: number; initializeTimeoutMs?: number; requestTimeoutMs?: number; maxRestarts?: number; restartDelayMs?: number; onDiagnostics?: (params: LspPublishDiagnosticsParams) => void; } interface ManagedServer { serverId: string; languageId: string; executable: string; exePath: string; args: string[]; processIdentity: string; client: LspClient; proc: ReturnType; kill: () => void; initializedAt: string; restartCount: number; state: "starting" | "running" | "degraded" | "stopped" | "crash_loop"; lastError?: string; capabilitiesHash: string; diagnostics: LspPublishDiagnosticsParams[]; } export declare class LspServerManager { private options; private servers; private starting; private workspaceRoot; private rootUri; constructor(opts: LspManagerOptions); private key; private hashCapabilities; /** * Get (or create and reuse) a managed server for a language. Returns null * when no server is installed or startup failed (typed via `unavailable`). */ getServer(languageId: string): Promise<{ server: ManagedServer; unavailableReason?: string; }>; private startServer; private onExit; private restartServer; identity(languageId: string): Promise; health(languageId: string): LspServerHealth | null; listServers(): Array<{ serverId: string; languageId: string; executable: string; state: string; }>; /** Read bounded diagnostics published by a server for a URI. */ diagnosticsForUri(uri: string): LspPublishDiagnosticsParams[]; shutdownAll(): Promise; } export type { ManagedServer }; //# sourceMappingURL=manager.d.ts.map