@caupulican/pi-adaptative 0.90.7 → 0.90.11

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 (207) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/bundled-resources/skills/tool-call-repair/SKILL.md +5 -4
  3. package/dist/bundled-resources/skills/tool-call-repair/references/failure-grammar.md +6 -3
  4. package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +1 -0
  5. package/dist/core/agent-session-contracts.d.ts +2 -0
  6. package/dist/core/agent-session-contracts.d.ts.map +1 -1
  7. package/dist/core/agent-session-contracts.js.map +1 -1
  8. package/dist/core/agent-session.d.ts +8 -7
  9. package/dist/core/agent-session.d.ts.map +1 -1
  10. package/dist/core/agent-session.js +80 -196
  11. package/dist/core/agent-session.js.map +1 -1
  12. package/dist/core/autonomy/bounded-completion.d.ts +7 -1
  13. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  14. package/dist/core/autonomy/bounded-completion.js +8 -2
  15. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  16. package/dist/core/autonomy/contracts.d.ts +1 -1
  17. package/dist/core/autonomy/contracts.d.ts.map +1 -1
  18. package/dist/core/autonomy/contracts.js.map +1 -1
  19. package/dist/core/background-lane-controller.d.ts +14 -0
  20. package/dist/core/background-lane-controller.d.ts.map +1 -1
  21. package/dist/core/background-lane-controller.js +32 -0
  22. package/dist/core/background-lane-controller.js.map +1 -1
  23. package/dist/core/billing-failover-controller.js +1 -1
  24. package/dist/core/billing-failover-controller.js.map +1 -1
  25. package/dist/core/context/current-work-memory.d.ts +1 -1
  26. package/dist/core/context/current-work-memory.d.ts.map +1 -1
  27. package/dist/core/context/current-work-memory.js +2 -1
  28. package/dist/core/context/current-work-memory.js.map +1 -1
  29. package/dist/core/context/long-term-memory-trigger.d.ts +1 -1
  30. package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
  31. package/dist/core/context/long-term-memory-trigger.js +2 -1
  32. package/dist/core/context/long-term-memory-trigger.js.map +1 -1
  33. package/dist/core/delegation/managed-lane-controller.js +2 -2
  34. package/dist/core/delegation/managed-lane-controller.js.map +1 -1
  35. package/dist/core/delegation/worker-agent-control-coordinator.d.ts +13 -0
  36. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
  37. package/dist/core/delegation/worker-agent-control-coordinator.js +71 -8
  38. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  39. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  40. package/dist/core/delegation/worker-attempt-executor.js +13 -8
  41. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  42. package/dist/core/delegation/worker-claim.d.ts.map +1 -1
  43. package/dist/core/delegation/worker-claim.js +14 -1
  44. package/dist/core/delegation/worker-claim.js.map +1 -1
  45. package/dist/core/delegation/worker-delegation-controller.d.ts +3 -2
  46. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  47. package/dist/core/delegation/worker-delegation-controller.js +95 -42
  48. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  49. package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
  50. package/dist/core/delegation/worker-fleet-limits.js +5 -1
  51. package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
  52. package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
  53. package/dist/core/delegation/worker-lane-projection.js +7 -4
  54. package/dist/core/delegation/worker-lane-projection.js.map +1 -1
  55. package/dist/core/delegation/worker-lifecycle.d.ts +8 -0
  56. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
  57. package/dist/core/delegation/worker-lifecycle.js.map +1 -1
  58. package/dist/core/delegation/worker-notification-coordinator.d.ts +21 -0
  59. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
  60. package/dist/core/delegation/worker-notification-coordinator.js +65 -2
  61. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
  62. package/dist/core/delegation/worker-runner.d.ts +7 -0
  63. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  64. package/dist/core/delegation/worker-runner.js +24 -7
  65. package/dist/core/delegation/worker-runner.js.map +1 -1
  66. package/dist/core/delegation/worker-system-prompt.d.ts +54 -0
  67. package/dist/core/delegation/worker-system-prompt.d.ts.map +1 -0
  68. package/dist/core/delegation/worker-system-prompt.js +85 -0
  69. package/dist/core/delegation/worker-system-prompt.js.map +1 -0
  70. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -1
  71. package/dist/core/delegation/worker-tree-budget-coordinator.js +4 -0
  72. package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -1
  73. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +4 -0
  74. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
  75. package/dist/core/delegation/worker-write-reservation-coordinator.js +28 -1
  76. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
  77. package/dist/core/durable-custom-message-turn-controller.d.ts.map +1 -1
  78. package/dist/core/durable-custom-message-turn-controller.js +14 -3
  79. package/dist/core/durable-custom-message-turn-controller.js.map +1 -1
  80. package/dist/core/extension-binding-controller.d.ts +107 -0
  81. package/dist/core/extension-binding-controller.d.ts.map +1 -0
  82. package/dist/core/extension-binding-controller.js +224 -0
  83. package/dist/core/extension-binding-controller.js.map +1 -0
  84. package/dist/core/extensions/types.d.ts +2 -0
  85. package/dist/core/extensions/types.d.ts.map +1 -1
  86. package/dist/core/extensions/types.js.map +1 -1
  87. package/dist/core/foreground-terminal-handoff-controller.d.ts +9 -0
  88. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  89. package/dist/core/foreground-terminal-handoff-controller.js +35 -9
  90. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  91. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  92. package/dist/core/goal-loop-controller.js +10 -1
  93. package/dist/core/goal-loop-controller.js.map +1 -1
  94. package/dist/core/goals/compact-goal-context.d.ts +1 -1
  95. package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
  96. package/dist/core/goals/compact-goal-context.js +2 -1
  97. package/dist/core/goals/compact-goal-context.js.map +1 -1
  98. package/dist/core/goals/goal-execution-errors.d.ts +18 -0
  99. package/dist/core/goals/goal-execution-errors.d.ts.map +1 -0
  100. package/dist/core/goals/goal-execution-errors.js +21 -0
  101. package/dist/core/goals/goal-execution-errors.js.map +1 -0
  102. package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
  103. package/dist/core/goals/goal-lifecycle.js +3 -3
  104. package/dist/core/goals/goal-lifecycle.js.map +1 -1
  105. package/dist/core/goals/goal-session-controller.d.ts +11 -0
  106. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  107. package/dist/core/goals/goal-session-controller.js +74 -14
  108. package/dist/core/goals/goal-session-controller.js.map +1 -1
  109. package/dist/core/goals/goal-state.js +1 -1
  110. package/dist/core/goals/goal-state.js.map +1 -1
  111. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  112. package/dist/core/goals/goal-tool-core.js +2 -2
  113. package/dist/core/goals/goal-tool-core.js.map +1 -1
  114. package/dist/core/goals/natural-language-goal.d.ts +18 -0
  115. package/dist/core/goals/natural-language-goal.d.ts.map +1 -1
  116. package/dist/core/goals/natural-language-goal.js +99 -16
  117. package/dist/core/goals/natural-language-goal.js.map +1 -1
  118. package/dist/core/model-registry.d.ts +5 -0
  119. package/dist/core/model-registry.d.ts.map +1 -1
  120. package/dist/core/model-registry.js +10 -0
  121. package/dist/core/model-registry.js.map +1 -1
  122. package/dist/core/model-resolver.d.ts.map +1 -1
  123. package/dist/core/model-resolver.js +3 -1
  124. package/dist/core/model-resolver.js.map +1 -1
  125. package/dist/core/orchestration/capability-gateway.d.ts +1 -1
  126. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
  127. package/dist/core/orchestration/capability-gateway.js +4 -4
  128. package/dist/core/orchestration/capability-gateway.js.map +1 -1
  129. package/dist/core/orchestration/event-store.d.ts +8 -0
  130. package/dist/core/orchestration/event-store.d.ts.map +1 -1
  131. package/dist/core/orchestration/event-store.js +9 -7
  132. package/dist/core/orchestration/event-store.js.map +1 -1
  133. package/dist/core/orchestration/task-runtime-reducer.js +1 -1
  134. package/dist/core/orchestration/task-runtime-reducer.js.map +1 -1
  135. package/dist/core/orchestration/worker-model-pins.d.ts +7 -0
  136. package/dist/core/orchestration/worker-model-pins.d.ts.map +1 -1
  137. package/dist/core/orchestration/worker-model-pins.js +17 -1
  138. package/dist/core/orchestration/worker-model-pins.js.map +1 -1
  139. package/dist/core/provider-request-runtime-controller.d.ts +9 -0
  140. package/dist/core/provider-request-runtime-controller.d.ts.map +1 -1
  141. package/dist/core/provider-request-runtime-controller.js +17 -3
  142. package/dist/core/provider-request-runtime-controller.js.map +1 -1
  143. package/dist/core/provider-tool-text.d.ts +15 -1
  144. package/dist/core/provider-tool-text.d.ts.map +1 -1
  145. package/dist/core/provider-tool-text.js +42 -10
  146. package/dist/core/provider-tool-text.js.map +1 -1
  147. package/dist/core/research/research-lane-controller.d.ts +1 -1
  148. package/dist/core/research/research-lane-controller.d.ts.map +1 -1
  149. package/dist/core/research/research-lane-controller.js +2 -1
  150. package/dist/core/research/research-lane-controller.js.map +1 -1
  151. package/dist/core/resource-loader.d.ts +3 -0
  152. package/dist/core/resource-loader.d.ts.map +1 -1
  153. package/dist/core/resource-loader.js +8 -0
  154. package/dist/core/resource-loader.js.map +1 -1
  155. package/dist/core/runtime-builder.d.ts +8 -0
  156. package/dist/core/runtime-builder.d.ts.map +1 -1
  157. package/dist/core/runtime-builder.js +6 -0
  158. package/dist/core/runtime-builder.js.map +1 -1
  159. package/dist/core/session-supervision-runtime.d.ts.map +1 -1
  160. package/dist/core/session-supervision-runtime.js +2 -1
  161. package/dist/core/session-supervision-runtime.js.map +1 -1
  162. package/dist/core/settings-manager.d.ts +2 -2
  163. package/dist/core/settings-manager.d.ts.map +1 -1
  164. package/dist/core/settings-manager.js +7 -2
  165. package/dist/core/settings-manager.js.map +1 -1
  166. package/dist/core/tools/delegate.d.ts +13 -0
  167. package/dist/core/tools/delegate.d.ts.map +1 -1
  168. package/dist/core/tools/delegate.js +20 -18
  169. package/dist/core/tools/delegate.js.map +1 -1
  170. package/dist/core/util/atomic-file.d.ts +7 -0
  171. package/dist/core/util/atomic-file.d.ts.map +1 -1
  172. package/dist/core/util/atomic-file.js +8 -6
  173. package/dist/core/util/atomic-file.js.map +1 -1
  174. package/dist/core/util/faultable-fs.d.ts +30 -0
  175. package/dist/core/util/faultable-fs.d.ts.map +1 -0
  176. package/dist/core/util/faultable-fs.js +30 -0
  177. package/dist/core/util/faultable-fs.js.map +1 -0
  178. package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
  179. package/dist/modes/interactive/auth-dialogs-controller.js +1 -0
  180. package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
  181. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
  182. package/dist/modes/interactive/components/activity-lane.js +4 -3
  183. package/dist/modes/interactive/components/activity-lane.js.map +1 -1
  184. package/dist/modes/interactive/components/footer.js +1 -1
  185. package/dist/modes/interactive/components/footer.js.map +1 -1
  186. package/dist/modes/interactive/components/oauth-selector.d.ts +2 -0
  187. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  188. package/dist/modes/interactive/components/oauth-selector.js +3 -2
  189. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  190. package/dist/modes/interactive/report-commands.js +1 -1
  191. package/dist/modes/interactive/report-commands.js.map +1 -1
  192. package/dist/modes/interactive/session-flow-commands.d.ts +1 -1
  193. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
  194. package/dist/modes/interactive/session-flow-commands.js +3 -2
  195. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  196. package/docs/providers.md +3 -0
  197. package/docs/settings.md +4 -2
  198. package/docs/tool-repair.md +1 -0
  199. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  200. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  201. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  202. package/examples/extensions/sandbox/package-lock.json +2 -2
  203. package/examples/extensions/sandbox/package.json +1 -1
  204. package/examples/extensions/with-deps/package-lock.json +2 -2
  205. package/examples/extensions/with-deps/package.json +1 -1
  206. package/npm-shrinkwrap.json +12 -12
  207. package/package.json +9 -4
