export interface FileSnapshot { /** Path relative to the workspace root. */ path: string; /** False when the file did not exist yet — reverting deletes it again. */ existed: boolean; content: string | null; /** Set when the file was too large to capture; such a file is never restored. */ skipped?: boolean; } export interface Checkpoint { id: string; label: string; timestamp: string; files: FileSnapshot[]; /** Git tree for an explicit whole-workspace restore point (tracked + non-ignored untracked). */ tree?: string; } /** Human-readable scope for checkpoint lists; a tree represents the entire workspace. */ export declare function checkpointScope(checkpoint: Pick): string; /** Creates a named whole-workspace restore point without modifying user files. */ export declare function createWorkspaceCheckpoint(cwd: string, label: string): Promise; /** Workspace-relative paths a tool call is about to modify. */ export declare function filesTouchedBy(toolName: string, argsJson: string): string[]; /** * KONECK's own bookkeeping and git's internals are never user work. The audit trail in * particular is a compliance record: rolling it back to undo a code change would erase * evidence of what the agent did, which is the opposite of what an audit log is for. */ export declare function isAgentState(relPath: string): boolean; /** Accumulates snapshots for one user message. Nothing is written until commit(). */ export declare class CheckpointRecorder { private readonly cwd; private readonly label; private readonly files; constructor(cwd: string, label: string); /** Captures a file's current state. First capture wins, so the snapshot is pre-turn state. */ capture(targetPath: string): Promise; get size(): number; /** True when this path is already captured, so the pre-turn snapshot is not overwritten. */ has(relPath: string): boolean; /** * Stores a snapshot whose contents came from somewhere other than the current disk state — * a git tree, for a file a shell command has already overwritten. First capture still wins. */ addSnapshot(snapshot: FileSnapshot): void; /** Persists the checkpoint. Returns null when the turn changed no files. */ commit(): Promise; } /** Captures the full working tree (including untracked files) as a git tree object. */ /** * How long a workspace snapshot may take before it stops being worth taking. * * A snapshot is `git add -A` into a throwaway index, which is fast in a repository with a history * and slow in one with nothing committed — there, every file in the working tree is hashed afresh * on every call. Measured on a real Next.js project with no commits: 8,086ms, against 98ms for a * repository of similar size that had a history. * * That snapshot runs before and after every shell command, so it was adding seconds to each one. A * session in that project ran 76 commands, and every successful one took about 3,800ms whatever it * was — `cat`, `curl`, `ls`, all the same floor, because the floor was not the command. * * It buys the ability to undo what a shell command changed, which is a convenience rather than a * correctness property. Paying seconds per command for it is a bad trade, and one nobody agreed to * because nobody could see it. */ export declare const SNAPSHOT_BUDGET_MS = 1500; /** How long the snapshot took when it was found to be too slow, or null while it is still worth doing. */ export declare function snapshotGaveUp(cwd: string): number | null; /** Forgets the measurement, so a workspace can be tried again. Exists for tests. */ export declare function resetSnapshotBudget(): void; export declare function snapshotTree(cwd: string, /** Injectable so the giving-up path can be driven without building an eight-second repository. */ budgetMs?: number): Promise; /** * Records the pre-command contents of every file a shell command changed, by diffing the * working tree against a snapshot taken before it ran. Returns the paths captured. */ export declare function captureCommandEffects(cwd: string, recorder: CheckpointRecorder, beforeTree: string): Promise; /** Newest first. */ export declare function listCheckpoints(cwd: string): Promise; export interface RevertResult { restored: string[]; deleted: string[]; skipped: string[]; /** Checkpoint of the pre-revert state, so a revert can itself be undone. */ undoId: string | null; } export interface CheckpointPreview { /** Files whose current state differs from what this restore point would put back. */ changes: string[]; /** Files intentionally not restorable, such as oversized file-tool snapshots. */ skipped: string[]; } /** * Computes a restore's effect without touching user files or creating an undo checkpoint. * * A checkpoint title is not enough evidence to safely choose an undo point after several agent * turns. This uses the same source of truth as `revertCheckpoint`, so preview and apply cannot * drift into describing different files. */ export declare function previewCheckpoint(cwd: string, checkpoint: Checkpoint): Promise; /** * Restores every file in a checkpoint. The current state is captured first, so an unwanted * revert can be reverted in turn. */ export declare function revertCheckpoint(cwd: string, checkpoint: Checkpoint): Promise; //# sourceMappingURL=checkpoint.d.ts.map