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