/** * File Tools Module - Built-in workspace inspection tools for LLM workflows. * * Features: * - Exposes built-in `read_file`, `write_file`, `list_files`, and `grep` tool definitions * - Supports bounded line-based file reads with offset and limit * - Provides deterministic directory listing with optional hidden-file support * - Performs recursive text search with plain-text or regex matching * - Supports optional glob-like include filtering for `grep` * * Implementation Notes: * - Paths resolve relative to runtime working directory context when provided * - Tool outputs are JSON strings for deterministic downstream parsing * - Search depth and output volume are bounded to avoid runaway scans * - Errors are returned as tool-friendly `Error:` strings * * Recent Changes: * - 2026-03-12: Added `read` permission level guard to `write_file` — returns a blocked-tool error when world toolPermission is 'read'. * - 2026-03-03: Tightened tool output limits: read_file hard-capped at 200 lines, list_files capped at depth 2 and 200 entries, grep capped at 50 hits with configurable context_lines (2–5). * - 2026-03-01: Hardened `read_file` against undefined read payloads from mocked fs implementations by coercing to empty content instead of hard-failing. * - 2026-03-01: Added read_file fallback that resolves missing relative paths against loaded skill roots (for skill script paths like `scripts/convert.py`). * - 2026-03-01: Allowed read-only file tools to traverse lexically in-scope `.agents/skills/*` paths even when symlinks resolve outside the world directory (skill workspace compatibility). * - 2026-02-28: Added built-in `write_file` tool with explicit `create`/`overwrite` modes and trusted-scope path enforcement. * - 2026-02-21: Added `list_files` output bounding (`maxEntries`) and optional `includePattern` filtering with truncation metadata to reduce continuation token spikes and tool-hop churn on large workspaces. * - 2026-02-19: Aligned file-tool path behavior with `shell_cmd`: `list_files` now defaults to trusted working directory when `path` is omitted, and `read_file` accepts `path` alias. * - 2026-02-16: Switched `list_files` scanning to `fast-glob` with depth control and default ignore rules. * - 2026-02-16: Added optional `recursive` mode to `list_files` for nested directory traversal in a single call. * - 2026-02-16: `list_files` now includes hidden dot-prefixed entries by default (set `includeHidden: false` to exclude). * - 2026-02-16: Switched `path` import to namespace style for Vitest mock compatibility. * - 2026-02-16: Initial implementation of built-in file inspection tools. * - 2026-02-16: Enhanced `list_files` empty-directory and not-found reporting with structured flags. */ type ToolContext = { workingDirectory?: string; world?: { variables?: string; [key: string]: unknown; }; chatId?: string | null; toolCallId?: string; agentName?: string; messages?: Array>; }; export declare function createReadFileToolDefinition(): { description: string; parameters: { type: string; properties: { filePath: { type: string; description: string; }; path: { type: string; description: string; }; offset: { type: string; description: string; }; limit: { type: string; description: string; }; }; required: never[]; additionalProperties: boolean; }; execute: (args: any, _sequenceId?: string, _parentToolCall?: string, context?: ToolContext) => Promise; }; export declare function createWriteFileToolDefinition(): { description: string; parameters: { type: string; properties: { filePath: { type: string; description: string; }; path: { type: string; description: string; }; content: { type: string; description: string; }; mode: { type: string; enum: string[]; description: string; }; }; required: string[]; additionalProperties: boolean; }; execute: (args: any, _sequenceId?: string, _parentToolCall?: string, context?: ToolContext) => Promise; }; export declare function createListFilesToolDefinition(): { description: string; parameters: { type: string; properties: { path: { type: string; description: string; }; includeHidden: { type: string; description: string; }; recursive: { type: string; description: string; }; maxDepth: { type: string; description: string; }; includePattern: { type: string; description: string; }; maxEntries: { type: string; description: string; }; }; required: never[]; additionalProperties: boolean; }; execute: (args: any, _sequenceId?: string, _parentToolCall?: string, context?: ToolContext) => Promise; }; export declare function createGrepToolDefinition(): { description: string; parameters: { type: string; properties: { query: { type: string; description: string; }; isRegexp: { type: string; description: string; }; directoryPath: { type: string; description: string; }; includePattern: { type: string; description: string; }; maxResults: { type: string; description: string; }; contextLines: { type: string; description: string; }; }; required: string[]; additionalProperties: boolean; }; execute: (args: any, _sequenceId?: string, _parentToolCall?: string, context?: ToolContext) => Promise; }; export {};