@modelnex/sdk 0.5.5 → 0.5.7

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/README.md CHANGED
@@ -33,9 +33,6 @@ export default function AppShell() {
33
33
  isNewUser: currentUser.isNewUser,
34
34
  userId: currentUser.id,
35
35
  }}
36
- tourFacts={{
37
- features: currentUser.enabledFeatures,
38
- }}
39
36
  >
40
37
  <App />
41
38
  <ModelNexChatBubble appName="My Product" />
@@ -44,7 +41,7 @@ export default function AppShell() {
44
41
  }
45
42
  ```
46
43
 
47
- `websiteId` identifies the integration. `userProfile` is used for tour/workflow targeting and completion tracking. `tourFacts.features` is used for `feature_unlocked` experiences.
44
+ `websiteId` identifies the integration. `userProfile` is used for tour/workflow targeting and completion tracking.
48
45
 
49
46
  ## Tour Start Model
50
47
 
@@ -85,12 +82,8 @@ Current behavior:
85
82
 
86
83
  | Prop | Purpose |
87
84
  |------|---------|
88
- | `serverUrl` | ModelNex server base URL. Defaults to `https://api.modelnex.io` |
89
- | `commandUrl` | Optional same-origin command proxy base |
90
85
  | `websiteId` | Tenant/integration identifier |
91
86
  | `userProfile` | End-user targeting data for tours/workflows |
92
- | `tourFacts` | Additional facts, currently used for feature-based eligibility |
93
- | `toursApiBase` | Same-origin API base for tour/workflow fetches and test URLs |
94
87
  | `devMode` | Enables recording/studio tooling for your internal users |
95
88
 
96
89
  ## Chat Bubble Props
