@bendyline/gezel-inference 0.0.0-stage → 1.0.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 (967) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -2
  3. package/dist/cache/adapter.d.ts +115 -0
  4. package/dist/cache/adapter.js +23 -0
  5. package/dist/cache/budget.d.ts +15 -0
  6. package/dist/cache/budget.js +31 -0
  7. package/dist/cache/controller.d.ts +205 -0
  8. package/dist/cache/controller.js +377 -0
  9. package/dist/catalog/LICENSE +21 -0
  10. package/dist/catalog/chat-models/bt/btl4-35b-q4/manifest.json +146 -0
  11. package/dist/catalog/chat-models/bt/btl4-35b-q4/versions/1.0.0/manifest.json +15 -0
  12. package/dist/catalog/chat-models/bt/btl4-35b-q4/versions/1.0.1/manifest.json +15 -0
  13. package/dist/catalog/chat-models/bt/btl4-compact-iq2/manifest.json +146 -0
  14. package/dist/catalog/chat-models/bt/btl4-compact-iq2/versions/1.0.0/manifest.json +15 -0
  15. package/dist/catalog/chat-models/bt/btl4-compact-iq2/versions/1.0.1/manifest.json +15 -0
  16. package/dist/catalog/chat-models/bt/btl4-compact-iq2/versions/1.0.2/manifest.json +15 -0
  17. package/dist/catalog/chat-models/de/deepseek-r1-8b-q4/manifest.json +166 -0
  18. package/dist/catalog/chat-models/de/deepseek-r1-8b-q4/versions/1.1.0/manifest.json +62 -0
  19. package/dist/catalog/chat-models/de/deepseek-r1-8b-q4/versions/1.1.1/manifest.json +61 -0
  20. package/dist/catalog/chat-models/de/deepseek-v4-flash-284b-mxfp4/manifest.json +125 -0
  21. package/dist/catalog/chat-models/de/deepseek-v4-flash-284b-mxfp4/versions/1.0.0/manifest.json +27 -0
  22. package/dist/catalog/chat-models/de/deepseek-v4-flash-284b-q2/manifest.json +125 -0
  23. package/dist/catalog/chat-models/de/deepseek-v4-flash-284b-q2/versions/1.0.0/manifest.json +27 -0
  24. package/dist/catalog/chat-models/de/deepseek-v4-flash-284b-q2/versions/1.1.0/manifest.json +27 -0
  25. package/dist/catalog/chat-models/de/deepseek-v4-flash-284b-q2q4/manifest.json +126 -0
  26. package/dist/catalog/chat-models/de/deepseek-v4-flash-284b-q2q4/versions/1.0.0/manifest.json +27 -0
  27. package/dist/catalog/chat-models/de/deepseek-v4-flash-284b-q4/manifest.json +318 -0
  28. package/dist/catalog/chat-models/de/deepseek-v4-flash-284b-q4/versions/1.0.0/manifest.json +225 -0
  29. package/dist/catalog/chat-models/de/deepseek-v4-flash-284b-q4/versions/1.1.0/manifest.json +225 -0
  30. package/dist/catalog/chat-models/ge/gemma4-12b-q4/manifest.json +249 -0
  31. package/dist/catalog/chat-models/ge/gemma4-12b-q4/versions/1.0.0/manifest.json +70 -0
  32. package/dist/catalog/chat-models/ge/gemma4-12b-q4/versions/1.1.0/manifest.json +72 -0
  33. package/dist/catalog/chat-models/ge/gemma4-12b-q4/versions/1.1.2/manifest.json +78 -0
  34. package/dist/catalog/chat-models/ge/gemma4-12b-q4/versions/1.1.3/manifest.json +78 -0
  35. package/dist/catalog/chat-models/ge/gemma4-12b-q4/versions/1.2.0/manifest.json +98 -0
  36. package/dist/catalog/chat-models/ge/gemma4-12b-q8/manifest.json +228 -0
  37. package/dist/catalog/chat-models/ge/gemma4-12b-q8/versions/1.0.0/manifest.json +72 -0
  38. package/dist/catalog/chat-models/ge/gemma4-12b-q8/versions/1.0.2/manifest.json +78 -0
  39. package/dist/catalog/chat-models/ge/gemma4-12b-q8/versions/1.0.3/manifest.json +78 -0
  40. package/dist/catalog/chat-models/ge/gemma4-12b-q8/versions/1.1.0/manifest.json +78 -0
  41. package/dist/catalog/chat-models/ge/gemma4-26b-q4/manifest.json +220 -0
  42. package/dist/catalog/chat-models/ge/gemma4-26b-q4/versions/1.1.0/manifest.json +75 -0
  43. package/dist/catalog/chat-models/ge/gemma4-26b-q4/versions/1.2.0/manifest.json +75 -0
  44. package/dist/catalog/chat-models/ge/gemma4-26b-q4/versions/1.2.1/manifest.json +80 -0
  45. package/dist/catalog/chat-models/ge/gemma4-26b-q4/versions/1.2.2/manifest.json +80 -0
  46. package/dist/catalog/chat-models/ge/gemma4-26b-q4/versions/1.3.0/manifest.json +81 -0
  47. package/dist/catalog/chat-models/ge/gemma4-31b-q4/manifest.json +226 -0
  48. package/dist/catalog/chat-models/ge/gemma4-31b-q4/versions/1.1.0/manifest.json +80 -0
  49. package/dist/catalog/chat-models/ge/gemma4-31b-q4/versions/1.1.1/manifest.json +82 -0
  50. package/dist/catalog/chat-models/ge/gemma4-31b-q4/versions/1.2.0/manifest.json +82 -0
  51. package/dist/catalog/chat-models/ge/gemma4-31b-q4/versions/1.2.1/manifest.json +95 -0
  52. package/dist/catalog/chat-models/ge/gemma4-31b-q4/versions/1.2.2/manifest.json +95 -0
  53. package/dist/catalog/chat-models/ge/gemma4-31b-q4/versions/1.3.0/manifest.json +86 -0
  54. package/dist/catalog/chat-models/ge/gemma4-e2b-q4/manifest.json +213 -0
  55. package/dist/catalog/chat-models/ge/gemma4-e2b-q4/versions/1.1.0/manifest.json +67 -0
  56. package/dist/catalog/chat-models/ge/gemma4-e2b-q4/versions/1.1.2/manifest.json +75 -0
  57. package/dist/catalog/chat-models/ge/gemma4-e2b-q4/versions/1.2.0/manifest.json +71 -0
  58. package/dist/catalog/chat-models/ge/gemma4-e2b-q4/versions/1.2.1/manifest.json +71 -0
  59. package/dist/catalog/chat-models/ge/gemma4-e2b-q4/versions/1.3.0/manifest.json +71 -0
  60. package/dist/catalog/chat-models/ge/gemma4-e4b-q4/manifest.json +205 -0
  61. package/dist/catalog/chat-models/ge/gemma4-e4b-q4/versions/1.1.0/manifest.json +72 -0
  62. package/dist/catalog/chat-models/ge/gemma4-e4b-q4/versions/1.1.2/manifest.json +75 -0
  63. package/dist/catalog/chat-models/ge/gemma4-e4b-q4/versions/1.2.0/manifest.json +76 -0
  64. package/dist/catalog/chat-models/ge/gemma4-e4b-q4/versions/1.2.1/manifest.json +76 -0
  65. package/dist/catalog/chat-models/ge/gemma4-e4b-q4/versions/1.3.0/manifest.json +76 -0
  66. package/dist/catalog/chat-models/gl/glm-5.2-754b-q2/manifest.json +127 -0
  67. package/dist/catalog/chat-models/gl/glm-5.2-754b-q2/versions/1.0.0/manifest.json +20 -0
  68. package/dist/catalog/chat-models/gl/glm-5.3-flash-320b-q2/manifest.json +140 -0
  69. package/dist/catalog/chat-models/gl/glm-5.3-flash-320b-q2/versions/1.0.0/manifest.json +23 -0
  70. package/dist/catalog/chat-models/gl/glm-5.3-flash-320b-q2/versions/1.0.1/manifest.json +26 -0
  71. package/dist/catalog/chat-models/gp/gpt-oss-120b-q4/manifest.json +247 -0
  72. package/dist/catalog/chat-models/gp/gpt-oss-120b-q4/versions/1.0.0/manifest.json +137 -0
  73. package/dist/catalog/chat-models/gp/gpt-oss-120b-q4/versions/1.1.0/manifest.json +135 -0
  74. package/dist/catalog/chat-models/gp/gpt-oss-20b-q4/manifest.json +195 -0
  75. package/dist/catalog/chat-models/gp/gpt-oss-20b-q4/versions/1.1.0/manifest.json +72 -0
  76. package/dist/catalog/chat-models/gp/gpt-oss-20b-q4/versions/1.1.1/manifest.json +71 -0
  77. package/dist/catalog/chat-models/gr/granite4.2-30b-q4/manifest.json +200 -0
  78. package/dist/catalog/chat-models/gr/granite4.2-30b-q4/versions/1.0.0/manifest.json +72 -0
  79. package/dist/catalog/chat-models/gr/granite4.2-3b-q4/manifest.json +196 -0
  80. package/dist/catalog/chat-models/gr/granite4.2-3b-q4/versions/1.0.0/manifest.json +57 -0
  81. package/dist/catalog/chat-models/gr/granite4.2-8b-q4/manifest.json +189 -0
  82. package/dist/catalog/chat-models/gr/granite4.2-8b-q4/versions/1.0.0/manifest.json +57 -0
  83. package/dist/catalog/chat-models/index.json +1 -0
  84. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q4/manifest.json +235 -0
  85. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q4/versions/1.0.0/manifest.json +124 -0
  86. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q4/versions/1.0.1/manifest.json +124 -0
  87. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q4/versions/1.0.2/manifest.json +123 -0
  88. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q6/manifest.json +257 -0
  89. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q6/versions/1.0.0/manifest.json +145 -0
  90. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q6/versions/1.0.1/manifest.json +145 -0
  91. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q8/manifest.json +285 -0
  92. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q8/versions/1.0.0/manifest.json +174 -0
  93. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q8/versions/1.0.1/manifest.json +174 -0
  94. package/dist/catalog/chat-models/la/laguna-s-2.1-118b-q8/versions/1.0.2/manifest.json +173 -0
  95. package/dist/catalog/chat-models/lf/lfm2.5-2.6b-q4/manifest.json +162 -0
  96. package/dist/catalog/chat-models/lf/lfm2.5-2.6b-q4/versions/1.0.0/manifest.json +59 -0
  97. package/dist/catalog/chat-models/lf/lfm2.5-2.6b-q4/versions/1.0.1/manifest.json +58 -0
  98. package/dist/catalog/chat-models/ll/llama3.2-3b-q4/manifest.json +134 -0
  99. package/dist/catalog/chat-models/ll/llama3.2-3b-q4/versions/1.1.0/manifest.json +57 -0
  100. package/dist/catalog/chat-models/ll/llama3.2-3b-q4/versions/1.1.1/manifest.json +56 -0
  101. package/dist/catalog/chat-models/mi/minicpm5-1b-q4/manifest.json +156 -0
  102. package/dist/catalog/chat-models/mi/minicpm5-1b-q4/versions/1.0.0/manifest.json +57 -0
  103. package/dist/catalog/chat-models/mi/minicpm5-2b-q4/manifest.json +161 -0
  104. package/dist/catalog/chat-models/mi/minicpm5-2b-q4/versions/1.0.0/manifest.json +57 -0
  105. package/dist/catalog/chat-models/mi/mistral-7b-q4/manifest.json +159 -0
  106. package/dist/catalog/chat-models/mi/mistral-7b-q4/versions/1.1.0/manifest.json +62 -0
  107. package/dist/catalog/chat-models/mi/mistral-7b-q4/versions/1.1.1/manifest.json +61 -0
  108. package/dist/catalog/chat-models/mi/mistral-medium-3.5-128b-q4/manifest.json +275 -0
  109. package/dist/catalog/chat-models/mi/mistral-medium-3.5-128b-q4/versions/1.0.0/manifest.json +154 -0
  110. package/dist/catalog/chat-models/mi/mistral-medium-3.5-128b-q4/versions/1.0.1/manifest.json +153 -0
  111. package/dist/catalog/chat-models/mu/muse-glimmer-30b-q4/manifest.json +135 -0
  112. package/dist/catalog/chat-models/mu/muse-glimmer-30b-q4/versions/1.0.0/manifest.json +20 -0
  113. package/dist/catalog/chat-models/mu/muse-glimmer-30b-q4/versions/1.0.1/manifest.json +20 -0
  114. package/dist/catalog/chat-models/mu/muse-glimmer-30b-q4/versions/1.0.2/manifest.json +20 -0
  115. package/dist/catalog/chat-models/na/nanbeige4.2-3b-q4/manifest.json +138 -0
  116. package/dist/catalog/chat-models/na/nanbeige4.2-3b-q4/versions/1.0.0/manifest.json +14 -0
  117. package/dist/catalog/chat-models/ne/nemotron3-nano-30b-q4/manifest.json +212 -0
  118. package/dist/catalog/chat-models/ne/nemotron3-nano-30b-q4/versions/1.0.0/manifest.json +94 -0
  119. package/dist/catalog/chat-models/ne/nemotron3-nano-30b-q4/versions/1.0.1/manifest.json +94 -0
  120. package/dist/catalog/chat-models/ne/nemotron3-nano-30b-q4/versions/1.0.2/manifest.json +93 -0
  121. package/dist/catalog/chat-models/ne/nemotron3-super-120b-q4/manifest.json +135 -0
  122. package/dist/catalog/chat-models/ne/nemotron3-super-120b-q4/versions/1.0.0/manifest.json +30 -0
  123. package/dist/catalog/chat-models/ne/nemotron3-super-120b-q4/versions/1.0.1/manifest.json +30 -0
  124. package/dist/catalog/chat-models/ne/nemotron3.5-lightning-30b-q4/manifest.json +192 -0
  125. package/dist/catalog/chat-models/ne/nemotron3.5-lightning-30b-q4/versions/1.0.0/manifest.json +74 -0
  126. package/dist/catalog/chat-models/ne/nemotron3.5-lightning-30b-q4/versions/1.0.1/manifest.json +73 -0
  127. package/dist/catalog/chat-models/ne/nemotron3.5-lightning-30b-q8/manifest.json +207 -0
  128. package/dist/catalog/chat-models/ne/nemotron3.5-lightning-30b-q8/versions/1.0.0/manifest.json +89 -0
  129. package/dist/catalog/chat-models/ne/nemotron3.5-lightning-30b-q8/versions/1.0.1/manifest.json +88 -0
  130. package/dist/catalog/chat-models/or/ornith-35b-q4/manifest.json +224 -0
  131. package/dist/catalog/chat-models/or/ornith-35b-q4/versions/1.0.0/manifest.json +94 -0
  132. package/dist/catalog/chat-models/or/ornith-35b-q4/versions/1.0.1/manifest.json +93 -0
  133. package/dist/catalog/chat-models/or/ornith-35b-q8/manifest.json +244 -0
  134. package/dist/catalog/chat-models/or/ornith-35b-q8/versions/1.0.0/manifest.json +114 -0
  135. package/dist/catalog/chat-models/or/ornith-35b-q8/versions/1.0.1/manifest.json +113 -0
  136. package/dist/catalog/chat-models/or/ornith-9b-q4/manifest.json +215 -0
  137. package/dist/catalog/chat-models/or/ornith-9b-q4/versions/1.0.0/manifest.json +84 -0
  138. package/dist/catalog/chat-models/or/ornith-9b-q4/versions/1.0.1/manifest.json +83 -0
  139. package/dist/catalog/chat-models/or/ornith1.5-35b-a3b-q4/manifest.json +208 -0
  140. package/dist/catalog/chat-models/or/ornith1.5-35b-a3b-q4/versions/1.0.0/manifest.json +74 -0
  141. package/dist/catalog/chat-models/or/ornith1.5-35b-a3b-q8/manifest.json +223 -0
  142. package/dist/catalog/chat-models/or/ornith1.5-35b-a3b-q8/versions/1.0.0/manifest.json +89 -0
  143. package/dist/catalog/chat-models/or/ornith1.5-9b-q4/manifest.json +187 -0
  144. package/dist/catalog/chat-models/or/ornith1.5-9b-q4/versions/1.0.0/manifest.json +53 -0
  145. package/dist/catalog/chat-models/or/ornith1.5-9b-q4/versions/1.0.1/manifest.json +77 -0
  146. package/dist/catalog/chat-models/or/ornith1.5-9b-q8/manifest.json +192 -0
  147. package/dist/catalog/chat-models/or/ornith1.5-9b-q8/versions/1.0.0/manifest.json +58 -0
  148. package/dist/catalog/chat-models/or/ornith1.5-9b-q8/versions/1.0.1/manifest.json +82 -0
  149. package/dist/catalog/chat-models/qw/qwen3.5-0.8b-q4/manifest.json +192 -0
  150. package/dist/catalog/chat-models/qw/qwen3.5-0.8b-q4/versions/1.0.0/manifest.json +75 -0
  151. package/dist/catalog/chat-models/qw/qwen3.5-122b-a10b-q4/manifest.json +315 -0
  152. package/dist/catalog/chat-models/qw/qwen3.5-122b-a10b-q4/versions/1.0.0/manifest.json +164 -0
  153. package/dist/catalog/chat-models/qw/qwen3.5-122b-a10b-q4/versions/1.0.1/manifest.json +164 -0
  154. package/dist/catalog/chat-models/qw/qwen3.5-122b-a10b-q4/versions/1.0.2/manifest.json +164 -0
  155. package/dist/catalog/chat-models/qw/qwen3.5-122b-a10b-q4/versions/1.0.3/manifest.json +163 -0
  156. package/dist/catalog/chat-models/qw/qwen3.5-27b-q4/manifest.json +217 -0
  157. package/dist/catalog/chat-models/qw/qwen3.5-27b-q4/versions/1.0.0/manifest.json +90 -0
  158. package/dist/catalog/chat-models/qw/qwen3.5-2b-q4/manifest.json +194 -0
  159. package/dist/catalog/chat-models/qw/qwen3.5-2b-q4/versions/1.1.0/manifest.json +77 -0
  160. package/dist/catalog/chat-models/qw/qwen3.5-2b-q4/versions/1.1.2/manifest.json +76 -0
  161. package/dist/catalog/chat-models/qw/qwen3.5-2b-q4/versions/1.1.3/manifest.json +76 -0
  162. package/dist/catalog/chat-models/qw/qwen3.5-4b-q4/manifest.json +188 -0
  163. package/dist/catalog/chat-models/qw/qwen3.5-4b-q4/versions/1.1.0/manifest.json +77 -0
  164. package/dist/catalog/chat-models/qw/qwen3.5-4b-q4/versions/1.1.2/manifest.json +76 -0
  165. package/dist/catalog/chat-models/qw/qwen3.5-4b-q4/versions/1.1.3/manifest.json +76 -0
  166. package/dist/catalog/chat-models/qw/qwen3.5-9b-q4/manifest.json +205 -0
  167. package/dist/catalog/chat-models/qw/qwen3.5-9b-q4/versions/1.1.0/manifest.json +82 -0
  168. package/dist/catalog/chat-models/qw/qwen3.5-9b-q4/versions/1.1.2/manifest.json +81 -0
  169. package/dist/catalog/chat-models/qw/qwen3.5-9b-q4/versions/1.1.3/manifest.json +81 -0
  170. package/dist/catalog/chat-models/qw/qwen3.6-27b-q4/manifest.json +230 -0
  171. package/dist/catalog/chat-models/qw/qwen3.6-27b-q4/versions/1.1.0/manifest.json +92 -0
  172. package/dist/catalog/chat-models/qw/qwen3.6-27b-q4/versions/1.1.4/manifest.json +91 -0
  173. package/dist/catalog/chat-models/qw/qwen3.6-27b-q4/versions/1.1.5/manifest.json +91 -0
  174. package/dist/catalog/chat-models/qw/qwen3.6-27b-q4/versions/1.1.6/manifest.json +115 -0
  175. package/dist/catalog/chat-models/qw/qwen3.6-27b-q8/manifest.json +240 -0
  176. package/dist/catalog/chat-models/qw/qwen3.6-27b-q8/versions/1.0.0/manifest.json +102 -0
  177. package/dist/catalog/chat-models/qw/qwen3.6-27b-q8/versions/1.0.2/manifest.json +103 -0
  178. package/dist/catalog/chat-models/qw/qwen3.6-27b-q8/versions/1.0.3/manifest.json +103 -0
  179. package/dist/catalog/chat-models/qw/qwen3.6-27b-q8/versions/1.0.4/manifest.json +127 -0
  180. package/dist/catalog/chat-models/qw/qwen3.6-35b-a3b-q4/manifest.json +233 -0
  181. package/dist/catalog/chat-models/qw/qwen3.6-35b-a3b-q4/versions/1.0.0/manifest.json +92 -0
  182. package/dist/catalog/chat-models/qw/qwen3.6-35b-a3b-q4/versions/1.0.1/manifest.json +93 -0
  183. package/dist/catalog/chat-models/qw/qwen3.6-35b-a3b-q4/versions/1.0.2/manifest.json +93 -0
  184. package/dist/catalog/chat-models/qw/qwen3.6-35b-a3b-q4/versions/1.0.3/manifest.json +117 -0
  185. package/dist/catalog/chat-models/qw/qwen3.6-35b-a3b-q8/manifest.json +252 -0
  186. package/dist/catalog/chat-models/qw/qwen3.6-35b-a3b-q8/versions/1.0.0/manifest.json +112 -0
  187. package/dist/catalog/chat-models/qw/qwen3.6-35b-a3b-q8/versions/1.0.1/manifest.json +113 -0
  188. package/dist/catalog/chat-models/qw/qwen3.6-35b-a3b-q8/versions/1.0.2/manifest.json +113 -0
  189. package/dist/catalog/chat-models/qw/qwen3.6-35b-a3b-q8/versions/1.0.3/manifest.json +137 -0
  190. package/dist/catalog/chat-models/qw/qwen3.8-27b-iq1-s/manifest.json +195 -0
  191. package/dist/catalog/chat-models/qw/qwen3.8-27b-iq1-s/versions/1.0.0/manifest.json +19 -0
  192. package/dist/catalog/chat-models/qw/qwen3.8-27b-q2/manifest.json +194 -0
  193. package/dist/catalog/chat-models/qw/qwen3.8-27b-q2/versions/1.0.0/manifest.json +19 -0
  194. package/dist/catalog/chat-models/qw/qwen3.8-27b-q3/manifest.json +194 -0
  195. package/dist/catalog/chat-models/qw/qwen3.8-27b-q3/versions/1.0.0/manifest.json +19 -0
  196. package/dist/catalog/chat-models/qw/qwen3.8-27b-q3/versions/1.0.1/manifest.json +19 -0
  197. package/dist/catalog/chat-models/qw/qwen3.8-27b-q4/manifest.json +291 -0
  198. package/dist/catalog/chat-models/qw/qwen3.8-27b-q4/versions/1.0.0/manifest.json +20 -0
  199. package/dist/catalog/chat-models/qw/qwen3.8-27b-q4/versions/1.0.1/manifest.json +93 -0
  200. package/dist/catalog/chat-models/qw/qwen3.8-27b-q4/versions/1.0.2/manifest.json +92 -0
  201. package/dist/catalog/chat-models/qw/qwen3.8-27b-q4/versions/1.0.3/manifest.json +116 -0
  202. package/dist/catalog/chat-models/qw/qwen3.8-27b-q4/versions/1.0.4/manifest.json +116 -0
  203. package/dist/catalog/chat-models/qw/qwen3.8-27b-q4/versions/1.0.5/manifest.json +116 -0
  204. package/dist/catalog/chat-models/qw/qwen3.8-27b-q6/manifest.json +278 -0
  205. package/dist/catalog/chat-models/qw/qwen3.8-27b-q6/versions/1.0.0/manifest.json +20 -0
  206. package/dist/catalog/chat-models/qw/qwen3.8-27b-q6/versions/1.0.1/manifest.json +104 -0
  207. package/dist/catalog/chat-models/qw/qwen3.8-27b-q6/versions/1.0.2/manifest.json +103 -0
  208. package/dist/catalog/chat-models/qw/qwen3.8-27b-q6/versions/1.0.3/manifest.json +127 -0
  209. package/dist/catalog/chat-models/qw/qwen3.8-27b-q8/manifest.json +278 -0
  210. package/dist/catalog/chat-models/qw/qwen3.8-27b-q8/versions/1.0.0/manifest.json +113 -0
  211. package/dist/catalog/chat-models/qw/qwen3.8-27b-q8/versions/1.0.1/manifest.json +113 -0
  212. package/dist/catalog/chat-models/qw/qwen3.8-27b-q8/versions/1.0.2/manifest.json +137 -0
  213. package/dist/catalog/chat-models/qw/qwen3.8-flash-next-iq3/manifest.json +221 -0
  214. package/dist/catalog/chat-models/qw/qwen3.8-flash-next-iq3/versions/1.0.0/manifest.json +36 -0
  215. package/dist/catalog/chat-models/qw/qwen3.8-flash-next-iq4/manifest.json +429 -0
  216. package/dist/catalog/chat-models/qw/qwen3.8-flash-next-iq4/versions/1.0.0/manifest.json +36 -0
  217. package/dist/catalog/chat-models/qw/qwen3.8-flash-next-iq4/versions/1.1.0/manifest.json +205 -0
  218. package/dist/catalog/chat-models/qw/qwen3.8-flash-next-iq4/versions/1.1.1/manifest.json +244 -0
  219. package/dist/catalog/chat-models/qw/qwen3.8-flash-next-q2/manifest.json +203 -0
  220. package/dist/catalog/chat-models/qw/qwen3.8-flash-next-q2/versions/1.0.0/manifest.json +21 -0
  221. package/dist/catalog/chat-models/qw/qwen3.8-flash-next-q2/versions/1.0.1/manifest.json +31 -0
  222. package/dist/catalog/chat-models/qw/qwen3.8-flash-next-q2/versions/1.0.2/manifest.json +30 -0
  223. package/dist/catalog/chat-models/raw-index.json +1 -0
  224. package/dist/catalog/chat-models/ta/talkie-1930-13b-q4/manifest.json +79 -0
  225. package/dist/catalog/chat-models/ta/talkie-1930-13b-q4/versions/1.0.0/manifest.json +15 -0
  226. package/dist/catalog/chat-models/ta/talkie-1930-13b-q4/versions/1.0.1/manifest.json +15 -0
  227. package/dist/catalog/chat-models/te/ternary-bonsai-27b-q2/manifest.json +204 -0
  228. package/dist/catalog/chat-models/te/ternary-bonsai-27b-q2/versions/1.0.0/manifest.json +70 -0
  229. package/dist/catalog/chat-models/te/ternary-bonsai-27b-q2/versions/1.0.1/manifest.json +70 -0
  230. package/dist/catalog/chat-models/un/underdog-saluki-27b-iq2-mix/manifest.json +164 -0
  231. package/dist/catalog/chat-models/un/underdog-saluki-27b-iq2-mix/versions/1.0.0/manifest.json +14 -0
  232. package/dist/catalog/knowledge-catalogs/be/bendyline-how-to-books/manifest.json +26 -0
  233. package/dist/catalog/knowledge-catalogs/be/bendyline-how-to-books/versions/2026.10.8/manifest.json +8950 -0
  234. package/dist/catalog/knowledge-catalogs/ca/caselaw-alaska-part-0001/manifest.json +24 -0
  235. package/dist/catalog/knowledge-catalogs/ca/caselaw-alaska-part-0001/versions/2026.10.1/manifest.json +658 -0
  236. package/dist/catalog/knowledge-catalogs/ca/caselaw-nevada-part-0001/manifest.json +24 -0
  237. package/dist/catalog/knowledge-catalogs/ca/caselaw-nevada-part-0001/versions/2026.10.1/manifest.json +666 -0
  238. package/dist/catalog/knowledge-catalogs/ca/caselaw-us-300-399-part-0001/manifest.json +24 -0
  239. package/dist/catalog/knowledge-catalogs/ca/caselaw-us-300-399-part-0001/versions/2026.10.2/manifest.json +182 -0
  240. package/dist/catalog/knowledge-catalogs/ca/caselaw-us-347-349/manifest.json +25 -0
  241. package/dist/catalog/knowledge-catalogs/ca/caselaw-us-347-349/versions/2026.10.5/manifest.json +38 -0
  242. package/dist/catalog/knowledge-catalogs/ca/caselaw-utah-part-0001/manifest.json +24 -0
  243. package/dist/catalog/knowledge-catalogs/ca/caselaw-utah-part-0001/versions/2026.10.1/manifest.json +558 -0
  244. package/dist/catalog/knowledge-catalogs/ca/caselaw-utah-part-0002/manifest.json +24 -0
  245. package/dist/catalog/knowledge-catalogs/ca/caselaw-utah-part-0002/versions/2026.10.1/manifest.json +258 -0
  246. package/dist/catalog/knowledge-catalogs/ca/caselaw-washington-part-0001/manifest.json +24 -0
  247. package/dist/catalog/knowledge-catalogs/ca/caselaw-washington-part-0001/versions/2026.10.1/manifest.json +318 -0
  248. package/dist/catalog/knowledge-catalogs/ca/caselaw-washington-part-0002/manifest.json +24 -0
  249. package/dist/catalog/knowledge-catalogs/ca/caselaw-washington-part-0002/versions/2026.10.1/manifest.json +266 -0
  250. package/dist/catalog/knowledge-catalogs/ca/caselaw-washington-part-0003/manifest.json +24 -0
  251. package/dist/catalog/knowledge-catalogs/ca/caselaw-washington-part-0003/versions/2026.10.1/manifest.json +186 -0
  252. package/dist/catalog/knowledge-catalogs/ca/caselaw-washington-part-0004/manifest.json +24 -0
  253. package/dist/catalog/knowledge-catalogs/ca/caselaw-washington-part-0004/versions/2026.10.1/manifest.json +138 -0
  254. package/dist/catalog/knowledge-catalogs/ca/caselaw-washington-part-0005/manifest.json +24 -0
  255. package/dist/catalog/knowledge-catalogs/ca/caselaw-washington-part-0005/versions/2026.10.1/manifest.json +138 -0
  256. package/dist/catalog/knowledge-catalogs/ca/caselaw-wyoming-part-0001/manifest.json +24 -0
  257. package/dist/catalog/knowledge-catalogs/ca/caselaw-wyoming-part-0001/versions/2026.10.3/manifest.json +626 -0
  258. package/dist/catalog/knowledge-catalogs/index.json +1 -0
  259. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-aspnet-core-en/manifest.json +22 -0
  260. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-aspnet-core-en/versions/2026.10.16/manifest.json +18270 -0
  261. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-azure-ai-platform-en/manifest.json +23 -0
  262. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-azure-ai-platform-en/versions/2026.10.16/manifest.json +1098 -0
  263. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-azure-apps-compute-en/manifest.json +23 -0
  264. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-azure-apps-compute-en/versions/2026.10.16/manifest.json +722 -0
  265. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-azure-data-aiot-en/manifest.json +23 -0
  266. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-azure-data-aiot-en/versions/2026.10.16/manifest.json +530 -0
  267. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-azure-management-hybrid-en/manifest.json +23 -0
  268. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-azure-management-hybrid-en/versions/2026.10.16/manifest.json +602 -0
  269. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-azure-network-security-en/manifest.json +23 -0
  270. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-azure-network-security-en/versions/2026.10.16/manifest.json +250 -0
  271. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-dotnet-en/manifest.json +22 -0
  272. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-dotnet-en/versions/2026.10.16/manifest.json +16794 -0
  273. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-entity-framework-en/manifest.json +22 -0
  274. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-entity-framework-en/versions/2026.10.16/manifest.json +1106 -0
  275. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-microsoft-365-en/manifest.json +22 -0
  276. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-microsoft-365-en/versions/2026.10.16/manifest.json +234 -0
  277. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-powershell-en/manifest.json +22 -0
  278. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-powershell-en/versions/2026.10.16/manifest.json +522 -0
  279. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-sql-server-en/manifest.json +22 -0
  280. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-sql-server-en/versions/2026.10.16/manifest.json +1850 -0
  281. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-windows-apps-en/manifest.json +22 -0
  282. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-windows-apps-en/versions/2026.10.16/manifest.json +1734 -0
  283. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-windows-server-en/manifest.json +22 -0
  284. package/dist/catalog/knowledge-catalogs/mi/microsoftdocs-windows-server-en/versions/2026.10.16/manifest.json +774 -0
  285. package/dist/catalog/knowledge-catalogs/raw-index.json +1 -0
  286. package/dist/catalog/knowledge-catalogs/re/regional-american-south/art.json +12 -0
  287. package/dist/catalog/knowledge-catalogs/re/regional-american-south/logo.webp +0 -0
  288. package/dist/catalog/knowledge-catalogs/re/regional-american-south/manifest.json +48 -0
  289. package/dist/catalog/knowledge-catalogs/re/regional-american-south/versions/2026.10.3/manifest.json +133 -0
  290. package/dist/catalog/knowledge-catalogs/re/regional-andes-amazon/art.json +12 -0
  291. package/dist/catalog/knowledge-catalogs/re/regional-andes-amazon/logo.webp +0 -0
  292. package/dist/catalog/knowledge-catalogs/re/regional-andes-amazon/manifest.json +48 -0
  293. package/dist/catalog/knowledge-catalogs/re/regional-andes-amazon/versions/2026.10.3/manifest.json +133 -0
  294. package/dist/catalog/knowledge-catalogs/re/regional-australia-nz/art.json +12 -0
  295. package/dist/catalog/knowledge-catalogs/re/regional-australia-nz/logo.webp +0 -0
  296. package/dist/catalog/knowledge-catalogs/re/regional-australia-nz/manifest.json +48 -0
  297. package/dist/catalog/knowledge-catalogs/re/regional-australia-nz/versions/2026.10.3/manifest.json +133 -0
  298. package/dist/catalog/knowledge-catalogs/re/regional-brazil/art.json +12 -0
  299. package/dist/catalog/knowledge-catalogs/re/regional-brazil/logo.webp +0 -0
  300. package/dist/catalog/knowledge-catalogs/re/regional-brazil/manifest.json +48 -0
  301. package/dist/catalog/knowledge-catalogs/re/regional-brazil/versions/2026.10.3/manifest.json +133 -0
  302. package/dist/catalog/knowledge-catalogs/re/regional-britain-ireland/art.json +12 -0
  303. package/dist/catalog/knowledge-catalogs/re/regional-britain-ireland/logo.webp +0 -0
  304. package/dist/catalog/knowledge-catalogs/re/regional-britain-ireland/manifest.json +48 -0
  305. package/dist/catalog/knowledge-catalogs/re/regional-britain-ireland/versions/2026.10.3/manifest.json +133 -0
  306. package/dist/catalog/knowledge-catalogs/re/regional-california-southwest/art.json +12 -0
  307. package/dist/catalog/knowledge-catalogs/re/regional-california-southwest/logo.webp +0 -0
  308. package/dist/catalog/knowledge-catalogs/re/regional-california-southwest/manifest.json +48 -0
  309. package/dist/catalog/knowledge-catalogs/re/regional-california-southwest/versions/2026.10.3/manifest.json +133 -0
  310. package/dist/catalog/knowledge-catalogs/re/regional-canada-alaska/art.json +12 -0
  311. package/dist/catalog/knowledge-catalogs/re/regional-canada-alaska/logo.webp +0 -0
  312. package/dist/catalog/knowledge-catalogs/re/regional-canada-alaska/manifest.json +48 -0
  313. package/dist/catalog/knowledge-catalogs/re/regional-canada-alaska/versions/2026.10.3/manifest.json +133 -0
  314. package/dist/catalog/knowledge-catalogs/re/regional-central-eastern-europe/art.json +12 -0
  315. package/dist/catalog/knowledge-catalogs/re/regional-central-eastern-europe/logo.webp +0 -0
  316. package/dist/catalog/knowledge-catalogs/re/regional-central-eastern-europe/manifest.json +48 -0
  317. package/dist/catalog/knowledge-catalogs/re/regional-central-eastern-europe/versions/2026.10.3/manifest.json +133 -0
  318. package/dist/catalog/knowledge-catalogs/re/regional-east-asia/art.json +12 -0
  319. package/dist/catalog/knowledge-catalogs/re/regional-east-asia/logo.webp +0 -0
  320. package/dist/catalog/knowledge-catalogs/re/regional-east-asia/manifest.json +48 -0
  321. package/dist/catalog/knowledge-catalogs/re/regional-east-asia/versions/2026.10.3/manifest.json +133 -0
  322. package/dist/catalog/knowledge-catalogs/re/regional-east-southern-africa/art.json +12 -0
  323. package/dist/catalog/knowledge-catalogs/re/regional-east-southern-africa/logo.webp +0 -0
  324. package/dist/catalog/knowledge-catalogs/re/regional-east-southern-africa/manifest.json +48 -0
  325. package/dist/catalog/knowledge-catalogs/re/regional-east-southern-africa/versions/2026.10.3/manifest.json +133 -0
  326. package/dist/catalog/knowledge-catalogs/re/regional-mediterranean/art.json +12 -0
  327. package/dist/catalog/knowledge-catalogs/re/regional-mediterranean/logo.webp +0 -0
  328. package/dist/catalog/knowledge-catalogs/re/regional-mediterranean/manifest.json +48 -0
  329. package/dist/catalog/knowledge-catalogs/re/regional-mediterranean/versions/2026.10.3/manifest.json +133 -0
  330. package/dist/catalog/knowledge-catalogs/re/regional-mexico-central-america/art.json +12 -0
  331. package/dist/catalog/knowledge-catalogs/re/regional-mexico-central-america/logo.webp +0 -0
  332. package/dist/catalog/knowledge-catalogs/re/regional-mexico-central-america/manifest.json +48 -0
  333. package/dist/catalog/knowledge-catalogs/re/regional-mexico-central-america/versions/2026.10.3/manifest.json +133 -0
  334. package/dist/catalog/knowledge-catalogs/re/regional-middle-east/art.json +12 -0
  335. package/dist/catalog/knowledge-catalogs/re/regional-middle-east/logo.webp +0 -0
  336. package/dist/catalog/knowledge-catalogs/re/regional-middle-east/manifest.json +48 -0
  337. package/dist/catalog/knowledge-catalogs/re/regional-middle-east/versions/2026.10.3/manifest.json +133 -0
  338. package/dist/catalog/knowledge-catalogs/re/regional-midwest/art.json +12 -0
  339. package/dist/catalog/knowledge-catalogs/re/regional-midwest/logo.webp +0 -0
  340. package/dist/catalog/knowledge-catalogs/re/regional-midwest/manifest.json +48 -0
  341. package/dist/catalog/knowledge-catalogs/re/regional-midwest/versions/2026.10.3/manifest.json +133 -0
  342. package/dist/catalog/knowledge-catalogs/re/regional-north-africa/art.json +12 -0
  343. package/dist/catalog/knowledge-catalogs/re/regional-north-africa/logo.webp +0 -0
  344. package/dist/catalog/knowledge-catalogs/re/regional-north-africa/manifest.json +48 -0
  345. package/dist/catalog/knowledge-catalogs/re/regional-north-africa/versions/2026.10.3/manifest.json +133 -0
  346. package/dist/catalog/knowledge-catalogs/re/regional-northeast/art.json +12 -0
  347. package/dist/catalog/knowledge-catalogs/re/regional-northeast/logo.webp +0 -0
  348. package/dist/catalog/knowledge-catalogs/re/regional-northeast/manifest.json +48 -0
  349. package/dist/catalog/knowledge-catalogs/re/regional-northeast/versions/2026.10.3/manifest.json +133 -0
  350. package/dist/catalog/knowledge-catalogs/re/regional-northern-eurasia/art.json +12 -0
  351. package/dist/catalog/knowledge-catalogs/re/regional-northern-eurasia/logo.webp +0 -0
  352. package/dist/catalog/knowledge-catalogs/re/regional-northern-eurasia/manifest.json +48 -0
  353. package/dist/catalog/knowledge-catalogs/re/regional-northern-eurasia/versions/2026.10.3/manifest.json +133 -0
  354. package/dist/catalog/knowledge-catalogs/re/regional-northern-europe/art.json +12 -0
  355. package/dist/catalog/knowledge-catalogs/re/regional-northern-europe/logo.webp +0 -0
  356. package/dist/catalog/knowledge-catalogs/re/regional-northern-europe/manifest.json +48 -0
  357. package/dist/catalog/knowledge-catalogs/re/regional-northern-europe/versions/2026.10.3/manifest.json +133 -0
  358. package/dist/catalog/knowledge-catalogs/re/regional-pacific-islands/art.json +12 -0
  359. package/dist/catalog/knowledge-catalogs/re/regional-pacific-islands/logo.webp +0 -0
  360. package/dist/catalog/knowledge-catalogs/re/regional-pacific-islands/manifest.json +48 -0
  361. package/dist/catalog/knowledge-catalogs/re/regional-pacific-islands/versions/2026.10.3/manifest.json +133 -0
  362. package/dist/catalog/knowledge-catalogs/re/regional-pacific-northwest/art.json +12 -0
  363. package/dist/catalog/knowledge-catalogs/re/regional-pacific-northwest/logo.webp +0 -0
  364. package/dist/catalog/knowledge-catalogs/re/regional-pacific-northwest/manifest.json +48 -0
  365. package/dist/catalog/knowledge-catalogs/re/regional-pacific-northwest/versions/2026.10.3/manifest.json +133 -0
  366. package/dist/catalog/knowledge-catalogs/re/regional-rockies-plains/art.json +12 -0
  367. package/dist/catalog/knowledge-catalogs/re/regional-rockies-plains/logo.webp +0 -0
  368. package/dist/catalog/knowledge-catalogs/re/regional-rockies-plains/manifest.json +48 -0
  369. package/dist/catalog/knowledge-catalogs/re/regional-rockies-plains/versions/2026.10.3/manifest.json +133 -0
  370. package/dist/catalog/knowledge-catalogs/re/regional-south-asia/art.json +12 -0
  371. package/dist/catalog/knowledge-catalogs/re/regional-south-asia/logo.webp +0 -0
  372. package/dist/catalog/knowledge-catalogs/re/regional-south-asia/manifest.json +48 -0
  373. package/dist/catalog/knowledge-catalogs/re/regional-south-asia/versions/2026.10.3/manifest.json +133 -0
  374. package/dist/catalog/knowledge-catalogs/re/regional-southeast-asia/art.json +12 -0
  375. package/dist/catalog/knowledge-catalogs/re/regional-southeast-asia/logo.webp +0 -0
  376. package/dist/catalog/knowledge-catalogs/re/regional-southeast-asia/manifest.json +48 -0
  377. package/dist/catalog/knowledge-catalogs/re/regional-southeast-asia/versions/2026.10.3/manifest.json +133 -0
  378. package/dist/catalog/knowledge-catalogs/re/regional-southern-cone/art.json +12 -0
  379. package/dist/catalog/knowledge-catalogs/re/regional-southern-cone/logo.webp +0 -0
  380. package/dist/catalog/knowledge-catalogs/re/regional-southern-cone/manifest.json +48 -0
  381. package/dist/catalog/knowledge-catalogs/re/regional-southern-cone/versions/2026.10.3/manifest.json +133 -0
  382. package/dist/catalog/knowledge-catalogs/re/regional-west-central-africa/art.json +12 -0
  383. package/dist/catalog/knowledge-catalogs/re/regional-west-central-africa/logo.webp +0 -0
  384. package/dist/catalog/knowledge-catalogs/re/regional-west-central-africa/manifest.json +48 -0
  385. package/dist/catalog/knowledge-catalogs/re/regional-west-central-africa/versions/2026.10.3/manifest.json +133 -0
  386. package/dist/catalog/knowledge-catalogs/re/regional-western-europe/art.json +12 -0
  387. package/dist/catalog/knowledge-catalogs/re/regional-western-europe/logo.webp +0 -0
  388. package/dist/catalog/knowledge-catalogs/re/regional-western-europe/manifest.json +48 -0
  389. package/dist/catalog/knowledge-catalogs/re/regional-western-europe/versions/2026.10.3/manifest.json +133 -0
  390. package/dist/catalog/knowledge-catalogs/wi/wikipedia-arts/art.json +12 -0
  391. package/dist/catalog/knowledge-catalogs/wi/wikipedia-arts/logo.webp +0 -0
  392. package/dist/catalog/knowledge-catalogs/wi/wikipedia-arts/manifest.json +28 -0
  393. package/dist/catalog/knowledge-catalogs/wi/wikipedia-arts/versions/2026.4.2/manifest.json +53 -0
  394. package/dist/catalog/knowledge-catalogs/wi/wikipedia-arts/versions/2026.4.3/manifest.json +885 -0
  395. package/dist/catalog/knowledge-catalogs/wi/wikipedia-arts/versions/2026.4.5/manifest.json +157 -0
  396. package/dist/catalog/knowledge-catalogs/wi/wikipedia-astronomy/art.json +11 -0
  397. package/dist/catalog/knowledge-catalogs/wi/wikipedia-astronomy/logo.webp +0 -0
  398. package/dist/catalog/knowledge-catalogs/wi/wikipedia-astronomy/manifest.json +32 -0
  399. package/dist/catalog/knowledge-catalogs/wi/wikipedia-astronomy/versions/2026.4.2/manifest.json +69 -0
  400. package/dist/catalog/knowledge-catalogs/wi/wikipedia-astronomy/versions/2026.4.3/manifest.json +741 -0
  401. package/dist/catalog/knowledge-catalogs/wi/wikipedia-astronomy/versions/2026.4.5/manifest.json +173 -0
  402. package/dist/catalog/knowledge-catalogs/wi/wikipedia-biology/art.json +12 -0
  403. package/dist/catalog/knowledge-catalogs/wi/wikipedia-biology/logo.webp +0 -0
  404. package/dist/catalog/knowledge-catalogs/wi/wikipedia-biology/manifest.json +69 -0
  405. package/dist/catalog/knowledge-catalogs/wi/wikipedia-biology/versions/2026.4.4/manifest.json +217 -0
  406. package/dist/catalog/knowledge-catalogs/wi/wikipedia-biology/versions/2026.4.5/manifest.json +217 -0
  407. package/dist/catalog/knowledge-catalogs/wi/wikipedia-business/art.json +12 -0
  408. package/dist/catalog/knowledge-catalogs/wi/wikipedia-business/logo.webp +0 -0
  409. package/dist/catalog/knowledge-catalogs/wi/wikipedia-business/manifest.json +64 -0
  410. package/dist/catalog/knowledge-catalogs/wi/wikipedia-business/versions/2026.4.4/manifest.json +197 -0
  411. package/dist/catalog/knowledge-catalogs/wi/wikipedia-business/versions/2026.4.5/manifest.json +197 -0
  412. package/dist/catalog/knowledge-catalogs/wi/wikipedia-film-tv/art.json +12 -0
  413. package/dist/catalog/knowledge-catalogs/wi/wikipedia-film-tv/logo.webp +0 -0
  414. package/dist/catalog/knowledge-catalogs/wi/wikipedia-film-tv/manifest.json +64 -0
  415. package/dist/catalog/knowledge-catalogs/wi/wikipedia-film-tv/versions/2026.4.5/manifest.json +197 -0
  416. package/dist/catalog/knowledge-catalogs/wi/wikipedia-food-drink/art.json +11 -0
  417. package/dist/catalog/knowledge-catalogs/wi/wikipedia-food-drink/logo.webp +0 -0
  418. package/dist/catalog/knowledge-catalogs/wi/wikipedia-food-drink/manifest.json +29 -0
  419. package/dist/catalog/knowledge-catalogs/wi/wikipedia-food-drink/versions/2026.4.2/manifest.json +57 -0
  420. package/dist/catalog/knowledge-catalogs/wi/wikipedia-food-drink/versions/2026.4.3/manifest.json +925 -0
  421. package/dist/catalog/knowledge-catalogs/wi/wikipedia-food-drink/versions/2026.4.5/manifest.json +185 -0
  422. package/dist/catalog/knowledge-catalogs/wi/wikipedia-games/art.json +12 -0
  423. package/dist/catalog/knowledge-catalogs/wi/wikipedia-games/logo.webp +0 -0
  424. package/dist/catalog/knowledge-catalogs/wi/wikipedia-games/manifest.json +28 -0
  425. package/dist/catalog/knowledge-catalogs/wi/wikipedia-games/versions/2026.4.2/manifest.json +53 -0
  426. package/dist/catalog/knowledge-catalogs/wi/wikipedia-games/versions/2026.4.3/manifest.json +1665 -0
  427. package/dist/catalog/knowledge-catalogs/wi/wikipedia-games/versions/2026.4.5/manifest.json +133 -0
  428. package/dist/catalog/knowledge-catalogs/wi/wikipedia-language/art.json +12 -0
  429. package/dist/catalog/knowledge-catalogs/wi/wikipedia-language/logo.webp +0 -0
  430. package/dist/catalog/knowledge-catalogs/wi/wikipedia-language/manifest.json +29 -0
  431. package/dist/catalog/knowledge-catalogs/wi/wikipedia-language/versions/2026.4.2/manifest.json +57 -0
  432. package/dist/catalog/knowledge-catalogs/wi/wikipedia-language/versions/2026.4.3/manifest.json +1233 -0
  433. package/dist/catalog/knowledge-catalogs/wi/wikipedia-language/versions/2026.4.5/manifest.json +141 -0
  434. package/dist/catalog/knowledge-catalogs/wi/wikipedia-law/art.json +11 -0
  435. package/dist/catalog/knowledge-catalogs/wi/wikipedia-law/logo.webp +0 -0
  436. package/dist/catalog/knowledge-catalogs/wi/wikipedia-law/manifest.json +29 -0
  437. package/dist/catalog/knowledge-catalogs/wi/wikipedia-law/versions/2026.4.2/manifest.json +57 -0
  438. package/dist/catalog/knowledge-catalogs/wi/wikipedia-law/versions/2026.4.3/manifest.json +493 -0
  439. package/dist/catalog/knowledge-catalogs/wi/wikipedia-law/versions/2026.4.5/manifest.json +185 -0
  440. package/dist/catalog/knowledge-catalogs/wi/wikipedia-literature/art.json +12 -0
  441. package/dist/catalog/knowledge-catalogs/wi/wikipedia-literature/logo.webp +0 -0
  442. package/dist/catalog/knowledge-catalogs/wi/wikipedia-literature/manifest.json +63 -0
  443. package/dist/catalog/knowledge-catalogs/wi/wikipedia-literature/versions/2026.4.4/manifest.json +193 -0
  444. package/dist/catalog/knowledge-catalogs/wi/wikipedia-literature/versions/2026.4.5/manifest.json +193 -0
  445. package/dist/catalog/knowledge-catalogs/wi/wikipedia-mathematics/art.json +12 -0
  446. package/dist/catalog/knowledge-catalogs/wi/wikipedia-mathematics/logo.webp +0 -0
  447. package/dist/catalog/knowledge-catalogs/wi/wikipedia-mathematics/manifest.json +30 -0
  448. package/dist/catalog/knowledge-catalogs/wi/wikipedia-mathematics/versions/2026.4.2/manifest.json +61 -0
  449. package/dist/catalog/knowledge-catalogs/wi/wikipedia-mathematics/versions/2026.4.3/manifest.json +665 -0
  450. package/dist/catalog/knowledge-catalogs/wi/wikipedia-mathematics/versions/2026.4.5/manifest.json +177 -0
  451. package/dist/catalog/knowledge-catalogs/wi/wikipedia-medicine/art.json +12 -0
  452. package/dist/catalog/knowledge-catalogs/wi/wikipedia-medicine/logo.webp +0 -0
  453. package/dist/catalog/knowledge-catalogs/wi/wikipedia-medicine/manifest.json +29 -0
  454. package/dist/catalog/knowledge-catalogs/wi/wikipedia-medicine/versions/2026.4.2/manifest.json +57 -0
  455. package/dist/catalog/knowledge-catalogs/wi/wikipedia-medicine/versions/2026.4.3/manifest.json +745 -0
  456. package/dist/catalog/knowledge-catalogs/wi/wikipedia-medicine/versions/2026.4.5/manifest.json +185 -0
  457. package/dist/catalog/knowledge-catalogs/wi/wikipedia-military/art.json +12 -0
  458. package/dist/catalog/knowledge-catalogs/wi/wikipedia-military/logo.webp +0 -0
  459. package/dist/catalog/knowledge-catalogs/wi/wikipedia-military/manifest.json +62 -0
  460. package/dist/catalog/knowledge-catalogs/wi/wikipedia-military/versions/2026.4.4/manifest.json +189 -0
  461. package/dist/catalog/knowledge-catalogs/wi/wikipedia-military/versions/2026.4.5/manifest.json +189 -0
  462. package/dist/catalog/knowledge-catalogs/wi/wikipedia-music/art.json +12 -0
  463. package/dist/catalog/knowledge-catalogs/wi/wikipedia-music/logo.webp +0 -0
  464. package/dist/catalog/knowledge-catalogs/wi/wikipedia-music/manifest.json +64 -0
  465. package/dist/catalog/knowledge-catalogs/wi/wikipedia-music/versions/2026.4.5/manifest.json +197 -0
  466. package/dist/catalog/knowledge-catalogs/wi/wikipedia-politics/art.json +12 -0
  467. package/dist/catalog/knowledge-catalogs/wi/wikipedia-politics/logo.webp +0 -0
  468. package/dist/catalog/knowledge-catalogs/wi/wikipedia-politics/manifest.json +64 -0
  469. package/dist/catalog/knowledge-catalogs/wi/wikipedia-politics/versions/2026.4.4/manifest.json +197 -0
  470. package/dist/catalog/knowledge-catalogs/wi/wikipedia-politics/versions/2026.4.5/manifest.json +197 -0
  471. package/dist/catalog/knowledge-catalogs/wi/wikipedia-religion-philosophy/art.json +12 -0
  472. package/dist/catalog/knowledge-catalogs/wi/wikipedia-religion-philosophy/logo.webp +0 -0
  473. package/dist/catalog/knowledge-catalogs/wi/wikipedia-religion-philosophy/manifest.json +30 -0
  474. package/dist/catalog/knowledge-catalogs/wi/wikipedia-religion-philosophy/versions/2026.4.2/manifest.json +61 -0
  475. package/dist/catalog/knowledge-catalogs/wi/wikipedia-religion-philosophy/versions/2026.4.3/manifest.json +1253 -0
  476. package/dist/catalog/knowledge-catalogs/wi/wikipedia-religion-philosophy/versions/2026.4.5/manifest.json +189 -0
  477. package/dist/catalog/knowledge-catalogs/wi/wikipedia-science/art.json +12 -0
  478. package/dist/catalog/knowledge-catalogs/wi/wikipedia-science/logo.webp +0 -0
  479. package/dist/catalog/knowledge-catalogs/wi/wikipedia-science/manifest.json +29 -0
  480. package/dist/catalog/knowledge-catalogs/wi/wikipedia-science/versions/2026.4.2/manifest.json +57 -0
  481. package/dist/catalog/knowledge-catalogs/wi/wikipedia-science/versions/2026.4.3/manifest.json +1957 -0
  482. package/dist/catalog/knowledge-catalogs/wi/wikipedia-science/versions/2026.4.5/manifest.json +185 -0
  483. package/dist/catalog/knowledge-catalogs/wi/wikipedia-sports/art.json +12 -0
  484. package/dist/catalog/knowledge-catalogs/wi/wikipedia-sports/logo.webp +0 -0
  485. package/dist/catalog/knowledge-catalogs/wi/wikipedia-sports/manifest.json +63 -0
  486. package/dist/catalog/knowledge-catalogs/wi/wikipedia-sports/versions/2026.4.5/manifest.json +193 -0
  487. package/dist/catalog/knowledge-catalogs/wi/wikipedia-technology/art.json +11 -0
  488. package/dist/catalog/knowledge-catalogs/wi/wikipedia-technology/logo.webp +0 -0
  489. package/dist/catalog/knowledge-catalogs/wi/wikipedia-technology/manifest.json +45 -0
  490. package/dist/catalog/knowledge-catalogs/wi/wikipedia-technology/versions/2026.4.4/manifest.json +121 -0
  491. package/dist/catalog/knowledge-catalogs/wi/wikipedia-technology/versions/2026.4.5/manifest.json +173 -0
  492. package/dist/catalog/knowledge-catalogs/wi/wikipedia-transportation/art.json +12 -0
  493. package/dist/catalog/knowledge-catalogs/wi/wikipedia-transportation/logo.webp +0 -0
  494. package/dist/catalog/knowledge-catalogs/wi/wikipedia-transportation/manifest.json +62 -0
  495. package/dist/catalog/knowledge-catalogs/wi/wikipedia-transportation/versions/2026.4.4/manifest.json +189 -0
  496. package/dist/catalog/knowledge-catalogs/wi/wikipedia-transportation/versions/2026.4.5/manifest.json +189 -0
  497. package/dist/catalog/provenance.json +8 -0
  498. package/dist/chat/catalog-model-lookup.d.ts +21 -0
  499. package/dist/chat/catalog-model-lookup.js +48 -0
  500. package/dist/chat/local-model-tier.d.ts +1 -0
  501. package/dist/chat/local-model-tier.js +2 -0
  502. package/dist/chat/vision-capability.d.ts +1 -0
  503. package/dist/chat/vision-capability.js +3 -0
  504. package/dist/engine-components.d.ts +30 -0
  505. package/dist/engine-components.js +144 -0
  506. package/dist/engines/electron-native-reuse.d.ts +65 -0
  507. package/dist/engines/electron-native-reuse.js +305 -0
  508. package/dist/engines/native-file-manifest.json +1320 -0
  509. package/dist/engines/native-manifest.d.ts +70 -0
  510. package/dist/engines/native-manifest.js +98 -0
  511. package/dist/engines/registry.d.ts +88 -0
  512. package/dist/engines/registry.js +217 -0
  513. package/dist/engines/resolver.d.ts +121 -0
  514. package/dist/engines/resolver.js +894 -0
  515. package/dist/engines/signature.d.ts +85 -0
  516. package/dist/engines/signature.js +231 -0
  517. package/dist/fs/atomic.d.ts +53 -0
  518. package/dist/fs/atomic.js +202 -0
  519. package/dist/fs/config-store.d.ts +14 -0
  520. package/dist/fs/config-store.js +101 -0
  521. package/dist/fs/home-permissions.d.ts +18 -0
  522. package/dist/fs/home-permissions.js +27 -0
  523. package/dist/fs/safe-paths.d.ts +107 -0
  524. package/dist/fs/safe-paths.js +264 -0
  525. package/dist/fs/security-json.d.ts +13 -0
  526. package/dist/fs/security-json.js +67 -0
  527. package/dist/http/auth-context.d.ts +23 -0
  528. package/dist/http/auth-context.js +1 -0
  529. package/dist/http/engine-runtime-context.d.ts +30 -0
  530. package/dist/http/engine-runtime-context.js +1 -0
  531. package/dist/http/external-conversation-contract.d.ts +49 -0
  532. package/dist/http/external-conversation-contract.js +1 -0
  533. package/dist/http/external-conversation-headers.d.ts +11 -0
  534. package/dist/http/external-conversation-headers.js +11 -0
  535. package/dist/http/inference-context.d.ts +36 -0
  536. package/dist/http/inference-context.js +1 -0
  537. package/dist/http/model-inventory-cache.d.ts +8 -0
  538. package/dist/http/model-inventory-cache.js +8 -0
  539. package/dist/http/openai-compat/action-ledger.d.ts +15 -0
  540. package/dist/http/openai-compat/action-ledger.js +119 -0
  541. package/dist/http/openai-compat/apple-model.d.ts +3 -0
  542. package/dist/http/openai-compat/apple-model.js +44 -0
  543. package/dist/http/openai-compat/caller-owned-profile.d.ts +7 -0
  544. package/dist/http/openai-compat/caller-owned-profile.js +18 -0
  545. package/dist/http/openai-compat/chat-progress.d.ts +9 -0
  546. package/dist/http/openai-compat/chat-progress.js +69 -0
  547. package/dist/http/openai-compat/chat-target.d.ts +76 -0
  548. package/dist/http/openai-compat/chat-target.js +97 -0
  549. package/dist/http/openai-compat/embeddings.d.ts +37 -0
  550. package/dist/http/openai-compat/embeddings.js +86 -0
  551. package/dist/http/openai-compat/request-tuning.d.ts +35 -0
  552. package/dist/http/openai-compat/request-tuning.js +87 -0
  553. package/dist/http/openai-compat/responses-streaming.d.ts +351 -0
  554. package/dist/http/openai-compat/responses-streaming.js +717 -0
  555. package/dist/http/openai-compat/responses-translate.d.ts +215 -0
  556. package/dist/http/openai-compat/responses-translate.js +377 -0
  557. package/dist/http/openai-compat/streaming-telemetry.d.ts +30 -0
  558. package/dist/http/openai-compat/streaming-telemetry.js +88 -0
  559. package/dist/http/openai-compat/streaming.d.ts +141 -0
  560. package/dist/http/openai-compat/streaming.js +687 -0
  561. package/dist/http/openai-compat/tool-call-stream-filter.d.ts +33 -0
  562. package/dist/http/openai-compat/tool-call-stream-filter.js +110 -0
  563. package/dist/http/openai-compat/translate.d.ts +254 -0
  564. package/dist/http/openai-compat/translate.js +485 -0
  565. package/dist/http/routes/engines.d.ts +13 -0
  566. package/dist/http/routes/engines.js +366 -0
  567. package/dist/http/routes/machine-engine-proxy.d.ts +26 -0
  568. package/dist/http/routes/machine-engine-proxy.js +43 -0
  569. package/dist/http/routes/model-bundles.d.ts +4 -0
  570. package/dist/http/routes/model-bundles.js +190 -0
  571. package/dist/http/routes/v1-chat.d.ts +72 -0
  572. package/dist/http/routes/v1-chat.js +645 -0
  573. package/dist/http/routes/v1-embeddings.d.ts +3 -0
  574. package/dist/http/routes/v1-embeddings.js +82 -0
  575. package/dist/http/routes/v1-knowledge.d.ts +4 -0
  576. package/dist/http/routes/v1-knowledge.js +304 -0
  577. package/dist/http/routes/v1-models-ensure.d.ts +32 -0
  578. package/dist/http/routes/v1-models-ensure.js +122 -0
  579. package/dist/http/routes/v1-models.d.ts +8 -0
  580. package/dist/http/routes/v1-models.js +189 -0
  581. package/dist/http/routes/v1-responses.d.ts +20 -0
  582. package/dist/http/routes/v1-responses.js +327 -0
  583. package/dist/index.d.ts +2 -0
  584. package/dist/index.js +2 -0
  585. package/dist/inference-service.d.ts +28 -0
  586. package/dist/inference-service.js +275 -0
  587. package/dist/knowledge/admission.d.ts +3 -0
  588. package/dist/knowledge/admission.js +22 -0
  589. package/dist/knowledge/bundled-catalog.d.ts +2 -0
  590. package/dist/knowledge/bundled-catalog.js +2 -0
  591. package/dist/knowledge/catalog-host.d.ts +103 -0
  592. package/dist/knowledge/catalog-host.js +180 -0
  593. package/dist/knowledge/catalog-source.d.ts +22 -0
  594. package/dist/knowledge/catalog-source.js +35 -0
  595. package/dist/knowledge/install.d.ts +55 -0
  596. package/dist/knowledge/install.js +274 -0
  597. package/dist/knowledge/manager.d.ts +287 -0
  598. package/dist/knowledge/manager.js +1540 -0
  599. package/dist/knowledge/registry.d.ts +35 -0
  600. package/dist/knowledge/registry.js +123 -0
  601. package/dist/knowledge/search-worker.d.ts +17 -0
  602. package/dist/knowledge/search-worker.js +36 -0
  603. package/dist/knowledge/shared-install-contract.d.ts +19 -0
  604. package/dist/knowledge/shared-install-contract.js +1 -0
  605. package/dist/knowledge/spatial-query.d.ts +11 -0
  606. package/dist/knowledge/spatial-query.js +33 -0
  607. package/dist/knowledge/trust-anchors.d.ts +11 -0
  608. package/dist/knowledge/trust-anchors.js +51 -0
  609. package/dist/knowledge/vector-floors.d.ts +44 -0
  610. package/dist/knowledge/vector-floors.js +92 -0
  611. package/dist/knowledge/worker-host.d.ts +9 -0
  612. package/dist/knowledge/worker-host.js +179 -0
  613. package/dist/kokoro-lexicon/LICENSE +202 -0
  614. package/dist/kokoro-lexicon/lexicon-gb-en.txt.gz +0 -0
  615. package/dist/kokoro-lexicon/lexicon-us-en.txt.gz +0 -0
  616. package/dist/kokoro-lexicon/manifest.json +23 -0
  617. package/dist/machine-engine/inspect-runtime.d.ts +3 -0
  618. package/dist/machine-engine/inspect-runtime.js +48 -0
  619. package/dist/machine-engine/knowledge-assets.d.ts +79 -0
  620. package/dist/machine-engine/knowledge-assets.js +505 -0
  621. package/dist/memory/embed-core.d.ts +131 -0
  622. package/dist/memory/embed-core.js +398 -0
  623. package/dist/memory/embed-worker.d.ts +23 -0
  624. package/dist/memory/embed-worker.js +49 -0
  625. package/dist/memory/embeddings.d.ts +105 -0
  626. package/dist/memory/embeddings.js +467 -0
  627. package/dist/model-profile/behaviors/tools-mlx-template-fix.d.ts +1 -0
  628. package/dist/model-profile/behaviors/tools-mlx-template-fix.js +2 -0
  629. package/dist/model-profile/behaviors/turn-ramble-detection.d.ts +1 -0
  630. package/dist/model-profile/behaviors/turn-ramble-detection.js +2 -0
  631. package/dist/model-profile/defaults.d.ts +1 -0
  632. package/dist/model-profile/defaults.js +2 -0
  633. package/dist/model-profile/index.d.ts +9 -0
  634. package/dist/model-profile/index.js +7 -0
  635. package/dist/model-profile/registry.d.ts +15 -0
  636. package/dist/model-profile/registry.js +18 -0
  637. package/dist/model-profile/runtime.d.ts +48 -0
  638. package/dist/model-profile/runtime.js +131 -0
  639. package/dist/model-profile/tool-grammar.d.ts +1 -0
  640. package/dist/model-profile/tool-grammar.js +2 -0
  641. package/dist/model-profile/tuning.d.ts +19 -0
  642. package/dist/model-profile/tuning.js +21 -0
  643. package/dist/model-profile/types.d.ts +1 -0
  644. package/dist/model-profile/types.js +2 -0
  645. package/dist/models/bundle-storage.d.ts +28 -0
  646. package/dist/models/bundle-storage.js +80 -0
  647. package/dist/models/catalog-drift.d.ts +48 -0
  648. package/dist/models/catalog-drift.js +94 -0
  649. package/dist/models/catalog-payload-identity.d.ts +107 -0
  650. package/dist/models/catalog-payload-identity.js +254 -0
  651. package/dist/models/ensure.d.ts +125 -0
  652. package/dist/models/ensure.js +205 -0
  653. package/dist/models/gezmodel.d.ts +47 -0
  654. package/dist/models/gezmodel.js +742 -0
  655. package/dist/models/install-registry.d.ts +101 -0
  656. package/dist/models/install-registry.js +216 -0
  657. package/dist/models/model-id.d.ts +22 -0
  658. package/dist/models/model-id.js +40 -0
  659. package/dist/models/storage-roots.d.ts +274 -0
  660. package/dist/models/storage-roots.js +865 -0
  661. package/dist/native-release-entry.d.ts +16 -0
  662. package/dist/native-release-entry.js +16 -0
  663. package/dist/perf/redact-path.d.ts +2 -0
  664. package/dist/perf/redact-path.js +27 -0
  665. package/dist/perf/responsiveness.d.ts +70 -0
  666. package/dist/perf/responsiveness.js +560 -0
  667. package/dist/providers/active-install-message.d.ts +42 -0
  668. package/dist/providers/active-install-message.js +49 -0
  669. package/dist/providers/apple-foundation-models/binary.d.ts +4 -0
  670. package/dist/providers/apple-foundation-models/binary.js +18 -0
  671. package/dist/providers/apple-foundation-models/helper.d.ts +66 -0
  672. package/dist/providers/apple-foundation-models/helper.js +262 -0
  673. package/dist/providers/apple-foundation-models/provider.d.ts +82 -0
  674. package/dist/providers/apple-foundation-models/provider.js +389 -0
  675. package/dist/providers/apple-foundation-models/status.d.ts +9 -0
  676. package/dist/providers/apple-foundation-models/status.js +49 -0
  677. package/dist/providers/audio/kokoro-frontend.d.ts +50 -0
  678. package/dist/providers/audio/kokoro-frontend.js +113 -0
  679. package/dist/providers/audio/managed-speech-model.d.ts +9 -0
  680. package/dist/providers/audio/managed-speech-model.js +86 -0
  681. package/dist/providers/audio/types.d.ts +202 -0
  682. package/dist/providers/audio/types.js +17 -0
  683. package/dist/providers/audio/whisper-cpp.d.ts +99 -0
  684. package/dist/providers/audio/whisper-cpp.js +420 -0
  685. package/dist/providers/audio-persister-contract.d.ts +13 -0
  686. package/dist/providers/audio-persister-contract.js +1 -0
  687. package/dist/providers/catalog-model-config.d.ts +63 -0
  688. package/dist/providers/catalog-model-config.js +95 -0
  689. package/dist/providers/code-block-salvage.d.ts +1 -0
  690. package/dist/providers/code-block-salvage.js +2 -0
  691. package/dist/providers/codex-cli/reasoning.d.ts +8 -0
  692. package/dist/providers/codex-cli/reasoning.js +17 -0
  693. package/dist/providers/complete-tool-call.d.ts +16 -0
  694. package/dist/providers/complete-tool-call.js +25 -0
  695. package/dist/providers/constrained-turn.d.ts +1 -0
  696. package/dist/providers/constrained-turn.js +2 -0
  697. package/dist/providers/deliverable-read-pacing.d.ts +1 -0
  698. package/dist/providers/deliverable-read-pacing.js +2 -0
  699. package/dist/providers/direct-file-work-prompt.d.ts +1 -0
  700. package/dist/providers/direct-file-work-prompt.js +2 -0
  701. package/dist/providers/ds4/build-provider.d.ts +100 -0
  702. package/dist/providers/ds4/build-provider.js +539 -0
  703. package/dist/providers/ds4/cache-adapter.d.ts +42 -0
  704. package/dist/providers/ds4/cache-adapter.js +110 -0
  705. package/dist/providers/ds4/dspark.d.ts +83 -0
  706. package/dist/providers/ds4/dspark.js +107 -0
  707. package/dist/providers/ds4/mtp.d.ts +32 -0
  708. package/dist/providers/ds4/mtp.js +46 -0
  709. package/dist/providers/ds4/provider.d.ts +67 -0
  710. package/dist/providers/ds4/provider.js +104 -0
  711. package/dist/providers/ds4/residency.d.ts +143 -0
  712. package/dist/providers/ds4/residency.js +139 -0
  713. package/dist/providers/ds4/stdout-parser.d.ts +47 -0
  714. package/dist/providers/ds4/stdout-parser.js +134 -0
  715. package/dist/providers/duplicate-tool-calls.d.ts +1 -0
  716. package/dist/providers/duplicate-tool-calls.js +2 -0
  717. package/dist/providers/file-repair-policy.d.ts +1 -0
  718. package/dist/providers/file-repair-policy.js +2 -0
  719. package/dist/providers/gpu-arbiter.d.ts +159 -0
  720. package/dist/providers/gpu-arbiter.js +301 -0
  721. package/dist/providers/image-persister-contract.d.ts +15 -0
  722. package/dist/providers/image-persister-contract.js +1 -0
  723. package/dist/providers/llama-cpp/build-metadata.d.ts +13 -0
  724. package/dist/providers/llama-cpp/build-metadata.js +39 -0
  725. package/dist/providers/llama-cpp/build-provider.d.ts +66 -0
  726. package/dist/providers/llama-cpp/build-provider.js +1491 -0
  727. package/dist/providers/llama-cpp/cache-adapter.d.ts +242 -0
  728. package/dist/providers/llama-cpp/cache-adapter.js +689 -0
  729. package/dist/providers/llama-cpp/devices.d.ts +130 -0
  730. package/dist/providers/llama-cpp/devices.js +256 -0
  731. package/dist/providers/llama-cpp/disk-cache.d.ts +8 -0
  732. package/dist/providers/llama-cpp/disk-cache.js +112 -0
  733. package/dist/providers/llama-cpp/engine-flags.d.ts +181 -0
  734. package/dist/providers/llama-cpp/engine-flags.js +279 -0
  735. package/dist/providers/llama-cpp/gguf-metadata-async.d.ts +11 -0
  736. package/dist/providers/llama-cpp/gguf-metadata-async.js +180 -0
  737. package/dist/providers/llama-cpp/gguf-metadata-worker.d.ts +7 -0
  738. package/dist/providers/llama-cpp/gguf-metadata-worker.js +27 -0
  739. package/dist/providers/llama-cpp/gguf-metadata.d.ts +198 -0
  740. package/dist/providers/llama-cpp/gguf-metadata.js +615 -0
  741. package/dist/providers/llama-cpp/gguf-quantization-backfill.d.ts +32 -0
  742. package/dist/providers/llama-cpp/gguf-quantization-backfill.js +75 -0
  743. package/dist/providers/llama-cpp/index.d.ts +10 -0
  744. package/dist/providers/llama-cpp/index.js +13 -0
  745. package/dist/providers/llama-cpp/kv-cache-type.d.ts +118 -0
  746. package/dist/providers/llama-cpp/kv-cache-type.js +140 -0
  747. package/dist/providers/llama-cpp/log.d.ts +92 -0
  748. package/dist/providers/llama-cpp/log.js +280 -0
  749. package/dist/providers/llama-cpp/models.d.ts +389 -0
  750. package/dist/providers/llama-cpp/models.js +1011 -0
  751. package/dist/providers/llama-cpp/offload-planner.d.ts +339 -0
  752. package/dist/providers/llama-cpp/offload-planner.js +524 -0
  753. package/dist/providers/llama-cpp/provider.d.ts +493 -0
  754. package/dist/providers/llama-cpp/provider.js +862 -0
  755. package/dist/providers/llama-cpp/reasoning-launch.d.ts +7 -0
  756. package/dist/providers/llama-cpp/reasoning-launch.js +14 -0
  757. package/dist/providers/llama-cpp/spec-draft.d.ts +44 -0
  758. package/dist/providers/llama-cpp/spec-draft.js +44 -0
  759. package/dist/providers/llama-cpp/stdout-parser.d.ts +70 -0
  760. package/dist/providers/llama-cpp/stdout-parser.js +197 -0
  761. package/dist/providers/local-tool-call-salvage.d.ts +1 -0
  762. package/dist/providers/local-tool-call-salvage.js +2 -0
  763. package/dist/providers/local-turn-policy.d.ts +1 -0
  764. package/dist/providers/local-turn-policy.js +2 -0
  765. package/dist/providers/mlx/async-file-handoff.d.ts +11 -0
  766. package/dist/providers/mlx/async-file-handoff.js +25 -0
  767. package/dist/providers/mlx/build-provider.d.ts +65 -0
  768. package/dist/providers/mlx/build-provider.js +717 -0
  769. package/dist/providers/mlx/cache-adapter.d.ts +161 -0
  770. package/dist/providers/mlx/cache-adapter.js +445 -0
  771. package/dist/providers/mlx/chat-protocol.d.ts +48 -0
  772. package/dist/providers/mlx/chat-protocol.js +8 -0
  773. package/dist/providers/mlx/config-parser.d.ts +29 -0
  774. package/dist/providers/mlx/config-parser.js +81 -0
  775. package/dist/providers/mlx/engine-gate.d.ts +51 -0
  776. package/dist/providers/mlx/engine-gate.js +207 -0
  777. package/dist/providers/mlx/engine-hold.d.ts +41 -0
  778. package/dist/providers/mlx/engine-hold.js +59 -0
  779. package/dist/providers/mlx/engine-log-router.d.ts +84 -0
  780. package/dist/providers/mlx/engine-log-router.js +137 -0
  781. package/dist/providers/mlx/engine-stats-sampler.d.ts +36 -0
  782. package/dist/providers/mlx/engine-stats-sampler.js +59 -0
  783. package/dist/providers/mlx/index.d.ts +10 -0
  784. package/dist/providers/mlx/index.js +10 -0
  785. package/dist/providers/mlx/log.d.ts +55 -0
  786. package/dist/providers/mlx/log.js +157 -0
  787. package/dist/providers/mlx/model-geometry.d.ts +35 -0
  788. package/dist/providers/mlx/model-geometry.js +118 -0
  789. package/dist/providers/mlx/models.d.ts +289 -0
  790. package/dist/providers/mlx/models.js +1079 -0
  791. package/dist/providers/mlx/provider.d.ts +404 -0
  792. package/dist/providers/mlx/provider.js +3017 -0
  793. package/dist/providers/mlx/python/cache_persist.py +348 -0
  794. package/dist/providers/mlx/python/cache_seed.py +402 -0
  795. package/dist/providers/mlx/python/gezel_mlx_server.py +4491 -0
  796. package/dist/providers/mlx/python/lfm2_compat.py +55 -0
  797. package/dist/providers/mlx/python/qwen3_5_text_compat.py +60 -0
  798. package/dist/providers/mlx/python/qwen4_ple.py +159 -0
  799. package/dist/providers/mlx/python/spec_decode.py +775 -0
  800. package/dist/providers/mlx/python/template_stability.py +133 -0
  801. package/dist/providers/mlx/python/think_budget.py +113 -0
  802. package/dist/providers/mlx/python/tool_args_json.py +297 -0
  803. package/dist/providers/mlx/python/tool_call_stream.py +265 -0
  804. package/dist/providers/mlx/python/tool_grammar.py +794 -0
  805. package/dist/providers/mlx/python/vision_inputs.py +64 -0
  806. package/dist/providers/mlx/python/wave_policy.py +147 -0
  807. package/dist/providers/mlx/reasoning-stream.d.ts +85 -0
  808. package/dist/providers/mlx/reasoning-stream.js +196 -0
  809. package/dist/providers/mlx/request-shape.d.ts +34 -0
  810. package/dist/providers/mlx/request-shape.js +42 -0
  811. package/dist/providers/mlx/runtime-diagnostics.d.ts +29 -0
  812. package/dist/providers/mlx/runtime-diagnostics.js +162 -0
  813. package/dist/providers/mlx/spec-drafter.d.ts +25 -0
  814. package/dist/providers/mlx/spec-drafter.js +73 -0
  815. package/dist/providers/mlx/stdout-parser.d.ts +60 -0
  816. package/dist/providers/mlx/stdout-parser.js +254 -0
  817. package/dist/providers/mlx/textual-tool-call-salvage.d.ts +46 -0
  818. package/dist/providers/mlx/textual-tool-call-salvage.js +396 -0
  819. package/dist/providers/mlx/tool-call-protocol.d.ts +65 -0
  820. package/dist/providers/mlx/tool-call-protocol.js +140 -0
  821. package/dist/providers/mlx/tool-call-stripper.d.ts +68 -0
  822. package/dist/providers/mlx/tool-call-stripper.js +153 -0
  823. package/dist/providers/mlx/tool-image-retention.d.ts +23 -0
  824. package/dist/providers/mlx/tool-image-retention.js +43 -0
  825. package/dist/providers/mlx/turn-telemetry.d.ts +22 -0
  826. package/dist/providers/mlx/turn-telemetry.js +45 -0
  827. package/dist/providers/mlx/venv.d.ts +91 -0
  828. package/dist/providers/mlx/venv.js +111 -0
  829. package/dist/providers/mlx/vision-mode.d.ts +92 -0
  830. package/dist/providers/mlx/vision-mode.js +187 -0
  831. package/dist/providers/mlx/vision.d.ts +2 -0
  832. package/dist/providers/mlx/vision.js +12 -0
  833. package/dist/providers/mlx/wire-transcript.d.ts +14 -0
  834. package/dist/providers/mlx/wire-transcript.js +43 -0
  835. package/dist/providers/native/capacity-broker.d.ts +812 -0
  836. package/dist/providers/native/capacity-broker.js +1058 -0
  837. package/dist/providers/native/capacity-budget.d.ts +133 -0
  838. package/dist/providers/native/capacity-budget.js +265 -0
  839. package/dist/providers/native/device-capacity-ledger.d.ts +31 -0
  840. package/dist/providers/native/device-capacity-ledger.js +196 -0
  841. package/dist/providers/native/device-capacity.d.ts +84 -0
  842. package/dist/providers/native/device-capacity.js +431 -0
  843. package/dist/providers/native/engine-api-key.d.ts +57 -0
  844. package/dist/providers/native/engine-api-key.js +72 -0
  845. package/dist/providers/native/engine-key.d.ts +18 -0
  846. package/dist/providers/native/engine-key.js +41 -0
  847. package/dist/providers/native/engine-router.d.ts +145 -0
  848. package/dist/providers/native/engine-router.js +191 -0
  849. package/dist/providers/native/gpu-panic-guard.d.ts +54 -0
  850. package/dist/providers/native/gpu-panic-guard.js +59 -0
  851. package/dist/providers/native/inference.d.ts +33 -0
  852. package/dist/providers/native/inference.js +49 -0
  853. package/dist/providers/native/local-engine-runtime.d.ts +412 -0
  854. package/dist/providers/native/local-engine-runtime.js +1714 -0
  855. package/dist/providers/native/measured-budget.d.ts +32 -0
  856. package/dist/providers/native/measured-budget.js +54 -0
  857. package/dist/providers/native/port.d.ts +11 -0
  858. package/dist/providers/native/port.js +29 -0
  859. package/dist/providers/native/provider-pool.d.ts +474 -0
  860. package/dist/providers/native/provider-pool.js +1166 -0
  861. package/dist/providers/native/supervisor.d.ts +503 -0
  862. package/dist/providers/native/supervisor.js +1466 -0
  863. package/dist/providers/observation-context.d.ts +16 -0
  864. package/dist/providers/observation-context.js +1 -0
  865. package/dist/providers/openai-compatible/sse.d.ts +1 -0
  866. package/dist/providers/openai-compatible/sse.js +2 -0
  867. package/dist/providers/patient-fetch.d.ts +36 -0
  868. package/dist/providers/patient-fetch.js +44 -0
  869. package/dist/providers/project-macro-loop-bail.d.ts +7 -0
  870. package/dist/providers/project-macro-loop-bail.js +21 -0
  871. package/dist/providers/prose-document-salvage.d.ts +1 -0
  872. package/dist/providers/prose-document-salvage.js +2 -0
  873. package/dist/providers/provider-disposal.d.ts +1 -0
  874. package/dist/providers/provider-disposal.js +2 -0
  875. package/dist/providers/queue.d.ts +15 -0
  876. package/dist/providers/queue.js +23 -0
  877. package/dist/providers/ramble-abort-message.d.ts +1 -0
  878. package/dist/providers/ramble-abort-message.js +2 -0
  879. package/dist/providers/ramble-detector.d.ts +1 -0
  880. package/dist/providers/ramble-detector.js +2 -0
  881. package/dist/providers/reasoning-depth.d.ts +1 -0
  882. package/dist/providers/reasoning-depth.js +2 -0
  883. package/dist/providers/required-input-reads.d.ts +1 -0
  884. package/dist/providers/required-input-reads.js +2 -0
  885. package/dist/providers/session-defaults.d.ts +13 -0
  886. package/dist/providers/session-defaults.js +49 -0
  887. package/dist/providers/session-hooks.d.ts +26 -0
  888. package/dist/providers/session-hooks.js +1 -0
  889. package/dist/providers/streaming-session.d.ts +1 -0
  890. package/dist/providers/streaming-session.js +2 -0
  891. package/dist/providers/terminal-tool-policy.d.ts +1 -0
  892. package/dist/providers/terminal-tool-policy.js +2 -0
  893. package/dist/providers/tool-arg-schema-coercion.d.ts +1 -0
  894. package/dist/providers/tool-arg-schema-coercion.js +2 -0
  895. package/dist/providers/tool-executor.d.ts +12 -0
  896. package/dist/providers/tool-executor.js +20 -0
  897. package/dist/providers/tool-failure-tracker.d.ts +1 -0
  898. package/dist/providers/tool-failure-tracker.js +2 -0
  899. package/dist/providers/tool-repeat-tracker.d.ts +1 -0
  900. package/dist/providers/tool-repeat-tracker.js +2 -0
  901. package/dist/providers/turn-timeout.d.ts +1 -0
  902. package/dist/providers/turn-timeout.js +1 -0
  903. package/dist/providers/types.d.ts +834 -0
  904. package/dist/providers/types.js +42 -0
  905. package/dist/providers/usage-builder.d.ts +1 -0
  906. package/dist/providers/usage-builder.js +2 -0
  907. package/dist/providers/vision-capability.d.ts +109 -0
  908. package/dist/providers/vision-capability.js +137 -0
  909. package/dist/python/mlx-runtime-status-bus.d.ts +39 -0
  910. package/dist/python/mlx-runtime-status-bus.js +27 -0
  911. package/dist/python/uv-runtime.d.ts +176 -0
  912. package/dist/python/uv-runtime.js +492 -0
  913. package/dist/relevance/install.d.ts +28 -0
  914. package/dist/relevance/install.js +114 -0
  915. package/dist/relevance/manager.d.ts +79 -0
  916. package/dist/relevance/manager.js +211 -0
  917. package/dist/relevance/registry.d.ts +11 -0
  918. package/dist/relevance/registry.js +158 -0
  919. package/dist/relevance/relevance-core.d.ts +67 -0
  920. package/dist/relevance/relevance-core.js +189 -0
  921. package/dist/relevance/relevance-model.d.ts +42 -0
  922. package/dist/relevance/relevance-model.js +292 -0
  923. package/dist/relevance/relevance-worker.d.ts +20 -0
  924. package/dist/relevance/relevance-worker.js +57 -0
  925. package/dist/relevance/settings.d.ts +30 -0
  926. package/dist/relevance/settings.js +81 -0
  927. package/dist/remotes/identity.d.ts +121 -0
  928. package/dist/remotes/identity.js +348 -0
  929. package/dist/remotes/pinned-fetch.d.ts +45 -0
  930. package/dist/remotes/pinned-fetch.js +193 -0
  931. package/dist/remotes/types.d.ts +54 -0
  932. package/dist/remotes/types.js +1 -0
  933. package/dist/runtime-lock.d.ts +29 -0
  934. package/dist/runtime-lock.js +85 -0
  935. package/dist/search/relevance-stage.d.ts +81 -0
  936. package/dist/search/relevance-stage.js +177 -0
  937. package/dist/secrets/types.d.ts +63 -0
  938. package/dist/secrets/types.js +64 -0
  939. package/dist/speech.d.ts +1 -0
  940. package/dist/speech.js +1 -0
  941. package/dist/system/darwin-memory.d.ts +26 -0
  942. package/dist/system/darwin-memory.js +81 -0
  943. package/dist/system/gezel-process-memory.d.ts +55 -0
  944. package/dist/system/gezel-process-memory.js +156 -0
  945. package/dist/system/memory.d.ts +154 -0
  946. package/dist/system/memory.js +501 -0
  947. package/dist/transformers-cache.d.ts +112 -0
  948. package/dist/transformers-cache.js +392 -0
  949. package/dist/utils/disk-space.d.ts +55 -0
  950. package/dist/utils/disk-space.js +72 -0
  951. package/dist/utils/download-common.d.ts +138 -0
  952. package/dist/utils/download-common.js +196 -0
  953. package/dist/utils/download-with-retry.d.ts +85 -0
  954. package/dist/utils/download-with-retry.js +522 -0
  955. package/dist/utils/extract-zip.d.ts +22 -0
  956. package/dist/utils/extract-zip.js +103 -0
  957. package/dist/utils/retire-model-worker.d.ts +15 -0
  958. package/dist/utils/retire-model-worker.js +24 -0
  959. package/dist/utils/service-worker-entry.d.ts +59 -0
  960. package/dist/utils/service-worker-entry.js +69 -0
  961. package/dist/utils/xet-download.d.ts +40 -0
  962. package/dist/utils/xet-download.js +526 -0
  963. package/dist/utils/xet.d.ts +86 -0
  964. package/dist/utils/xet.js +201 -0
  965. package/package.json +103 -3
  966. package/scripts/embedding-packaging.cjs +264 -0
  967. package/scripts/embedding-packaging.d.cts +16 -0
