/**
 * Tool Cache
 *
 * Caches results of deterministic tool calls to avoid redundant operations.
 * Uses semantic similarity to match similar queries.
 */
import { EventEmitter } from 'events';
import { SemanticCache } from '../utils/semantic-cache.js';
import { ToolResult } from '../types/index.js';
export interface ToolCacheConfig {
    enabled: boolean;
    ttlMs: number;
    maxEntries: number;
    similarityThreshold: number;
    cacheableTools: Set<string>;
    excludePatterns: RegExp[];
}
export interface CachedToolResult extends ToolResult {
    cached: boolean;
    cacheKey?: string;
    similarity?: number;
}
export interface ToolCacheStats {
    hits: number;
    misses: number;
    hitRate: number;
    savedCalls: number;
    savedTime: number;
}
export declare class ToolCache extends EventEmitter {
    private cache;
    private config;
    private stats;
    private avgToolTime;
    constructor(config?: Partial<ToolCacheConfig>);
    /**
     * Check if a tool call can be cached
     */
    isCacheable(toolName: string, args: Record<string, unknown>): boolean;
    /**
     * Get cached result or execute tool
     */
    getOrExecute(toolName: string, args: Record<string, unknown>, executeFn: () => Promise<ToolResult>): Promise<CachedToolResult>;
    /**
     * Invalidate cache for specific tool or pattern
     */
    invalidate(toolName?: string, pattern?: string | RegExp): number;
    /**
     * Invalidate cache entries affected by file changes
     */
    invalidateForFile(filePath: string): number;
    /**
     * Clear entire cache
     */
    clear(): void;
    /**
     * Get cache statistics
     */
    getStats(): ToolCacheStats;
    /**
     * Reset statistics
     */
    resetStats(): void;
    /**
     * Get detailed cache info
     */
    getCacheInfo(): {
        stats: ToolCacheStats;
        cacheStats: ReturnType<SemanticCache['getStats']>;
        config: ToolCacheConfig;
    };
    /**
     * Update configuration
     */
    updateConfig(config: Partial<ToolCacheConfig>): void;
    /**
     * Dispose cache
     */
    dispose(): void;
    private createCacheKey;
    private updateHitRate;
}
export declare function getToolCache(config?: Partial<ToolCacheConfig>): ToolCache;
export declare function resetToolCache(): void;
/**
 * Wrap a tool executor with caching
 */
export declare function withCache<T extends ToolResult>(toolName: string, args: Record<string, unknown>, executeFn: () => Promise<T>): Promise<T & {
    cached: boolean;
}>;
/**
 * Decorator for caching tool methods
 */
export declare function Cacheable(toolName?: string): (_target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
