@opentiny/tiny-robot 0.5.2-alpha.17 → 0.5.2-alpha.18

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