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