import type { PromptHistoryEntry, PromptLabel, PromptStore, PromptVersion } from '../types/prompts.js'; /** * The Redis commands the prompt store needs, in `ioredis` argument order. * * Structural, as with the other Redis adapters, so no Redis client becomes a dependency. */ export interface RedisPromptLikeClient { /** Sets a hash field only when it does not exist, resolving to 1 when it was set. */ hsetnx(key: string, field: string, value: string): Promise | number | unknown; /** Sets a hash field. */ hset(key: string, field: string, value: string): Promise | unknown; /** Reads a hash field. */ hget(key: string, field: string): Promise | string | null; /** Reads every hash value. */ hvals(key: string): Promise | string[]; /** Deletes a hash field, resolving to the number removed. */ hdel(key: string, field: string): Promise | number | unknown; /** Pushes onto the head of a list. */ lpush(key: string, value: string): Promise | unknown; /** Reads a range of a list. */ lrange(key: string, start: number, stop: number): Promise | string[]; /** Trims a list to a range. */ ltrim(key: string, start: number, stop: number): Promise | unknown; /** Adds to a set. */ sadd(key: string, member: string): Promise | unknown; /** Reads a set. */ smembers(key: string): Promise | string[]; /** Optional atomic primitive. Strongly preferred, so that label compare-and-set is one step. */ eval?(script: string, numKeys: number, ...args: string[]): Promise | unknown; } /** Options for the Redis prompt store. */ export interface RedisPromptStoreOptions { /** Key prefix. Defaults to `nexus-ai-pro:prompts:`. */ prefix?: string; /** History entries kept per prompt. Defaults to 1,000. */ maxHistory?: number; /** Disables the Lua compare-and-set even when the client exposes `eval`. */ useEval?: boolean; } /** * Prompt versions, labels, and history in Redis, shared by every process that serves prompts. * * Versions sit in one hash per prompt with a list keeping their order; labels in another hash, * written by a Lua compare-and-set when the client has `eval`; history in a capped list. */ export declare class RedisPromptStore implements PromptStore { private readonly client; private readonly options; private readonly prefix; private readonly useEval; constructor(client: RedisPromptLikeClient, options?: RedisPromptStoreOptions); /** Stores a version, unless one with the same content version exists. */ saveVersion(version: PromptVersion): Promise; /** Reads a version. */ getVersion(name: string, version: string): Promise; /** Versions of a prompt, newest first. Defaults to 50. */ listVersions(name: string, options?: { limit?: number; }): Promise; /** Reads a label. */ getLabel(name: string, label: string): Promise; /** Every label of a prompt, sorted by name. */ listLabels(name: string): Promise; /** Writes a label when it still points at `expected`, in one step when the client has `eval`. */ setLabel(label: PromptLabel, expected?: string | null): Promise; /** Removes a label. Resolves true when it existed. */ deleteLabel(name: string, label: string): Promise; /** Records a change, trimming the history to `maxHistory`. */ appendHistory(entry: PromptHistoryEntry): Promise; /** A prompt's history, newest first, optionally for one label. Defaults to 100. */ listHistory(name: string, options?: { label?: string; limit?: number; }): Promise; /** Every prompt name, sorted. */ listNames(): Promise; private key; }