@atomic-chat/core 0.21.0 → 0.21.2

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 (186) hide show
  1. package/dist/backend/advisor/advisor.js +11 -2
  2. package/dist/backend/advisor/advisor.js.map +1 -1
  3. package/dist/backend/install/cuda-guard.d.ts +62 -0
  4. package/dist/backend/install/cuda-guard.js +80 -0
  5. package/dist/backend/install/cuda-guard.js.map +1 -0
  6. package/dist/backend/install/cuda-runtime-source.d.ts +76 -0
  7. package/dist/backend/install/cuda-runtime-source.js +294 -0
  8. package/dist/backend/install/cuda-runtime-source.js.map +1 -0
  9. package/dist/backend/install/index.d.ts +3 -0
  10. package/dist/backend/install/index.js +3 -0
  11. package/dist/backend/install/index.js.map +1 -1
  12. package/dist/backend/install/runtime-backend.d.ts +30 -3
  13. package/dist/backend/install/runtime-backend.js +106 -28
  14. package/dist/backend/install/runtime-backend.js.map +1 -1
  15. package/dist/backend/install/service.d.ts +42 -24
  16. package/dist/backend/install/service.js +176 -31
  17. package/dist/backend/install/service.js.map +1 -1
  18. package/dist/backend/install/windows-launch-check.d.ts +72 -0
  19. package/dist/backend/install/windows-launch-check.js +173 -0
  20. package/dist/backend/install/windows-launch-check.js.map +1 -0
  21. package/dist/backend/installed/installed.d.ts +13 -0
  22. package/dist/backend/installed/installed.js +32 -0
  23. package/dist/backend/installed/installed.js.map +1 -1
  24. package/dist/backend/select/bad-backends.d.ts +68 -0
  25. package/dist/backend/select/bad-backends.js +136 -0
  26. package/dist/backend/select/bad-backends.js.map +1 -0
  27. package/dist/backend/select/features.d.ts +18 -1
  28. package/dist/backend/select/features.js +29 -1
  29. package/dist/backend/select/features.js.map +1 -1
  30. package/dist/backend/select/index.d.ts +1 -0
  31. package/dist/backend/select/index.js +1 -0
  32. package/dist/backend/select/index.js.map +1 -1
  33. package/dist/backend/turboquant.d.ts +8 -0
  34. package/dist/backend/turboquant.js +37 -9
  35. package/dist/backend/turboquant.js.map +1 -1
  36. package/dist/cli/main.d.ts +1 -1
  37. package/dist/contracts/diagnostics.d.ts +21 -0
  38. package/dist/contracts/diagnostics.js +71 -0
  39. package/dist/contracts/diagnostics.js.map +1 -0
  40. package/dist/contracts/errors.d.ts +18 -76
  41. package/dist/contracts/errors.js +145 -2
  42. package/dist/contracts/errors.js.map +1 -1
  43. package/dist/contracts/hardware.d.ts +8 -0
  44. package/dist/contracts/index.d.ts +2 -0
  45. package/dist/contracts/index.js +2 -0
  46. package/dist/contracts/index.js.map +1 -1
  47. package/dist/contracts/load-diag.d.ts +34 -0
  48. package/dist/contracts/load-diag.js +48 -0
  49. package/dist/contracts/load-diag.js.map +1 -0
  50. package/dist/core/atomic-core.d.ts +1 -1
  51. package/dist/core/atomic-core.js +2 -1
  52. package/dist/core/atomic-core.js.map +1 -1
  53. package/dist/core/create.js +25 -15
  54. package/dist/core/create.js.map +1 -1
  55. package/dist/core/managed-environment.d.ts +2 -0
  56. package/dist/core/managed-environment.js +2 -0
  57. package/dist/core/managed-environment.js.map +1 -1
  58. package/dist/decision/service.d.ts +2 -23
  59. package/dist/decision/service.js +27 -0
  60. package/dist/decision/service.js.map +1 -1
  61. package/dist/decision/wiring.d.ts +2 -0
  62. package/dist/decision/wiring.js +1 -6
  63. package/dist/decision/wiring.js.map +1 -1
  64. package/dist/diffusion/errors.js +3 -3
  65. package/dist/diffusion/errors.js.map +1 -1
  66. package/dist/diffusion/jobs.js +1 -0
  67. package/dist/diffusion/jobs.js.map +1 -1
  68. package/dist/diffusion/remote-job.js +1 -0
  69. package/dist/diffusion/remote-job.js.map +1 -1
  70. package/dist/diffusion/service.d.ts +2 -6
  71. package/dist/diffusion/service.js +1 -0
  72. package/dist/diffusion/service.js.map +1 -1
  73. package/dist/diffusion/session.d.ts +2 -5
  74. package/dist/diffusion/session.js +1 -0
  75. package/dist/diffusion/session.js.map +1 -1
  76. package/dist/diffusion/wiring.d.ts +2 -0
  77. package/dist/diffusion/wiring.js +1 -5
  78. package/dist/diffusion/wiring.js.map +1 -1
  79. package/dist/downloads/archive.js +8 -3
  80. package/dist/downloads/archive.js.map +1 -1
  81. package/dist/downloads/disk.d.ts +18 -0
  82. package/dist/downloads/disk.js +32 -1
  83. package/dist/downloads/disk.js.map +1 -1
  84. package/dist/downloads/downloader.d.ts +2 -18
  85. package/dist/downloads/downloader.js +208 -97
  86. package/dist/downloads/downloader.js.map +1 -1
  87. package/dist/downloads/fs-retry.d.ts +27 -0
  88. package/dist/downloads/fs-retry.js +40 -0
  89. package/dist/downloads/fs-retry.js.map +1 -0
  90. package/dist/downloads/index.d.ts +1 -0
  91. package/dist/downloads/index.js +1 -0
  92. package/dist/downloads/index.js.map +1 -1
  93. package/dist/downloads/protocol.d.ts +6 -2
  94. package/dist/downloads/protocol.js +27 -5
  95. package/dist/downloads/protocol.js.map +1 -1
  96. package/dist/embedding/service.d.ts +2 -18
  97. package/dist/embedding/service.js +21 -1
  98. package/dist/embedding/service.js.map +1 -1
  99. package/dist/embedding/wiring.d.ts +2 -0
  100. package/dist/embedding/wiring.js +1 -6
  101. package/dist/embedding/wiring.js.map +1 -1
  102. package/dist/hardware/index.d.ts +1 -0
  103. package/dist/hardware/index.js +1 -0
  104. package/dist/hardware/index.js.map +1 -1
  105. package/dist/hardware/probe-common.d.ts +9 -1
  106. package/dist/hardware/probe-common.js.map +1 -1
  107. package/dist/hardware/probe-windows.d.ts +10 -2
  108. package/dist/hardware/probe-windows.js +65 -10
  109. package/dist/hardware/probe-windows.js.map +1 -1
  110. package/dist/hardware/probe.js +1 -1
  111. package/dist/hardware/probe.js.map +1 -1
  112. package/dist/hardware/service.d.ts +11 -0
  113. package/dist/hardware/service.js +31 -4
  114. package/dist/hardware/service.js.map +1 -1
  115. package/dist/hardware/windows-registry.d.ts +80 -0
  116. package/dist/hardware/windows-registry.js +197 -0
  117. package/dist/hardware/windows-registry.js.map +1 -0
  118. package/dist/lock/instance-lock.js +7 -3
  119. package/dist/lock/instance-lock.js.map +1 -1
  120. package/dist/remote-access/manager.d.ts +2 -0
  121. package/dist/remote-access/manager.js +18 -2
  122. package/dist/remote-access/manager.js.map +1 -1
  123. package/dist/runtime/environment/service.d.ts +2 -14
  124. package/dist/runtime/environment/service.js +10 -0
  125. package/dist/runtime/environment/service.js.map +1 -1
  126. package/dist/runtime/environment/wiring.d.ts +2 -23
  127. package/dist/runtime/environment/wiring.js +1 -0
  128. package/dist/runtime/environment/wiring.js.map +1 -1
  129. package/dist/runtime/llamacpp/args.d.ts +11 -0
  130. package/dist/runtime/llamacpp/args.js +28 -3
  131. package/dist/runtime/llamacpp/args.js.map +1 -1
  132. package/dist/runtime/llamacpp/devices.d.ts +11 -0
  133. package/dist/runtime/llamacpp/devices.js +22 -0
  134. package/dist/runtime/llamacpp/devices.js.map +1 -1
  135. package/dist/runtime/llamacpp/errors.d.ts +34 -4
  136. package/dist/runtime/llamacpp/errors.js +105 -22
  137. package/dist/runtime/llamacpp/errors.js.map +1 -1
  138. package/dist/runtime/llamacpp/index.d.ts +1 -0
  139. package/dist/runtime/llamacpp/index.js +1 -0
  140. package/dist/runtime/llamacpp/index.js.map +1 -1
  141. package/dist/runtime/llamacpp/load-failure.d.ts +52 -0
  142. package/dist/runtime/llamacpp/load-failure.js +105 -0
  143. package/dist/runtime/llamacpp/load-failure.js.map +1 -0
  144. package/dist/runtime/llamacpp/load-plan.d.ts +5 -0
  145. package/dist/runtime/llamacpp/load-plan.js +34 -4
  146. package/dist/runtime/llamacpp/load-plan.js.map +1 -1
  147. package/dist/runtime/llamacpp/runtime.d.ts +24 -1
  148. package/dist/runtime/llamacpp/runtime.js +116 -27
  149. package/dist/runtime/llamacpp/runtime.js.map +1 -1
  150. package/dist/runtime/shared/env.js +13 -15
  151. package/dist/runtime/shared/env.js.map +1 -1
  152. package/dist/server/public/errors.d.ts +2 -0
  153. package/dist/server/public/errors.js +6 -2
  154. package/dist/server/public/errors.js.map +1 -1
  155. package/dist/server/public/forward.js +22 -18
  156. package/dist/server/public/forward.js.map +1 -1
  157. package/dist/settings/store.js +1 -1
  158. package/dist/settings/store.js.map +1 -1
  159. package/dist/telemetry/diagnostics.d.ts +14 -0
  160. package/dist/telemetry/diagnostics.js +289 -0
  161. package/dist/telemetry/diagnostics.js.map +1 -0
  162. package/dist/telemetry/envelope.d.ts +1 -1
  163. package/dist/telemetry/envelope.js +57 -28
  164. package/dist/telemetry/envelope.js.map +1 -1
  165. package/dist/telemetry/index.d.ts +1 -0
  166. package/dist/telemetry/index.js +1 -0
  167. package/dist/telemetry/index.js.map +1 -1
  168. package/dist/telemetry/policy.d.ts +1 -1
  169. package/dist/telemetry/policy.js +45 -2
  170. package/dist/telemetry/policy.js.map +1 -1
  171. package/dist/telemetry/reporter.d.ts +1 -0
  172. package/dist/telemetry/reporter.js +0 -0
  173. package/dist/telemetry/reporter.js.map +1 -1
  174. package/dist/telemetry/reports.d.ts +2 -7
  175. package/dist/telemetry/reports.js +34 -29
  176. package/dist/telemetry/reports.js.map +1 -1
  177. package/dist/telemetry/stack.d.ts +1 -1
  178. package/dist/telemetry/stack.js +8 -1
  179. package/dist/telemetry/stack.js.map +1 -1
  180. package/dist/telemetry/subscribe.d.ts +1 -1
  181. package/dist/telemetry/subscribe.js +7 -5
  182. package/dist/telemetry/subscribe.js.map +1 -1
  183. package/dist/telemetry/types.d.ts +3 -2
  184. package/dist/version.d.ts +1 -1
  185. package/dist/version.js +1 -1
  186. package/package.json +1 -1
