@marketrix.ai/widget 3.8.457 → 3.8.458
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/src/components/base/IconButton.d.ts +1 -1
- package/dist/src/components/base/Text.d.ts +1 -3
- package/dist/src/components/base/layoutProps.d.ts +0 -11
- package/dist/src/context/ChatContext.d.ts +0 -3
- package/dist/src/context/UIStateContext.d.ts +0 -1
- package/dist/src/context/sseReducer.d.ts +2 -0
- package/dist/src/design-system/semantic-tokens.d.ts +2 -7
- package/dist/src/hooks/useWidget.d.ts +0 -1
- package/dist/src/services/BrowserToolService.d.ts +0 -4
- package/dist/src/services/DomService.d.ts +1 -3
- package/dist/src/services/ShowModeService.d.ts +1 -2
- package/dist/src/services/StorageService.d.ts +2 -2
- package/dist/src/utils/bootstrap.d.ts +1 -2
- package/dist/src/utils/chat.d.ts +2 -8
- package/dist/src/utils/suggestedActions.d.ts +2 -2
- package/dist/widget.mjs +62 -63
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef } from 'react';
|
|
2
2
|
import { type TextTone } from '../../design-system/component-tokens';
|
|
3
3
|
import type { ShadowToken } from '../../design-system/shadows';
|
|
4
|
-
type IconButtonVariant = 'primary' | 'secondary' | 'ghost'
|
|
4
|
+
type IconButtonVariant = 'primary' | 'secondary' | 'ghost';
|
|
5
5
|
type IconButtonSize = 'xs' | 'sm';
|
|
6
6
|
type IconButtonShape = 'circle' | 'theme';
|
|
7
7
|
export interface IconButtonProps extends ComponentPropsWithRef<'button'> {
|
|
@@ -7,8 +7,6 @@ type TextAlign = 'center' | 'right';
|
|
|
7
7
|
export interface TextProps extends React.HTMLAttributes<HTMLElement> {
|
|
8
8
|
as?: ElementType;
|
|
9
9
|
block?: boolean;
|
|
10
|
-
clamp?: 1 | 2 | 3;
|
|
11
|
-
code?: boolean;
|
|
12
10
|
inheritColor?: boolean;
|
|
13
11
|
italic?: boolean;
|
|
14
12
|
leading?: TextLeading;
|
|
@@ -22,5 +20,5 @@ export interface TextProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
22
20
|
className?: string;
|
|
23
21
|
ref?: Ref<HTMLElement>;
|
|
24
22
|
}
|
|
25
|
-
export declare function Text({ as: Component, block,
|
|
23
|
+
export declare function Text({ as: Component, block, inheritColor, italic, leading, tone, variant, size, weight, truncate, align, className, ref, style, ...props }: TextProps): import("react").JSX.Element;
|
|
26
24
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CSSProperties, ElementType } from 'react';
|
|
2
|
-
import type { ShadowToken } from '../../design-system/shadows';
|
|
3
2
|
export type SpacingToken = 'none' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
4
3
|
export interface LayoutProps {
|
|
5
4
|
padding?: SpacingToken;
|
|
@@ -7,15 +6,9 @@ export interface LayoutProps {
|
|
|
7
6
|
paddingY?: SpacingToken;
|
|
8
7
|
paddingTop?: SpacingToken;
|
|
9
8
|
paddingBottom?: SpacingToken;
|
|
10
|
-
margin?: SpacingToken;
|
|
11
|
-
marginX?: SpacingToken;
|
|
12
|
-
marginY?: SpacingToken;
|
|
13
|
-
marginTop?: SpacingToken;
|
|
14
|
-
marginBottom?: SpacingToken;
|
|
15
9
|
gap?: SpacingToken;
|
|
16
10
|
align?: 'start' | 'center' | 'end' | 'stretch' | 'baseline';
|
|
17
11
|
justify?: 'start' | 'center' | 'end' | 'between' | 'around';
|
|
18
|
-
wrap?: boolean;
|
|
19
12
|
grow?: boolean;
|
|
20
13
|
shrink?: boolean;
|
|
21
14
|
position?: 'relative' | 'absolute' | 'fixed' | 'sticky';
|
|
@@ -25,12 +18,8 @@ export interface LayoutProps {
|
|
|
25
18
|
width?: 'full' | 'auto';
|
|
26
19
|
height?: 'full' | 'auto';
|
|
27
20
|
minWidth?: '0';
|
|
28
|
-
minHeight?: '0';
|
|
29
21
|
border?: boolean | 'top' | 'bottom' | 'left' | 'right';
|
|
30
22
|
rounded?: boolean | 'none' | 'sm' | 'full' | 'lg' | 'theme' | 'md' | 'xl' | 'pill' | 'circle';
|
|
31
|
-
shadow?: boolean | ShadowToken | 'theme';
|
|
32
|
-
cursor?: 'pointer' | 'default' | 'not-allowed' | 'grab';
|
|
33
|
-
opacity?: 0 | 50 | 80 | 100;
|
|
34
23
|
animate?: 'spin' | 'ping' | 'pulse' | 'fadeIn' | 'none';
|
|
35
24
|
hidden?: boolean;
|
|
36
25
|
as?: ElementType;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ChatMessage, InstructionType } from '../types';
|
|
3
3
|
import { type TaskState } from './sseReducer';
|
|
4
|
-
import type { UIStateActions } from './UIStateContext';
|
|
5
4
|
export interface ChatActions {
|
|
6
5
|
addMessage: (message: ChatMessage) => void;
|
|
7
6
|
updateMessage: (messageId: string, updates: Partial<ChatMessage>) => void;
|
|
@@ -26,8 +25,6 @@ interface ChatContextType {
|
|
|
26
25
|
interface ChatProviderProps {
|
|
27
26
|
children: React.ReactNode;
|
|
28
27
|
previewMode?: boolean;
|
|
29
|
-
currentMode: InstructionType;
|
|
30
|
-
uiActions: Pick<UIStateActions, 'setLoading' | 'setError'>;
|
|
31
28
|
}
|
|
32
29
|
export declare const ChatProvider: React.FC<ChatProviderProps>;
|
|
33
30
|
export declare const useChatContext: () => ChatContextType;
|
|
@@ -14,7 +14,6 @@ export interface UIStateActions {
|
|
|
14
14
|
setMode: (mode: InstructionType) => void;
|
|
15
15
|
setLoading: (loading: boolean) => void;
|
|
16
16
|
setError: (error: string | undefined) => void;
|
|
17
|
-
clearError: () => void;
|
|
18
17
|
applyState: (payload: Partial<UIState>) => void;
|
|
19
18
|
}
|
|
20
19
|
interface UIStateContextType {
|
|
@@ -27,5 +27,7 @@ type ProgressStatus = 'in_progress' | 'completed' | 'failed';
|
|
|
27
27
|
export declare function reduceToolProgress(state: SseState, browserToolName: string, explanation: string, status: ProgressStatus, currentMode: InstructionType, error?: string): SseState;
|
|
28
28
|
export declare function reduceToolDone(state: SseState, currentMode: InstructionType): SseState;
|
|
29
29
|
export declare function reduceStop(state: SseState, currentMode: InstructionType): SseState;
|
|
30
|
+
/** Settles a pending message into a plain error bubble — the one shape for both a failed POST and a chat/error. */
|
|
31
|
+
export declare function reduceError(state: SseState, messageId: string, text: string): SseState;
|
|
30
32
|
export declare function reduceSse(state: SseState, event: WidgetEvent, currentMode: InstructionType): ReduceResult;
|
|
31
33
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WidgetSettingsData } from '../sdk';
|
|
2
|
-
|
|
2
|
+
type SemanticTokens = {
|
|
3
3
|
color: {
|
|
4
4
|
background: string;
|
|
5
5
|
foreground: string;
|
|
@@ -18,9 +18,6 @@ export type SemanticTokens = {
|
|
|
18
18
|
};
|
|
19
19
|
radius: string;
|
|
20
20
|
shadow: string;
|
|
21
|
-
typography: {
|
|
22
|
-
fontSizeBase: string;
|
|
23
|
-
};
|
|
24
21
|
motion: {
|
|
25
22
|
durationAnimation: string;
|
|
26
23
|
durationFade: string;
|
|
@@ -30,8 +27,6 @@ export type SemanticTokens = {
|
|
|
30
27
|
widgetHeight: string;
|
|
31
28
|
};
|
|
32
29
|
};
|
|
33
|
-
export type WidgetStyleSettingsDefaults = Pick<WidgetSettingsData, 'widget_background_color' | 'widget_text_color' | 'widget_border_color' | 'widget_accent_color' | 'widget_secondary_color' | 'widget_border_radius' | 'widget_font_size' | 'widget_width' | 'widget_height' | 'widget_shadow' | 'widget_animation_duration' | 'widget_fade_duration'>;
|
|
34
|
-
export declare const WIDGET_STYLE_SETTINGS_DEFAULTS: WidgetStyleSettingsDefaults;
|
|
35
|
-
export declare function mapWidgetSettingsToSemanticTokens(settings: WidgetStyleSettingsDefaults): SemanticTokens;
|
|
36
30
|
export declare function createSemanticTokens(settings?: Partial<WidgetSettingsData>): SemanticTokens;
|
|
37
31
|
export declare function semanticTokensToCssCustomProperties(tokens: SemanticTokens): Record<string, string>;
|
|
32
|
+
export {};
|
|
@@ -24,7 +24,6 @@ export declare const useWidget: () => {
|
|
|
24
24
|
setMode: (mode: import("..").InstructionType) => void;
|
|
25
25
|
setLoading: (loading: boolean) => void;
|
|
26
26
|
setError: (error: string | undefined) => void;
|
|
27
|
-
clearError: () => void;
|
|
28
27
|
applyState: (payload: Partial<import("../context/UIStateContext").UIState>) => void;
|
|
29
28
|
};
|
|
30
29
|
};
|
|
@@ -31,8 +31,6 @@ export interface SearchParams {
|
|
|
31
31
|
}
|
|
32
32
|
export interface ClickElementParams {
|
|
33
33
|
index: number;
|
|
34
|
-
coordinate_x?: number;
|
|
35
|
-
coordinate_y?: number;
|
|
36
34
|
}
|
|
37
35
|
export interface TypeTextParams {
|
|
38
36
|
index: number;
|
|
@@ -68,9 +66,7 @@ export interface WaitParams {
|
|
|
68
66
|
seconds: number;
|
|
69
67
|
}
|
|
70
68
|
export interface ExtractParams {
|
|
71
|
-
query?: string;
|
|
72
69
|
extract_links?: boolean;
|
|
73
|
-
start_from_char?: number;
|
|
74
70
|
}
|
|
75
71
|
export declare class BrowserToolService {
|
|
76
72
|
executeTool(browserToolName: string, args: Record<string, unknown>, mode?: string, explanation?: string): Promise<ToolExecutionResult<unknown>>;
|
|
@@ -8,9 +8,7 @@ export declare class DomService {
|
|
|
8
8
|
private generateSelector;
|
|
9
9
|
private staleReason;
|
|
10
10
|
private indexInteractableElements;
|
|
11
|
-
|
|
12
|
-
private isStackingContext;
|
|
13
|
-
private calculateGlobalZOrder;
|
|
11
|
+
/** `data-id` is the whole contract: the agent parses the snapshot for `[data-id]` and reads nothing else off it. */
|
|
14
12
|
getSnapshotHtml(): string;
|
|
15
13
|
getSequenceForElement(element: Element): number | undefined;
|
|
16
14
|
private clearIndex;
|
|
@@ -14,7 +14,6 @@ export declare class ShowModeService {
|
|
|
14
14
|
private rejectPromise;
|
|
15
15
|
private clickHandler;
|
|
16
16
|
private scrollHandler;
|
|
17
|
-
private mutationObserver;
|
|
18
17
|
private visibilityCheckInterval;
|
|
19
18
|
showToolAction(options: ShowModeOptions): Promise<boolean>;
|
|
20
19
|
cleanup(): void;
|
|
@@ -26,7 +25,7 @@ export declare class ShowModeService {
|
|
|
26
25
|
private updatePopupPosition;
|
|
27
26
|
private setupClickHandler;
|
|
28
27
|
private setupContinueButton;
|
|
29
|
-
|
|
28
|
+
/** checkElementInteractable's first test is `document.body.contains`, so this one watchdog also covers removal. */
|
|
30
29
|
private setupVisibilityMonitoring;
|
|
31
30
|
private failWithElementGone;
|
|
32
31
|
private escapeHtml;
|
|
@@ -2,14 +2,14 @@ import type { ChatMessage, InstructionType, MarketrixConfig } from '../types';
|
|
|
2
2
|
export type StoredMessage = Omit<ChatMessage, 'videoStream' | 'timestamp'> & {
|
|
3
3
|
timestamp: string;
|
|
4
4
|
};
|
|
5
|
-
/** The
|
|
5
|
+
/** The durable half of the widget's React state. `isLoading` is deliberately absent — restoring it would
|
|
6
|
+
* leave the FAB glowing for a request that died with the previous page. */
|
|
6
7
|
export interface ChatSnapshot {
|
|
7
8
|
messages: ChatMessage[];
|
|
8
9
|
isTaskRunning: boolean;
|
|
9
10
|
activeTaskId: string | null;
|
|
10
11
|
currentMode: InstructionType;
|
|
11
12
|
isOpen: boolean;
|
|
12
|
-
isLoading: boolean;
|
|
13
13
|
}
|
|
14
14
|
export type MarketrixChatContext = Omit<ChatSnapshot, 'messages'> & {
|
|
15
15
|
chat_id: string | null;
|
|
@@ -3,9 +3,8 @@ import type { MarketrixConfig } from '../types';
|
|
|
3
3
|
export declare const widgetState: {
|
|
4
4
|
instance: Root | null;
|
|
5
5
|
config: MarketrixConfig | null;
|
|
6
|
-
programmaticInit: boolean;
|
|
7
6
|
};
|
|
8
|
-
export declare const createWidgetContainer: (parentContainer?: HTMLElement
|
|
7
|
+
export declare const createWidgetContainer: (parentContainer?: HTMLElement) => {
|
|
9
8
|
container: HTMLElement;
|
|
10
9
|
shadowRoot: ShadowRoot;
|
|
11
10
|
mountEl: HTMLElement;
|
package/dist/src/utils/chat.d.ts
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import type { ChatMessage, InstructionType } from '../types';
|
|
2
2
|
export declare const getModeDisplayName: (mode: InstructionType) => string;
|
|
3
3
|
export declare const formatMessageTime: (date: Date | undefined) => string;
|
|
4
|
-
export declare function removeThinkingMarkers(content: string): string;
|
|
5
|
-
export declare function removeThinkingMarkerFromEnd(content: string): string;
|
|
6
|
-
export declare function hasThinkingMarker(content: string): boolean;
|
|
7
|
-
export declare function addThinkingMarker(content: string): string;
|
|
8
4
|
export interface FindMessageOptions {
|
|
9
5
|
messages: ChatMessage[];
|
|
10
6
|
isTaskRunning: boolean;
|
|
11
7
|
currentMode: InstructionType;
|
|
12
|
-
requireContent?: boolean;
|
|
13
8
|
}
|
|
14
9
|
/** Ranked predicates: the first rank matching anything wins, and within it the newest message. */
|
|
15
|
-
export declare function findMessageForProgress({ messages, isTaskRunning, currentMode,
|
|
10
|
+
export declare function findMessageForProgress({ messages, isTaskRunning, currentMode, }: FindMessageOptions): {
|
|
16
11
|
index: number;
|
|
17
12
|
message: ChatMessage;
|
|
18
13
|
} | null;
|
|
19
14
|
export declare const WAIT_FOR_USER_TOOLS: Set<string>;
|
|
20
15
|
export declare function filterCancellationText(content: string): string;
|
|
21
16
|
export declare function addProgressLine(message: ChatMessage, browserToolName: string, explanation: string): ChatMessage;
|
|
22
|
-
export declare
|
|
17
|
+
export declare const markProgressLineComplete: (message: ChatMessage) => ChatMessage;
|
|
23
18
|
export declare function markProgressLineFailed(message: ChatMessage, browserToolName: string, error: string): ChatMessage;
|
|
24
|
-
export declare function updateThinkingMarker(message: ChatMessage, isTaskRunning: boolean, currentMode: 'show' | 'tell' | 'do', isWaitingForUser?: boolean): ChatMessage;
|
|
25
19
|
/** Tool id -> the phrase shown in the activity log. Also the allowlist of tools the agent may call. */
|
|
26
20
|
export declare const BROWSER_TOOLS: Map<string, string>;
|
|
27
21
|
export declare function getFriendlyToolName(browserToolName: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { MarketrixConfig } from '../types';
|
|
1
|
+
import type { InstructionType, MarketrixConfig } from '../types';
|
|
2
2
|
export interface SuggestedActionItem {
|
|
3
3
|
id: string;
|
|
4
4
|
text: string;
|
|
5
|
-
type:
|
|
5
|
+
type: InstructionType;
|
|
6
6
|
}
|
|
7
7
|
export declare function getSuggestedActionsFromConfig(config: MarketrixConfig): SuggestedActionItem[];
|