Add --user/--cwd/--env terminal flags to sandbox create & connect#1501
Add --user/--cwd/--env terminal flags to sandbox create & connect#1501mishushakov wants to merge 1 commit into
Conversation
Expose --user, --cwd, and repeatable --env KEY=VALUE flags on `e2b sandbox create` (and the deprecated `spawn` alias) and `e2b sandbox connect`, forwarding them to the underlying PTY session. Extract the shared --env arg parser into src/utils/env.ts and reuse it across create, connect, and exec. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PR SummaryLow Risk Overview There are no automated tests for Reviewed by Cursor Bugbot for commit cab456f. Bugbot is set up for automated code reviews on this repo. Configure here. |
🦋 Changeset detectedLatest commit: cab456f 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 |
Package ArtifactsBuilt from 77ccf17. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-2.31.1-mishushakov-move-parseenv-to-shared-utils.0.tgzCLI ( npm install ./e2b-cli-2.13.1-mishushakov-move-parseenv-to-shared-utils.0.tgzPython SDK ( pip install ./e2b-2.30.0+mishushakov.move.parseenv.to.shared.utils-py3-none-any.whl |
There was a problem hiding this comment.
LGTM — straightforward CLI flag plumbing through to existing SDK PTY options, with tests and a changeset.
Extended reasoning...
Overview
This PR adds three new flags (--user, --cwd, repeatable --env KEY=VALUE) to the e2b sandbox create and e2b sandbox connect CLI commands and forwards them to the underlying PTY session via the existing SDK options. It also extracts the existing --env parser from exec.ts into a shared src/utils/env.ts and reuses it across the three commands. Includes unit tests for the parser, CLI tests for the new flags, and a changeset.
Security risks
None apparent. The flag values are passed as parameters through to the SDK's pty.create call which the SDKs already support — no new shell-escaping or process-exec surface is introduced in the CLI layer. The parseEnv helper only splits on = and assigns to a plain object; behavior is equivalent to the prior in-line version it replaces.
Level of scrutiny
Low. This is CLI-only code (no auth, crypto, or server-side logic), the change is small (~150 lines including tests), follows the existing pattern used in exec.ts, and is well-tested. The TerminalOpts conditional spread also correctly avoids passing undefined keys to the SDK.
Other factors
The bug hunting system found no issues. New tests cover the happy path (flags forwarded correctly), the edge case of = inside values, and the no-env-flags case. The shared parseEnv extraction is a behavior-preserving refactor of code that already existed in exec.ts.
Exposes
--user,--cwd, and repeatable--env KEY=VALUEflags one2b sandbox create(and the deprecatedspawnalias) ande2b sandbox connect, forwarding them to the underlying PTY session so the connected terminal starts as the given user, in the given working directory, and with the given environment variables. The SDKs already supported these PTY options — this just wires them through the CLI. The--envarg parser is extracted into a sharedsrc/utils/env.tsand reused acrosscreate,connect, andexec. Added unit tests for the parser and CLI tests covering the new flags; a changeset is included for@e2b/cli.Usage
🤖 Generated with Claude Code