@cimulate/copilot-widget 1.57.1 → 1.58.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.58.1 — 2026-11-18
6
+
7
+ - Add the selected product variant and quantity through the storefront adapter in direct mode, with in-card feedback.
8
+ - Notify the storefront after confirmed agent cart mutations in direct mode so an open cart page can refresh.
9
+
10
+ ## 1.58.0 — 2026-11-17
11
+
12
+ - Add themed hover states for cart controls and keep cart loading, empty, and populated views mutually exclusive. Use native coupon form submission.
13
+ - Preserve transcript bubble spacing while switching between conversation and cart.
14
+ - Move the cart back arrow and title into the dialog and modal main header, restoring branding on return to conversation.
15
+ - Add opt-in direct carts for messaging: storefront cart actions, compact summaries with payments, a dedicated pane, and a configurable header cart button. Preserve the existing agent-mode cart.
16
+
5
17
  ## 1.57.1 — 2026-11-16
6
18
 
7
19
  - Allow consecutive shopper messages after confirmed human escalation, including while queued and while a human types. Complete human-chat sends on server acknowledgment and restore handoff mode from conversation history.
package/README.md CHANGED
@@ -657,7 +657,26 @@ The object is the full basket (`CartDetails`), not a quantity stub. An empty `it
657
657
 
658
658
  Call it as soon as the messaging API is available and the storefront has a fresh basket, including before mount or during startup. Startup history and duplicate replay cannot replace a storefront seed; later live agent cart responses advance the baseline normally. Call again after storefront basket changes. The storefront must discard stale fetch results rather than submit them as new snapshots.
659
659
 
660
- Only the internal cart-diff baseline is updated. The call does not emit `cimulate:cart-update`. The next agent cart result is compared with that basket.
660
+ In agent mode, only the internal cart-diff baseline is updated. The call does not emit `cimulate:cart-update`. The next agent cart result is compared with that basket.
661
+
662
+ ### Direct cart in messaging mode
663
+
664
+ Set `messagingConfig.cartTransport` to `"direct"` to opt in. Use `eventHandlers.cart.update(cart)` to supply basket changes made outside the widget. The default `"agent"` keeps the existing cart experience. Register the storefront listener before mounting the widget:
665
+
666
+ ```ts
667
+ import { addCartActionListener, type CartActionDetail } from "@cimulate/copilot-widget/messaging";
668
+
669
+ addCartActionListener((event) => {
670
+ const { respond, ...request } = (event as CustomEvent<CartActionDetail>).detail;
671
+ storefrontCartAction(request)
672
+ .then((cart) => respond({ ok: true, cart }))
673
+ .catch(() => respond({ ok: false, error: "Could not update your cart" }));
674
+ });
675
+ ```
676
+
677
+ Implement `get`, `add`, `quantity`, `remove`, and `coupon` in `storefrontCartAction`, returning the full basket. The in-chat product detail button sends `add` with the selected purchasable `productId` and `quantity`. Typed cart requests go through the agent. On `cimulate:cart-update`, re-fetch the basket and refresh any visible storefront cart. Supply `expressPaymentUrl` and `checkoutButtonUrl` on the basket to show express payment controls and checkout in the latest in-chat summary and the built-in cart pane.
678
+
679
+ 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.
661
680
 
662
681
  ## Linting and pre-commit hooks
663
682
 
@@ -84,6 +84,13 @@ declare interface BrowseState extends CommonParams {
84
84
  categoryName?: string;
85
85
  }
86
86
 
87
+ /**
88
+ * `"agent"` (default) edits the basket with natural-language prompts.
89
+ * `"direct"` dispatches `cimulate:cart-action` and renders the cart the
90
+ * storefront returns from `detail.respond`.
91
+ */
92
+ declare type CartTransport = "agent" | "direct";
93
+
87
94
  declare type CimCopilotSdkConfig = {
88
95
  apiKey?: string;
89
96
  apiToken?: string;
@@ -144,16 +151,9 @@ declare interface ComponentOverrides {
144
151
  */
145
152
  OrderConfirmation?: OverrideTagName;
146
153
  /**
147
- * Replaces the in-chat cart BODY (items, totals, coupons) — a presentational
148
- * slot. Checkout and the Apple/Google Pay iframe are NOT part of it: the widget
149
- * keeps rendering them itself, beneath the override. The slot receives a
150
- * {@link CartOverrideProps} — a display-only {@link DisplayCart} (no
151
- * checkout/express URLs) and a {@link CartOverrideApi} whose `cart` methods are
152
- * the only way to mutate the basket; there is no `sendMessage`. The widget
153
- * marks every cart snapshot except the newest `readOnly` and refuses mutations
154
- * while it is set (or the cart is busy/disconnected), but an override should
155
- * also reflect `readOnly` in its controls so a shopper can't act on a stale
156
- * basket.
154
+ * Receives {@link CartOverrideProps} with display data and structured cart actions.
155
+ * Agent mode replaces the cart body; checkout stays widget-owned.
156
+ * Direct mode replaces the iframe or built-in cart and its payment controls.
157
157
  */
158
158
  Cart?: OverrideTagName;
159
159
  /**
@@ -404,7 +404,7 @@ declare const getConversationMessages: ({ payload, callback, }: {
404
404
 
405
405
  declare const getSessionInformation: (callback: (sessionInfo: SessionInformation) => void) => void;
406
406
 
407
- declare type HeaderActionName = "close" | "toggleExpanded" | "toggleFullscreen" | "toggleDialogPosition" | "minimize" | "clearChat" | "endConversation" | "downloadTranscript";
407
+ declare type HeaderActionName = "cart" | "close" | "toggleExpanded" | "toggleFullscreen" | "toggleDialogPosition" | "minimize" | "clearChat" | "endConversation" | "downloadTranscript";
408
408
 
409
409
  declare type HeaderActionsConfig = Partial<Record<HeaderActionName, boolean>>;
410
410
 
@@ -529,6 +529,17 @@ declare interface MessagingModeConfig {
529
529
  * entries are ignored. `null` hides the connecting indicator entirely.
530
530
  */
531
531
  connectingMessages?: readonly string[] | null;
532
+ /**
533
+ * Who edits the basket. `"agent"` (default) sends the natural-language cart
534
+ * prompts. `"direct"` dispatches `cimulate:cart-action` and renders the cart
535
+ * the storefront passes to `detail.respond`.
536
+ */
537
+ cartTransport?: CartTransport;
538
+ /**
539
+ * Storefront cart page embedded in the cart tab. When set, that page replaces
540
+ * the built-in lines, coupon field, totals, and checkout.
541
+ */
542
+ storefrontCartPageUrl?: string;
532
543
  }
533
544
 
534
545
  declare type MessagingSessionReason = "created" | "resumed" | "refreshed" | "ended" | "reset";