/** * Tool Usage Analyzer - Tracks and analyzes tool usage patterns * * Based on Agent Harness theory: "Vercel deleted 80% of its Agent tools, * and the Agent went from task failure to task success" */ export interface ToolUsageStats { toolName: string; calls: number; successes: number; failures: number; avgDurationMs: number; lastUsedTimestamp: number; successRate: number; } export interface ToolUsageRecommendations { keep: string[]; review: string[]; remove: string[]; } export interface ToolUsageAnalyzerConfig { enabled: boolean; lowUsageThreshold: number; veryLowUsageThreshold: number; minCallsForAnalysis: number; reportIntervalMs: number; } export declare class ToolUsageAnalyzer { private stats; private config; private totalCalls; private lastReportTime; constructor(config?: Partial); /** * Record a tool usage event */ recordUsage(toolName: string, success: boolean, durationMs: number): void; /** * Get usage stats for a specific tool */ getToolStats(toolName: string): ToolUsageStats | undefined; /** * Get all tool usage stats */ getAllStats(): Map; /** * Get tools with low usage (below threshold) */ getLowUsageTools(threshold?: number): string[]; /** * Get tools with low success rate */ getLowSuccessTools(threshold?: number): string[]; /** * Get recommendations for tool optimization */ getRecommendations(): ToolUsageRecommendations; /** * Generate and log usage report */ generateReport(): void; /** * Get top N most used tools */ getTopTools(n: number): ToolUsageStats[]; /** * Get usage summary as text */ getSummaryText(): string; /** * Reset all stats */ reset(): void; /** * Export stats as JSON */ exportStats(): string; /** * Get config */ getConfig(): ToolUsageAnalyzerConfig; /** * Update config */ setConfig(config: Partial): void; }