@zerogpu/browser-extension-sdk 0.2.1 → 0.2.2

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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const SDK_VERSION = typeof "0.2.1+8a18008" === 'string' && "0.2.1+8a18008".length > 0
4
- ? "0.2.1+8a18008"
3
+ const SDK_VERSION = typeof "0.2.2+0a17606" === 'string' && "0.2.2+0a17606".length > 0
4
+ ? "0.2.2+0a17606"
5
5
  : '0.0.0-dev';
6
6
 
7
7
  const ORCHESTRATOR_BASE_URL = typeof "https://devices.zerogpu.ai" === 'string' && "https://devices.zerogpu.ai".length > 0
@@ -23,7 +23,6 @@ const DEFAULT_CONFIG = {
23
23
  telemetry: {
24
24
  enableConsoleLogs: false,
25
25
  locationData: false,
26
- cameraData: false,
27
26
  events: true
28
27
  }
29
28
  };
@@ -41,7 +40,8 @@ const resolveConfig = (overrides) => {
41
40
  telemetry: {
42
41
  enableConsoleLogs: asBoolean(merged.telemetry?.enableConsoleLogs, base.telemetry.enableConsoleLogs),
43
42
  locationData: asBoolean(merged.telemetry?.locationData, base.telemetry.locationData),
44
- cameraData: asBoolean(merged.telemetry?.cameraData, base.telemetry.cameraData),
43
+ // `cameraData` is deliberately dropped: the camera path no longer exists
44
+ // (ZGA-538); a host that still passes the flag is silently ignored.
45
45
  events: asBoolean(merged.telemetry?.events, base.telemetry.events)
46
46
  }
47
47
  };
