@caupulican/pi-adaptative 0.86.17 → 0.90.2

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 (297) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +1 -1
  3. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  4. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +14 -15
  5. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  6. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +14 -16
  7. package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +4 -4
  8. package/dist/core/agent-session.d.ts +23 -33
  9. package/dist/core/agent-session.d.ts.map +1 -1
  10. package/dist/core/agent-session.js +81 -110
  11. package/dist/core/agent-session.js.map +1 -1
  12. package/dist/core/autonomy/contracts.d.ts +1 -1
  13. package/dist/core/autonomy/contracts.js.map +1 -1
  14. package/dist/core/autonomy/gates.d.ts.map +1 -1
  15. package/dist/core/autonomy/gates.js +16 -0
  16. package/dist/core/autonomy/gates.js.map +1 -1
  17. package/dist/core/autonomy/subagent-prompt.d.ts +2 -1
  18. package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -1
  19. package/dist/core/autonomy/subagent-prompt.js +2 -18
  20. package/dist/core/autonomy/subagent-prompt.js.map +1 -1
  21. package/dist/core/background-tool-task-controller.js +5 -5
  22. package/dist/core/background-tool-task-controller.js.map +1 -1
  23. package/dist/core/compaction-controller.d.ts +22 -2
  24. package/dist/core/compaction-controller.d.ts.map +1 -1
  25. package/dist/core/compaction-controller.js +75 -39
  26. package/dist/core/compaction-controller.js.map +1 -1
  27. package/dist/core/context/brain-curator.d.ts +2 -3
  28. package/dist/core/context/brain-curator.d.ts.map +1 -1
  29. package/dist/core/context/brain-curator.js +3 -20
  30. package/dist/core/context/brain-curator.js.map +1 -1
  31. package/dist/core/context/context-composition.d.ts +2 -1
  32. package/dist/core/context/context-composition.d.ts.map +1 -1
  33. package/dist/core/context/context-composition.js +6 -1
  34. package/dist/core/context/context-composition.js.map +1 -1
  35. package/dist/core/context/memory-prompt-block.js +1 -1
  36. package/dist/core/context/memory-prompt-block.js.map +1 -1
  37. package/dist/core/context/tool-output-packer.js +1 -1
  38. package/dist/core/context/tool-output-packer.js.map +1 -1
  39. package/dist/core/context-gc.js +10 -10
  40. package/dist/core/context-gc.js.map +1 -1
  41. package/dist/core/context-pipeline.d.ts +4 -4
  42. package/dist/core/context-pipeline.js +4 -4
  43. package/dist/core/context-pipeline.js.map +1 -1
  44. package/dist/core/default-tool-surface.d.ts.map +1 -1
  45. package/dist/core/default-tool-surface.js +1 -2
  46. package/dist/core/default-tool-surface.js.map +1 -1
  47. package/dist/core/delegation/session-worker-claim.d.ts +2 -2
  48. package/dist/core/delegation/session-worker-claim.js +2 -2
  49. package/dist/core/delegation/session-worker-claim.js.map +1 -1
  50. package/dist/core/delegation/worker-agent-control-coordinator.js +1 -1
  51. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  52. package/dist/core/delegation/worker-resource-materializer.js +3 -3
  53. package/dist/core/delegation/worker-resource-materializer.js.map +1 -1
  54. package/dist/core/delegation/worker-runner.d.ts +2 -13
  55. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  56. package/dist/core/delegation/worker-runner.js +5 -67
  57. package/dist/core/delegation/worker-runner.js.map +1 -1
  58. package/dist/core/extensions/builtin.js +4 -4
  59. package/dist/core/extensions/builtin.js.map +1 -1
  60. package/dist/core/extensions/runner.d.ts +6 -2
  61. package/dist/core/extensions/runner.d.ts.map +1 -1
  62. package/dist/core/extensions/runner.js +21 -9
  63. package/dist/core/extensions/runner.js.map +1 -1
  64. package/dist/core/extensions/types.d.ts +9 -2
  65. package/dist/core/extensions/types.d.ts.map +1 -1
  66. package/dist/core/extensions/types.js.map +1 -1
  67. package/dist/core/foreground-terminal-handoff-controller.js +2 -2
  68. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  69. package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
  70. package/dist/core/goals/compact-goal-context.js +13 -9
  71. package/dist/core/goals/compact-goal-context.js.map +1 -1
  72. package/dist/core/goals/goal-continuation-prompt.js +1 -1
  73. package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
  74. package/dist/core/goals/goal-session-controller.d.ts +6 -0
  75. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  76. package/dist/core/goals/goal-session-controller.js +16 -13
  77. package/dist/core/goals/goal-session-controller.js.map +1 -1
  78. package/dist/core/human-input-controller.js +1 -1
  79. package/dist/core/human-input-controller.js.map +1 -1
  80. package/dist/core/improvement-loop.js +13 -13
  81. package/dist/core/improvement-loop.js.map +1 -1
  82. package/dist/core/learning/reflection-engine.d.ts +2 -1
  83. package/dist/core/learning/reflection-engine.d.ts.map +1 -1
  84. package/dist/core/learning/reflection-engine.js +4 -24
  85. package/dist/core/learning/reflection-engine.js.map +1 -1
  86. package/dist/core/model-capability.d.ts.map +1 -1
  87. package/dist/core/model-capability.js +1 -1
  88. package/dist/core/model-capability.js.map +1 -1
  89. package/dist/core/model-router/route-judge.d.ts +2 -1
  90. package/dist/core/model-router/route-judge.d.ts.map +1 -1
  91. package/dist/core/model-router/route-judge.js +4 -12
  92. package/dist/core/model-router/route-judge.js.map +1 -1
  93. package/dist/core/models/perf-profile.d.ts +1 -1
  94. package/dist/core/models/perf-profile.d.ts.map +1 -1
  95. package/dist/core/models/perf-profile.js +2 -8
  96. package/dist/core/models/perf-profile.js.map +1 -1
  97. package/dist/core/orchestration/lane-tool-manifests.d.ts +1 -1
  98. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  99. package/dist/core/orchestration/lane-tool-manifests.js +1 -6
  100. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  101. package/dist/core/process-matrix/resume-launcher.js +3 -3
  102. package/dist/core/process-matrix/resume-launcher.js.map +1 -1
  103. package/dist/core/process-matrix/runtime.d.ts +2 -0
  104. package/dist/core/process-matrix/runtime.d.ts.map +1 -1
  105. package/dist/core/process-matrix/runtime.js +23 -19
  106. package/dist/core/process-matrix/runtime.js.map +1 -1
  107. package/dist/core/provider-prompt-contracts.d.ts +34 -0
  108. package/dist/core/provider-prompt-contracts.d.ts.map +1 -0
  109. package/dist/core/provider-prompt-contracts.js +133 -0
  110. package/dist/core/provider-prompt-contracts.js.map +1 -0
  111. package/dist/core/provider-request-context-controller.d.ts +40 -0
  112. package/dist/core/provider-request-context-controller.d.ts.map +1 -0
  113. package/dist/core/provider-request-context-controller.js +68 -0
  114. package/dist/core/provider-request-context-controller.js.map +1 -0
  115. package/dist/core/provider-request-runtime-controller.d.ts +22 -0
  116. package/dist/core/provider-request-runtime-controller.d.ts.map +1 -0
  117. package/dist/core/provider-request-runtime-controller.js +87 -0
  118. package/dist/core/provider-request-runtime-controller.js.map +1 -0
  119. package/dist/core/provider-tool-text.d.ts +7 -0
  120. package/dist/core/provider-tool-text.d.ts.map +1 -0
  121. package/dist/core/provider-tool-text.js +42 -0
  122. package/dist/core/provider-tool-text.js.map +1 -0
  123. package/dist/core/research/model-fitness.d.ts +2 -5
  124. package/dist/core/research/model-fitness.d.ts.map +1 -1
  125. package/dist/core/research/model-fitness.js +2 -20
  126. package/dist/core/research/model-fitness.js.map +1 -1
  127. package/dist/core/research/research-runner.d.ts +2 -1
  128. package/dist/core/research/research-runner.d.ts.map +1 -1
  129. package/dist/core/research/research-runner.js +6 -21
  130. package/dist/core/research/research-runner.js.map +1 -1
  131. package/dist/core/risk-classifier.d.ts.map +1 -1
  132. package/dist/core/risk-classifier.js +9 -1
  133. package/dist/core/risk-classifier.js.map +1 -1
  134. package/dist/core/runtime-builder.d.ts +3 -0
  135. package/dist/core/runtime-builder.d.ts.map +1 -1
  136. package/dist/core/runtime-builder.js +20 -25
  137. package/dist/core/runtime-builder.js.map +1 -1
  138. package/dist/core/scout-controller.d.ts +2 -1
  139. package/dist/core/scout-controller.d.ts.map +1 -1
  140. package/dist/core/scout-controller.js +2 -16
  141. package/dist/core/scout-controller.js.map +1 -1
  142. package/dist/core/sdk.d.ts +1 -1
  143. package/dist/core/sdk.js.map +1 -1
  144. package/dist/core/secrets/credential-exposure-guard.js +6 -6
  145. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  146. package/dist/core/secrets/credential-manager.d.ts +11 -1
  147. package/dist/core/secrets/credential-manager.d.ts.map +1 -1
  148. package/dist/core/secrets/credential-manager.js +28 -7
  149. package/dist/core/secrets/credential-manager.js.map +1 -1
  150. package/dist/core/secrets/credential-migration-source.d.ts +20 -0
  151. package/dist/core/secrets/credential-migration-source.d.ts.map +1 -0
  152. package/dist/core/secrets/credential-migration-source.js +113 -0
  153. package/dist/core/secrets/credential-migration-source.js.map +1 -0
  154. package/dist/core/secrets/credential-session-connection.d.ts +9 -0
  155. package/dist/core/secrets/credential-session-connection.d.ts.map +1 -0
  156. package/dist/core/secrets/credential-session-connection.js +39 -0
  157. package/dist/core/secrets/credential-session-connection.js.map +1 -0
  158. package/dist/core/security/untrusted-boundary.d.ts +2 -2
  159. package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
  160. package/dist/core/security/untrusted-boundary.js +3 -10
  161. package/dist/core/security/untrusted-boundary.js.map +1 -1
  162. package/dist/core/session-role.d.ts.map +1 -1
  163. package/dist/core/session-role.js +1 -2
  164. package/dist/core/session-role.js.map +1 -1
  165. package/dist/core/skill-vault.d.ts +98 -0
  166. package/dist/core/skill-vault.d.ts.map +1 -0
  167. package/dist/core/skill-vault.js +270 -0
  168. package/dist/core/skill-vault.js.map +1 -0
  169. package/dist/core/skills.d.ts +10 -9
  170. package/dist/core/skills.d.ts.map +1 -1
  171. package/dist/core/skills.js +42 -50
  172. package/dist/core/skills.js.map +1 -1
  173. package/dist/core/system-prompt-builder.d.ts +1 -1
  174. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  175. package/dist/core/system-prompt-builder.js +20 -60
  176. package/dist/core/system-prompt-builder.js.map +1 -1
  177. package/dist/core/system-prompt.d.ts +4 -4
  178. package/dist/core/system-prompt.d.ts.map +1 -1
  179. package/dist/core/system-prompt.js +87 -121
  180. package/dist/core/system-prompt.js.map +1 -1
  181. package/dist/core/tasks/task-state.d.ts.map +1 -1
  182. package/dist/core/tasks/task-state.js +6 -7
  183. package/dist/core/tasks/task-state.js.map +1 -1
  184. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  185. package/dist/core/tool-capability-policy.js +2 -1
  186. package/dist/core/tool-capability-policy.js.map +1 -1
  187. package/dist/core/tool-protocol-controller.d.ts.map +1 -1
  188. package/dist/core/tool-protocol-controller.js +4 -7
  189. package/dist/core/tool-protocol-controller.js.map +1 -1
  190. package/dist/core/tool-selection/promotion.d.ts.map +1 -1
  191. package/dist/core/tool-selection/promotion.js +2 -6
  192. package/dist/core/tool-selection/promotion.js.map +1 -1
  193. package/dist/core/toolkit/reflex-interpreter.d.ts +2 -1
  194. package/dist/core/toolkit/reflex-interpreter.d.ts.map +1 -1
  195. package/dist/core/toolkit/reflex-interpreter.js +2 -14
  196. package/dist/core/toolkit/reflex-interpreter.js.map +1 -1
  197. package/dist/core/tools/ask-question.js +6 -6
  198. package/dist/core/tools/ask-question.js.map +1 -1
  199. package/dist/core/tools/bash.d.ts.map +1 -1
  200. package/dist/core/tools/bash.js +8 -7
  201. package/dist/core/tools/bash.js.map +1 -1
  202. package/dist/core/tools/delegate-status.d.ts +17 -13
  203. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  204. package/dist/core/tools/delegate-status.js +111 -226
  205. package/dist/core/tools/delegate-status.js.map +1 -1
  206. package/dist/core/tools/delegate.d.ts +29 -2
  207. package/dist/core/tools/delegate.d.ts.map +1 -1
  208. package/dist/core/tools/delegate.js +149 -48
  209. package/dist/core/tools/delegate.js.map +1 -1
  210. package/dist/core/tools/edit.js +3 -3
  211. package/dist/core/tools/edit.js.map +1 -1
  212. package/dist/core/tools/extensionify-runtime.js +4 -4
  213. package/dist/core/tools/extensionify-runtime.js.map +1 -1
  214. package/dist/core/tools/find.d.ts.map +1 -1
  215. package/dist/core/tools/find.js +2 -4
  216. package/dist/core/tools/find.js.map +1 -1
  217. package/dist/core/tools/goal.js +3 -3
  218. package/dist/core/tools/goal.js.map +1 -1
  219. package/dist/core/tools/grep.js +2 -2
  220. package/dist/core/tools/grep.js.map +1 -1
  221. package/dist/core/tools/index.d.ts +1 -1
  222. package/dist/core/tools/index.d.ts.map +1 -1
  223. package/dist/core/tools/index.js +1 -1
  224. package/dist/core/tools/index.js.map +1 -1
  225. package/dist/core/tools/model-fitness.js +4 -4
  226. package/dist/core/tools/model-fitness.js.map +1 -1
  227. package/dist/core/tools/profile-writer.d.ts +30 -16
  228. package/dist/core/tools/profile-writer.d.ts.map +1 -1
  229. package/dist/core/tools/profile-writer.js +98 -59
  230. package/dist/core/tools/profile-writer.js.map +1 -1
  231. package/dist/core/tools/python.js +6 -6
  232. package/dist/core/tools/python.js.map +1 -1
  233. package/dist/core/tools/run-process.js +4 -4
  234. package/dist/core/tools/run-process.js.map +1 -1
  235. package/dist/core/tools/run-toolkit-script.js +4 -4
  236. package/dist/core/tools/run-toolkit-script.js.map +1 -1
  237. package/dist/core/tools/secret-store.d.ts +32 -3
  238. package/dist/core/tools/secret-store.d.ts.map +1 -1
  239. package/dist/core/tools/secret-store.js +141 -34
  240. package/dist/core/tools/secret-store.js.map +1 -1
  241. package/dist/core/tools/skill.d.ts +29 -0
  242. package/dist/core/tools/skill.d.ts.map +1 -0
  243. package/dist/core/tools/skill.js +79 -0
  244. package/dist/core/tools/skill.js.map +1 -0
  245. package/dist/core/tools/task-steps.js +4 -4
  246. package/dist/core/tools/task-steps.js.map +1 -1
  247. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  248. package/dist/core/tools/tool-definition-wrapper.js +2 -0
  249. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  250. package/dist/core/tools/tool-task.d.ts.map +1 -1
  251. package/dist/core/tools/tool-task.js +4 -0
  252. package/dist/core/tools/tool-task.js.map +1 -1
  253. package/dist/core/tools/worktree-sync.js +6 -6
  254. package/dist/core/tools/worktree-sync.js.map +1 -1
  255. package/dist/core/tools/write.js +3 -3
  256. package/dist/core/tools/write.js.map +1 -1
  257. package/dist/index.d.ts +5 -2
  258. package/dist/index.d.ts.map +1 -1
  259. package/dist/index.js +4 -1
  260. package/dist/index.js.map +1 -1
  261. package/dist/modes/interactive/interactive-event-controller.js +1 -1
  262. package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
  263. package/dist/modes/interactive/interactive-mode.js +1 -1
  264. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  265. package/dist/modes/interactive/report-commands.js +1 -1
  266. package/dist/modes/interactive/report-commands.js.map +1 -1
  267. package/dist/modes/interactive/secret-menu-controller.d.ts.map +1 -1
  268. package/dist/modes/interactive/secret-menu-controller.js +2 -18
  269. package/dist/modes/interactive/secret-menu-controller.js.map +1 -1
  270. package/dist/modes/interactive/session-flow-commands.js +1 -1
  271. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  272. package/docs/compaction.md +45 -25
  273. package/docs/extensions.md +23 -7
  274. package/docs/settings.md +3 -3
  275. package/docs/skills.md +14 -10
  276. package/docs/task-steps.md +2 -2
  277. package/docs/tmux-agent-manager.md +1 -1
  278. package/docs/tool-repair.md +18 -1
  279. package/docs/usage.md +4 -2
  280. package/docs/worker-profiles.md +3 -3
  281. package/docs/worktree-sync.md +2 -2
  282. package/examples/extensions/custom-compaction.ts +5 -17
  283. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  284. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  285. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  286. package/examples/extensions/sandbox/package-lock.json +2 -2
  287. package/examples/extensions/sandbox/package.json +1 -1
  288. package/examples/extensions/summarize.ts +3 -5
  289. package/examples/extensions/with-deps/package-lock.json +2 -2
  290. package/examples/extensions/with-deps/package.json +1 -1
  291. package/examples/sdk/04-skills.ts +1 -1
  292. package/npm-shrinkwrap.json +12 -12
  293. package/package.json +4 -4
  294. package/dist/core/util/json-size.d.ts +0 -3
  295. package/dist/core/util/json-size.d.ts.map +0 -1
  296. package/dist/core/util/json-size.js +0 -95
  297. package/dist/core/util/json-size.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"session-flow-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/session-flow-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,OAAO,EAAkC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,oBAAoB,CAAC;AAOpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EACN,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EAEjB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,mBAAmB,GACnB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE3F,OAAO,EACN,4BAA4B,EAC5B,iBAAiB,EACjB,gCAAgC,GAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EAEf,cAAc,GACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC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AI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AACzB,CAAC","sourcesContent":["/**\n * Session-picker, tree/fork navigation, and model-selector flows extracted from\n * interactive-mode.\n *\n * Each entry opens a selector overlay (via `host.showSelector`) or renders a\n * session-info block, driving `AgentSession`/`AgentSessionRuntime` navigation and\n * the fork/resume/clone/goal-continuation paths. The interdependent selector\n * flows share one narrow `SessionFlowHost` seam; the three prototype-tested leaf\n * commands (`handleCloneCommand`, `handleGoalContinueCommand`,\n * `handleSessionCommand`) take their own minimal host shapes so their behaviour\n * tests keep exercising them through interactive-mode's thin wrappers unchanged.\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { Api, Model } from \"@caupulican/pi-ai\";\nimport type { EditorComponent } from \"@caupulican/pi-tui\";\nimport { type Component, type Container, Loader, Spacer, Text, type TUI } from \"@caupulican/pi-tui\";\nimport type {\n\tAgentSession,\n\tGoalContinuationLoopOptions,\n\tGoalContinuationLoopResult,\n} from \"../../core/agent-session.ts\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport { hasCostSummarySignal } from \"../../core/cost/cost-summary.ts\";\nimport type { ExtensionCommandContext } from \"../../core/extensions/index.ts\";\nimport {\n\tcancelPersistedGoal,\n\tclearPersistedGoal,\n\teditPersistedGoal,\n\ttype GoalStateRevision,\n\tgetGoalStateRevision,\n\tpausePersistedGoal,\n\treplaceGoal,\n\tresumeGoal,\n\tresumePersistedGoal,\n} from \"../../core/goals/goal-lifecycle.ts\";\nimport type { GoalState } from \"../../core/goals/goal-state.ts\";\nimport { applyGoalAction, completeGoalManually } from \"../../core/goals/goal-tool-core.ts\";\nimport type { KeybindingsManager } from \"../../core/keybindings.ts\";\nimport {\n\tfindExactModelReferenceMatch,\n\tresolveModelScope,\n\tresolveModelScopeWithDiagnostics,\n} from \"../../core/model-resolver.ts\";\nimport { MissingSessionCwdError } from \"../../core/session-cwd.ts\";\nimport { listAllSessions, listSessions, openSession } from \"../../core/session-manager-factory.ts\";\nimport type { SettingsManager } from \"../../core/settings-manager.ts\";\nimport { parseTaskCommand } from \"../../core/tasks/task-command.ts\";\nimport {\n\taddTaskStep,\n\tclearTaskSteps,\n\tcompactTaskSteps,\n\tcreateTaskStepsState,\n\tformatTaskSteps,\n\ttype TaskStepsState,\n\tupdateTaskStep,\n} from \"../../core/tasks/task-state.ts\";\nimport { ProjectTrustStore } from \"../../core/trust-manager.ts\";\nimport type { CustomEditor } from \"./components/custom-editor.ts\";\nimport type { FooterComponent } from \"./components/footer.ts\";\nimport { keyText } from \"./components/keybinding-hints.ts\";\nimport { ModelSelectorComponent } from \"./components/model-selector.ts\";\nimport { ScopedModelsSelectorComponent } from \"./components/scoped-models-selector.ts\";\nimport { SessionSelectorComponent } from \"./components/session-selector.ts\";\nimport { TreeSelectorComponent } from \"./components/tree-selector.ts\";\nimport { TrustSelectorComponent } from \"./components/trust-selector.ts\";\nimport { UserMessageSelectorComponent } from \"./components/user-message-selector.ts\";\nimport type { ExtensionUiHost } from \"./extension-ui-host.ts\";\nimport { formatCostReport } from \"./report-commands.ts\";\nimport { handleNonFatalSessionReplacementError } from \"./session-replacement-errors.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\n/** Shared seam for the interdependent selector/navigation flows. */\nexport interface SessionFlowHost {\n\treadonly session: AgentSession;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n\treadonly runtimeHost: AgentSessionRuntime;\n\treadonly ui: TUI;\n\treadonly chatContainer: Container;\n\treadonly statusContainer: Container;\n\treadonly editor: EditorComponent;\n\treadonly defaultEditor: CustomEditor;\n\treadonly footer: FooterComponent;\n\treadonly extensionUiHost: ExtensionUiHost;\n\treadonly keybindings: KeybindingsManager;\n\tloadingAnimation: Loader | undefined;\n\tshowSelector(create: (done: () => void) => { component: Component; focus: Component }): void;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\trefreshAutonomyFooterStatus(): void;\n\trenderCurrentSessionState(): void;\n\trenderInitialMessages(options?: { forceHistoryLoad?: boolean }): Promise<void>;\n\tflushCompactionQueue(options?: { willRetry?: boolean }): Promise<void>;\n\thandleFatalRuntimeError(prefix: string, error: unknown): Promise<never>;\n\tpromptForMissingSessionCwd(error: MissingSessionCwdError): Promise<string | undefined>;\n\tupdateEditorBorderColor(): void;\n\tupdateAvailableProviderCount(): Promise<void>;\n\tmaybeWarnAboutAnthropicSubscriptionAuth(model?: Model<Api>): Promise<void>;\n\tcheckDaxnutsEasterEgg(model: { provider: string; id: string }): void;\n\tgetModelCandidates(): Promise<Model<Api>[]>;\n\tshutdown(options?: { fromSignal?: boolean }): Promise<void>;\n}\n\nfunction finishSelectorCancellation(host: Pick<SessionFlowHost, \"ui\">, done: () => void): void {\n\tdone();\n\thost.ui.requestRender();\n}\n\nfunction finishSelectorError(host: Pick<SessionFlowHost, \"showError\">, done: () => void, error: unknown): void {\n\tdone();\n\thost.showError(error instanceof Error ? error.message : String(error));\n}\n\nexport async function showModelSelector(host: SessionFlowHost, initialSearchInput?: string): Promise<void> {\n\ttry {\n\t\tawait host.session.extensionRunner.emit({\n\t\t\ttype: \"model_selector_open\",\n\t\t\tcurrentModel: host.session.model,\n\t\t\tscopedModels: host.session.scopedModels,\n\t\t\tinitialSearchInput,\n\t\t});\n\t} catch (error) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t\treturn;\n\t}\n\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\ttry {\n\t\t\t\t\tawait host.session.setModel(model);\n\t\t\t\t\thost.footer.invalidate();\n\t\t\t\t\thost.updateEditorBorderColor();\n\t\t\t\t\tdone();\n\t\t\t\t\thost.showStatus(`Model: ${model.id}`);\n\t\t\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth(model);\n\t\t\t\t\thost.checkDaxnutsEasterEgg(model);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfinishSelectorError(host, done, error);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t},\n\t\t\tinitialSearchInput,\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function showModelsSelector(host: SessionFlowHost): Promise<void> {\n\t// Get all available models\n\thost.session.modelRegistry.refresh();\n\tconst allModels = host.session.modelRegistry.getAvailable();\n\tconst allModelIds = new Set(allModels.map((model) => `${model.provider}/${model.id}`));\n\tconst configuredPatterns = host.settingsManager.getEnabledModels();\n\tconst sessionScopedModels = host.session.scopedModels;\n\n\tif (allModels.length === 0 && !configuredPatterns?.length && sessionScopedModels.length === 0) {\n\t\thost.showStatus(\"No models available\");\n\t\treturn;\n\t}\n\tconst configuredScope = configuredPatterns?.length\n\t\t? await resolveModelScopeWithDiagnostics(configuredPatterns, host.session.modelRegistry)\n\t\t: undefined;\n\n\t// Check if session has scoped models (from previous session-only changes or CLI --models)\n\tconst hasSessionScope = sessionScopedModels.length > 0;\n\n\t// Build enabled model IDs from session state or settings\n\tlet currentEnabledIds: string[] | null = null;\n\n\tif (hasSessionScope) {\n\t\t// Use current session's scoped models\n\t\tcurrentEnabledIds = sessionScopedModels.map((scoped) => `${scoped.model.provider}/${scoped.model.id}`);\n\t} else if (configuredScope) {\n\t\tcurrentEnabledIds = configuredScope.scopedModels.map((scoped) => `${scoped.model.provider}/${scoped.model.id}`);\n\t}\n\n\tfor (const diagnostic of configuredScope?.diagnostics ?? []) {\n\t\tif (diagnostic.code !== \"no-match\") continue;\n\t\tcurrentEnabledIds ??= [];\n\t\tif (!currentEnabledIds.includes(diagnostic.pattern)) currentEnabledIds.push(diagnostic.pattern);\n\t}\n\n\t// Helper to update session's scoped models (session-only, no persist)\n\tconst updateSessionModels = async (enabledIds: string[] | null) => {\n\t\tcurrentEnabledIds = enabledIds === null ? null : [...enabledIds];\n\t\tconst hasEnabledAvailableModel = enabledIds?.some((id) => allModelIds.has(id)) ?? false;\n\t\tconst allAvailableModelsEnabled = enabledIds !== null && [...allModelIds].every((id) => enabledIds.includes(id));\n\t\tif (enabledIds && hasEnabledAvailableModel && !allAvailableModelsEnabled) {\n\t\t\tconst newScopedModels = await resolveModelScope(enabledIds, host.session.modelRegistry);\n\t\t\thost.session.setScopedModels(\n\t\t\t\tnewScopedModels.map((sm) => ({\n\t\t\t\t\tmodel: sm.model,\n\t\t\t\t\tthinkingLevel: sm.thinkingLevel,\n\t\t\t\t})),\n\t\t\t);\n\t\t} else {\n\t\t\t// All enabled or none enabled = no filter\n\t\t\thost.session.setScopedModels([]);\n\t\t}\n\t\tawait host.updateAvailableProviderCount();\n\t\thost.ui.requestRender();\n\t};\n\n\thost.showSelector((done) => {\n\t\tconst selector = new ScopedModelsSelectorComponent(\n\t\t\t{\n\t\t\t\tallModels,\n\t\t\t\tenabledModelIds: currentEnabledIds,\n\t\t\t},\n\t\t\t{\n\t\t\t\tonChange: async (enabledIds) => {\n\t\t\t\t\tawait updateSessionModels(enabledIds);\n\t\t\t\t},\n\t\t\t\tonPersist: (enabledIds) => {\n\t\t\t\t\t// Persist to settings\n\t\t\t\t\tconst allEnabled =\n\t\t\t\t\t\tenabledIds !== null &&\n\t\t\t\t\t\tenabledIds.length === allModels.length &&\n\t\t\t\t\t\tenabledIds.every((id) => allModelIds.has(id));\n\t\t\t\t\tconst newPatterns = enabledIds === null || allEnabled ? undefined : enabledIds;\n\t\t\t\t\thost.settingsManager.setEnabledModels(newPatterns ? [...newPatterns] : undefined);\n\t\t\t\t\thost.showStatus(\"Model selection saved to settings\");\n\t\t\t\t},\n\t\t\t\tonCancel: () => {\n\t\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showUserMessageSelector(host: SessionFlowHost, newSessionName?: string): void {\n\tconst userMessages = host.session.getUserMessagesForForking();\n\n\tif (userMessages.length === 0) {\n\t\thost.showStatus(\"No messages to fork from\");\n\t\treturn;\n\t}\n\n\tconst initialSelectedId = userMessages[userMessages.length - 1]?.entryId;\n\n\thost.showSelector((done) => {\n\t\tconst selector = new UserMessageSelectorComponent(\n\t\t\tuserMessages.map((m) => ({ id: m.entryId, text: m.text })),\n\t\t\tasync (entryId) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await host.runtimeHost.fork(entryId);\n\t\t\t\t\tif (result.cancelled) {\n\t\t\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thost.renderCurrentSessionState();\n\t\t\t\t\tif (newSessionName) {\n\t\t\t\t\t\thost.session.setSessionName(newSessionName);\n\t\t\t\t\t}\n\t\t\t\t\thost.editor.setText(result.selectedText ?? \"\");\n\t\t\t\t\tdone();\n\t\t\t\t\thost.showStatus(newSessionName ? `Forked to new session: ${newSessionName}` : \"Forked to new session\");\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tfinishSelectorError(host, done, error);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t},\n\t\t\tinitialSelectedId,\n\t\t);\n\t\treturn { component: selector, focus: selector.getMessageList() };\n\t});\n}\n\nexport function showTreeSelector(host: SessionFlowHost, initialSelectedId?: string): void {\n\tconst tree = host.sessionManager.getTree();\n\tconst realLeafId = host.sessionManager.getLeafId();\n\tconst initialFilterMode = host.settingsManager.getTreeFilterMode();\n\n\tif (tree.length === 0) {\n\t\thost.showStatus(\"No entries in session\");\n\t\treturn;\n\t}\n\n\thost.showSelector((done) => {\n\t\tconst selector = new TreeSelectorComponent(\n\t\t\ttree,\n\t\t\trealLeafId,\n\t\t\thost.ui.terminal.rows,\n\t\t\tasync (entryId) => {\n\t\t\t\t// Selecting the current leaf is a no-op (already there)\n\t\t\t\tif (entryId === realLeafId) {\n\t\t\t\t\tdone();\n\t\t\t\t\thost.showStatus(\"Already at this point\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Ask about summarization\n\t\t\t\tdone(); // Close selector first\n\n\t\t\t\t// Loop until user makes a complete choice or cancels to tree\n\t\t\t\tlet wantsSummary = false;\n\t\t\t\tlet customInstructions: string | undefined;\n\n\t\t\t\t// Check if we should skip the prompt (user preference to always default to no summary)\n\t\t\t\tif (!host.settingsManager.getBranchSummarySkipPrompt()) {\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst summaryChoice = await host.extensionUiHost.showExtensionSelector(\"Summarize branch?\", [\n\t\t\t\t\t\t\t\"No summary\",\n\t\t\t\t\t\t\t\"Summarize\",\n\t\t\t\t\t\t\t\"Summarize with custom prompt\",\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tif (summaryChoice === undefined) {\n\t\t\t\t\t\t\t// User pressed escape - re-show tree selector with same selection\n\t\t\t\t\t\t\tshowTreeSelector(host, entryId);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\twantsSummary = summaryChoice !== \"No summary\";\n\n\t\t\t\t\t\tif (summaryChoice === \"Summarize with custom prompt\") {\n\t\t\t\t\t\t\tcustomInstructions = await host.extensionUiHost.showExtensionEditor(\n\t\t\t\t\t\t\t\t\"Custom summarization instructions\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (customInstructions === undefined) {\n\t\t\t\t\t\t\t\t// User cancelled - loop back to summary selector\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// User made a complete choice\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Set up escape handler and loader if summarizing\n\t\t\t\tlet summaryLoader: Loader | undefined;\n\t\t\t\tconst originalOnEscape = host.defaultEditor.onEscape;\n\n\t\t\t\tif (wantsSummary) {\n\t\t\t\t\thost.defaultEditor.onEscape = () => {\n\t\t\t\t\t\thost.session.abortBranchSummary();\n\t\t\t\t\t};\n\t\t\t\t\thost.chatContainer.addChild(new Spacer(1));\n\t\t\t\t\tsummaryLoader = new Loader(\n\t\t\t\t\t\thost.ui,\n\t\t\t\t\t\t(spinner) => theme.fg(\"accent\", spinner),\n\t\t\t\t\t\t(text) => theme.fg(\"muted\", text),\n\t\t\t\t\t\t`Summarizing branch... (${keyText(\"app.interrupt\")} to cancel)`,\n\t\t\t\t\t);\n\t\t\t\t\thost.statusContainer.addChild(summaryLoader);\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await host.session.navigateTree(entryId, {\n\t\t\t\t\t\tsummarize: wantsSummary,\n\t\t\t\t\t\tcustomInstructions,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (result.aborted) {\n\t\t\t\t\t\t// Summarization aborted - re-show tree selector with same selection\n\t\t\t\t\t\thost.showStatus(\"Branch summarization cancelled\");\n\t\t\t\t\t\tshowTreeSelector(host, entryId);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (result.cancelled) {\n\t\t\t\t\t\thost.showStatus(\"Navigation cancelled\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update UI\n\t\t\t\t\tawait host.renderInitialMessages();\n\t\t\t\t\tif (result.editorText && !host.editor.getText().trim()) {\n\t\t\t\t\t\thost.editor.setText(result.editorText);\n\t\t\t\t\t}\n\t\t\t\t\thost.showStatus(\"Navigated to selected point\");\n\t\t\t\t\tvoid host.flushCompactionQueue({ willRetry: false });\n\t\t\t\t} catch (error) {\n\t\t\t\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t\t\t\t} finally {\n\t\t\t\t\tif (summaryLoader) {\n\t\t\t\t\t\tsummaryLoader.stop();\n\t\t\t\t\t\thost.statusContainer.clear();\n\t\t\t\t\t}\n\t\t\t\t\thost.defaultEditor.onEscape = originalOnEscape;\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t},\n\t\t\t(entryId, label) => {\n\t\t\t\thost.sessionManager.appendLabelChange(entryId, label);\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t\tinitialSelectedId,\n\t\t\tinitialFilterMode,\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showTrustSelector(host: SessionFlowHost): void {\n\tconst cwd = host.sessionManager.getCwd();\n\tconst trustStore = new ProjectTrustStore(host.runtimeHost.services.agentDir);\n\tconst savedDecision = trustStore.get(cwd);\n\thost.showSelector((done) => {\n\t\tconst selector = new TrustSelectorComponent({\n\t\t\tcwd,\n\t\t\tsavedDecision,\n\t\t\tprojectTrusted: host.settingsManager.isProjectTrusted(),\n\t\t\tonSelect: (trusted) => {\n\t\t\t\ttrustStore.set(cwd, trusted);\n\t\t\t\tdone();\n\t\t\t\thost.showStatus(\n\t\t\t\t\t`Saved trust decision: ${trusted ? \"trusted\" : \"untrusted\"}. Restart pi for this to take effect.`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tonCancel: () => {\n\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t},\n\t\t});\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showSessionSelector(host: SessionFlowHost): void {\n\thost.showSelector((done) => {\n\t\tconst selector = new SessionSelectorComponent(\n\t\t\t(onProgress) => listSessions(host.sessionManager.getCwd(), host.sessionManager.getSessionDir(), onProgress),\n\t\t\t(onProgress) =>\n\t\t\t\thost.sessionManager.usesDefaultSessionDir()\n\t\t\t\t\t? listAllSessions(onProgress)\n\t\t\t\t\t: listAllSessions(host.sessionManager.getSessionDir(), onProgress),\n\t\t\tasync (sessionPath) => {\n\t\t\t\tdone();\n\t\t\t\tawait handleResumeSession(host, sessionPath);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tvoid host.shutdown();\n\t\t\t},\n\t\t\t() => host.ui.requestRender(),\n\t\t\t{\n\t\t\t\trenameSession: async (sessionFilePath: string, nextName: string | undefined) => {\n\t\t\t\t\tconst next = (nextName ?? \"\").trim();\n\t\t\t\t\tif (!next) return;\n\t\t\t\t\tconst mgr = openSession(sessionFilePath);\n\t\t\t\t\tmgr.appendSessionInfo(next);\n\t\t\t\t},\n\t\t\t\tshowRenameHint: true,\n\t\t\t\tkeybindings: host.keybindings,\n\t\t\t},\n\n\t\t\thost.sessionManager.getSessionFile(),\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nasync function switchSession(\n\thost: SessionFlowHost,\n\tsessionPath: string,\n\toptions: Parameters<ExtensionCommandContext[\"switchSession\"]>[1] | undefined,\n\tcwdOverride?: string,\n): Promise<{ cancelled: boolean }> {\n\treturn host.runtimeHost.switchSession(sessionPath, {\n\t\tcwdOverride,\n\t\twithSession: options?.withSession,\n\t});\n}\n\nasync function offerRestoredGoalResume(host: SessionFlowHost): Promise<boolean> {\n\tconst state = host.session.getGoalStateSnapshot();\n\tif (!state || (state.status !== \"paused\" && state.status !== \"blocked\" && state.status !== \"usage_limited\")) {\n\t\thost.session.restoreGoalRuntimeAfterResume();\n\t\treturn false;\n\t}\n\tconst choice = await host.extensionUiHost?.showExtensionSelector(\"Resume stopped goal?\", [\n\t\t\"Resume goal\",\n\t\t\"Leave stopped\",\n\t]);\n\tif (choice !== \"Resume goal\") return false;\n\tconst resumed = resumePersistedGoal(host.session);\n\tif (!resumed.ok) throw new Error(`Goal resume failed: ${resumed.error}`);\n\thost.session.restoreGoalRuntimeAfterResume();\n\thost.refreshAutonomyFooterStatus();\n\treturn true;\n}\n\nexport async function handleResumeSession(\n\thost: SessionFlowHost,\n\tsessionPath: string,\n\toptions?: Parameters<ExtensionCommandContext[\"switchSession\"]>[1],\n): Promise<{ cancelled: boolean }> {\n\tif (host.loadingAnimation) {\n\t\thost.loadingAnimation.stop();\n\t\thost.loadingAnimation = undefined;\n\t}\n\thost.statusContainer.clear();\n\ttry {\n\t\tconst result = await switchSession(host, sessionPath, options);\n\t\tif (result.cancelled) {\n\t\t\treturn result;\n\t\t}\n\t\thost.renderCurrentSessionState();\n\t\tconst goalResumed = await offerRestoredGoalResume(host);\n\t\thost.showStatus(goalResumed ? \"Resumed session and goal\" : \"Resumed session; goal state preserved\");\n\t\treturn result;\n\t} catch (error: unknown) {\n\t\tconst disposition = handleNonFatalSessionReplacementError(host, error);\n\t\tif (disposition) return { cancelled: disposition === \"previous_restored\" };\n\t\tif (error instanceof MissingSessionCwdError) {\n\t\t\tconst selectedCwd = await host.promptForMissingSessionCwd(error);\n\t\t\tif (!selectedCwd) {\n\t\t\t\thost.showStatus(\"Resume cancelled\");\n\t\t\t\treturn { cancelled: true };\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst result = await switchSession(host, sessionPath, options, selectedCwd);\n\t\t\t\tif (result.cancelled) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\thost.renderCurrentSessionState();\n\t\t\t\tconst goalResumed = await offerRestoredGoalResume(host);\n\t\t\t\thost.showStatus(\n\t\t\t\t\tgoalResumed\n\t\t\t\t\t\t? \"Resumed session and goal in current cwd\"\n\t\t\t\t\t\t: \"Resumed session in current cwd; goal state preserved\",\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t} catch (retryError: unknown) {\n\t\t\t\tconst retryDisposition = handleNonFatalSessionReplacementError(host, retryError);\n\t\t\t\tif (retryDisposition) return { cancelled: retryDisposition === \"previous_restored\" };\n\t\t\t\treturn host.handleFatalRuntimeError(\"Failed to resume session\", retryError);\n\t\t\t}\n\t\t}\n\t\treturn host.handleFatalRuntimeError(\"Failed to resume session\", error);\n\t}\n}\n\nexport async function handleModelCommand(host: SessionFlowHost, searchTerm?: string): Promise<void> {\n\tif (!searchTerm) {\n\t\tawait showModelSelector(host);\n\t\treturn;\n\t}\n\n\tconst model = await findExactModelMatch(host, searchTerm);\n\tif (model) {\n\t\ttry {\n\t\t\tawait host.session.setModel(model);\n\t\t\thost.footer.invalidate();\n\t\t\thost.updateEditorBorderColor();\n\t\t\thost.showStatus(`Model: ${model.id}`);\n\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth(model);\n\t\t\thost.checkDaxnutsEasterEgg(model);\n\t\t} catch (error) {\n\t\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t\t}\n\t\treturn;\n\t}\n\n\tawait showModelSelector(host, searchTerm);\n}\n\nexport async function findExactModelMatch(host: SessionFlowHost, searchTerm: string): Promise<Model<Api> | undefined> {\n\tconst models = await host.getModelCandidates();\n\treturn findExactModelReferenceMatch(searchTerm, models);\n}\n\n// ===========================================================================\n// Prototype-tested leaf commands — narrow host shapes matching their fakes.\n// ===========================================================================\n\nexport interface CloneCommandHost {\n\treadonly sessionManager: { getLeafId: () => string | null };\n\treadonly runtimeHost: {\n\t\tfork: (entryId: string, options?: { position?: \"before\" | \"at\" }) => Promise<{ cancelled: boolean }>;\n\t};\n\trenderCurrentSessionState(): void;\n\treadonly editor: { setText: (text: string) => void };\n\treadonly session: { setSessionName: (name: string) => void };\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\treadonly ui: { requestRender: () => void };\n}\n\nexport async function handleCloneCommand(host: CloneCommandHost, newSessionName?: string): Promise<void> {\n\tconst leafId = host.sessionManager.getLeafId();\n\tif (!leafId) {\n\t\thost.showStatus(\"Nothing to clone yet\");\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst result = await host.runtimeHost.fork(leafId, { position: \"at\" });\n\t\tif (result.cancelled) {\n\t\t\thost.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\thost.renderCurrentSessionState();\n\t\tif (newSessionName) {\n\t\t\thost.session.setSessionName(newSessionName);\n\t\t}\n\t\thost.editor.setText(\"\");\n\t\thost.showStatus(newSessionName ? `Cloned to new session: ${newSessionName}` : \"Cloned to new session\");\n\t} catch (error: unknown) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t}\n}\n\nexport type ParsedGoalContinueCommand =\n\t| { ok: true; maxTurns: number; maxStallTurns: number; maxWallClockMinutes: number }\n\t| { ok: false; error: string };\n\nexport interface GoalResumeHost {\n\treadonly session: {\n\t\tgetGoalStateSnapshot: () => GoalState | undefined;\n\t\tsaveGoalStateSnapshot: (state: GoalState, expected?: GoalStateRevision) => string;\n\t\tclearGoalStateSnapshot?: (state: GoalState, now: string) => string;\n\t\trestoreGoalRuntimeAfterResume: () => void;\n\t};\n\trefreshAutonomyFooterStatus(): void;\n}\n\nexport interface GoalCommandHost extends GoalResumeHost {\n\treadonly session: GoalResumeHost[\"session\"] & {\n\t\tcontinueGoalLoop: (options: GoalContinuationLoopOptions) => Promise<GoalContinuationLoopResult>;\n\t\tgetGoalRuntimeSnapshot: (settings: {\n\t\t\tmaxStallTurns: number;\n\t\t}) => ReturnType<AgentSession[\"getGoalRuntimeSnapshot\"]>;\n\t};\n\tpromptForGoalEdit?(currentObjective: string): Promise<string | undefined>;\n\tgetMaxStallTurns?(): number;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n}\n\nexport type GoalResumeResult = { ok: true; resumed: true; state: GoalState } | { ok: false; error: string };\n\n/** Canonical persisted transition used by both `/goal resume` and session `/resume`. */\nexport function resumeCurrentGoal(host: GoalResumeHost, now = new Date().toISOString()): GoalResumeResult {\n\tconst resumed = resumePersistedGoal(host.session, now);\n\tif (!resumed.ok) return resumed;\n\thost.session.restoreGoalRuntimeAfterResume();\n\thost.refreshAutonomyFooterStatus();\n\treturn { ok: true, resumed: true, state: resumed.state };\n}\n\nfunction formatGoalStatus(snapshot: ReturnType<AgentSession[\"getGoalRuntimeSnapshot\"]>): string {\n\tconst state = snapshot.goalState;\n\tif (!state) return `Goal: none (${snapshot.continuation.action}/${snapshot.continuation.reasonCode})`;\n\tconst requirements = state.requirements.map((requirement) => {\n\t\tconst blockedReason = requirement.blockedReason ? ` — ${requirement.blockedReason}` : \"\";\n\t\treturn `- ${requirement.id}: ${requirement.status}${blockedReason}`;\n\t});\n\tconst blockedReason = state.blockedReason ? `\\nBlocked reason: ${state.blockedReason}` : \"\";\n\tconst requirementDetails = requirements.length > 0 ? `\\n${requirements.join(\"\\n\")}` : \"\";\n\tconst tokenUsage =\n\t\tstate.tokenBudget !== undefined\n\t\t\t? `\\nTokens: ${state.tokensUsed ?? 0}/${state.tokenBudget}`\n\t\t\t: (state.tokensUsed ?? 0) > 0\n\t\t\t\t? `\\nTokens: ${state.tokensUsed ?? 0}`\n\t\t\t\t: \"\";\n\treturn `Goal: ${state.userGoal}\\nStatus: ${state.status}${blockedReason}${tokenUsage}\\nRequirements: open ${snapshot.continuation.openRequirementIds.length}, blocked ${snapshot.continuation.blockedRequirementIds.length}, satisfied ${snapshot.continuation.satisfiedRequirementIds.length}${requirementDetails}\\nContinuation: ${snapshot.continuation.action}/${snapshot.continuation.reasonCode}\\nControls: /goal edit | /goal pause | /goal resume | /goal reopen <requirement-id> | /goal complete | /goal clear | /goal override <text>`;\n}\n\nexport async function handleGoalCommand(host: GoalCommandHost, text: string): Promise<void> {\n\tconst input = text.replace(/^\\/goal\\s*/, \"\").trim();\n\tif (!input || input === \"status\") {\n\t\thost.showStatus(\n\t\t\tformatGoalStatus(host.session.getGoalRuntimeSnapshot({ maxStallTurns: host.getMaxStallTurns?.() ?? 20 })),\n\t\t);\n\t\treturn;\n\t}\n\n\tconst now = new Date().toISOString();\n\tconst current = host.session.getGoalStateSnapshot();\n\tif (input === \"resume\") {\n\t\tconst resumed = resumeCurrentGoal(host, now);\n\t\tif (!resumed.ok) {\n\t\t\thost.showError(resumed.error);\n\t\t\treturn;\n\t\t}\n\t\thost.showStatus(\"Goal resumed.\");\n\t\treturn;\n\t}\n\n\tif (input === \"pause\") {\n\t\tconst paused = pausePersistedGoal(host.session, now);\n\t\tif (!paused.ok) {\n\t\t\thost.showError(paused.error);\n\t\t\treturn;\n\t\t}\n\t\thost.showStatus(\"Goal paused.\");\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tif (input === \"edit\" || input.startsWith(\"edit \")) {\n\t\tconst inlineObjective = input.slice(\"edit\".length).trim();\n\t\tconst objective = inlineObjective || (current ? await host.promptForGoalEdit?.(current.userGoal) : undefined);\n\t\tif (!objective) {\n\t\t\thost.showError(current ? \"Usage: /goal edit <objective>\" : \"No goal exists to edit.\");\n\t\t\treturn;\n\t\t}\n\t\tconst edited = editPersistedGoal(host.session, { userGoal: objective }, now);\n\t\tif (!edited.ok) {\n\t\t\thost.showError(edited.error);\n\t\t\treturn;\n\t\t}\n\t\tif (edited.state.status === \"active\") host.session.restoreGoalRuntimeAfterResume();\n\t\thost.showStatus(\"Goal updated.\");\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tif (input === \"complete\") {\n\t\tconst completed = completeGoalManually(current, now);\n\t\tif (!completed.ok) {\n\t\t\thost.showError(completed.error);\n\t\t\treturn;\n\t\t}\n\t\thost.session.saveGoalStateSnapshot(completed.state, current ? getGoalStateRevision(current) : undefined);\n\t\thost.showStatus(\"Goal completed manually.\");\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tif (input === \"clear\") {\n\t\tconst cleared = clearPersistedGoal(host.session, now);\n\t\tif (!cleared.ok) {\n\t\t\thost.showError(cleared.error);\n\t\t\treturn;\n\t\t}\n\t\thost.showStatus(cleared.cleared ? \"Goal cleared.\" : \"No goal exists to clear.\");\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tif (input === \"close\" || input === \"cancel\") {\n\t\tconst cancelled = cancelPersistedGoal(host.session, now);\n\t\tif (!cancelled.ok) {\n\t\t\thost.showError(cancelled.error);\n\t\t\treturn;\n\t\t}\n\t\thost.showStatus(\"Goal closed.\");\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tif (input === \"reopen\" || input.startsWith(\"reopen \")) {\n\t\tconst requirementId = input.slice(\"reopen\".length).trim();\n\t\tif (!requirementId) {\n\t\t\thost.showError(\"Usage: /goal reopen <requirement-id>\");\n\t\t\treturn;\n\t\t}\n\t\tif (!current) {\n\t\t\thost.showError(\"No goal exists to update.\");\n\t\t\treturn;\n\t\t}\n\t\tconst requirement = current.requirements.find((candidate) => candidate.id === requirementId);\n\t\tif (!requirement || requirement.status !== \"blocked\") {\n\t\t\thost.showError(\n\t\t\t\trequirement\n\t\t\t\t\t? `Requirement '${requirementId}' is ${requirement.status}; only blocked requirements can be reopened.`\n\t\t\t\t\t: `Unknown requirement '${requirementId}'.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tlet active = current;\n\t\tif (active.status === \"blocked\") {\n\t\t\tconst resumed = resumeGoal(active, now);\n\t\t\tif (!resumed.ok) {\n\t\t\t\thost.showError(resumed.error);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tactive = resumed.state;\n\t\t}\n\t\tconst reopened = applyGoalAction(active, { action: \"reopen_requirement\", requirementId }, now);\n\t\tif (!reopened.ok) {\n\t\t\thost.showError(reopened.error);\n\t\t\treturn;\n\t\t}\n\t\thost.session.saveGoalStateSnapshot(reopened.state, getGoalStateRevision(current));\n\t\tif (reopened.state.status === \"active\") host.session.restoreGoalRuntimeAfterResume();\n\t\thost.showStatus(\n\t\t\t`Requirement '${requirementId}' reopened${current.status === \"blocked\" ? \" and goal resumed\" : \"\"}.`,\n\t\t);\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tconst overriding = input === \"override\" || input.startsWith(\"override \");\n\tconst goalText = overriding ? input.slice(\"override\".length).trim() : input;\n\tif (!goalText) {\n\t\thost.showError(\"Usage: /goal override <text>\");\n\t\treturn;\n\t}\n\tconst goalId = `goal-${randomUUID()}`;\n\tconst started = overriding\n\t\t? replaceGoal({ goalId, userGoal: goalText }, now)\n\t\t: applyGoalAction(current, { action: \"start\", goalId, userGoal: goalText }, now);\n\tif (!started.ok) {\n\t\thost.showError(`${started.error} Use /goal override <text> to replace it explicitly.`);\n\t\treturn;\n\t}\n\thost.session.saveGoalStateSnapshot(started.state, current ? getGoalStateRevision(current) : undefined);\n\tconst verb = overriding ? \"overridden\" : \"started\";\n\ttry {\n\t\t// Submit one bootstrap pass, then yield to the event-driven idle scheduler. This is a scheduling\n\t\t// quantum, not a goal ceiling: an active goal is immediately rearmed and the configured goal turn\n\t\t// limit (unbounded by default) governs subsequent continuation.\n\t\tconst result = await host.session.continueGoalLoop({\n\t\t\tmaxTurns: 1,\n\t\t\tmaxStallTurns: host.getMaxStallTurns?.() ?? 20,\n\t\t\tmaxWallClockMinutes: 0,\n\t\t});\n\t\tif (result.stopReason === \"already_continuing\") {\n\t\t\thost.showStatus(`Goal ${verb}: the autonomy loop is already continuing this goal.`);\n\t\t} else if (result.stopReason === \"session_disposed\") {\n\t\t\thost.showStatus(`Goal ${verb}, but the session was disposed before continuation could run.`);\n\t\t} else {\n\t\t\tconst continuation = result.finalSnapshot.continuation;\n\t\t\thost.showStatus(`Goal ${verb}: ${continuation.action}/${continuation.reasonCode}.`);\n\t\t\tif (continuation.action === \"continue\") host.session.restoreGoalRuntimeAfterResume();\n\t\t}\n\t} catch (error) {\n\t\thost.showError(`Goal continuation failed: ${error instanceof Error ? error.message : String(error)}`);\n\t} finally {\n\t\thost.refreshAutonomyFooterStatus();\n\t}\n}\n\nexport interface TaskCommandHost {\n\treadonly session: {\n\t\tgetTaskStepsStateSnapshot: () => TaskStepsState | undefined;\n\t\tsaveTaskStepsStateSnapshot: (state: TaskStepsState) => string;\n\t};\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n}\n\nexport function handleTaskCommand(host: TaskCommandHost, text: string): void {\n\tconst parsed = parseTaskCommand(text);\n\tif (!parsed.ok) {\n\t\thost.showError(parsed.error);\n\t\treturn;\n\t}\n\tif (parsed.command.type === \"retired_execution\") {\n\t\thost.showStatus(\n\t\t\t`/task ${parsed.command.operation} was retired with the detached extension runner. Ask Pi to use native delegate/delegate_status; session-owned worker lanes notify on completion without polling.`,\n\t\t);\n\t\treturn;\n\t}\n\n\tconst now = new Date().toISOString();\n\tlet state = host.session.getTaskStepsStateSnapshot() ?? createTaskStepsState(now);\n\ttry {\n\t\tswitch (parsed.command.type) {\n\t\t\tcase \"list\":\n\t\t\t\thost.showStatus(formatTaskSteps(state, { includeTerminal: parsed.command.includeTerminal }));\n\t\t\t\treturn;\n\t\t\tcase \"add\":\n\t\t\t\tstate = addTaskStep(state, { content: parsed.command.content }, now);\n\t\t\t\tbreak;\n\t\t\tcase \"update\":\n\t\t\t\tstate = updateTaskStep(\n\t\t\t\t\tstate,\n\t\t\t\t\tparsed.command.selector,\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus: parsed.command.status,\n\t\t\t\t\t\tnote: parsed.command.note,\n\t\t\t\t\t\tevidence: parsed.command.evidence ? [parsed.command.evidence] : undefined,\n\t\t\t\t\t},\n\t\t\t\t\tnow,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"clear\":\n\t\t\t\tstate = clearTaskSteps(state, now);\n\t\t\t\tbreak;\n\t\t\tcase \"compact\":\n\t\t\t\tstate = compactTaskSteps(state, now);\n\t\t\t\tbreak;\n\t\t}\n\t\thost.session.saveTaskStepsStateSnapshot(state);\n\t\thost.showStatus(formatTaskSteps(state));\n\t} catch (error) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t}\n}\n\nexport interface GoalContinueCommandHost {\n\treadonly session: {\n\t\tcontinueGoalLoop: (options: GoalContinuationLoopOptions) => Promise<GoalContinuationLoopResult>;\n\t};\n\tparseGoalContinueCommand(text: string): ParsedGoalContinueCommand;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\trefreshAutonomyFooterStatus(): void;\n}\n\nexport async function handleGoalContinueCommand(host: GoalContinueCommandHost, text: string): Promise<void> {\n\tconst parsed = host.parseGoalContinueCommand(text);\n\tif (!parsed.ok) {\n\t\thost.showError(parsed.error);\n\t\treturn;\n\t}\n\n\thost.showStatus(\n\t\t`Goal continuation started: ${parsed.maxTurns === 0 ? \"unbounded turns\" : `up to ${parsed.maxTurns} turn(s)`}, stall limit ${parsed.maxStallTurns}, wall-clock limit ${parsed.maxWallClockMinutes || \"disabled\"} minute(s).`,\n\t);\n\ttry {\n\t\tconst result = await host.session.continueGoalLoop({\n\t\t\tmaxTurns: parsed.maxTurns,\n\t\t\tmaxStallTurns: parsed.maxStallTurns,\n\t\t\tmaxWallClockMinutes: parsed.maxWallClockMinutes,\n\t\t});\n\t\tconst continuation = result.finalSnapshot.continuation;\n\t\thost.showStatus(\n\t\t\t`Goal continuation stopped: ${result.stopReason}; submitted ${result.turnsSubmitted} turn(s); latest decision ${continuation.action}/${continuation.reasonCode}.`,\n\t\t);\n\t} catch (error) {\n\t\thost.showError(`Goal continuation failed: ${error instanceof Error ? error.message : String(error)}`);\n\t} finally {\n\t\thost.refreshAutonomyFooterStatus();\n\t}\n}\n\nexport interface SessionInfoCommandHost {\n\treadonly session: {\n\t\tgetSessionStats: () => ReturnType<AgentSession[\"getSessionStats\"]>;\n\t\tgetCostSummary: () => ReturnType<AgentSession[\"getCostSummary\"]>;\n\t\tgetModelRouterStatus: (formatLabel: (label: string) => string) => string;\n\t};\n\treadonly sessionManager: { getSessionName: () => string | undefined };\n\treadonly chatContainer: Container;\n\treadonly ui: { requestRender: () => void };\n}\n\nexport function handleSessionCommand(host: SessionInfoCommandHost): void {\n\tconst stats = host.session.getSessionStats();\n\tconst sessionName = host.sessionManager.getSessionName();\n\n\tlet info = `${theme.bold(\"Session Info\")}\\n\\n`;\n\tif (sessionName) {\n\t\tinfo += `${theme.fg(\"dim\", \"Name:\")} ${sessionName}\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"File:\")} ${stats.sessionFile ?? \"In-memory\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"ID:\")} ${stats.sessionId}\\n\\n`;\n\tinfo += `${theme.bold(\"Messages\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"User:\")} ${stats.userMessages}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Assistant:\")} ${stats.assistantMessages}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Tool Calls:\")} ${stats.toolCalls}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Tool Results:\")} ${stats.toolResults}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.totalMessages}\\n\\n`;\n\tinfo += `${theme.bold(\"Tokens\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\tif (stats.tokens.cacheRead > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cache Read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\t}\n\tif (stats.tokens.cacheWrite > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cache Write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n`;\n\n\tconst costs = host.session.getCostSummary();\n\tif (hasCostSummarySignal(costs)) {\n\t\tinfo += `\\n${theme.bold(\"Cost\")}\\n`;\n\t\tinfo += formatCostReport(costs);\n\t}\n\n\tinfo += `\\n\\n${theme.bold(\"Model Router\")}\\n`;\n\tinfo += host.session.getModelRouterStatus((label) => theme.fg(\"dim\", label));\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(info, 1, 0));\n\thost.ui.requestRender();\n}\n"]}
