import type { ToolResult } from "../types.js"; export declare function writeFileAtomic(resolved: string, contents: string): Promise; /** * Decide whether a path falls inside configured sandbox roots / cwd / home. * Used for UX (outside-cwd confirm) and optional sandboxReads opt-in. * Writes are not hard-blocked by sandbox — outside cwd always prompts instead. */ export declare function pathInsideSandbox(resolvedPath: string, mode: "read" | "write"): boolean; /** * True when a write sits outside the working directory and active project * root, but not system temp / scratch (agent scratch lives under tmpdir and * must not spam confirmations). Default permissions confirm such writes; * allow-all auto-approves them. Deletes are handled separately and always * confirm. */ export declare function isOutsideWorkingDirectory(resolvedPath: string): boolean; /** Resolve a tool path for permission checks (tilde + project root). */ export declare function resolveFsToolPath(path: string): string; export interface FsReadOptions { maxBytes?: number | undefined; confirmed?: boolean | undefined; /** 1-indexed first line to return (inclusive). */ offset?: number | undefined; /** Max number of lines to return from `offset`. */ limit?: number | undefined; /** Alias for `offset` (1-indexed inclusive). */ startLine?: number | undefined; /** Inclusive end line; implies a line window when set. */ endLine?: number | undefined; /** Regex source (no surrounding slashes). Return matching windows with context. */ pattern?: string | undefined; /** Lines of context each side of a pattern match (default 2, max 20). */ context?: number | undefined; /** Max pattern matches to return (default 20, hard max 100). */ maxMatches?: number | undefined; /** Case-insensitive pattern match. */ caseInsensitive?: boolean | undefined; } export declare function fsRead(path: string, options?: FsReadOptions): Promise; export declare function fsWrite(path: string, content: string, options?: { confirmed?: boolean | undefined; }): Promise; /** Atomically replace an inclusive, 1-indexed line range in an existing file. */ export declare function fsReplaceLines(path: string, startLine: number, endLine: number, content: string, options?: { confirmed?: boolean | undefined; }): Promise; export interface FileWrite { path: string; content: string; } /** * Write several files in a single tool call. This is the workhorse for * scaffolding a project: a React app, an Express server, etc. all need a * handful of files, and forcing one fs.write per file burns through the * agent's step budget (the most common reason a scaffold never finished). * * Each entry is validated and written independently — a bad path does not * abort the whole batch. Parent directories are created automatically, just * like fs.write. */ export declare function fsWriteMany(files: FileWrite[], options?: { confirmed?: boolean | undefined; }): Promise; export declare function fsList(path: string, options?: { maxEntries?: number | undefined; confirmed?: boolean | undefined; }): Promise; export declare function fsSearch(pattern: string, path?: string, options?: { confirmed?: boolean | undefined; /** Max matching lines to return (default 50, hard cap 200). */ maxMatches?: number | undefined; /** Max hits per file (default 20). */ maxPerFile?: number | undefined; /** Glob filter passed to ripgrep -g (e.g. "*.ts"). */ glob?: string | undefined; /** Case-insensitive search (-i). */ caseInsensitive?: boolean | undefined; /** Treat the pattern as a literal string (-F). */ fixedString?: boolean | undefined; /** Lines of context around each hit (-C). */ context?: number | undefined; /** Report matching file names only (-l). */ filesOnly?: boolean | undefined; /** Include hidden files/directories (--hidden). */ hidden?: boolean | undefined; timeoutMs?: number | undefined; }): Promise; /** * Atomic search-and-replace edit. Reads the file, validates the match * count, performs replacement, and writes back. */ export declare function fsEdit(path: string, oldText: string, newText: string, expectedReplacements?: number | undefined, options?: { confirmed?: boolean | undefined; }): Promise; /** * Delete a file or directory. Requires the path to be inside the * write sandbox and not a secret path. */ export declare function fsDelete(path: string, recursive?: boolean | undefined, options?: { confirmed?: boolean | undefined; }): Promise; export declare function fsAppend(path: string, content: string, options?: { position?: "start" | "end" | undefined; confirmed?: boolean | undefined; /** * Optional integrity check: expected UTF-8 byte length of the file * *before* this append. Prevents double-append / wrong-base corruption * when continuing a truncated write. */ expectedPriorBytes?: number | undefined; }): Promise;