/** * Fetch the admin-managed list of allowed base models from the backend. * * Used by `AgentBridge` at startup to register synthetic providers * (`spectral-proxy-openai` / `spectral-proxy-user-model`) that route every * inference call through the backend's `/v1/chat/completions` endpoint. * The backend authenticates the call * with the machine JWT (Bearer) and forwards to the upstream provider * using its own (centralized) API keys. * * Why GraphQL (not REST): * - The backend already exposes the whitelist via `availableAgentModels` * in its public GraphQL schema (`schema.graphql`); there is no * equivalent REST endpoint and we don't want to add one just for the * CLI. * * The query is built with the generated Zeus client (`src/generated/zeus`) * instead of a raw `fetch` + hand-written GraphQL string, so the selected * fields and their result shape stay in lock-step with `schema.graphql`. * * Caching: * - In-memory TTL cache (default 5 min), keyed by `${backendUrl}|${jwt}`. * Pi sessions are short-lived but a single `spectral serve` process * creates many of them, so we don't want to hammer the GraphQL * endpoint on every reconnect. */ export interface AllowedModel { /** Raw provider modelId, e.g. "claude-3-5-haiku-latest". Sent as `body.model`. */ modelId: string; /** Provider key as the backend records it, e.g. "anthropic", "openai", "google", "built-in". */ provider: string; /** Human-readable name. Backend currently returns the modelId here, but the * shape is forward-compatible with a separate displayName field. */ displayName: string; /** Whether the upstream model supports reasoning/thinking. */ supportsReasoning?: boolean | null; /** Backend-assigned UserModel id. Present for built-in (custom) models. */ userModelId?: string; /** Optional model credit rates (credits per 1M tokens) used for Agent UI usage display. */ creditInputPer1M?: number | null; creditOutputPer1M?: number | null; creditCachedInputPer1M?: number | null; creditCacheReadPer1M?: number | null; creditCacheWritePer1M?: number | null; /** Context window size in tokens (from backend's BaseModelInfo). */ contextWindow?: number | null; /** Whether the model supports image input (derived from capabilities.modalities.input). */ supportsImages?: boolean | null; /** Admin-configured default model flag (from backend BaseModel.isDefault). */ isDefault?: boolean | null; /** Admin-configured default vision model flag (from backend BaseModel.isVisionDefault). */ isVisionDefault?: boolean | null; } export interface FetchAllowedModelsOptions { backendUrl: string; machineJwt: string; /** * Bypass the in-memory cache for this call. Tests use this to assert * that the network is actually hit; production code never sets it. */ bypassCache?: boolean; /** TTL in milliseconds. Default 5 min. Tests use 0 to effectively disable. */ cacheTtlMs?: number; } /** Test-only helper: drops every cached entry. */ export declare function clearAllowedModelsCache(): void; /** * Fetch the whitelist of allowed base models. Throws on any failure with a * message tailored for an operator running `spectral serve` — the caller * (AgentBridge.start) lets the throw propagate so the WS subscriber sees a * clear error event instead of a silent fall-through to "no models". */ export declare function fetchAllowedModels(opts: FetchAllowedModelsOptions): Promise; //# sourceMappingURL=models-fetch.d.ts.map