@shogo-ai/worker 1.7.8 → 1.7.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shogo-ai/worker",
3
- "version": "1.7.8",
3
+ "version": "1.7.9",
4
4
  "description": "Shogo Cloud Agent Worker — run Shogo agents on your own machine (laptop, devbox, CI).",
5
5
  "license": "MIT",
6
6
  "author": "Shogo Technologies, Inc.",
@@ -292,14 +292,32 @@ function sleep(ms: number, signal?: AbortSignal): Promise<void> {
292
292
  });
293
293
  }
294
294
 
295
+ // Build-time injected worker version.
296
+ //
297
+ // Bundlers replace this identifier via `--define '__SHOGO_WORKER_VERSION__="x.y.z"'`
298
+ // (see `apps/desktop/scripts/bundle-main.mjs`). When this module is consumed
299
+ // as an unbundled npm library the identifier is undeclared at runtime, and the
300
+ // `typeof` guard returns `'undefined'` without throwing.
301
+ //
302
+ // Previously this used `new URL('../../package.json', import.meta.url)` to
303
+ // read the worker's own `package.json` at runtime. That works in unbundled
304
+ // ESM but fails catastrophically once the worker is bundled into the
305
+ // desktop's `dist/main.js`: Bun / esbuild inline `import.meta.url` as the
306
+ // source file's `file:///...` URL at build time, which leaks the build
307
+ // host's filesystem layout into shipped artifacts and points at a path that
308
+ // doesn't exist on end-user machines. The same problem affects
309
+ // `require.resolve('@shogo-ai/worker/package.json')` (statically analyzed
310
+ // and inlined to a build-time absolute path). Bundle consumers must pass
311
+ // the version in via `--define`; standalone library consumers fall back
312
+ // to an `unknown` tag, which is purely diagnostic (this function feeds a
313
+ // telemetry User-Agent string, nothing load-bearing).
314
+ declare const __SHOGO_WORKER_VERSION__: string | undefined;
315
+
295
316
  function readWorkerVersion(): string {
296
- try {
297
- const url = new URL('../../package.json', import.meta.url);
298
- const pkg = JSON.parse(require('node:fs').readFileSync(url, 'utf-8'));
299
- return pkg?.version ? `shogo-cli/${pkg.version}` : 'shogo-cli/unknown';
300
- } catch {
301
- return 'shogo-cli/unknown';
317
+ if (typeof __SHOGO_WORKER_VERSION__ === 'string' && __SHOGO_WORKER_VERSION__.length > 0) {
318
+ return `shogo-cli/${__SHOGO_WORKER_VERSION__}`;
302
319
  }
320
+ return 'shogo-cli/unknown';
303
321
  }
304
322
 
305
323
  function openInBrowser(url: string): Promise<void> {