import type { GraphCheckpoint, GraphCheckpointer } from '../types/graph.js'; import type { OperationRecord, OperationStore } from '../types/operations.js'; /** Options for the in-process checkpointer. */ export interface MemoryGraphCheckpointerOptions { /** Checkpoints kept per thread, newest first. Defaults to 50. */ maxPerThread?: number; /** * Threads kept before the least recently written one is dropped. Defaults to 1,000. * * The cap is what makes this safe as a default: a service that runs graphs without ever resuming * them would otherwise grow without bound. Pass `Infinity` to keep every thread. */ maxThreads?: number; } /** * In-process checkpoint history. * * The default when `compile()` is given no checkpointer, and enough for a single process that wants * interrupts, resume, and time travel without a store. It does not survive a restart; * `OperationStoreCheckpointer` does. */ export declare class MemoryGraphCheckpointer implements GraphCheckpointer { private readonly threads; private readonly maxPerThread; private readonly maxThreads; constructor(options?: MemoryGraphCheckpointerOptions); /** * Stores a checkpoint, discarding any at the same or a later step of that thread, since those * belong to a rewound timeline. */ put(checkpoint: GraphCheckpoint): void; /** The latest checkpoint of a thread, or the one at a given step. */ get(threadId: string, step?: number): GraphCheckpoint | undefined; /** A thread's checkpoints, newest first. Defaults to 20. */ history(threadId: string, limit?: number): GraphCheckpoint[]; /** Deletes a thread's checkpoints. */ delete(threadId: string): void; /** Thread ids this checkpointer knows about. */ threadIds(): string[]; } /** Options for the operation-store checkpointer. */ export interface OperationStoreCheckpointerOptions { /** Checkpoints kept per thread. Defaults to 50. */ maxPerThread?: number; } /** * Persists checkpoints through the `OperationStore` that already backs durable operations. * * This is what makes a graph durable without the graph module depending on the operations runtime: * the store is imported as a type only, so `nexus-ai-pro/graph` stays small, and handing it a * `RedisOperationStore` is all it takes to make a thread survive a restart. * * Each checkpoint is one record at `#`, with a head record at `` naming * the latest step. Two records per superstep, in exchange for time travel and a resume point that * another process can read. */ export declare class OperationStoreCheckpointer implements GraphCheckpointer { private readonly store; private readonly maxPerThread; constructor(store: OperationStore, options?: OperationStoreCheckpointerOptions); /** Stores a checkpoint and moves the thread's head to it, pruning beyond `maxPerThread`. */ put(checkpoint: GraphCheckpoint): Promise; /** The latest checkpoint of a thread, or the one at a given step. */ get(threadId: string, step?: number): Promise; /** A thread's checkpoints, newest first. Defaults to 20. */ history(threadId: string, limit?: number): Promise; /** Deletes a thread's checkpoints and its head. */ delete(threadId: string): Promise; /** * Every thread with a checkpoint, read from the head records. Empty when the store cannot list, * since finding heads any other way would mean scanning every key. */ threadIds(): Promise; private readHead; /** * Writes one record, creating it when absent and otherwise updating in place. * * `update` is a compare-and-set on the record's sequence, so two workers advancing the same * thread cannot both win; the loser simply re-reads on its next step. */ private write; } interface ThreadHead { kind: 'graph-thread'; latest: number; steps: number[]; } /** Re-exported for the adapter's signature, so a caller need not import the operations types. */ export type { OperationRecord, OperationStore };