gz-research-assistant 0.1.0 → 0.1.1
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 +57 -21
- package/dist/{ResearchAssistant-DAsgcwcG.js → Assistant-DEhy-idh.js} +648 -529
- package/dist/Assistant-DEhy-idh.js.map +1 -0
- package/dist/Assistant.d.ts +12 -0
- package/dist/core.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{recorder-Da1VSLid.js → recorder-B_wXzg3N.js} +62 -54
- package/dist/recorder-B_wXzg3N.js.map +1 -0
- package/dist/runtime.d.ts +1 -0
- package/dist/sdk.d.ts +6 -3
- package/dist/sdk.js +27 -9
- package/dist/sdk.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/ResearchAssistant-DAsgcwcG.js.map +0 -1
- package/dist/recorder-Da1VSLid.js.map +0 -1
package/README.md
CHANGED
|
@@ -6,38 +6,74 @@ Installable research assistant with gz-ui components, diagnostics, recording, as
|
|
|
6
6
|
npm install gz-research-assistant @chenhui996/gg-ui @ant-design/icons antd react react-dom
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
## React component
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { ResearchAssistant, type ResearchAssistantProps } from 'gz-research-assistant';
|
|
13
|
+
import '@chenhui996/gg-ui/gg-ui.css';
|
|
14
|
+
import 'gz-research-assistant/style.css';
|
|
15
|
+
|
|
16
|
+
// Keep callback references stable (module scope or useCallback).
|
|
17
|
+
const options: ResearchAssistantProps = {
|
|
18
|
+
developer: true,
|
|
19
|
+
bridgeUrl: '/__laya-pilot',
|
|
20
|
+
themeMode: 'gold-dark',
|
|
21
|
+
runtimeOptions: {
|
|
22
|
+
isBusinessFailure: (body) =>
|
|
23
|
+
!!body && typeof body === 'object' && 'code' in body && body.code !== 0,
|
|
24
|
+
ignoreRequest: (url) => url.pathname.startsWith('/telemetry/'),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Render only after login; unmount on logout.
|
|
29
|
+
<ResearchAssistant {...options} sessionKey={userId} />;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Imperative SDK
|
|
33
|
+
|
|
9
34
|
```tsx
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
ResearchAssistant,
|
|
13
|
-
startAssistant,
|
|
14
|
-
assistantRuntime,
|
|
15
|
-
recorder,
|
|
16
|
-
} from 'gz-research-assistant';
|
|
35
|
+
import { mountAssistant } from 'gz-research-assistant/sdk';
|
|
17
36
|
import '@chenhui996/gg-ui/gg-ui.css';
|
|
18
37
|
import 'gz-research-assistant/style.css';
|
|
19
38
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, []);
|
|
29
|
-
return <ResearchAssistant developer bridgeUrl="/__laya-pilot" />;
|
|
30
|
-
}
|
|
39
|
+
// Same options as the React example; no separate SDK business implementation.
|
|
40
|
+
const assistant = mountAssistant(document.getElementById('assistant-root')!, {
|
|
41
|
+
...options,
|
|
42
|
+
sessionKey: userId,
|
|
43
|
+
});
|
|
44
|
+
assistant.update({ themeMode: 'blue-light' }); // Retains recording and evidence.
|
|
45
|
+
assistant.update({ sessionKey: nextUserId }); // Clears the previous session and resets the UI.
|
|
46
|
+
assistant(); // Logout/unmount: restores hooks, stops timers and recording, clears data.
|
|
31
47
|
```
|
|
32
48
|
|
|
33
|
-
|
|
49
|
+
The SDK mounts the exact public React component in its own React root. Both entrypoints use the same lifecycle, gz-ui provider, UI, collection, diagnostics, recording, assertion editor and bridge. Given the same options and browser environment, their behavior is the same. Mount only **one** assistant per page; do not combine React, SDK and manual `startAssistant()` ownership. The SDK retains the legacy third `runtimeOptions` argument, but passing all settings in the second argument is recommended. Calling its disposer more than once is safe.
|
|
34
50
|
|
|
35
|
-
|
|
51
|
+
`sessionKey` changes reset the entire assistant, including open tabs, drafts, imported/frozen snapshots and paused collection. Changing `themeMode` or `developer` retains data. Changing the bridge URL or runtime callbacks restarts collection and discards diagnostics and recorded cases. The host controls authentication and business response semantics; the package does not import a host store or read auth tokens. Bridge polling is excluded from Fetch and XHR collection automatically, including custom bridge URLs. Additional `ignoreRequest` filters apply to both APIs.
|
|
36
52
|
|
|
37
|
-
|
|
53
|
+
Theme defaults to `gold-dark`; pass the same `themeMode` to both integration styles to follow your application. Assistant styles use scoped `--ra-color-*` variables, independent of host `--app-*` variables. Both require the CSS imports and the same React/gz-ui peer dependencies. This SDK is an ESM npm entrypoint, not a dependency-free CDN script.
|
|
54
|
+
|
|
55
|
+
### Migrating from 0.1.0
|
|
56
|
+
|
|
57
|
+
React now starts/stops the collector automatically. **Remove the old `startAssistant()` effect or bootstrap** when rendering `<ResearchAssistant>`. Pass business filters via `runtimeOptions`, and provide `sessionKey` for account switching. Existing SDK `mountAssistant(container, props, options)` calls remain supported. For diagnostics without React UI, `gz-research-assistant/core` still exposes manual `startAssistant`, `assistantRuntime` and `recorder`; the caller owns cleanup in that mode.
|
|
58
|
+
|
|
59
|
+
## Shared automation dependency
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
React <ResearchAssistant> ─┐
|
|
63
|
+
├→ shared Assistant → recorder / assertion UI
|
|
64
|
+
SDK mountAssistant ───────┘ ├→ gz-laya-pilot/browser (semantic targets)
|
|
65
|
+
├→ gz-laya-pilot/schema (case validation)
|
|
66
|
+
└→ HTTP bridge → Node gz-laya-pilot.runCase
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`gz-laya-pilot@0.1.0` is a declared runtime dependency for **both** entrypoints. The browser imports only its schema and semantic targets. To execute, the host provides the same-origin bridge to a Node process importing `runCase` from `gz-laya-pilot`; no copied runner or SDK-specific replay path exists. Never bundle Node execution or model keys into the browser. This repository's `vite/laya-pilot.plugin.ts` and `tools/laya-pilot-recorded-runner.mjs` are a restricted localhost mock adapter, not a production test service.
|
|
38
70
|
|
|
39
71
|
Bridge: `GET /status` returns RunStatus + available; `POST /run` accepts `{testCase, delay, headed}` and returns 202 + status; `POST /stop` stops the run. POST uses JSON and `X-Laya-Pilot: recorded-case-v1`. The host must authenticate, validate input, restrict test targets and serialize runs. Server results use idle/running/passed/completed/failed/stopped and assertion evidence.
|
|
40
72
|
|
|
41
73
|
Timeline data stays in memory (300 events / 60 requests / 15 minutes), with private inputs excluded and JSON previews redacted. Timeline text is presentation only. Passive history never reconstructs input values or runnable selectors. Active recordings store structured targets and actions; add `data-testid`, proper labels or `data-assistant-label` to improve semantics. Closed Shadow DOM and cross-origin frames require host adapters.
|
|
42
74
|
|
|
43
75
|
OverlayScrollbars handles scroll visibility/dragging. Performance warnings are bounded heuristics, not proof of a memory leak. rrweb visual replay and OpenTelemetry trace correlation are optional future integrations, not silently enabled collection.
|
|
76
|
+
|
|
77
|
+
## Verifying parity in this repository
|
|
78
|
+
|
|
79
|
+
Run `npm run assistant:build`, `npm run assistant:test` and `npm run assistant:parity` (system Chrome required). The browser suite mounts each public entrypoint on the same fixture, records trusted form actions, adds an assertion through the editor, exports/imports JSON, and executes passing and failing cases through the real `gz-laya-pilot` Node package. It compares case JSON, replay results and theme styles, and checks window controls, narrow layouts, diagnostics, session reset and cleanup. It starts and closes its own local server; results are saved under `test-results/entry-parity/`.
|