UNPKG

erosolar-cli

Version:

Unified AI agent framework for the command line - Multi-provider support with schema-driven tools, code intelligence, and transparent reasoning

157 lines 4.25 kB
/** * Performance Metrics Tracker * * Tracks session performance metrics for analytics and improvement suggestions. * Integrated with AlphaZero engine for learning-based improvements. */ import type { ProviderUsage } from './types.js'; import { type QualityScore, type ToolCallRecord } from './alphaZeroEngine.js'; /** * Performance metrics for an agent session. */ export interface AgentPerformanceMetrics { sessionId: string; totalMessages: number; totalToolCalls: number; totalTokensUsed: number; totalTimeMs: number; successfulToolCalls: number; failedToolCalls: number; codeBlocksGenerated: number; avgResponseTimeMs: number; avgCodeQuality: number; avgAlgorithmEfficiency: number; avgErrorHandling: number; } /** * Code quality evaluation result. */ export interface CodeQualityMetrics { codeQualityScore: number; algorithmEfficiency: number; errorHandlingScore: number; documentationScore: number; maintainabilityScore: number; securityScore: number; } /** * Execution trace for debugging and analysis. */ export interface ExecutionTrace { traceId: string; timestamp: string; prompt: string; response: string; toolCalls: Array<{ name: string; arguments: Record<string, unknown>; result?: string; error?: string; durationMs: number; }>; totalDurationMs: number; tokenUsage?: ProviderUsage; } /** * Improvement suggestion from analysis. */ export interface ImprovementSuggestion { category: 'performance' | 'quality' | 'efficiency' | 'error-handling'; severity: 'low' | 'medium' | 'high'; message: string; suggestedAction?: string; } /** * Creates default performance metrics. */ export declare function createDefaultMetrics(sessionId: string): AgentPerformanceMetrics; /** * Tracks performance metrics for an agent session. */ export declare class MetricsTracker { private metrics; private responseTimes; private codeQualityScores; private efficiencyScores; private errorHandlingScores; private traces; constructor(sessionId: string); /** * Record a message exchange. */ recordMessage(elapsedMs: number, usage?: ProviderUsage | null): void; /** * Record a tool call. */ recordToolCall(success: boolean): void; /** * Record code generation. */ recordCodeGeneration(codeBlockCount: number): void; /** * Record code quality evaluation. */ recordCodeQuality(quality: CodeQualityMetrics): void; /** * Add an execution trace. */ addTrace(trace: ExecutionTrace): void; /** * Update running averages. */ private updateAverages; /** * Get current metrics. */ getMetrics(): AgentPerformanceMetrics; /** * Get execution traces. */ getTraces(): ExecutionTrace[]; /** * Get human-readable performance summary. */ getPerformanceSummary(): string; /** * Get improvement suggestions based on metrics. */ getImprovementSuggestions(): ImprovementSuggestion[]; /** * Reset all metrics. */ reset(): void; /** * Start tracking a new task with AlphaZero */ startAlphaZeroTask(userQuery: string): void; /** * Record tool call with AlphaZero pattern learning */ recordToolCallWithLearning(toolName: string, success: boolean, durationMs?: number): void; /** * Complete task and record pattern */ completeAlphaZeroTask(success: boolean): void; /** * Get quick quality score for a response */ getResponseQualityScore(response: string, toolCalls: ToolCallRecord[]): QualityScore; /** * Get recommended tools for a task type */ getRecommendedTools(userQuery: string): string[] | null; /** * Get AlphaZero statistics */ getAlphaZeroStats(): { dualResponsesGenerated: number; critiqueIterations: number; improvementsApplied: number; patternsLearned: number; }; /** * Get combined performance summary with AlphaZero stats */ getEnhancedPerformanceSummary(): string; } //# sourceMappingURL=metricsTracker.d.ts.map