@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
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The SDK's two name spaces.
3
+ *
4
+ * `herogpu` is the name everything is documented under. `zerogpu` is the name
5
+ * the SDK shipped with until 0.5.1 and stays supported: every message type,
6
+ * window event, DOM attribute and stored key that existed under it keeps
7
+ * working. This module holds the two prefixes and the small helpers the rest
8
+ * of the code uses to speak both, so no other file spells the rule out again.
9
+ *
10
+ * Dependency-free on purpose: the service-worker bundle and the settings-link
11
+ * bundle import it and must stay tiny.
12
+ */
13
+ export declare const BRAND = "herogpu";
14
+ export declare const LEGACY_BRAND = "zerogpu";
15
+ /** `herogpu:<name>`: the documented form of a message or window-event type. */
16
+ export declare const brandMessage: <T extends string>(name: T) => `herogpu:${T}`;
17
+ /** `zerogpu:<name>`: the same type as 0.5.1 and earlier spelled it. */
18
+ export declare const legacyMessage: <T extends string>(name: T) => `zerogpu:${T}`;
19
+ /**
20
+ * Reads a received message type in either spelling and gives back the
21
+ * documented one (`zerogpu:ping` → `herogpu:ping`). Anything else comes back
22
+ * unchanged, and a non-string as `undefined`, so callers can compare the
23
+ * result against their `herogpu:*` constants and nothing else.
24
+ */
25
+ export declare const canonicalMessageType: (type: unknown) => string | undefined;
26
+ /** True when the type was spelled the 0.5.1 way; used to answer in the same spelling. */
27
+ export declare const isLegacyMessageType: (type: unknown) => boolean;
@@ -83,7 +83,7 @@ export interface InferenceConfig {
83
83
  */
84
84
  worker: boolean;
85
85
  /**
86
- * Same-origin URL of the SDK's worker script (`dist/zerogpu-worker.js`) for
86
+ * Same-origin URL of the SDK's worker script (`dist/herogpu-worker.js`) for
87
87
  * hosts whose Content-Security-Policy forbids `blob:` workers. Absent → the
88
88
  * worker source bundled into the SDK is spawned from a blob: URL.
89
89
  */
@@ -1,40 +1,59 @@
1
1
  /**
2
- * ZeroGPU "extension kit" — service-worker consent bridge.
2
+ * herogpu "extension kit" — service-worker consent bridge.
3
3
  *
4
4
  * This is the piece that makes an end user's opt-out real. It owns the offscreen
5
5
  * document's lifecycle and refuses to create it while the user is opted out, so
6
6
  * the decision survives browser restarts rather than lasting only as long as the
7
7
  * current document.
8
8
  *
9
- * It also exposes a deliberately tiny message vocabulary to the ZeroGPU-hosted
9
+ * It also exposes a deliberately tiny message vocabulary to the herogpu-hosted
10
10
  * settings page via `chrome.runtime.onMessageExternal`, so a user can flip the
11
11
  * switch from a normal web page (the Mellowtel-style flow) without the host
12
12
  * extension needing a content script.
13
13
  *
14
- * Built as an IIFE (`dist/extension/zerogpu-background.js`) exposing
15
- * `self.ZeroGpuBackground`, NOT as an ES module: the scaffolded service worker
14
+ * Built as an IIFE (`dist/extension/herogpu-background.js`) exposing
15
+ * `self.HeroGpuBackground`, NOT as an ES module: the scaffolded service worker
16
16
  * is a classic worker, and hosts with an existing worker are told to
17
17
  * `importScripts(...)` it. Shipping ESM would force `"type": "module"` onto
18
18
  * every host extension and break their existing service-worker code.
19
+ *
20
+ * Extensions integrated with 0.5.1 or earlier load the same file as
21
+ * `zerogpu-background.js` and call it through `self.ZeroGpuBackground` with
22
+ * `...ZeroGpu...` function names. Both globals are the same object and every
23
+ * earlier name below is the same function, so that code runs unchanged.
19
24
  */
20
- import { ZeroGpuConsent } from './consent';
25
+ import { HeroGpuConsent } from './consent';
21
26
  import type { CustomParams } from '../runtime/custom-params';
22
27
  import { type ContributionState, type EligibleModel, type LocalInferenceResult, type SwitchOutcome } from '../appinference/types';
23
28
  /** The three messages the bridge answers. Nothing here can start inference,
24
29
  * read device data, or reach the model store — by design. */
30
+ export declare const HEROGPU_BRIDGE_MESSAGES: {
31
+ readonly ping: "herogpu:ping";
32
+ readonly getConsent: "herogpu:getConsent";
33
+ readonly setConsent: "herogpu:setConsent";
34
+ };
35
+ /**
36
+ * The same three messages as 0.5.1 and earlier spelled them. The bridge
37
+ * answers both spellings; the hosted settings page sends these.
38
+ * @deprecated New code sends {@link HEROGPU_BRIDGE_MESSAGES}.
39
+ */
25
40
  export declare const ZEROGPU_BRIDGE_MESSAGES: {
26
41
  readonly ping: "zerogpu:ping";
27
42
  readonly getConsent: "zerogpu:getConsent";
28
43
  readonly setConsent: "zerogpu:setConsent";
29
44
  };
30
- /** Origins allowed to talk to the extension. Must stay in step with the
31
- * `externally_connectable.matches` entry the CLI writes into manifest.json. */
45
+ /**
46
+ * Origins allowed to talk to the extension: the hosted settings page, on the
47
+ * herogpu.com site and on the zerogpu.ai site it is served from today. Must
48
+ * stay in step with the `externally_connectable.matches` entries the CLI
49
+ * writes into manifest.json.
50
+ */
32
51
  export declare const DEFAULT_ALLOWED_ORIGINS: string[];
33
52
  export interface ConsentBridgeOptions {
34
53
  /**
35
54
  * Exact origins permitted to send `onMessageExternal` messages. Checked as a
36
55
  * strict equality against `sender.origin` — never a substring or suffix test,
37
- * which `https://zerogpu.ai.attacker.com` would pass.
56
+ * which `https://herogpu.com.attacker.com` would pass.
38
57
  */
39
58
  allowedOrigins?: string[];
40
59
  /** Path to the offscreen document inside the extension. */
@@ -48,39 +67,59 @@ export interface ConsentBridgeOptions {
48
67
  * there. The consent check lives here rather than at the call sites so that
49
68
  * every path into starting the SDK is gated by construction.
50
69
  */
70
+ export declare const ensureHeroGpuOffscreen: (options?: ConsentBridgeOptions) => Promise<boolean>;
71
+ /** @deprecated Use {@link ensureHeroGpuOffscreen}. Same function, earlier name. */
51
72
  export declare const ensureZeroGpuOffscreen: (options?: ConsentBridgeOptions) => Promise<boolean>;
52
73
  /**
53
74
  * Stop the SDK: ask the offscreen document to run its ordered shutdown (close
54
75
  * the socket, flush telemetry, dispose adapters, mark a clean exit), then tear
55
76
  * the document down so nothing restarts inside it.
56
77
  */
78
+ export declare const stopHeroGpuOffscreen: (options?: ConsentBridgeOptions) => Promise<void>;
79
+ /** @deprecated Use {@link stopHeroGpuOffscreen}. Same function, earlier name. */
57
80
  export declare const stopZeroGpuOffscreen: (options?: ConsentBridgeOptions) => Promise<void>;
58
81
  /**
59
82
  * Replace the operator macros (`cust_param1`..`cust_param3`) in the running
60
83
  * offscreen SDK; `{}` clears them. Resolves false when there is no document to
61
84
  * receive them (user opted out, or not started yet). The values live as long
62
85
  * as that document — for values that must survive a restart, pass
63
- * `customParams` to `initZeroGpuOffscreen` as well.
86
+ * `customParams` to `initHeroGpuOffscreen` as well.
64
87
  */
88
+ export declare const setHeroGpuCustomParams: (customParams: CustomParams, options?: ConsentBridgeOptions) => Promise<boolean>;
89
+ /** @deprecated Use {@link setHeroGpuCustomParams}. Same function, earlier name. */
65
90
  export declare const setZeroGpuCustomParams: (customParams: CustomParams, options?: ConsentBridgeOptions) => Promise<boolean>;
66
- export interface ZeroGpuContribution {
91
+ export interface HeroGpuContribution {
67
92
  contributionState: ContributionState;
68
93
  activeModelId: string | null;
69
94
  status: string;
70
95
  /** This device's id at the registry, or null before the SDK registered. */
71
96
  deviceId: string | null;
72
97
  }
98
+ /** @deprecated Use {@link HeroGpuContribution}. */
99
+ export type ZeroGpuContribution = HeroGpuContribution;
73
100
  /** Where the SDK stands right now; `stopped` when the offscreen document is not running. */
74
- export declare const getZeroGpuContribution: (options?: ConsentBridgeOptions) => Promise<ZeroGpuContribution>;
101
+ export declare const getHeroGpuContribution: (options?: ConsentBridgeOptions) => Promise<HeroGpuContribution>;
102
+ /** @deprecated Use {@link getHeroGpuContribution}. Same function, earlier name. */
103
+ export declare const getZeroGpuContribution: (options?: ConsentBridgeOptions) => Promise<HeroGpuContribution>;
75
104
  /** Every model of the chrome-extension list, judged for this device. */
105
+ export declare const getHeroGpuEligibleModels: (options?: ConsentBridgeOptions) => Promise<EligibleModel[]>;
106
+ /** @deprecated Use {@link getHeroGpuEligibleModels}. Same function, earlier name. */
76
107
  export declare const getZeroGpuEligibleModels: (options?: ConsentBridgeOptions) => Promise<EligibleModel[]>;
77
108
  /** Switch the device to `modelId`; resolves when it contributes again (download included). */
109
+ export declare const switchHeroGpuModel: (modelId: string, options?: ConsentBridgeOptions) => Promise<SwitchOutcome>;
110
+ /** @deprecated Use {@link switchHeroGpuModel}. Same function, earlier name. */
78
111
  export declare const switchZeroGpuModel: (modelId: string, options?: ConsentBridgeOptions) => Promise<SwitchOutcome>;
79
112
  /** Run the active model on `input` (the shape of the model's inference kind). */
113
+ export declare const runHeroGpuLocal: (input: Record<string, unknown>, options?: ConsentBridgeOptions) => Promise<LocalInferenceResult>;
114
+ /** @deprecated Use {@link runHeroGpuLocal}. Same function, earlier name. */
80
115
  export declare const runZeroGpuLocal: (input: Record<string, unknown>, options?: ConsentBridgeOptions) => Promise<LocalInferenceResult>;
116
+ export declare const clearHeroGpuModelChoice: (options?: ConsentBridgeOptions) => Promise<boolean>;
117
+ /** @deprecated Use {@link clearHeroGpuModelChoice}. Same function, earlier name. */
81
118
  export declare const clearZeroGpuModelChoice: (options?: ConsentBridgeOptions) => Promise<boolean>;
119
+ export declare const forgetHeroGpuUnfitModel: (modelId: string, options?: ConsentBridgeOptions) => Promise<boolean>;
120
+ /** @deprecated Use {@link forgetHeroGpuUnfitModel}. Same function, earlier name. */
82
121
  export declare const forgetZeroGpuUnfitModel: (modelId: string, options?: ConsentBridgeOptions) => Promise<boolean>;
83
- export interface ZeroGpuEvent {
122
+ export interface HeroGpuEvent {
84
123
  event: 'activeModelChanged' | 'modelChoiceRefused' | 'degraded' | 'recovered' | 'shutdown';
85
124
  detail: {
86
125
  code?: string;
@@ -90,28 +129,38 @@ export interface ZeroGpuEvent {
90
129
  restartInMs?: number;
91
130
  };
92
131
  }
132
+ /** @deprecated Use {@link HeroGpuEvent}. */
133
+ export type ZeroGpuEvent = HeroGpuEvent;
93
134
  /**
94
135
  * Follow the SDK's host events from any extension context (the offscreen
95
136
  * document broadcasts them). Returns nothing to unsubscribe with: extension
96
137
  * listeners live as long as their context.
97
138
  */
98
- export declare const onZeroGpuEvent: (listener: (event: ZeroGpuEvent) => void) => void;
139
+ export declare const onHeroGpuEvent: (listener: (event: HeroGpuEvent) => void) => void;
140
+ /** @deprecated Use {@link onHeroGpuEvent}. Same function, earlier name. */
141
+ export declare const onZeroGpuEvent: (listener: (event: HeroGpuEvent) => void) => void;
99
142
  /** Start or stop to match the stored decision. Safe to call repeatedly. */
100
- export declare const applyZeroGpuConsent: (consent: ZeroGpuConsent, options?: ConsentBridgeOptions) => Promise<void>;
143
+ export declare const applyHeroGpuConsent: (consent: HeroGpuConsent, options?: ConsentBridgeOptions) => Promise<void>;
144
+ /** @deprecated Use {@link applyHeroGpuConsent}. Same function, earlier name. */
145
+ export declare const applyZeroGpuConsent: (consent: HeroGpuConsent, options?: ConsentBridgeOptions) => Promise<void>;
101
146
  /** Start only if the user is opted in — for `onInstalled` / `onStartup`. */
147
+ export declare const startHeroGpuIfConsented: (options?: ConsentBridgeOptions) => Promise<void>;
148
+ /** @deprecated Use {@link startHeroGpuIfConsented}. Same function, earlier name. */
102
149
  export declare const startZeroGpuIfConsented: (options?: ConsentBridgeOptions) => Promise<void>;
103
150
  /**
104
151
  * Install the bridge. Call once from the service worker:
105
152
  *
106
- * ZeroGpuBackground.registerZeroGpuConsentBridge();
153
+ * HeroGpuBackground.registerHeroGpuConsentBridge();
107
154
  *
108
155
  * Wires up: external messages from the allowlisted settings page, internal
109
156
  * messages from the extension's own popup/options, storage changes from any
110
157
  * context, and the install/startup gate.
111
158
  */
159
+ export declare const registerHeroGpuConsentBridge: (options?: ConsentBridgeOptions) => void;
160
+ /** @deprecated Use {@link registerHeroGpuConsentBridge}. Same function, earlier name. */
112
161
  export declare const registerZeroGpuConsentBridge: (options?: ConsentBridgeOptions) => void;
113
- export { ZEROGPU_CONSENT_KEY, DEFAULT_CONSENT, getZeroGpuConsent, isZeroGpuOptedIn, setZeroGpuConsent, onZeroGpuConsentChanged, buildZeroGpuSettingsUrl, ZEROGPU_SETTINGS_BASE_URL } from './consent';
114
- export type { ZeroGpuConsent, ZeroGpuConsentSource } from './consent';
162
+ export { HEROGPU_CONSENT_KEY, ZEROGPU_CONSENT_KEY, DEFAULT_CONSENT, getHeroGpuConsent, getZeroGpuConsent, isHeroGpuOptedIn, isZeroGpuOptedIn, setHeroGpuConsent, setZeroGpuConsent, onHeroGpuConsentChanged, onZeroGpuConsentChanged, buildHeroGpuSettingsUrl, buildZeroGpuSettingsUrl, HEROGPU_SETTINGS_BASE_URL, ZEROGPU_SETTINGS_BASE_URL } from './consent';
163
+ export type { HeroGpuConsent, HeroGpuConsentSource, ZeroGpuConsent, ZeroGpuConsentSource } from './consent';
115
164
  export type { CustomParams } from '../runtime/custom-params';
116
- export { LocalInferenceFailedError, ModelNotEligibleError, NotContributingError, ZeroGpuError, isZeroGpuError } from '../appinference/types';
117
- export type { ContributionState, EligibleModel, LocalInferenceResult, SwitchOutcome, SerializedZeroGpuError } from '../appinference/types';
165
+ export { LocalInferenceFailedError, ModelNotEligibleError, NotContributingError, HeroGpuError, isHeroGpuError, ZeroGpuError, isZeroGpuError } from '../appinference/types';
166
+ export type { ContributionState, EligibleModel, LocalInferenceResult, SwitchOutcome, SerializedHeroGpuError, SerializedZeroGpuError } from '../appinference/types';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ZeroGPU "extension kit" — end-user consent store.
2
+ * herogpu "extension kit" — end-user consent store.
3
3
  *
4
4
  * An end user must be able to stop the SDK on their own device, and have that
5
5
  * stick across browser restarts. That decision lives in `chrome.storage.local`
@@ -10,34 +10,83 @@
10
10
  * Enforcement is entirely client-side: opting out stops the device connecting.
11
11
  * Nothing is deregistered server-side.
12
12
  */
13
- /** Single `chrome.storage.local` key holding the whole record. */
13
+ /**
14
+ * The `chrome.storage.local` key that holds the whole record.
15
+ *
16
+ * The record is kept twice, under this key and under {@link ZEROGPU_CONSENT_KEY},
17
+ * the key releases up to 0.5.1 used. An opt-out must never be lost, and this is
18
+ * what guarantees it across versions:
19
+ *
20
+ * - **Every write stores the same record under both keys**, in one storage
21
+ * call. An extension that goes back to 0.5.1 (which knows only the earlier
22
+ * key, and treats "nothing stored" as opted in) still finds the user's
23
+ * choice, and so does host code that reads the earlier key itself.
24
+ * - **A record under only one key is honoured** as it is: an install that last
25
+ * ran 0.5.1 has only the earlier key. Nothing is moved or deleted; the next
26
+ * write stores both.
27
+ * - **When the two differ, the earlier key is the decision.** This SDK never
28
+ * writes one without the other, so a difference means a 0.5.1 build (or host
29
+ * code written for it) wrote the earlier key afterwards: that is the later
30
+ * choice. The next write brings the two back in step.
31
+ *
32
+ * To change the decision, call {@link setHeroGpuConsent}. Writing this key
33
+ * alone from host code does not override a record under the earlier key.
34
+ */
35
+ export declare const HEROGPU_CONSENT_KEY = "herogpu:consent";
36
+ /**
37
+ * The key the record was stored under until 0.5.1. It keeps being written with
38
+ * every decision (see {@link HEROGPU_CONSENT_KEY}), is the one that decides
39
+ * when the two differ, and is still watched for direct writes.
40
+ * @deprecated New code reads {@link HEROGPU_CONSENT_KEY}, or calls {@link getHeroGpuConsent}.
41
+ */
14
42
  export declare const ZEROGPU_CONSENT_KEY = "zerogpu:consent";
15
43
  /** Where a decision came from. Recorded so a surprising flip is traceable. */
16
- export type ZeroGpuConsentSource = 'default' | 'extension' | 'settings-page';
17
- export interface ZeroGpuConsent {
44
+ export type HeroGpuConsentSource = 'default' | 'extension' | 'settings-page';
45
+ /** @deprecated Use {@link HeroGpuConsentSource}. */
46
+ export type ZeroGpuConsentSource = HeroGpuConsentSource;
47
+ export interface HeroGpuConsent {
18
48
  optedIn: boolean;
19
49
  /** ISO timestamp of the decision; `null` while it is still the default. */
20
50
  updatedAt: string | null;
21
- source: ZeroGpuConsentSource;
51
+ source: HeroGpuConsentSource;
22
52
  }
53
+ /** @deprecated Use {@link HeroGpuConsent}. */
54
+ export type ZeroGpuConsent = HeroGpuConsent;
23
55
  /**
24
56
  * Opted IN until told otherwise, which preserves the behaviour every already
25
57
  * shipped extension has today: adding this module must not silently stop
26
58
  * existing installs. The hosted settings page is what turns it off.
27
59
  */
28
- export declare const DEFAULT_CONSENT: ZeroGpuConsent;
60
+ export declare const DEFAULT_CONSENT: HeroGpuConsent;
29
61
  /** Read the stored decision, or the default when nothing has been stored. */
30
- export declare const getZeroGpuConsent: () => Promise<ZeroGpuConsent>;
62
+ export declare const getHeroGpuConsent: () => Promise<HeroGpuConsent>;
63
+ /** @deprecated Use {@link getHeroGpuConsent}. Same function, earlier name. */
64
+ export declare const getZeroGpuConsent: () => Promise<HeroGpuConsent>;
31
65
  /** Convenience for the common gate: "may the SDK run right now?" */
66
+ export declare const isHeroGpuOptedIn: () => Promise<boolean>;
67
+ /** @deprecated Use {@link isHeroGpuOptedIn}. Same function, earlier name. */
32
68
  export declare const isZeroGpuOptedIn: () => Promise<boolean>;
33
- export declare const setZeroGpuConsent: (optedIn: boolean, source?: ZeroGpuConsentSource) => Promise<ZeroGpuConsent>;
69
+ export declare const setHeroGpuConsent: (optedIn: boolean, source?: HeroGpuConsentSource) => Promise<HeroGpuConsent>;
70
+ /** @deprecated Use {@link setHeroGpuConsent}. Same function, earlier name. */
71
+ export declare const setZeroGpuConsent: (optedIn: boolean, source?: HeroGpuConsentSource) => Promise<HeroGpuConsent>;
34
72
  /**
35
73
  * Subscribe to consent changes from any extension context (the hosted settings
36
74
  * page writing through the service worker, the options page, another window).
37
75
  * Returns an unsubscribe function.
38
76
  */
39
- export declare const onZeroGpuConsentChanged: (listener: (consent: ZeroGpuConsent) => void) => (() => void);
40
- /** Default host for the ZeroGPU-hosted end-user settings page. */
77
+ export declare const onHeroGpuConsentChanged: (listener: (consent: HeroGpuConsent) => void) => (() => void);
78
+ /** @deprecated Use {@link onHeroGpuConsentChanged}. Same function, earlier name. */
79
+ export declare const onZeroGpuConsentChanged: (listener: (consent: HeroGpuConsent) => void) => (() => void);
80
+ /**
81
+ * Default address of the hosted end-user settings page: the one place it is
82
+ * defined (the CLI's printed hint repeats it for people to read).
83
+ *
84
+ * The page is still served from zerogpu.ai. When it is also live at
85
+ * `https://herogpu.com/extension-settings`, that address becomes the value
86
+ * here; the bridge already accepts messages from both sites.
87
+ */
88
+ export declare const HEROGPU_SETTINGS_BASE_URL = "https://zerogpu.ai/extension-settings";
89
+ /** @deprecated Use {@link HEROGPU_SETTINGS_BASE_URL}. Same value, earlier name. */
41
90
  export declare const ZEROGPU_SETTINGS_BASE_URL = "https://zerogpu.ai/extension-settings";
42
91
  export interface SettingsUrlOptions {
43
92
  /** The extension's own id — `chrome.runtime.id` in an extension context. */
@@ -54,4 +103,6 @@ export interface SettingsUrlOptions {
54
103
  * operator key: the page only needs the extension id to address a message, and
55
104
  * keeping keys out is what lets the page stay backend-free.
56
105
  */
106
+ export declare const buildHeroGpuSettingsUrl: ({ extensionId, appName, baseUrl, debug }: SettingsUrlOptions) => string;
107
+ /** @deprecated Use {@link buildHeroGpuSettingsUrl}. Same function, earlier name. */
57
108
  export declare const buildZeroGpuSettingsUrl: ({ extensionId, appName, baseUrl, debug }: SettingsUrlOptions) => string;
@@ -1,20 +1,24 @@
1
1
  /**
2
- * ZeroGPU "extension kit" — offscreen host helper.
2
+ * herogpu "extension kit" — offscreen host helper.
3
3
  *
4
4
  * Chrome Manifest V3 forbids remotely-hosted code, so the SDK and its model
5
5
  * runtimes (transformers.js + ONNX wasm, wllama + wasm) must be vendored into the
6
6
  * extension package and loaded locally. This module does all of that wiring so an
7
7
  * extension's offscreen document needs only a single call.
8
8
  *
9
- * Vendor the runtime assets with `npx zerogpu vendor` (default into
10
- * `vendor/zerogpu/`); this bundle (`dist/extension/zerogpu-offscreen.js`) is one
9
+ * Vendor the runtime assets with `npx herogpu vendor` (default into
10
+ * `vendor/herogpu/`); this bundle (`dist/extension/herogpu-offscreen.js`) is one
11
11
  * of the vendored files and already contains the SDK itself.
12
+ *
13
+ * An extension integrated with 0.5.1 or earlier keeps its layout: the same
14
+ * bundle vendored as `vendor/zerogpu/zerogpu-offscreen.js`, its assets next to
15
+ * it, and `initZeroGpuOffscreen` and the `zerogpu:*` messages working as before.
12
16
  */
13
- import { getZeroGpuSdk, setCustomParams } from '../public-api';
17
+ import { getHeroGpuSdk, getZeroGpuSdk, setCustomParams } from '../public-api';
14
18
  import { CustomParams } from '../runtime/custom-params';
15
19
  import { ConfigOverrides } from '../config/env';
16
20
  export interface OffscreenInitOptions {
17
- /** SDK operator key (from the ZeroGPU dashboard). */
21
+ /** SDK operator key (from the herogpu dashboard). */
18
22
  edgeOperatorKey?: string;
19
23
  /** Optional stable per-user id; the SDK generates one if omitted. */
20
24
  appUserId?: string;
@@ -22,18 +26,19 @@ export interface OffscreenInitOptions {
22
26
  deviceId?: string;
23
27
  /**
24
28
  * Override the orchestrator base URL. Defaults to the URL baked into the
25
- * published build (production). Set this (e.g. https://dev.devices.zerogpu.ai)
29
+ * published build (production). Set this (e.g. https://dev-devices.herogpu.com)
26
30
  * to test against another environment without rebuilding.
27
31
  */
28
32
  orchestratorBaseUrl?: string;
29
33
  /**
30
- * Where the vendored runtime assets live. Defaults to
31
- * `chrome.runtime.getURL('vendor/zerogpu/')`.
34
+ * Where the vendored runtime assets live. Defaults to the folder the CLI
35
+ * vendored them into: `chrome.runtime.getURL('vendor/herogpu/')`, or
36
+ * `vendor/zerogpu/` in an extension that keeps the layout of 0.5.1.
32
37
  */
33
38
  assetsBaseUrl?: string;
34
39
  /**
35
- * URL of the ZeroGPU-hosted runner page that *executes* `tracking_script` ad
36
- * tags (see tag-runner.html, served from ZeroGPU's own https origin under a
40
+ * URL of the herogpu-hosted runner page that *executes* `tracking_script` ad
41
+ * tags (see tag-runner.html, served from herogpu's own https origin under a
37
42
  * permissive CSP). Defaults to the production runner. The offscreen document
38
43
  * frames it — no manifest change or file is needed in the host extension. Pass
39
44
  * `false` to disable execution and always fall back to the request beacon.
@@ -43,7 +48,7 @@ export interface OffscreenInitOptions {
43
48
  enableConsoleLogs?: boolean;
44
49
  /**
45
50
  * Run model loading and inference in the SDK's inference worker (the
46
- * vendored `zerogpu-worker.js`) rather than on the offscreen document's own
51
+ * vendored `herogpu-worker.js`) rather than on the offscreen document's own
47
52
  * thread. Default true; the SDK falls back to the document's thread by
48
53
  * itself if the worker cannot start. Set false to force that mode.
49
54
  */
@@ -51,10 +56,10 @@ export interface OffscreenInitOptions {
51
56
  /**
52
57
  * Operator macros (`cust_param1`..`cust_param3`). Values set here survive the
53
58
  * document being recreated; values sent later with
54
- * `zerogpu:setCustomParams` last only as long as this document.
59
+ * `herogpu:setCustomParams` last only as long as this document.
55
60
  */
56
61
  customParams?: CustomParams;
57
- /** This extension's ZeroGPU app ID, from the ZeroGPU dashboard. */
62
+ /** This extension's herogpu app ID, from the herogpu dashboard. */
58
63
  appId?: string;
59
64
  appName?: string;
60
65
  /** Defaults to the extension ID (`chrome.runtime.id`). */
@@ -62,16 +67,43 @@ export interface OffscreenInitOptions {
62
67
  /** Advanced: deep config overrides merged last. */
63
68
  overrides?: ConfigOverrides;
64
69
  }
70
+ export type VendoredLayoutName = 'herogpu' | 'zerogpu';
71
+ /**
72
+ * Which layout this bundle was vendored in, read off its own file name: the
73
+ * CLI writes it as `herogpu-offscreen.js` or `zerogpu-offscreen.js` next to
74
+ * the assets. Null when the helper was bundled into the host's own file, where
75
+ * the name says nothing.
76
+ */
77
+ export declare const vendoredLayoutFromModuleUrl: (moduleUrl: string | undefined) => VendoredLayoutName | null;
65
78
  /**
66
79
  * Point the SDK at the vendored model runtimes (so it never reaches the CDN)
67
- * and initialize the ZeroGPU SDK. Safe to call more than once; the SDK ignores
80
+ * and initialize the herogpu SDK. Safe to call more than once; the SDK ignores
68
81
  * repeated init.
69
82
  */
83
+ export declare const initHeroGpuOffscreen: (options?: OffscreenInitOptions) => Promise<void>;
84
+ /** @deprecated Use {@link initHeroGpuOffscreen}. Same function, earlier name. */
70
85
  export declare const initZeroGpuOffscreen: (options?: OffscreenInitOptions) => Promise<void>;
71
- export { setCustomParams, getZeroGpuSdk };
86
+ export { setCustomParams, getHeroGpuSdk, getZeroGpuSdk };
72
87
  export type { CustomParams };
73
- export type { ZeroGpuSdkHandle } from '../public-api';
74
- export type { ContributionState, EligibleModel, LocalInferenceResult, SwitchOutcome, SerializedZeroGpuError } from '../appinference/types';
88
+ export type { HeroGpuSdkHandle, ZeroGpuSdkHandle } from '../public-api';
89
+ export type { ContributionState, EligibleModel, LocalInferenceResult, SwitchOutcome, SerializedHeroGpuError, SerializedZeroGpuError } from '../appinference/types';
90
+ export declare const HEROGPU_OFFSCREEN_MESSAGES: {
91
+ readonly forceInit: "herogpu:forceInit";
92
+ readonly getStatus: "herogpu:getStatus";
93
+ readonly disable: "herogpu:disable";
94
+ readonly setCustomParams: "herogpu:setCustomParams";
95
+ readonly getContribution: "herogpu:getContribution";
96
+ readonly eligibleModels: "herogpu:eligibleModels";
97
+ readonly switchModel: "herogpu:switchModel";
98
+ readonly runLocal: "herogpu:runLocal";
99
+ readonly clearModelChoice: "herogpu:clearModelChoice";
100
+ readonly forgetUnfitModel: "herogpu:forgetUnfitModel";
101
+ };
102
+ /**
103
+ * The same messages as 0.5.1 and earlier spelled them. The offscreen document
104
+ * answers both spellings; a message is one request and gets one answer.
105
+ * @deprecated New code sends {@link HEROGPU_OFFSCREEN_MESSAGES}.
106
+ */
75
107
  export declare const ZEROGPU_OFFSCREEN_MESSAGES: {
76
108
  readonly forceInit: "zerogpu:forceInit";
77
109
  readonly getStatus: "zerogpu:getStatus";
@@ -86,11 +118,16 @@ export declare const ZEROGPU_OFFSCREEN_MESSAGES: {
86
118
  };
87
119
  /**
88
120
  * Host events, broadcast to every extension context as
89
- * `{ type: 'zerogpu:event', event, detail }` so a popup or the service worker
121
+ * `{ type: 'herogpu:event', event, detail }` so a popup or the service worker
90
122
  * can follow the SDK without polling. Best effort: no receiver is not an error.
123
+ *
124
+ * Each event is also broadcast as `{ type: 'zerogpu:event', … }` for listeners
125
+ * written against 0.5.1. Listen for one of the two types, not both.
91
126
  */
92
- export declare const ZEROGPU_EVENT_MESSAGE = "zerogpu:event";
93
- export interface ZeroGpuOffscreenState {
127
+ export declare const HEROGPU_EVENT_MESSAGE: "herogpu:event";
128
+ /** @deprecated New code listens for {@link HEROGPU_EVENT_MESSAGE}. */
129
+ export declare const ZEROGPU_EVENT_MESSAGE: "zerogpu:event";
130
+ export interface HeroGpuOffscreenState {
94
131
  status: 'idle' | 'initializing' | 'running' | 'error';
95
132
  initialized: boolean;
96
133
  lastAttemptAt: string | null;
@@ -99,11 +136,15 @@ export interface ZeroGpuOffscreenState {
99
136
  lastErrorMessage: string;
100
137
  orchestratorBaseUrl?: string;
101
138
  }
139
+ /** @deprecated Use {@link HeroGpuOffscreenState}. */
140
+ export type ZeroGpuOffscreenState = HeroGpuOffscreenState;
102
141
  /**
103
142
  * Wire the offscreen document to the standard popup/background protocol
104
- * (`initZeroGpuOffscreen` does this itself; calling it again is a no-op).
105
- * Returns the live state object (also queryable via zerogpu:getStatus).
143
+ * (`initHeroGpuOffscreen` does this itself; calling it again is a no-op).
144
+ * Returns the live state object (also queryable via herogpu:getStatus).
106
145
  */
107
- export declare const registerZeroGpuOffscreenMessaging: (options?: OffscreenInitOptions) => ZeroGpuOffscreenState;
146
+ export declare const registerHeroGpuOffscreenMessaging: (options?: OffscreenInitOptions) => HeroGpuOffscreenState;
147
+ /** @deprecated Use {@link registerHeroGpuOffscreenMessaging}. Same function, earlier name. */
148
+ export declare const registerZeroGpuOffscreenMessaging: (options?: OffscreenInitOptions) => HeroGpuOffscreenState;
108
149
  /** Test-only: forget the registered listener state (a new chrome stub gets a new listener). */
109
150
  export declare const __resetOffscreenMessaging: () => void;
@@ -1,14 +1,25 @@
1
1
  /** Marks an element as the settings entry point. */
2
+ export declare const HEROGPU_SETTINGS_ATTRIBUTE = "data-herogpu-settings";
3
+ /**
4
+ * The marker 0.5.1 and earlier documented. Still wired.
5
+ * @deprecated New markup uses {@link HEROGPU_SETTINGS_ATTRIBUTE}.
6
+ */
2
7
  export declare const ZEROGPU_SETTINGS_ATTRIBUTE = "data-zerogpu-settings";
3
8
  /**
4
9
  * Build the settings URL for this extension. Per-element overrides are read from
5
- * `data-zerogpu-app-name`, `data-zerogpu-base-url` and `data-zerogpu-debug`.
10
+ * `data-herogpu-app-name`, `data-herogpu-base-url` and `data-herogpu-debug`,
11
+ * and from the `data-zerogpu-*` attributes of the same names where the
12
+ * herogpu one is absent.
6
13
  * Returns null outside an extension page, where there is no id to address.
7
14
  */
15
+ export declare const resolveHeroGpuSettingsUrl: (element?: Element | null) => string | null;
16
+ /** @deprecated Use {@link resolveHeroGpuSettingsUrl}. Same function, earlier name. */
8
17
  export declare const resolveZeroGpuSettingsUrl: (element?: Element | null) => string | null;
9
18
  /**
10
19
  * Wire every marked element under `root`. An anchor gets a real href, so it can
11
20
  * be middle-clicked or copied; anything else gets a click handler. Returns how
12
21
  * many were wired, and is safe to call again after rendering more markup.
13
22
  */
23
+ export declare const applyHeroGpuSettingsLinks: (root?: ParentNode) => number;
24
+ /** @deprecated Use {@link applyHeroGpuSettingsLinks}. Same function, earlier name. */
14
25
  export declare const applyZeroGpuSettingsLinks: (root?: ParentNode) => number;
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Web pages import transformers.js (and, through it, the ONNX Runtime wasm)
5
5
  * from the CDN. A Chrome MV3 offscreen document may not load remote code, so
6
- * it points everything at the files `npx zerogpu vendor` copied into the
6
+ * it points everything at the files `npx herogpu vendor` copied into the
7
7
  * extension. Whatever the surface configures here is handed to the inference
8
8
  * worker at boot, so both threads resolve the identical files.
9
9
  */
@@ -4,7 +4,7 @@ import { WorkerFramework } from './worker-protocol';
4
4
  * Worker-side host: answers the main thread's protocol by loading executors
5
5
  * through the same loaders the main thread would use, and relays this
6
6
  * realm's log lines back over the channel (the page's logger is the single
7
- * console sink). Runs inside `dist/zerogpu-worker.js` (see worker-entry.ts).
7
+ * console sink). Runs inside `dist/herogpu-worker.js` (see worker-entry.ts).
8
8
  */
9
9
  /** The slice of DedicatedWorkerGlobalScope the host needs (fakeable in tests). */
10
10
  export interface WorkerScopeLike {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ZeroGPU SDK loader (bootstrap stub).
2
+ * herogpu SDK loader (bootstrap stub).
3
3
  *
4
4
  * This is the tiny, stable entry point that host apps embed *once* and never
5
5
  * change. It resolves the current core bundle from a short-TTL `manifest.json`
@@ -13,6 +13,14 @@
13
13
  * - "latest" flips the instant the manifest points at a new hash.
14
14
  *
15
15
  * The loader has no runtime imports — it must stay self-contained and minifiable.
16
+ *
17
+ * Names: the SDK's globals are `HeroGpuBrowserSdk` (the API) and `HeroGpuSdk`
18
+ * (the queueing stub this file installs). Pages written against 0.5.1 use
19
+ * `ZeroGpuBrowserSdk` / `ZeroGpuSdk` and `initZeroGpuSdk` / `getZeroGpuSdk`;
20
+ * every one of those keeps working and is the same object under another name.
21
+ * A loader and a core bundle of different releases also work together, in
22
+ * either combination, because a manifest can be pointed back at an older
23
+ * bundle and a page can hold an older copy of this file.
16
24
  */
17
25
  /**
18
26
  * The SDK's own window globals, as the loader sees them before the core bundle
@@ -20,9 +28,11 @@
20
28
  * arbitrary calls, so the value type stays callable rather than `unknown`.
21
29
  */
22
30
  type LoaderApiMethod = (...args: unknown[]) => unknown;
23
- interface ZeroGpuGlobal {
31
+ interface SdkGlobal {
32
+ getHeroGpuSdk?: LoaderApiMethod;
24
33
  getZeroGpuSdk?: LoaderApiMethod;
25
34
  ready?: Promise<void>;
35
+ initHeroGpuSdk?: LoaderApiMethod;
26
36
  initZeroGpuSdk?: LoaderApiMethod;
27
37
  [method: string]: LoaderApiMethod | Promise<void> | undefined;
28
38
  }
@@ -30,9 +40,11 @@ interface ZeroGpuGlobal {
30
40
  export interface LoaderEnv {
31
41
  script: HTMLScriptElement;
32
42
  documentRef: Document;
33
- windowRef: Record<string, ZeroGpuGlobal | undefined>;
43
+ windowRef: Record<string, SdkGlobal | undefined>;
34
44
  fetchImpl: typeof fetch;
35
45
  baseUri: string;
36
46
  }
47
+ export declare const bootHeroGpuLoader: (env: LoaderEnv) => Promise<void>;
48
+ /** @deprecated Use {@link bootHeroGpuLoader}. Same function, earlier name. */
37
49
  export declare const bootZeroGpuLoader: (env: LoaderEnv) => Promise<void>;
38
50
  export {};