@deepseek-harness-tui/dsh-tui 0.16.1 → 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 (394) hide show
  1. package/README.md +208 -31
  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/cli.en.md +114 -0
  20. package/guide/dsh-tui-guide/cli.md +114 -0
  21. package/guide/dsh-tui-guide/configuration.en.md +6 -5
  22. package/guide/dsh-tui-guide/configuration.md +6 -5
  23. package/guide/dsh-tui-guide/getting-started.en.md +27 -1
  24. package/guide/dsh-tui-guide/getting-started.md +19 -1
  25. package/guide/dsh-tui-guide/interaction.en.md +22 -10
  26. package/guide/dsh-tui-guide/interaction.md +18 -8
  27. package/guide/dsh-tui-guide/plugins.en.md +35 -4
  28. package/guide/dsh-tui-guide/plugins.md +23 -2
  29. package/guide/dsh-tui-guide/user-guide.en.md +30 -23
  30. package/guide/dsh-tui-guide/user-guide.md +29 -22
  31. package/lib/settings.json +83 -40
  32. package/lib/types/adapter/channel/plugins.d.ts.map +1 -1
  33. package/lib/types/adapter/channel/plugins.js +8 -0
  34. package/lib/types/adapter/channel/ui-policy.d.ts +1 -1
  35. package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
  36. package/lib/types/adapter/channel/ui-policy.js +3 -0
  37. package/lib/types/adapter/ports/channel-display.d.ts +10 -0
  38. package/lib/types/adapter/ports/channel-display.d.ts.map +1 -1
  39. package/lib/types/adapter/ports/channel-session.d.ts +2 -0
  40. package/lib/types/adapter/ports/channel-session.d.ts.map +1 -1
  41. package/lib/types/adapter/ports/channel-settings.d.ts +20 -0
  42. package/lib/types/adapter/ports/channel-settings.d.ts.map +1 -1
  43. package/lib/types/adapter/ports/channel-ui.d.ts +17 -2
  44. package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
  45. package/lib/types/adapter/ports/channel-view.d.ts +8 -1
  46. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  47. package/lib/types/adapter/ports/channel.d.ts +7 -0
  48. package/lib/types/adapter/ports/channel.d.ts.map +1 -1
  49. package/lib/types/agent/capabilities.d.ts +2 -0
  50. package/lib/types/agent/capabilities.d.ts.map +1 -1
  51. package/lib/types/agent/events.d.ts +8 -0
  52. package/lib/types/agent/events.d.ts.map +1 -1
  53. package/lib/types/api.d.ts +2 -2
  54. package/lib/types/api.d.ts.map +1 -1
  55. package/lib/types/backends/claude/translate/events.d.ts.map +1 -1
  56. package/lib/types/backends/claude/translate/events.js +2 -1
  57. package/lib/types/backends/codex/auth/status.js +1 -1
  58. package/lib/types/backends/codex/session/controls.d.ts.map +1 -1
  59. package/lib/types/backends/codex/session/controls.js +6 -5
  60. package/lib/types/backends/codex/session/goals.d.ts.map +1 -1
  61. package/lib/types/backends/codex/session/side-query.d.ts.map +1 -1
  62. package/lib/types/backends/codex/translate/events.d.ts.map +1 -1
  63. package/lib/types/backends/codex/translate/events.js +3 -1
  64. package/lib/types/backends/shared/channel-tokens.d.ts.map +1 -1
  65. package/lib/types/backends/shared/channel-tokens.js +9 -8
  66. package/lib/types/channel/history-restore.d.ts.map +1 -1
  67. package/lib/types/channel/history-restore.js +2 -0
  68. package/lib/types/channel/interaction.d.ts.map +1 -1
  69. package/lib/types/channel/interaction.js +1 -0
  70. package/lib/types/channel/projection.d.ts +1 -1
  71. package/lib/types/channel/projection.d.ts.map +1 -1
  72. package/lib/types/channel/projection.js +19 -4
  73. package/lib/types/channel/questions.d.ts +2 -0
  74. package/lib/types/channel/questions.d.ts.map +1 -1
  75. package/lib/types/channel/sanitize.d.ts +14 -0
  76. package/lib/types/channel/sanitize.d.ts.map +1 -1
  77. package/lib/types/channel/sanitize.js +55 -0
  78. package/lib/types/channel/working-directory.d.ts +9 -0
  79. package/lib/types/channel/working-directory.d.ts.map +1 -0
  80. package/lib/types/channel/working-directory.js +7 -0
  81. package/lib/types/commands.d.ts +8 -1
  82. package/lib/types/commands.d.ts.map +1 -1
  83. package/lib/types/commands.js +13 -4
  84. package/lib/types/components/ChatTitle.d.ts +7 -0
  85. package/lib/types/components/ChatTitle.d.ts.map +1 -0
  86. package/lib/types/components/ChatTitle.js +15 -0
  87. package/lib/types/components/CodeBlockFrame.d.ts.map +1 -1
  88. package/lib/types/components/CodeBlockFrame.js +10 -5
  89. package/lib/types/components/CompactionStatusRow.d.ts.map +1 -1
  90. package/lib/types/components/CompactionStatusRow.js +24 -3
  91. package/lib/types/components/GoalTodoPanel.d.ts +3 -1
  92. package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
  93. package/lib/types/components/GoalTodoPanel.js +2 -2
  94. package/lib/types/components/Markdown.d.ts +9 -1
  95. package/lib/types/components/Markdown.d.ts.map +1 -1
  96. package/lib/types/components/Markdown.js +5 -4
  97. package/lib/types/components/MessageList.d.ts.map +1 -1
  98. package/lib/types/components/MessageList.js +17 -12
  99. package/lib/types/components/PromptInput.d.ts +13 -5
  100. package/lib/types/components/PromptInput.d.ts.map +1 -1
  101. package/lib/types/components/PromptInput.js +189 -107
  102. package/lib/types/components/SplitDiffView.d.ts.map +1 -1
  103. package/lib/types/components/SplitDiffView.js +232 -22
  104. package/lib/types/components/SubagentDetailScene.d.ts +3 -1
  105. package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
  106. package/lib/types/components/SubagentDetailScene.js +5 -1
  107. package/lib/types/components/Whale.d.ts.map +1 -1
  108. package/lib/types/components/Whale.js +8 -5
  109. package/lib/types/components/approvals/ApprovalPanel.d.ts +1 -1
  110. package/lib/types/components/approvals/ApprovalPanel.d.ts.map +1 -1
  111. package/lib/types/components/approvals/ApprovalPanel.js +93 -11
  112. package/lib/types/components/bigfont.d.ts.map +1 -1
  113. package/lib/types/components/bigfont.js +2 -1
  114. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  115. package/lib/types/components/messages/AssistantToolUseMessage.js +13 -6
  116. package/lib/types/components/previewRows.d.ts +19 -0
  117. package/lib/types/components/previewRows.d.ts.map +1 -0
  118. package/lib/types/components/previewRows.js +46 -0
  119. package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
  120. package/lib/types/components/questions/AskUserQuestionPanel.js +75 -10
  121. package/lib/types/components/sessions/ForeignSessionRow.d.ts +3 -9
  122. package/lib/types/components/sessions/ForeignSessionRow.d.ts.map +1 -1
  123. package/lib/types/components/sessions/ForeignSessionRow.js +6 -10
  124. package/lib/types/components/sessions/SessionListRow.d.ts +4 -9
  125. package/lib/types/components/sessions/SessionListRow.d.ts.map +1 -1
  126. package/lib/types/components/sessions/SessionListRow.js +18 -10
  127. package/lib/types/components/sidePanel/InfoPanel.d.ts.map +1 -1
  128. package/lib/types/components/sidePanel/InfoPanel.js +4 -3
  129. package/lib/types/components/sidePanel/SidePanelLayout.d.ts.map +1 -1
  130. package/lib/types/components/sidePanel/SidePanelLayout.js +5 -5
  131. package/lib/types/components/sidePanel/WorkspacePanel.d.ts.map +1 -1
  132. package/lib/types/components/sidePanel/WorkspacePanel.js +19 -7
  133. package/lib/types/components/sidePanel/builtinPanels.d.ts.map +1 -1
  134. package/lib/types/components/sidePanel/builtinPanels.js +22 -16
  135. package/lib/types/components/sidePanel/companion/CompanionPanel.d.ts.map +1 -1
  136. package/lib/types/components/sidePanel/companion/CompanionPanel.js +2 -1
  137. package/lib/types/components/sidePanel/panelMarkdown.d.ts +32 -0
  138. package/lib/types/components/sidePanel/panelMarkdown.d.ts.map +1 -0
  139. package/lib/types/components/sidePanel/panelMarkdown.js +45 -0
  140. package/lib/types/components/sidePanel/pluginPanelAdapter.d.ts.map +1 -1
  141. package/lib/types/components/sidePanel/pluginPanelAdapter.js +6 -1
  142. package/lib/types/components/sidePanel/subagentFailureRead.d.ts +21 -0
  143. package/lib/types/components/sidePanel/subagentFailureRead.d.ts.map +1 -0
  144. package/lib/types/components/sidePanel/subagentFailureRead.js +66 -0
  145. package/lib/types/components/sidePanel/useSidePanel.d.ts.map +1 -1
  146. package/lib/types/components/sidePanel/useSidePanel.js +24 -6
  147. package/lib/types/components/trajectory/MiniWake.d.ts +2 -2
  148. package/lib/types/components/trajectory/MiniWake.d.ts.map +1 -1
  149. package/lib/types/components/trajectory/MiniWake.js +7 -3
  150. package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts.map +1 -1
  151. package/lib/types/components/workspaces/HomeWorkspaceRow.js +4 -7
  152. package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
  153. package/lib/types/dsh-adapter/backend/translate.js +11 -1
  154. package/lib/types/dsh-adapter/backend-admission.d.ts +3 -3
  155. package/lib/types/dsh-adapter/channel/binding-events.d.ts +5 -1
  156. package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
  157. package/lib/types/dsh-adapter/channel/binding-events.js +18 -1
  158. package/lib/types/dsh-adapter/channel/command-completions.d.ts.map +1 -1
  159. package/lib/types/dsh-adapter/channel/command-completions.js +6 -8
  160. package/lib/types/dsh-adapter/channel/composer-images.d.ts +9 -1
  161. package/lib/types/dsh-adapter/channel/composer-images.d.ts.map +1 -1
  162. package/lib/types/dsh-adapter/channel/composer-images.js +111 -111
  163. package/lib/types/dsh-adapter/channel/composer-mentions.d.ts.map +1 -1
  164. package/lib/types/dsh-adapter/channel/composer-mentions.js +16 -10
  165. package/lib/types/dsh-adapter/channel/core/actions.d.ts +1 -1
  166. package/lib/types/dsh-adapter/channel/core/actions.d.ts.map +1 -1
  167. package/lib/types/dsh-adapter/channel/core/actions.js +23 -2
  168. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts +4 -1
  169. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts.map +1 -1
  170. package/lib/types/dsh-adapter/channel/core/binding-feed.js +13 -2
  171. package/lib/types/dsh-adapter/channel/core/compose.d.ts +4 -1
  172. package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
  173. package/lib/types/dsh-adapter/channel/core/compose.js +2 -0
  174. package/lib/types/dsh-adapter/channel/core/files.d.ts.map +1 -1
  175. package/lib/types/dsh-adapter/channel/core/files.js +2 -1
  176. package/lib/types/dsh-adapter/channel/core/host.d.ts +14 -10
  177. package/lib/types/dsh-adapter/channel/core/host.d.ts.map +1 -1
  178. package/lib/types/dsh-adapter/channel/core/host.js +192 -13
  179. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts +1 -0
  180. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts.map +1 -1
  181. package/lib/types/dsh-adapter/channel/core/local-actions.js +32 -3
  182. package/lib/types/dsh-adapter/channel/extensions.d.ts.map +1 -1
  183. package/lib/types/dsh-adapter/channel/extensions.js +31 -5
  184. package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
  185. package/lib/types/dsh-adapter/channel/input-actions.js +4 -0
  186. package/lib/types/dsh-adapter/channel/input-delivery.d.ts +4 -1
  187. package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
  188. package/lib/types/dsh-adapter/channel/input-delivery.js +24 -1
  189. package/lib/types/dsh-adapter/channel/model-actions.d.ts +1 -1
  190. package/lib/types/dsh-adapter/channel/model-actions.d.ts.map +1 -1
  191. package/lib/types/dsh-adapter/channel/model-actions.js +7 -1
  192. package/lib/types/dsh-adapter/channel/model-selection.d.ts.map +1 -1
  193. package/lib/types/dsh-adapter/channel/model-selection.js +6 -4
  194. package/lib/types/dsh-adapter/channel/session-fork.d.ts.map +1 -1
  195. package/lib/types/dsh-adapter/channel/session-fork.js +1 -0
  196. package/lib/types/dsh-adapter/channel/session-metadata.d.ts.map +1 -1
  197. package/lib/types/dsh-adapter/channel/session-metadata.js +15 -2
  198. package/lib/types/dsh-adapter/channel/session-reset.d.ts +1 -1
  199. package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
  200. package/lib/types/dsh-adapter/channel/session-reset.js +4 -0
  201. package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
  202. package/lib/types/dsh-adapter/channel/session-resume.js +46 -33
  203. package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
  204. package/lib/types/dsh-adapter/channel/settings-host.js +10 -3
  205. package/lib/types/dsh-adapter/channel/state.d.ts +1 -1
  206. package/lib/types/dsh-adapter/channel/state.d.ts.map +1 -1
  207. package/lib/types/dsh-adapter/channel/state.js +2 -2
  208. package/lib/types/dsh-adapter/channel/types.d.ts +13 -1
  209. package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
  210. package/lib/types/dsh-adapter/compat/liveSession.d.ts +3 -3
  211. package/lib/types/dsh-adapter/compat/liveSession.js +3 -3
  212. package/lib/types/dsh-adapter/compat/sessionLog.d.ts +1 -1
  213. package/lib/types/dsh-adapter/compat/sessionLog.d.ts.map +1 -1
  214. package/lib/types/dsh-adapter/compat/sessionLog.js +17 -1
  215. package/lib/types/dsh-adapter/contract.d.ts +6 -5
  216. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  217. package/lib/types/dsh-adapter/contract.js +7 -5
  218. package/lib/types/dsh-adapter/effect-ledger.d.ts +1 -1
  219. package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -1
  220. package/lib/types/dsh-adapter/effect-ledger.js +1 -0
  221. package/lib/types/dsh-adapter/experimental-bundles.d.ts +26 -0
  222. package/lib/types/dsh-adapter/experimental-bundles.d.ts.map +1 -0
  223. package/lib/types/dsh-adapter/experimental-bundles.js +11 -0
  224. package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
  225. package/lib/types/dsh-adapter/host-contract.js +1 -1
  226. package/lib/types/dsh-adapter/host-dsh.js +3 -3
  227. package/lib/types/dsh-adapter/index.d.ts +8 -4
  228. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  229. package/lib/types/dsh-adapter/index.js +9 -7
  230. package/lib/types/dsh-adapter/panels.d.ts +21 -7
  231. package/lib/types/dsh-adapter/panels.d.ts.map +1 -1
  232. package/lib/types/dsh-adapter/panels.js +11 -56
  233. package/lib/types/dsh-adapter/plugin.d.ts +81 -0
  234. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  235. package/lib/types/dsh-adapter/plugin.js +318 -70
  236. package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -1
  237. package/lib/types/dsh-adapter/plugins-info.js +65 -10
  238. package/lib/types/dsh-adapter/presets.d.ts +15 -6
  239. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  240. package/lib/types/dsh-adapter/presets.js +51 -12
  241. package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
  242. package/lib/types/dsh-adapter/process-exit.js +1 -1
  243. package/lib/types/dsh-adapter/session-tools.d.ts +34 -0
  244. package/lib/types/dsh-adapter/session-tools.d.ts.map +1 -0
  245. package/lib/types/dsh-adapter/session-tools.js +39 -0
  246. package/lib/types/dsh-adapter/settings-sections.d.ts +18 -1
  247. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
  248. package/lib/types/dsh-adapter/settings-sections.js +73 -0
  249. package/lib/types/dsh-adapter/status.d.ts +88 -1
  250. package/lib/types/dsh-adapter/status.d.ts.map +1 -1
  251. package/lib/types/dsh-adapter/status.js +318 -3
  252. package/lib/types/dsh-adapter/team-mode.d.ts +42 -33
  253. package/lib/types/dsh-adapter/team-mode.d.ts.map +1 -1
  254. package/lib/types/dsh-adapter/team-mode.js +76 -112
  255. package/lib/types/extensions.d.ts +1 -1
  256. package/lib/types/extensions.d.ts.map +1 -1
  257. package/lib/types/force-production-react.js +3 -3
  258. package/lib/types/i18n.d.ts +195 -52
  259. package/lib/types/i18n.d.ts.map +1 -1
  260. package/lib/types/i18n.js +96 -30
  261. package/lib/types/ink/colorize.d.ts +7 -1
  262. package/lib/types/ink/colorize.d.ts.map +1 -1
  263. package/lib/types/ink/colorize.js +29 -8
  264. package/lib/types/ink/components/App.d.ts +2 -1
  265. package/lib/types/ink/components/App.d.ts.map +1 -1
  266. package/lib/types/ink/components/App.js +10 -3
  267. package/lib/types/ink/components/ScrollBox.d.ts.map +1 -1
  268. package/lib/types/ink/components/ScrollBox.js +1 -0
  269. package/lib/types/ink/dom.d.ts +1 -0
  270. package/lib/types/ink/dom.d.ts.map +1 -1
  271. package/lib/types/ink/hooks/use-program-status.d.ts +78 -0
  272. package/lib/types/ink/hooks/use-program-status.d.ts.map +1 -0
  273. package/lib/types/ink/hooks/use-program-status.js +96 -0
  274. package/lib/types/ink/ink.d.ts +13 -4
  275. package/lib/types/ink/ink.d.ts.map +1 -1
  276. package/lib/types/ink/ink.js +119 -25
  277. package/lib/types/ink/output.d.ts +17 -2
  278. package/lib/types/ink/output.d.ts.map +1 -1
  279. package/lib/types/ink/output.js +85 -2
  280. package/lib/types/ink/parse-keypress.d.ts +1 -0
  281. package/lib/types/ink/parse-keypress.d.ts.map +1 -1
  282. package/lib/types/ink/parse-keypress.js +5 -4
  283. package/lib/types/ink/render-node-to-output.d.ts +2 -0
  284. package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
  285. package/lib/types/ink/render-node-to-output.js +79 -10
  286. package/lib/types/ink/root.d.ts +8 -0
  287. package/lib/types/ink/root.d.ts.map +1 -1
  288. package/lib/types/ink/root.js +12 -3
  289. package/lib/types/ink/screen.d.ts +11 -0
  290. package/lib/types/ink/screen.d.ts.map +1 -1
  291. package/lib/types/ink/screen.js +44 -0
  292. package/lib/types/ink/selection.d.ts +7 -2
  293. package/lib/types/ink/selection.d.ts.map +1 -1
  294. package/lib/types/ink/selection.js +187 -44
  295. package/lib/types/ink/shutdown-input.d.ts +15 -0
  296. package/lib/types/ink/shutdown-input.d.ts.map +1 -0
  297. package/lib/types/ink/shutdown-input.js +28 -0
  298. package/lib/types/ink/sixel-cursor-heal.d.ts +21 -0
  299. package/lib/types/ink/sixel-cursor-heal.d.ts.map +1 -0
  300. package/lib/types/ink/sixel-cursor-heal.js +62 -0
  301. package/lib/types/ink/sixel-graphics.d.ts +6 -0
  302. package/lib/types/ink/sixel-graphics.d.ts.map +1 -1
  303. package/lib/types/ink/sixel-graphics.js +18 -0
  304. package/lib/types/ink/styles.d.ts +8 -1
  305. package/lib/types/ink/styles.d.ts.map +1 -1
  306. package/lib/types/ink/terminal-notification-windows.d.ts +195 -0
  307. package/lib/types/ink/terminal-notification-windows.d.ts.map +1 -0
  308. package/lib/types/ink/terminal-notification-windows.js +433 -0
  309. package/lib/types/ink/terminal-notification.d.ts +3 -1
  310. package/lib/types/ink/terminal-notification.d.ts.map +1 -1
  311. package/lib/types/ink/terminal-notification.js +4 -1
  312. package/lib/types/ink/terminal-querier.d.ts +9 -1
  313. package/lib/types/ink/terminal-querier.d.ts.map +1 -1
  314. package/lib/types/ink/terminal-querier.js +32 -1
  315. package/lib/types/ink/terminal.d.ts +23 -2
  316. package/lib/types/ink/terminal.d.ts.map +1 -1
  317. package/lib/types/ink/terminal.js +32 -2
  318. package/lib/types/ink/termio/osc.d.ts +2 -1
  319. package/lib/types/ink/termio/osc.d.ts.map +1 -1
  320. package/lib/types/ink/termio/osc.js +37 -8
  321. package/lib/types/ink/termio/osc7501.d.ts +102 -0
  322. package/lib/types/ink/termio/osc7501.d.ts.map +1 -0
  323. package/lib/types/ink/termio/osc7501.js +229 -0
  324. package/lib/types/ink/termio/tokenize.js +5 -7
  325. package/lib/types/panels.d.ts +1 -1
  326. package/lib/types/panels.d.ts.map +1 -1
  327. package/lib/types/screens/AgentTranscriptScene.d.ts +3 -1
  328. package/lib/types/screens/AgentTranscriptScene.d.ts.map +1 -1
  329. package/lib/types/screens/AgentTranscriptScene.js +5 -1
  330. package/lib/types/screens/Chat.d.ts +6 -6
  331. package/lib/types/screens/Chat.d.ts.map +1 -1
  332. package/lib/types/screens/Chat.js +304 -111
  333. package/lib/types/screens/Launchpad.d.ts +8 -2
  334. package/lib/types/screens/Launchpad.d.ts.map +1 -1
  335. package/lib/types/screens/Launchpad.js +32 -12
  336. package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
  337. package/lib/types/screens/SessionSupervisor.js +31 -21
  338. package/lib/types/screens/Settings.d.ts +5 -1
  339. package/lib/types/screens/Settings.d.ts.map +1 -1
  340. package/lib/types/screens/Settings.js +528 -51
  341. package/lib/types/screens/StatusLine.d.ts +9 -3
  342. package/lib/types/screens/StatusLine.d.ts.map +1 -1
  343. package/lib/types/screens/StatusLine.js +91 -15
  344. package/lib/types/screens/StatusMetrics.d.ts +2 -11
  345. package/lib/types/screens/StatusMetrics.d.ts.map +1 -1
  346. package/lib/types/screens/StatusMetrics.js +20 -14
  347. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -1
  348. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +1 -1
  349. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts +1 -1
  350. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts.map +1 -1
  351. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.js +13 -21
  352. package/lib/types/sessionMounts.d.ts +14 -0
  353. package/lib/types/sessionMounts.d.ts.map +1 -1
  354. package/lib/types/sessionMounts.js +20 -9
  355. package/lib/types/sessions/format.d.ts +39 -0
  356. package/lib/types/sessions/format.d.ts.map +1 -1
  357. package/lib/types/sessions/format.js +83 -0
  358. package/lib/types/sessions/resumeFailure.d.ts +4 -0
  359. package/lib/types/sessions/resumeFailure.d.ts.map +1 -1
  360. package/lib/types/sessions/resumeFailure.js +12 -4
  361. package/lib/types/sessions/workspaceCounts.d.ts +6 -0
  362. package/lib/types/sessions/workspaceCounts.d.ts.map +1 -0
  363. package/lib/types/sessions/workspaceCounts.js +24 -0
  364. package/lib/types/settings/definitions.d.ts +24 -0
  365. package/lib/types/settings/definitions.d.ts.map +1 -1
  366. package/lib/types/settings/definitions.js +38 -13
  367. package/lib/types/tips.js +2 -2
  368. package/lib/types/tuiDisplayPrefs.d.ts +113 -5
  369. package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
  370. package/lib/types/tuiDisplayPrefs.js +276 -14
  371. package/lib/types/update.d.ts +15 -14
  372. package/lib/types/update.d.ts.map +1 -1
  373. package/lib/types/update.js +163 -115
  374. package/lib/types/updateProcess.d.ts +28 -0
  375. package/lib/types/updateProcess.d.ts.map +1 -0
  376. package/lib/types/updateProcess.js +135 -0
  377. package/lib/types/utils/inputWordBoundary.d.ts +5 -0
  378. package/lib/types/utils/inputWordBoundary.d.ts.map +1 -0
  379. package/lib/types/utils/inputWordBoundary.js +18 -0
  380. package/lib/types/utils/keymap.d.ts +1 -1
  381. package/lib/types/utils/keymap.d.ts.map +1 -1
  382. package/lib/types/utils/keymap.js +6 -1
  383. package/lib/types/windowsInstaller.d.ts +4 -0
  384. package/lib/types/windowsInstaller.d.ts.map +1 -0
  385. package/lib/types/windowsInstaller.js +237 -0
  386. package/locale/en.json +6 -0
  387. package/locale/zh.json +6 -0
  388. package/package.json +127 -111
  389. package/presets/liangshen/custom-bash.mjs +13 -1
  390. package/presets/liangshen/instruction-hint.mjs +4 -1
  391. package/presets/liangshen/skill-search.mjs +14 -2
  392. package/presets/winbash.mjs +16 -4
  393. package/tui-profile/feed/README.md +17 -8
  394. package/tui-profile/feed/first-party.json +1 -1
