@deepseek-harness-tui/dsh-tui 0.16.1 → 0.18.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 (488) hide show
  1. package/README.md +213 -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/cli.en.md +114 -0
  20. package/guide/dsh-tui-guide/cli.md +114 -0
  21. package/guide/dsh-tui-guide/configuration.en.md +7 -5
  22. package/guide/dsh-tui-guide/configuration.md +7 -5
  23. package/guide/dsh-tui-guide/getting-started.en.md +33 -3
  24. package/guide/dsh-tui-guide/getting-started.md +23 -2
  25. package/guide/dsh-tui-guide/interaction.en.md +50 -17
  26. package/guide/dsh-tui-guide/interaction.md +35 -13
  27. package/guide/dsh-tui-guide/plugins.en.md +63 -11
  28. package/guide/dsh-tui-guide/plugins.md +41 -7
  29. package/guide/dsh-tui-guide/user-guide.en.md +55 -34
  30. package/guide/dsh-tui-guide/user-guide.md +45 -28
  31. package/lib/settings.json +85 -42
  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 +2 -1
  35. package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
  36. package/lib/types/adapter/channel/ui-policy.js +4 -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 +22 -2
  44. package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
  45. package/lib/types/adapter/ports/channel-view.d.ts +11 -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/adapter/standard/grants.d.ts +60 -0
  50. package/lib/types/adapter/standard/grants.d.ts.map +1 -1
  51. package/lib/types/adapter/standard/grants.js +74 -0
  52. package/lib/types/agent/capabilities.d.ts +2 -0
  53. package/lib/types/agent/capabilities.d.ts.map +1 -1
  54. package/lib/types/agent/events.d.ts +15 -1
  55. package/lib/types/agent/events.d.ts.map +1 -1
  56. package/lib/types/api.d.ts +2 -2
  57. package/lib/types/api.d.ts.map +1 -1
  58. package/lib/types/backends/claude/translate/events.d.ts.map +1 -1
  59. package/lib/types/backends/claude/translate/events.js +2 -1
  60. package/lib/types/backends/codex/auth/status.js +1 -1
  61. package/lib/types/backends/codex/session/controls.d.ts.map +1 -1
  62. package/lib/types/backends/codex/session/controls.js +6 -5
  63. package/lib/types/backends/codex/session/goals.d.ts.map +1 -1
  64. package/lib/types/backends/codex/session/side-query.d.ts.map +1 -1
  65. package/lib/types/backends/codex/translate/events.d.ts.map +1 -1
  66. package/lib/types/backends/codex/translate/events.js +3 -1
  67. package/lib/types/backends/shared/channel-tokens.d.ts.map +1 -1
  68. package/lib/types/backends/shared/channel-tokens.js +9 -8
  69. package/lib/types/channel/history-restore.d.ts.map +1 -1
  70. package/lib/types/channel/history-restore.js +2 -0
  71. package/lib/types/channel/interaction.d.ts.map +1 -1
  72. package/lib/types/channel/interaction.js +1 -0
  73. package/lib/types/channel/projection.d.ts +1 -1
  74. package/lib/types/channel/projection.d.ts.map +1 -1
  75. package/lib/types/channel/projection.js +19 -4
  76. package/lib/types/channel/questions.d.ts +2 -0
  77. package/lib/types/channel/questions.d.ts.map +1 -1
  78. package/lib/types/channel/sanitize.d.ts +14 -0
  79. package/lib/types/channel/sanitize.d.ts.map +1 -1
  80. package/lib/types/channel/sanitize.js +55 -0
  81. package/lib/types/channel/working-directory.d.ts +9 -0
  82. package/lib/types/channel/working-directory.d.ts.map +1 -0
  83. package/lib/types/channel/working-directory.js +7 -0
  84. package/lib/types/commands.d.ts +8 -1
  85. package/lib/types/commands.d.ts.map +1 -1
  86. package/lib/types/commands.js +14 -5
  87. package/lib/types/components/ChatTitle.d.ts +7 -0
  88. package/lib/types/components/ChatTitle.d.ts.map +1 -0
  89. package/lib/types/components/ChatTitle.js +15 -0
  90. package/lib/types/components/CodeBlockFrame.d.ts.map +1 -1
  91. package/lib/types/components/CodeBlockFrame.js +10 -5
  92. package/lib/types/components/CompactionStatusRow.d.ts.map +1 -1
  93. package/lib/types/components/CompactionStatusRow.js +24 -3
  94. package/lib/types/components/GoalTodoPanel.d.ts +73 -6
  95. package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
  96. package/lib/types/components/GoalTodoPanel.js +165 -17
  97. package/lib/types/components/Markdown.d.ts +9 -1
  98. package/lib/types/components/Markdown.d.ts.map +1 -1
  99. package/lib/types/components/Markdown.js +5 -4
  100. package/lib/types/components/MessageList.d.ts.map +1 -1
  101. package/lib/types/components/MessageList.js +20 -14
  102. package/lib/types/components/PluginGrantList.d.ts +45 -0
  103. package/lib/types/components/PluginGrantList.d.ts.map +1 -0
  104. package/lib/types/components/PluginGrantList.js +126 -0
  105. package/lib/types/components/PluginInstallPane.d.ts.map +1 -1
  106. package/lib/types/components/PluginInstallPane.js +35 -6
  107. package/lib/types/components/PluginManagePane.d.ts.map +1 -1
  108. package/lib/types/components/PluginManagePane.js +65 -8
  109. package/lib/types/components/PromptInput.d.ts +13 -5
  110. package/lib/types/components/PromptInput.d.ts.map +1 -1
  111. package/lib/types/components/PromptInput.js +190 -108
  112. package/lib/types/components/SplitDiffView.d.ts.map +1 -1
  113. package/lib/types/components/SplitDiffView.js +232 -22
  114. package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
  115. package/lib/types/components/SubagentDashboard.js +10 -0
  116. package/lib/types/components/SubagentDetailScene.d.ts +3 -1
  117. package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
  118. package/lib/types/components/SubagentDetailScene.js +17 -1
  119. package/lib/types/components/Whale.d.ts.map +1 -1
  120. package/lib/types/components/Whale.js +8 -5
  121. package/lib/types/components/approvals/ApprovalPanel.d.ts +1 -1
  122. package/lib/types/components/approvals/ApprovalPanel.d.ts.map +1 -1
  123. package/lib/types/components/approvals/ApprovalPanel.js +93 -11
  124. package/lib/types/components/bigfont.d.ts.map +1 -1
  125. package/lib/types/components/bigfont.js +2 -1
  126. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +2 -1
  127. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  128. package/lib/types/components/messages/AssistantToolUseMessage.js +24 -11
  129. package/lib/types/components/onboardingModel.d.ts +2 -2
  130. package/lib/types/components/onboardingModel.js +3 -3
  131. package/lib/types/components/onboardingProviderPlan.d.ts +110 -0
  132. package/lib/types/components/onboardingProviderPlan.d.ts.map +1 -0
  133. package/lib/types/components/onboardingProviderPlan.js +78 -0
  134. package/lib/types/components/previewRows.d.ts +19 -0
  135. package/lib/types/components/previewRows.d.ts.map +1 -0
  136. package/lib/types/components/previewRows.js +46 -0
  137. package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
  138. package/lib/types/components/questions/AskUserQuestionPanel.js +75 -10
  139. package/lib/types/components/sessions/ForeignSessionRow.d.ts +3 -9
  140. package/lib/types/components/sessions/ForeignSessionRow.d.ts.map +1 -1
  141. package/lib/types/components/sessions/ForeignSessionRow.js +6 -10
  142. package/lib/types/components/sessions/SessionListRow.d.ts +4 -9
  143. package/lib/types/components/sessions/SessionListRow.d.ts.map +1 -1
  144. package/lib/types/components/sessions/SessionListRow.js +18 -10
  145. package/lib/types/components/sidePanel/InfoPanel.d.ts.map +1 -1
  146. package/lib/types/components/sidePanel/InfoPanel.js +4 -3
  147. package/lib/types/components/sidePanel/SidePanelLayout.d.ts.map +1 -1
  148. package/lib/types/components/sidePanel/SidePanelLayout.js +5 -5
  149. package/lib/types/components/sidePanel/WorkspacePanel.d.ts.map +1 -1
  150. package/lib/types/components/sidePanel/WorkspacePanel.js +19 -7
  151. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +7 -0
  152. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
  153. package/lib/types/components/sidePanel/btw/BtwComposer.js +16 -0
  154. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
  155. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +8 -1
  156. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts +7 -1
  157. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts.map +1 -1
  158. package/lib/types/components/sidePanel/btw/BtwThreadScene.js +8 -1
  159. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts +30 -0
  160. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts.map +1 -0
  161. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.js +94 -0
  162. package/lib/types/components/sidePanel/builtinPanels.d.ts.map +1 -1
  163. package/lib/types/components/sidePanel/builtinPanels.js +36 -18
  164. package/lib/types/components/sidePanel/companion/CompanionPanel.d.ts.map +1 -1
  165. package/lib/types/components/sidePanel/companion/CompanionPanel.js +2 -1
  166. package/lib/types/components/sidePanel/panelMarkdown.d.ts +32 -0
  167. package/lib/types/components/sidePanel/panelMarkdown.d.ts.map +1 -0
  168. package/lib/types/components/sidePanel/panelMarkdown.js +45 -0
  169. package/lib/types/components/sidePanel/pluginPanelAdapter.d.ts.map +1 -1
  170. package/lib/types/components/sidePanel/pluginPanelAdapter.js +6 -1
  171. package/lib/types/components/sidePanel/subagentFailureRead.d.ts +21 -0
  172. package/lib/types/components/sidePanel/subagentFailureRead.d.ts.map +1 -0
  173. package/lib/types/components/sidePanel/subagentFailureRead.js +66 -0
  174. package/lib/types/components/sidePanel/types.d.ts +2 -0
  175. package/lib/types/components/sidePanel/types.d.ts.map +1 -1
  176. package/lib/types/components/sidePanel/useSidePanel.d.ts.map +1 -1
  177. package/lib/types/components/sidePanel/useSidePanel.js +39 -7
  178. package/lib/types/components/trajectory/MiniWake.d.ts +2 -2
  179. package/lib/types/components/trajectory/MiniWake.d.ts.map +1 -1
  180. package/lib/types/components/trajectory/MiniWake.js +7 -3
  181. package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts.map +1 -1
  182. package/lib/types/components/workspaces/HomeWorkspaceRow.js +4 -7
  183. package/lib/types/dsh-adapter/backend/session.d.ts +7 -1
  184. package/lib/types/dsh-adapter/backend/session.d.ts.map +1 -1
  185. package/lib/types/dsh-adapter/backend/session.js +62 -6
  186. package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
  187. package/lib/types/dsh-adapter/backend/translate.js +18 -4
  188. package/lib/types/dsh-adapter/backend-admission.d.ts +3 -3
  189. package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts +1 -1
  190. package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts.map +1 -1
  191. package/lib/types/dsh-adapter/channel/agent-view-projection.js +3 -1
  192. package/lib/types/dsh-adapter/channel/binding-events.d.ts +5 -1
  193. package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
  194. package/lib/types/dsh-adapter/channel/binding-events.js +18 -1
  195. package/lib/types/dsh-adapter/channel/command-completions.d.ts.map +1 -1
  196. package/lib/types/dsh-adapter/channel/command-completions.js +6 -8
  197. package/lib/types/dsh-adapter/channel/composer-images.d.ts +11 -1
  198. package/lib/types/dsh-adapter/channel/composer-images.d.ts.map +1 -1
  199. package/lib/types/dsh-adapter/channel/composer-images.js +121 -113
  200. package/lib/types/dsh-adapter/channel/composer-mentions.d.ts.map +1 -1
  201. package/lib/types/dsh-adapter/channel/composer-mentions.js +38 -17
  202. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts +1 -1
  203. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
  204. package/lib/types/dsh-adapter/channel/context-bookkeeping.js +9 -5
  205. package/lib/types/dsh-adapter/channel/core/actions.d.ts +1 -1
  206. package/lib/types/dsh-adapter/channel/core/actions.d.ts.map +1 -1
  207. package/lib/types/dsh-adapter/channel/core/actions.js +23 -2
  208. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts +10 -1
  209. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts.map +1 -1
  210. package/lib/types/dsh-adapter/channel/core/binding-feed.js +48 -3
  211. package/lib/types/dsh-adapter/channel/core/compose.d.ts +5 -2
  212. package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
  213. package/lib/types/dsh-adapter/channel/core/compose.js +7 -0
  214. package/lib/types/dsh-adapter/channel/core/files.d.ts.map +1 -1
  215. package/lib/types/dsh-adapter/channel/core/files.js +2 -1
  216. package/lib/types/dsh-adapter/channel/core/host.d.ts +14 -10
  217. package/lib/types/dsh-adapter/channel/core/host.d.ts.map +1 -1
  218. package/lib/types/dsh-adapter/channel/core/host.js +192 -13
  219. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts +1 -0
  220. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts.map +1 -1
  221. package/lib/types/dsh-adapter/channel/core/local-actions.js +32 -3
  222. package/lib/types/dsh-adapter/channel/extensions.d.ts.map +1 -1
  223. package/lib/types/dsh-adapter/channel/extensions.js +31 -5
  224. package/lib/types/dsh-adapter/channel/input-actions.d.ts +2 -2
  225. package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
  226. package/lib/types/dsh-adapter/channel/input-actions.js +34 -0
  227. package/lib/types/dsh-adapter/channel/input-delivery.d.ts +5 -2
  228. package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
  229. package/lib/types/dsh-adapter/channel/input-delivery.js +31 -4
  230. package/lib/types/dsh-adapter/channel/mentions.d.ts.map +1 -1
  231. package/lib/types/dsh-adapter/channel/mentions.js +21 -7
  232. package/lib/types/dsh-adapter/channel/model-actions.d.ts +1 -1
  233. package/lib/types/dsh-adapter/channel/model-actions.d.ts.map +1 -1
  234. package/lib/types/dsh-adapter/channel/model-actions.js +7 -1
  235. package/lib/types/dsh-adapter/channel/model-selection.d.ts.map +1 -1
  236. package/lib/types/dsh-adapter/channel/model-selection.js +6 -4
  237. package/lib/types/dsh-adapter/channel/paths.d.ts.map +1 -1
  238. package/lib/types/dsh-adapter/channel/paths.js +11 -9
  239. package/lib/types/dsh-adapter/channel/session-fork.d.ts.map +1 -1
  240. package/lib/types/dsh-adapter/channel/session-fork.js +1 -0
  241. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts +1 -1
  242. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts.map +1 -1
  243. package/lib/types/dsh-adapter/channel/session-live-adoption.js +6 -1
  244. package/lib/types/dsh-adapter/channel/session-metadata.d.ts.map +1 -1
  245. package/lib/types/dsh-adapter/channel/session-metadata.js +15 -2
  246. package/lib/types/dsh-adapter/channel/session-reset.d.ts +1 -1
  247. package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
  248. package/lib/types/dsh-adapter/channel/session-reset.js +7 -1
  249. package/lib/types/dsh-adapter/channel/session-resume.d.ts +1 -1
  250. package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
  251. package/lib/types/dsh-adapter/channel/session-resume.js +56 -36
  252. package/lib/types/dsh-adapter/channel/session-rewind.d.ts +1 -1
  253. package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
  254. package/lib/types/dsh-adapter/channel/session-rewind.js +3 -1
  255. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts +1 -1
  256. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
  257. package/lib/types/dsh-adapter/channel/session-tree-actions.js +3 -1
  258. package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
  259. package/lib/types/dsh-adapter/channel/settings-host.js +10 -3
  260. package/lib/types/dsh-adapter/channel/state.d.ts +1 -1
  261. package/lib/types/dsh-adapter/channel/state.d.ts.map +1 -1
  262. package/lib/types/dsh-adapter/channel/state.js +2 -2
  263. package/lib/types/dsh-adapter/channel/types.d.ts +13 -1
  264. package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
  265. package/lib/types/dsh-adapter/compat/liveSession.d.ts +3 -3
  266. package/lib/types/dsh-adapter/compat/liveSession.js +3 -3
  267. package/lib/types/dsh-adapter/compat/sessionLog.d.ts +1 -1
  268. package/lib/types/dsh-adapter/compat/sessionLog.d.ts.map +1 -1
  269. package/lib/types/dsh-adapter/compat/sessionLog.js +17 -1
  270. package/lib/types/dsh-adapter/contract.d.ts +7 -5
  271. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  272. package/lib/types/dsh-adapter/contract.js +10 -5
  273. package/lib/types/dsh-adapter/effect-ledger.d.ts +1 -1
  274. package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -1
  275. package/lib/types/dsh-adapter/effect-ledger.js +1 -0
  276. package/lib/types/dsh-adapter/entry-slot.d.ts +6 -0
  277. package/lib/types/dsh-adapter/entry-slot.d.ts.map +1 -1
  278. package/lib/types/dsh-adapter/experimental-bundles.d.ts +29 -0
  279. package/lib/types/dsh-adapter/experimental-bundles.d.ts.map +1 -0
  280. package/lib/types/dsh-adapter/experimental-bundles.js +15 -0
  281. package/lib/types/dsh-adapter/grant-file.d.ts +70 -0
  282. package/lib/types/dsh-adapter/grant-file.d.ts.map +1 -0
  283. package/lib/types/dsh-adapter/grant-file.js +178 -0
  284. package/lib/types/dsh-adapter/host-access.d.ts +4 -0
  285. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
  286. package/lib/types/dsh-adapter/host-access.js +54 -4
  287. package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
  288. package/lib/types/dsh-adapter/host-contract.js +2 -2
  289. package/lib/types/dsh-adapter/host-dsh.js +3 -3
  290. package/lib/types/dsh-adapter/index.d.ts +8 -4
  291. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  292. package/lib/types/dsh-adapter/index.js +17 -12
  293. package/lib/types/dsh-adapter/panels.d.ts +28 -8
  294. package/lib/types/dsh-adapter/panels.d.ts.map +1 -1
  295. package/lib/types/dsh-adapter/panels.js +11 -56
  296. package/lib/types/dsh-adapter/plugin-declaration.d.ts +28 -0
  297. package/lib/types/dsh-adapter/plugin-declaration.d.ts.map +1 -1
  298. package/lib/types/dsh-adapter/plugin-declaration.js +43 -1
  299. package/lib/types/dsh-adapter/plugin-install.d.ts +28 -1
  300. package/lib/types/dsh-adapter/plugin-install.d.ts.map +1 -1
  301. package/lib/types/dsh-adapter/plugin-install.js +160 -13
  302. package/lib/types/dsh-adapter/plugin-manage.d.ts +53 -10
  303. package/lib/types/dsh-adapter/plugin-manage.d.ts.map +1 -1
  304. package/lib/types/dsh-adapter/plugin-manage.js +240 -51
  305. package/lib/types/dsh-adapter/plugin.d.ts +81 -0
  306. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  307. package/lib/types/dsh-adapter/plugin.js +378 -84
  308. package/lib/types/dsh-adapter/plugins-info.d.ts +6 -7
  309. package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -1
  310. package/lib/types/dsh-adapter/plugins-info.js +99 -31
  311. package/lib/types/dsh-adapter/presets.d.ts +19 -6
  312. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  313. package/lib/types/dsh-adapter/presets.js +69 -12
  314. package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
  315. package/lib/types/dsh-adapter/process-exit.js +1 -1
  316. package/lib/types/dsh-adapter/providerWizard.d.ts +2 -0
  317. package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -1
  318. package/lib/types/dsh-adapter/providerWizard.js +11 -5
  319. package/lib/types/dsh-adapter/row-attachment.d.ts +30 -0
  320. package/lib/types/dsh-adapter/row-attachment.d.ts.map +1 -0
  321. package/lib/types/dsh-adapter/row-attachment.js +29 -0
  322. package/lib/types/dsh-adapter/session-tools.d.ts +34 -0
  323. package/lib/types/dsh-adapter/session-tools.d.ts.map +1 -0
  324. package/lib/types/dsh-adapter/session-tools.js +39 -0
  325. package/lib/types/dsh-adapter/settings-sections.d.ts +18 -1
  326. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
  327. package/lib/types/dsh-adapter/settings-sections.js +73 -0
  328. package/lib/types/dsh-adapter/status.d.ts +88 -1
  329. package/lib/types/dsh-adapter/status.d.ts.map +1 -1
  330. package/lib/types/dsh-adapter/status.js +318 -3
  331. package/lib/types/dsh-adapter/team-mode.d.ts +42 -33
  332. package/lib/types/dsh-adapter/team-mode.d.ts.map +1 -1
  333. package/lib/types/dsh-adapter/team-mode.js +76 -112
  334. package/lib/types/dsh-adapter/worktree-tool.d.ts +27 -0
  335. package/lib/types/dsh-adapter/worktree-tool.d.ts.map +1 -0
  336. package/lib/types/dsh-adapter/worktree-tool.js +87 -0
  337. package/lib/types/extensions.d.ts +1 -1
  338. package/lib/types/extensions.d.ts.map +1 -1
  339. package/lib/types/force-production-react.js +3 -3
  340. package/lib/types/heldInputs.d.ts +36 -0
  341. package/lib/types/heldInputs.d.ts.map +1 -0
  342. package/lib/types/heldInputs.js +173 -0
  343. package/lib/types/i18n.d.ts +543 -73
  344. package/lib/types/i18n.d.ts.map +1 -1
  345. package/lib/types/i18n.js +265 -46
  346. package/lib/types/ink/colorize.d.ts +7 -1
  347. package/lib/types/ink/colorize.d.ts.map +1 -1
  348. package/lib/types/ink/colorize.js +29 -8
  349. package/lib/types/ink/components/App.d.ts +2 -1
  350. package/lib/types/ink/components/App.d.ts.map +1 -1
  351. package/lib/types/ink/components/App.js +10 -3
  352. package/lib/types/ink/components/ScrollBox.d.ts.map +1 -1
  353. package/lib/types/ink/components/ScrollBox.js +1 -0
  354. package/lib/types/ink/dom.d.ts +1 -0
  355. package/lib/types/ink/dom.d.ts.map +1 -1
  356. package/lib/types/ink/hooks/use-program-status.d.ts +78 -0
  357. package/lib/types/ink/hooks/use-program-status.d.ts.map +1 -0
  358. package/lib/types/ink/hooks/use-program-status.js +96 -0
  359. package/lib/types/ink/ink.d.ts +13 -4
  360. package/lib/types/ink/ink.d.ts.map +1 -1
  361. package/lib/types/ink/ink.js +119 -25
  362. package/lib/types/ink/output.d.ts +17 -2
  363. package/lib/types/ink/output.d.ts.map +1 -1
  364. package/lib/types/ink/output.js +85 -2
  365. package/lib/types/ink/parse-keypress.d.ts +1 -0
  366. package/lib/types/ink/parse-keypress.d.ts.map +1 -1
  367. package/lib/types/ink/parse-keypress.js +5 -4
  368. package/lib/types/ink/render-node-to-output.d.ts +2 -0
  369. package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
  370. package/lib/types/ink/render-node-to-output.js +79 -10
  371. package/lib/types/ink/root.d.ts +8 -0
  372. package/lib/types/ink/root.d.ts.map +1 -1
  373. package/lib/types/ink/root.js +12 -3
  374. package/lib/types/ink/screen.d.ts +11 -0
  375. package/lib/types/ink/screen.d.ts.map +1 -1
  376. package/lib/types/ink/screen.js +44 -0
  377. package/lib/types/ink/selection.d.ts +7 -2
  378. package/lib/types/ink/selection.d.ts.map +1 -1
  379. package/lib/types/ink/selection.js +187 -44
  380. package/lib/types/ink/shutdown-input.d.ts +15 -0
  381. package/lib/types/ink/shutdown-input.d.ts.map +1 -0
  382. package/lib/types/ink/shutdown-input.js +28 -0
  383. package/lib/types/ink/sixel-cursor-heal.d.ts +21 -0
  384. package/lib/types/ink/sixel-cursor-heal.d.ts.map +1 -0
  385. package/lib/types/ink/sixel-cursor-heal.js +62 -0
  386. package/lib/types/ink/sixel-graphics.d.ts +6 -0
  387. package/lib/types/ink/sixel-graphics.d.ts.map +1 -1
  388. package/lib/types/ink/sixel-graphics.js +18 -0
  389. package/lib/types/ink/styles.d.ts +8 -1
  390. package/lib/types/ink/styles.d.ts.map +1 -1
  391. package/lib/types/ink/terminal-notification-windows.d.ts +195 -0
  392. package/lib/types/ink/terminal-notification-windows.d.ts.map +1 -0
  393. package/lib/types/ink/terminal-notification-windows.js +433 -0
  394. package/lib/types/ink/terminal-notification.d.ts +3 -1
  395. package/lib/types/ink/terminal-notification.d.ts.map +1 -1
  396. package/lib/types/ink/terminal-notification.js +4 -1
  397. package/lib/types/ink/terminal-querier.d.ts +9 -1
  398. package/lib/types/ink/terminal-querier.d.ts.map +1 -1
  399. package/lib/types/ink/terminal-querier.js +32 -1
  400. package/lib/types/ink/terminal.d.ts +23 -2
  401. package/lib/types/ink/terminal.d.ts.map +1 -1
  402. package/lib/types/ink/terminal.js +32 -2
  403. package/lib/types/ink/termio/osc.d.ts +2 -1
  404. package/lib/types/ink/termio/osc.d.ts.map +1 -1
  405. package/lib/types/ink/termio/osc.js +37 -8
  406. package/lib/types/ink/termio/osc7501.d.ts +102 -0
  407. package/lib/types/ink/termio/osc7501.d.ts.map +1 -0
  408. package/lib/types/ink/termio/osc7501.js +229 -0
  409. package/lib/types/ink/termio/tokenize.js +5 -7
  410. package/lib/types/onboardingDraft.d.ts +143 -0
  411. package/lib/types/onboardingDraft.d.ts.map +1 -0
  412. package/lib/types/onboardingDraft.js +71 -0
  413. package/lib/types/panels.d.ts +1 -1
  414. package/lib/types/panels.d.ts.map +1 -1
  415. package/lib/types/screens/AgentTranscriptScene.d.ts +3 -1
  416. package/lib/types/screens/AgentTranscriptScene.d.ts.map +1 -1
  417. package/lib/types/screens/AgentTranscriptScene.js +5 -1
  418. package/lib/types/screens/Chat.d.ts +6 -6
  419. package/lib/types/screens/Chat.d.ts.map +1 -1
  420. package/lib/types/screens/Chat.js +394 -141
  421. package/lib/types/screens/Launchpad.d.ts +8 -2
  422. package/lib/types/screens/Launchpad.d.ts.map +1 -1
  423. package/lib/types/screens/Launchpad.js +32 -12
  424. package/lib/types/screens/Onboarding.d.ts +22 -3
  425. package/lib/types/screens/Onboarding.d.ts.map +1 -1
  426. package/lib/types/screens/Onboarding.js +606 -36
  427. package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
  428. package/lib/types/screens/SessionSupervisor.js +31 -21
  429. package/lib/types/screens/Settings.d.ts +5 -1
  430. package/lib/types/screens/Settings.d.ts.map +1 -1
  431. package/lib/types/screens/Settings.js +528 -51
  432. package/lib/types/screens/StatusLine.d.ts +9 -3
  433. package/lib/types/screens/StatusLine.d.ts.map +1 -1
  434. package/lib/types/screens/StatusLine.js +91 -15
  435. package/lib/types/screens/StatusMetrics.d.ts +2 -11
  436. package/lib/types/screens/StatusMetrics.d.ts.map +1 -1
  437. package/lib/types/screens/StatusMetrics.js +20 -14
  438. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -1
  439. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +1 -1
  440. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts +1 -1
  441. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts.map +1 -1
  442. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.js +13 -21
  443. package/lib/types/sessionMounts.d.ts +14 -0
  444. package/lib/types/sessionMounts.d.ts.map +1 -1
  445. package/lib/types/sessionMounts.js +20 -9
  446. package/lib/types/sessions/format.d.ts +39 -0
  447. package/lib/types/sessions/format.d.ts.map +1 -1
  448. package/lib/types/sessions/format.js +83 -0
  449. package/lib/types/sessions/resumeFailure.d.ts +4 -0
  450. package/lib/types/sessions/resumeFailure.d.ts.map +1 -1
  451. package/lib/types/sessions/resumeFailure.js +12 -4
  452. package/lib/types/sessions/workspaceCounts.d.ts +6 -0
  453. package/lib/types/sessions/workspaceCounts.d.ts.map +1 -0
  454. package/lib/types/sessions/workspaceCounts.js +24 -0
  455. package/lib/types/settings/definitions.d.ts +24 -0
  456. package/lib/types/settings/definitions.d.ts.map +1 -1
  457. package/lib/types/settings/definitions.js +40 -15
  458. package/lib/types/tips.js +2 -2
  459. package/lib/types/tuiDisplayPrefs.d.ts +113 -5
  460. package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
  461. package/lib/types/tuiDisplayPrefs.js +276 -14
  462. package/lib/types/update.d.ts +15 -14
  463. package/lib/types/update.d.ts.map +1 -1
  464. package/lib/types/update.js +163 -115
  465. package/lib/types/updateProcess.d.ts +28 -0
  466. package/lib/types/updateProcess.d.ts.map +1 -0
  467. package/lib/types/updateProcess.js +135 -0
  468. package/lib/types/utils/inputWordBoundary.d.ts +5 -0
  469. package/lib/types/utils/inputWordBoundary.d.ts.map +1 -0
  470. package/lib/types/utils/inputWordBoundary.js +18 -0
  471. package/lib/types/utils/keymap.d.ts +1 -1
  472. package/lib/types/utils/keymap.d.ts.map +1 -1
  473. package/lib/types/utils/keymap.js +6 -1
  474. package/lib/types/utils/paths.d.ts +15 -0
  475. package/lib/types/utils/paths.d.ts.map +1 -1
  476. package/lib/types/utils/paths.js +25 -0
  477. package/lib/types/windowsInstaller.d.ts +4 -0
  478. package/lib/types/windowsInstaller.d.ts.map +1 -0
  479. package/lib/types/windowsInstaller.js +237 -0
  480. package/locale/en.json +6 -0
  481. package/locale/zh.json +6 -0
  482. package/package.json +130 -111
  483. package/presets/liangshen/custom-bash.mjs +13 -1
  484. package/presets/liangshen/instruction-hint.mjs +4 -1
  485. package/presets/liangshen/skill-search.mjs +14 -2
  486. package/presets/winbash.mjs +16 -4
  487. package/tui-profile/feed/README.md +17 -8
  488. package/tui-profile/feed/first-party.json +1 -1
