gz-research-assistant 0.1.2 → 1.0.4
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 +49 -32
- package/dist/App.d.ts +7 -3
- package/dist/api/automation.d.ts +1 -1
- package/dist/components/AssistantErrorBoundary/index.d.ts +16 -0
- package/dist/{recorder-ClSMnnGL.js → core-DWx1hG8M.js} +234 -233
- package/dist/core-DWx1hG8M.js.map +1 -0
- package/dist/core.js +2 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2676 -4
- package/dist/index.js.map +1 -0
- package/dist/inject.d.ts +21 -0
- package/dist/pages/assistant/components/TimelinePanel/index.d.ts +1 -1
- package/dist/pages/assistant/index.d.ts +3 -1
- package/dist/pages/assistant/useLauncherDrag.d.ts +5 -0
- package/dist/style.css +1 -1
- package/package.json +51 -55
- package/dist/App-B12hd4tM.js +0 -2524
- package/dist/App-B12hd4tM.js.map +0 -1
- package/dist/recorder-ClSMnnGL.js.map +0 -1
- package/dist/sdk.d.ts +0 -7
- package/dist/sdk.js +0 -33
- package/dist/sdk.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
# gz-research-assistant
|
|
2
2
|
|
|
3
|
-
Installable research assistant with gz-ui components, diagnostics, recording, assertions and local replay integration. Requires React 19 and gz-ui's peer dependencies.
|
|
3
|
+
Installable research assistant with gz-ui-web components, diagnostics, recording, assertions and local replay integration. Requires React 19 and gz-ui-web's peer dependencies.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
npm install gz-research-assistant
|
|
6
|
+
npm install gz-research-assistant gz-ui-web @ant-design/icons antd react react-dom
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Application entry point
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { researchAssistant } from 'gz-research-assistant';
|
|
13
|
+
import 'gz-ui-web/gz-ui-web.css'; // Omit if the host already imports it.
|
|
14
|
+
import 'gz-research-assistant/style.css';
|
|
15
|
+
|
|
16
|
+
researchAssistant.inject({
|
|
17
|
+
enabled: () => Boolean(authStore.getState().token),
|
|
18
|
+
sessionKey: () => authStore.getState().userId,
|
|
19
|
+
themeMode: () => authStore.getState().theme,
|
|
20
|
+
subscribe: authStore.subscribe,
|
|
21
|
+
diagnosticsOnly: true,
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`inject(options)` configures and starts a single assistant instance. `enabled`, `sessionKey` and `themeMode` accept either values or getter functions. When supplied, `subscribe(refresh)` connects application state updates and must return an unsubscribe function; without it, getters are read on startup only. The host owns activation conditions. The package owns the React root, popup container, collection, error boundary and cleanup.
|
|
26
|
+
|
|
27
|
+
- `researchAssistant.stop()` removes the UI, stops collection and releases the host subscription.
|
|
28
|
+
- `researchAssistant.start()` resumes the last configuration; repeated starts do not create duplicates.
|
|
29
|
+
- `researchAssistant.destroy()` also forgets the configuration.
|
|
30
|
+
- Calling `inject` again replaces the previous configuration and session.
|
|
31
|
+
|
|
32
|
+
No application wrapper component, Vite plugin or assistant-specific environment variable is required. For Vite HMR, dispose with `import.meta.hot?.dispose(() => researchAssistant.destroy())`.
|
|
33
|
+
|
|
34
|
+
## React component (optional)
|
|
10
35
|
|
|
11
36
|
```tsx
|
|
12
37
|
import { ResearchAssistant, type ResearchAssistantProps } from 'gz-research-assistant';
|
|
13
|
-
import '
|
|
38
|
+
import 'gz-ui-web/gz-ui-web.css';
|
|
14
39
|
import 'gz-research-assistant/style.css';
|
|
15
40
|
|
|
16
41
|
// Keep callback references stable (module scope or useCallback).
|
|
@@ -26,51 +51,38 @@ const options: ResearchAssistantProps = {
|
|
|
26
51
|
};
|
|
27
52
|
|
|
28
53
|
// Render only after login; unmount on logout.
|
|
29
|
-
<ResearchAssistant {...options} sessionKey={userId} />;
|
|
54
|
+
<ResearchAssistant {...options} enabled={Boolean(token)} sessionKey={userId} />;
|
|
30
55
|
```
|
|
31
56
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```tsx
|
|
35
|
-
import { mountAssistant } from 'gz-research-assistant/sdk';
|
|
36
|
-
import '@chenhui996/gg-ui/gg-ui.css';
|
|
37
|
-
import 'gz-research-assistant/style.css';
|
|
57
|
+
Version 1.0.4 replaces the retired `@chenhui996/gg-ui` dependency with `gz-ui-web@^1.0.4` without changing the assistant layout or icons. Theme isolation and Ant Design style hashing are handled inside the package, including hosts configured with `hashed: false`.
|
|
38
58
|
|
|
39
|
-
|
|
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.
|
|
47
|
-
```
|
|
59
|
+
Import the component and its stylesheet directly in the application's entry point. `enabled` defaults to `true`; set it from application state to start or stop the assistant. Disabling it unmounts its UI, restores collection hooks and clears the session. No integration adapter, Vite plugin or assistant-specific environment variable is required. Use `diagnosticsOnly` to show only phase-one diagnostics.
|
|
48
60
|
|
|
49
|
-
The
|
|
61
|
+
The package includes its own React error boundary. Assistant rendering failures hide its UI and tear down collection without propagating to the host React tree. Changing `sessionKey` or toggling `enabled` off and on starts a fresh attempt; the host does not need an assistant-specific error boundary.
|
|
50
62
|
|
|
51
|
-
`
|
|
63
|
+
`gz-laya-pilot@0.1.2` is installed automatically as a declared npm dependency. A browser application does not need a separate direct dependency or local tarball for it.
|
|
52
64
|
|
|
53
|
-
|
|
65
|
+
## Chrome browser extension
|
|
54
66
|
|
|
55
|
-
|
|
67
|
+
The second supported integration is a Chrome Manifest V3 extension. Build it with `npm run assistant:extension:build`, then load `extensions/research-assistant/dist` in Chrome developer mode. Click the toolbar action to enable or disable the assistant on the current HTTP/HTTPS page. It bundles its dependencies and reuses the same React UI and collector. The first extension release exposes diagnostics only (timeline, requests, performance, environment and snapshots); feedback, automation, knowledge and bridge configuration are hidden. The npm component retains its complete feature set. See [installation, permissions and limitations](../../extensions/research-assistant/README.md).
|
|
56
68
|
|
|
57
|
-
|
|
69
|
+
The previous `gz-research-assistant/sdk` export and `mountAssistant` API have been removed. Use `researchAssistant.inject()` from the main npm export, the React component, or the browser extension. Both npm entry styles own collection automatically; remove manual `startAssistant()` calls. The `core` export remains a low-level npm API, not an additional supported UI integration. Enable only one entry style per page.
|
|
58
70
|
|
|
59
|
-
|
|
71
|
+
`sessionKey` changes reset the entire npm assistant session. Unmount on logout. Presentation-only changes retain recording and evidence. The extension requires manual disable/re-enable on account changes and starts fresh after navigation. Only enable one integration per page.
|
|
60
72
|
|
|
61
73
|
## Shared automation dependency
|
|
62
74
|
|
|
63
|
-
Version 0.1.
|
|
75
|
+
Version 0.1.3 keeps the existing **自主探索** interface and upgrades its shared engine to `gz-laya-pilot@0.1.2`. Select a host-authorized page, allow test-data writes if needed, explore, download the upstream Excel workbook, then import it for fresh-session replay. The Node host uses `createAgentBridge()` → `runAgent()` → the pinned upstream `runWorkflow`; generation and replay both use local Laya, with real Playwright assertions and evidence. The engine adds continuous microfrontend execution, semantic record trees, search/detail checks and related-record transactions. Real-model acceptance on 2026-10-07 generated and replayed 12 cases on the securities fixture and 11 on an independent English tree/relationship fixture. These results cover supported flows, not arbitrary backends or every page feature. See the engine's [package documentation](https://www.npmjs.com/package/gz-laya-pilot) for dependencies, integration requirements and support boundaries.
|
|
64
76
|
|
|
65
77
|
```text
|
|
66
78
|
React <ResearchAssistant> ─┐
|
|
67
79
|
├→ shared Assistant → recorder / assertion UI
|
|
68
|
-
|
|
80
|
+
Chrome extension (diagnostics only) ─┘ ├→ gz-laya-pilot/browser (semantic targets)
|
|
69
81
|
├→ gz-laya-pilot/schema (case validation)
|
|
70
82
|
└→ HTTP bridge → Node gz-laya-pilot.runCase
|
|
71
83
|
```
|
|
72
84
|
|
|
73
|
-
`gz-laya-pilot@0.1.
|
|
85
|
+
`gz-laya-pilot@0.1.2` is a declared runtime dependency of the shared package. The phase-one extension does not expose automation or call its bridge. The browser imports only its schema and semantic targets. To execute, the host provides the same-origin bridge to a Node process importing `runCase` or `createAgentBridge` from `gz-laya-pilot`; no copied runner or extension-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` provide localhost integration, not a production test service.
|
|
74
86
|
|
|
75
87
|
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.
|
|
76
88
|
|
|
@@ -80,7 +92,7 @@ OverlayScrollbars handles scroll visibility/dragging. Performance warnings are b
|
|
|
80
92
|
|
|
81
93
|
## Verifying parity in this repository
|
|
82
94
|
|
|
83
|
-
Run `npm run assistant:build`, `npm run assistant:test` and `npm run assistant:parity` (system Chrome required). The browser suite mounts
|
|
95
|
+
Run `npm run assistant:build`, `npm run assistant:test` and `npm run assistant:parity` (system Chrome required). The npm browser suite mounts the public React component on a 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 checks case JSON, replay results, theme styles, and 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/`.
|
|
84
96
|
|
|
85
97
|
## 源码组织约定
|
|
86
98
|
|
|
@@ -88,9 +100,9 @@ Run `npm run assistant:build`, `npm run assistant:test` and `npm run assistant:p
|
|
|
88
100
|
|
|
89
101
|
```text
|
|
90
102
|
src/
|
|
91
|
-
├─ index.ts /
|
|
103
|
+
├─ index.ts / core.ts # npm 组件、无 UI 能力的稳定公开入口
|
|
92
104
|
├─ App.tsx / App.module.less # 会话与 gg-ui 主题 token,样式就近存放
|
|
93
|
-
├─ App.test.tsx #
|
|
105
|
+
├─ App.test.tsx # npm 会话与生命周期测试
|
|
94
106
|
├─ api/ # 回放服务通信、知识问答适配协议
|
|
95
107
|
├─ components/
|
|
96
108
|
│ └─ AssistantAvatar/ # 复用的小机器人组件
|
|
@@ -122,3 +134,8 @@ src/
|
|
|
122
134
|
- 组件的专属样式及响应式规则放在自己的 module 中;页面内共用的间距、字段、按钮行等通过 CSS Modules 的 `composes` 显式复用页面样式,避免复制声明。不要通过 Less 汇总导入所有组件样式。
|
|
123
135
|
- `:global(...)` 仅用于 gg-ui/OverlayScrollbars 内部类名,必须受本地类名约束。滚动逻辑和浏览器检查使用 `data-assistant-part`、`data-expanded` 等稳定标记,不依赖生成的 CSS 类名。
|
|
124
136
|
- 目录或样式迁移不得改变小机器人 SVG、界面布局、行为及公开 API。新增功能沿用所属模块,不再堆回源码根目录。
|
|
137
|
+
- 当前 UI 已冻结:未经用户明确授权,不修改任何样式、布局、图标或其他视觉表现相关代码;功能优化沿用现有界面。
|
|
138
|
+
|
|
139
|
+
自主探索的操作类型、断言与证据保存在 Excel 中,尚未验证的入口记录在工作簿“探索范围”及运行结果元数据中;“用例通过”不表示页面功能全覆盖。0.1.3 保留原有结果区 UI,npm 与 Chrome 扩展 仍使用同一 AgentPanel 和同一 `gz-laya-pilot` 工作流。
|
|
140
|
+
|
|
141
|
+
关联列表测试在本轮新建父记录中选择现有数据、确认添加、独立会话核对,再移除关联并独立确认恢复。该事务与断言保存进 Excel,由相同引擎回放;不能将只打开详情页签计为关联业务测试通过。
|
package/dist/App.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { type ComponentProps } from 'react';
|
|
2
|
-
import { ConfigProvider } from '
|
|
2
|
+
import { ConfigProvider } from 'gz-ui-web';
|
|
3
3
|
import { type ResearchAssistantProps as ViewProps } from './pages/assistant/index';
|
|
4
4
|
import { type AssistantOptions } from './utils/diagnostics/runtime';
|
|
5
5
|
export interface ResearchAssistantProps extends ViewProps {
|
|
6
|
+
/** The host owns the activation condition. Disabling tears down collection and UI. */
|
|
7
|
+
enabled?: boolean;
|
|
6
8
|
runtimeOptions?: AssistantOptions;
|
|
7
9
|
themeMode?: ComponentProps<typeof ConfigProvider>['themeMode'];
|
|
8
10
|
/** Change when the authenticated user/session changes to discard the previous session. */
|
|
9
11
|
sessionKey?: string | number;
|
|
12
|
+
/** Container for overlays when embedded by the browser extension. */
|
|
13
|
+
popupContainer?: HTMLElement;
|
|
10
14
|
}
|
|
11
|
-
/**
|
|
12
|
-
export default function ResearchAssistant(props?: ResearchAssistantProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
/** npm and the browser extension share the same session, theme and UI. */
|
|
16
|
+
export default function ResearchAssistant(props?: ResearchAssistantProps): import("react/jsx-runtime").JSX.Element | null;
|
package/dist/api/automation.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export declare const agentArtifactUrl: (base: string, id: string, file: string)
|
|
|
8
8
|
export type AutomationStatus = RunStatus & {
|
|
9
9
|
available?: boolean;
|
|
10
10
|
};
|
|
11
|
-
/** Same-origin replay bridge; shared by the
|
|
11
|
+
/** Same-origin replay bridge; shared by the npm and browser extension panels. */
|
|
12
12
|
export declare function bridge(base: string, action: 'status' | 'run' | 'stop', body?: unknown): Promise<AutomationStatus>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component, type ReactNode } from 'react';
|
|
2
|
+
/** An embedded assistant must not take down the host application's React tree. */
|
|
3
|
+
export default class AssistantErrorBoundary extends Component<{
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}, {
|
|
6
|
+
failed: boolean;
|
|
7
|
+
}> {
|
|
8
|
+
state: {
|
|
9
|
+
failed: boolean;
|
|
10
|
+
};
|
|
11
|
+
static getDerivedStateFromError(): {
|
|
12
|
+
failed: boolean;
|
|
13
|
+
};
|
|
14
|
+
componentDidCatch(error: Error): void;
|
|
15
|
+
render(): ReactNode;
|
|
16
|
+
}
|