import { type ChildProcess } from 'child_process'; /** * JSON-RPC 2.0 transport over stdio for LSP communication. * * Handles: * - Content-Length framed message encoding/decoding * - Request/response correlation via JSON-RPC IDs * - Notification dispatch to registered handlers * - Process lifecycle management */ export declare class LspTransport { readonly serverPath: string; readonly args: string[]; process: ChildProcess | null; closed: boolean; private idCounter; private pendingRequests; private notificationHandlers; private buffer; constructor(serverPath: string, args: string[]); /** * Start the LSP server process and wire up stdio. */ start(): void; /** * Generate next JSON-RPC request ID. */ nextId(): number; /** * Format a JSON-RPC 2.0 request message (with ID, expects response). */ formatRequest(id: number, method: string, params: any): string; /** * Format a JSON-RPC 2.0 notification message (no ID, no response expected). */ formatNotification(method: string, params: any): string; /** * Encode a message with Content-Length header (LSP framing). */ encodeMessage(body: string): string; /** * Parse a raw message from the buffer, extracting the body if a complete * Content-Length framed message is available. * * Returns the message body string, or null if the message is incomplete. */ parseRawMessage(raw: string): string | null; /** * Register a handler for a server-to-client notification. */ registerNotificationHandler(method: string, handler: (params: any) => void): void; /** * Get a registered notification handler. */ getNotificationHandler(method: string): ((params: any) => void) | null; /** * Send a request and wait for the response. */ send(method: string, params: any): Promise; /** * Resolve a pending response (used by tests to inject responses). */ resolveResponse(id: number): Promise; /** * Process incoming data from stdout, parsing Content-Length framed messages. */ processDataBuffer(chunk: Buffer): void; /** * Close the transport, killing the server process. */ close(): void; } /** * Create a new LspTransport instance (factory function). */ export declare function createLspTransport(serverPath: string, args: string[]): LspTransport;