@baishuyun/chat-sdk 0.0.18 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (447) hide show
  1. package/.turbo/turbo-build.log +175 -178
  2. package/CHANGELOG.md +25 -0
  3. package/dist/chat-sdk.js +11116 -11004
  4. package/dist/chat-sdk.js.map +1 -1
  5. package/dist/chat-sdk.umd.cjs +129 -127
  6. package/dist/chat-sdk.umd.cjs.map +1 -1
  7. package/dist/chat.d.ts +5 -0
  8. package/dist/chat.d.ts.map +1 -0
  9. package/dist/components/biz-comp/FakeBotMsg.d.ts +8 -0
  10. package/dist/components/biz-comp/FakeBotMsg.d.ts.map +1 -0
  11. package/dist/components/biz-comp/FieldChecker.d.ts +19 -0
  12. package/dist/components/biz-comp/FieldChecker.d.ts.map +1 -0
  13. package/dist/components/biz-comp/FieldCheckerListMsg.d.ts +19 -0
  14. package/dist/components/biz-comp/FieldCheckerListMsg.d.ts.map +1 -0
  15. package/dist/components/biz-comp/FieldValueChecker.d.ts +16 -0
  16. package/dist/components/biz-comp/FieldValueChecker.d.ts.map +1 -0
  17. package/dist/components/biz-comp/SubformFieldsValueChecker.d.ts +22 -0
  18. package/dist/components/biz-comp/SubformFieldsValueChecker.d.ts.map +1 -0
  19. package/dist/components/biz-comp/chat-client.d.ts +13 -0
  20. package/dist/components/biz-comp/chat-client.d.ts.map +1 -0
  21. package/dist/components/biz-comp/chat-frame.d.ts +6 -0
  22. package/dist/components/biz-comp/chat-frame.d.ts.map +1 -0
  23. package/dist/components/biz-comp/conversation.d.ts +10 -0
  24. package/dist/components/biz-comp/conversation.d.ts.map +1 -0
  25. package/dist/components/biz-comp/dash-widget-icon.d.ts +7 -0
  26. package/dist/components/biz-comp/dash-widget-icon.d.ts.map +1 -0
  27. package/dist/components/biz-comp/dock-btn.d.ts +2 -0
  28. package/dist/components/biz-comp/dock-btn.d.ts.map +1 -0
  29. package/dist/components/biz-comp/error-boundary.d.ts +15 -0
  30. package/dist/components/biz-comp/error-boundary.d.ts.map +1 -0
  31. package/dist/components/biz-comp/error-msg.d.ts +4 -0
  32. package/dist/components/biz-comp/error-msg.d.ts.map +1 -0
  33. package/dist/components/biz-comp/field-icon.d.ts +5 -0
  34. package/dist/components/biz-comp/field-icon.d.ts.map +1 -0
  35. package/dist/components/biz-comp/highlight-msg.d.ts +4 -0
  36. package/dist/components/biz-comp/highlight-msg.d.ts.map +1 -0
  37. package/dist/components/biz-comp/markdown-part.d.ts +7 -0
  38. package/dist/components/biz-comp/markdown-part.d.ts.map +1 -0
  39. package/dist/components/biz-comp/markdown.d.ts +5 -0
  40. package/dist/components/biz-comp/markdown.d.ts.map +1 -0
  41. package/dist/components/biz-comp/message-content.d.ts +6 -0
  42. package/dist/components/biz-comp/message-content.d.ts.map +1 -0
  43. package/dist/components/biz-comp/messages.d.ts +3 -0
  44. package/dist/components/biz-comp/messages.d.ts.map +1 -0
  45. package/dist/components/biz-comp/multi-modal-input/attachment-btn.d.ts +9 -0
  46. package/dist/components/biz-comp/multi-modal-input/attachment-btn.d.ts.map +1 -0
  47. package/dist/components/biz-comp/multi-modal-input/clear-btn.d.ts +8 -0
  48. package/dist/components/biz-comp/multi-modal-input/clear-btn.d.ts.map +1 -0
  49. package/dist/components/biz-comp/multi-modal-input/index.d.ts +21 -0
  50. package/dist/components/biz-comp/multi-modal-input/index.d.ts.map +1 -0
  51. package/dist/components/biz-comp/multi-modal-input/preview-attachment.d.ts +12 -0
  52. package/dist/components/biz-comp/multi-modal-input/preview-attachment.d.ts.map +1 -0
  53. package/dist/components/biz-comp/multi-modal-input/prompt-input.d.ts +36 -0
  54. package/dist/components/biz-comp/multi-modal-input/prompt-input.d.ts.map +1 -0
  55. package/dist/components/biz-comp/opening-lines.d.ts +3 -0
  56. package/dist/components/biz-comp/opening-lines.d.ts.map +1 -0
  57. package/dist/components/biz-comp/preview-message-wrapper.d.ts +12 -0
  58. package/dist/components/biz-comp/preview-message-wrapper.d.ts.map +1 -0
  59. package/dist/components/biz-comp/preview-message.d.ts +13 -0
  60. package/dist/components/biz-comp/preview-message.d.ts.map +1 -0
  61. package/dist/components/biz-comp/response.d.ts +6 -0
  62. package/dist/components/biz-comp/response.d.ts.map +1 -0
  63. package/dist/components/biz-comp/suggestions.d.ts +8 -0
  64. package/dist/components/biz-comp/suggestions.d.ts.map +1 -0
  65. package/dist/components/bs-ui/abs-fullscreen-gradient-bg.d.ts +10 -0
  66. package/dist/components/bs-ui/abs-fullscreen-gradient-bg.d.ts.map +1 -0
  67. package/dist/components/bs-ui/attachment-part-group.d.ts +16 -0
  68. package/dist/components/bs-ui/attachment-part-group.d.ts.map +1 -0
  69. package/dist/components/bs-ui/attachment-part.d.ts +19 -0
  70. package/dist/components/bs-ui/attachment-part.d.ts.map +1 -0
  71. package/dist/components/bs-ui/attachments-previewer.d.ts +18 -0
  72. package/dist/components/bs-ui/attachments-previewer.d.ts.map +1 -0
  73. package/dist/components/bs-ui/base-button.d.ts +8 -0
  74. package/dist/components/bs-ui/base-button.d.ts.map +1 -0
  75. package/dist/components/bs-ui/border-animation.d.ts +23 -0
  76. package/dist/components/bs-ui/border-animation.d.ts.map +1 -0
  77. package/dist/components/bs-ui/border-color-animation.d.ts +11 -0
  78. package/dist/components/bs-ui/border-color-animation.d.ts.map +1 -0
  79. package/dist/components/bs-ui/bot-avatar-name.d.ts +6 -0
  80. package/dist/components/bs-ui/bot-avatar-name.d.ts.map +1 -0
  81. package/dist/components/bs-ui/bot-icon.d.ts +5 -0
  82. package/dist/components/bs-ui/bot-icon.d.ts.map +1 -0
  83. package/dist/components/bs-ui/bs-icons.d.ts +65 -0
  84. package/dist/components/bs-ui/bs-icons.d.ts.map +1 -0
  85. package/dist/components/bs-ui/card-field.d.ts +11 -0
  86. package/dist/components/bs-ui/card-field.d.ts.map +1 -0
  87. package/dist/components/bs-ui/card.d.ts +11 -0
  88. package/dist/components/bs-ui/card.d.ts.map +1 -0
  89. package/dist/components/bs-ui/chat-area-header.d.ts +13 -0
  90. package/dist/components/bs-ui/chat-area-header.d.ts.map +1 -0
  91. package/dist/components/bs-ui/circle-checker.d.ts +10 -0
  92. package/dist/components/bs-ui/circle-checker.d.ts.map +1 -0
  93. package/dist/components/bs-ui/collapsible-txt-msg.d.ts +11 -0
  94. package/dist/components/bs-ui/collapsible-txt-msg.d.ts.map +1 -0
  95. package/dist/components/bs-ui/confirm-dialog.d.ts +26 -0
  96. package/dist/components/bs-ui/confirm-dialog.d.ts.map +1 -0
  97. package/dist/components/bs-ui/fields-design-info-table.d.ts +7 -0
  98. package/dist/components/bs-ui/fields-design-info-table.d.ts.map +1 -0
  99. package/dist/components/bs-ui/fields-generating-indicator.d.ts +6 -0
  100. package/dist/components/bs-ui/fields-generating-indicator.d.ts.map +1 -0
  101. package/dist/components/bs-ui/fields-portal.d.ts +8 -0
  102. package/dist/components/bs-ui/fields-portal.d.ts.map +1 -0
  103. package/dist/components/bs-ui/fields-previewer.d.ts +18 -0
  104. package/dist/components/bs-ui/fields-previewer.d.ts.map +1 -0
  105. package/dist/components/bs-ui/font-icon.d.ts +6 -0
  106. package/dist/components/bs-ui/font-icon.d.ts.map +1 -0
  107. package/dist/components/bs-ui/form-info-editor.d.ts +37 -0
  108. package/dist/components/bs-ui/form-info-editor.d.ts.map +1 -0
  109. package/dist/components/bs-ui/formula-tag.d.ts +8 -0
  110. package/dist/components/bs-ui/formula-tag.d.ts.map +1 -0
  111. package/dist/components/bs-ui/generate-animation.d.ts +5 -0
  112. package/dist/components/bs-ui/generate-animation.d.ts.map +1 -0
  113. package/dist/components/bs-ui/icon-btn.d.ts +9 -0
  114. package/dist/components/bs-ui/icon-btn.d.ts.map +1 -0
  115. package/dist/components/bs-ui/img-part.d.ts +10 -0
  116. package/dist/components/bs-ui/img-part.d.ts.map +1 -0
  117. package/dist/components/bs-ui/line-checker.d.ts +19 -0
  118. package/dist/components/bs-ui/line-checker.d.ts.map +1 -0
  119. package/dist/components/bs-ui/linear-gradient-border-btn.d.ts +10 -0
  120. package/dist/components/bs-ui/linear-gradient-border-btn.d.ts.map +1 -0
  121. package/dist/components/bs-ui/linear-gradient-color-bg-animation.d.ts +8 -0
  122. package/dist/components/bs-ui/linear-gradient-color-bg-animation.d.ts.map +1 -0
  123. package/dist/components/bs-ui/number-part.d.ts +9 -0
  124. package/dist/components/bs-ui/number-part.d.ts.map +1 -0
  125. package/dist/components/bs-ui/option-item.d.ts +9 -0
  126. package/dist/components/bs-ui/option-item.d.ts.map +1 -0
  127. package/dist/components/bs-ui/previewer-header.d.ts +20 -0
  128. package/dist/components/bs-ui/previewer-header.d.ts.map +1 -0
  129. package/dist/components/bs-ui/primary-confirm-btn.d.ts +10 -0
  130. package/dist/components/bs-ui/primary-confirm-btn.d.ts.map +1 -0
  131. package/dist/components/bs-ui/primary-entry-btn.d.ts +9 -0
  132. package/dist/components/bs-ui/primary-entry-btn.d.ts.map +1 -0
  133. package/dist/components/bs-ui/scroll-to-bottom-btn.d.ts +6 -0
  134. package/dist/components/bs-ui/scroll-to-bottom-btn.d.ts.map +1 -0
  135. package/dist/components/bs-ui/split-line.d.ts +5 -0
  136. package/dist/components/bs-ui/split-line.d.ts.map +1 -0
  137. package/dist/components/bs-ui/square-checker.d.ts +15 -0
  138. package/dist/components/bs-ui/square-checker.d.ts.map +1 -0
  139. package/dist/components/bs-ui/tab-radio-group.d.ts +19 -0
  140. package/dist/components/bs-ui/tab-radio-group.d.ts.map +1 -0
  141. package/dist/components/bs-ui/tooltip.d.ts +6 -0
  142. package/dist/components/bs-ui/tooltip.d.ts.map +1 -0
  143. package/dist/components/bs-ui/user-txt-msg-bubble.d.ts +6 -0
  144. package/dist/components/bs-ui/user-txt-msg-bubble.d.ts.map +1 -0
  145. package/dist/components/bs-ui/warning-msg.d.ts +6 -0
  146. package/dist/components/bs-ui/warning-msg.d.ts.map +1 -0
  147. package/dist/components/ui/badge.d.ts +10 -0
  148. package/dist/components/ui/badge.d.ts.map +1 -0
  149. package/dist/components/ui/button.d.ts +12 -0
  150. package/dist/components/ui/button.d.ts.map +1 -0
  151. package/dist/components/ui/card.d.ts +9 -0
  152. package/dist/components/ui/card.d.ts.map +1 -0
  153. package/dist/components/ui/checkbox.d.ts +5 -0
  154. package/dist/components/ui/checkbox.d.ts.map +1 -0
  155. package/dist/components/ui/collapsible.d.ts +6 -0
  156. package/dist/components/ui/collapsible.d.ts.map +1 -0
  157. package/dist/components/ui/dialog.d.ts +24 -0
  158. package/dist/components/ui/dialog.d.ts.map +1 -0
  159. package/dist/components/ui/dropdown-menu.d.ts +28 -0
  160. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  161. package/dist/components/ui/icons.d.ts +176 -0
  162. package/dist/components/ui/icons.d.ts.map +1 -0
  163. package/dist/components/ui/input-group.d.ts +17 -0
  164. package/dist/components/ui/input-group.d.ts.map +1 -0
  165. package/dist/components/ui/input.d.ts +4 -0
  166. package/dist/components/ui/input.d.ts.map +1 -0
  167. package/dist/components/ui/label.d.ts +6 -0
  168. package/dist/components/ui/label.d.ts.map +1 -0
  169. package/dist/components/ui/one-time-click-btn.d.ts +4 -0
  170. package/dist/components/ui/one-time-click-btn.d.ts.map +1 -0
  171. package/dist/components/ui/select.d.ts +14 -0
  172. package/dist/components/ui/select.d.ts.map +1 -0
  173. package/dist/components/ui/spinner.d.ts +3 -0
  174. package/dist/components/ui/spinner.d.ts.map +1 -0
  175. package/dist/components/ui/tabs.d.ts +8 -0
  176. package/dist/components/ui/tabs.d.ts.map +1 -0
  177. package/dist/components/ui/textarea.d.ts +4 -0
  178. package/dist/components/ui/textarea.d.ts.map +1 -0
  179. package/dist/components/ui/tooltip.d.ts +13 -0
  180. package/dist/components/ui/tooltip.d.ts.map +1 -0
  181. package/dist/components/web-comp/fields-previewer-web-component.d.ts +60 -0
  182. package/dist/components/web-comp/fields-previewer-web-component.d.ts.map +1 -0
  183. package/dist/const/index.d.ts +5 -0
  184. package/dist/const/index.d.ts.map +1 -0
  185. package/dist/const/ui.d.ts +7 -0
  186. package/dist/const/ui.d.ts.map +1 -0
  187. package/dist/hooks/use-chat-preference.d.ts +3 -0
  188. package/dist/hooks/use-chat-preference.d.ts.map +1 -0
  189. package/dist/hooks/use-draggable.d.ts +24 -0
  190. package/dist/hooks/use-draggable.d.ts.map +1 -0
  191. package/dist/hooks/use-evt-bus.d.ts +2 -0
  192. package/dist/hooks/use-evt-bus.d.ts.map +1 -0
  193. package/dist/hooks/use-evt.d.ts +3 -0
  194. package/dist/hooks/use-evt.d.ts.map +1 -0
  195. package/dist/hooks/use-frame-mode.d.ts +20 -0
  196. package/dist/hooks/use-frame-mode.d.ts.map +1 -0
  197. package/dist/hooks/use-merged-chat.d.ts +7 -0
  198. package/dist/hooks/use-merged-chat.d.ts.map +1 -0
  199. package/dist/hooks/use-msg-status-broadcast.d.ts +3 -0
  200. package/dist/hooks/use-msg-status-broadcast.d.ts.map +1 -0
  201. package/dist/hooks/use-plugin-component.d.ts +5 -0
  202. package/dist/hooks/use-plugin-component.d.ts.map +1 -0
  203. package/dist/hooks/use-plugin-ctx.d.ts +3 -0
  204. package/dist/hooks/use-plugin-ctx.d.ts.map +1 -0
  205. package/dist/hooks/use-plugin-custom-components.d.ts +5 -0
  206. package/dist/hooks/use-plugin-custom-components.d.ts.map +1 -0
  207. package/dist/hooks/use-plugin-life-cycle-chain-runner.d.ts +5 -0
  208. package/dist/hooks/use-plugin-life-cycle-chain-runner.d.ts.map +1 -0
  209. package/dist/hooks/use-plugin-list.d.ts +2 -0
  210. package/dist/hooks/use-plugin-list.d.ts.map +1 -0
  211. package/dist/hooks/use-plugin.d.ts +2 -0
  212. package/dist/hooks/use-plugin.d.ts.map +1 -0
  213. package/dist/hooks/use-scroll-to-bottom.d.ts +9 -0
  214. package/dist/hooks/use-scroll-to-bottom.d.ts.map +1 -0
  215. package/dist/hooks/use-shadow.d.ts +25 -0
  216. package/dist/hooks/use-shadow.d.ts.map +1 -0
  217. package/dist/hooks/use-toast.d.ts +3 -0
  218. package/dist/hooks/use-toast.d.ts.map +1 -0
  219. package/dist/index.d.ts +6 -0
  220. package/dist/index.d.ts.map +1 -0
  221. package/dist/lib/clone.d.ts +32 -0
  222. package/dist/lib/clone.d.ts.map +1 -0
  223. package/dist/lib/event-emitter.d.ts +39 -0
  224. package/dist/lib/event-emitter.d.ts.map +1 -0
  225. package/dist/lib/parse-design-doc.d.ts +16 -0
  226. package/dist/lib/parse-design-doc.d.ts.map +1 -0
  227. package/dist/lib/readonly.d.ts +14 -0
  228. package/dist/lib/readonly.d.ts.map +1 -0
  229. package/dist/lib/utils.d.ts +55 -0
  230. package/dist/lib/utils.d.ts.map +1 -0
  231. package/dist/plugins/form-builder-base-plugin/const.d.ts +3 -0
  232. package/dist/plugins/form-builder-base-plugin/const.d.ts.map +1 -0
  233. package/dist/plugins/form-builder-base-plugin/index.d.ts +7 -0
  234. package/dist/plugins/form-builder-base-plugin/index.d.ts.map +1 -0
  235. package/dist/plugins/form-builder-base-plugin/types.d.ts +12 -0
  236. package/dist/plugins/form-builder-base-plugin/types.d.ts.map +1 -0
  237. package/dist/plugins/form-builder-plugin/components/create-form-confirm.d.ts +7 -0
  238. package/dist/plugins/form-builder-plugin/components/create-form-confirm.d.ts.map +1 -0
  239. package/dist/plugins/form-builder-plugin/components/design-doc-part.d.ts +4 -0
  240. package/dist/plugins/form-builder-plugin/components/design-doc-part.d.ts.map +1 -0
  241. package/dist/plugins/form-builder-plugin/components/design-info.d.ts +6 -0
  242. package/dist/plugins/form-builder-plugin/components/design-info.d.ts.map +1 -0
  243. package/dist/plugins/form-builder-plugin/components/entry-btn.d.ts +3 -0
  244. package/dist/plugins/form-builder-plugin/components/entry-btn.d.ts.map +1 -0
  245. package/dist/plugins/form-builder-plugin/components/fields-part.d.ts +4 -0
  246. package/dist/plugins/form-builder-plugin/components/fields-part.d.ts.map +1 -0
  247. package/dist/plugins/form-builder-plugin/components/follow-up.d.ts +3 -0
  248. package/dist/plugins/form-builder-plugin/components/follow-up.d.ts.map +1 -0
  249. package/dist/plugins/form-builder-plugin/components/msg-part.d.ts +3 -0
  250. package/dist/plugins/form-builder-plugin/components/msg-part.d.ts.map +1 -0
  251. package/dist/plugins/form-builder-plugin/components/opening-lines.d.ts +3 -0
  252. package/dist/plugins/form-builder-plugin/components/opening-lines.d.ts.map +1 -0
  253. package/dist/plugins/form-builder-plugin/components/suggestion-part.d.ts +5 -0
  254. package/dist/plugins/form-builder-plugin/components/suggestion-part.d.ts.map +1 -0
  255. package/dist/plugins/form-builder-plugin/const/index.d.ts +12 -0
  256. package/dist/plugins/form-builder-plugin/const/index.d.ts.map +1 -0
  257. package/dist/plugins/form-builder-plugin/hooks/index.d.ts +4 -0
  258. package/dist/plugins/form-builder-plugin/hooks/index.d.ts.map +1 -0
  259. package/dist/plugins/form-builder-plugin/hooks/use-fields-confirmed.d.ts +2 -0
  260. package/dist/plugins/form-builder-plugin/hooks/use-fields-confirmed.d.ts.map +1 -0
  261. package/dist/plugins/form-builder-plugin/index.d.ts +30 -0
  262. package/dist/plugins/form-builder-plugin/index.d.ts.map +1 -0
  263. package/dist/plugins/form-builder-plugin/types.d.ts +28 -0
  264. package/dist/plugins/form-builder-plugin/types.d.ts.map +1 -0
  265. package/dist/plugins/form-builder-plugin/utils/get-render-strategy.d.ts +3 -0
  266. package/dist/plugins/form-builder-plugin/utils/get-render-strategy.d.ts.map +1 -0
  267. package/dist/plugins/form-builder-plugin/utils/index.d.ts +57 -0
  268. package/dist/plugins/form-builder-plugin/utils/index.d.ts.map +1 -0
  269. package/dist/plugins/form-filling-plugin/batch-filling-data-manager.d.ts +26 -0
  270. package/dist/plugins/form-filling-plugin/batch-filling-data-manager.d.ts.map +1 -0
  271. package/dist/plugins/form-filling-plugin/components/FormFillingOpeningLines.d.ts +3 -0
  272. package/dist/plugins/form-filling-plugin/components/FormFillingOpeningLines.d.ts.map +1 -0
  273. package/dist/plugins/form-filling-plugin/components/avatar.d.ts +5 -0
  274. package/dist/plugins/form-filling-plugin/components/avatar.d.ts.map +1 -0
  275. package/dist/plugins/form-filling-plugin/components/batch-fill-part.d.ts +4 -0
  276. package/dist/plugins/form-filling-plugin/components/batch-fill-part.d.ts.map +1 -0
  277. package/dist/plugins/form-filling-plugin/components/batch-generator-action.d.ts +14 -0
  278. package/dist/plugins/form-filling-plugin/components/batch-generator-action.d.ts.map +1 -0
  279. package/dist/plugins/form-filling-plugin/components/entry-btn.d.ts +3 -0
  280. package/dist/plugins/form-filling-plugin/components/entry-btn.d.ts.map +1 -0
  281. package/dist/plugins/form-filling-plugin/components/first-batch-generating-animation.d.ts +2 -0
  282. package/dist/plugins/form-filling-plugin/components/first-batch-generating-animation.d.ts.map +1 -0
  283. package/dist/plugins/form-filling-plugin/components/generated-data-counter.d.ts +5 -0
  284. package/dist/plugins/form-filling-plugin/components/generated-data-counter.d.ts.map +1 -0
  285. package/dist/plugins/form-filling-plugin/components/mode-select.d.ts +2 -0
  286. package/dist/plugins/form-filling-plugin/components/mode-select.d.ts.map +1 -0
  287. package/dist/plugins/form-filling-plugin/components/msg-part.d.ts +3 -0
  288. package/dist/plugins/form-filling-plugin/components/msg-part.d.ts.map +1 -0
  289. package/dist/plugins/form-filling-plugin/components/non-first-batch-generating-animation.d.ts +2 -0
  290. package/dist/plugins/form-filling-plugin/components/non-first-batch-generating-animation.d.ts.map +1 -0
  291. package/dist/plugins/form-filling-plugin/components/single-fill-part.d.ts +4 -0
  292. package/dist/plugins/form-filling-plugin/components/single-fill-part.d.ts.map +1 -0
  293. package/dist/plugins/form-filling-plugin/const.d.ts +615 -0
  294. package/dist/plugins/form-filling-plugin/const.d.ts.map +1 -0
  295. package/dist/plugins/form-filling-plugin/hooks/use-conversation-id-in-ctx.d.ts +3 -0
  296. package/dist/plugins/form-filling-plugin/hooks/use-conversation-id-in-ctx.d.ts.map +1 -0
  297. package/dist/plugins/form-filling-plugin/hooks/use-fields-data.d.ts +4 -0
  298. package/dist/plugins/form-filling-plugin/hooks/use-fields-data.d.ts.map +1 -0
  299. package/dist/plugins/form-filling-plugin/index.d.ts +22 -0
  300. package/dist/plugins/form-filling-plugin/index.d.ts.map +1 -0
  301. package/dist/plugins/form-filling-plugin/types.d.ts +22 -0
  302. package/dist/plugins/form-filling-plugin/types.d.ts.map +1 -0
  303. package/dist/plugins/form-filling-plugin/utils.d.ts +6 -0
  304. package/dist/plugins/form-filling-plugin/utils.d.ts.map +1 -0
  305. package/dist/plugins/report-query-plugin/components/avatar.d.ts +5 -0
  306. package/dist/plugins/report-query-plugin/components/avatar.d.ts.map +1 -0
  307. package/dist/plugins/report-query-plugin/components/query-entry-btn.d.ts +3 -0
  308. package/dist/plugins/report-query-plugin/components/query-entry-btn.d.ts.map +1 -0
  309. package/dist/plugins/report-query-plugin/components/query-msg-part.d.ts +3 -0
  310. package/dist/plugins/report-query-plugin/components/query-msg-part.d.ts.map +1 -0
  311. package/dist/plugins/report-query-plugin/components/query-opening-lines.d.ts +2 -0
  312. package/dist/plugins/report-query-plugin/components/query-opening-lines.d.ts.map +1 -0
  313. package/dist/plugins/report-query-plugin/components/result-cards/CreatedSourceMsg.d.ts +7 -0
  314. package/dist/plugins/report-query-plugin/components/result-cards/CreatedSourceMsg.d.ts.map +1 -0
  315. package/dist/plugins/report-query-plugin/components/result-cards/DataTableCard.d.ts +5 -0
  316. package/dist/plugins/report-query-plugin/components/result-cards/DataTableCard.d.ts.map +1 -0
  317. package/dist/plugins/report-query-plugin/components/result-cards/DataTableFields.d.ts +18 -0
  318. package/dist/plugins/report-query-plugin/components/result-cards/DataTableFields.d.ts.map +1 -0
  319. package/dist/plugins/report-query-plugin/components/result-cards/FilterCondition.d.ts +4 -0
  320. package/dist/plugins/report-query-plugin/components/result-cards/FilterCondition.d.ts.map +1 -0
  321. package/dist/plugins/report-query-plugin/components/result-cards/FormulaField.d.ts +8 -0
  322. package/dist/plugins/report-query-plugin/components/result-cards/FormulaField.d.ts.map +1 -0
  323. package/dist/plugins/report-query-plugin/const.d.ts +5 -0
  324. package/dist/plugins/report-query-plugin/const.d.ts.map +1 -0
  325. package/dist/plugins/report-query-plugin/index.d.ts +19 -0
  326. package/dist/plugins/report-query-plugin/index.d.ts.map +1 -0
  327. package/dist/plugins/report-query-plugin/types.d.ts +18 -0
  328. package/dist/plugins/report-query-plugin/types.d.ts.map +1 -0
  329. package/dist/plugins/report-query-plugin/utils/build-dash-component.d.ts +17 -0
  330. package/dist/plugins/report-query-plugin/utils/build-dash-component.d.ts.map +1 -0
  331. package/dist/plugins/report-query-plugin/utils/create-default-dash-styles.d.ts +30 -0
  332. package/dist/plugins/report-query-plugin/utils/create-default-dash-styles.d.ts.map +1 -0
  333. package/dist/plugins/report-query-plugin/utils/create-default-widget-attr-list.d.ts +60 -0
  334. package/dist/plugins/report-query-plugin/utils/create-default-widget-attr-list.d.ts.map +1 -0
  335. package/dist/plugins/report-query-plugin/utils/field-enhance.d.ts +31 -0
  336. package/dist/plugins/report-query-plugin/utils/field-enhance.d.ts.map +1 -0
  337. package/dist/plugins/report-query-plugin/utils/get-field-group.d.ts +208 -0
  338. package/dist/plugins/report-query-plugin/utils/get-field-group.d.ts.map +1 -0
  339. package/dist/plugins/report-query-plugin/utils/get-field-icon.d.ts +4 -0
  340. package/dist/plugins/report-query-plugin/utils/get-field-icon.d.ts.map +1 -0
  341. package/dist/plugins/report-query-plugin/utils/get-group-rule.d.ts +4 -0
  342. package/dist/plugins/report-query-plugin/utils/get-group-rule.d.ts.map +1 -0
  343. package/dist/plugins/report-query-plugin/utils/index.d.ts +5 -0
  344. package/dist/plugins/report-query-plugin/utils/index.d.ts.map +1 -0
  345. package/dist/sdk.impl.d.ts +42 -0
  346. package/dist/sdk.impl.d.ts.map +1 -0
  347. package/dist/store/context.d.ts +12 -0
  348. package/dist/store/context.d.ts.map +1 -0
  349. package/dist/store/index.d.ts +14 -0
  350. package/dist/store/index.d.ts.map +1 -0
  351. package/dist/stories/AbsFullscreenGradientBg.stories.d.ts +17 -0
  352. package/dist/stories/AbsFullscreenGradientBg.stories.d.ts.map +1 -0
  353. package/dist/stories/AttachmentPart.stories.d.ts +23 -0
  354. package/dist/stories/AttachmentPart.stories.d.ts.map +1 -0
  355. package/dist/stories/AttachmentPartGroup.stories.d.ts +21 -0
  356. package/dist/stories/AttachmentPartGroup.stories.d.ts.map +1 -0
  357. package/dist/stories/AttachmentsPreviewer.stories.d.ts +20 -0
  358. package/dist/stories/AttachmentsPreviewer.stories.d.ts.map +1 -0
  359. package/dist/stories/BaseButton.stories.d.ts +18 -0
  360. package/dist/stories/BaseButton.stories.d.ts.map +1 -0
  361. package/dist/stories/BorderAnimation.stories.d.ts +21 -0
  362. package/dist/stories/BorderAnimation.stories.d.ts.map +1 -0
  363. package/dist/stories/BorderColorAnimation.stories.d.ts +26 -0
  364. package/dist/stories/BorderColorAnimation.stories.d.ts.map +1 -0
  365. package/dist/stories/BotAvatarAndName.stories.d.ts +18 -0
  366. package/dist/stories/BotAvatarAndName.stories.d.ts.map +1 -0
  367. package/dist/stories/BotIcon.stories.d.ts +17 -0
  368. package/dist/stories/BotIcon.stories.d.ts.map +1 -0
  369. package/dist/stories/BsTooltip.stories.d.ts +7 -0
  370. package/dist/stories/BsTooltip.stories.d.ts.map +1 -0
  371. package/dist/stories/Card.stories.d.ts +14 -0
  372. package/dist/stories/Card.stories.d.ts.map +1 -0
  373. package/dist/stories/CardField.stories.d.ts +13 -0
  374. package/dist/stories/CardField.stories.d.ts.map +1 -0
  375. package/dist/stories/ChatAreaHeader.stories.d.ts +14 -0
  376. package/dist/stories/ChatAreaHeader.stories.d.ts.map +1 -0
  377. package/dist/stories/CircleChecker.stories.d.ts +21 -0
  378. package/dist/stories/CircleChecker.stories.d.ts.map +1 -0
  379. package/dist/stories/CollapsibleTextMsg.stories.d.ts +16 -0
  380. package/dist/stories/CollapsibleTextMsg.stories.d.ts.map +1 -0
  381. package/dist/stories/ConfirmDialog.stories.d.ts +61 -0
  382. package/dist/stories/ConfirmDialog.stories.d.ts.map +1 -0
  383. package/dist/stories/DashWidgetIcon.stories.d.ts +13 -0
  384. package/dist/stories/DashWidgetIcon.stories.d.ts.map +1 -0
  385. package/dist/stories/FormInfoEditor.stories.d.ts +15 -0
  386. package/dist/stories/FormInfoEditor.stories.d.ts.map +1 -0
  387. package/dist/stories/FormulaField.stories.d.ts +24 -0
  388. package/dist/stories/FormulaField.stories.d.ts.map +1 -0
  389. package/dist/stories/FormulaTag.stories.d.ts +37 -0
  390. package/dist/stories/FormulaTag.stories.d.ts.map +1 -0
  391. package/dist/stories/GenerateAnimation.stories.d.ts +17 -0
  392. package/dist/stories/GenerateAnimation.stories.d.ts.map +1 -0
  393. package/dist/stories/IconBtn.stories.d.ts +15 -0
  394. package/dist/stories/IconBtn.stories.d.ts.map +1 -0
  395. package/dist/stories/IconLib.d.ts +12 -0
  396. package/dist/stories/IconLib.d.ts.map +1 -0
  397. package/dist/stories/Icons.stories.d.ts +24 -0
  398. package/dist/stories/Icons.stories.d.ts.map +1 -0
  399. package/dist/stories/ImgMsgPart.stories.d.ts +20 -0
  400. package/dist/stories/ImgMsgPart.stories.d.ts.map +1 -0
  401. package/dist/stories/LineChecker.stories.d.ts +23 -0
  402. package/dist/stories/LineChecker.stories.d.ts.map +1 -0
  403. package/dist/stories/LinearGradientBorderBtn.stories.d.ts +22 -0
  404. package/dist/stories/LinearGradientBorderBtn.stories.d.ts.map +1 -0
  405. package/dist/stories/LinearGradientColorBgAnimation.stories.d.ts +23 -0
  406. package/dist/stories/LinearGradientColorBgAnimation.stories.d.ts.map +1 -0
  407. package/dist/stories/NumbersMsgPart.stories.d.ts +19 -0
  408. package/dist/stories/NumbersMsgPart.stories.d.ts.map +1 -0
  409. package/dist/stories/OptionItem.stories.d.ts +20 -0
  410. package/dist/stories/OptionItem.stories.d.ts.map +1 -0
  411. package/dist/stories/PreviewerHeader.stories.d.ts +12 -0
  412. package/dist/stories/PreviewerHeader.stories.d.ts.map +1 -0
  413. package/dist/stories/PrimaryConfirmBtn.stories.d.ts +19 -0
  414. package/dist/stories/PrimaryConfirmBtn.stories.d.ts.map +1 -0
  415. package/dist/stories/PrimaryEntryBtn.stories.d.ts +26 -0
  416. package/dist/stories/PrimaryEntryBtn.stories.d.ts.map +1 -0
  417. package/dist/stories/ScrollToBottom.stories.d.ts +15 -0
  418. package/dist/stories/ScrollToBottom.stories.d.ts.map +1 -0
  419. package/dist/stories/SplitLine.stories.d.ts +9 -0
  420. package/dist/stories/SplitLine.stories.d.ts.map +1 -0
  421. package/dist/stories/SquareChecker.stories.d.ts +26 -0
  422. package/dist/stories/SquareChecker.stories.d.ts.map +1 -0
  423. package/dist/stories/TabRadioGroup.stories.d.ts +18 -0
  424. package/dist/stories/TabRadioGroup.stories.d.ts.map +1 -0
  425. package/dist/stories/UserTextMsgBubble.stories.d.ts +14 -0
  426. package/dist/stories/UserTextMsgBubble.stories.d.ts.map +1 -0
  427. package/dist/stories/WarningMessage.stories.d.ts +16 -0
  428. package/dist/stories/WarningMessage.stories.d.ts.map +1 -0
  429. package/dist/stories/fields-design-info-table.stories.d.ts +14 -0
  430. package/dist/stories/fields-design-info-table.stories.d.ts.map +1 -0
  431. package/dist/stories/fields-generating.stories.d.ts +20 -0
  432. package/dist/stories/fields-generating.stories.d.ts.map +1 -0
  433. package/dist/stories/fields-previewer.stories.d.ts +19 -0
  434. package/dist/stories/fields-previewer.stories.d.ts.map +1 -0
  435. package/package.json +4 -4
  436. package/src/chat.tsx +59 -1
  437. package/src/components/biz-comp/FakeBotMsg.tsx +4 -1
  438. package/src/components/biz-comp/chat-client.tsx +1 -1
  439. package/src/components/biz-comp/markdown-part.tsx +17 -4
  440. package/src/components/biz-comp/multi-modal-input/index.tsx +7 -5
  441. package/src/components/biz-comp/preview-message-wrapper.tsx +3 -1
  442. package/src/components/biz-comp/preview-message.tsx +15 -0
  443. package/src/components/bs-ui/fields-design-info-table.tsx +9 -9
  444. package/src/lib/utils.ts +34 -0
  445. package/src/plugins/report-query-plugin/index.ts +1 -1
  446. package/src/sdk.impl.tsx +54 -7
  447. package/src/store/index.ts +8 -0
