/** * SqlJsBackend - Pure JavaScript SQLite for Windows compatibility * * When better-sqlite3 native compilation fails on Windows, * sql.js provides a WASM-based fallback that works everywhere. * * @module v3/memory/sqljs-backend */ import { EventEmitter } from 'node:events'; import { IMemoryBackend, MemoryEntry, MemoryEntryUpdate, MemoryQuery, SearchOptions, SearchResult, BackendStats, HealthCheckResult, EmbeddingGenerator } from './types.js'; /** * Configuration for SqlJs Backend */ export interface SqlJsBackendConfig { /** Path to SQLite database file (:memory: for in-memory) */ databasePath: string; /** 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; /** Auto-persist interval in milliseconds (0 = manual only) */ autoPersistInterval: number; /** Path to sql.js WASM file (optional, will use CDN default) */ wasmPath?: string; } /** * SqlJs Backend for Cross-Platform Memory Storage * * Provides: * - Pure JavaScript/WASM implementation (no native compilation) * - Windows, macOS, Linux compatibility * - Same SQL interface as better-sqlite3 * - In-memory with periodic disk persistence * - Fallback when native SQLite fails */ export declare class SqlJsBackend extends EventEmitter implements IMemoryBackend { private config; private db; private initialized; private persistTimer; private SQL; private stats; constructor(config?: Partial); /** * Initialize the SqlJs backend */ initialize(): Promise; /** * Shutdown the backend */ shutdown(): Promise; /** * Create database schema */ private createSchema; /** * Store a memory entry */ store(entry: MemoryEntry): Promise; /** * Retrieve a memory entry by ID */ get(id: string): Promise; /** * Retrieve a memory entry by key within a namespace */ getByKey(namespace: string, key: string): Promise; /** * Update a memory entry */ update(id: string, updateData: MemoryEntryUpdate): Promise; /** * Delete a memory entry */ delete(id: string): Promise; /** * Query memory entries */ query(query: MemoryQuery): Promise; /** * Semantic vector search (limited without vector index) */ 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; /** * Persist changes to disk (sql.js is in-memory, needs explicit save) */ persist(): Promise; private ensureInitialized; private rowToEntry; private updateAccessTracking; private cosineSimilarity; private estimateMemoryUsage; } //# sourceMappingURL=sqljs-backend.d.ts.map