/** * @license * Copyright 2025 Vybestack LLC * SPDX-License-Identifier: Apache-2.0 * * @plan PLAN-20251213issue490 * Phase 7: Bucket Failover Integration * * Integrates bucket failover logic into GeminiChat provider execution flow */ import type { IContent, ContentBlock } from '../services/history/IContent.js'; import type { IProvider, GenerateChatOptions } from '../providers/IProvider.js'; /** * Configuration for bucket failover execution */ export interface BucketFailoverConfig { buckets: string[]; provider: IProvider; tokenRefreshCallback?: (bucket: string) => Promise; notificationCallback?: (fromBucket: string, toBucket: string) => void; } /** * Result from bucket failover execution including which bucket succeeded */ export interface BucketFailoverResult { content: IContent; bucket: string; attemptedBuckets: string[]; } /** * Wrapper for provider generateChatCompletion that handles bucket failover * * When multiple OAuth buckets are configured, this will automatically retry * failed requests (429/quota/402 errors) with the next available bucket. * * @param options - Chat generation options to pass to provider * @param config - Bucket failover configuration * @returns The final IContent response and which bucket succeeded * @throws Error if all buckets are exhausted */ export declare function executeProviderWithBucketFailover(options: GenerateChatOptions, config: BucketFailoverConfig): Promise; /** * Check if bucket failover should be enabled for the current configuration * * Bucket failover is enabled when: * 1. Profile has auth configuration * 2. Auth type is 'oauth' * 3. Multiple buckets are configured * * @param authConfig - The profile's auth configuration * @returns true if failover should be enabled */ export declare function shouldEnableBucketFailover(authConfig: { type: string; buckets?: string[]; } | undefined): boolean; /** * Aggregate text content from IContent blocks * Helper to extract text from provider responses */ export declare function aggregateTextFromBlocks(blocks: ContentBlock[]): string;