[PR #350] [CLOSED] feat: add webhook API #370

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

📋 Pull Request Information

Original PR: https://github.com/kvcache-ai/AgentENV/pull/350
Author: @zlzGithub-0801
Created: 10/9/2026
Status: ❌ Closed

Base: main ← Head: feat/webhook


📝 Commits (1)

📊 Changes

27 files changed (+7736 additions, -34 deletions)

View changed files

📝 docs/src/SUMMARY.md (+1 -0)
➕ docs/src/concepts/sandboxes/webhooks.md (+178 -0)
📝 services/README.md (+2 -0)
📝 services/gateway/internal/cluster_list.go (+366 -0)
📝 services/gateway/internal/cluster_list_test.go (+362 -0)
📝 services/gateway/internal/metrics.go (+11 -0)
📝 services/gateway/internal/server.go (+5 -0)
📝 src/api/generated/src/apis/mod.rs (+1 -0)
➕ src/api/generated/src/apis/webhooks.rs (+203 -0)
📝 src/api/generated/src/models.rs (+2331 -0)
📝 src/api/generated/src/server/mod.rs (+1183 -0)
📝 src/api/impls/mod.rs (+9 -0)
➕ src/api/impls/webhooks.rs (+555 -0)
📝 src/api/openapi.yml (+556 -0)
📝 src/api/server.rs (+1 -0)
📝 src/bin/server.rs (+20 -10)
📝 src/lib.rs (+1 -0)
📝 src/orchestrator/service.rs (+15 -23)
📝 src/orchestrator/tests.rs (+53 -0)
📝 src/orchestrator/types.rs (+6 -1)

...and 7 more files

📄 Description

What

Adds E2B-compatible lifecycle event webhooks, implemented natively in the node:

  • GET/POST /events/webhooks, GET/PATCH/DELETE /events/webhooks/{webhookID},
    GET /events/webhooks/{webhookID}/deliveries, GET /events/webhooks/{webhookID}/stats
  • Signed POST delivery of sandbox lifecycle events (created, killed, paused,
    resumed, forked) to every enabled, subscribed webhook
  • Gateway fan-out that merges deliveries and stats across all nodes

Why

Webhooks are not im

#5

Scope and non-goals

  • Included: the 7 endpoints, signed delivery with retries, and gateway
    aggregation of deliveries and stats.
  • Not included: E2B's updated and checkpointed events (registering them
    returns 400), event_data.execution and kill_reason, the
    /events/sandboxes* query API, durable delivery, and multi-tenancy.
  • The custom extension API is unchanged.

Design and behavior changes

  1. Configuration is stored in the shared backend. Each webhook is
    webhooks/{id}.json in the snapshot repository (POSIX or OSS), so nodes that
    share a repository share registrations. Every change also updates
    webhooks/generation. Nodes check this marker before each event and reload
    when it changes, so a change made on any node applies to the next event on
    every node.
  2. Webhooks listen to sandbox lifecycle events. They subscribe to the existing
    orchestrator lifecycle broadcast and support created, killed, paused,
    resumed, and forked. forked is an AgentENV extension and carries
    source_sandbox_id. Each node delivers only events for its own sandboxes.
  3. Delivery history is stored in node-local RocksDB. Each attempt is written
    to $AENV_HOME/webhooks/deliveries and pruned hourly after 7 days. Through the
    gateway, deliveries and stats are sent to every node and the results are
    merged. If any node fails, the request returns 502.

Compatibility and operations

  • Public API or generated protocol: Additive. 7 endpoints under a new webhooks
    tag, with E2B schemas. /stats additionally returns 400 when start >= end or
    the range exceeds 31 days. The scheduler proto is unchanged: Update/Checkpoint
    events never existed in it, and webhook-only data is not reported.
  • Configuration or defaults: N/A
  • Snapshot manifest, artifact layout, or storage format: Repositories gain
    webhooks/{id}.json and webhooks/generation
  • Upgrade and rollback: N/A
  • **Host requirements, permissions, ports, or dependencies:**N/A

Validation

  • make fmt
  • make clippy
  • make test-unit:
  • Relevant Rust integration tests
  • make -C services test, plus make -C services fmt-check vet
  • Generated clients/server regenerated with the documented make target
    (make agentenv-server)
  • Documentation updated (docs/src/concepts/sandboxes/webhooks.md, services/README.md)
  • Benchmarks or performance comparison completed

