/**
 * Observability Dashboard
 *
 * Real-time monitoring and analytics for Code Buddy:
 * - Token usage and costs
 * - Tool execution metrics
 * - Response times and latency
 * - Error tracking
 * - Session analytics
 */
import { EventEmitter } from 'events';
export interface MetricPoint {
    timestamp: number;
    value: number;
    labels?: Record<string, string>;
}
export interface Metric {
    name: string;
    type: 'counter' | 'gauge' | 'histogram';
    description: string;
    unit?: string;
    points: MetricPoint[];
}
export interface ToolMetrics {
    name: string;
    totalCalls: number;
    successCount: number;
    errorCount: number;
    totalDuration: number;
    avgDuration: number;
    minDuration: number;
    maxDuration: number;
    lastExecuted?: number;
}
export interface ProviderMetrics {
    provider: string;
    model: string;
    totalRequests: number;
    totalTokens: number;
    promptTokens: number;
    completionTokens: number;
    totalCost: number;
    avgLatency: number;
    errorCount: number;
    lastRequest?: number;
}
export interface SessionMetrics {
    sessionId: string;
    startTime: number;
    duration: number;
    messageCount: number;
    userMessages: number;
    assistantMessages: number;
    toolCalls: number;
    totalTokens: number;
    totalCost: number;
    errorCount: number;
}
export interface ErrorRecord {
    timestamp: number;
    type: string;
    message: string;
    stack?: string;
    context?: Record<string, unknown>;
}
export interface DashboardState {
    uptime: number;
    activeSession: boolean;
    totalSessions: number;
    totalTokens: number;
    totalCost: number;
    totalToolCalls: number;
    avgResponseTime: number;
    errorRate: number;
    tokensPerMinute: number;
    costPerHour: number;
}
export declare class MetricsCollector extends EventEmitter {
    private metrics;
    private toolMetrics;
    private providerMetrics;
    private errors;
    private sessionMetrics;
    private startTime;
    private maxHistoryPoints;
    private maxErrors;
    constructor();
    /**
     * Initialize default metrics
     */
    private initializeDefaultMetrics;
    /**
     * Register a metric
     */
    registerMetric(metric: Metric): void;
    /**
     * Record a metric point
     */
    record(name: string, value: number, labels?: Record<string, string>): void;
    /**
     * Increment a counter
     */
    increment(name: string, amount?: number, labels?: Record<string, string>): void;
    /**
     * Record API request
     */
    recordAPIRequest(data: {
        provider: string;
        model: string;
        promptTokens: number;
        completionTokens: number;
        cost: number;
        latency: number;
        success: boolean;
    }): void;
    /**
     * Record tool execution
     */
    recordToolExecution(data: {
        name: string;
        duration: number;
        success: boolean;
        error?: string;
    }): void;
    /**
     * Record error
     */
    recordError(type: string, message: string, context?: Record<string, unknown>): void;
    /**
     * Start session tracking
     */
    startSession(sessionId: string): void;
    /**
     * Record message in session
     */
    recordMessage(role: 'user' | 'assistant' | 'system' | 'tool'): void;
    /**
     * End session
     */
    endSession(): SessionMetrics | null;
    /**
     * Get dashboard state
     */
    getDashboardState(): DashboardState;
    /**
     * Get total tokens
     */
    getTotalTokens(): number;
    /**
     * Get total cost
     */
    getTotalCost(): number;
    /**
     * Get total tool calls
     */
    getTotalToolCalls(): number;
    /**
     * Get average response time
     */
    getAverageResponseTime(): number;
    /**
     * Get error rate
     */
    getErrorRate(): number;
    /**
     * Get tool metrics
     */
    getToolMetrics(): ToolMetrics[];
    /**
     * Get provider metrics
     */
    getProviderMetrics(): ProviderMetrics[];
    /**
     * Get recent errors
     */
    getRecentErrors(limit?: number): ErrorRecord[];
    /**
     * Get metric history
     */
    getMetricHistory(name: string, since?: number): MetricPoint[];
    /**
     * Clear all metrics
     */
    reset(): void;
    /**
     * Export metrics
     */
    export(): {
        uptime: number;
        metrics: Record<string, Metric>;
        tools: ToolMetrics[];
        providers: ProviderMetrics[];
        errors: ErrorRecord[];
        session: SessionMetrics | null;
    };
    /**
     * Dispose
     */
    dispose(): void;
}
export declare class TerminalDashboard {
    private collector;
    private refreshInterval;
    constructor(collector: MetricsCollector);
    /**
     * Render dashboard to string
     */
    render(): string;
    /**
     * Format duration
     */
    private formatDuration;
    /**
     * Start live refresh
     */
    startLiveRefresh(intervalMs: number | undefined, render: (output: string) => void): void;
    /**
     * Stop live refresh
     */
    stopLiveRefresh(): void;
}
export declare class PrometheusExporter {
    private collector;
    constructor(collector: MetricsCollector);
    /**
     * Export metrics in Prometheus format
     */
    export(): string;
}
export declare function getMetricsCollector(): MetricsCollector;
export declare function resetMetricsCollector(): void;
/**
 * Get terminal dashboard
 */
export declare function getTerminalDashboard(): TerminalDashboard;
/**
 * Get Prometheus exporter
 */
export declare function getPrometheusExporter(): PrometheusExporter;
