@tokenade/cli 0.5.3 → 0.5.5

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/install.js +36 -3
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -38,15 +38,48 @@ const VENDOR = path.join(__dirname, "vendor");
38
38
  const REQUEST_TIMEOUT_MS = Number(process.env.TOKENADE_HTTP_TIMEOUT_MS) || 30000;
39
39
  const MAX_ATTEMPTS = 4;
40
40
 
41
+ // Is this Linux userland musl (Alpine, Void-musl, …) rather than glibc?
42
+ // A glibc node reports its runtime glibc version in the process report header;
43
+ // a musl node does not. We fall back to looking for the musl loader on disk.
44
+ // When genuinely unsure we return false (glibc) — that preserves the historical
45
+ // x86_64-gnu mapping for the overwhelming glibc majority, so a detection miss is
46
+ // never worse than the status quo.
47
+ function isMuslLinux() {
48
+ if (process.platform !== "linux") return false;
49
+ try {
50
+ const header = process.report && process.report.getReport().header;
51
+ if (header && typeof header.glibcVersionRuntime === "string") return false;
52
+ if (header && "glibcVersionRuntime" in header) {
53
+ // key present but not a string ⇒ no glibc runtime ⇒ musl
54
+ return true;
55
+ }
56
+ } catch {
57
+ // fall through to the on-disk probe
58
+ }
59
+ try {
60
+ return fs
61
+ .readdirSync("/lib")
62
+ .some((f) => f.startsWith("ld-musl-"));
63
+ } catch {
64
+ return false;
65
+ }
66
+ }
67
+
41
68
  function rustTarget() {
42
69
  const p = process.platform;
43
70
  const a = process.arch;
44
71
  if (p === "darwin")
45
72
  return a === "arm64" ? "aarch64-apple-darwin" : "x86_64-apple-darwin";
46
- if (p === "linux")
47
- return a === "arm64"
48
- ? "aarch64-unknown-linux-musl"
73
+ if (p === "linux") {
74
+ if (a === "arm64") return "aarch64-unknown-linux-musl";
75
+ // x86_64: a fully-static musl build runs on glibc too, but musl's DNS
76
+ // resolver ignores /etc/nsswitch.conf — so we only hand musl to machines
77
+ // whose libc is already musl (Alpine et al.), and keep the proven glibc
78
+ // build as the default everywhere else.
79
+ return isMuslLinux()
80
+ ? "x86_64-unknown-linux-musl"
49
81
  : "x86_64-unknown-linux-gnu";
82
+ }
50
83
  if (p === "win32") return "x86_64-pc-windows-gnu";
51
84
  throw new Error(`unsupported platform: ${p}/${a}`);
52
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenade/cli",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Tokenade — cut your AI coding agent's token bill. Installs the Tokenade CLI + MCP server (a local, paid token-reduction tool; activate via your browser).",
5
5
  "homepage": "https://tokenade.net",
6
6
  "license": "UNLICENSED",