The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
webhooks
Client-side webhook tunnel routing for OpenHuman. The backend provisions and hosts the actual tunnels (ngrok / cloudflare / etc.) and forwards incoming HTTP requests to the app over Socket.IO; this module maps each backend tunnel UUID to its owning target (a skill, the built-in echo responder, or the agent triage pipeline), dispatches incoming requests, builds responses, captures debug logs, and exposes the local routing RPCs. The backend tunnel-management RPCs (webhooks.{list,create,get,update,delete}_tunnel, webhooks.get_bandwidth) share this namespace but live in crates/openhuman-tinyhumans/src/hosted/webhooks/ on the TinyHumans SDK; they are registered only when openhuman_tinyhumans::install runs.
webhooks is nested under skills/ for historical reasons but is not gated by the skills Cargo feature. It has always-compiled callers in crates/openhuman-core/src/core/ and stays outside the skills feature gate (see crates/openhuman-core/src/skills/mod.rs).
Responsibilities
- Maintain an in-memory, ownership-enforced map of
tunnel_uuid → TunnelRegistration(WebhookRouter), persisted to disk as JSON. - Enforce isolation: a skill can only register/unregister/list its own tunnels; cross-skill takeover and silent agent rebinds are rejected.
- Route incoming
WebhookIncomingRequestevents to the correct target bytarget_kind(echo,agent, orskill) and emit the response back over the socket (webhook:response). - Build echo responses; route
agenttunnels into the agent triage pipeline (spawned, non-blocking, returns202 Accepted). - Capture per-request debug logs (request + response + lifecycle stage) in a bounded ring buffer for developer tooling, and broadcast debug events.
- Expose local routing RPCs (registrations, logs, echo/agent registration, manual triage trigger).
Key files
| File | Role |
|---|---|
crates/openhuman-core/src/skills/webhooks/mod.rs |
Export-only: module docstring, pub mod decls, re-exports of WebhookRouter, types, and the all_webhooks_* controller pair. |
crates/openhuman-core/src/skills/webhooks/types.rs |
Serde domain types: WebhookRequest, WebhookResponseData, TunnelRegistration, WebhookActivityEntry, WebhookDebugLogEntry, debug result wrappers, WebhookDebugEvent. |
crates/openhuman-core/src/skills/webhooks/router.rs |
WebhookRouter: route map + ownership rules, disk persistence (generation-counter, spawn_blocking offload), bounded debug log ring (MAX_DEBUG_LOG_ENTRIES = 250), debug-event broadcast channel. |
crates/openhuman-core/src/skills/webhooks/ops.rs |
RPC handler logic returning RpcOutcome<T>: local routing ops (list_registrations, list_logs, clear_logs, register_echo, unregister_echo, register_agent, trigger_agent), and build_echo_response. |
crates/openhuman-core/src/skills/webhooks/schemas.rs |
Controller schemas + handle_* fns + all_controller_schemas / all_registered_controllers; deserializes params, delegates to ops.rs. |
crates/openhuman-core/src/skills/webhooks/bus.rs |
WebhookRequestSubscriber (EventHandler): the incoming-request routing flow; helpers decode_webhook_body, run_agent_trigger, build_agent_response. |
crates/openhuman-core/src/skills/webhooks/{webhooks_tests,bus_tests,ops_tests,router_tests,schemas_tests,types_tests}.rs |
Test suites, each pulled into its sibling source file via #[cfg(test)] #[path = "..."] mod tests; (no inline test modules). |
Public surface
Re-exported from mod.rs:
WebhookRouter(fromrouter).all_webhooks_controller_schemas,all_webhooks_registered_controllers(fromschemas).- Types:
TunnelRegistration,WebhookActivityEntry,WebhookDebugEvent,WebhookDebugLogEntry,WebhookDebugLogListResult,WebhookDebugLogsClearedResult,WebhookDebugRegistrationsResult,WebhookRequest,WebhookResponseData.
Key WebhookRouter methods: new(persist_path), register / register_echo / register_agent, unregister, unregister_skill, route, registration, list_all, record_request / record_parse_error / record_response, list_logs, clear_logs, subscribe_debug_events. ops::build_echo_response is also public for the bus.
RPC / controllers
Registered via all_webhooks_registered_controllers() (wired in crates/openhuman-core/src/core/all.rs). Methods (webhooks namespace):
| Method | Backing | Purpose |
|---|---|---|
webhooks.list_registrations |
local router | All in-app tunnel registrations. |
webhooks.list_logs |
local router | Captured request/response debug logs (limit). |
webhooks.clear_logs |
local router | Clear debug logs; returns count cleared. |
webhooks.register_echo |
local router | Register echo target for a tunnel_uuid. |
webhooks.unregister_echo |
local router | Remove echo target. |
webhooks.register_agent |
local router | Register an agent-backed tunnel (routes to triage). |
webhooks.trigger_agent |
triage | Fire triage/agent pipeline directly (source webhook/cron/external); 60s timeouts on triage + apply. |
list_registrations, list_logs and clear_logs return empty results when the router/socket manager isn't initialized; the register_*/unregister_* ops return an error in that case.
Agent tools
None. This domain owns no tools.rs agent tools.
Events
Subscriber (in bus.rs): WebhookRequestSubscriber, with name() = "webhook::request_handler" and domains() = ["webhook"]. Registered in register_domain_subscribers() (crates/openhuman-core/src/core/runtime/subscribers.rs, called from bootstrap_core_runtime()), gated on the Skills domain group being enabled (plan.skills) and installed at most once per process; channels/runtime/startup/start_channels.rs deliberately does not register it, to avoid double-registration when both startup paths run in the same process.
- Subscribes:
DomainEvent::WebhookIncomingRequest(published by the socket transport insocket/event_handlers.rs). - Publishes:
DomainEvent::WebhookRegistered/WebhookUnregistered(from the router on registration changes;WebhookUnregistered, theregistration_changeddebug event and the route re-persist all fire only when a registration was actually removed. Unregistering an absent tunnel is a silent no-op that returnsOk(false), see #6091),DomainEvent::WebhookReceived(when routed to a target),DomainEvent::WebhookProcessed(always, with status/elapsed/error).
Routing outcomes by target_kind: echo → build_echo_response (200); agent → decode body, spawn triage, return 202 Accepted (spawned task emits the real response later, with 60s timeout → 504); skill / unknown → 501 (direct skill dispatch not available); no registration → 404. Responses are emitted over the socket as webhook:response.
The router also runs a separate tokio::sync::broadcast channel of WebhookDebugEvent (registration_changed, log_updated, logs_cleared) consumed via subscribe_debug_events() for frontend/dev tooling.
Persistence
WebhookRouter serializes its registrations to a JSON file (PersistedRoutes) at the optional persist_path passed to new(), and reloads them from that file when constructed. Writes are best-effort and fire-and-forget: offloaded to spawn_blocking inside a tokio runtime (inline otherwise), guarded by a monotonic generation counter so stale writes under rapid churn are dropped. Debug logs are not persisted. They live only in an in-memory VecDeque capped at 250 entries.
Note that nothing in the production startup path currently constructs a WebhookRouter or calls SocketManager::set_webhook_router; it has no caller outside tests. Until a router is attached, the local RPCs return empty results (see above) and the subscriber answers every incoming request with 404.
Dependencies
crate::core::bus::BUSandcrate::core::events::DomainEvent: publishing and subscribing; theEventHandlertrait comes fromtinybus.crate::core::all:ControllerFuture,RegisteredControllerfor controller registration.crate::core::{ControllerSchema, FieldSchema, TypeSchema}: RPC schema types.crate::core::observability::report_error: error reporting for body-decode / agent-trigger failures.crate::platform::socket::global_socket_manager: obtain theWebhookRouter(stored on the socket manager) andemitresponses over the socket.crate::triage:TriggerEnvelope,run_triage,apply_decision,TriageOutcomefor agent-tunnel routing andtrigger_agent.crate::config::{Config, rpc::load_config_with_timeout}: config for local webhook routing operations.crate::rpc::RpcOutcome: handler return contract.
Used by
crates/openhuman-core/src/core/all.rs: registers the controllers/schemas into the RPC registry.crates/openhuman-core/src/platform/socket/manager.rs: stores theWebhookRouter(set_webhook_router/webhook_router) on the socket manager; ops/bus retrieve it from there.crates/openhuman-core/src/platform/socket/event_handlers.rs: publishesWebhookIncomingRequestfrom the socket and reads the shared router slot.crates/openhuman-core/src/core/runtime/subscribers.rs: registersWebhookRequestSubscriber.crates/openhuman-core/src/core/events.rs: defines theWebhook*DomainEventvariants this module uses.
Notes / gotchas
- Direct skill dispatch is not implemented: a
skill-kind tunnel returns501. Real handling exists only forechoandagentkinds (the QuickJS skill runtime was removed; seedocs/gitbooks/en/developing/architecture.md). route()deliberately resolves onlytarget_kind == "skill"registrations; echo/agent registrations are matched viaregistration()in the bus, notroute().- Agent tunnels respond
202immediately and complete asynchronously: the spawned task emits the finalwebhook:responseitself to avoid blocking the broadcast dispatch task during LLM calls. register_agentstoresagent_idfor observability and rebind validation only; per the docstring the triage evaluator selects the target agent dynamically regardless of the pinned value.- Persistence is fire-and-forget and may not flush before process exit; a lost write only replays the most recent registration change on next startup.
decode_webhook_bodyreturns{}for empty bodies and wraps non-JSON-but-valid-UTF-8 bodies under a"raw"key; invalid base64 is a hard error (→ 400).- All request/response bodies are base64-encoded over the wire (
WebhookRequest.body/WebhookResponseData.body).