feat: allow passing template as option in Sandbox.create()#1267
feat: allow passing template as option in Sandbox.create()#1267mishushakov merged 2 commits intomainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR SummaryLow Risk Overview Updates Reviewed by Cursor Bugbot for commit 521d043. Bugbot is set up for automated code reviews on this repo. Configure here. |
🦋 Changeset detectedLatest commit: 521d043 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 c14bbd0. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-2.19.1-mishushakov-sandbox-template-option.0.tgzCLI ( npm install ./e2b-cli-2.9.1-mishushakov-sandbox-template-option.0.tgzPython SDK ( pip install ./e2b-2.20.0+mishushakov.sandbox.template.option-py3-none-any.whl |
There was a problem hiding this comment.
LGTM — small, backwards-compatible feature addition with correct logic.
Extended reasoning...
Overview
The PR adds a template optional field to SandboxOpts and threads it through create/betaCreate with a simple nullish-coalescing expression before the existing MCP/default fallback. Changeset is included. Three files changed: the interface definition, the two overloaded create methods, and the changeset.
Security risks
None. This is a pure convenience API addition — no auth, crypto, or permissions code is touched. The template string is already passed through to the API in the same way as the positional-string overload.
Level of scrutiny
Low. The logic change is minimal and mechanical: templateOrOpts?.template ?? (existing expression). Both call sites are updated identically. Backwards compatibility is preserved for the string-argument and no-argument forms.
Other factors
The only finding is a JSDoc nit (@default 'base' being inaccurate when mcp is also set), which is documentation-only and does not affect runtime behavior. No outstanding reviewer comments or unresolved threads exist. The inline comment already captures this nit for the author.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
templateas an optional property onSandboxOptsin the JS SDK, enablingSandbox.create({ template: 'my-template' })syntaxcreateandbetaCreateto checkopts.templatebefore falling back to the default templateSandbox.create(template='template')via named parameters, so no changes needed thereTest plan
Sandbox.create({ template: 'base' })worksSandbox.create('base')still works (backwards compatible)Sandbox.create()still defaults to'base'🤖 Generated with Claude Code