1. Grant One Tool Over a MessagePort
Grants catalog.search_books, hands a narrowed MessagePort to the sandboxed provider iframe, calls the allowed tool, and verifies that calling catalog.delete_inventory is blocked with -32602.
Track 9 · Agent Bridges & Discovery · MessagePort + ACP + Binary Framing
Connecting web apps and external AI agents today usually means wiring custom OAuth apps, copying raw API keys into URLs, or handing one page access to every tool you own. This browser patch bay tests a cleaner pattern built on standard MessageChannel / MessagePort pipes, the Agent Client Protocol (ACP) over JSON-RPC 2.0, binary framing, and Server-Sent Events (SSE) cursor resume.
Early cross-site tool ideas like Web Intents stalled on scoped permissions, and modern browser-to-agent bridges often leak bearer tokens in query strings or let untrusted sites set working directories (cwd) and auto-approve actions. Browser Storage Partitioning also isolates embedded iframes from a user's top-level tool registry.
Replacing bespoke N×M agent integrations with browser-native MessagePort handoffs: a single user-controlled Hub grants a website access to one exact tool (such as a WebMCP catalog search), gates local ACP agent permissions in one place, streams binary files cleanly over 15 KiB pipes, and authenticates live tabs via origin-bound SHA-256 headers.
Run the 3 Quickstart Probes below to execute four live benches backed by a Dedicated Worker (/acp-worker.js), an opaque sandboxed iframe (/tool-provider.html), and a Cloudflare SQLite Durable Object (BridgeRegistry).
pick(intent) / acp.prompt()
MessagePort scoped to 1 tool onlycwd or approve its own permissionstop-level popup · window.top === window
event.origin & event.source before wiring portscwd & mcpServers fields from ACP callssession/request_permission only to Hub Owner controlsportwire chunkssandbox="allow-scripts" · origin="null"
Runs only the granted tool; rejects sibling tools with -32602.
cwd="/sandbox/hub-workspace"
Pauses execution until the Hub Owner clicks Approve or Deny.
MessagePort handoffs for site tools, Hub-sanitized ACP sessions for agents, 15 KiB binary frames for byte pipes, and SHA-256 header authentication for live tabs.
Grants catalog.search_books, hands a narrowed MessagePort to the sandboxed provider iframe, calls the allowed tool, and verifies that calling catalog.delete_inventory is blocked with -32602.
Sends malicious cwd: "/etc" and mcpServers into /acp-worker.js and SQLite, confirms both are stripped, blocks a site forgery attempt, and pauses the agent for Hub Owner approval.
Sends a 32 KiB Uint8Array, a nested MessagePort, and a 4-chunk ReadableStream through a 15 KiB byte pipe vs. JSON.stringify to compare lossless framing against silent data loss.
Searches registered providers, records a 1-tool grant in SQLite, and hands a direct MessagePort to a sandboxed iframe with event.origin checks.
| Tool | Provider Origin | Score | Handoff |
|---|
Click "Grant 1-Tool Port" on any row above or run Quickstart Probe #1.
sandbox="allow-scripts")
Zero cookies, zero localStorage, zero parent DOM access. Enforces single-tool attenuation directly on the transferred MessagePort.
No handoff recorded yet.
Last-Event-ID Resume
Runs real ACP JSON-RPC over /acp-worker.js + Cloudflare DO SQLite (/api/acp/rpc, /api/acp/permission, /api/acp/stream). Strips hostile cwd/mcpServers and gates session/request_permission exclusively in the Hub Owner panel.
Run step 1 to observe hostile cwd/mcpServers stripping in both /acp-worker.js and DO SQLite.
Last-Event-ID Drop/Resume Test
Connects via fetch("/api/acp/stream") with Acp-Connection-Id header (never query strings), simulates a mid-stream drop after 2 frames (maxEvents=2), then reconnects with Last-Event-ID: 2 to verify zero duplicates and zero dropped frames.
Initialize an ACP session and send a prompt, then click "Run Drop-at-Frame-2 & Last-Event-ID Resume".
portwire Binary Framing vs. Naive JSON.stringify DataChannel Check
Executes real payloads across a 15 KiB-framed loopback byte pipe (/lib/portwire.js) side-by-side with naive JSON.stringify/JSON.parse DataChannel transport.
| Payload Type | portwire Binary Frames (<= 15 KiB) | Naive JSON.stringify DataChannel | Verdict |
|---|
Run any framing check above to inspect SHA-256 digests, wire frame counts, and naive JSON corruption output.
bridge.mjs Quickstart
Compares embedded/opaque iframe storage isolation against a top-level Hub popup, verifies SHA-256(origin:secret) Live-Tab registration with zero URL secrets, and provides a copyable header-authenticated bridge.mjs snippet.
Browser generates a 256-bit local secret, hashes SHA-256(origin + ":" + secret) locally, and registers only the digest in DO SQLite.
Click "1. Register Origin-Bound Hash" to test SHA-256 origin-bound header auth vs. forbidden URL token paths.
Click "Run Storage Partitioning Snapshot" to compare top-level vs. opaque embedded contexts.
bridge.mjs Quickstart (Header / First-Message Auth)Node 22+ zero-dependency bridge for piping a local stdio ACP agent to a remote Hub without putting bearer secrets in WebSocket or HTTP URLs.
portwire) for binary arrays and streams.