Risks and reviewer notes

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/350 **Author:** [@zlzGithub-0801](https://github.com/zlzGithub-0801) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/webhook` --- ### 📝 Commits (1) - [`9ab1d30`](https://github.com/kvcache-ai/AgentENV/commit/9ab1d30713368cba8e509ddd532c64e40fe906a1) feat: add webhook API ### 📊 Changes **27 files changed** (+7736 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `docs/src/SUMMARY.md` (+1 -0) ➕ `docs/src/concepts/sandboxes/webhooks.md` (+178 -0) 📝 `services/README.md` (+2 -0) 📝 `services/gateway/internal/cluster_list.go` (+366 -0) 📝 `services/gateway/internal/cluster_list_test.go` (+362 -0) 📝 `services/gateway/internal/metrics.go` (+11 -0) 📝 `services/gateway/internal/server.go` (+5 -0) 📝 `src/api/generated/src/apis/mod.rs` (+1 -0) ➕ `src/api/generated/src/apis/webhooks.rs` (+203 -0) 📝 `src/api/generated/src/models.rs` (+2331 -0) 📝 `src/api/generated/src/server/mod.rs` (+1183 -0) 📝 `src/api/impls/mod.rs` (+9 -0) ➕ `src/api/impls/webhooks.rs` (+555 -0) 📝 `src/api/openapi.yml` (+556 -0) 📝 `src/api/server.rs` (+1 -0) 📝 `src/bin/server.rs` (+20 -10) 📝 `src/lib.rs` (+1 -0) 📝 `src/orchestrator/service.rs` (+15 -23) 📝 `src/orchestrator/tests.rs` (+53 -0) 📝 `src/orchestrator/types.rs` (+6 -1) _...and 7 more files_ </details> ### 📄 Description ## What Adds E2B-compatible lifecycle event webhooks, implemented natively in the node: - `GET/POST /events/webhooks`, `GET/PATCH/DELETE /events/webhooks/{webhookID}`, `GET /events/webhooks/{webhookID}/deliveries`, `GET /events/webhooks/{webhookID}/stats` - Signed `POST` delivery of sandbox lifecycle events (`created`, `killed`, `paused`, `resumed`, `forked`) to every enabled, subscribed webhook - Gateway fan-out that merges `deliveries` and `stats` across all nodes ## Why Webhooks are not im ## Related issue #5 ## Scope and non-goals - Included: the 7 endpoints, signed delivery with retries, and gateway aggregation of `deliveries` and `stats`. - Not included: E2B's `updated` and `checkpointed` events (registering them returns `400`), `event_data.execution` and `kill_reason`, the `/events/sandboxes*` query API, durable delivery, and multi-tenancy. - The custom extension API is unchanged. ## Design and behavior changes 1. **Configuration is stored in the shared backend.** Each webhook is `webhooks/{id}.json` in the snapshot repository (POSIX or OSS), so nodes that share a repository share registrations. Every change also updates `webhooks/generation`. Nodes check this marker before each event and reload when it changes, so a change made on any node applies to the next event on every node. 2. **Webhooks listen to sandbox lifecycle events.** They subscribe to the existing orchestrator lifecycle broadcast and support `created`, `killed`, `paused`, `resumed`, and `forked`. `forked` is an AgentENV extension and carries `source_sandbox_id`. Each node delivers only events for its own sandboxes. 3. **Delivery history is stored in node-local RocksDB.** Each attempt is written to `$AENV_HOME/webhooks/deliveries` and pruned hourly after 7 days. Through the gateway, `deliveries` and `stats` are sent to every node and the results are merged. If any node fails, the request returns `502`. ## Compatibility and operations - **Public API or generated protocol:** Additive. 7 endpoints under a new `webhooks` tag, with E2B schemas. `/stats` additionally returns `400` when `start >= end` or the range exceeds 31 days. The scheduler proto is unchanged: Update/Checkpoint events never existed in it, and webhook-only data is not reported. - **Configuration or defaults:** N/A - **Snapshot manifest, artifact layout, or storage format:** Repositories gain `webhooks/{id}.json` and `webhooks/generation` - **Upgrade and rollback:** N/A - **Host requirements, permissions, ports, or dependencies:**N/A ## Validation - [x] `make fmt` - [x] `make clippy` - [x] `make test-unit`: - [x] Relevant Rust integration tests - [x] `make -C services test`, plus `make -C services fmt-check vet` - [x] Generated clients/server regenerated with the documented `make` target (`make agentenv-server`) - [x] Documentation updated (`docs/src/concepts/sandboxes/webhooks.md`, `services/README.md`) - [ ] Benchmarks or performance comparison completed ## Risks and reviewer notes ## 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:42 +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#370
No description provided.