aicodeman 1.49.0 → 1.50.1

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 (324) hide show
  1. package/README.md +30 -4
  2. package/dist/cli-install-runner.d.ts +112 -0
  3. package/dist/cli-install-runner.d.ts.map +1 -0
  4. package/dist/cli-install-runner.js +289 -0
  5. package/dist/cli-install-runner.js.map +1 -0
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +2 -2
  8. package/dist/cli.js.map +1 -1
  9. package/dist/config/attachment-guard.d.ts +11 -0
  10. package/dist/config/attachment-guard.d.ts.map +1 -1
  11. package/dist/config/attachment-guard.js +21 -1
  12. package/dist/config/attachment-guard.js.map +1 -1
  13. package/dist/config/local-model-catalog.d.ts +188 -0
  14. package/dist/config/local-model-catalog.d.ts.map +1 -0
  15. package/dist/config/local-model-catalog.js +556 -0
  16. package/dist/config/local-model-catalog.js.map +1 -0
  17. package/dist/config-backup.js +1 -1
  18. package/dist/config-backup.js.map +1 -1
  19. package/dist/custom-model-hosts-writer.d.ts +50 -0
  20. package/dist/custom-model-hosts-writer.d.ts.map +1 -0
  21. package/dist/custom-model-hosts-writer.js +110 -0
  22. package/dist/custom-model-hosts-writer.js.map +1 -0
  23. package/dist/git-clone.d.ts.map +1 -1
  24. package/dist/git-clone.js +21 -1
  25. package/dist/git-clone.js.map +1 -1
  26. package/dist/git-fetch.d.ts.map +1 -1
  27. package/dist/git-fetch.js +6 -0
  28. package/dist/git-fetch.js.map +1 -1
  29. package/dist/git-workspace-status.d.ts.map +1 -1
  30. package/dist/git-workspace-status.js +4 -0
  31. package/dist/git-workspace-status.js.map +1 -1
  32. package/dist/git-worktrees.d.ts.map +1 -1
  33. package/dist/git-worktrees.js +6 -0
  34. package/dist/git-worktrees.js.map +1 -1
  35. package/dist/hooks-config.d.ts +15 -3
  36. package/dist/hooks-config.d.ts.map +1 -1
  37. package/dist/hooks-config.js +108 -4
  38. package/dist/hooks-config.js.map +1 -1
  39. package/dist/live-worktree.d.ts +73 -15
  40. package/dist/live-worktree.d.ts.map +1 -1
  41. package/dist/live-worktree.js +200 -32
  42. package/dist/live-worktree.js.map +1 -1
  43. package/dist/local-model/connect.d.ts +155 -0
  44. package/dist/local-model/connect.d.ts.map +1 -0
  45. package/dist/local-model/connect.js +243 -0
  46. package/dist/local-model/connect.js.map +1 -0
  47. package/dist/local-model/developer-tools.d.ts +45 -0
  48. package/dist/local-model/developer-tools.d.ts.map +1 -0
  49. package/dist/local-model/developer-tools.js +105 -0
  50. package/dist/local-model/developer-tools.js.map +1 -0
  51. package/dist/local-model/format.d.ts +39 -0
  52. package/dist/local-model/format.d.ts.map +1 -0
  53. package/dist/local-model/format.js +48 -0
  54. package/dist/local-model/format.js.map +1 -0
  55. package/dist/local-model/hardware.d.ts +125 -0
  56. package/dist/local-model/hardware.d.ts.map +1 -0
  57. package/dist/local-model/hardware.js +336 -0
  58. package/dist/local-model/hardware.js.map +1 -0
  59. package/dist/local-model/harness-facts.d.ts +77 -0
  60. package/dist/local-model/harness-facts.d.ts.map +1 -0
  61. package/dist/local-model/harness-facts.js +145 -0
  62. package/dist/local-model/harness-facts.js.map +1 -0
  63. package/dist/local-model/install-job.d.ts +431 -0
  64. package/dist/local-model/install-job.d.ts.map +1 -0
  65. package/dist/local-model/install-job.js +1822 -0
  66. package/dist/local-model/install-job.js.map +1 -0
  67. package/dist/local-model/ollama-client.d.ts +216 -0
  68. package/dist/local-model/ollama-client.d.ts.map +1 -0
  69. package/dist/local-model/ollama-client.js +636 -0
  70. package/dist/local-model/ollama-client.js.map +1 -0
  71. package/dist/local-model/paths.d.ts +64 -0
  72. package/dist/local-model/paths.d.ts.map +1 -0
  73. package/dist/local-model/paths.js +75 -0
  74. package/dist/local-model/paths.js.map +1 -0
  75. package/dist/local-model/recommend.d.ts +118 -0
  76. package/dist/local-model/recommend.d.ts.map +1 -0
  77. package/dist/local-model/recommend.js +430 -0
  78. package/dist/local-model/recommend.js.map +1 -0
  79. package/dist/local-model/runtime.d.ts +339 -0
  80. package/dist/local-model/runtime.d.ts.map +1 -0
  81. package/dist/local-model/runtime.js +1240 -0
  82. package/dist/local-model/runtime.js.map +1 -0
  83. package/dist/local-model/state-store.d.ts +45 -0
  84. package/dist/local-model/state-store.d.ts.map +1 -0
  85. package/dist/local-model/state-store.js +261 -0
  86. package/dist/local-model/state-store.js.map +1 -0
  87. package/dist/readmymind-collectors.d.ts.map +1 -1
  88. package/dist/readmymind-collectors.js +4 -0
  89. package/dist/readmymind-collectors.js.map +1 -1
  90. package/dist/reboot-restore.d.ts +3 -1
  91. package/dist/reboot-restore.d.ts.map +1 -1
  92. package/dist/reboot-restore.js.map +1 -1
  93. package/dist/session.d.ts +29 -7
  94. package/dist/session.d.ts.map +1 -1
  95. package/dist/session.js +63 -10
  96. package/dist/session.js.map +1 -1
  97. package/dist/types/common.d.ts +5 -0
  98. package/dist/types/common.d.ts.map +1 -1
  99. package/dist/types/index.d.ts +4 -0
  100. package/dist/types/index.d.ts.map +1 -1
  101. package/dist/types/index.js +4 -0
  102. package/dist/types/index.js.map +1 -1
  103. package/dist/types/local-model-install.d.ts +533 -0
  104. package/dist/types/local-model-install.d.ts.map +1 -0
  105. package/dist/types/local-model-install.js +169 -0
  106. package/dist/types/local-model-install.js.map +1 -0
  107. package/dist/types/local-model.d.ts +551 -0
  108. package/dist/types/local-model.d.ts.map +1 -0
  109. package/dist/types/local-model.js +115 -0
  110. package/dist/types/local-model.js.map +1 -0
  111. package/dist/types/session.d.ts +17 -6
  112. package/dist/types/session.d.ts.map +1 -1
  113. package/dist/types/session.js.map +1 -1
  114. package/dist/utils/cli-executable-resolver.d.ts +18 -0
  115. package/dist/utils/cli-executable-resolver.d.ts.map +1 -1
  116. package/dist/utils/cli-executable-resolver.js +34 -2
  117. package/dist/utils/cli-executable-resolver.js.map +1 -1
  118. package/dist/utils/git-availability.d.ts +65 -0
  119. package/dist/utils/git-availability.d.ts.map +1 -0
  120. package/dist/utils/git-availability.js +134 -0
  121. package/dist/utils/git-availability.js.map +1 -0
  122. package/dist/web/agent-skill-default-migration.d.ts +60 -0
  123. package/dist/web/agent-skill-default-migration.d.ts.map +1 -0
  124. package/dist/web/agent-skill-default-migration.js +97 -0
  125. package/dist/web/agent-skill-default-migration.js.map +1 -0
  126. package/dist/web/approval-inbox.d.ts +10 -0
  127. package/dist/web/approval-inbox.d.ts.map +1 -1
  128. package/dist/web/approval-inbox.js +15 -0
  129. package/dist/web/approval-inbox.js.map +1 -1
  130. package/dist/web/case-state-sync.d.ts +28 -0
  131. package/dist/web/case-state-sync.d.ts.map +1 -0
  132. package/dist/web/case-state-sync.js +41 -0
  133. package/dist/web/case-state-sync.js.map +1 -0
  134. package/dist/web/ports/config-port.d.ts +1 -1
  135. package/dist/web/ports/config-port.d.ts.map +1 -1
  136. package/dist/web/public/admin-ui.js.gz +0 -0
  137. package/dist/web/public/api-client.c9b1cddc.js.gz +0 -0
  138. package/dist/web/public/{app.9ea37070.js → app.07398d90.js} +1 -1
  139. package/dist/web/public/app.07398d90.js.br +0 -0
  140. package/dist/web/public/app.07398d90.js.gz +0 -0
  141. package/dist/web/public/approvals-ui.js.gz +0 -0
  142. package/dist/web/public/constants.782170e1.js.gz +0 -0
  143. package/dist/web/public/cron-ui.js.gz +0 -0
  144. package/dist/web/public/edit-history-ui.js.gz +0 -0
  145. package/dist/web/public/entrance-animations.js.gz +0 -0
  146. package/dist/web/public/foreign-sessions.js.gz +0 -0
  147. package/dist/web/public/git-status-ui.js.gz +0 -0
  148. package/dist/web/public/header-divider.eb2d2463.js.gz +0 -0
  149. package/dist/web/public/home-sessions.js +38 -18
  150. package/dist/web/public/home-sessions.js.br +0 -0
  151. package/dist/web/public/home-sessions.js.gz +0 -0
  152. package/dist/web/public/host-wake-ui.js.gz +0 -0
  153. package/dist/web/public/{i18n.a5e82c95.js → i18n.519d025e.js} +2 -2
  154. package/dist/web/public/i18n.519d025e.js.br +0 -0
  155. package/dist/web/public/i18n.519d025e.js.gz +0 -0
  156. package/dist/web/public/image-input.a5d0f8f3.js.gz +0 -0
  157. package/dist/web/public/index.html +88 -13
  158. package/dist/web/public/index.html.br +0 -0
  159. package/dist/web/public/index.html.gz +0 -0
  160. package/dist/web/public/input-cjk.8bc46081.js.gz +0 -0
  161. package/dist/web/public/{keyboard-accessory.b941676c.js → keyboard-accessory.0800fc44.js} +160 -2
  162. package/dist/web/public/keyboard-accessory.0800fc44.js.br +0 -0
  163. package/dist/web/public/keyboard-accessory.0800fc44.js.gz +0 -0
  164. package/dist/web/public/local-model-ui.js +1735 -0
  165. package/dist/web/public/local-model-ui.js.br +0 -0
  166. package/dist/web/public/local-model-ui.js.gz +0 -0
  167. package/dist/web/public/mobile-handlers.f7c3f692.js.gz +0 -0
  168. package/dist/web/public/mobile-ime-preview.2dbaf262.js.gz +0 -0
  169. package/dist/web/public/mobile-overview.js +30 -14
  170. package/dist/web/public/mobile-overview.js.br +0 -0
  171. package/dist/web/public/mobile-overview.js.gz +0 -0
  172. package/dist/web/public/mobile.4dfd5c55.css +1 -0
  173. package/dist/web/public/mobile.4dfd5c55.css.br +0 -0
  174. package/dist/web/public/mobile.4dfd5c55.css.gz +0 -0
  175. package/dist/web/public/notification-manager.feb82c04.js.gz +0 -0
  176. package/dist/web/public/orchestrator-panel.js.gz +0 -0
  177. package/dist/web/public/{panels-ui.8bcd4473.js → panels-ui.9ba2683e.js} +100 -98
  178. package/dist/web/public/panels-ui.9ba2683e.js.br +0 -0
  179. package/dist/web/public/panels-ui.9ba2683e.js.gz +0 -0
  180. package/dist/web/public/ralph-panel.b350e2ef.js.gz +0 -0
  181. package/dist/web/public/ralph-wizard.b6c0dd19.js.gz +0 -0
  182. package/dist/web/public/readmymind-ui.js.gz +0 -0
  183. package/dist/web/public/reboot-restore-ui.js +2 -0
  184. package/dist/web/public/reboot-restore-ui.js.br +0 -0
  185. package/dist/web/public/reboot-restore-ui.js.gz +0 -0
  186. package/dist/web/public/respawn-ui.304ba0d4.js.gz +0 -0
  187. package/dist/web/public/sanitize-html.e7147e76.js.gz +0 -0
  188. package/dist/web/public/session-lineage.js.gz +0 -0
  189. package/dist/web/public/{session-ui.a7c8c095.js → session-ui.8f300b14.js} +21 -21
  190. package/dist/web/public/session-ui.8f300b14.js.br +0 -0
  191. package/dist/web/public/session-ui.8f300b14.js.gz +0 -0
  192. package/dist/web/public/{settings-ui.18f92052.js → settings-ui.8b37cf07.js} +14 -14
  193. package/dist/web/public/settings-ui.8b37cf07.js.br +0 -0
  194. package/dist/web/public/settings-ui.8b37cf07.js.gz +0 -0
  195. package/dist/web/public/spreadsheet-preview-worker.js.gz +0 -0
  196. package/dist/web/public/spreadsheet-preview.75c751de.js.gz +0 -0
  197. package/dist/web/public/spreadsheet-xlsx-core.js.gz +0 -0
  198. package/dist/web/public/styles.21b93520.css +1 -0
  199. package/dist/web/public/styles.21b93520.css.br +0 -0
  200. package/dist/web/public/styles.21b93520.css.gz +0 -0
  201. package/dist/web/public/subagent-windows.07277a58.js.gz +0 -0
  202. package/dist/web/public/sw.js +2 -2
  203. package/dist/web/public/sw.js.br +0 -0
  204. package/dist/web/public/sw.js.gz +0 -0
  205. package/dist/web/public/tab-layout-browser.2d6189f7.js.gz +0 -0
  206. package/dist/web/public/tab-rail-resize.b5cdceaf.js.gz +0 -0
  207. package/dist/web/public/terminal-keycode229-recovery.98843069.js.gz +0 -0
  208. package/dist/web/public/terminal-split.js.gz +0 -0
  209. package/dist/web/public/terminal-tile.js.gz +0 -0
  210. package/dist/web/public/{terminal-ui.a7883640.js → terminal-ui.f92eae28.js} +2 -2
  211. package/dist/web/public/terminal-ui.f92eae28.js.br +0 -0
  212. package/dist/web/public/terminal-ui.f92eae28.js.gz +0 -0
  213. package/dist/web/public/tile-grid.js.gz +0 -0
  214. package/dist/web/public/ultracode-panel.js.gz +0 -0
  215. package/dist/web/public/ultracode-windows.js.gz +0 -0
  216. package/dist/web/public/vendor/dompurify.min.js.gz +0 -0
  217. package/dist/web/public/vendor/exceljs.min.js.gz +0 -0
  218. package/dist/web/public/vendor/fflate.min.js.gz +0 -0
  219. package/dist/web/public/vendor/marked.min.js.gz +0 -0
  220. package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
  221. package/dist/web/public/vendor/xterm-addon-serialize.min.js.gz +0 -0
  222. package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
  223. package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
  224. package/dist/web/public/vendor/xterm-predictive-echo.276b11d9.js.gz +0 -0
  225. package/dist/web/public/vendor/xterm-zerolag-input.1be42307.js.gz +0 -0
  226. package/dist/web/public/vendor/xterm.css.gz +0 -0
  227. package/dist/web/public/vendor/xterm.min.js.gz +0 -0
  228. package/dist/web/public/{voice-input.2342c37b.js → voice-input.d0580528.js} +232 -137
  229. package/dist/web/public/voice-input.d0580528.js.br +0 -0
  230. package/dist/web/public/voice-input.d0580528.js.gz +0 -0
  231. package/dist/web/public/voice-pcm-worklet.js.gz +0 -0
  232. package/dist/web/public/webview-tabs.js.gz +0 -0
  233. package/dist/web/public/whats-new.json +9 -9
  234. package/dist/web/repo-status.d.ts.map +1 -1
  235. package/dist/web/repo-status.js +4 -0
  236. package/dist/web/repo-status.js.map +1 -1
  237. package/dist/web/route-helpers.d.ts +29 -0
  238. package/dist/web/route-helpers.d.ts.map +1 -1
  239. package/dist/web/route-helpers.js +37 -0
  240. package/dist/web/route-helpers.js.map +1 -1
  241. package/dist/web/routes/approval-routes.d.ts.map +1 -1
  242. package/dist/web/routes/approval-routes.js +3 -2
  243. package/dist/web/routes/approval-routes.js.map +1 -1
  244. package/dist/web/routes/case-routes.d.ts.map +1 -1
  245. package/dist/web/routes/case-routes.js +31 -5
  246. package/dist/web/routes/case-routes.js.map +1 -1
  247. package/dist/web/routes/cli-registry-routes.d.ts +1 -27
  248. package/dist/web/routes/cli-registry-routes.d.ts.map +1 -1
  249. package/dist/web/routes/cli-registry-routes.js +11 -202
  250. package/dist/web/routes/cli-registry-routes.js.map +1 -1
  251. package/dist/web/routes/custom-model-routes.d.ts +15 -0
  252. package/dist/web/routes/custom-model-routes.d.ts.map +1 -1
  253. package/dist/web/routes/custom-model-routes.js +114 -33
  254. package/dist/web/routes/custom-model-routes.js.map +1 -1
  255. package/dist/web/routes/file-routes.d.ts +4 -2
  256. package/dist/web/routes/file-routes.d.ts.map +1 -1
  257. package/dist/web/routes/file-routes.js +160 -24
  258. package/dist/web/routes/file-routes.js.map +1 -1
  259. package/dist/web/routes/html-view-routes.d.ts.map +1 -1
  260. package/dist/web/routes/html-view-routes.js +12 -3
  261. package/dist/web/routes/html-view-routes.js.map +1 -1
  262. package/dist/web/routes/index.d.ts +1 -0
  263. package/dist/web/routes/index.d.ts.map +1 -1
  264. package/dist/web/routes/index.js +1 -0
  265. package/dist/web/routes/index.js.map +1 -1
  266. package/dist/web/routes/local-model-routes.d.ts +103 -0
  267. package/dist/web/routes/local-model-routes.d.ts.map +1 -0
  268. package/dist/web/routes/local-model-routes.js +210 -0
  269. package/dist/web/routes/local-model-routes.js.map +1 -0
  270. package/dist/web/routes/reboot-restore-routes.d.ts.map +1 -1
  271. package/dist/web/routes/reboot-restore-routes.js +16 -0
  272. package/dist/web/routes/reboot-restore-routes.js.map +1 -1
  273. package/dist/web/routes/session-routes.d.ts.map +1 -1
  274. package/dist/web/routes/session-routes.js +22 -27
  275. package/dist/web/routes/session-routes.js.map +1 -1
  276. package/dist/web/routes/system-routes.d.ts +2 -2
  277. package/dist/web/routes/system-routes.d.ts.map +1 -1
  278. package/dist/web/routes/system-routes.js +23 -4
  279. package/dist/web/routes/system-routes.js.map +1 -1
  280. package/dist/web/schemas.d.ts +30 -0
  281. package/dist/web/schemas.d.ts.map +1 -1
  282. package/dist/web/schemas.js +52 -5
  283. package/dist/web/schemas.js.map +1 -1
  284. package/dist/web/self-update.d.ts.map +1 -1
  285. package/dist/web/self-update.js +4 -0
  286. package/dist/web/self-update.js.map +1 -1
  287. package/dist/web/sensitive-path.d.ts.map +1 -1
  288. package/dist/web/sensitive-path.js +5 -0
  289. package/dist/web/sensitive-path.js.map +1 -1
  290. package/dist/web/server.d.ts +20 -0
  291. package/dist/web/server.d.ts.map +1 -1
  292. package/dist/web/server.js +83 -7
  293. package/dist/web/server.js.map +1 -1
  294. package/dist/web/voice-stream.d.ts +4 -3
  295. package/dist/web/voice-stream.d.ts.map +1 -1
  296. package/dist/web/voice-stream.js +5 -4
  297. package/dist/web/voice-stream.js.map +1 -1
  298. package/package.json +2 -1
  299. package/skills/codeman/SKILL.md +318 -24
  300. package/skills/codeman/preamble.sh +242 -16
  301. package/skills/codeman/reference/recipes.md +1 -1
  302. package/skills/codeman/reference/verbs.md +101 -1
  303. package/dist/web/public/app.9ea37070.js.br +0 -0
  304. package/dist/web/public/app.9ea37070.js.gz +0 -0
  305. package/dist/web/public/i18n.a5e82c95.js.br +0 -0
  306. package/dist/web/public/i18n.a5e82c95.js.gz +0 -0
  307. package/dist/web/public/keyboard-accessory.b941676c.js.br +0 -0
  308. package/dist/web/public/keyboard-accessory.b941676c.js.gz +0 -0
  309. package/dist/web/public/mobile.67c8eb5b.css +0 -1
  310. package/dist/web/public/mobile.67c8eb5b.css.br +0 -0
  311. package/dist/web/public/mobile.67c8eb5b.css.gz +0 -0
  312. package/dist/web/public/panels-ui.8bcd4473.js.br +0 -0
  313. package/dist/web/public/panels-ui.8bcd4473.js.gz +0 -0
  314. package/dist/web/public/session-ui.a7c8c095.js.br +0 -0
  315. package/dist/web/public/session-ui.a7c8c095.js.gz +0 -0
  316. package/dist/web/public/settings-ui.18f92052.js.br +0 -0
  317. package/dist/web/public/settings-ui.18f92052.js.gz +0 -0
  318. package/dist/web/public/styles.6a718331.css +0 -1
  319. package/dist/web/public/styles.6a718331.css.br +0 -0
  320. package/dist/web/public/styles.6a718331.css.gz +0 -0
  321. package/dist/web/public/terminal-ui.a7883640.js.br +0 -0
  322. package/dist/web/public/terminal-ui.a7883640.js.gz +0 -0
  323. package/dist/web/public/voice-input.2342c37b.js.br +0 -0
  324. package/dist/web/public/voice-input.2342c37b.js.gz +0 -0
