/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { type GenerateContentConfig, type PartListUnion, type Content, GenerateContentResponse, type SendMessageParameters } from '@google/genai';
import { Turn, type ServerGeminiStreamEvent } from './turn.js';
import type { ChatCompressionInfo } from './turn.js';
import { Config } from '../config/config.js';
import { UserTierId } from '../code_assist/types.js';
import { GeminiChat } from './geminiChat.js';
import { HistoryService } from '../services/history/HistoryService.js';
import { type ContentGenerator, type ContentGeneratorConfig } from './contentGenerator.js';
import type { AgentRuntimeState } from '../runtime/AgentRuntimeState.js';
/**
 * Returns the index of the content after the fraction of the total characters in the history.
 *
 * Exported for testing purposes.
 */
export declare function findCompressSplitPoint(contents: Content[], fraction: number): number;
export declare class GeminiClient {
    private readonly config;
    private chat?;
    private contentGenerator?;
    private embeddingModel;
    private logger;
    private generateContentConfig;
    private sessionTurnCount;
    private readonly MAX_TURNS;
    private _pendingConfig?;
    private _previousHistory?;
    private _storedHistoryService?;
    private currentSequenceModel;
    private readonly loopDetector;
    private lastPromptId?;
    private readonly complexityAnalyzer;
    private readonly todoReminderService;
    private todoToolsAvailable;
    private lastComplexitySuggestionTime;
    private readonly complexitySuggestionCooldown;
    private lastSentIdeContext;
    private forceFullIdeContext;
    private lastTodoToolTurn?;
    private consecutiveComplexTurns;
    private lastComplexitySuggestionTurn?;
    private toolActivityCount;
    private toolCallReminderLevel;
    private lastTodoSnapshot?;
    /**
     * At any point in this conversation, was compression triggered without
     * being forced and did it fail?
     */
    private hasFailedCompressionAttempt;
    /**
     * Runtime state for stateless operation (Phase 5)
     * @plan PLAN-20251027-STATELESS5.P10
     * @requirement REQ-STAT5-003.1
     * @pseudocode gemini-runtime.md lines 21-42
     */
    private readonly runtimeState;
    private _historyService?;
    private _unsubscribe?;
    /**
     * BaseLLMClient for stateless utility operations (generateJson, embeddings, etc.)
     * Lazily initialized when needed
     */
    private _baseLlmClient?;
    /**
     * @plan PLAN-20251027-STATELESS5.P10
     * @requirement REQ-STAT5-003.1
     * @pseudocode gemini-runtime.md lines 11-66
     *
     * Phase 5 constructor: Accept optional AgentRuntimeState and HistoryService
     * When provided, client operates in stateless mode using runtime state
     * Otherwise falls back to Config-based operation (backward compatibility)
     */
    constructor(config: Config, runtimeState: AgentRuntimeState, historyService?: HistoryService);
    dispose(): void;
    initialize(contentGeneratorConfig: ContentGeneratorConfig): Promise<void>;
    private lazyInitialize;
    getContentGenerator(): ContentGenerator;
    getUserTier(): UserTierId | undefined;
    /**
     * Get or create the BaseLLMClient for stateless utility operations.
     * This is lazily initialized to avoid creating it when not needed.
     */
    private getBaseLlmClient;
    private processComplexityAnalysis;
    private shouldEscalateReminder;
    private isTodoToolCall;
    private appendTodoSuffixToRequest;
    private recordModelActivity;
    private readTodoSnapshot;
    private getActiveTodos;
    private areTodoSnapshotsEqual;
    private getTodoReminderForCurrentState;
    private appendSystemReminderToRequest;
    private shouldDeferStreamEvent;
    private isTodoPauseResponse;
    addHistory(content: Content): Promise<void>;
    getChat(): GeminiChat;
    /**
     * Get the HistoryService from the current chat session
     * @returns The HistoryService instance, or null if chat is not initialized
     */
    getHistoryService(): HistoryService | null;
    hasChatInitialized(): boolean;
    isInitialized(): boolean;
    getHistory(): Promise<Content[]>;
    setHistory(history: Content[], { stripThoughts }?: {
        stripThoughts?: boolean;
    }): Promise<void>;
    /**
     * Store history for later use when the client is initialized.
     * This is used when resuming a chat before authentication.
     * The history will be restored when lazyInitialize() is called.
     */
    storeHistoryForLaterUse(history: Content[]): void;
    /**
     * Store HistoryService instance for reuse after refreshAuth.
     * This preserves the UI's conversation display across provider switches.
     */
    storeHistoryServiceForReuse(historyService: HistoryService): void;
    setTools(): Promise<void>;
    clearTools(): void;
    resetChat(): Promise<void>;
    getCurrentSequenceModel(): string | null;
    addDirectoryContext(): Promise<void>;
    generateDirectMessage(params: SendMessageParameters, promptId: string): Promise<GenerateContentResponse>;
    startChat(extraHistory?: Content[]): Promise<GeminiChat>;
    private getIdeContextParts;
    sendMessageStream(initialRequest: PartListUnion, signal: AbortSignal, prompt_id: string, turns?: number): AsyncGenerator<ServerGeminiStreamEvent, Turn>;
    generateJson(contents: Content[], schema: Record<string, unknown>, abortSignal: AbortSignal, model: string, config?: GenerateContentConfig): Promise<Record<string, unknown>>;
    generateContent(contents: Content[], generationConfig: GenerateContentConfig, abortSignal: AbortSignal, model: string): Promise<GenerateContentResponse>;
    generateEmbedding(texts: string[]): Promise<number[][]>;
    /**
     * Manually trigger chat compression
     * Returns compression info if successful, null if not needed
     */
    tryCompressChat(prompt_id: string, force?: boolean): Promise<ChatCompressionInfo>;
    private getToolGovernanceEphemerals;
    private readToolList;
    private buildToolDeclarationsFromView;
    private getEnabledToolNamesForPrompt;
    private updateTodoToolAvailabilityFromDeclarations;
}