1
+ {"version":3,"file":"session-flow-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/session-flow-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MA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AAI,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,IAAI,CAAC;IAC5F,CAAC;IACD,IAAI,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC;IAEhF,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;IAC5C,IAAI,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACpC,IAAI,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;IAC9C,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAE7E,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AACzB,CAAC","sourcesContent":["/**\n * Session-picker, tree/fork navigation, and model-selector flows extracted from\n * interactive-mode.\n *\n * Each entry opens a selector overlay (via `host.showSelector`) or renders a\n * session-info block, driving `AgentSession`/`AgentSessionRuntime` navigation and\n * the fork/resume/clone/goal-continuation paths. The interdependent selector\n * flows share one narrow `SessionFlowHost` seam; the three prototype-tested leaf\n * commands (`handleCloneCommand`, `handleGoalContinueCommand`,\n * `handleSessionCommand`) take their own minimal host shapes so their behaviour\n * tests keep exercising them through interactive-mode's thin wrappers unchanged.\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { Api, Model } from \"@caupulican/pi-ai\";\nimport type { EditorComponent } from \"@caupulican/pi-tui\";\nimport { type Component, type Container, Loader, Spacer, Text, type TUI } from \"@caupulican/pi-tui\";\nimport type {\n\tAgentSession,\n\tGoalContinuationLoopOptions,\n\tGoalContinuationLoopResult,\n} from \"../../core/agent-session.ts\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport { hasCostSummarySignal } from \"../../core/cost/cost-summary.ts\";\nimport type { ExtensionCommandContext } from \"../../core/extensions/index.ts\";\nimport {\n\tcancelPersistedGoal,\n\tclearPersistedGoal,\n\teditPersistedGoal,\n\ttype GoalStateRevision,\n\tgetGoalStateRevision,\n\tpausePersistedGoal,\n\treplaceGoal,\n\tresumeGoal,\n\tresumePersistedGoal,\n} from \"../../core/goals/goal-lifecycle.ts\";\nimport type { GoalState } from \"../../core/goals/goal-state.ts\";\nimport { applyGoalAction, completeGoalManually } from \"../../core/goals/goal-tool-core.ts\";\nimport type { KeybindingsManager } from \"../../core/keybindings.ts\";\nimport {\n\tfindExactModelReferenceMatch,\n\tresolveModelScope,\n\tresolveModelScopeWithDiagnostics,\n} from \"../../core/model-resolver.ts\";\nimport { MissingSessionCwdError } from \"../../core/session-cwd.ts\";\nimport { listAllSessions, listSessions, openSession } from \"../../core/session-manager-factory.ts\";\nimport type { SettingsManager } from \"../../core/settings-manager.ts\";\nimport { parseTaskCommand } from \"../../core/tasks/task-command.ts\";\nimport {\n\taddTaskStep,\n\tclearTaskSteps,\n\tcompactTaskSteps,\n\tcreateTaskStepsState,\n\tformatTaskSteps,\n\ttype TaskStepsState,\n\tupdateTaskStep,\n} from \"../../core/tasks/task-state.ts\";\nimport { ProjectTrustStore } from \"../../core/trust-manager.ts\";\nimport type { CustomEditor } from \"./components/custom-editor.ts\";\nimport type { FooterComponent } from \"./components/footer.ts\";\nimport { keyText } from \"./components/keybinding-hints.ts\";\nimport { ModelSelectorComponent } from \"./components/model-selector.ts\";\nimport { ScopedModelsSelectorComponent } from \"./components/scoped-models-selector.ts\";\nimport { SessionSelectorComponent } from \"./components/session-selector.ts\";\nimport { TreeSelectorComponent } from \"./components/tree-selector.ts\";\nimport { TrustSelectorComponent } from \"./components/trust-selector.ts\";\nimport { UserMessageSelectorComponent } from \"./components/user-message-selector.ts\";\nimport type { ExtensionUiHost } from \"./extension-ui-host.ts\";\nimport { formatCostReport } from \"./report-commands.ts\";\nimport { handleNonFatalSessionReplacementError } from \"./session-replacement-errors.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\n/** Shared seam for the interdependent selector/navigation flows. */\nexport interface SessionFlowHost {\n\treadonly session: AgentSession;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n\treadonly runtimeHost: AgentSessionRuntime;\n\treadonly ui: TUI;\n\treadonly chatContainer: Container;\n\treadonly statusContainer: Container;\n\treadonly editor: EditorComponent;\n\treadonly defaultEditor: CustomEditor;\n\treadonly footer: FooterComponent;\n\treadonly extensionUiHost: ExtensionUiHost;\n\treadonly keybindings: KeybindingsManager;\n\tloadingAnimation: Loader | undefined;\n\tshowSelector(create: (done: () => void) => { component: Component; focus: Component }): void;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\trefreshAutonomyFooterStatus(): void;\n\trenderCurrentSessionState(): void;\n\trenderInitialMessages(options?: { forceHistoryLoad?: boolean }): Promise<void>;\n\tflushCompactionQueue(options?: { willRetry?: boolean }): Promise<void>;\n\thandleFatalRuntimeError(prefix: string, error: unknown): Promise<never>;\n\tpromptForMissingSessionCwd(error: MissingSessionCwdError): Promise<string | undefined>;\n\tupdateEditorBorderColor(): void;\n\tupdateAvailableProviderCount(): Promise<void>;\n\tmaybeWarnAboutAnthropicSubscriptionAuth(model?: Model<Api>): Promise<void>;\n\tcheckDaxnutsEasterEgg(model: { provider: string; id: string }): void;\n\tgetModelCandidates(): Promise<Model<Api>[]>;\n\tshutdown(options?: { fromSignal?: boolean }): Promise<void>;\n}\n\nfunction finishSelectorCancellation(host: Pick<SessionFlowHost, \"ui\">, done: () => void): void {\n\tdone();\n\thost.ui.requestRender();\n}\n\nfunction finishSelectorError(host: Pick<SessionFlowHost, \"showError\">, done: () => void, error: unknown): void {\n\tdone();\n\thost.showError(error instanceof Error ? error.message : String(error));\n}\n\nexport async function showModelSelector(host: SessionFlowHost, initialSearchInput?: string): Promise<void> {\n\ttry {\n\t\tawait host.session.extensionRunner.emit({\n\t\t\ttype: \"model_selector_open\",\n\t\t\tcurrentModel: host.session.model,\n\t\t\tscopedModels: host.session.scopedModels,\n\t\t\tinitialSearchInput,\n\t\t});\n\t} catch (error) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t\treturn;\n\t}\n\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\ttry {\n\t\t\t\t\tawait host.session.setModel(model);\n\t\t\t\t\thost.footer.invalidate();\n\t\t\t\t\thost.updateEditorBorderColor();\n\t\t\t\t\tdone();\n\t\t\t\t\thost.showStatus(`Model: ${model.id}`);\n\t\t\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth(model);\n\t\t\t\t\thost.checkDaxnutsEasterEgg(model);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfinishSelectorError(host, done, error);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t},\n\t\t\tinitialSearchInput,\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function showModelsSelector(host: SessionFlowHost): Promise<void> {\n\t// Get all available models\n\thost.session.modelRegistry.refresh();\n\tconst allModels = host.session.modelRegistry.getAvailable();\n\tconst allModelIds = new Set(allModels.map((model) => `${model.provider}/${model.id}`));\n\tconst configuredPatterns = host.settingsManager.getEnabledModels();\n\tconst sessionScopedModels = host.session.scopedModels;\n\n\tif (allModels.length === 0 && !configuredPatterns?.length && sessionScopedModels.length === 0) {\n\t\thost.showStatus(\"No models available\");\n\t\treturn;\n\t}\n\tconst configuredScope = configuredPatterns?.length\n\t\t? await resolveModelScopeWithDiagnostics(configuredPatterns, host.session.modelRegistry)\n\t\t: undefined;\n\n\t// Check if session has scoped models (from previous session-only changes or CLI --models)\n\tconst hasSessionScope = sessionScopedModels.length > 0;\n\n\t// Build enabled model IDs from session state or settings\n\tlet currentEnabledIds: string[] | null = null;\n\n\tif (hasSessionScope) {\n\t\t// Use current session's scoped models\n\t\tcurrentEnabledIds = sessionScopedModels.map((scoped) => `${scoped.model.provider}/${scoped.model.id}`);\n\t} else if (configuredScope) {\n\t\tcurrentEnabledIds = configuredScope.scopedModels.map((scoped) => `${scoped.model.provider}/${scoped.model.id}`);\n\t}\n\n\tfor (const diagnostic of configuredScope?.diagnostics ?? []) {\n\t\tif (diagnostic.code !== \"no-match\") continue;\n\t\tcurrentEnabledIds ??= [];\n\t\tif (!currentEnabledIds.includes(diagnostic.pattern)) currentEnabledIds.push(diagnostic.pattern);\n\t}\n\n\t// Helper to update session's scoped models (session-only, no persist)\n\tconst updateSessionModels = async (enabledIds: string[] | null) => {\n\t\tcurrentEnabledIds = enabledIds === null ? null : [...enabledIds];\n\t\tconst hasEnabledAvailableModel = enabledIds?.some((id) => allModelIds.has(id)) ?? false;\n\t\tconst allAvailableModelsEnabled = enabledIds !== null && [...allModelIds].every((id) => enabledIds.includes(id));\n\t\tif (enabledIds && hasEnabledAvailableModel && !allAvailableModelsEnabled) {\n\t\t\tconst newScopedModels = await resolveModelScope(enabledIds, host.session.modelRegistry);\n\t\t\thost.session.setScopedModels(\n\t\t\t\tnewScopedModels.map((sm) => ({\n\t\t\t\t\tmodel: sm.model,\n\t\t\t\t\tthinkingLevel: sm.thinkingLevel,\n\t\t\t\t})),\n\t\t\t);\n\t\t} else {\n\t\t\t// All enabled or none enabled = no filter\n\t\t\thost.session.setScopedModels([]);\n\t\t}\n\t\tawait host.updateAvailableProviderCount();\n\t\thost.ui.requestRender();\n\t};\n\n\thost.showSelector((done) => {\n\t\tconst selector = new ScopedModelsSelectorComponent(\n\t\t\t{\n\t\t\t\tallModels,\n\t\t\t\tenabledModelIds: currentEnabledIds,\n\t\t\t},\n\t\t\t{\n\t\t\t\tonChange: async (enabledIds) => {\n\t\t\t\t\tawait updateSessionModels(enabledIds);\n\t\t\t\t},\n\t\t\t\tonPersist: (enabledIds) => {\n\t\t\t\t\t// Persist to settings\n\t\t\t\t\tconst allEnabled =\n\t\t\t\t\t\tenabledIds !== null &&\n\t\t\t\t\t\tenabledIds.length === allModels.length &&\n\t\t\t\t\t\tenabledIds.every((id) => allModelIds.has(id));\n\t\t\t\t\tconst newPatterns = enabledIds === null || allEnabled ? undefined : enabledIds;\n\t\t\t\t\thost.settingsManager.setEnabledModels(newPatterns ? [...newPatterns] : undefined);\n\t\t\t\t\thost.showStatus(\"Model selection saved to settings\");\n\t\t\t\t},\n\t\t\t\tonCancel: () => {\n\t\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showUserMessageSelector(host: SessionFlowHost, newSessionName?: string): void {\n\tconst userMessages = host.session.getUserMessagesForForking();\n\n\tif (userMessages.length === 0) {\n\t\thost.showStatus(\"No messages to fork from\");\n\t\treturn;\n\t}\n\n\tconst initialSelectedId = userMessages[userMessages.length - 1]?.entryId;\n\n\thost.showSelector((done) => {\n\t\tconst selector = new UserMessageSelectorComponent(\n\t\t\tuserMessages.map((m) => ({ id: m.entryId, text: m.text })),\n\t\t\tasync (entryId) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await host.runtimeHost.fork(entryId);\n\t\t\t\t\tif (result.cancelled) {\n\t\t\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thost.renderCurrentSessionState();\n\t\t\t\t\tif (newSessionName) {\n\t\t\t\t\t\thost.session.setSessionName(newSessionName);\n\t\t\t\t\t}\n\t\t\t\t\thost.editor.setText(result.selectedText ?? \"\");\n\t\t\t\t\tdone();\n\t\t\t\t\thost.showStatus(newSessionName ? `Forked to new session: ${newSessionName}` : \"Forked to new session\");\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tfinishSelectorError(host, done, error);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t},\n\t\t\tinitialSelectedId,\n\t\t);\n\t\treturn { component: selector, focus: selector.getMessageList() };\n\t});\n}\n\nexport function showTreeSelector(host: SessionFlowHost, initialSelectedId?: string): void {\n\tconst tree = host.sessionManager.getTree();\n\tconst realLeafId = host.sessionManager.getLeafId();\n\tconst initialFilterMode = host.settingsManager.getTreeFilterMode();\n\n\tif (tree.length === 0) {\n\t\thost.showStatus(\"No entries in session\");\n\t\treturn;\n\t}\n\n\thost.showSelector((done) => {\n\t\tconst selector = new TreeSelectorComponent(\n\t\t\ttree,\n\t\t\trealLeafId,\n\t\t\thost.ui.terminal.rows,\n\t\t\tasync (entryId) => {\n\t\t\t\t// Selecting the current leaf is a no-op (already there)\n\t\t\t\tif (entryId === realLeafId) {\n\t\t\t\t\tdone();\n\t\t\t\t\thost.showStatus(\"Already at this point\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Ask about summarization\n\t\t\t\tdone(); // Close selector first\n\n\t\t\t\t// Loop until user makes a complete choice or cancels to tree\n\t\t\t\tlet wantsSummary = false;\n\t\t\t\tlet customInstructions: string | undefined;\n\n\t\t\t\t// Check if we should skip the prompt (user preference to always default to no summary)\n\t\t\t\tif (!host.settingsManager.getBranchSummarySkipPrompt()) {\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst summaryChoice = await host.extensionUiHost.showExtensionSelector(\"Summarize branch?\", [\n\t\t\t\t\t\t\t\"No summary\",\n\t\t\t\t\t\t\t\"Summarize\",\n\t\t\t\t\t\t\t\"Summarize with custom prompt\",\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tif (summaryChoice === undefined) {\n\t\t\t\t\t\t\t// User pressed escape - re-show tree selector with same selection\n\t\t\t\t\t\t\tshowTreeSelector(host, entryId);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\twantsSummary = summaryChoice !== \"No summary\";\n\n\t\t\t\t\t\tif (summaryChoice === \"Summarize with custom prompt\") {\n\t\t\t\t\t\t\tcustomInstructions = await host.extensionUiHost.showExtensionEditor(\n\t\t\t\t\t\t\t\t\"Custom summarization instructions\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (customInstructions === undefined) {\n\t\t\t\t\t\t\t\t// User cancelled - loop back to summary selector\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// User made a complete choice\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Set up escape handler and loader if summarizing\n\t\t\t\tlet summaryLoader: Loader | undefined;\n\t\t\t\tconst originalOnEscape = host.defaultEditor.onEscape;\n\n\t\t\t\tif (wantsSummary) {\n\t\t\t\t\thost.defaultEditor.onEscape = () => {\n\t\t\t\t\t\thost.session.abortBranchSummary();\n\t\t\t\t\t};\n\t\t\t\t\thost.chatContainer.addChild(new Spacer(1));\n\t\t\t\t\tsummaryLoader = new Loader(\n\t\t\t\t\t\thost.ui,\n\t\t\t\t\t\t(spinner) => theme.fg(\"accent\", spinner),\n\t\t\t\t\t\t(text) => theme.fg(\"muted\", text),\n\t\t\t\t\t\t`Summarizing branch... (${keyText(\"app.interrupt\")} to cancel)`,\n\t\t\t\t\t);\n\t\t\t\t\thost.statusContainer.addChild(summaryLoader);\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await host.session.navigateTree(entryId, {\n\t\t\t\t\t\tsummarize: wantsSummary,\n\t\t\t\t\t\tcustomInstructions,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (result.aborted) {\n\t\t\t\t\t\t// Summarization aborted - re-show tree selector with same selection\n\t\t\t\t\t\thost.showStatus(\"Branch summarization cancelled\");\n\t\t\t\t\t\tshowTreeSelector(host, entryId);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (result.cancelled) {\n\t\t\t\t\t\thost.showStatus(\"Navigation cancelled\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update UI\n\t\t\t\t\tawait host.renderInitialMessages();\n\t\t\t\t\tif (result.editorText && !host.editor.getText().trim()) {\n\t\t\t\t\t\thost.editor.setText(result.editorText);\n\t\t\t\t\t}\n\t\t\t\t\thost.showStatus(\"Navigated to selected point\");\n\t\t\t\t\tvoid host.flushCompactionQueue({ willRetry: false });\n\t\t\t\t} catch (error) {\n\t\t\t\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t\t\t\t} finally {\n\t\t\t\t\tif (summaryLoader) {\n\t\t\t\t\t\tsummaryLoader.stop();\n\t\t\t\t\t\thost.statusContainer.clear();\n\t\t\t\t\t}\n\t\t\t\t\thost.defaultEditor.onEscape = originalOnEscape;\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t},\n\t\t\t(entryId, label) => {\n\t\t\t\thost.sessionManager.appendLabelChange(entryId, label);\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t\tinitialSelectedId,\n\t\t\tinitialFilterMode,\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showTrustSelector(host: SessionFlowHost): void {\n\tconst cwd = host.sessionManager.getCwd();\n\tconst trustStore = new ProjectTrustStore(host.runtimeHost.services.agentDir);\n\tconst savedDecision = trustStore.get(cwd);\n\thost.showSelector((done) => {\n\t\tconst selector = new TrustSelectorComponent({\n\t\t\tcwd,\n\t\t\tsavedDecision,\n\t\t\tprojectTrusted: host.settingsManager.isProjectTrusted(),\n\t\t\tonSelect: (trusted) => {\n\t\t\t\ttrustStore.set(cwd, trusted);\n\t\t\t\tdone();\n\t\t\t\thost.showStatus(\n\t\t\t\t\t`Saved trust decision: ${trusted ? \"trusted\" : \"untrusted\"}. Restart pi for this to take effect.`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tonCancel: () => {\n\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t},\n\t\t});\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showSessionSelector(host: SessionFlowHost): void {\n\thost.showSelector((done) => {\n\t\tconst selector = new SessionSelectorComponent(\n\t\t\t(onProgress) => listSessions(host.sessionManager.getCwd(), host.sessionManager.getSessionDir(), onProgress),\n\t\t\t(onProgress) =>\n\t\t\t\thost.sessionManager.usesDefaultSessionDir()\n\t\t\t\t\t? listAllSessions(onProgress)\n\t\t\t\t\t: listAllSessions(host.sessionManager.getSessionDir(), onProgress),\n\t\t\tasync (sessionPath) => {\n\t\t\t\tdone();\n\t\t\t\tawait handleResumeSession(host, sessionPath);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tfinishSelectorCancellation(host, done);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tvoid host.shutdown();\n\t\t\t},\n\t\t\t() => host.ui.requestRender(),\n\t\t\t{\n\t\t\t\trenameSession: async (sessionFilePath: string, nextName: string | undefined) => {\n\t\t\t\t\tconst next = (nextName ?? \"\").trim();\n\t\t\t\t\tif (!next) return;\n\t\t\t\t\tconst mgr = openSession(sessionFilePath);\n\t\t\t\t\tmgr.appendSessionInfo(next);\n\t\t\t\t},\n\t\t\t\tshowRenameHint: true,\n\t\t\t\tkeybindings: host.keybindings,\n\t\t\t},\n\n\t\t\thost.sessionManager.getSessionFile(),\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nasync function switchSession(\n\thost: SessionFlowHost,\n\tsessionPath: string,\n\toptions: Parameters<ExtensionCommandContext[\"switchSession\"]>[1] | undefined,\n\tcwdOverride?: string,\n): Promise<{ cancelled: boolean }> {\n\treturn host.runtimeHost.switchSession(sessionPath, {\n\t\tcwdOverride,\n\t\twithSession: options?.withSession,\n\t});\n}\n\nasync function offerRestoredGoalResume(host: SessionFlowHost): Promise<boolean> {\n\tconst state = host.session.getGoalStateSnapshot();\n\tif (!state || (state.status !== \"paused\" && state.status !== \"blocked\" && state.status !== \"usage_limited\")) {\n\t\thost.session.restoreGoalRuntimeAfterResume();\n\t\treturn false;\n\t}\n\tconst choice = await host.extensionUiHost?.showExtensionSelector(\"Resume stopped goal?\", [\n\t\t\"Resume goal\",\n\t\t\"Leave stopped\",\n\t]);\n\tif (choice !== \"Resume goal\") return false;\n\tconst resumed = resumePersistedGoal(host.session);\n\tif (!resumed.ok) throw new Error(`Goal resume failed: ${resumed.error}`);\n\thost.session.restoreGoalRuntimeAfterResume();\n\thost.refreshAutonomyFooterStatus();\n\treturn true;\n}\n\nexport async function handleResumeSession(\n\thost: SessionFlowHost,\n\tsessionPath: string,\n\toptions?: Parameters<ExtensionCommandContext[\"switchSession\"]>[1],\n): Promise<{ cancelled: boolean }> {\n\tif (host.loadingAnimation) {\n\t\thost.loadingAnimation.stop();\n\t\thost.loadingAnimation = undefined;\n\t}\n\thost.statusContainer.clear();\n\ttry {\n\t\tconst result = await switchSession(host, sessionPath, options);\n\t\tif (result.cancelled) {\n\t\t\treturn result;\n\t\t}\n\t\thost.renderCurrentSessionState();\n\t\tconst goalResumed = await offerRestoredGoalResume(host);\n\t\thost.showStatus(goalResumed ? \"Resumed session and goal\" : \"Resumed session; goal state preserved\");\n\t\treturn result;\n\t} catch (error: unknown) {\n\t\tconst disposition = handleNonFatalSessionReplacementError(host, error);\n\t\tif (disposition) return { cancelled: disposition === \"previous_restored\" };\n\t\tif (error instanceof MissingSessionCwdError) {\n\t\t\tconst selectedCwd = await host.promptForMissingSessionCwd(error);\n\t\t\tif (!selectedCwd) {\n\t\t\t\thost.showStatus(\"Resume cancelled\");\n\t\t\t\treturn { cancelled: true };\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst result = await switchSession(host, sessionPath, options, selectedCwd);\n\t\t\t\tif (result.cancelled) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\thost.renderCurrentSessionState();\n\t\t\t\tconst goalResumed = await offerRestoredGoalResume(host);\n\t\t\t\thost.showStatus(\n\t\t\t\t\tgoalResumed\n\t\t\t\t\t\t? \"Resumed session and goal in current cwd\"\n\t\t\t\t\t\t: \"Resumed session in current cwd; goal state preserved\",\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t} catch (retryError: unknown) {\n\t\t\t\tconst retryDisposition = handleNonFatalSessionReplacementError(host, retryError);\n\t\t\t\tif (retryDisposition) return { cancelled: retryDisposition === \"previous_restored\" };\n\t\t\t\treturn host.handleFatalRuntimeError(\"Failed to resume session\", retryError);\n\t\t\t}\n\t\t}\n\t\treturn host.handleFatalRuntimeError(\"Failed to resume session\", error);\n\t}\n}\n\nexport async function handleModelCommand(host: SessionFlowHost, searchTerm?: string): Promise<void> {\n\tif (!searchTerm) {\n\t\tawait showModelSelector(host);\n\t\treturn;\n\t}\n\n\tconst model = await findExactModelMatch(host, searchTerm);\n\tif (model) {\n\t\ttry {\n\t\t\tawait host.session.setModel(model);\n\t\t\thost.footer.invalidate();\n\t\t\thost.updateEditorBorderColor();\n\t\t\thost.showStatus(`Model: ${model.id}`);\n\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth(model);\n\t\t\thost.checkDaxnutsEasterEgg(model);\n\t\t} catch (error) {\n\t\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t\t}\n\t\treturn;\n\t}\n\n\tawait showModelSelector(host, searchTerm);\n}\n\nexport async function findExactModelMatch(host: SessionFlowHost, searchTerm: string): Promise<Model<Api> | undefined> {\n\tconst models = await host.getModelCandidates();\n\treturn findExactModelReferenceMatch(searchTerm, models);\n}\n\n// ===========================================================================\n// Prototype-tested leaf commands — narrow host shapes matching their fakes.\n// ===========================================================================\n\nexport interface CloneCommandHost {\n\treadonly sessionManager: { getLeafId: () => string | null };\n\treadonly runtimeHost: {\n\t\tfork: (entryId: string, options?: { position?: \"before\" | \"at\" }) => Promise<{ cancelled: boolean }>;\n\t};\n\trenderCurrentSessionState(): void;\n\treadonly editor: { setText: (text: string) => void };\n\treadonly session: { setSessionName: (name: string) => void };\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\treadonly ui: { requestRender: () => void };\n}\n\nexport async function handleCloneCommand(host: CloneCommandHost, newSessionName?: string): Promise<void> {\n\tconst leafId = host.sessionManager.getLeafId();\n\tif (!leafId) {\n\t\thost.showStatus(\"Nothing to clone yet\");\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst result = await host.runtimeHost.fork(leafId, { position: \"at\" });\n\t\tif (result.cancelled) {\n\t\t\thost.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\thost.renderCurrentSessionState();\n\t\tif (newSessionName) {\n\t\t\thost.session.setSessionName(newSessionName);\n\t\t}\n\t\thost.editor.setText(\"\");\n\t\thost.showStatus(newSessionName ? `Cloned to new session: ${newSessionName}` : \"Cloned to new session\");\n\t} catch (error: unknown) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t}\n}\n\nexport type ParsedGoalContinueCommand =\n\t| { ok: true; maxTurns: number; maxStallTurns: number; maxWallClockMinutes: number }\n\t| { ok: false; error: string };\n\nexport interface GoalResumeHost {\n\treadonly session: {\n\t\tgetGoalStateSnapshot: () => GoalState | undefined;\n\t\tsaveGoalStateSnapshot: (state: GoalState, expected?: GoalStateRevision) => string;\n\t\tclearGoalStateSnapshot?: (state: GoalState, now: string) => string;\n\t\trestoreGoalRuntimeAfterResume: () => void;\n\t};\n\trefreshAutonomyFooterStatus(): void;\n}\n\nexport interface GoalCommandHost extends GoalResumeHost {\n\treadonly session: GoalResumeHost[\"session\"] & {\n\t\tcontinueGoalLoop: (options: GoalContinuationLoopOptions) => Promise<GoalContinuationLoopResult>;\n\t\tgetGoalRuntimeSnapshot: (settings: {\n\t\t\tmaxStallTurns: number;\n\t\t}) => ReturnType<AgentSession[\"getGoalRuntimeSnapshot\"]>;\n\t};\n\tpromptForGoalEdit?(currentObjective: string): Promise<string | undefined>;\n\tgetMaxStallTurns?(): number;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n}\n\nexport type GoalResumeResult = { ok: true; resumed: true; state: GoalState } | { ok: false; error: string };\n\n/** Canonical persisted transition used by both `/goal resume` and session `/resume`. */\nexport function resumeCurrentGoal(host: GoalResumeHost, now = new Date().toISOString()): GoalResumeResult {\n\tconst resumed = resumePersistedGoal(host.session, now);\n\tif (!resumed.ok) return resumed;\n\thost.session.restoreGoalRuntimeAfterResume();\n\thost.refreshAutonomyFooterStatus();\n\treturn { ok: true, resumed: true, state: resumed.state };\n}\n\nfunction formatGoalStatus(snapshot: ReturnType<AgentSession[\"getGoalRuntimeSnapshot\"]>): string {\n\tconst state = snapshot.goalState;\n\tif (!state) return `Goal: none (${snapshot.continuation.action}/${snapshot.continuation.reasonCode})`;\n\tconst requirements = state.requirements.map((requirement) => {\n\t\tconst blockedReason = requirement.blockedReason ? ` — ${requirement.blockedReason}` : \"\";\n\t\treturn `- ${requirement.id}: ${requirement.status}${blockedReason}`;\n\t});\n\tconst blockedReason = state.blockedReason ? `\\nBlocked reason: ${state.blockedReason}` : \"\";\n\tconst requirementDetails = requirements.length > 0 ? `\\n${requirements.join(\"\\n\")}` : \"\";\n\tconst tokenUsage =\n\t\tstate.tokenBudget !== undefined\n\t\t\t? `\\nTokens: ${state.tokensUsed ?? 0}/${state.tokenBudget}`\n\t\t\t: (state.tokensUsed ?? 0) > 0\n\t\t\t\t? `\\nTokens: ${state.tokensUsed ?? 0}`\n\t\t\t\t: \"\";\n\treturn `Goal: ${state.userGoal}\\nStatus: ${state.status}${blockedReason}${tokenUsage}\\nRequirements: open ${snapshot.continuation.openRequirementIds.length}, blocked ${snapshot.continuation.blockedRequirementIds.length}, satisfied ${snapshot.continuation.satisfiedRequirementIds.length}${requirementDetails}\\nContinuation: ${snapshot.continuation.action}/${snapshot.continuation.reasonCode}\\nControls: /goal edit | /goal pause | /goal resume | /goal reopen <requirement-id> | /goal complete | /goal clear | /goal override <text>`;\n}\n\nexport async function handleGoalCommand(host: GoalCommandHost, text: string): Promise<void> {\n\tconst input = text.replace(/^\\/goal\\s*/, \"\").trim();\n\tif (!input || input === \"status\") {\n\t\thost.showStatus(\n\t\t\tformatGoalStatus(host.session.getGoalRuntimeSnapshot({ maxStallTurns: host.getMaxStallTurns?.() ?? 20 })),\n\t\t);\n\t\treturn;\n\t}\n\n\tconst now = new Date().toISOString();\n\tconst current = host.session.getGoalStateSnapshot();\n\tif (input === \"resume\") {\n\t\tconst resumed = resumeCurrentGoal(host, now);\n\t\tif (!resumed.ok) {\n\t\t\thost.showError(resumed.error);\n\t\t\treturn;\n\t\t}\n\t\thost.showStatus(\"Goal resumed.\");\n\t\treturn;\n\t}\n\n\tif (input === \"pause\") {\n\t\tconst paused = pausePersistedGoal(host.session, now);\n\t\tif (!paused.ok) {\n\t\t\thost.showError(paused.error);\n\t\t\treturn;\n\t\t}\n\t\thost.showStatus(\"Goal paused.\");\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tif (input === \"edit\" || input.startsWith(\"edit \")) {\n\t\tconst inlineObjective = input.slice(\"edit\".length).trim();\n\t\tconst objective = inlineObjective || (current ? await host.promptForGoalEdit?.(current.userGoal) : undefined);\n\t\tif (!objective) {\n\t\t\thost.showError(current ? \"Usage: /goal edit <objective>\" : \"No goal exists to edit.\");\n\t\t\treturn;\n\t\t}\n\t\tconst edited = editPersistedGoal(host.session, { userGoal: objective }, now);\n\t\tif (!edited.ok) {\n\t\t\thost.showError(edited.error);\n\t\t\treturn;\n\t\t}\n\t\tif (edited.state.status === \"active\") host.session.restoreGoalRuntimeAfterResume();\n\t\thost.showStatus(\"Goal updated.\");\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tif (input === \"complete\") {\n\t\tconst completed = completeGoalManually(current, now);\n\t\tif (!completed.ok) {\n\t\t\thost.showError(completed.error);\n\t\t\treturn;\n\t\t}\n\t\thost.session.saveGoalStateSnapshot(completed.state, current ? getGoalStateRevision(current) : undefined);\n\t\thost.showStatus(\"Goal completed manually.\");\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tif (input === \"clear\") {\n\t\tconst cleared = clearPersistedGoal(host.session, now);\n\t\tif (!cleared.ok) {\n\t\t\thost.showError(cleared.error);\n\t\t\treturn;\n\t\t}\n\t\thost.showStatus(cleared.cleared ? \"Goal cleared.\" : \"No goal exists to clear.\");\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tif (input === \"close\" || input === \"cancel\") {\n\t\tconst cancelled = cancelPersistedGoal(host.session, now);\n\t\tif (!cancelled.ok) {\n\t\t\thost.showError(cancelled.error);\n\t\t\treturn;\n\t\t}\n\t\thost.showStatus(\"Goal closed.\");\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tif (input === \"reopen\" || input.startsWith(\"reopen \")) {\n\t\tconst requirementId = input.slice(\"reopen\".length).trim();\n\t\tif (!requirementId) {\n\t\t\thost.showError(\"Usage: /goal reopen <requirement-id>\");\n\t\t\treturn;\n\t\t}\n\t\tif (!current) {\n\t\t\thost.showError(\"No goal exists to update.\");\n\t\t\treturn;\n\t\t}\n\t\tconst requirement = current.requirements.find((candidate) => candidate.id === requirementId);\n\t\tif (!requirement || requirement.status !== \"blocked\") {\n\t\t\thost.showError(\n\t\t\t\trequirement\n\t\t\t\t\t? `Requirement '${requirementId}' is ${requirement.status}; only blocked requirements can be reopened.`\n\t\t\t\t\t: `Unknown requirement '${requirementId}'.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tlet active = current;\n\t\tif (active.status === \"blocked\") {\n\t\t\tconst resumed = resumeGoal(active, now);\n\t\t\tif (!resumed.ok) {\n\t\t\t\thost.showError(resumed.error);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tactive = resumed.state;\n\t\t}\n\t\tconst reopened = applyGoalAction(active, { action: \"reopen_requirement\", requirementId }, now);\n\t\tif (!reopened.ok) {\n\t\t\thost.showError(reopened.error);\n\t\t\treturn;\n\t\t}\n\t\thost.session.saveGoalStateSnapshot(reopened.state, getGoalStateRevision(current));\n\t\tif (reopened.state.status === \"active\") host.session.restoreGoalRuntimeAfterResume();\n\t\thost.showStatus(\n\t\t\t`Requirement '${requirementId}' reopened${current.status === \"blocked\" ? \" and goal resumed\" : \"\"}.`,\n\t\t);\n\t\thost.refreshAutonomyFooterStatus();\n\t\treturn;\n\t}\n\n\tconst overriding = input === \"override\" || input.startsWith(\"override \");\n\tconst goalText = overriding ? input.slice(\"override\".length).trim() : input;\n\tif (!goalText) {\n\t\thost.showError(\"Usage: /goal override <text>\");\n\t\treturn;\n\t}\n\tconst goalId = `goal-${randomUUID()}`;\n\tconst started = overriding\n\t\t? replaceGoal({ goalId, userGoal: goalText }, now)\n\t\t: applyGoalAction(current, { action: \"start\", goalId, userGoal: goalText }, now);\n\tif (!started.ok) {\n\t\thost.showError(`${started.error} Use /goal override <text> to replace it explicitly.`);\n\t\treturn;\n\t}\n\thost.session.saveGoalStateSnapshot(started.state, current ? getGoalStateRevision(current) : undefined);\n\tconst verb = overriding ? \"overridden\" : \"started\";\n\ttry {\n\t\t// Submit one bootstrap pass, then yield to the event-driven idle scheduler. This is a scheduling\n\t\t// quantum, not a goal ceiling: an active goal is immediately rearmed and the configured goal turn\n\t\t// limit (unbounded by default) governs subsequent continuation.\n\t\tconst result = await host.session.continueGoalLoop({\n\t\t\tmaxTurns: 1,\n\t\t\tmaxStallTurns: host.getMaxStallTurns?.() ?? 20,\n\t\t\tmaxWallClockMinutes: 0,\n\t\t});\n\t\tif (result.stopReason === \"already_continuing\") {\n\t\t\thost.showStatus(`Goal ${verb}: the autonomy loop is already continuing this goal.`);\n\t\t} else if (result.stopReason === \"session_disposed\") {\n\t\t\thost.showStatus(`Goal ${verb}, but the session was disposed before continuation could run.`);\n\t\t} else {\n\t\t\tconst continuation = result.finalSnapshot.continuation;\n\t\t\thost.showStatus(`Goal ${verb}: ${continuation.action}/${continuation.reasonCode}.`);\n\t\t\tif (continuation.action === \"continue\") host.session.restoreGoalRuntimeAfterResume();\n\t\t}\n\t} catch (error) {\n\t\thost.showError(`Goal continuation failed: ${error instanceof Error ? error.message : String(error)}`);\n\t} finally {\n\t\thost.refreshAutonomyFooterStatus();\n\t}\n}\n\nexport interface TaskCommandHost {\n\treadonly session: {\n\t\tgetTaskStepsStateSnapshot: () => TaskStepsState | undefined;\n\t\tsaveTaskStepsStateSnapshot: (state: TaskStepsState) => string;\n\t};\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n}\n\nexport function handleTaskCommand(host: TaskCommandHost, text: string): void {\n\tconst parsed = parseTaskCommand(text);\n\tif (!parsed.ok) {\n\t\thost.showError(parsed.error);\n\t\treturn;\n\t}\n\tif (parsed.command.type === \"retired_execution\") {\n\t\thost.showStatus(\n\t\t\t`/task ${parsed.command.operation} was retired with the detached extension runner. Ask Pi to use native delegate; session-owned worker lanes notify on completion without polling.`,\n\t\t);\n\t\treturn;\n\t}\n\n\tconst now = new Date().toISOString();\n\tlet state = host.session.getTaskStepsStateSnapshot() ?? createTaskStepsState(now);\n\ttry {\n\t\tswitch (parsed.command.type) {\n\t\t\tcase \"list\":\n\t\t\t\thost.showStatus(formatTaskSteps(state, { includeTerminal: parsed.command.includeTerminal }));\n\t\t\t\treturn;\n\t\t\tcase \"add\":\n\t\t\t\tstate = addTaskStep(state, { content: parsed.command.content }, now);\n\t\t\t\tbreak;\n\t\t\tcase \"update\":\n\t\t\t\tstate = updateTaskStep(\n\t\t\t\t\tstate,\n\t\t\t\t\tparsed.command.selector,\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus: parsed.command.status,\n\t\t\t\t\t\tnote: parsed.command.note,\n\t\t\t\t\t\tevidence: parsed.command.evidence ? [parsed.command.evidence] : undefined,\n\t\t\t\t\t},\n\t\t\t\t\tnow,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"clear\":\n\t\t\t\tstate = clearTaskSteps(state, now);\n\t\t\t\tbreak;\n\t\t\tcase \"compact\":\n\t\t\t\tstate = compactTaskSteps(state, now);\n\t\t\t\tbreak;\n\t\t}\n\t\thost.session.saveTaskStepsStateSnapshot(state);\n\t\thost.showStatus(formatTaskSteps(state));\n\t} catch (error) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t}\n}\n\nexport interface GoalContinueCommandHost {\n\treadonly session: {\n\t\tcontinueGoalLoop: (options: GoalContinuationLoopOptions) => Promise<GoalContinuationLoopResult>;\n\t};\n\tparseGoalContinueCommand(text: string): ParsedGoalContinueCommand;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\trefreshAutonomyFooterStatus(): void;\n}\n\nexport async function handleGoalContinueCommand(host: GoalContinueCommandHost, text: string): Promise<void> {\n\tconst parsed = host.parseGoalContinueCommand(text);\n\tif (!parsed.ok) {\n\t\thost.showError(parsed.error);\n\t\treturn;\n\t}\n\n\thost.showStatus(\n\t\t`Goal continuation started: ${parsed.maxTurns === 0 ? \"unbounded turns\" : `up to ${parsed.maxTurns} turn(s)`}, stall limit ${parsed.maxStallTurns}, wall-clock limit ${parsed.maxWallClockMinutes || \"disabled\"} minute(s).`,\n\t);\n\ttry {\n\t\tconst result = await host.session.continueGoalLoop({\n\t\t\tmaxTurns: parsed.maxTurns,\n\t\t\tmaxStallTurns: parsed.maxStallTurns,\n\t\t\tmaxWallClockMinutes: parsed.maxWallClockMinutes,\n\t\t});\n\t\tconst continuation = result.finalSnapshot.continuation;\n\t\thost.showStatus(\n\t\t\t`Goal continuation stopped: ${result.stopReason}; submitted ${result.turnsSubmitted} turn(s); latest decision ${continuation.action}/${continuation.reasonCode}.`,\n\t\t);\n\t} catch (error) {\n\t\thost.showError(`Goal continuation failed: ${error instanceof Error ? error.message : String(error)}`);\n\t} finally {\n\t\thost.refreshAutonomyFooterStatus();\n\t}\n}\n\nexport interface SessionInfoCommandHost {\n\treadonly session: {\n\t\tgetSessionStats: () => ReturnType<AgentSession[\"getSessionStats\"]>;\n\t\tgetCostSummary: () => ReturnType<AgentSession[\"getCostSummary\"]>;\n\t\tgetModelRouterStatus: (formatLabel: (label: string) => string) => string;\n\t};\n\treadonly sessionManager: { getSessionName: () => string | undefined };\n\treadonly chatContainer: Container;\n\treadonly ui: { requestRender: () => void };\n}\n\nexport function handleSessionCommand(host: SessionInfoCommandHost): void {\n\tconst stats = host.session.getSessionStats();\n\tconst sessionName = host.sessionManager.getSessionName();\n\n\tlet info = `${theme.bold(\"Session Info\")}\\n\\n`;\n\tif (sessionName) {\n\t\tinfo += `${theme.fg(\"dim\", \"Name:\")} ${sessionName}\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"File:\")} ${stats.sessionFile ?? \"In-memory\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"ID:\")} ${stats.sessionId}\\n\\n`;\n\tinfo += `${theme.bold(\"Messages\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"User:\")} ${stats.userMessages}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Assistant:\")} ${stats.assistantMessages}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Tool Calls:\")} ${stats.toolCalls}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Tool Results:\")} ${stats.toolResults}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.totalMessages}\\n\\n`;\n\tinfo += `${theme.bold(\"Tokens\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\tif (stats.tokens.cacheRead > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cache Read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\t}\n\tif (stats.tokens.cacheWrite > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cache Write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n`;\n\n\tconst costs = host.session.getCostSummary();\n\tif (hasCostSummarySignal(costs)) {\n\t\tinfo += `\\n${theme.bold(\"Cost\")}\\n`;\n\t\tinfo += formatCostReport(costs);\n\t}\n\n\tinfo += `\\n\\n${theme.bold(\"Model Router\")}\\n`;\n\tinfo += host.session.getModelRouterStatus((label) => theme.fg(\"dim\", label));\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(info, 1, 0));\n\thost.ui.requestRender();\n}\n"]}
@@ -29,10 +29,10 @@ Both use the same structured summary format and track file operations cumulative
29
29
  Auto-compaction triggers when:
