/** * OpenKernel — Provider Manager * * Tracks available models, quota, latency, health, capabilities. * Tracks 429s, quota remaining, per-request success rate. * Background refresh only. Never blocks execution. */ import type { ProviderInfo, ProviderInterface, ProviderModel } from './types.js'; import type { EventBus } from './event-bus.js'; import type { Logger } from './types.js'; /** How long a provider is excluded from routing after each failure class. */ export declare const COOLDOWN_MS: Record; export declare class ProviderManager { private eventBus; private logger; private providers; private healthTimers; private refreshIntervalMs; private stats; constructor(eventBus: EventBus, logger: Logger); register(providerId: string, provider: ProviderInterface): void; unregister(providerId: string): void; get(providerId: string): ProviderInterface | undefined; list(): ProviderInterface[]; listInfos(): ProviderInfo[]; getAvailableModels(): Promise; getHealthyProviders(): Promise; /** Is this provider currently parked on a recovery cooldown? */ isCoolingDown(info: ProviderInfo): boolean; /** * Park a provider out of routing for a window (out of credits, bad key, rate * limited, down). The health check will NOT resurrect it until the cooldown * expires — this is what stops a broke provider (whose /models still answers) * from being re-picked on every task. */ markCooldown(providerId: string, ms: number, reason: string): void; /** Apply the standard cooldown for a classified failure. Returns the ms used. */ penalize(providerId: string, failureType: string, reason?: string): number; /** Record a successful completion for success-rate + quota tracking. */ recordSuccess(providerId: string): void; /** Record a failed completion (non-429) for success-rate tracking. */ recordFailure(providerId: string): void; /** Record a 429 / rate-limit hit — decrements quota and may mark unhealthy. */ record429(providerId: string): void; private pushQuota; private estimateQuota; private scheduleHealthCheck; checkHealth(providerId: string): Promise; setRefreshInterval(ms: number): void; destroy(): void; }