import type { StreamConfig, ProviderType, CoreModelType } from "./config.js";
import type { StreamSession } from "./session.js";
import type { ProviderInfo } from "./types.js";
export interface FallbackAttempt {
    provider: ProviderType;
    model: CoreModelType;
}
export interface RetryDecision {
    shouldRetry: boolean;
    delayMs: number;
    newProvider?: ProviderInfo;
    reason?: "non-retryable" | "max-attempts" | "max-time" | "aborted" | "auth_error" | "not_found" | "rate_limit" | "api_error";
}
/**
 * Engine for making retry and fallback decisions.
 *
 * @example
 * ```typescript
 * const engine = new RetryEngine(config);
 *
 * // Check if we should retry
 * const decision = engine.getRetryDecision(error, session);
 *
 * if (decision.shouldRetry) {
 *   // Update provider if fallback
 *   if (decision.newProvider) {
 *     session.provider = decision.newProvider;
 *   }
 *   // Wait and retry
 *   await sleep(decision.delayMs);
 * } else {
 *   // Give up
 *   throw error;
 * }
 * ```
 */
export declare class RetryEngine {
    private readonly config;
    private readonly fallbackChain;
    private fallbackIndex;
    constructor(config: StreamConfig);
    private getMaxAttemptsForProvider;
    getRetryDecision(error: unknown, session: StreamSession, abortSignal?: AbortSignal): RetryDecision;
    getInitialProvider(): ProviderInfo;
    resetFallback(): void;
    isRetryable(error: unknown): boolean;
    /**
     * Check if error is an AI_RetryError (wrapper error from AI SDK retry logic).
     */
    private isRetryErrorLike;
    private calculateDelay;
    private advanceFallback;
    /**
     * Build the fallback chain based on initial provider/model and strategy.
     *
     * The chain always starts with the initial provider/model from the config.
     * Strategy controls the fallback order:
     *
     * With retry (4+ entries):
     * - "model-then-provider": initial → initial+model2 → fallback providers+initial → fallback providers+model2
     * - "provider-then-model": initial → fallback providers+initial → initial+model2 → fallback providers+model2
     *
     * Without retry (3+ entries):
     * - "model-then-provider-no-retry": initial → initial+model2 → fallback providers+model2
     * - "provider-then-model-no-retry": initial → fallback providers+initial → fallback providers+model2
     *
     * Limited (2+ entries):
     * - "only-model": initial → initial+model2
     * - "only-provider": initial → fallback providers+initial
     *
     * No fallback (1 entry):
     * - "disabled": initial only
     */
    private buildFallbackChain;
}
//# sourceMappingURL=retry-engine.d.ts.map