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