@sema-agent/core
Version:
Stateless, task-oriented AI agent core
16 lines (15 loc) • 1.14 kB
TypeScript
/**
* LSP base-protocol framing over a byte stream (stdio) — `Content-Length: <n>\r\n\r\n<n bytes of JSON>`. A
* language server speaks JSON-RPC over stdin/stdout with THIS framing (the part a WebSocket transport skips,
* since each WS message is already one message). Ported 1:1 from service's unit-tested `lsp-frames` bridge
* decoder + CC's `StreamMessageReader`/`StreamMessageWriter` (vscode-jsonrpc) — hand-rolled here to keep core
* dependency-free (the framing is trivial; a native LSP-client dep is not worth it).
*/
/** Encode a JSON-RPC message body as an LSP base-protocol frame (header + payload) ready to write to stdin. */
export declare function encodeFrame(json: string): Buffer;
/**
* A stateful decoder: feed it stdout chunks, get back complete JSON payloads (0+ per chunk — a frame can span
* chunks, and a chunk can hold several). `maxBytes` caps the buffer so a server that never emits a delimiter
* (or a corrupt Content-Length) can't grow it unboundedly — on overflow the buffer is dropped (fail-safe).
*/
export declare function createFrameDecoder(maxBytes?: number): (chunk: Buffer) => string[];