[PR #306] [MERGED] feat(api): support E2B v2 sandbox create and connect #333

Closed
opened 2026-10-29 14:22:20 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/kvcache-ai/AgentENV/pull/306
Author: @LSX-s-Software
Created: 9/20/2026
Status: ✅ Merged
Merged: 9/21/2026
Merged by: @yingdi-shan

Base: main ← Head: api/e2b-v2


📝 Commits (1)

  • 08bec99 feat(api): support E2B v2 sandbox create and connect

📊 Changes

11 files changed (+1470 additions, -85 deletions)

View changed files

📝 scripts/tests/e2e/suites/02_sandbox_lifecycle.sh (+47 -0)
📝 services/gateway/internal/schedule_hint.go (+1 -1)
📝 services/gateway/internal/schedule_hint_test.go (+22 -18)
📝 services/gateway/internal/server.go (+4 -1)
📝 services/gateway/internal/server_test.go (+59 -50)
📝 src/api/generated/src/apis/sandboxes.rs (+66 -0)
📝 src/api/generated/src/models.rs (+447 -0)
📝 src/api/generated/src/server/mod.rs (+434 -1)
📝 src/api/impls/sandbox.rs (+97 -0)
📝 src/api/openapi.yml (+145 -13)
📝 src/api/server.rs (+148 -1)

📄 Description

What

Support E2B v2 sandbox creation and connection in the node API and gateway. The TypeScript SDK can create a sandbox through POST /v2/sandboxes and connect through POST /v2/sandboxes/{sandboxID}/connect.

Why

E2B TypeScript SDK 2.51.0 uses these v2 endpoints. AgentENV previously registered only GET on /v2/sandboxes, so SDK creation failed with HTTP 405 after template and volume creation succeeded.

Closes #305

Scope and non-goals

Includes OpenAPI and regenerated server changes, v2 handlers, gateway routing and assignment handling, and regression coverage. The schema also marks legacy create/connect deprecated, adds list-operation metadata, and removes obsolete access-token references. This does not implement E2B filesystem-only pause/resume or change storage formats.

Design and behavior changes

  • Reuse existing creation and connect flows. V2 creation enforces secure envd access and defaults an omitted timeout to 300 seconds. Forward metadata, environment, network, volume mounts, custom extension parameters, and MCP configuration to the existing flow.
  • V2 connect accepts an omitted body or timeout, defaults to 300 seconds, extends running-sandbox TTL without shortening it, and resumes paused sandboxes. Preserve existing success/error responses and volume-conflict HTTP 409.
  • A middleware scoped to v2 connect converts an empty HTTP body into JSON null, which the generated Json<Option<ConnectSandboxV2>> extractor accepts. Non-empty bodies retain JSON validation and Axum body-size limits. The generator is unchanged.
  • Gateway v2 creation uses template scheduling hints and records sandbox assignments. V2 connect uses the sandbox path for node lookup, including requests carrying SDK proxy headers.

Compatibility and operations

  • Public API or generated protocol: adds v2 create/connect while retaining legacy endpoints; includes regenerated Rust server types and routes.
  • Configuration or defaults: v2 omitted timeout defaults to 300 seconds; creation always enables secure envd access. Retains AgentENV's autoPause=true default, which differs from E2B's default.
  • Snapshot manifest, artifact layout, or storage format: unchanged.
  • Upgrade and rollback: update both gateway and node server for clustered v2 access. Rollback removes v2 create/connect support; clients using those endpoints must use a compatible server or SDK version.
  • Host requirements, permissions, ports, or dependencies: unchanged.

Validation

  • make fmt
  • make clippy
  • make test-unit
  • Relevant Rust integration tests
  • make -C services test (required when services/ changes)
  • Generated clients/server regenerated with the documented make target
  • Documentation updated
  • Benchmarks or performance comparison completed

The author reports that tests on the final pushed branch passed. Tests were not rerun for PR creation. Recorded implementation validation:

make agentenv-server                                      passed
make fmt                                                 passed
make clippy                                              passed
cargo test -p agentenv --lib api::                         104 passed
cargo test -p agentenv --lib api::server::tests             2 passed on the final middleware fix
make -C services test fmt-check vet                       passed
(cd services && go test ./...)                            passed
SUITE_FILTER='0[29]*' make test-e2e                        2 suites passed:
                                                         lifecycle 34/34, E2B compatibility 8/8

E2E runs used isolated state and runtime dependency directories. The SDK check covers template build, volume persistence, lifecycle operations, and command execution. HTTP tests cover omitted bodies, JSON validation, body-size limits, and unchanged legacy handling.

Skipped checks and reasons: full make test-unit, separate Rust integration targets, and benchmarks are not claimed by the recorded command list. No documentation files changed; the public contract is documented in OpenAPI.

Risks and reviewer notes

Review timeout/security defaults and response mapping in src/api/impls/sandbox.rs, gateway scheduling/binding changes, and the exact route match in src/api/server.rs. The compatibility middleware buffers v2 connect bodies within the existing Axum limit; empty bodies have their content headers normalized, while non-empty requests still require a JSON content type. Cluster behavior has Go test coverage; the recorded VM E2E runs used single-node mode.

Checklist

  • The PR contains one coherent change and no unrelated formatting or refactoring.
  • New behavior is covered by tests, or I explained why testing is impractical.
  • Logs and examples contain no credentials, tokens, or private registry information.
  • I did not manually edit generated code without updating its source and regenerating it.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/kvcache-ai/AgentENV/pull/306 **Author:** [@LSX-s-Software](https://github.com/LSX-s-Software) **Created:** 9/20/2026 **Status:** ✅ Merged **Merged:** 9/21/2026 **Merged by:** [@yingdi-shan](https://github.com/yingdi-shan) **Base:** `main` ← **Head:** `api/e2b-v2` --- ### 📝 Commits (1) - [`08bec99`](https://github.com/kvcache-ai/AgentENV/commit/08bec99a7a1ff2abc6ad782e5a1c397e8fcde8fc) feat(api): support E2B v2 sandbox create and connect ### 📊 Changes **11 files changed** (+1470 additions, -85 deletions) <details> <summary>View changed files</summary> 📝 `scripts/tests/e2e/suites/02_sandbox_lifecycle.sh` (+47 -0) 📝 `services/gateway/internal/schedule_hint.go` (+1 -1) 📝 `services/gateway/internal/schedule_hint_test.go` (+22 -18) 📝 `services/gateway/internal/server.go` (+4 -1) 📝 `services/gateway/internal/server_test.go` (+59 -50) 📝 `src/api/generated/src/apis/sandboxes.rs` (+66 -0) 📝 `src/api/generated/src/models.rs` (+447 -0) 📝 `src/api/generated/src/server/mod.rs` (+434 -1) 📝 `src/api/impls/sandbox.rs` (+97 -0) 📝 `src/api/openapi.yml` (+145 -13) 📝 `src/api/server.rs` (+148 -1) </details> ### 📄 Description ## What Support E2B v2 sandbox creation and connection in the node API and gateway. The TypeScript SDK can create a sandbox through `POST /v2/sandboxes` and connect through `POST /v2/sandboxes/{sandboxID}/connect`. ## Why E2B TypeScript SDK 2.51.0 uses these v2 endpoints. AgentENV previously registered only GET on `/v2/sandboxes`, so SDK creation failed with HTTP 405 after template and volume creation succeeded. ## Related issue Closes #305 ## Scope and non-goals Includes OpenAPI and regenerated server changes, v2 handlers, gateway routing and assignment handling, and regression coverage. The schema also marks legacy create/connect deprecated, adds list-operation metadata, and removes obsolete access-token references. This does not implement E2B filesystem-only pause/resume or change storage formats. ## Design and behavior changes - Reuse existing creation and connect flows. V2 creation enforces secure envd access and defaults an omitted timeout to 300 seconds. Forward metadata, environment, network, volume mounts, custom extension parameters, and MCP configuration to the existing flow. - V2 connect accepts an omitted body or timeout, defaults to 300 seconds, extends running-sandbox TTL without shortening it, and resumes paused sandboxes. Preserve existing success/error responses and volume-conflict HTTP 409. - A middleware scoped to v2 connect converts an empty HTTP body into JSON `null`, which the generated `Json<Option<ConnectSandboxV2>>` extractor accepts. Non-empty bodies retain JSON validation and Axum body-size limits. The generator is unchanged. - Gateway v2 creation uses template scheduling hints and records sandbox assignments. V2 connect uses the sandbox path for node lookup, including requests carrying SDK proxy headers. ## Compatibility and operations - Public API or generated protocol: adds v2 create/connect while retaining legacy endpoints; includes regenerated Rust server types and routes. - Configuration or defaults: v2 omitted timeout defaults to 300 seconds; creation always enables secure envd access. Retains AgentENV's `autoPause=true` default, which differs from E2B's default. - Snapshot manifest, artifact layout, or storage format: unchanged. - Upgrade and rollback: update both gateway and node server for clustered v2 access. Rollback removes v2 create/connect support; clients using those endpoints must use a compatible server or SDK version. - Host requirements, permissions, ports, or dependencies: unchanged. ## Validation - [x] `make fmt` - [x] `make clippy` - [x] `make test-unit` - [x] Relevant Rust integration tests - [x] `make -C services test` (required when `services/` changes) - [x] Generated clients/server regenerated with the documented `make` target - [ ] Documentation updated - [ ] Benchmarks or performance comparison completed The author reports that tests on the final pushed branch passed. Tests were not rerun for PR creation. Recorded implementation validation: ```text make agentenv-server passed make fmt passed make clippy passed cargo test -p agentenv --lib api:: 104 passed cargo test -p agentenv --lib api::server::tests 2 passed on the final middleware fix make -C services test fmt-check vet passed (cd services && go test ./...) passed SUITE_FILTER='0[29]*' make test-e2e 2 suites passed: lifecycle 34/34, E2B compatibility 8/8 ``` E2E runs used isolated state and runtime dependency directories. The SDK check covers template build, volume persistence, lifecycle operations, and command execution. HTTP tests cover omitted bodies, JSON validation, body-size limits, and unchanged legacy handling. Skipped checks and reasons: full `make test-unit`, separate Rust integration targets, and benchmarks are not claimed by the recorded command list. No documentation files changed; the public contract is documented in OpenAPI. ## Risks and reviewer notes Review timeout/security defaults and response mapping in `src/api/impls/sandbox.rs`, gateway scheduling/binding changes, and the exact route match in `src/api/server.rs`. The compatibility middleware buffers v2 connect bodies within the existing Axum limit; empty bodies have their content headers normalized, while non-empty requests still require a JSON content type. Cluster behavior has Go test coverage; the recorded VM E2E runs used single-node mode. ## Checklist - [x] The PR contains one coherent change and no unrelated formatting or refactoring. - [x] New behavior is covered by tests, or I explained why testing is impractical. - [x] Logs and examples contain no credentials, tokens, or private registry information. - [x] I did not manually edit generated code without updating its source and regenerating it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 14:22:20 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/AgentENV#333
No description provided.