30
30
 
31
31
  ```
32
- contextTokens > contextWindow - reserveTokens
32
+ requestTokens > contextWindow - reserveTokens
33
33
  ```
34
34
 
35
- By default, `reserveTokens` is 16384 tokens (configurable in `~/.pi/agent/settings.json` or `<project-dir>/.pi/settings.json`). This leaves room for the LLM's response.
35
+ `requestTokens` estimates the complete materialized provider context, not only stored conversation history. It includes the system prompt, projected tool schemas, text-only tool protocol, and request-local context. By default, `reserveTokens` is 16384 tokens (configurable in `~/.pi/agent/settings.json` or `<project-dir>/.pi/settings.json`). This leaves room for the LLM's response.
36
36
 
37
37
  You can also trigger manually with `/compact [instructions]`, where optional instructions focus the summary.
38
38
 
@@ -83,9 +83,36 @@ Memory providers receive `onPreCompress` once per manual or automatic compaction
83
83
  combined handoff at 4,000 characters and reuses it for extension handling and every summarizer retry,
84
84
  so a retry ladder does not repeat provider work or grow the prompt. Durable goals do not depend on the
85
85
  summary model recalling a large ledger: the next provider context contains exactly one bounded
86
- `<active_goal>` projection, while the hidden continuation trigger remains transient and is never
86
+ `ACTIVE GOAL` projection, while the hidden continuation trigger remains transient and is never
87
87
  stored as fake user history.
