tasq/node_modules/@claude-flow/memory/dist/sqlite-backend.d.ts

121 lines
3.5 KiB
TypeScript

/**
* 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<SQLiteBackendConfig>);
/**
* Initialize the SQLite backend
*/
initialize(): Promise<void>;
/**
* Shutdown the backend
*/
shutdown(): Promise<void>;
/**
* Store a memory entry
*/
store(entry: MemoryEntry): Promise<void>;
/**
* Get a memory entry by ID
*/
get(id: string): Promise<MemoryEntry | null>;
/**
* Get a memory entry by key within a namespace
*/
getByKey(namespace: string, key: string): Promise<MemoryEntry | null>;
/**
* Update a memory entry
*/
update(id: string, update: MemoryEntryUpdate): Promise<MemoryEntry | null>;
/**
* Delete a memory entry
*/
delete(id: string): Promise<boolean>;
/**
* Query memory entries with filters
*/
query(query: MemoryQuery): Promise<MemoryEntry[]>;
/**
* Semantic vector search (not optimized for SQLite, returns empty)
* Use HybridBackend for semantic search with AgentDB
*/
search(embedding: Float32Array, options: SearchOptions): Promise<SearchResult[]>;
/**
* Bulk insert entries
*/
bulkInsert(entries: MemoryEntry[]): Promise<void>;
/**
* Bulk delete entries
*/
bulkDelete(ids: string[]): Promise<number>;
/**
* Get entry count
*/
count(namespace?: string): Promise<number>;
/**
* List all namespaces
*/
listNamespaces(): Promise<string[]>;
/**
* Clear all entries in a namespace
*/
clearNamespace(namespace: string): Promise<number>;
/**
* Get backend statistics
*/
getStats(): Promise<BackendStats>;
/**
* Perform health check
*/
healthCheck(): Promise<HealthCheckResult>;
private ensureInitialized;
private createSchema;
private rowToEntry;
/**
* Synchronous store for use in transactions
*/
private storeSync;
}
export default SQLiteBackend;
//# sourceMappingURL=sqlite-backend.d.ts.map