@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.
Files changed (85) hide show
  1. package/dist/{ChatInterface-2MN5cpYB.d.ts → ChatInterface-CRmM_RG_.d.ts} +9 -1
  2. package/dist/{ChatInterface-BnVyOUG5.d.cts → ChatInterface-DKF3BY42.d.cts} +9 -1
  3. package/dist/{SlotsContext-BZBi51ZT.d.ts → SlotsContext-B_087V7B.d.ts} +11 -2
  4. package/dist/{SlotsContext-D_C7zlUA.d.cts → SlotsContext-DAQiASVu.d.cts} +11 -2
  5. package/dist/ai-elements.cjs +39 -27
  6. package/dist/ai-elements.d.cts +63 -1
  7. package/dist/ai-elements.d.ts +63 -1
  8. package/dist/ai-elements.js +2 -2
  9. package/dist/{chunk-3MP2EGEJ.cjs → chunk-72QJ2ORD.cjs} +4 -2
  10. package/dist/chunk-72QJ2ORD.cjs.map +1 -0
  11. package/dist/{chunk-KTYYLZN7.cjs → chunk-B277MAUK.cjs} +76 -4
  12. package/dist/chunk-B277MAUK.cjs.map +1 -0
  13. package/dist/{chunk-P3RPAI4F.cjs → chunk-BYX6IOGX.cjs} +4 -4
  14. package/dist/{chunk-P3RPAI4F.cjs.map → chunk-BYX6IOGX.cjs.map} +1 -1
  15. package/dist/chunk-CNPYBLLT.js +81 -0
  16. package/dist/chunk-CNPYBLLT.js.map +1 -0
  17. package/dist/{chunk-FJZL33KP.js → chunk-CW6LCVNC.js} +3 -3
  18. package/dist/{chunk-FJZL33KP.js.map → chunk-CW6LCVNC.js.map} +1 -1
  19. package/dist/{chunk-D75TDRBH.js → chunk-JAEXKKSE.js} +41 -35
  20. package/dist/chunk-JAEXKKSE.js.map +1 -0
  21. package/dist/{chunk-Q3UJEIBN.cjs → chunk-JEK2V5I3.cjs} +6 -6
  22. package/dist/{chunk-Q3UJEIBN.cjs.map → chunk-JEK2V5I3.cjs.map} +1 -1
  23. package/dist/{chunk-7ESWDFF5.cjs → chunk-KHQYSEYN.cjs} +244 -146
  24. package/dist/chunk-KHQYSEYN.cjs.map +1 -0
  25. package/dist/{chunk-QYCEHFAB.js → chunk-LDQVDUUJ.js} +4 -2
  26. package/dist/chunk-LDQVDUUJ.js.map +1 -0
  27. package/dist/{chunk-5XF3NEFB.js → chunk-O5TPHZRP.js} +74 -5
  28. package/dist/chunk-O5TPHZRP.js.map +1 -0
  29. package/dist/{chunk-BWWN5LSE.js → chunk-PNUHUUA3.js} +221 -124
  30. package/dist/chunk-PNUHUUA3.js.map +1 -0
  31. package/dist/{chunk-52ZHMTAA.cjs → chunk-UXVOUC2A.cjs} +41 -35
  32. package/dist/chunk-UXVOUC2A.cjs.map +1 -0
  33. package/dist/{chunk-IU7Q7O5G.js → chunk-VQPOUMBC.js} +3 -3
  34. package/dist/{chunk-IU7Q7O5G.js.map → chunk-VQPOUMBC.js.map} +1 -1
  35. package/dist/chunk-VYBHYFG3.cjs +87 -0
  36. package/dist/chunk-VYBHYFG3.cjs.map +1 -0
  37. package/dist/components.cjs +20 -19
  38. package/dist/components.cjs.map +1 -1
  39. package/dist/components.d.cts +2 -2
  40. package/dist/components.d.ts +2 -2
  41. package/dist/components.js +8 -7
  42. package/dist/components.js.map +1 -1
  43. package/dist/core.cjs +21 -82
  44. package/dist/core.cjs.map +1 -1
  45. package/dist/core.d.cts +2 -2
  46. package/dist/core.d.ts +2 -2
  47. package/dist/core.js +2 -78
  48. package/dist/core.js.map +1 -1
  49. package/dist/hooks.cjs +9 -8
  50. package/dist/hooks.cjs.map +1 -1
  51. package/dist/hooks.d.cts +2 -2
  52. package/dist/hooks.d.ts +2 -2
  53. package/dist/hooks.js +4 -3
  54. package/dist/hooks.js.map +1 -1
  55. package/dist/i18n.cjs +5 -5
  56. package/dist/i18n.d.cts +2 -2
  57. package/dist/i18n.d.ts +2 -2
  58. package/dist/i18n.js +1 -1
  59. package/dist/index.cjs +35 -26
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.cts +28 -6
  62. package/dist/index.d.ts +28 -6
  63. package/dist/index.js +18 -13
  64. package/dist/index.js.map +1 -1
  65. package/dist/llms-full.txt +10 -10
  66. package/dist/styles.css +1 -1
  67. package/dist/theme.cjs +4 -4
  68. package/dist/theme.d.cts +1 -1
  69. package/dist/theme.d.ts +1 -1
  70. package/dist/theme.js +2 -2
  71. package/dist/tools.cjs +6 -5
  72. package/dist/tools.d.cts +2 -2
  73. package/dist/tools.d.ts +2 -2
  74. package/dist/tools.js +3 -2
  75. package/dist/{types-bsR_-fq8.d.cts → types-DRa1zFlN.d.cts} +10 -1
  76. package/dist/{types-bsR_-fq8.d.ts → types-DRa1zFlN.d.ts} +10 -1
  77. package/package.json +2 -2
  78. package/dist/chunk-3MP2EGEJ.cjs.map +0 -1
  79. package/dist/chunk-52ZHMTAA.cjs.map +0 -1
  80. package/dist/chunk-5XF3NEFB.js.map +0 -1
  81. package/dist/chunk-7ESWDFF5.cjs.map +0 -1
  82. package/dist/chunk-BWWN5LSE.js.map +0 -1
  83. package/dist/chunk-D75TDRBH.js.map +0 -1
  84. package/dist/chunk-KTYYLZN7.cjs.map +0 -1
  85. package/dist/chunk-QYCEHFAB.js.map +0 -1
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import { useAutoResize, useIsMobile, useLiveChat, usePreviewEmbed } from './chunk-P7UR37HP.js';
3
- import { useTheme } from './chunk-IU7Q7O5G.js';
4
- import { Conversation, ConversationContent, ConversationEmptyState, MessageAttachments, MessageAttachment, Sources, SourcesTrigger, SourcesContent, Source, MessageFeedback, Loader } from './chunk-5XF3NEFB.js';
5
- import { useI18n } from './chunk-QYCEHFAB.js';
6
- import { ToolRenderer } from './chunk-FJZL33KP.js';
7
- import { useChatContext, useSlots, renderSlot } from './chunk-D75TDRBH.js';
3
+ import { useTheme } from './chunk-VQPOUMBC.js';
4
+ import { Conversation, anchorToLatestTurn, FollowLatestTurn, ConversationContent, ConversationEmptyState, MessageAttachments, MessageAttachment, Sources, SourcesTrigger, SourcesContent, Source, MessageFeedback, LATEST_TURN_ATTR, Loader } from './chunk-O5TPHZRP.js';
5
+ import { useI18n } from './chunk-LDQVDUUJ.js';
6
+ import { ToolRenderer } from './chunk-CW6LCVNC.js';
7
+ import { useChatContext, useSlots, renderSlot } from './chunk-JAEXKKSE.js';
8
8
  import { cn } from './chunk-3RW7O444.js';
