@engenty/wizards-runtime 0.20.5 → 0.21.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 (363) hide show
  1. package/README.md +3 -3
  2. package/apps/runtime/dist/agents/studio-assistant.js +7 -3
  3. package/apps/runtime/dist/agents/subscription.js +20 -25
  4. package/apps/runtime/dist/app.js +4 -1
  5. package/apps/runtime/dist/cli/clients.js +6 -24
  6. package/apps/runtime/dist/cli/connect.js +2 -1
  7. package/apps/runtime/dist/cli/environment.js +3 -0
  8. package/apps/runtime/dist/cli/machine.js +1 -70
  9. package/apps/runtime/dist/cli/main.js +2 -1
  10. package/apps/runtime/dist/cli/ollama.js +7 -254
  11. package/apps/runtime/dist/cli/setup.js +12 -9
  12. package/apps/runtime/dist/decision-model.js +1 -4
  13. package/apps/runtime/dist/docs/dev/licensing.md +20 -9
  14. package/apps/runtime/dist/docs/user-guide/command-line.md +5 -2
  15. package/apps/runtime/dist/elements/outside.js +2 -1
  16. package/apps/runtime/dist/engine/code-step.js +1 -1
  17. package/apps/runtime/dist/engine/decide.js +2 -2
  18. package/apps/runtime/dist/engine/device.js +3 -2
  19. package/apps/runtime/dist/engine/input.js +1 -1
  20. package/apps/runtime/dist/engine/runner.js +1 -1
  21. package/apps/runtime/dist/engine/steps.js +27 -8
  22. package/apps/runtime/dist/engine/surface.js +1 -1
  23. package/apps/runtime/dist/engine/template.js +1 -1
  24. package/apps/runtime/dist/env.js +1 -0
  25. package/apps/runtime/dist/harness/apple.js +4 -3
  26. package/apps/runtime/dist/harness/clients.js +117 -0
  27. package/apps/runtime/dist/harness/index.js +32 -87
  28. package/apps/runtime/dist/harness/model.js +32 -270
  29. package/apps/runtime/dist/harness/prompt.js +6 -120
  30. package/apps/runtime/dist/harness/types.js +5 -3
  31. package/apps/runtime/dist/local-call.js +6 -0
  32. package/apps/runtime/dist/local-models.js +53 -177
  33. package/apps/runtime/dist/mcp/bridge.js +12 -55
  34. package/apps/runtime/dist/mcp/elements.js +39 -4
  35. package/apps/runtime/dist/mcp/handler.js +12 -0
  36. package/apps/runtime/dist/mcp/run-pages.js +238 -0
  37. package/apps/runtime/dist/mcp/run-tasks.js +157 -0
  38. package/apps/runtime/dist/mcp/runs.js +129 -0
  39. package/apps/runtime/dist/mcp/tools.js +4 -95
  40. package/apps/runtime/dist/models.js +82 -32
  41. package/apps/runtime/dist/motion-graphics/step.js +2 -2
  42. package/apps/runtime/dist/prompts/mcp.md +4 -1
  43. package/apps/runtime/dist/render/downloads.js +1 -1
  44. package/apps/runtime/dist/render/shaped.js +1 -1
  45. package/apps/runtime/dist/routes/model-setup.js +77 -0
  46. package/apps/runtime/dist/routes/studio.js +8 -251
  47. package/apps/runtime/dist/services/space-categories.js +1 -1
  48. package/apps/runtime/dist/services/work-ai.js +11 -5
  49. package/apps/runtime/dist/texts.js +4 -6
  50. package/apps/runtime/dist/tools/connections.js +3 -0
  51. package/apps/runtime/dist/tools/harness.js +124 -0
  52. package/apps/web/dist/assets/AboutDialog-BSdAA4Wi.js +1 -0
  53. package/apps/web/dist/assets/{BlockEditor-CgjXTWly.js → BlockEditor-0noqMcAl.js} +1 -1
  54. package/apps/web/dist/assets/Bundle-Ctrq7lHH.js +1 -0
  55. package/apps/web/dist/assets/CapabilitiesPage-CZlVhBmU.js +2 -0
  56. package/apps/web/dist/assets/ChangelogDialog-BLCYV4jT.js +1 -0
  57. package/apps/web/dist/assets/{CodeEditor-2LyHbSre.js → CodeEditor-CpRn9BZq.js} +1 -1
  58. package/apps/web/dist/assets/ConnectorsSection-B4rRDlFo.js +1 -0
  59. package/apps/web/dist/assets/EditorPage-CXN-_zzG.js +3 -0
  60. package/apps/web/dist/assets/FlowPreview-DjQvcWxs.js +1 -0
  61. package/apps/web/dist/assets/LangSwitch-BuzsLp16.js +1 -0
  62. package/apps/web/dist/assets/LocalModels-BDfP2v5-.js +1 -0
  63. package/apps/web/dist/assets/Marketplace-4baBNzEc.js +2 -0
  64. package/apps/web/dist/assets/NewWizardChannels-B_xHm-bI.js +1 -0
  65. package/apps/web/dist/assets/NewWizardPage-BmZAY4zi.js +7 -0
  66. package/apps/web/dist/assets/OnboardingPage-fZq3WiTk.js +1 -0
  67. package/apps/web/dist/assets/ProtocolSection-v9wIxisg.js +1 -0
  68. package/apps/web/dist/assets/PublicRunner-BCh0VzAT.js +1 -0
  69. package/apps/web/dist/assets/{ReadOnly-CbvEK0rz.js → ReadOnly-13stkvNz.js} +1 -1
  70. package/apps/web/dist/assets/Results-4gmguYzH.js +1 -0
  71. package/apps/web/dist/assets/RunDrawer-CeEldWRn.js +1 -0
  72. package/apps/web/dist/assets/SettingsPage-BsKRRlfP.js +2 -0
  73. package/apps/web/dist/assets/SetupPage-FgA5Kl8z.js +1 -0
  74. package/apps/web/dist/assets/SharePage-BlBW4oxl.js +1 -0
  75. package/apps/web/dist/assets/SkillEditor-9QSskfmY.js +1 -0
  76. package/apps/web/dist/assets/Skills-DdUAyNhR.js +9 -0
  77. package/apps/web/dist/assets/SpacePage-CHkNPuqt.js +2 -0
  78. package/apps/web/dist/assets/StudioHome-BwPD-inc.js +1 -0
  79. package/apps/web/dist/assets/TableEditor-Du1DhbEC.js +7 -0
  80. package/apps/web/dist/assets/UpdateCheck-DPr9NXq_.js +2 -0
  81. package/apps/web/dist/assets/brand-DY3lzrOd.js +2 -0
  82. package/apps/web/dist/assets/changelog-BSdb22c3.js +1 -0
  83. package/apps/web/dist/assets/code-editor-Bep_LzQ5.js +2 -0
  84. package/apps/web/dist/assets/host-DiZQ_uws.js +1 -0
  85. package/apps/web/dist/assets/host-Dw-sMUSd.js +54 -0
  86. package/apps/web/dist/assets/i18n-DVrYWJaj.js +55 -0
  87. package/apps/web/dist/assets/index-C2gxK14s.css +1 -0
  88. package/apps/web/dist/assets/index-lQ4JYHYQ.js +102 -0
  89. package/apps/web/dist/assets/oss-credits-BHy69wkx.js +1 -0
  90. package/apps/web/dist/assets/{read-aloud-CRFt5q6k.js → read-aloud-CBycd8TA.js} +1 -1
  91. package/apps/web/dist/assets/{session-RDdtfee2.js → session-BYLtgklo.js} +1 -1
  92. package/apps/web/dist/assets/terminal-DmGdMags.js +16 -0
  93. package/apps/web/dist/assets/texts-ClKS2xhh.js +1 -0
  94. package/apps/web/dist/assets/theme-DFDOMsVo.js +14 -0
  95. package/apps/web/dist/assets/ui-CW2I3ecu.js +1 -0
  96. package/apps/web/dist/assets/ui-DfVpZYIW.js +16 -0
  97. package/apps/web/dist/assets/{useMutation-BSffqL6W.js → useMutation-BnkuLlQC.js} +1 -1
  98. package/apps/web/dist/assets/viewers-C6FfRwG1.js +2 -0
  99. package/apps/web/dist/index.html +18 -16
  100. package/apps/web/dist/mcp/flow.html +129 -129
  101. package/bin/bot-tunnel.mjs +375 -0
  102. package/bin/bot.mjs +494 -69
  103. package/node_modules/@engenty/{wizards-shared → chatviews}/dist/calc.js +1 -1
  104. package/node_modules/@engenty/chatviews/dist/chat/a2ui.d.ts +48 -0
  105. package/node_modules/@engenty/chatviews/dist/chat/a2ui.js +514 -0
  106. package/node_modules/@engenty/chatviews/dist/chat/check.d.ts +18 -0
  107. package/node_modules/@engenty/chatviews/dist/chat/check.js +97 -0
  108. package/node_modules/@engenty/chatviews/dist/chat/index.d.ts +3 -0
  109. package/node_modules/@engenty/chatviews/dist/chat/index.js +4 -0
  110. package/node_modules/@engenty/chatviews/dist/chat/library.d.ts +39 -0
  111. package/node_modules/@engenty/chatviews/dist/chat/library.js +314 -0
  112. package/node_modules/@engenty/{wizards-shared → chatviews}/dist/numbers.js +1 -1
  113. package/node_modules/@engenty/chatviews/dist/react/chat.d.ts +33 -0
  114. package/node_modules/@engenty/chatviews/dist/react/chat.js +150 -0
  115. package/node_modules/@engenty/chatviews/dist/react/field-looks.d.ts +39 -0
  116. package/node_modules/@engenty/chatviews/dist/react/field-looks.js +47 -0
  117. package/node_modules/@engenty/chatviews/dist/react/markdown.d.ts +5 -0
  118. package/node_modules/@engenty/chatviews/dist/react/markdown.js +11 -0
  119. package/node_modules/@engenty/chatviews/dist/react/no-devtools.d.ts +0 -0
  120. package/node_modules/@engenty/chatviews/dist/react/no-devtools.js +8 -0
  121. package/node_modules/@engenty/chatviews/dist/react/surface.d.ts +39 -0
  122. package/node_modules/@engenty/chatviews/dist/react/surface.js +552 -0
  123. package/node_modules/@engenty/chatviews/dist/react/texts.d.ts +39 -0
  124. package/node_modules/@engenty/chatviews/dist/react/texts.js +42 -0
  125. package/node_modules/@engenty/chatviews/dist/react/ui.d.ts +112 -0
  126. package/node_modules/@engenty/chatviews/dist/react/ui.js +212 -0
  127. package/node_modules/@engenty/{wizards-shared → chatviews}/dist/shape.js +1 -1
  128. package/node_modules/@engenty/{wizards-shared → chatviews}/dist/surface.js +1 -1
  129. package/node_modules/@engenty/chatviews/package.json +19 -0
  130. package/node_modules/@engenty/decision-model/dist/client.d.ts +76 -0
  131. package/node_modules/@engenty/decision-model/dist/client.js +188 -0
  132. package/node_modules/@engenty/decision-model/dist/index.d.ts +6 -0
  133. package/node_modules/@engenty/decision-model/dist/index.js +5 -0
  134. package/node_modules/@engenty/decision-model/dist/local.d.ts +11 -0
  135. package/node_modules/@engenty/decision-model/dist/local.js +116 -0
  136. package/node_modules/@engenty/decision-model/dist/resolve.d.ts +26 -0
  137. package/node_modules/@engenty/decision-model/dist/resolve.js +53 -0
  138. package/node_modules/@engenty/decision-model/dist/types.d.ts +80 -0
  139. package/node_modules/@engenty/decision-model/dist/types.js +6 -0
  140. package/node_modules/@engenty/decision-model/dist/validate.d.ts +9 -0
  141. package/node_modules/@engenty/decision-model/dist/validate.js +50 -0
  142. package/node_modules/@engenty/decision-model/dist/ways.d.ts +42 -0
  143. package/node_modules/@engenty/decision-model/dist/ways.js +72 -0
  144. package/node_modules/@engenty/decision-model/package.json +9 -0
  145. package/node_modules/@engenty/local-models/dist/bridge/index.d.ts +54 -0
  146. package/node_modules/@engenty/local-models/dist/bridge/index.js +117 -0
  147. package/node_modules/@engenty/local-models/dist/clients/antigravity.d.ts +37 -0
  148. package/{apps/runtime/dist/harness → node_modules/@engenty/local-models/dist/clients}/antigravity.js +72 -17
  149. package/node_modules/@engenty/local-models/dist/clients/chat.d.ts +89 -0
  150. package/node_modules/@engenty/local-models/dist/clients/chat.js +22 -0
  151. package/node_modules/@engenty/local-models/dist/clients/claude.d.ts +32 -0
  152. package/node_modules/@engenty/local-models/dist/clients/claude.js +239 -0
  153. package/node_modules/@engenty/local-models/dist/clients/client.d.ts +31 -0
  154. package/node_modules/@engenty/local-models/dist/clients/client.js +2 -0
  155. package/node_modules/@engenty/local-models/dist/clients/codex.d.ts +35 -0
  156. package/node_modules/@engenty/local-models/dist/clients/codex.js +254 -0
  157. package/node_modules/@engenty/local-models/dist/clients/cursor.d.ts +35 -0
  158. package/node_modules/@engenty/local-models/dist/clients/cursor.js +192 -0
  159. package/node_modules/@engenty/local-models/dist/clients/detect.d.ts +18 -0
  160. package/node_modules/@engenty/local-models/dist/clients/detect.js +34 -0
  161. package/node_modules/@engenty/local-models/dist/clients/env.d.ts +66 -0
  162. package/{apps/runtime/dist/harness → node_modules/@engenty/local-models/dist/clients}/env.js +62 -31
  163. package/node_modules/@engenty/local-models/dist/clients/failure.d.ts +26 -0
  164. package/node_modules/@engenty/local-models/dist/clients/failure.js +35 -0
  165. package/node_modules/@engenty/local-models/dist/clients/index.d.ts +15 -0
  166. package/node_modules/@engenty/local-models/dist/clients/index.js +18 -0
  167. package/node_modules/@engenty/local-models/dist/clients/model.d.ts +129 -0
  168. package/node_modules/@engenty/local-models/dist/clients/model.js +225 -0
  169. package/node_modules/@engenty/local-models/dist/clients/prompt.d.ts +36 -0
  170. package/node_modules/@engenty/local-models/dist/clients/prompt.js +123 -0
  171. package/node_modules/@engenty/local-models/dist/clients/run.d.ts +15 -0
  172. package/node_modules/@engenty/local-models/dist/clients/run.js +41 -0
  173. package/node_modules/@engenty/local-models/dist/index.d.ts +4 -0
  174. package/node_modules/@engenty/local-models/dist/index.js +4 -0
  175. package/node_modules/@engenty/local-models/dist/lmstudio/api.d.ts +49 -0
  176. package/node_modules/@engenty/local-models/dist/lmstudio/api.js +101 -0
  177. package/node_modules/@engenty/local-models/dist/lmstudio/index.d.ts +3 -0
  178. package/node_modules/@engenty/local-models/dist/lmstudio/index.js +3 -0
  179. package/node_modules/@engenty/local-models/dist/lmstudio/load.d.ts +12 -0
  180. package/node_modules/@engenty/local-models/dist/lmstudio/load.js +100 -0
  181. package/node_modules/@engenty/local-models/dist/lmstudio/server.d.ts +3 -0
  182. package/node_modules/@engenty/local-models/dist/lmstudio/server.js +29 -0
  183. package/node_modules/@engenty/local-models/dist/mlx/helper.d.ts +54 -0
  184. package/node_modules/@engenty/local-models/dist/mlx/helper.js +149 -0
  185. package/node_modules/@engenty/local-models/dist/mlx/index.d.ts +3 -0
  186. package/node_modules/@engenty/local-models/dist/mlx/index.js +3 -0
  187. package/node_modules/@engenty/local-models/dist/mlx/server.d.ts +19 -0
  188. package/node_modules/@engenty/local-models/dist/mlx/server.js +82 -0
  189. package/node_modules/@engenty/local-models/dist/mlx/store.d.ts +16 -0
  190. package/node_modules/@engenty/local-models/dist/mlx/store.js +153 -0
  191. package/node_modules/@engenty/local-models/dist/ollama/api.d.ts +37 -0
  192. package/node_modules/@engenty/local-models/dist/ollama/api.js +147 -0
  193. package/node_modules/@engenty/local-models/dist/ollama/index.d.ts +3 -0
  194. package/node_modules/@engenty/local-models/dist/ollama/index.js +3 -0
  195. package/node_modules/@engenty/local-models/dist/ollama/model.d.ts +54 -0
  196. package/node_modules/@engenty/local-models/dist/ollama/model.js +302 -0
  197. package/node_modules/@engenty/local-models/dist/ollama/server.d.ts +3 -0
  198. package/node_modules/@engenty/local-models/dist/ollama/server.js +45 -0
  199. package/node_modules/@engenty/local-models/dist/probe.d.ts +57 -0
  200. package/node_modules/@engenty/local-models/dist/probe.js +174 -0
  201. package/node_modules/@engenty/local-models/dist/servers/index.d.ts +6 -0
  202. package/node_modules/@engenty/local-models/dist/servers/index.js +12 -0
  203. package/node_modules/@engenty/local-models/dist/servers/server.d.ts +84 -0
  204. package/node_modules/@engenty/local-models/dist/servers/server.js +38 -0
  205. package/node_modules/@engenty/local-models/package.json +16 -0
  206. package/node_modules/@engenty/model-setup/dist/catalog.d.ts +36 -0
  207. package/node_modules/@engenty/model-setup/dist/catalog.js +81 -0
  208. package/node_modules/@engenty/model-setup/dist/index.d.ts +3 -0
  209. package/node_modules/@engenty/model-setup/dist/index.js +3 -0
  210. package/node_modules/@engenty/model-setup/dist/offered.d.ts +7 -0
  211. package/node_modules/@engenty/model-setup/dist/offered.js +64 -0
  212. package/node_modules/@engenty/model-setup/dist/react/client.d.ts +46 -0
  213. package/node_modules/@engenty/model-setup/dist/react/client.js +147 -0
  214. package/node_modules/@engenty/model-setup/dist/react/columns.d.ts +78 -0
  215. package/node_modules/@engenty/model-setup/dist/react/columns.js +99 -0
  216. package/node_modules/@engenty/model-setup/dist/react/host.d.ts +31 -0
  217. package/node_modules/@engenty/model-setup/dist/react/host.js +48 -0
  218. package/node_modules/@engenty/model-setup/dist/react/index.d.ts +7 -0
  219. package/node_modules/@engenty/model-setup/dist/react/index.js +7 -0
  220. package/node_modules/@engenty/model-setup/dist/react/keys.d.ts +48 -0
  221. package/node_modules/@engenty/model-setup/dist/react/keys.js +74 -0
  222. package/node_modules/@engenty/model-setup/dist/react/local-models.d.ts +23 -0
  223. package/node_modules/@engenty/model-setup/dist/react/local-models.js +134 -0
  224. package/node_modules/@engenty/model-setup/dist/react/servers.d.ts +4 -0
  225. package/node_modules/@engenty/model-setup/dist/react/servers.js +13 -0
  226. package/node_modules/@engenty/model-setup/dist/react/terminal.d.ts +13 -0
  227. package/node_modules/@engenty/model-setup/dist/react/terminal.js +79 -0
  228. package/node_modules/@engenty/model-setup/dist/react/tone.d.ts +13 -0
  229. package/node_modules/@engenty/model-setup/dist/react/tone.js +66 -0
  230. package/node_modules/@engenty/model-setup/dist/server/apps.d.ts +12 -0
  231. package/node_modules/@engenty/model-setup/dist/server/apps.js +22 -0
  232. package/node_modules/@engenty/model-setup/dist/server/clients.d.ts +55 -0
  233. package/node_modules/@engenty/model-setup/dist/server/clients.js +96 -0
  234. package/node_modules/@engenty/model-setup/dist/server/index.d.ts +8 -0
  235. package/node_modules/@engenty/model-setup/dist/server/index.js +8 -0
  236. package/node_modules/@engenty/model-setup/dist/server/install.d.ts +24 -0
  237. package/node_modules/@engenty/model-setup/dist/server/install.js +68 -0
  238. package/node_modules/@engenty/model-setup/dist/server/lmstudio.d.ts +9 -0
  239. package/node_modules/@engenty/model-setup/dist/server/lmstudio.js +52 -0
  240. package/node_modules/@engenty/model-setup/dist/server/local-models.d.ts +47 -0
  241. package/node_modules/@engenty/model-setup/dist/server/local-models.js +164 -0
  242. package/node_modules/@engenty/model-setup/dist/server/models.d.ts +12 -0
  243. package/node_modules/@engenty/model-setup/dist/server/models.js +16 -0
  244. package/node_modules/@engenty/model-setup/dist/server/ollama.d.ts +22 -0
  245. package/node_modules/@engenty/model-setup/dist/server/ollama.js +146 -0
  246. package/node_modules/@engenty/model-setup/dist/server/routes.d.ts +51 -0
  247. package/node_modules/@engenty/model-setup/dist/server/routes.js +211 -0
  248. package/node_modules/@engenty/model-setup/dist/server/server-apps.d.ts +14 -0
  249. package/node_modules/@engenty/model-setup/dist/server/server-apps.js +24 -0
  250. package/node_modules/@engenty/model-setup/dist/server/terminal.d.ts +43 -0
  251. package/node_modules/@engenty/model-setup/dist/server/terminal.js +222 -0
  252. package/node_modules/@engenty/model-setup/dist/texts.d.ts +222 -0
  253. package/node_modules/@engenty/model-setup/dist/texts.js +222 -0
  254. package/node_modules/@engenty/model-setup/dist/types.d.ts +111 -0
  255. package/node_modules/@engenty/model-setup/dist/types.js +2 -0
  256. package/node_modules/@engenty/model-setup/package.json +12 -0
  257. package/node_modules/@engenty/search-index/dist/catalog-lexical.d.ts +14 -0
  258. package/node_modules/@engenty/search-index/dist/catalog-lexical.js +165 -0
  259. package/node_modules/@engenty/search-index/dist/catalog-rank.d.ts +33 -0
  260. package/node_modules/@engenty/search-index/dist/catalog-rank.js +99 -0
  261. package/node_modules/@engenty/search-index/dist/catalog-search.d.ts +40 -0
  262. package/node_modules/@engenty/search-index/dist/catalog-search.js +161 -0
  263. package/node_modules/@engenty/search-index/dist/chunks.d.ts +17 -0
  264. package/node_modules/@engenty/search-index/dist/chunks.js +164 -0
  265. package/node_modules/@engenty/search-index/dist/contracts.d.ts +135 -0
  266. package/node_modules/@engenty/search-index/dist/contracts.js +9 -0
  267. package/node_modules/@engenty/search-index/dist/embedder.d.ts +31 -0
  268. package/node_modules/@engenty/search-index/dist/embedder.js +82 -0
  269. package/node_modules/@engenty/search-index/dist/embedders/gemini.d.ts +11 -0
  270. package/node_modules/@engenty/search-index/dist/embedders/gemini.js +54 -0
  271. package/node_modules/@engenty/search-index/dist/embedders/index.d.ts +5 -0
  272. package/node_modules/@engenty/search-index/dist/embedders/index.js +5 -0
  273. package/node_modules/@engenty/search-index/dist/embedders/ollama.d.ts +12 -0
  274. package/node_modules/@engenty/search-index/dist/embedders/ollama.js +43 -0
  275. package/node_modules/@engenty/search-index/dist/embedders/openai.d.ts +11 -0
  276. package/node_modules/@engenty/search-index/dist/embedders/openai.js +36 -0
  277. package/node_modules/@engenty/search-index/dist/embedders/shared.d.ts +5 -0
  278. package/node_modules/@engenty/search-index/dist/embedders/shared.js +26 -0
  279. package/node_modules/@engenty/search-index/dist/embedders/ways.d.ts +16 -0
  280. package/node_modules/@engenty/search-index/dist/embedders/ways.js +90 -0
  281. package/node_modules/@engenty/search-index/dist/index.d.ts +10 -0
  282. package/node_modules/@engenty/search-index/dist/index.js +10 -0
  283. package/node_modules/@engenty/search-index/dist/payload.d.ts +13 -0
  284. package/node_modules/@engenty/search-index/dist/payload.js +51 -0
  285. package/node_modules/@engenty/search-index/dist/registry.d.ts +25 -0
  286. package/node_modules/@engenty/search-index/dist/registry.js +56 -0
  287. package/node_modules/@engenty/search-index/dist/scoring.d.ts +10 -0
  288. package/node_modules/@engenty/search-index/dist/scoring.js +45 -0
  289. package/node_modules/@engenty/search-index/dist/strategy.d.ts +6 -0
  290. package/node_modules/@engenty/search-index/dist/strategy.js +25 -0
  291. package/node_modules/@engenty/search-index/package.json +10 -0
  292. package/node_modules/@engenty/tool-harness/dist/harness.d.ts +70 -0
  293. package/node_modules/@engenty/tool-harness/dist/harness.js +170 -0
  294. package/node_modules/@engenty/tool-harness/dist/index.d.ts +5 -0
  295. package/node_modules/@engenty/tool-harness/dist/index.js +5 -0
  296. package/node_modules/@engenty/tool-harness/dist/judge.d.ts +8 -0
  297. package/node_modules/@engenty/tool-harness/dist/judge.js +39 -0
  298. package/node_modules/@engenty/tool-harness/dist/levels.d.ts +18 -0
  299. package/node_modules/@engenty/tool-harness/dist/levels.js +47 -0
  300. package/node_modules/@engenty/tool-harness/dist/model.d.ts +6 -0
  301. package/node_modules/@engenty/tool-harness/dist/model.js +60 -0
  302. package/node_modules/@engenty/tool-harness/dist/schema.d.ts +26 -0
  303. package/node_modules/@engenty/tool-harness/dist/schema.js +57 -0
  304. package/node_modules/@engenty/tool-harness/package.json +9 -0
  305. package/node_modules/@engenty/wizards-shared/dist/catalog-prompt.js +2 -1
  306. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +10 -10
  307. package/node_modules/@engenty/wizards-shared/dist/definition.js +4 -4
  308. package/node_modules/@engenty/wizards-shared/dist/run-schema.js +1 -1
  309. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -1
  310. package/node_modules/@engenty/wizards-shared/dist/run.js +4 -0
  311. package/node_modules/@engenty/wizards-shared/dist/store.js +2 -1
  312. package/node_modules/@engenty/wizards-shared/dist/wizard-agents.d.ts +1 -1
  313. package/node_modules/@engenty/wizards-shared/dist/wizard-agents.js +1 -1
  314. package/node_modules/@engenty/wizards-shared/dist/wizard-text.js +2 -2
  315. package/package.json +13 -1
  316. package/plugin/.claude-plugin/plugin.json +1 -1
  317. package/plugin/plugin.json +1 -1
  318. package/apps/runtime/dist/agents/chat-clients.js +0 -344
  319. package/apps/runtime/dist/harness/claude.js +0 -141
  320. package/apps/runtime/dist/harness/codex.js +0 -222
  321. package/apps/runtime/dist/harness/cursor.js +0 -89
  322. package/apps/runtime/dist/harness/terminal.js +0 -201
  323. package/apps/web/dist/assets/AboutDialog-DM_2-iLP.js +0 -1
  324. package/apps/web/dist/assets/Bundle-C0u5HUZL.js +0 -1
  325. package/apps/web/dist/assets/CapabilitiesPage-DxRUERr-.js +0 -2
  326. package/apps/web/dist/assets/ChangelogDialog-Cyn3LAch.js +0 -1
  327. package/apps/web/dist/assets/ConnectorsSection-BYOrwccO.js +0 -1
  328. package/apps/web/dist/assets/EditorPage-BFUQzJpN.js +0 -3
  329. package/apps/web/dist/assets/FlowPreview-BXf4EKjU.js +0 -1
  330. package/apps/web/dist/assets/LangSwitch-BLB7dDce.js +0 -1
  331. package/apps/web/dist/assets/Marketplace-B3NoH5Va.js +0 -2
  332. package/apps/web/dist/assets/NewWizardChannels-DhmYe2C8.js +0 -1
  333. package/apps/web/dist/assets/NewWizardPage-MGKJVDp2.js +0 -7
  334. package/apps/web/dist/assets/OnboardingPage-RawpCO9J.js +0 -1
  335. package/apps/web/dist/assets/ProtocolSection-B1MshkAx.js +0 -1
  336. package/apps/web/dist/assets/PublicRunner-COatyxMi.js +0 -1
  337. package/apps/web/dist/assets/Results-DI4EHtkh.js +0 -1
  338. package/apps/web/dist/assets/RunDrawer-xXcbQ9wP.js +0 -1
  339. package/apps/web/dist/assets/SettingsPage-BcqqYDqw.js +0 -2
  340. package/apps/web/dist/assets/SetupPage-DG3fJ6fk.js +0 -1
  341. package/apps/web/dist/assets/SharePage-Drntg_oj.js +0 -1
  342. package/apps/web/dist/assets/SkillEditor-Ca_bzmjD.js +0 -1
  343. package/apps/web/dist/assets/Skills-BcgxuD15.js +0 -9
  344. package/apps/web/dist/assets/SpacePage-CzQAEQj8.js +0 -2
  345. package/apps/web/dist/assets/StudioHome-DWTDTslp.js +0 -1
  346. package/apps/web/dist/assets/TableEditor-DirMDIGk.js +0 -7
  347. package/apps/web/dist/assets/UpdateCheck-C6GlE6Am.js +0 -2
  348. package/apps/web/dist/assets/brand-BIT7AumL.js +0 -2
  349. package/apps/web/dist/assets/changelog-CMovB3yB.js +0 -1
  350. package/apps/web/dist/assets/code-editor-CufyaUFC.js +0 -2
  351. package/apps/web/dist/assets/host-DNvnJXoi.js +0 -69
  352. package/apps/web/dist/assets/i18n-WXeVnv7i.js +0 -55
  353. package/apps/web/dist/assets/index-D1iL3986.css +0 -1
  354. package/apps/web/dist/assets/index-DOq0CvXM.js +0 -102
  355. package/apps/web/dist/assets/oss-credits-C4SGbRkz.js +0 -1
  356. package/apps/web/dist/assets/theme-23bNrOQh.js +0 -14
  357. package/apps/web/dist/assets/ui-DkEhb2Rt.js +0 -16
  358. package/apps/web/dist/assets/viewers-CmGDpBjn.js +0 -2
  359. /package/apps/web/dist/assets/{host-BrP-ENHg.css → terminal-BrP-ENHg.css} +0 -0
  360. /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/calc.d.ts +0 -0
  361. /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/numbers.d.ts +0 -0
  362. /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/shape.d.ts +0 -0
  363. /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/surface.d.ts +0 -0
