@deepdesk/deepdesk-sdk 19.6.2-beta.14 → 19.6.2-beta.16

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.mts CHANGED
@@ -412,6 +412,11 @@ type State$a = {
412
412
  /** Bumped on reset/clear so in-flight getProfile cannot repopulate profile. */
413
413
  generation: number;
414
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;
415
420
  };
416
421
 
417
422
  interface State$9 {
@@ -465,6 +470,13 @@ type State$8 = {
465
470
  }>;
466
471
  activeAssistantCode: string | null;
467
472
  nextLocalThreadId: number;
473
+ /** Evaluation ids suppressed after {@link clearDisplayedAnswers} so late chunks do not repopulate UI. */
474
+ suppressedEvaluationIds: string[];
475
+ /** Bumped on {@link clearDisplayedAnswers} so in-flight evaluateAssistant results are dropped. */
476
+ assistantDisplayGeneration: number;
477
+ pendingEvaluationGenerations: Record<string, number>;
478
+ pendingEvaluationAssistantCodes: Record<string, string>;
479
+ evaluationIdDisplayGeneration: Record<string, number>;
468
480
  };
469
481
  type Transcript = Array<{
470
482
  source: string;
@@ -2161,6 +2173,20 @@ interface KnowledgeAssistOptions {
2161
2173
  };
2162
2174
  }
2163
2175
  type OpenAdminFeedbackHandler = (feedbackPath: string) => void | Promise<void>;
