Skip to content

Commit 63a3a95

Browse files
authored
fix(browser): support Chrome Web Store native bootstrap (#124775)
* fix(browser): support Chrome Web Store native bootstrap * chore: keep browser release note in PR body * docs(browser): document Store identity trust boundary * docs(browser): correct Store recovery guidance
1 parent 65922f9 commit 63a3a95

11 files changed

Lines changed: 490 additions & 102 deletions

‎docs/cli/browser.md‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,13 @@ openclaw browser extension cdp
150150
openclaw browser extension cdp --json
151151
```
152152

153-
- `extension install` copies the bundled runtime into a stable state-directory
154-
path and pre-registers its deterministic, origin-locked native bootstrap host
155-
in existing Chrome-family user-data roots. Launch Chrome, run this command,
156-
and use **Load unpacked** only after it prints the stable path. The command
157-
waits while Chrome records that exact path, then verifies the recorded ID
158-
against Chromium's path-derived ID. **Load unpacked** is the only manual
159-
action in normal setup.
160-
- `extension status` reports the installed copy, detected IDs/profiles,
161-
owned-registration health, and whether manual setup is required. JSON output
162-
never includes a pairing string or relay key.
153+
- `extension install` pre-registers the origin-locked native bootstrap host in
154+
existing Chrome-family user-data roots. Run it first, then
155+
[add OpenClaw from the Chrome Web Store](https://chromewebstore.google.com/detail/openclaw/kcdjddhmeafeomebliikmbpblkmkfoig).
156+
The stable **Load unpacked** path remains available as a development fallback.
157+
- `extension status` reports Store discovery separately from approved unpacked
158+
IDs and paths, plus owned-registration health and whether manual setup is
159+
required. JSON output never includes a pairing string or relay key.
163160
- `extension uninstall-host` removes only verified OpenClaw-owned native-host
164161
manifests and launchers. It does not remove the extension from Chrome.
165162
- `extension path` is read-only. It prints the stable installed copy when
@@ -194,8 +191,8 @@ Setup, security model, and recovery steps: [Chrome extension](/tools/chrome-exte
194191

195192
If the extension already attempted automatic setup before the native host
196193
existed, Chromium retains that miss for the running browser process. Restart
197-
Chrome once, then repeat the ordered install flow; popup retries alone cannot
198-
recover that existing process.
194+
Chrome once, run `extension install`, then reopen the Store extension; popup
195+
retries alone cannot recover that existing process.
199196

200197
## Tabs
201198

‎docs/gateway/doctor.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,10 @@ That stages grounded durable candidates into the short-term dreaming store while
366366
When a stable Chrome extension copy and owned native-host registration already
367367
exist, doctor reports registration drift. `openclaw doctor --fix` may repair
368368
that owned registration, but it never installs the host for every OpenClaw
369-
user and never overwrites a foreign same-name manifest or launcher. Use
370-
`openclaw browser extension install` for the initial setup.
369+
user and never overwrites a foreign same-name manifest or launcher. For
370+
initial setup, run `openclaw browser extension install` first, then add the
371+
official Chrome Web Store extension. The unpacked stable path is a
372+
development fallback.
371373

372374
Doctor also audits the host-local Chrome MCP path when you use `defaultProfile: "user"` or a configured `existing-session` profile:
373375

‎docs/tools/chrome-extension.md‎

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,38 @@ a script launcher or registry key without a proven binary framing path.
3232

3333
## Install
3434

35-
Launch Chrome, then run this command before loading the extension:
35+
Launch Chrome, then pre-register the native host before adding the extension:
3636

3737
```bash
3838
openclaw browser extension install
3939
```
4040

41-
Keep the command running. It copies the bundled extension to a stable
42-
OpenClaw-owned directory, predicts the unpacked extension ID from that exact
43-
path, and pre-registers an origin-locked native host in existing Chrome-family
44-
user-data roots. Only after pre-registration succeeds does it print the stable
45-
path to load.
41+
Keep the command running. It pre-registers an origin-locked native host for the
42+
exact official Chrome Web Store identity and for OpenClaw's deterministic
43+
development IDs. After pre-registration succeeds, add
44+
[OpenClaw from the Chrome Web Store](https://chromewebstore.google.com/detail/openclaw/kcdjddhmeafeomebliikmbpblkmkfoig).
4645

47-
Chrome does not let a normal CLI silently install an unpacked extension. This
48-
one step is unavoidable:
46+
The extension pairs on its first native call; you do not need to open its
47+
popup, reload it, or restart Chrome during a normal first-time setup. The
48+
installer then reads the profile's `Secure Preferences` and verifies the exact
49+
Store ID independently from any extension path.
50+
51+
For extension development, the command also copies the bundled extension to a
52+
stable OpenClaw-owned directory. Use that unpacked copy only as a development
53+
fallback:
4954

5055
1. Open `chrome://extensions`.
5156
2. Enable **Developer mode**.
5257
3. Click **Load unpacked**.
5358
4. Select the path printed by the command.
5459

55-
Leave the install command running while you complete those steps. The extension
56-
pairs on its first native call; you do not need to open its popup, reload the
57-
extension, or restart Chrome during a normal first-time setup. The installer
58-
then reads the profile's `Secure Preferences` and verifies that Chrome loaded
59-
the approved realpath under the predicted ID.
60+
Leave the install command running while completing either Store or development
61+
setup. For unpacked development, the installer verifies that Chrome loaded the
62+
approved realpath under its predicted deterministic ID.
6063

61-
The installer accepts an ID only when all of these are true:
64+
The installer recognizes the official Store installation only by the exact
65+
Foundation Store ID. That identity never makes a recorded path OpenClaw-owned.
66+
For unpacked development, it accepts an ID only when all of these are true:
6267

6368
- the ID matches Chrome's 32-character extension ID format;
6469
- Chrome records the install location as unpacked;
@@ -76,9 +81,10 @@ Use a different bounded wait when needed:
7681
openclaw browser extension install --wait-ms 60000
7782
```
7883

79-
For automation, use `--json`. The result includes the stable copy, discovered
80-
IDs and profiles, native-host registration health, and whether manual setup is
81-
required. It never includes a relay key or pairing string.
84+
For automation, use `--json`. The result reports Store discovery separately
85+
from approved unpacked IDs and paths, plus native-host registration health and
86+
whether manual setup is required. It never includes a relay key or pairing
87+
string.
8288

8389
## Use it
8490

@@ -160,7 +166,8 @@ Chromium caches the first missing-native-host result for the running browser
160166
process. If an existing extension already attempted automatic setup before the
161167
native host was installed, restart Chrome once (a full browser-process reload).
162168
Retrying from the popup or Settings cannot clear that process-level miss.
163-
Normal setup avoids it by pre-registering the host before **Load unpacked**.
169+
Normal setup avoids it by pre-registering the host before adding or reopening
170+
the Store extension. For development, pre-register before **Load unpacked**.
164171

165172
## Status and removal
166173

@@ -177,8 +184,8 @@ Remove only OpenClaw-owned native-host manifests and launchers:
177184
openclaw browser extension uninstall-host
178185
```
179186

180-
This does not remove the unpacked extension from Chrome. Use
181-
`chrome://extensions` for that. It also does not delete the stable extension
187+
This does not remove the Store or unpacked extension from Chrome. Use
188+
`chrome://extensions` for that. It also does not delete the stable development
182189
copy or an existing relay key.
183190

184191
`openclaw browser extension path` is read-only. It prints the stable installed
@@ -261,12 +268,21 @@ OpenClaw-owned mode-`0700` directory. Manifests are mode `0600`; the launcher is
261268
owner-executable. Symlinks, foreign ownership, unsafe modes, path traversal,
262269
wildcard origins, and foreign same-name registrations fail closed.
263270

264-
The unpacked ID calculation matches Chromium's
271+
The managed manifest authorizes the exact Foundation Chrome Web Store origin
272+
plus deterministic development origins in canonical order. The Store identity
273+
is a fixed product trust grant, not proof that an arbitrary path is
274+
OpenClaw-owned.
275+
276+
Install the official Chrome Web Store build for normal use. Only load unpacked
277+
development copies you trust: Chrome can give a key-matched unpacked build the
278+
same extension identity and native-host access.
279+
280+
The unpacked development ID calculation matches Chromium's
265281
`crx_file::id_util::GenerateIdForPath`: hash the canonical absolute path's raw
266282
bytes with SHA-256 (native UTF-16LE path bytes on Windows, with only a lowercase
267283
drive letter uppercased), keep the first 16 digest bytes, then map hexadecimal
268-
digits `0` through `f` to letters `a` through `p`. The extension manifest has no
269-
`key`; registration authorizes only exact IDs derived from approved
284+
digits `0` through `f` to letters `a` through `p`. The unpacked extension
285+
manifest has no `key`; only these development IDs depend on approved
270286
OpenClaw-owned realpaths.
271287

272288
The relay itself uses connection-bound HMAC proofs. The persistent per-host key
@@ -281,8 +297,8 @@ openclaw doctor
281297
```
282298

283299
- **No extension ID detected:** keep Chrome running, rerun `extension install`,
284-
and use **Load unpacked** only after the command says native bootstrap is
285-
ready and prints the stable path.
300+
then add the official Store extension. Use **Load unpacked** only as a
301+
development fallback after the command says native bootstrap is ready.
286302
- **Extension was loaded before native setup:** restart Chrome once to clear its
287303
cached native-host miss, then rerun the ordered install flow.
288304
- **Waiting for local OpenClaw:** run `extension status`; install or repair the

‎extensions/browser/chrome-extension/bootstrap.chromium.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const runE2E =
2626
process.env.OPENCLAW_BROWSER_EXTENSION_E2E === "1" &&
2727
(process.platform === "linux" || process.platform === "darwin");
2828
const cleanups: Array<() => Promise<void>> = [];
29+
const STORE_ORIGIN = "chrome-extension://kcdjddhmeafeomebliikmbpblkmkfoig/";
2930

3031
afterEach(async () => {
3132
for (const cleanup of cleanups.splice(0).toReversed()) {
@@ -249,6 +250,8 @@ describe.runIf(runE2E)("Chrome native bootstrap Chromium E2E", () => {
249250
]
250251
.toSorted()
251252
.map((id) => `chrome-extension://${id}/`);
253+
expectedOrigins.push(STORE_ORIGIN);
254+
expectedOrigins.sort();
252255
const relevantManifestPaths = chromeProductRoots(deps)
253256
.filter((productRoot) => productRoot.userDataDir === userDataDir)
254257
.map((productRoot) =>
@@ -392,6 +395,19 @@ describe.runIf(runE2E)("Chrome native bootstrap Chromium E2E", () => {
392395
) {
393396
throw new Error("native host did not use the custom installation context");
394397
}
398+
const storeHostProbe = spawnSync(manifest.path, [STORE_ORIGIN], {
399+
input: requestFrame,
400+
env: browserEnv,
401+
timeout: 30_000,
402+
});
403+
expect(
404+
storeHostProbe.status,
405+
`Store native host exit=${storeHostProbe.status} signal=${storeHostProbe.signal} stderr=${storeHostProbe.stderr.toString("utf8")}`,
406+
).toBe(0);
407+
expect(decodeSingleNativeResponse(storeHostProbe.stdout)).toMatchObject({
408+
ok: true,
409+
nonce: "BwcHBwcHBwcHBwcHBwcHBw",
410+
});
395411
process.stderr.write("[browser-extension-e2e] launcher probe passed\n");
396412

397413
await expect

‎extensions/browser/src/browser/extension-install-layout.ts‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type DiscoveredChromeExtension = {
2626
extensionId: string;
2727
extensionPath: string;
2828
};
29+
export type DiscoveredChromeStoreExtension = Omit<DiscoveredChromeExtension, "extensionPath">;
2930
export type ExtensionInstallDeps = {
3031
platform?: NodeJS.Platform;
3132
env?: NodeJS.ProcessEnv;
@@ -310,12 +311,14 @@ async function approvedRealpaths(paths: readonly string[]): Promise<string[]> {
310311
return [...new Set(resolved.filter((value): value is string => value !== null))];
311312
}
312313

313-
/** Discover unpacked OpenClaw IDs from exact Secure Preferences path records. */
314+
/** Discover exact Store identity separately from approved unpacked path records. */
314315
export async function discoverChromeExtensionIds(params: {
315316
approvedDirs: readonly string[];
317+
storeExtensionId?: string;
316318
deps?: ExtensionInstallDeps;
317319
}): Promise<{
318320
discovered: DiscoveredChromeExtension[];
321+
storeDiscovered: DiscoveredChromeStoreExtension[];
319322
issues: string[];
320323
identityMismatches: string[];
321324
}> {
@@ -325,6 +328,7 @@ export async function discoverChromeExtensionIds(params: {
325328
(await approvedRealpaths(params.approvedDirs)).map((value) => comparablePath(value, platform)),
326329
);
327330
const discovered: DiscoveredChromeExtension[] = [];
331+
const storeDiscovered: DiscoveredChromeStoreExtension[] = [];
328332
const issues: string[] = [];
329333
const identityMismatches: string[] = [];
330334
for (const root of chromeProductRoots(deps)) {
@@ -374,7 +378,26 @@ export async function discoverChromeExtensionIds(params: {
374378
) {
375379
continue;
376380
}
377-
const entry = rawEntry as { location?: unknown; path?: unknown };
381+
const entry = rawEntry as {
382+
from_webstore?: unknown;
383+
location?: unknown;
384+
path?: unknown;
385+
};
386+
if (
387+
extensionId === params.storeExtensionId &&
388+
entry.from_webstore === true &&
389+
entry.location !== UNPACKED_MANIFEST_LOCATION
390+
) {
391+
storeDiscovered.push({
392+
product: root.product,
393+
browser: root.label,
394+
userDataDir: root.userDataDir,
395+
profile: profileEntry.name,
396+
securePreferencesPath,
397+
extensionId,
398+
});
399+
continue;
400+
}
378401
if (entry.location !== UNPACKED_MANIFEST_LOCATION || typeof entry.path !== "string") {
379402
continue;
380403
}
@@ -415,12 +438,23 @@ export async function discoverChromeExtensionIds(params: {
415438
entry,
416439
]),
417440
);
441+
const uniqueStore = new Map(
442+
storeDiscovered.map((entry) => [
443+
`${entry.product}\0${entry.profile}\0${entry.extensionId}`,
444+
entry,
445+
]),
446+
);
418447
return {
419448
discovered: [...unique.values()].toSorted((a, b) =>
420449
`${a.product}/${a.profile}/${a.extensionId}`.localeCompare(
421450
`${b.product}/${b.profile}/${b.extensionId}`,
422451
),
423452
),
453+
storeDiscovered: [...uniqueStore.values()].toSorted((a, b) =>
454+
`${a.product}/${a.profile}/${a.extensionId}`.localeCompare(
455+
`${b.product}/${b.profile}/${b.extensionId}`,
456+
),
457+
),
424458
issues,
425459
identityMismatches,
426460
};

0 commit comments

Comments
 (0)