@deepdesk/deepdesk-sdk 19.6.2-beta.15 → 19.6.2-beta.17

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
@@ -470,6 +470,18 @@ type State$8 = {
470
470
  }>;
471
471
  activeAssistantCode: string | null;
472
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>;
473
485
  };
474
486
  type Transcript = Array<{
475
487
  source: string;
@@ -749,6 +761,7 @@ declare namespace Server {
749
761
  evaluation_id: string;
750
762
  evaluation_status: EvaluationStatus;
751
763
  session_id?: string;
764
+ is_silent?: boolean;
752
765
  output: EvaluationOutput | KAAnswer | string;
753
766
  };
754
767
  type EvaluationOutput = Array<{
@@ -2166,6 +2179,20 @@ interface KnowledgeAssistOptions {
2166
2179
  };
2167
2180
  }
2168
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
+ };
2169
2196
  interface WidgetOptions {
2170
2197
  customStyles?: WidgetCustomStyles;
2171
2198
  showImages?: boolean;
@@ -2701,6 +2728,106 @@ declare class DeepdeskSDK {
2701
2728
  * ```
2702
2729
  */
2703
2730
  resetConversation(): void;
2731
+ /**
2732
+ * Clears on-screen assistant answers and related suggestion UI for the loaded
2733
+ * conversation without unloading it from the store.
2734
+ *
2735
+ * **Preserved:** `conversation.current` (including `id`, `externalId`, and `metadata`),
2736
+ * visitor info, profile configuration, and active handling-time tracking.
2737
+ *
2738
+ * **Reset:** assistant panels, text/style/search/pinned suggestions, entities, and input
2739
+ * fields tied to displayed answers (same slices as after {@link resetConversation}, except
2740
+ * `conversation.current` and handling-time state stay set).
2741
+ *
2742
+ * Does not re-fetch CRM data or post transcript messages. For a host-driven refresh,
2743
+ * use {@link reloadConversationContext} with `clearDisplayedUi: true` and then
2744
+ * {@link publishConversationTranscript}.
2745
+ *
2746
+ * **Integrators:** do not dispatch private store actions (for example
2747
+ * `conversation/upsert/fulfilled`) to simulate a refresh; use the public methods above.
2748
+ *
2749
+ * No-op when no conversation is loaded.
2750
+ *
2751
+ * @example
2752
+ * ```typescript
2753
+ * // Same session, only wipe stale suggestions before reposting messages
2754
+ * sdk.clearDisplayedAnswers();
2755
+ * await sdk.publishConversationTranscript(messagesFromCrm);
2756
+ * ```
2757
+ */
2758
+ clearDisplayedAnswers(): void;
2759
+ /**
2760
+ * Applies host-fetched conversation metadata to the current SDK session.
2761
+ *
2762
+ * Upserts via {@link upsertConversation} and optionally clears on-screen assistant UI.
2763
+ * The host must fetch CRM (or other) data itself; this method does not load emails or
2764
+ * transcript text. Call {@link publishConversationTranscript} afterward to push messages
2765
+ * and refresh the conversation query.
2766
+ *
2767
+ * When `clearDisplayedUi` is `true`, {@link clearDisplayedAnswers} runs after the upsert.
2768
+ * If `visitorInfo` is provided, it is applied after the upsert (and after the UI clear when
2769
+ * requested). {@link clearDisplayedAnswers} does not clear visitor info; apply visitor info
2770
+ * after upsert so it is not lost when upsert switches or resets conversation state.
2771
+ *
2772
+ * When switching to a different conversation, prefer {@link resetConversation} first,
2773
+ * then load or upsert the new conversation.
2774
+ *
2775
+ * @param options - Host conversation payload and optional visitor / UI flags.
2776
+ * @param options.conversation - Metadata to upsert (external id, platform, metadata, etc.).
2777
+ * @param options.visitorInfo - Visitor fields to merge when refreshing the same session.
2778
+ * @param options.clearDisplayedUi - Clear assistant/suggestion UI after upsert (default `false`).
2779
+ *
2780
+ * @example
2781
+ * ```typescript
2782
+ * const conversation = await fetchConversationFromCrm(caseId);
2783
+ * const messages = await fetchEmailsFromCrm(caseId);
2784
+ *
2785
+ * await sdk.reloadConversationContext({
2786
+ * conversation,
2787
+ * visitorInfo: { visitorId: contactId, visitorName: contactName },
2788
+ * clearDisplayedUi: true,
2789
+ * });
2790
+ *
2791
+ * // Optional: host-only widget state (assistant input, etc.)
2792
+ * updateWidgetAssistantInput(...);
2793
+ *
2794
+ * await sdk.publishConversationTranscript(messages);
2795
+ * ```
2796
+ */
2797
+ reloadConversationContext({ conversation, visitorInfo, clearDisplayedUi, }: ReloadConversationContextOptions): Promise<void>;
2798
+ /**
2799
+ * Publishes a host-built transcript for the current conversation.
2800
+ *
2801
+ * Sets the dynamic conversation query to the given messages and, when the array is
2802
+ * non-empty, posts them through {@link postMessages}. Use after
2803
+ * {@link reloadConversationContext} when the host already fetched the latest thread
2804
+ * from an external system.
2805
+ *
2806
+ * @param messages - Transcript lines (`source`, `text`, and other {@link ConversationMessage} fields).
2807
+ *
2808
+ * @example
2809
+ * ```typescript
2810
+ * await sdk.publishConversationTranscript([
2811
+ * {
2812
+ * externalId: 'msg-1',
2813
+ * time: '2024-01-01T12:00:00Z',
2814
+ * source: 'visitor',
2815
+ * authorId: 'visitor-1',
2816
+ * text: 'Hello',
2817
+ * metadata: null,
2818
+ * },
2819
+ * {
2820
+ * externalId: 'msg-2',
2821
+ * time: '2024-01-01T12:01:00Z',
2822
+ * source: 'agent',
2823
+ * authorId: 'agent-1',
2824
+ * text: 'Hi, how can I help?',
2825
+ * metadata: null,
2826
+ * },
2827
+ * ]);
2828
+ * ```
2829
+ */
2830
+ publishConversationTranscript(messages: ConversationMessage[]): Promise<void>;
2704
2831
  /**
2705
2832
  * Updates SDK configuration settings.
2706
2833
  *
@@ -3733,4 +3860,4 @@ declare function logEvent<T extends keyof SendEventArgumentMap>(event: LogEvent<
3733
3860
  type CSSModule = Record<string, string>;
3734
3861
  declare function useStyles<TStyles extends CSSModule>(componentName: string, defaultStyles: TStyles): TStyles;
3735
3862
 
3736
- 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 };
3863
+ 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
@@ -470,6 +470,18 @@ type State$8 = {
470
470
  }>;
471
471
  activeAssistantCode: string | null;
472
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>;
473
485
  };
474
486
  type Transcript = Array<{
475
487
  source: string;
@@ -749,6 +761,7 @@ declare namespace Server {
749
761
  evaluation_id: string;
750
762
  evaluation_status: EvaluationStatus;
751
763
  session_id?: string;
764
+ is_silent?: boolean;
752
765
  output: EvaluationOutput | KAAnswer | string;
753
766
  };
754
767
  type EvaluationOutput = Array<{
@@ -2166,6 +2179,20 @@ interface KnowledgeAssistOptions {
2166
2179
  };
2167
2180
  }
2168
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
+ };
2169
2196
  interface WidgetOptions {
2170
2197
  customStyles?: WidgetCustomStyles;
2171
2198
  showImages?: boolean;
@@ -2701,6 +2728,106 @@ declare class DeepdeskSDK {
2701
2728
  * ```
2702
2729
  */
2703
2730
  resetConversation(): void;
2731
+ /**
2732
+ * Clears on-screen assistant answers and related suggestion UI for the loaded
2733
+ * conversation without unloading it from the store.
2734
+ *
2735
+ * **Preserved:** `conversation.current` (including `id`, `externalId`, and `metadata`),
2736
+ * visitor info, profile configuration, and active handling-time tracking.
2737
+ *
2738
+ * **Reset:** assistant panels, text/style/search/pinned suggestions, entities, and input
2739
+ * fields tied to displayed answers (same slices as after {@link resetConversation}, except
2740
+ * `conversation.current` and handling-time state stay set).
2741
+ *
2742
+ * Does not re-fetch CRM data or post transcript messages. For a host-driven refresh,
2743
+ * use {@link reloadConversationContext} with `clearDisplayedUi: true` and then
2744
+ * {@link publishConversationTranscript}.
2745
+ *
2746
+ * **Integrators:** do not dispatch private store actions (for example
2747
+ * `conversation/upsert/fulfilled`) to simulate a refresh; use the public methods above.
2748
+ *
2749
+ * No-op when no conversation is loaded.
2750
+ *
2751
+ * @example
2752
+ * ```typescript
2753
+ * // Same session, only wipe stale suggestions before reposting messages
2754
+ * sdk.clearDisplayedAnswers();
2755
+ * await sdk.publishConversationTranscript(messagesFromCrm);
2756
+ * ```
2757
+ */
2758
+ clearDisplayedAnswers(): void;
2759
+ /**
2760
+ * Applies host-fetched conversation metadata to the current SDK session.
2761
+ *
2762
+ * Upserts via {@link upsertConversation} and optionally clears on-screen assistant UI.
2763
+ * The host must fetch CRM (or other) data itself; this method does not load emails or
2764
+ * transcript text. Call {@link publishConversationTranscript} afterward to push messages
2765
+ * and refresh the conversation query.
2766
+ *
2767
+ * When `clearDisplayedUi` is `true`, {@link clearDisplayedAnswers} runs after the upsert.
2768
+ * If `visitorInfo` is provided, it is applied after the upsert (and after the UI clear when
2769
+ * requested). {@link clearDisplayedAnswers} does not clear visitor info; apply visitor info
2770
+ * after upsert so it is not lost when upsert switches or resets conversation state.
2771
+ *
2772
+ * When switching to a different conversation, prefer {@link resetConversation} first,
2773
+ * then load or upsert the new conversation.
2774
+ *
2775
+ * @param options - Host conversation payload and optional visitor / UI flags.
2776
+ * @param options.conversation - Metadata to upsert (external id, platform, metadata, etc.).
2777
+ * @param options.visitorInfo - Visitor fields to merge when refreshing the same session.
2778
+ * @param options.clearDisplayedUi - Clear assistant/suggestion UI after upsert (default `false`).
2779
+ *
2780
+ * @example
2781
+ * ```typescript
2782
+ * const conversation = await fetchConversationFromCrm(caseId);
2783
+ * const messages = await fetchEmailsFromCrm(caseId);
2784
+ *
2785
+ * await sdk.reloadConversationContext({
2786
+ * conversation,
2787
+ * visitorInfo: { visitorId: contactId, visitorName: contactName },
2788
+ * clearDisplayedUi: true,
2789
+ * });
2790
+ *
2791
+ * // Optional: host-only widget state (assistant input, etc.)
2792
+ * updateWidgetAssistantInput(...);
2793
+ *
2794
+ * await sdk.publishConversationTranscript(messages);
2795
+ * ```
2796
+ */
2797
+ reloadConversationContext({ conversation, visitorInfo, clearDisplayedUi, }: ReloadConversationContextOptions): Promise<void>;
2798
+ /**
2799
+ * Publishes a host-built transcript for the current conversation.
2800
+ *
2801
+ * Sets the dynamic conversation query to the given messages and, when the array is
2802
+ * non-empty, posts them through {@link postMessages}. Use after
2803
+ * {@link reloadConversationContext} when the host already fetched the latest thread
2804
+ * from an external system.
2805
+ *
2806
+ * @param messages - Transcript lines (`source`, `text`, and other {@link ConversationMessage} fields).
2807
+ *
2808
+ * @example
2809
+ * ```typescript
2810
+ * await sdk.publishConversationTranscript([
2811
+ * {
2812
+ * externalId: 'msg-1',
2813
+ * time: '2024-01-01T12:00:00Z',
2814
+ * source: 'visitor',
2815
+ * authorId: 'visitor-1',
2816
+ * text: 'Hello',
2817
+ * metadata: null,
2818
+ * },
2819
+ * {
2820
+ * externalId: 'msg-2',
2821
+ * time: '2024-01-01T12:01:00Z',
2822
+ * source: 'agent',
2823
+ * authorId: 'agent-1',
2824
+ * text: 'Hi, how can I help?',
2825
+ * metadata: null,
2826
+ * },
2827
+ * ]);
2828
+ * ```
2829
+ */
2830
+ publishConversationTranscript(messages: ConversationMessage[]): Promise<void>;
2704
2831
  /**
2705
2832
  * Updates SDK configuration settings.
2706
2833
  *
@@ -3733,4 +3860,4 @@ declare function logEvent<T extends keyof SendEventArgumentMap>(event: LogEvent<
3733
3860
  type CSSModule = Record<string, string>;
3734
3861
  declare function useStyles<TStyles extends CSSModule>(componentName: string, defaultStyles: TStyles): TStyles;
3735
3862
 
3736
- 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 };
3863
+ 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 };