@marketrix.ai/widget 3.8.40 → 3.8.117

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 (34) hide show
  1. package/dist/src/components/base/Dialog.d.ts +4 -6
  2. package/dist/src/components/base/icons.d.ts +0 -267
  3. package/dist/src/components/blocks/WidgetDialog.d.ts +0 -12
  4. package/dist/src/components/navigation/MessengerShell.d.ts +1 -2
  5. package/dist/src/components/views/ChatView.d.ts +1 -2
  6. package/dist/src/context/ConversationContext.d.ts +56 -0
  7. package/dist/src/context/WidgetProviders.d.ts +8 -6
  8. package/dist/src/context/sseReducer.d.ts +3 -3
  9. package/dist/src/hooks/useWidget.d.ts +2 -5
  10. package/dist/src/index.d.ts +0 -4
  11. package/dist/src/services/ApiService.d.ts +0 -6
  12. package/dist/src/services/ChatService.d.ts +1 -2
  13. package/dist/src/services/DomService.d.ts +0 -62
  14. package/dist/src/services/ScreenShareService.d.ts +0 -7
  15. package/dist/src/services/SessionManager.d.ts +0 -6
  16. package/dist/src/services/SessionRecorder.d.ts +0 -15
  17. package/dist/src/services/StorageService.d.ts +3 -25
  18. package/dist/src/services/ValidationService.d.ts +0 -7
  19. package/dist/src/types/browserTools.d.ts +2 -2
  20. package/dist/src/types/index.d.ts +0 -16
  21. package/dist/src/utils/apiUtils.d.ts +0 -3
  22. package/dist/src/utils/bootstrap.d.ts +0 -44
  23. package/dist/src/utils/chat.d.ts +0 -24
  24. package/dist/src/utils/{format.d.ts → color.d.ts} +0 -9
  25. package/dist/src/utils/dom.d.ts +0 -7
  26. package/dist/src/utils/{common.d.ts → logger.d.ts} +0 -3
  27. package/dist/src/utils/validation.d.ts +0 -13
  28. package/dist/widget.mjs +62 -65
  29. package/dist/widget.mjs.map +1 -1
  30. package/package.json +10 -10
  31. package/dist/src/components/blocks/TabBar.d.ts +0 -12
  32. package/dist/src/constants/config.d.ts +0 -7
  33. package/dist/src/context/ChatContext.d.ts +0 -33
  34. package/dist/src/context/TaskContext.d.ts +0 -38
