@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,227 @@
1
+ import type { Context } from '@deepseek-ai/cordis'
2
+ import type {
3
+ CommandNode, CompactionSummaryNode, ConversationMatch, ConversationNodeContext, ConversationNodeDefinition,
4
+ } from '@deepseek-ai/dsh-client-ui-conversation/client'
5
+ import type { CompactionCheckpointSource } from '@deepseek-ai/dsh-compaction/checkpoint'
6
+ import type {} from '@deepseek-ai/dsh-compaction/types'
7
+ import type {} from '@deepseek-ai/dsh-commands/types'
8
+ import { isReplacementSurfaceEvent } from '@deepseek-ai/dsh-session/surface'
9
+ import type { ManualCompactionChatData } from '../contract/chat-nodes.ts'
10
+ import { chatNode } from './common.ts'
11
+
12
+ declare module '../contract/chat-nodes.ts' {
13
+ interface ChatNodeDataMap {
14
+ /** Ordinary slash-command lifecycle. */
15
+ command: CommandNode
16
+ /** Manual compact command combined with its compaction transaction. */
17
+ 'manual-compaction': ManualCompactionChatData
18
+ }
19
+ }
20
+
21
+ type CommandId = CommandNode['commandId']
22
+
23
+ const COMPACT_KIND: CompactionCheckpointSource['kind'] = 'compact-checkpoint'
24
+
25
+ interface CommandState {
26
+ readonly command: CommandNode
27
+ readonly summary?: ConversationMatch
28
+ readonly checkpoint?: ConversationMatch
29
+ }
30
+
31
+ interface CompactionEvidence {
32
+ readonly summary?: ConversationMatch
33
+ readonly checkpoint?: ConversationMatch
34
+ }
35
+
36
+ function commandFromRun(match: ConversationMatch): CommandNode {
37
+ if (match.event.type !== 'command/run') throw new Error('command start requires command/run')
38
+ const data = match.event.data
39
+ return {
40
+ kind: 'command',
41
+ seq: match.event.seq,
42
+ time: match.event.time,
43
+ commandId: data.commandId,
44
+ name: data.name,
45
+ args: data.args ?? null,
46
+ outcome: null,
47
+ }
48
+ }
49
+
50
+ function commandFromDone(match: ConversationMatch, previous?: CommandNode): CommandNode {
51
+ if (match.event.type !== 'command/done') throw new Error('command update requires command/done')
52
+ const data = match.event.data
53
+ const sourceEventSeq = data.kind === 'success'
54
+ && data.sourceEventSeq !== undefined
55
+ && Number.isSafeInteger(data.sourceEventSeq) && data.sourceEventSeq >= 0
56
+ ? data.sourceEventSeq
57
+ : undefined
58
+ return {
59
+ kind: 'command',
60
+ seq: previous?.seq ?? match.event.seq,
61
+ time: previous?.time ?? match.event.time,
62
+ commandId: data.commandId,
63
+ name: previous?.name ?? null,
64
+ args: previous?.args ?? null,
65
+ outcome: {
66
+ kind: data.kind,
67
+ ...data.text === undefined ? {} : { text: data.text },
68
+ ...sourceEventSeq === undefined ? {} : { sourceEventSeq },
69
+ },
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Read correlation identity from a compaction replacement checkpoint.
75
+ * @param event - candidate Session event.
76
+ * @returns correlated compaction and optional command identity.
77
+ */
78
+ function compactSource(event: Parameters<ConversationNodeDefinition['match']>[0]): {
79
+ compactionId: string
80
+ sourceCommandId?: CommandId
81
+ } | undefined {
82
+ if (event.type !== 'user/message' || !isReplacementSurfaceEvent(event)) return undefined
83
+ const source = event.data.source as {
84
+ kind?: unknown
85
+ compactionId?: unknown
86
+ sourceCommandId?: CommandId
87
+ }
88
+ if (source.kind !== COMPACT_KIND || typeof source.compactionId !== 'string') return undefined
89
+ return {
90
+ compactionId: source.compactionId,
91
+ ...source.sourceCommandId === undefined ? {} : { sourceCommandId: source.sourceCommandId },
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Build the visible summary marker from optional lifecycle evidence.
97
+ * @param match - compaction/summary Match, when loaded.
98
+ * @param checkpoint - replacement checkpoint Match.
99
+ * @returns final compaction summary Node data.
100
+ */
101
+ function compactSummary(match: ConversationMatch | undefined, checkpoint: ConversationMatch): CompactionSummaryNode {
102
+ let summary: string | null = null
103
+ let shadowedItemCount: number | null = null
104
+ let shadowedTokenCount: number | null = null
105
+ if (match?.event.type === 'compaction/summary') {
106
+ const data = match.event.data
107
+ if (Array.isArray(data.summary)) {
108
+ const text = data.summary
109
+ .map(block => block.type === 'text' ? block.text : '')
110
+ .join('')
111
+ summary = text.trim() === '' ? null : text
112
+ }
113
+ shadowedItemCount = Array.isArray(data.shadowedSeqs)
114
+ && data.shadowedSeqs.every(seq => Number.isSafeInteger(seq) && seq >= 0)
115
+ ? data.shadowedSeqs.length
116
+ : null
117
+ shadowedTokenCount = Number.isSafeInteger(data.shadowedTokenCount)
118
+ && data.shadowedTokenCount >= 0
119
+ ? data.shadowedTokenCount
120
+ : null
121
+ }
122
+ return {
123
+ kind: 'compaction',
124
+ seq: checkpoint.event.seq,
125
+ time: checkpoint.event.time,
126
+ summary,
127
+ summaryEventSeq: match?.event.seq ?? null,
128
+ shadowedItemCount,
129
+ shadowedTokenCount,
130
+ }
131
+ }
132
+
133
+ function fallbackState(context: ConversationNodeContext<CommandState>): CommandState | undefined {
134
+ const done = context.matches.find(match => match.event.type === 'command/done')
135
+ const checkpoint = context.matches.find(match => compactSource(match.event) !== undefined)
136
+ const summary = context.matches.find(match => match.event.type === 'compaction/summary')
137
+ if (checkpoint === undefined) return done === undefined ? undefined : { command: commandFromDone(done) }
138
+ const source = compactSource(checkpoint.event)
139
+ if (source?.sourceCommandId === undefined) return done === undefined ? undefined : { command: commandFromDone(done) }
140
+ const fallbackCommand = done === undefined
141
+ ? {
142
+ kind: 'command' as const,
143
+ seq: checkpoint.event.seq,
144
+ time: checkpoint.event.time,
145
+ commandId: source.sourceCommandId,
146
+ name: 'compact',
147
+ args: null,
148
+ outcome: null,
149
+ }
150
+ : { ...commandFromDone(done), name: 'compact' }
151
+ return {
152
+ command: fallbackCommand,
153
+ checkpoint,
154
+ ...summary === undefined ? {} : { summary },
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Fold shared compaction evidence into a Definition-owned State.
160
+ * @param state - current business State carrying optional compaction evidence.
161
+ * @param match - next compaction lifecycle Match.
162
+ * @returns adopted State, preserving reference identity when the Match adds no evidence.
163
+ */
164
+ export function updateCompactionState<State extends CompactionEvidence>(
165
+ state: State,
166
+ match: ConversationMatch,
167
+ ): State {
168
+ if (match.event.type === 'compaction/summary') return { ...state, summary: match }
169
+ if (compactSource(match.event) !== undefined) return { ...state, checkpoint: match }
170
+ return state
171
+ }
172
+
173
+ /** Slash-command lifecycle, including integrated manual compaction, Definition. */
174
+ export const commandDefinition: ConversationNodeDefinition<CommandState> = {
175
+ kind: 'command',
176
+ target: 'chat',
177
+ match: (event) => {
178
+ if (event.type === 'command/run') {
179
+ return { id: String(event.data.commandId), role: 'start' }
180
+ }
181
+ if (event.type === 'command/done') {
182
+ return { id: String(event.data.commandId), role: 'update' }
183
+ }
184
+ const checkpoint = compactSource(event)
185
+ if (checkpoint?.sourceCommandId !== undefined) {
186
+ return { id: String(checkpoint.sourceCommandId), role: 'update' }
187
+ }
188
+ if (event.type === 'compaction/start'
189
+ || event.type === 'compaction/summary'
190
+ || event.type === 'compaction/end') {
191
+ if (event.data.sourceCommandId !== undefined) {
192
+ return { id: String(event.data.sourceCommandId), role: 'update' }
193
+ }
194
+ }
195
+ return null
196
+ },
197
+ start: (_context, match) => ({ command: commandFromRun(match) }),
198
+ update: (context, match) => {
199
+ if (match.event.type === 'command/done') {
200
+ return { ...context.state, command: commandFromDone(match, context.state.command) }
201
+ }
202
+ return updateCompactionState(context.state, match)
203
+ },
204
+ buildViewNode: (context) => {
205
+ const state = context.state ?? fallbackState(context)
206
+ if (state === undefined) return null
207
+ if (state.command.name !== 'compact') {
208
+ return chatNode(context, 'command', state.command.seq, state.command)
209
+ }
210
+ const compaction = state.checkpoint === undefined
211
+ ? null
212
+ : compactSummary(state.summary, state.checkpoint)
213
+ const data: ManualCompactionChatData = { command: state.command, compaction }
214
+ return chatNode(context, 'manual-compaction', compaction?.seq ?? state.command.seq, data)
215
+ },
216
+ }
217
+
218
+ /**
219
+ * Register the command lifecycle business contribution.
220
+ * @param ctx - owning UI Conversation context.
221
+ */
222
+ export function registerCommandConversationNode(ctx: Context): void {
223
+ ctx.uiConversation.events.register(commandDefinition)
224
+ }
225
+
226
+ /** Shared structural checkpoint recognizer for automatic compaction. */
227
+ export { compactSource, compactSummary }
@@ -0,0 +1,83 @@
1
+ import type {
2
+ ConversationLocation, ConversationNodeContext,
3
+ } from '@deepseek-ai/dsh-client-ui-conversation/client'
4
+ import type {
5
+ ChatNode, ChatNodeDataMap, ChatNodeKind,
6
+ } from '../contract/chat-nodes.ts'
7
+ import type { ChatGroupTree } from '../contract/group-tree.ts'
8
+
9
+ /**
10
+ * Relative positions in one durable event's seq neighborhood: interrupted
11
+ * Assistant, its follow-up Nodes, then follow-ups to an ordinary final. The
12
+ * max-tokens notice sits between a closing Assistant and the turn-tail so the
13
+ * tail stays the turn's last node and keeps its branch action enabled.
14
+ */
15
+ export const CHAT_SYNTHETIC_SEQ_OFFSETS = {
16
+ interruptedAssistant: -0.9,
17
+ interruptedFollowup: -0.8,
18
+ processControl: -0.1,
19
+ maxTokensNotice: 0.05,
20
+ finalizedFollowup: 0.1,
21
+ } as const
22
+
23
+ /**
24
+ * Resolve one Context's best currently loaded event Location.
25
+ * @param context - assembled business Context.
26
+ * @returns start or first-match Location, otherwise unresolved.
27
+ */
28
+ export function contextLocation(context: ConversationNodeContext): ConversationLocation {
29
+ return context.start?.location ?? context.matches[0]?.location ?? { kind: 'unresolved' }
30
+ }
31
+
32
+ /**
33
+ * Read the Turn and Step a Location resolves to.
34
+ * @param location - engine-owned Location.
35
+ * @returns resolved coordinates; Session-level and unresolved Locations have none.
36
+ */
37
+ export function locationCoordinates(location: ConversationLocation): { turn?: number; step?: number } {
38
+ if (location.kind === 'step') return { turn: location.turn.turn, step: location.step.step }
39
+ if (location.kind === 'turn') return { turn: location.turn.turn }
40
+ return {}
41
+ }
42
+
43
+ /**
44
+ * Build one final Chat target Node with the engine-owned stable key.
45
+ * @param context - assembled business Context.
46
+ * @param kind - Chat renderer dispatch key.
47
+ * @param anchorSeq - sortable render position.
48
+ * @param data - renderer-owned payload.
49
+ * @param options - optional Location, visibility, and group-tree overrides.
50
+ * @returns final Chat view Node.
51
+ */
52
+ export function chatNode<Kind extends ChatNodeKind>(
53
+ context: ConversationNodeContext,
54
+ kind: Kind,
55
+ anchorSeq: number,
56
+ data: ChatNodeDataMap[Kind],
57
+ options: {
58
+ readonly location?: ConversationLocation
59
+ readonly visibility?: 'visible' | 'hidden'
60
+ readonly groupTree?: ChatGroupTree | undefined
61
+ } = {},
62
+ ): ChatNode<Kind> {
63
+ return {
64
+ key: context.key,
65
+ kind,
66
+ id: context.id,
67
+ target: 'chat',
68
+ anchorSeq,
69
+ location: options.location ?? contextLocation(context),
70
+ visibility: options.visibility ?? 'visible',
71
+ groupTree: options.groupTree,
72
+ data,
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Read a finite non-negative integer from a structurally narrowed payload.
78
+ * @param value - untrusted payload field.
79
+ * @returns valid coordinate, otherwise undefined.
80
+ */
81
+ export function coordinate(value: unknown): number | undefined {
82
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : undefined
83
+ }
@@ -0,0 +1,65 @@
1
+ import type { Context } from '@deepseek-ai/cordis'
2
+ import type {
3
+ CompactionSummaryNode, ConversationMatch, ConversationNodeContext, ConversationNodeDefinition,
4
+ } from '@deepseek-ai/dsh-client-ui-conversation/client'
5
+ import type {} from '@deepseek-ai/dsh-compaction/types'
6
+ import { chatNode } from './common.ts'
7
+ import { compactSource, compactSummary, updateCompactionState } from './command.ts'
8
+
9
+ declare module '../contract/chat-nodes.ts' {
10
+ interface ChatNodeDataMap {
11
+ /** Automatic compaction checkpoint marker. */
12
+ compaction: CompactionSummaryNode
13
+ }
14
+ }
15
+
16
+ interface CompactionState {
17
+ readonly summary?: ConversationMatch
18
+ readonly checkpoint?: ConversationMatch
19
+ }
20
+
21
+ function fallbackState(context: ConversationNodeContext<CompactionState>): CompactionState {
22
+ const summary = context.matches.find(match => match.event.type === 'compaction/summary')
23
+ const checkpoint = context.matches.find(match => compactSource(match.event) !== undefined)
24
+ return {
25
+ ...summary === undefined ? {} : { summary },
26
+ ...checkpoint === undefined ? {} : { checkpoint },
27
+ }
28
+ }
29
+
30
+ /** Automatic compaction lifecycle and landed checkpoint Definition. */
31
+ export const compactionDefinition: ConversationNodeDefinition<CompactionState> = {
32
+ kind: 'compaction',
33
+ target: 'chat',
34
+ match: (event) => {
35
+ const checkpoint = compactSource(event)
36
+ if (checkpoint !== undefined && checkpoint.sourceCommandId === undefined) {
37
+ return { id: checkpoint.compactionId, role: 'update' }
38
+ }
39
+ if (event.type === 'compaction/start'
40
+ || event.type === 'compaction/summary'
41
+ || event.type === 'compaction/end') {
42
+ if (event.data.sourceCommandId !== undefined) return null
43
+ const compactionId: unknown = event.data.compactionId
44
+ if (typeof compactionId !== 'string' || compactionId === '') return null
45
+ return { id: compactionId, role: event.type === 'compaction/start' ? 'start' : 'update' }
46
+ }
47
+ return null
48
+ },
49
+ start: () => ({}),
50
+ update: (context, match) => updateCompactionState(context.state, match),
51
+ buildViewNode: (context) => {
52
+ const state = context.state ?? fallbackState(context)
53
+ if (state.checkpoint === undefined) return null
54
+ const marker = compactSummary(state.summary, state.checkpoint)
55
+ return chatNode(context, 'compaction', marker.seq, marker)
56
+ },
57
+ }
58
+
59
+ /**
60
+ * Register the automatic-compaction business contribution.
61
+ * @param ctx - owning UI Conversation context.
62
+ */
63
+ export function registerCompactionConversationNode(ctx: Context): void {
64
+ ctx.uiConversation.events.register(compactionDefinition)
65
+ }
@@ -0,0 +1,179 @@
1
+ /** Chat-owned conversion from durable Session events to Chat view data. */
2
+
3
+ import type { ContentBlock, StreamChunk } from '@deepseek-ai/dsh-llm/types'
4
+ import type {
5
+ AssistantBlock, ContextProducerView, KnownContextForm,
6
+ } from '@deepseek-ai/dsh-client-ui-conversation/client'
7
+
8
+ /* jscpd:ignore-start -- Chat and Trajectory own independent event-to-view projections. */
9
+
10
+ function asRecord(value: unknown): Record<string, unknown> | null {
11
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
12
+ ? value as Record<string, unknown>
13
+ : null
14
+ }
15
+
16
+ function readString(record: Record<string, unknown>, key: string): string | null {
17
+ const value = record[key]
18
+ return typeof value === 'string' && value.length > 0 ? value : null
19
+ }
20
+
21
+ function collect(source: Record<string, unknown>, member: string, field: string): string[] {
22
+ const list = source[member]
23
+ if (!Array.isArray(list)) return []
24
+ const seen: string[] = []
25
+ for (const entry of list) {
26
+ const record = asRecord(entry)
27
+ const value = record === null ? null : readString(record, field)
28
+ if (value !== null && !seen.includes(value)) seen.push(value)
29
+ }
30
+ return seen
31
+ }
32
+
33
+ function joined(names: string[]): string | null {
34
+ return names.length > 0 ? names.join(', ') : null
35
+ }
36
+
37
+ /** Forms Chat presents structurally; unknown merge-extensible values remain opaque. */
38
+ const KNOWN_FORMS: readonly KnownContextForm[] = [
39
+ 'instructions', 'catalog', 'snapshot', 'notice', 'relay', 'recall',
40
+ ]
41
+
42
+ /**
43
+ * Read the target-supported presentation form from a durable message source.
44
+ * @param source - Logged `user/message` source.
45
+ * @returns Supported form, or null for the opaque presentation.
46
+ */
47
+ export function contextForm(source: unknown): KnownContextForm | null {
48
+ const record = asRecord(source)
49
+ const form = record === null ? null : readString(record, 'form')
50
+ return form !== null && (KNOWN_FORMS as readonly string[]).includes(form)
51
+ ? form as KnownContextForm
52
+ : null
53
+ }
54
+
55
+ /**
56
+ * Project a durable message source to the Chat row's role and producer label.
57
+ * @param source - Logged `user/message` source.
58
+ * @returns Role and label rendered by Chat.
59
+ */
60
+ export function contextProducer(source: unknown): ContextProducerView {
61
+ const record = asRecord(source)
62
+ const kind = record === null ? null : readString(record, 'kind')
63
+ if (record === null || kind === null) return { role: 'inject', label: null }
64
+ switch (kind) {
65
+ case 'session-reference':
66
+ return { role: 'recall', label: joined(collect(record, 'references', 'label')) ?? kind }
67
+ case 'agent-instructions':
68
+ return { role: 'inject', label: joined(collect(record, 'changes', 'path')) ?? kind }
69
+ case 'skill-invocation':
70
+ return { role: 'inject', label: readString(record, 'name') ?? kind }
71
+ default:
72
+ // MessageSourceMap is merge-extensible; keep an unknown producer
73
+ // visible by its durable kind.
74
+ return { role: 'inject', label: kind }
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Read distinct labels cited by a durable cross-session recall source.
80
+ * @param source - Logged `user/message` source.
81
+ * @returns Labels in first-seen order.
82
+ */
83
+ export function sessionRecallLabels(source: unknown): string[] {
84
+ const record = asRecord(source)
85
+ if (record === null || readString(record, 'kind') !== 'session-reference') return []
86
+ return collect(record, 'references', 'label')
87
+ }
88
+
89
+ /**
90
+ * Read the skill name a durable skill-invocation injection loaded.
91
+ * @param source - Logged `user/message` source.
92
+ * @returns The skill name, or null for every other source.
93
+ */
94
+ export function skillInvocationName(source: unknown): string | null {
95
+ const record = asRecord(source)
96
+ if (record === null || readString(record, 'kind') !== 'skill-invocation') return null
97
+ return readString(record, 'name')
98
+ }
99
+
100
+ /**
101
+ * Classify finalized Assistant content for Chat rendering.
102
+ * @param content - Core content blocks.
103
+ * @returns Chat blocks in source order.
104
+ */
105
+ export function toAssistantBlocks(content: readonly ContentBlock[]): AssistantBlock[] {
106
+ return content.map(toAssistantBlock)
107
+ }
108
+
109
+ /**
110
+ * Classify one finalized Assistant block for Chat rendering.
111
+ * @param block - Core content block.
112
+ * @returns Chat block.
113
+ */
114
+ export function toAssistantBlock(block: ContentBlock): AssistantBlock {
115
+ switch (block.type) {
116
+ case 'text': return { kind: 'text', text: block.text }
117
+ case 'reasoning': return { kind: 'reasoning', text: block.text }
118
+ case 'image': return { kind: 'image', attachment: block.attachment }
119
+ case 'tool-call': return { kind: 'tool-call', callId: String(block.id), name: block.name, argsRaw: block.arguments }
120
+ default: return { kind: 'other', block }
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Create the initial Chat block for one streamed Assistant block kind.
126
+ * @param blockType - Wire block kind.
127
+ * @returns Empty block ready to receive deltas.
128
+ */
129
+ export function emptyAssistantBlock(blockType: string): AssistantBlock {
130
+ switch (blockType) {
131
+ case 'text': return { kind: 'text', text: '' }
132
+ case 'reasoning': return { kind: 'reasoning', text: '' }
133
+ case 'tool-call': return { kind: 'tool-call', callId: '', name: '', argsRaw: '' }
134
+ default: return { kind: 'other', block: null }
135
+ }
136
+ }
137
+
138
+ /** Display-safe failure fields retained by Chat projections. */
139
+ export interface DisplayFailure {
140
+ readonly code?: string
141
+ readonly message: string
142
+ }
143
+
144
+ /**
145
+ * Convert a durable failure to locale-independent fields safe for Chat.
146
+ * @param failure - Failure preserved by a Session event.
147
+ * @returns Sanitized message and optional stable provider code.
148
+ */
149
+ export function displayFailure(failure: unknown): DisplayFailure {
150
+ if (failure === null || typeof failure !== 'object') return { message: String(failure) }
151
+ const record = failure as { code?: unknown; message?: unknown }
152
+ const code = typeof record.code === 'string' ? record.code : undefined
153
+ // Provider AUTH messages may echo a masked or partially preserved credential.
154
+ // Keep the raw diagnostic in the Session log, but never retain it in UI state.
155
+ if (code === 'AUTH') return { code, message: '' }
156
+ return {
157
+ ...(code === undefined ? {} : { code }),
158
+ message: typeof record.message === 'string' ? record.message : JSON.stringify(failure),
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Whether a stream chunk carries visible model output for Chat timing.
164
+ * @param chunk - Stream chunk to inspect.
165
+ * @returns true for a non-empty text, reasoning, or Tool-call delta.
166
+ */
167
+ export function isTokenDelta(chunk: StreamChunk): boolean {
168
+ switch (chunk.type) {
169
+ case 'text-delta':
170
+ case 'reasoning-delta':
171
+ return chunk.text !== ''
172
+ case 'tool-call-delta':
173
+ return chunk.argumentsDelta !== '' || chunk.name !== undefined
174
+ default:
175
+ return false
176
+ }
177
+ }
178
+
179
+ /* jscpd:ignore-end */
@@ -0,0 +1,41 @@
1
+ import type { Context } from '@deepseek-ai/cordis'
2
+ import type {
3
+ ConversationNodeDefinition, UnknownSurfaceNode,
4
+ } from '@deepseek-ai/dsh-client-ui-conversation/client'
5
+ import { isAppendSurfaceEvent } from '@deepseek-ai/dsh-session/surface'
6
+ import { chatNode } from './common.ts'
7
+
8
+ declare module '../contract/chat-nodes.ts' {
9
+ interface ChatNodeDataMap {
10
+ /** Generic presentation of an unclaimed append-surface event. */
11
+ unknown: UnknownSurfaceNode
12
+ }
13
+ }
14
+
15
+ /** Unclaimed append-surface fallback Definition. */
16
+ export const unknownFallbackDefinition: ConversationNodeDefinition<UnknownSurfaceNode> = {
17
+ kind: 'unknown-surface',
18
+ target: 'chat',
19
+ match: event => event.type !== 'assistant/live-chunk' && isAppendSurfaceEvent(event)
20
+ ? { id: String(event.seq), role: 'start' }
21
+ : null,
22
+ start: (_context, match) => ({
23
+ kind: 'unknown',
24
+ seq: match.event.seq,
25
+ time: match.event.time,
26
+ type: match.event.type,
27
+ data: match.event.data,
28
+ }),
29
+ update: context => context.state,
30
+ buildViewNode: context => context.state === undefined
31
+ ? null
32
+ : chatNode(context, 'unknown', context.state.seq, context.state),
33
+ }
34
+
35
+ /**
36
+ * Register the unmatched append-surface fallback contribution.
37
+ * @param ctx - owning UI Conversation context.
38
+ */
39
+ export function registerUnknownConversationFallback(ctx: Context): void {
40
+ ctx.uiConversation.events.registerFallback(unknownFallbackDefinition)
41
+ }
@@ -0,0 +1,91 @@
1
+ import type { ChatConversationViewNode } from '../contract/chat-nodes.ts'
2
+ import { isAtOrOutside, type ChatGroupTree } from '../contract/group-tree.ts'
3
+ import { locationCoordinates } from './common.ts'
4
+
5
+ const NO_TURNS: readonly number[] = []
6
+
7
+ /**
8
+ * Loaded Turns split into consecutive segments at the Turns holding a Node at
9
+ * one group-tree position, visible or hidden. The latest segment starts at the
10
+ * last such Turn, or at the first loaded Turn when none is loaded. Node changes
11
+ * update per-Turn counts without scanning the loaded Nodes; `settle` returns at
12
+ * once while the start holds and otherwise reads loaded Turns only from the
13
+ * earlier of the previous and new starts.
14
+ */
15
+ export class GroupTreeSegments {
16
+ /** Opening Node count by owning Turn. */
17
+ private readonly openings = new Map<number, number>()
18
+ private latestOpening: number | undefined
19
+ private latestStart: number | undefined
20
+
21
+ /** @param position - group-tree position whose Nodes open a segment. */
22
+ constructor(private readonly position: ChatGroupTree) {}
23
+
24
+ /**
25
+ * Account one Node change.
26
+ * @param previous - replaced Node; absent for an addition.
27
+ * @param next - replacing Node; absent for a removal.
28
+ */
29
+ track(previous: ChatConversationViewNode | undefined, next: ChatConversationViewNode | undefined): void {
30
+ const before = this.openingTurn(previous)
31
+ const after = this.openingTurn(next)
32
+ if (before === after) return
33
+ if (before !== undefined && this.adjust(before, -1) === 0 && before === this.latestOpening) {
34
+ this.latestOpening = this.lastOpeningTurn()
35
+ }
36
+ if (after !== undefined) {
37
+ this.adjust(after, 1)
38
+ if (this.latestOpening === undefined || after > this.latestOpening) this.latestOpening = after
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Test latest-segment membership as of the last `settle`.
44
+ * @param turn - owning Turn, when resolved.
45
+ * @returns whether the Turn belongs to the latest segment.
46
+ */
47
+ inLatest(turn: number | undefined): boolean {
48
+ return turn !== undefined && this.latestStart !== undefined && turn >= this.latestStart
49
+ }
50
+
51
+ /**
52
+ * Move the latest segment start for the currently loaded Turns.
53
+ * @param turnOrder - loaded Turns in ascending timeline order.
54
+ * @returns loaded Turns that entered or left the latest segment, in ascending order.
55
+ */
56
+ settle(turnOrder: readonly number[]): readonly number[] {
57
+ const previous = this.latestStart
58
+ const start = this.latestOpening ?? turnOrder[0]
59
+ if (start === previous) return NO_TURNS
60
+ this.latestStart = start
61
+ const bounded = previous !== undefined && start !== undefined
62
+ const low = bounded ? Math.min(previous, start) : Number.NEGATIVE_INFINITY
63
+ const high = bounded ? Math.max(previous, start) : Number.POSITIVE_INFINITY
64
+ const changed: number[] = []
65
+ for (const turn of turnOrder.slice(turnOrder.findLastIndex(turn => turn < low) + 1)) {
66
+ if (turn >= high) break
67
+ changed.push(turn)
68
+ }
69
+ return changed
70
+ }
71
+
72
+ private openingTurn(node: ChatConversationViewNode | undefined): number | undefined {
73
+ return node !== undefined && isAtOrOutside(node, this.position) ? locationCoordinates(node.location).turn : undefined
74
+ }
75
+
76
+ private lastOpeningTurn(): number | undefined {
77
+ let last: number | undefined
78
+ for (const turn of this.openings.keys()) {
79
+ if (last === undefined || turn > last) last = turn
80
+ }
81
+ return last
82
+ }
83
+
84
+ /** @returns the Turn's opening count after the change; zero removes the Turn. */
85
+ private adjust(turn: number, delta: number): number {
86
+ const next = (this.openings.get(turn) ?? 0) + delta
87
+ if (next > 0) this.openings.set(turn, next)
88
+ else this.openings.delete(turn)
89
+ return next
90
+ }
91
+ }