@opentiny/tiny-robot 0.5.2-alpha.0 → 0.5.2-alpha.3

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,19 +1,19 @@
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
- import { _ as N } from "./_plugin-vue_export-helper.js";
1
+ import { ref as M, watch as U, toValue as k, onMounted as xe, onUnmounted as We, nextTick as te, defineComponent as I, openBlock as v, createElementBlock as E, renderSlot as C, computed as x, unref as R, normalizeClass as G, createVNode as V, onBeforeUnmount as Ve, Fragment as D, createElementVNode as B, mergeProps as w, toDisplayString as z, withDirectives as Q, vShow as ee, createBlock as A, resolveDynamicComponent as J, normalizeProps as P, guardReactiveProps as H, createCommentVNode as ae, watchEffect as ne, useCssModule as ze, renderList as W, markRaw as F, inject as T, provide as L, reactive as Xe, readonly as qe, withCtx as $ } from "vue";
2
+ import { _ as O } from "./_plugin-vue_export-helper.js";
3
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";
4
+ import { l as tt, w as nt, g as ot, a as st } from "./index4.js";
5
5
  function _e(t, e) {
6
- const n = U(t, (s, l) => {
7
- l === !0 && s === !1 && (e(), n());
6
+ const n = U(t, (o, l) => {
7
+ l === !0 && o === !1 && (e(), n());
8
8
  });
9
9
  return n;
10
10
  }
11
11
  function rt(t, e, n) {
12
- const { scrollOnMount: s = !0, bottomThreshold: l = 20, scrollThrottle: i = 0 } = n ?? {}, r = M(!0);
12
+ const { scrollOnMount: o = !0, bottomThreshold: l = 20, scrollThrottle: i = 0 } = n ?? {}, r = M(!0);
13
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") => {
14
+ const u = /* @__PURE__ */ new Set(), p = () => st(t), { y: _, isScrolling: h, arrivedState: y } = tt(p, { throttle: i }), m = (s) => s.scrollHeight - s.scrollTop - s.clientHeight <= l, c = async (s = "auto") => {
15
15
  const d = k(p);
16
- if (d && (await te(), d.scrollTo({ top: d.scrollHeight, behavior: o }), o === "smooth" && !m(d))) {
16
+ if (d && (await te(), d.scrollTo({ top: d.scrollHeight, behavior: s }), s === "smooth" && !m(d))) {
17
17
  const g = _e(h, () => {
18
18
  d.scrollTo({ top: d.scrollHeight, behavior: "auto" }), u.delete(g);
19
19
  });
@@ -27,8 +27,8 @@ function rt(t, e, n) {
27
27
  return U(
28
28
  _,
29
29
  () => {
30
- const o = k(p);
31
- o && (r.value = m(o));
30
+ const s = k(p);
31
+ s && (r.value = m(s));
32
32
  },
33
33
  { flush: "post" }
34
34
  ), nt(
@@ -38,13 +38,13 @@ function rt(t, e, n) {
38
38
  },
39
39
  { flush: "post", throttle: 100 }
40
40
  ), xe(() => {
41
- s && c("smooth");
41
+ o && c("smooth");
42
42
  }), We(() => {
43
- u.forEach((o) => {
44
- o();
43
+ u.forEach((s) => {
44
+ s();
45
45
  }), u.clear();
46
- }), st("keydown", (o) => {
47
- if (o.key === "End" && !r.value) {
46
+ }), ot("keydown", (s) => {
47
+ if (s.key === "End" && !r.value) {
48
48
  const d = _e(h, () => {
49
49
  c("auto"), u.delete(d);
50
50
  });
@@ -61,7 +61,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
61
61
  "bubble-content-fallback-renderer"
62
62
  ), Me = Symbol("bubble-content-attributes"), Le = Symbol(
63
63
  "bubble-content-prop-fallback-renderer"
64
- ), re = Symbol("bubble-store"), $e = Symbol("bubble-event-fn"), Oe = Symbol("bubble-list-context"), K = {
64
+ ), re = Symbol("bubble-store"), $e = Symbol("bubble-event-fn"), we = Symbol("bubble-list-context"), K = {
65
65
  LOADING: -1,
66
66
  NORMAL: 0,
67
67
  CONTENT: 10,
@@ -80,21 +80,21 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
80
80
  C(e.$slots, "default", {}, void 0, !0)
81
81
  ]));
82
82
  }
83
- }), le = /* @__PURE__ */ N(lt, [["__scopeId", "data-v-98101726"]]), ct = ["src", "alt"], ut = /* @__PURE__ */ I({
83
+ }), le = /* @__PURE__ */ O(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 = 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);
90
+ const e = t, n = M(!1), o = M(!1), { content: l } = fe(e), i = x(() => l.value ? typeof l.value.image_url == "string" ? l.value.image_url : l.value.image_url.url : null);
91
91
  U(i, () => {
92
- n.value = !1, s.value = !1;
92
+ n.value = !1, o.value = !1;
93
93
  });
94
94
  const r = () => {
95
- n.value = !0, s.value = !1;
95
+ n.value = !0, o.value = !1;
96
96
  }, a = () => {
97
- s.value = !0, n.value = !0;
97
+ o.value = !0, n.value = !0;
98
98
  };
99
99
  return (u, p) => {
100
100
  var _;
@@ -109,7 +109,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
109
109
  }, null, 42, ct);
110
110
  };
111
111
  }
112
- }), Ne = /* @__PURE__ */ N(ut, [["__scopeId", "data-v-e59794cb"]]), it = {
112
+ }), Oe = /* @__PURE__ */ O(ut, [["__scopeId", "data-v-e59794cb"]]), it = {
113
113
  class: "tr-bubble__loading",
114
114
  "data-type": "loading"
115
115
  }, dt = /* @__PURE__ */ I({
@@ -123,7 +123,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
123
123
  V(R(Be))
124
124
  ]));
