@askalf/dario 6.0.36 → 6.0.37

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 (2) hide show
  1. package/dist/version.js +24 -10
  2. package/package.json +1 -1
package/dist/version.js CHANGED
@@ -1,28 +1,42 @@
1
1
  /**
2
- * dario's own package version, read once from the bundled package.json.
2
+ * dario's own package version, bound at module load.
3
3
  *
4
4
  * Surfaced on `/status` and `/health` (#640) so a headless operator can confirm
5
5
  * an auto-update actually rolled the running proxy — `curl /health | jq .version`
6
6
  * beats exec-ing into the container to read package.json.
7
+ *
8
+ * WHY AT MODULE LOAD, NOT ON FIRST CALL. This used to read package.json lazily
9
+ * the first time someone asked, and cache that. `npm i -g` rewrites
10
+ * package.json under the running install without touching the process, so a
11
+ * proxy that had not served `/status` before an upgrade answered its first one
12
+ * with the NEW version while still executing the OLD code — precisely the
13
+ * opposite of what the field exists to report. It cost the reporter on #1244 a
14
+ * round trip: `/status` read 6.0.34 while `GET /admin/accounts` was still
15
+ * emitting the 6.0.33 field set, so the advice he had been given ("upgrade,
16
+ * then read `organization_id`") looked already done.
17
+ *
18
+ * Reading at import binds the value to the process. proxy.ts imports this at
19
+ * startup, so `/status` reports the build that is actually answering until it
20
+ * restarts — the only claim the field can honestly make.
7
21
  */
8
22
  import { readFileSync } from 'node:fs';
9
23
  import { join, dirname } from 'node:path';
10
24
  import { fileURLToPath } from 'node:url';
11
- let cached = null;
12
- export function darioVersion() {
13
- if (cached !== null)
14
- return cached;
15
- let v = 'unknown';
25
+ function readVersion() {
16
26
  try {
17
27
  // dist/version.js → ../package.json (same layout the MCP server + CLI use).
18
28
  const here = dirname(fileURLToPath(import.meta.url));
19
29
  const pkg = JSON.parse(readFileSync(join(here, '..', 'package.json'), 'utf-8'));
20
30
  if (typeof pkg.version === 'string')
21
- v = pkg.version;
31
+ return pkg.version;
22
32
  }
23
33
  catch {
24
- // package.json missing/malformed — keep 'unknown', never throw.
34
+ // package.json missing/malformed — report 'unknown', never throw.
25
35
  }
26
- cached = v;
27
- return v;
36
+ return 'unknown';
37
+ }
38
+ /** Read once, at import. See the note above for why not on first call. */
39
+ const VERSION = readVersion();
40
+ export function darioVersion() {
41
+ return VERSION;
28
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askalf/dario",
3
- "version": "6.0.36",
3
+ "version": "6.0.37",
4
4
  "description": "Use your Claude and ChatGPT subscriptions in Cursor, Cline, Aider, Claude Code and the Agent SDK — at subscription pricing, not per-token API bills. One local Anthropic + OpenAI-compatible endpoint: either plan answers either wire shape, with automatic failover when one hits its limit.",
5
5
  "type": "module",
6
6
  "bin": {