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
- Run Quickstart Probe #1 (1-Tool
MessagePortHandoff) to grantcatalog.search_books, transfer a scopedMessagePortinto the opaque<iframe sandbox="allow-scripts" src="/tool-provider.html">, invoke the granted tool, and verify that siblingcatalog.delete_inventorycalls fail with JSON-RPC-32602. - Run Quickstart Probe #2 (Hostile ACP Payload & SSE Resume) to send
cwd: "/etc"and hostilemcpServersinto/acp-worker.jsand SQLite, verify both fields are stripped, block a site permission-approval forgery (403), approve in the Hub Owner box, and drop/resume SSE viaLast-Event-IDwith zero gaps or duplicates. - Run Quickstart Probe #3 (
portwirevs.JSON.stringify) to send a 32 KiBUint8Array, a nestedMessagePort, and a 4-chunkReadableStreamacross a 15 KiB byte pipe and compare byte-identical framing against naive JSON corruption. - Test Storage Partitioning and Live-Tab SHA-256 Auth in Bench 4 by opening the top-level
/hub-popup.htmlpicker, registeringSHA-256(origin:secret)in SQLite, replaying a spoofed origin (401), and confirming URL-embedded secrets fail closed with400 URL_SECRET_FORBIDDEN.
Hypothesis
Pairing a top-level Hub picker with single-tool
MessagePorthandoffs, Hub-sanitized ACP permission gates (X-Hub-Owner-Proof), SQLite SSELast-Event-IDresume, and 15 KiB binaryportwireframing 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:
- Single-Tool
MessagePortIntent Picker — QueriesGET /api/hub/intents, records grants viaPOST /api/hub/handoff, opens/hub-popup.htmlas a top-level context to navigate storage partitioning, and transfers a narrowed 1-toolMessagePortinto an opaque<iframe sandbox="allow-scripts" src="/tool-provider.html">that allows only the granted tool and refuses sibling calls with-32602. - Hub-Mediated ACP Broker & SSE Resume — Runs
/acp-worker.jsbehindattachAcpHubBroker(), strips hostilecwdandmcpServersfields onPOST /api/acp/rpc, requiresX-Hub-Owner-ProofonPOST /api/acp/permission(blocking site forgery with403), and replays ordered SQLite frames overGET /api/acp/streamusing theLast-Event-IDheader. portwireBinary Framing vs.JSON.stringify— Compares a 15 KiB-capped loopback byte pipe (/lib/portwire.js) against naiveJSON.stringifyDataChannel serialization across a 32 KiBUint8Array, a transferred nestedMessagePort, and a 4-chunkReadableStreamwith pull back-pressure.- Origin-Bound Live-Tab Auth &
bridge.mjs— Stores onlySHA-256(origin:secret)digests in SQLite, verifiesAuthorization: Bearer+X-Target-Originin constant time, rejects?token=and/mcp/live/<channel>/<token>URL secrets with400 URL_SECRET_FORBIDDEN, and ships a copyable zero-dependency Node 22+bridge.mjssnippet 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_permissionpauses 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
MessagePortintent picker cover both human-clicked widgets and headless WebMCP tool dispatches? - What binary framing header minimizes overhead when tunneling
ReadableStreamchunks and transferredMessagePorthandles over WebRTC DataChannels?
Iteration log
- — Deployed Cloudflare Worker + SQLite Durable Object (
BridgeRegistry) and Browser Patch Bay featuring a 1-tool attenuatedMessagePortintent picker + top-level/hub-popup.html, permission-gated Dedicated Worker ACP broker (/acp-worker.js) with SSELast-Event-IDreplay,portwirebinary 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.