/** * Model catalog — static fallback + live provider API fetching. * * Provides `fetchProviderModels(provider, apiKey)` for live model lists and * `getStaticModels(provider)` as an offline fallback. * OMP model listing is handled by `OmpDriver.listModels()` in the bridge driver. */ /** * A single LLM model entry returned by the model catalog. * * Used by `getModels`, `getStaticModels`, and `fetchProviderModels` to represent * an available model for a provider. * * @docLink packages/bridge/api-reference#models */ export interface ModelEntry { /** Provider-specific model identifier used in API calls (e.g. `"claude-sonnet-4-5"`). */ id: string; /** Human-readable display name for UIs and logs (e.g. `"Claude Sonnet 4.5"`). */ name: string; } /** * Result of a model-list fetch operation, with source attribution. * * Returned by {@link fetchProviderModels} and {@link getModels}. When `ok` is `false`, * `models` is empty and `error` describes the failure. The `source` field indicates * whether the list came from a live API call or the offline static catalog. * * @docLink packages/bridge/api-reference#models */ export interface FetchModelsResult { /** `true` when the fetch succeeded and `models` is populated. */ ok: boolean; /** Fetched model list; empty on failure. */ models: ModelEntry[]; /** Human-readable error description when `ok` is `false`. */ error?: string; /** Whether the result came from a live API call or the static fallback. */ source: "api" | "static"; } /** * Options controlling where a model-list fetch is addressed. * * @since 1.5.0 */ export interface FetchModelsOptions { /** * Base URL to resolve the provider's models endpoint against — e.g. the * gateway a session already routes completions through. Overrides the * provider's `baseUrlEnv` value. */ baseUrl?: string; /** * Environment consulted for the provider's base-URL env var * (`ANTHROPIC_BASE_URL` for `anthropic`). Defaults to `process.env`; pass an * explicit record to keep a call hermetic. */ env?: Record; } /** * Fetch the model list from a provider's REST API. * * Returns `{ ok: true, models, source: 'api' }` on success, or * `{ ok: false, models: [], error }` on any HTTP or network failure — the * caller should fall back to {@link getStaticModels} in that case. * * When the provider is reachable through a gateway, the request targets the * configured base URL rather than the provider's public API — see * {@link resolveProviderModelsUrl}. Without one, behaviour is unchanged. * * @param provider - Provider name matching a key in the shared `PROVIDER_ENDPOINTS` map * (e.g. `"anthropic"`, `"openai"`, `"google"`). * @param apiKey - API key forwarded in the request header or query parameter. * @param options - Optional base-URL / environment overrides. * @returns Resolved model list with source attribution. * @docLink packages/bridge/api-reference#models */ export declare function fetchProviderModels(provider: string, apiKey: string, options?: FetchModelsOptions): Promise; /** * Get models for a provider, trying the live API first and falling back to the static catalog. * * When no `apiKey` is provided the static catalog is returned immediately without * a network call. When the live API fails or returns an empty list, the static * catalog is used as a fallback — the result's `source` field indicates which was used. * * @param provider - Provider name (e.g. `"anthropic"`, `"openai"`, `"google"`). * @param apiKey - Optional API key; omit to skip the live fetch and use the static catalog. * @param options - Optional base-URL / environment overrides (see {@link FetchModelsOptions}). * @returns Resolved model list with source attribution. * @docLink packages/bridge/api-reference#models */ export declare function getModels(provider: string, apiKey?: string, options?: FetchModelsOptions): Promise; /** * Offline model catalog keyed by provider name. * * Used as a fallback by {@link getModels} when the live provider API is unreachable or * returns an empty list. Covers Anthropic, OpenAI, Google, Mistral, Groq, DeepSeek, * xAI, Together, Fireworks, and OpenRouter. Update this list when providers add new * models and a live fetch is not available. * * @docLink packages/bridge/api-reference#models */ export declare const STATIC_MODELS: Record; /** * Get models for a specific provider from the static catalog, or empty array if unknown. * * Pure synchronous lookup — no network call. Use when the provider API is unavailable * or when a fast offline fallback is needed (e.g. in the UI before credentials are configured). * * @param provider - Provider name matching a key in {@link STATIC_MODELS}. * @returns Offline model list, or `[]` for unknown providers. * @docLink packages/bridge/api-reference#models */ export declare function getStaticModels(provider: string): ModelEntry[]; /** Per-tier concrete model ids for one provider. */ export interface ModelTierOverrides { small?: string; default?: string; deep?: string; } /** * Built-in tier→model mapping per provider. This is the point of the closed * `small | default | deep` vocabulary: an authored flow names an intent and the * runtime owns which concrete model serves it, so flows stay portable across * model-lineup changes. * * These are **direct provider-API ids**. A gateway transport (Bedrock, Vertex, * Azure) addresses the same models by different ids — Bedrock prefixes * `us.anthropic.`, for instance — and that translation belongs to whoever owns * the deployment, not here. {@link resolveModelTier} therefore consults this * table only on the direct API and demands an explicit override otherwise, * rather than handing a gateway an id it cannot serve. * * Every id here must also appear in {@link STATIC_MODELS} — a test asserts it, * so the two cannot drift into naming a model the catalog disowns. That check * proves internal consistency only; it cannot tell you an id is still current * with a provider's live lineup. * * Where a provider's lineup has no genuinely distinct model for a tier, the * entry deliberately repeats the neighbouring one. That is a reviewable * property of that lineup, unlike inheriting whatever model the session * happened to start with — which is how `small` could silently mean Opus. */ export declare const PROVIDER_MODEL_TIERS: Record>; /** Raised when a tier names an intent this provider cannot serve. */ export declare class ModelTierResolutionError extends Error { readonly tier: "small" | "deep"; readonly provider: string | undefined; constructor(tier: "small" | "deep", provider: string | undefined); } /** * Resolve a Flow v2 `run.model` tier to a concrete model id. * * `"default"` and an absent tier **inherit `sessionModel` first**. The session * model is the one id known to work for this deployment — it already carries * whatever provider, lineup and gateway translation the host configured — so * preferring a built-in over it would silently downgrade a configured model * and, on a gateway transport, substitute an id that provider cannot serve. * * `"small"` and `"deep"` never fall back to `sessionModel`: they resolve from * an override, then from {@link PROVIDER_MODEL_TIERS} on the direct provider * API, and otherwise throw {@link ModelTierResolutionError}. Inheriting there * would run an arbitrary model behind an author's explicit request for a cheap * or a strong one — a cost or quality surprise that shows up only in the bill * or the output. Failing names it at the node instead. * * Pure: no I/O, no environment reads. */ export declare function resolveModelTier(tier: "small" | "default" | "deep" | undefined, sessionModel: string | undefined, options?: { provider?: string; cloud?: string; overrides?: ModelTierOverrides; }): string | undefined; //# sourceMappingURL=models.d.ts.map