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