@deepseek-harness-tui/dsh-tui 0.18.0 → 0.20.0

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 (318) hide show
  1. package/README.md +90 -59
  2. package/bin/dsh-tui.js +46 -3
  3. package/cordis.patch.yml +5 -3
  4. package/cordis.yml +3 -2
  5. package/guide/dsh-tui-guide/codex-backend.en.md +2 -2
  6. package/guide/dsh-tui-guide/codex-backend.md +2 -2
  7. package/guide/dsh-tui-guide/configuration.en.md +7 -2
  8. package/guide/dsh-tui-guide/configuration.md +7 -2
  9. package/guide/dsh-tui-guide/getting-started.en.md +168 -4
  10. package/guide/dsh-tui-guide/getting-started.md +121 -14
  11. package/guide/dsh-tui-guide/interaction.en.md +11 -10
  12. package/guide/dsh-tui-guide/interaction.md +5 -4
  13. package/guide/dsh-tui-guide/user-guide.en.md +12 -6
  14. package/guide/dsh-tui-guide/user-guide.md +12 -6
  15. package/lib/settings.json +24 -8
  16. package/lib/types/adapter/ports/channel-ui.d.ts +10 -7
  17. package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
  18. package/lib/types/adapter/ports/channel-view.d.ts +67 -8
  19. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  20. package/lib/types/agent/events.d.ts +14 -5
  21. package/lib/types/agent/events.d.ts.map +1 -1
  22. package/lib/types/agent/session.d.ts +5 -0
  23. package/lib/types/agent/session.d.ts.map +1 -1
  24. package/lib/types/backends/claude/tools.d.ts.map +1 -1
  25. package/lib/types/backends/claude/tools.js +8 -3
  26. package/lib/types/backends/claude/translate/core.d.ts +2 -2
  27. package/lib/types/backends/claude/translate/core.d.ts.map +1 -1
  28. package/lib/types/backends/claude/translate/core.js +10 -6
  29. package/lib/types/backends/codex/session/commands.d.ts +2 -0
  30. package/lib/types/backends/codex/session/commands.d.ts.map +1 -1
  31. package/lib/types/backends/codex/session/commands.js +8 -4
  32. package/lib/types/backends/codex/session/input.d.ts +11 -7
  33. package/lib/types/backends/codex/session/input.d.ts.map +1 -1
  34. package/lib/types/backends/codex/session/input.js +68 -15
  35. package/lib/types/backends/codex/session/session.d.ts.map +1 -1
  36. package/lib/types/backends/codex/session/session.js +2 -3
  37. package/lib/types/backends/codex/translate/presentation.d.ts.map +1 -1
  38. package/lib/types/backends/codex/translate/presentation.js +5 -2
  39. package/lib/types/channel/interaction.d.ts.map +1 -1
  40. package/lib/types/channel/interaction.js +1 -0
  41. package/lib/types/channel/permissions.d.ts +15 -0
  42. package/lib/types/channel/permissions.d.ts.map +1 -1
  43. package/lib/types/channel/permissions.js +28 -0
  44. package/lib/types/channel/projection.d.ts.map +1 -1
  45. package/lib/types/channel/projection.js +89 -11
  46. package/lib/types/channel/questions.d.ts +45 -3
  47. package/lib/types/channel/questions.d.ts.map +1 -1
  48. package/lib/types/channel/questions.js +43 -0
  49. package/lib/types/channel/sanitize.d.ts.map +1 -1
  50. package/lib/types/channel/sanitize.js +8 -4
  51. package/lib/types/channel/subagent-failure.d.ts +49 -0
  52. package/lib/types/channel/subagent-failure.d.ts.map +1 -0
  53. package/lib/types/channel/subagent-failure.js +59 -0
  54. package/lib/types/channel/transcript.d.ts +17 -0
  55. package/lib/types/channel/transcript.d.ts.map +1 -1
  56. package/lib/types/channel/transcript.js +35 -0
  57. package/lib/types/commands.js +2 -2
  58. package/lib/types/components/MessageList.d.ts.map +1 -1
  59. package/lib/types/components/MessageList.js +14 -10
  60. package/lib/types/components/PromptInput.d.ts.map +1 -1
  61. package/lib/types/components/PromptInput.js +61 -6
  62. package/lib/types/components/SplitDiffView.d.ts.map +1 -1
  63. package/lib/types/components/SplitDiffView.js +3 -2
  64. package/lib/types/components/StarPrompt.d.ts +5 -3
  65. package/lib/types/components/StarPrompt.d.ts.map +1 -1
  66. package/lib/types/components/StarPrompt.js +56 -6
  67. package/lib/types/components/SubagentCard.d.ts.map +1 -1
  68. package/lib/types/components/SubagentCard.js +1 -1
  69. package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
  70. package/lib/types/components/SubagentDashboard.js +9 -2
  71. package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
  72. package/lib/types/components/SubagentDetailScene.js +1 -1
  73. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  74. package/lib/types/components/messages/AssistantToolUseMessage.js +126 -25
  75. package/lib/types/components/questions/AskUserQuestionPanel.d.ts +5 -8
  76. package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
  77. package/lib/types/components/questions/AskUserQuestionPanel.js +7 -4
  78. package/lib/types/components/questions/PlanReviewPanel.d.ts +3 -6
  79. package/lib/types/components/questions/PlanReviewPanel.d.ts.map +1 -1
  80. package/lib/types/components/revealScope.d.ts +15 -0
  81. package/lib/types/components/revealScope.d.ts.map +1 -0
  82. package/lib/types/components/revealScope.js +17 -0
  83. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +34 -1
  84. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
  85. package/lib/types/components/sidePanel/btw/BtwComposer.js +108 -7
  86. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
  87. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +1 -1
  88. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts.map +1 -1
  89. package/lib/types/components/sidePanel/btw/BtwThreadScene.js +1 -1
  90. package/lib/types/components/smoothReveal.d.ts +36 -6
  91. package/lib/types/components/smoothReveal.d.ts.map +1 -1
  92. package/lib/types/components/smoothReveal.js +92 -21
  93. package/lib/types/components/teamRoster.d.ts +6 -3
  94. package/lib/types/components/teamRoster.d.ts.map +1 -1
  95. package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts +4 -14
  96. package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts.map +1 -1
  97. package/lib/types/components/workspaces/HomeWorkspaceRow.js +26 -17
  98. package/lib/types/dsh-adapter/approvals.d.ts +19 -0
  99. package/lib/types/dsh-adapter/approvals.d.ts.map +1 -1
  100. package/lib/types/dsh-adapter/approvals.js +17 -1
  101. package/lib/types/dsh-adapter/backend/session.d.ts.map +1 -1
  102. package/lib/types/dsh-adapter/backend/session.js +12 -0
  103. package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
  104. package/lib/types/dsh-adapter/backend/translate.js +21 -4
  105. package/lib/types/dsh-adapter/channel/attached-context.d.ts +15 -2
  106. package/lib/types/dsh-adapter/channel/attached-context.d.ts.map +1 -1
  107. package/lib/types/dsh-adapter/channel/attached-context.js +26 -3
  108. package/lib/types/dsh-adapter/channel/binding-events.d.ts +3 -0
  109. package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
  110. package/lib/types/dsh-adapter/channel/binding-events.js +43 -2
  111. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts +2 -6
  112. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
  113. package/lib/types/dsh-adapter/channel/context-bookkeeping.js +7 -1
  114. package/lib/types/dsh-adapter/channel/core/compose.d.ts +2 -6
  115. package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
  116. package/lib/types/dsh-adapter/channel/core/compose.js +1 -1
  117. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts.map +1 -1
  118. package/lib/types/dsh-adapter/channel/core/local-actions.js +3 -26
  119. package/lib/types/dsh-adapter/channel/emitter.js +1 -1
  120. package/lib/types/dsh-adapter/channel/extensions.d.ts.map +1 -1
  121. package/lib/types/dsh-adapter/channel/extensions.js +15 -4
  122. package/lib/types/dsh-adapter/channel/input-actions.d.ts +2 -2
  123. package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
  124. package/lib/types/dsh-adapter/channel/input-actions.js +34 -10
  125. package/lib/types/dsh-adapter/channel/input-delivery.d.ts +3 -7
  126. package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
  127. package/lib/types/dsh-adapter/channel/input-delivery.js +14 -5
  128. package/lib/types/dsh-adapter/channel/local-actions.d.ts.map +1 -1
  129. package/lib/types/dsh-adapter/channel/local-actions.js +7 -3
  130. package/lib/types/dsh-adapter/channel/model-actions.d.ts +4 -1
  131. package/lib/types/dsh-adapter/channel/model-actions.d.ts.map +1 -1
  132. package/lib/types/dsh-adapter/channel/model-actions.js +26 -9
  133. package/lib/types/dsh-adapter/channel/model-selection.d.ts +27 -2
  134. package/lib/types/dsh-adapter/channel/model-selection.d.ts.map +1 -1
  135. package/lib/types/dsh-adapter/channel/model-selection.js +81 -37
  136. package/lib/types/dsh-adapter/channel/model-switch.d.ts +1 -1
  137. package/lib/types/dsh-adapter/channel/model-switch.d.ts.map +1 -1
  138. package/lib/types/dsh-adapter/channel/projection-helpers.d.ts.map +1 -1
  139. package/lib/types/dsh-adapter/channel/projection-helpers.js +4 -2
  140. package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
  141. package/lib/types/dsh-adapter/channel/session-rewind.js +6 -2
  142. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
  143. package/lib/types/dsh-adapter/channel/session-tree-actions.js +8 -4
  144. package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
  145. package/lib/types/dsh-adapter/channel/settings-host.js +185 -36
  146. package/lib/types/dsh-adapter/channel/subagent-projection.d.ts +55 -4
  147. package/lib/types/dsh-adapter/channel/subagent-projection.d.ts.map +1 -1
  148. package/lib/types/dsh-adapter/channel/subagent-projection.js +80 -16
  149. package/lib/types/dsh-adapter/channel/subagent-transcript.d.ts +1 -1
  150. package/lib/types/dsh-adapter/channel/subagent-transcript.d.ts.map +1 -1
  151. package/lib/types/dsh-adapter/channel/subagent-transcript.js +6 -5
  152. package/lib/types/dsh-adapter/channel/task-completion.js +2 -10
  153. package/lib/types/dsh-adapter/channel/transcript.d.ts +3 -2
  154. package/lib/types/dsh-adapter/channel/transcript.d.ts.map +1 -1
  155. package/lib/types/dsh-adapter/channel/transcript.js +13 -4
  156. package/lib/types/dsh-adapter/channel/types.d.ts +11 -2
  157. package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
  158. package/lib/types/dsh-adapter/compat/compaction-previews.d.ts +11 -0
  159. package/lib/types/dsh-adapter/compat/compaction-previews.d.ts.map +1 -0
  160. package/lib/types/dsh-adapter/compat/compaction-previews.js +38 -0
  161. package/lib/types/dsh-adapter/compat/messages.d.ts +1 -1
  162. package/lib/types/dsh-adapter/compat/messages.d.ts.map +1 -1
  163. package/lib/types/dsh-adapter/compat/messages.js +2 -2
  164. package/lib/types/dsh-adapter/contract.d.ts +29 -3
  165. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  166. package/lib/types/dsh-adapter/contract.js +48 -5
  167. package/lib/types/dsh-adapter/experimental-bundles.d.ts +5 -0
  168. package/lib/types/dsh-adapter/experimental-bundles.d.ts.map +1 -1
  169. package/lib/types/dsh-adapter/experimental-bundles.js +0 -2
  170. package/lib/types/dsh-adapter/fresh-agent.d.ts +1 -1
  171. package/lib/types/dsh-adapter/fresh-agent.d.ts.map +1 -1
  172. package/lib/types/dsh-adapter/fresh-agent.js +60 -11
  173. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
  174. package/lib/types/dsh-adapter/host-access.js +60 -11
  175. package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
  176. package/lib/types/dsh-adapter/host-contract.d.ts.map +1 -1
  177. package/lib/types/dsh-adapter/host-contract.js +5 -3
  178. package/lib/types/dsh-adapter/host-dsh.d.ts +2 -8
  179. package/lib/types/dsh-adapter/host-dsh.d.ts.map +1 -1
  180. package/lib/types/dsh-adapter/host-dsh.js +30 -6
  181. package/lib/types/dsh-adapter/host-entry.js +4 -0
  182. package/lib/types/dsh-adapter/index.d.ts +9 -1
  183. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  184. package/lib/types/dsh-adapter/index.js +5 -0
  185. package/lib/types/dsh-adapter/oauth/account-notifications.d.ts +73 -0
  186. package/lib/types/dsh-adapter/oauth/account-notifications.d.ts.map +1 -0
  187. package/lib/types/dsh-adapter/oauth/account-notifications.js +250 -0
  188. package/lib/types/dsh-adapter/oauth/bonus.d.ts +34 -9
  189. package/lib/types/dsh-adapter/oauth/bonus.d.ts.map +1 -1
  190. package/lib/types/dsh-adapter/oauth/bonus.js +47 -5
  191. package/lib/types/dsh-adapter/oauth/deepseek.d.ts +7 -2
  192. package/lib/types/dsh-adapter/oauth/deepseek.d.ts.map +1 -1
  193. package/lib/types/dsh-adapter/oauth/deepseek.js +6 -1
  194. package/lib/types/dsh-adapter/oauth/index.d.ts.map +1 -1
  195. package/lib/types/dsh-adapter/oauth/index.js +44 -0
  196. package/lib/types/dsh-adapter/oauth/profiles.d.ts.map +1 -1
  197. package/lib/types/dsh-adapter/oauth/profiles.js +14 -1
  198. package/lib/types/dsh-adapter/oauth/service.d.ts.map +1 -1
  199. package/lib/types/dsh-adapter/oauth/service.js +5 -6
  200. package/lib/types/dsh-adapter/plugin-manage.d.ts +6 -4
  201. package/lib/types/dsh-adapter/plugin-manage.d.ts.map +1 -1
  202. package/lib/types/dsh-adapter/plugin-manage.js +3 -2
  203. package/lib/types/dsh-adapter/plugin.d.ts +237 -6
  204. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  205. package/lib/types/dsh-adapter/plugin.js +751 -67
  206. package/lib/types/dsh-adapter/presets.d.ts +38 -11
  207. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  208. package/lib/types/dsh-adapter/presets.js +46 -17
  209. package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
  210. package/lib/types/dsh-adapter/process-exit.js +1 -1
  211. package/lib/types/dsh-adapter/questions.d.ts +3 -4
  212. package/lib/types/dsh-adapter/questions.d.ts.map +1 -1
  213. package/lib/types/dsh-adapter/questions.js +1 -1
  214. package/lib/types/dsh-adapter/session-list-metadata.js +2 -2
  215. package/lib/types/dsh-adapter/session-projection-store.d.ts +1 -1
  216. package/lib/types/dsh-adapter/session-projection-store.d.ts.map +1 -1
  217. package/lib/types/dsh-adapter/session-projection-store.js +30 -23
  218. package/lib/types/dsh-adapter/sessionTree.d.ts.map +1 -1
  219. package/lib/types/dsh-adapter/sessionTree.js +4 -1
  220. package/lib/types/dsh-adapter/subagents.d.ts +6 -0
  221. package/lib/types/dsh-adapter/subagents.d.ts.map +1 -1
  222. package/lib/types/dsh-adapter/subagents.js +32 -3
  223. package/lib/types/dsh-adapter/team-mode.d.ts +46 -27
  224. package/lib/types/dsh-adapter/team-mode.d.ts.map +1 -1
  225. package/lib/types/dsh-adapter/team-mode.js +157 -29
  226. package/lib/types/dsh-adapter/team-roster.d.ts +53 -18
  227. package/lib/types/dsh-adapter/team-roster.d.ts.map +1 -1
  228. package/lib/types/dsh-adapter/team-roster.js +206 -39
  229. package/lib/types/dsh-adapter/team-tools.d.ts +25 -12
  230. package/lib/types/dsh-adapter/team-tools.d.ts.map +1 -1
  231. package/lib/types/dsh-adapter/team-tools.js +81 -26
  232. package/lib/types/dsh-adapter/tool-scope.d.ts +24 -0
  233. package/lib/types/dsh-adapter/tool-scope.d.ts.map +1 -0
  234. package/lib/types/dsh-adapter/tool-scope.js +127 -0
  235. package/lib/types/dsh-adapter/types.d.ts +2 -1
  236. package/lib/types/dsh-adapter/types.d.ts.map +1 -1
  237. package/lib/types/heldInputs.d.ts +55 -16
  238. package/lib/types/heldInputs.d.ts.map +1 -1
  239. package/lib/types/heldInputs.js +277 -41
  240. package/lib/types/i18n.d.ts +292 -20
  241. package/lib/types/i18n.d.ts.map +1 -1
  242. package/lib/types/i18n.js +89 -13
  243. package/lib/types/ink/components/App.d.ts +2 -0
  244. package/lib/types/ink/components/App.d.ts.map +1 -1
  245. package/lib/types/ink/components/App.js +8 -0
  246. package/lib/types/ink/dom.d.ts.map +1 -1
  247. package/lib/types/ink/dom.js +13 -3
  248. package/lib/types/ink/events/input-event.d.ts.map +1 -1
  249. package/lib/types/ink/events/input-event.js +7 -6
  250. package/lib/types/ink/flush-tick.d.ts +6 -0
  251. package/lib/types/ink/flush-tick.d.ts.map +1 -1
  252. package/lib/types/ink/flush-tick.js +31 -0
  253. package/lib/types/ink/hit-test.d.ts +2 -0
  254. package/lib/types/ink/hit-test.d.ts.map +1 -1
  255. package/lib/types/ink/hit-test.js +10 -0
  256. package/lib/types/ink/hooks/use-program-status.d.ts +1 -1
  257. package/lib/types/ink/hooks/use-program-status.d.ts.map +1 -1
  258. package/lib/types/ink/hooks/use-program-status.js +3 -2
  259. package/lib/types/ink/hooks/use-terminal-title.d.ts +15 -0
  260. package/lib/types/ink/hooks/use-terminal-title.d.ts.map +1 -1
  261. package/lib/types/ink/hooks/use-terminal-title.js +23 -3
  262. package/lib/types/ink/ink.d.ts +1 -0
  263. package/lib/types/ink/ink.d.ts.map +1 -1
  264. package/lib/types/ink/ink.js +7 -4
  265. package/lib/types/ink/jumpback-state.d.ts +33 -0
  266. package/lib/types/ink/jumpback-state.d.ts.map +1 -0
  267. package/lib/types/ink/jumpback-state.js +51 -0
  268. package/lib/types/ink/jumpback.d.ts +78 -0
  269. package/lib/types/ink/jumpback.d.ts.map +1 -0
  270. package/lib/types/ink/jumpback.js +515 -0
  271. package/lib/types/ink/log-update.js +37 -14
  272. package/lib/types/ink/notify-helper/activate.cs +836 -0
  273. package/lib/types/ink/notify-helper/compile.d.ts +30 -0
  274. package/lib/types/ink/notify-helper/compile.d.ts.map +1 -0
  275. package/lib/types/ink/notify-helper/compile.js +235 -0
  276. package/lib/types/ink/parse-keypress.d.ts.map +1 -1
  277. package/lib/types/ink/parse-keypress.js +25 -0
  278. package/lib/types/ink/terminal-notification-windows.d.ts +8 -4
  279. package/lib/types/ink/terminal-notification-windows.d.ts.map +1 -1
  280. package/lib/types/ink/terminal-notification-windows.js +14 -21
  281. package/lib/types/ink/terminal-notification.d.ts +31 -2
  282. package/lib/types/ink/terminal-notification.d.ts.map +1 -1
  283. package/lib/types/ink/terminal-notification.js +51 -0
  284. package/lib/types/ink/terminal.d.ts +15 -3
  285. package/lib/types/ink/terminal.d.ts.map +1 -1
  286. package/lib/types/ink/terminal.js +38 -9
  287. package/lib/types/screens/AgentTranscriptScene.d.ts.map +1 -1
  288. package/lib/types/screens/AgentTranscriptScene.js +1 -1
  289. package/lib/types/screens/Chat.d.ts +4 -3
  290. package/lib/types/screens/Chat.d.ts.map +1 -1
  291. package/lib/types/screens/Chat.js +81 -11
  292. package/lib/types/screens/SessionSupervisor.d.ts +3 -6
  293. package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
  294. package/lib/types/screens/SessionSupervisor.js +5 -8
  295. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts +1 -2
  296. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -1
  297. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +2 -2
  298. package/lib/types/screens/sessionSupervisor/model.d.ts +1 -1
  299. package/lib/types/screens/sessionSupervisor/model.js +1 -1
  300. package/lib/types/sessionMounts.d.ts +12 -5
  301. package/lib/types/sessionMounts.d.ts.map +1 -1
  302. package/lib/types/sessionMounts.js +33 -6
  303. package/lib/types/settings/definitions.d.ts +12 -0
  304. package/lib/types/settings/definitions.d.ts.map +1 -1
  305. package/lib/types/settings/definitions.js +15 -7
  306. package/lib/types/update.d.ts +412 -20
  307. package/lib/types/update.d.ts.map +1 -1
  308. package/lib/types/update.js +2094 -193
  309. package/lib/types/updateHost.d.ts +198 -0
  310. package/lib/types/updateHost.d.ts.map +1 -0
  311. package/lib/types/updateHost.js +608 -0
  312. package/lib/types/utils/processName.d.ts +16 -0
  313. package/lib/types/utils/processName.d.ts.map +1 -0
  314. package/lib/types/utils/processName.js +27 -0
  315. package/package.json +114 -111
  316. package/presets/liangshen/agent.cordis.yml +4 -0
  317. package/tui-profile/feed/README.md +1 -1
  318. package/tui-profile/feed/first-party.json +1 -1
