@cimulate/copilot-widget 1.58.2 → 1.60.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  `@cimulate/copilot-widget` follows [Semantic Versioning](https://semver.org/). Each entry is a released `package.json` version (deployed on merge to `master`), newest first.
4
4
 
5
+ ## 1.60.1 — 2026-11-23
6
+
7
+ - Early shopper messages are answered in cases that previously dropped them: a late welcome treated as the reply, a resumed conversation with no agent message, and a joined chatbot that never sends a welcome. A brand-new conversation still waits so a late welcome is not treated as the reply. If the chatbot never joins, the send fails after 12 seconds.
8
+
9
+ ## 1.60.0 — 2026-11-20
10
+
11
+ - Messaging adds `eventHandlers.browsingHistory.set/get/clear`. With `enablePageContext` on, storefronts can send the shopper's recent storefront events as `browsing_history` in `commerce_agent_context`.
12
+
13
+ ## 1.59.0 — 2026-11-18
14
+
15
+ - Internal foundation for localization support. All visible and accessible widget labels are now routed through a translation catalog with English (`en-US`) as the default fallback. Full multi-locale support — including locale JSON files and the `translations` prop — is coming in a future release.
16
+
5
17
  ## 1.58.2 - 2026-11-19
6
18
 
7
19
  - Delay the Copilot socket connection until the widget first opens; keep it connected through closing and minimizing.
package/README.md CHANGED
@@ -273,9 +273,9 @@ to `AgentForceWidget.theme`. Component examples live in Storybook under
273
273
  **Theming/Product components**, with Legacy, Commerce, and Custom stories and
274
274
  controls for preset, density, shape, elevation, and tokens.
275
275
 
276
- Themes control appearance and structure, not wording. Continue to supply
277
- connection copy through `messagingConfig.connectingMessages` and header content
278
- through `headerConfig`. This change does not introduce a localization API.
276
+ Themes control appearance and structure, not wording. Supply connection copy
277
+ through `messagingConfig.connectingMessages` and header content through
278
+ `headerConfig`. Multi-locale support is coming soon — see the **Localization** section.
279
279
 
280
280
  The new Commerce default follows a neutral white/gray/charcoal appearance. Orange
281
281
  is reserved for selected product variants. The Custom playground option is a
@@ -630,6 +630,22 @@ select a look.
630
630
  TypeScript contracts are in `src/themes/types.ts`; preset values are in
631
631
  `src/themes/presets.ts`; exact trait scales are in `src/themes/traits.ts`.
632
632
 
633
+ ### Messaging Browsing History
634
+
635
+ `eventHandlers.browsingHistory` sends the shopper's recent storefront events as `browsing_history` in the same `commerce_agent_context` variable as page context, on every text message. Pass `{ events }`, or a function the widget calls at send time so each turn carries the latest history:
636
+
637
+ ```ts
638
+ import { eventHandlers } from "@cimulate/copilot-widget/messaging";
639
+
640
+ eventHandlers.browsingHistory.set(() => ({ events: readRecentEvents() }));
641
+
642
+ eventHandlers.browsingHistory.clear();
643
+ ```
644
+
645
+ [`@cimulate/shopper-events`](https://www.npmjs.com/package/@cimulate/shopper-events) records these events; pass `toAgentContext()?.browsing_history` from it.
646
+
647
+ The history is sent only when `messagingConfig.enablePageContext` is on, with or without page context. If the function throws or returns no `events` array, nothing is sent for that turn.
648
+
633
649
  ### Messaging Cart
634
650
 
635
651
  Messaging integrations push the shopper's current basket with `eventHandlers.cart.update`. Call it from the messaging entry only: `window.CimulateMessaging.eventHandlers.cart.update(cart)` on the CDN, or the NPM import below. The Copilot entry does not expose it.
@@ -682,6 +698,74 @@ Implement `get`, `add`, `quantity`, `remove`, and `coupon` in `storefrontCartAct
682
698
 
683
699
  Optionally set `messagingConfig.storefrontCartPageUrl` to embed your cart page, or `headerConfig.actions.cart: false` to hide the header cart button; the summary’s View Cart still works. A registered `overrides.Cart` replaces the iframe and built-in cart, including the widget’s express pay and checkout.
684
700
 
701
+ ## Localization
702
+
703
+ > **Coming soon.** Multi-locale support is under active development and is not yet available in a released version. The widget currently renders English (`en-US`) only. This section documents the planned API — do not use it in production yet.
704
+
705
+ The widget will ship with English (`en-US`) copy embedded in the bundle. All visible and accessible labels will fall back to English when no catalog is supplied. A `translations` prop will let you switch languages or override individual strings.
706
+
707
+ ### Supported locales (planned)
708
+
709
+ 17 locale catalogs will be distributed alongside the bundle. Planned locale codes: `da-DK`, `de-DE`, `en-US`, `es-ES`, `es-MX`, `fi-FI`, `fr-FR`, `it-IT`, `ja-JP`, `ko-KR`, `nb-NO`, `nl-NL`, `pl`, `pt-BR`, `sv-SE`, `zh-CN`, `zh-TW`.
710
+
711
+ ### Fallback chain (planned)
712
+
713
+ ```
714
+ translations prop → en-US.json defaults
715
+ ```
716
+
717
+ The merge will be per-namespace. Passing `translations={{ launcher: { ... } }}` will override only `launcher` keys; all other namespaces use English. Any key absent from both the supplied object and `en-US.json` renders as an empty string.
718
+
719
+ ### Authoring guide: adding new strings
720
+
721
+ Follow these steps when a new visible or accessible label is added to a widget component.
722
+
723
+ **1. Add the key to `WidgetMessageCatalog`** in `src/models/translations.ts`:
724
+
725
+ Place it in the nearest existing namespace, or create a new namespace interface. Mark the field optional (`?`). Document `{placeholder}` interpolation tokens in JSDoc only if the value is non-obvious.
726
+
727
+ ```ts
728
+ // In the SearchBarMessages interface:
729
+ /** aria-label for the clear-history button; shown to screen-reader users only */
730
+ clearHistoryAriaLabel?: string;
731
+ ```
732
+
733
+ **2. Add the English default to `src/static/locales/en-US.json`** under the matching namespace key:
734
+
735
+ ```json
736
+ {
737
+ "searchBar": {
738
+ "clearHistoryAriaLabel": "Clear conversation history"
739
+ }
740
+ }
741
+ ```
742
+
743
+ **3. Read the new key in the component** via `useTranslations()`:
744
+
745
+ ```tsx
746
+ const t = useTranslations();
747
+ // ...
748
+ <button aria-label={t.searchBar.clearHistoryAriaLabel}>...</button>;
749
+ ```
750
+
751
+ **4. Send the new key to the localization team** with the English value and any `{placeholder}` token descriptions. They add it to the 16 non-English locale files. Until translations land, every locale falls back to the English value automatically.
752
+
753
+ > **Interpolation tokens:** Use `{variableName}` in the JSON string and call `interpolate(t.namespace.key, { variableName: value })` in the component. Import `interpolate` from `@contexts/translations`.
754
+
755
+ #### Key naming conventions
756
+
757
+ Use lower camelCase. Apply the suffix that matches the string's role so its purpose is self-evident without reading the component:
758
+
759
+ | Suffix | Used for | Example |
760
+ | -------------------- | ------------------------------------------------------------ | ------------------------------------ |
761
+ | _(none)_ | Visible rendered text (button labels, headings, body copy) | `cart.checkout`, `common.cancel` |
762
+ | `AriaLabel` | `aria-label` attribute — read by screen readers, not visible | `cart.decreaseQuantityAriaLabel` |
763
+ | `Alt` | `alt=""` on `<img>` elements | `cart.productImageAlt` |
764
+ | `Title` | `title=""` tooltip attribute | `searchBar.cancelRequestTitle` |
765
+ | `placeholder` prefix | `placeholder=""` on `<input>` / `<textarea>` | `searchBar.placeholderAskUsAnything` |
766
+
767
+ The namespace already provides context, so the key only needs to name the element, not repeat the namespace. For example `jumpToLatest.jumpToLatestAriaLabel` is correct — `jumpToLatest.ariaLabel` alone is ambiguous when reading the catalog in isolation.
768
+
685
769
  ## Linting and pre-commit hooks
686
770
 
687
771
  Lint and format locally with the npm scripts:
@@ -328,6 +328,13 @@ declare interface CopilotWidgetProps extends CimCopilotSdkConfig {
328
328
  * Configuration for messaging mode. Required when mode is 'messaging'.
329
329
  */
330
330
  messagingConfig?: MessagingModeConfig;
331
+ /**
332
+ * Translated or customized widget copy. Pass a full locale catalog (e.g.
333
+ * imported from `@cimulate/copilot-widget/locales/fr-FR`) or a partial
334
+ * object to override individual strings. Any key omitted falls back to the
335
+ * bundled English (`en-US`) default.
336
+ */
337
+ translations?: WidgetMessageCatalog;
331
338
  overrides?: ComponentOverrides;
332
339
  overridesUrl?: string;
333
340
  inlineOverrides?: ComponentOverrides;
@@ -352,7 +359,7 @@ declare interface CopilotWidgetProps extends CimCopilotSdkConfig {
352
359
  * PromptsExtensionContext >
353
360
  * CopilotProvider (SocketSdk: copilot-sdk)
354
361
  */
355
- declare const CopilotWidgetProvider: ({ mode, apiKey, apiToken, baseUrl, customerId, tenantId, logoUrl, headerText, headerConfig, theme, openLinksInNewTab, onNavigate, globalClassName, isDevelopment, componentType, componentConfig, entryType, initialEntry, entryMessage, disclaimerText, disclaimerMarkdown, clientContext, baseCatalogParams, searchPlaceholder, searchButtonLabel, searchConfig, suggestionButtonConfig, messageAlignment, autoScroll, promptsConfig, resetConversationMessage, conversationHistory, onConnect, onCopilotEvent, onRefinedSearch, onRefinedBrowse, __features, children, }: CopilotWidgetProps & {
362
+ declare const CopilotWidgetProvider: ({ mode, apiKey, apiToken, baseUrl, customerId, tenantId, logoUrl, headerText, headerConfig, theme, openLinksInNewTab, onNavigate, globalClassName, isDevelopment, componentType, componentConfig, entryType, initialEntry, entryMessage, disclaimerText, disclaimerMarkdown, clientContext, baseCatalogParams, searchPlaceholder, searchButtonLabel, searchConfig, suggestionButtonConfig, messageAlignment, autoScroll, promptsConfig, resetConversationMessage, conversationHistory, onConnect, onCopilotEvent, onRefinedSearch, onRefinedBrowse, translations, __features, children, }: CopilotWidgetProps & {
356
363
  children: ReactNode;
357
364
  }) => JSX_2.Element;
358
365
 
@@ -925,6 +932,287 @@ declare interface WidgetComponentConfig {
925
932
  };
926
933
  }
927
934
 
935
+ /**
936
+ * Locale-keyed catalog of every widget-owned UI string.
937
+ *
938
+ * Pass a partial catalog as the `messages` prop on `CopilotWidget` or
939
+ * `AgentForceWidget`. Each key is optional — omitted keys fall back to
940
+ * the locale catalog default and then to the bundled English default.
941
+ *
942
+ * String values that contain `{placeholder}` tokens are interpolated at
943
+ * runtime by the widget's `interpolate(template, params)` utility before
944
+ * they are rendered.
945
+ */
946
+ declare interface WidgetMessageCatalog {
947
+ common?: {
948
+ close?: string;
949
+ cancel?: string;
950
+ retry?: string;
951
+ dismiss?: string;
952
+ remove?: string;
953
+ search?: string;
954
+ checkout?: string;
955
+ moreOptions?: string;
956
+ conversation?: string;
957
+ };
958
+ controls?: {
959
+ /** `{componentType}` */
960
+ overflowMenuAriaLabel?: string;
961
+ clearChat?: string;
962
+ clearChatMenu?: string;
963
+ downloadTranscript?: string;
964
+ endConversation?: string;
965
+ toggleMinimizeAriaLabel?: string;
966
+ minimize?: string;
967
+ expandAriaLabel?: string;
968
+ showModal?: string;
969
+ collapseAriaLabel?: string;
970
+ /** `{previousComponentType}` */
971
+ showDialog?: string;
972
+ showDialogFallback?: string;
973
+ toggleFullscreen?: string;
974
+ moveRight?: string;
975
+ moveLeft?: string;
976
+ };
977
+ launcher?: {
978
+ openCommerceClientAriaLabel?: string;
979
+ openCopilotAriaLabel?: string;
980
+ logoAlt?: string;
981
+ };
982
+ header?: {
983
+ defaultHeaderTextCopilot?: string;
984
+ defaultHeaderTextMessaging?: string;
985
+ };
986
+ loading?: {
987
+ loadingCopilot?: string;
988
+ loadingResponse?: string;
989
+ reconnecting?: string;
990
+ addingToCart?: string;
991
+ connectingToAgent?: string;
992
+ };
993
+ connecting?: {
994
+ /** Shown for `layoutPreset="standard"`. */
995
+ default?: readonly string[];
996
+ /** Shown for `layoutPreset="commerce"`. */
997
+ commerce?: readonly string[];
998
+ loadingShoppingAssistantAriaLabel?: string;
999
+ loadingShoppingAssistantHeading?: string;
1000
+ connectingToAssistantAriaLabel?: string;
1001
+ connectedToAssistant?: string;
1002
+ disconnectedFromAssistant?: string;
1003
+ };
1004
+ searchBar?: {
1005
+ placeholderAskUsAnything?: string;
1006
+ placeholderAskAQuestion?: string;
1007
+ connectToHumanAriaLabel?: string;
1008
+ connectToHumanSentMessage?: string;
1009
+ currentPageContextAriaLabel?: string;
1010
+ searchCopilotAriaLabel?: string;
1011
+ cancelProcessingAriaLabel?: string;
1012
+ cancelRequestTitle?: string;
1013
+ sendMessageAriaLabel?: string;
1014
+ };
1015
+ imageAttachment?: {
1016
+ uploadImageAriaLabel?: string;
1017
+ removeImageLabel?: string;
1018
+ /** `{fileName}` */
1019
+ previewAlt?: string;
1020
+ /** `{maxImageMb}` */
1021
+ fileSizeExceeded?: string;
1022
+ fileSizeExceeded10mb?: string;
1023
+ unsupportedFileType?: string;
1024
+ fileProcessingError?: string;
1025
+ };
1026
+ prompts?: {
1027
+ askMeSomethingElse?: string;
1028
+ submitPromptAriaLabel?: string;
1029
+ placeholderAskCopilot?: string;
1030
+ placeholderAskAQuestion?: string;
1031
+ connectingToAgent?: string;
1032
+ agentError?: string;
1033
+ };
1034
+ entryMessage?: {
1035
+ askCimWelcome?: string;
1036
+ };
1037
+ messages?: {
1038
+ conversationReset?: string;
1039
+ startSearchPrompt?: string;
1040
+ genericError?: string;
1041
+ displayDisplayTrouble?: string;
1042
+ requestTrouble?: string;
1043
+ progressHide?: string;
1044
+ progressContext?: string;
1045
+ userProvidedContextAlt?: string;
1046
+ recommendedProductsAriaLabel?: string;
1047
+ /** `{count}` — singular */
1048
+ filterCountOne?: string;
1049
+ /** `{count}` — plural */
1050
+ filterCountMultiple?: string;
1051
+ progressStepCompleted?: string;
1052
+ progressStepInProgress?: string;
1053
+ /** `{step}`, `{status}` */
1054
+ progressStepAriaLabel?: string;
1055
+ };
1056
+ userQuery?: {
1057
+ yourSearch?: string;
1058
+ browsingCategory?: string;
1059
+ viewingProduct?: string;
1060
+ };
1061
+ product?: {
1062
+ /** `{name}` */
1063
+ goToProductPageAriaLabel?: string;
1064
+ /** `{name}` */
1065
+ viewDetailsAriaLabel?: string;
1066
+ productImageAlt?: string;
1067
+ /** `{name}` */
1068
+ noImageAriaLabel?: string;
1069
+ noProductImageAriaLabel?: string;
1070
+ /** `{productName}` */
1071
+ showMeDetailsSentMessage?: string;
1072
+ thisProductFallbackName?: string;
1073
+ /** `{low}`, `{high}` */
1074
+ priceFromToAriaLabel?: string;
1075
+ colorVariantLabel?: string;
1076
+ quantityLabel?: string;
1077
+ decreaseQuantityAriaLabel?: string;
1078
+ increaseQuantityAriaLabel?: string;
1079
+ unavailableVariant?: string;
1080
+ addToCart?: string;
1081
+ };
1082
+ productComparison?: {
1083
+ /** `{productName}` */
1084
+ viewDetailsAriaLabel?: string;
1085
+ /** `{productName}` */
1086
+ showDetailsSentMessage?: string;
1087
+ };
1088
+ productGallery?: {
1089
+ productImagesAriaLabel?: string;
1090
+ /** `{altText}`, `{index}` */
1091
+ imageAlt?: string;
1092
+ /** `{index}` */
1093
+ imageAltFallback?: string;
1094
+ previousImageAriaLabel?: string;
1095
+ nextImageAriaLabel?: string;
1096
+ /** `{index}` */
1097
+ goToImageAriaLabel?: string;
1098
+ };
1099
+ carousel?: {
1100
+ productCarouselAriaLabel?: string;
1101
+ productRecommendationsAriaLabel?: string;
1102
+ previousSlideAriaLabel?: string;
1103
+ nextSlideAriaLabel?: string;
1104
+ /** `{index}` */
1105
+ goToSlideGroupAriaLabel?: string;
1106
+ };
1107
+ price?: {
1108
+ currentPriceLabel?: string;
1109
+ originalPriceLabel?: string;
1110
+ };
1111
+ cart?: {
1112
+ checkout?: string;
1113
+ decreaseQuantityAriaLabel?: string;
1114
+ increaseQuantityAriaLabel?: string;
1115
+ quantityAriaLabel?: string;
1116
+ quantityHeading?: string;
1117
+ productImageAlt?: string;
1118
+ /** `{promo}` */
1119
+ promotionLabel?: string;
1120
+ remove?: string;
1121
+ /** `{count}` — singular */
1122
+ subtotalOne?: string;
1123
+ /** `{count}` — plural */
1124
+ subtotalMultiple?: string;
1125
+ coupon?: string;
1126
+ promotions?: string;
1127
+ shipping?: string;
1128
+ shippingDiscount?: string;
1129
+ tax?: string;
1130
+ estimatedTotal?: string;
1131
+ enterCouponCode?: string;
1132
+ applyCouponAriaLabel?: string;
1133
+ couponNotApplied?: string;
1134
+ shippingAndTaxesFooter?: string;
1135
+ /** `{orderId}` */
1136
+ expressCheckoutCompleteWithOrder?: string;
1137
+ expressCheckoutCompleteNoOrder?: string;
1138
+ /** `{qty}` */
1139
+ addToCartWithQty?: string;
1140
+ addToCart?: string;
1141
+ };
1142
+ orderConfirmation?: {
1143
+ productImageAlt?: string;
1144
+ /** `{promo}` */
1145
+ promotionLabel?: string;
1146
+ /** `{quantity}` */
1147
+ quantityLabel?: string;
1148
+ orderConfirmed?: string;
1149
+ /** `{id}` */
1150
+ orderNumberLabel?: string;
1151
+ /** `{date}` */
1152
+ orderedOnLabel?: string;
1153
+ subtotal?: string;
1154
+ coupon?: string;
1155
+ promotions?: string;
1156
+ shipping?: string;
1157
+ shippingDiscount?: string;
1158
+ tax?: string;
1159
+ total?: string;
1160
+ shippingAndTaxesFooter?: string;
1161
+ };
1162
+ payment?: {
1163
+ expressPaymentTitle?: string;
1164
+ paymentFailed?: string;
1165
+ paymentCanceled?: string;
1166
+ };
1167
+ jumpToLatest?: {
1168
+ jumpToLatestAriaLabel?: string;
1169
+ jumpToLatestTitle?: string;
1170
+ };
1171
+ attachment?: {
1172
+ fallbackAlt?: string;
1173
+ };
1174
+ announcements?: {
1175
+ assistantResponseAvailable?: string;
1176
+ noProductsFound?: string;
1177
+ /** `{count}` — singular */
1178
+ productsFoundOne?: string;
1179
+ /** `{count}` — plural */
1180
+ productsFoundMultiple?: string;
1181
+ /** singular */
1182
+ productTitleLabelOne?: string;
1183
+ /** plural */
1184
+ productTitleLabelMultiple?: string;
1185
+ };
1186
+ pageContext?: {
1187
+ /** `{label}` */
1188
+ stopAskingAboutAriaLabel?: string;
1189
+ /** `{label}` */
1190
+ askAboutPlaceholder?: string;
1191
+ /** `{query}` */
1192
+ searchDisplayLabel?: string;
1193
+ /** `{query}` */
1194
+ removeSearchContextAriaLabel?: string;
1195
+ searchPlaceholder?: string;
1196
+ /** `{label}` */
1197
+ searchDividerLabel?: string;
1198
+ };
1199
+ errors?: {
1200
+ genericRetry?: string;
1201
+ rateLimited?: string;
1202
+ offline?: string;
1203
+ messagingUnavailable?: string;
1204
+ };
1205
+ session?: {
1206
+ sessionEnded?: string;
1207
+ conversationEnded?: string;
1208
+ /** `{name}` */
1209
+ participantJoined?: string;
1210
+ /** `{name}` */
1211
+ participantLeft?: string;
1212
+ participantFallbackName?: string;
1213
+ };
1214
+ }
1215
+
928
1216
  /**
929
1217
  * Widget operating mode.
930
1218
  * - 'copilot' (default): Uses the Cimulate Copilot SDK (Socket.IO)