Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .changeset/spicy-suns-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"@e2b/desktop": minor
"@e2b/desktop-python": minor
---

Update `e2b` (js → `2.27.1`, python → `2.25.1`). The js SDK now requires Node `>=20.18.1`, matching the upstream engine range.

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:

```ts
// before
await Sandbox.betaCreate({ autoPause: true })
// after
await Sandbox.create({ lifecycle: { onTimeout: 'pause' } })
```

```python
# before
Sandbox.beta_create(auto_pause=True)
# after
Sandbox.create(lifecycle={"on_timeout": "pause"})
```
4 changes: 2 additions & 2 deletions packages/js-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"package.json"
],
"engines": {
"node": ">=20"
"node": ">=20.18.1"
},
"browserslist": [
"defaults"
Expand All @@ -61,6 +61,6 @@
"vitest": "^4.0.0"
},
"dependencies": {
"e2b": "^2.19.4"
"e2b": "^2.27.1"
Comment thread
mishushakov marked this conversation as resolved.
}
}
91 changes: 0 additions & 91 deletions packages/js-sdk/src/sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
Sandbox as SandboxBase,
SandboxOpts as SandboxOptsBase,
SandboxBetaCreateOpts as SandboxBetaCreateOptsBase,
CommandHandle,
CommandResult,
CommandExitError,
Expand Down Expand Up @@ -116,31 +115,6 @@ export interface SandboxOpts extends SandboxOptsBase {
display?: string
}

/**
* Configuration options for the Sandbox environment.
* @interface SandboxOpts
* @extends {SandboxOptsBase}
*/
export interface SandboxBetaCreateOpts extends SandboxBetaCreateOptsBase {
/**
* The screen resolution in pixels, specified as [width, height].
* @type {[number, number]}
*/
resolution?: [number, number]

/**
* Dots per inch (DPI) setting for the display.
* @type {number}
*/
dpi?: number

/**
* Display identifier.
* @type {string}
*/
display?: string
}

export class Sandbox extends SandboxBase {
protected static override readonly defaultTemplate: string = 'desktop'
public display: string = ':0'
Expand Down Expand Up @@ -229,71 +203,6 @@ export class Sandbox extends SandboxBase {
return sbx
}

/**
* Create a new sandbox from the default `desktop` sandbox template.
*
* @param opts connection options.
*
* @returns sandbox instance for the new sandbox.
*
* @example
* ```ts
* const sandbox = await Sandbox.create()
* ```
* @constructs Sandbox
*/
static async betaCreate<S extends typeof Sandbox>(
this: S,
opts?: SandboxBetaCreateOpts
): Promise<InstanceType<S>>
/**
* Create a new sandbox from the specified sandbox template.
*
* @param template sandbox template name or ID.
* @param opts connection options.
*
* @returns sandbox instance for the new sandbox.
*
* @example
* ```ts
* const sandbox = await Sandbox.create('<template-name-or-id>')
* ```
* @constructs Sandbox
*/
static async betaCreate<S extends typeof Sandbox>(
this: S,
template: string,
opts?: SandboxBetaCreateOpts
): Promise<InstanceType<S>>
static async betaCreate<S extends typeof Sandbox>(
this: S,
templateOrOpts?: SandboxBetaCreateOpts | string,
opts?: SandboxOpts
): Promise<InstanceType<S>> {
const { template, sandboxOpts } =
typeof templateOrOpts === 'string'
? { template: templateOrOpts, sandboxOpts: opts }
: { template: this.defaultTemplate, sandboxOpts: templateOrOpts }

// Add DISPLAY environment variable if not already set
const display = opts?.display || ':0'
const sandboxOptsWithDisplay = {
...sandboxOpts,
envs: {
...sandboxOpts?.envs,
DISPLAY: display,
},
}

const sbx = (await super.betaCreate(
template,
sandboxOptsWithDisplay
)) as InstanceType<S>
await sbx._start(display, sandboxOptsWithDisplay)

return sbx
}

/**
* Wait for a command to return a specific result.
* @param cmd - The command to run.
Expand Down
74 changes: 0 additions & 74 deletions packages/python-sdk/e2b_desktop/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,80 +277,6 @@ def create(

return sbx

@classmethod
def beta_create(
cls,
template: Optional[str] = None,
resolution: Optional[Tuple[int, int]] = None,
dpi: Optional[int] = None,
display: Optional[str] = None,
timeout: Optional[int] = None,
auto_pause: Optional[bool] = False,
metadata: Optional[Dict[str, str]] = None,
envs: Optional[Dict[str, str]] = None,
secure: bool = True,
allow_internet_access: bool = True,
**opts: Unpack[ApiParams],
) -> Self:
"""
[BETA] This feature is in beta and may change in the future.

Create a new sandbox.

By default, the sandbox is created from the default `desktop` sandbox template.


:param template: Sandbox template name or ID
:param resolution: Startup the desktop with custom screen resolution. Defaults to (1024, 768)
:param dpi: Startup the desktop with custom DPI. Defaults to 96
:param display: Startup the desktop with custom display. Defaults to ":0"
: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.
:param auto_pause: Automatically pause the sandbox after the timeout expires. Defaults to `False`.
:param metadata: Custom metadata for the sandbox
:param envs: Custom environment variables for the sandbox
:param secure: Envd is secured with access token and cannot be used without it
:param allow_internet_access: Allow sandbox to access the internet, defaults to `True`.

:return: A Sandbox instance for the new sandbox

Use this method instead of using the constructor to create a new sandbox.
"""

# Initialize environment variables with DISPLAY
display = display or ":0"
if envs is None:
envs = {}
envs["DISPLAY"] = display

sbx = super().beta_create(
template=template,
timeout=timeout,
metadata=metadata,
envs=envs,
secure=secure,
allow_internet_access=allow_internet_access,
**opts,
)

sbx._display = display
width, height = resolution or (1024, 768)
sbx.commands.run(
f"Xvfb {display} -ac -screen 0 {width}x{height}x24"
f" -retro -dpi {dpi or 96} -nolisten tcp -nolisten unix",
background=True,
timeout=0,
)

if not sbx._wait_and_verify(
f"xdpyinfo -display {display}", lambda r: r.exit_code == 0
):
raise TimeoutException("Could not start Xvfb")

sbx.__vnc_server = _VNCServer(sbx)
sbx._start_xfce4()

return sbx

def _wait_and_verify(
self,
cmd: str,
Expand Down
55 changes: 48 additions & 7 deletions packages/python-sdk/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/python-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ packages = [{ include = "e2b_desktop" }]
[tool.poetry.dependencies]
python = "^3.10"

e2b = "^2.20.3"
e2b = "^2.25.1"
requests = "^2.32.3"
pillow = "^12.0.0"

Expand Down
Loading
Loading