Skip to content

Commit 122a1f0

Browse files
mishushakovclaude
andauthored
Update e2b SDK (js → 2.27.1, python → 2.25.1) (#204)
* Update e2b SDK: js to 2.27.1, python to 2.25.1 Bumps the e2b dependency for both SDKs and adapts to the breaking change in e2b 2.24.0, which removed Sandbox.betaCreate / SandboxBetaCreateOpts (JS) and Sandbox.beta_create (Python). The lifecycle config those methods gated now ships on Sandbox.create, so the desktop overrides are dropped: - js-sdk: removed the betaCreate override and SandboxBetaCreateOpts interface (tsc failed against the new types) - python-sdk: removed the beta_create override (super().beta_create no longer exists, leaving it broken at runtime) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Tighten js-sdk engines.node to >=20.18.1 e2b 2.27.1 declares engines.node >=20.18.1. Bump @e2b/desktop's range to match so consumers on Node 20.0–20.17 get a clear engine mismatch at install time rather than runtime failures from the upgraded SDK. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Add changeset for e2b update and betaCreate removal Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Include python sdk in changeset Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent bf2571c commit 122a1f0

7 files changed

Lines changed: 86 additions & 181 deletions

File tree

.changeset/spicy-suns-bow.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
"@e2b/desktop": minor
3+
"@e2b/desktop-python": minor
4+
---
5+
6+
Update `e2b` (js → `2.27.1`, python → `2.25.1`). The js SDK now requires Node `>=20.18.1`, matching the upstream engine range.
7+
8+
The base SDK removed the beta create API in e2b 2.24.0, so the desktop overrides have been removed: `Sandbox.betaCreate` / `SandboxBetaCreateOpts` (js) and `Sandbox.beta_create` (python). Use `Sandbox.create` with the `lifecycle` option instead:
9+
10+
```ts
11+
// before
12+
await Sandbox.betaCreate({ autoPause: true })
13+
// after
14+
await Sandbox.create({ lifecycle: { onTimeout: 'pause' } })
15+
```
16+
17+
```python
18+
# before
19+
Sandbox.beta_create(auto_pause=True)
20+
# after
21+
Sandbox.create(lifecycle={"on_timeout": "pause"})
22+
```

packages/js-sdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"package.json"
3535
],
3636
"engines": {
37-
"node": ">=20"
37+
"node": ">=20.18.1"
3838
},
3939
"browserslist": [
4040
"defaults"
@@ -61,6 +61,6 @@
6161
"vitest": "^4.0.0"
6262
},
6363
"dependencies": {
64-
"e2b": "^2.19.4"
64+
"e2b": "^2.27.1"
6565
}
6666
}

packages/js-sdk/src/sandbox.ts

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
Sandbox as SandboxBase,
33
SandboxOpts as SandboxOptsBase,
4-
SandboxBetaCreateOpts as SandboxBetaCreateOptsBase,
54
CommandHandle,
65
CommandResult,
76
CommandExitError,
@@ -116,31 +115,6 @@ export interface SandboxOpts extends SandboxOptsBase {
116115
display?: string
117116
}
118117

