/** * fallbackProvider — convenience for chained fallbacks across N providers. * * Pattern: Chain of Responsibility (GoF) over `LLMProvider` instances. * Role: Outer ring (Hexagonal). Sugar over repeated `withFallback`. * * `fallbackProvider(p1, p2, p3)` is equivalent to * `withFallback(p1, withFallback(p2, p3))` — tries each provider in * order, advancing on errors that match the (optional) shouldFallback * predicate. The first success wins; if all fail, the last error throws. * * @example * import { anthropic, openai, mock } from 'agentfootprint/llm-providers'; * import { fallbackProvider } from 'agentfootprint/resilience'; * * const provider = fallbackProvider( * anthropic({ apiKey: A }), * openai({ apiKey: O }), * mock({ reply: '[degraded] all upstream providers failed' }), * ); */ import type { LLMProvider } from '../adapters/types.js'; import { type WithFallbackOptions } from './withFallback.js'; export interface FallbackProviderOptions extends WithFallbackOptions { /** Optional explicit name for the chained provider. */ readonly name?: string; } /** * Compose N providers into a single fallback chain. At least one * provider is required; throws synchronously on empty input. */ export declare function fallbackProvider(...providers: readonly LLMProvider[]): LLMProvider; export declare function fallbackProvider(options: FallbackProviderOptions, ...providers: readonly LLMProvider[]): LLMProvider; //# sourceMappingURL=fallbackProvider.d.ts.map