import { SerializerProtocol } from "./serde/base.js"; import { CheckpointMetadata, CheckpointPendingWrite, DeltaChannelHistory, PendingWrite } from "./types.js"; import { RunnableConfig } from "@langchain/core/runnables"; //#region src/base.d.ts /** @inline */ type ChannelVersion = number | string; type ChannelVersions = Record; interface Checkpoint { /** * The version of the checkpoint format. Currently 4 */ v: number; /** * Checkpoint ID {uuid6} */ id: string; /** * Timestamp {new Date().toISOString()} */ ts: string; /** * @default {} */ channel_values: Record; /** * @default {} */ channel_versions: Record; /** * @default {} */ versions_seen: Record>; } interface ReadonlyCheckpoint extends Readonly { readonly channel_values: Readonly>; readonly channel_versions: Readonly>; readonly versions_seen: Readonly>>>; } declare function deepCopy(obj: T): T; /** @hidden */ declare function emptyCheckpoint(): Checkpoint; /** @hidden */ declare function copyCheckpoint(checkpoint: ReadonlyCheckpoint): Checkpoint; interface CheckpointTuple { config: RunnableConfig; checkpoint: Checkpoint; metadata?: CheckpointMetadata; parentConfig?: RunnableConfig; pendingWrites?: CheckpointPendingWrite[]; } type CheckpointListOptions = { limit?: number; before?: RunnableConfig; filter?: Record; }; declare abstract class BaseCheckpointSaver { serde: SerializerProtocol; constructor(serde?: SerializerProtocol); /** * Prevent `JSON.stringify` from traversing backend clients (e.g. pg Pool * timers) when a checkpointer is present in runnable `configurable`. */ toJSON(): string; get(config: RunnableConfig): Promise; abstract getTuple(config: RunnableConfig): Promise; abstract list(config: RunnableConfig, options?: CheckpointListOptions): AsyncGenerator; abstract put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, newVersions: ChannelVersions): Promise; /** * Store intermediate writes linked to a checkpoint. */ abstract putWrites(config: RunnableConfig, writes: PendingWrite[], taskId: string): Promise; /** * Delete all checkpoints and writes associated with a specific thread ID. * @param threadId The thread ID whose checkpoints should be deleted. */ abstract deleteThread(threadId: string): Promise; /** * Walk the parent chain returning per-channel writes + seed, used to * reconstruct `DeltaChannel` state from `checkpoint_writes`. * * For each requested channel, walks ancestors of the checkpoint identified * by `config` (following `parentConfig`) and accumulates the pending writes * for that channel. The walk terminates per-channel at the nearest ancestor * whose `channel_values[ch]` is populated; that value is returned as `seed`. * If the walk reaches the root without finding a stored value, `seed` is * omitted from that channel's entry — the consumer treats the absence as * "start empty". * * Walks the parent chain (not `list({ before })`): for forked threads, only * on-path ancestors contribute. * * The default implementation walks `getTuple` + `parentConfig` once for all * channels — each ancestor visited once, not once per channel. Savers with * direct storage access (e.g. `MemorySaver`) override for performance; the * return contract is fixed here. * * @remarks Beta. The signature, return shape, and interaction with * `DeltaSnapshot` blobs may change. Override at your own risk; the default * implementation will continue to work against the public * `BaseCheckpointSaver` contract. * * @param options.config Configuration identifying the target checkpoint. * @param options.channels Channel names to walk for. Empty → empty mapping. * @returns Per-channel {@link DeltaChannelHistory} for every requested name. */ getDeltaChannelHistory(options: { config: RunnableConfig; channels: string[]; }): Promise>; /** * Generate the next version ID for a channel. * * Default is to use integer versions, incrementing by 1. If you override, you can use str/int/float versions, * as long as they are monotonically increasing. */ getNextVersion(current: V | undefined): V; } declare function compareChannelVersions(a: ChannelVersion, b: ChannelVersion): number; declare function maxChannelVersion(...versions: ChannelVersion[]): ChannelVersion; /** * Mapping from error type to error index. * Regular writes just map to their index in the list of writes being saved. * Special writes (e.g. errors) map to negative indices, to avoid those writes from * conflicting with regular writes. * Each Checkpointer implementation should use this mapping in put_writes. */ declare const WRITES_IDX_MAP: Record; /** * Metadata keys that are LangGraph's internal framework bookkeeping and * should not be surfaced as user-meaningful metadata. * * Consumed by stream handlers (e.g. the `tasks` debug stream) to drop * framework keys — which are redundant with a task's own fields and * namespace — while keeping keys like `lc_agent_name`, `ls_integration`, * and user-supplied metadata. */ declare const EXCLUDED_METADATA_KEYS: ReadonlySet; declare function getCheckpointId(config: RunnableConfig): string; //#endregion export { BaseCheckpointSaver, ChannelVersions, Checkpoint, CheckpointListOptions, CheckpointTuple, EXCLUDED_METADATA_KEYS, ReadonlyCheckpoint, WRITES_IDX_MAP, compareChannelVersions, copyCheckpoint, deepCopy, emptyCheckpoint, getCheckpointId, maxChannelVersion }; //# sourceMappingURL=base.d.ts.map