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