@marketrix.ai/widget 1.0.0

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 (125) hide show
  1. package/README.md +600 -0
  2. package/dist/components/BrowserTools.d.ts +11 -0
  3. package/dist/components/BrowserTools.d.ts.map +1 -0
  4. package/dist/components/MarketrixWidget.d.ts +8 -0
  5. package/dist/components/MarketrixWidget.d.ts.map +1 -0
  6. package/dist/components/chat/ChatWindow.d.ts +26 -0
  7. package/dist/components/chat/ChatWindow.d.ts.map +1 -0
  8. package/dist/components/chat/MessageContent.d.ts +12 -0
  9. package/dist/components/chat/MessageContent.d.ts.map +1 -0
  10. package/dist/components/chat/MessageItem.d.ts +21 -0
  11. package/dist/components/chat/MessageItem.d.ts.map +1 -0
  12. package/dist/components/chat/MessageList.d.ts +16 -0
  13. package/dist/components/chat/MessageList.d.ts.map +1 -0
  14. package/dist/components/chat/ProgressLine.d.ts +13 -0
  15. package/dist/components/chat/ProgressLine.d.ts.map +1 -0
  16. package/dist/components/chat/SuggestedActions.d.ts +20 -0
  17. package/dist/components/chat/SuggestedActions.d.ts.map +1 -0
  18. package/dist/components/chat/TaskStatusIcon.d.ts +8 -0
  19. package/dist/components/chat/TaskStatusIcon.d.ts.map +1 -0
  20. package/dist/components/chat/ThinkingIndicator.d.ts +10 -0
  21. package/dist/components/chat/ThinkingIndicator.d.ts.map +1 -0
  22. package/dist/components/chat/VideoStreamDisplay.d.ts +8 -0
  23. package/dist/components/chat/VideoStreamDisplay.d.ts.map +1 -0
  24. package/dist/components/chat/WelcomeMessage.d.ts +30 -0
  25. package/dist/components/chat/WelcomeMessage.d.ts.map +1 -0
  26. package/dist/components/debug/DebugPanel.d.ts +17 -0
  27. package/dist/components/debug/DebugPanel.d.ts.map +1 -0
  28. package/dist/components/dev/DomTestPanel.d.ts +8 -0
  29. package/dist/components/dev/DomTestPanel.d.ts.map +1 -0
  30. package/dist/components/input/MessageInput.d.ts +15 -0
  31. package/dist/components/input/MessageInput.d.ts.map +1 -0
  32. package/dist/components/input/ModeSelector.d.ts +13 -0
  33. package/dist/components/input/ModeSelector.d.ts.map +1 -0
  34. package/dist/components/layout/WidgetButton.d.ts +12 -0
  35. package/dist/components/layout/WidgetButton.d.ts.map +1 -0
  36. package/dist/components/ui/DiagnosticModal.d.ts +16 -0
  37. package/dist/components/ui/DiagnosticModal.d.ts.map +1 -0
  38. package/dist/components/ui/ErrorDisplay.d.ts +9 -0
  39. package/dist/components/ui/ErrorDisplay.d.ts.map +1 -0
  40. package/dist/components/ui/ScreenAccessModal.d.ts +10 -0
  41. package/dist/components/ui/ScreenAccessModal.d.ts.map +1 -0
  42. package/dist/components/ui/WidgetSettingsLoader.d.ts +13 -0
  43. package/dist/components/ui/WidgetSettingsLoader.d.ts.map +1 -0
  44. package/dist/constants/config.d.ts +26 -0
  45. package/dist/constants/config.d.ts.map +1 -0
  46. package/dist/context/WidgetContext.d.ts +34 -0
  47. package/dist/context/WidgetContext.d.ts.map +1 -0
  48. package/dist/debug.d.ts +23 -0
  49. package/dist/debug.d.ts.map +1 -0
  50. package/dist/debug.js +22790 -0
  51. package/dist/debug.js.map +1 -0
  52. package/dist/hooks/usePageLifecycle.d.ts +12 -0
  53. package/dist/hooks/usePageLifecycle.d.ts.map +1 -0
  54. package/dist/hooks/useTaskState.d.ts +6 -0
  55. package/dist/hooks/useTaskState.d.ts.map +1 -0
  56. package/dist/hooks/useWidget.d.ts +67 -0
  57. package/dist/hooks/useWidget.d.ts.map +1 -0
  58. package/dist/index.d.ts +29 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.html +1464 -0
  61. package/dist/index.mjs +14660 -0
  62. package/dist/index.mjs.map +1 -0
  63. package/dist/sdk/index.d.ts +6330 -0
  64. package/dist/sdk/index.d.ts.map +1 -0
  65. package/dist/sdk/routes.d.ts +17972 -0
  66. package/dist/sdk/routes.d.ts.map +1 -0
  67. package/dist/sdk/schema.d.ts +9345 -0
  68. package/dist/sdk/schema.d.ts.map +1 -0
  69. package/dist/services/ApiService.d.ts +53 -0
  70. package/dist/services/ApiService.d.ts.map +1 -0
  71. package/dist/services/ChatService.d.ts +46 -0
  72. package/dist/services/ChatService.d.ts.map +1 -0
  73. package/dist/services/ConfigManager.d.ts +21 -0
  74. package/dist/services/ConfigManager.d.ts.map +1 -0
  75. package/dist/services/DevTestService.d.ts +172 -0
  76. package/dist/services/DevTestService.d.ts.map +1 -0
  77. package/dist/services/DomService.d.ts +145 -0
  78. package/dist/services/DomService.d.ts.map +1 -0
  79. package/dist/services/IntegrationService.d.ts +18 -0
  80. package/dist/services/IntegrationService.d.ts.map +1 -0
  81. package/dist/services/ScreenShareService.d.ts +25 -0
  82. package/dist/services/ScreenShareService.d.ts.map +1 -0
  83. package/dist/services/SessionManager.d.ts +68 -0
  84. package/dist/services/SessionManager.d.ts.map +1 -0
  85. package/dist/services/ShowModeService.d.ts +33 -0
  86. package/dist/services/ShowModeService.d.ts.map +1 -0
  87. package/dist/services/ToolService.d.ts +89 -0
  88. package/dist/services/ToolService.d.ts.map +1 -0
  89. package/dist/services/ValidationService.d.ts +34 -0
  90. package/dist/services/ValidationService.d.ts.map +1 -0
  91. package/dist/services/WebSocketClient.d.ts +53 -0
  92. package/dist/services/WebSocketClient.d.ts.map +1 -0
  93. package/dist/types/browserTools.d.ts +98 -0
  94. package/dist/types/browserTools.d.ts.map +1 -0
  95. package/dist/types/index.d.ts +128 -0
  96. package/dist/types/index.d.ts.map +1 -0
  97. package/dist/types/toolMessages.d.ts +78 -0
  98. package/dist/types/toolMessages.d.ts.map +1 -0
  99. package/dist/utils/apiUtils.d.ts +55 -0
  100. package/dist/utils/apiUtils.d.ts.map +1 -0
  101. package/dist/utils/bootstrap.d.ts +74 -0
  102. package/dist/utils/bootstrap.d.ts.map +1 -0
  103. package/dist/utils/chat.d.ts +97 -0
  104. package/dist/utils/chat.d.ts.map +1 -0
  105. package/dist/utils/cleanupUtils.d.ts +24 -0
  106. package/dist/utils/cleanupUtils.d.ts.map +1 -0
  107. package/dist/utils/common.d.ts +55 -0
  108. package/dist/utils/common.d.ts.map +1 -0
  109. package/dist/utils/config.d.ts +58 -0
  110. package/dist/utils/config.d.ts.map +1 -0
  111. package/dist/utils/devTools.d.ts +71 -0
  112. package/dist/utils/devTools.d.ts.map +1 -0
  113. package/dist/utils/dom.d.ts +66 -0
  114. package/dist/utils/dom.d.ts.map +1 -0
  115. package/dist/utils/format.d.ts +36 -0
  116. package/dist/utils/format.d.ts.map +1 -0
  117. package/dist/utils/persistence.d.ts +15 -0
  118. package/dist/utils/persistence.d.ts.map +1 -0
  119. package/dist/utils/stateUtils.d.ts +20 -0
  120. package/dist/utils/stateUtils.d.ts.map +1 -0
  121. package/dist/utils/validation.d.ts +130 -0
  122. package/dist/utils/validation.d.ts.map +1 -0
  123. package/dist/utils/widgetPositioning.d.ts +3 -0
  124. package/dist/utils/widgetPositioning.d.ts.map +1 -0
  125. package/package.json +87 -0
