@marketrix.ai/widget 4.0.108 → 4.0.110

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.
@@ -122,9 +122,9 @@ export declare const WidgetEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
122
122
  }, z.core.$strip>, z.ZodObject<{
123
123
  type: z.ZodLiteral<"task/status">;
124
124
  status: z.ZodEnum<{
125
- running: "running";
126
125
  completed: "completed";
127
126
  failed: "failed";
127
+ running: "running";
128
128
  stopped: "stopped";
129
129
  has_question: "has_question";
130
130
  }>;
@@ -593,7 +593,7 @@ export declare const widgetStream: import("@orpc/contract").ContractProcedureBui
593
593
  error: string;
594
594
  } | {
595
595
  type: "task/status";
596
- status: "running" | "completed" | "failed" | "stopped" | "has_question";
596
+ status: "completed" | "failed" | "running" | "stopped" | "has_question";
597
597
  message?: string | undefined;
598
598
  } | {
599
599
  type: "tool/call";
@@ -621,7 +621,7 @@ export declare const widgetStream: import("@orpc/contract").ContractProcedureBui
621
621
  error: string;
622
622
  } | {
623
623
  type: "task/status";
624
- status: "running" | "completed" | "failed" | "stopped" | "has_question";
624
+ status: "completed" | "failed" | "running" | "stopped" | "has_question";
625
625
  message?: string | undefined;
626
626
  } | {
627
627
  type: "tool/call";
@@ -1088,7 +1088,7 @@ export declare const widgetRoutes: {
1088
1088
  error: string;
1089
1089
  } | {
1090
1090
  type: "task/status";
1091
- status: "running" | "completed" | "failed" | "stopped" | "has_question";
1091
+ status: "completed" | "failed" | "running" | "stopped" | "has_question";
1092
1092
  message?: string | undefined;
1093
1093
  } | {
1094
1094
  type: "tool/call";
@@ -1116,7 +1116,7 @@ export declare const widgetRoutes: {
1116
1116
  error: string;
1117
1117
  } | {
1118
1118
  type: "task/status";
1119
- status: "running" | "completed" | "failed" | "stopped" | "has_question";
1119
+ status: "completed" | "failed" | "running" | "stopped" | "has_question";
1120
1120
  message?: string | undefined;
1121
1121
  } | {
1122
1122
  type: "tool/call";
@@ -170,7 +170,7 @@ export declare const sdk: {
170
170
  error: string;
171
171
  } | {
172
172
  type: "task/status";
173
- status: "running" | "completed" | "failed" | "stopped" | "has_question";
173
+ status: "completed" | "failed" | "running" | "stopped" | "has_question";
174
174
  message?: string | undefined;
175
175
  } | {
176
176
  type: "tool/call";
@@ -198,7 +198,7 @@ export declare const sdk: {
198
198
  error: string;
199
199
  } | {
200
200
  type: "task/status";
201
- status: "running" | "completed" | "failed" | "stopped" | "has_question";
201
+ status: "completed" | "failed" | "running" | "stopped" | "has_question";
202
202
  message?: string | undefined;
203
203
  } | {
204
204
  type: "tool/call";
@@ -1,25 +1,28 @@
1
1
  /**
2
- * Browser-local persistence for the widget: the one door to `localStorage`, and the per-tenant chat context
3
- * (chat_id, transcript, composer mode, open state, resolved config) behind the `storageService` singleton.
4
- * `tenantScope` is the scope suffix for every browser-local key — the credential id, else the application id, else
5
- * `default` shared with the drag-position and resize keys so all of them partition the same way. `readLocal` /
6
- * `writeLocal` are the only `localStorage` access in `src/`; a host page can deny storage outright (third-party
7
- * cookies off, sandboxed iframe) where even reading throws, so both degrade to a warn and the widget keeps working
8
- * unpersisted. `loadContext` parses one key merged over `DEFAULT_CONTEXT`, so a payload from an older widget
9
- * version reads as incomplete rather than corrupt, and discards anything older than `CONTEXT_EXPIRY_MS` (7 days).
10
- * `StorageService`'s `getContext`, `updateContext` (merges, restamps `timestamp`, writes through), `getChatId` /
11
- * `setChatId`, `getCredentialedConfig` (null unless both `mtxId` and `mtxKey` are present, so callers cannot
12
- * dispatch half-credentialed) and `setConfig` sit behind the singleton; `readChatSnapshot` / `writeChatSnapshot`
13
- * are the UI-facing view of the context. `setConfig` re-keys storage to `${STORAGE_KEY}_${tenantScope}` and
14
- * reloads from that key, since without it two applications embedded on one origin would share a stored chat_id and
15
- * one tenant's transcript would leak into another's.
2
+ * Browser-local persistence for the widget: the one door to `localStorage`, and the per-tenant chat
3
+ * context (chat_id, transcript, composer mode, open state, resolved config) behind the `storageService`
4
+ * singleton. `tenantScope` (credential id, else application id, else `default`) is the scope suffix every
5
+ * browser-local key shares via `scopedKey`, so the chat-context, drag-position and resize keys all
6
+ * partition by tenant identically. `readLocal`/`writeLocal` are the only `localStorage` access in `src/`;
7
+ * a host page can deny storage outright (third-party cookies off, sandboxed iframe), so both degrade to
8
+ * a warn and the widget keeps working unpersisted.
16
9
  *
17
- * The snapshot is `{messages, currentMode, isOpen}` chat_id, config and timestamp are deliberately excluded.
18
- * Reading revives `timestamp` to a `Date` and backfills a text part for messages stored before `parts` existed;
19
- * writing drops `videoStream` (unserializable, dead on reload), rewriting it as `Screen sharing ended`.
10
+ * `loadContext` merges one parsed key over `DEFAULT_CONTEXT`, so an older widget version's payload reads
11
+ * as incomplete rather than corrupt, and discards anything past `CONTEXT_EXPIRY_MS` (7 days).
12
+ * `getCredentialedConfig` is null unless both `mtxId` and `mtxKey` are present, so callers cannot
13
+ * dispatch half-credentialed. `setConfig` re-keys storage to `${STORAGE_KEY}_${tenantScope}` and reloads
14
+ * from it, since without that two applications on one origin would leak one tenant's transcript into
15
+ * another's.
20
16
  *
21
- * `scopedKey(name, config)` is the one place `<name>_<tenantScope>` is assembled the position and resize-size
22
- * keys share it with the chat context key, so all three browser-local entries partition by tenant identically.
17
+ * The chat snapshot is `{messages, currentMode, isOpen}` chat_id, config and timestamp are deliberately
18
+ * excluded. Reading revives `timestamp` to a `Date` and backfills a text part for messages stored before
19
+ * `parts` existed; writing drops `videoStream` (unserializable, dead on reload), rewriting it as "Screen
20
+ * sharing ended".
21
+ *
22
+ * `sanitizeStoredContext` is hand-rolled, not zod, per the package-level rule that a schema imported as a
23
+ * VALUE anywhere reachable from `src/index.tsx` pulls zod's whole runtime into the bundle. Each field
24
+ * falls back to `DEFAULT_CONTEXT`'s value individually, so a partially-corrupt payload keeps the fields
25
+ * that DID parse rather than discarding the whole context.
23
26
  */
24
27
  import type { ChatMessage, InstructionType, MarketrixConfig, ValidWidgetConfig } from '../types';
25
28
  type StoredMessage = Omit<ChatMessage, 'videoStream' | 'timestamp'> & {
@@ -1,3 +1,4 @@
1
+ import type { CredentialedConfig } from '../services/StorageService';
1
2
  import type { ChatMessage, ValidWidgetConfig, WidgetSettingsData } from '../types';
2
3
  export declare const flushMicrotasks: () => Promise<void>;
3
4
  export declare const mountTarget: () => HTMLDivElement;
@@ -5,4 +6,5 @@ export declare function agentMessage(overrides?: Partial<ChatMessage>): ChatMess
5
6
  type MockWidgetConfig = ValidWidgetConfig & Pick<WidgetSettingsData, 'widget_border_radius' | 'widget_font_size' | 'widget_animation_duration' | 'widget_fade_duration'>;
6
7
  export declare function getMockWidgetConfig(overrides?: Partial<MockWidgetConfig>): MockWidgetConfig;
7
8
  export declare function validSettings(overrides?: Partial<MockWidgetConfig>): WidgetSettingsData;
9
+ export declare function credentialedConfig(overrides?: Partial<CredentialedConfig>): CredentialedConfig;
8
10
  export {};
@@ -40,14 +40,14 @@ export interface ChatMessage {
40
40
  content: string;
41
41
  sender: 'user' | 'agent';
42
42
  timestamp: Date;
43
- mode?: InstructionType;
43
+ mode?: InstructionType | undefined;
44
44
  videoStream?: MediaStream;
45
45
  isScreenAccessRequest?: boolean;
46
46
  screenShareStatus?: 'allowed' | 'denied';
47
- pendingContent?: string;
47
+ pendingContent?: string | undefined;
48
48
  isSystemMessage?: boolean;
49
- isPlaceholder?: boolean;
50
- placeholderState?: 'thinking' | 'waiting-for-user';
49
+ isPlaceholder?: boolean | undefined;
50
+ placeholderState?: 'thinking' | 'waiting-for-user' | undefined;
51
51
  parts: MessagePart[];
52
52
  taskStatus?: 'done' | 'failed' | 'stopped';
53
53
  }
@@ -65,7 +65,7 @@ export interface WidgetState {
65
65
  isAwaitingReply: boolean;
66
66
  messages: ChatMessage[];
67
67
  currentMode: InstructionType;
68
- error?: string;
68
+ error?: string | undefined;
69
69
  isTaskRunning: boolean;
70
70
  activeView: WidgetView;
71
71
  }