/**
 * Persistent Analytics
 *
 * Comprehensive analytics and cost tracking system backed by SQLite.
 *
 * Features:
 * - Daily aggregated analytics
 * - Cost tracking with budgets
 * - Usage trends and forecasting
 * - Export capabilities
 */
import { EventEmitter } from 'events';
import { AnalyticsFilter } from '../database/repositories/analytics-repository.js';
import type { Analytics } from '../database/schema.js';
export interface CostBudget {
    daily?: number;
    weekly?: number;
    monthly?: number;
    session?: number;
}
export interface UsageEvent {
    model: string;
    tokensIn: number;
    tokensOut: number;
    cost: number;
    responseTimeMs: number;
    cacheHit: boolean;
    toolCalls?: number;
    error?: boolean;
    projectId?: string;
}
export interface AnalyticsSummary {
    period: string;
    totalCost: number;
    totalRequests: number;
    totalTokens: {
        in: number;
        out: number;
    };
    avgResponseTime: number;
    cacheHitRate: number;
    errorRate: number;
    byModel: Record<string, {
        cost: number;
        requests: number;
    }>;
    trend: 'increasing' | 'stable' | 'decreasing';
}
export interface CostAlert {
    type: 'warning' | 'exceeded';
    budget: 'daily' | 'weekly' | 'monthly' | 'session';
    limit: number;
    current: number;
    percentage: number;
}
export declare class PersistentAnalytics extends EventEmitter {
    private analyticsRepo;
    private budget;
    private sessionCost;
    private sessionStart;
    constructor(budget?: Partial<CostBudget>);
    /**
     * Record a usage event
     */
    record(event: UsageEvent): void;
    /**
     * Record a new session
     */
    recordSession(projectId?: string): void;
    /**
     * Calculate cost for tokens
     */
    calculateCost(model: string, tokensIn: number, tokensOut: number): number;
    /**
     * Get current session cost
     */
    getSessionCost(): number;
    /**
     * Get daily cost
     */
    getDailyCost(date?: string): number;
    /**
     * Get weekly cost
     */
    getWeeklyCost(): number;
    /**
     * Get monthly cost
     */
    getMonthlyCost(): number;
    /**
     * Get analytics summary
     */
    getSummary(filter?: AnalyticsFilter): AnalyticsSummary;
    /**
     * Get daily summaries
     */
    getDailySummaries(days?: number): {
        date: string;
        cost: number;
        requests: number;
        tokens: number;
    }[];
    /**
     * Get budget status
     */
    getBudgetStatus(): {
        daily: {
            limit: number;
            used: number;
            remaining: number;
            percentage: number;
        };
        weekly: {
            limit: number;
            used: number;
            remaining: number;
            percentage: number;
        };
        monthly: {
            limit: number;
            used: number;
            remaining: number;
            percentage: number;
        };
        session: {
            limit: number;
            used: number;
            remaining: number;
            percentage: number;
        };
    };
    /**
     * Update budget limits
     */
    setBudget(budget: Partial<CostBudget>): void;
    /**
     * Export analytics data
     */
    export(filter?: AnalyticsFilter): Analytics[];
    /**
     * Export as CSV
     */
    exportCSV(filter?: AnalyticsFilter): string;
    /**
     * Format stats for display
     */
    formatDashboard(): string;
    /**
     * Cleanup old data
     */
    cleanup(daysToKeep?: number): number;
    private checkBudgets;
    private formatBudgetStatus;
    private formatPeriod;
    private calculateTrend;
}
export declare function getPersistentAnalytics(budget?: Partial<CostBudget>): PersistentAnalytics;
export declare function resetPersistentAnalytics(): void;
