/** * GitMem Diagnostics Collector * * Subscribes to diagnostics_channel events and collects metrics * during diagnostic pass. Anonymizes data as it's collected. * * */ /** * Collected metrics for a diagnostic run */ export interface DiagnosticMetrics { startTime: number; endTime?: number; durationMs?: number; toolCalls: { tool: string; durationMs: number; success: boolean; error?: string; }[]; cache: { hits: number; misses: number; hitRate: number; hitsByType: Record; missesByType: Record; }; dbQueries: { operation: string; table?: string; durationMs: number; success: boolean; rowCount?: number; }[]; embeddings: { provider: string; durationMs: number; success: boolean; inputLength: number; }[]; errors: { message: string; context: string; severity: string; }[]; totals: { toolCallCount: number; dbQueryCount: number; embeddingCallCount: number; errorCount: number; totalToolDurationMs: number; totalDbDurationMs: number; totalEmbeddingDurationMs: number; }; } /** * Full diagnostic report */ export interface DiagnosticReport { version: string; generatedAt: string; mode: "quick" | "full"; environment: { platform: string; nodeVersion: string; arch: string; tier: string; }; configuration: { supabaseConfigured: boolean; supabaseUrl: string; embeddingProvider: string; embeddingConfigured: boolean; cacheEnabled: boolean; cachePath: string; }; health: { supabase: HealthCheckResult; embedding: HealthCheckResult; cache: HealthCheckResult; recall: HealthCheckResult; write: HealthCheckResult; }; metrics: DiagnosticMetrics; benchmarks?: { coldStart?: BenchmarkResult; recall?: BenchmarkResult; cachePopulate?: BenchmarkResult; cacheHit?: BenchmarkResult; }; dataVolume?: { learningsCount: number; sessionsCount: number; decisionsCount: number; localCacheFiles: number; localCacheBytes: number; }; } /** * Health check result */ export interface HealthCheckResult { status: "pass" | "fail" | "skip"; message: string; durationMs?: number; } /** * Benchmark result */ export interface BenchmarkResult { iterations: number; meanMs: number; minMs: number; maxMs: number; p50Ms: number; p95Ms: number; p99Ms: number; } /** * Diagnostics collector */ export declare class DiagnosticsCollector { private metrics; private subscriptions; private isCollecting; constructor(); /** * Create empty metrics object */ private createEmptyMetrics; /** * Start collecting metrics */ start(): void; /** * Stop collecting and return metrics */ stop(): DiagnosticMetrics; /** * Get current metrics (without stopping) */ getMetrics(): DiagnosticMetrics; /** * Subscribe to a channel */ private subscribeToChannel; /** * Handle tool call event */ private handleToolCall; /** * Handle cache hit event */ private handleCacheHit; /** * Handle cache miss event */ private handleCacheMiss; /** * Handle database query event */ private handleDbQuery; /** * Handle embedding call event */ private handleEmbeddingCall; /** * Handle error event */ private handleError; } /** * Calculate percentile from sorted array */ export declare function percentile(sortedValues: number[], p: number): number; /** * Run benchmark with multiple iterations */ export declare function runBenchmark(name: string, fn: () => Promise, iterations?: number): Promise; export declare function getCollector(): DiagnosticsCollector; export declare function resetCollector(): void; //# sourceMappingURL=collector.d.ts.map