@@ -22,5 +22,16 @@ export declare function findMemoryPattern(text: string): {
22
22
  /** First whitespace token as i32 (`"7721 MiB free"` → 7721). */
23
23
  export declare function parseMemoryValue(memStr: string): number | undefined;
24
24
  export declare function parseDeviceLine(rawLine: string): DeviceInfo | undefined;
25
+ /**
26
+ * A `--device` value checked against what the build lists: the names it has (llama.cpp matches them
27
+ * case-insensitively, `ggml_backend_dev_by_name`) and `none` are kept in the order given, every other
28
+ * name is dropped. llama-server exits on a name it does not have ("use --list-devices to see a list of
29
+ * available devices"), which is what a value copied from a CUDA build does on a Vulkan or ROCm one.
30
+ * `device` is `''` when nothing is left: llama.cpp then picks its devices itself.
31
+ */
32
+ export declare function validateDeviceList(requested: string, devices: readonly DeviceInfo[]): {
33
+ device: string;
34
+ dropped: string[];
35
+ };
25
36
  /** Throws `DEVICE_LIST_PARSE_FAILED` (details = the whole output) when the header is missing. */
26
37
  export declare function parseDeviceOutput(output: string): DeviceInfo[];
@@ -63,6 +63,28 @@ export function parseDeviceLine(rawLine) {
63
63
  return undefined;
64
64
  return { id, name, mem: total, free };
65
65
  }
66
+ /**
67
+ * A `--device` value checked against what the build lists: the names it has (llama.cpp matches them
68
+ * case-insensitively, `ggml_backend_dev_by_name`) and `none` are kept in the order given, every other
69
+ * name is dropped. llama-server exits on a name it does not have ("use --list-devices to see a list of
70
+ * available devices"), which is what a value copied from a CUDA build does on a Vulkan or ROCm one.
71
+ * `device` is `''` when nothing is left: llama.cpp then picks its devices itself.
72
+ */
73
+ export function validateDeviceList(requested, devices) {
74
+ const known = new Set(devices.map((d) => d.id.toLowerCase()));
75
+ const kept = [];
76
+ const dropped = [];
77
+ for (const raw of String(requested).split(',')) {
78
+ const name = raw.trim();
79
+ if (name === '')
80
+ continue;
81
+ if (name.toLowerCase() === 'none' || known.has(name.toLowerCase()))
82
+ kept.push(name);
83
+ else
84
+ dropped.push(name);
85
+ }
86
+ return { device: kept.join(','), dropped };
87
+ }
66
88
  /** Throws `DEVICE_LIST_PARSE_FAILED` (details = the whole output) when the header is missing. */
67
89
  export function parseDeviceOutput(output) {
68
90
  const devices = [];
@@ -1 +1 @@
1
- {"version":3,"file":"devices.js","sourceRoot":"","sources":["../../../src/runtime/llamacpp/devices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAA;AAElD,qFAAqF;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AI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,cAAc,EAAE,CAAC;YAClC,YAAY,GAAG,IAAI,CAAA;YACnB,SAAQ;QACV,CAAC;QACD,IAAI,CAAC,YAAY,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,SAAQ;QAChD,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IACD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,eAAe,CACvB,0BAA0B,EAC1B,oEAAoE,EACpE,MAAM,CACP,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -2,8 +2,8 @@
2
2
  * Classification of a failed `llama-server` process into the app's error contract. Port of
3
3
  * `src-tauri/plugins/tauri-plugin-llamacpp-upstream/src/error.rs` (`LlamacppError::from_stderr`,
4
4
  * `from_exit_status`, `from_process_output`). Pinned by `test/contract/errors.test.ts`. The
5
- * TurboQuant fork's `error.rs` differs in one rule, `wrong number of tensors` (app commit
6
- * `ec1fd3ea7`), so the provider is a parameter.
5
+ * recorded desktop fixture predates the tensor-layout correction: a tensor-count mismatch alone
6
+ * is backend incompatibility on every provider (2026-11-02-tensor-layout-error).
7
7
  *
8
8
  * The cascade is ordered: the first matching group wins. Messages are the app's user-facing strings
9
9
  * and are part of the contract. `details` is always set (the raw stream), even when empty.
@@ -18,18 +18,48 @@ export interface ExitInfo {
18
18
  }
19
19
  /** Normalise a Node signal name to the Unix number Rust sees. */
20
20
  export declare function signalNumber(signal: number | string | null): number | null;
21
+ /**
22
+ * NTSTATUS codes a Windows process ends with when the loader gives up before `main`, so it prints
23
+ * nothing of its own — the same set `src/diffusion/install.ts` and `src/audio/install.ts` read for
24
+ * their engines: a missing DLL, a missing ordinal or entry point, a bad image, a DLL whose init failed.
25
+ */
26
+ export declare const WINDOWS_LOADER_FAILURES: ReadonlyMap<number, string>;
27
+ /** STATUS_ILLEGAL_INSTRUCTION: the build uses an instruction this CPU does not have. */
28
+ export declare const WINDOWS_ILLEGAL_INSTRUCTION = 3221225501;
29
+ /**
30
+ * An exit status as the load diagnostics spell it: `0x`-prefixed upper-case hex on Windows (NTSTATUS
31
+ * codes arrive signed or unsigned), decimal elsewhere; `undefined` when the process was killed by a
32
+ * signal or never started.
33
+ */
34
+ export declare function formatExitCode(code: number | null, platform: NodeJS.Platform): string | undefined;
21
35
  /** A hard native crash (segfault / abort) rather than a normal non-zero exit. */
22
36
  export declare function isCrashExit(exit: ExitInfo, platform: NodeJS.Platform): boolean;
37
+ export declare const GPU_BACKEND_INCOMPATIBLE_MESSAGE = "This GPU build of the model engine does not run on this graphics card with its current driver. Update the NVIDIA graphics driver, or switch to another backend (CUDA 12, Vulkan or CPU).";
38
+ export declare const ENGINE_BINARY_BROKEN_MESSAGE = "The model engine could not load a library it needs, so it did not start. Its files may be incomplete or blocked by antivirus software: reinstall this backend or switch to another one.";
39
+ export declare const CPU_INSTRUCTION_UNSUPPORTED_MESSAGE = "The model engine stopped on a processor instruction this computer does not have. Switch to another backend, such as the CPU build, which picks the instructions this processor supports.";
23
40
  export declare const ARGUMENT_REJECTED_MESSAGE = "This llama.cpp backend does not accept one of the arguments it was started with. If you added custom arguments to this model, remove them; otherwise switch to another backend version or update Atomic Chat.";
24
41
  export declare const GENERIC_PROCESS_ERROR_MESSAGE = "The model process encountered an unexpected error.";
25
42
  export declare const CRASH_MESSAGE = "The model process crashed unexpectedly (access violation / segfault). This usually means the model is incompatible with this backend, or its speculative-decoding (MTP) configuration is unsupported here.";
26
43
  /** `LlamacppError::from_stderr`: ordered substring cascade over the lowercased stream. */
27
44
  export declare function classifyStderr(stderr: string, provider?: LocalProviderId): AtomicCoreError;
28
- /** `LlamacppError::from_exit_status`: a recognised crash upgrades the generic error's message. */
45
+ /**
46
+ * A Windows exit status that names its own cause when stderr named none: the loader gave up before
47
+ * `main` (`ENGINE_BINARY_BROKEN`), or the build hit an instruction this CPU lacks
48
+ * (`CPU_INSTRUCTION_UNSUPPORTED`). `undefined` for anything else, and off Windows.
49
+ */
50
+ export declare function windowsExitCause(exit: ExitInfo, platform: NodeJS.Platform): {
51
+ code: 'ENGINE_BINARY_BROKEN' | 'CPU_INSTRUCTION_UNSUPPORTED';
52
+ message: string;
53
+ } | undefined;
54
+ /**
55
+ * `LlamacppError::from_exit_status`: a recognised crash upgrades the generic error's message; beyond
56
+ * the app, a Windows loader or illegal-instruction status that stderr did not explain gets its own code.
57
+ */
29
58
  export declare function classifyExit(exit: ExitInfo, stderr: string, platform: NodeJS.Platform, provider?: LocalProviderId): AtomicCoreError;
30
59
  /**
31
60
  * `LlamacppError::from_process_output`: stderr classification wins; otherwise try stdout (several
32
61
  * llama.cpp builds report loader failures there); otherwise keep the exit-status error but hand the
33
- * caller stdout as details when stderr is blank.
62
+ * caller stdout as details when stderr is blank. A code read from the Windows exit status alone ranks
63
+ * with the exit status, below stdout.
34
64
  */
35
65
  export declare function classifyProcessOutput(exit: ExitInfo, stderr: string, stdout: string, platform: NodeJS.Platform, provider?: LocalProviderId): AtomicCoreError;
@@ -2,8 +2,8 @@
2
2
  * Classification of a failed `llama-server` process into the app's error contract. Port of
3
3
  * `src-tauri/plugins/tauri-plugin-llamacpp-upstream/src/error.rs` (`LlamacppError::from_stderr`,
4
4
  * `from_exit_status`, `from_process_output`). Pinned by `test/contract/errors.test.ts`. The
5
- * TurboQuant fork's `error.rs` differs in one rule, `wrong number of tensors` (app commit
6
- * `ec1fd3ea7`), so the provider is a parameter.
5
+ * recorded desktop fixture predates the tensor-layout correction: a tensor-count mismatch alone
6
+ * is backend incompatibility on every provider (2026-11-02-tensor-layout-error).
7
7
  *
8
8
  * The cascade is ordered: the first matching group wins. Messages are the app's user-facing strings
9
9
  * and are part of the contract. `details` is always set (the raw stream), even when empty.
@@ -36,6 +36,32 @@ export function signalNumber(signal) {
36
36
  }
37
37
  /** Windows: STATUS_ACCESS_VIOLATION / STATUS_STACK_OVERFLOW / STATUS_STACK_BUFFER_OVERRUN. */
38
38
  const WINDOWS_CRASH_CODES = new Set([0xc000_0005, 0xc000_00fd, 0xc000_0409]);
39
+ /**
40
+ * NTSTATUS codes a Windows process ends with when the loader gives up before `main`, so it prints
41
+ * nothing of its own — the same set `src/diffusion/install.ts` and `src/audio/install.ts` read for
42
+ * their engines: a missing DLL, a missing ordinal or entry point, a bad image, a DLL whose init failed.
43
+ */
44
+ export const WINDOWS_LOADER_FAILURES = new Map([
45
+ [0xc000_0135, 'STATUS_DLL_NOT_FOUND'],
46
+ [0xc000_0138, 'STATUS_ORDINAL_NOT_FOUND'],
47
+ [0xc000_0139, 'STATUS_ENTRYPOINT_NOT_FOUND'],
48
+ [0xc000_007b, 'STATUS_INVALID_IMAGE_FORMAT'],
49
+ [0xc000_0142, 'STATUS_DLL_INIT_FAILED'],
50
+ ]);
51
+ /** STATUS_ILLEGAL_INSTRUCTION: the build uses an instruction this CPU does not have. */
52
+ export const WINDOWS_ILLEGAL_INSTRUCTION = 0xc000_001d;
53
+ /**
54
+ * An exit status as the load diagnostics spell it: `0x`-prefixed upper-case hex on Windows (NTSTATUS
55
+ * codes arrive signed or unsigned), decimal elsewhere; `undefined` when the process was killed by a
56
+ * signal or never started.
57
+ */
58
+ export function formatExitCode(code, platform) {
59
+ if (code === null)
60
+ return undefined;
61
+ if (platform !== 'win32')
62
+ return String(code);
63
+ return `0x${(code >>> 0).toString(16).toUpperCase()}`;
64
+ }
39
65
  /** A hard native crash (segfault / abort) rather than a normal non-zero exit. */
40
66
  export function isCrashExit(exit, platform) {
41
67
  if (platform === 'win32') {
@@ -48,11 +74,25 @@ const includesAny = (lower, needles) => needles.some((n) => lower.includes(n));
48
74
  /**
49
75
  * TurboQuant (`llamacpp`) can know an architecture and still expect a tensor layout that differs
50
76
  * from a valid upstream GGUF: re-downloading cannot fix that, and the same file loads in stock
51
- * llama.cpp, so there the mismatch is an unsupported architecture. Upstream it still means a
52
- * damaged file.
77
+ * llama.cpp, so there the mismatch is an unsupported architecture. Ollama conversions can differ
78
+ * from upstream too, so on any build a tensor count alone does not prove a damaged file.
53
79
  */
54
80
  const TENSOR_COUNT_MISMATCH = 'wrong number of tensors';
55
- const tensorLayoutIsArchitecture = (provider) => provider === 'llamacpp';
81
+ /**
82
+ * What CUDA prints when a build cannot run on this card or driver: a driver too old for the toolchain
83
+ * the build's PTX came from (CUDA 13.x on Turing before R616), or no kernels for this architecture at
84
+ * all. The bare `ggml_cuda_kernel_can_use_pdl` + `cudaFuncGetAttributes` pair is the same failure when
85
+ * the CUDA error line itself was cut off. Lowercase, like the stream the cascade reads.
86
+ */
87
+ const GPU_BUILD_INCOMPATIBLE_MARKERS = [
88
+ 'provided ptx was compiled with an unsupported toolchain',
89
+ 'no kernel image is available for execution on the device',
90
+ ];
91
+ const isGpuBuildIncompatible = (l) => includesAny(l, GPU_BUILD_INCOMPATIBLE_MARKERS) ||
92
+ (l.includes('ggml_cuda_kernel_can_use_pdl') && l.includes('cudafuncgetattributes'));
93
+ export const GPU_BACKEND_INCOMPATIBLE_MESSAGE = 'This GPU build of the model engine does not run on this graphics card with its current driver. Update the NVIDIA graphics driver, or switch to another backend (CUDA 12, Vulkan or CPU).';
94
+ export const ENGINE_BINARY_BROKEN_MESSAGE = 'The model engine could not load a library it needs, so it did not start. Its files may be incomplete or blocked by antivirus software: reinstall this backend or switch to another one.';
95
+ export const CPU_INSTRUCTION_UNSUPPORTED_MESSAGE = 'The model engine stopped on a processor instruction this computer does not have. Switch to another backend, such as the CPU build, which picks the instructions this processor supports.';
56
96
  export const ARGUMENT_REJECTED_MESSAGE = 'This llama.cpp backend does not accept one of the arguments it was started with. If you added custom arguments to this model, remove them; otherwise switch to another backend version or update Atomic Chat.';
57
97
  const CASCADE = [
58
98
  {
@@ -72,16 +112,23 @@ const CASCADE = [
72
112
  'cuda_error_out_of_memory',
73
113
  ]),
74
114
  },
115
+ {
116
+ // After out-of-memory (a card that ran out of VRAM is not an incompatible one), before every
117
+ // model rule: the build never got far enough for the model to be the reason.
118
+ code: 'GPU_BACKEND_INCOMPATIBLE',
119
+ message: GPU_BACKEND_INCOMPATIBLE_MESSAGE,
120
+ match: isGpuBuildIncompatible,
121
+ },
75
122
  {
76
123
  code: 'MODEL_ARCH_NOT_SUPPORTED',
77
124
  message: "The model's architecture or format is not supported by this version of the backend.",
78
- match: (l, provider) => includesAny(l, [
125
+ match: (l) => includesAny(l, [
79
126
  'error loading model architecture',
80
127
  'unknown model architecture',
81
128
  'error loading model hyperparameters',
82
129
  'key not found in model',
83
- ]) ||
84
- (tensorLayoutIsArchitecture(provider) && l.includes(TENSOR_COUNT_MISMATCH)),
130
+ TENSOR_COUNT_MISMATCH,
131
+ ]),
85
132
  },
86
133
  {
87
134
  code: 'MULTIMODAL_PROJECTOR_LOAD_FAILED',
@@ -91,13 +138,12 @@ const CASCADE = [
91
138
  {
92
139
  code: 'MODEL_FILE_CORRUPT',
93
140
  message: 'The model file appears to be incomplete or corrupted. Try deleting and re-downloading the model.',
94
- match: (l, provider) => includesAny(l, [
141
+ match: (l) => includesAny(l, [
95
142
  'corrupted or incomplete',
96
143
  'invalid magic',
97
144
  'unexpectedly reached end of file',
98
145
  'failed to read tensor',
99
- ]) ||
100
- (!tensorLayoutIsArchitecture(provider) && l.includes(TENSOR_COUNT_MISMATCH)),
146
+ ]),
101
147
  },
102
148
  {
103
149
  // `common_params_parse` (upstream, TurboQuant and Prism alike): a flag the build does not know,
@@ -120,28 +166,65 @@ export function classifyStderr(stderr, provider = 'llamacpp-upstream') {
120
166
  }
121
167
  return new AtomicCoreError('LLAMA_CPP_PROCESS_ERROR', GENERIC_PROCESS_ERROR_MESSAGE, stderr);
122
168
  }
123
- /** `LlamacppError::from_exit_status`: a recognised crash upgrades the generic error's message. */
169
+ /**
170
+ * A Windows exit status that names its own cause when stderr named none: the loader gave up before
171
+ * `main` (`ENGINE_BINARY_BROKEN`), or the build hit an instruction this CPU lacks
172
+ * (`CPU_INSTRUCTION_UNSUPPORTED`). `undefined` for anything else, and off Windows.
173
+ */
174
+ export function windowsExitCause(exit, platform) {
175
+ if (platform !== 'win32' || exit.code === null)
176
+ return undefined;
177
+ const status = exit.code >>> 0;
178
+ if (WINDOWS_LOADER_FAILURES.has(status))
179
+ return { code: 'ENGINE_BINARY_BROKEN', message: ENGINE_BINARY_BROKEN_MESSAGE };
180
+ if (status === WINDOWS_ILLEGAL_INSTRUCTION)
181
+ return { code: 'CPU_INSTRUCTION_UNSUPPORTED', message: CPU_INSTRUCTION_UNSUPPORTED_MESSAGE };
182
+ return undefined;
183
+ }
184
+ /**
185
+ * `LlamacppError::from_exit_status`: a recognised crash upgrades the generic error's message; beyond
186
+ * the app, a Windows loader or illegal-instruction status that stderr did not explain gets its own code.
187
+ */
124
188
  export function classifyExit(exit, stderr, platform, provider = 'llamacpp-upstream') {
125
189
  const base = classifyStderr(stderr, provider);
126
- if (base.code !== 'LLAMA_CPP_PROCESS_ERROR' || !isCrashExit(exit, platform))
190
+ if (base.code !== 'LLAMA_CPP_PROCESS_ERROR')
191
+ return base;
192
+ const cause = windowsExitCause(exit, platform);
193
+ if (cause)
194
+ return new AtomicCoreError(cause.code, cause.message, stderr);
195
+ if (!isCrashExit(exit, platform))
127
196
  return base;
128
197
  return new AtomicCoreError('LLAMA_CPP_PROCESS_ERROR', CRASH_MESSAGE, stderr);
129
198
  }
130
199
  /**
131
200
  * `LlamacppError::from_process_output`: stderr classification wins; otherwise try stdout (several
132
201
  * llama.cpp builds report loader failures there); otherwise keep the exit-status error but hand the
133
- * caller stdout as details when stderr is blank.
202
+ * caller stdout as details when stderr is blank. A code read from the Windows exit status alone ranks
203
+ * with the exit status, below stdout.
134
204
  */
135
205
  export function classifyProcessOutput(exit, stderr, stdout, platform, provider = 'llamacpp-upstream') {
136
206
  const base = classifyExit(exit, stderr, platform, provider);
137
- if (base.code !== 'LLAMA_CPP_PROCESS_ERROR')
138
- return base;
139
207
  const fromStdout = classifyStderr(stdout, provider);
140
- if (fromStdout.code !== 'LLAMA_CPP_PROCESS_ERROR')
141
- return fromStdout;
142
- if (stderr.trim() === '' && stdout.trim() !== '') {
143
- return new AtomicCoreError(base.code, base.message, stdout);
144
- }
145
- return base;
208
+ const fromStderr = base.code !== 'LLAMA_CPP_PROCESS_ERROR' && base.code !== windowsExitCause(exit, platform)?.code;
209
+ const selected = fromStderr
210
+ ? base
211
+ : fromStdout.code !== 'LLAMA_CPP_PROCESS_ERROR'
212
+ ? fromStdout
213
+ : stderr.trim() === '' && stdout.trim() !== ''
214
+ ? new AtomicCoreError(base.code, base.message, stdout)
215
+ : base;
216
+ // Preserve the Rust-compatible body while retaining facts that disappear when details are scrubbed.
217
+ return new AtomicCoreError(selected.code, selected.message, selected.details, {
218
+ diagnostic: {
219
+ component: 'runtime',
220
+ operation: 'load',
221
+ stage: 'ready',
222
+ exitCode: exit.code,
223
+ signal: exit.signal,
224
+ ...(selected.code === 'LLAMA_CPP_PROCESS_ERROR' && /GGML_ASSERT/.test(stderr + stdout)
225
+ ? { nativeFailure: 'assertion', reason: 'native_crash' }
226
+ : {}),
227
+ },
228
+ });
146
229
  }
147
230
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/runtime/llamacpp/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAU1D,MAAM,cAAc,GAA2B;IAC7C,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,OAAO,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AAC,CAAE,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAY;gBACnE,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -12,4 +12,5 @@ export * from './policy.js';
12
12
  export * from './probe.js';
13
13
  export * from './fit-margin.js';
14
14
  export * from './load-plan.js';
15
+ export * from './load-failure.js';
15
16
  export * from './runtime.js';
@@ -12,5 +12,6 @@ export * from './policy.js';
12
12
  export * from './probe.js';
13
13
  export * from './fit-margin.js';
14
14
  export * from './load-plan.js';
15
+ export * from './load-failure.js';
15
16
  export * from './runtime.js';
16
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/llamacpp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/llamacpp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * What a failed llama.cpp load carries beyond its error body: the `atomic-core-diag` line the app
3
+ * reads from the tail of `details` (`src/contracts/load-diag.ts`), the stage the load stopped at, and
4
+ * whether the failure is one a single retry on another installed build may get past. Pure; the
5
+ * runtime gathers the facts while it spawns.
6
+ */
7
+ import { AtomicCoreError } from '../../contracts/index.js';
8
+ import type { LoadDiag } from '../../contracts/index.js';
9
+ export declare function isWeightsLoadedLine(line: string): boolean;
10
+ /**
11
+ * Where a load stopped. `spawn`: the process never ran its own code — it could not be started, the
12
+ * Windows loader refused it, or it exited without printing a line. `load`: it died or timed out while
13
+ * loading the weights. `ready`: the weights were loaded and it never said it was listening.
14
+ * `runtime`: it had said so, and the load failed after that.
15
+ */
16
+ export declare function loadFailureStage(input: {
17
+ code: string;
18
+ printed: boolean;
19
+ weightsLoaded: boolean;
20
+ ready: boolean;
21
+ }): NonNullable<LoadDiag['stage']>;
22
+ /**
23
+ * `error` with the diag line appended to its details (replacing an earlier one) and `engineVersion`
24
+ * added to its telemetry diagnostic. Anything that is not an `AtomicCoreError`, a cancel and a stop
25
+ * are returned as they are.
26
+ */
27
+ export declare function withLoadFailureDiag(error: unknown, diag: LoadDiag, engineVersion?: string): unknown;
28
+ /** The diag line of one spawn attempt, from the error and what the runtime saw of the process. */
29
+ export declare function attemptLoadDiag(error: AtomicCoreError, facts: {
30
+ platform: NodeJS.Platform;
31
+ backend: string;
32
+ version: string;
33
+ printed: boolean;
34
+ stderrPrinted: boolean;
35
+ weightsLoaded: boolean;
36
+ ready: boolean;
37
+ }): LoadDiag;
38
+ /** What made a load try another build: the reason recorded against the build that failed. */
39
+ export type BackendFallbackTrigger = 'GPU_BACKEND_INCOMPATIBLE' | 'ENGINE_BINARY_BROKEN' | 'EMPTY_STDERR_CRASH';
40
+ /**
41
+ * Whether a failed load may be retried once on the next installed build, and why: the build cannot
42
+ * run on this card or driver; or, on a GPU build, Windows could not start it, or it died before
43
+ * printing anything (an empty stderr: a missing DLL or an illegal instruction rather than the model).
44
+ * Reads the diag line the attempt left in `details`.
45
+ */
46
+ export declare function backendFallbackTrigger(error: unknown, backend: string): BackendFallbackTrigger | undefined;
47
+ /** The diag of the error a load ends with after a fallback, the fallback's own facts kept. */
48
+ export declare function withFallbackDiag(error: unknown, fallback: {
49
+ from: string;
50
+ to: string;
51
+ ok: boolean;
52
+ }): unknown;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * What a failed llama.cpp load carries beyond its error body: the `atomic-core-diag` line the app
3
+ * reads from the tail of `details` (`src/contracts/load-diag.ts`), the stage the load stopped at, and
4
+ * whether the failure is one a single retry on another installed build may get past. Pure; the
5
+ * runtime gathers the facts while it spawns.
6
+ */
7
+ import { AtomicCoreError, parseLoadDiag, withLoadDiag } from '../../contracts/index.js';
8
+ import { formatExitCode } from './errors.js';
9
+ /** What llama-server prints once the weights are in memory, before it starts listening. */
10
+ const WEIGHTS_LOADED = /\bmodel loaded\b/i;
11
+ export function isWeightsLoadedLine(line) {
12
+ return WEIGHTS_LOADED.test(line);
13
+ }
14
+ /**
15
+ * Where a load stopped. `spawn`: the process never ran its own code — it could not be started, the
16
+ * Windows loader refused it, or it exited without printing a line. `load`: it died or timed out while
17
+ * loading the weights. `ready`: the weights were loaded and it never said it was listening.
18
+ * `runtime`: it had said so, and the load failed after that.
19
+ */
20
+ export function loadFailureStage(input) {
21
+ if (input.ready)
22
+ return 'runtime';
23
+ if (input.code === 'IO_ERROR' || input.code === 'ENGINE_BINARY_BROKEN')
24
+ return 'spawn';
25
+ if (input.weightsLoaded)
26
+ return 'ready';
27
+ if (input.code === 'MODEL_LOAD_TIMED_OUT' || input.printed)
28
+ return 'load';
29
+ return 'spawn';
30
+ }
31
+ /** Errors that end a load without being a failure of it: the user's cancel, the owner stopping. */
32
+ const NOT_LOAD_FAILURES = new Set(['MODEL_LOAD_CANCELLED', 'CORE_NOT_RUNNING']);
33
+ /**
34
+ * `error` with the diag line appended to its details (replacing an earlier one) and `engineVersion`
35
+ * added to its telemetry diagnostic. Anything that is not an `AtomicCoreError`, a cancel and a stop
36
+ * are returned as they are.
37
+ */
38
+ export function withLoadFailureDiag(error, diag, engineVersion) {
39
+ if (!(error instanceof AtomicCoreError) || NOT_LOAD_FAILURES.has(error.code))
40
+ return error;
41
+ const diagnostic = error.diagnostic
42
+ ? { ...error.diagnostic, ...(engineVersion ? { engineVersion } : {}) }
43
+ : engineVersion
44
+ ? { component: 'runtime', operation: 'load', engineVersion }
45
+ : undefined;
46
+ const wrapped = new AtomicCoreError(error.code, error.message, withLoadDiag(error.details, diag), {
47
+ ...(diagnostic ? { diagnostic } : {}),
48
+ ...(error.cause !== undefined ? { cause: error.cause } : {}),
49
+ });
50
+ if (error.stack)
51
+ wrapped.stack = error.stack;
52
+ return wrapped;
53
+ }
54
+ /** The diag line of one spawn attempt, from the error and what the runtime saw of the process. */
55
+ export function attemptLoadDiag(error, facts) {
56
+ const exitCode = error.diagnostic?.exitCode;
57
+ const signal = error.diagnostic?.signal;
58
+ const exit = typeof exitCode === 'number' ? formatExitCode(exitCode, facts.platform) : undefined;
59
+ return {
60
+ ...(exit !== undefined ? { exit_code: exit } : {}),
61
+ ...(typeof signal === 'string' ? { signal } : {}),
62
+ stage: loadFailureStage({ code: error.code, ...facts }),
63
+ backend: facts.backend,
64
+ // `cli` is the placeholder of an executable the CLI was pointed at, not a build tag.
65
+ ...(facts.version && facts.version !== 'cli' ? { build: facts.version } : {}),
66
+ ...(!facts.stderrPrinted ? { empty_stderr: true } : {}),
67
+ };
68
+ }
69
+ /** A build whose id names a GPU API; only these fall back on a broken binary or a silent crash. */
70
+ const GPU_BUILD = /cuda|vulkan|rocm|hip|sycl|opencl|musa|cann/i;
71
+ /**
72
+ * Whether a failed load may be retried once on the next installed build, and why: the build cannot
73
+ * run on this card or driver; or, on a GPU build, Windows could not start it, or it died before
74
+ * printing anything (an empty stderr: a missing DLL or an illegal instruction rather than the model).
75
+ * Reads the diag line the attempt left in `details`.
76
+ */
77
+ export function backendFallbackTrigger(error, backend) {
78
+ if (!(error instanceof AtomicCoreError))
79
+ return undefined;
80
+ if (error.code === 'GPU_BACKEND_INCOMPATIBLE')
81
+ return 'GPU_BACKEND_INCOMPATIBLE';
82
+ if (!GPU_BUILD.test(backend))
83
+ return undefined;
84
+ if (error.code === 'ENGINE_BINARY_BROKEN')
85
+ return 'ENGINE_BINARY_BROKEN';
86
+ if (error.code !== 'LLAMA_CPP_PROCESS_ERROR' && error.code !== 'CPU_INSTRUCTION_UNSUPPORTED')
87
+ return undefined;
88
+ const diag = parseLoadDiag(error.details);
89
+ const died = (diag?.exit_code !== undefined && diag.exit_code !== '0' && diag.exit_code !== '0x0') ||
90
+ diag?.signal !== undefined;
91
+ return diag?.empty_stderr === true && died ? 'EMPTY_STDERR_CRASH' : undefined;
92
+ }
93
+ /** The diag of the error a load ends with after a fallback, the fallback's own facts kept. */
94
+ export function withFallbackDiag(error, fallback) {
95
+ if (!(error instanceof AtomicCoreError) || NOT_LOAD_FAILURES.has(error.code))
96
+ return error;
97
+ const diag = {
98
+ ...(parseLoadDiag(error.details) ?? {}),
99
+ fallback_from: fallback.from,
100
+ fallback_to: fallback.to,
101
+ fallback_ok: fallback.ok,
102
+ };
103
+ return withLoadFailureDiag(error, diag);
104
+ }
105
+ //# sourceMappingURL=load-failure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-failure.js","sourceRoot":"","sources":["../../../src/runtime/llamacpp/load-failure.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,2FAA2F;AAC3F,MAAM,cAAc,GAAG,mBAAmB,CAAA;AAE1C,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAKhC;IACC,IAAI,KAAK,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IACjC,IAAI,KAAK,CAAC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AC,EAAE;QACxB,WAAW,EAAE,QAAQ,CAAC,EAAE;KACzB,CAAA;IACD,OAAO,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACzC,CAAC"}
@@ -110,6 +110,11 @@ export interface LoadPlan {
110
110
  fitCtxCeiling?: number;
111
111
  /** `--cache-ram` (MiB) on a machine with at most 16 GiB of RAM; absent: llama.cpp's 8192 MiB. */
112
112
  cacheRamMiB?: number;
113
+ /**
114
+ * Set by the runtime on the plan of a backend fallback: the `version_backend` the settings asked for,
115
+ * which `config.version_backend` (the build that runs) no longer is.
116
+ */
117
+ configuredVersionBackend?: string;
113
118
  warnings: string[];
114
119
  }
115
120
  /** Which loaded text sessions to unload before loading `modelId` (auto-unload policy). */
@@ -13,8 +13,9 @@
13
13
  import { AtomicCoreError } from '../../contracts/index.js';
14
14
  import { effectiveCtxSize, estimateKvCache, firstGgufShardPath, ggufShardSetPaths, isMtpCapable, matchesMtpLoadFailure, parseGgufShard, } from '../../models/index.js';
15
15
  import { generateApiKey } from '../shared/index.js';
16
- import { withLlamacppDefaults } from './args.js';
16
+ import { resolveFitCtx, withLlamacppDefaults } from './args.js';
17
17
  import { DEFAULT_CTX_LEN } from './ctx-ladder.js';
18
+ import { validateDeviceList } from './devices.js';
18
19
  import { DEFAULT_FIT_CTX, DEFAULT_FIT_TARGET_MIB, metalDevice, smallMemoryDefaultCtx, smallUnifiedMemoryCtxCeiling, unifiedMemoryFitTargetMiB, } from './fit-margin.js';
19
20
  import { promptCacheRamMiB, resolveNPredict } from './generation-limits.js';
20
21
  import { BACKEND_NOT_CONFIGURED_MESSAGE, CPU_NO_AVX_ERROR_CODE, CPU_NO_AVX_MESSAGE, codedLoadError, formatLoadError, isCpuBackend, isUnsupportedNoAvxCpu, modelLoadReadyTimeoutSecs, parseBuildNumberStrict, parseEnvString, stripBom, } from './policy.js';
@@ -61,8 +62,9 @@ export async function planLlamaLoad(input, deps) {
61
62
  deps.warn?.(m);
62
63
  };
63
64
  const { modelId } = input;
64
- // 2. settings merge (per-model overrides win)
65
+ // 2. settings merge (per-model overrides win; a model's `fit_ctx` only when it names a window)
65
66
  const cfg = withLlamacppDefaults({ ...input.config, ...(input.overrides ?? {}) });
67
+ cfg.fit_ctx = resolveFitCtx(input.config.fit_ctx, input.overrides?.fit_ctx);
66
68
  const env = {};
67
69
  // 3. `latest/<backend>` sentinel
68
70
  if (stripBom(cfg.version_backend || '').startsWith('latest/')) {
@@ -95,6 +97,33 @@ export async function planLlamaLoad(input, deps) {
95
97
  version = ready.version;
96
98
  backend = ready.backend;
97
99
  const exePath = ready.exePath;
100
+ // One `--list-devices` per executable and plan: the device check below and fit's Metal margin
101
+ // read the same list.
102
+ if (deps.listDevices) {
103
+ const listDevices = deps.listDevices;
104
+ const lists = new Map();
105
+ deps = {
106
+ ...deps,
107
+ listDevices: (path) => {
108
+ const listed = lists.get(path) ?? listDevices(path);
109
+ lists.set(path, listed);
110
+ return listed;
111
+ },
112
+ };
113
+ }
114
+ // 7b. a `--device` this build does not have would make llama-server exit; it is dropped instead.
115
+ // A device list that cannot be read changes nothing.
116
+ if (String(cfg.device ?? '').trim() !== '' && deps.listDevices) {
117
+ const devices = await deps.listDevices(exePath).catch(() => undefined);
118
+ if (devices) {
119
+ const checked = validateDeviceList(cfg.device, devices);
120
+ if (checked.dropped.length > 0) {
121
+ const listedIds = devices.map((d) => d.id).join(', ') || 'none';
122
+ warn(`Ignoring device ${checked.dropped.join(', ')} for "${modelId}": ${version}/${backend} does not have it (it lists ${listedIds}).`);
123
+ cfg.device = checked.device;
124
+ }
125
+ }
126
+ }
98
127
  // 8-9. model.yml, port, key, env
99
128
  const modelConfig = input.modelPath
100
129
  ? {
@@ -219,8 +248,9 @@ export async function planLlamaLoad(input, deps) {
219
248
  warn(`Unified memory: fitting "${modelId}" with a ${fit.marginMiB} MiB margin so llama.cpp leaves half of RAM to the system.`);
220
249
  }
221
250
  if (fit?.ctxCeiling !== undefined) {
222
- fitCtxCeiling = fit.ctxCeiling;
223
- warn(`Unified memory below 16 GiB: capping the window fit may pick for "${modelId}" at ${fit.ctxCeiling} tokens.`);
251
+ // Never below the floor fit is given (`fit_ctx`, which the app raises to grow the window).
252
+ fitCtxCeiling = Math.max(fit.ctxCeiling, fitMinCtx(cfg));
253
+ warn(`Unified memory below 16 GiB: capping the window fit may pick for "${modelId}" at ${fitCtxCeiling} tokens.`);
224
254
  }
225
255
  }
226
256
  // 19c. fit off with no window chosen: llama.cpp would take the whole trained context (`n_ctx = 0`,