import type { Store, StoreIndexOptions, StoreItem, StoreNamespace, StorePutOptions, StoreSearchOptions } from '../types/store.js'; /** * The subset of a Redis client this store uses. * * Structural, as with the operation store and the rate-limit store, so `ioredis`, `node-redis`, an * Upstash client, or a fake in a test all work without this package depending on any of them. */ export interface RedisStoreLikeClient { /** Reads a key. */ get(key: string): Promise; /** Writes a key, with `PX` and a TTL in milliseconds when the item expires. */ set(key: string, value: string, mode?: string, ttl?: number): Promise; /** Deletes keys. */ del(key: string | string[]): Promise; /** Adds to a set. */ sadd(key: string, member: string): Promise; /** Removes from a set. */ srem(key: string, member: string): Promise; /** Reads a set. */ smembers(key: string): Promise; } /** Options for the Redis store. */ export interface RedisStoreOptions { /** Key prefix, so one Redis instance can hold several stores. Defaults to `nexus:store`. */ prefix?: string; /** Embeds items for semantic search. Without it, search matches text in the stored values. */ index?: StoreIndexOptions; /** Replaces the system clock, for tests. */ now?: () => Date; } /** * Long-term memory in Redis, so several processes share what an agent remembers. * * Expiry is Redis's own TTL, so an expired item costs nothing to skip. A namespace index is kept in * a set per namespace, which is what makes prefix search and `listNamespaces()` possible without * scanning the keyspace. */ export declare class RedisStore implements Store { private readonly client; private readonly options; private readonly prefix; private readonly now; constructor(client: RedisStoreLikeClient, options?: RedisStoreOptions); /** 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 Redis has expired it. */ 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; private namespacesUnder; private read; private embed; private itemKey; private namespaceKey; private indexKey; }