/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type { Content, GenerateContentConfig, GenerateContentResponse, PartListUnion } from '@google/genai'; import type { UserTierId } from '../code_assist/types.js'; import type { Config } from '../config/config.js'; import type { ContentGenerator, ContentGeneratorConfig } from './contentGenerator.js'; import { GeminiChat } from './geminiChat.js'; import type { ChatCompressionInfo, ServerGeminiStreamEvent } from './turn.js'; import { Turn } from './turn.js'; /** * Returns the index of the content after the fraction of the total characters in the history. * * Exported for testing purposes. */ export declare function findIndexAfterFraction(history: Content[], fraction: number): number; export declare class GeminiClient { private readonly config; private chat?; private contentGenerator?; private readonly embeddingModel; private readonly generateContentConfig; private sessionTurnCount; private readonly loopDetector; private lastPromptId; private lastSentIdeContext; private forceFullIdeContext; /** * At any point in this conversation, was compression triggered without * being forced and did it fail? */ private hasFailedCompressionAttempt; constructor(config: Config); initialize(contentGeneratorConfig: ContentGeneratorConfig, extraHistory?: Content[]): Promise; getContentGenerator(): ContentGenerator; getUserTier(): UserTierId | undefined; addHistory(content: Content): Promise; getChat(): GeminiChat; isInitialized(): boolean; getHistory(): Content[]; setHistory(history: Content[], { stripThoughts }?: { stripThoughts?: boolean; }): void; setTools(): Promise; resetChat(): Promise; /** * Reinitializes the chat with the current contentGeneratorConfig while preserving chat history. * This creates a new chat object using the existing history and updated configuration. * Should be called when configuration changes (model, auth, etc.) to ensure consistency. */ reinitialize(): Promise; addDirectoryContext(): Promise; startChat(extraHistory?: Content[], model?: string): Promise; private getIdeContextParts; sendMessageStream(request: PartListUnion, signal: AbortSignal, prompt_id: string, turns?: number, originalModel?: string): AsyncGenerator; generateJson(contents: Content[], schema: Record, abortSignal: AbortSignal, model?: string, config?: GenerateContentConfig): Promise>; generateContent(contents: Content[], generationConfig: GenerateContentConfig, abortSignal: AbortSignal, model?: string): Promise; generateEmbedding(texts: string[]): Promise; tryCompressChat(prompt_id: string, force?: boolean): Promise; /** * Handles falling back to Flash model when persistent 429 errors occur for OAuth users. * Uses a fallback handler if provided by the config; otherwise, returns null. */ private handleFlashFallback; /** * Handles Qwen OAuth authentication errors and rate limiting */ private handleQwenOAuthError; } export declare const TEST_ONLY: { COMPRESSION_PRESERVE_THRESHOLD: number; COMPRESSION_TOKEN_THRESHOLD: number; };