/** * GatewayDispatchPort (spec §1/§6). The opaque model-invocation seam the * gateway dispatches through — llm-mesh fills it server-side once an account * is selected + resolved. Mirrors the `MeshDispatchPort` contract published by * `@sentropic/chat-core` (`chat-core/mesh-port.ts`): chat-core never imports * provider creds, it sees only this opaque port. Here the gateway OWNS the * concrete dispatch (selected `SecretAuthMaterial` + llm-mesh adapter), so it * keeps its own local port name rather than depending on chat-core. * * Native passthrough retains these signatures. Routed execution uses the * separate RouteAttemptDispatchPort below, without provider credentials. */ import type { RequestSizeDetail, SecretAuthMaterial } from '@sentropic/llm-mesh'; import type { GenerateResponse, PreparedRouteAttempt, StreamRequest, StreamResult } from '@sentropic/llm-mesh'; import type { NativeMessagesRequest, NativeMessagesResult, PreparedNativeMessages } from '@sentropic/llm-mesh'; export interface NativeAttemptDispatchRequest { readonly capability: PreparedNativeMessages; readonly request: NativeMessagesRequest; } export interface RouteAttemptDispatchRequest { readonly attempt: Pick; readonly request: Omit; } export interface RouteAttemptDispatchPort { generate(input: RouteAttemptDispatchRequest): Promise; stream(input: RouteAttemptDispatchRequest): Promise; nativeMessages?(input: NativeAttemptDispatchRequest): Promise; } export type GatewayWire = 'anthropic-messages' | 'openai-chat-completions' | 'openai-responses'; /** * One dispatch unit: the provider-native body passed through verbatim (spec * §3b), plus the resolved executable material and the wire to frame the * response on. `body` stays opaque — the gateway round-trips the vendor shape. */ export interface GatewayDispatchRequest { readonly wire: GatewayWire; readonly providerId: string; readonly model: string; readonly material: SecretAuthMaterial; /** Provider-native request JSON, passed through verbatim. */ readonly body: unknown; readonly stream: boolean; /** * Reasoning effort implied by the resolved target/alias (e.g. a `*-xhigh` * launch alias). Optional; the dispatch impl applies it to the provider * request. Absent = honor whatever the verbatim body already carries. */ readonly effort?: string; readonly signal?: AbortSignal; } /** * Provider response headers carried through the dispatch contract (#4). The * gateway forwards an ALLOWLIST of these so request-ids/rate-limit/version/beta/ * retry headers survive — faithful passthrough. Keys are lowercased. */ export type ProviderResponseHeaders = Readonly>; /** Non-stream provider-native response, passed through verbatim. */ export interface GatewayDispatchResponse { readonly status: number; readonly body: unknown; /** Provider response headers (lowercased). The router forwards the allowlist (#4). */ readonly headers?: ProviderResponseHeaders; /** Trusted measured size evidence; terminal 413 survives callback wrapping. */ readonly requestSize?: RequestSizeDetail; } /** Provider-native SSE event, framed by wire (Anthropic event/data; OpenAI data + [DONE]). */ export interface GatewayDispatchStreamEvent { readonly raw: string; } /** * A streaming dispatch result: the provider response headers (known BEFORE the * first byte) + the async frame iterator. Carrying headers here lets the router * forward the allowlisted provider stream headers (#4) faithfully. */ export interface GatewayDispatchStream { /** Provider response headers (lowercased) for the stream. */ readonly headers?: ProviderResponseHeaders; /** The provider-native SSE frames, relayed verbatim. */ readonly frames: AsyncIterable; } export interface GatewayDispatchPort { dispatch(request: GatewayDispatchRequest): Promise; dispatchStream(request: GatewayDispatchRequest): GatewayDispatchStream; } //# sourceMappingURL=dispatch.d.ts.map