@zerogpu/browser-extension-sdk 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +99 -41
  2. package/bin/browser-extension-sdk.mjs +23 -0
  3. package/bin/cli.mjs +781 -0
  4. package/bin/herogpu.mjs +6 -0
  5. package/bin/zerogpu.mjs +6 -585
  6. package/dist/assets/herogpu-assets.json +21 -0
  7. package/dist/assets/herogpu-worker.js +1 -0
  8. package/dist/assets/zerogpu-assets.json +2 -2
  9. package/dist/assets/zerogpu-worker.js +1 -1
  10. package/dist/extension/herogpu-background.js +1 -0
  11. package/dist/extension/herogpu-offscreen.js +1 -0
  12. package/dist/extension/herogpu-settings-link.js +1 -0
  13. package/dist/extension/zerogpu-background.js +1 -1
  14. package/dist/extension/zerogpu-offscreen.js +1 -1
  15. package/dist/extension/zerogpu-settings-link.js +1 -1
  16. package/dist/herogpu-browser-sdk.cjs +1 -0
  17. package/dist/herogpu-browser-sdk.esm.js +1 -0
  18. package/dist/herogpu-browser-sdk.umd.js +1 -0
  19. package/dist/herogpu-worker.js +1 -0
  20. package/dist/loader.js +1 -1
  21. package/dist/manifest.json +5 -5
  22. package/dist/types/appinference/store.d.ts +6 -2
  23. package/dist/types/appinference/types.d.ts +29 -10
  24. package/dist/types/branding.d.ts +27 -0
  25. package/dist/types/config/types.d.ts +1 -1
  26. package/dist/types/extension/background.d.ts +68 -19
  27. package/dist/types/extension/consent.d.ts +61 -10
  28. package/dist/types/extension/offscreen.d.ts +64 -23
  29. package/dist/types/extension/settings-link.d.ts +12 -1
  30. package/dist/types/inference/runtime-locator.d.ts +1 -1
  31. package/dist/types/inference/worker-host.d.ts +1 -1
  32. package/dist/types/loader.d.ts +15 -3
  33. package/dist/types/public-api.d.ts +16 -10
  34. package/dist/types/runtime/app-identity.d.ts +2 -2
  35. package/dist/types/runtime/app-inference.d.ts +1 -1
  36. package/dist/types/runtime/custom-params.d.ts +1 -1
  37. package/dist/types/runtime/host-api.d.ts +2 -1
  38. package/dist/types/runtime/init-guard.d.ts +2 -1
  39. package/dist/types/runtime/tracking-script.d.ts +1 -1
  40. package/dist/types/storage/adopted-key.d.ts +23 -0
  41. package/dist/types/storage/cached-model.d.ts +4 -1
  42. package/dist/types/storage/model-store.d.ts +6 -0
  43. package/dist/types/transport/protocol.d.ts +1 -1
  44. package/dist/v/herogpu-browser-sdk.a957716b164a.umd.js +1 -0
  45. package/dist/v/zerogpu-browser-sdk.a957716b164a.umd.js +1 -0
  46. package/dist/zerogpu-browser-sdk.cjs +1 -1
  47. package/dist/zerogpu-browser-sdk.esm.js +1 -1
  48. package/dist/zerogpu-browser-sdk.umd.js +1 -1
  49. package/dist/zerogpu-worker.js +1 -1
  50. package/docs/app-side-inference.md +55 -45
  51. package/docs/auto-update-loader.md +33 -19
  52. package/docs/extension-developer-guide.md +158 -75
  53. package/docs/multi-model-support.md +14 -14
  54. package/package.json +13 -10
  55. package/dist/v/zerogpu-browser-sdk.686affbdf19f.umd.js +0 -1
@@ -1,6 +1,6 @@
1
- # ZeroGPU SDK — Chrome Extension Developer Guide
1
+ # herogpu SDK — Chrome Extension Developer Guide
2
2
 
3
- Add on-device AI to your Chrome extension. The ZeroGPU SDK runs a small language
3
+ Add on-device AI to your Chrome extension. The herogpu SDK runs a small language
4
4
  model on your users' own devices — so you get private, on-device text AI
5
5
  (summarizing, classifying, extracting, and more) without running any inference
6
6
  servers yourself.
@@ -8,6 +8,10 @@ servers yourself.
8
8
  This guide takes you from an empty Manifest V3 extension to a working integration
9
9
  in a few minutes, then shows how to validate it and keep it up to date.
10
10
 
