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