Commit Graph

81 Commits

Author SHA1 Message Date
Matt Brockman 87ceec29d9 feat: enable piping on the e2b cli (#1127)
Adds stdin piping support to `e2b sandbox exec`, so users can do:

  ```bash
  echo "data" | e2b sandbox exec <id> -- cat
cat file.bin | e2b sandbox exec <id> -- python3 -c 'import sys;
print(len(sys.stdin.buffer.read()))'
```

  Included:
  - JS SDK updates:
      - closeStdin()
      - supportsStdinClose
  - CLI updates:
      - detects piped stdin
      - streams stdin in 64 KiB chunks
      - closes remote stdin on EOF
  - graceful fallback for older sandbox versions (requires `envd` >= 0.5.2, warn + ignore piped input)


  ### Example Usage

  #### non-piped exec still works
```
  e2b sandbox exec <sandbox_id> -- 'echo backend-non-pipe'
```
  #### piped stdin path (supported envd) should deliver bytes
```
  echo "hello" | e2b sandbox exec <sandbox_id> -- 'wc -c'   # expect 6
printf '\x00\x01\x02\xff' | $e2b sandbox exec <sandbox_id> -- 'wc -c' #
expect 4
```
  #### optional: legacy template behavior should warn + ignore piped stdin
```
echo "hello" | e2b sandbox exec <legacy_sandbox_id> -- 'wc -c' # expect
0 + "Ignoring piped stdin."
```
2026-02-11 16:18:28 -08:00
Jakub Dobry 631522d74a feat: use v2 template update endpoint with namespaced templates (#1105) 2026-01-29 07:01:41 -08:00
Jakub Dobry 10abab8e96 feat: add template versioning with tags support for JS and Python SDKs (#1080) 2026-01-27 13:41:24 +00:00
Jiri Sveceny d8ef36d84f Support Template.aliasExists for JavaScript and Python SDKs (#1068)
Integration tests will fail until the feature is deployed in E2B Cloud
production.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Enables checking template alias availability from both SDKs.
> 
> - JS: Implements `checkAliasExists` in `template/buildApi.ts`, exposes
`Template.aliasExists` in `template/index.ts`, adds `AliasExistsOptions`
type and tests
> - Python: Adds `Template.alias_exists` and
`AsyncTemplate.alias_exists` wired to generated
`get_templates_aliases_{alias}` client; includes sync/async tests
> - API: Regenerates schemas/clients to include `GET
/templates/aliases/{alias}`, template build logs endpoint and
parameters, and supporting models (e.g., `TemplateAliasResponse`)
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
4e577fd77888478ac83b66db7537cd2355ea050b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-12 10:05:48 +00:00
Jakub Dobry 4c612888d4 feat: implement network out allow/deny list support (#1016) 2025-11-15 22:35:09 +00:00
Jakub Novák 423d87cf91 Update spec and templates to use /v3/ endpoint (#1002)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Switches SDKs to the /v3 template build API and updates spec with
sandbox connect, team max metrics, and related schema changes while
deprecating legacy endpoints.
> 
> - **API Spec / Schema**:
> - **Templates v3**: Add `POST /v3/templates` with
`TemplateBuildRequestV3` → `TemplateRequestResponseV3`; deprecate `POST
/templates`, `POST /templates/{templateID}`, and `POST /v2/templates`
(now return `TemplateLegacy`).
> - **Sandbox Connect**: Add `POST /sandboxes/{sandboxID}/connect` with
`ConnectSandbox`; mark `POST /sandboxes/{sandboxID}/resume` as
deprecated.
> - **Team Metrics**: Add `GET /teams/{teamID}/metrics/max` returning
`MaxTeamMetric`.
> - **Schema updates**: `Template` now includes `buildStatus`
(`TemplateBuildStatus`); `BuildLogEntry.step`;
`BuildStatusReason.logEntries`; `NodeStatusChange.clusterID`; replace
`McpConfig` with nullable `Mcp`; add `timestampUnix` to metrics and
deprecate `timestamp`.
> - **JS SDK**:
> - Update template build request to `POST /v3/templates` in
`template/buildApi.ts`.
> - Regenerate `schema.gen.ts` reflecting new endpoints/types and
deprecations.
> - **Python SDK**:
> - Add client for `POST /v3/templates`; switch sync/async build APIs to
use `TemplateBuildRequestV3` and new response type.
>   - Add client for `POST /sandboxes/{sandboxID}/connect`.
> - Introduce/adjust models: `TemplateBuildStatus`,
`TemplateRequestResponseV3`, `TemplateLegacy`, `ConnectSandbox`,
`MaxTeamMetric`, `McpType0`, and metric timestamp fields.
> - **Meta**:
>   - Changesets: patch bumps for affected packages.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
4672fbf655ae3e508bf375dc58a89299e19f0664. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-31 01:53:02 -07:00
Jonas Scholz 12daca8b39 Add custom MCP to SDK (#974)
This adds (experimantal) support to add arbitrary MCP server from
Github.
```python
sbx = await AsyncSandbox.beta_create(timeout=600, mcp={
    "github/modelcontextprotocol/servers": {
        "install_cmd": "npm install",
        "run_cmd": "sudo npx -y @modelcontextprotocol/server-filesystem /root",
    },
})
```

or in TS with better typing:

```typescript
const sandbox = await Sandbox.betaCreate({
    mcp: {
        duckduckgo: {},        
        'github/modelcontextprotocol/servers': {
            installCmd: 'npm install',
            runCmd: `sudo npx -y @modelcontextprotocol/server-filesystem /root`,
        },
    },
    timeoutMs: 600_000,
});
```


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds beta support to launch custom MCP servers (including
GitHub-defined ones) and updates MCP schemas/types; also switches
default MCP template to `mcp-gateway`.
> 
> - **SDK (JS & Python)**:
> - Add beta support for `mcp` config, including dynamic GitHub-based
servers with custom `runCmd/installCmd/envs` and automatic `mcp-gateway`
startup with token.
>   - Send `UNSET`/omit when `mcp` not provided to avoid API noise.
> - Change default MCP template from `mcp-gateway-v0-2` to
`mcp-gateway`.
> - **Types/Schema**:
> - Extend `McpServer` typings (JS `mcp.d.ts`, Python type hints) to
include many servers and descriptive metadata.
> - Introduce GitHub MCP types (TS `GitHubMcpServer`, Python
`GitHubMcpServerConfig`) and export in SDK surfaces.
> - Regenerate and enrich `spec/mcp-server.json` with
titles/descriptions and new server entries.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f3139b8fc2f1246c72734d8048ba277a13e3949d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-20 14:38:18 -07: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
Jakub Dobry de771ea3eb feat: keep user and workdir from the template in the sandbox (#944) 2025-10-15 00:23:01 -07:00
Tomas Valenta 1203ccbad3 Add MCP experimental feature to beta (#936)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Adds beta MCP support to JS/Python SDKs with template auto-selection,
config POST, MCP URL helpers, and codegen for MCP types/schemas.
> 
> - **SDKs (Beta MCP support)**:
>   - **JS SDK**:
> - Add `McpServer` types and export; extend `Sandbox.betaCreate` with
`mcp` option that auto-selects `mcp-gateway-v0`, configures MCP via POST
`/config` on port `50005` with retries, and expose `betaGetMcpUrl()`.
> - Add `wait(ms)` util; generate MCP types from `spec/mcp-server.json`;
new `generate:mcp` script and dev dep `json-schema-to-typescript`.
>   - **Python SDK**:
> - Generate and export `McpServer` (TypedDict); extend sync/async
`beta_create` with `mcp` option, auto-select default MCP template, POST
MCP config with retries, and add `beta_get_mcp_url()`; define `mcp_port`
and `default_mcp_template`.
> - Makefile: add `generate-mcp` target; include
`datamodel-code-generator` in tooling; update lockfile/pyproject deps.
> - **Tooling**:
> - Add `spec/mcp-server.json` schema; update codegen Dockerfile to
install `datamodel-code-generator`.
> -
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
cf3f175d310d4c242cd2e867efd801f5c04f2099. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Jonas Scholz <Jonas.Scholz@bbscholz.de>
2025-10-09 08:37:32 +00: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
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
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 74457ff1dd SDK v2 - Changeset and docs (#862)
SDK v2 release
2025-08-21 08:45:25 -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
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
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
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
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
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
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 5c4d07536f Add filtering option for listing sandboxes (#532)
# Description

Allow users to filter out sandbox based on metadata

---------

Co-authored-by: Mish Ushakov <10400064+mishushakov@users.noreply.github.com>
2025-03-21 15:57:48 +01:00
Jakub Dobrý 25c4539de6 Add watch dir recursive option (missing python client regeneration) 2025-01-28 11:25:42 -08:00
Jakub Novak 594bb174d2 Generate only relevant api routes for the client in SDKs 2025-01-17 11:01:40 -08:00
Mish Ushakov fc8086dcf5 Changed template ls command to sync with latest API changes (#508)
- Added createdBy, createdAt columns
- Hidden 'buildCount', 'lastSpawnedAt', 'spawnCount', 'updatedAt'
columns
- Sync API spec and ts schema to latest

---------

Co-authored-by: Mish Ushakov <mishushakov@users.noreply.github.com>
Co-authored-by: Jakub Novák <jakub@e2b.dev>
2024-12-17 11:35:20 +01:00
Jakub Novak 23ea4adfb1 Rename rpc methods for watcher 2024-10-14 19:51:05 -07:00
Jakub Novak bc42ba1e66 Refactor watch dir 2024-10-14 13:01:59 -07:00
Jakub Novak c5aa13ea86 Fix command for generating from rpc spec 2024-10-14 11:29:20 -07:00
Jakub Novak 81db2b1466 Add sync watch handler 2024-10-11 11:54:00 +02:00
Tomas Valenta b1c3e01c96 Split buf generation 2024-08-20 14:29:57 -07:00
Jakub Novak b38e0ee2a4 Fix env vars type 2024-08-14 13:12:01 +02:00
Jakub Novak 2357fa3da7 Add possibility to add env vars on sandbox create 2024-08-14 11:08:25 +02:00
Jakub Novak e882d152bc Improve spec 2024-08-06 17:54:24 +02:00
Jakub Novak 0976c10a21 Remove file info from remove method 2024-08-06 15:47:03 +02:00
Jakub Novak 08fc1e4c8a Get paths for filesystem operations from envd 2024-08-06 14:48:48 +02:00
Tomas Valenta 6291c13adb Update generated clients; Ensure script cleanup 2024-06-28 16:13:54 -07:00
Tomas Valenta 6b32979f0f Fix python request timeout error; Change auth 2024-06-28 15:01:48 -07:00
Tomas Valenta 41703374c0 Merge branch 'grpc' into beta 2024-06-28 11:10:10 -07:00
Jakub Novak dd8960c572 Add check if template has envd V2 2024-06-26 12:51:12 +02:00
Tomas Valenta 955876ef29 Fix openapi specs 2024-06-24 21:59:12 -07:00
Tomas Valenta 206d6744f0 Fix testing config; [WIP] Add tests; Fix python debug opt; Fix enum mapping 2024-06-24 20:51:47 -07:00
Tomas Valenta d8251e79c7 Client keepalive 2024-06-17 17:47:39 +02:00
Tomas Valenta 8f1839c710 Regenerate envd rpc clients 2024-06-16 21:24:44 +02:00
Tomas Valenta af449d7f5d Fix watch init error 2024-06-13 17:17:43 +02:00
Tomas Valenta 229c13524a Update scripts; Fix dir watch; Improve naming 2024-06-13 15:08:54 +02:00
Tomas Valenta b3617d99d9 [WIP] Fix bug and add proper errors 2024-06-11 13:11:36 +02:00
Tomas Valenta c18ada0b9d Python file handling 2024-06-08 23:22:19 +02:00
Tomas Valenta ef19d8f822 Regenrate RPC; Fix namespacing 2024-06-07 21:35:34 +02:00
Tomas Valenta b04342cbff Fix input stream; [WIP] Python SDK 2024-06-04 00:50:23 +02:00