UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

39 lines (38 loc) • 1.87 kB
import { type LspTransport } from "../../core/lsp.js"; /** The slice of a spawned child process the transport uses (so a test can drive a fake duplex — no real spawn). */ export interface LspChildProcess { stdin: { write(data: Buffer): void; on(event: "error", cb: (err: unknown) => void): void; }; stdout: { on(event: "data", cb: (chunk: Buffer) => void): void; }; on(event: "exit" | "error", cb: (arg?: unknown) => void): void; kill(signal?: string): void; /** Present on a real child process; used on win32 (shell:true shim) to tree-kill on close. */ pid?: number; } export declare class StdioLspTransport implements LspTransport { private readonly child; private readonly requestTimeoutMs; private nextId; private readonly pending; private isClosed; private readonly decode; /** design/121: server→client notification subscribers (publishDiagnostics, …). Empty = pre-121 behavior. */ private readonly notificationHandlers; constructor(child: LspChildProcess, requestTimeoutMs?: number); /** Manager-visible liveness: evict + reopen instead of reusing a dead server (crashed / killed). */ get closed(): boolean; private onMessage; /** design/121 {@link LspTransport.onNotification}: subscribe to server notifications; returns unsubscribe. */ onNotification(handler: (method: string, params: unknown) => void): () => void; /** RB-232: every failAll caller — child exit, child error, AND deliberate close() — means "server is * gone" to the model, so all are branded `server_terminated` alike (no exit-vs-close distinction). */ private failAll; private send; request(method: string, params: unknown, signal?: AbortSignal): Promise<unknown>; notify(method: string, params: unknown): void; close(): Promise<void>; }