@eshal-bot/chat-widget 0.1.99 → 0.1.101

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-BHNeh4MK.esm.js";import"react";import"react-dom/client";import"react-dom";import"react/jsx-runtime";
1
+ export{S as default}from"./chat-widget-index-B5VwIIEZ.esm.js";import"react";import"react-dom/client";import"react-dom";import"react/jsx-runtime";
@@ -7880,6 +7880,13 @@
7880
7880
  TEXT_CHUNK: 'text_chunk',
7881
7881
  PROCESSING_END: 'processing_end',
7882
7882
  COMPLETE: 'complete',
7883
+ // EV-2872: suggestion chips delivered AFTER `complete` on the same
7884
+ // stream (the backend no longer blocks the composer unlock on chip
7885
+ // generation). Carries a `prompts` array; attaches to the last
7886
+ // assistant message. Wire value matches @eshal/shared's
7887
+ // StreamEventType.FOLLOW_UP_PROMPTS (the frontend's ChatService.ts
7888
+ // already handled it).
7889
+ FOLLOW_UP_PROMPTS: 'follow_up_prompts',
7883
7890
  ERROR: 'error',
7884
7891
  HUMAN_DECISION_REQUIRED: 'human_decision_required'
7885
7892
  };
@@ -8322,6 +8329,26 @@
8322
8329
  updateFinalMessage(setMessages, finalContent, metadata);
8323
8330
  break;
8324
8331
  }
8332
+ case StreamEventType.FOLLOW_UP_PROMPTS:
8333
+ {
8334
+ // EV-2872: trailing chips chunk - arrives after COMPLETE. Attach to
8335
+ // the finalized assistant message (same shape updateFinalMessage
8336
+ // stores from the complete chunk).
8337
+ const latePrompts = Array.isArray(streamEvent.prompts) ? streamEvent.prompts : [];
8338
+ if (latePrompts.length > 0) {
8339
+ setMessages(prev => {
8340
+ const updated = [...(prev || [])];
8341
+ const lastMsg = updated[updated.length - 1];
8342
+ if (lastMsg && lastMsg.role === 'assistant') {
8343
+ updated[updated.length - 1] = _objectSpread2(_objectSpread2({}, lastMsg), {}, {
8344
+ prompts: normalizePrompts(latePrompts)
8345
+ });
8346
+ }
8347
+ return updated;
8348
+ });
8349
+ }
8350
+ break;
8351
+ }
8325
8352
  case StreamEventType.ERROR:
8326
8353
  addErrorMessage(setMessages, streamEvent.error || 'Unknown error occurred');
8327
8354
  break;
@@ -8464,6 +8491,32 @@
8464
8491
  continue;
8465
8492
  }
8466
8493
 
8494
+ // EV-2872: trailing chips chunk. The backend now emits `complete`
8495
+ // WITHOUT waiting for suggestion-chip generation (the composer
8496
+ // unlocks at last-token time) and delivers the chips afterwards
8497
+ // as their own {type:'follow_up_prompts'} chunk on the same
8498
+ // stream. Attach them to the already-finalized assistant
8499
+ // message. Turns where chip generation timed out simply never
8500
+ // send this chunk.
8501
+ if (parsed.type === 'follow_up_prompts') {
8502
+ const latePrompts = Array.isArray(parsed.prompts) ? parsed.prompts : [];
8503
+ if (latePrompts.length > 0) {
8504
+ setMessages(prev => {
8505
+ const updated = [...(prev || [])];
8506
+ const lastMsg = updated[updated.length - 1];
8507
+ if (lastMsg && lastMsg.role === 'assistant') {
8508
+ // Same storage shape updateFinalMessage uses on the
8509
+ // complete chunk: message.prompts, normalized.
8510
+ updated[updated.length - 1] = _objectSpread2(_objectSpread2({}, lastMsg), {}, {
8511
+ prompts: normalizePrompts(latePrompts)
8512
+ });
8513
+ }
8514
+ return updated;
8515
+ });
8516
+ }
8517
+ continue;
8518
+ }
8519
+
8467
8520
  // Handle text_chunk events
8468
8521
  if (parsed.type === 'text_chunk') {
8469
8522
  var _parsed$choices2;
@@ -8915,6 +8968,34 @@
8915
8968
  return classes.filter(Boolean).join(' ');
8916
8969
  };
8917
8970
 
