import { type TruncationResult } from "@caupulican/pi-agent-core/truncate"; import type { AgentTool } from "@caupulican/pi-agent-core/types"; import { type Static, Type } from "typebox"; import type { ToolDefinition } from "../extensions/types.ts"; import { type FileFailureRecoveryAuthority } from "./file-failure-recovery.ts"; declare const readSchema: Type.TObject<{ path: Type.TString; offset: Type.TOptional; limit: Type.TOptional; lineNumbers: Type.TOptional; tail: Type.TOptional; filter: Type.TOptional, Type.TLiteral<"minimal">, Type.TLiteral<"aggressive">]>>; }>; export type ReadToolInput = Static; export interface ReadToolDetails { truncation?: TruncationResult; } /** * Pluggable operations for the read tool. * Override these to delegate file reading to remote systems (for example SSH). */ export interface ReadOperations { /** Read file contents as a Buffer */ readFile: (absolutePath: string) => Promise; /** Check if file is readable (throw if not) */ access: (absolutePath: string) => Promise; /** Detect image MIME type, return null or undefined for non-images */ detectImageMimeType?: (absolutePath: string) => Promise; /** File size in bytes, used to decide between whole-file and sliced reads. */ stat?: (absolutePath: string) => Promise<{ size: number; }>; /** * Stream a slice of lines out of the file with bounded memory. Any region of an * arbitrarily large file stays reachable in batches via offset continuation. */ readLineSlice?: (absolutePath: string, options: LineSliceOptions) => Promise; /** Count lines by streaming (bounded memory); used to resolve tail reads on oversized files. */ countLines?: (absolutePath: string) => Promise; } export interface LineSliceOptions { /** 0-based line to start collecting at. */ startLine: number; /** Maximum number of lines to collect. */ maxLines: number; /** Maximum total characters to collect across lines. */ maxChars: number; } export interface LineSlice { lines: { text: string; originalIndex: number; }[]; /** True when the end of the file was reached while collecting. */ reachedEnd: boolean; } export interface ReadToolOptions { /** Whether to auto-resize images to 2000x2000 max. Default: true */ autoResizeImages?: boolean; /** Custom operations for file reading. Default: local filesystem */ operations?: ReadOperations; /** Shared backend identity for exact cross-tool recovery with custom operations. */ failureRecoveryAuthority?: FileFailureRecoveryAuthority; /** Whole-file load budget for text reads; larger files stream line slices instead. Default 16 MiB. */ maxTextReadBytes?: number; /** Pathology guard for image reads; larger images return downscale guidance. Default 128 MiB. */ maxImageReadBytes?: number; } export declare function createReadToolDefinition(cwd: string, options?: ReadToolOptions): ToolDefinition; export declare function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool; export {}; //# sourceMappingURL=read.d.ts.map