/** * tool-command-worker-rpc — the WORKER side of the ADR-0054 host-RPC upcall * channel (increment M4-C). * * A host-RPC seam in the worker shim (`tool-command-worker-context.ts`) calls * `hostRpc(request)`: it stamps a monotonic `rpcId`, posts the request to the * parent over the transport's `progress` arm * (`WorkerMessage`), and BLOCKS on the * matching {@link RpcReply} the parent posts back via `child.send`. The host * performs the privileged effect through the real `ToolCliContext` and replies; * a host-side fault crosses back as `{ ok: false, error }`, which this re-throws * so the handler sees a normal thrown error (never a host crash, never a silent * no-op). * * Replies are delivered on the worker's single `process.on('message')` listener, * installed once and demultiplexed by `rpcId` into the pending-request map. The * listener ignores anything that is not an `rpc-reply` (the channel is otherwise * child → parent), so it never races the worker's own outbound posts. */ import type { DispatchProgressEvent, HostRpcCall } from './tool-command-dispatch-types.js'; import type { WorkerMessage } from '@opensip-cli/core'; /** The worker's outbound IPC type binding: requests stream on `progress`. */ type WorkerOutbound = WorkerMessage; /** * A worker RPC client: `call` issues one upcall and resolves with the host's * reply value (or rejects with the host's structured error). `dispose` removes * the reply listener (hygiene for the short-lived fork; the process exits on * settle regardless). */ export interface WorkerRpcClient { /** * Issue one host-RPC upcall (sans `rpcId` — assigned here) and await the * host's reply. * * @throws {Error} when the host reply is `{ ok: false }` (the host-side fault * re-thrown into the handler), or when the worker is not forked with an IPC * channel (no `process.send`, an integration-only misuse). */ readonly call: (request: HostRpcCall) => Promise; readonly dispose: () => void; } /** * Create the worker's RPC client over the live IPC channel. Installs the single * reply listener; `send` posts requests on the `progress` arm. The caller passes * `process` so unit tests can supply a fake duplex. */ export declare function createWorkerRpcClient(channel: { send?: (msg: WorkerOutbound) => unknown; on: (event: 'message', listener: (msg: unknown) => void) => unknown; off?: (event: 'message', listener: (msg: unknown) => void) => unknown; }): WorkerRpcClient; export {}; //# sourceMappingURL=tool-command-worker-rpc.d.ts.map