Repository navigation
feat(browser): standalone extension relay daemon with native-host wake-up - #128379
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 30, 2026, 4:39 AM ET / 08:39 UTC. ClawSweeper reviewWhat this changesThis PR adds a standalone browser-extension relay daemon that an authenticated native host can wake for a paired direct-loopback Chrome extension. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the new daemon can own a relay port before Gateway starts, but Gateway still unconditionally creates its own in-process relay, causing the documented Priority: P1 Review scores
Verification
How this fits togetherThe browser plugin connects Chrome to authenticated loopback relay servers used by OpenClaw browser control and CDP clients. The native host can now start a relay when Chrome reconnects, while Gateway later attempts to manage relays for the same browser profiles. flowchart LR
A[Paired Chrome extension] --> B[Native messaging host]
B --> C[Standalone relay daemon]
C --> D[Loopback relay port]
E[Gateway browser control] --> F[Relay lifecycle]
F --> D
D --> G[CDP and browser-control clients]
Decision needed
Why: Gateway currently requires an in-process relay bridge, while the new daemon owns an independent bridge on the same port; choosing a safe handoff or canonical owner is an architectural decision. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +431, Tests +568, Docs +52, Other +1. Total +1052 across 24 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Give daemon-first and Gateway-first startup one coordinated relay ownership model, then prove both orders preserve authenticated browser control without weakening the existing port or authentication boundary. Do we have a high-confidence way to reproduce the issue? Yes on this PR head: wake the direct-loopback daemon, then start Gateway and invoke browser control. The PR's isolated live evidence reports that result and the source confirms the competing bind path; this read-only review did not rerun it. Is this the best way to solve the issue? No. The standalone daemon is viable, but its independent ownership is incomplete because Gateway cannot adopt or coordinate the daemon's relay bridge. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f2cc4f1a0f4b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
Adversarial security pass (5 parallel reviewers)Ran five adversarial subagents against distinct trust boundaries — native-host Fixed: standalone daemon was not v2-onlyThe daemon called Confirmed safe (attackers could not break these)
Noted, pre-existing (not introduced here — for separate follow-up)
|
Follow-up: secret-file read hardening now includedThe "pre-existing" item from the security pass above — the relay secret's confidentiality resting only on the directory mode set at write time, with no owner/mode re-check on read — is now fixed in this PR (7cf6b78), since it's the load-bearing assumption behind the whole loopback-plus-secret trust model.
Verified live: a secret manually loosened to Remaining follow-ups (genuinely out of scope, unchanged from above): scrub |
7cf6b78 to
6637eb2
Compare
|
@clawsweeper re-review The wrong-target finding and both rank-up moves are addressed in the refreshed candidate: The refreshed build, whole-PR changed gate, and focused suite passed (299 tests, one skipped). A fresh full-PR Codex autoreview found no actionable defects at its P0 threshold. The PR body now records the exact commands and the original failing/passing regressions. Not ready to merge yet: one complete CLI-first native/daemon proof passed, but a second fresh-state run and a profiled diagnostic timed out at the unchanged 30-second CLI bound. Existing-profile source-blind Chrome UI verification is also blocked by refused/indeterminate native GUI targeting. These gaps are explicit in the updated evidence; no native-first warm-up, longer timeout, remote-secret copy, direct DevTools fallback, or historical live run is being substituted for current proof. Native prepare/merge remains on hold, and exact-head hosted CI still needs to complete. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Use the existing relay payload cap for the teardown fixture WebSocketServer. Refs: #128379
Await authoritative cleanup and retirement-notice write settlement without letting delivery failure retroactively fail completed cleanup. Actual cleanup failures remain fatal, and missing borrower receipts remain fenced. Refs: #128379
Keep Gateway browser evaluation from timing out when Chrome sends its default Runtime context before the frame-tree reply. Wait for earlier frame replies in the same logical CDP session before Runtime.enable, retaining disable and lifetime checks while unrelated commands stay concurrent. Refs: #128379
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Installed browser proof completedThe daemon-first ownership finding and the requested startup-order demonstration are resolved. Real Chrome now passes Gateway-first and native-daemon-first Core actions, snapshots, diagnostics, navigation, Gateway-forwarded ingress, and unchanged external-client operation after Gateway shutdown. Native messaging also replaces the stopped daemon while preserving the same Chrome/page; a deliberately restarted external client then changes the preserved counter 7→8 and creates/closes a new page. This was built and installed from c79e339. The current CI-only commit has exactly the same source tree ( The images below are inspected captures of a synthetic fixture in the real isolated browser, not generated mockups. The before image is the predecessor's stalled Gateway evaluation; the remaining images show the repaired Gateway-first flow, daemon-first navigation, external control after Gateway stop, and native recovery. The PR body contains commands, regression evidence, process-identity checks, and the full scope/limitations. Protected operator state was not touched. Cold-client daemon recovery is proved; retained-client reconnection after daemon replacement and the ten-minute idle expiry are not claimed. Land-ready verification: CI 33340376759 and OpenGrep 33340376753 passed on attempt 1 for exact head |
|
Merged via squash.
|
Remove duplicate profile admission and terminal handling, reuse RPC result schemas and deferred completion, and make announcement recipients and request-local action guards explicit. Preserve authentication, asynchronous ownership checks, cleanup acknowledgements, and action error precedence. Make the Gateway upgrade-head fixture deterministic at its existing input boundary instead of depending on TCP coalescing. Keep its assertions. Maintainer-requested follow-up to the standalone relay in #128379. Production LOC -75; test LOC -11. Validated with 203 focused tests, changed checks, full build, and fresh scoped-clean Codex autoreview at P0.
…e-up (openclaw#128379) * feat(browser): standalone extension relay daemon with native-host wake-up Host the extension relay outside the Gateway: a new relay-daemon-entry serves the existing relay server on the configured port, the native messaging host learns an origin-validated ensure_relay op that spawns it detached when nothing serves the port, and the extension asks for it (rate-limited) when a direct loopback /extension pairing cannot connect. Chrome becomes the supervisor: the daemon defers to a hosting Gateway on EADDRINUSE and idle-exits once both the extension and all CDP clients are gone, so browser control no longer depends on Gateway boot. * fix(browser): make standalone relay daemon v2-only by default The daemon previously called startExtensionRelayServer without allowLegacyAuth, inheriting the permissive ?? true default and silently re-enabling legacy one-directional auth (Bearer/Basic/token-subprotocol) even where an operator set extensionRelay.allowLegacyAuth=false. Because legacy auth sends the secret to whoever holds the port, a process that squats the relay port could harvest the credential from a legacy client. Default the standalone daemon to v2-only (mutual HMAC, which the extension and mcporter both speak), honoring an explicit allowLegacyAuth=true opt-in read from the raw config. Adversarial review via subagents surfaced this as the one operator-config regression the PR introduced. * fix(browser): enforce owner + 0600 on relay secret reads The relay secret is the entire auth model and loopback is not a trust boundary on a multi-user host, but the fs-safe reader only rejected symlinks/hardlinks — a secret whose mode drifted group/other-readable (loosened umask, restore, shared home) was still trusted. Re-check owner and mode on every read at the relay boundary: self-heal a too-broad mode on our own file back to 0600, refuse a foreign-owned or non-regular file, and route the concurrent-creation reread through the same hardened path so a foreign secret is never adopted. Verified live: a 0644 secret is tightened to 0600 on read while v2 control keeps working. * fix(browser): wake the paired extension relay * fix(browser): share standalone relay ownership with Gateway Let Gateway authenticate and borrow an existing standalone relay without rebinding its port. Fence operations to the exact owner, profile, and tab generation, and acknowledge shutdown only after owned cleanup completes. Discover native extension IDs from Chromium Preferences and Secure Preferences, including non-first profiles, while retaining explicit repair. Refs: openclaw#128379 * fix(browser): preserve relay ingress through setup and teardown Keep raw socket error ownership until close so late write errors remain handled after wrapper destruction. Retain WebSocket error handling through authentication and the full ingress lifetime. Pause legacy ingress during asynchronous preparation to preserve immediate and coalesced hello frames, then resume after admission or rejection. Refs: openclaw#128379 * test(browser): bound relay teardown fixture payloads Use the existing relay payload cap for the teardown fixture WebSocketServer. Refs: openclaw#128379 * fix(browser): separate retirement delivery from cleanup Await authoritative cleanup and retirement-notice write settlement without letting delivery failure retroactively fail completed cleanup. Actual cleanup failures remain fatal, and missing borrower receipts remain fenced. Refs: openclaw#128379 * fix(browser): order relay runtime bootstrap after frame replies Keep Gateway browser evaluation from timing out when Chrome sends its default Runtime context before the frame-tree reply. Wait for earlier frame replies in the same logical CDP session before Runtime.enable, retaining disable and lifetime checks while unrelated commands stay concurrent. Refs: openclaw#128379 * ci: refresh relay checks against repaired main
Remove duplicate profile admission and terminal handling, reuse RPC result schemas and deferred completion, and make announcement recipients and request-local action guards explicit. Preserve authentication, asynchronous ownership checks, cleanup acknowledgements, and action error precedence. Make the Gateway upgrade-head fixture deterministic at its existing input boundary instead of depending on TCP coalescing. Keep its assertions. Maintainer-requested follow-up to the standalone relay in openclaw#128379. Production LOC -75; test LOC -11. Validated with 203 focused tests, changed checks, full build, and fresh scoped-clean Codex autoreview at P0.
Consolidate image traversal, request observation ownership, bus waiters, Slack response classification, Node selection and WebSocket decoding. Retire the generic Windows executable export after its Node caller moved; keep trusted taskkill/PowerShell paths and all environment validation. Remove duplicate planner validation and unsupported private lifecycle guards. Keep external evidence validation, security authority, resource limits and ordinary write-capable shutdown settlement. Also preserve WhatsApp audio preflight when enabling message actions and avoid recording a POSIX pipe-drain failure during the normal TERM grace. Best-effort tradeoffs accepted: - Bus cloning trusts its private typed event union. 0ebeee8 added the unsupported-kind throw only for lint; fabricated internal kinds now fail naturally, and a new typed variant must update this owner at compile time. - Overlapping private QA driver transitions are unsupported; callers await them. #113855 introduced synthetic interleavings, not a human incident. - Canonical smoke selection is trusted instead of revalidated; #114055 was an ownership cutover. A future selector defect belongs at that owner. - Wire image inputs are parsed JSON trees. #71311 introduced no human cyclic-input incident; unsupported internal cyclic objects are best effort. - Fabricated cyclic/BigInt tool outputs now fail clearly instead of becoming empty evidence. 195e721 added stabilization, not a human incident. - Reinstalling the private AIMock mount is unsupported. bdc9c60 added speculative guards; the actual owner installs it once before start. - Obsolete repeated observer disposal after port reuse can remove the newer QA lookup. 6386dc4 was an affinity repair, not a disposal incident; normal unique-port ownership and stop ordering prevent that lifecycle. - Local non-federated Matrix joins fail immediately on setup errors; #64489 added initial coverage, not a reported transient-join incident. Rerun the QA command after an unusual setup fault. - Artifact publication is trusted after its awaited atomic writer. #92606 added suite execution, not a missing-write incident; deletion afterward is reported by normal readers. - Native browser JSON needs no branded rawJSON surrogate workaround. #140882 added that generality without a human incident; a future branded producer must own its serialization contract. - Insertion-only pending caches clear directly on settlement. #113926 and #128379 supplied no human successor-eviction incident; no replacement can precede these finalizers. Real close-time successor checks stay. - Re-registering the identical private borrowed-relay handle is unsupported. #128379/#133706 introduced no such incident; the owner creates fresh handles and current authority and distinct-successor comparisons remain. - Inconclusive Linux process snapshots conservatively stay alive until the next check. #132230/#131643 used controlled fault injection, not a human actual-use incident. Final unconfirmed settlement retains state for retry.
…0889) Consolidate image traversal, request observation ownership, bus waiters, Slack response classification, Node selection and WebSocket decoding. Retire the generic Windows executable export after its Node caller moved; keep trusted taskkill/PowerShell paths and all environment validation. Remove duplicate planner validation and unsupported private lifecycle guards. Keep external evidence validation, security authority, resource limits and ordinary write-capable shutdown settlement. Also preserve WhatsApp audio preflight when enabling message actions and avoid recording a POSIX pipe-drain failure during the normal TERM grace. Best-effort tradeoffs accepted: - Bus cloning trusts its private typed event union. f993a27 added the unsupported-kind throw only for lint; fabricated internal kinds now fail naturally, and a new typed variant must update this owner at compile time. - Overlapping private QA driver transitions are unsupported; callers await them. openclaw#113855 introduced synthetic interleavings, not a human incident. - Canonical smoke selection is trusted instead of revalidated; openclaw#114055 was an ownership cutover. A future selector defect belongs at that owner. - Wire image inputs are parsed JSON trees. openclaw#71311 introduced no human cyclic-input incident; unsupported internal cyclic objects are best effort. - Fabricated cyclic/BigInt tool outputs now fail clearly instead of becoming empty evidence. 5929e9a added stabilization, not a human incident. - Reinstalling the private AIMock mount is unsupported. e98e098 added speculative guards; the actual owner installs it once before start. - Obsolete repeated observer disposal after port reuse can remove the newer QA lookup. ace0e05 was an affinity repair, not a disposal incident; normal unique-port ownership and stop ordering prevent that lifecycle. - Local non-federated Matrix joins fail immediately on setup errors; openclaw#64489 added initial coverage, not a reported transient-join incident. Rerun the QA command after an unusual setup fault. - Artifact publication is trusted after its awaited atomic writer. openclaw#92606 added suite execution, not a missing-write incident; deletion afterward is reported by normal readers. - Native browser JSON needs no branded rawJSON surrogate workaround. openclaw#140882 added that generality without a human incident; a future branded producer must own its serialization contract. - Insertion-only pending caches clear directly on settlement. openclaw#113926 and openclaw#128379 supplied no human successor-eviction incident; no replacement can precede these finalizers. Real close-time successor checks stay. - Re-registering the identical private borrowed-relay handle is unsupported. openclaw#128379/openclaw#133706 introduced no such incident; the owner creates fresh handles and current authority and distinct-successor comparisons remain. - Inconclusive Linux process snapshots conservatively stay alive until the next check. openclaw#132230/openclaw#131643 used controlled fault injection, not a human actual-use incident. Final unconfirmed settlement retains state for retry.





What Problem This Solves
Fixes an issue where a Chrome extension with a direct-loopback pairing loses browser automation when no local Gateway or browser node is serving its relay. A tunnel to a remote Gateway does not supply that same-host listener.
Installed testing also exposed two broken supported flows: a native-woken daemon prevented later Gateway browser control with
EADDRINUSE, and Gateway-owned browser evaluation could hang after a successful tab listing because an execution-context event overtook its initialization response. Both are repaired and now pass real installed Chrome proof.Why This Change Was Made
The browser plugin owns an on-demand standalone daemon, and Gateway now distinguishes owning a listener from borrowing authenticated access to its real bridge. Each configured profile/port has one authoritative bridge in either startup order. Ordinary browser work remains CDP/Playwright; a narrow, existing-v2-authenticated owner channel supplies readiness, bounded connection-local operation references, and forwarding of authenticated Gateway extension ingress. Closing Gateway's lease does not stop the daemon or unrelated external clients.
The native host validates the reconnecting extension's saved port against configured extension profiles before waking it. Automatic wake accepts only the canonical
127.0.0.1address the daemon serves. The new daemon defaults to mutual v2 authentication; the existing explicitbrowser.extensionRelay.allowLegacyAuth=trueopt-in remains available. Normal automatic bootstrap retains its Gateway route.Connected repairs preserve the same ownership boundaries: descriptor-owned POSIX relay-secret reads; guarded discovery of both Chromium
PreferencesandSecure Preferences; raw/WebSocket error ownership through close; immediate/coalesced legacy ingress admission; and cleanup acknowledgement distinct from best-effort final notification delivery. Runtime initialization now waits for earlier frame-tree replies on the exact logical session without serializing unrelated clients, Fetch responses, dialog handling, or other CDP commands.User Impact
With a supporting extension/native-host build, a configured direct-loopback pairing can recover its local relay on reconnect without a running Gateway. External authenticated CDP clients can use it directly. Core
openclaw browseractions still use a Gateway, which can now join an already-running daemon safely. Access revocation, opt-out, exact origins, profile/session generations, and real native cleanup remain authoritative.The daemon and Gateway both need a build supporting owner access. No new configuration/environment option, dependency, SQLite schema, persistent store, SDK API, or protocol-version bump is introduced. The native request union is IPC framing, not a persistent data-model change. No v3 path, direct-DevTools fallback, remote-secret copying, or Gateway service installation is added. Windows retains manual setup. The unpacked source build was tested; Store v2.2.0 must not be assumed to contain this unpublished feature.
See Chrome extension setup and browser CLI.
Evidence
Published CI head: 4f47b95ffe4218f874da0df1cc576ea80bec6702. Its parent c79e3399c8c91add8019fc5ee954135cb56b00fb is the built/live-tested commit. Both have exactly source tree
f389993641a5ff1341c68d105db09ed3aa22a762: the intervening commit is empty and only refreshes CI. No source file changed after review or installed proof. Fresh exact-head CI run 33340376759 and OpenGrep run 33340376753 both passed on attempt 1. Requiredopenclaw/ci-gatesucceeded, with zero failed or pending checks. Actual CI checkouteb88e616b3f1f2ed72b3f5cf9ae2644260617e18contains the published head and repaired main. Source, installed proof, and CI are ready for the native landing workflow; no merge is claimed yet.Installed real-Chrome proof
All required installed behavior clauses passed on Blacksmith Testbox, lease
tbx_01m1abng2m81wkaac18f2kzcn1, run 33338491413. The canonical packer built a self-contained tarball, which was installed into a fresh task HOME withumask 022. CLI:OpenClaw 2026.8.1 (c79e339). Artifact SHA-256:70c6172999e3e928a0e93ec01859255482786f329f023d0b16000bd8e6099588(62,047,957 bytes).Chrome for Testing 152.0.7977.54 loaded the managed unpacked copy through the visible Extensions UI and native directory chooser, after native-host registration. Installed dependencies were independently checked: Playwright 1.62.1, ws 8.21.3. External control used MCPorter 0.13.8 and chrome-devtools-mcp 1.8.0, explicit
--autoConnect,requirerelay policy, and the default discovery budget. No storage injection, fabricated Chrome record, manual daemon launch, relay-URL pin, or discovery-timeout override supplied this proof. The setup driver disconnected before relay-driven actions.Preferences, withmanualSetupRequired=falseand no issues.127.0.0.1hostname is allowlisted.Seventeen captures were inspected and verified synthetic-only. The directory chooser needed two observed activations; the first dismissed path completion. The initial 120-second installer waiter ended before UI setup finished and correctly still requested manual setup; after actual visible loading, the normal idempotent install command discovered the plugin. That setup timing is not hidden as a first-attempt success or fixed with a longer timeout.
This proves cold-client recovery after daemon replacement, not retained-client crash reconnection. Protected existing-profile recovery, live non-first-profile configuration, background screenshot capture, and the ten-minute idle expiry were not exercised. Non-first/pinned-port selection has focused regression coverage. No package or Store release was performed.
Regression and local verification
EADDRINUSE; current installed proof above demonstrates both repairs.Principal commands (Node 24; full exact command/exit/hash receipts retained locally):
CI and review follow-through
The behavioral commit's browser shard and OpenGrep run 33337441900 passed. CI run 33337441820 failed only the docs release-navigation assertion. The independently owned navigation expectation fix landed as 7504a3b3c453. A draft/ready refresh still checked out the old merge input, so one CI-only empty commit forces a fresh synchronize event. The source tree remains identical; the old failed/stale checks are not being relabeled green.
The latest substantive ClawSweeper review reviewed the earlier
1a8f89cbhead. Its ownership finding, architectural decision, and rank-up request are addressed by the single real-bridge owner model, both startup-order regressions, and the installed daemon-first/Gateway proof above. The v2-only daemon default with existing explicit legacy opt-in is accepted. The stored-data-model classification of native IPC framing is not a SQLite/schema change. A new review has been queued by the ready-for-review event; its arrival is separate from required CI and verified behavior.Production: +2,559/-844, net +1,715; tests/support: +3,140/-579, net +2,561; docs: +90/-18; tooling/config: +2/-1. Raw churn includes authentication/target-info/fixture extractions and
finallyindentation, not additional capabilities. Production growth supplies the standalone lifecycle and authenticated cross-process ownership, generation fencing, bounded operation references, and acknowledged cleanup; the final ordering repair itself is net +23 production lines. Release-ownedCHANGELOG.mdis unchanged; release-note context is in this PR.