@caupulican/pi-adaptative 0.81.38 → 0.81.39

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 (433) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +18 -1
  3. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +131 -0
  4. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -0
  5. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +196 -0
  6. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -0
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +308 -0
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +22 -2
  9. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  10. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +585 -24
  11. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  12. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +749 -27
  13. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/__init__.py +43 -0
  14. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +270 -0
  15. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +252 -0
  16. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +399 -0
  17. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +575 -0
  18. package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +52 -0
  19. package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +49 -0
  20. package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +734 -0
  21. package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +238 -0
  22. package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +132 -0
  23. package/dist/bundled-resources/runtimes/pi-shell-engine/nodes.py +116 -0
  24. package/dist/bundled-resources/runtimes/pi-shell-engine/parser.py +287 -0
  25. package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +137 -0
  26. package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +100 -0
  27. package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +579 -0
  28. package/dist/bundled-resources/skills/tool-call-repair/SKILL.md +19 -9
  29. package/dist/bundled-resources/skills/tool-call-repair/references/failure-grammar.md +22 -5
  30. package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +5 -5
  31. package/dist/bundled-resources/skills/tool-call-repair/references/text-protocol-grammar.md +28 -7
  32. package/dist/cli/args.d.ts +3 -0
  33. package/dist/cli/args.d.ts.map +1 -1
  34. package/dist/cli/args.js +15 -0
  35. package/dist/cli/args.js.map +1 -1
  36. package/dist/core/agent-paths.d.ts +49 -0
  37. package/dist/core/agent-paths.d.ts.map +1 -0
  38. package/dist/core/agent-paths.js +107 -0
  39. package/dist/core/agent-paths.js.map +1 -0
  40. package/dist/core/agent-session-services.d.ts.map +1 -1
  41. package/dist/core/agent-session-services.js +3 -3
  42. package/dist/core/agent-session-services.js.map +1 -1
  43. package/dist/core/agent-session.d.ts +234 -17
  44. package/dist/core/agent-session.d.ts.map +1 -1
  45. package/dist/core/agent-session.js +484 -62
  46. package/dist/core/agent-session.js.map +1 -1
  47. package/dist/core/autonomy/contracts.d.ts +9 -0
  48. package/dist/core/autonomy/contracts.d.ts.map +1 -1
  49. package/dist/core/autonomy/contracts.js.map +1 -1
  50. package/dist/core/autonomy/lane-tracker.d.ts +10 -1
  51. package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
  52. package/dist/core/autonomy/lane-tracker.js +5 -1
  53. package/dist/core/autonomy/lane-tracker.js.map +1 -1
  54. package/dist/core/background-lane-controller.d.ts +122 -6
  55. package/dist/core/background-lane-controller.d.ts.map +1 -1
  56. package/dist/core/background-lane-controller.js +446 -89
  57. package/dist/core/background-lane-controller.js.map +1 -1
  58. package/dist/core/bash-execution-controller.d.ts +4 -0
  59. package/dist/core/bash-execution-controller.d.ts.map +1 -1
  60. package/dist/core/bash-execution-controller.js +7 -1
  61. package/dist/core/bash-execution-controller.js.map +1 -1
  62. package/dist/core/compaction-support.d.ts +13 -3
  63. package/dist/core/compaction-support.d.ts.map +1 -1
  64. package/dist/core/compaction-support.js +43 -7
  65. package/dist/core/compaction-support.js.map +1 -1
  66. package/dist/core/context/context-audit.d.ts +33 -1
  67. package/dist/core/context/context-audit.d.ts.map +1 -1
  68. package/dist/core/context/context-audit.js +31 -5
  69. package/dist/core/context/context-audit.js.map +1 -1
  70. package/dist/core/context-gc.d.ts.map +1 -1
  71. package/dist/core/context-gc.js +16 -1
  72. package/dist/core/context-gc.js.map +1 -1
  73. package/dist/core/context-pipeline.d.ts +26 -4
  74. package/dist/core/context-pipeline.d.ts.map +1 -1
  75. package/dist/core/context-pipeline.js +137 -14
  76. package/dist/core/context-pipeline.js.map +1 -1
  77. package/dist/core/cost-guard.d.ts +19 -3
  78. package/dist/core/cost-guard.d.ts.map +1 -1
  79. package/dist/core/cost-guard.js +18 -3
  80. package/dist/core/cost-guard.js.map +1 -1
  81. package/dist/core/delegation/session-worker-result.d.ts +34 -4
  82. package/dist/core/delegation/session-worker-result.d.ts.map +1 -1
  83. package/dist/core/delegation/session-worker-result.js +64 -4
  84. package/dist/core/delegation/session-worker-result.js.map +1 -1
  85. package/dist/core/delegation/worker-result.d.ts +42 -1
  86. package/dist/core/delegation/worker-result.d.ts.map +1 -1
  87. package/dist/core/delegation/worker-result.js +68 -0
  88. package/dist/core/delegation/worker-result.js.map +1 -1
  89. package/dist/core/extensions/loader.d.ts.map +1 -1
  90. package/dist/core/extensions/loader.js +20 -0
  91. package/dist/core/extensions/loader.js.map +1 -1
  92. package/dist/core/extensions/runner.d.ts.map +1 -1
  93. package/dist/core/extensions/runner.js +1 -0
  94. package/dist/core/extensions/runner.js.map +1 -1
  95. package/dist/core/extensions/types.d.ts +51 -0
  96. package/dist/core/extensions/types.d.ts.map +1 -1
  97. package/dist/core/extensions/types.js.map +1 -1
  98. package/dist/core/goal-loop-controller.d.ts +17 -1
  99. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  100. package/dist/core/goal-loop-controller.js +79 -11
  101. package/dist/core/goal-loop-controller.js.map +1 -1
  102. package/dist/core/goals/goal-continuation-controller.d.ts +48 -2
  103. package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
  104. package/dist/core/goals/goal-continuation-controller.js +77 -0
  105. package/dist/core/goals/goal-continuation-controller.js.map +1 -1
  106. package/dist/core/goals/goal-continuation-defaults.d.ts +39 -0
  107. package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
  108. package/dist/core/goals/goal-continuation-defaults.js +42 -0
  109. package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
  110. package/dist/core/goals/goal-continuation-prompt.d.ts +4 -0
  111. package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
  112. package/dist/core/goals/goal-continuation-prompt.js +51 -10
  113. package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
  114. package/dist/core/goals/goal-runtime-snapshot.d.ts +101 -2
  115. package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
  116. package/dist/core/goals/goal-runtime-snapshot.js +87 -4
  117. package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
  118. package/dist/core/goals/goal-state.d.ts +89 -1
  119. package/dist/core/goals/goal-state.d.ts.map +1 -1
  120. package/dist/core/goals/goal-state.js +71 -5
  121. package/dist/core/goals/goal-state.js.map +1 -1
  122. package/dist/core/goals/goal-tool-core.d.ts +56 -2
  123. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  124. package/dist/core/goals/goal-tool-core.js +111 -5
  125. package/dist/core/goals/goal-tool-core.js.map +1 -1
  126. package/dist/core/goals/session-goal-state.d.ts +11 -2
  127. package/dist/core/goals/session-goal-state.d.ts.map +1 -1
  128. package/dist/core/goals/session-goal-state.js +32 -17
  129. package/dist/core/goals/session-goal-state.js.map +1 -1
  130. package/dist/core/keybindings.d.ts +10 -0
  131. package/dist/core/keybindings.d.ts.map +1 -1
  132. package/dist/core/keybindings.js +10 -2
  133. package/dist/core/keybindings.js.map +1 -1
  134. package/dist/core/learning/observation-store.d.ts +12 -3
  135. package/dist/core/learning/observation-store.d.ts.map +1 -1
  136. package/dist/core/learning/observation-store.js +30 -15
  137. package/dist/core/learning/observation-store.js.map +1 -1
  138. package/dist/core/learning/skill-curator.d.ts +5 -1
  139. package/dist/core/learning/skill-curator.d.ts.map +1 -1
  140. package/dist/core/learning/skill-curator.js +21 -19
  141. package/dist/core/learning/skill-curator.js.map +1 -1
  142. package/dist/core/local-runtime-controller.d.ts +65 -3
  143. package/dist/core/local-runtime-controller.d.ts.map +1 -1
  144. package/dist/core/local-runtime-controller.js +186 -26
  145. package/dist/core/local-runtime-controller.js.map +1 -1
  146. package/dist/core/memory/providers/file-store.d.ts +1 -1
  147. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  148. package/dist/core/memory/providers/file-store.js +6 -6
  149. package/dist/core/memory/providers/file-store.js.map +1 -1
  150. package/dist/core/model-capability.d.ts +34 -0
  151. package/dist/core/model-capability.d.ts.map +1 -1
  152. package/dist/core/model-capability.js +42 -1
  153. package/dist/core/model-capability.js.map +1 -1
  154. package/dist/core/model-router/tool-escalation.d.ts +15 -0
  155. package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
  156. package/dist/core/model-router/tool-escalation.js +23 -1
  157. package/dist/core/model-router/tool-escalation.js.map +1 -1
  158. package/dist/core/model-router-controller.d.ts +34 -7
  159. package/dist/core/model-router-controller.d.ts.map +1 -1
  160. package/dist/core/model-router-controller.js +95 -16
  161. package/dist/core/model-router-controller.js.map +1 -1
  162. package/dist/core/models/adaptation-store.d.ts +7 -0
  163. package/dist/core/models/adaptation-store.d.ts.map +1 -1
  164. package/dist/core/models/adaptation-store.js +47 -11
  165. package/dist/core/models/adaptation-store.js.map +1 -1
  166. package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
  167. package/dist/core/models/default-model-suggestions.js +17 -0
  168. package/dist/core/models/default-model-suggestions.js.map +1 -1
  169. package/dist/core/models/fitness-store.d.ts +3 -0
  170. package/dist/core/models/fitness-store.d.ts.map +1 -1
  171. package/dist/core/models/fitness-store.js +11 -2
  172. package/dist/core/models/fitness-store.js.map +1 -1
  173. package/dist/core/models/llamacpp-runtime.d.ts +180 -0
  174. package/dist/core/models/llamacpp-runtime.d.ts.map +1 -0
  175. package/dist/core/models/llamacpp-runtime.js +475 -0
  176. package/dist/core/models/llamacpp-runtime.js.map +1 -0
  177. package/dist/core/models/local-registration.d.ts +40 -0
  178. package/dist/core/models/local-registration.d.ts.map +1 -1
  179. package/dist/core/models/local-registration.js +94 -5
  180. package/dist/core/models/local-registration.js.map +1 -1
  181. package/dist/core/models/local-runtime.d.ts.map +1 -1
  182. package/dist/core/models/local-runtime.js +6 -5
  183. package/dist/core/models/local-runtime.js.map +1 -1
  184. package/dist/core/models/model-ref.d.ts +7 -0
  185. package/dist/core/models/model-ref.d.ts.map +1 -1
  186. package/dist/core/models/model-ref.js +26 -0
  187. package/dist/core/models/model-ref.js.map +1 -1
  188. package/dist/core/models/needle-runtime.d.ts +257 -0
  189. package/dist/core/models/needle-runtime.d.ts.map +1 -0
  190. package/dist/core/models/needle-runtime.js +519 -0
  191. package/dist/core/models/needle-runtime.js.map +1 -0
  192. package/dist/core/models/prism-llamacpp-lifecycle.d.ts +89 -0
  193. package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -0
  194. package/dist/core/models/prism-llamacpp-lifecycle.js +121 -0
  195. package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -0
  196. package/dist/core/package-manager.d.ts.map +1 -1
  197. package/dist/core/package-manager.js +11 -10
  198. package/dist/core/package-manager.js.map +1 -1
  199. package/dist/core/process-matrix/codes.d.ts +72 -0
  200. package/dist/core/process-matrix/codes.d.ts.map +1 -0
  201. package/dist/core/process-matrix/codes.js +15 -0
  202. package/dist/core/process-matrix/codes.js.map +1 -0
  203. package/dist/core/process-matrix/runtime.d.ts +63 -0
  204. package/dist/core/process-matrix/runtime.d.ts.map +1 -0
  205. package/dist/core/process-matrix/runtime.js +310 -0
  206. package/dist/core/process-matrix/runtime.js.map +1 -0
  207. package/dist/core/process-matrix/store.d.ts +22 -0
  208. package/dist/core/process-matrix/store.d.ts.map +1 -0
  209. package/dist/core/process-matrix/store.js +80 -0
  210. package/dist/core/process-matrix/store.js.map +1 -0
  211. package/dist/core/process-matrix/supervisor.d.ts +72 -0
  212. package/dist/core/process-matrix/supervisor.d.ts.map +1 -0
  213. package/dist/core/process-matrix/supervisor.js +130 -0
  214. package/dist/core/process-matrix/supervisor.js.map +1 -0
  215. package/dist/core/profile-registry.d.ts +7 -0
  216. package/dist/core/profile-registry.d.ts.map +1 -1
  217. package/dist/core/profile-registry.js +20 -0
  218. package/dist/core/profile-registry.js.map +1 -1
  219. package/dist/core/python-runtime.d.ts.map +1 -1
  220. package/dist/core/python-runtime.js +3 -3
  221. package/dist/core/python-runtime.js.map +1 -1
  222. package/dist/core/reflection-controller.d.ts +29 -5
  223. package/dist/core/reflection-controller.d.ts.map +1 -1
  224. package/dist/core/reflection-controller.js +215 -126
  225. package/dist/core/reflection-controller.js.map +1 -1
  226. package/dist/core/reload-blockers.d.ts +36 -0
  227. package/dist/core/reload-blockers.d.ts.map +1 -1
  228. package/dist/core/reload-blockers.js +44 -0
  229. package/dist/core/reload-blockers.js.map +1 -1
  230. package/dist/core/resource-loader.d.ts.map +1 -1
  231. package/dist/core/resource-loader.js +8 -7
  232. package/dist/core/resource-loader.js.map +1 -1
  233. package/dist/core/runtime-builder.d.ts +58 -5
  234. package/dist/core/runtime-builder.d.ts.map +1 -1
  235. package/dist/core/runtime-builder.js +209 -25
  236. package/dist/core/runtime-builder.js.map +1 -1
  237. package/dist/core/scout-controller.d.ts +6 -0
  238. package/dist/core/scout-controller.d.ts.map +1 -1
  239. package/dist/core/scout-controller.js +66 -52
  240. package/dist/core/scout-controller.js.map +1 -1
  241. package/dist/core/sdk.d.ts.map +1 -1
  242. package/dist/core/sdk.js +3 -3
  243. package/dist/core/sdk.js.map +1 -1
  244. package/dist/core/session-role.d.ts +31 -0
  245. package/dist/core/session-role.d.ts.map +1 -0
  246. package/dist/core/session-role.js +52 -0
  247. package/dist/core/session-role.js.map +1 -0
  248. package/dist/core/settings-manager.d.ts +42 -3
  249. package/dist/core/settings-manager.d.ts.map +1 -1
  250. package/dist/core/settings-manager.js +94 -60
  251. package/dist/core/settings-manager.js.map +1 -1
  252. package/dist/core/system-prompt-builder.d.ts +12 -0
  253. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  254. package/dist/core/system-prompt-builder.js +6 -0
  255. package/dist/core/system-prompt-builder.js.map +1 -1
  256. package/dist/core/system-prompt.d.ts +14 -1
  257. package/dist/core/system-prompt.d.ts.map +1 -1
  258. package/dist/core/system-prompt.js +20 -3
  259. package/dist/core/system-prompt.js.map +1 -1
  260. package/dist/core/tasks/session-task-state.d.ts +11 -2
  261. package/dist/core/tasks/session-task-state.d.ts.map +1 -1
  262. package/dist/core/tasks/session-task-state.js +27 -11
  263. package/dist/core/tasks/session-task-state.js.map +1 -1
  264. package/dist/core/tasks/task-contract-monitor.d.ts +45 -0
  265. package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -0
  266. package/dist/core/tasks/task-contract-monitor.js +56 -0
  267. package/dist/core/tasks/task-contract-monitor.js.map +1 -0
  268. package/dist/core/tasks/task-state.d.ts +8 -0
  269. package/dist/core/tasks/task-state.d.ts.map +1 -1
  270. package/dist/core/tasks/task-state.js +28 -1
  271. package/dist/core/tasks/task-state.js.map +1 -1
  272. package/dist/core/tool-gate-controller.d.ts.map +1 -1
  273. package/dist/core/tool-gate-controller.js +5 -0
  274. package/dist/core/tool-gate-controller.js.map +1 -1
  275. package/dist/core/tool-recovery-log-records.d.ts +7 -0
  276. package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
  277. package/dist/core/tool-recovery-log-records.js +14 -6
  278. package/dist/core/tool-recovery-log-records.js.map +1 -1
  279. package/dist/core/tool-selection/promotion.d.ts +54 -0
  280. package/dist/core/tool-selection/promotion.d.ts.map +1 -0
  281. package/dist/core/tool-selection/promotion.js +81 -0
  282. package/dist/core/tool-selection/promotion.js.map +1 -0
  283. package/dist/core/tool-selection/tool-performance-store.d.ts +37 -0
  284. package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
  285. package/dist/core/tool-selection/tool-performance-store.js +87 -3
  286. package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
  287. package/dist/core/tool-selection/tool-selection-controller.d.ts +45 -0
  288. package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
  289. package/dist/core/tool-selection/tool-selection-controller.js +96 -0
  290. package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
  291. package/dist/core/tools/bash.d.ts +18 -0
  292. package/dist/core/tools/bash.d.ts.map +1 -1
  293. package/dist/core/tools/bash.js +95 -16
  294. package/dist/core/tools/bash.js.map +1 -1
  295. package/dist/core/tools/delegate-status.d.ts +14 -0
  296. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  297. package/dist/core/tools/delegate-status.js +82 -7
  298. package/dist/core/tools/delegate-status.js.map +1 -1
  299. package/dist/core/tools/delegate.d.ts.map +1 -1
  300. package/dist/core/tools/delegate.js +25 -8
  301. package/dist/core/tools/delegate.js.map +1 -1
  302. package/dist/core/tools/goal.d.ts +94 -3
  303. package/dist/core/tools/goal.d.ts.map +1 -1
  304. package/dist/core/tools/goal.js +165 -15
  305. package/dist/core/tools/goal.js.map +1 -1
  306. package/dist/core/tools/model-fitness.d.ts +7 -0
  307. package/dist/core/tools/model-fitness.d.ts.map +1 -1
  308. package/dist/core/tools/model-fitness.js +2 -2
  309. package/dist/core/tools/model-fitness.js.map +1 -1
  310. package/dist/core/tools/shell-contract-router.d.ts +6 -1
  311. package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
  312. package/dist/core/tools/shell-contract-router.js +23 -2
  313. package/dist/core/tools/shell-contract-router.js.map +1 -1
  314. package/dist/core/tools/shell-session.d.ts +89 -0
  315. package/dist/core/tools/shell-session.d.ts.map +1 -0
  316. package/dist/core/tools/shell-session.js +432 -0
  317. package/dist/core/tools/shell-session.js.map +1 -0
  318. package/dist/core/tools/task-steps.d.ts +4 -0
  319. package/dist/core/tools/task-steps.d.ts.map +1 -1
  320. package/dist/core/tools/task-steps.js +63 -8
  321. package/dist/core/tools/task-steps.js.map +1 -1
  322. package/dist/core/tools/tmux-dispatch.d.ts +86 -0
  323. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -0
  324. package/dist/core/tools/tmux-dispatch.js +91 -0
  325. package/dist/core/tools/tmux-dispatch.js.map +1 -0
  326. package/dist/core/tools/windows-shell-engine.d.ts +42 -0
  327. package/dist/core/tools/windows-shell-engine.d.ts.map +1 -0
  328. package/dist/core/tools/windows-shell-engine.js +153 -0
  329. package/dist/core/tools/windows-shell-engine.js.map +1 -0
  330. package/dist/core/tools/windows-shell-state.d.ts +40 -0
  331. package/dist/core/tools/windows-shell-state.d.ts.map +1 -0
  332. package/dist/core/tools/windows-shell-state.js +59 -0
  333. package/dist/core/tools/windows-shell-state.js.map +1 -0
  334. package/dist/core/tools/worktree-sync.d.ts +24 -0
  335. package/dist/core/tools/worktree-sync.d.ts.map +1 -0
  336. package/dist/core/tools/worktree-sync.js +338 -0
  337. package/dist/core/tools/worktree-sync.js.map +1 -0
  338. package/dist/core/trust-manager.d.ts +4 -1
  339. package/dist/core/trust-manager.d.ts.map +1 -1
  340. package/dist/core/trust-manager.js +20 -2
  341. package/dist/core/trust-manager.js.map +1 -1
  342. package/dist/core/util/atomic-file.d.ts +55 -0
  343. package/dist/core/util/atomic-file.d.ts.map +1 -0
  344. package/dist/core/util/atomic-file.js +255 -0
  345. package/dist/core/util/atomic-file.js.map +1 -0
  346. package/dist/core/util/minimatch-cache.d.ts +33 -0
  347. package/dist/core/util/minimatch-cache.d.ts.map +1 -0
  348. package/dist/core/util/minimatch-cache.js +0 -0
  349. package/dist/core/util/minimatch-cache.js.map +1 -0
  350. package/dist/core/worktree-sync/codes.d.ts +227 -0
  351. package/dist/core/worktree-sync/codes.d.ts.map +1 -0
  352. package/dist/core/worktree-sync/codes.js +14 -0
  353. package/dist/core/worktree-sync/codes.js.map +1 -0
  354. package/dist/core/worktree-sync/git-engine.d.ts +156 -0
  355. package/dist/core/worktree-sync/git-engine.d.ts.map +1 -0
  356. package/dist/core/worktree-sync/git-engine.js +1191 -0
  357. package/dist/core/worktree-sync/git-engine.js.map +1 -0
  358. package/dist/core/worktree-sync/lane-gate.d.ts +75 -0
  359. package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -0
  360. package/dist/core/worktree-sync/lane-gate.js +360 -0
  361. package/dist/core/worktree-sync/lane-gate.js.map +1 -0
  362. package/dist/core/worktree-sync/runtime.d.ts +47 -0
  363. package/dist/core/worktree-sync/runtime.d.ts.map +1 -0
  364. package/dist/core/worktree-sync/runtime.js +96 -0
  365. package/dist/core/worktree-sync/runtime.js.map +1 -0
  366. package/dist/core/worktree-sync/store.d.ts +69 -0
  367. package/dist/core/worktree-sync/store.d.ts.map +1 -0
  368. package/dist/core/worktree-sync/store.js +247 -0
  369. package/dist/core/worktree-sync/store.js.map +1 -0
  370. package/dist/core/worktree-sync/watcher.d.ts +29 -0
  371. package/dist/core/worktree-sync/watcher.d.ts.map +1 -0
  372. package/dist/core/worktree-sync/watcher.js +93 -0
  373. package/dist/core/worktree-sync/watcher.js.map +1 -0
  374. package/dist/main.d.ts.map +1 -1
  375. package/dist/main.js +94 -0
  376. package/dist/main.js.map +1 -1
  377. package/dist/migrations.d.ts +9 -0
  378. package/dist/migrations.d.ts.map +1 -1
  379. package/dist/migrations.js +38 -0
  380. package/dist/migrations.js.map +1 -1
  381. package/dist/modes/interactive/auto-learn-controller.d.ts +16 -1
  382. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
  383. package/dist/modes/interactive/auto-learn-controller.js +50 -8
  384. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  385. package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
  386. package/dist/modes/interactive/components/profile-resource-editor.js +23 -1
  387. package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
  388. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  389. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  390. package/dist/modes/interactive/interactive-mode.js +4 -0
  391. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  392. package/dist/modes/interactive/local-model-commands.d.ts +43 -0
  393. package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
  394. package/dist/modes/interactive/local-model-commands.js +290 -3
  395. package/dist/modes/interactive/local-model-commands.js.map +1 -1
  396. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
  397. package/dist/modes/interactive/session-flow-commands.js +24 -4
  398. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  399. package/dist/utils/fs-watch.d.ts +11 -0
  400. package/dist/utils/fs-watch.d.ts.map +1 -1
  401. package/dist/utils/fs-watch.js +20 -2
  402. package/dist/utils/fs-watch.js.map +1 -1
  403. package/dist/utils/highlight-js-languages.d.ts +4 -0
  404. package/dist/utils/highlight-js-languages.d.ts.map +1 -0
  405. package/dist/utils/highlight-js-languages.js +573 -0
  406. package/dist/utils/highlight-js-languages.js.map +1 -0
  407. package/dist/utils/shell.d.ts +7 -1
  408. package/dist/utils/shell.d.ts.map +1 -1
  409. package/dist/utils/shell.js +21 -6
  410. package/dist/utils/shell.js.map +1 -1
  411. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  412. package/dist/utils/syntax-highlight.js +53 -5
  413. package/dist/utils/syntax-highlight.js.map +1 -1
  414. package/dist/utils/tools-manager.d.ts.map +1 -1
  415. package/dist/utils/tools-manager.js +112 -1
  416. package/dist/utils/tools-manager.js.map +1 -1
  417. package/docs/process-matrix.md +120 -0
  418. package/docs/settings.md +3 -0
  419. package/docs/tmux-agent-manager.md +85 -2
  420. package/docs/windows.md +52 -3
  421. package/docs/work-directory.md +29 -0
  422. package/docs/worktree-sync.md +250 -0
  423. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  424. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  425. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  426. package/examples/extensions/sandbox/package-lock.json +2 -2
  427. package/examples/extensions/sandbox/package.json +1 -1
  428. package/examples/extensions/with-deps/package-lock.json +2 -2
  429. package/examples/extensions/with-deps/package.json +1 -1
  430. package/npm-shrinkwrap.json +12 -12
  431. package/package.json +10 -4
  432. package/docs/integration-sweep-builder-blueprint-2026-07-09.md +0 -365
  433. package/docs/integration-sweep-resume-2026-07-09.md +0 -407
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Core lifecycle logic for pi-managed prism llama.cpp models (Bonsai-27B first), shared between the
3
+ * `/models add` install pipeline (modes/interactive/local-model-commands.ts) and the router's
4
+ * readiness gate (local-runtime-controller.ts). ONE place owns "ensure both GGUF files exist, then
5
+ * serve" so a turn routed to a cold Bonsai-27B and a fresh `/models add` both go through the
6
+ * identical self-healing path instead of two parallel, potentially-diverging implementations.
7
+ *
8
+ * Lives in core/models/ (not modes/) so the headless readiness gate — used by print/RPC/interactive
9
+ * sessions and isolated/background lanes alike — never depends on the interactive-only UI layer;
10
+ * mirrors the existing local-runtime.ts (mechanics) / local-runtime-controller.ts (gate) split.
11
+ */
12
+ import { type PrismLlamaCppRuntime, type PrismModelDescriptor } from "./llamacpp-runtime.ts";
13
+ /**
14
+ * Curated prism llama.cpp descriptors, keyed by repo id — matches the modelId model-ref.ts's
15
+ * curated `PRISM_LLAMACPP_MODEL_IDS` route returns, and the id `registerPrismLlamaCppModel` writes
16
+ * as the model's id in models.json. Add future curated prism-ml models to both places together.
17
+ *
18
+ * Also the pi-managed-vs-user-owned discriminator (see {@link isPiManagedPrismLlamaCppModel}): a
19
+ * `llama-cpp` provider model is gated/self-healed by pi ONLY when its id is a key here — a user's
20
+ * own hand-configured entry (e.g. the built-in `llama-cpp/local` catalog model on port 8080,
21
+ * pointing at a server the user runs themselves) is never touched.
22
+ */
23
+ export declare const PRISM_LLAMACPP_DESCRIPTORS: Record<string, PrismModelDescriptor>;
24
+ /**
25
+ * True only for a `llama-cpp` provider model pi itself registered (id present in
26
+ * {@link PRISM_LLAMACPP_DESCRIPTORS}) — never true for a user's own hand-configured llama-cpp
27
+ * model, including the built-in `llama-cpp/local` catalog entry. This is the gate that must run
28
+ * before ANY self-heal/serve action so pi never touches a server it doesn't own.
29
+ */
30
+ export declare function isPiManagedPrismLlamaCppModel(model: {
31
+ provider: string;
32
+ id: string;
33
+ }): boolean;
34
+ /**
35
+ * Fixed local port for pi's own managed prism llama.cpp server. Deliberately NOT the generic
36
+ * built-in `llama-cpp/local` catalog model's conventional port 8080 (models.generated.ts) — that
37
+ * port is the convention for a user's OWN manually started llama-server pi merely points at; pi's
38
+ * managed instance must never collide with it.
39
+ */
40
+ export declare const PRISM_LLAMACPP_SERVE_PORT = 8090;
41
+ /**
42
+ * Conservative RAM-only context cap for the pi-managed prism llama.cpp server, used at FIRST
43
+ * install time only (`/models add`) — a later self-heal re-serve reuses the model's already
44
+ * registered `contextWindow` instead (see the readiness gate in local-runtime-controller.ts), never
45
+ * re-deriving from current RAM, so a served context size can't drift from what pi already told the
46
+ * rest of the session (compaction, etc.) to expect. PrismLlamaCppRuntime has no `/api/show`-
47
+ * equivalent GGUF metadata endpoint (unlike Ollama, which context-sizing.ts's
48
+ * deriveLocalContextSizing depends on), so this is a coarse rung table mirroring
49
+ * context-sizing.ts's CONTEXT_RUNGS, hard-capped at 32768 regardless of headroom: Bonsai-27B
50
+ * advertises a 262K-class context, but that is not a realistic KV budget for a CPU-served model on
51
+ * consumer hardware, and there is no larger validated rung to grow into yet.
52
+ */
53
+ export declare function derivePrismLlamaCppNumCtx(totalMemBytes: number): number;
54
+ export type EnsurePrismModelServedResult = {
55
+ ok: true;
56
+ baseUrl: string;
57
+ } | {
58
+ ok: false;
59
+ stage: "model-download" | "mmproj-download" | "serve";
60
+ error: string;
61
+ };
62
+ /**
63
+ * The SOLE path allowed to call `runtime.serve()` for a prism llama.cpp model — no caller may spawn
64
+ * llama-server without first passing through here (both `addPrismLlamaCppModel`'s install pipeline
65
+ * and the readiness gate's self-heal path call this, never `runtime.serve()` directly).
66
+ * Unconditionally re-verifies BOTH GGUF files via `runtime.downloadModel()` immediately before every
67
+ * serve — that call is idempotent (skips a re-download when the local file already matches the
68
+ * remote size, so the happy path costs one stat) and self-heals a file that went missing from disk
69
+ * (deleted, a partial download from a prior crash, host cleanup, etc.) by re-fetching it instead of
70
+ * ever starting llama-server without it. The vision projector is mandatory whenever the descriptor
71
+ * declares one (Bonsai-27B always does — see BONSAI_27B.mmprojFile): a download failure on EITHER
72
+ * file means llama-server is never spawned. There is no text-only fallback — Bonsai-27B never
73
+ * silently degrades to a vision-less serve because the projector went missing.
74
+ */
75
+ export declare function ensurePrismModelFilesThenServe(runtime: PrismLlamaCppRuntime, descriptor: PrismModelDescriptor, args: {
76
+ port: number;
77
+ numCtx: number;
78
+ }, onProgress: (message: string) => void): Promise<EnsurePrismModelServedResult>;
79
+ /**
80
+ * Direct HTTP reachability probe against a prism llama.cpp server root (NOT the `/v1` OpenAI-compat
81
+ * suffix models.json registers — same root/health split as llama-server's own health endpoint used
82
+ * internally by PrismLlamaCppRuntime#serve). PrismLlamaCppRuntime has no public method for this (its
83
+ * own equivalent, `_healthUp`, is private and scoped to a `serve()` call in progress), so the
84
+ * readiness gate needs its own — this is deliberately independent of any single runtime instance:
85
+ * it answers "is a server already alive at this URL", true even for a server this session never
86
+ * spawned (started earlier, or by a different process).
87
+ */
88
+ export declare function isPrismLlamaCppServerHealthy(serverUrl: string, fetchFn?: typeof fetch, timeoutMs?: number): Promise<boolean>;
89
+ //# sourceMappingURL=prism-llamacpp-lifecycle.d.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,SAAS,GAAE,MAAwC,GACjD,OAAO,CAAC,OAAO,CAAC,CAOlB","sourcesContent":["/**\n * Core lifecycle logic for pi-managed prism llama.cpp models (Bonsai-27B first), shared between the\n * `/models add` install pipeline (modes/interactive/local-model-commands.ts) and the router's\n * readiness gate (local-runtime-controller.ts). ONE place owns \"ensure both GGUF files exist, then\n * serve\" so a turn routed to a cold Bonsai-27B and a fresh `/models add` both go through the\n * identical self-healing path instead of two parallel, potentially-diverging implementations.\n *\n * Lives in core/models/ (not modes/) so the headless readiness gate — used by print/RPC/interactive\n * sessions and isolated/background lanes alike — never depends on the interactive-only UI layer;\n * mirrors the existing local-runtime.ts (mechanics) / local-runtime-controller.ts (gate) split.\n */\n\nimport { BONSAI_27B, type PrismLlamaCppRuntime, type PrismModelDescriptor } from \"./llamacpp-runtime.ts\";\nimport { PRISM_LLAMACPP_PROVIDER } from \"./local-registration.ts\";\n\n/**\n * Curated prism llama.cpp descriptors, keyed by repo id — matches the modelId model-ref.ts's\n * curated `PRISM_LLAMACPP_MODEL_IDS` route returns, and the id `registerPrismLlamaCppModel` writes\n * as the model's id in models.json. Add future curated prism-ml models to both places together.\n *\n * Also the pi-managed-vs-user-owned discriminator (see {@link isPiManagedPrismLlamaCppModel}): a\n * `llama-cpp` provider model is gated/self-healed by pi ONLY when its id is a key here — a user's\n * own hand-configured entry (e.g. the built-in `llama-cpp/local` catalog model on port 8080,\n * pointing at a server the user runs themselves) is never touched.\n */\nexport const PRISM_LLAMACPP_DESCRIPTORS: Record<string, PrismModelDescriptor> = {\n\t[BONSAI_27B.repo]: BONSAI_27B,\n};\n\n/**\n * True only for a `llama-cpp` provider model pi itself registered (id present in\n * {@link PRISM_LLAMACPP_DESCRIPTORS}) — never true for a user's own hand-configured llama-cpp\n * model, including the built-in `llama-cpp/local` catalog entry. This is the gate that must run\n * before ANY self-heal/serve action so pi never touches a server it doesn't own.\n */\nexport function isPiManagedPrismLlamaCppModel(model: { provider: string; id: string }): boolean {\n\treturn model.provider === PRISM_LLAMACPP_PROVIDER && Object.hasOwn(PRISM_LLAMACPP_DESCRIPTORS, model.id);\n}\n\n/**\n * Fixed local port for pi's own managed prism llama.cpp server. Deliberately NOT the generic\n * built-in `llama-cpp/local` catalog model's conventional port 8080 (models.generated.ts) — that\n * port is the convention for a user's OWN manually started llama-server pi merely points at; pi's\n * managed instance must never collide with it.\n */\nexport const PRISM_LLAMACPP_SERVE_PORT = 8090;\n\n/**\n * Conservative RAM-only context cap for the pi-managed prism llama.cpp server, used at FIRST\n * install time only (`/models add`) — a later self-heal re-serve reuses the model's already\n * registered `contextWindow` instead (see the readiness gate in local-runtime-controller.ts), never\n * re-deriving from current RAM, so a served context size can't drift from what pi already told the\n * rest of the session (compaction, etc.) to expect. PrismLlamaCppRuntime has no `/api/show`-\n * equivalent GGUF metadata endpoint (unlike Ollama, which context-sizing.ts's\n * deriveLocalContextSizing depends on), so this is a coarse rung table mirroring\n * context-sizing.ts's CONTEXT_RUNGS, hard-capped at 32768 regardless of headroom: Bonsai-27B\n * advertises a 262K-class context, but that is not a realistic KV budget for a CPU-served model on\n * consumer hardware, and there is no larger validated rung to grow into yet.\n */\nexport function derivePrismLlamaCppNumCtx(totalMemBytes: number): number {\n\tconst totalGb = totalMemBytes / 1e9;\n\tif (totalGb >= 64) return 32_768;\n\tif (totalGb >= 32) return 16_384;\n\tif (totalGb >= 16) return 8_192;\n\treturn 4_096;\n}\n\nexport type EnsurePrismModelServedResult =\n\t| { ok: true; baseUrl: string }\n\t| { ok: false; stage: \"model-download\" | \"mmproj-download\" | \"serve\"; error: string };\n\n/**\n * The SOLE path allowed to call `runtime.serve()` for a prism llama.cpp model — no caller may spawn\n * llama-server without first passing through here (both `addPrismLlamaCppModel`'s install pipeline\n * and the readiness gate's self-heal path call this, never `runtime.serve()` directly).\n * Unconditionally re-verifies BOTH GGUF files via `runtime.downloadModel()` immediately before every\n * serve — that call is idempotent (skips a re-download when the local file already matches the\n * remote size, so the happy path costs one stat) and self-heals a file that went missing from disk\n * (deleted, a partial download from a prior crash, host cleanup, etc.) by re-fetching it instead of\n * ever starting llama-server without it. The vision projector is mandatory whenever the descriptor\n * declares one (Bonsai-27B always does — see BONSAI_27B.mmprojFile): a download failure on EITHER\n * file means llama-server is never spawned. There is no text-only fallback — Bonsai-27B never\n * silently degrades to a vision-less serve because the projector went missing.\n */\nexport async function ensurePrismModelFilesThenServe(\n\truntime: PrismLlamaCppRuntime,\n\tdescriptor: PrismModelDescriptor,\n\targs: { port: number; numCtx: number },\n\tonProgress: (message: string) => void,\n): Promise<EnsurePrismModelServedResult> {\n\tconst downloadedModel = await runtime.downloadModel({ repo: descriptor.repo, file: descriptor.file }, (progress) =>\n\t\tonProgress(` ${descriptor.file}: ${progress}`),\n\t);\n\tif (!downloadedModel.ok || !downloadedModel.path) {\n\t\treturn { ok: false, stage: \"model-download\", error: downloadedModel.error ?? \"unknown error\" };\n\t}\n\n\tlet mmprojPath: string | undefined;\n\tif (descriptor.mmprojFile) {\n\t\tconst downloadedMmproj = await runtime.downloadModel(\n\t\t\t{ repo: descriptor.repo, file: descriptor.mmprojFile },\n\t\t\t(progress) => onProgress(` ${descriptor.mmprojFile}: ${progress}`),\n\t\t);\n\t\tif (!downloadedMmproj.ok || !downloadedMmproj.path) {\n\t\t\treturn { ok: false, stage: \"mmproj-download\", error: downloadedMmproj.error ?? \"unknown error\" };\n\t\t}\n\t\tmmprojPath = downloadedMmproj.path;\n\t}\n\n\tonProgress(`Starting ${descriptor.displayName} on 127.0.0.1:${args.port} (context ${args.numCtx})…`);\n\tconst served = await runtime.serve({\n\t\tmodelPath: downloadedModel.path,\n\t\tmmprojPath,\n\t\tport: args.port,\n\t\tnumCtx: args.numCtx,\n\t});\n\tif (!served.ok) return { ok: false, stage: \"serve\", error: served.error };\n\treturn { ok: true, baseUrl: served.baseUrl };\n}\n\nconst DEFAULT_HEALTH_CHECK_TIMEOUT_MS = 2_000;\n\n/**\n * Direct HTTP reachability probe against a prism llama.cpp server root (NOT the `/v1` OpenAI-compat\n * suffix models.json registers — same root/health split as llama-server's own health endpoint used\n * internally by PrismLlamaCppRuntime#serve). PrismLlamaCppRuntime has no public method for this (its\n * own equivalent, `_healthUp`, is private and scoped to a `serve()` call in progress), so the\n * readiness gate needs its own — this is deliberately independent of any single runtime instance:\n * it answers \"is a server already alive at this URL\", true even for a server this session never\n * spawned (started earlier, or by a different process).\n */\nexport async function isPrismLlamaCppServerHealthy(\n\tserverUrl: string,\n\tfetchFn: typeof fetch = fetch,\n\ttimeoutMs: number = DEFAULT_HEALTH_CHECK_TIMEOUT_MS,\n): Promise<boolean> {\n\ttry {\n\t\tconst response = await fetchFn(`${serverUrl}/health`, { signal: AbortSignal.timeout(timeoutMs) });\n\t\treturn response.ok;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Core lifecycle logic for pi-managed prism llama.cpp models (Bonsai-27B first), shared between the
3
+ * `/models add` install pipeline (modes/interactive/local-model-commands.ts) and the router's
4
+ * readiness gate (local-runtime-controller.ts). ONE place owns "ensure both GGUF files exist, then
5
+ * serve" so a turn routed to a cold Bonsai-27B and a fresh `/models add` both go through the
6
+ * identical self-healing path instead of two parallel, potentially-diverging implementations.
7
+ *
8
+ * Lives in core/models/ (not modes/) so the headless readiness gate — used by print/RPC/interactive
9
+ * sessions and isolated/background lanes alike — never depends on the interactive-only UI layer;
10
+ * mirrors the existing local-runtime.ts (mechanics) / local-runtime-controller.ts (gate) split.
11
+ */
12
+ import { BONSAI_27B } from "./llamacpp-runtime.js";
13
+ import { PRISM_LLAMACPP_PROVIDER } from "./local-registration.js";
14
+ /**
15
+ * Curated prism llama.cpp descriptors, keyed by repo id — matches the modelId model-ref.ts's
16
+ * curated `PRISM_LLAMACPP_MODEL_IDS` route returns, and the id `registerPrismLlamaCppModel` writes
17
+ * as the model's id in models.json. Add future curated prism-ml models to both places together.
18
+ *
19
+ * Also the pi-managed-vs-user-owned discriminator (see {@link isPiManagedPrismLlamaCppModel}): a
20
+ * `llama-cpp` provider model is gated/self-healed by pi ONLY when its id is a key here — a user's
21
+ * own hand-configured entry (e.g. the built-in `llama-cpp/local` catalog model on port 8080,
22
+ * pointing at a server the user runs themselves) is never touched.
23
+ */
24
+ export const PRISM_LLAMACPP_DESCRIPTORS = {
25
+ [BONSAI_27B.repo]: BONSAI_27B,
26
+ };
27
+ /**
28
+ * True only for a `llama-cpp` provider model pi itself registered (id present in
29
+ * {@link PRISM_LLAMACPP_DESCRIPTORS}) — never true for a user's own hand-configured llama-cpp
30
+ * model, including the built-in `llama-cpp/local` catalog entry. This is the gate that must run
31
+ * before ANY self-heal/serve action so pi never touches a server it doesn't own.
32
+ */
33
+ export function isPiManagedPrismLlamaCppModel(model) {
34
+ return model.provider === PRISM_LLAMACPP_PROVIDER && Object.hasOwn(PRISM_LLAMACPP_DESCRIPTORS, model.id);
35
+ }
36
+ /**
37
+ * Fixed local port for pi's own managed prism llama.cpp server. Deliberately NOT the generic
38
+ * built-in `llama-cpp/local` catalog model's conventional port 8080 (models.generated.ts) — that
39
+ * port is the convention for a user's OWN manually started llama-server pi merely points at; pi's
40
+ * managed instance must never collide with it.
41
+ */
42
+ export const PRISM_LLAMACPP_SERVE_PORT = 8090;
43
+ /**
44
+ * Conservative RAM-only context cap for the pi-managed prism llama.cpp server, used at FIRST
45
+ * install time only (`/models add`) — a later self-heal re-serve reuses the model's already
46
+ * registered `contextWindow` instead (see the readiness gate in local-runtime-controller.ts), never
47
+ * re-deriving from current RAM, so a served context size can't drift from what pi already told the
48
+ * rest of the session (compaction, etc.) to expect. PrismLlamaCppRuntime has no `/api/show`-
49
+ * equivalent GGUF metadata endpoint (unlike Ollama, which context-sizing.ts's
50
+ * deriveLocalContextSizing depends on), so this is a coarse rung table mirroring
51
+ * context-sizing.ts's CONTEXT_RUNGS, hard-capped at 32768 regardless of headroom: Bonsai-27B
52
+ * advertises a 262K-class context, but that is not a realistic KV budget for a CPU-served model on
53
+ * consumer hardware, and there is no larger validated rung to grow into yet.
54
+ */
55
+ export function derivePrismLlamaCppNumCtx(totalMemBytes) {
56
+ const totalGb = totalMemBytes / 1e9;
57
+ if (totalGb >= 64)
58
+ return 32_768;
59
+ if (totalGb >= 32)
60
+ return 16_384;
61
+ if (totalGb >= 16)
62
+ return 8_192;
63
+ return 4_096;
64
+ }
65
+ /**
66
+ * The SOLE path allowed to call `runtime.serve()` for a prism llama.cpp model — no caller may spawn
67
+ * llama-server without first passing through here (both `addPrismLlamaCppModel`'s install pipeline
68
+ * and the readiness gate's self-heal path call this, never `runtime.serve()` directly).
69
+ * Unconditionally re-verifies BOTH GGUF files via `runtime.downloadModel()` immediately before every
70
+ * serve — that call is idempotent (skips a re-download when the local file already matches the
71
+ * remote size, so the happy path costs one stat) and self-heals a file that went missing from disk
72
+ * (deleted, a partial download from a prior crash, host cleanup, etc.) by re-fetching it instead of
73
+ * ever starting llama-server without it. The vision projector is mandatory whenever the descriptor
74
+ * declares one (Bonsai-27B always does — see BONSAI_27B.mmprojFile): a download failure on EITHER
75
+ * file means llama-server is never spawned. There is no text-only fallback — Bonsai-27B never
76
+ * silently degrades to a vision-less serve because the projector went missing.
77
+ */
78
+ export async function ensurePrismModelFilesThenServe(runtime, descriptor, args, onProgress) {
79
+ const downloadedModel = await runtime.downloadModel({ repo: descriptor.repo, file: descriptor.file }, (progress) => onProgress(` ${descriptor.file}: ${progress}`));
80
+ if (!downloadedModel.ok || !downloadedModel.path) {
81
+ return { ok: false, stage: "model-download", error: downloadedModel.error ?? "unknown error" };
82
+ }
83
+ let mmprojPath;
84
+ if (descriptor.mmprojFile) {
85
+ const downloadedMmproj = await runtime.downloadModel({ repo: descriptor.repo, file: descriptor.mmprojFile }, (progress) => onProgress(` ${descriptor.mmprojFile}: ${progress}`));
86
+ if (!downloadedMmproj.ok || !downloadedMmproj.path) {
87
+ return { ok: false, stage: "mmproj-download", error: downloadedMmproj.error ?? "unknown error" };
88
+ }
89
+ mmprojPath = downloadedMmproj.path;
90
+ }
91
+ onProgress(`Starting ${descriptor.displayName} on 127.0.0.1:${args.port} (context ${args.numCtx})…`);
92
+ const served = await runtime.serve({
93
+ modelPath: downloadedModel.path,
94
+ mmprojPath,
95
+ port: args.port,
96
+ numCtx: args.numCtx,
97
+ });
98
+ if (!served.ok)
99
+ return { ok: false, stage: "serve", error: served.error };
100
+ return { ok: true, baseUrl: served.baseUrl };
101
+ }
102
+ const DEFAULT_HEALTH_CHECK_TIMEOUT_MS = 2_000;
103
+ /**
104
+ * Direct HTTP reachability probe against a prism llama.cpp server root (NOT the `/v1` OpenAI-compat
105
+ * suffix models.json registers — same root/health split as llama-server's own health endpoint used
106
+ * internally by PrismLlamaCppRuntime#serve). PrismLlamaCppRuntime has no public method for this (its
107
+ * own equivalent, `_healthUp`, is private and scoped to a `serve()` call in progress), so the
108
+ * readiness gate needs its own — this is deliberately independent of any single runtime instance:
109
+ * it answers "is a server already alive at this URL", true even for a server this session never
110
+ * spawned (started earlier, or by a different process).
111
+ */
112
+ export async function isPrismLlamaCppServerHealthy(serverUrl, fetchFn = fetch, timeoutMs = DEFAULT_HEALTH_CHECK_TIMEOUT_MS) {
113
+ try {
114
+ const response = await fetchFn(`${serverUrl}/health`, { signal: AbortSignal.timeout(timeoutMs) });
115
+ return response.ok;
116
+ }
117
+ catch {
118
+ return false;
119
+ }
120
+ }
121
+ //# sourceMappingURL=prism-llamacpp-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prism-llamacpp-lifecycle.js","sourceRoot":"","sources":["../../../src/core/models/prism-llamacpp-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAwD,MAAM,uBAAuB,CAAC;AACzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAyC;IAC/E,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,UAAU;CAC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B,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,SAAS,SAAS,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAClG,OAAO,QAAQ,CAAC,EAAE,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AAAA,CACD","sourcesContent":["/**\n * Core lifecycle logic for pi-managed prism llama.cpp models (Bonsai-27B first), shared between the\n * `/models add` install pipeline (modes/interactive/local-model-commands.ts) and the router's\n * readiness gate (local-runtime-controller.ts). ONE place owns \"ensure both GGUF files exist, then\n * serve\" so a turn routed to a cold Bonsai-27B and a fresh `/models add` both go through the\n * identical self-healing path instead of two parallel, potentially-diverging implementations.\n *\n * Lives in core/models/ (not modes/) so the headless readiness gate — used by print/RPC/interactive\n * sessions and isolated/background lanes alike — never depends on the interactive-only UI layer;\n * mirrors the existing local-runtime.ts (mechanics) / local-runtime-controller.ts (gate) split.\n */\n\nimport { BONSAI_27B, type PrismLlamaCppRuntime, type PrismModelDescriptor } from \"./llamacpp-runtime.ts\";\nimport { PRISM_LLAMACPP_PROVIDER } from \"./local-registration.ts\";\n\n/**\n * Curated prism llama.cpp descriptors, keyed by repo id — matches the modelId model-ref.ts's\n * curated `PRISM_LLAMACPP_MODEL_IDS` route returns, and the id `registerPrismLlamaCppModel` writes\n * as the model's id in models.json. Add future curated prism-ml models to both places together.\n *\n * Also the pi-managed-vs-user-owned discriminator (see {@link isPiManagedPrismLlamaCppModel}): a\n * `llama-cpp` provider model is gated/self-healed by pi ONLY when its id is a key here — a user's\n * own hand-configured entry (e.g. the built-in `llama-cpp/local` catalog model on port 8080,\n * pointing at a server the user runs themselves) is never touched.\n */\nexport const PRISM_LLAMACPP_DESCRIPTORS: Record<string, PrismModelDescriptor> = {\n\t[BONSAI_27B.repo]: BONSAI_27B,\n};\n\n/**\n * True only for a `llama-cpp` provider model pi itself registered (id present in\n * {@link PRISM_LLAMACPP_DESCRIPTORS}) — never true for a user's own hand-configured llama-cpp\n * model, including the built-in `llama-cpp/local` catalog entry. This is the gate that must run\n * before ANY self-heal/serve action so pi never touches a server it doesn't own.\n */\nexport function isPiManagedPrismLlamaCppModel(model: { provider: string; id: string }): boolean {\n\treturn model.provider === PRISM_LLAMACPP_PROVIDER && Object.hasOwn(PRISM_LLAMACPP_DESCRIPTORS, model.id);\n}\n\n/**\n * Fixed local port for pi's own managed prism llama.cpp server. Deliberately NOT the generic\n * built-in `llama-cpp/local` catalog model's conventional port 8080 (models.generated.ts) — that\n * port is the convention for a user's OWN manually started llama-server pi merely points at; pi's\n * managed instance must never collide with it.\n */\nexport const PRISM_LLAMACPP_SERVE_PORT = 8090;\n\n/**\n * Conservative RAM-only context cap for the pi-managed prism llama.cpp server, used at FIRST\n * install time only (`/models add`) — a later self-heal re-serve reuses the model's already\n * registered `contextWindow` instead (see the readiness gate in local-runtime-controller.ts), never\n * re-deriving from current RAM, so a served context size can't drift from what pi already told the\n * rest of the session (compaction, etc.) to expect. PrismLlamaCppRuntime has no `/api/show`-\n * equivalent GGUF metadata endpoint (unlike Ollama, which context-sizing.ts's\n * deriveLocalContextSizing depends on), so this is a coarse rung table mirroring\n * context-sizing.ts's CONTEXT_RUNGS, hard-capped at 32768 regardless of headroom: Bonsai-27B\n * advertises a 262K-class context, but that is not a realistic KV budget for a CPU-served model on\n * consumer hardware, and there is no larger validated rung to grow into yet.\n */\nexport function derivePrismLlamaCppNumCtx(totalMemBytes: number): number {\n\tconst totalGb = totalMemBytes / 1e9;\n\tif (totalGb >= 64) return 32_768;\n\tif (totalGb >= 32) return 16_384;\n\tif (totalGb >= 16) return 8_192;\n\treturn 4_096;\n}\n\nexport type EnsurePrismModelServedResult =\n\t| { ok: true; baseUrl: string }\n\t| { ok: false; stage: \"model-download\" | \"mmproj-download\" | \"serve\"; error: string };\n\n/**\n * The SOLE path allowed to call `runtime.serve()` for a prism llama.cpp model — no caller may spawn\n * llama-server without first passing through here (both `addPrismLlamaCppModel`'s install pipeline\n * and the readiness gate's self-heal path call this, never `runtime.serve()` directly).\n * Unconditionally re-verifies BOTH GGUF files via `runtime.downloadModel()` immediately before every\n * serve — that call is idempotent (skips a re-download when the local file already matches the\n * remote size, so the happy path costs one stat) and self-heals a file that went missing from disk\n * (deleted, a partial download from a prior crash, host cleanup, etc.) by re-fetching it instead of\n * ever starting llama-server without it. The vision projector is mandatory whenever the descriptor\n * declares one (Bonsai-27B always does — see BONSAI_27B.mmprojFile): a download failure on EITHER\n * file means llama-server is never spawned. There is no text-only fallback — Bonsai-27B never\n * silently degrades to a vision-less serve because the projector went missing.\n */\nexport async function ensurePrismModelFilesThenServe(\n\truntime: PrismLlamaCppRuntime,\n\tdescriptor: PrismModelDescriptor,\n\targs: { port: number; numCtx: number },\n\tonProgress: (message: string) => void,\n): Promise<EnsurePrismModelServedResult> {\n\tconst downloadedModel = await runtime.downloadModel({ repo: descriptor.repo, file: descriptor.file }, (progress) =>\n\t\tonProgress(` ${descriptor.file}: ${progress}`),\n\t);\n\tif (!downloadedModel.ok || !downloadedModel.path) {\n\t\treturn { ok: false, stage: \"model-download\", error: downloadedModel.error ?? \"unknown error\" };\n\t}\n\n\tlet mmprojPath: string | undefined;\n\tif (descriptor.mmprojFile) {\n\t\tconst downloadedMmproj = await runtime.downloadModel(\n\t\t\t{ repo: descriptor.repo, file: descriptor.mmprojFile },\n\t\t\t(progress) => onProgress(` ${descriptor.mmprojFile}: ${progress}`),\n\t\t);\n\t\tif (!downloadedMmproj.ok || !downloadedMmproj.path) {\n\t\t\treturn { ok: false, stage: \"mmproj-download\", error: downloadedMmproj.error ?? \"unknown error\" };\n\t\t}\n\t\tmmprojPath = downloadedMmproj.path;\n\t}\n\n\tonProgress(`Starting ${descriptor.displayName} on 127.0.0.1:${args.port} (context ${args.numCtx})…`);\n\tconst served = await runtime.serve({\n\t\tmodelPath: downloadedModel.path,\n\t\tmmprojPath,\n\t\tport: args.port,\n\t\tnumCtx: args.numCtx,\n\t});\n\tif (!served.ok) return { ok: false, stage: \"serve\", error: served.error };\n\treturn { ok: true, baseUrl: served.baseUrl };\n}\n\nconst DEFAULT_HEALTH_CHECK_TIMEOUT_MS = 2_000;\n\n/**\n * Direct HTTP reachability probe against a prism llama.cpp server root (NOT the `/v1` OpenAI-compat\n * suffix models.json registers — same root/health split as llama-server's own health endpoint used\n * internally by PrismLlamaCppRuntime#serve). PrismLlamaCppRuntime has no public method for this (its\n * own equivalent, `_healthUp`, is private and scoped to a `serve()` call in progress), so the\n * readiness gate needs its own — this is deliberately independent of any single runtime instance:\n * it answers \"is a server already alive at this URL\", true even for a server this session never\n * spawned (started earlier, or by a different process).\n */\nexport async function isPrismLlamaCppServerHealthy(\n\tserverUrl: string,\n\tfetchFn: typeof fetch = fetch,\n\ttimeoutMs: number = DEFAULT_HEALTH_CHECK_TIMEOUT_MS,\n): Promise<boolean> {\n\ttry {\n\t\tconst response = await fetchFn(`${serverUrl}/health`, { signal: AbortSignal.timeout(timeoutMs) });\n\t\treturn response.ok;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}