feat(agent-relay): arelay.to/agent-relay chat-with-our-agent front door

Merged
KH
16d ago
+746-1

Change

arelay.to/agent-relay is the single front door for "have your agent chat with ours". A visitor copies one snippet into the Claude Code or Codex chat they already have open. No install, account, restart or MCP.

AddressServed by
arelay.to/agent-relaySite page. The server mints a private 128-bit conversation id per request (force-dynamic), so an agent that fetches the page gets a complete snippet too.
arelay.to/agent-relay/bridge.shFile-bridge fallback (POSIX sh + curl, nothing installed).
arelay.to/agent-relay/<32 hex id>Router → cloud /cloud/api/v1/agent-chat/agent-relay/<id>.
arelay.to/, arelay.to/cloud/*, www.arelay.to/*302 to agentrelay.com (www → arelay.to).
  • Snippet: every message uses the same curl -sS --data-binary @- https://arelay.to/agent-relay/<id> <<'ARELAY_END_<id prefix>' prefix (a per-conversation here-doc marker, so a message line can't end it early), so one "don't ask again" approval covers the conversation. The reply is the command's output (request–reply, long-poll). A connect failure is explained as the sandbox, so the agent asks to escalate instead of reporting "server down".
  • Bridge fallback for sandboxes that cannot escalate (Codex approval_policy = never): the human runs curl -fsSL https://arelay.to/agent-relay/bridge.sh | sh -s -- <conversation-url>. The agent writes /tmp/agent-relay/<id>/out/*.txt and reads in/. The bridge keeps a wait open, so replies sent while the agent is idle still land.
  • Router: arelay.to and www.arelay.to are added as custom_domain routes. A redirect rule can't carry the snippet's POST (curl doesn't follow without -L, and 301/302 turns POST into GET). Agent chat is an allowlist (agent-relay) with a lowercase 32-hex id, so the page and bridge.sh are never claimed.
  • docs/arelay-to-cloudflare.md: human runbook.

Validation

  • Router: 81/81 tests (4 new: mapping on both hosts, non-claims, POST body forwarded to the cloud worker, short-host redirects). tsc clean.
  • Web: agent-chat-snippet 7/7 (snippet, default arelay.to URL, bridge argument checks). tsc clean apart from the existing unrelated prerender-cache-key.test.ts error.
  • Local: two requests to /agent-relay returned different conversation ids, and the HTML <pre> carries the full snippet. Request–reply verified from Claude Code against a local stand-in server. The hosted bridge was verified via curl … | sh -s -- (message out, reply in, idle reply delivered).

Release gate (keep draft)

  • Cloud endpoint: AgentWorkforce/cloud#4240 adds /cloud/api/v1/agent-chat/[agent]/[conversationId] with a stub agent. Deploy it before or with this PR.
  • DNS: before the router deploy, a human deletes existing arelay.to/www DNS records (custom domains refuse to attach over them). See the runbook. The zone is active on Cloudflare NS as of 2026-10-07.
  • Caching: check on a preview that /agent-relay is not cached by the CDN (dev shows no-cache, must-revalidate).
  • Approvals: prompt counts across ~5 messages in stock Claude Code and Codex are not yet measured.

🤖 Generated with Claude Code


[!NOTE]
Medium Risk
Introduces new edge routing and a public agent-chat ingress path that must stay aligned with the cloud /cloud/api/v1/agent-chat API and correct DNS/custom-domain setup.

Overview
Adds arelay.to as a short public front door for “paste a snippet and have your coding agent chat with ours,” with agentrelay-router claiming arelay.to / www.arelay.to and routing agent chat without breaking POSTs.

Router: New allowlisted mapping forwards POST /<agent>/<32-hex-id> (today agent-relay) on arelay.to, www.arelay.to, or agentrelay.com to /cloud/api/v1/agent-chat/... instead of using redirects (so curl/agents don’t turn POST into GET). getShortHostRedirect sends arelay.to/ and /cloud/* to agentrelay.com and www → apex, but chat POSTs on www are served, not redirected. wrangler.jsonc adds the two custom domains; docs/arelay-to-cloudflare.md documents DNS/deploy/verify/rollback.

Web: New /agent-relay page (force-dynamic) mints a per-request conversation id and renders AgentChatSnippet (copy / new conversation). agent-chat-snippet builds the curl here-doc instructions (fixed command prefix, per-id end marker) and optional file-bridge path. public/agent-relay/bridge.sh is the POSIX file bridge for sandboxed agents, with tests for snippet shape and script safety.

Reviewed by Cursor Bugbot for commit d1d66bdb0889b44f62d238849ae4486349d935bf. Bugbot is set up for automated code reviews on this repo. Configure here.


Agent Relay sessions

  • claude session 1e2adfbe · opened via gh pr create · last active 2026-10-07