@autotest/agent 0.0.3 → 0.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 +130 -75
- package/dist/api/agent_api.d.ts +2 -6
- package/dist/api/agent_api.js +6 -11
- package/dist/autotest-cli.js +9 -2
- package/dist/common/config/config.yaml +134 -0
- package/dist/common/model/custom_model.js +24 -5
- package/dist/common/path_utils.d.ts +7 -3
- package/dist/common/path_utils.js +12 -5
- package/dist/common/result_parser.js +1 -1
- package/dist/core/agent/layered_agent/decision.js +61 -23
- package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.d.ts +1 -1
- package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.js +5 -5
- package/dist/core/agent/layered_agent/execute_agent/parser/general_parser.js +1 -1
- package/dist/core/agent/layered_agent/execute_agent/parser/glm_parser.js +1 -1
- package/dist/core/agent/layered_agent/execute_agent/parser/mai_ui_parser.js +1 -1
- package/dist/core/agent/layered_agent/execute_agent/prompts.d.ts +1 -1
- package/dist/core/agent/layered_agent/execute_agent/prompts.js +5 -5
- package/dist/core/mcp/mcp_tools.d.ts +19 -2
- package/dist/core/mcp/mcp_tools.js +40 -12
- package/dist/core/memory/_utils.d.ts +18 -0
- package/dist/core/memory/_utils.js +140 -0
- package/dist/core/memory/replan_manager.d.ts +9 -0
- package/dist/core/memory/replan_manager.js +12 -0
- package/dist/core/memory/tool_player_popup.d.ts +66 -0
- package/dist/core/memory/tool_player_popup.js +276 -0
- package/dist/core/memory/tool_player_replan.d.ts +49 -0
- package/dist/core/memory/tool_player_replan.js +226 -0
- package/dist/core/memory/tool_player_xpath.d.ts +52 -0
- package/dist/core/memory/tool_player_xpath.js +139 -0
- package/dist/core/prompt/prompt_loader.js +3 -1
- package/dist/core/prompt/templates/debug/hypium/hypium_v2.0_optimize_scroll_search.md +310 -0
- package/dist/core/prompt/templates/debug/hypium/hypium_v2.0_relative_1000.md +284 -0
- package/dist/core/prompt/templates/debug/planner/planner_v3.0.md +140 -0
- package/dist/core/prompt/templates/debug/single/single_v2.0_optimize_scroll_search.md +272 -0
- package/dist/core/prompt/templates/debug/single/single_v2.0_relative_1000.md +277 -0
- package/dist/core/prompt/templates/single/single_v2.0_0_1000.md +315 -0
- package/dist/core/skill/skill_manager.js +4 -1
- package/dist/core/skill/skills/cancel-all-follows/SKILL.md +23 -0
- package/dist/core/skill/skills/create-local-image/SKILL.md +12 -0
- package/dist/core/skill/skills/create-local-video/SKILL.md +12 -0
- package/dist/core/skill/skills/dismiss-popups/SKILL.md +39 -0
- package/dist/core/skill/skills/douyin_test_skills.md +16 -0
- package/dist/data_types/case.d.ts +32 -0
- package/dist/data_types/case.js +57 -0
- package/dist/data_types/index.d.ts +2 -0
- package/dist/data_types/index.js +6 -1
- package/dist/data_types/screen.d.ts +12 -0
- package/dist/data_types/screen.js +23 -0
- package/dist/mcp-server/types.js +72 -50
- package/dist/reporter/generator.d.ts +0 -14
- package/dist/reporter/generator.js +18 -504
- package/dist/reporter/html_template/index.d.ts +56 -0
- package/dist/reporter/html_template/index.js +524 -0
- package/dist/reporter/json_report.d.ts +1 -0
- package/dist/reporter/json_report.js +6 -0
- package/dist/reporter/types.d.ts +1 -0
- package/dist/reporter/types.js +1 -0
- package/dist/tools/batch_runner.d.ts +3 -1
- package/dist/tools/batch_runner.js +13 -6
- package/dist/tools/case_runner/report.d.ts +9 -0
- package/dist/tools/case_runner/report.js +264 -0
- package/dist/tools/case_runner/runner.d.ts +57 -0
- package/dist/tools/case_runner/runner.js +410 -0
- package/dist/tools/config/config_tool.d.ts +13 -0
- package/dist/tools/config/config_tool.js +339 -0
- package/dist/tools/prompt_compare/compare_runner.d.ts +13 -0
- package/dist/tools/prompt_compare/compare_runner.js +360 -0
- package/package.json +7 -3
|
@@ -36,15 +36,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.ReportGeneratorImpl = void 0;
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
|
+
const result_parser_1 = require("../common/result_parser");
|
|
39
40
|
const types_1 = require("./types");
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
click: '点击', long_click: '长按', double_click: '双击',
|
|
43
|
-
swipe: '滑动', drag: '拖拽', input_text: '输入文本',
|
|
44
|
-
go_back: '返回', go_home: '回到桌面', start_app: '启动应用',
|
|
45
|
-
stop_app: '停止应用', wait: '等待', press_key: '按键',
|
|
46
|
-
screen_on: '点亮屏幕', unlock_screen: '解锁屏幕', clear_recent_task: '清空最近任务',
|
|
47
|
-
};
|
|
41
|
+
const html_template_1 = require("./html_template");
|
|
42
|
+
const json_report_1 = require("./json_report");
|
|
48
43
|
class ReportGeneratorImpl {
|
|
49
44
|
events = [];
|
|
50
45
|
totalTokens = {
|
|
@@ -98,7 +93,7 @@ class ReportGeneratorImpl {
|
|
|
98
93
|
return;
|
|
99
94
|
try {
|
|
100
95
|
const data = this.serializeForJson();
|
|
101
|
-
fs.writeFileSync(path.join(this.reportDir, 'report.json'),
|
|
96
|
+
fs.writeFileSync(path.join(this.reportDir, 'report.json'), (0, json_report_1.generateJson)(data), 'utf-8');
|
|
102
97
|
}
|
|
103
98
|
catch {
|
|
104
99
|
// flush failure is non-blocking
|
|
@@ -153,18 +148,7 @@ class ReportGeneratorImpl {
|
|
|
153
148
|
endTask(result, status) {
|
|
154
149
|
this.endTime = new Date().toISOString();
|
|
155
150
|
if (!status) {
|
|
156
|
-
|
|
157
|
-
this.status = 'FAIL';
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
const m = result.match(/结果\s*[::]\s*(不?通过)/);
|
|
161
|
-
if (m) {
|
|
162
|
-
this.status = m[1] === '通过' ? 'PASS' : 'FAIL';
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
this.status = this.status ?? 'UNKNOWN';
|
|
166
|
-
}
|
|
167
|
-
}
|
|
151
|
+
this.status = (0, result_parser_1.parseTaskResult)(null, result).status;
|
|
168
152
|
}
|
|
169
153
|
else {
|
|
170
154
|
this.status = status.toUpperCase();
|
|
@@ -200,11 +184,15 @@ class ReportGeneratorImpl {
|
|
|
200
184
|
const name = baseFilename ?? 'report';
|
|
201
185
|
const reportData = this.buildReportData();
|
|
202
186
|
const jsonPath = path.join(this.reportDir, `${name}.json`);
|
|
203
|
-
fs.writeFileSync(jsonPath,
|
|
187
|
+
fs.writeFileSync(jsonPath, (0, json_report_1.generateJson)(this.serializeForJson()), 'utf-8');
|
|
204
188
|
const mdPath = path.join(this.reportDir, `${name}.md`);
|
|
205
189
|
fs.writeFileSync(mdPath, this.generateMarkdown(reportData), 'utf-8');
|
|
206
190
|
const htmlPath = path.join(this.reportDir, `${name}.html`);
|
|
207
|
-
fs.writeFileSync(htmlPath, await
|
|
191
|
+
fs.writeFileSync(htmlPath, await (0, html_template_1.generateHtmlFromJson)(reportData, {
|
|
192
|
+
reportDir: this.reportDir,
|
|
193
|
+
embedImages: this.embedImages,
|
|
194
|
+
embedMaxPixels: this.embedMaxPixels,
|
|
195
|
+
}), 'utf-8');
|
|
208
196
|
return { json: jsonPath, markdown: mdPath, html: htmlPath };
|
|
209
197
|
}
|
|
210
198
|
getReportDir() { return this.reportDir; }
|
|
@@ -240,215 +228,6 @@ class ReportGeneratorImpl {
|
|
|
240
228
|
}
|
|
241
229
|
return d;
|
|
242
230
|
}
|
|
243
|
-
toRelativePath(absPath) {
|
|
244
|
-
if (!absPath)
|
|
245
|
-
return '';
|
|
246
|
-
try {
|
|
247
|
-
return path.relative(this.reportDir, absPath).replace(/\\/g, '/');
|
|
248
|
-
}
|
|
249
|
-
catch {
|
|
250
|
-
return absPath;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
async resolveImgSrc(relPath) {
|
|
254
|
-
if (!relPath || !this.embedImages)
|
|
255
|
-
return relPath;
|
|
256
|
-
const abs = path.resolve(this.reportDir, relPath);
|
|
257
|
-
const base64 = await (0, image_helper_1.compressImageToBase64)(abs, this.embedMaxPixels);
|
|
258
|
-
return base64 || relPath;
|
|
259
|
-
}
|
|
260
|
-
escapeHtml(text) {
|
|
261
|
-
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
262
|
-
.replace(/"/g, '"').replace(/'/g, ''');
|
|
263
|
-
}
|
|
264
|
-
formatDuration(s, e) {
|
|
265
|
-
if (!s || !e)
|
|
266
|
-
return 'N/A';
|
|
267
|
-
const d = new Date(e).getTime() - new Date(s).getTime();
|
|
268
|
-
return `${Math.floor(d / 60000)}:${Math.floor((d % 60000) / 1000).toString().padStart(2, '0')}`;
|
|
269
|
-
}
|
|
270
|
-
formatTime(iso) {
|
|
271
|
-
try {
|
|
272
|
-
const d = new Date(iso);
|
|
273
|
-
return `${d.getHours().toString().padStart(2, '0')}:${d.getMinutes().toString().padStart(2, '0')}:${d.getSeconds().toString().padStart(2, '0')}.${d.getMilliseconds().toString().padStart(3, '0').slice(0, 2)}`;
|
|
274
|
-
}
|
|
275
|
-
catch {
|
|
276
|
-
return iso;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
formatTokenCount(n) {
|
|
280
|
-
if (n >= 1000000)
|
|
281
|
-
return `${(n / 1000000).toFixed(1)}M`;
|
|
282
|
-
if (n >= 1000)
|
|
283
|
-
return `${(n / 1000).toFixed(1)}K`;
|
|
284
|
-
return String(n);
|
|
285
|
-
}
|
|
286
|
-
extractStepTitle(g) {
|
|
287
|
-
if (!g.toolCall)
|
|
288
|
-
return g.thinking ? g.thinking.split('\n')[0].slice(0, 50) : `步骤 ${g.step}`;
|
|
289
|
-
const name = g.toolCall.name;
|
|
290
|
-
const args = g.toolCallArgs ?? {};
|
|
291
|
-
if (args.log && typeof args.log === 'string')
|
|
292
|
-
return args.log;
|
|
293
|
-
if (name === 'start_app' && args.app_name)
|
|
294
|
-
return `启动${args.app_name}`;
|
|
295
|
-
if (name === 'stop_app' && args.app_name)
|
|
296
|
-
return `停止${args.app_name}`;
|
|
297
|
-
if (name === 'wait' && args.duration)
|
|
298
|
-
return `等待${args.duration}秒`;
|
|
299
|
-
if (name === 'input_text' && args.text)
|
|
300
|
-
return `输入"${args.text}"`;
|
|
301
|
-
if (name === 'press_key' && args.key_name)
|
|
302
|
-
return `按下${args.key_name}键`;
|
|
303
|
-
return TOOL_NAME_MAP[name] ?? name;
|
|
304
|
-
}
|
|
305
|
-
asPoint2(v) {
|
|
306
|
-
if (Array.isArray(v) && v.length === 2 && typeof v[0] === 'number' && typeof v[1] === 'number') {
|
|
307
|
-
return [v[0], v[1]];
|
|
308
|
-
}
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
asPointFromXY(x, y) {
|
|
312
|
-
if (typeof x === 'number' && typeof y === 'number')
|
|
313
|
-
return [x, y];
|
|
314
|
-
if (typeof x === 'number')
|
|
315
|
-
return [x, 0];
|
|
316
|
-
if (typeof y === 'number')
|
|
317
|
-
return [0, y];
|
|
318
|
-
return null;
|
|
319
|
-
}
|
|
320
|
-
stripTagMarkers(text) {
|
|
321
|
-
return text.replace(/<\/?(?:thinking|judgment|judgement)\b[^>]*>/gi, '').trim();
|
|
322
|
-
}
|
|
323
|
-
groupSteps(data) {
|
|
324
|
-
const groups = new Map();
|
|
325
|
-
for (const ev of data.events) {
|
|
326
|
-
const s = ev.stepNumber;
|
|
327
|
-
if (s == null || s <= 0)
|
|
328
|
-
continue;
|
|
329
|
-
if (!groups.has(s)) {
|
|
330
|
-
groups.set(s, {
|
|
331
|
-
step: s, thinking: '', reasoning: '', toolCall: null, toolCallArgs: null,
|
|
332
|
-
observationScreenshot: null, beforeScreenshot: null, afterScreenshot: null,
|
|
333
|
-
toolResult: '', toolStartTime: '', toolEndTime: '',
|
|
334
|
-
stepStartTime: '', stepEndTime: '', clickPoint: null, swipeStart: null, swipeEnd: null,
|
|
335
|
-
action: null, subSteps: [], hasSubAgent: false,
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
const g = groups.get(s);
|
|
339
|
-
const d = ev.data;
|
|
340
|
-
const sr = this.toRelativePath(ev.screenshotPath);
|
|
341
|
-
if (ev.eventType === 'llm_response' || ev.eventType === 'planner_thinking' || ev.eventType === 'planner_output') {
|
|
342
|
-
const reasoning = d?.reasoning ?? '';
|
|
343
|
-
if (reasoning)
|
|
344
|
-
g.reasoning = reasoning;
|
|
345
|
-
const thinking = d?.thinking ?? '';
|
|
346
|
-
const judgment = d?.judgment ?? '';
|
|
347
|
-
const raw = d?.text ?? ev.content ?? '';
|
|
348
|
-
const chosen = thinking || judgment || raw;
|
|
349
|
-
if (chosen)
|
|
350
|
-
g.thinking = this.stripTagMarkers(chosen);
|
|
351
|
-
}
|
|
352
|
-
else if (ev.eventType === 'screenshot' || ev.eventType === 'planner_observation') {
|
|
353
|
-
const phase = d?.phase ?? 'observation';
|
|
354
|
-
if (phase === 'after' && sr)
|
|
355
|
-
g.afterScreenshot = sr;
|
|
356
|
-
else if (phase === 'before' && sr)
|
|
357
|
-
g.beforeScreenshot = sr;
|
|
358
|
-
else if (!g.observationScreenshot && sr)
|
|
359
|
-
g.observationScreenshot = sr;
|
|
360
|
-
}
|
|
361
|
-
else if (ev.eventType === 'planner_tool_call') {
|
|
362
|
-
const tn = d?.tool_name ?? d?.toolName ?? '';
|
|
363
|
-
const rawArgs = d?.arguments ?? d?.args;
|
|
364
|
-
g.toolCall = { name: tn, args: rawArgs ? JSON.stringify(rawArgs, null, 2) : (ev.content ?? '') };
|
|
365
|
-
g.toolCallArgs = (rawArgs && typeof rawArgs === 'object') ? rawArgs : null;
|
|
366
|
-
}
|
|
367
|
-
else if (ev.eventType === 'mcp_tool_start') {
|
|
368
|
-
g.toolStartTime = ev.timestamp;
|
|
369
|
-
if (sr)
|
|
370
|
-
g.beforeScreenshot = sr;
|
|
371
|
-
const dd = d;
|
|
372
|
-
if (dd) {
|
|
373
|
-
const args = (dd.args ?? dd.arguments ?? {});
|
|
374
|
-
const toolName = dd.action ?? dd.tool_name ?? '';
|
|
375
|
-
if (toolName)
|
|
376
|
-
g.action = toolName;
|
|
377
|
-
if (toolName === 'run_subagent' || toolName === 'run_subagent_tool') {
|
|
378
|
-
g.hasSubAgent = true;
|
|
379
|
-
}
|
|
380
|
-
const point = this.asPoint2(dd.point) ?? this.asPoint2(args.pos) ?? this.asPointFromXY(args.x, args.y);
|
|
381
|
-
const start = this.asPoint2(dd.start) ?? this.asPoint2(args.start) ?? this.asPointFromXY(args.start_x, args.start_y);
|
|
382
|
-
const end = this.asPoint2(dd.end) ?? this.asPoint2(args.end) ?? this.asPointFromXY(args.end_x, args.end_y);
|
|
383
|
-
if (point)
|
|
384
|
-
g.clickPoint = point;
|
|
385
|
-
if (start)
|
|
386
|
-
g.swipeStart = start;
|
|
387
|
-
if (end)
|
|
388
|
-
g.swipeEnd = end;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
else if (ev.eventType === 'mcp_tool_end') {
|
|
392
|
-
g.toolEndTime = ev.timestamp;
|
|
393
|
-
if (sr)
|
|
394
|
-
g.afterScreenshot = sr;
|
|
395
|
-
g.toolResult = d?.result ?? ev.content ?? '';
|
|
396
|
-
}
|
|
397
|
-
else if (ev.eventType === 'step_start') {
|
|
398
|
-
g.stepStartTime = ev.timestamp;
|
|
399
|
-
}
|
|
400
|
-
else if (ev.eventType === 'step_end') {
|
|
401
|
-
g.stepEndTime = ev.timestamp;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
return Array.from(groups.values()).sort((a, b) => a.step - b.step);
|
|
405
|
-
}
|
|
406
|
-
getStepTokens(data, step) {
|
|
407
|
-
let input = 0, output = 0, cached = 0, reasoning = 0, total = 0, normalized = 0;
|
|
408
|
-
for (const st of data.step_tokens) {
|
|
409
|
-
if (st.stepNumber === step || st.step === step) {
|
|
410
|
-
input += (st.inputTokens ?? st.input_tokens ?? 0);
|
|
411
|
-
output += (st.outputTokens ?? st.output_tokens ?? 0);
|
|
412
|
-
cached += (st.cachedTokens ?? st.cached_tokens ?? 0);
|
|
413
|
-
reasoning += (st.reasoningTokens ?? st.reasoning_tokens ?? 0);
|
|
414
|
-
total += (st.totalTokens ?? st.total_tokens ?? 0);
|
|
415
|
-
normalized += (st.normalizedTokens ?? st.normalized_tokens ?? 0);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return { input, output, cached, reasoning, total, normalized };
|
|
419
|
-
}
|
|
420
|
-
getFinalStatus(data) {
|
|
421
|
-
const r = { status: 'UNKNOWN', result: '', judgment: '', screenshot: '' };
|
|
422
|
-
for (const ev of data.events) {
|
|
423
|
-
if (ev.eventType === 'task_end') {
|
|
424
|
-
const d = ev.data;
|
|
425
|
-
const rawStatus = d?.status ?? '';
|
|
426
|
-
const rawResult = d?.result ?? ev.content ?? '';
|
|
427
|
-
// Strategy A: explicit status
|
|
428
|
-
if (['pass', 'completed', 'success'].includes(rawStatus.toLowerCase()))
|
|
429
|
-
r.status = 'PASS';
|
|
430
|
-
else if (['fail', 'failed', 'error', 'stopped'].includes(rawStatus.toLowerCase()))
|
|
431
|
-
r.status = 'FAIL';
|
|
432
|
-
else if (rawStatus)
|
|
433
|
-
r.status = rawStatus.toUpperCase();
|
|
434
|
-
r.result = rawResult;
|
|
435
|
-
// Strategy B: Chinese keyword matching
|
|
436
|
-
const m = rawResult.match(/结果\s*[::]\s*(不?通过)/);
|
|
437
|
-
if (m)
|
|
438
|
-
r.status = m[1] === '通过' ? 'PASS' : 'FAIL';
|
|
439
|
-
// Strategy C: error pattern
|
|
440
|
-
if (rawResult.startsWith('Error:') || rawResult.startsWith('任务执行失败') || rawResult.includes('超过最大步数'))
|
|
441
|
-
r.status = 'FAIL';
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
const steps = this.groupSteps(data);
|
|
445
|
-
const last = steps[steps.length - 1];
|
|
446
|
-
if (last) {
|
|
447
|
-
r.judgment = last.thinking || last.reasoning;
|
|
448
|
-
r.screenshot = last.afterScreenshot || last.observationScreenshot || '';
|
|
449
|
-
}
|
|
450
|
-
return r;
|
|
451
|
-
}
|
|
452
231
|
generateMarkdown(data) {
|
|
453
232
|
const lines = [];
|
|
454
233
|
lines.push('# 执行报告', '');
|
|
@@ -457,9 +236,9 @@ class ReportGeneratorImpl {
|
|
|
457
236
|
lines.push(`- **任务描述**: ${data.task || 'N/A'}`);
|
|
458
237
|
lines.push(`- **开始时间**: ${data.start_time ?? 'N/A'}`);
|
|
459
238
|
lines.push(`- **结束时间**: ${data.end_time ?? 'N/A'}`);
|
|
460
|
-
lines.push(`- **耗时**: ${
|
|
239
|
+
lines.push(`- **耗时**: ${(0, html_template_1.formatDuration)(data.start_time, data.end_time)}`, '');
|
|
461
240
|
lines.push('### Token 消耗', '');
|
|
462
|
-
lines.push(`- **总 Token**: ${
|
|
241
|
+
lines.push(`- **总 Token**: ${(0, html_template_1.formatTokenCount)(data.total_tokens.total)}`);
|
|
463
242
|
lines.push(`- **输入**: ${data.total_tokens.inputTokens}`);
|
|
464
243
|
lines.push(`- **输出**: ${data.total_tokens.outputTokens}`);
|
|
465
244
|
lines.push(`- **推理**: ${data.total_tokens.reasoningTokens}`);
|
|
@@ -468,16 +247,16 @@ class ReportGeneratorImpl {
|
|
|
468
247
|
if (sk.length > 0)
|
|
469
248
|
lines.push(`- **来源**: ${sk.map(s => `${s}: ${data.total_tokens.sources[s].total}`).join(' | ')}`);
|
|
470
249
|
lines.push(`- **总事件数**: ${data.events.length}`, '');
|
|
471
|
-
const steps =
|
|
250
|
+
const steps = (0, html_template_1.groupSteps)(data, this.reportDir);
|
|
472
251
|
if (steps.length > 0) {
|
|
473
252
|
lines.push('## 执行时间线', '');
|
|
474
|
-
const fr =
|
|
253
|
+
const fr = (0, html_template_1.getFinalStatus)(data, this.reportDir);
|
|
475
254
|
lines.push(`**最终结果**: ${fr.status} ${fr.result ? '— ' + fr.result : ''}`, '');
|
|
476
255
|
for (const g of steps) {
|
|
477
|
-
const t =
|
|
478
|
-
const title =
|
|
256
|
+
const t = (0, html_template_1.getStepTokens)(data, g.step);
|
|
257
|
+
const title = (0, html_template_1.extractStepTitle)(g);
|
|
479
258
|
lines.push(`### Step ${g.step}: ${title}`, '');
|
|
480
|
-
lines.push(`- **时间**: ${g.stepStartTime ?
|
|
259
|
+
lines.push(`- **时间**: ${g.stepStartTime ? (0, html_template_1.formatTime)(g.stepStartTime) : 'N/A'} ~ ${g.stepEndTime ? (0, html_template_1.formatTime)(g.stepEndTime) : 'N/A'}`);
|
|
481
260
|
lines.push(`- **Token**: 输入 ${t.input} | 输出 ${t.output} | 缓存 ${t.cached} | 推理 ${t.reasoning} | 归一化 ${t.normalized}`, '');
|
|
482
261
|
if (g.reasoning) {
|
|
483
262
|
lines.push('#### 💭 思考过程', '', g.reasoning, '');
|
|
@@ -503,270 +282,5 @@ class ReportGeneratorImpl {
|
|
|
503
282
|
}
|
|
504
283
|
return lines.join('\n');
|
|
505
284
|
}
|
|
506
|
-
async generateHtml(data) {
|
|
507
|
-
const steps = this.groupSteps(data);
|
|
508
|
-
const fr = this.getFinalStatus(data);
|
|
509
|
-
const sc = fr.status === 'PASS' ? 'pass' : fr.status === 'FAIL' ? 'fail' : '';
|
|
510
|
-
const dur = this.formatDuration(data.start_time, data.end_time);
|
|
511
|
-
const tn = this.formatTokenCount(data.total_tokens.total);
|
|
512
|
-
// Pre-resolve screenshot paths to base64 if embedImages is enabled
|
|
513
|
-
const allPaths = new Set();
|
|
514
|
-
for (const g of steps) {
|
|
515
|
-
if (g.observationScreenshot)
|
|
516
|
-
allPaths.add(g.observationScreenshot);
|
|
517
|
-
if (g.beforeScreenshot)
|
|
518
|
-
allPaths.add(g.beforeScreenshot);
|
|
519
|
-
if (g.afterScreenshot)
|
|
520
|
-
allPaths.add(g.afterScreenshot);
|
|
521
|
-
}
|
|
522
|
-
if (fr.screenshot)
|
|
523
|
-
allPaths.add(fr.screenshot);
|
|
524
|
-
const imgSrcMap = new Map();
|
|
525
|
-
if (this.embedImages) {
|
|
526
|
-
await Promise.all(Array.from(allPaths).map(async (p) => {
|
|
527
|
-
const embedded = await this.resolveImgSrc(p);
|
|
528
|
-
imgSrcMap.set(p, embedded);
|
|
529
|
-
}));
|
|
530
|
-
}
|
|
531
|
-
const resolveSrc = (p) => {
|
|
532
|
-
if (!p)
|
|
533
|
-
return '';
|
|
534
|
-
return imgSrcMap.get(p) ?? p;
|
|
535
|
-
};
|
|
536
|
-
const navItems = steps.map((g, i) => {
|
|
537
|
-
const title = this.extractStepTitle(g);
|
|
538
|
-
return `<div class="nav-item" title="${this.escapeHtml(title)}" onclick="scrollToStep(${i})">${i + 1}. ${this.escapeHtml(title)}</div>`;
|
|
539
|
-
}).join('\n');
|
|
540
|
-
const stepCards = steps.map((g, idx) => {
|
|
541
|
-
const t = this.getStepTokens(data, g.step);
|
|
542
|
-
const tb = t.total > 0 ? `<span class="step-token-badge" title="输入: ${t.input} | 输出: ${t.output} | 缓存: ${t.cached} | 推理: ${t.reasoning}">${this.formatTokenCount(t.total)}</span>` : '';
|
|
543
|
-
const tr = g.stepStartTime ? `${this.formatTime(g.stepStartTime)} ~ ${g.stepEndTime ? this.formatTime(g.stepEndTime) : 'N/A'}` : '';
|
|
544
|
-
const tb2 = (g.reasoning || g.thinking) ? `<div class="thinking"><div class="thinking-label">思考过程</div><div class="thinking-text">${this.escapeHtml(g.reasoning || g.thinking)}</div></div>` : '';
|
|
545
|
-
const tcb = g.toolCall ? `<div class="event planner"><div class="event-head"><span class="event-type">TOOL: ${this.escapeHtml(g.toolCall.name)}</span><span class="event-time">${this.formatTime(g.stepStartTime)}</span></div><div class="event-content">${this.escapeHtml(g.toolCall.args)}</div></div>` : '';
|
|
546
|
-
const ss = [
|
|
547
|
-
{ label: '操作前', path: g.beforeScreenshot ? resolveSrc(g.beforeScreenshot) : '' }, { label: '操作', path: g.observationScreenshot ? resolveSrc(g.observationScreenshot) : '' }, { label: '操作后', path: g.afterScreenshot ? resolveSrc(g.afterScreenshot) : '' },
|
|
548
|
-
].filter((s) => !!s.path);
|
|
549
|
-
const mk = (s) => {
|
|
550
|
-
if (s.label !== '操作')
|
|
551
|
-
return '';
|
|
552
|
-
const isDoubleTap = g.action && ['double_click', 'double_tap', 'doubleclick'].includes(g.action);
|
|
553
|
-
const isLongPress = g.action && ['long_press', 'long_click', 'longpress'].includes(g.action);
|
|
554
|
-
if (g.clickPoint) {
|
|
555
|
-
const [cx, cy] = g.clickPoint;
|
|
556
|
-
if (isDoubleTap) {
|
|
557
|
-
return `<div class="double-tap-marker" style="left:${cx / 10}%;top:${cy / 10}%" title="双击: ${cx},${cy}"></div>`;
|
|
558
|
-
}
|
|
559
|
-
if (isLongPress) {
|
|
560
|
-
return `<div class="long-press-marker" style="left:${cx / 10}%;top:${cy / 10}%" title="长按: ${cx},${cy}"></div>`;
|
|
561
|
-
}
|
|
562
|
-
return `<div class="marker marker-click" style="left:${cx / 10}%;top:${cy / 10}%" title="点击: ${cx},${cy}"><span class="marker-ring"></span><span class="marker-dot"></span></div>`;
|
|
563
|
-
}
|
|
564
|
-
if (g.swipeStart && g.swipeEnd) {
|
|
565
|
-
const [sx, sy] = g.swipeStart;
|
|
566
|
-
const [ex, ey] = g.swipeEnd;
|
|
567
|
-
const aid = `arrow-${g.step}`;
|
|
568
|
-
return `<div class="marker marker-swipe-start" style="left:${sx / 10}%;top:${sy / 10}%" title="起点 ${sx},${sy}"><span class="swipe-label swipe-label-start">起</span></div><div class="marker marker-swipe-end" style="left:${ex / 10}%;top:${ey / 10}%" title="终点 ${ex},${ey}"><span class="swipe-label swipe-label-end">终</span></div><svg class="swipe-line-svg" viewBox="0 0 100 100" preserveAspectRatio="none"><defs><marker id="${aid}" markerWidth="4" markerHeight="4" refX="3" refY="2" orient="auto"><path d="M0,0 L4,2 L0,4 Z" fill="#10b981"></path></marker></defs><line x1="${sx / 10}" y1="${sy / 10}" x2="${ex / 10}" y2="${ey / 10}" stroke="#10b981" stroke-width="0.8" marker-end="url(#${aid})"></line></svg>`;
|
|
569
|
-
}
|
|
570
|
-
return '';
|
|
571
|
-
};
|
|
572
|
-
const ssHtml = ss.length > 0 ? `<div class="screenshots">${ss.map(s => `<div class="screenshot"><div class="screenshot-label">${s.label}</div><div style="position:relative"><img class="screenshot-img" src="${s.path}" alt="Screenshot" loading="lazy" onclick="openFullscreen('${s.path}')">${mk(s)}</div></div>`).join('')}</div>` : '';
|
|
573
|
-
const rb = g.toolResult ? `<div class="section"><div class="section-title result">执行结果</div><div class="event mcp"><div class="event-head"><span class="event-type">状态: 完成</span><span class="event-time">${this.formatTime(g.toolEndTime)}</span></div><div class="event-data">${this.escapeHtml(g.toolResult)}</div></div></div>` : '';
|
|
574
|
-
const subAgentHtml = g.hasSubAgent && g.subSteps.length > 0
|
|
575
|
-
? `<div class="subagent-section"><div class="subagent-toggle" onclick="this.parentElement.classList.toggle('subagent-expanded')"><span class="subagent-icon">▼</span> 子 Agent 执行 (${g.subSteps.length} 步)</div><div class="subagent-body">${g.subSteps.map((ssg) => {
|
|
576
|
-
const ssTitle = this.escapeHtml(this.extractStepTitle(ssg));
|
|
577
|
-
const ssTime = ssg.stepStartTime ? this.formatTime(ssg.stepStartTime) : '';
|
|
578
|
-
const ssScreenshots = [{ l: '操作前', p: ssg.beforeScreenshot }, { l: '观察', p: ssg.observationScreenshot }, { l: '操作后', p: ssg.afterScreenshot }].filter(s => s.p);
|
|
579
|
-
const ssHtml2 = ssScreenshots.length > 0 ? `<div class="screenshots">${ssScreenshots.map(s => `<div class="screenshot"><div class="screenshot-label">${s.l}</div><img class="screenshot-img" src="${resolveSrc(s.p)}" loading="lazy" style="max-width:200px"></div>`).join('')}</div>` : '';
|
|
580
|
-
const ssResult = ssg.toolResult ? `<div class="event-data" style="font-size:12px">${this.escapeHtml(ssg.toolResult.slice(0, 200))}</div>` : '';
|
|
581
|
-
return `<div class="substep-card"><div class="substep-header"><span class="substep-num">子步 ${ssg.step}</span><span class="substep-name">${ssTitle}</span><span class="substep-time">${ssTime}</span></div>${ssHtml2}${ssResult}</div>`;
|
|
582
|
-
}).join('')}</div></div>`
|
|
583
|
-
: '';
|
|
584
|
-
const isLast = idx === steps.length - 1;
|
|
585
|
-
const hc = isLast && (fr.status === 'PASS' || fr.status === 'FAIL') ? (fr.status === 'PASS' ? 'end' : 'fail') : '';
|
|
586
|
-
const title = this.extractStepTitle(g);
|
|
587
|
-
return `<div class="step-card" id="step-${idx + 1}">
|
|
588
|
-
<div class="step-header ${hc}"><span class="step-num">${g.step}</span><span class="step-name">${this.escapeHtml(title)}</span>${tb}<span class="step-time">${tr}</span></div>
|
|
589
|
-
<div class="step-body"><div class="step-grid"><div class="section"><div class="section-title">Planner 规划</div>${tb2}</div><div class="section"><div class="section-title model">模型执行</div>${tcb}</div></div>${ssHtml || rb || subAgentHtml ? `<div class="step-bottom">${ssHtml}${rb}${subAgentHtml}</div>` : ''}</div>
|
|
590
|
-
</div>`;
|
|
591
|
-
}).join('\n');
|
|
592
|
-
const frScr = fr.screenshot ? resolveSrc(fr.screenshot) : '';
|
|
593
|
-
const jsc = frScr ? `<div class="judgment-card-right"><div class="judgment-screenshot"><div class="judgment-screenshot-label">判定观察</div><img class="judgment-screenshot-img" src="${frScr}" alt="Screenshot" loading="lazy" onclick="openFullscreen('${frScr}')"></div></div>` : '';
|
|
594
|
-
return `<!DOCTYPE html>
|
|
595
|
-
<html lang="zh-CN">
|
|
596
|
-
<head>
|
|
597
|
-
<meta charset="UTF-8">
|
|
598
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
599
|
-
<title>测试报告 - ${this.escapeHtml(data.test_case)}</title>
|
|
600
|
-
<style>
|
|
601
|
-
*{margin:0;padding:0;box-sizing:border-box}
|
|
602
|
-
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;background:#f8fafc;color:#1e293b;line-height:1.6}
|
|
603
|
-
.sidebar{width:260px;background:#fff;height:100vh;position:fixed;left:0;top:0;overflow-y:auto;border-right:1px solid #e2e8f0;padding:20px}
|
|
604
|
-
.sidebar-title{font-size:16px;font-weight:700;color:#0f172a;padding-bottom:16px;border-bottom:2px solid #3b82f6;margin-bottom:20px}
|
|
605
|
-
.metrics{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:20px}
|
|
606
|
-
.metric{padding:16px;border-radius:12px;background:linear-gradient(135deg,#3b82f6,#2563eb);color:#fff;overflow:hidden}
|
|
607
|
-
.metric.pass{background:linear-gradient(135deg,#22c55e,#16a34a)}
|
|
608
|
-
.metric.fail{background:linear-gradient(135deg,#ef4444,#dc2626)}
|
|
609
|
-
.metric-label{font-size:12px;opacity:.9}
|
|
610
|
-
.metric-value{font-size:18px;font-weight:700;margin-top:4px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
611
|
-
.nav-title{font-size:12px;color:#64748b;margin-bottom:12px;font-weight:600}
|
|
612
|
-
.nav-item{padding:10px 12px;margin-bottom:4px;border-radius:8px;cursor:pointer;font-size:14px;color:#475569;background:#f1f5f9;transition:background .15s;overflow:hidden;text-overflow:ellipsis;position:relative}
|
|
613
|
-
.nav-item:hover{background:#e2e8f0}
|
|
614
|
-
.nav-item.active{background:#3b82f6;color:#fff}
|
|
615
|
-
.main{margin-left:260px;padding:30px;min-height:100vh}
|
|
616
|
-
.header{margin-bottom:30px}
|
|
617
|
-
.title{font-size:24px;font-weight:700;color:#0f172a;margin-bottom:8px}
|
|
618
|
-
.subtitle{font-size:14px;color:#64748b}
|
|
619
|
-
.step-card{background:#fff;border-radius:16px;margin-bottom:20px;border:1px solid #e2e8f0;overflow:hidden}
|
|
620
|
-
.step-header{padding:16px 24px;background:linear-gradient(135deg,#3b82f6,#2563eb);color:#fff;display:flex;align-items:center}
|
|
621
|
-
.step-header.end{background:linear-gradient(135deg,#22c55e,#16a34a)}
|
|
622
|
-
.step-header.fail{background:linear-gradient(135deg,#ef4444,#dc2626)}
|
|
623
|
-
.step-num{width:32px;height:32px;line-height:32px;text-align:center;background:rgba(255,255,255,.2);border-radius:8px;font-weight:700;margin-right:12px}
|
|
624
|
-
.step-name{font-size:16px;font-weight:600;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
625
|
-
.step-time{font-size:12px;opacity:.8;margin-left:12px}
|
|
626
|
-
.step-body{padding:20px 24px}
|
|
627
|
-
.step-grid{display:grid;grid-template-columns:1fr 1fr;gap:20px}
|
|
628
|
-
.step-bottom{display:grid;grid-template-columns:1fr 1fr;gap:20px;margin-top:16px;padding-top:16px;border-top:1px solid #e2e8f0}
|
|
629
|
-
.section-title{font-size:13px;font-weight:700;color:#0f172a;margin-bottom:12px;padding-left:12px;border-left:3px solid #3b82f6}
|
|
630
|
-
.section-title.model{border-left-color:#f59e0b}
|
|
631
|
-
.section-title.result{border-left-color:#22c55e}
|
|
632
|
-
.event{padding:14px 18px;margin-bottom:12px;background:#f8fafc;border-radius:10px;border-left:3px solid #cbd5e1}
|
|
633
|
-
.event.planner{border-left-color:#3b82f6;background:#eff6ff}
|
|
634
|
-
.event.mcp{border-left-color:#f59e0b;background:#fffbeb}
|
|
635
|
-
.event-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}
|
|
636
|
-
.event-type{font-size:11px;font-weight:600;color:#64748b;background:#e2e8f0;padding:2px 8px;border-radius:4px}
|
|
637
|
-
.event-time{font-size:11px;color:#94a3b8}
|
|
638
|
-
.event-content{font-size:14px;color:#334155;white-space:pre-wrap;word-break:break-word}
|
|
639
|
-
.event-data{margin-top:12px;padding:12px;background:#1e293b;color:#e2e8f0;border-radius:8px;font-size:12px;font-family:Consolas,Monaco,monospace;overflow-x:auto;white-space:pre-wrap;word-break:break-word}
|
|
640
|
-
.thinking{padding:16px;background:#eff6ff;border-radius:10px;border:1px solid #bfdbfe;margin-bottom:12px}
|
|
641
|
-
.thinking-label{font-size:12px;font-weight:700;color:#3b82f6;margin-bottom:8px}
|
|
642
|
-
.thinking-text{font-size:14px;color:#334155;white-space:pre-wrap;word-break:break-word;overflow-y:auto;max-height:50vh}
|
|
643
|
-
.screenshots{display:flex;gap:12px;flex-wrap:nowrap}
|
|
644
|
-
.screenshot{border:1px solid #e2e8f0;border-radius:8px;overflow:hidden;background:#fff;flex:1 1 0%;min-width:0;max-width:260px}
|
|
645
|
-
.screenshot-label{padding:6px 10px;background:#f1f5f9;font-size:11px;font-weight:600;color:#475569}
|
|
646
|
-
.screenshot-img{width:100%;max-width:260px;display:block;cursor:pointer}
|
|
647
|
-
.marker{position:absolute;transform:translate(-50%,-50%);pointer-events:none;z-index:2}
|
|
648
|
-
.marker-click{width:24px;height:24px}
|
|
649
|
-
.marker-ring{position:absolute;inset:0;border-radius:50%;border:3px solid #ef4444;animation:marker-pulse 1.8s ease-in-out infinite}
|
|
650
|
-
.marker-dot{position:absolute;top:50%;left:50%;width:10px;height:10px;border-radius:50%;background:#ef4444;transform:translate(-50%,-50%);box-shadow:0 0 8px rgba(239,68,68,.6)}
|
|
651
|
-
@keyframes marker-pulse{0%,100%{transform:scale(1);opacity:1}50%{transform:scale(1.6);opacity:.4}}
|
|
652
|
-
.marker-swipe-start,.marker-swipe-end{width:24px;height:24px}
|
|
653
|
-
.swipe-label{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:50%;font-size:12px;font-weight:700;color:#fff;box-shadow:0 2px 8px rgba(0,0,0,.35)}
|
|
654
|
-
.swipe-label-start{background:#10b981}
|
|
655
|
-
.swipe-label-end{background:#f59e0b}
|
|
656
|
-
.swipe-line-svg{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:1}
|
|
657
|
-
.double-tap-marker{position:absolute;width:24px;height:24px;background:rgba(33,150,243,.6);border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;box-shadow:0 0 0 4px rgba(33,150,243,.3)}
|
|
658
|
-
.long-press-marker{position:absolute;width:30px;height:30px;background:rgba(156,39,176,.6);border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;box-shadow:0 0 10px rgba(156,39,176,.5)}
|
|
659
|
-
.subagent-section{margin-top:12px;border:1px solid #a855f7;border-radius:8px;overflow:hidden}
|
|
660
|
-
.subagent-toggle{padding:8px 12px;background:#faf5ff;color:#7c3aed;font-size:13px;font-weight:600;cursor:pointer;user-select:none;display:flex;align-items:center;gap:6px}
|
|
661
|
-
.subagent-icon{font-size:10px;transition:transform .2s}
|
|
662
|
-
.subagent-section.subagent-expanded .subagent-icon{transform:rotate(180deg)}
|
|
663
|
-
.subagent-body{display:none;padding:12px;background:#faf5ff}
|
|
664
|
-
.subagent-section.subagent-expanded .subagent-body{display:block}
|
|
665
|
-
.substep-card{background:#fff;border:1px solid #e9d5ff;border-radius:6px;padding:10px;margin-bottom:8px}
|
|
666
|
-
.substep-header{display:flex;align-items:center;gap:8px;margin-bottom:8px}
|
|
667
|
-
.substep-num{font-size:11px;font-weight:700;color:#7c3aed;background:#f3e8ff;padding:2px 8px;border-radius:4px}
|
|
668
|
-
.substep-name{font-size:13px;color:#475569;flex:1}
|
|
669
|
-
.substep-time{font-size:11px;color:#94a3b8}
|
|
670
|
-
.status-badge{display:inline-block;padding:10px 24px;border-radius:12px;font-size:16px;font-weight:700;color:#fff}
|
|
671
|
-
.status-pass{background:#22c55e}.status-fail{background:#ef4444}.status-unknown{background:#64748b}
|
|
672
|
-
.step-token-badge{display:inline-block;padding:2px 10px;background:rgba(255,255,255,.2);border-radius:10px;font-size:12px;font-weight:600;margin-left:8px}
|
|
673
|
-
.top-cards-row{display:grid;grid-template-columns:4fr 6fr;gap:20px;margin-bottom:20px}
|
|
674
|
-
.detail-card{background:#fff;border-radius:16px;padding:24px;border:1px solid #e2e8f0;max-height:50vh;display:flex;flex-direction:column}
|
|
675
|
-
.detail-card-title{font-size:16px;font-weight:700;color:#0f172a;margin-bottom:16px;padding-bottom:12px;border-bottom:2px solid #3b82f6;flex-shrink:0}
|
|
676
|
-
.detail-card-body{overflow:auto;flex:1;min-height:0}
|
|
677
|
-
.detail-card-task-content{font-size:14px;color:#334155;white-space:pre-wrap;word-break:break-word;background:#f8fafc;padding:16px;border-radius:8px}
|
|
678
|
-
.judgment-card{background:#fff;border-radius:16px;padding:24px;border:1px solid #e2e8f0;max-height:50vh;display:flex;flex-direction:column}
|
|
679
|
-
.judgment-card-title{font-size:16px;font-weight:700;color:#0f172a;margin-bottom:16px;padding-bottom:12px;border-bottom:2px solid #22c55e;flex-shrink:0}
|
|
680
|
-
.judgment-card-body{overflow-y:auto;flex:1;min-height:0;display:flex;gap:16px}
|
|
681
|
-
.judgment-content{font-size:14px;color:#334155;white-space:pre-wrap;word-break:break-word;background:#f8fafc;padding:16px;border-radius:8px}
|
|
682
|
-
.judgment-card-left{flex:1;min-width:0}
|
|
683
|
-
.judgment-card-right{flex-shrink:0;display:flex;flex-direction:column;gap:8px;align-items:center}
|
|
684
|
-
.judgment-screenshot{border-radius:8px;overflow:hidden;border:1px solid #e2e8f0;cursor:pointer;position:relative}
|
|
685
|
-
.judgment-screenshot-img{width:100%;max-width:180px;display:block;cursor:pointer}
|
|
686
|
-
.judgment-screenshot-label{padding:4px 8px;background:#f1f5f9;font-size:10px;font-weight:600;color:#475569;text-align:center}
|
|
687
|
-
.end-box{padding:40px;background:#f0fdf4;border-radius:16px;border:2px solid #22c55e;text-align:center;margin-bottom:20px}
|
|
688
|
-
.end-box.fail{background:#fef2f2;border-color:#ef4444}
|
|
689
|
-
.floating-detail{position:fixed;top:16px;right:16px;z-index:100;background:#fff;border-radius:12px;border:2px solid #3b82f6;padding:16px;display:none;flex-direction:column;gap:12px;max-width:25vw;max-height:35vh;overflow-y:auto;box-shadow:0 4px 16px rgba(0,0,0,.15);transition:opacity .2s}
|
|
690
|
-
.floating-detail-header{display:flex;align-items:center;gap:10px;cursor:pointer}
|
|
691
|
-
.floating-detail-title{font-size:14px;font-weight:700;color:#0f172a;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
692
|
-
.floating-detail-desc{font-size:13px;color:#64748b;overflow-y:auto;word-break:break-word;cursor:pointer;max-height:calc(35vh - 52px)}
|
|
693
|
-
.floating-detail-close{width:24px;height:24px;line-height:24px;text-align:center;background:#e2e8f0;border-radius:6px;cursor:pointer;font-size:14px;color:#475569;flex-shrink:0;margin-left:auto}
|
|
694
|
-
.floating-detail-close:hover{background:#cbd5e1;color:#0f172a}
|
|
695
|
-
</style>
|
|
696
|
-
</head>
|
|
697
|
-
<body>
|
|
698
|
-
<div class="sidebar">
|
|
699
|
-
<div class="sidebar-title">测试报告</div>
|
|
700
|
-
<div class="metrics">
|
|
701
|
-
<div class="metric ${sc}"><div class="metric-label">状态</div><div class="metric-value">${fr.status}</div></div>
|
|
702
|
-
<div class="metric"><div class="metric-label">耗时</div><div class="metric-value">${dur}</div></div>
|
|
703
|
-
<div class="metric"><div class="metric-label">步骤</div><div class="metric-value">${steps.length}</div></div>
|
|
704
|
-
<div class="metric"><div class="metric-label">Token</div><div class="metric-value" title="输入: ${data.total_tokens.inputTokens} | 输出: ${data.total_tokens.outputTokens} | 推理: ${data.total_tokens.reasoningTokens} | 缓存: ${data.total_tokens.cachedTokens}">${tn}</div></div>
|
|
705
|
-
</div>
|
|
706
|
-
<div class="nav-title">导航</div>
|
|
707
|
-
<div class="nav-item" onclick="scrollToDetail()" id="nav-detail">任务描述</div>
|
|
708
|
-
${navItems}
|
|
709
|
-
</div>
|
|
710
|
-
<div class="main">
|
|
711
|
-
<div class="header">
|
|
712
|
-
<div class="title">${this.escapeHtml(data.test_case)}</div>
|
|
713
|
-
<div class="subtitle">自动化测试执行报告</div>
|
|
714
|
-
</div>
|
|
715
|
-
<div id="floating-detail" class="floating-detail">
|
|
716
|
-
<div class="floating-detail-header" onclick="scrollToDetail()">
|
|
717
|
-
<span class="floating-detail-title">任务描述</span>
|
|
718
|
-
<div class="floating-detail-close" onclick="closeFloatingDetail(event)" title="关闭">✕</div>
|
|
719
|
-
</div>
|
|
720
|
-
<div class="floating-detail-desc" onclick="scrollToDetail()">${this.escapeHtml(data.task)}</div>
|
|
721
|
-
</div>
|
|
722
|
-
<div class="top-cards-row">
|
|
723
|
-
<div class="detail-card" id="task-detail">
|
|
724
|
-
<div class="detail-card-title">任务描述</div>
|
|
725
|
-
<div class="detail-card-body"><div class="detail-card-task-content">${this.escapeHtml(data.task)}</div></div>
|
|
726
|
-
</div>
|
|
727
|
-
<div class="judgment-card">
|
|
728
|
-
<div class="judgment-card-title">结果判定详情 <span class="status-badge status-${sc || 'unknown'}" style="font-size:12px;padding:3px 10px;margin-left:8px">${fr.status}</span></div>
|
|
729
|
-
<div class="judgment-card-body">
|
|
730
|
-
<div class="judgment-card-left"><div class="judgment-content">${this.escapeHtml(fr.judgment || fr.result || '暂无判定内容')}</div></div>
|
|
731
|
-
${jsc}
|
|
732
|
-
</div>
|
|
733
|
-
</div>
|
|
734
|
-
</div>
|
|
735
|
-
${stepCards}
|
|
736
|
-
<div class="end-box ${fr.status === 'FAIL' ? 'fail' : ''}">
|
|
737
|
-
<div style="font-size:20px;font-weight:700;color:${fr.status === 'PASS' ? '#22c55e' : fr.status === 'FAIL' ? '#ef4444' : '#64748b'}">${fr.status} ${fr.result ? '— ' + this.escapeHtml(fr.result) : ''}</div>
|
|
738
|
-
</div>
|
|
739
|
-
</div>
|
|
740
|
-
<script>
|
|
741
|
-
var cards=document.querySelectorAll('.step-card');
|
|
742
|
-
var navs=document.querySelectorAll('.nav-item');
|
|
743
|
-
var navDetail=document.getElementById('nav-detail');
|
|
744
|
-
var taskDetail=document.getElementById('task-detail');
|
|
745
|
-
var floatingDetail=document.getElementById('floating-detail');
|
|
746
|
-
var floatingClosed=false;
|
|
747
|
-
function closeFloatingDetail(e){if(e)e.stopPropagation();floatingClosed=true;if(floatingDetail)floatingDetail.style.display='none'}
|
|
748
|
-
function scrollToDetail(){if(taskDetail){taskDetail.scrollIntoView({behavior:'smooth',block:'start'});clearNavActive();if(navDetail)navDetail.classList.add('active')}}
|
|
749
|
-
function scrollToStep(n){if(cards[n]){cards[n].scrollIntoView({behavior:'smooth',block:'start'});cards[n].style.boxShadow='0 0 0 2px #3b82f6';setTimeout(function(){cards[n].style.boxShadow=''},1500)}clearNavActive();var ni=n+1;if(navs[ni])navs[ni].classList.add('active')}
|
|
750
|
-
function clearNavActive(){navs.forEach(function(e){e.classList.remove('active')})}
|
|
751
|
-
function onScroll(){
|
|
752
|
-
clearNavActive();
|
|
753
|
-
if(taskDetail){var r=taskDetail.getBoundingClientRect();if(r.top>0&&r.bottom>0&&r.top<=200){if(navDetail)navDetail.classList.add('active');if(floatingDetail)floatingDetail.style.display='none';floatingClosed=false;return}if(floatingDetail&&!floatingClosed){floatingDetail.style.display=r.bottom<0?'flex':'none'}}
|
|
754
|
-
var a=-1;for(var i=0;i<cards.length;i++){var r=cards[i].getBoundingClientRect();if(r.top<=150)a=i}
|
|
755
|
-
if(a>=0){var ni=a+1;if(navs[ni])navs[ni].classList.add('active')}else if(navDetail)navDetail.classList.add('active')
|
|
756
|
-
}
|
|
757
|
-
window.addEventListener('scroll',onScroll);onScroll();
|
|
758
|
-
function openFullscreen(src){
|
|
759
|
-
var o=document.createElement('div');
|
|
760
|
-
o.style.cssText='position:fixed;top:0;left:0;width:100vw;height:100vh;background:rgba(0,0,0,.9);display:flex;align-items:center;justify-content:center;z-index:9999;cursor:pointer';
|
|
761
|
-
var img=document.createElement('img');
|
|
762
|
-
img.src=src;img.style.cssText='display:block;max-width:95vw;max-height:95vh;border-radius:8px';
|
|
763
|
-
o.appendChild(img);
|
|
764
|
-
o.onclick=function(e){if(e.target===o||e.target===img)o.remove()};
|
|
765
|
-
document.body.appendChild(o)
|
|
766
|
-
}
|
|
767
|
-
</script>
|
|
768
|
-
</body>
|
|
769
|
-
</html>`;
|
|
770
|
-
}
|
|
771
285
|
}
|
|
772
286
|
exports.ReportGeneratorImpl = ReportGeneratorImpl;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ReportData } from '../types';
|
|
2
|
+
export interface StepGroup {
|
|
3
|
+
step: number;
|
|
4
|
+
thinking: string;
|
|
5
|
+
reasoning: string;
|
|
6
|
+
toolCall: {
|
|
7
|
+
name: string;
|
|
8
|
+
args: string;
|
|
9
|
+
} | null;
|
|
10
|
+
toolCallArgs: Record<string, unknown> | null;
|
|
11
|
+
observationScreenshot: string | null;
|
|
12
|
+
beforeScreenshot: string | null;
|
|
13
|
+
afterScreenshot: string | null;
|
|
14
|
+
toolResult: string;
|
|
15
|
+
toolStartTime: string;
|
|
16
|
+
toolEndTime: string;
|
|
17
|
+
stepStartTime: string;
|
|
18
|
+
stepEndTime: string;
|
|
19
|
+
clickPoint: [number, number] | null;
|
|
20
|
+
swipeStart: [number, number] | null;
|
|
21
|
+
swipeEnd: [number, number] | null;
|
|
22
|
+
action: string | null;
|
|
23
|
+
subSteps: StepGroup[];
|
|
24
|
+
hasSubAgent: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface HtmlRenderOptions {
|
|
27
|
+
reportDir: string;
|
|
28
|
+
embedImages: boolean;
|
|
29
|
+
embedMaxPixels: number;
|
|
30
|
+
}
|
|
31
|
+
export declare function escapeHtml(text: string): string;
|
|
32
|
+
export declare function formatDuration(s: string | null, e: string | null): string;
|
|
33
|
+
export declare function formatTime(iso: string): string;
|
|
34
|
+
export declare function formatTokenCount(n: number): string;
|
|
35
|
+
export declare function stripTagMarkers(text: string): string;
|
|
36
|
+
export declare function asPoint2(v: unknown): [number, number] | null;
|
|
37
|
+
export declare function asPointFromXY(x: unknown, y: unknown): [number, number] | null;
|
|
38
|
+
export declare function toRelativePath(absPath: string | null | undefined, reportDir: string): string;
|
|
39
|
+
export declare function resolveImgSrc(relPath: string, opts: HtmlRenderOptions): Promise<string>;
|
|
40
|
+
export declare function extractStepTitle(g: StepGroup): string;
|
|
41
|
+
export declare function groupSteps(data: ReportData, reportDir: string): StepGroup[];
|
|
42
|
+
export declare function getStepTokens(data: ReportData, step: number): {
|
|
43
|
+
input: number;
|
|
44
|
+
output: number;
|
|
45
|
+
cached: number;
|
|
46
|
+
reasoning: number;
|
|
47
|
+
total: number;
|
|
48
|
+
normalized: number;
|
|
49
|
+
};
|
|
50
|
+
export declare function getFinalStatus(data: ReportData, reportDir: string): {
|
|
51
|
+
status: string;
|
|
52
|
+
result: string;
|
|
53
|
+
judgment: string;
|
|
54
|
+
screenshot: string;
|
|
55
|
+
};
|
|
56
|
+
export declare function generateHtmlFromJson(data: ReportData, opts: HtmlRenderOptions): Promise<string>;
|