AI Focus

messageport intent & acp bridge

Why this matters

Web Intents stalled because cross-site handoffs lacked fine-grained capability scoping, and many browser-to-agent bridges today either pass raw bearer tokens in URLs or expose an entire host tool catalog to every page. Combining standard MessagePort transfers, a top-level Hub popup to navigate Storage Partitioning, Agent Client Protocol (ACP) sanitization, binary framing, and origin-bound header auth tests how far built-in browser primitives carry cross-origin agent bridges.

What this opens up

Replacing bespoke N×M website-to-agent integrations with browser-native MessagePort handoffs—letting a user-controlled Hub wire one exact tool to a page, gate local ACP permissions in one place, stream binary data cleanly over 15 KiB pipes, and connect live tabs with zero URL secrets.

How the tests work

  1. Run Quickstart Probe #1 (1-Tool MessagePort Handoff) to grant catalog.search_books, transfer a scoped MessagePort into the opaque <iframe sandbox="allow-scripts" src="/tool-provider.html">, invoke the granted tool, and verify that sibling catalog.delete_inventory calls fail with JSON-RPC -32602.
  2. Run Quickstart Probe #2 (Hostile ACP Payload & SSE Resume) to send cwd: "/etc" and hostile mcpServers into /acp-worker.js and SQLite, verify both fields are stripped, block a site permission-approval forgery (403), approve in the Hub Owner box, and drop/resume SSE via Last-Event-ID with zero gaps or duplicates.
  3. Run Quickstart Probe #3 (portwire vs. JSON.stringify) to send a 32 KiB Uint8Array, a nested MessagePort, and a 4-chunk ReadableStream across a 15 KiB byte pipe and compare byte-identical framing against naive JSON corruption.
  4. Test Storage Partitioning and Live-Tab SHA-256 Auth in Bench 4 by opening the top-level /hub-popup.html picker, registering SHA-256(origin:secret) in SQLite, replaying a spoofed origin (401), and confirming URL-embedded secrets fail closed with 400 URL_SECRET_FORBIDDEN.
Browser patch bay testing single-tool MessagePort handoffs, top-level popup storage partitioning, Hub-mediated ACP permission gating with SSE Last-Event-ID replay, 15 KiB portwire binary framing, and SHA-256 origin-bound live-tab auth. Open messageport intent & acp bridge full screen ↗

Hypothesis

Pairing a top-level Hub picker with single-tool MessagePort handoffs, Hub-sanitized ACP permission gates (X-Hub-Owner-Proof), SQLite SSE Last-Event-ID resume, and 15 KiB binary portwire framing enables safe cross-origin tool and agent bridging without URL secrets or binary JSON bloat.

What confirms it: An opaque <iframe sandbox="allow-scripts"> runs only its single granted tool over the transferred MessagePort; the ACP broker strips hostile cwd/mcpServers fields and replays dropped SSE streams via Last-Event-ID without drops or duplicates; portwire round-trips 32 KiB buffers, nested ports, and streams byte-identically; and URL-embedded secrets reject with 400 URL_SECRET_FORBIDDEN.

What bounds or disproves it: Browser storage partitioning isolates embedded Hub iframes from top-level tool registrations unless a top-level popup (/hub-popup.html) mediates access, and tunneling binary data or streams across WebRTC-compatible byte pipes requires explicit <=16 KiB framing.

Under the hood

MessagePort Intent & ACP Bridge (GitHub) pairs a Cloudflare Worker and SQLite Durable Object (BridgeRegistry) with four browser test benches:

  1. Single-Tool MessagePort Intent Picker — Queries GET /api/hub/intents, records grants via POST /api/hub/handoff, opens /hub-popup.html as a top-level context to navigate storage partitioning, and transfers a narrowed 1-tool MessagePort into an opaque <iframe sandbox="allow-scripts" src="/tool-provider.html"> that allows only the granted tool and refuses sibling calls with -32602.
  2. Hub-Mediated ACP Broker & SSE Resume — Runs /acp-worker.js behind attachAcpHubBroker(), strips hostile cwd and mcpServers fields on POST /api/acp/rpc, requires X-Hub-Owner-Proof on POST /api/acp/permission (blocking site forgery with 403), and replays ordered SQLite frames over GET /api/acp/stream using the Last-Event-ID header.
  3. portwire Binary Framing vs. JSON.stringify — Compares a 15 KiB-capped loopback byte pipe (/lib/portwire.js) against naive JSON.stringify DataChannel serialization across a 32 KiB Uint8Array, a transferred nested MessagePort, and a 4-chunk ReadableStream with pull back-pressure.
  4. Origin-Bound Live-Tab Auth & bridge.mjs — Stores only SHA-256(origin:secret) digests in SQLite, verifies Authorization: Bearer + X-Target-Origin in constant time, rejects ?token= and /mcp/live/<channel>/<token> URL secrets with 400 URL_SECRET_FORBIDDEN, and ships a copyable zero-dependency Node 22+ bridge.mjs snippet using header/first-message auth.

Key terms & further reading

MessageChannel & MessagePort ↗
Browser messaging API creating a transferable two-ended pipe whose ports can be scoped to a single tool and handed across origins.
Agent Client Protocol (ACP) ↗
JSON-RPC 2.0 protocol for driving local or remote AI agents with explicit session/request_permission pauses and streamed updates.
Storage Partitioning ↗
Browser isolation model separating cross-site iframe storage from top-level origins, making a top-level Hub popup necessary to read shared registrations.
Server-Sent Events & Last-Event-ID ↗
HTTP streaming standard where reconnecting clients send their last sequence ID so the Durable Object replays only missed frames.
RTCDataChannel Binary Limits ↗
Peer-to-peer byte transport whose ~16 KiB message cap requires chunked framing (like portwire) to carry binary arrays, nested ports, and streams.
JSON-RPC 2.0 ↗
Stateless request/response format used here for single-tool port calls and Hub-mediated ACP messages.

Open questions

  • How cleanly can a single MessagePort intent picker cover both human-clicked widgets and headless WebMCP tool dispatches?
  • What binary framing header minimizes overhead when tunneling ReadableStream chunks and transferred MessagePort handles over WebRTC DataChannels?

Iteration log

  • — Deployed Cloudflare Worker + SQLite Durable Object (BridgeRegistry) and Browser Patch Bay featuring a 1-tool attenuated MessagePort intent picker + top-level /hub-popup.html, permission-gated Dedicated Worker ACP broker (/acp-worker.js) with SSE Last-Event-ID replay, portwire binary framing benchmark vs. JSON.stringify, and SHA-256 origin-bound live-tab auth rejecting URL secrets (400 URL_SECRET_FORBIDDEN).

Primitives tested: MessagePort & MessageChannel, Agent Client Protocol (ACP), portwire Binary Framing, SSE Last-Event-ID Cursor Resume, Top-Level Popup Storage Partitioning, Durable Object SQLite (BridgeRegistry).

This is an active lab under /labs/ and stays off the main RSS feed until graduated into a full essay.

More in agent discovery, auth & protocol bridges

Connected labs

← agent discovery, auth & protocol bridges · All labs