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