@carbon/ai-chat 1.3.1 → 1.4.0-rc.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.
Files changed (35) hide show
  1. package/dist/es/aiChatEntry.js +96 -132
  2. package/dist/es/aiChatEntry.js.map +1 -1
  3. package/dist/es/chat.ChatAppEntry.js +1804 -4916
  4. package/dist/es/chat.ChatAppEntry.js.map +1 -1
  5. package/dist/es/chat.LayoutCustomProperties.js +12 -0
  6. package/dist/es/chat.LayoutCustomProperties.js.map +1 -0
  7. package/dist/es/{chat.PageObjectId.js → chat.languages.js} +489 -227
  8. package/dist/es/chat.languages.js.map +1 -0
  9. package/dist/es/serverEntry.js +36 -9
  10. package/dist/es/serverEntry.js.map +1 -1
  11. package/dist/es/web-components/cds-aichat-container/index.js +31 -67
  12. package/dist/es/web-components/cds-aichat-container/index.js.map +1 -1
  13. package/dist/es/web-components/cds-aichat-custom-element/index.js +30 -66
  14. package/dist/es/web-components/cds-aichat-custom-element/index.js.map +1 -1
  15. package/dist/es-custom/aiChatEntry.js +96 -132
  16. package/dist/es-custom/aiChatEntry.js.map +1 -1
  17. package/dist/es-custom/chat.ChatAppEntry.js +1804 -4916
  18. package/dist/es-custom/chat.ChatAppEntry.js.map +1 -1
  19. package/dist/es-custom/chat.LayoutCustomProperties.js +12 -0
  20. package/dist/es-custom/chat.LayoutCustomProperties.js.map +1 -0
  21. package/dist/es-custom/{chat.PageObjectId.js → chat.languages.js} +489 -227
  22. package/dist/es-custom/chat.languages.js.map +1 -0
  23. package/dist/es-custom/serverEntry.js +36 -9
  24. package/dist/es-custom/serverEntry.js.map +1 -1
  25. package/dist/es-custom/web-components/cds-aichat-container/index.js +31 -67
  26. package/dist/es-custom/web-components/cds-aichat-container/index.js.map +1 -1
  27. package/dist/es-custom/web-components/cds-aichat-custom-element/index.js +30 -66
  28. package/dist/es-custom/web-components/cds-aichat-custom-element/index.js.map +1 -1
  29. package/dist/types/aiChatEntry.d.ts +4 -3
  30. package/dist/types/{serverEntry-ojFJl1OR.d.ts → serverEntry-BZ90jVeY.d.ts} +1026 -975
  31. package/dist/types/serverEntry.d.ts +3 -2
  32. package/package.json +8 -19
  33. package/telemetry.yml +0 -5
  34. package/dist/es/chat.PageObjectId.js.map +0 -1
  35. package/dist/es-custom/chat.PageObjectId.js.map +0 -1
@@ -1,57 +1,109 @@
1
- import { NOTIFICATION_KIND } from '@carbon/web-components/es/components/notification/defs.js';
2
- import { BUTTON_KIND } from '@carbon/web-components/es/components/button/defs.js';
1
+ import { BUTTON_KIND, BUTTON_SIZE } from '@carbon/web-components/es/components/button/defs.js';
2
+ import { CHAT_BUTTON_KIND, CHAT_BUTTON_SIZE } from '@carbon/ai-chat-components/es/react/chat-button.js';
3
+ import { ChainOfThoughtStep } from '@carbon/ai-chat-components/es/components/chain-of-thought/src/types.js';
3
4
  import { ReactNode } from 'react';
4
5
  import * as lit_html from 'lit-html';
5
6
  import { LitElement, PropertyValues } from 'lit';
6
7
  import { Root } from 'react-dom/client';
7
8
 
8
9
  /**
9
- * Whether a particular Carbon AI Chat view is visible or not.
10
+ * An enum of all of our data-testid we use. For some elements (like INPUT) they can appear in multiple "panels"
11
+ * (e.g. on the home screen and in the main chat window). There are provided testids for "panels" as well so you
12
+ * can first select a panel and then select the correct child.
10
13
  *
11
- * @category Instance
14
+ * @category Testing
15
+ *
16
+ * @experimental
12
17
  */
13
- interface ViewState {
18
+ declare enum PageObjectId {
14
19
  /**
15
- * Whether the launcher is visible or not.
20
+ * Minimize chat button in header.
16
21
  */
17
- launcher: boolean;
22
+ CLOSE_CHAT = "close_chat",
18
23
  /**
19
- * Whether the main window is visible or not.
24
+ * The launcher button to open the chat. This id is maintained across desktop and mobile launchers.
20
25
  */
21
- mainWindow: boolean;
22
- }
23
- /**
24
- * A record of a notification to be shown in the UI.
25
- *
26
- * @experimental
27
- * @category Instance
28
- */
29
- interface NotificationMessage {
30
- kind: NOTIFICATION_KIND;
26
+ LAUNCHER = "launcher_open_chat",
31
27
  /**
32
- * The title to show in the message.
28
+ * Input field.
33
29
  */
34
- title: string;
30
+ INPUT = "input_field",
35
31
  /**
36
- * The message to show.
32
+ * Input send button.
37
33
  */
38
- message: string;
34
+ INPUT_SEND = "input_send",
35
+ /**
36
+ * The chat header title element.
37
+ */
38
+ HEADER_TITLE = "header_title",
39
+ /**
40
+ * The chat header name element.
41
+ */
42
+ HEADER_NAME = "header_name",
43
+ /**
44
+ * The main chat panel.
45
+ */
46
+ MAIN_PANEL = "main_panel",
47
+ /**
48
+ * Disclaimer panel.
49
+ */
50
+ DISCLAIMER_PANEL = "disclaimer_panel",
51
+ /**
52
+ * Disclaimer accept button.
53
+ */
54
+ DISCLAIMER_ACCEPT_BUTTON = "disclaimer_accept_button",
55
+ /**
56
+ * Homescreen Panel.
57
+ */
58
+ HOME_SCREEN_PANEL = "home_screen_panel",
59
+ /**
60
+ * Hydration/loading state panel.
61
+ */
62
+ HYDRATING_PANEL = "hydrating_panel",
63
+ /**
64
+ * Catastrophic error panel.
65
+ */
66
+ CATASTROPHIC_PANEL = "catastrophic_panel",
67
+ /**
68
+ * Iframe panel.
69
+ */
70
+ IFRAME_PANEL = "iframe_panel",
71
+ /**
72
+ * Conversational search panel.
73
+ */
74
+ CONVERSATIONAL_SEARCH_CITATION_PANEL = "conversational_search_citation_panel",
39
75
  /**
40
- * An optional action button that a user can click. If there is an action button, we will not auto dismiss.
76
+ * Custom panel.
41
77
  */
42
- actionButtonLabel?: string;
78
+ CUSTOM_PANEL = "custom_panel",
43
79
  /**
44
- * The group id that associates notifications together. This can be used to remove the notification later.
80
+ * A panel that opens from a button response.
45
81
  */
46
- groupID?: string;
82
+ BUTTON_RESPONSE_PANEL = "button_response_panel"
83
+ }
84
+ /**
85
+ * Ids used for data-testid.
86
+ *
87
+ * @category Testing
88
+ *
89
+ * @experimental
90
+ */
91
+ type TestId = PageObjectId;
92
+
93
+ /**
94
+ * Whether a particular Carbon AI Chat view is visible or not.
95
+ *
96
+ * @category Instance
97
+ */
98
+ interface ViewState {
47
99
  /**
48
- * The callback called when someone clicks on the action button.
100
+ * Whether the launcher is visible or not.
49
101
  */
50
- onActionButtonClick?: () => void;
102
+ launcher: boolean;
51
103
  /**
52
- * The callback called when someone clicks on the close button.
104
+ * Whether the main window is visible or not.
53
105
  */
54
- onCloseButtonClick?: () => void;
106
+ mainWindow: boolean;
55
107
  }
56
108
  /**
57
109
  * The different views that can be shown by Carbon AI Chat.
@@ -181,6 +233,8 @@ interface CustomPanelConfigOptions {
181
233
  *
182
234
  * When {@link hideBackButton} is set to true, any {@link title} value defined here will override the title/name in
183
235
  * the main chat header.
236
+ *
237
+ * @category Instance
184
238
  */
185
239
  interface DefaultCustomPanelConfigOptions {
186
240
  /**
@@ -202,9 +256,25 @@ interface DefaultCustomPanelConfigOptions {
202
256
  /**
203
257
  * Options accepted by {@link CustomPanelInstance.open}. Legacy consumers may continue to pass
204
258
  * {@link CustomPanelConfigOptions} until the next major release.
259
+ *
260
+ * @category Instance
205
261
  */
206
262
  type CustomPanelOpenOptions = CustomPanelConfigOptions | DefaultCustomPanelConfigOptions;
207
263
 
264
+ /**
265
+ * @category Config
266
+ */
267
+ interface ChatHeaderConfig {
268
+ /**
269
+ * The chat header title.
270
+ */
271
+ title?: string;
272
+ /**
273
+ * The name displayed after the title.
274
+ */
275
+ name?: string;
276
+ }
277
+
208
278
  /*
209
279
  * Copyright IBM Corp. 2025
210
280
  *
@@ -612,63 +682,7 @@ interface ItemStreamingMetadata {
612
682
  */
613
683
  stream_stopped?: boolean;
614
684
  }
615
- /**
616
- * Status of the chain of thought step.
617
- *
618
- * @category Messaging
619
- */
620
- declare enum ChainOfThoughtStepStatus {
621
- PROCESSING = "processing",
622
- FAILURE = "failure",
623
- SUCCESS = "success"
624
- }
625
- /**
626
- * A chain of thought step is meant to show tool calls and other steps made by your agent
627
- * to reach its final answer.
628
- *
629
- * @category Messaging
630
- */
631
- interface ChainOfThoughtStep {
632
- /**
633
- * The plain text name of the step.
634
- */
635
- title?: string;
636
- /**
637
- * An optional human readable description of what the tool does.
638
- *
639
- * Accepts markdown formatted text.
640
- */
641
- description?: string;
642
- /**
643
- * The plain text name of the tool called.
644
- */
645
- tool_name?: string;
646
- /**
647
- * Optional request metadata sent to a tool.
648
- */
649
- request?: {
650
- /**
651
- * Arguments sent to the tool. If this is properly formed JSON, it will be shown as a code block.
652
- */
653
- args?: unknown;
654
- };
655
- /**
656
- * Optional response from a tool.
657
- */
658
- response?: {
659
- /**
660
- * Content returned by the tool. If this is properly formed JSON, it will be shown as a code block.
661
- *
662
- * You can also return markdown compatible text here.
663
- */
664
- content: unknown;
665
- };
666
- /**
667
- * Optionally, share the status of this step. An icon will appear in the view showing the status. If no status is
668
- * shared, the UI will assume success.
669
- */
670
- status?: ChainOfThoughtStepStatus;
671
- }
685
+
672
686
  /**
673
687
  * Options that control additional features available for a message item.
674
688
  *
@@ -1394,7 +1408,11 @@ interface ButtonItem<TUserDefinedType = Record<string, unknown>> extends BaseGen
1394
1408
  /**
1395
1409
  * The style of button to display.
1396
1410
  */
1397
- kind?: BUTTON_KIND | "LINK";
1411
+ kind?: BUTTON_KIND | CHAT_BUTTON_KIND | "LINK";
1412
+ /**
1413
+ * The button size.
1414
+ */
1415
+ size?: BUTTON_SIZE | CHAT_BUTTON_SIZE;
1398
1416
  /**
1399
1417
  * The type of button.
1400
1418
  */
@@ -1520,6 +1538,66 @@ interface Chunk {
1520
1538
  response_id: string;
1521
1539
  };
1522
1540
  }
1541
+ /**
1542
+ * If the reasoning step is open, closed, or is controlled by Carbon AI Chat.
1543
+ *
1544
+ * If a user elects to open/close the user action will override what is provided here.
1545
+ *
1546
+ * @category Messaging
1547
+ */
1548
+ declare enum ReasoningStepOpenState {
1549
+ OPEN = "open",
1550
+ CLOSE = "close",
1551
+ DEFAULT = "default"
1552
+ }
1553
+ /**
1554
+ * An individual reasoning step.
1555
+ *
1556
+ * @category Messaging
1557
+ */
1558
+ interface ReasoningStep {
1559
+ /**
1560
+ * The title of the reasoning step.
1561
+ */
1562
+ title: string;
1563
+ /**
1564
+ * Marks if this individual step is open. Only use this if you don't want the default behavior.
1565
+ *
1566
+ * If the step has content, by default the reasoning step will automatically open and will close when the
1567
+ * next step(s) have content or the first {@link GenericItem} is returned with something to display.
1568
+ *
1569
+ * No matter what you choose, if the user manually marks something open/closed they retain control.
1570
+ */
1571
+ open_state?: ReasoningStepOpenState;
1572
+ /**
1573
+ * Optional markdown content to explain what the step is doing.
1574
+ */
1575
+ content?: string;
1576
+ }
1577
+ /**
1578
+ * The interface describing how to pass reasoning steps to the UI.
1579
+ *
1580
+ * @category Messaging
1581
+ */
1582
+ interface ReasoningSteps {
1583
+ /**
1584
+ * Marks if the reasoning step interface is open. Only use this if you don't want the default behavior.
1585
+ *
1586
+ * By default the reasoning step interface will automatically open and will then close when the first
1587
+ * {@link GenericItem} is returned with something to display.
1588
+ *
1589
+ * No matter what you choose, if the user manually marks something open/closed they retain control.
1590
+ */
1591
+ open_state?: ReasoningStepOpenState;
1592
+ /**
1593
+ * The array of reasoning steps for this message.
1594
+ */
1595
+ steps?: ReasoningStep[];
1596
+ /**
1597
+ * Optional markdown content to explain what the step is doing.
1598
+ */
1599
+ content?: string;
1600
+ }
1523
1601
  /**
1524
1602
  * This interface contains options for a {@link MessageResponse}.
1525
1603
  *
@@ -1530,8 +1608,26 @@ interface MessageResponseOptions {
1530
1608
  * This is the profile for the human or assistant who sent or triggered this message.
1531
1609
  */
1532
1610
  response_user_profile?: ResponseUserProfile;
