@deepseek-ai/dsh-client-ui-chat 0.2.2-rc.1 → 0.2.2-rc.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 (355) hide show
  1. package/README.i18n.yaml +16 -16
  2. package/README.md +17 -5
  3. package/README.zh.md +17 -5
  4. package/lib/client.js +18 -15587
  5. package/lib/client.js.map +1 -0
  6. package/lib/types/chat-settings.d.ts.map +1 -0
  7. package/lib/types/chat-settings.js.map +1 -0
  8. package/lib/types/client/apply.d.ts.map +1 -0
  9. package/lib/types/client/apply.js.map +1 -0
  10. package/lib/types/client/chat/ApprovalCommand.d.ts +4 -3
  11. package/lib/types/client/chat/ApprovalCommand.d.ts.map +1 -0
  12. package/lib/types/client/chat/ApprovalCommand.js.map +1 -0
  13. package/lib/types/client/chat/AssistantMarkdown.d.ts.map +1 -0
  14. package/lib/types/client/chat/AssistantMarkdown.js.map +1 -0
  15. package/lib/types/client/chat/AssistantNodeView.d.ts.map +1 -0
  16. package/lib/types/client/chat/AssistantNodeView.js.map +1 -0
  17. package/lib/types/client/chat/ChatFlow.d.ts.map +1 -0
  18. package/lib/types/client/chat/ChatFlow.js.map +1 -0
  19. package/lib/types/client/chat/ChatGroupSeat.d.ts.map +1 -0
  20. package/lib/types/client/chat/ChatGroupSeat.js.map +1 -0
  21. package/lib/types/client/chat/ChatNodeSeat.d.ts.map +1 -0
  22. package/lib/types/client/chat/ChatNodeSeat.js.map +1 -0
  23. package/lib/types/client/chat/ChatView.d.ts +1 -1
  24. package/lib/types/client/chat/ChatView.d.ts.map +1 -0
  25. package/lib/types/client/chat/ChatView.js.map +1 -0
  26. package/lib/types/client/chat/CommandNodeView.d.ts.map +1 -0
  27. package/lib/types/client/chat/CommandNodeView.js.map +1 -0
  28. package/lib/types/client/chat/CompactionCommandCard.d.ts.map +1 -0
  29. package/lib/types/client/chat/CompactionCommandCard.js.map +1 -0
  30. package/lib/types/client/chat/CompactionItem.d.ts.map +1 -0
  31. package/lib/types/client/chat/CompactionItem.js.map +1 -0
  32. package/lib/types/client/chat/ContextBody.d.ts.map +1 -0
  33. package/lib/types/client/chat/ContextBody.js.map +1 -0
  34. package/lib/types/client/chat/ContextInjectionRow.d.ts.map +1 -0
  35. package/lib/types/client/chat/ContextInjectionRow.js.map +1 -0
  36. package/lib/types/client/chat/GenericCommandCard.d.ts.map +1 -0
  37. package/lib/types/client/chat/GenericCommandCard.js.map +1 -0
  38. package/lib/types/client/chat/MessageIconActions.d.ts.map +1 -0
  39. package/lib/types/client/chat/MessageIconActions.js.map +1 -0
  40. package/lib/types/client/chat/MessageItem.d.ts.map +1 -0
  41. package/lib/types/client/chat/MessageItem.js.map +1 -0
  42. package/lib/types/client/chat/QuotaNoticeHost.d.ts.map +1 -0
  43. package/lib/types/client/chat/QuotaNoticeHost.js.map +1 -0
  44. package/lib/types/client/chat/ReasoningContent.d.ts.map +1 -0
  45. package/lib/types/client/chat/ReasoningContent.js.map +1 -0
  46. package/lib/types/client/chat/ReasoningRow.d.ts.map +1 -0
  47. package/lib/types/client/chat/ReasoningRow.js.map +1 -0
  48. package/lib/types/client/chat/RunningStatus.d.ts.map +1 -0
  49. package/lib/types/client/chat/RunningStatus.js.map +1 -0
  50. package/lib/types/client/chat/RunningWhaleTail.d.ts.map +1 -0
  51. package/lib/types/client/chat/RunningWhaleTail.js.map +1 -0
  52. package/lib/types/client/chat/StatsPills.d.ts.map +1 -0
  53. package/lib/types/client/chat/StatsPills.js.map +1 -0
  54. package/lib/types/client/chat/SystemPromptRow.d.ts.map +1 -0
  55. package/lib/types/client/chat/SystemPromptRow.js.map +1 -0
  56. package/lib/types/client/chat/TurnNavigator.d.ts.map +1 -0
  57. package/lib/types/client/chat/TurnNavigator.js.map +1 -0
  58. package/lib/types/client/chat/TurnProcessNodeView.d.ts.map +1 -0
  59. package/lib/types/client/chat/TurnProcessNodeView.js.map +1 -0
  60. package/lib/types/client/chat/TurnTailNodeView.d.ts.map +1 -0
  61. package/lib/types/client/chat/TurnTailNodeView.js.map +1 -0
  62. package/lib/types/client/chat/TurnTriggerNodeView.d.ts.map +1 -0
  63. package/lib/types/client/chat/TurnTriggerNodeView.js.map +1 -0
  64. package/lib/types/client/chat/TurnUsagePanel.d.ts.map +1 -0
  65. package/lib/types/client/chat/TurnUsagePanel.js.map +1 -0
  66. package/lib/types/client/chat/UserContent.d.ts.map +1 -0
  67. package/lib/types/client/chat/UserContent.js.map +1 -0
  68. package/lib/types/client/chat/flow-motion.d.ts +2 -0
  69. package/lib/types/client/chat/flow-motion.d.ts.map +1 -0
  70. package/lib/types/client/chat/flow-motion.js.map +1 -0
  71. package/lib/types/client/chat/message-chrome.d.ts.map +1 -0
  72. package/lib/types/client/chat/message-chrome.js.map +1 -0
  73. package/lib/types/client/chat/register-node-renderers.d.ts.map +1 -0
  74. package/lib/types/client/chat/register-node-renderers.js.map +1 -0
  75. package/lib/types/client/chat/render-entry.d.ts.map +1 -0
  76. package/lib/types/client/chat/render-entry.js.map +1 -0
  77. package/lib/types/client/chat/searchable-hidden.d.ts.map +1 -0
  78. package/lib/types/client/chat/searchable-hidden.js.map +1 -0
  79. package/lib/types/client/chat/stat-dialog.d.ts +5 -10
  80. package/lib/types/client/chat/stat-dialog.d.ts.map +1 -0
  81. package/lib/types/client/chat/stat-dialog.js.map +1 -0
  82. package/lib/types/client/chat/step-process.d.ts.map +1 -0
  83. package/lib/types/client/chat/step-process.js.map +1 -0
  84. package/lib/types/client/chat/text-interaction.d.ts.map +1 -0
  85. package/lib/types/client/chat/text-interaction.js.map +1 -0
  86. package/lib/types/client/chat/text-selection.d.ts.map +1 -0
  87. package/lib/types/client/chat/text-selection.js.map +1 -0
  88. package/lib/types/client/chat/token-format.d.ts.map +1 -0
  89. package/lib/types/client/chat/token-format.js.map +1 -0
  90. package/lib/types/client/chat/turn-assistant.d.ts.map +1 -0
  91. package/lib/types/client/chat/turn-assistant.js.map +1 -0
  92. package/lib/types/client/chat/turn-rail-items.d.ts.map +1 -0
  93. package/lib/types/client/chat/turn-rail-items.js.map +1 -0
  94. package/lib/types/client/chat/turn-trigger.d.ts +3 -2
  95. package/lib/types/client/chat/turn-trigger.d.ts.map +1 -0
  96. package/lib/types/client/chat/turn-trigger.js.map +1 -0
  97. package/lib/types/client/chat/use-calendar-day.d.ts.map +1 -0
  98. package/lib/types/client/chat/use-calendar-day.js.map +1 -0
  99. package/lib/types/client/chat/use-chat-navigation.d.ts +21 -5
  100. package/lib/types/client/chat/use-chat-navigation.d.ts.map +1 -0
  101. package/lib/types/client/chat/use-chat-navigation.js.map +1 -0
  102. package/lib/types/client/chat/use-chat-reading.d.ts.map +1 -0
  103. package/lib/types/client/chat/use-chat-reading.js.map +1 -0
  104. package/lib/types/client/chat/use-chat-scroll.d.ts +5 -2
  105. package/lib/types/client/chat/use-chat-scroll.d.ts.map +1 -0
  106. package/lib/types/client/chat/use-chat-scroll.js.map +1 -0
  107. package/lib/types/client/chat/use-chat-viewport.d.ts +53 -0
  108. package/lib/types/client/chat/use-chat-viewport.d.ts.map +1 -0
  109. package/lib/types/client/chat/use-chat-viewport.js.map +1 -0
  110. package/lib/types/client/chat/use-disclosure.d.ts.map +1 -0
  111. package/lib/types/client/chat/use-disclosure.js.map +1 -0
  112. package/lib/types/client/chat/use-process-scroll.d.ts.map +1 -0
  113. package/lib/types/client/chat/use-process-scroll.js.map +1 -0
  114. package/lib/types/client/chat/use-scroll-follow.d.ts.map +1 -0
  115. package/lib/types/client/chat/use-scroll-follow.js.map +1 -0
  116. package/lib/types/client/chat/use-turn-data.d.ts.map +1 -0
  117. package/lib/types/client/chat/use-turn-data.js.map +1 -0
  118. package/lib/types/client/contract/assistant-content.d.ts.map +1 -0
  119. package/lib/types/client/contract/assistant-content.js.map +1 -0
  120. package/lib/types/client/contract/chat-nodes.d.ts.map +1 -0
  121. package/lib/types/client/contract/chat-nodes.js.map +1 -0
  122. package/lib/types/client/contract/chat-visibility.d.ts +2 -2
  123. package/lib/types/client/contract/chat-visibility.d.ts.map +1 -0
  124. package/lib/types/client/contract/chat-visibility.js.map +1 -0
  125. package/lib/types/client/contract/group-tree.d.ts.map +1 -0
  126. package/lib/types/client/contract/group-tree.js.map +1 -0
  127. package/lib/types/client/contract/process-groups.d.ts +6 -3
  128. package/lib/types/client/contract/process-groups.d.ts.map +1 -0
  129. package/lib/types/client/contract/process-groups.js.map +1 -0
  130. package/lib/types/client/contract/slots.d.ts +11 -2
  131. package/lib/types/client/contract/slots.d.ts.map +1 -0
  132. package/lib/types/client/contract/slots.js.map +1 -0
  133. package/lib/types/client/contract/snapshot.d.ts.map +1 -0
  134. package/lib/types/client/contract/snapshot.js.map +1 -0
  135. package/lib/types/client/contract/store.d.ts.map +1 -0
  136. package/lib/types/client/contract/store.js.map +1 -0
  137. package/lib/types/client/contract/turn-metrics.d.ts.map +1 -0
  138. package/lib/types/client/contract/turn-metrics.js.map +1 -0
  139. package/lib/types/client/contract/turn-process.d.ts.map +1 -0
  140. package/lib/types/client/contract/turn-process.js.map +1 -0
  141. package/lib/types/client/conversation-nodes/assistant.d.ts.map +1 -0
  142. package/lib/types/client/conversation-nodes/assistant.js.map +1 -0
  143. package/lib/types/client/conversation-nodes/chat-snapshot-builder.d.ts.map +1 -0
  144. package/lib/types/client/conversation-nodes/chat-snapshot-builder.js.map +1 -0
  145. package/lib/types/client/conversation-nodes/command.d.ts.map +1 -0
  146. package/lib/types/client/conversation-nodes/command.js.map +1 -0
  147. package/lib/types/client/conversation-nodes/common.d.ts.map +1 -0
  148. package/lib/types/client/conversation-nodes/common.js.map +1 -0
  149. package/lib/types/client/conversation-nodes/compaction.d.ts.map +1 -0
  150. package/lib/types/client/conversation-nodes/compaction.js.map +1 -0
  151. package/lib/types/client/conversation-nodes/event-projection.d.ts.map +1 -0
  152. package/lib/types/client/conversation-nodes/event-projection.js.map +1 -0
  153. package/lib/types/client/conversation-nodes/fallback.d.ts.map +1 -0
  154. package/lib/types/client/conversation-nodes/fallback.js.map +1 -0
  155. package/lib/types/client/conversation-nodes/group-tree-segments.d.ts.map +1 -0
  156. package/lib/types/client/conversation-nodes/group-tree-segments.js.map +1 -0
  157. package/lib/types/client/conversation-nodes/inbox.d.ts.map +1 -0
  158. package/lib/types/client/conversation-nodes/inbox.js.map +1 -0
  159. package/lib/types/client/conversation-nodes/message.d.ts +1 -1
  160. package/lib/types/client/conversation-nodes/message.d.ts.map +1 -0
  161. package/lib/types/client/conversation-nodes/message.js.map +1 -0
  162. package/lib/types/client/conversation-nodes/process-activity.d.ts +1 -0
  163. package/lib/types/client/conversation-nodes/process-activity.d.ts.map +1 -0
  164. package/lib/types/client/conversation-nodes/process-activity.js.map +1 -0
  165. package/lib/types/client/conversation-nodes/process-groups.d.ts.map +1 -0
  166. package/lib/types/client/conversation-nodes/process-groups.js.map +1 -0
  167. package/lib/types/client/conversation-nodes/register.d.ts.map +1 -0
  168. package/lib/types/client/conversation-nodes/register.js.map +1 -0
  169. package/lib/types/client/conversation-nodes/request-prompt.d.ts.map +1 -0
  170. package/lib/types/client/conversation-nodes/request-prompt.js.map +1 -0
  171. package/lib/types/client/conversation-nodes/retry.d.ts.map +1 -0
  172. package/lib/types/client/conversation-nodes/retry.js.map +1 -0
  173. package/lib/types/client/conversation-nodes/tool.d.ts.map +1 -0
  174. package/lib/types/client/conversation-nodes/tool.js.map +1 -0
  175. package/lib/types/client/conversation-nodes/turn-error.d.ts.map +1 -0
  176. package/lib/types/client/conversation-nodes/turn-error.js.map +1 -0
  177. package/lib/types/client/conversation-nodes/turn-max-tokens.d.ts.map +1 -0
  178. package/lib/types/client/conversation-nodes/turn-max-tokens.js.map +1 -0
  179. package/lib/types/client/conversation-nodes/turn-navigation.d.ts.map +1 -0
  180. package/lib/types/client/conversation-nodes/turn-navigation.js.map +1 -0
  181. package/lib/types/client/conversation-nodes/turn-process-presentation.d.ts.map +1 -0
  182. package/lib/types/client/conversation-nodes/turn-process-presentation.js.map +1 -0
  183. package/lib/types/client/conversation-nodes/turn-process.d.ts.map +1 -0
  184. package/lib/types/client/conversation-nodes/turn-process.js.map +1 -0
  185. package/lib/types/client/conversation-nodes/turn-tail.d.ts.map +1 -0
  186. package/lib/types/client/conversation-nodes/turn-tail.js.map +1 -0
  187. package/lib/types/client/fence/FenceLayers.d.ts +21 -0
  188. package/lib/types/client/fence/FenceLayers.d.ts.map +1 -0
  189. package/lib/types/client/fence/FenceLayers.js.map +1 -0
  190. package/lib/types/client/fence/register.d.ts +10 -0
  191. package/lib/types/client/fence/register.d.ts.map +1 -0
  192. package/lib/types/client/fence/register.js.map +1 -0
  193. package/lib/types/client/file-path.d.ts.map +1 -0
  194. package/lib/types/client/file-path.js.map +1 -0
  195. package/lib/types/client/index.d.ts +1 -1
  196. package/lib/types/client/index.d.ts.map +1 -0
  197. package/lib/types/client/index.js.map +1 -0
  198. package/lib/types/client/locale.d.ts +96 -0
  199. package/lib/types/client/locale.d.ts.map +1 -0
  200. package/lib/types/client/locale.js.map +1 -0
  201. package/lib/types/client/markdown-labels.d.ts.map +1 -0
  202. package/lib/types/client/markdown-labels.js.map +1 -0
  203. package/lib/types/client/model/conversation-context.d.ts.map +1 -0
  204. package/lib/types/client/model/conversation-context.js.map +1 -0
  205. package/lib/types/client/model/steering-history.d.ts.map +1 -0
  206. package/lib/types/client/model/steering-history.js.map +1 -0
  207. package/lib/types/client/model/tool-call-tree.d.ts.map +1 -0
  208. package/lib/types/client/model/tool-call-tree.js.map +1 -0
  209. package/lib/types/client/performance-usage.d.ts.map +1 -0
  210. package/lib/types/client/performance-usage.js.map +1 -0
  211. package/lib/types/client/presentation-policy.d.ts.map +1 -0
  212. package/lib/types/client/presentation-policy.js.map +1 -0
  213. package/lib/types/client/reasoning-text.d.ts.map +1 -0
  214. package/lib/types/client/reasoning-text.js.map +1 -0
  215. package/lib/types/client/settings/LinkOpeningRow.d.ts.map +1 -0
  216. package/lib/types/client/settings/LinkOpeningRow.js.map +1 -0
  217. package/lib/types/client/settings/PerformanceUsageRow.d.ts.map +1 -0
  218. package/lib/types/client/settings/PerformanceUsageRow.js.map +1 -0
  219. package/lib/types/client/settings/PreferenceRow.d.ts.map +1 -0
  220. package/lib/types/client/settings/PreferenceRow.js.map +1 -0
  221. package/lib/types/client/settings/TranscriptViewRow.d.ts.map +1 -0
  222. package/lib/types/client/settings/TranscriptViewRow.js.map +1 -0
  223. package/lib/types/client/stores.d.ts.map +1 -0
  224. package/lib/types/client/stores.js.map +1 -0
  225. package/lib/types/client/transcript-view.d.ts.map +1 -0
  226. package/lib/types/client/transcript-view.js.map +1 -0
  227. package/lib/types/index.d.ts.map +1 -0
  228. package/lib/types/index.js.map +1 -0
  229. package/package.json +44 -41
  230. package/src/chat-settings.ts +98 -0
  231. package/src/client/apply.ts +355 -0
  232. package/src/client/assets/running-whale@2x.png +0 -0
  233. package/src/client/chat/ApprovalCommand.tsx +42 -0
  234. package/src/client/chat/AssistantMarkdown.module.css +88 -0
  235. package/src/client/chat/AssistantMarkdown.tsx +170 -0
  236. package/src/client/chat/AssistantNodeView.tsx +67 -0
  237. package/src/client/chat/ChatFlow.tsx +100 -0
  238. package/src/client/chat/ChatGroupSeat.module.css +166 -0
  239. package/src/client/chat/ChatGroupSeat.tsx +208 -0
  240. package/src/client/chat/ChatNodeSeat.tsx +179 -0
  241. package/src/client/chat/ChatView.module.css +426 -0
  242. package/src/client/chat/ChatView.tsx +351 -0
  243. package/src/client/chat/CommandNodeView.tsx +40 -0
  244. package/src/client/chat/CompactionCommandCard.tsx +26 -0
  245. package/src/client/chat/CompactionItem.tsx +76 -0
  246. package/src/client/chat/ContextBody.module.css +161 -0
  247. package/src/client/chat/ContextBody.tsx +592 -0
  248. package/src/client/chat/ContextInjectionRow.module.css +68 -0
  249. package/src/client/chat/ContextInjectionRow.tsx +94 -0
  250. package/src/client/chat/GenericCommandCard.module.css +49 -0
  251. package/src/client/chat/GenericCommandCard.tsx +75 -0
  252. package/src/client/chat/MessageIconActions.module.css +116 -0
  253. package/src/client/chat/MessageIconActions.tsx +90 -0
  254. package/src/client/chat/MessageItem.module.css +360 -0
  255. package/src/client/chat/MessageItem.tsx +410 -0
  256. package/src/client/chat/QuotaNoticeHost.tsx +27 -0
  257. package/src/client/chat/ReasoningContent.tsx +26 -0
  258. package/src/client/chat/ReasoningRow.module.css +77 -0
  259. package/src/client/chat/ReasoningRow.tsx +112 -0
  260. package/src/client/chat/RunningStatus.tsx +48 -0
  261. package/src/client/chat/RunningWhaleTail.tsx +19 -0
  262. package/src/client/chat/StatsPills.module.css +63 -0
  263. package/src/client/chat/StatsPills.tsx +348 -0
  264. package/src/client/chat/SystemPromptRow.tsx +50 -0
  265. package/src/client/chat/TurnNavigator.module.css +223 -0
  266. package/src/client/chat/TurnNavigator.tsx +295 -0
  267. package/src/client/chat/TurnProcessNodeView.module.css +62 -0
  268. package/src/client/chat/TurnProcessNodeView.tsx +62 -0
  269. package/src/client/chat/TurnTailNodeView.module.css +12 -0
  270. package/src/client/chat/TurnTailNodeView.tsx +81 -0
  271. package/src/client/chat/TurnTriggerNodeView.module.css +50 -0
  272. package/src/client/chat/TurnTriggerNodeView.tsx +57 -0
  273. package/src/client/chat/TurnUsagePanel.module.css +79 -0
  274. package/src/client/chat/TurnUsagePanel.tsx +110 -0
  275. package/src/client/chat/UserContent.tsx +60 -0
  276. package/src/client/chat/accessibility.module.css +8 -0
  277. package/src/client/chat/flow-motion.ts +556 -0
  278. package/src/client/chat/message-chrome.ts +100 -0
  279. package/src/client/chat/register-node-renderers.ts +100 -0
  280. package/src/client/chat/render-entry.ts +16 -0
  281. package/src/client/chat/searchable-hidden.ts +45 -0
  282. package/src/client/chat/stat-dialog.module.css +149 -0
  283. package/src/client/chat/stat-dialog.ts +55 -0
  284. package/src/client/chat/step-process.ts +28 -0
  285. package/src/client/chat/text-interaction.ts +298 -0
  286. package/src/client/chat/text-selection.ts +180 -0
  287. package/src/client/chat/token-format.ts +98 -0
  288. package/src/client/chat/turn-assistant.ts +10 -0
  289. package/src/client/chat/turn-rail-items.ts +89 -0
  290. package/src/client/chat/turn-trigger.ts +88 -0
  291. package/src/client/chat/use-calendar-day.ts +25 -0
  292. package/src/client/chat/use-chat-navigation.ts +309 -0
  293. package/src/client/chat/use-chat-reading.ts +283 -0
  294. package/src/client/chat/use-chat-scroll.ts +209 -0
  295. package/src/client/chat/use-chat-viewport.ts +1130 -0
  296. package/src/client/chat/use-disclosure.ts +35 -0
  297. package/src/client/chat/use-process-scroll.ts +88 -0
  298. package/src/client/chat/use-scroll-follow.ts +182 -0
  299. package/src/client/chat/use-turn-data.ts +23 -0
  300. package/src/client/contract/assistant-content.ts +15 -0
  301. package/src/client/contract/chat-nodes.ts +135 -0
  302. package/src/client/contract/chat-visibility.ts +20 -0
  303. package/src/client/contract/group-tree.ts +37 -0
  304. package/src/client/contract/process-groups.ts +30 -0
  305. package/src/client/contract/slots.ts +508 -0
  306. package/src/client/contract/snapshot.ts +171 -0
  307. package/src/client/contract/store.ts +17 -0
  308. package/src/client/contract/turn-metrics.ts +43 -0
  309. package/src/client/contract/turn-process.ts +58 -0
  310. package/src/client/conversation-nodes/README.i18n.yaml +64 -0
  311. package/src/client/conversation-nodes/README.md +338 -0
  312. package/src/client/conversation-nodes/README.zh.md +338 -0
  313. package/src/client/conversation-nodes/assistant.ts +384 -0
  314. package/src/client/conversation-nodes/chat-snapshot-builder.ts +1244 -0
  315. package/src/client/conversation-nodes/command.ts +227 -0
  316. package/src/client/conversation-nodes/common.ts +83 -0
  317. package/src/client/conversation-nodes/compaction.ts +65 -0
  318. package/src/client/conversation-nodes/event-projection.ts +179 -0
  319. package/src/client/conversation-nodes/fallback.ts +41 -0
  320. package/src/client/conversation-nodes/group-tree-segments.ts +91 -0
  321. package/src/client/conversation-nodes/inbox.ts +148 -0
  322. package/src/client/conversation-nodes/message.ts +182 -0
  323. package/src/client/conversation-nodes/process-activity.ts +170 -0
  324. package/src/client/conversation-nodes/process-groups.ts +303 -0
  325. package/src/client/conversation-nodes/register.ts +38 -0
  326. package/src/client/conversation-nodes/request-prompt.ts +169 -0
  327. package/src/client/conversation-nodes/retry.ts +97 -0
  328. package/src/client/conversation-nodes/tool.ts +371 -0
  329. package/src/client/conversation-nodes/turn-error.ts +120 -0
  330. package/src/client/conversation-nodes/turn-max-tokens.ts +82 -0
  331. package/src/client/conversation-nodes/turn-navigation.ts +97 -0
  332. package/src/client/conversation-nodes/turn-process-presentation.ts +149 -0
  333. package/src/client/conversation-nodes/turn-process.ts +374 -0
  334. package/src/client/conversation-nodes/turn-tail.ts +164 -0
  335. package/src/client/fence/FenceLayers.tsx +33 -0
  336. package/src/client/fence/register.ts +22 -0
  337. package/src/client/file-path.ts +19 -0
  338. package/src/client/index.ts +69 -0
  339. package/src/client/locale.ts +1695 -0
  340. package/src/client/markdown-labels.ts +16 -0
  341. package/src/client/model/conversation-context.ts +24 -0
  342. package/src/client/model/steering-history.ts +64 -0
  343. package/src/client/model/tool-call-tree.ts +204 -0
  344. package/src/client/performance-usage.ts +34 -0
  345. package/src/client/presentation-policy.ts +109 -0
  346. package/src/client/reasoning-text.ts +25 -0
  347. package/src/client/settings/LinkOpeningRow.tsx +47 -0
  348. package/src/client/settings/PerformanceUsageRow.tsx +46 -0
  349. package/src/client/settings/PreferenceRow.module.css +66 -0
  350. package/src/client/settings/PreferenceRow.tsx +59 -0
  351. package/src/client/settings/TranscriptViewRow.tsx +93 -0
  352. package/src/client/stores.ts +62 -0
  353. package/src/client/transcript-view.ts +81 -0
  354. package/src/css-modules.d.ts +6 -0
  355. package/src/index.ts +45 -0
