@deepseek-harness-tui/dsh-tui 0.7.3 → 0.8.1

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 (371) hide show
  1. package/README.md +15 -7
  2. package/bin/dsh-tui.js +19 -3
  3. package/cordis.patch.yml +43 -11
  4. package/cordis.yml +20 -1
  5. package/ecosystem-spec/registry/contracts/decision-events-v1alpha1.json +13 -0
  6. package/ecosystem-spec/registry/host-descriptor.tui.example.json +56 -0
  7. package/ecosystem-spec/registry/permissions-0.1.json +13 -0
  8. package/ecosystem-spec/registry/registry-0.15.json +57 -0
  9. package/ecosystem-spec/schemas/conformance-claim.schema.json +15 -0
  10. package/ecosystem-spec/schemas/effect-ledger-record.schema.json +16 -0
  11. package/ecosystem-spec/schemas/host-descriptor.schema.json +26 -0
  12. package/lib/types/cc/figures.d.ts +4 -0
  13. package/lib/types/cc/figures.d.ts.map +1 -1
  14. package/lib/types/cc/figures.js +4 -0
  15. package/lib/types/commands.d.ts.map +1 -1
  16. package/lib/types/commands.js +4 -1
  17. package/lib/types/components/ExtensionDialog.d.ts +40 -0
  18. package/lib/types/components/ExtensionDialog.d.ts.map +1 -0
  19. package/lib/types/components/ExtensionDialog.js +210 -0
  20. package/lib/types/components/HelpMenu.js +1 -1
  21. package/lib/types/components/LoadedContextPanel.d.ts +5 -10
  22. package/lib/types/components/LoadedContextPanel.d.ts.map +1 -1
  23. package/lib/types/components/LoadedContextPanel.js +7 -18
  24. package/lib/types/components/LogoV2.d.ts.map +1 -1
  25. package/lib/types/components/LogoV2.js +1 -2
  26. package/lib/types/components/MessageList.d.ts +3 -1
  27. package/lib/types/components/MessageList.d.ts.map +1 -1
  28. package/lib/types/components/MessageList.js +29 -5
  29. package/lib/types/components/PluginSceneBoundary.d.ts +31 -0
  30. package/lib/types/components/PluginSceneBoundary.d.ts.map +1 -0
  31. package/lib/types/components/PluginSceneBoundary.js +29 -0
  32. package/lib/types/components/RewindPicker.d.ts +13 -1
  33. package/lib/types/components/RewindPicker.d.ts.map +1 -1
  34. package/lib/types/components/RewindPicker.js +26 -2
  35. package/lib/types/components/SkillsPicker.d.ts +18 -0
  36. package/lib/types/components/SkillsPicker.d.ts.map +1 -0
  37. package/lib/types/components/SkillsPicker.js +50 -0
  38. package/lib/types/components/SplitDiffView.d.ts +28 -0
  39. package/lib/types/components/SplitDiffView.d.ts.map +1 -0
  40. package/lib/types/components/SplitDiffView.js +417 -0
  41. package/lib/types/components/ToolUseLoader.d.ts +8 -3
  42. package/lib/types/components/ToolUseLoader.d.ts.map +1 -1
  43. package/lib/types/components/ToolUseLoader.js +43 -9
  44. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +3 -1
  45. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  46. package/lib/types/components/messages/AssistantToolUseMessage.js +17 -7
  47. package/lib/types/dsh-adapter/channel.d.ts +98 -7
  48. package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
  49. package/lib/types/dsh-adapter/channel.js +623 -26
  50. package/lib/types/dsh-adapter/command-attribution.d.ts +51 -0
  51. package/lib/types/dsh-adapter/command-attribution.d.ts.map +1 -0
  52. package/lib/types/dsh-adapter/command-attribution.js +93 -0
  53. package/lib/types/dsh-adapter/command-errors.d.ts +42 -0
  54. package/lib/types/dsh-adapter/command-errors.d.ts.map +1 -0
  55. package/lib/types/dsh-adapter/command-errors.js +63 -0
  56. package/lib/types/dsh-adapter/component-identity.d.ts +28 -0
  57. package/lib/types/dsh-adapter/component-identity.d.ts.map +1 -0
  58. package/lib/types/dsh-adapter/component-identity.js +108 -0
  59. package/lib/types/dsh-adapter/contract.d.ts +2 -2
  60. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  61. package/lib/types/dsh-adapter/contract.js +3 -2
  62. package/lib/types/dsh-adapter/decision-guard.d.ts +84 -0
  63. package/lib/types/dsh-adapter/decision-guard.d.ts.map +1 -0
  64. package/lib/types/dsh-adapter/decision-guard.js +354 -0
  65. package/lib/types/dsh-adapter/dialogs.d.ts +146 -0
  66. package/lib/types/dsh-adapter/dialogs.d.ts.map +1 -0
  67. package/lib/types/dsh-adapter/dialogs.js +262 -0
  68. package/lib/types/dsh-adapter/effect-ledger.d.ts +99 -0
  69. package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -0
  70. package/lib/types/dsh-adapter/effect-ledger.js +231 -0
  71. package/lib/types/dsh-adapter/extension-events.d.ts +193 -0
  72. package/lib/types/dsh-adapter/extension-events.d.ts.map +1 -0
  73. package/lib/types/dsh-adapter/extension-events.js +169 -0
  74. package/lib/types/dsh-adapter/extensions.d.ts +32 -0
  75. package/lib/types/dsh-adapter/extensions.d.ts.map +1 -0
  76. package/lib/types/dsh-adapter/extensions.js +42 -0
  77. package/lib/types/dsh-adapter/grants.d.ts +25 -0
  78. package/lib/types/dsh-adapter/grants.d.ts.map +1 -0
  79. package/lib/types/dsh-adapter/grants.js +184 -0
  80. package/lib/types/dsh-adapter/host-descriptor.d.ts +24 -0
  81. package/lib/types/dsh-adapter/host-descriptor.d.ts.map +1 -0
  82. package/lib/types/dsh-adapter/host-descriptor.js +146 -0
  83. package/lib/types/dsh-adapter/index.d.ts +4 -0
  84. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  85. package/lib/types/dsh-adapter/index.js +1 -0
  86. package/lib/types/dsh-adapter/message-observer.d.ts +178 -0
  87. package/lib/types/dsh-adapter/message-observer.d.ts.map +1 -0
  88. package/lib/types/dsh-adapter/message-observer.js +509 -0
  89. package/lib/types/dsh-adapter/plugin-host.d.ts +103 -0
  90. package/lib/types/dsh-adapter/plugin-host.d.ts.map +1 -0
  91. package/lib/types/dsh-adapter/plugin-host.js +270 -0
  92. package/lib/types/dsh-adapter/plugin-storage.d.ts +113 -0
  93. package/lib/types/dsh-adapter/plugin-storage.d.ts.map +1 -0
  94. package/lib/types/dsh-adapter/plugin-storage.js +385 -0
  95. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  96. package/lib/types/dsh-adapter/plugin.js +106 -1
  97. package/lib/types/dsh-adapter/plugins-info.d.ts +43 -0
  98. package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -0
  99. package/lib/types/dsh-adapter/plugins-info.js +276 -0
  100. package/lib/types/dsh-adapter/promptDebug.d.ts +10 -0
  101. package/lib/types/dsh-adapter/promptDebug.d.ts.map +1 -0
  102. package/lib/types/dsh-adapter/promptDebug.js +148 -0
  103. package/lib/types/dsh-adapter/renderers.d.ts +65 -0
  104. package/lib/types/dsh-adapter/renderers.d.ts.map +1 -0
  105. package/lib/types/dsh-adapter/renderers.js +138 -0
  106. package/lib/types/dsh-adapter/sanitize.d.ts +36 -0
  107. package/lib/types/dsh-adapter/sanitize.d.ts.map +1 -0
  108. package/lib/types/dsh-adapter/sanitize.js +65 -0
  109. package/lib/types/dsh-adapter/scenes.d.ts +81 -0
  110. package/lib/types/dsh-adapter/scenes.d.ts.map +1 -0
  111. package/lib/types/dsh-adapter/scenes.js +93 -0
  112. package/lib/types/dsh-adapter/settings-sections.d.ts +116 -0
  113. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -0
  114. package/lib/types/dsh-adapter/settings-sections.js +63 -0
  115. package/lib/types/dsh-adapter/settingsEditor.d.ts +128 -0
  116. package/lib/types/dsh-adapter/settingsEditor.d.ts.map +1 -0
  117. package/lib/types/dsh-adapter/settingsEditor.js +244 -0
  118. package/lib/types/dsh-adapter/shortcuts.d.ts +109 -0
  119. package/lib/types/dsh-adapter/shortcuts.d.ts.map +1 -0
  120. package/lib/types/dsh-adapter/shortcuts.js +268 -0
  121. package/lib/types/dsh-adapter/status.d.ts +75 -0
  122. package/lib/types/dsh-adapter/status.d.ts.map +1 -0
  123. package/lib/types/dsh-adapter/status.js +168 -0
  124. package/lib/types/extensions.d.ts +8 -0
  125. package/lib/types/extensions.d.ts.map +1 -0
  126. package/lib/types/extensions.js +15 -0
  127. package/lib/types/i18n.d.ts +299 -26
  128. package/lib/types/i18n.d.ts.map +1 -1
  129. package/lib/types/i18n.js +89 -8
  130. package/lib/types/ink/ink.d.ts +11 -0
  131. package/lib/types/ink/ink.d.ts.map +1 -1
  132. package/lib/types/ink/ink.js +33 -0
  133. package/lib/types/ink/log-update.d.ts.map +1 -1
  134. package/lib/types/ink/log-update.js +101 -51
  135. package/lib/types/ink/output.d.ts +7 -0
  136. package/lib/types/ink/output.d.ts.map +1 -1
  137. package/lib/types/ink/output.js +125 -4
  138. package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
  139. package/lib/types/ink/render-node-to-output.js +14 -6
  140. package/lib/types/ink/terminal.d.ts.map +1 -1
  141. package/lib/types/ink/terminal.js +18 -6
  142. package/lib/types/jsx-runtime.d.ts +2 -0
  143. package/lib/types/jsx-runtime.d.ts.map +1 -0
  144. package/lib/types/jsx-runtime.js +13 -0
  145. package/lib/types/modelRoute.d.ts +10 -2
  146. package/lib/types/modelRoute.d.ts.map +1 -1
  147. package/lib/types/modelRoute.js +33 -4
  148. package/lib/types/plugin-host.d.ts +13 -0
  149. package/lib/types/plugin-host.d.ts.map +1 -0
  150. package/lib/types/plugin-host.js +17 -0
  151. package/lib/types/plugin-spec/negotiate.d.ts +11 -0
  152. package/lib/types/plugin-spec/negotiate.d.ts.map +1 -0
  153. package/lib/types/plugin-spec/negotiate.js +97 -0
  154. package/lib/types/plugin-spec/permission-scope.d.ts +32 -0
  155. package/lib/types/plugin-spec/permission-scope.d.ts.map +1 -0
  156. package/lib/types/plugin-spec/permission-scope.js +90 -0
  157. package/lib/types/plugin-spec/registry.d.ts +23 -0
  158. package/lib/types/plugin-spec/registry.d.ts.map +1 -0
  159. package/lib/types/plugin-spec/registry.js +157 -0
  160. package/lib/types/plugin-spec/schema-check.d.ts +17 -0
  161. package/lib/types/plugin-spec/schema-check.d.ts.map +1 -0
  162. package/lib/types/plugin-spec/schema-check.js +165 -0
  163. package/lib/types/plugin-spec/tui-extension.d.ts +16 -0
  164. package/lib/types/plugin-spec/tui-extension.d.ts.map +1 -0
  165. package/lib/types/plugin-spec/tui-extension.js +77 -0
  166. package/lib/types/plugin-spec/types.d.ts +114 -0
  167. package/lib/types/plugin-spec/types.d.ts.map +1 -0
  168. package/lib/types/plugin-spec/types.js +10 -0
  169. package/lib/types/plugin-spec/validate.d.ts +21 -0
  170. package/lib/types/plugin-spec/validate.d.ts.map +1 -0
  171. package/lib/types/plugin-spec/validate.js +119 -0
  172. package/lib/types/scenes.d.ts +3 -0
  173. package/lib/types/scenes.d.ts.map +1 -0
  174. package/lib/types/scenes.js +4 -0
  175. package/lib/types/screens/Chat.d.ts +14 -1
  176. package/lib/types/screens/Chat.d.ts.map +1 -1
  177. package/lib/types/screens/Chat.js +247 -48
  178. package/lib/types/screens/Settings.d.ts +20 -0
  179. package/lib/types/screens/Settings.d.ts.map +1 -0
  180. package/lib/types/screens/Settings.js +333 -0
  181. package/lib/types/screens/StatusLine.js +1 -1
  182. package/lib/types/settings-sections.d.ts +3 -0
  183. package/lib/types/settings-sections.d.ts.map +1 -0
  184. package/lib/types/settings-sections.js +4 -0
  185. package/lib/types/theme.d.ts +17 -0
  186. package/lib/types/theme.d.ts.map +1 -1
  187. package/lib/types/theme.js +51 -0
  188. package/lib/types/update.d.ts +20 -0
  189. package/lib/types/update.d.ts.map +1 -1
  190. package/lib/types/update.js +54 -7
  191. package/lib/types/utils/loaded-context.d.ts +8 -3
  192. package/lib/types/utils/loaded-context.d.ts.map +1 -1
  193. package/lib/types/utils/loaded-context.js +39 -3
  194. package/lib/types/utils/modifiers.d.ts.map +1 -1
  195. package/lib/types/utils/modifiers.js +3 -2
  196. package/lib/types/working-activity.d.ts +12 -0
  197. package/lib/types/working-activity.d.ts.map +1 -1
  198. package/lib/types/working-activity.js +13 -0
  199. package/node_modules/@dsh-std/command/LICENSE +21 -0
  200. package/node_modules/@dsh-std/command/README.md +26 -0
  201. package/node_modules/@dsh-std/command/README.zh.md +28 -0
  202. package/node_modules/@dsh-std/command/lib/index.d.ts +144 -0
  203. package/node_modules/@dsh-std/command/lib/index.d.ts.map +1 -0
  204. package/node_modules/@dsh-std/command/lib/index.js +252 -0
  205. package/node_modules/@dsh-std/command/lib/index.js.map +1 -0
  206. package/node_modules/@dsh-std/command/package.json +22 -0
  207. package/node_modules/@dsh-std/connection/LICENSE +21 -0
  208. package/node_modules/@dsh-std/connection/README.md +42 -0
  209. package/node_modules/@dsh-std/connection/README.zh.md +42 -0
  210. package/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
  211. package/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
  212. package/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
  213. package/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
  214. package/node_modules/@dsh-std/connection/lib/index.js +158 -0
  215. package/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
  216. package/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
  217. package/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
  218. package/node_modules/@dsh-std/connection/lib/memory.js +257 -0
  219. package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
  220. package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
  221. package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
  222. package/node_modules/@dsh-std/connection/package.json +20 -0
  223. package/node_modules/@dsh-std/core/LICENSE +21 -0
  224. package/node_modules/@dsh-std/core/README.md +13 -0
  225. package/node_modules/@dsh-std/core/README.zh.md +13 -0
  226. package/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  227. package/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  228. package/node_modules/@dsh-std/core/lib/index.js +424 -0
  229. package/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  230. package/node_modules/@dsh-std/core/package.json +21 -0
  231. package/node_modules/@dsh-std/manifest/LICENSE +21 -0
  232. package/node_modules/@dsh-std/manifest/README.md +5 -0
  233. package/node_modules/@dsh-std/manifest/README.zh.md +5 -0
  234. package/node_modules/@dsh-std/manifest/lib/index.d.ts +182 -0
  235. package/node_modules/@dsh-std/manifest/lib/index.d.ts.map +1 -0
  236. package/node_modules/@dsh-std/manifest/lib/index.js +625 -0
  237. package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -0
  238. package/node_modules/@dsh-std/manifest/package.json +20 -0
  239. package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -0
  240. package/node_modules/@dsh-std/messages/LICENSE +21 -0
  241. package/node_modules/@dsh-std/messages/README.md +5 -0
  242. package/node_modules/@dsh-std/messages/README.zh.md +7 -0
  243. package/node_modules/@dsh-std/messages/lib/index.d.ts +50 -0
  244. package/node_modules/@dsh-std/messages/lib/index.d.ts.map +1 -0
  245. package/node_modules/@dsh-std/messages/lib/index.js +151 -0
  246. package/node_modules/@dsh-std/messages/lib/index.js.map +1 -0
  247. package/node_modules/@dsh-std/messages/package.json +20 -0
  248. package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -0
  249. package/node_modules/@dsh-std/presentation/LICENSE +21 -0
  250. package/node_modules/@dsh-std/presentation/README.md +26 -0
  251. package/node_modules/@dsh-std/presentation/README.zh.md +28 -0
  252. package/node_modules/@dsh-std/presentation/lib/index.d.ts +219 -0
  253. package/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -0
  254. package/node_modules/@dsh-std/presentation/lib/index.js +547 -0
  255. package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -0
  256. package/node_modules/@dsh-std/presentation/lib/interaction.d.ts +2 -0
  257. package/node_modules/@dsh-std/presentation/lib/interaction.js +2 -0
  258. package/node_modules/@dsh-std/presentation/lib/operations.d.ts +2 -0
  259. package/node_modules/@dsh-std/presentation/lib/operations.js +2 -0
  260. package/node_modules/@dsh-std/presentation/package.json +21 -0
  261. package/node_modules/@dsh-std/storage/LICENSE +21 -0
  262. package/node_modules/@dsh-std/storage/README.md +5 -0
  263. package/node_modules/@dsh-std/storage/README.zh.md +7 -0
  264. package/node_modules/@dsh-std/storage/lib/index.d.ts +48 -0
  265. package/node_modules/@dsh-std/storage/lib/index.d.ts.map +1 -0
  266. package/node_modules/@dsh-std/storage/lib/index.js +104 -0
  267. package/node_modules/@dsh-std/storage/lib/index.js.map +1 -0
  268. package/node_modules/@dsh-std/storage/package.json +20 -0
  269. package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -0
  270. package/package.json +118 -67
  271. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -0
  272. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -0
  273. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -0
  274. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
  275. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
  276. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
  277. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
  278. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js +158 -0
  279. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
  280. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
  281. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
  282. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js +257 -0
  283. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
  284. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
  285. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
  286. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -0
  287. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -0
  288. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -0
  289. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -0
  290. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  291. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  292. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js +424 -0
  293. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  294. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -0
  295. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -0
  296. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -0
  297. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -0
  298. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.d.ts +182 -0
  299. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.d.ts.map +1 -0
  300. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js +625 -0
  301. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -0
  302. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -0
  303. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -0
  304. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -0
  305. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +26 -0
  306. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +28 -0
  307. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts +219 -0
  308. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -0
  309. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js +547 -0
  310. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -0
  311. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/interaction.d.ts +2 -0
  312. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/interaction.js +2 -0
  313. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/operations.d.ts +2 -0
  314. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/operations.js +2 -0
  315. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +21 -0
  316. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -0
  317. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -0
  318. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -0
  319. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  320. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  321. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js +424 -0
  322. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  323. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -0
  324. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -0
  325. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -0
  326. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -0
  327. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  328. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  329. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js +424 -0
  330. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  331. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -0
  332. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -0
  333. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -0
  334. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -0
  335. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  336. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  337. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js +424 -0
  338. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  339. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -0
  340. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -0
  341. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -0
  342. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -0
  343. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
  344. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
  345. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
  346. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
  347. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js +158 -0
  348. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
  349. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
  350. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
  351. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js +257 -0
  352. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
  353. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
  354. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
  355. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -0
  356. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -0
  357. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -0
  358. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -0
  359. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  360. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  361. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js +424 -0
  362. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  363. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -0
  364. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -0
  365. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -0
  366. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -0
  367. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  368. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  369. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js +424 -0
  370. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  371. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +21 -0
