@modelnex/sdk 0.1.1 → 0.5.3

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
@@ -1,66 +1,140 @@
1
1
  # @modelnex/sdk
2
2
 
3
- React SDK for natural language control of web apps. Register actions and context; an AI agent executes actions in response to user commands.
3
+ React SDK for ModelNex agent chat, tours, and guided onboarding.
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- npm install @modelnex/sdk react zod
8
+ npm install @modelnex/sdk react react-dom zod
9
9
  ```
10
10
 
11
+ ## Unit Tests
12
+
13
+ Run the SDK unit tests from the `sdk` package directory:
14
+
15
+ ```bash
16
+ cd sdk
17
+ npm test
18
+ ```
19
+
20
+ The SDK test script builds `dist/` first, then runs the unit tests.
21
+
11
22
  ## Quick Start
12
23
 
13
24
  ```tsx
14
- import { ModelNexProvider, ModelNexChatBubble } from "@modelnex/sdk";
15
-
16
- function App() {
17
- const [items, setItems] = React.useState([]);
25
+ import { ModelNexProvider, ModelNexChatBubble } from '@modelnex/sdk';
18
26
 
27
+ export default function AppShell() {
19
28
  return (
20
- <div>
21
- <ModelNexChatBubble placeholder="Add item, list all..." />
22
- <ul>{items.map(i => <li key={i.id}>{i.title}</li>)}</ul>
23
- </div>
29
+ <ModelNexProvider
30
+ websiteId="your-website-id"
31
+ userProfile={{
32
+ type: currentUser.role,
33
+ isNewUser: currentUser.isNewUser,
34
+ userId: currentUser.id,
35
+ }}
36
+ tourFacts={{
37
+ features: currentUser.enabledFeatures,
38
+ }}
39
+ >
40
+ <App />
41
+ <ModelNexChatBubble appName="My Product" />
42
+ </ModelNexProvider>
24
43
  );
25
44
  }
26
-
27
- // Wrap your app (serverUrl defaults to http://localhost:3002)
28
- export default () => (
29
- <ModelNexProvider>
30
- <App />
31
- </ModelNexProvider>
32
- );
33
45
  ```
34
46
 
35
- ## Exports
47
+ `websiteId` identifies the integration. `userProfile` is used for tour/onboarding targeting and completion tracking. `tourFacts.features` is used for `feature_unlocked` experiences.
48
+
49
+ ## Tour Start Model
50
+
51
+ ModelNex currently supports these automatic trigger types:
52
+
53
+ - `first_visit`
54
+ - `feature_unlocked`
55
+ - `manual`
56
+
57
+ Each tour or onboarding flow can also configure:
58
+
59
+ - `startPolicy`: `immediate_start` | `prompt_only` | `manual_only`
60
+ - `notificationType`: `bubble_card` | `modal`
61
+
62
+ Current behavior:
63
+
64
+ - `prompt_only + bubble_card` shows an in-bubble prompt
65
+ - `prompt_only + modal` shows a centered modal
66
+ - `immediate_start` starts playback immediately
67
+ - `manual_only` never auto-surfaces
68
+
69
+ ## Main Exports
36
70
 
37
71
  | Export | Purpose |
38
72
  |--------|---------|
39
- | `ModelNexProvider` | Wraps app, connects to agent server |
40
- | `useRunCommand` | Run commands programmatically (for custom UI) |
41
- | `UIStateProvider` | Holds UI state synced to agent |
42
- | `useUIState` | Read/update UI state |
43
- | `useViewportTrack` | Track element visibility |
44
- | `useVisibleIds` | Get visible element IDs |
45
- | `useAgentViewport` | Register visible IDs with agent |
46
- | `ModelNexChatBubble` | Optional chat bubble UI |
73
+ | `ModelNexProvider` | Root provider for server connection, chat state, dev tools, tours, and onboarding |
74
+ | `ModelNexChatBubble` | Unified assistant UI for chat, voice tours, and guided onboarding |
75
+ | `useRunCommand` | Run agent commands from custom UI |
76
+ | `useRegisterAction` | Register app actions the agent can execute |
77
+ | `useTourPlayback` | Low-level playback hook for tours and shared experience runtime |
78
+ | `useOnboardingPlayback` | Playback hook preconfigured for onboarding flows |
79
+ | `useExperiencePlayback` | Alias over the shared playback hook |
80
+ | `useRecordingMode` | Low-level recorder hook for custom authoring UI |
81
+ | `useActionHighlight` | Highlight actions currently being executed |
82
+ | `UIStateProvider`, `useUIState` | Sync UI state to the agent |
83
+ | `useViewportTrack`, `useVisibleIds`, `useAgentViewport` | Track and expose visible UI to the agent |
84
+
85
+ ## Provider Props
86
+
87
+ | Prop | Purpose |
88
+ |------|---------|
89
+ | `serverUrl` | ModelNex server base URL. Defaults to `https://api.modelnex.io` |
90
+ | `commandUrl` | Optional same-origin command proxy base |
91
+ | `websiteId` | Tenant/integration identifier |
92
+ | `userProfile` | End-user targeting data for tours/onboarding |
93
+ | `tourFacts` | Additional facts, currently used for feature-based eligibility |
94
+ | `toursApiBase` | Same-origin API base for tour/onboarding fetches and test URLs |
95
+ | `devMode` | Enables recording/studio tooling for your internal users |
96
+
97
+ ## Chat Bubble Props
98
+
99
+ | Prop | Purpose |
100
+ |------|---------|
101
+ | `placeholder` | Input placeholder |
102
+ | `defaultCommand` | Fallback command when the input is empty |
103
+ | `welcomeMessage` | Empty-state greeting |
104
+ | `appName` | Product name used in narration and UI copy |
105
+ | `onCommand` | Custom backend override for agent command handling |
106
+ | `recordingExperienceType` | Save recordings as `'tour'` or `'onboarding'` |
107
+ | `className` | Additional class name for the container |
108
+
109
+ ## Testing Flows
110
+
111
+ - Force a tour with `?modelnex_test_tour=TOUR_ID`
112
+ - Force onboarding with `?modelnex_test_onboarding=FLOW_ID`
113
+ - If you use a same-origin proxy, set `toursApiBase` so test fetches avoid CORS issues
47
114
 
48
115
  ## Custom UI
49
116
 
50
- Use `useRunCommand` instead of `ModelNexChatBubble` for your own command UI:
117
+ Use `useRunCommand` instead of `ModelNexChatBubble` when you want your own assistant UI:
51
118
 
52
119
  ```tsx
53
- const runCommand = useRunCommand();
120
+ import { useRunCommand } from '@modelnex/sdk';
54
121
 
55
- <button onClick={() => runCommand("Add a new card")}>Run</button>
122
+ function MyButton() {
123
+ const runCommand = useRunCommand();
124
+ return <button onClick={() => runCommand('Open billing settings')}>Run</button>;
125
+ }
56
126
  ```
57
127
 
58
-
59
128
  ## Peer Dependencies
60
129
 
61
130
  - `react` >= 17
131
+ - `react-dom` >= 17
62
132
  - `zod` >= 3
63
133
 
64
134
  ## License
65
135
 
66
136
  MIT
137
+
138
+ ## Releasing
139
+
140
+ Releases are published by GitHub Actions from version tags only. See [RELEASING.md](./RELEASING.md).
@@ -0,0 +1,10 @@
1
+ import {
2
+ clearAOMMap,
3
+ generateMinifiedAOM,
4
+ getElementByUid
5
+ } from "./chunk-N65UEB6X.mjs";
6
+ export {
7
+ clearAOMMap,
8
+ generateMinifiedAOM,
9
+ getElementByUid
10
+ };
@@ -62,8 +62,9 @@ function clearAOMMap() {
62
62
  uidMap.clear();
63
63
  nextUid = 1;
64
64
  }
65
+
65
66
  export {
66
- clearAOMMap,
67
67
  generateMinifiedAOM,
68
- getElementByUid
68
+ getElementByUid,
69
+ clearAOMMap
69
70
  };