88
88
 
89
+ ### Provider Request Admission
90
+
91
+ Every model turn uses one bounded plan/admit/commit boundary:
92
+
93
+ ```text
94
+ durable history
95
+ -> replay-safe context plan
96
+ -> provider conversion + tool projection + text-protocol materialization
97
+ -> estimate complete request and fixed envelope
98
+ -> admit, or compact durable history and replan
99
+ -> validate freshness, commit accepted host effects
100
+ -> send the admitted Context object through the provider adapter
101
+ ```
102
+
103
+ The context plan separates two classes of input:
104
+
105
+ - **Compactable:** durable conversation history, including an accepted compaction summary and retained recent messages.
106
+ - **Non-compactable:** system prompt, provider-visible tool schemas, text-only tool primer and guard, extension `transientMessages`, memory evidence, the active goal projection, and the active skill body.
107
+
108
+ Compaction can replace only the durable class. After a compaction entry is accepted, Pi replans from the reloaded session history and adopts that history in the running agent loop before transport. The exact admitted `Context` object then enters the provider adapter; the planner does not rebuild it or append context after admission.
109
+
110
+ An optional early-cost trigger gets at most one normal summary pass. A hard boundary can use that pass plus one deterministic tightening pass. No-progress, repeated invalidation, an active conflicting compaction, or a fixed envelope at the hard boundary fails explicitly; Pi does not drop mandatory request-local context to make the request fit.
111
+
112
+ Planning is replay-safe. Extension/resource, active-skill, and goal revisions can invalidate a plan before commit; stale retries have their own bound and do not consume the compaction-replan allowance. Previewed context-GC and skill usage effects are committed only for the accepted plan.
113
+
114
+ An active skill remains host state during in-process compaction and is re-injected on every replan. Its body is absent from durable history and summaries. Process or session replacement starts a new skill-vault lifecycle, so a skill must be loaded again after a process restart, `/new`, `/resume`, or `/fork`. `/reload` retains an unchanged eligible skill and invalidates it if the resource changed or became unavailable.
115
+
89
116
  ### Split Turns
