feat(events-shim): one MCP URL that wakes an idle agent on each webhook post

Merged
KH
3h ago
+3102-1

Summary

Adds @agent-relay/events-shim: one MCP URL that turns webhook posts into Agent Relay messages that wake an idle agent session (like a hosted webhook inbox, but delivered by injection instead of polling).

  • A person adds one MCP server (claude mcp add --transport http webhooks <mcp url>) and points any sender at the paired webhook URL.
  • Under Agent Relay the agent runs agent-relay-probe webhook --socket <socket> (new; POST /webhooks on the session socket, which already existed) and calls link_relay_wake. Every later post is forwarded to that session webhook; relay-node injects it, waking the session when idle.
  • Without Agent Relay: wait_for_webhook (blocks up to 50s) or get_webhook_events.
  • Webhook URLs: open, GitHub, Stripe, Linear and bearer (signature/bearer checked). Once-per-Idempotency-Key (or provider delivery id). 60/h, 500/day, 64 KB bodies, 50-post feed, 7-day idle expiry.
  • Nudges: a text/plain post to an authenticated URL is delivered verbatim, so an MCP vendor can wake agents with a pointer to its own data. Open posts are always wrapped as untrusted data.
  • Wake links only to allowed Relaycast origins (default https://cast.agentrelay.com), checked with a link-check post before storing — prevents SSRF via the MCP URL.
  • Hosts supply an EventsShimStore and mount one Web Request → Response handler (handleEventsShimRequest). Cloud and relay-control PRs consume it.
  • agent-relay-probe webhook is deliberately not in Codex's auto-allow list: its secret lets the holder inject into the session, so a relayed message must not be able to mint one unattended.
  • Package added to the publish matrix, build:core, vitest workspace aliases; CHANGELOG [Unreleased - Minor].

Test Plan

  • vitest packages/events-shim/src — 13/13 (real MCP SDK client over the HTTP handler: queueing, wake forwarding, broken links, SSRF refusal, wait_for_webhook, idempotency, GitHub/Stripe/Linear/bearer verification, limits, rotate/expiry, verbatim nudges, no double hand-over)
  • tsc --noEmit for the package
  • cargo test --lib -- session_cli relay_commands sandbox_rule — 12/12
  • Real end-to-end (2026-11-11): package handler → real cast.agentrelay.com session webhook → Agent Relay Desktop. The link check arrived in a live Claude Code session as from webhook; then, with that session idle, a bearer text/plain post (202, wake: forwarded) woke the session with the exact nudge text; feed recorded woken. Test webhook revoked afterwards.

Follow-ups: AgentWorkforce/cloud and AgentWorkforce/relay-control PRs pin @agent-relay/events-shim@18.2.0 and need this released first.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.