@@ -0,0 +1,101 @@
1
+ import { getJson, jsonBody, refusal, } from "../servers/server.js";
2
+ /**
3
+ * LM Studio on a computer, through its own REST API (`/api/v1/…`, LM Studio 0.4.0 and newer): the
4
+ * models it holds, downloads, and a model loaded with the context length a caller needs. Where
5
+ * its server wants a token, LM_API_TOKEN is it.
6
+ */
7
+ /** Where LM Studio answers when nothing names another address. */
8
+ export const LMSTUDIO_DEFAULT = "http://127.0.0.1:1234";
9
+ const NAME = "LM Studio";
10
+ /** LM Studio's root address, from its root or the OpenAI-compatible `…/v1`. */
11
+ export function lmStudioRoot(url) {
12
+ return url.trim().replace(/\/+$/, "").replace(/\/v1$/, "");
13
+ }
14
+ /** Where LM Studio answers for this process: LMSTUDIO_URL (a root or `…/v1`), else its default. */
15
+ export function lmStudioAddress(env = process.env) {
16
+ return lmStudioRoot(env.LMSTUDIO_URL || LMSTUDIO_DEFAULT);
17
+ }
18
+ /** A request's headers: the token, where there is one. */
19
+ export function lmStudioHeaders(env = process.env) {
20
+ const token = env.LM_API_TOKEN?.trim();
21
+ return token ? { authorization: `Bearer ${token}` } : {};
22
+ }
23
+ const JOB = { llm: "completion", embedding: "embedding", decision: "decision" };
24
+ /** The models as LM Studio lists them; null where it does not answer. */
25
+ export async function listedModels(url, { fetch: doFetch = fetch } = {}) {
26
+ const list = await getJson(doFetch, `${lmStudioRoot(url)}/api/v1/models`, { headers: lmStudioHeaders() }, 5000);
27
+ return list ? (list.models ?? []) : null;
28
+ }
29
+ export async function lmStudioState(url, { fetch: doFetch = fetch } = {}) {
30
+ const state = { running: false, version: null, models: [], trouble: null };
31
+ try {
32
+ const res = await doFetch(`${lmStudioRoot(url)}/api/v1/models`, {
33
+ headers: lmStudioHeaders(),
34
+ signal: AbortSignal.timeout(2000),
35
+ });
36
+ if (res.ok) {
37
+ const { models } = (await res.json());
38
+ return { ...state, running: true, models: (models ?? []).map((m) => m.key) };
39
+ }
40
+ const trouble = res.status === 401 || res.status === 403 ? "locked" : "old";
41
+ return { ...state, running: true, trouble };
42
+ }
43
+ catch {
44
+ return state;
45
+ }
46
+ }
47
+ /** The models of the LM Studio at `url`; empty where it does not answer. */
48
+ export async function lmStudioModels(url, options = {}) {
49
+ return ((await listedModels(url, options)) ?? []).map((m) => {
50
+ const tools = Boolean(m.capabilities?.trained_for_tool_use);
51
+ const vision = Boolean(m.capabilities?.vision);
52
+ const thinking = Boolean(m.capabilities?.reasoning?.allowed_options?.some((o) => o !== "off"));
53
+ return {
54
+ name: m.key,
55
+ size: m.size_bytes,
56
+ digest: m.key,
57
+ capabilities: [
58
+ JOB[m.type],
59
+ ...(tools ? ["tools"] : []),
60
+ ...(vision ? ["vision"] : []),
61
+ ...(thinking ? ["thinking"] : []),
62
+ ],
63
+ completion: m.type === "llm",
64
+ tools,
65
+ vision,
66
+ thinking,
67
+ runner: m.format === "mlx" ? "mlx" : m.format === "gguf" ? "llamacpp" : null,
68
+ quantization: m.quantization?.name || null,
69
+ running: Boolean(m.loaded_instances?.length),
70
+ };
71
+ });
72
+ }
73
+ /** Downloads a model of LM Studio's catalog, or by its Hugging Face address; asked again each second. */
74
+ export async function lmStudioDownload(url, model, onProgress, { fetch: doFetch = fetch, signal, every = 1000, } = {}) {
75
+ const root = lmStudioRoot(url);
76
+ const ask = async (path, init = {}) => {
77
+ const res = await doFetch(`${root}${path}`, {
78
+ ...init,
79
+ headers: { ...init.headers, ...lmStudioHeaders() },
80
+ signal,
81
+ });
82
+ if (!res.ok) {
83
+ throw await refusal(res, NAME);
84
+ }
85
+ return (await res.json());
86
+ };
87
+ let status = await ask("/api/v1/models/download", { method: "POST", ...jsonBody({ model }) });
88
+ const job = status.job_id;
89
+ while (status.status === "downloading" && job) {
90
+ onProgress(status.downloaded_bytes ?? 0, status.total_size_bytes ?? 0);
91
+ await new Promise((resolve) => setTimeout(resolve, every));
92
+ signal?.throwIfAborted();
93
+ status = await ask(`/api/v1/models/download/status/${encodeURIComponent(job)}`);
94
+ }
95
+ if (status.status === "paused") {
96
+ throw new Error("The download is paused in LM Studio.");
97
+ }
98
+ if (status.status === "failed") {
99
+ throw new Error("The download failed. LM Studio says why.");
100
+ }
101
+ }
@@ -0,0 +1,3 @@
1
+ export { LMSTUDIO_DEFAULT, lmStudioAddress, lmStudioDownload, lmStudioHeaders, lmStudioModels, lmStudioRoot, lmStudioState, } from "./api.js";
2
+ export { lmStudioFetch, lmStudioLoaded } from "./load.js";
3
+ export { lmStudio } from "./server.js";
@@ -0,0 +1,3 @@
1
+ export { LMSTUDIO_DEFAULT, lmStudioAddress, lmStudioDownload, lmStudioHeaders, lmStudioModels, lmStudioRoot, lmStudioState, } from "./api.js";
2
+ export { lmStudioFetch, lmStudioLoaded } from "./load.js";
3
+ export { lmStudio } from "./server.js";
@@ -0,0 +1,12 @@
1
+ import { type ServerOptions } from "../servers/server.js";
2
+ /** Has a model in memory that reads at least `context` tokens, or all it can. */
3
+ export declare function lmStudioLoaded(url: string, model: string, { context, fetch: doFetch }?: ServerOptions & {
4
+ context?: number;
5
+ }): Promise<void>;
6
+ /**
7
+ * A `fetch` for an OpenAI-compatible client of LM Studio: before each call the model it names is
8
+ * loaded with the context length, and the token goes along where there is one.
9
+ */
10
+ export declare function lmStudioFetch(url: string, options?: ServerOptions & {
11
+ context?: number;
12
+ }): typeof fetch;
@@ -0,0 +1,100 @@
1
+ import { jsonBody, refusal } from "../servers/server.js";
2
+ import { listedModels, lmStudioHeaders, lmStudioRoot } from "./api.js";
3
+ /**
4
+ * Loading: LM Studio loads a model by itself at the first call, with the context length of its
5
+ * own settings, which a conversation with tools outgrows at once. So a model is loaded before the
6
+ * call, with the length the caller needs, and unloaded once nobody asked it for a while: LM
7
+ * Studio keeps a model loaded this way until it is told otherwise.
8
+ */
9
+ /** Tokens a model reads at most, where the caller names no other number. */
10
+ const CONTEXT = 16_384;
11
+ /** How long a model this process loaded stays, unasked. */
12
+ const IDLE_MS = 30 * 60_000;
13
+ /** Loading takes as long as the model is large. */
14
+ const LOAD_TIMEOUT = 180_000;
15
+ /** The models this process loaded, by address and instance, each with the clock of its unloading. */
16
+ const loaded = new Map();
17
+ /** Loads that run now: calls that come meanwhile wait for the same one. */
18
+ const loading = new Map();
19
+ async function unload(root, instance, doFetch) {
20
+ const clock = loaded.get(`${root} ${instance}`);
21
+ clearTimeout(clock);
22
+ loaded.delete(`${root} ${instance}`);
23
+ await doFetch(`${root}/api/v1/models/unload`, {
24
+ method: "POST",
25
+ ...withToken(jsonBody({ instance_id: instance })),
26
+ signal: AbortSignal.timeout(30_000),
27
+ }).catch(() => undefined);
28
+ }
29
+ const withToken = (init) => ({
30
+ ...init,
31
+ headers: { ...init.headers, ...lmStudioHeaders() },
32
+ });
33
+ /** A call was made on it: its clock starts again. Only for an instance this process loaded. */
34
+ function touch(root, instance, doFetch) {
35
+ const id = `${root} ${instance}`;
36
+ clearTimeout(loaded.get(id));
37
+ const clock = setTimeout(() => void unload(root, instance, doFetch), IDLE_MS);
38
+ clock.unref?.();
39
+ loaded.set(id, clock);
40
+ }
41
+ async function load(root, model, context, doFetch) {
42
+ const held = (await listedModels(root, { fetch: doFetch }))?.find((m) => m.key === model);
43
+ if (!held) {
44
+ // Not one it lists: LM Studio itself says so at the call.
45
+ return;
46
+ }
47
+ const wanted = Math.min(context, held.max_context_length ?? context);
48
+ for (const { id, config } of held.loaded_instances ?? []) {
49
+ if ((config?.context_length ?? 0) >= wanted) {
50
+ if (loaded.has(`${root} ${id}`)) {
51
+ touch(root, id, doFetch);
52
+ }
53
+ return;
54
+ }
55
+ // Loaded too short: it makes room for the same model at the length that is needed.
56
+ await unload(root, id, doFetch);
57
+ }
58
+ const res = await doFetch(`${root}/api/v1/models/load`, {
59
+ method: "POST",
60
+ ...withToken(jsonBody({ model, context_length: wanted })),
61
+ signal: AbortSignal.timeout(LOAD_TIMEOUT),
62
+ });
63
+ if (!res.ok) {
64
+ throw await refusal(res, "LM Studio");
65
+ }
66
+ const { instance_id } = (await res.json());
67
+ touch(root, instance_id ?? model, doFetch);
68
+ }
69
+ /** Has a model in memory that reads at least `context` tokens, or all it can. */
70
+ export function lmStudioLoaded(url, model, { context = CONTEXT, fetch: doFetch = fetch } = {}) {
71
+ const root = lmStudioRoot(url);
72
+ const key = `${root} ${model}`;
73
+ const running = loading.get(key);
74
+ if (running) {
75
+ return running;
76
+ }
77
+ const run = load(root, model, context, doFetch).finally(() => loading.delete(key));
78
+ loading.set(key, run);
79
+ return run;
80
+ }
81
+ /**
82
+ * A `fetch` for an OpenAI-compatible client of LM Studio: before each call the model it names is
83
+ * loaded with the context length, and the token goes along where there is one.
84
+ */
85
+ export function lmStudioFetch(url, options = {}) {
86
+ const doFetch = options.fetch ?? fetch;
87
+ return async (input, init) => {
88
+ if (typeof init?.body === "string") {
89
+ const { model } = JSON.parse(init.body);
90
+ if (model) {
91
+ await lmStudioLoaded(url, model, options);
92
+ }
93
+ }
94
+ const headers = new Headers(init?.headers);
95
+ for (const [name, value] of Object.entries(lmStudioHeaders())) {
96
+ headers.set(name, value);
97
+ }
98
+ return doFetch(input, { ...init, headers });
99
+ };
100
+ }
@@ -0,0 +1,3 @@
1
+ import { type LocalServer } from "../servers/server.js";
2
+ /** LM Studio as one of the servers on a computer. Its API removes no model: the app does. */
3
+ export declare const lmStudio: LocalServer;
@@ -0,0 +1,29 @@
1
+ import { jsonBody, refusal } from "../servers/server.js";
2
+ import { lmStudioAddress, lmStudioDownload, lmStudioModels, lmStudioRoot, lmStudioState, } from "./api.js";
3
+ import { lmStudioFetch } from "./load.js";
4
+ /** LM Studio as one of the servers on a computer. Its API removes no model: the app does. */
5
+ export const lmStudio = {
6
+ id: "lmstudio",
7
+ name: "LM Studio",
8
+ address: lmStudioAddress,
9
+ state: lmStudioState,
10
+ models: lmStudioModels,
11
+ download: lmStudioDownload,
12
+ async ask(url, model, prompt, { fetch: doFetch, signal } = {}) {
13
+ const root = lmStudioRoot(url);
14
+ const res = await lmStudioFetch(root, { fetch: doFetch })(`${root}/v1/chat/completions`, {
15
+ method: "POST",
16
+ ...jsonBody({
17
+ model: model.name,
18
+ messages: [{ role: "user", content: prompt }],
19
+ max_tokens: 64,
20
+ }),
21
+ signal,
22
+ });
23
+ if (!res.ok) {
24
+ throw await refusal(res, "LM Studio");
25
+ }
26
+ const body = (await res.json());
27
+ return body.choices?.[0]?.message?.content?.trim() ?? "";
28
+ },
29
+ };
@@ -0,0 +1,54 @@
1
+ /** The helper: built into mlx/bin by mlx/build.mjs, or named by the environment. */
2
+ export declare function mlxBin(env?: NodeJS.ProcessEnv): string;
3
+ /** MLX runs here: a Mac with Apple silicon that has the helper. */
4
+ export declare function mlxSupported(): boolean;
5
+ /** What a call waits for: the model is loaded, reads (of `total` tokens `done`) or thinks. */
6
+ export interface Waiting {
7
+ state: "loading" | "reading" | "thinking";
8
+ done?: number;
9
+ total?: number;
10
+ }
11
+ /** What the helper says of a call, in the shape of Ollama's chat API. */
12
+ export interface HelperChunk {
13
+ id: string;
14
+ wait?: Waiting;
15
+ message?: {
16
+ content?: string;
17
+ thinking?: string;
18
+ tool_calls?: {
19
+ function: {
20
+ name: string;
21
+ arguments: unknown;
22
+ };
23
+ }[];
24
+ };
25
+ done?: boolean;
26
+ done_reason?: string;
27
+ prompt_eval_count?: number;
28
+ eval_count?: number;
29
+ error?: string;
30
+ }
31
+ export declare class Helper {
32
+ private readonly bin;
33
+ private readonly idle;
34
+ private child;
35
+ private readonly calls;
36
+ /** The call that only reads ahead. What it has read stays read when another call ends it. */
37
+ private ahead;
38
+ private clock;
39
+ private next;
40
+ /** The folder of the model in memory. */
41
+ model: string | undefined;
42
+ constructor(bin?: () => string, idle?: number);
43
+ private start;
44
+ private write;
45
+ private rest;
46
+ /** Ends the helper and frees the memory of its model. */
47
+ stop(): void;
48
+ /** One call: what the model says as it says it. */
49
+ chat(chat: {
50
+ model: string;
51
+ } & Record<string, unknown>, signal?: AbortSignal): ReadableStream<HelperChunk>;
52
+ }
53
+ /** This process's helper. */
54
+ export declare const helper: Helper;
@@ -0,0 +1,149 @@
1
+ import { spawn } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { join, resolve } from "node:path";
4
+ import { createInterface } from "node:readline";
5
+ import { fileURLToPath } from "node:url";
6
+ /**
7
+ * `wizards-mlx` (../../mlx): Apple's MLX as a long-lived child of this process. It holds one
8
+ * model, answers one call after the other, and goes away once nobody asked it for a while, with
9
+ * the memory the model took.
10
+ */
11
+ /** How long the model stays in memory, unasked. */
12
+ const IDLE_MS = 10 * 60_000;
13
+ /** The helper: built into mlx/bin by mlx/build.mjs, or named by the environment. */
14
+ export function mlxBin(env = process.env) {
15
+ return (env.WIZARDS_MLX_BIN?.trim() ||
16
+ join(resolve(fileURLToPath(import.meta.url), "../../.."), "mlx", "bin", "wizards-mlx"));
17
+ }
18
+ /** MLX runs here: a Mac with Apple silicon that has the helper. */
19
+ export function mlxSupported() {
20
+ return process.platform === "darwin" && process.arch === "arm64" && existsSync(mlxBin());
21
+ }
22
+ /** A pipe no longer keeps this process alive. */
23
+ const unref = (pipe) => pipe?.unref?.();
24
+ export class Helper {
25
+ bin;
26
+ idle;
27
+ child;
28
+ calls = new Map();
29
+ /** The call that only reads ahead. What it has read stays read when another call ends it. */
30
+ ahead;
31
+ clock;
32
+ next = 0;
33
+ /** The folder of the model in memory. */
34
+ model;
35
+ constructor(bin = mlxBin, idle = IDLE_MS) {
36
+ this.bin = bin;
37
+ this.idle = idle;
38
+ }
39
+ start() {
40
+ if (this.child) {
41
+ return this.child;
42
+ }
43
+ const child = spawn(this.bin(), [], { stdio: ["pipe", "pipe", "pipe"] });
44
+ let stderr = "";
45
+ child.stderr.on("data", (data) => {
46
+ stderr = (stderr + data.toString()).slice(-2000);
47
+ });
48
+ createInterface({ input: child.stdout }).on("line", (line) => {
49
+ let chunk;
50
+ try {
51
+ chunk = JSON.parse(line);
52
+ }
53
+ catch {
54
+ return; // a line the library prints
55
+ }
56
+ this.calls.get(chunk.id)?.(chunk);
57
+ });
58
+ const gone = (why) => {
59
+ if (this.child !== child) {
60
+ return;
61
+ }
62
+ this.child = undefined;
63
+ this.model = undefined;
64
+ for (const [id, say] of [...this.calls]) {
65
+ say({ id, error: why });
66
+ }
67
+ };
68
+ child.on("error", (error) => gone(error.message));
69
+ child.on("close", (code, signal) => gone(stderr.trim().split("\n").pop() || `MLX ended (${signal ?? code}).`));
70
+ // The host ends without waiting for it; the helper ends with its stdin.
71
+ child.stdin.on("error", () => undefined);
72
+ child.unref();
73
+ for (const pipe of [child.stdin, child.stdout, child.stderr]) {
74
+ unref(pipe);
75
+ }
76
+ this.child = child;
77
+ return child;
78
+ }
79
+ write(body) {
80
+ this.start().stdin?.write(`${JSON.stringify(body)}\n`);
81
+ }
82
+ rest() {
83
+ clearTimeout(this.clock);
84
+ if (this.calls.size === 0) {
85
+ // Nothing is read any more: the pipe no longer keeps the host alive.
86
+ unref(this.child?.stdout);
87
+ this.clock = setTimeout(() => this.stop(), this.idle);
88
+ this.clock.unref?.();
89
+ }
90
+ }
91
+ /** Ends the helper and frees the memory of its model. */
92
+ stop() {
93
+ clearTimeout(this.clock);
94
+ this.child?.stdin?.end();
95
+ this.child?.kill();
96
+ }
97
+ /** One call: what the model says as it says it. */
98
+ chat(chat, signal) {
99
+ const id = String(++this.next);
100
+ clearTimeout(this.clock);
101
+ const over = () => {
102
+ this.calls.delete(id);
103
+ if (this.ahead === id) {
104
+ this.ahead = undefined;
105
+ }
106
+ signal?.removeEventListener("abort", abort);
107
+ this.rest();
108
+ };
109
+ let fail = () => undefined;
110
+ // The caller hears it at once; the helper ends the call at its next token.
111
+ const abort = () => {
112
+ this.write({ id, cancel: true });
113
+ over();
114
+ fail(signal?.reason);
115
+ };
116
+ return new ReadableStream({
117
+ start: (controller) => {
118
+ if (signal?.aborted) {
119
+ return controller.error(signal.reason);
120
+ }
121
+ // A pipe that is being read keeps the host alive for the answer.
122
+ this.start().stdout.ref?.();
123
+ this.calls.set(id, (chunk) => {
124
+ if (chunk.error || chunk.done) {
125
+ over();
126
+ }
127
+ controller.enqueue(chunk);
128
+ if (chunk.error || chunk.done) {
129
+ controller.close();
130
+ }
131
+ });
132
+ fail = (reason) => controller.error(reason);
133
+ signal?.addEventListener("abort", abort, { once: true });
134
+ this.model = chat.model;
135
+ if (this.ahead !== undefined) {
136
+ this.write({ id: this.ahead, cancel: true });
137
+ }
138
+ this.ahead = chat.warm ? id : undefined;
139
+ this.write({ id, chat });
140
+ },
141
+ cancel: () => {
142
+ this.write({ id, cancel: true });
143
+ over();
144
+ },
145
+ });
146
+ }
147
+ }
148
+ /** This process's helper. */
149
+ export const helper = new Helper();
@@ -0,0 +1,3 @@
1
+ export { Helper, type HelperChunk, helper, mlxBin, mlxSupported, type Waiting, } from "./helper.js";
2
+ export { mlx, mlxModel } from "./server.js";
3
+ export { downloadModel, mlxFolder, mlxModels, modelFolder, removeModel } from "./store.js";
@@ -0,0 +1,3 @@
1
+ export { Helper, helper, mlxBin, mlxSupported, } from "./helper.js";
2
+ export { mlx, mlxModel } from "./server.js";
3
+ export { downloadModel, mlxFolder, mlxModels, modelFolder, removeModel } from "./store.js";
@@ -0,0 +1,19 @@
1
+ import { type ChatModel } from "../ollama/model.js";
2
+ import type { LocalServer } from "../servers/server.js";
3
+ import { type Waiting } from "./helper.js";
4
+ /** Apple's MLX as one of the servers on a computer; its address is the folder of its models. */
5
+ export declare const mlx: LocalServer;
6
+ /** A model of MLX as an AI SDK language model. It loads at its first call. */
7
+ export declare function mlxModel({ folder, model, tools, thinking, warm, onWaiting, }: {
8
+ folder: string;
9
+ model: string;
10
+ tools?: boolean;
11
+ thinking?: boolean;
12
+ /**
13
+ * Loads the model and reads the prompt up to its last message, and answers nothing: a call that
14
+ * starts with the same then starts to answer at once.
15
+ */
16
+ warm?: boolean;
17
+ /** What a call waits for before its first word; null once it begins to answer or calls a tool. */
18
+ onWaiting?: (waiting: Waiting | null) => void;
19
+ }): ChatModel;
@@ -0,0 +1,82 @@
1
+ import { ollamaModel } from "../ollama/model.js";
2
+ import { helper, mlxSupported } from "./helper.js";
3
+ import { downloadModel, mlxFolder, mlxModels, modelFolder, removeModel } from "./store.js";
4
+ /** Apple's MLX as one of the servers on a computer; its address is the folder of its models. */
5
+ export const mlx = {
6
+ id: "mlx",
7
+ name: "Apple MLX",
8
+ address: mlxFolder,
9
+ async state(folder) {
10
+ const running = mlxSupported();
11
+ const models = running ? (await mlxModels(folder)).map((m) => m.name) : [];
12
+ return { running, version: null, models, trouble: null };
13
+ },
14
+ models: (folder) => (mlxSupported() ? mlxModels(folder, helper.model) : Promise.resolve([])),
15
+ download: downloadModel,
16
+ async remove(folder, model) {
17
+ if (helper.model === modelFolder(folder, model)) {
18
+ helper.stop();
19
+ }
20
+ await removeModel(folder, model);
21
+ },
22
+ async ask(folder, model, prompt, { signal } = {}) {
23
+ const chat = mlxModel({
24
+ folder,
25
+ model: model.name,
26
+ ...(model.thinking ? { thinking: false } : {}),
27
+ });
28
+ const { content } = await chat.doGenerate({
29
+ prompt: [{ role: "user", content: [{ type: "text", text: prompt }] }],
30
+ maxOutputTokens: 16,
31
+ ...(signal ? { abortSignal: signal } : {}),
32
+ });
33
+ return content
34
+ .map((part) => (part.type === "text" ? part.text : ""))
35
+ .join("")
36
+ .trim();
37
+ },
38
+ };
39
+ /** A model of MLX as an AI SDK language model. It loads at its first call. */
40
+ export function mlxModel({ folder, model, tools, thinking, warm, onWaiting, }) {
41
+ const dir = modelFolder(folder, model);
42
+ // The helper speaks the shape of Ollama's chat API.
43
+ const answer = async (_url, init) => {
44
+ const { format, stream: _stream, model: _model, ...body } = JSON.parse(String(init?.body));
45
+ const schema = format === undefined
46
+ ? {}
47
+ : { schema: JSON.stringify(format === "json" ? { type: "object" } : format) };
48
+ const encoder = new TextEncoder();
49
+ let waits;
50
+ const lines = helper
51
+ .chat({ ...body, ...schema, ...(warm ? { warm } : {}), model: dir }, init?.signal ?? undefined)
52
+ .pipeThrough(new TransformStream({
53
+ transform: (chunk, controller) => {
54
+ if (chunk.wait) {
55
+ waits = chunk.wait.state;
56
+ onWaiting?.(chunk.wait);
57
+ return;
58
+ }
59
+ if (chunk.message?.thinking) {
60
+ if (waits !== "thinking") {
61
+ waits = "thinking";
62
+ onWaiting?.({ state: "thinking" });
63
+ }
64
+ }
65
+ else if (waits) {
66
+ waits = undefined;
67
+ onWaiting?.(null);
68
+ }
69
+ controller.enqueue(encoder.encode(`${JSON.stringify(chunk)}\n`));
70
+ },
71
+ }));
72
+ return new Response(lines);
73
+ };
74
+ return ollamaModel({
75
+ provider: "mlx",
76
+ url: "http://mlx",
77
+ model,
78
+ ...(tools === undefined ? {} : { tools }),
79
+ ...(thinking === undefined ? {} : { thinking }),
80
+ fetch: answer,
81
+ });
82
+ }
@@ -0,0 +1,16 @@
1
+ import type { InstalledModel, ServerOptions } from "../servers/server.js";
2
+ /** Where the models are for this process: MLX_MODELS, else a folder of engenty's. */
3
+ export declare function mlxFolder(env?: NodeJS.ProcessEnv): string;
4
+ export declare function modelFolder(root: string, model: string): string;
5
+ /** The models in the folder, each with what it can do. */
6
+ export declare function mlxModels(root: string, loaded?: string): Promise<InstalledModel[]>;
7
+ /**
8
+ * Downloads a model from Hugging Face. A download that broke off goes on where it stopped; each
9
+ * weights file is checked against the hash Hugging Face names.
10
+ */
11
+ export declare function downloadModel(root: string, model: string, onProgress: (done: number, total: number) => void, { fetch: doFetch, signal, hub, }?: ServerOptions & {
12
+ signal?: AbortSignal;
13
+ hub?: string;
14
+ }): Promise<void>;
15
+ /** Removes a model and what its folder held. */
16
+ export declare function removeModel(root: string, model: string): Promise<void>;