/** * Codex app-server WebSocket JSON-RPC client. * * Adapted from claudemux's `plugins/claudemux/core/src/engines/codex/rpc.ts` * (excitedjs/dreamux#2 "key code-reuse conclusions"). Two differences: * - uses the public `ws` npm package instead of the vendored `#ws`; * - replaces the `codex-protocol` import with the in-tree `./types.ts`. * * The wire envelope codex emits is *not* strict JSON-RPC 2.0 — the * `jsonrpc` version field is omitted. Frame routing is by structural probe: * - method + id + params → request * - method + params → notification * - id + result|error → response */ import type { ServerNotification, ServerRequest } from './types.js'; export interface CodexWsClientOptions { /** Unix socket path the codex daemon listens on (production). */ socketPath?: string; /** `ws://...` URL — used by tests pointing at an in-process WebSocket.Server. */ url?: string; } export type NotificationHandler = (notif: ServerNotification) => void; export type ServerRequestHandler = (req: ServerRequest) => Promise; export type CloseHandler = (reason: Error) => void; /** * A long-running WebSocket connection to one codex app-server daemon. * One instance per Dispatcher; lifetime matches the dispatcher runtime. */ export declare class CodexWsClient { private readonly ws; private readonly pending; private readonly notifHandlers; private readonly closeHandlers; private serverReqHandler; private nextId; private readonly opened; private rejectOpened; private closed; private closeReason; constructor(opts: CodexWsClientOptions); ready(): Promise; onNotification(handler: NotificationHandler): () => void; /** * Install handler for server→client requests (approval, attestation, etc). * The handler's return value becomes the response `result`; a throw becomes * the response `error.message`. * * For dreamux MVP this should fail-fast on any approval request — see * issue #2 "trust model" (approval-policy=never + fail-fast handler). */ setServerRequestHandler(handler: ServerRequestHandler): void; onClose(handler: CloseHandler): void; request(method: string, params: unknown): Promise; /** * Send a JSON-RPC notification (no `id`, no response expected). codex 0.134+ * uses these for the `initialized` handshake confirmation, among others. */ notify(method: string, params: unknown): void; close(): void; private onFrame; private handleResponse; private dispatchNotification; private handleServerRequest; private tearDown; } //# sourceMappingURL=rpc.d.ts.map