@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
@@ -1,21 +1,42 @@
1
1
  /**
2
- * Read side of DSH's experimental Agent Teams: the Lead session's `agentTeam`
3
- * projection (roster + non-deleted task board), folded for the session on
4
- * screen. Inside a teammate it reads the Lead's value, found through the
5
- * teammate header's `parentSession` (another child of the Lead reads none).
2
+ * Read side of DSH Agent Teams: the Lead session's `agentTeam` projection
3
+ * (saved selection + non-deleted task board, and — on older hosts — the
4
+ * durable member roster), folded for the session on screen. Inside a
5
+ * teammate it reads the Lead's value, found through the teammate header's
6
+ * `parentSession` (another child of the Lead reads none on a roster host).
6
7
  *
7
- * The wire value is narrowed locally (`@deepseek-ai/dsh-experimental-agent-team`
8
- * is never imported); a composition without the team service never publishes
9
- * the key and the store stays empty.
8
+ * Two upstream wire shapes are told apart by shape, never by version:
9
+ *
10
+ * - `roster` — DSH `0.2.2-rc.1` and earlier: `agentTeam` carries
11
+ * `{members, tasks, failure?}`. The team exists only while the bundle that
12
+ * mounts the service is on, so an implicit one-member team is no team.
13
+ * - `switch` — DSH `0.2.2-rc.2` and later: `agentTeam` carries
14
+ * `{enabled, tasks, failure?}` and no members; the service ships in
15
+ * `dsh-base` and each root session saves its own selection. Members are the
16
+ * Lead's current subagents, supplied by the parent `subagentCatalog`
17
+ * projection and joined here.
18
+ *
19
+ * Neither package is imported: both wire values are narrowed locally.
10
20
  *
11
21
  * @module
12
22
  */
13
23
  import { attachSessionProjection, createSessionProjectionStore } from './session-projection-store.js';
14
24
  export const TEAM_PROJECTION_KEY = 'agentTeam';
15
- /** The upstream bundle that mounts the team service and tools: the team-mode switch. */
25
+ /**
26
+ * The parent Session's direct-child catalog, and on `switch` hosts the only
27
+ * member source. Payload version 3 rows carry the child's model-facing `name`.
28
+ */
29
+ export const SUBAGENT_CATALOG_KEY = 'subagentCatalog';
30
+ /**
31
+ * The upstream bundle that mounts the team service on `0.2.2-rc.1` and
32
+ * earlier hosts: the legacy switch. `0.2.2-rc.2` retires it (the service and
33
+ * task tools ship in `dsh-base`, switched per root session), so the name only
34
+ * serves the old-host flows and their migration hints.
35
+ */
16
36
  export const TEAM_BUNDLE = '@deepseek-ai/dsh-experimental-agent-team-profile';
17
37
  const PHASES = new Set(['provisioning', 'active', 'failed']);
18
38
  const TASK_STATUSES = new Set(['pending', 'in_progress', 'completed']);
39
+ const LEAD_NAME = 'lead';
19
40
  function isRecord(value) {
20
41
  return value !== null && typeof value === 'object' && !Array.isArray(value);
21
42
  }