@@ -5,6 +5,7 @@ const userCancelled = (error) => typeof error === 'object' && error !== null &&
5
5
  function storeRequest(request, signal) {
6
6
  return {
7
7
  signal,
8
+ ...(request.agentId === undefined ? {} : { agentId: request.agentId }),
8
9
  questions: request.questions.map((question, index) => ({
9
10
  id: String(index),
10
11
  question: question.question,
@@ -116,6 +116,8 @@ export declare class PermissionStore implements PermissionPanelSource {
116
116
  private seq;
117
117
  /** Stable reference between mutations (useSyncExternalStore contract). */
118
118
  private snapshotCache;
119
+ /** Per-park observer (see {@link setOnPark}); undefined = no observer. */
120
+ private onPark;
119
121
  subscribe(listener: () => void): () => void;
120
122
  getSnapshot(): PermissionPanelSnapshot | null;
121
123
  /** Every parked prompt (active first), in the backend's own shape. */
@@ -128,6 +130,13 @@ export declare class PermissionStore implements PermissionPanelSource {
128
130
  readonly reason?: string;
129
131
  readonly command?: string;
130
132
  } | undefined;
133
+ /**
134
+ * Watch every park — the non-DSH counterpart of the approval-request
135
+ * listener. Called once per parked prompt, a queued one included (each
136
+ * still needs a decision); settling or withdrawing never calls it. Unset
137
+ * (the default) leaves the store's behaviour unchanged.
138
+ */
139
+ setOnPark(callback: ((request: PermissionRequestView) => void) | undefined): void;
131
140
  /** Park one prompt; it surfaces once every earlier prompt settled. A
132
141
  * duplicate (same session and request id) is refused as cancelled. */
133
142
  park(ask: PermissionAsk): void;
@@ -146,6 +155,12 @@ export declare class PermissionStore implements PermissionPanelSource {
146
155
  private all;
147
156
  private find;
148
157
  private remove;
158
+ /**
159
+ * A notification callback that throws must not wedge the approval queue:
160
+ * the prompt stays parked and the notification is simply lost, exactly
161
+ * like a throwing settle callback.
162
+ */
163
+ private notifyParked;
149
164
  /** A settle callback that throws must not wedge the queue. */
150
165
  private settle;
151
166
  private startNext;
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../src/channel/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAExG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Gb"}
@@ -36,6 +36,8 @@ export class PermissionStore {
36
36
  seq = 0;
37
37
  /** Stable reference between mutations (useSyncExternalStore contract). */
38
38
  snapshotCache = null;
39
+ /** Per-park observer (see {@link setOnPark}); undefined = no observer. */
40
+ onPark;
39
41
  subscribe(listener) {
40
42
  this.listeners.add(listener);
41
43
  return () => { this.listeners.delete(listener); };
@@ -59,6 +61,15 @@ export class PermissionStore {
59
61
  const { toolName, reason, command } = parked.ask.request;
60
62
  return { toolName, ...(reason === undefined ? {} : { reason }), ...(command === undefined ? {} : { command }) };
61
63
  }
64
+ /**
65
+ * Watch every park — the non-DSH counterpart of the approval-request
66
+ * listener. Called once per parked prompt, a queued one included (each
67
+ * still needs a decision); settling or withdrawing never calls it. Unset
68
+ * (the default) leaves the store's behaviour unchanged.
69
+ */
70
+ setOnPark(callback) {
71
+ this.onPark = callback;
72
+ }
62
73
  /** Park one prompt; it surfaces once every earlier prompt settled. A
63
74
  * duplicate (same session and request id) is refused as cancelled. */
64
75
  park(ask) {
@@ -69,6 +80,7 @@ export class PermissionStore {
69
80
  }
70
81
  this.queue.push({ key: String(++this.seq), ask });
71
82
  this.startNext();
83
+ this.notifyParked(ask.request);
72
84
  }
73
85
  /**
74
86
  * The user decided on the active prompt. The outcome's option comes from
@@ -141,6 +153,22 @@ export class PermissionStore {
141
153
  if (at >= 0)
142
154
  this.queue.splice(at, 1);
143
155
  }
156
+ /**
157
+ * A notification callback that throws must not wedge the approval queue:
158
+ * the prompt stays parked and the notification is simply lost, exactly
159
+ * like a throwing settle callback.
160
+ */
161
+ notifyParked(request) {
162
+ const callback = this.onPark;
163
+ if (callback === undefined)
164
+ return;
165
+ try {
166
+ callback(request);
167
+ }
168
+ catch {
169
+ // A failed notification must never block the approval.
170
+ }
171
+ }
144
172
  /** A settle callback that throws must not wedge the queue. */
145
173
  settle(parked, outcome, decision) {
146
174
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../src/channel/projection.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4EACwE;IACxE,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAAA;IACrE;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,CAAA;CAChD;AAID,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,GAAG,SAAS,GAAG,MAAM,CAGpF;AAED,0DAA0D;AAC1D,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,qBAAqB;oBAw9ClE,SAAS,UAAU,EAAE,QAAQ,cAAc,KAAG,IAAI;iBA6CvD,IAAI;2BA1uCM,IAAI;6BAmDF,IAAI;;;;;;;;;;;EAstCnC;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
@@ -3,10 +3,10 @@ import { t } from '../i18n.js';
3
3
  import { logForDebugging } from '../utils/debug.js';
4
4
  import { laneOf } from './activity.js';
5
5
  import { buildQuestionRecord, parseQuestionRecordAnswers, parseQuestionRecordQuestions } from './question-record.js';
6
- import { cleanRenderText, NOTICE_CELLS } from './sanitize.js';
6
+ import { cleanCommandReport, cleanRenderText, NOTICE_CELLS } from './sanitize.js';
7
7
  import { appendLiveOutput } from './live-output.js';
8
8
  import { replaySelectionAttachment } from './selection-record.js';
9
- import { ARGS_PREVIEW_LIMIT, LOCAL_OUTPUT_LIMIT, preview, RESULT_PREVIEW_LIMIT } from './transcript.js';
9
+ import { ARGS_PREVIEW_LIMIT, LOCAL_OUTPUT_LIMIT, preview, previewIndented, RESULT_PREVIEW_LIMIT, trimLocalRows } from './transcript.js';
10
10
  import { addUsageToBucket, emptyCostBuckets, estimateTokens, estimateTokensFraction, usageOutputTokens } from './usage.js';
11
11
  /** Notice keys whose live toast is tracked (a repeat replaces it). */
12
12
  const MAX_KEYED_TOASTS = 32;
@@ -201,7 +201,11 @@ export function createChannelProjection(state, deps) {
201
201
  assistantRowsBySeq.set(row.seq, row);
202
202
  };
203
203
  const openStreaming = (seq) => {
204
- streaming = { id: deps.rowIds.value, kind: 'assistant', text: '', streaming: true, fresh: true, ...seq !== undefined ? { seq } : {} };
204
+ // `fresh` is a LIVE-only claim (channel-view.ts): a replay batch folds the
205
+ // session's own durable deltas through this same factory, and a replayed
206
+ // row that claims freshness makes the transcript typewrite history from
207
+ // its first character on every resume.
208
+ streaming = { id: deps.rowIds.value, kind: 'assistant', text: '', streaming: true, fresh: !replaying, ...seq !== undefined ? { seq } : {} };
205
209
  deps.rowIds.value += 1;
206
210
  appendRow(streaming);
207
211
  indexAssistantRow(streaming);
@@ -663,9 +667,19 @@ export function createChannelProjection(state, deps) {
663
667
  appendRow({ id: deps.rowIds.value, kind: 'notice', text: t('compact-done') });
664
668
  deps.rowIds.value += 1;
665
669
  if (summary) {
666
- appendRow({ id: deps.rowIds.value, kind: 'compact', text: summary });
670
+ appendRow({
671
+ id: deps.rowIds.value, kind: 'compact', text: summary,
672
+ ...(event.compactPreview === undefined ? {} : { compactPreview: event.compactPreview }),
673
+ });
667
674
  deps.rowIds.value += 1;
668
675
  }
676
+ // A partial checkpoint does not identify the removed segment mix. Keep
677
+ // the heuristic composition unchanged rather than treating summary size
678
+ // as a net delta; the host meter remains authoritative for occupancy.
679
+ if (event.compactionScope === 'partial') {
680
+ deps.resetContextWarning();
681
+ return;
682
+ }
669
683
  // The checkpoint replaces the whole pre-compact surface. Occupancy
670
684
  // needs no chars/4 rewrite here: a DSH host's token meter folds this
671
685
  // same event and reprices the surface by its logged shadow price (the
@@ -691,11 +705,50 @@ export function createChannelProjection(state, deps) {
691
705
  }
692
706
  // Command output a backend recorded as an input (Claude: `!!` output
693
707
  // sent on to the model): live, the channel already showed the command
694
- // and its output; a replay restores the output row.
708
+ // and its output; a replay restores the output row. A backend command
709
+ // that answers itself (`/usage`, `/diff`) has no channel-side echo, and
710
+ // marks its record `displayLive` so the live pass draws it too.
695
711
  if (event.source === 'command-output') {
696
- if (replaying && event.text !== '') {
697
- appendRow({ id: deps.rowIds.value, kind: 'local-output', text: preview(event.text, LOCAL_OUTPUT_LIMIT), seq: event.seq });
698
- deps.rowIds.value += 1;
712
+ if ((replaying || event.displayLive === true) && event.text !== '') {
713
+ if (event.displayLive === true) {
714
+ // A backend command's own report (`/usage` windows, a git diff): the
715
+ // same bounded shape `pushLocal` uses for registry reports — 200
716
+ // lines, 64K UTF-16 units, 4000 cells per line, ANSI/C0 stripped,
717
+ // indentation and blank rows kept; a trailing newline is not a row.
718
+ const report = cleanCommandReport(event.text);
719
+ // A terminator-only report has nothing to draw: a lone title row
720
+ // would read as a render failure. The channel-side sink keeps the
721
+ // same guard, so both shapes stay identical.
722
+ if (report.lines.length === 0 && !report.truncated)
723
+ return;
724
+ // The `local` title is the block boundary `trimLocalRows` relies on
725
+ // (and tells the reader which command produced the report). `label`
726
+ // is a neutral event field, so it takes the same render sanitizer as
727
+ // the body instead of reaching the row verbatim; a label that cleans
728
+ // to nothing falls back to the neutral title rather than drawing an
729
+ // empty row.
730
+ const title = cleanRenderText(event.label ?? '', NOTICE_CELLS) || t('command-output-title');
731
+ trimLocalRows(state.rows, report.lines.length + 1 + Number(report.truncated));
732
+ appendRow({ id: deps.rowIds.value, kind: 'local', text: title, seq: event.seq });
733
+ deps.rowIds.value += 1;
734
+ for (const line of report.lines) {
735
+ // `cleanCommandReport` already bounded the line in cells; this
736
+ // call only normalizes newlines and blank rows (the 65K limit can
737
+ // never cut here — a 240 limit would undo the report budget).
738
+ appendRow({ id: deps.rowIds.value, kind: 'local-output', text: previewIndented(line, 65_536), seq: event.seq });
739
+ deps.rowIds.value += 1;
740
+ }
741
+ if (report.truncated) {
742
+ appendRow({ id: deps.rowIds.value, kind: 'local-output', text: t('command-output-truncated'), seq: event.seq });
743
+ deps.rowIds.value += 1;
744
+ }
745
+ }
746
+ else {
747
+ // `!`/`!!` output keeps the live shape the channel already showed
748
+ // (one flattened row): the replay must not disagree with it.
749
+ appendRow({ id: deps.rowIds.value, kind: 'local-output', text: preview(event.text, LOCAL_OUTPUT_LIMIT), seq: event.seq });
750
+ deps.rowIds.value += 1;
751
+ }
699
752
  }
700
753
  return;
701
754
  }
@@ -960,8 +1013,9 @@ export function createChannelProjection(state, deps) {
960
1013
  // usage-bearing message emits nothing (nothing was measured), and a
961
1014
  // fully successful zero-usage turn stays quiet too.
962
1015
  const outcome = reason.kind === 'completed' ? 'completed'
963
- : reason.kind === 'aborted' || reason.kind === 'interrupted' ? 'interrupted'
964
- : 'error';
1016
+ : reason.kind === 'aborted' && reason.cause === 'disposed' ? 'stopped'
1017
+ : reason.kind === 'aborted' || reason.kind === 'interrupted' ? 'interrupted'
1018
+ : 'error';
965
1019
  // The turn's terminal state is projected from the close reason itself,
966
1020
  // NOT from the ledger below: a turn that emitted no usage-bearing message
967
1021
  // still ended (and can have failed or been cancelled), and the ledger is
@@ -999,6 +1053,12 @@ export function createChannelProjection(state, deps) {
999
1053
  emitTurnSummary();
1000
1054
  return;
1001
1055
  }
1056
+ if (reason.kind === 'aborted' && reason.cause === 'disposed') {
1057
+ appendRow({ id: deps.rowIds.value, kind: 'notice', text: t('session-stopped') });
1058
+ deps.rowIds.value += 1;
1059
+ emitTurnSummary();
1060
+ return;
1061
+ }
1002
1062
  if (reason.kind === 'aborted' || reason.kind === 'interrupted') {
1003
1063
  // A user cancel closes the turn as `aborted`; `interrupted` only
1004
1064
  // appears for crash-orphaned turns. Both user-interruption paths
@@ -1498,10 +1558,28 @@ export function createChannelProjection(state, deps) {
1498
1558
  lastTextDelta.clear();
1499
1559
  // Rows still on screen when a replay starts keep matching by seq, so a
1500
1560
  // replay over painted history reuses them instead of duplicating them.
1561
+ // Everything the replay leaves behind is settled history, so the reused
1562
+ // rows drop their live-only `fresh` claim too: a rebind/resume that
1563
+ // replays over painted rows would otherwise keep typewriting them.
1501
1564
  assistantRowsBySeq.clear();
1502
- for (const row of state.rows)
1565
+ let droppedFresh = false;
1566
+ for (const row of state.rows) {
1567
+ if (row.fresh === true) {
1568
+ delete row.fresh;
1569
+ // Read-view snapshots reuse untouched rows from the previous
1570
+ // revision, so dropping the live claim has to move this row's dirty
1571
+ // revision with it — otherwise a panel keeps serving `fresh: true`.
1572
+ markChannelReadDirty(row);
1573
+ droppedFresh = true;
1574
+ }
1503
1575
  if (row.kind === 'assistant')
1504
1576
  indexAssistantRow(row);
1577
+ }
1578
+ // The array itself is reused whole when its revision matches, before any
1579
+ // row is inspected; move it too or the rows above stay hidden behind the
1580
+ // previous snapshot.
1581
+ if (droppedFresh)
1582
+ markChannelReadDirty(state.rows);
1505
1583
  replaying = true;
1506
1584
  try {
1507
1585
  for (const event of events)
@@ -29,6 +29,24 @@ export interface QuestionOption {
29
29
  readonly label: string;
30
30
  readonly description?: string;
31
31
  }
32
+ /**
33
+ * Presentation intent a panel may branch on. `plan-review` opens the decision
34
+ * card; `approval` is the blocking permission decision the upstream ask-user
35
+ * protocol gained in 0.2.2 (its option labels are caller-named, so the
36
+ * ordinary question layout renders it).
37
+ */
38
+ export type QuestionIntentView = (PlanReviewIntentView & {
39
+ readonly callId?: string;
40
+ }) | {
41
+ readonly kind: 'approval';
42
+ /** Option label granting the scope described by the caller. */
43
+ readonly approve: string;
44
+ /** Option label refusing the requested access. */
45
+ readonly reject: string;
46
+ /** Optional persistent grant, offered only when the caller supports it. */
47
+ readonly always?: string;
48
+ readonly callId?: string;
49
+ };
32
50
  /** One question as the panel renders it. */
33
51
  export interface QuestionItem {
34
52
  readonly id: string;
@@ -40,9 +58,7 @@ export interface QuestionItem {
40
58
  readonly options?: readonly QuestionOption[];
41
59
  readonly multiSelect?: boolean;
42
60
  /** Presentation intent: `plan-review` switches to the decision card. */
43
- readonly intent?: PlanReviewIntentView & {
44
- readonly callId?: string;
45
- };
61
+ readonly intent?: QuestionIntentView;
46
62
  /** Hide the trailing free-text row for pure option questions (wizards). */
47
63
  readonly hideCustomInput?: boolean;
48
64
  /** Pre-checked option labels / default-focused option. */
@@ -58,6 +74,8 @@ export interface QuestionItem {
58
74
  export interface QuestionRequest {
59
75
  readonly questions: readonly QuestionItem[];
60
76
  readonly signal?: AbortSignal;
77
+ /** The asking subagent, when the ask runs inside one. */
78
+ readonly agentId?: string;
61
79
  }
62
80
  /** One committed answer. */
63
81
  export interface QuestionAnswerItem {
@@ -141,6 +159,8 @@ export declare class QuestionStore implements QuestionStoreLike {
141
159
  * nothing changed (a fresh object per call would loop re-renders).
142
160
  */
143
161
  private snapshotCache;
162
+ /** Per-ask observer (see {@link setOnAsk}); undefined = no observer. */
163
+ private onAsk;
144
164
  /**
145
165
  * Subscribe to store changes (useSyncExternalStore contract).
146
166
  * @param listener - Called after every mutation that changes the snapshot.
@@ -158,6 +178,22 @@ export declare class QuestionStore implements QuestionStoreLike {
158
178
  * was mounted for the first key, after the store has already moved.
159
179
  */
160
180
  stillCurrent(key: string): boolean;
181
+ /**
182
+ * Whether this exact ask is still pending (the batch on screen or one queued
183
+ * behind it). A notification queued before the native transport dispatches
184
+ * uses it to drop a toast whose question was answered or cancelled in the
185
+ * meantime; object identity is the only per-ask identity the store keeps.
186
+ * @param request - The request object handed to {@link ask}.
187
+ * @returns True while the batch still waits for an answer.
188
+ */
189
+ hasPendingRequest(request: QuestionRequest): boolean;
190
+ /**
191
+ * Watch every ask — e.g. to raise a notification when a question needs the
192
+ * user. Called once per ask batch, a queued one included (each still needs
193
+ * an answer); answering or interrupting never calls it. Unset (the default)
194
+ * leaves the store's behaviour unchanged.
195
+ */
196
+ setOnAsk(callback: ((request: QuestionRequest) => void) | undefined): void;
161
197
  private emit;
162
198
  /** Rebuild the cached snapshot after any mutation of active/index. */
163
199
  private rebuildSnapshot;
@@ -198,6 +234,12 @@ export declare class QuestionStore implements QuestionStoreLike {
198
234
  cancelCurrent(): void;
199
235
  /** Reject the active and all queued asks (plugin teardown). */
200
236
  rejectAll(): void;
237
+ /**
238
+ * A notification callback that throws must not wedge the question queue:
239
+ * the ask stays queued and the notification is simply lost, exactly like a
240
+ * throwing settle callback.
241
+ */
242
+ private notifyAsk;
201
243
  /** User-initiated cancel — the asker learns the user wants to speak. */
202
244
  private cancel;
203
245
  /** Asker-side interruption: abort signal fired or plugin teardown. */
@@ -1 +1 @@
1
- {"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../../src/channel/questions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE9D,gCAAgC;AAChC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;IAC5C,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACrE,2EAA2E;IAC3E,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAA;IAClC,0DAA0D;IAC1D,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC5C;6CACyC;IACzC,QAAQ,CAAC,IAAI,CAA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AI;IAIZ,sEAAsE;IACtE,OAAO,CAAC,eAAe;IAyBvB;;;;;;;;OAQG;IACH,GAAG,CAAC,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAiC5D,8CAA8C;IAC9C,OAAO,CAAC,SAAS;IAOjB;;;;;OAKG;IACH,aAAa,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI;IAqCjD;;;;OAIG;IACH,cAAc,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI;IAW3C;;;;OAIG;IACH,WAAW,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI;IAWxC,6DAA6D;IAC7D,aAAa,IAAI,IAAI;IAUrB,+DAA+D;IAC/D,SAAS,IAAI,IAAI;IASjB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAUjB,wEAAwE;IACxE,OAAO,CAAC,MAAM;IAId,sEAAsE;IACtE,OAAO,CAAC,IAAI;CAGb"}
@@ -73,6 +73,8 @@ export class QuestionStore {
73
73
  * nothing changed (a fresh object per call would loop re-renders).
74
74
  */
75
75
  snapshotCache = null;
76
+ /** Per-ask observer (see {@link setOnAsk}); undefined = no observer. */
77
+ onAsk;
76
78
  /**
77
79
  * Subscribe to store changes (useSyncExternalStore contract).
78
80
  * @param listener - Called after every mutation that changes the snapshot.
@@ -99,6 +101,30 @@ export class QuestionStore {
99
101
  stillCurrent(key) {
100
102
  return this.snapshotCache?.key === key;
101
103
  }
104
+ /**
105
+ * Whether this exact ask is still pending (the batch on screen or one queued
106
+ * behind it). A notification queued before the native transport dispatches
107
+ * uses it to drop a toast whose question was answered or cancelled in the
108
+ * meantime; object identity is the only per-ask identity the store keeps.
109
+ * @param request - The request object handed to {@link ask}.
110
+ * @returns True while the batch still waits for an answer.
111
+ */
112
+ hasPendingRequest(request) {
113
+ for (const pending of this.active === undefined ? this.queue : [this.active, ...this.queue]) {
114
+ if (pending.request === request)
115
+ return true;
116
+ }
117
+ return false;
118
+ }
119
+ /**
120
+ * Watch every ask — e.g. to raise a notification when a question needs the
121
+ * user. Called once per ask batch, a queued one included (each still needs
122
+ * an answer); answering or interrupting never calls it. Unset (the default)
123
+ * leaves the store's behaviour unchanged.
124
+ */
125
+ setOnAsk(callback) {
126
+ this.onAsk = callback;
127
+ }
102
128
  emit() {
103
129
  for (const listener of this.listeners)
104
130
  listener();
@@ -167,6 +193,7 @@ export class QuestionStore {
167
193
  request.signal?.addEventListener('abort', pending.onAbort, { once: true });
168
194
  this.queue.push(pending);
169
195
  this.startNext();
196
+ this.notifyAsk(request);
170
197
  });
171
198
  }
172
199
  /** Advance to the next queued ask, if any. */
@@ -275,6 +302,22 @@ export class QuestionStore {
275
302
  this.fail(pending);
276
303
  this.emit();
277
304
  }
305
+ /**
306
+ * A notification callback that throws must not wedge the question queue:
307
+ * the ask stays queued and the notification is simply lost, exactly like a
308
+ * throwing settle callback.
309
+ */
310
+ notifyAsk(request) {
311
+ const callback = this.onAsk;
312
+ if (callback === undefined)
313
+ return;
314
+ try {
315
+ callback(request);
316
+ }
317
+ catch {
318
+ // A failed notification must never block the question.
319
+ }
320
+ }
278
321
  /** User-initiated cancel — the asker learns the user wants to speak. */
279
322
  cancel(pending) {
280
323
  pending.reject(this.interruption('the user cancelled ask_user_question', 'ASK_CANCELLED'));
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/channel/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAevE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzE;AAED;mFACmF;AACnF,wBAAgB,kBAAkB,CAAC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,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQhE;AAED;;6CAE6C;AAC7C,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKxD;AAaD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG7E;AAED;;qCAEqC;AACrC,eAAO,MAAM,YAAY,MAAM,CAAA"}
@@ -50,11 +50,15 @@ export function cleanCommandReport(value) {
50
50
  const maxCodeUnits = 65_536;
51
51
  const maxLines = 200;
52
52
  const maxCells = 4000;
53
- let bounded = value.slice(0, maxCodeUnits);
53
+ // A trailing line terminator (`\n`, `\r\n` or a lone `\r`) is not an empty
54
+ // reported row; leaving the `\r` behind would charge a cell/unit to the last
55
+ // line (clipping a 4000-cell line or faking a 64K truncation).
56
+ const raw = value.replace(/\r\n$|[\r\n]$/u, '');
57
+ let bounded = raw.slice(0, maxCodeUnits);
54
58
  // Do not split a Unicode scalar at the allocation boundary.
55
- if (bounded.length < value.length && /[\uD800-\uDBFF]$/u.test(bounded))
59
+ if (bounded.length < raw.length && /[\uD800-\uDBFF]$/u.test(bounded))
56
60
  bounded = bounded.slice(0, -1);
57
- let truncated = bounded.length < value.length;
61
+ let truncated = bounded.length < raw.length;
58
62
  const rows = bounded.split(/\r?\n/u);
59
63
  if (rows.length > maxLines)
60
64
  truncated = true;
@@ -74,7 +78,7 @@ export function cleanCommandReport(value) {
74
78
  }
75
79
  return `${clipped}…`;
76
80
  });
77
- return { lines: value === '' ? [] : lines, truncated };
81
+ return { lines: raw === '' ? [] : lines, truncated };
78
82
  }
79
83
  /**
80
84
  * Sanitize an untrusted (possibly non-string) value. Non-scalars — objects,
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Channel-level failure counts for delegation children.
3
+ *
4
+ * A failed child's own error text stays where the backend put it; this module
5
+ * only counts how many runs a provider answered and how many of those failed,
6
+ * so one broken channel cannot read as "every subagent is broken". It never
7
+ * invents a diagnosis: the per-item `product/stage/category` sentence a
8
+ * product provider emits reaches the transcript as a tool result, not as
9
+ * `SubagentState.error`, so parsing it here would be parsing a field that
10
+ * never carries it.
11
+ */
12
+ import type { SubagentStatus } from '../adapter/ports/channel-view.js';
13
+ export interface ChannelFailureSummary {
14
+ readonly provider: string;
15
+ readonly failed: number;
16
+ /** Runs the provider answered for: `failed + completed`. A user-cancelled
17
+ * child did not get an answer, so cancelling must not dilute the rate that
18
+ * decides a banner. */
19
+ readonly settled: number;
20
+ }
21
+ /**
22
+ * Children the provider answered for, grouped by that provider. `provider` is
23
+ * absent on rows discovered from a durable catalog without a provider name;
24
+ * `''` reaches here from a host registry that reported an empty name. Both are
25
+ * skipped rather than bucketed under a guess.
26
+ *
27
+ * This is a plain count — callers decide what is worth surfacing. Rows that
28
+ * carry `settledRuns` are counted from that history: a continuable child
29
+ * reuses one `agentId` and resets to `running` when it opens the next run, so
30
+ * the live row alone would report at most one failure no matter how often the
31
+ * same child failed. The live row is only the fallback for callers that have
32
+ * no history (older projections, focused tests).
33
+ */
34
+ export declare function summarizeChannelFailures(rows: readonly {
35
+ readonly provider?: string | undefined;
36
+ readonly status: SubagentStatus;
37
+ readonly settledRuns?: readonly {
38
+ readonly provider?: string | undefined;
39
+ readonly status: SubagentStatus;
40
+ }[];
41
+ }[]): ChannelFailureSummary[];
42
+ /**
43
+ * Whether a summary is worth a banner: a switchable product route, at least
44
+ * two failures, and failures at least half of the runs that got an answer.
45
+ * One failed child is business as usual; a channel failing most of what it
46
+ * runs is not.
47
+ */
48
+ export declare function isDegradedChannel(summary: ChannelFailureSummary): boolean;
49
+ //# sourceMappingURL=subagent-failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent-failure.d.ts","sourceRoot":"","sources":["../../../src/channel/subagent-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEtE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB;;4BAEwB;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,SAAS;IACb,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;KAAE,EAAE,CAAA;CAC9G,EAAE,GACF,qBAAqB,EAAE,CAiBzB;AAiBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAGzE"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Children the provider answered for, grouped by that provider. `provider` is
3
+ * absent on rows discovered from a durable catalog without a provider name;
4
+ * `''` reaches here from a host registry that reported an empty name. Both are
5
+ * skipped rather than bucketed under a guess.
6
+ *
7
+ * This is a plain count — callers decide what is worth surfacing. Rows that
8
+ * carry `settledRuns` are counted from that history: a continuable child
9
+ * reuses one `agentId` and resets to `running` when it opens the next run, so
10
+ * the live row alone would report at most one failure no matter how often the
11
+ * same child failed. The live row is only the fallback for callers that have
12
+ * no history (older projections, focused tests).
13
+ */
14
+ export function summarizeChannelFailures(rows) {
15
+ const buckets = new Map();
16
+ for (const row of rows) {
17
+ const runs = row.settledRuns !== undefined && row.settledRuns.length > 0 ? row.settledRuns : [row];
18
+ for (const run of runs) {
19
+ const provider = run.provider === undefined || run.provider === '' ? row.provider : run.provider;
20
+ if (provider === undefined || provider === '')
21
+ continue;
22
+ if (run.status !== 'failed' && run.status !== 'completed')
23
+ continue;
24
+ const bucket = buckets.get(provider) ?? { failed: 0, settled: 0 };
25
+ bucket.settled += 1;
26
+ if (run.status === 'failed')
27
+ bucket.failed += 1;
28
+ buckets.set(provider, bucket);
29
+ }
30
+ }
31
+ return Array.from(buckets, ([provider, bucket]) => ({ provider, ...bucket }))
32
+ .filter(summary => summary.failed > 0)
33
+ .sort((left, right) => right.failed - left.failed || left.provider.localeCompare(right.provider));
34
+ }
35
+ /**
36
+ * Product delegation routes whose provider a user can actually swap: the
37
+ * `provider:` values of the shipped `tool-subagent-*` preset rows for the
38
+ * Claude Code and Codex products.
39
+ *
40
+ * Everything else is excluded on purpose. The built-in `subagent` default, the
41
+ * workflow member lane (`subagent-projection.ts` writes `provider:
42
+ * 'workflow'`), and the Claude backend's per-child `subagent_type` (`Explore`,
43
+ * `general-purpose`, …) are not switchable routes, so a banner offering
44
+ * "switch provider" would be advice nobody can act on. This is a positive
45
+ * list, not an exclusion list: a new backend inventing a provider name must
46
+ * opt in rather than start bannering by default.
47
+ */
48
+ const SWITCHABLE_PRODUCT_PROVIDERS = new Set(['claude-code', 'codex']);
49
+ /**
50
+ * Whether a summary is worth a banner: a switchable product route, at least
51
+ * two failures, and failures at least half of the runs that got an answer.
52
+ * One failed child is business as usual; a channel failing most of what it
53
+ * runs is not.
54
+ */
55
+ export function isDegradedChannel(summary) {
56
+ if (!SWITCHABLE_PRODUCT_PROVIDERS.has(summary.provider))
57
+ return false;
58
+ return summary.failed >= 2 && summary.failed * 2 >= summary.settled;
59
+ }
@@ -14,4 +14,21 @@ export declare const LOCAL_OUTPUT_LIMIT = 240;
14
14
  */
15
15
  export declare const MAX_ROWS = 600;
16
16
  export declare function preview(text: string, limit: number): string;
17
+ /**
18
+ * One report line that keeps its shape: blank rows stay blank and leading
19
+ * indentation survives; a stray newline still cannot become a second row.
20
+ */
21
+ export declare function previewIndented(text: string, limit: number): string;
22
+ /**
23
+ * Keep local rows inside the transcript budget: drop the oldest `local` block
24
+ * (its title plus its `local-output` lines) until the incoming report fits.
25
+ * A run of headerless `local-output` rows (a `!!` replay with no `local`
26
+ * companion) counts as one block — nothing marks a boundary inside it.
27
+ * Local rows cannot be restored from backend history, so nothing else bounds
28
+ * them — `foldRows` deliberately leaves them alone. Shared by `pushLocal`
29
+ * (channel-side reports) and the projector (backend command reports).
30
+ */
31
+ export declare function trimLocalRows(rows: {
32
+ kind: string;
33
+ }[], nextLines: number): void;
17
34
  //# sourceMappingURL=transcript.d.ts.map