119-
/**
120-
* Configuration options for the Sandbox environment.
121-
* @interface SandboxOpts
122-
* @extends {SandboxOptsBase}
123-
*/
124-
export interface SandboxBetaCreateOpts extends SandboxBetaCreateOptsBase {
125-
/**
126-
* The screen resolution in pixels, specified as [width, height].
127-
* @type {[number, number]}
128-
*/
129-
resolution?: [number, number]
130-
131-
/**
132-
* Dots per inch (DPI) setting for the display.
133-
* @type {number}
134-
*/
135-
dpi?: number
136-
137-
/**
138-
* Display identifier.
139-
* @type {string}
140-
*/
141-
display?: string
142-
}
143-
144118
export class Sandbox extends SandboxBase {
145119
protected static override readonly defaultTemplate: string = 'desktop'
146120
public display: string = ':0'
@@ -229,71 +203,6 @@ export class Sandbox extends SandboxBase {
229203
return sbx
230204
}
231205

232-
/**
233-
* Create a new sandbox from the default `desktop` sandbox template.
234-
*
235-
* @param opts connection options.
236-
*
237-
* @returns sandbox instance for the new sandbox.
238-
*
239-
* @example
240-
* ```ts
241-
* const sandbox = await Sandbox.create()
242-
* ```
243-
* @constructs Sandbox
244-
*/
245-
static async betaCreate<S extends typeof Sandbox>(
246-
this: S,
247-
opts?: SandboxBetaCreateOpts
248-
): Promise<InstanceType<S>>
249-
/**
250-
* Create a new sandbox from the specified sandbox template.
251-
*
252-
* @param template sandbox template name or ID.
253-
* @param opts connection options.
254-
*
255-
* @returns sandbox instance for the new sandbox.
256-
*
257-
* @example
258-
* ```ts
259-
* const sandbox = await Sandbox.create('<template-name-or-id>')
260-
* ```
261-
* @constructs Sandbox
262-
*/
263-
static async betaCreate<S extends typeof Sandbox>(
264-
this: S,
265-
template: string,
266-
opts?: SandboxBetaCreateOpts
267-
): Promise<InstanceType<S>>
268-
static async betaCreate<S extends typeof Sandbox>(
269-
this: S,
270-
templateOrOpts?: SandboxBetaCreateOpts | string,
271-
opts?: SandboxOpts
272-
): Promise<InstanceType<S>> {
273-
const { template, sandboxOpts } =
274-
typeof templateOrOpts === 'string'
275-
? { template: templateOrOpts, sandboxOpts: opts }
276-
: { template: this.defaultTemplate, sandboxOpts: templateOrOpts }
277-
278-
// Add DISPLAY environment variable if not already set
279-
const display = opts?.display || ':0'
280-
const sandboxOptsWithDisplay = {
281-
...sandboxOpts,
282-
envs: {
283-
...sandboxOpts?.envs,
284-
DISPLAY: display,
285-
},
286-
}
287-
288-
const sbx = (await super.betaCreate(
289-
template,
290-
sandboxOptsWithDisplay
291-
)) as InstanceType<S>
292-
await sbx._start(display, sandboxOptsWithDisplay)
293-
294-
return sbx
295-
}
296-
297206
/**
298207
* Wait for a command to return a specific result.
299208
* @param cmd - The command to run.

packages/python-sdk/e2b_desktop/main.py

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -277,80 +277,6 @@ def create(
277277

278278
return sbx
279279

280-
@classmethod
281-
def beta_create(
282-
cls,
283-
template: Optional[str] = None,
284-
resolution: Optional[Tuple[int, int]] = None,
285-
dpi: Optional[int] = None,
286-
display: Optional[str] = None,
287-
timeout: Optional[int] = None,
288-
auto_pause: Optional[bool] = False,
289-
metadata: Optional[Dict[str, str]] = None,
290-
envs: Optional[Dict[str, str]] = None,
291-
secure: bool = True,
292-
allow_internet_access: bool = True,
293-
**opts: Unpack[ApiParams],
294-
) -> Self:
295-
"""
296-
[BETA] This feature is in beta and may change in the future.
297-
298-
Create a new sandbox.
299-
300-
By default, the sandbox is created from the default `desktop` sandbox template.
301-
302-
303-
:param template: Sandbox template name or ID
304-
:param resolution: Startup the desktop with custom screen resolution. Defaults to (1024, 768)
305-
:param dpi: Startup the desktop with custom DPI. Defaults to 96
306-
:param display: Startup the desktop with custom display. Defaults to ":0"
307-
:param timeout: Timeout for the sandbox in **seconds**, default to 300 seconds. The maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
308-
:param auto_pause: Automatically pause the sandbox after the timeout expires. Defaults to `False`.
309-
:param metadata: Custom metadata for the sandbox
310-
:param envs: Custom environment variables for the sandbox
311-
:param secure: Envd is secured with access token and cannot be used without it
312-
:param allow_internet_access: Allow sandbox to access the internet, defaults to `True`.
313-
314-
:return: A Sandbox instance for the new sandbox
315-
316-
Use this method instead of using the constructor to create a new sandbox.
317-
"""
318-
319-
# Initialize environment variables with DISPLAY
320-
display = display or ":0"
321-
if envs is None:
322-
envs = {}
323-
envs["DISPLAY"] = display
324-
325-
sbx = super().beta_create(
326-
template=template,
327-
timeout=timeout,
328-
metadata=metadata,
329-
envs=envs,
330-
secure=secure,
331-
allow_internet_access=allow_internet_access,
332-
**opts,
333-
)
334-
335-
sbx._display = display
336-
width, height = resolution or (1024, 768)
337-
sbx.commands.run(
338-
f"Xvfb {display} -ac -screen 0 {width}x{height}x24"
339-
f" -retro -dpi {dpi or 96} -nolisten tcp -nolisten unix",
340-
background=True,
341-
timeout=0,
342-
)
343-
344-
if not sbx._wait_and_verify(
345-
f"xdpyinfo -display {display}", lambda r: r.exit_code == 0
346-
):
347-
raise TimeoutException("Could not start Xvfb")
348-
349-
sbx.__vnc_server = _VNCServer(sbx)
350-
sbx._start_xfce4()
351-
352-
return sbx
353-
354280
def _wait_and_verify(
355281
self,
356282
cmd: str,

packages/python-sdk/poetry.lock

Lines changed: 48 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/python-sdk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ packages = [{ include = "e2b_desktop" }]
1212
[tool.poetry.dependencies]
1313
python = "^3.10"
1414

15-
e2b = "^2.20.3"
15+
e2b = "^2.25.1"
1616
requests = "^2.32.3"
1717
pillow = "^12.0.0"
1818

0 commit comments

Comments
 (0)