@caupulican/pi-adaptative 0.81.41 → 0.81.43

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 (1480) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/bun/cli.d.ts.map +1 -1
  3. package/dist/bun/cli.js.map +1 -1
  4. package/dist/bun/register-bedrock.d.ts.map +1 -1
  5. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  6. package/dist/bun/restore-sandbox-env.js.map +1 -1
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
  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 +52 -49
  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 +62 -57
  13. package/dist/bundled-resources/prompts/skillify.md +1 -1
  14. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +16 -19
  15. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +12 -26
  16. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +15 -121
  17. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +57 -80
  18. package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +3 -3
  19. package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +8 -0
  20. package/dist/bundled-resources/runtimes/pi-shell-engine/escapes.py +70 -0
  21. package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +135 -63
  22. package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +3 -0
  23. package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +108 -22
  24. package/dist/bundled-resources/runtimes/pi-shell-engine/paths.py +10 -0
  25. package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +12 -4
  26. package/dist/bundled-resources/runtimes/pi-shell-engine/shell_args.py +22 -0
  27. package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +10 -2
  28. package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +131 -259
  29. package/dist/bundled-resources/skills/authorized-web-security-audit/SKILL.md +187 -0
  30. package/dist/bundled-resources/skills/authorized-web-security-audit/references/assessment-contract.md +92 -0
  31. package/dist/bundled-resources/skills/deduplicate-by-evidence/SKILL.md +134 -0
  32. package/dist/bundled-resources/skills/evidence-gated-tdd/SKILL.md +93 -0
  33. package/dist/bundled-resources/skills/evidence-gated-tdd/references/evidence-model.md +27 -0
  34. package/dist/bundled-resources/skills/evidence-gated-tdd/references/security-scanners.md +24 -0
  35. package/dist/bundled-resources/skills/harness-self-adaptation/SKILL.md +4 -2
  36. package/dist/bundled-resources/skills/secure-agent-tool-surfaces/SKILL.md +217 -0
  37. package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/defensive-exploit-catalogue.md +175 -0
  38. package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/tool-boundary-checklist.md +87 -0
  39. package/dist/bundled-resources/skills/skill-architect/SKILL.md +2 -2
  40. package/dist/bundled-resources/skills/skill-creator/SKILL.md +188 -0
  41. package/dist/bundled-resources/skills/skill-creator/references/pi-skill-contract.md +73 -0
  42. package/dist/bundled-resources/skills/skill-creator/scripts/init-skill.mjs +142 -0
  43. package/dist/bundled-resources/skills/skill-creator/scripts/validate-skill.mjs +122 -0
  44. package/dist/cli/args.d.ts.map +1 -1
  45. package/dist/cli/args.js.map +1 -1
  46. package/dist/cli/config-selector.d.ts.map +1 -1
  47. package/dist/cli/config-selector.js.map +1 -1
  48. package/dist/cli/file-processor.d.ts.map +1 -1
  49. package/dist/cli/file-processor.js +8 -8
  50. package/dist/cli/file-processor.js.map +1 -1
  51. package/dist/cli/initial-message.d.ts +1 -1
  52. package/dist/cli/initial-message.d.ts.map +1 -1
  53. package/dist/cli/initial-message.js.map +1 -1
  54. package/dist/cli/list-models.d.ts.map +1 -1
  55. package/dist/cli/list-models.js.map +1 -1
  56. package/dist/cli/piped-stdin.d.ts +4 -0
  57. package/dist/cli/piped-stdin.d.ts.map +1 -0
  58. package/dist/cli/piped-stdin.js +13 -0
  59. package/dist/cli/piped-stdin.js.map +1 -0
  60. package/dist/cli/session-picker.d.ts.map +1 -1
  61. package/dist/cli/session-picker.js.map +1 -1
  62. package/dist/cli.d.ts.map +1 -1
  63. package/dist/cli.js.map +1 -1
  64. package/dist/config.d.ts.map +1 -1
  65. package/dist/config.js +9 -14
  66. package/dist/config.js.map +1 -1
  67. package/dist/core/agent-directory-layout.d.ts.map +1 -1
  68. package/dist/core/agent-directory-layout.js.map +1 -1
  69. package/dist/core/agent-paths.d.ts +32 -0
  70. package/dist/core/agent-paths.d.ts.map +1 -1
  71. package/dist/core/agent-paths.js +65 -0
  72. package/dist/core/agent-paths.js.map +1 -1
  73. package/dist/core/agent-session-contracts.d.ts +24 -10
  74. package/dist/core/agent-session-contracts.d.ts.map +1 -1
  75. package/dist/core/agent-session-contracts.js +1 -12
  76. package/dist/core/agent-session-contracts.js.map +1 -1
  77. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  78. package/dist/core/agent-session-runtime.js +10 -25
  79. package/dist/core/agent-session-runtime.js.map +1 -1
  80. package/dist/core/agent-session-services.d.ts.map +1 -1
  81. package/dist/core/agent-session-services.js.map +1 -1
  82. package/dist/core/agent-session.d.ts +24 -1
  83. package/dist/core/agent-session.d.ts.map +1 -1
  84. package/dist/core/agent-session.js +214 -246
  85. package/dist/core/agent-session.js.map +1 -1
  86. package/dist/core/auth-guidance.d.ts.map +1 -1
  87. package/dist/core/auth-guidance.js.map +1 -1
  88. package/dist/core/auth-storage.d.ts +4 -1
  89. package/dist/core/auth-storage.d.ts.map +1 -1
  90. package/dist/core/auth-storage.js +13 -39
  91. package/dist/core/auth-storage.js.map +1 -1
  92. package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
  93. package/dist/core/autonomy/approval-gate.js.map +1 -1
  94. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  95. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  96. package/dist/core/autonomy/contracts.d.ts +2 -0
  97. package/dist/core/autonomy/contracts.d.ts.map +1 -1
  98. package/dist/core/autonomy/contracts.js.map +1 -1
  99. package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
  100. package/dist/core/autonomy/envelope-enforcement.js +4 -9
  101. package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
  102. package/dist/core/autonomy/evidence-finding-projection.d.ts +11 -0
  103. package/dist/core/autonomy/evidence-finding-projection.d.ts.map +1 -0
  104. package/dist/core/autonomy/evidence-finding-projection.js +37 -0
  105. package/dist/core/autonomy/evidence-finding-projection.js.map +1 -0
  106. package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
  107. package/dist/core/autonomy/foreground-envelope.js.map +1 -1
  108. package/dist/core/autonomy/gates.d.ts.map +1 -1
  109. package/dist/core/autonomy/gates.js.map +1 -1
  110. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
  111. package/dist/core/autonomy/lane-private-paths.js.map +1 -1
  112. package/dist/core/autonomy/lane-tool-surface.d.ts +3 -1
  113. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  114. package/dist/core/autonomy/lane-tool-surface.js +17 -4
  115. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  116. package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
  117. package/dist/core/autonomy/lane-tracker.js +2 -3
  118. package/dist/core/autonomy/lane-tracker.js.map +1 -1
  119. package/dist/core/autonomy/path-scope.d.ts +14 -0
  120. package/dist/core/autonomy/path-scope.d.ts.map +1 -1
  121. package/dist/core/autonomy/path-scope.js +37 -6
  122. package/dist/core/autonomy/path-scope.js.map +1 -1
  123. package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
  124. package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
  125. package/dist/core/autonomy/session-lane-record.js.map +1 -1
  126. package/dist/core/autonomy/status.d.ts.map +1 -1
  127. package/dist/core/autonomy/status.js.map +1 -1
  128. package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -1
  129. package/dist/core/autonomy/subagent-prompt.js.map +1 -1
  130. package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
  131. package/dist/core/autonomy/telemetry-events.js.map +1 -1
  132. package/dist/core/autonomy-telemetry.d.ts.map +1 -1
  133. package/dist/core/autonomy-telemetry.js +2 -4
  134. package/dist/core/autonomy-telemetry.js.map +1 -1
  135. package/dist/core/background-lane-controller.d.ts +27 -1
  136. package/dist/core/background-lane-controller.d.ts.map +1 -1
  137. package/dist/core/background-lane-controller.js +34 -16
  138. package/dist/core/background-lane-controller.js.map +1 -1
  139. package/dist/core/background-tool-task-controller.d.ts +88 -0
  140. package/dist/core/background-tool-task-controller.d.ts.map +1 -0
  141. package/dist/core/background-tool-task-controller.js +470 -0
  142. package/dist/core/background-tool-task-controller.js.map +1 -0
  143. package/dist/core/bash-execution-controller.d.ts +1 -0
  144. package/dist/core/bash-execution-controller.d.ts.map +1 -1
  145. package/dist/core/bash-execution-controller.js +5 -4
  146. package/dist/core/bash-execution-controller.js.map +1 -1
  147. package/dist/core/bash-executor.d.ts.map +1 -1
  148. package/dist/core/bash-executor.js.map +1 -1
  149. package/dist/core/bedrock-sso-login.d.ts.map +1 -1
  150. package/dist/core/bedrock-sso-login.js.map +1 -1
  151. package/dist/core/billing-failover-controller.d.ts.map +1 -1
  152. package/dist/core/billing-failover-controller.js +3 -3
  153. package/dist/core/billing-failover-controller.js.map +1 -1
  154. package/dist/core/billing-failover.d.ts.map +1 -1
  155. package/dist/core/billing-failover.js.map +1 -1
  156. package/dist/core/capability-contract.d.ts.map +1 -1
  157. package/dist/core/catalog-manager.d.ts.map +1 -1
  158. package/dist/core/catalog-manager.js +0 -0
  159. package/dist/core/catalog-manager.js.map +1 -1
  160. package/dist/core/compaction-controller.d.ts +2 -0
  161. package/dist/core/compaction-controller.d.ts.map +1 -1
  162. package/dist/core/compaction-controller.js +21 -8
  163. package/dist/core/compaction-controller.js.map +1 -1
  164. package/dist/core/compaction-support.d.ts +8 -0
  165. package/dist/core/compaction-support.d.ts.map +1 -1
  166. package/dist/core/compaction-support.js +0 -2
  167. package/dist/core/compaction-support.js.map +1 -1
  168. package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
  169. package/dist/core/context/artifact-retrieval.js.map +1 -1
  170. package/dist/core/context/brain-curator.d.ts.map +1 -1
  171. package/dist/core/context/brain-curator.js +14 -33
  172. package/dist/core/context/brain-curator.js.map +1 -1
  173. package/dist/core/context/context-artifacts.d.ts.map +1 -1
  174. package/dist/core/context/context-artifacts.js +16 -24
  175. package/dist/core/context/context-artifacts.js.map +1 -1
  176. package/dist/core/context/context-audit.d.ts.map +1 -1
  177. package/dist/core/context/context-audit.js +3 -17
  178. package/dist/core/context/context-audit.js.map +1 -1
  179. package/dist/core/context/context-composition.d.ts.map +1 -1
  180. package/dist/core/context/context-composition.js.map +1 -1
  181. package/dist/core/context/context-item.d.ts.map +1 -1
  182. package/dist/core/context/context-item.js.map +1 -1
  183. package/dist/core/context/context-prompt-enforcement.d.ts.map +1 -1
  184. package/dist/core/context/context-prompt-enforcement.js +3 -16
  185. package/dist/core/context/context-prompt-enforcement.js.map +1 -1
  186. package/dist/core/context/context-prompt-policy.d.ts.map +1 -1
  187. package/dist/core/context/context-prompt-policy.js.map +1 -1
  188. package/dist/core/context/context-retention.d.ts.map +1 -1
  189. package/dist/core/context/context-retention.js.map +1 -1
  190. package/dist/core/context/context-store-retention.d.ts.map +1 -1
  191. package/dist/core/context/context-store-retention.js.map +1 -1
  192. package/dist/core/context/context-store.d.ts.map +1 -1
  193. package/dist/core/context/context-store.js.map +1 -1
  194. package/dist/core/context/context-tool-result.d.ts +4 -0
  195. package/dist/core/context/context-tool-result.d.ts.map +1 -0
  196. package/dist/core/context/context-tool-result.js +15 -0
  197. package/dist/core/context/context-tool-result.js.map +1 -0
  198. package/dist/core/context/current-work-memory.d.ts.map +1 -1
  199. package/dist/core/context/current-work-memory.js.map +1 -1
  200. package/dist/core/context/file-store-memory-provider.d.ts.map +1 -1
  201. package/dist/core/context/file-store-memory-provider.js +7 -28
  202. package/dist/core/context/file-store-memory-provider.js.map +1 -1
  203. package/dist/core/context/local-memory-search.d.ts +11 -0
  204. package/dist/core/context/local-memory-search.d.ts.map +1 -0
  205. package/dist/core/context/local-memory-search.js +37 -0
  206. package/dist/core/context/local-memory-search.js.map +1 -0
  207. package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
  208. package/dist/core/context/long-term-memory-trigger.js.map +1 -1
  209. package/dist/core/context/memory-diagnostics.d.ts.map +1 -1
  210. package/dist/core/context/memory-diagnostics.js.map +1 -1
  211. package/dist/core/context/memory-index-store.d.ts.map +1 -1
  212. package/dist/core/context/memory-index-store.js.map +1 -1
  213. package/dist/core/context/memory-prompt-block.d.ts.map +1 -1
  214. package/dist/core/context/memory-prompt-block.js.map +1 -1
  215. package/dist/core/context/memory-prompt-budget.d.ts.map +1 -1
  216. package/dist/core/context/memory-prompt-budget.js.map +1 -1
  217. package/dist/core/context/memory-provider-contract.d.ts.map +1 -1
  218. package/dist/core/context/memory-provider-contract.js.map +1 -1
  219. package/dist/core/context/memory-retrieval.d.ts.map +1 -1
  220. package/dist/core/context/memory-retrieval.js.map +1 -1
  221. package/dist/core/context/memory-tier-composer.d.ts.map +1 -1
  222. package/dist/core/context/memory-tier-composer.js.map +1 -1
  223. package/dist/core/context/message-text.d.ts +7 -0
  224. package/dist/core/context/message-text.d.ts.map +1 -0
  225. package/dist/core/context/message-text.js +68 -0
  226. package/dist/core/context/message-text.js.map +1 -0
  227. package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
  228. package/dist/core/context/okf-memory-provider.js +4 -30
  229. package/dist/core/context/okf-memory-provider.js.map +1 -1
  230. package/dist/core/context/okf-memory.d.ts.map +1 -1
  231. package/dist/core/context/okf-memory.js.map +1 -1
  232. package/dist/core/context/policy-engine.d.ts.map +1 -1
  233. package/dist/core/context/policy-engine.js.map +1 -1
  234. package/dist/core/context/policy-types.d.ts.map +1 -1
  235. package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
  236. package/dist/core/context/sqlite-runtime-index.js.map +1 -1
  237. package/dist/core/context/storage-authority.d.ts.map +1 -1
  238. package/dist/core/context/tool-output-packer.d.ts.map +1 -1
  239. package/dist/core/context/tool-output-packer.js.map +1 -1
  240. package/dist/core/context-gc.d.ts.map +1 -1
  241. package/dist/core/context-gc.js +14 -21
  242. package/dist/core/context-gc.js.map +1 -1
  243. package/dist/core/context-pipeline.d.ts +1 -3
  244. package/dist/core/context-pipeline.d.ts.map +1 -1
  245. package/dist/core/context-pipeline.js +64 -145
  246. package/dist/core/context-pipeline.js.map +1 -1
  247. package/dist/core/cost/cost-summary.d.ts.map +1 -1
  248. package/dist/core/cost/cost-summary.js.map +1 -1
  249. package/dist/core/cost/daily-usage.d.ts.map +1 -1
  250. package/dist/core/cost/daily-usage.js.map +1 -1
  251. package/dist/core/cost/session-usage.d.ts.map +1 -1
  252. package/dist/core/cost/session-usage.js.map +1 -1
  253. package/dist/core/cost-guard.d.ts.map +1 -1
  254. package/dist/core/cost-guard.js.map +1 -1
  255. package/dist/core/default-tool-surface.d.ts.map +1 -1
  256. package/dist/core/default-tool-surface.js +1 -0
  257. package/dist/core/default-tool-surface.js.map +1 -1
  258. package/dist/core/defaults.d.ts.map +1 -1
  259. package/dist/core/delegation/managed-lane-controller.d.ts +11 -1
  260. package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
  261. package/dist/core/delegation/managed-lane-controller.js +85 -46
  262. package/dist/core/delegation/managed-lane-controller.js.map +1 -1
  263. package/dist/core/delegation/session-worker-claim.d.ts.map +1 -1
  264. package/dist/core/delegation/session-worker-claim.js +4 -3
  265. package/dist/core/delegation/session-worker-claim.js.map +1 -1
  266. package/dist/core/delegation/worker-action-journal.d.ts +73 -0
  267. package/dist/core/delegation/worker-action-journal.d.ts.map +1 -0
  268. package/dist/core/delegation/worker-action-journal.js +293 -0
  269. package/dist/core/delegation/worker-action-journal.js.map +1 -0
  270. package/dist/core/delegation/worker-actions.d.ts +36 -1
  271. package/dist/core/delegation/worker-actions.d.ts.map +1 -1
  272. package/dist/core/delegation/worker-actions.js +171 -46
  273. package/dist/core/delegation/worker-actions.js.map +1 -1
  274. package/dist/core/delegation/worker-agent-control-coordinator.d.ts +76 -0
  275. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -0
  276. package/dist/core/delegation/worker-agent-control-coordinator.js +216 -0
  277. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -0
  278. package/dist/core/delegation/worker-agent-control.d.ts +66 -0
  279. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -0
  280. package/dist/core/delegation/worker-agent-control.js +160 -0
  281. package/dist/core/delegation/worker-agent-control.js.map +1 -0
  282. package/dist/core/delegation/worker-attempt-executor.d.ts +80 -0
  283. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -0
  284. package/dist/core/delegation/worker-attempt-executor.js +343 -0
  285. package/dist/core/delegation/worker-attempt-executor.js.map +1 -0
  286. package/dist/core/delegation/worker-claim.d.ts +30 -0
  287. package/dist/core/delegation/worker-claim.d.ts.map +1 -1
  288. package/dist/core/delegation/worker-claim.js +205 -53
  289. package/dist/core/delegation/worker-claim.js.map +1 -1
  290. package/dist/core/delegation/worker-conversation-store.d.ts +116 -0
  291. package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -0
  292. package/dist/core/delegation/worker-conversation-store.js +440 -0
  293. package/dist/core/delegation/worker-conversation-store.js.map +1 -0
  294. package/dist/core/delegation/worker-delegation-controller.d.ts +21 -5
  295. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  296. package/dist/core/delegation/worker-delegation-controller.js +386 -260
  297. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  298. package/dist/core/delegation/worker-delegation-request.d.ts +14 -0
  299. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
  300. package/dist/core/delegation/worker-delegation-request.js.map +1 -1
  301. package/dist/core/delegation/worker-dispatch-scheduler.d.ts +4 -2
  302. package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
  303. package/dist/core/delegation/worker-dispatch-scheduler.js +20 -11
  304. package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
  305. package/dist/core/delegation/worker-execution-policy.d.ts +2 -1
  306. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
  307. package/dist/core/delegation/worker-execution-policy.js +5 -7
  308. package/dist/core/delegation/worker-execution-policy.js.map +1 -1
  309. package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
  310. package/dist/core/delegation/worker-lane-projection.js.map +1 -1
  311. package/dist/core/delegation/worker-lifecycle.d.ts +44 -1
  312. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
  313. package/dist/core/delegation/worker-lifecycle.js +119 -2
  314. package/dist/core/delegation/worker-lifecycle.js.map +1 -1
  315. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
  316. package/dist/core/delegation/worker-notification-coordinator.js +4 -5
  317. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
  318. package/dist/core/delegation/worker-process-owner.d.ts +18 -0
  319. package/dist/core/delegation/worker-process-owner.d.ts.map +1 -0
  320. package/dist/core/delegation/worker-process-owner.js +54 -0
  321. package/dist/core/delegation/worker-process-owner.js.map +1 -0
  322. package/dist/core/delegation/worker-profile-resolver.d.ts +5 -1
  323. package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
  324. package/dist/core/delegation/worker-profile-resolver.js +9 -2
  325. package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
  326. package/dist/core/delegation/worker-recovery-coordinator.d.ts +54 -0
  327. package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -0
  328. package/dist/core/delegation/worker-recovery-coordinator.js +180 -0
  329. package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -0
  330. package/dist/core/delegation/worker-resource-catalog.d.ts +32 -0
  331. package/dist/core/delegation/worker-resource-catalog.d.ts.map +1 -0
  332. package/dist/core/delegation/worker-resource-catalog.js +116 -0
  333. package/dist/core/delegation/worker-resource-catalog.js.map +1 -0
  334. package/dist/core/delegation/worker-resource-materializer.d.ts +47 -0
  335. package/dist/core/delegation/worker-resource-materializer.d.ts.map +1 -0
  336. package/dist/core/delegation/worker-resource-materializer.js +134 -0
  337. package/dist/core/delegation/worker-resource-materializer.js.map +1 -0
  338. package/dist/core/delegation/worker-runner.d.ts +5 -5
  339. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  340. package/dist/core/delegation/worker-runner.js +193 -70
  341. package/dist/core/delegation/worker-runner.js.map +1 -1
  342. package/dist/core/delegation/worker-task-label.d.ts.map +1 -1
  343. package/dist/core/delegation/worker-task-label.js.map +1 -1
  344. package/dist/core/delegation/worker-terminal-finalizer.d.ts +23 -0
  345. package/dist/core/delegation/worker-terminal-finalizer.d.ts.map +1 -0
  346. package/dist/core/delegation/worker-terminal-finalizer.js +12 -0
  347. package/dist/core/delegation/worker-terminal-finalizer.js.map +1 -0
  348. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +38 -0
  349. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -0
  350. package/dist/core/delegation/worker-write-reservation-coordinator.js +104 -0
  351. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -0
  352. package/dist/core/delegation/worker-write-reservation.d.ts +90 -0
  353. package/dist/core/delegation/worker-write-reservation.d.ts.map +1 -0
  354. package/dist/core/delegation/worker-write-reservation.js +346 -0
  355. package/dist/core/delegation/worker-write-reservation.js.map +1 -0
  356. package/dist/core/diagnostics.d.ts.map +1 -1
  357. package/dist/core/doctor.d.ts.map +1 -1
  358. package/dist/core/doctor.js.map +1 -1
  359. package/dist/core/event-bus.d.ts.map +1 -1
  360. package/dist/core/event-bus.js.map +1 -1
  361. package/dist/core/exec.d.ts.map +1 -1
  362. package/dist/core/exec.js +26 -7
  363. package/dist/core/exec.js.map +1 -1
  364. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  365. package/dist/core/export-html/ansi-to-html.js +21 -74
  366. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  367. package/dist/core/export-html/index.d.ts.map +1 -1
  368. package/dist/core/export-html/index.js +4 -0
  369. package/dist/core/export-html/index.js.map +1 -1
  370. package/dist/core/export-html/session-tree-foundations.d.mts +67 -0
  371. package/dist/core/export-html/session-tree-foundations.mjs +313 -0
  372. package/dist/core/export-html/template.css +14 -41
  373. package/dist/core/export-html/template.html +3 -1
  374. package/dist/core/export-html/template.js +26 -435
  375. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  376. package/dist/core/export-html/tool-renderer.js.map +1 -1
  377. package/dist/core/extension-import-authority.d.ts.map +1 -1
  378. package/dist/core/extension-import-authority.js.map +1 -1
  379. package/dist/core/extension-metadata.d.ts.map +1 -1
  380. package/dist/core/extension-metadata.js.map +1 -1
  381. package/dist/core/extensions/builtin.d.ts +17 -0
  382. package/dist/core/extensions/builtin.d.ts.map +1 -1
  383. package/dist/core/extensions/builtin.js +18 -54
  384. package/dist/core/extensions/builtin.js.map +1 -1
  385. package/dist/core/extensions/entry-resolution.d.ts +3 -0
  386. package/dist/core/extensions/entry-resolution.d.ts.map +1 -0
  387. package/dist/core/extensions/entry-resolution.js +17 -0
  388. package/dist/core/extensions/entry-resolution.js.map +1 -0
  389. package/dist/core/extensions/index.d.ts.map +1 -1
  390. package/dist/core/extensions/loader.d.ts.map +1 -1
  391. package/dist/core/extensions/loader.js +76 -21
  392. package/dist/core/extensions/loader.js.map +1 -1
  393. package/dist/core/extensions/runner.d.ts +2 -0
  394. package/dist/core/extensions/runner.d.ts.map +1 -1
  395. package/dist/core/extensions/runner.js +41 -112
  396. package/dist/core/extensions/runner.js.map +1 -1
  397. package/dist/core/extensions/stale-context.d.ts.map +1 -1
  398. package/dist/core/extensions/storage.d.ts.map +1 -1
  399. package/dist/core/extensions/storage.js.map +1 -1
  400. package/dist/core/extensions/types.d.ts.map +1 -1
  401. package/dist/core/extensions/types.js.map +1 -1
  402. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  403. package/dist/core/extensions/wrapper.js.map +1 -1
  404. package/dist/core/failure-corpus.d.ts.map +1 -1
  405. package/dist/core/failure-corpus.js +2 -5
  406. package/dist/core/failure-corpus.js.map +1 -1
  407. package/dist/core/footer-data-provider.d.ts.map +1 -1
  408. package/dist/core/footer-data-provider.js +27 -33
  409. package/dist/core/footer-data-provider.js.map +1 -1
  410. package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
  411. package/dist/core/foreground-recovery-controller.js +0 -4
  412. package/dist/core/foreground-recovery-controller.js.map +1 -1
  413. package/dist/core/gateways/channel-provider.d.ts.map +1 -1
  414. package/dist/core/gateways/channel-provider.js +7 -5
  415. package/dist/core/gateways/channel-provider.js.map +1 -1
  416. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  417. package/dist/core/goal-loop-controller.js +0 -1
  418. package/dist/core/goal-loop-controller.js.map +1 -1
  419. package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
  420. package/dist/core/goals/compact-goal-context.js +2 -4
  421. package/dist/core/goals/compact-goal-context.js.map +1 -1
  422. package/dist/core/goals/goal-acceptance.d.ts.map +1 -1
  423. package/dist/core/goals/goal-acceptance.js.map +1 -1
  424. package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
  425. package/dist/core/goals/goal-auto-continue-controller.js +1 -3
  426. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
  427. package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
  428. package/dist/core/goals/goal-continuation-controller.js.map +1 -1
  429. package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
  430. package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
  431. package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
  432. package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
  433. package/dist/core/goals/goal-lifecycle.js.map +1 -1
  434. package/dist/core/goals/goal-record.d.ts.map +1 -1
  435. package/dist/core/goals/goal-record.js.map +1 -1
  436. package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
  437. package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
  438. package/dist/core/goals/goal-session-controller.d.ts +15 -0
  439. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  440. package/dist/core/goals/goal-session-controller.js +27 -3
  441. package/dist/core/goals/goal-session-controller.js.map +1 -1
  442. package/dist/core/goals/goal-state.d.ts.map +1 -1
  443. package/dist/core/goals/goal-state.js +35 -51
  444. package/dist/core/goals/goal-state.js.map +1 -1
  445. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  446. package/dist/core/goals/goal-tool-core.js.map +1 -1
  447. package/dist/core/goals/natural-language-goal.d.ts +9 -0
  448. package/dist/core/goals/natural-language-goal.d.ts.map +1 -0
  449. package/dist/core/goals/natural-language-goal.js +23 -0
  450. package/dist/core/goals/natural-language-goal.js.map +1 -0
  451. package/dist/core/goals/session-goal-state.d.ts.map +1 -1
  452. package/dist/core/goals/session-goal-state.js.map +1 -1
  453. package/dist/core/http-dispatcher.d.ts.map +1 -1
  454. package/dist/core/http-dispatcher.js.map +1 -1
  455. package/dist/core/human-input-controller.d.ts.map +1 -1
  456. package/dist/core/human-input-controller.js +2 -3
  457. package/dist/core/human-input-controller.js.map +1 -1
  458. package/dist/core/human-input.d.ts.map +1 -1
  459. package/dist/core/human-input.js.map +1 -1
  460. package/dist/core/improvement-loop.d.ts.map +1 -1
  461. package/dist/core/improvement-loop.js +11 -11
  462. package/dist/core/improvement-loop.js.map +1 -1
  463. package/dist/core/index.d.ts.map +1 -1
  464. package/dist/core/install-telemetry.d.ts.map +1 -1
  465. package/dist/core/install-telemetry.js.map +1 -1
  466. package/dist/core/isolated-text-completion.d.ts +17 -0
  467. package/dist/core/isolated-text-completion.d.ts.map +1 -0
  468. package/dist/core/isolated-text-completion.js +15 -0
  469. package/dist/core/isolated-text-completion.js.map +1 -0
  470. package/dist/core/keybindings.d.ts +47 -2
  471. package/dist/core/keybindings.d.ts.map +1 -1
  472. package/dist/core/keybindings.js +12 -1
  473. package/dist/core/keybindings.js.map +1 -1
  474. package/dist/core/learning/learning-audit.d.ts.map +1 -1
  475. package/dist/core/learning/learning-audit.js.map +1 -1
  476. package/dist/core/learning/learning-gate.d.ts.map +1 -1
  477. package/dist/core/learning/learning-gate.js.map +1 -1
  478. package/dist/core/learning/observation-store.d.ts.map +1 -1
  479. package/dist/core/learning/observation-store.js +0 -2
  480. package/dist/core/learning/observation-store.js.map +1 -1
  481. package/dist/core/learning/reflection-engine.d.ts +1 -1
  482. package/dist/core/learning/reflection-engine.d.ts.map +1 -1
  483. package/dist/core/learning/reflection-engine.js +3 -0
  484. package/dist/core/learning/reflection-engine.js.map +1 -1
  485. package/dist/core/learning/reflection-turn-analysis.d.ts +20 -0
  486. package/dist/core/learning/reflection-turn-analysis.d.ts.map +1 -0
  487. package/dist/core/learning/reflection-turn-analysis.js +136 -0
  488. package/dist/core/learning/reflection-turn-analysis.js.map +1 -0
  489. package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
  490. package/dist/core/learning/session-learning-decision.js.map +1 -1
  491. package/dist/core/learning/skill-curator.d.ts.map +1 -1
  492. package/dist/core/learning/skill-curator.js +0 -3
  493. package/dist/core/learning/skill-curator.js.map +1 -1
  494. package/dist/core/local-runtime-controller.d.ts +39 -0
  495. package/dist/core/local-runtime-controller.d.ts.map +1 -1
  496. package/dist/core/local-runtime-controller.js +41 -62
  497. package/dist/core/local-runtime-controller.js.map +1 -1
  498. package/dist/core/memory/effectiveness-tracker.d.ts.map +1 -1
  499. package/dist/core/memory/effectiveness-tracker.js +4 -2
  500. package/dist/core/memory/effectiveness-tracker.js.map +1 -1
  501. package/dist/core/memory/memory-manager.d.ts.map +1 -1
  502. package/dist/core/memory/memory-manager.js +7 -7
  503. package/dist/core/memory/memory-manager.js.map +1 -1
  504. package/dist/core/memory/memory-provider.d.ts.map +1 -1
  505. package/dist/core/memory/providers/file-store.d.ts +7 -0
  506. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  507. package/dist/core/memory/providers/file-store.js +48 -13
  508. package/dist/core/memory/providers/file-store.js.map +1 -1
  509. package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts +47 -0
  510. package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts.map +1 -0
  511. package/dist/core/memory/providers/transcript-recall-worker-protocol.js +50 -0
  512. package/dist/core/memory/providers/transcript-recall-worker-protocol.js.map +1 -0
  513. package/dist/core/memory/providers/transcript-recall-worker.d.ts +2 -0
  514. package/dist/core/memory/providers/transcript-recall-worker.d.ts.map +1 -0
  515. package/dist/core/memory/providers/transcript-recall-worker.js +143 -0
  516. package/dist/core/memory/providers/transcript-recall-worker.js.map +1 -0
  517. package/dist/core/memory/providers/transcript-recall.d.ts +24 -13
  518. package/dist/core/memory/providers/transcript-recall.d.ts.map +1 -1
  519. package/dist/core/memory/providers/transcript-recall.js +143 -141
  520. package/dist/core/memory/providers/transcript-recall.js.map +1 -1
  521. package/dist/core/memory/providers/user-memory-archive.d.ts +39 -0
  522. package/dist/core/memory/providers/user-memory-archive.d.ts.map +1 -0
  523. package/dist/core/memory/providers/user-memory-archive.js +258 -0
  524. package/dist/core/memory/providers/user-memory-archive.js.map +1 -0
  525. package/dist/core/memory/transcript-index.d.ts.map +1 -1
  526. package/dist/core/memory/transcript-index.js +1 -1
  527. package/dist/core/memory/transcript-index.js.map +1 -1
  528. package/dist/core/memory-controller.d.ts +9 -0
  529. package/dist/core/memory-controller.d.ts.map +1 -1
  530. package/dist/core/memory-controller.js +57 -16
  531. package/dist/core/memory-controller.js.map +1 -1
  532. package/dist/core/model-capability.d.ts.map +1 -1
  533. package/dist/core/model-capability.js.map +1 -1
  534. package/dist/core/model-output-json.d.ts +10 -0
  535. package/dist/core/model-output-json.d.ts.map +1 -0
  536. package/dist/core/model-output-json.js +43 -0
  537. package/dist/core/model-output-json.js.map +1 -0
  538. package/dist/core/model-registry.d.ts +8 -8
  539. package/dist/core/model-registry.d.ts.map +1 -1
  540. package/dist/core/model-registry.js +29 -52
  541. package/dist/core/model-registry.js.map +1 -1
  542. package/dist/core/model-resolver.d.ts.map +1 -1
  543. package/dist/core/model-resolver.js +1 -1
  544. package/dist/core/model-resolver.js.map +1 -1
  545. package/dist/core/model-router/config-diagnostics.d.ts.map +1 -1
  546. package/dist/core/model-router/config-diagnostics.js.map +1 -1
  547. package/dist/core/model-router/executor-route.d.ts.map +1 -1
  548. package/dist/core/model-router/executor-route.js.map +1 -1
  549. package/dist/core/model-router/fitness-gate.d.ts.map +1 -1
  550. package/dist/core/model-router/fitness-gate.js.map +1 -1
  551. package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
  552. package/dist/core/model-router/route-judge.d.ts.map +1 -1
  553. package/dist/core/model-router/route-judge.js +18 -36
  554. package/dist/core/model-router/route-judge.js.map +1 -1
  555. package/dist/core/model-router/session-buffer.d.ts.map +1 -1
  556. package/dist/core/model-router/session-buffer.js.map +1 -1
  557. package/dist/core/model-router/status.d.ts.map +1 -1
  558. package/dist/core/model-router/status.js.map +1 -1
  559. package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
  560. package/dist/core/model-router/tool-escalation.js.map +1 -1
  561. package/dist/core/model-router-controller.d.ts +1 -0
  562. package/dist/core/model-router-controller.d.ts.map +1 -1
  563. package/dist/core/model-router-controller.js +25 -56
  564. package/dist/core/model-router-controller.js.map +1 -1
  565. package/dist/core/model-selection-controller.d.ts +10 -0
  566. package/dist/core/model-selection-controller.d.ts.map +1 -1
  567. package/dist/core/model-selection-controller.js +0 -1
  568. package/dist/core/model-selection-controller.js.map +1 -1
  569. package/dist/core/model-tool-protocol.d.ts.map +1 -1
  570. package/dist/core/model-tool-protocol.js.map +1 -1
  571. package/dist/core/models/adaptation-store.d.ts.map +1 -1
  572. package/dist/core/models/adaptation-store.js +0 -1
  573. package/dist/core/models/adaptation-store.js.map +1 -1
  574. package/dist/core/models/context-sizing.d.ts.map +1 -1
  575. package/dist/core/models/context-sizing.js.map +1 -1
  576. package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
  577. package/dist/core/models/default-model-suggestions.js.map +1 -1
  578. package/dist/core/models/fitness-store.d.ts.map +1 -1
  579. package/dist/core/models/fitness-store.js +0 -1
  580. package/dist/core/models/fitness-store.js.map +1 -1
  581. package/dist/core/models/host-state-store.d.ts.map +1 -1
  582. package/dist/core/models/host-state-store.js +1 -6
  583. package/dist/core/models/host-state-store.js.map +1 -1
  584. package/dist/core/models/llamacpp-runtime.d.ts +4 -19
  585. package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
  586. package/dist/core/models/llamacpp-runtime.js +32 -136
  587. package/dist/core/models/llamacpp-runtime.js.map +1 -1
  588. package/dist/core/models/local-registration.d.ts.map +1 -1
  589. package/dist/core/models/local-registration.js +82 -115
  590. package/dist/core/models/local-registration.js.map +1 -1
  591. package/dist/core/models/local-runtime.d.ts +12 -18
  592. package/dist/core/models/local-runtime.d.ts.map +1 -1
  593. package/dist/core/models/local-runtime.js +60 -204
  594. package/dist/core/models/local-runtime.js.map +1 -1
  595. package/dist/core/models/model-endpoint.d.ts +3 -0
  596. package/dist/core/models/model-endpoint.d.ts.map +1 -0
  597. package/dist/core/models/model-endpoint.js +11 -0
  598. package/dist/core/models/model-endpoint.js.map +1 -0
  599. package/dist/core/models/model-ref.d.ts.map +1 -1
  600. package/dist/core/models/model-ref.js.map +1 -1
  601. package/dist/core/models/needle-runtime.d.ts +7 -3
  602. package/dist/core/models/needle-runtime.d.ts.map +1 -1
  603. package/dist/core/models/needle-runtime.js +16 -92
  604. package/dist/core/models/needle-runtime.js.map +1 -1
  605. package/dist/core/models/perf-profile.d.ts +1 -1
  606. package/dist/core/models/perf-profile.d.ts.map +1 -1
  607. package/dist/core/models/perf-profile.js +6 -13
  608. package/dist/core/models/perf-profile.js.map +1 -1
  609. package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -1
  610. package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -1
  611. package/dist/core/models/runtime-arbiter.d.ts.map +1 -1
  612. package/dist/core/models/runtime-arbiter.js +3 -15
  613. package/dist/core/models/runtime-arbiter.js.map +1 -1
  614. package/dist/core/models/runtime-process.d.ts +100 -0
  615. package/dist/core/models/runtime-process.d.ts.map +1 -0
  616. package/dist/core/models/runtime-process.js +183 -0
  617. package/dist/core/models/runtime-process.js.map +1 -0
  618. package/dist/core/orchestration/agent-resume.d.ts +2 -0
  619. package/dist/core/orchestration/agent-resume.d.ts.map +1 -1
  620. package/dist/core/orchestration/agent-resume.js +7 -0
  621. package/dist/core/orchestration/agent-resume.js.map +1 -1
  622. package/dist/core/orchestration/attempt-usage.d.ts +28 -0
  623. package/dist/core/orchestration/attempt-usage.d.ts.map +1 -0
  624. package/dist/core/orchestration/attempt-usage.js +168 -0
  625. package/dist/core/orchestration/attempt-usage.js.map +1 -0
  626. package/dist/core/orchestration/capability-gateway.d.ts +19 -1
  627. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
  628. package/dist/core/orchestration/capability-gateway.js +120 -34
  629. package/dist/core/orchestration/capability-gateway.js.map +1 -1
  630. package/dist/core/orchestration/contracts.d.ts +35 -0
  631. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  632. package/dist/core/orchestration/contracts.js +17 -0
  633. package/dist/core/orchestration/contracts.js.map +1 -1
  634. package/dist/core/orchestration/delegation-ledger.d.ts +17 -2
  635. package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
  636. package/dist/core/orchestration/delegation-ledger.js +78 -5
  637. package/dist/core/orchestration/delegation-ledger.js.map +1 -1
  638. package/dist/core/orchestration/event-store.d.ts +1 -0
  639. package/dist/core/orchestration/event-store.d.ts.map +1 -1
  640. package/dist/core/orchestration/event-store.js +79 -52
  641. package/dist/core/orchestration/event-store.js.map +1 -1
  642. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  643. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  644. package/dist/core/orchestration/model-binding.d.ts.map +1 -1
  645. package/dist/core/orchestration/model-binding.js.map +1 -1
  646. package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
  647. package/dist/core/orchestration/policy-compiler.js +0 -3
  648. package/dist/core/orchestration/policy-compiler.js.map +1 -1
  649. package/dist/core/orchestration/policy-gate.d.ts.map +1 -1
  650. package/dist/core/orchestration/policy-gate.js +0 -2
  651. package/dist/core/orchestration/policy-gate.js.map +1 -1
  652. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  653. package/dist/core/orchestration/profile-registry.js +82 -42
  654. package/dist/core/orchestration/profile-registry.js.map +1 -1
  655. package/dist/core/orchestration/profile-store.d.ts.map +1 -1
  656. package/dist/core/orchestration/profile-store.js +18 -7
  657. package/dist/core/orchestration/profile-store.js.map +1 -1
  658. package/dist/core/orchestration/risk-budget.d.ts +2 -0
  659. package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
  660. package/dist/core/orchestration/risk-budget.js +26 -0
  661. package/dist/core/orchestration/risk-budget.js.map +1 -1
  662. package/dist/core/orchestration/task-runtime.d.ts +14 -1
  663. package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
  664. package/dist/core/orchestration/task-runtime.js +153 -57
  665. package/dist/core/orchestration/task-runtime.js.map +1 -1
  666. package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
  667. package/dist/core/orchestration/work-state-projection.js.map +1 -1
  668. package/dist/core/orchestration/worker-execution-contract.d.ts +3 -1
  669. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
  670. package/dist/core/orchestration/worker-execution-contract.js +75 -23
  671. package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
  672. package/dist/core/orchestration/worker-result-adapter.d.ts +9 -3
  673. package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -1
  674. package/dist/core/orchestration/worker-result-adapter.js +167 -14
  675. package/dist/core/orchestration/worker-result-adapter.js.map +1 -1
  676. package/dist/core/output-guard.d.ts.map +1 -1
  677. package/dist/core/output-guard.js.map +1 -1
  678. package/dist/core/package-manager.d.ts +3 -0
  679. package/dist/core/package-manager.d.ts.map +1 -1
  680. package/dist/core/package-manager.js +88 -353
  681. package/dist/core/package-manager.js.map +1 -1
  682. package/dist/core/process-identity.d.ts.map +1 -1
  683. package/dist/core/process-identity.js.map +1 -1
  684. package/dist/core/process-liveness.d.ts +3 -0
  685. package/dist/core/process-liveness.d.ts.map +1 -0
  686. package/dist/core/process-liveness.js +17 -0
  687. package/dist/core/process-liveness.js.map +1 -0
  688. package/dist/core/process-matrix/codes.d.ts.map +1 -1
  689. package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -1
  690. package/dist/core/process-matrix/resume-launcher.js.map +1 -1
  691. package/dist/core/process-matrix/runtime.d.ts.map +1 -1
  692. package/dist/core/process-matrix/runtime.js.map +1 -1
  693. package/dist/core/process-matrix/store.d.ts.map +1 -1
  694. package/dist/core/process-matrix/store.js.map +1 -1
  695. package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
  696. package/dist/core/process-matrix/supervisor.js.map +1 -1
  697. package/dist/core/profile-filter-controller.d.ts.map +1 -1
  698. package/dist/core/profile-filter-controller.js +7 -8
  699. package/dist/core/profile-filter-controller.js.map +1 -1
  700. package/dist/core/profile-registry.d.ts.map +1 -1
  701. package/dist/core/profile-registry.js +1 -2
  702. package/dist/core/profile-registry.js.map +1 -1
  703. package/dist/core/profile-resource-selection.d.ts.map +1 -1
  704. package/dist/core/profile-resource-selection.js +18 -59
  705. package/dist/core/profile-resource-selection.js.map +1 -1
  706. package/dist/core/prompt-markup.d.ts +3 -0
  707. package/dist/core/prompt-markup.d.ts.map +1 -0
  708. package/dist/core/prompt-markup.js +7 -0
  709. package/dist/core/prompt-markup.js.map +1 -0
  710. package/dist/core/prompt-templates.d.ts.map +1 -1
  711. package/dist/core/prompt-templates.js +13 -39
  712. package/dist/core/prompt-templates.js.map +1 -1
  713. package/dist/core/provider-display-names.d.ts.map +1 -1
  714. package/dist/core/python-runtime.d.ts.map +1 -1
  715. package/dist/core/python-runtime.js.map +1 -1
  716. package/dist/core/reflection-controller.d.ts +23 -2
  717. package/dist/core/reflection-controller.d.ts.map +1 -1
  718. package/dist/core/reflection-controller.js +233 -79
  719. package/dist/core/reflection-controller.js.map +1 -1
  720. package/dist/core/reload-blockers.d.ts +2 -1
  721. package/dist/core/reload-blockers.d.ts.map +1 -1
  722. package/dist/core/reload-blockers.js +4 -14
  723. package/dist/core/reload-blockers.js.map +1 -1
  724. package/dist/core/request-auth.d.ts.map +1 -1
  725. package/dist/core/request-auth.js.map +1 -1
  726. package/dist/core/research/automata-provider.d.ts.map +1 -1
  727. package/dist/core/research/automata-provider.js.map +1 -1
  728. package/dist/core/research/evidence-bundle.d.ts +20 -0
  729. package/dist/core/research/evidence-bundle.d.ts.map +1 -1
  730. package/dist/core/research/evidence-bundle.js +173 -69
  731. package/dist/core/research/evidence-bundle.js.map +1 -1
  732. package/dist/core/research/lane-model-resolver.d.ts.map +1 -1
  733. package/dist/core/research/lane-model-resolver.js +0 -1
  734. package/dist/core/research/lane-model-resolver.js.map +1 -1
  735. package/dist/core/research/model-fitness-controller.d.ts.map +1 -1
  736. package/dist/core/research/model-fitness-controller.js +17 -33
  737. package/dist/core/research/model-fitness-controller.js.map +1 -1
  738. package/dist/core/research/model-fitness.d.ts.map +1 -1
  739. package/dist/core/research/model-fitness.js +4 -25
  740. package/dist/core/research/model-fitness.js.map +1 -1
  741. package/dist/core/research/research-gate.d.ts.map +1 -1
  742. package/dist/core/research/research-gate.js.map +1 -1
  743. package/dist/core/research/research-lane-controller.d.ts.map +1 -1
  744. package/dist/core/research/research-lane-controller.js +5 -10
  745. package/dist/core/research/research-lane-controller.js.map +1 -1
  746. package/dist/core/research/research-runner.d.ts +2 -4
  747. package/dist/core/research/research-runner.d.ts.map +1 -1
  748. package/dist/core/research/research-runner.js +17 -48
  749. package/dist/core/research/research-runner.js.map +1 -1
  750. package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
  751. package/dist/core/research/session-evidence-bundle.js.map +1 -1
  752. package/dist/core/research/workspace-collector.d.ts.map +1 -1
  753. package/dist/core/research/workspace-collector.js.map +1 -1
  754. package/dist/core/resolve-config-value.d.ts.map +1 -1
  755. package/dist/core/resolve-config-value.js.map +1 -1
  756. package/dist/core/resource-ignore.d.ts +6 -0
  757. package/dist/core/resource-ignore.d.ts.map +1 -0
  758. package/dist/core/resource-ignore.js +44 -0
  759. package/dist/core/resource-ignore.js.map +1 -0
  760. package/dist/core/resource-loader.d.ts +0 -1
  761. package/dist/core/resource-loader.d.ts.map +1 -1
  762. package/dist/core/resource-loader.js +52 -187
  763. package/dist/core/resource-loader.js.map +1 -1
  764. package/dist/core/resource-profile-blocks.d.ts +3 -1
  765. package/dist/core/resource-profile-blocks.d.ts.map +1 -1
  766. package/dist/core/resource-profile-blocks.js +8 -5
  767. package/dist/core/resource-profile-blocks.js.map +1 -1
  768. package/dist/core/resource-profile-equality.d.ts.map +1 -1
  769. package/dist/core/resource-profile-equality.js.map +1 -1
  770. package/dist/core/resource-traversal.d.ts +43 -0
  771. package/dist/core/resource-traversal.d.ts.map +1 -0
  772. package/dist/core/resource-traversal.js +84 -0
  773. package/dist/core/resource-traversal.js.map +1 -0
  774. package/dist/core/risk-classifier.d.ts.map +1 -1
  775. package/dist/core/risk-classifier.js.map +1 -1
  776. package/dist/core/runtime-builder.d.ts +11 -1
  777. package/dist/core/runtime-builder.d.ts.map +1 -1
  778. package/dist/core/runtime-builder.js +40 -51
  779. package/dist/core/runtime-builder.js.map +1 -1
  780. package/dist/core/scout-controller.d.ts.map +1 -1
  781. package/dist/core/scout-controller.js +0 -1
  782. package/dist/core/scout-controller.js.map +1 -1
  783. package/dist/core/sdk.d.ts.map +1 -1
  784. package/dist/core/sdk.js.map +1 -1
  785. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
  786. package/dist/core/secrets/credential-exposure-guard.js +70 -44
  787. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  788. package/dist/core/secrets/secret-dotenv.d.ts.map +1 -1
  789. package/dist/core/secrets/secret-dotenv.js +0 -1
  790. package/dist/core/secrets/secret-dotenv.js.map +1 -1
  791. package/dist/core/secrets/secret-vault-format.d.ts.map +1 -1
  792. package/dist/core/secrets/secret-vault-format.js +0 -1
  793. package/dist/core/secrets/secret-vault-format.js.map +1 -1
  794. package/dist/core/secrets/secret-vault.d.ts.map +1 -1
  795. package/dist/core/secrets/secret-vault.js +2 -10
  796. package/dist/core/secrets/secret-vault.js.map +1 -1
  797. package/dist/core/security/secret-text.d.ts.map +1 -1
  798. package/dist/core/security/secret-text.js.map +1 -1
  799. package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
  800. package/dist/core/security/untrusted-boundary.js.map +1 -1
  801. package/dist/core/session-analytics.d.ts.map +1 -1
  802. package/dist/core/session-analytics.js +18 -50
  803. package/dist/core/session-analytics.js.map +1 -1
  804. package/dist/core/session-artifact-bundle.d.ts +35 -0
  805. package/dist/core/session-artifact-bundle.d.ts.map +1 -0
  806. package/dist/core/session-artifact-bundle.js +61 -0
  807. package/dist/core/session-artifact-bundle.js.map +1 -0
  808. package/dist/core/session-cwd.d.ts.map +1 -1
  809. package/dist/core/session-cwd.js +0 -1
  810. package/dist/core/session-cwd.js.map +1 -1
  811. package/dist/core/session-entry-index.d.ts +8 -0
  812. package/dist/core/session-entry-index.d.ts.map +1 -0
  813. package/dist/core/session-entry-index.js +16 -0
  814. package/dist/core/session-entry-index.js.map +1 -0
  815. package/dist/core/session-image-store.d.ts.map +1 -1
  816. package/dist/core/session-image-store.js +0 -3
  817. package/dist/core/session-image-store.js.map +1 -1
  818. package/dist/core/session-jsonl-writer.d.ts +3 -0
  819. package/dist/core/session-jsonl-writer.d.ts.map +1 -0
  820. package/dist/core/session-jsonl-writer.js +38 -0
  821. package/dist/core/session-jsonl-writer.js.map +1 -0
  822. package/dist/core/session-manager-factory.d.ts.map +1 -1
  823. package/dist/core/session-manager-factory.js.map +1 -1
  824. package/dist/core/session-role.d.ts.map +1 -1
  825. package/dist/core/session-role.js.map +1 -1
  826. package/dist/core/session-snapshot.d.ts.map +1 -1
  827. package/dist/core/session-snapshot.js.map +1 -1
  828. package/dist/core/session-supervision-runtime.d.ts.map +1 -1
  829. package/dist/core/session-supervision-runtime.js +1 -4
  830. package/dist/core/session-supervision-runtime.js.map +1 -1
  831. package/dist/core/session-tree-navigator.d.ts.map +1 -1
  832. package/dist/core/session-tree-navigator.js +0 -1
  833. package/dist/core/session-tree-navigator.js.map +1 -1
  834. package/dist/core/settings-manager.d.ts +2 -1
  835. package/dist/core/settings-manager.d.ts.map +1 -1
  836. package/dist/core/settings-manager.js +64 -162
  837. package/dist/core/settings-manager.js.map +1 -1
  838. package/dist/core/skill-block.d.mts +8 -0
  839. package/dist/core/skill-block.mjs +52 -0
  840. package/dist/core/skill-discovery.d.ts +5 -0
  841. package/dist/core/skill-discovery.d.ts.map +1 -0
  842. package/dist/core/skill-discovery.js +34 -0
  843. package/dist/core/skill-discovery.js.map +1 -0
  844. package/dist/core/skills.d.ts.map +1 -1
  845. package/dist/core/skills.js +23 -159
  846. package/dist/core/skills.js.map +1 -1
  847. package/dist/core/slash-commands.d.ts.map +1 -1
  848. package/dist/core/source-info.d.ts.map +1 -1
  849. package/dist/core/source-info.js.map +1 -1
  850. package/dist/core/spawned-usage.d.ts +21 -0
  851. package/dist/core/spawned-usage.d.ts.map +1 -0
  852. package/dist/core/spawned-usage.js +29 -0
  853. package/dist/core/spawned-usage.js.map +1 -0
  854. package/dist/core/system-prompt-builder.d.ts +4 -0
  855. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  856. package/dist/core/system-prompt-builder.js +15 -8
  857. package/dist/core/system-prompt-builder.js.map +1 -1
  858. package/dist/core/system-prompt.d.ts.map +1 -1
  859. package/dist/core/system-prompt.js +52 -35
  860. package/dist/core/system-prompt.js.map +1 -1
  861. package/dist/core/tasks/session-task-state.d.ts.map +1 -1
  862. package/dist/core/tasks/session-task-state.js.map +1 -1
  863. package/dist/core/tasks/task-command.d.ts.map +1 -1
  864. package/dist/core/tasks/task-command.js.map +1 -1
  865. package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -1
  866. package/dist/core/tasks/task-contract-monitor.js.map +1 -1
  867. package/dist/core/tasks/task-projection.d.ts.map +1 -1
  868. package/dist/core/tasks/task-projection.js.map +1 -1
  869. package/dist/core/tasks/task-state.d.ts.map +1 -1
  870. package/dist/core/tasks/task-state.js.map +1 -1
  871. package/dist/core/text-preview.d.ts +4 -0
  872. package/dist/core/text-preview.d.ts.map +1 -0
  873. package/dist/core/text-preview.js +33 -0
  874. package/dist/core/text-preview.js.map +1 -0
  875. package/dist/core/timings.d.ts.map +1 -1
  876. package/dist/core/timings.js.map +1 -1
  877. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  878. package/dist/core/tool-capability-policy.js.map +1 -1
  879. package/dist/core/tool-gate-controller.d.ts.map +1 -1
  880. package/dist/core/tool-gate-controller.js +86 -87
  881. package/dist/core/tool-gate-controller.js.map +1 -1
  882. package/dist/core/tool-protocol-controller.d.ts +4 -1
  883. package/dist/core/tool-protocol-controller.d.ts.map +1 -1
  884. package/dist/core/tool-protocol-controller.js +19 -23
  885. package/dist/core/tool-protocol-controller.js.map +1 -1
  886. package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
  887. package/dist/core/tool-recovery-log-records.js.map +1 -1
  888. package/dist/core/tool-recovery-log-worker.d.ts.map +1 -1
  889. package/dist/core/tool-recovery-log-worker.js.map +1 -1
  890. package/dist/core/tool-recovery-logger.d.ts.map +1 -1
  891. package/dist/core/tool-recovery-logger.js +12 -24
  892. package/dist/core/tool-recovery-logger.js.map +1 -1
  893. package/dist/core/tool-recovery-stats.d.ts.map +1 -1
  894. package/dist/core/tool-recovery-stats.js +16 -22
  895. package/dist/core/tool-recovery-stats.js.map +1 -1
  896. package/dist/core/tool-repair-health.d.ts.map +1 -1
  897. package/dist/core/tool-repair-health.js.map +1 -1
  898. package/dist/core/tool-repair-settings.d.ts.map +1 -1
  899. package/dist/core/tool-repair-settings.js.map +1 -1
  900. package/dist/core/tool-selection/expected-utility.d.ts.map +1 -1
  901. package/dist/core/tool-selection/expected-utility.js.map +1 -1
  902. package/dist/core/tool-selection/promotion.d.ts.map +1 -1
  903. package/dist/core/tool-selection/promotion.js.map +1 -1
  904. package/dist/core/tool-selection/tool-performance-store.d.ts +2 -0
  905. package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
  906. package/dist/core/tool-selection/tool-performance-store.js +49 -7
  907. package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
  908. package/dist/core/tool-selection/tool-phase-timing.d.ts +19 -0
  909. package/dist/core/tool-selection/tool-phase-timing.d.ts.map +1 -0
  910. package/dist/core/tool-selection/tool-phase-timing.js +63 -0
  911. package/dist/core/tool-selection/tool-phase-timing.js.map +1 -0
  912. package/dist/core/tool-selection/tool-selection-controller.d.ts +2 -5
  913. package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
  914. package/dist/core/tool-selection/tool-selection-controller.js +50 -30
  915. package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
  916. package/dist/core/toolkit/reflex-interpreter.d.ts +16 -0
  917. package/dist/core/toolkit/reflex-interpreter.d.ts.map +1 -1
  918. package/dist/core/toolkit/reflex-interpreter.js +21 -0
  919. package/dist/core/toolkit/reflex-interpreter.js.map +1 -1
  920. package/dist/core/toolkit/script-registry.d.ts.map +1 -1
  921. package/dist/core/toolkit/script-registry.js.map +1 -1
  922. package/dist/core/toolkit/script-runner.d.ts.map +1 -1
  923. package/dist/core/toolkit/script-runner.js.map +1 -1
  924. package/dist/core/tools/artifact-retrieve.d.ts.map +1 -1
  925. package/dist/core/tools/artifact-retrieve.js.map +1 -1
  926. package/dist/core/tools/ask-question.d.ts +2 -3
  927. package/dist/core/tools/ask-question.d.ts.map +1 -1
  928. package/dist/core/tools/ask-question.js +14 -40
  929. package/dist/core/tools/ask-question.js.map +1 -1
  930. package/dist/core/tools/bash.d.ts +2 -0
  931. package/dist/core/tools/bash.d.ts.map +1 -1
  932. package/dist/core/tools/bash.js +83 -30
  933. package/dist/core/tools/bash.js.map +1 -1
  934. package/dist/core/tools/context-scout.d.ts.map +1 -1
  935. package/dist/core/tools/context-scout.js.map +1 -1
  936. package/dist/core/tools/delegate-status.d.ts +6 -1
  937. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  938. package/dist/core/tools/delegate-status.js +109 -25
  939. package/dist/core/tools/delegate-status.js.map +1 -1
  940. package/dist/core/tools/delegate.d.ts +9 -1
  941. package/dist/core/tools/delegate.d.ts.map +1 -1
  942. package/dist/core/tools/delegate.js +329 -67
  943. package/dist/core/tools/delegate.js.map +1 -1
  944. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  945. package/dist/core/tools/edit-diff.js.map +1 -1
  946. package/dist/core/tools/edit.d.ts.map +1 -1
  947. package/dist/core/tools/edit.js.map +1 -1
  948. package/dist/core/tools/extensionify.d.ts.map +1 -1
  949. package/dist/core/tools/extensionify.js.map +1 -1
  950. package/dist/core/tools/fff-search-backend.d.ts +19 -0
  951. package/dist/core/tools/fff-search-backend.d.ts.map +1 -1
  952. package/dist/core/tools/fff-search-backend.js +28 -2
  953. package/dist/core/tools/fff-search-backend.js.map +1 -1
  954. package/dist/core/tools/file-encoding-policy.d.ts.map +1 -1
  955. package/dist/core/tools/file-encoding-policy.js.map +1 -1
  956. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  957. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  958. package/dist/core/tools/find.d.ts +1 -1
  959. package/dist/core/tools/find.d.ts.map +1 -1
  960. package/dist/core/tools/find.js +44 -108
  961. package/dist/core/tools/find.js.map +1 -1
  962. package/dist/core/tools/git-filter.d.ts.map +1 -1
  963. package/dist/core/tools/git-filter.js.map +1 -1
  964. package/dist/core/tools/goal.d.ts.map +1 -1
  965. package/dist/core/tools/goal.js +7 -7
  966. package/dist/core/tools/goal.js.map +1 -1
  967. package/dist/core/tools/grep.d.ts +1 -1
  968. package/dist/core/tools/grep.d.ts.map +1 -1
  969. package/dist/core/tools/grep.js +42 -102
  970. package/dist/core/tools/grep.js.map +1 -1
  971. package/dist/core/tools/index.d.ts.map +1 -1
  972. package/dist/core/tools/index.js.map +1 -1
  973. package/dist/core/tools/ls.d.ts.map +1 -1
  974. package/dist/core/tools/ls.js +20 -36
  975. package/dist/core/tools/ls.js.map +1 -1
  976. package/dist/core/tools/model-fitness.d.ts.map +1 -1
  977. package/dist/core/tools/model-fitness.js.map +1 -1
  978. package/dist/core/tools/orchestration-panel.d.ts +5 -0
  979. package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
  980. package/dist/core/tools/orchestration-panel.js +5 -5
  981. package/dist/core/tools/orchestration-panel.js.map +1 -1
  982. package/dist/core/tools/output-accumulator.d.ts +2 -0
  983. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  984. package/dist/core/tools/output-accumulator.js +24 -36
  985. package/dist/core/tools/output-accumulator.js.map +1 -1
  986. package/dist/core/tools/path-utils.d.ts.map +1 -1
  987. package/dist/core/tools/path-utils.js.map +1 -1
  988. package/dist/core/tools/persistent-process-coordinator.d.ts +31 -0
  989. package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -0
  990. package/dist/core/tools/persistent-process-coordinator.js +123 -0
  991. package/dist/core/tools/persistent-process-coordinator.js.map +1 -0
  992. package/dist/core/tools/python.d.ts.map +1 -1
  993. package/dist/core/tools/python.js.map +1 -1
  994. package/dist/core/tools/read.d.ts.map +1 -1
  995. package/dist/core/tools/read.js +14 -13
  996. package/dist/core/tools/read.js.map +1 -1
  997. package/dist/core/tools/render-utils.d.ts +29 -0
  998. package/dist/core/tools/render-utils.d.ts.map +1 -1
  999. package/dist/core/tools/render-utils.js +31 -1
  1000. package/dist/core/tools/render-utils.js.map +1 -1
  1001. package/dist/core/tools/run-process.d.ts +1 -1
  1002. package/dist/core/tools/run-process.d.ts.map +1 -1
  1003. package/dist/core/tools/run-process.js +69 -9
  1004. package/dist/core/tools/run-process.js.map +1 -1
  1005. package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
  1006. package/dist/core/tools/run-toolkit-script.js.map +1 -1
  1007. package/dist/core/tools/search-command-guard.d.ts +10 -0
  1008. package/dist/core/tools/search-command-guard.d.ts.map +1 -1
  1009. package/dist/core/tools/search-command-guard.js +118 -31
  1010. package/dist/core/tools/search-command-guard.js.map +1 -1
  1011. package/dist/core/tools/search-router.d.ts.map +1 -1
  1012. package/dist/core/tools/search-router.js.map +1 -1
  1013. package/dist/core/tools/search-tool-runtime.d.ts +19 -0
  1014. package/dist/core/tools/search-tool-runtime.d.ts.map +1 -0
  1015. package/dist/core/tools/search-tool-runtime.js +12 -0
  1016. package/dist/core/tools/search-tool-runtime.js.map +1 -0
  1017. package/dist/core/tools/secret-store.d.ts.map +1 -1
  1018. package/dist/core/tools/secret-store.js.map +1 -1
  1019. package/dist/core/tools/shell-command-parser.d.ts.map +1 -1
  1020. package/dist/core/tools/shell-command-parser.js.map +1 -1
  1021. package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
  1022. package/dist/core/tools/shell-contract-router.js +16 -6
  1023. package/dist/core/tools/shell-contract-router.js.map +1 -1
  1024. package/dist/core/tools/shell-execution-session.d.ts +4 -0
  1025. package/dist/core/tools/shell-execution-session.d.ts.map +1 -0
  1026. package/dist/core/tools/shell-execution-session.js +11 -0
  1027. package/dist/core/tools/shell-execution-session.js.map +1 -0
  1028. package/dist/core/tools/shell-output-projection.d.ts +49 -0
  1029. package/dist/core/tools/shell-output-projection.d.ts.map +1 -0
  1030. package/dist/core/tools/shell-output-projection.js +381 -0
  1031. package/dist/core/tools/shell-output-projection.js.map +1 -0
  1032. package/dist/core/tools/shell-session.d.ts +2 -13
  1033. package/dist/core/tools/shell-session.d.ts.map +1 -1
  1034. package/dist/core/tools/shell-session.js +36 -136
  1035. package/dist/core/tools/shell-session.js.map +1 -1
  1036. package/dist/core/tools/skill-audit.d.ts.map +1 -1
  1037. package/dist/core/tools/skill-audit.js.map +1 -1
  1038. package/dist/core/tools/skillify.d.ts.map +1 -1
  1039. package/dist/core/tools/skillify.js.map +1 -1
  1040. package/dist/core/tools/task-steps.d.ts +8 -8
  1041. package/dist/core/tools/task-steps.d.ts.map +1 -1
  1042. package/dist/core/tools/task-steps.js +17 -18
  1043. package/dist/core/tools/task-steps.js.map +1 -1
  1044. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
  1045. package/dist/core/tools/tmux-dispatch.js.map +1 -1
  1046. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  1047. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  1048. package/dist/core/tools/tool-task.d.ts +23 -0
  1049. package/dist/core/tools/tool-task.d.ts.map +1 -0
  1050. package/dist/core/tools/tool-task.js +93 -0
  1051. package/dist/core/tools/tool-task.js.map +1 -0
  1052. package/dist/core/tools/windows-shell-engine.d.ts +17 -11
  1053. package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
  1054. package/dist/core/tools/windows-shell-engine.js +339 -117
  1055. package/dist/core/tools/windows-shell-engine.js.map +1 -1
  1056. package/dist/core/tools/windows-shell-state.d.ts.map +1 -1
  1057. package/dist/core/tools/windows-shell-state.js.map +1 -1
  1058. package/dist/core/tools/worktree-sync.d.ts.map +1 -1
  1059. package/dist/core/tools/worktree-sync.js +8 -12
  1060. package/dist/core/tools/worktree-sync.js.map +1 -1
  1061. package/dist/core/tools/write.d.ts.map +1 -1
  1062. package/dist/core/tools/write.js +0 -1
  1063. package/dist/core/tools/write.js.map +1 -1
  1064. package/dist/core/trust-manager.d.ts.map +1 -1
  1065. package/dist/core/trust-manager.js +7 -40
  1066. package/dist/core/trust-manager.js.map +1 -1
  1067. package/dist/core/util/atomic-file.d.ts +19 -0
  1068. package/dist/core/util/atomic-file.d.ts.map +1 -1
  1069. package/dist/core/util/atomic-file.js +50 -15
  1070. package/dist/core/util/atomic-file.js.map +1 -1
  1071. package/dist/core/util/bounded-file.d.ts +15 -0
  1072. package/dist/core/util/bounded-file.d.ts.map +1 -0
  1073. package/dist/core/util/bounded-file.js +120 -0
  1074. package/dist/core/util/bounded-file.js.map +1 -0
  1075. package/dist/core/util/bounded-jsonl.d.ts.map +1 -1
  1076. package/dist/core/util/bounded-jsonl.js +112 -9
  1077. package/dist/core/util/bounded-jsonl.js.map +1 -1
  1078. package/dist/core/util/bounded-value.d.ts +3 -0
  1079. package/dist/core/util/bounded-value.d.ts.map +1 -0
  1080. package/dist/core/util/bounded-value.js +12 -0
  1081. package/dist/core/util/bounded-value.js.map +1 -0
  1082. package/dist/core/util/json-size.d.ts +3 -0
  1083. package/dist/core/util/json-size.d.ts.map +1 -0
  1084. package/dist/core/util/json-size.js +95 -0
  1085. package/dist/core/util/json-size.js.map +1 -0
  1086. package/dist/core/util/minimatch-cache.d.ts.map +1 -1
  1087. package/dist/core/util/minimatch-cache.js.map +1 -1
  1088. package/dist/core/util/value-guards.d.ts +2 -0
  1089. package/dist/core/util/value-guards.d.ts.map +1 -1
  1090. package/dist/core/util/value-guards.js +5 -0
  1091. package/dist/core/util/value-guards.js.map +1 -1
  1092. package/dist/core/worktree-sync/codes.d.ts.map +1 -1
  1093. package/dist/core/worktree-sync/git-engine.d.ts.map +1 -1
  1094. package/dist/core/worktree-sync/git-engine.js +20 -36
  1095. package/dist/core/worktree-sync/git-engine.js.map +1 -1
  1096. package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
  1097. package/dist/core/worktree-sync/lane-gate.js +1 -4
  1098. package/dist/core/worktree-sync/lane-gate.js.map +1 -1
  1099. package/dist/core/worktree-sync/runtime.d.ts.map +1 -1
  1100. package/dist/core/worktree-sync/runtime.js.map +1 -1
  1101. package/dist/core/worktree-sync/store.d.ts.map +1 -1
  1102. package/dist/core/worktree-sync/store.js.map +1 -1
  1103. package/dist/core/worktree-sync/watcher.d.ts.map +1 -1
  1104. package/dist/core/worktree-sync/watcher.js.map +1 -1
  1105. package/dist/index.d.ts.map +1 -1
  1106. package/dist/index.js.map +1 -1
  1107. package/dist/main.d.ts.map +1 -1
  1108. package/dist/main.js +10 -32
  1109. package/dist/main.js.map +1 -1
  1110. package/dist/migrations.d.ts.map +1 -1
  1111. package/dist/migrations.js +6 -19
  1112. package/dist/migrations.js.map +1 -1
  1113. package/dist/modes/index.d.ts.map +1 -1
  1114. package/dist/modes/interactive/auth-dialogs-controller.d.ts +3 -0
  1115. package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
  1116. package/dist/modes/interactive/auth-dialogs-controller.js +96 -132
  1117. package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
  1118. package/dist/modes/interactive/auto-learn-controller.d.ts +1 -31
  1119. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
  1120. package/dist/modes/interactive/auto-learn-controller.js +86 -307
  1121. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  1122. package/dist/modes/interactive/autocomplete-provider.d.ts.map +1 -1
  1123. package/dist/modes/interactive/autocomplete-provider.js.map +1 -1
  1124. package/dist/modes/interactive/autonomy-commands.d.ts.map +1 -1
  1125. package/dist/modes/interactive/autonomy-commands.js +2 -8
  1126. package/dist/modes/interactive/autonomy-commands.js.map +1 -1
  1127. package/dist/modes/interactive/clipboard-input.d.ts +5 -1
  1128. package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
  1129. package/dist/modes/interactive/clipboard-input.js +17 -0
  1130. package/dist/modes/interactive/clipboard-input.js.map +1 -1
  1131. package/dist/modes/interactive/compaction-queue.d.ts.map +1 -1
  1132. package/dist/modes/interactive/compaction-queue.js +13 -18
  1133. package/dist/modes/interactive/compaction-queue.js.map +1 -1
  1134. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
  1135. package/dist/modes/interactive/components/activity-lane.js +6 -10
  1136. package/dist/modes/interactive/components/activity-lane.js.map +1 -1
  1137. package/dist/modes/interactive/components/armin.d.ts +1 -0
  1138. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  1139. package/dist/modes/interactive/components/armin.js +10 -21
  1140. package/dist/modes/interactive/components/armin.js.map +1 -1
  1141. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  1142. package/dist/modes/interactive/components/assistant-message.js +1 -6
  1143. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  1144. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  1145. package/dist/modes/interactive/components/bash-execution.js +4 -9
  1146. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  1147. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  1148. package/dist/modes/interactive/components/bordered-loader.js +0 -3
  1149. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  1150. package/dist/modes/interactive/components/branch-summary-message.d.ts +3 -8
  1151. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  1152. package/dist/modes/interactive/components/branch-summary-message.js +13 -35
  1153. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  1154. package/dist/modes/interactive/components/compaction-summary-message.d.ts +3 -8
  1155. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  1156. package/dist/modes/interactive/components/compaction-summary-message.js +14 -36
  1157. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  1158. package/dist/modes/interactive/components/config-selector.d.ts +1 -0
  1159. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  1160. package/dist/modes/interactive/components/config-selector.js +20 -43
  1161. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  1162. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  1163. package/dist/modes/interactive/components/countdown-timer.js +0 -5
  1164. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  1165. package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
  1166. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  1167. package/dist/modes/interactive/components/custom-editor.js +4 -8
  1168. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  1169. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  1170. package/dist/modes/interactive/components/custom-message.js +1 -6
  1171. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  1172. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  1173. package/dist/modes/interactive/components/daxnuts.js +6 -8
  1174. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  1175. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  1176. package/dist/modes/interactive/components/diff.js.map +1 -1
  1177. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  1178. package/dist/modes/interactive/components/dynamic-border.js +0 -1
  1179. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  1180. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  1181. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  1182. package/dist/modes/interactive/components/expandable-markdown-message.d.ts +21 -0
  1183. package/dist/modes/interactive/components/expandable-markdown-message.d.ts.map +1 -0
  1184. package/dist/modes/interactive/components/expandable-markdown-message.js +48 -0
  1185. package/dist/modes/interactive/components/expandable-markdown-message.js.map +1 -0
  1186. package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -1
  1187. package/dist/modes/interactive/components/expandable-text.js +0 -2
  1188. package/dist/modes/interactive/components/expandable-text.js.map +1 -1
  1189. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  1190. package/dist/modes/interactive/components/extension-editor.js +1 -9
  1191. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  1192. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  1193. package/dist/modes/interactive/components/extension-input.js +2 -8
  1194. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  1195. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  1196. package/dist/modes/interactive/components/extension-selector.js +5 -20
  1197. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  1198. package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
  1199. package/dist/modes/interactive/components/fitness-role-selector.js +0 -1
  1200. package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
  1201. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  1202. package/dist/modes/interactive/components/footer.js +1 -5
  1203. package/dist/modes/interactive/components/footer.js.map +1 -1
  1204. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  1205. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  1206. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  1207. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  1208. package/dist/modes/interactive/components/login-dialog.js +4 -10
  1209. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  1210. package/dist/modes/interactive/components/model-selector.d.ts +2 -2
  1211. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  1212. package/dist/modes/interactive/components/model-selector.js +21 -44
  1213. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  1214. package/dist/modes/interactive/components/model-suggestion-selector.d.ts.map +1 -1
  1215. package/dist/modes/interactive/components/model-suggestion-selector.js +0 -1
  1216. package/dist/modes/interactive/components/model-suggestion-selector.js.map +1 -1
  1217. package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
  1218. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  1219. package/dist/modes/interactive/components/oauth-selector.js +16 -32
  1220. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  1221. package/dist/modes/interactive/components/profile-resource-editor.d.ts +3 -4
  1222. package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
  1223. package/dist/modes/interactive/components/profile-resource-editor.js +34 -93
  1224. package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
  1225. package/dist/modes/interactive/components/profile-selector.d.ts.map +1 -1
  1226. package/dist/modes/interactive/components/profile-selector.js +0 -1
  1227. package/dist/modes/interactive/components/profile-selector.js.map +1 -1
  1228. package/dist/modes/interactive/components/scoped-models-selector.d.ts +3 -4
  1229. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  1230. package/dist/modes/interactive/components/scoped-models-selector.js +34 -79
  1231. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  1232. package/dist/modes/interactive/components/selector-list.d.ts +63 -0
  1233. package/dist/modes/interactive/components/selector-list.d.ts.map +1 -0
  1234. package/dist/modes/interactive/components/selector-list.js +186 -0
  1235. package/dist/modes/interactive/components/selector-list.js.map +1 -0
  1236. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  1237. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  1238. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  1239. package/dist/modes/interactive/components/session-selector.js +61 -103
  1240. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  1241. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  1242. package/dist/modes/interactive/components/settings-selector.js +40 -138
  1243. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  1244. package/dist/modes/interactive/components/show-images-selector.d.ts +2 -4
  1245. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  1246. package/dist/modes/interactive/components/show-images-selector.js +9 -28
  1247. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  1248. package/dist/modes/interactive/components/skill-invocation-message.d.ts +3 -8
  1249. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  1250. package/dist/modes/interactive/components/skill-invocation-message.js +12 -40
  1251. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  1252. package/dist/modes/interactive/components/theme-selector.d.ts +2 -5
  1253. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  1254. package/dist/modes/interactive/components/theme-selector.js +11 -37
  1255. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  1256. package/dist/modes/interactive/components/thinking-selector.d.ts +2 -4
  1257. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  1258. package/dist/modes/interactive/components/thinking-selector.js +9 -31
  1259. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  1260. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  1261. package/dist/modes/interactive/components/tool-execution.js +9 -28
  1262. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  1263. package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
  1264. package/dist/modes/interactive/components/tool-group.js +2 -3
  1265. package/dist/modes/interactive/components/tool-group.js.map +1 -1
  1266. package/dist/modes/interactive/components/tool-panel-registry.d.ts.map +1 -1
  1267. package/dist/modes/interactive/components/tool-panel-registry.js +5 -3
  1268. package/dist/modes/interactive/components/tool-panel-registry.js.map +1 -1
  1269. package/dist/modes/interactive/components/tool-title.d.ts.map +1 -1
  1270. package/dist/modes/interactive/components/tool-title.js +0 -4
  1271. package/dist/modes/interactive/components/tool-title.js.map +1 -1
  1272. package/dist/modes/interactive/components/transcript-pager.d.ts +26 -0
  1273. package/dist/modes/interactive/components/transcript-pager.d.ts.map +1 -0
  1274. package/dist/modes/interactive/components/transcript-pager.js +81 -0
  1275. package/dist/modes/interactive/components/transcript-pager.js.map +1 -0
  1276. package/dist/modes/interactive/components/tree-selector.d.ts +1 -12
  1277. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  1278. package/dist/modes/interactive/components/tree-selector.js +42 -402
  1279. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  1280. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
  1281. package/dist/modes/interactive/components/trust-selector.js +4 -16
  1282. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  1283. package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -1
  1284. package/dist/modes/interactive/components/usage-action-selector.js +2 -10
  1285. package/dist/modes/interactive/components/usage-action-selector.js.map +1 -1
  1286. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  1287. package/dist/modes/interactive/components/user-message-selector.js +3 -6
  1288. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  1289. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  1290. package/dist/modes/interactive/components/user-message.js +0 -1
  1291. package/dist/modes/interactive/components/user-message.js.map +1 -1
  1292. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  1293. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  1294. package/dist/modes/interactive/config-backup.d.ts.map +1 -1
  1295. package/dist/modes/interactive/config-backup.js.map +1 -1
  1296. package/dist/modes/interactive/editor-overlay-host.d.ts.map +1 -1
  1297. package/dist/modes/interactive/editor-overlay-host.js +0 -3
  1298. package/dist/modes/interactive/editor-overlay-host.js.map +1 -1
  1299. package/dist/modes/interactive/extension-ui-host.d.ts +2 -0
  1300. package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
  1301. package/dist/modes/interactive/extension-ui-host.js +51 -72
  1302. package/dist/modes/interactive/extension-ui-host.js.map +1 -1
  1303. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  1304. package/dist/modes/interactive/external-editor.js +2 -15
  1305. package/dist/modes/interactive/external-editor.js.map +1 -1
  1306. package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
  1307. package/dist/modes/interactive/history-reload-math.js.map +1 -1
  1308. package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -1
  1309. package/dist/modes/interactive/interactive-event-controller.js +23 -16
  1310. package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
  1311. package/dist/modes/interactive/interactive-mode.d.ts +13 -4
  1312. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  1313. package/dist/modes/interactive/interactive-mode.js +123 -204
  1314. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  1315. package/dist/modes/interactive/interactive-selection-prompts.d.ts +20 -0
  1316. package/dist/modes/interactive/interactive-selection-prompts.d.ts.map +1 -0
  1317. package/dist/modes/interactive/interactive-selection-prompts.js +43 -0
  1318. package/dist/modes/interactive/interactive-selection-prompts.js.map +1 -0
  1319. package/dist/modes/interactive/key-handlers.d.ts +2 -1
  1320. package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
  1321. package/dist/modes/interactive/key-handlers.js +4 -2
  1322. package/dist/modes/interactive/key-handlers.js.map +1 -1
  1323. package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -1
  1324. package/dist/modes/interactive/loaded-resources-view.js.map +1 -1
  1325. package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
  1326. package/dist/modes/interactive/local-model-commands.js +4 -9
  1327. package/dist/modes/interactive/local-model-commands.js.map +1 -1
  1328. package/dist/modes/interactive/model-fitness-presentation.d.ts +21 -0
  1329. package/dist/modes/interactive/model-fitness-presentation.d.ts.map +1 -0
  1330. package/dist/modes/interactive/model-fitness-presentation.js +13 -0
  1331. package/dist/modes/interactive/model-fitness-presentation.js.map +1 -0
  1332. package/dist/modes/interactive/profile-menu-controller.d.ts +2 -0
  1333. package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
  1334. package/dist/modes/interactive/profile-menu-controller.js +79 -171
  1335. package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
  1336. package/dist/modes/interactive/report-commands.d.ts +2 -0
  1337. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  1338. package/dist/modes/interactive/report-commands.js +12 -6
  1339. package/dist/modes/interactive/report-commands.js.map +1 -1
  1340. package/dist/modes/interactive/resource-display.d.ts.map +1 -1
  1341. package/dist/modes/interactive/resource-display.js.map +1 -1
  1342. package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
  1343. package/dist/modes/interactive/resource-shell-commands.js +6 -23
  1344. package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
  1345. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
  1346. package/dist/modes/interactive/session-flow-commands.js +21 -25
  1347. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  1348. package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
  1349. package/dist/modes/interactive/session-io-commands.js.map +1 -1
  1350. package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -1
  1351. package/dist/modes/interactive/session-replacement-errors.js.map +1 -1
  1352. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
  1353. package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
  1354. package/dist/modes/interactive/signal-lifecycle.d.ts.map +1 -1
  1355. package/dist/modes/interactive/signal-lifecycle.js.map +1 -1
  1356. package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
  1357. package/dist/modes/interactive/startup-checks.js +12 -8
  1358. package/dist/modes/interactive/startup-checks.js.map +1 -1
  1359. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  1360. package/dist/modes/interactive/theme/theme.js +10 -76
  1361. package/dist/modes/interactive/theme/theme.js.map +1 -1
  1362. package/dist/modes/interactive/usage-commands.d.ts.map +1 -1
  1363. package/dist/modes/interactive/usage-commands.js.map +1 -1
  1364. package/dist/modes/print-mode.d.ts.map +1 -1
  1365. package/dist/modes/print-mode.js +5 -22
  1366. package/dist/modes/print-mode.js.map +1 -1
  1367. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  1368. package/dist/modes/rpc/jsonl.js +1 -1
  1369. package/dist/modes/rpc/jsonl.js.map +1 -1
  1370. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  1371. package/dist/modes/rpc/rpc-client.js +7 -8
  1372. package/dist/modes/rpc/rpc-client.js.map +1 -1
  1373. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  1374. package/dist/modes/rpc/rpc-mode.js +5 -20
  1375. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  1376. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  1377. package/dist/modes/rpc/rpc-types.js.map +1 -1
  1378. package/dist/modes/termination-signals.d.ts +4 -0
  1379. package/dist/modes/termination-signals.d.ts.map +1 -0
  1380. package/dist/modes/termination-signals.js +21 -0
  1381. package/dist/modes/termination-signals.js.map +1 -0
  1382. package/dist/package-manager-cli.d.ts.map +1 -1
  1383. package/dist/package-manager-cli.js.map +1 -1
  1384. package/dist/utils/ansi-colors.d.ts +5 -0
  1385. package/dist/utils/ansi-colors.d.ts.map +1 -0
  1386. package/dist/utils/ansi-colors.js +38 -0
  1387. package/dist/utils/ansi-colors.js.map +1 -0
  1388. package/dist/utils/ansi.d.ts.map +1 -1
  1389. package/dist/utils/ansi.js.map +1 -1
  1390. package/dist/utils/changelog.d.ts.map +1 -1
  1391. package/dist/utils/changelog.js.map +1 -1
  1392. package/dist/utils/child-process.d.ts.map +1 -1
  1393. package/dist/utils/child-process.js.map +1 -1
  1394. package/dist/utils/clipboard-image.d.ts.map +1 -1
  1395. package/dist/utils/clipboard-image.js.map +1 -1
  1396. package/dist/utils/clipboard-native.d.ts.map +1 -1
  1397. package/dist/utils/clipboard-native.js.map +1 -1
  1398. package/dist/utils/clipboard.d.ts.map +1 -1
  1399. package/dist/utils/clipboard.js.map +1 -1
  1400. package/dist/utils/deprecation.d.ts.map +1 -1
  1401. package/dist/utils/deprecation.js.map +1 -1
  1402. package/dist/utils/exif-orientation.d.ts.map +1 -1
  1403. package/dist/utils/exif-orientation.js.map +1 -1
  1404. package/dist/utils/external-editor-command.d.ts.map +1 -1
  1405. package/dist/utils/external-editor-command.js.map +1 -1
  1406. package/dist/utils/frontmatter.d.ts.map +1 -1
  1407. package/dist/utils/frontmatter.js.map +1 -1
  1408. package/dist/utils/fs-watch.d.ts.map +1 -1
  1409. package/dist/utils/fs-watch.js.map +1 -1
  1410. package/dist/utils/git.d.ts.map +1 -1
  1411. package/dist/utils/git.js +20 -28
  1412. package/dist/utils/git.js.map +1 -1
  1413. package/dist/utils/highlight-js-languages.d.ts.map +1 -1
  1414. package/dist/utils/html.d.ts.map +1 -1
  1415. package/dist/utils/html.js.map +1 -1
  1416. package/dist/utils/image-convert.d.ts.map +1 -1
  1417. package/dist/utils/image-convert.js.map +1 -1
  1418. package/dist/utils/image-resize-core.d.ts.map +1 -1
  1419. package/dist/utils/image-resize-core.js.map +1 -1
  1420. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  1421. package/dist/utils/image-resize-worker.js.map +1 -1
  1422. package/dist/utils/image-resize.d.ts.map +1 -1
  1423. package/dist/utils/image-resize.js.map +1 -1
  1424. package/dist/utils/json.d.ts.map +1 -1
  1425. package/dist/utils/json.js.map +1 -1
  1426. package/dist/utils/mime.d.ts.map +1 -1
  1427. package/dist/utils/mime.js.map +1 -1
  1428. package/dist/utils/open-browser.d.ts.map +1 -1
  1429. package/dist/utils/open-browser.js.map +1 -1
  1430. package/dist/utils/paths.d.ts.map +1 -1
  1431. package/dist/utils/paths.js.map +1 -1
  1432. package/dist/utils/photon.d.ts.map +1 -1
  1433. package/dist/utils/photon.js.map +1 -1
  1434. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  1435. package/dist/utils/pi-user-agent.js.map +1 -1
  1436. package/dist/utils/platform.d.ts.map +1 -1
  1437. package/dist/utils/platform.js.map +1 -1
  1438. package/dist/utils/process-memory.d.ts.map +1 -1
  1439. package/dist/utils/process-memory.js.map +1 -1
  1440. package/dist/utils/safe-write-stream.d.ts.map +1 -1
  1441. package/dist/utils/safe-write-stream.js.map +1 -1
  1442. package/dist/utils/shell.d.ts.map +1 -1
  1443. package/dist/utils/shell.js.map +1 -1
  1444. package/dist/utils/sleep.d.ts.map +1 -1
  1445. package/dist/utils/sleep.js +2 -15
  1446. package/dist/utils/sleep.js.map +1 -1
  1447. package/dist/utils/stdin-events.d.ts +8 -0
  1448. package/dist/utils/stdin-events.d.ts.map +1 -0
  1449. package/dist/utils/stdin-events.js +19 -0
  1450. package/dist/utils/stdin-events.js.map +1 -0
  1451. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  1452. package/dist/utils/syntax-highlight.js +20 -13
  1453. package/dist/utils/syntax-highlight.js.map +1 -1
  1454. package/dist/utils/tools-manager.d.ts.map +1 -1
  1455. package/dist/utils/tools-manager.js.map +1 -1
  1456. package/dist/utils/version-check.d.ts.map +1 -1
  1457. package/dist/utils/version-check.js.map +1 -1
  1458. package/dist/utils/windows-self-update.d.ts.map +1 -1
  1459. package/dist/utils/windows-self-update.js.map +1 -1
  1460. package/dist/utils/work-directory.d.ts.map +1 -1
  1461. package/dist/utils/work-directory.js.map +1 -1
  1462. package/docs/compaction.md +11 -3
  1463. package/docs/sessions.md +6 -0
  1464. package/docs/settings.md +1 -1
  1465. package/docs/tool-repair.md +3 -0
  1466. package/docs/windows.md +29 -2
  1467. package/docs/work-directory.md +9 -1
  1468. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  1469. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  1470. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  1471. package/examples/extensions/sandbox/package-lock.json +2 -2
  1472. package/examples/extensions/sandbox/package.json +1 -1
  1473. package/examples/extensions/with-deps/package-lock.json +2 -2
  1474. package/examples/extensions/with-deps/package.json +1 -1
  1475. package/npm-shrinkwrap.json +16 -16
  1476. package/package.json +10 -10
  1477. package/dist/utils/streaming-lines.d.ts +0 -20
  1478. package/dist/utils/streaming-lines.d.ts.map +0 -1
  1479. package/dist/utils/streaming-lines.js +0 -79
  1480. package/dist/utils/streaming-lines.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"local-model-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/local-model-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAEN,SAAS,EAET,UAAU,EAEV,MAAM,EACN,IAAI,GAEJ,MAAM,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,CAAC,CAAC,YAAY;oBACd,CAAC,CAAC,eAAe,CAAC;IACvB,IAAI,CAAC,eAAe,CAAC,sBAAsB,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,kFAA8E,CAAC;IAClH,IAAI,CAAC,UAAU,CAAC,GAAG,QAAQ,WAAW,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;AAAA,CAC1F","sourcesContent":["/**\n * `/models` local-model lifecycle and `/fitness` probe/role-assignment flows\n * extracted from interactive-mode.\n *\n * `/models` is a USER-invoked local-model manager (list/add/remove/stop, never a\n * model-invokable tool); the fitness helpers probe a model on the current host\n * and land a shaped role. The server/selector flows share a `LocalModelHost`\n * seam, while `runFitnessAndAssign`/`assignFitnessRole` take narrow host shapes\n * matching their prototype-driven behaviour tests (fitness-probe-gate,\n * fitness-role-assignment), which keep exercising interactive-mode's thin\n * wrappers unchanged.\n */\n\nimport { existsSync, rmSync } from \"node:fs\";\nimport { totalmem } from \"node:os\";\nimport type { ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport { getSupportedThinkingLevels } from \"@caupulican/pi-ai\";\nimport {\n\ttype Component,\n\tContainer,\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\tSpacer,\n\tText,\n\ttype TUI,\n} from \"@caupulican/pi-tui\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { ModelRegistry } from \"../../core/model-registry.ts\";\nimport { resolveCliModel } from \"../../core/model-resolver.ts\";\nimport { evaluateSurfaceFitness } from \"../../core/model-router/fitness-gate.ts\";\nimport {\n\tderiveLocalContextSizing,\n\trenderOllamaContextModelfile,\n\tsizedLocalModelRef,\n} from \"../../core/models/context-sizing.ts\";\nimport { DEFAULT_MODEL_SUGGESTIONS } from \"../../core/models/default-model-suggestions.ts\";\nimport { FitnessStore } from \"../../core/models/fitness-store.ts\";\nimport { PrismLlamaCppRuntime, type PrismModelDescriptor } from \"../../core/models/llamacpp-runtime.ts\";\nimport {\n\tHF_TRANSFORMERS_PROVIDER,\n\tPRISM_LLAMACPP_PROVIDER,\n\tregisterLocalModel,\n\tregisterPrismLlamaCppModel,\n\tregisterTransformersModel,\n\tunregisterLocalModel,\n\tunregisterPrismLlamaCppModel,\n\tunregisterTransformersModel,\n} from \"../../core/models/local-registration.ts\";\nimport type { OllamaRuntime, TransformersRuntime } from \"../../core/models/local-runtime.ts\";\nimport { matchesInstalledLocalModel, normalizeModelSource } from \"../../core/models/model-ref.ts\";\nimport { NeedleRuntime } from \"../../core/models/needle-runtime.ts\";\nimport {\n\tderivePrismLlamaCppNumCtx,\n\tensurePrismModelFilesThenServe,\n\tisPiManagedPrismLlamaCppModel,\n\tPRISM_LLAMACPP_DESCRIPTORS,\n\tPRISM_LLAMACPP_SERVE_PORT,\n} from \"../../core/models/prism-llamacpp-lifecycle.ts\";\nimport { formatModelFitnessReport, isProbeAllFailed } from \"../../core/research/model-fitness.ts\";\nimport type { SettingsManager } from \"../../core/settings-manager.ts\";\nimport { DynamicBorder } from \"./components/dynamic-border.ts\";\nimport { type FitnessRole, FitnessRoleSelectorComponent } from \"./components/fitness-role-selector.ts\";\nimport { ModelSelectorComponent } from \"./components/model-selector.ts\";\nimport { ModelSuggestionSelectorComponent } from \"./components/model-suggestion-selector.ts\";\nimport { getSelectListTheme } from \"./theme/theme.ts\";\n\ntype SelectorFactory = (done: () => void) => { component: Component; focus: Component };\n\nconst MODEL_ROUTER_THINKING_SELECT_LIST_LAYOUT: SelectListLayoutOptions = {\n\tminPrimaryColumnWidth: 12,\n\tmaxPrimaryColumnWidth: 32,\n};\n\nconst MODEL_ROUTER_THINKING_INHERIT_VALUE = \"__inherit_model_router_thinking__\";\nconst MODEL_ROUTER_THINKING_INHERIT_LABEL = \"(inherit)\";\n\nconst THINKING_LEVEL_DESCRIPTIONS: Record<ThinkingLevel, string> = {\n\toff: \"No reasoning\",\n\tminimal: \"Very brief reasoning (~1k tokens)\",\n\tlow: \"Light reasoning (~2k tokens)\",\n\tmedium: \"Moderate reasoning (~8k tokens)\",\n\thigh: \"Deep reasoning (~16k tokens)\",\n\txhigh: \"Maximum reasoning (~32k tokens)\",\n\tmax: \"Maximum reasoning depth for the hardest problems\",\n\tultra: \"Maximum reasoning with reinforced proactive delegation\",\n};\n\nconst MODEL_ROUTER_THINKING_FALLBACK_LEVELS: readonly ThinkingLevel[] = [\n\t\"off\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\",\n\t\"xhigh\",\n];\n\ntype RouterThinkingLevel = ThinkingLevel | typeof MODEL_ROUTER_THINKING_INHERIT_VALUE;\ntype ModelRouterThinkingField =\n\t| \"cheapThinking\"\n\t| \"mediumThinking\"\n\t| \"expensiveThinking\"\n\t| \"executorThinking\"\n\t| \"judgeThinking\";\n\n/** Narrow seam for persisting a probed model's role — matches the fitness-role test. */\nexport interface AssignRoleHost {\n\treadonly settingsManager: SettingsManager;\n\tshowStatus(message: string): void;\n}\n\n/** Seam for the fitness probe + role-selector flow — matches the fitness-probe-gate test. */\nexport interface RunFitnessHost {\n\treadonly session: Pick<AgentSession, \"runModelFitness\"> & { modelRegistry?: ModelRegistry };\n\treadonly settingsManager: SettingsManager;\n\treadonly chatContainer: Container;\n\treadonly ui: TUI;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowSelector(create: SelectorFactory): void;\n}\n\n/** Full seam for the `/models` server/selector flows. */\nexport interface LocalModelHost {\n\treadonly localRuntime: OllamaRuntime;\n\treadonly session: AgentSession;\n\treadonly settingsManager: SettingsManager;\n\treadonly ui: TUI;\n\treadonly chatContainer: Container;\n\tgetTransformersRuntime(modelId: string, baseUrl?: string): TransformersRuntime;\n\t/**\n\t * Seam for the pi-managed prism llama.cpp runtime (Bonsai-27B and future curated prism-ml\n\t * models). Production (interactive-mode.ts's `localModelHost()`) always supplies this, wired\n\t * through `AgentSession.getPrismLlamaCppRuntime()` -> `LocalRuntimeController`'s cached instance\n\t * — the SAME instance the readiness gate uses, mirroring `getTransformersRuntime` above (cached\n\t * for the session's lifetime, so `stop()`/`removePrismLlamaCppModel` reattach to the SAME\n\t * instance that holds the running child process instead of each tracking an untracked one).\n\t * Optional only so tests can inject a fake without needing the full session stack; the fallback\n\t * below (a fresh, uncached instance) is a test convenience, never the production path.\n\t */\n\tgetPrismLlamaCppRuntime?(): PrismLlamaCppRuntime;\n\t/**\n\t * Seam for the pi-managed needle runtime (see needle-runtime.ts) — optional so tests can inject a\n\t * fake, falling back to a fresh instance otherwise. Unlike `getPrismLlamaCppRuntime` above, needle\n\t * has no session-caching need: every invocation is a one-shot `runCommand` call with no persistent\n\t * child process to reattach to (needle-runtime.ts's `dispose()` is a documented no-op), so a fresh\n\t * instance per call is functionally identical to a cached one — `runtimeDir()`/`modelsDir()`/\n\t * `checkpointPath()` are pure path derivations from `agentDir`, not in-memory state.\n\t */\n\tgetNeedleRuntime?(): NeedleRuntime;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowSelector(create: SelectorFactory): void;\n}\n\nfunction getPrismLlamaCppRuntime(host: LocalModelHost): PrismLlamaCppRuntime {\n\treturn host.getPrismLlamaCppRuntime?.() ?? new PrismLlamaCppRuntime({ agentDir: getAgentDir() });\n}\n\nfunction getNeedleRuntime(host: LocalModelHost): NeedleRuntime {\n\treturn host.getNeedleRuntime?.() ?? new NeedleRuntime({ agentDir: getAgentDir() });\n}\n\n/**\n * Mirrors needle-runtime.ts's own (module-private, not exported) NEEDLE_SMOKE_TOOLS — the default\n * tool set for `/models needle <query>` when no tools-json is supplied, so an ad-hoc probe has the\n * same sensible starting point the install pipeline's own smoke test already exercises. Kept in\n * sync manually since the source constant isn't exported from the frozen runtime module.\n */\nconst NEEDLE_DEFAULT_TOOLS = [\n\t{\n\t\tname: \"get_weather\",\n\t\tdescription: \"Get current weather for a city.\",\n\t\tparameters: { location: { type: \"string\", description: \"City name.\", required: true } },\n\t},\n];\n\nclass ModelRouterThinkingSelectorComponent extends Container {\n\tprivate selectList: SelectList;\n\n\tconstructor(\n\t\tcurrentLevel: RouterThinkingLevel,\n\t\tavailableLevels: ThinkingLevel[],\n\t\tonSelect: (level: RouterThinkingLevel) => void,\n\t\tonCancel: () => void,\n\t) {\n\t\tsuper();\n\n\t\tconst thinkingOptions: SelectItem[] = [\n\t\t\t{\n\t\t\t\tvalue: MODEL_ROUTER_THINKING_INHERIT_VALUE,\n\t\t\t\tlabel: MODEL_ROUTER_THINKING_INHERIT_LABEL,\n\t\t\t\tdescription: \"Use current session default for this tier.\",\n\t\t\t},\n\t\t\t...availableLevels.map((level) => ({\n\t\t\t\tvalue: level,\n\t\t\t\tlabel: level,\n\t\t\t\tdescription: THINKING_LEVEL_DESCRIPTIONS[level],\n\t\t\t})),\n\t\t];\n\n\t\tthis.addChild(new DynamicBorder());\n\n\t\tthis.selectList = new SelectList(\n\t\t\tthinkingOptions,\n\t\t\tthinkingOptions.length,\n\t\t\tgetSelectListTheme(),\n\t\t\tMODEL_ROUTER_THINKING_SELECT_LIST_LAYOUT,\n\t\t);\n\n\t\tconst index = thinkingOptions.findIndex((item) => item.value === currentLevel);\n\t\tif (index !== -1) {\n\t\t\tthis.selectList.setSelectedIndex(index);\n\t\t}\n\n\t\tthis.selectList.onSelect = (item) => {\n\t\t\tonSelect(item.value as RouterThinkingLevel);\n\t\t};\n\t\tthis.selectList.onCancel = () => {\n\t\t\tonCancel();\n\t\t};\n\n\t\tthis.addChild(this.selectList);\n\t\tthis.addChild(new DynamicBorder());\n\t}\n}\n/**\n * /models — USER-invoked local model lifecycle (never a model-invokable tool):\n * list/add/remove/stop per local-model-lifecycle-design.md. Removal is explicit-only with\n * full disclosure; a pasted install command is parsed for its ref, never executed.\n */\nexport async function handleModelsCommand(host: LocalModelHost, argsText: string): Promise<void> {\n\tconst [action = \"list\", ...rest] = argsText.split(/\\s+/).filter(Boolean);\n\ttry {\n\t\tif (action === \"suggest\" || action === \"suggestions\") {\n\t\t\tshowModelSuggestionSelector(host);\n\t\t\treturn;\n\t\t}\n\t\tif (action === \"stop\") {\n\t\t\tconst stopped = host.localRuntime.stop();\n\t\t\tlet stoppedTransformers = 0;\n\t\t\tfor (const model of host.session.modelRegistry\n\t\t\t\t.getAll()\n\t\t\t\t.filter((entry) => entry.provider === HF_TRANSFORMERS_PROVIDER)) {\n\t\t\t\tconst serverUrl = model.baseUrl.replace(/\\/v1\\/?$/, \"\");\n\t\t\t\tif (host.getTransformersRuntime(model.id, serverUrl).stop().stopped) stoppedTransformers++;\n\t\t\t}\n\t\t\t// Only touch the prism runtime when a pi-managed prism model is actually registered —\n\t\t\t// never construct/stop it on a session that never used one. isPiManagedPrismLlamaCppModel\n\t\t\t// is the SAME discriminator the readiness gate uses, so this never reaches for a user's own\n\t\t\t// hand-configured llama-cpp entry (e.g. the built-in llama-cpp/local catalog model).\n\t\t\tconst hasPiManagedPrismModel = host.session.modelRegistry\n\t\t\t\t.getAll()\n\t\t\t\t.some((entry) => isPiManagedPrismLlamaCppModel(entry));\n\t\t\tconst stoppedPrism = hasPiManagedPrismModel && getPrismLlamaCppRuntime(host).stop().stopped;\n\t\t\tconst stoppedAny = stopped.stopped || stoppedTransformers > 0 || stoppedPrism;\n\t\t\thost.showStatus(\n\t\t\t\tstoppedAny\n\t\t\t\t\t? `Pi-managed local model server stopped${stoppedTransformers > 0 ? ` (${stoppedTransformers} Transformers sidecar(s))` : \"\"}${stoppedPrism ? \" (prism llama.cpp server)\" : \"\"}; models remain installed.`\n\t\t\t\t\t: \"No pi-managed server running (a system server, if any, is not pi's to stop).\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tif (action === \"import\") {\n\t\t\tconst imported = host.localRuntime.importUserModels();\n\t\t\thost.showStatus(\n\t\t\t\t`Imported Ollama models from ${imported.sourceDir} into pi-owned store ${imported.targetDir}: ` +\n\t\t\t\t\t`${imported.manifestsImported} manifest(s), ${imported.blobsHardlinked} blob(s) hardlinked, ` +\n\t\t\t\t\t`${imported.blobsCopied} blob(s) copied, ${imported.blobsSkipped + imported.manifestsSkipped} existing file(s) skipped.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tif (action === \"needle\") {\n\t\t\tif (rest.length === 0) {\n\t\t\t\thost.showStatus(\"Usage: /models needle <query> [tools-json]\");\n\t\t\t\thost.showStatus(\n\t\t\t\t\t` tools-json defaults to the smoke-test tool set: ${JSON.stringify(NEEDLE_DEFAULT_TOOLS)}`,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait runNeedleQuery(host, rest);\n\t\t\treturn;\n\t\t}\n\n\t\tif (action === \"add\") {\n\t\t\tconst rawRef = rest.join(\" \");\n\t\t\tif (!rawRef) {\n\t\t\t\thost.showStatus(\n\t\t\t\t\t\"Usage: /models add <ollama-tag | hf.co/org/repo[:quant] | curated HF full-base ref | huggingface URL | pasted install command>\",\n\t\t\t\t);\n\t\t\t\thost.showStatus(\"Or start from a validated suggestion: /models suggest\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst source = normalizeModelSource(rawRef);\n\t\t\tif (source.type === \"rejected\") {\n\t\t\t\thost.showStatus(`Not added: ${source.reason}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"api\") {\n\t\t\t\thost.showStatus(\n\t\t\t\t\t`${source.ref} is an API model — nothing to install. Configure auth for the provider, then probe it with /fitness ${source.ref}.`,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"transformers\") {\n\t\t\t\tawait addTransformersModel(host, source.modelId);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"prism-llamacpp\") {\n\t\t\t\tconst descriptor = PRISM_LLAMACPP_DESCRIPTORS[source.modelId];\n\t\t\t\tif (!descriptor) {\n\t\t\t\t\thost.showStatus(`${source.modelId} has no curated prism llama.cpp descriptor — this is a wiring bug.`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait addPrismLlamaCppModel(host, descriptor);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"needle\") {\n\t\t\t\tawait addNeedleModel(host);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait addLocalModel(host, source.pullRef);\n\t\t\treturn;\n\t\t}\n\n\t\tif (action === \"remove\") {\n\t\t\tconst ref = rest[0];\n\t\t\tconst confirmed = rest[1] === \"confirm\";\n\t\t\tif (!ref) {\n\t\t\t\thost.showStatus(\"Usage: /models remove <ref> confirm\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst source = normalizeModelSource(ref);\n\t\t\tif (source.type === \"transformers\") {\n\t\t\t\tawait removeTransformersModel(host, source.modelId, confirmed);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"prism-llamacpp\") {\n\t\t\t\tawait removePrismLlamaCppModel(host, source.modelId, confirmed);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"needle\") {\n\t\t\t\tawait removeNeedleModel(host, confirmed);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait removeLocalModel(host, ref, confirmed);\n\t\t\treturn;\n\t\t}\n\n\t\tawait listLocalModels(host);\n\t} catch (error) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t}\n}\n\nfunction formatOllamaStore(store: { kind: string; path: string; modelCount: number } | undefined): string {\n\tif (!store) return \"unknown store (0 model(s))\";\n\treturn `${store.path} [${store.kind}, ${store.modelCount} model(s)]`;\n}\n\nexport async function ensureLocalServer(host: LocalModelHost): Promise<boolean> {\n\tconst status = await host.localRuntime.detect();\n\tif (status.serverUp) {\n\t\tif (status.activeStore?.kind === \"pi-owned\") return true;\n\t\thost.showStatus(\n\t\t\t`Ollama is already running on ${status.serverUrl} with store ${formatOllamaStore(status.activeStore)}; ` +\n\t\t\t\t`pi's canonical store is ${status.ownedModelsDir} (${status.ownedStore.modelCount} model(s)). ` +\n\t\t\t\t\"Stop the other serve or run /models import before adding models.\",\n\t\t);\n\t\treturn false;\n\t}\n\tif (!status.binaryPath) {\n\t\tfor (const line of host.localRuntime.installGuide()) host.showStatus(line);\n\t\treturn false;\n\t}\n\thost.showStatus(\n\t\t`Starting local model server (${status.binarySource} binary, owned storage: ${status.ownedModelsDir})…`,\n\t);\n\tconst started = await host.localRuntime.start();\n\tif (!started.started) {\n\t\thost.showStatus(`Could not start the local server: ${started.reason}`);\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nexport async function listLocalModels(host: LocalModelHost): Promise<void> {\n\tconst status = await host.localRuntime.detect();\n\tconst models = status.serverUp ? await host.localRuntime.list() : [];\n\tconst ollamaLines = status.serverUp\n\t\t? [\n\t\t\t\t`Ollama models (active store: ${formatOllamaStore(status.activeStore)}; pi-owned store: ${status.ownedModelsDir} with ${status.ownedStore.modelCount} model(s)):`,\n\t\t\t\t...(models.length === 0\n\t\t\t\t\t? [\" (none installed — /models add <ref>, /models import, or /models suggest for a validated roster)\"]\n\t\t\t\t\t: []),\n\t\t\t]\n\t\t: [\n\t\t\t\t\"Ollama models:\",\n\t\t\t\t...(status.binaryPath\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t` server not running (binary: ${status.binarySource}). /models add starts it on demand; /fitness probes registered models.`,\n\t\t\t\t\t\t]\n\t\t\t\t\t: host.localRuntime.installGuide().map((line) => ` ${line}`)),\n\t\t\t];\n\tconst fitness = FitnessStore.forAgentDir(getAgentDir()).getForHost();\n\tconst transformersModels = host.session.modelRegistry\n\t\t.getAll()\n\t\t.filter((model) => model.provider === HF_TRANSFORMERS_PROVIDER);\n\tconst transformersLines = await Promise.all(\n\t\ttransformersModels.map(async (model) => {\n\t\t\tconst serverUrl = model.baseUrl.replace(/\\/v1\\/?$/, \"\");\n\t\t\tconst runtime = host.getTransformersRuntime(model.id, serverUrl);\n\t\t\tconst runtimeStatus = await runtime.detect();\n\t\t\tconst report = fitness.find((entry) => entry.model === `${HF_TRANSFORMERS_PROVIDER}/${model.id}`);\n\t\t\tconst readiness = runtimeStatus.serverUp\n\t\t\t\t? \"server running\"\n\t\t\t\t: runtimeStatus.runtimeInstalled\n\t\t\t\t\t? \"runtime installed\"\n\t\t\t\t\t: \"runtime missing\";\n\t\t\tconst probe = report\n\t\t\t\t? `probed ${report.at.slice(0, 10)}: digest ${report.report.digest?.succeeded ?? \"?\"}/${report.report.digest?.total ?? \"?\"}, tool-calls ${report.report.toolCall.succeeded}/${report.report.toolCall.total}${report.report.tokensPerSecond ? `, ~${report.report.tokensPerSecond} tok/s` : \"\"}`\n\t\t\t\t: `unprobed — run /fitness ${HF_TRANSFORMERS_PROVIDER}/${model.id}`;\n\t\t\treturn ` - ${model.id} (${readiness}, cache: ${runtimeStatus.cacheDir}) · ${probe}`;\n\t\t}),\n\t);\n\tconst lines = [\n\t\t...ollamaLines,\n\t\t...models.map((model) => {\n\t\t\tconst report = fitness.find((entry) => entry.model === `ollama/${model.name}`);\n\t\t\tconst gb = (model.sizeBytes / 1e9).toFixed(2);\n\t\t\tconst probe = report\n\t\t\t\t? `probed ${report.at.slice(0, 10)}: digest ${report.report.digest?.succeeded ?? \"?\"}/${report.report.digest?.total ?? \"?\"}, tool-calls ${report.report.toolCall.succeeded}/${report.report.toolCall.total}${report.report.tokensPerSecond ? `, ~${report.report.tokensPerSecond} tok/s` : \"\"}`\n\t\t\t\t: `unprobed — run /fitness ollama/${model.name}`;\n\t\t\treturn ` - ${model.name} (${gb} GB) · ${probe}`;\n\t\t}),\n\t\t...(transformersLines.length > 0 ? [\"Pi-managed Transformers models:\", ...transformersLines] : []),\n\t\t\"Commands: /models import · /models add <ref> · /models remove <ref> confirm · /models stop\",\n\t];\n\tfor (const line of lines) host.showStatus(line);\n}\n\nexport async function addLocalModel(host: LocalModelHost, pullRef: string, preselectRole?: FitnessRole): Promise<void> {\n\tif (!(await ensureLocalServer(host))) return;\n\thost.showStatus(`Pulling ${pullRef}… (weights land in pi's owned Ollama store)`);\n\tlet lastShown = 0;\n\tconst pulled = await host.localRuntime.pull(pullRef, (progress) => {\n\t\tconst now = Date.now();\n\t\tif (now - lastShown > 2000) {\n\t\t\tlastShown = now;\n\t\t\thost.showStatus(` ${pullRef}: ${progress}`);\n\t\t}\n\t});\n\tif (!pulled.ok) {\n\t\thost.showStatus(`Pull failed: ${pulled.error}`);\n\t\treturn;\n\t}\n\tconst installed = await host.localRuntime.list().catch(() => []);\n\tconst installedEntry = installed.find((entry) => matchesInstalledLocalModel(pullRef, entry.name));\n\tconst shown = await host.localRuntime.show(pullRef);\n\tconst sizing =\n\t\tinstalledEntry && shown.ok\n\t\t\t? deriveLocalContextSizing({\n\t\t\t\t\thost: { totalMemBytes: totalmem() },\n\t\t\t\t\tmodel: { modelInfo: shown.info.modelInfo, weightsBytes: installedEntry.sizeBytes },\n\t\t\t\t\truntime: { supportsKvQuantization: true },\n\t\t\t\t})\n\t\t\t: undefined;\n\tlet registeredRef = pullRef;\n\tif (sizing) {\n\t\tconst sizedRef = sizedLocalModelRef(pullRef, sizing.numCtx);\n\t\tconst created = await host.localRuntime.createFromModelfile({\n\t\t\tname: sizedRef,\n\t\t\tmodelfile: renderOllamaContextModelfile({ from: pullRef, numCtx: sizing.numCtx }),\n\t\t});\n\t\tif (!created.ok) {\n\t\t\thost.showStatus(`Pulled, but could not create sized context model: ${created.error}`);\n\t\t\treturn;\n\t\t}\n\t\tregisteredRef = sizedRef;\n\t}\n\tconst registration = registerLocalModel({\n\t\tagentDir: getAgentDir(),\n\t\tref: registeredRef,\n\t\tbaseUrl: host.localRuntime.baseUrl,\n\t\tcontextWindow: sizing?.numCtx,\n\t\tservedContextWindow: sizing?.numCtx,\n\t});\n\tif (!registration.ok) {\n\t\thost.showStatus(`Pulled, but not auto-registered: ${registration.reason}`);\n\t\tif (registration.manualSnippet) {\n\t\t\thost.showStatus(`Add this to ${registration.modelsJsonPath} yourself:\\n${registration.manualSnippet}`);\n\t\t}\n\t\treturn;\n\t}\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(`${pullRef} installed and registered as ollama/${registeredRef}. Probing fitness…`);\n\tawait runFitnessAndAssign(host, `ollama/${registeredRef}`, preselectRole);\n}\n\nexport async function addTransformersModel(\n\thost: LocalModelHost,\n\tmodelId: string,\n\tpreselectRole?: FitnessRole,\n): Promise<void> {\n\tconst runtime = host.getTransformersRuntime(modelId);\n\tlet status = await runtime.detect();\n\tif (!status.runtimeInstalled) {\n\t\thost.showStatus(`Installing isolated Transformers runtime for ${modelId} at ${status.venvDir}…`);\n\t\tconst installed = await runtime.installManaged((progress) => host.showStatus(` transformers: ${progress}`));\n\t\tif (!installed.ok) {\n\t\t\thost.showStatus(`Transformers runtime install failed: ${installed.error}`);\n\t\t\treturn;\n\t\t}\n\t\tstatus = await runtime.detect();\n\t}\n\tif (!status.runtimeInstalled) {\n\t\thost.showStatus(`Transformers runtime is still unavailable at ${status.venvDir}.`);\n\t\treturn;\n\t}\n\n\tconst downloaded = await runtime.downloadModel((progress) => host.showStatus(` ${modelId}: ${progress}`));\n\tif (!downloaded.ok) {\n\t\thost.showStatus(`Model download failed: ${downloaded.error}`);\n\t\treturn;\n\t}\n\n\tconst started = await runtime.start();\n\tif (!started.started && started.reason !== \"already_running\") {\n\t\thost.showStatus(`Could not start Transformers sidecar: ${started.reason}`);\n\t\treturn;\n\t}\n\n\tconst registration = registerTransformersModel({\n\t\tagentDir: getAgentDir(),\n\t\tmodelId,\n\t\tbaseUrl: runtime.baseUrl,\n\t});\n\tif (!registration.ok) {\n\t\thost.showStatus(`Installed, but not auto-registered: ${registration.reason}`);\n\t\tif (registration.manualSnippet) {\n\t\t\thost.showStatus(`Add this to ${registration.modelsJsonPath} yourself:\\n${registration.manualSnippet}`);\n\t\t}\n\t\treturn;\n\t}\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(\n\t\t`${modelId} installed in pi-managed Transformers and registered as ${HF_TRANSFORMERS_PROVIDER}/${modelId}. Probing fitness…`,\n\t);\n\tawait runFitnessAndAssign(host, `${HF_TRANSFORMERS_PROVIDER}/${modelId}`, preselectRole);\n}\n\n/**\n * Zero-setup pipeline for a curated prism llama.cpp model (Bonsai-27B): install the pinned prism\n * llama.cpp runtime (prebuilt release download, no compiler needed), ensure both GGUF files and\n * start llama-server (see `ensurePrismModelFilesThenServe`), register the model, then probe\n * fitness. Mirrors addTransformersModel's shape — each stage checks its own `{ ok }`/\n * `{ runtimeInstalled }` result and stops with an honest status message on failure; nothing\n * continues past a failed stage.\n */\nexport async function addPrismLlamaCppModel(\n\thost: LocalModelHost,\n\tdescriptor: PrismModelDescriptor,\n\tpreselectRole?: FitnessRole,\n): Promise<void> {\n\tconst runtime = getPrismLlamaCppRuntime(host);\n\tconst modelId = descriptor.repo;\n\n\tlet status = await runtime.detect();\n\tif (!status.runtimeInstalled) {\n\t\thost.showStatus(`Installing prism llama.cpp runtime for ${descriptor.displayName} at ${runtime.runtimeDir()}…`);\n\t\tconst installed = await runtime.installManaged((progress) => host.showStatus(` prism-llamacpp: ${progress}`));\n\t\tif (!installed.ok) {\n\t\t\thost.showStatus(`Prism llama.cpp runtime install failed: ${installed.error}`);\n\t\t\treturn;\n\t\t}\n\t\tstatus = await runtime.detect();\n\t}\n\tif (!status.runtimeInstalled) {\n\t\thost.showStatus(`Prism llama.cpp runtime is still unavailable at ${runtime.runtimeDir()}.`);\n\t\treturn;\n\t}\n\n\tconst numCtx = derivePrismLlamaCppNumCtx(totalmem());\n\tconst served = await ensurePrismModelFilesThenServe(\n\t\truntime,\n\t\tdescriptor,\n\t\t{ port: PRISM_LLAMACPP_SERVE_PORT, numCtx },\n\t\t(message) => host.showStatus(message),\n\t);\n\tif (!served.ok) {\n\t\tconst label =\n\t\t\tserved.stage === \"model-download\"\n\t\t\t\t? \"Model download failed\"\n\t\t\t\t: served.stage === \"mmproj-download\"\n\t\t\t\t\t? \"Vision projector download failed\"\n\t\t\t\t\t: \"Could not start llama-server\";\n\t\thost.showStatus(`${label}: ${served.error}`);\n\t\treturn;\n\t}\n\n\tconst registration = registerPrismLlamaCppModel({\n\t\tagentDir: getAgentDir(),\n\t\tmodelId,\n\t\tbaseUrl: served.baseUrl,\n\t\tcontextWindow: numCtx,\n\t\tservedContextWindow: numCtx,\n\t});\n\tif (!registration.ok) {\n\t\thost.showStatus(`Served, but not auto-registered: ${registration.reason}`);\n\t\tif (registration.manualSnippet) {\n\t\t\thost.showStatus(`Add this to ${registration.modelsJsonPath} yourself:\\n${registration.manualSnippet}`);\n\t\t}\n\t\treturn;\n\t}\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(\n\t\t`${descriptor.displayName} installed and registered as ${PRISM_LLAMACPP_PROVIDER}/${modelId}. Probing fitness…`,\n\t);\n\tawait runFitnessAndAssign(host, `${PRISM_LLAMACPP_PROVIDER}/${modelId}`, preselectRole);\n}\n\nexport async function removeLocalModel(host: LocalModelHost, ref: string, confirmed: boolean): Promise<void> {\n\tconst status = await host.localRuntime.detect();\n\tif (!status.serverUp) {\n\t\thost.showStatus(\"Local server not running — start it (any /models action) before removing.\");\n\t\treturn;\n\t}\n\tconst models = await host.localRuntime.list();\n\tconst target = models.find((model) => matchesInstalledLocalModel(ref, model.name));\n\tif (!target) {\n\t\thost.showStatus(\n\t\t\t`${ref} is not installed. Installed: ${models.map((model) => model.name).join(\", \") || \"(none)\"}`,\n\t\t);\n\t\treturn;\n\t}\n\tif (!confirmed) {\n\t\t// EXPLICIT USER ACTION ONLY: full disclosure, then require the confirm token.\n\t\tconst gb = (target.sizeBytes / 1e9).toFixed(2);\n\t\thost.showStatus(\n\t\t\t[\n\t\t\t\t`Removing ${ref} will delete:`,\n\t\t\t\t` - model weights (${gb} GB) from ${status.managedByPi ? status.ownedModelsDir : \"the system server's storage\"}`,\n\t\t\t\t` - the ollama/${ref} entry in models.json`,\n\t\t\t\t` - its cached fitness report for this host`,\n\t\t\t\t`Run: /models remove ${ref} confirm`,\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t\treturn;\n\t}\n\tconst removed = await host.localRuntime.remove(ref);\n\tif (!removed.ok) {\n\t\thost.showStatus(`Remove failed: ${removed.error}`);\n\t\treturn;\n\t}\n\tunregisterLocalModel({ agentDir: getAgentDir(), ref });\n\tFitnessStore.forAgentDir(getAgentDir()).remove(`ollama/${ref}`);\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(`${ref} removed: weights deleted, registration and fitness report dropped.`);\n}\n\nasync function removeTransformersModel(host: LocalModelHost, modelId: string, confirmed: boolean): Promise<void> {\n\tconst runtime = host.getTransformersRuntime(modelId);\n\tconst status = await runtime.detect();\n\tif (!confirmed) {\n\t\thost.showStatus(\n\t\t\t[\n\t\t\t\t`Removing ${modelId} will delete:`,\n\t\t\t\t` - the ${HF_TRANSFORMERS_PROVIDER}/${modelId} entry in models.json`,\n\t\t\t\t` - its cached fitness report for this host`,\n\t\t\t\t`It will stop this session's Transformers sidecar if running. Cached weights remain under ${status.cacheDir}.`,\n\t\t\t\t`Run: /models remove hf.co/${modelId} confirm`,\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t\treturn;\n\t}\n\truntime.stop();\n\tconst registration = unregisterTransformersModel({ agentDir: getAgentDir(), modelId });\n\tif (!registration.ok) {\n\t\thost.showStatus(`Remove failed: ${registration.reason}`);\n\t\treturn;\n\t}\n\tFitnessStore.forAgentDir(getAgentDir()).remove(`${HF_TRANSFORMERS_PROVIDER}/${modelId}`);\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(\n\t\t`${modelId} registration and fitness report dropped; cached weights remain under ${status.cacheDir}.`,\n\t);\n}\n\n/**\n * Drop a pi-managed prism llama.cpp model's registration and fitness report. Production supplies a\n * session-cached runtime (see `LocalModelHost.getPrismLlamaCppRuntime`'s doc comment), the SAME\n * instance the readiness gate uses, so `stop()` here reliably reaches the tracked child whenever\n * THIS session is the one that started it — including a server started earlier in the session by\n * the readiness gate itself, not just by a prior `/models add`. Only a server started by a\n * DIFFERENT process/session (pi restarted, a different terminal) is out of reach; the status text\n * only carries that caveat, not a blanket \"may not stop\" disclaimer.\n */\nasync function removePrismLlamaCppModel(host: LocalModelHost, modelId: string, confirmed: boolean): Promise<void> {\n\tconst runtime = getPrismLlamaCppRuntime(host);\n\tif (!confirmed) {\n\t\thost.showStatus(\n\t\t\t[\n\t\t\t\t`Removing ${modelId} will delete:`,\n\t\t\t\t` - the ${PRISM_LLAMACPP_PROVIDER}/${modelId} entry in models.json`,\n\t\t\t\t` - its cached fitness report for this host`,\n\t\t\t\t`Downloaded GGUF weights remain under ${runtime.modelsDir()}. Its llama-server will be stopped if ` +\n\t\t\t\t\t`this session started it; if it was started by a different pi process or session, it will keep ` +\n\t\t\t\t\t`serving on 127.0.0.1:${PRISM_LLAMACPP_SERVE_PORT} until stopped manually.`,\n\t\t\t\t`Run: /models remove hf.co/${modelId} confirm`,\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t\treturn;\n\t}\n\tconst stopped = runtime.stop();\n\tconst registration = unregisterPrismLlamaCppModel({ agentDir: getAgentDir(), modelId });\n\tif (!registration.ok) {\n\t\thost.showStatus(`Remove failed: ${registration.reason}`);\n\t\treturn;\n\t}\n\tFitnessStore.forAgentDir(getAgentDir()).remove(`${PRISM_LLAMACPP_PROVIDER}/${modelId}`);\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(\n\t\t`${modelId} registration and fitness report dropped; downloaded weights remain under ${runtime.modelsDir()}.` +\n\t\t\t(stopped.stopped\n\t\t\t\t? \" Its llama-server was stopped.\"\n\t\t\t\t: ` No llama-server tracked by this session — if one is still running (started by a different pi process or session), stop it manually on port ${PRISM_LLAMACPP_SERVE_PORT}.`),\n\t);\n}\n\n/**\n * Zero-setup pipeline for needle (see needle-runtime.ts): a standalone 26M-parameter function-call\n * test bench, NOT a chat/executor/lane model — no OpenAI-compatible endpoint, no models.json\n * registration, no /fitness probe. Install the pinned needle clone+venv (menu pick = consent, same\n * doctrine as the Transformers/prism precedents), download and sha256-verify the pickle checkpoint\n * (never called implicitly by installManaged — see the module's SECURITY note: the checkpoint is a\n * pickle file, arbitrary code execution on load by construction, so this is deliberately a separate\n * consent-adjacent step, not folded into install), then run its own smoke test as the honest\n * post-install verification. Each stage checks its own `{ ok }` result and stops with a stage-tagged\n * status on failure; nothing continues past a failed stage.\n */\nexport async function addNeedleModel(host: LocalModelHost): Promise<void> {\n\tconst runtime = getNeedleRuntime(host);\n\n\tlet status = await runtime.detect();\n\tif (!status.installed) {\n\t\thost.showStatus(`Installing needle (function-call test bench) at ${runtime.runtimeDir()}…`);\n\t\tconst installed = await runtime.installManaged((progress) => host.showStatus(` needle: ${progress}`));\n\t\tif (!installed.ok) {\n\t\t\thost.showStatus(`needle install failed: ${installed.error}`);\n\t\t\treturn;\n\t\t}\n\t\tstatus = await runtime.detect();\n\t}\n\tif (!status.installed) {\n\t\thost.showStatus(`needle is still unavailable at ${runtime.runtimeDir()}.`);\n\t\treturn;\n\t}\n\n\tconst downloaded = await runtime.downloadWeights((progress) => host.showStatus(` ${progress}`));\n\tif (!downloaded.ok) {\n\t\thost.showStatus(`needle weights download failed: ${downloaded.error}`);\n\t\treturn;\n\t}\n\n\thost.showStatus(\"Running needle smoke test (function-call probe)…\");\n\tconst smoke = await runtime.smokeTest();\n\tif (!smoke.ok || !smoke.call) {\n\t\thost.showStatus(\n\t\t\t`needle smoke test failed: ${smoke.error ?? \"smoke test reported success but returned no parsed call\"}`,\n\t\t);\n\t\treturn;\n\t}\n\thost.showStatus(\n\t\t`needle installed and verified: smoke test called ${smoke.call.name}(${JSON.stringify(smoke.call.arguments)}) ` +\n\t\t\t`in ${smoke.latencyMs}ms. Use /models needle <query> [tools-json] to test it further — it is a standalone ` +\n\t\t\t\"bench, not a chat/executor lane.\",\n\t);\n}\n\n/**\n * Wipe pi's needle runtime (clone+venv) and downloaded checkpoint. Unlike the other /models remove\n * flows, there is no models.json entry or fitness report to drop (needle never registers as a model\n * — see the roster entry's rationale) and no server process to stop (every needle invocation is a\n * one-shot runCommand call — see needle-runtime.ts's `dispose()` doc comment); removal is purely\n * deleting the two pi-owned directories. needle-runtime.ts exposes no delete method of its own (its\n * public surface is detect/installManaged/downloadWeights/runFunctionCall/smokeTest/dispose), so\n * this deletes directly via the runtime's own path-derivation methods.\n */\nasync function removeNeedleModel(host: LocalModelHost, confirmed: boolean): Promise<void> {\n\tconst runtime = getNeedleRuntime(host);\n\tconst runtimeDir = runtime.runtimeDir();\n\tconst modelsDir = runtime.modelsDir();\n\tif (!confirmed) {\n\t\thost.showStatus(\n\t\t\t[\n\t\t\t\t\"Removing needle will delete:\",\n\t\t\t\t` - the pi-managed needle runtime (clone + venv) at ${runtimeDir}`,\n\t\t\t\t` - the downloaded checkpoint at ${runtime.checkpointPath()}`,\n\t\t\t\t\"needle has no models.json entry or fitness report — it is a standalone function-call test bench, \" +\n\t\t\t\t\t\"never registered as a chat/lane model.\",\n\t\t\t\t\"Run: /models remove hf.co/Cactus-Compute/needle confirm\",\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t\treturn;\n\t}\n\tif (existsSync(runtimeDir)) rmSync(runtimeDir, { recursive: true, force: true });\n\tif (existsSync(modelsDir)) rmSync(modelsDir, { recursive: true, force: true });\n\thost.showStatus(`needle removed: deleted ${runtimeDir} and ${modelsDir}.`);\n}\n\n/**\n * `/models needle <query> [tools-json]` — the actual test surface for needle (see the roster\n * entry's rationale: there is no chat lane to probe it through). `tools-json`, when present, must be\n * the LAST whitespace-split token and start with `[`/`{` (compact JSON, no embedded spaces) —\n * anything else is treated as part of the query and the default smoke-test tool set is used. A fast\n * `detect()`-based pre-check gives friendly install guidance without spawning a doomed process;\n * `runFunctionCall`'s own not-installed/checkpoint-missing pre-flight is still the final honest\n * backstop if state changes between the check and the call.\n */\nasync function runNeedleQuery(host: LocalModelHost, args: string[]): Promise<void> {\n\tif (args.length === 0) {\n\t\thost.showStatus(\"Usage: /models needle <query> [tools-json]\");\n\t\treturn;\n\t}\n\n\tconst runtime = getNeedleRuntime(host);\n\tconst status = await runtime.detect();\n\tif (!status.installed) {\n\t\thost.showStatus(\n\t\t\t\"needle is not installed. Run /models add hf.co/Cactus-Compute/needle first (or /models suggest).\",\n\t\t);\n\t\treturn;\n\t}\n\tif (!status.checkpointPresent) {\n\t\thost.showStatus(\n\t\t\t\"needle is installed but its checkpoint hasn't been downloaded. Run /models add hf.co/Cactus-Compute/needle to fetch and verify it.\",\n\t\t);\n\t\treturn;\n\t}\n\n\tlet tools: unknown = NEEDLE_DEFAULT_TOOLS;\n\tlet toolsJsonParsed = false;\n\tconst last = args[args.length - 1];\n\tif (last && (last.startsWith(\"[\") || last.startsWith(\"{\"))) {\n\t\ttry {\n\t\t\ttools = JSON.parse(last);\n\t\t\ttoolsJsonParsed = true;\n\t\t} catch {\n\t\t\t// Not valid JSON — treat the whole thing as the query, keep the default tools.\n\t\t}\n\t}\n\tconst query = (toolsJsonParsed ? args.slice(0, -1) : args).join(\" \");\n\tif (!query.trim()) {\n\t\thost.showStatus(\"Usage: /models needle <query> [tools-json]\");\n\t\treturn;\n\t}\n\n\thost.showStatus(`needle: running \"${query}\"…`);\n\tconst startedAt = Date.now();\n\tconst result = await runtime.runFunctionCall({ query, tools });\n\tconst latencyMs = Date.now() - startedAt;\n\tif (!result.ok) {\n\t\thost.showStatus(`needle call failed (${latencyMs}ms): ${result.error}\\nraw output:\\n${result.rawOutput}`);\n\t\treturn;\n\t}\n\thost.showStatus(`needle (${latencyMs}ms): ${result.call.name}(${JSON.stringify(result.call.arguments)})`);\n}\n\n/** /fitness with no args: pick a model from the configured registry, probe it, assign a role. */\n/** Pick a validated suggestion → install it → probe on this host → land its shaped role. */\nexport function showModelSuggestionSelector(host: LocalModelHost): void {\n\thost.showSelector((done) => {\n\t\tconst selector = new ModelSuggestionSelectorComponent(\n\t\t\tDEFAULT_MODEL_SUGGESTIONS,\n\t\t\tasync (suggestion) => {\n\t\t\t\tdone();\n\t\t\t\t// The shaped role rides along so the post-probe selector lands on it pre-selected;\n\t\t\t\t// non-tool-callers carry curator/judge/none, never executor, so this can't footgun.\n\t\t\t\tconst source = normalizeModelSource(suggestion.pullRef);\n\t\t\t\tif (source.type === \"transformers\") {\n\t\t\t\t\tawait addTransformersModel(host, source.modelId, suggestion.assignRole);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (source.type === \"prism-llamacpp\") {\n\t\t\t\t\tconst descriptor = PRISM_LLAMACPP_DESCRIPTORS[source.modelId];\n\t\t\t\t\tif (!descriptor) {\n\t\t\t\t\t\thost.showStatus(\n\t\t\t\t\t\t\t`Suggestion ${suggestion.name} maps to an unknown curated prism model \"${source.modelId}\" — wiring bug.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tawait addPrismLlamaCppModel(host, descriptor, suggestion.assignRole);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (source.type === \"needle\") {\n\t\t\t\t\tawait addNeedleModel(host);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (source.type === \"local\") {\n\t\t\t\t\tawait addLocalModel(host, source.pullRef, suggestion.assignRole);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thost.showStatus(\n\t\t\t\t\t`Suggestion ${suggestion.name} is not installable: ${source.type === \"rejected\" ? source.reason : source.ref}`,\n\t\t\t\t);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showFitnessModelSelector(host: LocalModelHost): void {\n\thost.showSelector((done) => {\n\t\tconst selector = new ModelSelectorComponent(\n\t\t\thost.ui,\n\t\t\thost.session.model,\n\t\t\thost.settingsManager,\n\t\t\thost.session.modelRegistry,\n\t\t\thost.session.scopedModels,\n\t\t\tasync (model) => {\n\t\t\t\tdone();\n\t\t\t\tawait runFitnessAndAssign(host, `${model.provider}/${model.id}`);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\n/** Resolve the routed model's supported thinking levels for a fitness-assignment flow, with a safe fallback. */\nfunction getModelThinkingLevels(modelRegistry: ModelRegistry | undefined, modelRef: string): ThinkingLevel[] {\n\tif (!modelRegistry) {\n\t\treturn [...MODEL_ROUTER_THINKING_FALLBACK_LEVELS];\n\t}\n\tconst resolved = resolveCliModel({ cliModel: modelRef, modelRegistry });\n\tif (!resolved.model) {\n\t\treturn [...MODEL_ROUTER_THINKING_FALLBACK_LEVELS];\n\t}\n\treturn getSupportedThinkingLevels(resolved.model);\n}\n\nfunction getModelRouterThinkingField(role: FitnessRole): ModelRouterThinkingField | undefined {\n\tif (role === \"router-cheap\") {\n\t\treturn \"cheapThinking\";\n\t}\n\tif (role === \"router-medium\") {\n\t\treturn \"mediumThinking\";\n\t}\n\tif (role === \"router-expensive\") {\n\t\treturn \"expensiveThinking\";\n\t}\n\tif (role === \"executor\") {\n\t\treturn \"executorThinking\";\n\t}\n\tif (role === \"judge\") {\n\t\treturn \"judgeThinking\";\n\t}\n\treturn undefined;\n}\n\nfunction promptForModelRouterThinking(host: RunFitnessHost, modelRef: string, role: FitnessRole): void {\n\tconst thinkingField = getModelRouterThinkingField(role);\n\tif (!thinkingField) {\n\t\treturn;\n\t}\n\n\tconst modelRegistry = host.session.modelRegistry;\n\tconst availableLevels = getModelThinkingLevels(modelRegistry, modelRef);\n\tconst settings = host.settingsManager.getModelRouterSettings();\n\tconst configuredThinking = settings[thinkingField];\n\tconst currentThinking =\n\t\tconfiguredThinking && availableLevels.includes(configuredThinking)\n\t\t\t? configuredThinking\n\t\t\t: MODEL_ROUTER_THINKING_INHERIT_VALUE;\n\n\thost.showSelector((done) => {\n\t\tconst selector = new ModelRouterThinkingSelectorComponent(\n\t\t\tcurrentThinking,\n\t\t\tavailableLevels,\n\t\t\t(level) => {\n\t\t\t\tdone();\n\t\t\t\thost.settingsManager.setModelRouterSettings({\n\t\t\t\t\t...settings,\n\t\t\t\t\t[thinkingField]: level === MODEL_ROUTER_THINKING_INHERIT_VALUE ? undefined : level,\n\t\t\t\t});\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\n/** Probe a model's fitness, show the report, then offer one-step role assignment. When the model\n * came from a validated suggestion, `preselectRole` lands its shaped role already highlighted. */\nexport async function runFitnessAndAssign(\n\thost: RunFitnessHost,\n\tmodelRef: string,\n\tpreselectRole?: FitnessRole,\n): Promise<void> {\n\thost.showStatus(`Model fitness probe running on ${modelRef}… (6 surfaces; local models may take a few minutes)`);\n\ttry {\n\t\tconst outcome = await host.session.runModelFitness({ model: modelRef });\n\t\tif (!outcome.started) {\n\t\t\thost.showStatus(`Model fitness skipped: ${outcome.skipReason}`);\n\t\t\treturn;\n\t\t}\n\t\thost.chatContainer.addChild(new Spacer(1));\n\t\thost.chatContainer.addChild(new Text(formatModelFitnessReport(outcome.model, outcome.report), 1, 0));\n\t\thost.ui.requestRender();\n\t\t// Validate-before-load: zero successes on every probed surface means the model cannot\n\t\t// drive any of the harness's subagent contracts on this host — refuse adoption instead\n\t\t// of landing a role selector the user might reflexively confirm (this is the reported\n\t\t// bug: a 0/3-everywhere model still got set as judge model and saved to Model Router).\n\t\tif (isProbeAllFailed(outcome.report)) {\n\t\t\thost.showStatus(\n\t\t\t\t`${outcome.model} failed the fitness probe on all surfaces — not configured. Use /model to set it manually if you accept the risk.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\thost.showSelector((done) => {\n\t\t\tconst selector = new FitnessRoleSelectorComponent(\n\t\t\t\toutcome.model,\n\t\t\t\t(role) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tif (role === \"scout\") {\n\t\t\t\t\t\tconst verdict = evaluateSurfaceFitness(\"scout_auto\", outcome.report);\n\t\t\t\t\t\tif (!verdict.fit) {\n\t\t\t\t\t\t\tconst reason = verdict.reason === \"lane_failed\" ? `failed ${verdict.lane}` : \"was not probed\";\n\t\t\t\t\t\t\thost.showStatus(\n\t\t\t\t\t\t\t\t`${outcome.model} not assigned as scout: ${reason} on the scout_auto fitness exam. Use the docs/scout.md Modelfile recipe, then rerun /fitness.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tassignFitnessRole(host, outcome.model, role);\n\t\t\t\t\tpromptForModelRouterThinking(host, outcome.model, role);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t},\n\t\t\t\tpreselectRole,\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector };\n\t\t});\n\t} catch (error) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t}\n}\n\n/** Persist a role assignment from the post-probe selector into the matching settings. */\nexport function assignFitnessRole(host: AssignRoleHost, modelRef: string, role: FitnessRole): void {\n\tif (role === \"none\") {\n\t\thost.showStatus(`Fitness result for ${modelRef} saved. Assign a role later from /settings.`);\n\t\treturn;\n\t}\n\tif (role === \"curator\") {\n\t\tconst current = host.settingsManager.getContextCurationSettings();\n\t\thost.settingsManager.setContextCurationSettings({ ...current, enabled: true, model: modelRef });\n\t\thost.showStatus(`Context curation enabled with ${modelRef} as the curator.`);\n\t\treturn;\n\t}\n\tif (role === \"executor\") {\n\t\tconst router = host.settingsManager.getModelRouterSettings();\n\t\thost.settingsManager.setModelRouterSettings({ ...router, executorModel: modelRef });\n\t\tconst hint = router.enabled ? \"\" : \" Model router is currently disabled — enable it in /settings → Model Router.\";\n\t\thost.showStatus(`${modelRef} set as the toolkit executor (direct Level-0 hits route to it).${hint}`);\n\t\treturn;\n\t}\n\tif (role === \"scout\") {\n\t\thost.settingsManager.setScoutSettings({ enabled: true, model: modelRef });\n\t\thost.showStatus(`${modelRef} set as the repository scout (context_scout enabled).`);\n\t\treturn;\n\t}\n\tconst router = host.settingsManager.getModelRouterSettings();\n\tconst field =\n\t\trole === \"router-cheap\"\n\t\t\t? \"cheapModel\"\n\t\t\t: role === \"router-medium\"\n\t\t\t\t? \"mediumModel\"\n\t\t\t\t: role === \"router-expensive\"\n\t\t\t\t\t? \"expensiveModel\"\n\t\t\t\t\t: role === \"judge\"\n\t\t\t\t\t\t? \"judgeModel\"\n\t\t\t\t\t\t: \"learningModel\";\n\thost.settingsManager.setModelRouterSettings({ ...router, [field]: modelRef });\n\tconst hint = router.enabled ? \"\" : \" Model router is currently disabled — enable it in /settings → Model Router.\";\n\thost.showStatus(`${modelRef} set as ${role.replace(\"router-\", \"router \")} model.${hint}`);\n}\n"]}
