/** * UndoEdit tool: revert the most recent Edit or Write on a single file. * * Uses the per-runtime `EditHistory` stack: every successful Edit / * Write push a pre-mutation snapshot, and `UndoEdit` pops the top * snapshot to restore the prior state. * * The undo is guarded: we verify the current on-disk state still * matches what we recorded at the moment the mutation completed (via * mtime + SHA-256 hash). If anything has diverged since — another * Edit/Write that wasn't history-tracked, a formatter, cloud sync — * we refuse rather than overwrite unrelated changes. * * Reference: docs/cortex/tools/undo-edit.md */ import { Type, type Static } from 'typebox'; import type { EditHistory } from './shared/edit-history.js'; import type { FileMutationLock } from './shared/file-mutation-lock.js'; import type { ReadRegistry } from './shared/read-registry.js'; import type { ToolContentDetails } from '../types.js'; import type { CortexToolRuntime } from './runtime.js'; export declare const UndoEditParams: Type.TObject<{ file_path: Type.TString; }>; export type UndoEditParamsType = Static; export interface UndoEditDetails { filePath: string; /** The tool whose mutation was reverted (when the undo succeeds). */ revertedSource?: 'Edit' | 'Write'; /** True when the undo removed a file that Write had created. */ deleted?: boolean; /** True when the undo restored prior content to an existing file. */ restored?: boolean; /** True when the undo was rejected (no history, stale state, etc.). */ rejected?: boolean; /** Remaining history depth for this file after the operation. */ remainingDepth?: number; } export interface UndoEditToolConfig { runtime?: CortexToolRuntime | undefined; editHistory?: EditHistory | undefined; readRegistry?: ReadRegistry | undefined; fileMutationLock?: FileMutationLock | undefined; } export declare function createUndoEditTool(config: UndoEditToolConfig): { name: string; description: string; parameters: typeof UndoEditParams; execute: (params: UndoEditParamsType) => Promise>; }; //# sourceMappingURL=undo-edit.d.ts.map