@@ -0,0 +1,33 @@
1
+ export interface ShowModeOptions {
2
+ element: HTMLElement;
3
+ explanation: string;
4
+ toolName: string;
5
+ isClickAction?: boolean;
6
+ }
7
+ export declare class ShowModeService {
8
+ private static instance;
9
+ private currentPopup;
10
+ private currentHighlight;
11
+ private currentElement;
12
+ private currentOptions;
13
+ private currentPromise;
14
+ private resolvePromise;
15
+ private rejectPromise;
16
+ private clickHandler;
17
+ private scrollHandler;
18
+ private updateHighlightPosition;
19
+ private rafId;
20
+ private constructor();
21
+ static getInstance(): ShowModeService;
22
+ showToolAction(options: ShowModeOptions): Promise<boolean>;
23
+ cleanup(): void;
24
+ private createHighlight;
25
+ private createPopup;
26
+ private setupPositionUpdates;
27
+ private updatePopupPosition;
28
+ private setupClickHandler;
29
+ private setupContinueButton;
30
+ private escapeHtml;
31
+ }
32
+ export declare const showModeService: ShowModeService;
33
+ //# sourceMappingURL=ShowModeService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShowModeService.d.ts","sourceRoot":"","sources":["../../src/services/ShowModeService.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkB;IAEzC,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,cAAc,CAAgC;IACtD,OAAO,CAAC,cAAc,CAAiC;IACvD,OAAO,CAAC,cAAc,CAA2C;IACjE,OAAO,CAAC,aAAa,CAA6C;IAClE,OAAO,CAAC,YAAY,CAA0C;IAC9D,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,uBAAuB,CAA6B;IAC5D,OAAO,CAAC,KAAK,CAAuB;IAEpC,OAAO;IAEP,MAAM,CAAC,WAAW,IAAI,eAAe;IAO/B,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IA8ChE,OAAO,IAAI,IAAI;IAoDf,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,WAAW;IAyBnB,OAAO,CAAC,oBAAoB;IAsB5B,OAAO,CAAC,mBAAmB;IA6D3B,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,UAAU;CAKnB;AAED,eAAO,MAAM,eAAe,iBAAgC,CAAC"}
@@ -0,0 +1,89 @@
1
+ export interface ToolExecutionResult {
2
+ success: boolean;
3
+ result: string;
4
+ error?: string;
5
+ recoveryInfo?: {
6
+ originalIndex: number;
7
+ recoveredIndex?: number;
8
+ domReindexed: boolean;
9
+ };
10
+ }
11
+ export interface NavigateParams {
12
+ url: string;
13
+ new_tab?: boolean;
14
+ }
15
+ export interface SearchParams {
16
+ query: string;
17
+ engine?: 'duckduckgo' | 'google' | 'bing';
18
+ }
19
+ export interface ClickElementParams {
20
+ index: number;
21
+ }
22
+ export interface TypeTextParams {
23
+ index: number;
24
+ text: string;
25
+ }
26
+ export interface ScrollParams {
27
+ direction: 'up' | 'down' | 'left' | 'right';
28
+ }
29
+ export interface ScrollToTextParams {
30
+ text: string;
31
+ }
32
+ export interface SendKeysParams {
33
+ index: number;
34
+ keys: string;
35
+ }
36
+ export interface SelectDropdownOptionParams {
37
+ index: number;
38
+ option: string;
39
+ }
40
+ export interface GetDropdownOptionsParams {
41
+ index: number;
42
+ }
43
+ export interface UploadFileParams {
44
+ index: number;
45
+ path: string;
46
+ }
47
+ export interface SwitchTabParams {
48
+ tab_index: number;
49
+ }
50
+ export interface DoneParams {
51
+ success: boolean;
52
+ message?: string;
53
+ }
54
+ export interface WaitParams {
55
+ seconds: number;
56
+ }
57
+ export declare class ToolExecutionService {
58
+ private static instance;
59
+ private constructor();
60
+ static getInstance(): ToolExecutionService;
61
+ executeTool(toolName: string, args: Record<string, unknown>, mode?: string, explanation?: string): Promise<ToolExecutionResult>;
62
+ private requiresHighlight;
63
+ private navigate;
64
+ private search;
65
+ private clickElement;
66
+ private typeText;
67
+ private scroll;
68
+ private scrollToText;
69
+ private extract;
70
+ private goBack;
71
+ private wait;
72
+ private selectDropdownOption;
73
+ private getDropdownOptions;
74
+ private sendKeys;
75
+ /**
76
+ * Simulate actual browser behavior for special keys
77
+ * Since programmatic KeyboardEvents are not "trusted", we need to
78
+ * manually trigger the expected behavior
79
+ */
80
+ private simulateKeyAction;
81
+ private uploadFile;
82
+ private closeTab;
83
+ private switchTab;
84
+ private done;
85
+ private getHtml;
86
+ private getScreenshot;
87
+ }
88
+ export declare const toolExecutionService: ToolExecutionService;
89
+ //# sourceMappingURL=ToolService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolService.d.ts","sourceRoot":"","sources":["../../src/services/ToolService.ts"],"names":[],"mappings":"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O,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAuB;IAE9C,OAAO;IAEP,MAAM,CAAC,WAAW,IAAI,oBAAoB;IAOpC,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,GAAE,MAAa,EACnB,WAAW,GAAE,MAAW,GACvB,OAAO,CAAC,mBAAmB,CAAC;IAuF/B,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,MAAM;YAeA,YAAY;IAiE1B,OAAO,CAAC,QAAQ;IA4LhB,OAAO,CAAC,MAAM;IAuBd,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,OAAO;IAef,OAAO,CAAC,MAAM;YAQA,IAAI;IAOlB,OAAO,CAAC,oBAAoB;IA2C5B,OAAO,CAAC,kBAAkB;IA2B1B,OAAO,CAAC,QAAQ;IAkDhB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IA0PzB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,IAAI;IAUZ,OAAO,CAAC,OAAO;YASD,aAAa;CAmC5B;AAED,eAAO,MAAM,oBAAoB,sBAAqC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type AgentData, type ConnectionData, type IntegrationData } from '../sdk';
2
+ import type { MarketrixConfig } from '../types';
3
+ export interface WidgetValidationResult {
4
+ isValid: boolean;
5
+ error?: string;
6
+ integration?: IntegrationData;
7
+ agent?: AgentData;
8
+ connection?: ConnectionData;
9
+ }
10
+ /**
11
+ * WidgetValidationService
12
+ *
13
+ * Validates widget configuration by checking:
14
+ * 1. Integration exists (via marketrix_id and marketrix_key) OR
15
+ * 2. Agent ID and Connection ID exist and match
16
+ */
17
+ export declare class WidgetValidationService {
18
+ /**
19
+ * Validate widget configuration
20
+ * Handles both mtxId+mtxKey and mtxApp+mtxAgent cases
21
+ */
22
+ validateConfig(config: MarketrixConfig): Promise<WidgetValidationResult>;
23
+ /**
24
+ * Validate by mtxId and mtxKey
25
+ */
26
+ private validateByMarketrixId;
27
+ /**
28
+ * Validate by mtxApp and mtxAgent directly
29
+ * Validates connection and agent by ID
30
+ */
31
+ private validateByAgentAndConnection;
32
+ }
33
+ export default WidgetValidationService;
34
+ //# sourceMappingURL=ValidationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValidationService.d.ts","sourceRoot":"","sources":["../../src/services/ValidationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAO,MAAM,QAAQ,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIhD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,qBAAa,uBAAuB;IAClC;;;OAGG;IACG,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAa9E;;OAEG;YACW,qBAAqB;IAsKnC;;;OAGG;YACW,4BAA4B;CAgF3C;AAED,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { MarketrixConfig } from '../types';
2
+ export type WebSocketStatus = 'disconnected' | 'connecting' | 'connected' | 'registered' | 'error';
3
+ export interface WebSocketMessage {
4
+ jsonrpc?: string;
5
+ method?: string;
6
+ params?: Record<string, unknown>;
7
+ result?: unknown;
8
+ error?: {
9
+ code: number;
10
+ message: string;
11
+ };
12
+ id?: string | number;
13
+ }
14
+ export interface WebSocketClientCallbacks {
15
+ onStatusChange?: (status: WebSocketStatus) => void;
16
+ onMessage?: (message: WebSocketMessage) => void;
17
+ onError?: (error: Error) => void;
18
+ }
19
+ export declare class WebSocketClient {
20
+ private static instance;
21
+ private websocket;
22
+ private url;
23
+ private chatId;
24
+ private status;
25
+ private callbacks;
26
+ private reconnectAttempts;
27
+ private readonly maxReconnectAttempts;
28
+ private reconnectDelay;
29
+ private readonly maxReconnectDelay;
30
+ private reconnectTimer;
31
+ private isIntentionallyDisconnected;
32
+ private heartbeatInterval;
33
+ private readonly heartbeatIntervalMs;
34
+ private constructor();
35
+ static getInstance(config?: Partial<MarketrixConfig>): WebSocketClient;
36
+ addCallbacks(callbacks: WebSocketClientCallbacks): void;
37
+ removeCallbacks(callbacks: WebSocketClientCallbacks): void;
38
+ getStatus(): WebSocketStatus;
39
+ getUrl(): string;
40
+ isConnected(): boolean;
41
+ connect(chatId: string): Promise<void>;
42
+ disconnect(): void;
43
+ send(message: WebSocketMessage): void;
44
+ private setStatus;
45
+ private notifyError;
46
+ private handleMessage;
47
+ private sendRegistration;
48
+ private scheduleReconnect;
49
+ private clearReconnectTimer;
50
+ private startHeartbeat;
51
+ private stopHeartbeat;
52
+ }
53
+ //# sourceMappingURL=WebSocketClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketClient.d.ts","sourceRoot":"","sources":["../../src/services/WebSocketClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGhD,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;AAEnG,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,C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hB,WAAW,IAAI,OAAO;IAIhB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgH5C,UAAU,IAAI,IAAI;IAclB,IAAI,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAmBrC,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,aAAa;CAMtB"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Browser Use Tools - TypeScript types for browser automation actions
3
+ * Based on browser_use Python library views.py
4
+ */
5
+ export interface BaseBrowserAction {
6
+ type: string;
7
+ }
8
+ export interface ExtractAction extends BaseBrowserAction {
9
+ type: 'extract';
10
+ query: string;
11
+ extract_links?: boolean;
12
+ start_from_char?: number;
13
+ }
14
+ export interface SearchAction extends BaseBrowserAction {
15
+ type: 'search';
16
+ query: string;
17
+ engine?: 'duckduckgo' | 'google' | 'bing';
18
+ }
19
+ export interface NavigateAction extends BaseBrowserAction {
20
+ type: 'navigate';
21
+ url: string;
22
+ new_tab?: boolean;
23
+ }
24
+ export interface ClickElementAction extends BaseBrowserAction {
25
+ type: 'click';
26
+ index?: number | null;
27
+ coordinate_x?: number | null;
28
+ coordinate_y?: number | null;
29
+ }
30
+ export interface InputTextAction extends BaseBrowserAction {
31
+ type: 'input_text';
32
+ index: number;
33
+ text: string;
34
+ clear?: boolean;
35
+ }
36
+ export interface DoneAction extends BaseBrowserAction {
37
+ type: 'done';
38
+ text: string;
39
+ success?: boolean;
40
+ files_to_display?: string[] | null;
41
+ }
42
+ export interface StructuredOutputAction<T = unknown> extends BaseBrowserAction {
43
+ type: 'structured_output';
44
+ success?: boolean;
45
+ data: T;
46
+ }
47
+ export interface SwitchTabAction extends BaseBrowserAction {
48
+ type: 'switch_tab';
49
+ tab_id: string;
50
+ }
51
+ export interface CloseTabAction extends BaseBrowserAction {
52
+ type: 'close_tab';
53
+ tab_id: string;
54
+ }
55
+ export interface ScrollAction extends BaseBrowserAction {
56
+ type: 'scroll';
57
+ down?: boolean;
58
+ pages?: number;
59
+ index?: number | null;
60
+ }
61
+ export interface SendKeysAction extends BaseBrowserAction {
62
+ type: 'send_keys';
63
+ keys: string;
64
+ }
65
+ export interface UploadFileAction extends BaseBrowserAction {
66
+ type: 'upload_file';
67
+ index: number;
68
+ path: string;
69
+ }
70
+ export interface NoParamsAction extends BaseBrowserAction {
71
+ type: 'no_params';
72
+ }
73
+ export interface GetDropdownOptionsAction extends BaseBrowserAction {
74
+ type: 'get_dropdown_options';
75
+ index: number;
76
+ }
77
+ export interface SelectDropdownOptionAction extends BaseBrowserAction {
78
+ type: 'select_dropdown_option';
79
+ index: number;
80
+ text: string;
81
+ }
82
+ export type BrowserAction = ExtractAction | SearchAction | NavigateAction | ClickElementAction | InputTextAction | DoneAction | StructuredOutputAction | SwitchTabAction | CloseTabAction | ScrollAction | SendKeysAction | UploadFileAction | NoParamsAction | GetDropdownOptionsAction | SelectDropdownOptionAction;
83
+ export interface BrowserToolMetadata {
84
+ id: string;
85
+ name: string;
86
+ description: string;
87
+ icon?: string;
88
+ category: 'navigation' | 'interaction' | 'extraction' | 'utility';
89
+ actionType: BrowserAction['type'];
90
+ }
91
+ export declare const BROWSER_TOOL_CATEGORIES: {
92
+ readonly navigation: "Navigation";
93
+ readonly interaction: "Interaction";
94
+ readonly extraction: "Extraction";
95
+ readonly utility: "Utility";
96
+ };
97
+ export declare const BROWSER_TOOLS: BrowserToolMetadata[];
98
+ //# sourceMappingURL=browserTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browserTools.d.ts","sourceRoot":"","sources":["../../src/types/browserTools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;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AW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,SAAS,CAAC;IAClE,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACnC;AAGD,eAAO,MAAM,uBAAuB;;;;;CAK1B,CAAC;AAGX,eAAO,MAAM,aAAa,EAAE,mBAAmB,EAmG9C,CAAC"}
@@ -0,0 +1,128 @@
1
+ import type { InstructionType, WidgetSettingsData } from '../sdk';
2
+ export type { AgentData, ConnectionData, InstructionType, IntegrationData, TenantData, UserData, WidgetChip, WidgetSettingsData, } from '../sdk';
3
+ /**
4
+ * MarketrixConfig - Flat superset type extending WidgetSettingsData
5
+ *
6
+ * This type extends WidgetSettingsData (with all fields optional) with additional
7
+ * widget-specific fields, allowing API settings to be spread directly:
8
+ * { ...config, ...apiSettings }
9
+ *
10
+ * All fields are at the top level for easy merging and access.
11
+ */
12
+ export type MarketrixConfig = Partial<WidgetSettingsData> & {
13
+ mtxId?: string;
14
+ mtxKey?: string;
15
+ mtxApp?: number;
16
+ mtxAgent?: number;
17
+ userId?: number;
18
+ mtxApiHost?: string;
19
+ mtxAiHost?: string;
20
+ widget_position_offset?: {
21
+ x?: number;
22
+ y?: number;
23
+ };
24
+ widget_position_z_index?: number;
25
+ };
26
+ export interface ChatMessage {
27
+ id: string;
28
+ content: string;
29
+ sender: 'user' | 'agent';
30
+ timestamp: Date;
31
+ mode?: InstructionType;
32
+ videoStream?: MediaStream;
33
+ isScreenAccessRequest?: boolean;
34
+ screenShareStatus?: 'allowed' | 'denied';
35
+ isSystemMessage?: boolean;
36
+ isPlaceholder?: boolean;
37
+ placeholderState?: 'thinking' | 'waiting-for-user';
38
+ parts?: MessagePart[];
39
+ taskStatus?: 'ongoing' | 'done' | 'failed' | 'stopped';
40
+ }
41
+ export interface MessagePart {
42
+ type: 'text' | 'progress';
43
+ content: string;
44
+ status?: 'running' | 'completed' | 'failed' | 'canceled';
45
+ toolName?: string;
46
+ hideIcon?: boolean;
47
+ textStyle?: 'default' | 'muted';
48
+ }
49
+ export interface TaskProgress {
50
+ tool_name: string;
51
+ tool_params: Record<string, unknown>;
52
+ step: number;
53
+ explanation: string;
54
+ mode: string;
55
+ timestamp: number;
56
+ }
57
+ export interface WidgetState {
58
+ isOpen: boolean;
59
+ isMinimized: boolean;
60
+ isLoading: boolean;
61
+ messages: ChatMessage[];
62
+ currentMode: InstructionType;
63
+ agentAvailable: boolean;
64
+ error?: string;
65
+ activeTaskId: string | null;
66
+ isTaskRunning: boolean;
67
+ taskProgress: TaskProgress[];
68
+ }
69
+ export interface SendMessageRequest {
70
+ message?: string;
71
+ mode?: InstructionType;
72
+ mtxId?: string;
73
+ mtxKey?: string;
74
+ connection_id?: number;
75
+ question?: string;
76
+ }
77
+ export interface SendMessageResponse {
78
+ messageId: string;
79
+ response: string;
80
+ mode: InstructionType;
81
+ timestamp: Date;
82
+ task_id?: string;
83
+ }
84
+ export type WidgetPosition = WidgetSettingsData['widget_position'];
85
+ /**
86
+ * Configuration for addWidget function
87
+ * Supports preview, production, and dev modes
88
+ */
89
+ export type AddWidgetConfig = ({
90
+ settings: WidgetSettingsData;
91
+ mtxId?: never;
92
+ mtxKey?: never;
93
+ mtxApp?: never;
94
+ mtxAgent?: never;
95
+ } | {
96
+ settings?: never;
97
+ mtxId: string;
98
+ mtxKey: string;
99
+ mtxApp?: never;
100
+ mtxAgent?: never;
101
+ } | {
102
+ settings?: never;
103
+ mtxId?: never;
104
+ mtxKey?: never;
105
+ mtxApp: number;
106
+ mtxAgent: number;
107
+ }) & {
108
+ container?: HTMLElement;
109
+ mtxApiHost?: string;
110
+ mtxAiHost?: string;
111
+ userId?: number;
112
+ widget_position_offset?: {
113
+ x?: number;
114
+ y?: number;
115
+ };
116
+ widget_position_z_index?: number;
117
+ };
118
+ /**
119
+ * Props for MarketrixWidget React component
120
+ */
121
+ export interface MarketrixWidgetProps {
122
+ settings: WidgetSettingsData;
123
+ container?: HTMLElement;
124
+ }
125
+ export type { TourData } from '../sdk';
126
+ export type { BrowserAction, BrowserToolMetadata, ClickElementAction, CloseTabAction, DoneAction, ExtractAction, GetDropdownOptionsAction, InputTextAction, NavigateAction, NoParamsAction, ScrollAction, SearchAction, SelectDropdownOptionAction, SendKeysAction, StructuredOutputAction, SwitchTabAction, UploadFileAction, } from './browserTools';
127
+ export { BROWSER_TOOL_CATEGORIES, BROWSER_TOOLS } from './browserTools';
128
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAGlE,YAAY,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,eAAe,EACf,UAAU,EACV,QAAQ,EACR,UAAU,EACV,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAEhB;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG;IAG1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,sBAAsB,CAAC,EAAE;QACvB,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,EAAE,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MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CACJ,GAAG;IAEF,SAAS,CAAC,EAAE,WAAW,CAAC;IAExB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sBAAsB,CAAC,EAAE;QACvB,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,SAAS,CAAC,EAAE,WAAW,CAAC;CACzB;AAGD,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGvC,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Typed structures for MCP tool call messages between agent and widget.
3
+ *
4
+ * These types ensure type safety and consistency between Python (agent) and TypeScript (widget) sides.
5
+ */
6
+ import type { WebSocketMessage } from '../services/WebSocketClient';
7
+ /**
8
+ * Parameters for a tool call request.
9
+ * Matches the Python ToolCallRequestParams structure.
10
+ */
11
+ export interface ToolCallRequestParams extends Record<string, unknown> {
12
+ /** Name of the tool to call */
13
+ name: string;
14
+ /** Tool-specific arguments (dict of string keys to any values) */
15
+ arguments: Record<string, unknown>;
16
+ /** Execution mode - 'show' or 'do' (subset of InstructionType) */
17
+ mode: 'show' | 'do';
18
+ /** Optional explanation for the tool call */
19
+ explanation?: string;
20
+ }
21
+ /**
22
+ * Complete JSON-RPC 2.0 tool call request message.
23
+ * This structure is sent from agent to widget via WebSocket.
24
+ * Matches the Python ToolCallRequest structure.
25
+ */
26
+ export interface ToolCallRequestMessage extends WebSocketMessage {
27
+ jsonrpc: '2.0';
28
+ id: string | number;
29
+ method: 'tools/call';
30
+ params: ToolCallRequestParams;
31
+ }
32
+ /**
33
+ * TextContent structure in JSON-RPC response.
34
+ * Matches the MCP TextContent type structure and Python TextContentDict.
35
+ */
36
+ export interface TextContentDict {
37
+ type: 'text';
38
+ text: string;
39
+ }
40
+ /**
41
+ * Content structure in tool call response.
42
+ * Matches the Python ToolCallResponseContent structure.
43
+ */
44
+ export interface ToolCallResponseContent {
45
+ content: TextContentDict[];
46
+ }
47
+ /**
48
+ * Complete JSON-RPC 2.0 tool call response message.
49
+ * This structure is sent from widget to agent via WebSocket.
50
+ * Matches the Python ToolCallResponse structure.
51
+ */
52
+ export interface ToolCallResponseMessage extends WebSocketMessage {
53
+ jsonrpc: '2.0';
54
+ id: string | number;
55
+ result: ToolCallResponseContent;
56
+ }
57
+ /**
58
+ * JSON-RPC 2.0 error response for tool calls.
59
+ * Matches the Python ToolCallErrorResponse structure.
60
+ */
61
+ export interface ToolCallErrorResponseMessage extends WebSocketMessage {
62
+ jsonrpc: '2.0';
63
+ id: string | number;
64
+ error: {
65
+ code: number;
66
+ message: string;
67
+ data?: unknown;
68
+ };
69
+ }
70
+ /**
71
+ * Type guard to check if a WebSocketMessage is a ToolCallRequestMessage.
72
+ */
73
+ export declare function isToolCallRequestMessage(message: WebSocketMessage): message is ToolCallRequestMessage;
74
+ /**
75
+ * Type guard to check if a WebSocketMessage is a ToolCallResponseMessage.
76
+ */
77
+ export declare function isToolCallResponseMessage(message: WebSocketMessage): message is ToolCallResponseMessage;
78
+ //# sourceMappingURL=toolMessages.d.ts.map
@@ -0,0 +1 @@
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AC,EAAE,OAAO,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,gBAAgB,GACxB,OAAO,IAAI,sBAAsB,CASnC;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,gBAAgB,GACxB,OAAO,IAAI,uBAAuB,CAQpC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * API Utilities
3
+ *
4
+ * Consolidates API response validation, data extraction, and error handling patterns.
5
+ * Eliminates repetition of response validation and error handling across services.
6
+ */
7
+ /**
8
+ * API Response Body structure (matches SDK's ResBody interface)
9
+ */
10
+ interface ApiResponseBody<T = unknown> {
11
+ success: boolean;
12
+ data?: T;
13
+ error?: string;
14
+ message?: string;
15
+ }
16
+ /**
17
+ * Generic API response type - flexible to handle SDK union types
18
+ */
19
+ type ApiResponse<T = unknown> = {
20
+ status: number;
21
+ body?: ApiResponseBody<T> | null | unknown;
22
+ [key: string]: unknown;
23
+ };
24
+ /**
25
+ * Validate API response structure
26
+ * Consolidates the repeated pattern: response.status === 200 && response.body?.success
27
+ */
28
+ export declare function isValidApiResponse<T = unknown>(response: ApiResponse<T>): response is ApiResponse<T> & {
29
+ status: 200;
30
+ body: ApiResponseBody<T>;
31
+ };
32
+ /**
33
+ * Extract data from API response with validation
34
+ * Consolidates the pattern: isValidApiResponse(response) && response.body.data
35
+ */
36
+ export declare function extractApiData<T>(response: ApiResponse<T>): T | null;
37
+ /**
38
+ * Check if error is a connection/network error
39
+ * Consolidates the repeated pattern across widgetValidationService and other services
40
+ */
41
+ export declare function isConnectionError(error: unknown): boolean;
42
+ /**
43
+ * Extract error message from unknown error type
44
+ * Consolidates error instanceof Error ? error.message : String(error)
45
+ */
46
+ export declare function extractErrorMessage(error: unknown, fallback?: string): string;
47
+ /**
48
+ * Handle API error with consistent error message extraction
49
+ */
50
+ export declare function handleApiError(error: unknown, context?: string): {
51
+ isValid: false;
52
+ error: string;
53
+ };
54
+ export {};
55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