/** * Vector Memory Service * * Enhanced memory system using @sparkleideas/memory for: * - HNSW indexing for fast similarity search * - Vector embeddings for semantic search * - Hybrid SQLite + AgentDB backend * * Falls back to simple file-based storage if @sparkleideas/memory unavailable. * * Fallback supports: * - **Sharding**: auto-rotate shards when max entries per shard is reached * - **Quality guards**: min content length, reject repeated chars * - **Deduplication**: exact hash-based dedup, optional near-duplicate detection */ export interface MemoryMetadata { type?: 'decision' | 'learning' | 'preference' | 'blocker' | 'context' | 'pattern'; scope?: string; tags?: string[]; source?: string; } export interface VectorMemoryEntry { id: string; content: string; embedding?: number[]; metadata: MemoryMetadata; createdAt: string; updatedAt: string; } export interface SearchResult { id: string; content: string; score: number; metadata: MemoryMetadata; } /** * Override sharding configuration at runtime. * Called from the plugin config hook with values from agent_hive.json. */ export declare function setShardingConfig(config: { maxEntriesPerShard?: number; }): void; /** * Override quality configuration at runtime. * Called from the plugin config hook with values from agent_hive.json. */ export declare function setQualityConfig(config: { minContentLength?: number; rejectRepeatedChars?: boolean; enableDedup?: boolean; enableNearDedup?: boolean; }): void; /** * Override memory filter configuration at runtime. */ export declare function setMemoryFilterConfig(config: { enabled?: boolean; redactEmails?: boolean; } | undefined): void; /** * Add a memory entry to the vector index */ export declare function addMemory(content: string, metadata?: MemoryMetadata): Promise<{ id: string; success: boolean; fallback?: boolean; rejected?: boolean; reason?: string; }>; /** * Search memories using vector similarity */ export declare function searchMemories(query: string, options?: { limit?: number; type?: string; scope?: string; minScore?: number; }): Promise<{ results: SearchResult[]; fallback?: boolean; }>; /** * List recent memories by recency (no text query needed). * Used by auto-recall to inject relevant context into system prompt. */ export declare function listMemories(options?: { limit?: number; type?: string; scope?: string; }): Promise<{ results: SearchResult[]; fallback?: boolean; }>; /** * Get a memory entry by ID */ export declare function getMemory(id: string): Promise; /** * Delete a memory entry */ export declare function deleteMemory(id: string): Promise; /** * Get vector memory status */ export declare function getMemoryStatus(): Promise<{ available: boolean; type: 'vector' | 'fallback'; stats?: { total: number; byType?: Record; }; shard?: { index: number; entryCount: number; maxEntries: number; }; }>; export declare const VectorMemoryService: { init: (options?: { indexPath?: string; dimensions?: number; }) => Promise; add: (content: string, metadata: MemoryMetadata) => Promise<{ id: string; success: boolean; fallback?: boolean; rejected?: boolean; reason?: string; }>; search: (query: string, options?: { limit?: number; type?: string; scope?: string; minScore?: number; }) => Promise<{ results: SearchResult[]; fallback?: boolean; }>; list: (options?: { limit?: number; type?: string; scope?: string; }) => Promise<{ results: SearchResult[]; fallback?: boolean; }>; get: (id: string) => Promise; delete: (id: string) => Promise; status: () => Promise<{ available: boolean; type: "vector" | "fallback"; stats?: { total: number; byType?: Record; }; shard?: { index: number; entryCount: number; maxEntries: number; }; }>; setShardingConfig: typeof setShardingConfig; setQualityConfig: typeof setQualityConfig; setMemoryFilterConfig: typeof setMemoryFilterConfig; }; export default VectorMemoryService;