Files
e2b-dev--e2b/.changeset/python-js-sdk-alignment.md
T
Mish Ushakov 7dc861f899 fix: align behavior and API surface between the JS and Python SDKs (#1411)
Aligns several behavioral and API-surface discrepancies between the JS
and Python SDKs found during a cross-SDK audit. **Python:**
`commands.send_stdin`/`CommandHandle.send_stdin` now accept `bytes`
(plus `request_timeout` on the handle), `git.reset` gets a typed
`GitResetMode` with JS-matching validation, `sandbox_url` is threaded
through `get_api_params` (and the dead `SandboxOpts` key removed), and
`from_image` requires both `username` and `password` when credentials
are given. **JS:** `getFullInfo` was removed in favor of a single
`getInfo` that now includes `sandboxDomain` (matching Python's
`get_info`), `fromImage` requires both credentials, `getBuildStatus`
defaults `logsOffset` to `0`, `getMetrics`/`kill` short-circuit
consistently in debug mode (instance + static), and `requestTimeoutMs:
0` explicitly disables the request timeout. Tests were added on both
sides (git-arg validation, stdin bytes, credential validation,
timeout-0, connection config) and the CLI's `sandbox info` now uses
`getInfo`. See the changeset for the full per-SDK list.

## Usage examples

```ts
// JS: registry credentials now require both fields
Template().fromImage('registry.example.com/img:latest', { username: 'u', password: 'p' })

// JS: getInfo now exposes sandboxDomain (getFullInfo removed)
const info = await Sandbox.getInfo(sandboxId)
console.log(info.sandboxDomain)

// JS: disable the request timeout
await Sandbox.create({ requestTimeoutMs: 0 })
```

```python
# Python: send raw bytes to stdin
sandbox.commands.send_stdin(cmd.pid, b"hello")

# Python: typed git reset mode (validated)
sandbox.git.reset(repo, mode="hard")

# Python: registry credentials require both fields
Template().from_image("registry.example.com/img:latest", username="u", password="p")
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-10 13:40:22 +00:00

1.7 KiB

e2b, @e2b/python-sdk, @e2b/cli
e2b @e2b/python-sdk @e2b/cli
patch patch patch

fix: align behavior between the JS and Python SDKs

Python SDK:

  • commands.send_stdin and CommandHandle.send_stdin now accept bytes in addition to str, and the handle's send_stdin / close_stdin now accept a request_timeout.
  • git.reset now accepts a typed GitResetMode and its validation error matches the JS SDK wording/ordering. GitResetMode is now exported.
  • sandbox_url is now propagated through get_api_params.
  • Template.from_image() now raises when only one of username / password is provided.
  • get_info() no longer carries the envd access token on the returned SandboxInfo (the _envd_access_token field was unused), matching the JS SDK which strips it from getInfo.
  • get_metrics() now raises TemplateException (was SandboxException) with the same message as the JS SDK when the sandbox is too old.

JS SDK:

  • Sandbox.getInfo() now includes sandboxDomain, matching the Python SDK's single get_info. getFullInfo is deprecated and now just wraps getInfo (it no longer returns the envd access token).
  • Sandbox.getMetrics() now returns [] in debug mode, matching the Python SDK. The debug short-circuit for getMetrics / kill is implemented on both the instance and static methods, so it applies consistently whether called as Sandbox.kill(sandboxId) or sandbox.kill().
  • Template.fromImage() now requires both username and password when registry credentials are provided.
  • Template.getBuildStatus() now defaults logsOffset to 0.
  • requestTimeoutMs: 0 now explicitly disables the request timeout.
  • getMetrics() now throws TemplateError (was SandboxError) when the sandbox is too old to support metrics.