/**
 * Metrics Service
 *
 * Records and aggregates provider metrics for LLM usage tracking.
 * Stores data in the provider_metrics SQLite table and provides
 * aggregation queries for dashboards and CLI reporting.
 */
import type { StorageBackend } from '@stoneforge/storage';
/**
 * Outcome of a provider session
 */
export type MetricOutcome = 'completed' | 'failed' | 'rate_limited' | 'handoff';
/**
 * Input for recording a single metric entry
 */
export interface RecordMetricInput {
    provider: string;
    model?: string;
    sessionId: string;
    taskId?: string;
    inputTokens: number;
    outputTokens: number;
    durationMs: number;
    outcome: MetricOutcome;
}
/**
 * Time range for aggregation queries
 */
export interface TimeRange {
    /** Number of days to look back (e.g., 7, 14, 30) */
    days: number;
}
/**
 * Aggregated metrics for a group (provider or model)
 */
export interface AggregatedMetrics {
    /** Group key (provider name or model name) */
    group: string;
    /** Total input tokens */
    totalInputTokens: number;
    /** Total output tokens */
    totalOutputTokens: number;
    /** Total tokens (input + output) */
    totalTokens: number;
    /** Number of sessions */
    sessionCount: number;
    /** Average duration in milliseconds */
    avgDurationMs: number;
    /** Error rate (0-1) */
    errorRate: number;
    /** Number of failed sessions */
    failedCount: number;
    /** Number of rate-limited sessions */
    rateLimitedCount: number;
}
/**
 * A single time-series data point
 */
export interface TimeSeriesPoint {
    /** Time bucket (ISO 8601 date string) */
    bucket: string;
    /** Group key (provider or model name) */
    group: string;
    /** Total input tokens in this bucket */
    totalInputTokens: number;
    /** Total output tokens in this bucket */
    totalOutputTokens: number;
    /** Number of sessions in this bucket */
    sessionCount: number;
    /** Average duration in milliseconds for this bucket */
    avgDurationMs: number;
}
export interface MetricsService {
    /**
     * Record a provider metric entry
     */
    record(input: RecordMetricInput): void;
    /**
     * Get aggregated metrics grouped by provider
     */
    aggregateByProvider(timeRange: TimeRange): AggregatedMetrics[];
    /**
     * Get aggregated metrics grouped by model
     */
    aggregateByModel(timeRange: TimeRange): AggregatedMetrics[];
    /**
     * Get time-series data for trend charts
     */
    getTimeSeries(timeRange: TimeRange, groupBy: 'provider' | 'model'): TimeSeriesPoint[];
}
export declare function createMetricsService(storage: StorageBackend): MetricsService;
//# sourceMappingURL=metrics-service.d.ts.map