@deepseek-harness-tui/dsh-tui 0.16.0 → 0.17.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 (401) hide show
  1. package/README.md +214 -34
  2. package/assets/plugin-icon.svg +13 -0
  3. package/assets/windows-installer.cs +308 -0
  4. package/assets/windows-installer.ps1 +17 -0
  5. package/bin/dsh-tui.js +64 -5
  6. package/cli/adapters/dsh/index.mjs +111 -0
  7. package/cli/adapters/dsh/locate.mjs +73 -0
  8. package/cli/adapters/dsh/management-plugin.mjs +111 -0
  9. package/cli/args.mjs +154 -0
  10. package/cli/contracts.d.ts +48 -0
  11. package/cli/engine.mjs +92 -0
  12. package/cli/entry.mjs +48 -0
  13. package/cli/process.mjs +118 -0
  14. package/cli/protocol.mjs +23 -0
  15. package/cli/schema-v1.json +33 -0
  16. package/cordis.patch.yml +3 -1
  17. package/cordis.yml +3 -1
  18. package/guide/dsh-tui-guide/SKILL.md +1 -0
  19. package/guide/dsh-tui-guide/claude-backend.en.md +8 -0
  20. package/guide/dsh-tui-guide/claude-backend.md +5 -0
  21. package/guide/dsh-tui-guide/cli.en.md +114 -0
  22. package/guide/dsh-tui-guide/cli.md +114 -0
  23. package/guide/dsh-tui-guide/configuration.en.md +6 -5
  24. package/guide/dsh-tui-guide/configuration.md +6 -5
  25. package/guide/dsh-tui-guide/getting-started.en.md +44 -10
  26. package/guide/dsh-tui-guide/getting-started.md +31 -9
  27. package/guide/dsh-tui-guide/interaction.en.md +22 -10
  28. package/guide/dsh-tui-guide/interaction.md +18 -8
  29. package/guide/dsh-tui-guide/plugins.en.md +35 -4
  30. package/guide/dsh-tui-guide/plugins.md +23 -2
  31. package/guide/dsh-tui-guide/user-guide.en.md +30 -23
  32. package/guide/dsh-tui-guide/user-guide.md +29 -22
  33. package/lib/settings.json +83 -40
  34. package/lib/types/adapter/channel/plugins.d.ts.map +1 -1
  35. package/lib/types/adapter/channel/plugins.js +8 -0
  36. package/lib/types/adapter/channel/ui-policy.d.ts +1 -1
  37. package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
  38. package/lib/types/adapter/channel/ui-policy.js +3 -0
  39. package/lib/types/adapter/ports/channel-display.d.ts +10 -0
  40. package/lib/types/adapter/ports/channel-display.d.ts.map +1 -1
  41. package/lib/types/adapter/ports/channel-session.d.ts +2 -0
  42. package/lib/types/adapter/ports/channel-session.d.ts.map +1 -1
  43. package/lib/types/adapter/ports/channel-settings.d.ts +20 -0
  44. package/lib/types/adapter/ports/channel-settings.d.ts.map +1 -1
  45. package/lib/types/adapter/ports/channel-ui.d.ts +17 -2
  46. package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
  47. package/lib/types/adapter/ports/channel-view.d.ts +8 -1
  48. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  49. package/lib/types/adapter/ports/channel.d.ts +7 -0
  50. package/lib/types/adapter/ports/channel.d.ts.map +1 -1
  51. package/lib/types/agent/capabilities.d.ts +2 -0
  52. package/lib/types/agent/capabilities.d.ts.map +1 -1
  53. package/lib/types/agent/events.d.ts +8 -0
  54. package/lib/types/agent/events.d.ts.map +1 -1
  55. package/lib/types/api.d.ts +2 -2
  56. package/lib/types/api.d.ts.map +1 -1
  57. package/lib/types/backends/claude/translate/events.d.ts.map +1 -1
  58. package/lib/types/backends/claude/translate/events.js +2 -1
  59. package/lib/types/backends/codex/auth/status.js +1 -1
  60. package/lib/types/backends/codex/session/controls.d.ts.map +1 -1
  61. package/lib/types/backends/codex/session/controls.js +6 -5
  62. package/lib/types/backends/codex/session/goals.d.ts.map +1 -1
  63. package/lib/types/backends/codex/session/side-query.d.ts.map +1 -1
  64. package/lib/types/backends/codex/translate/events.d.ts.map +1 -1
  65. package/lib/types/backends/codex/translate/events.js +3 -1
  66. package/lib/types/backends/shared/channel-tokens.d.ts.map +1 -1
  67. package/lib/types/backends/shared/channel-tokens.js +9 -8
  68. package/lib/types/channel/history-restore.d.ts.map +1 -1
  69. package/lib/types/channel/history-restore.js +2 -0
  70. package/lib/types/channel/interaction.d.ts.map +1 -1
  71. package/lib/types/channel/interaction.js +1 -0
  72. package/lib/types/channel/projection.d.ts +1 -1
  73. package/lib/types/channel/projection.d.ts.map +1 -1
  74. package/lib/types/channel/projection.js +19 -4
  75. package/lib/types/channel/questions.d.ts +2 -0
  76. package/lib/types/channel/questions.d.ts.map +1 -1
  77. package/lib/types/channel/sanitize.d.ts +14 -0
  78. package/lib/types/channel/sanitize.d.ts.map +1 -1
  79. package/lib/types/channel/sanitize.js +55 -0
  80. package/lib/types/channel/working-directory.d.ts +9 -0
  81. package/lib/types/channel/working-directory.d.ts.map +1 -0
  82. package/lib/types/channel/working-directory.js +7 -0
  83. package/lib/types/commands.d.ts +8 -1
  84. package/lib/types/commands.d.ts.map +1 -1
  85. package/lib/types/commands.js +13 -4
  86. package/lib/types/components/ChatTitle.d.ts +7 -0
  87. package/lib/types/components/ChatTitle.d.ts.map +1 -0
  88. package/lib/types/components/ChatTitle.js +15 -0
  89. package/lib/types/components/CodeBlockFrame.d.ts.map +1 -1
  90. package/lib/types/components/CodeBlockFrame.js +10 -5
  91. package/lib/types/components/CompactionStatusRow.d.ts.map +1 -1
  92. package/lib/types/components/CompactionStatusRow.js +24 -3
  93. package/lib/types/components/GoalTodoPanel.d.ts +3 -1
  94. package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
  95. package/lib/types/components/GoalTodoPanel.js +2 -2
  96. package/lib/types/components/Markdown.d.ts +9 -1
  97. package/lib/types/components/Markdown.d.ts.map +1 -1
  98. package/lib/types/components/Markdown.js +5 -4
  99. package/lib/types/components/MessageList.d.ts.map +1 -1
  100. package/lib/types/components/MessageList.js +17 -12
  101. package/lib/types/components/PromptInput.d.ts +13 -5
  102. package/lib/types/components/PromptInput.d.ts.map +1 -1
  103. package/lib/types/components/PromptInput.js +189 -107
  104. package/lib/types/components/SplitDiffView.d.ts.map +1 -1
  105. package/lib/types/components/SplitDiffView.js +232 -22
  106. package/lib/types/components/SubagentDetailScene.d.ts +3 -1
  107. package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
  108. package/lib/types/components/SubagentDetailScene.js +5 -1
  109. package/lib/types/components/Whale.d.ts.map +1 -1
  110. package/lib/types/components/Whale.js +8 -5
  111. package/lib/types/components/approvals/ApprovalPanel.d.ts +1 -1
  112. package/lib/types/components/approvals/ApprovalPanel.d.ts.map +1 -1
  113. package/lib/types/components/approvals/ApprovalPanel.js +93 -11
  114. package/lib/types/components/bigfont.d.ts.map +1 -1
  115. package/lib/types/components/bigfont.js +2 -1
  116. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  117. package/lib/types/components/messages/AssistantToolUseMessage.js +13 -6
  118. package/lib/types/components/previewRows.d.ts +19 -0
  119. package/lib/types/components/previewRows.d.ts.map +1 -0
  120. package/lib/types/components/previewRows.js +46 -0
  121. package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
  122. package/lib/types/components/questions/AskUserQuestionPanel.js +75 -10
  123. package/lib/types/components/sessions/ForeignSessionRow.d.ts +3 -9
  124. package/lib/types/components/sessions/ForeignSessionRow.d.ts.map +1 -1
  125. package/lib/types/components/sessions/ForeignSessionRow.js +6 -10
  126. package/lib/types/components/sessions/SessionListRow.d.ts +4 -9
  127. package/lib/types/components/sessions/SessionListRow.d.ts.map +1 -1
  128. package/lib/types/components/sessions/SessionListRow.js +18 -10
  129. package/lib/types/components/sidePanel/InfoPanel.d.ts.map +1 -1
  130. package/lib/types/components/sidePanel/InfoPanel.js +4 -3
  131. package/lib/types/components/sidePanel/SidePanelLayout.d.ts.map +1 -1
  132. package/lib/types/components/sidePanel/SidePanelLayout.js +5 -5
  133. package/lib/types/components/sidePanel/WorkspacePanel.d.ts.map +1 -1
  134. package/lib/types/components/sidePanel/WorkspacePanel.js +19 -7
  135. package/lib/types/components/sidePanel/builtinPanels.d.ts.map +1 -1
  136. package/lib/types/components/sidePanel/builtinPanels.js +22 -16
  137. package/lib/types/components/sidePanel/companion/CompanionPanel.d.ts.map +1 -1
  138. package/lib/types/components/sidePanel/companion/CompanionPanel.js +2 -1
  139. package/lib/types/components/sidePanel/panelMarkdown.d.ts +32 -0
  140. package/lib/types/components/sidePanel/panelMarkdown.d.ts.map +1 -0
  141. package/lib/types/components/sidePanel/panelMarkdown.js +45 -0
  142. package/lib/types/components/sidePanel/pluginPanelAdapter.d.ts.map +1 -1
  143. package/lib/types/components/sidePanel/pluginPanelAdapter.js +6 -1
  144. package/lib/types/components/sidePanel/subagentFailureRead.d.ts +21 -0
  145. package/lib/types/components/sidePanel/subagentFailureRead.d.ts.map +1 -0
  146. package/lib/types/components/sidePanel/subagentFailureRead.js +66 -0
  147. package/lib/types/components/sidePanel/useSidePanel.d.ts.map +1 -1
  148. package/lib/types/components/sidePanel/useSidePanel.js +24 -6
  149. package/lib/types/components/trajectory/MiniWake.d.ts +2 -2
  150. package/lib/types/components/trajectory/MiniWake.d.ts.map +1 -1
  151. package/lib/types/components/trajectory/MiniWake.js +7 -3
  152. package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts.map +1 -1
  153. package/lib/types/components/workspaces/HomeWorkspaceRow.js +4 -7
  154. package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
  155. package/lib/types/dsh-adapter/backend/translate.js +11 -1
  156. package/lib/types/dsh-adapter/backend-admission.d.ts +3 -3
  157. package/lib/types/dsh-adapter/channel/binding-events.d.ts +5 -1
  158. package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
  159. package/lib/types/dsh-adapter/channel/binding-events.js +18 -1
  160. package/lib/types/dsh-adapter/channel/command-completions.d.ts.map +1 -1
  161. package/lib/types/dsh-adapter/channel/command-completions.js +6 -8
  162. package/lib/types/dsh-adapter/channel/composer-images.d.ts +9 -1
  163. package/lib/types/dsh-adapter/channel/composer-images.d.ts.map +1 -1
  164. package/lib/types/dsh-adapter/channel/composer-images.js +111 -111
  165. package/lib/types/dsh-adapter/channel/composer-mentions.d.ts.map +1 -1
  166. package/lib/types/dsh-adapter/channel/composer-mentions.js +16 -10
  167. package/lib/types/dsh-adapter/channel/core/actions.d.ts +1 -1
  168. package/lib/types/dsh-adapter/channel/core/actions.d.ts.map +1 -1
  169. package/lib/types/dsh-adapter/channel/core/actions.js +23 -2
  170. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts +4 -1
  171. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts.map +1 -1
  172. package/lib/types/dsh-adapter/channel/core/binding-feed.js +13 -2
  173. package/lib/types/dsh-adapter/channel/core/compose.d.ts +4 -1
  174. package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
  175. package/lib/types/dsh-adapter/channel/core/compose.js +2 -0
  176. package/lib/types/dsh-adapter/channel/core/files.d.ts.map +1 -1
  177. package/lib/types/dsh-adapter/channel/core/files.js +2 -1
  178. package/lib/types/dsh-adapter/channel/core/host.d.ts +14 -10
  179. package/lib/types/dsh-adapter/channel/core/host.d.ts.map +1 -1
  180. package/lib/types/dsh-adapter/channel/core/host.js +192 -13
  181. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts +1 -0
  182. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts.map +1 -1
  183. package/lib/types/dsh-adapter/channel/core/local-actions.js +32 -3
  184. package/lib/types/dsh-adapter/channel/extensions.d.ts.map +1 -1
  185. package/lib/types/dsh-adapter/channel/extensions.js +31 -5
  186. package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
  187. package/lib/types/dsh-adapter/channel/input-actions.js +4 -0
  188. package/lib/types/dsh-adapter/channel/input-delivery.d.ts +4 -1
  189. package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
  190. package/lib/types/dsh-adapter/channel/input-delivery.js +24 -1
  191. package/lib/types/dsh-adapter/channel/model-actions.d.ts +1 -1
  192. package/lib/types/dsh-adapter/channel/model-actions.d.ts.map +1 -1
  193. package/lib/types/dsh-adapter/channel/model-actions.js +7 -1
  194. package/lib/types/dsh-adapter/channel/model-selection.d.ts.map +1 -1
  195. package/lib/types/dsh-adapter/channel/model-selection.js +6 -4
  196. package/lib/types/dsh-adapter/channel/session-fork.d.ts.map +1 -1
  197. package/lib/types/dsh-adapter/channel/session-fork.js +1 -0
  198. package/lib/types/dsh-adapter/channel/session-metadata.d.ts.map +1 -1
  199. package/lib/types/dsh-adapter/channel/session-metadata.js +15 -2
  200. package/lib/types/dsh-adapter/channel/session-reset.d.ts +1 -1
  201. package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
  202. package/lib/types/dsh-adapter/channel/session-reset.js +4 -0
  203. package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
  204. package/lib/types/dsh-adapter/channel/session-resume.js +46 -33
  205. package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
  206. package/lib/types/dsh-adapter/channel/settings-host.js +10 -3
  207. package/lib/types/dsh-adapter/channel/state.d.ts +1 -1
  208. package/lib/types/dsh-adapter/channel/state.d.ts.map +1 -1
  209. package/lib/types/dsh-adapter/channel/state.js +2 -2
  210. package/lib/types/dsh-adapter/channel/types.d.ts +13 -1
  211. package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
  212. package/lib/types/dsh-adapter/compat/liveSession.d.ts +3 -3
  213. package/lib/types/dsh-adapter/compat/liveSession.js +3 -3
  214. package/lib/types/dsh-adapter/compat/sessionLog.d.ts +1 -1
  215. package/lib/types/dsh-adapter/compat/sessionLog.d.ts.map +1 -1
  216. package/lib/types/dsh-adapter/compat/sessionLog.js +17 -1
  217. package/lib/types/dsh-adapter/contract.d.ts +6 -5
  218. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  219. package/lib/types/dsh-adapter/contract.js +7 -5
  220. package/lib/types/dsh-adapter/effect-ledger.d.ts +1 -1
  221. package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -1
  222. package/lib/types/dsh-adapter/effect-ledger.js +1 -0
  223. package/lib/types/dsh-adapter/experimental-bundles.d.ts +26 -0
  224. package/lib/types/dsh-adapter/experimental-bundles.d.ts.map +1 -0
  225. package/lib/types/dsh-adapter/experimental-bundles.js +11 -0
  226. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
  227. package/lib/types/dsh-adapter/host-access.js +4 -0
  228. package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
  229. package/lib/types/dsh-adapter/host-contract.js +2 -2
  230. package/lib/types/dsh-adapter/host-dsh.js +3 -3
  231. package/lib/types/dsh-adapter/host-entry.js +5 -3
  232. package/lib/types/dsh-adapter/index.d.ts +8 -4
  233. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  234. package/lib/types/dsh-adapter/index.js +9 -7
  235. package/lib/types/dsh-adapter/install/pnpm-profile-add.d.ts.map +1 -1
  236. package/lib/types/dsh-adapter/install/pnpm-profile-add.js +9 -3
  237. package/lib/types/dsh-adapter/panels.d.ts +21 -7
  238. package/lib/types/dsh-adapter/panels.d.ts.map +1 -1
  239. package/lib/types/dsh-adapter/panels.js +11 -56
  240. package/lib/types/dsh-adapter/plugin.d.ts +81 -0
  241. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  242. package/lib/types/dsh-adapter/plugin.js +318 -70
  243. package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -1
  244. package/lib/types/dsh-adapter/plugins-info.js +65 -10
  245. package/lib/types/dsh-adapter/presets.d.ts +15 -6
  246. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  247. package/lib/types/dsh-adapter/presets.js +51 -12
  248. package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
  249. package/lib/types/dsh-adapter/process-exit.js +1 -1
  250. package/lib/types/dsh-adapter/session-tools.d.ts +34 -0
  251. package/lib/types/dsh-adapter/session-tools.d.ts.map +1 -0
  252. package/lib/types/dsh-adapter/session-tools.js +39 -0
  253. package/lib/types/dsh-adapter/settings-sections.d.ts +18 -1
  254. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
  255. package/lib/types/dsh-adapter/settings-sections.js +73 -0
  256. package/lib/types/dsh-adapter/status.d.ts +88 -1
  257. package/lib/types/dsh-adapter/status.d.ts.map +1 -1
  258. package/lib/types/dsh-adapter/status.js +318 -3
  259. package/lib/types/dsh-adapter/team-mode.d.ts +42 -33
  260. package/lib/types/dsh-adapter/team-mode.d.ts.map +1 -1
  261. package/lib/types/dsh-adapter/team-mode.js +76 -112
  262. package/lib/types/extensions.d.ts +1 -1
  263. package/lib/types/extensions.d.ts.map +1 -1
  264. package/lib/types/force-production-react.js +3 -3
  265. package/lib/types/i18n.d.ts +195 -52
  266. package/lib/types/i18n.d.ts.map +1 -1
  267. package/lib/types/i18n.js +96 -30
  268. package/lib/types/ink/colorize.d.ts +7 -1
  269. package/lib/types/ink/colorize.d.ts.map +1 -1
  270. package/lib/types/ink/colorize.js +29 -8
  271. package/lib/types/ink/components/App.d.ts +2 -1
  272. package/lib/types/ink/components/App.d.ts.map +1 -1
  273. package/lib/types/ink/components/App.js +10 -3
  274. package/lib/types/ink/components/ScrollBox.d.ts.map +1 -1
  275. package/lib/types/ink/components/ScrollBox.js +1 -0
  276. package/lib/types/ink/dom.d.ts +1 -0
  277. package/lib/types/ink/dom.d.ts.map +1 -1
  278. package/lib/types/ink/hooks/use-program-status.d.ts +78 -0
  279. package/lib/types/ink/hooks/use-program-status.d.ts.map +1 -0
  280. package/lib/types/ink/hooks/use-program-status.js +96 -0
  281. package/lib/types/ink/ink.d.ts +13 -4
  282. package/lib/types/ink/ink.d.ts.map +1 -1
  283. package/lib/types/ink/ink.js +119 -25
  284. package/lib/types/ink/output.d.ts +17 -2
  285. package/lib/types/ink/output.d.ts.map +1 -1
  286. package/lib/types/ink/output.js +85 -2
  287. package/lib/types/ink/parse-keypress.d.ts +1 -0
  288. package/lib/types/ink/parse-keypress.d.ts.map +1 -1
  289. package/lib/types/ink/parse-keypress.js +5 -4
  290. package/lib/types/ink/render-node-to-output.d.ts +2 -0
  291. package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
  292. package/lib/types/ink/render-node-to-output.js +79 -10
  293. package/lib/types/ink/root.d.ts +8 -0
  294. package/lib/types/ink/root.d.ts.map +1 -1
  295. package/lib/types/ink/root.js +12 -3
  296. package/lib/types/ink/screen.d.ts +11 -0
  297. package/lib/types/ink/screen.d.ts.map +1 -1
  298. package/lib/types/ink/screen.js +44 -0
  299. package/lib/types/ink/selection.d.ts +7 -2
  300. package/lib/types/ink/selection.d.ts.map +1 -1
  301. package/lib/types/ink/selection.js +187 -44
  302. package/lib/types/ink/shutdown-input.d.ts +15 -0
  303. package/lib/types/ink/shutdown-input.d.ts.map +1 -0
  304. package/lib/types/ink/shutdown-input.js +28 -0
  305. package/lib/types/ink/sixel-cursor-heal.d.ts +21 -0
  306. package/lib/types/ink/sixel-cursor-heal.d.ts.map +1 -0
  307. package/lib/types/ink/sixel-cursor-heal.js +62 -0
  308. package/lib/types/ink/sixel-graphics.d.ts +6 -0
  309. package/lib/types/ink/sixel-graphics.d.ts.map +1 -1
  310. package/lib/types/ink/sixel-graphics.js +18 -0
  311. package/lib/types/ink/styles.d.ts +8 -1
  312. package/lib/types/ink/styles.d.ts.map +1 -1
  313. package/lib/types/ink/terminal-notification-windows.d.ts +195 -0
  314. package/lib/types/ink/terminal-notification-windows.d.ts.map +1 -0
  315. package/lib/types/ink/terminal-notification-windows.js +433 -0
  316. package/lib/types/ink/terminal-notification.d.ts +3 -1
  317. package/lib/types/ink/terminal-notification.d.ts.map +1 -1
  318. package/lib/types/ink/terminal-notification.js +4 -1
  319. package/lib/types/ink/terminal-querier.d.ts +9 -1
  320. package/lib/types/ink/terminal-querier.d.ts.map +1 -1
  321. package/lib/types/ink/terminal-querier.js +32 -1
  322. package/lib/types/ink/terminal.d.ts +23 -2
  323. package/lib/types/ink/terminal.d.ts.map +1 -1
  324. package/lib/types/ink/terminal.js +32 -2
  325. package/lib/types/ink/termio/osc.d.ts +2 -1
  326. package/lib/types/ink/termio/osc.d.ts.map +1 -1
  327. package/lib/types/ink/termio/osc.js +37 -8
  328. package/lib/types/ink/termio/osc7501.d.ts +102 -0
  329. package/lib/types/ink/termio/osc7501.d.ts.map +1 -0
  330. package/lib/types/ink/termio/osc7501.js +229 -0
  331. package/lib/types/ink/termio/tokenize.js +5 -7
  332. package/lib/types/panels.d.ts +1 -1
  333. package/lib/types/panels.d.ts.map +1 -1
  334. package/lib/types/screens/AgentTranscriptScene.d.ts +3 -1
  335. package/lib/types/screens/AgentTranscriptScene.d.ts.map +1 -1
  336. package/lib/types/screens/AgentTranscriptScene.js +5 -1
  337. package/lib/types/screens/Chat.d.ts +6 -6
  338. package/lib/types/screens/Chat.d.ts.map +1 -1
  339. package/lib/types/screens/Chat.js +304 -111
  340. package/lib/types/screens/Launchpad.d.ts +8 -2
  341. package/lib/types/screens/Launchpad.d.ts.map +1 -1
  342. package/lib/types/screens/Launchpad.js +32 -12
  343. package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
  344. package/lib/types/screens/SessionSupervisor.js +31 -21
  345. package/lib/types/screens/Settings.d.ts +5 -1
  346. package/lib/types/screens/Settings.d.ts.map +1 -1
  347. package/lib/types/screens/Settings.js +528 -51
  348. package/lib/types/screens/StatusLine.d.ts +9 -3
  349. package/lib/types/screens/StatusLine.d.ts.map +1 -1
  350. package/lib/types/screens/StatusLine.js +91 -15
  351. package/lib/types/screens/StatusMetrics.d.ts +2 -11
  352. package/lib/types/screens/StatusMetrics.d.ts.map +1 -1
  353. package/lib/types/screens/StatusMetrics.js +20 -14
  354. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -1
  355. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +1 -1
  356. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts +1 -1
  357. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts.map +1 -1
  358. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.js +13 -21
  359. package/lib/types/sessionMounts.d.ts +14 -0
  360. package/lib/types/sessionMounts.d.ts.map +1 -1
  361. package/lib/types/sessionMounts.js +20 -9
  362. package/lib/types/sessions/format.d.ts +39 -0
  363. package/lib/types/sessions/format.d.ts.map +1 -1
  364. package/lib/types/sessions/format.js +83 -0
  365. package/lib/types/sessions/resumeFailure.d.ts +4 -0
  366. package/lib/types/sessions/resumeFailure.d.ts.map +1 -1
  367. package/lib/types/sessions/resumeFailure.js +12 -4
  368. package/lib/types/sessions/workspaceCounts.d.ts +6 -0
  369. package/lib/types/sessions/workspaceCounts.d.ts.map +1 -0
  370. package/lib/types/sessions/workspaceCounts.js +24 -0
  371. package/lib/types/settings/definitions.d.ts +24 -0
  372. package/lib/types/settings/definitions.d.ts.map +1 -1
  373. package/lib/types/settings/definitions.js +38 -13
  374. package/lib/types/tips.js +2 -2
  375. package/lib/types/tuiDisplayPrefs.d.ts +113 -5
  376. package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
  377. package/lib/types/tuiDisplayPrefs.js +276 -14
  378. package/lib/types/update.d.ts +46 -36
  379. package/lib/types/update.d.ts.map +1 -1
  380. package/lib/types/update.js +248 -157
  381. package/lib/types/updateProcess.d.ts +28 -0
  382. package/lib/types/updateProcess.d.ts.map +1 -0
  383. package/lib/types/updateProcess.js +135 -0
  384. package/lib/types/utils/inputWordBoundary.d.ts +5 -0
  385. package/lib/types/utils/inputWordBoundary.d.ts.map +1 -0
  386. package/lib/types/utils/inputWordBoundary.js +18 -0
  387. package/lib/types/utils/keymap.d.ts +1 -1
  388. package/lib/types/utils/keymap.d.ts.map +1 -1
  389. package/lib/types/utils/keymap.js +6 -1
  390. package/lib/types/windowsInstaller.d.ts +4 -0
  391. package/lib/types/windowsInstaller.d.ts.map +1 -0
  392. package/lib/types/windowsInstaller.js +237 -0
  393. package/locale/en.json +6 -0
  394. package/locale/zh.json +6 -0
  395. package/package.json +127 -111
  396. package/presets/liangshen/custom-bash.mjs +13 -1
  397. package/presets/liangshen/instruction-hint.mjs +4 -1
  398. package/presets/liangshen/skill-search.mjs +14 -2
  399. package/presets/winbash.mjs +16 -4
  400. package/tui-profile/feed/README.md +17 -8
  401. package/tui-profile/feed/first-party.json +1 -1