@@ -0,0 +1,155 @@
1
+ /**
2
+ * @fileoverview Connecting the installed local model to Codeman, and undoing it: the endpoint
3
+ * record, the settings flag, and the checks around them.
4
+ *
5
+ * These are the ONLY two writes of the local model outside its own folder:
6
+ * 1. One record in `custom-model-hosts.json`, through `mutateCustomModelHosts()`:
7
+ * `{ id: 'local-ollama', label: 'This Mac', baseUrl: 'http://127.0.0.1:<port>',
8
+ * authStyle: 'bearer', models: [<id as /v1/models lists it>], defaultModelId,
9
+ * defaultContextLength: <the chosen context> }`, validated by `CustomModelHostSchema`
10
+ * before it is written. No `apiKey`. `defaultContextLength` is what reaches the coding
11
+ * agent as its context limit, because the runtime's model listing states none.
12
+ * 2. `customModelEndpointsEnabled: true` in `settings.json`, through `mutateSettingsFile()`.
13
+ * The value it had before is returned and kept in the state file.
14
+ *
15
+ * Rules:
16
+ * - The id is reserved. A record with it that this feature did not write is never
17
+ * overwritten: the connect step fails with `endpoint-id-taken`.
18
+ * - The connection is CLAIMED before it is written: the install job records `connection` in
19
+ * the state file first (`inspectLocalEndpoint()` tells it what is there and what the flag
20
+ * is), then calls `connectLocalModel()` with `ours: true`. A state write that fails, or a
21
+ * server that is killed between the two, therefore never leaves a record of ours that the
22
+ * state file does not know: the worst case is a claim with nothing behind it, which a
23
+ * resumed job fills in and Remove undoes.
24
+ * - Second net: a record with the reserved id that already says exactly what ours would say
25
+ * (`isSameLocalEndpoint()`) is ours whatever `ours` says. Nobody else can have made it: the
26
+ * endpoint routes refuse the reserved id.
27
+ * - Both writes are idempotent, so a resumed job writes them again.
28
+ * - Undoing removes our record, and switches the flag off again only when this feature
29
+ * switched it on AND no other endpoint is saved.
30
+ * - The model's digest is compared again before a session starts and at boot
31
+ * (`compareModelDigest()`): a model that changed under the same name is not launched.
32
+ * - The record is MANAGED while the state file records it as ours (`isManagedLocalEndpoint()`):
33
+ * the endpoint routes then refuse to edit or delete it and the discovery sweep leaves it
34
+ * alone, so its `models` stays the one model the install job checked.
35
+ */
36
+ import type { CustomModelHost } from '../custom-model-hosts.js';
37
+ import { type LocalModelErrorCode } from '../types.js';
38
+ /** The id of the endpoint record this feature writes. Reserved: nobody else may use it. */
39
+ export declare const LOCAL_MODEL_ENDPOINT_ID = "local-ollama";
40
+ /** The label of that record, what the Run menu shows in brackets. */
41
+ export declare const LOCAL_MODEL_ENDPOINT_LABEL = "This Mac";
42
+ /** What the endpoint record is built from. */
43
+ export interface LocalEndpointInput {
44
+ /** The runtime's loopback port. */
45
+ port: number;
46
+ /** The model id exactly as the runtime's `/v1/models` lists it. */
47
+ modelId: string;
48
+ /** The chosen context length in tokens. */
49
+ context: number;
50
+ }
51
+ /** The endpoint record of the file header. Pure; the caller validates it with `CustomModelHostSchema`. */
52
+ export declare function buildLocalEndpointRecord(input: LocalEndpointInput): CustomModelHost;
53
+ /**
54
+ * Whether a saved record says exactly what our record for `input` says: the same address, the
55
+ * one model, its context, no key. What discovery may have added to it (context lengths, a
56
+ * time stamp) does not count. Pure.
57
+ */
58
+ export declare function isSameLocalEndpoint(host: CustomModelHost, input: LocalEndpointInput): boolean;
59
+ /** What the connect step finds before it claims the connection. */
60
+ export interface LocalEndpointInspection {
61
+ /**
62
+ * The saved record with the reserved id: there is none, it says what ours would say, or it
63
+ * says something else (somebody else's: `endpoint-id-taken`).
64
+ */
65
+ record: 'absent' | 'same' | 'other';
66
+ /** `customModelEndpointsEnabled` right now: what the claim keeps as the value before this feature. */
67
+ flagEnabled: boolean;
68
+ }
69
+ /**
70
+ * Looks at the endpoint store and the settings flag WITHOUT writing either. The install job
71
+ * calls it before it claims the connection in the state file. Rejects when the endpoint store
72
+ * cannot be read; a settings file that cannot be read counts as "the flag is off".
73
+ */
74
+ export declare function inspectLocalEndpoint(input: LocalEndpointInput): Promise<LocalEndpointInspection>;
75
+ export interface ConnectLocalModelInput extends LocalEndpointInput {
76
+ /**
77
+ * True when the state file already records a connection of ours: an existing record with
78
+ * our id is then ours and is replaced. False: such a record is somebody else's, unless it
79
+ * says exactly what ours would say (`isSameLocalEndpoint()`).
80
+ */
81
+ ours: boolean;
82
+ /**
83
+ * The flag's value before this feature first switched it on, when the state file already
84
+ * holds one. It is handed back unchanged, so a second connect cannot overwrite it with `true`.
85
+ */
86
+ flagWasEnabled?: boolean;
87
+ }
88
+ /** How the connect step ended. */
89
+ export type ConnectResult = {
90
+ ok: true;
91
+ /** The value `customModelEndpointsEnabled` had before this feature switched it on. */
92
+ flagWasEnabled: boolean;
93
+ } | {
94
+ ok: false;
95
+ code: Extract<LocalModelErrorCode, 'endpoint-id-taken' | 'connect-failed'>;
96
+ detail?: string;
97
+ };
98
+ /**
99
+ * Writes the record and the flag. Idempotent. Never throws: a refused write is `connect-failed`
100
+ * with its message as `detail`.
101
+ *
102
+ * The record goes first, with the "is the id free" check in the same serialized step as the
103
+ * write, so a record that is somebody else's is found before anything is changed. Should the
104
+ * flag then fail to save, a record this call ADDED is taken out again: the pair is never left
105
+ * half done, and a later attempt starts from the same place.
106
+ */
107
+ export declare function connectLocalModel(input: ConnectLocalModelInput): Promise<ConnectResult>;
108
+ /**
109
+ * Puts our record back when it is gone, and does nothing when a record with our id exists
110
+ * (it is never replaced here). For the start of the server while a model is installed: a
111
+ * config-backup restore can bring back an older endpoint store without our record while the
112
+ * model, the runtime and the state file stay. The settings flag is NOT touched: a person who
113
+ * switched it off meant to. Resolves true when the record was added. Never throws.
114
+ */
115
+ export declare function ensureLocalEndpoint(input: LocalEndpointInput): Promise<boolean>;
116
+ /**
117
+ * Moves our record to another port (the answer to "Use another port" once connected). A
118
+ * missing record is not an error, and a record that is already there is not written again.
119
+ */
120
+ export declare function moveLocalEndpoint(port: number): Promise<void>;
121
+ /**
122
+ * Removes our record, and restores the settings flag when this feature switched it on
123
+ * (`flagWasEnabled` is false) and no other endpoint is left. Idempotent.
124
+ */
125
+ export declare function disconnectLocalModel(input: {
126
+ flagWasEnabled: boolean;
127
+ }): Promise<void>;
128
+ /** Whether `id` is the reserved endpoint id. For the endpoint routes and the discovery sweep, which leave that record alone. */
129
+ export declare function isLocalModelEndpointId(id: string): boolean;
130
+ /**
131
+ * Whether the saved endpoint `id` is the record THIS feature wrote and still owns: the id is
132
+ * the reserved one and the state file records a connection under it. A record with the
133
+ * reserved id that somebody made by hand (before this feature, or while nothing is installed)
134
+ * is not managed, so its owner can still edit and delete it. Never throws.
135
+ */
136
+ export declare function isManagedLocalEndpoint(id: string): Promise<boolean>;
137
+ /**
138
+ * The names of the live sessions that use the endpoint `endpointId`, in the order given.
139
+ * Pure. What `DELETE /api/local-model` answers its 409 with.
140
+ */
141
+ export declare function sessionNamesUsingEndpoint(sessions: Iterable<{
142
+ name: string;
143
+ customModel?: {
144
+ endpointId: string;
145
+ };
146
+ }>, endpointId?: string): string[];
147
+ /**
148
+ * Compares the digest stored at install time with the one the runtime reports now. Pure.
149
+ * - `same`: launch.
150
+ * - `changed`: refuse (`model-changed`): the name now stands for other weights or another template.
151
+ * - `unknown`: one of the two is absent (the runtime does not answer, the model is gone).
152
+ * The caller refuses as well, with the reason it knows.
153
+ */
154
+ export declare function compareModelDigest(stored: string | undefined, current: string | undefined): 'same' | 'changed' | 'unknown';
155
+ //# sourceMappingURL=connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/local-model/connect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AASxE,2FAA2F;AAC3F,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AACtD,qEAAqE;AACrE,eAAO,MAAM,0BAA0B,aAAa,CAAC;AAErD,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,IAAI,EA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CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASnE;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAAE,cAAc,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAM5F;AAED,gIAAgI;AAChI,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAIzE;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,EAC1E,UAAU,GAAE,MAAgC,GAC3C,MAAM,EAAE,CAMV;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,MAAM,GAAG,SAAS,GAAG,SAAS,CAKhC"}
@@ -0,0 +1,243 @@
1
+ /**
2
+ * @fileoverview Connecting the installed local model to Codeman, and undoing it: the endpoint
3
+ * record, the settings flag, and the checks around them.
4
+ *
5
+ * These are the ONLY two writes of the local model outside its own folder:
6
+ * 1. One record in `custom-model-hosts.json`, through `mutateCustomModelHosts()`:
7
+ * `{ id: 'local-ollama', label: 'This Mac', baseUrl: 'http://127.0.0.1:<port>',
8
+ * authStyle: 'bearer', models: [<id as /v1/models lists it>], defaultModelId,
9
+ * defaultContextLength: <the chosen context> }`, validated by `CustomModelHostSchema`
10
+ * before it is written. No `apiKey`. `defaultContextLength` is what reaches the coding
11
+ * agent as its context limit, because the runtime's model listing states none.
12
+ * 2. `customModelEndpointsEnabled: true` in `settings.json`, through `mutateSettingsFile()`.
13
+ * The value it had before is returned and kept in the state file.
14
+ *
15
+ * Rules:
16
+ * - The id is reserved. A record with it that this feature did not write is never
17
+ * overwritten: the connect step fails with `endpoint-id-taken`.
18
+ * - The connection is CLAIMED before it is written: the install job records `connection` in
19
+ * the state file first (`inspectLocalEndpoint()` tells it what is there and what the flag
20
+ * is), then calls `connectLocalModel()` with `ours: true`. A state write that fails, or a
21
+ * server that is killed between the two, therefore never leaves a record of ours that the
22
+ * state file does not know: the worst case is a claim with nothing behind it, which a
23
+ * resumed job fills in and Remove undoes.
24
+ * - Second net: a record with the reserved id that already says exactly what ours would say
25
+ * (`isSameLocalEndpoint()`) is ours whatever `ours` says. Nobody else can have made it: the
26
+ * endpoint routes refuse the reserved id.
27
+ * - Both writes are idempotent, so a resumed job writes them again.
28
+ * - Undoing removes our record, and switches the flag off again only when this feature
29
+ * switched it on AND no other endpoint is saved.
30
+ * - The model's digest is compared again before a session starts and at boot
31
+ * (`compareModelDigest()`): a model that changed under the same name is not launched.
32
+ * - The record is MANAGED while the state file records it as ours (`isManagedLocalEndpoint()`):
33
+ * the endpoint routes then refuse to edit or delete it and the discovery sweep leaves it
34
+ * alone, so its `models` stays the one model the install job checked.
35
+ */
36
+ import { mutateCustomModelHosts } from '../custom-model-hosts-writer.js';
37
+ import { getDataDir } from '../config/instance.js';
38
+ import { readCustomModelHosts } from '../custom-model-hosts.js';
39
+ import { getErrorMessage } from '../types.js';
40
+ import { readJsonConfig, SETTINGS_PATH } from '../web/route-helpers.js';
41
+ import { CustomModelHostSchema } from '../web/schemas.js';
42
+ import { mutateSettingsFile } from '../web/settings-writer.js';
43
+ import { readLocalModelState } from './state-store.js';
44
+ /** The key of the settings flag that shows saved endpoints in the Run menu and runs the discovery sweep. */
45
+ const ENDPOINTS_FLAG = 'customModelEndpointsEnabled';
46
+ /** The id of the endpoint record this feature writes. Reserved: nobody else may use it. */
47
+ export const LOCAL_MODEL_ENDPOINT_ID = 'local-ollama';
48
+ /** The label of that record, what the Run menu shows in brackets. */
49
+ export const LOCAL_MODEL_ENDPOINT_LABEL = 'This Mac';
50
+ /** The endpoint record of the file header. Pure; the caller validates it with `CustomModelHostSchema`. */
51
+ export function buildLocalEndpointRecord(input) {
52
+ return {
53
+ id: LOCAL_MODEL_ENDPOINT_ID,
54
+ label: LOCAL_MODEL_ENDPOINT_LABEL,
55
+ baseUrl: `http://127.0.0.1:${input.port}`,
56
+ authStyle: 'bearer',
57
+ models: [input.modelId],
58
+ defaultModelId: input.modelId,
59
+ defaultContextLength: input.context,
60
+ };
61
+ }
62
+ /**
63
+ * Whether a saved record says exactly what our record for `input` says: the same address, the
64
+ * one model, its context, no key. What discovery may have added to it (context lengths, a
65
+ * time stamp) does not count. Pure.
66
+ */
67
+ export function isSameLocalEndpoint(host, input) {
68
+ const ours = buildLocalEndpointRecord(input);
69
+ return (host.id === ours.id &&
70
+ host.label === ours.label &&
71
+ host.baseUrl === ours.baseUrl &&
72
+ host.authStyle === ours.authStyle &&
73
+ host.apiKey === undefined &&
74
+ Array.isArray(host.models) &&
75
+ host.models.length === 1 &&
76
+ host.models[0] === input.modelId &&
77
+ host.defaultModelId === ours.defaultModelId &&
78
+ host.defaultContextLength === ours.defaultContextLength);
79
+ }
80
+ /**
81
+ * Looks at the endpoint store and the settings flag WITHOUT writing either. The install job
82
+ * calls it before it claims the connection in the state file. Rejects when the endpoint store
83
+ * cannot be read; a settings file that cannot be read counts as "the flag is off".
84
+ */
85
+ export async function inspectLocalEndpoint(input) {
86
+ const hosts = await readCustomModelHosts(getDataDir());
87
+ const existing = hosts.find((host) => host.id === LOCAL_MODEL_ENDPOINT_ID);
88
+ const settings = await readJsonConfig(SETTINGS_PATH, 'settings.json', {});
89
+ return {
90
+ record: !existing ? 'absent' : isSameLocalEndpoint(existing, input) ? 'same' : 'other',
91
+ flagEnabled: settings[ENDPOINTS_FLAG] === true,
92
+ };
93
+ }
94
+ /**
95
+ * Writes the record and the flag. Idempotent. Never throws: a refused write is `connect-failed`
96
+ * with its message as `detail`.
97
+ *
98
+ * The record goes first, with the "is the id free" check in the same serialized step as the
99
+ * write, so a record that is somebody else's is found before anything is changed. Should the
100
+ * flag then fail to save, a record this call ADDED is taken out again: the pair is never left
101
+ * half done, and a later attempt starts from the same place.
102
+ */
103
+ export async function connectLocalModel(input) {
104
+ const parsed = CustomModelHostSchema.safeParse(buildLocalEndpointRecord(input));
105
+ if (!parsed.success) {
106
+ return { ok: false, code: 'connect-failed', detail: `The endpoint record is not valid: ${parsed.error.message}` };
107
+ }
108
+ const record = parsed.data;
109
+ let outcome;
110
+ try {
111
+ outcome = await mutateCustomModelHosts((hosts) => {
112
+ const index = hosts.findIndex((host) => host.id === record.id);
113
+ if (index === -1)
114
+ return { hosts: [...hosts, record], result: 'added' };
115
+ if (!input.ours && !isSameLocalEndpoint(hosts[index], input))
116
+ return { result: 'taken' };
117
+ const next = [...hosts];
118
+ next[index] = record;
119
+ return { hosts: next, result: 'replaced' };
120
+ });
121
+ }
122
+ catch (err) {
123
+ return { ok: false, code: 'connect-failed', detail: getErrorMessage(err) };
124
+ }
125
+ if (outcome === 'taken')
126
+ return { ok: false, code: 'endpoint-id-taken' };
127
+ let flagBefore;
128
+ try {
129
+ const { before } = await mutateSettingsFile((current) => current[ENDPOINTS_FLAG] === true ? undefined : { ...current, [ENDPOINTS_FLAG]: true });
130
+ flagBefore = before[ENDPOINTS_FLAG] === true;
131
+ }
132
+ catch (err) {
133
+ if (outcome === 'added')
134
+ await removeLocalEndpoint().catch(() => { });
135
+ return { ok: false, code: 'connect-failed', detail: getErrorMessage(err) };
136
+ }
137
+ return { ok: true, flagWasEnabled: input.flagWasEnabled ?? flagBefore };
138
+ }
139
+ /**
140
+ * Puts our record back when it is gone, and does nothing when a record with our id exists
141
+ * (it is never replaced here). For the start of the server while a model is installed: a
142
+ * config-backup restore can bring back an older endpoint store without our record while the
143
+ * model, the runtime and the state file stay. The settings flag is NOT touched: a person who
144
+ * switched it off meant to. Resolves true when the record was added. Never throws.
145
+ */
146
+ export async function ensureLocalEndpoint(input) {
147
+ const parsed = CustomModelHostSchema.safeParse(buildLocalEndpointRecord(input));
148
+ if (!parsed.success)
149
+ return false;
150
+ const record = parsed.data;
151
+ try {
152
+ return await mutateCustomModelHosts((hosts) => hosts.some((host) => host.id === record.id) ? { result: false } : { hosts: [...hosts, record], result: true });
153
+ }
154
+ catch {
155
+ // A store that must not be overwritten stays as it is; a session start then says what is wrong.
156
+ return false;
157
+ }
158
+ }
159
+ /** Takes our record out of the store. Resolves with how many OTHER endpoints are saved. */
160
+ async function removeLocalEndpoint() {
161
+ return mutateCustomModelHosts((hosts) => {
162
+ const others = hosts.filter((host) => host.id !== LOCAL_MODEL_ENDPOINT_ID);
163
+ return others.length === hosts.length ? { result: others.length } : { hosts: others, result: others.length };
164
+ });
165
+ }
166
+ /**
167
+ * Moves our record to another port (the answer to "Use another port" once connected). A
168
+ * missing record is not an error, and a record that is already there is not written again.
169
+ */
170
+ export async function moveLocalEndpoint(port) {
171
+ const baseUrl = `http://127.0.0.1:${port}`;
172
+ await mutateCustomModelHosts((hosts) => {
173
+ const index = hosts.findIndex((host) => host.id === LOCAL_MODEL_ENDPOINT_ID);
174
+ if (index === -1 || hosts[index].baseUrl === baseUrl)
175
+ return { result: undefined };
176
+ const next = [...hosts];
177
+ next[index] = { ...next[index], baseUrl };
178
+ return { hosts: next, result: undefined };
179
+ });
180
+ }
181
+ /**
182
+ * Removes our record, and restores the settings flag when this feature switched it on
183
+ * (`flagWasEnabled` is false) and no other endpoint is left. Idempotent.
184
+ */
185
+ export async function disconnectLocalModel(input) {
186
+ const othersLeft = await removeLocalEndpoint();
187
+ if (input.flagWasEnabled || othersLeft > 0)
188
+ return;
189
+ await mutateSettingsFile((current) => current[ENDPOINTS_FLAG] === true ? { ...current, [ENDPOINTS_FLAG]: false } : undefined);
190
+ }
191
+ /** Whether `id` is the reserved endpoint id. For the endpoint routes and the discovery sweep, which leave that record alone. */
192
+ export function isLocalModelEndpointId(id) {
193
+ return id === LOCAL_MODEL_ENDPOINT_ID;
194
+ }
195
+ /**
196
+ * Whether the saved endpoint `id` is the record THIS feature wrote and still owns: the id is
197
+ * the reserved one and the state file records a connection under it. A record with the
198
+ * reserved id that somebody made by hand (before this feature, or while nothing is installed)
199
+ * is not managed, so its owner can still edit and delete it. Never throws.
200
+ */
201
+ export async function isManagedLocalEndpoint(id) {
202
+ if (!isLocalModelEndpointId(id))
203
+ return false;
204
+ const state = await readLocalModelState();
205
+ return state.connection?.endpointId === id;
206
+ }
207
+ /**
208
+ * The names of the live sessions that use the endpoint `endpointId`, in the order given.
209
+ * Pure. What `DELETE /api/local-model` answers its 409 with.
210
+ */
211
+ export function sessionNamesUsingEndpoint(sessions, endpointId = LOCAL_MODEL_ENDPOINT_ID) {
212
+ const names = [];
213
+ for (const session of sessions) {
214
+ if (session.customModel?.endpointId === endpointId)
215
+ names.push(session.name);
216
+ }
217
+ return names;
218
+ }
219
+ /**
220
+ * Compares the digest stored at install time with the one the runtime reports now. Pure.
221
+ * - `same`: launch.
222
+ * - `changed`: refuse (`model-changed`): the name now stands for other weights or another template.
223
+ * - `unknown`: one of the two is absent (the runtime does not answer, the model is gone).
224
+ * The caller refuses as well, with the reason it knows.
225
+ */
226
+ export function compareModelDigest(stored, current) {
227
+ const a = normalizeDigest(stored);
228
+ const b = normalizeDigest(current);
229
+ if (!a || !b)
230
+ return 'unknown';
231
+ return a === b ? 'same' : 'changed';
232
+ }
233
+ /** A digest as it is compared: lowercase hex, without the `sha256:` some listings put in front. */
234
+ function normalizeDigest(digest) {
235
+ if (typeof digest !== 'string')
236
+ return undefined;
237
+ const hex = digest
238
+ .trim()
239
+ .toLowerCase()
240
+ .replace(/^sha256:/, '');
241
+ return hex === '' ? undefined : hex;
242
+ }
243
+ //# sourceMappingURL=connect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/local-model/connect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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E3B,MAAM,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC;AAED,mGAAmG;AACnG,SAAS,eAAe,CAAC,MAA0B;IACjD,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACjD,MAAM,GAAG,GAAG,MAAM;SACf,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC3B,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;AACtC,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @fileoverview Whether this Mac has the developer tools a coding agent calls (git, Python).
3
+ *
4
+ * Why it exists: on a Mac without Xcode or the Command Line Tools, `git` and `python3` are
5
+ * stubs that open macOS's "install the command line developer tools" window. A coding agent
6
+ * runs both, so the install window says one honest sentence when the tools are missing
7
+ * (`LOCAL_MODEL_INSTALL_LABELS.developerToolsMissing`).
8
+ *
9
+ * Rules:
10
+ * - The ONLY command ever run is `/usr/bin/xcode-select -p`, bounded by a timeout. Never
11
+ * `git`, `python3`, `xcrun` or anything else that would open that window itself.
12
+ * - macOS only. Anywhere else, and when the command does not answer in time, the answer is
13
+ * `unknown`, and nothing is said.
14
+ * - Never throws. The answer is cached for a short while, so a window that polls once a
15
+ * second does not spawn once a second. Only `present` and `missing` are cached: an
16
+ * `unknown` is asked again, because it says the check itself did not work.
17
+ * - Under vitest the default `run` spawns nothing and answers "did not start", so a test
18
+ * that wants an answer injects its own.
19
+ */
20
+ import type { LocalModelDeveloperTools } from '../types.js';
21
+ /** How long `/usr/bin/xcode-select -p` may take. */
22
+ export declare const DEVELOPER_TOOLS_TIMEOUT_MS = 2000;
23
+ /** What the check calls. Each member defaults to the real thing; a test injects its own. */
24
+ export interface DeveloperToolsDeps {
25
+ /** Default `process.platform`. */
26
+ platform: string;
27
+ /** Runs `file` with `args` and resolves with its exit code (`null` when it timed out or could not be started). */
28
+ run: (file: string, args: readonly string[], timeoutMs: number) => Promise<number | null>;
29
+ }
30
+ /**
31
+ * A check that remembers its answer for a minute and shares one run among callers that ask at
32
+ * the same time. `now` is the clock of the cache; a test injects its own.
33
+ */
34
+ export declare function createDeveloperToolsCheck(deps?: Partial<DeveloperToolsDeps> & {
35
+ now?: () => number;
36
+ }): () => Promise<LocalModelDeveloperTools>;
37
+ /** Forgets the cached answer of this server's own Mac. For tests. */
38
+ export declare function resetDeveloperToolsCache(): void;
39
+ /**
40
+ * `present` when `/usr/bin/xcode-select -p` exits 0, `missing` when it exits with anything
41
+ * else, `unknown` otherwise. Without `deps` it is the cached check of this server's Mac; with
42
+ * a platform or a runner of the caller's it asks once and remembers nothing.
43
+ */
44
+ export declare function checkDeveloperTools(deps?: Partial<DeveloperToolsDeps>): Promise<LocalModelDeveloperTools>;
45
+ //# sourceMappingURL=developer-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"developer-tools.d.ts","sourceRoot":"","sources":["../../src/local-model/developer-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,oDAAoD;AACpD,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AAQhD,4FAA4F;AAC5F,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,kHAAkH;IAClH,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC3F;AAgCD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,GAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,GAC9D,MAAM,OAAO,CAAC,wBAAwB,CAAC,CAoBzC;AAKD,qEAAqE;AACrE,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,GAAE,OAAO,CAAC,kBAAkB,CAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAKnH"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @fileoverview Whether this Mac has the developer tools a coding agent calls (git, Python).
3
+ *
4
+ * Why it exists: on a Mac without Xcode or the Command Line Tools, `git` and `python3` are
5
+ * stubs that open macOS's "install the command line developer tools" window. A coding agent
6
+ * runs both, so the install window says one honest sentence when the tools are missing
7
+ * (`LOCAL_MODEL_INSTALL_LABELS.developerToolsMissing`).
8
+ *
9
+ * Rules:
10
+ * - The ONLY command ever run is `/usr/bin/xcode-select -p`, bounded by a timeout. Never
11
+ * `git`, `python3`, `xcrun` or anything else that would open that window itself.
12
+ * - macOS only. Anywhere else, and when the command does not answer in time, the answer is
13
+ * `unknown`, and nothing is said.
14
+ * - Never throws. The answer is cached for a short while, so a window that polls once a
15
+ * second does not spawn once a second. Only `present` and `missing` are cached: an
16
+ * `unknown` is asked again, because it says the check itself did not work.
17
+ * - Under vitest the default `run` spawns nothing and answers "did not start", so a test
18
+ * that wants an answer injects its own.
19
+ */
20
+ import { execFile } from 'node:child_process';
21
+ /** How long `/usr/bin/xcode-select -p` may take. */
22
+ export const DEVELOPER_TOOLS_TIMEOUT_MS = 2_000;
23
+ /** How long an answer is reused. Installing the tools takes minutes, so a minute of staleness is not seen. */
24
+ const DEVELOPER_TOOLS_CACHE_MS = 60_000;
25
+ /** The one command this module runs. It prints the active developer directory and exits 0, or exits with an error when there is none. */
26
+ const XCODE_SELECT = '/usr/bin/xcode-select';
27
+ /** The default `run`: one bounded `execFile`, no shell. Spawns nothing under vitest. */
28
+ function runBounded(file, args, timeoutMs) {
29
+ return new Promise((resolve) => {
30
+ if (process.env.VITEST)
31
+ return resolve(null);
32
+ try {
33
+ execFile(file, [...args], { timeout: timeoutMs }, (err) => {
34
+ if (!err)
35
+ return resolve(0);
36
+ // A number is the exit code of a command that ran. Anything else (ENOENT, a timeout
37
+ // that killed it) is "it did not answer".
38
+ const code = err.code;
39
+ resolve(typeof code === 'number' && !err.killed ? code : null);
40
+ });
41
+ }
42
+ catch {
43
+ resolve(null);
44
+ }
45
+ });
46
+ }
47
+ async function check(deps) {
48
+ if (deps.platform !== 'darwin')
49
+ return 'unknown';
50
+ let code;
51
+ try {
52
+ code = await deps.run(XCODE_SELECT, ['-p'], DEVELOPER_TOOLS_TIMEOUT_MS);
53
+ }
54
+ catch {
55
+ code = null;
56
+ }
57
+ if (code === null || !Number.isInteger(code))
58
+ return 'unknown';
59
+ return code === 0 ? 'present' : 'missing';
60
+ }
61
+ /**
62
+ * A check that remembers its answer for a minute and shares one run among callers that ask at
63
+ * the same time. `now` is the clock of the cache; a test injects its own.
64
+ */
65
+ export function createDeveloperToolsCheck(deps = {}) {
66
+ const resolved = {
67
+ platform: deps.platform ?? process.platform,
68
+ run: deps.run ?? runBounded,
69
+ };
70
+ const now = deps.now ?? Date.now;
71
+ let cached;
72
+ let inFlight;
73
+ return () => {
74
+ if (cached && now() - cached.at < DEVELOPER_TOOLS_CACHE_MS)
75
+ return Promise.resolve(cached.answer);
76
+ inFlight ??= check(resolved)
77
+ .then((answer) => {
78
+ if (answer !== 'unknown')
79
+ cached = { answer, at: now() };
80
+ return answer;
81
+ })
82
+ .finally(() => {
83
+ inFlight = undefined;
84
+ });
85
+ return inFlight;
86
+ };
87
+ }
88
+ /** The check of this server's own Mac. */
89
+ let shared = createDeveloperToolsCheck();
90
+ /** Forgets the cached answer of this server's own Mac. For tests. */
91
+ export function resetDeveloperToolsCache() {
92
+ shared = createDeveloperToolsCheck();
93
+ }
94
+ /**
95
+ * `present` when `/usr/bin/xcode-select -p` exits 0, `missing` when it exits with anything
96
+ * else, `unknown` otherwise. Without `deps` it is the cached check of this server's Mac; with
97
+ * a platform or a runner of the caller's it asks once and remembers nothing.
98
+ */
99
+ export async function checkDeveloperTools(deps = {}) {
100
+ if (deps.platform !== undefined || deps.run !== undefined) {
101
+ return check({ platform: deps.platform ?? process.platform, run: deps.run ?? runBounded });
102
+ }
103
+ return shared();
104
+ }
105
+ //# sourceMappingURL=developer-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"developer-tools.js","sourceRoot":"","sources":["../../src/local-model/developer-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,oDAAoD;AACpD,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAEhD,8GAA8G;AAC9G,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAExC,yIAAyI;AACzI,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAU7C,wFAAwF;AACxF,SAAS,UAAU,CAAC,IAAY,EAAE,IAAuB,EAAE,SAAiB;IAC1E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC;YACH,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;gBACxD,IAAI,CAAC,GAAG;oBAAE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC5B,oFAAoF;gBACpF,0CAA0C;gBAC1C,MAAM,IAAI,G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AAC,EAAE,GAAG,wBAAwB;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAClG,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC;aACzB,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,IAAI,MAAM,KAAK,SAAS;gBAAE,MAAM,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC;YACzD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,QAAQ,GAAG,SAAS,CAAC;QACvB,CAAC,CAAC,CAAC;QACL,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC;AAED,0CAA0C;AAC1C,IAAI,MAAM,GAAG,yBAAyB,EAAE,CAAC;AAEzC,qEAAqE;AACrE,MAAM,UAAU,wBAAwB;IACtC,MAAM,GAAG,yBAAyB,EAAE,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAoC,EAAE;IAC9E,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC1D,OAAO,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,UAAU,EAAE,CAAC,CAAC;IAC7F,CAAC;IACD,OAAO,MAAM,EAAE,CAAC;AAClB,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @fileoverview The formatters of the local model recommendation, and its byte units.
3
+ *
4
+ * `formatGb()` is the ONE place a byte count becomes a size a person reads: decimal GB (the
5
+ * unit the Finder and the model registry use). `hardware.ts` and `recommend.ts` call it to fill
6
+ * the `...Gb` text fields of the payload (`memGb`, `freeDiskGb`, `needGb`, `downloadGb`,
7
+ * `budgetGb`, and the size slots of a `LocalModelMessage`). Nothing else may turn bytes into a
8
+ * size for display, the browser included: it prints the text it was sent.
9
+ *
10
+ * GiB and MiB exist only for the budget math (reserves, the wired limit, the device total the
11
+ * runtime reports) and never reach a person, with one exception: `memClassGb()`, the memory
12
+ * size a Mac is sold as, is how the card names the installed memory ("48 GB memory", what
13
+ * About This Mac shows). It is a name of the machine, not a computed size: `formatGb()` of the
14
+ * same bytes reads 51.5, which no owner recognises. Every computed size (need, budget,
15
+ * download, free disk) is `formatGb()`.
16
+ *
17
+ * Pure: no IO, no state.
18
+ */
19
+ /** One decimal gigabyte, the unit a person reads. */
20
+ export declare const GB = 1000000000;
21
+ /** One binary gigabyte. Budget math only. */
22
+ export declare const GIB: number;
23
+ /** One binary megabyte. Budget math only. */
24
+ export declare const MIB: number;
25
+ /**
26
+ * A byte count as decimal GB text, WITHOUT the unit: one decimal below 100 ('6.6', '17.7',
27
+ * '25.5'), a whole number from 100 ('212'). The caller's sentence supplies ' GB'.
28
+ * Anything that is not a positive finite number reads '0.0'.
29
+ */
30
+ export declare function formatGb(bytes: number): string;
31
+ /**
32
+ * The memory size a Mac is sold as: whole binary gigabytes (17179869184 bytes is 16). This is
33
+ * `HardwareFacts.memClassGb`: the key of the tier rules ("below 36 GB") and of `TestedOn.memGb`,
34
+ * and what the card and the `noneMemory` sentence call the installed memory. It names a class
35
+ * of Mac; 0 means the size is unknown and is never shown. Any other size for display is
36
+ * `formatGb()`.
37
+ */
38
+ export declare function memClassGb(memBytes: number): number;
39
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/local-model/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,qDAAqD;AACrD,eAAO,MAAM,EAAE,aAAgB,CAAC;AAChC,6CAA6C;AAC7C,eAAO,MAAM,GAAG,QAAY,CAAC;AAC7B,6CAA6C;AAC7C,eAAO,MAAM,GAAG,QAAY,CAAC;AAE7B;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGnD"}