/**
 * Metrics Dashboard for Code Buddy
 *
 * Provides real-time and historical metrics visualization including:
 * - Token usage and costs
 * - Tool execution statistics
 * - Session analytics
 * - Performance metrics
 */
import { EventEmitter } from 'events';
export interface TokenMetrics {
    promptTokens: number;
    completionTokens: number;
    totalTokens: number;
    cachedTokens: number;
}
export interface CostMetrics {
    totalCost: number;
    sessionCost: number;
    averageCostPerRequest: number;
    costByModel: Record<string, number>;
}
export interface ToolMetrics {
    totalExecutions: number;
    successfulExecutions: number;
    failedExecutions: number;
    executionsByTool: Record<string, {
        success: number;
        failed: number;
        avgTime: number;
    }>;
    averageExecutionTime: number;
}
export interface SessionMetrics {
    sessionId: string;
    startTime: Date;
    duration: number;
    messageCount: number;
    toolRounds: number;
    userMessages: number;
    assistantMessages: number;
}
export interface PerformanceMetrics {
    averageLatency: number;
    p50Latency: number;
    p95Latency: number;
    p99Latency: number;
    requestsPerMinute: number;
    cacheHitRate: number;
}
export interface DashboardMetrics {
    tokens: TokenMetrics;
    costs: CostMetrics;
    tools: ToolMetrics;
    session: SessionMetrics;
    performance: PerformanceMetrics;
    timestamp: Date;
}
export interface MetricsEvent {
    type: 'token_usage' | 'tool_execution' | 'request_complete' | 'cache_hit' | 'cost_update';
    data: Record<string, unknown>;
    timestamp: Date;
}
/**
 * Metrics Dashboard class
 */
export declare class MetricsDashboard extends EventEmitter {
    private sessionId;
    private startTime;
    private events;
    private latencies;
    private maxEvents;
    private tokens;
    private costs;
    private tools;
    private requestCount;
    private cacheHits;
    private messageCount;
    private userMessages;
    private assistantMessages;
    private toolRounds;
    constructor(sessionId?: string);
    private generateSessionId;
    /**
     * Record token usage
     */
    recordTokenUsage(usage: {
        promptTokens: number;
        completionTokens: number;
        cachedTokens?: number;
    }): void;
    /**
     * Record tool execution
     */
    recordToolExecution(execution: {
        toolName: string;
        success: boolean;
        duration: number;
        error?: string;
    }): void;
    /**
     * Record request completion
     */
    recordRequestComplete(request: {
        latency: number;
        model: string;
        cost?: number;
    }): void;
    /**
     * Record cache hit
     */
    recordCacheHit(): void;
    /**
     * Record message
     */
    recordMessage(type: 'user' | 'assistant'): void;
    /**
     * Record tool round
     */
    recordToolRound(): void;
    /**
     * Add event to history
     */
    private addEvent;
    /**
     * Calculate percentile from sorted array
     */
    private percentile;
    /**
     * Get current metrics snapshot
     */
    getMetrics(): DashboardMetrics;
    /**
     * Format metrics for terminal display
     */
    formatMetrics(): string;
    /**
     * Export metrics to JSON
     */
    exportMetrics(): string;
    /**
     * Get tool leaderboard (most used tools)
     */
    getToolLeaderboard(): Array<{
        tool: string;
        executions: number;
        successRate: number;
    }>;
    /**
     * Get events in time range
     */
    getEventsInRange(start: Date, end: Date): MetricsEvent[];
    /**
     * Reset session metrics
     */
    resetSession(): void;
    /**
     * Dispose and cleanup
     */
    dispose(): void;
}
/**
 * Get or create the metrics dashboard
 */
export declare function getMetricsDashboard(): MetricsDashboard;
/**
 * Reset the metrics dashboard
 */
export declare function resetMetricsDashboard(): void;