8971
+ /**
8972
+ * EV-2977: what an auto-prompt chip DISPLAYS.
8973
+ *
8974
+ * Each auto-prompt has a dual output: `text` (short title-case label,
8975
+ * e.g. "Geidea Accept Payments") and `submitText` (the full natural
8976
+ * question, e.g. "How do I accept payments?") which is what actually
8977
+ * gets submitted on click. Product decision: the web widget shows the
8978
+ * natural question (Perplexity/ChatGPT-style follow-ups) instead of
8979
+ * the label. Display-only - the SUBMIT value and the prompt payload
8980
+ * (`text`, `submitText`) are untouched.
8981
+ *
8982
+ * Kill-switch: `behavior.autoPromptQuestionDisplay` (default true).
8983
+ * When false - or when `submitText` is absent/identical - falls back
8984
+ * to the label, i.e. the pre-EV-2977 rendering.
8985
+ *
8986
+ * @param {{text?: string, submitText?: string}|string} prompt
8987
+ * @param {boolean} [questionDisplay=true]
8988
+ * @returns {string}
8989
+ */
8990
+ const getPromptDisplayText = function (prompt) {
8991
+ let questionDisplay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
8992
+ if (!prompt || typeof prompt === 'string') return prompt || '';
8993
+ const label = typeof prompt.text === 'string' ? prompt.text : '';
8994
+ if (!questionDisplay) return label;
8995
+ const question = typeof prompt.submitText === 'string' ? prompt.submitText.trim() : '';
8996
+ return question && question !== label ? question : label;
8997
+ };
8998
+
8918
8999
  /**
8919
9000
  * Constructs the voice WebSocket base URL.
8920
9001
  *
@@ -17099,7 +17180,11 @@
17099
17180
  promptFontSize,
17100
17181
  isDark,
17101
17182
  isRtl,
17102
- t
17183
+ t,
17184
+ // EV-2977: show the natural question (submitText) on the chip face
17185
+ // instead of the title-case label. Display-only; see
17186
+ // getPromptDisplayText. Kill-switch: behavior.autoPromptQuestionDisplay.
17187
+ questionDisplay = true
17103
17188
  } = _ref;
17104
17189
  const scrollRef = reactExports.useRef(null);
17105
17190
  const [canScrollLeft, setCanScrollLeft] = reactExports.useState(false);
@@ -17182,7 +17267,7 @@
17182
17267
  fontFamily: promptFontFamily,
17183
17268
  fontSize: promptFontSize
17184
17269
  },
17185
- children: p.text || p
17270
+ children: getPromptDisplayText(p, questionDisplay)
17186
17271
  }, "".concat(p.text || p, "-").concat(index)))
17187
17272
  }), /*#__PURE__*/jsxRuntimeExports.jsx("button", {
17188
17273
  type: "button",
@@ -17244,6 +17329,10 @@
17244
17329
  userTextColor,
17245
17330
  promptSuggestions,
17246
17331
  onPromptSuggestionClick,
17332
+ // EV-2977: chip face shows the natural question (submitText) instead
17333
+ // of the title-case label. Kill-switch per deployment via
17334
+ // behavior.autoPromptQuestionDisplay; default on.
17335
+ autoPromptQuestionDisplay = true,
17247
17336
  // Inline tag selector, rendered at the top of the input card in the
17248
17337
  // same slot as PromptSuggestionsRow. Mutually exclusive with prompt
17249
17338
  // suggestions in practice (tag selector only shows before the user
@@ -17527,6 +17616,7 @@
17527
17616
  children: [tagSelectorNode ? tagSelectorNode : promptSuggestions.length > 0 && onPromptSuggestionClick && /*#__PURE__*/jsxRuntimeExports.jsx(PromptSuggestionsRow, {
17528
17617
  suggestions: promptSuggestions,
17529
17618
  onSuggestionClick: onPromptSuggestionClick,
17619
+ questionDisplay: autoPromptQuestionDisplay,
17530
17620
  promptPrimary: promptPrimary,
17531
17621
  promptTextColor: promptTextColor,
17532
17622
  promptFontFamily: promptFontFamily,
@@ -18821,6 +18911,10 @@
18821
18911
  onboardingEnabled = false,
18822
18912
  onResetConversation,
18823
18913
  autoPromptEnabled = true,
18914
+ // EV-2977: auto-prompt chips display the natural question
18915
+ // (submitText) instead of the title-case label. Display-only;
18916
+ // kill-switch via behavior.autoPromptQuestionDisplay (default on).
18917
+ autoPromptQuestionDisplay = true,
18824
18918
  allowFeedback = true,
18825
18919
  provideCitations = true,
18826
18920
  onFeedback,
@@ -19644,6 +19738,7 @@
19644
19738
  userTextColor: userTextColor,
19645
19739
  promptSuggestions: showResolveForm || isConversationResolved || autoPromptEnabled === false || isLoading ? [] : stablePromptSuggestions,
19646
19740
  onPromptSuggestionClick: stableOnPromptSuggestionClick,
19741
+ autoPromptQuestionDisplay: autoPromptQuestionDisplay,
19647
19742
  tagSelectorNode: null,
19648
19743
  showResolveButton: isCsatEnabled && hasUserMessages && !isConversationResolved && !showResolveForm && !showCsat && !shouldHideResolveForOnboarding,
19649
19744
  onResolve: () => {
@@ -19985,7 +20080,7 @@
19985
20080
 
19986
20081
  // Map API response to widget props (use props as overrides if provided)
19987
20082
  const widgetConfig = reactExports.useMemo(() => {
19988
- var _agentConfig$config, _cfg$identity, _cfg$branding, _cfg$typography, _cfg$messages, _cfg$voice, _cfg$onboarding, _cfg$disclaimer, _cfg$csat, _cfg$inactivity, _cfg$behavior, _cfg$security, _cfg$layout, _ref2, _messages$bundles$loc, _messages$bundles, _messages$bundles$en, _messages$bundles2, _ref3, _ref4, _security$domains, _ref5, _ref6, _ref7, _branding$chatbotAvat, _branding$chatbotAvat2, _ref8, _ref9, _ref0, _ref1, _ref10, _ref11, _ref12, _ref13, _typography$headerTex, _identity$subtitle, _identity$showStatus, _identity$statusMode, _identity$officeHours, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _inactivity$timeoutVa, _inactivity$timeoutUn, _ref20, _ref21, _ref22, _ref23, _ref24, _ref25, _ref26, _ref27, _csat$enabled, _csat$format, _csat$prompt, _csat$triggerType, _csat$idleTimeoutMins, _csat$followUpEnabled, _csat$followUpPrompt, _behavior$autoPromptE, _behavior$allowFeedba, _behavior$provideCita, _agentConfig$organiza, _cfg$chatFeatures;
20083
+ var _agentConfig$config, _cfg$identity, _cfg$branding, _cfg$typography, _cfg$messages, _cfg$voice, _cfg$onboarding, _cfg$disclaimer, _cfg$csat, _cfg$inactivity, _cfg$behavior, _cfg$security, _cfg$layout, _ref2, _messages$bundles$loc, _messages$bundles, _messages$bundles$en, _messages$bundles2, _ref3, _ref4, _security$domains, _ref5, _ref6, _ref7, _branding$chatbotAvat, _branding$chatbotAvat2, _ref8, _ref9, _ref0, _ref1, _ref10, _ref11, _ref12, _ref13, _typography$headerTex, _identity$subtitle, _identity$showStatus, _identity$statusMode, _identity$officeHours, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _inactivity$timeoutVa, _inactivity$timeoutUn, _ref20, _ref21, _ref22, _ref23, _ref24, _ref25, _ref26, _ref27, _csat$enabled, _csat$format, _csat$prompt, _csat$triggerType, _csat$idleTimeoutMins, _csat$followUpEnabled, _csat$followUpPrompt, _behavior$autoPromptE, _behavior$autoPromptQ, _behavior$allowFeedba, _behavior$provideCita, _agentConfig$organiza, _cfg$chatFeatures;
19989
20084
  if (!agentConfig) {
19990
20085
  return null;
19991
20086
  }
@@ -20080,6 +20175,11 @@
20080
20175
  csatFollowUpEnabled: (_csat$followUpEnabled = csat.followUpEnabled) !== null && _csat$followUpEnabled !== void 0 ? _csat$followUpEnabled : false,
20081
20176
  csatFollowUpPrompt: (_csat$followUpPrompt = csat.followUpPrompt) !== null && _csat$followUpPrompt !== void 0 ? _csat$followUpPrompt : null,
20082
20177
  autoPromptEnabled: (_behavior$autoPromptE = behavior.autoPromptEnabled) !== null && _behavior$autoPromptE !== void 0 ? _behavior$autoPromptE : true,
20178
+ // EV-2977: chip face shows the natural follow-up question
20179
+ // (submitText) instead of the title-case label. Display-only
20180
+ // (submit payload untouched). Kill-switch per deployment: set
20181
+ // behavior.autoPromptQuestionDisplay=false to revert to labels.
20182
+ autoPromptQuestionDisplay: (_behavior$autoPromptQ = behavior.autoPromptQuestionDisplay) !== null && _behavior$autoPromptQ !== void 0 ? _behavior$autoPromptQ : true,
20083
20183
  allowFeedback: (_behavior$allowFeedba = behavior.allowFeedback) !== null && _behavior$allowFeedba !== void 0 ? _behavior$allowFeedba : true,
20084
20184
  // behavior.provideCitations - when false, hide the Sources panel on
20085
20185
  // every message and tell the backend to skip citation generation.
@@ -20377,6 +20477,7 @@
20377
20477
  onboardingEnabled: widgetConfig.onboardingEnabled,
20378
20478
  onResetConversation: resetConversation,
20379
20479
  autoPromptEnabled: widgetConfig.autoPromptEnabled,
20480
+ autoPromptQuestionDisplay: widgetConfig.autoPromptQuestionDisplay,
20380
20481
  allowFeedback: widgetConfig.allowFeedback,
20381
20482
  provideCitations: widgetConfig.provideCitations,
20382
20483
  onFeedback: handleMessageFeedback,