/** * Transport-neutral JSON-RPC dispatcher. Every JSON-RPC transport adapter * (HTTP POST, WebSocket frame, stdio session) calls `dispatchJsonRpc` * with the raw body and a dispatch context; the dispatcher parses the * body, resolves each request via `executeOperation`, and produces the * wire-level response shape. * * The stable JSON-RPC operation-catalog contract mandates sequential dispatch * in request order. Response order matches request order by construction — * notifications are dropped from the response array, so the returned * indices are the non-notification request indices. * * Notifications invoke the operation (for side effects) but produce no * response. An all-notification batch returns `kind: 'notification-batch'` * so transport adapters can translate it to HTTP 204 / no-response * appropriately. */ import { type JsonRpcResponse } from './json-rpc-protocol.ts'; import { type OperationRegistry } from './operation-catalog.ts'; import { type TransportKind } from './operation-fault.ts'; import { type Principal } from './principal.ts'; export type DispatchJsonRpcContext = { readonly principal: Principal; readonly engine: unknown; readonly transport: Extract; readonly registry: OperationRegistry; }; /** * Result of dispatching a JSON-RPC body. Shapes: * - `single`: a single request → one response (success or error). * - `notification`: a single notification → no response. * - `batch`: a batch with at least one non-notification → an array of * responses in request order. * - `notification-batch`: a batch where every item is a notification * → no response body on the wire (HTTP 204, etc.). */ export type DispatchJsonRpcResult = { readonly kind: 'single'; readonly response: JsonRpcResponse; } | { readonly kind: 'notification'; } | { readonly kind: 'batch'; readonly responses: ReadonlyArray; } | { readonly kind: 'notification-batch'; }; /** Parse the raw body and dispatch each request. */ export declare function dispatchJsonRpc(body: unknown, context: DispatchJsonRpcContext): Promise;