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