refactor(core): simplify file tools to lexical paths - #40962
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Simplify the V2 file tools to match V1 and established agent-tool behavior:
How
LocationMutationnow usespath.resolve(location.directory, input.path)as its single absolute filesystem path and retains the existing lexicalexternal_directoryauthorization flow.non_directory_ancestorerror. Filesystem operations now report ordinary OS errors for invalid ancestors.ReadToolFileSystem.listusesreadDirectoryEntriestypes directly, preserves directory separators, and emits a tool-localsymlinkentry type without following or filtering links.TextDecoderbehavior while preserving null-byte/non-printable binary sniffing, media magic-byte handling, base64 ingestion, and media size limits.This follows V1 parity and the direction established by #38180, where external authorization became lexical. Cloudflare realpath PR #7515 was rejected because symlinks outside the working directory are permitted. The field survey across Codex, Gemini, OpenHands, Claude Code, pi-mono, and flue found no agent that escape-filters listed symlinks or hard-fails malformed UTF-8.
Scope
This PR deliberately does not change the streaming read state machine,
FileMutationBOM/locking/formatter behavior, AGENTS.md discovery, environment drivers, or process spawning.Testing
packages/core:bun typecheckpackages/core:bun run test(1,551 pass, 7 skip; only the known global-config leakage failure inconfig/plugin.test.ts)packages/server:bun typecheckpackages/protocol:bun typecheckpackages/cli:bun typecheckpackages/util:bun typecheckpackages/schema:bun typecheckpackages/client:bun typecheck