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