/** * Memory Store * * Core CRUD operations for the memory database. * Handles storage, retrieval, and management of memories. */ import { Memory, MemoryInput, MemoryType, SearchOptions, SearchResult, MemoryConfig } from './types.js'; /** * Get truncation info from the last addMemory call */ export declare function getLastTruncationInfo(): { wasTruncated: boolean; originalLength: number; truncatedLength: number; } | null; /** * Convert database row to Memory object */ export declare function rowToMemory(row: Record): Memory; /** * Error thrown when memory creation is paused */ export declare class MemoryPausedError extends Error { constructor(); } /** * Add a new memory */ export declare function addMemory(input: MemoryInput, config?: MemoryConfig): Memory; /** * Get a memory by ID */ export declare function getMemoryById(id: number): Memory | null; /** * Update a memory */ export declare function updateMemory(id: number, updates: Partial): Memory | null; /** * Delete a memory */ export declare function deleteMemory(id: number): boolean; /** * Access a memory (updates access count and timestamp, returns reinforced memory) */ export declare function accessMemory(id: number, config?: MemoryConfig): Memory | null; /** * Reinforce a memory that appeared in search results * Gives a small salience boost with diminishing returns based on access count. * ORGANIC FEATURE: Searched memories get reinforced, closing the feedback loop * so frequently-found memories grow stronger over time. */ export declare function reinforceFromSearch(memoryId: number): void; /** * Enrichment result indicating what happened */ export interface EnrichmentResult { enriched: boolean; reason: string; } /** * Enrich a memory with additional context * * This adds timestamped context to a memory when: * 1. The new context is sufficiently related but different (new information) * 2. The memory hasn't been enriched recently (cooldown) * 3. The content won't exceed the size limit * * ORGANIC FEATURE: Memories grow with new context over time, * mimicking how human memories are reconsolidated with new information * * @param memoryId - ID of the memory to enrich * @param newContext - New context to add * @param contextType - Type of context ('search' | 'access' | 'related') * @returns EnrichmentResult indicating success or failure with reason */ export declare function enrichMemory(memoryId: number, newContext: string, contextType?: 'search' | 'access' | 'related'): EnrichmentResult; /** * Clear enrichment cooldown for a memory (for testing) */ export declare function clearEnrichmentCooldown(memoryId: number): void; /** * Get enrichment cooldown status for a memory */ export declare function getEnrichmentCooldownStatus(memoryId: number): { onCooldown: boolean; remainingMs: number; }; /** * Update persisted decay scores for all memories * Called during consolidation and periodically by the API server * Returns the number of memories updated */ export declare function updateDecayScores(): number; export declare function searchMemories(options: SearchOptions, config?: MemoryConfig): Promise; /** * Get all memories for a project */ export declare function getProjectMemories(project: string, config?: MemoryConfig): Memory[]; /** * Get recent memories */ export declare function getRecentMemories(limit?: number, project?: string): Memory[]; /** * Get memories by type */ export declare function getMemoriesByType(type: MemoryType, limit?: number): Memory[]; /** * Get high-priority memories (for context injection) */ export declare function getHighPriorityMemories(limit?: number, project?: string): Memory[]; /** * Promote a memory from short-term to long-term */ export declare function promoteMemory(id: number): Memory | null; /** * Bulk delete decayed memories */ export declare function cleanupDecayedMemories(config?: MemoryConfig): number; /** * Get memory statistics */ export declare function getMemoryStats(project?: string): { total: number; shortTerm: number; longTerm: number; episodic: number; byCategory: Record; averageSalience: number; }; export type RelationshipType = 'references' | 'extends' | 'contradicts' | 'related'; export interface MemoryLink { id: number; sourceId: number; targetId: number; relationship: RelationshipType; strength: number; createdAt: Date; } /** * Create a link between two memories */ export declare function createMemoryLink(sourceId: number, targetId: number, relationship: RelationshipType, strength?: number): MemoryLink | null; /** * Get all memories related to a given memory */ export declare function getRelatedMemories(memoryId: number): { memory: Memory; relationship: RelationshipType; strength: number; direction: 'outgoing' | 'incoming'; }[]; /** * Delete a memory link */ export declare function deleteMemoryLink(sourceId: number, targetId: number): boolean; /** * Get all memory links */ export declare function getAllMemoryLinks(): MemoryLink[]; /** * Detect potential relationships for a new memory * Uses three strategies in priority order: * 1. Tag-based linking (shared tags) * 2. Embedding-based semantic linking (cosine similarity >= 0.6) * 3. FTS content similarity fallback (Jaccard similarity >= 0.3) */ export declare function detectRelationships(memory: Memory, maxResults?: number): { targetId: number; relationship: RelationshipType; strength: number; }[]; //# sourceMappingURL=store.d.ts.map