@koed-labs/server 0.11.1 → 1.2.0

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 (47) hide show
  1. package/README.md +3 -3
  2. package/bin/koed.js +1 -1
  3. package/package.json +2 -2
  4. package/vendor/chunk-2YCDKSKW.js +45 -0
  5. package/vendor/{chunk-TG26CZGQ.js → chunk-355BP3MF.js} +4 -4
  6. package/vendor/{chunk-RCR4XPE3.js → chunk-3VNLZCMB.js} +1 -1
  7. package/vendor/{chunk-NVTMIAAF.js → chunk-7YXEB2CR.js} +18 -17
  8. package/vendor/{chunk-SRKIBFOE.js → chunk-A2TMTAAS.js} +1 -1
  9. package/vendor/{chunk-PL3LWC5C.js → chunk-AJPFOTVX.js} +1 -1
  10. package/vendor/{chunk-O7DW2VAV.js → chunk-BDJR6CKS.js} +4 -3
  11. package/vendor/{chunk-Z5WCAUA6.js → chunk-BMHMNUNK.js} +18 -17
  12. package/vendor/{chunk-C5SNDPAP.js → chunk-CSDTMMRL.js} +4 -4
  13. package/vendor/{chunk-FYYRFX4U.js → chunk-CX73L6YS.js} +67 -38
  14. package/vendor/{chunk-VGIYSDNU.js → chunk-D4XZTNLU.js} +117 -33
  15. package/vendor/{chunk-W2OJZZ6X.js → chunk-DQ5SIGZZ.js} +4 -2
  16. package/vendor/{chunk-4OO6VAU3.js → chunk-G54Q5W6M.js} +1 -1
  17. package/vendor/{chunk-EA4QDDQA.js → chunk-GEIN6UIL.js} +7 -2
  18. package/vendor/{chunk-QRKHHWJJ.js → chunk-H7ETSD25.js} +51 -3
  19. package/vendor/{chunk-NOU7RHYZ.js → chunk-HG47LAWW.js} +5 -4
  20. package/vendor/{chunk-C4V72GXC.js → chunk-HXL36SED.js} +19 -18
  21. package/vendor/{chunk-FN3HUUO2.js → chunk-I5XO5FL4.js} +73 -13
  22. package/vendor/{chunk-TVYEB2GN.js → chunk-J7LW6JFY.js} +48 -10
  23. package/vendor/{chunk-OCILJ737.js → chunk-JG7OELJM.js} +9 -9
  24. package/vendor/{chunk-6KS67EQE.js → chunk-KBECHDUE.js} +1 -1
  25. package/vendor/{chunk-2XKSVKQA.js → chunk-KH4UBONI.js} +3 -2
  26. package/vendor/{chunk-ZIOKV2X6.js → chunk-MFPPURFE.js} +113 -33
  27. package/vendor/{chunk-GFASBPV2.js → chunk-MHFYPBCL.js} +3 -3
  28. package/vendor/{chunk-V67IQB7H.js → chunk-OG7G6DIR.js} +1 -1
  29. package/vendor/{chunk-WDFERJG3.js → chunk-TAQWNZVD.js} +109 -33
  30. package/vendor/{chunk-HC76426R.js → chunk-TMCW2P6G.js} +7 -5
  31. package/vendor/chunk-ULLAURFV.js +8 -0
  32. package/vendor/{chunk-WPIEF4LY.js → chunk-ULUSFNAE.js} +3 -3
  33. package/vendor/{chunk-ZOHNXUDY.js → chunk-VWB3VEOL.js} +493 -20
  34. package/vendor/{chunk-LRP66XEY.js → chunk-XPSPPLX5.js} +14 -14
  35. package/vendor/{chunk-SHLRINKO.js → chunk-XSOQ2U5H.js} +2 -2
  36. package/vendor/{chunk-EDPNYIX5.js → chunk-XTQYFCVY.js} +146 -89
  37. package/vendor/{chunk-CHMH4LH5.js → chunk-XW7AXRDI.js} +3 -3
  38. package/vendor/{chunk-SNKWETM5.js → chunk-Y5OJXAUF.js} +2 -2
  39. package/vendor/chunk-YDZEMIAH.js +11 -0
  40. package/vendor/{chunk-BUIM2M4R.js → chunk-YOMK7KMB.js} +2 -2
  41. package/vendor/{chunk-ALJUSOF7.js → chunk-YY7NMZGD.js} +79 -1
  42. package/vendor/{chunk-BGENSONI.js → chunk-ZKKWLLPU.js} +1 -1
  43. package/vendor/cli.js +1 -1
  44. package/vendor/component-manifest-catalog.js +1 -1
  45. package/vendor/control-plane.js +6 -4
  46. package/vendor/chunk-7EGSY3E4.js +0 -8
  47. package/vendor/chunk-ZUDSZGVO.js +0 -11
@@ -3,23 +3,25 @@ import {
3
3
  checkCudaHost,
4
4
  nativeCommand,
5
5
  validateStagedCuda
6
- } from "./chunk-TVYEB2GN.js";
6
+ } from "./chunk-J7LW6JFY.js";
7
+ import "./chunk-2YCDKSKW.js";
7
8
  import "./chunk-JYK6UL6D.js";
