whitemagic-mcp 10.2.0-alpha.2 → 10.2.0-alpha.4

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 (3) hide show
  1. package/README.md +1 -1
  2. package/bin/lib.mjs +75 -57
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -39,7 +39,7 @@ MCP client config:
39
39
  Or try the binary directly:
40
40
 
41
41
  ```bash
42
- npx whitemagic-mcp --version # wm 10.2.0-alpha.2
42
+ npx whitemagic-mcp --version # wm 10.2.0-alpha.4
43
43
  npx whitemagic-mcp doctor # environment health check
44
44
  ```
45
45
 
package/bin/lib.mjs CHANGED
@@ -55,13 +55,23 @@ export function childEnvironment(env = process.env) {
55
55
  return { ...env, WM_INSTALL_CHANNEL: ref ? `npm:${ref}` : "npm" };
56
56
  }
57
57
 
58
+ /**
59
+ * Release assets to try, most-specific first. Linux lists the static musl
60
+ * build then the glibc build: the v10 line is glibc-only (the ONNX runtime
61
+ * the binary loads has no musl build), while older releases published musl,
62
+ * so the launcher stays correct across both.
63
+ */
64
+ export function assetCandidates(p = platform(), a = arch()) {
65
+ if (p === "linux" && a === "x64") return ["wm-linux-x86_64-musl", "wm-linux-x86_64"];
66
+ if (p === "linux" && a === "arm64") return ["wm-linux-aarch64-musl", "wm-linux-aarch64"];
67
+ if (p === "darwin" && a === "arm64") return ["wm-macos-aarch64"];
68
+ if (p === "darwin" && a === "x64") return ["wm-macos-x86_64"];
69
+ if (p === "win32" && a === "x64") return ["wm-windows-x86_64.exe"];
70
+ return [];
71
+ }
72
+
58
73
  export function assetFor(p = platform(), a = arch()) {
59
- if (p === "linux" && a === "x64") return "wm-linux-x86_64-musl";
60
- if (p === "linux" && a === "arm64") return "wm-linux-aarch64-musl";
61
- if (p === "darwin" && a === "arm64") return "wm-macos-aarch64";
62
- if (p === "darwin" && a === "x64") return "wm-macos-x86_64";
63
- if (p === "win32" && a === "x64") return "wm-windows-x86_64.exe";
64
- return null;
74
+ return assetCandidates(p, a)[0] ?? null;
65
75
  }
66
76
 