11
+ herogpu is the new name of ZeroGPU. If your extension already ships the SDK under
12
+ the ZeroGPU names, it keeps working unchanged: see
13
+ [Coming from ZeroGPU](#coming-from-zerogpu) at the end of this guide.
14
+
11
15
  ---
12
16
 
13
17
  ## How it works (the short version)
@@ -15,11 +19,11 @@ in a few minutes, then shows how to validate it and keep it up to date.
15
19
  - **Where it runs:** the SDK runs in a background *offscreen document* — an
16
20
  invisible page Chrome provides for code that needs a full browser context. The
17
21
  tooling sets this up for you. Model loading and inference happen in a Worker
18
- the SDK spawns from the vendored `zerogpu-worker.js`, so the document's own
22
+ the SDK spawns from the vendored `herogpu-worker.js`, so the document's own
19
23
  thread stays responsive.
20
24
  - **What ships in your extension:** Chrome Manifest V3 doesn't allow extensions to
21
25
  load code from the internet, so the SDK and its runtime are copied into your
22
- extension at build time. Only model data is fetched while running. The `zerogpu`
26
+ extension at build time. Only model data is fetched while running. The `herogpu`
23
27
  CLI does the copying for you.
24
28
  - **When it starts:** once integrated, the SDK starts and registers the device
25
29
  **automatically** whenever your extension loads — there's nothing to trigger by
@@ -33,7 +37,7 @@ dependency and republish your extension.
33
37
  ## Prerequisites
34
38
 
35
39
  - A Manifest V3 Chrome extension.
36
- - An **operator key** from ZeroGPU (looks like `zgpu-sdk-…`).
40
+ - An **operator key** from herogpu (looks like `zgpu-sdk-…`).
37
41
  - Node.js and npm — used only at build time. Nothing from `node_modules` ships in
38
42
  your extension.
39
43
 
@@ -42,24 +46,24 @@ dependency and republish your extension.
42
46
  ## 1. Install
43
47
 
44
48
  ```bash
45
- npm install @zerogpu/browser-extension-sdk
49
+ npm install @herogpu/browser-extension-sdk
46
50
  ```
47
51
 
48
52
  ## 2. Integrate
49
53
 
50
54
  ```bash
51
- npx zerogpu init
55
+ npx herogpu init
52
56
  ```
53
57
 
54
58
  This single command:
55
59
 
56
- - copies the SDK runtime into your extension at `vendor/zerogpu/`,
60
+ - copies the SDK runtime into your extension at `vendor/herogpu/`,
57
61
  - creates `offscreen.html`, `offscreen.js`, and `background.js` (it never overwrites
58
62
  files you already have),
59
63
  - adds the entries the SDK needs to your `manifest.json` (the `offscreen` and
60
64
  `storage` permissions, a content-security-policy entry, the host permissions
61
65
  used to download models, and the `externally_connectable` entry that lets the
62
- ZeroGPU-hosted settings page reach your extension).
66
+ herogpu-hosted settings page reach your extension).
63
67
 
64
68
  ### Add the opt-out link
65
69
 
@@ -67,8 +71,8 @@ This is the one piece of markup you add yourself. Put it anywhere in an
67
71
  extension page you already show users — your popup is the usual place:
68
72
 
69
73
  ```html
70
- <a data-zerogpu-settings>Resource sharing</a>
71
- <script src="vendor/zerogpu/zerogpu-settings-link.js"></script>
74
+ <a data-herogpu-settings>Resource sharing</a>
75
+ <script src="vendor/herogpu/herogpu-settings-link.js"></script>
72
76
  ```
73
77
 
74
78
  That is the whole integration, and it is identical in every extension. There is
@@ -85,9 +89,9 @@ popup is not what you want.
85
89
  Open the generated `offscreen.js` and replace the placeholder:
86
90
 
87
91
  ```js
88
- import { initZeroGpuOffscreen } from "./vendor/zerogpu/zerogpu-offscreen.js";
92
+ import { initHeroGpuOffscreen } from "./vendor/herogpu/herogpu-offscreen.js";
89
93
 
90
- initZeroGpuOffscreen({
94
+ initHeroGpuOffscreen({
91
95
  edgeOperatorKey: "zgpu-sdk-your-key",
92
96
  enableConsoleLogs: true
93
97
  });
@@ -98,7 +102,7 @@ automatically.
98
102
 
99
103
  > **Using your own service worker or build pipeline?** `init` won't overwrite your
100
104
  > files — merge the generated `background.js` snippet into your existing worker, and
101
- > add `npx zerogpu vendor` to your build script (see [§5](#5-keep-it-up-to-date)).
105
+ > add `npx herogpu vendor` to your build script (see [§6](#6-keep-it-up-to-date)).
102
106
 
103
107
  ---
104
108
 
@@ -114,7 +118,7 @@ automatically.
114
118
  Run the built-in check any time:
115
119
 
116
120
  ```bash
117
- npx zerogpu doctor
121
+ npx herogpu doctor
118
122
  ```
119
123
 
120
124
  It confirms your manifest is wired correctly and that the vendored runtime is
@@ -125,9 +129,9 @@ present and matches the installed SDK version.
125
129
  ## 5. Let users opt out
126
130
 
127
131
  Your users must be able to turn resource sharing off, and have it stay off. The
128
- SDK ships this for you — `npx zerogpu init` wires it into the scaffolded
132
+ SDK ships this for you — `npx herogpu init` wires it into the scaffolded
129
133
  `background.js`, and if you merged the SDK into a service worker of your own,
130
- `npx zerogpu doctor` checks the worker your manifest actually points at and
134
+ `npx herogpu doctor` checks the worker your manifest actually points at and
131
135
  fails if the call is missing.
132
136
 
133
137
  Enforcement is entirely **client-side**: while a user is opted out, the service
@@ -136,7 +140,7 @@ connects. Nothing is deregistered server-side.
136
140
 
137
141
  ### Where a user can change it
138
142
 
139
- **1. The ZeroGPU-hosted settings page.** Give your users this link — it is the
143
+ **1. The herogpu-hosted settings page.** Give your users this link — it is the
140
144
  one they can reach without opening your extension's UI:
141
145
 
142
146
  ```text
@@ -146,17 +150,23 @@ https://zerogpu.ai/extension-settings?browser=chrome&extension_id=<your extensio
146
150
  Build it in code with:
147
151
 
