/** * SQLite FTS5 memory store. Full-text search with BM25 ranking. * * Interface (implements Memory store contract): * store(content, metadata) → id * search(query, options) → [{ id, content, metadata, score }] * get(id) → { content, metadata } * delete(id) → void * * Requires peer dep: better-sqlite3 */ export type ChunkRow = { id: number; content: string; /** * - JSON-serialized metadata. */ metadata: string; /** * - FTS5 rank (search rows only). */ rank?: number | undefined; }; /** * SQLite FTS5 memory store. Full-text search with BM25 ranking. * * Interface (implements Memory store contract): * store(content, metadata) → id * search(query, options) → [{ id, content, metadata, score }] * get(id) → { content, metadata } * delete(id) → void * * Requires peer dep: better-sqlite3 * * @typedef {object} ChunkRow * @property {number} id * @property {string} content * @property {string} metadata - JSON-serialized metadata. * @property {number} [rank] - FTS5 rank (search rows only). */ export class SQLiteStore { /** * @param {{ path?: string }} [options] * @throws {Error} `[SQLiteStore] requires options.path` — when path is missing. * @throws {Error} `[SQLiteStore] requires better-sqlite3` — when peer dep is not installed. * @name SQLite * @when you want durable, queryable SQLite-backed storage for Memory (store/search/get/delete) persisted on disk * @fails throws on a missing path or an absent better-sqlite3 peer dep; implements the four-verb Store socket. * @example * const store = new SQLite({ path: './agent.db' }); */ constructor(options?: { path?: string; }); _db: any; _insertStmt: any; _getStmt: any; _deleteStmt: any; _searchStmt: any; _allStmt: any; /** * @param {any} content * @param {Record} [metadata] * @returns {number} id */ store(content: any, metadata?: Record): number; /** * @param {string} query * @param {{ limit?: number }} [options] * @returns {Array<{ id: number, content: string, metadata: Record, score: number }>} */ search(query: string, options?: { limit?: number; }): Array<{ id: number; content: string; metadata: Record; score: number; }>; /** * @param {number} id * @returns {{ id: number, content: string, metadata: Record } | null} */ get(id: number): { id: number; content: string; metadata: Record; } | null; /** * @param {number} id * @returns {void} */ delete(id: number): void; close(): void; }