@@ -0,0 +1,308 @@
1
+ // Private installer ownership. JOB_LIST requires Windows 10 / Server 2016.
2
+ // Assignment failures fail closed before the suspended installer can execute.
3
+ // https://learn.microsoft.com/windows/win32/procthread/nested-jobs
4
+ // https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute
5
+ using System;
6
+ using System.ComponentModel;
7
+ using System.Diagnostics;
8
+ using System.IO;
9
+ using System.Runtime.InteropServices;
10
+ using System.Text;
11
+ using System.Threading;
12
+
13
+ public static class DshInstallerJob
14
+ {
15
+ public sealed class Result
16
+ {
17
+ public int code = 127;
18
+ public bool cleanupConfirmed = true;
19
+ public string error;
20
+ }
21
+
22
+ [StructLayout(LayoutKind.Sequential)]
23
+ struct BasicLimits
24
+ {
25
+ public long ProcessTime, JobTime;
26
+ public uint Flags;
27
+ public UIntPtr MinWorkingSet, MaxWorkingSet;
28
+ public uint ActiveProcessLimit;
29
+ public UIntPtr Affinity;
30
+ public uint PriorityClass, SchedulingClass;
31
+ }
32
+ [StructLayout(LayoutKind.Sequential)]
33
+ struct IoCounters
34
+ {
35
+ public ulong ReadOperations, WriteOperations, OtherOperations;
36
+ public ulong ReadBytes, WriteBytes, OtherBytes;
37
+ }
38
+ [StructLayout(LayoutKind.Sequential)]
39
+ struct ExtendedLimits
40
+ {
41
+ public BasicLimits Basic;
42
+ public IoCounters Io;
43
+ public UIntPtr ProcessMemory, JobMemory, PeakProcessMemory, PeakJobMemory;
44
+ }
45
+ [StructLayout(LayoutKind.Sequential)]
46
+ struct Accounting
47
+ {
48
+ public long UserTime, KernelTime, PeriodUserTime, PeriodKernelTime;
49
+ public uint PageFaults, TotalProcesses, ActiveProcesses, TerminatedProcesses;
50
+ }
51
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
52
+ struct StartupInfo
53
+ {
54
+ public uint Size;
55
+ public string Reserved, Desktop, Title;
56
+ public uint X, Y, XSize, YSize, XChars, YChars, Fill, Flags;
57
+ public ushort ShowWindow, ReservedBytes;
58
+ public IntPtr ReservedData, Stdin, Stdout, Stderr;
59
+ }
60
+ [StructLayout(LayoutKind.Sequential)]
61
+ struct StartupInfoEx
62
+ {
63
+ public StartupInfo Startup;
64
+ public IntPtr Attributes;
65
+ }
66
+ [StructLayout(LayoutKind.Sequential)]
67
+ struct ProcessInfo
68
+ {
69
+ public IntPtr Process, Thread;
70
+ public uint Pid, Tid;
71
+ }
72
+
73
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
74
+ static extern IntPtr CreateJobObjectW(IntPtr attributes, string name);
75
+ [DllImport("kernel32.dll", SetLastError = true)]
76
+ static extern bool SetInformationJobObject(IntPtr job, int kind, ref ExtendedLimits limits, uint size);
77
+ [DllImport("kernel32.dll", SetLastError = true)]
78
+ static extern bool QueryInformationJobObject(IntPtr job, int kind, out Accounting info, uint size, IntPtr length);
79
+ [DllImport("kernel32.dll", SetLastError = true)]
80
+ static extern bool InitializeProcThreadAttributeList(IntPtr list, int count, uint flags, ref UIntPtr size);
81
+ [DllImport("kernel32.dll", SetLastError = true)]
82
+ static extern bool UpdateProcThreadAttribute(IntPtr list, uint flags, UIntPtr attribute,
83
+ IntPtr value, UIntPtr size, IntPtr previous, IntPtr returnedSize);
84
+ [DllImport("kernel32.dll")]
85
+ static extern void DeleteProcThreadAttributeList(IntPtr list);
86
+ [DllImport("kernel32.dll", SetLastError = true)]
87
+ static extern bool GetHandleInformation(IntPtr handle, out uint flags);
88
+ [DllImport("kernel32.dll", SetLastError = true)]
89
+ static extern bool GetProcessTimes(IntPtr process, out long created, out long exited, out long kernel, out long user);
90
+ [DllImport("kernel32.dll", SetLastError = true)]
91
+ static extern bool IsProcessInJob(IntPtr process, IntPtr job, out bool member);
92
+ [DllImport("kernel32.dll", SetLastError = true)]
93
+ static extern bool TerminateJobObject(IntPtr job, uint code);
94
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
95
+ static extern bool CreateProcessW(string application, StringBuilder command, IntPtr processAttributes,
96
+ IntPtr threadAttributes, bool inherit, uint flags, IntPtr environment, string directory,
97
+ ref StartupInfoEx startup, out ProcessInfo process);
98
+ [DllImport("kernel32.dll", SetLastError = true)]
99
+ static extern uint ResumeThread(IntPtr thread);
100
+ [DllImport("kernel32.dll", SetLastError = true)]
101
+ static extern uint WaitForSingleObject(IntPtr handle, uint milliseconds);
102
+ [DllImport("kernel32.dll", SetLastError = true)]
103
+ static extern bool GetExitCodeProcess(IntPtr process, out uint code);
104
+ [DllImport("kernel32.dll", SetLastError = true)]
105
+ static extern bool TerminateProcess(IntPtr process, uint code);
106
+ [DllImport("kernel32.dll", SetLastError = true)]
107
+ static extern IntPtr OpenProcess(uint access, bool inherit, uint pid);
108
+ [DllImport("kernel32.dll")]
109
+ static extern IntPtr GetCurrentProcess();
110
+ [DllImport("kernel32.dll", SetLastError = true)]
111
+ static extern IntPtr GetStdHandle(int which);
112
+ [DllImport("kernel32.dll", SetLastError = true)]
113
+ static extern bool DuplicateHandle(IntPtr sourceProcess, IntPtr source, IntPtr targetProcess,
114
+ out IntPtr target, uint access, bool inherit, uint options);
115
+ [DllImport("kernel32.dll", SetLastError = true)]
116
+ static extern bool CloseHandle(IntPtr handle);
117
+
118
+ static void Check(bool success, string operation)
119
+ {
120
+ if (!success)
121
+ {
122
+ int code = Marshal.GetLastWin32Error();
123
+ throw new Win32Exception(code, operation + " failed (Win32 " + code + "): " + new Win32Exception(code).Message);
124
+ }
125
+ }
126
+ static bool Exited(IntPtr process)
127
+ {
128
+ uint result = WaitForSingleObject(process, 0);
129
+ if (result == 0) return true;
130
+ if (result == 258) return false;
131
+ throw new Win32Exception(Marshal.GetLastWin32Error(), "WaitForSingleObject");
132
+ }
133
+ static uint Active(IntPtr job)
134
+ {
135
+ Accounting info;
136
+ Check(QueryInformationJobObject(job, 1, out info, (uint)Marshal.SizeOf(typeof(Accounting)), IntPtr.Zero),
137
+ "QueryInformationJobObject");
138
+ return info.ActiveProcesses;
139
+ }
140
+ static bool Drain(IntPtr job)
141
+ {
142
+ Stopwatch clock = Stopwatch.StartNew();
143
+ do
144
+ {
145
+ if (Active(job) == 0) return true;
146
+ Thread.Sleep(20);
147
+ } while (clock.ElapsedMilliseconds < 5000);
148
+ return false;
149
+ }
150
+ static IntPtr StandardHandle(int which)
151
+ {
152
+ IntPtr source = GetStdHandle(which);
153
+ if (source == IntPtr.Zero || source == new IntPtr(-1))
154
+ throw new InvalidOperationException("Missing inherited installer standard handle " + which);
155
+ IntPtr copy;
156
+ Check(DuplicateHandle(GetCurrentProcess(), source, GetCurrentProcess(), out copy, 0, true, 2),
157
+ "DuplicateHandle(standard stream)");
158
+ return copy;
159
+ }
160
+ static void Close(IntPtr handle)
161
+ {
162
+ if (handle != IntPtr.Zero && handle != new IntPtr(-1)) CloseHandle(handle);
163
+ }
164
+
165
+ public static Result Run(string application, string commandLine, string directory, uint parentPid, long parentNotAfterMs)
166
+ {
167
+ Result result = new Result();
168
+ IntPtr parent = IntPtr.Zero, job = IntPtr.Zero;
169
+ ProcessInfo child = new ProcessInfo();
170
+ StartupInfoEx startup = new StartupInfoEx();
171
+ IntPtr handleList = IntPtr.Zero, jobList = IntPtr.Zero;
172
+ bool attributesInitialized = false;
173
+ bool assigned = false;
174
+ try
175
+ {
176
+ // Pin identity once, before launching anything. No PID lookup is used to
177
+ // terminate an installer or to rediscover descendants after root exit.
178
+ parent = OpenProcess(0x00101000, false, parentPid); // SYNCHRONIZE | QUERY_LIMITED_INFORMATION
179
+ Check(parent != IntPtr.Zero, "OpenProcess(installer owner)");
180
+ if (Exited(parent)) throw new InvalidOperationException("Installer owner has exited");
181
+ long created, exited, kernel, user;
182
+ Check(GetProcessTimes(parent, out created, out exited, out kernel, out user), "GetProcessTimes(installer owner)");
183
+ if (created / 10000 - 11644473600000L > parentNotAfterMs)
184
+ throw new InvalidOperationException("Installer owner PID was reused before supervisor startup");
185
+ job = CreateJobObjectW(IntPtr.Zero, null); // unnamed and non-inheritable
186
+ Check(job != IntPtr.Zero, "CreateJobObject");
187
+ uint handleFlags;
188
+ Check(GetHandleInformation(job, out handleFlags), "GetHandleInformation(job)");
189
+ if ((handleFlags & 1) != 0) throw new InvalidOperationException("Installer job handle must not be inheritable");
190
+ ExtendedLimits limits = new ExtendedLimits();
191
+ limits.Basic.Flags = 0x00002000; // KILL_ON_JOB_CLOSE; NEVER allow breakaway
192
+ Check(SetInformationJobObject(job, 9, ref limits, (uint)Marshal.SizeOf(typeof(ExtendedLimits))),
193
+ "SetInformationJobObject(KILL_ON_JOB_CLOSE)");
194
+ if (File.Exists(Path.Combine(directory, "cancel"))) { result.code = 130; return result; }
195
+ startup.Startup.Size = (uint)Marshal.SizeOf(typeof(StartupInfoEx));
196
+ startup.Startup.Flags = 0x00000100; // STARTF_USESTDHANDLES
197
+ startup.Startup.Stdin = StandardHandle(-10);
198
+ startup.Startup.Stdout = StandardHandle(-11);
199
+ startup.Startup.Stderr = StandardHandle(-12);
200
+ UIntPtr attributeBytes = UIntPtr.Zero;
201
+ InitializeProcThreadAttributeList(IntPtr.Zero, 2, 0, ref attributeBytes);
202
+ startup.Attributes = Marshal.AllocHGlobal(checked((int)attributeBytes.ToUInt64()));
203
+ Check(InitializeProcThreadAttributeList(startup.Attributes, 2, 0, ref attributeBytes),
204
+ "InitializeProcThreadAttributeList");
205
+ attributesInitialized = true;
206
+ handleList = Marshal.AllocHGlobal(IntPtr.Size * 3);
207
+ Marshal.WriteIntPtr(handleList, 0, startup.Startup.Stdin);
208
+ Marshal.WriteIntPtr(handleList, IntPtr.Size, startup.Startup.Stdout);
209
+ Marshal.WriteIntPtr(handleList, IntPtr.Size * 2, startup.Startup.Stderr);
210
+ Check(UpdateProcThreadAttribute(startup.Attributes, 0, new UIntPtr(0x00020002), handleList,
211
+ new UIntPtr((uint)(IntPtr.Size * 3)), IntPtr.Zero, IntPtr.Zero), "UpdateProcThreadAttribute(HANDLE_LIST)");
212
+ jobList = Marshal.AllocHGlobal(IntPtr.Size);
213
+ Marshal.WriteIntPtr(jobList, job);
214
+ Check(UpdateProcThreadAttribute(startup.Attributes, 0, new UIntPtr(0x0002000d), jobList,
215
+ new UIntPtr((uint)IntPtr.Size), IntPtr.Zero, IntPtr.Zero), "UpdateProcThreadAttribute(JOB_LIST)");
216
+ // Atomically assign during creation: killing the supervisor between
217
+ // CreateProcess and a separate AssignProcessToJobObject must not leak an
218
+ // unowned suspended installer. No breakaway or unowned fallback exists.
219
+ Check(CreateProcessW(String.IsNullOrEmpty(application) ? null : application,
220
+ new StringBuilder(commandLine), IntPtr.Zero, IntPtr.Zero, true,
221
+ 0x00080004, IntPtr.Zero, null, ref startup, out child), "CreateProcess(CREATE_SUSPENDED, JOB_LIST)");
222
+ result.cleanupConfirmed = false;
223
+ assigned = true;
224
+ bool member;
225
+ Check(IsProcessInJob(child.Process, job, out member), "IsProcessInJob");
226
+ if (!member) throw new InvalidOperationException("Installer job membership could not be verified");
227
+ // Recheck cancellation/parent while the installer still cannot execute.
228
+ if (Exited(parent) || File.Exists(Path.Combine(directory, "cancel")))
229
+ {
230
+ result.code = 130;
231
+ Check(TerminateJobObject(job, 130), "TerminateJobObject");
232
+ result.cleanupConfirmed = Drain(job);
233
+ return result;
234
+ }
235
+ Check(ResumeThread(child.Thread) != 0xffffffff, "ResumeThread");
236
+ Close(child.Thread);
237
+ child.Thread = IntPtr.Zero;
238
+ File.WriteAllText(Path.Combine(directory, "ready.tmp"), "{\"pid\":" + child.Pid + ",\"member\":true,\"inheritable\":false}", Encoding.ASCII);
239
+ File.Move(Path.Combine(directory, "ready.tmp"), Path.Combine(directory, "ready"));
240
+ while (true)
241
+ {
242
+ if (File.Exists(Path.Combine(directory, "cancel")) || Exited(parent))
243
+ {
244
+ result.code = 130;
245
+ Check(TerminateJobObject(job, 130), "TerminateJobObject");
246
+ result.cleanupConfirmed = Drain(job);
247
+ if (!result.cleanupConfirmed) result.error = "Installer job did not empty after termination";
248
+ return result;
249
+ }
250
+ if (Active(job) == 0)
251
+ {
252
+ if (WaitForSingleObject(child.Process, 5000) != 0)
253
+ throw new InvalidOperationException("Empty installer job did not signal root exit");
254
+ uint code;
255
+ Check(GetExitCodeProcess(child.Process, out code), "GetExitCodeProcess");
256
+ result.code = unchecked((int)code);
257
+ result.cleanupConfirmed = true;
258
+ return result;
259
+ }
260
+ Thread.Sleep(25);
261
+ }
262
+ }
263
+ catch (Exception error)
264
+ {
265
+ result.code = 127;
266
+ result.error = error.Message;
267
+ try
268
+ {
269
+ if (job != IntPtr.Zero)
270
+ {
271
+ // Even a failed atomic assignment can briefly leave a terminating
272
+ // process in job accounting. Confirm zero instead of assuming it.
273
+ Check(TerminateJobObject(job, 127), "TerminateJobObject after failure");
274
+ result.cleanupConfirmed = Drain(job);
275
+ }
276
+ if (!assigned && child.Process != IntPtr.Zero)
277
+ {
278
+ // Still suspended and never assigned: terminate only the retained
279
+ // process handle, even when assignment failed under an outer job.
280
+ if (!Exited(child.Process)) Check(TerminateProcess(child.Process, 127), "TerminateProcess(suspended root)");
281
+ bool rootStopped = WaitForSingleObject(child.Process, 5000) == 0;
282
+ result.cleanupConfirmed = result.cleanupConfirmed && rootStopped;
283
+ }
284
+ }
285
+ catch (Exception cleanupError)
286
+ {
287
+ result.cleanupConfirmed = false;
288
+ result.error += "; cleanup: " + cleanupError.Message;
289
+ }
290
+ return result;
291
+ }
292
+ finally
293
+ {
294
+ // Closing the sole job handle is a fail-safe even if confirmation failed.
295
+ Close(job);
296
+ Close(child.Thread);
297
+ Close(child.Process);
298
+ if (attributesInitialized) DeleteProcThreadAttributeList(startup.Attributes);
299
+ if (startup.Attributes != IntPtr.Zero) Marshal.FreeHGlobal(startup.Attributes);
300
+ if (handleList != IntPtr.Zero) Marshal.FreeHGlobal(handleList);
301
+ if (jobList != IntPtr.Zero) Marshal.FreeHGlobal(jobList);
302
+ Close(startup.Startup.Stdin);
303
+ Close(startup.Startup.Stdout);
304
+ Close(startup.Startup.Stderr);
305
+ Close(parent);
306
+ }
307
+ }
308
+ }
@@ -0,0 +1,17 @@
1
+ param([Parameter(Mandatory = $true)][string]$ControlDirectory)
2
+ $ErrorActionPreference = 'Stop'
3
+ $nativeStarted = $false
4
+ # No pipeline or Read-Host: installer stdin belongs exclusively to the child.
5
+ try {
6
+ $config = [IO.File]::ReadAllText((Join-Path $ControlDirectory 'config.json')) | ConvertFrom-Json
7
+ Add-Type -Path (Join-Path $PSScriptRoot 'windows-installer.cs')
8
+ $nativeStarted = $true
9
+ $result = [DshInstallerJob]::Run([string]$config.application, [string]$config.commandLine,
10
+ $ControlDirectory, [uint32]$config.parentPid, [long]$config.parentNotAfterMs)
11
+ } catch {
12
+ $result = @{ code = 127; cleanupConfirmed = (-not $nativeStarted); error = $_.Exception.Message }
13
+ }
14
+ $json = $result | ConvertTo-Json -Compress
15
+ [IO.File]::WriteAllText((Join-Path $ControlDirectory 'result.tmp'), $json, [Text.UTF8Encoding]::new($false))
16
+ [IO.File]::Move((Join-Path $ControlDirectory 'result.tmp'), (Join-Path $ControlDirectory 'result.json'))
17
+ exit 0
package/bin/dsh-tui.js CHANGED
@@ -172,8 +172,38 @@ const isVersionNewer = (a, b) => {
172
172
  return false
173
173
  }