@@ -0,0 +1,354 @@
1
+ /**
2
+ * RFC 0005 D-7 enforcement: subscribing to an intercept-class (decision)
3
+ * event requires an explicit host-side grant — default deny.
4
+ *
5
+ * Interception is strictly more powerful than observation: a plugin that can
6
+ * veto user input or a session switch can change what the user's intent
7
+ * actually does. So `tui/input`, `tui/rewind-prompt`, `tui/session-switch`
8
+ * and `tui/compact` are NOT free-for-all `ctx.on` targets: the subscribing
9
+ * plugin (identified by its verified Component identity) must hold the
10
+ * matching `domain.resource.intercept` grant. Grant answers
11
+ * come from the unified 8-permission GrantStore in ./grants.js (registry-
12
+ * driven defaults, `grants`/`denies` sections, corrupt fail-closed) — this
13
+ * module is only the subscribe-time CHECKPOINT: which event needs which
14
+ * permission, and the cordis bail hook that enforces it.
15
+ *
16
+ * A denied subscription never enters the dispatch chain — it is "as if
17
+ * unregistered" (D-7) and the caller gets a no-op disposer plus a logger
18
+ * warning naming the plugin, the event, and the missing grant.
19
+ *
20
+ * Re-check semantics (D-7: subscription, revocation, scope change): every
21
+ * operation reads the live GrantStore and grant-owned registrations are
22
+ * released when its change watcher observes a revocation.
23
+ *
24
+ * Mechanism: cordis bails `internal/listener` on EVERY `ctx.on` before
25
+ * registering, with `this` bound to the subscribing context; a truthy bail
26
+ * result skips the registration and becomes the caller's disposer. That is
27
+ * the whole hook — no patching of the events service.
28
+ */
29
+ import { EXTENSION_GRANTS_FILE, parseGrantStore, readGrantStore, } from './grants.js';
30
+ import { componentIdentityOf, requiresDecisionEvents, } from './component-identity.js';
31
+ import { INTERCEPT_EVENT_SCOPE_BY_PERMISSION, normalizePermissionScope, permissionScopeCovers, } from '../plugin-spec/permission-scope.js';
32
+ import { TUI_DECISION_EVENT_NAMES } from '../plugin-spec/tui-extension.js';
33
+ /** The intercept permission each decision event requires (D-7 naming:
34
+ * `domain.resource.intercept`). Observe-class events (tui/rewind-done,
35
+ * tui/session-switched) are deliberately absent. */
36
+ export const DECISION_EVENT_PERMISSIONS = {
37
+ 'tui/input': 'session.input.intercept',
38
+ 'tui/rewind-prompt': 'session.rewind.intercept',
39
+ 'tui/session-switch': 'session.switch.intercept',
40
+ 'tui/compact': 'session.compact.intercept',
41
+ };
42
+ // ── Compatibility aliases (pre-GrantStore names) ────────────────────────────
43
+ // The grant-file format and these entry points predate the unified store;
44
+ // keep them working — verify batteries and any embedder code import them
45
+ // from this module.
46
+ export { EXTENSION_GRANTS_FILE };
47
+ /** @deprecated Use parseGrantStore from ./grants.js. */
48
+ export const parseExtensionGrants = parseGrantStore;
49
+ /** @deprecated Use readGrantStore from ./grants.js. */
50
+ export const readExtensionGrants = readGrantStore;
51
+ /**
52
+ * Install the D-7 gate: every subscription to a decision event is checked
53
+ * against `grants` at subscribe time. Registered with `global` so context
54
+ * filtering can never hide a plugin's subscription from the gate, and
55
+ * `prepend` so it decides before any later internal/listener hook.
56
+ *
57
+ * Idempotent per cordis root: BOTH the extensions row and createChannel
58
+ * call this — the channel is the dispatch path, so a stale patch without
59
+ * the extensions row (or a bare embed mounting neither) must not leave
60
+ * decision events subscribable-by-default. The first installer wins; both
61
+ * production call sites read the same host-owned grants file, so which one
62
+ * lands first is unobservable.
63
+ */
64
+ const guardedRoots = new WeakSet();
65
+ const handlerMetadata = new WeakMap();
66
+ const registries = new WeakMap();
67
+ function rootKey(ctx) {
68
+ const root = ctx.root;
69
+ if (typeof root === 'object' && root !== null)
70
+ return root;
71
+ return ctx;
72
+ }
73
+ function registryFor(ctx, grants) {
74
+ const key = rootKey(ctx);
75
+ let registry = registries.get(key);
76
+ if (registry === undefined) {
77
+ registry = { grants: grants ?? readGrantStore(), handlers: new Map() };
78
+ registries.set(key, registry);
79
+ }
80
+ else if (grants !== undefined) {
81
+ registry.grants = grants;
82
+ }
83
+ return registry;
84
+ }
85
+ export function decisionRegistryOf(ctx) {
86
+ return registryFor(ctx);
87
+ }
88
+ /** Return a stable snapshot of handlers for one event and payload scope. */
89
+ export function decisionHandlersOf(ctx, event, payloadScope) {
90
+ const rows = [...(registryFor(ctx).handlers.get(event)?.values() ?? [])];
91
+ const permission = eventPermission(event);
92
+ const scopePermission = permission ?? 'messages.observe.read';
93
+ const actual = typeof payloadScope === 'string'
94
+ ? normalizePermissionScope(scopePermission, payloadScope, 'host')
95
+ : undefined;
96
+ return rows
97
+ .filter(row => {
98
+ const declared = normalizeDecisionScope(event, row.scope, 'host');
99
+ // A session-scoped handler cannot be safely applied when the host did
100
+ // not provide a session scope. Treat the missing scope as an
101
+ // unmatchable request instead of turning a narrow grant into a global
102
+ // one. Event-point scopes remain applicable because they deliberately
103
+ // cover every session.
104
+ if (actual === undefined)
105
+ return declared?.kind === 'event';
106
+ // An event-name scope (for example `tui/input`) selects the Decision
107
+ // Events point, not one session. It therefore applies to every payload
108
+ // session; only session-kind scopes participate in session filtering.
109
+ return declared?.kind === 'event' && declared.value === event
110
+ || (declared !== undefined && permissionScopeCovers(scopePermission, declared, actual));
111
+ })
112
+ .sort((left, right) => {
113
+ const order = compareStableText(left.order, right.order);
114
+ if (order !== 0)
115
+ return order;
116
+ const component = compareStableText(left.componentId, right.componentId);
117
+ if (component !== 0)
118
+ return component;
119
+ return compareStableText(left.activationId, right.activationId);
120
+ });
121
+ }
122
+ function eventPermission(event) {
123
+ return DECISION_EVENT_PERMISSIONS[event];
124
+ }
125
+ /** Normalize a handler scope against its actual event point. Notification
126
+ * points have no intercept permission, but still support event/session scopes
127
+ * for deterministic delivery filtering. */
128
+ function normalizeDecisionScope(event, scope, componentId) {
129
+ const permission = eventPermission(event);
130
+ if (permission !== undefined)
131
+ return normalizePermissionScope(permission, scope, componentId);
132
+ if (scope === event)
133
+ return { kind: 'event', value: event };
134
+ return normalizePermissionScope('messages.observe.read', scope, componentId);
135
+ }
136
+ /** Pick a scope for a legacy-looking `ctx.on(event, listener)` call without
137
+ * widening a concrete declaration. */
138
+ function defaultDecisionScope(identity, event) {
139
+ const permission = eventPermission(event);
140
+ if (permission === undefined)
141
+ return event;
142
+ const expectedEvent = INTERCEPT_EVENT_SCOPE_BY_PERMISSION[permission];
143
+ const requests = identity.manifest.permissions.filter(request => request.name === permission);
144
+ if (requests.some(request => request.scope === expectedEvent))
145
+ return expectedEvent;
146
+ if (requests.some(request => {
147
+ const normalized = normalizePermissionScope(permission, request.scope, identity.componentId);
148
+ return normalized?.kind === 'session' && normalized.value === 'session:*';
149
+ }))
150
+ return 'session:*';
151
+ // A concrete session grant cannot safely be inferred for a context-level
152
+ // listener. The caller must pass that scope explicitly through the mediated
153
+ // API, otherwise registration is refused.
154
+ return undefined;
155
+ }
156
+ /** Host-only registration used by TuiPluginHostRuntime. */
157
+ export function registerDecisionHandler(pluginCtx, identity, event, listener, options = {}, onRelease) {
158
+ if (componentIdentityOf(pluginCtx) !== identity) {
159
+ throw new Error('DecisionEvents registration identity is not bound to the calling activation');
160
+ }
161
+ if (!requiresDecisionEvents(identity)) {
162
+ throw new Error('DecisionEvents registration requires tui.dsh/v1alpha1#DecisionEvents');
163
+ }
164
+ if (!TUI_DECISION_EVENT_NAMES.includes(event)) {
165
+ throw new TypeError(`unknown TUI DecisionEvents point: ${event}`);
166
+ }
167
+ if (typeof listener !== 'function')
168
+ throw new TypeError('DecisionEvents handler must be a function');
169
+ const scope = options.scope ?? defaultDecisionScope(identity, event);
170
+ if (scope === undefined) {
171
+ throw new Error(`DecisionEvents scope for ${event} must be explicit when the manifest only declares a concrete session scope`);
172
+ }
173
+ const normalizedScope = normalizeDecisionScope(event, scope, identity.componentId);
174
+ if (normalizedScope === undefined)
175
+ throw new TypeError(`DecisionEvents scope is not enforceable: ${scope}`);
176
+ const permission = eventPermission(event);
177
+ const staticallyDeclared = permission === undefined
178
+ ? normalizedScope.kind === 'event' && normalizedScope.value === event
179
+ : identity.manifest.permissions.some(request => {
180
+ if (request.name !== permission)
181
+ return false;
182
+ const declared = normalizePermissionScope(permission, request.scope, identity.componentId);
183
+ return declared !== undefined && permissionScopeCovers(permission, declared, normalizedScope);
184
+ });
185
+ if (!staticallyDeclared) {
186
+ throw new Error(`DecisionEvents permission ${permission}@${scope} is not statically declared by ${identity.componentId}`);
187
+ }
188
+ const registry = registryFor(pluginCtx);
189
+ const principal = { componentId: identity.componentId, activationId: identity.activationId };
190
+ const currentlyGranted = permission === undefined || registry.grants.allows(principal, permission, scope);
191
+ if (!currentlyGranted) {
192
+ try {
193
+ pluginCtx.logger.warn(`dsh-tui: ${event} registration denied for Component "${identity.componentId}" — grant ${permission}@${scope} is missing`);
194
+ }
195
+ catch { /* best effort */ }
196
+ return () => false;
197
+ }
198
+ const order = options.order ?? identity.componentId;
199
+ if (order === '' || /[\x00-\x1f\x7f-\x9f]/u.test(order)) {
200
+ throw new TypeError('DecisionEvents order must be a non-empty control-free string');
201
+ }
202
+ const key = `${identity.activationId}\0${event}\0${order}`;
203
+ const byActivation = registry.handlers.get(event) ?? new Map();
204
+ if (byActivation.has(key))
205
+ throw new Error(`DecisionEvents order is already registered for this activation/event: ${event}@${order}`);
206
+ const row = Object.freeze({
207
+ event,
208
+ scope,
209
+ componentId: identity.componentId,
210
+ activationId: identity.activationId,
211
+ order,
212
+ identity,
213
+ ownerContext: pluginCtx,
214
+ listener,
215
+ });
216
+ byActivation.set(key, row);
217
+ handlerMetadata.set(listener, {
218
+ componentId: identity.componentId,
219
+ activationId: identity.activationId,
220
+ event,
221
+ order,
222
+ });
223
+ registry.handlers.set(event, byActivation);
224
+ let closed = false;
225
+ let stopGrantWatch;
226
+ const release = () => {
227
+ if (closed)
228
+ return false;
229
+ closed = true;
230
+ stopGrantWatch?.();
231
+ stopGrantWatch = undefined;
232
+ if (byActivation.get(key) === row)
233
+ byActivation.delete(key);
234
+ if (handlerMetadata.get(listener)?.activationId === identity.activationId
235
+ && handlerMetadata.get(listener)?.event === event
236
+ && handlerMetadata.get(listener)?.order === order)
237
+ handlerMetadata.delete(listener);
238
+ try {
239
+ onRelease?.();
240
+ }
241
+ catch {
242
+ // The registry has already released the effect. Observability failures
243
+ // must not turn a revoke/deactivate cleanup into a leaked handler.
244
+ }
245
+ return true;
246
+ };
247
+ // Both deactivation and grant-file revocation are release boundaries.
248
+ try {
249
+ pluginCtx.effect(() => release);
250
+ }
251
+ catch { /* degraded test context */ }
252
+ if (permission !== undefined) {
253
+ const stop = registry.grants.onChange?.(() => {
254
+ const principal = { componentId: identity.componentId, activationId: identity.activationId };
255
+ if (!registry.grants.allows(principal, permission, scope))
256
+ release();
257
+ });
258
+ stopGrantWatch = stop;
259
+ if (stop !== undefined) {
260
+ try {
261
+ pluginCtx.effect(() => stop);
262
+ }
263
+ catch { /* degraded test context */ }
264
+ }
265
+ }
266
+ return release;
267
+ }
268
+ /** Locale-independent comparator for the declared decision order policy.
269
+ * `localeCompare()` can vary with host ICU settings, which would make the
270
+ * winner depend on the machine running the same admitted component set. */
271
+ function compareStableText(left, right) {
272
+ return left < right ? -1 : left > right ? 1 : 0;
273
+ }
274
+ function fiberKey(ctx) {
275
+ try {
276
+ const fiber = ctx.fiber;
277
+ return typeof fiber === 'object' && fiber !== null ? fiber : undefined;
278
+ }
279
+ catch {
280
+ return undefined;
281
+ }
282
+ }
283
+ /** Execute ctx.on for one host-mediated decision registration. */
284
+ export function withDecisionRegistration(ctx, callback) {
285
+ const fiber = fiberKey(ctx);
286
+ if (fiber === undefined)
287
+ throw new Error('decision registration requires a Cordis activation');
288
+ return callback();
289
+ }
290
+ export function decisionHandlerMetadataOf(listener) {
291
+ return handlerMetadata.get(listener);
292
+ }
293
+ export function installDecisionGuard(ctx, grants) {
294
+ // Degraded/fake contexts (minimal embedders, test harnesses) may lack
295
+ // `root` or `on` entirely — the gate is best-effort there, matching the
296
+ // channel's soft-degradation posture: no dedup bookkeeping without a root
297
+ // object, no hook without an `on`.
298
+ const root = ctx.root ?? ctx;
299
+ // Keep the live grant source even when another row installed the Cordis
300
+ // hook first. The file-backed GrantStore evaluates each operation again.
301
+ registryFor(ctx, grants);
302
+ if (typeof root === 'object' && root !== null) {
303
+ if (guardedRoots.has(root))
304
+ return;
305
+ guardedRoots.add(root);
306
+ }
307
+ if (typeof ctx.on !== 'function')
308
+ return;
309
+ ctx.on('internal/listener', function (name, listener) {
310
+ if (typeof name !== 'string')
311
+ return undefined;
312
+ const permission = DECISION_EVENT_PERMISSIONS[name];
313
+ if (permission === undefined && !TUI_DECISION_EVENT_NAMES.includes(name))
314
+ return undefined;
315
+ // `this` is the SUBSCRIBING context (cordis binds internal/listener
316
+ // hooks to it). A fiber name is used below only for a refusal diagnostic;
317
+ // authorization always comes from the verified Component identity.
318
+ let pluginName = 'root';
319
+ try {
320
+ const resolved = this.fiber?.name;
321
+ if (typeof resolved === 'string' && resolved !== '')
322
+ pluginName = resolved;
323
+ }
324
+ catch {
325
+ // A degraded context without fiber access: fall back to 'root'.
326
+ }
327
+ const identity = componentIdentityOf(this);
328
+ // The public Cordis surface remains usable, but it is mediated into the
329
+ // same registry as subscribeDecision: a verified Component, static
330
+ // DecisionEvents requirement, normalized scope and live grant are all
331
+ // required before the raw listener is ever visible to dispatch. Cordis
332
+ // treats a truthy internal/listener result as a bail/disposer, so returning
333
+ // the registry release function prevents a second unmediated registration.
334
+ if (identity !== undefined && typeof listener === 'function') {
335
+ try {
336
+ return registerDecisionHandler(this, identity, name, listener, {});
337
+ }
338
+ catch (error) {
339
+ try {
340
+ this.logger.warn(`dsh-tui: ${name} subscription from Component "${identity.componentId}" denied — ` +
341
+ `${error instanceof Error ? error.message : String(error)}`);
342
+ }
343
+ catch { /* best effort */ }
344
+ return () => false;
345
+ }
346
+ }
347
+ const requiredGrant = permission === undefined ? '' : `; required grant ${permission}`;
348
+ ctx.logger.warn(`dsh-tui: ${name} direct subscription from Component "${pluginName}" denied${requiredGrant} — ` +
349
+ 'use the mediated DecisionEvents activation surface; the listener was NOT registered');
350
+ // Truthy bail result: cordis skips the registration and hands this back
351
+ // as the caller's disposer — a no-op keeps the ctx.on contract intact.
352
+ return () => false;
353
+ }, { global: true, prepend: true });
354
+ }
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Managed plugin dialogs — the pi `ctx.ui.select/confirm/input` seam for
3
+ * dsh-TUI. Plugins hand the HOST a declarative request; the TUI renders the
4
+ * dialog in its own chrome (next to the approval panel), owns the keyboard,
5
+ * and settles the plugin's promise with the user's answer. Plugins never
6
+ * touch the TTY themselves.
7
+ *
8
+ * Split in two, mirroring QuestionStore/ApprovalStore:
9
+ *
10
+ * - {@link TuiDialogStore} — cordis-free queue + snapshot. The chat screen
11
+ * subscribes to it and renders the current dialog; tests can drive it
12
+ * without a cordis context.
13
+ * - {@link TuiDialogRuntime} — the cordis service (`ctx.tuiDialogs`)
14
+ * plugins call. Validation of untrusted request data lives here.
15
+ *
16
+ * Queue semantics mirror the approval store: parallel plugin calls park
17
+ * FIFO and surface one at a time. A request settles exactly once — user
18
+ * answer, Esc cancel, caller AbortSignal, caller timeout, or service
19
+ * teardown (`cancelled` outcomes map to `undefined`/`false` returns).
20
+ */
21
+ import { Context, Service } from '@deepseek-ai/cordis';
22
+ /** Option of a select dialog. `id` is what the promise resolves with. */
23
+ export interface TuiDialogSelectOption {
24
+ id: string;
25
+ label: string;
26
+ description?: string;
27
+ }
28
+ /** What the chat screen renders while a dialog is pending. */
29
+ export type TuiDialogSnapshot = {
30
+ readonly key: string;
31
+ readonly kind: 'select';
32
+ readonly title: string;
33
+ readonly options: readonly TuiDialogSelectOption[];
34
+ } | {
35
+ readonly key: string;
36
+ readonly kind: 'confirm';
37
+ readonly title: string;
38
+ readonly message?: string;
39
+ readonly confirmLabel: string;
40
+ readonly cancelLabel: string;
41
+ } | {
42
+ readonly key: string;
43
+ readonly kind: 'input';
44
+ readonly title: string;
45
+ readonly placeholder?: string;
46
+ readonly initial: string;
47
+ };
48
+ /** Common request options. */
49
+ export interface TuiDialogBase {
50
+ /** Dialog title (rendered bold). Control chars are stripped. */
51
+ title: string;
52
+ /** Cancels the request when fired — the pi `signal` option. */
53
+ signal?: AbortSignal;
54
+ /** Auto-cancel after this many ms. Guards against a wedged flow when no
55
+ * TUI consumer is present (headless embedders). */
56
+ timeoutMs?: number;
57
+ }
58
+ export interface TuiDialogSelectRequest extends TuiDialogBase {
59
+ options: readonly TuiDialogSelectOption[];
60
+ }
61
+ export interface TuiDialogConfirmRequest extends TuiDialogBase {
62
+ message?: string;
63
+ /** Empty/absent labels fall back to the host's localized defaults. */
64
+ confirmLabel?: string;
65
+ cancelLabel?: string;
66
+ }
67
+ export interface TuiDialogInputRequest extends TuiDialogBase {
68
+ placeholder?: string;
69
+ initial?: string;
70
+ }
71
+ /** Settled value of the active dialog: the select id, the confirm boolean,
72
+ * or the input text. `undefined` means cancelled. */
73
+ export type TuiDialogAnswer = string | boolean | undefined;
74
+ /** Distributive Omit: `Omit` over a union collapses to the shared members
75
+ * only, which would strip kind-specific fields from the ask() input. */
76
+ type WithoutKey<T> = T extends unknown ? Omit<T, 'key'> : never;
77
+ /** The documented bound of the resolved input text; the panel enforces it
78
+ * on every edit path (typing AND paste) so the promise never resolves with
79
+ * a larger value. */
80
+ export declare const INPUT_CELLS = 500;
81
+ /** Bound a request that omits both signal and timeout. */
82
+ export declare const DIALOG_DEFAULT_TIMEOUT_MS = 30000;
83
+ /**
84
+ * Cordis-free dialog queue. `ask` parks a request; the UI drains one at a
85
+ * time via the snapshot and settles through {@link decide}/{@link cancel}.
86
+ */
87
+ export declare class TuiDialogStore {
88
+ private readonly listeners;
89
+ private readonly queue;
90
+ private active;
91
+ /** Park a request. The snapshot argument must already be sanitized. */
92
+ ask(snapshot: WithoutKey<TuiDialogSnapshot>, signal?: AbortSignal, timeoutMs?: number, owner?: Context): Promise<TuiDialogAnswer>;
93
+ /** The dialog the UI should render right now, if any. */
94
+ getSnapshot(): TuiDialogSnapshot | null;
95
+ /**
96
+ * Settle the active dialog with the user's answer. The caller passes the
97
+ * key of the snapshot IT rendered; a mismatched key is a stale callback
98
+ * and ignored. This is not paranoia: ConPTY can deliver one Enter as a
99
+ * same-batch CR+LF pair, firing the old panel's handler twice before
100
+ * React unmounts it — an unkeyed decide would settle the active dialog
101
+ * AND the successor the first call just promoted (one Enter answering two
102
+ * consecutive dialogs).
103
+ */
104
+ decide(key: string, value: TuiDialogAnswer): void;
105
+ /** Cancel the active dialog (Esc). Keyed like {@link decide}: a stale
106
+ * panel's Esc must not close the successor it never rendered. */
107
+ cancel(key: string): void;
108
+ /** Settle everything queued + active (teardown): all resolve cancelled. */
109
+ settleAll(): void;
110
+ subscribe(listener: () => void): () => void;
111
+ private advance;
112
+ private emit;
113
+ }
114
+ declare module '@deepseek-ai/cordis' {
115
+ interface Context {
116
+ tuiDialogs: TuiDialogRuntime;
117
+ }
118
+ }
119
+ /**
120
+ * `ctx.tuiDialogs` — plugin-facing managed dialogs. Every method validates
121
+ * its request (untrusted data on the render path) and resolves with the
122
+ * cancelled value (`undefined`/`false`) rather than throwing when the
123
+ * request is malformed — a dialog must never take the plugin or the TUI
124
+ * down; callers get a logger warning instead.
125
+ */
126
+ export declare class TuiDialogRuntime extends Service {
127
+ /** The queue the chat screen renders. Exposed for the host, not plugins. */
128
+ readonly store: TuiDialogStore;
129
+ constructor(ctx: Context);
130
+ /** Cordis traceable services normally provide the caller through `this.ctx`;
131
+ * the explicit overloads below make ownership unambiguous for embedders and
132
+ * tests that retain the service instance directly. */
133
+ private callContext;
134
+ private timeoutOf;
135
+ /** Pick one of `options`; resolves the option id, or undefined on cancel. */
136
+ select(request: TuiDialogSelectRequest): Promise<string | undefined>;
137
+ select(owner: Context, request: TuiDialogSelectRequest): Promise<string | undefined>;
138
+ /** Yes/no question; resolves the boolean, false on cancel. */
139
+ confirm(request: TuiDialogConfirmRequest): Promise<boolean>;
140
+ confirm(owner: Context, request: TuiDialogConfirmRequest): Promise<boolean>;
141
+ /** Free-text input; resolves the text, or undefined on cancel. */
142
+ input(request: TuiDialogInputRequest): Promise<string | undefined>;
143
+ input(owner: Context, request: TuiDialogInputRequest): Promise<string | undefined>;
144
+ }
145
+ export default TuiDialogRuntime;
146
+ //# sourceMappingURL=dialogs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialogs.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/dialogs.ts"],"names":[],"mappings":"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"}