@modelnex/sdk 0.5.28 → 0.5.30
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 +11 -5
- package/dist/dom-sync-GABDEODR.mjs +54 -0
- package/dist/index.d.mts +4 -8
- package/dist/index.d.ts +4 -8
- package/dist/index.js +268 -124
- package/dist/index.mjs +272 -127
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -86,7 +86,6 @@ Current behavior:
|
|
|
86
86
|
| `serverUrl` | Backend base URL for chat, tags, tours, voice, and recording APIs |
|
|
87
87
|
| `websiteId` | Tenant/integration identifier |
|
|
88
88
|
| `userProfile` | End-user targeting data for tours/workflows |
|
|
89
|
-
| `devMode` | Enables recording/studio tooling for your internal users |
|
|
90
89
|
|
|
91
90
|
## Chat Bubble Props
|
|
92
91
|
|
|
@@ -115,10 +114,7 @@ export function AppShell({ children, currentUser }) {
|
|
|
115
114
|
return (
|
|
116
115
|
<ModelNexProvider
|
|
117
116
|
websiteId="prod_site_123"
|
|
118
|
-
|
|
119
|
-
// Development setup
|
|
120
|
-
devMode={process.env.NODE_ENV === 'development'}
|
|
121
|
-
|
|
117
|
+
|
|
122
118
|
// User Targeting for Tours & Workflows
|
|
123
119
|
userProfile={{
|
|
124
120
|
userId: currentUser.id,
|
|
@@ -132,6 +128,16 @@ export function AppShell({ children, currentUser }) {
|
|
|
132
128
|
}
|
|
133
129
|
```
|
|
134
130
|
|
|
131
|
+
### Browser-Injected Dev Mode
|
|
132
|
+
|
|
133
|
+
```html
|
|
134
|
+
<script>
|
|
135
|
+
window.__MODELNEX_DEV_MODE_KEY__ = 'dmk_live_xxxxxxxxx';
|
|
136
|
+
</script>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The SDK now enables dev tooling only after it finds a browser-injected dev mode key and validates it with the backend for the current `websiteId`.
|
|
140
|
+
|
|
135
141
|
### Themed Chat Bubble
|
|
136
142
|
|
|
137
143
|
```tsx
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/utils/dom-sync.ts
|
|
2
|
+
function waitForDomSettle(options = {}) {
|
|
3
|
+
const { timeoutMs = 5e3, debounceMs = 400, minWaitMs = 100 } = options;
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
let debounceTimer = null;
|
|
6
|
+
let resolved = false;
|
|
7
|
+
const maxTimer = setTimeout(() => {
|
|
8
|
+
if (!resolved) {
|
|
9
|
+
resolved = true;
|
|
10
|
+
cleanup();
|
|
11
|
+
resolve();
|
|
12
|
+
}
|
|
13
|
+
}, Math.max(timeoutMs, minWaitMs));
|
|
14
|
+
const finish = () => {
|
|
15
|
+
if (!resolved) {
|
|
16
|
+
resolved = true;
|
|
17
|
+
cleanup();
|
|
18
|
+
resolve();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const observer = new MutationObserver((mutations) => {
|
|
22
|
+
const hasSignificantMutations = mutations.some((m) => {
|
|
23
|
+
if (m.target instanceof HTMLElement) {
|
|
24
|
+
if (m.target.hasAttribute("data-modelnex-tour-highlight")) return false;
|
|
25
|
+
if (m.target.hasAttribute("data-modelnex-caption")) return false;
|
|
26
|
+
if (m.target.closest("#modelnex-studio-root")) return false;
|
|
27
|
+
if (m.target.closest("#modelnex-active-agent-root")) return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
});
|
|
31
|
+
if (!hasSignificantMutations) return;
|
|
32
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
33
|
+
debounceTimer = setTimeout(finish, debounceMs);
|
|
34
|
+
});
|
|
35
|
+
const cleanup = () => {
|
|
36
|
+
observer.disconnect();
|
|
37
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
38
|
+
clearTimeout(maxTimer);
|
|
39
|
+
};
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
if (resolved) return;
|
|
42
|
+
observer.observe(document.body, {
|
|
43
|
+
childList: true,
|
|
44
|
+
subtree: true,
|
|
45
|
+
attributes: true,
|
|
46
|
+
characterData: true
|
|
47
|
+
});
|
|
48
|
+
debounceTimer = setTimeout(finish, debounceMs);
|
|
49
|
+
}, minWaitMs);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
waitForDomSettle
|
|
54
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -284,7 +284,7 @@ declare function extractInteractiveElements(): ExtractedElement[];
|
|
|
284
284
|
* Hook that automatically extracts all interactive DOM elements and keeps
|
|
285
285
|
* the list up-to-date via MutationObserver (debounced at 500ms).
|
|
286
286
|
*/
|
|
287
|
-
declare function useAutoExtract(): ExtractedElement[];
|
|
287
|
+
declare function useAutoExtract(devMode?: boolean): ExtractedElement[];
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
290
|
* Tag store for human-in-the-loop tagging.
|
|
@@ -346,10 +346,10 @@ interface AgentTraceLlmInput {
|
|
|
346
346
|
/** Single step in agent execution trace */
|
|
347
347
|
interface AgentTraceStep {
|
|
348
348
|
step: number;
|
|
349
|
-
/**
|
|
349
|
+
/** Internal reasoning is intentionally stripped from customer-visible traces */
|
|
350
350
|
reasoning?: string;
|
|
351
351
|
llmInput?: AgentTraceLlmInput;
|
|
352
|
-
llmOutput
|
|
352
|
+
llmOutput?: string;
|
|
353
353
|
actions: Array<{
|
|
354
354
|
actionId: string;
|
|
355
355
|
params?: Record<string, unknown>;
|
|
@@ -361,7 +361,7 @@ interface AgentTraceStep {
|
|
|
361
361
|
error?: string;
|
|
362
362
|
}>;
|
|
363
363
|
}
|
|
364
|
-
/**
|
|
364
|
+
/** Sanitized debug payload from /agent/command */
|
|
365
365
|
interface AgentDebug {
|
|
366
366
|
actions?: Array<{
|
|
367
367
|
actionId: string;
|
|
@@ -845,10 +845,6 @@ interface ModelNexProviderProps {
|
|
|
845
845
|
* Same-origin base for tour API (avoids CORS for ?modelnex_test_tour=)
|
|
846
846
|
*/
|
|
847
847
|
toursApiBase?: string;
|
|
848
|
-
/**
|
|
849
|
-
* Enable SDK dev tools unconditionally (tour recording, studio mode)
|
|
850
|
-
*/
|
|
851
|
-
devMode?: boolean;
|
|
852
848
|
}
|
|
853
849
|
declare const ModelNexProvider: React$1.FC<ModelNexProviderProps>;
|
|
854
850
|
|
package/dist/index.d.ts
CHANGED
|
@@ -284,7 +284,7 @@ declare function extractInteractiveElements(): ExtractedElement[];
|
|
|
284
284
|
* Hook that automatically extracts all interactive DOM elements and keeps
|
|
285
285
|
* the list up-to-date via MutationObserver (debounced at 500ms).
|
|
286
286
|
*/
|
|
287
|
-
declare function useAutoExtract(): ExtractedElement[];
|
|
287
|
+
declare function useAutoExtract(devMode?: boolean): ExtractedElement[];
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
290
|
* Tag store for human-in-the-loop tagging.
|
|
@@ -346,10 +346,10 @@ interface AgentTraceLlmInput {
|
|
|
346
346
|
/** Single step in agent execution trace */
|
|
347
347
|
interface AgentTraceStep {
|
|
348
348
|
step: number;
|
|
349
|
-
/**
|
|
349
|
+
/** Internal reasoning is intentionally stripped from customer-visible traces */
|
|
350
350
|
reasoning?: string;
|
|
351
351
|
llmInput?: AgentTraceLlmInput;
|
|
352
|
-
llmOutput
|
|
352
|
+
llmOutput?: string;
|
|
353
353
|
actions: Array<{
|
|
354
354
|
actionId: string;
|
|
355
355
|
params?: Record<string, unknown>;
|
|
@@ -361,7 +361,7 @@ interface AgentTraceStep {
|
|
|
361
361
|
error?: string;
|
|
362
362
|
}>;
|
|
363
363
|
}
|
|
364
|
-
/**
|
|
364
|
+
/** Sanitized debug payload from /agent/command */
|
|
365
365
|
interface AgentDebug {
|
|
366
366
|
actions?: Array<{
|
|
367
367
|
actionId: string;
|
|
@@ -845,10 +845,6 @@ interface ModelNexProviderProps {
|
|
|
845
845
|
* Same-origin base for tour API (avoids CORS for ?modelnex_test_tour=)
|
|
846
846
|
*/
|
|
847
847
|
toursApiBase?: string;
|
|
848
|
-
/**
|
|
849
|
-
* Enable SDK dev tools unconditionally (tour recording, studio mode)
|
|
850
|
-
*/
|
|
851
|
-
devMode?: boolean;
|
|
852
848
|
}
|
|
853
849
|
declare const ModelNexProvider: React$1.FC<ModelNexProviderProps>;
|
|
854
850
|
|