gz-laya-pilot 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/NOTICE.md +6 -2
- package/README.md +32 -2
- package/dist/agent/bridge.d.ts +21 -0
- package/dist/agent/bridge.js +158 -0
- package/dist/agent/bridge.js.map +1 -0
- package/dist/agent/report.d.ts +51 -0
- package/dist/agent/report.js +91 -0
- package/dist/agent/report.js.map +1 -0
- package/dist/agent/run.d.ts +19 -0
- package/dist/agent/run.js +121 -0
- package/dist/agent/run.js.map +1 -0
- package/dist/agent/schema.d.ts +32 -0
- package/dist/agent/schema.js +9 -0
- package/dist/agent/schema.js.map +1 -0
- package/dist/agent/worker.d.ts +1 -0
- package/dist/agent/worker.js +102 -0
- package/dist/agent/worker.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +7 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +14 -6
- package/src/agent/bridge.ts +180 -0
- package/src/agent/report.ts +126 -0
- package/src/agent/run.ts +136 -0
- package/src/agent/schema.ts +33 -0
- package/src/agent/worker.ts +114 -0
- package/src/cli.ts +5 -0
- package/src/index.ts +3 -0
- package/vendor/.gitattributes +4 -0
- package/vendor/UPSTREAM.json +79 -0
- package/vendor/laya-pilot/LICENSE +21 -0
- package/vendor/laya-pilot/README.en.md +116 -0
- package/vendor/laya-pilot/README.md +116 -0
- package/vendor/laya-pilot/ROADMAP.md +21 -0
- package/vendor/laya-pilot/config.example.json +14 -0
- package/vendor/laya-pilot/docs/architecture.md +21 -0
- package/vendor/laya-pilot/docs/browser-use-evaluation.md +32 -0
- package/vendor/laya-pilot/docs/demo.png +0 -0
- package/vendor/laya-pilot/docs/local-runtime.md +88 -0
- package/vendor/laya-pilot/docs/pr1-selection.md +33 -0
- package/vendor/laya-pilot/docs/retry-policy.md +14 -0
- package/vendor/laya-pilot/examples/demo-cases.xlsx +0 -0
- package/vendor/laya-pilot/examples/demo-server.mjs +19 -0
- package/vendor/laya-pilot/examples/demo.html +733 -0
- package/vendor/laya-pilot/lib/auth-state.mjs +141 -0
- package/vendor/laya-pilot/lib/browser-provider.mjs +31 -0
- package/vendor/laya-pilot/lib/diagnostics.mjs +210 -0
- package/vendor/laya-pilot/lib/discovery.mjs +323 -0
- package/vendor/laya-pilot/lib/dom.mjs +476 -0
- package/vendor/laya-pilot/lib/engine.mjs +879 -0
- package/vendor/laya-pilot/lib/form.mjs +377 -0
- package/vendor/laya-pilot/lib/language.mjs +273 -0
- package/vendor/laya-pilot/lib/model.mjs +271 -0
- package/vendor/laya-pilot/lib/pending-writes.mjs +50 -0
- package/vendor/laya-pilot/lib/planner.mjs +127 -0
- package/vendor/laya-pilot/lib/project-config.mjs +95 -0
- package/vendor/laya-pilot/lib/readiness.mjs +179 -0
- package/vendor/laya-pilot/lib/replay-model.mjs +44 -0
- package/vendor/laya-pilot/lib/run-state.mjs +119 -0
- package/vendor/laya-pilot/lib/test-data.mjs +115 -0
- package/vendor/laya-pilot/lib/workflow-policy.mjs +61 -0
- package/vendor/laya-pilot/lib/workflow.mjs +1906 -0
- package/vendor/laya-pilot/lib/workflow_excel.py +431 -0
- package/vendor/laya-pilot/requirements-local.txt +2 -0
- package/vendor/laya-pilot/requirements.txt +1 -0
- package/vendor/laya-pilot/runner.mjs +452 -0
- package/vendor/laya-pilot/tests/api.test.mjs +98 -0
- package/vendor/laya-pilot/tests/browser/runtime.test.mjs +847 -0
- package/vendor/laya-pilot/tests/config.test.mjs +109 -0
- package/vendor/laya-pilot/tests/diagnostics.test.mjs +91 -0
- package/vendor/laya-pilot/tests/discovery.test.mjs +76 -0
- package/vendor/laya-pilot/tests/fixtures/local-model/laya.py +28 -0
- package/vendor/laya-pilot/tests/fixtures/local-model/torch.py +5 -0
- package/vendor/laya-pilot/tests/guards.test.mjs +43 -0
- package/vendor/laya-pilot/tests/language.test.mjs +39 -0
- package/vendor/laya-pilot/tests/planner.test.mjs +129 -0
- package/vendor/laya-pilot/tests/readiness.test.mjs +118 -0
- package/vendor/laya-pilot/tests/real-model.smoke.mjs +74 -0
- package/vendor/laya-pilot/tests/replay-model.test.mjs +90 -0
- package/vendor/laya-pilot/tests/retries.test.mjs +257 -0
- package/vendor/laya-pilot/tests/run-state.test.mjs +162 -0
- package/vendor/laya-pilot/tests/selected-pr1.test.mjs +291 -0
- package/vendor/laya-pilot/tests/test-data.test.mjs +83 -0
- package/vendor/laya-pilot/tests/test_workflow_excel.py +162 -0
- package/vendor/laya-pilot/tests/worker_test.py +33 -0
- package/vendor/laya-pilot/tests/workflow.test.mjs +98 -0
- package/vendor/laya-pilot/worker.py +135 -0
- package/vendor/patches/0001-native-field-recipes.patch +57 -0
package/NOTICE.md
CHANGED
|
@@ -6,6 +6,10 @@ The repository already contains the complete adapted source snapshot under `tool
|
|
|
6
6
|
|
|
7
7
|
Ported `lib/browser-provider.mjs`, the `waitForReady` function in `lib/readiness.mjs`, and decision validation / HTTP protocol from `lib/model.mjs` to strict TypeScript functions. Added schema validation, deterministic recording replay, declarative assertions and semantic target metadata. Removed application routes, demo credentials, workflow classes, implicit logs and unbounded caches from this package. LICENSE retains the upstream notice.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Version 0.1.1 additionally vendors the complete generation/replay engine from upstream commit `9f1bb801e0ca5eb4ded82413ab112ab0da0716d8` under `vendor/laya-pilot`. `vendor/UPSTREAM.json` records the commit and SHA-256 source hashes. Original MIT notices and upstream regression tests are retained. The earlier paragraph describes the 0.1.0 recording adapter, not the scope of this new integration.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The new TypeScript functions add npm exports, a child-process boundary, UTF-8 Windows IPC, local HTTP integration and UI report projection. `runWorkflow`, Laya decisions, discovery, assertions, state/auth handling and the original Python/openpyxl workbook contract remain upstream implementations. `vendor/patches/0001-native-field-recipes.patch` tracks three focused adaptations: constrain data recipes using native number/email types, accept text recipes that preserve the unique record variable, and mark absent optional detail views as not applicable only during automatic discovery. Explicit view requests and execution errors still fail. Model thresholds and refusal behavior are unchanged. Original and modified hashes are both retained.
|
|
12
|
+
|
|
13
|
+
The abandoned replacement planner and ExcelJS workbook grammar are not part of this package. Model weights and the Python environment are not distributed. The new APIs require 0.1.1 or later.
|
|
14
|
+
|
|
15
|
+
Playwright and dom-accessibility-api retain their own licenses. Python libraries and Laya model weights retain their own licenses. This package is not an official npm release of upstream `laya-pilot`.
|
package/README.md
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
# gz-laya-pilot
|
|
2
2
|
|
|
3
|
-
Node 22+
|
|
3
|
+
Node 22+ package based on LayaPilot. Functional TypeScript host API, ESM and declarations; Playwright execution stays in Node.
|
|
4
|
+
|
|
5
|
+
## Autonomous exploration (0.1.1)
|
|
6
|
+
|
|
7
|
+
Version 0.1.1 integrates the full upstream generation and replay workflow, pinned at `9f1bb801e0ca5eb4ded82413ab112ab0da0716d8`, with a small tracked patch for native input constraints, text record titles and absent optional detail views. Version 0.1.0 only contains the recorded JSON adapter. Original and modified source hashes are in `vendor/UPSTREAM.json`; the complete diff is under `vendor/patches/`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { runAgent } from 'gz-laya-pilot';
|
|
11
|
+
const options = {
|
|
12
|
+
url: 'http://localhost:3000/customers',
|
|
13
|
+
python: '/absolute/path/to/python',
|
|
14
|
+
model: '/absolute/path/to/laya-multilingual',
|
|
15
|
+
channel: 'chrome', allowWrite: true,
|
|
16
|
+
};
|
|
17
|
+
await runAgent({ ...options, outputDir: './results/explore', onProgress: console.log });
|
|
18
|
+
await runAgent({ ...options, workbook: './results/explore/cases.xlsx', outputDir: './results/replay' });
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`runAgent` starts an isolated worker calling the vendored `runWorkflow`. Upstream owns DOM observation, field/option decisions, CRUD and supplemental discovery, assertions, retries, pending-write journal, screenshots, Trace and Excel. The original 17-column workbook and hidden `__laya_steps__` contract are preserved, including visible-column integrity checks. There is no second planner or custom workbook grammar. Both generation and replay use real Laya decisions; replay binds recorded targets to the new DOM and creates new test identifiers. A model refusal or assertion failure remains a failure.
|
|
22
|
+
|
|
23
|
+
`createAgentBridge({targets: [{url, authState?, authCheck?}], python, model, outputDir, channel?, headed?})` returns `{middleware, stop, isRunning}`. Mount at `<assistant bridgeUrl>/agent` in a same-origin local Node server. It validates target permissions, serializes runs and serves upstream reports. The default is installed Chrome in headless mode. This is local middleware, not a production multi-user service. Saved login state must use the upstream auth-state format and a login-success selector. Browser cookies are not implicitly copied from the host page.
|
|
24
|
+
|
|
25
|
+
The CLI delegates to upstream and preserves its flags. Generate: `gz-laya-pilot --mode generate --url <url> --case-file ./cases.xlsx --out ./results/generate --python <path> --model <path> --browser-channel chrome --headless --allow-write`. Replay uses `--mode execute` with the same URL/case file and a new output directory. `--help` lists all upstream modes, including existing natural-language Excel via `--excel`.
|
|
26
|
+
|
|
27
|
+
Install Python dependencies from the vendored `requirements-local.txt` (or the repository's tested Windows lock), then download the pinned model. Python runs Laya and openpyxl; this is **not** a pure TypeScript model/Excel rewrite. Python, model weights and browser binaries are not bundled into npm. Windows IPC explicitly uses UTF-8. No model/API fallback is silently substituted.
|
|
28
|
+
|
|
29
|
+
See the [integration and acceptance guide](https://github.com/chenhui996/gz-zd-web/blob/codex/research-assistant/docs/研发小蜜自主探索.md) for pinned setup, support boundaries and real-model verification. Browser consumers use `gz-laya-pilot/agent-schema` without importing Node/Excel/Playwright.
|
|
30
|
+
|
|
31
|
+
Known limitation in 0.1.1: the local model still refuses the English `Credit limit` field in the independent customer fixture, including when the input declares `type=number`. This blocks that fixture's CRUD flow and the full cross-backend acceptance command remains failing. The public upstream demo and independent Chinese asset fixture passed generation and fresh-session replay; this is not a guarantee for arbitrary backends.
|
|
32
|
+
|
|
33
|
+
## Recorded JSON replay
|
|
4
34
|
|
|
5
35
|
```sh
|
|
6
36
|
npm install gz-laya-pilot
|
|
@@ -41,6 +71,6 @@ Use `beforeRun(page, context)` for your host's authentication or test setup; use
|
|
|
41
71
|
|
|
42
72
|
Browser consumers import `gz-laya-pilot/schema` or `gz-laya-pilot/browser`; neither entry imports Node or Playwright. `locate()` uses unique CSS plus W3C accessible name/role. Version 1 CSS/text targets still work. Automatic retry never substitutes another business control.
|
|
43
73
|
|
|
44
|
-
`createApiDecision({base, model, key})` returns a Laya-protocol decision function. `chooseStep(instruction, observedCandidates, decide)` selects a structured step or returns null for uncertainty. It does not execute the candidate or invent locators. The host must observe candidates and review the draft; `runCase` evaluates assertions against real DOM, not model opinions. JSON replay does not require Python
|
|
74
|
+
`createApiDecision({base, model, key})` returns a Laya-protocol decision function. `chooseStep(instruction, observedCandidates, decide)` selects a structured step or returns null for uncertainty. It does not execute the candidate or invent locators. The host must observe candidates and review the draft; `runCase` evaluates assertions against real DOM, not model opinions. Recorded JSON replay does not require Python; autonomous Excel generation/replay uses the vendored upstream engine described above. The older `tools/laya-pilot` snapshot is retained for compatibility, not used as the new agent engine.
|
|
45
75
|
|
|
46
76
|
See NOTICE.md and LICENSE for upstream provenance and the scope of the port.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
export interface AgentBridgeTarget {
|
|
3
|
+
url: string;
|
|
4
|
+
authState?: string;
|
|
5
|
+
authCheck?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AgentBridgeOptions {
|
|
8
|
+
targets: AgentBridgeTarget[];
|
|
9
|
+
outputDir: string;
|
|
10
|
+
python: string;
|
|
11
|
+
model: string;
|
|
12
|
+
channel?: string;
|
|
13
|
+
headed?: boolean;
|
|
14
|
+
isBusy?: () => boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Local HTTP adapter shared by React and SDK. All test decisions/execution remain upstream. */
|
|
17
|
+
export declare function createAgentBridge(options: AgentBridgeOptions): {
|
|
18
|
+
middleware: (req: IncomingMessage, res: ServerResponse, next: () => void) => Promise<void>;
|
|
19
|
+
stop: () => void | undefined;
|
|
20
|
+
isRunning: () => boolean;
|
|
21
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { existsSync, createReadStream } from 'node:fs';
|
|
2
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { testUrl } from './schema.js';
|
|
6
|
+
import { runAgent } from './run.js';
|
|
7
|
+
/** Local HTTP adapter shared by React and SDK. All test decisions/execution remain upstream. */
|
|
8
|
+
export function createAgentBridge(options) {
|
|
9
|
+
const targets = options.targets.map((t) => ({ ...t, url: testUrl(t.url) }));
|
|
10
|
+
const root = path.resolve(options.outputDir);
|
|
11
|
+
let active, controller;
|
|
12
|
+
let status = {
|
|
13
|
+
state: 'idle',
|
|
14
|
+
mode: 'explore',
|
|
15
|
+
message: '尚未探索',
|
|
16
|
+
cases: [],
|
|
17
|
+
decisions: 0,
|
|
18
|
+
};
|
|
19
|
+
const stop = () => controller?.abort();
|
|
20
|
+
const middleware = async (req, res, next) => {
|
|
21
|
+
const url = new URL(req.url ?? '/', 'http://localhost');
|
|
22
|
+
if (!['/status', '/explore', '/replay', '/stop', '/artifact'].includes(url.pathname))
|
|
23
|
+
return next();
|
|
24
|
+
const send = (code, body) => {
|
|
25
|
+
res.statusCode = code;
|
|
26
|
+
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
27
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
28
|
+
res.end(JSON.stringify(body));
|
|
29
|
+
};
|
|
30
|
+
const host = req.headers.host ?? '';
|
|
31
|
+
if (!['127.0.0.1', '::1', '::ffff:127.0.0.1'].includes(req.socket.remoteAddress ?? '') ||
|
|
32
|
+
!/^(localhost|127\.0\.0\.1|\[::1\]):\d+$/.test(host))
|
|
33
|
+
return send(403, { message: '执行服务仅允许本机访问' });
|
|
34
|
+
if (req.headers.origin && req.headers.origin !== `http://${host}`)
|
|
35
|
+
return send(403, { message: '仅接受同源访问' });
|
|
36
|
+
if (req.method === 'GET' && url.pathname === '/status') {
|
|
37
|
+
const configured = existsSync(options.python) && existsSync(options.model) && targets.length > 0;
|
|
38
|
+
return send(200, {
|
|
39
|
+
...status,
|
|
40
|
+
capabilities: {
|
|
41
|
+
configured,
|
|
42
|
+
targets: targets.map((t) => t.url),
|
|
43
|
+
message: configured
|
|
44
|
+
? '本地 Laya 已配置 · 上游 LayaPilot 引擎'
|
|
45
|
+
: '请在宿主配置 LAYA_PYTHON、LAYA_MODEL 和 LAYA_TEST_URLS',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (req.method === 'GET' && url.pathname === '/artifact') {
|
|
50
|
+
const id = url.searchParams.get('id') ?? '', file = url.searchParams.get('file') ?? '';
|
|
51
|
+
if (!/^[\da-f-]{36}$/.test(id) ||
|
|
52
|
+
!/^(cases\.xlsx|results\.xlsx|results\.json|decisions\.ndjson|checkpoint\.json|trace\.zip|evidence\/[a-zA-Z0-9_-]{1,150}\.png)$/.test(file))
|
|
53
|
+
return send(400, { message: '无效的报告文件' });
|
|
54
|
+
const filename = path.join(root, id, file === 'results.xlsx' ? '执行结果.xlsx' : file);
|
|
55
|
+
if (!existsSync(filename))
|
|
56
|
+
return send(404, { message: '报告尚未生成' });
|
|
57
|
+
res.setHeader('Content-Type', file.endsWith('.png') ? 'image/png' : 'application/octet-stream');
|
|
58
|
+
res.setHeader('Content-Disposition', `attachment; filename="${path.basename(file)}"`);
|
|
59
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
60
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
61
|
+
const stream = createReadStream(filename);
|
|
62
|
+
stream.on('error', () => res.destroy());
|
|
63
|
+
stream.pipe(res);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (req.method !== 'POST' || !['/explore', '/replay', '/stop'].includes(url.pathname))
|
|
67
|
+
return send(405, { message: '请求方法不支持' });
|
|
68
|
+
if (req.headers.origin !== `http://${host}` ||
|
|
69
|
+
req.headers['x-laya-pilot'] !== 'agent-v1' ||
|
|
70
|
+
!req.headers['content-type']?.startsWith('application/json'))
|
|
71
|
+
return send(403, { message: '仅接受页面内同源请求' });
|
|
72
|
+
if (url.pathname === '/stop') {
|
|
73
|
+
stop();
|
|
74
|
+
return send(200, status);
|
|
75
|
+
}
|
|
76
|
+
if (active || options.isBusy?.())
|
|
77
|
+
return send(409, { message: '已有测试正在运行' });
|
|
78
|
+
try {
|
|
79
|
+
let body = '';
|
|
80
|
+
for await (const chunk of req) {
|
|
81
|
+
body += chunk;
|
|
82
|
+
if (Buffer.byteLength(body) > 3 * 1024 * 1024)
|
|
83
|
+
throw Error('请求超过 3 MB');
|
|
84
|
+
}
|
|
85
|
+
const input = JSON.parse(body), target = targets.find((t) => t.url === testUrl(input.url));
|
|
86
|
+
if (!target)
|
|
87
|
+
throw Error('入口不在宿主配置的测试地址列表中');
|
|
88
|
+
if (typeof input.allowWrite !== 'boolean')
|
|
89
|
+
throw Error('需要明确选择是否允许创建测试数据');
|
|
90
|
+
if (!existsSync(options.python) || !existsSync(options.model))
|
|
91
|
+
throw Error('生成和回放均需配置本地 Laya');
|
|
92
|
+
if (active || options.isBusy?.())
|
|
93
|
+
return send(409, { message: '已有测试正在运行' });
|
|
94
|
+
const replay = url.pathname === '/replay';
|
|
95
|
+
let content;
|
|
96
|
+
if (replay) {
|
|
97
|
+
if (typeof input.workbook !== 'string' || !/^[a-z\d+/]+={0,2}$/i.test(input.workbook))
|
|
98
|
+
throw Error('请上传有效的 Excel 用例');
|
|
99
|
+
content = Buffer.from(input.workbook, 'base64');
|
|
100
|
+
if (content.length > 2 * 1024 * 1024 ||
|
|
101
|
+
content.length < 4 ||
|
|
102
|
+
content.readUInt32LE(0) !== 0x04034b50)
|
|
103
|
+
throw Error('仅支持 2 MB 内的 xlsx 用例');
|
|
104
|
+
}
|
|
105
|
+
const id = randomUUID(), outputDir = path.join(root, id);
|
|
106
|
+
controller = new AbortController();
|
|
107
|
+
const signal = controller.signal;
|
|
108
|
+
status = {
|
|
109
|
+
id,
|
|
110
|
+
state: 'running',
|
|
111
|
+
mode: replay ? 'replay' : 'explore',
|
|
112
|
+
message: '正在启动上游 LayaPilot',
|
|
113
|
+
cases: [],
|
|
114
|
+
decisions: 0,
|
|
115
|
+
};
|
|
116
|
+
active = (async () => {
|
|
117
|
+
try {
|
|
118
|
+
await mkdir(outputDir, { recursive: true });
|
|
119
|
+
const workbook = content ? path.join(outputDir, 'uploaded.xlsx') : undefined;
|
|
120
|
+
if (workbook && content)
|
|
121
|
+
await writeFile(workbook, content);
|
|
122
|
+
const result = await runAgent({
|
|
123
|
+
...target,
|
|
124
|
+
outputDir,
|
|
125
|
+
python: options.python,
|
|
126
|
+
model: options.model,
|
|
127
|
+
channel: options.channel,
|
|
128
|
+
workbook,
|
|
129
|
+
allowWrite: input.allowWrite,
|
|
130
|
+
headed: options.headed ?? false,
|
|
131
|
+
signal,
|
|
132
|
+
onProgress: (value) => {
|
|
133
|
+
status = { ...value, id };
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
status = { ...result, id };
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
status = {
|
|
140
|
+
...status,
|
|
141
|
+
state: signal.aborted ? 'stopped' : 'failed',
|
|
142
|
+
message: error instanceof Error ? error.message : String(error),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
active = undefined;
|
|
147
|
+
controller = undefined;
|
|
148
|
+
}
|
|
149
|
+
})();
|
|
150
|
+
send(202, status);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
send(400, { message: error instanceof Error ? error.message : '无法启动测试' });
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
return { middleware, stop, isRunning: () => Boolean(active) };
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0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C/B,MAAM;wBACN,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;4BACpB,MAAM,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC;wBAC5B,CAAC;qBACF,CAAC,CAAC;oBACH,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC;gBAC7B,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,GAAG;wBACP,GAAG,MAAM;wBACT,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;wBAC5C,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;qBAChE,CAAC;gBACJ,CAAC;wBAAS,CAAC;oBACT,MAAM,GAAG,SAAS,CAAC;oBACnB,UAAU,GAAG,SAAS,CAAC;gBACzB,CAAC;YACH,CAAC,CAAC,EAAE,CAAC;YACL,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC,CAAC;IACF,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AgentStatus } from './schema.js';
|
|
2
|
+
export interface UpstreamStep {
|
|
3
|
+
kind: string;
|
|
4
|
+
value?: unknown;
|
|
5
|
+
target?: {
|
|
6
|
+
name?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
};
|
|
9
|
+
spec?: {
|
|
10
|
+
title?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface UpstreamCase {
|
|
14
|
+
id: string;
|
|
15
|
+
title: string;
|
|
16
|
+
status: string;
|
|
17
|
+
reason: string;
|
|
18
|
+
steps: UpstreamStep[];
|
|
19
|
+
evidence?: string;
|
|
20
|
+
failedStep?: {
|
|
21
|
+
number: number;
|
|
22
|
+
action: string;
|
|
23
|
+
target?: string;
|
|
24
|
+
} | null;
|
|
25
|
+
browserEvents?: {
|
|
26
|
+
type?: string;
|
|
27
|
+
message?: string;
|
|
28
|
+
url?: string;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
export interface UpstreamReport {
|
|
32
|
+
runStatus?: string;
|
|
33
|
+
status?: string;
|
|
34
|
+
error?: string;
|
|
35
|
+
exitCode?: number;
|
|
36
|
+
results: UpstreamCase[];
|
|
37
|
+
activeCase?: {
|
|
38
|
+
title?: string;
|
|
39
|
+
};
|
|
40
|
+
caseFile?: string;
|
|
41
|
+
retainedRecord?: string;
|
|
42
|
+
pendingWrite?: unknown;
|
|
43
|
+
metrics?: {
|
|
44
|
+
modelCalls?: number;
|
|
45
|
+
};
|
|
46
|
+
runtime?: {
|
|
47
|
+
currentName?: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Preserve upstream truth: recorded assertion steps are appended after successful execution. */
|
|
51
|
+
export declare function projectReport(report: UpstreamReport, mode: AgentStatus['mode'], final: boolean): AgentStatus;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
function assertionTitle(step) {
|
|
2
|
+
if (step.spec?.title)
|
|
3
|
+
return step.spec.title;
|
|
4
|
+
const target = step.target?.label ?? step.target?.name ?? '';
|
|
5
|
+
const value = Array.isArray(step.value)
|
|
6
|
+
? step.value.join('、')
|
|
7
|
+
: typeof step.value === 'string'
|
|
8
|
+
? step.value
|
|
9
|
+
.replaceAll('${recordName}', '本轮测试记录')
|
|
10
|
+
.replaceAll('${updatedName}', '修改后的本轮记录')
|
|
11
|
+
: '';
|
|
12
|
+
const titles = {
|
|
13
|
+
'assert-control': `控件可见且唯一:${target}`,
|
|
14
|
+
'assert-selected': `页签已选中:${target}`,
|
|
15
|
+
'assert-disabled': `控件不可用:${target}`,
|
|
16
|
+
'assert-headers': `列表包含列头:${value}`,
|
|
17
|
+
'assert-form-errors': `表单提示必填错误:${value}`,
|
|
18
|
+
'assert-input-invalid': `输入校验阻止无效数据:${target}`,
|
|
19
|
+
'assert-row': `列表存在唯一记录:${value}`,
|
|
20
|
+
'assert-absent': `列表中记录已消失:${value}`,
|
|
21
|
+
'assert-text': `页面显示文本:${value}`,
|
|
22
|
+
};
|
|
23
|
+
return titles[step.kind] ?? `${step.kind} ${target}`;
|
|
24
|
+
}
|
|
25
|
+
/** Preserve upstream truth: recorded assertion steps are appended after successful execution. */
|
|
26
|
+
export function projectReport(report, mode, final) {
|
|
27
|
+
const cases = (report.results ?? []).map((c) => ({
|
|
28
|
+
id: c.id,
|
|
29
|
+
title: c.title,
|
|
30
|
+
state: ['通过', '已验证'].includes(c.status)
|
|
31
|
+
? 'passed'
|
|
32
|
+
: ['不适用', '未选择'].includes(c.status)
|
|
33
|
+
? 'skipped'
|
|
34
|
+
: 'failed',
|
|
35
|
+
reason: `${c.status}:${c.reason}`,
|
|
36
|
+
screenshot: c.evidence || undefined,
|
|
37
|
+
assertions: [
|
|
38
|
+
...c.steps.flatMap((step, i) => step.kind.startsWith('assert-')
|
|
39
|
+
? [
|
|
40
|
+
{
|
|
41
|
+
step: i + 1,
|
|
42
|
+
expected: assertionTitle(step),
|
|
43
|
+
actual: '页面断言已通过,原始执行记录和浏览器证据见报告。',
|
|
44
|
+
passed: true,
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
: []),
|
|
48
|
+
...(c.failedStep?.action.startsWith('assert-')
|
|
49
|
+
? [
|
|
50
|
+
{
|
|
51
|
+
step: c.failedStep.number,
|
|
52
|
+
expected: assertionTitle({
|
|
53
|
+
kind: c.failedStep.action,
|
|
54
|
+
target: { name: c.failedStep.target },
|
|
55
|
+
}),
|
|
56
|
+
actual: c.reason,
|
|
57
|
+
passed: false,
|
|
58
|
+
},
|
|
59
|
+
]
|
|
60
|
+
: []),
|
|
61
|
+
],
|
|
62
|
+
errors: (c.browserEvents ?? []).map((e) => e.message ?? e.type ?? '页面事件'),
|
|
63
|
+
...(report.retainedRecord
|
|
64
|
+
? { cleanup: `保留测试记录:${report.retainedRecord}` }
|
|
65
|
+
: report.pendingWrite
|
|
66
|
+
? { cleanup: '存在未确认写入,请核对 checkpoint.json 后清理。' }
|
|
67
|
+
: {}),
|
|
68
|
+
}));
|
|
69
|
+
const passed = cases.filter((c) => c.state === 'passed').length;
|
|
70
|
+
const state = !final
|
|
71
|
+
? 'running'
|
|
72
|
+
: report.runStatus === 'interrupted'
|
|
73
|
+
? 'stopped'
|
|
74
|
+
: report.exitCode === 0
|
|
75
|
+
? 'passed'
|
|
76
|
+
: passed
|
|
77
|
+
? 'partial'
|
|
78
|
+
: 'failed';
|
|
79
|
+
return {
|
|
80
|
+
mode,
|
|
81
|
+
state,
|
|
82
|
+
cases,
|
|
83
|
+
decisions: report.metrics?.modelCalls ?? 0,
|
|
84
|
+
message: !final
|
|
85
|
+
? (report.activeCase?.title ?? '上游 LayaPilot 正在执行')
|
|
86
|
+
: (report.error ??
|
|
87
|
+
`${mode === 'explore' ? '探索' : '回放'}结束:${passed} 条通过,${cases.filter((c) => c.state === 'failed').length} 条失败,${cases.filter((c) => c.state === 'skipped').length} 条不适用/未选择`),
|
|
88
|
+
...(final && mode === 'explore' && report.caseFile ? { workbook: 'cases.xlsx' } : {}),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/agent/report.ts"],"names":[],"mappings":"AA+BA,SAAS,cAAc,CAAC,IAAkB;IACxC,IAA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AE,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,MAAM,QAAQ,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,MAAM,WAAW,CAAC;QAChL,GAAG,CAAC,KAAK,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACtF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type AgentStatus } from './schema.js';
|
|
2
|
+
export interface AgentOptions {
|
|
3
|
+
url: string;
|
|
4
|
+
outputDir: string;
|
|
5
|
+
python: string;
|
|
6
|
+
model: string;
|
|
7
|
+
workbook?: string;
|
|
8
|
+
allowWrite?: boolean;
|
|
9
|
+
headed?: boolean;
|
|
10
|
+
channel?: string;
|
|
11
|
+
authState?: string;
|
|
12
|
+
authCheck?: string;
|
|
13
|
+
manualLogin?: boolean;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
timeout?: number;
|
|
16
|
+
onProgress?: (status: AgentStatus) => void;
|
|
17
|
+
}
|
|
18
|
+
/** Functional npm facade over the pinned upstream generate/execute workflow. No second planner. */
|
|
19
|
+
export declare function runAgent(options: AgentOptions): Promise<AgentStatus>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { fork, execFile } from 'node:child_process';
|
|
2
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { testUrl } from './schema.js';
|
|
7
|
+
import { projectReport } from './report.js';
|
|
8
|
+
/** Functional npm facade over the pinned upstream generate/execute workflow. No second planner. */
|
|
9
|
+
export async function runAgent(options) {
|
|
10
|
+
options.signal?.throwIfAborted();
|
|
11
|
+
const url = testUrl(options.url), outputDir = path.resolve(options.outputDir);
|
|
12
|
+
if (!existsSync(options.python) || !existsSync(options.model))
|
|
13
|
+
throw Error('请配置可用的本地 Laya Python 和模型路径');
|
|
14
|
+
if (options.authState && !options.authCheck)
|
|
15
|
+
throw Error('复用登录态需要 authCheck 校验登录成功页面');
|
|
16
|
+
await mkdir(outputDir, { recursive: true });
|
|
17
|
+
if (existsSync(path.join(outputDir, 'checkpoint.json')))
|
|
18
|
+
throw Error('输出目录已有运行记录,请使用新的目录');
|
|
19
|
+
const mode = options.workbook ? 'replay' : 'explore';
|
|
20
|
+
let last = {
|
|
21
|
+
state: 'running',
|
|
22
|
+
mode,
|
|
23
|
+
message: '正在启动上游 LayaPilot',
|
|
24
|
+
cases: [],
|
|
25
|
+
decisions: 0,
|
|
26
|
+
};
|
|
27
|
+
options.onProgress?.(last);
|
|
28
|
+
const child = fork(fileURLToPath(new URL('./worker.js', import.meta.url)), [], {
|
|
29
|
+
execArgv: [],
|
|
30
|
+
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
|
31
|
+
...{ windowsHide: true },
|
|
32
|
+
env: {
|
|
33
|
+
...process.env,
|
|
34
|
+
PYTHONIOENCODING: 'utf-8',
|
|
35
|
+
PYTHONUTF8: '1',
|
|
36
|
+
PYTHONDONTWRITEBYTECODE: '1',
|
|
37
|
+
HF_HUB_OFFLINE: '1',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
let stopped = false, finished = false, diagnostic = '', stopping;
|
|
41
|
+
const stop = () => {
|
|
42
|
+
if (stopped)
|
|
43
|
+
return;
|
|
44
|
+
stopped = true;
|
|
45
|
+
if (child.connected)
|
|
46
|
+
child.send({ type: 'stop' }, () => { });
|
|
47
|
+
stopping = setTimeout(() => {
|
|
48
|
+
if (child.exitCode !== null || !child.pid)
|
|
49
|
+
return;
|
|
50
|
+
if (process.platform === 'win32')
|
|
51
|
+
execFile('taskkill', ['/PID', String(child.pid), '/T', '/F'], { windowsHide: true }, () => { });
|
|
52
|
+
else
|
|
53
|
+
child.kill('SIGKILL');
|
|
54
|
+
}, 20000);
|
|
55
|
+
};
|
|
56
|
+
options.signal?.addEventListener('abort', stop, { once: true });
|
|
57
|
+
const timeout = setTimeout(stop, options.timeout ?? 12 * 60 * 1000);
|
|
58
|
+
const readProgress = async () => {
|
|
59
|
+
try {
|
|
60
|
+
const report = JSON.parse(await readFile(path.join(outputDir, 'checkpoint.json'), 'utf8'));
|
|
61
|
+
if (finished)
|
|
62
|
+
return;
|
|
63
|
+
last = projectReport(report, mode, false);
|
|
64
|
+
options.onProgress?.(last);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
/* Atomic checkpoint may not exist until startup completes. */
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const polling = setInterval(() => void readProgress(), 1000);
|
|
71
|
+
child.stdout?.on('data', (chunk) => {
|
|
72
|
+
const message = chunk.toString().trim();
|
|
73
|
+
if (message && !message.startsWith('RESULT '))
|
|
74
|
+
options.onProgress?.({ ...last, message: message.slice(-1000) });
|
|
75
|
+
});
|
|
76
|
+
child.stderr?.on('data', (chunk) => {
|
|
77
|
+
diagnostic = (diagnostic + chunk.toString()).slice(-1000);
|
|
78
|
+
});
|
|
79
|
+
child.on('message', (message) => {
|
|
80
|
+
if (message.error)
|
|
81
|
+
diagnostic = message.error;
|
|
82
|
+
});
|
|
83
|
+
try {
|
|
84
|
+
const exited = new Promise((resolve, reject) => {
|
|
85
|
+
child.once('error', reject);
|
|
86
|
+
child.once('exit', resolve);
|
|
87
|
+
});
|
|
88
|
+
child.send({
|
|
89
|
+
type: 'run',
|
|
90
|
+
options: { ...options, url, outputDir, signal: undefined, onProgress: undefined },
|
|
91
|
+
});
|
|
92
|
+
if (options.signal?.aborted)
|
|
93
|
+
stop();
|
|
94
|
+
const code = await exited;
|
|
95
|
+
finished = true;
|
|
96
|
+
clearInterval(polling);
|
|
97
|
+
let report;
|
|
98
|
+
try {
|
|
99
|
+
report = JSON.parse(await readFile(path.join(outputDir, 'results.json'), 'utf8'));
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
report = { results: [], exitCode: code ?? 1, error: diagnostic || '上游执行未生成报告' };
|
|
103
|
+
}
|
|
104
|
+
last = projectReport(report, mode, true);
|
|
105
|
+
if (stopped)
|
|
106
|
+
last.state = 'stopped';
|
|
107
|
+
if (existsSync(path.join(outputDir, 'trace.zip')))
|
|
108
|
+
last.trace = 'trace.zip';
|
|
109
|
+
await writeFile(path.join(outputDir, 'assistant-status.json'), JSON.stringify(last, null, 2));
|
|
110
|
+
options.onProgress?.(last);
|
|
111
|
+
return last;
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
finished = true;
|
|
115
|
+
clearInterval(polling);
|
|
116
|
+
clearTimeout(timeout);
|
|
117
|
+
clearTimeout(stopping);
|
|
118
|
+
options.signal?.removeEventListener('abort', stop);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/agent/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAoB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,aAAa,EAAuB,MAAM,aAAa,CAAC;AAkBjE,mGAAmG;AACnG,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAqB;IAClD,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,C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B,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9F,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;YAAS,CAAC;QACT,QAAQ,GAAG,IAAI,CAAC;QAChB,aAAa,CAAC,OAAO,CAAC,CAAC;QACvB,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,YAAY,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** UI projection of upstream reports. Execution and workbook grammar remain upstream-owned. */
|
|
2
|
+
export interface CaseEvidence {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
state: 'passed' | 'failed' | 'skipped';
|
|
6
|
+
reason: string;
|
|
7
|
+
assertions: {
|
|
8
|
+
step: number;
|
|
9
|
+
expected: string;
|
|
10
|
+
actual: string;
|
|
11
|
+
passed: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
screenshot?: string;
|
|
14
|
+
errors: string[];
|
|
15
|
+
cleanup?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface AgentStatus {
|
|
18
|
+
id?: string;
|
|
19
|
+
state: 'idle' | 'running' | 'passed' | 'partial' | 'failed' | 'stopped';
|
|
20
|
+
mode: 'explore' | 'replay';
|
|
21
|
+
message: string;
|
|
22
|
+
cases: CaseEvidence[];
|
|
23
|
+
decisions: number;
|
|
24
|
+
workbook?: string;
|
|
25
|
+
trace?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface AgentCapabilities {
|
|
28
|
+
configured: boolean;
|
|
29
|
+
message: string;
|
|
30
|
+
targets: string[];
|
|
31
|
+
}
|
|
32
|
+
export declare function testUrl(value: unknown): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function testUrl(value) {
|
|
2
|
+
if (typeof value !== 'string' || value.length > 2000)
|
|
3
|
+
throw Error('测试地址格式错误');
|
|
4
|
+
const url = new URL(value);
|
|
5
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password)
|
|
6
|
+
throw Error('测试地址必须为不含凭据的 HTTP(S) 地址');
|
|
7
|
+
return url.href;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/agent/schema.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI;QAAE,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9E,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ;QAC7E,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACzC,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|