87ceec29d9
Adds stdin piping support to `e2b sandbox exec`, so users can do:
```bash
echo "data" | e2b sandbox exec <id> -- cat
cat file.bin | e2b sandbox exec <id> -- python3 -c 'import sys;
print(len(sys.stdin.buffer.read()))'
```
Included:
- JS SDK updates:
- closeStdin()
- supportsStdinClose
- CLI updates:
- detects piped stdin
- streams stdin in 64 KiB chunks
- closes remote stdin on EOF
- graceful fallback for older sandbox versions (requires `envd` >= 0.5.2, warn + ignore piped input)
### Example Usage
#### non-piped exec still works
```
e2b sandbox exec <sandbox_id> -- 'echo backend-non-pipe'
```
#### piped stdin path (supported envd) should deliver bytes
```
echo "hello" | e2b sandbox exec <sandbox_id> -- 'wc -c' # expect 6
printf '\x00\x01\x02\xff' | $e2b sandbox exec <sandbox_id> -- 'wc -c' #
expect 4
```
#### optional: legacy template behavior should warn + ignore piped stdin
```
echo "hello" | e2b sandbox exec <legacy_sandbox_id> -- 'wc -c' # expect
0 + "Ignoring piped stdin."
```
E2B CLI
This CLI tool allows you to build manager your running E2B sandbox and sandbox templates. Learn more in our documentation.
1. Install the CLI
Using Homebrew (on macOS)
brew install e2b
Using NPM
npm install -g @e2b/cli
2. Authenticate
e2b auth login
Note
To authenticate without the ability to open the browser, provide
E2B_ACCESS_TOKENas an environment variable. You can find your token in Account Settings under the Team selector at e2b.dev/dashboard. Then use the CLI like this:E2B_ACCESS_TOKEN=sk_e2b_... e2b template build.
Important
Note the distinction between
E2B_ACCESS_TOKENandE2B_API_KEY.
3. Check out docs
Visit our CLI documentation to learn more.
