/** * FileSystemCheckpointStore — persistent checkpoint storage on disk. * * Stores checkpoint data as JSON arrays in `.rolebox/state/checkpoints/{task_id}.json`, * one array per task (supporting multiple checkpoints per task). * * Uses the same atomic write pattern (.tmp + renameSync) as TaskStateStore * and MetricsPersister to prevent file corruption from partial writes. */ import type { CheckpointData, CheckpointStore } from "../types.checkpoint.ts"; /** Maximum checkpoints retained per task. Older entries are evicted (FIFO). */ export declare const MAX_CHECKPOINTS_PER_TASK = 100; export declare class FileSystemCheckpointStore implements CheckpointStore { private directory; /** * @param directory Base workspace directory (usually process.cwd()). * Checkpoints are stored under `.rolebox/state/checkpoints/`. */ constructor(directory: string); /** * Append a checkpoint to the task's checkpoint array and persist to disk * atomically (tmp file + rename). */ saveCheckpoint(taskId: string, data: CheckpointData): Promise; /** * Read all checkpoints for a task and return the most recent (by created_at), * or null if none exist. */ getLatestCheckpoint(taskId: string): Promise; /** * Read all checkpoints for a task, sorted by created_at (newest first). */ listCheckpoints(taskId: string): Promise; /** * Delete the checkpoint file for a task. * No-op if the file does not exist. */ deleteCheckpoint(taskId: string): Promise; /** * Scan all checkpoint files, remove entries whose (created_at + ttl_ms) * is in the past relative to `now`, rewrite files that have remaining * entries, and delete files that become empty. * * @param ttlMs Time-to-live in milliseconds. Entries older than * (now - ttlMs) are removed. When ttlMs <= 0, all are expired. */ cleanupExpired(ttlMs: number): Promise; /** * Build a human-readable retry context string from the latest checkpoint. * Returns null when no checkpoint exists. */ buildRetryContext(taskId: string): Promise; /** * Check if at least one checkpoint exists for the given task. * Returns false when no checkpoint file exists, the file is corrupt, or the array is empty. * Lighter than getLatestCheckpoint when only existence matters. */ hasCheckpoint(taskId: string): Promise; /** Get the absolute path to the checkpoints directory. */ private getCheckpointsDir; /** Get the absolute path to a task's checkpoint file. */ private getCheckpointPath; /** * Read all checkpoint entries for a task from disk. * Returns an empty array if the file does not exist or is corrupt. */ private _readAll; } //# sourceMappingURL=checkpoint-store.d.ts.map