1611
+ /**
1612
+ * Controls the display of the reasoning steps component.
1613
+ *
1614
+ * Most people should use reasoning steps instead of chain of thought.
1615
+ *
1616
+ * Chain of thought it meant more for technical "called X API and got Y result back".
1617
+ *
1618
+ * Reasoning steps can include that kind of detail depending on your use case, but is meant more for user friendly
1619
+ * content than debugging technical internal content.
1620
+ */
1621
+ reasoning?: ReasoningSteps;
1533
1622
  /**
1534
1623
  * Controls the display of the chain of thought component.
1624
+ *
1625
+ * Most people should use reasoning steps instead of chain of thought.
1626
+ *
1627
+ * Chain of thought it meant more for technical "called X API and got Y result back".
1628
+ *
1629
+ * Reasoning steps can include that kind of detail depending on your use case, but is meant more for user friendly
1630
+ * content than debugging technical internal content.
1535
1631
  */
1536
1632
  chain_of_thought?: ChainOfThoughtStep[];
1537
1633
  }
@@ -2957,6 +3053,26 @@ interface BusEventFeedback extends BusEvent {
2957
3053
  */
2958
3054
  categories?: string[];
2959
3055
  }
3056
+ /**
3057
+ * This event is fired whenever the public state returned by ChatInstance.getState() changes.
3058
+ * This includes changes to viewState, showUnreadIndicator, and other persisted state.
3059
+ *
3060
+ * @category Events
3061
+ */
3062
+ interface BusEventStateChange extends BusEvent {
3063
+ /**
3064
+ * The type of the event.
3065
+ */
3066
+ type: BusEventType.STATE_CHANGE;
3067
+ /**
3068
+ * The previous state before the change.
3069
+ */
3070
+ previousState: PublicChatState;
3071
+ /**
3072
+ * The new state after the change.
3073
+ */
3074
+ newState: PublicChatState;
3075
+ }
2960
3076
 
2961
3077
  /**
2962
3078
  * The types here describe the history structure.
@@ -3056,569 +3172,207 @@ interface CustomSendMessageOptions {
3056
3172
  }
3057
3173
 
3058
3174
  /**
3059
- * The subset of HumanAgentState that is persisted to browser storage.
3175
+ * The types of corners the chat can have.
3060
3176
  *
3061
- * @category Instance
3177
+ * @category Config
3062
3178
  */
