export interface ToolExecution {
    toolName: string;
    startTime: number;
    durationMs: number;
    inputChars: number;
    outputChars: number;
    success: boolean;
    error?: string;
}
export interface TurnInfo {
    turnNumber: number;
    timestamp: number;
}
export interface CacheMetrics {
    inputTokens: number;
    outputTokens: number;
    cacheCreationInputTokens: number;
    cacheReadInputTokens: number;
    totalCostUsd: number;
    /** Ratio of cache-read tokens to total input tokens (0-1). Higher = better prefix caching. */
    cacheHitRate: number;
}
/** Per-turn performance metrics collected from SDK stream. */
export interface TurnMetricsSummary {
    totalTurns: number;
    totalDurationMs: number;
    totalToolCalls: number;
    totalPayloadBytes: number;
    turns: Array<{
        turn: number;
        durationMs?: number;
        firstTokenMs?: number;
        tools: string[];
        payloadBytes: number;
        thinking: boolean;
        inputTokens?: number;
        outputTokens?: number;
        cacheReadTokens?: number;
        cacheCreationTokens?: number;
    }>;
}
export interface SessionMetrics {
    sessionId: string;
    startTime: number;
    endTime: number;
    totalDurationMs: number;
    turns: number;
    toolExecutions: ToolExecution[];
    toolSummary: {
        totalCalls: number;
        totalDurationMs: number;
        successCount: number;
        failureCount: number;
        byTool: Record<string, {
            calls: number;
            totalMs: number;
            avgMs: number;
            failures: number;
        }>;
    };
    /** SDK token usage and prompt cache metrics (recorded from result message). */
    cache?: CacheMetrics;
    /** Per-turn performance metrics for optimization analysis. */
    turnMetrics?: TurnMetricsSummary;
    /** Analysis mode the orchestrator ran in ('fast' quick path / 'full' pipeline / 'auto' classifier-driven). */
    analysisMode?: 'fast' | 'full' | 'auto';
    /** Origin of the complexity decision — explicit user choice, deterministic rule, or AI classifier. */
    classifierSource?: 'user_explicit' | 'hard_rule' | 'ai';
}
export declare class AgentMetricsCollector {
    private sessionId;
    private startTime;
    private toolExecutions;
    private turnCount;
    private cacheMetrics;
    private turnMetricsSummary;
    private analysisMode;
    private classifierSource;
    constructor(sessionId: string);
    /**
     * Wrap a tool handler function with timing instrumentation.
     * Returns a new function with the same signature that records execution metrics.
     */
    wrapToolHandler<TInput, TOutput>(toolName: string, handler: (input: TInput) => Promise<TOutput>): (input: TInput) => Promise<TOutput>;
    /**
     * Record a tool execution observed from the SDK stream.
     * Timing = time between tool_use (assistant message) and tool_use_result (user message).
     * Less precise than in-handler timing but requires no modification to tool definitions.
     */
    recordToolFromStream(toolName: string, durationMs: number, success: boolean): void;
    /** Record a turn completion from SDK stream processing. */
    recordTurn(): void;
    /**
     * Record SDK result usage metrics for prompt cache analysis.
     * Called once per analysis when the SDK result message arrives.
     */
    recordSdkUsage(result: {
        usage?: Record<string, number | null>;
        modelUsage?: Record<string, Record<string, number>>;
        total_cost_usd?: number;
    }): void;
    /** Record per-turn metrics collected from SDK stream processing. */
    recordTurnMetrics(summary: TurnMetricsSummary): void;
    /** Record the analysis mode (explicit from UI/CLI or inferred by classifier). */
    recordAnalysisMode(mode: 'fast' | 'full' | 'auto', source: 'user_explicit' | 'hard_rule' | 'ai'): void;
    /** Generate session metrics summary. */
    summarize(): SessionMetrics;
}
export declare const METRICS_DIR: string;
/** Write session metrics to disk. */
export declare function persistSessionMetrics(metrics: SessionMetrics): void;
/** Clean up old metrics files (called at backend startup). */
export declare function cleanupOldMetrics(): void;
//# sourceMappingURL=agentMetrics.d.ts.map