/**
 * Generation Handler Module
 *
 * Handles text generation execution, result formatting, and tool information extraction.
 * Extracted from BaseProvider to follow Single Responsibility Principle.
 *
 * Responsibilities:
 * - Generation execution with AI SDK
 * - Tool information extraction
 * - Result formatting and enhancement
 * - Response analysis and logging
 *
 * @module core/modules/GenerationHandler
 */
import type { AIProviderName, EnhancedGenerateResult, NeuroLinkEvents, StandardRecord, TextGenerationOptions, TypedEventEmitter } from "../../types/index.js";
import type { LanguageModel, ModelMessage, Tool } from "../../types/index.js";
import { generateText } from "../../utils/generation.js";
/**
 * Turn budget + wrap-up deadline (parity with the googleVertex native loops).
 * A deadline is engaged only when the caller expressed one: turnTimeoutMs
 * wins, else an explicit generate timeout. Callers that set neither keep the
 * pre-existing behaviour (no wrap-up; the outer defensive timeout in
 * executeStandardGenerateFlow still applies). With `wrapupTimeLeadMs` left of
 * the deadline, the loop stops offering tools (toolChoice: "none") so the
 * model spends the remaining budget producing a final answer instead of being
 * guillotined mid-tool-loop with all work discarded. The lead is clamped to a
 * quarter of the budget so short explicit timeouts (e.g. 30s) don't trigger
 * wrap-up on the very first step.
 *
 * `turnStartMs` anchors the deadline to the ORIGINAL generation start:
 * callGenerateText re-runs on executeGeneration's fallback retries
 * (structured-output conflict, temperature-deprecated) and provider retries,
 * and a deadline computed from Date.now() per attempt would hand each retry
 * a fresh budget — multiplying the caller's wall-clock cap.
 */
export declare function resolveTurnBudget(options: TextGenerationOptions, turnStartMs: number): {
    callerTimeoutMs: number | undefined;
    turnBudgetMs: number | undefined;
    wrapupLeadMs: number;
    turnDeadline: number | undefined;
};
/**
 * GenerationHandler class - Handles text generation operations for AI providers
 */
export declare class GenerationHandler {
    private readonly providerName;
    private readonly modelName;
    private readonly supportsToolsFn;
    private readonly getTelemetryConfigFn;
    private readonly handleToolStorageFn;
    private readonly getEmitterFn?;
    constructor(providerName: AIProviderName, modelName: string, supportsToolsFn: () => boolean, getTelemetryConfigFn: (options: TextGenerationOptions, type: string) => {
        isEnabled: boolean;
        functionId?: string;
        metadata?: Record<string, string | number | boolean>;
    } | undefined, handleToolStorageFn: (toolCalls: unknown[], toolResults: unknown[], options: TextGenerationOptions, timestamp: Date) => Promise<void>, getEmitterFn?: (() => TypedEventEmitter<NeuroLinkEvents> | undefined) | undefined);
    /**
     * Helper method to call generateText with optional structured output
     * @private
     */
    private callGenerateText;
    /**
     * Execute the generation with AI SDK
     */
    executeGeneration(model: LanguageModel, messages: ModelMessage[], tools: Record<string, Tool>, options: TextGenerationOptions): Promise<Awaited<ReturnType<typeof generateText>>>;
    /**
     * Extract cache metrics from provider metadata (e.g. Anthropic's providerMetadata.anthropic)
     * The AI SDK's LanguageModelUsage only has inputTokens/outputTokens.
     * Cache metrics are surfaced via providerMetadata by provider-specific SDK adapters.
     */
    private extractCacheMetricsFromProviderMetadata;
    /**
     * Log generation completion information
     */
    logGenerationComplete(generateResult: Awaited<ReturnType<typeof generateText>>): void;
    /**
     * Extract tool information from generation result
     */
    extractToolInformation(generateResult: Awaited<ReturnType<typeof generateText>>): {
        toolsUsed: string[];
        toolExecutions: Array<{
            name: string;
            input: StandardRecord;
            output: unknown;
        }>;
    };
    /**
     * Format the enhanced result
     */
    formatEnhancedResult(generateResult: Awaited<ReturnType<typeof generateText>>, tools: Record<string, Tool>, toolsUsed: string[], toolExecutions: Array<{
        name: string;
        input: StandardRecord;
        output: unknown;
    }>, options: TextGenerationOptions): EnhancedGenerateResult;
    /**
     * Analyze AI response structure and log detailed debugging information
     */
    analyzeAIResponse(result: Record<string, unknown>): void;
}
