/** * Newline-delimited JSON message framing - the exact wire format * @modelcontextprotocol/sdk uses for stdio (see its own ReadBuffer in * dist/esm/shared/stdio.js: messages are `JSON.stringify(message) + '\n'`, * split on the first '\n', with a trailing '\r' tolerated on read). * * Buffers as raw bytes (not strings) so a multi-byte UTF-8 character split * across two chunks is never corrupted. */ export declare class NdjsonReader { private buffer; /** Feed a raw chunk of bytes read from a stream. */ push(chunk: Buffer): void; /** * Pull the next complete line, if any, as a raw string (not yet parsed). * Returns undefined if no complete line is buffered yet. */ readLine(): string | undefined; /** Drain and return every complete line currently buffered, in order. */ readAllLines(): string[]; } /** JSON-RPC 2.0 message shape, classified structurally (no schema validation). */ export type ParsedMessage = { kind: 'request'; id: string | number; method: string; raw: unknown; } | { kind: 'notification'; method: string; raw: unknown; } | { kind: 'response'; id: string | number; raw: unknown; } | { kind: 'unparseable'; raw: string; }; /** * Classify a raw NDJSON line. Never throws - an unparseable or * unrecognizable line is still forwarded (as 'unparseable'), since the * supervisor's job is to proxy, not to police the protocol. */ export declare function classifyLine(line: string): ParsedMessage; export declare function serializeMessage(message: unknown): string; //# sourceMappingURL=ndjson-reader.d.ts.map