@marketrix.ai/widget 3.8.455 → 3.8.457

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 (39) hide show
  1. package/dist/src/components/base/Stack.d.ts +3 -15
  2. package/dist/src/components/base/icons.d.ts +0 -32
  3. package/dist/src/components/blocks/HeaderBar.d.ts +2 -2
  4. package/dist/src/components/blocks/WidgetFab.d.ts +2 -15
  5. package/dist/src/components/chat/MessageList.d.ts +3 -7
  6. package/dist/src/components/chat/SuggestedActions.d.ts +3 -9
  7. package/dist/src/components/chat/TaskStatusIcon.d.ts +4 -5
  8. package/dist/src/components/navigation/MessengerShell.d.ts +1 -21
  9. package/dist/src/components/views/ChatView.d.ts +6 -18
  10. package/dist/src/components/views/HomeView.d.ts +0 -3
  11. package/dist/src/context/ChatContext.d.ts +3 -11
  12. package/dist/src/context/UIStateContext.d.ts +2 -9
  13. package/dist/src/context/sseReducer.d.ts +2 -2
  14. package/dist/src/design-system/component-tokens.d.ts +1 -8
  15. package/dist/src/hooks/useResize.d.ts +1 -3
  16. package/dist/src/hooks/useWidget.d.ts +27 -32
  17. package/dist/src/sdk/contract.d.ts +0 -10
  18. package/dist/src/sdk/contracts/activityLog.d.ts +0 -30
  19. package/dist/src/sdk/contracts/entities.d.ts +0 -15
  20. package/dist/src/sdk/index.d.ts +0 -10
  21. package/dist/src/services/ApiService.d.ts +4 -4
  22. package/dist/src/services/BrowserToolService.d.ts +0 -1
  23. package/dist/src/services/ChatService.d.ts +7 -19
  24. package/dist/src/services/ChatSessionManager.d.ts +2 -7
  25. package/dist/src/services/DomService.d.ts +4 -23
  26. package/dist/src/services/ShowModeService.d.ts +2 -2
  27. package/dist/src/services/StorageService.d.ts +14 -14
  28. package/dist/src/services/StreamClient.d.ts +1 -8
  29. package/dist/src/services/WidgetService.d.ts +4 -0
  30. package/dist/src/types/index.d.ts +3 -10
  31. package/dist/src/utils/bootstrap.d.ts +6 -8
  32. package/dist/src/utils/chat.d.ts +5 -1
  33. package/dist/src/utils/color.d.ts +0 -2
  34. package/dist/src/utils/suggestedActions.d.ts +0 -3
  35. package/dist/src/utils/widgetPositioning.d.ts +18 -0
  36. package/dist/widget.mjs +63 -60
  37. package/dist/widget.mjs.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/src/services/ConfigManager.d.ts +0 -10
@@ -1,38 +1,19 @@
1
- export interface ElementFingerprint {
2
- tagName: string;
3
- id: string | null;
4
- textContent: string | null;
5
- type: string | null;
6
- role: string | null;
7
- ariaLabel: string | null;
8
- name: string | null;
9
- href: string | null;
10
- selector: string;
11
- indexVersion: number;
12
- }
13
1
  export interface ValidatedElementResult {
14
2
  element: HTMLElement | null;
15
3
  error?: string;
16
4
  }
17
5
  export declare class DomService {
18
- private elementMap;
6
+ private index;
19
7
  private elementToSequence;
20
- private selectorMap;
21
- private fingerprintMap;
22
- private indexingInProgress;
23
- private indexVersion;
24
8
  private generateSelector;
25
- private generateFingerprint;
26
- private matchesFingerprint;
27
- private validateElementAtIndex;
28
- indexInteractableElements(): Array<[number, Element]>;
9
+ private staleReason;
10
+ private indexInteractableElements;
29
11
  private getElementCoordinates;
30
12
  private isStackingContext;
31
13
  private calculateGlobalZOrder;
32
14
  getSnapshotHtml(): string;
33
15
  getSequenceForElement(element: Element): number | undefined;
34
- clearIndex(): void;
35
- private checkInteractability;
16
+ private clearIndex;
36
17
  checkElementInteractable(element: HTMLElement, index: number): string | null;
37
18
  getValidatedElement(index: number): ValidatedElementResult;
38
19
  }
