/** * SMI-915: Metrics Aggregator * * Aggregates skill usage events into actionable metrics for value measurement. * Provides: * - Per-skill metrics aggregation * - Global metrics across all skills * - Retention rate calculation * - Time-period filtering */ import type { Database as DatabaseType } from '../db/database-interface.js'; import type { SkillMetrics } from './types.js'; /** * Time period for aggregation queries */ export interface AggregationPeriod { /** Start timestamp in milliseconds */ start: number; /** End timestamp in milliseconds */ end: number; } /** * Global metrics across all skills */ export interface GlobalMetrics { /** Total number of skill invocations */ totalInvocations: number; /** Count of unique users */ uniqueUsers: number; /** Overall success rate (0-1) */ overallSuccessRate: number; /** Average task duration in milliseconds */ avgTaskDuration: number; /** Top skills by invocation count */ topSkills: Array<{ skillId: string; invocations: number; }>; } /** * Aggregates skill usage metrics from the database */ export declare class MetricsAggregator { private db; /** * Create a metrics aggregator * * @param db - SQLite database instance */ constructor(db: DatabaseType); /** * Get metrics for a specific skill * * @param skillId - The skill identifier * @param period - Optional time period filter * @returns Aggregated metrics for the skill */ getSkillMetrics(skillId: string, period?: AggregationPeriod): SkillMetrics; /** * Get metrics for all skills * * @param period - Optional time period filter * @returns Array of metrics for each skill */ getAllSkillMetrics(period?: AggregationPeriod): SkillMetrics[]; /** * Get global metrics across all skills * * @param period - Optional time period filter * @returns Aggregated metrics for all skills */ getGlobalMetrics(period?: AggregationPeriod): GlobalMetrics; /** * Calculate retention rate (users who used skill again within N days) * * @param skillId - The skill identifier * @param days - Retention window in days (default: 7) * @returns Retention rate (0-1) */ getRetentionRate(skillId: string, days?: number): number; /** * Get skills with usage in the specified period * * @param period - Time period filter * @returns Array of skill IDs with usage */ getActiveSkills(period: AggregationPeriod): string[]; /** * Get the date range of available data * * @returns Object with min and max timestamps, or null if no data */ getDataRange(): { minTimestamp: number; maxTimestamp: number; } | null; } //# sourceMappingURL=metrics-aggregator.d.ts.map