@tanstack/ai-persistence
Version:
Composable state persistence for TanStack AI messages, runs, interrupts, metadata, and locks.
34 lines (33 loc) • 1.62 kB
TypeScript
import { AIPersistence, AIPersistenceStores } from '../types.js';
type MakePersistence = () => Promise<AIPersistence> | AIPersistence;
/**
* Methods that are optional on the `RunStore` contract.
*
* `findActiveRun` is deliberately NOT here: it is REQUIRED, per the evolution
* policy in `../types.ts`. It was optional for one release cycle and silently
* disabled reconnect on every backend that had not caught up.
*/
type OptionalRunStoreMethod = 'listByThread' | 'listReclaimable';
/** Dotted `store.method` key a backend passes to declare an omitted method. */
export type PersistenceConformanceMethodKey = `runs.${OptionalRunStoreMethod}`;
export interface PersistenceConformanceOptions {
/**
* Store keys this backend intentionally does not provide. Any store that is
* absent from the persistence and NOT listed here fails the suite, so a
* dropped/misconfigured store can never pass silently.
*/
skip?: Array<keyof AIPersistenceStores>;
/**
* OPTIONAL store methods this backend intentionally does not implement, as
* `'runs.listByThread'` and friends. A method that is absent and NOT listed
* here fails the suite; a listed one is reported as a skipped case.
*/
skipMethods?: Array<PersistenceConformanceMethodKey>;
}
/**
* Register a Vitest suite that validates `makePersistence()` against the full
* `AIPersistence` contract — every store it provides, and none it declares
* skipped.
*/
export declare function runPersistenceConformance(name: string, makePersistence: MakePersistence, options?: PersistenceConformanceOptions): void;
export {};