@eshal-bot/chat-widget 0.2.51 → 0.2.52

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.
@@ -1 +1 @@
1
- export{S as default}from"./chat-widget-index-NZXHxR3K.esm.js";import"react";import"react-dom/client";import"react/jsx-runtime";import"react-dom";
1
+ export{S as default}from"./chat-widget-index-BZbPoQVV.esm.js";import"react";import"react-dom/client";import"react/jsx-runtime";import"react-dom";
@@ -13444,6 +13444,40 @@
13444
13444
  return true;
13445
13445
  }
13446
13446
 
13447
+ /**
13448
+ * The call socket message a verify card sends once the caller's code checked
13449
+ * out: voice-runtime (serializer.verification_turn) makes it the caller's
13450
+ * next turn and resumes the held call with it. The code itself went from the
13451
+ * card to the server's identity route, never over the call. Null when the
13452
+ * card names no held call, so nothing half-formed is sent.
13453
+ * Mirrors packages/frontend/src/components/chatbot-preview/voiceCard.ts.
13454
+ */
13455
+ function verificationResumeMessage(text, card) {
13456
+ const toolCallId = String(card?.tool_call_id || "").trim();
13457
+ if (!toolCallId) return null;
13458
+ const verificationComplete = {
13459
+ tool_call_id: toolCallId
13460
+ };
13461
+ const invocationId = String(card?.invocation_id || "").trim();
13462
+ if (invocationId) verificationComplete.invocation_id = invocationId;
13463
+ return JSON.stringify({
13464
+ type: "verification_complete",
13465
+ text: String(text || "").trim(),
13466
+ verificationComplete
13467
+ });
13468
+ }
13469
+
13470
+ /**
13471
+ * A click on the call screen's card: a verify card whose code checked out
13472
+ * resumes the held call (never typed as the caller's words), a web address
13473
+ * opens in a new tab, anything else is the caller's next turn.
13474
+ * `send` is { resume(text, card), say(text) }.
13475
+ * Mirrors packages/frontend/src/components/chatbot-preview/voiceCard.ts.
13476
+ */
13477
+ function routeCallCardAction(text, extra, send, open) {
13478
+ if (extra?.verificationComplete) send.resume?.(text, extra.verificationComplete);else if (!openCardLink(text, open)) send.say?.(text);
13479
+ }
13480
+
13447
13481
  /**
13448
13482
  * Replies the widget never streamed itself.
13449
13483
  *
@@ -16987,6 +17021,23 @@
16987
17021
  setInputValue("");
16988
17022
  }, []);
16989
17023
 
17024
+ // A verify card on the call screen whose code checked out: the held call
17025
+ // resumes over the call socket. Not drawn as the caller's words, as in the
17026
+ // chat (EV-4942): the caller entered a code, they did not say this.
17027
+ const sendBidiVerificationComplete = reactExports.useCallback((text, card) => {
17028
+ const message = verificationResumeMessage(text, card);
17029
+ if (!message) return;
17030
+ const ws = websocketRef.current;
17031
+ if (!ws || ws.readyState !== WebSocket.OPEN) {
17032
+ if (!voiceCreditsExhaustedRef.current) setVoiceError("voiceUnavailable");
17033
+ return;
17034
+ }
17035
+ userHasSpokenRef.current = true;
17036
+ ws.send(message);
17037
+ updateActivity(organizationId);
17038
+ setIsLoading(true);
17039
+ }, []);
17040
+
16990
17041
  // Cleanup on unmount
16991
17042
  reactExports.useEffect(() => {
16992
17043
  isVoiceSessionActiveRef.current = isVoiceSessionActive;
@@ -17311,6 +17362,7 @@
17311
17362
  handleVoiceToggle,
17312
17363
  toggleVoicePause,
17313
17364
  sendBidiTextMessage,
17365
+ sendBidiVerificationComplete,
17314
17366
  // Session lifecycle
17315
17367
  sessionExpiringSoon,
17316
17368
  resetConversation,
@@ -23423,7 +23475,7 @@
23423
23475
  isRtl: isRtl,
23424
23476
  fontFamily: fontFamily,
23425
23477
  provideCitations: false,
23426
- onButtonClick: value => onCardAction?.(String(value ?? ""))
23478
+ onButtonClick: (value, _label, extra) => onCardAction?.(String(value ?? ""), extra)
23427
23479
  })
23428
23480
  })
23429
23481
  }, card)
@@ -23999,6 +24051,7 @@
23999
24051
  onToggleVoicePause,
24000
24052
  voiceLevelSource,
24001
24053
  onBidiTextMessage,
24054
+ onBidiVerificationComplete,
24002
24055
  disclaimerEnabled = false,
24003
24056
  disclaimerText,
24004
24057
  disclaimerPosition = "top",
@@ -24294,11 +24347,13 @@
24294
24347
  // While a voice call is live the body becomes the call screen; when it
24295
24348
  // ends the chat returns with the call's lines kept as messages.
24296
24349
  const showCallView = isVoiceSessionActive;
24297
- // A card button on the call screen: a web address (a payment or check-in
24298
- // link) opens in a new tab, anything else is the caller's next turn.
24299
- const handleVoiceCardAction = reactExports.useCallback(value => {
24300
- if (!openCardLink(value)) onBidiTextMessage?.(value);
24301
- }, [onBidiTextMessage]);
24350
+ // A card button on the call screen: a verify card's confirmed code resumes
24351
+ // the held call over the call, a web address (a payment or check-in link)
24352
+ // opens in a new tab, anything else is the caller's next turn.
24353
+ const handleVoiceCardAction = reactExports.useCallback((value, extra) => routeCallCardAction(value, extra, {
24354
+ resume: onBidiVerificationComplete,
24355
+ say: onBidiTextMessage
24356
+ }), [onBidiTextMessage, onBidiVerificationComplete]);
24302
24357
  // EV-3813: voiceError is an i18n code (lib/voiceErrors.js), resolved the
24303
24358
  // way ChatInput resolves it.
24304
24359
  const voiceErrorText = voiceError ? t(voiceError) === voiceError ? t("voiceUnavailable") : t(voiceError) : null;
@@ -25342,7 +25397,7 @@
25342
25397
  * value by its own test (that constant sat at 0.1.113 while this package was
25343
25398
  * at 0.2.2 precisely because nothing enforced it - EV-2431).
25344
25399
  */
25345
- const WIDGET_VERSION = '0.2.51';
25400
+ const WIDGET_VERSION = '0.2.52';
25346
25401
 
25347
25402
  /**
25348
25403
  * API utility functions
@@ -25768,6 +25823,7 @@
25768
25823
  voiceConclusionForCsat,
25769
25824
  handleVoiceToggle,
25770
25825
  sendBidiTextMessage,
25826
+ sendBidiVerificationComplete,
25771
25827
  bidiMessages,
25772
25828
  isVoicePaused,
25773
25829
  toggleVoicePause,
@@ -25996,6 +26052,7 @@
25996
26052
  onToggleVoicePause: toggleVoicePause,
25997
26053
  voiceLevelSource: voiceLevelSource,
25998
26054
  onBidiTextMessage: sendBidiTextMessage,
26055
+ onBidiVerificationComplete: sendBidiVerificationComplete,
25999
26056
  disclaimerEnabled: widgetConfig.disclaimerEnabled,
26000
26057
  disclaimerText: widgetConfig.disclaimerText,
26001
26058
  disclaimerPosition: widgetConfig.disclaimerPosition,