/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 *
 * @plan PLAN-20251213issue490
 * Implementation of BucketFailoverHandler for CLI package
 *
 * This class wraps OAuthManager to provide bucket failover capabilities
 * during API calls when rate limits or quota errors are encountered.
 */
import { BucketFailoverHandler, type FailoverContext, type BucketFailureReason } from '@vybestack/llxprt-code-core';
import type { OAuthManager } from './oauth-manager.js';
/**
 * CLI implementation of BucketFailoverHandler
 *
 * Uses OAuthManager to:
 * - Track available buckets from profile configuration
 * - Switch between buckets on failover
 * - Refresh OAuth tokens when switching buckets
 */
export declare class BucketFailoverHandlerImpl implements BucketFailoverHandler {
    private buckets;
    private currentBucketIndex;
    private readonly provider;
    private readonly oauthManager;
    private triedBucketsThisSession;
    /**
     * @plan PLAN-20260223-ISSUE1598.P05
     * @requirement REQ-1598-IC09
     * Record of failure reasons for buckets evaluated during last failover attempt
     */
    private lastFailoverReasons;
    constructor(buckets: string[], provider: string, oauthManager: OAuthManager);
    /**
     * Get the list of available buckets
     */
    getBuckets(): string[];
    /**
     * Get the currently active bucket
     */
    getCurrentBucket(): string | undefined;
    /**
     * Try to failover to the next bucket
     *
     * @plan PLAN-20260223-ISSUE1598.P05
     * @requirement REQ-1598-FL01, CL01, CL02, CL03, CL04, CL07, CL09, FL12
     * @pseudocode failover-handler.md lines 1-58
     *
     * This method implements the three-pass failover algorithm:
     * Pass 1: Classify the triggering bucket based on context and token state
     * Pass 2: Find next candidate with valid/refreshable token
     * Pass 3: Attempt foreground reauth for expired/missing tokens
     */
    tryFailover(context?: FailoverContext): Promise<boolean>;
    /**
     * Check if bucket failover is enabled
     * Returns true if there are multiple buckets configured
     */
    isEnabled(): boolean;
    /**
     * @fix issue1616
     * Eagerly authenticate all unauthenticated buckets at turn boundaries.
     * Delegates to OAuthManager.authenticateMultipleBuckets which respects
     * auth-bucket-prompt/delay ephemerals and skips already-authenticated buckets.
     * No-op for single-bucket profiles (no failover needed).
     */
    ensureBucketsAuthenticated(): Promise<void>;
    /**
     * Reset the session tracking so failover can try buckets again in a new request.
     * Call this at the start of each new request to prevent infinite cycling.
     */
    resetSession(): void;
    /**
     * Reset to the first bucket (useful for new sessions)
     */
    reset(): void;
    /**
     * @plan PLAN-20260223-ISSUE1598.P05
     * @requirement REQ-1598-IC09
     * Get the failure reasons for buckets that were skipped during last failover
     * Returns a shallow copy to prevent external mutation
     */
    getLastFailoverReasons(): Record<string, BucketFailureReason>;
}