@@ -119,14 +112,10 @@ import { ModelNexProvider } from '@modelnex/sdk';
119
112
  export function AppShell({ children, currentUser }) {
120
113
  return (
121
114
  <ModelNexProvider
122
- // Basic Setup
123
- serverUrl="https://api.yourdomain.com/modelnex"
124
115
  websiteId="prod_site_123"
125
116
 
126
- // Development and Proxy setup
117
+ // Development setup
127
118
  devMode={process.env.NODE_ENV === 'development'}
128
- commandUrl="/api/modelnex/command" // Proxies commands through your own API
129
- toursApiBase="/api/tours" // Proxies tour fetches to avoid CORS
130
119
 
131
120
  // User Targeting for Tours & Workflows
132
121
  userProfile={{
@@ -134,11 +123,6 @@ export function AppShell({ children, currentUser }) {
134
123
  isNewUser: currentUser.createdAt > Date.now() - 86400000 * 7, // 7 days
135
124
  type: currentUser.role, // e.g. "admin", "viewer"
136
125
  }}
137
-
138
- // Additional facts for Feature-Gated Tours
139
- tourFacts={{
140
- features: currentUser.enabledFeatures, // e.g. ["billing", "advanced_reporting"]
141
- }}
142
126
  >
143
127
  {children}
144
128
  </ModelNexProvider>
@@ -183,7 +167,6 @@ export function ChatIntegration() {
183
167
 
184
168
  - Force a tour with `?modelnex_test_tour=TOUR_ID`
185
169
  - Force a workflow with `?modelnex_test_workflow=FLOW_ID`
186
- - If you use a same-origin proxy, set `toursApiBase` so test fetches avoid CORS issues
187
170
 
188
171
  ## Custom UI
189
172
 
package/dist/index.js CHANGED
@@ -739,32 +739,64 @@ function captureDomSummary(tags) {
739
739
  var import_zod = require("zod");
740
740
  function zodToJsonSchema(schema) {
741
741
  if (!schema) return {};
742
- const def = schema._def;
742
+ const schemaWithCompat = schema;
743
+ if (typeof schemaWithCompat.toJSONSchema === "function") {
744
+ try {
745
+ return schemaWithCompat.toJSONSchema();
746
+ } catch {
747
+ }
748
+ }
749
+ const def = schemaWithCompat._def ?? schemaWithCompat.def;
743
750
  if (!def) return {};
744
- if (def.typeName === import_zod.z.ZodFirstPartyTypeKind.ZodObject) {
745
- const shape = schema.shape;
751
+ const typeName = def.typeName ?? def.type;
752
+ const getShape = (value) => {
753
+ if (value.shape) return value.shape;
754
+ const valueDef = value._def ?? value.def;
755
+ const defShape = valueDef?.shape;
756
+ return typeof defShape === "function" ? defShape() : defShape;
757
+ };
758
+ const getInnerType = (value) => {
759
+ const valueDef = value._def ?? value.def;
760
+ return valueDef?.innerType;
761
+ };
762
+ const getDescription = (value) => {
763
+ const valueWithCompat = value;
764
+ return valueWithCompat.description ?? valueWithCompat._def?.description ?? valueWithCompat.def?.description;
765
+ };
766
+ if (typeName === import_zod.z.ZodFirstPartyTypeKind.ZodObject || typeName === "object") {
767
+ const shape = getShape(schemaWithCompat);
768
+ if (!shape) return {};
746
769
  const properties = {};
747
770
  const required = [];
748
771
  for (const key in shape) {
749
772
  let isOptional = false;
750
773
  let fieldSchema = shape[key];
751
- if (fieldSchema._def.typeName === import_zod.z.ZodFirstPartyTypeKind.ZodOptional) {
774
+ const fieldDef = fieldSchema._def ?? fieldSchema.def;
775
+ const fieldTypeName = fieldDef?.typeName ?? fieldDef?.type;
776
+ if (fieldTypeName === import_zod.z.ZodFirstPartyTypeKind.ZodOptional || fieldTypeName === "optional") {
752
777
  isOptional = true;
753
- fieldSchema = fieldSchema._def.innerType;
778
+ fieldSchema = getInnerType(fieldSchema) ?? fieldSchema;
754
779
  }
755
780
  properties[key] = zodToJsonSchema(fieldSchema);
756
- if (fieldSchema._def.description || shape[key]._def.description) {
757
- properties[key].description = fieldSchema._def.description || shape[key]._def.description;
781
+ const description = getDescription(fieldSchema) ?? getDescription(shape[key]);
782
+ if (description) {
783
+ properties[key].description = description;
758
784
  }
759
785
  if (!isOptional) required.push(key);
760
786
  }
761
787
  return { type: "object", properties, required };
762
788
  }
763
- if (def.typeName === import_zod.z.ZodFirstPartyTypeKind.ZodString) return { type: "string" };
764
- if (def.typeName === import_zod.z.ZodFirstPartyTypeKind.ZodNumber) return { type: "number" };
765
- if (def.typeName === import_zod.z.ZodFirstPartyTypeKind.ZodBoolean) return { type: "boolean" };
766
- if (def.typeName === import_zod.z.ZodFirstPartyTypeKind.ZodEnum) return { type: "string", enum: def.values };
767
- if (def.typeName === import_zod.z.ZodFirstPartyTypeKind.ZodArray) return { type: "array", items: zodToJsonSchema(def.type) };
789
+ if (typeName === import_zod.z.ZodFirstPartyTypeKind.ZodString || typeName === "string") return { type: "string" };
790
+ if (typeName === import_zod.z.ZodFirstPartyTypeKind.ZodNumber || typeName === "number") return { type: "number" };
791
+ if (typeName === import_zod.z.ZodFirstPartyTypeKind.ZodBoolean || typeName === "boolean") return { type: "boolean" };
792
+ if (typeName === import_zod.z.ZodFirstPartyTypeKind.ZodEnum || typeName === "enum") {
793
+ const values = def.values ?? Object.values(def.entries ?? {});
794
+ return { type: "string", enum: values };
795
+ }
796
+ if (typeName === import_zod.z.ZodFirstPartyTypeKind.ZodArray || typeName === "array") {
797
+ const arrayType = def.type ?? def.element;
798
+ return { type: "array", items: zodToJsonSchema(arrayType ?? {}) };
799
+ }
768
800
  return {};
769
801
  }
770
802
  function serializeActions(actions) {
@@ -2249,7 +2281,7 @@ function useBuiltinActions(registerAction, unregisterAction, tagStore, serverUrl
2249
2281
 
2250
2282
  // src/hooks/useRunCommand.ts
2251
2283
  var import_react9 = require("react");
2252
- var DEFAULT_SERVER_URL = "http://localhost:3002";
2284
+ var DEFAULT_SERVER_URL = "https://69tgf4aic6.us-east-1.awsapprunner.com";
2253
2285
  function searchTaggedElementsForQuery(store, query, limit = 8) {
2254
2286
  const allTags = store.getAllTags();
2255
2287
  if (allTags.length === 0) return [];
@@ -8339,7 +8371,7 @@ function ModelNexChatBubble({
8339
8371
  const messagesEndRef = (0, import_react18.useRef)(null);
8340
8372
  const abortControllerRef = (0, import_react18.useRef)(null);
8341
8373
  const panelRef = (0, import_react18.useRef)(null);
8342
- const serverUrl = ctx?.serverUrl ?? "http://localhost:3002";
8374
+ const serverUrl = ctx?.serverUrl ?? "https://69tgf4aic6.us-east-1.awsapprunner.com";
8343
8375
  const voice = useVoice(serverUrl);
8344
8376
  const audioLevels = useAudioLevel(voice.isListening);
8345
8377
  const recordingMode = ctx?.recordingMode ?? false;
@@ -8426,7 +8458,7 @@ function ModelNexChatBubble({
8426
8458
  if (lastAutoTaggedUrlRef.current === currentUrl || localStorage.getItem(storageKey)) {
8427
8459
  return;
8428
8460
  }
8429
- const baseUrl = commandUrl ?? serverUrl2 ?? "http://localhost:3002";
8461
+ const baseUrl = commandUrl ?? serverUrl2 ?? "https://69tgf4aic6.us-east-1.awsapprunner.com";
8430
8462
  const url = baseUrl.startsWith("/") ? `${window.location.origin}${baseUrl}/agent/auto-tag` : `${baseUrl}/agent/auto-tag`;
8431
8463
  const elements = extractedElements.map((el) => ({
8432
8464
  fingerprint: el.fingerprint,
@@ -8830,7 +8862,7 @@ function ModelNexChatBubble({
8830
8862
  }
8831
8863
  };
8832
8864
  const stopAgent = async () => {
8833
- const baseUrl = ctx?.commandUrl ?? ctx?.serverUrl ?? "http://localhost:3002";
8865
+ const baseUrl = ctx?.commandUrl ?? ctx?.serverUrl ?? "https://69tgf4aic6.us-east-1.awsapprunner.com";
8834
8866
  const abortUrl = baseUrl.startsWith("/") ? `${window.location.origin}${baseUrl}/agent/abort` : `${baseUrl}/agent/abort`;
8835
8867
  try {
8836
8868
  await fetch(abortUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ socketId: ctx?.socketId }) });
@@ -10088,7 +10120,7 @@ function ModelNexOnboardingPanel({
10088
10120
  title = "Getting Started"
10089
10121
  }) {
10090
10122
  const ctx = (0, import_react19.useContext)(ModelNexContext);
10091
- const serverUrl = ctx?.serverUrl ?? "http://localhost:3002";
10123
+ const serverUrl = ctx?.serverUrl ?? "https://69tgf4aic6.us-east-1.awsapprunner.com";
10092
10124
  const voice = useVoice(serverUrl);
10093
10125
  const audioLevels = useAudioLevel(voice.isListening);
10094
10126
  const [input, setInput] = (0, import_react19.useState)("");
@@ -10828,7 +10860,7 @@ function TourProgressPanel({ tour, currentStepIndex, onSkip, voiceOnly }) {
10828
10860
  }
10829
10861
 
10830
10862
  // src/index.ts
10831
- var DEFAULT_SERVER_URL2 = "https://api.modelnex.io";
10863
+ var DEFAULT_SERVER_URL2 = "https://69tgf4aic6.us-east-1.awsapprunner.com";
10832
10864
  var ModelNexProvider = ({
10833
10865
  children,
10834
10866
  websiteId,
package/dist/index.mjs CHANGED
@@ -530,32 +530,64 @@ function captureDomSummary(tags) {
530
530
  import { z } from "zod";
531
531
  function zodToJsonSchema(schema) {
532
532
  if (!schema) return {};
533
- const def = schema._def;
533
+ const schemaWithCompat = schema;
534
+ if (typeof schemaWithCompat.toJSONSchema === "function") {
535
+ try {
536
+ return schemaWithCompat.toJSONSchema();
537
+ } catch {
538
+ }
539
+ }
540
+ const def = schemaWithCompat._def ?? schemaWithCompat.def;
534
541
  if (!def) return {};
535
- if (def.typeName === z.ZodFirstPartyTypeKind.ZodObject) {
536
- const shape = schema.shape;
542
+ const typeName = def.typeName ?? def.type;
543
+ const getShape = (value) => {
544
+ if (value.shape) return value.shape;
545
+ const valueDef = value._def ?? value.def;
546
+ const defShape = valueDef?.shape;
547
+ return typeof defShape === "function" ? defShape() : defShape;
548
+ };
549
+ const getInnerType = (value) => {
550
+ const valueDef = value._def ?? value.def;
551
+ return valueDef?.innerType;
552
+ };
553
+ const getDescription = (value) => {
554
+ const valueWithCompat = value;
555
+ return valueWithCompat.description ?? valueWithCompat._def?.description ?? valueWithCompat.def?.description;
556
+ };
557
+ if (typeName === z.ZodFirstPartyTypeKind.ZodObject || typeName === "object") {
558
+ const shape = getShape(schemaWithCompat);
559
+ if (!shape) return {};
537
560
  const properties = {};
538
561
  const required = [];
539
562
  for (const key in shape) {
540
563
  let isOptional = false;
541
564
  let fieldSchema = shape[key];
542
- if (fieldSchema._def.typeName === z.ZodFirstPartyTypeKind.ZodOptional) {
565
+ const fieldDef = fieldSchema._def ?? fieldSchema.def;
566
+ const fieldTypeName = fieldDef?.typeName ?? fieldDef?.type;
567
+ if (fieldTypeName === z.ZodFirstPartyTypeKind.ZodOptional || fieldTypeName === "optional") {
543
568
  isOptional = true;
544
- fieldSchema = fieldSchema._def.innerType;
569
+ fieldSchema = getInnerType(fieldSchema) ?? fieldSchema;
545
570
  }
546
571
  properties[key] = zodToJsonSchema(fieldSchema);
547
- if (fieldSchema._def.description || shape[key]._def.description) {
548
- properties[key].description = fieldSchema._def.description || shape[key]._def.description;
572
+ const description = getDescription(fieldSchema) ?? getDescription(shape[key]);
573
+ if (description) {
574
+ properties[key].description = description;
549
575
  }
550
576
  if (!isOptional) required.push(key);
551
577
  }
552
578
  return { type: "object", properties, required };
553
579
  }
554
- if (def.typeName === z.ZodFirstPartyTypeKind.ZodString) return { type: "string" };
555
- if (def.typeName === z.ZodFirstPartyTypeKind.ZodNumber) return { type: "number" };
556
- if (def.typeName === z.ZodFirstPartyTypeKind.ZodBoolean) return { type: "boolean" };
557
- if (def.typeName === z.ZodFirstPartyTypeKind.ZodEnum) return { type: "string", enum: def.values };
558
- if (def.typeName === z.ZodFirstPartyTypeKind.ZodArray) return { type: "array", items: zodToJsonSchema(def.type) };
580
+ if (typeName === z.ZodFirstPartyTypeKind.ZodString || typeName === "string") return { type: "string" };
581
+ if (typeName === z.ZodFirstPartyTypeKind.ZodNumber || typeName === "number") return { type: "number" };
582
+ if (typeName === z.ZodFirstPartyTypeKind.ZodBoolean || typeName === "boolean") return { type: "boolean" };
583
+ if (typeName === z.ZodFirstPartyTypeKind.ZodEnum || typeName === "enum") {
584
+ const values = def.values ?? Object.values(def.entries ?? {});
585
+ return { type: "string", enum: values };
586
+ }
587
+ if (typeName === z.ZodFirstPartyTypeKind.ZodArray || typeName === "array") {
588
+ const arrayType = def.type ?? def.element;
589
+ return { type: "array", items: zodToJsonSchema(arrayType ?? {}) };
590
+ }
559
591
  return {};
560
592
  }
561
593
  function serializeActions(actions) {
@@ -2040,7 +2072,7 @@ function useBuiltinActions(registerAction, unregisterAction, tagStore, serverUrl
2040
2072
 
2041
2073
  // src/hooks/useRunCommand.ts
2042
2074
  import { useCallback as useCallback5, useContext as useContext2 } from "react";
2043
- var DEFAULT_SERVER_URL = "http://localhost:3002";
2075
+ var DEFAULT_SERVER_URL = "https://69tgf4aic6.us-east-1.awsapprunner.com";
2044
2076
  function searchTaggedElementsForQuery(store, query, limit = 8) {
2045
2077
  const allTags = store.getAllTags();
2046
2078
  if (allTags.length === 0) return [];
@@ -8129,7 +8161,7 @@ function ModelNexChatBubble({
8129
8161
  const messagesEndRef = useRef13(null);
8130
8162
  const abortControllerRef = useRef13(null);
8131
8163
  const panelRef = useRef13(null);
8132
- const serverUrl = ctx?.serverUrl ?? "http://localhost:3002";
8164
+ const serverUrl = ctx?.serverUrl ?? "https://69tgf4aic6.us-east-1.awsapprunner.com";
8133
8165
  const voice = useVoice(serverUrl);
8134
8166
  const audioLevels = useAudioLevel(voice.isListening);
8135
8167
  const recordingMode = ctx?.recordingMode ?? false;
@@ -8216,7 +8248,7 @@ function ModelNexChatBubble({
8216
8248
  if (lastAutoTaggedUrlRef.current === currentUrl || localStorage.getItem(storageKey)) {
8217
8249
  return;
8218
8250
  }
8219
- const baseUrl = commandUrl ?? serverUrl2 ?? "http://localhost:3002";
8251
+ const baseUrl = commandUrl ?? serverUrl2 ?? "https://69tgf4aic6.us-east-1.awsapprunner.com";
8220
8252
  const url = baseUrl.startsWith("/") ? `${window.location.origin}${baseUrl}/agent/auto-tag` : `${baseUrl}/agent/auto-tag`;
8221
8253
  const elements = extractedElements.map((el) => ({
8222
8254
  fingerprint: el.fingerprint,
@@ -8620,7 +8652,7 @@ function ModelNexChatBubble({
8620
8652
  }
8621
8653
  };
8622
8654
  const stopAgent = async () => {
8623
- const baseUrl = ctx?.commandUrl ?? ctx?.serverUrl ?? "http://localhost:3002";
8655
+ const baseUrl = ctx?.commandUrl ?? ctx?.serverUrl ?? "https://69tgf4aic6.us-east-1.awsapprunner.com";
8624
8656
  const abortUrl = baseUrl.startsWith("/") ? `${window.location.origin}${baseUrl}/agent/abort` : `${baseUrl}/agent/abort`;
8625
8657
  try {
8626
8658
  await fetch(abortUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ socketId: ctx?.socketId }) });
@@ -9878,7 +9910,7 @@ function ModelNexOnboardingPanel({
9878
9910
  title = "Getting Started"
9879
9911
  }) {
9880
9912
  const ctx = useContext6(ModelNexContext);
9881
- const serverUrl = ctx?.serverUrl ?? "http://localhost:3002";
9913
+ const serverUrl = ctx?.serverUrl ?? "https://69tgf4aic6.us-east-1.awsapprunner.com";
9882
9914
  const voice = useVoice(serverUrl);
9883
9915
  const audioLevels = useAudioLevel(voice.isListening);
9884
9916
  const [input, setInput] = useState14("");
@@ -10618,7 +10650,7 @@ function TourProgressPanel({ tour, currentStepIndex, onSkip, voiceOnly }) {
10618
10650
  }
10619
10651
 
10620
10652
  // src/index.ts
10621
- var DEFAULT_SERVER_URL2 = "https://api.modelnex.io";
10653
+ var DEFAULT_SERVER_URL2 = "https://69tgf4aic6.us-east-1.awsapprunner.com";
10622
10654
  var ModelNexProvider = ({
10623
10655
  children,
10624
10656
  websiteId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelnex/sdk",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "React SDK for natural language control of web apps via AI agents",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",