@@ -70,6 +70,152 @@ const deepMerge = (target, source) => {
70
70
  const asNonEmptyString = (value, fallback) => typeof value === 'string' && value.length > 0 ? value : fallback;
71
71
  const asBoolean = (value, fallback) => typeof value === 'boolean' ? value : fallback;
72
72
 
73
+ const MESSAGE_MAX = 200;
74
+ const ID_MAX = 256;
75
+ const ARRAY_MAX = 20;
76
+ /** Keys that must never print their value, whatever it is. */
77
+ const CREDENTIAL_KEY_PATTERN = /(session|token|secret|password|credential|cookie|authorization|api[-_]?key|operator)/i;
78
+ /** Keys whose string value is a URL: keep origin + path, drop query/hash. */
79
+ const URL_KEYS = new Set([
80
+ 'url',
81
+ 'wsurl',
82
+ 'baseurl',
83
+ 'modelurl',
84
+ 'modelrepourl',
85
+ 'runtimeurl',
86
+ 'requesturl',
87
+ 'endpoint',
88
+ 'endpointurl',
89
+ 'manifesturl',
90
+ 'bundleurl',
91
+ 'orchestrator'
92
+ ]);
93
+ /** Keys carrying an error/diagnostic summary: kept, capped. */
94
+ const MESSAGE_KEYS = new Set(['message', 'errormessage', 'error', 'reason']);
95
+ /** Identifier / enum-like keys whose string value is safe to print (capped). */
96
+ const SAFE_STRING_KEYS = new Set([
97
+ 'requestid',
98
+ 'modelid',
99
+ 'modelversion',
100
+ 'modelrepoid',
101
+ 'modeltype',
102
+ 'deviceid',
103
+ 'sdkversion',
104
+ 'tasktype',
105
+ 'framework',
106
+ 'inferenceframework',
107
+ 'quantization',
108
+ 'code',
109
+ 'status',
110
+ 'type',
111
+ 'phase',
112
+ 'flow',
113
+ 'event',
114
+ 'source',
115
+ 'name',
116
+ 'platform',
117
+ 'devicetype',
118
+ 'gpurenderer',
119
+ 'mime',
120
+ 'mode',
121
+ 'file',
122
+ 'files',
123
+ 'requiredfiles',
124
+ 'models',
125
+ 'cachedmodels',
126
+ 'keys',
127
+ 'changed',
128
+ 'cachedmodelid',
129
+ 'assignedmodelid',
130
+ 'primarymodelid'
131
+ ]);
132
+ const cap = (value, max) => value.length > max ? `${value.slice(0, max)}…` : value;
133
+ /** One-line, capped error summary — diagnostics survive, payloads cannot ride along uncapped. */
134
+ const summarizeError = (error) => {
135
+ if (error instanceof Error) {
136
+ return cap(`${error.name}: ${error.message}`, MESSAGE_MAX);
137
+ }
138
+ if (typeof error === 'string')
139
+ return cap(error, MESSAGE_MAX);
140
+ if (error === null || error === undefined)
141
+ return String(error);
142
+ if (typeof error === 'object')
143
+ return `[${error.constructor?.name ?? 'object'}]`;
144
+ return cap(String(error), MESSAGE_MAX);
145
+ };
146
+ const stripUrl = (value) => {
147
+ try {
148
+ const url = new URL(value);
149
+ return `${url.origin}${url.pathname}`;
150
+ }
151
+ catch {
152
+ return '[invalid-url]';
153
+ }
154
+ };
155
+ const describeOpaque = (value) => {
156
+ if (Array.isArray(value))
157
+ return `[array:${value.length}]`;
158
+ if (value && typeof value === 'object')
159
+ return `[object:${Object.keys(value).length} keys]`;
160
+ return `[${typeof value}]`;
161
+ };
162
+ const sanitizeString = (key, value) => {
163
+ const normalizedKey = key.toLowerCase();
164
+ if (URL_KEYS.has(normalizedKey))
165
+ return stripUrl(value);
166
+ if (MESSAGE_KEYS.has(normalizedKey))
167
+ return cap(value, MESSAGE_MAX);
168
+ if (SAFE_STRING_KEYS.has(normalizedKey))
169
+ return cap(value, ID_MAX);
170
+ return `[string:${value.length}]`;
171
+ };
172
+ const sanitizeValue = (key, value) => {
173
+ if (CREDENTIAL_KEY_PATTERN.test(key))
174
+ return '[redacted]';
175
+ if (value === null || value === undefined)
176
+ return value;
177
+ if (typeof value === 'boolean')
178
+ return value;
179
+ if (typeof value === 'number')
180
+ return Number.isFinite(value) ? value : String(value);
181
+ if (typeof value === 'string')
182
+ return sanitizeString(key, value);
183
+ if (value instanceof Error)
184
+ return summarizeError(value);
185
+ return describeOpaque(value);
186
+ };
187
+ /**
188
+ * The runtime redaction gate. Whatever a caller manages to pass (the types
189
+ * merely guide), nothing but ids, enums, counts, sizes, durations and capped
190
+ * error summaries comes out the other side.
191
+ */
192
+ const sanitizeLogFields = (fields) => {
193
+ if (fields instanceof Error) {
194
+ return { error: summarizeError(fields) };
195
+ }
196
+ if (!fields || typeof fields !== 'object' || Array.isArray(fields)) {
197
+ return { detail: sanitizeValue('detail', fields) };
198
+ }
199
+ const sanitized = {};
200
+ for (const [key, value] of Object.entries(fields)) {
201
+ if (Array.isArray(value)) {
202
+ if (CREDENTIAL_KEY_PATTERN.test(key)) {
203
+ sanitized[key] = '[redacted]';
204
+ }
205
+ else if (value.every((item) => item === null || typeof item !== 'object')) {
206
+ sanitized[key] = value.slice(0, ARRAY_MAX).map((item) => sanitizeValue(key, item));
207
+ }
208
+ else {
209
+ sanitized[key] = describeOpaque(value);
210
+ }
211
+ continue;
212
+ }
213
+ sanitized[key] = sanitizeValue(key, value);
214
+ }
215
+ return sanitized;
216
+ };
217
+ const sanitizeMessage = (message) => typeof message === 'string' ? cap(message, MESSAGE_MAX) : '[invalid log message]';
218
+ /* eslint-disable no-console -- sole audited console sink; everything printed here has passed sanitizeLogFields. */
73
219
  class Logger {
74
220
  constructor(config) {
75
221
  this.enabled = config.enableConsoleLogs;
@@ -80,21 +226,28 @@ class Logger {
80
226
  isEnabled() {
81
227
  return this.enabled;
82
228
  }
83
- debug(...args) {
84
- if (this.enabled)
85
- console.debug('[ZeroGPU]', ...args);
229
+ emit(sink, message, fields) {
230
+ if (!this.enabled)
231
+ return;
232
+ if (fields === undefined) {
233
+ sink('[ZeroGPU]', sanitizeMessage(message));
234
+ }
235
+ else {
236
+ sink('[ZeroGPU]', sanitizeMessage(message), sanitizeLogFields(fields));
237
+ }
238
+ }
239
+ debug(message, fields) {
240
+ this.emit(console.debug, message, fields);
86
241
  }
87
- info(...args) {
88
- if (this.enabled)
89
- console.debug('[ZeroGPU]', ...args);
242
+ info(message, fields) {
243
+ // Historic behavior: info also goes to console.debug to keep host consoles quiet.
244
+ this.emit(console.debug, message, fields);
90
245
  }
91
- warn(...args) {
92
- if (this.enabled)
93
- console.warn('[ZeroGPU]', ...args);
246
+ warn(message, fields) {
247
+ this.emit(console.warn, message, fields);
94
248
  }
95
- error(...args) {
96
- if (this.enabled)
97
- console.error('[ZeroGPU]', ...args);
249
+ error(message, fields) {
250
+ this.emit(console.error, message, fields);
98
251
  }
99
252
  }
100
253
  let singleton$1 = null;
@@ -107,7 +260,6 @@ const getLogger = () => {
107
260
  singleton$1 = new Logger({
108
261
  enableConsoleLogs: false,
109
262
  locationData: false,
110
- cameraData: false,
111
263
  events: true
112
264
  });
113
265
  }
@@ -342,77 +494,8 @@ const collectDeviceInfo = async (config, appUserId, sdkDeviceId) => {
342
494
  // Optional permissions
343
495
  location: config.locationData ? await getLocation() : undefined
344
496
  };
345
- if (config.cameraData) {
346
- baseInfo.camera = await captureCameraSample();
347
- }
348
497
  return baseInfo;
349
498
  };
350
- const captureCameraSample = async () => {
351
- if (!navigator.mediaDevices?.getUserMedia) {
352
- return { permission: 'error', error: 'mediaDevices unavailable' };
353
- }
354
- let stream = null;
355
- let video = null;
356
- let canvas = null;
357
- try {
358
- stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: 'user' } });
359
- video = document.createElement('video');
360
- video.setAttribute('playsinline', 'true');
361
- video.playsInline = true;
362
- video.muted = true;
363
- video.style.cssText = 'position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0';
364
- document.body.appendChild(video);
365
- video.srcObject = stream;
366
- await video.play().catch(() => { });
367
- await new Promise((resolve) => {
368
- const ready = () => resolve();
369
- video.onloadeddata = ready;
370
- video.oncanplay = ready;
371
- setTimeout(ready, 800);
372
- });
373
- const vw = video.videoWidth || 640;
374
- const vh = video.videoHeight || 480;
375
- canvas = document.createElement('canvas');
376
- canvas.width = vw;
377
- canvas.height = vh;
378
- const ctx = canvas.getContext('2d');
379
- ctx?.drawImage(video, 0, 0, vw, vh);
380
- const mime = 'image/jpeg';
381
- const dataUrl = canvas.toDataURL(mime, 0.85);
382
- const bytes = Math.floor((dataUrl.length * 3) / 4);
383
- return {
384
- permission: 'granted',
385
- width: vw,
386
- height: vh,
387
- bytes,
388
- mime,
389
- timestamp: Date.now(),
390
- previewDataUrl: dataUrl
391
- };
392
- }
393
- catch (err) {
394
- const errorObj = err;
395
- return {
396
- permission: errorObj?.name === 'NotAllowedError' ? 'denied' : 'error',
397
- error: errorObj?.message || String(err)
398
- };
399
- }
400
- finally {
401
- try {
402
- stream?.getTracks().forEach((track) => track.stop());
403
- }
404
- catch {
405
- // Best-effort cleanup.
406
- }
407
- try {
408
- video?.remove();
409
- }
410
- catch {
411
- // Best-effort cleanup.
412
- }
413
- canvas = null;
414
- }
415
- };
416
499
 
417
500
  class RegisterError extends Error {
418
501
  constructor(status, body) {
@@ -453,14 +536,6 @@ const detectSoftRefusal = (payload) => {
453
536
  }
454
537
  return null;
455
538
  };
456
- const escapeShellSingleQuotes = (value) => value.replace(/'/g, "'\\''");
457
- const buildCurl = (url, body, headers) => {
458
- const payload = escapeShellSingleQuotes(JSON.stringify(body));
459
- const headerFlags = Object.entries(headers)
460
- .map(([key, value]) => `-H '${escapeShellSingleQuotes(`${key}: ${value}`)}'`)
461
- .join(' ');
462
- return `curl -X POST '${url}' ${headerFlags} -d '${payload}'`;
463
- };
464
539
  const registerDevice = async (config, payload, auth) => {
465
540
  const logger = getLogger();
466
541
  const orchestrator = config?.orchestrator;
@@ -477,20 +552,31 @@ const registerDevice = async (config, payload, auth) => {
477
552
  headers,
478
553
  body: JSON.stringify(payload)
479
554
  });
480
- logger.info('Register request sent:', { url, status: response.status });
481
- getLogger().debug('Register API blueprint (curl):', buildCurl(url, payload, headers));
555
+ // ZGA-538: never log the request body or headers — the payload carries the
556
+ // full device profile and the x-edge-operator-key credential.
557
+ logger.info('Register request sent', {
558
+ url,
559
+ status: response.status,
560
+ bodyBytes: JSON.stringify(payload).length
561
+ });
482
562
  const registerResponseBody = await parseRegisterResponseBody(response);
483
563
  const refusalReason = detectSoftRefusal(registerResponseBody);
484
564
  if (!response.ok && !refusalReason) {
485
565
  const text = typeof registerResponseBody === 'string'
486
566
  ? registerResponseBody
487
567
  : JSON.stringify(registerResponseBody ?? '');
488
- logger.error('Register request failed:', { status: response.status, text });
568
+ logger.error('Register request failed', { status: response.status, message: text });
489
569
  throw new RegisterError(response.status, text);
490
570
  }
491
571
  if (registerResponseBody && typeof registerResponseBody === 'object' && !refusalReason) {
492
572
  const registerResponse = registerResponseBody;
493
- logger.info('Register response parsed:', registerResponse);
573
+ // Shape only — the body carries the session key and the model sample text.
574
+ logger.info('Register response parsed', {
575
+ deviceId: registerResponse.deviceId,
576
+ hasWsUrl: Boolean(registerResponse.wsUrl),
577
+ models: registerResponse.slmConfig?.length ?? 0,
578
+ ttlSeconds: registerResponse.ttlSeconds
579
+ });
494
580
  return registerResponse;
495
581
  }
496
582
  if (refusalReason) {
@@ -524,23 +610,35 @@ const registerDevice = async (config, payload, auth) => {
524
610
  throw new RegisterError(response.status, 'Register response body is not valid JSON');
525
611
  };
526
612
 
613
+ /**
614
+ * Frame logging is metadata-only (ZGA-538): message type, request ids, byte
615
+ * size — never the frame body. Task frames carry customer input/output and the
616
+ * hello carries the session key, so a content dump here would hand both to any
617
+ * crash reporter watching the host console.
618
+ */
619
+ const frameType = (frame) => {
620
+ if (frame && typeof frame === 'object') {
621
+ const candidate = frame.type;
622
+ if (typeof candidate === 'string' && candidate.length > 0)
623
+ return candidate;
624
+ if (Array.isArray(frame.requests))
625
+ return 'task_batch';
626
+ }
627
+ return 'unknown';
628
+ };
527
629
  class WebSocketClient {
528
630
  constructor(options) {
529
631
  this.options = options;
530
632
  this.logger = getLogger();
531
633
  this.pingTimer = null;
532
- this.consoleWithVerbose = console;
533
634
  this.handleOpen = () => {
534
635
  this.logger.info('WebSocket connection opened');
535
636
  this.options.onOpen?.();
536
- this.logger.debug('Sending hello message:', this.options.hello);
537
- this.logger.info('[WS OUT] hello:', JSON.stringify(this.options.hello));
538
637
  this.send(this.options.hello);
539
638
  // Keepalive starts only once the hello is on the wire.
540
639
  this.startPing();
541
640
  if (this.options.ack) {
542
641
  // Send readiness/error ack immediately after hello.
543
- this.logger.info('[WS OUT] hello_ack:', JSON.stringify(this.options.ack));
544
642
  this.send(this.options.ack);
545
643
  if (this.options.closeAfterAck) {
546
644
  // Optionally close after ack (used for error cases).
@@ -562,24 +660,23 @@ class WebSocketClient {
562
660
  if (trimmed === 'pong')
563
661
  return;
564
662
  if (trimmed.length > 0 && trimmed[0] !== '{' && trimmed[0] !== '[') {
565
- this.logger.debug('[WS IN] ignoring non-JSON frame:', trimmed.slice(0, 64));
663
+ this.logger.debug('[WS IN] ignoring non-JSON frame', { bytes: trimmed.length });
566
664
  return;
567
665
  }
568
666
  }
569
667
  try {
570
668
  const data = JSON.parse(raw);
571
- if (this.logger.isEnabled()) {
572
- if (typeof this.consoleWithVerbose.verbose === 'function') {
573
- this.consoleWithVerbose.verbose('[ZeroGPU]', '[WS IN] payload:', data);
574
- }
575
- else {
576
- console.debug('[ZeroGPU]', '[WS IN] payload:', data);
577
- }
578
- }
669
+ this.logger.debug('[WS IN] frame', {
670
+ type: frameType(data),
671
+ requests: Array.isArray(data.requests)
672
+ ? data.requests.length
673
+ : undefined,
674
+ bytes: typeof raw === 'string' ? raw.length : undefined
675
+ });
579
676
  this.options.onMessage(data);
580
677
  }
581
678
  catch (error) {
582
- this.logger.error('Failed to parse WS message', error);
679
+ this.logger.error('Failed to parse WS message', { error: summarizeError(error) });
583
680
  }
584
681
  };
585
682
  this.handleError = (event) => {
@@ -604,7 +701,7 @@ class WebSocketClient {
604
701
  this.options.onClose(event);
605
702
  };
606
703
  this.pingIntervalMs = normalizePingIntervalMs(options.pingIntervalSeconds);
607
- this.logger.info('Creating WebSocket connection to:', options.url);
704
+ this.logger.info('Creating WebSocket connection', { url: options.url });
608
705
  this.socket = new WebSocket(options.url);
609
706
  this.socket.onopen = this.handleOpen;
610
707
  this.socket.onmessage = this.handleMessage;
@@ -638,7 +735,7 @@ class WebSocketClient {
638
735
  this.socket.send('ping');
639
736
  }
640
737
  catch (error) {
641
- this.logger.debug('Keepalive ping failed', error);
738
+ this.logger.debug('Keepalive ping failed', { error: summarizeError(error) });
642
739
  }
643
740
  try {
644
741
  this.options.onPingTick?.();
@@ -658,8 +755,13 @@ class WebSocketClient {
658
755
  return (this.socket.readyState === WebSocket.OPEN || this.socket.readyState === WebSocket.CONNECTING);
659
756
  }
660
757
  send(payload) {
661
- this.logger.debug('[WS OUT] payload:', JSON.stringify(payload));
662
- this.socket.send(JSON.stringify(payload));
758
+ const json = JSON.stringify(payload);
759
+ this.logger.debug('[WS OUT] frame', {
760
+ type: frameType(payload),
761
+ requests: Array.isArray(payload.requests) ? payload.requests.length : undefined,
762
+ bytes: json.length
763
+ });
764
+ this.socket.send(json);
663
765
  }
664
766
  close(code, reason) {
665
767
  this.stopPing();
@@ -1236,8 +1338,7 @@ const resolveWasmSettings = (probe = probeWasmEnvironment()) => {
1236
1338
  * Host-facing lifecycle status and events. The SDK is a guest in someone
1237
1339
  * else's app: this module is how the host observes guardrail state (degraded /
1238
1340
  * recovered / shutdown) without the SDK ever throwing into it. Script-tag
1239
- * consumers get the same signals as `zerogpu:*` window events, matching the
1240
- * existing `zerogpu:cameraPreview` pattern.
1341
+ * consumers get the same signals as `zerogpu:*` window events.
1241
1342
  */
1242
1343
  let lifecycleStatus = 'starting';
1243
1344
  const listeners = {
@@ -1820,9 +1921,12 @@ const fireTrackingPixel = (url, timeoutMs = DEFAULT_TIMEOUT_MS) => {
1820
1921
  *
1821
1922
  * Progressive:
1822
1923
  * 1. If a runner URL is configured, run the tag in the framed runner.
1823
- * 2. Otherwise fall back to a credentialed request beacon so the impression at
1824
- * least reaches the ad server with the user's real IP/UA/cookies (the tag's
1825
- * JS does not run).
1924
+ * 2. Otherwise, on an ordinary web page or WebView (including a Telegram Mini
1925
+ * App) with no restrictive `script-src` CSP, inject a real `<script>`
1926
+ * element so the tag executes directly in the page.
1927
+ * 3. Failing both (no DOM, or a CSP that blocks the injected script), fall back
1928
+ * to a credentialed request beacon so the impression at least reaches the ad
1929
+ * server with the user's real IP/UA/cookies (the tag's JS does not run).
1826
1930
  *
1827
1931
  * Never rejects: a tag is best-effort and must not affect inference.
1828
1932
  */
@@ -1914,18 +2018,107 @@ const fireBeacon = (url, timeoutMs) => {
1914
2018
  });
1915
2019
  };
1916
2020
  /**
1917
- * Fire a JavaScript tracking tag. Runs it in the framed runner when one is
1918
- * available; otherwise fires the request as a beacon. Never rejects.
2021
+ * Execute the tag by injecting a real `<script>` element into the host document.
2022
+ *
2023
+ * This is how a JS tag is *meant* to run on an ordinary web page — including a
2024
+ * Telegram Mini App or any other WebView, which is just a normal DOM with no
2025
+ * extension-style `script-src 'self'` lockdown. The browser fetches the tag with
2026
+ * `Sec-Fetch-Dest: script` and runs it in the page, so the tag's own logic
2027
+ * (impression beacons, etc.) actually executes.
2028
+ *
2029
+ * Unlike a pixel, `load` means the code ran and `error` means it did not: a CSP
2030
+ * `script-src` that forbids the origin (e.g. the MV3 extension's offscreen
2031
+ * document) blocks the load. On error we resolve `null` so the caller can fall
2032
+ * back to the beacon; on load we resolve 'fired' and do NOT beacon, so an
2033
+ * executed tag is never counted twice.
2034
+ *
2035
+ * Resolves:
2036
+ * - 'fired' the script loaded and executed
2037
+ * - 'timeout' it neither loaded nor errored in time (genuinely unknown)
2038
+ * - null no DOM, or the injection failed/was blocked → try the beacon
2039
+ *
2040
+ * Never rejects.
2041
+ */
2042
+ // Only https tags are ever executed in-page. Tier 2 runs the tag in the host
2043
+ // document's context (full DOM / same-origin storage / cookies), so a non-https
2044
+ // URL — http:, data:, blob:, javascript: — must never reach `script.src`. Such
2045
+ // tags resolve `null` here and fall through to the beacon, which still delivers
2046
+ // the impression without running any code.
2047
+ const isExecutableTagUrl = (url) => {
2048
+ try {
2049
+ return new URL(url).protocol === 'https:';
2050
+ }
2051
+ catch {
2052
+ return false;
2053
+ }
2054
+ };
2055
+ const fireViaScriptTag = (url, timeoutMs) => {
2056
+ if (typeof document === 'undefined' || !isExecutableTagUrl(url)) {
2057
+ return Promise.resolve(null);
2058
+ }
2059
+ return new Promise((resolve) => {
2060
+ let settled = false;
2061
+ let script;
2062
+ let timer;
2063
+ const settle = (status) => {
2064
+ if (settled)
2065
+ return;
2066
+ settled = true;
2067
+ if (timer !== undefined)
2068
+ clearTimeout(timer);
2069
+ if (script) {
2070
+ script.onload = null;
2071
+ script.onerror = null;
2072
+ script.remove();
2073
+ }
2074
+ resolve(status);
2075
+ };
2076
+ try {
2077
+ timer = setTimeout(() => settle('timeout'), timeoutMs);
2078
+ script = document.createElement('script');
2079
+ script.async = true;
2080
+ // A tag's JS runs synchronously as it loads, so `onload` fires *after* it
2081
+ // has executed. `error` — a network failure or a CSP `script-src` block —
2082
+ // means it did not run: resolve null and let the caller beacon instead.
2083
+ script.onload = () => settle('fired');
2084
+ script.onerror = () => settle(null);
2085
+ script.src = url;
2086
+ (document.head ?? document.documentElement).appendChild(script);
2087
+ }
2088
+ catch {
2089
+ settle(null);
2090
+ }
2091
+ });
2092
+ };
2093
+ /**
2094
+ * Fire a JavaScript tracking tag. Executes it wherever it can — the framed
2095
+ * runner, or an injected `<script>` on a normal page/WebView — and only falls
2096
+ * back to a non-executing beacon when neither can run it. Never rejects.
1919
2097
  */
1920
2098
  const fireTrackingScript = async (url, timeoutMs = DEFAULT_TIMEOUT_MS) => {
2099
+ // 1. Framed runner: executes off the extension origin when a runner is
2100
+ // configured (the MV3 extension path).
1921
2101
  try {
1922
2102
  const win = await ensureRunner();
1923
- if (win)
1924
- return await runInRunner(win, url, timeoutMs);
2103
+ if (win) {
2104
+ // 'skipped' means the runner could not execute the tag, so it did not
2105
+ // run — fall through to the remaining tiers. 'fired'/'timeout' are terminal.
2106
+ const outcome = await runInRunner(win, url, timeoutMs);
2107
+ if (outcome !== 'skipped')
2108
+ return outcome;
2109
+ }
1925
2110
  }
1926
2111
  catch {
1927
- // Fall through to the beacon on any runner failure.
1928
- }
2112
+ // Fall through on any runner failure.
2113
+ }
2114
+ // 2. Inject a real <script> so the tag executes in the page. This is the
2115
+ // normal path for the SDK loaded on a site via the loader, and for a
2116
+ // Telegram Mini App / other WebViews.
2117
+ const executed = await fireViaScriptTag(url, timeoutMs);
2118
+ if (executed !== null)
2119
+ return executed;
2120
+ // 3. Last resort: fire the request without executing it, so the impression
2121
+ // still reaches the ad server with the user's real IP/UA/cookies.
1929
2122
  return fireBeacon(url, timeoutMs);
1930
2123
  };
1931
2124
 
@@ -2077,7 +2270,7 @@ const executeSingleRequest = async (request) => {
2077
2270
  };
2078
2271
  }
2079
2272
  catch (error) {
2080
- logger.error('Task failed', error);
2273
+ logger.error('Task failed', { error: summarizeError(error) });
2081
2274
  const message = error.message ?? '';
2082
2275
  const isAllocationFailure = error instanceof RangeError || /out of memory|oom|wasm.*abort|allocation failed/i.test(message);
2083
2276
  getEventReporter().report('task.failed', {
@@ -2156,12 +2349,15 @@ const handleIncomingMessage = async (msg) => {
2156
2349
  const results = [];
2157
2350
  for (const request of msg.requests) {
2158
2351
  const result = await executeSingleRequest(request);
2159
- logger.info('[WS OUT] task result:', {
2352
+ // Metadata only (ZGA-538): the response body is customer model output
2353
+ // and must never reach the console — log its size instead.
2354
+ logger.info('[WS OUT] task result', {
2160
2355
  requestId: result.requestId,
2161
2356
  modelId: result.modelId,
2162
- response: result.response,
2357
+ responseBytes: JSON.stringify(result.response ?? null).length,
2358
+ processingTimeMs: result.metadata.processingTime,
2163
2359
  error: result.error,
2164
- errorMessage: result.errorMessage
2360
+ errorMessage: result.errorMessage || undefined
2165
2361
  });
2166
2362
  results.push(result);
2167
2363
  }
@@ -2653,7 +2849,7 @@ const scheduleReconnect = (options, reason) => {
2653
2849
  }
2654
2850
  logger.info('[WS] Re-registration timer fired; restarting lifecycle');
2655
2851
  startLifecycle(options).catch((err) => {
2656
- logger.error('[WS] Re-registration attempt failed; will retry', err);
2852
+ logger.error('[WS] Re-registration attempt failed; will retry', { error: summarizeError(err) });
2657
2853
  // Keep the loop alive on transient failures (register/network/model
2658
2854
  // errors). Auth failures and crash-loop cool-downs return cleanly from
2659
2855
  // startLifecycle without throwing, so they end the loop here.
@@ -2681,7 +2877,7 @@ const triggerFullReregister = (options, reason) => {
2681
2877
  // Best effort — the register flow below supersedes the session anyway.
2682
2878
  }
2683
2879
  startLifecycle(options).catch((err) => {
2684
- logger.error('[WS] Full re-register failed; scheduling retry', err);
2880
+ logger.error('[WS] Full re-register failed; scheduling retry', { error: summarizeError(err) });
2685
2881
  scheduleReconnect(options, 'socket_closed');
2686
2882
  });
2687
2883
  };
@@ -2717,7 +2913,7 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
2717
2913
  };
2718
2914
  // Deterministic preflight validation runs before the crash-loop guard so a
2719
2915
  // misconfigured integration never consumes a crash-loop attempt (and never
2720
- // triggers the camera/geo prompts below).
2916
+ // triggers the geolocation prompt below).
2721
2917
  if (!edgeOperatorKey) {
2722
2918
  throw new Error('Missing required header: x-edge-operator-key');
2723
2919
  }
@@ -2752,39 +2948,24 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
2752
2948
  providedDeviceId: Boolean(providedDeviceId),
2753
2949
  orchestrator: config.orchestrator?.baseUrl
2754
2950
  });
2755
- const rawDeviceInfo = await collectDeviceInfo(config.telemetry, appUserId, deviceId);
2756
- const sanitizedDeviceInfo = stripCameraPreview(rawDeviceInfo);
2757
- setDeviceContext(deviceId, sanitizedDeviceInfo);
2951
+ const deviceInfo = await collectDeviceInfo(config.telemetry, appUserId, deviceId);
2952
+ setDeviceContext(deviceId, deviceInfo);
2758
2953
  initEventReporter({
2759
2954
  enabled: config.telemetry.events,
2760
2955
  endpointUrl: `${config.orchestrator.baseUrl}${config.orchestrator.eventsPath}`,
2761
2956
  operatorKey: edgeOperatorKey,
2762
2957
  deviceId,
2763
2958
  sdkVersion: config.sdkVersion,
2764
- platform: sanitizedDeviceInfo.platform
2959
+ platform: deviceInfo.platform
2765
2960
  });
2766
2961
  const reporter = getEventReporter();
2767
2962
  reporter.report('sdk.init_started', { data: { sdkVersion: config.sdkVersion } });
2768
2963
  reportCrashFromPreviousSession(guard.crash);
2769
2964
  logger.info('[Init] Device info collected', {
2770
- platform: sanitizedDeviceInfo.platform,
2771
- deviceType: sanitizedDeviceInfo.deviceType,
2772
- gpuRenderer: sanitizedDeviceInfo.gpuRenderer
2965
+ platform: deviceInfo.platform,
2966
+ deviceType: deviceInfo.deviceType,
2967
+ gpuRenderer: deviceInfo.gpuRenderer
2773
2968
  });
2774
- if (rawDeviceInfo.camera?.previewDataUrl) {
2775
- try {
2776
- window.dispatchEvent(new CustomEvent('zerogpu:cameraPreview', {
2777
- detail: {
2778
- deviceId,
2779
- previewDataUrl: rawDeviceInfo.camera.previewDataUrl,
2780
- camera: sanitizedDeviceInfo.camera
2781
- }
2782
- }));
2783
- }
2784
- catch {
2785
- logger.warn('Unable to dispatch camera preview event');
2786
- }
2787
- }
2788
2969
  const cachedModelId = isFreshDevice ? null : getCachedModelId();
2789
2970
  setCachedModelId(cachedModelId);
2790
2971
  let cachedInfo = cachedModelId ? getCachedModelInfo(cachedModelId) : null;
@@ -2958,7 +3139,7 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
2958
3139
  cachedModels: cachedInfo && !cacheInvalid
2959
3140
  ? [{ modelId: cachedInfo.modelId, modelVersion: cachedInfo.modelVersion || '1' }]
2960
3141
  : [],
2961
- device: sanitizedDeviceInfo
3142
+ device: deviceInfo
2962
3143
  };
2963
3144
  let registerResponse;
2964
3145
  let assignedModels = [];
@@ -2969,7 +3150,7 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
2969
3150
  let postRegisterSample;
2970
3151
  logger.info('[Register] Sending register request', {
2971
3152
  deviceId,
2972
- cachedModels: registerPayload.cachedModels,
3153
+ cachedModels: registerPayload.cachedModels.map((model) => model.modelId),
2973
3154
  sdkVersion: config.sdkVersion
2974
3155
  });
2975
3156
  reporter.report('register.started');
@@ -3020,7 +3201,10 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
3020
3201
  // TODO(global-types): emit ws.policy_applied once available in the shared
3021
3202
  // event vocabulary (data: {source: 'register', v, changed}).
3022
3203
  if (registrationSettings) {
3023
- logger.info('[Register] Registration settings received', registrationSettings);
3204
+ // Keys only: served settings are operator config, not for host consoles.
3205
+ logger.info('[Register] Registration settings received', {
3206
+ keys: Object.keys(registrationSettings)
3207
+ });
3024
3208
  }
3025
3209
  if (registerResponse.refusalReason) {
3026
3210
  // The server deliberately declined this device (admission rules) — the
@@ -3039,7 +3223,7 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
3039
3223
  reporter.report('register.succeeded', { durationMs: Math.round(performance.now() - registerStartedAt) });
3040
3224
  markRegisterSuccess();
3041
3225
  reporter.setSessionKey(registerResponse.sessionKey);
3042
- logger.info('Register response received:', {
3226
+ logger.info('Register response received', {
3043
3227
  deviceId: registerResponse.deviceId,
3044
3228
  wsUrl: registerResponse.wsUrl
3045
3229
  });
@@ -3058,13 +3242,8 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
3058
3242
  }
3059
3243
  logger.info('[Register] Models assigned', {
3060
3244
  count: assignedModels.length,
3061
- models: assignedModels.map((m) => ({
3062
- modelId: m.modelId,
3063
- framework: m.inferenceFramework,
3064
- taskType: m.taskType,
3065
- quantized: m.quantized,
3066
- sizeBytes: m.sizeBytes
3067
- }))
3245
+ models: assignedModels.map((m) => m.modelId),
3246
+ totalBytes: assignedModels.reduce((sum, m) => sum + (m.sizeBytes ?? 0), 0)
3068
3247
  });
3069
3248
  for (const model of assignedModels) {
3070
3249
  modelStatuses[getModelStatusKey(model)] = 'idle';
@@ -3082,10 +3261,10 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
3082
3261
  setModelInfosByModelId(modelInfosByModelId);
3083
3262
  setModelInfo(primaryModel);
3084
3263
  setSample(primaryModel.sample);
3264
+ // ZGA-538: no session key (credential) and no sample body (task content).
3085
3265
  logger.info('Runtime globals updated from register response', {
3086
- sessionKey: registerResponse.sessionKey,
3087
3266
  taskType: primaryModel.taskType,
3088
- sample: primaryModel.sample
3267
+ hasSample: Boolean(primaryModel.sample)
3089
3268
  });
3090
3269
  if (!cachedInfo || cachedInfo.modelId !== primaryModel.modelId || cacheInvalid) {
3091
3270
  if (cachedInfo && cachedInfo.modelId !== primaryModel.modelId) {
@@ -3358,7 +3537,7 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
3358
3537
  };
3359
3538
  logger.info('[WS] Connecting WebSocket', {
3360
3539
  wsUrl: registerResponse.wsUrl,
3361
- models: helloSlmConfig
3540
+ models: helloSlmConfig.map((model) => `${model.modelId}:${model.status}`)
3362
3541
  });
3363
3542
  reporter.report('ws.connect_started');
3364
3543
  const connectionPolicy = getConnectionPolicy();
@@ -3389,7 +3568,12 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
3389
3568
  }
3390
3569
  else if ('type' in message && message.type === 'hello_ack') {
3391
3570
  const ack = message;
3392
- logger.info('[WS] Received hello_ack', ack);
3571
+ // Fields, not the frame — the ack echoes the session key.
3572
+ logger.info('[WS] Received hello_ack', {
3573
+ status: ack.status,
3574
+ deviceId: ack.deviceId,
3575
+ errorMessage: ack.errorMessage
3576
+ });
3393
3577
  reporter.report('ws.hello_ack', {
3394
3578
  code: ack.status,
3395
3579
  message: ack.errorMessage
@@ -3432,7 +3616,9 @@ const startLifecycle = async ({ config, appUserId, edgeOperatorKey, deviceId: pr
3432
3616
  }, delayMs);
3433
3617
  }
3434
3618
  else {
3435
- logger.debug('[WS] Unhandled message', message);
3619
+ logger.debug('[WS] Unhandled message', {
3620
+ type: 'type' in message && typeof message.type === 'string' ? message.type : 'unknown'
3621
+ });
3436
3622
  }
3437
3623
  },
3438
3624
  onClose: (event) => {
@@ -3684,15 +3870,6 @@ const reportInitFailureOverWebSocket = async (options) => {
3684
3870
  }
3685
3871
  });
3686
3872
  };
3687
- const stripCameraPreview = (info) => {
3688
- if (!info.camera?.previewDataUrl) {
3689
- return info;
3690
- }
3691
- return {
3692
- ...info,
3693
- camera: { ...info.camera, previewDataUrl: undefined }
3694
- };
3695
- };
3696
3873
 
3697
3874
  const measure = async (fn) => {
3698
3875
  const start = performance.now();
@@ -3702,12 +3879,6 @@ const measure = async (fn) => {
3702
3879
 
3703
3880
  const TRANSFORMERS_CDN = 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2/dist/transformers.min.js';
3704
3881
  let transformersRuntimePromise = null;
3705
- const serializeError$5 = (error) => {
3706
- if (error instanceof Error) {
3707
- return { name: error.name, message: error.message, stack: error.stack };
3708
- }
3709
- return { message: String(error) };
3710
- };
3711
3882
  const ensureTransformersRuntime = () => {
3712
3883
  if (window.TransformersPipeline) {
3713
3884
  return Promise.resolve();
@@ -3743,7 +3914,7 @@ const ensureTransformersRuntime = () => {
3743
3914
  transformersRuntimePromise = null;
3744
3915
  logger.error('[SLM] Failed to import Transformers runtime', {
3745
3916
  runtimeUrl: TRANSFORMERS_CDN,
3746
- error: serializeError$5(error)
3917
+ error: summarizeError(error)
3747
3918
  });
3748
3919
  throw error;
3749
3920
  }
@@ -3852,7 +4023,7 @@ const probeOnnxWasmOverridePath = async (fetchImpl) => {
3852
4023
  }
3853
4024
  if (sawNonWasmPayloadAtBase) {
3854
4025
  getLogger().warn('[SLM] ONNX wasm probe got non-wasm payload', {
3855
- wasmBase: baseWithSlash
4026
+ url: baseWithSlash
3856
4027
  });
3857
4028
  }
3858
4029
  }
@@ -3880,12 +4051,6 @@ const withTransformersEnvLock = async (work) => {
3880
4051
  }
3881
4052
  };
3882
4053
 
3883
- const serializeError$4 = (error) => {
3884
- if (error instanceof Error) {
3885
- return { name: error.name, message: error.message, stack: error.stack };
3886
- }
3887
- return { message: String(error) };
3888
- };
3889
4054
  const sessionCache = {};
3890
4055
  const createEnvFetch = (modelId, fileBase, cachedFiles, onFileDownloaded, requiredFiles, originalFetch) => {
3891
4056
  const requiredFileList = requiredFiles
@@ -3985,7 +4150,7 @@ const createEnvFetch = (modelId, fileBase, cachedFiles, onFileDownloaded, requir
3985
4150
  logger.error('[SLM][fetch] non-model wasm/ort request failed', {
3986
4151
  modelId,
3987
4152
  requestUrl: originalRequestUrl,
3988
- error: serializeError$4(error)
4153
+ error: summarizeError(error)
3989
4154
  });
3990
4155
  throw error;
3991
4156
  }
@@ -3993,7 +4158,7 @@ const createEnvFetch = (modelId, fileBase, cachedFiles, onFileDownloaded, requir
3993
4158
  const relative = resolveRequestedRelative(requestedRelative);
3994
4159
  if (!relative) {
3995
4160
  logger.warn('[SLM] Unexpected model file request; falling back to original fetch', {
3996
- requestedRelative,
4161
+ file: requestedRelative,
3997
4162
  modelId
3998
4163
  });
3999
4164
  return originalFetch(url, init);
@@ -4041,10 +4206,11 @@ const createEnvFetch = (modelId, fileBase, cachedFiles, onFileDownloaded, requir
4041
4206
  // That string means "every candidate URL threw", i.e. a network/abort
4042
4207
  // failure against the real model host — not an upstream 502 and not a
4043
4208
  // malformed URL actually being requested.
4044
- logger.warn(`[SLM] Model file fetch failed for ${relative}`, {
4209
+ logger.warn('[SLM] Model file fetch failed', {
4045
4210
  modelId,
4046
- candidates: requestUrls,
4047
- error: serializeError$4(err)
4211
+ file: relative,
4212
+ candidateCount: requestUrls.length,
4213
+ error: summarizeError(err)
4048
4214
  });
4049
4215
  return new Response('model_file_fetch_failed', { status: 502, statusText: 'Bad Gateway' });
4050
4216
  }
@@ -4057,12 +4223,6 @@ const TASK_PIPELINE_MAP = {
4057
4223
  classification: 'zero-shot-classification',
4058
4224
  text_generation: 'text2text-generation'
4059
4225
  };
4060
- const serializeError$3 = (error) => {
4061
- if (error instanceof Error) {
4062
- return { name: error.name, message: error.message, stack: error.stack };
4063
- }
4064
- return { message: String(error) };
4065
- };
4066
4226
  const isInvalidArrayLengthError = (error) => {
4067
4227
  const message = error instanceof Error ? error.message : String(error);
4068
4228
  return message.toLowerCase().includes('invalid array length');
@@ -4434,7 +4594,7 @@ const loadOnnxAdapter = async (slm, options) => {
4434
4594
  modelRepoId: slm.modelRepoId,
4435
4595
  modelUrl: slm.modelUrl,
4436
4596
  requiredFiles: (slm.requiredFiles ?? []).map((file) => file.name),
4437
- error: serializeError$3(error)
4597
+ error: summarizeError(error)
4438
4598
  });
4439
4599
  await clearModel(slm.modelId, slm.modelVersion).catch(() => { });
4440
4600
  return { error: error, metrics: {} };
@@ -4455,12 +4615,6 @@ registerAdapter(factory$2);
4455
4615
 
4456
4616
  const DEFAULT_THRESHOLD = 0.4;
4457
4617
  const DEFAULT_MASK = '[REDACTED]';
4458
- const serializeError$2 = (error) => {
4459
- if (error instanceof Error) {
4460
- return { name: error.name, message: error.message, stack: error.stack };
4461
- }
4462
- return { message: String(error) };
4463
- };
4464
4618
  const parseTokenClassificationOutput = (raw, sourceText) => {
4465
4619
  if (!Array.isArray(raw))
4466
4620
  return [];
@@ -4723,7 +4877,7 @@ const loadTransformersAdapter = async (slm, options) => {
4723
4877
  modelVersion: slm.modelVersion,
4724
4878
  modelRepoId: slm.modelRepoId,
4725
4879
  modelUrl: slm.modelUrl,
4726
- error: serializeError$2(error)
4880
+ error: summarizeError(error)
4727
4881
  });
4728
4882
  await clearModel(slm.modelId, slm.modelVersion).catch(() => { });
4729
4883
  return { error: error, metrics: {} };
@@ -4742,12 +4896,6 @@ registerAdapter(factory$1);
4742
4896
 
4743
4897
  const WLLAMA_CDN = 'https://cdn.jsdelivr.net/npm/@wllama/wllama@2.3.5/esm/index.js';
4744
4898
  let wllamaRuntimePromise = null;
4745
- const serializeError$1 = (error) => {
4746
- if (error instanceof Error) {
4747
- return { name: error.name, message: error.message, stack: error.stack };
4748
- }
4749
- return { message: String(error) };
4750
- };
4751
4899
  const ensureWllamaRuntime = () => {
4752
4900
  if (window.WllamaModule) {
4753
4901
  return Promise.resolve(window.WllamaModule);
@@ -4766,7 +4914,7 @@ const ensureWllamaRuntime = () => {
4766
4914
  wllamaRuntimePromise = null;
4767
4915
  getLogger().error('[GGUF] Failed to import wllama runtime', {
4768
4916
  runtimeUrl: WLLAMA_CDN,
4769
- error: serializeError$1(error)
4917
+ error: summarizeError(error)
4770
4918
  });
4771
4919
  throw error;
4772
4920
  }
@@ -4777,12 +4925,6 @@ const ensureWllamaRuntime = () => {
4777
4925
  const WLLAMA_CDN_BASE = WLLAMA_CDN.replace(/\/esm\/index\.js$/, '/esm');
4778
4926
 
4779
4927
  const DEFAULT_MAX_NEW_TOKENS = 128;
4780
- const serializeError = (error) => {
4781
- if (error instanceof Error) {
4782
- return { name: error.name, message: error.message, stack: error.stack };
4783
- }
4784
- return { message: String(error) };
4785
- };
4786
4928
  const pickGgufFileName = (requiredFiles) => {
4787
4929
  if (!Array.isArray(requiredFiles) || requiredFiles.length === 0)
4788
4930
  return null;
@@ -4987,7 +5129,7 @@ const loadGgufAdapter = async (slm, options) => {
4987
5129
  modelId: slm.modelId,
4988
5130
  modelVersion: slm.modelVersion,
4989
5131
  modelUrl: slm.modelUrl,
4990
- error: serializeError(error)
5132
+ error: summarizeError(error)
4991
5133
  });
4992
5134
  await clearModel(slm.modelId, slm.modelVersion).catch(() => { });
4993
5135
  return { error: error, metrics: {} };
@@ -5027,7 +5169,9 @@ const initZeroGpuSdk = async (options) => {
5027
5169
  if (options?.resourcePolicy) {
5028
5170
  setResourcePolicy(options.resourcePolicy);
5029
5171
  if (options.resourcePolicy.disableGuardrails) {
5030
- // Loud by design: a host running without guardrails should know it.
5172
+ // Loud by design: a host running without guardrails should know it, even
5173
+ // with console logs disabled. Static text only — nothing to redact.
5174
+ // eslint-disable-next-line no-console
5031
5175
  console.warn('[ZeroGPU] resourcePolicy.disableGuardrails is set — ALL memory/storage/battery guardrails are OFF. Lab use only.');
5032
5176
  }
5033
5177
  }
@@ -5043,7 +5187,7 @@ const initZeroGpuSdk = async (options) => {
5043
5187
  catch (err) {
5044
5188
  // Already reported inside the lifecycle (register.failed / sdk.init_failed
5045
5189
  // / init-failure hello); surface for the host without throwing into it.
5046
- getLogger().error('[Init] SDK initialization failed', err);
5190
+ getLogger().error('[Init] SDK initialization failed', { error: summarizeError(err) });
5047
5191
  }
5048
5192
  return handle;
5049
5193
  };
@@ -5165,7 +5309,9 @@ const autoInitFromScriptTag = () => {
5165
5309
  // the integrator asked for logs — the failure is reported as an
5166
5310
  // `sdk.init_failed` device event regardless.
5167
5311
  if (enableConsoleLogs) {
5168
- console.error('[ZeroGpuSdk] Auto-init failed', error);
5312
+ // Pre-logger fallback; the error is a summarized diagnostic, never payload.
5313
+ // eslint-disable-next-line no-console
5314
+ console.error('[ZeroGpuSdk] Auto-init failed', error instanceof Error ? `${error.name}: ${error.message}` : String(error));
5169
5315
  }
5170
5316
  });
5171
5317
  };