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