/** * Minimal JSON-RPC 2.0 line transport over a paired stream. One newline- * terminated JSON frame per message; request correlation by numeric id. * * The gateway core is intentionally dependency-free: it must run in any * environment (smoke tests, dsh host, standalone) without touching the * published dsh package set. This transport mirrors the framing semantics of * the official `@deepseek-ai/dsh-sdk-protocol` line transport. * * @module dsh-subagent-codex-plus/gateway/transport */ import type { Readable, Writable } from 'node:stream'; /** Structured JSON-RPC error carried to callers of {@link JsonRpcLineTransport.request}. */ export declare class JsonRpcTransportError extends Error { readonly code: number; readonly data?: unknown | undefined; constructor(code: number, message: string, data?: unknown | undefined); } export type JsonRpcRequestHandler = (method: string, params: unknown) => unknown | Promise; export type JsonRpcNotificationHandler = (method: string, params: unknown) => void; /** * Frame, dispatch, and correlate JSON-RPC messages on one input/output pair. * Starts reading on {@link start}; requests reject once closed. */ export declare class JsonRpcLineTransport { private readonly input; private readonly output; private readonly pending; private buffer; private sequence; private closed; private requestHandler; private notificationHandler; constructor(input: Readable, output: Writable); /** Register the handler for server-initiated requests. */ onRequest(handler: JsonRpcRequestHandler): void; /** Register the handler for server-initiated notifications. */ onNotification(handler: JsonRpcNotificationHandler): void; /** Begin consuming input frames. Idempotent. */ start(): void; /** * Send one request and await its correlated response. * @param method - RPC method name. * @param params - positional or named parameters. * @param signal - optional abort for this request only. */ request(method: string, params: object, signal?: AbortSignal): Promise; /** Send one fire-and-forget notification. */ notify(method: string, params?: object): void; /** Reject all outstanding requests and stop accepting new ones. Idempotent. */ close(): void; private onData; private handleLine; private handleServerRequest; private write; private failAll; }