gz-research-assistant 0.1.3 → 1.0.5
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 +145 -129
- package/dist/App.d.ts +7 -3
- package/dist/api/automation.d.ts +1 -1
- package/dist/components/AssistantAvatar/index.d.ts +1 -1
- package/dist/components/AssistantErrorBoundary/index.d.ts +16 -0
- package/dist/{recorder-ClSMnnGL.js → core-Xoh1ApY1.js} +244 -251
- package/dist/core-Xoh1ApY1.js.map +1 -0
- package/dist/core.js +1 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2640 -4
- package/dist/index.js.map +1 -0
- package/dist/inject.d.ts +21 -0
- package/dist/pages/assistant/components/AgentPanel/index.d.ts +1 -1
- package/dist/pages/assistant/components/AssertionEditor/index.d.ts +1 -1
- package/dist/pages/assistant/components/AutomationPanel/index.d.ts +1 -1
- package/dist/pages/assistant/components/PerformancePanel/index.d.ts +1 -1
- package/dist/pages/assistant/components/StepSupplement/index.d.ts +1 -1
- package/dist/pages/assistant/components/TimelinePanel/index.d.ts +2 -2
- 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 +52 -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,129 +1,145 @@
|
|
|
1
|
-
# gz-research-assistant
|
|
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.
|
|
4
|
-
|
|
5
|
-
```sh
|
|
6
|
-
npm install gz-research-assistant
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
import {
|
|
13
|
-
import '
|
|
14
|
-
import 'gz-research-assistant/style.css';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import 'gz-research-assistant
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
###
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
`gz-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
│
|
|
113
|
-
│
|
|
114
|
-
└─
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
1
|
+
# gz-research-assistant
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install gz-research-assistant gz-ui-web @ant-design/icons antd react react-dom
|
|
7
|
+
```
|
|
8
|
+
|
|
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)
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { ResearchAssistant, type ResearchAssistantProps } from 'gz-research-assistant';
|
|
38
|
+
import 'gz-ui-web/gz-ui-web.css';
|
|
39
|
+
import 'gz-research-assistant/style.css';
|
|
40
|
+
|
|
41
|
+
// Keep callback references stable (module scope or useCallback).
|
|
42
|
+
const options: ResearchAssistantProps = {
|
|
43
|
+
developer: true,
|
|
44
|
+
bridgeUrl: '/__laya-pilot',
|
|
45
|
+
themeMode: 'gold-dark',
|
|
46
|
+
runtimeOptions: {
|
|
47
|
+
isBusinessFailure: (body) =>
|
|
48
|
+
!!body && typeof body === 'object' && 'code' in body && body.code !== 0,
|
|
49
|
+
ignoreRequest: (url) => url.pathname.startsWith('/telemetry/'),
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Render only after login; unmount on logout.
|
|
54
|
+
<ResearchAssistant {...options} enabled={Boolean(token)} sessionKey={userId} />;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Changes in 1.0.5
|
|
58
|
+
|
|
59
|
+
- Isolated the assistant's Ant Design styles from hosts using `hashed: false`, preserving control padding, tab spacing, card padding and window controls.
|
|
60
|
+
- Restored the 52×52 launcher and enabled dragging in both the full and diagnostics-only modes. The tooltip closes during a drag and appears at the new position on the next hover.
|
|
61
|
+
- Simplified labels and help across the assistant. Snapshot import is distinct from test-case import, status and warnings appear next to their controls, and the step editor keeps its field labels visible.
|
|
62
|
+
|
|
63
|
+
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.
|
|
64
|
+
|
|
65
|
+
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.
|
|
66
|
+
|
|
67
|
+
`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.
|
|
68
|
+
|
|
69
|
+
## Chrome browser extension
|
|
70
|
+
|
|
71
|
+
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).
|
|
72
|
+
|
|
73
|
+
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.
|
|
74
|
+
|
|
75
|
+
`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.
|
|
76
|
+
|
|
77
|
+
## Shared automation dependency
|
|
78
|
+
|
|
79
|
+
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.
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
React <ResearchAssistant> ─┐
|
|
83
|
+
├→ shared Assistant → recorder / assertion UI
|
|
84
|
+
Chrome extension (diagnostics only) ─┘ ├→ gz-laya-pilot/browser (semantic targets)
|
|
85
|
+
├→ gz-laya-pilot/schema (case validation)
|
|
86
|
+
└→ HTTP bridge → Node gz-laya-pilot.runCase
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`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.
|
|
90
|
+
|
|
91
|
+
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.
|
|
92
|
+
|
|
93
|
+
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.
|
|
94
|
+
|
|
95
|
+
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.
|
|
96
|
+
|
|
97
|
+
## Verifying parity in this repository
|
|
98
|
+
|
|
99
|
+
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/`.
|
|
100
|
+
|
|
101
|
+
## 源码组织约定
|
|
102
|
+
|
|
103
|
+
遵循本仓库的 [项目目录结构规范](https://github.com/chenhui996/gz-zd-web/blob/codex/research-assistant/docs/项目目录结构规范.md),按职责和业务模块组织。小蜜是嵌入式组件,`pages/assistant` 表示浮窗内的功能视图,不另外引入路由,也不建立没有实际用途的空目录。
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
src/
|
|
107
|
+
├─ index.ts / core.ts # npm 组件、无 UI 能力的稳定公开入口
|
|
108
|
+
├─ App.tsx / App.module.less # 会话与 gg-ui 主题 token,样式就近存放
|
|
109
|
+
├─ App.test.tsx # npm 会话与生命周期测试
|
|
110
|
+
├─ api/ # 回放服务通信、知识问答适配协议
|
|
111
|
+
├─ components/
|
|
112
|
+
│ └─ AssistantAvatar/ # 复用的小机器人组件
|
|
113
|
+
│ ├─ index.tsx
|
|
114
|
+
│ └─ index.module.less
|
|
115
|
+
├─ layouts/
|
|
116
|
+
│ └─ FloatingPanel/ # 浮窗布局、滚动条 Hook、就近测试
|
|
117
|
+
│ ├─ index.tsx
|
|
118
|
+
│ └─ index.module.less
|
|
119
|
+
├─ pages/
|
|
120
|
+
│ └─ assistant/
|
|
121
|
+
│ ├─ index.tsx # 主界面与页签装配
|
|
122
|
+
│ ├─ index.module.less # 当前页面样式及页面内复用的布局样式
|
|
123
|
+
│ └─ components/ # 页面私有组件,每个目录均有 TSX + module.less
|
|
124
|
+
│ ├─ AutomationPanel/
|
|
125
|
+
│ ├─ AgentPanel/
|
|
126
|
+
│ ├─ AssertionEditor/
|
|
127
|
+
│ ├─ StepSupplement/
|
|
128
|
+
│ ├─ TimelinePanel/
|
|
129
|
+
│ └─ PerformancePanel/
|
|
130
|
+
└─ utils/
|
|
131
|
+
├─ diagnostics/ # 采集、脱敏、快照、性能规则及就近测试
|
|
132
|
+
└─ automation/ # 录制、用例协议、时间线转换及就近测试
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- `pages` 负责视图,页面专用组件放在该页面的 `components` 下;`layouts` 负责浮窗容器,`components` 存放复用组件,`api` 负责通信,`utils` 负责非 UI 能力。工具逻辑不依赖 React 或视图,测试与实现就近存放。
|
|
136
|
+
- 宿主只能从包的公开入口导入;包内按实际依赖直接引用文件,避免为每层增加重复转发的 `index.ts`。跨业务复用限于模型和协议,不让面板相互嵌套依赖。
|
|
137
|
+
- 有自有样式的组件使用同目录的 `index.tsx` 和 `index.module.less`,TSX 统一通过 `import styles from './index.module.less'` 导入。禁止把组件样式集中到远处的 `shared/styles`,也不使用普通 `.less` 的副作用导入。
|
|
138
|
+
- 组件的专属样式及响应式规则放在自己的 module 中;页面内共用的间距、字段、按钮行等通过 CSS Modules 的 `composes` 显式复用页面样式,避免复制声明。不要通过 Less 汇总导入所有组件样式。
|
|
139
|
+
- `:global(...)` 仅用于 gg-ui/OverlayScrollbars 内部类名,必须受本地类名约束。滚动逻辑和浏览器检查使用 `data-assistant-part`、`data-expanded` 等稳定标记,不依赖生成的 CSS 类名。
|
|
140
|
+
- 目录或样式迁移不得改变小机器人 SVG、界面布局、行为及公开 API。新增功能沿用所属模块,不再堆回源码根目录。
|
|
141
|
+
- 当前 UI 已冻结:未经用户明确授权,不修改任何样式、布局、图标或其他视觉表现相关代码;功能优化沿用现有界面。
|
|
142
|
+
|
|
143
|
+
自主探索的操作类型、断言与证据保存在 Excel 中,尚未验证的入口记录在工作簿“探索范围”及运行结果元数据中;“用例通过”不表示页面功能全覆盖。0.1.3 保留原有结果区 UI,npm 与 Chrome 扩展 仍使用同一 AgentPanel 和同一 `gz-laya-pilot` 工作流。
|
|
144
|
+
|
|
145
|
+
关联列表测试在本轮新建父记录中选择现有数据、确认添加、独立会话核对,再移除关联并独立确认恢复。该事务与断言保存进 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
|
|
15
|
+
/** npm and the browser extension share the same session, theme and UI. */
|
|
16
|
+
export default function ResearchAssistant(props?: ResearchAssistantProps): import("react").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
|
+
}
|