[PR #72] [CLOSED] [2/4] feat(api): E2B build-context upload endpoints and configuration #157

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

📋 Pull Request Information

Original PR: https://github.com/kvcache-ai/AgentENV/pull/72
Author: @JoyboyBrian
Created: 7/29/2026
Status: ❌ Closed

Base: main ← Head: e2b-build/04-upload-api


📝 Commits (2)

  • 81a8edb feat(snapshot): template build-context archive store (posixfs + oss)
  • d11d80a feat(api): E2B build-context upload endpoints and [template_build] config

📊 Changes

22 files changed (+2185 additions, -2 deletions)

View changed files

📝 config/default.toml (+24 -0)
➕ src/api/build_files.rs (+287 -0)
📝 src/api/generated/src/apis/templates.rs (+29 -0)
📝 src/api/generated/src/models.rs (+158 -0)
📝 src/api/generated/src/server/mod.rs (+172 -0)
📝 src/api/impls/mod.rs (+4 -0)
📝 src/api/impls/template.rs (+95 -0)
📝 src/api/mod.rs (+1 -0)
📝 src/api/openapi.yml (+48 -0)
📝 src/api/server.rs (+3 -2)
📝 src/cfg.rs (+223 -0)
📝 src/snapshot/image_export/service.rs (+2 -0)
📝 src/snapshot/manager.rs (+8 -0)
➕ src/snapshot/repository/backends/oss/build_files.rs (+169 -0)
📝 src/snapshot/repository/backends/oss/mod.rs (+1 -0)
📝 src/snapshot/repository/backends/oss/repository.rs (+12 -0)
📝 src/snapshot/repository/backends/posixfs/backend.rs (+12 -0)
➕ src/snapshot/repository/backends/posixfs/build_files.rs (+726 -0)
📝 src/snapshot/repository/backends/posixfs/mod.rs (+2 -0)
➕ src/snapshot/repository/build_files.rs (+197 -0)

...and 2 more files

📄 Description

What

Expose the E2B build-context upload contract:

  • GET /templates/{templateID}/files/{hash} returns 201 with {present, url};
  • the returned bearer-token URL accepts a streaming PUT;
  • [template_build] adds upload, expansion, aggregate-context, TTL, timeout, and public-base-URL settings;
  • the HTTP server is regenerated from the OpenAPI source.

This is layer 2 of the active COPY/ADD stack, replayed onto current main at 00ba6cb without #70.

Layer PR Branch Scope
1/4 #71 e2b-build/03-build-file-store Build-context archive store
2/4 #72 e2b-build/04-upload-api Upload API and configuration
3/4 #73 e2b-build/05-copy-plan Host-side COPY planning
4/4 #74 e2b-build/06-copy-exec COPY/ADD execution, E2E, and documentation

Why

The official E2B SDK asks the template service whether a content-addressed context archive is present, uploads it when needed, and then references its hash in the build request. This layer implements that handshake on top of #71's repository store.

Related: #28. The original PR remains the full concept/reference discussion.

Scope and non-goals

This layer adds the OpenAPI contract, generated server surface, request handlers, streaming upload path, configuration, and focused tests. It does not plan guest paths or execute COPY/ADD. Existing-alias rebuild remains unsupported.

Exact layer diff: e2b-build/03-build-file-store...e2b-build/04-upload-api

Design

  • Existing content returns present: true; missing content receives a short-lived, single-use upload URL.
  • Uploads stream to the repository store and are bounded by configured size and timeout limits.
  • Hashes and bearer grants are validated before import.
  • template_build.public_base_url supports TLS termination and multi-hop deployments where the request Host is not the client-facing origin.
  • Generated code is derived from src/api/openapi.yml.

Compatibility and operations

  • Adds the E2B-compatible files endpoint; existing endpoints are unchanged.
  • Configuration defaults preserve direct-node and bundled-gateway behavior.
  • TLS-terminated or externally routed deployments should set template_build.public_base_url so the SDK receives the correct HTTPS upload origin.
  • No snapshot manifest change or new host service is required.

Validation

The rewritten stack was validated on Linux against the #74 tip:

cargo fmt --all -- --check
cargo test --locked -p agentenv --lib template::
# 68 passed, 0 failed
cargo clippy --locked -p agentenv --lib -- -D warnings
make agentenv-server
# regeneration produced no intended generated-code diff

This layer includes handler/config/store integration tests for present/missing archives, grant validation, upload bounds, timeouts, and public URL construction. GitHub CI validates this cumulative branch independently.

Reviewer notes

The security-sensitive surfaces are upload limits, grant single-use semantics, URL construction, and bearer-token handling. #70 is not required to merge this stack.


🔄 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/72 **Author:** [@JoyboyBrian](https://github.com/JoyboyBrian) **Created:** 7/29/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `e2b-build/04-upload-api` --- ### 📝 Commits (2) - [`81a8edb`](https://github.com/kvcache-ai/AgentENV/commit/81a8edbae406df6d93a21063322370cf1bffd109) feat(snapshot): template build-context archive store (posixfs + oss) - [`d11d80a`](https://github.com/kvcache-ai/AgentENV/commit/d11d80a782eae96a71302fe2a699d8741dfec682) feat(api): E2B build-context upload endpoints and [template_build] config ### 📊 Changes **22 files changed** (+2185 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `config/default.toml` (+24 -0) ➕ `src/api/build_files.rs` (+287 -0) 📝 `src/api/generated/src/apis/templates.rs` (+29 -0) 📝 `src/api/generated/src/models.rs` (+158 -0) 📝 `src/api/generated/src/server/mod.rs` (+172 -0) 📝 `src/api/impls/mod.rs` (+4 -0) 📝 `src/api/impls/template.rs` (+95 -0) 📝 `src/api/mod.rs` (+1 -0) 📝 `src/api/openapi.yml` (+48 -0) 📝 `src/api/server.rs` (+3 -2) 📝 `src/cfg.rs` (+223 -0) 📝 `src/snapshot/image_export/service.rs` (+2 -0) 📝 `src/snapshot/manager.rs` (+8 -0) ➕ `src/snapshot/repository/backends/oss/build_files.rs` (+169 -0) 📝 `src/snapshot/repository/backends/oss/mod.rs` (+1 -0) 📝 `src/snapshot/repository/backends/oss/repository.rs` (+12 -0) 📝 `src/snapshot/repository/backends/posixfs/backend.rs` (+12 -0) ➕ `src/snapshot/repository/backends/posixfs/build_files.rs` (+726 -0) 📝 `src/snapshot/repository/backends/posixfs/mod.rs` (+2 -0) ➕ `src/snapshot/repository/build_files.rs` (+197 -0) _...and 2 more files_ </details> ### 📄 Description ## What Expose the E2B build-context upload contract: - `GET /templates/{templateID}/files/{hash}` returns `201` with `{present, url}`; - the returned bearer-token URL accepts a streaming `PUT`; - `[template_build]` adds upload, expansion, aggregate-context, TTL, timeout, and public-base-URL settings; - the HTTP server is regenerated from the OpenAPI source. This is layer 2 of the active COPY/ADD stack, replayed onto current main at `00ba6cb` without #70. | Layer | PR | Branch | Scope | |---|---|---|---| | 1/4 | #71 | `e2b-build/03-build-file-store` | Build-context archive store | | **2/4** | **#72** | **`e2b-build/04-upload-api`** | **Upload API and configuration** | | 3/4 | #73 | `e2b-build/05-copy-plan` | Host-side COPY planning | | 4/4 | #74 | `e2b-build/06-copy-exec` | COPY/ADD execution, E2E, and documentation | ## Why The official E2B SDK asks the template service whether a content-addressed context archive is present, uploads it when needed, and then references its hash in the build request. This layer implements that handshake on top of #71's repository store. Related: #28. The original PR remains the full concept/reference discussion. ## Scope and non-goals This layer adds the OpenAPI contract, generated server surface, request handlers, streaming upload path, configuration, and focused tests. It does not plan guest paths or execute COPY/ADD. Existing-alias rebuild remains unsupported. Exact layer diff: [e2b-build/03-build-file-store...e2b-build/04-upload-api](https://github.com/JoyboyBrian/AgentENV/compare/e2b-build/03-build-file-store...e2b-build/04-upload-api) ## Design - Existing content returns `present: true`; missing content receives a short-lived, single-use upload URL. - Uploads stream to the repository store and are bounded by configured size and timeout limits. - Hashes and bearer grants are validated before import. - `template_build.public_base_url` supports TLS termination and multi-hop deployments where the request `Host` is not the client-facing origin. - Generated code is derived from `src/api/openapi.yml`. ## Compatibility and operations - Adds the E2B-compatible files endpoint; existing endpoints are unchanged. - Configuration defaults preserve direct-node and bundled-gateway behavior. - TLS-terminated or externally routed deployments should set `template_build.public_base_url` so the SDK receives the correct HTTPS upload origin. - No snapshot manifest change or new host service is required. ## Validation The rewritten stack was validated on Linux against the #74 tip: ```text cargo fmt --all -- --check cargo test --locked -p agentenv --lib template:: # 68 passed, 0 failed cargo clippy --locked -p agentenv --lib -- -D warnings make agentenv-server # regeneration produced no intended generated-code diff ``` This layer includes handler/config/store integration tests for present/missing archives, grant validation, upload bounds, timeouts, and public URL construction. GitHub CI validates this cumulative branch independently. ## Reviewer notes The security-sensitive surfaces are upload limits, grant single-use semantics, URL construction, and bearer-token handling. #70 is not required to merge this stack. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 14:20:22 +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#157
No description provided.