@@ -25,74 +46,165 @@ function isStringArray(value) {
25
46
  function asMember(value) {
26
47
  if (!isRecord(value))
27
48
  return undefined;
28
- const { id, name, role, phase, error } = value;
49
+ const { id, name, role, phase, error, description } = value;
29
50
  if (typeof id !== 'string' || typeof name !== 'string')
30
51
  return undefined;
31
52
  if (role !== 'lead' && role !== 'teammate')
32
53
  return undefined;
33
54
  if (typeof phase !== 'string' || !PHASES.has(phase))
34
55
  return undefined;
35
- return { id, name, role, phase: phase, ...typeof error === 'string' ? { error } : {} };
56
+ return {
57
+ id, name, role, phase: phase,
58
+ ...typeof description === 'string' && description !== '' ? { description } : {},
59
+ ...typeof error === 'string' ? { error } : {},
60
+ };
36
61
  }
37
62
  function asTask(value) {
38
63
  if (!isRecord(value))
39
64
  return undefined;
40
- const { id, revision, subject, description, status, blockedBy, writeScopes, ownerName, ready, writeScopeWarnings } = value;
65
+ const { id, revision, subject, description, status, blockedBy, writeScopes, ownerName, owner, ready, writeScopeWarnings } = value;
41
66
  if (typeof id !== 'string' || typeof revision !== 'number' || typeof subject !== 'string' || typeof description !== 'string')
42
67
  return undefined;
43
68
  if (typeof status !== 'string' || !TASK_STATUSES.has(status))
44
69
  return undefined;
45
70
  if (!isStringArray(blockedBy) || !isStringArray(writeScopes) || !isStringArray(writeScopeWarnings) || typeof ready !== 'boolean')
46
71
  return undefined;
72
+ const ownerLabel = typeof ownerName === 'string' ? ownerName : typeof owner === 'string' ? owner : undefined;
47
73
  return {
48
74
  id, revision, subject, description, status: status, blockedBy, writeScopes, ready, writeScopeWarnings,
49
- ...typeof ownerName === 'string' ? { ownerName } : {},
75
+ ...ownerLabel === undefined ? {} : { ownerName: ownerLabel },
50
76
  };
51
77
  }
78
+ /** Narrow one parent catalog wire value; absent/malformed rows are skipped. */
79
+ function asCatalog(value) {
80
+ if (!Array.isArray(value))
81
+ return undefined;
82
+ const children = [];
83
+ for (const row of value) {
84
+ if (!isRecord(row) || typeof row.id !== 'string' || row.id === '')
85
+ continue;
86
+ const name = typeof row.name === 'string' && row.name !== '' ? row.name : undefined;
87
+ const label = typeof row.label === 'string' && row.label !== '' ? row.label : undefined;
88
+ children.push({ id: row.id, ...name === undefined ? {} : { name }, ...label === undefined ? {} : { label } });
89
+ }
90
+ return children;
91
+ }
52
92
  /**
53
- * Narrow one `agentTeam` value into the view the UI renders. A session's
54
- * implicit team (the Lead alone, no task, no failure) is no team: every root
55
- * session publishes that baseline once the service is mounted.
56
- * @param value - Raw projection value.
57
- * @param leadSessionId - The session the value was published for.
58
- * @returns the team view, or `undefined` when there is nothing to show.
93
+ * The Lead plus its named current subagents: what a `switch` host means by
94
+ * "team". The root is always `lead`; unnamed historical children cannot be
95
+ * addressed by name, so they stay out of the roster (the agents surface still
96
+ * lists their subagent rows under the remaining children).
97
+ * @param leadSessionId - Root Session id the `agentTeam` value belongs to.
98
+ * @param catalog - The root's direct-child catalog rows, if read yet.
59
99
  */
60
- export function asTeamView(value, leadSessionId) {
61
- if (!isRecord(value) || !Array.isArray(value.members) || !Array.isArray(value.tasks))
100
+ function membersFromCatalog(leadSessionId, catalog) {
101
+ const members = [{ id: leadSessionId, name: LEAD_NAME, role: 'lead', phase: 'active' }];
102
+ const seen = new Set([leadSessionId]);
103
+ for (const child of catalog ?? []) {
104
+ if (child.name === undefined || child.name === LEAD_NAME || seen.has(child.id))
105
+ continue;
106
+ seen.add(child.id);
107
+ members.push({
108
+ id: child.id, name: child.name, role: 'teammate', phase: 'active',
109
+ ...child.label === undefined ? {} : { description: child.label },
110
+ });
111
+ }
112
+ return members;
113
+ }
114
+ /** The durable-roster wire (`0.2.2-rc.1` and earlier). */
115
+ function asRosterTeamView(value, leadSessionId) {
116
+ if (!Array.isArray(value.tasks))
62
117
  return undefined;
63
- const members = value.members.map(asMember);
118
+ const members = value.members;
119
+ const roster = members.map(asMember);
64
120
  const tasks = value.tasks.map(asTask);
65
- if (members.includes(undefined) || tasks.includes(undefined))
121
+ if (roster.includes(undefined) || tasks.includes(undefined))
66
122
  return undefined;
67
123
  const failure = typeof value.failure === 'string' ? value.failure : undefined;
68
- const roster = members;
124
+ const rows = roster;
69
125
  const board = tasks;
70
- if (!roster.some(member => member.role === 'teammate') && board.length === 0 && failure === undefined)
126
+ if (!rows.some(member => member.role === 'teammate') && board.length === 0 && failure === undefined)
71
127
  return undefined;
72
- return { leadSessionId, members: roster, tasks: board, ...failure === undefined ? {} : { failure } };
128
+ return { leadSessionId, mode: 'roster', enabled: true, members: rows, tasks: board, ...failure === undefined ? {} : { failure } };
129
+ }
130
+ /** The per-session selection wire (`0.2.2-rc.2` and later). */
131
+ function asSwitchTeamView(value, leadSessionId, catalog) {
132
+ if (typeof value.enabled !== 'boolean' || !Array.isArray(value.tasks))
133
+ return undefined;
134
+ const tasks = value.tasks.map(asTask);
135
+ if (tasks.includes(undefined))
136
+ return undefined;
137
+ const failure = typeof value.failure === 'string' ? value.failure : undefined;
138
+ const board = tasks;
139
+ // A root that never selected the team and has no record reads as none; a
140
+ // disabled root that still keeps its board is shown read-only.
141
+ if (!value.enabled && board.length === 0 && failure === undefined)
142
+ return undefined;
143
+ return {
144
+ leadSessionId, mode: 'switch', enabled: value.enabled,
145
+ members: membersFromCatalog(leadSessionId, catalog), tasks: board,
146
+ ...failure === undefined ? {} : { failure },
147
+ };
148
+ }
149
+ /**
150
+ * Narrow one `agentTeam` value into the view the UI renders. Both upstream
151
+ * shapes are told apart by the value itself; a session's implicit team (the
152
+ * Lead alone, no task, no failure) is no team on a roster host, while a
153
+ * `switch` host publishes the saved selection.
154
+ * @param value - Raw projection value.
155
+ * @param leadSessionId - The session the value was published for.
156
+ * @param catalog - The Lead's direct-child catalog (a `switch` host's member source).
157
+ * @returns the team view, or `undefined` when there is nothing to show.
158
+ */
159
+ export function asTeamView(value, leadSessionId, catalog) {
160
+ if (!isRecord(value))
161
+ return undefined;
162
+ if (Array.isArray(value.members))
163
+ return asRosterTeamView(value, leadSessionId);
164
+ return asSwitchTeamView(value, leadSessionId, catalog);
73
165
  }
74
166
  /**
75
- * The team a bound session belongs to is rooted at itself, or — for a
76
- * delegated child — at its parent: teammates are direct children of the Lead.
167
+ * The team a bound session belongs to is rooted at its top-level ancestor:
168
+ * the Lead itself, or — for a delegated child — the root its creator chain
169
+ * reaches. On a roster host teammates are direct children of the Lead; a
170
+ * `switch` host can nest deeper. Loaded ancestors are followed by identity;
171
+ * one that is gone stops the walk at its recorded parent id (the value there
172
+ * is likely absent, which reads as no team rather than a stale one).
77
173
  * @param session - The bound session.
78
- * @param agents - Live agents, to find the Lead's session object for a baseline.
174
+ * @param agents - Live agents, used to find loaded ancestors for traversal and baseline snapshots.
79
175
  * @returns the session whose `agentTeam` value to read.
80
176
  */
81
177
  export function teamRootOf(session, agents) {
82
178
  const own = session;
83
- const parent = own.header?.origin === 'subagent' ? own.header.parentSession : undefined;
84
- if (typeof parent !== 'string')
179
+ if (own.header?.origin !== 'subagent')
85
180
  return { id: String(own.id), session };
86
- for (const agent of agents?.list() ?? []) {
87
- if (String(agent.session.id) === parent)
88
- return { id: parent, session: agent.session };
181
+ const loaded = new Map();
182
+ for (const agent of agents?.list() ?? [])
183
+ loaded.set(String(agent.session.id), agent.session);
184
+ const seen = new Set();
185
+ let current = own;
186
+ let currentSession = session;
187
+ for (;;) {
188
+ const parent = current.header?.parentSession;
189
+ if (typeof parent !== 'string' || parent === '' || seen.has(parent))
190
+ break;
191
+ seen.add(parent);
192
+ const ancestor = loaded.get(parent);
193
+ if (ancestor === undefined)
194
+ return { id: parent };
195
+ const next = ancestor;
196
+ if (next.header?.origin !== 'subagent')
197
+ return { id: parent, session: ancestor };
198
+ current = next;
199
+ currentSession = ancestor;
89
200
  }
90
- return { id: parent };
201
+ return { id: String(current.id), session: currentSession };
91
202
  }
92
203
  /**
93
- * The watched team as seen from `sessionId`: the Lead's own, or a listed
94
- * teammate's. Any other child of the Lead (a plain subagent, a workflow
95
- * spawn) is watched at the same parent but belongs to no team.
204
+ * The watched team as seen from `sessionId`: the Lead's own, or — on a
205
+ * roster host — a listed teammate's. A `switch` host's tree is the team, so
206
+ * any session watched at that Lead reads it. Any other child of a roster
207
+ * host's Lead (a plain subagent, a workflow spawn) belongs to no team.
96
208
  * @param team - The watched session's team.
97
209
  * @param sessionId - The bound session.
98
210
  * @returns the team, or `undefined` when the session is not on it.
@@ -100,6 +212,8 @@ export function teamRootOf(session, agents) {
100
212
  export function teamFor(team, sessionId) {
101
213
  if (team === undefined || team.leadSessionId === sessionId)
102
214
  return team;
215
+ if (team.mode === 'switch')
216
+ return team;
103
217
  return team.members.some(member => member.role === 'teammate' && member.id === sessionId) ? team : undefined;
104
218
  }
105
219
  /**
@@ -108,14 +222,52 @@ export function teamFor(team, sessionId) {
108
222
  * @returns the store the channel reads from.
109
223
  */
110
224
  export function createTeamRosterStore(ctx) {
225
+ const agents = () => ctx.get('agents');
226
+ const watch = (session) => {
227
+ const subagents = ctx.get('subagents');
228
+ if (subagents?.rootOf === undefined)
229
+ return teamRootOf(session, agents());
230
+ const agent = [...(agents()?.list() ?? [])].find(agent => agent.session === session);
231
+ if (agent === undefined)
232
+ return undefined;
233
+ try {
234
+ const root = subagents.rootOf(agent);
235
+ return { id: String(root.session.id), session: root.session };
236
+ }
237
+ catch {
238
+ // A separately restored delegated Session has no resident runtime owner.
239
+ return undefined;
240
+ }
241
+ };
242
+ // The member source of a `switch` host, watched at the same root as the team.
243
+ const catalogStore = createSessionProjectionStore({
244
+ key: SUBAGENT_CATALOG_KEY,
245
+ narrow: asCatalog,
246
+ watch,
247
+ warn: message => { ctx.logger.warn(message); },
248
+ });
111
249
  const store = createSessionProjectionStore({
112
250
  key: TEAM_PROJECTION_KEY,
113
251
  // A team bundle switched off at run time takes the service down before
114
252
  // (or while) its projection definition leaves: no service, no team.
115
- narrow: (value, leadSessionId) => (ctx.get('agentTeams', false) === undefined ? undefined : asTeamView(value, leadSessionId)),
116
- watch: session => teamRootOf(session, ctx.get('agents')),
253
+ narrow: (value, leadSessionId) => (ctx.get('agentTeams', false) === undefined
254
+ ? undefined
255
+ : asTeamView(value, leadSessionId, catalogStore.read())),
256
+ watch,
117
257
  warn: message => { ctx.logger.warn(message); },
118
258
  });
259
+ // The catalog arrives after (or before) the team wire, and either change
260
+ // recomposes the members a `switch` host renders: re-narrow on every move.
261
+ // The composite seed below rebinds both watches; a catalog change it causes
262
+ // must not reseed the team store while the team still points at the previous
263
+ // session (that reseed would narrow the old team against the new catalog and,
264
+ // through the overridden seed, bind the catalog back to the old root).
265
+ let seeding = false;
266
+ catalogStore.subscribe(() => { if (!seeding)
267
+ store.reseed(); });
268
+ // Attached in this order so the team feed stays the last listener on a
269
+ // single-listener registry (the order the pre-switch store wired itself in).
270
+ attachSessionProjection(ctx, SUBAGENT_CATALOG_KEY, catalogStore);
119
271
  attachSessionProjection(ctx, TEAM_PROJECTION_KEY, store);
120
272
  // The plugin manager announces every profile write it applied (`/team`,
121
273
  // `/plugin`, the Web UI). Unregistering a projection emits nothing on the
@@ -130,7 +282,22 @@ export function createTeamRosterStore(ctx) {
130
282
  if (name === 'agentTeams')
131
283
  store.reseed();
132
284
  }));
285
+ // Seeding the bound session fills both watches at once: the channel binds
286
+ // the team, and the catalog that supplies its members follows the same root.
287
+ const seedTeam = store.seed;
133
288
  return Object.assign(store, {
289
+ seed(session) {
290
+ if (seeding)
291
+ return;
292
+ seeding = true;
293
+ try {
294
+ catalogStore.seed(session);
295
+ seedTeam(session);
296
+ }
297
+ finally {
298
+ seeding = false;
299
+ }
300
+ },
134
301
  teamOf: (sessionId) => (store.boundId === sessionId ? teamFor(store.read(), sessionId) : undefined),
135
302
  });
136
303
  }
@@ -1,16 +1,29 @@
1
1
  /**
2
- * Compact cards for DSH's experimental Agent Teams tools. Their results are
3
- * compact JSON records and the tools ship no presenters, so the plain card
4
- * would show a capitalised tool id and a raw `⎿ {"messageId":…}` line. These
5
- * views fold known shapes into one line; anything else (an error text, a
6
- * changed upstream shape) falls back to the plain card. A presenter the tool
7
- * itself registers always wins: these run only when it has none.
8
- * `spawn_teammate` is not here — it renders as the subagent row, and as a
9
- * plain card only when it fails before the teammate exists (translate.ts).
2
+ * Compact cards for DSH's Agent Teams tool results. The tools ship no
3
+ * presenters, so the plain card would show a capitalised tool id and a raw
4
+ * `⎿ {"messageId":…}` line. These views fold known shapes into one line;
5
+ * anything else (an error text, a changed upstream shape) falls back to the
6
+ * plain card. A presenter the tool itself registers always wins: these run
7
+ * only when it has none.
10
8
  *
11
- * Three names are shared with the legacy subagent controls, which also ship
12
- * no presenters: a team call is told apart by its `target` argument (the
13
- * legacy ones take `agent_id`), a team result by its record shape.
9
+ * Two upstream generations of the same tools are read by shape:
10
+ *
11
+ * - **Team copies** (`0.2.2-rc.1` and earlier): `send_message` takes `target`,
12
+ * `list_agents` rows carry `target`, `interrupt_agent` answers
13
+ * `{previousStatus}`, and `spawn_teammate` is the delegation tool (it renders
14
+ * as the subagent row and as a plain card only when it fails before the
15
+ * teammate exists — translate.ts).
16
+ * - **Standard controls** (`0.2.2-rc.2` and later): the same tools take
17
+ * `agent` (a name or a Session id), `list_agents` rows are
18
+ * `{name, status, description?}`, `send_message` answers `{messageId}`,
19
+ * `interrupt_agent` `{accepted}`, and `wait_agent` no longer reports
20
+ * `noProgress`. `spawn_teammate` is gone; `subagent` / `subagent_fork` are
21
+ * the delegation tools.
22
+ *
23
+ * Older logs keep rendering: a team call is still recognised by its `target`
24
+ * argument, and a legacy control call (`agent_id`) keeps the plain card.
25
+ * Task results carry `owner` (the owner's name) on `0.2.2-rc.2` and
26
+ * `ownerName` before it; both are read.
14
27
  *
15
28
  * {@link teamMessageOf} reads a delivered team message for the transcript
16
29
  * translator.
@@ -18,7 +31,7 @@
18
31
  * @module
19
32
  */
20
33
  import type { ToolCallView, ToolResultView } from './channel/types.js';
21
- /** The team's own delegation tool; its presence is what "team on" means to a request. */
34
+ /** The bundle-host delegation tool; its presence is what "team on" means there. */
22
35
  export declare const TEAM_SPAWN_TOOL = "spawn_teammate";
23
36
  /** Whether `name` is a team tool with a compact card here (not `spawn_teammate`). */
24
37
  export declare function isTeamToolName(name: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"team-tools.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/team-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAgBtE,yFAAyF;AACzF,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAE/C,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AA4CD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAKxF;AAmDD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAa1G;AAKD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAgB7K"}
1
+ {"version":3,"file":"team-tools.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/team-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAgBtE,mFAAmF;AACnF,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAE/C,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAuDD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAKxF;AA4ED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAa1G;AAMD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAgB7K"}
@@ -1,16 +1,29 @@
1
1
  /**
2
- * Compact cards for DSH's experimental Agent Teams tools. Their results are
3
- * compact JSON records and the tools ship no presenters, so the plain card
4
- * would show a capitalised tool id and a raw `⎿ {"messageId":…}` line. These
5
- * views fold known shapes into one line; anything else (an error text, a
6
- * changed upstream shape) falls back to the plain card. A presenter the tool
7
- * itself registers always wins: these run only when it has none.
8
- * `spawn_teammate` is not here — it renders as the subagent row, and as a
9
- * plain card only when it fails before the teammate exists (translate.ts).
2
+ * Compact cards for DSH's Agent Teams tool results. The tools ship no
3
+ * presenters, so the plain card would show a capitalised tool id and a raw
4
+ * `⎿ {"messageId":…}` line. These views fold known shapes into one line;
5
+ * anything else (an error text, a changed upstream shape) falls back to the
6
+ * plain card. A presenter the tool itself registers always wins: these run
7
+ * only when it has none.
10
8
  *
11
- * Three names are shared with the legacy subagent controls, which also ship
12
- * no presenters: a team call is told apart by its `target` argument (the
13
- * legacy ones take `agent_id`), a team result by its record shape.
9
+ * Two upstream generations of the same tools are read by shape:
10
+ *
11
+ * - **Team copies** (`0.2.2-rc.1` and earlier): `send_message` takes `target`,
12
+ * `list_agents` rows carry `target`, `interrupt_agent` answers
13
+ * `{previousStatus}`, and `spawn_teammate` is the delegation tool (it renders
14
+ * as the subagent row and as a plain card only when it fails before the
15
+ * teammate exists — translate.ts).
16
+ * - **Standard controls** (`0.2.2-rc.2` and later): the same tools take
17
+ * `agent` (a name or a Session id), `list_agents` rows are
18
+ * `{name, status, description?}`, `send_message` answers `{messageId}`,
19
+ * `interrupt_agent` `{accepted}`, and `wait_agent` no longer reports
20
+ * `noProgress`. `spawn_teammate` is gone; `subagent` / `subagent_fork` are
21
+ * the delegation tools.
22
+ *
23
+ * Older logs keep rendering: a team call is still recognised by its `target`
24
+ * argument, and a legacy control call (`agent_id`) keeps the plain card.
25
+ * Task results carry `owner` (the owner's name) on `0.2.2-rc.2` and
26
+ * `ownerName` before it; both are read.
14
27
  *
15
28
  * {@link teamMessageOf} reads a delivered team message for the transcript
16
29
  * translator.
@@ -29,7 +42,7 @@ const DISPLAY_KEYS = {
29
42
  team_task_get: 'tool-name-team-task',
30
43
  team_task_update: 'tool-name-team-task',
31
44
  };
32
- /** The team's own delegation tool; its presence is what "team on" means to a request. */
45
+ /** The bundle-host delegation tool; its presence is what "team on" means there. */
33
46
  export const TEAM_SPAWN_TOOL = 'spawn_teammate';
34
47
  /** Whether `name` is a team tool with a compact card here (not `spawn_teammate`). */
35
48
  export function isTeamToolName(name) {
@@ -44,10 +57,22 @@ function str(value) {
44
57
  function firstLine(text) {
45
58
  return text.split('\n', 1)[0].trim();
46
59
  }
60
+ /**
61
+ * Which generation of a shared-name control tool this call belongs to.
62
+ * `agent` is the `0.2.2-rc.2` argument name; `target` is the team copy's; a
63
+ * call with `agent_id` (or neither) is a legacy control and stays a plain card.
64
+ */
65
+ function controlFlavor(args) {
66
+ if (str(args.agent) !== undefined)
67
+ return 'switch';
68
+ if (str(args.target) !== undefined)
69
+ return 'team';
70
+ return undefined;
71
+ }
47
72
  function callTitle(name, args) {
48
73
  switch (name) {
49
74
  case 'send_message': {
50
- const target = str(args.target);
75
+ const target = str(args.agent) ?? str(args.target);
51
76
  if (target === undefined)
52
77
  return undefined;
53
78
  const message = str(args.message);
@@ -56,11 +81,11 @@ function callTitle(name, args) {
56
81
  // `list_agents` / `wait_agent` calls carry nothing that tells them from the
57
82
  // legacy subagent controls of the same names; only their results do.
58
83
  case 'interrupt_agent':
59
- return str(args.target);
84
+ return str(args.agent) ?? str(args.target);
60
85
  case 'team_task_create':
61
86
  return str(args.subject);
62
87
  case 'team_task_list':
63
- return ['status', 'owner', 'ready'].flatMap(key => (args[key] === undefined ? [] : [`${key}=${String(args[key])}`])).join(' ') || undefined;
88
+ return ['status', 'owner', 'ready', 'unowned'].flatMap(key => (args[key] === undefined ? [] : [`${key}=${String(args[key])}`])).join(' ') || undefined;
64
89
  case 'team_task_get':
65
90
  return str(args.task_id);
66
91
  case 'team_task_update': {
@@ -98,39 +123,68 @@ function titleOf(name, rawArgs) {
98
123
  }
99
124
  return isRecord(args) ? callTitle(name, args) : undefined;
100
125
  }
126
+ function argsOf(rawArgs) {
127
+ try {
128
+ const args = JSON.parse(rawArgs);
129
+ return isRecord(args) ? args : undefined;
130
+ }
131
+ catch {
132
+ return undefined;
133
+ }
134
+ }
101
135
  function taskLine(task) {
102
136
  const id = str(task.id);
103
137
  const status = str(task.status);
104
138
  if (id === undefined || status === undefined || typeof task.revision !== 'number')
105
139
  return undefined;
106
- const owner = str(task.ownerName);
140
+ // `owner` is the owner's name on 0.2.2-rc.2; earlier views publish `ownerName`.
141
+ const owner = str(task.owner) ?? str(task.ownerName);
107
142
  return `${id} r${task.revision} · ${status}${owner === undefined ? '' : ` · ${owner}`}`;
108
143
  }
109
- function resultLine(name, value) {
144
+ function resultLine(name, value, args) {
110
145
  switch (name) {
111
- case 'send_message':
146
+ case 'send_message': {
112
147
  if (!isRecord(value))
113
148
  return undefined;
114
149
  if (value.sent === true)
115
150
  return 'sent';
116
151
  // compat(dsh 0.2.0, log): the mailbox status a 0.2.0 send answered.
117
- return legacySendMessageStatus(value);
152
+ const legacyStatus = legacySendMessageStatus(value);
153
+ if (legacyStatus !== undefined)
154
+ return legacyStatus;
155
+ // The rc.2 control answers `{messageId}`; the legacy control's identical
156
+ // record stays raw (its call carries `agent_id`, not `agent`).
157
+ return args !== undefined && controlFlavor(args) === 'switch' && str(value.messageId) !== undefined ? 'sent' : undefined;
158
+ }
118
159
  case 'list_agents': {
119
160
  if (!Array.isArray(value))
120
161
  return undefined;
121
- const members = value.flatMap(member => (isRecord(member) && str(member.target) !== undefined && str(member.status) !== undefined
122
- ? [`${String(member.target)} ${String(member.status)}`]
123
- : []));
162
+ const members = value.flatMap(member => {
163
+ if (!isRecord(member) || str(member.status) === undefined)
164
+ return [];
165
+ // `target` is the team copy's row; `name` is the standard control's.
166
+ const label = str(member.target) ?? str(member.name);
167
+ return label === undefined ? [] : [`${label} ${String(member.status)}`];
168
+ });
124
169
  return members.length === value.length ? members.join(' · ') : undefined;
125
170
  }
126
171
  case 'wait_agent':
127
172
  if (!isRecord(value) || typeof value.timedOut !== 'boolean')
128
173
  return undefined;
174
+ // compat(team, log): the team copy's 0.2.2-rc.1 wait reported noProgress.
129
175
  if (value.noProgress)
130
176
  return 'noProgress';
131
177
  return value.timedOut ? 'timedOut' : 'changed';
132
- case 'interrupt_agent':
133
- return isRecord(value) ? str(value.previousStatus) : undefined;
178
+ case 'interrupt_agent': {
179
+ if (!isRecord(value))
180
+ return undefined;
181
+ const previous = str(value.previousStatus);
182
+ if (previous !== undefined)
183
+ return previous;
184
+ // The standard control's `{accepted}` only means something for a call
185
+ // this card understands; a legacy control call keeps the raw result.
186
+ return controlFlavor(args ?? {}) === undefined ? undefined : typeof value.accepted === 'boolean' ? 'accepted' : undefined;
187
+ }
134
188
  case 'team_task_list': {
135
189
  if (!isRecord(value) || !Array.isArray(value.tasks))
136
190
  return undefined;
@@ -166,7 +220,7 @@ export function teamToolResultView(name, rawArgs, text) {
166
220
  catch {
167
221
  return undefined;
168
222
  }
169
- const line = resultLine(name, value);
223
+ const line = resultLine(name, value, argsOf(rawArgs));
170
224
  if (line === undefined)
171
225
  return undefined;
172
226
  const title = titleOf(name, rawArgs);
@@ -178,6 +232,7 @@ export function teamToolResultView(name, rawArgs, text) {
178
232
  }
179
233
  /** Relay framing: one whole leading block, `Team message from <name>:`. */
180
234
  const RELAY_FRAMING = /^Team message from ([^\n]+):$/;
235
+ const AGENT_RELAY_FRAMING = /^Agent ([^\n]+) sent a message: $/;
181
236
  /**
182
237
  * An Agent Teams message delivered to a session (`user/message`): the
183
238
  * generic relay (`agent-message` / `relay`) whose first block is exactly
@@ -191,7 +246,7 @@ const RELAY_FRAMING = /^Team message from ([^\n]+):$/;
191
246
  export function teamMessageOf(source, content) {
192
247
  const first = content[0];
193
248
  const framing = agentRelaySourceOf(source) !== undefined && first?.type === 'text' && typeof first.text === 'string'
194
- ? RELAY_FRAMING.exec(first.text)
249
+ ? (RELAY_FRAMING.exec(first.text) ?? AGENT_RELAY_FRAMING.exec(first.text))
195
250
  : null;
196
251
  if (framing === null)
197
252
  return undefined;
@@ -0,0 +1,24 @@
1
+ /** Per-agent preset/team tool visibility on the 0.2.2 registry seam.
2
+ * Older hosts retain the final assembly filters in plugin.ts instead.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ /** The agent shape the restriction needs; no driver implementation is owned here. */
6
+ export interface ScopedAgentLike {
7
+ readonly ctx: Context;
8
+ readonly session: unknown;
9
+ }
10
+ export interface ToolScope {
11
+ /** Track an existing agent and refresh the composition's live scopes. */
12
+ apply(agent: ScopedAgentLike): void;
13
+ }
14
+ /**
15
+ * Keep one exact restriction per live agent, including background/child agents
16
+ * that never bind to the screen. Agent publication awaits agent/created, so its
17
+ * restriction is installed before the factory releases any queued work.
18
+ *
19
+ * @param ctx - Composition context supplying the registry and lifecycle events.
20
+ * @param own - Channel lifetime funnel; releases listeners and every owned mask.
21
+ * @param currentAgent - Initial/borrowed foreground not necessarily in the registry.
22
+ */
23
+ export declare function createToolScope(ctx: Context, own: (dispose: () => void) => void, currentAgent: () => ScopedAgentLike | undefined): ToolScope;
24
+ //# sourceMappingURL=tool-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-scope.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/tool-scope.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAclD,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,WAAW,SAAS;IACxB,yEAAyE;IACzE,KAAK,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAA;CACpC;AAMD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,IAAI,EAClC,YAAY,EAAE,MAAM,eAAe,GAAG,SAAS,GAC9C,SAAS,CA6FX"}