Mish Ushakov
9f9e2a8f20
Render failed layer stack traces on build error ( #901 )
...
### Changelog
- Added traces for Python and JavaScript SDK.
- Added methods for stack trace collection, stack trace context
- Updated file upload mechanism for tracing
- Changed API handling to support throwing API errors with traces
> **Note**
> For functions like `aptInstall`, `fromRegistry` which call `.run` and
`.fromImage`, the stack trace has to be replaced so it throws correctly
from parent.
> **Note**
> There are no build logs in the trace, we can add this at later point.
### Examples
Keep in mind that the way the traces are rendered entirely depends on
environment (Bun, Node, Deno, Vitest, Pytest)
**Standard Python**
```
Traceback (most recent call last):
File "/Users/mish/Documents/Projects/E2B/E2B/packages/python-sdk/tests/sync/template_sync/test_stacktrace.py", line 17, in <module>
Template.build(
~~~~~~~~~~~~~~^
template,
^^^^^^^^^
...<2 lines>...
memory_mb=1024,
^^^^^^^^^^^^^^^
)
^
File "/Users/mish/Documents/Projects/E2B/E2B/packages/python-sdk/e2b/template_sync/main.py", line 157, in build
wait_for_build_finish(
~~~~~~~~~~~~~~~~~~~~~^
api_client,
^^^^^^^^^^^
...<4 lines>...
stack_traces=template._template._stack_traces,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/mish/Documents/Projects/E2B/E2B/packages/python-sdk/e2b/template_sync/build_api.py", line 199, in wait_for_build_finish
raise BuildException(error_message).with_traceback(stack_trace)
File "/Users/mish/Documents/Projects/E2B/E2B/packages/python-sdk/tests/sync/template_sync/test_stacktrace.py", line 12, in <module>
.run_cmd("cat non_existing_file.txt")
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
e2b.template.exceptions.BuildException: failed to run command: exit status 1
```
**Pytest**
```
[gw0] darwin -- Python 3.13.3 /Users/mish/Library/Caches/pypoetry/virtualenvs/e2b-e6GdLxLZ-py3.13/bin/python
@pytest.mark.skip_debug()
def test_build():
template = (
Template()
.from_image("ubuntu:22.04")
.run_cmd("cat non_existing_file.txt")
.set_workdir("/app")
.set_start_cmd("echo 'Hello, world!'", wait_for_timeout(10_000))
)
# try:
> Template.build(
template,
alias=str(uuid4()),
cpu_count=1,
memory_mb=1024,
)
tests/sync/template_sync/test_stacktrace.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
e2b/template_sync/main.py:157: in build
wait_for_build_finish(
e2b/template_sync/build_api.py:199: in wait_for_build_finish
raise BuildException(error_message).with_traceback(stack_trace)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@pytest.mark.skip_debug()
def test_build():
template = (
Template()
.from_image("ubuntu:22.04")
> .run_cmd("cat non_existing_file.txt")
.set_workdir("/app")
.set_start_cmd("echo 'Hello, world!'", wait_for_timeout(10_000))
)
E e2b.template.exceptions.BuildException: failed to run command: exit status 1
tests/sync/template_sync/test_stacktrace.py:12: BuildException
========================================================== short test summary info ==========================================================
FAILED tests/sync/template_sync/test_stacktrace.py::test_build - e2b.template.exceptions.BuildException: failed to run command: exit status 1
```
**Node**
```
node:internal/modules/run_main:104
triggerUncaughtException(
^
at file:///Users/mish/Documents/Projects/E2B/E2B/packages/js-sdk/tests/template/trace.test.mts:8:4
at ModuleJob.run (node:internal/modules/esm/module_job:274:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:98:5) {
name: 'BuildError'
}
Node.js v23.11.0
```
**Bun**
```
1 | export class BuildError extends Error {
2 | constructor(message: string, stackTrace?: string) {
3 | super(message)
^
BuildError: failed to run command: exit status 1
at /Users/mish/Documents/Projects/E2B/E2B/packages/js-sdk/src/template/errors.ts:3:5
Bun v1.2.4 (macOS arm64)
```
**Vitest**
```
BuildError: failed to run command: exit status 1
❯ tests/template/trace.test.ts:8:6
6| const template = Template()
7| .fromImage('ubuntu:22.04')
8| .runCmd('cat folder/test.txt')
| ^
9| .setWorkdir('/app')
10| .setStartCmd('echo "Hello, world!"', waitForTimeout(10_000))
```
---------
Co-authored-by: Jakub Dobry <jakub.dobry8@gmail.com >
2025-09-19 12:34:08 +02:00
github-actions[bot]
9cbcaa40c4
[skip ci] Release new versions
2025-09-09 19:57:39 +00:00
Mish Ushakov
3d6418184f
Add custom registries support for pulling base images ( #897 )
...
### Changelog
- added support for pulling base images from AWS, Docker, GCP
registries.
- removed unnecessary conversion in build_api.py.
- synced serialize implementation in TypeScript and Python.
- added Cursor Pylance config (side-effect, can delete if unwanted).
### Examples
**TypeScript**
```ts
import { Template } from 'e2b'
// Generic Docker registry
Template().fromRegistry('ubuntu:22.04', {
username: 'jirka',
password: 'password',
})
// AWS ECR registry
Template().fromAWSRegistry('ubuntu:22.04', {
accessKeyId: '123',
secretAccessKey: '456',
region: 'eu-west-1',
})
// GCP GCR registry from file path
Template().fromGCPRegistry('ubuntu:22.04', {
serviceAccountJSON: './service_account.json',
})
// GCP GCR registry from object
Template().fromGCPRegistry('ubuntu:22.04', {
serviceAccountJSON: { project_id: '123', private_key_id: '456' },
})
```
**Python**
```py
from e2b import Template
# Generic Docker registry
Template().from_registry(
image="ubuntu:22.04",
username="jirka",
password="password",
)
# AWS ECR registry
Template().from_aws_registry(
image="ubuntu:22.04",
access_key_id="123",
secret_access_key="456",
region="eu-west-1",
)
# GCP GCR registry from file path
Template().from_gcp_registry(
image="ubuntu:22.04",
service_account_json="./service_account.json",
)
# GCP GCR registry from object
Template().from_gcp_registry(
image="ubuntu:22.04",
service_account_json={"project_id": "123", "private_key_id": "456"},
)
```
2025-09-09 19:51:40 +00:00
Mish Ushakov
79d4ce34e2
Templates SDK: simplify exports ( #898 )
...
- Removed unnecessary deep export chains
2025-09-08 08:38:16 -07:00
github-actions[bot]
448beca40c
[skip ci] Release new versions
2025-09-08 05:23:08 +00:00
Mish Ushakov
44365999e1
Vendor strip-ansi npm module to avoid ESM-related issues ( #895 )
...
- Fixes #894
2025-09-08 08:17:25 +03:00
github-actions[bot]
bee91610dc
[skip ci] Release new versions
2025-09-06 10:58:21 +00:00
Jakub Dobry
6fc97604f7
Add ready command for JS and Python ( #893 )
2025-09-06 03:52:42 -07:00
github-actions[bot]
9d82bd60fc
[skip ci] Release new versions
2025-09-05 20:06:19 +00:00
Mish Ushakov
4a2a6c7051
Add Templates SDK ( #871 )
...
### Merge Templates SDK into E2B SDK.
This PR merges code from Templates SDK to E2B SDK.
**Changelog**
- Added new error classes: BuildError, FileUploadError.
- Added template API endpoints to API Client generation (Python).
- Updated API Clients error handling to throw BuildError in addition to
SandboxError.
- Exported Template and TemplateAsync classes.
- Moved `getRuntime` utility method from api to utils.
- Browser is supported except file operations (COPY). Incompatible
modules are not bundled, using dynamic imports (tar, glob) in supported
environments (Node, Deno, Bun) instead.
- Basic tests were added, subject to expansion in a follow-up PR.
- Breaking: Before, 401 error was raising `SandboxError`, which was
incorrect, now it will raise `AuthenticationError`. I have also changed
the `AuthenticationError` to extend Error class, not `SandboxError`
anymore as it's now thrown by both Sandbox and Template.
**Usage**
JavaScript
```js
import { Template } from 'e2b';
const template = Template()
.fromImage('ubuntu:22.04')
.copy('folder/*.txt', 'folder', { forceUpload: true })
.setEnvs({
ENV_1: 'value1',
ENV_2: 'value2',
})
.runCmd('cat folder/test.txt')
.setWorkdir('/app')
.setStartCmd('echo "Hello, world!"', Template.waitForTimeout('10s'))
await Template.build(template, {
alias: 'test-template',
cpuCount: 1,
memoryMB: 1024,
onBuildLogs: (logEntry) => console.log(logEntry.toString()),
})
```
Python
```py
from e2b import Template
template = (
Template()
.from_image("ubuntu:22.04")
.copy("folder/*.txt", "folder", force_upload=True)
.set_envs(
{
"ENV_1": "value1",
"ENV_2": "value2",
}
)
.run_cmd("cat folder/test.txt")
.set_workdir("/app")
.set_start_cmd("echo 'Hello, world!'", Template.wait_for_timeout("10s"))
)
Template.build(
template,
alias="test-template",
cpu_count=1,
memory_mb=1024,
on_build_logs=lambda log_entry: print(log_entry),
)
```
Python Async
```py
from e2b import AsyncTemplate
template = (
AsyncTemplate()
.from_image("ubuntu:22.04")
.copy("folder/*.txt", "folder", force_upload=True)
.set_envs(
{
"ENV_1": "value1",
"ENV_2": "value2",
}
)
.run_cmd("cat folder/test.txt")
.set_workdir("/app")
.set_start_cmd("echo 'Hello, world!'", Template.wait_for_timeout("10s"))
)
await AsyncTemplate.build(
template,
alias="test-template",
cpu_count=1,
memory_mb=1024,
on_build_logs=lambda log_entry: print(log_entry),
)
```
---
Merge progress
- [x] JavaScript SDK
- [x] Python SDK
- [x] Tests
- [x] Split files for review
2025-09-05 22:00:22 +02:00
github-actions[bot]
2162c6191f
[skip ci] Release new versions
2025-09-03 12:49:17 +00:00
Mish Ushakov
67070bb9ea
Synced spec + generated API client ( #889 )
...
Changelog
- Synced latest spec from e2b-dev/infra
- Regenerated API clients
2025-09-03 05:43:47 -07:00
github-actions[bot]
787a3192ce
[skip ci] Release new versions
2025-09-03 12:01:10 +00:00
Jakub Novák
cf0bb40ed3
Fix autopause ( #876 )
...
# Description
Autopause option shouldn't be passed for resume
2025-09-03 11:48:12 +00:00
Jakub Novák
b42ab2a86b
Add pipeline for linting and formatting ( #883 )
...
Setup linting and formatting in all packages
2025-08-31 12:06:00 -07:00
Jakub Novák
c2195d832f
Fix API key check in JS SDK & remove deprecated fields ( #869 )
...
Fix the check and remove deprecated fields
2025-08-22 09:42:49 +00:00
github-actions[bot]
4eb3a2d322
[skip ci] Release new versions
2025-08-21 20:08:42 +00:00
Jakub Novák
fe214af0ce
Change envd access token to protected ( #867 )
2025-08-21 19:56:11 +00:00
github-actions[bot]
774dfd7667
[skip ci] Release new versions
2025-08-21 15:51:16 +00:00
Jakub Novák
74457ff1dd
SDK v2 - Changeset and docs ( #862 )
...
SDK v2 release
2025-08-21 08:45:25 -07:00
Jakub Novák
d117ba09e8
SDK v2 - Add beta pause and update Sandbox list ( #854 )
...
Introduce beta submodule with beta features - pause and resume
Update Sandbox list to also return paused sandboxes
---------
Co-authored-by: Tomas Valenta <valenta.and.thomas@gmail.com >
2025-08-19 00:37:07 -07:00
Jakub Novák
1aee7c8195
Refactor Sandbox object in Python ( #855 )
...
# Description
We can simplify typing and return only SandboxInfo in SDKs as the types
are very similar (there are some extra fields in detail, which we don't
want to expose but we need them e.g. for connect)
2025-08-10 12:40:09 -07:00
github-actions[bot]
e140ec3717
[skip ci] Release new versions
2025-08-06 21:14:31 +00:00
Tomas Valenta
1f1c666413
Add RateLimitError to export ( #851 )
...
Co-authored-by: Zobeir Hamid <zobeirhamid@berkeley.edu >
2025-08-06 21:09:23 +00:00
github-actions[bot]
7540839268
[skip ci] Release new versions
2025-08-06 10:32:14 +00:00
Tomas Valenta
0bace983b1
Increase default request timeout ( #847 )
...
Increase the default request timeout to 60 seconds. This is the value in
the current beta, and with the merge, we want to keep it that way, to
minimize possible negative migration impact.
2025-08-06 03:27:19 -07:00
github-actions[bot]
9d2b3c92a7
[skip ci] Release new versions
2025-08-04 12:40:16 +00:00
Jiri Sveceny
c0a41722e5
Secured sandbox auto signature ( #845 )
...
Some users report that JS/Python types lack a `useSignature` attribute,
which only works when `secure=true` is set for the sandbox. This change
removes the `useSignatrue` parameter and makes all upload/download URL
requests signed if `secure` was provided, making sure the function will
work for all possible cases.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com >
Co-authored-by: Ben Fornefeld <50748440+ben-fornefeld@users.noreply.github.com >
2025-08-04 12:34:59 +00:00
Jakub Novák
8c4710cc60
Fix metrics cli missing api key ( #836 )
...
# Description
Fixing a missing API key issue for sandbox metrics in the CLI
2025-07-31 09:54:44 +00:00
github-actions[bot]
115407cf1e
[skip ci] Release new versions
2025-07-31 09:44:55 +00:00
Jakub Novák
f123091e9a
Allow to block network from SDK ( #834 )
...
# Description
This pull request introduces the ability to control internet access for
sandboxes, enhancing security for sensitive workloads.
2025-07-31 02:34:57 -07:00
github-actions[bot]
76d62ed070
[skip ci] Release new versions
2025-07-30 19:25:33 +00:00
Jakub Novák
e34d69525f
Expose sandbox metrics in SDKs and CLI ( #828 )
...
# Description
Expose sandbox metrics in SDKs and CLI
```
e2b sbx mt il98ycmohc6enybi79uf8
Metrics for sandbox il98ycmohc6enybi79uf8:
[2025-07-25 14:05:55Z] CPU: 8.27% / 2 Cores | Memory: 31 / 484 MiB | Disk: 1445 / 2453 MiB
[2025-07-25 14:06:00Z] CPU: 0.5% / 2 Cores | Memory: 32 / 484 MiB | Disk: 1445 / 2453 MiB
[2025-07-25 14:06:05Z] CPU: 0.1% / 2 Cores | Memory: 32 / 484 MiB | Disk: 1445 / 2453 MiB
[2025-07-25 14:06:10Z] CPU: 0.3% / 2 Cores | Memory: 32 / 484 MiB | Disk: 1445 / 2453 MiB
```
---------
Co-authored-by: Tomas Valenta <valenta.and.thomas@gmail.com >
2025-07-30 12:17:30 -07:00
github-actions[bot]
7f26f5536e
[skip ci] Release new versions
2025-07-29 10:44:36 +00:00
Mish Ushakov
edeafb1cdd
Adds files.getInfo / files.get_info methods to retrieve information about directory/files ( #724 )
...
**Changelog**
- Adds `files.getInfo`, `files.get_info` methods to the SDKs.
- Adds tests for the new methods
- Adds documentation for the above.
**Examples**
JavaScript
```js
import { Sandbox } from '@e2b/code-interpreter'
const sandbox = await Sandbox.create()
// Create a new file
await sandbox.files.write('test_file.txt', 'Hello, world!')
// Get information about the file
const info = await sandbox.files.getInfo('test_file.txt')
console.log(info)
// {
// name: 'test_file.txt',
// type: 'file',
// path: '/home/user/test_file.txt'
// }
```
Python
```py
from e2b_code_interpreter import Sandbox
sandbox = Sandbox()
# Create a new file
sandbox.files.write('test_file', 'Hello, world!')
# Get information about the file
info = sandbox.files.get_info('test_file')
print(info)
# EntryInfo(name='test_file.txt', type=<FileType.FILE: 'file'>, path='/home/user/test_file.txt')
```
---------
Co-authored-by: Jakub Novak <jakub@e2b.dev >
2025-07-29 03:39:42 -07:00
github-actions[bot]
37d69be891
[skip ci] Release new versions
2025-07-28 15:23:07 +00:00
Jakub Novák
c54528faea
Update User-Agent header in SDKs based on the SDK version ( #830 )
...
# Description
The bug where extra fields in envd response caused an exception was
fixed in #738 . As we're also ignoring new fields in envd (implemented in
https://github.com/e2b-dev/infra/pull/847 ). We now have to update the
`user-agent` header.
2025-07-28 08:18:02 -07:00
Jakub Novák
706ebd9af8
Fix generating files with docker ( #829 )
...
# Description
Fixes an issue in generating files in Docker. There has been an
incompatibility of `buf` (version `29.5`) and `protoc-gen-es` (version
`2.2.2`).
I updated `protoc-gen-es@` to `2.6.2`
Also refactored the code a little so it's easier to read
Added a CI pipeline job to check all files are properly generated
2025-07-28 13:47:26 +02:00
github-actions[bot]
e7538fb5cc
[skip ci] Release new versions
2025-07-18 11:20:02 +00:00
Jiri Sveceny
10e9a28a82
Support sandbox domain in sdk and cli ( #821 )
...
Support sandbox traffic routing to the custom domain returned from API.
2025-07-18 13:15:12 +02:00
github-actions[bot]
5f207ffa95
[skip ci] Release new versions
2025-07-17 13:16:31 +00:00
Jiri Sveceny
9f8c40e49e
Client ID part removal from SDKs ( #820 )
...
- CLI spawn, connect, and logs work with and without the client part
provided
- JavaScript and Python SDKs are no longer returning IDs with client
part
2025-07-17 13:11:50 +00:00
Mish Ushakov
5c68eb7a25
Fixes Sandbox.connect not working when trying to pass API key via parameters ( #772 )
...
fixes https://github.com/e2b-dev/E2B/issues/746
- Renamed SandboxApi.get_info() > SandboxApi._cls_get_info()
- Properly overloaded Sandbox.get_info()
- Passed connect parameters to SandboxApi._cls_get_info()
2025-07-10 15:41:33 +02:00
James Murdza
606d03060c
Fix broken example code in README ( #798 )
...
This fixes the broken example code in the README.
2025-07-09 07:28:42 -07:00
0div
9b4861d2ea
Add sandbox metadata docs and update env var tests ( #804 )
...
# Description
- [x] update env var docs to include new default sandbox metadata env
vars
- [x] update js-sdk tests
- [x] update python tests
# Test
```sh
$ [packages/js-sdk] pnpm test env
$ [packages/python-sdk] poetry run pytest --verbose -x tests/async/sandbox_async/commands/test_env_vars.py
$ [packages/python-sdk] poetry run pytest --verbose -x tests/sync/sandbox_sync/commands/test_env_vars.py
```
2025-07-03 14:44:27 -07:00
github-actions[bot]
9704e2ff03
[skip ci] Release new versions
2025-06-24 17:08:34 +00:00
Mish Ushakov
89b8680c75
watchDir remove redundant "timeout" option in JS SDK ( #796 )
...
- removes redundant "timeout" option for watchDir method in the JS SDK
(we're using timeoutMs already)
2025-06-24 19:00:49 +02:00
github-actions[bot]
884e6b3917
[skip ci] Release new versions
2025-06-23 16:58:16 +00:00
Mish Ushakov
05948ed527
Use TextEncoder for crypto/signed URLs ( #790 )
...
- Replaces node:crypto with cross-runtime TextEncoder/TextDecoder API
- The uploadUrl/downloadUrl methods are now async
2025-06-23 09:51:54 -07:00
github-actions[bot]
40c73100bc
[skip ci] Release new versions
2025-06-20 02:52:52 +00:00