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