import type { Store, StoreIndexOptions, StoreItem, StoreNamespace, StorePutOptions, StoreSearchOptions } from '../types/store.js'; export { cosine, matches, readPath, textOf } from './helpers.js'; /** Options for the in-memory store. */ export interface MemoryStoreOptions { /** Enables semantic search by embedding indexed fields on write. */ index?: StoreIndexOptions; /** Items kept before the least recently written one is dropped. Defaults to 10,000. */ maxItems?: number; /** Replaces the system clock, for tests. */ now?: () => Date; } /** * In-process long-term memory. * * Enough for a single process, for tests, and for development; `RedisStore` and `PostgresStore` * carry the same contract across processes. Bounded like the graph's memory checkpointer, because a * store that only grows is a leak with a friendly name. */ export declare class MemoryStore implements Store { private readonly options; private readonly items; private readonly maxItems; /** Whether any item was ever given a time to live; until one is, there is nothing to sweep. */ private expiring; /** When expired items were last swept, in milliseconds. */ private sweptAt; private readonly now; constructor(options?: MemoryStoreOptions); /** Stores an item, keeping its original `createdAt` when it replaces one. */ put(namespace: StoreNamespace, key: string, value: V, options?: StorePutOptions): Promise; /** * Stores an item only when the stored one's `version` is `expected`, or, with `expected` `null`, * only when none is stored. The check and the write run with nothing in between. */ putIfVersion(namespace: StoreNamespace, key: string, value: V, expected: number | null): Promise; private write; /** Reads an item, or `undefined` when it does not exist or has expired. */ get(namespace: StoreNamespace, key: string): StoreItem | undefined; /** Deletes an item. */ delete(namespace: StoreNamespace, key: string): void; /** * Items under a namespace prefix, newest first, or ranked by similarity when a query is given. * Defaults to 20. */ search(namespacePrefix: StoreNamespace, options?: StoreSearchOptions): Promise>>; /** Namespaces under a prefix. Defaults to 100. */ listNamespaces(options?: { prefix?: StoreNamespace; limit?: number; }): string[][]; /** Items currently held, expired ones excluded. */ size(): number; private embed; private expired; /** * Drops expired items. Reads already skip them, so this only reclaims memory: it runs once any item * has a time to live, and at most once a second, so a write stays constant-time however many items * there are. A store that is full sweeps before it evicts, so a live item never makes way for an * expired one. */ private sweep; }