@burdenoff/website-sdk 2026.1102.1 → 2026.1102.3

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 (46) hide show
  1. package/README.md +50 -2
  2. package/dist/avatar-live-view/index.d.mts +18 -4
  3. package/dist/avatar-live-view/index.d.ts +18 -4
  4. package/dist/avatar-live-view/index.js +1348 -266
  5. package/dist/avatar-live-view/index.js.map +1 -1
  6. package/dist/avatar-live-view/index.mjs +1346 -264
  7. package/dist/avatar-live-view/index.mjs.map +1 -1
  8. package/dist/{chunk-OIQHIGGU.js → chunk-7O2I32ZN.js} +2 -2
  9. package/dist/chunk-7O2I32ZN.js.map +1 -0
  10. package/dist/{chunk-R742FS5E.js → chunk-DZLUZKOX.js} +19 -17
  11. package/dist/{chunk-R742FS5E.js.map → chunk-DZLUZKOX.js.map} +1 -1
  12. package/dist/{chunk-QOHPLTGT.mjs → chunk-K3QZGJEH.mjs} +2 -2
  13. package/dist/chunk-K3QZGJEH.mjs.map +1 -0
  14. package/dist/{chunk-SK5UGG6A.js → chunk-P5GMVPR6.js} +76 -20
  15. package/dist/chunk-P5GMVPR6.js.map +1 -0
  16. package/dist/{chunk-EUPFS6MZ.mjs → chunk-SMD7MEEA.mjs} +76 -20
  17. package/dist/chunk-SMD7MEEA.mjs.map +1 -0
  18. package/dist/{chunk-ETI2HQEC.mjs → chunk-ZWEEBHXJ.mjs} +4 -4
  19. package/dist/{chunk-ETI2HQEC.mjs.map → chunk-ZWEEBHXJ.mjs.map} +1 -1
  20. package/dist/components/explore.d.mts +2 -2
  21. package/dist/components/explore.d.ts +2 -2
  22. package/dist/components/explore.js +14 -14
  23. package/dist/components/explore.mjs +2 -2
  24. package/dist/{explore-DUTNYUOm.d.mts → explore-DaSNdm4O.d.mts} +1 -1
  25. package/dist/{explore-DjQE7Xia.d.ts → explore-DtSPdlEy.d.ts} +1 -1
  26. package/dist/{explore-avatar-live-config-C1ILEcY8.d.ts → explore-avatar-live-config-CAfN5eAX.d.ts} +9 -3
  27. package/dist/{explore-avatar-live-config-D-hO90-A.d.mts → explore-avatar-live-config-N4WhJzgS.d.mts} +9 -3
  28. package/dist/{explore-types-Bb2Ih3d8.d.mts → explore-types-Ol1Mm3dW.d.mts} +12 -1
  29. package/dist/{explore-types-Bb2Ih3d8.d.ts → explore-types-Ol1Mm3dW.d.ts} +12 -1
  30. package/dist/hooks/index.d.mts +2 -2
  31. package/dist/hooks/index.d.ts +2 -2
  32. package/dist/hooks/index.js +9 -9
  33. package/dist/hooks/index.mjs +1 -1
  34. package/dist/index.d.mts +15 -9
  35. package/dist/index.d.ts +15 -9
  36. package/dist/index.js +93 -63
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.mjs +36 -6
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/{use-explore-chat-DunjG-3p.d.ts → use-explore-chat-B3dOOvJN.d.ts} +43 -3
  41. package/dist/{use-explore-chat-zRuoAin6.d.mts → use-explore-chat-CbfohA9O.d.mts} +43 -3
  42. package/package.json +1 -1
  43. package/dist/chunk-EUPFS6MZ.mjs.map +0 -1
  44. package/dist/chunk-OIQHIGGU.js.map +0 -1
  45. package/dist/chunk-QOHPLTGT.mjs.map +0 -1
  46. package/dist/chunk-SK5UGG6A.js.map +0 -1
