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