/** * FallbackProfileManager — centralized, decoupled fallback profile resolution. * * Every consumer (fallback-model, council orchestrator, one-shot LLM, plugins) * resolves its fallback chain through this single manager instead of parsing * config.fallbackProfiles independently. This guarantees consistent resolution, * provider-health filtering, and a single reload point on config changes. * * Design: * - Stable service identity: `reload()` atomically replaces the manager's * immutable config/profile snapshot so injected consumers stay live. * - Immutable outputs: every resolved chain is frozen. * - Provider-aware: each profile entry is checked against live provider config * (has API key?) before inclusion. * - Zero coupling: consumers only see `readonly FallbackChainEntry[]` — * no awareness of profile names, config shape, or provider internals. */ import type { ProviderModelStatusTracker } from '../coordination/provider-status-tracker.js'; import type { Config } from '../types/config.js'; /** One resolved entry in a fallback chain. */ export interface FallbackChainEntry { /** Resolved provider id. */ readonly providerId: string; /** Resolved model id. */ readonly model: string; /** Whether this entry uses a different provider than the primary. */ readonly providerSwitched: boolean; } /** Immutable fallback chain returned by the manager. */ export type FallbackChain = readonly FallbackChainEntry[]; /** * Configuration-level provider health used while resolving fallback chains. * * This deliberately answers whether the runtime has enough configuration to * construct the provider; it does not perform a network probe. Keyless * self-hosted endpoints are usable when they declare a `baseUrl`. */ export interface ProviderHealth { readonly providerId: string; readonly hasKey: boolean; readonly hasEndpoint: boolean; readonly hasModels: boolean; readonly usable: boolean; } export declare class FallbackProfileManager { /** Immutable snapshot of config.fallbackProfiles for the active config. */ private profiles; /** Active frozen config snapshot for provider lookups. */ private config; /** Optional shared runtime status tracker. */ private statusTracker; constructor(config: Config, opts?: { statusTracker?: ProviderModelStatusTracker | undefined; }); /** * Bind (or replace) the shared runtime status tracker. * Called by the boot path after the tracker is created. */ setStatusTracker(tracker: ProviderModelStatusTracker | undefined): void; hasProfile(name: string): boolean; listProfiles(): readonly string[]; /** * Resolve a named fallback profile to a validated, provider-filtered chain. * * Returns an empty chain when: * - The profile doesn't exist. * - Every entry's provider is missing, has no key, or has no matching model. * * @param name - Profile name from config.fallbackProfiles. * @param defaultProvider - Used when an entry has no explicit provider. * @param exclude - Optional { providerId, model } to skip (avoid self-fallback). */ resolve(name: string, opts?: { defaultProvider?: string | undefined; exclude?: { providerId: string; model: string; } | undefined; }): FallbackChain; /** * Resolve the effective fallback chain for a session: explicit fallbackModels * first, then named profile, then smart default (unless disabled). * * Mirrors the previous `effectiveFallbackChain()` logic but centralized. */ resolveEffective(opts?: { fallbackModels?: readonly string[] | undefined; fallbackProfile?: string | undefined; fallbackAuto?: boolean | undefined; exclude?: { providerId: string; model: string; } | undefined; }): FallbackChain; checkProvider(providerId: string): ProviderHealth; /** * Atomically replace the active immutable snapshot while preserving this * service identity for every injected consumer. */ reload(newConfig: Config): void; /** * Resolve an array of model ref strings (from explicit fallbackModels config). * Public so consumers like one-shot-llm can use it directly. */ resolveRefs(refs: readonly string[], exclude?: { providerId: string; model: string; }): FallbackChain; /** * Derive a smart default chain from configured providers when nothing * explicit is set. Same-provider alternatives first, then cross-provider. * Limited to 4 entries to avoid burning through models on a transient blip. */ private smartDefault; } //# sourceMappingURL=fallback-profile-manager.d.ts.map