67
77
  export function defaultCacheRoot(env = process.env) {
@@ -158,69 +168,77 @@ export async function ensureBinary({
158
168
  log = console.error,
159
169
  } = {}) {
160
170
  const resolvedTag = tag ?? releaseTag(pkgVersion);
161
- const asset = assetFor(p, a);
162
- if (!asset) {
171
+ const candidates = assetCandidates(p, a);
172
+ if (candidates.length === 0) {
163
173
  throw new Error(
164
174
  `no release asset for ${p}/${a} yet — install from source: https://github.com/${REPO}#install`,
165
175
  );
166
176
  }
167
- const cached = cachedBinaryPath(asset, resolvedTag, cacheRoot);
168
- if (cacheIsValid(cached)) return cached;
169
- if (existsSync(cached)) {
170
- log("whitemagic-mcp: cached binary failed verification — re-downloading.");
171
- }
172
177
 
173
- log(`whitemagic-mcp: fetching ${resolvedTag}/${asset} ...`);
174
178
  const binDir = join(cacheRoot, "whitemagic", "bin", resolvedTag);
175
- mkdirSync(binDir, { recursive: true });
176
- // Stage INSIDE the cache dir so the final rename is atomic (a /tmp staging
177
- // dir can live on another filesystem, where rename fails with EXDEV).
178
- const tmp = mkdtempSync(join(binDir, ".download-"));
179
- try {
180
- const tmpBin = join(tmp, asset);
181
- let compressed = false;
182
- if (!asset.endsWith(".exe")) {
183
- try {
184
- await fetchTo(`${BASE_URL(resolvedTag)}/${asset}.gz`, join(tmp, `${asset}.gz`), fetchImpl);
179
+ let notFound = null;
180
+ for (const asset of candidates) {
181
+ const cached = cachedBinaryPath(asset, resolvedTag, cacheRoot);
182
+ if (cacheIsValid(cached)) return cached;
183
+ if (existsSync(cached)) {
184
+ log("whitemagic-mcp: cached binary failed verification — re-downloading.");
185
+ }
186
+
187
+ log(`whitemagic-mcp: fetching ${resolvedTag}/${asset} ...`);
188
+ mkdirSync(binDir, { recursive: true });
189
+ // Stage INSIDE the cache dir so the final rename is atomic (a /tmp staging
190
+ // dir can live on another filesystem, where rename fails with EXDEV).
191
+ const tmp = mkdtempSync(join(binDir, ".download-"));
192
+ try {
193
+ const tmpBin = join(tmp, asset);
194
+ let compressed = false;
195
+ if (!asset.endsWith(".exe")) {
196
+ try {
197
+ await fetchTo(`${BASE_URL(resolvedTag)}/${asset}.gz`, join(tmp, `${asset}.gz`), fetchImpl);
198
+ await fetchTo(
199
+ `${BASE_URL(resolvedTag)}/${asset}.gz.sha256`,
200
+ join(tmp, `${asset}.gz.sha256`),
201
+ fetchImpl,
202
+ );
203
+ compressed = true;
204
+ } catch (err) {
205
+ if (!String(err?.message ?? "").includes("HTTP 404")) throw err;
206
+ }
207
+ }
208
+ if (compressed) {
209
+ const gzPath = join(tmp, `${asset}.gz`);
210
+ const expectedGz = parseDigestFile(join(tmp, `${asset}.gz.sha256`), `${asset}.gz`);
211
+ const actualGz = digestFile(gzPath);
212
+ if (actualGz !== expectedGz) {
213
+ throw checksumMismatch(`${asset}.gz`, expectedGz, actualGz);
214
+ }
215
+ writeFileSync(tmpBin, gunzipSync(readFileSync(gzPath)));
216
+ log(`whitemagic-mcp: using the compressed distributable (${asset}.gz)`);
217
+ } else {
218
+ await fetchTo(`${BASE_URL(resolvedTag)}/${asset}`, tmpBin, fetchImpl);
185
219
  await fetchTo(
186
- `${BASE_URL(resolvedTag)}/${asset}.gz.sha256`,
187
- join(tmp, `${asset}.gz.sha256`),
220
+ `${BASE_URL(resolvedTag)}/${asset}.sha256`,
221
+ join(tmp, `${asset}.sha256`),
188
222
  fetchImpl,
189
223
  );
190
- compressed = true;
191
- } catch (err) {
192
- if (!String(err?.message ?? "").includes("HTTP 404")) throw err;
193
- }
194
- }
195
- if (compressed) {
196
- const gzPath = join(tmp, `${asset}.gz`);
197
- const expectedGz = parseDigestFile(join(tmp, `${asset}.gz.sha256`), `${asset}.gz`);
198
- const actualGz = digestFile(gzPath);
199
- if (actualGz !== expectedGz) {
200
- throw checksumMismatch(`${asset}.gz`, expectedGz, actualGz);
201
- }
202
- writeFileSync(tmpBin, gunzipSync(readFileSync(gzPath)));
203
- log(`whitemagic-mcp: using the compressed distributable (${asset}.gz)`);
204
- } else {
205
- await fetchTo(`${BASE_URL(resolvedTag)}/${asset}`, tmpBin, fetchImpl);
206
- await fetchTo(
207
- `${BASE_URL(resolvedTag)}/${asset}.sha256`,
208
- join(tmp, `${asset}.sha256`),
209
- fetchImpl,
210
- );
211
- const expected = parseDigestFile(join(tmp, `${asset}.sha256`), asset);
212
- const actual = digestFile(tmpBin);
213
- if (actual !== expected) {
214
- throw checksumMismatch(asset, expected, actual);
224
+ const expected = parseDigestFile(join(tmp, `${asset}.sha256`), asset);
225
+ const actual = digestFile(tmpBin);
226
+ if (actual !== expected) {
227
+ throw checksumMismatch(asset, expected, actual);
228
+ }
215
229
  }
230
+ chmodSync(tmpBin, 0o755);
231
+ renameSync(tmpBin, cached);
232
+ writeFileSync(sidecarFor(cached), `${digestFile(cached)}\n`);
233
+ return cached;
234
+ } catch (err) {
235
+ if (!String(err?.message ?? "").includes("HTTP 404")) throw err;
236
+ notFound = err; // asset absent from this release — try the next candidate
237
+ } finally {
238
+ rmSync(tmp, { recursive: true, force: true });
216
239
  }
217
- chmodSync(tmpBin, 0o755);
218
- renameSync(tmpBin, cached);
219
- writeFileSync(sidecarFor(cached), `${digestFile(cached)}\n`);
220
- return cached;
221
- } finally {
222
- rmSync(tmp, { recursive: true, force: true });
223
240
  }
241
+ throw notFound;
224
242
  }
225
243
 
226
244
  export function BASE_URL(tag) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whitemagic-mcp",
3
- "version": "10.2.0-alpha.2",
3
+ "version": "10.2.0-alpha.4",
4
4
  "description": "Local-first sovereign cognitive kernel and memory for AI coding agents over MCP - pure Rust, zero-telemetry, Landlock LSM sandbox.",
5
5
  "license": "MIT",
6
6
  "bin": {