@@ -0,0 +1,303 @@
1
+ /** Chat-owned segmentation and incremental summaries over materialized Node inputs. */
2
+ import { brandString } from '@deepseek-ai/dsh-brand'
3
+ import type {
4
+ ConversationGroupDefinition, ConversationGroupInput, GroupKey, GroupSnapshot,
5
+ GroupUpdate, NodeKey, NodeReference, RenderEntry,
6
+ } from '@deepseek-ai/dsh-client-ui-conversation/client'
7
+ import type { ChatConversationViewNode, ChatNode } from '../contract/chat-nodes.ts'
8
+ import type { ProcessActivitySummary, ProcessGroupData } from '../contract/process-groups.ts'
9
+ import { hasAssistantReplyContent } from '../contract/assistant-content.ts'
10
+ import { isVisibleChatNode } from '../contract/chat-visibility.ts'
11
+ import { isAtOrOutside } from '../contract/group-tree.ts'
12
+ import { processActivity } from './process-activity.ts'
13
+
14
+ type ProcessInput = ConversationGroupInput<ChatConversationViewNode>
15
+
16
+ function turnOf(node: ChatNode): number | undefined {
17
+ const location = node.location
18
+ return location.kind === 'turn' || location.kind === 'step' ? location.turn.turn : undefined
19
+ }
20
+
21
+ function reasoning(node: ChatNode): boolean {
22
+ return node.kind === 'assistant-step'
23
+ && node.data.blocks.some(block => block.kind === 'reasoning' && block.text.trim() !== '')
24
+ }
25
+
26
+ function reply(node: ChatNode): boolean {
27
+ return node.kind === 'assistant-step' && hasAssistantReplyContent(node.data.blocks)
28
+ }
29
+
30
+ function sameSummary(left: ProcessActivitySummary, right: ProcessActivitySummary): boolean {
31
+ return left.running === right.running && left.runningDetail === right.runningDetail
32
+ && left.preparing === right.preparing
33
+ && left.counts.length === right.counts.length && left.counts.every((value, index) =>
34
+ value.kind === right.counts[index]?.kind && value.count === right.counts[index].count)
35
+ }
36
+
37
+ function sameMembers(left: readonly NodeReference[], right: readonly NodeReference[]): boolean {
38
+ return left.length === right.length && left.every((value, index) =>
39
+ value.key === right[index]?.key && value.groupPart === right[index].groupPart)
40
+ }
41
+
42
+ function structureChanged(previous: ChatNode | undefined, current: ChatNode): boolean {
43
+ if (!isVisibleChatNode(current) && (previous === undefined || !isVisibleChatNode(previous))) return false
44
+ return previous === undefined || previous.kind !== current.kind
45
+ || turnOf(previous) !== turnOf(current)
46
+ || isVisibleChatNode(previous) !== isVisibleChatNode(current)
47
+ || previous.groupTree !== current.groupTree
48
+ || reasoning(previous) !== reasoning(current) || reply(previous) !== reply(current)
49
+ }
50
+
51
+ function readNode(input: ProcessInput, key: NodeKey): ChatNode {
52
+ const node = input.readNode(key) as ChatNode | undefined
53
+ if (node === undefined) throw new Error(`Chat grouping input is missing Node ${key}`)
54
+ return node
55
+ }
56
+
57
+ /** One group's members and cached summary, refreshed together when its content changes. */
58
+ class ProcessGroup {
59
+ private nodes: readonly ChatNode[] = []
60
+ snapshot: GroupSnapshot<ProcessGroupData>
61
+
62
+ constructor(readonly key: GroupKey, readonly turn: number, readonly members: readonly NodeReference[]) {
63
+ this.snapshot = { key, members, data: { turn, closed: false, summary: { counts: [], running: undefined, runningDetail: '' } } }
64
+ }
65
+
66
+ refresh(input: ProcessInput, closed: boolean): void {
67
+ const nodes = this.members.map(member => readNode(input, member.key))
68
+ const unchanged = nodes.length === this.nodes.length && nodes.every((node, index) => node === this.nodes[index])
69
+ const previous = this.snapshot.data
70
+ const activity = unchanged && previous.closed === closed ? previous.summary : processActivity(nodes)
71
+ const summary = closed ? { counts: activity.counts, running: undefined, runningDetail: '' } : activity
72
+ this.nodes = nodes
73
+ if (previous.closed !== closed || !sameSummary(previous.summary, summary)) {
74
+ this.snapshot = {
75
+ key: this.key, members: this.members,
76
+ data: { turn: this.turn, closed, summary },
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ /** One Turn's grouping result and member lookup; summaries stay with their groups. */
83
+ class TurnGroups {
84
+ private groups = new Map<GroupKey, ProcessGroup>()
85
+ private membership = new Map<NodeKey, GroupKey>()
86
+ private roots = new Map<NodeKey, readonly RenderEntry[]>()
87
+
88
+ constructor(readonly turn: number) {}
89
+
90
+ references(key: NodeKey): readonly RenderEntry[] {
91
+ return this.roots.get(key) ?? []
92
+ }
93
+
94
+ snapshots(): GroupSnapshot<ProcessGroupData>[] {
95
+ return [...this.groups.values()].map(group => group.snapshot)
96
+ }
97
+
98
+ refresh(input: ProcessInput, changed: ReadonlySet<NodeKey>): GroupSnapshot<ProcessGroupData>[] {
99
+ const dirty = new Set<GroupKey>()
100
+ for (const node of changed) {
101
+ const group = this.membership.get(node)
102
+ if (group !== undefined) dirty.add(group)
103
+ }
104
+ const ended = input.timeline.turns.get(this.turn)?.status === 'closed'
105
+ if (ended) {
106
+ for (const group of this.groups.values()) {
107
+ if (!group.snapshot.data.closed) dirty.add(group.key)
108
+ }
109
+ }
110
+ const upserts: GroupSnapshot<ProcessGroupData>[] = []
111
+ for (const key of dirty) {
112
+ const group = this.groups.get(key) as ProcessGroup
113
+ const previous = group.snapshot
114
+ group.refresh(input, previous.data.closed || ended)
115
+ if (group.snapshot !== previous) upserts.push(group.snapshot)
116
+ }
117
+ return upserts
118
+ }
119
+
120
+ rebuild(input: ProcessInput, added: ReadonlySet<NodeKey>): { upserts: GroupSnapshot<ProcessGroupData>[]; removes: GroupKey[] } {
121
+ const roots = new Map<NodeKey, readonly RenderEntry[]>()
122
+ const groups = new Map<GroupKey, ProcessGroup>()
123
+ const membership = new Map<NodeKey, GroupKey>()
124
+ let pending: NodeReference[] = []
125
+ const upserts: GroupSnapshot<ProcessGroupData>[] = []
126
+ const emit = (key: NodeKey, entry: RenderEntry): void => {
127
+ roots.set(key, [...roots.get(key) ?? [], entry])
128
+ }
129
+ const flush = (closed: boolean): void => {
130
+ const first = pending[0]
131
+ if (first === undefined) return
132
+ const retained = this.extendedGroup(pending, added)
133
+ const key = retained?.key ?? brandString<GroupKey>(JSON.stringify(['process', first.key, first.groupPart ?? null]))
134
+ const previous = this.groups.get(key)
135
+ const before = previous?.snapshot
136
+ const group = previous !== undefined && sameMembers(previous.members, pending)
137
+ ? previous : new ProcessGroup(key, this.turn, pending)
138
+ group.refresh(input, closed || input.timeline.turns.get(this.turn)?.status === 'closed')
139
+ groups.set(group.key, group)
140
+ emit(first.key, { kind: 'group', key: group.key })
141
+ for (const member of pending) membership.set(member.key, group.key)
142
+ if (group.snapshot !== before) upserts.push(group.snapshot)
143
+ pending = []
144
+ }
145
+ let previous: NodeKey | undefined
146
+ let followed = false
147
+ for (const key of input.readTurn(this.turn)) {
148
+ const position = readPosition(input, key)
149
+ if (previous !== undefined && position.previous !== previous) flush(true)
150
+ previous = key
151
+ followed = position.next !== undefined
152
+ const node = readNode(input, key)
153
+ if (isAtOrOutside(node, 'process')) {
154
+ flush(true)
155
+ emit(key, { kind: 'node', key })
156
+ } else if (node.kind === 'assistant-step') {
157
+ // One Node, two rows: reasoning joins the step run, a reply stands outside it.
158
+ if (reasoning(node)) pending.push({ kind: 'node', key, groupPart: 'reasoning' })
159
+ if (reply(node)) {
160
+ flush(true)
161
+ emit(key, { kind: 'node', key, groupPart: 'response' })
162
+ }
163
+ } else pending.push({ kind: 'node', key })
164
+ }
165
+ flush(followed)
166
+ const removes = [...this.groups.keys()].filter(key => !groups.has(key))
167
+ this.groups = groups
168
+ this.membership = membership
169
+ this.roots = roots
170
+ return { upserts, removes }
171
+ }
172
+
173
+ private extendedGroup(members: readonly NodeReference[], added: ReadonlySet<NodeKey>): ProcessGroup | undefined {
174
+ // Reuse identity only while the complete old group remains between newly visible members.
175
+ const offset = members.findIndex(member => !added.has(member.key))
176
+ const first = members[offset]
177
+ if (first === undefined) return undefined
178
+ const key = this.membership.get(first.key)
179
+ const previous = key === undefined ? undefined : this.groups.get(key)
180
+ if (previous === undefined || offset + previous.members.length > members.length) return undefined
181
+ for (let index = 0; index < previous.members.length; index++) {
182
+ const before = previous.members[index] as NodeReference
183
+ const after = members[offset + index] as NodeReference
184
+ if (before.key !== after.key || before.groupPart !== after.groupPart) return undefined
185
+ }
186
+ for (let index = offset + previous.members.length; index < members.length; index++) {
187
+ if (!added.has((members[index] as NodeReference).key)) return undefined
188
+ }
189
+ return previous
190
+ }
191
+ }
192
+
193
+ function readPosition(input: ProcessInput, key: NodeKey) {
194
+ const position = input.readPosition(key)
195
+ if (position === undefined) throw new Error(`Chat grouping order is missing position for Node ${key}`)
196
+ return position
197
+ }
198
+
199
+ /** Session-local Turn results; ordinary updates never read other Turns' Node contents. */
200
+ export class ProcessState {
201
+ private turns = new Map<number, TurnGroups>()
202
+ private order: readonly NodeKey[] = []
203
+ private pending: GroupUpdate<ProcessGroupData> | null = null
204
+
205
+ /**
206
+ * Consume one synchronous Builder input without retaining its readers.
207
+ * @param input - projected Node changes, indexed positions, and Turn lifecycle.
208
+ */
209
+ accept(input: ProcessInput): void {
210
+ if (input.kind === 'replace') {
211
+ const previousKeys = new Set(this.order)
212
+ const added = new Set(input.order.filter(key => !previousKeys.has(key)))
213
+ const turns = new Map<number, TurnGroups>()
214
+ for (const key of input.order) {
215
+ const turn = readPosition(input, key).turn
216
+ if (turn === undefined || turns.has(turn)) continue
217
+ const groups = this.turns.get(turn) ?? new TurnGroups(turn)
218
+ groups.rebuild(input, added)
219
+ turns.set(turn, groups)
220
+ }
221
+ this.turns = turns
222
+ this.order = input.order
223
+ this.pending = {
224
+ entries: this.rootEntries(input),
225
+ groups: { kind: 'replace', snapshots: [...turns.values()].flatMap(turn => turn.snapshots()) },
226
+ }
227
+ return
228
+ }
229
+
230
+ const regroup = new Set(input.changedTurnOrders)
231
+ const added = new Set<NodeKey>()
232
+ const changed = new Map<number, Set<NodeKey>>()
233
+ const touch = (turn: number): Set<NodeKey> => {
234
+ let keys = changed.get(turn)
235
+ if (keys === undefined) {
236
+ keys = new Set()
237
+ changed.set(turn, keys)
238
+ }
239
+ return keys
240
+ }
241
+ for (const change of input.changes) {
242
+ const before = change.previous as ChatNode | undefined
243
+ const after = change.current as ChatNode
244
+ const turn = turnOf(after)
245
+ if (before === undefined || !isVisibleChatNode(before)) added.add(after.key as NodeKey)
246
+ if (structureChanged(before, after)) {
247
+ const previousTurn = before === undefined ? undefined : turnOf(before)
248
+ if (previousTurn !== undefined) regroup.add(previousTurn)
249
+ if (turn !== undefined) regroup.add(turn)
250
+ }
251
+ if (turn !== undefined) touch(turn).add(after.key as NodeKey)
252
+ }
253
+ for (const turn of input.changedTurns) touch(turn)
254
+
255
+ const upserts: GroupSnapshot<ProcessGroupData>[] = []
256
+ const removes: GroupKey[] = []
257
+ for (const turn of regroup) {
258
+ const groups = this.turns.get(turn) ?? new TurnGroups(turn)
259
+ const update = groups.rebuild(input, added)
260
+ upserts.push(...update.upserts)
261
+ removes.push(...update.removes)
262
+ if (input.readTurn(turn).length === 0) this.turns.delete(turn)
263
+ else this.turns.set(turn, groups)
264
+ }
265
+ for (const [turn, keys] of changed) {
266
+ if (!regroup.has(turn)) upserts.push(...this.turns.get(turn)?.refresh(input, keys) ?? [])
267
+ }
268
+ const reordered = input.order !== this.order || regroup.size > 0
269
+ this.order = input.order
270
+ const installed = new Set(upserts.map(group => group.key))
271
+ this.pending = reordered || upserts.length > 0 || removes.length > 0
272
+ ? {
273
+ ...reordered ? { entries: this.rootEntries(input) } : {},
274
+ groups: { kind: 'apply', upserts, removes: removes.filter(key => !installed.has(key)) },
275
+ }
276
+ : null
277
+ }
278
+
279
+ private rootEntries(input: ProcessInput): RenderEntry[] {
280
+ return input.order.flatMap<RenderEntry>((key) => {
281
+ const turn = readPosition(input, key).turn
282
+ if (turn === undefined) return [{ kind: 'node', key }]
283
+ const groups = this.turns.get(turn)
284
+ if (groups === undefined) throw new Error(`Chat grouping order is missing Turn ${turn}`)
285
+ return groups.references(key)
286
+ })
287
+ }
288
+
289
+ /**
290
+ * Read pending output without advancing State.
291
+ * @returns the repeatable update for the last input batch.
292
+ */
293
+ output(): GroupUpdate<ProcessGroupData> | null { return this.pending }
294
+ }
295
+
296
+ /** Chat's registered business grouping; presentation modes never enter its State. */
297
+ export const processGroupDefinition: ConversationGroupDefinition<ChatConversationViewNode, ProcessState, ProcessGroupData>
298
+ & { readonly target: 'chat' } = {
299
+ kind: 'process-groups', target: 'chat',
300
+ create: () => new ProcessState(),
301
+ update: (context, input) => { context.state.accept(input); return context.state },
302
+ buildGroups: context => context.state.output(),
303
+ }
@@ -0,0 +1,38 @@
1
+ import type { Context } from '@deepseek-ai/cordis'
2
+ import { registerAssistantConversationNode } from './assistant.ts'
3
+ import { registerChatConversationView } from './chat-snapshot-builder.ts'
4
+ import { registerCommandConversationNode } from './command.ts'
5
+ import { registerCompactionConversationNode } from './compaction.ts'
6
+ import { registerUnknownConversationFallback } from './fallback.ts'
7
+ import { registerInboxConversationNodes } from './inbox.ts'
8
+ import { registerMessageConversationNode } from './message.ts'
9
+ import { registerRequestPromptConversationNode } from './request-prompt.ts'
10
+ import { registerRetryConversationNode } from './retry.ts'
11
+ import { registerToolConversationNode } from './tool.ts'
12
+ import { registerTurnErrorConversationNode } from './turn-error.ts'
13
+ import { registerTurnMaxTokensConversationNode } from './turn-max-tokens.ts'
14
+ import { registerTurnProcess } from './turn-process.ts'
15
+ import { registerTurnTailConversationNode } from './turn-tail.ts'
16
+ import { processGroupDefinition } from './process-groups.ts'
17
+
18
+ /**
19
+ * Register the Chat business Definitions and target builder contributed by this package.
20
+ * @param ctx - owning UI Conversation context.
21
+ */
22
+ export function registerConversationNodes(ctx: Context): void {
23
+ registerInboxConversationNodes(ctx)
24
+ registerMessageConversationNode(ctx)
25
+ registerRequestPromptConversationNode(ctx)
26
+ registerAssistantConversationNode(ctx)
27
+ registerTurnProcess(ctx)
28
+ registerToolConversationNode(ctx)
29
+ registerCommandConversationNode(ctx)
30
+ registerCompactionConversationNode(ctx)
31
+ registerRetryConversationNode(ctx)
32
+ registerTurnErrorConversationNode(ctx)
33
+ registerTurnMaxTokensConversationNode(ctx)
34
+ registerTurnTailConversationNode(ctx)
35
+ registerUnknownConversationFallback(ctx)
36
+ registerChatConversationView(ctx)
37
+ ctx.uiConversation.groups.register(processGroupDefinition)
38
+ }
@@ -0,0 +1,169 @@
1
+ import type { Context } from '@deepseek-ai/cordis'
2
+ import type {
3
+ ConversationMatch, ConversationNodeContext, ConversationNodeDefinition, RequestPromptInspector,
4
+ SystemPromptState, SystemPromptInspector,
5
+ } from '@deepseek-ai/dsh-client-ui-conversation/client'
6
+ import type { ChatNode } from '../contract/chat-nodes.ts'
7
+ import { chatNode } from './common.ts'
8
+
9
+ declare module '../contract/chat-nodes.ts' {
10
+ interface ChatNodeDataMap {
11
+ /** Complete system prompt rendered for one model request, or an in-history prompt update at its own position. */
12
+ 'system-prompt': { readonly text: string; readonly update?: true }
13
+ }
14
+ }
15
+
16
+ interface RequestPromptState extends ReturnType<RequestPromptInspector> {
17
+ readonly anchorSeq: number
18
+ readonly showsPrompt: boolean
19
+ readonly turn?: number
20
+ readonly step?: number
21
+ }
22
+
23
+ /** Place a request's system prompt at the start of its visible message series. */
24
+ function requestPromptAnchor(
25
+ match: ConversationMatch,
26
+ previous: Readonly<RequestPromptState> | undefined,
27
+ isInitial: boolean,
28
+ ): number {
29
+ if (match.location.kind !== 'step') return match.event.seq
30
+ if (previous === undefined && !isInitial) return match.event.seq
31
+ if (previous?.turn === match.location.turn.turn
32
+ && previous.step === match.location.step.step) return match.event.seq
33
+ return match.location.step.step === 1
34
+ ? match.location.turn.start?.seq ?? match.location.step.start?.seq ?? match.event.seq
35
+ : match.location.step.start?.seq ?? match.event.seq
36
+ }
37
+
38
+ /** Keep an already rendered prompt at its page-lifetime presentation anchor. */
39
+ function stableRequestPromptAnchor(
40
+ context: ConversationNodeContext<RequestPromptState>,
41
+ match: ConversationMatch,
42
+ previous: Readonly<RequestPromptState> | undefined,
43
+ isInitial: boolean,
44
+ ): number {
45
+ const current = context.current.get('chat') as ChatNode | null | undefined
46
+ return current?.kind === 'system-prompt'
47
+ ? current.anchorSeq
48
+ : requestPromptAnchor(match, previous, isInitial)
49
+ }
50
+
51
+ /**
52
+ * System-prompt surface node Definition for the Chat target. It owns every
53
+ * `system/message` event on the Chat target so the unknown-surface fallback
54
+ * never renders the prompt as a transcript row. Each nonempty append owns a
55
+ * prompt card, even without a loaded request header. Initial cards precede
56
+ * their step's input; in-history updates stay at their own positions. The
57
+ * request-prompt Definition owns replacement and later-series cards. Positional
58
+ * replacements advance the effective prompt without changing historical cards.
59
+ * A published node becomes `hidden` under the same key while a prepended replacement
60
+ * leaves its prompt order unknown, and `visible` again once older history resolves it.
61
+ * @param inspect - Pure surface interpretation supplied by uiConversation.
62
+ * @returns The Chat system-prompt Definition.
63
+ */
64
+ export function systemMessageDefinition(inspect: SystemPromptInspector): ConversationNodeDefinition<SystemPromptState> {
65
+ return {
66
+ kind: 'system-message',
67
+ target: 'chat',
68
+ match: event => event.type === 'system/message'
69
+ || ('surfaceOp' in event && event.surfaceOp !== 'append')
70
+ ? { id: String(event.seq), role: 'start' }
71
+ : null,
72
+ start: (_context, match, reader) => {
73
+ if (match.event.type === 'assistant/live-chunk') throw new Error('system-message requires a durable event')
74
+ return inspect(reader.previous<SystemPromptState>('system-message')?.state, match.event)
75
+ },
76
+ update: context => context.state,
77
+ buildViewNode: (context) => {
78
+ const state = context.state?.introduced
79
+ if (state === undefined || state.text === ''
80
+ || context.start?.event.type !== 'system/message' || context.start.event.surfaceOp !== 'append') {
81
+ const current = context.current.get('chat') as ChatNode | null | undefined
82
+ if (current?.kind !== 'system-prompt') return null
83
+ return chatNode(context, 'system-prompt', current.anchorSeq, current.data, { visibility: 'hidden' })
84
+ }
85
+ const anchor = state.update ? state.seq : requestPromptAnchor(context.start, undefined, true)
86
+ return chatNode(context, 'system-prompt', anchor, { text: state.text, ...state.update ? { update: true } : {} })
87
+ },
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Request-header prompt Definition for the Chat target. Resume and explicit
93
+ * series starts retain a prompt card even when the system text is unchanged.
94
+ * @param inspect - the shared prompt interpretation, supplied by the
95
+ * uiConversation service (a client bundle cannot value-import it).
96
+ * @returns the Chat request-prompt Definition.
97
+ */
98
+ export function requestPromptDefinition(inspect: RequestPromptInspector): ConversationNodeDefinition<RequestPromptState> {
99
+ return {
100
+ kind: 'request-prompt',
101
+ target: 'chat',
102
+ match: event => event.type === 'request/header'
103
+ ? { id: String(event.seq), role: 'start' }
104
+ : null,
105
+ start: (context, match, reader) => {
106
+ if (match.event.type !== 'request/header') {
107
+ throw new Error('request-prompt start requires request/header')
108
+ }
109
+ const previous = reader.previous<RequestPromptState>('request-prompt')?.state
110
+ const systemContext = reader.previous<SystemPromptState>('system-message')
111
+ const system = systemContext?.state.effective
112
+ const location = match.location.kind === 'step'
113
+ ? { turn: match.location.turn.turn, step: match.location.step.step }
114
+ : {}
115
+ const inspection = inspect(previous?.prompt, match.event, system)
116
+ const change = inspection.change?.kind
117
+ // Appended prompts own their cards; a same-step header must not repeat them.
118
+ const systemEvent = systemContext?.matches[0]?.event
119
+ const shownByUpdate = system !== undefined
120
+ && systemEvent?.type === 'system/message' && systemEvent.surfaceOp === 'append'
121
+ && (system.update || previous === undefined)
122
+ && system.turn === location.turn
123
+ && system.step === location.step
124
+ return {
125
+ anchorSeq: stableRequestPromptAnchor(
126
+ context,
127
+ match,
128
+ previous,
129
+ match.event.data.reason === 'initial',
130
+ ),
131
+ showsPrompt: !shownByUpdate && (previous === undefined
132
+ || match.event.data.reason !== 'change'
133
+ || match.event.data.startsSeries === true
134
+ || change === 'system'
135
+ || change === 'system-and-tools'),
136
+ ...location,
137
+ ...inspection,
138
+ }
139
+ },
140
+ update: context => context.state,
141
+ buildViewNode: (context) => {
142
+ const state = context.state
143
+ if (state === undefined) return null
144
+ const current = context.current.get('chat') as ChatNode | null | undefined
145
+ const visible = state.showsPrompt && state.prompt.system !== ''
146
+ if (!visible && current?.kind !== 'system-prompt') return null
147
+ return chatNode(
148
+ context,
149
+ 'system-prompt',
150
+ state.anchorSeq,
151
+ { text: state.prompt.system },
152
+ { visibility: visible ? 'visible' : 'hidden' },
153
+ )
154
+ },
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Register the system-prompt surface node and the model-request prompt card in the Chat flow.
160
+ * @param ctx - Owning UI Conversation context.
161
+ */
162
+ export function registerRequestPromptConversationNode(ctx: Context): void {
163
+ ctx.uiConversation.events.register(systemMessageDefinition(
164
+ (previous, event) => ctx.uiConversation.inspectSystemPrompt(previous, event),
165
+ ))
166
+ ctx.uiConversation.events.register(requestPromptDefinition(
167
+ (previous, event, system) => ctx.uiConversation.inspectRequestPrompt(previous, event, system),
168
+ ))
169
+ }
@@ -0,0 +1,97 @@
1
+ import type { Context } from '@deepseek-ai/cordis'
2
+ import type {
3
+ ConversationLocation, ConversationMatch, ConversationNodeDefinition, ModelRetryNode,
4
+ } from '@deepseek-ai/dsh-client-ui-conversation/client'
5
+ import type {} from '@deepseek-ai/dsh-llm-retry/types'
6
+ import type { RetryChatData } from '../contract/chat-nodes.ts'
7
+ import { chatNode } from './common.ts'
8
+
9
+ declare module '../contract/chat-nodes.ts' {
10
+ interface ChatNodeDataMap {
11
+ /** Producer-correlated model retry chain. */
12
+ 'model-retry': RetryChatData
13
+ }
14
+ }
15
+
16
+ /** Accumulated retry attempts sharing one producer-owned RetryId. */
17
+ export interface RetryState {
18
+ readonly turn: number
19
+ readonly step: number
20
+ readonly attempts: readonly ModelRetryNode[]
21
+ }
22
+
23
+ function scheduledNode(match: ConversationMatch): ModelRetryNode | undefined {
24
+ if (match.event.type !== 'llm/retry') return undefined
25
+ return {
26
+ kind: 'model-retry',
27
+ seq: match.event.seq,
28
+ time: match.event.time,
29
+ retryState: 'scheduled',
30
+ ...match.event.data,
31
+ }
32
+ }
33
+
34
+ /** A scheduled attempt is cancelled once either owning boundary closes. */
35
+ function isClosed(location: ConversationLocation): boolean {
36
+ return (location.kind === 'step' && location.step.status === 'closed')
37
+ || ((location.kind === 'step' || location.kind === 'turn') && location.turn.status === 'closed')
38
+ }
39
+
40
+ /** Producer-correlated model retry chain Definition. */
41
+ export const retryDefinition: ConversationNodeDefinition<RetryState> = {
42
+ kind: 'model-retry',
43
+ target: 'chat',
44
+ match: (event) => {
45
+ if (event.type === 'llm/retry') {
46
+ const retryId: unknown = event.data.retryId
47
+ if (typeof retryId !== 'string' || retryId === '') return null
48
+ return { id: retryId, role: event.data.retry === 1 ? 'start' : 'update' }
49
+ }
50
+ if (event.type === 'llm/retry-started') {
51
+ const retryId: unknown = event.data.retryId
52
+ return typeof retryId === 'string' && retryId !== '' ? { id: retryId, role: 'update' } : null
53
+ }
54
+ return null
55
+ },
56
+ start: (_context, match) => {
57
+ const node = scheduledNode(match)
58
+ if (node === undefined) throw new Error('model-retry start requires a valid llm/retry event')
59
+ return { turn: node.turn, step: node.step, attempts: [node] }
60
+ },
61
+ update: (context, match) => {
62
+ if (match.event.type === 'llm/retry') {
63
+ const node = scheduledNode(match)
64
+ return node === undefined ? context.state : { ...context.state, attempts: [...context.state.attempts, node] }
65
+ }
66
+ if (match.event.type !== 'llm/retry-started') return context.state
67
+ const retry = match.event.data.retry
68
+ return {
69
+ ...context.state,
70
+ attempts: context.state.attempts.map(attempt =>
71
+ attempt.retry === retry ? { ...attempt, retryState: 'started' } : attempt),
72
+ }
73
+ },
74
+ buildViewNode: (context) => {
75
+ if (context.state === undefined || context.state.attempts.length === 0) return null
76
+ const location = context.start?.location ?? context.matches[0]?.location ?? { kind: 'unresolved' as const }
77
+ const stateAttempts = context.state.attempts
78
+ const attempts = stateAttempts.map((attempt, index) =>
79
+ index === stateAttempts.length - 1
80
+ && attempt.retryState === 'scheduled'
81
+ && isClosed(location)
82
+ ? { ...attempt, retryState: 'cancelled' as const }
83
+ : attempt)
84
+ const current = attempts.at(-1)
85
+ if (current === undefined) return null
86
+ const data: RetryChatData = { attempts, current }
87
+ return chatNode(context, 'model-retry', attempts[0]?.seq ?? current.seq, data, { groupTree: 'process' })
88
+ },
89
+ }
90
+
91
+ /**
92
+ * Register the correlated model-retry business contribution.
93
+ * @param ctx - owning UI Conversation context.
94
+ */
95
+ export function registerRetryConversationNode(ctx: Context): void {
96
+ ctx.uiConversation.events.register(retryDefinition)
97
+ }