125
125
  }
126
- }), we = /* @__PURE__ */ N(dt, [["__scopeId", "data-v-bc1b5ff4"]]), bt = { class: "title" }, ft = { class: "detail" }, pt = /* @__PURE__ */ I({
126
+ }), Ne = /* @__PURE__ */ O(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,12 +131,16 @@ 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"]), l = ue(n, e.contentIndex), i = M(!0), r = M(e.message.reasoning_content ?? ""), a = M(null);
134
+ const e = t, { restMessage: n, restProps: o } = je(e, ["reasoning_content"]), l = ue(n, e.contentIndex), i = M(!0), r = M(e.message.reasoning_content ?? ""), a = M(null);
135
135
  let u = null;
136
136
  const p = () => {
137
137
  !i.value || !a.value || (a.value.scrollTop = a.value.scrollHeight);
138
138
  }, _ = () => {
139
- u === null && (u = requestAnimationFrame(() => {
139
+ if (typeof window > "u" || typeof window.requestAnimationFrame != "function") {
140
+ r.value = e.message.reasoning_content ?? "";
141
+ return;
142
+ }
143
+ u === null && (u = window.requestAnimationFrame(() => {
140
144
  u = null, r.value = e.message.reasoning_content ?? "", te(p);
141
145
  }));
142
146
  };
@@ -160,11 +164,11 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
160
164
  });
161
165
  };
162
166
  return Ve(() => {
163
- u !== null && cancelAnimationFrame(u);
167
+ u !== null && typeof window < "u" && (window.cancelAnimationFrame(u), u = null);
164
168
  }), (m, c) => {
165
- var f, o;
169
+ var f, s;
166
170
  return v(), E(D, null, [
167
- B("div", O({
171
+ B("div", w({
168
172
  class: "tr-bubble__reasoning",
169
173
  "data-type": "reasoning"
170
174
  }, m.$attrs), [
@@ -176,7 +180,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
176
180
  class: G(["icon-and-text", { thinking: (f = e.message.state) == null ? void 0 : f.thinking }])
177
181
  }, [
178
182
  V(R(Ze)),
179
- B("span", bt, z((o = e.message.state) != null && o.thinking ? "正在思考" : "已思考"), 1)
183
+ B("span", bt, z((s = e.message.state) != null && s.thinking ? "正在思考" : "已思考"), 1)
180
184
  ], 2),
181
185
  V(R(Re), {
182
186
  class: G(["expand-icon", { "-rotate-90": !i.value }])
@@ -198,11 +202,11 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
198
202
  [ee, i.value]
199
203
  ])
200
204
  ], 16),
201
- (v(), A(J(R(l).renderer), P(H({ ...R(l).attributes, ...R(s) })), null, 16))
205
+ (v(), A(J(R(l).renderer), P(H({ ...R(l).attributes, ...R(o) })), null, 16))
202
206
  ], 64);
203
207
  };
204
208
  }
205
- }), Fe = /* @__PURE__ */ N(pt, [["__scopeId", "data-v-cb375d8c"]]), mt = {
209
+ }), Fe = /* @__PURE__ */ O(pt, [["__scopeId", "data-v-4e9abfba"]]), mt = {
206
210
  key: 0,
207
211
  class: "tr-bubble__text",
208
212
  "data-type": "text"
@@ -214,9 +218,9 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
214
218
  },
215
219
  setup(t) {
216
220
  const e = t, { contentText: n } = fe(e);
217
- return (s, l) => R(n) ? (v(), E("p", mt, z(R(n)), 1)) : ae("", !0);
221
+ return (o, l) => R(n) ? (v(), E("p", mt, z(R(n)), 1)) : ae("", !0);
218
222
  }
219
- }), ce = /* @__PURE__ */ N(_t, [["__scopeId", "data-v-93592ecb"]]), De = /* @__PURE__ */ I({
223
+ }), ce = /* @__PURE__ */ O(_t, [["__scopeId", "data-v-93592ecb"]]), De = /* @__PURE__ */ I({
220
224
  __name: "ToolRole",
221
225
  props: {
222
226
  message: {},
@@ -226,7 +230,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
226
230
  const e = t, n = be();
227
231
  return ne(() => {
228
232
  e.message.tool_call_id && (n.toolCallResults || (n.toolCallResults = {}), n.toolCallResults[e.message.tool_call_id] = e.message.content ?? "");
229
- }), (s, l) => ae("", !0);
233
+ }), (o, l) => ae("", !0);
230
234
  }
231
235
  }), gt = {
232
236
  class: "tr-bubble__tool-call",
@@ -239,7 +243,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
239
243
  toolCallIndex: {}
240
244
  },