@@ -0,0 +1,111 @@
1
+ /** DSH-only read adapter, mounted by the official profile loader (no UI). */
2
+ export const name = 'dst-cli-management'
3
+
4
+ function service(ctx, key) {
5
+ const value = ctx.get(key)
6
+ if (value === undefined) throw Object.assign(new Error(`Missing service ${key}`), { code: 'CAPABILITY_UNAVAILABLE' })
7
+ return value
8
+ }
9
+
10
+ function headerDto(record) {
11
+ const h = record.header
12
+ return {
13
+ sessionId: h.id, cwd: h.cwd, createdAt: h.createdAt,
14
+ ...(h.parentSession === undefined ? {} : { parentSession: h.parentSession }),
15
+ ...(h.agentPreset === undefined ? {} : { agentPreset: h.agentPreset }),
16
+ persisted: record.persisted, live: record.live,
17
+ }
18
+ }
19
+
20
+ function compatible(snapshot, cwd) {
21
+ const h = snapshot.session
22
+ return h.cwd === cwd && h.origin !== 'subagent' && h.parentSession === undefined
23
+ && h.agentPreset === undefined
24
+ && !snapshot.events.some(event => event.type === 'agent-preset/selected')
25
+ }
26
+
27
+ function markdown(snapshot) {
28
+ const lines = [`# Session ${snapshot.session.id}`, '']
29
+ for (const event of snapshot.events) {
30
+ if (!['user/message', 'assistant/message'].includes(event.type)) continue
31
+ const message = event.data?.message
32
+ const text = message?.content?.filter(block => block.type === 'text').map(block => block.text).join('\n')
33
+ if (text) lines.push(`## ${event.type === 'user/message' ? 'User' : 'Assistant'}`, '', text, '')
34
+ }
35
+ return lines.join('\n')
36
+ }
37
+
38
+ /** Public service calls only. No file scanning, private format or credential values. */
39
+ export async function manage(ctx, request) {
40
+ if (request.kind === 'session') {
41
+ const query = service(ctx, 'sessionQuery')
42
+ if (request.action === 'show') return query.readSession(request.sessionId)
43
+ if (request.action === 'export') return markdown(await query.readSurface(request.sessionId))
44
+ const rows = (await query.listSessions()).filter(row => request.all || row.header.cwd === request.cwd)
45
+ if (request.action === 'list') return rows.slice(0, request.limit ?? 50).map(headerDto)
46
+ if (request.action === 'continue') {
47
+ // listSessions is newest-first by header; choose by latest validated activity.
48
+ let latest
49
+ for (const row of rows) {
50
+ if (!row.persisted || row.live || row.header.origin === 'subagent' || row.header.parentSession !== undefined || row.header.agentPreset !== undefined) continue
51
+ const snapshot = await query.readSession(row.header.id)
52
+ if (!compatible(snapshot, request.cwd)) continue
53
+ const time = snapshot.events.at(-1)?.time ?? snapshot.session.createdAt
54
+ if (latest === undefined || time > latest.time) latest = { sessionId: row.header.id, time }
55
+ }
56
+ if (latest === undefined) throw Object.assign(new Error('No compatible session'), { code: 'SESSION_NOT_FOUND' })
57
+ return { sessionId: latest.sessionId }
58
+ }
59
+ }
60
+ if (request.kind === 'models') {
61
+ const llm = service(ctx, 'llm')
62
+ const providers = llm.listProviders().filter(provider => !request.provider || provider.id === request.provider)
63
+ if (request.provider && providers.length === 0) throw Object.assign(new Error('Unknown provider'), { code: 'PROVIDER_NOT_FOUND' })
64
+ const result = []
65
+ for (const provider of providers) {
66
+ const models = await llm.listModels(provider.id)
67
+ result.push({ provider: provider.id, models: models.map(model => ({ id: model.id, name: model.name })) })
68
+ }
69
+ return result
70
+ }
71
+ if (request.kind === 'skills') {
72
+ return (await service(ctx, 'skills').list({ cwd: request.cwd })).map(skill => ({
73
+ name: skill.name, description: skill.description, source: skill.source,
74
+ provider: skill.provider, invocation: skill.invocation,
75
+ }))
76
+ }
77
+ if (request.kind === 'mcp') {
78
+ const names = service(ctx, 'tools').schemas().map(tool => tool.name).filter(name => name.startsWith('mcp__'))
79
+ const servers = new Map()
80
+ for (const name of names) {
81
+ const server = name.split('__')[1]
82
+ const tools = servers.get(server) ?? []
83
+ tools.push(name)
84
+ servers.set(server, tools)
85
+ }
86
+ return { observation: 'registered-tools', connectionHealth: 'unavailable', servers: [...servers].map(([name, tools]) => ({ name, tools })) }
87
+ }
88
+ if (request.kind === 'auth') {
89
+ const info = await service(ctx, 'credentials').describe('DEEPSEEK_API_KEY')
90
+ return { credentialRef: 'DEEPSEEK_API_KEY', configured: info.configured === true, writable: info.writable === true, ...(typeof info.source === 'string' ? { source: info.source } : {}) }
91
+ }
92
+ throw Object.assign(new Error('Unsupported management action'), { code: 'CAPABILITY_UNAVAILABLE' })
93
+ }
94
+
95
+ /** Do not await loader settlement from apply: that would wait on this fiber. */
96
+ export function apply(ctx, config) {
97
+ const run = async () => {
98
+ await ctx.get('loader')?.await()
99
+ const exit = service(ctx, 'appExit')
100
+ try {
101
+ const data = await manage(ctx, config.request)
102
+ await new Promise((resolve, reject) => process.stdout.write(`${JSON.stringify({ schemaVersion: 1, type: 'final', data })}\n`, error => error ? reject(error) : resolve()))
103
+ exit(0)
104
+ } catch (error) {
105
+ const code = error.code === 'SESSION_QUERY_SESSION_NOT_FOUND' ? 'SESSION_NOT_FOUND'
106
+ : ['SESSION_NOT_FOUND', 'PROVIDER_NOT_FOUND', 'CAPABILITY_UNAVAILABLE'].includes(error.code) ? error.code : 'MANAGEMENT_FAILED'
107
+ process.stdout.write(`${JSON.stringify({ schemaVersion: 1, type: 'error', code, message: 'DSH management operation failed' })}\n`, () => exit(1))
108
+ }
109
+ }
110
+ void run().catch(() => ctx.get('appExit')?.(1))
111
+ }
package/cli/args.mjs ADDED
@@ -0,0 +1,154 @@
1
+ /** Backend-neutral command grammar; values are never inferred from TUI state. */
2
+ import { resolve } from 'node:path'
3
+ import { CliError } from './protocol.mjs'
4
+
5
+ const valueFlags = new Map([
6
+ ['--cwd', 'cwd'], ['--workspace', 'cwd'], ['--profile', 'profile'],
7
+ ['--patch', 'patches'], ['--dsh-bin', 'dshBin'], ['--timeout', 'timeout'],
8
+ ['--output-format', 'output'], ['--session-id', 'sessionId'], ['--resume', 'sessionId'],
9
+ ['--limit', 'limit'], ['--provider', 'provider'], ['--model', 'model'],
10
+ ['--permission-mode', 'permission'],
11
+ ])
12
+ const kinds = new Set(['run', 'session', 'models', 'skills', 'mcp', 'auth', 'capabilities', 'dsh'])
13
+ const management = {
14
+ session: ['list', 'show', 'export'], models: ['list'], skills: ['list'],
15
+ mcp: ['status'], auth: ['status'],
16
+ }
17
+
18
+ function usage(message) { throw new CliError('INVALID_ARGUMENT', message, 2) }
19
+
20
+ /** Parse only this CLI's namespace. `dsh` is an opaque argv escape hatch. */
21
+ export function parse(argv, cwd = process.cwd()) {
22
+ const args = [...argv]
23
+ const namespaced = args[0] === 'cli'
24
+ if (namespaced) args.shift()
25
+ if (namespaced && args[0] && !args[0].startsWith('-') && !kinds.has(args[0])) usage(`Unknown CLI command ${args[0]}`)
26
+ const kind = kinds.has(args[0]) ? args.shift() : 'run'
27
+ if (kind === 'dsh') return { kind, args, cwd, timeout: 0, output: 'text' }
28
+ const request = { kind, cwd, profile: 'headless', patches: [], timeout: 0, output: 'text' }
29
+ const positional = []
30
+ const seen = new Set()
31
+ for (let index = 0; index < args.length; index++) {
32
+ const token = args[index]
33
+ if (token === '--') { positional.push(...args.slice(index + 1)); break }
34
+ if (token === '-p' || token === '--print') {
35
+ if (kind !== 'run') usage('--print requires run mode')
36
+ continue
37
+ }
38
+ if (token === '-h' || token === '--help') { request.help = true; continue }
39
+ if (token === '--json') {
40
+ if (seen.has('output')) usage('Output format may be specified only once')
41
+ seen.add('output')
42
+ request.output = 'json'
43
+ continue
44
+ }
45
+ if (token === '-c' || token === '--continue') { request.continue = true; continue }
46
+ if (token === '--all') { request.all = true; continue }
47
+ if (token === '-' || !token.startsWith('-')) { positional.push(token); continue }
48
+ const equal = token.indexOf('=')
49
+ const flag = equal < 0 ? token : token.slice(0, equal)
50
+ const key = valueFlags.get(flag)
51
+ if (key === undefined) usage(`Unknown option ${flag}; use dst dsh for native DSH arguments`)
52
+ const value = equal < 0 ? args[++index] : token.slice(equal + 1)
53
+ if (value === undefined || value === '' || (equal < 0 && value.startsWith('--'))) usage(`${flag} requires a value`)
54
+ if (seen.has(key) && key !== 'patches') usage(`${flag} may be specified only once`)
55
+ seen.add(key)
56
+ if (key === 'patches') request.patches.push(resolve(cwd, value))
57
+ else request[key] = value
58
+ }
59
+ if (request.help) return request
60
+ request.cwd = resolve(cwd, request.cwd)
61
+ if (request.dshBin) request.dshBin = resolve(cwd, request.dshBin)
62
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/u.test(request.profile)) usage('Invalid profile name')
63
+ if (!['text', 'json', 'stream-json'].includes(request.output)) usage('Output format must be text, json, or stream-json')
64
+ for (const key of ['timeout', 'limit']) {
65
+ if (request[key] === undefined) continue
66
+ if (!/^\d+$/u.test(String(request[key]))) usage(`${key} must be an integer`)
67
+ request[key] = Number(request[key])
68
+ if (!Number.isSafeInteger(request[key]) || request[key] > 2147483647 || (key === 'limit' && request[key] < 1)) usage(`Invalid ${key}`)
69
+ }
70
+ if (kind === 'run') {
71
+ if (request.continue && request.sessionId) usage('--continue and --session-id are mutually exclusive')
72
+ if (request.all || request.limit) usage('--all/--limit are session list options')
73
+ if (request.model && !request.provider) usage('--model requires --provider (no guessed model route)')
74
+ if (request.provider && !request.model) usage('--provider requires --model in run mode')
75
+ if (request.permission && !['read-only', 'workspace-write', 'danger-full-access'].includes(request.permission)) usage('Unknown DSH permission mode')
76
+ request.prompt = positional.join(' ')
77
+ if (positional.includes('-') && positional.length !== 1) usage('The stdin marker - must be the only prompt argument')
78
+ } else if (management[kind]) {
79
+ request.action = positional.shift() ?? management[kind][0]
80
+ if (!management[kind].includes(request.action)) usage(`Unknown ${kind} action ${request.action}`)
81
+ if (kind === 'session' && ['show', 'export'].includes(request.action)) {
82
+ if (request.sessionId || !positional[0]) usage(`session ${request.action} requires one positional session id`)
83
+ request.sessionId = positional.shift()
84
+ }
85
+ if (positional.length) usage('Unexpected positional arguments')
86
+ if (request.continue || request.model || request.permission) usage('Run-only option used outside run mode')
87
+ if (request.provider && kind !== 'models') usage('--provider is a models list option')
88
+ if ((request.all || request.limit) && !(kind === 'session' && request.action === 'list')) usage('--all/--limit require session list')
89
+ if (request.sessionId && !(kind === 'session' && ['show', 'export'].includes(request.action))) usage('--session-id is a run option')
90
+ } else {
91
+ if (positional.length || request.continue || request.sessionId || request.model || request.provider || request.permission || request.all || request.limit) usage('Unexpected capability arguments')
92
+ }
93
+ return request
94
+ }
95
+
96
+ /** Output selection for parser failures; values and literal prompt tails are skipped. */
97
+ export function errorFormat(argv) {
98
+ let format = 'text'
99
+ for (let i = 0; i < argv.length; i++) {
100
+ const token = argv[i]
101
+ if (token === '--') break
102
+ if (token === 'dsh' && (i === 0 || (i === 1 && argv[0] === 'cli'))) return 'text'
103
+ if (token === '--json') format = 'json'
104
+ if (token === '--output-format') {
105
+ const value = argv[++i]
106
+ if (['text', 'json', 'stream-json'].includes(value)) format = value
107
+ } else if (token.startsWith('--output-format=')) {
108
+ const value = token.slice('--output-format='.length)
109
+ if (['text', 'json', 'stream-json'].includes(value)) format = value
110
+ } else if (valueFlags.has(token)) i++
111
+ }
112
+ return format
113
+ }
114
+
115
+ export function help() {
116
+ return `Usage: dst run [options] [--] [prompt...]
117
+ dst -p [options] [prompt...]
118
+ dst cli <command> [options]
119
+ dst dsh <native DSH argv...>
120
+
121
+ Commands:
122
+ run Run one DSH task without loading the TUI
123
+ session list List sessions (current cwd; --all, --limit N)
124
+ session show <id> Read the validated durable session log
125
+ session export <id> Export visible text as Markdown (JSON with --json)
126
+ models list List registered provider models (--provider ID)
127
+ skills list List global profile skills for this cwd
128
+ mcp status Report registered MCP tools, not connection health
129
+ auth status Report credential presence; never credential values
130
+ capabilities Describe this adapter and its supported operations
131
+ dsh Forward every remaining argument unchanged to DSH
132
+
133
+ Options:
134
+ -p, --print One-shot mode; alias of run
135
+ --cwd, --workspace DIR Child working directory (default: current directory)
136
+ --profile NAME DSH headless-compatible profile (default: headless)
137
+ --patch FILE Additional DSH overlay, repeatable
138
+ --dsh-bin FILE Explicit official DSH JavaScript bin (not a shell shim)
139
+ --session-id ID Resume an existing compatible DSH session
140
+ -c, --continue Resume newest compatible root session in this cwd
141
+ --provider ID --model ID Exact run model route, applied by a launch overlay
142
+ --permission-mode MODE read-only | workspace-write | danger-full-access
143
+ --output-format FORMAT text | json | stream-json (schemaVersion: 1)
144
+ --json Alias for --output-format json
145
+ --timeout MS Entire invocation deadline; 0 means no deadline
146
+ -h, --help Show this help without starting DSH
147
+
148
+ Piped UTF-8 text is appended after the prompt, separated by two newlines.
149
+ Run output is committed-message streaming, not token streaming. Resume retains
150
+ DSH's preset/fork/cwd restrictions. This CLI does not inherit the TUI profile.
151
+ Exit codes: 0 success, 1 task failure, 2 usage, 3 unavailable, 4 protocol,
152
+ 124 deadline, 130 interrupted, 143 terminated. Native passthrough keeps DSH codes.
153
+ `
154
+ }
@@ -0,0 +1,48 @@
1
+ /** Internal adapter contract. No DSH, TUI or rendering types. */
2
+ export type OutputFormat = 'text' | 'json' | 'stream-json'
3
+ export interface CliRequest {
4
+ kind: 'run' | 'session' | 'models' | 'skills' | 'mcp' | 'auth' | 'capabilities' | 'dsh'
5
+ action?: string
6
+ cwd: string
7
+ profile: string
8
+ patches: string[]
9
+ output: OutputFormat
10
+ timeout: number
11
+ prompt?: string
12
+ sessionId?: string
13
+ continue?: boolean
14
+ dshBin?: string
15
+ args?: string[]
16
+ all?: boolean
17
+ limit?: number
18
+ provider?: string
19
+ model?: string
20
+ permission?: string
21
+ help?: boolean
22
+ }
23
+ export interface AdapterEvent {
24
+ type: string
25
+ /** A final event is provisional until the iterator finishes successfully. */
26
+ ok?: boolean
27
+ sessionId?: string
28
+ phase?: string
29
+ reason?: { kind: string }
30
+ text?: string
31
+ data?: unknown
32
+ code?: string
33
+ message?: string
34
+ }
35
+ export interface ExecutionContext { signal: AbortSignal }
36
+ /** Selection occurs before execution; no fallback/replay after any side effect. */
37
+ export interface CliAdapter {
38
+ readonly id: string
39
+ capabilities(request: CliRequest, context: ExecutionContext): Promise<object>
40
+ execute(request: CliRequest, context: ExecutionContext): AsyncIterable<AdapterEvent>
41
+ continueSession(request: CliRequest, context: ExecutionContext): Promise<string>
42
+ passthrough(request: CliRequest, context: ExecutionContext): Promise<number>
43
+ }
44
+ export interface CliIo {
45
+ stdin: NodeJS.ReadableStream & { isTTY?: boolean; destroy(error?: Error): void }
46
+ stdout: NodeJS.WritableStream
47
+ stderr: NodeJS.WritableStream
48
+ }
package/cli/engine.mjs ADDED
@@ -0,0 +1,92 @@
1
+ /** Pure command orchestration. Adapter selection belongs to entry.mjs only. */
2
+ import { CliError, envelope, failure } from './protocol.mjs'
3
+
4
+ const MAX_INPUT_BYTES = 8 * 1024 * 1024
5
+
6
+ async function inputText(input, signal) {
7
+ if (input.isTTY) return ''
8
+ signal.throwIfAborted()
9
+ const abort = () => input.destroy(signal.reason)
10
+ signal.addEventListener('abort', abort, { once: true })
11
+ let bytes = 0
12
+ const chunks = []
13
+ try {
14
+ for await (const chunk of input) {
15
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)
16
+ bytes += buffer.length
17
+ if (bytes > MAX_INPUT_BYTES) throw new CliError('INPUT_LIMIT', 'Piped input exceeds 8 MiB', 2)
18
+ chunks.push(buffer)
19
+ }
20
+ return Buffer.concat(chunks).toString('utf8')
21
+ } finally { signal.removeEventListener('abort', abort) }
22
+ }
23
+
24
+ async function write(output, text, signal) {
25
+ signal?.throwIfAborted()
26
+ await new Promise((resolve, reject) => {
27
+ const abort = () => reject(signal.reason)
28
+ signal?.addEventListener('abort', abort, { once: true })
29
+ output.write(text, error => {
30
+ signal?.removeEventListener('abort', abort)
31
+ error ? reject(error) : resolve()
32
+ })
33
+ })
34
+ }
35
+
36
+ /** Execute with a preselected adapter. No retry, UI bootstrap or fallback. */
37
+ export async function execute(request, adapter, io, signal) {
38
+ if (request.kind === 'dsh') return adapter.passthrough(request, { signal })
39
+ if (request.kind === 'capabilities') {
40
+ const data = await adapter.capabilities(request, { signal })
41
+ await write(io.stdout, `${JSON.stringify(envelope('capabilities', data), null, request.output === 'text' ? 2 : undefined)}\n`, signal)
42
+ return 0
43
+ }
44
+ if (request.kind === 'run') {
45
+ const piped = await inputText(io.stdin, signal)
46
+ const prompt = request.prompt === '-' ? '' : request.prompt
47
+ const task = [prompt, piped].filter(part => part !== '').join('\n\n')
48
+ if (task.trim() === '') throw new CliError('INVALID_ARGUMENT', 'A prompt or piped UTF-8 input is required', 2)
49
+ request = { ...request, prompt: task }
50
+ if (request.continue) request.sessionId = await adapter.continueSession(request, { signal })
51
+ }
52
+ let final
53
+ let sessionId
54
+ let backendError = false
55
+ for await (const event of adapter.execute(request, { signal })) {
56
+ signal.throwIfAborted()
57
+ if (event.type === 'session') {
58
+ if (sessionId !== undefined || typeof event.sessionId !== 'string' || !event.sessionId) throw new CliError('PROTOCOL_ERROR', 'Invalid or duplicate session event', 4)
59
+ sessionId = event.sessionId
60
+ }
61
+ if (final !== undefined) throw new CliError('PROTOCOL_ERROR', 'Backend emitted events after its final result', 4)
62
+ if (event.type === 'error') backendError = true
63
+ if (event.type === 'final') {
64
+ if (request.kind === 'run' && typeof event.text !== 'string') throw new CliError('PROTOCOL_ERROR', 'Missing final answer text', 4)
65
+ final = event
66
+ continue // Never publish a success until process exit/cleanup is verified.
67
+ }
68
+ if (request.output === 'stream-json') await write(io.stdout, `${JSON.stringify(envelope(event.type, { ...event, schemaVersion: 1 }))}\n`, signal)
69
+ }
70
+ signal.throwIfAborted()
71
+ if (final === undefined) throw new CliError('PROTOCOL_ERROR', 'Backend exited without a final result', 4)
72
+ if (backendError || final.ok !== true || (request.kind === 'run' && sessionId === undefined)) throw new CliError('PROTOCOL_ERROR', 'Backend success disagrees with its committed outcome', 4)
73
+ const result = envelope('result', request.kind === 'run'
74
+ ? { ok: true, sessionId, text: final.text }
75
+ : { ok: true, data: final.data })
76
+ if (request.output === 'text') {
77
+ const text = request.kind === 'run' ? final.text
78
+ : typeof final.data === 'string' ? final.data : JSON.stringify(final.data, null, 2)
79
+ await write(io.stdout, `${text}\n`, signal)
80
+ } else await write(io.stdout, `${JSON.stringify(result)}\n`, signal)
81
+ return 0
82
+ }
83
+
84
+ export async function reportFailure(error, request, io, signal) {
85
+ if (error?.code === 'EPIPE') return 1
86
+ const exitCode = error instanceof CliError ? error.exitCode : 1
87
+ const payload = failure(error)
88
+ if (request?.output === 'json') await write(io.stdout, `${JSON.stringify(envelope('result', { ok: false, error: payload, exitCode }))}\n`, signal)
89
+ else if (request?.output === 'stream-json') await write(io.stdout, `${JSON.stringify(envelope('error', { ...payload, exitCode }))}\n`, signal)
90
+ else await write(io.stderr, `dst: ${payload.code}: ${payload.message}\n`, signal)
91
+ return exitCode
92
+ }
package/cli/entry.mjs ADDED
@@ -0,0 +1,48 @@
1
+ /** Composition root: the only module binding the engine to its default adapter. */
2
+ import { realpath, stat } from 'node:fs/promises'
3
+ import { fileURLToPath } from 'node:url'
4
+ import { parse, help, errorFormat } from './args.mjs'
5
+ import { execute, reportFailure } from './engine.mjs'
6
+ import { CliError } from './protocol.mjs'
7
+ import { createDshAdapter } from './adapters/dsh/index.mjs'
8
+
9
+ /** Injectable adapter is an embedding/testing seam, not untrusted CLI code loading. */
10
+ export async function main(argv = process.argv.slice(2), options = {}) {
11
+ const io = options.io ?? { stdin: process.stdin, stdout: process.stdout, stderr: process.stderr }
12
+ const controller = new AbortController()
13
+ const abort = (code, message, exitCode) => controller.abort(new CliError(code, message, exitCode))
14
+ const interrupt = () => abort('INTERRUPTED', 'Invocation interrupted', 130)
15
+ const terminate = () => abort('TERMINATED', 'Invocation terminated', 143)
16
+ const brokenPipe = error => { if (error.code === 'EPIPE') abort('BROKEN_PIPE', 'Output consumer closed the pipe', 1) }
17
+ process.on('SIGINT', interrupt)
18
+ process.on('SIGTERM', terminate)
19
+ io.stdout.on('error', brokenPipe)
20
+ let timer
21
+ let request = { output: errorFormat(argv) }
22
+ try {
23
+ request = parse(argv)
24
+ if (request.help) { io.stdout.write(help()); return 0 }
25
+ let directory
26
+ try { request.cwd = await realpath(request.cwd); directory = await stat(request.cwd) } catch { throw new CliError('INVALID_ARGUMENT', 'Working directory does not exist', 2) }
27
+ if (!directory.isDirectory()) throw new CliError('INVALID_ARGUMENT', 'Working directory is not a directory', 2)
28
+ if (request.timeout > 0) timer = setTimeout(() => abort('TIMEOUT', 'Invocation deadline exceeded', 124), request.timeout)
29
+ return await execute(request, options.adapter ?? createDshAdapter(), io, controller.signal)
30
+ } catch (error) {
31
+ const reason = controller.signal.aborted ? controller.signal.reason : error
32
+ // A blocked downstream must not turn reporting a deadline into another
33
+ // unbounded wait. No successful result is written through this path.
34
+ const reporting = new AbortController()
35
+ const reportTimer = setTimeout(() => reporting.abort(new CliError('OUTPUT_CLOSED', 'Error output did not drain', 1)), 1000)
36
+ try { return await reportFailure(reason, request, io, reporting.signal) } catch { return reason instanceof CliError ? reason.exitCode : 1 }
37
+ finally { clearTimeout(reportTimer) }
38
+ } finally {
39
+ clearTimeout(timer)
40
+ process.removeListener('SIGINT', interrupt)
41
+ process.removeListener('SIGTERM', terminate)
42
+ io.stdout.removeListener('error', brokenPipe)
43
+ }
44
+ }
45
+
46
+ // Node resolves module URLs, but argv may retain a symlinked path (including macOS /var).
47
+ const invokedPath = process.argv[1] && await realpath(process.argv[1]).catch(() => undefined)
48
+ if (invokedPath && await realpath(fileURLToPath(import.meta.url)) === invokedPath) process.exitCode = await main()
@@ -0,0 +1,118 @@
1
+ /** Process ownership and bounded NDJSON framing. No backend or UI imports. */
2
+ import { spawn } from 'node:child_process'
3
+ import { StringDecoder } from 'node:string_decoder'
4
+ import { join } from 'node:path'
5
+ import { CliError } from './protocol.mjs'
6
+
7
+ export const MAX_RECORD_BYTES = 32 * 1024 * 1024
8
+
9
+ /** Start exactly one process; abort reaps its process tree before completion. */
10
+ export function startProcess(spec, signal, diagnostic = () => {}) {
11
+ signal.throwIfAborted()
12
+ const child = spawn(spec.command, spec.args, {
13
+ cwd: spec.cwd, env: spec.env, shell: false,
14
+ detached: !spec.inherit && process.platform !== 'win32', windowsHide: true,
15
+ stdio: spec.inherit ? 'inherit' : ['pipe', 'pipe', 'pipe'],
16
+ })
17
+ let spawnError
18
+ let escalation
19
+ let drainDeadline
20
+ let drainFailed = false
21
+ let killer
22
+ let closed = false
23
+ child.stdin?.on('error', error => { if (error.code !== 'EPIPE' && error.code !== 'ERR_STREAM_DESTROYED') spawnError = error })
24
+ if (spec.input !== undefined) child.stdin?.end(spec.input)
25
+ else child.stdin?.end()
26
+ const kill = force => {
27
+ if (closed || child.pid === undefined) return
28
+ if (process.platform === 'win32') {
29
+ // Node's Windows kill is not a cooperative signal. Own the exact tree.
30
+ if (killer === undefined) {
31
+ const command = join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'taskkill.exe')
32
+ killer = spawn(command, ['/pid', String(child.pid), '/t', '/f'], { stdio: 'ignore', windowsHide: true })
33
+ killer.once('error', () => { child.kill('SIGKILL') })
34
+ killer.once('exit', code => { if (code !== 0 && !closed) child.kill('SIGKILL') })
35
+ } else if (force) child.kill('SIGKILL')
36
+ } else {
37
+ try {
38
+ if (spec.inherit) child.kill(force ? 'SIGKILL' : 'SIGTERM')
39
+ else process.kill(-child.pid, force ? 'SIGKILL' : 'SIGTERM')
40
+ } catch (error) {
41
+ if (error.code !== 'ESRCH') child.kill(force ? 'SIGKILL' : 'SIGTERM')
42
+ }
43
+ }
44
+ }
45
+ const abort = () => {
46
+ if (closed) return
47
+ kill(false)
48
+ escalation ??= setTimeout(() => kill(true), 5000)
49
+ }
50
+ const completion = new Promise(resolve => {
51
+ child.once('error', error => { spawnError = error })
52
+ child.once('exit', () => {
53
+ // A descendant holding inherited pipes must not keep a finished run alive.
54
+ drainDeadline = setTimeout(() => {
55
+ if (closed) return
56
+ drainFailed = true
57
+ kill(true)
58
+ child.stdout?.destroy()
59
+ child.stderr?.destroy()
60
+ }, 2000)
61
+ })
62
+ child.once('close', (code, exitSignal) => {
63
+ closed = true
64
+ signal.removeEventListener('abort', abort)
65
+ clearTimeout(escalation)
66
+ clearTimeout(drainDeadline)
67
+ resolve({ code: code ?? 1, signal: exitSignal, error: spawnError, drainFailed })
68
+ })
69
+ })
70
+ signal.addEventListener('abort', abort, { once: true })
71
+ if (signal.aborted) abort()
72
+ const stderr = child.stderr === null ? Promise.resolve() : (async () => {
73
+ const decoder = new StringDecoder('utf8')
74
+ for await (const chunk of child.stderr) diagnostic(decoder.write(chunk))
75
+ const tail = decoder.end()
76
+ if (tail) diagnostic(tail)
77
+ })().catch(error => { spawnError ??= error; abort() })
78
+ // Observe both owned promises even when parsing or a consumer fails.
79
+ const settled = Promise.all([completion, stderr]).then(async ([result]) => {
80
+ if (killer && killer.exitCode === null && killer.signalCode === null) await new Promise(resolve => killer.once('close', resolve))
81
+ return result
82
+ })
83
+ settled.catch(() => {})
84
+ return { child, settled, stop: abort }
85
+ }
86
+
87
+ /** Complete newline-delimited records, including UTF-8 split across buffers. */
88
+ export async function* records(stream, maxBytes = MAX_RECORD_BYTES) {
89
+ let parts = []
90
+ let bytes = 0
91
+ for await (const chunk of stream) {
92
+ let start = 0
93
+ for (let index = 0; index < chunk.length; index++) {
94
+ if (chunk[index] !== 10) continue
95
+ const part = chunk.subarray(start, index)
96
+ if (bytes + part.length > maxBytes) throw new CliError('OUTPUT_LIMIT', 'Backend record exceeds the CLI byte limit', 4)
97
+ parts.push(part)
98
+ const line = Buffer.concat(parts).toString('utf8').replace(/\r$/u, '')
99
+ parts = []
100
+ bytes = 0
101
+ start = index + 1
102
+ if (line !== '') yield line
103
+ }
104
+ const tail = chunk.subarray(start)
105
+ bytes += tail.length
106
+ if (bytes > maxBytes) throw new CliError('OUTPUT_LIMIT', 'Backend record exceeds the CLI byte limit', 4)
107
+ if (tail.length) parts.push(tail)
108
+ }
109
+ if (bytes > 0) throw new CliError('PROTOCOL_ERROR', 'Backend ended with an incomplete JSONL record', 4)
110
+ }
111
+
112
+ export function parseRecord(line) {
113
+ try {
114
+ const value = JSON.parse(line)
115
+ if (value === null || typeof value !== 'object' || Array.isArray(value) || typeof value.type !== 'string') throw new Error('record')
116
+ return value
117
+ } catch { throw new CliError('PROTOCOL_ERROR', 'Backend returned an invalid JSONL record', 4) }
118
+ }
@@ -0,0 +1,23 @@
1
+ /** Versioned CLI DTOs. No UI, backend or process dependencies. */
2
+ export const SCHEMA_VERSION = 1
3
+
4
+ /** Stable automation failures; backend failure details stay on stderr. */
5
+ export class CliError extends Error {
6
+ constructor(code, message, exitCode = 1) {
7
+ super(message)
8
+ this.name = 'CliError'
9
+ this.code = code
10
+ this.exitCode = exitCode
11
+ }
12
+ }
13
+
14
+ export function envelope(type, fields = {}) {
15
+ return { schemaVersion: SCHEMA_VERSION, type, ...fields }
16
+ }
17
+
18
+ export function failure(error) {
19
+ return {
20
+ code: error instanceof CliError ? error.code : 'INTERNAL_ERROR',
21
+ message: error instanceof CliError ? error.message : 'CLI operation failed; inspect controlled diagnostics.',
22
+ }
23
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://dshtui.com/schemas/cli-v1.json",
4
+ "title": "dst CLI v1 record",
5
+ "type": "object",
6
+ "required": ["schemaVersion", "type"],
7
+ "properties": {
8
+ "schemaVersion": { "const": 1 },
9
+ "type": { "enum": ["capabilities", "session", "status", "text", "thinking", "tool_call", "tool_result", "error", "result"] },
10
+ "ok": { "type": "boolean" },
11
+ "sessionId": { "type": "string", "minLength": 1 },
12
+ "text": { "type": "string" },
13
+ "exitCode": { "type": "integer" },
14
+ "error": {
15
+ "type": "object",
16
+ "required": ["code", "message"],
17
+ "properties": { "code": { "type": "string" }, "message": { "type": "string" } }
18
+ }
19
+ },
20
+ "allOf": [
21
+ {
22
+ "if": { "properties": { "type": { "const": "result" } } },
23
+ "then": {
24
+ "required": ["ok"],
25
+ "oneOf": [
26
+ { "properties": { "ok": { "const": true } }, "not": { "required": ["error"] } },
27
+ { "properties": { "ok": { "const": false } }, "required": ["error", "exitCode"] }
28
+ ]
29
+ }
30
+ }
31
+ ],
32
+ "additionalProperties": true
33
+ }
package/cordis.patch.yml CHANGED
@@ -437,9 +437,11 @@
437
437
  terminalImages: true
