export type Store = import("../types").Store; /** * Persistence + search across turns and sessions. * Thin wrapper that delegates to a swappable store. * * Interface: * store(content, metadata) → id * search(query, options) → [{ id, content, metadata, score }] * get(id) → { content, metadata } * delete(id) → void * * Stores (swappable): * SQLite FTS5 — store-sqlite.js (peer dep: better-sqlite3) * JSON file — store-jsonfile.js (zero deps) * Bring your own: implement { store, search, get, delete } */ /** @typedef {import('../types').Store} Store */ export class Memory { /** * @param {{ store?: Store }} [options] - Store backend (must implement store/search/get/delete). * @throws {Error} `[Memory] requires options.store` — when options.store is missing. * @when you want thin store-backed memory (store/search/get/delete) an agent can write to and recall from, over any swappable backend * @fails throws if constructed without a store; recall/store metering is opt-in via ctx. All persistence delegates to the backend. * @example * const memory = new Memory({ store: new JsonFile({ path: './mem.json' }) }); * await memory.store({ text: 'a durable fact' }); */ constructor(options?: { store?: Store; }); /** @type {Store} */ _store: Store; /** * @param {any} content * @param {Record} [metadata] - Stored alongside the content; persisted to the backend. * @param {Record} [opts] - Transient call options (NOT persisted). If `opts.ctx` carries a * Loop-lent `recordMemoryOp` hook, this write is counted against that run's `result.metrics.memory.stored` * (§3.6, opt-in — the write-side mirror of search's `recalls`). `ctx` rides here, never in `metadata`, * precisely because `metadata` is persisted. Memory stays Loop-agnostic: it only calls an optional hook. * @returns {any} id */ store(content: any, metadata?: Record, opts?: Record): any; /** * @param {string} query * @param {Record} [options] - Store search options. If `options.ctx` carries a Loop-lent * `recordMemoryOp` hook, this recall is counted against that run's `result.metrics.memory.recalls` * (§3.6, opt-in — the hook is absent unless the caller threads the run's ctx). Memory stays * Loop-agnostic: it only calls an optional hook, and `ctx` is stripped, never forwarded to the store. * @returns {any} */ search(query: string, options?: Record): any; /** * @param {any} id * @returns {any} */ get(id: any): any; /** * @param {any} id * @returns {any} */ delete(id: any): any; }