174
174
 
175
+ // The migrated launcher is a single file, so this conservative evaluator has
176
+ // no package dependencies. Only stable positive-major caret / lower-bound OR
177
+ // ranges are recognized. Unknown manifests or syntax must never block launch.
178
+ const supportsNode = (version, range) => {
179
+ const current = parseVersion(version)
180
+ if (!current || typeof range !== 'string') return undefined
181
+ const alternatives = range.split('||').map(part => /^(\^|>=)([1-9]\d*)(?:\.(\d+))?(?:\.(\d+))?$/.exec(part.trim()))
182
+ if (alternatives.some(part => !part || (part[1] === '^' && part[3] === undefined))) return undefined
183
+ // Stable engine ranges exclude prereleases, including a future major's RC.
184
+ if (current.pre !== null) return false
185
+ return alternatives.some(part => {
186
+ const [, operator, major, minor = '0', patch = '0'] = part
187
+ const floor = [Number(major), Number(minor), Number(patch)]
188
+ const actual = [current.major, current.minor, current.patch]
189
+ const firstDifference = actual.findIndex((value, i) => value !== floor[i])
190
+ const atLeast = firstDifference < 0 || actual[firstDifference] > floor[firstDifference]
191
+ return atLeast && (operator !== '^' || current.major === floor[0])
192
+ })
193
+ }
194
+ const nodeRange = ownPackage?.name === PACKAGE ? ownPackage.engines?.node : undefined
195
+ const nodeSupported = supportsNode(process.versions.node, nodeRange)
196
+
175
197
  const lang = process.env.DSH_TUI_LANG === 'en' ? 'en' : 'zh'
