Repository navigation
[sandbox-cli] Add read, write, and recursive copy for agent-friendly file I/O - #380
Draft
roboeve[bot] wants to merge 1 commit into
Draft
roboeve[bot] wants to merge 1 commit into
roboeve[bot] wants to merge 1 commit into
Conversation
Adds sandbox read, sandbox write, and sandbox copy --recursive so coding agents can work with sandbox files without shell workarounds. Failed copies now exit non-zero.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| })), | ||
| ); | ||
| await sandbox.writeFiles(contents); | ||
| done += batch.length; |
Contributor
This branch was successfully deployed
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.
Adds
sandbox read,sandbox write, andsandbox copy --recursiveso a coding agent can drive a sandbox's filesystem from the CLI without shell workarounds.Why
Agents like Claude Code can already run commands through
sandbox exec, but file I/O is awkward:sandbox copymoves one file per call, so pushing a project means tarring it locally, copying the tarball, and extracting it withexec.exec -- catand shell heredocs, which brings quoting bugs (zsh globs, nested quotes) and mixes file contents with command output.Approach
Add the three missing primitives on top of existing SDK calls, with no API changes:
sandbox read <name>:<path>(aliascat) streams the file's raw bytes to stdout viasandbox.readFile. Errors go to stderr with a non-zero exit, so output is safe to pipe.sandbox write <name>:<path> [--mode 755]reads stdin and writes it withsandbox.writeFiles. If stdin is a TTY it exits with a hint instead of hanging.sandbox copy -r <src> <dst>copies directories in both directions. The contents ofsrcland insidedst.writeFiles.find <dir> -type f -printf '%P\0'(NUL-separated, so odd filenames are safe), then reads them with up to 8 in flight.-ron a single file falls back to a normal file copy. Copying a local directory without-rfails with a hint.Paths use the same
SANDBOX_NAME:PATHsyntax ascopy, so there is one convention to learn.Validation
pnpm typecheckpasses.pnpm vitest run: 28 files, 235 tests pass.test/commands/file-commands.test.tsruns the real command handlers against a fake sandbox backed by a temp directory (realfind). It covers acopy -rround trip with modes kept, the no--rdirectory error,-ron a single file,readwriting exact bytes to stdout,readexiting non-zero on a missing file, andwritefrom stdin with--mode.findoutput parsing, mode parsing, and the concurrency limit.writeto a path whose parent directory doesn't exist yet, and a largecopy -rupload.Relevant context
src/util/file-transfer.ts.docs/index.mdwas regenerated, andscripts/print-usage.tsnow includes the new commands.sandboxskill's CLI section documents the new commands.minorbump ofsandbox.