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