@@ -6,6 +6,7 @@ import { UserTextMsgBubble } from '../bs-ui/user-txt-msg-bubble';
6
6
  import { CollapsibleTxtMsg } from '../bs-ui/collapsible-txt-msg';
7
7
  import { AnalysisIcon } from '../bs-ui/bs-icons';
8
8
  import { UIDataTypes, UIMessagePart, UITools } from 'ai';
9
+ import { formatJSONIfValid } from '@/lib/utils';
9
10
 
10
11
  export const MarkdownMsgpart = (
11
12
  props: MsgPartCompProps & {
@@ -14,7 +15,7 @@ export const MarkdownMsgpart = (
14
15
  collapsibleTitle?: string;
15
16
  }
16
17
  ) => {
17
- const { part: p, role, id, collapsible = true, collapsibleTitle = '表单设计' } = props;
18
+ const { part: p, role, id, collapsible = true, collapsibleTitle, title, status } = props;
18
19
 
19
20
  const part = p as UIMessagePart<UIDataTypes, UITools>;
20
21
 
@@ -30,6 +31,18 @@ export const MarkdownMsgpart = (
30
31
  return <UserTextMsgBubble>{part.text}</UserTextMsgBubble>;
31
32
  }
32
33
 
34
+ const rawContent = sanitizeText(part.text);
35
+ let displayContent = rawContent;
36
+
37
+ if (status === 'ready') {
38
+
39
+ // 如果是合法 JSON,包装为代码块格式
40
+ const formattedJSON = formatJSONIfValid(rawContent);
41
+ if (formattedJSON) {
42
+ displayContent = `\`\`\`json\n${formattedJSON}\n\`\`\``;
43
+ }
44
+ }
45
+
33
46
  if (!collapsible) {
34
47
  return (
35
48
  <div>
@@ -42,7 +55,7 @@ export const MarkdownMsgpart = (
42
55
  data-testid="message-content"
43
56
  >
44
57
  <article className={typoCls} style={{ fontSize: 14 }}>
45
- <MemoizedMarkdown id={id} content={sanitizeText(part.text)} />
58
+ <MemoizedMarkdown id={id} content={displayContent} />
46
59
  </article>
47
60
  {props.children}
48
61
  </MessageContent>
@@ -60,9 +73,9 @@ export const MarkdownMsgpart = (
60
73
  })}
61
74
  data-testid="message-content"
62
75
  >
63
- <CollapsibleTxtMsg title={collapsibleTitle} icon={<AnalysisIcon />} defaultOpen>
76
+ <CollapsibleTxtMsg title={collapsibleTitle || title || '表单设计'} icon={<AnalysisIcon />} defaultOpen>
64
77
  <article className={typoCls} style={{ fontSize: 14 }}>
65
- <MemoizedMarkdown id={id} content={sanitizeText(part.text)} />
78
+ <MemoizedMarkdown id={id} content={displayContent} />
66
79
  </article>
67
80
  </CollapsibleTxtMsg>
68
81
  {props.children}
@@ -108,7 +108,7 @@ function PureMultimodalInput({
108
108
 
109
109
  const placeholder = useChatPreference()?.placeholder || 'Send a message...';
110
110
  const maxCount = useChatPreference()?.acceptAttachmentMaxCount || 5;
111
- const maxSizeMb = useChatPreference()?.acceptAttachmentMaxSizeMb || 100;
111
+ const maxSizeMb = useChatPreference()?.acceptAttachmentMaxSizeMb || 50;
112
112
  const tooltip = `上传附件(仅识别文字),最多${maxCount}个,单个文件最大${maxSizeMb}MB`;
113
113
 
114
114
  const clearAttachmentsAndUploadQueue = useCallback(() => {
@@ -303,12 +303,14 @@ function PureMultimodalInput({
303
303
  className="border border-[#e0e0e0] bg-background p-[10px] shadow-xs transition-all duration-200 focus-within:border-border hover:border-[#0265ff]"
304
304
  onSubmit={(event) => {
305
305
  event.preventDefault();
306
- if (status !== 'ready') {
307
- // toast.error("Please wait for the model to finish its response!");
308
- } else {
306
+ // if (status !== 'ready') {
307
+ // console.error("Please wait for the model to finish its response!");
308
+ // } else {
309
+ // submitForm();
310
+ // }
311
+ if (status === 'ready' || status === 'error') {
309
312
  submitForm();
310
313
  }
311
- // submitForm();
312
314
  }}
313
315
  >
314
316
  {(attachments.length > 0 || uploadQueue.length > 0) && (
@@ -8,6 +8,7 @@ import { IconBtn } from '../bs-ui/icon-btn';
8
8
  import { CopyIcon, RefreshIcon } from '../bs-ui/bs-icons';
9
9
  import { useChatPreference } from '@/hooks/use-chat-preference';
10
10
  import { GenerateAnimation } from '../bs-ui/generate-animation';
11
+ import { useChatStore } from '@/store/context';
11
12
 
12
13
  export const PreviewMessageWrapper = ({
13
14
  role,
@@ -32,11 +33,12 @@ export const PreviewMessageWrapper = ({
32
33
  const isUser = role === 'user';
33
34
 
34
35
  const chatPref = useChatPreference();
36
+ const botInfo = useChatStore((state) => state.botInfo);
35
37
 
36
38
  const avatarComInfo = useDefaultPluginCustomComponent('AvatarAndName');
37
39
  const Avatar: ComponentType<{ variant?: 'default' | 'active' }> | undefined =
38
40
  avatarComInfo?.Component;
39
- const avatarJsx = Avatar ? <Avatar /> : <BotAvatarAndName name={'AI表单搭建'} />;
41
+ const avatarJsx = Avatar ? <Avatar /> : <BotAvatarAndName name={botInfo?.name || 'AI表单搭建'} />;
40
42
 
41
43
  // const [isHovered, setIsHovered] = useState(false);
42
44
 
@@ -15,6 +15,8 @@ import {
15
15
  IsLoadingPart,
16
16
  mergeFileParts,
17
17
  imageUrlToBase64,
18
+ IsFakeMsgPart,
19
+ getMetaErrorMsg,
18
20
  } from '@/lib/utils';
19
21
  import { FakeBotMessage } from './FakeBotMsg';
20
22
  import { WarningMessage } from '../bs-ui/warning-msg';
@@ -24,6 +26,7 @@ import { AttachmentPart } from '../bs-ui/attachment-part';
24
26
  import { useChatStatus } from '@/hooks/use-frame-mode';
25
27
  import { useEvtBus } from '@/hooks/use-evt-bus';
26
28
  import type { FilePart } from '../bs-ui/attachment-part';
29
+ import { useChatStore } from '@/store/context';
27
30
 
28
31
  const PurePreviewMessage = ({
29
32
  message,
@@ -51,6 +54,8 @@ const PurePreviewMessage = ({
51
54
 
52
55
  const chatStatus = useChatStatus();
53
56
 
57
+ const botInfo = useChatStore((state) => state.botInfo);
58
+
54
59
  const hasFileType = message.parts?.some((p: any) => {
55
60
  if (Array.isArray(p)) {
56
61
  return p.some((subP) => subP?.type === 'file');
@@ -153,6 +158,15 @@ const PurePreviewMessage = ({
153
158
  return <WarningMessage key={key} message={errMsg}></WarningMessage>;
154
159
  }
155
160
 
161
+ if (IsFakeMsgPart(part)) {
162
+ const errMsg = getMetaErrorMsg(part);
163
+ return (
164
+ <FakeBotMessage key={key} headless>
165
+ {errMsg}
166
+ </FakeBotMessage>
167
+ );
168
+ }
169
+
156
170
  if (IsLoadingPart(part)) {
157
171
  return (
158
172
  <FakeBotMessage key={key} headless>
@@ -164,6 +178,7 @@ const PurePreviewMessage = ({
164
178
  return (
165
179
  <ErrorBoundary>
166
180
  <MsgPartCom
181
+ title={botInfo?.name}
167
182
  setMessages={setMessages}
168
183
  sendMessage={sendMessage}
169
184
  addToolOutput={addToolOutput}
@@ -50,7 +50,7 @@ function FieldRow({
50
50
  return (
51
51
  <div className="flex items-center w-full">
52
52
  {/* 名称 */}
53
- <div className={cn(cellCls, 'w-20 shrink-0 min-h-[34px] whitespace-nowrap')}>
53
+ <div className={cn(cellCls, 'w-20 shrink-0 min-h-[34px]')}>
54
54
  {isSubFormChild && (
55
55
  <span className="inline-flex items-center justify-center shrink-0 w-5 h-5 opacity-0">
56
56
  <ChevronIcon />
@@ -59,11 +59,11 @@ function FieldRow({
59
59
  <span>{field.fieldName}</span>
60
60
  </div>
61
61
  {/* 类型 */}
62
- <div className={cn(cellCls, 'w-[72px] shrink-0 min-h-[34px] whitespace-nowrap')}>
62
+ <div className={cn(cellCls, 'w-[72px] shrink-0 min-h-[34px]')}>
63
63
  {field.type}
64
64
  </div>
65
65
  {/* 必填 */}
66
- <div className={cn(cellCls, 'w-9 shrink-0 min-h-[34px] whitespace-nowrap')}>
66
+ <div className={cn(cellCls, 'w-9 shrink-0 min-h-[34px]')}>
67
67
  {field.required ? '是' : '否'}
68
68
  </div>
69
69
  {/* 说明 */}
@@ -100,11 +100,11 @@ function SubFormGroup({
100
100
  <span>{parent.fieldName}</span>
101
101
  </div>
102
102
  {/* 类型 */}
103
- <div className={cn(cellCls, 'w-[72px] shrink-0 min-h-[34px] whitespace-nowrap')}>
103
+ <div className={cn(cellCls, 'w-[72px] shrink-0 min-h-[34px] ')}>
104
104
  {parent.type}
105
105
  </div>
106
106
  {/* 必填 */}
107
- <div className={cn(cellCls, 'w-9 shrink-0 min-h-[34px] whitespace-nowrap')}>
107
+ <div className={cn(cellCls, 'w-9 shrink-0 min-h-[34px]')}>
108
108
  {parent.required ? '是' : '否'}
109
109
  </div>
110
110
  {/* 说明 */}
@@ -126,21 +126,21 @@ export function FieldsDesignInfoTable({ fields }: FieldsDesignInfoTableProps) {
126
126
  <div className="flex flex-col items-start w-full bg-white rounded-[10px] overflow-hidden text-black my-[10px] border border-[#E0E0E0]">
127
127
  {/* 表头 */}
128
128
  <div className="flex items-center w-full shrink-0 bg-[#E5E6EB] rounded-t-[10px] border-b border-[#E0E0E0]">
129
- <div className={cn(cellCls, 'w-20 shrink-0 h-[34px] font-bold whitespace-nowrap')}>
129
+ <div className={cn(cellCls, 'w-20 shrink-0 h-[34px] font-bold')}>
130
130
  名称
131
131
  </div>
132
- <div className={cn(cellCls, 'w-[72px] shrink-0 h-[34px] font-bold whitespace-nowrap')}>
132
+ <div className={cn(cellCls, 'w-[72px] shrink-0 h-[34px] font-bold')}>
133
133
  类型
134
134
  </div>
135
135
  <div
136
136
  className={cn(
137
137
  cellCls,
138
- 'w-9 shrink-0 h-[34px] font-bold whitespace-nowrap justify-center'
138
+ 'w-9 shrink-0 h-[34px] font-bold justify-center'
139
139
  )}
140
140
  >
141
141
  必填
142
142
  </div>
143
- <div className={cn(cellCls, 'flex-1 min-w-0 h-[34px] font-bold whitespace-nowrap')}>
143
+ <div className={cn(cellCls, 'flex-1 min-w-0 h-[34px] font-bold')}>
144
144
  说明
145
145
  </div>
146
146
  </div>
package/src/lib/utils.ts CHANGED
@@ -71,6 +71,11 @@ export const IsErrorPart = (part: any): boolean => {
71
71
  return payload?.type === 'agent-error';
72
72
  };
73
73
 
74
+ export const IsFakeMsgPart = (part: any): boolean => {
75
+ const payload = extractTextPartMeta(part);
76
+ return payload?.type === 'agent-fake-msg';
77
+ };
78
+
74
79
  export const IsFilePart = (part: any): boolean => {
75
80
  return part?.type === 'file';
76
81
  };
@@ -117,6 +122,15 @@ export const GetPartErrMsg = (part: any): string => {
117
122
  return payload?.error || '未知错误';
118
123
  };
119
124
 
125
+ export const getMetaErrorMsg = (part: any): string => {
126
+ if (part?.errorText) {
127
+ return part.errorText;
128
+ }
129
+
130
+ const payload = extractTextPartMeta(part);
131
+ return payload?.error || '未知错误';
132
+ };
133
+
120
134
  export const GetFieldJsonInfo = (part: any): IFilledField | null => {
121
135
  const payload = extractTextPartMeta(part);
122
136
  if (payload?.type !== 'mcp-fields-json') {
@@ -384,3 +398,23 @@ export const imageUrlToBase64 = (url: string, mediaType = 'image/png'): Promise<
384
398
  img.onerror = () => resolve(url);
385
399
  img.src = url;
386
400
  });
401
+
402
+ export const isValidJSON = (str: string): boolean => {
403
+ if (!str || typeof str !== 'string') return false;
404
+ try {
405
+ JSON.parse(str);
406
+ return true;
407
+ } catch {
408
+ return false;
409
+ }
410
+ };
411
+
412
+ export const formatJSONIfValid = (str: string): string | null => {
413
+ try {
414
+ const parsed = JSON.parse(str);
415
+ console.log('try parse JSON: ', str);
416
+ return JSON.stringify(parsed, null, 2);
417
+ } catch {
418
+ return null;
419
+ }
420
+ };
@@ -119,7 +119,7 @@ export class ReportQueryPlugin extends ChatAreaPlugin<IReportQueryContext> {
119
119
  return;
120
120
  }
121
121
 
122
- await fetch(`${ensureEndSlash(apiEndpoint)}/form/conversation/clear`, {
122
+ await fetch(`${ensureEndSlash(apiEndpoint)}form/conversation/clear`, {
123
123
  method: 'POST',
124
124
  body: JSON.stringify({ conversationId }),
125
125
  });
package/src/sdk.impl.tsx CHANGED
@@ -3,6 +3,7 @@ import { ChatStore, createStore, setupStoreSubscriptions } from '@/store';
3
3
  import { ChatClient } from '@/components/biz-comp/chat-client';
4
4
  import './style.css';
5
5
  import {
6
+ ChatMessage,
6
7
  DeepReadonly,
7
8
  IChatSDK,
8
9
  IChatSDKOption,
@@ -10,18 +11,25 @@ import {
10
11
  type PluginRegistryEntry,
11
12
  } from '@baishuyun/types';
12
13
  import { EvtBus } from './lib/event-emitter';
14
+ import type { UseChatHelpers } from '@ai-sdk/react';
15
+ import { ChatRequestOptions, JSONValue } from 'ai';
13
16
 
14
17
  export class ChatSDK implements IChatSDK {
15
18
  static instances: ChatSDK[] = [];
16
19
 
17
20
  private root: ReturnType<typeof createRoot> | undefined;
18
21
  private readonly Store: ChatStore;
22
+ private chatComponentReadyResolve!: () => void;
23
+ private chatComponentReadyPromise: Promise<void>;
19
24
 
20
25
  public options: IChatSDKOption;
21
26
 
22
27
  public eventBus = new EvtBus() as IEvtBus;
23
28
 
24
29
  constructor(options: IChatSDKOption) {
30
+ this.chatComponentReadyPromise = new Promise((resolve) => {
31
+ this.chatComponentReadyResolve = resolve;
32
+ });
25
33
  this.options = options;
26
34
 
27
35
  const renderEl = document.createElement('div');
@@ -92,10 +100,56 @@ export class ChatSDK implements IChatSDK {
92
100
  return undefined;
93
101
  }
94
102
 
103
+ markChatComponentReady() {
104
+ this.chatComponentReadyResolve();
105
+ }
106
+
107
+ whenChatComponentReady(): Promise<void> {
108
+ return this.chatComponentReadyPromise;
109
+ }
110
+
111
+ _sendMessage?: UseChatHelpers<ChatMessage>['sendMessage'];
112
+ _appendFakeBotMessage?: (text: string) => void;
113
+
114
+ public appendBotMessage = async (text: string) => {
115
+ await this.whenChatComponentReady();
116
+ this._appendFakeBotMessage?.(text);
117
+ }
118
+
119
+ public sendMessage = async (text: string, customVariable: JSONValue, options: ChatRequestOptions) => {
120
+ await this.whenChatComponentReady();
121
+
122
+ // if is streaming, return;
123
+ this._sendMessage?.(
124
+ { text }, // First arg: message data
125
+ { // Second arg: options
126
+ ...options,
127
+ body: {
128
+ ...(options?.body || {}),
129
+ userVar: customVariable,
130
+ },
131
+ }
132
+ );
133
+ }
134
+
95
135
  public clearChatHistory() {
96
136
  this.Store.getState().clearMessages();
97
137
  }
98
138
 
139
+ public getLastBotMsg(textOnly?: boolean): ChatMessage | string | undefined {
140
+ const lastBotMessage = this.Store.getState().lastBotMessage;
141
+ if (!lastBotMessage) return undefined;
142
+
143
+ if (textOnly) {
144
+ return lastBotMessage.parts
145
+ .filter((part) => part.type === 'text')
146
+ .map((part) => (part as any).text)
147
+ .join('');
148
+ }
149
+
150
+ return lastBotMessage;
151
+ }
152
+
99
153
  public getFullStyle() {
100
154
  return this.options.style;
101
155
  }
@@ -121,13 +175,6 @@ export class ChatSDK implements IChatSDK {
121
175
  };
122
176
  }
123
177
 
124
- public setUserId(userId: string) {
125
- this.options.chatApiHeaders = {
126
- ...this.options.chatApiHeaders,
127
- 'X-User-Id': userId,
128
- };
129
- }
130
-
131
178
  public getChatStatus() {
132
179
  return this.Store.getState().chatStatus;
133
180
  }
@@ -6,6 +6,7 @@ import {
6
6
  ChatStatus,
7
7
  IChatSDKOption,
8
8
  IEvtBus,
9
+ ChatMessage,
9
10
  } from '@baishuyun/types';
10
11
  import { ChatSDK } from '..';
11
12
  import { create } from 'zustand';
@@ -24,6 +25,8 @@ export const createStore = (sdkInst: ChatSDK) => {
24
25
 
25
26
  msgClearTimestamp: Date.now(),
26
27
  globalFakeLoadingMessage: '',
28
+ lastBotMessage: undefined,
29
+ botInfo: sdkInst.options?.botInfo,
27
30
  };
28
31
 
29
32
  return create<ChatContextType>()(
@@ -104,6 +107,11 @@ export const createStore = (sdkInst: ChatSDK) => {
104
107
  newButtons.set(id, { ...existing, visible });
105
108
  return { chatEntryButtons: newButtons };
106
109
  }),
110
+
111
+ setLastBotMessage: (message?: ChatMessage | undefined) =>
112
+ set(() => ({
113
+ lastBotMessage: message,
114
+ })),
107
115
  }))
108
116
  );
109
117
  };