/** * omp auth-gateway HTTP server. * * Accepts any provider-format request (OpenAI chat-completions, Anthropic * messages, OpenAI Responses) and dispatches through pi-ai's `streamSimple()` * — which handles credential injection, anthropic-beta headers, codex * websocket transport, and all the per-provider intricacies. The gateway is * pure protocol translation: foreign wire → omp Context → pi-ai stream() → * omp events → foreign wire. * * Endpoints: * GET /healthz → unauth; ok + version * GET /v1/usage → aggregated provider usage (5-min per-credential cache via AuthStorage) * GET /v1/credentials/check → per-credential auth probe (diagnose 401s in a multi-account pool) * GET /v1/models → list known models from the registry * POST /v1/chat/completions → OpenAI chat-completions in/out * POST /v1/messages → Anthropic messages in/out * POST /v1/responses → OpenAI Responses in/out */ import type { AuthStorage } from "../auth-storage"; import type { Api, Model } from "../types"; import type { AuthGatewayServerHandle, AuthGatewayServerOptions } from "./types"; export type ModelResolver = (modelId: string) => Model | undefined; export interface AuthGatewayBootOptions extends AuthGatewayServerOptions { /** Source of credentials. Caller wires this to a broker-backed AuthStorage. */ storage: AuthStorage; /** * Resolve a client-requested model id to a pi-ai Model. Caller supplies * this from a ModelRegistry (lives in `coding-agent` to avoid an inverse * dependency in `pi-ai`). */ resolveModel: ModelResolver; /** Optional supplier for `/v1/models` listing. Returns the full model array. */ listModels?: () => Iterable>; } export declare function startAuthGateway(opts: AuthGatewayBootOptions): AuthGatewayServerHandle;