/** * auto-register.ts * * Automatically registers providers when their API keys are detected in the environment. * * When a user has an API key set in their environment (e.g. GROQ_API_KEY), * auto-register that provider using catalog data, zero manual configuration. * * Multi-endpoint providers (e.g. ZenMux) are handled by registering separate * provider instances for each endpoint, routed by the model's native API format. */ import type { LLMProvider } from './interface.js'; import type { ProviderRegistry } from './registry.js'; import type { CatalogProvider } from './model-catalog.js'; /** API wire format used by a provider endpoint. */ export type ApiFormat = 'openai' | 'anthropic'; /** * Extended provider descriptor used internally for auto-registration. * Extends CatalogProvider with routing metadata. */ export interface AutoRegisterEntry extends CatalogProvider { /** * Wire format used by this endpoint. * Defaults to 'openai' (OpenAI-compatible). */ apiFormat?: ApiFormat | undefined; /** * Default model ID sent when no model is specified in a request. * Auto-register uses the first entry from the catalog where available; * falls back to this value. */ defaultModel: string; /** * Model IDs pre-seeded for this provider. * Auto-registered providers start with an empty list; these seeds allow the * provider to be usable immediately without waiting for a catalog fetch. */ seedModels?: string[] | undefined; } /** * Well-known providers that can be auto-registered from environment variables. * * Each entry maps to one registered LLM provider instance. Multi-endpoint * providers (e.g. ZenMux) appear multiple times, once per endpoint, with * distinct `id` and `name` values (e.g. 'zenmux' and 'zenmux-anthropic'). * * Order determines registration priority when multiple providers offer the * same model. Earlier entries take precedence in the auto-registration log. */ export declare const AUTO_REGISTER_CATALOG: AutoRegisterEntry[]; /** * Check whether a provider ID is already registered in the provider registry. */ export declare function isProviderRegistered(providerRegistry: Pick, providerId: string): boolean; /** * Resolve the API key to use for a provider entry. * Returns the first non-empty env var value, or empty string. */ export declare function resolveApiKey(entry: AutoRegisterEntry): string; /** * Create an LLMProvider instance from an AutoRegisterEntry. * Routes to the correct provider class based on apiFormat. */ export declare function createProviderFromEntry(entry: AutoRegisterEntry, apiKey: string): LLMProvider; /** * autoRegisterProviders, scan catalog providers, check env vars, register * any providers not already in the registry. * * Called during startup after `initCatalog()`. Safe to call multiple times; * already-registered providers are skipped. * * @param catalog - Optional override for the provider catalog entries. * Defaults to AUTO_REGISTER_CATALOG. Pass a custom list in tests. * @returns Array of display names that were newly registered. * * @example * // Startup sequence: * // const names = autoRegisterProviders(); * // if (names.length > 0) { * // conversation.addSystemMessage(`Auto-registered ${names.length} providers: ${names.join(', ')}`); * // } */ export declare function autoRegisterProviders(providerRegistry: Pick, catalog?: AutoRegisterEntry[]): string[]; //# sourceMappingURL=auto-register.d.ts.map