2176
+ /**
2177
+ * Options for {@link DeepdeskSDK.reloadConversationContext}.
2178
+ */
2179
+ type ReloadConversationContextOptions = {
2180
+ /** Conversation payload from the host (same shape as {@link DeepdeskSDK.upsertConversation}). */
2181
+ conversation: CreateConversation;
2182
+ /** Optional visitor fields to apply when refreshing metadata on the same session. */
2183
+ visitorInfo?: Partial<VisitorInfo>;
2184
+ /**
2185
+ * When `true`, clears on-screen assistant output after upsert (typical same-conversation refresh).
2186
+ * Visitor info is applied after upsert (and after the UI clear when requested).
2187
+ */
2188
+ clearDisplayedUi?: boolean;
2189
+ };
2164
2190
  interface WidgetOptions {
2165
2191
  customStyles?: WidgetCustomStyles;
2166
2192
  showImages?: boolean;
@@ -2696,6 +2722,106 @@ declare class DeepdeskSDK {
2696
2722
  * ```
2697
2723
  */
2698
2724
  resetConversation(): void;
2725
+ /**
2726
+ * Clears on-screen assistant answers and related suggestion UI for the loaded
2727
+ * conversation without unloading it from the store.
2728
+ *
2729
+ * **Preserved:** `conversation.current` (including `id`, `externalId`, and `metadata`),
2730
+ * visitor info, profile configuration, and active handling-time tracking.
2731
+ *
2732
+ * **Reset:** assistant panels, text/style/search/pinned suggestions, entities, and input
2733
+ * fields tied to displayed answers (same slices as after {@link resetConversation}, except
2734
+ * `conversation.current` and handling-time state stay set).
2735
+ *
2736
+ * Does not re-fetch CRM data or post transcript messages. For a host-driven refresh,
2737
+ * use {@link reloadConversationContext} with `clearDisplayedUi: true` and then
2738
+ * {@link publishConversationTranscript}.
2739
+ *
2740
+ * **Integrators:** do not dispatch private store actions (for example
2741
+ * `conversation/upsert/fulfilled`) to simulate a refresh; use the public methods above.
2742
+ *
2743
+ * No-op when no conversation is loaded.
2744
+ *
2745
+ * @example
2746
+ * ```typescript
2747
+ * // Same session, only wipe stale suggestions before reposting messages
2748
+ * sdk.clearDisplayedAnswers();
2749
+ * await sdk.publishConversationTranscript(messagesFromCrm);
2750
+ * ```
2751
+ */
2752
+ clearDisplayedAnswers(): void;
2753
+ /**
2754
+ * Applies host-fetched conversation metadata to the current SDK session.
2755
+ *
2756
+ * Upserts via {@link upsertConversation} and optionally clears on-screen assistant UI.
2757
+ * The host must fetch CRM (or other) data itself; this method does not load emails or
2758
+ * transcript text. Call {@link publishConversationTranscript} afterward to push messages
2759
+ * and refresh the conversation query.
2760
+ *
2761
+ * When `clearDisplayedUi` is `true`, {@link clearDisplayedAnswers} runs after the upsert.
2762
+ * If `visitorInfo` is provided, it is applied after the upsert (and after the UI clear when
2763
+ * requested). {@link clearDisplayedAnswers} does not clear visitor info; apply visitor info
2764
+ * after upsert so it is not lost when upsert switches or resets conversation state.
2765
+ *
2766
+ * When switching to a different conversation, prefer {@link resetConversation} first,
2767
+ * then load or upsert the new conversation.
2768
+ *
2769
+ * @param options - Host conversation payload and optional visitor / UI flags.
2770
+ * @param options.conversation - Metadata to upsert (external id, platform, metadata, etc.).
2771
+ * @param options.visitorInfo - Visitor fields to merge when refreshing the same session.
2772
+ * @param options.clearDisplayedUi - Clear assistant/suggestion UI after upsert (default `false`).
2773
+ *
2774
+ * @example
2775
+ * ```typescript
2776
+ * const conversation = await fetchConversationFromCrm(caseId);
2777
+ * const messages = await fetchEmailsFromCrm(caseId);
2778
+ *
2779
+ * await sdk.reloadConversationContext({
2780
+ * conversation,
2781
+ * visitorInfo: { visitorId: contactId, visitorName: contactName },
2782
+ * clearDisplayedUi: true,
2783
+ * });
2784
+ *
2785
+ * // Optional: host-only widget state (assistant input, etc.)
2786
+ * updateWidgetAssistantInput(...);
2787
+ *
2788
+ * await sdk.publishConversationTranscript(messages);
2789
+ * ```
2790
+ */
2791
+ reloadConversationContext({ conversation, visitorInfo, clearDisplayedUi, }: ReloadConversationContextOptions): Promise<void>;
2792
+ /**
2793
+ * Publishes a host-built transcript for the current conversation.
2794
+ *
2795
+ * Sets the dynamic conversation query to the given messages and, when the array is
2796
+ * non-empty, posts them through {@link postMessages}. Use after
2797
+ * {@link reloadConversationContext} when the host already fetched the latest thread
2798
+ * from an external system.
2799
+ *
2800
+ * @param messages - Transcript lines (`source`, `text`, and other {@link ConversationMessage} fields).
2801
+ *
2802
+ * @example
2803
+ * ```typescript
2804
+ * await sdk.publishConversationTranscript([
2805
+ * {
2806
+ * externalId: 'msg-1',
2807
+ * time: '2024-01-01T12:00:00Z',
2808
+ * source: 'visitor',
2809
+ * authorId: 'visitor-1',
2810
+ * text: 'Hello',
2811
+ * metadata: null,
2812
+ * },
2813
+ * {
2814
+ * externalId: 'msg-2',
2815
+ * time: '2024-01-01T12:01:00Z',
2816
+ * source: 'agent',
2817
+ * authorId: 'agent-1',
2818
+ * text: 'Hi, how can I help?',
2819
+ * metadata: null,
2820
+ * },
2821
+ * ]);
2822
+ * ```
2823
+ */
2824
+ publishConversationTranscript(messages: ConversationMessage[]): Promise<void>;
2699
2825
  /**
2700
2826
  * Updates SDK configuration settings.
2701
2827
  *
@@ -3728,4 +3854,4 @@ declare function logEvent<T extends keyof SendEventArgumentMap>(event: LogEvent<
3728
3854
  type CSSModule = Record<string, string>;
3729
3855
  declare function useStyles<TStyles extends CSSModule>(componentName: string, defaultStyles: TStyles): TStyles;
3730
3856
 
3731
- 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 };
3857
+ 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 };
package/dist/index.d.ts CHANGED
@@ -412,6 +412,11 @@ type State$a = {
412
412
  /** Bumped on reset/clear so in-flight getProfile cannot repopulate profile. */
413
413
  generation: number;
414
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;
415
420
  };
416
421
 
417
422
  interface State$9 {
@@ -465,6 +470,13 @@ type State$8 = {
465
470
  }>;
466
471
  activeAssistantCode: string | null;
467
472
  nextLocalThreadId: number;
473
+ /** Evaluation ids suppressed after {@link clearDisplayedAnswers} so late chunks do not repopulate UI. */
474
+ suppressedEvaluationIds: string[];
475
+ /** Bumped on {@link clearDisplayedAnswers} so in-flight evaluateAssistant results are dropped. */
476
+ assistantDisplayGeneration: number;
477
+ pendingEvaluationGenerations: Record<string, number>;
478
+ pendingEvaluationAssistantCodes: Record<string, string>;
479
+ evaluationIdDisplayGeneration: Record<string, number>;
468
480
  };
469
481
  type Transcript = Array<{
470
482
  source: string;
@@ -2161,6 +2173,20 @@ interface KnowledgeAssistOptions {
2161
2173
  };
2162
2174
  }
2163
2175
  type OpenAdminFeedbackHandler = (feedbackPath: string) => void | Promise<void>;
2176
+ /**
2177
+ * Options for {@link DeepdeskSDK.reloadConversationContext}.
2178
+ */
2179
+ type ReloadConversationContextOptions = {
2180
+ /** Conversation payload from the host (same shape as {@link DeepdeskSDK.upsertConversation}). */
2181
+ conversation: CreateConversation;
2182
+ /** Optional visitor fields to apply when refreshing metadata on the same session. */
2183
+ visitorInfo?: Partial<VisitorInfo>;
2184
+ /**
2185
+ * When `true`, clears on-screen assistant output after upsert (typical same-conversation refresh).
2186
+ * Visitor info is applied after upsert (and after the UI clear when requested).
2187
+ */
2188
+ clearDisplayedUi?: boolean;
2189
+ };
2164
2190
  interface WidgetOptions {
2165
2191
  customStyles?: WidgetCustomStyles;
2166
2192
  showImages?: boolean;
@@ -2696,6 +2722,106 @@ declare class DeepdeskSDK {
2696
2722
  * ```
2697
2723
  */
2698
2724
  resetConversation(): void;
2725
+ /**
2726
+ * Clears on-screen assistant answers and related suggestion UI for the loaded
2727
+ * conversation without unloading it from the store.
2728
+ *
2729
+ * **Preserved:** `conversation.current` (including `id`, `externalId`, and `metadata`),
2730
+ * visitor info, profile configuration, and active handling-time tracking.
2731
+ *
2732
+ * **Reset:** assistant panels, text/style/search/pinned suggestions, entities, and input
2733
+ * fields tied to displayed answers (same slices as after {@link resetConversation}, except
2734
+ * `conversation.current` and handling-time state stay set).
2735
+ *
2736
+ * Does not re-fetch CRM data or post transcript messages. For a host-driven refresh,
2737
+ * use {@link reloadConversationContext} with `clearDisplayedUi: true` and then
2738
+ * {@link publishConversationTranscript}.
2739
+ *
2740
+ * **Integrators:** do not dispatch private store actions (for example
2741
+ * `conversation/upsert/fulfilled`) to simulate a refresh; use the public methods above.
2742
+ *
2743
+ * No-op when no conversation is loaded.
2744
+ *
2745
+ * @example
2746
+ * ```typescript
2747
+ * // Same session, only wipe stale suggestions before reposting messages
2748
+ * sdk.clearDisplayedAnswers();
2749
+ * await sdk.publishConversationTranscript(messagesFromCrm);
2750
+ * ```
2751
+ */
2752
+ clearDisplayedAnswers(): void;
2753
+ /**
2754
+ * Applies host-fetched conversation metadata to the current SDK session.
2755
+ *
2756
+ * Upserts via {@link upsertConversation} and optionally clears on-screen assistant UI.
2757
+ * The host must fetch CRM (or other) data itself; this method does not load emails or
2758
+ * transcript text. Call {@link publishConversationTranscript} afterward to push messages
2759
+ * and refresh the conversation query.
2760
+ *
2761
+ * When `clearDisplayedUi` is `true`, {@link clearDisplayedAnswers} runs after the upsert.
2762
+ * If `visitorInfo` is provided, it is applied after the upsert (and after the UI clear when
2763
+ * requested). {@link clearDisplayedAnswers} does not clear visitor info; apply visitor info
2764
+ * after upsert so it is not lost when upsert switches or resets conversation state.
2765
+ *
2766
+ * When switching to a different conversation, prefer {@link resetConversation} first,
2767
+ * then load or upsert the new conversation.
2768
+ *
2769
+ * @param options - Host conversation payload and optional visitor / UI flags.
2770
+ * @param options.conversation - Metadata to upsert (external id, platform, metadata, etc.).
2771
+ * @param options.visitorInfo - Visitor fields to merge when refreshing the same session.
2772
+ * @param options.clearDisplayedUi - Clear assistant/suggestion UI after upsert (default `false`).
2773
+ *
2774
+ * @example
2775
+ * ```typescript
2776
+ * const conversation = await fetchConversationFromCrm(caseId);
2777
+ * const messages = await fetchEmailsFromCrm(caseId);
2778
+ *
2779
+ * await sdk.reloadConversationContext({
2780
+ * conversation,
2781
+ * visitorInfo: { visitorId: contactId, visitorName: contactName },
2782
+ * clearDisplayedUi: true,
2783
+ * });
2784
+ *
2785
+ * // Optional: host-only widget state (assistant input, etc.)
2786
+ * updateWidgetAssistantInput(...);
2787
+ *
2788
+ * await sdk.publishConversationTranscript(messages);
2789
+ * ```
2790
+ */
2791
+ reloadConversationContext({ conversation, visitorInfo, clearDisplayedUi, }: ReloadConversationContextOptions): Promise<void>;
2792
+ /**
2793
+ * Publishes a host-built transcript for the current conversation.
2794
+ *
2795
+ * Sets the dynamic conversation query to the given messages and, when the array is
2796
+ * non-empty, posts them through {@link postMessages}. Use after
2797
+ * {@link reloadConversationContext} when the host already fetched the latest thread
2798
+ * from an external system.
2799
+ *
2800
+ * @param messages - Transcript lines (`source`, `text`, and other {@link ConversationMessage} fields).
2801
+ *
2802
+ * @example
2803
+ * ```typescript
2804
+ * await sdk.publishConversationTranscript([
2805
+ * {
2806
+ * externalId: 'msg-1',
2807
+ * time: '2024-01-01T12:00:00Z',
2808
+ * source: 'visitor',
2809
+ * authorId: 'visitor-1',
2810
+ * text: 'Hello',
2811
+ * metadata: null,
2812
+ * },
2813
+ * {
2814
+ * externalId: 'msg-2',
2815
+ * time: '2024-01-01T12:01:00Z',
2816
+ * source: 'agent',
2817
+ * authorId: 'agent-1',
2818
+ * text: 'Hi, how can I help?',
2819
+ * metadata: null,
2820
+ * },
2821
+ * ]);
2822
+ * ```
2823
+ */
2824
+ publishConversationTranscript(messages: ConversationMessage[]): Promise<void>;
2699
2825
  /**
2700
2826
  * Updates SDK configuration settings.
2701
2827
  *
@@ -3728,4 +3854,4 @@ declare function logEvent<T extends keyof SendEventArgumentMap>(event: LogEvent<
3728
3854
  type CSSModule = Record<string, string>;
3729
3855
  declare function useStyles<TStyles extends CSSModule>(componentName: string, defaultStyles: TStyles): TStyles;
3730
3856
 
3731
- 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 };
3857
+ 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 };