@deepseek-harness-tui/dsh-tui 0.8.0 → 0.8.2

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 (434) hide show
  1. package/README.md +32 -15
  2. package/cordis.patch.yml +21 -2
  3. package/cordis.yml +12 -1
  4. package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -0
  5. package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -0
  6. package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -0
  7. package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -0
  8. package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -0
  9. package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -0
  10. package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -0
  11. package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -0
  12. package/dsh-ecosystem-spec/registry/README.md +14 -0
  13. package/dsh-ecosystem-spec/registry/contracts/decision-events-v1alpha1.json +13 -0
  14. package/dsh-ecosystem-spec/registry/contracts/scene-v1alpha1.json +13 -0
  15. package/dsh-ecosystem-spec/registry/contracts/settings-section-v1alpha1.json +13 -0
  16. package/dsh-ecosystem-spec/registry/contracts/tui-channel-v1alpha1.json +30 -0
  17. package/dsh-ecosystem-spec/registry/contracts/workspace-provider-v1alpha1.json +6 -0
  18. package/dsh-ecosystem-spec/registry/host-descriptor.tui.example.json +56 -0
  19. package/dsh-ecosystem-spec/registry/permissions-0.1.json +13 -0
  20. package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -0
  21. package/dsh-ecosystem-spec/schemas/conformance-claim.schema.json +15 -0
  22. package/dsh-ecosystem-spec/schemas/effect-ledger-record.schema.json +16 -0
  23. package/dsh-ecosystem-spec/schemas/host-descriptor.schema.json +26 -0
  24. package/lib/types/cc/figures.d.ts +4 -0
  25. package/lib/types/cc/figures.d.ts.map +1 -1
  26. package/lib/types/cc/figures.js +4 -0
  27. package/lib/types/command-trees.d.ts +2 -1
  28. package/lib/types/command-trees.d.ts.map +1 -1
  29. package/lib/types/command-trees.js +1 -1
  30. package/lib/types/commands.d.ts.map +1 -1
  31. package/lib/types/commands.js +2 -0
  32. package/lib/types/components/ExtensionDialog.d.ts +40 -0
  33. package/lib/types/components/ExtensionDialog.d.ts.map +1 -0
  34. package/lib/types/components/ExtensionDialog.js +210 -0
  35. package/lib/types/components/HelpMenu.js +1 -1
  36. package/lib/types/components/LoadedContextPanel.d.ts +5 -5
  37. package/lib/types/components/LoadedContextPanel.js +6 -6
  38. package/lib/types/components/LogoV2.d.ts.map +1 -1
  39. package/lib/types/components/LogoV2.js +16 -8
  40. package/lib/types/components/Markdown.d.ts +13 -1
  41. package/lib/types/components/Markdown.d.ts.map +1 -1
  42. package/lib/types/components/Markdown.js +15 -1
  43. package/lib/types/components/MessageList.d.ts +3 -1
  44. package/lib/types/components/MessageList.d.ts.map +1 -1
  45. package/lib/types/components/MessageList.js +111 -6
  46. package/lib/types/components/PromptInput.d.ts.map +1 -1
  47. package/lib/types/components/PromptInput.js +26 -12
  48. package/lib/types/components/RewindPicker.d.ts +13 -1
  49. package/lib/types/components/RewindPicker.d.ts.map +1 -1
  50. package/lib/types/components/RewindPicker.js +26 -2
  51. package/lib/types/components/StreamingMarkdown.d.ts +2 -8
  52. package/lib/types/components/StreamingMarkdown.d.ts.map +1 -1
  53. package/lib/types/components/StreamingMarkdown.js +51 -9
  54. package/lib/types/components/ToolUseLoader.d.ts +8 -3
  55. package/lib/types/components/ToolUseLoader.d.ts.map +1 -1
  56. package/lib/types/components/ToolUseLoader.js +43 -9
  57. package/lib/types/components/activityFrames.d.ts +1 -1
  58. package/lib/types/components/activityFrames.d.ts.map +1 -1
  59. package/lib/types/components/activityFrames.js +4 -1
  60. package/lib/types/components/messages/AssistantThinkingMessage.d.ts +5 -1
  61. package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -1
  62. package/lib/types/components/messages/AssistantThinkingMessage.js +26 -3
  63. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  64. package/lib/types/components/messages/AssistantToolUseMessage.js +13 -2
  65. package/lib/types/dsh-adapter/channel.d.ts +61 -11
  66. package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
  67. package/lib/types/dsh-adapter/channel.js +767 -120
  68. package/lib/types/dsh-adapter/childStderr.d.ts.map +1 -1
  69. package/lib/types/dsh-adapter/childStderr.js +10 -0
  70. package/lib/types/dsh-adapter/command-attribution.d.ts +51 -0
  71. package/lib/types/dsh-adapter/command-attribution.d.ts.map +1 -0
  72. package/lib/types/dsh-adapter/command-attribution.js +93 -0
  73. package/lib/types/dsh-adapter/command-errors.d.ts +42 -0
  74. package/lib/types/dsh-adapter/command-errors.d.ts.map +1 -0
  75. package/lib/types/dsh-adapter/command-errors.js +63 -0
  76. package/lib/types/dsh-adapter/command-trees.d.ts +7 -1
  77. package/lib/types/dsh-adapter/command-trees.d.ts.map +1 -1
  78. package/lib/types/dsh-adapter/command-trees.js +70 -20
  79. package/lib/types/dsh-adapter/component-identity.d.ts +33 -0
  80. package/lib/types/dsh-adapter/component-identity.d.ts.map +1 -0
  81. package/lib/types/dsh-adapter/component-identity.js +108 -0
  82. package/lib/types/dsh-adapter/contract.d.ts +1 -1
  83. package/lib/types/dsh-adapter/contract.js +2 -2
  84. package/lib/types/dsh-adapter/decision-guard.d.ts +84 -0
  85. package/lib/types/dsh-adapter/decision-guard.d.ts.map +1 -0
  86. package/lib/types/dsh-adapter/decision-guard.js +348 -0
  87. package/lib/types/dsh-adapter/dialogs.d.ts +145 -0
  88. package/lib/types/dsh-adapter/dialogs.d.ts.map +1 -0
  89. package/lib/types/dsh-adapter/dialogs.js +316 -0
  90. package/lib/types/dsh-adapter/effect-ledger.d.ts +91 -0
  91. package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -0
  92. package/lib/types/dsh-adapter/effect-ledger.js +251 -0
  93. package/lib/types/dsh-adapter/extension-events.d.ts +193 -0
  94. package/lib/types/dsh-adapter/extension-events.d.ts.map +1 -0
  95. package/lib/types/dsh-adapter/extension-events.js +207 -0
  96. package/lib/types/dsh-adapter/extensions.d.ts +32 -0
  97. package/lib/types/dsh-adapter/extensions.d.ts.map +1 -0
  98. package/lib/types/dsh-adapter/extensions.js +42 -0
  99. package/lib/types/dsh-adapter/grants.d.ts +25 -0
  100. package/lib/types/dsh-adapter/grants.d.ts.map +1 -0
  101. package/lib/types/dsh-adapter/grants.js +213 -0
  102. package/lib/types/dsh-adapter/host-access.d.ts +37 -0
  103. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -0
  104. package/lib/types/dsh-adapter/host-access.js +652 -0
  105. package/lib/types/dsh-adapter/host-descriptor.d.ts +24 -0
  106. package/lib/types/dsh-adapter/host-descriptor.d.ts.map +1 -0
  107. package/lib/types/dsh-adapter/host-descriptor.js +169 -0
  108. package/lib/types/dsh-adapter/index.d.ts +4 -0
  109. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  110. package/lib/types/dsh-adapter/index.js +1 -0
  111. package/lib/types/dsh-adapter/message-observer.d.ts +173 -0
  112. package/lib/types/dsh-adapter/message-observer.d.ts.map +1 -0
  113. package/lib/types/dsh-adapter/message-observer.js +553 -0
  114. package/lib/types/dsh-adapter/plugin-host.d.ts +136 -0
  115. package/lib/types/dsh-adapter/plugin-host.d.ts.map +1 -0
  116. package/lib/types/dsh-adapter/plugin-host.js +365 -0
  117. package/lib/types/dsh-adapter/plugin-storage.d.ts +108 -0
  118. package/lib/types/dsh-adapter/plugin-storage.d.ts.map +1 -0
  119. package/lib/types/dsh-adapter/plugin-storage.js +397 -0
  120. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  121. package/lib/types/dsh-adapter/plugin.js +124 -14
  122. package/lib/types/dsh-adapter/plugins-info.d.ts +43 -0
  123. package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -0
  124. package/lib/types/dsh-adapter/plugins-info.js +276 -0
  125. package/lib/types/dsh-adapter/promptDebug.d.ts +0 -6
  126. package/lib/types/dsh-adapter/promptDebug.d.ts.map +1 -1
  127. package/lib/types/dsh-adapter/promptDebug.js +13 -4
  128. package/lib/types/dsh-adapter/renderers.d.ts +57 -0
  129. package/lib/types/dsh-adapter/renderers.d.ts.map +1 -0
  130. package/lib/types/dsh-adapter/renderers.js +173 -0
  131. package/lib/types/dsh-adapter/sanitize.d.ts +36 -0
  132. package/lib/types/dsh-adapter/sanitize.d.ts.map +1 -0
  133. package/lib/types/dsh-adapter/sanitize.js +65 -0
  134. package/lib/types/dsh-adapter/scenes.d.ts +15 -5
  135. package/lib/types/dsh-adapter/scenes.d.ts.map +1 -1
  136. package/lib/types/dsh-adapter/scenes.js +149 -35
  137. package/lib/types/dsh-adapter/settings-sections.d.ts +7 -3
  138. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
  139. package/lib/types/dsh-adapter/settings-sections.js +106 -26
  140. package/lib/types/dsh-adapter/shortcuts.d.ts +107 -0
  141. package/lib/types/dsh-adapter/shortcuts.d.ts.map +1 -0
  142. package/lib/types/dsh-adapter/shortcuts.js +340 -0
  143. package/lib/types/dsh-adapter/status.d.ts +74 -0
  144. package/lib/types/dsh-adapter/status.d.ts.map +1 -0
  145. package/lib/types/dsh-adapter/status.js +234 -0
  146. package/lib/types/dsh-adapter/workspaces.d.ts +16 -5
  147. package/lib/types/dsh-adapter/workspaces.d.ts.map +1 -1
  148. package/lib/types/dsh-adapter/workspaces.js +287 -170
  149. package/lib/types/extensions.d.ts +13 -0
  150. package/lib/types/extensions.d.ts.map +1 -0
  151. package/lib/types/extensions.js +21 -0
  152. package/lib/types/force-production-react.d.ts +1 -0
  153. package/lib/types/force-production-react.d.ts.map +1 -0
  154. package/lib/types/force-production-react.js +12 -0
  155. package/lib/types/i18n.d.ts +174 -20
  156. package/lib/types/i18n.d.ts.map +1 -1
  157. package/lib/types/i18n.js +56 -6
  158. package/lib/types/index.d.ts +1 -0
  159. package/lib/types/index.d.ts.map +1 -1
  160. package/lib/types/index.js +1 -0
  161. package/lib/types/ink/components/App.d.ts +2 -0
  162. package/lib/types/ink/components/App.d.ts.map +1 -1
  163. package/lib/types/ink/components/App.js +4 -0
  164. package/lib/types/ink/ink.d.ts +31 -3
  165. package/lib/types/ink/ink.d.ts.map +1 -1
  166. package/lib/types/ink/ink.js +90 -5
  167. package/lib/types/ink/log-update.d.ts.map +1 -1
  168. package/lib/types/ink/log-update.js +225 -56
  169. package/lib/types/ink/output.d.ts +35 -2
  170. package/lib/types/ink/output.d.ts.map +1 -1
  171. package/lib/types/ink/output.js +281 -14
  172. package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
  173. package/lib/types/ink/render-node-to-output.js +14 -6
  174. package/lib/types/ink/screen.d.ts +39 -0
  175. package/lib/types/ink/screen.d.ts.map +1 -1
  176. package/lib/types/ink/screen.js +117 -0
  177. package/lib/types/ink/terminal.d.ts.map +1 -1
  178. package/lib/types/ink/terminal.js +26 -6
  179. package/lib/types/ink/wrapAnsi.d.ts +1 -1
  180. package/lib/types/ink/wrapAnsi.d.ts.map +1 -1
  181. package/lib/types/ink/wrapAnsi.js +29 -2
  182. package/lib/types/plugin-host.d.ts +15 -0
  183. package/lib/types/plugin-host.d.ts.map +1 -0
  184. package/lib/types/plugin-host.js +17 -0
  185. package/lib/types/plugin-spec/negotiate.d.ts +11 -0
  186. package/lib/types/plugin-spec/negotiate.d.ts.map +1 -0
  187. package/lib/types/plugin-spec/negotiate.js +97 -0
  188. package/lib/types/plugin-spec/permission-scope.d.ts +32 -0
  189. package/lib/types/plugin-spec/permission-scope.d.ts.map +1 -0
  190. package/lib/types/plugin-spec/permission-scope.js +90 -0
  191. package/lib/types/plugin-spec/registry.d.ts +23 -0
  192. package/lib/types/plugin-spec/registry.d.ts.map +1 -0
  193. package/lib/types/plugin-spec/registry.js +252 -0
  194. package/lib/types/plugin-spec/schema-check.d.ts +17 -0
  195. package/lib/types/plugin-spec/schema-check.d.ts.map +1 -0
  196. package/lib/types/plugin-spec/schema-check.js +165 -0
  197. package/lib/types/plugin-spec/tui-extension.d.ts +16 -0
  198. package/lib/types/plugin-spec/tui-extension.d.ts.map +1 -0
  199. package/lib/types/plugin-spec/tui-extension.js +79 -0
  200. package/lib/types/plugin-spec/types.d.ts +114 -0
  201. package/lib/types/plugin-spec/types.d.ts.map +1 -0
  202. package/lib/types/plugin-spec/types.js +10 -0
  203. package/lib/types/plugin-spec/validate.d.ts +21 -0
  204. package/lib/types/plugin-spec/validate.d.ts.map +1 -0
  205. package/lib/types/plugin-spec/validate.js +138 -0
  206. package/lib/types/scenes.d.ts +2 -1
  207. package/lib/types/scenes.d.ts.map +1 -1
  208. package/lib/types/scenes.js +1 -1
  209. package/lib/types/screens/Chat.d.ts +14 -1
  210. package/lib/types/screens/Chat.d.ts.map +1 -1
  211. package/lib/types/screens/Chat.js +173 -49
  212. package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
  213. package/lib/types/screens/SessionBrowser.js +10 -3
  214. package/lib/types/sessions/view.d.ts +3 -2
  215. package/lib/types/sessions/view.d.ts.map +1 -1
  216. package/lib/types/sessions/view.js +18 -0
  217. package/lib/types/settings-sections.d.ts +2 -1
  218. package/lib/types/settings-sections.d.ts.map +1 -1
  219. package/lib/types/settings-sections.js +1 -1
  220. package/lib/types/theme.d.ts +5 -0
  221. package/lib/types/theme.d.ts.map +1 -1
  222. package/lib/types/theme.js +15 -0
  223. package/lib/types/update.d.ts +20 -0
  224. package/lib/types/update.d.ts.map +1 -1
  225. package/lib/types/update.js +54 -7
  226. package/lib/types/utils/execFileNoThrow.d.ts.map +1 -1
  227. package/lib/types/utils/execFileNoThrow.js +3 -0
  228. package/lib/types/utils/loaded-context.d.ts +8 -3
  229. package/lib/types/utils/loaded-context.d.ts.map +1 -1
  230. package/lib/types/utils/loaded-context.js +39 -3
  231. package/lib/types/utils/modifiers.d.ts.map +1 -1
  232. package/lib/types/utils/modifiers.js +3 -2
  233. package/lib/types/working-activity.d.ts +12 -0
  234. package/lib/types/working-activity.d.ts.map +1 -1
  235. package/lib/types/working-activity.js +13 -0
  236. package/lib/types/workspaces.d.ts +2 -1
  237. package/lib/types/workspaces.d.ts.map +1 -1
  238. package/lib/types/workspaces.js +1 -1
  239. package/node_modules/@dsh-std/command/CHANGELOG.md +8 -0
  240. package/node_modules/@dsh-std/command/LICENSE +21 -0
  241. package/node_modules/@dsh-std/command/README.md +26 -0
  242. package/node_modules/@dsh-std/command/README.zh.md +28 -0
  243. package/node_modules/@dsh-std/command/lib/index.d.ts +144 -0
  244. package/node_modules/@dsh-std/command/lib/index.d.ts.map +1 -0
  245. package/node_modules/@dsh-std/command/lib/index.js +252 -0
  246. package/node_modules/@dsh-std/command/lib/index.js.map +1 -0
  247. package/node_modules/@dsh-std/command/package.json +22 -0
  248. package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
  249. package/node_modules/@dsh-std/connection/LICENSE +21 -0
  250. package/node_modules/@dsh-std/connection/README.md +42 -0
  251. package/node_modules/@dsh-std/connection/README.zh.md +42 -0
  252. package/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
  253. package/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
  254. package/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
  255. package/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
  256. package/node_modules/@dsh-std/connection/lib/index.js +158 -0
  257. package/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
  258. package/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
  259. package/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
  260. package/node_modules/@dsh-std/connection/lib/memory.js +258 -0
  261. package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
  262. package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
  263. package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
  264. package/node_modules/@dsh-std/connection/package.json +20 -0
  265. package/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  266. package/node_modules/@dsh-std/core/LICENSE +21 -0
  267. package/node_modules/@dsh-std/core/README.md +13 -0
  268. package/node_modules/@dsh-std/core/README.zh.md +13 -0
  269. package/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  270. package/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  271. package/node_modules/@dsh-std/core/lib/index.js +424 -0
  272. package/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  273. package/node_modules/@dsh-std/core/package.json +21 -0
  274. package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
  275. package/node_modules/@dsh-std/manifest/LICENSE +21 -0
  276. package/node_modules/@dsh-std/manifest/README.md +5 -0
  277. package/node_modules/@dsh-std/manifest/README.zh.md +5 -0
  278. package/node_modules/@dsh-std/manifest/lib/index.d.ts +182 -0
  279. package/node_modules/@dsh-std/manifest/lib/index.d.ts.map +1 -0
  280. package/node_modules/@dsh-std/manifest/lib/index.js +625 -0
  281. package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -0
  282. package/node_modules/@dsh-std/manifest/package.json +20 -0
  283. package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -0
  284. package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -0
  285. package/node_modules/@dsh-std/messages/LICENSE +21 -0
  286. package/node_modules/@dsh-std/messages/README.md +5 -0
  287. package/node_modules/@dsh-std/messages/README.zh.md +7 -0
  288. package/node_modules/@dsh-std/messages/lib/index.d.ts +50 -0
  289. package/node_modules/@dsh-std/messages/lib/index.d.ts.map +1 -0
  290. package/node_modules/@dsh-std/messages/lib/index.js +151 -0
  291. package/node_modules/@dsh-std/messages/lib/index.js.map +1 -0
  292. package/node_modules/@dsh-std/messages/package.json +20 -0
  293. package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -0
  294. package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
  295. package/node_modules/@dsh-std/presentation/LICENSE +21 -0
  296. package/node_modules/@dsh-std/presentation/README.md +27 -0
  297. package/node_modules/@dsh-std/presentation/README.zh.md +29 -0
  298. package/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
  299. package/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
  300. package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
  301. package/node_modules/@dsh-std/presentation/lib/index.d.ts +262 -0
  302. package/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -0
  303. package/node_modules/@dsh-std/presentation/lib/index.js +550 -0
  304. package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -0
  305. package/node_modules/@dsh-std/presentation/lib/interaction.d.ts +2 -0
  306. package/node_modules/@dsh-std/presentation/lib/interaction.js +2 -0
  307. package/node_modules/@dsh-std/presentation/lib/operations.d.ts +2 -0
  308. package/node_modules/@dsh-std/presentation/lib/operations.js +2 -0
  309. package/node_modules/@dsh-std/presentation/package.json +25 -0
  310. package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -0
  311. package/node_modules/@dsh-std/storage/LICENSE +21 -0
  312. package/node_modules/@dsh-std/storage/README.md +5 -0
  313. package/node_modules/@dsh-std/storage/README.zh.md +7 -0
  314. package/node_modules/@dsh-std/storage/lib/index.d.ts +48 -0
  315. package/node_modules/@dsh-std/storage/lib/index.d.ts.map +1 -0
  316. package/node_modules/@dsh-std/storage/lib/index.js +104 -0
  317. package/node_modules/@dsh-std/storage/lib/index.js.map +1 -0
  318. package/node_modules/@dsh-std/storage/package.json +20 -0
  319. package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -0
  320. package/package.json +110 -70
  321. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
  322. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -0
  323. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -0
  324. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -0
  325. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
  326. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
  327. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
  328. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
  329. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js +158 -0
  330. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
  331. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
  332. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
  333. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js +258 -0
  334. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
  335. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
  336. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
  337. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -0
  338. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  339. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -0
  340. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -0
  341. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -0
  342. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  343. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  344. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js +424 -0
  345. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  346. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -0
  347. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
  348. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -0
  349. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -0
  350. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -0
  351. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.d.ts +182 -0
  352. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.d.ts.map +1 -0
  353. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js +625 -0
  354. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -0
  355. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -0
  356. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -0
  357. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
  358. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -0
  359. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +27 -0
  360. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +29 -0
  361. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
  362. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
  363. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
  364. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts +262 -0
  365. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -0
  366. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js +550 -0
  367. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -0
  368. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/interaction.d.ts +2 -0
  369. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/interaction.js +2 -0
  370. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/operations.d.ts +2 -0
  371. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/operations.js +2 -0
  372. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +25 -0
  373. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  374. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -0
  375. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -0
  376. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -0
  377. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  378. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  379. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js +424 -0
  380. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  381. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -0
  382. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  383. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -0
  384. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -0
  385. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -0
  386. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  387. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  388. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js +424 -0
  389. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  390. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -0
  391. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  392. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -0
  393. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -0
  394. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -0
  395. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  396. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  397. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js +424 -0
  398. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  399. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -0
  400. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
  401. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -0
  402. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -0
  403. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -0
  404. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
  405. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
  406. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
  407. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
  408. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js +158 -0
  409. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
  410. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
  411. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
  412. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js +258 -0
  413. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
  414. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
  415. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
  416. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -0
  417. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  418. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -0
  419. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -0
  420. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -0
  421. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  422. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  423. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js +424 -0
  424. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  425. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -0
  426. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  427. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -0
  428. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -0
  429. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -0
  430. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
  431. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
  432. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js +424 -0
  433. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -0
  434. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +21 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The render-path sanitization contract for plugin-supplied text — the
