@opentiny/tiny-robot 0.4.2-alpha.6 → 0.4.2-alpha.8

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 (263) hide show
  1. package/dist/action-group/index.js +4 -4
  2. package/dist/anchor/index.js +44 -44
  3. package/dist/bubble/index.js +10 -9
  4. package/dist/drag-overlay/index.js +1 -1
  5. package/dist/dropdown-menu/index.js +1 -1
  6. package/dist/index.d.ts +5239 -49
  7. package/dist/index.js +129 -118
  8. package/dist/index2.js +2 -2
  9. package/dist/index4.js +384 -321
  10. package/dist/index5.js +247 -240
  11. package/dist/index6.js +597 -547
  12. package/dist/index7.js +28 -28
  13. package/dist/index8.js +8 -8
  14. package/dist/layout/index.js +1243 -0
  15. package/dist/sender/index.js +2 -2
  16. package/dist/sender-actions/index.js +1 -1
  17. package/dist/style.css +1 -1
  18. package/dist/suggestion-pills/index.js +1 -1
  19. package/dist/suggestion-popover/index.js +1 -1
  20. package/dist/theme-provider/index.js +41 -32
  21. package/dist/useSlotRefs.js +1 -1
  22. package/dist/utils.js +1 -1
  23. package/package.json +3 -22
  24. package/dist/action-group/ActionGroup.vue.d.ts +0 -26
  25. package/dist/action-group/ActionGroupItem.vue.d.ts +0 -18
  26. package/dist/action-group/index.d.ts +0 -12
  27. package/dist/action-group/index.type.d.ts +0 -17
  28. package/dist/anchor/components/AnchorItem.vue.d.ts +0 -24
  29. package/dist/anchor/components/AnchorList.vue.d.ts +0 -20
  30. package/dist/anchor/components/AnchorOverlay.vue.d.ts +0 -33
  31. package/dist/anchor/components/AnchorSearch.vue.d.ts +0 -7
  32. package/dist/anchor/composables/index.d.ts +0 -5
  33. package/dist/anchor/composables/useActiveSync.d.ts +0 -10
  34. package/dist/anchor/composables/useFloatingOffset.d.ts +0 -6
  35. package/dist/anchor/composables/useNavController.d.ts +0 -12
  36. package/dist/anchor/composables/useOverlayInteractions.d.ts +0 -6
  37. package/dist/anchor/composables/useTargetFeedback.d.ts +0 -5
  38. package/dist/anchor/defaults.d.ts +0 -16
  39. package/dist/anchor/index.d.ts +0 -7
  40. package/dist/anchor/index.type.d.ts +0 -60
  41. package/dist/anchor/index.vue.d.ts +0 -159
  42. package/dist/anchor/internal.type.d.ts +0 -103
  43. package/dist/anchor/utils/scroll.d.ts +0 -7
  44. package/dist/anchor/utils/target.d.ts +0 -6
  45. package/dist/attachments/components/FileCard.vue.d.ts +0 -18
  46. package/dist/attachments/components/ImagePreview.vue.d.ts +0 -17
  47. package/dist/attachments/components/index.d.ts +0 -2
  48. package/dist/attachments/composables/index.d.ts +0 -5
  49. package/dist/attachments/composables/useFileCard.d.ts +0 -15
  50. package/dist/attachments/composables/useFileType.d.ts +0 -20
  51. package/dist/attachments/composables/useImagePreview.d.ts +0 -18
  52. package/dist/attachments/composables/useListType.d.ts +0 -11
  53. package/dist/attachments/index.d.ts +0 -7
  54. package/dist/attachments/index.type.d.ts +0 -70
  55. package/dist/attachments/index.vue.d.ts +0 -27
  56. package/dist/attachments/utils.d.ts +0 -3
  57. package/dist/base-popper/components/Popper.vue.d.ts +0 -28
  58. package/dist/base-popper/index.d.ts +0 -2
  59. package/dist/base-popper/index.vue.d.ts +0 -41
  60. package/dist/bubble/Bubble.vue.d.ts +0 -39
  61. package/dist/bubble/BubbleBoxWrapper.vue.d.ts +0 -22
  62. package/dist/bubble/BubbleContentWrapper.vue.d.ts +0 -16
  63. package/dist/bubble/BubbleItem.vue.d.ts +0 -36
  64. package/dist/bubble/BubbleList.vue.d.ts +0 -41
  65. package/dist/bubble/BubbleProvider.vue.d.ts +0 -18
  66. package/dist/bubble/composables/index.d.ts +0 -10
  67. package/dist/bubble/composables/useBubbleBoxRenderer.d.ts +0 -18
  68. package/dist/bubble/composables/useBubbleContentRenderer.d.ts +0 -18
  69. package/dist/bubble/composables/useBubbleStateChange.d.ts +0 -2
  70. package/dist/bubble/composables/useBubbleStore.d.ts +0 -16
  71. package/dist/bubble/composables/useContentResolver.d.ts +0 -5
  72. package/dist/bubble/composables/useCopyCleanup.d.ts +0 -6
  73. package/dist/bubble/composables/useMessageContent.d.ts +0 -5
  74. package/dist/bubble/composables/useMessageGroup.d.ts +0 -4
  75. package/dist/bubble/composables/useOmitMessageFields.d.ts +0 -12
  76. package/dist/bubble/composables/useToolCall.d.ts +0 -25
  77. package/dist/bubble/constants.d.ts +0 -42
  78. package/dist/bubble/index.d.ts +0 -19
  79. package/dist/bubble/index.type.d.ts +0 -171
  80. package/dist/bubble/renderers/Box.vue.d.ts +0 -18
  81. package/dist/bubble/renderers/Image.vue.d.ts +0 -4
  82. package/dist/bubble/renderers/Loading.vue.d.ts +0 -4
  83. package/dist/bubble/renderers/Markdown.vue.d.ts +0 -4
  84. package/dist/bubble/renderers/Reasoning.vue.d.ts +0 -9
  85. package/dist/bubble/renderers/Text.vue.d.ts +0 -4
  86. package/dist/bubble/renderers/Tool.vue.d.ts +0 -14
  87. package/dist/bubble/renderers/ToolRole.vue.d.ts +0 -4
  88. package/dist/bubble/renderers/Tools.vue.d.ts +0 -4
  89. package/dist/bubble/renderers/allRenderers.d.ts +0 -93
  90. package/dist/bubble/renderers/defaultRenderers.d.ts +0 -27
  91. package/dist/bubble/utils.d.ts +0 -7
  92. package/dist/chat/components/ChatConversation.vue.d.ts +0 -267
  93. package/dist/chat/components/ChatLauncherButton.vue.d.ts +0 -12
  94. package/dist/chat/components/ChatMcpTrigger.vue.d.ts +0 -30
  95. package/dist/chat/components/ChatThemeToggleButton.vue.d.ts +0 -6
  96. package/dist/chat/components/ChatWelcome.vue.d.ts +0 -14
  97. package/dist/chat/components/icons/IconModelAliyunBailian.vue.d.ts +0 -7
  98. package/dist/chat/components/icons/IconModelDeepseek.vue.d.ts +0 -7
  99. package/dist/chat/components/icons/index.d.ts +0 -5
  100. package/dist/chat/composables/useChatConversation.d.ts +0 -37
  101. package/dist/chat/composables/useChatMcp.d.ts +0 -29
  102. package/dist/chat/composables/useChatModel.d.ts +0 -27
  103. package/dist/chat/index.d.ts +0 -9
  104. package/dist/chat/index.js +0 -13902
  105. package/dist/chat/index.type.d.ts +0 -92
  106. package/dist/chat/index.vue.d.ts +0 -51
  107. package/dist/chat/locale.d.ts +0 -12
  108. package/dist/chat/mcpServers.d.ts +0 -3
  109. package/dist/container/index.d.ts +0 -7
  110. package/dist/container/index.type.d.ts +0 -20
  111. package/dist/container/index.vue.d.ts +0 -32
  112. package/dist/conversations/index.d.ts +0 -7
  113. package/dist/conversations/index.vue.d.ts +0 -2
  114. package/dist/drag-overlay/constants.d.ts +0 -17
  115. package/dist/drag-overlay/directives/vDropzone.d.ts +0 -14
  116. package/dist/drag-overlay/index.d.ts +0 -7
  117. package/dist/drag-overlay/index.type.d.ts +0 -105
  118. package/dist/drag-overlay/index.vue.d.ts +0 -20
  119. package/dist/dropdown-menu/composables/usePopperHover.d.ts +0 -6
  120. package/dist/dropdown-menu/index.d.ts +0 -7
  121. package/dist/dropdown-menu/index.type.d.ts +0 -42
  122. package/dist/dropdown-menu/index.vue.d.ts +0 -217
  123. package/dist/feedback/components/SourceList.vue.d.ts +0 -11
  124. package/dist/feedback/components/index.d.ts +0 -1
  125. package/dist/feedback/index.d.ts +0 -7
  126. package/dist/feedback/index.type.d.ts +0 -25
  127. package/dist/feedback/index.vue.d.ts +0 -13
  128. package/dist/flow-layout-buttons/index.d.ts +0 -7
  129. package/dist/flow-layout-buttons/index.type.d.ts +0 -35
  130. package/dist/flow-layout-buttons/index.vue.d.ts +0 -22
  131. package/dist/history/components/Empty.vue.d.ts +0 -7
  132. package/dist/history/components/MenuList.vue.d.ts +0 -24
  133. package/dist/history/composables/useRenameEditor.d.ts +0 -22
  134. package/dist/history/constants.d.ts +0 -1
  135. package/dist/history/index.d.ts +0 -7
  136. package/dist/history/index.type.d.ts +0 -33
  137. package/dist/history/index.vue.d.ts +0 -18
  138. package/dist/icon-button/index.d.ts +0 -7
  139. package/dist/icon-button/index.type.d.ts +0 -7
  140. package/dist/icon-button/index.vue.d.ts +0 -6
  141. package/dist/mcp-add-form/components/CodeEditor.vue.d.ts +0 -9
  142. package/dist/mcp-add-form/components/FormEditor.vue.d.ts +0 -10
  143. package/dist/mcp-add-form/components/index.d.ts +0 -2
  144. package/dist/mcp-add-form/index.d.ts +0 -7
  145. package/dist/mcp-add-form/index.type.d.ts +0 -19
  146. package/dist/mcp-add-form/index.vue.d.ts +0 -13
  147. package/dist/mcp-server-picker/components/NoData.vue.d.ts +0 -7
  148. package/dist/mcp-server-picker/components/PluginCard.vue.d.ts +0 -40
  149. package/dist/mcp-server-picker/components/PluginModal.vue.d.ts +0 -15
  150. package/dist/mcp-server-picker/components/index.d.ts +0 -3
  151. package/dist/mcp-server-picker/index.d.ts +0 -7
  152. package/dist/mcp-server-picker/index.type.d.ts +0 -99
  153. package/dist/mcp-server-picker/index.vue.d.ts +0 -71
  154. package/dist/prompts/index.d.ts +0 -12
  155. package/dist/prompts/index.type.d.ts +0 -59
  156. package/dist/prompts/prompt.vue.d.ts +0 -5
  157. package/dist/prompts/prompts.vue.d.ts +0 -20
  158. package/dist/sender/components/editor-content/index.vue.d.ts +0 -4
  159. package/dist/sender/components/footer/index.vue.d.ts +0 -38
  160. package/dist/sender/components/layouts/MultiLineLayout.vue.d.ts +0 -43
  161. package/dist/sender/components/layouts/SingleLineLayout.vue.d.ts +0 -32
  162. package/dist/sender/composables/index.d.ts +0 -7
  163. package/dist/sender/composables/useAutoSize.d.ts +0 -5
  164. package/dist/sender/composables/useEditor.d.ts +0 -13
  165. package/dist/sender/composables/useKeyboardShortcuts.d.ts +0 -7
  166. package/dist/sender/composables/useModeSwitch.d.ts +0 -4
  167. package/dist/sender/composables/useSenderCore.d.ts +0 -31
  168. package/dist/sender/composables/useSlotScope.d.ts +0 -10
  169. package/dist/sender/context/index.d.ts +0 -6
  170. package/dist/sender/context/types.d.ts +0 -7
  171. package/dist/sender/extensions/constants.d.ts +0 -94
  172. package/dist/sender/extensions/index.d.ts +0 -12
  173. package/dist/sender/extensions/mention/commands.d.ts +0 -20
  174. package/dist/sender/extensions/mention/components/mention-list.vue.d.ts +0 -18
  175. package/dist/sender/extensions/mention/components/mention-view.vue.d.ts +0 -19
  176. package/dist/sender/extensions/mention/extension.d.ts +0 -6
  177. package/dist/sender/extensions/mention/index.d.ts +0 -22
  178. package/dist/sender/extensions/mention/plugin.d.ts +0 -16
  179. package/dist/sender/extensions/mention/types.d.ts +0 -126
  180. package/dist/sender/extensions/mention/utils.d.ts +0 -34
  181. package/dist/sender/extensions/suggestion/extension.d.ts +0 -8
  182. package/dist/sender/extensions/suggestion/index.d.ts +0 -20
  183. package/dist/sender/extensions/suggestion/plugin.d.ts +0 -21
  184. package/dist/sender/extensions/suggestion/suggestion-list.vue.d.ts +0 -46
  185. package/dist/sender/extensions/suggestion/types.d.ts +0 -254
  186. package/dist/sender/extensions/suggestion/utils/filter.d.ts +0 -29
  187. package/dist/sender/extensions/suggestion/utils/highlight.d.ts +0 -73
  188. package/dist/sender/extensions/template/block/extension.d.ts +0 -6
  189. package/dist/sender/extensions/template/block/plugins.d.ts +0 -13
  190. package/dist/sender/extensions/template/block/template-block-view.vue.d.ts +0 -14
  191. package/dist/sender/extensions/template/commands.d.ts +0 -31
  192. package/dist/sender/extensions/template/extension.d.ts +0 -6
  193. package/dist/sender/extensions/template/index.d.ts +0 -21
  194. package/dist/sender/extensions/template/select/dropdown-manager.d.ts +0 -23
  195. package/dist/sender/extensions/template/select/extension.d.ts +0 -5
  196. package/dist/sender/extensions/template/select/plugins.d.ts +0 -34
  197. package/dist/sender/extensions/template/select/template-select-view.vue.d.ts +0 -20
  198. package/dist/sender/extensions/template/types.d.ts +0 -100
  199. package/dist/sender/extensions/template/utils.d.ts +0 -20
  200. package/dist/sender/extensions/utils/id-generator.d.ts +0 -16
  201. package/dist/sender/extensions/utils/index.d.ts +0 -7
  202. package/dist/sender/extensions/utils/keyboard.d.ts +0 -49
  203. package/dist/sender/extensions/utils/position.d.ts +0 -25
  204. package/dist/sender/index.d.ts +0 -136
  205. package/dist/sender/index.type.d.ts +0 -302
  206. package/dist/sender/index.vue.d.ts +0 -90
  207. package/dist/sender/types/base.d.ts +0 -239
  208. package/dist/sender/types/components.d.ts +0 -68
  209. package/dist/sender/types/composables.d.ts +0 -122
  210. package/dist/sender/types/context.d.ts +0 -132
  211. package/dist/sender/types/slots.d.ts +0 -67
  212. package/dist/sender/utils/countGraphemes.d.ts +0 -1
  213. package/dist/sender-actions/action-button/index.vue.d.ts +0 -23
  214. package/dist/sender-actions/clear-button/index.vue.d.ts +0 -2
  215. package/dist/sender-actions/clear-button/useClearButtonState.d.ts +0 -6
  216. package/dist/sender-actions/default-actions/index.vue.d.ts +0 -17
  217. package/dist/sender-actions/index.d.ts +0 -21
  218. package/dist/sender-actions/index.type.d.ts +0 -7
  219. package/dist/sender-actions/submit-button/index.vue.d.ts +0 -2
  220. package/dist/sender-actions/types/common.d.ts +0 -40
  221. package/dist/sender-actions/types/index.d.ts +0 -5
  222. package/dist/sender-actions/types/tooltip.d.ts +0 -7
  223. package/dist/sender-actions/upload-button/index.type.d.ts +0 -57
  224. package/dist/sender-actions/upload-button/index.vue.d.ts +0 -16
  225. package/dist/sender-actions/utils/tooltip.d.ts +0 -8
  226. package/dist/sender-actions/voice-button/index.type.d.ts +0 -78
  227. package/dist/sender-actions/voice-button/index.vue.d.ts +0 -43
  228. package/dist/sender-actions/voice-button/speech.types.d.ts +0 -40
  229. package/dist/sender-actions/voice-button/useSpeechHandler.d.ts +0 -10
  230. package/dist/sender-actions/voice-button/webSpeechHandler.d.ts +0 -40
  231. package/dist/sender-actions/word-counter/index.vue.d.ts +0 -2
  232. package/dist/sender-compat/index.d.ts +0 -7
  233. package/dist/sender-compat/index.type.d.ts +0 -91
  234. package/dist/sender-compat/index.vue.d.ts +0 -532
  235. package/dist/shared/composables/createTeleport.d.ts +0 -2
  236. package/dist/shared/composables/index.d.ts +0 -5
  237. package/dist/shared/composables/useAutoScroll.d.ts +0 -25
  238. package/dist/shared/composables/useSlotRefs.d.ts +0 -12
  239. package/dist/shared/composables/useTeleportTarget.d.ts +0 -11
  240. package/dist/shared/composables/useTouchDevice.d.ts +0 -3
  241. package/dist/shared/utils.d.ts +0 -7
  242. package/dist/suggestion-pills/components/PillButton.vue.d.ts +0 -16
  243. package/dist/suggestion-pills/components/index.d.ts +0 -1
  244. package/dist/suggestion-pills/index.d.ts +0 -13
  245. package/dist/suggestion-pills/index.type.d.ts +0 -45
  246. package/dist/suggestion-pills/index.vue.d.ts +0 -44
  247. package/dist/suggestion-popover/components/Backdrop.vue.d.ts +0 -5
  248. package/dist/suggestion-popover/components/Header.vue.d.ts +0 -4
  249. package/dist/suggestion-popover/components/Loading.vue.d.ts +0 -17
  250. package/dist/suggestion-popover/components/NoData.vue.d.ts +0 -17
  251. package/dist/suggestion-popover/components/Tooltip.vue.d.ts +0 -19
  252. package/dist/suggestion-popover/index.d.ts +0 -7
  253. package/dist/suggestion-popover/index.type.d.ts +0 -80
  254. package/dist/suggestion-popover/index.vue.d.ts +0 -262
  255. package/dist/theme-provider/constants.d.ts +0 -6
  256. package/dist/theme-provider/index.d.ts +0 -9
  257. package/dist/theme-provider/index.type.d.ts +0 -18
  258. package/dist/theme-provider/index.vue.d.ts +0 -32
  259. package/dist/theme-provider/useTheme.d.ts +0 -11
  260. package/dist/useTheme.js +0 -22
  261. package/dist/welcome/index.d.ts +0 -7
  262. package/dist/welcome/index.type.d.ts +0 -10
  263. package/dist/welcome/index.vue.d.ts +0 -18