@@ -14,12 +14,12 @@ export declare class ShowModeService {
14
14
  private rejectPromise;
15
15
  private clickHandler;
16
16
  private scrollHandler;
17
- private updateHighlightPosition;
18
- private rafId;
19
17
  private mutationObserver;
20
18
  private visibilityCheckInterval;
21
19
  showToolAction(options: ShowModeOptions): Promise<boolean>;
22
20
  cleanup(): void;
21
+ /** Detach both settlers before calling one — the click handler, the Continue button and the two watchdogs race. */
22
+ private takeSettlers;
23
23
  private createHighlight;
24
24
  private createPopup;
25
25
  private setupPositionUpdates;
@@ -1,33 +1,33 @@
1
1
  import type { ChatMessage, InstructionType, MarketrixConfig } from '../types';
2
- type StoredMessage = Omit<ChatMessage, 'videoStream' | 'timestamp'> & {
2
+ export type StoredMessage = Omit<ChatMessage, 'videoStream' | 'timestamp'> & {
3
3
  timestamp: string;
4
4
  };
5
- export interface MarketrixChatContext {
6
- chat_id: string | null;
7
- messages: StoredMessage[];
5
+ /** The live half of the persisted context: exactly what the widget's three React stores hold between them. */
6
+ export interface ChatSnapshot {
7
+ messages: ChatMessage[];
8
8
  isTaskRunning: boolean;
9
9
  activeTaskId: string | null;
10
10
  currentMode: InstructionType;
11
11
  isOpen: boolean;
12
- isMinimized: boolean;
13
12
  isLoading: boolean;
13
+ }
14
+ export type MarketrixChatContext = Omit<ChatSnapshot, 'messages'> & {
15
+ chat_id: string | null;
16
+ messages: StoredMessage[];
14
17
  config: MarketrixConfig | null;
15
18
  timestamp: number;
16
- }
19
+ };
20
+ export declare function readLocal(key: string): string | null;
21
+ export declare function writeLocal(key: string, value: string): void;
17
22
  declare class StorageService {
18
23
  private context;
19
- constructor();
20
- private loadContext;
21
- private saveContext;
22
24
  getContext(): MarketrixChatContext;
23
25
  updateContext(updates: Partial<MarketrixChatContext>): void;
24
- private isValidChatId;
25
- /** window.name takes priority over localStorage — it persists across page navigations. */
26
+ /** window.name takes priority over localStorage — it is what survives host-page navigation. */
26
27
  getChatId(): string | null;
27
- setChatId(chatId: string | null): void;
28
+ setChatId(chatId: string): void;
28
29
  getConfig(): MarketrixConfig | null;
29
- setConfig(config: MarketrixConfig | null): void;
30
- hasValidContext(): boolean;
30
+ setConfig(config: MarketrixConfig): void;
31
31
  }
32
32
  export declare const storageService: StorageService;
33
33
  export {};
@@ -1,7 +1,6 @@
1
1
  import { type WidgetCommand, type WidgetEvent } from '../sdk';
2
2
  export type StreamStatus = 'disconnected' | 'connecting' | 'connected' | 'registered' | 'error';
3
3
  export interface StreamClientCallbacks {
4
- onStatusChange?: (status: StreamStatus) => void;
5
4
  onMessage?: (event: WidgetEvent) => void;
6
5
  onError?: (error: Error) => void;
7
6
  }
@@ -17,7 +16,6 @@ export declare class StreamClient {
17
16
  private reconnectDelay;
18
17
  private readonly maxReconnectDelay;
19
18
  private reconnectTimer;
20
- private config?;
21
19
  private connectionId;
22
20
  private readonly tabId;
23
21
  private registrationWaiters;
@@ -27,15 +25,10 @@ export declare class StreamClient {
27
25
  removeCallbacks(callbacks: StreamClientCallbacks): void;
28
26
  isConnected(): boolean;
29
27
  waitUntilRegistered(): Promise<void>;
30
- connect(chatId: string, config?: {
31
- mtxId?: string;
32
- mtxKey?: string;
33
- mtxApp?: number;
34
- }): Promise<void>;
28
+ connect(chatId: string): Promise<void>;
35
29
  private consumeEvents;
36
30
  disconnect(): void;
37
31
  send(command: WidgetCommand): Promise<void>;
38
- private setStatus;
39
32
  private notifyError;
40
33
  private handleMessage;
41
34
  private scheduleReconnect;
@@ -1,2 +1,6 @@
1
+ import { type WidgetSettingsData } from '../sdk';
1
2
  import type { MarketrixConfig } from '../types';
3
+ export declare function createConfigFromSettings(widgetSettings: WidgetSettingsData, baseConfig?: Partial<MarketrixConfig>): MarketrixConfig;
4
+ /** Per-tenant scope for browser-local keys: the credential id, else the application id. */
5
+ export declare function tenantScope(config: MarketrixConfig): string;
2
6
  export declare function loadWidgetConfig(config: MarketrixConfig): Promise<MarketrixConfig>;
@@ -25,13 +25,13 @@ export interface ChatMessage {
25
25
  isSystemMessage?: boolean;
26
26
  isPlaceholder?: boolean;
27
27
  placeholderState?: 'thinking' | 'waiting-for-user';
28
- parts?: MessagePart[];
29
- taskStatus?: 'ongoing' | 'done' | 'failed' | 'stopped';
28
+ parts: MessagePart[];
29
+ taskStatus?: 'done' | 'failed' | 'stopped';
30
30
  }
31
31
  export interface MessagePart {
32
32
  type: 'text' | 'progress';
33
33
  content: string;
34
- status?: 'in_progress' | 'completed' | 'failed' | 'stopped';
34
+ status?: 'in_progress' | 'completed' | 'failed';
35
35
  browserToolName?: string;
36
36
  /** chat/delta fragments accumulate into this part; the final chat/response replaces it. */
37
37
  streaming?: boolean;
@@ -39,21 +39,14 @@ export interface MessagePart {
39
39
  export type WidgetView = 'home' | 'chat';
40
40
  export interface WidgetState {
41
41
  isOpen: boolean;
42
- isMinimized: boolean;
43
42
  isLoading: boolean;
44
43
  messages: ChatMessage[];
45
44
  currentMode: InstructionType;
46
- agentAvailable: boolean;
47
45
  error?: string;
48
46
  activeTaskId: string | null;
49
47
  isTaskRunning: boolean;
50
48
  activeView: WidgetView;
51
49
  }
52
- export interface MessageDispatchRequest {
53
- message?: string;
54
- mode?: InstructionType;
55
- requestId?: string;
56
- }
57
50
  export type WidgetPosition = WidgetSettingsData['widget_position'];
58
51
  export type AddWidgetConfig = ({
59
52
  settings: WidgetSettingsData;
@@ -1,20 +1,18 @@
1
1
  import { type Root } from 'react-dom/client';
2
2
  import type { MarketrixConfig } from '../types';
3
+ export declare const widgetState: {
4
+ instance: Root | null;
5
+ config: MarketrixConfig | null;
6
+ programmaticInit: boolean;
7
+ };
3
8
  export declare const createWidgetContainer: (parentContainer?: HTMLElement, containerId?: string) => {
4
9
  container: HTMLElement;
5
10
  shadowRoot: ShadowRoot;
6
11
  mountEl: HTMLElement;
7
12
  };
8
13
  export declare const mountWidgetToContainer: (mountEl: HTMLElement, config: MarketrixConfig, previewMode?: boolean) => Root;
9
- export declare const destroyWidgetContainer: (container: HTMLElement) => void;
10
- export declare const getWidgetInstance: () => Root | null;
11
- export declare const setWidgetInstance: (instance: Root | null) => void;
12
- export declare const getCurrentConfig: () => MarketrixConfig | null;
13
- export declare const setCurrentConfig: (config: MarketrixConfig | null) => void;
14
14
  export declare const isWidgetInitialized: () => boolean;
15
- export declare const clearWidgetState: () => void;
16
- export declare const setProgrammaticInitInProgress: (inProgress: boolean) => void;
17
- export declare const isProgrammaticInitInProgress: () => boolean;
15
+ export declare const getCurrentConfig: () => MarketrixConfig | null;
18
16
  export declare const showWidgetSettingsLoader: (message?: string) => void;
19
17
  export declare const hideWidgetSettingsLoader: () => void;
20
18
  export declare const autoInitializeWidget: () => void;
@@ -1,4 +1,6 @@
1
1
  import type { ChatMessage, InstructionType } from '../types';
2
+ export declare const getModeDisplayName: (mode: InstructionType) => string;
3
+ export declare const formatMessageTime: (date: Date | undefined) => string;
2
4
  export declare function removeThinkingMarkers(content: string): string;
3
5
  export declare function removeThinkingMarkerFromEnd(content: string): string;
4
6
  export declare function hasThinkingMarker(content: string): boolean;
@@ -9,11 +11,13 @@ export interface FindMessageOptions {
9
11
  currentMode: InstructionType;
10
12
  requireContent?: boolean;
11
13
  }
12
- export declare function findMessageForProgress(options: FindMessageOptions): {
14
+ /** Ranked predicates: the first rank matching anything wins, and within it the newest message. */
15
+ export declare function findMessageForProgress({ messages, isTaskRunning, currentMode, requireContent, }: FindMessageOptions): {
13
16
  index: number;
14
17
  message: ChatMessage;
15
18
  } | null;
16
19
  export declare const WAIT_FOR_USER_TOOLS: Set<string>;
20
+ export declare function filterCancellationText(content: string): string;
17
21
  export declare function addProgressLine(message: ChatMessage, browserToolName: string, explanation: string): ChatMessage;
18
22
  export declare function markProgressLineComplete(message: ChatMessage): ChatMessage;
19
23
  export declare function markProgressLineFailed(message: ChatMessage, browserToolName: string, error: string): ChatMessage;
@@ -6,5 +6,3 @@ export declare function hexToRgb(hex: string): {
6
6
  export declare function getContrastingColor(color: string): string;
7
7
  export declare function addOpacity(color: string, opacity: number): string;
8
8
  export declare function darkenColor(color: string, amount: number): string;
9
- export declare const formatMessageTime: (date: Date | undefined) => string;
10
- export declare const getModeDisplayName: (mode: "show" | "tell" | "do") => string;
@@ -1,10 +1,7 @@
1
- import React from 'react';
2
1
  import type { MarketrixConfig } from '../types';
3
2
  export interface SuggestedActionItem {
4
3
  id: string;
5
4
  text: string;
6
- icon: React.ReactElement;
7
5
  type: 'tell' | 'show' | 'do';
8
- isShow: boolean;
9
6
  }
10
7
  export declare function getSuggestedActionsFromConfig(config: MarketrixConfig): SuggestedActionItem[];
@@ -1,5 +1,23 @@
1
1
  import type React from 'react';
2
2
  import type { WidgetPosition } from '../types';
3
+ export declare const getCorner: (position: WidgetPosition) => {
4
+ readonly classes: "bottom-5 right-5";
5
+ readonly vertical: "bottom";
6
+ readonly horizontal: "right";
7
+ } | {
8
+ readonly classes: "bottom-5 left-5";
9
+ readonly vertical: "bottom";
10
+ readonly horizontal: "left";
11
+ } | {
12
+ readonly classes: "top-5 right-5";
13
+ readonly vertical: "top";
14
+ readonly horizontal: "right";
15
+ } | {
16
+ readonly classes: "top-5 left-5";
17
+ readonly vertical: "top";
18
+ readonly horizontal: "left";
19
+ };
20
+ export declare const isWidgetPosition: (value: unknown) => value is WidgetPosition;
3
21
  export declare const getPositionClasses: (position: WidgetPosition) => string;
4
22
  export declare const getPanelPositionStyle: (position: WidgetPosition) => React.CSSProperties;
5
23
  export declare const getAnchorTopLeft: (position: WidgetPosition, vw: number, vh: number, w: number, h: number) => {