@opentiny/tiny-robot 0.4.0-beta.0 → 0.4.0

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