@marketrix.ai/widget 3.8.142 → 3.8.144
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/Card.d.ts +0 -4
- package/dist/src/components/base/Flex.d.ts +0 -9
- package/dist/src/components/base/icons.d.ts +0 -8
- package/dist/src/components/blocks/HeaderBar.d.ts +0 -1
- package/dist/src/components/navigation/ViewTransition.d.ts +0 -6
- package/dist/src/components/ui/StateMessage.d.ts +0 -4
- package/dist/src/components/views/ChatView.d.ts +0 -1
- package/dist/src/context/ChatContext.d.ts +0 -14
- package/dist/src/context/UIStateContext.d.ts +0 -1
- package/dist/src/context/WidgetProviders.d.ts +0 -11
- package/dist/src/context/sseReducer.d.ts +0 -17
- package/dist/src/design-system/semantic-tokens.d.ts +0 -7
- package/dist/src/design-system/shadows.d.ts +0 -6
- package/dist/src/hooks/useFocusTrap.d.ts +0 -5
- package/dist/src/hooks/useScrollLock.d.ts +0 -5
- package/dist/src/hooks/useWidget.d.ts +0 -5
- package/dist/src/index.d.ts +0 -17
- package/dist/src/sdk/contracts/common.d.ts +0 -3
- package/dist/src/sdk/contracts/entities.d.ts +3 -9
- package/dist/src/sdk/contracts/widget.d.ts +2 -5
- package/dist/src/services/ApiService.d.ts +2 -10
- package/dist/src/services/BrowserToolService.d.ts +1 -5
- package/dist/src/services/ChatService.d.ts +3 -13
- package/dist/src/services/ChatSessionManager.d.ts +1 -13
- package/dist/src/services/ConfigManager.d.ts +1 -5
- package/dist/src/services/DomService.d.ts +8 -33
- package/dist/src/services/RrwebSessionRecorder.d.ts +5 -18
- package/dist/src/services/ScreenShareService.d.ts +1 -9
- package/dist/src/services/StorageService.d.ts +8 -31
- package/dist/src/services/ValidationService.d.ts +3 -9
- package/dist/src/services/WidgetService.d.ts +1 -9
- package/dist/src/test/a11y-utils.d.ts +0 -5
- package/dist/src/test/fixtures.d.ts +0 -4
- package/dist/src/types/browserTools.d.ts +0 -7
- package/dist/src/types/index.d.ts +2 -18
- package/dist/src/utils/apiUtils.d.ts +0 -4
- package/dist/src/utils/bootstrap.d.ts +0 -28
- package/dist/src/utils/chat.d.ts +0 -38
- package/dist/src/utils/color.d.ts +0 -7
- package/dist/src/utils/dom.d.ts +0 -6
- package/dist/src/utils/logger.d.ts +0 -6
- package/dist/src/utils/validation.d.ts +0 -6
- package/dist/widget.mjs +3 -3
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -9,8 +9,4 @@ export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
9
9
|
/** @internal */
|
|
10
10
|
className?: string;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* A card surface with consistent border-radius, shadow, and white background.
|
|
14
|
-
* Used for: recent conversation card, help about card, chat input container, etc.
|
|
15
|
-
*/
|
|
16
12
|
export declare const Card: import("react").ForwardRefExoticComponent<CardProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type SurfaceProps } from './Surface';
|
|
3
|
-
/**
|
|
4
|
-
* Flex extends Surface with flexbox semantics.
|
|
5
|
-
*
|
|
6
|
-
* Composes `Surface` so that the prop-forwarding, className merging, and
|
|
7
|
-
* elevation/padding/background/radius/layout handling all live in exactly
|
|
8
|
-
* one place. Flex's only contribution is the `flex` utility class plus an
|
|
9
|
-
* optional `flex-col` from the `direction` prop. Public API is unchanged
|
|
10
|
-
* for callers.
|
|
11
|
-
*/
|
|
12
3
|
export interface FlexProps extends SurfaceProps {
|
|
13
4
|
direction?: 'row' | 'column';
|
|
14
5
|
children?: ReactNode;
|
|
@@ -153,7 +153,6 @@ export declare const icons: {
|
|
|
153
153
|
readonly fill: "currentColor";
|
|
154
154
|
}];
|
|
155
155
|
};
|
|
156
|
-
/** Home icon — from MessengerShell TAB_ICONS.home, viewBox 0 0 24 24 */
|
|
157
156
|
readonly home: {
|
|
158
157
|
readonly viewBox: "0 0 24 24";
|
|
159
158
|
readonly paths: [{
|
|
@@ -165,7 +164,6 @@ export declare const icons: {
|
|
|
165
164
|
readonly strokeLinejoin: "round";
|
|
166
165
|
}];
|
|
167
166
|
};
|
|
168
|
-
/** Chat bubble dots icon — from MessengerShell TAB_ICONS.chat and HomeView CTA */
|
|
169
167
|
readonly chat: {
|
|
170
168
|
readonly viewBox: "0 0 24 24";
|
|
171
169
|
readonly paths: [{
|
|
@@ -177,7 +175,6 @@ export declare const icons: {
|
|
|
177
175
|
readonly strokeLinejoin: "round";
|
|
178
176
|
}];
|
|
179
177
|
};
|
|
180
|
-
/** Send / arrow right — from MessageInput send button */
|
|
181
178
|
readonly send: {
|
|
182
179
|
readonly viewBox: "0 0 24 24";
|
|
183
180
|
readonly paths: [{
|
|
@@ -189,7 +186,6 @@ export declare const icons: {
|
|
|
189
186
|
readonly strokeLinejoin: "round";
|
|
190
187
|
}];
|
|
191
188
|
};
|
|
192
|
-
/** Close X (small) — 12×12 viewBox used in NotificationToast, WidgetSettingsLoader */
|
|
193
189
|
readonly closeSmall: {
|
|
194
190
|
readonly viewBox: "0 0 12 12";
|
|
195
191
|
readonly paths: [{
|
|
@@ -201,7 +197,6 @@ export declare const icons: {
|
|
|
201
197
|
readonly strokeLinejoin: "round";
|
|
202
198
|
}];
|
|
203
199
|
};
|
|
204
|
-
/** Close X (fill) — 20×20 fill variant used in MessengerShell header/minimized state */
|
|
205
200
|
readonly close: {
|
|
206
201
|
readonly viewBox: "0 0 20 20";
|
|
207
202
|
readonly paths: [{
|
|
@@ -211,7 +206,6 @@ export declare const icons: {
|
|
|
211
206
|
readonly clipRule: "evenodd";
|
|
212
207
|
}];
|
|
213
208
|
};
|
|
214
|
-
/** Chevron down — from WidgetButton open/close toggle */
|
|
215
209
|
readonly chevronDown: {
|
|
216
210
|
readonly viewBox: "0 0 24 24";
|
|
217
211
|
readonly paths: [{
|
|
@@ -223,7 +217,6 @@ export declare const icons: {
|
|
|
223
217
|
readonly strokeLinejoin: "round";
|
|
224
218
|
}];
|
|
225
219
|
};
|
|
226
|
-
/** Screen share / video camera — from MessengerShell header screen share button */
|
|
227
220
|
readonly screenShare: {
|
|
228
221
|
readonly viewBox: "0 0 24 24";
|
|
229
222
|
readonly paths: [{
|
|
@@ -235,7 +228,6 @@ export declare const icons: {
|
|
|
235
228
|
readonly strokeLinejoin: "round";
|
|
236
229
|
}];
|
|
237
230
|
};
|
|
238
|
-
/** Alert circle / error — from VideoStreamDisplay stream error state */
|
|
239
231
|
readonly alertCircle: {
|
|
240
232
|
readonly viewBox: "0 0 24 24";
|
|
241
233
|
readonly paths: [{
|
|
@@ -4,11 +4,5 @@ interface ViewTransitionProps {
|
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
direction: ViewDirection;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Wrapper that applies view slide animation.
|
|
9
|
-
* Forward: enter from right (translateX 20px → 0).
|
|
10
|
-
* Back: enter from left (translateX -20px → 0).
|
|
11
|
-
* Animation driven by data-view-transition + data-direction CSS selectors in index.css.
|
|
12
|
-
*/
|
|
13
7
|
export declare const ViewTransition: React.FC<ViewTransitionProps>;
|
|
14
8
|
export {};
|
|
@@ -4,9 +4,5 @@ interface StateMessageProps {
|
|
|
4
4
|
variant: StateMessageVariant;
|
|
5
5
|
message: string;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Standardized skeleton/loading, empty, and error states using design tokens.
|
|
9
|
-
* Use in message list, composer, or any surface that needs consistent state UI.
|
|
10
|
-
*/
|
|
11
7
|
export declare const StateMessage: React.FC<StateMessageProps>;
|
|
12
8
|
export {};
|
|
@@ -14,7 +14,6 @@ export interface ChatViewProps {
|
|
|
14
14
|
onStopTask?: () => void;
|
|
15
15
|
onClearChat?: () => void | Promise<void>;
|
|
16
16
|
onScreenSharingChange?: (isSharing: boolean) => void;
|
|
17
|
-
/** Refs for header buttons to trigger screen share start/stop */
|
|
18
17
|
onStartScreenShareRef?: React.MutableRefObject<(() => void) | null>;
|
|
19
18
|
onStopScreenShareRef?: React.MutableRefObject<(() => void) | null>;
|
|
20
19
|
/** Optional ref for focus trap to focus the message input */
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ChatMessage, InstructionType } from '../types';
|
|
3
3
|
import type { UIStateActions } from './UIStateContext';
|
|
4
|
-
/**
|
|
5
|
-
* ChatContext — the single store for the widget's conversation.
|
|
6
|
-
*
|
|
7
|
-
* Holds `{ messages, task }` as ONE `SseState`, so the SSE effect commits each
|
|
8
|
-
* transition through a single atomic `setState(prev => transition(prev))`. This
|
|
9
|
-
* removes the previous two-store split (ChatContext + TaskContext), which forced
|
|
10
|
-
* a raw-setState escape hatch and `messagesRef`/`taskRef` snapshots and could
|
|
11
|
-
* tear (messages updating while task lagged across an await). UIStateContext
|
|
12
|
-
* (open/minimized/mode/loading/error) stays separate — a genuinely different
|
|
13
|
-
* concern.
|
|
14
|
-
*/
|
|
15
4
|
export interface SimulationState {
|
|
16
5
|
activeSimulationId: string | null;
|
|
17
6
|
isSimulationRunning: boolean;
|
|
@@ -43,11 +32,8 @@ interface ChatContextType {
|
|
|
43
32
|
interface ChatProviderProps {
|
|
44
33
|
children: React.ReactNode;
|
|
45
34
|
previewMode?: boolean;
|
|
46
|
-
/** Current mode from UIState — fallback for messageDispatch and progress-line logic. */
|
|
47
35
|
currentMode: InstructionType;
|
|
48
|
-
/** Injected UI actions so the conversation store drives loading/availability/error without nesting contexts. */
|
|
49
36
|
uiActions: Pick<UIStateActions, 'setLoading' | 'setAgentAvailable' | 'setError'>;
|
|
50
|
-
/** One-time hydrated snapshot to seed the store (messages + task) on mount. */
|
|
51
37
|
initialMessages?: ChatMessage[];
|
|
52
38
|
initialTask?: SimulationState;
|
|
53
39
|
}
|
|
@@ -18,7 +18,6 @@ export interface UIStateActions {
|
|
|
18
18
|
setAgentAvailable: (available: boolean) => void;
|
|
19
19
|
setError: (error: string | undefined) => void;
|
|
20
20
|
clearError: () => void;
|
|
21
|
-
/** Bulk-apply partial state overrides. */
|
|
22
21
|
applyState: (payload: Partial<UIState>) => void;
|
|
23
22
|
}
|
|
24
23
|
interface UIStateContextType {
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WidgetProviders — composition root that wires UIStateProvider and
|
|
3
|
-
* ChatProvider together.
|
|
4
|
-
*
|
|
5
|
-
* Conversation state ({ messages, task }) lives in ONE store (ChatProvider);
|
|
6
|
-
* UI state (open/minimized/mode/loading/error) lives in UIStateProvider. Both
|
|
7
|
-
* one-time initialization (SSE connection, ChatService hydration) and persistence
|
|
8
|
-
* live in inner bridge components that can read every context. React context is
|
|
9
|
-
* the single source of truth; ChatService is the load/persist boundary only,
|
|
10
|
-
* driven by one effect here.
|
|
11
|
-
*/
|
|
12
1
|
import React from 'react';
|
|
13
2
|
interface WidgetProvidersProps {
|
|
14
3
|
children: React.ReactNode;
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure SSE reducer — the single place where a `WidgetEvent` turns into the next
|
|
3
|
-
* widget state. No transport, no tool execution, no localStorage: just
|
|
4
|
-
* `(state, event) => { state, effects }`. The ChatContext effect wires
|
|
5
|
-
* this up, runs the returned effects (tool exec, wsClient.send, setLoading), and
|
|
6
|
-
* re-enters via the tool-progress helpers once an async tool finishes.
|
|
7
|
-
*
|
|
8
|
-
* Keeping this pure makes the previously-untestable ~180-line SSE handler unit
|
|
9
|
-
* testable and removes the nested setState-within-setState that hid bugs.
|
|
10
|
-
*/
|
|
11
1
|
import type { WidgetEvent } from '../sdk';
|
|
12
2
|
import type { ChatMessage, InstructionType } from '../types';
|
|
13
3
|
export interface SseSimulationState {
|
|
@@ -35,15 +25,8 @@ export interface ReduceResult {
|
|
|
35
25
|
effects: SseEffect[];
|
|
36
26
|
}
|
|
37
27
|
type ProgressStatus = 'in_progress' | 'completed' | 'failed';
|
|
38
|
-
/** Public: progress transition used by the wiring layer for tool lifecycle. */
|
|
39
28
|
export declare function reduceToolProgress(state: SseState, browserToolName: string, explanation: string, status: ProgressStatus, currentMode: InstructionType, error?: string): SseState;
|
|
40
|
-
/** Public: terminal `done` tool — strip the in-flight `done` progress line and end the task. */
|
|
41
29
|
export declare function reduceToolDone(state: SseState, currentMode: InstructionType): SseState;
|
|
42
|
-
/** Public: user-initiated stop — flag the active message `stopped` and end the task. */
|
|
43
30
|
export declare function reduceStop(state: SseState, currentMode: InstructionType): SseState;
|
|
44
|
-
/**
|
|
45
|
-
* Pure reducer. Returns the next state plus any side effects the wiring must run.
|
|
46
|
-
* Unknown / non-stateful events (registered, heartbeat) are ignored.
|
|
47
|
-
*/
|
|
48
31
|
export declare function reduceSse(state: SseState, event: WidgetEvent, currentMode: InstructionType): ReduceResult;
|
|
49
32
|
export {};
|
|
@@ -34,11 +34,4 @@ export type WidgetStyleSettingsDefaults = Pick<WidgetSettingsData, 'widget_backg
|
|
|
34
34
|
export declare const WIDGET_STYLE_SETTINGS_DEFAULTS: WidgetStyleSettingsDefaults;
|
|
35
35
|
export declare function mapWidgetSettingsToSemanticTokens(settings: WidgetStyleSettingsDefaults): SemanticTokens;
|
|
36
36
|
export declare const DEFAULT_SEMANTIC_TOKENS: SemanticTokens;
|
|
37
|
-
/**
|
|
38
|
-
* Convert tokens to CSS custom properties.
|
|
39
|
-
* Applied as inline styles on the widget root to override static CSS defaults
|
|
40
|
-
* set by `:host` in index.css. Must cover every variable that Tailwind utilities
|
|
41
|
-
* or base-component classes reference so the widget renders correctly inside
|
|
42
|
-
* closed Shadow DOM regardless of host page styles.
|
|
43
|
-
*/
|
|
44
37
|
export declare function semanticTokensToCssCustomProperties(tokens: SemanticTokens): Record<string, string>;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
/** Shared shadow tokens used across all widget components */
|
|
2
1
|
export declare const SHADOW: {
|
|
3
2
|
readonly none: "none";
|
|
4
|
-
/** Cards, message bubbles, chips — subtle elevation */
|
|
5
3
|
readonly card: "0 1px 4px rgba(0,0,0,0.1)";
|
|
6
|
-
/** Header bar, tab bar — section separator */
|
|
7
4
|
readonly section: "0 2px 8px rgba(0,0,0,0.06)";
|
|
8
|
-
/** Main widget panel — strong overlay elevation */
|
|
9
5
|
readonly panel: "0 12px 40px rgba(0,0,0,0.16), 0 4px 12px rgba(0,0,0,0.08)";
|
|
10
|
-
/** FAB button */
|
|
11
6
|
readonly fab: "0 2px 8px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.04)";
|
|
12
|
-
/** Scroll-to buttons */
|
|
13
7
|
readonly button: "0 4px 6px -1px rgba(0,0,0,0.1)";
|
|
14
8
|
};
|
|
15
9
|
export type ShadowToken = keyof typeof SHADOW;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trap focus inside container when active. On mount when active, focus first focusable
|
|
3
|
-
* (or focusTargetRef if provided). Tab cycles within container. On deactivate, return focus
|
|
4
|
-
* to previously focused element. Escape calls onEscape when provided.
|
|
5
|
-
*/
|
|
6
1
|
export declare function useFocusTrap(containerRef: React.RefObject<HTMLElement | null>, isActive: boolean, options?: {
|
|
7
2
|
onEscape?: () => void;
|
|
8
3
|
focusTargetRef?: React.RefObject<HTMLElement | null>;
|
|
@@ -24,11 +24,6 @@ interface UseWidgetActions {
|
|
|
24
24
|
clearChatHistory: () => void;
|
|
25
25
|
messageDispatch: (content: string, mode?: InstructionType, applicationId?: number, question?: string, skipUserMessage?: boolean) => Promise<void>;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Composes UIStateContext and ChatContext into the unified
|
|
29
|
-
* `{ state, actions, config, … }` shape that the widget UI consumes. New code
|
|
30
|
-
* can either keep using this hook or read the focused contexts directly.
|
|
31
|
-
*/
|
|
32
27
|
export declare const useWidget: ({ config }?: UseWidgetProps) => {
|
|
33
28
|
state: WidgetState;
|
|
34
29
|
actions: UseWidgetActions;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -10,28 +10,11 @@ import type { AddWidgetConfig, MarketrixConfig, MarketrixWidgetProps } from './t
|
|
|
10
10
|
import { getCurrentConfig } from './utils/bootstrap';
|
|
11
11
|
export declare const initWidget: (config: MarketrixConfig, container?: HTMLElement) => Promise<void>;
|
|
12
12
|
export declare const unmountWidget: () => void;
|
|
13
|
-
/**
|
|
14
|
-
* Stop RRWeb session recording without unmounting the widget.
|
|
15
|
-
* Keeps the RrwebSessionRecorder instance so recording can be restarted with startRecording().
|
|
16
|
-
* RrwebSessionRecorder.stop() aborts in-flight start() via stopRequested.
|
|
17
|
-
*/
|
|
18
13
|
export declare const stopRecording: () => void;
|
|
19
|
-
/**
|
|
20
|
-
* Start RRWeb session recording. Use after stopRecording() to resume, or when recording was not started on init.
|
|
21
|
-
* Safe to call while auto-start is in-flight — awaits the pending start instead of creating a concurrent one.
|
|
22
|
-
* @throws Error if session recorder was never created (e.g. missing mtxApiHost/mtxApp).
|
|
23
|
-
*/
|
|
24
14
|
export declare const startRecording: () => Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Returns whether RRWeb session recording is currently active.
|
|
27
|
-
*/
|
|
28
15
|
export declare const getRecordingState: () => boolean;
|
|
29
16
|
export declare const updateMarketrixConfig: (newConfig: Partial<MarketrixConfig>) => Promise<void>;
|
|
30
17
|
export { getCurrentConfig };
|
|
31
|
-
/**
|
|
32
|
-
* MarketrixWidget - React component for preview mode
|
|
33
|
-
* Renders widget into parent container with shadow DOM
|
|
34
|
-
*/
|
|
35
18
|
export declare const MarketrixWidget: React.FC<MarketrixWidgetProps>;
|
|
36
19
|
export declare const mountWidget: (config: AddWidgetConfig) => Promise<void>;
|
|
37
20
|
export type { InstructionType } from './sdk';
|
|
@@ -5,9 +5,6 @@ export declare const EntityStatusSchema: z.ZodEnum<{
|
|
|
5
5
|
suspended: "suspended";
|
|
6
6
|
pending_approval: "pending_approval";
|
|
7
7
|
}>;
|
|
8
|
-
/**
|
|
9
|
-
* Base entity schema with common fields for all database entities
|
|
10
|
-
*/
|
|
11
8
|
export declare const BaseEntitySchema: z.ZodObject<{
|
|
12
9
|
id: z.ZodOptional<z.ZodNumber>;
|
|
13
10
|
created_at: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
@@ -49,10 +49,6 @@ export declare const InstructionTypeSchema: z.ZodEnum<{
|
|
|
49
49
|
do: "do";
|
|
50
50
|
}>;
|
|
51
51
|
export type InstructionType = z.infer<typeof InstructionTypeSchema>;
|
|
52
|
-
/**
|
|
53
|
-
* Complete user entity schema
|
|
54
|
-
* Note: Users don't have plans - plans belong to workspaces (via workspace_plan table)
|
|
55
|
-
*/
|
|
56
52
|
export declare const UserEntitySchema: z.ZodObject<{
|
|
57
53
|
id: z.ZodOptional<z.ZodNumber>;
|
|
58
54
|
created_at: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
@@ -77,11 +73,6 @@ export declare const UserEntitySchema: z.ZodObject<{
|
|
|
77
73
|
}>>>;
|
|
78
74
|
}, z.core.$strip>;
|
|
79
75
|
export type UserData = z.infer<typeof UserEntitySchema>;
|
|
80
|
-
/**
|
|
81
|
-
* Complete workspace entity schema
|
|
82
|
-
* Note: package and ending_date come from workspace_plan table (joined when fetching workspace data).
|
|
83
|
-
* They are NOT stored on the workspace table itself.
|
|
84
|
-
*/
|
|
85
76
|
export declare const WorkspaceEntitySchema: z.ZodObject<{
|
|
86
77
|
id: z.ZodOptional<z.ZodNumber>;
|
|
87
78
|
created_at: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
@@ -163,6 +154,7 @@ export declare const SimPersonaReactionEntitySchema: z.ZodObject<{
|
|
|
163
154
|
user_index: z.ZodNullable<z.ZodNumber>;
|
|
164
155
|
simulation_id: z.ZodNullable<z.ZodNumber>;
|
|
165
156
|
study_variant_id: z.ZodNullable<z.ZodNumber>;
|
|
157
|
+
study_task_id: z.ZodNullable<z.ZodNumber>;
|
|
166
158
|
journey_reaction: z.ZodNullable<z.ZodString>;
|
|
167
159
|
journey_sentiment: z.ZodNullable<z.ZodEnum<{
|
|
168
160
|
positive: "positive";
|
|
@@ -226,6 +218,7 @@ export declare const SimulationEntitySchema: z.ZodObject<{
|
|
|
226
218
|
step_count: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
227
219
|
started_at: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
|
|
228
220
|
completed_at: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
|
|
221
|
+
output_persisted_at: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
|
|
229
222
|
graph_status: z.ZodOptional<z.ZodEnum<{
|
|
230
223
|
completed: "completed";
|
|
231
224
|
failed: "failed";
|
|
@@ -248,6 +241,7 @@ export declare const SimulationEntitySchema: z.ZodObject<{
|
|
|
248
241
|
user_index: z.ZodNullable<z.ZodNumber>;
|
|
249
242
|
simulation_id: z.ZodNullable<z.ZodNumber>;
|
|
250
243
|
study_variant_id: z.ZodNullable<z.ZodNumber>;
|
|
244
|
+
study_task_id: z.ZodNullable<z.ZodNumber>;
|
|
251
245
|
journey_reaction: z.ZodNullable<z.ZodString>;
|
|
252
246
|
journey_sentiment: z.ZodNullable<z.ZodEnum<{
|
|
253
247
|
positive: "positive";
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { WidgetSettingsDataSchema } from './entities';
|
|
3
|
-
/**
|
|
4
|
-
* Application with widgets schema — matches API response structure
|
|
5
|
-
*/
|
|
6
3
|
export declare const ApplicationWithWidgetsSchema: z.ZodObject<{
|
|
7
4
|
id: z.ZodOptional<z.ZodNumber>;
|
|
8
5
|
created_at: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
@@ -217,7 +214,7 @@ export declare const WidgetUpdateSchema: z.ZodObject<{
|
|
|
217
214
|
}, z.core.$strip>;
|
|
218
215
|
export type WidgetUpdateData = z.infer<typeof WidgetUpdateSchema>;
|
|
219
216
|
export type WidgetSettingsKey = keyof z.infer<typeof WidgetSettingsDataSchema>;
|
|
220
|
-
/** Server → Widget
|
|
217
|
+
/** Server → Widget events. */
|
|
221
218
|
export declare const WidgetEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
222
219
|
type: z.ZodLiteral<"registered">;
|
|
223
220
|
chat_id: z.ZodString;
|
|
@@ -261,7 +258,7 @@ export declare const WidgetEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
261
258
|
state_version: z.ZodOptional<z.ZodNumber>;
|
|
262
259
|
}, z.core.$strip>], "type">;
|
|
263
260
|
export type WidgetEvent = z.infer<typeof WidgetEventSchema>;
|
|
264
|
-
/** Widget → Server
|
|
261
|
+
/** Widget → Server commands. */
|
|
265
262
|
export declare const WidgetCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
266
263
|
type: z.ZodLiteral<"chat/tell">;
|
|
267
264
|
request_id: z.ZodString;
|
|
@@ -3,18 +3,10 @@ export declare class ApiService {
|
|
|
3
3
|
private config;
|
|
4
4
|
constructor(config: MarketrixConfig);
|
|
5
5
|
getChatId(): string | null;
|
|
6
|
-
/**
|
|
7
|
-
* Get user_id from various sources (config, localStorage, sessionStorage)
|
|
8
|
-
*/
|
|
6
|
+
/** Resolves user_id from config, then localStorage, then sessionStorage. */
|
|
9
7
|
private getUserId;
|
|
10
8
|
logWidgetQuestion(question: string, mode: string): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* Send a message via the typed stream (fire-and-forget).
|
|
13
|
-
* The actual response arrives asynchronously as a chat/response stream event.
|
|
14
|
-
*/
|
|
9
|
+
/** Fire-and-forget send over the typed stream; the reply arrives asynchronously as a chat/response event. */
|
|
15
10
|
messageDispatch(request: MessageDispatchRequest): Promise<MessageDispatchResponse>;
|
|
16
|
-
/**
|
|
17
|
-
* Update configuration
|
|
18
|
-
*/
|
|
19
11
|
updateConfig(newConfig: Partial<MarketrixConfig>): void;
|
|
20
12
|
}
|
|
@@ -96,11 +96,7 @@ export declare class BrowserToolService {
|
|
|
96
96
|
private selectDropdownOption;
|
|
97
97
|
private getDropdownOptions;
|
|
98
98
|
private sendKeys;
|
|
99
|
-
/**
|
|
100
|
-
* Simulate actual browser behavior for special keys
|
|
101
|
-
* Since programmatic KeyboardEvents are not "trusted", we need to
|
|
102
|
-
* manually trigger the expected behavior
|
|
103
|
-
*/
|
|
99
|
+
/** Programmatic KeyboardEvents aren't "trusted", so manually reproduce each key's expected behavior. */
|
|
104
100
|
private simulateKeyAction;
|
|
105
101
|
private uploadFile;
|
|
106
102
|
private closeTab;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { ChatMessage, InstructionType } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Snapshot of widget state persisted to / restored from localStorage.
|
|
4
|
-
* React context is the single source of truth at runtime — this is the
|
|
5
|
-
* load/persist boundary only.
|
|
6
|
-
*/
|
|
2
|
+
/** Widget state persisted to / restored from localStorage; React context is the runtime source of truth. */
|
|
7
3
|
export interface ChatSnapshot {
|
|
8
4
|
messages: ChatMessage[];
|
|
9
5
|
isSimulationRunning: boolean;
|
|
@@ -13,12 +9,7 @@ export interface ChatSnapshot {
|
|
|
13
9
|
isMinimized: boolean;
|
|
14
10
|
isLoading: boolean;
|
|
15
11
|
}
|
|
16
|
-
/**
|
|
17
|
-
* ChatService — thin persistence layer.
|
|
18
|
-
*
|
|
19
|
-
* Owns only the localStorage read/write lifecycle for the widget chat context:
|
|
20
|
-
* contexts call `persist(snapshot)` from a single effect and `restore()` once on mount.
|
|
21
|
-
*/
|
|
12
|
+
/** localStorage read/write lifecycle for the widget chat context: `persist(snapshot)` from an effect, `restore()` once on mount. */
|
|
22
13
|
export declare class ChatService {
|
|
23
14
|
private static instance;
|
|
24
15
|
private chatId;
|
|
@@ -28,9 +19,8 @@ export declare class ChatService {
|
|
|
28
19
|
initialize(chatId: string | null): void;
|
|
29
20
|
createInitialContext(chatId: string): void;
|
|
30
21
|
getInitError(): Error | null;
|
|
31
|
-
/** Read the persisted snapshot, rehydrating messages (dates, lost streams). */
|
|
32
22
|
restore(): ChatSnapshot;
|
|
33
|
-
/**
|
|
23
|
+
/** No-op until a chatId is known. */
|
|
34
24
|
persist(snapshot: ChatSnapshot): void;
|
|
35
25
|
}
|
|
36
26
|
export declare const chatService: ChatService;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chat ID Manager Service
|
|
3
|
-
*
|
|
4
|
-
* Centralized chat ID management with promise-based locking to prevent
|
|
5
|
-
* concurrent chat ID creation. Ensures only one chat ID is created per session.
|
|
6
|
-
*/
|
|
7
1
|
declare class ChatSessionManager {
|
|
8
2
|
private static instance;
|
|
9
3
|
private chatId;
|
|
@@ -11,14 +5,8 @@ declare class ChatSessionManager {
|
|
|
11
5
|
private constructor();
|
|
12
6
|
static getInstance(): ChatSessionManager;
|
|
13
7
|
getChatId(): string | null;
|
|
14
|
-
/**
|
|
15
|
-
* Get or create chat ID with promise-based locking
|
|
16
|
-
* If multiple calls happen concurrently, they all wait for the same promise
|
|
17
|
-
*/
|
|
8
|
+
/** Promise-based lock: concurrent callers all await the same creation promise. */
|
|
18
9
|
getOrCreateChatId(): Promise<string>;
|
|
19
|
-
/**
|
|
20
|
-
* Create a new chat ID - oRPC returns data directly
|
|
21
|
-
*/
|
|
22
10
|
private createChatId;
|
|
23
11
|
private getStoredChatId;
|
|
24
12
|
private storeChatId;
|
|
@@ -12,9 +12,5 @@ export declare class ConfigManager {
|
|
|
12
12
|
shouldShowWidget(): boolean;
|
|
13
13
|
}
|
|
14
14
|
export declare const configManager: ConfigManager;
|
|
15
|
-
/**
|
|
16
|
-
* Creates MarketrixConfig from WidgetSettingsData
|
|
17
|
-
* Since MarketrixConfig extends WidgetSettingsData, this is just a direct merge.
|
|
18
|
-
* API settings (which include defaults) override base config.
|
|
19
|
-
*/
|
|
15
|
+
/** API settings (defaults included) override the base config. */
|
|
20
16
|
export declare function createConfigFromSettings(widgetSettings: WidgetSettingsData, baseConfig?: Partial<MarketrixConfig>): MarketrixConfig;
|
|
@@ -33,28 +33,16 @@ export declare class DomService {
|
|
|
33
33
|
static getInstance(): DomService;
|
|
34
34
|
private generateSelector;
|
|
35
35
|
private generateFingerprint;
|
|
36
|
-
/**
|
|
37
|
-
* Check if an element matches a stored fingerprint.
|
|
38
|
-
* Uses strict matching - fails if any key attribute differs.
|
|
39
|
-
*/
|
|
36
|
+
/** Strict match against a stored fingerprint — fails if any key attribute differs. */
|
|
40
37
|
private matchesFingerprint;
|
|
41
|
-
/**
|
|
42
|
-
* Validate that the element at a given index still matches its fingerprint.
|
|
43
|
-
* No recovery - just check if element exists and matches.
|
|
44
|
-
*/
|
|
38
|
+
/** Check the element at an index still matches its fingerprint; no recovery. */
|
|
45
39
|
private validateElementAtIndex;
|
|
46
|
-
/**
|
|
47
|
-
* Index all interactable elements in the live DOM.
|
|
48
|
-
* Always clears previous index first.
|
|
49
|
-
*/
|
|
40
|
+
/** Index all interactable elements in the live DOM, clearing any previous index first. */
|
|
50
41
|
indexInteractableElements(): Array<[number, Element]>;
|
|
51
42
|
private getElementCoordinates;
|
|
52
43
|
private isStackingContext;
|
|
53
44
|
private calculateGlobalZOrder;
|
|
54
|
-
/**
|
|
55
|
-
* Get HTML snapshot with data-id attributes injected.
|
|
56
|
-
* This re-indexes the live DOM and then produces a corresponding HTML string.
|
|
57
|
-
*/
|
|
45
|
+
/** Re-index the live DOM and return an HTML snapshot with data-id attributes injected. */
|
|
58
46
|
getSnapshotHtml(): string;
|
|
59
47
|
getInteractableElements(): Array<{
|
|
60
48
|
index: number;
|
|
@@ -70,26 +58,13 @@ export declare class DomService {
|
|
|
70
58
|
}>;
|
|
71
59
|
getSequenceForElement(element: Element): number | undefined;
|
|
72
60
|
clearIndex(): void;
|
|
73
|
-
/**
|
|
74
|
-
* Check if an element is interactable (visible, not hidden, not obscured).
|
|
75
|
-
* Returns error string if not interactable, null if OK.
|
|
76
|
-
*/
|
|
61
|
+
/** Returns an error string if the element isn't interactable (hidden/obscured/off-screen), null if OK. */
|
|
77
62
|
private checkInteractability;
|
|
78
|
-
/**
|
|
79
|
-
* Public method to check element interactability (for use by ShowModeService).
|
|
80
|
-
*/
|
|
63
|
+
/** Public interactability check for ShowModeService. */
|
|
81
64
|
checkElementInteractable(element: HTMLElement, index: number): string | null;
|
|
82
|
-
/**
|
|
83
|
-
* Get an interactive element by its index.
|
|
84
|
-
* Returns element only if it's interactable, otherwise returns null with error.
|
|
85
|
-
*/
|
|
65
|
+
/** Look up an element by index; returns it only if interactable, else null + error. */
|
|
86
66
|
getElementByIndex(index: number): ElementLookupResult;
|
|
87
|
-
/**
|
|
88
|
-
* Get an element by index with validation.
|
|
89
|
-
* This is the main entry point for BrowserToolService to use.
|
|
90
|
-
* It validates the element matches its fingerprint and attempts recovery if not.
|
|
91
|
-
* Returns element only if it's interactable.
|
|
92
|
-
*/
|
|
67
|
+
/** Main entry point for BrowserToolService: validate against fingerprint, then return if interactable. */
|
|
93
68
|
getValidatedElement(index: number): ValidatedElementResult;
|
|
94
69
|
}
|
|
95
70
|
export declare const domService: DomService;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RrwebSessionRecorder manages real-time RRWeb session recording,
|
|
3
|
-
* sending batched events to the API via HTTP POST (widget message endpoint).
|
|
4
|
-
*/
|
|
1
|
+
/** Real-time RRWeb recording; batched events POSTed to the API widget-message endpoint. */
|
|
5
2
|
export declare class RrwebSessionRecorder {
|
|
6
3
|
private eventQueue;
|
|
7
4
|
private estimatedQueueBytes;
|
|
@@ -20,23 +17,13 @@ export declare class RrwebSessionRecorder {
|
|
|
20
17
|
private metadataEmit;
|
|
21
18
|
private bufferEvent;
|
|
22
19
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* Batches are capped at MAX_BATCH_BYTES to stay within the API body-parser limit.
|
|
26
|
-
* On transient server errors (5xx / network) the batch is re-queued up to
|
|
27
|
-
* MAX_CONSECUTIVE_FAILURES times before being dropped.
|
|
28
|
-
* On permanent client errors (4xx) the batch is dropped immediately — re-sending
|
|
29
|
-
* would never succeed and would create an infinite retry loop.
|
|
20
|
+
* POST buffered events (batch capped at MAX_BATCH_BYTES). Transient errors (5xx/network) re-queue
|
|
21
|
+
* up to MAX_CONSECUTIVE_FAILURES; permanent errors (4xx) drop immediately (a retry never succeeds).
|
|
30
22
|
*/
|
|
31
23
|
private flush;
|
|
32
|
-
/**
|
|
33
|
-
* Start recording session.
|
|
34
|
-
* Safe against concurrent calls (returns existing startPromise).
|
|
35
|
-
*/
|
|
24
|
+
/** Concurrent-call safe — returns the in-flight startPromise. */
|
|
36
25
|
start(): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Internal start implementation. Checks stopRequested at each async boundary.
|
|
39
|
-
*/
|
|
26
|
+
/** Rechecks stopRequested at each async boundary so a mid-startup stop aborts cleanly. */
|
|
40
27
|
private doStart;
|
|
41
28
|
stop(): void;
|
|
42
29
|
getSessionId(): string;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Screen Share Service
|
|
3
|
-
* Manages screensharing state and provides shared access to the active MediaStream
|
|
4
|
-
* for use across the widget (chatWindow, toolExecutor, etc.)
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Start screen sharing. If already active, returns the existing stream.
|
|
8
|
-
* @returns Promise resolving to the MediaStream
|
|
9
|
-
*/
|
|
1
|
+
/** Reuses the existing stream if one is still active. */
|
|
10
2
|
export declare function startScreenShare(): Promise<MediaStream>;
|
|
11
3
|
export declare function stopScreenShare(): void;
|
|
12
4
|
export declare function isScreenSharing(): boolean;
|