148
152
  ```js
149
- ZeroGpuBackground.buildZeroGpuSettingsUrl({ extensionId: chrome.runtime.id });
153
+ HeroGpuBackground.buildHeroGpuSettingsUrl({ extensionId: chrome.runtime.id });
150
154
  ```
151
155
 
152
- This works because `npx zerogpu init` adds an `externally_connectable` entry to
156
+ This works because `npx herogpu init` adds an `externally_connectable` entry to
153
157
  your manifest, which lets that one page — and only that page — send the
154
158
  extension three messages:
155
159
 
156
160
  ```jsonc
157
- "externally_connectable": { "matches": ["https://*.zerogpu.ai/*"], "ids": ["*"] }
161
+ "externally_connectable": {
162
+ "matches": ["https://*.herogpu.com/*", "https://*.zerogpu.ai/*"],
163
+ "ids": ["*"]
164
+ }
158
165
  ```
159
166
 
167
+ The settings page is served from `zerogpu.ai` today and will also be served from
168
+ `herogpu.com`; both are listed so the link keeps working when it moves.
169
+
160
170
  The `ids` entry appears only when you had no `externally_connectable` key at all,
161
171
  and it changes nothing: Chrome treats a missing key as "every extension may
162
172
  connect, no web page may", but once the key exists an unspecified `ids` means
@@ -166,7 +176,7 @@ already declared the key yourself, even as `{}`, your `ids` is left exactly as
166
176
  it was.
167
177
 
168
178
  No content script and no extra host permission is involved. The bridge accepts
169
- only `zerogpu:ping`, `zerogpu:getConsent` and `zerogpu:setConsent`, validates the
179
+ only `herogpu:ping`, `herogpu:getConsent` and `herogpu:setConsent`, validates the
170
180
  sender's origin against an exact allowlist first, and can neither start
171
181
  inference nor read device data.
172
182
 
@@ -196,8 +206,8 @@ or when you need the link to work in unpacked builds too. Two lines, and they
196
206
  are the same two lines in every extension:
197
207
 
198
208
  ```html
199
- <a data-zerogpu-settings>Resource sharing</a>
200
- <script src="vendor/zerogpu/zerogpu-settings-link.js"></script>
209
+ <a data-herogpu-settings>Resource sharing</a>
210
+ <script src="vendor/herogpu/herogpu-settings-link.js"></script>
201
211
  ```
202
212
 
203
213
  There is nothing to configure and no JavaScript to write. The script fills in
@@ -217,10 +227,10 @@ A `role` or `tabindex` you set yourself is never overwritten. Off an extension
217
227
  page, where there is no id to send, the script leaves your markup alone rather
218
228
  than rendering a link that cannot work.
219
229
 
220
- Optional per-element overrides: `data-zerogpu-app-name` to show a different
221
- name, `data-zerogpu-base-url` to point at staging, `data-zerogpu-debug="true"`
230
+ Optional per-element overrides: `data-herogpu-app-name` to show a different
231
+ name, `data-herogpu-base-url` to point at staging, `data-herogpu-debug="true"`
222
232
  to render the page's raw payload. If you render your UI dynamically, call
223
- `ZeroGpuSettingsLink.applyZeroGpuSettingsLinks()` afterwards; it is idempotent,
233
+ `HeroGpuSettingsLink.applyHeroGpuSettingsLinks()` afterwards; it is idempotent,
224
234
  so wiring the same element twice is a no-op.
225
235
 
226
236
  **4. Your own toggle.** `init` also scaffolds an `options.html`/`options.js`
@@ -229,13 +239,13 @@ control in your own UI rather than a link out:
229
239
 
230
240
  ```js
231
241
  // current state
232
- chrome.runtime.sendMessage({ type: "zerogpu:getConsent" }, (res) => {
242
+ chrome.runtime.sendMessage({ type: "herogpu:getConsent" }, (res) => {
233
243
  if (!res?.ok) return showUnknown(chrome.runtime.lastError?.message || res?.error);
234
244
  console.log(res.consent); // { optedIn, updatedAt, source }
235
245
  });
236
246
 
237
247
  // turn it off — the SDK stops immediately and stays off across restarts
238
- chrome.runtime.sendMessage({ type: "zerogpu:setConsent", optedIn: false }, (res) => {
248
+ chrome.runtime.sendMessage({ type: "herogpu:setConsent", optedIn: false }, (res) => {
239
249
  if (res?.ok) return render(res.consent);
240
250
  // The write did not happen, so the SDK is still running. Put the control back
241
251
  // where it was; leaving it on the rejected choice tells the user their
@@ -245,7 +255,7 @@ chrome.runtime.sendMessage({ type: "zerogpu:setConsent", optedIn: false }, (res)
245
255
  ```
246
256
 
247
257
  Check `res.ok` on both, and **undo the control when a write fails**. A write only
248
- fails when the choice was not stored — `setZeroGpuConsent` throws rather than
258
+ fails when the choice was not stored — `setHeroGpuConsent` throws rather than
249
259
  report success for a decision that would not survive a restart — and a checkbox
250
260
  has already flipped by the time your callback runs, so reporting the error
251
261
  without reverting still leaves the user looking at an opt-out that never
@@ -266,26 +276,52 @@ confirmed yet. Copy its handling along with its calls rather than just the two
266
276
  Or directly, inside the service worker:
267
277
 