package/dist/index6.js CHANGED
@@ -1,76 +1,129 @@
1
- import { defineComponent as S, openBlock as g, createElementBlock as C, renderSlot as E, ref as L, computed as y, watch as U, unref as B, normalizeClass as K, createVNode as W, watchEffect as q, nextTick as ee, Fragment as F, createElementVNode as x, mergeProps as $, toDisplayString as z, withDirectives as Z, vShow as Q, createBlock as T, resolveDynamicComponent as Y, normalizeProps as P, guardReactiveProps as D, createCommentVNode as se, useCssModule as je, renderList as j, markRaw as w, inject as I, provide as A, toValue as k, reactive as We, readonly as ze, withCtx as M, onMounted as ve, onUnmounted as Ve } from "vue";
1
+ import { ref as L, watch as H, toValue as k, onMounted as xe, onUnmounted as We, nextTick as ne, defineComponent as I, openBlock as v, createElementBlock as E, renderSlot as C, computed as x, unref as R, normalizeClass as G, createVNode as V, watchEffect as Z, Fragment as P, createElementVNode as B, mergeProps as O, toDisplayString as z, withDirectives as ee, vShow as te, createBlock as A, resolveDynamicComponent as J, normalizeProps as D, guardReactiveProps as U, createCommentVNode as ae, useCssModule as Ve, renderList as W, markRaw as F, inject as T, provide as M, reactive as ze, readonly as Xe, withCtx as $ } from "vue";
2
2
  import { _ as N } from "./_plugin-vue_export-helper.js";
3
- import { IconLoading as he, IconAtom as Xe, IconArrowDown as ye, IconPlugin as be, IconError as qe, IconCancelled as Ze } from "@opentiny/tiny-robot-svgs";
4
- import { j as Qe, m as et, d as tt, u as nt } from "./index4.js";
5
- const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matches"), Be = Symbol("bubble-box-fallback-renderer"), Ce = Symbol("bubble-box-attributes"), Ee = Symbol(
3
+ import { IconLoading as Be, IconAtom as qe, IconArrowDown as Re, IconPlugin as me, IconError as Ze, IconCancelled as Qe } from "@opentiny/tiny-robot-svgs";
4
+ import { l as et, w as tt, g as nt, a as st } from "./index4.js";
5
+ function _e(t, e) {
6
+ const n = H(t, (s, a) => {
7
+ a === !0 && s === !1 && (e(), n());
8
+ });
9
+ return n;
10
+ }
11
+ function ot(t, e, n) {
12
+ const { scrollOnMount: s = !0, bottomThreshold: a = 20, scrollThrottle: i = 0 } = n ?? {}, o = L(!0);
13
+ let l = !1;
14
+ const u = /* @__PURE__ */ new Set(), f = () => st(t), { y: m, isScrolling: h, arrivedState: y } = et(f, { throttle: i }), g = (r) => r.scrollHeight - r.scrollTop - r.clientHeight <= a, c = async (r = "auto") => {
15
+ const d = k(f);
16
+ if (d && (await ne(), d.scrollTo({ top: d.scrollHeight, behavior: r }), r === "smooth" && !g(d))) {
17
+ const _ = _e(h, () => {
18
+ d.scrollTo({ top: d.scrollHeight, behavior: "auto" }), u.delete(_);
19
+ });
20
+ u.add(_);
21
+ }
22
+ }, p = () => {
23
+ l || !o.value || (l = !0, requestAnimationFrame(async () => {
24
+ l = !1, await c("auto");
25
+ }));
26
+ };
27
+ return H(
28
+ m,
29
+ () => {
30
+ const r = k(f);
31
+ r && (o.value = g(r));
32
+ },
33
+ { flush: "post" }
34
+ ), tt(
35
+ e,
36
+ () => {
37
+ p();
38
+ },
39
+ { flush: "post", throttle: 100 }
40
+ ), xe(() => {
41
+ s && c("smooth");
42
+ }), We(() => {
43
+ u.forEach((r) => {
44
+ r();
45
+ }), u.clear();
46
+ }), nt("keydown", (r) => {
47
+ if (r.key === "End" && !o.value) {
48
+ const d = _e(h, () => {
49
+ c("auto"), u.delete(d);
50
+ });
51
+ u.add(d);
52
+ }
53
+ }), {
54
+ scrollToBottom: c,
55
+ arrivedState: y
56
+ };
57
+ }
58
+ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matches"), ke = Symbol("bubble-box-fallback-renderer"), Ie = Symbol("bubble-box-attributes"), Se = Symbol(
6
59
  "bubble-box-prop-fallback-renderer"
