/** * Idempotency Store Service * * Provides idempotency key validation and result caching for tool execution. * Ensures that duplicate tool calls with the same parameters return cached results * instead of re-executing, preventing unintended side effects. * */ import type { LLMToolCall } from '../types/llm.types.js'; import { type IdempotencyCheckResult, type IdempotencyOptions, type IdempotencyResult, type IdempotencyStoreConfig } from '../types/idempotency.types.js'; export declare class IdempotencyStoreService { private cleanupTimer; private readonly config; private readonly lockerId; private readonly lockManager; private recordCount; constructor(config?: Partial); /** * Generate an idempotency key from a tool call * The key is a hash of the tool name and sorted arguments */ generateKey(toolCall: LLMToolCall, sessionId?: string): string; /** * Generate a hash of the arguments for verification */ private generateArgsHash; /** * Check if a tool call has a cached result * Returns the cached result if found and not expired */ check(toolCall: LLMToolCall, options?: IdempotencyOptions): Promise; /** * Store a result for an idempotency key */ store(toolCall: LLMToolCall, result: IdempotencyResult, options?: IdempotencyOptions): Promise; /** * Delete an idempotency record */ delete(key: string): void; /** * Invalidate all records for a specific tool */ invalidateTool(toolName: string): number; /** * Invalidate all records for a session */ invalidateSession(sessionId: string): Promise; /** * Clean up expired records */ cleanup(): Promise; /** * Clean up a single expired record */ private cleanupExpiredRecord; /** * Update the record count from the store directory */ private updateRecordCount; /** * Clear all idempotency records */ clear(): number; /** * Get store statistics */ getStats(): { max_records: number; record_count: number; store_dir: string; }; /** * Stop the cleanup timer (for graceful shutdown) */ stop(): void; /** * Ensure the store directory exists */ private ensureStoreDirectory; /** * Start the periodic cleanup timer */ private startCleanupTimer; /** * Get the file path for a record */ private getRecordPath; /** * Sort an object's keys recursively for consistent hashing */ private sortObject; } /** * Get the global idempotency store instance */ export declare function getIdempotencyStore(config?: Partial): IdempotencyStoreService; /** * Reset the singleton (for testing) */ export declare function resetIdempotencyStore(): void; //# sourceMappingURL=idempotency-store.service.d.ts.map