@opentiny/tiny-robot 0.4.2-alpha.0 → 0.4.2-alpha.2

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