/** * Cross-provider failover: the reusable core of Elyra's "AI sovereignty" * behavior. When a turn fails because a provider is unavailable (overloaded, * rate-limited, an auth problem, or a model that vanished — e.g. an * export-control suspension), we can re-run the turn on an equivalent model * from a *different* provider instead of just surfacing the error. * * This is only possible because Elyra is provider-agnostic. A single-vendor * agent has nowhere to fail over to. * * Both functions here are pure so they can be unit-tested without real * providers, and reused by cross-provider consensus (#1) and per-repo model * shopping (#4), which need the same equivalence notion. */ /** Minimal model shape the fallback selector needs (Model satisfies it). */ export interface FallbackModelInfo { provider: string; id: string; reasoning: boolean; input: readonly string[]; cost: { output: number; }; contextWindow: number; } export type FailureClass = "failover" | "fatal"; /** Stable key for de-duping tried models across failover attempts. */ export declare function modelKey(m: { provider: string; id: string; }): string; /** * Decide whether a failed turn should be retried on a different provider. * * Conservative on the fatal side: an unrecognized error with no transient * signal is treated as fatal (surfaced as today) rather than burning a * failover attempt on what is probably a real bug or malformed request. */ export declare function classifyProviderFailure(error: unknown): FailureClass; /** Coarse capability band by output cost ($/million tokens). */ export declare function costBand(outputCost: number): 0 | 1 | 2; /** * Minimal reliability measurements the fallback selector can consume * (structurally satisfied by routing-ledger's ModelOutcomeStats). */ export interface ModelReliabilityStats { turns: number; successRate: number; failoversFrom: number; } /** * Pick an equivalent model to fail over to, or null when none is suitable. * * Ranking, best first: * 1. A different provider (the whole point — route around the outage). * 2. Measured reliability (when a local routing ledger is supplied): * models that demonstrably failed here are demoted, with a sample-size * floor so thin data never changes the ranking. * 3. Same capability band as the current model (don't silently downgrade * a powerful turn to a fast model, or overpay by jumping up a band). * 4. Reasoning capability matching the current model. * 5. Closest output cost. * 6. Larger context window as a final tiebreak. * * Image conversations only ever fall over to vision-capable models, so a * multimodal session can never break. */ export declare function selectFallbackModel(current: FallbackModelInfo, available: readonly T[], alreadyTried?: ReadonlySet, stats?: ReadonlyMap): T | null; //# sourceMappingURL=model-fallback.d.ts.map