/**
 * Prompt Caching Module
 *
 * Implements prompt caching for LLM API calls to reduce costs and latency.
 * Research shows up to 90% cost reduction and 80% latency improvement.
 *
 * References:
 * - OpenAI Prompt Caching: https://platform.openai.com/docs/guides/prompt-caching
 * - Anthropic Prompt Caching: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
 */
import { EventEmitter } from "events";
import type { CodeBuddyMessage, CodeBuddyTool } from "../codebuddy/client.js";
/**
 * Cache entry structure
 */
export interface CacheEntry {
    hash: string;
    timestamp: number;
    hitCount: number;
    tokens: number;
    type: "system" | "tools" | "context" | "full";
}
/**
 * Cache statistics
 */
export interface CacheStats {
    hits: number;
    misses: number;
    hitRate: number;
    totalTokensSaved: number;
    estimatedCostSaved: number;
    entries: number;
}
/**
 * Cache configuration
 */
export interface CacheConfig {
    enabled: boolean;
    maxEntries: number;
    ttlMs: number;
    minTokensToCache: number;
    costPerMillion: number;
}
/**
 * Default cache configuration
 */
export declare const DEFAULT_CACHE_CONFIG: CacheConfig;
/**
 * Prompt Cache Manager
 *
 * Manages caching of prompt components to optimize API costs.
 * Implements LRU eviction and TTL-based expiration.
 */
export declare class PromptCacheManager extends EventEmitter {
    private config;
    private cache;
    private stats;
    private systemPromptHash;
    private toolsHash;
    private contextHashes;
    constructor(config?: Partial<CacheConfig>);
    /**
     * Generate hash for content
     */
    private hash;
    /**
     * Estimate token count (rough approximation)
     */
    private estimateTokens;
    /**
     * Check if cache entry is valid
     */
    private isValid;
    /**
     * Evict expired entries
     */
    private evictExpired;
    /**
     * Evict LRU entries if at capacity
     */
    private evictLRU;
    /**
     * Cache system prompt
     */
    cacheSystemPrompt(prompt: string): string;
    /**
     * Cache tools definition
     */
    cacheTools(tools: CodeBuddyTool[]): string;
    /**
     * Cache context content
     */
    cacheContext(key: string, content: string): string;
    /**
     * Add cache entry
     */
    private addEntry;
    /**
     * Check if content is cached
     */
    isCached(content: string): boolean;
    /**
     * Get cache statistics
     */
    getStats(): CacheStats;
    /**
     * Format stats for display
     */
    formatStats(): string;
    /**
     * Clear cache
     */
    clear(): void;
    /**
     * Warm cache with common prompts
     */
    warmCache(prompts: {
        system?: string;
        tools?: CodeBuddyTool[];
    }): void;
    /**
     * Structure messages for optimal caching
     *
     * OpenAI/Anthropic cache prompts from the beginning, so static content
     * should come first. This reorders messages to maximize cache hits.
     */
    structureForCaching(messages: CodeBuddyMessage[]): CodeBuddyMessage[];
    /**
     * Get configuration
     */
    getConfig(): CacheConfig;
    /**
     * Update configuration
     */
    updateConfig(config: Partial<CacheConfig>): void;
}
/**
 * Get or create cache manager instance
 */
export declare function getPromptCacheManager(config?: Partial<CacheConfig>): PromptCacheManager;
/**
 * Initialize cache manager with config
 */
export declare function initializePromptCache(config?: Partial<CacheConfig>): PromptCacheManager;
