/** * @massa-th0th/core - Read File Tool * * Optimized file reading with: * - Automatic compression for large files * - Intelligent caching * - Symbol metadata integration * - Multi-range support * - Language detection */ import { IToolHandler, ToolResponse } from "@massa-th0th/shared"; import { SymbolGraphService } from "../services/symbol/symbol-graph.service.js"; export declare class ReadFileTool implements IToolHandler { name: string; description: string; inputSchema: { type: string; properties: { filePath: { type: string; description: string; }; projectId: { type: string; description: string; }; offset: { type: string; description: string; }; limit: { type: string; description: string; }; lineStart: { type: string; description: string; }; lineEnd: { type: string; description: string; }; compress: { type: string; description: string; default: boolean; }; targetRatio: { type: string; description: string; default: number; }; format: { type: string; enum: string[]; description: string; default: string; }; includeSymbols: { type: string; description: string; default: boolean; }; includeImports: { type: string; description: string; default: boolean; }; }; required: string[]; }; private compressor; private symbolGraph?; private fileCache; private projectRootCache; private readonly CACHE_TTL; private readonly ROOT_CACHE_TTL; /** * Maximum entries retained in each in-memory cache. Without a cap, an * adversarial caller cycling distinct cache keys grows the map for the * process lifetime. Map preserves INSERTION order in JS; we promote a key * to most-recently-used on GET via delete+set, and evict the oldest key on * SET while over the cap. Mirrors WebController's WEB_CACHE_MAX_ENTRIES. */ private readonly FILE_CACHE_MAX_ENTRIES; constructor(symbolGraph?: SymbolGraphService); handle(params: unknown): Promise; /** * Resolve a filePath to an absolute path. * * Resolution rules: * - Absolute path → returned verbatim (still normalized via path.resolve, but base-independent). * - `projectId` present → resolved against the workspace `project_path`. If the * workspace lookup fails (no root), this returns null (ambiguous). * - No `projectId` AND relative `filePath` → returns null. We deliberately do NOT * fall back to `path.resolve(filePath)` against process.cwd(), because a relative * path arriving without a projectId is ambiguous and historically read from * the * server's cwd (COVERAGE finding #3). Callers must provide an absolute path or * a projectId. * * Returns null to signal an ambiguous/unsatisfiable path so `handle()` can map it * to a distinct, clear error instead of the generic "Failed to read file" catch. */ private resolveFilePath; private getProjectRoot; /** * Evict the oldest (first-inserted) entries from a cache Map until it is * under FILE_CACHE_MAX_ENTRIES. Called BEFORE the new insert so the cap is * honored post-insert with a single iteration. */ private evictOldest; private calculateRange; private adjustRange; private readFileWithCache; private extractMetadata; private extractLines; private detectLanguage; private extractImports; } //# sourceMappingURL=read_file.d.ts.map