9
9
  import { memo, useState, useRef, useEffect, useCallback, Component, useMemo } from 'react';
10
10
  import { X, ArrowLeft, ShoppingCart, Plus, Ticket, FerrisWheel, Flag, Building, Heart, Star, Calendar, MapPin, Hotel, Coffee, Utensils, Settings, Users, FileText, HelpCircle, Search, Zap, MessageSquare, Shield, Minus, Trash2, Headset, Send, ThumbsUp, ThumbsDown, ExternalLink, SparklesIcon } from 'lucide-react';
@@ -793,6 +793,71 @@ function SystemMessage({ message, type }) {
793
793
  const displayMessage = translateMessage(message, type);
794
794
  return /* @__PURE__ */ jsx("div", { className: "flex justify-center my-3", children: /* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground bg-muted px-4 py-1.5 rounded-full border border-border/50", children: displayMessage }) });
795
795
  }
796
+ function serverMessage(error) {
797
+ const raw = error?.message?.trim();
798
+ if (!raw || !raw.startsWith("{")) return null;
799
+ try {
800
+ const parsed = JSON.parse(raw);
801
+ const message = typeof parsed.error === "string" ? parsed.error.trim() : "";
802
+ return message || null;
803
+ } catch {
804
+ return null;
805
+ }
806
+ }
807
+ function isTerminal(error) {
808
+ const raw = error?.message ?? "";
809
+ if (/too_many_messages|message_too_long|request_too_large/.test(raw)) {
810
+ return true;
811
+ }
812
+ return /conversation too long|request too large|message too long/i.test(raw);
813
+ }
814
+ function ChatError({ error, onRetry, onNewConversation }) {
815
+ const { t, direction } = useI18n();
816
+ const terminal = isTerminal(error);
817
+ const detail = serverMessage(error);
818
+ return /* @__PURE__ */ jsxs(
819
+ "div",
820
+ {
821
+ role: "alert",
822
+ dir: direction,
823
+ className: "mx-auto w-full max-w-[520px] rounded-xl border px-4 py-3 text-sm",
824
+ style: {
825
+ borderColor: "var(--ac-error-border, rgba(220, 38, 38, 0.25))",
826
+ backgroundColor: "var(--ac-error-background, rgba(220, 38, 38, 0.06))",
827
+ color: "var(--ac-foreground, inherit)"
828
+ },
829
+ children: [
830
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: terminal ? t("conversationTooLong") : t("somethingWentWrong") }),
831
+ /* @__PURE__ */ jsx("p", { className: "mt-1 opacity-80", children: detail ?? (terminal ? t("conversationTooLongDesc") : t("somethingWentWrongDesc")) }),
832
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 flex flex-wrap gap-2", children: [
833
+ onRetry && !terminal && /* @__PURE__ */ jsx(
834
+ "button",
835
+ {
836
+ type: "button",
837
+ onClick: onRetry,
838
+ className: "rounded-lg px-3 py-1.5 text-sm font-medium",
839
+ style: {
840
+ backgroundColor: "var(--ac-primary, #111827)",
841
+ color: "var(--ac-primary-foreground, #ffffff)"
842
+ },
843
+ children: t("tryAgain")
844
+ }
845
+ ),
846
+ /* @__PURE__ */ jsx(
847
+ "button",
848
+ {
849
+ type: "button",
850
+ onClick: onNewConversation,
851
+ className: "rounded-lg border px-3 py-1.5 text-sm font-medium",
852
+ style: { borderColor: "var(--ac-border, rgba(0, 0, 0, 0.15))" },
853
+ children: t("startNewConversation")
854
+ }
855
+ )
856
+ ] })
857
+ ]
858
+ }
859
+ );
860
+ }
796
861
  var ChatErrorBoundary = class extends Component {
797
862
  state = { error: null };
798
863
  static getDerivedStateFromError(error) {
@@ -903,7 +968,7 @@ function DefaultUserMessage({ text }) {
903
968
  }
904
969
  function ChatInterface(props) {
905
970
  const { showSources = false } = props;
906
- const { messages, status, sendMessage, sessionId, config, newConversation: ctxNewConversation } = useChatContext();
971
+ const { messages, status, error, sendMessage, sessionId, config, retryLastTurn, newConversation: ctxNewConversation } = useChatContext();
907
972
  const { t, direction } = useI18n();
908
973
  useTheme();
909
974
  const slots = useSlots();
@@ -920,6 +985,16 @@ function ChatInterface(props) {
920
985
  const [cartOpen, setCartOpen] = useState(false);
921
986
  const [storeOrigin, _setStoreOrigin] = useState(null);
922
987
  const isProcessing = status === "streaming";
988
+ const anchorLatestTurn = props.scrollAnchor !== "bottom";
989
+ const latestUserId = useMemo(() => {
990
+ for (let i = messages.length - 1; i >= 0; i--) {
991
+ const m = messages[i];
992
+ if (m.role !== "user") continue;
993
+ if (hideFirstUserMessage && i === 0) continue;
994
+ return m.id;
995
+ }
996
+ return void 0;
997
+ }, [messages, hideFirstUserMessage]);
923
998
  useEffect(() => {
924
999
  if (messages.length > 0 && showWelcome) setShowWelcome(false);
925
1000
  if (messages.length === 0 && !showWelcome) setShowWelcome(true);
@@ -1021,124 +1096,146 @@ function ChatInterface(props) {
1021
1096
  onCartUpdate: (count) => setCartCount(count)
1022
1097
  }
1023
1098
  ),
1024
- /* @__PURE__ */ jsx(Conversation, { className: "flex-1", children: /* @__PURE__ */ jsxs(ConversationContent, { className: "px-[15px] md:px-[40px] py-6 sm:py-8 w-full space-y-6", children: [
1025
- messages.length === 0 && renderSlot("emptyState", {}, ConversationEmptyState, slots),
1026
- messages.map((message, messageIndex) => {
1027
- if (hideFirstUserMessage && messageIndex === 0 && message.role === "user") return null;
1028
- if (message.role === "system") {
1029
- return /* @__PURE__ */ jsx("div", { children: renderSlot("systemMessage", { message: message.content }, SystemMessage, slots) }, message.id);
1030
- }
1031
- return /* @__PURE__ */ jsxs(
1032
- "div",
1033
- {
1034
- className: `group ${message.role === "assistant" ? "is-assistant" : "is-user"}`,
1035
- children: [
1036
- /* @__PURE__ */ jsx(
1037
- MessageAttachments,
1099
+ /* @__PURE__ */ jsxs(
1100
+ Conversation,
1101
+ {
1102
+ className: "flex-1",
1103
+ targetScrollTop: anchorLatestTurn ? anchorToLatestTurn : void 0,
1104
+ ...anchorLatestTurn ? { initial: "instant", resize: "instant" } : {},
1105
+ children: [
1106
+ anchorLatestTurn && /* @__PURE__ */ jsx(FollowLatestTurn, { turnKey: latestUserId }),
1107
+ /* @__PURE__ */ jsxs(ConversationContent, { className: "px-[15px] md:px-[40px] py-6 sm:py-8 w-full space-y-6", children: [
1108
+ messages.length === 0 && renderSlot("emptyState", {}, ConversationEmptyState, slots),
1109
+ messages.map((message, messageIndex) => {
1110
+ if (hideFirstUserMessage && messageIndex === 0 && message.role === "user") return null;
1111
+ if (message.role === "system") {
1112
+ return /* @__PURE__ */ jsx("div", { children: renderSlot("systemMessage", { message: message.content }, SystemMessage, slots) }, message.id);
1113
+ }
1114
+ return /* @__PURE__ */ jsxs(
1115
+ "div",
1038
1116
  {
1039
- className: message.role === "user" ? "mb-2" : "mr-auto ml-0 mb-2",
1040
- children: (message.parts || []).filter((p) => p.type === "file" && p.url).map((p, i) => /* @__PURE__ */ jsx(
1041
- MessageAttachment,
1042
- {
1043
- className: "size-32",
1044
- data: {
1045
- type: "file",
1046
- url: p.url,
1047
- mediaType: p.mediaType ?? "",
1048
- filename: p.filename
1117
+ className: `group ${message.role === "assistant" ? "is-assistant" : "is-user"}`,
1118
+ ...message.id === latestUserId ? { [LATEST_TURN_ATTR]: "" } : {},
1119
+ children: [
1120
+ /* @__PURE__ */ jsx(
1121
+ MessageAttachments,
1122
+ {
1123
+ className: message.role === "user" ? "mb-2" : "mr-auto ml-0 mb-2",
1124
+ children: (message.parts || []).filter((p) => p.type === "file" && p.url).map((p, i) => /* @__PURE__ */ jsx(
1125
+ MessageAttachment,
1126
+ {
1127
+ className: "size-32",
1128
+ data: {
1129
+ type: "file",
1130
+ url: p.url,
1131
+ mediaType: p.mediaType ?? "",
1132
+ filename: p.filename
1133
+ }
1134
+ },
1135
+ `${message.id}-file-${i}`
1136
+ ))
1049
1137
  }
1050
- },
1051
- `${message.id}-file-${i}`
1052
- ))
1053
- }
1054
- ),
1055
- (() => {
1056
- const parts = (message.parts || []).filter(
1057
- (p) => p.type !== "file" && !(p.type === "text" && !(p.text || "").trim())
1058
- );
1059
- return props.messagePartOrder === "stream-order" ? parts : [...parts].sort((a, b) => {
1060
- const textFirst = props.messagePartOrder !== "tools-first";
1061
- if (a.type === "text" && b.type !== "text") return textFirst ? -1 : 1;
1062
- if (a.type !== "text" && b.type === "text") return textFirst ? 1 : -1;
1063
- return 0;
1064
- });
1065
- })().map((part, i) => {
1066
- if (part.type === "text") {
1067
- if (message.role === "assistant") {
1068
- return /* @__PURE__ */ jsx("div", { children: renderSlot("assistantMessage", { message, partIndex: i, text: part.text || "" }, DefaultAssistantMessage, slots) }, `${message.id}-${i}`);
1069
- }
1070
- return /* @__PURE__ */ jsx("div", { children: renderSlot("userMessage", { message, partIndex: i, text: part.text || "" }, DefaultUserMessage, slots) }, `${message.id}-${i}`);
1071
- }
1072
- if (part.type.startsWith("tool-")) {
1073
- const toolName = part.type.replace("tool-", "");
1074
- if (toolName === "requestHumanChat") return null;
1075
- let output = part.output;
1076
- if (typeof output === "string") {
1077
- try {
1078
- output = JSON.parse(output);
1079
- } catch {
1080
- }
1081
- }
1082
- const result = output && typeof output === "object" && !Array.isArray(output) && ("data" in output || "uiRenderMode" in output) ? output : { data: output };
1083
- return /* @__PURE__ */ jsx(
1084
- ChatErrorBoundary,
1085
- {
1086
- label: `tool "${toolName}"`,
1087
- children: /* @__PURE__ */ jsx(
1088
- ToolRenderer,
1089
- {
1090
- toolName,
1091
- state: part.state ?? "output-available",
1092
- args: part.input ?? {},
1093
- result,
1094
- onSendMessage: handleSubmit,
1095
- isProcessing
1138
+ ),
1139
+ (() => {
1140
+ const parts = (message.parts || []).filter(
1141
+ (p) => p.type !== "file" && !(p.type === "text" && !(p.text || "").trim())
1142
+ );
1143
+ return props.messagePartOrder === "stream-order" ? parts : [...parts].sort((a, b) => {
1144
+ const textFirst = props.messagePartOrder !== "tools-first";
1145
+ if (a.type === "text" && b.type !== "text") return textFirst ? -1 : 1;
1146
+ if (a.type !== "text" && b.type === "text") return textFirst ? 1 : -1;
1147
+ return 0;
1148
+ });
1149
+ })().map((part, i) => {
1150
+ if (part.type === "text") {
1151
+ if (message.role === "assistant") {
1152
+ return /* @__PURE__ */ jsx("div", { children: renderSlot("assistantMessage", { message, partIndex: i, text: part.text || "" }, DefaultAssistantMessage, slots) }, `${message.id}-${i}`);
1096
1153
  }
1097
- )
1098
- },
1099
- `${message.id}-tool-${i}`
1100
- );
1101
- }
1102
- return null;
1103
- }),
1104
- showSources && message.role === "assistant" && (() => {
1105
- const kbSources = extractKbSources(message.parts);
1106
- if (kbSources.length === 0) return null;
1107
- return /* @__PURE__ */ jsxs(Sources, { children: [
1108
- /* @__PURE__ */ jsx(SourcesTrigger, { count: kbSources.length }),
1109
- /* @__PURE__ */ jsx(SourcesContent, { children: kbSources.map((s, idx) => /* @__PURE__ */ jsx(
1110
- Source,
1111
- {
1112
- href: s.sourceUrl ?? "#",
1113
- title: s.documentName || s.pageTitle || `Source ${idx + 1}`
1114
- },
1115
- `${message.id}-src-${idx}`
1116
- )) })
1117
- ] });
1118
- })(),
1119
- message.role === "assistant" && renderSlot("feedback", {
1120
- messageId: message.id,
1121
- projectId: config.projectId,
1122
- sessionId,
1123
- apiKey: config.apiKey,
1124
- apiEndpoint: config.apiEndpoint,
1125
- textContent: (message.parts || []).filter((p) => p.type === "text").map((p) => p.text || "").join("\n") || (typeof message.content === "string" ? message.content : "")
1126
- }, MessageFeedback, slots)
1127
- ]
1128
- },
1129
- message.id
1130
- );
1131
- }),
1132
- status === "streaming" && (() => {
1133
- const lastMessage = messages[messages.length - 1];
1134
- if (!lastMessage || lastMessage.role !== "assistant") return true;
1135
- const hasText = (lastMessage.parts || []).some(
1136
- (p) => p.type === "text" && (p.text || "").trim()
1137
- );
1138
- const allToolsComplete = (lastMessage.parts || []).filter((p) => p.type.startsWith("tool-")).every((p) => p.state === "output-available");
1139
- return allToolsComplete && !hasText;
1140
- })() && /* @__PURE__ */ jsx(Loader, { text: t("thinking") })
1141
- ] }) }),
1154
+ return /* @__PURE__ */ jsx("div", { children: renderSlot("userMessage", { message, partIndex: i, text: part.text || "" }, DefaultUserMessage, slots) }, `${message.id}-${i}`);
1155
+ }
1156
+ if (part.type.startsWith("tool-")) {
1157
+ const toolName = part.type.replace("tool-", "");
1158
+ if (toolName === "requestHumanChat") return null;
1159
+ let output = part.output;
1160
+ if (typeof output === "string") {
1161
+ try {
1162
+ output = JSON.parse(output);
1163
+ } catch {
1164
+ }
1165
+ }
1166
+ const result = output && typeof output === "object" && !Array.isArray(output) && ("data" in output || "uiRenderMode" in output) ? output : { data: output };
1167
+ return /* @__PURE__ */ jsx(
1168
+ ChatErrorBoundary,
1169
+ {
1170
+ label: `tool "${toolName}"`,
1171
+ children: /* @__PURE__ */ jsx(
1172
+ ToolRenderer,
1173
+ {
1174
+ toolName,
1175
+ state: part.state ?? "output-available",
1176
+ args: part.input ?? {},
1177
+ result,
1178
+ onSendMessage: handleSubmit,
1179
+ isProcessing
1180
+ }
1181
+ )
1182
+ },
1183
+ `${message.id}-tool-${i}`
1184
+ );
1185
+ }
1186
+ return null;
1187
+ }),
1188
+ showSources && message.role === "assistant" && (() => {
1189
+ const kbSources = extractKbSources(message.parts);
1190
+ if (kbSources.length === 0) return null;
1191
+ return /* @__PURE__ */ jsxs(Sources, { children: [
1192
+ /* @__PURE__ */ jsx(SourcesTrigger, { count: kbSources.length }),
1193
+ /* @__PURE__ */ jsx(SourcesContent, { children: kbSources.map((s, idx) => /* @__PURE__ */ jsx(
1194
+ Source,
1195
+ {
1196
+ href: s.sourceUrl ?? "#",
1197
+ title: s.documentName || s.pageTitle || `Source ${idx + 1}`
1198
+ },
1199
+ `${message.id}-src-${idx}`
1200
+ )) })
1201
+ ] });
1202
+ })(),
1203
+ message.role === "assistant" && renderSlot("feedback", {
1204
+ messageId: message.id,
1205
+ projectId: config.projectId,
1206
+ sessionId,
1207
+ apiKey: config.apiKey,
1208
+ apiEndpoint: config.apiEndpoint,
1209
+ textContent: (message.parts || []).filter((p) => p.type === "text").map((p) => p.text || "").join("\n") || (typeof message.content === "string" ? message.content : "")
1210
+ }, MessageFeedback, slots)
1211
+ ]
1212
+ },
1213
+ message.id
1214
+ );
1215
+ }),
1216
+ status === "streaming" && (() => {
1217
+ const lastMessage = messages[messages.length - 1];
1218
+ if (!lastMessage || lastMessage.role !== "assistant") return true;
1219
+ const hasText = (lastMessage.parts || []).some(
1220
+ (p) => p.type === "text" && (p.text || "").trim()
1221
+ );
1222
+ const allToolsComplete = (lastMessage.parts || []).filter((p) => p.type.startsWith("tool-")).every((p) => p.state === "output-available");
1223
+ return allToolsComplete && !hasText;
1224
+ })() && /* @__PURE__ */ jsx(Loader, { text: t("thinking") }),
1225
+ status === "error" && renderSlot(
1226
+ "error",
1227
+ {
1228
+ error,
1229
+ onRetry: retryLastTurn,
1230
+ onNewConversation: handleNewConversation
1231
+ },
1232
+ ChatError,
1233
+ slots
1234
+ )
1235
+ ] })
1236
+ ]
1237
+ }
1238
+ ),
1142
1239
  /* @__PURE__ */ jsxs("div", { className: "shrink-0 px-[15px] md:px-[40px] pb-2", style: { backgroundColor: "var(--ac-background)" }, children: [
1143
1240
  props.pageQuestions && props.pageQuestions.length > 0 && /* @__PURE__ */ jsx(
1144
1241
  QuickQuestions,
@@ -1805,6 +1902,6 @@ function PreviewEmbedPanel({ isOpen, isRightSide, zIndex }) {
1805
1902
  );
1806
1903
  }
1807
1904
 
1808
- export { CartDrawer, ChatErrorBoundary, ChatFooter, ChatHeader, ChatInput, ChatInterface, FloatingButton, LiveChatPanel, MobileLiveChatDrawer, PreviewEmbedPanel, QuickQuestions, SystemMessage, WelcomePage };
1809
- //# sourceMappingURL=chunk-BWWN5LSE.js.map
1810
- //# sourceMappingURL=chunk-BWWN5LSE.js.map
1905
+ export { CartDrawer, ChatError, ChatErrorBoundary, ChatFooter, ChatHeader, ChatInput, ChatInterface, FloatingButton, LiveChatPanel, MobileLiveChatDrawer, PreviewEmbedPanel, QuickQuestions, SystemMessage, WelcomePage };
1906
+ //# sourceMappingURL=chunk-PNUHUUA3.js.map
1907
+ //# sourceMappingURL=chunk-PNUHUUA3.js.map