@deepdesk/deepdesk-sdk 19.6.2-beta.8 → 19.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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;
@@ -2159,6 +2179,20 @@ interface KnowledgeAssistOptions {
2159
2179
  };
2160
2180
  }
2161
2181
  type OpenAdminFeedbackHandler = (feedbackPath: string) => void | Promise<void>;
2182
+ /**
2183
+ * Options for {@link DeepdeskSDK.reloadConversationContext}.
2184
+ */
2185
+ type ReloadConversationContextOptions = {
2186
+ /** Conversation payload from the host (same shape as {@link DeepdeskSDK.upsertConversation}). */
2187
+ conversation: CreateConversation;
2188
+ /** Optional visitor fields to apply when refreshing metadata on the same session. */
2189
+ visitorInfo?: Partial<VisitorInfo>;
2190
+ /**
2191
+ * When `true`, clears on-screen assistant output after upsert (typical same-conversation refresh).
2192
+ * Visitor info is applied after upsert (and after the UI clear when requested).
2193
+ */
2194
+ clearDisplayedUi?: boolean;
2195
+ };
2162
2196
  interface WidgetOptions {
2163
2197
  customStyles?: WidgetCustomStyles;
2164
2198
  showImages?: boolean;
@@ -2195,6 +2229,12 @@ declare class DeepdeskSDK {
2195
2229
  private floatingMenu;
2196
2230
  private widgetElement;
2197
2231
  private widgetRoot;
2232
+ /** Shared DialogOverlays root (SearchOverlay / CMD+K). Owned by mount and/or renderWidget. */
2233
+ private dialogOverlays;
2234
+ /** First `customStyles` passed to {@link ensureDialogOverlays} wins for the shared root. */
2235
+ private dialogOverlaysCustomStyles;
2236
+ /** OR of includeLoginOverlay across ensureDialogOverlays callers (mount can upgrade widget-only). */
2237
+ private dialogOverlaysIncludeLogin;
2198
2238
  private nicknameDialogUnsubscribe;
2199
2239
  private nicknameDialogFailed;
2200
2240
  private dynamicThunkObject;
@@ -2237,9 +2277,9 @@ declare class DeepdeskSDK {
2237
2277
  */
2238
2278
  constructor({ deepdeskUrl, version, locale, token, fetch, productName, createCustomChannel, websocketClient, }: SDKOptions);
2239
2279
  get state(): {
2240
- assistants: State$9;
2280
+ assistants: State$8;
2241
2281
  auth: State$2;
2242
- conversation: State$a;
2282
+ conversation: State$9;
2243
2283
  contentTypes: State$3;
2244
2284
  passwordlessToken: State$4;
2245
2285
  entities: State$1;
@@ -2291,9 +2331,9 @@ declare class DeepdeskSDK {
2291
2331
  enableFeedbackForm: boolean;
2292
2332
  hasKeyboardInput: boolean;
2293
2333
  };
2294
- profile: State$7;
2334
+ profile: State$a;
2295
2335
  search: State$b;
2296
- styleSuggestions: State$8;
2336
+ styleSuggestions: State$7;
2297
2337
  ui: {
2298
2338
  showTabHint: boolean;
2299
2339
  inputHasFocus: boolean;
@@ -2694,6 +2734,106 @@ declare class DeepdeskSDK {
2694
2734
  * ```
2695
2735
  */
2696
2736
  resetConversation(): void;
2737
+ /**
2738
+ * Clears on-screen assistant answers and related suggestion UI for the loaded
2739
+ * conversation without unloading it from the store.
2740
+ *
2741
+ * **Preserved:** `conversation.current` (including `id`, `externalId`, and `metadata`),
2742
+ * visitor info, profile configuration, and active handling-time tracking.
2743
+ *
2744
+ * **Reset:** assistant panels, text/style/search/pinned suggestions, entities, and input
2745
+ * fields tied to displayed answers (same slices as after {@link resetConversation}, except
2746
+ * `conversation.current` and handling-time state stay set).
2747
+ *
2748
+ * Does not re-fetch CRM data or post transcript messages. For a host-driven refresh,
2749
+ * use {@link reloadConversationContext} with `clearDisplayedUi: true` and then
2750
+ * {@link publishConversationTranscript}.
2751
+ *
2752
+ * **Integrators:** do not dispatch private store actions (for example
2753
+ * `conversation/upsert/fulfilled`) to simulate a refresh; use the public methods above.
2754
+ *
2755
+ * No-op when no conversation is loaded.
2756
+ *
2757
+ * @example
2758
+ * ```typescript
2759
+ * // Same session, only wipe stale suggestions before reposting messages
2760
+ * sdk.clearDisplayedAnswers();
2761
+ * await sdk.publishConversationTranscript(messagesFromCrm);
2762
+ * ```
2763
+ */
2764
+ clearDisplayedAnswers(): void;
2765
+ /**
2766
+ * Applies host-fetched conversation metadata to the current SDK session.
2767
+ *
2768
+ * Upserts via {@link upsertConversation} and optionally clears on-screen assistant UI.
2769
+ * The host must fetch CRM (or other) data itself; this method does not load emails or
2770
+ * transcript text. Call {@link publishConversationTranscript} afterward to push messages
2771
+ * and refresh the conversation query.
2772
+ *
2773
+ * When `clearDisplayedUi` is `true`, {@link clearDisplayedAnswers} runs after the upsert.
2774
+ * If `visitorInfo` is provided, it is applied after the upsert (and after the UI clear when
2775
+ * requested). {@link clearDisplayedAnswers} does not clear visitor info; apply visitor info
2776
+ * after upsert so it is not lost when upsert switches or resets conversation state.
2777
+ *
2778
+ * When switching to a different conversation, prefer {@link resetConversation} first,
2779
+ * then load or upsert the new conversation.
2780
+ *
2781
+ * @param options - Host conversation payload and optional visitor / UI flags.
2782
+ * @param options.conversation - Metadata to upsert (external id, platform, metadata, etc.).
2783
+ * @param options.visitorInfo - Visitor fields to merge when refreshing the same session.
2784
+ * @param options.clearDisplayedUi - Clear assistant/suggestion UI after upsert (default `false`).
2785
+ *
2786
+ * @example
2787
+ * ```typescript
2788
+ * const conversation = await fetchConversationFromCrm(caseId);
2789
+ * const messages = await fetchEmailsFromCrm(caseId);
2790
+ *
2791
+ * await sdk.reloadConversationContext({
2792
+ * conversation,
2793
+ * visitorInfo: { visitorId: contactId, visitorName: contactName },
2794
+ * clearDisplayedUi: true,
2795
+ * });
2796
+ *
2797
+ * // Optional: host-only widget state (assistant input, etc.)
2798
+ * updateWidgetAssistantInput(...);
2799
+ *
2800
+ * await sdk.publishConversationTranscript(messages);
2801
+ * ```
2802
+ */
2803
+ reloadConversationContext({ conversation, visitorInfo, clearDisplayedUi, }: ReloadConversationContextOptions): Promise<void>;
2804
+ /**
2805
+ * Publishes a host-built transcript for the current conversation.
2806
+ *
2807
+ * Sets the dynamic conversation query to the given messages and, when the array is
2808
+ * non-empty, posts them through {@link postMessages}. Use after
2809
+ * {@link reloadConversationContext} when the host already fetched the latest thread
2810
+ * from an external system.
2811
+ *
2812
+ * @param messages - Transcript lines (`source`, `text`, and other {@link ConversationMessage} fields).
2813
+ *
2814
+ * @example
2815
+ * ```typescript
2816
+ * await sdk.publishConversationTranscript([
2817
+ * {
2818
+ * externalId: 'msg-1',
2819
+ * time: '2024-01-01T12:00:00Z',
2820
+ * source: 'visitor',
2821
+ * authorId: 'visitor-1',
2822
+ * text: 'Hello',
2823
+ * metadata: null,
2824
+ * },
2825
+ * {
2826
+ * externalId: 'msg-2',
2827
+ * time: '2024-01-01T12:01:00Z',
2828
+ * source: 'agent',
2829
+ * authorId: 'agent-1',
2830
+ * text: 'Hi, how can I help?',
2831
+ * metadata: null,
2832
+ * },
2833
+ * ]);
2834
+ * ```
2835
+ */
2836
+ publishConversationTranscript(messages: ConversationMessage[]): Promise<void>;
2697
2837
  /**
2698
2838
  * Updates SDK configuration settings.
2699
2839
  *
@@ -3390,6 +3530,17 @@ declare class DeepdeskSDK {
3390
3530
  private renderInlineSuggestions;
3391
3531
  private renderAboveOrBelowSuggestions;
3392
3532
  private renderFloatingMenu;
3533
+ /**
3534
+ * Mount DialogOverlays (SearchOverlay / CMD+K) once per SDK instance.
3535
+ * Used by both {@link mount} and {@link renderWidget} so iframe-only widgets
3536
+ * (Content Guru, Dimelo) get search without attaching to a host input.
3537
+ *
3538
+ * `customStyles`: first caller wins (later `mount` / `renderWidget` styles are ignored).
3539
+ * `includeLoginOverlay`: OR'd across callers — `mount` can upgrade a widget-only root
3540
+ * by re-rendering into the **existing** React root (preserves SearchOverlay local state).
3541
+ */
3542
+ private ensureDialogOverlays;
3543
+ private disposeDialogOverlays;
3393
3544
  private renderOverlays;
3394
3545
  /**
3395
3546
  * Renders the Deepdesk widget in a container element.
@@ -3401,6 +3552,11 @@ declare class DeepdeskSDK {
3401
3552
  * **Important:** Make sure to set the container element to a fixed or minimum size
3402
3553
  * (height and width) as the widget will grow to fill the container.
3403
3554
  *
3555
+ * Also mounts dialog overlays (search command palette / CMD+K) so iframe-only
3556
+ * integrations that never call {@link mount} still get search. Shared with `mount()` —
3557
+ * only one overlays root exists per SDK instance. Does **not** mount `LoginOverlay`
3558
+ * (iframe apps use their own sign-in); `mount()` still can.
3559
+ *
3404
3560
  * **Note:** Only one widget can be rendered per SDK instance.
3405
3561
  *
3406
3562
  * @param containerElement - Element to render widget in
@@ -3726,4 +3882,4 @@ declare function logEvent<T extends keyof SendEventArgumentMap>(event: LogEvent<
3726
3882
  type CSSModule = Record<string, string>;
3727
3883
  declare function useStyles<TStyles extends CSSModule>(componentName: string, defaultStyles: TStyles): TStyles;
3728
3884
 
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 };
3885
+ 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, createFullRange, createOverlayContainer, createRangeFromOffsets, escapeHTML, formatTextMarkup, getRangeOffsets, getRangeText, insertCKEditor, isHTML, isSupportedInputElement, logEvent, updateContentEditable, updateTextArea, useClickOutsideRoot, useStyles, waitForElementVisibilityChange };