1
+ {"version":3,"file":"local-model-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/local-model-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAEN,SAAS,EAET,UAAU,GAGV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EACN,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,GAClB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,o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AAC,sBAAsB,EAAE,CAAC;IAC7D,MAAM,KAAK,GACV,IAAI,KAAK,cAAc;QACtB,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,IAAI,KAAK,eAAe;YACzB,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,IAAI,KAAK,kBAAkB;gBAC5B,CAAC,CAAC,gBAAgB;gBAClB,CAAC,CAAC,IAAI,KAAK,OAAO;oBACjB,CAAC,CAAC,YAAY;oBACd,CAAC,CAAC,eAAe,CAAC;IACvB,IAAI,CAAC,eAAe,CAAC,sBAAsB,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,8EAA8E,CAAC;IAClH,IAAI,CAAC,UAAU,CAAC,GAAG,QAAQ,WAAW,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["/**\n * `/models` local-model lifecycle and `/fitness` probe/role-assignment flows\n * extracted from interactive-mode.\n *\n * `/models` is a USER-invoked local-model manager (list/add/remove/stop, never a\n * model-invokable tool); the fitness helpers probe a model on the current host\n * and land a shaped role. The server/selector flows share a `LocalModelHost`\n * seam, while `runFitnessAndAssign`/`assignFitnessRole` take narrow host shapes\n * matching their prototype-driven behaviour tests (fitness-probe-gate,\n * fitness-role-assignment), which keep exercising interactive-mode's thin\n * wrappers unchanged.\n */\n\nimport { existsSync, rmSync } from \"node:fs\";\nimport { totalmem } from \"node:os\";\nimport type { ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport { getSupportedThinkingLevels } from \"@caupulican/pi-ai\";\nimport {\n\ttype Component,\n\tContainer,\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype TUI,\n} from \"@caupulican/pi-tui\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { ModelRegistry } from \"../../core/model-registry.ts\";\nimport { resolveCliModel } from \"../../core/model-resolver.ts\";\nimport { evaluateSurfaceFitness } from \"../../core/model-router/fitness-gate.ts\";\nimport {\n\tderiveLocalContextSizing,\n\trenderOllamaContextModelfile,\n\tsizedLocalModelRef,\n} from \"../../core/models/context-sizing.ts\";\nimport { DEFAULT_MODEL_SUGGESTIONS } from \"../../core/models/default-model-suggestions.ts\";\nimport { FitnessStore } from \"../../core/models/fitness-store.ts\";\nimport { PrismLlamaCppRuntime, type PrismModelDescriptor } from \"../../core/models/llamacpp-runtime.ts\";\nimport {\n\tHF_TRANSFORMERS_PROVIDER,\n\tPRISM_LLAMACPP_PROVIDER,\n\tregisterLocalModel,\n\tregisterPrismLlamaCppModel,\n\tregisterTransformersModel,\n\tunregisterLocalModel,\n\tunregisterPrismLlamaCppModel,\n\tunregisterTransformersModel,\n} from \"../../core/models/local-registration.ts\";\nimport type { OllamaRuntime, TransformersRuntime } from \"../../core/models/local-runtime.ts\";\nimport { matchesInstalledLocalModel, normalizeModelSource } from \"../../core/models/model-ref.ts\";\nimport { NeedleRuntime } from \"../../core/models/needle-runtime.ts\";\nimport {\n\tderivePrismLlamaCppNumCtx,\n\tensurePrismModelFilesThenServe,\n\tisPiManagedPrismLlamaCppModel,\n\tPRISM_LLAMACPP_DESCRIPTORS,\n\tPRISM_LLAMACPP_SERVE_PORT,\n} from \"../../core/models/prism-llamacpp-lifecycle.ts\";\nimport { isProbeAllFailed } from \"../../core/research/model-fitness.ts\";\nimport type { SettingsManager } from \"../../core/settings-manager.ts\";\nimport { DynamicBorder } from \"./components/dynamic-border.ts\";\nimport { type FitnessRole, FitnessRoleSelectorComponent } from \"./components/fitness-role-selector.ts\";\nimport { ModelSelectorComponent } from \"./components/model-selector.ts\";\nimport { ModelSuggestionSelectorComponent } from \"./components/model-suggestion-selector.ts\";\nimport { presentModelFitnessOutcome } from \"./model-fitness-presentation.ts\";\nimport { getSelectListTheme } from \"./theme/theme.ts\";\n\ntype SelectorFactory = (done: () => void) => { component: Component; focus: Component };\n\nconst MODEL_ROUTER_THINKING_SELECT_LIST_LAYOUT: SelectListLayoutOptions = {\n\tminPrimaryColumnWidth: 12,\n\tmaxPrimaryColumnWidth: 32,\n};\n\nconst MODEL_ROUTER_THINKING_INHERIT_VALUE = \"__inherit_model_router_thinking__\";\nconst MODEL_ROUTER_THINKING_INHERIT_LABEL = \"(inherit)\";\n\nconst THINKING_LEVEL_DESCRIPTIONS: Record<ThinkingLevel, string> = {\n\toff: \"No reasoning\",\n\tminimal: \"Very brief reasoning (~1k tokens)\",\n\tlow: \"Light reasoning (~2k tokens)\",\n\tmedium: \"Moderate reasoning (~8k tokens)\",\n\thigh: \"Deep reasoning (~16k tokens)\",\n\txhigh: \"Maximum reasoning (~32k tokens)\",\n\tmax: \"Maximum reasoning depth for the hardest problems\",\n\tultra: \"Maximum reasoning with reinforced proactive delegation\",\n};\n\nconst MODEL_ROUTER_THINKING_FALLBACK_LEVELS: readonly ThinkingLevel[] = [\n\t\"off\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\",\n\t\"xhigh\",\n];\n\ntype RouterThinkingLevel = ThinkingLevel | typeof MODEL_ROUTER_THINKING_INHERIT_VALUE;\ntype ModelRouterThinkingField =\n\t| \"cheapThinking\"\n\t| \"mediumThinking\"\n\t| \"expensiveThinking\"\n\t| \"executorThinking\"\n\t| \"judgeThinking\";\n\n/** Narrow seam for persisting a probed model's role — matches the fitness-role test. */\nexport interface AssignRoleHost {\n\treadonly settingsManager: SettingsManager;\n\tshowStatus(message: string): void;\n}\n\n/** Seam for the fitness probe + role-selector flow — matches the fitness-probe-gate test. */\nexport interface RunFitnessHost {\n\treadonly session: Pick<AgentSession, \"runModelFitness\"> & { modelRegistry?: ModelRegistry };\n\treadonly settingsManager: SettingsManager;\n\treadonly chatContainer: Container;\n\treadonly ui: TUI;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowSelector(create: SelectorFactory): void;\n}\n\n/** Full seam for the `/models` server/selector flows. */\nexport interface LocalModelHost {\n\treadonly localRuntime: OllamaRuntime;\n\treadonly session: AgentSession;\n\treadonly settingsManager: SettingsManager;\n\treadonly ui: TUI;\n\treadonly chatContainer: Container;\n\tgetTransformersRuntime(modelId: string, baseUrl?: string): TransformersRuntime;\n\t/**\n\t * Seam for the pi-managed prism llama.cpp runtime (Bonsai-27B and future curated prism-ml\n\t * models). Production (interactive-mode.ts's `localModelHost()`) always supplies this, wired\n\t * through `AgentSession.getPrismLlamaCppRuntime()` -> `LocalRuntimeController`'s cached instance\n\t * — the SAME instance the readiness gate uses, mirroring `getTransformersRuntime` above (cached\n\t * for the session's lifetime, so `stop()`/`removePrismLlamaCppModel` reattach to the SAME\n\t * instance that holds the running child process instead of each tracking an untracked one).\n\t * Optional only so tests can inject a fake without needing the full session stack; the fallback\n\t * below (a fresh, uncached instance) is a test convenience, never the production path.\n\t */\n\tgetPrismLlamaCppRuntime?(): PrismLlamaCppRuntime;\n\t/**\n\t * Seam for the pi-managed needle runtime (see needle-runtime.ts) — optional so tests can inject a\n\t * fake, falling back to a fresh instance otherwise. Unlike `getPrismLlamaCppRuntime` above, needle\n\t * has no session-caching need: every invocation is a one-shot `runCommand` call with no persistent\n\t * child process to reattach to (needle-runtime.ts's `dispose()` is a documented no-op), so a fresh\n\t * instance per call is functionally identical to a cached one — `runtimeDir()`/`modelsDir()`/\n\t * `checkpointPath()` are pure path derivations from `agentDir`, not in-memory state.\n\t */\n\tgetNeedleRuntime?(): NeedleRuntime;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowSelector(create: SelectorFactory): void;\n}\n\nfunction getPrismLlamaCppRuntime(host: LocalModelHost): PrismLlamaCppRuntime {\n\treturn host.getPrismLlamaCppRuntime?.() ?? new PrismLlamaCppRuntime({ agentDir: getAgentDir() });\n}\n\nfunction getNeedleRuntime(host: LocalModelHost): NeedleRuntime {\n\treturn host.getNeedleRuntime?.() ?? new NeedleRuntime({ agentDir: getAgentDir() });\n}\n\n/**\n * Mirrors needle-runtime.ts's own (module-private, not exported) NEEDLE_SMOKE_TOOLS — the default\n * tool set for `/models needle <query>` when no tools-json is supplied, so an ad-hoc probe has the\n * same sensible starting point the install pipeline's own smoke test already exercises. Kept in\n * sync manually since the source constant isn't exported from the frozen runtime module.\n */\nconst NEEDLE_DEFAULT_TOOLS = [\n\t{\n\t\tname: \"get_weather\",\n\t\tdescription: \"Get current weather for a city.\",\n\t\tparameters: { location: { type: \"string\", description: \"City name.\", required: true } },\n\t},\n];\n\nclass ModelRouterThinkingSelectorComponent extends Container {\n\tprivate selectList: SelectList;\n\n\tconstructor(\n\t\tcurrentLevel: RouterThinkingLevel,\n\t\tavailableLevels: ThinkingLevel[],\n\t\tonSelect: (level: RouterThinkingLevel) => void,\n\t\tonCancel: () => void,\n\t) {\n\t\tsuper();\n\n\t\tconst thinkingOptions: SelectItem[] = [\n\t\t\t{\n\t\t\t\tvalue: MODEL_ROUTER_THINKING_INHERIT_VALUE,\n\t\t\t\tlabel: MODEL_ROUTER_THINKING_INHERIT_LABEL,\n\t\t\t\tdescription: \"Use current session default for this tier.\",\n\t\t\t},\n\t\t\t...availableLevels.map((level) => ({\n\t\t\t\tvalue: level,\n\t\t\t\tlabel: level,\n\t\t\t\tdescription: THINKING_LEVEL_DESCRIPTIONS[level],\n\t\t\t})),\n\t\t];\n\n\t\tthis.addChild(new DynamicBorder());\n\n\t\tthis.selectList = new SelectList(\n\t\t\tthinkingOptions,\n\t\t\tthinkingOptions.length,\n\t\t\tgetSelectListTheme(),\n\t\t\tMODEL_ROUTER_THINKING_SELECT_LIST_LAYOUT,\n\t\t);\n\n\t\tconst index = thinkingOptions.findIndex((item) => item.value === currentLevel);\n\t\tif (index !== -1) {\n\t\t\tthis.selectList.setSelectedIndex(index);\n\t\t}\n\n\t\tthis.selectList.onSelect = (item) => {\n\t\t\tonSelect(item.value as RouterThinkingLevel);\n\t\t};\n\t\tthis.selectList.onCancel = () => {\n\t\t\tonCancel();\n\t\t};\n\n\t\tthis.addChild(this.selectList);\n\t\tthis.addChild(new DynamicBorder());\n\t}\n}\n/**\n * /models — USER-invoked local model lifecycle (never a model-invokable tool):\n * list/add/remove/stop per local-model-lifecycle-design.md. Removal is explicit-only with\n * full disclosure; a pasted install command is parsed for its ref, never executed.\n */\nexport async function handleModelsCommand(host: LocalModelHost, argsText: string): Promise<void> {\n\tconst [action = \"list\", ...rest] = argsText.split(/\\s+/).filter(Boolean);\n\ttry {\n\t\tif (action === \"suggest\" || action === \"suggestions\") {\n\t\t\tshowModelSuggestionSelector(host);\n\t\t\treturn;\n\t\t}\n\t\tif (action === \"stop\") {\n\t\t\tconst stopped = host.localRuntime.stop();\n\t\t\tlet stoppedTransformers = 0;\n\t\t\tfor (const model of host.session.modelRegistry\n\t\t\t\t.getAll()\n\t\t\t\t.filter((entry) => entry.provider === HF_TRANSFORMERS_PROVIDER)) {\n\t\t\t\tconst serverUrl = model.baseUrl.replace(/\\/v1\\/?$/, \"\");\n\t\t\t\tif (host.getTransformersRuntime(model.id, serverUrl).stop().stopped) stoppedTransformers++;\n\t\t\t}\n\t\t\t// Only touch the prism runtime when a pi-managed prism model is actually registered —\n\t\t\t// never construct/stop it on a session that never used one. isPiManagedPrismLlamaCppModel\n\t\t\t// is the SAME discriminator the readiness gate uses, so this never reaches for a user's own\n\t\t\t// hand-configured llama-cpp entry (e.g. the built-in llama-cpp/local catalog model).\n\t\t\tconst hasPiManagedPrismModel = host.session.modelRegistry\n\t\t\t\t.getAll()\n\t\t\t\t.some((entry) => isPiManagedPrismLlamaCppModel(entry));\n\t\t\tconst stoppedPrism = hasPiManagedPrismModel && getPrismLlamaCppRuntime(host).stop().stopped;\n\t\t\tconst stoppedAny = stopped.stopped || stoppedTransformers > 0 || stoppedPrism;\n\t\t\thost.showStatus(\n\t\t\t\tstoppedAny\n\t\t\t\t\t? `Pi-managed local model server stopped${stoppedTransformers > 0 ? ` (${stoppedTransformers} Transformers sidecar(s))` : \"\"}${stoppedPrism ? \" (prism llama.cpp server)\" : \"\"}; models remain installed.`\n\t\t\t\t\t: \"No pi-managed server running (a system server, if any, is not pi's to stop).\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tif (action === \"import\") {\n\t\t\tconst imported = host.localRuntime.importUserModels();\n\t\t\thost.showStatus(\n\t\t\t\t`Imported Ollama models from ${imported.sourceDir} into pi-owned store ${imported.targetDir}: ` +\n\t\t\t\t\t`${imported.manifestsImported} manifest(s), ${imported.blobsHardlinked} blob(s) hardlinked, ` +\n\t\t\t\t\t`${imported.blobsCopied} blob(s) copied, ${imported.blobsSkipped + imported.manifestsSkipped} existing file(s) skipped.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tif (action === \"needle\") {\n\t\t\tif (rest.length === 0) {\n\t\t\t\thost.showStatus(\"Usage: /models needle <query> [tools-json]\");\n\t\t\t\thost.showStatus(\n\t\t\t\t\t` tools-json defaults to the smoke-test tool set: ${JSON.stringify(NEEDLE_DEFAULT_TOOLS)}`,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait runNeedleQuery(host, rest);\n\t\t\treturn;\n\t\t}\n\n\t\tif (action === \"add\") {\n\t\t\tconst rawRef = rest.join(\" \");\n\t\t\tif (!rawRef) {\n\t\t\t\thost.showStatus(\n\t\t\t\t\t\"Usage: /models add <ollama-tag | hf.co/org/repo[:quant] | curated HF full-base ref | huggingface URL | pasted install command>\",\n\t\t\t\t);\n\t\t\t\thost.showStatus(\"Or start from a validated suggestion: /models suggest\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst source = normalizeModelSource(rawRef);\n\t\t\tif (source.type === \"rejected\") {\n\t\t\t\thost.showStatus(`Not added: ${source.reason}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"api\") {\n\t\t\t\thost.showStatus(\n\t\t\t\t\t`${source.ref} is an API model — nothing to install. Configure auth for the provider, then probe it with /fitness ${source.ref}.`,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"transformers\") {\n\t\t\t\tawait addTransformersModel(host, source.modelId);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"prism-llamacpp\") {\n\t\t\t\tconst descriptor = PRISM_LLAMACPP_DESCRIPTORS[source.modelId];\n\t\t\t\tif (!descriptor) {\n\t\t\t\t\thost.showStatus(`${source.modelId} has no curated prism llama.cpp descriptor — this is a wiring bug.`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait addPrismLlamaCppModel(host, descriptor);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"needle\") {\n\t\t\t\tawait addNeedleModel(host);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait addLocalModel(host, source.pullRef);\n\t\t\treturn;\n\t\t}\n\n\t\tif (action === \"remove\") {\n\t\t\tconst ref = rest[0];\n\t\t\tconst confirmed = rest[1] === \"confirm\";\n\t\t\tif (!ref) {\n\t\t\t\thost.showStatus(\"Usage: /models remove <ref> confirm\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst source = normalizeModelSource(ref);\n\t\t\tif (source.type === \"transformers\") {\n\t\t\t\tawait removeTransformersModel(host, source.modelId, confirmed);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"prism-llamacpp\") {\n\t\t\t\tawait removePrismLlamaCppModel(host, source.modelId, confirmed);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (source.type === \"needle\") {\n\t\t\t\tawait removeNeedleModel(host, confirmed);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait removeLocalModel(host, ref, confirmed);\n\t\t\treturn;\n\t\t}\n\n\t\tawait listLocalModels(host);\n\t} catch (error) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t}\n}\n\nfunction formatOllamaStore(store: { kind: string; path: string; modelCount: number } | undefined): string {\n\tif (!store) return \"unknown store (0 model(s))\";\n\treturn `${store.path} [${store.kind}, ${store.modelCount} model(s)]`;\n}\n\nexport async function ensureLocalServer(host: LocalModelHost): Promise<boolean> {\n\tconst status = await host.localRuntime.detect();\n\tif (status.serverUp) {\n\t\tif (status.activeStore?.kind === \"pi-owned\") return true;\n\t\thost.showStatus(\n\t\t\t`Ollama is already running on ${status.serverUrl} with store ${formatOllamaStore(status.activeStore)}; ` +\n\t\t\t\t`pi's canonical store is ${status.ownedModelsDir} (${status.ownedStore.modelCount} model(s)). ` +\n\t\t\t\t\"Stop the other serve or run /models import before adding models.\",\n\t\t);\n\t\treturn false;\n\t}\n\tif (!status.binaryPath) {\n\t\tfor (const line of host.localRuntime.installGuide()) host.showStatus(line);\n\t\treturn false;\n\t}\n\thost.showStatus(\n\t\t`Starting local model server (${status.binarySource} binary, owned storage: ${status.ownedModelsDir})…`,\n\t);\n\tconst started = await host.localRuntime.start();\n\tif (!started.started) {\n\t\thost.showStatus(`Could not start the local server: ${started.reason}`);\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nexport async function listLocalModels(host: LocalModelHost): Promise<void> {\n\tconst status = await host.localRuntime.detect();\n\tconst models = status.serverUp ? await host.localRuntime.list() : [];\n\tconst ollamaLines = status.serverUp\n\t\t? [\n\t\t\t\t`Ollama models (active store: ${formatOllamaStore(status.activeStore)}; pi-owned store: ${status.ownedModelsDir} with ${status.ownedStore.modelCount} model(s)):`,\n\t\t\t\t...(models.length === 0\n\t\t\t\t\t? [\" (none installed — /models add <ref>, /models import, or /models suggest for a validated roster)\"]\n\t\t\t\t\t: []),\n\t\t\t]\n\t\t: [\n\t\t\t\t\"Ollama models:\",\n\t\t\t\t...(status.binaryPath\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t` server not running (binary: ${status.binarySource}). /models add starts it on demand; /fitness probes registered models.`,\n\t\t\t\t\t\t]\n\t\t\t\t\t: host.localRuntime.installGuide().map((line) => ` ${line}`)),\n\t\t\t];\n\tconst fitness = FitnessStore.forAgentDir(getAgentDir()).getForHost();\n\tconst transformersModels = host.session.modelRegistry\n\t\t.getAll()\n\t\t.filter((model) => model.provider === HF_TRANSFORMERS_PROVIDER);\n\tconst transformersLines = await Promise.all(\n\t\ttransformersModels.map(async (model) => {\n\t\t\tconst serverUrl = model.baseUrl.replace(/\\/v1\\/?$/, \"\");\n\t\t\tconst runtime = host.getTransformersRuntime(model.id, serverUrl);\n\t\t\tconst runtimeStatus = await runtime.detect();\n\t\t\tconst report = fitness.find((entry) => entry.model === `${HF_TRANSFORMERS_PROVIDER}/${model.id}`);\n\t\t\tconst readiness = runtimeStatus.serverUp\n\t\t\t\t? \"server running\"\n\t\t\t\t: runtimeStatus.runtimeInstalled\n\t\t\t\t\t? \"runtime installed\"\n\t\t\t\t\t: \"runtime missing\";\n\t\t\tconst probe = report\n\t\t\t\t? `probed ${report.at.slice(0, 10)}: digest ${report.report.digest?.succeeded ?? \"?\"}/${report.report.digest?.total ?? \"?\"}, tool-calls ${report.report.toolCall.succeeded}/${report.report.toolCall.total}${report.report.tokensPerSecond ? `, ~${report.report.tokensPerSecond} tok/s` : \"\"}`\n\t\t\t\t: `unprobed — run /fitness ${HF_TRANSFORMERS_PROVIDER}/${model.id}`;\n\t\t\treturn ` - ${model.id} (${readiness}, cache: ${runtimeStatus.cacheDir}) · ${probe}`;\n\t\t}),\n\t);\n\tconst lines = [\n\t\t...ollamaLines,\n\t\t...models.map((model) => {\n\t\t\tconst report = fitness.find((entry) => entry.model === `ollama/${model.name}`);\n\t\t\tconst gb = (model.sizeBytes / 1e9).toFixed(2);\n\t\t\tconst probe = report\n\t\t\t\t? `probed ${report.at.slice(0, 10)}: digest ${report.report.digest?.succeeded ?? \"?\"}/${report.report.digest?.total ?? \"?\"}, tool-calls ${report.report.toolCall.succeeded}/${report.report.toolCall.total}${report.report.tokensPerSecond ? `, ~${report.report.tokensPerSecond} tok/s` : \"\"}`\n\t\t\t\t: `unprobed — run /fitness ollama/${model.name}`;\n\t\t\treturn ` - ${model.name} (${gb} GB) · ${probe}`;\n\t\t}),\n\t\t...(transformersLines.length > 0 ? [\"Pi-managed Transformers models:\", ...transformersLines] : []),\n\t\t\"Commands: /models import · /models add <ref> · /models remove <ref> confirm · /models stop\",\n\t];\n\tfor (const line of lines) host.showStatus(line);\n}\n\nexport async function addLocalModel(host: LocalModelHost, pullRef: string, preselectRole?: FitnessRole): Promise<void> {\n\tif (!(await ensureLocalServer(host))) return;\n\thost.showStatus(`Pulling ${pullRef}… (weights land in pi's owned Ollama store)`);\n\tlet lastShown = 0;\n\tconst pulled = await host.localRuntime.pull(pullRef, (progress) => {\n\t\tconst now = Date.now();\n\t\tif (now - lastShown > 2000) {\n\t\t\tlastShown = now;\n\t\t\thost.showStatus(` ${pullRef}: ${progress}`);\n\t\t}\n\t});\n\tif (!pulled.ok) {\n\t\thost.showStatus(`Pull failed: ${pulled.error}`);\n\t\treturn;\n\t}\n\tconst installed = await host.localRuntime.list().catch(() => []);\n\tconst installedEntry = installed.find((entry) => matchesInstalledLocalModel(pullRef, entry.name));\n\tconst shown = await host.localRuntime.show(pullRef);\n\tconst sizing =\n\t\tinstalledEntry && shown.ok\n\t\t\t? deriveLocalContextSizing({\n\t\t\t\t\thost: { totalMemBytes: totalmem() },\n\t\t\t\t\tmodel: { modelInfo: shown.info.modelInfo, weightsBytes: installedEntry.sizeBytes },\n\t\t\t\t\truntime: { supportsKvQuantization: true },\n\t\t\t\t})\n\t\t\t: undefined;\n\tlet registeredRef = pullRef;\n\tif (sizing) {\n\t\tconst sizedRef = sizedLocalModelRef(pullRef, sizing.numCtx);\n\t\tconst created = await host.localRuntime.createFromModelfile({\n\t\t\tname: sizedRef,\n\t\t\tmodelfile: renderOllamaContextModelfile({ from: pullRef, numCtx: sizing.numCtx }),\n\t\t});\n\t\tif (!created.ok) {\n\t\t\thost.showStatus(`Pulled, but could not create sized context model: ${created.error}`);\n\t\t\treturn;\n\t\t}\n\t\tregisteredRef = sizedRef;\n\t}\n\tconst registration = registerLocalModel({\n\t\tagentDir: getAgentDir(),\n\t\tref: registeredRef,\n\t\tbaseUrl: host.localRuntime.baseUrl,\n\t\tcontextWindow: sizing?.numCtx,\n\t\tservedContextWindow: sizing?.numCtx,\n\t});\n\tif (!registration.ok) {\n\t\thost.showStatus(`Pulled, but not auto-registered: ${registration.reason}`);\n\t\tif (registration.manualSnippet) {\n\t\t\thost.showStatus(`Add this to ${registration.modelsJsonPath} yourself:\\n${registration.manualSnippet}`);\n\t\t}\n\t\treturn;\n\t}\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(`${pullRef} installed and registered as ollama/${registeredRef}. Probing fitness…`);\n\tawait runFitnessAndAssign(host, `ollama/${registeredRef}`, preselectRole);\n}\n\nexport async function addTransformersModel(\n\thost: LocalModelHost,\n\tmodelId: string,\n\tpreselectRole?: FitnessRole,\n): Promise<void> {\n\tconst runtime = host.getTransformersRuntime(modelId);\n\tlet status = await runtime.detect();\n\tif (!status.runtimeInstalled) {\n\t\thost.showStatus(`Installing isolated Transformers runtime for ${modelId} at ${status.venvDir}…`);\n\t\tconst installed = await runtime.installManaged((progress) => host.showStatus(` transformers: ${progress}`));\n\t\tif (!installed.ok) {\n\t\t\thost.showStatus(`Transformers runtime install failed: ${installed.error}`);\n\t\t\treturn;\n\t\t}\n\t\tstatus = await runtime.detect();\n\t}\n\tif (!status.runtimeInstalled) {\n\t\thost.showStatus(`Transformers runtime is still unavailable at ${status.venvDir}.`);\n\t\treturn;\n\t}\n\n\tconst downloaded = await runtime.downloadModel((progress) => host.showStatus(` ${modelId}: ${progress}`));\n\tif (!downloaded.ok) {\n\t\thost.showStatus(`Model download failed: ${downloaded.error}`);\n\t\treturn;\n\t}\n\n\tconst started = await runtime.start();\n\tif (!started.started && started.reason !== \"already_running\") {\n\t\thost.showStatus(`Could not start Transformers sidecar: ${started.reason}`);\n\t\treturn;\n\t}\n\n\tconst registration = registerTransformersModel({\n\t\tagentDir: getAgentDir(),\n\t\tmodelId,\n\t\tbaseUrl: runtime.baseUrl,\n\t});\n\tif (!registration.ok) {\n\t\thost.showStatus(`Installed, but not auto-registered: ${registration.reason}`);\n\t\tif (registration.manualSnippet) {\n\t\t\thost.showStatus(`Add this to ${registration.modelsJsonPath} yourself:\\n${registration.manualSnippet}`);\n\t\t}\n\t\treturn;\n\t}\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(\n\t\t`${modelId} installed in pi-managed Transformers and registered as ${HF_TRANSFORMERS_PROVIDER}/${modelId}. Probing fitness…`,\n\t);\n\tawait runFitnessAndAssign(host, `${HF_TRANSFORMERS_PROVIDER}/${modelId}`, preselectRole);\n}\n\n/**\n * Zero-setup pipeline for a curated prism llama.cpp model (Bonsai-27B): install the pinned prism\n * llama.cpp runtime (prebuilt release download, no compiler needed), ensure both GGUF files and\n * start llama-server (see `ensurePrismModelFilesThenServe`), register the model, then probe\n * fitness. Mirrors addTransformersModel's shape — each stage checks its own `{ ok }`/\n * `{ runtimeInstalled }` result and stops with an honest status message on failure; nothing\n * continues past a failed stage.\n */\nexport async function addPrismLlamaCppModel(\n\thost: LocalModelHost,\n\tdescriptor: PrismModelDescriptor,\n\tpreselectRole?: FitnessRole,\n): Promise<void> {\n\tconst runtime = getPrismLlamaCppRuntime(host);\n\tconst modelId = descriptor.repo;\n\n\tlet status = await runtime.detect();\n\tif (!status.runtimeInstalled) {\n\t\thost.showStatus(`Installing prism llama.cpp runtime for ${descriptor.displayName} at ${runtime.runtimeDir()}…`);\n\t\tconst installed = await runtime.installManaged((progress) => host.showStatus(` prism-llamacpp: ${progress}`));\n\t\tif (!installed.ok) {\n\t\t\thost.showStatus(`Prism llama.cpp runtime install failed: ${installed.error}`);\n\t\t\treturn;\n\t\t}\n\t\tstatus = await runtime.detect();\n\t}\n\tif (!status.runtimeInstalled) {\n\t\thost.showStatus(`Prism llama.cpp runtime is still unavailable at ${runtime.runtimeDir()}.`);\n\t\treturn;\n\t}\n\n\tconst numCtx = derivePrismLlamaCppNumCtx(totalmem());\n\tconst served = await ensurePrismModelFilesThenServe(\n\t\truntime,\n\t\tdescriptor,\n\t\t{ port: PRISM_LLAMACPP_SERVE_PORT, numCtx },\n\t\t(message) => host.showStatus(message),\n\t);\n\tif (!served.ok) {\n\t\tconst label =\n\t\t\tserved.stage === \"model-download\"\n\t\t\t\t? \"Model download failed\"\n\t\t\t\t: served.stage === \"mmproj-download\"\n\t\t\t\t\t? \"Vision projector download failed\"\n\t\t\t\t\t: \"Could not start llama-server\";\n\t\thost.showStatus(`${label}: ${served.error}`);\n\t\treturn;\n\t}\n\n\tconst registration = registerPrismLlamaCppModel({\n\t\tagentDir: getAgentDir(),\n\t\tmodelId,\n\t\tbaseUrl: served.baseUrl,\n\t\tcontextWindow: numCtx,\n\t\tservedContextWindow: numCtx,\n\t});\n\tif (!registration.ok) {\n\t\thost.showStatus(`Served, but not auto-registered: ${registration.reason}`);\n\t\tif (registration.manualSnippet) {\n\t\t\thost.showStatus(`Add this to ${registration.modelsJsonPath} yourself:\\n${registration.manualSnippet}`);\n\t\t}\n\t\treturn;\n\t}\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(\n\t\t`${descriptor.displayName} installed and registered as ${PRISM_LLAMACPP_PROVIDER}/${modelId}. Probing fitness…`,\n\t);\n\tawait runFitnessAndAssign(host, `${PRISM_LLAMACPP_PROVIDER}/${modelId}`, preselectRole);\n}\n\nexport async function removeLocalModel(host: LocalModelHost, ref: string, confirmed: boolean): Promise<void> {\n\tconst status = await host.localRuntime.detect();\n\tif (!status.serverUp) {\n\t\thost.showStatus(\"Local server not running — start it (any /models action) before removing.\");\n\t\treturn;\n\t}\n\tconst models = await host.localRuntime.list();\n\tconst target = models.find((model) => matchesInstalledLocalModel(ref, model.name));\n\tif (!target) {\n\t\thost.showStatus(\n\t\t\t`${ref} is not installed. Installed: ${models.map((model) => model.name).join(\", \") || \"(none)\"}`,\n\t\t);\n\t\treturn;\n\t}\n\tif (!confirmed) {\n\t\t// EXPLICIT USER ACTION ONLY: full disclosure, then require the confirm token.\n\t\tconst gb = (target.sizeBytes / 1e9).toFixed(2);\n\t\thost.showStatus(\n\t\t\t[\n\t\t\t\t`Removing ${ref} will delete:`,\n\t\t\t\t` - model weights (${gb} GB) from ${status.managedByPi ? status.ownedModelsDir : \"the system server's storage\"}`,\n\t\t\t\t` - the ollama/${ref} entry in models.json`,\n\t\t\t\t` - its cached fitness report for this host`,\n\t\t\t\t`Run: /models remove ${ref} confirm`,\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t\treturn;\n\t}\n\tconst removed = await host.localRuntime.remove(ref);\n\tif (!removed.ok) {\n\t\thost.showStatus(`Remove failed: ${removed.error}`);\n\t\treturn;\n\t}\n\tunregisterLocalModel({ agentDir: getAgentDir(), ref });\n\tFitnessStore.forAgentDir(getAgentDir()).remove(`ollama/${ref}`);\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(`${ref} removed: weights deleted, registration and fitness report dropped.`);\n}\n\nasync function removeTransformersModel(host: LocalModelHost, modelId: string, confirmed: boolean): Promise<void> {\n\tconst runtime = host.getTransformersRuntime(modelId);\n\tconst status = await runtime.detect();\n\tif (!confirmed) {\n\t\thost.showStatus(\n\t\t\t[\n\t\t\t\t`Removing ${modelId} will delete:`,\n\t\t\t\t` - the ${HF_TRANSFORMERS_PROVIDER}/${modelId} entry in models.json`,\n\t\t\t\t` - its cached fitness report for this host`,\n\t\t\t\t`It will stop this session's Transformers sidecar if running. Cached weights remain under ${status.cacheDir}.`,\n\t\t\t\t`Run: /models remove hf.co/${modelId} confirm`,\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t\treturn;\n\t}\n\truntime.stop();\n\tconst registration = unregisterTransformersModel({ agentDir: getAgentDir(), modelId });\n\tif (!registration.ok) {\n\t\thost.showStatus(`Remove failed: ${registration.reason}`);\n\t\treturn;\n\t}\n\tFitnessStore.forAgentDir(getAgentDir()).remove(`${HF_TRANSFORMERS_PROVIDER}/${modelId}`);\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(\n\t\t`${modelId} registration and fitness report dropped; cached weights remain under ${status.cacheDir}.`,\n\t);\n}\n\n/**\n * Drop a pi-managed prism llama.cpp model's registration and fitness report. Production supplies a\n * session-cached runtime (see `LocalModelHost.getPrismLlamaCppRuntime`'s doc comment), the SAME\n * instance the readiness gate uses, so `stop()` here reliably reaches the tracked child whenever\n * THIS session is the one that started it — including a server started earlier in the session by\n * the readiness gate itself, not just by a prior `/models add`. Only a server started by a\n * DIFFERENT process/session (pi restarted, a different terminal) is out of reach; the status text\n * only carries that caveat, not a blanket \"may not stop\" disclaimer.\n */\nasync function removePrismLlamaCppModel(host: LocalModelHost, modelId: string, confirmed: boolean): Promise<void> {\n\tconst runtime = getPrismLlamaCppRuntime(host);\n\tif (!confirmed) {\n\t\thost.showStatus(\n\t\t\t[\n\t\t\t\t`Removing ${modelId} will delete:`,\n\t\t\t\t` - the ${PRISM_LLAMACPP_PROVIDER}/${modelId} entry in models.json`,\n\t\t\t\t` - its cached fitness report for this host`,\n\t\t\t\t`Downloaded GGUF weights remain under ${runtime.modelsDir()}. Its llama-server will be stopped if ` +\n\t\t\t\t\t`this session started it; if it was started by a different pi process or session, it will keep ` +\n\t\t\t\t\t`serving on 127.0.0.1:${PRISM_LLAMACPP_SERVE_PORT} until stopped manually.`,\n\t\t\t\t`Run: /models remove hf.co/${modelId} confirm`,\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t\treturn;\n\t}\n\tconst stopped = runtime.stop();\n\tconst registration = unregisterPrismLlamaCppModel({ agentDir: getAgentDir(), modelId });\n\tif (!registration.ok) {\n\t\thost.showStatus(`Remove failed: ${registration.reason}`);\n\t\treturn;\n\t}\n\tFitnessStore.forAgentDir(getAgentDir()).remove(`${PRISM_LLAMACPP_PROVIDER}/${modelId}`);\n\thost.session.modelRegistry.refresh();\n\thost.showStatus(\n\t\t`${modelId} registration and fitness report dropped; downloaded weights remain under ${runtime.modelsDir()}.` +\n\t\t\t(stopped.stopped\n\t\t\t\t? \" Its llama-server was stopped.\"\n\t\t\t\t: ` No llama-server tracked by this session — if one is still running (started by a different pi process or session), stop it manually on port ${PRISM_LLAMACPP_SERVE_PORT}.`),\n\t);\n}\n\n/**\n * Zero-setup pipeline for needle (see needle-runtime.ts): a standalone 26M-parameter function-call\n * test bench, NOT a chat/executor/lane model — no OpenAI-compatible endpoint, no models.json\n * registration, no /fitness probe. Install the pinned needle clone+venv (menu pick = consent, same\n * doctrine as the Transformers/prism precedents), download and sha256-verify the pickle checkpoint\n * (never called implicitly by installManaged — see the module's SECURITY note: the checkpoint is a\n * pickle file, arbitrary code execution on load by construction, so this is deliberately a separate\n * consent-adjacent step, not folded into install), then run its own smoke test as the honest\n * post-install verification. Each stage checks its own `{ ok }` result and stops with a stage-tagged\n * status on failure; nothing continues past a failed stage.\n */\nexport async function addNeedleModel(host: LocalModelHost): Promise<void> {\n\tconst runtime = getNeedleRuntime(host);\n\n\tlet status = await runtime.detect();\n\tif (!status.installed) {\n\t\thost.showStatus(`Installing needle (function-call test bench) at ${runtime.runtimeDir()}…`);\n\t\tconst installed = await runtime.installManaged((progress) => host.showStatus(` needle: ${progress}`));\n\t\tif (!installed.ok) {\n\t\t\thost.showStatus(`needle install failed: ${installed.error}`);\n\t\t\treturn;\n\t\t}\n\t\tstatus = await runtime.detect();\n\t}\n\tif (!status.installed) {\n\t\thost.showStatus(`needle is still unavailable at ${runtime.runtimeDir()}.`);\n\t\treturn;\n\t}\n\n\tconst downloaded = await runtime.downloadWeights((progress) => host.showStatus(` ${progress}`));\n\tif (!downloaded.ok) {\n\t\thost.showStatus(`needle weights download failed: ${downloaded.error}`);\n\t\treturn;\n\t}\n\n\thost.showStatus(\"Running needle smoke test (function-call probe)…\");\n\tconst smoke = await runtime.smokeTest();\n\tif (!smoke.ok || !smoke.call) {\n\t\thost.showStatus(\n\t\t\t`needle smoke test failed: ${smoke.error ?? \"smoke test reported success but returned no parsed call\"}`,\n\t\t);\n\t\treturn;\n\t}\n\thost.showStatus(\n\t\t`needle installed and verified: smoke test called ${smoke.call.name}(${JSON.stringify(smoke.call.arguments)}) ` +\n\t\t\t`in ${smoke.latencyMs}ms. Use /models needle <query> [tools-json] to test it further — it is a standalone ` +\n\t\t\t\"bench, not a chat/executor lane.\",\n\t);\n}\n\n/**\n * Wipe pi's needle runtime (clone+venv) and downloaded checkpoint. Unlike the other /models remove\n * flows, there is no models.json entry or fitness report to drop (needle never registers as a model\n * — see the roster entry's rationale) and no server process to stop (every needle invocation is a\n * one-shot runCommand call — see needle-runtime.ts's `dispose()` doc comment); removal is purely\n * deleting the two pi-owned directories. needle-runtime.ts exposes no delete method of its own (its\n * public surface is detect/installManaged/downloadWeights/runFunctionCall/smokeTest/dispose), so\n * this deletes directly via the runtime's own path-derivation methods.\n */\nasync function removeNeedleModel(host: LocalModelHost, confirmed: boolean): Promise<void> {\n\tconst runtime = getNeedleRuntime(host);\n\tconst runtimeDir = runtime.runtimeDir();\n\tconst modelsDir = runtime.modelsDir();\n\tif (!confirmed) {\n\t\thost.showStatus(\n\t\t\t[\n\t\t\t\t\"Removing needle will delete:\",\n\t\t\t\t` - the pi-managed needle runtime (clone + venv) at ${runtimeDir}`,\n\t\t\t\t` - the downloaded checkpoint at ${runtime.checkpointPath()}`,\n\t\t\t\t\"needle has no models.json entry or fitness report — it is a standalone function-call test bench, \" +\n\t\t\t\t\t\"never registered as a chat/lane model.\",\n\t\t\t\t\"Run: /models remove hf.co/Cactus-Compute/needle confirm\",\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t\treturn;\n\t}\n\tif (existsSync(runtimeDir)) rmSync(runtimeDir, { recursive: true, force: true });\n\tif (existsSync(modelsDir)) rmSync(modelsDir, { recursive: true, force: true });\n\thost.showStatus(`needle removed: deleted ${runtimeDir} and ${modelsDir}.`);\n}\n\n/**\n * `/models needle <query> [tools-json]` — the actual test surface for needle (see the roster\n * entry's rationale: there is no chat lane to probe it through). `tools-json`, when present, must be\n * the LAST whitespace-split token and start with `[`/`{` (compact JSON, no embedded spaces) —\n * anything else is treated as part of the query and the default smoke-test tool set is used. A fast\n * `detect()`-based pre-check gives friendly install guidance without spawning a doomed process;\n * `runFunctionCall`'s own not-installed/checkpoint-missing pre-flight is still the final honest\n * backstop if state changes between the check and the call.\n */\nasync function runNeedleQuery(host: LocalModelHost, args: string[]): Promise<void> {\n\tif (args.length === 0) {\n\t\thost.showStatus(\"Usage: /models needle <query> [tools-json]\");\n\t\treturn;\n\t}\n\n\tconst runtime = getNeedleRuntime(host);\n\tconst status = await runtime.detect();\n\tif (!status.installed) {\n\t\thost.showStatus(\n\t\t\t\"needle is not installed. Run /models add hf.co/Cactus-Compute/needle first (or /models suggest).\",\n\t\t);\n\t\treturn;\n\t}\n\tif (!status.checkpointPresent) {\n\t\thost.showStatus(\n\t\t\t\"needle is installed but its checkpoint hasn't been downloaded. Run /models add hf.co/Cactus-Compute/needle to fetch and verify it.\",\n\t\t);\n\t\treturn;\n\t}\n\n\tlet tools: unknown = NEEDLE_DEFAULT_TOOLS;\n\tlet toolsJsonParsed = false;\n\tconst last = args[args.length - 1];\n\tif (last && (last.startsWith(\"[\") || last.startsWith(\"{\"))) {\n\t\ttry {\n\t\t\ttools = JSON.parse(last);\n\t\t\ttoolsJsonParsed = true;\n\t\t} catch {\n\t\t\t// Not valid JSON — treat the whole thing as the query, keep the default tools.\n\t\t}\n\t}\n\tconst query = (toolsJsonParsed ? args.slice(0, -1) : args).join(\" \");\n\tif (!query.trim()) {\n\t\thost.showStatus(\"Usage: /models needle <query> [tools-json]\");\n\t\treturn;\n\t}\n\n\thost.showStatus(`needle: running \"${query}\"…`);\n\tconst startedAt = Date.now();\n\tconst result = await runtime.runFunctionCall({ query, tools });\n\tconst latencyMs = Date.now() - startedAt;\n\tif (!result.ok) {\n\t\thost.showStatus(`needle call failed (${latencyMs}ms): ${result.error}\\nraw output:\\n${result.rawOutput}`);\n\t\treturn;\n\t}\n\thost.showStatus(`needle (${latencyMs}ms): ${result.call.name}(${JSON.stringify(result.call.arguments)})`);\n}\n\n/** /fitness with no args: pick a model from the configured registry, probe it, assign a role. */\n/** Pick a validated suggestion → install it → probe on this host → land its shaped role. */\nexport function showModelSuggestionSelector(host: LocalModelHost): void {\n\thost.showSelector((done) => {\n\t\tconst selector = new ModelSuggestionSelectorComponent(\n\t\t\tDEFAULT_MODEL_SUGGESTIONS,\n\t\t\tasync (suggestion) => {\n\t\t\t\tdone();\n\t\t\t\t// The shaped role rides along so the post-probe selector lands on it pre-selected;\n\t\t\t\t// non-tool-callers carry curator/judge/none, never executor, so this can't footgun.\n\t\t\t\tconst source = normalizeModelSource(suggestion.pullRef);\n\t\t\t\tif (source.type === \"transformers\") {\n\t\t\t\t\tawait addTransformersModel(host, source.modelId, suggestion.assignRole);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (source.type === \"prism-llamacpp\") {\n\t\t\t\t\tconst descriptor = PRISM_LLAMACPP_DESCRIPTORS[source.modelId];\n\t\t\t\t\tif (!descriptor) {\n\t\t\t\t\t\thost.showStatus(\n\t\t\t\t\t\t\t`Suggestion ${suggestion.name} maps to an unknown curated prism model \"${source.modelId}\" — wiring bug.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tawait addPrismLlamaCppModel(host, descriptor, suggestion.assignRole);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (source.type === \"needle\") {\n\t\t\t\t\tawait addNeedleModel(host);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (source.type === \"local\") {\n\t\t\t\t\tawait addLocalModel(host, source.pullRef, suggestion.assignRole);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thost.showStatus(\n\t\t\t\t\t`Suggestion ${suggestion.name} is not installable: ${source.type === \"rejected\" ? source.reason : source.ref}`,\n\t\t\t\t);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showFitnessModelSelector(host: LocalModelHost): void {\n\thost.showSelector((done) => {\n\t\tconst selector = new ModelSelectorComponent(\n\t\t\thost.ui,\n\t\t\thost.session.model,\n\t\t\thost.settingsManager,\n\t\t\thost.session.modelRegistry,\n\t\t\thost.session.scopedModels,\n\t\t\tasync (model) => {\n\t\t\t\tdone();\n\t\t\t\tawait runFitnessAndAssign(host, `${model.provider}/${model.id}`);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\n/** Resolve the routed model's supported thinking levels for a fitness-assignment flow, with a safe fallback. */\nfunction getModelThinkingLevels(modelRegistry: ModelRegistry | undefined, modelRef: string): ThinkingLevel[] {\n\tif (!modelRegistry) {\n\t\treturn [...MODEL_ROUTER_THINKING_FALLBACK_LEVELS];\n\t}\n\tconst resolved = resolveCliModel({ cliModel: modelRef, modelRegistry });\n\tif (!resolved.model) {\n\t\treturn [...MODEL_ROUTER_THINKING_FALLBACK_LEVELS];\n\t}\n\treturn getSupportedThinkingLevels(resolved.model);\n}\n\nfunction getModelRouterThinkingField(role: FitnessRole): ModelRouterThinkingField | undefined {\n\tif (role === \"router-cheap\") {\n\t\treturn \"cheapThinking\";\n\t}\n\tif (role === \"router-medium\") {\n\t\treturn \"mediumThinking\";\n\t}\n\tif (role === \"router-expensive\") {\n\t\treturn \"expensiveThinking\";\n\t}\n\tif (role === \"executor\") {\n\t\treturn \"executorThinking\";\n\t}\n\tif (role === \"judge\") {\n\t\treturn \"judgeThinking\";\n\t}\n\treturn undefined;\n}\n\nfunction promptForModelRouterThinking(host: RunFitnessHost, modelRef: string, role: FitnessRole): void {\n\tconst thinkingField = getModelRouterThinkingField(role);\n\tif (!thinkingField) {\n\t\treturn;\n\t}\n\n\tconst modelRegistry = host.session.modelRegistry;\n\tconst availableLevels = getModelThinkingLevels(modelRegistry, modelRef);\n\tconst settings = host.settingsManager.getModelRouterSettings();\n\tconst configuredThinking = settings[thinkingField];\n\tconst currentThinking =\n\t\tconfiguredThinking && availableLevels.includes(configuredThinking)\n\t\t\t? configuredThinking\n\t\t\t: MODEL_ROUTER_THINKING_INHERIT_VALUE;\n\n\thost.showSelector((done) => {\n\t\tconst selector = new ModelRouterThinkingSelectorComponent(\n\t\t\tcurrentThinking,\n\t\t\tavailableLevels,\n\t\t\t(level) => {\n\t\t\t\tdone();\n\t\t\t\thost.settingsManager.setModelRouterSettings({\n\t\t\t\t\t...settings,\n\t\t\t\t\t[thinkingField]: level === MODEL_ROUTER_THINKING_INHERIT_VALUE ? undefined : level,\n\t\t\t\t});\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\n/** Probe a model's fitness, show the report, then offer one-step role assignment. When the model\n * came from a validated suggestion, `preselectRole` lands its shaped role already highlighted. */\nexport async function runFitnessAndAssign(\n\thost: RunFitnessHost,\n\tmodelRef: string,\n\tpreselectRole?: FitnessRole,\n): Promise<void> {\n\thost.showStatus(`Model fitness probe running on ${modelRef}… (6 surfaces; local models may take a few minutes)`);\n\ttry {\n\t\tconst outcome = await host.session.runModelFitness({ model: modelRef });\n\t\tif (!presentModelFitnessOutcome(host, outcome)) return;\n\t\t// Validate-before-load: zero successes on every probed surface means the model cannot\n\t\t// drive any of the harness's subagent contracts on this host — refuse adoption instead\n\t\t// of landing a role selector the user might reflexively confirm (this is the reported\n\t\t// bug: a 0/3-everywhere model still got set as judge model and saved to Model Router).\n\t\tif (isProbeAllFailed(outcome.report)) {\n\t\t\thost.showStatus(\n\t\t\t\t`${outcome.model} failed the fitness probe on all surfaces — not configured. Use /model to set it manually if you accept the risk.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\thost.showSelector((done) => {\n\t\t\tconst selector = new FitnessRoleSelectorComponent(\n\t\t\t\toutcome.model,\n\t\t\t\t(role) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tif (role === \"scout\") {\n\t\t\t\t\t\tconst verdict = evaluateSurfaceFitness(\"scout_auto\", outcome.report);\n\t\t\t\t\t\tif (!verdict.fit) {\n\t\t\t\t\t\t\tconst reason = verdict.reason === \"lane_failed\" ? `failed ${verdict.lane}` : \"was not probed\";\n\t\t\t\t\t\t\thost.showStatus(\n\t\t\t\t\t\t\t\t`${outcome.model} not assigned as scout: ${reason} on the scout_auto fitness exam. Use the docs/scout.md Modelfile recipe, then rerun /fitness.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tassignFitnessRole(host, outcome.model, role);\n\t\t\t\t\tpromptForModelRouterThinking(host, outcome.model, role);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t},\n\t\t\t\tpreselectRole,\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector };\n\t\t});\n\t} catch (error) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t}\n}\n\n/** Persist a role assignment from the post-probe selector into the matching settings. */\nexport function assignFitnessRole(host: AssignRoleHost, modelRef: string, role: FitnessRole): void {\n\tif (role === \"none\") {\n\t\thost.showStatus(`Fitness result for ${modelRef} saved. Assign a role later from /settings.`);\n\t\treturn;\n\t}\n\tif (role === \"curator\") {\n\t\tconst current = host.settingsManager.getContextCurationSettings();\n\t\thost.settingsManager.setContextCurationSettings({ ...current, enabled: true, model: modelRef });\n\t\thost.showStatus(`Context curation enabled with ${modelRef} as the curator.`);\n\t\treturn;\n\t}\n\tif (role === \"executor\") {\n\t\tconst router = host.settingsManager.getModelRouterSettings();\n\t\thost.settingsManager.setModelRouterSettings({ ...router, executorModel: modelRef });\n\t\tconst hint = router.enabled ? \"\" : \" Model router is currently disabled — enable it in /settings → Model Router.\";\n\t\thost.showStatus(`${modelRef} set as the toolkit executor (direct Level-0 hits route to it).${hint}`);\n\t\treturn;\n\t}\n\tif (role === \"scout\") {\n\t\thost.settingsManager.setScoutSettings({ enabled: true, model: modelRef });\n\t\thost.showStatus(`${modelRef} set as the repository scout (context_scout enabled).`);\n\t\treturn;\n\t}\n\tconst router = host.settingsManager.getModelRouterSettings();\n\tconst field =\n\t\trole === \"router-cheap\"\n\t\t\t? \"cheapModel\"\n\t\t\t: role === \"router-medium\"\n\t\t\t\t? \"mediumModel\"\n\t\t\t\t: role === \"router-expensive\"\n\t\t\t\t\t? \"expensiveModel\"\n\t\t\t\t\t: role === \"judge\"\n\t\t\t\t\t\t? \"judgeModel\"\n\t\t\t\t\t\t: \"learningModel\";\n\thost.settingsManager.setModelRouterSettings({ ...router, [field]: modelRef });\n\tconst hint = router.enabled ? \"\" : \" Model router is currently disabled — enable it in /settings → Model Router.\";\n\thost.showStatus(`${modelRef} set as ${role.replace(\"router-\", \"router \")} model.${hint}`);\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { Container, TUI } from "@caupulican/pi-tui";
2
+ import { type ModelFitnessReport } from "../../core/research/model-fitness.ts";
3
+ export type ModelFitnessOutcome = {
4
+ started: true;
5
+ model: string;
6
+ report: ModelFitnessReport;
7
+ } | {
8
+ started: false;
9
+ skipReason: string;
10
+ };
11
+ type StartedModelFitnessOutcome = Extract<ModelFitnessOutcome, {
12
+ started: true;
13
+ }>;
14
+ export interface ModelFitnessPresentationHost {
15
+ readonly chatContainer: Pick<Container, "addChild">;
16
+ readonly ui: Pick<TUI, "requestRender">;
17
+ showStatus(message: string): void;
18
+ }
19
+ export declare function presentModelFitnessOutcome(host: ModelFitnessPresentationHost, outcome: ModelFitnessOutcome): outcome is StartedModelFitnessOutcome;
20
+ export {};
21
+ //# sourceMappingURL=model-fitness-presentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-fitness-presentation.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/model-fitness-presentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAA4B,KAAK,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAEzG,MAAM,MAAM,mBAAmB,GAC5B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,GAC5D;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,KAAK,0BAA0B,GAAG,OAAO,CAAC,mBAAmB,EAAE;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AAElF,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IACxC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,4BAA4B,EAClC,OAAO,EAAE,mBAAmB,GAC1B,OAAO,IAAI,0BAA0B,CASvC"}
@@ -0,0 +1,13 @@
1
+ import { Spacer, Text } from "@caupulican/pi-tui";
2
+ import { formatModelFitnessReport } from "../../core/research/model-fitness.js";
3
+ export function presentModelFitnessOutcome(host, outcome) {
4
+ if (!outcome.started) {
5
+ host.showStatus(`Model fitness skipped: ${outcome.skipReason}`);
6
+ return false;
7
+ }
8
+ host.chatContainer.addChild(new Spacer(1));
9
+ host.chatContainer.addChild(new Text(formatModelFitnessReport(outcome.model, outcome.report), 1, 0));
10
+ host.ui.requestRender();
11
+ return true;
12
+ }
13
+ //# sourceMappingURL=model-fitness-presentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-fitness-presentation.js","sourceRoot":"","sources":["../../../src/modes/interactive/model-fitness-presentation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAA2B,MAAM,sCAAsC,CAAC;AAczG,MAAM,UAAU,0BAA0B,CACzC,IAAkC,EAClC,OAA4B;IAE5B,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,CAAC,0BAA0B,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QAChE,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrG,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;IACxB,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import type { Container, TUI } from \"@caupulican/pi-tui\";\nimport { Spacer, Text } from \"@caupulican/pi-tui\";\nimport { formatModelFitnessReport, type ModelFitnessReport } from \"../../core/research/model-fitness.ts\";\n\nexport type ModelFitnessOutcome =\n\t| { started: true; model: string; report: ModelFitnessReport }\n\t| { started: false; skipReason: string };\n\ntype StartedModelFitnessOutcome = Extract<ModelFitnessOutcome, { started: true }>;\n\nexport interface ModelFitnessPresentationHost {\n\treadonly chatContainer: Pick<Container, \"addChild\">;\n\treadonly ui: Pick<TUI, \"requestRender\">;\n\tshowStatus(message: string): void;\n}\n\nexport function presentModelFitnessOutcome(\n\thost: ModelFitnessPresentationHost,\n\toutcome: ModelFitnessOutcome,\n): outcome is StartedModelFitnessOutcome {\n\tif (!outcome.started) {\n\t\thost.showStatus(`Model fitness skipped: ${outcome.skipReason}`);\n\t\treturn false;\n\t}\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(formatModelFitnessReport(outcome.model, outcome.report), 1, 0));\n\thost.ui.requestRender();\n\treturn true;\n}\n"]}
@@ -63,9 +63,11 @@ export declare class ProfileMenuController {
63
63
  private createProfileAndOpenLibraryFlow;
64
64
  private selectProfileAndOpenLibraryFlow;
65
65
  private getProfileResourceKinds;
66
+ private editProfileResource;
66
67
  private openLibraryEditorForProfile;
67
68
  private saveProfileResources;
68
69
  private rollbackValidatedProfileMutation;
70
+ private reportProfileMutationFailure;
69
71
  private promptScopeChangeForProfile;
70
72
  handleProfilesCommand(profileName?: string): Promise<void>;
71
73
  private applyProfile;
@@ -1 +1 @@
1
- {"version":3,"file":"profile-menu-controller.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/profile-menu-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAqBhE,eAAO,MAAM,6BAA6B,wFAC4C,CAAC;AA8BvF,MAAM,WAAW,uBAAuB;IACvC,YAAY,CACX,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK;QAC7B,SAAS,EAAE,SAAS,CAAC;QACrB,KAAK,EAAE,SAAS,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;KAC1B,GACC,IAAI,CAAC;IACR,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,C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BAA4B;YAoCtB,gBAAgB;YA+BhB,0BAA0B;YAgC1B,yBAAyB;YA6BzB,sBAAsB;YAiDtB,sBAAsB;YAkDtB,+BAA+B;YAuD/B,+BAA+B;YAsC/B,uBAAuB;YAkJvB,2BAA2B;YA4D3B,oBAAoB;YA2EpB,gCAAgC;YAsChC,2BAA2B;IAkCnC,qBAAqB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B/D;YAEa,YAAY;IA+G1B,mFAAmF;IACnF,OAAO,CAAC,qBAAqB;IAgBvB,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQpE;YAEa,iBAAiB;YAuDjB,kBAAkB;YA4ClB,oBAAoB;IAwDlC,OAAO,CAAC,oBAAoB;YAkBd,uBAAuB;YA0EvB,2BAA2B;YAmF3B,8BAA8B;CAiB5C","sourcesContent":["/**\n * Resource-profile & external-source menu controller.\n *\n * Extracted verbatim from interactive-mode.ts (god-file decomposition). Owns the /profiles command\n * and the resource-hub menu tree: active-profile selection, profile create/delete/persist, the\n * library (per-profile resource grants) editor, and external-source root management. It holds NO\n * state of its own — every profile/source fact lives in settingsManager / the profile registry /\n * the session resourceLoader — so it takes narrow deps (a live session accessor plus a UI callback\n * surface, including the editor-overlay-backed showSelector) rather than the whole InteractiveMode\n * instance.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { Api, Model } from \"@caupulican/pi-ai\";\nimport type { Component, SelectItem, TUI } from \"@caupulican/pi-tui\";\nimport { getAgentDir, getProfilesDir } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport { resolveCliModel } from \"../../core/model-resolver.ts\";\nimport type { NormalizedProfile } from \"../../core/profile-registry.ts\";\nimport { resourceProfileSettingsChangedKinds } from \"../../core/resource-profile-equality.ts\";\nimport type { SettingsReloadSnapshot } from \"../../core/settings-manager.ts\";\nimport { validateSkillName } from \"../../core/skills.ts\";\nimport { allToolNames } from \"../../core/tools/index.ts\";\nimport { parseFrontmatter } from \"../../utils/frontmatter.ts\";\nimport { ExtensionInputComponent } from \"./components/extension-input.ts\";\nimport {\n\tProfileResourceEditorComponent,\n\ttype ProfileResourceEditorKind,\n\tresolveResourceEditPath,\n} from \"./components/profile-resource-editor.ts\";\nimport { ProfileSelectorComponent } from \"./components/profile-selector.ts\";\nimport { SelectSubmenu } from \"./components/settings-selector.ts\";\nimport { captureProfileFiles, restoreProfileFiles } from \"./config-backup.ts\";\nimport { getAvailableThemesWithPaths } from \"./theme/theme.ts\";\n\ntype WritableProfileScope = \"session\" | \"directory\" | \"project\" | \"global\" | \"reusable-file\";\n\nexport const NO_ACTIVE_PROFILE_DESCRIPTION =\n\t\"Baseline resources; inline SDK extensions load, discovered extensions stay withheld\";\n\nfunction deletionScopeForProfile(profile: NormalizedProfile): WritableProfileScope | undefined {\n\tswitch (profile.source) {\n\t\tcase \"inline\":\n\t\t\treturn \"session\";\n\t\tcase \"directory-overlay\":\n\t\t\treturn \"directory\";\n\t\tcase \"project-settings\":\n\t\t\treturn \"project\";\n\t\tcase \"global-settings\":\n\t\t\treturn \"global\";\n\t\tcase \"profile-file\": {\n\t\t\tconst localProfilePath = path.resolve(getProfilesDir(), `${profile.name}.json`);\n\t\t\treturn profile.sourcePath && path.resolve(profile.sourcePath) === localProfilePath\n\t\t\t\t? \"reusable-file\"\n\t\t\t\t: undefined;\n\t\t}\n\t\tcase \"embedded\":\n\t\tcase \"external-settings\":\n\t\t\treturn undefined;\n\t}\n}\n\ninterface ProfileDefinitionRollbackTarget {\n\tprofileName: string;\n\tscope: WritableProfileScope;\n\tprofileFilesSnapshot?: ReturnType<typeof captureProfileFiles>;\n}\n\nexport interface ProfileMenuControllerUi {\n\tshowSelector(\n\t\tcreate: (done: () => void) => {\n\t\t\tcomponent: Component;\n\t\t\tfocus: Component;\n\t\t\tonSuperseded?: () => void;\n\t\t},\n\t): void;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowWarning(message: string): void;\n\trequestRender(): void;\n\treadonly tui: TUI;\n\treadonly footerDataProvider: { setExtensionStatus(key: string, text: string | undefined): void };\n\tinvalidateFooter(): void;\n\tupdateEditorBorderColor(): void;\n\topenEditorForPath(filePath: string): Promise<boolean>;\n\thandleReloadCommand(): Promise<boolean>;\n\tmaybeWarnAboutAnthropicSubscriptionAuth(model?: Model<Api>): void;\n\tcheckDaxnutsEasterEgg(model: { provider: string; id: string }): void;\n\tshowSettingsSelector(): void;\n\tgetAutoLearnModelOptions(): SelectItem[];\n}\n\nexport interface ProfileMenuControllerDeps {\n\tgetSession(): AgentSession;\n\tui: ProfileMenuControllerUi;\n}\n\nfunction portableBasename(filePath: string): string {\n\treturn filePath.split(/[\\\\/]/).filter(Boolean).pop() ?? filePath;\n}\n\nexport function getProfileExtensionDisplayLabel(filePath: string, description?: string): string {\n\tconst normalizedDescription = description?.trim();\n\tif (normalizedDescription) return normalizedDescription;\n\tconst fileName = portableBasename(filePath);\n\tif (!/^index\\.(?:ts|js)$/i.test(fileName)) return fileName;\n\tconst parentPath = filePath.slice(0, Math.max(0, filePath.length - fileName.length)).replace(/[\\\\/]$/, \"\");\n\treturn portableBasename(parentPath) || fileName;\n}\n\nexport class ProfileMenuController {\n\tprivate readonly deps: ProfileMenuControllerDeps;\n\n\tconstructor(deps: ProfileMenuControllerDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\tprivate get session(): AgentSession {\n\t\treturn this.deps.getSession();\n\t}\n\tprivate get sessionManager() {\n\t\treturn this.deps.getSession().sessionManager;\n\t}\n\tprivate get settingsManager() {\n\t\treturn this.deps.getSession().settingsManager;\n\t}\n\tprivate get ui(): ProfileMenuControllerUi {\n\t\treturn this.deps.ui;\n\t}\n\n\tasync handleResourcesHubAction(action: string): Promise<void> {\n\t\tswitch (action) {\n\t\t\tcase \"nudge-add-source\":\n\t\t\t\tvoid this.addExternalResourceRootFlow().then(() => {\n\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"active-profile\":\n\t\t\t\tvoid this.openActiveProfileSelector();\n\t\t\t\tbreak;\n\t\t\tcase \"manage-library\":\n\t\t\t\tvoid this.openLibraryManagerFlow();\n\t\t\t\tbreak;\n\t\t\tcase \"manage-profiles\":\n\t\t\t\tvoid this.openManageProfilesFlow();\n\t\t\t\tbreak;\n\t\t\tcase \"sources\":\n\t\t\t\tvoid this.openSourcesManagerFlow();\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tprivate async openActiveProfileSelector(): Promise<void> {\n\t\tconst registry = this.settingsManager.getProfileRegistry();\n\t\tconst profiles = registry.listProfiles();\n\t\tconst activeNames = this.settingsManager.getActiveResourceProfileNames();\n\n\t\tconst options = [\n\t\t\t{ value: \"(none)\", label: \"(none)\", description: NO_ACTIVE_PROFILE_DESCRIPTION },\n\t\t\t...profiles.map((p) => ({\n\t\t\t\tvalue: p.name,\n\t\t\t\tlabel: p.name,\n\t\t\t\tdescription: p.description || p.source,\n\t\t\t})),\n\t\t];\n\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst selector = new SelectSubmenu(\n\t\t\t\t\"Profile / Situation\",\n\t\t\t\t\"Select the active runtime profile/situation for this session. This is session-only unless saved elsewhere.\",\n\t\t\t\toptions,\n\t\t\t\tactiveNames[0] || \"(none)\",\n\t\t\t\t(value) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.applyProfile(value === \"(none)\" ? \"\" : value).then(() => {\n\t\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector.getSelectList() };\n\t\t});\n\t}\n\n\tprivate async openManageProfilesFlow(): Promise<void> {\n\t\tconst registry = this.settingsManager.getProfileRegistry();\n\t\tconst profiles = registry.listProfiles();\n\t\tconst editableProfiles = profiles.map((p) => ({\n\t\t\tvalue: p.name,\n\t\t\tlabel: p.name,\n\t\t\tdescription: p.description || p.source,\n\t\t}));\n\n\t\tconst options = [\n\t\t\t{\n\t\t\t\tvalue: \"create\",\n\t\t\t\tlabel: \"+ Create profile / situation...\",\n\t\t\t\tdescription: \"Create a new resource profile/situation definition.\",\n\t\t\t},\n\t\t];\n\n\t\tif (editableProfiles.length > 0) {\n\t\t\toptions.push({\n\t\t\t\tvalue: \"edit-model\",\n\t\t\t\tlabel: \"Edit profile model...\",\n\t\t\t\tdescription: \"Pin a model or inherit the session/default model.\",\n\t\t\t});\n\t\t}\n\n\t\tif (this.settingsManager.getActiveResourceProfileNames().length > 0) {\n\t\t\toptions.push({\n\t\t\t\tvalue: \"persist\",\n\t\t\t\tlabel: \"Persist active profile / situation to...\",\n\t\t\t\tdescription: \"Save the current active profile/situation selection so it survives restart.\",\n\t\t\t});\n\t\t}\n\n\t\tif (editableProfiles.length > 0) {\n\t\t\toptions.push({\n\t\t\t\tvalue: \"delete\",\n\t\t\t\tlabel: \"Delete profile / situation...\",\n\t\t\t\tdescription: \"Remove a profile/situation definition from where it is stored.\",\n\t\t\t});\n\t\t}\n\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst selector = new SelectSubmenu(\n\t\t\t\t\"Manage Profiles / Situations\",\n\t\t\t\t\"Create, edit, delete, or persist profile/situation definitions.\",\n\t\t\t\toptions,\n\t\t\t\t\"\",\n\t\t\t\t(value) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tif (value === \"create\") {\n\t\t\t\t\t\tvoid this.createProfileFlow().then(() => {\n\t\t\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (value === \"edit-model\") {\n\t\t\t\t\t\tthis.openEditProfileModelSelector();\n\t\t\t\t\t} else if (value === \"persist\") {\n\t\t\t\t\t\tvoid this.openPersistProfileSelector();\n\t\t\t\t\t} else if (value === \"delete\") {\n\t\t\t\t\t\tvoid this.openDeleteProfileSelector();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector.getSelectList() };\n\t\t});\n\t}\n\n\tprivate openEditProfileModelSelector(): void {\n\t\tconst profiles = this.settingsManager\n\t\t\t.getProfileRegistry()\n\t\t\t.listProfiles()\n\t\t\t.filter((profile) => deletionScopeForProfile(profile) !== undefined);\n\t\tif (profiles.length === 0) {\n\t\t\tthis.ui.showStatus(\"No writable profiles available. External and embedded profiles are read-only.\");\n\t\t\treturn;\n\t\t}\n\t\tconst activeNames = this.settingsManager.getActiveResourceProfileNames();\n\t\tconst initialValue = profiles.find((profile) => activeNames.includes(profile.name))?.name ?? profiles[0].name;\n\t\tconst items = profiles.map((profile) => ({\n\t\t\tvalue: profile.name,\n\t\t\tlabel: profile.name,\n\t\t\tdescription: `${profile.model ? `Pinned: ${profile.model}` : \"Inherits session/default model\"} · ${profile.description || profile.source}`,\n\t\t}));\n\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst selector = new SelectSubmenu(\n\t\t\t\t\"Edit Profile Model\",\n\t\t\t\t\"Choose a writable profile, then pin or inherit its foreground model.\",\n\t\t\t\titems,\n\t\t\t\tinitialValue,\n\t\t\t\t(profileName) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.editProfileModel(profileName);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.openManageProfilesFlow();\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector.getSelectList() };\n\t\t});\n\t}\n\n\tprivate async editProfileModel(profileName: string): Promise<void> {\n\t\tconst profile = this.settingsManager.getProfileRegistry().getProfile(profileName);\n\t\tif (!profile) {\n\t\t\tthis.ui.showError(`Profile \"${profileName}\" is no longer available.`);\n\t\t\treturn;\n\t\t}\n\t\tconst scope = deletionScopeForProfile(profile);\n\t\tif (!scope) {\n\t\t\tthis.ui.showError(`Profile \"${profileName}\" is read-only (${profile.source}).`);\n\t\t\treturn;\n\t\t}\n\t\tconst selectedModel = await this.selectProfileModel(profile.model);\n\t\tif (selectedModel === undefined) {\n\t\t\tvoid this.openManageProfilesFlow();\n\t\t\treturn;\n\t\t}\n\t\tconst model = selectedModel ?? undefined;\n\t\tif (model === profile.model) {\n\t\t\tthis.ui.showStatus(`Profile \"${profileName}\" model unchanged.`);\n\t\t\treturn;\n\t\t}\n\t\tawait this.saveProfileResources(\n\t\t\t{ ...profile, model },\n\t\t\tprofile.resources,\n\t\t\tprofile.resources,\n\t\t\tscope,\n\t\t\tthis.settingsManager.getActiveResourceProfileNames().includes(profile.name),\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tprivate async openPersistProfileSelector(): Promise<void> {\n\t\tconst scopeOptions = [\n\t\t\t{ value: \"session\", label: \"session\", description: \"Runtime only (not written to disk)\" },\n\t\t\t{\n\t\t\t\tvalue: \"directory\",\n\t\t\t\tlabel: \"directory\",\n\t\t\t\tdescription: \"~/.pi/agent/profiles/directories/<hash>/settings.json\",\n\t\t\t},\n\t\t\t{ value: \"project\", label: \"project\", description: \".pi/settings.json\" },\n\t\t\t{ value: \"global\", label: \"global\", description: \"~/.pi/agent/settings.json\" },\n\t\t];\n\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst selector = new SelectSubmenu(\n\t\t\t\t\"Persist Active Profile / Situation\",\n\t\t\t\t\"Choose where to write the active profile/situation selection.\",\n\t\t\t\tscopeOptions,\n\t\t\t\t\"directory\",\n\t\t\t\t(value) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tthis.persistActiveProfile(value as \"session\" | \"directory\" | \"project\" | \"global\");\n\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.openManageProfilesFlow();\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector.getSelectList() };\n\t\t});\n\t}\n\n\tprivate async openDeleteProfileSelector(): Promise<void> {\n\t\tconst registry = this.settingsManager.getProfileRegistry();\n\t\tconst editableProfiles = registry.listProfiles().map((p) => ({\n\t\t\tvalue: p.name,\n\t\t\tlabel: p.name,\n\t\t\tdescription: p.description || p.source,\n\t\t}));\n\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst selector = new SelectSubmenu(\n\t\t\t\t\"Delete Profile / Situation\",\n\t\t\t\t\"Pick a profile/situation to delete.\",\n\t\t\t\teditableProfiles,\n\t\t\t\t\"\",\n\t\t\t\t(value) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.deleteProfileFromSource(value).then(() => {\n\t\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.openManageProfilesFlow();\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector.getSelectList() };\n\t\t});\n\t}\n\n\tprivate async openSourcesManagerFlow(): Promise<void> {\n\t\tconst externalRoots = this.settingsManager.getExternalResourceRoots();\n\t\tconst trustedRoots = this.settingsManager.getTrustedResourceRoots();\n\n\t\tconst options = [\n\t\t\t{\n\t\t\t\tvalue: \"add\",\n\t\t\t\tlabel: \"+ Add external root...\",\n\t\t\t\tdescription: \"Register a new external directory root (requires trust)\",\n\t\t\t},\n\t\t];\n\n\t\tfor (const r of externalRoots) {\n\t\t\tconst isTrusted = trustedRoots.includes(r);\n\t\t\toptions.push({\n\t\t\t\tvalue: `remove:${r}`,\n\t\t\t\tlabel: `Remove: ${r}`,\n\t\t\t\tdescription: isTrusted ? \"Trusted external root\" : \"Untrusted external root\",\n\t\t\t});\n\t\t}\n\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst selector = new SelectSubmenu(\n\t\t\t\t\"Sources\",\n\t\t\t\t\"Manage external resource roots. Adding a root requires trust confirmation.\",\n\t\t\t\toptions,\n\t\t\t\t\"\",\n\t\t\t\t(value) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tif (value === \"add\") {\n\t\t\t\t\t\tvoid this.addExternalResourceRootFlow().then(() => {\n\t\t\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (value.startsWith(\"remove:\")) {\n\t\t\t\t\t\tconst root = value.slice(\"remove:\".length);\n\t\t\t\t\t\tvoid this.removeExternalResourceRootFlow(root).then(() => {\n\t\t\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector.getSelectList() };\n\t\t});\n\t}\n\n\tprivate async openLibraryManagerFlow(): Promise<void> {\n\t\tconst activeNames = this.settingsManager.getActiveResourceProfileNames();\n\t\tconst activeName = activeNames[0];\n\n\t\tif (!activeName || activeName === \"(none)\") {\n\t\t\tthis.ui.showSelector((done) => {\n\t\t\t\tconst selector = new SelectSubmenu(\n\t\t\t\t\t\"No Active Profile / Situation\",\n\t\t\t\t\t\"Select or create a profile/situation to manage the library.\",\n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: \"select\",\n\t\t\t\t\t\t\tlabel: \"Select existing profile / situation...\",\n\t\t\t\t\t\t\tdescription: \"Choose an existing profile/situation to activate.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: \"create\",\n\t\t\t\t\t\t\tlabel: \"Create new profile / situation...\",\n\t\t\t\t\t\t\tdescription: \"Create a new profile/situation definition.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\t\"select\",\n\t\t\t\t\t(value) => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tif (value === \"create\") {\n\t\t\t\t\t\t\tvoid this.createProfileAndOpenLibraryFlow();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvoid this.selectProfileAndOpenLibraryFlow();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tvoid this.ui.showSettingsSelector();\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn { component: selector, focus: selector.getSelectList() };\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst registry = this.settingsManager.getProfileRegistry();\n\t\tconst profile = registry.getProfile(activeName);\n\t\tif (!profile) {\n\t\t\tthis.ui.showError(`Active profile/situation \"${activeName}\" not found in registry.`);\n\t\t\treturn;\n\t\t}\n\t\tconst scope = this.scopeForProfileSource(profile.source);\n\t\tvoid this.openLibraryEditorForProfile(profile.name, scope);\n\t}\n\n\tprivate async createProfileAndOpenLibraryFlow(): Promise<void> {\n\t\tconst name = await new Promise<string | undefined>((resolve) => {\n\t\t\tthis.ui.showSelector((done) => {\n\t\t\t\tconst input = new ExtensionInputComponent(\n\t\t\t\t\t\"Create Profile / Situation\",\n\t\t\t\t\t\"Enter profile/situation name\",\n\t\t\t\t\t(value) => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tresolve(value);\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tresolve(undefined);\n\t\t\t\t\t},\n\t\t\t\t\t{ tui: this.ui.tui },\n\t\t\t\t);\n\t\t\t\treturn { component: input, focus: input, onSuperseded: () => resolve(undefined) };\n\t\t\t});\n\t\t});\n\n\t\tif (name === undefined) {\n\t\t\tvoid this.openLibraryManagerFlow();\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmed = name.trim();\n\t\tif (!trimmed) {\n\t\t\tthis.ui.showWarning(\"Profile/situation name cannot be empty.\");\n\t\t\tvoid this.openLibraryManagerFlow();\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst profileModel = await this.selectProfileModel();\n\t\t\tif (profileModel === undefined) {\n\t\t\t\tvoid this.openLibraryManagerFlow();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.settingsManager.setProfileDefinition(\n\t\t\t\ttrimmed,\n\t\t\t\t{\n\t\t\t\t\tname: trimmed,\n\t\t\t\t\tmodel: profileModel ?? undefined,\n\t\t\t\t\tresources: {},\n\t\t\t\t},\n\t\t\t\t\"reusable-file\",\n\t\t\t);\n\t\t\tawait this.applyProfile(trimmed);\n\t\t\tvoid this.openLibraryEditorForProfile(trimmed, \"reusable-file\");\n\t\t} catch (error) {\n\t\t\tthis.ui.showError(error instanceof Error ? error.message : String(error));\n\t\t\tvoid this.openLibraryManagerFlow();\n\t\t}\n\t}\n\n\tprivate async selectProfileAndOpenLibraryFlow(): Promise<void> {\n\t\tconst registry = this.settingsManager.getProfileRegistry();\n\t\tconst profiles = registry.listProfiles();\n\t\tconst editableProfiles = profiles.map((p) => ({\n\t\t\tvalue: p.name,\n\t\t\tlabel: p.name,\n\t\t\tdescription: p.description || p.source,\n\t\t}));\n\n\t\tif (editableProfiles.length === 0) {\n\t\t\tthis.ui.showWarning(\"No existing profiles/situations to select. Please create one.\");\n\t\t\tvoid this.createProfileAndOpenLibraryFlow();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst selector = new SelectSubmenu(\n\t\t\t\t\"Select Profile / Situation\",\n\t\t\t\t\"Pick a profile/situation to activate and edit.\",\n\t\t\t\teditableProfiles,\n\t\t\t\t\"\",\n\t\t\t\t(value) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.applyProfile(value).then(() => {\n\t\t\t\t\t\tconst profile = registry.getProfile(value)!;\n\t\t\t\t\t\tconst scope = this.scopeForProfileSource(profile.source);\n\t\t\t\t\t\tvoid this.openLibraryEditorForProfile(value, scope);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.openLibraryManagerFlow();\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector.getSelectList() };\n\t\t});\n\t}\n\n\tprivate async getProfileResourceKinds(): Promise<ProfileResourceEditorKind[]> {\n\t\tconst loader = this.session.resourceLoader;\n\t\tconst base = portableBasename;\n\t\tconst allDiscoverableExtensions = await loader.getDiscoverableExtensionPaths();\n\t\t// Defined BEFORE the skills/prompts arrays below that call it (const = TDZ: defining it\n\t\t// later crashes the whole app with a ReferenceError when the library editor opens).\n\t\tconst getFrontmatterDescription = (filePath: string): string | undefined => {\n\t\t\ttry {\n\t\t\t\tconst content = fs.readFileSync(filePath, \"utf-8\");\n\t\t\t\tconst { frontmatter } = parseFrontmatter<Record<string, unknown>>(content);\n\t\t\t\tif (typeof frontmatter.description === \"string\") return frontmatter.description;\n\t\t\t} catch {}\n\t\t\treturn undefined;\n\t\t};\n\t\t// The editor's universe must be profile-INDEPENDENT (discovery, not loading): the loaded\n\t\t// getters are narrowed by the active profile, so building the lists from them makes\n\t\t// currently-blocked skills/prompts/context files ungrantable — including expanding the\n\t\t// very profile you are running under. Union the loaded (rich metadata) sets with the\n\t\t// full pre-filter discovery paths.\n\t\tconst loadedSkills = loader.getSkills().skills;\n\t\tconst loadedSkillPaths = new Set(loadedSkills.map((skill) => skill.filePath));\n\t\tconst skillIdFromPath = (skillPath: string): string => {\n\t\t\tconst parts = skillPath.split(/[\\\\/]/);\n\t\t\tconst last = parts.pop() ?? skillPath;\n\t\t\tif (/^skill\\.md$/i.test(last)) return parts.pop() ?? last;\n\t\t\treturn last.replace(/\\.md$/i, \"\");\n\t\t};\n\t\tconst skills = [\n\t\t\t...loadedSkills.map((skill) => ({ id: skill.name, path: skill.filePath, description: skill.description })),\n\t\t\t...loader\n\t\t\t\t.getDiscoverableSkillPaths()\n\t\t\t\t.filter((skillPath) => !loadedSkillPaths.has(skillPath))\n\t\t\t\t.map((skillPath) => ({\n\t\t\t\t\tid: skillIdFromPath(skillPath),\n\t\t\t\t\tpath: skillPath,\n\t\t\t\t\tdescription: getFrontmatterDescription(skillPath),\n\t\t\t\t})),\n\t\t];\n\t\tconst loadedPrompts = loader.getPrompts().prompts;\n\t\tconst loadedPromptPaths = new Set(loadedPrompts.map((prompt) => prompt.filePath));\n\t\tconst prompts = [\n\t\t\t...loadedPrompts.map((prompt) => ({\n\t\t\t\tid: prompt.name,\n\t\t\t\tpath: prompt.filePath,\n\t\t\t\tdescription: prompt.description,\n\t\t\t})),\n\t\t\t...loader\n\t\t\t\t.getDiscoverablePromptPaths()\n\t\t\t\t.filter((promptPath) => !loadedPromptPaths.has(promptPath))\n\t\t\t\t.map((promptPath) => ({\n\t\t\t\t\tid: (promptPath.split(/[\\\\/]/).pop() ?? promptPath).replace(/\\.md$/i, \"\"),\n\t\t\t\t\tpath: promptPath,\n\t\t\t\t\tdescription: getFrontmatterDescription(promptPath),\n\t\t\t\t})),\n\t\t];\n\t\tconst themes = getAvailableThemesWithPaths();\n\t\tconst loadedAgentPaths = new Set(loader.getAgentsFiles().agentsFiles.map((file) => file.path));\n\t\tconst agents = [\n\t\t\t...loader.getAgentsFiles().agentsFiles.map((file) => ({ path: file.path })),\n\t\t\t...loader\n\t\t\t\t.getDiscoverableAgentsFilePaths()\n\t\t\t\t.filter((agentPath) => !loadedAgentPaths.has(agentPath))\n\t\t\t\t.map((agentPath) => ({ path: agentPath })),\n\t\t];\n\n\t\tconst getAgentDescription = (filePath: string): string | undefined => {\n\t\t\ttry {\n\t\t\t\tconst content = fs.readFileSync(filePath, \"utf-8\");\n\t\t\t\tconst { frontmatter } = parseFrontmatter<Record<string, unknown>>(content);\n\t\t\t\tif (typeof frontmatter.description === \"string\") {\n\t\t\t\t\treturn frontmatter.description;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t\treturn undefined;\n\t\t};\n\n\t\tconst getExtensionDescription = (filePath: string): string | undefined => {\n\t\t\ttry {\n\t\t\t\tlet dir = filePath;\n\t\t\t\tif (fs.existsSync(filePath) && !fs.statSync(filePath).isDirectory()) {\n\t\t\t\t\tdir = path.dirname(filePath);\n\t\t\t\t}\n\t\t\t\tconst pkgPath = path.join(dir, \"package.json\");\n\t\t\t\tif (fs.existsSync(pkgPath)) {\n\t\t\t\t\tconst pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n\t\t\t\t\tif (typeof pkg.description === \"string\") {\n\t\t\t\t\t\treturn pkg.description;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t\treturn undefined;\n\t\t};\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: \"tools\",\n\t\t\t\tlabel: \"Tools\",\n\t\t\t\t// Built-ins plus every currently registered tool (extension tools included), so\n\t\t\t\t// an extension tool can be granted by name without hand-editing settings JSON.\n\t\t\t\titems: [...new Set([...allToolNames, ...this.session.getAllTools().map((tool) => tool.name)])].map(\n\t\t\t\t\t(name: string) => ({ id: name }),\n\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tkind: \"skills\",\n\t\t\t\tlabel: \"Skills\",\n\t\t\t\titems: skills,\n\t\t\t},\n\t\t\t{\n\t\t\t\tkind: \"extensions\",\n\t\t\t\tlabel: \"Extensions\",\n\t\t\t\titems: allDiscoverableExtensions.map((extensionPath) => {\n\t\t\t\t\tconst description = getExtensionDescription(extensionPath);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: path.resolve(extensionPath),\n\t\t\t\t\t\tlabel: getProfileExtensionDisplayLabel(extensionPath, description),\n\t\t\t\t\t\tpath: extensionPath,\n\t\t\t\t\t\tdescription,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t},\n\t\t\t{\n\t\t\t\tkind: \"agents\",\n\t\t\t\tlabel: \"Agents\",\n\t\t\t\titems: agents.map((f) => ({\n\t\t\t\t\tid: base(f.path),\n\t\t\t\t\tpath: f.path,\n\t\t\t\t\tdescription: getAgentDescription(f.path),\n\t\t\t\t})),\n\t\t\t},\n\t\t\t{\n\t\t\t\tkind: \"prompts\",\n\t\t\t\tlabel: \"Prompts\",\n\t\t\t\titems: prompts,\n\t\t\t},\n\t\t\t{\n\t\t\t\tkind: \"themes\",\n\t\t\t\tlabel: \"Themes\",\n\t\t\t\titems: themes.map((t) => ({\n\t\t\t\t\tid: t.name,\n\t\t\t\t\tpath: t.path,\n\t\t\t\t})),\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate async openLibraryEditorForProfile(\n\t\tprofileName: string,\n\t\tinitialScope: \"session\" | \"directory\" | \"project\" | \"global\" | \"reusable-file\",\n\t): Promise<void> {\n\t\tconst currentScope = initialScope;\n\t\tconst registry = this.settingsManager.getProfileRegistry();\n\t\tconst profile = registry.getProfile(profileName);\n\t\tif (!profile) {\n\t\t\tthis.ui.showError(`Profile not found: ${profileName}`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst kinds = await this.getProfileResourceKinds();\n\t\tconst originalResources = profile.resources;\n\t\tconst isActiveProfile = this.settingsManager.getActiveResourceProfileNames().includes(profile.name);\n\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst editor = new ProfileResourceEditorComponent({\n\t\t\t\tprofileName: profile!.name,\n\t\t\t\tprofileScope: currentScope,\n\t\t\t\tinitialResources: profile!.resources,\n\t\t\t\tkinds,\n\t\t\t\tcwd: this.sessionManager.getCwd(),\n\t\t\t\tagentDir: getAgentDir(),\n\t\t\t\texternalResourceRoots: this.settingsManager.getExternalResourceRoots(),\n\t\t\t\tonSave: (resources) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.saveProfileResources(profile, originalResources, resources, currentScope, isActiveProfile);\n\t\t\t\t},\n\t\t\t\tonCancel: () => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.openLibraryManagerFlow();\n\t\t\t\t},\n\t\t\t\tonScopeChange: () => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.promptScopeChangeForProfile(profileName, currentScope);\n\t\t\t\t},\n\t\t\t\tonEdit: async (id, pathValue, kind) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tconst resolvedEditPath = resolveResourceEditPath(id, pathValue, kind);\n\t\t\t\t\tif (!resolvedEditPath) {\n\t\t\t\t\t\tthis.ui.showWarning(`Resource \"${id}\" of kind \"${kind}\" has no editable file path.`);\n\t\t\t\t\t\tvoid this.openLibraryEditorForProfile(profileName, currentScope);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (!fs.existsSync(resolvedEditPath)) {\n\t\t\t\t\t\tthis.ui.showError(`Resolved path for \"${id}\" does not exist: ${resolvedEditPath}`);\n\t\t\t\t\t\tvoid this.openLibraryEditorForProfile(profileName, currentScope);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tawait this.ui.openEditorForPath(resolvedEditPath);\n\t\t\t\t\tawait this.ui.handleReloadCommand();\n\t\t\t\t\tvoid this.openLibraryEditorForProfile(profileName, currentScope);\n\t\t\t\t},\n\t\t\t});\n\n\t\t\treturn { component: editor, focus: editor };\n\t\t});\n\t}\n\n\tprivate async saveProfileResources(\n\t\tprofile: NormalizedProfile,\n\t\toriginalResources: NormalizedProfile[\"resources\"],\n\t\tresources: NormalizedProfile[\"resources\"],\n\t\tscope: WritableProfileScope,\n\t\tisActiveProfile: boolean,\n\t\truntimeMetadataChanged = false,\n\t): Promise<void> {\n\t\tconst definition = {\n\t\t\tname: profile.name,\n\t\t\tdescription: profile.description,\n\t\t\tmodel: profile.model,\n\t\t\tthinking: profile.thinking,\n\t\t\tmodelRouter: profile.modelRouter,\n\t\t\tsoul: profile.soul,\n\t\t\tresources,\n\t\t};\n\t\tconst changedKinds = resourceProfileSettingsChangedKinds(originalResources, resources);\n\t\tif (!isActiveProfile || (changedKinds.size === 0 && !runtimeMetadataChanged)) {\n\t\t\ttry {\n\t\t\t\tthis.settingsManager.setProfileDefinition(profile.name, definition, scope);\n\t\t\t\tthis.ui.showStatus(`Saved profile \"${profile.name}\" to ${scope}.`);\n\t\t\t\tthis.ui.requestRender();\n\t\t\t} catch (error) {\n\t\t\t\tthis.ui.showError(error instanceof Error ? error.message : String(error));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst settingsSnapshot = this.settingsManager.createReloadSnapshot();\n\t\tconst profilesDir = getProfilesDir();\n\t\tconst profileFilesSnapshot = scope === \"reusable-file\" ? captureProfileFiles(profilesDir) : undefined;\n\t\tlet stagedRuntimeApplied = false;\n\t\ttry {\n\t\t\t// Validate the edited authority surface as a session overlay first. Persistent scopes are\n\t\t\t// written only after the complete runtime generation passes its reload doctor.\n\t\t\tthis.settingsManager.setProfileDefinition(profile.name, definition, \"session\");\n\t\t\tif (!(await this.ui.handleReloadCommand())) {\n\t\t\t\tthis.settingsManager.restoreReloadSnapshot(settingsSnapshot);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstagedRuntimeApplied = true;\n\n\t\t\tif (scope !== \"session\") {\n\t\t\t\tthis.settingsManager.setProfileDefinition(profile.name, definition, scope);\n\t\t\t\tawait this.settingsManager.flush();\n\t\t\t\t// Drop the validation-only inline winner, then refresh the registry from the now-validated\n\t\t\t\t// persistent definition. The live runtime already represents the same profile definition.\n\t\t\t\tthis.settingsManager.restoreReloadSnapshot(settingsSnapshot);\n\t\t\t\tawait this.settingsManager.reload();\n\t\t\t}\n\n\t\t\tconst active = this.settingsManager.getActiveResourceProfileNames()[0] ?? \"(none)\";\n\t\t\tthis.ui.footerDataProvider.setExtensionStatus(\"profile\", active);\n\t\t\tthis.ui.invalidateFooter();\n\t\t\tthis.ui.updateEditorBorderColor();\n\t\t\tthis.ui.showStatus(`Saved profile \"${profile.name}\" to ${scope}.`);\n\t\t} catch (error) {\n\t\t\tconst rollbackError = stagedRuntimeApplied\n\t\t\t\t? await this.rollbackValidatedProfileMutation(settingsSnapshot, {\n\t\t\t\t\t\tprofileName: profile.name,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tprofileFilesSnapshot,\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t\t\tif (!stagedRuntimeApplied) this.settingsManager.restoreReloadSnapshot(settingsSnapshot);\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tthis.ui.showError(\n\t\t\t\trollbackError\n\t\t\t\t\t? `${message}; rollback failed: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`\n\t\t\t\t\t: message,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate async rollbackValidatedProfileMutation(\n\t\tsettingsSnapshot: SettingsReloadSnapshot,\n\t\tdefinition?: ProfileDefinitionRollbackTarget,\n\t): Promise<unknown> {\n\t\tconst errors: string[] = [];\n\t\ttry {\n\t\t\tif (definition?.scope === \"reusable-file\") {\n\t\t\t\trestoreProfileFiles(getProfilesDir(), definition.profileFilesSnapshot!);\n\t\t\t} else if (definition && definition.scope !== \"session\") {\n\t\t\t\tthis.settingsManager.restoreProfileDefinitionFromReloadSnapshot(\n\t\t\t\t\tdefinition.profileName,\n\t\t\t\t\tdefinition.scope,\n\t\t\t\t\tsettingsSnapshot,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst global = settingsSnapshot.globalSettings;\n\t\t\tthis.settingsManager.replaceGlobalResourceProfileConfiguration({\n\t\t\t\tresourceProfiles: global.resourceProfiles,\n\t\t\t\tactiveResourceProfile: global.activeResourceProfile,\n\t\t\t\tactiveResourceProfiles: global.activeResourceProfiles,\n\t\t\t\texternalResourceRoots: global.externalResourceRoots,\n\t\t\t\ttrustedResourceRoots: global.trustedResourceRoots,\n\t\t\t});\n\t\t\tawait this.settingsManager.flush();\n\t\t} catch (error) {\n\t\t\terrors.push(`persistence: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t\tthis.settingsManager.restoreReloadSnapshot(settingsSnapshot);\n\t\ttry {\n\t\t\tif (!(await this.ui.handleReloadCommand())) {\n\t\t\t\terrors.push(\"runtime: the previous profile runtime could not be restored\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\terrors.push(`runtime: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t\treturn errors.length > 0 ? new Error(errors.join(\"; \")) : undefined;\n\t}\n\n\tprivate async promptScopeChangeForProfile(\n\t\tprofileName: string,\n\t\tcurrentScope: \"session\" | \"directory\" | \"project\" | \"global\" | \"reusable-file\",\n\t): Promise<void> {\n\t\tconst scopeOptions = [\n\t\t\t{ value: \"session\", label: \"session\", description: \"Runtime only (not written to disk)\" },\n\t\t\t{\n\t\t\t\tvalue: \"directory\",\n\t\t\t\tlabel: \"directory\",\n\t\t\t\tdescription: \"~/.pi/agent/profiles/directories/<hash>/settings.json\",\n\t\t\t},\n\t\t\t{ value: \"project\", label: \"project\", description: \".pi/settings.json\" },\n\t\t\t{ value: \"global\", label: \"global\", description: \"~/.pi/agent/settings.json\" },\n\t\t];\n\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst selector = new SelectSubmenu(\n\t\t\t\t\"Change Profile / Situation Scope\",\n\t\t\t\t`Select new scope for profile/situation \"${profileName}\".`,\n\t\t\t\tscopeOptions,\n\t\t\t\tcurrentScope,\n\t\t\t\t(value) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.openLibraryEditorForProfile(profileName, value as any);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.openLibraryEditorForProfile(profileName, currentScope);\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector.getSelectList() };\n\t\t});\n\t}\n\n\tasync handleProfilesCommand(profileName?: string): Promise<void> {\n\t\tif (profileName) {\n\t\t\tawait this.applyProfile(profileName);\n\t\t\treturn;\n\t\t}\n\n\t\tconst registry = this.settingsManager.getProfileRegistry();\n\t\tconst profiles = registry.listProfiles();\n\t\tif (profiles.length === 0) {\n\t\t\tthis.ui.showWarning(\n\t\t\t\t\"No profiles found. Add resourceProfiles to settings or JSON files under ~/.pi/agent/profiles/.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst selector = new ProfileSelectorComponent(\n\t\t\t\tprofiles,\n\t\t\t\tthis.settingsManager.getActiveResourceProfileNames(),\n\t\t\t\t(profile) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tvoid this.applyProfile(profile);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tdone();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { component: selector, focus: selector.getSelectList() };\n\t\t});\n\t}\n\n\tprivate async applyProfile(profileName: string): Promise<void> {\n\t\tconst normalizedName = profileName.trim();\n\t\tconst normalizedLower = normalizedName.toLowerCase();\n\t\tif (normalizedName.length === 0 || normalizedLower === \"none\" || normalizedLower === \"(none)\") {\n\t\t\tconst settingsSnapshot = this.settingsManager.createReloadSnapshot();\n\t\t\tlet stagedRuntimeApplied = false;\n\t\t\ttry {\n\t\t\t\tthis.settingsManager.setRuntimeResourceProfiles([]);\n\t\t\t\tif (!(await this.ui.handleReloadCommand())) {\n\t\t\t\t\tthis.settingsManager.restoreReloadSnapshot(settingsSnapshot);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tstagedRuntimeApplied = true;\n\t\t\t\t// Persist only after the new runtime generation passes its reload doctor.\n\t\t\t\tthis.settingsManager.setActiveProfile(undefined, \"global\");\n\t\t\t\tawait this.settingsManager.flush();\n\t\t\t\tthis.session.sessionManager.appendCustomEntry(\"pi.activeResourceProfiles\", {\n\t\t\t\t\tprofiles: [],\n\t\t\t\t});\n\t\t\t\tconst activeProfileName = this.settingsManager.getActiveResourceProfileNames()[0] ?? \"(none)\";\n\t\t\t\tthis.ui.footerDataProvider.setExtensionStatus(\"profile\", activeProfileName);\n\t\t\t\tthis.ui.invalidateFooter();\n\t\t\t\tthis.ui.updateEditorBorderColor();\n\t\t\t\tthis.ui.showStatus(`Profile: ${activeProfileName}`);\n\t\t\t} catch (error) {\n\t\t\t\tconst rollbackError = stagedRuntimeApplied\n\t\t\t\t\t? await this.rollbackValidatedProfileMutation(settingsSnapshot)\n\t\t\t\t\t: undefined;\n\t\t\t\tif (!stagedRuntimeApplied) this.settingsManager.restoreReloadSnapshot(settingsSnapshot);\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthis.ui.showError(\n\t\t\t\t\trollbackError\n\t\t\t\t\t\t? `${message}; rollback failed: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`\n\t\t\t\t\t\t: message,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst registry = this.settingsManager.getProfileRegistry();\n\t\tconst profile =\n\t\t\tnormalizedName.startsWith(\"./\") || normalizedName.startsWith(\"../\")\n\t\t\t\t? registry.resolveProfileRef(normalizedName, this.sessionManager.getCwd())\n\t\t\t\t: registry.getProfile(normalizedName);\n\t\tif (!profile) {\n\t\t\tthis.ui.showError(`Profile not found: ${profileName}`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst settingsSnapshot = this.settingsManager.createReloadSnapshot();\n\t\tconst modelRegistrySnapshot = profile.model ? this.session.modelRegistry.createReloadSnapshot() : undefined;\n\t\tlet stagedRuntimeApplied = false;\n\t\ttry {\n\t\t\tconst activeProfileRef =\n\t\t\t\tnormalizedName.startsWith(\"./\") || normalizedName.startsWith(\"../\") ? normalizedName : profile.name;\n\t\t\tlet requestedModel: Model<Api> | undefined;\n\t\t\tif (profile.model) {\n\t\t\t\tthis.session.modelRegistry.refresh();\n\t\t\t\tconst resolved = resolveCliModel({ cliModel: profile.model, modelRegistry: this.session.modelRegistry });\n\t\t\t\t// The profile may grant an extension that contributes this model. The current generation\n\t\t\t\t// cannot validate that case; the atomic reload binds new providers before authoritative\n\t\t\t\t// profile resolution and rolls back if the model is still unresolved.\n\t\t\t\tif (!resolved.error && resolved.warning) {\n\t\t\t\t\tthis.ui.showWarning(resolved.warning);\n\t\t\t\t}\n\t\t\t\tif (!resolved.error) requestedModel = resolved.model;\n\t\t\t}\n\n\t\t\t// Stage the complete situation in memory. Runtime reload applies model/thinking, resource\n\t\t\t// grants, extensions, skills, prompts, and soul together; explicit launch overrides still win.\n\t\t\tthis.settingsManager.setRuntimeResourceProfiles([activeProfileRef]);\n\t\t\tif (!(await this.ui.handleReloadCommand())) {\n\t\t\t\tthis.settingsManager.restoreReloadSnapshot(settingsSnapshot);\n\t\t\t\tif (modelRegistrySnapshot) this.session.modelRegistry.restoreReloadSnapshot(modelRegistrySnapshot);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstagedRuntimeApplied = true;\n\n\t\t\t// Selection survives restarts only after the new runtime generation passes its reload doctor.\n\t\t\tthis.settingsManager.setActiveProfile(activeProfileRef, \"global\");\n\t\t\tawait this.settingsManager.flush();\n\t\t\tthis.session.sessionManager.appendCustomEntry(\"pi.activeResourceProfiles\", {\n\t\t\t\tprofiles: [activeProfileRef],\n\t\t\t});\n\t\t\tthis.ui.footerDataProvider.setExtensionStatus(\"profile\", profile.name);\n\t\t\tthis.ui.invalidateFooter();\n\t\t\tthis.ui.updateEditorBorderColor();\n\t\t\tthis.ui.showStatus(`Profile: ${profile.name}`);\n\t\t\tif (\n\t\t\t\trequestedModel &&\n\t\t\t\tthis.session.model?.provider === requestedModel.provider &&\n\t\t\t\tthis.session.model.id === requestedModel.id\n\t\t\t) {\n\t\t\t\tvoid this.ui.maybeWarnAboutAnthropicSubscriptionAuth(requestedModel);\n\t\t\t\tthis.ui.checkDaxnutsEasterEgg(requestedModel);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst rollbackError = stagedRuntimeApplied\n\t\t\t\t? await this.rollbackValidatedProfileMutation(settingsSnapshot)\n\t\t\t\t: undefined;\n\t\t\tif (!stagedRuntimeApplied) this.settingsManager.restoreReloadSnapshot(settingsSnapshot);\n\t\t\tif (modelRegistrySnapshot) this.session.modelRegistry.restoreReloadSnapshot(modelRegistrySnapshot);\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tthis.ui.showError(\n\t\t\t\trollbackError\n\t\t\t\t\t? `${message}; rollback failed: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`\n\t\t\t\t\t: message,\n\t\t\t);\n\t\t}\n\t}\n\n\t/** Map where a profile currently lives to the scope we should write it back to. */\n\tprivate scopeForProfileSource(source: string): WritableProfileScope {\n\t\tswitch (source) {\n\t\t\tcase \"profile-file\":\n\t\t\t\treturn \"reusable-file\";\n\t\t\tcase \"directory-overlay\":\n\t\t\tcase \"embedded\":\n\t\t\t\treturn \"directory\";\n\t\t\tcase \"project-settings\":\n\t\t\t\treturn \"project\";\n\t\t\tcase \"inline\":\n\t\t\t\treturn \"session\";\n\t\t\tdefault:\n\t\t\t\treturn \"global\";\n\t\t}\n\t}\n\n\tasync refreshAfterProfileMutation(profileName: string): Promise<void> {\n\t\tif (this.settingsManager.getActiveResourceProfileNames().includes(profileName)) {\n\t\t\tif (!(await this.ui.handleReloadCommand())) return;\n\t\t\tconst active = this.settingsManager.getActiveResourceProfileNames()[0] ?? \"(none)\";\n\t\t\tthis.ui.footerDataProvider.setExtensionStatus(\"profile\", active);\n\t\t\tthis.ui.invalidateFooter();\n\t\t\tthis.ui.updateEditorBorderColor();\n\t\t}\n\t}\n\n\tprivate async createProfileFlow(): Promise<void> {\n\t\tconst name = await new Promise<string | undefined>((resolve) => {\n\t\t\tthis.ui.showSelector((done) => {\n\t\t\t\tconst input = new ExtensionInputComponent(\n\t\t\t\t\t\"Create Profile / Situation\",\n\t\t\t\t\t\"Enter profile/situation name\",\n\t\t\t\t\t(value) => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tresolve(value);\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tresolve(undefined);\n\t\t\t\t\t},\n\t\t\t\t\t{ tui: this.ui.tui },\n\t\t\t\t);\n\t\t\t\treturn { component: input, focus: input, onSuperseded: () => resolve(undefined) };\n\t\t\t});\n\t\t});\n\n\t\tif (name === undefined) {\n\t\t\tthis.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmed = name.trim();\n\t\tif (!trimmed) {\n\t\t\tthis.ui.showError(\"Profile/situation name cannot be empty\");\n\t\t\treturn this.createProfileFlow();\n\t\t}\n\n\t\t// Validate name rules using validateSkillName\n\t\tconst errors = validateSkillName(trimmed);\n\t\tif (errors.length > 0) {\n\t\t\tthis.ui.showError(`Invalid profile/situation name: ${errors.join(\", \")}`);\n\t\t\treturn this.createProfileFlow();\n\t\t}\n\n\t\t// Collision check\n\t\tconst existing = this.settingsManager.getProfileRegistry().getProfile(trimmed);\n\t\tif (existing) {\n\t\t\tthis.ui.showError(`Profile/situation \"${trimmed}\" already exists`);\n\t\t\treturn this.createProfileFlow();\n\t\t}\n\n\t\tconst profileModel = await this.selectProfileModel();\n\t\tif (profileModel === undefined) {\n\t\t\tthis.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\t// Open the resource editor on the NEW profile\n\t\tvoid this.openNewProfileEditor(trimmed, profileModel ?? undefined);\n\t}\n\n\tprivate async selectProfileModel(profileModel?: string): Promise<string | null | undefined> {\n\t\tconst inheritValue = \"(inherit)\";\n\t\tconst availableModelOptions = [...this.ui.getAutoLearnModelOptions()];\n\t\tif (profileModel && !availableModelOptions.some((option) => option.value === profileModel)) {\n\t\t\tavailableModelOptions.unshift({\n\t\t\t\tvalue: profileModel,\n\t\t\t\tlabel: profileModel,\n\t\t\t\tdescription: \"Current profile model (not currently available)\",\n\t\t\t});\n\t\t}\n\t\tconst modelOptions = [\n\t\t\t{\n\t\t\t\tvalue: inheritValue,\n\t\t\t\tlabel: \"Inherit session/default model\",\n\t\t\t\tdescription: \"Remove the profile model pin and use the current session/default model\",\n\t\t\t},\n\t\t\t...availableModelOptions,\n\t\t];\n\n\t\treturn await new Promise<string | null | undefined>((resolve) => {\n\t\t\tthis.ui.showSelector((done) => {\n\t\t\t\tconst selector = new SelectSubmenu(\n\t\t\t\t\t\"Profile Model\",\n\t\t\t\t\t\"Pin a foreground model for this profile or inherit the session/default model.\",\n\t\t\t\t\tmodelOptions,\n\t\t\t\t\tprofileModel ?? inheritValue,\n\t\t\t\t\t(value) => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tresolve(value === inheritValue ? null : value);\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tresolve(undefined);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tcomponent: selector,\n\t\t\t\t\tfocus: selector.getSelectList(),\n\t\t\t\t\tonSuperseded: () => resolve(undefined),\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate async openNewProfileEditor(profileName: string, profileModel?: string): Promise<void> {\n\t\tconst scope = \"reusable-file\";\n\t\tconst kinds = await this.getProfileResourceKinds();\n\t\tthis.ui.showSelector((done) => {\n\t\t\tconst editor = new ProfileResourceEditorComponent({\n\t\t\t\tprofileName,\n\t\t\t\tprofileScope: scope,\n\t\t\t\tinitialResources: {},\n\t\t\t\tkinds,\n\t\t\t\tcwd: this.sessionManager.getCwd(),\n\t\t\t\tagentDir: getAgentDir(),\n\t\t\t\texternalResourceRoots: this.settingsManager.getExternalResourceRoots(),\n\t\t\t\tonSave: (resources) => {\n\t\t\t\t\tdone();\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthis.settingsManager.setProfileDefinition(\n\t\t\t\t\t\t\tprofileName,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: profileName,\n\t\t\t\t\t\t\t\tmodel: profileModel,\n\t\t\t\t\t\t\t\tresources,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.ui.showStatus(`Saved profile \"${profileName}\" to ${scope}.`);\n\t\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.ui.showError(error instanceof Error ? error.message : String(error));\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tonCancel: () => {\n\t\t\t\t\tdone();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t},\n\t\t\t\tonEdit: async (id, pathValue, kind) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tconst resolvedEditPath = resolveResourceEditPath(id, pathValue, kind);\n\t\t\t\t\tif (!resolvedEditPath) {\n\t\t\t\t\t\tthis.ui.showWarning(`Resource \"${id}\" of kind \"${kind}\" has no editable file path.`);\n\t\t\t\t\t\tvoid this.openNewProfileEditor(profileName, profileModel);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (!fs.existsSync(resolvedEditPath)) {\n\t\t\t\t\t\tthis.ui.showError(`Resolved path for \"${id}\" does not exist: ${resolvedEditPath}`);\n\t\t\t\t\t\tvoid this.openNewProfileEditor(profileName, profileModel);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tawait this.ui.openEditorForPath(resolvedEditPath);\n\t\t\t\t\tawait this.ui.handleReloadCommand();\n\t\t\t\t\tvoid this.openNewProfileEditor(profileName, profileModel);\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn { component: editor, focus: editor };\n\t\t});\n\t}\n\n\tprivate persistActiveProfile(scope: \"session\" | \"directory\" | \"project\" | \"global\"): void {\n\t\tconst active = this.settingsManager.getActiveResourceProfileNames()[0];\n\t\tif (!active) {\n\t\t\tthis.ui.showError(\"No active profile to persist. Select one with /profiles first.\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tif (scope === \"session\") {\n\t\t\t\tthis.settingsManager.setRuntimeResourceProfiles([active]);\n\t\t\t} else {\n\t\t\t\tthis.settingsManager.setActiveProfile(active, scope);\n\t\t\t}\n\t\t\tthis.ui.showStatus(`Active profile \"${active}\" persisted to ${scope}.`);\n\t\t} catch (error) {\n\t\t\tthis.ui.showError(error instanceof Error ? error.message : String(error));\n\t\t}\n\t}\n\n\tprivate async deleteProfileFromSource(profileName: string): Promise<void> {\n\t\tconst registry = this.settingsManager.getProfileRegistry();\n\t\tconst profile = registry.getProfile(profileName);\n\t\tif (!profile) {\n\t\t\tthis.ui.showError(`Profile not found: ${profileName}`);\n\t\t\treturn;\n\t\t}\n\t\tconst scope = deletionScopeForProfile(profile);\n\t\tif (!scope) {\n\t\t\tconst location = profile.sourcePath ? ` at ${profile.sourcePath}` : \"\";\n\t\t\tthis.ui.showError(\n\t\t\t\t`Profile \"${profileName}\" comes from read-only source ${profile.source}${location}; edit or remove that source definition directly.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst wasActive = this.settingsManager.getActiveResourceProfileNames().some((profileRef) => {\n\t\t\tif (profileRef === profileName || profileRef === profile.name) return true;\n\t\t\tconst activeProfile =\n\t\t\t\tprofileRef.startsWith(\"./\") || profileRef.startsWith(\"../\")\n\t\t\t\t\t? registry.resolveProfileRef(profileRef, this.sessionManager.getCwd())\n\t\t\t\t\t: registry.getProfile(profileRef);\n\t\t\treturn Boolean(\n\t\t\t\tactiveProfile && activeProfile.name === profile.name && activeProfile.sourcePath === profile.sourcePath,\n\t\t\t);\n\t\t});\n\t\tconst settingsSnapshot = this.settingsManager.createReloadSnapshot();\n\t\tconst profileFilesSnapshot = scope === \"reusable-file\" ? captureProfileFiles(getProfilesDir()) : undefined;\n\t\tlet switchedToNone = false;\n\t\ttry {\n\t\t\tif (wasActive) {\n\t\t\t\t// Stage an explicit empty runtime selection while the definition is still intact. The\n\t\t\t\t// full reload can now remove the profile's extensions, tools, providers, model, and\n\t\t\t\t// memory generation atomically. Persisting the deletion is deliberately deferred until\n\t\t\t\t// that generation passes its doctor, so a failed reload has no on-disk deletion to undo.\n\t\t\t\tthis.settingsManager.setRuntimeResourceProfiles([]);\n\t\t\t\tif (!(await this.ui.handleReloadCommand())) {\n\t\t\t\t\tthis.settingsManager.restoreReloadSnapshot(settingsSnapshot);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tswitchedToNone = true;\n\t\t\t}\n\n\t\t\tthis.settingsManager.deleteProfile(profileName, scope);\n\t\t\tconst remaining = this.settingsManager.getProfileRegistry().getProfile(profileName);\n\t\t\tif (remaining && remaining.source === profile.source && remaining.sourcePath === profile.sourcePath) {\n\t\t\t\tthrow new Error(`Profile \"${profileName}\" was not removed from ${profile.source}.`);\n\t\t\t}\n\t\t\tif (wasActive) {\n\t\t\t\tthis.settingsManager.setActiveProfile(undefined, \"global\");\n\t\t\t\tawait this.settingsManager.flush();\n\t\t\t\tthis.session.sessionManager.appendCustomEntry(\"pi.activeResourceProfiles\", { profiles: [] });\n\t\t\t\tthis.ui.footerDataProvider.setExtensionStatus(\"profile\", \"(none)\");\n\t\t\t\tthis.ui.invalidateFooter();\n\t\t\t\tthis.ui.updateEditorBorderColor();\n\t\t\t}\n\t\t\tthis.ui.showStatus(`Deleted profile \"${profileName}\" from ${scope}.`);\n\t\t} catch (error) {\n\t\t\tconst rollbackError = switchedToNone\n\t\t\t\t? await this.rollbackValidatedProfileMutation(settingsSnapshot, {\n\t\t\t\t\t\tprofileName,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tprofileFilesSnapshot,\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t\t\tif (!switchedToNone) this.settingsManager.restoreReloadSnapshot(settingsSnapshot);\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tthis.ui.showError(\n\t\t\t\trollbackError\n\t\t\t\t\t? `${message}; rollback failed: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`\n\t\t\t\t\t: message,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate async addExternalResourceRootFlow(): Promise<void> {\n\t\tconst rootPath = await new Promise<string | undefined>((resolve) => {\n\t\t\tthis.ui.showSelector((done) => {\n\t\t\t\tconst input = new ExtensionInputComponent(\n\t\t\t\t\t\"Add External Root\",\n\t\t\t\t\t\"Enter external root directory path\",\n\t\t\t\t\t(value) => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tresolve(value);\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tresolve(undefined);\n\t\t\t\t\t},\n\t\t\t\t\t{ tui: this.ui.tui },\n\t\t\t\t);\n\t\t\t\treturn { component: input, focus: input, onSuperseded: () => resolve(undefined) };\n\t\t\t});\n\t\t});\n\n\t\tif (rootPath === undefined) {\n\t\t\tthis.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmed = rootPath.trim();\n\t\tif (!trimmed) {\n\t\t\tthis.ui.showError(\"Directory path cannot be empty\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst canonical = this.settingsManager.canonicalizePath(trimmed);\n\t\tif (!canonical) {\n\t\t\tthis.ui.showError(`Invalid path: ${trimmed}`);\n\t\t\treturn;\n\t\t}\n\n\t\t// Prompt for trust confirmation (Yes/No)\n\t\tconst trust = await new Promise<boolean>((resolve) => {\n\t\t\tthis.ui.showSelector((done) => {\n\t\t\t\tconst submenu = new SelectSubmenu(\n\t\t\t\t\t\"Trust external source?\",\n\t\t\t\t\t\"This directory can load custom extensions that execute arbitrary code on your machine.\",\n\t\t\t\t\t[\n\t\t\t\t\t\t{ value: \"yes\", label: \"Yes\", description: \"Trust this directory and enable loading resources.\" },\n\t\t\t\t\t\t{ value: \"no\", label: \"No\", description: \"Do not trust this directory. Skip loading resources.\" },\n\t\t\t\t\t],\n\t\t\t\t\t\"no\",\n\t\t\t\t\t(value) => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tresolve(value === \"yes\");\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tcomponent: submenu,\n\t\t\t\t\tfocus: submenu.getSelectList(),\n\t\t\t\t\tonSuperseded: () => resolve(false),\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\n\t\tif (!trust) {\n\t\t\tthis.ui.showStatus(\"Aborted. External root was not trusted.\");\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst currentRoots = this.settingsManager.getExternalResourceRoots();\n\t\t\tif (!currentRoots.includes(canonical)) {\n\t\t\t\tthis.settingsManager.setExternalResourceRoots([...currentRoots, canonical], \"global\");\n\t\t\t}\n\t\t\tthis.settingsManager.addTrustedResourceRoot(canonical, \"global\");\n\t\t\tthis.ui.showStatus(`Added trusted external root: ${canonical}`);\n\t\t\tawait this.ui.handleReloadCommand();\n\t\t} catch (error) {\n\t\t\tthis.ui.showError(error instanceof Error ? error.message : String(error));\n\t\t}\n\t}\n\n\tprivate async removeExternalResourceRootFlow(root: string): Promise<void> {\n\t\ttry {\n\t\t\tconst currentRoots = this.settingsManager.getExternalResourceRoots();\n\t\t\tconst currentTrusted = this.settingsManager.getTrustedResourceRoots();\n\n\t\t\tconst newRoots = currentRoots.filter((r) => r !== root);\n\t\t\tconst newTrusted = currentTrusted.filter((r) => r !== root);\n\n\t\t\tthis.settingsManager.setExternalResourceRoots(newRoots, \"global\");\n\t\t\tthis.settingsManager.setTrustedResourceRoots(newTrusted, \"global\");\n\n\t\t\tthis.ui.showStatus(`Removed external root: ${root}`);\n\t\t\tawait this.ui.handleReloadCommand();\n\t\t} catch (error) {\n\t\t\tthis.ui.showError(error instanceof Error ? error.message : String(error));\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"profile-menu-controller.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/profile-menu-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,KAAK,EAAE,YAAY,EAAE,MAA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