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