export interface MemoryConfiguration { maxConversations: number; conversationTTL: number; maxMessagesPerConversation: number; maxThinkingBlocks: number; maxThinkingBlockSize: number; thinkingBlockTTL: number; maxTotalMemoryMB: number; cleanupInterval: number; gracefulDegradationThreshold: number; maxCacheEntries: number; cacheTTL: number; } export declare const DEFAULT_MEMORY_CONFIG: MemoryConfiguration; export interface ConversationMetrics { id: string; createdAt: number; lastAccessedAt: number; messageCount: number; thinkingBlockCount: number; estimatedSizeBytes: number; correlationIds: string[]; } export interface MemoryMetrics { totalConversations: number; totalMessages: number; totalThinkingBlocks: number; estimatedMemoryUsage: number; oldestConversation?: number; newestConversation?: number; avgConversationSize: number; memoryPressure: 'low' | 'medium' | 'high' | 'critical'; } /** * Comprehensive Memory Management System * Handles conversation state, thinking blocks, and resource cleanup */ export declare class MemoryManager { private static instance; private config; private conversationMetrics; private cleanupTimer?; private lastCleanup; private constructor(); static getInstance(config?: MemoryConfiguration): MemoryManager; /** * Register a new conversation for memory tracking */ registerConversation(conversationId: string, initialSize?: number, correlationId?: string): void; /** * Update conversation metrics when accessed or modified */ updateConversationAccess(conversationId: string, messageAdded?: boolean, thinkingBlocksAdded?: number, additionalSize?: number, correlationId?: string): void; /** * Validate and manage thinking blocks for memory safety */ validateThinkingBlocks(conversationId: string, thinkingBlocks: any[]): { validBlocks: any[]; warnings: string[]; }; /** * Clean up expired conversations and thinking blocks */ performCleanup(): { removedConversations: number; warnings: string[]; }; /** * Emergency cleanup when memory pressure is high */ performEmergencyCleanup(): void; /** * Get current memory metrics for monitoring */ getMemoryMetrics(): MemoryMetrics; /** * Check if system should enter graceful degradation mode */ shouldEnterGracefulDegradation(): boolean; /** * Get recommendations for memory optimization */ getOptimizationRecommendations(): string[]; /** * Start automatic cleanup scheduler */ private startCleanupScheduler; /** * Stop cleanup scheduler (for testing or shutdown) */ stopCleanupScheduler(): void; /** * Remove specific conversation from tracking */ removeConversation(conversationId: string): boolean; /** * Get conversation metrics for debugging */ getConversationMetrics(conversationId: string): ConversationMetrics | undefined; /** * Get all conversation metrics (for monitoring dashboard) */ getAllConversationMetrics(): ConversationMetrics[]; /** * Get current configuration */ getConfiguration(): MemoryConfiguration; /** * Update memory manager configuration */ updateConfiguration(newConfig: Partial): void; } export declare const memoryManager: MemoryManager; /** * Helper function to integrate memory management with conversation state */ export declare function withMemoryManagement>(conversationStates: T, memoryManager: MemoryManager): T; //# sourceMappingURL=memoryManager.d.ts.map