/** * SQLite Memory Backend * * Provides structured storage for memory entries using SQLite. * Optimized for ACID transactions, exact matches, and complex queries. * Part of ADR-009: Hybrid Memory Backend (SQLite + AgentDB) * * @module v3/memory/sqlite-backend */ import { EventEmitter } from 'node:events'; import { IMemoryBackend, MemoryEntry, MemoryEntryUpdate, MemoryQuery, SearchOptions, SearchResult, BackendStats, HealthCheckResult, EmbeddingGenerator } from './types.js'; /** * Configuration for SQLite Backend */ export interface SQLiteBackendConfig { /** Path to SQLite database file (:memory: for in-memory) */ databasePath: string; /** Enable WAL mode for better concurrency */ walMode: boolean; /** Enable query optimization */ optimize: boolean; /** Default namespace */ defaultNamespace: string; /** Embedding generator (for compatibility with hybrid mode) */ embeddingGenerator?: EmbeddingGenerator; /** Maximum entries before auto-cleanup */ maxEntries: number; /** Enable verbose logging */ verbose: boolean; } /** * SQLite Backend for Structured Memory Storage * * Provides: * - ACID transactions for data consistency * - Efficient indexing for exact matches and prefix queries * - Full-text search capabilities * - Complex SQL queries with joins and aggregations * - Persistent storage with WAL mode */ export declare class SQLiteBackend extends EventEmitter implements IMemoryBackend { private config; private db; private initialized; private stats; constructor(config?: Partial); /** * Initialize the SQLite backend */ initialize(): Promise; /** * Shutdown the backend */ shutdown(): Promise; /** * Store a memory entry */ store(entry: MemoryEntry): Promise; /** * Get a memory entry by ID */ get(id: string): Promise; /** * Get a memory entry by key within a namespace */ getByKey(namespace: string, key: string): Promise; /** * Update a memory entry */ update(id: string, update: MemoryEntryUpdate): Promise; /** * Delete a memory entry */ delete(id: string): Promise; /** * Query memory entries with filters */ query(query: MemoryQuery): Promise; /** * Semantic vector search (not optimized for SQLite, returns empty) * Use HybridBackend for semantic search with AgentDB */ search(embedding: Float32Array, options: SearchOptions): Promise; /** * Bulk insert entries */ bulkInsert(entries: MemoryEntry[]): Promise; /** * Bulk delete entries */ bulkDelete(ids: string[]): Promise; /** * Get entry count */ count(namespace?: string): Promise; /** * List all namespaces */ listNamespaces(): Promise; /** * Clear all entries in a namespace */ clearNamespace(namespace: string): Promise; /** * Get backend statistics */ getStats(): Promise; /** * Perform health check */ healthCheck(): Promise; private ensureInitialized; private createSchema; private rowToEntry; /** * Synchronous store for use in transactions */ private storeSync; } export default SQLiteBackend; //# sourceMappingURL=sqlite-backend.d.ts.map