176
198
  const MSG = {
199
+ nodeUnsupported: {
200
+ en: `[dsh-tui] Node ${process.version} is unsupported (required: ${nodeRange}). Install a supported Node release from https://nodejs.org/en/download and reopen this terminal.`,
201
+ zh: `[dsh-tui] Node ${process.version} 不受支持(要求:${nodeRange})。请从 https://nodejs.org/en/download 安装受支持的 Node 并重新打开终端。`,
202
+ },
203
+ nodeUnknown: {
204
+ en: `[dsh-tui] Cannot determine Node ${process.version} compatibility: package engines.node is missing or unrecognized (${nodeRange ?? 'unknown'}).`,
205
+ zh: `[dsh-tui] 无法判断 Node ${process.version} 兼容性:包 engines.node 缺失或无法识别(${nodeRange ?? 'unknown'})。`,
206
+ },
177
207
  noDsh: {
178
208
  en: '[dsh-tui] dsh CLI not found. Install the official client first:\n npm install -g @deepseek-ai/dsh',
179
209
  zh: '[dsh-tui] 未检测到 dsh CLI。请先安装官方客户端:\n npm install -g @deepseek-ai/dsh',
@@ -490,6 +520,9 @@ const MSG = {
490
520
  en:
491
521
  `Usage: dsh-tui|dst [command] [options] [path|url]\n\n` +
492
522
  `Commands:\n` +
523
+ ` run / -p Run one non-interactive DSH task (dst cli --help)\n` +
524
+ ` cli <command> Independent automation CLI and management commands\n` +
525
+ ` dsh <argv...> Forward native DSH arguments unchanged\n` +
493
526
  ` update Update the ${PROFILE} profile to the latest release\n` +
494
527
  ` migrate [agent] Import conversations from claude-code/codex/omp/zcode/grok-build (--dry-run to preview)\n` +
495
528
  ` doctor Pre-flight environment checks (dsh/pnpm/profile/key)\n` +
@@ -509,6 +542,9 @@ const MSG = {
509
542
  zh:
510
543
  `用法:dsh-tui|dst [命令] [选项] [路径|URL]\n\n` +
511
544
  `命令:\n` +
545
+ ` run / -p 无界面运行单个 DSH 任务(dst cli --help)\n` +
546
+ ` cli <命令> 独立自动化 CLI 与管理命令\n` +
547
+ ` dsh <参数...> 原样转交官方 DSH CLI\n` +
512
548
  ` update 将 ${PROFILE} profile 升级到最新版本\n` +
513
549
  ` migrate [agent] 迁移 claude-code/codex/omp/zcode/grok-build 的对话(--dry-run 预览)\n` +
514
550
  ` doctor 启动前环境诊断(dsh/pnpm/profile/密钥)\n` +
@@ -529,9 +565,9 @@ const MSG = {
529
565
  }
530
566
  const msg = key => MSG[key][lang]
531
567
 
532
- // React 开发构建会把每次渲染的 performance.measure() 堆进无界缓冲区导致
533
- // 长会话 OOM——与仓库根 dsh-tui.cmd 保持一致,强制 production。
534
- process.env.NODE_ENV ??= 'production'
568
+ // 与包入口的 force-production-react 保持一致:工作区 NODE_ENV 不能启用
569
+ // React 开发构建的无界渲染插桩,调试须显式设置 DSH_TUI_REACT_DEV=1。
570
+ process.env.NODE_ENV = process.env.DSH_TUI_REACT_DEV === '1' ? 'development' : 'production'
535
571
 
536
572
  const sameDir = (a, b) => {
537
573
  try {
@@ -595,6 +631,26 @@ if (subcommand === 'help' || subcommand === '--help' || subcommand === '-h') {
595
631
  console.log(msg('helpText'))
596
632
  process.exit(0)
597
633
  }
634
+ // Help/version stay readable. Unknown engines in migrated/profile manifests
635
+ // are allowed; doctor exposes the uncertainty without breaking delegation.
636
+ if (subcommand !== 'doctor' && nodeSupported === false) {
637
+ console.error(msg('nodeUnsupported'))
638
+ process.exit(1)
639
+ }
640
+ // CLI is a separate, uncompiled application. Never bootstrap/render the TUI for
641
+ // automation. A migrated single-file launcher prefers the updated profile copy.
642
+ const cliInvocation = ['cli', 'run', '-p', '--print', 'session', 'models', 'skills', 'mcp', 'auth', 'capabilities', 'dsh'].includes(subcommand)
643
+ if (cliInvocation) {
644
+ const profileEntry = join(profilePkgDir, 'cli', 'entry.mjs')
645
+ const ownEntry = join(ownDir, 'cli', 'entry.mjs')
646
+ const entry = existsSync(profileEntry) ? profileEntry : ownEntry
647
+ if (!existsSync(entry)) {
648
+ console.error('[dsh-tui] CLI_ENTRY_MISSING: update the profile or reinstall the package; no task was started.')
649
+ process.exit(3)
650
+ }
651
+ const { main } = await import(pathToFileURL(entry).href)
652
+ process.exit(await main(process.argv.slice(2)))
653
+ }
598
654
  /**
599
655
  * The credential documents a read may consult, most authoritative first: the
600
656
  * active home's store, then the default `~/.dsh` store. A `DSH_HOME` override
@@ -645,7 +701,10 @@ const runDoctorChecks = () => {
645
701
  let hardFailure = false
646
702
  const report = (ok, label, detail) => lines.push(`${ok ? '✓' : '✗'} ${label}: ${detail}`)
647
703
  lines.push(`dsh-tui doctor · ${PACKAGE} ${ownVersion ?? 'unknown'}`)
648
- report(true, 'node', `${process.version} · ${process.platform} ${process.arch}`)
704
+ report(nodeSupported === true, 'node', nodeSupported === true
705
+ ? `${process.version} · ${process.platform} ${process.arch}`
706
+ : msg(nodeSupported === false ? 'nodeUnsupported' : 'nodeUnknown'))
707
+ if (nodeSupported !== true) hardFailure = true
649
708
  const probeVersion = command => {
650
709
  const probe = spawnSync(...cmd(command, ['--version']), { stdio: 'pipe', encoding: 'utf8', ...shellOpt })
651
710
  if (probe.error || probe.status !== 0) return undefined
@@ -765,7 +824,7 @@ const renderSafeReport = extraLines => {
765
824
  // 启动前环境诊断——针对「TUI 起不来」的故障域(装不上、update 后版本不
766
825
  // 同步、密钥没配),与 TUI 内 /doctor 的会话内诊断互补。零 lib 依赖、
767
826
  // 不委托、不自举:profile 残缺时它必须还能跑。密钥红线:只报告是否已
768
- // 设置,绝不输出值。仅 dsh 缺失记为硬失败(其余检查全部照常打印后再
827
+ // 设置,绝不输出值。Node 不兼容/无法判断或 dsh 缺失记为硬失败(其余检查照常打印后再
769
828
  // 以退出码 1 收束)。
770
829
  if (subcommand === 'doctor') {
771
830
  const { hardFailure, lines } = runDoctorChecks()
@@ -0,0 +1,111 @@
1
+ /** Official headless subprocess adapter. This directory alone owns DSH details. */
2
+ import { mkdtemp, writeFile, rm } from 'node:fs/promises'
3
+ import { constants as osConstants, tmpdir } from 'node:os'
4
+ import { join } from 'node:path'
5
+ import { fileURLToPath } from 'node:url'
6
+ import { CliError } from '../../protocol.mjs'
7
+ import { startProcess, records, parseRecord } from '../../process.mjs'
8
+ import { locateDsh } from './locate.mjs'
9
+
10
+ const manager = fileURLToPath(new URL('./management-plugin.mjs', import.meta.url))
11
+ const validated = new Set(['0.2.0-rc.2', '0.2.1-rc.2', '0.2.1-rc.3', '0.2.1-rc.4', '0.2.1-rc.5'])
12
+ const allowedEvents = new Set(['session', 'status', 'text', 'thinking', 'tool_call', 'tool_result', 'error', 'final'])
13
+
14
+ function requireContract(runtime) {
15
+ // A new version is not proof of wire compatibility. Passthrough is ungated.
16
+ if (!validated.has(runtime.version)) throw new CliError('ADAPTER_UNAVAILABLE', `This adapter validates DSH ${[...validated].join(', ')}; use dst dsh for another runtime`, 3)
17
+ }
18
+
19
+ /** Create the default adapter; host/process facilities are injectable in tests. */
20
+ export function createDshAdapter({ locate = locateDsh, start = startProcess, diagnostic = () => {} } = {}) {
21
+ async function* perform(request, { signal }) {
22
+ const runtime = locate(request)
23
+ requireContract(runtime)
24
+ signal.throwIfAborted()
25
+ let directory
26
+ let processRun
27
+ let pendingFailure
28
+ let completed = false
29
+ try {
30
+ directory = await mkdtemp(join(tmpdir(), 'dst-cli-'))
31
+ const patches = []
32
+ if (request.kind !== 'run') {
33
+ patches.push({ id: 'headless-startup', disabled: true }, { id: 'headless-runner', disabled: true })
34
+ patches.push({ insert: [{ id: 'dst-cli-management', name: manager, config: { request } }] })
35
+ } else if (request.model) {
36
+ patches.push({ id: 'agent-default-model', config: { provider: request.provider, model: request.model } })
37
+ }
38
+ const overlay = join(directory, 'cli.patch.json')
39
+ await writeFile(overlay, JSON.stringify(patches), { mode: 0o600 })
40
+ const args = [runtime.path, '--profile', request.profile]
41
+ for (const patch of request.patches) args.push('--patch', patch)
42
+ args.push('--patch', overlay, '--')
43
+ if (request.kind === 'run') {
44
+ args.push('--json')
45
+ if (request.sessionId) args.push('--session-id', request.sessionId)
46
+ args.push('-') // Prompt travels through stdin, never a command or process argv.
47
+ }
48
+ const env = { ...process.env }
49
+ if (request.permission) env.DSH_PERMISSION_MODE = request.permission
50
+ processRun = start({ command: process.execPath, args, cwd: request.cwd, env, input: request.kind === 'run' ? request.prompt : '' }, signal, diagnostic)
51
+ for await (const line of records(processRun.child.stdout)) {
52
+ const event = parseRecord(line)
53
+ if (request.kind === 'run') {
54
+ if (!allowedEvents.has(event.type)) throw new CliError('PROTOCOL_ERROR', 'Unsupported DSH headless event; adapter update required', 4)
55
+ } else if (event.schemaVersion !== 1 || !['final', 'error'].includes(event.type)) {
56
+ throw new CliError('PROTOCOL_ERROR', 'Management plugin protocol mismatch', 4)
57
+ }
58
+ if (event.type === 'status' && event.phase === 'turn_end') completed = event.reason?.kind === 'completed'
59
+ if (event.type === 'error') {
60
+ const code = ['SESSION_NOT_FOUND', 'PROVIDER_NOT_FOUND', 'CAPABILITY_UNAVAILABLE'].includes(event.code) ? event.code : 'TASK_FAILED'
61
+ pendingFailure = new CliError(code, 'DSH could not complete the requested operation', code === 'TASK_FAILED' ? 1 : 3)
62
+ yield { type: 'error', code, message: pendingFailure.message }
63
+ } else if (event.type === 'final') yield { ...event, ok: request.kind !== 'run' || completed }
64
+ else yield event
65
+ }
66
+ const exit = await processRun.settled
67
+ signal.throwIfAborted()
68
+ if (exit.drainFailed) throw new CliError('PROTOCOL_ERROR', 'Backend descendants did not release output pipes', 4)
69
+ if (exit.error) throw new CliError('ADAPTER_UNAVAILABLE', 'Unable to start the DSH process', 3)
70
+ if (exit.signal || exit.code !== 0) throw pendingFailure ?? new CliError('TASK_FAILED', `DSH exited unsuccessfully (${exit.code}); no operation was retried`, 1)
71
+ if (pendingFailure) throw pendingFailure
72
+ } finally {
73
+ if (processRun) {
74
+ processRun.stop()
75
+ await processRun.settled
76
+ }
77
+ if (directory) await rm(directory, { recursive: true, force: true })
78
+ }
79
+ }
80
+ return {
81
+ id: 'dsh-headless',
82
+ async capabilities(request) {
83
+ const runtime = locate(request)
84
+ return {
85
+ adapter: 'dsh-headless', runtimeVersion: runtime.version,
86
+ validated: validated.has(runtime.version),
87
+ operations: ['run', 'session.list', 'session.show', 'session.export', 'continue', 'models.list', 'skills.list', 'mcp.status', 'auth.status', 'dsh'],
88
+ output: ['text', 'json', 'stream-json'],
89
+ limits: { inputBytes: 8 * 1024 * 1024, recordBytes: 32 * 1024 * 1024 },
90
+ limitations: ['committed-message-stream-not-token-stream', 'official-headless-resume-restrictions', 'profile-not-tui-preferences', 'mcp-registered-tools-not-connection-health', 'no-credential-values-or-login', 'profile-code-is-trusted'],
91
+ }
92
+ },
93
+ execute: perform,
94
+ async continueSession(request, context) {
95
+ let id
96
+ for await (const event of perform({ ...request, kind: 'session', action: 'continue' }, context)) {
97
+ if (event.type === 'final') id = event.data?.sessionId
98
+ }
99
+ if (typeof id !== 'string' || !id) throw new CliError('SESSION_NOT_FOUND', 'No compatible session exists in this cwd', 3)
100
+ return id
101
+ },
102
+ async passthrough(request, { signal }) {
103
+ const runtime = locate(request)
104
+ const processRun = start({ command: process.execPath, args: [runtime.path, ...request.args], cwd: request.cwd, env: process.env, inherit: true }, signal)
105
+ const exit = await processRun.settled
106
+ signal.throwIfAborted()
107
+ if (exit.error) throw new CliError('ADAPTER_UNAVAILABLE', 'Unable to start DSH', 3)
108
+ return exit.signal ? 128 + (osConstants.signals[exit.signal] ?? 0) : exit.code
109
+ },
110
+ }
111
+ }
@@ -0,0 +1,73 @@
1
+ /** Resolve a built DSH JS bin without executing a shell or importing the TUI. */
2
+ import { accessSync, constants, existsSync, readFileSync, realpathSync, statSync } from 'node:fs'
3
+ import { basename, delimiter, dirname, join, resolve } from 'node:path'
4
+ import { CliError } from '../../protocol.mjs'
5
+
6
+ function fromPackage(dir) {
7
+ try {
8
+ const manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'))
9
+ if (manifest.name !== '@deepseek-ai/dsh') return undefined
10
+ const bin = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin?.dsh
11
+ if (typeof bin !== 'string') return undefined
12
+ const path = resolve(dir, bin)
13
+ if (!existsSync(path)) return undefined
14
+ return { path: realpathSync(path), version: manifest.version }
15
+ } catch { return undefined }
16
+ }
17
+
18
+ function above(path) {
19
+ for (let dir = dirname(path); ; dir = dirname(dir)) {
20
+ const found = fromPackage(dir)
21
+ if (found) return found
22
+ if (dirname(dir) === dir) return undefined
23
+ }
24
+ }
25
+
26
+ /** Explicit bin -> standalone install anchor -> first executable on PATH. */
27
+ export function locateDsh(request, env = process.env) {
28
+ const configured = request.dshBin ?? env.DSH_TUI_CLI_DSH_BIN
29
+ if (configured !== undefined) {
30
+ const path = resolve(request.cwd, configured)
31
+ if (!/\.[cm]?js$/iu.test(path) || !existsSync(path)) throw new CliError('ADAPTER_UNAVAILABLE', 'Explicit DSH bin must be an existing built JavaScript entry', 3)
32
+ const found = above(path)
33
+ if (!found) throw new CliError('ADAPTER_UNAVAILABLE', 'Explicit bin must belong to an installed @deepseek-ai/dsh package', 3)
34
+ return { ...found, path: realpathSync(path) }
35
+ }
36
+ if (env.DSH_TUI_CLI_INSTALL_ANCHOR) {
37
+ const found = fromPackage(env.DSH_TUI_CLI_INSTALL_ANCHOR)
38
+ if (found) return found
39
+ throw new CliError('ADAPTER_UNAVAILABLE', 'Standalone DSH installation is incomplete', 3)
40
+ }
41
+ const names = process.platform === 'win32' ? ['dsh.cmd', 'dsh.exe', 'dsh'] : ['dsh']
42
+ for (const dir of (env.PATH ?? env.Path ?? '').split(delimiter).filter(Boolean)) {
43
+ for (const name of names) {
44
+ const candidate = join(dir, name)
45
+ try { accessSync(candidate, process.platform === 'win32' ? constants.F_OK : constants.X_OK) } catch { continue }
46
+ const beside = fromPackage(join(dir, 'node_modules', '@deepseek-ai', 'dsh'))
47
+ if (beside) return beside
48
+ let real
49
+ try { real = realpathSync(candidate) } catch { break }
50
+ const direct = above(real)
51
+ if (direct) return direct
52
+ const size = statSync(real).size
53
+ const bytes = size < 65536 ? readFileSync(real) : Buffer.alloc(0)
54
+ if (size < 65536 && !bytes.subarray(0, 4096).includes(0)) {
55
+ const text = bytes.toString('utf8')
56
+ const tokens = /"([^"\r\n]+?\.[cm]?js)"|'([^'\r\n]+?\.[cm]?js)'|([^\s"'`;|&<>()]+\.[cm]?js)(?=[\s"';|&)]|$)/gmu
57
+ for (const match of text.matchAll(tokens)) {
58
+ const script = (match[1] ?? match[2] ?? match[3])
59
+ .replace(/^\$\{?basedir\}?/u, dirname(real))
60
+ .replace(/^%~dp0%?/iu, `${dirname(real)}\\`)
61
+ .replace(/^%dp0%/iu, dirname(real))
62
+ .replace(/^\$PSScriptRoot/iu, dirname(real))
63
+ if (/[$%]/u.test(script)) continue
64
+ const found = above(resolve(dirname(real), script))
65
+ if (found) return found
66
+ }
67
+ }
68
+ // Do not quietly launch a different installation than the first shim.
69
+ throw new CliError('ADAPTER_UNAVAILABLE', `Cannot resolve the first ${basename(candidate)} on PATH; use --dsh-bin`, 3)
70
+ }
71
+ }
72
+ throw new CliError('ADAPTER_UNAVAILABLE', 'DSH was not found on PATH; install the official CLI or pass --dsh-bin', 3)
73
+ }