Skip to content

Commit fada067

Browse files
authored
feat(browser): add zero-click Chrome extension bootstrap (#121586)
* feat(browser): add zero-click extension bootstrap Pre-register deterministic path-derived extension IDs and install a strict native messaging host. Keep the popup and options UI minimal while removing the obsolete copilot and page-share flows. * fix(browser): satisfy native bootstrap CI guards * test(browser): isolate native bootstrap Chrome roots * test(browser): flush native bootstrap profile before status * test(browser): seed Linux native bootstrap identity * fix(browser): preserve native bootstrap upgrade safety Allow immutable root-owned package inputs while keeping mutable state, manifests, and launchers user-owned. Preserve all retired copilot keys whenever active or unrecognized recovery custody remains. * fix(browser): preserve pending copilot custody Retired cleanup now removes copilot state only when the durable registry is exactly empty. Any session, archive, malformed value, future shape, or read failure preserves every retired key. * fix(browser): guard native bootstrap upgrades Fail closed while retired copilot custody remains and make discard durable across partial failures. Require exact launcher-embedded origins and repair full launcher drift without accepting mismatched registrations. * fix(browser): remove stale layout export * chore(release): leave changelog to release flow
1 parent d6f70a9 commit fada067

122 files changed

Lines changed: 5593 additions & 12015 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,9 +1545,9 @@ jobs:
15451545
--configLoader runner
15461546
--shard ${{ matrix.shard }}/4
15471547
1548-
- name: Test browser copilot end-to-end
1548+
- name: Test browser extension bootstrap end-to-end
15491549
if: matrix.shard == 1
1550-
run: pnpm test:e2e:browser-copilot
1550+
run: pnpm test:e2e:browser-extension
15511551

15521552
checks-ui-e2e-real-gateway:
15531553
permissions:

‎.oxlintrc.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@
214214
".agents/skills/autoreview/tests/fixtures/**",
215215
"test/fixtures/oxlint-boundary-guards/**",
216216
"**/a2ui.bundle.js",
217-
"extensions/browser/chrome-extension/modules/copilot-runtime.js",
218217
"extensions/diffs/assets/viewer-runtime.js",
219218
"extensions/diffs-language-pack/assets/viewer-runtime.js",
220219
"node_modules/",

‎config/knip.config.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,13 +685,12 @@ const config = {
685685
"browser-host-inspection.ts!",
686686
"browser-maintenance.ts!",
687687
"browser-profiles.ts!",
688+
// Built by tsdown as the native messaging executable; Chrome launches it by path.
689+
"native-host-entry.ts!",
688690
// Chrome manifest/package scripts load these without TypeScript imports.
689691
"chrome-extension/background.js!",
692+
"chrome-extension/options.js!",
690693
"chrome-extension/popup.js!",
691-
"chrome-extension/sidepanel.js!",
692-
"scripts/build-copilot-runtime.mjs!",
693-
// esbuild receives this browser bootstrap by an assembled path.
694-
"scripts/copilot-runtime-entry.ts!",
695694
"scripts/copy-chrome-extension.mjs!",
696695
]),
697696
[`${BUNDLED_PLUGIN_ROOT_DIR}/canvas`]: bundledPluginWorkspace([

‎docs/cli/browser.md‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,33 @@ System-profile import is enabled by default. Set `browser.allowSystemProfileImpo
122122

123123
```bash
124124
openclaw browser extension path
125+
openclaw browser extension install
126+
openclaw browser extension install --json --wait-ms 60000
127+
openclaw browser extension status
128+
openclaw browser extension status --json
129+
openclaw browser extension uninstall-host
125130
openclaw browser extension pair
126131
openclaw browser extension pair --gateway-url wss://gateway.example.com
127132
openclaw browser extension cdp
128133
openclaw browser extension cdp --json
129134
```
130135

131-
- `extension path` prints the unpacked extension directory for Chrome's **Load
132-
unpacked** flow.
133-
- `extension pair` creates the host-local relay key when needed and prints the
134-
pairing string. `--gateway-url` creates a direct remote-Gateway pairing URL;
135-
non-loopback URLs must use `wss://`.
136+
- `extension install` copies the bundled runtime into a stable state-directory
137+
path and pre-registers its deterministic, origin-locked native bootstrap host
138+
in existing Chrome-family user-data roots. Launch Chrome, run this command,
139+
and use **Load unpacked** only after it prints the stable path. The command
140+
waits while Chrome records that exact path, then verifies the recorded ID
141+
against Chromium's path-derived ID. **Load unpacked** is the only manual
142+
action in normal setup.
143+
- `extension status` reports the installed copy, detected IDs/profiles,
144+
owned-registration health, and whether manual setup is required. JSON output
145+
never includes a pairing string or relay key.
146+
- `extension uninstall-host` removes only verified OpenClaw-owned native-host
147+
manifests and launchers. It does not remove the extension from Chrome.
148+
- `extension path` is read-only. It prints the stable installed copy when
149+
present and the bundled source directory otherwise.
150+
- `extension pair` remains the advanced manual flow. `--gateway-url` creates a
151+
direct remote-Gateway pairing URL; non-loopback URLs must use `wss://`.
136152
- `extension cdp` prints non-secret Browser Relay Authentication v2 metadata:
137153
the loopback browser/CDP endpoints, protocol version, key ID, and fixed
138154
challenge/complete binding. It never prints the relay key or an authorization
@@ -146,6 +162,11 @@ on stderr so stdout stays valid JSON.
146162

147163
Setup, security model, and migration steps: [Chrome extension](/tools/chrome-extension).
148164

165+
If the extension already attempted automatic setup before the native host
166+
existed, Chromium retains that miss for the running browser process. Restart
167+
Chrome once, then repeat the ordered install flow; popup retries alone cannot
168+
recover that existing process.
169+
149170
## Tabs
150171

151172
```bash

‎docs/gateway/doctor.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Flags:
155155
<Accordion title="Config and migrations">
156156
- Config normalization for legacy value shapes.
157157
- Talk config migration from legacy flat `talk.*` fields into `talk.provider` + `talk.providers.<provider>`.
158-
- Browser migration checks for legacy Chrome extension configs and Chrome MCP readiness.
158+
- Browser migration checks for legacy Chrome extension configs, owned native-bootstrap registration drift, and Chrome MCP readiness.
159159
- OpenCode provider override warnings (`models.providers.opencode` / `opencode-zen` / `opencode-go`).
160160
- Legacy OpenAI Codex provider/profile migration (`openai-codex` → `openai`) and shadowing warnings for stale `models.providers.openai-codex`.
161161
- OAuth TLS prerequisites check for OpenAI Codex OAuth profiles.
@@ -359,6 +359,12 @@ That stages grounded durable candidates into the short-term dreaming store while
359359

360360
Doctor warns while `browser.extensionRelay.allowLegacyAuth` is enabled. Upgrade paired Chrome extensions and external CDP clients to Browser Relay Authentication v2, then set the flag to `false`. V2 clients do not downgrade to legacy authentication.
361361

362+
When a stable Chrome extension copy and owned native-host registration already
363+
exist, doctor reports registration drift. `openclaw doctor --fix` may repair
364+
that owned registration, but it never installs the host for every OpenClaw
365+
user and never overwrites a foreign same-name manifest or launcher. Use
366+
`openclaw browser extension install` for the initial setup.
367+
362368
Doctor also audits the host-local Chrome MCP path when you use `defaultProfile: "user"` or a configured `existing-session` profile:
363369

364370
- checks whether Google Chrome is installed on the same host for default auto-connect profiles

‎docs/gateway/security/index.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,15 @@ Enabling browser control gives the model a real browser. If that profile already
502502
OpenClaw tab group as its ACL. Existing pairings migrate to **Selected tabs**,
503503
while new personal-browser pairings recommend **All tabs**. Incognito and
504504
internal Chrome pages remain excluded in either mode.
505+
- Automatic Chrome extension setup uses an origin-locked native messaging
506+
manifest discovered from an exact unpacked extension path in Chrome profile
507+
metadata. The one-shot host accepts only a versioned request with a fresh
508+
nonce, caps input at 4 KiB, validates the Chrome-supplied origin, and returns
509+
only a locally owned pairing. It never transfers a remote Gateway key.
510+
- Native-host manifests, launchers, and status output contain no pairing key.
511+
OpenClaw refuses symlinks, unsafe ownership/modes, wildcard origins, and
512+
foreign registrations using the same host name. Windows uses the manual
513+
pairing fallback until an executable native-host path is supported.
505514
- Run a **node host** on the browser machine and let the Gateway proxy browser actions when the Gateway is remote from the browser (see [Browser tool](/tools/browser)); treat node pairing like admin access, keep Gateway and node host on the same tailnet, and avoid exposing relay/control ports over LAN, public internet, or Tailscale Funnel.
506515

507516
### Browser SSRF policy (strict by default)

0 commit comments

Comments
 (0)