/** * [WHO]: discoverModels(), discoverOpenAIModels(), getDiscoveryProtocol(), DiscoveredModel, DiscoveryResult * [FROM]: Depends on @catui/ai/types for Api type * [TO]: Consumed by core/model-registry.ts, core/model/discovery-cache.ts * [HERE]: core/model/discovery.ts - remote model discovery engine * * Fetches model lists from provider /models endpoints (OpenAI-compatible protocol). * All failures are graceful — returns empty results instead of throwing. */ /** * A model discovered from a remote /models endpoint. */ export interface DiscoveredModel { /** Model identifier (same format as used in API requests). */ id: string; /** Human-readable display name, if provided by the endpoint. */ name?: string; /** Organization or entity that owns the model. */ ownedBy?: string; } /** * Result of a discovery operation for a single provider. */ export interface DiscoveryResult { /** Provider name this result belongs to. */ provider: string; /** Discovered models (may be empty on failure or unsupported protocol). */ models: DiscoveredModel[]; /** Epoch milliseconds when this result was fetched. */ fetchedAt: number; /** Cache time-to-live in seconds. */ ttl: number; /** Non-fatal error message (e.g., "unsupported protocol" or network error details). */ error?: string; } /** * Discovery protocol supported by a provider's API type. * - "openai-models": GET {baseUrl}/models (OpenAI-compatible standard) * - "unsupported": API type does not expose a model listing endpoint */ export type DiscoveryProtocol = "openai-models" | "unsupported"; /** Default cache TTL: 24 hours. */ export declare const DEFAULT_DISCOVERY_TTL_SECONDS = 86400; /** Default fetch timeout: 5 seconds. */ export declare const DEFAULT_DISCOVERY_TIMEOUT_MS = 5000; /** * Determine which discovery protocol a provider supports based on its API type. * * OpenAI-compatible APIs (completions, responses) implement the standard * `GET /v1/models` endpoint. Anthropic Messages API does not expose one. */ export declare function getDiscoveryProtocol(api: string): DiscoveryProtocol; /** * Fetch model list from an OpenAI-compatible /models endpoint. * * Expects response format: `{ data: [{ id: string, name?: string, owned_by?: string }, ...] }` * * Returns empty array on any failure: * - Network errors / timeouts * - Non-200 HTTP responses (401, 403, 500, etc.) * - Malformed response bodies * * @param baseUrl Provider base URL (trailing slashes are stripped) * @param apiKey Optional API key for Authorization header * @param options Optional timeout and abort signal */ export declare function discoverOpenAIModels(baseUrl: string, apiKey: string | undefined, options?: { timeoutMs?: number; signal?: AbortSignal; }): Promise; /** * Top-level discover function: routes to the correct protocol handler. * * Returns a DiscoveryResult with metadata (timestamps, TTL, error info). * Never throws — all errors are captured in the result. */ export declare function discoverModels(providerName: string, baseUrl: string, api: string, apiKey: string | undefined, options?: { timeoutMs?: number; }): Promise;