import type { Store, StoreIndexOptions, StoreItem, StoreNamespace, StorePutOptions, StoreSearchOptions } from '../types/store.js'; import { type PostgresLikeClient } from './client.js'; /** Options for the Postgres store. */ export interface PostgresStoreOptions { /** Table name, optionally schema-qualified. Defaults to `nexus_store`. */ table?: string; /** Enables semantic search by embedding indexed fields on write. */ index?: StoreIndexOptions; /** * Stores embeddings as a pgvector column of this many dimensions and ranks in the database. The * extension must be installed. Without it, embeddings are kept as JSON and ranked in process, * which works on any Postgres and suits namespaces of a few thousand items. */ vectorDimensions?: number; /** Replaces the system clock, for tests. */ now?: () => Date; } /** The schema, as statements. With `vectorDimensions`, pgvector's extension is created too. */ export declare function storeMigration(options?: Pick): string[]; /** * Long-term memory in Postgres, with pgvector when it is available. * * The same contract as `MemoryStore` and `RedisStore`, checked by the same tests. Namespace prefixes * are matched on a `C`-collated key, so `['tenant-7']` never matches `['tenant-70']` and an index * serves the match. Expired items are hidden from every read at once; `sweep()` deletes them, for a * retention job. */ export declare class PostgresStore implements Store { private readonly client; private readonly options; private readonly table; private readonly now; constructor(client: PostgresLikeClient, options?: PostgresStoreOptions); /** Creates the table, indexes, and pgvector extension if configured. Never runs implicitly. */ migrate(): Promise; /** Stores an item, keeping its original `createdAt` when it replaces one. */ put(namespace: StoreNamespace, key: string, value: V, options?: StorePutOptions): Promise; /** Reads an item, or `undefined` when it does not exist or has expired. */ get(namespace: StoreNamespace, key: string): Promise | undefined>; /** Deletes an item. */ delete(namespace: StoreNamespace, key: string): Promise; /** * 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; }): Promise; /** Deletes expired items, returning how many went. Reads already hide them. */ sweep(): Promise; private embed; }