@8wave/ai-elements 0.114.0-beta.30 → 0.114.0-beta.7
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/_chunks/Agent-DTLrWpzX.js +460 -0
- package/dist/_chunks/Agent-DTLrWpzX.js.map +1 -0
- package/dist/_chunks/Media-Cft7Pwrh.js +108 -0
- package/dist/_chunks/Media-Cft7Pwrh.js.map +1 -0
- package/dist/_chunks/{PkStreamingMarkdown-ZD0SROu1.js → PkStreamingMarkdown-C1sANAr5.js} +672 -688
- package/dist/_chunks/PkStreamingMarkdown-C1sANAr5.js.map +1 -0
- package/dist/_chunks/{PkToolRequestGeolocation-OF1PWhMw.js → PkToolRequestGeolocation-BbxYKt-9.js} +2 -2
- package/{dist-vue/_chunks/PkToolRequestGeolocation-BOVbaCzQ.js.map → dist/_chunks/PkToolRequestGeolocation-BbxYKt-9.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestOAuthConnection-ChGMAKV7.js → PkToolRequestOAuthConnection-CTp2w60F.js} +2 -2
- package/dist/_chunks/{PkToolRequestOAuthConnection-ChGMAKV7.js.map → PkToolRequestOAuthConnection-CTp2w60F.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-LEfO5zfg.js → PkToolShowArtifact-BfTjxGOT.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-LEfO5zfg.js.map → PkToolShowArtifact-BfTjxGOT.js.map} +1 -1
- package/dist/_chunks/PkToolShowComparison-BJ7QBXtf.js +60 -0
- package/dist/_chunks/PkToolShowComparison-BJ7QBXtf.js.map +1 -0
- package/dist/_chunks/{PkToolShowContactForm-BO3JQfts.js → PkToolShowContactForm-PFpY9dIp.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-BO3JQfts.js.map → PkToolShowContactForm-PFpY9dIp.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-KW8MOL-j.js → PkToolShowForm-CMtSN0oX.js} +5 -5
- package/dist/_chunks/{PkToolShowForm-KW8MOL-j.js.map → PkToolShowForm-CMtSN0oX.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-Bfx-Th_j.js → PkToolShowSources-C6cu66Ts.js} +3 -3
- package/dist/_chunks/{PkToolShowSources-Bfx-Th_j.js.map → PkToolShowSources-C6cu66Ts.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSuggestedReply-Dl4x_nEJ.js → PkToolShowSuggestedReply-CFO8wV1b.js} +2 -2
- package/dist/_chunks/{PkToolShowSuggestedReply-Dl4x_nEJ.js.map → PkToolShowSuggestedReply-CFO8wV1b.js.map} +1 -1
- package/dist/_chunks/{markdown-BL7WANiX.js → markdown-BRD-hDrH.js} +12 -19
- package/dist/_chunks/markdown-BRD-hDrH.js.map +1 -0
- package/dist/ai-elements.es.js +2767 -3035
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotAuth.js +1 -1
- package/dist-vue/PkChatbotEmptyState.js +1 -1
- package/dist-vue/PkChatbotInput.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotStepPayload.js +1 -1
- package/dist-vue/PkChatbotStepToolDetail.js +1 -1
- package/dist-vue/PkChatbotSteps.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/PkChatbotViewConversations.js +1 -1
- package/dist-vue/PkChatbotViewFiles.js +1 -1
- package/dist-vue/PkChatbotViewProfile.js +1 -1
- package/dist-vue/_chunks/{Agent-tbKw8Mdt.js → Agent-BNlmK-uJ.js} +2 -2
- package/dist-vue/_chunks/{Agent-tbKw8Mdt.js.map → Agent-BNlmK-uJ.js.map} +1 -1
- package/dist-vue/_chunks/{Document-nCWwJC2h.js → Document-2X01-F4Z.js} +11 -18
- package/dist-vue/_chunks/Document-2X01-F4Z.js.map +1 -0
- package/dist-vue/_chunks/Media-_HfFLHGD.js.map +1 -1
- package/dist-vue/_chunks/{PkChatbot-CXQzBuxy.js → PkChatbot-HRayDr2d.js} +8 -8
- package/dist-vue/_chunks/{PkChatbot-CXQzBuxy.js.map → PkChatbot-HRayDr2d.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotAuth-Bi508F1u.js +349 -0
- package/dist-vue/_chunks/PkChatbotAuth-Bi508F1u.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotEmptyState-9mWiPd4B.js → PkChatbotEmptyState-CPOcfoRC.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-9mWiPd4B.js.map → PkChatbotEmptyState-CPOcfoRC.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotInput-BzaCyeFp.js → PkChatbotInput-pLJQIu7v.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotInput-BzaCyeFp.js.map → PkChatbotInput-pLJQIu7v.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotMessages-KH5RE8Dk.js → PkChatbotMessages-GZStJbx_.js} +256 -258
- package/dist-vue/_chunks/PkChatbotMessages-GZStJbx_.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotStepPayload-C36nXLW7.js → PkChatbotStepPayload-DU0W-eUp.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-C36nXLW7.js.map → PkChatbotStepPayload-DU0W-eUp.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-CBX-AQXv.js → PkChatbotStepToolDetail-etlBryOg.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-CBX-AQXv.js.map → PkChatbotStepToolDetail-etlBryOg.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotSteps-Cl4pVtPJ.js +190 -0
- package/dist-vue/_chunks/PkChatbotSteps-Cl4pVtPJ.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotViewChat-D5sfTMCW.js → PkChatbotViewChat-DIfBWFoG.js} +7 -7
- package/dist-vue/_chunks/{PkChatbotViewChat-D5sfTMCW.js.map → PkChatbotViewChat-DIfBWFoG.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewConversations-CHpN4vhm.js → PkChatbotViewConversations-BCdolW0R.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewConversations-CHpN4vhm.js.map → PkChatbotViewConversations-BCdolW0R.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewFiles-Bk9-K6Hw.js → PkChatbotViewFiles-Cudao8ew.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewFiles-Bk9-K6Hw.js.map → PkChatbotViewFiles-Cudao8ew.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewProfile-CosaHA-g.js → PkChatbotViewProfile-DDsKOkcC.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-CosaHA-g.js.map → PkChatbotViewProfile-DDsKOkcC.js.map} +1 -1
- package/dist-vue/_chunks/{PkStreamingMarkdown-BN7waklD.js → PkStreamingMarkdown-BloMJaIW.js} +205 -214
- package/dist-vue/_chunks/{PkStreamingMarkdown-BN7waklD.js.map → PkStreamingMarkdown-BloMJaIW.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestGeolocation-BOVbaCzQ.js → PkToolRequestGeolocation-9vfYNaQo.js} +2 -2
- package/{dist/_chunks/PkToolRequestGeolocation-OF1PWhMw.js.map → dist-vue/_chunks/PkToolRequestGeolocation-9vfYNaQo.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-DMvCGPuX.js → PkToolRequestOAuthConnection-BorR5NmZ.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-DMvCGPuX.js.map → PkToolRequestOAuthConnection-BorR5NmZ.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowArtifact-DrE_mK1z.js → PkToolShowArtifact-BuMY7GNj.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-DrE_mK1z.js.map → PkToolShowArtifact-BuMY7GNj.js.map} +1 -1
- package/dist-vue/_chunks/PkToolShowComparison-BLn4pkno.js +61 -0
- package/dist-vue/_chunks/PkToolShowComparison-BLn4pkno.js.map +1 -0
- package/dist-vue/_chunks/{PkToolShowContactForm-BBTbrgt4.js → PkToolShowContactForm-0OQRqT8m.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-BBTbrgt4.js.map → PkToolShowContactForm-0OQRqT8m.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-CztnTdq2.js → PkToolShowDiagram-BGL27iHG.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-CztnTdq2.js.map → PkToolShowDiagram-BGL27iHG.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowEmail-C30K5kJA.js → PkToolShowEmail-BJJpS69F.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowEmail-C30K5kJA.js.map → PkToolShowEmail-BJJpS69F.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-C9N_SSm8.js → PkToolShowForm-DDcPpOZ8.js} +4 -4
- package/dist-vue/_chunks/{PkToolShowForm-C9N_SSm8.js.map → PkToolShowForm-DDcPpOZ8.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowMessage-DvkCRERv.js → PkToolShowMessage-BFGynf3p.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowMessage-DvkCRERv.js.map → PkToolShowMessage-BFGynf3p.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-cfjg3CmV.js → PkToolShowProductList-6t1Ir5CW.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-cfjg3CmV.js.map → PkToolShowProductList-6t1Ir5CW.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-CyR2GTiE.js → PkToolShowSources-cOF0ZxOj.js} +4 -4
- package/dist-vue/_chunks/{PkToolShowSources-CyR2GTiE.js.map → PkToolShowSources-cOF0ZxOj.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-qAWdCUhr.js → PkToolShowSuggestedReply-DA4NEjHB.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-qAWdCUhr.js.map → PkToolShowSuggestedReply-DA4NEjHB.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-CkQ2NhRj.js → PkToolShowWebPages-OgaT1vYJ.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-CkQ2NhRj.js.map → PkToolShowWebPages-OgaT1vYJ.js.map} +1 -1
- package/dist-vue/_chunks/{PkUrl-BsD4Vby6.js → PkUrl-Cd69XP5z.js} +2 -2
- package/dist-vue/_chunks/{PkUrl-BsD4Vby6.js.map → PkUrl-Cd69XP5z.js.map} +1 -1
- package/dist-vue/_chunks/{createChatbotApiClient-BlWs282E.js → createChatbotApiClient-CaVLm5W9.js} +168 -137
- package/dist-vue/_chunks/createChatbotApiClient-CaVLm5W9.js.map +1 -0
- package/dist-vue/_chunks/{useChatbotStore-CMo47fnS.js → useChatbotStore-BwrBZJCq.js} +3 -3
- package/dist-vue/_chunks/{useChatbotStore-CMo47fnS.js.map → useChatbotStore-BwrBZJCq.js.map} +1 -1
- package/dist-vue/_chunks/utils-h4C7rRcu.js +177 -0
- package/dist-vue/_chunks/utils-h4C7rRcu.js.map +1 -0
- package/dist-vue/api.js +1 -1
- package/dist-vue/apps/web-component/src/components/EmbeddedChatWidget.ce.d.ts +4 -4
- package/dist-vue/apps/web-component/src/composables/useChatbotAuth.d.ts +8 -54
- package/dist-vue/apps/web-component/src/composables/useChatbotAuthForm.d.ts +0 -14
- package/dist-vue/composables.js +112 -436
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +3235 -3359
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +0 -42
- package/dist-vue/packages/ability/src/index.d.ts +14 -10
- package/dist-vue/packages/auth/src/social-redirect-plugin.d.ts +12 -18
- package/dist-vue/packages/components/src/chat/PkChatbotAuth.d.ts +0 -19
- package/dist-vue/packages/components/src/chat/PkChatbotMessages.d.ts +4 -8
- package/dist-vue/packages/components/src/chat/PkChatbotSteps.d.ts +0 -1
- package/dist-vue/packages/components/src/chat/utils.d.ts +0 -9
- package/dist-vue/packages/components/src/index.d.ts +1 -2
- package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +0 -60
- package/dist-vue/packages/models/src/schema/Chat.d.ts +0 -42
- package/dist-vue/packages/models/src/schema/Document.d.ts +0 -17
- package/dist-vue/packages/models/src/schema/DocumentFolder.d.ts +0 -10
- package/dist-vue/packages/models/src/schema/DocumentSyncSource.d.ts +1 -71
- package/dist-vue/packages/models/src/schema/Media.d.ts +1 -0
- package/dist-vue/packages/models/src/schema/Member.d.ts +0 -3
- package/dist-vue/packages/models/src/schema/Notification.d.ts +0 -6
- package/dist-vue/packages/models/src/schema/Organization.d.ts +0 -1
- package/dist-vue/packages/models/src/schema/User.d.ts +0 -1
- package/dist-vue/style.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/Agent-DK76k05_.js +0 -566
- package/dist/_chunks/Agent-DK76k05_.js.map +0 -1
- package/dist/_chunks/PkStreamingMarkdown-ZD0SROu1.js.map +0 -1
- package/dist/_chunks/PkToolShowComparison-8d6fAhRp.js +0 -72
- package/dist/_chunks/PkToolShowComparison-8d6fAhRp.js.map +0 -1
- package/dist/_chunks/markdown-BL7WANiX.js.map +0 -1
- package/dist-vue/_chunks/Document-nCWwJC2h.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotAuth-jzoNJkmH.js +0 -421
- package/dist-vue/_chunks/PkChatbotAuth-jzoNJkmH.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotMessages-KH5RE8Dk.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotSteps-356rnZG5.js +0 -191
- package/dist-vue/_chunks/PkChatbotSteps-356rnZG5.js.map +0 -1
- package/dist-vue/_chunks/PkToolShowComparison-DQs3E6-k.js +0 -72
- package/dist-vue/_chunks/PkToolShowComparison-DQs3E6-k.js.map +0 -1
- package/dist-vue/_chunks/createChatbotApiClient-BlWs282E.js.map +0 -1
- package/dist-vue/_chunks/utils--8iNpBr_.js +0 -184
- package/dist-vue/_chunks/utils--8iNpBr_.js.map +0 -1
- package/dist-vue/packages/auth/src/additional-fields.d.ts +0 -48
- package/dist-vue/packages/auth/src/passkey-policy-client-plugin.d.ts +0 -31
- package/dist-vue/packages/auth/src/passkey-policy-plugin.d.ts +0 -22
- package/dist-vue/packages/auth/src/two-factor-policy-client-plugin.d.ts +0 -60
- package/dist-vue/packages/auth/src/two-factor-policy-plugin.d.ts +0 -65
- package/dist-vue/packages/components/src/PkQrCode.d.ts +0 -14
- package/dist-vue/packages/components/src/chat/PkTurnEvaluation.d.ts +0 -8
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { E as e } from "./Agent-tbKw8Mdt.js";
|
|
2
|
-
import "./src-DT8FLE4_.js";
|
|
3
|
-
import { c as t, o as n, r, s as i } from "./message-RohfrdWS.js";
|
|
4
|
-
//#region ../../packages/components/src/chat/utils.ts
|
|
5
|
-
function a(e) {
|
|
6
|
-
let t = [];
|
|
7
|
-
for (let n of e) {
|
|
8
|
-
if (!i(n)) {
|
|
9
|
-
t.push(n);
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
let e = t[t.length - 1];
|
|
13
|
-
e && i(e) ? t[t.length - 1] = {
|
|
14
|
-
...e,
|
|
15
|
-
text: e.text + n.text
|
|
16
|
-
} : t.push(n);
|
|
17
|
-
}
|
|
18
|
-
return t;
|
|
19
|
-
}
|
|
20
|
-
var o = (n) => t(n) && e(r(n));
|
|
21
|
-
function s(e) {
|
|
22
|
-
let t = /* @__PURE__ */ new Map();
|
|
23
|
-
for (let [n, r] of e.entries()) o(r) && r.state !== "output-error" && !c(r) && t.set(r.type, n);
|
|
24
|
-
return e.filter((e, n) => !(o(e) && e.state === "output-error" && (t.get(e.type) ?? -1) > n));
|
|
25
|
-
}
|
|
26
|
-
function c(e) {
|
|
27
|
-
return e && "state" in e ? e.state === "streaming" || e.state === "input-streaming" : !1;
|
|
28
|
-
}
|
|
29
|
-
var l = 4e3, u = /^[ \t]*(?:(?:[-*+]|\d{1,9}[.)])[ \t]+|>[ \t]?)*(`{3,}|~{3,})(.*)$/gm;
|
|
30
|
-
function d(e, t) {
|
|
31
|
-
if (e.length <= t) return e;
|
|
32
|
-
let n = e.length - t, r = n + t / 2, i = (e, t) => e !== -1 && e < r ? e + t : void 0, a = i(e.indexOf("\n\n", n), 2) ?? i(e.indexOf("\n", n), 1) ?? n, o;
|
|
33
|
-
for (let t of e.matchAll(u)) {
|
|
34
|
-
if (t.index >= a) break;
|
|
35
|
-
let [, e, n] = t;
|
|
36
|
-
if (o) e[0] === o[0] && e.length >= o.length && !n.trim() && (o = void 0);
|
|
37
|
-
else {
|
|
38
|
-
if (e[0] === "`" && n.includes("`")) continue;
|
|
39
|
-
o = e;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return `…\n\n${o ? `${o}\n` : ""}${e.slice(a)}`;
|
|
43
|
-
}
|
|
44
|
-
var f = /* @__PURE__ */ new Set([
|
|
45
|
-
"approval-requested",
|
|
46
|
-
"approval-responded",
|
|
47
|
-
"output-denied"
|
|
48
|
-
]);
|
|
49
|
-
function p(e) {
|
|
50
|
-
return t(e) ? f.has(e.state) ? !0 : e.approval != null : !1;
|
|
51
|
-
}
|
|
52
|
-
var m = "requestConfirm";
|
|
53
|
-
function h(e) {
|
|
54
|
-
return t(e) && e.type === "tool-requestConfirm";
|
|
55
|
-
}
|
|
56
|
-
function g(e) {
|
|
57
|
-
return p(e) || h(e);
|
|
58
|
-
}
|
|
59
|
-
function _(e) {
|
|
60
|
-
if (t(e)) return e.approval?.id;
|
|
61
|
-
}
|
|
62
|
-
function v(e) {
|
|
63
|
-
if (e && "state" in e) return e.state;
|
|
64
|
-
}
|
|
65
|
-
function y(e) {
|
|
66
|
-
return e ? ["streaming"].includes(e) : !1;
|
|
67
|
-
}
|
|
68
|
-
function b(e = "000000") {
|
|
69
|
-
let t = e.replace("#", "");
|
|
70
|
-
t.length === 3 && (t = t.split("").map((e) => e + e).join(""));
|
|
71
|
-
let n = parseInt(t.substring(0, 2), 16) / 255, r = parseInt(t.substring(2, 4), 16) / 255, i = parseInt(t.substring(4, 6), 16) / 255, a = (e) => e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
72
|
-
return .2126 * a(n) + .7152 * a(r) + .0722 * a(i) > .179 ? "black" : "white";
|
|
73
|
-
}
|
|
74
|
-
function x(e, t) {
|
|
75
|
-
return e === "white" || e === "black" ? e : b(t);
|
|
76
|
-
}
|
|
77
|
-
function S(e, t) {
|
|
78
|
-
if (!(t === void 0 || t < 50)) return e(t / 1e3, "seconds");
|
|
79
|
-
}
|
|
80
|
-
function C(e) {
|
|
81
|
-
if (e !== void 0) {
|
|
82
|
-
if (typeof e == "string") return e.trim() || void 0;
|
|
83
|
-
try {
|
|
84
|
-
let t = JSON.stringify(e, null, 2);
|
|
85
|
-
return t === "{}" || t === "[]" ? void 0 : t;
|
|
86
|
-
} catch {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function w(e) {
|
|
92
|
-
return C(e) !== void 0;
|
|
93
|
-
}
|
|
94
|
-
function T(e, t) {
|
|
95
|
-
let n = e?.input;
|
|
96
|
-
if (typeof t == "string") {
|
|
97
|
-
let e = n?.question ?? n?.steps?.[0]?.question;
|
|
98
|
-
return e ? `${e} ${t}` : t;
|
|
99
|
-
}
|
|
100
|
-
let r = new Map((n?.steps ?? []).map((e) => [e.id, e.question]));
|
|
101
|
-
return t.answers.filter(({ value: e }) => e !== null && e !== "" && !(Array.isArray(e) && !e.length)).map(({ id: e, value: t }) => {
|
|
102
|
-
let n = Array.isArray(t) ? t.join(", ") : String(t), i = r.get(e);
|
|
103
|
-
return i ? `${i} ${n}` : n;
|
|
104
|
-
}).join(". ");
|
|
105
|
-
}
|
|
106
|
-
function E(e) {
|
|
107
|
-
return e?.options ? e.options.map((e) => ({
|
|
108
|
-
label: e.label,
|
|
109
|
-
value: e.label,
|
|
110
|
-
description: e.description
|
|
111
|
-
})) : [];
|
|
112
|
-
}
|
|
113
|
-
function D(e, t) {
|
|
114
|
-
let n = {};
|
|
115
|
-
if (t == null) return n;
|
|
116
|
-
if (typeof t == "string") return e.length === 1 && (n[0] = t), n;
|
|
117
|
-
let r = (t, r) => {
|
|
118
|
-
e.forEach((e, i) => {
|
|
119
|
-
e.id === t && (n[i] = r);
|
|
120
|
-
});
|
|
121
|
-
}, i = t.answers;
|
|
122
|
-
if (Array.isArray(i)) {
|
|
123
|
-
for (let e of i) typeof e?.id == "string" && r(e.id, e.value);
|
|
124
|
-
return n;
|
|
125
|
-
}
|
|
126
|
-
for (let [e, n] of Object.entries(t)) n !== void 0 && r(e, n);
|
|
127
|
-
return n;
|
|
128
|
-
}
|
|
129
|
-
var O = [
|
|
130
|
-
"tool-perplexity_search",
|
|
131
|
-
"tool-parallel_search",
|
|
132
|
-
"tool-web_search",
|
|
133
|
-
"tool-google_search"
|
|
134
|
-
], k = /* @__PURE__ */ new Set([
|
|
135
|
-
"tool-searchInKnowledgeBase",
|
|
136
|
-
"tool-retrieveRevisedAnswers",
|
|
137
|
-
"tool-expandChunkContext",
|
|
138
|
-
"tool-readDocumentFile",
|
|
139
|
-
"tool-getWeather",
|
|
140
|
-
"tool-geocode",
|
|
141
|
-
"tool-recallUserMemory",
|
|
142
|
-
"tool-saveUserMemory",
|
|
143
|
-
...O
|
|
144
|
-
]);
|
|
145
|
-
function A(e) {
|
|
146
|
-
return t(e) && k.has(e.type);
|
|
147
|
-
}
|
|
148
|
-
var j = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, M = (e, ...t) => {
|
|
149
|
-
for (let n of t) {
|
|
150
|
-
let t = e?.[n];
|
|
151
|
-
if (typeof t == "string" && t.trim()) return t;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
function N(e) {
|
|
155
|
-
if (!t(e)) return;
|
|
156
|
-
let n = j("input" in e ? e.input : void 0), r = j("output" in e ? e.output : void 0);
|
|
157
|
-
if (e.type === "tool-searchInKnowledgeBase" || O.includes(e.type)) {
|
|
158
|
-
let e = n?.queries;
|
|
159
|
-
if (Array.isArray(e)) {
|
|
160
|
-
let t = e.filter((e) => typeof e == "string" && !!e.trim());
|
|
161
|
-
return t.length ? t.join(" · ") : void 0;
|
|
162
|
-
}
|
|
163
|
-
return M(n, "query", "objective");
|
|
164
|
-
}
|
|
165
|
-
if (e.type === "tool-retrieveRevisedAnswers") return M(n, "query");
|
|
166
|
-
if (e.type === "tool-getWeather") return M(r, "location") ?? M(n, "locationName");
|
|
167
|
-
if (e.type === "tool-geocode") return M(n, "locationName");
|
|
168
|
-
if (e.type === "tool-expandChunkContext") return M(r, "documentName");
|
|
169
|
-
if (e.type === "tool-readDocumentFile") return M(r, "name");
|
|
170
|
-
if (e.type === "tool-recallUserMemory") return M(n, "query");
|
|
171
|
-
if (e.type === "tool-saveUserMemory") return M(n, "content", "query");
|
|
172
|
-
}
|
|
173
|
-
function P(e) {
|
|
174
|
-
if (t(e)) return e.type.includes("tool-subagent") ? "ri:robot-2-line" : e.type === "tool-runWorker" ? "ri:flow-chart" : e.type === "tool-fetchTeamsChannelHistory" ? "ri:chat-history-line" : e.type === "tool-enableTools" ? "ri:toggle-line" : e.type.includes("tool-mcp") ? "mcp" : e.type === "tool-retrieveRevisedAnswers" ? "ri:file-edit-line" : e.type === "tool-searchInKnowledgeBase" ? "ri:search-line" : e.type === "tool-expandChunkContext" ? "ri:file-search-line" : e.type === "tool-readDocumentFile" ? "ri:file-text-line" : e.type === "tool-geocode" ? "ri:map-2-line" : e.type === "tool-getWeather" ? "ri:sun-cloudy-line" : e.type === "tool-recallUserMemory" ? "ri:brain-line" : e.type === "tool-saveUserMemory" ? "ri:save-3-line" : e.type === "tool-showWeather" ? "ri:sun-line" : e.type === "tool-showDiagram" ? "ri:flow-chart" : e.type === "tool-showSources" ? "ri:book-2-line" : e.type === "tool-showForm" ? "ri:survey-line" : e.type === "tool-showMultipleChoice" ? "ri:checkbox-multiple-line" : e.type === "tool-showArtifact" ? "ri:file-code-line" : e.type === "tool-showEmail" ? "ri:mail-line" : e.type === "tool-showMessage" ? "ri:chat-1-line" : e.type === "tool-showWebPages" ? "ri:pages-line" : e.type === "tool-showProductList" ? "ri:shopping-bag-line" : e.type === "tool-showContactForm" ? "ri:send-plane-2-line" : e.type === "tool-showCalendarEvent" ? "ri:calendar-event-line" : e.type === "tool-showComparison" ? "ri:scales-line" : e.type === "tool-showLocation" ? "ri:map-pin-line" : e.type === "tool-showQrCode" ? "ri:qr-code-line" : e.type === "tool-showImageGallery" ? "ri:image-line" : e.type === "tool-showVideo" ? "ri:film-line" : e.type === "tool-showSuggestedReply" ? "ri:corner-down-right-line" : e.type === "tool-requestGeolocation" ? "ri:map-pin-user-line" : e.type === "tool-perplexity_search" || e.type === "tool-parallel_search" || e.type === "tool-web_search" || e.type === "tool-google_search" ? "ri:global-line" : "ri:tools-line";
|
|
175
|
-
if (n(e)) return "ri:lightbulb-line";
|
|
176
|
-
if (i(e)) return "ri:double-quotes-r";
|
|
177
|
-
}
|
|
178
|
-
function F(e, r) {
|
|
179
|
-
return t(r) ? r.type.includes("tool-subagent") ? e("messagePart.runSubagent") : r.type === "tool-runWorker" ? e("messagePart.runWorker") : r.type === "tool-fetchTeamsChannelHistory" ? e("messagePart.fetchTeamsChannelHistory") : r.type === "tool-enableTools" ? e("messagePart.enableTools") : r.type === "tool-retrieveRevisedAnswers" ? e("messagePart.revisedAnswers") : r.type === "tool-searchInKnowledgeBase" ? e("messagePart.searchingDocuments") : r.type === "tool-expandChunkContext" ? e("messagePart.expandChunkContext") : r.type === "tool-readDocumentFile" ? e("messagePart.readDocumentFile") : r.type === "tool-geocode" ? e("messagePart.geocode") : r.type === "tool-getWeather" ? e("messagePart.getWeather") : r.type === "tool-recallUserMemory" ? e("messagePart.recallUserMemory") : r.type === "tool-saveUserMemory" ? e("messagePart.saveUserMemory") : r.type === "tool-showWeather" ? e("messagePart.showWeather") : r.type === "tool-showForm" ? e("messagePart.showForm") : r.type === "tool-showDiagram" ? e("messagePart.showDiagram") : r.type === "tool-showSources" ? e("messagePart.showSources") : r.type === "tool-showMultipleChoice" ? e("messagePart.showMultipleChoice") : r.type === "tool-showArtifact" ? e("messagePart.showArtifact") : r.type === "tool-showEmail" ? e("messagePart.showEmail") : r.type === "tool-showMessage" ? e("messagePart.showMessage") : r.type === "tool-showWebPages" ? e("messagePart.showWebPages") : r.type === "tool-showProducts" ? e("messagePart.showProducts") : r.type === "tool-showContactForm" ? e("messagePart.showContactForm") : r.type === "tool-showCalendarEvent" ? e("messagePart.showCalendarEvent") : r.type === "tool-showComparison" ? e("messagePart.showComparison") : r.type === "tool-showLocation" ? e("messagePart.showLocation") : r.type === "tool-showQrCode" ? e("messagePart.showQrCode") : r.type === "tool-showImageGallery" ? e("messagePart.showImageGallery") : r.type === "tool-showVideo" ? e("messagePart.showVideo") : r.type === "tool-showSuggestedReply" ? e("messagePart.showSuggestedReply") : r.type === "tool-requestGeolocation" ? e("messagePart.requestGeolocation") : O.includes(r.type) ? e("messagePart.webSearch") : e("messagePart.tool") : n(r) ? e("messagePart.reasoning") : e("messagePart.streaming");
|
|
180
|
-
}
|
|
181
|
-
//#endregion
|
|
182
|
-
export { C, x as S, g as _, T as a, h as b, S as c, v as d, _ as f, A as g, w as h, s as i, d as l, N as m, l as n, D as o, F as p, O as r, E as s, m as t, P as u, y as v, a as x, c as y };
|
|
183
|
-
|
|
184
|
-
//# sourceMappingURL=utils--8iNpBr_.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils--8iNpBr_.js","names":[],"sources":["../../../../packages/components/src/chat/utils.ts"],"sourcesContent":["import type { UIMessage } from 'ai'\nimport { isPresentationTool } from 'models'\nimport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n getToolPartName,\n} from 'utils'\n\nexport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n}\n\n/**\n * Merges consecutive text parts into a single text part.\n * Claude (and other models) often produce multiple text parts during streaming\n * that should logically be a single block of text.\n */\nexport function mergeConsecutiveTextParts(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const merged: UIMessage['parts'] = []\n for (const part of parts) {\n if (!isTextPart(part)) {\n merged.push(part)\n continue\n }\n const prev = merged[merged.length - 1]\n if (prev && isTextPart(prev)) {\n merged[merged.length - 1] = { ...prev, text: prev.text + part.text }\n } else {\n merged.push(part)\n }\n }\n return merged\n}\n\nconst isWidgetPart = (\n part: UIMessage['parts'][number],\n): part is Extract<UIMessage['parts'][number], { type: `tool-${string}` }> =>\n isToolPart(part) && isPresentationTool(getToolPartName(part))\n\n/**\n * Drops a widget call refused for its arguments when a later call of the same\n * widget in the message was drawn: the turn corrected it (the backend's\n * `correctableInputRefusals`), and the refusal would sit next to the working\n * widget, `showForm` drawing its render error above the form. A refusal with\n * nothing drawn after it stays. Only the feed reads this: the steps timeline\n * keeps every call, the refused one included.\n */\nexport function dropCorrectedWidgetErrors(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const lastDrawn = new Map<string, number>()\n for (const [index, part] of parts.entries()) {\n if (\n isWidgetPart(part) &&\n part.state !== 'output-error' &&\n !isStreamingPart(part)\n ) {\n lastDrawn.set(part.type, index)\n }\n }\n return parts.filter(\n (part, index) =>\n !(\n isWidgetPart(part) &&\n part.state === 'output-error' &&\n (lastDrawn.get(part.type) ?? -1) > index\n ),\n )\n}\n\nexport function isStreamingPart(\n part: UIMessage['parts'][number] | null | undefined,\n): part is Extract<UIMessage['parts'][number], { streaming?: boolean }> {\n if (!part) {\n return false\n }\n if ('state' in part) {\n return part.state === 'streaming' || part.state === 'input-streaming'\n }\n return false\n}\n\n/**\n * How much of a reasoning still being written its live box renders. The box is\n * a few lines tall and follows the bottom, while the reasoning of one turn runs\n * to tens of kilobytes: chat `st0Eg8iG0zUX0HQN` wrote 92KB, and parsing all of\n * it at every delta froze the tab. Four thousand characters leave a few screens\n * to scroll back through, and a finished step renders all of it.\n */\nexport const LIVE_REASONING_TAIL_LENGTH = 4000\n\n// A fence opener or closer, also inside a list item or a quote, whose markers\n// and indentation are skipped. The rest of the line tells them apart: a\n// closing fence carries no info string.\nconst FENCE_LINE =\n /^[ \\t]*(?:(?:[-*+]|\\d{1,9}[.)])[ \\t]+|>[ \\t]?)*(`{3,}|~{3,})(.*)$/gm\n\n/**\n * The end of a markdown text, at most `maxLength` characters long, cut on a\n * blank line (a line break when there is none) so it does not open on half a\n * paragraph. A table or a formula can still be cut in two. An ellipsis marks\n * the cut. A cut inside a fenced code block reopens the fence, or the rest of\n * the text would render as code and the code as prose.\n */\nexport function getMarkdownTail(markdown: string, maxLength: number): string {\n if (markdown.length <= maxLength) {\n return markdown\n }\n const from = markdown.length - maxLength\n // The boundary is looked for in the first half of the window only: the one\n // blank line of the window can be the last thing written, and cutting there\n // would leave nothing to render.\n const limit = from + maxLength / 2\n const boundary = (index: number, length: number) =>\n index !== -1 && index < limit ? index + length : undefined\n const cut =\n boundary(markdown.indexOf('\\n\\n', from), 2) ??\n boundary(markdown.indexOf('\\n', from), 1) ??\n from\n let openFence: string | undefined\n for (const match of markdown.matchAll(FENCE_LINE)) {\n if (match.index >= cut) {\n break\n }\n const [, marker, rest] = match\n if (!openFence) {\n // A backtick in a backtick fence's info string makes it inline\n // code, not a fence.\n if (marker[0] === '`' && rest.includes('`')) {\n continue\n }\n openFence = marker\n } else if (\n marker[0] === openFence[0] &&\n marker.length >= openFence.length &&\n !rest.trim()\n ) {\n openFence = undefined\n }\n }\n const reopen = openFence ? `${openFence}\\n` : ''\n return `…\\n\\n${reopen}${markdown.slice(cut)}`\n}\n\n/**\n * States a tool part goes through when it needs the user's approval. They are\n * rendered by `PkToolApprovalCard` whatever the tool is, so the decision (and\n * its outcome) stays visible in the transcript.\n */\nconst TOOL_APPROVAL_STATES = new Set([\n 'approval-requested',\n 'approval-responded',\n 'output-denied',\n])\n\nexport function isToolApprovalPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n if (!isToolPart(part)) {\n return false\n }\n if (TOOL_APPROVAL_STATES.has(part.state)) {\n return true\n }\n // An executed (or errored) call that went through the gate keeps its\n // verdict in `approval`: the card stays in the transcript, so the user's\n // decision remains visible in the chat and in the log viewers (parity\n // with requestConfirm, whose 'confirmed' output is persisted).\n return (part as { approval?: unknown }).approval != null\n}\n\n/**\n * The client-side tool the model uses to have an action it described approved.\n * It predates the SDK's approval gate and keeps its own round-trip (it resolves\n * through `addToolOutput`), but it asks the user the very same question, so it\n * shares `PkToolApprovalCard` instead of having a card of its own.\n */\nexport const CONFIRM_TOOL_NAME = 'requestConfirm'\n\nexport function isToolConfirmPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return isToolPart(part) && part.type === `tool-${CONFIRM_TOOL_NAME}`\n}\n\n/** True for any part the confirmation card is responsible for. */\nexport function isConfirmationCardPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return isToolApprovalPart(part) || isToolConfirmPart(part)\n}\n\n/** The id of the pending approval request on a tool part, if any. */\nexport function getToolApprovalId(\n part: UIMessage['parts'][number] | null | undefined,\n): string | undefined {\n if (!isToolPart(part)) {\n return undefined\n }\n return (part as { approval?: { id?: string } }).approval?.id\n}\n\nexport function getPartState(\n part: UIMessage['parts'][number] | null | undefined,\n): string | undefined {\n if (!part) {\n return undefined\n }\n if ('state' in part) {\n return part.state\n }\n return undefined\n}\n\nexport function isLoadingState(state?: string): boolean {\n if (!state) {\n return false\n }\n return ['streaming'].includes(state)\n}\n\nexport function getContrast(hexcolor: string = '000000'): 'black' | 'white' {\n let hex = hexcolor.replace('#', '')\n\n // Expand 3-character hex to 6-character (e.g., #ccc -> #cccccc)\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map((char) => char + char)\n .join('')\n }\n\n // WCAG relative luminance\n const r = parseInt(hex.substring(0, 2), 16) / 255\n const g = parseInt(hex.substring(2, 4), 16) / 255\n const b = parseInt(hex.substring(4, 6), 16) / 255\n\n const linearize = (c: number) =>\n c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n\n const luminance =\n 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b)\n\n return luminance > 0.179 ? 'black' : 'white'\n}\n\n/**\n * Resolves the contrast color based on the user's `textColor` preference.\n * Falls back to WCAG auto-detection via `getContrast` when set to `'auto'` or `undefined`.\n */\nexport function resolveContrastColor(\n textColor: 'auto' | 'white' | 'black' | undefined,\n mainColor: string | undefined,\n): 'black' | 'white' {\n if (textColor === 'white' || textColor === 'black') {\n return textColor\n }\n return getContrast(mainColor)\n}\n\n/**\n * Formats a duration in milliseconds using the i18n `seconds` number format\n * (e.g. \"12,4 secondi\" / \"12.4 seconds\"). Returns undefined for durations\n * that would render as \"0 seconds\" (less than 0.05s).\n */\nexport function formatDuration(\n $n: (value: number, format: string) => string,\n ms?: number,\n): string | undefined {\n if (ms === undefined || ms < 50) {\n return undefined\n }\n return $n(ms / 1000, 'seconds')\n}\n\n/**\n * Stringifies a tool payload for the raw fallback view. Returns undefined for\n * empty values so the caller can skip rendering the block entirely.\n */\nexport function stringifyPayload(value: unknown): string | undefined {\n if (value === undefined) {\n return undefined\n }\n if (typeof value === 'string') {\n return value.trim() || undefined\n }\n try {\n const json = JSON.stringify(value, null, 2)\n return json === '{}' || json === '[]' ? undefined : json\n } catch {\n return undefined\n }\n}\n\n/**\n * True when a tool payload carries something worth rendering, so a caller can\n * skip the block without stringifying the value twice.\n */\nexport function hasPayload(value: unknown): boolean {\n return stringifyPayload(value) !== undefined\n}\n\n/**\n * Turns the answers of a form into the sentence the caller would have said.\n *\n * On a call the tool loop is over by the time the form is on screen, so the\n * answers go back to the agent as a user message (see `sendUserMessage` in\n * `useVoiceSession`). Each answer is paired with its question, because that is\n * how a person would say it and because the agent hears it with no widget\n * attached.\n */\nexport function formAnswerAsSpoken(\n part: unknown,\n answer: string | { answers: { id: string; value: unknown }[] },\n): string {\n const input = (\n part as {\n input?: {\n steps?: { id: string; question?: string }[]\n question?: string\n }\n }\n )?.input\n\n if (typeof answer === 'string') {\n const question = input?.question ?? input?.steps?.[0]?.question\n return question ? `${question} ${answer}` : answer\n }\n\n const questionById = new Map(\n (input?.steps ?? []).map((step) => [step.id, step.question]),\n )\n const lines = answer.answers\n .filter(\n ({ value }) =>\n value !== null &&\n value !== '' &&\n !(Array.isArray(value) && !value.length),\n )\n .map(({ id, value }) => {\n const said = Array.isArray(value) ? value.join(', ') : String(value)\n const question = questionById.get(id)\n return question ? `${question} ${said}` : said\n })\n\n return lines.join('. ')\n}\n\n/**\n * The choices of a form step, as the radio and checkbox editors take them.\n *\n * The `value` is the LABEL and not the position, because it is what travels\n * back to the model as the answer: it reads the words it wrote, not an index.\n * Nothing here caps the list, and nothing should: the number of options an\n * agent configures is advice to the model, so a step can legitimately carry\n * more (see `showForm.tool.ts`).\n */\nexport function formStepOptions(\n step: { options?: { label: string; description?: string }[] } | undefined,\n): { label: string; value: string; description?: string }[] {\n if (!step?.options) {\n return []\n }\n return step.options.map((option) => ({\n label: option.label,\n value: option.label,\n description: option.description,\n }))\n}\n\n/**\n * Spreads the answers a form comes back with onto one slot PER STEP.\n *\n * A form's answers travel paired with step ids, and the tool schema does not\n * enforce that those ids are unique: a `.refine()` there would refuse the whole\n * form over a duplicate, which is the failure the schema was just cured of (see\n * the gotchas entry \"A configurable cap does not belong in an inputSchema\").\n * So the duplicate has to be survivable here. Keyed by id, two steps sharing\n * one collapsed onto a single answer: the second question showed the first\n * one's reply, and submitting sent that reply twice. Keyed by position, each\n * step keeps its own.\n *\n * A duplicated id restores the same incoming value to every step claiming it,\n * which is as much as the payload allows: the ids are all it says.\n */\nexport function formAnswerSlots(\n steps: { id: string }[],\n output: unknown,\n): Record<number, unknown> {\n const slots: Record<number, unknown> = {}\n if (output === undefined || output === null) {\n return slots\n }\n // A legacy single-choice answer is the plain string, and it can only\n // belong to a single-step form.\n if (typeof output === 'string') {\n if (steps.length === 1) {\n slots[0] = output\n }\n return slots\n }\n const assign = (id: string, value: unknown) => {\n steps.forEach((step, index) => {\n if (step.id === id) {\n slots[index] = value\n }\n })\n }\n const list = (output as { answers?: unknown }).answers\n if (Array.isArray(list)) {\n for (const answer of list as { id?: unknown; value?: unknown }[]) {\n if (typeof answer?.id === 'string') {\n assign(answer.id, answer.value)\n }\n }\n return slots\n }\n // Forms answered on a platform channel (the Teams modal) come back as a\n // flat record keyed by step id.\n for (const [id, value] of Object.entries(\n output as Record<string, unknown>,\n )) {\n if (value !== undefined) {\n assign(id, value)\n }\n }\n return slots\n}\n\n// Provider-native web search tool part types\nexport const WEB_SEARCH_TOOL_TYPES = [\n 'tool-perplexity_search',\n 'tool-parallel_search',\n 'tool-web_search',\n 'tool-google_search',\n]\n\n// Tool part types with a dedicated rich rendering in PkChatbotStepToolDetail\nconst RICH_DETAIL_TOOL_TYPES = new Set([\n 'tool-searchInKnowledgeBase',\n 'tool-retrieveRevisedAnswers',\n 'tool-expandChunkContext',\n 'tool-readDocumentFile',\n 'tool-getWeather',\n 'tool-geocode',\n 'tool-recallUserMemory',\n 'tool-saveUserMemory',\n ...WEB_SEARCH_TOOL_TYPES,\n])\n\nexport function hasRichToolDetail(\n part?: UIMessage['parts'][number] | null,\n): boolean {\n return isToolPart(part) && RICH_DETAIL_TOOL_TYPES.has(part.type)\n}\n\nconst asRecord = (value: unknown): Record<string, unknown> | undefined =>\n value && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined\n\nconst pickString = (\n record: Record<string, unknown> | undefined,\n ...keys: string[]\n): string | undefined => {\n for (const key of keys) {\n const value = record?.[key]\n if (typeof value === 'string' && value.trim()) {\n return value\n }\n }\n return undefined\n}\n\n/**\n * Returns a short inline summary for a tool part (search queries, location,\n * document name, ...) to be shown next to the step label without expanding\n * the step body.\n */\nexport function getToolPartSummary(\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n if (!isToolPart(part)) {\n return undefined\n }\n const input = asRecord('input' in part ? part.input : undefined)\n const output = asRecord('output' in part ? part.output : undefined)\n if (\n part.type === 'tool-searchInKnowledgeBase' ||\n WEB_SEARCH_TOOL_TYPES.includes(part.type)\n ) {\n const queries = input?.queries\n if (Array.isArray(queries)) {\n const valid = queries.filter(\n (query): query is string =>\n typeof query === 'string' && Boolean(query.trim()),\n )\n return valid.length ? valid.join(' · ') : undefined\n }\n return pickString(input, 'query', 'objective')\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return pickString(input, 'query')\n }\n if (part.type === 'tool-getWeather') {\n return (\n pickString(output, 'location') ?? pickString(input, 'locationName')\n )\n }\n if (part.type === 'tool-geocode') {\n return pickString(input, 'locationName')\n }\n if (part.type === 'tool-expandChunkContext') {\n return pickString(output, 'documentName')\n }\n if (part.type === 'tool-readDocumentFile') {\n return pickString(output, 'name')\n }\n if (part.type === 'tool-recallUserMemory') {\n return pickString(input, 'query')\n }\n if (part.type === 'tool-saveUserMemory') {\n return pickString(input, 'content', 'query')\n }\n return undefined\n}\n\n// Get part icon\nexport function getPartIcon(\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n if (isToolPart(part)) {\n if (part.type.includes('tool-subagent')) {\n return 'ri:robot-2-line'\n }\n if (part.type === 'tool-runWorker') {\n return 'ri:flow-chart'\n }\n if (part.type === 'tool-fetchTeamsChannelHistory') {\n return 'ri:chat-history-line'\n }\n if (part.type === 'tool-enableTools') {\n return 'ri:toggle-line'\n }\n if (part.type.includes('tool-mcp')) {\n return 'mcp'\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return 'ri:file-edit-line'\n }\n if (part.type === 'tool-searchInKnowledgeBase') {\n return 'ri:search-line'\n }\n if (part.type === 'tool-expandChunkContext') {\n return 'ri:file-search-line'\n }\n if (part.type === 'tool-readDocumentFile') {\n return 'ri:file-text-line'\n }\n if (part.type === 'tool-geocode') {\n return 'ri:map-2-line'\n }\n if (part.type === 'tool-getWeather') {\n return 'ri:sun-cloudy-line'\n }\n if (part.type === 'tool-recallUserMemory') {\n return 'ri:brain-line'\n }\n if (part.type === 'tool-saveUserMemory') {\n return 'ri:save-3-line'\n }\n if (part.type === 'tool-showWeather') {\n return 'ri:sun-line'\n }\n if (part.type === 'tool-showDiagram') {\n return 'ri:flow-chart'\n }\n if (part.type === 'tool-showSources') {\n return 'ri:book-2-line'\n }\n if (part.type === 'tool-showForm') {\n return 'ri:survey-line'\n }\n if (part.type === 'tool-showMultipleChoice') {\n return 'ri:checkbox-multiple-line'\n }\n if (part.type === 'tool-showArtifact') {\n return 'ri:file-code-line'\n }\n if (part.type === 'tool-showEmail') {\n return 'ri:mail-line'\n }\n if (part.type === 'tool-showMessage') {\n return 'ri:chat-1-line'\n }\n if (part.type === 'tool-showWebPages') {\n return 'ri:pages-line'\n }\n if (part.type === 'tool-showProductList') {\n return 'ri:shopping-bag-line'\n }\n if (part.type === 'tool-showContactForm') {\n return 'ri:send-plane-2-line'\n }\n if (part.type === 'tool-showCalendarEvent') {\n return 'ri:calendar-event-line'\n }\n if (part.type === 'tool-showComparison') {\n return 'ri:scales-line'\n }\n if (part.type === 'tool-showLocation') {\n return 'ri:map-pin-line'\n }\n if (part.type === 'tool-showQrCode') {\n return 'ri:qr-code-line'\n }\n if (part.type === 'tool-showImageGallery') {\n return 'ri:image-line'\n }\n if (part.type === 'tool-showVideo') {\n return 'ri:film-line'\n }\n if (part.type === 'tool-showSuggestedReply') {\n return 'ri:corner-down-right-line'\n }\n if (part.type === 'tool-requestGeolocation') {\n return 'ri:map-pin-user-line'\n }\n if (\n part.type === 'tool-perplexity_search' ||\n part.type === 'tool-parallel_search' ||\n part.type === 'tool-web_search' ||\n part.type === 'tool-google_search'\n ) {\n return 'ri:global-line'\n }\n return 'ri:tools-line'\n }\n if (isReasoningPart(part)) {\n return 'ri:lightbulb-line'\n }\n if (isTextPart(part)) {\n return 'ri:double-quotes-r'\n }\n return undefined\n}\n\n// Get part label\nexport function getToolPartLabel(\n $t: (key: string) => string,\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n if (isToolPart(part)) {\n if (part.type.includes('tool-subagent')) {\n return $t(`messagePart.runSubagent`)\n }\n if (part.type === 'tool-runWorker') {\n return $t(`messagePart.runWorker`)\n }\n if (part.type === 'tool-fetchTeamsChannelHistory') {\n return $t(`messagePart.fetchTeamsChannelHistory`)\n }\n if (part.type === 'tool-enableTools') {\n return $t(`messagePart.enableTools`)\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return $t(`messagePart.revisedAnswers`)\n }\n if (part.type === 'tool-searchInKnowledgeBase') {\n return $t(`messagePart.searchingDocuments`)\n }\n if (part.type === 'tool-expandChunkContext') {\n return $t(`messagePart.expandChunkContext`)\n }\n if (part.type === 'tool-readDocumentFile') {\n return $t(`messagePart.readDocumentFile`)\n }\n if (part.type === 'tool-geocode') {\n return $t(`messagePart.geocode`)\n }\n if (part.type === 'tool-getWeather') {\n return $t(`messagePart.getWeather`)\n }\n if (part.type === 'tool-recallUserMemory') {\n return $t(`messagePart.recallUserMemory`)\n }\n if (part.type === 'tool-saveUserMemory') {\n return $t(`messagePart.saveUserMemory`)\n }\n if (part.type === 'tool-showWeather') {\n return $t(`messagePart.showWeather`)\n }\n if (part.type === 'tool-showForm') {\n return $t(`messagePart.showForm`)\n }\n if (part.type === 'tool-showDiagram') {\n return $t(`messagePart.showDiagram`)\n }\n if (part.type === 'tool-showSources') {\n return $t(`messagePart.showSources`)\n }\n if (part.type === 'tool-showMultipleChoice') {\n return $t(`messagePart.showMultipleChoice`)\n }\n if (part.type === 'tool-showArtifact') {\n return $t(`messagePart.showArtifact`)\n }\n if (part.type === 'tool-showEmail') {\n return $t(`messagePart.showEmail`)\n }\n if (part.type === 'tool-showMessage') {\n return $t(`messagePart.showMessage`)\n }\n if (part.type === 'tool-showWebPages') {\n return $t(`messagePart.showWebPages`)\n }\n if (part.type === 'tool-showProducts') {\n return $t(`messagePart.showProducts`)\n }\n if (part.type === 'tool-showContactForm') {\n return $t(`messagePart.showContactForm`)\n }\n if (part.type === 'tool-showCalendarEvent') {\n return $t(`messagePart.showCalendarEvent`)\n }\n if (part.type === 'tool-showComparison') {\n return $t(`messagePart.showComparison`)\n }\n if (part.type === 'tool-showLocation') {\n return $t(`messagePart.showLocation`)\n }\n if (part.type === 'tool-showQrCode') {\n return $t(`messagePart.showQrCode`)\n }\n if (part.type === 'tool-showImageGallery') {\n return $t(`messagePart.showImageGallery`)\n }\n if (part.type === 'tool-showVideo') {\n return $t(`messagePart.showVideo`)\n }\n if (part.type === 'tool-showSuggestedReply') {\n return $t(`messagePart.showSuggestedReply`)\n }\n if (part.type === 'tool-requestGeolocation') {\n return $t(`messagePart.requestGeolocation`)\n }\n if (WEB_SEARCH_TOOL_TYPES.includes(part.type)) {\n return $t(`messagePart.webSearch`)\n }\n return $t(`messagePart.tool`)\n }\n if (isReasoningPart(part)) {\n return $t(`messagePart.reasoning`)\n }\n return $t(`messagePart.streaming`)\n}\n"],"mappings":";;;;AA8BA,SAAgB,EACZ,GACkB;CAClB,IAAM,IAA6B,CAAC;CACpC,KAAK,IAAM,KAAQ,GAAO;EACtB,IAAI,CAAC,EAAW,CAAI,GAAG;GACnB,EAAO,KAAK,CAAI;GAChB;EACJ;EACA,IAAM,IAAO,EAAO,EAAO,SAAS;EACpC,AAAI,KAAQ,EAAW,CAAI,IACvB,EAAO,EAAO,SAAS,KAAK;GAAE,GAAG;GAAM,MAAM,EAAK,OAAO,EAAK;EAAK,IAEnE,EAAO,KAAK,CAAI;CAExB;CACA,OAAO;AACX;AAEA,IAAM,KACF,MAEA,EAAW,CAAI,KAAK,EAAmB,EAAgB,CAAI,CAAC;AAUhE,SAAgB,EACZ,GACkB;CAClB,IAAM,oBAAY,IAAI,IAAoB;CAC1C,KAAK,IAAM,CAAC,GAAO,MAAS,EAAM,QAAQ,GACtC,AACI,EAAa,CAAI,KAC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AA0B,IAEpC,EAAK,SAAS,sBACP,EAAG,0BAA0B,IAEpC,EAAK,SAAS,yBACP,EAAG,6BAA6B,IAEvC,EAAK,SAAS,2BACP,EAAG,+BAA+B,IAEzC,EAAK,SAAS,wBACP,EAAG,4BAA4B,IAEtC,EAAK,SAAS,sBACP,EAAG,0BAA0B,IAEpC,EAAK,SAAS,oBACP,EAAG,wBAAwB,IAElC,EAAK,SAAS,0BACP,EAAG,8BAA8B,IAExC,EAAK,SAAS,mBACP,EAAG,uBAAuB,IAEjC,EAAK,SAAS,4BACP,EAAG,gCAAgC,IAE1C,EAAK,SAAS,4BACP,EAAG,gCAAgC,IAE1C,EAAsB,SAAS,EAAK,IAAI,IACjC,EAAG,uBAAuB,IAE9B,EAAG,kBAAkB,IAE5B,EAAgB,CAAI,IACb,EAAG,uBAAuB,IAE9B,EAAG,uBAAuB;AACrC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/** The columns the config adds to better-auth's session. */
|
|
2
|
-
export declare const sessionAdditionalFields: {
|
|
3
|
-
activeOrganizationId: {
|
|
4
|
-
type: "string";
|
|
5
|
-
};
|
|
6
|
-
impersonatedBy: {
|
|
7
|
-
type: "string";
|
|
8
|
-
};
|
|
9
|
-
organizationRole: {
|
|
10
|
-
type: "string";
|
|
11
|
-
};
|
|
12
|
-
hardExpiresAt: {
|
|
13
|
-
type: "date";
|
|
14
|
-
required: false;
|
|
15
|
-
input: false;
|
|
16
|
-
};
|
|
17
|
-
signedInWithPasskey: {
|
|
18
|
-
type: "boolean";
|
|
19
|
-
required: false;
|
|
20
|
-
input: false;
|
|
21
|
-
defaultValue: false;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
/** The columns the config adds to better-auth's user. */
|
|
25
|
-
export declare const userAdditionalFields: {
|
|
26
|
-
media: {
|
|
27
|
-
type: "json";
|
|
28
|
-
required: false;
|
|
29
|
-
};
|
|
30
|
-
phoneNumber: {
|
|
31
|
-
type: "string";
|
|
32
|
-
required: false;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* What `inferAdditionalFields` reads of the server options, for a client that
|
|
37
|
-
* must not load the config itself. The widget's type declarations are built
|
|
38
|
-
* from its imports, and the inferred type of the config, with the two-step
|
|
39
|
-
* verification and passkey plugins, is too long to serialize (TS7056).
|
|
40
|
-
*/
|
|
41
|
-
export type AdditionalFieldsOptions = {
|
|
42
|
-
session: {
|
|
43
|
-
additionalFields: typeof sessionAdditionalFields;
|
|
44
|
-
};
|
|
45
|
-
user: {
|
|
46
|
-
additionalFields: typeof userAdditionalFields;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { BetterFetch } from 'better-auth/client';
|
|
2
|
-
/**
|
|
3
|
-
* Client counterpart of the server `passkeyPolicy()` plugin, see
|
|
4
|
-
* docs/specs/two-factor-authentication.md, D10.
|
|
5
|
-
*/
|
|
6
|
-
export declare function passkeyPolicyClient(): {
|
|
7
|
-
id: "passkey-policy";
|
|
8
|
-
getActions: ($fetch: BetterFetch) => {
|
|
9
|
-
passkeyPolicy: {
|
|
10
|
-
/** Lets the session add a passkey for the next five minutes. */
|
|
11
|
-
confirmPassword: (data: {
|
|
12
|
-
password: string;
|
|
13
|
-
}) => Promise<{
|
|
14
|
-
data: null;
|
|
15
|
-
error: {
|
|
16
|
-
message?: string | undefined;
|
|
17
|
-
status: number;
|
|
18
|
-
statusText: string;
|
|
19
|
-
};
|
|
20
|
-
} | {
|
|
21
|
-
data: {
|
|
22
|
-
status: boolean;
|
|
23
|
-
};
|
|
24
|
-
error: null;
|
|
25
|
-
}>;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
pathMethods: {
|
|
29
|
-
'/passkey-policy/confirm-password': "POST";
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BetterAuthPlugin } from 'better-auth';
|
|
2
|
-
/** Whether a session created on this route is opened with a passkey. */
|
|
3
|
-
export declare function isPasskeySessionPath(path: string | undefined): boolean;
|
|
4
|
-
/**
|
|
5
|
-
* Refuses a passkey that did not check who holds it (a PIN, a fingerprint, a
|
|
6
|
-
* face). With that check a passkey is two factors on its own, which is what
|
|
7
|
-
* lets it stand in for the password and the code; without it, it is a key
|
|
8
|
-
* anyone holding the device can use. better-auth leaves the check off.
|
|
9
|
-
*/
|
|
10
|
-
export declare function requirePasskeyUserVerification(userVerified: boolean | undefined): void;
|
|
11
|
-
/**
|
|
12
|
-
* The confirmation that guards adding a passkey, the announcements of D7 for
|
|
13
|
-
* passkeys and the rate limit of the confirmation.
|
|
14
|
-
*
|
|
15
|
-
* A passkey signs in without the password and without the code, so adding
|
|
16
|
-
* one is as strong as setting the password: the session alone is not enough,
|
|
17
|
-
* since a stolen one would leave a way in that outlives it (there is no
|
|
18
|
-
* freshness window, see `freshAge` in packages/auth/src/index.ts). The
|
|
19
|
-
* password is asked again, or, for an account without one, a sign-in in the
|
|
20
|
-
* last ten minutes.
|
|
21
|
-
*/
|
|
22
|
-
export declare function passkeyPolicy(): BetterAuthPlugin;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { BetterFetch } from 'better-auth/client';
|
|
2
|
-
/** What `GET /two-factor-policy/status` answers. */
|
|
3
|
-
export interface TwoFactorStatus {
|
|
4
|
-
enabled: boolean;
|
|
5
|
-
/** `totp` for an authenticator app, `otp` for the code sent by email. */
|
|
6
|
-
method: 'totp' | 'otp' | null;
|
|
7
|
-
/** The second factor protects a password: without one it is not offered. */
|
|
8
|
-
hasPassword: boolean;
|
|
9
|
-
/** An organization of the user requires it and it is not set up yet. */
|
|
10
|
-
required: boolean;
|
|
11
|
-
/** The user's organizations that require it. */
|
|
12
|
-
requiredBy: {
|
|
13
|
-
id: string;
|
|
14
|
-
name: string;
|
|
15
|
-
}[];
|
|
16
|
-
/** Backup codes left, with an authenticator app; null otherwise. */
|
|
17
|
-
backupCodesRemaining: number | null;
|
|
18
|
-
/** Passkeys of the user: a session opened with one meets the policy. */
|
|
19
|
-
passkeys: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Client counterpart of the server `twoFactorPolicy()` plugin, see
|
|
23
|
-
* docs/specs/two-factor-authentication.md.
|
|
24
|
-
*/
|
|
25
|
-
export declare function twoFactorPolicyClient(): {
|
|
26
|
-
id: "two-factor-policy";
|
|
27
|
-
getActions: ($fetch: BetterFetch) => {
|
|
28
|
-
twoFactorPolicy: {
|
|
29
|
-
status: () => Promise<{
|
|
30
|
-
data: null;
|
|
31
|
-
error: {
|
|
32
|
-
message?: string | undefined;
|
|
33
|
-
status: number;
|
|
34
|
-
statusText: string;
|
|
35
|
-
};
|
|
36
|
-
} | {
|
|
37
|
-
data: TwoFactorStatus;
|
|
38
|
-
error: null;
|
|
39
|
-
}>;
|
|
40
|
-
reset: (data: {
|
|
41
|
-
userId: string;
|
|
42
|
-
}) => Promise<{
|
|
43
|
-
data: null;
|
|
44
|
-
error: {
|
|
45
|
-
message?: string | undefined;
|
|
46
|
-
status: number;
|
|
47
|
-
statusText: string;
|
|
48
|
-
};
|
|
49
|
-
} | {
|
|
50
|
-
data: {
|
|
51
|
-
status: boolean;
|
|
52
|
-
};
|
|
53
|
-
error: null;
|
|
54
|
-
}>;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
pathMethods: {
|
|
58
|
-
'/two-factor-policy/reset': "POST";
|
|
59
|
-
};
|
|
60
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { BetterAuthPlugin } from 'better-auth';
|
|
2
|
-
import { createAuthMiddleware } from 'better-auth/api';
|
|
3
|
-
import { TwoFactorChange } from 'email';
|
|
4
|
-
/**
|
|
5
|
-
* Carries the challenge for a client that cannot hold the cookie: the widget,
|
|
6
|
-
* cross-origin and on bearer tokens (D4). The value is the signed cookie as
|
|
7
|
-
* the sign-in set it.
|
|
8
|
-
*/
|
|
9
|
-
export declare const TWO_FACTOR_TOKEN_HEADER = "x-two-factor-token";
|
|
10
|
-
/** Time the code sent by email stays valid, in minutes. */
|
|
11
|
-
export declare const TWO_FACTOR_OTP_PERIOD_MINUTES = 5;
|
|
12
|
-
type ChangedUser = {
|
|
13
|
-
id: string;
|
|
14
|
-
email: string;
|
|
15
|
-
name: string;
|
|
16
|
-
};
|
|
17
|
-
export type MiddlewareContext = Parameters<Parameters<typeof createAuthMiddleware>[0]>[0];
|
|
18
|
-
/**
|
|
19
|
-
* Tells the user that their second factor or their passkeys changed (D7, D10),
|
|
20
|
-
* by email and in the notification panel. Never throws: the change is already
|
|
21
|
-
* written.
|
|
22
|
-
*/
|
|
23
|
-
export declare function announceTwoFactorChange(user: ChangedUser, change: TwoFactorChange): Promise<void>;
|
|
24
|
-
type PolicyOrganization = {
|
|
25
|
-
requireTwoFactor?: boolean | null;
|
|
26
|
-
deleted?: boolean | null;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Whether the request has to stop for the organization policy (D6): the
|
|
30
|
-
* session of a member of an organization that requires a second factor, who
|
|
31
|
-
* signs in with a password and has none. `organizations` is what the caller
|
|
32
|
-
* already listed for the request, so the common case costs no query, or a
|
|
33
|
-
* loader that runs only once the cheap exemptions are past; the password
|
|
34
|
-
* check is cached, since most users have no second factor. Impersonation and
|
|
35
|
-
* anonymous sessions are exempt, and so is a deleted organization, which the
|
|
36
|
-
* status endpoint does not list either: counted here alone, it would bounce
|
|
37
|
-
* the user between the setup page and the app.
|
|
38
|
-
*
|
|
39
|
-
* A session opened with a passkey meets the policy (D10), and so does a user
|
|
40
|
-
* with a passkey where no session tells how they signed in: a Platform MCP
|
|
41
|
-
* token, whose authorization ran in a session the policy let through.
|
|
42
|
-
*/
|
|
43
|
-
export declare function isTwoFactorSetupRequiredForSession(input: {
|
|
44
|
-
user: {
|
|
45
|
-
id: string;
|
|
46
|
-
twoFactorEnabled?: boolean | null;
|
|
47
|
-
isAnonymous?: boolean | null;
|
|
48
|
-
hasPasskey?: boolean;
|
|
49
|
-
};
|
|
50
|
-
session: {
|
|
51
|
-
impersonatedBy?: string | null;
|
|
52
|
-
signedInWithPasskey?: boolean | null;
|
|
53
|
-
};
|
|
54
|
-
organizations: readonly PolicyOrganization[] | (() => Promise<readonly PolicyOrganization[]>);
|
|
55
|
-
}): Promise<boolean>;
|
|
56
|
-
/**
|
|
57
|
-
* The status endpoint, the administrator reset, the widget bridge and the
|
|
58
|
-
* announcements of docs/specs/two-factor-authentication.md.
|
|
59
|
-
*
|
|
60
|
-
* The endpoints live under `/two-factor-policy/` and not `/two-factor/` on
|
|
61
|
-
* purpose: the `twoFactor` plugin rate limits its prefix to three requests
|
|
62
|
-
* every ten seconds, which a profile page reading the status would hit.
|
|
63
|
-
*/
|
|
64
|
-
export declare function twoFactorPolicy(): BetterAuthPlugin;
|
|
65
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
2
|
-
/**
|
|
3
|
-
* A QR code drawn as inline SVG, with `qrcode` loaded on first use. The
|
|
4
|
-
* code stays dark on a white ground whatever the theme: a scanner reads
|
|
5
|
-
* the contrast, and not every one reads it inverted.
|
|
6
|
-
*/
|
|
7
|
-
type __VLS_Props = {
|
|
8
|
-
value: string;
|
|
9
|
-
/** What the code holds, for a screen reader. */
|
|
10
|
-
label: string;
|
|
11
|
-
};
|
|
12
|
-
declare const __VLS_export: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
13
|
-
declare const _default: typeof __VLS_export;
|
|
14
|
-
export default _default;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { UIChatMessage } from '../../../models/src';
|
|
2
|
-
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
|
-
type __VLS_Props = {
|
|
4
|
-
message: UIChatMessage;
|
|
5
|
-
};
|
|
6
|
-
declare const __VLS_export: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
7
|
-
declare const _default: typeof __VLS_export;
|
|
8
|
-
export default _default;
|