@@ -746,6 +746,7 @@ function useExploreChat(options = {}) {
746
746
  const [remainingToday, setRemainingToday] = useState(null);
747
747
  const [focusProduct, setFocusProductState] = useState(null);
748
748
  const [turnCount, setTurnCount] = useState(0);
749
+ const [resent, setResent] = useState(null);
749
750
  const messagesRef = useRef([]);
750
751
  const [archive, setArchive] = useState([]);
751
752
  const [hydrated, setHydrated] = useState(false);
@@ -766,6 +767,7 @@ function useExploreChat(options = {}) {
766
767
  const lastSentAttachmentsRef = useRef(
767
768
  []
768
769
  );
770
+ const lastSentSurfaceRef = useRef(null);
769
771
  const inFlightRef = useRef(false);
770
772
  catalogRef.current = catalog;
771
773
  const rememberConversationToken = useCallback((token) => {
@@ -1014,7 +1016,7 @@ function useExploreChat(options = {}) {
1014
1016
  [client, pollIntervalMs, pollTimeoutMs]
1015
1017
  );
1016
1018
  const submit = useCallback(
1017
- async (text, optimisticId, captchaAttempt, attachments) => {
1019
+ async (text, optimisticId, captchaAttempt, attachments, surface, replaces) => {
1018
1020
  const activeCatalog = catalogRef.current;
1019
1021
  let recaptchaToken;
1020
1022
  if (activeCatalog.captchaRequired && activeCatalog.recaptchaSiteKey) {
@@ -1033,27 +1035,27 @@ function useExploreChat(options = {}) {
1033
1035
  ...recaptchaToken ? { recaptchaToken } : {},
1034
1036
  ...locale ? { locale } : {},
1035
1037
  ...pageUrl ? { pageUrl } : {},
1036
- ...attachments.length > 0 ? { attachments: [...attachments] } : {}
1038
+ ...attachments.length > 0 ? { attachments: [...attachments] } : {},
1039
+ ...surface !== null ? { surface } : {}
1037
1040
  };
1038
1041
  const res = await client.mutate(
1039
1042
  SEND_EXPLORE_MESSAGE_MUTATION,
1040
1043
  { input },
1041
1044
  { timeoutMs: SEND_REQUEST_TIMEOUT_MS }
1042
1045
  );
1043
- if (!mountedRef.current) return;
1046
+ if (!mountedRef.current) return null;
1044
1047
  const first = res.errors?.[0];
1045
1048
  const result = res.data?.sendExploreMessage;
1046
1049
  if (first || !result) {
1047
1050
  const code = typeof first?.extensions?.code === "string" ? first.extensions.code : void 0;
1048
1051
  const classified = classifyExploreError(code, first?.message);
1049
1052
  if (classified.kind === "captcha" && captchaAttempt === 0) {
1050
- await submit(text, optimisticId, 1, attachments);
1051
- return;
1053
+ return submit(text, optimisticId, 1, attachments, surface, replaces);
1052
1054
  }
1053
1055
  inFlightRef.current = false;
1054
1056
  setError(classified);
1055
1057
  setPhase(classified.kind === "rate-limit" ? "limited" : "error");
1056
- return;
1058
+ return null;
1057
1059
  }
1058
1060
  rememberConversationToken(result.conversation.token);
1059
1061
  turnCountRef.current = result.conversation.turnCount;
@@ -1065,6 +1067,15 @@ function useExploreChat(options = {}) {
1065
1067
  const replaced = prev.some((m) => m.id === optimisticId) ? prev.map((m) => m.id === optimisticId ? userMessage : m) : [...prev, userMessage];
1066
1068
  return [...replaced, assistantMessage];
1067
1069
  });
1070
+ if (replaces !== null) {
1071
+ setResent({
1072
+ replacedMessageIds: [...replaces, optimisticId],
1073
+ sent: {
1074
+ userMessageId: userMessage.id,
1075
+ conversationToken: result.conversation.token
1076
+ }
1077
+ });
1078
+ }
1068
1079
  if (assistantMessage.status === "COMPLETED" || assistantMessage.status === "FAILED") {
1069
1080
  inFlightRef.current = false;
1070
1081
  if (assistantMessage.status === "FAILED") {
@@ -1076,10 +1087,11 @@ function useExploreChat(options = {}) {
1076
1087
  } else {
1077
1088
  setPhase("ready");
1078
1089
  }
1079
- return;
1090
+ return userMessage.id;
1080
1091
  }
1081
1092
  setPhase("streaming");
1082
1093
  startPolling(result.conversation.token, assistantMessage.id);
1094
+ return userMessage.id;
1083
1095
  },
1084
1096
  [
1085
1097
  client,
@@ -1090,16 +1102,17 @@ function useExploreChat(options = {}) {
1090
1102
  startPolling
1091
1103
  ]
1092
1104
  );
1093
- const send = useCallback(
1094
- async (message, attachments = []) => {
1105
+ const sendQuestion = useCallback(
1106
+ async (message, attachments, options2, replaces) => {
1095
1107
  const text = message.trim();
1096
- if (!text) return;
1097
- if (inFlightRef.current) return;
1108
+ const surface = options2.surface ?? null;
1109
+ if (!text) return null;
1110
+ if (inFlightRef.current) return null;
1098
1111
  const activeCatalog = catalogRef.current;
1099
1112
  if (!activeCatalog.enabled) {
1100
1113
  setError(classifyExploreError("EXPLORE_DISABLED"));
1101
1114
  setPhase("disabled");
1102
- return;
1115
+ return null;
1103
1116
  }
1104
1117
  if (text.length > activeCatalog.limits.maxMessageLength) {
1105
1118
  setError({
@@ -1108,7 +1121,7 @@ function useExploreChat(options = {}) {
1108
1121
  message: `That message is ${text.length} characters \u2014 the limit is ${activeCatalog.limits.maxMessageLength}.`,
1109
1122
  retryable: false
1110
1123
  });
1111
- return;
1124
+ return null;
1112
1125
  }
1113
1126
  if (turnCountRef.current >= activeCatalog.limits.maxTurnsPerConversation) {
1114
1127
  setError({
@@ -1117,11 +1130,12 @@ function useExploreChat(options = {}) {
1117
1130
  message: `This conversation has reached its ${activeCatalog.limits.maxTurnsPerConversation}-message limit. Start a new chat to keep going.`,
1118
1131
  retryable: false
1119
1132
  });
1120
- return;
1133
+ return null;
1121
1134
  }
1122
1135
  inFlightRef.current = true;
1123
1136
  lastSentTextRef.current = text;
1124
1137
  lastSentAttachmentsRef.current = attachments;
1138
+ lastSentSurfaceRef.current = surface;
1125
1139
  setError(null);
1126
1140
  setPhase("sending");
1127
1141
  cancelPolling();
@@ -1140,21 +1154,47 @@ function useExploreChat(options = {}) {
1140
1154
  completedAt: (/* @__PURE__ */ new Date()).toISOString()
1141
1155
  };
1142
1156
  setMessages((prev) => [...prev, optimistic]);
1157
+ if (replaces !== null) {
1158
+ setResent({
1159
+ replacedMessageIds: replaces,
1160
+ sent: {
1161
+ userMessageId: optimistic.id,
1162
+ conversationToken: conversationTokenRef.current
1163
+ }
1164
+ });
1165
+ }
1143
1166
  turnCountRef.current += 1;
1144
1167
  setTurnCount(turnCountRef.current);
1145
1168
  onSend?.(text);
1169
+ let userMessageId = optimistic.id;
1146
1170
  try {
1147
- await submit(text, optimistic.id, 0, attachments);
1171
+ userMessageId = await submit(
1172
+ text,
1173
+ optimistic.id,
1174
+ 0,
1175
+ attachments,
1176
+ surface,
1177
+ replaces
1178
+ ) ?? optimistic.id;
1148
1179
  } catch (err) {
1149
- if (!mountedRef.current) return;
1180
+ if (!mountedRef.current) return null;
1150
1181
  console.error("[WebSDK] Explore send failed", err);
1151
1182
  inFlightRef.current = false;
1152
1183
  setError(classifyExploreError("NETWORK_ERROR"));
1153
1184
  setPhase("error");
1154
1185
  }
1186
+ if (!mountedRef.current) return null;
1187
+ return {
1188
+ userMessageId,
1189
+ conversationToken: conversationTokenRef.current
1190
+ };
1155
1191
  },
1156
1192
  [cancelPolling, onSend, submit]
1157
1193
  );
1194
+ const send = useCallback(
1195
+ (message, attachments = [], options2 = {}) => sendQuestion(message, attachments, options2, null),
1196
+ [sendQuestion]
1197
+ );
1158
1198
  const stop = useCallback(() => {
1159
1199
  cancelPolling();
1160
1200
  inFlightRef.current = false;
@@ -1183,6 +1223,13 @@ function useExploreChat(options = {}) {
1183
1223
  if (!text) return;
1184
1224
  cancelPolling();
1185
1225
  inFlightRef.current = false;
1226
+ const shown = [...messagesRef.current];
1227
+ const lastShown = shown[shown.length - 1];
1228
+ if (lastShown?.role === "ASSISTANT" && lastShown.status === "FAILED") {
1229
+ shown.pop();
1230
+ }
1231
+ const priorShown = shown[shown.length - 1];
1232
+ const replaces = priorShown?.role === "USER" && priorShown.content === text ? [priorShown.id] : null;
1186
1233
  setMessages((prev) => {
1187
1234
  const next = [...prev];
1188
1235
  const last = next[next.length - 1];
@@ -1193,8 +1240,14 @@ function useExploreChat(options = {}) {
1193
1240
  });
1194
1241
  turnCountRef.current = Math.max(0, turnCountRef.current - 1);
1195
1242
  setTurnCount(turnCountRef.current);
1196
- void send(text, lastSentAttachmentsRef.current);
1197
- }, [cancelPolling, send]);
1243
+ const surface = lastSentSurfaceRef.current;
1244
+ void sendQuestion(
1245
+ text,
1246
+ lastSentAttachmentsRef.current,
1247
+ surface === null ? {} : { surface },
1248
+ replaces
1249
+ );
1250
+ }, [cancelPolling, sendQuestion]);
1198
1251
  const reset = useCallback(() => {
1199
1252
  setArchive(
1200
1253
  upsertArchive(storageKey, {
@@ -1208,9 +1261,11 @@ function useExploreChat(options = {}) {
1208
1261
  rememberConversationToken(null);
1209
1262
  lastSentTextRef.current = null;
1210
1263
  lastSentAttachmentsRef.current = [];
1264
+ lastSentSurfaceRef.current = null;
1211
1265
  turnCountRef.current = 0;
1212
1266
  setTurnCount(0);
1213
1267
  setMessages([]);
1268
+ setResent(null);
1214
1269
  setError(null);
1215
1270
  setRemainingToday(null);
1216
1271
  setPhase(catalogRef.current.enabled ? "ready" : "disabled");
@@ -1413,6 +1468,7 @@ function useExploreChat(options = {}) {
1413
1468
  send,
1414
1469
  stop,
1415
1470
  retry,
1471
+ resent,
1416
1472
  reset,
1417
1473
  canSend,
1418
1474
  history: archive,
@@ -2015,5 +2071,5 @@ function useSpeechOutput({
2015
2071
  }
2016
2072
 
2017
2073
  export { BAKED_CATALOG_ELEMENT_ID, DEFAULT_EXPLORE_EXAMPLE_PROMPTS, ECOSYSTEM_PRODUCTS, ESCALATE_EXPLORE_CONVERSATION_MUTATION, EXPLORE_CATALOG_QUERY, EXPLORE_CATALOG_QUERY_WITHOUT_HIGHLIGHTS, EXPLORE_ESCALATION_NOTE_SOFT_MAX, EXPLORE_FEEDBACK_COMMENT_SOFT_MAX, EXPLORE_FEEDBACK_REASONS, EXPLORE_MESSAGE_QUERY, FALLBACK_EXPLORE_LIMITS, SEND_EXPLORE_MESSAGE_MUTATION, bakedCatalogLocale, classifyExploreError, looksLikeDeliverableEmail, serializeBakedCatalog, stopSpeaking, useExploreChat, useProgressiveReveal, useSpeechInput, useSpeechOutput };
2018
- //# sourceMappingURL=chunk-EUPFS6MZ.mjs.map
2019
- //# sourceMappingURL=chunk-EUPFS6MZ.mjs.map
2074
+ //# sourceMappingURL=chunk-SMD7MEEA.mjs.map
2075
+ //# sourceMappingURL=chunk-SMD7MEEA.mjs.map