@@ -18,6 +18,7 @@ import { HANDOFF_ACK_FD_ENV, HANDOFF_ATTEMPT_ENV, HANDOFF_SCREEN_ENV, parseHando
18
18
  import { DISABLE_KITTY_KEYBOARD, DISABLE_MODIFY_OTHER_KEYS, DISABLE_WIN32_INPUT_MODE } from './ink/termio/csi.js';
19
19
  import { DBP, DFE, DISABLE_MOUSE_TRACKING, EXIT_ALT_SCREEN, SHOW_CURSOR } from './ink/termio/dec.js';
20
20
  import { detachHandoffStdin } from './ink/stdin-handoff.js';
21
+ import { runInstallerProcess } from './updateProcess.js';
21
22
  // Re-exported for scripts/verify-update.mjs and the bin launcher, which reads
22
23
  // the compiled copy at lib/types/utils/shellQuote.js.
23
24
  export { shellQuote };
@@ -296,13 +297,15 @@ function isRecord(value) {
296
297
  return value !== null && typeof value === 'object' && !Array.isArray(value);
297
298
  }
298
299
  /** Fetch `latest` from a registry; undefined on any failure. */
299
- async function fetchLatestVersion(registryBase) {
300
+ async function fetchLatestVersion(registryBase, signal) {
301
+ if (signal?.aborted)
302
+ return undefined;
300
303
  const controller = new AbortController();
301
304
  const timeout = setTimeout(() => controller.abort(), UPDATE_CHECK_TIMEOUT_MS);
302
305
  try {
303
306
  const response = await fetch(`${registryBase}/${PACKAGE_NAME}/latest`, {
304
307
  headers: { accept: 'application/json' },
305
- signal: controller.signal,
308
+ signal: signal === undefined ? controller.signal : AbortSignal.any([controller.signal, signal]),
306
309
  });
307
310
  if (!response.ok)
308
311
  return undefined;
@@ -397,14 +400,16 @@ export function releaseChecksumUrl(version) {
397
400
  * the transition-period warning path instead of being blocked (new releases
398
401
  * always ship the manifest; old ones must keep updating).
399
402
  */
400
- async function probeChecksumManifestUrl(url) {
403
+ async function probeChecksumManifestUrl(url, signal) {
404
+ if (signal?.aborted)
405
+ return undefined;
401
406
  const controller = new AbortController();
402
407
  const timeout = setTimeout(() => controller.abort(), UPDATE_CHECK_TIMEOUT_MS);
403
408
  try {
404
409
  const response = await fetch(url, {
405
410
  headers: { 'user-agent': 'dsh-tui-updater' },
406
411
  redirect: 'follow',
407
- signal: controller.signal,
412
+ signal: signal === undefined ? controller.signal : AbortSignal.any([controller.signal, signal]),
408
413
  });
409
414
  return response.ok ? url : undefined;
410
415
  }
@@ -424,13 +429,15 @@ async function probeChecksumManifestUrl(url) {
424
429
  * failure.
425
430
  */
426
431
  export async function fetchGithubLatestRelease(options = {}) {
432
+ if (options.signal?.aborted)
433
+ return undefined;
427
434
  const doFetch = options.fetchImpl ?? fetch;
428
435
  const controller = new AbortController();
429
436
  const timeout = setTimeout(() => controller.abort(), UPDATE_CHECK_TIMEOUT_MS);
430
437
  try {
431
438
  const response = await doFetch(`${options.apiBaseUrl ?? 'https://api.github.com'}/repos/${GITHUB_REPO}/releases/latest`, {
432
439
  headers: { accept: 'application/vnd.github.v3+json', 'user-agent': 'dsh-tui-updater' },
433
- signal: controller.signal,
440
+ signal: options.signal === undefined ? controller.signal : AbortSignal.any([controller.signal, options.signal]),
434
441
  });
435
442
  if (!response.ok)
436
443
  return undefined;
@@ -628,14 +635,14 @@ export function validateExtractedTree(extractDir) {
628
635
  * {@link MAX_CHECKSUM_MANIFEST_BYTES}); tests inject a small value.
629
636
  * @returns The manifest text.
630
637
  */
631
- async function fetchChecksumManifest(checksumUrl, maxManifestBytes = MAX_CHECKSUM_MANIFEST_BYTES) {
638
+ async function fetchChecksumManifest(checksumUrl, maxManifestBytes = MAX_CHECKSUM_MANIFEST_BYTES, signal) {
632
639
  const controller = new AbortController();
633
640
  const timeout = setTimeout(() => controller.abort(), STANDALONE_DOWNLOAD_TIMEOUT_MS);
634
641
  try {
635
642
  const response = await fetch(checksumUrl, {
636
643
  headers: { 'user-agent': 'dsh-tui-updater' },
637
644
  redirect: 'follow',
638
- signal: controller.signal,
645
+ signal: signal === undefined ? controller.signal : AbortSignal.any([controller.signal, signal]),
639
646
  });
640
647
  if (!response.ok) {
641
648
  throw new Error(`checksum manifest fetch failed: HTTP ${response.status} ${response.statusText}`);
@@ -691,8 +698,12 @@ async function fetchChecksumManifest(checksumUrl, maxManifestBytes = MAX_CHECKSU
691
698
  */
692
699
  export async function downloadAndReplaceStandaloneBinary(downloadUrl, onProgress, checksumUrl, options = {}) {
693
700
  const maxAssetBytes = options.maxAssetBytes ?? MAX_ASSET_BYTES;
701
+ const controller = new AbortController();
702
+ const signal = options.signal === undefined ? controller.signal : AbortSignal.any([controller.signal, options.signal]);
703
+ const timeout = setTimeout(() => controller.abort(), STANDALONE_DOWNLOAD_TIMEOUT_MS);
694
704
  const tempDir = join(process.env.DSH_TUI_STANDALONE_CACHE ?? join(homedir(), '.cache', 'dsh-tui-standalone'), `.update-${Date.now()}-${process.pid}`);
695
705
  try {
706
+ signal.throwIfAborted();
696
707
  const currentBinary = getStandaloneBinaryPath();
697
708
  const targetDir = dirname(currentBinary);
698
709
  const assetName = getStandaloneAssetName();
@@ -700,19 +711,11 @@ export async function downloadAndReplaceStandaloneBinary(downloadUrl, onProgress
700
711
  mkdirSync(tempDir, { recursive: true });
701
712
  const downloadPath = join(tempDir, assetName);
702
713
  onProgress?.(`downloading: ${downloadUrl}`);
703
- const controller = new AbortController();
704
- const timeout = setTimeout(() => controller.abort(), STANDALONE_DOWNLOAD_TIMEOUT_MS);
705
- let response;
706
- try {
707
- response = await fetch(downloadUrl, {
708
- headers: { 'user-agent': 'dsh-tui-updater' },
709
- redirect: 'follow',
710
- signal: controller.signal,
711
- });
712
- }
713
- finally {
714
- clearTimeout(timeout);
715
- }
714
+ const response = await fetch(downloadUrl, {
715
+ headers: { 'user-agent': 'dsh-tui-updater' },
716
+ redirect: 'follow',
717
+ signal,
718
+ });
716
719
  if (!response.ok) {
717
720
  throw new Error(`HTTP ${response.status} ${response.statusText}`);
718
721
  }
@@ -760,7 +763,7 @@ export async function downloadAndReplaceStandaloneBinary(downloadUrl, onProgress
760
763
  }
761
764
  else {
762
765
  onProgress?.('verifying checksum…');
763
- const manifest = await fetchChecksumManifest(checksumUrl, options.maxChecksumManifestBytes ?? MAX_CHECKSUM_MANIFEST_BYTES);
766
+ const manifest = await fetchChecksumManifest(checksumUrl, options.maxChecksumManifestBytes ?? MAX_CHECKSUM_MANIFEST_BYTES, signal);
764
767
  if (!verifyAssetChecksum(buffer, manifest, assetName)) {
765
768
  // Fail closed: never leave a mismatching (potentially hostile) asset
766
769
  // on disk for a later retry to pick up, and never extract it.
@@ -773,6 +776,7 @@ export async function downloadAndReplaceStandaloneBinary(downloadUrl, onProgress
773
776
  onProgress?.('checksum verified');
774
777
  }
775
778
  onProgress?.('extracting…');
779
+ signal.throwIfAborted();
776
780
  const extractDir = join(tempDir, 'extracted');
777
781
  mkdirSync(extractDir, { recursive: true });
778
782
  if (isZip) {
@@ -816,6 +820,7 @@ export async function downloadAndReplaceStandaloneBinary(downloadUrl, onProgress
816
820
  throw new Error(`expected binary entry is not a regular file: ${newBinaryPath}`);
817
821
  }
818
822
  onProgress?.('replacing binary…');
823
+ signal.throwIfAborted();
819
824
  if (process.platform !== 'win32') {
820
825
  try {
821
826
  chmodSync(newBinaryPath, 0o755);
@@ -847,18 +852,17 @@ export async function downloadAndReplaceStandaloneBinary(downloadUrl, onProgress
847
852
  chmodSync(stagedTarget, 0o755);
848
853
  renameSync(stagedTarget, currentBinary);
849
854
  }
850
- try {
851
- rmSync(tempDir, { recursive: true, force: true });
852
- }
853
- catch { }
854
855
  return { success: true };
855
856
  }
856
857
  catch (error) {
858
+ return { success: false, error: error instanceof Error ? error.message : String(error) };
859
+ }
860
+ finally {
861
+ clearTimeout(timeout);
857
862
  try {
858
863
  rmSync(tempDir, { recursive: true, force: true });
859
864
  }
860
865
  catch { }
861
- return { success: false, error: error instanceof Error ? error.message : String(error) };
862
866
  }
863
867
  }
864
868
  /**
@@ -874,14 +878,20 @@ export async function downloadAndReplaceStandaloneBinary(downloadUrl, onProgress
874
878
  * say "installing X now, official latest is Y" instead of silently
875
879
  * upgrading to yesterday's version.
876
880
  */
877
- export async function resolveTuiUpdateTarget() {
881
+ export async function resolveTuiUpdateTarget(signal) {
882
+ if (signal?.aborted)
883
+ return { kind: 'unknown' };
878
884
  const current = installedTuiVersion();
879
885
  const currentVersion = current === undefined ? null : valid(current);
880
886
  if (currentVersion === null)
881
887
  return { kind: 'unknown' };
882
888
  if (isStandaloneRuntime()) {
883
- const ghRelease = await fetchGithubLatestRelease();
884
- const latest = ghRelease?.version ?? (await fetchLatestVersion(resolveRegistryBase()));
889
+ const ghRelease = await fetchGithubLatestRelease({ signal });
890
+ if (signal?.aborted)
891
+ return { kind: 'unknown' };
892
+ const latest = ghRelease?.version ?? (await fetchLatestVersion(resolveRegistryBase(), signal));
893
+ if (signal?.aborted)
894
+ return { kind: 'unknown' };
885
895
  if (latest === undefined)
886
896
  return { kind: 'unknown' };
887
897
  if (!gt(latest, currentVersion))
@@ -896,15 +906,15 @@ export async function resolveTuiUpdateTarget() {
896
906
  // release-bundle.yml generates it alongside the assets).
897
907
  const checksumUrl = ghRelease !== undefined
898
908
  ? ghRelease.checksumUrl
899
- : await probeChecksumManifestUrl(releaseChecksumUrl(latest));
909
+ : await probeChecksumManifestUrl(releaseChecksumUrl(latest), signal);
900
910
  return checksumUrl === undefined
901
911
  ? { kind: 'update', current: currentVersion, latest, isStandalone: true, downloadUrl }
902
912
  : { kind: 'update', current: currentVersion, latest, isStandalone: true, downloadUrl, checksumUrl };
903
913
  }
904
914
  const registryBase = resolveRegistryBase();
905
915
  const [latest, official] = await Promise.all([
906
- fetchLatestVersion(registryBase),
907
- registryBase === DEFAULT_REGISTRY ? undefined : fetchLatestVersion(DEFAULT_REGISTRY),
916
+ fetchLatestVersion(registryBase, signal),
917
+ registryBase === DEFAULT_REGISTRY ? undefined : fetchLatestVersion(DEFAULT_REGISTRY, signal),
908
918
  ]);
909
919
  if (latest === undefined)
910
920
  return { kind: 'unknown' };
@@ -941,41 +951,23 @@ export async function checkForTuiUpdate() {
941
951
  * process never starts, leaving an updated package and a dead TUI.
942
952
  */
943
953
  function runProcess(command, args, options = {}) {
944
- return new Promise(resolve => {
945
- let settled = false;
946
- const useShell = options.shell === true && process.platform === 'win32';
947
- // DEP0190 (issue #148): Node ≥22 warns on `shell: true` with a non-empty
948
- // args array even when every arg is escaped — the check is syntactic.
949
- // Fold the shell-quoted args into the command string instead (an empty
950
- // args array does not trigger the warning); future Node majors may turn
951
- // the deprecation into a hard error.
952
- const [runCommand, runArgs] = useShell
953
- ? [`${command} ${shellQuote(args).join(' ')}`, []]
954
- : [command, args];
955
- const child = spawn(runCommand, runArgs, {
956
- env: options.env,
957
- stdio: options.onStderr === undefined ? 'inherit' : ['inherit', 'inherit', 'pipe'],
958
- shell: useShell,
959
- });
960
- if (options.onStderr !== undefined && child.stderr !== null) {
961
- const onStderr = options.onStderr;
962
- child.stderr.on('data', (chunk) => {
963
- const text = chunk.toString('utf8');
964
- process.stderr.write(text);
965
- onStderr(text);
966
- });
967
- }
968
- const finish = (code) => {
969
- if (settled)
970
- return;
971
- settled = true;
972
- resolve(code);
973
- };
974
- child.once('error', error => {
975
- process.stderr.write(`dsh-tui: failed to run ${command}: ${error.message}\n`);
976
- finish(127);
977
- });
978
- child.once('close', code => finish(code ?? 1));
954
+ return runInstallerProcess(command, args, {
955
+ ...options,
956
+ category: 'profile-install',
957
+ onStdout: text => { process.stdout.write(text); },
958
+ onStderr: text => {
959
+ process.stderr.write(text);
960
+ options.onStderr?.(text);
961
+ },
962
+ onEvent: event => {
963
+ if (event.stage === 'cleanup-error')
964
+ options.onCleanupError?.();
965
+ logRestartEvent('update installer', { ...event });
966
+ if (event.stage === 'timeout' || event.stage === 'cancel' || event.stage === 'cleanup-error' || event.stage === 'error') {
967
+ writeHandoffNotice(`dsh-tui: installer ${event.stage}; category=${event.category} pid=${event.pid ?? 'unavailable'} last-output=${event.lastOutputAt === undefined ? 'none' : new Date(event.lastOutputAt).toISOString()}${event.message === undefined ? '' : `: ${event.message}`}\n`);
968
+ writeHandoffNotice('Installation may be partial. Check/repair the profile before resuming; no automatic restart.\n');
969
+ }
970
+ },
979
971
  });
980
972
  }
981
973
  /** Build the profile-manager command, preferring a preflight-pinned version. */
@@ -1103,17 +1095,14 @@ export function ensureWorkspaceAllowBuilds(yamlPath) {
1103
1095
  * preserved, a missing `minimumReleaseAgeExclude` block is appended, a
1104
1096
  * missing file is created, and an absent profile directory resolves to
1105
1097
  * undefined — the caller still runs pnpm, whose own diagnostic stays the
1106
- * visible fallback. Own entries are re-rendered target-first on every
1107
- * rewrite: pnpm 11.7.x honours only the FIRST entry per package (later
1108
- * entries for the same package are ignored against the real registry), and
1109
- * 11.21.x applies every entry in any order, so the target — the version the
1110
- * swap itself has to resolve, and published by construction while a
1111
- * dev-built `updatedFrom` need not be — takes the slot older pnpm still
1112
- * reads. Both exemptions come from the manifest, not from `pnpm-lock.yaml`:
1113
- * a profile whose manifest and lockfile diverged keeps the lockfile's entry
1114
- * unexempted. The 11.7.x `--frozen-lockfile` policy check reads that first
1115
- * entry only, so a two-entry list does not clear it there; the `pnpm add`
1116
- * path `/update` runs resolves the target and does pass.
1098
+ * visible fallback. Both versions share ONE entry, `pkg@<target> || <from>`:
1099
+ * pnpm 11.5.x–11.7.x honour only the FIRST entry per package (later entries
1100
+ * for the same package are ignored), so two entries leave the old lockfile
1101
+ * version unexempted there whatever their order — the `pnpm update` dsh runs
1102
+ * for `/update` fails on it (issue #1605) — while 11.10+ applies every entry.
1103
+ * A version union is read whole by both. Both exemptions come from the
1104
+ * manifest, not from `pnpm-lock.yaml`: a profile whose manifest and lockfile
1105
+ * diverged keeps the lockfile's entry unexempted.
1117
1106
  *
1118
1107
  * @param profile - The dsh profile whose workspace file is seeded.
1119
1108
  * @param version - The update target (exact version).
@@ -1133,10 +1122,9 @@ export function ensureProfileReleaseAgeExclude(profile, version, alsoExempt) {
1133
1122
  // Missing file — start from an empty document; writeFileSync creates it.
1134
1123
  }
1135
1124
  const entry = `${PACKAGE_NAME}@${version}`;
1136
- const alsoEntry = alsoExempt !== undefined && alsoExempt !== '' && alsoExempt !== version
1137
- ? `${PACKAGE_NAME}@${alsoExempt}`
1138
- : undefined;
1139
- const keep = alsoEntry === undefined ? [entry] : [entry, alsoEntry];
1125
+ const keep = alsoExempt !== undefined && alsoExempt !== '' && alsoExempt !== version
1126
+ ? [`${entry} || ${alsoExempt}`]
1127
+ : [entry];
1140
1128
  const lines = text.split(/\r?\n/u);
1141
1129
  let blockStart = -1;
1142
1130
  for (let i = 0; i < lines.length; i += 1) {
@@ -1178,10 +1166,8 @@ export function ensureProfileReleaseAgeExclude(profile, version, alsoExempt) {
1178
1166
  if (!droppedStale && missing.length === 0) {
1179
1167
  return { entries: [...foreignLines.map(itemOf), ...present], changed: false };
1180
1168
  }
1181
- // Own entries are re-rendered in keep order (target first) instead of
1182
- // copied as found: pnpm 11.7.x honours only the first entry per package
1183
- // (11.21.x applies them all, order-independent), and the target is the
1184
- // version the swap must resolve, so it takes that first slot.
1169
+ // Own entries are re-rendered from the keep set instead of copied as
1170
+ // found, so a pre-#1605 two-entry pair collapses into the single union.
1185
1171
  const insert = foreignLines.concat(keep.map(item => ` - '${item}'`));
1186
1172
  if (blockStart !== -1) {
1187
1173
  lines.splice(blockStart + 1, blockEnd - blockStart - 1, ...insert);
@@ -1590,32 +1576,55 @@ export function migrateGlobalLauncher() {
1590
1576
  // layouts collapse both onto the same real path — copying onto ourselves
1591
1577
  // would be a no-op at best).
1592
1578
  let dir = dirname(resolve(launcherBin));
1593
- const ownDir = dirname(dirname(fileURLToPath(import.meta.url)));
1579
+ const here = dirname(fileURLToPath(import.meta.url));
1580
+ let own;
1581
+ // These are the same two layouts accepted by installedTuiVersion(). Read
1582
+ // both source files before replacing either destination file.
1583
+ for (const relativePath of ['../..', '..']) {
1584
+ try {
1585
+ const candidate = resolve(here, relativePath);
1586
+ const manifest = readFileSync(join(candidate, 'package.json'));
1587
+ const parsed = JSON.parse(manifest.toString('utf8'));
1588
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)
1589
+ || parsed.name !== PACKAGE_NAME)
1590
+ continue;
1591
+ const bin = readFileSync(join(candidate, 'bin', 'dsh-tui.js'));
1592
+ if (bin.length === 0)
1593
+ continue;
1594
+ own = { dir: realpathSync(candidate), bin, manifest };
1595
+ break;
1596
+ }
1597
+ catch {
1598
+ // A missing or invalid compiled root may still be a source checkout.
1599
+ }
1600
+ }
1601
+ if (!own)
1602
+ return false;
1594
1603
  for (let depth = 0; depth < 4; depth++) {
1595
1604
  const manifest = join(dir, 'package.json');
1596
1605
  try {
1597
1606
  const parsed = JSON.parse(readFileSync(manifest, 'utf8'));
1598
1607
  if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)
1599
1608
  && parsed.name === PACKAGE_NAME) {
1600
- let same = false;
1601
1609
  try {
1602
- same = realpathSync(dir) === realpathSync(ownDir);
1610
+ // Fail closed when the real paths cannot establish distinct roots.
1611
+ if (realpathSync(dir) === own.dir)
1612
+ return false;
1613
+ // Each rename is atomic, not the pair. A partial migration returns
1614
+ // false and can be retried; the standalone bin is safe in either case.
1615
+ const replace = (target, content) => {
1616
+ const staged = `${target}.dsh-tui-migrate`;
1617
+ writeFileSync(staged, content);
1618
+ renameSync(staged, target);
1619
+ };
1620
+ replace(join(dir, 'bin', 'dsh-tui.js'), own.bin);
1621
+ replace(manifest, own.manifest);
1622
+ return true;
1603
1623
  }
1604
1624
  catch {
1605
- same = resolve(dir) === resolve(ownDir);
1606
- }
1607
- if (same)
1625
+ // Keep the alignment warning as the permission/locked-file fallback.
1608
1626
  return false;
1609
- // tmp + rename keeps each file atomic; a crash mid-migration leaves
1610
- // either the old or the new file, never a truncated one.
1611
- const replace = (target, source) => {
1612
- const staged = `${target}.dsh-tui-migrate`;
1613
- writeFileSync(staged, readFileSync(source));
1614
- renameSync(staged, target);
1615
- };
1616
- replace(join(dir, 'bin', 'dsh-tui.js'), join(ownDir, 'bin', 'dsh-tui.js'));
1617
- replace(manifest, join(ownDir, 'package.json'));
1618
- return true;
1627
+ }
1619
1628
  }
1620
1629
  }
1621
1630
  catch {
@@ -1639,15 +1648,19 @@ export function migrateGlobalLauncher() {
1639
1648
  * undefined when that check failed and pnpm should resolve latest.
1640
1649
  * @returns The update exit code plus the before/after versions.
1641
1650
  */
1642
- export async function updateTui(profile, targetVersion) {
1651
+ export async function updateTui(profile, targetVersion, signal) {
1643
1652
  // Stamp the pre-update version BEFORE pnpm runs: it reads this package's
1644
1653
  // manifest from disk, which the update replaces on the fly — a
1645
1654
  // post-update read already sees the NEW version, and the restarted
1646
1655
  // process then compares new-vs-new and false-alarms "version did not
1647
1656
  // advance" on every successful update (issue #307's screenshots).
1648
1657
  const updatedFrom = installedTuiVersion() ?? '';
1658
+ if (signal?.aborted)
1659
+ return { code: 130, updatedFrom };
1649
1660
  if (isStandaloneRuntime()) {
1650
- const target = await resolveTuiUpdateTarget();
1661
+ const target = await resolveTuiUpdateTarget(signal);
1662
+ if (signal?.aborted)
1663
+ return { code: 130, updatedFrom };
1651
1664
  const latestVersion = targetVersion ?? (target.kind === 'update' ? target.latest : undefined);
1652
1665
  const downloadUrl = (target.kind === 'update' && target.downloadUrl)
1653
1666
  ? target.downloadUrl
@@ -1660,7 +1673,9 @@ export async function updateTui(profile, targetVersion) {
1660
1673
  process.stderr.write(`dsh-tui: 正在更新便携包 (${updatedFrom || 'current'} → ${latestVersion})…\n`);
1661
1674
  const result = await downloadAndReplaceStandaloneBinary(downloadUrl, msg => {
1662
1675
  process.stderr.write(`dsh-tui: ${msg}\n`);
1663
- }, checksumUrl);
1676
+ }, checksumUrl, { signal });
1677
+ if (signal?.aborted)
1678
+ return { code: 130, updatedFrom };
1664
1679
  if (!result.success) {
1665
1680
  process.stderr.write(`dsh-tui: 便携包更新失败: ${result.error ?? '未知错误'}\n`);
1666
1681
  return { code: 1, updatedFrom };
@@ -1699,7 +1714,7 @@ export async function updateTui(profile, targetVersion) {
1699
1714
  const releaseAge = ensureProfileReleaseAgeExclude(profile, targetVersion, updatedFrom === '' ? undefined : updatedFrom);
1700
1715
  if (releaseAge !== undefined && releaseAge.changed) {
1701
1716
  const exempted = updatedFrom !== '' && updatedFrom !== targetVersion
1702
- ? `${PACKAGE_NAME}@${targetVersion} + ${PACKAGE_NAME}@${updatedFrom}`
1717
+ ? `${PACKAGE_NAME}@${targetVersion} || ${updatedFrom}`
1703
1718
  : `${PACKAGE_NAME}@${targetVersion}`;
1704
1719
  process.stderr.write(`dsh-tui: pre-seeded profile release-age exclusion (${exempted}) — ` +
1705
1720
  'freshly published versions install without the 24h supply-chain delay\n');
@@ -1707,14 +1722,28 @@ export async function updateTui(profile, targetVersion) {
1707
1722
  }
1708
1723
  let updateStderr = '';
1709
1724
  const capture = (chunk) => { updateStderr += chunk; };
1710
- let updateCode = await runProcess(dsh, updateArgs, { shell: true, onStderr: capture });
1725
+ let cleanupUnconfirmed = false;
1726
+ const onCleanupError = () => { cleanupUnconfirmed = true; };
1727
+ const installerOptions = { shell: true, onStderr: capture, signal, onCleanupError };
1728
+ let updateCode = await runProcess(dsh, updateArgs, installerOptions);
1729
+ // Exit codes alone cannot prove ownership cleanup: a supervisor failure can
1730
+ // use the same code/stderr as a retryable installer failure. Never overlap
1731
+ // a surviving installer with a retry, stale-file removal, repair or restart.
1732
+ if (cleanupUnconfirmed)
1733
+ return { code: updateCode || 1, updatedFrom };
1734
+ if (signal?.aborted)
1735
+ return { code: 130, updatedFrom };
1711
1736
  // Transient Windows tmp-rename race (issue #225): retry the identical
1712
1737
  // command once — it succeeds on a clean second run, and only the
1713
1738
  // `_tmp_<pid>` race signature qualifies, never a real resolution error.
1714
- if (updateCode !== 0 && isTransientUpdateFailure(updateStderr)) {
1739
+ if (![0, 124, 129, 130, 143].includes(updateCode) && isTransientUpdateFailure(updateStderr)) {
1715
1740
  process.stderr.write('dsh-tui: transient pnpm failure (Windows tmp-rename race) — retrying once…\n');
1716
1741
  updateStderr = '';
1717
- updateCode = await runProcess(dsh, updateArgs, { shell: true, onStderr: capture });
1742
+ updateCode = await runProcess(dsh, updateArgs, installerOptions);
1743
+ if (cleanupUnconfirmed)
1744
+ return { code: updateCode || 1, updatedFrom };
1745
+ if (signal?.aborted)
1746
+ return { code: 130, updatedFrom };
1718
1747
  }
1719
1748
  // Deterministic Linux tmp-rename race (issue #479): EEXIST never clears on
1720
1749
  // a plain retry (the staging-dir collision reproduces every run), and a
@@ -1722,14 +1751,18 @@ export async function updateTui(profile, targetVersion) {
1722
1751
  // recover by removing the stale install + staging dirs, then rerunning —
1723
1752
  // the field-verified workaround that takes pnpm down its fresh-install
1724
1753
  // path instead of renaming over the collision.
1725
- if (updateCode !== 0 && (isEexistTmpRenameFailure(updateStderr) || isTransientUpdateFailure(updateStderr))) {
1754
+ if (![0, 124, 129, 130, 143].includes(updateCode) && (isEexistTmpRenameFailure(updateStderr) || isTransientUpdateFailure(updateStderr))) {
1726
1755
  const flavor = isEexistTmpRenameFailure(updateStderr) ? 'EEXIST, issue #479' : 'retry failed, issue #225';
1727
1756
  const removal = removeStalePackageInstall(profile);
1728
1757
  const stagingNote = removal.tmpDirs.length > 0 ? ` + ${removal.tmpDirs.length} staging dir(s)` : '';
1729
1758
  process.stderr.write(`dsh-tui: pnpm tmp-rename race (${flavor}) — cleared the stale install ` +
1730
1759
  `(package dir: ${removal.packageDir}${stagingNote}) and rerunning the update…\n`);
1731
1760
  updateStderr = '';
1732
- updateCode = await runProcess(dsh, updateArgs, { shell: true, onStderr: capture });
1761
+ updateCode = await runProcess(dsh, updateArgs, installerOptions);
1762
+ if (cleanupUnconfirmed)
1763
+ return { code: updateCode || 1, updatedFrom };
1764
+ if (signal?.aborted)
1765
+ return { code: 130, updatedFrom };
1733
1766
  }
1734
1767
  if (updateCode !== 0)
1735
1768
  return { code: updateCode, updatedFrom };
@@ -1740,6 +1773,8 @@ export async function updateTui(profile, targetVersion) {
1740
1773
  // who was already on it keeps their restart (their combo demonstrably
1741
1774
  // boots) and gets the repair hint on the next /update instead.
1742
1775
  const installedNow = installedTuiVersion();
1776
+ if (signal?.aborted)
1777
+ return { code: 130, updatedFrom };
1743
1778
  if (installedNow !== undefined && installedNow !== updatedFrom && isBootDeadlockTarget(installedNow)) {
1744
1779
  process.stderr.write(`dsh-tui: update landed on ${installedNow}, which can permanently deadlock boot under older launcher patches ` +
1745
1780
  `(#183/#307) — NOT restarting into it. Repair with:\n` +
@@ -1754,8 +1789,16 @@ export async function updateTui(profile, targetVersion) {
1754
1789
  // a mixed state and hand the user the exact repair command instead.
1755
1790
  if (targetVersion !== undefined) {
1756
1791
  let installed = installedTuiVersion();
1792
+ if (signal?.aborted)
1793
+ return { code: 130, updatedFrom };
1757
1794
  if (installed !== targetVersion) {
1758
- await runProcess(dsh, ['plugin', '--profile', profile, 'install'], { shell: true });
1795
+ const repairCode = await runProcess(dsh, ['plugin', '--profile', profile, 'install'], { shell: true, signal, onCleanupError });
1796
+ if (cleanupUnconfirmed)
1797
+ return { code: repairCode || 1, updatedFrom };
1798
+ if (signal?.aborted)
1799
+ return { code: 130, updatedFrom };
1800
+ if (repairCode !== 0)
1801
+ return { code: repairCode, updatedFrom };
1759
1802
  installed = installedTuiVersion();
1760
1803
  }
1761
1804
  if (installed !== targetVersion) {
@@ -1769,10 +1812,13 @@ export async function updateTui(profile, targetVersion) {
1769
1812
  // delegating shim — stamp it over the global launcher so this is the LAST
1770
1813
  // time the outer copy can lag. Best-effort; the alignment warning stays as
1771
1814
  // the fallback when the copy is impossible.
1815
+ if (signal?.aborted)
1816
+ return { code: 130, updatedFrom };
1772
1817
  if (migrateGlobalLauncher()) {
1773
1818
  process.stderr.write('dsh-tui: global launcher aligned to the delegating shim (no manual npm i -g needed anymore).\n');
1774
1819
  }
1775
- return { code: 0, updatedFrom, installed: installedTuiVersion() };
1820
+ const installed = installedTuiVersion();
1821
+ return { code: signal?.aborted ? 130 : 0, updatedFrom, installed };
1776
1822
  }
1777
1823
  /**
1778
1824
  * Update the installed dsh-tui package and restart the same launcher while
@@ -1795,11 +1841,13 @@ export async function updateTui(profile, targetVersion) {
1795
1841
  */
1796
1842
  export async function updateTuiAndRestart(sessionId, profile, targetVersion, kernel,
1797
1843
  /** The standalone entry's supervision hooks (TuiRestartOptions.onSpawn / onTerminationSignal). */
1798
- supervision = {}) {
1799
- const outcome = await updateTui(profile, targetVersion);
1844
+ supervision = {}, signal) {
1845
+ const outcome = await updateTui(profile, targetVersion, signal);
1800
1846
  const { updatedFrom } = outcome;
1801
1847
  if (outcome.code !== 0)
1802
1848
  return { updateCode: outcome.code, restartCode: outcome.code };
1849
+ if (signal?.aborted)
1850
+ return { updateCode: 130, restartCode: 130 };
1803
1851
  // Restart through the same hardened handoff as /restart (issues
1804
1852
  // #284/#307/#483): wait for the replacement's natural exit (the outer
1805
1853
  // interpreter must not reclaim the console under it), re-assert the
@@ -0,0 +1,28 @@
1
+ /** Conservative wall-clock limit, independent of output/silence. */
2
+ export declare const DEFAULT_UPDATE_TIMEOUT_MS: number;
3
+ export declare function updateTimeoutMs(value?: string | undefined): number;
4
+ export interface InstallerEvent {
5
+ readonly category: string;
6
+ readonly pid?: number;
7
+ readonly lastOutputAt?: number;
8
+ readonly stage: 'start' | 'timeout' | 'cancel' | 'error' | 'close' | 'cleanup-error';
9
+ readonly code?: number;
10
+ readonly message?: string;
11
+ }
12
+ export interface InstallerOptions {
13
+ env?: NodeJS.ProcessEnv;
14
+ shell?: boolean;
15
+ category: string;
16
+ timeoutMs?: number;
17
+ signal?: AbortSignal;
18
+ /** Grace period for this owned process group, before forceful termination. */
19
+ terminationGraceMs?: number;
20
+ onStdout?: (text: string) => void;
21
+ onStderr?: (text: string) => void;
22
+ onEvent?: (event: InstallerEvent) => void;
23
+ }
24
+ /** Installer-only runner: one result, owned tree cancellation, bounded cleanup.
25
+ * Output is observational; even "Done" cannot settle the process successfully.
26
+ */
27
+ export declare function runInstallerProcess(command: string, args: readonly string[], options: InstallerOptions): Promise<number>;
28
+ //# sourceMappingURL=updateProcess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateProcess.d.ts","sourceRoot":"","sources":["../../src/updateProcess.ts"],"names":[],"mappings":"AAGA,oEAAoE;AACpE,eAAO,MAAM,yBAAyB,QAAiB,CAAA;AAEvD,wBAAgB,eAAe,CAAC,KAAK,qBAA2C,GAAG,MAAM,CAKxF;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,eAAe,CAAA;IACpF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,8EAA8E;IAC9E,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAA;CAC1C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CA0GxH"}