@@ -1 +1 @@
1
- {"version":3,"file":"report-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/report-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAA2B,MAAM,iCAAiC,CAAC;AAGjG,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AA4BzC,MAAM,UAAU,gBAAgB,CAAC,KAAyB,EAAE,iBAAiB,GAAG,KAAK;IACpF,MAAM,KAAK,GAAG;QACb,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,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C,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAsB;IAC1D,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,6BAA6B,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAsB;IACnD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAsB,EAAE,KAAuC;IACpG,IAAI,KAAK,CAAC,QAAQ,KAAK,UAAU,IAAI,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnF,aAAa,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;AACF,CAAC","sourcesContent":["/**\n * Read-only report and easter-egg commands extracted from interactive-mode.\n *\n * These build informational output (usage/cost summary, changelog, hotkeys\n * table, render debug dump) or render an easter-egg component, appending to the\n * chat container and requesting a render. None mutate agent/session state, so\n * they operate through narrow `host` seams (chat container, TUI, and a few\n * read accessors) while interactive-mode keeps thin delegating wrappers.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { Container, Keybinding, MarkdownTheme, TUI } from \"@caupulican/pi-tui\";\nimport { Markdown, Spacer, Text, visibleWidth } from \"@caupulican/pi-tui\";\nimport { getDebugLogPath } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport { hasSubagentCostSignal, type SessionCostSummary } from \"../../core/cost/cost-summary.ts\";\nimport type { AppKeybinding, KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { AutoLearnSettings } from \"../../core/settings-manager.ts\";\nimport { getChangelogPath, parseChangelog } from \"../../utils/changelog.ts\";\nimport { getProcessMemoryMb } from \"../../utils/process-memory.ts\";\nimport { ArminComponent } from \"./components/armin.ts\";\nimport { DaxnutsComponent } from \"./components/daxnuts.ts\";\nimport { DynamicBorder } from \"./components/dynamic-border.ts\";\nimport { EarendilAnnouncementComponent } from \"./components/earendil-announcement.ts\";\nimport { formatKeyText } from \"./components/keybinding-hints.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport interface ReportRenderHost {\n\treadonly chatContainer: Container;\n\treadonly ui: TUI;\n}\n\nexport interface UsageReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\tgetCurrentAutoLearnSettings(): Required<AutoLearnSettings>;\n}\n\nexport interface ChangelogReportHost extends ReportRenderHost {\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n}\n\nexport interface HotkeysReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\treadonly keybindings: KeybindingsManager;\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n\tgetAppKeyDisplay(action: AppKeybinding): string;\n\tgetEditorKeyDisplay(action: Keybinding): string;\n}\n\nexport interface DebugReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n}\n\nexport function formatCostReport(costs: SessionCostSummary, usingSubscription = false): string {\n\tconst lines = [\n\t\t`${theme.fg(\"dim\", \"CURRENT (session):\")} $${costs.currentCost.toFixed(4)}${usingSubscription ? \" (sub)\" : \"\"}`,\n\t];\n\tif (hasSubagentCostSignal(costs)) {\n\t\tlines.push(\n\t\t\t`${theme.fg(\"dim\", \"SUBAGENTS (included in CURRENT):\")} $${costs.subagentCost.toFixed(4)} (${costs.subagentReports} reports)`,\n\t\t);\n\t}\n\tlines.push(\n\t\t`${theme.fg(\"dim\", \"TODAY (host local day):\")} $${costs.todayCost.toFixed(4)}`,\n\t\t`${theme.fg(\"dim\", \"Today rollover:\")} local midnight`,\n\t);\n\treturn lines.join(\"\\n\");\n}\n\nexport function handleUsageCommand(host: UsageReportHost): void {\n\tconst stats = host.session.getSessionStats();\n\tconst costs = host.session.getCostSummary();\n\tconst context = host.session.getContextUsage();\n\tconst autoLearn = host.getCurrentAutoLearnSettings();\n\tconst costGuard = host.session.getLastCostGuardDecision();\n\tconst activeModel = host.session.model;\n\tconst usingSubscription = activeModel ? host.session.modelRegistry.isUsingOAuth(activeModel) : false;\n\tconst isChatGptSubscription = usingSubscription && activeModel?.provider === \"openai-codex\";\n\n\tlet info = `${theme.bold(\"Usage & Optimization\")}\\n\\n`;\n\tinfo += `${theme.bold(\"Session 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\tinfo += `${theme.fg(\"dim\", \"Cache read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Cost\")}\\n`;\n\tinfo += `${formatCostReport(costs, usingSubscription)}\\n\\n`;\n\n\tconst processMemory = getProcessMemoryMb();\n\tinfo += `${theme.bold(\"Process\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Memory:\")} rss ${processMemory.rssMb}MB, heap ${processMemory.heapUsedMb}MB, external ${processMemory.externalMb}MB\\n\\n`;\n\n\tinfo += `${theme.bold(\"Optimization state\")}\\n`;\n\tconst contextPercent = context?.percent;\n\tconst contextTokens = context?.tokens;\n\tif (\n\t\tcontext &&\n\t\tcontextPercent !== undefined &&\n\t\tcontextPercent !== null &&\n\t\tcontextTokens !== undefined &&\n\t\tcontextTokens !== null\n\t) {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} ${contextPercent.toFixed(1)}% (${contextTokens.toLocaleString()}/${context.contextWindow.toLocaleString()})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} unknown until next provider usage sample\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto-compaction:\")} ${host.session.autoCompactionEnabled ? \"enabled\" : \"disabled\"}\\n`;\n\tconst compactionGates = stats.compactionGates ?? {\n\t\tgateFailures: 0,\n\t\tdeterministicGapFills: 0,\n\t\tcompactionsWithGateFailures: 0,\n\t\tchecks: {},\n\t};\n\tinfo += `${theme.fg(\"dim\", \"Compaction gate failures:\")} ${compactionGates.gateFailures} (${compactionGates.deterministicGapFills} deterministic gap-fill)\\n`;\n\tconst failingChecks = Object.entries(compactionGates.checks).sort(\n\t\t([leftName, left], [rightName, right]) => right.failures - left.failures || leftName.localeCompare(rightName),\n\t);\n\tif (failingChecks.length > 0) {\n\t\tconst visibleChecks = failingChecks.slice(0, 3).map(([check, checkStats]) => {\n\t\t\tlet score = \"\";\n\t\t\tif (checkStats.minScore !== undefined && checkStats.maxScore !== undefined) {\n\t\t\t\tconst range =\n\t\t\t\t\tcheckStats.minScore === checkStats.maxScore\n\t\t\t\t\t\t? checkStats.minScore.toFixed(2)\n\t\t\t\t\t\t: `${checkStats.minScore.toFixed(2)}-${checkStats.maxScore.toFixed(2)}`;\n\t\t\t\tconst threshold =\n\t\t\t\t\tcheckStats.threshold === undefined\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: ` ${checkStats.comparator === \"maximum\" ? \">\" : \"<\"} ${checkStats.threshold.toFixed(2)}`;\n\t\t\t\tscore = ` (${range}${threshold})`;\n\t\t\t}\n\t\t\treturn `${check} x${checkStats.failures}${score}`;\n\t\t});\n\t\tif (failingChecks.length > visibleChecks.length) {\n\t\t\tvisibleChecks.push(`+${failingChecks.length - visibleChecks.length} more`);\n\t\t}\n\t\tinfo += `${theme.fg(\"dim\", \"Failing compaction checks:\")} ${visibleChecks.join(\"; \")}\\n`;\n\t}\n\tif (isChatGptSubscription) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} not applicable to ChatGPT subscription usage\\n`;\n\t} else if (costGuard) {\n\t\tconst status = costGuard.over ? \"over\" : \"ok\";\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} ${status} $${costGuard.estUsd.toFixed(4)}/$${costGuard.thresholdUsd.toFixed(4)} (${costGuard.action})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} disabled\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn:\")} ${autoLearn.enabled ? \"enabled\" : \"disabled\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Scavenger model:\")} ${autoLearn.model || \"active\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Reflection review:\")} ${autoLearn.reflectionReview ? \"enabled\" : \"disabled\"} (${autoLearn.reflectionMinToolCalls} tool-call trigger)\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn concurrency:\")} ${autoLearn.maxConcurrentLearners} learner(s), ${autoLearn.cooldownMinutes}m cooldown\\n\\n`;\n\n\tinfo += `${theme.bold(\"Model Router\")}\\n`;\n\tinfo += `${host.session.getModelRouterStatus((label) => theme.fg(\"dim\", label))}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Manual controls\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/compact\")}: compact the active context now\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/settings\")}: adjust Auto Learn, cost guard, compaction, and model-router config\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/auto-learn status|run\")}: inspect or launch background learning\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/context\")}: inspect provider-visible context contributors without model tokens\\n`;\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(info, 1, 0));\n\thost.ui.requestRender();\n}\n\nexport function handleChangelogCommand(host: ChangelogReportHost): void {\n\tconst changelogPath = getChangelogPath();\n\tconst allEntries = parseChangelog(changelogPath);\n\n\tconst changelogMarkdown =\n\t\tallEntries.length > 0\n\t\t\t? allEntries\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.map((e) => e.content)\n\t\t\t\t\t.join(\"\\n\\n\")\n\t\t\t: \"No changelog entries found.\";\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleHotkeysCommand(host: HotkeysReportHost): void {\n\t// Navigation keybindings\n\tconst cursorUp = host.getEditorKeyDisplay(\"tui.editor.cursorUp\");\n\tconst cursorDown = host.getEditorKeyDisplay(\"tui.editor.cursorDown\");\n\tconst cursorLeft = host.getEditorKeyDisplay(\"tui.editor.cursorLeft\");\n\tconst cursorRight = host.getEditorKeyDisplay(\"tui.editor.cursorRight\");\n\tconst cursorWordLeft = host.getEditorKeyDisplay(\"tui.editor.cursorWordLeft\");\n\tconst cursorWordRight = host.getEditorKeyDisplay(\"tui.editor.cursorWordRight\");\n\tconst cursorLineStart = host.getEditorKeyDisplay(\"tui.editor.cursorLineStart\");\n\tconst cursorLineEnd = host.getEditorKeyDisplay(\"tui.editor.cursorLineEnd\");\n\tconst jumpForward = host.getEditorKeyDisplay(\"tui.editor.jumpForward\");\n\tconst jumpBackward = host.getEditorKeyDisplay(\"tui.editor.jumpBackward\");\n\tconst pageUp = host.getEditorKeyDisplay(\"tui.editor.pageUp\");\n\tconst pageDown = host.getEditorKeyDisplay(\"tui.editor.pageDown\");\n\n\t// Editing keybindings\n\tconst submit = host.getEditorKeyDisplay(\"tui.input.submit\");\n\tconst newLine = host.getEditorKeyDisplay(\"tui.input.newLine\");\n\tconst deleteWordBackward = host.getEditorKeyDisplay(\"tui.editor.deleteWordBackward\");\n\tconst deleteWordForward = host.getEditorKeyDisplay(\"tui.editor.deleteWordForward\");\n\tconst deleteToLineStart = host.getEditorKeyDisplay(\"tui.editor.deleteToLineStart\");\n\tconst deleteToLineEnd = host.getEditorKeyDisplay(\"tui.editor.deleteToLineEnd\");\n\tconst yank = host.getEditorKeyDisplay(\"tui.editor.yank\");\n\tconst yankPop = host.getEditorKeyDisplay(\"tui.editor.yankPop\");\n\tconst undo = host.getEditorKeyDisplay(\"tui.editor.undo\");\n\tconst tab = host.getEditorKeyDisplay(\"tui.input.tab\");\n\n\t// App keybindings\n\tconst interrupt = host.getAppKeyDisplay(\"app.interrupt\");\n\tconst clear = host.getAppKeyDisplay(\"app.clear\");\n\tconst exit = host.getAppKeyDisplay(\"app.exit\");\n\tconst suspend = host.getAppKeyDisplay(\"app.suspend\");\n\tconst cycleThinkingLevel = host.getAppKeyDisplay(\"app.thinking.cycle\");\n\tconst cycleModelForward = host.getAppKeyDisplay(\"app.model.cycleForward\");\n\tconst selectModel = host.getAppKeyDisplay(\"app.model.select\");\n\tconst expandTools = host.getAppKeyDisplay(\"app.tools.expand\");\n\tconst toggleThinking = host.getAppKeyDisplay(\"app.thinking.toggle\");\n\tconst externalEditor = host.getAppKeyDisplay(\"app.editor.external\");\n\tconst cycleModelBackward = host.getAppKeyDisplay(\"app.model.cycleBackward\");\n\tconst followUp = host.getAppKeyDisplay(\"app.message.followUp\");\n\tconst dequeue = host.getAppKeyDisplay(\"app.message.dequeue\");\n\tconst pasteImage = host.getAppKeyDisplay(\"app.clipboard.pasteImage\");\n\n\tlet hotkeys = `\n**Navigation**\n| Key | Action |\n|-----|--------|\n| \\`${cursorUp}\\` / \\`${cursorDown}\\` / \\`${cursorLeft}\\` / \\`${cursorRight}\\` | Move cursor / browse history (Up when empty) |\n| \\`${cursorWordLeft}\\` / \\`${cursorWordRight}\\` | Move by word |\n| \\`${cursorLineStart}\\` | Start of line |\n| \\`${cursorLineEnd}\\` | End of line |\n| \\`${jumpForward}\\` | Jump forward to character |\n| \\`${jumpBackward}\\` | Jump backward to character |\n| \\`${pageUp}\\` / \\`${pageDown}\\` | Scroll by page |\n\n**Editing**\n| Key | Action |\n|-----|--------|\n| \\`${submit}\\` | Send message |\n| \\`${newLine}\\` | New line${process.platform === \"win32\" ? \" (Ctrl+Enter on Windows Terminal)\" : \"\"} |\n| \\`${deleteWordBackward}\\` | Delete word backwards |\n| \\`${deleteWordForward}\\` | Delete word forwards |\n| \\`${deleteToLineStart}\\` | Delete to start of line |\n| \\`${deleteToLineEnd}\\` | Delete to end of line |\n| \\`${yank}\\` | Paste the most-recently-deleted text |\n| \\`${yankPop}\\` | Cycle through the deleted text after pasting |\n| \\`${undo}\\` | Undo |\n\n**Other**\n| Key | Action |\n|-----|--------|\n| \\`${tab}\\` | Path completion / accept autocomplete |\n| \\`${interrupt}\\` | Cancel autocomplete / abort streaming |\n| \\`${clear}\\` | Clear editor (first) / exit (second) |\n| \\`${exit}\\` | Exit (when editor is empty) |\n| \\`${suspend}\\` | Suspend to background |\n| \\`${cycleThinkingLevel}\\` | Cycle thinking level |\n| \\`${cycleModelForward}\\` / \\`${cycleModelBackward}\\` | Cycle models |\n| \\`${selectModel}\\` | Open model selector |\n| \\`${expandTools}\\` | Toggle tool output expansion |\n| \\`${toggleThinking}\\` | Toggle thinking block visibility |\n| \\`${externalEditor}\\` | Edit message in external editor |\n| \\`${followUp}\\` | Queue follow-up message |\n| \\`${dequeue}\\` | Restore queued messages |\n| \\`${pasteImage}\\` | Paste image from clipboard |\n| \\`/\\` | Slash commands |\n| \\`!\\` | Run bash command |\n| \\`!!\\` | Run bash command (excluded from context) |\n`;\n\n\t// Add extension-registered shortcuts\n\tconst extensionRunner = host.session.extensionRunner;\n\tconst shortcuts = extensionRunner.getShortcuts(host.keybindings.getEffectiveConfig());\n\tif (shortcuts.size > 0) {\n\t\thotkeys += `\n**Extensions**\n| Key | Action |\n|-----|--------|\n`;\n\t\tfor (const [key, shortcut] of shortcuts) {\n\t\t\tconst description = shortcut.description ?? shortcut.extensionPath;\n\t\t\tconst keyDisplay = formatKeyText(key, { capitalize: true });\n\t\t\thotkeys += `| \\`${keyDisplay}\\` | ${description} |\\n`;\n\t\t}\n\t}\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Keyboard Shortcuts\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleDebugCommand(host: DebugReportHost): void {\n\tconst width = host.ui.terminal.columns;\n\tconst height = host.ui.terminal.rows;\n\tconst allLines = host.ui.render(width);\n\n\tconst debugLogPath = getDebugLogPath();\n\tconst debugData = [\n\t\t`Debug output at ${new Date().toISOString()}`,\n\t\t`Terminal: ${width}x${height}`,\n\t\t`Total lines: ${allLines.length}`,\n\t\t\"\",\n\t\t\"=== All rendered lines with visible widths ===\",\n\t\t...allLines.map((line, idx) => {\n\t\t\tconst vw = visibleWidth(line);\n\t\t\tconst escaped = JSON.stringify(line);\n\t\t\treturn `[${idx}] (w=${vw}) ${escaped}`;\n\t\t}),\n\t\t\"\",\n\t\t\"=== Agent messages (JSONL) ===\",\n\t\t...host.session.messages.map((msg) => JSON.stringify(msg)),\n\t\t\"\",\n\t].join(\"\\n\");\n\n\tfs.mkdirSync(path.dirname(debugLogPath), { recursive: true });\n\tfs.writeFileSync(debugLogPath, debugData);\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(\n\t\tnew Text(`${theme.fg(\"accent\", \"✓ Debug log written\")}\\n${theme.fg(\"muted\", debugLogPath)}`, 1, 1),\n\t);\n\thost.ui.requestRender();\n}\n\nexport function handleArminSaysHi(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new ArminComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function handleDementedDelves(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new EarendilAnnouncementComponent());\n\thost.ui.requestRender();\n}\n\nexport function handleDaxnuts(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DaxnutsComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function checkDaxnutsEasterEgg(host: ReportRenderHost, model: { provider: string; id: string }): void {\n\tif (model.provider === \"opencode\" && model.id.toLowerCase().includes(\"kimi-k2.5\")) {\n\t\thandleDaxnuts(host);\n\t}\n}\n"]}
1
+ {"version":3,"file":"report-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/report-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAA2B,MAAM,iCAAiC,CAAC;AAGjG,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;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AAE,CAAC;QACnF,aAAa,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;AACF,CAAC","sourcesContent":["/**\n * Read-only report and easter-egg commands extracted from interactive-mode.\n *\n * These build informational output (usage/cost summary, changelog, hotkeys\n * table, render debug dump) or render an easter-egg component, appending to the\n * chat container and requesting a render. None mutate agent/session state, so\n * they operate through narrow `host` seams (chat container, TUI, and a few\n * read accessors) while interactive-mode keeps thin delegating wrappers.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { Container, Keybinding, MarkdownTheme, TUI } from \"@caupulican/pi-tui\";\nimport { Markdown, Spacer, Text, visibleWidth } from \"@caupulican/pi-tui\";\nimport { getDebugLogPath } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport { hasSubagentCostSignal, type SessionCostSummary } from \"../../core/cost/cost-summary.ts\";\nimport type { AppKeybinding, KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { AutoLearnSettings } from \"../../core/settings-manager.ts\";\nimport { getChangelogPath, parseChangelog } from \"../../utils/changelog.ts\";\nimport { getProcessMemoryMb } from \"../../utils/process-memory.ts\";\nimport { ArminComponent } from \"./components/armin.ts\";\nimport { DaxnutsComponent } from \"./components/daxnuts.ts\";\nimport { DynamicBorder } from \"./components/dynamic-border.ts\";\nimport { EarendilAnnouncementComponent } from \"./components/earendil-announcement.ts\";\nimport { formatKeyText } from \"./components/keybinding-hints.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport interface ReportRenderHost {\n\treadonly chatContainer: Container;\n\treadonly ui: TUI;\n}\n\nexport interface UsageReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\tgetCurrentAutoLearnSettings(): Required<AutoLearnSettings>;\n}\n\nexport interface ChangelogReportHost extends ReportRenderHost {\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n}\n\nexport interface HotkeysReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\treadonly keybindings: KeybindingsManager;\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n\tgetAppKeyDisplay(action: AppKeybinding): string;\n\tgetEditorKeyDisplay(action: Keybinding): string;\n}\n\nexport interface DebugReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n}\n\nexport function formatCostReport(costs: SessionCostSummary, usingSubscription = false): string {\n\tconst lines = [\n\t\t`${theme.fg(\"dim\", \"CURRENT (session):\")} $${costs.currentCost.toFixed(4)}${usingSubscription ? \" (sub)\" : \"\"}`,\n\t];\n\tif (hasSubagentCostSignal(costs)) {\n\t\tlines.push(\n\t\t\t`${theme.fg(\"dim\", \"SUBAGENTS (included in CURRENT):\")} $${costs.subagentCost.toFixed(4)} (${costs.subagentReports} reports)`,\n\t\t);\n\t}\n\tlines.push(\n\t\t`${theme.fg(\"dim\", \"TODAY (host local day):\")} $${costs.todayCost.toFixed(4)}`,\n\t\t`${theme.fg(\"dim\", \"Today rollover:\")} local midnight`,\n\t);\n\treturn lines.join(\"\\n\");\n}\n\nexport function handleUsageCommand(host: UsageReportHost): void {\n\tconst stats = host.session.getSessionStats();\n\tconst costs = host.session.getCostSummary();\n\tconst context = host.session.getContextUsage();\n\tconst autoLearn = host.getCurrentAutoLearnSettings();\n\tconst costGuard = host.session.getLastCostGuardDecision();\n\tconst activeModel = host.session.model;\n\tconst usingSubscription = activeModel ? host.session.modelRegistry.isUsingSubscription(activeModel) : false;\n\tconst isChatGptSubscription = usingSubscription && activeModel?.provider === \"openai-codex\";\n\n\tlet info = `${theme.bold(\"Usage & Optimization\")}\\n\\n`;\n\tinfo += `${theme.bold(\"Session 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\tinfo += `${theme.fg(\"dim\", \"Cache read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Cost\")}\\n`;\n\tinfo += `${formatCostReport(costs, usingSubscription)}\\n\\n`;\n\n\tconst processMemory = getProcessMemoryMb();\n\tinfo += `${theme.bold(\"Process\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Memory:\")} rss ${processMemory.rssMb}MB, heap ${processMemory.heapUsedMb}MB, external ${processMemory.externalMb}MB\\n\\n`;\n\n\tinfo += `${theme.bold(\"Optimization state\")}\\n`;\n\tconst contextPercent = context?.percent;\n\tconst contextTokens = context?.tokens;\n\tif (\n\t\tcontext &&\n\t\tcontextPercent !== undefined &&\n\t\tcontextPercent !== null &&\n\t\tcontextTokens !== undefined &&\n\t\tcontextTokens !== null\n\t) {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} ${contextPercent.toFixed(1)}% (${contextTokens.toLocaleString()}/${context.contextWindow.toLocaleString()})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} unknown until next provider usage sample\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto-compaction:\")} ${host.session.autoCompactionEnabled ? \"enabled\" : \"disabled\"}\\n`;\n\tconst compactionGates = stats.compactionGates ?? {\n\t\tgateFailures: 0,\n\t\tdeterministicGapFills: 0,\n\t\tcompactionsWithGateFailures: 0,\n\t\tchecks: {},\n\t};\n\tinfo += `${theme.fg(\"dim\", \"Compaction gate failures:\")} ${compactionGates.gateFailures} (${compactionGates.deterministicGapFills} deterministic gap-fill)\\n`;\n\tconst failingChecks = Object.entries(compactionGates.checks).sort(\n\t\t([leftName, left], [rightName, right]) => right.failures - left.failures || leftName.localeCompare(rightName),\n\t);\n\tif (failingChecks.length > 0) {\n\t\tconst visibleChecks = failingChecks.slice(0, 3).map(([check, checkStats]) => {\n\t\t\tlet score = \"\";\n\t\t\tif (checkStats.minScore !== undefined && checkStats.maxScore !== undefined) {\n\t\t\t\tconst range =\n\t\t\t\t\tcheckStats.minScore === checkStats.maxScore\n\t\t\t\t\t\t? checkStats.minScore.toFixed(2)\n\t\t\t\t\t\t: `${checkStats.minScore.toFixed(2)}-${checkStats.maxScore.toFixed(2)}`;\n\t\t\t\tconst threshold =\n\t\t\t\t\tcheckStats.threshold === undefined\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: ` ${checkStats.comparator === \"maximum\" ? \">\" : \"<\"} ${checkStats.threshold.toFixed(2)}`;\n\t\t\t\tscore = ` (${range}${threshold})`;\n\t\t\t}\n\t\t\treturn `${check} x${checkStats.failures}${score}`;\n\t\t});\n\t\tif (failingChecks.length > visibleChecks.length) {\n\t\t\tvisibleChecks.push(`+${failingChecks.length - visibleChecks.length} more`);\n\t\t}\n\t\tinfo += `${theme.fg(\"dim\", \"Failing compaction checks:\")} ${visibleChecks.join(\"; \")}\\n`;\n\t}\n\tif (isChatGptSubscription) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} not applicable to ChatGPT subscription usage\\n`;\n\t} else if (costGuard) {\n\t\tconst status = costGuard.over ? \"over\" : \"ok\";\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} ${status} $${costGuard.estUsd.toFixed(4)}/$${costGuard.thresholdUsd.toFixed(4)} (${costGuard.action})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} disabled\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn:\")} ${autoLearn.enabled ? \"enabled\" : \"disabled\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Scavenger model:\")} ${autoLearn.model || \"active\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Reflection review:\")} ${autoLearn.reflectionReview ? \"enabled\" : \"disabled\"} (${autoLearn.reflectionMinToolCalls} tool-call trigger)\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn concurrency:\")} ${autoLearn.maxConcurrentLearners} learner(s), ${autoLearn.cooldownMinutes}m cooldown\\n\\n`;\n\n\tinfo += `${theme.bold(\"Model Router\")}\\n`;\n\tinfo += `${host.session.getModelRouterStatus((label) => theme.fg(\"dim\", label))}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Manual controls\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/compact\")}: compact the active context now\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/settings\")}: adjust Auto Learn, cost guard, compaction, and model-router config\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/auto-learn status|run\")}: inspect or launch background learning\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/context\")}: inspect provider-visible context contributors without model tokens\\n`;\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(info, 1, 0));\n\thost.ui.requestRender();\n}\n\nexport function handleChangelogCommand(host: ChangelogReportHost): void {\n\tconst changelogPath = getChangelogPath();\n\tconst allEntries = parseChangelog(changelogPath);\n\n\tconst changelogMarkdown =\n\t\tallEntries.length > 0\n\t\t\t? allEntries\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.map((e) => e.content)\n\t\t\t\t\t.join(\"\\n\\n\")\n\t\t\t: \"No changelog entries found.\";\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleHotkeysCommand(host: HotkeysReportHost): void {\n\t// Navigation keybindings\n\tconst cursorUp = host.getEditorKeyDisplay(\"tui.editor.cursorUp\");\n\tconst cursorDown = host.getEditorKeyDisplay(\"tui.editor.cursorDown\");\n\tconst cursorLeft = host.getEditorKeyDisplay(\"tui.editor.cursorLeft\");\n\tconst cursorRight = host.getEditorKeyDisplay(\"tui.editor.cursorRight\");\n\tconst cursorWordLeft = host.getEditorKeyDisplay(\"tui.editor.cursorWordLeft\");\n\tconst cursorWordRight = host.getEditorKeyDisplay(\"tui.editor.cursorWordRight\");\n\tconst cursorLineStart = host.getEditorKeyDisplay(\"tui.editor.cursorLineStart\");\n\tconst cursorLineEnd = host.getEditorKeyDisplay(\"tui.editor.cursorLineEnd\");\n\tconst jumpForward = host.getEditorKeyDisplay(\"tui.editor.jumpForward\");\n\tconst jumpBackward = host.getEditorKeyDisplay(\"tui.editor.jumpBackward\");\n\tconst pageUp = host.getEditorKeyDisplay(\"tui.editor.pageUp\");\n\tconst pageDown = host.getEditorKeyDisplay(\"tui.editor.pageDown\");\n\n\t// Editing keybindings\n\tconst submit = host.getEditorKeyDisplay(\"tui.input.submit\");\n\tconst newLine = host.getEditorKeyDisplay(\"tui.input.newLine\");\n\tconst deleteWordBackward = host.getEditorKeyDisplay(\"tui.editor.deleteWordBackward\");\n\tconst deleteWordForward = host.getEditorKeyDisplay(\"tui.editor.deleteWordForward\");\n\tconst deleteToLineStart = host.getEditorKeyDisplay(\"tui.editor.deleteToLineStart\");\n\tconst deleteToLineEnd = host.getEditorKeyDisplay(\"tui.editor.deleteToLineEnd\");\n\tconst yank = host.getEditorKeyDisplay(\"tui.editor.yank\");\n\tconst yankPop = host.getEditorKeyDisplay(\"tui.editor.yankPop\");\n\tconst undo = host.getEditorKeyDisplay(\"tui.editor.undo\");\n\tconst tab = host.getEditorKeyDisplay(\"tui.input.tab\");\n\n\t// App keybindings\n\tconst interrupt = host.getAppKeyDisplay(\"app.interrupt\");\n\tconst clear = host.getAppKeyDisplay(\"app.clear\");\n\tconst exit = host.getAppKeyDisplay(\"app.exit\");\n\tconst suspend = host.getAppKeyDisplay(\"app.suspend\");\n\tconst cycleThinkingLevel = host.getAppKeyDisplay(\"app.thinking.cycle\");\n\tconst cycleModelForward = host.getAppKeyDisplay(\"app.model.cycleForward\");\n\tconst selectModel = host.getAppKeyDisplay(\"app.model.select\");\n\tconst expandTools = host.getAppKeyDisplay(\"app.tools.expand\");\n\tconst toggleThinking = host.getAppKeyDisplay(\"app.thinking.toggle\");\n\tconst externalEditor = host.getAppKeyDisplay(\"app.editor.external\");\n\tconst cycleModelBackward = host.getAppKeyDisplay(\"app.model.cycleBackward\");\n\tconst followUp = host.getAppKeyDisplay(\"app.message.followUp\");\n\tconst dequeue = host.getAppKeyDisplay(\"app.message.dequeue\");\n\tconst pasteImage = host.getAppKeyDisplay(\"app.clipboard.pasteImage\");\n\n\tlet hotkeys = `\n**Navigation**\n| Key | Action |\n|-----|--------|\n| \\`${cursorUp}\\` / \\`${cursorDown}\\` / \\`${cursorLeft}\\` / \\`${cursorRight}\\` | Move cursor / browse history (Up when empty) |\n| \\`${cursorWordLeft}\\` / \\`${cursorWordRight}\\` | Move by word |\n| \\`${cursorLineStart}\\` | Start of line |\n| \\`${cursorLineEnd}\\` | End of line |\n| \\`${jumpForward}\\` | Jump forward to character |\n| \\`${jumpBackward}\\` | Jump backward to character |\n| \\`${pageUp}\\` / \\`${pageDown}\\` | Scroll by page |\n\n**Editing**\n| Key | Action |\n|-----|--------|\n| \\`${submit}\\` | Send message |\n| \\`${newLine}\\` | New line${process.platform === \"win32\" ? \" (Ctrl+Enter on Windows Terminal)\" : \"\"} |\n| \\`${deleteWordBackward}\\` | Delete word backwards |\n| \\`${deleteWordForward}\\` | Delete word forwards |\n| \\`${deleteToLineStart}\\` | Delete to start of line |\n| \\`${deleteToLineEnd}\\` | Delete to end of line |\n| \\`${yank}\\` | Paste the most-recently-deleted text |\n| \\`${yankPop}\\` | Cycle through the deleted text after pasting |\n| \\`${undo}\\` | Undo |\n\n**Other**\n| Key | Action |\n|-----|--------|\n| \\`${tab}\\` | Path completion / accept autocomplete |\n| \\`${interrupt}\\` | Cancel autocomplete / abort streaming |\n| \\`${clear}\\` | Clear editor (first) / exit (second) |\n| \\`${exit}\\` | Exit (when editor is empty) |\n| \\`${suspend}\\` | Suspend to background |\n| \\`${cycleThinkingLevel}\\` | Cycle thinking level |\n| \\`${cycleModelForward}\\` / \\`${cycleModelBackward}\\` | Cycle models |\n| \\`${selectModel}\\` | Open model selector |\n| \\`${expandTools}\\` | Toggle tool output expansion |\n| \\`${toggleThinking}\\` | Toggle thinking block visibility |\n| \\`${externalEditor}\\` | Edit message in external editor |\n| \\`${followUp}\\` | Queue follow-up message |\n| \\`${dequeue}\\` | Restore queued messages |\n| \\`${pasteImage}\\` | Paste image from clipboard |\n| \\`/\\` | Slash commands |\n| \\`!\\` | Run bash command |\n| \\`!!\\` | Run bash command (excluded from context) |\n`;\n\n\t// Add extension-registered shortcuts\n\tconst extensionRunner = host.session.extensionRunner;\n\tconst shortcuts = extensionRunner.getShortcuts(host.keybindings.getEffectiveConfig());\n\tif (shortcuts.size > 0) {\n\t\thotkeys += `\n**Extensions**\n| Key | Action |\n|-----|--------|\n`;\n\t\tfor (const [key, shortcut] of shortcuts) {\n\t\t\tconst description = shortcut.description ?? shortcut.extensionPath;\n\t\t\tconst keyDisplay = formatKeyText(key, { capitalize: true });\n\t\t\thotkeys += `| \\`${keyDisplay}\\` | ${description} |\\n`;\n\t\t}\n\t}\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Keyboard Shortcuts\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleDebugCommand(host: DebugReportHost): void {\n\tconst width = host.ui.terminal.columns;\n\tconst height = host.ui.terminal.rows;\n\tconst allLines = host.ui.render(width);\n\n\tconst debugLogPath = getDebugLogPath();\n\tconst debugData = [\n\t\t`Debug output at ${new Date().toISOString()}`,\n\t\t`Terminal: ${width}x${height}`,\n\t\t`Total lines: ${allLines.length}`,\n\t\t\"\",\n\t\t\"=== All rendered lines with visible widths ===\",\n\t\t...allLines.map((line, idx) => {\n\t\t\tconst vw = visibleWidth(line);\n\t\t\tconst escaped = JSON.stringify(line);\n\t\t\treturn `[${idx}] (w=${vw}) ${escaped}`;\n\t\t}),\n\t\t\"\",\n\t\t\"=== Agent messages (JSONL) ===\",\n\t\t...host.session.messages.map((msg) => JSON.stringify(msg)),\n\t\t\"\",\n\t].join(\"\\n\");\n\n\tfs.mkdirSync(path.dirname(debugLogPath), { recursive: true });\n\tfs.writeFileSync(debugLogPath, debugData);\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(\n\t\tnew Text(`${theme.fg(\"accent\", \"✓ Debug log written\")}\\n${theme.fg(\"muted\", debugLogPath)}`, 1, 1),\n\t);\n\thost.ui.requestRender();\n}\n\nexport function handleArminSaysHi(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new ArminComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function handleDementedDelves(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new EarendilAnnouncementComponent());\n\thost.ui.requestRender();\n}\n\nexport function handleDaxnuts(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DaxnutsComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function checkDaxnutsEasterEgg(host: ReportRenderHost, model: { provider: string; id: string }): void {\n\tif (model.provider === \"opencode\" && model.id.toLowerCase().includes(\"kimi-k2.5\")) {\n\t\thandleDaxnuts(host);\n\t}\n}\n"]}
@@ -18,7 +18,7 @@ import type { AgentSession, GoalContinuationLoopOptions, GoalContinuationLoopRes
18
18
  import type { AgentSessionRuntime } from "../../core/agent-session-runtime.ts";
19
19
  import type { ExtensionCommandContext } from "../../core/extensions/index.ts";
20
20
  import { type GoalStateRevision } from "../../core/goals/goal-lifecycle.ts";
21
- import type { GoalState } from "../../core/goals/goal-state.ts";
21
+ import { type GoalState } from "../../core/goals/goal-state.ts";
22
22
  import type { KeybindingsManager } from "../../core/keybindings.ts";
23
23
  import { MissingSessionCwdError } from "../../core/session-cwd.ts";
24
24
  import type { SettingsManager } from "../../core/settings-manager.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"session-flow-commands.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/session-flow-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,EAAgB,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,KAAK,EACX,YAAY,EACZ,2BAA2B,EAC3B,0BAA0B,EAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAIN,KAAK,iBAAiB,EAMtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAMpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,OAAO,EAMN,KAAK,cAAc,EAEnB,MAAM,gCAAgC,CAAC;AAExC,O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AG,SAAS,CAAA;KAAE,CAAC;IACtE,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC;IAClC,QAAQ,CAAC,EAAE,EAAE;QAAE,aAAa,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;CAC3C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,sBAAsB,GAAG,IAAI,CAuCvE"}
@@ -14,6 +14,7 @@ import { randomUUID } from "node:crypto";
14
14
  import { Loader, Spacer, Text } from "@caupulican/pi-tui";
15
15
  import { hasCostSummarySignal } from "../../core/cost/cost-summary.js";
16
16
  import { cancelPersistedGoal, clearPersistedGoal, editPersistedGoal, getGoalStateRevision, pausePersistedGoal, replaceGoal, resumeGoal, resumePersistedGoal, } from "../../core/goals/goal-lifecycle.js";
17
+ import { isGoalExecutionActive } from "../../core/goals/goal-state.js";
17
18
  import { applyGoalAction, completeGoalManually } from "../../core/goals/goal-tool-core.js";
18
19
  import { findExactModelReferenceMatch, resolveModelScope, resolveModelScopeWithDiagnostics, } from "../../core/model-resolver.js";
19
20
  import { MissingSessionCwdError } from "../../core/session-cwd.js";
@@ -512,7 +513,7 @@ export async function handleGoalCommand(host, text) {
512
513
  host.showError(edited.error);
513
514
  return;
514
515
  }
515
- if (edited.state.status === "active")
516
+ if (isGoalExecutionActive(edited.state.status))
516
517
  host.session.restoreGoalRuntimeAfterResume();
517
518
  host.showStatus("Goal updated.");
518
519
  host.refreshAutonomyFooterStatus();
@@ -581,7 +582,7 @@ export async function handleGoalCommand(host, text) {
581
582
  return;
582
583
  }
583
584
  host.session.saveGoalStateSnapshot(reopened.state, getGoalStateRevision(current));
584
- if (reopened.state.status === "active")
585
+ if (isGoalExecutionActive(reopened.state.status))
585
586
  host.session.restoreGoalRuntimeAfterResume();
586
587
  host.showStatus(`Requirement '${requirementId}' reopened${current.status === "blocked" ? " and goal resumed" : ""}.`);
587
588
  host.refreshAutonomyFooterStatus();
@@ -1 +1 @@
1
- {"version":3,"file":"session-flow-commands.js","sourceRoot":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C,UAAU,GAAG,CAAC,EAAE,CAAC;QACjC,IAAI,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,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"]}
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,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,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, isGoalExecutionActive } 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 (isGoalExecutionActive(edited.state.status)) 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 (isGoalExecutionActive(reopened.state.status)) 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"]}
package/docs/providers.md CHANGED
@@ -18,6 +18,9 @@ Use `/login` in interactive mode, then select a provider, or pass one directly (
18
18
  - ChatGPT Plus/Pro (Codex)
19
19
  - Claude Pro/Max
20
20
  - GitHub Copilot
21
+ - xAI (Grok/X subscription) — `/login xai`. Signs in with SuperGrok or X Premium via device-code OAuth; `XAI_API_KEY` remains available as an API key under [API Keys](#api-keys) for metered access instead.
22
+ - Kimi Code (subscription) — `/login kimi-coding`.
23
+ - OpenRouter — `/login openrouter`. This OAuth flow exchanges a browser sign-in for a permanent OpenRouter API key rather than a metered/subscription credential, so it does not get the subscription-hop failover behavior described below.
21
24
 
22
25
  Use `/logout` to clear credentials. Tokens are stored per provider in `~/.pi/agent/auth.json` and auto-refresh when expired.
23
26