Repository navigation
feat(pair-page): per-daemon pair page on agentproto.cloud (Cloudflare Worker) - #1457
Conversation
… Worker) A private package with the phone pair page as one static bundle, served identically on every <daemon-fingerprint>.agentproto.cloud by a Cloudflare Worker (AIP-59 §5.8). Isolation comes from the browser origin; there is no per-daemon server logic. - /pair pairs from the offer in the fragment with @agentproto/pair-client, refuses an offer whose fingerprint isn't the origin's first label before any network I/O (the offer stays unspent), and asks to confirm the daemon. - /d/<fp> is the status page (connecting, offline, revoked, outdated, not paired, wrong address). The service worker (dist/pair-sw.js) proxies /d/<fp>/ to the daemon over one tunnel client, so the Control Center loads from the daemon. - The IndexedDB store, in the page and the worker, holds only the origin's daemon. - Plain DOM, bundled with esbuild into dist/: no framework, no inline script or style, no third-party code. The build checks index.html for that. - src/worker.ts (logic in src/edge.ts): 404 for the apex and any host whose first label isn't a fingerprint, extra hosts only via PREVIEW_HOSTS (a labelled preview mode), a strict CSP and security headers on every response, no-cache for the worker script and immutable hashed assets. wrangler.toml: workers_dev, [assets] with run_worker_first, no routes. - scripts/preview.mjs serves dist/ through the same edge handler locally. Ported from agentproto/cli-site#15.
`pair offer --qr` now links to https://{fp}.agentproto.cloud/pair by
default (DEFAULT_PAIR_PAGE = PAIR_WEB_URL_TEMPLATE_CLOUD), the page from
packages/pair-page. It stays configurable with pairing.pairPage and
--pair-page, as AIP-59 requires. encodeOfferWebUrl and the pairing.pairPage
config default follow. PAIR_WEB_URL (https://cli.agentproto.sh/pair) stays
exported as the explicit shared-origin option.
identityFingerprint is now the first 32 lowercase hex chars (128 bits) of
sha256(x25519 pub), was 16 (64 bits). The fingerprint names the daemon's
browser origin (<fingerprint>.agentproto.cloud, AIP-59 §5.8): at 64 bits a
well-resourced attacker could grind a daemon key whose fingerprint collides
with a victim's and get their daemon's UI onto the victim's origin. 32 hex is
still one DNS label.
One fingerprint concept: the handshake's peerFingerprint (the daemon's key
seen by the client, the client's key seen by the daemon, the pairing handle)
uses the same function and widens with it.
- The offer codec requires `id` to be exactly 32 lowercase hex.
- The pair page and its Worker match ^[0-9a-f]{32}$.
- sealKeyId keeps 16 hex (it is persisted in keyring files); it is the
fingerprint's prefix.
- Golden vectors: the fingerprint fields and the v2 offer URL id are
re-derived; a KAT checks that the captured 64-bit values are their 16-char
prefix, so only the length changed. The captured v1 offer keeps its id.
- pair ls widens its column; docs, examples and READMEs use 32-hex values.
BREAKING CHANGE: fingerprints, offer URLs and stored pairings from before this
change don't validate. pair/v2 is unreleased, so there is no migration.
32 hex chars don't fit one line on a phone; groups of 4 wrap between groups and are easier to compare with the terminal. The gaps are CSS margins, so a copy still yields the raw hex. Screenshots re-taken with 32-hex fingerprints.
Deployed after the workers.dev preview was verified; the zone carries the proxied wildcard record (AAAA 100::) the route needs.
There was a problem hiding this comment.
Summary
Ports a per-daemon "phone pair page" (@agentproto/pair-page, private, Cloudflare Worker) that gives every daemon its own browser origin (<fingerprint>.agentproto.cloud), widens the daemon identity fingerprint from 64 to 128 bits to make that origin collision-resistant, and switches the default pairing.pairPage (CLI/runtime/pair-client) to the new per-daemon template.
Changeset
| package | bump | reason |
|---|---|---|
@agentproto/secrets |
major | identityFingerprint() now returns 32 hex (128 bits) instead of 16 (64 bits) — same exported signature, breaking change in output value/length; offer URL id param now requires 32 hex (old-format v2 offers are rejected as malformed_offer, not the friendlier pairing_protocol_outdated). New export IDENTITY_FINGERPRINT_HEX_LENGTH, DEFAULT_PAIR_PAGE. |
@agentproto/pair-client |
minor | New export DEFAULT_PAIR_PAGE; default pairing origin behavior changes (see secrets). |
@agentproto/runtime |
minor | pairing.pairPage's default changes from the shared cli.agentproto.sh URL to the per-daemon {fp}.agentproto.cloud template; new config default plumbed through config-schema.ts. |
@agentproto/cli |
minor | pair offer --qr / pair ls default + display width follow the new fingerprint format and default page. |
@agentproto/pair-page |
none | private: true, not published. |
Findings
Correctness
- The 64→128-bit widening is done carefully:
sealKeyId(independent, still 16-hex) is untouched, and a test pins that the new fingerprint's 16-hex prefix equals the old captured 64-bit value and equalssealKeyId— a strong invariant check. - Golden-vector tests (
golden.test.ts,golden-vectors.ts) replay pre-refactor captures and pin the new 32-hex outputs against the historical 16-hex ones, so the widening's blast radius is well fenced. - Every length-dependent regex/format I could find was updated consistently:
parseOfferUrl(^[0-9a-f]{32}$),pair-page/src/edge.tshost regex,pair-clientservice-worker path regex, CLI'spair lscolumn padding, andresolvePairPageUrl's DNS-label sample fingerprint ("0".repeat(32)). No stray{16}/{18}leftovers found via grep. OFFER_VERSIONstays at2even though theidparam's required length changed. A daemon/client pair that straddles this change (old CLI's v2 offer parsed by a new CLI, or vice versa) now fails withmalformed_offerrather than the actionablepairing_protocol_outdatedmessage the v1→v2 transition got. Given this is a coordinated workspace release (not an independently-versioned wire protocol), this is likely acceptable, but it's worth confirming this was a deliberate call rather than an oversight, since the failure mode is a less friendly error for anyone mixing daemon/CLI versions across the upgrade.- Reassuringly, existing pairings are unaffected:
openPairChannelreconnects using the pinneddaemonX25519Pub/daemonEd25519Pub, never re-comparing against the stored (possibly stale 16-hex)ClientPairing.fingerprint, so this is a purely additive/cosmetic mismatch for already-paired daemons, not a functional break.
AIP alignment
- Matches AIP-59 §5.8 (per-daemon browser origin for pairing isolation); the widened fingerprint is specifically justified against a second-preimage grind on that origin, which is the right threat model for a DNS-label-based isolation boundary.
Tests
- Strong coverage across the boundary:
edge.test.ts/host.test.ts(pair-page),offer-url.test.ts,handshake.test.ts,identity.test.ts,pair-page.test.ts/tunnel-client.test.ts(pair-client),pair-offer-qr.test.ts(cli),config-schema.test.ts(runtime) all updated in lockstep with the format change.
Nits
IDENTITY_FINGERPRINT_HEX_LENGTHis exported fromidentity/core.tsbut doesn't appear to be re-exported from the Node (identity/index.ts) or browser entry points — fine if intentionally internal, otherwise minor inconsistency with the rest ofcore.ts's public surface.
Simplify
Nothing over-engineered here — the fingerprint widening touches exactly the places it needs to, and the per-daemon default is a straightforward constant swap. No cuts to suggest.
Verdict
LGTM ✅ — a well-tested, deliberately-scoped breaking change (correctly marked ! in the secrets commit) with consistent propagation across all consumers; only a documentation/confirmation nit around the unbumped OFFER_VERSION friendliness during a mixed-version rollout.
🤖 @agentproto-bot — review · legacy fallback (api-key) · run 36276702986 · sha 96592cf19f3a43f94615f7721326cf96d55daed7
…ed rdv) Captured on 2026-09-26 against the deployed Worker (cae88bea) and wss://rdv.agentproto.sh/v1 with two scratch daemons: confirm and session list on daemon A's origin, B's offer refused on A's origin, B paired on its own origin, A's paired list, A revoked, B unaffected.
…state The status page redrew its whole view on every worker reply (every 2.5 s), replacing its buttons each time, so a tap could land on a node that was just swapped out (the production proof's Forget click failed that way). Draw only when the shown state, error, name or fingerprint changes.
There was a problem hiding this comment.
Summary
Three related changes shipped together: (1) a new private @agentproto/pair-page package — a static bundle + Cloudflare Worker serving the AIP-59 §5.8 phone pair page on <fingerprint>.agentproto.cloud, one origin per daemon; (2) pair offer --qr (and encodeOfferWebUrl / pairing.pairPage) now default to that per-daemon template instead of the old shared cli.agentproto.sh page, while the plain-URL/shared-origin path stays available; (3) identityFingerprint widens from 64 to 128 bits (16→32 hex) to resist an origin-grinding attack against the new per-daemon-origin scheme.
Changeset
| package | bump | reason |
|---|---|---|
| @agentproto/secrets | major | identityFingerprint output length changes (16→32 hex) — breaking for anything depending on the old width; sealKeyId correctly untouched (stays 16 hex, still used in persisted keyring files) |
| @agentproto/cli | minor | pair offer --qr default page changes, pair ls column width, new DEFAULT_PAIR_PAGE import |
| @agentproto/pair-client | minor | DEFAULT_PAIR_PAGE export, SW route regex widened to 32-hex, README updated |
| @agentproto/runtime | minor | pairing.pairPage config schema default now DEFAULT_PAIR_PAGE |
@agentproto/pair-page is "private": true (confirmed in package.json) and correctly excluded from list_changed_packages/the changeset.
Findings
Correctness
identityFingerprint/sealKeyIdsplit is handled carefully: the seal key id intentionally stays at 16 hex (persisted format, unrelated concern) while the identity fingerprint widens; a test assertsfp.slice(0, 16) === sealKeyId(...), guarding against the two accidentally re-coupling.- Golden-vector KAT (
golden-vectors.ts/golden.test.ts) re-derives the 128-bit values and separately asserts the captured 64-bit values are exact 16-char prefixes of the new ones — good proof that only the length changed, not the derivation. resolvePairPageUrl/expectedPairHostcorrectly restrict{fp}substitution to the hostname only, validate the DNS-label shape, and reject fragments — all exercised by tests (including the CLI-side probe using"0".repeat(32)post-widening).pair-page/src/edge.tsclassifyHostcorrectly 404s the apex, non-fingerprint labels, and deeper names, and gatesws://loopback CSP additions to preview/loopback hosts only — matches the design note about not leaking a loopback allowance into production daemon origins.- Offer codec's
idregex is now strictly^[0-9a-f]{32}$; parse-time re-derivation offingerprint(pk)still guards against tampering.
Tests
- CLI, pair-client, and secrets test fixtures are all updated consistently to 32-hex fingerprints; the "defaults to per-daemon page, plain URL still selects shared page" test explicitly covers both the new default and the escape hatch.
- No gaps found in the areas reviewed (offer codec, pair-page host classification, CLI default resolution).
AIP alignment
- Behavior and docs (verbs/pair.md-style comments, pair-client README, CLI usage banner) are updated together and consistently reference AIP-59 §5.8;
PAIR_WEB_URL(shared origin) stays exported and documented as an explicit opt-in, not removed.
Nits
- None worth blocking on — the PR body's own gate/e2e log plus the golden-vector cross-check gives good confidence this was validated beyond unit tests.
Simplify (ponytail pass)
Nothing found to cut — the pair-page package explicitly avoids a framework and inline scripts, resolvePairPageUrl reuses URL/URLSearchParams rather than hand-rolling parsing, and the fingerprint-prefix relationship (sealKeyId vs identityFingerprint) is kept as two distinct concepts rather than a shared abstraction with a single caller. No speculative flexibility spotted in the diff reviewed.
net: -0 lines possible.
Verdict
LGTM ✅ — correct, well-tested (including a KAT proving the fingerprint widening didn't change the derivation), properly labeled as a breaking change on @agentproto/secrets, and changeset-accurate once the private pair-page package is excluded.
🤖 @agentproto-bot — review · legacy fallback (api-key) · run 36276937695 · sha f7eefe2c87fa159664ec0999da4dca9cf507e14a
There was a problem hiding this comment.
Summary
Incremental re-review of PR #1457 since commit 96592cf. The new commits add production proof screenshots (docs, private pair-page package) and a small render-dedup guard on the daemon status page so identical poll responses don't re-build the DOM and swap buttons out from under a tap. Everything else is unchanged from the previously approved state.
Changeset
| package | bump | reason |
|---|---|---|
@agentproto/secrets |
major | (prior commits) 128-bit identity fingerprint, IDENTITY_FINGERPRINT_HEX_LENGTH, DEFAULT_PAIR_PAGE — changeset added in 2d8e28eb. |
@agentproto/pair-client |
minor | (prior commits) DEFAULT_PAIR_PAGE export, new default pairing origin. |
@agentproto/runtime |
minor | (prior commits) new pairing.pairPage default plumbed through config schema. |
@agentproto/cli |
minor | (prior commits) fingerprint display/QR follows new format. |
@agentproto/pair-page |
none | private: true, not published — screenshots and status-page fix need no bump. |
Findings
Correctness
- The new dedup guard (
packages/pair-page/src/pages/status.ts:63-67) keys on[state, error.message, name, fp], which is exactly the set of inputs the rendered view depends on.name/fpare assigned before the worker responses redraw (status.ts:194-195), so late-arriving identity correctly invalidates the key and forces a redraw. No stale-view risk found. - The transition to
openstill bypasses dedup only in effect by being a distinct state key; the subsequentwindow.location.replace(next)is unaffected. Fine.
Tests
- No tests added for the dedup guard; acceptable given it's a pure idempotence optimization in a private package with visible-manual impact only, but worth a follow-up if the status page gains more dynamic views.
Changeset
- No changeset existed for this PR despite published packages (
secretsmajor,pair-client/runtime/climinor) being touched; added.changeset/pr-1457-agentic.mdand pushed it towt/pair-page-worker(2d8e28eb). Package names verified viascripts/list-changesets.mjs-equivalent (list-changed-packages.mjs) andcheck-changesets.mjs --fixpasses.
Prior findings
- The
OFFER_VERSION-stays-at-2 observation from the previous review remains open but unchanged — still a documentation/confirmation nit only, no new evidence against it. - Prior fingerprint-widening, golden-vector, and call-site coverage findings are unaffected and were all resolved as described in the previous pass.
Verdict
LGTM ✅ — the increment is a small, safe UX fix in the private pair-page package plus docs; the previously reviewed core change remains sound, and the missing changeset has been supplied.
🤖 @agentproto-bot — review · legacy fallback (api-key) · run 36278163023 · sha 2d8e28eb07a424b232dcbba2521ac7c13437dd9c
Checking whether --qr is merely recognized doesn't catch a daemon built between #1450 and #1457, which accepts the flag but prints the old shared-origin cli.agentproto.sh link with a 16-hex id — a link that 404s on the current pair page. Check the printed link's shape instead (https://<32-hex>.agentproto.cloud/pair#...), in both Prerequisites and the Troubleshooting 404 entry. Regenerate the PDF.
User guide for pairing a phone with a daemon (pair offer --qr, fingerprint confirm, home screen, unpair, several daemons, troubleshooting, self-hosting), with screenshots of the pair page. Salvaged from wt/phone-pairing-guide (618ed84 + 125c47f, draft PR #1458 closed when its base #1457 merged). Adapted: the release caveat is gone (pair/v2 ships), the self-hosting anchor points at the current concepts/pairing.md heading, and the PDF export is dropped.
The phone pair page (AIP-59 §5.8) as a private package, served as one static bundle on every
<daemon-fingerprint>.agentproto.cloudby a Cloudflare Worker. Also in this PR:pair offer --qrdefaults to that page, and the identity fingerprint widens to 128 bits.Commits
feat(pair-page): per-daemon pair page on agentproto.cloud (Cloudflare Worker). New private packagepackages/pair-page, ported from cli-site#15 (logic kept, UI rewritten without Next)./pairreads the offer from the fragment and wipes it from history.id≠ the origin's first label before any network I/O; the offer stays unspent, and the page links to the right origin.pairFromOffer, shows name and fingerprint to confirm, and stores the credential./d/<fp>is the status page: connecting, daemon offline (retrying, Retry now), revoked, outdated pairing, not paired, wrong address.src/sw.ts: one service worker per pairing, scope/d/<fp>/, oneTunnelClientat module scope, proxying everything under the scope to the daemon. The Control Center loads from the daemon at/d/<fp>/apps/@agentik/session-chat/ui/.scopeCredentialStore): other fingerprints read as absent and are never written.dist/: hashed/assets/app-*.{js,css}, fixed/pair-sw.js,index.html, manifest, icons). No framework, no inline script or style, no third-party runtime code. The build fails ifindex.htmlhas inline script/style or a cross-origin reference.src/worker.ts, logic insrc/edge.ts):PREVIEW_HOSTS, where the page shows a PREVIEW banner./,/pair,/d/*→index.html; everything else served as named.default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self' wss:; worker-src 'self'; manifest-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'(ws://127.0.0.1:*/ws://localhost:*are added only on preview and loopback hosts);X-Frame-Options: DENY,Referrer-Policy: no-referrer, a minimal Permissions-Policy, HSTS;no-cachefor the SW script and the document,immutablefor hashed assets.wrangler.toml:name = "agentproto-pair-page",workers_dev = true,[assets]withrun_worker_first,html_handling = "none", no routes. The account comes from the environment.sw.ts).scripts/preview.mjsservesdist/through the same edge handler, for local tests.feat(secrets,cli,runtime): default pair page is one origin per daemon.DEFAULT_PAIR_PAGE = PAIR_WEB_URL_TEMPLATE_CLOUD(https://{fp}.agentproto.cloud/pair) forpair offer --qr,encodeOfferWebUrland thepairing.pairPageconfig default. It's still configurable (pairing.pairPage,--pair-page).PAIR_WEB_URLstays exported as the explicit shared-origin option. Docs updated:verbs/pair.md,concepts/pairing.md,reference/config-schema.md, pair-client README.feat(secrets)!: 128-bit identity fingerprint.identityFingerprint= the first 32 lowercase hex of sha256(x25519 pub), was 16. At 64 bits, a well-resourced attacker could grind a daemon key whose fingerprint lands on a victim daemon's origin. 32 hex is still one DNS label. pair/v2 is unreleased, so there's no migration.peerFingerprint(daemon key seen by the client, client key seen by the daemon, the pairing handle) uses the same function and widens with it.idmust be exactly^[0-9a-f]{32}$(new test: 16-hex, 33-hex and uppercase are refused). Pair page and Worker match^[0-9a-f]{32}$.sealKeyIdkeeps 16 hex, because it is persisted in keyring files by the released secrets CLI. It is the fingerprint's 16-hex prefix (identity test updated accordingly).idare re-derived, and a new KAT checks that the captured 64-bit values are the 16-char prefix of the new ones, so only the length changed. The captured v1 offer keeps itsid(still refused as outdated).identity/core.ts(definition) andidentity/index.ts(doc);pairing/offer-url.ts(validation and docs);pairing/handshake.ts(peerFingerprint, unchanged: it calls the same function);runtime/pairing-registry.ts(daemon fingerprint and client handle, same function);cli/util/client-pairings.ts,cli/util/pair-transport.ts,cli/commands/pair.ts(the{fp}template probe is now 32 zeros;pair lscolumn widened);pair-client/src/pair.tsandcredential.ts(credential key = fingerprint);pair-page(regexes);feat(pair-page): show the 128-bit fingerprint in groups of 4. It wraps cleanly on a phone, and a copy still yields the raw hex.Gates (real exit codes, on the rebased tree)
pnpm build(138 tasks)pnpm check-types(full)@agentproto/pair-pagetest (19)@agentproto/pair-clienttest (20)@agentproto/secretstest (263)@agentproto/clitest (1164)pairing-integration,pairing-browser-interop,pairing-rendezvous-default,config-schema,config-http,config-tools: 96)pnpm cli-docs:check(thepretestdocs gate)One pre-rebase cli run hit a hook timeout in
install-skill.test.ts, a file this PR doesn't touch, under full parallel load. It passed alone and on the re-run, and on the rebased tree.Local e2e (no Cloudflare, no live rdv)
Setup: a local broker at its default
--max-message-bytes, a scratch daemon (ownHOME, :18897, not :18790) serving agentik-studio#313's session-chat, andscripts/preview.mjs(the same edge handler). Browser: headless Chrome at 390×844 mobile.pair offer --qr --pair-page 'http://{fp}.localhost:8788/pair', fingerprintae5be03faa146dd77a5eaf2dc473649b(the old 64-bit value is its prefix).0123456789abcdef0123456789abcdef.localhostwas refused, and that origin has no IndexedDB and no worker. The link opened the still-unspent offer on the right origin.agentproto-pairand one worker scoped to/d/<fp>/.pair revokemoved the open Control Center to revoked.pair offer --qrwith no flag printshttps://ae5be03f…49b.agentproto.cloud/pair#….Deploy (for the supervisor; nothing was deployed and Cloudflare wasn't touched)
Then add the
*.agentproto.cloud/*route and a proxied wildcard*DNS record, with SSL Full (strict) and Universal SSL covering*.agentproto.cloud. Redeploy withoutPREVIEW_HOSTSfor production.🤖 @agentproto-bot — PR · session
sess_515e1367(rdv-browser PR3: cli-site /pair + service worker) · claude-code / subscription · auth-profileClaude Subs Agentik· modelclaude-opus-5-5· supervisorsess_d3e835f4· $36.0258 (daemon) · hostmac.home· cwdagentik-studio/rdv-pair-pageProduction proof (2026-09-26, Worker
cae88bea, hostedwss://rdv.agentproto.sh/v1)Setup: two scratch daemons from this branch (own
HOME/AGENTPROTO_HOMEunder/tmp, verified withps ewwandlsof; :18790 untouched). Browser: the chrome-devtools MCP, i.e. real Chrome with real WebCrypto, emulating 390×844 mobile with touch.pair offer --qr, no flags (0.86 s):https://e77b…2aef.agentproto.cloud/pair#v=2&rv=wss%3A%2F%2Frdv.agentproto.sh%2Fv1&id=e77b…2aef…./d/<fp>/…in 1.5 s.workerStart > 0for the navigation and/mcp.daemon: https://<fp>.agentproto.cloud/d/<fp>.isPolling: not exposed by the UI; no polling fallback active./d/<fp>/. B's key read from A's raw IndexedDB isnull./mcp200 in 102 ms).Found and fixed here (
f7eefe2c, needs a redeploy): the status page rebuilt its buttons on every 2.5 s worker reply, so a tap could miss. Minor:/favicon.ico404 at the origin root.