Skip to content

Commit c14bbd0

Browse files
authored
Merge 521d043 into f667f33
2 parents f667f33 + 521d043 commit c14bbd0

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'e2b': patch
3+
---
4+
5+
allow passing template as an option in Sandbox.create()

packages/js-sdk/src/sandbox/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,11 @@ export class Sandbox extends SandboxApi {
273273
sandboxOpts: opts,
274274
}
275275
: {
276-
template: templateOrOpts?.mcp
277-
? this.defaultMcpTemplate
278-
: this.defaultTemplate,
276+
template:
277+
templateOrOpts?.template ??
278+
(templateOrOpts?.mcp
279+
? this.defaultMcpTemplate
280+
: this.defaultTemplate),
279281
sandboxOpts: templateOrOpts,
280282
}
281283

@@ -368,9 +370,11 @@ export class Sandbox extends SandboxApi {
368370
sandboxOpts: opts,
369371
}
370372
: {
371-
template: templateOrOpts?.mcp
372-
? this.defaultMcpTemplate
373-
: this.defaultTemplate,
373+
template:
374+
templateOrOpts?.template ??
375+
(templateOrOpts?.mcp
376+
? this.defaultMcpTemplate
377+
: this.defaultTemplate),
374378
sandboxOpts: templateOrOpts,
375379
}
376380

packages/js-sdk/src/sandbox/sandboxApi.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ export interface SandboxApiOpts
107107
* Options for creating a new Sandbox.
108108
*/
109109
export interface SandboxOpts extends ConnectionOpts {
110+
/**
111+
* Sandbox template name or ID.
112+
*
113+
* @default 'base' (or 'mcp-gateway' when `mcp` option is set)
114+
*/
115+
template?: string
116+
110117
/**
111118
* Custom metadata for the sandbox.
112119
*

0 commit comments

Comments
 (0)