3063
- interface PersistedHumanAgentState {
3064
- /** Indicates that the user is connected to a human agent. */
3065
- isConnected: boolean;
3066
- /** Indicates if the human agent conversation is currently suspended. */
3067
- isSuspended: boolean;
3068
- /** The profile of the last human agent to join the chat. */
3069
- responseUserProfile?: ResponseUserProfile;
3070
- /** Cache of known agent profiles by ID. */
3071
- responseUserProfiles: Record<string, ResponseUserProfile>;
3072
- /** Arbitrary state saved by the service desk. */
3073
- serviceDeskState?: unknown;
3179
+ declare enum CornersType {
3180
+ /**
3181
+ * Makes the corners on the chat component rounded.
3182
+ */
3183
+ ROUND = "round",
3184
+ /**
3185
+ * Makes the corners on the chat component square.
3186
+ */
3187
+ SQUARE = "square"
3074
3188
  }
3075
3189
 
3076
3190
  /**
3077
- * The interface represents the API contract with the chat widget and contains all the public methods and properties
3078
- * that can be used with Carbon AI Chat.
3191
+ * A conversation starter button on the home screen. Currently, only label is provided by tooling.
3079
3192
  *
3080
- * @category Instance
3193
+ * @category Config
3081
3194
  */
3082
- interface ChatInstance extends EventHandlers, ChatActions {
3195
+ interface HomeScreenStarterButton {
3083
3196
  /**
3084
- * Returns state information of the Carbon AI Chat that could be useful.
3197
+ * The display label of the button. This is also the value that is sent as the user's utterance to the assistant
3198
+ * when the button is clicked.
3085
3199
  */
3086
- getState: () => PublicChatState;
3200
+ label: string;
3087
3201
  /**
3088
- * Manager for accessing and controlling custom panels.
3202
+ * Indicates if the button was previously clicked and should be displayed as selected.
3089
3203
  */
3090
- customPanels?: CustomPanels;
3204
+ isSelected?: boolean;
3091
3205
  }
3092
3206
  /**
3093
- * This is the state made available by calling {@link ChatInstance.getState}. This is a public method that returns immutable values.
3207
+ * Starter buttons that appear on home screen.
3094
3208
  *
3095
- * @category Instance
3209
+ * @category Config
3096
3210
  */
3097
- interface PublicInputState {
3098
- /**
3099
- * @experimental Raw text currently queued in the input before being sent to customSendMessage.
3100
- */
3101
- rawValue: string;
3211
+ interface HomeScreenStarterButtons {
3212
+ isOn?: boolean;
3213
+ buttons?: HomeScreenStarterButton[];
3102
3214
  }
3103
3215
  /**
3104
- * Represents public state for each supported custom panel variant.
3105
- */
3106
- interface PublicDefaultCustomPanelState {
3107
- /** Indicates if the default custom panel overlay is currently open. */
3108
- isOpen: boolean;
3109
- }
3110
- interface PublicCustomPanelsState {
3111
- /** State for the default overlay-style custom panel. */
3112
- default: PublicDefaultCustomPanelState;
3113
- }
3114
- type PublicChatState = Readonly<Omit<PersistedState, "humanAgentState"> & {
3216
+ * Configuration for the optional home screen that appears before the assistant chat window.
3217
+ *
3218
+ * @category Config
3219
+ */
3220
+ interface HomeScreenConfig {
3115
3221
  /**
3116
- * Current human agent state.
3222
+ * If the home page is turned on via config or remote config.
3117
3223
  */
3118
- humanAgent: PublicChatHumanAgentState;
3224
+ isOn?: boolean;
3119
3225
  /**
3120
- * Counter that indicates if a message is loading and a loading indicator should be displayed.
3121
- * If "0" then we do not show loading indicator.
3226
+ * The greeting to show to the user to prompt them to start a conversation.
3122
3227
  */
3123
- isMessageLoadingCounter: number;
3228
+ greeting?: string;
3124
3229
  /**
3125
- * Optional string to display next to the loading indicator.
3230
+ * Optional conversation starter utterances that are displayed as buttons.
3126
3231
  */
3127
- isMessageLoadingText?: string;
3232
+ starters?: HomeScreenStarterButtons;
3128
3233
  /**
3129
- * Counter that indicates if the chat is hydrating and a full screen loading state should be displayed.
3234
+ * Do not show the greeting or starters.
3130
3235
  */
3131
- isHydratingCounter: number;
3236
+ customContentOnly?: boolean;
3132
3237
  /**
3133
- * @experimental State representing the main input surface.
3238
+ * Defaults to false. If enabled, a user can not navigate back to the home screen after they have sent a message to the
3239
+ * assistant. If false, the home screen is navigatable after an initial message is sent.
3134
3240
  */
3135
- input: PublicInputState;
3241
+ disableReturn?: boolean;
3242
+ }
3243
+ /**
3244
+ * Current state of home screen (currently, limited to if it is open or closed).
3245
+ *
3246
+ * @category Config
3247
+ */
3248
+ interface HomeScreenState {
3136
3249
  /**
3137
- * @experimental State for any surfaced custom panels.
3250
+ * Indicates if the home screen is currently open.
3138
3251
  */
3139
- customPanels: PublicCustomPanelsState;
3140
- }>;
3141
- interface ChatInstanceInput {
3252
+ isHomeScreenOpen: boolean;
3142
3253
  /**
3143
- * @experimental Updates the raw text queued in the input before it is sent to customSendMessage.
3144
- * Use this when you want to manipulate the canonical value while leaving
3145
- * presentation up to the default renderer or, in the future, a custom slot implementation.
3146
- *
3147
- * @example
3148
- * ```ts
3149
- * instance.input.updateRawValue((prev) => `${prev} @celeste`);
3150
- * ```
3254
+ * Indicates if the home screen should display a "return to assistant" button. This button is displayed when the user
3255
+ * has clicked the "back to home" button from the assistant.
3151
3256
  */
3152
- updateRawValue: (updater: (previous: string) => string) => void;
3257
+ showBackToAssistant: boolean;
3153
3258
  }
3259
+
3154
3260
  /**
3155
- * Current connection state of the human agent experience.
3261
+ * These variables map to CSS custom properties used in styling the AI chat interface.
3156
3262
  *
3157
- * @category Instance
3158
- */
3159
- type PublicChatHumanAgentState = Readonly<PersistedHumanAgentState & {
3160
- /** Indicates if Carbon AI Chat is attempting to connect to an agent. */
3161
- isConnecting: boolean;
3162
- }>;
3163
- /**
3164
- * This is a subset of the public interface that is managed by the event bus that is used for registering and
3165
- * unregistering event listeners on the bus.
3263
+ * Keys map to the underlying `--cds-aichat-*` custom properties.
3166
3264
  *
3167
- * @category Instance
3265
+ * You can use any standard CSS as the value.
3266
+ *
3267
+ * @category Config
3168
3268
  */
3169
- interface EventHandlers {
3269
+ declare enum LayoutCustomProperties {
3170
3270
  /**
3171
- * Adds the given event handler as a listener for events of the given type.
3271
+ * Float layout only.
3272
+ *
3273
+ * Minimum height of the chat container.
3274
+ *
3275
+ * Defaults to `calc(100vh - 4rem)`
3172
3276
  *
3173
- * @param handlers The handler or handlers along with the event type to start listening for events.
3174
- * @returns The instance for method chaining.
3175
3277
  */
3176
- on: (handlers: TypeAndHandler | TypeAndHandler[]) => EventHandlers;
3278
+ height = "height",
3177
3279
  /**
3178
- * Removes an event listener that was previously added via {@link on} or {@link once}.
3280
+ * Float layout only.
3179
3281
  *
3180
- * @param handlers The handler or handlers along with the event type to stop listening for events.
3181
- * @returns The instance for method chaining.
3282
+ * Maximum height of the chat container (float layout).
3283
+ *
3284
+ * Defaults to `640px`.
3182
3285
  */
3183
- off: (handlers: TypeAndHandler | TypeAndHandler[]) => EventHandlers;
3286
+ max_height = "max-height",
3184
3287
  /**
3185
- * Adds the given event handler as a listener for events of the given type. After the first event is handled, this
3186
- * handler will automatically be removed.
3288
+ * Float layout only.
3187
3289
  *
3188
- * @param handlers The handler or handlers along with the event type to start listening for an event.
3189
- * @returns The instance for method chaining.
3290
+ * Width of the chat panel (float layout).
3291
+ *
3292
+ * Defaults to `380px`.
3190
3293
  */
3191
- once: (handlers: TypeAndHandler | TypeAndHandler[]) => EventHandlers;
3192
- }
3193
- /**
3194
- * The type of handler for event bus events. This function may return a Promise in which case, the bus will await
3195
- * the result and the loop will block until the Promise is resolved.
3196
- *
3197
- * @category Instance
3198
- */
3199
- type EventBusHandler<T extends BusEvent = BusEvent> = (event: T, instance: ChatInstance) => unknown;
3200
- /**
3201
- * The type of the object that is passed to the event bus functions (e.g. "on") when registering a handler.
3202
- *
3203
- * @category Instance
3204
- */
3205
- interface TypeAndHandler {
3294
+ width = "width",
3206
3295
  /**
3207
- * The type of event this handler is for.
3296
+ * Float layout only.
3297
+ *
3298
+ * z-index of the chat overlay or container (float layout).
3299
+ *
3300
+ * Defaults to `99999`.
3208
3301
  */
3209
- type: BusEventType;
3302
+ z_index = "z-index",
3210
3303
  /**
3211
- * The handler for events of this type.
3304
+ * Custom element layouts only.
3305
+ *
3306
+ * Max width of messages area in fullscreen / larger views if {@link LayoutConfig.hascontentmaxwidth} is not set to
3307
+ * true.
3308
+ *
3309
+ * Defaults to `672px`.
3212
3310
  */
3213
- handler: EventBusHandler;
3311
+ messages_max_width = "messages-max-width"
3214
3312
  }
3313
+
3215
3314
  /**
3216
- * This is a subset of the public interface that provides methods that can be used by the user to control the widget
3217
- * and have it perform certain actions.
3315
+ * Configuration for the launcher.
3218
3316
  *
3219
- * @category Instance
3317
+ * @category Config
3220
3318
  */
3221
- interface ChatActions {
3222
- /**
3223
- * Messaging actions for a chat instance.
3224
- */
3225
- messaging: ChatInstanceMessaging;
3226
- /**
3227
- * This function can be called when another component wishes this component to gain focus. It is up to the
3228
- * component to decide where focus belongs. This may return true or false to indicate if a suitable focus location
3229
- * was found.
3230
- */
3231
- requestFocus: () => boolean | void;
3232
- /**
3233
- * Sends the given message to the assistant on the remote server. This will result in a "pre:send" and "send" event
3234
- * being fired on the event bus. The returned promise will resolve once a response has received and processed and
3235
- * both the "pre:receive" and "receive" events have fired. It will reject when too many errors have occurred and
3236
- * the system gives up retrying.
3237
- *
3238
- * @param message The message to send.
3239
- * @param options Options for the message sent.
3240
- */
3241
- send: (message: MessageRequest | string, options?: SendOptions) => Promise<void>;
3242
- /**
3243
- * Fire the view:pre:change and view:change events and change the view of the Carbon AI Chat. If a {@link ViewType} is
3244
- * provided then that view will become visible and the rest will be hidden. If a {@link ViewState} is provided that
3245
- * includes all of the views then all of the views will be changed accordingly. If a partial {@link ViewState} is
3246
- * provided then only the views provided will be changed.
3247
- */
3248
- changeView: (newView: ViewType | ViewState) => Promise<void>;
3249
- /**
3250
- * Returns the list of writable elements.
3251
- */
3252
- writeableElements: Partial<WriteableElements>;
3253
- /**
3254
- * @deprecated Configure via {@link InputConfig.isVisible}.
3255
- */
3256
- updateInputFieldVisibility: (isVisible: boolean) => void;
3257
- /**
3258
- * @deprecated Configure via {@link InputConfig.isDisabled}
3259
- * or {@link PublicConfig.isReadonly}.
3260
- */
3261
- updateInputIsDisabled: (isDisabled: boolean) => void;
3319
+ interface LauncherConfig {
3262
3320
  /**
3263
- * @deprecated Configure via {@link LauncherConfig.showUnreadIndicator}.
3321
+ * If the launcher is visible. Defaults to true.
3264
3322
  */
3265
- updateAssistantUnreadIndicatorVisibility: (isVisible: boolean) => void;
3323
+ isOn?: boolean;
3266
3324
  /**
3267
- * Scrolls to the (original) message with the given ID. Since there may be multiple message items in a given
3268
- * message, this will scroll the first message to the top of the message window.
3269
- *
3270
- * @param messageID The (original) message ID to scroll to.
3271
- * @param animate Whether or not the scroll should be animated. Defaults to true.
3325
+ * Controls whether the unread indicator dot shows even when no human-agent unread count exists.
3272
3326
  */
3273
- scrollToMessage: (messageID: string, animate?: boolean) => void;
3327
+ showUnreadIndicator?: boolean;
3274
3328
  /**
3275
- * Restarts the conversation with the assistant. This does not make any changes to a conversation with a human agent.
3276
- * This will clear all the current assistant messages from the main assistant view and cancel any outstanding
3277
- * messages. This will also clear the current assistant session which will force a new session to start on the
3278
- * next message.
3279
- *
3280
- * @deprecated Use {@link ChatInstanceMessaging.restartConversation} instead.
3329
+ * Properties specific to the mobile launcher.
3281
3330
  */
3282
- restartConversation: () => Promise<void>;
3331
+ mobile?: LauncherCallToActionConfig;
3283
3332
  /**
3284
- * Initiates a doAutoScroll on the currently visible chat panel.
3333
+ * Properties specific to the desktop launcher.
3285
3334
  */
3286
- doAutoScroll: () => void;
3335
+ desktop?: LauncherCallToActionConfig;
3336
+ }
3337
+ /**
3338
+ * @category Config
3339
+ */
3340
+ interface LauncherCallToActionConfig {
3287
3341
  /**
3288
- * @param direction Either increases or decreases the internal counter that indicates whether the "message is loading"
3289
- * indicator is shown. If the count is greater than zero, then the indicator is shown. Values of "increase" or "decrease" will
3290
- * increase or decrease the value. "reset" will set the value back to 0. You may pass undefined as the first value
3291
- * if you just wish to update the message.
3342
+ * If the launcher will have a call to action expanded state. Defaults to false. This feature will be removed in
3343
+ * the next major release of the AI Chat.
3292
3344
  *
3293
- * You can access the current value via {@link ChatInstance.getState}.
3294
- *
3295
- * @param message You can also, optionally, pass a plain text string as the second argument. It will display next to the loading indicator for
3296
- * you to give meaningful feedback while the message is loading (or simple strings like "Thinking...", etc). The most
3297
- * recent value will be used. So if you call it with a string value and then again with no value, the value will be
3298
- * replaced with undefined and stop showing in the UI.
3345
+ * @deprecated
3299
3346
  */
3300
- updateIsMessageLoadingCounter: (direction: IncreaseOrDecrease, message?: string) => void;
3347
+ isOn?: boolean;
3301
3348
  /**
3302
- * Either increases or decreases the internal counter that indicates whether the hydration fullscreen loading state is
3303
- * shown. If the count is greater than zero, then the indicator is shown. Values of "increase" or "decrease" will
3304
- * increase or decrease the value. "reset" will set the value back to 0.
3349
+ * The title that will be used by the expanded state of the launcher. If nothing is set in the config then a default
3350
+ * translated string will be used.
3305
3351
  *
3306
- * You can access the current value via {@link ChatInstance.getState}.
3352
+ * @deprecated
3307
3353
  */
3308
- updateIsChatLoadingCounter: (direction: IncreaseOrDecrease) => void;
3354
+ title?: string;
3309
3355
  /**
3310
- * The state of notifications in the chat.
3356
+ * The amount of time to wait before extending the launcher. If nothing is set then the default time of
3357
+ * 15s will be used.
3311
3358
  *
3312
- * @experimental
3313
- */
3314
- notifications: ChatInstanceNotifications;
3315
- /**
3316
- * Actions for mutating the chat input contents.
3317
- */
3318
- input: ChatInstanceInput;
3319
- /**
3320
- * Actions that are related to a service desk integration.
3359
+ * @deprecated
3321
3360
  */
3322
- serviceDesk: ChatInstanceServiceDeskActions;
3361
+ timeToExpand?: number;
3323
3362
  /**
3324
- * Remove any record of the current session from the browser's SessionStorage.
3325
- *
3326
- * @param keepOpenState If we are destroying the session to restart the chat this can be used to preserve if the web
3327
- * chat is open.
3363
+ * An optional override of the icon shown on the launcher.
3328
3364
  */
3329
- destroySession: (keepOpenState?: boolean) => Promise<void>;
3365
+ avatarUrlOverride?: string;
3330
3366
  }
3367
+
3331
3368
  /**
3332
- * @category Instance
3369
+ * This file contains the definition for the public application configuration operations that are provided by the
3370
+ * host page.
3333
3371
  */
3334
- type IncreaseOrDecrease = "increase" | "decrease" | "reset" | undefined;
3335
3372
  /**
3336
- * This interface represents the options for when a MessageRequest is sent to the server with the send method.
3373
+ * The raw strings used for {@link PublicConfig.strings}. Presented in ICU format.
3337
3374
  *
3338
- * @category Instance
3339
- */
3340
- interface SendOptions {
3341
- /**
3342
- * If you want to send a message to the API, but NOT have it show up in the UI, set this to true. The "pre:send"
3343
- * and "send" events will still be fired but the message will not be added to the local message list displayed in
3344
- * the UI. Note that the response message will still be added.
3345
- */
3346
- silent?: boolean;
3347
- }
3348
- /**
3349
- * An object of elements we expose to developers to write to. Be sure to check the documentation of the React or
3350
- * web component you are using for how to make use of this, as it differs based on implementation.
3351
- *
3352
- * @category Instance
3353
- */
3354
- type WriteableElements = Record<WriteableElementName, HTMLElement>;
3355
- /**
3356
- * @category Instance
3357
- */
3358
- declare enum WriteableElementName {
3359
- /**
3360
- * An element that appears in the AI theme only and is shown beneath the title and description in the AI tooltip
3361
- * content.
3362
- */
3363
- AI_TOOLTIP_AFTER_DESCRIPTION_ELEMENT = "aiTooltipAfterDescriptionElement",
3364
- /**
3365
- * An element that appears in the main message body directly above the welcome node.
3366
- */
3367
- WELCOME_NODE_BEFORE_ELEMENT = "welcomeNodeBeforeElement",
3368
- /**
3369
- * An element that appears in the header on a new line. Only visible while talking to the assistant.
3370
- */
3371
- HEADER_BOTTOM_ELEMENT = "headerBottomElement",
3372
- /**
3373
- * An element that appears after the messages area and before the input area.
3374
- */
3375
- BEFORE_INPUT_ELEMENT = "beforeInputElement",
3376
- /**
3377
- * An element that appears above the input field on the home screen.
3378
- */
3379
- HOME_SCREEN_BEFORE_INPUT_ELEMENT = "homeScreenBeforeInputElement",
3380
- /**
3381
- * An element that appears on the home screen after the conversation starters.
3382
- */
3383
- HOME_SCREEN_AFTER_STARTERS_ELEMENT = "homeScreenAfterStartersElement",
3384
- /**
3385
- * An element that appears on the home screen above the welcome message and conversation starters.
3386
- */
3387
- HOME_SCREEN_HEADER_BOTTOM_ELEMENT = "homeScreenHeaderBottomElement",
3388
- /**
3389
- * An element to be housed in the custom panel.
3390
- */
3391
- CUSTOM_PANEL_ELEMENT = "customPanelElement"
3392
- }
3393
- /**
3394
- * Add notification messages to the chat. This component has some a11y bugs before we can mark it complete.
3395
- *
3396
- * @category Instance
3397
- *
3398
- * @experimental
3399
- */
3400
- interface ChatInstanceNotifications {
3401
- /**
3402
- * Add a system level notification to the list of system notifications.
3403
- */
3404
- addNotification: (notification: NotificationMessage) => void;
3405
- /**
3406
- * Remove a system level notification from the list of system notifications.
3407
- */
3408
- removeNotifications: (groupID: string) => void;
3409
- /**
3410
- * Remove all system level notifications from the list of system notifications.
3411
- */
3412
- removeAllNotifications: () => void;
3413
- }
3414
- /**
3415
- * @category Instance
3416
- */
3417
- type ChangeFunction = (text: string) => void;
3418
- /**
3419
- * Upload options. Currently only applies to conversations with a human agent.
3420
- *
3421
- * @category Instance
3422
- */
3423
- interface FileUploadCapabilities {
3424
- /**
3425
- * Indicates that file uploads may be performed by the user.
3426
- */
3427
- allowFileUploads: boolean;
3428
- /**
3429
- * If file uploads are allowed, this indicates if more than one file may be selected at a time. The default is false.
3430
- */
3431
- allowMultipleFileUploads: boolean;
3432
- /**
3433
- * If file uploads are allowed, this is the set a file types that are allowed. This is filled into the "accept"
3434
- * field for the file input element.
3435
- */
3436
- allowedFileUploadTypes: string;
3437
- }
3438
- /**
3439
- * Start or end conversations with human agent.
3440
- *
3441
- * @category Instance
3442
- */
3443
- interface ChatInstanceServiceDeskActions {
3444
- /**
3445
- * Ends the conversation with a human agent. This does not request confirmation from the user first. If the user
3446
- * is not connected or connecting to a human agent, this function has no effect. You can determine if the user is
3447
- * connected or connecting by calling {@link ChatInstance.getState}. Note that this function
3448
- * returns a Promise that only resolves when the conversation has ended. This includes after the
3449
- * {@link BusEventType.HUMAN_AGENT_PRE_END_CHAT} and {@link BusEventType.HUMAN_AGENT_END_CHAT} events have been fired and
3450
- * resolved.
3451
- */
3452
- endConversation: () => Promise<void>;
3453
- /**
3454
- * Sets the suspended state for an agent conversation. A conversation can be suspended or un-suspended only if the
3455
- * user is currently connecting or connected to an agent. If a conversation is suspended, then messages from the user
3456
- * will no longer be routed to the service desk and incoming messages from the service desk will not be displayed. In
3457
- * addition, the current connection status with an agent will not be shown.
3458
- */
3459
- updateIsSuspended: (isSuspended: boolean) => Promise<void>;
3460
- }
3461
-
3462
- /**
3463
- * The types of corners the chat can have.
3464
- *
3465
- * @category Config
3466
- */
3467
- declare enum CornersType {
3468
- /**
3469
- * Makes the corners on the chat component rounded.
3470
- */
3471
- ROUND = "round",
3472
- /**
3473
- * Makes the corners on the chat component square.
3474
- */
3475
- SQUARE = "square"
3476
- }
3477
-
3478
- /**
3479
- * A conversation starter button on the home screen. Currently, only label is provided by tooling.
3480
- *
3481
- * @category Config
3482
- */
3483
- interface HomeScreenStarterButton {
3484
- /**
3485
- * The display label of the button. This is also the value that is sent as the user's utterance to the assistant
3486
- * when the button is clicked.
3487
- */
3488
- label: string;
3489
- /**
3490
- * Indicates if the button was previously clicked and should be displayed as selected.
3491
- */
3492
- isSelected?: boolean;
3493
- }
3494
- /**
3495
- * Starter buttons that appear on home screen.
3496
- *
3497
- * @category Config
3498
- */
3499
- interface HomeScreenStarterButtons {
3500
- isOn?: boolean;
3501
- buttons?: HomeScreenStarterButton[];
3502
- }
3503
- /**
3504
- * Configuration for the optional home screen that appears before the assistant chat window.
3505
- *
3506
- * @category Config
3507
- */
3508
- interface HomeScreenConfig {
3509
- /**
3510
- * If the home page is turned on via config or remote config.
3511
- */
3512
- isOn?: boolean;
3513
- /**
3514
- * The greeting to show to the user to prompt them to start a conversation.
3515
- */
3516
- greeting?: string;
3517
- /**
3518
- * Optional conversation starter utterances that are displayed as buttons.
3519
- */
3520
- starters?: HomeScreenStarterButtons;
3521
- /**
3522
- * Do not show the greeting or starters.
3523
- */
3524
- customContentOnly?: boolean;
3525
- /**
3526
- * Defaults to false. If enabled, a user can not navigate back to the home screen after they have sent a message to the
3527
- * assistant. If false, the home screen is navigatable after an initial message is sent.
3528
- */
3529
- disableReturn?: boolean;
3530
- }
3531
- /**
3532
- * Current state of home screen (currently, limited to if it is open or closed).
3533
- *
3534
- * @category Config
3535
- */
3536
- interface HomeScreenState {
3537
- /**
3538
- * Indicates if the home screen is currently open.
3539
- */
3540
- isHomeScreenOpen: boolean;
3541
- /**
3542
- * Indicates if the home screen should display a "return to assistant" button. This button is displayed when the user
3543
- * has clicked the "back to home" button from the assistant.
3544
- */
3545
- showBackToAssistant: boolean;
3546
- }
3547
-
3548
- /**
3549
- * Valid public CSS variables that can be controlled when white labeling is disabled.
3550
- * These variables map to CSS custom properties used in styling the AI chat interface.
3551
- *
3552
- * Keys map to the underlying `--cds-aichat-…` custom properties.
3553
- *
3554
- * @category Config
3555
- */
3556
- declare enum LayoutCustomProperties {
3557
- /** Minimum height of the chat container (float layout). */
3558
- height = "height",
3559
- /** Maximum height of the chat container (float layout). */
3560
- max_height = "max-height",
3561
- /** Width of the chat panel (float layout). */
3562
- width = "width",
3563
- /** z-index of the chat overlay or container (float layout). */
3564
- z_index = "z-index"
3565
- }
3566
-
3567
- /**
3568
- * Configuration for the launcher.
3569
- *
3570
- * @category Config
3571
- */
3572
- interface LauncherConfig {
3573
- /**
3574
- * If the launcher is visible. Defaults to true.
3575
- */
3576
- isOn?: boolean;
3577
- /**
3578
- * Controls whether the unread indicator dot shows even when no human-agent unread count exists.
3579
- */
3580
- showUnreadIndicator?: boolean;
3581
- /**
3582
- * Properties specific to the mobile launcher.
3583
- */
3584
- mobile?: LauncherCallToActionConfig;
3585
- /**
3586
- * Properties specific to the desktop launcher.
3587
- */
3588
- desktop?: LauncherCallToActionConfig;
3589
- }
3590
- /**
3591
- * @category Config
3592
- */
3593
- interface LauncherCallToActionConfig {
3594
- /**
3595
- * If the launcher will expand with a call to action.
3596
- */
3597
- isOn?: boolean;
3598
- /**
3599
- * The title that will be used by the expanded state of the launcher. If nothing is set in the config then a default
3600
- * translated string will be used.
3601
- */
3602
- title?: string;
3603
- /**
3604
- * The amount of time to wait before extending the launcher. If nothing is set then the default time of
3605
- * 15s will be used.
3606
- */
3607
- timeToExpand?: number;
3608
- /**
3609
- * An optional override of the icon shown on the launcher.
3610
- */
3611
- avatarUrlOverride?: string;
3612
- }
3613
-
3614
- /**
3615
- * This file contains the definition for the public application configuration operations that are provided by the
3616
- * host page.
3617
- */
3618
- /**
3619
- * The raw strings used for {@link PublicConfig.strings}. Presented in ICU format.
3620
- *
3621
- * @category Config
3375
+ * @category Config
3622
3376
  */
3623
3377
  declare const enLanguagePack: {
3624
3378
  ai_slug_label: string;
@@ -3669,6 +3423,7 @@ declare const enLanguagePack: {
3669
3423
  messages_searchResultsCollapse: string;
3670
3424
  messages_assistantIsLoading: string;
3671
3425
  messages_agentIsTyping: string;
3426
+ messages_focusHandle: string;
3672
3427
  messages_scrollHandle: string;
3673
3428
  messages_scrollHandleDetailed: string;
3674
3429
  messages_scrollHandleEnd: string;
@@ -3676,7 +3431,6 @@ declare const enLanguagePack: {
3676
3431
  messages_scrollMoreButton: string;
3677
3432
  message_labelAssistant: string;
3678
3433
  message_labelYou: string;
3679
- notifications_toastClose: string;
3680
3434
  buttons_restart: string;
3681
3435
  buttons_cancel: string;
3682
3436
  buttons_retry: string;
@@ -3768,7 +3522,6 @@ declare const enLanguagePack: {
3768
3522
  conversationalSearch_citationsLabel: string;
3769
3523
  conversationalSearch_toggleCitations: string;
3770
3524
  conversationalSearch_responseStopped: string;
3771
- launcher_chatNow: string;
3772
3525
  iframe_ariaSourceLoaded: string;
3773
3526
  iframe_ariaImageAltText: string;
3774
3527
  iframe_ariaClosePanel: string;
@@ -3795,6 +3548,14 @@ declare const enLanguagePack: {
3795
3548
  table_itemsPerPage: string;
3796
3549
  table_paginationSupplementalText: string;
3797
3550
  table_paginationStatus: string;
3551
+ codeSnippet_feedback: string;
3552
+ codeSnippet_showLessText: string;
3553
+ codeSnippet_showMoreText: string;
3554
+ codeSnippet_tooltipContent: string;
3555
+ codeSnippet_lineCount: string;
3556
+ codeSnippet_foldCollapse: string;
3557
+ codeSnippet_foldExpand: string;
3558
+ table_downloadButton: string;
3798
3559
  feedback_positiveLabel: string;
3799
3560
  feedback_negativeLabel: string;
3800
3561
  feedback_defaultTitle: string;
@@ -3812,500 +3573,874 @@ declare const enLanguagePack: {
3812
3573
  chainOfThought_statusFailedLabel: string;
3813
3574
  chainOfThought_statusProcessingLabel: string;
3814
3575
  chainOfThought_explainabilityLabel: string;
3576
+ reasoningSteps_mainLabelOpen: string;
3577
+ reasoningSteps_mainLabelClosed: string;
3815
3578
  };
3816
3579
  /**
3817
- * A language pack represents the set of display strings for a particular language.
3818
- * It defines all the text strings that can be customized for different languages.
3819
- *
3580
+ * A language pack represents the set of display strings for a particular language.
3581
+ * It defines all the text strings that can be customized for different languages.
3582
+ *
3583
+ * @category Config
3584
+ */
3585
+ type LanguagePack = typeof enLanguagePack;
3586
+ /**
3587
+ * Configuration interface for Carbon AI Chat.
3588
+ *
3589
+ * @category Config
3590
+ */
3591
+ interface PublicConfig {
3592
+ /**
3593
+ * This is a one-off listener for catastrophic errors. This is used instead of a normal event bus handler because this function can be
3594
+ * defined and called before the event bus has been created.
3595
+ */
3596
+ onError?: (data: OnErrorData) => void;
3597
+ /**
3598
+ * By default, the chat window will be rendered in a "closed" state.
3599
+ */
3600
+ openChatByDefault?: boolean;
3601
+ /**
3602
+ * Disclaimer screen configuration.
3603
+ *
3604
+ * If `disclaimerHTML` changes after the disclaimer has been accepted, we request a user to accept again.
3605
+ */
3606
+ disclaimer?: DisclaimerPublicConfig;
3607
+ /**
3608
+ * This value is only used when a custom element is being used to render the widget. By default, a number of
3609
+ * enhancements to the widget are activated on mobile devices which can interfere with a custom element. This
3610
+ * value can be used to disable those enhancements while using a custom element.
3611
+ */
3612
+ disableCustomElementMobileEnhancements?: boolean;
3613
+ /**
3614
+ * Add a bunch of noisy console.log messages!
3615
+ */
3616
+ debug?: boolean;
3617
+ /**
3618
+ * Which Carbon theme tokens to inject. If unset (falsy), the chat inherits tokens from the host page.
3619
+ * Set to a specific theme to force token injection.
3620
+ */
3621
+ injectCarbonTheme?: CarbonTheme;
3622
+ /**
3623
+ * Enables Carbon AI theme styling. Defaults to true.
3624
+ */
3625
+ aiEnabled?: boolean;
3626
+ /**
3627
+ * This is a factory for producing custom implementations of service desks. If this value is set, then this will
3628
+ * be used to create an instance of a {@link ServiceDesk} when the user attempts to connect to an agent.
3629
+ *
3630
+ * If it is changed in the middle of a conversation (you should obviously avoid this) the conversation with the
3631
+ * human agent will be disconnected.
3632
+ */
3633
+ serviceDeskFactory?: (parameters: ServiceDeskFactoryParameters) => Promise<ServiceDesk>;
3634
+ /**
3635
+ * Any public config to apply to service desks.
3636
+ */
3637
+ serviceDesk?: ServiceDeskPublicConfig;
3638
+ /**
3639
+ * If the Carbon AI Chat should grab focus if the chat is open on page load.
3640
+ */
3641
+ shouldTakeFocusIfOpensAutomatically?: boolean;
3642
+ /**
3643
+ * An optional namespace that can be added to the Carbon AI Chat that must be 30 characters or under. This value is
3644
+ * intended to enable multiple instances of the Carbon AI Chat to be used on the same page. The namespace for this web
3645
+ * chat. This value is used to generate a value to append to anything unique (id, session keys, etc) to allow
3646
+ * multiple Carbon AI Chats on the same page.
3647
+ *
3648
+ * Note: this value is used in the aria region label for the Carbon AI Chat. This means this value will be read out loud
3649
+ * by users using a screen reader.
3650
+ */
3651
+ namespace?: string;
3652
+ /**
3653
+ * Indicates if Carbon AI Chat should sanitize HTML from the assistant.
3654
+ */
3655
+ shouldSanitizeHTML?: boolean;
3656
+ /**
3657
+ * Extra config for controlling the behavior of the header.
3658
+ */
3659
+ header?: HeaderConfig;
3660
+ /**
3661
+ * The config object for changing Carbon AI Chat's layout.
3662
+ */
3663
+ layout?: LayoutConfig;
3664
+ /**
3665
+ * Config options for controlling messaging.
3666
+ */
3667
+ messaging?: PublicConfigMessaging;
3668
+ /**
3669
+ * Sets the chat into a read only mode for displaying old conversations.
3670
+ */
3671
+ isReadonly?: boolean;
3672
+ /**
3673
+ * Sets the name of the assistant. Defaults to "watsonx". Used in screen reader announcements and error messages.
3674
+ */
3675
+ assistantName?: string;
3676
+ /**
3677
+ * The locale to use for the widget. This controls the language pack and regional formatting.
3678
+ * Example values include: 'en', 'en-us', 'fr', 'es'.
3679
+ */
3680
+ locale?: string;
3681
+ /**
3682
+ * Configuration for the homescreen.
3683
+ *
3684
+ * If you change anything but `is_on` after the chat session has started, the chat will handle it gracefully.
3685
+ *
3686
+ * If you turn on the homescreen after the user has already started chatting, it will show up in the header as
3687
+ * an icon, but the user won't be forced to go back to the homescreen (unlike turning on the disclaimer mid-chat).
3688
+ */
3689
+ homescreen?: HomeScreenConfig;
3690
+ /**
3691
+ * Configuration for the launcher.
3692
+ */
3693
+ launcher?: LauncherConfig;
3694
+ /**
3695
+ * Configuration for the main input field on the chat.
3696
+ */
3697
+ input?: InputConfig;
3698
+ /**
3699
+ * Optional partial language pack overrides. Values merge with defaults.
3700
+ */
3701
+ strings?: DeepPartial<LanguagePack>;
3702
+ }
3703
+ /**
3704
+ * A single menu option.
3705
+ *
3706
+ * @category Config
3707
+ */
3708
+ interface CustomMenuOption {
3709
+ /**
3710
+ * The text to display for the menu option.
3711
+ */
3712
+ text: string;
3713
+ /**
3714
+ * The callback handler to call when the option is selected. Provide this of "url".
3715
+ */
3716
+ handler: () => void;
3717
+ }
3718
+ /**
3719
+ * @category Config
3720
+ */
3721
+ declare enum MinimizeButtonIconType {
3722
+ /**
3723
+ * This shows an "X" icon.
3724
+ */
3725
+ CLOSE = "close",
3726
+ /**
3727
+ * This shows a "-" icon.
3728
+ */
3729
+ MINIMIZE = "minimize",
3730
+ /**
3731
+ * This shows an icon that indicates that the Carbon AI Chat can be collapsed into a side panel.
3732
+ */
3733
+ SIDE_PANEL_LEFT = "side-panel-left",
3734
+ /**
3735
+ * This shows an icon that indicates that the Carbon AI Chat can be collapsed into a side panel.
3736
+ */
3737
+ SIDE_PANEL_RIGHT = "side-panel-right"
3738
+ }
3739
+ /**
3740
+ * Configuration for the input field in the main chat and homescreen.
3741
+ *
3742
+ * @category Config
3743
+ */
3744
+ interface InputConfig {
3745
+ /**
3746
+ * The maximum number of characters allowed in the input field. Defaults to 10000.
3747
+ */
3748
+ maxInputCharacters?: number;
3749
+ /**
3750
+ * Controls whether the main input surface is visible when the chat loads.
3751
+ * Defaults to true.
3752
+ */
3753
+ isVisible?: boolean;
3754
+ /**
3755
+ * If true, the main input surface starts in a disabled (read-only) state.
3756
+ * Equivalent to {@link PublicConfig.isReadonly}, but scoped just to the assistant input.
3757
+ */
3758
+ isDisabled?: boolean;
3759
+ }
3760
+ /**
3761
+ * Configuration for the main header of the chat.
3762
+ *
3763
+ * @category Config
3764
+ */
3765
+ interface HeaderConfig {
3766
+ /**
3767
+ * If the chat should supply its own header. Can be false if you have a fullscreen chat or one embedded into a page and
3768
+ * you want to only make use of the main application header. Defaults to true.
3769
+ */
3770
+ isOn?: boolean;
3771
+ /**
3772
+ * Indicates the icon to use for the close button in the header.
3773
+ */
3774
+ minimizeButtonIconType?: MinimizeButtonIconType;
3775
+ /**
3776
+ * Hide the ability to minimize the Carbon AI Chat.
3777
+ */
3778
+ hideMinimizeButton?: boolean;
3779
+ /**
3780
+ * If true, shows the restart conversation button in the header of home screen and main chat.
3781
+ */
3782
+ showRestartButton?: boolean;
3783
+ /**
3784
+ * The chat header title.
3785
+ */
3786
+ title?: string;
3787
+ /**
3788
+ * The name displayed after the title.
3789
+ */
3790
+ name?: string;
3791
+ /**
3792
+ * All the currently configured custom menu options.
3793
+ */
3794
+ menuOptions?: CustomMenuOption[];
3795
+ /**
3796
+ * Controls whether to show the AI label/slug in the header. Defaults to true.
3797
+ *
3798
+ * There is currently no version of this that does not include the AI theme
3799
+ * blue gradients.
3800
+ */
3801
+ showAiLabel?: boolean;
3802
+ }
3803
+ /**
3804
+ * @category Config
3805
+ */
3806
+ interface LayoutConfig {
3807
+ /**
3808
+ * Indicates if the Carbon AI Chat widget should keep its border and box-shadow.
3809
+ */
3810
+ showFrame?: boolean;
3811
+ /**
3812
+ * Indicates if content inside the Carbon AI Chat widget should be constrained to a max-width.
3813
+ *
3814
+ * At larger widths the card, carousel, options and conversational search response types
3815
+ * have pending issues.
3816
+ */
3817
+ hasContentMaxWidth?: boolean;
3818
+ /**
3819
+ * This flag is used to disable Carbon AI Chat's rounded corners.
3820
+ */
3821
+ corners?: CornersType;
3822
+ /**
3823
+ * CSS variable overrides for the chat UI.
3824
+ *
3825
+ * Keys correspond to values from `LayoutCustomProperties` (e.g. `LayoutCustomProperties.height`),
3826
+ * which map to the underlying `--cds-aichat-…` custom properties.
3827
+ * Values are raw CSS values such as `"420px"`, `"9999"`, etc.
3828
+ *
3829
+ * Example:
3830
+ * { height: "560px", width: "420px" }
3831
+ */
3832
+ customProperties?: Partial<Record<LayoutCustomProperties, string>>;
3833
+ }
3834
+ /**
3835
+ * Config options for controlling messaging.
3836
+ *
3837
+ * @category Config
3838
+ */
3839
+ interface PublicConfigMessaging {
3840
+ /**
3841
+ * Indicates if Carbon AI Chat should make a request for the welcome message when a new conversation begins. If this is
3842
+ * true, then Carbon AI Chat will start with an empty conversation.
3843
+ *
3844
+ * **Manual session management required**: Changes to this property after conversation has started have no effect.
3845
+ * To apply new welcome behavior, call `instance.messaging.restartConversation()`.
3846
+ */
3847
+ skipWelcome?: boolean;
3848
+ /**
3849
+ * Changes the timeout used by the message service when making message calls. The timeout is in seconds. The
3850
+ * default is 150 seconds. After this time, an error will be shown in the client and an Abort signal will be sent
3851
+ * to customSendMessage. If set to 0, the chat will never timeout. This is tied to either {@link ChatInstanceMessaging.addMessage} or
3852
+ * {@link ChatInstanceMessaging.addMessageChunk} being called after this message was sent. If neither of those methods
3853
+ * are called with in the window defined here, the chat will timeout (unless the value is set to 0).
3854
+ */
3855
+ messageTimeoutSecs?: number;
3856
+ /**
3857
+ * Controls how long AI chat should wait before showing the loading indicator. If set to 0, the chat will never show
3858
+ * the loading indicator on its own. This is tied to either {@link ChatInstanceMessaging.addMessage} or
3859
+ * {@link ChatInstanceMessaging.addMessageChunk} being called after this message was sent. If neither of those methods
3860
+ * are called with in the window defined here, the loading indicator will be shown.
3861
+ */
3862
+ messageLoadingIndicatorTimeoutSecs?: number;
3863
+ /**
3864
+ * A callback for Carbon AI Chat to use to send messages to your assistant.
3865
+ *
3866
+ * Carbon AI Chat will queue up any additional user messages until the Promise from a previous call to customSendMessage
3867
+ * has resolved. If you do not make customSendMessage async, it will be up to you to manage what happens when a message is
3868
+ * sent when the previous is still processing. If the Promise rejects, an error indicator will be displayed next to the user's message.
3869
+ *
3870
+ * If the request takes longer than PublicConfigMessaging.messageTimeoutSecs than the AbortSignal will be sent.
3871
+ */
3872
+ customSendMessage?: (request: MessageRequest, requestOptions: CustomSendMessageOptions, instance: ChatInstance) => Promise<void> | void;
3873
+ /**
3874
+ * This is a callback function that is used by Carbon AI Chat to retrieve history data for populating the Carbon AI Chat. If
3875
+ * this function is defined, it will be used instead of any other mechanism for fetching history.
3876
+ *
3877
+ * If this function is mutated after it was initially called, the chat does not re-call it.
3878
+ */
3879
+ customLoadHistory?: (instance: ChatInstance) => Promise<HistoryItem[]>;
3880
+ }
3881
+ /**
3820
3882
  * @category Config
3821
3883
  */
3822
- type LanguagePack = typeof enLanguagePack;
3884
+ interface DisclaimerPublicConfig {
3885
+ /**
3886
+ * If the disclaimer is turned on.
3887
+ */
3888
+ isOn: boolean;
3889
+ /**
3890
+ * HTML content to show in disclaimer.
3891
+ */
3892
+ disclaimerHTML: string;
3893
+ }
3823
3894
  /**
3824
- * Configuration interface for Carbon AI Chat.
3895
+ * A string identifying what Carbon Theme we should base UI variables off of.
3896
+ * Defaults to "inherit". If you are not hosting the chat on a website that is Carbon styles, you will want to choose
3897
+ * once of the non-inherited values to inject the correct CSS custom property values into the code. See
3898
+ * https://carbondesignsystem.com/guidelines/color/tokens.
3825
3899
  *
3826
3900
  * @category Config
3827
3901
  */
3828
- interface PublicConfig {
3902
+ declare enum CarbonTheme {
3829
3903
  /**
3830
- * This is a one-off listener for catastrophic errors. This is used instead of a normal event bus handler because this function can be
3831
- * defined and called before the event bus has been created.
3904
+ * Injects Carbon white theme tokens.
3832
3905
  */
3833
- onError?: (data: OnErrorData) => void;
3906
+ WHITE = "white",
3834
3907
  /**
3835
- * By default, the chat window will be rendered in a "closed" state.
3908
+ * Injects Carbon Gray 10 theme tokens.
3836
3909
  */
3837
- openChatByDefault?: boolean;
3910
+ G10 = "g10",
3838
3911
  /**
3839
- * Disclaimer screen configuration.
3840
- *
3841
- * If `disclaimerHTML` changes after the disclaimer has been accepted, we request a user to accept again.
3912
+ * Injects Carbon Gray 90 theme tokens.
3842
3913
  */
3843
- disclaimer?: DisclaimerPublicConfig;
3914
+ G90 = "g90",
3844
3915
  /**
3845
- * This value is only used when a custom element is being used to render the widget. By default, a number of
3846
- * enhancements to the widget are activated on mobile devices which can interfere with a custom element. This
3847
- * value can be used to disable those enhancements while using a custom element.
3916
+ * Injects Carbon Gray 100 theme tokens.
3848
3917
  */
3849
- disableCustomElementMobileEnhancements?: boolean;
3918
+ G100 = "g100"
3919
+ }
3920
+ /**
3921
+ * The different categories of errors that the system can record. These values are published for end user consumption.
3922
+ *
3923
+ * @category Config
3924
+ */
3925
+ declare enum OnErrorType {
3850
3926
  /**
3851
- * Add a bunch of noisy console.log messages!
3927
+ * Indicates an error sending a message to the assistant. This error is only generated after all retries have
3928
+ * failed and the system has given up.
3852
3929
  */
3853
- debug?: boolean;
3930
+ MESSAGE_COMMUNICATION = "MESSAGE_COMMUNICATION",
3854
3931
  /**
3855
- * Which Carbon theme tokens to inject. If unset (falsy), the chat inherits tokens from the host page.
3856
- * Set to a specific theme to force token injection.
3932
+ * This indicates an error in one of the components that occurs as part of rendering the UI.
3857
3933
  */
3858
- injectCarbonTheme?: CarbonTheme;
3934
+ RENDER = "RENDER",
3859
3935
  /**
3860
- * Enables Carbon AI theme styling. Defaults to true.
3936
+ * This indicates a known error with the configuration for a service desk. Fired when a connect_to_agent
3937
+ * response type is received, but none is configured.
3861
3938
  */
3862
- aiEnabled?: boolean;
3939
+ INTEGRATION_ERROR = "INTEGRATION_ERROR",
3863
3940
  /**
3864
- * This is a factory for producing custom implementations of service desks. If this value is set, then this will
3865
- * be used to create an instance of a {@link ServiceDesk} when the user attempts to connect to an agent.
3866
- *
3867
- * If it is changed in the middle of a conversation (you should obviously avoid this) the conversation with the
3868
- * human agent will be disconnected.
3941
+ * This indicates that some error occurred while trying to hydrate the chat. This will prevent the chat from
3942
+ * functioning.
3869
3943
  */
3870
- serviceDeskFactory?: (parameters: ServiceDeskFactoryParameters) => Promise<ServiceDesk>;
3944
+ HYDRATION = "HYDRATION"
3945
+ }
3946
+ /**
3947
+ * Fired when a serious error in the chat occurs.
3948
+ *
3949
+ * @category Config
3950
+ */
3951
+ interface OnErrorData {
3871
3952
  /**
3872
- * Any public config to apply to service desks.
3953
+ * The type of error that occurred.
3873
3954
  */
3874
- serviceDesk?: ServiceDeskPublicConfig;
3955
+ errorType: OnErrorType;
3875
3956
  /**
3876
- * If the Carbon AI Chat should grab focus if the chat is open on page load.
3957
+ * A message associated with the error.
3877
3958
  */
3878
- shouldTakeFocusIfOpensAutomatically?: boolean;
3959
+ message: string;
3879
3960
  /**
3880
- * An optional namespace that can be added to the Carbon AI Chat that must be 30 characters or under. This value is
3881
- * intended to enable multiple instances of the Carbon AI Chat to be used on the same page. The namespace for this web
3882
- * chat. This value is used to generate a value to append to anything unique (id, session keys, etc) to allow
3883
- * multiple Carbon AI Chats on the same page.
3884
- *
3885
- * Note: this value is used in the aria region label for the Carbon AI Chat. This means this value will be read out loud
3886
- * by users using a screen reader.
3961
+ * An extra blob of data associated with the error. This may be a stack trace for thrown errors.
3887
3962
  */
3888
- namespace?: string;
3963
+ otherData?: unknown;
3889
3964
  /**
3890
- * Indicates if Carbon AI Chat should sanitize HTML from the assistant.
3965
+ * If the error is of the severity that requires a whole restart of Carbon AI Chat.
3891
3966
  */
3892
- shouldSanitizeHTML?: boolean;
3967
+ catastrophicErrorType?: boolean;
3968
+ }
3969
+
3970
+ /**
3971
+ * A TypeScript definition file for ObjectMap.
3972
+ */
3973
+ /**
3974
+ * This interface represents an object which behaves like a map. The object contains a set of properties representing
3975
+ * keys in the map and the values of those properties are all of the same type (TPropertyType). The type of the keys
3976
+ * defaults to any string but you can specify a type that is a string enum instead if you want a map that contains
3977
+ * only keys for a given enum (or other similar type).
3978
+ *
3979
+ * @category Utilities
3980
+ */
3981
+ type ObjectMap<TPropertyType, TKeyType extends string | number = string> = Partial<Record<TKeyType, TPropertyType>>;
3982
+
3983
+ /**
3984
+ * The subset of HumanAgentState that is persisted to browser storage.
3985
+ *
3986
+ * @category Instance
3987
+ */
3988
+ interface PersistedHumanAgentState {
3989
+ /** Indicates that the user is connected to a human agent. */
3990
+ isConnected: boolean;
3991
+ /** Indicates if the human agent conversation is currently suspended. */
3992
+ isSuspended: boolean;
3993
+ /** The profile of the last human agent to join the chat. */
3994
+ responseUserProfile?: ResponseUserProfile;
3995
+ /** Cache of known agent profiles by ID. */
3996
+ responseUserProfiles: Record<string, ResponseUserProfile>;
3997
+ /** Arbitrary state saved by the service desk. */
3998
+ serviceDeskState?: unknown;
3999
+ }
4000
+
4001
+ /**
4002
+ * Items stored in sessionStorage.
4003
+ *
4004
+ * @category Instance
4005
+ */
4006
+ interface PersistedState {
3893
4007
  /**
3894
- * Extra config for controlling the behavior of the header.
4008
+ * Indicates if this state was loaded from browser session storage or if was created as part of a new session.
3895
4009
  */
3896
- header?: HeaderConfig;
4010
+ wasLoadedFromBrowser: boolean;
3897
4011
  /**
3898
- * The config object for changing Carbon AI Chat's layout.
4012
+ * The version of the Carbon AI Chat that this data is persisted for. If there are any breaking changes to the
4013
+ * application state and a user reloads and gets a new version of the widget, bad things might happen so we'll
4014
+ * just invalidate the persisted storage if we ever attempt to load an old version on Carbon AI Chat startup.
3899
4015
  */
3900
- layout?: LayoutConfig;
4016
+ version: string;
3901
4017
  /**
3902
- * Config options for controlling messaging.
4018
+ * Indicates which of the Carbon AI Chat views are visible and which are hidden.
3903
4019
  */
3904
- messaging?: PublicConfigMessaging;
4020
+ viewState: ViewState;
3905
4021
  /**
3906
- * Sets the chat into a read only mode for displaying old conversations.
4022
+ * Indicates if we should show an unread indicator on the launcher. This is set by
4023
+ * {@link ChatInstance.updateAssistantUnreadIndicatorVisibility} and will display an empty circle on
4024
+ * the launcher. This setting is overridden if there are any unread human agent messages in which case a circle
4025
+ * with a number is displayed.
3907
4026
  */
3908
- isReadonly?: boolean;
4027
+ showUnreadIndicator: boolean;
3909
4028
  /**
3910
- * Sets the name of the assistant. Defaults to "watsonx". Used in screen reader announcements and error messages.
4029
+ * Indicates if the launcher should be in the expanded state.
3911
4030
  */
3912
- assistantName?: string;
4031
+ launcherIsExpanded: boolean;
3913
4032
  /**
3914
- * The locale to use for the widget. This controls the language pack and regional formatting.
3915
- * Example values include: 'en', 'en-us', 'fr', 'es'.
4033
+ * Determines if the launcher should start a timer to show its expanded state.
3916
4034
  */
3917
- locale?: string;
4035
+ launcherShouldStartCallToActionCounterIfEnabled: boolean;
3918
4036
  /**
3919
- * Configuration for the homescreen.
3920
- *
3921
- * If you change anything but `is_on` after the chat session has started, the chat will handle it gracefully.
3922
- *
3923
- * If you turn on the homescreen after the user has already started chatting, it will show up in the header as
3924
- * an icon, but the user won't be forced to go back to the homescreen (unlike turning on the disclaimer mid-chat).
4037
+ * If the user has received a message beyond the welcome node. We use this to mark if the chat has been interacted
4038
+ * with. This flag is duplicated so the information is available before hydration and before the user is known.
4039
+ * Note that this property reflects only the last user and should only be used when an approximate value is
4040
+ * acceptable.
3925
4041
  */
3926
- homescreen?: HomeScreenConfig;
4042
+ hasSentNonWelcomeMessage: boolean;
3927
4043
  /**
3928
- * Configuration for the launcher.
4044
+ * Map of if a disclaimer has been accepted on a given window.hostname value, keyed by hostname via
4045
+ * {@link ObjectMap}.
3929
4046
  */
3930
- launcher?: LauncherConfig;
4047
+ disclaimersAccepted: ObjectMap<boolean>;
3931
4048
  /**
3932
- * Configuration for the main input field on the chat.
4049
+ * State of home screen.
3933
4050
  */
3934
- input?: InputConfig;
4051
+ homeScreenState: HomeScreenState;
3935
4052
  /**
3936
- * Optional partial language pack overrides. Values merge with defaults.
4053
+ * The persisted subset of the human agent state.
3937
4054
  */
3938
- strings?: DeepPartial<LanguagePack>;
4055
+ humanAgentState: PersistedHumanAgentState;
3939
4056
  }
4057
+
3940
4058
  /**
3941
- * A single menu option.
4059
+ * The interface represents the API contract with the chat widget and contains all the public methods and properties
4060
+ * that can be used with Carbon AI Chat.
3942
4061
  *
3943
- * @category Config
4062
+ * @category Instance
3944
4063
  */
3945
- interface CustomMenuOption {
4064
+ interface ChatInstance extends EventHandlers, ChatActions {
3946
4065
  /**
3947
- * The text to display for the menu option.
4066
+ * Returns state information of the Carbon AI Chat that could be useful.
3948
4067
  */
3949
- text: string;
4068
+ getState: () => PublicChatState;
3950
4069
  /**
3951
- * The callback handler to call when the option is selected. Provide this of "url".
4070
+ * Manager for accessing and controlling custom panels.
3952
4071
  */
3953
- handler: () => void;
4072
+ customPanels?: CustomPanels;
3954
4073
  }
3955
4074
  /**
3956
- * @category Config
4075
+ * This is the state made available by calling {@link ChatInstance.getState}. This is a public method that returns immutable values.
4076
+ *
4077
+ * @category Instance
3957
4078
  */
3958
- declare enum MinimizeButtonIconType {
3959
- /**
3960
- * This shows an "X" icon.
3961
- */
3962
- CLOSE = "close",
3963
- /**
3964
- * This shows a "-" icon.
3965
- */
3966
- MINIMIZE = "minimize",
3967
- /**
3968
- * This shows an icon that indicates that the Carbon AI Chat can be collapsed into a side panel.
3969
- */
3970
- SIDE_PANEL_LEFT = "side-panel-left",
4079
+ interface PublicInputState {
3971
4080
  /**
3972
- * This shows an icon that indicates that the Carbon AI Chat can be collapsed into a side panel.
4081
+ * @experimental Raw text currently queued in the input before being sent to customSendMessage.
3973
4082
  */
3974
- SIDE_PANEL_RIGHT = "side-panel-right"
4083
+ rawValue: string;
3975
4084
  }
3976
4085
  /**
3977
- * Configuration for the input field in the main chat and homescreen.
4086
+ * Represents public state for default custom panel.
4087
+ *
4088
+ * @category Instance
4089
+ */
4090
+ interface PublicDefaultCustomPanelState {
4091
+ /** Indicates if the default custom panel overlay is currently open. */
4092
+ isOpen: boolean;
4093
+ }
4094
+ /**
4095
+ * Represents public state for each supported custom panel variant.
3978
4096
  *
3979
- * @category Config
4097
+ * @category Instance
3980
4098
  */
3981
- interface InputConfig {
3982
- /**
3983
- * The maximum number of characters allowed in the input field. Defaults to 10000.
3984
- */
3985
- maxInputCharacters?: number;
3986
- /**
3987
- * Controls whether the main input surface is visible when the chat loads.
3988
- * Defaults to true.
3989
- */
3990
- isVisible?: boolean;
3991
- /**
3992
- * If true, the main input surface starts in a disabled (read-only) state.
3993
- * Equivalent to {@link PublicConfig.isReadonly}, but scoped just to the assistant input.
3994
- */
3995
- isDisabled?: boolean;
4099
+ interface PublicCustomPanelsState {
4100
+ /** State for the default overlay-style custom panel. */
4101
+ default: PublicDefaultCustomPanelState;
3996
4102
  }
3997
4103
  /**
3998
- * Configuration for the main header of the chat.
4104
+ * Type returned by {@link ChatInstance.getState}.
3999
4105
  *
4000
- * @category Config
4106
+ * @category Instance
4001
4107
  */
4002
- interface HeaderConfig {
4003
- /**
4004
- * If the chat should supply its own header. Can be false if you have a fullscreen chat or one embedded into a page and
4005
- * you want to only make use of the main application header. Defaults to true.
4006
- */
4007
- isOn?: boolean;
4108
+ type PublicChatState = Readonly<Omit<PersistedState, "humanAgentState"> & {
4008
4109
  /**
4009
- * Indicates the icon to use for the close button in the header.
4110
+ * Current human agent state.
4010
4111
  */
4011
- minimizeButtonIconType?: MinimizeButtonIconType;
4112
+ humanAgent: PublicChatHumanAgentState;
4012
4113
  /**
4013
- * Hide the ability to minimize the Carbon AI Chat.
4114
+ * Counter that indicates if a message is loading and a loading indicator should be displayed.
4115
+ * If "0" then we do not show loading indicator.
4014
4116
  */
4015
- hideMinimizeButton?: boolean;
4117
+ isMessageLoadingCounter: number;
4016
4118
  /**
4017
- * If true, shows the restart conversation button in the header of home screen and main chat.
4119
+ * Optional string to display next to the loading indicator.
4018
4120
  */
4019
- showRestartButton?: boolean;
4121
+ isMessageLoadingText?: string;
4020
4122
  /**
4021
- * The chat header title.
4123
+ * Counter that indicates if the chat is hydrating and a full screen loading state should be displayed.
4022
4124
  */
4023
- title?: string;
4125
+ isHydratingCounter: number;
4024
4126
  /**
4025
- * The name displayed after the title.
4127
+ * @experimental State representing the main input surface.
4026
4128
  */
4027
- name?: string;
4129
+ input: PublicInputState;
4028
4130
  /**
4029
- * All the currently configured custom menu options.
4131
+ * @experimental State for any surfaced custom panels.
4030
4132
  */
4031
- menuOptions?: CustomMenuOption[];
4133
+ customPanels: PublicCustomPanelsState;
4134
+ }>;
4135
+ /**
4136
+ * Methods for controlling the input field.
4137
+ *
4138
+ * @category Instance
4139
+ */
4140
+ interface ChatInstanceInput {
4032
4141
  /**
4033
- * Controls whether to show the AI label/slug in the header. Defaults to true.
4142
+ * @experimental Updates the raw text queued in the input before it is sent to customSendMessage.
4143
+ * Use this when you want to manipulate the canonical value while leaving presentation up to the default renderer or,
4144
+ * in the future, a custom slot implementation.
4034
4145
  *
4035
- * There is currently no version of this that does not include the AI theme
4036
- * blue gradients.
4146
+ * @example
4147
+ * ```ts
4148
+ * instance.input.updateRawValue((prev) => `${prev} @celeste`);
4149
+ * ```
4037
4150
  */
4038
- showAiLabel?: boolean;
4151
+ updateRawValue: (updater: (previous: string) => string) => void;
4039
4152
  }
4040
4153
  /**
4041
- * @category Config
4154
+ * Current connection state of the human agent experience.
4155
+ *
4156
+ * @category Instance
4042
4157
  */
4043
- interface LayoutConfig {
4044
- /**
4045
- * Indicates if the Carbon AI Chat widget should keep its border and box-shadow.
4046
- */
4047
- showFrame?: boolean;
4158
+ type PublicChatHumanAgentState = Readonly<PersistedHumanAgentState & {
4159
+ /** Indicates if Carbon AI Chat is attempting to connect to an agent. */
4160
+ isConnecting: boolean;
4161
+ }>;
4162
+ /**
4163
+ * This is a subset of the public interface that is managed by the event bus that is used for registering and
4164
+ * unregistering event listeners on the bus.
4165
+ *
4166
+ * @category Instance
4167
+ */
4168
+ interface EventHandlers {
4048
4169
  /**
4049
- * Indicates if content inside the Carbon AI Chat widget should be constrained to a max-width.
4170
+ * Adds the given event handler as a listener for events of the given type.
4050
4171
  *
4051
- * At larger widths the card, carousel, options and conversational search response types
4052
- * have pending issues.
4172
+ * @param handlers The handler or handlers along with the event type to start listening for events.
4173
+ * @returns The instance for method chaining.
4053
4174
  */
4054
- hasContentMaxWidth?: boolean;
4175
+ on: (handlers: TypeAndHandler | TypeAndHandler[]) => EventHandlers;
4055
4176
  /**
4056
- * This flag is used to disable Carbon AI Chat's rounded corners.
4177
+ * Removes an event listener that was previously added via {@link on} or {@link once}.
4178
+ *
4179
+ * @param handlers The handler or handlers along with the event type to stop listening for events.
4180
+ * @returns The instance for method chaining.
4057
4181
  */
4058
- corners?: CornersType;
4182
+ off: (handlers: TypeAndHandler | TypeAndHandler[]) => EventHandlers;
4059
4183
  /**
4060
- * CSS variable overrides for the chat UI.
4061
- *
4062
- * Keys correspond to values from `LayoutCustomProperties` (e.g. `LayoutCustomProperties.height`),
4063
- * which map to the underlying `--cds-aichat-…` custom properties.
4064
- * Values are raw CSS values such as `"420px"`, `"9999"`, etc.
4184
+ * Adds the given event handler as a listener for events of the given type. After the first event is handled, this
4185
+ * handler will automatically be removed.
4065
4186
  *
4066
- * Example:
4067
- * { height: "560px", width: "420px" }
4187
+ * @param handlers The handler or handlers along with the event type to start listening for an event.
4188
+ * @returns The instance for method chaining.
4068
4189
  */
4069
- customProperties?: Partial<Record<LayoutCustomProperties, string>>;
4190
+ once: (handlers: TypeAndHandler | TypeAndHandler[]) => EventHandlers;
4070
4191
  }
4071
4192
  /**
4072
- * Config options for controlling messaging.
4193
+ * The type of handler for event bus events. This function may return a Promise in which case, the bus will await
4194
+ * the result and the loop will block until the Promise is resolved.
4073
4195
  *
4074
- * @category Config
4196
+ * @category Instance
4075
4197
  */
4076
- interface PublicConfigMessaging {
4198
+ type EventBusHandler<T extends BusEvent = BusEvent> = (event: T, instance: ChatInstance) => unknown;
4199
+ /**
4200
+ * The type of the object that is passed to the event bus functions (e.g. "on") when registering a handler.
4201
+ *
4202
+ * @category Instance
4203
+ */
4204
+ interface TypeAndHandler {
4077
4205
  /**
4078
- * Indicates if Carbon AI Chat should make a request for the welcome message when a new conversation begins. If this is
4079
- * true, then Carbon AI Chat will start with an empty conversation.
4080
- *
4081
- * **Manual session management required**: Changes to this property after conversation has started have no effect.
4082
- * To apply new welcome behavior, call `instance.messaging.restartConversation()`.
4206
+ * The type of event this handler is for.
4083
4207
  */
4084
- skipWelcome?: boolean;
4208
+ type: BusEventType;
4085
4209
  /**
4086
- * Changes the timeout used by the message service when making message calls. The timeout is in seconds. The
4087
- * default is 150 seconds. After this time, an error will be shown in the client and an Abort signal will be sent
4088
- * to customSendMessage. If set to 0, the chat will never timeout. This is tied to either {@link ChatInstanceMessaging.addMessage} or
4089
- * {@link ChatInstanceMessaging.addMessageChunk} being called after this message was sent. If neither of those methods
4090
- * are called with in the window defined here, the chat will timeout (unless the value is set to 0).
4210
+ * The handler for events of this type.
4091
4211
  */
4092
- messageTimeoutSecs?: number;
4212
+ handler: EventBusHandler;
4213
+ }
4214
+ /**
4215
+ * This is a subset of the public interface that provides methods that can be used by the user to control the widget
4216
+ * and have it perform certain actions.
4217
+ *
4218
+ * @category Instance
4219
+ */
4220
+ interface ChatActions {
4093
4221
  /**
4094
- * Controls how long AI chat should wait before showing the loading indicator. If set to 0, the chat will never show
4095
- * the loading indicator on its own. This is tied to either {@link ChatInstanceMessaging.addMessage} or
4096
- * {@link ChatInstanceMessaging.addMessageChunk} being called after this message was sent. If neither of those methods
4097
- * are called with in the window defined here, the loading indicator will be shown.
4222
+ * Messaging actions for a chat instance.
4098
4223
  */
4099
- messageLoadingIndicatorTimeoutSecs?: number;
4224
+ messaging: ChatInstanceMessaging;
4100
4225
  /**
4101
- * A callback for Carbon AI Chat to use to send messages to your assistant.
4102
- *
4103
- * Carbon AI Chat will queue up any additional user messages until the Promise from a previous call to customSendMessage
4104
- * has resolved. If you do not make customSendMessage async, it will be up to you to manage what happens when a message is
4105
- * sent when the previous is still processing. If the Promise rejects, an error indicator will be displayed next to the user's message.
4106
- *
4107
- * If the request takes longer than PublicConfigMessaging.messageTimeoutSecs than the AbortSignal will be sent.
4226
+ * This function can be called when another component wishes this component to gain focus. It is up to the
4227
+ * component to decide where focus belongs. This may return true or false to indicate if a suitable focus location
4228
+ * was found.
4108
4229
  */
4109
- customSendMessage?: (request: MessageRequest, requestOptions: CustomSendMessageOptions, instance: ChatInstance) => Promise<void> | void;
4230
+ requestFocus: () => boolean | void;
4110
4231
  /**
4111
- * This is a callback function that is used by Carbon AI Chat to retrieve history data for populating the Carbon AI Chat. If
4112
- * this function is defined, it will be used instead of any other mechanism for fetching history.
4232
+ * Sends the given message to the assistant on the remote server. This will result in a "pre:send" and "send" event
4233
+ * being fired on the event bus. The returned promise will resolve once a response has received and processed and
4234
+ * both the "pre:receive" and "receive" events have fired. It will reject when too many errors have occurred and
4235
+ * the system gives up retrying.
4113
4236
  *
4114
- * If this function is mutated after it was initially called, the chat does not re-call it.
4115
- */
4116
- customLoadHistory?: (instance: ChatInstance) => Promise<HistoryItem[]>;
4117
- }
4118
- /**
4119
- * @category Config
4120
- */
4121
- interface DisclaimerPublicConfig {
4122
- /**
4123
- * If the disclaimer is turned on.
4237
+ * @param message The message to send.
4238
+ * @param options Options for the message sent.
4124
4239
  */
4125
- isOn: boolean;
4240
+ send: (message: MessageRequest | string, options?: SendOptions) => Promise<void>;
4126
4241
  /**
4127
- * HTML content to show in disclaimer.
4242
+ * Fire the view:pre:change and view:change events and change the view of the Carbon AI Chat. If a {@link ViewType} is
4243
+ * provided then that view will become visible and the rest will be hidden. If a {@link ViewState} is provided that
4244
+ * includes all of the views then all of the views will be changed accordingly. If a partial {@link ViewState} is
4245
+ * provided then only the views provided will be changed.
4128
4246
  */
4129
- disclaimerHTML: string;
4130
- }
4131
- /**
4132
- * A string identifying what Carbon Theme we should base UI variables off of.
4133
- * Defaults to "inherit". If you are not hosting the chat on a website that is Carbon styles, you will want to choose
4134
- * once of the non-inherited values to inject the correct CSS custom property values into the code. See
4135
- * https://carbondesignsystem.com/guidelines/color/tokens.
4136
- *
4137
- * @category Config
4138
- */
4139
- declare enum CarbonTheme {
4247
+ changeView: (newView: ViewType | ViewState) => Promise<void>;
4140
4248
  /**
4141
- * Injects Carbon white theme tokens.
4249
+ * Returns the list of writable elements.
4142
4250
  */
4143
- WHITE = "white",
4251
+ writeableElements: Partial<WriteableElements>;
4144
4252
  /**
4145
- * Injects Carbon Gray 10 theme tokens.
4253
+ * @deprecated Configure via {@link InputConfig.isVisible}.
4146
4254
  */
4147
- G10 = "g10",
4255
+ updateInputFieldVisibility: (isVisible: boolean) => void;
4148
4256
  /**
4149
- * Injects Carbon Gray 90 theme tokens.
4257
+ * @deprecated Configure via {@link InputConfig.isDisabled}
4258
+ * or {@link PublicConfig.isReadonly}.
4150
4259
  */
4151
- G90 = "g90",
4260
+ updateInputIsDisabled: (isDisabled: boolean) => void;
4152
4261
  /**
4153
- * Injects Carbon Gray 100 theme tokens.
4262
+ * @deprecated Configure via {@link LauncherConfig.showUnreadIndicator}.
4154
4263
  */
4155
- G100 = "g100"
4156
- }
4157
- /**
4158
- * The different categories of errors that the system can record. These values are published for end user consumption.
4159
- *
4160
- * @category Config
4161
- */
4162
- declare enum OnErrorType {
4264
+ updateAssistantUnreadIndicatorVisibility: (isVisible: boolean) => void;
4163
4265
  /**
4164
- * Indicates an error sending a message to the assistant. This error is only generated after all retries have
4165
- * failed and the system has given up.
4266
+ * Scrolls to the (original) message with the given ID. Since there may be multiple message items in a given
4267
+ * message, this will scroll the first message to the top of the message window.
4268
+ *
4269
+ * @param messageID The (original) message ID to scroll to.
4270
+ * @param animate Whether or not the scroll should be animated. Defaults to true.
4166
4271
  */
4167
- MESSAGE_COMMUNICATION = "MESSAGE_COMMUNICATION",
4272
+ scrollToMessage: (messageID: string, animate?: boolean) => void;
4168
4273
  /**
4169
- * This indicates an error in one of the components that occurs as part of rendering the UI.
4274
+ * Restarts the conversation with the assistant. This does not make any changes to a conversation with a human agent.
4275
+ * This will clear all the current assistant messages from the main assistant view and cancel any outstanding
4276
+ * messages. This will also clear the current assistant session which will force a new session to start on the
4277
+ * next message.
4278
+ *
4279
+ * @deprecated Use {@link ChatInstanceMessaging.restartConversation} instead.
4170
4280
  */
4171
- RENDER = "RENDER",
4281
+ restartConversation: () => Promise<void>;
4172
4282
  /**
4173
- * This indicates a known error with the configuration for a service desk. Fired when a connect_to_agent
4174
- * response type is received, but none is configured.
4283
+ * Initiates a doAutoScroll on the currently visible chat panel.
4175
4284
  */
4176
- INTEGRATION_ERROR = "INTEGRATION_ERROR",
4285
+ doAutoScroll: () => void;
4177
4286
  /**
4178
- * This indicates that some error occurred while trying to hydrate the chat. This will prevent the chat from
4179
- * functioning.
4287
+ * @param direction Either increases or decreases the internal counter that indicates whether the "message is loading"
4288
+ * indicator is shown. If the count is greater than zero, then the indicator is shown. Values of "increase" or "decrease" will
4289
+ * increase or decrease the value. "reset" will set the value back to 0. You may pass undefined as the first value
4290
+ * if you just wish to update the message.
4291
+ *
4292
+ * You can access the current value via {@link ChatInstance.getState}.
4293
+ *
4294
+ * @param message You can also, optionally, pass a plain text string as the second argument. It will display next to the loading indicator for
4295
+ * you to give meaningful feedback while the message is loading (or simple strings like "Thinking...", etc). The most
4296
+ * recent value will be used. So if you call it with a string value and then again with no value, the value will be
4297
+ * replaced with undefined and stop showing in the UI.
4180
4298
  */
4181
- HYDRATION = "HYDRATION"
4182
- }
4183
- /**
4184
- * Fired when a serious error in the chat occurs.
4185
- *
4186
- * @category Config
4187
- */
4188
- interface OnErrorData {
4299
+ updateIsMessageLoadingCounter: (direction: IncreaseOrDecrease, message?: string) => void;
4189
4300
  /**
4190
- * The type of error that occurred.
4301
+ * Either increases or decreases the internal counter that indicates whether the hydration fullscreen loading state is
4302
+ * shown. If the count is greater than zero, then the indicator is shown. Values of "increase" or "decrease" will
4303
+ * increase or decrease the value. "reset" will set the value back to 0.
4304
+ *
4305
+ * You can access the current value via {@link ChatInstance.getState}.
4191
4306
  */
4192
- errorType: OnErrorType;
4307
+ updateIsChatLoadingCounter: (direction: IncreaseOrDecrease) => void;
4193
4308
  /**
4194
- * A message associated with the error.
4309
+ * Actions for mutating the chat input contents.
4195
4310
  */
4196
- message: string;
4311
+ input: ChatInstanceInput;
4197
4312
  /**
4198
- * An extra blob of data associated with the error. This may be a stack trace for thrown errors.
4313
+ * Actions that are related to a service desk integration.
4199
4314
  */
4200
- otherData?: unknown;
4315
+ serviceDesk: ChatInstanceServiceDeskActions;
4201
4316
  /**
4202
- * If the error is of the severity that requires a whole restart of Carbon AI Chat.
4317
+ * Remove any record of the current session from the browser's SessionStorage.
4318
+ *
4319
+ * @param keepOpenState If we are destroying the session to restart the chat this can be used to preserve if the web
4320
+ * chat is open.
4203
4321
  */
4204
- catastrophicErrorType?: boolean;
4322
+ destroySession: (keepOpenState?: boolean) => Promise<void>;
4205
4323
  }
4206
-
4207
4324
  /**
4208
- * A TypeScript definition file for ObjectMap.
4325
+ * @category Instance
4209
4326
  */
4327
+ type IncreaseOrDecrease = "increase" | "decrease" | "reset" | undefined;
4210
4328
  /**
4211
- * This interface represents an object which behaves like a map. The object contains a set of properties representing
4212
- * keys in the map and the values of those properties are all of the same type (TPropertyType). The type of the keys
4213
- * defaults to any string but you can specify a type that is a string enum instead if you want a map that contains
4214
- * only keys for a given enum (or other similar type).
4329
+ * This interface represents the options for when a MessageRequest is sent to the server with the send method.
4215
4330
  *
4216
- * @category Utilities
4331
+ * @category Instance
4217
4332
  */
4218
- type ObjectMap<TPropertyType, TKeyType extends string | number = string> = Partial<Record<TKeyType, TPropertyType>>;
4219
-
4333
+ interface SendOptions {
4334
+ /**
4335
+ * If you want to send a message to the API, but NOT have it show up in the UI, set this to true. The "pre:send"
4336
+ * and "send" events will still be fired but the message will not be added to the local message list displayed in
4337
+ * the UI. Note that the response message will still be added.
4338
+ */
4339
+ silent?: boolean;
4340
+ }
4220
4341
  /**
4221
- * Items stored in sessionStorage.
4342
+ * An object of elements we expose to developers to write to. Be sure to check the documentation of the React or
4343
+ * web component you are using for how to make use of this, as it differs based on implementation.
4222
4344
  *
4223
4345
  * @category Instance
4224
4346
  */
4225
- interface PersistedState {
4226
- /**
4227
- * Indicates if this state was loaded from browser session storage or if was created as part of a new session.
4228
- */
4229
- wasLoadedFromBrowser: boolean;
4230
- /**
4231
- * The version of the Carbon AI Chat that this data is persisted for. If there are any breaking changes to the
4232
- * application state and a user reloads and gets a new version of the widget, bad things might happen so we'll
4233
- * just invalidate the persisted storage if we ever attempt to load an old version on Carbon AI Chat startup.
4234
- */
4235
- version: string;
4236
- /**
4237
- * Indicates which of the Carbon AI Chat views are visible and which are hidden.
4238
- */
4239
- viewState: ViewState;
4347
+ type WriteableElements = Record<WriteableElementName, HTMLElement>;
4348
+ /**
4349
+ * @category Instance
4350
+ */
4351
+ declare enum WriteableElementName {
4240
4352
  /**
4241
- * Indicates if we should show an unread indicator on the launcher. This is set by
4242
- * {@link ChatInstance.updateAssistantUnreadIndicatorVisibility} and will display an empty circle on
4243
- * the launcher. This setting is overridden if there are any unread human agent messages in which case a circle
4244
- * with a number is displayed.
4353
+ * An element that appears in the AI theme only and is shown beneath the title and description in the AI tooltip
4354
+ * content.
4245
4355
  */
4246
- showUnreadIndicator: boolean;
4356
+ AI_TOOLTIP_AFTER_DESCRIPTION_ELEMENT = "aiTooltipAfterDescriptionElement",
4247
4357
  /**
4248
- * Indicates if the mobile launcher should be in the extended state.
4358
+ * An element that appears in the main message body directly above the welcome node.
4249
4359
  */
4250
- mobileLauncherIsExtended: boolean;
4360
+ WELCOME_NODE_BEFORE_ELEMENT = "welcomeNodeBeforeElement",
4251
4361
  /**
4252
- * Determines if the mobile launcher already played the extended animation and was reduced.
4362
+ * An element that appears in the header on a new line. Only visible while talking to the assistant.
4253
4363
  */
4254
- mobileLauncherWasReduced: boolean;
4364
+ HEADER_BOTTOM_ELEMENT = "headerBottomElement",
4255
4365
  /**
4256
- * Determines if the mobile launcher previously played the bounce animation and should no longer be able to.
4366
+ * An element that appears after the messages area and before the input area.
4257
4367
  */
4258
- mobileLauncherDisableBounce: boolean;
4368
+ BEFORE_INPUT_ELEMENT = "beforeInputElement",
4259
4369
  /**
4260
- * Indicates the desktop launcher is in its expanded state.
4370
+ * An element that appears above the input field on the home screen.
4261
4371
  */
4262
- desktopLauncherIsExpanded: boolean;
4372
+ HOME_SCREEN_BEFORE_INPUT_ELEMENT = "homeScreenBeforeInputElement",
4263
4373
  /**
4264
- * Indicates the desktop launcher has been minimized.
4374
+ * An element that appears on the home screen after the conversation starters.
4265
4375
  */
4266
- desktopLauncherWasMinimized: boolean;
4376
+ HOME_SCREEN_AFTER_STARTERS_ELEMENT = "homeScreenAfterStartersElement",
4267
4377
  /**
4268
- * The bounce turn the user is currently on in the sequence of bounces so that user doesn't start over in the
4269
- * sequence. A turn is a full set of animations that are displayed when a bounce occurs and each turn of a bounce is
4270
- * when a different bounce occurs at a different point in time. This is used for both the desktop and mobile launcher.
4378
+ * An element that appears on the home screen above the welcome message and conversation starters.
4271
4379
  */
4272
- bounceTurn: number;
4380
+ HOME_SCREEN_HEADER_BOTTOM_ELEMENT = "homeScreenHeaderBottomElement",
4273
4381
  /**
4274
- * If the user has received a message beyond the welcome node. We use this to mark if the chat has been interacted
4275
- * with. This flag is duplicated so the information is available before hydration and before the user is known.
4276
- * Note that this property reflects only the last user and should only be used when an approximate value is
4277
- * acceptable.
4382
+ * An element to be housed in the custom panel.
4278
4383
  */
4279
- hasSentNonWelcomeMessage: boolean;
4384
+ CUSTOM_PANEL_ELEMENT = "customPanelElement"
4385
+ }
4386
+ /**
4387
+ * @category Instance
4388
+ */
4389
+ type ChangeFunction = (text: string) => void;
4390
+ /**
4391
+ * Upload options. Currently only applies to conversations with a human agent.
4392
+ *
4393
+ * @category Instance
4394
+ */
4395
+ interface FileUploadCapabilities {
4280
4396
  /**
4281
- * Map of if a disclaimer has been accepted on a given window.hostname value, keyed by hostname via
4282
- * {@link ObjectMap}.
4397
+ * Indicates that file uploads may be performed by the user.
4283
4398
  */
4284
- disclaimersAccepted: ObjectMap<boolean>;
4399
+ allowFileUploads: boolean;
4285
4400
  /**
4286
- * State of home screen.
4401
+ * If file uploads are allowed, this indicates if more than one file may be selected at a time. The default is false.
4287
4402
  */
4288
- homeScreenState: HomeScreenState;
4403
+ allowMultipleFileUploads: boolean;
4289
4404
  /**
4290
- * The persisted subset of the human agent state.
4405
+ * If file uploads are allowed, this is the set a file types that are allowed. This is filled into the "accept"
4406
+ * field for the file input element.
4291
4407
  */
4292
- humanAgentState: PersistedHumanAgentState;
4408
+ allowedFileUploadTypes: string;
4293
4409
  }
4294
-
4295
4410
  /**
4296
- * @category Config
4411
+ * Start or end conversations with human agent.
4412
+ *
4413
+ * @category Instance
4297
4414
  */
4298
- interface ChatHeaderConfig {
4415
+ interface ChatInstanceServiceDeskActions {
4299
4416
  /**
4300
- * The chat header title.
4417
+ * Ends the conversation with a human agent. This does not request confirmation from the user first. If the user
4418
+ * is not connected or connecting to a human agent, this function has no effect. You can determine if the user is
4419
+ * connected or connecting by calling {@link ChatInstance.getState}. Note that this function
4420
+ * returns a Promise that only resolves when the conversation has ended. This includes after the
4421
+ * {@link BusEventType.HUMAN_AGENT_PRE_END_CHAT} and {@link BusEventType.HUMAN_AGENT_END_CHAT} events have been fired and
4422
+ * resolved.
4301
4423
  */
4302
- title?: string;
4424
+ endConversation: () => Promise<void>;
4303
4425
  /**
4304
- * The name displayed after the title.
4426
+ * Sets the suspended state for an agent conversation. A conversation can be suspended or un-suspended only if the
4427
+ * user is currently connecting or connected to an agent. If a conversation is suspended, then messages from the user
4428
+ * will no longer be routed to the service desk and incoming messages from the service desk will not be displayed. In
4429
+ * addition, the current connection status with an agent will not be shown.
4305
4430
  */
4306
- name?: string;
4431
+ updateIsSuspended: (isSuspended: boolean) => Promise<void>;
4307
4432
  }
4308
4433
 
4434
+ /**
4435
+ * Eagerly loads every lazily imported dependency across both
4436
+ * `@carbon/ai-chat-components` and `@carbon/ai-chat` so tests can preload
4437
+ * everything they need (Jest, Vitest, server rendering, etc.). Only available
4438
+ * from `@carbon/ai-chat/server`.
4439
+ *
4440
+ * @category Testing
4441
+ */
4442
+ declare function loadAllLazyDeps(): Promise<void>;
4443
+
4309
4444
  /**
4310
4445
  * This component is mostly a pass-through. Its takes any properties passed into the ChatContainer
4311
4446
  * custom element and then renders the React Carbon AI Chat application while passing in properties.
@@ -4557,89 +4692,5 @@ interface ChatContainerProps extends PublicConfig {
4557
4692
  renderWriteableElements?: RenderWriteableElementResponse;
4558
4693
  }
4559
4694
 
4560
- /**
4561
- * An enum of all of our data-testid we use. For some elements (like INPUT) they can appear in multiple "panels"
4562
- * (e.g. on the home screen and in the main chat window). There are provided testids for "panels" as well so you
4563
- * can first select a panel and then select the correct child.
4564
- *
4565
- * @category Testing
4566
- *
4567
- * @experimental
4568
- */
4569
- declare enum PageObjectId {
4570
- /**
4571
- * Minimize chat button in header.
4572
- */
4573
- CLOSE_CHAT = "close_chat",
4574
- /**
4575
- * The launcher button to open the chat. This id is maintained across desktop and mobile launchers.
4576
- */
4577
- LAUNCHER = "launcher_open_chat",
4578
- /**
4579
- * Input field.
4580
- */
4581
- INPUT = "input_field",
4582
- /**
4583
- * Input send button.
4584
- */
4585
- INPUT_SEND = "input_send",
4586
- /**
4587
- * The chat header title element.
4588
- */
4589
- HEADER_TITLE = "header_title",
4590
- /**
4591
- * The chat header name element.
4592
- */
4593
- HEADER_NAME = "header_name",
4594
- /**
4595
- * The main chat panel.
4596
- */
4597
- MAIN_PANEL = "main_panel",
4598
- /**
4599
- * Disclaimer panel.
4600
- */
4601
- DISCLAIMER_PANEL = "disclaimer_panel",
4602
- /**
4603
- * Disclaimer accept button.
4604
- */
4605
- DISCLAIMER_ACCEPT_BUTTON = "disclaimer_accept_button",
4606
- /**
4607
- * Homescreen Panel.
4608
- */
4609
- HOME_SCREEN_PANEL = "home_screen_panel",
4610
- /**
4611
- * Hydration/loading state panel.
4612
- */
4613
- HYDRATING_PANEL = "hydrating_panel",
4614
- /**
4615
- * Catastrophic error panel.
4616
- */
4617
- CATASTROPHIC_PANEL = "catastrophic_panel",
4618
- /**
4619
- * Iframe panel.
4620
- */
4621
- IFRAME_PANEL = "iframe_panel",
4622
- /**
4623
- * Conversational search panel.
4624
- */
4625
- CONVERSATIONAL_SEARCH_CITATION_PANEL = "conversational_search_citation_panel",
4626
- /**
4627
- * Custom panel.
4628
- */
4629
- CUSTOM_PANEL = "custom_panel",
4630
- /**
4631
- * A panel that opens from a button response.
4632
- */
4633
- BUTTON_RESPONSE_PANEL = "button_response_panel"
4634
- }
4635
- /**
4636
- * Ids used for data-testid.
4637
- *
4638
- * @category Testing
4639
- *
4640
- * @experimental
4641
- */
4642
- type TestId = PageObjectId;
4643
-
4644
- export { LayoutCustomProperties as L, PanelType as P, WriteableElementName as W, BusEventType as a6, FeedbackInteractionType as a8, MessageSendSource as a9, HumanAgentsOnlineStatus as aA, ErrorType as aE, FileStatusValue as aF, ScreenShareState as aH, ButtonItemKind as aY, ButtonItemType as aZ, ViewChangeReason as aa, CancellationReason as af, CarbonTheme as ai, enLanguagePack as al, MinimizeButtonIconType as aq, OnErrorType as as, WidthOptions as bE, HumanAgentMessageType as bI, ChainOfThoughtStepStatus as bK, UserType as bS, MessageErrorState as bU, IFrameItemDisplayOption as bf, MessageInputType as bp, MessageResponseTypes as bu, OptionItemPreference as bw, ViewType as c, PageObjectId as c0, CornersType as u };
4645
- export type { BusEventMessageItemCustom as $, BusEventHumanAgentPreSend as A, BusEventViewPreChange as B, ChatContainerProps as C, DefaultCustomPanelConfigOptions as D, EventBusHandler as E, FileUploadCapabilities as F, BusEventHumanAgentPreStartChat as G, BusEventHumanAgentReceive as H, IncreaseOrDecrease as I, BusEventHumanAgentSend as J, BusEventChatReady as K, BusEventChunkUserDefinedResponse as M, NotificationMessage as N, BusEventClosePanelButtonClicked as O, BusEventCustomPanelClose as Q, BusEventCustomPanelOpen as R, SendOptions as S, TypeAndHandler as T, BusEventCustomPanelPreClose as U, ViewState as V, BusEventCustomPanelPreOpen as X, BusEventFeedback as Y, BusEventHistoryBegin as Z, BusEventHistoryEnd as _, ChatInstance as a, CarouselItem as a$, BusEventPreReceive as a0, BusEventPreReset as a1, BusEventPreSend as a2, BusEventReceive as a3, BusEventReset as a4, BusEventSend as a5, BusEventUserDefinedResponse as a7, ConnectingErrorInfo as aB, DisconnectedErrorInfo as aC, EndChatInfo as aD, FileUpload as aG, ServiceDesk as aI, ServiceDeskCallback as aJ, ServiceDeskCapabilities as aK, ServiceDeskErrorInfo as aL, ServiceDeskFactoryParameters as aM, ServiceDeskPublicConfig as aN, StartChatOptions as aO, UserMessageErrorInfo as aP, BaseGenericItem as aQ, MessageResponseOptions as aR, MessageResponseHistory as aS, MessageRequestHistory as aT, ResponseUserProfile as aU, AudioItem as aV, BaseMessageInput as aW, ButtonItem as aX, CardItem as a_, HomeScreenConfig as ab, HomeScreenStarterButton as ac, HomeScreenStarterButtons as ad, HomeScreenState as ae, ChatInstanceMessaging as ag, CustomSendMessageOptions as ah, CustomMenuOption as aj, DisclaimerPublicConfig as ak, HeaderConfig as am, InputConfig as an, LanguagePack as ao, LayoutConfig as ap, OnErrorData as ar, PublicConfig as at, PublicConfigMessaging as au, PersistedHumanAgentState as av, DeepPartial as aw, ObjectMap as ax, AdditionalDataToAgent as ay, AgentAvailability as az, BusEventViewChange as b, RenderWriteableElementResponse as b$, Chunk as b0, CompleteItemChunk as b1, ConnectToHumanAgentItem as b2, ConnectToHumanAgentItemTransferInfo as b3, ConversationalSearchItem as b4, ConversationalSearchItemCitation as b5, DateItem as b6, EventInput as b7, EventInputData as b8, FinalResponseChunk as b9, TextItem as bA, UserDefinedItem as bB, VerticalCellAlignment as bC, VideoItem as bD, WithBodyAndFooter as bF, WithWidthOptions as bG, SingleOption as bH, ChainOfThoughtStep as bJ, GenericItemMessageFeedbackOptions as bL, GenericItemMessageOptions as bM, Message as bN, PartialOrCompleteItemChunk as bO, PartialResponse as bP, MessageHistoryFeedback as bQ, SearchResult as bR, HistoryItem as bT, LauncherCallToActionConfig as bV, LauncherConfig as bW, CdsAiChatContainerAttributes as bX, CdsAiChatCustomElementAttributes as bY, RenderUserDefinedResponse as bZ, RenderUserDefinedState as b_, GenericItem as ba, GenericItemMessageFeedbackCategories as bb, GridItem as bc, HorizontalCellAlignment as bd, IFrameItem as be, ImageItem as bg, InlineErrorItem as bh, ItemStreamingMetadata as bi, MediaItem as bj, MediaItemDimensions as bk, MediaSubtitleTrack as bl, MediaTranscript as bm, MediaFileAccessibility as bn, MessageInput as bo, MessageItemPanelInfo as bq, MessageOutput as br, MessageRequest as bs, MessageResponse as bt, OptionItem as bv, PartialItemChunk as bx, PauseItem as by, StreamChunk as bz, TestId as c1, PersistedState as d, ChatHeaderConfig as e, CustomPanelConfigOptions as f, CustomPanelInstance as g, CustomPanels as h, CustomPanelOpenOptions as i, ChangeFunction as j, ChatInstanceInput as k, ChatInstanceNotifications as l, ChatInstanceServiceDeskActions as m, EventHandlers as n, PublicInputState as o, PublicCustomPanelsState as p, PublicDefaultCustomPanelState as q, PublicChatHumanAgentState as r, PublicChatState as s, WriteableElements as t, BusEvent as v, BusEventHumanAgentAreAnyAgentsOnline as w, BusEventHumanAgentEndChat as x, BusEventHumanAgentPreEndChat as y, BusEventHumanAgentPreReceive as z };
4695
+ export { LayoutCustomProperties as L, PageObjectId as P, WriteableElementName as W, ButtonItemType as a$, BusEventType as a7, FeedbackInteractionType as a9, HumanAgentsOnlineStatus as aC, ErrorType as aG, FileStatusValue as aH, ScreenShareState as aJ, ButtonItemKind as a_, MessageSendSource as aa, ViewChangeReason as ab, CancellationReason as ai, CarbonTheme as al, enLanguagePack as ao, MinimizeButtonIconType as at, OnErrorType as av, WidthOptions as bG, HumanAgentMessageType as bK, ReasoningStepOpenState as bN, UserType as bV, MessageErrorState as bX, IFrameItemDisplayOption as bh, MessageInputType as br, MessageResponseTypes as bw, OptionItemPreference as by, ViewType as c, PanelType as g, CornersType as u, loadAllLazyDeps as v };
4696
+ export type { BusEventMessageItemCustom as $, BusEventHumanAgentPreReceive as A, BusEventViewPreChange as B, ChatContainerProps as C, DefaultCustomPanelConfigOptions as D, EventBusHandler as E, FileUploadCapabilities as F, BusEventHumanAgentPreSend as G, BusEventHumanAgentPreStartChat as H, IncreaseOrDecrease as I, BusEventHumanAgentReceive as J, BusEventHumanAgentSend as K, BusEventChatReady as M, BusEventChunkUserDefinedResponse as N, BusEventClosePanelButtonClicked as O, BusEventCustomPanelClose as Q, BusEventCustomPanelOpen as R, SendOptions as S, TestId as T, BusEventCustomPanelPreClose as U, ViewState as V, BusEventCustomPanelPreOpen as X, BusEventFeedback as Y, BusEventHistoryBegin as Z, BusEventHistoryEnd as _, ChatInstance as a, BusEventPreReceive as a0, BusEventPreReset as a1, BusEventPreSend as a2, BusEventReceive as a3, BusEventReset as a4, BusEventSend as a5, BusEventStateChange as a6, BusEventUserDefinedResponse as a8, AdditionalDataToAgent as aA, AgentAvailability as aB, ConnectingErrorInfo as aD, DisconnectedErrorInfo as aE, EndChatInfo as aF, FileUpload as aI, ServiceDesk as aK, ServiceDeskCallback as aL, ServiceDeskCapabilities as aM, ServiceDeskErrorInfo as aN, ServiceDeskFactoryParameters as aO, ServiceDeskPublicConfig as aP, StartChatOptions as aQ, UserMessageErrorInfo as aR, BaseGenericItem as aS, MessageResponseOptions as aT, MessageResponseHistory as aU, MessageRequestHistory as aV, ResponseUserProfile as aW, AudioItem as aX, BaseMessageInput as aY, ButtonItem as aZ, PersistedState as ac, PersistedHumanAgentState as ad, HomeScreenConfig as ae, HomeScreenStarterButton as af, HomeScreenStarterButtons as ag, HomeScreenState as ah, ChatInstanceMessaging as aj, CustomSendMessageOptions as ak, CustomMenuOption as am, DisclaimerPublicConfig as an, HeaderConfig as ap, InputConfig as aq, LanguagePack as ar, LayoutConfig as as, OnErrorData as au, PublicConfig as aw, PublicConfigMessaging as ax, DeepPartial as ay, ObjectMap as az, BusEventViewChange as b, CdsAiChatCustomElementAttributes as b$, CardItem as b0, CarouselItem as b1, Chunk as b2, CompleteItemChunk as b3, ConnectToHumanAgentItem as b4, ConnectToHumanAgentItemTransferInfo as b5, ConversationalSearchItem as b6, ConversationalSearchItemCitation as b7, DateItem as b8, EventInput as b9, PauseItem as bA, StreamChunk as bB, TextItem as bC, UserDefinedItem as bD, VerticalCellAlignment as bE, VideoItem as bF, WithBodyAndFooter as bH, WithWidthOptions as bI, SingleOption as bJ, ReasoningSteps as bL, ReasoningStep as bM, GenericItemMessageFeedbackOptions as bO, GenericItemMessageOptions as bP, Message as bQ, PartialOrCompleteItemChunk as bR, PartialResponse as bS, MessageHistoryFeedback as bT, SearchResult as bU, HistoryItem as bW, LauncherCallToActionConfig as bY, LauncherConfig as bZ, CdsAiChatContainerAttributes as b_, EventInputData as ba, FinalResponseChunk as bb, GenericItem as bc, GenericItemMessageFeedbackCategories as bd, GridItem as be, HorizontalCellAlignment as bf, IFrameItem as bg, ImageItem as bi, InlineErrorItem as bj, ItemStreamingMetadata as bk, MediaItem as bl, MediaItemDimensions as bm, MediaSubtitleTrack as bn, MediaTranscript as bo, MediaFileAccessibility as bp, MessageInput as bq, MessageItemPanelInfo as bs, MessageOutput as bt, MessageRequest as bu, MessageResponse as bv, OptionItem as bx, PartialItemChunk as bz, RenderUserDefinedResponse as c0, RenderUserDefinedState as c1, RenderWriteableElementResponse as c2, ChatHeaderConfig as d, CustomPanelConfigOptions as e, CustomPanelInstance as f, CustomPanels as h, CustomPanelOpenOptions as i, ChangeFunction as j, ChatInstanceInput as k, ChatInstanceServiceDeskActions as l, EventHandlers as m, PublicInputState as n, PublicCustomPanelsState as o, PublicDefaultCustomPanelState as p, PublicChatHumanAgentState as q, PublicChatState as r, TypeAndHandler as s, WriteableElements as t, BusEvent as w, BusEventHumanAgentAreAnyAgentsOnline as x, BusEventHumanAgentEndChat as y, BusEventHumanAgentPreEndChat as z };