import type { LLMProvider } from '../providers/types.js'; import type { LLMResponse, Logger } from '../llm_api/types.js'; import type { CascadeConfig } from './types.js'; import type { UsageAttempt } from '../pricing/types.js'; export interface CascadeRunOptions { /** Resolved provider instances to try in order */ providers: LLMProvider[]; /** Bound call function (params already captured by closure) */ call_fn: (provider: LLMProvider) => Promise; /** Error codes that allow cascade to next provider */ cascade_on_codes?: string[]; /** Per-attempt timeout in milliseconds (no timeout if absent) */ timeout_ms_per_attempt?: number; /** Logger */ logger: Logger; } export interface CascadeRunResult { response: LLMResponse; /** * Failed attempts before the final result. Empty array when the first * provider succeeded (no cascade fired). */ attempts: UsageAttempt[]; } export interface ResolveProvidersOptions { per_call?: string[]; init_cascade?: CascadeConfig; single_llm?: string; primary_llm: string; } /** * Determine the ordered list of provider names to use. * Precedence: per-call providers > init cascade providers > single_llm arg > primary_llm. * An empty per_call array is treated as "not set" (falls through). */ export declare function resolve_providers(opts: ResolveProvidersOptions): string[]; /** * Try each provider in order, returning the first successful response. * * Rules: * - Success on first try → `attempts` is empty (no cascade record). * - Cascadable error (RATE_LIMITED, NETWORK_ERROR, TIMEOUT, API_ERROR by default) → * record attempt, try next provider. * - Non-cascadable error (config errors: PROVIDER_NOT_FOUND, API_KEY_MISSING, etc.) → * return immediately without trying more providers. * - Timeout → treated as TIMEOUT error code, always cascadable. * - All providers exhausted → return last error with all attempts recorded. */ export declare function run_with_cascade(opts: CascadeRunOptions): Promise; //# sourceMappingURL=cascade_runner.d.ts.map