Commit Graph

156 Commits

Author SHA1 Message Date
Jakub Dobry f593bb7004 fix: update dev container naming (#989) 2025-10-24 22:34:45 +00:00
Jakub Dobry 1fa99a3d20 feat: devcontainer template support (#988) 2025-10-24 14:20:29 -07:00
Mish Ushakov c432805161 Promote beta MCP features to main (#986)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Promotes MCP to stable across JS/Python SDKs: add `mcp` config to
sandbox creation, auto-select MCP template, start gateway with token,
rename beta APIs to stable (`getMcpUrl`/`getMcpToken`, `addMcpServer`).
> 
> - **JS SDK**:
> - **Sandbox creation**: `Sandbox.create` now accepts `opts.mcp`;
auto-selects `defaultMcpTemplate`, starts `mcp-gateway` with generated
token, and returns initialized sandbox.
> - **API opts**: Move `mcp` from `SandboxBetaCreateOpts` to
`SandboxOpts`; pass `mcp` through `SandboxApi.createSandbox`.
> - **Stable MCP APIs**: Rename `betaGetMcpUrl` -> `getMcpUrl`,
`betaGetMcpToken` -> `getMcpToken`.
>   - **Template builder**: Rename `betaAddMcpServer` -> `addMcpServer`.
>   - **Tests**: Update stacktrace tests to new method names.
> - **Python SDK**:
> - **Sandbox creation**: `AsyncSandbox.create`/`Sandbox.create` accept
`mcp`; auto-select MCP template when unset, start `mcp-gateway`, store
token.
> - **Stable MCP APIs**: Add `get_mcp_url`; rename `beta_get_mcp_token`
-> `get_mcp_token`.
> - **Types**: Minor signature tweaks (e.g., `secure` default handling).
>   - **Tests**: Update stacktrace tests to new method names.
> - **Release**:
>   - Changeset: minor version bumps for `@e2b/python-sdk` and `e2b`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9c673f80eee37e530d05c6becf5a4a3c492ac9f3. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-22 21:22:02 +02:00
Mish Ushakov 818e8c2647 Add force option to make symlink method (#984)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Adds a force option to makeSymlink that passes -f to ln, with
typings/docs and tests across JS and Python SDKs.
> 
> - **Template symlink enhancement**
>   - **JS SDK (`packages/js-sdk`)**:
> - `makeSymlink(src, dest, options)` now accepts `{ user?: string;
force?: boolean }` and appends `-f` when `force` is true in
`src/template/index.ts`.
> - Types updated in `src/template/types.ts`, including example usage
with `{ force: true }`.
> - Tests added in `tests/template/methods/makeSymlink.test.ts` (regular
and forced).
>   - **Python SDK (`packages/python-sdk`)**:
> - `make_symlink(src, dest, user=None, force=False)` now supports
`force` and appends `-f` when true in `e2b/template/main.py`.
>     - Docstring examples updated to include `force=True`.
> - Tests added for async and sync in
`tests/async/template_async/methods/test_make_symlink.py` and
`tests/sync/template_sync/methods/test_make_symlink.py`.
> - **Release**:
>   - Changeset added for patch releases of `@e2b/python-sdk` and `e2b`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
6c5bbf9edfc7234b703046f387d11b8f10a002ab. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-22 00:48:11 +02:00
Mish Ushakov de2a922aa5 Make no install recommends optional (#983)
This was causing some unexpected issues if users were trying to
apt-install some packages that needed recommended dependencies.

<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Adds an option to `aptInstall`/`apt_install` to toggle
`--no-install-recommends`, updates typings/docs, and adds tests for both
modes.
> 
> - **Template APIs**:
>   - **JS SDK (`packages/js-sdk`)**:
> - `aptInstall` now accepts `options?: { noInstallRecommends?: boolean
}` and conditionally includes `--no-install-recommends`.
>     - Types updated in `src/template/types.ts` with example usage.
>   - **Python SDK (`packages/python-sdk`)**:
> - `apt_install` now accepts `no_install_recommends: bool = False` and
conditionally includes `--no-install-recommends`.
> - **Tests**:
> - JS: Add `aptInstall` tests (with and without `noInstallRecommends`);
refactor `npmInstall` tests to use `buildTemplateTest` helper.
> - Python: Add async and sync tests for `apt_install` with and without
`no_install_recommends`.
> - **Changeset**:
> - Patch bumps for `@e2b/python-sdk` and `e2b` with note on making
`--no-install-recommends` optional.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3963b7daca73f1cfb99f405b09fbfb86c40c4b4f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-21 14:59:57 -07:00
Mish Ushakov d4619f641b Fixes ubuntu default image tag and added tests (#982)
The "lts" tag was unavailable on Docker Hub

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Switch default Ubuntu image tag from 'lts' to 'latest' across
JS/Python SDKs and expand/refactor template tests and test config.
> 
> - **SDKs**:
> - **Ubuntu default**: Change `fromUbuntuImage`/`from_ubuntu_image`
default variant from `'lts'` to `'latest'` in
`packages/js-sdk/src/template/index.ts` and
`packages/python-sdk/e2b/template/main.py`; update TS docs in
`packages/js-sdk/src/template/types.ts`.
> - **Tests**:
> - **JS**: Refactor template tests to use `buildTemplateTest`, add
`tests/template/methods/fromMethods.test.ts`, adjust npm/pip/runCmd
tests (include user install with `g: false`), and remove per-test
timeouts where not needed.
> - **Python (async/sync)**: Add comprehensive tests for from* methods,
npm/pip installs (including user installs), and runCmd behaviors; switch
to shared build fixtures.
> - **Vitest config**: Exclude `tests/template/**` from the main suite
and include all template tests in a dedicated project in
`vitest.workspace.mts`.
> - **Changeset**:
>   - Patch bumps for `@e2b/python-sdk` and `e2b`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0bf3a7c15122d28cbc99b8faa44e7e217f634377. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-21 16:47:09 +02:00
Mish Ushakov 314bc14143 Test setup: append "e2b-test" to templates generated in tests (#981)
So that we ca distinguish templates in our team account that are built
from the CI tests.
2025-10-21 12:29:58 +00:00
Jonas Scholz 68abd92c40 Add mcp server prepull (#975)
Adds prepulling mcp server images to the SDK.

```typescript
export const template = Template()
    .fromTemplate("mcp-gateway")
    .betaAddMcpServer("arxiv")

await Template.build(template, {
    alias: "arxiv-mcp-gateway",
    cpuCount: 1,
    memoryMB: 1024,
    onBuildLogs: console.log,
});

```


```python
template = Template().from_template("mcp-gateway").beta_add_mcp_server("arxiv")

Template.build(
    template,
    alias="arxiv-mcp-gateway-v1",
    cpu_count=1,
    memory_mb=1024,
)

```


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Introduce beta methods to prepull MCP servers via mcp-gateway in JS
and Python templates, with typing, validation, and stacktrace-tested
errors.
> 
> - **Template SDKs**
>   - **JS**:
> - Add `Template.betaAddMcpServer(servers: McpServerName |
McpServerName[])` to run `mcp-gateway pull ...`.
> - Enforce base template check (`'mcp-gateway'`), throwing `BuildError`
with stack trace.
> - Introduce and export `McpServerName` type (from `../sandbox/mcp`).
>   - **Python**:
> - Add `Template.beta_add_mcp_server(servers: Union[str, List[str]])`
to run `mcp-gateway pull ...`.
> - Enforce `'mcp-gateway'` base template; raise `BuildException` with
captured traceback.
> - **Tests**
> - Add stacktrace tests for `betaAddMcpServer` (JS) and
`beta_add_mcp_server` (Python async/sync).
> - **Release**
>   - Changeset: patch bumps for `@e2b/python-sdk` and `e2b`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
43b4a01ce3c856dff7def5ba6b706ee00eda0f84. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Joseph Lombrozo <joe.lombrozo@e2b.dev>
2025-10-20 14:52:30 -07:00
Mish Ushakov 83243d5b43 Add user option to fs methods in Template (#976)
(no tests as nothin was breaking)


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds an optional `user` parameter to fs-related template methods and
`gitClone`, with tests for running commands as specific users.
> 
> - **SDKs**:
>   - **JS (`packages/js-sdk`)**:
> - Add `user` option to `TemplateBuilder` methods: `remove`, `rename`,
`makeDir`, `makeSymlink`, and `gitClone`; pass through to `runCmd`.
>     - Update type defs and examples in `src/template/types.ts`.
>   - **Python (`packages/python-sdk`)**:
> - Add `user` arg to `TemplateBuilder` methods: `remove`, `rename`,
`make_dir`, `make_symlink`, and `git_clone`; forward to `run_cmd`.
>     - Update docstrings/examples.
> - **Tests**:
> - JS: add `runCmd` tests for default, specific `user`, and invalid
user in `packages/js-sdk/tests/template/methods/runCmd.test.ts`.
> - Python: add async and sync `run_cmd` tests (default, specific
`user`, invalid user) in
`packages/python-sdk/tests/async/.../test_run_cmd.py` and
`packages/python-sdk/tests/sync/.../test_run_cmd.py`.
> - **Release**:
> - Add changeset (`.changeset/warm-seals-design.md`) marking patch
bumps for `@e2b/python-sdk` and `e2b`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
b0cbedc1d5c136367155c5646859842bd666b0d9. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-20 23:44:05 +02:00
Joseph Lombrozo 8c77cb04db Support overriding the api_url directly (#946)
This will help for local development

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Add support to override the API base URL via `api_url` parameter or
`E2B_API_URL` env var with clear precedence.
> 
> - **Python SDK**:
>   - **ConnectionConfig**:
> - Add `api_url` parameter and `_api_url()` env lookup (`E2B_API_URL`).
> - Resolve `api_url` in order: constructor arg > `E2B_API_URL` >
`debug` localhost or `https://api.<domain>`.
>   - **API Params**:
> - Include `api_url` in `ApiParams` and propagate via `get_api_params`.
>   - **Tests** (`packages/python-sdk/tests/test_connection_config.py`):
>     - Verify default, arg override, env override, and precedence.
> - **Changeset**: Patch release for `@e2b/python-sdk`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9be6d4e85bb0ad8ea52ad61c77530ac72f231c54. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-20 11:53:19 -07:00
Jonas Scholz cc595f3fc8 Revert timeout changes in tests (#973) 2025-10-20 00:25:50 +02:00
Mish Ushakov c47927f1d0 Fix .toDocker RUN and COPY handling (#972)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Fix Dockerfile generation to properly render `RUN` and `COPY`
instructions using only relevant args, and add patch changesets.
> 
> - **Template to Dockerfile generation**:
> - JS (`packages/js-sdk/src/template/index.ts`): Special-case `RUN` and
`COPY` so Dockerfile emits `RUN <cmd>` and `COPY <src> <dest>` instead
of joining all args.
> - Python (`packages/python-sdk/e2b/template/main.py`): Same
special-casing for `RUN` and `COPY` during Dockerfile rendering.
> - **Release**:
> - Changeset: patch bumps for `@e2b/python-sdk` and `e2b` with note
"fix RUN and COPY handling in to_dockerfile".
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
04b2dbbda34f0845f3d4ec9963cc478b7b7b7f01. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-18 19:35:22 +02:00
Jonas Scholz d7d55df930 Add mcp to request body (#961)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Adds `mcp` config support for sandbox creation across API, JS, and
Python SDKs, and updates timeout tests to use explicit request timeouts.
> 
> - **API/OpenAPI**:
> - Add `McpConfig` schema and `mcp` field to `NewSandbox` in
`spec/openapi.yml` and generated TS `schema.gen.ts`.
> - **JS SDK**:
> - `SandboxApi.createSandbox` sends `mcp` in POST body
(`packages/js-sdk/src/sandbox/sandboxApi.ts`).
>   - Types updated to include `components["schemas"]["McpConfig"]`.
> - **Python SDK**:
> - Extend `NewSandbox` model and sandbox create flow to accept/pass
`mcp`; async/sync APIs propagate `mcp` to POST `/sandboxes`.
> - **Tests**:
> - Increase `is_running` request timeouts in timeout tests to reduce
flakiness (JS and Python).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
04ad4e6d4947e33523b74aba2f703fa1e9c05e72. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-17 12:31:32 -07:00
Mish Ushakov d877205874 Implement stack traces override context for fromDockerfile (#959)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Adds a stack trace override context so fromDockerfile errors point to
the caller; enables related tests and bumps patch versions.
> 
> - **Template stack traces**:
>   - JS (`packages/js-sdk/src/template/index.ts`):
>     - Add `stackTracesOverride` and `runInStackTraceOverrideContext`.
> - `fromDockerfile` parses within override using
`getCallerFrame(STACK_TRACE_DEPTH - 1)`.
>     - `collectStackTrace` respects override.
>   - Python (`packages/python-sdk/e2b/template/main.py`):
> - Add `_stack_traces_override` and
`_run_in_stack_trace_override_context`.
> - `from_dockerfile` parses within override using caller frame-derived
`TracebackType`.
>     - `_collect_stack_trace` respects override.
> - **Tests**:
> - Enable stack trace expectations for `fromTemplate` and
`fromDockerfile` in JS and Python (sync/async) stacktrace tests.
> - **Release**:
>   - Patch bumps for `@e2b/python-sdk` and `e2b`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ef0db209ea968b2cedb39cd56b82f637ede3e4e0. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-15 09:31:50 -07:00
Jakub Dobry 3046491ea9 feat: set default user and workdir when using Dockerfile (#954)
Set default user for Dockerfiles. Includes also small migrate fixes.



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Defaults Dockerfile-based templates to user 'user' and workdir
'/home/user', updates CLI templates (sudo start/ready, relative Python
import), and allows template migration without a config file.
> 
> - **SDKs (Dockerfile parsing)**:
> - JS (`packages/js-sdk/src/template/dockerfileParser.ts`) and Python
(`packages/python-sdk/e2b/template/dockerfile_parser.py`): after
parsing, set defaults `setUser('user')` and `setWorkdir('/home/user')`.
> - **CLI Templates**:
> - Python build scripts: switch to relative import `from .template
import template`.
> - Generated template hbs: start/ready commands now prefixed with
`sudo`; removed explicit root/workdir before start/ready.
> - **CLI Migrate**:
> - Supports migration without `e2b.toml`; uses default config values
and prints a warning instead of exiting.
> - Initializes default config when missing; success messaging adjusted.
> - **Tests**:
> - Update fixtures to reflect new defaults (`set_user('user')`,
`set_workdir('/home/user')`, `sudo` start/ready, relative imports).
>   - Relax error case to succeed with warning when config is missing.
> - Comment out stacktrace tests for `fromDockerfile` in JS/Python until
fixed.
> - **Changesets**: Patch bumps for `@e2b/cli`, `@e2b/python-sdk`, and
`e2b`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
934dc3b23b5607f70d4a4f5b7a9413a9d04df28a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-15 05:51:40 -07:00
Jakub Dobry 86786e578f fix: template tests after infra update (#956)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Updates stacktrace tests to use root-owned paths for workdir/dir ops
and a more explicit failing set_user command in JS and Python
(async/sync) SDKs.
> 
> - **Tests (stacktrace)**:
>   - **JS SDK (`packages/js-sdk/tests/template/stacktrace.test.ts`)**:
> - `setWorkdir`: set user to `root` and change path to `/root/.bashrc`.
>     - `setUser`: use `; exit 1` as the failing command.
>   - **Python SDK**:
> - Async
(`packages/python-sdk/tests/async/template_async/test_stacktrace.py`):
> - `make_dir`, `set_workdir`: set user to `root` and target
`/root/.bashrc`.
>       - `set_user`: use `; exit 1` as the failing command.
> - Sync
(`packages/python-sdk/tests/sync/template_sync/test_stacktrace.py`):
> - `make_dir`, `set_workdir`: set user to `root` and target
`/root/.bashrc`.
>       - `set_user`: use `; exit 1` as the failing command.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
780023b3819f19ba908ccd794195e630bab2741b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-15 03:26:35 -07:00
Mish Ushakov c40eeaac38 Improve regex for fileContextPath (#939)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Improve stack-trace path parsing for caller directory and add
JS/Python tests; publish as patch.
> 
> - **Template utils (JS SDK)**:
> - Add `matchFileDir` to robustly extract file directory from
stack-trace lines (handles anonymous frames).
> - Refactor `getCallerDirectory` to use `matchFileDir` for path
parsing.
> - **Tests**:
>   - Add JS tests for `getCallerDirectory` and `matchFileDir`.
>   - Add Python async/sync tests for `get_caller_directory`.
> - **Release**:
>   - Add changeset marking a patch for `e2b`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
6bd8aa7353479c1657f63c99c732faee042f4c06. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Jakub Dobry <jakub.dobry8@gmail.com>
2025-10-10 12:27:40 +00:00
Mish Ushakov faeeb78a3c Skip cache before image in TypeScript (#937)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Adjusts `skipCache` to return `this` in types and aligns
implementation for proper fluent chaining.
> 
> - **JS SDK – `template`**:
> - **Types**: Change `skipCache` return type from `TemplateBuilder` to
`this` in `types.ts` (`TemplateFromImage`, `TemplateBuilder`).
> - **Implementation**: Align `skipCache` in `index.ts` by removing
explicit return type annotation to match `this` chaining.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
58131d1e5c8caaddc3a23523f99c069ac00a32a7. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-09 16:25:47 +00:00
Jakub Dobry a01c2374a9 feat: pretty default logs for build helper (#925) 2025-10-09 05:44:03 -07:00
Mish Ushakov edfcc63076 Improve method naming and consistency (#934)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Unifies Template APIs across JS/Python with PathLike support, new
copyItems, option/name tweaks, and simpler registry auth via
credentials; updates parser, exports, and tests.
> 
> - **Template API (JS + Python)**
> - Add PathLike support for paths in `copy`, `remove`, `rename`,
`makeDir`, `makeSymlink`, `setWorkdir`, and `gitClone`.
> - Introduce `copyItems` and corresponding `CopyItem` typing; adjust
Dockerfile parser to use `copyItems` overload.
> - Simplify registry auth: `fromImage(baseImage, credentials)` accepts
`{username,password}`; remove `fromRegistry`; update
`fromAWSRegistry`/`fromGCPRegistry` to take credentials and set config
internally.
> - Rename options: `ignoreFilePaths` -> `fileIgnorePatterns`;
`fileContextPath` can be `PathLike`.
> - Ensure internal hashing/upload use stringified paths; minor
enum/type tweaks (e.g., `InstructionType` as string enum, `forceUpload?:
true`).
> - **Exports**
>   - Export `CopyItem` from JS `index.ts` and Python `__init__.py`.
> - **Tests**
> - Update stacktrace and build tests to new method names/signatures
(e.g., registry via `fromImage` credentials, new `copyItems` tests,
optional `skipCache` param).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
95391030550a340fe99ebaac4494867b3e3e9507. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Jakub Dobry <jakub.dobry8@gmail.com>
2025-10-09 00:51:02 +02:00
Mish Ushakov b1e2701931 Correct file hashing logic in the SDK (#916)
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Co-authored-by: Jakub Dobry <jakub.dobry8@gmail.com>
2025-10-01 05:37:58 -07:00
Jakub Novák e142c23c31 Set stdin to /dev/null by default (#919)
Disable stdin (setting it to `/dev/null` for `command.run()`, but enable
to setting it to pipe, which you can send the input via
`command.sendStdin()`
This fixes issues with tools checking for stdin and then hanging
indefinitely

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Disables stdin by default and introduces a new `StartRequest.stdin`
flag to opt-in to stdin piping, updating JS/Python SDKs, version gating,
and tests.
> 
> - **Spec/Protobuf**:
> - Add `optional bool stdin` to `process.StartRequest` in
`spec/envd/process/process.proto` and regenerate JS/Python protos.
> - **JS SDK**:
> - Add `ENVD_COMMANDS_STDIN = '0.3.0'` and version check; error if
`stdin === false` on older envd.
> - Extend `CommandStartOpts` with `stdin` (default `false`); pass
`stdin` to `rpc.start`.
> - **Python SDK**:
> - Add `ENVD_COMMANDS_STDIN = Version("0.3.0")` and version check
mirroring JS.
> - Extend async/sync `commands.run()` with `stdin` (default `False`);
pass to `StartRequest`.
>   - Update generated `process_pb2`/`.pyi` with `StartRequest.stdin`.
> - **Tests**:
> - Update send-stdin tests to run commands with `stdin:
true`/`stdin=True`.
> - **Changeset**:
>   - Minor bump for `@e2b/python-sdk` and `e2b`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
458a15187e6eadccd43540e6b8972c4d45e1bb78. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-09-29 05:34:16 -07:00
Jakub Dobry 1c34e5dd0b fix: npm install and pip install helpers (#923) 2025-09-29 05:33:46 -07:00
Jakub Novák d90c201cf3 Update docstring in toml after CLI template build (#868)
Forgotten text with old way how to create sandbox in sync Python
2025-09-26 12:06:27 +00:00
Jakub Dobry 4b463bd09b Fix template SDK tests (#918) 2025-09-26 05:01:41 -07:00
Jakub Dobry e81c59be8c Fix template folder copy (#911) 2025-09-19 18:55:07 +00:00
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
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
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 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 da7c60d2dd Simplify connection config handling in Python SDK (#849)
Several improvements and refactors to the Python SDK's sandbox
connection and configuration logic.

The main focus is on making header management more flexible, improving
API parameter handling, and simplifying class structures for better
maintainability and usability.

Also unifies doc strings
2025-08-10 08:09:45 -07: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 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
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
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
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
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
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
Mish Ushakov b21f86c543 Added lint workflow for JS, Python SDKs (#759)
- Linted all existing files
- Added GitHub workflow to check everything is linted correctly
2025-06-05 14:52:48 +02:00
Mish Ushakov bf7e862a07 Added skip if debug for some tests (#737) 2025-05-20 03:15:31 -07:00
Jiri Sveceny 2def1305f3 Flag for securing envd access with auth token (#688)
Waiting until secure flag will be available in production cluster.

---------

Co-authored-by: Jakub Novák <jakub@e2b.dev>
2025-05-14 15:15:18 +00:00
Jakub Novák 106d0a7715 Remove closed port tests (#722)
# Description

They will be moved to infra, they are integration tests
2025-05-12 13:32:30 -07:00
Tomas Valenta 88266d6ae6 Unify passing of template used in tests and log background commands output (#704)
- Show errors from background commands
- Unify passing of template used in tests
2025-05-06 00:55:03 -07:00
0div a5b08de85f Add optional depth parameter to SDK file listing methods. (#649)
# Description

Do not merge before https://github.com/e2b-dev/infra/pull/524 is merged
and deployed.

The DX would look like this:
```js
const files = await sandbox.files.list(dirName, { depth: 3 })
```
- [x] update `envd` pb spec 
- [x] generate for `js-sdk`
- [x] update `js-sdk` `file.list` method to include optional depth param
- [x] update `js-sdk` tests
- [x] generate for `python-sdk`
- [x] update `python-sdk` `file.list` method to include optional depth
param
  - [x] sync
  - [x] async
- [x] update `python-sdk` tests
  - [x] sync
  - [x] async

---------

Co-authored-by: Mish <10400064+mishushakov@users.noreply.github.com>
2025-05-05 09:17:08 -07:00
0div e0c1bc752d Make codegen robust and deterministic for js and python SDKs (#664)
# Description 

This PR allows to codegen without worrying about your environment and
dependencies for consistent outcomes in what code is generated from
openapi and envd protobuf spec. Will generate files for `js-sdk` and
`python-sdk`

- [x] create Docker image with all the pinned deps needed to codegen
- [x] create codegen script using this container with mapped volumes
- [x] adapt Makefiles to this new approach
- [x] adapt where we install the connect-python protobuf binary for this
to work

# Test

```sh
make codegen # this command is similar to `make generate` but w/o the hassle

Generating SDK code from openapi and envd spec
cd packages/js-sdk && pnpm generate

> e2b@1.2.1 generate /workspace/packages/js-sdk
> python ./../../spec/remove_extra_tags.py sandboxes templates && openapi-typescript ../../spec/openapi_generated.yml -x api_key --arr
ay-length --alphabetize --output src/api/schema.gen.ts

 openapi-typescript 7.6.1
🚀 ../../spec/openapi_generated.yml → src/api/schema.gen.ts [44.2ms]
cd packages/js-sdk && pnpm generate-envd-api

> e2b@1.2.1 generate-envd-api /workspace/packages/js-sdk
> openapi-typescript ../../spec/envd/envd.yaml -x api_key --array-length --alphabetize --output src/envd/schema.gen.ts

 openapi-typescript 7.6.1
🚀 ../../spec/envd/envd.yaml → src/envd/schema.gen.ts [22.7ms]

[...]

cd packages/python-sdk && make generate-api

All done!  🍰 
```

---------

Co-authored-by: Jiri Sveceny <jiri.sveceny@icloud.com>
2025-04-07 17:00:31 +02:00
Jakub Novák 74a6944140 Fix test for closed ports (#668)
# Description

The response from backend for port is actual integer
2025-04-05 20:38:38 +01:00
0div bd4398f30d address PR comments 2025-03-25 15:53:42 -07:00
0div 6dd18e2832 allow writing files that are of type io.BufferedReader and update tests 2025-03-25 14:39:58 -07:00
Mish c0efd6f322 added additional test coverage for getInfo, updated doc 2025-03-24 16:59:37 +01:00