8
9
  import {
9
10
  resolveKoedServerConfig
10
- } from "./chunk-ALJUSOF7.js";
11
+ } from "./chunk-YY7NMZGD.js";
11
12
  import {
12
13
  resolveKoedRuntimeOwner
13
- } from "./chunk-V67IQB7H.js";
14
+ } from "./chunk-OG7G6DIR.js";
14
15
  import {
15
16
  assertDirectoryChain,
16
17
  fetchBounded,
17
18
  renameAtomically,
19
+ resolveDesktopRuntimeOwner,
18
20
  withStoppedRuntime
19
- } from "./chunk-FN3HUUO2.js";
21
+ } from "./chunk-I5XO5FL4.js";
20
22
  import "./chunk-T6UB5PNX.js";
21
23
  import "./chunk-7NXKPDF3.js";
22
- import "./chunk-ZUDSZGVO.js";
24
+ import "./chunk-YDZEMIAH.js";
23
25
  import {
24
26
  canonicalArtifactJson,
25
27
  extractNativeArchive,
@@ -29,15 +31,16 @@ import {
29
31
  readNativeMetadata,
30
32
  syncNativeDirectory,
31
33
  verifyNativePayload
32
- } from "./chunk-ZIOKV2X6.js";
34
+ } from "./chunk-MFPPURFE.js";
33
35
  import {
34
36
  compareNativeVersions,
35
37
  compatibleCuda,
36
38
  getNativeRuntimeCatalog,
37
39
  nativeKind,
40
+ selectNativeRuntimeCatalog,
38
41
  validateNativeRuntimeCatalog
39
- } from "./chunk-QRKHHWJJ.js";
40
- import "./chunk-7EGSY3E4.js";
42
+ } from "./chunk-H7ETSD25.js";
43
+ import "./chunk-ULLAURFV.js";
41
44
  import "./chunk-IY2HRXOZ.js";
42
45
  import "./chunk-FSNLU46W.js";
43
46
  import "./chunk-BTS4ZTF3.js";
@@ -46,6 +49,7 @@ import "./chunk-BTS4ZTF3.js";
46
49
  import { randomUUID as randomUUID2 } from "node:crypto";
47
50
  import { mkdirSync as mkdirSync2, mkdtempSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, writeFileSync as writeFileSync2, lstatSync as lstatSync2, readlinkSync as readlinkSync2 } from "node:fs";
48
51
  import { dirname as dirname2, resolve as resolve3 } from "node:path";
52
+ import { release as kernelRelease } from "node:os";
49
53
 
50
54
  // packages/koed-server/dist/native-selection.js
51
55
  import { lstatSync, mkdirSync, readlinkSync, readdirSync, rmSync, renameSync, symlinkSync, writeFileSync } from "node:fs";
@@ -55,9 +59,9 @@ var releaseInstallCommand = "koed runtime install --provider release --dependenc
55
59
  var nativeStore = (paths) => resolve(paths.koedHome, "runtime/native");
56
60
  var nativePathExists = (path) => lstatSync(path, { throwIfNoEntry: false }) !== void 0;
57
61
  var payloadRoot = (paths, pin) => resolve(nativeStore(paths), nativeKind(pin), pin.recipeId);
