UNPKG

@codai/memorai-core

Version:

Simplified advanced memory engine - no tiers, just powerful semantic search with persistence

85 lines 2.23 kB
/** * Basic Memory Engine - No AI Required * Provides keyword-based search and simple classification with persistent file storage */ import type { MemoryMetadata, MemoryQuery, MemoryResult, MemoryType } from '../types/index.js'; export interface KeywordIndex { [keyword: string]: Set<string>; } export declare class BasicMemoryEngine { private storage; private keywordIndex; private typeIndex; private tagIndex; private initialized; constructor(dataDirectory?: string); /** * Initialize the engine and rebuild indices from persistent storage */ initialize(): Promise<void>; /** * Store a memory using keyword indexing and persistent storage */ remember(memory: MemoryMetadata): Promise<void>; /** * Search memories using keyword matching */ recall(query: MemoryQuery): Promise<MemoryResult[]>; /** * List memories with filtering */ list(limit?: number, tenantId?: string, agentId?: string): Promise<MemoryMetadata[]>; /** * Update memory access statistics */ updateMemoryAccess(memoryId: string): Promise<void>; /** * Delete a memory */ forget(memoryId: string): Promise<void>; /** * Index memory by keywords */ private indexMemoryKeywords; /** * Index memory by type */ private indexMemoryType; /** * Index memory by tags */ private indexMemoryTags; /** * Remove memory from all indices */ private removeFromIndices; /** * Extract keywords from text using simple tokenization */ private extractKeywords; /** * Check if a word is a stop word */ private isStopWord; /** * Calculate keyword match score */ private calculateKeywordScore; /** * Get relevance reason for a memory */ private getRelevanceReason; /** * Get statistics about stored memories */ getStats(): Promise<{ totalMemories: number; memoryTypes: Record<MemoryType, number>; indexStats: { keywords: number; types: number; tags: number; }; }>; } //# sourceMappingURL=BasicMemoryEngine.d.ts.map