268
278
  ```js
269
- await ZeroGpuBackground.getZeroGpuConsent();
270
- await ZeroGpuBackground.setZeroGpuConsent(false);
279
+ await HeroGpuBackground.getHeroGpuConsent();
280
+ await HeroGpuBackground.setHeroGpuConsent(false);
271
281
  ```
272
282
 
273
- `ZeroGpuBackground` is a **global**, not a module. `zerogpu-background.js` is
283
+ `HeroGpuBackground` is a **global**, not a module. `herogpu-background.js` is
274
284
  built as a classic script so your service worker does not have to become
275
- `"type": "module"` — you get it from `importScripts("vendor/zerogpu/zerogpu-background.js")`
285
+ `"type": "module"` — you get it from `importScripts("vendor/herogpu/herogpu-background.js")`
276
286
  (the scaffolded `background.js` already does this), and there is nothing to
277
287
  `import`. Only the TypeScript types are exported from the package:
278
288
 
279
289
  ```ts
280
- import type { ZeroGpuConsent } from "@zerogpu/browser-extension-sdk/extension/consent";
290
+ import type { HeroGpuConsent } from "@herogpu/browser-extension-sdk/extension/consent";
281
291
  ```
282
292
 
283
- `setZeroGpuConsent` **rejects** if the write does not land — for example when
293
+ `setHeroGpuConsent` **rejects** if the write does not land — for example when
284
294
  the `storage` permission is missing. Treat a rejection as "the choice was not
285
295
  saved" and tell the user, rather than showing the toggle as flipped. Reads are
286
- the opposite: `getZeroGpuConsent` falls back to the opted-in default rather than
296
+ the opposite: `getHeroGpuConsent` falls back to the opted-in default rather than
287
297
  throwing, so a storage problem can never stop the SDK from starting.
288
298
 
299
+ ### Where the choice is stored
300
+
301
+ The choice is one record in `chrome.storage.local`, under the key
302
+ `herogpu:consent` (exported as `HEROGPU_CONSENT_KEY`):
303
+
304
+ ```jsonc
305
+ { "optedIn": false, "updatedAt": "2026-12-01T10:00:00.000Z", "source": "settings-page" }
306
+ ```
307
+
308
+ Every write also stores the same record under `zerogpu:consent`, the key the SDK
309
+ used up to 0.5.1, in the same storage call. That copy is what keeps an opt-out
310
+ from being lost: a version of your extension built with an earlier SDK reads only
311
+ that key, and treats "nothing stored" as opted in.
312
+
313
+ - A record under only one of the two keys is honoured as it is. Nothing is
314
+ moved or deleted; the next write stores both.
315
+ - If the two differ, `zerogpu:consent` is the one that counts. The SDK never
316
+ writes one without the other, so a difference means an earlier version wrote
317
+ its key afterwards, and that is the later choice. The next write puts the two
318
+ back in step.
319
+ - To change the choice from your own code, call `setHeroGpuConsent` or send
320
+ `herogpu:setConsent`. Do not write `herogpu:consent` yourself: on its own it
321
+ does not override a record under `zerogpu:consent`.
322
+ - One change is one notification: `onHeroGpuConsentChanged` listeners, and the
323
+ start or stop of the SDK, run once per write.
324
+
289
325
  ### The default
290
326
 
291
327
  New installs are **opted in**, which is why adding this to an existing extension
@@ -295,7 +331,7 @@ explicit yes first, write `false` on install and flip it when the user agrees:
295
331
  ```js
296
332
  chrome.runtime.onInstalled.addListener(async ({ reason }) => {
297
333
  if (reason === "install") {
298
- await ZeroGpuBackground.setZeroGpuConsent(false);
334
+ await HeroGpuBackground.setHeroGpuConsent(false);
299
335
  chrome.tabs.create({ url: "consent.html" });
300
336
  }
301
337
  });
@@ -317,20 +353,20 @@ Because Manifest V3 extensions can't change their code at runtime, your users ge
317
353
  new SDK version when you **publish a new build of your extension**. The aim is to
318
354
  make adopting new versions as low-effort as possible.
319
355
 
320
- **The one rule:** whenever the SDK version changes, the runtime in `vendor/zerogpu/`
321
- must be refreshed. `npx zerogpu vendor` does exactly that — it copies the currently
356
+ **The one rule:** whenever the SDK version changes, the runtime in `vendor/herogpu/`
357
+ must be refreshed. `npx herogpu vendor` does exactly that — it copies the currently
322
358
  installed SDK runtime into your extension. Wire it into your build so it can't be
323
359
  forgotten:
324
360
 
325
361
  ```json
