/** * Zoe Core — Provider Configuration Types & Mutation * * Types, singleton management, config mutation functions, and file-based resolution. * Extracted from provider-resolver.ts for single-responsibility. */ import { type ProviderConfig } from "../providers/factory.js"; import type { LLMProvider } from "../providers/types.js"; import type { MultiProviderConfig, ProviderType } from "./types.js"; import { type AppConfig } from "./config.js"; export type { AppConfig }; /** * Resolved provider configuration with all required fields. * This is what consumers receive after resolution. */ export interface ResolvedProviderConfig { type: ProviderType; apiKey: string; model: string; baseUrl?: string; timeout?: number; } /** * Creates a single provider configuration object. * Useful for building `MultiProviderConfig` declaratively. */ export declare function provider(type: ProviderType, apiKey: string, options?: { model?: string; baseUrl?: string; timeout?: number; }): { type: ProviderType; apiKey: string; model?: string; baseUrl?: string; timeout?: number; }; /** * Stores multi-provider configuration globally. * Can be called once at application startup. */ export declare function configureProviders(config: MultiProviderConfig): void; /** * Returns the raw configuration for a given provider type. * Falls back to environment variables when no explicit config is set. * * @param type - Provider type. If omitted, uses the default provider. * @returns Resolved provider configuration with apiKey, model, and optional baseUrl. * @throws Error if the provider is not configured and no env var is available. */ export declare function getProviderConfig(type?: ProviderType): { apiKey: string; model: string; baseUrl?: string; type: ProviderType; }; /** * Resolves which provider type is the default. * Checks explicit config, then LLM_PROVIDER env var, then falls back to "openai". */ export declare function getDefaultProviderType(): ProviderType; /** * Returns the default configured provider type (alias for getDefaultProviderType). */ export declare function getDefaultProvider(): ProviderType; /** * Creates and returns an LLMProvider instance using the existing factory. * If type is omitted, uses the default provider. * * @param type - Provider type. If omitted, uses the default provider. * @param modelOverride - When set, overrides the resolved model before creating the provider. * @returns The initialized LLMProvider and the resolved model name. */ export declare function getProvider(type?: ProviderType, modelOverride?: string): Promise<{ provider: LLMProvider; model: string; }>; /** * Resolves provider configuration from legacy AppConfig (CLI format). * This handles both old-style top-level config and new models map format. */ export declare function resolveProviderConfigFromApp(config: AppConfig, providerType: ProviderType): ProviderConfig | null; /** * Load CLI-style config (~/.zoe/setting.json + .zoe/setting.json + env * overrides) and translate it to a MultiProviderConfig suitable for * `configureProviders()`. * * When `app` is provided, uses that config directly (callers that have already * loaded and mutated their AppConfig should pass it here). Otherwise reads * fresh from disk via `loadMergedConfig()` + `applyEnvOverrides()`. * * @returns MultiProviderConfig if any provider has a configured apiKey, null otherwise. * Callers should check for null before passing to configureProviders(). */ export declare function loadProviderConfig(app?: AppConfig, cliProvider?: string): MultiProviderConfig | null; /** * Resolves provider configuration from a config file object. * Supports both legacy AppConfig format and new MultiProviderConfig format. */ export declare function resolveFromConfigFile(config: any, type?: ProviderType): ResolvedProviderConfig | null; /** * Migrates legacy top-level config to the new models map format. */ export declare function migrateLegacyConfig(config: any): MultiProviderConfig; /** * Adds or updates a provider configuration. * Modifies the global providerConfig singleton. */ export declare function addProvider(type: ProviderType, config: { apiKey: string; model?: string; baseUrl?: string; }): void; /** * Updates an existing provider configuration. * Only updates the specified fields, preserving others. */ export declare function updateProviderConfig(type: ProviderType, updates: Partial<{ model: string; baseUrl: string; }>): void; /** * Removes a provider configuration. */ export declare function removeProvider(type: ProviderType): void; /** * Saves the current provider configuration to a file. */ export declare function saveConfig(configPath?: string): Promise;