438
438
  # diffLayout: auto
439
439
  # mermaidDiagrams: true
440
- # 任务完成通知:off / unfocused(默认)/ always;方式:auto(默认)/ osc9 / bel。
440
+ # 任务完成通知:off / unfocused(默认)/ always;方式:auto(默认)/ osc9 / bel / windows。
441
441
  # taskNotifications: unfocused
442
442
  # notificationMethod: auto
443
+ # windows 档:Windows 主机原生 toast(首次注册当前用户的 HKCU 标识,约延迟 3 秒)。
444
+ # auto 在 Windows 本地会话用此档,SSH 改走客户端终端;仅 DSH 会话且 cc-dsh-notifier 已启用、正在运行时让位。
443
445
  # 回复中 LaTeX 公式的显示方式:auto(默认,目前为 Unicode)/ image(支持图形的终端里块级公式显示为图片)/ unicode / source(保留源码)。/settings 可实时改。
444
446
  # mathRendering: auto
445
447
  # 每个请求实际生效的推理强度,按当前路由的 adapter 档位校验
package/cordis.yml CHANGED
@@ -64,9 +64,11 @@
64
64
  # 以下为 /settings 可改的显示设置;每项说明与默认值见应用内 /settings 屏。
65
65
  terminalImages: true
66
66
  # mermaidDiagrams: true
67
- # 任务完成通知:off / unfocused(默认)/ always;方式:auto(默认)/ osc9 / bel。
67
+ # 任务完成通知:off / unfocused(默认)/ always;方式:auto(默认)/ osc9 / bel / windows。
68
68
  # taskNotifications: unfocused
69
69
  # notificationMethod: auto
70
+ # windows 档:Windows 主机原生 toast(首次注册当前用户的 HKCU 标识,约延迟 3 秒)。
71
+ # auto 在 Windows 本地会话用此档,SSH 改走客户端终端;仅 DSH 会话且 cc-dsh-notifier 已启用、正在运行时让位。
70
72
  # 回复中 LaTeX 公式的显示方式:auto(默认,目前为 Unicode)/ image(支持图形的终端里块级公式显示为图片)/ unicode / source(保留源码)。/settings 可实时改。
71
73
  # mathRendering: auto
72
74
  # Reasoning effort applied to every request, validated against the live