@deepdesk/deepdesk-sdk 19.6.2-beta.9 → 19.7.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -406,7 +406,20 @@ declare enum FetchState {
406
406
  ERROR = "error"
407
407
  }
408
408
 
409
- interface State$a {
409
+ type State$a = {
410
+ data: Profile | null;
411
+ fetchState: FetchState;
412
+ /** Bumped on reset/clear so in-flight getProfile cannot repopulate profile. */
413
+ generation: number;
414
+ inFlightRequestId: string | null;
415
+ /**
416
+ * Runtime-only UI override used by widget wrappers (e.g. to hide/show certain widget blocks
417
+ * via config.allowedWidgetTypes). Must not participate in async getProfile lifecycle.
418
+ */
419
+ widgetTypesOverride: Profile['uiConfig']['widget']['types'] | null;
420
+ };
421
+
422
+ interface State$9 {
410
423
  current: Conversation | null;
411
424
  isSupported: boolean | null;
412
425
  }
@@ -447,7 +460,7 @@ type AssistantInteraction = {
447
460
  };
448
461
  evaluationId: string;
449
462
  };
450
- type State$9 = {
463
+ type State$8 = {
451
464
  cues: Cue[];
452
465
  threads: Record<number, AssistantInteraction[]>;
453
466
  pending: string[];
@@ -457,6 +470,18 @@ type State$9 = {
457
470
  }>;
458
471
  activeAssistantCode: string | null;
459
472
  nextLocalThreadId: number;
473
+ /** Evaluation ids suppressed after {@link clearDisplayedAnswers} so late chunks do not repopulate UI. */
474
+ suppressedEvaluationIds: string[];
475
+ /**
476
+ * Silent parent cues (`evaluationId` + assistant code) that must not be recreated by a later
477
+ * websocket event. Child codes for the same evaluation stay allowed.
478
+ */
479
+ suppressedSilentParentKeys: string[];
480
+ /** Bumped on {@link clearDisplayedAnswers} so in-flight evaluateAssistant results are dropped. */
481
+ assistantDisplayGeneration: number;
482
+ pendingEvaluationGenerations: Record<string, number>;
483
+ pendingEvaluationAssistantCodes: Record<string, string>;
484
+ evaluationIdDisplayGeneration: Record<string, number>;
460
485
  };
461
486
  type Transcript = Array<{
462
487
  source: string;
@@ -473,6 +498,7 @@ interface EvaluateInput {
473
498
  includeMetadata?: boolean;
474
499
  externalConversationId?: string;
475
500
  skipState?: boolean;
501
+ silent?: boolean;
476
502
  }
477
503
 
478
504
  type QueueMicrotaskErrorEventData = {
@@ -735,6 +761,7 @@ declare namespace Server {
735
761
  evaluation_id: string;
736
762
  evaluation_status: EvaluationStatus;
737
763
  session_id?: string;
764
+ is_silent?: boolean;
738
765
  output: EvaluationOutput | KAAnswer | string;
739
766
  };
740
767
  type EvaluationOutput = Array<{
@@ -921,6 +948,7 @@ declare namespace Server {
921
948
  assistant_name: string;
922
949
  display_name?: string;
923
950
  is_pinned: boolean;
951
+ is_silent?: boolean;
924
952
  };
925
953
  type ChatHistory = {
926
954
  question: string;
@@ -1286,19 +1314,11 @@ declare class DeepdeskAPI {
1286
1314
  }
1287
1315
 
1288
1316
  type StyleSuggestion = CamelCaseKeys<Server.StyleSuggestion>;
1289
- interface State$8 {
1317
+ interface State$7 {
1290
1318
  list: StyleSuggestion;
1291
1319
  fetchState: FetchState;
1292
1320
  }
1293
1321
 
1294
- type State$7 = {
1295
- data: Profile | null;
1296
- fetchState: FetchState;
1297
- /** Bumped on reset/clear so in-flight getProfile cannot repopulate profile. */
1298
- generation: number;
1299
- inFlightRequestId: string | null;
1300
- };
1301
-
1302
1322
  /**
1303
1323
  * A selection range representation for textarea's and contenteditables only using offsets.
1304
1324
  */
@@ -1468,9 +1488,9 @@ interface StoreConfig {
1468
1488
  preloadedState?: any;
1469
1489
  }
1470
1490
  declare const reducers: redux.Reducer<{
1471
- assistants: State$9;
1491
+ assistants: State$8;
1472
1492
  auth: State$2;
1473
- conversation: State$a;
1493
+ conversation: State$9;
1474
1494
  contentTypes: State$3;
1475
1495
  passwordlessToken: State$4;
1476
1496
  entities: State$1;
@@ -1522,9 +1542,9 @@ declare const reducers: redux.Reducer<{
1522
1542
  enableFeedbackForm: boolean;
1523
1543
  hasKeyboardInput: boolean;
1524
1544
  };
1525
- profile: State$7;
1545
+ profile: State$a;
1526
1546
  search: State$b;
1527
- styleSuggestions: State$8;
1547
+ styleSuggestions: State$7;
1528
1548
  ui: {
1529
1549
  showTabHint: boolean;
1530
1550
  inputHasFocus: boolean;
@@ -1534,9 +1554,9 @@ declare const reducers: redux.Reducer<{
1534
1554
  };
1535
1555
  textSuggestions: TextSuggestionState;
1536
1556
  }, redux.UnknownAction, Partial<{
1537
- assistants: State$9 | undefined;
1557
+ assistants: State$8 | undefined;
1538
1558
  auth: State$2 | undefined;
1539
- conversation: State$a | undefined;
1559
+ conversation: State$9 | undefined;
1540
1560
  contentTypes: State$3 | undefined;
1541
1561
  passwordlessToken: State$4 | undefined;
1542
1562
  entities: State$1 | undefined;
@@ -1588,9 +1608,9 @@ declare const reducers: redux.Reducer<{
1588
1608
  enableFeedbackForm: boolean;
1589
1609
  hasKeyboardInput: boolean;
1590
1610
  } | undefined;
1591
- profile: State$7 | undefined;
1611
+ profile: State$a | undefined;
1592
1612
  search: State$b | undefined;
1593
- styleSuggestions: State$8 | undefined;
1613
+ styleSuggestions: State$7 | undefined;
1594
1614
  ui: {
1595
1615
  showTabHint: boolean;
1596
1616
  inputHasFocus: boolean;
@@ -1601,9 +1621,9 @@ declare const reducers: redux.Reducer<{
1601
1621
  textSuggestions: TextSuggestionState | undefined;
1602
1622
  }>>;
1603
1623
  declare function createStore(config: StoreConfig): _reduxjs_toolkit.EnhancedStore<{
1604
- assistants: State$9;
1624
+ assistants: State$8;
1605
1625
  auth: State$2;
1606
- conversation: State$a;
1626
+ conversation: State$9;
1607
1627
  contentTypes: State$3;
1608
1628
  passwordlessToken: State$4;
1609
1629
  entities: State$1;
@@ -1655,9 +1675,9 @@ declare function createStore(config: StoreConfig): _reduxjs_toolkit.EnhancedStor
1655
1675
  enableFeedbackForm: boolean;
1656
1676
  hasKeyboardInput: boolean;
1657
1677
  };
1658
- profile: State$7;
1678
+ profile: State$a;
1659
1679
  search: State$b;
1660
- styleSuggestions: State$8;
1680
+ styleSuggestions: State$7;
1661
1681
  ui: {
1662
1682
  showTabHint: boolean;
1663
1683
  inputHasFocus: boolean;
@@ -2028,16 +2048,23 @@ declare class WebsocketClient {
2028
2048
  private eventListeners;
2029
2049
  private url;
2030
2050
  private maxReconnectAttempts;
2051
+ private readonly initialReconnectAttempts;
2031
2052
  private reconnectInterval;
2032
2053
  private shouldReconnect;
2033
2054
  private cleanupCallbacks;
2055
+ private disposed;
2056
+ private reconnectTimer?;
2034
2057
  constructor(options: WebsocketOptions);
2035
2058
  connect(): void;
2059
+ private attachSocket;
2036
2060
  private setupListeners;
2037
- private reconnect;
2061
+ private tryReconnect;
2038
2062
  send(event: string, data: any): void;
2039
2063
  on<T = unknown>(eventType: string, callback: EventCallback<T>): void;
2040
2064
  close(): void;
2065
+ /** Page navigation prompt (e.g. cancelled "Leave site?") — close only, keep reconnect eligible. */
2066
+ private closeForPageLeave;
2067
+ private stopSocketWithoutReconnect;
2041
2068
  cleanup(): void;
2042
2069
  }
2043
2070
 
@@ -2159,6 +2186,20 @@ interface KnowledgeAssistOptions {
2159
2186
  };
2160
2187
  }
2161
2188
  type OpenAdminFeedbackHandler = (feedbackPath: string) => void | Promise<void>;
2189
+ /**
2190
+ * Options for {@link DeepdeskSDK.reloadConversationContext}.
2191
+ */
2192
+ type ReloadConversationContextOptions = {
2193
+ /** Conversation payload from the host (same shape as {@link DeepdeskSDK.upsertConversation}). */
2194
+ conversation: CreateConversation;
2195
+ /** Optional visitor fields to apply when refreshing metadata on the same session. */
2196
+ visitorInfo?: Partial<VisitorInfo>;
2197
+ /**
2198
+ * When `true`, clears on-screen assistant output after upsert (typical same-conversation refresh).
2199
+ * Visitor info is applied after upsert (and after the UI clear when requested).
2200
+ */
2201
+ clearDisplayedUi?: boolean;
2202
+ };
2162
2203
  interface WidgetOptions {
2163
2204
  customStyles?: WidgetCustomStyles;
2164
2205
  showImages?: boolean;
@@ -2189,12 +2230,19 @@ declare class DeepdeskSDK {
2189
2230
  private eventListeners;
2190
2231
  private unmountHandlers;
2191
2232
  private disposeHandlers;
2233
+ private disposed;
2192
2234
  private inlineSuggestions;
2193
2235
  private aboveSuggestions;
2194
2236
  private belowSuggestions;
2195
2237
  private floatingMenu;
2196
2238
  private widgetElement;
2197
2239
  private widgetRoot;
2240
+ /** Shared DialogOverlays root (SearchOverlay / CMD+K). Owned by mount and/or renderWidget. */
2241
+ private dialogOverlays;
2242
+ /** First `customStyles` passed to {@link ensureDialogOverlays} wins for the shared root. */
2243
+ private dialogOverlaysCustomStyles;
2244
+ /** OR of includeLoginOverlay across ensureDialogOverlays callers (mount can upgrade widget-only). */
2245
+ private dialogOverlaysIncludeLogin;
2198
2246
  private nicknameDialogUnsubscribe;
2199
2247
  private nicknameDialogFailed;
2200
2248
  private dynamicThunkObject;
@@ -2237,9 +2285,9 @@ declare class DeepdeskSDK {
2237
2285
  */
2238
2286
  constructor({ deepdeskUrl, version, locale, token, fetch, productName, createCustomChannel, websocketClient, }: SDKOptions);
2239
2287
  get state(): {
2240
- assistants: State$9;
2288
+ assistants: State$8;
2241
2289
  auth: State$2;
2242
- conversation: State$a;
2290
+ conversation: State$9;
2243
2291
  contentTypes: State$3;
2244
2292
  passwordlessToken: State$4;
2245
2293
  entities: State$1;
@@ -2291,9 +2339,9 @@ declare class DeepdeskSDK {
2291
2339
  enableFeedbackForm: boolean;
2292
2340
  hasKeyboardInput: boolean;
2293
2341
  };
2294
- profile: State$7;
2342
+ profile: State$a;
2295
2343
  search: State$b;
2296
- styleSuggestions: State$8;
2344
+ styleSuggestions: State$7;
2297
2345
  ui: {
2298
2346
  showTabHint: boolean;
2299
2347
  inputHasFocus: boolean;
@@ -2694,6 +2742,106 @@ declare class DeepdeskSDK {
2694
2742
  * ```
2695
2743
  */
2696
2744
  resetConversation(): void;
2745
+ /**
2746
+ * Clears on-screen assistant answers and related suggestion UI for the loaded
2747
+ * conversation without unloading it from the store.
2748
+ *
2749
+ * **Preserved:** `conversation.current` (including `id`, `externalId`, and `metadata`),
2750
+ * visitor info, profile configuration, and active handling-time tracking.
2751
+ *
2752
+ * **Reset:** assistant panels, text/style/search/pinned suggestions, entities, and input
2753
+ * fields tied to displayed answers (same slices as after {@link resetConversation}, except
2754
+ * `conversation.current` and handling-time state stay set).
2755
+ *
2756
+ * Does not re-fetch CRM data or post transcript messages. For a host-driven refresh,
2757
+ * use {@link reloadConversationContext} with `clearDisplayedUi: true` and then
2758
+ * {@link publishConversationTranscript}.
2759
+ *
2760
+ * **Integrators:** do not dispatch private store actions (for example
2761
+ * `conversation/upsert/fulfilled`) to simulate a refresh; use the public methods above.
2762
+ *
2763
+ * No-op when no conversation is loaded.
2764
+ *
2765
+ * @example
2766
+ * ```typescript
2767
+ * // Same session, only wipe stale suggestions before reposting messages
2768
+ * sdk.clearDisplayedAnswers();
2769
+ * await sdk.publishConversationTranscript(messagesFromCrm);
2770
+ * ```
2771
+ */
2772
+ clearDisplayedAnswers(): void;
2773
+ /**
2774
+ * Applies host-fetched conversation metadata to the current SDK session.
2775
+ *
2776
+ * Upserts via {@link upsertConversation} and optionally clears on-screen assistant UI.
2777
+ * The host must fetch CRM (or other) data itself; this method does not load emails or
2778
+ * transcript text. Call {@link publishConversationTranscript} afterward to push messages
2779
+ * and refresh the conversation query.
2780
+ *
2781
+ * When `clearDisplayedUi` is `true`, {@link clearDisplayedAnswers} runs after the upsert.
2782
+ * If `visitorInfo` is provided, it is applied after the upsert (and after the UI clear when
2783
+ * requested). {@link clearDisplayedAnswers} does not clear visitor info; apply visitor info
2784
+ * after upsert so it is not lost when upsert switches or resets conversation state.
2785
+ *
2786
+ * When switching to a different conversation, prefer {@link resetConversation} first,
2787
+ * then load or upsert the new conversation.
2788
+ *
2789
+ * @param options - Host conversation payload and optional visitor / UI flags.
2790
+ * @param options.conversation - Metadata to upsert (external id, platform, metadata, etc.).
2791
+ * @param options.visitorInfo - Visitor fields to merge when refreshing the same session.
2792
+ * @param options.clearDisplayedUi - Clear assistant/suggestion UI after upsert (default `false`).
2793
+ *
2794
+ * @example
2795
+ * ```typescript
2796
+ * const conversation = await fetchConversationFromCrm(caseId);
2797
+ * const messages = await fetchEmailsFromCrm(caseId);
2798
+ *
2799
+ * await sdk.reloadConversationContext({
2800
+ * conversation,
2801
+ * visitorInfo: { visitorId: contactId, visitorName: contactName },
2802
+ * clearDisplayedUi: true,
2803
+ * });
2804
+ *
2805
+ * // Optional: host-only widget state (assistant input, etc.)
2806
+ * updateWidgetAssistantInput(...);
2807
+ *
2808
+ * await sdk.publishConversationTranscript(messages);
2809
+ * ```
2810
+ */
2811
+ reloadConversationContext({ conversation, visitorInfo, clearDisplayedUi, }: ReloadConversationContextOptions): Promise<void>;
2812
+ /**
2813
+ * Publishes a host-built transcript for the current conversation.
2814
+ *
2815
+ * Sets the dynamic conversation query to the given messages and, when the array is
2816
+ * non-empty, posts them through {@link postMessages}. Use after
2817
+ * {@link reloadConversationContext} when the host already fetched the latest thread
2818
+ * from an external system.
2819
+ *
2820
+ * @param messages - Transcript lines (`source`, `text`, and other {@link ConversationMessage} fields).
2821
+ *
2822
+ * @example
2823
+ * ```typescript
2824
+ * await sdk.publishConversationTranscript([
2825
+ * {
2826
+ * externalId: 'msg-1',
2827
+ * time: '2024-01-01T12:00:00Z',
2828
+ * source: 'visitor',
2829
+ * authorId: 'visitor-1',
2830
+ * text: 'Hello',
2831
+ * metadata: null,
2832
+ * },
2833
+ * {
2834
+ * externalId: 'msg-2',
2835
+ * time: '2024-01-01T12:01:00Z',
2836
+ * source: 'agent',
2837
+ * authorId: 'agent-1',
2838
+ * text: 'Hi, how can I help?',
2839
+ * metadata: null,
2840
+ * },
2841
+ * ]);
2842
+ * ```
2843
+ */
2844
+ publishConversationTranscript(messages: ConversationMessage[]): Promise<void>;
2697
2845
  /**
2698
2846
  * Updates SDK configuration settings.
2699
2847
  *
@@ -3390,6 +3538,17 @@ declare class DeepdeskSDK {
3390
3538
  private renderInlineSuggestions;
3391
3539
  private renderAboveOrBelowSuggestions;
3392
3540
  private renderFloatingMenu;
3541
+ /**
3542
+ * Mount DialogOverlays (SearchOverlay / CMD+K) once per SDK instance.
3543
+ * Used by both {@link mount} and {@link renderWidget} so iframe-only widgets
3544
+ * (Content Guru, Dimelo) get search without attaching to a host input.
3545
+ *
3546
+ * `customStyles`: first caller wins (later `mount` / `renderWidget` styles are ignored).
3547
+ * `includeLoginOverlay`: OR'd across callers — `mount` can upgrade a widget-only root
3548
+ * by re-rendering into the **existing** React root (preserves SearchOverlay local state).
3549
+ */
3550
+ private ensureDialogOverlays;
3551
+ private disposeDialogOverlays;
3393
3552
  private renderOverlays;
3394
3553
  /**
3395
3554
  * Renders the Deepdesk widget in a container element.
@@ -3401,6 +3560,11 @@ declare class DeepdeskSDK {
3401
3560
  * **Important:** Make sure to set the container element to a fixed or minimum size
3402
3561
  * (height and width) as the widget will grow to fill the container.
3403
3562
  *
3563
+ * Also mounts dialog overlays (search command palette / CMD+K) so iframe-only
3564
+ * integrations that never call {@link mount} still get search. Shared with `mount()` —
3565
+ * only one overlays root exists per SDK instance. Does **not** mount `LoginOverlay`
3566
+ * (iframe apps use their own sign-in); `mount()` still can.
3567
+ *
3404
3568
  * **Note:** Only one widget can be rendered per SDK instance.
3405
3569
  *
3406
3570
  * @param containerElement - Element to render widget in
@@ -3717,6 +3881,8 @@ declare function waitForElementVisibilityChange(element: HTMLElement, callback:
3717
3881
  isVisible: boolean;
3718
3882
  }) => void, interval?: number): Cancelable;
3719
3883
 
3884
+ declare function clearWidgetAssistantSessionId(externalConversationId: string | undefined): void;
3885
+
3720
3886
  type LogEvent<T extends keyof SendEventArgumentMap, P extends T = T> = {
3721
3887
  name: T;
3722
3888
  data: SendEventArgumentMap[P]['data'];
@@ -3726,4 +3892,4 @@ declare function logEvent<T extends keyof SendEventArgumentMap>(event: LogEvent<
3726
3892
  type CSSModule = Record<string, string>;
3727
3893
  declare function useStyles<TStyles extends CSSModule>(componentName: string, defaultStyles: TStyles): TStyles;
3728
3894
 
3729
- export { type AgentInfo, Card, ContentEditableInput, type Conversation, type ConversationAssistantResult, type ConversationMessage, DeepdeskAPI, DeepdeskSDK, type EvaluationAttachment, HTTPClient, InputMediator, type InputOverlayCustomStyles, InputType, KeyboardHint, Label, Locale, type Logger, type MountOptions, type OpenAdminFeedbackHandler, type PinnedMessage, type PlatformConfig, type RootState, Section, SectionList, type SelectionRange, Sources, Suggestion, type SuggestionEventMetrics, SuggestionList, type SuggestionMetrics, TextAreaInput, type TextSuggestion, ToggleButton, type UrlSuggestion, type VisitorInfo, type WidgetCustomStyles, type WidgetOptions, attachFile, authenticateWithKey, createFullRange, createOverlayContainer, createRangeFromOffsets, escapeHTML, formatTextMarkup, getRangeOffsets, getRangeText, insertCKEditor, isHTML, isSupportedInputElement, logEvent, updateContentEditable, updateTextArea, useClickOutsideRoot, useStyles, waitForElementVisibilityChange };
3895
+ export { type AgentInfo, Card, ContentEditableInput, type Conversation, type ConversationAssistantResult, type ConversationMessage, DeepdeskAPI, DeepdeskSDK, type EvaluationAttachment, HTTPClient, InputMediator, type InputOverlayCustomStyles, InputType, KeyboardHint, Label, Locale, type Logger, type MountOptions, type OpenAdminFeedbackHandler, type PinnedMessage, type PlatformConfig, type ReloadConversationContextOptions, type RootState, Section, SectionList, type SelectionRange, Sources, Suggestion, type SuggestionEventMetrics, SuggestionList, type SuggestionMetrics, TextAreaInput, type TextSuggestion, ToggleButton, type UrlSuggestion, type VisitorInfo, type WidgetCustomStyles, type WidgetOptions, attachFile, authenticateWithKey, clearWidgetAssistantSessionId, createFullRange, createOverlayContainer, createRangeFromOffsets, escapeHTML, formatTextMarkup, getRangeOffsets, getRangeText, insertCKEditor, isHTML, isSupportedInputElement, logEvent, updateContentEditable, updateTextArea, useClickOutsideRoot, useStyles, waitForElementVisibilityChange };