/** * Wire helpers (spec §3b, §16.2). The gateway resolves provider/model from the * request BODY `model` (the only body field it reads for routing) and frames * responses faithfully per wire: * - Anthropic Messages: `event: \ndata: \n\n` ... `message_stop`. * - OpenAI Chat Completions: `data: \n\n` ... `data: [DONE]\n\n`. * - OpenAI Responses (`/responses`, `/v1/responses`): `event: \n` + * `data: \n\n` with a monotonic `sequence_number` in every data * object; the terminal event closes the stream (never Chat `[DONE]`). * * The gateway does NOT mutate the provider-native body or the provider-native * SSE payloads — it only frames/relays them. These helpers exist so the router * can (a) read `model` for routing and (b) re-frame a normalized event stream * into the faithful provider SSE bytes for a fixture/passthrough test. */ import type { GatewayWire } from './ports/dispatch.js'; export declare const WIRE_BY_PATH: Readonly>; /** * Read the `model` string from a provider-native request body. Both Anthropic * Messages and OpenAI Chat Completions place the model at top-level `model`. * Returns `undefined` for a malformed body (router maps to a 400 bad-request). */ export declare const readModel: (body: unknown) => string | undefined; /** Read the `stream` flag from a provider-native body (defaults false). */ export declare const readStream: (body: unknown) => boolean; /** * Frame one Anthropic Messages SSE event: `event: \ndata: \n\n`. * `data` is the provider-native JSON, passed through verbatim. */ export declare const frameAnthropicEvent: (eventName: string, data: unknown) => string; /** Frame one OpenAI Chat Completions SSE chunk: `data: \n\n`. */ export declare const frameOpenAiChunk: (data: unknown) => string; /** * Frame one OpenAI Responses SSE event: `event: \ndata: \n\n` * (spec §16.5). Independent of Chat Completions framing: no `[DONE]` * sentinel — the terminal `response.completed` / `response.incomplete` / * `response.failed` event closes the stream. */ export declare const frameResponsesEvent: (eventType: string, data: unknown) => string; /** The OpenAI stream terminator. */ export declare const OPENAI_DONE = "data: [DONE]\n\n"; /** Content-Type for an SSE response. */ export declare const SSE_CONTENT_TYPE = "text/event-stream; charset=utf-8"; /** * Parse a raw SSE text blob into discrete events for assertions. Splits on the * blank-line record separator and keeps the raw frame. Used by tests to assert * faithful framing without re-implementing an SSE parser in each test. */ export interface ParsedSseEvent { readonly event?: string; readonly data: string; readonly raw: string; } export declare const parseSse: (text: string) => ParsedSseEvent[]; //# sourceMappingURL=wire.d.ts.map