feat(node-vfs): enhance VfsSandbox to support absolute paths execute#322
Merged
Christian Bromann (christian-bromann) merged 4 commits intolangchain-ai:mainfrom Mar 20, 2026
Merged
Conversation
…nds and add related integration tests - Implemented a method to rewrite absolute paths in commands referencing VFS entries to point to the temporary directory. - Added integration tests for executing multi-file Node.js projects with both absolute and relative paths. - Updated existing tests to clarify path usage in commands.
🦋 Changeset detectedLatest commit: 343f0f4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Christian Bromann (christian-bromann)
approved these changes
Mar 18, 2026
Member
Christian Bromann (christian-bromann)
left a comment
There was a problem hiding this comment.
LGTM 👍
Contributor
Author
|
Christian Bromann (@christian-bromann) Thank you for your feedback. I’ll fix the |
commit: |
8dc4e9c
into
langchain-ai:main
12 checks passed
Merged
Contributor
Author
|
Christian Bromann (@christian-bromann) thank you for your approve. i'll be appreciate if you could help me to review another pr? |
Colin Francis (colifran)
pushed a commit
that referenced
this pull request
Mar 24, 2026
…322) * feat(node-vfs): enhance VfsSandbox to support absolute paths in commands and add related integration tests - Implemented a method to rewrite absolute paths in commands referencing VFS entries to point to the temporary directory. - Added integration tests for executing multi-file Node.js projects with both absolute and relative paths. - Updated existing tests to clarify path usage in commands. * fix(node-vfs): add changeset for rewriting absolute VFS paths in execute() commands * fix: ci --------- Co-authored-by: wangjiangjian.0224 <wangjiangjian.0224@bytedance.com>
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.
fix(node-vfs): rewrite absolute VFS paths in execute() commands
Summary
VfsSandbox.execute()to support absolute paths (e.g.node /src/index.js) by rewriting them to the temp directory path before shell executionProblem
When users define
initialFileswith absolute paths like/src/index.js, the VFS correctly stores and syncs files to a temp directory for execution. However, commands referencing those files with absolute paths fail:The
#normalizeExecPathmethod already handles leading/forread(),ls(),grep(),glob(), butexecute()passes the raw command string directly to/bin/bash -cwithout any path translation.Solution
Add a
#rewriteVfsPaths(command, execDir)private method that:src,data.json)/<name>at path-token boundaries in the command<tempDir>/<name>The regex uses negative lookbehind (
(?<![\w/.-])) and positive lookahead ((?=/|[\s"';|&><!]|$)) to ensure only standalone absolute path tokens are rewritten, leaving system paths like/bin/bashor/usr/local/bin/nodeuntouched (sincebin,usrare not VFS entries).Test plan
should run a multi-file Node.js project with absolute paths— verifiesnode /src/index.jswith cross-filerequire()should access initialFiles with leading slash via execute() using absolute path— verifies single-file absolute path executionshould run a multi-file Node.js project with absolute paths from README (absolute execute)— mirrors README example with absolute path