90
117
 
91
118
  A "turn" starts with a user message and includes all assistant responses and tool calls until the next user message. Normally, compaction cuts at turn boundaries.
@@ -223,39 +250,32 @@ See [`collectEntriesForBranchSummary()`](https://github.com/earendil-works/pi-mo
223
250
  Both compaction and branch summarization use the same structured format:
224
251
 
225
252
  ```markdown
226
- ## Goal
227
- [What the user is trying to accomplish]
253
+ ## Active Task
254
+ [Newest unfulfilled user request]
228
255
 
229
- ## Constraints & Preferences
230
- - [Requirements mentioned by user]
256
+ ### Mandatory Rules
257
+ - [Exact user constraints that still apply]
258
+
259
+ ## Working Set
260
+ - [Current symbols, commands, and evidence]
231
261
 
232
- ## Progress
233
- ### Done
234
- - [x] [Completed tasks]
262
+ ## Files
263
+ - [Relevant paths and their purpose]
235
264
 
236
- ### In Progress
237
- - [ ] [Current work]
265
+ ## Open Problems
266
+ - [Unresolved blockers or errors]
238
267
 
239
- ### Blocked
240
- - [Issues, if any]
268
+ ## Done
269
+ 1. [Recent completed work]
241
270
 
242
271
  ## Key Decisions
243
272
  - **[Decision]**: [Rationale]
244
273
 
245
- ## Next Steps
246
- 1. [What should happen next]
274
+ ## Constraints & Preferences
275
+ - [Durable requirements and preferences]
247
276
 
248
277
  ## Critical Context
249
278
  - [Data needed to continue]
250
-
251
- <read-files>
252
- path/to/file1.ts
253
- path/to/file2.ts
254
- </read-files>
255
-
256
- <modified-files>
257
- path/to/changed.ts
258
- </modified-files>
259
279
  ```
260
280
 
261
281
  ### Message Serialization
@@ -531,7 +531,7 @@ pi.on("before_agent_start", async (event, ctx) => {
531
531
  // .appendSystemPrompt - text from --append-system-prompt flags
532
532
  // .cwd - working directory
533
533
  // .contextFiles - eagerly loaded AGENTS.md/CLAUDE.md/GEMINI.md context files
534
- // .skills - discovered skills; startup prompt includes locations only, not frontmatter
534
+ // .skills - discovered frontmatter metadata, host-side; not rendered into the startup prompt
535
535
 
536
536
  return {
537
537
  // Inject a persistent message (stored in session, sent to LLM)
@@ -638,32 +638,48 @@ pi.on("tool_execution_end", async (event, ctx) => {
638
638
 
639
639
  #### context
640
640
 
641
- Fired before each LLM call. Modify messages non-destructively. See [Session Format](session-format.md) for message types.
641
+ Fired while planning each provider request. A plan may be replayed after compaction or invalidated resource state, so handlers must be replay-safe and must not perform durable side effects.
642
+
643
+ Return `messages` to replace compactable durable history. Return `transientMessages` for provider-only prompt material that must survive history compaction without entering session history or a compaction summary. Both classes are audited and budgeted before the request is admitted. See [Session Format](session-format.md) for message types.
642
644
 
643
645
  ```typescript
644
646
  pi.on("context", async (event, ctx) => {
645
647
  // event.messages - deep copy, safe to modify
646
648
  const filtered = event.messages.filter(m => !shouldPrune(m));
647
- return { messages: filtered };
649
+ return {
650
+ messages: filtered,
651
+ transientMessages: [{
652
+ role: "custom",
653
+ customType: "my-provider-context",
654
+ content: "Request-local instructions",
655
+ display: false,
656
+ details: undefined,
657
+ timestamp: Date.now(),
658
+ }],
659
+ };
648
660
  });
649
661
  ```
650
662
 
663
+ Later `context` handlers see the current `messages` projection. Transient additions accumulate separately and are not exposed as durable history to later handlers.
664
+
651
665
  #### before_provider_request
652
666
 
653
667
  Fired after the provider-specific payload is built, right before the request is sent. Handlers run in extension load order. Returning `undefined` keeps the payload unchanged. Returning any other value replaces the payload for later handlers and for the actual request.
654
668
 
655
- This hook can rewrite provider-level system instructions or remove them entirely. Those payload-level changes are not reflected by `ctx.getSystemPrompt()`, which reports Pi's system prompt string rather than the final serialized provider payload.
669
+ This is a trusted post-admission hook. A replacement may shrink or size-neutral-rewrite the serialized payload, but Pi rejects a replacement whose JSON representation is larger than the admitted payload. Add provider-visible prompt material with `context.transientMessages`; late prompt expansion fails closed instead of bypassing request admission.
670
+
671
+ Payload-level changes are not reflected by `ctx.getSystemPrompt()`, which reports Pi's system prompt string rather than the final serialized provider payload.
656
672
 
657
673
  ```typescript
658
674
  pi.on("before_provider_request", (event, ctx) => {
659
675
  console.log(JSON.stringify(event.payload, null, 2));
660
676
 
661
- // Optional: replace payload
677
+ // Optional: replace without increasing its serialized size
662
678
  // return { ...event.payload, temperature: 0 };
663
679
  });
664
680
  ```
665
681
 
666
- This is mainly useful for debugging provider serialization and cache behavior.
682
+ This is mainly useful for debugging provider serialization, cache behavior, and bounded provider controls. It is not a prompt-injection boundary.
667
683
 
668
684
  #### after_provider_response
669
685
 
@@ -860,7 +876,7 @@ Fired when user input is received, after extension commands are checked but befo
860
876
  **Processing order:**
861
877
  1. Extension commands (`/cmd`) checked first - if found, handler runs and input event is skipped
862
878
  2. `input` event fires - can intercept, transform, or handle
863
- 3. If not handled: skill commands (`/skill:name`) expanded to skill content
879
+ 3. If not handled: skill commands (`/skill:name`) load request-local skill context; arguments remain input
864
880
  4. If not handled: prompt templates (`/template`) expanded to template content
865
881
  5. Agent processing begins (`before_agent_start`, etc.)
866
882
 
package/docs/settings.md CHANGED
@@ -101,7 +101,7 @@ The agent is instructed to edit only that source checkout, preserve unrelated ch
101
101
 
102
102
  Use `/settings` → **Autonomy** to choose one preset and the foreground goal-loop round budget, or `/autonomy off|safe|balanced|full` to switch the preset while preserving the configured round budget. `full` is the standing-autonomy mode: it schedules post-turn reflection whenever concurrency allows and grants autonomous authority for high-confidence memory writes, user/project skill creation or patching, small user/project extension/tool improvements, autonomy/Auto Learn setting tuning, and edits under the authorized `selfModification.sourcePath` when validation and rollback evidence are recorded.
103
103
 
104
- Hard stops still require explicit foreground approval even in `full`: publishing, npm release, git push, tag creation, credential changes, destructive user-data deletion, network-exposed services, or authority expansion beyond this policy. `/autonomy status` shows the active grant and the Auto Learn audit/log directory.
104
+ Hard stops still require explicit foreground approval even in `full`: publishing, npm release, git push, tag creation, credential disclosure or provider-auth changes, destructive user-data deletion, network-exposed services, or authority expansion beyond this policy. An active user-plane `secret_store` grant is the narrow exception: model-blind activation and migration from named accessible sources require no duplicate confirmation. `/autonomy status` shows the active grant and the Auto Learn audit/log directory.
105
105
 
106
106
  ```json
107
107
  {
@@ -194,9 +194,9 @@ Fleet creation is bounded before Pi creates a durable task, conversation, agent,
194
194
 
195
195
  Transient attempt retries are evidence-gated. A classified provider or transport failure suspends the exact attempt with its retry count and ISO `notBefore` deadline, then resumes from the persisted transcript under a fresh fence when that deadline is eligible. Restart recovery uses the durable deadline rather than resetting an in-memory backoff; `maxAttempts: 1` disables the ladder, and missing/unknown failure classification never retries.
196
196
 
197
- `delegate` returns a stable agent/lane identity immediately. Completion persists a bounded terminal handoff before waking the parent; late output stays in the worker transcript instead of racing into the active foreground transcript. A full parent mailbox retains the attempt-keyed handoff until an explicit terminal, mailbox-capacity, state-change, or recovery event drains it—there is no retry polling loop. Exact replays are inert, conflicts fail closed, and delivery errors remain retained. `delegate_status` remains available for bounded lane-result retrieval.
197
+ `delegate` returns a stable agent/lane identity immediately. Completion persists a bounded terminal handoff before waking the parent; late output stays in the worker transcript instead of racing into the active foreground transcript. A full parent mailbox retains the attempt-keyed handoff until an explicit terminal, mailbox-capacity, state-change, or recovery event drains it—there is no retry polling loop. Exact replays are inert, conflicts fail closed, and delivery errors remain retained. Use `delegate { action: "status", laneId }` for bounded lane-result retrieval.
198
198
 
199
- Global profiles live at `~/.pi/agent/profiles/orchestration/<id>.json`; project profiles live at `.pi/profiles/orchestration/<id>.json`. They are optional presets for model, reasoning, tools, resources, budget, verification, and prompt defaults. Select one with `profileId` on a call or configure `workerDelegation.orchestrationProfile`. `dispatchProfileIds` is preset-routing metadata, not an admission allowlist. Profile `maxConcurrent` is retained in the authored schema but does not override the global scheduler. `profile_writer` can create an optional immutable session-scoped narrowing when a reusable preset is useful; direct authority selection does not require it.
199
+ Global profiles live at `~/.pi/agent/profiles/orchestration/<id>.json`; project profiles live at `.pi/profiles/orchestration/<id>.json`. They are optional presets for model, reasoning, tools, resources, budget, verification, and prompt defaults. Select one with `profileId` on a call or configure `workerDelegation.orchestrationProfile`. `dispatchProfileIds` is preset-routing metadata, not an admission allowlist. Profile `maxConcurrent` is retained in the authored schema but does not override the global scheduler. `delegate` actions `profile_inspect` and `profile_create` manage optional immutable session-scoped narrowings; direct authority selection does not require one.
200
200
 
201
201
  A preset with `requireIndependentVerification: true` still names an owner-authored `verificationProfileId`. The runtime creates a separate durable verifier task and accepts the implementation only after a typed verifier decision. A profile using `run_process` must declare `executionPolicy`; that tool launches only listed executables as direct argv. The platform shell is different: it is a real persistent per-agent shell and is not OS/container isolation. Shell commands can exercise the host process, filesystem, network, and credentials available to Pi; direct `write`/`edit` path scopes do not sandbox shell side effects.
202
202