@cimulate/copilot-widget 1.22.1 → 1.23.0
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/dist/cimulate-copilot-widget.d.ts +38 -0
- package/dist/cimulate-copilot-widget.es.js +6 -3
- package/dist/cimulate-copilot-widget.umd.js +1 -1
- package/dist/copilot.es.js +6 -3
- package/dist/copilot.umd.js +1 -1
- package/dist/messaging.d.ts +160 -3
- package/dist/messaging.es.js +10368 -10073
- package/dist/messaging.umd.js +36 -36
- package/package.json +1 -1
package/dist/messaging.d.ts
CHANGED
|
@@ -62,7 +62,9 @@ export declare const AgentForceWidget: (props: CopilotWidgetProps) => JSX_2.Elem
|
|
|
62
62
|
* UIStateContext >
|
|
63
63
|
* MessagingProvider (Agentforce/SCRT2 SDK)
|
|
64
64
|
*/
|
|
65
|
-
export declare const AgentforceWidgetProvider: ({ mode, apiKey, apiToken, baseUrl, logoUrl, headerText, headerConfig, theme, openLinksInNewTab, globalClassName, isDevelopment, componentType, componentConfig, entryType, entryMessage, disclaimerText, disclaimerMarkdown, clientContext, searchPlaceholder, searchButtonLabel, searchConfig, suggestionButtonConfig, messageAlignment, autoScroll, promptsConfig, resetConversationMessage, conversationHistory, messagingConfig, __features, children, }: CopilotWidgetProps & {
|
|
65
|
+
export declare const AgentforceWidgetProvider: ({ mode, apiKey, apiToken, baseUrl, logoUrl, headerText, headerConfig, theme, openLinksInNewTab, globalClassName, isDevelopment, componentType, componentConfig, entryType, entryMessage, disclaimerText, disclaimerMarkdown, clientContext, searchPlaceholder, searchButtonLabel, searchConfig, suggestionButtonConfig, messageAlignment, autoScroll, promptsConfig, resetConversationMessage, conversationHistory, messagingConfig, overrides, overridesUrl, inlineOverrides, __features, children, }: CopilotWidgetProps & {
|
|
66
|
+
overridesUrl?: string;
|
|
67
|
+
inlineOverrides?: ComponentOverrides;
|
|
66
68
|
children: ReactNode;
|
|
67
69
|
}) => JSX_2.Element;
|
|
68
70
|
|
|
@@ -171,6 +173,28 @@ declare type ComparisonTableRow = {
|
|
|
171
173
|
values: string[];
|
|
172
174
|
};
|
|
173
175
|
|
|
176
|
+
/**
|
|
177
|
+
* One flat map from override key to custom-element tag name.
|
|
178
|
+
*
|
|
179
|
+
* `ProductTile` and `ProductCarousel` are the only keys the widget consults for
|
|
180
|
+
* its built-in product UI: register one and the widget mounts your element in
|
|
181
|
+
* place of the default tile/carousel (leave it unset and the built-in renders).
|
|
182
|
+
* Every other key is matched against a `type:"tool_results"` block's top-level
|
|
183
|
+
* `output_name` (never a field inside the arbitrary `data` payload); an unmatched
|
|
184
|
+
* block renders nothing. All of them receive the same `OverrideProps`.
|
|
185
|
+
*
|
|
186
|
+
* { ProductTile: "cx-product-card", recentOrders: "cx-recent-orders" }
|
|
187
|
+
*
|
|
188
|
+
* Widget chrome (header, search bar, follow-up suggestions) is intentionally NOT
|
|
189
|
+
* overridable: those keys are accepted by the open index signature but have no
|
|
190
|
+
* render path, so they are silently ignored.
|
|
191
|
+
*/
|
|
192
|
+
export declare interface ComponentOverrides {
|
|
193
|
+
ProductTile?: OverrideTagName;
|
|
194
|
+
ProductCarousel?: OverrideTagName;
|
|
195
|
+
[key: string]: OverrideTagName | undefined;
|
|
196
|
+
}
|
|
197
|
+
|
|
174
198
|
export declare type ComponentType = "chat" | "dialog" | "modal";
|
|
175
199
|
|
|
176
200
|
declare interface CopilotWidgetProps extends CimCopilotSdkConfig {
|
|
@@ -245,6 +269,9 @@ declare interface CopilotWidgetProps extends CimCopilotSdkConfig {
|
|
|
245
269
|
* Configuration for messaging mode. Required when mode is 'messaging'.
|
|
246
270
|
*/
|
|
247
271
|
messagingConfig?: MessagingModeConfig;
|
|
272
|
+
overrides?: ComponentOverrides;
|
|
273
|
+
overridesUrl?: string;
|
|
274
|
+
inlineOverrides?: ComponentOverrides;
|
|
248
275
|
/**
|
|
249
276
|
*
|
|
250
277
|
* Enables features not yet released. They may require additional backend support and are subject to change.
|
|
@@ -285,7 +312,7 @@ declare interface HeaderConfig {
|
|
|
285
312
|
headerTextTextAlign?: "left" | "center" | "right";
|
|
286
313
|
}
|
|
287
314
|
|
|
288
|
-
export declare const injectMessagingWidget: ({ timeout, elementId, ...props }: InjectMessagingWidgetOptions) => void;
|
|
315
|
+
export declare const injectMessagingWidget: ({ timeout, elementId, overridesUrl, overrides: inlineOverrides, ...props }: InjectMessagingWidgetOptions) => void;
|
|
289
316
|
|
|
290
317
|
declare interface InjectMessagingWidgetOptions extends Omit<CopilotWidgetProps, "apiKey" | "apiToken" | "baseUrl" | "mode"> {
|
|
291
318
|
/** ID of the DOM element to render the widget into */
|
|
@@ -294,6 +321,20 @@ declare interface InjectMessagingWidgetOptions extends Omit<CopilotWidgetProps,
|
|
|
294
321
|
timeout?: number;
|
|
295
322
|
/** SCRT2 messaging configuration (required) */
|
|
296
323
|
messagingConfig: MessagingModeConfig;
|
|
324
|
+
/**
|
|
325
|
+
* URL to a hosted customer override script (the primary deploy path). The
|
|
326
|
+
* script must set `window.CimulateOverrides`. Loaded asynchronously in
|
|
327
|
+
* OverridesContext; the widget renders immediately while overrides load in
|
|
328
|
+
* the background.
|
|
329
|
+
*/
|
|
330
|
+
overridesUrl?: string;
|
|
331
|
+
/**
|
|
332
|
+
* Inline overrides map, passed directly instead of via `overridesUrl` (no
|
|
333
|
+
* hosting / no round-trip). `overridesUrl` takes precedence when both are set.
|
|
334
|
+
*
|
|
335
|
+
* (Inherited from `CopilotWidgetProps`; re-declared here for documentation.)
|
|
336
|
+
*/
|
|
337
|
+
overrides?: ComponentOverrides;
|
|
297
338
|
}
|
|
298
339
|
|
|
299
340
|
declare type MarkdownResponse = {
|
|
@@ -504,6 +545,108 @@ declare type OrderDetails = {
|
|
|
504
545
|
footerMessage: string | null;
|
|
505
546
|
};
|
|
506
547
|
|
|
548
|
+
/**
|
|
549
|
+
* Component Override Types
|
|
550
|
+
*
|
|
551
|
+
* Defines the contract between the Commerce Client widget and customer overrides.
|
|
552
|
+
* Each override is the tag name of a pre-registered custom element (a string).
|
|
553
|
+
* Every override — product or custom block — receives the same `OverrideProps`
|
|
554
|
+
* object on its element's `props` setter: the raw block payload plus an `api`.
|
|
555
|
+
*/
|
|
556
|
+
/**
|
|
557
|
+
* Widget capabilities handed to every override so it can be interactive — e.g. a
|
|
558
|
+
* product card, option picker, or warranty form that posts a message back to the
|
|
559
|
+
* agent via `sendMessage`.
|
|
560
|
+
*/
|
|
561
|
+
export declare interface OverrideApi {
|
|
562
|
+
sendMessage: (text: string) => void;
|
|
563
|
+
isLoading: boolean;
|
|
564
|
+
isConnected: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Widget presentation mode: `"chat"` (fullscreen), `"dialog"` (floating window),
|
|
567
|
+
* or `"modal"` (centered overlay). Use to adapt layout — e.g. expand details in
|
|
568
|
+
* `"chat"`, condense in `"dialog"`.
|
|
569
|
+
*/
|
|
570
|
+
componentType: "chat" | "dialog" | "modal";
|
|
571
|
+
/**
|
|
572
|
+
* Widget integration mode: `"standalone"` (the only UI on the page) or
|
|
573
|
+
* `"embedded"` (coexists with storefront chrome). Use to adjust z-index,
|
|
574
|
+
* backdrop behavior, or whether to render a close button.
|
|
575
|
+
*/
|
|
576
|
+
mode: "standalone" | "embedded";
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Minimal base class for customer override custom elements.
|
|
581
|
+
* Handles the widget contract: props setter/getter and lifecycle.
|
|
582
|
+
*
|
|
583
|
+
* Subclasses implement render() to build their DOM. Use your own
|
|
584
|
+
* sanitization/escaping when building HTML (DOMPurify, framework
|
|
585
|
+
* built-ins, or manual escaping).
|
|
586
|
+
*
|
|
587
|
+
* Usage:
|
|
588
|
+
* import { OverrideElement } from '@cimulate/copilot-widget/messaging';
|
|
589
|
+
*
|
|
590
|
+
* class ProductCard extends OverrideElement {
|
|
591
|
+
* render() {
|
|
592
|
+
* const { payload, api } = this.props || {};
|
|
593
|
+
* // Use your own escaping/sanitization here
|
|
594
|
+
* const escaped = yourEscapeFunction(payload.data.name);
|
|
595
|
+
* this.replaceChildren(document.createTextNode(escaped));
|
|
596
|
+
* }
|
|
597
|
+
* }
|
|
598
|
+
* customElements.define("product-card", ProductCard);
|
|
599
|
+
*/
|
|
600
|
+
export declare class OverrideElement extends HTMLElement {
|
|
601
|
+
protected _props: Record<string, unknown> | null;
|
|
602
|
+
/**
|
|
603
|
+
* The widget assigns `element.props = {...}` on first mount and every
|
|
604
|
+
* re-render. Store and render here — the single entry point.
|
|
605
|
+
*/
|
|
606
|
+
set props(value: Record<string, unknown> | null);
|
|
607
|
+
get props(): Record<string, unknown> | null;
|
|
608
|
+
/**
|
|
609
|
+
* Fires ONCE when inserted. The instance persists across widget re-renders,
|
|
610
|
+
* so this won't fire again per commit.
|
|
611
|
+
*/
|
|
612
|
+
connectedCallback(): void;
|
|
613
|
+
/**
|
|
614
|
+
* Subclasses override this to build their DOM. Called on first mount and
|
|
615
|
+
* every props update.
|
|
616
|
+
*/
|
|
617
|
+
protected render(): void;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* The single props object every override receives. `payload` is the block's raw
|
|
622
|
+
* data, verbatim from the agent — the widget does not normalize it, so its shape
|
|
623
|
+
* depends on `name`:
|
|
624
|
+
*
|
|
625
|
+
* - "ProductTile" → one raw product ({ id, caption?, data: { name, price,
|
|
626
|
+
* currencyCode, imageUrl, … }, customProperties? })
|
|
627
|
+
* - "ProductCarousel" → { title?, products: RawProduct[] }
|
|
628
|
+
* - any custom-block key → the `tool_results` block's raw `data`, your own shape
|
|
629
|
+
*/
|
|
630
|
+
export declare interface OverrideProps {
|
|
631
|
+
/** The resolved override key: "ProductTile"/"ProductCarousel" for the product slots, else the `tool_results` block's `output_name`. */
|
|
632
|
+
name: string;
|
|
633
|
+
payload: unknown;
|
|
634
|
+
api: OverrideApi;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* A component override is the tag name of a pre-registered custom element
|
|
639
|
+
* (e.g. "product-card"). The widget creates the element via
|
|
640
|
+
* document.createElement(tagName) and assigns `OverrideProps` to its `props`
|
|
641
|
+
* setter. The element must be registered with customElements.define before the
|
|
642
|
+
* widget renders.
|
|
643
|
+
*
|
|
644
|
+
* The name must be a valid custom element name — it has to contain a hyphen and
|
|
645
|
+
* be all lowercase. Anything else (e.g. "ProductTile" or "div") is rejected with
|
|
646
|
+
* a console error and the slot renders blank.
|
|
647
|
+
*/
|
|
648
|
+
export declare type OverrideTagName = string;
|
|
649
|
+
|
|
507
650
|
declare type ProductCarouselProduct = {
|
|
508
651
|
id: string;
|
|
509
652
|
caption?: string;
|
|
@@ -633,7 +776,7 @@ declare type PromptsExtensionState = {
|
|
|
633
776
|
|
|
634
777
|
declare type PromptsParams = AskCimSuggestions | CopilotSearchSuggestions | CopilotBrowseSuggestions | ProductViewSuggestions;
|
|
635
778
|
|
|
636
|
-
declare type ResponseItem = MarkdownResponse | ProductCarouselResponse | ProductTileResponse | ProductComparisonResponse | SuggestionsResponse | CartResponse | OrderConfirmationResponse;
|
|
779
|
+
declare type ResponseItem = MarkdownResponse | ProductCarouselResponse | ProductTileResponse | ProductComparisonResponse | SuggestionsResponse | CartResponse | OrderConfirmationResponse | ToolResultsResponse;
|
|
637
780
|
|
|
638
781
|
/**
|
|
639
782
|
* A retryable message-send failure: the connection is live but the send itself
|
|
@@ -674,6 +817,20 @@ declare interface ThemeConfig {
|
|
|
674
817
|
borderRadius?: string;
|
|
675
818
|
}
|
|
676
819
|
|
|
820
|
+
/**
|
|
821
|
+
* Escape hatch for agent-action outputs that don't map to any built-in block
|
|
822
|
+
* (e.g. order tracking, warranty registration, option pickers). Rendered via a
|
|
823
|
+
* customer-registered tag in the flat `overrides` map, keyed by `output_name`.
|
|
824
|
+
* `data` is the raw action output, handed to the override verbatim. An unmatched
|
|
825
|
+
* `output_name` renders nothing, same as an unknown block type.
|
|
826
|
+
*/
|
|
827
|
+
declare type ToolResultsResponse = {
|
|
828
|
+
type: "tool_results";
|
|
829
|
+
index: number;
|
|
830
|
+
output_name?: string;
|
|
831
|
+
data: unknown;
|
|
832
|
+
};
|
|
833
|
+
|
|
677
834
|
export declare function useMessaging(): MessagingContextType;
|
|
678
835
|
|
|
679
836
|
declare interface WidgetComponentConfig {
|