/** * Hierarchical Memory System for UAM * * Implements hot/warm/cold memory tiering with automatic promotion/demotion. * Based on MemGPT and R³Mem research for efficient memory management. */ export interface MemoryEntry { id: string; content: string; type: 'action' | 'observation' | 'thought' | 'goal'; timestamp: string; importance: number; accessCount: number; lastAccessed: string; embedding?: number[]; compressed?: string; tier?: 'hot' | 'warm' | 'cold'; } export interface TieredMemory { hot: MemoryEntry[]; warm: MemoryEntry[]; cold: MemoryEntry[]; } export interface HierarchicalConfig { hotMaxEntries: number; warmMaxEntries: number; coldMaxEntries: number; hotMaxTokens: number; warmMaxTokens: number; decayRate: number; promotionThreshold: number; demotionThreshold: number; staleDaysThreshold: number; } /** * Calculate effective importance with time decay * Formula: effective_importance = importance × (decayRate ^ days_since_access) */ export declare function calculateEffectiveImportance(entry: MemoryEntry, decayRate?: number): number; /** * Hierarchical Memory Manager */ export declare class HierarchicalMemoryManager { private config; private memory; private accessLog; constructor(config?: Partial); /** * Add a new memory entry */ add(entry: Omit): void; /** * Access a memory (promote if accessed frequently) */ access(id: string): MemoryEntry | null; /** * Query memories with automatic tier traversal */ query(queryText: string, limit?: number): Promise; /** * Get hot tier context (for inclusion in prompts) */ getHotContext(): { entries: MemoryEntry[]; tokens: number; }; /** * Consolidate old memories into summaries */ consolidate(): Promise; /** * Prune stale entries that haven't been accessed within staleDaysThreshold. * Demotes from hot -> warm, or warm -> cold. */ pruneStale(): number; /** * Enforce token budget on hot and warm tiers. * Demotes entries when token budget is exceeded. */ enforceTokenBudget(): number; /** * Rebalance tiers based on importance and access patterns */ private rebalance; /** * Check and promote entry if accessed frequently */ private checkPromotion; /** * Find entry across all tiers */ private findEntry; /** * Simple text similarity (delegates to shared utility) */ private textSimilarity; /** * Get stats about memory usage */ getStats(): { hot: { count: number; tokens: number; }; warm: { count: number; tokens: number; }; cold: { count: number; tokens: number; }; total: { count: number; tokens: number; }; }; /** * Export all memories (for persistence) */ export(): TieredMemory; /** * Import memories (for initialization) */ import(data: TieredMemory): void; } /** * Persist hierarchical memory to SQLite for cross-session continuity */ export declare function persistToSQLite(manager: HierarchicalMemoryManager, dbPath: string): void; /** * Load hierarchical memory from SQLite */ export declare function loadFromSQLite(dbPath: string): TieredMemory | null; export declare function getHierarchicalMemoryManager(config?: Partial, dbPath?: string): HierarchicalMemoryManager; /** * Save current hierarchical memory state to disk * Call periodically or on shutdown to ensure persistence */ export declare function saveHierarchicalMemory(dbPath?: string): void; //# sourceMappingURL=hierarchical-memory.d.ts.map