/**
 * Tool Usage Analytics Module
 *
 * Tracks tool usage patterns, success/failure rates, and provides insights
 * for optimizing tool selection and execution.
 *
 * Features:
 * - Track tool execution frequency
 * - Track success/failure rates per tool
 * - Track execution duration
 * - Learn from successful tool chains
 * - Provide smart suggestions based on patterns
 */
import { EventEmitter } from 'events';
export interface ToolExecution {
    toolName: string;
    timestamp: Date;
    success: boolean;
    duration: number;
    inputTokens?: number;
    outputTokens?: number;
    error?: string;
    context?: string;
}
export interface ToolStats {
    toolName: string;
    totalExecutions: number;
    successCount: number;
    failureCount: number;
    successRate: number;
    avgDuration: number;
    minDuration: number;
    maxDuration: number;
    lastUsed: Date;
    commonErrors: string[];
}
export interface ToolChain {
    tools: string[];
    frequency: number;
    successRate: number;
    avgDuration: number;
    lastUsed: Date;
}
export interface ToolSuggestion {
    toolName: string;
    confidence: number;
    reason: string;
    basedOn: 'frequency' | 'success_rate' | 'pattern' | 'context';
}
export interface ToolAnalyticsSnapshot {
    totalExecutions: number;
    uniqueTools: number;
    overallSuccessRate: number;
    mostUsedTools: Array<{
        name: string;
        count: number;
    }>;
    highestSuccessRate: Array<{
        name: string;
        rate: number;
    }>;
    lowestSuccessRate: Array<{
        name: string;
        rate: number;
    }>;
    recentChains: ToolChain[];
    period: {
        start: Date;
        end: Date;
    };
}
export declare class ToolAnalytics extends EventEmitter {
    private executions;
    private toolStats;
    private toolChains;
    private recentToolSequence;
    private maxExecutions;
    private maxChainLength;
    private dataDir;
    private persistenceEnabled;
    constructor(dataDir?: string);
    /**
     * Record a tool execution
     */
    recordExecution(execution: ToolExecution): void;
    /**
     * Record a successful tool execution
     */
    recordSuccess(toolName: string, duration: number, context?: string): void;
    /**
     * Record a failed tool execution
     */
    recordFailure(toolName: string, duration: number, error: string, context?: string): void;
    /**
     * Update statistics for a tool
     */
    private updateToolStats;
    /**
     * Update tool chain patterns
     */
    private updateToolChains;
    /**
     * Get statistics for a specific tool
     */
    getToolStats(toolName: string): ToolStats | undefined;
    /**
     * Get all tool statistics
     */
    getAllToolStats(): ToolStats[];
    /**
     * Get most used tools
     */
    getMostUsedTools(limit?: number): ToolStats[];
    /**
     * Get tools with highest success rate (minimum 5 executions)
     */
    getHighestSuccessRate(limit?: number): ToolStats[];
    /**
     * Get tools with lowest success rate (minimum 5 executions)
     */
    getLowestSuccessRate(limit?: number): ToolStats[];
    /**
     * Get common tool chains
     */
    getCommonChains(limit?: number): ToolChain[];
    /**
     * Suggest tools based on current context and patterns
     */
    suggestTools(context?: string, lastTool?: string): ToolSuggestion[];
    /**
     * Suggest next tool based on common chains
     */
    private suggestFromChains;
    /**
     * Get analytics snapshot
     */
    getSnapshot(): ToolAnalyticsSnapshot;
    /**
     * Format analytics for display
     */
    formatAnalytics(): string;
    /**
     * Export analytics to JSON
     */
    exportToJson(): string;
    /**
     * Save analytics to disk
     */
    save(): Promise<void>;
    /**
     * Load analytics from disk
     */
    load(): Promise<void>;
    /**
     * Clear all analytics data
     */
    clear(): void;
    /**
     * Reset the tool sequence (start fresh chain detection)
     */
    resetToolSequence(): void;
    /**
     * Dispose and cleanup
     */
    dispose(): void;
}
/**
 * Get the global tool analytics instance
 */
export declare function getToolAnalytics(): ToolAnalytics;
/**
 * Reset the global tool analytics instance
 */
export declare function resetToolAnalytics(): void;
export default ToolAnalytics;