241
245
  setup(t) {
242
- const e = t, { toolCall: n, toolCallWithResult: s, state: l } = Ht(e), i = /* @__PURE__ */ new Map([
246
+ const e = t, { toolCall: n, toolCallWithResult: o, state: l } = Ht(e), i = /* @__PURE__ */ new Map([
243
247
  ["running", { text: "正在调用", icon: Be }],
244
248
  ["success", { text: "已调用", icon: me }],
245
249
  ["failed", { text: "调用失败", icon: Qe }],
@@ -265,7 +269,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
265
269
  return /^"/.test(b) ? S = /:$/.test(b) ? "key" : "string" : /true|false/.test(b) ? S = "boolean" : /null/.test(b) && (S = "null"), `<span class="${u[S]}">${b}</span>`;
266
270
  }
267
271
  ), g;
268
- }, h = x(() => a(s.value, 2)), y = x(() => _(h.value)), m = M(null);
272
+ }, h = x(() => a(o.value, 2)), y = x(() => _(h.value)), m = M(null);
269
273
  U(h, (d, g) => {
270
274
  g === "" || g === "{}" || te(() => {
271
275
  m.value && m.value.scrollTo({
@@ -278,7 +282,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
278
282
  ne(() => {
279
283
  c.value = l.value.open ?? !1;
280
284
  });
281
- const f = ie(), o = () => {
285
+ const f = ie(), s = () => {
282
286
  var g, b;
283
287
  c.value = !c.value;
284
288
  const d = (g = n.value) == null ? void 0 : g.id;
@@ -309,7 +313,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
309
313
  B("div", xt, [
310
314
  V(R(Re), {
311
315
  class: G(["expand-icon", { "-rotate-90": !c.value }]),
312
- onClick: o
316
+ onClick: s
313
317
  }, null, 8, ["class"])
314
318
  ])
315
319
  ]),
@@ -335,7 +339,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
335
339
  null: "_null_1b448_18"
336
340
  }, At = {
337
341
  $style: Tt
338
- }, Pe = /* @__PURE__ */ N(Et, [["__cssModules", At], ["__scopeId", "data-v-00014a8b"]]), Ue = /* @__PURE__ */ I({
342
+ }, Pe = /* @__PURE__ */ O(Et, [["__cssModules", At], ["__scopeId", "data-v-00014a8b"]]), Ue = /* @__PURE__ */ I({
339
343
  inheritAttrs: !1,
340
344
  __name: "Tools",
341
345
  props: {
@@ -343,11 +347,11 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
343
347
  contentIndex: {}
344
348
  },
345
349
  setup(t) {
346
- const e = t, { restMessage: n, restProps: s } = je(e, ["tool_calls"]), l = ue(n, e.contentIndex);
350
+ const e = t, { restMessage: n, restProps: o } = je(e, ["tool_calls"]), l = ue(n, e.contentIndex);
347
351
  return (i, r) => (v(), E(D, null, [
348
- (v(), A(J(R(l).renderer), P(H({ ...R(l).attributes, ...R(s) })), null, 16)),
349
- B("div", O({ class: "tr-bubble__tools" }, i.$attrs), [
350
- (v(!0), E(D, null, W(e.message.tool_calls, (a, u) => (v(), A(Pe, O({
352
+ (v(), A(J(R(l).renderer), P(H({ ...R(l).attributes, ...R(o) })), null, 16)),
353
+ B("div", w({ class: "tr-bubble__tools" }, i.$attrs), [
354
+ (v(!0), E(D, null, W(e.message.tool_calls, (a, u) => (v(), A(Pe, w({
351
355
  key: a.id
352
356
  }, { ref_for: !0 }, e, { "tool-call-index": u }), null, 16, ["tool-call-index"]))), 128))
353
357
  ], 16)
@@ -363,7 +367,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
363
367
  ], Ke = [
364
368
  {
365
369
  find: (t) => !!t.loading,
366
- renderer: F(we),
370
+ renderer: F(Ne),
367
371
  priority: K.LOADING
368
372
  },
369
373
  {
@@ -378,7 +382,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
378
382
  },
379
383
  {
380
384
  find: (t, e) => e.type === "image_url",
381
- renderer: F(Ne),
385
+ renderer: F(Oe),
382
386
  priority: K.CONTENT
383
387
  },
384
388
  {
@@ -386,7 +390,7 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
386
390
  renderer: F(De),
387
391
  priority: K.ROLE
388
392
  }
389
- ], Ge = F(le), Ye = F(ce), ge = Symbol("BUBBLE_CONTENT_RESOLVER_KEY"), se = (t) => {
393
+ ], Ge = F(le), Ye = F(ce), ge = Symbol("BUBBLE_CONTENT_RESOLVER_KEY"), oe = (t) => {
390
394
  const e = T(ge, void 0), n = e ?? t;
391
395
  return !e && t && L(ge, t), n ? (l) => {
392
396
  const i = k(n);
@@ -394,15 +398,15 @@ const Ee = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
394
398
  } : (l) => l.content;
395
399
  };
396
400
  function Mt(t) {
397
- const { boxRendererMatches: e, boxAttributes: n, fallbackBoxRenderer: s } = t;
398
- e && L(Ce, e), n && L(Ie, n), s && L(ke, s);
401
+ const { boxRendererMatches: e, boxAttributes: n, fallbackBoxRenderer: o } = t;
402
+ e && L(Ce, e), n && L(Ie, n), o && L(ke, o);
399
403
  }
400
404
  function Lt(t) {
401
405
  const { fallbackBoxRenderer: e } = t;
402
406
  e && L(Se, e);
403
407
  }
404
408
  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();
409
+ const n = T(Ce, He), o = T(Ie, void 0), l = T(ke, void 0), i = T(Se, void 0), r = oe();
406
410
  if (typeof e == "number" && k(t).length !== 1)
407
411
  throw new Error("[BubbleBoxRenderer] When contentIndex is a number, messages array length must be 1");
408
412
  const a = (p) => {
@@ -416,7 +420,7 @@ function $t(t, e) {
416
420
  }, u = (p, _, h, y) => typeof p.attributes == "function" ? p.attributes(_, h, y) : p.attributes;
417
421
  return x(() => {
418
422
  const p = k(t), { content: _, index: h } = a(p), y = (() => {
419
- const c = k(s);
423
+ const c = k(o);
420
424
  if (c)
421
425
  return typeof c == "function" ? c(p, _, h) : c;
422
426
  })(), m = k(n).find((c) => c.find(p, _, h));
@@ -432,19 +436,19 @@ function $t(t, e) {
432
436
  };
433
437
  });
434
438
  }
435
- function Ot(t) {
436
- const { contentRendererMatches: e, contentAttributes: n, fallbackContentRenderer: s } = t;
437
- e && L(Te, e), n && L(Me, n), s && L(Ae, s);
439
+ function wt(t) {
440
+ const { contentRendererMatches: e, contentAttributes: n, fallbackContentRenderer: o } = t;
441
+ e && L(Te, e), n && L(Me, n), o && L(Ae, o);
438
442
  }
439
- function Nt(t) {
443
+ function Ot(t) {
440
444
  const { fallbackContentRenderer: e } = t;
441
445
  e && L(Le, e);
442
446
  }
443
447
  function ue(t, e) {
444
- const n = T(Te, Ke), s = T(Me, void 0), l = T(Ae, void 0), i = T(Le, void 0), r = se();
448
+ const n = T(Te, Ke), o = T(Me, void 0), l = T(Ae, void 0), i = T(Le, void 0), r = oe();
445
449
  return x(() => {
446
450
  const a = k(t), u = r(a), p = Array.isArray(u) ? u.at(e ?? 0) : { type: "text", text: u || "" }, _ = (() => {
447
- const y = k(s);
451
+ const y = k(o);
448
452
  if (y)
449
453
  return typeof y == "function" ? y(a, p, e) : y;
450
454
  })(), h = k(n).find((y) => y.find(a, p, e));
@@ -460,7 +464,7 @@ function ue(t, e) {
460
464
  };
461
465
  });
462
466
  }
463
- function wt(t) {
467
+ function Nt(t) {
464
468
  L($e, t);
465
469
  }
466
470
  function ie() {
@@ -490,7 +494,7 @@ function be() {
490
494
  function Je(t) {
491
495
  U(
492
496
  t,
493
- (e, n, s) => {
497
+ (e, n, o) => {
494
498
  if (!e) return;
495
499
  const l = (i) => {
496
500
  var u;
@@ -501,19 +505,19 @@ function Je(t) {
501
505
  `)) || "";
502
506
  (u = i.clipboardData) == null || u.setData("text/plain", a);
503
507
  };
504
- e.addEventListener("copy", l), s(() => e.removeEventListener("copy", l));
508
+ e.addEventListener("copy", l), o(() => e.removeEventListener("copy", l));
505
509
  },
506
510
  { immediate: !0, flush: "post" }
507
511
  );
508
512
  }
509
513
  const fe = (t) => {
510
- const e = se(), n = x(() => {
514
+ const e = oe(), n = x(() => {
511
515
  const l = e(t.message);
512
516
  return Array.isArray(l) ? l.at(t.contentIndex) : { type: "text", text: l || "" };
513
- }), s = x(() => n.value.type === "text" ? String(n.value.text) : "");
517
+ }), o = x(() => n.value.type === "text" ? String(n.value.text) : "");
514
518
  return {
515
519
  content: n,
516
- contentText: s
520
+ contentText: o
517
521
  };
518
522
  };
519
523
  function Ft(t) {
@@ -526,17 +530,17 @@ function je(t, e) {
526
530
  const n = x(() => {
527
531
  const l = Object.entries(t.message).filter(([i]) => !e.includes(i));
528
532
  return Object.fromEntries(l);
529
- }), s = x(() => ({
533
+ }), o = x(() => ({
530
534
  ...t,
531
535
  message: n.value
532
536
  }));
533
537
  return {
534
538
  restMessage: n,
535
- restProps: s
539
+ restProps: o
536
540
  };
537
541
  }
538
- let oe = null;
539
- const Pt = () => (oe || (oe = import("./index5.js")), oe);
542
+ let se = null;
543
+ const Pt = () => (se || (se = import("./index5.js")), se);
540
544
  let j = null;
541
545
  const Ut = async () => {
542
546
  if (j)
@@ -551,7 +555,7 @@ const Ut = async () => {
551
555
  const e = x(() => {
552
556
  var r, a;
553
557
  return (a = (r = t.message) == null ? void 0 : r.tool_calls) == null ? void 0 : a[t.toolCallIndex];
554
- }), n = be(), s = x(() => {
558
+ }), n = be(), o = x(() => {
555
559
  var _, h, y;
556
560
  let r = n.toolCallDefaultStatus;
557
561
  r && !ve.includes(r) && (r = void 0);
@@ -564,8 +568,8 @@ const Ut = async () => {
564
568
  if (p) {
565
569
  const m = (y = (h = t.message.state) == null ? void 0 : h.toolCall) == null ? void 0 : y[p];
566
570
  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 };
571
+ const { status: c, open: f, ...s } = m;
572
+ c && ve.includes(c) && (u.status = c), f !== void 0 && (u.open = f), u = { ...u, ...s };
569
573
  }
570
574
  }
571
575
  return u;
@@ -590,7 +594,7 @@ const Ut = async () => {
590
594
  }), {
591
595
  toolCall: e,
592
596
  toolCallWithResult: qe(i),
593
- state: s
597
+ state: o
594
598
  };
595
599
  }, he = /* @__PURE__ */ I({
596
600
  __name: "BubbleBoxWrapper",
@@ -603,13 +607,13 @@ const Ut = async () => {
603
607
  },
604
608
  setup(t) {
605
609
  const e = t, n = $t(() => e.messages, e.contentIndex);
606
- return (s, l) => (v(), A(J(R(n).renderer), O(R(n).attributes, {
610
+ return (o, l) => (v(), A(J(R(n).renderer), w(R(n).attributes, {
607
611
  "data-role": e.role,
608
612
  "data-placement": e.placement,
609
613
  "data-shape": e.shape
610
614
  }), {
611
615
  default: $(() => [
612
- C(s.$slots, "default")
616
+ C(o.$slots, "default")
613
617
  ]),
614
618
  _: 3
615
619
  }, 16, ["data-role", "data-placement", "data-shape"]));
@@ -622,12 +626,12 @@ const Ut = async () => {
622
626
  },
623
627
  emits: ["state-change", "bubble-event"],
624
628
  setup(t, { emit: e }) {
625
- const n = t, s = ue(() => n.message, n.contentIndex), l = x(() => ({
626
- ...s.value.attributes,
629
+ const n = t, o = ue(() => n.message, n.contentIndex), l = x(() => ({
630
+ ...o.value.attributes,
627
631
  message: n.message,
628
632
  contentIndex: n.contentIndex
629
633
  })), i = e;
630
- return wt((a) => {
634
+ return Nt((a) => {
631
635
  if (i("bubble-event", {
632
636
  ...a,
633
637
  contentIndex: n.contentIndex
@@ -641,7 +645,7 @@ const Ut = async () => {
641
645
  contentIndex: n.contentIndex
642
646
  });
643
647
  }
644
- }), (a, u) => (v(), A(J(R(s).renderer), P(H(l.value)), null, 16));
648
+ }), (a, u) => (v(), A(J(R(o).renderer), P(H(l.value)), null, 16));
645
649
  }
646
650
  }), Kt = ["data-role", "data-placement"], Gt = { class: "tr-bubble__body" }, Yt = { class: "tr-bubble__content" }, Jt = { class: "tr-bubble__after" }, jt = /* @__PURE__ */ I({
647
651
  __name: "Bubble",
@@ -666,27 +670,27 @@ const Ut = async () => {
666
670
  },
667
671
  emits: ["state-change", "bubble-event"],
668
672
  setup(t, { emit: e }) {
669
- const n = t, s = se(() => n.contentResolver), l = e;
673
+ const n = t, o = oe(() => n.contentResolver), l = e;
670
674
  de();
671
675
  const i = Dt(), r = x(() => k(i)), a = x(() => {
672
676
  var Z;
673
677
  if ((Z = r.value) != null && Z.messages.length)
674
678
  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 }];
679
+ const { role: m, content: c, reasoning_content: f, tool_calls: s, tool_call_id: d, name: g, id: b, loading: S, state: N } = n;
680
+ return [{ role: m, content: c, reasoning_content: f, tool_calls: s, tool_call_id: d, name: g, id: b, loading: S, state: N }];
677
681
  }), u = (m) => {
678
- const c = s(m);
682
+ const c = o(m);
679
683
  return Array.isArray(c) ? c : [{ type: "text", text: c || "" }];
680
684
  };
681
- Lt({ fallbackBoxRenderer: () => n.fallbackBoxRenderer }), Nt({ fallbackContentRenderer: () => n.fallbackContentRenderer });
685
+ Lt({ fallbackBoxRenderer: () => n.fallbackBoxRenderer }), Ot({ fallbackContentRenderer: () => n.fallbackContentRenderer });
682
686
  const p = x(() => a.value.length === 0 ? !0 : n.hidden), _ = x(() => {
683
687
  if (n.contentRenderMode === "split" && a.value.length === 1) {
684
- const m = s(a.value.at(0));
688
+ const m = o(a.value.at(0));
685
689
  if (Array.isArray(m))
686
690
  return m;
687
691
  }
688
692
  return null;
689
- }), h = T(Oe, !1), y = M(null);
693
+ }), h = T(we, !1), y = M(null);
690
694
  return h || Je(y), (m, c) => Q((v(), E("div", {
691
695
  class: "tr-bubble",
692
696
  ref_key: "bubbleRef",
@@ -704,26 +708,26 @@ const Ut = async () => {
704
708
  class: G(["tr-bubble__avatar", m.$style["tr-bubble__avatar"]])
705
709
  }, null, 8, ["class"])) : ae("", !0),
706
710
  B("div", Yt, [
707
- _.value ? (v(!0), E(D, { key: 0 }, W(_.value, (f, o) => (v(), A(he, {
708
- key: o,
711
+ _.value ? (v(!0), E(D, { key: 0 }, W(_.value, (f, s) => (v(), A(he, {
712
+ key: s,
709
713
  class: "tr-bubble__box",
710
714
  role: n.role,
711
715
  placement: n.placement,
712
716
  shape: n.shape,
713
717
  messages: a.value,
714
- "content-index": o
718
+ "content-index": s
715
719
  }, {
716
720
  default: $(() => [
717
721
  V(ye, {
718
722
  message: a.value.at(0),
719
- "content-index": o,
723
+ "content-index": s,
720
724
  onStateChange: c[0] || (c[0] = (d) => l("state-change", { ...d, messageIndex: 0 })),
721
725
  onBubbleEvent: c[1] || (c[1] = (d) => l("bubble-event", { ...d, messageIndex: 0 }))
722
726
  }, null, 8, ["message", "content-index"]),
723
727
  C(m.$slots, "content-footer", {
724
728
  messages: a.value,
725
729
  role: n.role,
726
- contentIndex: o
730
+ contentIndex: s
727
731
  }, void 0, !0)
728
732
  ]),
729
733
  _: 2
@@ -735,15 +739,15 @@ const Ut = async () => {
735
739
  messages: a.value
736
740
  }, {
737
741
  default: $(() => [
738
- (v(!0), E(D, null, W(a.value, (f, o) => (v(), E(D, {
739
- key: `message-${o}`
742
+ (v(!0), E(D, null, W(a.value, (f, s) => (v(), E(D, {
743
+ key: `message-${s}`
740
744
  }, [
741
745
  (v(!0), E(D, null, W(u(f), (d, g) => (v(), A(ye, {
742
746
  key: `content-${g}`,
743
747
  message: f,
744
748
  "content-index": g,
745
- onStateChange: (b) => l("state-change", { ...b, messageIndex: o }),
746
- onBubbleEvent: (b) => l("bubble-event", { ...b, messageIndex: o })
749
+ onStateChange: (b) => l("state-change", { ...b, messageIndex: s }),
750
+ onBubbleEvent: (b) => l("bubble-event", { ...b, messageIndex: s })
747
751
  }, null, 8, ["message", "content-index", "onStateChange", "onBubbleEvent"]))), 128))
748
752
  ], 64))), 128)),
749
753
  C(m.$slots, "content-footer", {
@@ -773,7 +777,7 @@ const Ut = async () => {
773
777
  "tr-bubble__avatar": "_tr-bubble__avatar_1r87c_2"
774
778
  }, Vt = {
775
779
  $style: Wt
776
- }, Y = /* @__PURE__ */ N(jt, [["__cssModules", Vt], ["__scopeId", "data-v-d68ceaad"]]), zt = /* @__PURE__ */ I({
780
+ }, Y = /* @__PURE__ */ O(jt, [["__cssModules", Vt], ["__scopeId", "data-v-d68ceaad"]]), zt = /* @__PURE__ */ I({
777
781
  __name: "BubbleItem",
778
782
  props: {
779
783
  messageGroup: {},
@@ -783,13 +787,13 @@ const Ut = async () => {
783
787
  },
784
788
  emits: ["state-change", "bubble-event"],
785
789
  setup(t, { emit: e }) {
786
- const n = t, s = e;
787
- return Ft(() => n.messageGroup), (l, i) => (v(), A(Y, O(t.roleConfig, {
790
+ const n = t, o = e;
791
+ return Ft(() => n.messageGroup), (l, i) => (v(), A(Y, w(t.roleConfig, {
788
792
  role: t.messageGroup.role,
789
793
  "content-render-mode": t.contentRenderMode,
790
794
  "content-resolver": t.contentResolver,
791
- onStateChange: i[0] || (i[0] = (r) => s("state-change", r)),
792
- onBubbleEvent: i[1] || (i[1] = (r) => s("bubble-event", r))
795
+ onStateChange: i[0] || (i[0] = (r) => o("state-change", r)),
796
+ onBubbleEvent: i[1] || (i[1] = (r) => o("bubble-event", r))
793
797
  }), {
794
798
  prefix: $((r) => [
795
799
  C(l.$slots, "prefix", P(H(r)))
@@ -820,64 +824,64 @@ const Ut = async () => {
820
824
  },
821
825
  emits: ["state-change", "bubble-event"],
822
826
  setup(t, { expose: e, emit: n }) {
823
- const s = t, l = n;
824
- de(), L(Oe, !0);
827
+ const o = t, l = n;
828
+ de(), L(we, !0);
825
829
  const i = (c) => {
826
- var f, o;
827
- return c ? !!((o = (f = s.roleConfigs) == null ? void 0 : f[c]) != null && o.hidden) : !1;
830
+ var f, s;
831
+ return c ? !!((s = (f = o.roleConfigs) == null ? void 0 : f[c]) != null && s.hidden) : !1;
828
832
  }, r = M(null);
829
833
  let a = async () => {
830
834
  };
831
- if (s.autoScroll) {
832
- const c = x(() => s.messages.at(-1)), { scrollToBottom: f } = rt(r, () => {
833
- var o, d;
835
+ if (o.autoScroll) {
836
+ const c = x(() => o.messages.at(-1)), { scrollToBottom: f } = rt(r, () => {
837
+ var s, d;
834
838
  return [
835
- s.messages.length,
836
- (o = c.value) == null ? void 0 : o.content,
839
+ o.messages.length,
840
+ (s = c.value) == null ? void 0 : s.content,
837
841
  (d = c.value) == null ? void 0 : d.reasoning_content
838
842
  ];
839
843
  });
840
844
  a = f, U(
841
845
  () => {
842
- var o;
843
- return (o = c.value) == null ? void 0 : o.role;
846
+ var s;
847
+ return (s = c.value) == null ? void 0 : s.role;
844
848
  },
845
- async (o) => {
846
- o === "user" && (await te(), f("smooth"));
849
+ async (s) => {
850
+ s === "user" && (await te(), f("smooth"));
847
851
  }
848
852
  );
849
853
  }
850
854
  Je(r);
851
855
  const u = (c) => {
852
856
  const f = [];
853
- let o = !1;
857
+ let s = !1;
854
858
  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({
859
+ const b = f[f.length - 1], S = g.role || "", N = i(g.role);
860
+ b && (s && N || b.role === S && s === N) ? (b.messages.push(g), b.messageIndexes.push(d)) : f.push({
857
861
  role: S,
858
862
  messages: [g],
859
863
  messageIndexes: [d]
860
- }), o = w;
864
+ }), s = N;
861
865
  }
862
866
  return f;
863
867
  }, p = (c, f) => {
864
- const o = [];
868
+ const s = [];
865
869
  let d = !1;
866
870
  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);
871
+ const S = s[s.length - 1], N = b.role === f, Z = b.role || "", pe = i(b.role);
868
872
  S && // divider 消息(分割角色)永远不与任何组进行合并
869
- !w && // divider 组(分割角色)不允许被追加消息,确保 divider 组永远只有 1 条 message
873
+ !N && // divider 组(分割角色)不允许被追加消息,确保 divider 组永远只有 1 条 message
870
874
  S.role !== f && // hidden / 非 hidden 分组隔离
871
- d === pe ? (S.messages.push(b), S.messageIndexes.push(g)) : o.push({
872
- role: w ? f : Z,
875
+ d === pe ? (S.messages.push(b), S.messageIndexes.push(g)) : s.push({
876
+ role: N ? f : Z,
873
877
  messages: [b],
874
878
  messageIndexes: [g]
875
879
  }), d = pe;
876
880
  }
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) {
881
+ return s;
882
+ }, _ = x(() => o.messages.length === 0 ? [] : typeof o.groupStrategy == "function" ? o.groupStrategy(o.messages, o.dividerRole) : o.groupStrategy === "consecutive" ? u(o.messages) : p(o.messages, o.dividerRole)), h = (c, f) => {
883
+ const s = c.messageIndexes[f];
884
+ if (s === void 0) {
881
885
  console.warn(
882
886
  "[BubbleList] Missing messageIndexes mapping; event was not emitted. Ensure custom groupStrategy returns messageIndexes aligned with messages.",
883
887
  {
@@ -887,13 +891,13 @@ const Ut = async () => {
887
891
  );
888
892
  return;
889
893
  }
890
- return o;
894
+ return s;
891
895
  }, y = (c, f) => {
892
- const o = h(c, f.messageIndex);
893
- o !== void 0 && l("state-change", { ...f, messageIndex: o });
896
+ const s = h(c, f.messageIndex);
897
+ s !== void 0 && l("state-change", { ...f, messageIndex: s });
894
898
  }, m = (c, f) => {
895
- const o = h(c, f.messageIndex);
896
- o !== void 0 && l("bubble-event", { ...f, messageIndex: o });
899
+ const s = h(c, f.messageIndex);
900
+ s !== void 0 && l("bubble-event", { ...f, messageIndex: s });
897
901
  };
898
902
  return e({
899
903
  scrollToBottom: a
@@ -902,36 +906,36 @@ const Ut = async () => {
902
906
  ref_key: "listRef",
903
907
  ref: r
904
908
  }, [
905
- (v(!0), E(D, null, W(_.value, (o, d) => {
909
+ (v(!0), E(D, null, W(_.value, (s, d) => {
906
910
  var g;
907
911
  return v(), A(zt, {
908
912
  key: d,
909
- role: o.role || s.fallbackRole,
910
- "role-config": (g = s.roleConfigs) == null ? void 0 : g[o.role || s.fallbackRole],
911
- "message-group": o,
912
- "content-render-mode": s.contentRenderMode,
913
- "content-resolver": s.contentResolver,
914
- onStateChange: (b) => y(o, b),
915
- onBubbleEvent: (b) => m(o, b)
913
+ role: s.role || o.fallbackRole,
914
+ "role-config": (g = o.roleConfigs) == null ? void 0 : g[s.role || o.fallbackRole],
915
+ "message-group": s,
916
+ "content-render-mode": o.contentRenderMode,
917
+ "content-resolver": o.contentResolver,
918
+ onStateChange: (b) => y(s, b),
919
+ onBubbleEvent: (b) => m(s, b)
916
920
  }, {
917
921
  prefix: $((b) => [
918
- C(c.$slots, "prefix", O({ ref_for: !0 }, b, {
919
- messageIndexes: o.messageIndexes
922
+ C(c.$slots, "prefix", w({ ref_for: !0 }, b, {
923
+ messageIndexes: s.messageIndexes
920
924
  }), void 0, !0)
921
925
  ]),
922
926
  suffix: $((b) => [
923
- C(c.$slots, "suffix", O({ ref_for: !0 }, b, {
924
- messageIndexes: o.messageIndexes
927
+ C(c.$slots, "suffix", w({ ref_for: !0 }, b, {
928
+ messageIndexes: s.messageIndexes
925
929
  }), void 0, !0)
926
930
  ]),
927
931
  "content-footer": $((b) => [
928
- C(c.$slots, "content-footer", O({ ref_for: !0 }, b, {
929
- messageIndexes: o.messageIndexes
932
+ C(c.$slots, "content-footer", w({ ref_for: !0 }, b, {
933
+ messageIndexes: s.messageIndexes
930
934
  }), void 0, !0)
931
935
  ]),
932
936
  after: $((b) => [
933
- C(c.$slots, "after", O({ ref_for: !0 }, b, {
934
- messageIndexes: o.messageIndexes
937
+ C(c.$slots, "after", w({ ref_for: !0 }, b, {
938
+ messageIndexes: s.messageIndexes
935
939
  }), void 0, !0)
936
940
  ]),
937
941
  _: 2
@@ -939,7 +943,7 @@ const Ut = async () => {
939
943
  }), 128))
940
944
  ], 512));
941
945
  }
942
- }), X = /* @__PURE__ */ N(Xt, [["__scopeId", "data-v-1d84cbfe"]]), q = /* @__PURE__ */ I({
946
+ }), X = /* @__PURE__ */ O(Xt, [["__scopeId", "data-v-1d84cbfe"]]), q = /* @__PURE__ */ I({
943
947
  __name: "BubbleProvider",
944
948
  props: {
945
949
  boxRendererMatches: {},
@@ -953,13 +957,13 @@ const Ut = async () => {
953
957
  setup(t) {
954
958
  const e = t;
955
959
  de(e.store);
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);
960
+ const n = x(() => (e.boxRendererMatches || []).concat(He).sort((r, a) => (r.priority ?? 0) - (a.priority ?? 0))), o = x(() => (e.contentRendererMatches || []).concat(Ke).sort((r, a) => (r.priority ?? 0) - (a.priority ?? 0))), l = x(() => e.fallbackBoxRenderer || Ge), i = x(() => e.fallbackContentRenderer || Ye);
957
961
  return Mt({
958
962
  boxRendererMatches: n,
959
963
  boxAttributes: () => e.boxAttributes,
960
964
  fallbackBoxRenderer: l
961
- }), Ot({
962
- contentRendererMatches: s,
965
+ }), wt({
966
+ contentRendererMatches: o,
963
967
  contentAttributes: () => e.contentAttributes,
964
968
  fallbackContentRenderer: i
965
969
  }), (r, a) => C(r.$slots, "default");
@@ -971,14 +975,14 @@ const Ut = async () => {
971
975
  contentIndex: {}
972
976
  },
973
977
  setup(t) {
974
- const e = t, { contentText: n } = fe(e), s = M(null);
978
+ const e = t, { contentText: n } = fe(e), o = M(null);
975
979
  xe(async () => {
976
- s.value = await Ut();
980
+ o.value = await Ut();
977
981
  });
978
982
  const { mdConfig: l, dompurifyConfig: i } = be(), r = M("");
979
983
  return ne(() => {
980
- if (s.value) {
981
- const { markdown: a, dompurify: u } = s.value, p = a(l || {}).render(n.value);
984
+ if (o.value) {
985
+ const { markdown: a, dompurify: u } = o.value, p = a(l || {}).render(n.value);
982
986
  r.value = u.sanitize(p, i);
983
987
  }
984
988
  }), (a, u) => r.value ? (v(), E("div", {
@@ -986,12 +990,12 @@ const Ut = async () => {
986
990
  class: "tr-bubble__markdown markdown-body",
987
991
  "data-type": "markdown",
988
992
  innerHTML: r.value
989
- }, null, 8, qt)) : (v(), A(ce, P(O({ key: 1 }, e)), null, 16));
993
+ }, null, 8, qt)) : (v(), A(ce, P(w({ key: 1 }, e)), null, 16));
990
994
  }
991
- }), Qt = /* @__PURE__ */ N(Zt, [["__scopeId", "data-v-eb1c196f"]]), cn = {
995
+ }), Qt = /* @__PURE__ */ O(Zt, [["__scopeId", "data-v-eb1c196f"]]), cn = {
992
996
  Box: le,
993
- Image: Ne,
994
- Loading: we,
997
+ Image: Oe,
998
+ Loading: Ne,
995
999
  Markdown: Qt,
996
1000
  Reasoning: Fe,
997
1001
  Text: ce,