@@ -1,6 +1,3 @@
1
- /**
2
- * Fingerprint of an indexed element for validation
3
- */
4
1
  export interface ElementFingerprint {
5
2
  tagName: string;
6
3
  id: string | null;
@@ -13,23 +10,14 @@ export interface ElementFingerprint {
13
10
  selector: string;
14
11
  indexVersion: number;
15
12
  }
16
- /**
17
- * Result of validating an element at a given index
18
- */
19
13
  export interface ValidationResult {
20
14
  isValid: boolean;
21
15
  mismatchReason?: 'element_removed' | 'element_changed';
22
16
  }
23
- /**
24
- * Result of looking up an element by index
25
- */
26
17
  export interface ElementLookupResult {
27
18
  element: HTMLElement | null;
28
19
  error?: string;
29
20
  }
30
- /**
31
- * Result of validated element lookup (includes validation info)
32
- */
33
21
  export interface ValidatedElementResult extends ElementLookupResult {
34
22
  validation: ValidationResult;
35
23
  }
@@ -39,18 +27,11 @@ export declare class DomService {
39
27
  private elementToSequence;
40
28
  private selectorMap;
41
29
  private fingerprintMap;
42
- private isIndexed;
43
30
  private indexingInProgress;
44
31
  private indexVersion;
45
32
  private constructor();
46
33
  static getInstance(): DomService;
47
- /**
48
- * Generate a unique CSS selector for an element
49
- */
50
34
  private generateSelector;
51
- /**
52
- * Generate a fingerprint for an element to enable validation later
53
- */
54
35
  private generateFingerprint;
55
36
  /**
56
37
  * Check if an element matches a stored fingerprint.
@@ -62,48 +43,19 @@ export declare class DomService {
62
43
  * No recovery - just check if element exists and matches.
63
44
  */
64
45
  private validateElementAtIndex;
65
- /**
66
- * Export state for external persistence (selectors and fingerprints)
67
- */
68
- exportState(): {
69
- selectors: Array<[number, string]>;
70
- fingerprints: Array<[number, ElementFingerprint]>;
71
- };
72
- /**
73
- * Import state from external persistence (selectors and fingerprints)
74
- */
75
- importState(state: {
76
- selectors?: Array<[number, string]>;
77
- fingerprints?: Array<[number, ElementFingerprint]>;
78
- }): void;
79
46
  /**
80
47
  * Index all interactable elements in the live DOM.
81
48
  * Always clears previous index first.
82
49
  */
83
50
  indexInteractableElements(): Array<[number, Element]>;
84
- /**
85
- * Get element coordinates using getBoundingClientRect()
86
- * Returns viewport-relative coordinates
87
- */
88
51
  private getElementCoordinates;
89
- /**
90
- * Check if an element creates a stacking context
91
- * Based on CSS stacking context rules
92
- */
93
52
  private isStackingContext;
94
- /**
95
- * Calculate global z-order for an element
96
- * Traverses up the DOM tree to identify stacking contexts and calculate z-order
97
- */
98
53
  private calculateGlobalZOrder;
99
54
  /**
100
55
  * Get HTML snapshot with data-id attributes injected.
101
56
  * This re-indexes the live DOM and then produces a corresponding HTML string.
102
57
  */
103
58
  getSnapshotHtml(): string;
104
- /**
105
- * Get actionable elements metadata
106
- */
107
59
  getInteractableElements(): Array<{
108
60
  index: number;
109
61
  fingerprint: ElementFingerprint;
@@ -116,9 +68,7 @@ export declare class DomService {
116
68
  };
117
69
  cssClasses: string[];
118
70
  }>;
119
- getElementByDataId(id: number): Element | undefined;
120
71
  getSequenceForElement(element: Element): number | undefined;
121
- isIndexActive(): boolean;
122
72
  clearIndex(): void;
123
73
  /**
124
74
  * Check if an element is interactable (visible, not hidden, not obscured).
@@ -141,17 +91,5 @@ export declare class DomService {
141
91
  * Returns element only if it's interactable.
142
92
  */
143
93
  getValidatedElement(index: number): ValidatedElementResult;
144
- /**
145
- * Get fingerprint for a given index (for debugging/testing)
146
- */
147
- getFingerprint(index: number): ElementFingerprint | undefined;
148
- /**
149
- * Get all fingerprints (for debugging/testing)
150
- */
151
- getAllFingerprints(): Array<[number, ElementFingerprint]>;
152
- /**
153
- * Get current index version
154
- */
155
- getIndexVersion(): number;
156
94
  }
157
95
  export declare const domService: DomService;
@@ -8,12 +8,5 @@
8
8
  * @returns Promise resolving to the MediaStream
9
9
  */
10
10
  export declare function startScreenShare(): Promise<MediaStream>;
11
- /**
12
- * Stop screen sharing and clear the stream reference.
13
- */
14
11
  export declare function stopScreenShare(): void;
15
- /**
16
- * Check if screensharing is currently active.
17
- * @returns True if screensharing is active, false otherwise
18
- */
19
12
  export declare function isScreenSharing(): boolean;
@@ -9,13 +9,7 @@ declare class SessionManager {
9
9
  private chatId;
10
10
  private initializationPromise;
11
11
  private constructor();
12
- /**
13
- * Get singleton instance
14
- */
15
12
  static getInstance(): SessionManager;
16
- /**
17
- * Get current chat ID without creating a new one
18
- */
19
13
  getChatId(): string | null;
20
14
  /**
21
15
  * Get or create chat ID with promise-based locking
@@ -17,13 +17,7 @@ export declare class SessionRecorder {
17
17
  private consecutiveFailures;
18
18
  private isFlushing;
19
19
  constructor(chatId: string, applicationId: number);
20
- /**
21
- * Send rrweb/metadata command via POST
22
- */
23
20
  private sendMetadata;
24
- /**
25
- * Buffer an event and trigger flush if thresholds are met
26
- */
27
21
  private bufferEvent;
28
22
  /**
29
23
  * Flush buffered events via POST.
@@ -44,16 +38,7 @@ export declare class SessionRecorder {
44
38
  * Internal start implementation. Checks stopRequested at each async boundary.
45
39
  */
46
40
  private doStart;
47
- /**
48
- * Stop recording session. Flushes remaining events before stopping.
49
- */
50
41
  stop(): void;
51
- /**
52
- * Get current session ID
53
- */
54
42
  getSessionId(): string;
55
- /**
56
- * Check if recording is active
57
- */
58
43
  isActive(): boolean;
59
44
  }
@@ -15,22 +15,18 @@
15
15
  * widget owns the read/write lifecycle, and the dashboard only ever reads
16
16
  * the same shape for parity.
17
17
  */
18
- import type { ChatMessage, InstructionType, MarketrixConfig, TaskProgress } from '../types';
18
+ import type { ChatMessage, InstructionType, MarketrixConfig } from '../types';
19
19
  /**
20
20
  * Serializable version of ChatMessage (timestamp as string, no videoStream)
21
21
  */
22
22
  type StoredMessage = Omit<ChatMessage, 'videoStream' | 'timestamp'> & {
23
23
  timestamp: string;
24
24
  };
25
- /**
26
- * Unified storage structure for all widget data
27
- */
28
25
  export interface MarketrixChatContext {
29
26
  chat_id: string | null;
30
27
  messages: StoredMessage[];
31
28
  isTaskRunning: boolean;
32
29
  activeTaskId: string | null;
33
- taskProgress: TaskProgress[];
34
30
  currentMode: InstructionType;
35
31
  isOpen: boolean;
36
32
  isMinimized: boolean;
@@ -49,25 +45,10 @@ declare class StorageService {
49
45
  private context;
50
46
  private constructor();
51
47
  static getInstance(): StorageService;
52
- /**
53
- * Load context from localStorage
54
- */
55
48
  private loadContext;
56
- /**
57
- * Save context to localStorage
58
- */
59
49
  private saveContext;
60
- /**
61
- * Get the full context
62
- */
63
50
  getContext(): MarketrixChatContext;
64
- /**
65
- * Update context with partial data
66
- */
67
51
  updateContext(updates: Partial<MarketrixChatContext>): void;
68
- /**
69
- * Check if a string is a valid chat_id
70
- */
71
52
  private isValidChatId;
72
53
  /**
73
54
  * Get chat_id with window.name fallback for cross-page navigation
@@ -81,14 +62,11 @@ declare class StorageService {
81
62
  setChatId(chatId: string | null): void;
82
63
  getMessages(): StoredMessage[];
83
64
  setMessages(messages: StoredMessage[]): void;
84
- getChatState(): Pick<MarketrixChatContext, 'isTaskRunning' | 'activeTaskId' | 'taskProgress' | 'currentMode' | 'isOpen' | 'isMinimized' | 'isLoading'>;
85
- setChatState(state: Partial<Pick<MarketrixChatContext, 'isTaskRunning' | 'activeTaskId' | 'taskProgress' | 'currentMode' | 'isOpen' | 'isMinimized' | 'isLoading'>>): void;
65
+ getChatState(): Pick<MarketrixChatContext, 'isTaskRunning' | 'activeTaskId' | 'currentMode' | 'isOpen' | 'isMinimized' | 'isLoading'>;
66
+ setChatState(state: Partial<Pick<MarketrixChatContext, 'isTaskRunning' | 'activeTaskId' | 'currentMode' | 'isOpen' | 'isMinimized' | 'isLoading'>>): void;
86
67
  getConfig(): MarketrixConfig | null;
87
68
  setConfig(config: MarketrixConfig | null): void;
88
69
  clear(): void;
89
- /**
90
- * Check if context exists and has a valid chat_id
91
- */
92
70
  hasValidContext(): boolean;
93
71
  }
94
72
  export declare const storageService: StorageService;
@@ -20,13 +20,6 @@ export declare class ValidationService {
20
20
  * Handles both mtxId+mtxKey and mtxApp cases
21
21
  */
22
22
  validateConfig(config: MarketrixConfig): Promise<WidgetValidationResult>;
23
- /**
24
- * Validate by mtxId and mtxKey
25
- */
26
23
  private validateByMarketrixId;
27
- /**
28
- * Validate by mtxApp directly
29
- * Validates the application by ID
30
- */
31
24
  private validateByApplication;
32
25
  }
@@ -2,8 +2,8 @@
2
2
  * Browser Use Tools - widget tool registry.
3
3
  *
4
4
  * IMPORTANT: This file is the single source of truth for widget tool metadata.
5
- * ALLOWED_TOOLS in TaskContext.tsx and TOOL_NAME_MAPPING in chat.ts are derived
6
- * from BROWSER_TOOLS below.
5
+ * ALLOWED_TOOLS in ConversationContext.tsx and TOOL_NAME_MAPPING in chat.ts are
6
+ * derived from BROWSER_TOOLS below.
7
7
  */
8
8
  interface BrowserToolMetadata {
9
9
  id: string;
@@ -56,14 +56,6 @@ export interface MessagePart {
56
56
  hideIcon?: boolean;
57
57
  textStyle?: 'default' | 'muted';
58
58
  }
59
- export interface TaskProgress {
60
- tool_name: string;
61
- tool_params: Record<string, unknown>;
62
- step: number;
63
- explanation: string;
64
- mode: string;
65
- timestamp: number;
66
- }
67
59
  export type WidgetView = 'home' | 'chat';
68
60
  export interface WidgetState {
69
61
  isOpen: boolean;
@@ -75,7 +67,6 @@ export interface WidgetState {
75
67
  error?: string;
76
68
  activeTaskId: string | null;
77
69
  isTaskRunning: boolean;
78
- taskProgress: TaskProgress[];
79
70
  activeView: WidgetView;
80
71
  }
81
72
  export interface SendMessageRequest {
@@ -95,10 +86,6 @@ export interface SendMessageResponse {
95
86
  task_id?: string;
96
87
  }
97
88
  export type WidgetPosition = WidgetSettingsData['widget_position'];
98
- /**
99
- * Configuration for addWidget function
100
- * Supports preview, production, and dev modes
101
- */
102
89
  export type AddWidgetConfig = ({
103
90
  settings: WidgetSettingsData;
104
91
  mtxId?: never;
@@ -128,9 +115,6 @@ export type AddWidgetConfig = ({
128
115
  /** Controls screen sharing prompts and button. When false, screen access requests are auto-denied and Share Screen button is hidden. Default: true */
129
116
  use_screenshare?: boolean;
130
117
  };
131
- /**
132
- * Props for MarketrixWidget React component
133
- */
134
118
  export interface MarketrixWidgetProps {
135
119
  settings: WidgetSettingsData;
136
120
  container?: HTMLElement;
@@ -5,9 +5,6 @@ import type { MarketrixConfig } from '../types';
5
5
  * Consolidates error instanceof Error ? error.message : String(error)
6
6
  */
7
7
  export declare function extractErrorMessage(error: unknown, fallback?: string): string;
8
- /**
9
- * Handle API error with consistent error message extraction
10
- */
11
8
  export declare function handleApiError(error: unknown, context?: string, config?: Partial<MarketrixConfig>): {
12
9
  isValid: false;
13
10
  error: string;
@@ -25,60 +25,16 @@ export declare const createWidgetContainer: (parentContainer?: HTMLElement, cont
25
25
  * @param previewMode - If true, disables network operations (for integration previews)
26
26
  */
27
27
  export declare const mountWidgetToContainer: (mountEl: HTMLElement, config: MarketrixConfig, previewMode?: boolean) => Root;
28
- /**
29
- * Destroy widget container
30
- * @param container - Container to destroy
31
- */
32
28
  export declare const destroyWidgetContainer: (container: HTMLElement) => void;
33
- /**
34
- * Get current widget instance
35
- */
36
29
  export declare const getWidgetInstance: () => Root | null;
37
- /**
38
- * Set widget instance
39
- */
40
30
  export declare const setWidgetInstance: (instance: Root | null) => void;
41
- /**
42
- * Get current configuration
43
- */
44
31
  export declare const getCurrentConfig: () => MarketrixConfig | null;
45
- /**
46
- * Set current configuration
47
- */
48
32
  export declare const setCurrentConfig: (config: MarketrixConfig | null) => void;
49
- /**
50
- * Check if widget is initialized
51
- */
52
33
  export declare const isWidgetInitialized: () => boolean;
53
- /**
54
- * Clear widget instance and config
55
- */
56
34
  export declare const clearWidgetState: () => void;
57
- /**
58
- * Set programmatic initialization in progress flag
59
- */
60
35
  export declare const setProgrammaticInitInProgress: (inProgress: boolean) => void;
61
- /**
62
- * Check if programmatic initialization is in progress
63
- */
64
36
  export declare const isProgrammaticInitInProgress: () => boolean;
65
- /**
66
- * Check if a production widget is already active on this page
67
- * Production widgets (non-preview) should be singletons - only one per page
68
- */
69
- export declare const isProductionWidgetActive: () => boolean;
70
- /**
71
- * Set production widget active state
72
- * Call with true when initializing a production widget, false when unmounting
73
- */
74
- export declare const setProductionWidgetActive: (active: boolean) => void;
75
- /**
76
- * Show widget settings loader with optional message
77
- */
78
37
  export declare const showWidgetSettingsLoader: (message?: string) => void;
79
- /**
80
- * Hide widget settings loader
81
- */
82
38
  export declare const hideWidgetSettingsLoader: () => void;
83
39
  /**
84
40
  * Auto-initialize widget from script tag attributes
@@ -5,21 +5,9 @@
5
5
  * - Removing thinking markers
6
6
  */
7
7
  import type { ChatMessage, InstructionType } from '../types';
8
- /**
9
- * Remove all __THINKING__ markers from message content
10
- */
11
8
  export declare function removeThinkingMarkers(content: string): string;
12
- /**
13
- * Remove thinking marker from end of content (for display)
14
- */
15
9
  export declare function removeThinkingMarkerFromEnd(content: string): string;
16
- /**
17
- * Check if content has thinking marker
18
- */
19
10
  export declare function hasThinkingMarker(content: string): boolean;
20
- /**
21
- * Add thinking marker to content
22
- */
23
11
  export declare function addThinkingMarker(content: string): string;
24
12
  /**
25
13
  * Message Finder Utility
@@ -56,21 +44,9 @@ export declare function findMessageForProgress(options: FindMessageOptions): {
56
44
  * Also the set that requires element highlighting in ToolService.
57
45
  */
58
46
  export declare const WAIT_FOR_USER_TOOLS: Set<string>;
59
- /**
60
- * Add a new progress step to a message
61
- */
62
47
  export declare function addProgressLine(message: ChatMessage, toolName: string, explanation: string): ChatMessage;
63
- /**
64
- * Mark the last incomplete progress step as completed
65
- */
66
48
  export declare function markProgressLineComplete(message: ChatMessage, toolName?: string): ChatMessage;
67
- /**
68
- * Mark the last incomplete progress step as failed
69
- */
70
49
  export declare function markProgressLineFailed(message: ChatMessage, toolName: string, error: string): ChatMessage;
71
- /**
72
- * Add or remove thinking marker based on task state
73
- */
74
50
  export declare function updateThinkingMarker(message: ChatMessage, isTaskRunning: boolean, currentMode: 'show' | 'tell' | 'do', isWaitingForUser?: boolean): ChatMessage;
75
51
  /**
76
52
  * Tool Name Mapping — derived from BROWSER_TOOLS (single source of truth).
@@ -1,26 +1,17 @@
1
1
  /**
2
2
  * Color utility functions for widget theming
3
3
  */
4
- /**
5
- * Converts hex color to RGB
6
- */
7
4
  export declare function hexToRgb(hex: string): {
8
5
  r: number;
9
6
  g: number;
10
7
  b: number;
11
8
  } | null;
12
- /**
13
- * Gets a contrasting color (white or black) based on the background color
14
- */
15
9
  export declare function getContrastingColor(color: string): string;
16
10
  /**
17
11
  * Adds opacity to a color
18
12
  * Supports hex colors (with or without #) and rgb/rgba strings
19
13
  */
20
14
  export declare function addOpacity(color: string, opacity: number): string;
21
- /**
22
- * Darkens a color by a specified amount (0-1)
23
- */
24
15
  export declare function darkenColor(color: string, amount: number): string;
25
16
  export declare const formatMessageTime: (date: Date | undefined) => string;
26
17
  export declare const getModeDisplayName: (mode: "show" | "tell" | "do") => string;
@@ -4,11 +4,4 @@
4
4
  * Centralized utilities for common DOM operations to reduce code duplication
5
5
  * and ensure consistent error handling.
6
6
  */
7
- /**
8
- * Get an interactive element by its index.
9
- * First tries to use data-id from get_html indexing, then falls back to current behavior.
10
- * @param index The zero-based index of the element
11
- * @returns The element at the given index, or null if not found
12
- */
13
- export declare function getElementByIndex(index: number): HTMLElement | null;
14
7
  export declare function isInteractable(el: Element | null): boolean;
@@ -4,9 +4,6 @@
4
4
  * Centralized logging utility with log levels and environment-based filtering.
5
5
  * Only logs in development mode to reduce noise in production.
6
6
  */
7
- /**
8
- * Create a scoped logger with a fixed prefix
9
- */
10
7
  export declare function createLogger(prefix: string): {
11
8
  debug: (message: string, ...args: unknown[]) => void;
12
9
  info: (message: string, ...args: unknown[]) => void;
@@ -5,19 +5,6 @@
5
5
  * These are shared utilities used across the codebase.
6
6
  */
7
7
  import type { WidgetSettingsData } from '../sdk';
8
- /**
9
- * Check if an object has a specific property
10
- */
11
- export declare function hasProperty<K extends string>(obj: unknown, key: K): obj is Record<K, unknown>;
12
- /**
13
- * Type guard for WidgetSettingsData
14
- */
15
8
  export declare function isWidgetSettingsData(data: unknown): data is WidgetSettingsData;
16
- /**
17
- * Type guard for HTMLElement
18
- */
19
9
  export declare function isHTMLElement(element: Element | null): element is HTMLElement;
20
- /**
21
- * Type guard for HTMLScriptElement
22
- */
23
10
  export declare function isHTMLScriptElement(element: Element | null): element is HTMLScriptElement;