@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,276 @@
1
+ /**
2
+ * /plugins diagnostics surface (C-070 trust disclosure + C-030 negotiation
3
+ * diagnostics): assembles the lines behind the `/plugins` command.
4
+ *
5
+ * Sections (overview):
6
+ *
7
+ * 1. TRUST BANNER — always the first line (C-070): plugins run in-process;
8
+ * grants are behavioral constraints, not a security boundary; passing
9
+ * validation is not proof of safety.
10
+ * 2. HOST DESCRIPTOR summary — what the running host actually advertises
11
+ * (coordinates + generation), including drift-dropped contracts.
12
+ * 3. GRANT MATRIX — plugins × the registered permissions. The plugin set is
13
+ * the union of FOOTPRINTS ONLY: keys of the grants file, pluginIds seen
14
+ * in the effect ledger, and storage namespaces on disk (the host cannot
15
+ * enumerate installed plugins — that knowledge lives in the dsh CLI
16
+ * Loader). The header says so honestly.
17
+ * 4. LEDGER TAIL — the last 5 effect-ledger records.
18
+ *
19
+ * `/plugins check <path>` uses the parser and projection from the pinned
20
+ * @dsh-std/manifest revision, then evaluates every public/private protocol
21
+ * through one ProtocolCatalog. Manifests and on-disk files are UNTRUSTED input:
22
+ * every derived line passes cleanScalarText before it reaches the
23
+ * transcript.
24
+ */
25
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
26
+ import { join, resolve } from 'node:path';
27
+ import { parseManifest, projectManifest } from '@dsh-std/manifest';
28
+ import { DATA_DIR } from '../utils/paths.js';
29
+ import { t } from '../i18n.js';
30
+ import { loadSpecData } from '../plugin-spec/registry.js';
31
+ import { createContractIndex, validatePlugin } from '../plugin-spec/validate.js';
32
+ import { negotiate } from '../plugin-spec/negotiate.js';
33
+ import { cleanScalarText } from './sanitize.js';
34
+ import { buildHostDescriptor } from './host-descriptor.js';
35
+ import { PLUGIN_STORAGE_DIR } from './plugin-storage.js';
36
+ import { EFFECT_LEDGER_FILE } from './effect-ledger.js';
37
+ /** How many plugins the matrix shows before an overflow note. */
38
+ export const PLUGINS_MATRIX_MAX_ROWS = 20;
39
+ /** How many ledger records the tail section shows. */
40
+ export const PLUGINS_LEDGER_TAIL = 5;
41
+ /** Per-line cell cap for file-derived content. */
42
+ const LINE_CELLS = 200;
43
+ const cell = (value) => cleanScalarText(String(value ?? ''), LINE_CELLS);
44
+ /** Parse the ledger file tolerantly (skip corrupt lines, never throw). */
45
+ function readLedgerRecords(file) {
46
+ let text;
47
+ try {
48
+ text = readFileSync(file, 'utf8');
49
+ }
50
+ catch {
51
+ return [];
52
+ }
53
+ const records = [];
54
+ for (const line of text.split('\n')) {
55
+ if (line.trim() === '')
56
+ continue;
57
+ try {
58
+ const parsed = JSON.parse(line);
59
+ if (parsed !== null && typeof parsed === 'object')
60
+ records.push(parsed);
61
+ }
62
+ catch {
63
+ // Corrupt line: the diagnostics surface skips it (never rewrites).
64
+ }
65
+ }
66
+ return records;
67
+ }
68
+ /** The plugin set for the matrix: grants-file keys ∪ ledger pluginIds ∪
69
+ * storage namespaces ('host'/'undeclared' ledger identities are not
70
+ * plugins and are excluded). */
71
+ function footprintPlugins(deps, dataDir, ledgerFile, storageDir) {
72
+ const found = new Set();
73
+ try {
74
+ const raw = JSON.parse(readFileSync(join(dataDir, 'extension-grants.json'), 'utf8'));
75
+ if (raw !== null && typeof raw === 'object') {
76
+ const table = raw;
77
+ for (const section of [table.grants, table.denies]) {
78
+ if (section !== null && typeof section === 'object') {
79
+ for (const plugin of Object.keys(section))
80
+ found.add(plugin);
81
+ }
82
+ }
83
+ }
84
+ }
85
+ catch {
86
+ // Missing/corrupt grants file: the GrantStore already answers deny;
87
+ // the matrix simply has no rows from this source.
88
+ }
89
+ for (const record of readLedgerRecords(ledgerFile)) {
90
+ if (typeof record.pluginId === 'string' && record.pluginId !== '' && record.pluginId !== 'host' && record.pluginId !== 'undeclared') {
91
+ found.add(record.pluginId);
92
+ }
93
+ }
94
+ try {
95
+ for (const entry of readdirSync(storageDir)) {
96
+ if (!entry.endsWith('.json'))
97
+ continue;
98
+ const namespace = decodeURIComponent(entry.slice(0, -'.json'.length));
99
+ if (namespace !== '')
100
+ found.add(namespace);
101
+ }
102
+ }
103
+ catch {
104
+ // No storage directory yet: no rows from this source.
105
+ }
106
+ void deps;
107
+ return [...found].sort();
108
+ }
109
+ /** `/plugins check <path>`: official parse/projection + profile validation + negotiation. */
110
+ function checkManifestLines(pathArg, deps) {
111
+ const lines = [];
112
+ const target = resolve(pathArg);
113
+ if (!existsSync(target)) {
114
+ lines.push(t('plugins-check-not-found', { path: cell(pathArg) }));
115
+ return lines;
116
+ }
117
+ let source;
118
+ try {
119
+ source = readFileSync(target, 'utf8');
120
+ }
121
+ catch (error) {
122
+ lines.push(t('plugins-check-invalid-json', { err: cell(error instanceof Error ? error.message : String(error)) }));
123
+ return lines;
124
+ }
125
+ const data = loadSpecData();
126
+ if (data === undefined) {
127
+ lines.push(t('plugins-check-spec-unavailable'));
128
+ return lines;
129
+ }
130
+ let manifest;
131
+ try {
132
+ manifest = parseManifest(source, { source: target });
133
+ // Projection is an explicit admission stage. validatePlugin performs its
134
+ // own defensive projection too, but keeping this call here makes parser
135
+ // and projection failures distinguishable at the user-facing boundary.
136
+ projectManifest(manifest);
137
+ }
138
+ catch (error) {
139
+ const message = cell(error instanceof Error ? error.message : String(error));
140
+ lines.push(error instanceof SyntaxError
141
+ ? t('plugins-check-invalid-json', { err: message })
142
+ : t('plugins-check-schema-failed', { err: message }));
143
+ return lines;
144
+ }
145
+ const index = createContractIndex(data.registry, data.permissions);
146
+ try {
147
+ validatePlugin(index, manifest);
148
+ }
149
+ catch (error) {
150
+ lines.push(t('plugins-check-invalid', { err: cell(error instanceof Error ? error.message : String(error)) }));
151
+ return lines;
152
+ }
153
+ const host = deps.host ?? buildHostDescriptor({ generationId: 'plugins-check' });
154
+ const granted = manifest.permissions
155
+ .map(request => ({
156
+ name: request.name,
157
+ scope: request.scope,
158
+ // `/plugins check` has no live activation instance. Passing an
159
+ // activation-less principal makes GrantStore fail closed when policy
160
+ // contains activation-scoped rules instead of treating them as global.
161
+ granted: deps.grants.allows({ componentId: manifest.id }, request.name, request.scope),
162
+ }));
163
+ const decision = negotiate(index, manifest, host.descriptor, granted);
164
+ lines.push(...decisionLines(decision));
165
+ if (host.dropped.length > 0) {
166
+ lines.push(t('plugins-check-dropped', { dropped: cell(host.dropped.join(', ')) }));
167
+ }
168
+ return lines;
169
+ }
170
+ function decisionLines(decision) {
171
+ switch (decision.decision) {
172
+ case 'compatible':
173
+ return [t('plugins-check-state', { state: 'compatible' })];
174
+ case 'compatible_degraded':
175
+ return [t('plugins-check-state', {
176
+ state: `compatible_degraded (missingOptional: ${cell(decision.missingOptional.join(', '))})`,
177
+ })];
178
+ case 'waiting_authorization':
179
+ return [t('plugins-check-state', {
180
+ state: `waiting_authorization (${cell(decision.reasonCode)}: ${cell(decision.deniedPermissions.join(', '))})`,
181
+ })];
182
+ case 'rejected': {
183
+ const detail = decision.missingRequired !== undefined
184
+ ? `${cell(decision.reasonCode)}: ${cell(decision.missingRequired.join(', '))}`
185
+ : `${cell(decision.reasonCode)}: facet ${cell(decision.facetApiVersion)} vs host [${cell((decision.hostFacetApiVersions ?? []).join(', '))}]`;
186
+ return [t('plugins-check-state', { state: `rejected (${detail})` })];
187
+ }
188
+ case 'unknown':
189
+ return [t('plugins-check-state', {
190
+ state: `unknown (${cell(decision.reasonCode)}: ${cell(decision.unknownContracts.join(', '))})`,
191
+ })];
192
+ }
193
+ }
194
+ /** The `/plugins` overview lines (banner always first). */
195
+ export function pluginsInfoLines(args, deps) {
196
+ const lines = [t('plugins-trust-banner')];
197
+ const trimmed = args.trim();
198
+ if (trimmed !== '') {
199
+ const [sub, ...rest] = trimmed.split(/\s+/);
200
+ if (sub === 'check') {
201
+ const pathArg = rest.join(' ');
202
+ if (pathArg === '') {
203
+ lines.push(t('plugins-check-usage'));
204
+ return lines;
205
+ }
206
+ lines.push(...checkManifestLines(pathArg, deps));
207
+ return lines;
208
+ }
209
+ lines.push(t('plugins-unknown-subcommand', { sub: cell(sub) }));
210
+ return lines;
211
+ }
212
+ const dataDir = deps.dataDir ?? DATA_DIR;
213
+ const ledgerFile = deps.ledgerFile ?? EFFECT_LEDGER_FILE;
214
+ const storageDir = deps.storageDir ?? join(dataDir, PLUGIN_STORAGE_DIR);
215
+ // ── Host Descriptor ──
216
+ if (deps.host === undefined) {
217
+ lines.push(t('plugins-host-unavailable'));
218
+ }
219
+ else {
220
+ const { descriptor, dropped } = deps.host;
221
+ lines.push(`Host Descriptor: ${cell(descriptor.hostId)} v${cell(descriptor.hostVersion)} · generation ${cell(descriptor.runtime.generationId)}`);
222
+ lines.push(` facets: ${cell(descriptor.facetApiVersions.join(', ') || '—')}`);
223
+ for (const contract of descriptor.contracts) {
224
+ const definition = contract.definition.source === 'dsh-std'
225
+ ? contract.definition.package
226
+ : contract.definition.profileHash.slice(0, 19) + '…';
227
+ lines.push(` ${cell(contract.apiVersion)}#${cell(contract.kind)} · definition ${cell(definition)} · perms ${cell(contract.permissions.join(', ') || '—')}`);
228
+ }
229
+ for (const coordinate of dropped) {
230
+ lines.push(` ${cell(coordinate)} · ${t('plugins-contract-dropped')}`);
231
+ }
232
+ }
233
+ // ── 授权矩阵 ──
234
+ const plugins = footprintPlugins(deps, dataDir, ledgerFile, storageDir);
235
+ lines.push(t('plugins-matrix-note'));
236
+ const permissions = deps.grants.knownPermissions();
237
+ if (permissions.length === 0) {
238
+ lines.push(` ${t('plugins-matrix-no-registry')}`);
239
+ }
240
+ else if (plugins.length === 0) {
241
+ lines.push(` ${t('plugins-matrix-empty')}`);
242
+ }
243
+ else {
244
+ lines.push(` ${permissions.map((permission, index) => `[${index + 1}] ${cell(permission)}`).join(' ')}`);
245
+ const shown = plugins.slice(0, PLUGINS_MATRIX_MAX_ROWS);
246
+ const width = Math.max(...shown.map(plugin => plugin.length), 8);
247
+ for (const plugin of shown) {
248
+ const diagnosticScope = (permission) => {
249
+ if (permission === 'storage.local.read' || permission === 'storage.local.write')
250
+ return plugin;
251
+ if (permission === 'commands.invoke')
252
+ return 'diagnostic.command';
253
+ return 'session:*';
254
+ };
255
+ const marks = permissions.map(permission => (deps.grants.allows({ componentId: plugin }, permission, diagnosticScope(permission)) ? '✓' : '·')).join(' ');
256
+ lines.push(` ${cell(plugin).padEnd(width)} ${marks}`);
257
+ }
258
+ if (plugins.length > shown.length) {
259
+ lines.push(` ${t('plugins-footprint-overflow', { count: plugins.length - shown.length })}`);
260
+ }
261
+ }
262
+ // ── 台账尾 ──
263
+ const records = readLedgerRecords(ledgerFile);
264
+ if (records.length === 0) {
265
+ lines.push(t('plugins-ledger-empty'));
266
+ }
267
+ else {
268
+ lines.push(t('plugins-ledger-header', { file: cell(ledgerFile) }));
269
+ for (const record of records.slice(-PLUGINS_LEDGER_TAIL)) {
270
+ const resource = record.resource ?? {};
271
+ lines.push(` #${cell(record.sequence)} ${cell(record.operation)} ${cell(resource.kind)}/${cell(resource.id)} ` +
272
+ `${cell(record.pluginId)} ${cell(record.result)}${typeof record.errorCode === 'string' ? ` (${cell(record.errorCode)})` : ''}`);
273
+ }
274
+ }
275
+ return lines;
276
+ }
@@ -0,0 +1,10 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ export declare const PROMPT_DEBUG_FILENAME = ".dsh-prompt-debug.json";
3
+ /**
4
+ * Register `/debug-prompt` and retain every final request observed for each
5
+ * live session. The command writes one private, atomic snapshot into the
6
+ * receiving session's workspace; it never records credentials, transport
7
+ * headers, or AbortSignals.
8
+ */
9
+ export declare function registerPromptDebug(ctx: Context): void;
10
+ //# sourceMappingURL=promptDebug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptDebug.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/promptDebug.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAMlD,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;AAmF7D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA4FtD"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * On-demand capture of every final AgentLoop request context observed for a
3
+ * live session.
4
+ *
5
+ * The LLM waterfall is the last provider-neutral boundary before adapter
6
+ * dispatch. Capturing there records the fully assembled system prompt,
7
+ * messages, and tool schemas after prompt/tool plugins have contributed.
8
+ * @module @deepseek-harness-tui/dsh-tui/prompt-debug
9
+ */
10
+ import { join, resolve } from 'node:path';
11
+ import { writeFileAtomic } from '@deepseek-ai/dsh-atomic-write';
12
+ import { isAgentLoopRequest } from '@deepseek-ai/dsh-llm';
13
+ export const PROMPT_DEBUG_FILENAME = '.dsh-prompt-debug.json';
14
+ function latestPosition(agent) {
15
+ for (let index = agent.session.events.length - 1; index >= 0; index -= 1) {
16
+ const event = agent.session.events[index];
17
+ if (event?.type === 'step/start')
18
+ return event.data;
19
+ }
20
+ return undefined;
21
+ }
22
+ function latestRequestHeaderReason(agent) {
23
+ for (let index = agent.session.events.length - 1; index >= 0; index -= 1) {
24
+ const event = agent.session.events[index];
25
+ if (event?.type === 'request/header')
26
+ return event.data.reason;
27
+ }
28
+ return undefined;
29
+ }
30
+ function turnCompleted(agent, turn) {
31
+ return agent.session.events.some(event => event.type === 'turn/end' && event.data.turn === turn);
32
+ }
33
+ function captureRequest(agent, options, requestIndex, position, attempt) {
34
+ const requestHeaderReason = latestRequestHeaderReason(agent);
35
+ return {
36
+ capturedAt: new Date().toISOString(),
37
+ requestIndex,
38
+ ...position,
39
+ attempt,
40
+ ...(requestHeaderReason === undefined ? {} : { requestHeaderReason }),
41
+ finalLlmContext: {
42
+ provider: options.provider,
43
+ model: options.model,
44
+ ...(options.reasoningEffort === undefined ? {} : { reasoningEffort: options.reasoningEffort }),
45
+ ...(options.system === undefined ? {} : { system: options.system }),
46
+ messages: options.messages,
47
+ ...(options.tools === undefined ? {} : { tools: options.tools }),
48
+ ...(options.temperature === undefined ? {} : { temperature: options.temperature }),
49
+ ...(options.maxTokens === undefined ? {} : { maxTokens: options.maxTokens }),
50
+ ...(options.stop === undefined ? {} : { stop: options.stop }),
51
+ },
52
+ };
53
+ }
54
+ /**
55
+ * Register `/debug-prompt` and retain every final request observed for each
56
+ * live session. The command writes one private, atomic snapshot into the
57
+ * receiving session's workspace; it never records credentials, transport
58
+ * headers, or AbortSignals.
59
+ */
60
+ export function registerPromptDebug(ctx) {
61
+ const commands = ctx.get('commands');
62
+ const agents = ctx.get('agents');
63
+ if (commands === undefined || agents === undefined || ctx.get('llm') === undefined)
64
+ return;
65
+ const captureStartedAt = new Date().toISOString();
66
+ const captures = new Map();
67
+ ctx.on('llm/stream', (options, next) => {
68
+ if (!isAgentLoopRequest(options) || options.sessionId === undefined)
69
+ return next();
70
+ const agent = agents.get(options.sessionId);
71
+ if (agent === undefined)
72
+ return next();
73
+ const position = latestPosition(agent);
74
+ if (position === undefined)
75
+ return next();
76
+ const sessionId = String(options.sessionId);
77
+ const capture = captures.get(sessionId) ?? { requests: [] };
78
+ if (!captures.has(sessionId))
79
+ captures.set(sessionId, capture);
80
+ const previous = capture.requests.findLast(request => request.turn === position.turn && request.step === position.step);
81
+ const attempt = (previous?.attempt ?? 0) + 1;
82
+ capture.requests.push(captureRequest(agent, options, capture.requests.length + 1, position, attempt));
83
+ return next();
84
+ });
85
+ // Replaced agents are no longer addressable by `/debug-prompt`; release
86
+ // their potentially large message/tool snapshots with the agent lifecycle.
87
+ ctx.on('agent/disposed', ({ agent }) => {
88
+ captures.delete(String(agent.session.id));
89
+ });
90
+ ctx.effect(() => commands.register({
91
+ name: 'debug-prompt',
92
+ description: 'Write every observed final LLM request context for this session to the workspace root',
93
+ recordInput: false,
94
+ handler: async ({ agent, rawInput }) => {
95
+ if (rawInput.trim().length > 0) {
96
+ return { kind: 'error', text: 'Usage: /debug-prompt' };
97
+ }
98
+ const sessionId = String(agent.session.id);
99
+ const capture = captures.get(sessionId);
100
+ if (capture === undefined || capture.requests.length === 0) {
101
+ return {
102
+ kind: 'error',
103
+ text: 'No final LLM request is available for this session. Send one prompt, wait for it to finish, then run /debug-prompt.',
104
+ };
105
+ }
106
+ const latest = capture.requests.at(-1);
107
+ if (!turnCompleted(agent, latest.turn)) {
108
+ return { kind: 'error', text: 'The latest model turn is still running. Wait for it to finish, then run /debug-prompt.' };
109
+ }
110
+ const root = resolve(agent.session.header.cwd ?? process.cwd());
111
+ const output = join(root, PROMPT_DEBUG_FILENAME);
112
+ const turns = new Map();
113
+ for (const request of capture.requests) {
114
+ const turn = turns.get(request.turn) ?? { turn: request.turn, requests: [] };
115
+ if (!turns.has(request.turn))
116
+ turns.set(request.turn, turn);
117
+ turn.requests.push(request);
118
+ }
119
+ const document = {
120
+ schemaVersion: 2,
121
+ generatedAt: new Date().toISOString(),
122
+ captureStartedAt,
123
+ captureScope: 'Requests observed by this dsh-tui process; requests from before a session resume cannot be reconstructed.',
124
+ warning: 'Sensitive debug data: contains system prompts, conversation messages, tool schemas, and tool results. It intentionally excludes credentials and transport headers.',
125
+ sessionId,
126
+ turnCount: turns.size,
127
+ requestCount: capture.requests.length,
128
+ turns: [...turns.values()].map(turn => ({
129
+ ...turn,
130
+ requestCount: turn.requests.length,
131
+ })),
132
+ };
133
+ try {
134
+ await writeFileAtomic(output, `${JSON.stringify(document, null, 2)}\n`, { mode: 0o600 });
135
+ }
136
+ catch (error) {
137
+ return {
138
+ kind: 'error',
139
+ text: `Could not write prompt debug file: ${error instanceof Error ? error.message : String(error)}`,
140
+ };
141
+ }
142
+ return {
143
+ kind: 'success',
144
+ text: `Wrote ${capture.requests.length} final LLM request${capture.requests.length === 1 ? '' : 's'} to ${output}. The file contains sensitive conversation and prompt data.`,
145
+ };
146
+ },
147
+ }));
148
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Custom session-entry renderers — pi's `pi.registerMessageRenderer`. A
3
+ * plugin that appends its own log-only session events (`session.append(
4
+ * 'my-plugin/event', payload)`) registers a renderer mapping the payload to
5
+ * plain TEXT rows; the channel then projects those events into the
6
+ * transcript on the live stream and on replay (resume/rewind), exactly like
7
+ * its built-in projection of `activity/status` or `agent-preset/selected`.
8
+ *
9
+ * Renderers are text-only by design: the full-React surface is the scenes
10
+ * seam (`ctx.tuiScenes`, with the host-React contract); transcript rows are
11
+ * shared with replay paths where a crash mid-replay would corrupt the whole
12
+ * screen, so a renderer never receives React and its output is sanitized
13
+ * (control chars stripped, lines preview-clipped like `pushLocal` output).
14
+ *
15
+ * Registration rules (untrusted-input discipline):
16
+ *
17
+ * - The type must look like `plugin/event` (kebab, one slash) — this is the
18
+ * same shape the session-log strict registry expects plugins to register.
19
+ * - Core vocabulary is off-limits: a renderer can never shadow a built-in
20
+ * event type's projection (locals win, same as commands).
21
+ * - A renderer that throws is skipped for THAT event and logged once per
22
+ * type — replay must survive a buggy plugin.
23
+ */
24
+ import { Context, Service } from '@deepseek-ai/cordis';
25
+ /** What a renderer returns: an optional title row plus body lines. */
26
+ export interface TuiEntryRenderResult {
27
+ /** Short heading (rendered as a notice row); omit for a body-only entry. */
28
+ title?: string;
29
+ /** Body rows, oldest-to-newest reading order. */
30
+ lines: readonly string[];
31
+ }
32
+ export type TuiEntryRenderer = (payload: unknown) => TuiEntryRenderResult | undefined;
33
+ declare module '@deepseek-ai/cordis' {
34
+ interface Context {
35
+ tuiRenderers: TuiRendererRuntime;
36
+ }
37
+ }
38
+ /** `ctx.tuiRenderers` — custom session-entry text renderers. */
39
+ export declare class TuiRendererRuntime extends Service {
40
+ private readonly renderers;
41
+ private readonly failedTypes;
42
+ constructor(ctx: Context);
43
+ /**
44
+ * Map a log-only session event type to transcript rows. Returns the
45
+ * dispose function (caller scopes it with `ctx.effect`, same contract as
46
+ * `tuiScenes`). Refusals warn instead of throwing. The optional trailing
47
+ * `identity` (the plugin's own ctx) only feeds the effect ledger's
48
+ * pluginId — omitting it records `undeclared` (C-060).
49
+ */
50
+ register(type: string, renderer: TuiEntryRenderer, identity?: Context): () => void;
51
+ /**
52
+ * Project one event; undefined when no renderer applies, the renderer has
53
+ * no opinion, or it failed (failure is sticky-logged once per type so a
54
+ * replayed log does not spam the warn stream per event).
55
+ *
56
+ * The result is validated and sanitized INSIDE the try boundary: the title
57
+ * must be a string (anything else is dropped — a non-string would crash
58
+ * the React render path), lines are kept to scalars, control chars are
59
+ * stripped, and the count/width caps bound what a replay can synchronously
60
+ * lay out.
61
+ */
62
+ render(type: string, payload: unknown): TuiEntryRenderResult | undefined;
63
+ }
64
+ export default TuiRendererRuntime;
65
+ //# sourceMappingURL=renderers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderers.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/renderers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAItD,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iDAAiD;IACjD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CACzB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,oBAAoB,GAAG,SAAS,CAAA;AAsBrF,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,YAAY,EAAE,kBAAkB,CAAA;KACjC;CACF;AAED,gEAAgE;AAChE,qBAAa,kBAAmB,SAAQ,OAAO;IAC7C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsC;IAChE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;gBAEpC,GAAG,EAAE,OAAO;IAIxB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,IAAI;IA+ClF;;;;;;;;;;OAUG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS;CAwBzE;AAED,eAAe,kBAAkB,CAAA"}
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Custom session-entry renderers — pi's `pi.registerMessageRenderer`. A
3
+ * plugin that appends its own log-only session events (`session.append(
4
+ * 'my-plugin/event', payload)`) registers a renderer mapping the payload to
5
+ * plain TEXT rows; the channel then projects those events into the
6
+ * transcript on the live stream and on replay (resume/rewind), exactly like
7
+ * its built-in projection of `activity/status` or `agent-preset/selected`.
8
+ *
9
+ * Renderers are text-only by design: the full-React surface is the scenes
10
+ * seam (`ctx.tuiScenes`, with the host-React contract); transcript rows are
11
+ * shared with replay paths where a crash mid-replay would corrupt the whole
12
+ * screen, so a renderer never receives React and its output is sanitized
13
+ * (control chars stripped, lines preview-clipped like `pushLocal` output).
14
+ *
15
+ * Registration rules (untrusted-input discipline):
16
+ *
17
+ * - The type must look like `plugin/event` (kebab, one slash) — this is the
18
+ * same shape the session-log strict registry expects plugins to register.
19
+ * - Core vocabulary is off-limits: a renderer can never shadow a built-in
20
+ * event type's projection (locals win, same as commands).
21
+ * - A renderer that throws is skipped for THAT event and logged once per
22
+ * type — replay must survive a buggy plugin.
23
+ */
24
+ import { Service } from '@deepseek-ai/cordis';
25
+ import { KNOWN_SESSION_EVENT_TYPES } from '@deepseek-ai/dsh-session';
26
+ import { cleanRenderText } from './sanitize.js';
27
+ const TYPE_PATTERN = /^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/u;
28
+ /**
29
+ * The built-in session-event vocabulary, FROZEN at module load. The live
30
+ * KNOWN_SESSION_EVENT_TYPES set cannot serve as this denylist: a plugin
31
+ * persisting custom events MUST add its types to that set (seam 1's hard
32
+ * rule), so by the time it registers a renderer for `my-plugin/note`, the
33
+ * mutable set already contains `my-plugin/note` — checking against it would
34
+ * reject exactly the types this seam exists for. The module-load snapshot
35
+ * (this service's row mounts before any plugin row) is the built-in truth.
36
+ */
37
+ const BUILTIN_SESSION_EVENT_TYPES = new Set(KNOWN_SESSION_EVENT_TYPES);
38
+ /** Output bounds (render-path hygiene): a renderer runs on the REPLAY path
39
+ * too, where an unbounded result would synchronously create thousands of
40
+ * transcript rows. Sanitization itself lives in ./sanitize.js. */
41
+ const MAX_RENDER_LINES = 100;
42
+ const TITLE_CELLS = 120;
43
+ const LINE_CELLS = 400;
44
+ /** `ctx.tuiRenderers` — custom session-entry text renderers. */
45
+ export class TuiRendererRuntime extends Service {
46
+ renderers = new Map();
47
+ failedTypes = new Set();
48
+ constructor(ctx) {
49
+ super(ctx, 'tuiRenderers');
50
+ }
51
+ /**
52
+ * Map a log-only session event type to transcript rows. Returns the
53
+ * dispose function (caller scopes it with `ctx.effect`, same contract as
54
+ * `tuiScenes`). Refusals warn instead of throwing. The optional trailing
55
+ * `identity` (the plugin's own ctx) only feeds the effect ledger's
56
+ * pluginId — omitting it records `undeclared` (C-060).
57
+ */
58
+ register(type, renderer, identity) {
59
+ const normalized = String(type ?? '').trim().toLowerCase();
60
+ if (!TYPE_PATTERN.test(normalized)) {
61
+ this.ctx.logger.warn(`dsh-tui: tuiRenderers.register rejected invalid event type ${JSON.stringify(type)}`);
62
+ return () => { };
63
+ }
64
+ // The channel's own projection (its renderEvent switch plus special-
65
+ // cased plugin events like agent-preset/selected) always wins. The check
66
+ // uses the module-load snapshot of the built-in vocabulary — NOT the live
67
+ // KNOWN_SESSION_EVENT_TYPES, which plugins must extend with their own
68
+ // types (see BUILTIN_SESSION_EVENT_TYPES above).
69
+ if (BUILTIN_SESSION_EVENT_TYPES.has(normalized) || normalized === 'agent-preset/selected') {
70
+ this.ctx.logger.warn(`dsh-tui: tuiRenderers.register rejected "${normalized}" — built-in event types keep their own projection`);
71
+ return () => { };
72
+ }
73
+ if (this.renderers.has(normalized)) {
74
+ this.ctx.logger.warn(`dsh-tui: tuiRenderers.register rejected "${normalized}" — already registered`);
75
+ this.ctx.get('tuiEffectLedger')?.record({
76
+ operation: 'create',
77
+ resource: { kind: 'renderer', id: normalized },
78
+ result: 'failed',
79
+ errorCode: 'DUPLICATE_CONTRIBUTION_ID',
80
+ }, identity);
81
+ return () => { };
82
+ }
83
+ if (typeof renderer !== 'function') {
84
+ this.ctx.logger.warn(`dsh-tui: tuiRenderers.register rejected "${normalized}" — renderer must be a function`);
85
+ return () => { };
86
+ }
87
+ this.renderers.set(normalized, renderer);
88
+ this.ctx.get('tuiEffectLedger')?.record({ operation: 'create', resource: { kind: 'renderer', id: normalized }, result: 'applied' }, identity);
89
+ return () => {
90
+ if (this.renderers.get(normalized) !== renderer)
91
+ return;
92
+ this.renderers.delete(normalized);
93
+ this.ctx.get('tuiEffectLedger')?.record({ operation: 'release', resource: { kind: 'renderer', id: normalized }, result: 'applied' }, identity);
94
+ };
95
+ }
96
+ /**
97
+ * Project one event; undefined when no renderer applies, the renderer has
98
+ * no opinion, or it failed (failure is sticky-logged once per type so a
99
+ * replayed log does not spam the warn stream per event).
100
+ *
101
+ * The result is validated and sanitized INSIDE the try boundary: the title
102
+ * must be a string (anything else is dropped — a non-string would crash
103
+ * the React render path), lines are kept to scalars, control chars are
104
+ * stripped, and the count/width caps bound what a replay can synchronously
105
+ * lay out.
106
+ */
107
+ render(type, payload) {
108
+ const renderer = this.renderers.get(type);
109
+ if (renderer === undefined)
110
+ return undefined;
111
+ try {
112
+ const result = renderer(payload);
113
+ if (result === undefined)
114
+ return undefined;
115
+ const raw = result;
116
+ if (!Array.isArray(raw.lines))
117
+ return undefined;
118
+ const lines = [];
119
+ for (const line of raw.lines) {
120
+ if (lines.length >= MAX_RENDER_LINES)
121
+ break;
122
+ if (typeof line !== 'string' && typeof line !== 'number' && typeof line !== 'boolean')
123
+ continue;
124
+ lines.push(cleanRenderText(String(line), LINE_CELLS));
125
+ }
126
+ const title = typeof raw.title === 'string' ? cleanRenderText(raw.title, TITLE_CELLS) : undefined;
127
+ return { ...(title === undefined || title === '' ? {} : { title }), lines };
128
+ }
129
+ catch (error) {
130
+ if (!this.failedTypes.has(type)) {
131
+ this.failedTypes.add(type);
132
+ this.ctx.logger.warn(`dsh-tui: renderer for "${type}" threw; its entries are skipped: %o`, error);
133
+ }
134
+ return undefined;
135
+ }
136
+ }
137
+ }
138
+ export default TuiRendererRuntime;