7
- ), ke = Symbol("bubble-content-renderer-matches"), Se = Symbol(
60
+ ), Te = Symbol("bubble-content-renderer-matches"), Ae = Symbol(
8
61
  "bubble-content-fallback-renderer"
9
- ), Ie = Symbol("bubble-content-attributes"), Te = Symbol(
62
+ ), Me = Symbol("bubble-content-attributes"), Le = Symbol(
10
63
  "bubble-content-prop-fallback-renderer"
11
- ), oe = Symbol("bubble-store"), Ae = Symbol("bubble-state-change-fn"), Le = Symbol("bubble-list-context"), H = {
64
+ ), re = Symbol("bubble-store"), $e = Symbol("bubble-event-fn"), Oe = Symbol("bubble-list-context"), K = {
12
65
  LOADING: -1,
13
66
  NORMAL: 0,
14
67
  CONTENT: 10,
15
68
  ROLE: 20
16
- }, ot = {
69
+ }, rt = {
17
70
  class: "tr-bubble__box",
18
71
  "data-box-type": "box"
19
- }, st = /* @__PURE__ */ S({
72
+ }, at = /* @__PURE__ */ I({
20
73
  __name: "Box",
21
74
  props: {
22
75
  placement: {},
23
76
  shape: {}
24
77
  },
25
78
  setup(t) {
26
- return (e, n) => (g(), C("div", ot, [
27
- E(e.$slots, "default", {}, void 0, !0)
79
+ return (e, n) => (v(), E("div", rt, [
80
+ C(e.$slots, "default", {}, void 0, !0)
28
81
  ]));
29
82
  }
30
- }), re = /* @__PURE__ */ N(st, [["__scopeId", "data-v-98101726"]]), rt = ["src", "alt"], at = /* @__PURE__ */ S({
83
+ }), le = /* @__PURE__ */ N(at, [["__scopeId", "data-v-98101726"]]), lt = ["src", "alt"], ct = /* @__PURE__ */ I({
31
84
  __name: "Image",
32
85
  props: {
33
86
  message: {},
34
87
  contentIndex: {}
35
88
  },
36
89
  setup(t) {
37
- const e = t, n = L(!1), o = L(!1), { content: r } = ie(e), i = y(() => r.value ? typeof r.value.image_url == "string" ? r.value.image_url : r.value.image_url.url : null);
38
- U(i, () => {
39
- n.value = !1, o.value = !1;
90
+ const e = t, n = L(!1), s = L(!1), { content: a } = fe(e), i = x(() => a.value ? typeof a.value.image_url == "string" ? a.value.image_url : a.value.image_url.url : null);
91
+ H(i, () => {
92
+ n.value = !1, s.value = !1;
40
93
  });
41
- const s = () => {
42
- n.value = !0, o.value = !1;
43
- }, a = () => {
44
- o.value = !0, n.value = !0;
94
+ const o = () => {
95
+ n.value = !0, s.value = !1;
96
+ }, l = () => {
97
+ s.value = !0, n.value = !0;
45
98
  };
46
- return (u, b) => {
99
+ return (u, f) => {
47
100
  var m;
48
- return g(), C("img", {
49
- class: K(["tr-bubble__image", { loading: !n.value }]),
101
+ return v(), E("img", {
102
+ class: G(["tr-bubble__image", { loading: !n.value }]),
50
103
  src: i.value,
51
- alt: (m = B(r)) == null ? void 0 : m.text,
104
+ alt: (m = R(a)) == null ? void 0 : m.text,
52
105
  loading: "lazy",
53
- onLoad: s,
54
- onError: a,
106
+ onLoad: o,
107
+ onError: l,
55
108
  "data-type": "image"
56
- }, null, 42, rt);
109
+ }, null, 42, lt);
57
110
  };
58
111
  }
59
- }), Me = /* @__PURE__ */ N(at, [["__scopeId", "data-v-e59794cb"]]), lt = {
112
+ }), Ne = /* @__PURE__ */ N(ct, [["__scopeId", "data-v-e59794cb"]]), ut = {
60
113
  class: "tr-bubble__loading",
61
114
  "data-type": "loading"
62
- }, ct = /* @__PURE__ */ S({
115
+ }, it = /* @__PURE__ */ I({
63
116
  __name: "Loading",
64
117
  props: {
65
118
  message: {},
66
119
  contentIndex: {}
67
120
  },
68
121
  setup(t) {
69
- return (e, n) => (g(), C("div", lt, [
70
- W(B(he))
122
+ return (e, n) => (v(), E("div", ut, [
123
+ V(R(Be))
71
124
  ]));
72
125
  }
73
- }), $e = /* @__PURE__ */ N(ct, [["__scopeId", "data-v-bc1b5ff4"]]), ut = { class: "title" }, it = { class: "detail" }, dt = /* @__PURE__ */ S({
126
+ }), we = /* @__PURE__ */ N(it, [["__scopeId", "data-v-bc1b5ff4"]]), dt = { class: "title" }, bt = { class: "detail" }, ft = /* @__PURE__ */ I({
74
127
  inheritAttrs: !1,
75
128
  __name: "Reasoning",
76
129
  props: {
@@ -78,95 +131,101 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
78
131
  contentIndex: {}
79
132
  },
80
133
  setup(t) {
81
- const e = t, { restMessage: n, restProps: o } = Ye(e, ["reasoning_content"]), r = le(n, e.contentIndex), i = L(!0);
82
- q(() => {
83
- var b;
84
- i.value = ((b = e.message.state) == null ? void 0 : b.open) ?? !0;
134
+ const e = t, { restMessage: n, restProps: s } = je(e, ["reasoning_content"]), a = ue(n, e.contentIndex), i = L(!0);
135
+ Z(() => {
136
+ var f;
137
+ i.value = ((f = e.message.state) == null ? void 0 : f.open) ?? !0;
85
138
  });
86
- const s = Ke(), a = () => {
87
- i.value = !i.value, s("open", i.value);
139
+ const o = ie(), l = () => {
140
+ i.value = !i.value, o({
141
+ name: "state:update",
142
+ payload: {
143
+ key: "open",
144
+ value: i.value
145
+ }
146
+ });
88
147
  }, u = L(null);
89
- return U(
148
+ return H(
90
149
  () => e.message.reasoning_content,
91
150
  () => {
92
- ee(() => {
151
+ ne(() => {
93
152
  u.value && u.value.scrollTo({
94
153
  top: u.value.scrollHeight,
95
154
  behavior: "smooth"
96
155
  });
97
156
  });
98
157
  }
99
- ), (b, m) => {
100
- var p, f;
101
- return g(), C(F, null, [
102
- x("div", $({
158
+ ), (f, m) => {
159
+ var h, y;
160
+ return v(), E(P, null, [
161
+ B("div", O({
103
162
  class: "tr-bubble__reasoning",
104
163
  "data-type": "reasoning"
105
- }, b.$attrs), [
106
- x("div", {
164
+ }, f.$attrs), [
165
+ B("div", {
107
166
  class: "header",
108
- onClick: a
167
+ onClick: l
109
168
  }, [
110
- x("div", {
111
- class: K(["icon-and-text", { thinking: (p = e.message.state) == null ? void 0 : p.thinking }])
169
+ B("div", {
170
+ class: G(["icon-and-text", { thinking: (h = e.message.state) == null ? void 0 : h.thinking }])
112
171
  }, [
113
- W(B(Xe)),
114
- x("span", ut, z((f = e.message.state) != null && f.thinking ? "正在思考" : "已思考"), 1)
172
+ V(R(qe)),
173
+ B("span", dt, z((y = e.message.state) != null && y.thinking ? "正在思考" : "已思考"), 1)
115
174
  ], 2),
116
- W(B(ye), {
117
- class: K(["expand-icon", { "-rotate-90": !i.value }])
175
+ V(R(Re), {
176
+ class: G(["expand-icon", { "-rotate-90": !i.value }])
118
177
  }, null, 8, ["class"])
119
178
  ]),
120
- Z(x("div", it, [
121
- m[0] || (m[0] = x("div", { class: "side-border" }, [
122
- x("div", { class: "dot-wrapper" }, [
123
- x("div", { class: "dot" })
179
+ ee(B("div", bt, [
180
+ m[0] || (m[0] = B("div", { class: "side-border" }, [
181
+ B("div", { class: "dot-wrapper" }, [
182
+ B("div", { class: "dot" })
124
183
  ]),
125
- x("div", { class: "border-line" })
184
+ B("div", { class: "border-line" })
126
185
  ], -1)),
127
- x("p", {
186
+ B("p", {
128
187
  class: "detail-content",
129
188
  ref_key: "detailRef",
130
189
  ref: u
131
190
  }, z(e.message.reasoning_content), 513)
132
191
  ], 512), [
133
- [Q, i.value]
192
+ [te, i.value]
134
193
  ])
135
194
  ], 16),
136
- (g(), T(Y(B(r).renderer), P(D({ ...B(r).attributes, ...B(o) })), null, 16))
195
+ (v(), A(J(R(a).renderer), D(U({ ...R(a).attributes, ...R(s) })), null, 16))
137
196
  ], 64);
138
197
  };
139
198
  }
140
- }), Oe = /* @__PURE__ */ N(dt, [["__scopeId", "data-v-d48eefd5"]]), bt = {
199
+ }), Fe = /* @__PURE__ */ N(ft, [["__scopeId", "data-v-4ddaccea"]]), pt = {
141
200
  key: 0,
142
201
  class: "tr-bubble__text",
143
202
  "data-type": "text"
144
- }, ft = /* @__PURE__ */ S({
203
+ }, mt = /* @__PURE__ */ I({
145
204
  __name: "Text",
146
205
  props: {
147
206
  message: {},
148
207
  contentIndex: {}
149
208
  },
150
209
  setup(t) {
151
- const e = t, { contentText: n } = ie(e);
152
- return (o, r) => B(n) ? (g(), C("p", bt, z(B(n)), 1)) : se("", !0);
210
+ const e = t, { contentText: n } = fe(e);
211
+ return (s, a) => R(n) ? (v(), E("p", pt, z(R(n)), 1)) : ae("", !0);
153
212
  }
154
- }), ae = /* @__PURE__ */ N(ft, [["__scopeId", "data-v-93592ecb"]]), Ne = /* @__PURE__ */ S({
213
+ }), ce = /* @__PURE__ */ N(mt, [["__scopeId", "data-v-93592ecb"]]), Pe = /* @__PURE__ */ I({
155
214
  __name: "ToolRole",
156
215
  props: {
157
216
  message: {},
158
217
  contentIndex: {}
159
218
  },
160
219
  setup(t) {
161
- const e = t, n = ue();
162
- return q(() => {
220
+ const e = t, n = be();
221
+ return Z(() => {
163
222
  e.message.tool_call_id && (n.toolCallResults || (n.toolCallResults = {}), n.toolCallResults[e.message.tool_call_id] = e.message.content ?? "");
164
- }), (o, r) => se("", !0);
223
+ }), (s, a) => ae("", !0);
165
224
  }
166
- }), pt = {
225
+ }), _t = {
167
226
  class: "tr-bubble__tool-call",
168
227
  "data-type": "tool-call"
169
- }, _t = { class: "header" }, mt = { class: "header-left" }, gt = { class: "title" }, vt = { class: "header-right" }, ht = { class: "divider" }, yt = ["innerHTML"], xt = /* @__PURE__ */ S({
228
+ }, gt = { class: "header" }, vt = { class: "header-left" }, ht = { class: "title" }, yt = { class: "header-right" }, xt = { class: "divider" }, Bt = ["innerHTML"], Rt = /* @__PURE__ */ I({
170
229
  __name: "Tool",
171
230
  props: {
172
231
  message: {},
@@ -174,97 +233,103 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
174
233
  toolCallIndex: {}
175
234
  },
176
235
  setup(t) {
177
- const e = t, { toolCall: n, toolCallWithResult: o, state: r } = Pt(e), i = /* @__PURE__ */ new Map([
178
- ["running", { text: "正在调用", icon: he }],
179
- ["success", { text: "已调用", icon: be }],
180
- ["failed", { text: "调用失败", icon: qe }],
181
- ["cancelled", { text: "已取消", icon: Ze }]
182
- ]), s = y(() => {
183
- var _;
184
- return i.get(((_ = r.value) == null ? void 0 : _.status) || "") || { text: "", icon: be };
185
- }), a = (_, v = 2) => {
186
- let R = "";
236
+ const e = t, { toolCall: n, toolCallWithResult: s, state: a } = Ut(e), i = /* @__PURE__ */ new Map([
237
+ ["running", { text: "正在调用", icon: Be }],
238
+ ["success", { text: "已调用", icon: me }],
239
+ ["failed", { text: "调用失败", icon: Ze }],
240
+ ["cancelled", { text: "已取消", icon: Qe }]
241
+ ]), o = x(() => {
242
+ var d;
243
+ return i.get(((d = a.value) == null ? void 0 : d.status) || "") || { text: "", icon: me };
244
+ }), l = (d, _ = 2) => {
245
+ let b = "";
187
246
  try {
188
- typeof _ == "string" ? R = JSON.stringify(JSON.parse(_), null, v) : R = JSON.stringify(_, null, v);
247
+ typeof d == "string" ? b = JSON.stringify(JSON.parse(d), null, _) : b = JSON.stringify(d, null, _);
189
248
  } catch {
190
249
  }
191
- return R;
192
- }, u = je(), b = (_) => _.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), m = (_) => {
193
- if (!_)
250
+ return b;
251
+ }, u = Ve(), f = (d) => d.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), m = (d) => {
252
+ if (!d)
194
253
  return "";
195
- let v = b(_);
196
- return v = v.replace(
254
+ let _ = f(d);
255
+ return _ = _.replace(
197
256
  /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,
198
- (R) => {
199
- let O = "number";
200
- return /^"/.test(R) ? O = /:$/.test(R) ? "key" : "string" : /true|false/.test(R) ? O = "boolean" : /null/.test(R) && (O = "null"), `<span class="${u[O]}">${R}</span>`;
257
+ (b) => {
258
+ let S = "number";
259
+ return /^"/.test(b) ? S = /:$/.test(b) ? "key" : "string" : /true|false/.test(b) ? S = "boolean" : /null/.test(b) && (S = "null"), `<span class="${u[S]}">${b}</span>`;
201
260
  }
202
- ), v;
203
- }, p = y(() => a(o.value, 2)), f = y(() => m(p.value)), l = L(null);
204
- U(p, (_, v) => {
205
- v === "" || v === "{}" || ee(() => {
206
- l.value && l.value.scrollTo({
207
- top: l.value.scrollHeight,
261
+ ), _;
262
+ }, h = x(() => l(s.value, 2)), y = x(() => m(h.value)), g = L(null);
263
+ H(h, (d, _) => {
264
+ _ === "" || _ === "{}" || ne(() => {
265
+ g.value && g.value.scrollTo({
266
+ top: g.value.scrollHeight,
208
267
  behavior: "smooth"
209
268
  });
210
269
  });
211
270
  });
212
- const d = L(!1);
213
- q(() => {
214
- d.value = r.value.open ?? !1;
271
+ const c = L(!1);
272
+ Z(() => {
273
+ c.value = a.value.open ?? !1;
215
274
  });
216
- const h = Ke(), c = () => {
217
- var v, R;
218
- d.value = !d.value;
219
- const _ = (v = n.value) == null ? void 0 : v.id;
220
- _ && h("toolCall", {
221
- ...(R = e.message.state) == null ? void 0 : R.toolCall,
222
- [_]: { ...r.value, open: d.value }
275
+ const p = ie(), r = () => {
276
+ var _, b;
277
+ c.value = !c.value;
278
+ const d = (_ = n.value) == null ? void 0 : _.id;
279
+ d && p({
280
+ name: "state:update",
281
+ payload: {
282
+ key: "toolCall",
283
+ value: {
284
+ ...(b = e.message.state) == null ? void 0 : b.toolCall,
285
+ [d]: { ...a.value, open: c.value }
286
+ }
287
+ }
223
288
  });
224
289
  };
225
- return (_, v) => {
226
- var R;
227
- return g(), C("div", pt, [
228
- x("div", _t, [
229
- x("div", mt, [
230
- (g(), T(Y(s.value.icon), {
231
- class: K(["header-icon", `icon-${B(r).status}`])
290
+ return (d, _) => {
291
+ var b;
292
+ return v(), E("div", _t, [
293
+ B("div", gt, [
294
+ B("div", vt, [
295
+ (v(), A(J(o.value.icon), {
296
+ class: G(["header-icon", `icon-${R(a).status}`])
232
297
  }, null, 8, ["class"])),
233
- x("span", null, [
234
- x("span", null, z(s.value.text) + " ", 1),
235
- x("span", gt, z(((R = B(n)) == null ? void 0 : R.function.name) || "Untitled"), 1)
298
+ B("span", null, [
299
+ B("span", null, z(o.value.text) + " ", 1),
300
+ B("span", ht, z(((b = R(n)) == null ? void 0 : b.function.name) || "Untitled"), 1)
236
301
  ])
237
302
  ]),
238
- x("div", vt, [
239
- W(B(ye), {
240
- class: K(["expand-icon", { "-rotate-90": !d.value }]),
241
- onClick: c
303
+ B("div", yt, [
304
+ V(R(Re), {
305
+ class: G(["expand-icon", { "-rotate-90": !c.value }]),
306
+ onClick: r
242
307
  }, null, 8, ["class"])
243
308
  ])
244
309
  ]),
245
- Z(x("div", ht, null, 512), [
246
- [Q, d.value]
310
+ ee(B("div", xt, null, 512), [
311
+ [te, c.value]
247
312
  ]),
248
- Z(x("div", {
313
+ ee(B("div", {
249
314
  class: "detail",
250
- innerHTML: f.value,
315
+ innerHTML: y.value,
251
316
  ref_key: "detailRef",
252
- ref: l
253
- }, null, 8, yt), [
254
- [Q, d.value]
317
+ ref: g
318
+ }, null, 8, Bt), [
319
+ [te, c.value]
255
320
  ])
256
321
  ]);
257
322
  };
258
323
  }
259
- }), Rt = "_key_1b448_2", Bt = "_number_1b448_6", Ct = "_string_1b448_10", Et = "_boolean_1b448_14", kt = {
260
- key: Rt,
261
- number: Bt,
262
- string: Ct,
263
- boolean: Et,
324
+ }), Et = "_key_1b448_2", Ct = "_number_1b448_6", kt = "_string_1b448_10", It = "_boolean_1b448_14", St = {
325
+ key: Et,
326
+ number: Ct,
327
+ string: kt,
328
+ boolean: It,
264
329
  null: "_null_1b448_18"
265
- }, St = {
266
- $style: kt
267
- }, we = /* @__PURE__ */ N(xt, [["__cssModules", St], ["__scopeId", "data-v-d5b7675f"]]), Fe = /* @__PURE__ */ S({
330
+ }, Tt = {
331
+ $style: St
332
+ }, De = /* @__PURE__ */ N(Rt, [["__cssModules", Tt], ["__scopeId", "data-v-00014a8b"]]), Ue = /* @__PURE__ */ I({
268
333
  inheritAttrs: !1,
269
334
  __name: "Tools",
270
335
  props: {
@@ -272,247 +337,256 @@ const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matc
272
337
  contentIndex: {}
273
338
  },
274
339
  setup(t) {
275
- const e = t, { restMessage: n, restProps: o } = Ye(e, ["tool_calls"]), r = le(n, e.contentIndex);
276
- return (i, s) => (g(), C(F, null, [
277
- (g(), T(Y(B(r).renderer), P(D({ ...B(r).attributes, ...B(o) })), null, 16)),
278
- x("div", $({ class: "tr-bubble__tools" }, i.$attrs), [
279
- (g(!0), C(F, null, j(e.message.tool_calls, (a, u) => (g(), T(we, $({
280
- key: a.id
340
+ const e = t, { restMessage: n, restProps: s } = je(e, ["tool_calls"]), a = ue(n, e.contentIndex);
341
+ return (i, o) => (v(), E(P, null, [
342
+ (v(), A(J(R(a).renderer), D(U({ ...R(a).attributes, ...R(s) })), null, 16)),
343
+ B("div", O({ class: "tr-bubble__tools" }, i.$attrs), [
344
+ (v(!0), E(P, null, W(e.message.tool_calls, (l, u) => (v(), A(De, O({
345
+ key: l.id
281
346
  }, { ref_for: !0 }, e, { "tool-call-index": u }), null, 16, ["tool-call-index"]))), 128))
282
347
  ], 16)
283
348
  ], 64));
284
349
  }
285
- }), Pe = [
350
+ }), He = [
286
351
  {
287
352
  find: (t, e) => (e == null ? void 0 : e.type) === "image_url",
288
- renderer: w(re),
289
- priority: H.NORMAL,
353
+ renderer: F(le),
354
+ priority: K.NORMAL,
290
355
  attributes: { "data-box-type": "image" }
291
356
  }
292
- ], De = [
357
+ ], Ke = [
293
358
  {
294
359
  find: (t) => !!t.loading,
295
- renderer: w($e),
296
- priority: H.LOADING
360
+ renderer: F(we),
361
+ priority: K.LOADING
297
362
  },
298
363
  {
299
364
  find: (t) => typeof t.reasoning_content == "string" && t.reasoning_content.trim() !== "",
300
- renderer: w(Oe),
301
- priority: H.NORMAL
365
+ renderer: F(Fe),
366
+ priority: K.NORMAL
302
367
  },
303
368
  {
304
369
  find: (t) => Array.isArray(t.tool_calls) && t.tool_calls.length > 0,
305
- renderer: w(Fe),
306
- priority: H.NORMAL
370
+ renderer: F(Ue),
371
+ priority: K.NORMAL
307
372
  },
308
373
  {
309
374
  find: (t, e) => e.type === "image_url",
310
- renderer: w(Me),
311
- priority: H.CONTENT
375
+ renderer: F(Ne),
376
+ priority: K.CONTENT
312
377
  },
313
378
  {
314
379
  find: (t) => t.role === "tool",
315
- renderer: w(Ne),
316
- priority: H.ROLE
380
+ renderer: F(Pe),
381
+ priority: K.ROLE
317
382
  }
318
- ], Ue = w(re), He = w(ae), fe = Symbol("BUBBLE_CONTENT_RESOLVER_KEY"), te = (t) => {
319
- const e = I(fe, void 0), n = e ?? t;
320
- return !e && t && A(fe, t), n ? (r) => {
383
+ ], Ge = F(le), Ye = F(ce), ge = Symbol("BUBBLE_CONTENT_RESOLVER_KEY"), se = (t) => {
384
+ const e = T(ge, void 0), n = e ?? t;
385
+ return !e && t && M(ge, t), n ? (a) => {
321
386
  const i = k(n);
322
- return i == null ? void 0 : i(r);
323
- } : (r) => r.content;
387
+ return i == null ? void 0 : i(a);
388
+ } : (a) => a.content;
324
389
  };
325
- function It(t) {
326
- const { boxRendererMatches: e, boxAttributes: n, fallbackBoxRenderer: o } = t;
327
- e && A(Re, e), n && A(Ce, n), o && A(Be, o);
390
+ function At(t) {
391
+ const { boxRendererMatches: e, boxAttributes: n, fallbackBoxRenderer: s } = t;
392
+ e && M(Ce, e), n && M(Ie, n), s && M(ke, s);
328
393
  }
329
- function Tt(t) {
394
+ function Mt(t) {
330
395
  const { fallbackBoxRenderer: e } = t;
331
- e && A(Ee, e);
396
+ e && M(Se, e);
332
397
  }
333
- function At(t, e) {
334
- const n = I(Re, Pe), o = I(Ce, void 0), r = I(Be, void 0), i = I(Ee, void 0), s = te();
398
+ function Lt(t, e) {
399
+ const n = T(Ce, He), s = T(Ie, void 0), a = T(ke, void 0), i = T(Se, void 0), o = se();
335
400
  if (typeof e == "number" && k(t).length !== 1)
336
401
  throw new Error("[BubbleBoxRenderer] When contentIndex is a number, messages array length must be 1");
337
- const a = (b) => {
338
- if (b.length !== 1)
402
+ const l = (f) => {
403
+ if (f.length !== 1)
339
404
  return { content: void 0, index: void 0 };
340
- const m = s(b.at(0));
405
+ const m = o(f.at(0));
341
406
  return {
342
407
  content: Array.isArray(m) ? m.at(e ?? 0) : { type: "text", text: m || "" },
343
408
  index: e ?? 0
344
409
  };
345
- }, u = (b, m, p, f) => typeof b.attributes == "function" ? b.attributes(m, p, f) : b.attributes;
346
- return y(() => {
347
- const b = k(t), { content: m, index: p } = a(b), f = (() => {
348
- const d = k(o);
349
- if (d)
350
- return typeof d == "function" ? d(b, m, p) : d;
351
- })(), l = k(n).find((d) => d.find(b, m, p));
352
- return l ? {
353
- renderer: l.renderer,
410
+ }, u = (f, m, h, y) => typeof f.attributes == "function" ? f.attributes(m, h, y) : f.attributes;
411
+ return x(() => {
412
+ const f = k(t), { content: m, index: h } = l(f), y = (() => {
413
+ const c = k(s);
414
+ if (c)
415
+ return typeof c == "function" ? c(f, m, h) : c;
416
+ })(), g = k(n).find((c) => c.find(f, m, h));
417
+ return g ? {
418
+ renderer: g.renderer,
354
419
  attributes: {
355
- ...f,
356
- ...u(l, b, m, p)
420
+ ...y,
421
+ ...u(g, f, m, h)
357
422
  }
358
423
  } : {
359
- renderer: k(i) || k(r) || Ue,
360
- attributes: f
424
+ renderer: k(i) || k(a) || Ge,
425
+ attributes: y
361
426
  };
362
427
  });
363
428
  }
364
- function Lt(t) {
365
- const { contentRendererMatches: e, contentAttributes: n, fallbackContentRenderer: o } = t;
366
- e && A(ke, e), n && A(Ie, n), o && A(Se, o);
429
+ function $t(t) {
430
+ const { contentRendererMatches: e, contentAttributes: n, fallbackContentRenderer: s } = t;
431
+ e && M(Te, e), n && M(Me, n), s && M(Ae, s);
367
432
  }
368
- function Mt(t) {
433
+ function Ot(t) {
369
434
  const { fallbackContentRenderer: e } = t;
370
- e && A(Te, e);
435
+ e && M(Le, e);
371
436
  }
372
- function le(t, e) {
373
- const n = I(ke, De), o = I(Ie, void 0), r = I(Se, void 0), i = I(Te, void 0), s = te();
374
- return y(() => {
375
- const a = k(t), u = s(a), b = Array.isArray(u) ? u.at(e ?? 0) : { type: "text", text: u || "" }, m = (() => {
376
- const f = k(o);
377
- if (f)
378
- return typeof f == "function" ? f(a, b, e) : f;
379
- })(), p = k(n).find((f) => f.find(a, b, e));
380
- return p ? {
381
- renderer: p.renderer,
437
+ function ue(t, e) {
438
+ const n = T(Te, Ke), s = T(Me, void 0), a = T(Ae, void 0), i = T(Le, void 0), o = se();
439
+ return x(() => {
440
+ const l = k(t), u = o(l), f = Array.isArray(u) ? u.at(e ?? 0) : { type: "text", text: u || "" }, m = (() => {
441
+ const y = k(s);
442
+ if (y)
443
+ return typeof y == "function" ? y(l, f, e) : y;
444
+ })(), h = k(n).find((y) => y.find(l, f, e));
445
+ return h ? {
446
+ renderer: h.renderer,
382
447
  attributes: {
383
448
  ...m,
384
- ...p.attributes
449
+ ...h.attributes
385
450
  }
386
451
  } : {
387
- renderer: k(i) || k(r) || He,
452
+ renderer: k(i) || k(a) || Ye,
388
453
  attributes: m
389
454
  };
390
455
  });
391
456
  }
392
- function $t(t) {
393
- A(Ae, t);
457
+ function Nt(t) {
458
+ M($e, t);
394
459
  }
395
- function Ke() {
396
- return I(Ae, (t, e) => {
397
- console.warn(`[Bubble] State change function not found for key: ${t}`);
460
+ function ie() {
461
+ return T($e, (t) => {
462
+ console.warn(`[Bubble] Event function not found for event: ${t.name}`);
398
463
  });
399
464
  }
400
- function ce(t) {
401
- const e = I(oe, void 0);
465
+ function an() {
466
+ const t = ie();
467
+ return (e, n) => {
468
+ t({
469
+ name: "state:update",
470
+ payload: { key: e, value: n }
471
+ });
472
+ };
473
+ }
474
+ function de(t) {
475
+ const e = T(re, void 0);
402
476
  if (e)
403
477
  return e;
404
- const n = We(t || {});
405
- return A(oe, n), n;
478
+ const n = ze(t || {});
479
+ return M(re, n), n;
406
480
  }
407
- function ue() {
408
- return I(oe, {});
481
+ function be() {
482
+ return T(re, {});
409
483
  }
410
- function Ge(t) {
411
- U(
484
+ function Je(t) {
485
+ H(
412
486
  t,
413
- (e, n, o) => {
487
+ (e, n, s) => {
414
488
  if (!e) return;
415
- const r = (i) => {
489
+ const a = (i) => {
416
490
  var u;
417
- const s = window.getSelection();
418
- if (!e.contains((s == null ? void 0 : s.anchorNode) || null)) return;
491
+ const o = window.getSelection();
492
+ if (!e.contains((o == null ? void 0 : o.anchorNode) || null)) return;
419
493
  i.preventDefault();
420
- const a = (s == null ? void 0 : s.toString().replace(/\n{2,}/g, `
494
+ const l = (o == null ? void 0 : o.toString().replace(/\n{2,}/g, `
421
495
  `)) || "";
422
- (u = i.clipboardData) == null || u.setData("text/plain", a);
496
+ (u = i.clipboardData) == null || u.setData("text/plain", l);
423
497
  };
424
- e.addEventListener("copy", r), o(() => e.removeEventListener("copy", r));
498
+ e.addEventListener("copy", a), s(() => e.removeEventListener("copy", a));
425
499
  },
426
500
  { immediate: !0, flush: "post" }
427
501
  );
428
502
  }
429
- const ie = (t) => {
430
- const e = te(), n = y(() => {
431
- const r = e(t.message);
432
- return Array.isArray(r) ? r.at(t.contentIndex) : { type: "text", text: r || "" };
433
- }), o = y(() => n.value.type === "text" ? String(n.value.text) : "");
503
+ const fe = (t) => {
504
+ const e = se(), n = x(() => {
505
+ const a = e(t.message);
506
+ return Array.isArray(a) ? a.at(t.contentIndex) : { type: "text", text: a || "" };
507
+ }), s = x(() => n.value.type === "text" ? String(n.value.text) : "");
434
508
  return {
435
509
  content: n,
436
- contentText: o
510
+ contentText: s
437
511
  };
438
512
  };
439
- function Ot(t) {
440
- A(xe, t);
513
+ function wt(t) {
514
+ M(Ee, t);
441
515
  }
442
- function Nt() {
443
- return I(xe, void 0);
516
+ function Ft() {
517
+ return T(Ee, void 0);
444
518
  }
445
- function Ye(t, e) {
446
- const n = y(() => {
447
- const r = Object.entries(t.message).filter(([i]) => !e.includes(i));
448
- return Object.fromEntries(r);
449
- }), o = y(() => ({
519
+ function je(t, e) {
520
+ const n = x(() => {
521
+ const a = Object.entries(t.message).filter(([i]) => !e.includes(i));
522
+ return Object.fromEntries(a);
523
+ }), s = x(() => ({
450
524
  ...t,
451
525
  message: n.value
452
526
  }));
453
527
  return {
454
528
  restMessage: n,
455
- restProps: o
529
+ restProps: s
456
530
  };
457
531
  }
458
- let ne = null;
459
- const wt = () => (ne || (ne = import("./index5.js")), ne);
460
- let J = null;
461
- const Ft = async () => {
462
- if (J)
463
- return J;
532
+ let oe = null;
533
+ const Pt = () => (oe || (oe = import("./index5.js")), oe);
534
+ let j = null;
535
+ const Dt = async () => {
536
+ if (j)
537
+ return j;
464
538
  try {
465
539
  const [t, e] = await Promise.all([import("markdown-it"), import("dompurify")]);
466
- return J = { markdown: t.default, dompurify: e.default }, J;
540
+ return j = { markdown: t.default, dompurify: e.default }, j;
467
541
  } catch {
468
- return console.warn("[BubbleMarkdownRenderer] install markdown-it and dompurify to use markdown renderer"), J = null, null;
542
+ return console.warn("[BubbleMarkdownRenderer] install markdown-it and dompurify to use markdown renderer"), j = null, null;
469
543
  }
470
- }, pe = ["running", "success", "failed", "cancelled"], Pt = (t) => {
471
- const e = y(() => {
472
- var s, a;
473
- return (a = (s = t.message) == null ? void 0 : s.tool_calls) == null ? void 0 : a[t.toolCallIndex];
474
- }), n = ue(), o = y(() => {
475
- var m, p, f;
476
- let s = n.toolCallDefaultStatus;
477
- s && !pe.includes(s) && (s = void 0);
478
- const a = n.toolCallDefaultOpen;
544
+ }, ve = ["running", "success", "failed", "cancelled"], Ut = (t) => {
545
+ const e = x(() => {
546
+ var o, l;
547
+ return (l = (o = t.message) == null ? void 0 : o.tool_calls) == null ? void 0 : l[t.toolCallIndex];
548
+ }), n = be(), s = x(() => {
549
+ var m, h, y;
550
+ let o = n.toolCallDefaultStatus;
551
+ o && !ve.includes(o) && (o = void 0);
552
+ const l = n.toolCallDefaultOpen;
479
553
  let u = {
480
- status: s,
481
- open: a
554
+ status: o,
555
+ open: l
482
556
  };
483
- const b = (m = e.value) == null ? void 0 : m.id;
484
- if (b) {
485
- const l = (f = (p = t.message.state) == null ? void 0 : p.toolCall) == null ? void 0 : f[b];
486
- if (l) {
487
- const { status: d, open: h, ...c } = l;
488
- d && pe.includes(d) && (u.status = d), h !== void 0 && (u.open = h), u = { ...u, ...c };
557
+ const f = (m = e.value) == null ? void 0 : m.id;
558
+ if (f) {
559
+ const g = (y = (h = t.message.state) == null ? void 0 : h.toolCall) == null ? void 0 : y[f];
560
+ if (g) {
561
+ const { status: c, open: p, ...r } = g;
562
+ c && ve.includes(c) && (u.status = c), p !== void 0 && (u.open = p), u = { ...u, ...r };
489
563
  }
490
564
  }
491
565
  return u;
492
- }), r = y(() => {
493
- var a, u;
494
- const s = (a = e.value) == null ? void 0 : a.id;
495
- if (s)
496
- return (u = n.toolCallResults) == null ? void 0 : u[s];
566
+ }), a = x(() => {
567
+ var l, u;
568
+ const o = (l = e.value) == null ? void 0 : l.id;
569
+ if (o)
570
+ return (u = n.toolCallResults) == null ? void 0 : u[o];
497
571
  }), i = L({});
498
- return q(() => {
572
+ return Z(() => {
499
573
  var u;
500
- const s = (u = e.value) == null ? void 0 : u.function.arguments, a = r.value;
501
- wt().then(({ jsonrepair: b }) => {
502
- const m = b(typeof s == "string" ? s || "{}" : JSON.stringify(s));
574
+ const o = (u = e.value) == null ? void 0 : u.function.arguments, l = a.value;
575
+ Pt().then(({ jsonrepair: f }) => {
576
+ const m = f(typeof o == "string" ? o || "{}" : JSON.stringify(o));
503
577
  i.value = {
504
578
  arguments: JSON.parse(m),
505
- result: a ? JSON.parse(b(a || "{}")) : void 0
579
+ result: l ? JSON.parse(f(l || "{}")) : void 0
506
580
  };
507
- }).catch((b) => {
508
- console.warn(b);
581
+ }).catch((f) => {
582
+ console.warn(f);
509
583
  });
510
584
  }), {
511
585
  toolCall: e,
512
- toolCallWithResult: ze(i),
513
- state: o
586
+ toolCallWithResult: Xe(i),
587
+ state: s
514
588
  };
515
- }, _e = /* @__PURE__ */ S({
589
+ }, he = /* @__PURE__ */ I({
516
590
  __name: "BubbleBoxWrapper",
517
591
  props: {
518
592
  role: {},
@@ -522,40 +596,48 @@ const Ft = async () => {
522
596
  contentIndex: {}
523
597
  },
524
598
  setup(t) {
525
- const e = t, n = At(() => e.messages, e.contentIndex);
526
- return (o, r) => (g(), T(Y(B(n).renderer), $(B(n).attributes, {
599
+ const e = t, n = Lt(() => e.messages, e.contentIndex);
600
+ return (s, a) => (v(), A(J(R(n).renderer), O(R(n).attributes, {
527
601
  "data-role": e.role,
528
602
  "data-placement": e.placement,
529
603
  "data-shape": e.shape
530
604
  }), {
531
- default: M(() => [
532
- E(o.$slots, "default")
605
+ default: $(() => [
606
+ C(s.$slots, "default")
533
607
  ]),
534
608
  _: 3
535
609
  }, 16, ["data-role", "data-placement", "data-shape"]));
536
610
  }
537
- }), me = /* @__PURE__ */ S({
611
+ }), ye = /* @__PURE__ */ I({
538
612
  __name: "BubbleContentWrapper",
539
613
  props: {
540
614
  message: {},
541
615
  contentIndex: {}
542
616
  },
543
- emits: ["state-change"],
617
+ emits: ["state-change", "bubble-event"],
544
618
  setup(t, { emit: e }) {
545
- const n = t, o = le(() => n.message, n.contentIndex), r = y(() => ({
546
- ...o.value.attributes,
619
+ const n = t, s = ue(() => n.message, n.contentIndex), a = x(() => ({
620
+ ...s.value.attributes,
547
621
  message: n.message,
548
622
  contentIndex: n.contentIndex
549
623
  })), i = e;
550
- return $t((a, u) => {
551
- i("state-change", {
552
- key: a,
553
- value: u,
624
+ return Nt((l) => {
625
+ if (i("bubble-event", {
626
+ ...l,
554
627
  contentIndex: n.contentIndex
555
- });
556
- }), (a, u) => (g(), T(Y(B(o).renderer), P(D(r.value)), null, 16));
628
+ }), l.name === "state:update") {
629
+ const u = l.payload;
630
+ if (!u || typeof u != "object" || !("key" in u) || typeof u.key != "string" || !("value" in u))
631
+ return;
632
+ i("state-change", {
633
+ key: u.key,
634
+ value: u.value,
635
+ contentIndex: n.contentIndex
636
+ });
637
+ }
638
+ }), (l, u) => (v(), A(J(R(s).renderer), D(U(a.value)), null, 16));
557
639
  }
558
- }), Dt = ["data-role", "data-placement"], Ut = { class: "tr-bubble__body" }, Ht = { class: "tr-bubble__content" }, Kt = { class: "tr-bubble__after" }, Gt = /* @__PURE__ */ S({
640
+ }), Ht = ["data-role", "data-placement"], Kt = { class: "tr-bubble__body" }, Gt = { class: "tr-bubble__content" }, Yt = { class: "tr-bubble__after" }, Jt = /* @__PURE__ */ I({
559
641
  __name: "Bubble",
560
642
  props: {
561
643
  content: {},
@@ -576,168 +658,116 @@ const Ft = async () => {
576
658
  fallbackBoxRenderer: {},
577
659
  fallbackContentRenderer: {}
578
660
  },
579
- emits: ["state-change"],
661
+ emits: ["state-change", "bubble-event"],
580
662
  setup(t, { emit: e }) {
581
- const n = t, o = te(() => n.contentResolver), r = e;
582
- ce();
583
- const i = Nt(), s = y(() => k(i)), a = y(() => {
584
- var de;
585
- if ((de = s.value) != null && de.messages.length)
586
- return s.value.messages;
587
- const { role: l, content: d, reasoning_content: h, tool_calls: c, tool_call_id: _, name: v, id: R, loading: O, state: Je } = n;
588
- return [{ role: l, content: d, reasoning_content: h, tool_calls: c, tool_call_id: _, name: v, id: R, loading: O, state: Je }];
589
- }), u = (l) => {
590
- const d = o(l);
591
- return Array.isArray(d) ? d : [{ type: "text", text: d || "" }];
663
+ const n = t, s = se(() => n.contentResolver), a = e;
664
+ de();
665
+ const i = Ft(), o = x(() => k(i)), l = x(() => {
666
+ var Q;
667
+ if ((Q = o.value) != null && Q.messages.length)
668
+ return o.value.messages;
669
+ const { role: g, content: c, reasoning_content: p, tool_calls: r, tool_call_id: d, name: _, id: b, loading: S, state: w } = n;
670
+ return [{ role: g, content: c, reasoning_content: p, tool_calls: r, tool_call_id: d, name: _, id: b, loading: S, state: w }];
671
+ }), u = (g) => {
672
+ const c = s(g);
673
+ return Array.isArray(c) ? c : [{ type: "text", text: c || "" }];
592
674
  };
593
- Tt({ fallbackBoxRenderer: () => n.fallbackBoxRenderer }), Mt({ fallbackContentRenderer: () => n.fallbackContentRenderer });
594
- const b = y(() => a.value.length === 0 ? !0 : n.hidden), m = y(() => {
595
- if (n.contentRenderMode === "split" && a.value.length === 1) {
596
- const l = o(a.value.at(0));
597
- if (Array.isArray(l))
598
- return l;
675
+ Mt({ fallbackBoxRenderer: () => n.fallbackBoxRenderer }), Ot({ fallbackContentRenderer: () => n.fallbackContentRenderer });
676
+ const f = x(() => l.value.length === 0 ? !0 : n.hidden), m = x(() => {
677
+ if (n.contentRenderMode === "split" && l.value.length === 1) {
678
+ const g = s(l.value.at(0));
679
+ if (Array.isArray(g))
680
+ return g;
599
681
  }
600
682
  return null;
601
- }), p = I(Le, !1), f = L(null);
602
- return p || Ge(f), (l, d) => Z((g(), C("div", {
683
+ }), h = T(Oe, !1), y = L(null);
684
+ return h || Je(y), (g, c) => ee((v(), E("div", {
603
685
  class: "tr-bubble",
604
686
  ref_key: "bubbleRef",
605
- ref: f,
687
+ ref: y,
606
688
  "data-role": n.role,
607
689
  "data-placement": n.placement
608
690
  }, [
609
- E(l.$slots, "prefix", {
610
- messages: a.value,
691
+ C(g.$slots, "prefix", {
692
+ messages: l.value,
611
693
  role: t.role
612
694
  }, void 0, !0),
613
- x("div", Ut, [
614
- n.avatar ? (g(), T(Y(n.avatar), {
695
+ B("div", Kt, [
696
+ n.avatar ? (v(), A(J(n.avatar), {
615
697
  key: 0,
616
- class: K(["tr-bubble__avatar", l.$style["tr-bubble__avatar"]])
617
- }, null, 8, ["class"])) : se("", !0),
618
- x("div", Ht, [
619
- m.value ? (g(!0), C(F, { key: 0 }, j(m.value, (h, c) => (g(), T(_e, {
620
- key: c,
698
+ class: G(["tr-bubble__avatar", g.$style["tr-bubble__avatar"]])
699
+ }, null, 8, ["class"])) : ae("", !0),
700
+ B("div", Gt, [
701
+ m.value ? (v(!0), E(P, { key: 0 }, W(m.value, (p, r) => (v(), A(he, {
702
+ key: r,
621
703
  class: "tr-bubble__box",
622
704
  role: n.role,
623
705
  placement: n.placement,
624
706
  shape: n.shape,
625
- messages: a.value,
626
- "content-index": c
707
+ messages: l.value,
708
+ "content-index": r
627
709
  }, {
628
- default: M(() => [
629
- W(me, {
630
- message: a.value.at(0),
631
- "content-index": c,
632
- onStateChange: d[0] || (d[0] = (_) => r("state-change", { ..._, messageIndex: 0 }))
710
+ default: $(() => [
711
+ V(ye, {
712
+ message: l.value.at(0),
713
+ "content-index": r,
714
+ onStateChange: c[0] || (c[0] = (d) => a("state-change", { ...d, messageIndex: 0 })),
715
+ onBubbleEvent: c[1] || (c[1] = (d) => a("bubble-event", { ...d, messageIndex: 0 }))
633
716
  }, null, 8, ["message", "content-index"]),
634
- E(l.$slots, "content-footer", {
635
- messages: a.value,
717
+ C(g.$slots, "content-footer", {
718
+ messages: l.value,
636
719
  role: n.role,
637
- contentIndex: c
720
+ contentIndex: r
638
721
  }, void 0, !0)
639
722
  ]),
640
723
  _: 2
641
- }, 1032, ["role", "placement", "shape", "messages", "content-index"]))), 128)) : (g(), T(_e, {
724
+ }, 1032, ["role", "placement", "shape", "messages", "content-index"]))), 128)) : (v(), A(he, {
642
725
  key: 1,
643
726
  role: n.role,
644
727
  placement: n.placement,
645
728
  shape: n.shape,
646
- messages: a.value
729
+ messages: l.value
647
730
  }, {
648
- default: M(() => [
649
- (g(!0), C(F, null, j(a.value, (h, c) => (g(), C(F, {
650
- key: `message-${c}`
731
+ default: $(() => [
732
+ (v(!0), E(P, null, W(l.value, (p, r) => (v(), E(P, {
733
+ key: `message-${r}`
651
734
  }, [
652
- (g(!0), C(F, null, j(u(h), (_, v) => (g(), T(me, {
653
- key: `content-${v}`,
654
- message: h,
655
- "content-index": v,
656
- onStateChange: (R) => r("state-change", { ...R, messageIndex: c })
657
- }, null, 8, ["message", "content-index", "onStateChange"]))), 128))
735
+ (v(!0), E(P, null, W(u(p), (d, _) => (v(), A(ye, {
736
+ key: `content-${_}`,
737
+ message: p,
738
+ "content-index": _,
739
+ onStateChange: (b) => a("state-change", { ...b, messageIndex: r }),
740
+ onBubbleEvent: (b) => a("bubble-event", { ...b, messageIndex: r })
741
+ }, null, 8, ["message", "content-index", "onStateChange", "onBubbleEvent"]))), 128))
658
742
  ], 64))), 128)),
659
- E(l.$slots, "content-footer", {
660
- messages: a.value,
743
+ C(g.$slots, "content-footer", {
744
+ messages: l.value,
661
745
  role: n.role
662
746
  }, void 0, !0)
663
747
  ]),
664
748
  _: 3
665
749
  }, 8, ["role", "placement", "shape", "messages"]))
666
750
  ]),
667
- x("div", Kt, [
668
- E(l.$slots, "after", {
669
- messages: a.value,
751
+ B("div", Yt, [
752
+ C(g.$slots, "after", {
753
+ messages: l.value,
670
754
  role: t.role
671
755
  }, void 0, !0)
672
756
  ])
673
757
  ]),
674
- E(l.$slots, "suffix", {
675
- messages: a.value,
758
+ C(g.$slots, "suffix", {
759
+ messages: l.value,
676
760
  role: t.role
677
761
  }, void 0, !0)
678
- ], 8, Dt)), [
679
- [Q, !b.value]
762
+ ], 8, Ht)), [
763
+ [te, !f.value]
680
764
  ]);
681
765
  }
682
- }), Yt = {
766
+ }), jt = {
683
767
  "tr-bubble__avatar": "_tr-bubble__avatar_1r87c_2"
684
- }, Jt = {
685
- $style: Yt
686
- }, G = /* @__PURE__ */ N(Gt, [["__cssModules", Jt], ["__scopeId", "data-v-2d927bba"]]);
687
- function ge(t, e) {
688
- const n = U(t, (o, r) => {
689
- r === !0 && o === !1 && (e(), n());
690
- });
691
- return n;
692
- }
693
- function jt(t, e, n) {
694
- const { scrollOnMount: o = !0, bottomThreshold: r = 20, scrollThrottle: i = 0 } = n ?? {}, s = L(!0);
695
- let a = !1;
696
- const u = /* @__PURE__ */ new Set(), b = () => nt(t), { y: m, isScrolling: p, arrivedState: f } = Qe(b, { throttle: i }), l = (c) => c.scrollHeight - c.scrollTop - c.clientHeight <= r, d = async (c = "auto") => {
697
- const _ = k(b);
698
- if (_ && (await ee(), _.scrollTo({ top: _.scrollHeight, behavior: c }), c === "smooth" && !l(_))) {
699
- const v = ge(p, () => {
700
- _.scrollTo({ top: _.scrollHeight, behavior: "auto" }), u.delete(v);
701
- });
702
- u.add(v);
703
- }
704
- }, h = () => {
705
- a || !s.value || (a = !0, requestAnimationFrame(async () => {
706
- a = !1, await d("auto");
707
- }));
708
- };
709
- return U(
710
- m,
711
- () => {
712
- const c = k(b);
713
- c && (s.value = l(c));
714
- },
715
- { flush: "post" }
716
- ), et(
717
- e,
718
- () => {
719
- h();
720
- },
721
- { flush: "post", throttle: 100 }
722
- ), ve(() => {
723
- o && d("smooth");
724
- }), Ve(() => {
725
- u.forEach((c) => {
726
- c();
727
- }), u.clear();
728
- }), tt("keydown", (c) => {
729
- if (c.key === "End" && !s.value) {
730
- const _ = ge(p, () => {
731
- d("auto"), u.delete(_);
732
- });
733
- u.add(_);
734
- }
735
- }), {
736
- scrollToBottom: d,
737
- arrivedState: f
738
- };
739
- }
740
- const Wt = /* @__PURE__ */ S({
768
+ }, Wt = {
769
+ $style: jt
770
+ }, Y = /* @__PURE__ */ N(Jt, [["__cssModules", Wt], ["__scopeId", "data-v-d68ceaad"]]), Vt = /* @__PURE__ */ I({
741
771
  __name: "BubbleItem",
742
772
  props: {
743
773
  messageGroup: {},
@@ -745,31 +775,32 @@ const Wt = /* @__PURE__ */ S({
745
775
  contentRenderMode: {},
746
776
  contentResolver: { type: Function }
747
777
  },
748
- emits: ["state-change"],
778
+ emits: ["state-change", "bubble-event"],
749
779
  setup(t, { emit: e }) {
750
- const n = t, o = e;
751
- return Ot(() => n.messageGroup), (r, i) => (g(), T(G, $(t.roleConfig, {
780
+ const n = t, s = e;
781
+ return wt(() => n.messageGroup), (a, i) => (v(), A(Y, O(t.roleConfig, {
752
782
  role: t.messageGroup.role,
753
783
  "content-render-mode": t.contentRenderMode,
754
784
  "content-resolver": t.contentResolver,
755
- onStateChange: i[0] || (i[0] = (s) => o("state-change", s))
785
+ onStateChange: i[0] || (i[0] = (o) => s("state-change", o)),
786
+ onBubbleEvent: i[1] || (i[1] = (o) => s("bubble-event", o))
756
787
  }), {
757
- prefix: M((s) => [
758
- E(r.$slots, "prefix", P(D(s)))
788
+ prefix: $((o) => [
789
+ C(a.$slots, "prefix", D(U(o)))
759
790
  ]),
760
- suffix: M((s) => [
761
- E(r.$slots, "suffix", P(D(s)))
791
+ suffix: $((o) => [
792
+ C(a.$slots, "suffix", D(U(o)))
762
793
  ]),
763
- "content-footer": M((s) => [
764
- E(r.$slots, "content-footer", P(D(s)))
794
+ "content-footer": $((o) => [
795
+ C(a.$slots, "content-footer", D(U(o)))
765
796
  ]),
766
- after: M((s) => [
767
- E(r.$slots, "after", P(D(s)))
797
+ after: $((o) => [
798
+ C(a.$slots, "after", D(U(o)))
768
799
  ]),
769
800
  _: 3
770
801
  }, 16, ["role", "content-render-mode", "content-resolver"]));
771
802
  }
772
- }), zt = /* @__PURE__ */ S({
803
+ }), zt = /* @__PURE__ */ I({
773
804
  __name: "BubbleList",
774
805
  props: {
775
806
  messages: {},
@@ -781,110 +812,128 @@ const Wt = /* @__PURE__ */ S({
781
812
  contentResolver: { type: Function, default: (t) => t.content },
782
813
  autoScroll: { type: Boolean }
783
814
  },
784
- emits: ["state-change"],
815
+ emits: ["state-change", "bubble-event"],
785
816
  setup(t, { expose: e, emit: n }) {
786
- const o = t, r = n;
787
- ce(), A(Le, !0);
788
- const i = (p) => {
789
- var f, l;
790
- return p ? !!((l = (f = o.roleConfigs) == null ? void 0 : f[p]) != null && l.hidden) : !1;
791
- }, s = L(null);
792
- let a = async () => {
817
+ const s = t, a = n;
818
+ de(), M(Oe, !0);
819
+ const i = (c) => {
820
+ var p, r;
821
+ return c ? !!((r = (p = s.roleConfigs) == null ? void 0 : p[c]) != null && r.hidden) : !1;
822
+ }, o = L(null);
823
+ let l = async () => {
793
824
  };
794
- if (o.autoScroll) {
795
- const p = y(() => o.messages.at(-1)), { scrollToBottom: f } = jt(s, () => {
796
- var l, d;
825
+ if (s.autoScroll) {
826
+ const c = x(() => s.messages.at(-1)), { scrollToBottom: p } = ot(o, () => {
827
+ var r, d;
797
828
  return [
798
- o.messages.length,
799
- (l = p.value) == null ? void 0 : l.content,
800
- (d = p.value) == null ? void 0 : d.reasoning_content
829
+ s.messages.length,
830
+ (r = c.value) == null ? void 0 : r.content,
831
+ (d = c.value) == null ? void 0 : d.reasoning_content
801
832
  ];
802
833
  });
803
- a = f, U(
834
+ l = p, H(
804
835
  () => {
805
- var l;
806
- return (l = p.value) == null ? void 0 : l.role;
836
+ var r;
837
+ return (r = c.value) == null ? void 0 : r.role;
807
838
  },
808
- async (l) => {
809
- l === "user" && (await ee(), f("smooth"));
839
+ async (r) => {
840
+ r === "user" && (await ne(), p("smooth"));
810
841
  }
811
842
  );
812
843
  }
813
- Ge(s);
814
- const u = (p) => {
815
- const f = [];
816
- let l = !1;
817
- for (const [d, h] of p.entries()) {
818
- const c = f[f.length - 1], _ = h.role || "", v = i(h.role);
819
- c && (l && v || c.role === _ && l === v) ? (c.messages.push(h), c.messageIndexes.push(d)) : f.push({
820
- role: _,
821
- messages: [h],
822
- messageIndexes: [d],
823
- startIndex: d
824
- }), l = v;
844
+ Je(o);
845
+ const u = (c) => {
846
+ const p = [];
847
+ let r = !1;
848
+ for (const [d, _] of c.entries()) {
849
+ const b = p[p.length - 1], S = _.role || "", w = i(_.role);
850
+ b && (r && w || b.role === S && r === w) ? (b.messages.push(_), b.messageIndexes.push(d)) : p.push({
851
+ role: S,
852
+ messages: [_],
853
+ messageIndexes: [d]
854
+ }), r = w;
825
855
  }
826
- return f;
827
- }, b = (p, f) => {
828
- const l = [];
856
+ return p;
857
+ }, f = (c, p) => {
858
+ const r = [];
829
859
  let d = !1;
830
- for (const [h, c] of p.entries()) {
831
- const _ = l[l.length - 1], v = c.role === f, R = c.role || "", O = i(c.role);
832
- _ && // divider 消息(分割角色)永远不与任何组进行合并
833
- !v && // divider 组(分割角色)不允许被追加消息,确保 divider 组永远只有 1 条 message
834
- _.role !== f && // hidden / 非 hidden 分组隔离
835
- d === O ? (_.messages.push(c), _.messageIndexes.push(h)) : l.push({
836
- role: v ? f : R,
837
- messages: [c],
838
- messageIndexes: [h],
839
- startIndex: h
840
- }), d = O;
860
+ for (const [_, b] of c.entries()) {
861
+ const S = r[r.length - 1], w = b.role === p, Q = b.role || "", pe = i(b.role);
862
+ S && // divider 消息(分割角色)永远不与任何组进行合并
863
+ !w && // divider 组(分割角色)不允许被追加消息,确保 divider 组永远只有 1 条 message
864
+ S.role !== p && // hidden / 非 hidden 分组隔离
865
+ d === pe ? (S.messages.push(b), S.messageIndexes.push(_)) : r.push({
866
+ role: w ? p : Q,
867
+ messages: [b],
868
+ messageIndexes: [_]
869
+ }), d = pe;
841
870
  }
842
- return l;
843
- }, m = y(() => o.messages.length === 0 ? [] : typeof o.groupStrategy == "function" ? o.groupStrategy(o.messages, o.dividerRole) : o.groupStrategy === "consecutive" ? u(o.messages) : b(o.messages, o.dividerRole));
871
+ return r;
872
+ }, m = x(() => s.messages.length === 0 ? [] : typeof s.groupStrategy == "function" ? s.groupStrategy(s.messages, s.dividerRole) : s.groupStrategy === "consecutive" ? u(s.messages) : f(s.messages, s.dividerRole)), h = (c, p) => {
873
+ const r = c.messageIndexes[p];
874
+ if (r === void 0) {
875
+ console.warn(
876
+ "[BubbleList] Missing messageIndexes mapping; event was not emitted. Ensure custom groupStrategy returns messageIndexes aligned with messages.",
877
+ {
878
+ messageIndex: p,
879
+ messageIndexes: c.messageIndexes
880
+ }
881
+ );
882
+ return;
883
+ }
884
+ return r;
885
+ }, y = (c, p) => {
886
+ const r = h(c, p.messageIndex);
887
+ r !== void 0 && a("state-change", { ...p, messageIndex: r });
888
+ }, g = (c, p) => {
889
+ const r = h(c, p.messageIndex);
890
+ r !== void 0 && a("bubble-event", { ...p, messageIndex: r });
891
+ };
844
892
  return e({
845
- scrollToBottom: a
846
- }), (p, f) => (g(), C("div", {
893
+ scrollToBottom: l
894
+ }), (c, p) => (v(), E("div", {
847
895
  class: "tr-bubble-list",
848
896
  ref_key: "listRef",
849
- ref: s
897
+ ref: o
850
898
  }, [
851
- (g(!0), C(F, null, j(m.value, (l, d) => {
852
- var h;
853
- return g(), T(Wt, {
899
+ (v(!0), E(P, null, W(m.value, (r, d) => {
900
+ var _;
901
+ return v(), A(Vt, {
854
902
  key: d,
855
- role: l.role || o.fallbackRole,
856
- "role-config": (h = o.roleConfigs) == null ? void 0 : h[l.role || o.fallbackRole],
857
- "message-group": l,
858
- "content-render-mode": o.contentRenderMode,
859
- "content-resolver": o.contentResolver,
860
- onStateChange: (c) => r("state-change", { ...c, messageIndex: l.startIndex + c.messageIndex })
903
+ role: r.role || s.fallbackRole,
904
+ "role-config": (_ = s.roleConfigs) == null ? void 0 : _[r.role || s.fallbackRole],
905
+ "message-group": r,
906
+ "content-render-mode": s.contentRenderMode,
907
+ "content-resolver": s.contentResolver,
908
+ onStateChange: (b) => y(r, b),
909
+ onBubbleEvent: (b) => g(r, b)
861
910
  }, {
862
- prefix: M((c) => [
863
- E(p.$slots, "prefix", $({ ref_for: !0 }, c, {
864
- messageIndexes: l.messageIndexes
911
+ prefix: $((b) => [
912
+ C(c.$slots, "prefix", O({ ref_for: !0 }, b, {
913
+ messageIndexes: r.messageIndexes
865
914
  }), void 0, !0)
866
915
  ]),
867
- suffix: M((c) => [
868
- E(p.$slots, "suffix", $({ ref_for: !0 }, c, {
869
- messageIndexes: l.messageIndexes
916
+ suffix: $((b) => [
917
+ C(c.$slots, "suffix", O({ ref_for: !0 }, b, {
918
+ messageIndexes: r.messageIndexes
870
919
  }), void 0, !0)
871
920
  ]),
872
- "content-footer": M((c) => [
873
- E(p.$slots, "content-footer", $({ ref_for: !0 }, c, {
874
- messageIndexes: l.messageIndexes
921
+ "content-footer": $((b) => [
922
+ C(c.$slots, "content-footer", O({ ref_for: !0 }, b, {
923
+ messageIndexes: r.messageIndexes
875
924
  }), void 0, !0)
876
925
  ]),
877
- after: M((c) => [
878
- E(p.$slots, "after", $({ ref_for: !0 }, c, {
879
- messageIndexes: l.messageIndexes
926
+ after: $((b) => [
927
+ C(c.$slots, "after", O({ ref_for: !0 }, b, {
928
+ messageIndexes: r.messageIndexes
880
929
  }), void 0, !0)
881
930
  ]),
882
931
  _: 2
883
- }, 1032, ["role", "role-config", "message-group", "content-render-mode", "content-resolver", "onStateChange"]);
932
+ }, 1032, ["role", "role-config", "message-group", "content-render-mode", "content-resolver", "onStateChange", "onBubbleEvent"]);
884
933
  }), 128))
885
934
  ], 512));
886
935
  }
887
- }), V = /* @__PURE__ */ N(zt, [["__scopeId", "data-v-e217fbb7"]]), X = /* @__PURE__ */ S({
936
+ }), X = /* @__PURE__ */ N(zt, [["__scopeId", "data-v-1d84cbfe"]]), q = /* @__PURE__ */ I({
888
937
  __name: "BubbleProvider",
889
938
  props: {
890
939
  boxRendererMatches: {},
@@ -897,82 +946,83 @@ const Wt = /* @__PURE__ */ S({
897
946
  },
898
947
  setup(t) {
899
948
  const e = t;
900
- ce(e.store);
901
- const n = y(() => (e.boxRendererMatches || []).concat(Pe).sort((s, a) => (s.priority ?? 0) - (a.priority ?? 0))), o = y(() => (e.contentRendererMatches || []).concat(De).sort((s, a) => (s.priority ?? 0) - (a.priority ?? 0))), r = y(() => e.fallbackBoxRenderer || Ue), i = y(() => e.fallbackContentRenderer || He);
902
- return It({
949
+ de(e.store);
950
+ const n = x(() => (e.boxRendererMatches || []).concat(He).sort((o, l) => (o.priority ?? 0) - (l.priority ?? 0))), s = x(() => (e.contentRendererMatches || []).concat(Ke).sort((o, l) => (o.priority ?? 0) - (l.priority ?? 0))), a = x(() => e.fallbackBoxRenderer || Ge), i = x(() => e.fallbackContentRenderer || Ye);
951
+ return At({
903
952
  boxRendererMatches: n,
904
953
  boxAttributes: () => e.boxAttributes,
905
- fallbackBoxRenderer: r
906
- }), Lt({
907
- contentRendererMatches: o,
954
+ fallbackBoxRenderer: a
955
+ }), $t({
956
+ contentRendererMatches: s,
908
957
  contentAttributes: () => e.contentAttributes,
909
958
  fallbackContentRenderer: i
910
- }), (s, a) => E(s.$slots, "default");
959
+ }), (o, l) => C(o.$slots, "default");
911
960
  }
912
- }), Vt = ["innerHTML"], Xt = /* @__PURE__ */ S({
961
+ }), Xt = ["innerHTML"], qt = /* @__PURE__ */ I({
913
962
  __name: "Markdown",
914
963
  props: {
915
964
  message: {},
916
965
  contentIndex: {}
917
966
  },
918
967
  setup(t) {
919
- const e = t, { contentText: n } = ie(e), o = L(null);
920
- ve(async () => {
921
- o.value = await Ft();
968
+ const e = t, { contentText: n } = fe(e), s = L(null);
969
+ xe(async () => {
970
+ s.value = await Dt();
922
971
  });
923
- const { mdConfig: r, dompurifyConfig: i } = ue(), s = L("");
924
- return q(() => {
925
- if (o.value) {
926
- const { markdown: a, dompurify: u } = o.value, b = a(r || {}).render(n.value);
927
- s.value = u.sanitize(b, i);
972
+ const { mdConfig: a, dompurifyConfig: i } = be(), o = L("");
973
+ return Z(() => {
974
+ if (s.value) {
975
+ const { markdown: l, dompurify: u } = s.value, f = l(a || {}).render(n.value);
976
+ o.value = u.sanitize(f, i);
928
977
  }
929
- }), (a, u) => s.value ? (g(), C("div", {
978
+ }), (l, u) => o.value ? (v(), E("div", {
930
979
  key: 0,
931
980
  class: "tr-bubble__markdown markdown-body",
932
981
  "data-type": "markdown",
933
- innerHTML: s.value
934
- }, null, 8, Vt)) : (g(), T(ae, P($({ key: 1 }, e)), null, 16));
982
+ innerHTML: o.value
983
+ }, null, 8, Xt)) : (v(), A(ce, D(O({ key: 1 }, e)), null, 16));
935
984
  }
936
- }), qt = /* @__PURE__ */ N(Xt, [["__scopeId", "data-v-eb1c196f"]]), rn = {
937
- Box: re,
938
- Image: Me,
939
- Loading: $e,
940
- Markdown: qt,
941
- Reasoning: Oe,
942
- Text: ae,
943
- Tool: we,
944
- ToolRole: Ne,
945
- Tools: Fe
985
+ }), Zt = /* @__PURE__ */ N(qt, [["__scopeId", "data-v-eb1c196f"]]), ln = {
986
+ Box: le,
987
+ Image: Ne,
988
+ Loading: we,
989
+ Markdown: Zt,
990
+ Reasoning: Fe,
991
+ Text: ce,
992
+ Tool: De,
993
+ ToolRole: Pe,
994
+ Tools: Ue
946
995
  };
947
- G.name = "TrBubble";
948
- const Zt = function(t) {
949
- t.component(G.name, G);
950
- };
951
- G.install = Zt;
952
- const an = G;
953
- V.name = "TrBubbleList";
996
+ Y.name = "TrBubble";
954
997
  const Qt = function(t) {
955
- t.component(V.name, V);
998
+ t.component(Y.name, Y);
956
999
  };
957
- V.install = Qt;
958
- const ln = V;
959
- X.name = "TrBubbleProvider";
1000
+ Y.install = Qt;
1001
+ const cn = Y;
1002
+ X.name = "TrBubbleList";
960
1003
  const en = function(t) {
961
1004
  t.component(X.name, X);
962
1005
  };
963
1006
  X.install = en;
964
- const cn = X;
1007
+ const un = X;
1008
+ q.name = "TrBubbleProvider";
1009
+ const tn = function(t) {
1010
+ t.component(q.name, q);
1011
+ };
1012
+ q.install = tn;
1013
+ const dn = q;
965
1014
  export {
966
- an as B,
967
- ln as a,
968
- cn as b,
969
- H as c,
970
- rn as d,
971
- At as e,
972
- le as f,
973
- Ke as g,
974
- ie as h,
975
- Ye as i,
976
- Pt as j,
977
- jt as u
1015
+ cn as B,
1016
+ un as a,
1017
+ dn as b,
1018
+ K as c,
1019
+ ln as d,
1020
+ Lt as e,
1021
+ ue as f,
1022
+ ie as g,
1023
+ an as h,
1024
+ fe as i,
1025
+ je as j,
1026
+ Ut as k,
1027
+ ot as u
978
1028
  };