import type { ToolOperations } from "./operations.js"; /** A 1-based, inclusive range of line numbers. */ export type LineRange = readonly [start: number, end: number]; export interface ReadEntry { mtimeMs: number; hash: string; /** Lines in the content `hash` covers (a trailing newline does not add one). */ lineCount: number; /** * How much of that content the model has been shown: `"all"`, or the merged, * sorted line ranges seen so far. A full-file `write` requires `"all"`. */ seen: "all" | readonly LineRange[]; } export type ReadTracker = Map; export declare function hashContent(content: string): string; /** Line count as the read tool numbers lines, not counting the empty "line" after a final newline. */ export declare function countLines(content: string): number; /** * Record that the model was shown `shown` (default: every line) of `content`. * Reads of unchanged content accumulate, so paging through a long file with * offset/limit eventually counts as having seen all of it. */ export declare function recordRead(tracker: ReadTracker | undefined, resolvedPath: string, content: string, mtimeMs: number, shown?: LineRange): void; /** * Record the model's own change to a file. `write` supplies every line itself, * so the model knows the whole result. `edit` changes only part of a file, so * it knows the whole result only if it had already seen all of the original. */ export declare function recordWrite(tracker: ReadTracker | undefined, resolvedPath: string, content: string, ops: ToolOperations, scope?: "whole" | "edit"): Promise; /** * Lines of the file as it is on disk now that the model has not been shown: * `"all"` when it never read the file or the file changed since its last * read/write (mtime, else content hash), otherwise the gaps between the ranges * it has seen (empty when it has seen every line). A full-file `write` uses * this to report which lines it removed without the model having seen them. */ export declare function unseenLines(tracker: ReadTracker | undefined, resolvedPath: string, ops: ToolOperations): Promise<"all" | readonly LineRange[]>; /** * True when the recorded read still matches disk (mtime, else content hash). * A hash match after an mtime-only change refreshes the recorded mtime. */ export declare function isFresh(tracker: ReadTracker, resolvedPath: string, ops: ToolOperations): Promise;