3
+ * single implementation behind every managed-UI seam (dialogs, status line,
4
+ * entry renderers, rewind modes, decision notices). TUI-PROP-009 Track A
5
+ * makes these rules normative, so they live in exactly one place:
6
+ *
7
+ * - C0/C1 control chars are stripped (replaced by a space) — plugin text
8
+ * must never smuggle escape sequences onto the screen;
9
+ * - whitespace collapses to single spaces (render paths are single-line);
10
+ * - width is capped in terminal CELLS (never string.length) with an
11
+ * ellipsis.
12
+ *
13
+ * Non-scalar input is DROPPED, never `String()`-coerced — `String({})`
14
+ * would put "[object Object]" on the render path. Scalars
15
+ * (string/number/boolean) coerce through String() first.
16
+ */
17
+ import { stringWidth } from '../ink/stringWidth.js';
18
+ /** Sanitize an already-string value for the render path. */
19
+ export function cleanRenderText(value, maxCells) {
20
+ // eslint-disable-next-line no-control-regex -- deliberate: sanitize untrusted render-path text
21
+ const flat = value.replace(/[\x00-\x1f\x7f-\x9f]/g, ' ').replace(/\s+/g, ' ').trim();
22
+ if (stringWidth(flat) <= maxCells)
23
+ return flat;
24
+ let out = '';
25
+ for (const ch of flat) {
26
+ if (stringWidth(out + ch) > maxCells - 1)
27
+ break;
28
+ out += ch;
29
+ }
30
+ return `${out}…`;
31
+ }
32
+ /**
33
+ * Sanitize an untrusted (possibly non-string) value. Non-scalars — objects,
34
+ * arrays, functions, symbols, null/undefined — yield '' so the caller takes
35
+ * its drop/refuse path; scalars coerce then sanitize.
36
+ */
37
+ export function cleanScalarText(value, maxCells) {
38
+ if (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean')
39
+ return '';
40
+ return cleanRenderText(String(value), maxCells);
41
+ }
42
+ /**
43
+ * Truncate to a cell budget WITHOUT ellipsis, whitespace folding, or any
44
+ * other mutation — the editing-path counterpart of {@link cleanRenderText}.
45
+ * An input panel caps what the user types/pastes; inserting '…' or
46
+ * collapsing their spaces would corrupt text they can still edit.
47
+ */
48
+ export function capCells(value, maxCells) {
49
+ if (stringWidth(value) <= maxCells)
50
+ return value;
51
+ let out = '';
52
+ for (const ch of value) {
53
+ if (stringWidth(out + ch) > maxCells)
54
+ break;
55
+ out += ch;
56
+ }
57
+ return out;
58
+ }
59
+ /** C0/C1 control chars → space, nothing else touched. The single-line
60
+ * input panel flattens pasted chunks with this (newlines become spaces —
61
+ * the panel has no second row for them). */
62
+ export function flattenInline(value) {
63
+ // eslint-disable-next-line no-control-regex -- deliberate: sanitize untrusted render-path text
64
+ return value.replace(/[\x00-\x1f\x7f-\x9f]/g, ' ');
65
+ }
@@ -37,6 +37,13 @@ export interface TuiSceneDescriptor {
37
37
  title?: string;
38
38
  component: React.ComponentType<TuiSceneProps>;
39
39
  }
40
+ /** Host-only scene controls used by the channel; omitted from the plugin export. */
41
+ export interface TuiSceneHost {
42
+ readonly active: TuiSceneDescriptor | undefined;
43
+ open(id: string): boolean;
44
+ close(): void;
45
+ subscribe(listener: () => void): () => void;
46
+ }
40
47
  declare module '@deepseek-ai/cordis' {
41
48
  interface Context {
42
49
  tuiScenes: TuiSceneRuntime;
@@ -53,11 +60,14 @@ export declare const name = "dsh-tui-scenes";
53
60
  * takes the whole terminal the way the trajectory scene does.
54
61
  */
55
62
  export declare class TuiSceneRuntime extends Service {
56
- private readonly scenes;
57
- private readonly listeners;
58
- private current;
59
63
  constructor(ctx: Context);
60
- register(descriptor: TuiSceneDescriptor): () => void;
64
+ /**
65
+ * Register a full-screen scene; returns the dispose function (caller
66
+ * scopes it with `ctx.effect`). The optional trailing `identity` (the
67
+ * plugin's own ctx) only feeds the effect ledger's pluginId — omitting it
68
+ * records `undeclared` (C-060).
69
+ */
70
+ register(descriptor: TuiSceneDescriptor, identity?: Context): () => void;
61
71
  /**
62
72
  * Swap the conversation for the named scene. Returns false (and warns)
63
73
  * when no plugin registered that id — a mistyped id must fail visibly in
@@ -69,7 +79,7 @@ export declare class TuiSceneRuntime extends Service {
69
79
  get active(): TuiSceneDescriptor | undefined;
70
80
  /** UI-side change feed: fired after every open/close/dispose transition. */
71
81
  subscribe(listener: () => void): () => void;
72
- private notify;
73
82
  }
83
+ export declare function getHostSceneRuntime(runtime: TuiSceneRuntime | undefined): TuiSceneHost | undefined;
74
84
  export default TuiSceneRuntime;
75
85
  //# sourceMappingURL=scenes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scenes.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/scenes.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,KAAK,EAAE,OAAO,KAAK,CAAA;IACnB,8DAA8D;IAC9D,EAAE,EAAE,cAAc,UAAU,CAAC,CAAA;IAC7B,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAA;IAChB,mEAAmE;IACnE,KAAK,IAAI,IAAI,CAAA;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAA;IACV,iFAAiF;IACj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doors. */
2
2
  import { Service } from '@deepseek-ai/cordis';
3
+ import { activationFiber, bindCallerEffect, compositionRoot, concreteService, requirePluginCaller } from './host-access.js';
4
+ import { componentIdentityOf } from './component-identity.js';
3
5
  export const name = 'dsh-tui-scenes';
4
6
  /**
5
7
  * Small host-only registry; command execution remains owned by dsh-commands.
@@ -11,30 +13,81 @@ export const name = 'dsh-tui-scenes';
11
13
  * takes the whole terminal the way the trajectory scene does.
12
14
  */
13
15
  export class TuiSceneRuntime extends Service {
14
- scenes = new Map();
15
- listeners = new Set();
16
- current;
17
16
  constructor(ctx) {
18
17
  super(ctx, 'tuiScenes');
18
+ compositionRoot(ctx);
19
+ const runtime = this;
20
+ const state = {
21
+ scenes: new Map(),
22
+ owners: new Map(),
23
+ listeners: new Set(),
24
+ current: undefined,
25
+ host: undefined,
26
+ logger: ctx.logger,
27
+ };
28
+ state.host = Object.freeze({
29
+ get active() {
30
+ return sceneStateFor(runtime).current;
31
+ },
32
+ open(id) {
33
+ return openScene(runtime, id);
34
+ },
35
+ close() {
36
+ closeScene(runtime);
37
+ },
38
+ subscribe(listener) {
39
+ return subscribeScenes(runtime, listener);
40
+ },
41
+ });
42
+ sceneStates.set(this, state);
19
43
  }
20
- register(descriptor) {
44
+ /**
45
+ * Register a full-screen scene; returns the dispose function (caller
46
+ * scopes it with `ctx.effect`). The optional trailing `identity` (the
47
+ * plugin's own ctx) only feeds the effect ledger's pluginId — omitting it
48
+ * records `undeclared` (C-060).
49
+ */
50
+ register(descriptor, identity) {
51
+ const state = sceneStateFor(this);
52
+ const caller = requirePluginCaller(this.ctx, 'tuiScenes.register', this);
53
+ const activationOwner = activationFiber(caller);
54
+ if (activationOwner === undefined)
55
+ throw new Error('dsh-tui: tuiScenes.register requires a live activation');
56
+ const callerIdentity = componentIdentityOf(caller);
57
+ const suppliedIdentity = identity === undefined ? callerIdentity : componentIdentityOf(identity);
58
+ if (identity !== undefined && callerIdentity !== undefined && suppliedIdentity !== callerIdentity) {
59
+ throw new Error('dsh-tui: tuiScenes.register identity belongs to another activation');
60
+ }
21
61
  const id = descriptor.id.trim().toLowerCase();
22
62
  if (!/^[a-z][a-z0-9_-]*$/u.test(id))
23
63
  throw new TypeError(`invalid TUI scene id: ${descriptor.id}`);
24
- if (this.scenes.has(id))
64
+ if (state.scenes.has(id)) {
65
+ caller.get('tuiEffectLedger')?.record({
66
+ operation: 'create',
67
+ resource: { kind: 'scene', id },
68
+ result: 'failed',
69
+ errorCode: 'DUPLICATE_CONTRIBUTION_ID',
70
+ }, identity);
25
71
  throw new Error(`TUI scene "${id}" is already registered`);
26
- const normalized = { ...descriptor, id };
27
- this.scenes.set(id, normalized);
28
- return () => {
29
- if (this.scenes.get(id) !== normalized)
72
+ }
73
+ const normalized = Object.freeze({ ...descriptor, id });
74
+ state.scenes.set(id, normalized);
75
+ state.owners.set(id, activationOwner);
76
+ caller.get('tuiEffectLedger')?.record({ operation: 'create', resource: { kind: 'scene', id }, result: 'applied' }, identity);
77
+ const dispose = () => {
78
+ if (state.scenes.get(id) !== normalized)
30
79
  return;
31
- this.scenes.delete(id);
80
+ state.scenes.delete(id);
81
+ state.owners.delete(id);
82
+ caller.get('tuiEffectLedger')?.record({ operation: 'release', resource: { kind: 'scene', id }, result: 'applied' }, identity);
32
83
  // Disposing the open scene must not strand the user on a dead screen.
33
- if (this.current === normalized) {
34
- this.current = undefined;
35
- this.notify();
84
+ if (state.current === normalized) {
85
+ state.current = undefined;
86
+ notifyScenes(state, activationOwner);
36
87
  }
37
88
  };
89
+ bindCallerEffect(caller, dispose);
90
+ return dispose;
38
91
  }
39
92
  /**
40
93
  * Swap the conversation for the named scene. Returns false (and warns)
@@ -42,37 +95,98 @@ export class TuiSceneRuntime extends Service {
42
95
  * the log, not silently do nothing in the UI.
43
96
  */
44
97
  open(id) {
45
- const scene = this.scenes.get(id.trim().toLowerCase());
46
- if (scene === undefined) {
47
- this.ctx.logger.warn(`dsh-tui: no TUI scene registered as "${id}"`);
48
- return false;
49
- }
50
- if (scene === this.current)
51
- return true;
52
- this.current = scene;
53
- this.notify();
54
- return true;
98
+ const caller = requirePluginCaller(this.ctx, 'tuiScenes.open', this);
99
+ const owner = activationFiber(caller);
100
+ return owner === undefined ? false : openScene(this, id, caller, owner);
55
101
  }
56
102
  close() {
57
- if (this.current === undefined)
58
- return;
59
- this.current = undefined;
60
- this.notify();
103
+ const caller = requirePluginCaller(this.ctx, 'tuiScenes.close', this);
104
+ const owner = activationFiber(caller);
105
+ if (owner !== undefined)
106
+ closeScene(this, caller, owner);
61
107
  }
62
108
  /** The scene currently replacing the conversation, if any. */
63
109
  get active() {
64
- return this.current;
110
+ const caller = requirePluginCaller(this.ctx, 'tuiScenes.active', this);
111
+ const owner = activationFiber(caller);
112
+ const state = sceneStateFor(this);
113
+ return owner !== undefined && state.current !== undefined && state.owners.get(state.current.id) === owner
114
+ ? state.current
115
+ : undefined;
65
116
  }
66
117
  /** UI-side change feed: fired after every open/close/dispose transition. */
67
118
  subscribe(listener) {
68
- this.listeners.add(listener);
69
- return () => {
70
- this.listeners.delete(listener);
71
- };
119
+ const caller = requirePluginCaller(this.ctx, 'tuiScenes.subscribe', this);
120
+ const owner = activationFiber(caller);
121
+ if (owner === undefined)
122
+ return () => { };
123
+ const dispose = subscribeScenes(this, listener, owner);
124
+ bindCallerEffect(caller, dispose);
125
+ return dispose;
126
+ }
127
+ }
128
+ const sceneStates = new WeakMap();
129
+ function sceneStateFor(runtime) {
130
+ const state = sceneStates.get(concreteService(runtime));
131
+ if (state === undefined)
132
+ throw new Error('tuiScenes host state is unavailable');
133
+ return state;
134
+ }
135
+ function openScene(runtime, id, caller, owner) {
136
+ const state = sceneStateFor(runtime);
137
+ const scene = state.scenes.get(id.trim().toLowerCase());
138
+ if (scene === undefined) {
139
+ ;
140
+ (caller?.logger ?? state.logger).warn(`dsh-tui: no TUI scene registered as "${id}"`);
141
+ return false;
142
+ }
143
+ if (owner !== undefined && state.owners.get(scene.id) !== owner) {
144
+ caller?.logger.warn(`dsh-tui: scene "${scene.id}" belongs to another activation`);
145
+ return false;
146
+ }
147
+ if (scene === state.current)
148
+ return true;
149
+ const previousOwner = state.current === undefined ? undefined : state.owners.get(state.current.id);
150
+ state.current = scene;
151
+ notifyScenes(state, previousOwner);
152
+ return true;
153
+ }
154
+ function closeScene(runtime, caller, owner) {
155
+ const state = sceneStateFor(runtime);
156
+ if (state.current === undefined)
157
+ return;
158
+ if (owner !== undefined && state.owners.get(state.current.id) !== owner) {
159
+ caller?.logger.warn(`dsh-tui: scene "${state.current.id}" belongs to another activation`);
160
+ return;
161
+ }
162
+ const previousOwner = state.owners.get(state.current.id);
163
+ state.current = undefined;
164
+ notifyScenes(state, previousOwner);
165
+ }
166
+ function subscribeScenes(runtime, listener, owner) {
167
+ const state = sceneStateFor(runtime);
168
+ const entry = { owner, listener };
169
+ state.listeners.add(entry);
170
+ return () => {
171
+ state.listeners.delete(entry);
172
+ };
173
+ }
174
+ function notifyScenes(state, previousOwner) {
175
+ const currentOwner = state.current === undefined ? undefined : state.owners.get(state.current.id);
176
+ for (const entry of state.listeners) {
177
+ if (entry.owner !== undefined && entry.owner !== currentOwner && entry.owner !== previousOwner)
178
+ continue;
179
+ entry.listener();
180
+ }
181
+ }
182
+ export function getHostSceneRuntime(runtime) {
183
+ if (runtime === undefined)
184
+ return undefined;
185
+ try {
186
+ return sceneStateFor(runtime).host ?? undefined;
72
187
  }
73
- notify() {
74
- for (const listener of this.listeners)
75
- listener();
188
+ catch {
189
+ return undefined;
76
190
  }
77
191
  }
78
192
  export default TuiSceneRuntime;
@@ -86,6 +86,12 @@ export interface TuiSettingsSection {
86
86
  /** Editable fields, in display order. */
87
87
  fields: readonly TuiSettingsField[];
88
88
  }
89
+ /** Host-only settings-section controls used by the TUI bootstrap/channel. */
90
+ export interface TuiSettingsSectionsHost {
91
+ register(section: TuiSettingsSection): () => void;
92
+ list(): readonly TuiSettingsSection[];
93
+ subscribe(listener: () => void): () => void;
94
+ }
89
95
  declare module '@deepseek-ai/cordis' {
90
96
  interface Context {
91
97
  tuiSettingsSections: TuiSettingsSectionsRuntime;
@@ -97,8 +103,6 @@ export declare const name = "dsh-tui-settings-sections";
97
103
  * the dsh settings service (`ctx.settings`).
98
104
  */
99
105
  export declare class TuiSettingsSectionsRuntime extends Service {
100
- private readonly sections;
101
- private readonly listeners;
102
106
  constructor(ctx: Context);
103
107
  register(section: TuiSettingsSection): () => void;
104
108
  /** Registered sections in registration order. */
@@ -110,7 +114,7 @@ export declare class TuiSettingsSectionsRuntime extends Service {
110
114
  * re-read the section list (a plugin (un)loading mid-session changes it).
111
115
  */
112
116
  subscribe(listener: () => void): () => void;
113
- private emit;
114
117
  }
118
+ export declare function getHostSettingsSections(runtime: TuiSettingsSectionsRuntime | undefined): TuiSettingsSectionsHost | undefined;
115
119
  export default TuiSettingsSectionsRuntime;
116
120
  //# sourceMappingURL=settings-sections.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"settings-sections.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/settings-sections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAE3D,iEAAiE;AACjE,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAA;AAE3E,MAAM,WAAW,sBAAsB;IACrC,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAA;IACb,iDAAiD;IACjD,YAAY,CAAC,EAAE,qBAAqB,CAAA;CACrC;AAED,oEAAoE;AACpE,MAAM,MAAM,qBAAqB,GAC7B;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAA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,EAAE;IAQrC,sDAAsD;IACtD,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAQnD;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;CAS5C;AAgED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,0BAA0B,GAAG,SAAS,GAAG,uBAAuB,GAAG,SAAS,CAO5H;AAED,eAAe,0BAA0B,CAAA"}
@@ -10,54 +10,134 @@
10
10
  * metadata only.
11
11
  */
12
12
  import { Service } from '@deepseek-ai/cordis';
13
+ import { activationFiber, bindCallerEffect, compositionRoot, concreteService, requirePluginCaller } from './host-access.js';
13
14
  export const name = 'dsh-tui-settings-sections';
14
15
  /**
15
16
  * Small host-only registry; settings storage and validation remain owned by
16
17
  * the dsh settings service (`ctx.settings`).
17
18
  */
18
19
  export class TuiSettingsSectionsRuntime extends Service {
19
- sections = new Map();
20
- listeners = new Set();
21
20
  constructor(ctx) {
22
21
  super(ctx, 'tuiSettingsSections');
22
+ compositionRoot(ctx);
23
+ const runtime = this;
24
+ const state = { sections: new Map(), owners: new Map(), listeners: new Set(), host: undefined };
25
+ state.host = Object.freeze({
26
+ register(section) {
27
+ return registerSection(runtime, section);
28
+ },
29
+ list() {
30
+ return [...settingsSectionStateFor(runtime).sections.values()];
31
+ },
32
+ subscribe(listener) {
33
+ return subscribeSections(runtime, listener);
34
+ },
35
+ });
36
+ settingsSectionStates.set(this, state);
23
37
  }
24
38
  register(section) {
25
- const ns = section.ns.trim();
26
- if (!/^[a-z][a-z0-9_-]*$/u.test(ns))
27
- throw new TypeError(`invalid TUI settings-section namespace: ${section.ns}`);
28
- if (this.sections.has(ns))
29
- throw new Error(`TUI settings section "${ns}" is already registered`);
30
- const normalized = { ...section, ns };
31
- this.sections.set(ns, normalized);
32
- this.emit();
33
- return () => {
34
- if (this.sections.get(ns) === normalized) {
35
- this.sections.delete(ns);
36
- this.emit();
37
- }
38
- };
39
+ const caller = requirePluginCaller(this.ctx, 'tuiSettingsSections.register', this);
40
+ const owner = activationFiber(caller);
41
+ if (owner === undefined)
42
+ throw new Error('dsh-tui: tuiSettingsSections.register requires a live activation');
43
+ const dispose = registerSection(this, section, owner);
44
+ bindCallerEffect(caller, dispose);
45
+ return dispose;
39
46
  }
40
47
  /** Registered sections in registration order. */
41
48
  list() {
42
- return [...this.sections.values()];
49
+ const caller = requirePluginCaller(this.ctx, 'tuiSettingsSections.list', this);
50
+ const owner = activationFiber(caller);
51
+ return owner === undefined ? [] : [...settingsSectionStateFor(this).sections.entries()]
52
+ .filter(([ns]) => settingsSectionStateFor(this).owners.get(ns) === owner)
53
+ .map(([, section]) => section);
43
54
  }
44
55
  /** The section registered for a namespace, if any. */
45
56
  section(ns) {
46
- return this.sections.get(ns.trim());
57
+ const caller = requirePluginCaller(this.ctx, 'tuiSettingsSections.section', this);
58
+ const owner = activationFiber(caller);
59
+ const state = settingsSectionStateFor(this);
60
+ const normalized = ns.trim();
61
+ return owner !== undefined && state.owners.get(normalized) === owner ? state.sections.get(normalized) : undefined;
47
62
  }
48
63
  /**
49
64
  * Subscribe to register/unregister events so an open settings screen can
50
65
  * re-read the section list (a plugin (un)loading mid-session changes it).
51
66
  */
52
67
  subscribe(listener) {
53
- this.listeners.add(listener);
54
- return () => {
55
- this.listeners.delete(listener);
56
- };
57
- }
58
- emit() {
59
- for (const listener of this.listeners)
60
- listener();
68
+ const caller = requirePluginCaller(this.ctx, 'tuiSettingsSections.subscribe', this);
69
+ const owner = activationFiber(caller);
70
+ if (owner === undefined)
71
+ return () => { };
72
+ const dispose = subscribeSections(this, listener, owner);
73
+ bindCallerEffect(caller, dispose);
74
+ return dispose;
75
+ }
76
+ }
77
+ const settingsSectionStates = new WeakMap();
78
+ function settingsSectionStateFor(runtime) {
79
+ const state = settingsSectionStates.get(concreteService(runtime));
80
+ if (state === undefined)
81
+ throw new Error('tuiSettingsSections host state is unavailable');
82
+ return state;
83
+ }
84
+ function registerSection(runtime, section, owner) {
85
+ const state = settingsSectionStateFor(runtime);
86
+ const ns = section.ns.trim();
87
+ if (!/^[a-z][a-z0-9_-]*$/u.test(ns))
88
+ throw new TypeError(`invalid TUI settings-section namespace: ${section.ns}`);
89
+ if (state.sections.has(ns))
90
+ throw new Error(`TUI settings section "${ns}" is already registered`);
91
+ const normalized = Object.freeze({
92
+ ...section,
93
+ ns,
94
+ descriptions: section.descriptions === undefined ? undefined : Object.freeze({ ...section.descriptions }),
95
+ fields: Object.freeze(section.fields.map(field => Object.freeze({
96
+ ...field,
97
+ path: Object.freeze([...field.path]),
98
+ descriptions: field.descriptions === undefined ? undefined : Object.freeze({ ...field.descriptions }),
99
+ hintDescriptions: field.hintDescriptions === undefined ? undefined : Object.freeze({ ...field.hintDescriptions }),
100
+ options: field.options === undefined
101
+ ? undefined
102
+ : Object.freeze(field.options.map(option => Object.freeze({ ...option, descriptions: option.descriptions === undefined ? undefined : Object.freeze({ ...option.descriptions }) }))),
103
+ secret: field.secret === undefined ? undefined : Object.freeze({ ...field.secret }),
104
+ }))),
105
+ });
106
+ state.sections.set(ns, normalized);
107
+ if (owner !== undefined)
108
+ state.owners.set(ns, owner);
109
+ emitSections(state, owner);
110
+ return () => {
111
+ if (state.sections.get(ns) !== normalized)
112
+ return;
113
+ state.sections.delete(ns);
114
+ state.owners.delete(ns);
115
+ emitSections(state, owner);
116
+ };
117
+ }
118
+ function subscribeSections(runtime, listener, owner) {
119
+ const state = settingsSectionStateFor(runtime);
120
+ const entry = { owner, listener };
121
+ state.listeners.add(entry);
122
+ return () => {
123
+ state.listeners.delete(entry);
124
+ };
125
+ }
126
+ function emitSections(state, changedOwner) {
127
+ for (const entry of state.listeners) {
128
+ if (entry.owner !== undefined && entry.owner !== changedOwner)
129
+ continue;
130
+ entry.listener();
131
+ }
132
+ }
133
+ export function getHostSettingsSections(runtime) {
134
+ if (runtime === undefined)
135
+ return undefined;
136
+ try {
137
+ return settingsSectionStateFor(runtime).host ?? undefined;
138
+ }
139
+ catch {
140
+ return undefined;
61
141
  }
62
142
  }
63
143
  export default TuiSettingsSectionsRuntime;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Plugin keyboard shortcuts — pi's `pi.registerShortcut`. A plugin binds a
3
+ * combo (`ctrl+shift+p`, `alt+k`, …) to a handler; the chat screen matches
4
+ * combos against keypresses that survived every built-in binding and runs
5
+ * the handler, consuming the key.
6
+ *
7
+ * Precedence rule (same philosophy as the command list: a plugin shadows
8
+ * nothing built in):
9
+ *
10
+ * - Combos must carry ctrl or alt (meta) — bare letters are typing, and
11
+ * bare Esc/arrows are navigation. Rejected at registration.
12
+ * - A RESERVED list (every combo the TUI itself binds globally or in the
13
+ * prompt editor) is refused at registration with a warning. The list is
14
+ * the enforcement of "locals win": collisions can never reach the matcher.
15
+ * - Overlays (pickers, dialogs, scenes, the session browser) own the
16
+ * keyboard while open; shortcuts match only in the plain chat state.
17
+ *
18
+ * Handlers are fire-and-forget from the UI's point of view: async handlers
19
+ * are awaited but their rejection is caught and toasted — a throwing
20
+ * handler must never break the keyboard for everyone else.
21
+ */
22
+ import { Context, Service } from '@deepseek-ai/cordis';
23
+ /** Minimal shape of the ink Key flags the matcher reads (kept structurally
24
+ * compatible with `Key` from the ui kit without importing React-facing
25
+ * modules into the adapter). */
26
+ export interface TuiShortcutKey {
27
+ ctrl?: boolean;
28
+ meta?: boolean;
29
+ super?: boolean;
30
+ shift?: boolean;
31
+ return?: boolean;
32
+ escape?: boolean;
33
+ tab?: boolean;
34
+ backspace?: boolean;
35
+ delete?: boolean;
36
+ upArrow?: boolean;
37
+ downArrow?: boolean;
38
+ leftArrow?: boolean;
39
+ rightArrow?: boolean;
40
+ home?: boolean;
41
+ end?: boolean;
42
+ pageUp?: boolean;
43
+ pageDown?: boolean;
44
+ }
45
+ /** Controls that only the Chat input path may use. They are kept out of the
46
+ * Cordis service object, so one plugin cannot synthesize an input event to
47
+ * invoke another plugin's shortcut handler. */
48
+ export interface TuiShortcutHost {
49
+ dispatch(input: string, key: TuiShortcutKey): boolean;
50
+ setErrorHandler(handler: (combo: string, error: unknown) => void): () => void;
51
+ }
52
+ export interface TuiShortcutOptions {
53
+ /** One-line description (shown by future /help surfaces; required so
54
+ * every binding is discoverable). */
55
+ description: string;
56
+ handler: () => void | Promise<void>;
57
+ }
58
+ interface ParsedCombo {
59
+ readonly raw: string;
60
+ readonly ctrl: boolean;
61
+ readonly meta: boolean;
62
+ readonly shift: boolean;
63
+ /** Named key flag on the Key object, or undefined for a character key. */
64
+ readonly named?: keyof TuiShortcutKey;
65
+ /** Character to match against the ink `input` string (lowercased). */
66
+ readonly char?: string;
67
+ }
68
+ /**
69
+ * Parse `ctrl+shift+p` style combos. Returns undefined on anything
70
+ * malformed or disallowed (no modifier, unknown key name); `allowReserved`
71
+ * is exposed for tests only.
72
+ */
73
+ export declare function parseShortcutCombo(raw: string): ParsedCombo | undefined;
74
+ /** Match a keypress against a parsed combo. `input` is ink's input string
75
+ * (already the resolved character; ctrl+space arrives as ' '). */
76
+ export declare function matchShortcut(combo: ParsedCombo, input: string, key: TuiShortcutKey): boolean;
77
+ declare module '@deepseek-ai/cordis' {
78
+ interface Context {
79
+ tuiShortcuts: TuiShortcutRuntime;
80
+ }
81
+ }
82
+ /** `ctx.tuiShortcuts` — plugin keyboard shortcut registry. */
83
+ export declare class TuiShortcutRuntime extends Service {
84
+ constructor(ctx: Context);
85
+ /**
86
+ * Bind `combo` to `handler`. Invalid, modifier-less, reserved, or
87
+ * duplicate combos are refused with a logger warning rather than a throw
88
+ * — a bad binding must not fail the plugin's whole boot.
89
+ *
90
+ * Returns the dispose function; the CALLER scopes it to its own fiber
91
+ * (`ctx.effect(() => dispose)`) — the same contract as `tuiScenes`
92
+ * registration. (A service method only sees the service's own ctx, so
93
+ * caller-fiber cleanup cannot happen here.)
94
+ *
95
+ * The optional trailing `identity` (the plugin's own ctx) only feeds the
96
+ * effect ledger's pluginId — omitting it records `undeclared` (C-060).
97
+ */
98
+ register(combo: string, options: TuiShortcutOptions, identity?: Context): () => void;
99
+ /** Registered combos with descriptions (diagnostics / future /help). */
100
+ list(): readonly {
101
+ combo: string;
102
+ description: string;
103
+ }[];
104
+ }
105
+ export declare function getHostShortcuts(runtime: TuiShortcutRuntime | undefined): TuiShortcutHost | undefined;
106
+ export default TuiShortcutRuntime;
107
+ //# sourceMappingURL=shortcuts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcuts.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/shortcuts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAItD;;iCAEiC;AACjC,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;+CAE+C;AAC/C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAA;IACrD,eAAe,CAAC,OAAO,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