import type { AIProviderConfig } from "../../types/ai"; export type ResilienceConfig = { /** Max retry attempts AFTER the first try (so total tries = maxRetries + 1). */ maxRetries: number; baseDelayMs: number; maxDelayMs: number; /** Consecutive failed requests before the circuit opens. */ failureThreshold: number; /** How long the circuit stays open before allowing a half-open probe. */ openMs: number; }; /** Override the global resilience defaults (retry counts, breaker thresholds). */ export declare const configureProviderResilience: (partial: Partial) => void; type CircuitState = "closed" | "open" | "half-open"; type ExternalStatus = { available: boolean; /** Statuspage indicator, e.g. "major_outage" | "operational" | "unknown". */ indicator: string; reason: string; checkedAt: number; }; /** * Feed externally-observed provider availability (typically from a status-page * monitor) into the breaker. A report of `available: false` makes the provider * fail fast immediately; `available: true` clears the external block (the * reactive breaker still governs real failures). */ export declare const setProviderAvailability: (provider: string, status: { available: boolean; indicator?: string; reason?: string; }) => void; export type ProviderHealth = { provider: string; /** * True when the provider is usable: circuit closed AND not reported down by * an external status monitor. */ healthy: boolean; state: CircuitState; consecutiveFailures: number; lastFailureAt: number | null; lastSuccessAt: number | null; /** When the breaker will next allow a probe (epoch ms), if open. */ nextRetryAt: number | null; lastError: { status: number | null; type: string | null; message: string; } | null; statusPageUrl: string | null; /** Latest externally-observed status (e.g. status page), if any. */ external: ExternalStatus | null; }; /** * Inspect provider health as tracked by the circuit breaker. Pass a provider * name for one snapshot, or omit to get every provider seen this process. */ export declare function getProviderHealth(provider: string): ProviderHealth; export declare function getProviderHealth(): ProviderHealth[]; /** * Wrap a provider with retry + circuit-breaker behaviour. The returned config * has the same `stream(params) => AsyncIterable` shape. */ export declare const withResilience: (provider: AIProviderConfig, providerName?: string) => AIProviderConfig; export {};