326
- { "scripts": { "prebuild": "zerogpu vendor" } }
362
+ { "scripts": { "prebuild": "herogpu vendor" } }
327
363
  ```
328
364
 
329
- `vendor` also adds `"externally_connectable": { "matches": ["https://*.zerogpu.ai/*"] }`
330
- to your `manifest.json` if it is missing, merging alongside any origins you already
365
+ `vendor` also adds `"externally_connectable": { "matches": ["https://*.herogpu.com/*", "https://*.zerogpu.ai/*"] }`
366
+ to your `manifest.json` if either entry is missing, merging alongside any origins you already
331
367
  allow — plus `"ids": ["*"]` when it has to create the key, which preserves the
332
368
  extension-to-extension access an absent key already gave you. That entry is what
333
- lets the ZeroGPU settings page reach your extension, so
369
+ lets the herogpu settings page reach your extension, so
334
370
  without it the opt-out link is a dead end — and `init` only runs once, so an
335
371
  extension scaffolded before the opt-out shipped would never gain it otherwise. Once
336
372
  present, later builds leave the file untouched.
@@ -343,7 +379,7 @@ below fits your workflow.
343
379
  > prerelease versions (`X.Y.Z-dev.<stamp>.<sha>`) under the `dev` dist-tag —
344
380
  > semver ranges, Dependabot/Renovate, `npm update`, and bare `npm install` never
345
381
  > resolve them. To try one deliberately:
346
- > `npm install @zerogpu/browser-extension-sdk@dev && npx zerogpu vendor`.
382
+ > `npm install @herogpu/browser-extension-sdk@dev && npx herogpu vendor`.
347
383
 
348
384
  ### Option A — Automatic (recommended)
349
385
 
@@ -363,7 +399,7 @@ re-vendor on merge.
363
399
  { "extends": ["config:recommended"] }
364
400
  ```
365
401
 
366
- When the bot's PR lands, your build re-runs `zerogpu vendor` (via `prebuild`) and you
402
+ When the bot's PR lands, your build re-runs `herogpu vendor` (via `prebuild`) and you
367
403
  republish. Reviewing the PR before merging is recommended so you can skim the
368
404
  changelog — especially for major version bumps.
369
405
 
@@ -381,9 +417,9 @@ You control **how aggressively** updates are accepted via the version range in
381
417
  Update on your own schedule:
382
418
 
383
419
  ```bash
384
- npm update @zerogpu/browser-extension-sdk
385
- npx zerogpu vendor
386
- npx zerogpu doctor # confirm the vendored runtime matches the installed version
420
+ npm update @herogpu/browser-extension-sdk
421
+ npx herogpu vendor
422
+ npx herogpu doctor # confirm the vendored runtime matches the installed version
387
423
  ```
388
424
 
389
425
  Then republish.
@@ -393,11 +429,11 @@ Then republish.
393
429
  If your extension has no build step, vendor on demand without adding a dependency:
394
430
 
395
431
  ```bash
396
- npx -p @zerogpu/browser-extension-sdk zerogpu vendor
432
+ npx -p @herogpu/browser-extension-sdk herogpu vendor
397
433
  ```
398
434
 
399
435
  Run it again whenever you want a newer version, commit the refreshed
400
- `vendor/zerogpu/`, and republish.
436
+ `vendor/herogpu/`, and republish.
401
437
 
402
438
  ### Delivering the update to users
403
439
 
@@ -408,21 +444,21 @@ users automatically — nothing else to do.
408
444
 
409
445
  ## Configuration reference
410
446
 
411
- `initZeroGpuOffscreen(options)`:
447
+ `initHeroGpuOffscreen(options)`:
412
448
 
413
449
  | Option | Required | Description |
414
450
  | :--- | :--- | :--- |
415
- | `edgeOperatorKey` | yes | Your ZeroGPU operator key. |
451
+ | `edgeOperatorKey` | yes | Your herogpu operator key. |
416
452
  | `enableConsoleLogs` | no | Logs SDK activity to the offscreen console. Handy while integrating. |
417
- | `inferenceWorker` | no | Run model loading and inference in the SDK's worker (`vendor/zerogpu/zerogpu-worker.js`). Default `true`; the SDK falls back to the document's thread by itself if the worker cannot start. `false` forces that mode. |
453
+ | `inferenceWorker` | no | Run model loading and inference in the SDK's worker (`vendor/herogpu/herogpu-worker.js`). Default `true`; the SDK falls back to the document's thread by itself if the worker cannot start. `false` forces that mode. |
418
454
  | `appUserId` | no | A stable identifier for the current user, if you want consistent identity across sessions. |
