/** * Write tool: create a new file or overwrite an existing file. * * Enforces the read-before-write contract via ReadRegistry. * Performs atomic writes (write to temp, then rename) to prevent * partial writes on crash. Creates parent directories as needed. * * Reference: docs/cortex/tools/write.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 WriteParams: Type.TObject<{ file_path: Type.TString; content: Type.TString; }>; export type WriteParamsType = Static; export interface DiffHunk { oldStart: number; oldLines: number; newStart: number; newLines: number; lines: string[]; } export interface WriteDetails { filePath: string; isCreate: boolean; bytesWritten: number; diff: DiffHunk[] | null; originalContent: string | null; } export interface WriteToolConfig { runtime?: CortexToolRuntime | undefined; readRegistry?: ReadRegistry | undefined; fileMutationLock?: FileMutationLock | undefined; /** * Undo stack. When provided, every successful write pushes a * pre-mutation snapshot (or `null` when the file did not exist) so * `UndoEdit` can restore the prior state. */ editHistory?: EditHistory | undefined; } /** * Compute a safe line-level diff between two strings. * * This intentionally emits at most one changed hunk. The UI only needs a * compact, deterministic summary of the mutation, not a minimal diff. */ export declare function computeDiff(oldContent: string, newContent: string): DiffHunk[]; export declare function createWriteTool(config: WriteToolConfig): { name: string; description: string; parameters: typeof WriteParams; execute: (params: WriteParamsType) => Promise>; }; //# sourceMappingURL=write.d.ts.map