@aigentyc/chat-sdk 0.5.0 → 0.5.2
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/{ChatInterface-2MN5cpYB.d.ts → ChatInterface-CRmM_RG_.d.ts} +9 -1
- package/dist/{ChatInterface-BnVyOUG5.d.cts → ChatInterface-DKF3BY42.d.cts} +9 -1
- package/dist/{SlotsContext-BZBi51ZT.d.ts → SlotsContext-B_087V7B.d.ts} +11 -2
- package/dist/{SlotsContext-D_C7zlUA.d.cts → SlotsContext-DAQiASVu.d.cts} +11 -2
- package/dist/ai-elements.cjs +39 -27
- package/dist/ai-elements.d.cts +63 -1
- package/dist/ai-elements.d.ts +63 -1
- package/dist/ai-elements.js +2 -2
- package/dist/{chunk-3MP2EGEJ.cjs → chunk-72QJ2ORD.cjs} +4 -2
- package/dist/chunk-72QJ2ORD.cjs.map +1 -0
- package/dist/{chunk-KTYYLZN7.cjs → chunk-B277MAUK.cjs} +76 -4
- package/dist/chunk-B277MAUK.cjs.map +1 -0
- package/dist/{chunk-P3RPAI4F.cjs → chunk-BYX6IOGX.cjs} +4 -4
- package/dist/{chunk-P3RPAI4F.cjs.map → chunk-BYX6IOGX.cjs.map} +1 -1
- package/dist/chunk-CNPYBLLT.js +81 -0
- package/dist/chunk-CNPYBLLT.js.map +1 -0
- package/dist/{chunk-FJZL33KP.js → chunk-CW6LCVNC.js} +3 -3
- package/dist/{chunk-FJZL33KP.js.map → chunk-CW6LCVNC.js.map} +1 -1
- package/dist/{chunk-D75TDRBH.js → chunk-JAEXKKSE.js} +41 -35
- package/dist/chunk-JAEXKKSE.js.map +1 -0
- package/dist/{chunk-Q3UJEIBN.cjs → chunk-JEK2V5I3.cjs} +6 -6
- package/dist/{chunk-Q3UJEIBN.cjs.map → chunk-JEK2V5I3.cjs.map} +1 -1
- package/dist/{chunk-7ESWDFF5.cjs → chunk-KHQYSEYN.cjs} +244 -146
- package/dist/chunk-KHQYSEYN.cjs.map +1 -0
- package/dist/{chunk-QYCEHFAB.js → chunk-LDQVDUUJ.js} +4 -2
- package/dist/chunk-LDQVDUUJ.js.map +1 -0
- package/dist/{chunk-5XF3NEFB.js → chunk-O5TPHZRP.js} +74 -5
- package/dist/chunk-O5TPHZRP.js.map +1 -0
- package/dist/{chunk-BWWN5LSE.js → chunk-PNUHUUA3.js} +221 -124
- package/dist/chunk-PNUHUUA3.js.map +1 -0
- package/dist/{chunk-52ZHMTAA.cjs → chunk-UXVOUC2A.cjs} +41 -35
- package/dist/chunk-UXVOUC2A.cjs.map +1 -0
- package/dist/{chunk-IU7Q7O5G.js → chunk-VQPOUMBC.js} +3 -3
- package/dist/{chunk-IU7Q7O5G.js.map → chunk-VQPOUMBC.js.map} +1 -1
- package/dist/chunk-VYBHYFG3.cjs +87 -0
- package/dist/chunk-VYBHYFG3.cjs.map +1 -0
- package/dist/components.cjs +20 -19
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/components.js +8 -7
- package/dist/components.js.map +1 -1
- package/dist/core.cjs +21 -82
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +2 -78
- package/dist/core.js.map +1 -1
- package/dist/hooks.cjs +9 -8
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +4 -3
- package/dist/hooks.js.map +1 -1
- package/dist/i18n.cjs +5 -5
- package/dist/i18n.d.cts +2 -2
- package/dist/i18n.d.ts +2 -2
- package/dist/i18n.js +1 -1
- package/dist/index.cjs +35 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -6
- package/dist/index.d.ts +28 -6
- package/dist/index.js +18 -13
- package/dist/index.js.map +1 -1
- package/dist/llms-full.txt +10 -10
- package/dist/styles.css +1 -1
- package/dist/theme.cjs +4 -4
- package/dist/theme.d.cts +1 -1
- package/dist/theme.d.ts +1 -1
- package/dist/theme.js +2 -2
- package/dist/tools.cjs +6 -5
- package/dist/tools.d.cts +2 -2
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +3 -2
- package/dist/{types-bsR_-fq8.d.cts → types-DRa1zFlN.d.cts} +10 -1
- package/dist/{types-bsR_-fq8.d.ts → types-DRa1zFlN.d.ts} +10 -1
- package/package.json +2 -2
- package/dist/chunk-3MP2EGEJ.cjs.map +0 -1
- package/dist/chunk-52ZHMTAA.cjs.map +0 -1
- package/dist/chunk-5XF3NEFB.js.map +0 -1
- package/dist/chunk-7ESWDFF5.cjs.map +0 -1
- package/dist/chunk-BWWN5LSE.js.map +0 -1
- package/dist/chunk-D75TDRBH.js.map +0 -1
- package/dist/chunk-KTYYLZN7.cjs.map +0 -1
- package/dist/chunk-QYCEHFAB.js.map +0 -1
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunkDVWX2UGY_cjs = require('./chunk-DVWX2UGY.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
5
|
+
var chunkBYX6IOGX_cjs = require('./chunk-BYX6IOGX.cjs');
|
|
6
|
+
var chunkB277MAUK_cjs = require('./chunk-B277MAUK.cjs');
|
|
7
|
+
var chunk72QJ2ORD_cjs = require('./chunk-72QJ2ORD.cjs');
|
|
8
|
+
var chunkJEK2V5I3_cjs = require('./chunk-JEK2V5I3.cjs');
|
|
9
|
+
var chunkUXVOUC2A_cjs = require('./chunk-UXVOUC2A.cjs');
|
|
10
10
|
var chunk525KS5HM_cjs = require('./chunk-525KS5HM.cjs');
|
|
11
11
|
var react = require('react');
|
|
12
12
|
var lucideReact = require('lucide-react');
|
|
@@ -30,8 +30,8 @@ var ChatHeader = react.memo(function ChatHeader2({
|
|
|
30
30
|
cartCount,
|
|
31
31
|
onCartClick
|
|
32
32
|
}) {
|
|
33
|
-
const { t, direction } =
|
|
34
|
-
const ctx =
|
|
33
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
34
|
+
const ctx = chunkUXVOUC2A_cjs.useChatContext();
|
|
35
35
|
const displayName = clientName || ctx.config.clientName || "AI Assistant";
|
|
36
36
|
const LogoOrIcon = () => {
|
|
37
37
|
if (logoUrl) {
|
|
@@ -164,7 +164,7 @@ var ChatInput = react.memo(function ChatInput2({
|
|
|
164
164
|
}) {
|
|
165
165
|
const [isFocused, setIsFocused] = react.useState(false);
|
|
166
166
|
const [isComposing, setIsComposing] = react.useState(false);
|
|
167
|
-
const { t, direction } =
|
|
167
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
168
168
|
const { ref: textareaRef } = chunkDVWX2UGY_cjs.useAutoResize(value, {
|
|
169
169
|
minHeight: 24,
|
|
170
170
|
maxHeight: 160
|
|
@@ -265,7 +265,7 @@ var ChatInput = react.memo(function ChatInput2({
|
|
|
265
265
|
);
|
|
266
266
|
});
|
|
267
267
|
function ChatFooter({ footerText }) {
|
|
268
|
-
const { t } =
|
|
268
|
+
const { t } = chunk72QJ2ORD_cjs.useI18n();
|
|
269
269
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
270
270
|
"div",
|
|
271
271
|
{
|
|
@@ -331,7 +331,7 @@ function WelcomePage({
|
|
|
331
331
|
questionsLayoutMobile
|
|
332
332
|
}) {
|
|
333
333
|
const isMobile = chunkDVWX2UGY_cjs.useIsMobile();
|
|
334
|
-
const { t } =
|
|
334
|
+
const { t } = chunk72QJ2ORD_cjs.useI18n();
|
|
335
335
|
const layout = isMobile && questionsLayoutMobile ? questionsLayoutMobile : questionsLayout;
|
|
336
336
|
const isHorizontal = layout === "horizontal";
|
|
337
337
|
const [shouldAnimate, setShouldAnimate] = react.useState(false);
|
|
@@ -495,7 +495,7 @@ function QuickQuestions({ questions, onSelect, isProcessing = false, pageKey })
|
|
|
495
495
|
const [dismissed, setDismissed] = react.useState(false);
|
|
496
496
|
const prevPageKeyRef = react.useRef(pageKey);
|
|
497
497
|
const scrollRef = react.useRef(null);
|
|
498
|
-
const { direction } =
|
|
498
|
+
const { direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
499
499
|
react.useEffect(() => {
|
|
500
500
|
if (prevPageKeyRef.current !== pageKey) {
|
|
501
501
|
setDismissed(false);
|
|
@@ -592,7 +592,7 @@ function decodeHtmlEntities(text) {
|
|
|
592
592
|
return text.replace(/&#(\d+);/g, (_, code) => String.fromCharCode(Number(code))).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/–/g, "\u2013").replace(/—/g, "\u2014").replace(/«/g, "\xAB").replace(/»/g, "\xBB");
|
|
593
593
|
}
|
|
594
594
|
function CartDrawer({ storeOrigin, isOpen, onClose, onCartUpdate }) {
|
|
595
|
-
const { t } =
|
|
595
|
+
const { t } = chunk72QJ2ORD_cjs.useI18n();
|
|
596
596
|
const [cart, setCart] = react.useState(null);
|
|
597
597
|
const [loading, setLoading] = react.useState(false);
|
|
598
598
|
const [updatingKeys, setUpdatingKeys] = react.useState(/* @__PURE__ */ new Set());
|
|
@@ -795,6 +795,71 @@ function SystemMessage({ message, type }) {
|
|
|
795
795
|
const displayMessage = translateMessage(message, type);
|
|
796
796
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center my-3", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-muted-foreground bg-muted px-4 py-1.5 rounded-full border border-border/50", children: displayMessage }) });
|
|
797
797
|
}
|
|
798
|
+
function serverMessage(error) {
|
|
799
|
+
const raw = error?.message?.trim();
|
|
800
|
+
if (!raw || !raw.startsWith("{")) return null;
|
|
801
|
+
try {
|
|
802
|
+
const parsed = JSON.parse(raw);
|
|
803
|
+
const message = typeof parsed.error === "string" ? parsed.error.trim() : "";
|
|
804
|
+
return message || null;
|
|
805
|
+
} catch {
|
|
806
|
+
return null;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
function isTerminal(error) {
|
|
810
|
+
const raw = error?.message ?? "";
|
|
811
|
+
if (/too_many_messages|message_too_long|request_too_large/.test(raw)) {
|
|
812
|
+
return true;
|
|
813
|
+
}
|
|
814
|
+
return /conversation too long|request too large|message too long/i.test(raw);
|
|
815
|
+
}
|
|
816
|
+
function ChatError({ error, onRetry, onNewConversation }) {
|
|
817
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
818
|
+
const terminal = isTerminal(error);
|
|
819
|
+
const detail = serverMessage(error);
|
|
820
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
821
|
+
"div",
|
|
822
|
+
{
|
|
823
|
+
role: "alert",
|
|
824
|
+
dir: direction,
|
|
825
|
+
className: "mx-auto w-full max-w-[520px] rounded-xl border px-4 py-3 text-sm",
|
|
826
|
+
style: {
|
|
827
|
+
borderColor: "var(--ac-error-border, rgba(220, 38, 38, 0.25))",
|
|
828
|
+
backgroundColor: "var(--ac-error-background, rgba(220, 38, 38, 0.06))",
|
|
829
|
+
color: "var(--ac-foreground, inherit)"
|
|
830
|
+
},
|
|
831
|
+
children: [
|
|
832
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium", children: terminal ? t("conversationTooLong") : t("somethingWentWrong") }),
|
|
833
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 opacity-80", children: detail ?? (terminal ? t("conversationTooLongDesc") : t("somethingWentWrongDesc")) }),
|
|
834
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 flex flex-wrap gap-2", children: [
|
|
835
|
+
onRetry && !terminal && /* @__PURE__ */ jsxRuntime.jsx(
|
|
836
|
+
"button",
|
|
837
|
+
{
|
|
838
|
+
type: "button",
|
|
839
|
+
onClick: onRetry,
|
|
840
|
+
className: "rounded-lg px-3 py-1.5 text-sm font-medium",
|
|
841
|
+
style: {
|
|
842
|
+
backgroundColor: "var(--ac-primary, #111827)",
|
|
843
|
+
color: "var(--ac-primary-foreground, #ffffff)"
|
|
844
|
+
},
|
|
845
|
+
children: t("tryAgain")
|
|
846
|
+
}
|
|
847
|
+
),
|
|
848
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
849
|
+
"button",
|
|
850
|
+
{
|
|
851
|
+
type: "button",
|
|
852
|
+
onClick: onNewConversation,
|
|
853
|
+
className: "rounded-lg border px-3 py-1.5 text-sm font-medium",
|
|
854
|
+
style: { borderColor: "var(--ac-border, rgba(0, 0, 0, 0.15))" },
|
|
855
|
+
children: t("startNewConversation")
|
|
856
|
+
}
|
|
857
|
+
)
|
|
858
|
+
] })
|
|
859
|
+
]
|
|
860
|
+
}
|
|
861
|
+
);
|
|
862
|
+
}
|
|
798
863
|
var ChatErrorBoundary = class extends react.Component {
|
|
799
864
|
state = { error: null };
|
|
800
865
|
static getDerivedStateFromError(error) {
|
|
@@ -905,10 +970,10 @@ function DefaultUserMessage({ text }) {
|
|
|
905
970
|
}
|
|
906
971
|
function ChatInterface(props) {
|
|
907
972
|
const { showSources = false } = props;
|
|
908
|
-
const { messages, status, sendMessage, sessionId, config, newConversation: ctxNewConversation } =
|
|
909
|
-
const { t, direction } =
|
|
910
|
-
|
|
911
|
-
const slots =
|
|
973
|
+
const { messages, status, error, sendMessage, sessionId, config, retryLastTurn, newConversation: ctxNewConversation } = chunkUXVOUC2A_cjs.useChatContext();
|
|
974
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
975
|
+
chunkBYX6IOGX_cjs.useTheme();
|
|
976
|
+
const slots = chunkUXVOUC2A_cjs.useSlots();
|
|
912
977
|
let liveChat = null;
|
|
913
978
|
try {
|
|
914
979
|
liveChat = chunkDVWX2UGY_cjs.useLiveChat();
|
|
@@ -922,6 +987,16 @@ function ChatInterface(props) {
|
|
|
922
987
|
const [cartOpen, setCartOpen] = react.useState(false);
|
|
923
988
|
const [storeOrigin, _setStoreOrigin] = react.useState(null);
|
|
924
989
|
const isProcessing = status === "streaming";
|
|
990
|
+
const anchorLatestTurn = props.scrollAnchor !== "bottom";
|
|
991
|
+
const latestUserId = react.useMemo(() => {
|
|
992
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
993
|
+
const m = messages[i];
|
|
994
|
+
if (m.role !== "user") continue;
|
|
995
|
+
if (hideFirstUserMessage && i === 0) continue;
|
|
996
|
+
return m.id;
|
|
997
|
+
}
|
|
998
|
+
return void 0;
|
|
999
|
+
}, [messages, hideFirstUserMessage]);
|
|
925
1000
|
react.useEffect(() => {
|
|
926
1001
|
if (messages.length > 0 && showWelcome) setShowWelcome(false);
|
|
927
1002
|
if (messages.length === 0 && !showWelcome) setShowWelcome(true);
|
|
@@ -982,8 +1057,8 @@ function ChatInterface(props) {
|
|
|
982
1057
|
);
|
|
983
1058
|
if (showWelcome && messages.length === 0) {
|
|
984
1059
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col", dir: direction, style: { backgroundColor: "var(--ac-background)" }, children: [
|
|
985
|
-
!props.hideHeader &&
|
|
986
|
-
|
|
1060
|
+
!props.hideHeader && chunkUXVOUC2A_cjs.renderSlot("header", headerProps, ChatHeader, slots),
|
|
1061
|
+
chunkUXVOUC2A_cjs.renderSlot(
|
|
987
1062
|
"welcomePage",
|
|
988
1063
|
{
|
|
989
1064
|
onSelectCategory: handleSelectCategory,
|
|
@@ -1002,18 +1077,18 @@ function ChatInterface(props) {
|
|
|
1002
1077
|
slots
|
|
1003
1078
|
),
|
|
1004
1079
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0 px-[15px] md:px-[40px]", style: { backgroundColor: "var(--ac-background)" }, children: [
|
|
1005
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto z-40 w-full", children:
|
|
1080
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto z-40 w-full", children: chunkUXVOUC2A_cjs.renderSlot(
|
|
1006
1081
|
"input",
|
|
1007
1082
|
{ value: input, onChange: setInput, onSubmit: handleSubmit, isProcessing },
|
|
1008
1083
|
ChatInput,
|
|
1009
1084
|
slots
|
|
1010
1085
|
) }),
|
|
1011
|
-
|
|
1086
|
+
chunkUXVOUC2A_cjs.renderSlot("footer", { footerText: props.footerText }, ChatFooter, slots)
|
|
1012
1087
|
] })
|
|
1013
1088
|
] });
|
|
1014
1089
|
}
|
|
1015
1090
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col", dir: direction, style: { backgroundColor: "var(--ac-background)" }, children: [
|
|
1016
|
-
!props.hideHeader &&
|
|
1091
|
+
!props.hideHeader && chunkUXVOUC2A_cjs.renderSlot("header", headerProps, ChatHeader, slots),
|
|
1017
1092
|
storeOrigin && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1018
1093
|
CartDrawer,
|
|
1019
1094
|
{
|
|
@@ -1023,124 +1098,146 @@ function ChatInterface(props) {
|
|
|
1023
1098
|
onCartUpdate: (count) => setCartCount(count)
|
|
1024
1099
|
}
|
|
1025
1100
|
),
|
|
1026
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
"
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1101
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1102
|
+
chunkB277MAUK_cjs.Conversation,
|
|
1103
|
+
{
|
|
1104
|
+
className: "flex-1",
|
|
1105
|
+
targetScrollTop: anchorLatestTurn ? chunkB277MAUK_cjs.anchorToLatestTurn : void 0,
|
|
1106
|
+
...anchorLatestTurn ? { initial: "instant", resize: "instant" } : {},
|
|
1107
|
+
children: [
|
|
1108
|
+
anchorLatestTurn && /* @__PURE__ */ jsxRuntime.jsx(chunkB277MAUK_cjs.FollowLatestTurn, { turnKey: latestUserId }),
|
|
1109
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkB277MAUK_cjs.ConversationContent, { className: "px-[15px] md:px-[40px] py-6 sm:py-8 w-full space-y-6", children: [
|
|
1110
|
+
messages.length === 0 && chunkUXVOUC2A_cjs.renderSlot("emptyState", {}, chunkB277MAUK_cjs.ConversationEmptyState, slots),
|
|
1111
|
+
messages.map((message, messageIndex) => {
|
|
1112
|
+
if (hideFirstUserMessage && messageIndex === 0 && message.role === "user") return null;
|
|
1113
|
+
if (message.role === "system") {
|
|
1114
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: chunkUXVOUC2A_cjs.renderSlot("systemMessage", { message: message.content }, SystemMessage, slots) }, message.id);
|
|
1115
|
+
}
|
|
1116
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1117
|
+
"div",
|
|
1040
1118
|
{
|
|
1041
|
-
className: message.role === "
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1119
|
+
className: `group ${message.role === "assistant" ? "is-assistant" : "is-user"}`,
|
|
1120
|
+
...message.id === latestUserId ? { [chunkB277MAUK_cjs.LATEST_TURN_ATTR]: "" } : {},
|
|
1121
|
+
children: [
|
|
1122
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1123
|
+
chunkB277MAUK_cjs.MessageAttachments,
|
|
1124
|
+
{
|
|
1125
|
+
className: message.role === "user" ? "mb-2" : "mr-auto ml-0 mb-2",
|
|
1126
|
+
children: (message.parts || []).filter((p) => p.type === "file" && p.url).map((p, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1127
|
+
chunkB277MAUK_cjs.MessageAttachment,
|
|
1128
|
+
{
|
|
1129
|
+
className: "size-32",
|
|
1130
|
+
data: {
|
|
1131
|
+
type: "file",
|
|
1132
|
+
url: p.url,
|
|
1133
|
+
mediaType: p.mediaType ?? "",
|
|
1134
|
+
filename: p.filename
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1137
|
+
`${message.id}-file-${i}`
|
|
1138
|
+
))
|
|
1051
1139
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
})().map((part, i) => {
|
|
1068
|
-
if (part.type === "text") {
|
|
1069
|
-
if (message.role === "assistant") {
|
|
1070
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: chunk52ZHMTAA_cjs.renderSlot("assistantMessage", { message, partIndex: i, text: part.text || "" }, DefaultAssistantMessage, slots) }, `${message.id}-${i}`);
|
|
1071
|
-
}
|
|
1072
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: chunk52ZHMTAA_cjs.renderSlot("userMessage", { message, partIndex: i, text: part.text || "" }, DefaultUserMessage, slots) }, `${message.id}-${i}`);
|
|
1073
|
-
}
|
|
1074
|
-
if (part.type.startsWith("tool-")) {
|
|
1075
|
-
const toolName = part.type.replace("tool-", "");
|
|
1076
|
-
if (toolName === "requestHumanChat") return null;
|
|
1077
|
-
let output = part.output;
|
|
1078
|
-
if (typeof output === "string") {
|
|
1079
|
-
try {
|
|
1080
|
-
output = JSON.parse(output);
|
|
1081
|
-
} catch {
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
const result = output && typeof output === "object" && !Array.isArray(output) && ("data" in output || "uiRenderMode" in output) ? output : { data: output };
|
|
1085
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1086
|
-
ChatErrorBoundary,
|
|
1087
|
-
{
|
|
1088
|
-
label: `tool "${toolName}"`,
|
|
1089
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1090
|
-
chunkQ3UJEIBN_cjs.ToolRenderer,
|
|
1091
|
-
{
|
|
1092
|
-
toolName,
|
|
1093
|
-
state: part.state ?? "output-available",
|
|
1094
|
-
args: part.input ?? {},
|
|
1095
|
-
result,
|
|
1096
|
-
onSendMessage: handleSubmit,
|
|
1097
|
-
isProcessing
|
|
1140
|
+
),
|
|
1141
|
+
(() => {
|
|
1142
|
+
const parts = (message.parts || []).filter(
|
|
1143
|
+
(p) => p.type !== "file" && !(p.type === "text" && !(p.text || "").trim())
|
|
1144
|
+
);
|
|
1145
|
+
return props.messagePartOrder === "stream-order" ? parts : [...parts].sort((a, b) => {
|
|
1146
|
+
const textFirst = props.messagePartOrder !== "tools-first";
|
|
1147
|
+
if (a.type === "text" && b.type !== "text") return textFirst ? -1 : 1;
|
|
1148
|
+
if (a.type !== "text" && b.type === "text") return textFirst ? 1 : -1;
|
|
1149
|
+
return 0;
|
|
1150
|
+
});
|
|
1151
|
+
})().map((part, i) => {
|
|
1152
|
+
if (part.type === "text") {
|
|
1153
|
+
if (message.role === "assistant") {
|
|
1154
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: chunkUXVOUC2A_cjs.renderSlot("assistantMessage", { message, partIndex: i, text: part.text || "" }, DefaultAssistantMessage, slots) }, `${message.id}-${i}`);
|
|
1098
1155
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1156
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: chunkUXVOUC2A_cjs.renderSlot("userMessage", { message, partIndex: i, text: part.text || "" }, DefaultUserMessage, slots) }, `${message.id}-${i}`);
|
|
1157
|
+
}
|
|
1158
|
+
if (part.type.startsWith("tool-")) {
|
|
1159
|
+
const toolName = part.type.replace("tool-", "");
|
|
1160
|
+
if (toolName === "requestHumanChat") return null;
|
|
1161
|
+
let output = part.output;
|
|
1162
|
+
if (typeof output === "string") {
|
|
1163
|
+
try {
|
|
1164
|
+
output = JSON.parse(output);
|
|
1165
|
+
} catch {
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
const result = output && typeof output === "object" && !Array.isArray(output) && ("data" in output || "uiRenderMode" in output) ? output : { data: output };
|
|
1169
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1170
|
+
ChatErrorBoundary,
|
|
1171
|
+
{
|
|
1172
|
+
label: `tool "${toolName}"`,
|
|
1173
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1174
|
+
chunkJEK2V5I3_cjs.ToolRenderer,
|
|
1175
|
+
{
|
|
1176
|
+
toolName,
|
|
1177
|
+
state: part.state ?? "output-available",
|
|
1178
|
+
args: part.input ?? {},
|
|
1179
|
+
result,
|
|
1180
|
+
onSendMessage: handleSubmit,
|
|
1181
|
+
isProcessing
|
|
1182
|
+
}
|
|
1183
|
+
)
|
|
1184
|
+
},
|
|
1185
|
+
`${message.id}-tool-${i}`
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
return null;
|
|
1189
|
+
}),
|
|
1190
|
+
showSources && message.role === "assistant" && (() => {
|
|
1191
|
+
const kbSources = extractKbSources(message.parts);
|
|
1192
|
+
if (kbSources.length === 0) return null;
|
|
1193
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkB277MAUK_cjs.Sources, { children: [
|
|
1194
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkB277MAUK_cjs.SourcesTrigger, { count: kbSources.length }),
|
|
1195
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkB277MAUK_cjs.SourcesContent, { children: kbSources.map((s, idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1196
|
+
chunkB277MAUK_cjs.Source,
|
|
1197
|
+
{
|
|
1198
|
+
href: s.sourceUrl ?? "#",
|
|
1199
|
+
title: s.documentName || s.pageTitle || `Source ${idx + 1}`
|
|
1200
|
+
},
|
|
1201
|
+
`${message.id}-src-${idx}`
|
|
1202
|
+
)) })
|
|
1203
|
+
] });
|
|
1204
|
+
})(),
|
|
1205
|
+
message.role === "assistant" && chunkUXVOUC2A_cjs.renderSlot("feedback", {
|
|
1206
|
+
messageId: message.id,
|
|
1207
|
+
projectId: config.projectId,
|
|
1208
|
+
sessionId,
|
|
1209
|
+
apiKey: config.apiKey,
|
|
1210
|
+
apiEndpoint: config.apiEndpoint,
|
|
1211
|
+
textContent: (message.parts || []).filter((p) => p.type === "text").map((p) => p.text || "").join("\n") || (typeof message.content === "string" ? message.content : "")
|
|
1212
|
+
}, chunkB277MAUK_cjs.MessageFeedback, slots)
|
|
1213
|
+
]
|
|
1214
|
+
},
|
|
1215
|
+
message.id
|
|
1216
|
+
);
|
|
1217
|
+
}),
|
|
1218
|
+
status === "streaming" && (() => {
|
|
1219
|
+
const lastMessage = messages[messages.length - 1];
|
|
1220
|
+
if (!lastMessage || lastMessage.role !== "assistant") return true;
|
|
1221
|
+
const hasText = (lastMessage.parts || []).some(
|
|
1222
|
+
(p) => p.type === "text" && (p.text || "").trim()
|
|
1223
|
+
);
|
|
1224
|
+
const allToolsComplete = (lastMessage.parts || []).filter((p) => p.type.startsWith("tool-")).every((p) => p.state === "output-available");
|
|
1225
|
+
return allToolsComplete && !hasText;
|
|
1226
|
+
})() && /* @__PURE__ */ jsxRuntime.jsx(chunkB277MAUK_cjs.Loader, { text: t("thinking") }),
|
|
1227
|
+
status === "error" && chunkUXVOUC2A_cjs.renderSlot(
|
|
1228
|
+
"error",
|
|
1229
|
+
{
|
|
1230
|
+
error,
|
|
1231
|
+
onRetry: retryLastTurn,
|
|
1232
|
+
onNewConversation: handleNewConversation
|
|
1233
|
+
},
|
|
1234
|
+
ChatError,
|
|
1235
|
+
slots
|
|
1236
|
+
)
|
|
1237
|
+
] })
|
|
1238
|
+
]
|
|
1239
|
+
}
|
|
1240
|
+
),
|
|
1144
1241
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0 px-[15px] md:px-[40px] pb-2", style: { backgroundColor: "var(--ac-background)" }, children: [
|
|
1145
1242
|
props.pageQuestions && props.pageQuestions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1146
1243
|
QuickQuestions,
|
|
@@ -1152,7 +1249,7 @@ function ChatInterface(props) {
|
|
|
1152
1249
|
}
|
|
1153
1250
|
),
|
|
1154
1251
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto z-40 w-full flex items-end gap-2", children: [
|
|
1155
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children:
|
|
1252
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children: chunkUXVOUC2A_cjs.renderSlot(
|
|
1156
1253
|
"input",
|
|
1157
1254
|
{ value: input, onChange: setInput, onSubmit: handleSubmit, isProcessing },
|
|
1158
1255
|
ChatInput,
|
|
@@ -1169,7 +1266,7 @@ function ChatInterface(props) {
|
|
|
1169
1266
|
}
|
|
1170
1267
|
)
|
|
1171
1268
|
] }),
|
|
1172
|
-
|
|
1269
|
+
chunkUXVOUC2A_cjs.renderSlot("footer", { footerText: props.footerText }, ChatFooter, slots)
|
|
1173
1270
|
] }),
|
|
1174
1271
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-session-id": sessionId, className: "hidden" })
|
|
1175
1272
|
] });
|
|
@@ -1202,7 +1299,7 @@ function FloatingButton({
|
|
|
1202
1299
|
hideGreeting = false
|
|
1203
1300
|
}) {
|
|
1204
1301
|
const [showGreeting, setShowGreeting] = react.useState(false);
|
|
1205
|
-
const { t, direction } =
|
|
1302
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
1206
1303
|
const isRtl = direction === "rtl";
|
|
1207
1304
|
const effectiveGreeting = greeting || t("greeting");
|
|
1208
1305
|
const [greetingDismissed, setGreetingDismissed] = react.useState(false);
|
|
@@ -1375,7 +1472,7 @@ function LiveChatPanel({ isWidgetOpen, isRightSide, zIndex }) {
|
|
|
1375
1472
|
}
|
|
1376
1473
|
function MobileLiveChatDrawer() {
|
|
1377
1474
|
const lc = chunkDVWX2UGY_cjs.useLiveChat();
|
|
1378
|
-
const { t } =
|
|
1475
|
+
const { t } = chunk72QJ2ORD_cjs.useI18n();
|
|
1379
1476
|
if (!lc) return null;
|
|
1380
1477
|
const isActive = lc.state !== "ai" || lc.showIdentityForm;
|
|
1381
1478
|
const [minimized, setMinimized] = react.useState(false);
|
|
@@ -1456,7 +1553,7 @@ function isValidEmail(email) {
|
|
|
1456
1553
|
}
|
|
1457
1554
|
function IdentityView() {
|
|
1458
1555
|
const lc = useLiveChatOrThrow();
|
|
1459
|
-
const { t, direction } =
|
|
1556
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
1460
1557
|
const userInfo = lc.userInfo;
|
|
1461
1558
|
const [name, setName] = react.useState(userInfo?.name || "");
|
|
1462
1559
|
const [email, setEmail] = react.useState(userInfo?.email || "");
|
|
@@ -1534,7 +1631,7 @@ function IdentityView() {
|
|
|
1534
1631
|
}
|
|
1535
1632
|
function QueueView() {
|
|
1536
1633
|
const lc = useLiveChatOrThrow();
|
|
1537
|
-
const { t, direction } =
|
|
1634
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
1538
1635
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col items-center justify-center p-8 text-center", dir: direction, children: [
|
|
1539
1636
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-16 w-16 rounded-2xl bg-blue-50 flex items-center justify-center mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Headset, { className: "h-8 w-8 text-blue-500" }) }),
|
|
1540
1637
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 w-2 rounded-full bg-blue-500 animate-pulse mb-4" }),
|
|
@@ -1553,7 +1650,7 @@ function QueueView() {
|
|
|
1553
1650
|
}
|
|
1554
1651
|
function ChatView() {
|
|
1555
1652
|
const lc = useLiveChatOrThrow();
|
|
1556
|
-
const { t, language, direction } =
|
|
1653
|
+
const { t, language, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
1557
1654
|
const [input, setInput] = react.useState("");
|
|
1558
1655
|
const messagesEndRef = react.useRef(null);
|
|
1559
1656
|
const isRTL = direction === "rtl";
|
|
@@ -1660,7 +1757,7 @@ function ChatView() {
|
|
|
1660
1757
|
}
|
|
1661
1758
|
function EndedView() {
|
|
1662
1759
|
const lc = useLiveChatOrThrow();
|
|
1663
|
-
const { t, direction } =
|
|
1760
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
1664
1761
|
const [selected, setSelected] = react.useState(null);
|
|
1665
1762
|
const [comment, setComment] = react.useState("");
|
|
1666
1763
|
const [submitted, setSubmitted] = react.useState(false);
|
|
@@ -1808,6 +1905,7 @@ function PreviewEmbedPanel({ isOpen, isRightSide, zIndex }) {
|
|
|
1808
1905
|
}
|
|
1809
1906
|
|
|
1810
1907
|
exports.CartDrawer = CartDrawer;
|
|
1908
|
+
exports.ChatError = ChatError;
|
|
1811
1909
|
exports.ChatErrorBoundary = ChatErrorBoundary;
|
|
1812
1910
|
exports.ChatFooter = ChatFooter;
|
|
1813
1911
|
exports.ChatHeader = ChatHeader;
|
|
@@ -1820,5 +1918,5 @@ exports.PreviewEmbedPanel = PreviewEmbedPanel;
|
|
|
1820
1918
|
exports.QuickQuestions = QuickQuestions;
|
|
1821
1919
|
exports.SystemMessage = SystemMessage;
|
|
1822
1920
|
exports.WelcomePage = WelcomePage;
|
|
1823
|
-
//# sourceMappingURL=chunk-
|
|
1824
|
-
//# sourceMappingURL=chunk-
|
|
1921
|
+
//# sourceMappingURL=chunk-KHQYSEYN.cjs.map
|
|
1922
|
+
//# sourceMappingURL=chunk-KHQYSEYN.cjs.map
|