@@ -0,0 +1,1058 @@
1
+ /**
2
+ * CapacityBroker — single source of truth for "do we have headroom
3
+ * to load another local model?" Sums per-engine `residentBytes`
4
+ * reservations against a budget (auto-derived from system RAM, or
5
+ * explicitly set in config) and decides reserve / deny.
6
+ *
7
+ * The broker tracks reservations, not actual RSS. Treating
8
+ * `residentBytes` from the catalog as the source of truth keeps the
9
+ * logic deterministic and fast — a polling RSS reader would race the
10
+ * reserve→spawn window where committed > actual. The catalog number
11
+ * intentionally over-estimates (working set + buffers), so the broker
12
+ * is conservative in the right direction.
13
+ *
14
+ * Lifecycle: every supervisor spawn calls `reserve(key, bytes)`;
15
+ * every supervisor stop (idle, eviction, shutdown) calls
16
+ * `release(key)`. The pool decides what to do when `reserve` returns
17
+ * false — typically: pick LRU and evict, then retry.
18
+ */
19
+ import { execFileSync } from 'node:child_process';
20
+ import { readFileSync } from 'node:fs';
21
+ import { freemem, totalmem } from 'node:os';
22
+ import { CONSTRAINED_LOCAL_CONTEXT_FLOOR_TOKENS, LLAMA_CPP_COMPUTE_HEADROOM, LOCAL_CONTEXT_FLOOR_TOKENS, MLX_COMPUTE_HEADROOM, createLogger, estimateLlamaCppResidentBytes, estimateMlxResidentBytes, localContextFloorTokens, } from '@bendyline/gezel';
23
+ import { autoAllowRamSpillover, computeCapacityBudget, fastMemoryBudgetBytes, getDetectedGpuVramBytes, } from './capacity-budget.js';
24
+ export { autoAllowRamSpillover, autoDetectBudgetBytes, computeCapacityBudget, getDetectedGpuVramBytes, pressureIdleGraceMs, setDetectedGpuVramBytes, } from './capacity-budget.js';
25
+ export { fastMemoryBudgetBytes };
26
+ const log = createLogger('capacity-broker');
27
+ /** Format a byte count as GB with one decimal (e.g. `14.3 GB`). */
28
+ function formatGb(bytes) {
29
+ return `${(bytes / 1024 ** 3).toFixed(1)} GB`;
30
+ }
31
+ /**
32
+ * Turn a raw capacity denial into a human-readable, actionable
33
+ * message. The raw broker reason (`budget exhausted: would commit
34
+ * 14326180192 against 10307921510`) is fine for logs but unreadable in
35
+ * a chat bubble — this is what the user actually sees when a model is
36
+ * too big to load.
37
+ */
38
+ export function formatCapacityDenial(opts) {
39
+ const { modelLabel, requestedBytes, budgetBytes, committedBytes, systemRamBytes, pools } = opts;
40
+ // A co-residency refusal is a different problem with different advice: the
41
+ // machine has the memory, but keeping this model on the card means the
42
+ // others cannot stay. It only reaches a user when eviction couldn't clear
43
+ // the room (every other model busy), so "wait or close a chat" is the fix,
44
+ // not "buy a smaller model".
45
+ if (opts.coResidencyBytes !== undefined && opts.coResidencyBytes < budgetBytes) {
46
+ return [
47
+ `Not enough graphics memory to add ${modelLabel} (about ${formatGb(requestedBytes)}) `,
48
+ `next to the models already loaded (${formatGb(committedBytes)} of `,
49
+ `${formatGb(opts.coResidencyBytes)}). Gezel is set to keep models on the graphics card `,
50
+ 'rather than let them spill into system memory, so it unloads one model to make room for ',
51
+ 'another — but every loaded model is busy right now. Wait for a turn to finish, or allow ',
52
+ 'system-memory spillover in Settings under the engine that runs it, which keeps them all ',
53
+ 'loaded at reduced speed.',
54
+ ].join('');
55
+ }
56
+ const free = Math.max(0, budgetBytes - committedBytes);
57
+ const parts = [
58
+ `Not enough memory to run ${modelLabel}: it needs about ${formatGb(requestedBytes)}, ` +
59
+ `but only ${formatGb(free)} is available for models`,
60
+ ];
61
+ if (pools && pools.kind === 'discrete-gpu' && pools.vramBytes > 0) {
62
+ parts.push(` (the model budget is ${formatGb(budgetBytes)} — ${formatGb(pools.vramBytes)} of ` +
63
+ `graphics memory plus ${formatGb(pools.ramShareBytes)} of this machine's ` +
64
+ `${formatGb(systemRamBytes)} system memory, with the rest left for everything else)`);
65
+ }
66
+ else if (systemRamBytes > 0) {
67
+ const pct = Math.round((budgetBytes / systemRamBytes) * 100);
68
+ parts.push(` (the model budget is ${formatGb(budgetBytes)} — about ${pct}% of your ` +
69
+ `${formatGb(systemRamBytes)} machine, with the rest left for everything else)`);
70
+ }
71
+ else {
72
+ parts.push(` (model budget ${formatGb(budgetBytes)})`);
73
+ }
74
+ parts.push('. ');
75
+ if (committedBytes > 0) {
76
+ parts.push(`Other models are currently using ${formatGb(committedBytes)}; closing one may free enough room. `);
77
+ }
78
+ parts.push('Try a smaller or more-quantized model, or raise the memory budget in ' +
79
+ 'Settings under the engine that runs it — at your own risk, since a ' +
80
+ 'budget the machine cannot back may make the app run out of memory.');
81
+ return parts.join('');
82
+ }
83
+ /**
84
+ * A model that could not be admitted for lack of memory. The message is
85
+ * unchanged from what `formatCapacityDenial` always produced — the class
86
+ * exists purely so `describeTurnError` can tell an out-of-memory refusal
87
+ * apart from an engine crash, since the two need very different advice in
88
+ * a bug report.
89
+ */
90
+ export class CapacityDeniedError extends Error {
91
+ code = 'capacity-denied';
92
+ /**
93
+ * Machine-readable cause when the human message alone would mislead a
94
+ * downstream surface. `resident-below-minimum` = the model is ALREADY
95
+ * running with a window smaller than the current policy requires — the
96
+ * remedy is an engine restart, not freeing memory, and the models list
97
+ * must not render it as a generic "won't fit".
98
+ */
99
+ reason;
100
+ constructor(message, opts) {
101
+ super(message);
102
+ this.name = 'CapacityDeniedError';
103
+ if (opts?.reason)
104
+ this.reason = opts.reason;
105
+ }
106
+ }
107
+ /**
108
+ * A resident engine could not be evicted in time to make room because it
109
+ * was still serving requests. Unlike {@link CapacityDeniedError} this is a
110
+ * *transient* condition — nothing is wrong with the model that wanted room;
111
+ * the caller should retry once current turns drain. The `code` lets the
112
+ * fitness probe classify the failure as "did not run" rather than "failed".
113
+ */
114
+ export class EngineBusyError extends Error {
115
+ code = 'engine-busy';
116
+ constructor(message) {
117
+ super(message);
118
+ this.name = 'EngineBusyError';
119
+ }
120
+ }
121
+ /**
122
+ * Did this failure come from the pool refusing to make room, rather than from
123
+ * the model? Match the `code` first, and fall back to the stable message so a
124
+ * rewrapped error (the one-shot and provider layers both re-throw) still
125
+ * classifies right.
126
+ *
127
+ * Callers must not charge this to whatever they were working on: the request
128
+ * never reached a model, so it is evidence about neither the target nor the
129
+ * input. The fitness probe records `blocked` ("did not run"); index enrichment
130
+ * defers the file with its retry budget untouched.
131
+ */
132
+ /**
133
+ * True for a refusal to load a model at all. Like {@link isEngineBusyError}
134
+ * this is a "never dispatched" signal: nothing reached a model, so it is
135
+ * evidence about neither the target's health nor the request's content.
136
+ */
137
+ export function isCapacityDeniedError(err) {
138
+ return !!err && typeof err === 'object' && err.code === 'capacity-denied';
139
+ }
140
+ export function isEngineBusyError(err) {
141
+ if (err && typeof err === 'object' && err.code === 'engine-busy') {
142
+ return true;
143
+ }
144
+ const message = err instanceof Error ? err.message : String(err);
145
+ return /did not drain|busy serving requests/i.test(message);
146
+ }
147
+ export class CapacityBroker {
148
+ budgetBytes;
149
+ enforced;
150
+ explicitBudgetBytes;
151
+ systemRamBytes;
152
+ unifiedMemory;
153
+ gpuVramBytes;
154
+ explicitAllowRamSpillover;
155
+ reservations = new Map();
156
+ constructor(opts = {}) {
157
+ this.systemRamBytes = (opts.systemRamBytes ?? totalmem)();
158
+ this.unifiedMemory = opts.unifiedMemory;
159
+ this.gpuVramBytes = opts.gpuVramBytes;
160
+ this.explicitAllowRamSpillover = opts.allowRamSpillover ?? null;
161
+ this.explicitBudgetBytes = opts.budgetBytes ?? null;
162
+ // Assigned by applyBudget; the definite-assignment dance TS wants for
163
+ // fields a constructor sets through a helper.
164
+ this.budgetBytes = 0;
165
+ this.enforced = false;
166
+ this.applyBudget();
167
+ }
168
+ /**
169
+ * The broker is built once and lives for the whole process, so the host
170
+ * shape it was handed at construction is the one every later admission is
171
+ * priced against. `gpuVramBytes: null` there means "the boot probe reported
172
+ * no accelerator" — which is also exactly what a probe that TIMED OUT
173
+ * reports, and `nvidia-smi` on a laptop dGPU parked in a low-power state
174
+ * routinely loses its 2s race. Pinning that answer turns one slow probe
175
+ * into a RAM-only budget for the life of the daemon.
176
+ *
177
+ * So a card measured SINCE construction wins, by deferring the whole host
178
+ * shape — VRAM and the unified flag together — to the published probe. A
179
+ * host that genuinely has no accelerator publishes `null` too, and nothing
180
+ * changes for it.
181
+ */
182
+ autoBudget() {
183
+ const measuredSince = (this.gpuVramBytes === undefined || this.gpuVramBytes === null) &&
184
+ getDetectedGpuVramBytes() !== null;
185
+ return computeCapacityBudget({
186
+ systemRamBytes: this.systemRamBytes,
187
+ ...(measuredSince
188
+ ? {}
189
+ : {
190
+ ...(this.unifiedMemory === undefined ? {} : { unifiedMemory: this.unifiedMemory }),
191
+ ...(this.gpuVramBytes === undefined ? {} : { gpuVramBytes: this.gpuVramBytes }),
192
+ }),
193
+ });
194
+ }
195
+ /**
196
+ * Re-derive the auto budget when the host measurement moved under it.
197
+ *
198
+ * {@link autoBudget} recomputes per call, but `budgetBytes` — the number
199
+ * admission actually gates on — is assigned once by {@link applyBudget}.
200
+ * Without this, a card measured after construction would show up in
201
+ * `pools` and in `fastBudgetBytes()` while the enforced ceiling stayed on
202
+ * the RAM-only curve, which is the half of the figure that denies models.
203
+ *
204
+ * Called from every public read; an explicit budget is the operator's
205
+ * number and is never re-derived.
206
+ */
207
+ refreshAutoBudget() {
208
+ if (this.explicitBudgetBytes !== null)
209
+ return;
210
+ const auto = this.autoBudget().budgetBytes;
211
+ if (auto === this.budgetBytes)
212
+ return;
213
+ log.info(`auto budget re-derived ${this.budgetBytes} → ${auto} (host memory measured after start)`);
214
+ this.budgetBytes = auto;
215
+ }
216
+ applyBudget() {
217
+ const explicit = this.explicitBudgetBytes;
218
+ if (explicit === null) {
219
+ this.budgetBytes = this.autoBudget().budgetBytes;
220
+ this.enforced = true;
221
+ }
222
+ else if (explicit < 1024 ** 3) {
223
+ this.budgetBytes = explicit;
224
+ this.enforced = false;
225
+ }
226
+ else {
227
+ this.budgetBytes = explicit;
228
+ this.enforced = true;
229
+ }
230
+ }
231
+ /**
232
+ * Re-point the budget without rebuilding the broker. `null` reverts to
233
+ * {@link autoDetectBudgetBytes}. Existing reservations are untouched: a
234
+ * shrink below current commitments doesn't evict anything, it just makes
235
+ * the next `reserve` fail until the pool's LRU path frees room. That is
236
+ * the same shape as the cache controller's live budget, and it keeps the
237
+ * Settings slider from severing a mid-turn engine.
238
+ *
239
+ * Without this the budget was read once when the engine router was built
240
+ * and cached until shutdown, so changing the setting did nothing until
241
+ * the daemon restarted.
242
+ */
243
+ setBudgetBytes(bytes) {
244
+ this.explicitBudgetBytes = bytes;
245
+ this.applyBudget();
246
+ log.info(`budget set to ${this.budgetBytes} (${bytes === null ? 'auto' : 'explicit'}), ` +
247
+ `committed ${this.committedBytes()}`);
248
+ }
249
+ /**
250
+ * Live-update whether co-resident models may spill into system RAM.
251
+ * `null` reverts to {@link autoAllowRamSpillover}. Like
252
+ * {@link setBudgetBytes}, tightening never evicts anything itself — it
253
+ * makes the next reserve fail, and the pool's LRU path does the freeing.
254
+ */
255
+ setAllowRamSpillover(allow) {
256
+ this.explicitAllowRamSpillover = allow;
257
+ log.info(`ram spillover ${this.ramSpilloverAllowed() ? 'allowed' : 'denied'} ` +
258
+ `(${allow === null ? 'auto' : 'explicit'}), co-residency ceiling ${this.coResidencyBytes()}`);
259
+ }
260
+ /** Whether co-resident models may spill into system RAM right now. */
261
+ ramSpilloverAllowed() {
262
+ return this.explicitAllowRamSpillover ?? autoAllowRamSpillover(this.autoBudget());
263
+ }
264
+ /**
265
+ * The ceiling the resident set must fit under **while more than one model
266
+ * is loaded**. Equal to the budget when spilling is allowed; the card's
267
+ * usable VRAM when it isn't.
268
+ *
269
+ * The single-model carve-out is the whole point of expressing this as a
270
+ * co-residency rule rather than a smaller budget: one model may still use
271
+ * the full budget, so a MoE larger than the card keeps running by streaming
272
+ * its experts from system RAM. What the rule forbids is a *second* model
273
+ * pushing the resident set off the card, where every model in it gets slow
274
+ * at once. Capping the budget instead would have made that big MoE
275
+ * unloadable and quietly shrunk the catalog to what fits in VRAM.
276
+ */
277
+ coResidencyBytes() {
278
+ this.refreshAutoBudget();
279
+ if (this.ramSpilloverAllowed())
280
+ return this.budgetBytes;
281
+ return Math.min(this.budgetBytes, this.fastBudgetBytes());
282
+ }
283
+ /** True iff a fresh reservation of `bytes` would fit. */
284
+ canReserve(bytes) {
285
+ return this.shortfallFor(bytes) <= 0;
286
+ }
287
+ /**
288
+ * Bytes of existing reservation that must be released before `bytes` fits
289
+ * — 0 when it already does. Both constraints in one number so the pool can
290
+ * size an eviction batch without knowing which rule bound it.
291
+ *
292
+ * `priorBytes` is an existing reservation for the same key being resized;
293
+ * it is not an obstacle to itself.
294
+ */
295
+ shortfallFor(bytes, priorBytes = 0) {
296
+ this.refreshAutoBudget();
297
+ if (!this.enforced)
298
+ return 0;
299
+ const others = Math.max(0, this.committedBytes() - priorBytes);
300
+ const budgetShort = others + bytes - this.budgetBytes;
301
+ // Co-residency binds only while something else is loaded. Releasing X
302
+ // satisfies it once `others - X + bytes <= ceiling` OR `others - X === 0`
303
+ // — hence the min: a model bigger than the ceiling needs the pool empty,
304
+ // never more than everything.
305
+ const ceiling = this.coResidencyBytes();
306
+ const coShort = others > 0 ? Math.min(others, others + bytes - ceiling) : Number.NEGATIVE_INFINITY;
307
+ return Math.max(0, budgetShort, coShort);
308
+ }
309
+ /**
310
+ * Attempt to reserve `bytes` for `key`. Returns the result; on
311
+ * `granted: false` the caller is expected to evict and retry.
312
+ *
313
+ * Idempotent on `key`: a second reserve for the same key replaces
314
+ * the prior bytes value (useful when an engine's working set grows
315
+ * after first turn). The replacement is treated as "free old, add
316
+ * new" so an enlargement that no longer fits returns false and
317
+ * leaves the prior reservation intact.
318
+ */
319
+ reserve(key, bytes) {
320
+ const prior = this.reservations.get(key) ?? 0;
321
+ if (!this.enforced) {
322
+ this.reservations.set(key, bytes);
323
+ return { granted: true };
324
+ }
325
+ if (this.shortfallFor(bytes, prior) > 0) {
326
+ return {
327
+ granted: false,
328
+ reason: this.denialReason(bytes, prior),
329
+ };
330
+ }
331
+ this.reservations.set(key, bytes);
332
+ if (prior > 0 && prior !== bytes) {
333
+ log.debug(`reserve ${key} resized ${prior} → ${bytes}`);
334
+ }
335
+ else if (prior === 0) {
336
+ log.debug(`reserve ${key} = ${bytes} (committed ${this.committedBytes()}/${this.budgetBytes})`);
337
+ }
338
+ return { granted: true };
339
+ }
340
+ /**
341
+ * The raw machine-shaped reason for a denial of `bytes` (optionally
342
+ * replacing an existing `priorBytes` reservation). Single source of
343
+ * the `budget exhausted: would commit N against M` string — it feeds
344
+ * both `reserve()` results and the pool's `capacity broker denied`
345
+ * log line, whose shape is a contract with the eval harness (see
346
+ * provider-pool.ts). Do not reword. A co-residency denial keeps that
347
+ * exact prefix and only appends its own clause, so the harness's
348
+ * `capacity broker denied … budget exhausted` match still classifies it.
349
+ */
350
+ denialReason(bytes, priorBytes = 0) {
351
+ const wouldCommit = this.committedBytes() - priorBytes + bytes;
352
+ const ceiling = this.coResidencyBytes();
353
+ if (this.enforced && ceiling < this.budgetBytes && wouldCommit > ceiling) {
354
+ const clause = '(co-residency ceiling — RAM spillover off)';
355
+ return `budget exhausted: would commit ${wouldCommit} against ${ceiling} ${clause}`;
356
+ }
357
+ return `budget exhausted: would commit ${wouldCommit} against ${this.budgetBytes}`;
358
+ }
359
+ release(key) {
360
+ const prior = this.reservations.get(key);
361
+ if (prior === undefined)
362
+ return;
363
+ this.reservations.delete(key);
364
+ log.debug(`release ${key} (-${prior}, committed ${this.committedBytes()}/${this.budgetBytes})`);
365
+ }
366
+ /** Sum of all current reservations. */
367
+ committedBytes() {
368
+ let sum = 0;
369
+ for (const v of this.reservations.values())
370
+ sum += v;
371
+ return sum;
372
+ }
373
+ /** Fast (on-accelerator) memory for this host — see {@link CapacityBudget.fastBytes}. */
374
+ fastBudgetBytes() {
375
+ this.refreshAutoBudget();
376
+ const auto = this.autoBudget();
377
+ // An explicit budget can only lower what we'll put on the accelerator,
378
+ // never raise the card's capacity.
379
+ return this.enforced ? Math.min(auto.fastBytes, this.budgetBytes) : auto.fastBytes;
380
+ }
381
+ /** Snapshot used by the UX status endpoint and tests. */
382
+ committed() {
383
+ this.refreshAutoBudget();
384
+ const auto = this.autoBudget();
385
+ return {
386
+ budgetBytes: this.budgetBytes,
387
+ committedBytes: this.committedBytes(),
388
+ enforced: this.enforced,
389
+ systemRamBytes: this.systemRamBytes,
390
+ autoBudgetBytes: auto.budgetBytes,
391
+ overridden: this.explicitBudgetBytes !== null,
392
+ pools: {
393
+ kind: auto.kind,
394
+ vramBytes: auto.vramBytes,
395
+ ramShareBytes: auto.ramShareBytes,
396
+ fastBytes: auto.fastBytes,
397
+ concurrencySizingBytes: auto.concurrencySizingBytes,
398
+ },
399
+ ramSpillover: {
400
+ allowed: this.ramSpilloverAllowed(),
401
+ auto: autoAllowRamSpillover(auto),
402
+ overridden: this.explicitAllowRamSpillover !== null,
403
+ coResidencyBytes: this.coResidencyBytes(),
404
+ },
405
+ byKey: [...this.reservations.entries()]
406
+ .map(([key, bytes]) => ({ key, bytes }))
407
+ .sort((a, b) => b.bytes - a.bytes),
408
+ };
409
+ }
410
+ /**
411
+ * Fallback estimate when a catalog entry lacks `residentBytes`.
412
+ * Used by callers building reservation requests from
413
+ * `approxSizeBytes`. Reflects the working-set footprint vs. on-disk
414
+ * size WITHOUT any KV — every caller prices KV explicitly on top.
415
+ *
416
+ * llama.cpp: see {@link estimateLlamaCppResidentBytes}. Pass `mmprojBytes`
417
+ * for a multimodal model — `approxSizeBytes` counts the weights alone, and
418
+ * the projector plus its vision buffers is 1.7 GB on a 30B.
419
+ * MLX: see {@link estimateMlxResidentBytes}. MLX needs no equivalent — its
420
+ * vision tower is inside the same safetensors set `approxSizeBytes` sums.
421
+ *
422
+ * ds4 is special: it streams MoE experts from SSD, so its resident
423
+ * working set is bounded by the configured expert-cache budget + KV +
424
+ * non-routed weights — NOT the full on-disk weight size. The catalog
425
+ * `residentBytes` is authoritative for ds4; this fallback only caps at a
426
+ * conservative streaming working set so a 64GB box is never told an
427
+ * 87GB DeepSeek-V4 model "can't fit" (which is the whole point of ds4).
428
+ */
429
+ static estimateResidentBytes(engine, approxSizeBytes, opts) {
430
+ if (engine === 'ds4') {
431
+ const DS4_STREAMING_RESIDENT_FALLBACK = 48 * 1024 ** 3;
432
+ return Math.min(approxSizeBytes, DS4_STREAMING_RESIDENT_FALLBACK);
433
+ }
434
+ if (engine === 'mlx')
435
+ return estimateMlxResidentBytes(approxSizeBytes);
436
+ return estimateLlamaCppResidentBytes(approxSizeBytes, {
437
+ mmprojBytes: opts?.mmprojBytes ?? 0,
438
+ });
439
+ }
440
+ }
441
+ const GIB = 1024 ** 3;
442
+ /**
443
+ * RECLAIMABLE-aware free RAM. `os.freemem()` reports truly-free pages
444
+ * only: on macOS, file-backed cache and purgeable memory count as "used"
445
+ * even though the kernel hands them back on demand — and a just-exited
446
+ * llama engine's mmap'd weights ARE file-backed cache, so freemem()
447
+ * reads a few GB on a 64 GB box right after any model ran. Wild-caught
448
+ * 2026-08-04: the context memory-clamp saw "~6.6 GB available", floored
449
+ * gemma4-31b to 8,192 ctx, and all 11 trials died on context overflow —
450
+ * on a machine with >40 GB actually reclaimable. Linux freemem() has the
451
+ * same free-vs-MemAvailable trap.
452
+ *
453
+ * darwin: vm_stat free+inactive+speculative+purgeable+file-backed.
454
+ * linux: /proc/meminfo MemAvailable. Fallback: freemem().
455
+ */
456
+ export function availableSystemRamBytes() {
457
+ // vm_stat categories overlap (file-backed pages span active+inactive),
458
+ // so the raw sum can exceed physical RAM; cap at 90% of totalmem — the
459
+ // consumers already hold back their own OS reserves on top.
460
+ const cap = totalmem() * 0.9;
461
+ try {
462
+ if (process.platform === 'darwin') {
463
+ const out = execFileSync('/usr/bin/vm_stat', { encoding: 'utf8', timeout: 3_000 });
464
+ const parsed = parseVmStatAvailableBytes(out);
465
+ if (parsed !== null)
466
+ return Math.max(Math.min(parsed, cap), freemem());
467
+ }
468
+ else if (process.platform === 'linux') {
469
+ const parsed = parseMeminfoAvailableBytes(readFileSync('/proc/meminfo', 'utf8'));
470
+ if (parsed !== null)
471
+ return Math.max(Math.min(parsed, cap), freemem());
472
+ }
473
+ }
474
+ catch {
475
+ // Probe failure falls through to the conservative number.
476
+ }
477
+ return freemem();
478
+ }
479
+ /** Pure vm_stat parser (exported for tests). Returns null when the output
480
+ * doesn't look like vm_stat. */
481
+ export function parseVmStatAvailableBytes(text) {
482
+ const page = Number(/page size of (\d+) bytes/.exec(text)?.[1]);
483
+ if (!Number.isFinite(page) || page <= 0)
484
+ return null;
485
+ const count = (label) => {
486
+ const m = new RegExp(`${label}:\\s+(\\d+)`).exec(text);
487
+ return m ? Number(m[1]) : 0;
488
+ };
489
+ const pages = count('Pages free') +
490
+ count('Pages inactive') +
491
+ count('Pages speculative') +
492
+ count('Pages purgeable') +
493
+ count('File-backed pages');
494
+ if (pages <= 0)
495
+ return null;
496
+ return pages * page;
497
+ }
498
+ /** Pure /proc/meminfo parser (exported for tests). */
499
+ export function parseMeminfoAvailableBytes(text) {
500
+ const m = /MemAvailable:\s+(\d+)\s*kB/.exec(text);
501
+ return m ? Number(m[1]) * 1024 : null;
502
+ }
503
+ /**
504
+ * Demand-shaped default concurrent-slot count for a supervised local engine.
505
+ * The input is usable FAST memory: VRAM on a discrete GPU, the shared pool on
506
+ * UMA, and the engine RAM budget on CPU. System RAM beside a dGPU must never
507
+ * raise `--parallel` / `--max-concurrency`; it is only a single-large-model
508
+ * offload pool. Thresholds are expressed against the safety-discounted pool,
509
+ * so an 8 GiB card resolves to 1 and a 16 GiB card to 2.
510
+ *
511
+ * The exact model/KV ceiling clamps this further. An explicit
512
+ * `providerConcurrency[engine]` setting remains an operator override.
513
+ */
514
+ export function defaultLocalEngineSlots(fastMemoryBytes = fastMemoryBudgetBytes()) {
515
+ const gb = fastMemoryBytes / GIB;
516
+ if (gb < 12)
517
+ return 1;
518
+ if (gb < 24)
519
+ return 2;
520
+ if (gb < 48)
521
+ return 3;
522
+ return 4;
523
+ }
524
+ /**
525
+ * Slots a launch would be admitted at before the context-admission ladder
526
+ * gets its say: an explicit operator setting, else the fast-memory tier default
527
+ * capped by what memory can actually hold.
528
+ *
529
+ * Exists so every caller resolves slots the same way. The launch-preview
530
+ * short-circuit once used the bare tier default while the main path clamped
531
+ * by the ceiling, so a resident model on a 32-48 GB host advertised a
532
+ * 3-slot reservation (~49 GB for a 17 GB model) the broker would never have
533
+ * admitted.
534
+ */
535
+ export function plannedLocalEngineSlots(opts) {
536
+ if (opts.configuredSlots !== undefined)
537
+ return opts.configuredSlots;
538
+ return Math.max(1, Math.min(opts.tierDefault ?? defaultLocalEngineSlots(), opts.ceiling));
539
+ }
540
+ /**
541
+ * Conservative estimate of the KV-cache bytes ONE slot needs at a given
542
+ * per-turn context window. We have no model attention-architecture metadata
543
+ * (layers / KV-heads / head-dim) anywhere in the app, so we scale off the
544
+ * on-disk weights size — calibrated to a measured anchor (a 26B Q4_K_M
545
+ * Gemma uses ~2 GB of q8_0 KV at 65K ctx ≈ 30 KB/token) and biased ~1.3×
546
+ * high so we under-provision slots rather than risk OOM. Clamped to a sane
547
+ * per-token band so tiny models don't round to ~0 and giant MoE weights
548
+ * don't push the estimate far past reality.
549
+ */
550
+ /** Approximate scale from an f16 KV baseline to the launcher's cache dtype. */
551
+ export function kvQuantScale(kvCacheType) {
552
+ const kvType = kvCacheType ?? 'q8_0';
553
+ return kvType.startsWith('q4') ? 0.3 : kvType.startsWith('q8') ? 0.55 : kvType === 'f32' ? 2 : 1;
554
+ }
555
+ export function estimatePerSlotKvBytes(opts) {
556
+ const KB = 1024;
557
+ // f16 KV bytes/token per byte of (quantized) on-disk weights. ~1.3× the
558
+ // measured Gemma-26B anchor (~3.7e-6) → conservative. NOTE the anchor is
559
+ // a WINDOWED-cache measurement, and small dense models routinely exceed
560
+ // the 40 KB/token floor by 3× — this heuristic exists only for weights
561
+ // without a readable header (external paths, MLX safetensors). Callers
562
+ // with GGUF metadata pass `exactPerSlotKvBytesF16` to the slot ceilings
563
+ // instead (see estimateExactPerSlotKvBytesF16 in offload-planner).
564
+ const KV_RATIO_F16 = 5e-6;
565
+ const perTokenF16 = Math.min(400 * KB, Math.max(40 * KB, opts.weightsBytes * KV_RATIO_F16));
566
+ return Math.round(opts.perTurnCtxTokens * perTokenF16 * kvQuantScale(opts.kvCacheType));
567
+ }
568
+ /**
569
+ * Fraction of the post-weights budget held back from KV-slot accounting to
570
+ * cover what {@link estimatePerSlotKvBytes} doesn't: per-wave prefill/compute
571
+ * activation buffers (prefill_step_size × batch × model dims), the framework's
572
+ * own scratch, and estimator error. Without this reserve a model that "just
573
+ * fits" N KV slots aborts the moment N concurrent prefills allocate their
574
+ * compute buffers on top of resident KV — the qwen3.6-27b-q8 Metal OOM. It is
575
+ * deliberately blunt: the per-slot KV estimate is itself coarse, so precision
576
+ * here buys nothing; a margin that survives a bad guess does.
577
+ *
578
+ * MLX reserves more, and holds it in the open. Its share of this margin used
579
+ * to hide inside a 1.3x weights multiplier that no measurement supported (see
580
+ * {@link CapacityBroker.estimateResidentBytes}); correcting that figure to the
581
+ * measured 1.0 would otherwise have bought every MLX model an extra slot,
582
+ * which is the one purchase this whole reserve exists to prevent. What the
583
+ * larger number actually covers is real and MLX-specific: prefill activation
584
+ * buffers plus the framework's retained free-buffer pool, which is unbounded,
585
+ * invisible to `get_active_memory`, and tracked by nothing else.
586
+ */
587
+ const LOCAL_ENGINE_COMPUTE_HEADROOM = LLAMA_CPP_COMPUTE_HEADROOM;
588
+ export function computeHeadroomFor(engine) {
589
+ return engine === 'mlx' ? MLX_COMPUTE_HEADROOM : LOCAL_ENGINE_COMPUTE_HEADROOM;
590
+ }
591
+ /**
592
+ * Bytes left for KV + compute after resident weights and any co-resident
593
+ * models. Negative when the model barely fits (or doesn't) — callers clamp.
594
+ * Shared so the slot COUNT ({@link localEngineSlotCeiling}) and the engine's
595
+ * own prompt-cache budget can be sized against the SAME number instead of
596
+ * drifting apart (a fat prompt cache holding idle-session KV was a
597
+ * co-conspirator in the 27B Metal OOM, not just the concurrent slots).
598
+ */
599
+ export function localEngineKvBudgetBytes(opts) {
600
+ const weightsResident = opts.weightsResidentBytes ??
601
+ CapacityBroker.estimateResidentBytes(opts.engine, opts.weightsBytes);
602
+ return opts.budgetBytes - (opts.committedOtherBytes ?? 0) - weightsResident;
603
+ }
604
+ /**
605
+ * Max concurrent slots that fit the model budget: resident weights +
606
+ * N × per-slot KV + a compute-headroom reserve ≤ budget. Always ≥ 1 — if even
607
+ * one slot's KV doesn't fit, that's the broker's job to deny the whole spawn;
608
+ * our job is only the slot COUNT given the model loads. `committedOtherBytes`
609
+ * subtracts co-resident model reservations (default 0 = primary/only model).
610
+ *
611
+ * `engine` drives the resident-weights multiplier (MLX's f16 KV + working set
612
+ * runs heavier than llama.cpp's — see {@link CapacityBroker.estimateResidentBytes}).
613
+ * Pass the ACTUAL `kvCacheType` the engine will run: MLX defaults to f16 (no
614
+ * `--kv-bits`), so omitting it or passing a q8 type here silently under-counts
615
+ * KV by ~1.8× and over-slots — exactly the trap the MLX path fell into.
616
+ */
617
+ export function localEngineSlotCeiling(opts) {
618
+ const perSlotKv = opts.exactPerSlotKvBytesF16 !== undefined && opts.exactPerSlotKvBytesF16 > 0
619
+ ? Math.round(opts.exactPerSlotKvBytesF16 * kvQuantScale(opts.kvCacheType))
620
+ : estimatePerSlotKvBytes({
621
+ perTurnCtxTokens: opts.perTurnCtxTokens,
622
+ weightsBytes: opts.weightsBytes,
623
+ ...(opts.kvCacheType !== undefined ? { kvCacheType: opts.kvCacheType } : {}),
624
+ });
625
+ if (perSlotKv <= 0)
626
+ return 1;
627
+ const freeForKv = localEngineKvBudgetBytes({
628
+ ...opts,
629
+ budgetBytes: Math.min(opts.budgetBytes, opts.sizingBudgetBytes ?? opts.budgetBytes),
630
+ });
631
+ const usableForKv = freeForKv * (1 - computeHeadroomFor(opts.engine));
632
+ return Math.max(1, Math.floor(usableForKv / perSlotKv));
633
+ }
634
+ /**
635
+ * llama.cpp slot ceiling — thin wrapper over {@link localEngineSlotCeiling}.
636
+ * Retained for existing callers/tests; new engine paths call the generic form
637
+ * with their own `engine` + `kvCacheType`.
638
+ */
639
+ export function llamaCppSlotCeiling(opts) {
640
+ return localEngineSlotCeiling({ engine: 'llama-cpp', ...opts });
641
+ }
642
+ /**
643
+ * Physical memory held back from every live-availability decision: the OS,
644
+ * the desktop shell, and whatever the user is actually doing.
645
+ *
646
+ * ONE function because there used to be two, and they disagreed by gigabytes.
647
+ * The context clamp held back a flat 2 GiB from
648
+ * {@link availableSystemRamBytes}; the device admission ledger held back
649
+ * `min(4 GiB, 10% of RAM)` from a stricter darwin-only sample that counted
650
+ * neither inactive nor speculative pages. On a 16 GiB Mac the planner read
651
+ * 9.3 GiB available and the admitter 4.3 GiB from the same `vm_stat` seconds
652
+ * apart, so a launch the planner sized at 9.7 GiB sat in the admission queue
653
+ * for its full five-minute budget and then failed — on a host that was never
654
+ * going to free 5 GiB, because nothing was holding it but the estimate.
655
+ * Planning and admission must read one number.
656
+ */
657
+ export function liveRamOsReserveBytes(totalRamBytes = totalmem()) {
658
+ return Math.min(4 * GIB, Math.max(2 * GIB, totalRamBytes * 0.1));
659
+ }
660
+ /**
661
+ * Extra headroom the PLANNER holds back on top of
662
+ * {@link liveRamOsReserveBytes}, so a launch is never sized to the exact
663
+ * admission boundary. The two sample the host a moment apart; a plan that
664
+ * only just fit would spend the whole admission wait losing a race to
665
+ * whatever allocated in between.
666
+ */
667
+ const CTX_PLANNING_MARGIN_BYTES = 512 * 1024 ** 2;
668
+ /**
669
+ * The most a launch could hold right now, as {@link clampCtxTokensForMemory}
670
+ * reckons it with nothing else resident: the fast pool plus the system RAM
671
+ * free now, less the OS reserve and the planning margin, capped by the
672
+ * budget. First run picks against this so it never chooses a model the
673
+ * first chat turn refuses, and the failed-turn card names a model that will
674
+ * start.
675
+ *
676
+ * It holds back {@link FIT_NOW_DRIFT_BYTES} more: free RAM moves by hundreds
677
+ * of megabytes between this check and the launch, and a model priced inside
678
+ * that drift was suggested and then refused (2026-10-12).
679
+ */
680
+ export function liveLaunchCapBytes(input) {
681
+ const freeRam = Math.max(0, availableSystemRamBytes() -
682
+ liveRamOsReserveBytes() -
683
+ CTX_PLANNING_MARGIN_BYTES -
684
+ FIT_NOW_DRIFT_BYTES);
685
+ return Math.min(input.budgetBytes, Math.max(0, input.vramBytes) + freeRam);
686
+ }
687
+ const FIT_NOW_DRIFT_BYTES = GIB;
688
+ /**
689
+ * Minimum useful per-turn context for Gezel's standing prompt + tool surface
690
+ * on a host with memory to spare. Read {@link minViableLocalContextTokens}
691
+ * rather than this constant when the answer has to fit the running machine.
692
+ */
693
+ export const MIN_VIABLE_LOCAL_CONTEXT_TOKENS = LOCAL_CONTEXT_FLOOR_TOKENS;
694
+ /** The same minimum on a host that has to trade context for memory. */
695
+ export const MIN_VIABLE_CONSTRAINED_CONTEXT_TOKENS = CONSTRAINED_LOCAL_CONTEXT_FLOOR_TOKENS;
696
+ function envMinContextTokens() {
697
+ const raw = process.env.GEZEL_MIN_CONTEXT_TOKENS;
698
+ if (!raw)
699
+ return null;
700
+ const tokens = Number.parseInt(raw, 10);
701
+ return Number.isFinite(tokens) && tokens > 0 ? tokens : null;
702
+ }
703
+ /**
704
+ * Operator/eval brake on adaptive context growth. Growth is uncapped by
705
+ * default — it already cannot exceed the model's native window or fast
706
+ * memory — but a fleet operator or an eval harness may want a deterministic
707
+ * ceiling independent of the machine it runs on.
708
+ */
709
+ function envGrowthCeilingTokens() {
710
+ const raw = process.env.GEZEL_LLAMA_GROWTH_CEILING_TOKENS;
711
+ if (!raw)
712
+ return null;
713
+ const tokens = Number.parseInt(raw, 10);
714
+ return Number.isFinite(tokens) && tokens > 0 ? tokens : null;
715
+ }
716
+ /**
717
+ * The context floor THIS host is held to. A 16 GB Mac or an 8 GB card cannot
718
+ * back a 64K window next to the weights, and the admission ladder's only
719
+ * remaining move there is to deny the launch — so those hosts run at
720
+ * {@link MIN_VIABLE_CONSTRAINED_CONTEXT_TOKENS} instead, and sessions compact
721
+ * sooner rather than the model being unusable.
722
+ *
723
+ * Reads the same host shape the budget does, so the two cannot disagree:
724
+ * a discrete card is judged on its usable VRAM, every other host on system
725
+ * RAM. `GEZEL_MIN_CONTEXT_TOKENS` overrides both, for operators and for tests
726
+ * that need a host-independent floor.
727
+ */
728
+ export function minViableLocalContextTokens(opts) {
729
+ const override = envMinContextTokens();
730
+ if (override !== null)
731
+ return override;
732
+ const systemRamBytes = opts?.systemRamBytes ?? totalmem();
733
+ const budget = opts?.budget ?? computeCapacityBudget({ systemRamBytes });
734
+ return localContextFloorTokens({
735
+ totalRamBytes: systemRamBytes,
736
+ gpuVramBytes: budget.kind === 'discrete-gpu' ? budget.vramBytes : null,
737
+ });
738
+ }
739
+ /**
740
+ * Resolve the model-aware context contract. Long-context models must retain
741
+ * at least the host's floor ({@link minViableLocalContextTokens} — 64K, or 32K
742
+ * on a memory-constrained machine); a model whose native window is genuinely
743
+ * smaller keeps that native limit instead of being asked to do something it
744
+ * cannot support.
745
+ *
746
+ * `minViableContextTokens` exists so callers that already know the host (and
747
+ * every test) pin the floor instead of re-probing the machine underneath them.
748
+ */
749
+ export function resolveLocalContextRequirement(opts) {
750
+ const floor = opts.minViableContextTokens && opts.minViableContextTokens > 0
751
+ ? Math.floor(opts.minViableContextTokens)
752
+ : minViableLocalContextTokens();
753
+ const preferred = opts.requestedContextWindow && opts.requestedContextWindow > 0
754
+ ? Math.floor(opts.requestedContextWindow)
755
+ : floor;
756
+ const native = opts.modelContextWindow && opts.modelContextWindow > 0
757
+ ? Math.floor(opts.modelContextWindow)
758
+ : floor;
759
+ const minimum = Math.min(native, floor);
760
+ return {
761
+ nativeContextWindow: native,
762
+ minimumPerTurnCtxTokens: minimum,
763
+ requestedPerTurnCtxTokens: Math.min(native, Math.max(preferred, minimum)),
764
+ };
765
+ }
766
+ /**
767
+ * Apply llama.cpp's user-selectable sizing policy on top of the shared local
768
+ * context floor. Explicit numeric overrides keep their historical semantics
769
+ * and win over the selector. In strict model-max mode the requested native
770
+ * window is also the admission minimum, so the planner may reduce slots but
771
+ * cannot silently shorten the context window to make the model fit.
772
+ */
773
+ export function resolveLlamaCppContextRequirement(opts) {
774
+ const strictModelMax = opts.contextSizing === 'model-max' && opts.explicitContextWindow === undefined;
775
+ const requestedContextWindow = opts.explicitContextWindow ??
776
+ (strictModelMax ? opts.modelContextWindow : opts.adaptiveContextWindow);
777
+ const resolved = resolveLocalContextRequirement({
778
+ ...(opts.modelContextWindow !== undefined
779
+ ? { modelContextWindow: opts.modelContextWindow }
780
+ : {}),
781
+ ...(requestedContextWindow !== undefined ? { requestedContextWindow } : {}),
782
+ ...(opts.minViableContextTokens !== undefined
783
+ ? { minViableContextTokens: opts.minViableContextTokens }
784
+ : {}),
785
+ });
786
+ if (strictModelMax) {
787
+ return {
788
+ ...resolved,
789
+ minimumPerTurnCtxTokens: resolved.requestedPerTurnCtxTokens,
790
+ strict: true,
791
+ };
792
+ }
793
+ const base = { ...resolved, strict: false };
794
+ // Growth eligibility: adaptive policy (not strict — handled above), no
795
+ // explicit numeric override (env, machine-wide, or per-model — the caller
796
+ // folds all three into explicitContextWindow), and a genuinely known
797
+ // native window to grow toward.
798
+ if (opts.explicitContextWindow === undefined &&
799
+ opts.modelContextWindow !== undefined &&
800
+ opts.modelContextWindow > 0) {
801
+ const ceiling = opts.growthCeilingTokens ?? envGrowthCeilingTokens() ?? Number.POSITIVE_INFINITY;
802
+ const cap = Math.min(Math.floor(opts.modelContextWindow), ceiling, opts.manifestContextSize && opts.manifestContextSize > 0
803
+ ? Math.floor(opts.manifestContextSize)
804
+ : Number.POSITIVE_INFINITY);
805
+ const target = Number.isFinite(cap) ? Math.floor(cap / 1024) * 1024 : 0;
806
+ if (target > resolved.requestedPerTurnCtxTokens) {
807
+ return { ...base, growthTargetTokens: target };
808
+ }
809
+ }
810
+ return base;
811
+ }
812
+ /** Numerical floor for the low-level clamp calculation. Production admission
813
+ * applies the model-aware policy above and refuses a launch when that
814
+ * requirement cannot fit. */
815
+ const CTX_CLAMP_FLOOR_TOKENS = 8_192;
816
+ /**
817
+ * Clamp the per-turn context window so the engine's projected footprint —
818
+ * resident weights plus total KV plus the compute-headroom reserve — fits
819
+ * BOTH the capacity budget and what the machine can actually give right
820
+ * now (live free RAM + discrete VRAM).
821
+ *
822
+ * This is the missing admission check behind the 2026-08-03 incident: the
823
+ * slot ceiling sizes the slot COUNT and the broker admits WEIGHTS, but
824
+ * nothing asked whether one slot at the requested context fit at all.
825
+ * A 64K-token default on an f16-KV model sailed through both and put a
826
+ * ~19 GB KV cache into system RAM. Clamping context degrades gracefully
827
+ * (sessions compact sooner); paging does not degrade at all — it takes
828
+ * the whole desktop with it.
829
+ *
830
+ * Never returns below the caller's floor. Production launch admission wraps
831
+ * this primitive with {@link planCtxTokensForMemory}, which tests the actual
832
+ * safe value and refuses a launch that cannot retain the model-aware floor.
833
+ * Returns multiples of 1024 for tidy engine arguments.
834
+ */
835
+ export function clampCtxTokensForMemory(input) {
836
+ const requested = input.requestedPerTurnCtxTokens;
837
+ const floor = Math.max(1, input.minPerTurnCtxTokens ?? CTX_CLAMP_FLOOR_TOKENS);
838
+ const slots = Math.max(1, input.slots);
839
+ if (!(input.kvBytesPerToken > 0) || requested <= floor) {
840
+ return { perTurnCtxTokens: requested, clamped: false, reason: null };
841
+ }
842
+ const committedOther = Math.max(0, input.committedOtherBytes ?? 0);
843
+ const budgetCap = input.budgetBytes - committedOther;
844
+ const osReserve = input.osReserveBytes ?? liveRamOsReserveBytes() + CTX_PLANNING_MARGIN_BYTES;
845
+ const liveCap = input.freeSystemRamBytes === undefined
846
+ ? null
847
+ : Math.max(0, input.vramBytes) + Math.max(0, input.freeSystemRamBytes - osReserve);
848
+ const cap = liveCap === null ? budgetCap : Math.min(budgetCap, liveCap);
849
+ const kvAllowance = (cap - input.weightsResidentBytes) * (1 - LOCAL_ENGINE_COMPUTE_HEADROOM);
850
+ const maxTotalTokens = kvAllowance > 0 ? kvAllowance / input.kvBytesPerToken : 0;
851
+ const maxPerTurn = Math.floor(maxTotalTokens / slots / 1024) * 1024;
852
+ const clampedTo = Math.max(floor, Math.min(requested, maxPerTurn));
853
+ if (clampedTo >= requested) {
854
+ return { perTurnCtxTokens: requested, clamped: false, reason: null };
855
+ }
856
+ const gb = (bytes) => `${(bytes / GIB).toFixed(1)} GB`;
857
+ const kvAtRequested = requested * slots * input.kvBytesPerToken;
858
+ const kvAtClamped = clampedTo * slots * input.kvBytesPerToken;
859
+ return {
860
+ perTurnCtxTokens: clampedTo,
861
+ clamped: true,
862
+ reason: `context clamped ${requested} → ${clampedTo} tokens/turn (${slots} slot${slots === 1 ? '' : 's'}): ` +
863
+ `weights ~${gb(input.weightsResidentBytes)} + KV at the requested context ~${gb(kvAtRequested)} ` +
864
+ `exceeds available memory ~${gb(Math.max(0, cap))} ` +
865
+ `(budget ${gb(budgetCap)}` +
866
+ `${liveCap === null ? '' : `, live free RAM ${gb(Math.max(0, input.freeSystemRamBytes ?? 0))}`}` +
867
+ `${liveCap !== null && input.vramBytes > 0 ? ` + VRAM ${gb(input.vramBytes)}` : ''}` +
868
+ `${committedOther > 0 ? `, ${gb(committedOther)} held by other models` : ''}); ` +
869
+ `KV now ~${gb(kvAtClamped)}. Sessions compact sooner instead of the machine paging.`,
870
+ };
871
+ }
872
+ /**
873
+ * Preserve useful context by reducing concurrency before context. If even a
874
+ * single slot cannot fit the required per-turn window, report a denial rather
875
+ * than silently launching a tool-using model with an unusably small window.
876
+ */
877
+ export function planCtxTokensForMemory(input) {
878
+ const requestedSlots = Math.max(1, Math.floor(input.slots));
879
+ const minimum = Math.max(1, Math.floor(input.minimumPerTurnCtxTokens));
880
+ let last;
881
+ for (let slots = requestedSlots; slots >= 1; slots -= 1) {
882
+ const safe = clampCtxTokensForMemory({
883
+ ...input,
884
+ slots,
885
+ // Reveal the actually safe context instead of pinning the low-level
886
+ // clamp to the policy floor; admission compares it below.
887
+ minPerTurnCtxTokens: 1,
888
+ });
889
+ last = safe;
890
+ if (safe.perTurnCtxTokens >= minimum) {
891
+ return {
892
+ ...safe,
893
+ slots,
894
+ minimumPerTurnCtxTokens: minimum,
895
+ minimumSatisfied: true,
896
+ };
897
+ }
898
+ }
899
+ const denied = last ?? clampCtxTokensForMemory({ ...input, slots: 1, minPerTurnCtxTokens: 1 });
900
+ return {
901
+ ...denied,
902
+ slots: 1,
903
+ minimumPerTurnCtxTokens: minimum,
904
+ minimumSatisfied: false,
905
+ };
906
+ }
907
+ /**
908
+ * The concurrency floor automatic growth may trade down to. Growth may
909
+ * consolidate a 3- or 4-lane launch to two lanes when that buys a longer
910
+ * window, but the second lane is never traded away — a single busy slot
911
+ * turns every other chat on the machine into a queue, and SWA models with
912
+ * one slot re-prefill wholesale on session alternation (the same wall the
913
+ * q8_0 KV trade in {@link planLlamaCppKv} exists to avoid).
914
+ */
915
+ export const ADAPTIVE_GROWTH_MIN_SLOTS = 2;
916
+ /**
917
+ * A lane is only traded when the window it buys is at least this much
918
+ * longer than the no-trade grown window. Pure KV-bound consolidation from
919
+ * 3 → 2 lanes yields 1.5× by construction, so real trades clear this
920
+ * easily; what it filters out is spending a lane to close the last few
921
+ * percent toward a target the untraded launch nearly reaches anyway.
922
+ */
923
+ export const ADAPTIVE_GROWTH_TRADE_MIN_GAIN = 1.25;
924
+ /**
925
+ * Grow an adaptive launch's per-turn context toward the model's native
926
+ * window using only the fast memory left over AFTER the admission ladder
927
+ * settled slots and granted the un-grown request.
928
+ *
929
+ * Deliberately a second clamp pass rather than a bigger first request:
930
+ * the first ladder pass sizes slot ceilings, the `--swa-full` fit verdict,
931
+ * and RAM-spillover admission, all of which must stay anchored on the
932
+ * practical 64K target — growing the request there would decline
933
+ * `--swa-full` for models whose full cache fits at 64K and grow KV into
934
+ * system-RAM spill on discrete cards.
935
+ *
936
+ * Slot trade: when `allowSlotTrade` is set and the target is out of reach
937
+ * at the settled slot count, growth walks the count down — taking the
938
+ * LARGEST count that reaches the target, else the longest window at
939
+ * {@link ADAPTIVE_GROWTH_MIN_SLOTS}. It never consolidates when the target
940
+ * is already reachable, never goes below two lanes, and never returns a
941
+ * smaller window than the un-traded grant.
942
+ *
943
+ * Confinement: on a discrete GPU the clamp sees only the fast budget and
944
+ * usable VRAM (`freeSystemRamBytes` zeroed) so grown KV never pages through
945
+ * system RAM, and — when the launch supplies `measuredFreeVramBytes` — only
946
+ * the VRAM other applications actually leave free, so a grown launch is one
947
+ * device admission will grant; on unified / system-ram hosts fast memory IS the budget, so
948
+ * the inputs match the base clamp. Inherits `VRAM_USABLE_FRACTION` and
949
+ * {@link LOCAL_ENGINE_COMPUTE_HEADROOM} through the shared clamp.
950
+ *
951
+ * MoE models never grow on a discrete card: `planMoeOffload` places routed
952
+ * experts around the KV reserve, and a grown reserve would silently evict
953
+ * experts from VRAM — trading decode speed for context behind the user's
954
+ * back. (Models whose resident weights exceed the fast pool get a zero
955
+ * allowance and don't grow regardless, which covers CPU-spilled MoE.)
956
+ */
957
+ export function planAdaptiveContextGrowth(input) {
958
+ const base = Math.max(1, Math.floor(input.basePerTurnCtxTokens));
959
+ const startSlots = Math.max(1, Math.floor(input.slots));
960
+ const noGrowth = {
961
+ perTurnCtxTokens: base,
962
+ slots: startSlots,
963
+ grown: false,
964
+ reason: null,
965
+ };
966
+ const target = Math.floor(input.targetPerTurnCtxTokens);
967
+ if (!(target > base) || !(input.kvBytesPerToken > 0))
968
+ return noGrowth;
969
+ const discrete = input.budgetKind === 'discrete-gpu';
970
+ if (input.isMoE && discrete)
971
+ return noGrowth;
972
+ const kvFixedPerSlot = Math.max(0, input.kvFixedPerSlotBytes ?? 0);
973
+ const measuredFreeVram = discrete && input.measuredFreeVramBytes !== undefined
974
+ ? Math.max(0, input.measuredFreeVramBytes)
975
+ : undefined;
976
+ const cardBytes = measuredFreeVram !== undefined ? Math.min(input.vramBytes, measuredFreeVram) : input.vramBytes;
977
+ const safeAt = (slots) => {
978
+ const safe = clampCtxTokensForMemory({
979
+ requestedPerTurnCtxTokens: target,
980
+ slots,
981
+ kvBytesPerToken: input.kvBytesPerToken,
982
+ weightsResidentBytes: input.weightsResidentBytes + kvFixedPerSlot * slots,
983
+ budgetBytes: input.fastBudgetBytes,
984
+ ...(input.committedOtherBytes !== undefined
985
+ ? { committedOtherBytes: input.committedOtherBytes }
986
+ : {}),
987
+ // A discrete card pins the clamp to VRAM (0 free RAM) so grown KV never
988
+ // pages through system memory; a shared pool passes through, including
989
+ // the policy-only `undefined` a preview supplies.
990
+ ...(discrete
991
+ ? { freeSystemRamBytes: 0 }
992
+ : input.freeSystemRamBytes !== undefined
993
+ ? { freeSystemRamBytes: input.freeSystemRamBytes }
994
+ : {}),
995
+ vramBytes: discrete ? cardBytes : 0,
996
+ minPerTurnCtxTokens: 1,
997
+ });
998
+ return Math.min(target, safe.perTurnCtxTokens);
999
+ };
1000
+ // Walk the slot count down only while the target stays out of reach:
1001
+ // the first (largest) count that reaches it wins, else the floor count
1002
+ // holds the longest achievable window.
1003
+ const floorSlots = input.allowSlotTrade
1004
+ ? Math.min(startSlots, ADAPTIVE_GROWTH_MIN_SLOTS)
1005
+ : startSlots;
1006
+ const noTradeCtx = safeAt(startSlots);
1007
+ let chosenSlots = startSlots;
1008
+ let chosenCtx = noTradeCtx;
1009
+ for (let slots = startSlots - 1; slots >= floorSlots && chosenCtx < target; slots -= 1) {
1010
+ const ctx = safeAt(slots);
1011
+ if (ctx > chosenCtx) {
1012
+ chosenSlots = slots;
1013
+ chosenCtx = ctx;
1014
+ }
1015
+ }
1016
+ // A lane costs real concurrency; don't spend one on a marginal gain.
1017
+ if (chosenSlots < startSlots && chosenCtx < noTradeCtx * ADAPTIVE_GROWTH_TRADE_MIN_GAIN) {
1018
+ chosenSlots = startSlots;
1019
+ chosenCtx = noTradeCtx;
1020
+ }
1021
+ const grownTo = Math.max(base, chosenCtx);
1022
+ if (grownTo <= base)
1023
+ return noGrowth;
1024
+ const gb = (bytes) => `${(bytes / GIB).toFixed(1)} GB`;
1025
+ const slotNote = chosenSlots < startSlots ? `, consolidating ${startSlots} → ${chosenSlots} engine lanes` : '';
1026
+ const fastLeft = Math.max(0, input.fastBudgetBytes - (input.committedOtherBytes ?? 0));
1027
+ const measuredNote = measuredFreeVram !== undefined && measuredFreeVram < Math.min(fastLeft, input.vramBytes)
1028
+ ? ` (capped at the ~${gb(measuredFreeVram)} of graphics memory other applications leave free)`
1029
+ : '';
1030
+ return {
1031
+ perTurnCtxTokens: grownTo,
1032
+ slots: chosenSlots,
1033
+ grown: true,
1034
+ reason: `growing context ${base} → ${grownTo} tokens/turn at ${chosenSlots} slot${chosenSlots === 1 ? '' : 's'}${slotNote} ` +
1035
+ `(target ${target}): weights ~${gb(input.weightsResidentBytes)} + grown KV ` +
1036
+ `~${gb(chosenSlots * (kvFixedPerSlot + grownTo * input.kvBytesPerToken))} fits fast memory ` +
1037
+ `~${gb(fastLeft)}${measuredNote}`,
1038
+ };
1039
+ }
1040
+ /**
1041
+ * What a person sees when a model cannot retain its viable context. The
1042
+ * arithmetic behind the refusal is ours, not theirs: launch paths log it via
1043
+ * {@link formatContextCapacityDenial}.
1044
+ */
1045
+ export const NOT_ENOUGH_MEMORY_MESSAGE = 'There is not enough memory to run this model. Please select another model or close some applications on this device.';
1046
+ /**
1047
+ * Log-side diagnostic for a context refusal. Never the thrown message — see
1048
+ * {@link NOT_ENOUGH_MEMORY_MESSAGE}. The eval harness reads the
1049
+ * `with its required <n>-token working window` shape from daemon.log
1050
+ * (evals/src/engine-context.ts), so keep that phrase intact.
1051
+ */
1052
+ export function formatContextCapacityDenial(opts) {
1053
+ const minimum = opts.plan.minimumPerTurnCtxTokens.toLocaleString('en-US');
1054
+ const safe = opts.plan.perTurnCtxTokens.toLocaleString('en-US');
1055
+ return `Not enough memory to run ${opts.modelLabel} with its required ${minimum}-token working window. Even at one engine slot, this machine could safely admit only about ${safe} tokens per turn. ${opts.plan.reason ?? ''}`
1056
+ .replace(/\s+/g, ' ')
1057
+ .trim();
1058
+ }