@marketrix.ai/widget 3.8.455 → 3.8.456

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.
@@ -1,7 +1,5 @@
1
1
  export type ResizeCorner = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
2
2
  export declare function useResize(settingsWidth: string | undefined, settingsHeight: string | undefined, workspaceId: string, isMinimized: boolean, isPreviewMode: boolean): {
3
- width: number;
4
- height: number;
5
3
  widthPx: string;
6
4
  heightPx: string;
7
5
  onResizeStart: (corner: ResizeCorner) => (e: React.MouseEvent) => void;
@@ -1,32 +1,33 @@
1
- import type { ChatMessage, InstructionType, MarketrixConfig, WidgetSettingsData, WidgetState, WidgetView } from '../types';
1
+ import type { MarketrixConfig, WidgetSettingsData, WidgetState } from '../types';
2
2
  export type ValidWidgetConfig = MarketrixConfig & Required<Pick<MarketrixConfig, keyof WidgetSettingsData>>;
3
3
  interface UseWidgetProps {
4
4
  config?: MarketrixConfig;
5
5
  }
6
- interface UseWidgetActions {
7
- setActiveView: (view: WidgetView) => void;
8
- toggleWidget: () => void;
9
- closeWidget: () => void;
10
- setMode: (mode: InstructionType) => void;
11
- setLoading: (loading: boolean) => void;
12
- setAgentAvailable: (available: boolean) => void;
13
- setError: (error: string | undefined) => void;
14
- clearError: () => void;
15
- setTaskState: (payload: {
16
- activeTaskId: string | null;
17
- isTaskRunning: boolean;
18
- }) => void;
19
- addMessage: (message: ChatMessage) => void;
20
- updateMessage: (messageId: string, updates: Partial<ChatMessage>) => void;
21
- removeMessage: (messageId: string) => void;
22
- setMessages: (messages: ChatMessage[]) => void;
23
- stopTask: () => Promise<void>;
24
- clearChatHistory: () => void;
25
- messageDispatch: (content: string, mode?: InstructionType, skipUserMessage?: boolean) => Promise<void>;
26
- }
27
6
  export declare const useWidget: ({ config }?: UseWidgetProps) => {
28
7
  state: WidgetState;
29
- actions: UseWidgetActions;
8
+ actions: {
9
+ clearChatHistory: () => void;
10
+ addMessage: (message: import("..").ChatMessage) => void;
11
+ updateMessage: (messageId: string, updates: Partial<import("..").ChatMessage>) => void;
12
+ removeMessage: (messageId: string) => void;
13
+ setMessages: (messages: import("..").ChatMessage[]) => void;
14
+ clearMessages: () => void;
15
+ messageDispatch: (content: string, mode?: import("..").InstructionType, skipUserMessage?: boolean) => Promise<void>;
16
+ setTaskState: (payload: {
17
+ activeTaskId: string | null;
18
+ isTaskRunning: boolean;
19
+ }) => void;
20
+ stopTask: () => Promise<void>;
21
+ setActiveView: (view: import("../types").WidgetView) => void;
22
+ toggleWidget: () => void;
23
+ closeWidget: () => void;
24
+ setMode: (mode: import("..").InstructionType) => void;
25
+ setLoading: (loading: boolean) => void;
26
+ setAgentAvailable: (available: boolean) => void;
27
+ setError: (error: string | undefined) => void;
28
+ clearError: () => void;
29
+ applyState: (payload: Partial<import("../context/UIStateContext").UIState>) => void;
30
+ };
30
31
  config: ValidWidgetConfig;
31
32
  shouldShow: boolean;
32
33
  isPreviewMode: boolean;
@@ -1,4 +1,3 @@
1
1
  import type { MarketrixConfig, MessageDispatchRequest } from '../types';
2
- export declare function getChatId(): string | null;
3
2
  /** Fire-and-forget send over the typed stream; the reply arrives asynchronously as a chat/response event. */
4
3
  export declare function messageDispatch(config: MarketrixConfig, request: MessageDispatchRequest): Promise<void>;
@@ -74,7 +74,6 @@ export interface ExtractParams {
74
74
  }
75
75
  export declare class BrowserToolService {
76
76
  executeTool(browserToolName: string, args: Record<string, unknown>, mode?: string, explanation?: string): Promise<ToolExecutionResult<unknown>>;
77
- private requiresHighlight;
78
77
  private navigate;
79
78
  private search;
80
79
  private clickElement;
@@ -1,19 +1,7 @@
1
1
  import type { ChatMessage, InstructionType } from '../types';
2
- export interface ChatSnapshot {
3
- messages: ChatMessage[];
4
- isTaskRunning: boolean;
5
- activeTaskId: string | null;
6
- currentMode: InstructionType;
7
- isOpen: boolean;
8
- isMinimized: boolean;
9
- isLoading: boolean;
10
- }
2
+ import { type ChatSnapshot } from './StorageService';
11
3
  export declare class ChatService {
12
- private chatId;
13
- initError: Error | null;
14
- initialize(chatId: string | null): void;
15
- createInitialContext(chatId: string): void;
16
- getInitError(): Error | null;
4
+ private restored;
17
5
  restore(): ChatSnapshot;
18
6
  persist(snapshot: ChatSnapshot): void;
19
7
  }
@@ -1,13 +1,8 @@
1
1
  declare class ChatSessionManager {
2
- private chatId;
3
- private initializationPromise;
4
- constructor();
5
- getChatId(): string | null;
6
- /** Promise-based lock: concurrent callers all await the same creation promise. */
2
+ private creation;
3
+ /** Promise-based lock: concurrent callers all await the same creation. */
7
4
  getOrCreateChatId(): Promise<string>;
8
5
  private createChatId;
9
- private getStoredChatId;
10
- private storeChatId;
11
6
  }
12
7
  export declare const chatSessionManager: ChatSessionManager;
13
8
  export {};
@@ -25,14 +25,13 @@ export declare class DomService {
25
25
  private generateFingerprint;
26
26
  private matchesFingerprint;
27
27
  private validateElementAtIndex;
28
- indexInteractableElements(): Array<[number, Element]>;
28
+ private indexInteractableElements;
29
29
  private getElementCoordinates;
30
30
  private isStackingContext;
31
31
  private calculateGlobalZOrder;
32
32
  getSnapshotHtml(): string;
33
33
  getSequenceForElement(element: Element): number | undefined;
34
- clearIndex(): void;
35
- private checkInteractability;
34
+ private clearIndex;
36
35
  checkElementInteractable(element: HTMLElement, index: number): string | null;
37
36
  getValidatedElement(index: number): ValidatedElementResult;
38
37
  }
@@ -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,32 @@
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
12
  isMinimized: boolean;
13
13
  isLoading: boolean;
14
+ }
15
+ export type MarketrixChatContext = Omit<ChatSnapshot, 'messages'> & {
16
+ chat_id: string | null;
17
+ messages: StoredMessage[];
14
18
  config: MarketrixConfig | null;
15
19
  timestamp: number;
16
- }
20
+ };
17
21
  declare class StorageService {
18
22
  private context;
19
- constructor();
20
- private loadContext;
21
- private saveContext;
22
23
  getContext(): MarketrixChatContext;
23
24
  updateContext(updates: Partial<MarketrixChatContext>): void;
24
- private isValidChatId;
25
- /** window.name takes priority over localStorage — it persists across page navigations. */
25
+ /** window.name takes priority over localStorage — it is what survives host-page navigation. */
26
26
  getChatId(): string | null;
27
- setChatId(chatId: string | null): void;
27
+ setChatId(chatId: string): void;
28
28
  getConfig(): MarketrixConfig | null;
29
- setConfig(config: MarketrixConfig | null): void;
30
- hasValidContext(): boolean;
29
+ setConfig(config: MarketrixConfig): void;
31
30
  }
32
31
  export declare const storageService: StorageService;
33
32
  export {};
@@ -17,7 +17,6 @@ export declare class StreamClient {
17
17
  private reconnectDelay;
18
18
  private readonly maxReconnectDelay;
19
19
  private reconnectTimer;
20
- private config?;
21
20
  private connectionId;
22
21
  private readonly tabId;
23
22
  private registrationWaiters;
@@ -27,11 +26,7 @@ export declare class StreamClient {
27
26
  removeCallbacks(callbacks: StreamClientCallbacks): void;
28
27
  isConnected(): boolean;
29
28
  waitUntilRegistered(): Promise<void>;
30
- connect(chatId: string, config?: {
31
- mtxId?: string;
32
- mtxKey?: string;
33
- mtxApp?: number;
34
- }): Promise<void>;
29
+ connect(chatId: string): Promise<void>;
35
30
  private consumeEvents;
36
31
  disconnect(): void;
37
32
  send(command: WidgetCommand): Promise<void>;
@@ -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>;
@@ -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;
@@ -9,7 +9,8 @@ export interface FindMessageOptions {
9
9
  currentMode: InstructionType;
10
10
  requireContent?: boolean;
11
11
  }
12
- export declare function findMessageForProgress(options: FindMessageOptions): {
12
+ /** Ranked predicates: the first rank matching anything wins, and within it the newest message. */
13
+ export declare function findMessageForProgress({ messages, isTaskRunning, currentMode, requireContent, }: FindMessageOptions): {
13
14
  index: number;
14
15
  message: ChatMessage;
15
16
  } | null;
@@ -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) => {