419
- | `orchestratorBaseUrl` | no | Point at a non-default ZeroGPU environment, if you've been given one. Defaults to production. |
455
+ | `orchestratorBaseUrl` | no | Point at a non-default herogpu environment, if you've been given one. Defaults to production. |
420
456
  | `customParams` | no | Your own reporting dimensions — `{ cust_param1, cust_param2, cust_param3 }`. See [Custom macros](#custom-macros). |
421
457
 
422
458
  ### Custom macros
423
459
 
424
460
  Three opaque slots (`cust_param1`..`cust_param3`) for placement, cohort,
425
- campaign or any dimension of your own. ZeroGPU counts them against every request
461
+ campaign or any dimension of your own. herogpu counts them against every request
426
462
  your users' devices serve and reports them back only to you. Values are strings
427
463
  up to 128 characters (longer ones are truncated) and **must not contain personal
428
464
  data** — email-shaped values are dropped.
@@ -430,7 +466,7 @@ data** — email-shaped values are dropped.
430
466
  Set them where the SDK starts, in `offscreen.js`:
431
467
 
432
468
  ```js
433
- initZeroGpuOffscreen({
469
+ initHeroGpuOffscreen({
434
470
  edgeOperatorKey: "zgpu-sdk-your-key",
435
471
  customParams: { cust_param1: "new_tab", cust_param2: "spring_campaign" }
436
472
  });
@@ -440,38 +476,38 @@ To change them while the extension runs, from your service worker:
440
476
 
441
477
  ```js
442
478
  // Replaces the whole map; {} clears it. Resolves false if the SDK isn't running.
443
- await ZeroGpuBackground.setZeroGpuCustomParams({ cust_param1: "popup" });
479
+ await HeroGpuBackground.setHeroGpuCustomParams({ cust_param1: "popup" });
444
480
  ```
445
481
 
446
482
  Values sent this way last as long as the offscreen document. Chrome may tear
447
483
  it down and recreate it (after an opt-out and back in, or a browser restart),
448
- so anything that should survive that belongs in `initZeroGpuOffscreen` too.
484
+ so anything that should survive that belongs in `initHeroGpuOffscreen` too.
449
485
 
450
486
  ### Use the model in your extension (0.5.0)
451
487
 
452
- The model the user's browser holds for the ZeroGPU network can also answer
488
+ The model the user's browser holds for the herogpu network can also answer
453
489
  requests from your extension, on the device, and you may choose which eligible
454
490
  model that is. The SDK runs in the offscreen document; your service worker,
455
491
  popup or options page reaches it through the background bundle:
456
492
 
457
493
  ```js
458
- const { contributionState, activeModelId } = await ZeroGpuBackground.getZeroGpuContribution();
459
- const models = await ZeroGpuBackground.getZeroGpuEligibleModels(); // judged for this device, never downloads
460
- const outcome = await ZeroGpuBackground.switchZeroGpuModel("zlm-v1-moderation-edge");
494
+ const { contributionState, activeModelId } = await HeroGpuBackground.getHeroGpuContribution();
495
+ const models = await HeroGpuBackground.getHeroGpuEligibleModels(); // judged for this device, never downloads
496
+ const outcome = await HeroGpuBackground.switchHeroGpuModel("zlm-v1-moderation-edge");
461
497
  if (outcome.granted) {
462
- const result = await ZeroGpuBackground.runZeroGpuLocal({ text: "some text", top_k: 14 });
498
+ const result = await HeroGpuBackground.runHeroGpuLocal({ text: "some text", top_k: 14 });
463
499
  result.response; // { unsafe: 0.02, … } — ran on this device
464
500
  }
465
- await ZeroGpuBackground.clearZeroGpuModelChoice();
466
- await ZeroGpuBackground.forgetZeroGpuUnfitModel("some-model");
467
- ZeroGpuBackground.onZeroGpuEvent(({ event, detail }) => {
501
+ await HeroGpuBackground.clearHeroGpuModelChoice();
502
+ await HeroGpuBackground.forgetHeroGpuUnfitModel("some-model");
503
+ HeroGpuBackground.onHeroGpuEvent(({ event, detail }) => {
468
504
  // activeModelChanged, modelChoiceRefused, degraded, recovered, shutdown
469
505
  });
470
506
  ```
471
507
 
472
508
  Each helper makes sure the offscreen document exists (never for a user who
473
- opted out), sends one `chrome.runtime` message (`zerogpu:eligibleModels`,
474
- `zerogpu:switchModel`, `zerogpu:runLocal`, …) and resolves with the typed
509
+ opted out), sends one `chrome.runtime` message (`herogpu:eligibleModels`,
510
+ `herogpu:switchModel`, `herogpu:runLocal`, …) and resolves with the typed
475
511
  answer; errors come back as the same classes a website gets
476
512
  (`NotContributingError`, `ModelNotEligibleError`, …, each with a `code`).
477
513
  Local calls work only while `contributionState` is `contributing`. The
@@ -484,10 +520,57 @@ full guide — flows, every inference kind's input and output, errors — is
484
520
 
485
521
  | Symptom | Fix |
486
522
  | :--- | :--- |
487
- | The SDK doesn't start | Open the offscreen console (*Inspect views: offscreen.html*) and check for errors, then run `npx zerogpu doctor`. |
488
- | CSP error mentioning `'wasm-unsafe-eval'` | Your manifest's content security policy must allow `'wasm-unsafe-eval'`. Re-run `npx zerogpu init` (or `doctor`). |
489
- | Import fails / runtime files missing | Run `npx zerogpu vendor` and confirm `vendor/zerogpu/` exists. |
490
- | Log line "Inference worker unavailable; models run on the main thread" | The vendored `zerogpu-worker.js` is missing or stale (an SDK update without re-vendoring). The SDK keeps working on the document's thread; run `npx zerogpu vendor` to restore the worker. |
491
- | Model download blocked | If your extension limits network access, allow the model host in your manifest's host permissions (`npx zerogpu doctor` will flag this). |
523
+ | The SDK doesn't start | Open the offscreen console (*Inspect views: offscreen.html*) and check for errors, then run `npx herogpu doctor`. |
524
+ | CSP error mentioning `'wasm-unsafe-eval'` | Your manifest's content security policy must allow `'wasm-unsafe-eval'`. Re-run `npx herogpu init` (or `doctor`). |
525
+ | Import fails / runtime files missing | Run `npx herogpu vendor` and confirm `vendor/herogpu/` exists. |
526
+ | Log line "Inference worker unavailable; models run on the main thread" | The vendored `herogpu-worker.js` is missing or stale (an SDK update without re-vendoring). The SDK keeps working on the document's thread; run `npx herogpu vendor` to restore the worker. |
527
+ | Model download blocked | If your extension limits network access, allow the model host in your manifest's host permissions (`npx herogpu doctor` will flag this). |
492
528
  | Rejected at registration / 401 | Your operator key isn't valid for the environment you're targeting. Check the key (and `orchestratorBaseUrl` if you set one). |
493
- | Out of date after an update | `npx zerogpu doctor` reports drift → run `npx zerogpu vendor`. |
529
+ | Out of date after an update | `npx herogpu doctor` reports drift → run `npx herogpu vendor`. |
530
+ | Registration blocked after updating an extension that narrowed its `host_permissions` to `zerogpu.ai` | The device registry is now on `herogpu.com`. Add `https://*.herogpu.com/*` next to the `zerogpu.ai` entry. |
531
+
532
+ ---
533
+
534
+ ## Coming from ZeroGPU
535
+
536
+ herogpu is the new name of ZeroGPU. An extension integrated with 0.5.1 or earlier
537
+ needs no change: update the package, build, publish.
538
+
539
+ - **The package and the command.** `@zerogpu/browser-extension-sdk` keeps receiving
540
+ every version (the same build as `@herogpu/browser-extension-sdk`), and
541
+ `npx zerogpu vendor`, `init` and `doctor` still work.
542
+ - **Your vendored files stay where they are.** `vendor` keeps writing
543
+ `vendor/zerogpu/zerogpu-offscreen.js`, `zerogpu-background.js`,
544
+ `zerogpu-settings-link.js` and `zerogpu-worker.js` for an extension that has that
545
+ folder or imports from it, whichever of the two commands you run. Your
546
+ `import`, `importScripts` and `<script src>` lines keep resolving.
547
+ - **Your code keeps running.** `ZeroGpuBackground`, `ZeroGpuSettingsLink`,
548
+ `initZeroGpuOffscreen`, `registerZeroGpuConsentBridge`, `getZeroGpuConsent` and
549
+ every other `…ZeroGpu…` name are still there: each is the same function as its
550
+ `…HeroGpu…` counterpart. Messages are accepted as `zerogpu:…` and as
551
+ `herogpu:…`, and host events are still broadcast as `zerogpu:event` (and as
552
+ `herogpu:event`; listen for one of the two). `data-zerogpu-settings` and the
553
+ other `data-zerogpu-…` attributes are still read.
554
+ - **Your users' choices stay.** An opt-out a user made before the update is
555
+ honoured exactly as it was stored (`zerogpu:consent` in `chrome.storage.local`),
556
+ and the device id and the downloaded models stay where they are too.
557
+ - **An opt-out is never lost, in either direction.** From this version on the
558
+ choice is stored under `herogpu:consent`, and every write also stores the same
559
+ record under `zerogpu:consent`. If you go back to an earlier version of the SDK,
560
+ it finds the user's latest choice under the key it knows, and code of yours
561
+ that reads `zerogpu:consent` directly keeps seeing it. A choice made while an
562
+ earlier version was running is picked up again after the next update (see
563
+ [Where the choice is stored](#where-the-choice-is-stored)).
564
+ - **Your manifest gains one entry.** The next `vendor` adds
565
+ `https://*.herogpu.com/*` to `externally_connectable.matches`, next to the
566
+ `zerogpu.ai` entry it already has. `doctor` accepts either domain.
567
+ - **One thing to check.** The device registry is now reached on `herogpu.com`. If
568
+ you replaced the scaffolded `<all_urls>` host permission with a narrower list,
569
+ add `https://*.herogpu.com/*` to it.
570
+
571
+ To move an extension to the new names, do it in one change: delete
572
+ `vendor/zerogpu/`, point your `import`, `importScripts` and `<script src>` lines
573
+ at `vendor/herogpu/herogpu-*.js`, run `npx herogpu vendor`, and rename the calls
574
+ when you like (`ZeroGpuBackground` → `HeroGpuBackground`, and so on). Nothing
575
+ requires it. The full list of names is in the
576
+ [SDK README](../README.md#coming-from-zerogpu).
@@ -1,6 +1,6 @@
1
1
  # Multi-Model Support in the Browser SDK
2
2
 
3
- A plain-language summary of what changed in the ZeroGPU Browser SDK to host any model from the model registry, what needs to happen on the backend, and how to verify it works.
3
+ A plain-language summary of what changed in the herogpu Browser SDK to host any model from the model registry, what needs to happen on the backend, and how to verify it works.
4
4
 
5
5
  Audience: project managers, product, anyone who wants the shape of the change without reading code.
6
6
 
@@ -18,7 +18,7 @@ The backend still decides which model goes to which device. The SDK just runs wh
18
18
 
19
19
  ## What the SDK had to support
20
20
 
21
- The ZeroGPU model registry contains models across **three different inference frameworks** and **five different task types**, plus some models that expose multiple "use cases" from one loaded model (e.g. GLiNER can do entity extraction, PII redaction, JSON parsing, and classification from the same weights).
21
+ The herogpu model registry contains models across **three different inference frameworks** and **five different task types**, plus some models that expose multiple "use cases" from one loaded model (e.g. GLiNER can do entity extraction, PII redaction, JSON parsing, and classification from the same weights).
22
22
 
23
23
  | Framework | What runs on it | Task types | Example models |
24
24
  |---|---|---|---|
@@ -41,7 +41,7 @@ The SDK has to route each incoming task to the right operation without reloading
41
41
 
42
42
  ```mermaid
43
43
  flowchart TD
44
- A[Browser tab opens] --> B[initZeroGpuSdk]
44
+ A[Browser tab opens] --> B[initHeroGpuSdk]
45
45
  B --> C[POST /register with device info]
46
46
  C --> D{Model assigned?}
47
47
  D -- No --> Stop1[Stop]
@@ -69,7 +69,7 @@ flowchart TD
69
69
 
70
70
  ```mermaid
71
71
  flowchart TD
72
- A[Browser tab opens] --> B[initZeroGpuSdk]
72
+ A[Browser tab opens] --> B[initHeroGpuSdk]
73
73
  B --> AdapterReg[Adapters self-register:<br/>ONNX, Transformers, GGUF]
74
74
  AdapterReg --> C[POST /register with device info]
75
75
  C --> D{Model assigned?}
@@ -155,7 +155,7 @@ sequenceDiagram
155
155
  participant ModelHost as Model File Host<br/>(HF / CDN)
156
156
  participant WS as WebSocket
157
157
 
158
- Browser->>SDK: initZeroGpuSdk()
158
+ Browser->>SDK: initHeroGpuSdk()
159
159
  SDK->>SDK: Register adapters (ONNX, Transformers, GGUF)
160
160
  SDK->>Orchestrator: POST /register (device info, cached models)
161
161
  Orchestrator->>SDK: slmConfig[] with inferenceFramework, taskType, requiredFiles
@@ -297,7 +297,7 @@ npm install
297
297
  ### Each test cycle
298
298
 
299
299
  ```bash
300
- # 1. Build the SDK bundle (writes sdk/dist/zerogpu-browser-sdk.umd.js)
300
+ # 1. Build the SDK bundle (writes sdk/dist/herogpu-browser-sdk.umd.js)
301
301
  npm run build
302
302
 
303
303
  # 2. Start the local demo on http://localhost:8000
@@ -312,31 +312,31 @@ The page sets the SDK's environment based on the hostname: `localhost` → `loca
312
312
  // IMPORTANT: the demo loads the UMD bundle lazily, only after you click
313
313
  // "Initialize SDK" the first time. Click the button once (any credentials)
314
314
  // so the script tag is injected, THEN run this in console:
315
- await window.ZeroGpuBrowserSdk.initZeroGpuSdk({
315
+ await window.HeroGpuBrowserSdk.initHeroGpuSdk({
316
316
  edgeOperatorKey: 'your-key'
317
317
  });
318
318
  ```
319
319
 
320
- If you see `Cannot read properties of undefined (reading 'initZeroGpuSdk')`, the bundle hasn't been loaded into the page yet. Either click the Initialize SDK button first, or inject the script manually:
320
+ If you see `Cannot read properties of undefined (reading 'initHeroGpuSdk')`, the bundle hasn't been loaded into the page yet. Either click the Initialize SDK button first, or inject the script manually:
321
321
 
322
322
  ```js
323
323
  await new Promise((resolve, reject) => {
324
324
  const s = document.createElement('script');
325
- s.src = '/dist/zerogpu-browser-sdk.umd.js';
325
+ s.src = '/dist/herogpu-browser-sdk.umd.js';
326
326
  s.onload = resolve;
327
327
  s.onerror = reject;
328
328
  document.head.appendChild(s);
329
329
  });
330
330
  ```
331
331
 
332
- If you also get a 404 on `/dist/zerogpu-browser-sdk.umd.js`, you haven't built the SDK yet — run `npm run build` in `sdk/`.
332
+ If you also get a 404 on `/dist/herogpu-browser-sdk.umd.js`, you haven't built the SDK yet — run `npm run build` in `sdk/`.
333
333
 
334
334
  ### What to watch in DevTools
335
335
 
336
336
  1. **Network tab → `/register`** — confirm the response's `slmConfig` includes `inferenceFramework`, `taskType`, `requiredFiles`, and a `sample` matching the model.
337
- 2. **Application tab → IndexedDB → `zerogpu-slm-cache` → `models`** — after first load, one row per `${modelId}:${version}` with all the model files cached as Blobs.
337
+ 2. **Application tab → IndexedDB → `herogpu-slm-cache` → `models`** — after first load, one row per `${modelId}:${version}` with all the model files cached as Blobs. (A browser that already ran the SDK before the rename keeps its `zerogpu-slm-cache` database and its downloaded models.)
338
338
  3. **Network tab → WS filter** — watch frames going both ways. Incoming = task batches. Outgoing = responses.
339
- 4. **Console** — every step logs `[ZeroGPU][Flow]` markers.
339
+ 4. **Console** — every step logs `[herogpu][Flow]` markers.
340
340
 
341
341
  ### Testing each adapter
342
342
 
@@ -526,7 +526,7 @@ If you want to test inference without changing the orchestrator yet, you can cal
526
526
 
527
527
  ```js
528
528
  // After SDK init succeeds:
529
- const { getAdapter } = window.ZeroGpuBrowserSdk;
529
+ const { getAdapter } = window.HeroGpuBrowserSdk;
530
530
  const adapter = getAdapter('deberta-v3-small');
531
531
  const result = await adapter.runInference({
532
532
  usecase: 'classification',
@@ -536,7 +536,7 @@ const result = await adapter.runInference({
536
536
  console.log(result.output);
537
537
  ```
538
538
 
539
- (Note: `getAdapter` is internal — not part of the public SDK API today. Exposing it on `window.ZeroGpuBrowserSdk` is a one-line dev affordance if you want to lean on this pattern.)
539
+ (Note: `getAdapter` is internal — not part of the public SDK API today. Exposing it on `window.HeroGpuBrowserSdk` is a one-line dev affordance if you want to lean on this pattern.)
540
540
 
541
541
  ---
542
542