import type { RpcErrorObject, RpcId } from "./rpc.js"; /** An error that crosses the wire as a JSON-RPC error object. */ export declare class RpcError extends Error { readonly code: number; readonly data?: unknown | undefined; constructor(code: number, message: string, data?: unknown | undefined); static app(appCode: string, message: string, extra?: Record): RpcError; /** The `data.code` of an application error, if any. */ get appCode(): string | undefined; toObject(): RpcErrorObject; } /** Returned by a request handler to leave a request unanswered for good. */ export declare const ABANDON: unique symbol; export type RequestHandler = (method: string, params: unknown, id: RpcId, signal: AbortSignal) => unknown | Promise; export type NotificationHandler = (method: string, params: unknown) => void; export interface RpcPeerOptions { /** Sends one serialized JSON-RPC message. */ send: (text: string) => void; onRequest?: RequestHandler; onNotification?: NotificationHandler; /** Default timeout for outgoing requests; 0 disables it. */ requestTimeoutMs?: number; } /** * Transport-agnostic JSON-RPC 2.0 peer: both sides can issue requests and * notifications. Feed incoming text frames to `receive()`. */ export declare class RpcPeer { private readonly options; private nextId; private readonly pending; private readonly inbound; private closed; constructor(options: RpcPeerOptions); request(method: string, params?: unknown, timeoutMs?: number): Promise; notify(method: string, params?: unknown): void; receive(text: string): void; private receiveLine; /** Rejects every in-flight request; later calls fail immediately. */ close(reason?: string): void; get isClosed(): boolean; hasPendingRequest(id: RpcId): boolean; private dispatch; private write; }