58
- var coreLinks = [
62
+ var coreLinks = (pin) => [
59
63
  "postgres",
60
- "llama.cpp/cpu",
64
+ `llama.cpp/${pin.target.platform === "macos" ? "metal" : "cpu"}`,
61
65
  "llama.cpp/llama-server"
62
66
  ];
63
67
  var entryNames = ["postgres", "llama.cpp"];
@@ -119,19 +123,28 @@ function loadSelection(paths, id, catalog) {
119
123
  if (nativeDigest(raw) !== id)
120
124
  throw new Error("Native selection metadata changed.");
121
125
  const record = nativeJsonObject(raw);
122
- const { core: pin, cuda } = validateNativeRuntimeCatalog({
126
+ const core = record.core;
127
+ if (typeof core === "object" && core !== null && "target" in core && typeof core.target === "object" && core.target !== null && "platform" in core.target && (core.target.platform === "linux" || core.target.platform === "macos") && core.target.platform !== catalog.core.target.platform)
128
+ throw new NativeSelectionTargetError();
129
+ const receipt = {
123
130
  schemaVersion: 1,
124
131
  minimumCoreVersion: "0.0.0",
125
132
  core: record.core,
126
133
  cuda: record.cuda
127
- });
134
+ };
135
+ let pin, cuda;
136
+ try {
137
+ ({ core: pin, cuda } = catalog.core.target.platform === "linux" ? validateNativeRuntimeCatalog(receipt) : selectNativeRuntimeCatalog({ schemaVersion: 2, linux: null, macos: receipt }, "darwin", "arm64"));
138
+ } catch (cause) {
139
+ throw new Error("Native selection target or receipt is incompatible with the reviewed host catalog.", { cause });
140
+ }
128
141
  if (canonicalArtifactJson(document(pin, cuda)) !== raw.toString("utf8") || cuda && conflictsWithPin(cuda, catalog.cuda) || conflictsWithPin(pin, catalog.core))
129
142
  throw new Error("Native selection conflicts with the reviewed identity.");
130
- if (canonicalArtifactJson(readdirSync(root).sort()) !== canonicalArtifactJson(["llama.cpp", "postgres", "selection.json"]) || canonicalArtifactJson(readdirSync(resolve(root, "llama.cpp")).sort()) !== canonicalArtifactJson(cuda ? ["cpu", "cuda", "llama-server"] : ["cpu", "llama-server"]))
143
+ if (canonicalArtifactJson(readdirSync(root).sort()) !== canonicalArtifactJson(["llama.cpp", "postgres", "selection.json"]) || canonicalArtifactJson(readdirSync(resolve(root, "llama.cpp")).sort()) !== canonicalArtifactJson(pin.target.platform === "macos" ? ["llama-server", "metal"] : cuda ? ["cpu", "cuda", "llama-server"] : ["cpu", "llama-server"]))
131
144
  throw new Error("Unexpected native selection contents.");
132
145
  const payload = payloadRoot(paths, pin);
133
146
  assertDirectoryChain(paths.koedHome, payload);
134
- for (const name of coreLinks) {
147
+ for (const name of coreLinks(pin)) {
135
148
  const path = resolve(root, name);
136
149
  checkLink(path, relative(dirname(path), resolve(payload, name)));
137
150
  }
@@ -144,6 +157,11 @@ function loadSelection(paths, id, catalog) {
144
157
  }
145
158
  return { id, root, pin, cuda };
146
159
  }
160
+ var NativeSelectionTargetError = class extends Error {
161
+ constructor() {
162
+ super("Native selection target differs from this host. Stop Koed, preserve the existing native store, and use a fresh KOED_HOME before installing the runtime. The new KOED_HOME does not include the existing database or other data.");
163
+ }
164
+ };
147
165
  function readNativeSelection(paths, catalog) {
148
166
  const id = currentNativeId(paths);
149
167
  checkEntryPaths(paths, id !== null);
@@ -152,6 +170,8 @@ function readNativeSelection(paths, catalog) {
152
170
  try {
153
171
  return loadSelection(paths, id, catalog);
154
172
  } catch (cause) {
173
+ if (cause instanceof NativeSelectionTargetError)
174
+ throw cause;
155
175
  const detail = (cause instanceof Error ? cause.message : String(cause)).replace(/\.$/, "");
156
176
  throw new Error(`Cannot admit the installed native selection: ${detail}. Stop Koed, preserve the damaged native store for recovery, then run ${releaseInstallCommand}.`, { cause });
157
177
  }
@@ -180,7 +200,7 @@ function composeNativeSelection(paths, pin, staging, catalog, cuda = null) {
180
200
  mode: 384,
181
201
  flush: true
182
202
  });
183
- for (const name of coreLinks) {
203
+ for (const name of coreLinks(pin)) {
184
204
  const target = relative(dirname(resolve(root, name)), resolve(payloadRoot(paths, pin), name));
185
205
  symlinkSync(target, resolve(fresh, name));
186
206
  }
@@ -255,7 +275,7 @@ async function stageNativeAsset(pin, staging, signal, progress) {
255
275
  } catch (cause) {
256
276
  throw new Error(`Could not acquire the pinned native ${kind}: ${cause instanceof Error ? cause.message : String(cause)}. Check connectivity and free space, then retry ${releaseInstallCommand}${kind === "cuda" ? " --with-cuda" : ""}.`, { cause });
257
277
  }
258
- await extractNativeArchive(kind, archive, unpack, pin.expandedBytes, signal);
278
+ await extractNativeArchive(kind, archive, unpack, pin.expandedBytes, signal, pin.target.platform);
259
279
  const root = resolve2(unpack, "koed-runtime");
260
280
  verifyNativePayload(root, pin, true);
261
281
  return root;
@@ -263,11 +283,29 @@ async function stageNativeAsset(pin, staging, signal, progress) {
263
283
 
264
284
  // packages/koed-server/dist/runtime-release.js
265
285
  var reserve = 128 * 1024 * 1024;
266
- function assertReleaseHost() {
267
- const report = process.report.getReport();
268
- const libc = report.header?.glibcVersionRuntime ?? "";
286
+ var MacCudaPolicyError = class extends Error {
287
+ constructor() {
288
+ super("CUDA is not supported by the macOS release runtime. Set KOED_EMBEDDING_ACCELERATION to auto or metal before installing or starting.");
289
+ }
290
+ };
291
+ function assertMacPolicy(platform, policy) {
292
+ if (platform === "macos" && policy === "cuda")
293
+ throw new MacCudaPolicyError();
294
+ }
295
+ function assertReleaseHost(host = {
296
+ platform: process.platform,
297
+ arch: process.arch,
298
+ kernel: kernelRelease(),
299
+ libc: process.report.getReport().header?.glibcVersionRuntime ?? ""
300
+ }) {
301
+ if (host.platform === "darwin" && host.arch === "arm64") {
302
+ if (!/^\d+\.\d+\.\d+$/.test(host.kernel) || Number(host.kernel.split(".")[0]) < 23)
303
+ throw new Error("The release provider requires macOS 14 or later on arm64. Upgrade macOS before installing the release runtime.");
304
+ return;
305
+ }
306
+ const libc = host.libc;
269
307
  const [major, minor] = libc.split(".").map(Number);
270
- if (process.platform !== "linux" || process.arch !== "x64" || !/^\d+\.\d+(\.\d+)?$/.test(libc) || !(major > 2 || major === 2 && minor >= 35))
308
+ if (host.platform !== "linux" || host.arch !== "x64" || !/^\d+\.\d+(\.\d+)?$/.test(libc) || !(major > 2 || major === 2 && minor >= 35))
271
309
  throw new Error("The release provider requires Linux x64 and glibc 2.35 or later. On a host supported by Homebrew, install Homebrew and its host prerequisites, then run koed runtime install --provider homebrew --dependency-mode bundled-local.");
272
310
  }
273
311
  function collectReleaseRuntimeStatus(paths, environment = process.env) {
@@ -284,7 +322,7 @@ function collectReleaseRuntimeStatus(paths, environment = process.env) {
284
322
  installedCudaId: null,
285
323
  pinnedCudaId: catalog.cuda?.recipeId ?? null,
286
324
  executionPolicy: policy,
287
- message: `Install the CPU runtime with ${releaseInstallCommand}.`
325
+ message: `Install the ${catalog.core.target.platform === "macos" ? "Metal" : "CPU"} runtime with ${releaseInstallCommand}.`
288
326
  };
289
327
  const blocker = coreStartBlocker(selected.pin, catalog);
290
328
  if (blocker)
@@ -315,10 +353,10 @@ function collectReleaseRuntimeStatus(paths, environment = process.env) {
315
353
  pinnedCudaId: catalog.cuda?.recipeId ?? null,
316
354
  executionPolicy: policy,
317
355
  runtimeVersion: selected.pin.runtimeVersion,
318
- message: cudaOutdated ? `A CUDA add-on update is available. Stop Koed and run ${releaseInstallCommand} --with-cuda.` : coreOutdated ? `A native core update is available. Stop Koed and run ${releaseInstallCommand}.` : selected.cuda ? "The selected CPU core and CUDA add-on are installed." : "The selected CPU runtime is installed."
356
+ message: cudaOutdated ? `A CUDA add-on update is available. Stop Koed and run ${releaseInstallCommand} --with-cuda.` : coreOutdated ? `A native core update is available. Stop Koed and run ${releaseInstallCommand}.` : selected.cuda ? "The selected CPU core and CUDA add-on are installed." : `The selected ${catalog.core.target.platform === "macos" ? "Metal" : "CPU"} runtime is installed.`
319
357
  };
320
358
  }
321
- async function probeCore(root, signal) {
359
+ async function probeCore(root, signal, platform) {
322
360
  for (const binary of [
323
361
  "postgres/bin/postgres",
324
362
  "postgres/bin/psql",
@@ -332,13 +370,32 @@ async function probeCore(root, signal) {
332
370
  PATH: "/usr/bin:/bin",
333
371
  LANG: "C",
334
372
  LC_ALL: "C",
335
- KOED_LLAMA_SERVER_BACKEND: "cpu"
373
+ KOED_LLAMA_SERVER_BACKEND: platform === "macos" ? "metal" : "cpu"
336
374
  }
337
375
  });
338
376
  } catch (error) {
339
377
  throw new Error(`Staged native probe failed: ${binary}. ${error instanceof Error ? error.message : String(error)}`, { cause: error });
340
378
  }
341
379
  }
380
+ if (platform === "macos") {
381
+ try {
382
+ const devices = await nativeCommand(resolve3(root, "llama.cpp/llama-server"), ["--list-devices"], {
383
+ cwd: root,
384
+ signal,
385
+ env: {
386
+ PATH: "/usr/bin:/bin",
387
+ LANG: "C",
388
+ LC_ALL: "C",
389
+ KOED_LLAMA_SERVER_BACKEND: "metal",
390
+ LLAMA_ARG_UI: "false"
391
+ }
392
+ });
393
+ if (!/^[ \t]*(?:MTL[0-9]+|Metal[0-9]*):[ \t]+\S/im.test(devices))
394
+ throw new Error("No Metal device was reported.");
395
+ } catch (cause) {
396
+ throw new Error(`Staged Metal device discovery failed: ${cause instanceof Error ? cause.message : String(cause)}. Check Metal support and the native runtime, then retry.`, { cause });
397
+ }
398
+ }
342
399
  }
343
400
  function recordStatus(paths, id) {
344
401
  const cache = resolve3(paths.cacheDir, "runtime-release.json");
@@ -368,13 +425,16 @@ function recordStatus(paths, id) {
368
425
  }
369
426
  async function installReleaseRuntime(paths, options = {}) {
370
427
  assertReleaseHost();
371
- const catalog = getNativeRuntimeCatalog(), pin = catalog.core, store = nativeStore(paths), owner = resolveKoedRuntimeOwner();
428
+ if (process.platform === "darwin" && options.cuda && options.cuda !== "preserve")
429
+ throw new Error("--with-cuda and --without-cuda are not supported on macOS.");
430
+ const catalog = getNativeRuntimeCatalog(), pin = catalog.core, store = nativeStore(paths), owner = options.desktopRuntimeCapability ? resolveDesktopRuntimeOwner(options.desktopRuntimeCapability, paths.koedHome) : resolveKoedRuntimeOwner();
372
431
  const choice = options.cuda ?? "preserve", environment = options.environment ?? process.env;
373
432
  const signal = options.signal ?? new AbortController().signal;
374
433
  const plan = () => {
375
434
  signal.throwIfAborted();
376
- const selected = readNativeSelection(paths, catalog);
377
435
  const policy = embeddingPolicy(paths, environment);
436
+ assertMacPolicy(pin.target.platform, policy);
437
+ const selected = readNativeSelection(paths, catalog);
378
438
  const cuda = chooseCuda(catalog, selected?.cuda ?? null, choice, policy);
379
439
  if (selected && selected.pin.recipeId !== pin.recipeId && compareNativeVersions(pin.runtimeVersion, selected.pin.runtimeVersion) <= 0)
380
440
  throw new Error("Refusing a native core downgrade or replacement at the same runtime version.");
@@ -382,6 +442,8 @@ async function installReleaseRuntime(paths, options = {}) {
382
442
  return { selected, cuda, policy };
383
443
  };
384
444
  const before = await withStoppedRuntime(paths, owner, async () => {
445
+ await options.assertConfiguration?.();
446
+ options.phase?.("checking");
385
447
  const { selected, cuda, policy } = plan();
386
448
  for (const name of ["core", "selections", ...cuda ? ["cuda"] : []]) {
387
449
  const dir = resolve3(store, name);
@@ -389,8 +451,11 @@ async function installReleaseRuntime(paths, options = {}) {
389
451
  mkdirSync2(dir, { recursive: true, mode: 448 });
390
452
  }
391
453
  if (selected?.pin.recipeId === pin.recipeId && selected.cuda?.recipeId === cuda?.recipeId) {
454
+ if (choice === "with")
455
+ options.phase?.("inference");
392
456
  const validation = choice === "with" ? await validateStagedCuda(paths, selected.root, environment, {
393
- signal
457
+ signal,
458
+ requireModel: options.requireModel
394
459
  }) : void 0;
395
460
  const warning = recordStatus(paths, selected.id);
396
461
  return {
@@ -437,9 +502,17 @@ async function installReleaseRuntime(paths, options = {}) {
437
502
  const staging = mkdtempSync(resolve3(store, ".stage-"));
438
503
  try {
439
504
  const staged = /* @__PURE__ */ new Map();
440
- for (const asset of missing)
441
- staged.set(asset, await stageNativeAsset(asset, staging, signal, options.progress));
505
+ let downloaded = 0;
506
+ for (const asset of missing) {
507
+ staged.set(asset, await stageNativeAsset(asset, staging, signal, (event) => options.progress?.({
508
+ ...event,
509
+ transferredBytes: downloaded + event.transferredBytes,
510
+ totalBytes: downloadBytes
511
+ })));
512
+ downloaded += asset.archiveBytes;
513
+ }
442
514
  return await withStoppedRuntime(paths, owner, async () => {
515
+ await options.assertConfiguration?.();
443
516
  const { selected, cuda, policy } = plan();
444
517
  if ((selected?.id ?? null) !== before.previousId || before.cuda?.recipeId !== cuda?.recipeId)
445
518
  throw new Error("Another installer changed the selection. Inspect runtime status and retry.");
@@ -452,19 +525,25 @@ async function installReleaseRuntime(paths, options = {}) {
452
525
  }
453
526
  }
454
527
  const next = composeNativeSelection(paths, pin, staging, catalog, cuda);
455
- await probeCore(next.root, signal);
528
+ options.phase?.("verifying");
529
+ await probeCore(next.root, signal, pin.target.platform);
530
+ if (cuda)
531
+ options.phase?.("inference");
456
532
  const validation = cuda ? await validateStagedCuda(paths, next.root, environment, {
457
- signal
533
+ signal,
534
+ requireModel: options.requireModel
458
535
  }).catch((error) => {
459
536
  if (signal.aborted)
460
537
  throw error;
461
538
  throw preservedCudaFailure(error, choice, policy);
462
539
  }) : void 0;
463
540
  signal.throwIfAborted();
541
+ options.phase?.("activating");
542
+ signal.throwIfAborted();
464
543
  activateNativeSelection(paths, next.id);
465
544
  const warning = recordStatus(paths, next.id);
466
545
  const dropped = choice === "preserve" && selected?.cuda && !cuda;
467
- const message = dropped ? `CPU runtime selected. The prior CUDA add-on is incompatible; run ${releaseInstallCommand} --with-cuda for a compatible pair. Run koed start when ready.` : `${cuda ? "CPU core and CUDA add-on" : "CPU runtime"} installed. Run koed start when ready.`;
546
+ const message = dropped ? `CPU runtime selected. The prior CUDA add-on is incompatible; run ${releaseInstallCommand} --with-cuda for a compatible pair. Run koed start when ready.` : `${cuda ? "CPU core and CUDA add-on" : pin.target.platform === "macos" ? "Metal runtime" : "CPU runtime"} installed. Run koed start when ready.`;
468
547
  return {
469
548
  ok: true,
470
549
  provider: "release",
@@ -506,10 +585,15 @@ function resolveSelectedCoreForStart(paths, environment = process.env, useSelect
506
585
  assertReleaseHost();
507
586
  const catalog = getNativeRuntimeCatalog(), selected = readNativeSelection(paths, catalog);
508
587
  assertStartableCore(selected.pin, catalog);
509
- if (useSelectedLlama && embeddingPolicy(paths, environment) === "cuda" && !selected.cuda)
588
+ const policy = useSelectedLlama ? embeddingPolicy(paths, environment) : null;
589
+ if (policy)
590
+ assertMacPolicy(catalog.core.target.platform, policy);
591
+ if (useSelectedLlama && policy === "cuda" && !selected.cuda)
510
592
  throw new Error("The forced CUDA policy requires a selected CUDA add-on.");
511
593
  return selected.root;
512
594
  } catch (cause) {
595
+ if (cause instanceof MacCudaPolicyError || cause instanceof NativeSelectionTargetError)
596
+ throw cause;
513
597
  const command = environment.KOED_EMBEDDING_ACCELERATION?.trim().toLowerCase() === "cuda" ? releaseInstallCommand + " --with-cuda" : releaseInstallCommand;
514
598
  throw new Error(`Cannot start the release-managed native runtime: ${cause instanceof Error ? cause.message : String(cause)}. Stop Koed, inspect runtime status, and run ${command}.`, { cause });
515
599
  }
@@ -4,13 +4,15 @@ import {
4
4
  isKoedServerCliEntrypoint,
5
5
  runKoedServerCli,
6
6
  shouldExitPackagedSupervisor
7
- } from "./chunk-FYYRFX4U.js";
7
+ } from "./chunk-CX73L6YS.js";
8
8
  import {
9
9
  startKoedServerDaemon
10
10
  } from "./chunk-7FSHVVTZ.js";
11
11
  import "./chunk-TSAYTRX3.js";
12
12
  import "./chunk-YZLQZU5E.js";
13
- import "./chunk-V67IQB7H.js";
13
+ import "./chunk-OG7G6DIR.js";
14
+ import "./chunk-VWB3VEOL.js";
15
+ import "./chunk-FSNLU46W.js";
14
16
  import "./chunk-BTS4ZTF3.js";
15
17
  export {
16
18
  isKoedServerCliEntrypoint,
@@ -3,7 +3,7 @@ import {
3
3
  PINNED_PRIVACY_MODEL_FILES,
4
4
  PINNED_PRIVACY_MODEL_ID,
5
5
  PINNED_PRIVACY_MODEL_REVISION
6
- } from "./chunk-ZOHNXUDY.js";
6
+ } from "./chunk-VWB3VEOL.js";
7
7
 
8
8
  // packages/koed-server/dist/privacy-model-runtime.js
9
9
  import { createHash, randomUUID } from "node:crypto";
@@ -1,10 +1,13 @@
1
1
  import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
+ import {
3
+ privateNodeLauncher
4
+ } from "./chunk-2YCDKSKW.js";
2
5
  import {
3
6
  resolveKoedHome
4
7
  } from "./chunk-TSAYTRX3.js";
5
8
  import {
6
9
  createPdsApplicationSecretStore
7
- } from "./chunk-ZOHNXUDY.js";
10
+ } from "./chunk-VWB3VEOL.js";
8
11
 
9
12
  // packages/koed-server/dist/application-secret-provider.js
10
13
  import { existsSync } from "node:fs";
@@ -24,7 +27,9 @@ var bundledPdsSecretProviderEnvironment = (environment) => {
24
27
  return {
25
28
  ...environment,
26
29
  PDS_SECRET_PROVIDER: "headless",
27
- PDS_SECRET_PROVIDER_COMMAND: process.execPath,
30
+ // Providers run with a restricted environment, so use the private Node
31
+ // launcher that supplies its own library path.
32
+ PDS_SECRET_PROVIDER_COMMAND: privateNodeLauncher(),
28
33
  PDS_SECRET_PROVIDER_COMMAND_ARGS_JSON: JSON.stringify([
29
34
  bundledCliPath(),
30
35
  "secret-provider"
@@ -1,7 +1,7 @@
1
1
  import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
2
  import {
3
3
  productionNativeRuntimeCatalog
4
- } from "./chunk-7EGSY3E4.js";
4
+ } from "./chunk-ULLAURFV.js";
5
5
  import {
6
6
  external_exports
7
7
  } from "./chunk-FSNLU46W.js";
@@ -66,7 +66,7 @@ var cudaPin = external_exports.object({
66
66
  }).strict()
67
67
  }).strict().refine((pin) => retainedUrl("cuda", pin), "Native CUDA URL does not identify the retained recipe release.");
68
68
  var nativeKind = (pin) => "components" in pin ? "core" : "cuda";
69
- var compatibleCuda = (core, cuda) => core.components.llamaCpp.revision === cuda.llamaCpp.revision && core.components.llamaCpp.version === cuda.llamaCpp.version && core.contracts.layout === cuda.contracts.layout && core.contracts.embedding === cuda.contracts.embedding;
69
+ var compatibleCuda = (core, cuda) => core.target.platform === "linux" && "revision" in core.components.llamaCpp && core.components.llamaCpp.revision === cuda.llamaCpp.revision && core.components.llamaCpp.version === cuda.llamaCpp.version && core.contracts.layout === cuda.contracts.layout && core.contracts.embedding === cuda.contracts.embedding;
70
70
  var compareNativeVersions = (left, right) => {
71
71
  const a = version.parse(left).split(".").map(Number);
72
72
  const b = version.parse(right).split(".").map(Number);
@@ -83,6 +83,53 @@ var catalog = external_exports.object({
83
83
  core: corePin,
84
84
  cuda: cudaPin.nullable()
85
85
  }).strict().refine((value) => !value.cuda || compatibleCuda(value.core, value.cuda), "Pinned CUDA add-on does not match the core revision and contracts.").refine((value) => compareNativeVersions(value.core.runtimeVersion, value.minimumCoreVersion) >= 0, "Pinned native core is below the compiled minimum runtime version.");
86
+ var macCorePin = external_exports.object({
87
+ ...corePin.shape,
88
+ target: external_exports.object({
89
+ platform: external_exports.literal("macos"),
90
+ architecture: external_exports.literal("arm64"),
91
+ minimumVersion: external_exports.literal("14.0")
92
+ }).strict(),
93
+ components: external_exports.object({
94
+ postgres: external_exports.object({
95
+ major: external_exports.literal(17),
96
+ version: external_exports.string().regex(/^17\.\d+$/)
97
+ }).strict(),
98
+ pgvector: external_exports.object({ version: external_exports.literal("0.8.3") }).strict(),
99
+ llamaCpp: external_exports.object({ version: external_exports.string().regex(/^b\d+$/) }).strict()
100
+ }).strict()
101
+ }).strict().refine((pin) => {
102
+ const prefix = "https://github.com/koed-labs/koed/releases/download/";
103
+ const [tag, archive, ...extra] = pin.url.slice(prefix.length).split("/");
104
+ return pin.url.startsWith(prefix) && extra.length === 0 && archive === `koed-native-core-${pin.recipeId}-macos-arm64.tar.gz` && (tag === `native-core-${pin.recipeId}` || /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(tag ?? ""));
105
+ }, "Native macOS core URL does not identify the retained recipe release.");
106
+ var macCatalog = external_exports.object({
107
+ schemaVersion: external_exports.literal(1),
108
+ minimumCoreVersion: version,
109
+ core: macCorePin,
110
+ cuda: external_exports.null()
111
+ }).strict().refine((value) => compareNativeVersions(value.core.runtimeVersion, value.minimumCoreVersion) >= 0);
112
+ var compiledCatalog = external_exports.object({
113
+ schemaVersion: external_exports.literal(2),
114
+ linux: catalog.nullable(),
115
+ macos: macCatalog.nullable()
116
+ }).strict();
117
+ function validateCompiledNativeRuntimeCatalog(value) {
118
+ const result = compiledCatalog.safeParse(value);
119
+ if (!result.success)
120
+ throw new Error(`Invalid compiled native runtime catalog: ${result.error.message}`);
121
+ return result.data;
122
+ }
123
+ function selectNativeRuntimeCatalog(value, platform, architecture) {
124
+ if (!(platform === "linux" && architecture === "x64" || platform === "darwin" && architecture === "arm64"))
125
+ throw new Error("Unsupported release runtime host. Requires Linux x64 or macOS arm64.");
126
+ const isLegacy = typeof value === "object" && value !== null && "schemaVersion" in value && value.schemaVersion === 1;
127
+ const compiled = isLegacy ? { linux: validateNativeRuntimeCatalog(value), macos: null } : validateCompiledNativeRuntimeCatalog(value);
128
+ const selected = platform === "linux" ? compiled.linux : compiled.macos;
129
+ if (!selected)
130
+ throw new Error("This Control Plane has no reviewed native runtime pin for this host. Use a trusted release with native runtime support.");
131
+ return selected;
132
+ }
86
133
  var validateNativeRuntimeCatalog = (value) => {
87
134
  const parsed = catalog.safeParse(value);
88
135
  if (!parsed.success)
@@ -92,13 +139,14 @@ var validateNativeRuntimeCatalog = (value) => {
92
139
  var getNativeRuntimeCatalog = () => {
93
140
  if (productionNativeRuntimeCatalog === null)
94
141
  throw new Error("This Control Plane has no reviewed native runtime pin. Use a trusted release with native runtime support.");
95
- return validateNativeRuntimeCatalog(productionNativeRuntimeCatalog);
142
+ return selectNativeRuntimeCatalog(productionNativeRuntimeCatalog, process.platform, process.arch);
96
143
  };
97
144
 
98
145
  export {
99
146
  nativeKind,
100
147
  compatibleCuda,
101
148
  compareNativeVersions,
149
+ selectNativeRuntimeCatalog,
102
150
  validateNativeRuntimeCatalog,
103
151
  getNativeRuntimeCatalog
104
152
  };
@@ -6,14 +6,15 @@ import {
6
6
  personalSyncProviderEnvironment,
7
7
  redeemPairingLink,
8
8
  runPersonalSyncCommand
9
- } from "./chunk-CHMH4LH5.js";
10
- import "./chunk-EA4QDDQA.js";
11
- import "./chunk-SRKIBFOE.js";
9
+ } from "./chunk-XW7AXRDI.js";
10
+ import "./chunk-GEIN6UIL.js";
11
+ import "./chunk-2YCDKSKW.js";
12
+ import "./chunk-A2TMTAAS.js";
12
13
  import "./chunk-TSAYTRX3.js";
13
14
  import "./chunk-YZLQZU5E.js";
14
15
  import "./chunk-W2HNI6AA.js";
15
16
  import "./chunk-7NXKPDF3.js";
16
- import "./chunk-ZOHNXUDY.js";
17
+ import "./chunk-VWB3VEOL.js";
17
18
  import "./chunk-FSNLU46W.js";
18
19
  import "./chunk-BTS4ZTF3.js";
19
20
  export {
@@ -2,40 +2,41 @@ import { createRequire as createKoedRequire } from "node:module"; const require
2
2
  import {
3
3
  createCliServiceContext,
4
4
  printJson
5
- } from "./chunk-WDFERJG3.js";
6
- import "./chunk-SHLRINKO.js";
7
- import "./chunk-CHMH4LH5.js";
8
- import "./chunk-EA4QDDQA.js";
5
+ } from "./chunk-TAQWNZVD.js";
6
+ import "./chunk-XSOQ2U5H.js";
7
+ import "./chunk-XW7AXRDI.js";
8
+ import "./chunk-GEIN6UIL.js";
9
+ import "./chunk-2YCDKSKW.js";
9
10
  import "./chunk-JYK6UL6D.js";
10
- import "./chunk-WPIEF4LY.js";
11
+ import "./chunk-ULUSFNAE.js";
11
12
  import {
12
13
  connectAiClientAfterSetup,
13
14
  disconnectAiClientThenRemove,
14
15
  verifyAiClientIntegration
15
- } from "./chunk-6KS67EQE.js";
16
+ } from "./chunk-KBECHDUE.js";
16
17
  import {
17
18
  evaluateAiClientReadiness
18
- } from "./chunk-EDPNYIX5.js";
19
+ } from "./chunk-XTQYFCVY.js";
19
20
  import "./chunk-QT24SAW6.js";
20
21
  import "./chunk-TISYUUEJ.js";
21
- import "./chunk-ALJUSOF7.js";
22
- import "./chunk-SRKIBFOE.js";
22
+ import "./chunk-YY7NMZGD.js";
23
+ import "./chunk-A2TMTAAS.js";
23
24
  import "./chunk-7FSHVVTZ.js";
24
25
  import "./chunk-TSAYTRX3.js";
25
26
  import "./chunk-YZLQZU5E.js";
26
27
  import "./chunk-W2HNI6AA.js";
27
- import "./chunk-V67IQB7H.js";
28
- import "./chunk-FN3HUUO2.js";
28
+ import "./chunk-OG7G6DIR.js";
29
+ import "./chunk-I5XO5FL4.js";
29
30
  import "./chunk-T6UB5PNX.js";
30
31
  import "./chunk-7NXKPDF3.js";
31
- import "./chunk-ZUDSZGVO.js";
32
- import "./chunk-ZIOKV2X6.js";
33
- import "./chunk-QRKHHWJJ.js";
34
- import "./chunk-7EGSY3E4.js";
32
+ import "./chunk-YDZEMIAH.js";
33
+ import "./chunk-MFPPURFE.js";
34
+ import "./chunk-H7ETSD25.js";
35
+ import "./chunk-ULLAURFV.js";
35
36
  import "./chunk-IY2HRXOZ.js";
36
- import "./chunk-4OO6VAU3.js";
37
- import "./chunk-RCR4XPE3.js";
38
- import "./chunk-ZOHNXUDY.js";
37
+ import "./chunk-G54Q5W6M.js";
38
+ import "./chunk-3VNLZCMB.js";
39
+ import "./chunk-VWB3VEOL.js";
39
40
  import "./chunk-FSNLU46W.js";
40
41
  import "./chunk-BTS4ZTF3.js";
41
42