@autotest/agent 0.0.20 → 0.0.22
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 +33 -22
- package/dist/.buildstamp +1 -0
- package/dist/api/types.d.ts +8 -0
- package/dist/autotest-cli.js +1 -1
- package/dist/common/config/config.yaml +144 -143
- package/dist/common/config/types.d.ts +2391 -2273
- package/dist/common/datetime.d.ts +19 -0
- package/dist/common/dfx/cache_fetch.d.ts +12 -0
- package/dist/common/dfx/client_factory.d.ts +10 -9
- package/dist/common/dfx/context.d.ts +0 -1
- package/dist/common/dfx/index.d.ts +5 -3
- package/dist/common/dfx/recorder.d.ts +13 -1
- package/dist/common/dfx/recorder_sqlite.d.ts +17 -0
- package/dist/common/dfx/recording_fetch.d.ts +2 -2
- package/dist/common/dfx/source.d.ts +1 -0
- package/dist/common/model/custom_model.d.ts +5 -0
- package/dist/core/agent/design_doc/design_doc.d.ts +106 -0
- package/dist/core/agent/layered_agent/execute_agent/agent_factory.d.ts +1 -1
- package/dist/core/agent/report_analyzer_agent/agent.d.ts +6 -1
- package/dist/core/agent/report_analyzer_agent/analysis_progress.d.ts +54 -0
- package/dist/core/agent/report_analyzer_agent/design_tool.d.ts +8 -0
- package/dist/core/agent/report_analyzer_agent/guardrails.d.ts +24 -0
- package/dist/core/agent/report_analyzer_agent/hooks.d.ts +0 -1
- package/dist/core/agent/report_analyzer_agent/index.d.ts +2 -1
- package/dist/core/agent/report_analyzer_agent/mapping.d.ts +1 -1
- package/dist/core/agent/report_analyzer_agent/prompt.d.ts +1 -1
- package/dist/core/agent/report_analyzer_agent/prompts/examples/example_out_of_scope_app_defect.md +13 -0
- package/dist/core/agent/report_analyzer_agent/prompts/examples/example_overturn_executor.md +13 -0
- package/dist/core/agent/report_analyzer_agent/prompts/examples/example_pass_precondition_selfconstruct.md +13 -0
- package/dist/core/agent/report_analyzer_agent/prompts/final_attribution.md +204 -0
- package/dist/core/agent/report_analyzer_agent/prompts/mid_analysis.md +177 -0
- package/dist/core/agent/report_analyzer_agent/report_html_template/_header.d.ts +5 -0
- package/dist/core/agent/report_analyzer_agent/report_html_template/_scripts.d.ts +1 -0
- package/dist/core/agent/report_analyzer_agent/report_html_template/_styles.d.ts +1 -0
- package/dist/core/agent/report_analyzer_agent/report_html_template/_summary.d.ts +2 -0
- package/dist/core/agent/report_analyzer_agent/report_html_template/_trace.d.ts +14 -0
- package/dist/core/agent/report_analyzer_agent/report_html_template/_utils.d.ts +20 -0
- package/dist/core/agent/report_analyzer_agent/report_html_template/_verdict.d.ts +2 -0
- package/dist/core/agent/report_analyzer_agent/report_html_template/index.d.ts +8 -0
- package/dist/core/agent/report_analyzer_agent/report_html_template/render.d.ts +6 -0
- package/dist/core/agent/report_analyzer_agent/report_markdown.d.ts +9 -0
- package/dist/core/agent/report_analyzer_agent/report_writer.d.ts +16 -1
- package/dist/core/agent/report_analyzer_agent/stage_contracts.d.ts +6 -5
- package/dist/core/agent/report_analyzer_agent/tools.d.ts +6 -0
- package/dist/core/agent/report_analyzer_agent/trace_extract.d.ts +49 -0
- package/dist/core/agent/report_analyzer_agent/types.d.ts +5 -1
- package/dist/core/agent/rewrite_agent/agent.d.ts +2 -0
- package/dist/core/agent/rewrite_agent/prompts/rewriter_v1.0.md +224 -168
- package/dist/core/agent/rewrite_agent/result_writer.d.ts +22 -0
- package/dist/core/agent/rewrite_agent/types.d.ts +4 -0
- package/dist/core/agent/single_agent/agent.d.ts +18 -9
- package/dist/core/agent/single_agent/context_builder.d.ts +61 -0
- package/dist/core/agent/single_agent/hook_manager.d.ts +15 -2
- package/dist/core/agent/single_agent/image_utils.d.ts +8 -0
- package/dist/core/agent/single_agent/llm_helper.d.ts +86 -0
- package/dist/core/agent/single_agent/processors.d.ts +22 -0
- package/dist/core/agent/single_agent/report_hook.d.ts +22 -0
- package/dist/core/agent/single_agent/scroll_search_agent.d.ts +15 -0
- package/dist/core/agent/single_agent/subagent_manager.d.ts +3 -4
- package/dist/core/agent/types.d.ts +5 -0
- package/dist/core/device/hdc/index.d.ts +1 -1
- package/dist/core/device/hdc/input.d.ts +7 -0
- package/dist/core/device/hdc/screenshot.d.ts +2 -0
- package/dist/core/mcp/android_adapter.d.ts +1 -1
- package/dist/core/mcp/base_adapter.d.ts +5 -0
- package/dist/core/mcp/ios_adapter.d.ts +1 -1
- package/dist/core/mcp/types.d.ts +2 -0
- package/dist/core/memory/_utils.d.ts +1 -1
- package/dist/core/memory/tool_player_replan.d.ts +3 -4
- package/dist/core/prompt/templates/single/single_v1.0.md +18 -18
- package/dist/core/prompt/templates/single/single_v2.0.md +31 -77
- package/dist/core/prompt/templates/single/single_v2.0_0_1000.md +6 -5
- package/dist/core/prompt/templates/single/single_v2.0_eco.md +14 -3
- package/dist/core/prompt/templates/single/single_v2.0_graph.md +244 -0
- package/dist/core/prompt/templates/single/single_v3.0.md +5 -5
- package/dist/generated/version.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/loop/orchestrator.d.ts +6 -0
- package/dist/loop/types.d.ts +4 -0
- package/dist/mcp-server/types.d.ts +120 -120
- package/dist/prompts/rewriter_v1.0.md +224 -168
- package/dist/reporter/generator.d.ts +10 -0
- package/dist/reporter/html_template/_cards.d.ts +21 -0
- package/dist/reporter/html_template/_markers.d.ts +11 -0
- package/dist/reporter/html_template/_scripts.d.ts +6 -0
- package/dist/reporter/html_template/_sidebar.d.ts +24 -0
- package/dist/reporter/html_template/_styles.d.ts +6 -0
- package/dist/reporter/html_template/_top_section.d.ts +33 -0
- package/dist/reporter/html_template/_utils.d.ts +87 -0
- package/dist/reporter/html_template/index.d.ts +2 -65
- package/dist/reporter/types.d.ts +59 -17
- package/dist/tools/batch_runner.d.ts +39 -1
- package/dist/tools/batch_runner.js +1 -1
- package/dist/tools/case_runner/runner.js +1 -1
- package/dist/tools/config/config_tool.js +1 -1
- package/dist/tools/gen_analysis_report.d.ts +12 -0
- package/dist/tools/gen_report.d.ts +13 -44
- package/dist/tools/prompt_compare/compare_runner.js +1 -1
- package/dist/tools/token_comparison/comparator.d.ts +74 -0
- package/package.json +6 -5
- package/scripts/bundle-obfuscate.js +111 -0
- package/scripts/gen-native-b64.js +51 -0
- package/dist/core/agent/layered_agent/ability_helper.d.ts +0 -35
|
@@ -1,67 +1,4 @@
|
|
|
1
|
+
import { type HtmlRenderOptions } from './_utils';
|
|
1
2
|
import type { ReportData } from '../types';
|
|
2
|
-
export
|
|
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
|
-
fastScreenshot: string | null;
|
|
15
|
-
fastScreenshots: string[];
|
|
16
|
-
recordingFramePaths: string[];
|
|
17
|
-
recordingFrameTimestamps: string[];
|
|
18
|
-
verifyFrames: string[];
|
|
19
|
-
verifySprite: string | null;
|
|
20
|
-
autoVerifySprite: string | null;
|
|
21
|
-
verifyClickPoint: [number, number] | null;
|
|
22
|
-
spritePath: string | null;
|
|
23
|
-
videoPath: string | null;
|
|
24
|
-
toolResult: string;
|
|
25
|
-
toolStartTime: string;
|
|
26
|
-
toolEndTime: string;
|
|
27
|
-
stepStartTime: string;
|
|
28
|
-
stepEndTime: string;
|
|
29
|
-
clickPoint: [number, number] | null;
|
|
30
|
-
swipeStart: [number, number] | null;
|
|
31
|
-
swipeEnd: [number, number] | null;
|
|
32
|
-
action: string | null;
|
|
33
|
-
subSteps: StepGroup[];
|
|
34
|
-
hasSubAgent: boolean;
|
|
35
|
-
}
|
|
36
|
-
export interface HtmlRenderOptions {
|
|
37
|
-
reportDir: string;
|
|
38
|
-
embedImages: boolean;
|
|
39
|
-
embedMaxPixels: number;
|
|
40
|
-
debugMode?: boolean;
|
|
41
|
-
}
|
|
42
|
-
export declare function escapeHtml(text: string): string;
|
|
43
|
-
export declare function formatDuration(s: string | null, e: string | null): string;
|
|
44
|
-
export declare function formatTime(iso: string): string;
|
|
45
|
-
export declare function formatTokenCount(n: number): string;
|
|
46
|
-
export declare function stripTagMarkers(text: string): string;
|
|
47
|
-
export declare function asPoint2(v: unknown): [number, number] | null;
|
|
48
|
-
export declare function asPointFromXY(x: unknown, y: unknown): [number, number] | null;
|
|
49
|
-
export declare function toRelativePath(absPath: string | null | undefined, reportDir: string): string;
|
|
50
|
-
export declare function resolveImgSrc(relPath: string, opts: HtmlRenderOptions): Promise<string>;
|
|
51
|
-
export declare function extractStepTitle(g: StepGroup): string;
|
|
52
|
-
export declare function groupSteps(data: ReportData, reportDir: string): StepGroup[];
|
|
53
|
-
export declare function getStepTokens(data: ReportData, step: number): {
|
|
54
|
-
input: number;
|
|
55
|
-
output: number;
|
|
56
|
-
cached: number;
|
|
57
|
-
reasoning: number;
|
|
58
|
-
total: number;
|
|
59
|
-
normalized: number;
|
|
60
|
-
};
|
|
61
|
-
export declare function getFinalStatus(data: ReportData, reportDir: string): {
|
|
62
|
-
status: string;
|
|
63
|
-
result: string;
|
|
64
|
-
judgment: string;
|
|
65
|
-
screenshot: string;
|
|
66
|
-
};
|
|
3
|
+
export * from './_utils';
|
|
67
4
|
export declare function generateHtmlFromJson(data: ReportData, opts: HtmlRenderOptions): Promise<string>;
|
package/dist/reporter/types.d.ts
CHANGED
|
@@ -39,42 +39,84 @@ export declare const ReportEventSchema: z.ZodObject<{
|
|
|
39
39
|
stepNumber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
40
40
|
subEvents: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
41
41
|
}, "strip", z.ZodTypeAny, {
|
|
42
|
-
eventType
|
|
43
|
-
timestamp
|
|
44
|
-
content
|
|
45
|
-
data
|
|
46
|
-
screenshotPath?: string;
|
|
47
|
-
stepNumber?: number;
|
|
48
|
-
subEvents?: Record<string, unknown>[];
|
|
42
|
+
eventType: EventType;
|
|
43
|
+
timestamp: string;
|
|
44
|
+
content: string;
|
|
45
|
+
data: Record<string, unknown>;
|
|
46
|
+
screenshotPath?: string | null | undefined;
|
|
47
|
+
stepNumber?: number | null | undefined;
|
|
48
|
+
subEvents?: Record<string, unknown>[] | undefined;
|
|
49
49
|
}, {
|
|
50
|
-
eventType
|
|
51
|
-
timestamp?: string;
|
|
52
|
-
content?: string;
|
|
53
|
-
data?: Record<string, unknown
|
|
54
|
-
screenshotPath?: string;
|
|
55
|
-
stepNumber?: number;
|
|
56
|
-
subEvents?: Record<string, unknown>[];
|
|
50
|
+
eventType: EventType;
|
|
51
|
+
timestamp?: string | undefined;
|
|
52
|
+
content?: string | undefined;
|
|
53
|
+
data?: Record<string, unknown> | undefined;
|
|
54
|
+
screenshotPath?: string | null | undefined;
|
|
55
|
+
stepNumber?: number | null | undefined;
|
|
56
|
+
subEvents?: Record<string, unknown>[] | undefined;
|
|
57
57
|
}>;
|
|
58
58
|
export type ReportEvent = z.infer<typeof ReportEventSchema>;
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* In-memory token accumulator (camelCase) — internal to ReportGeneratorImpl.
|
|
61
|
+
*
|
|
62
|
+
* The per-source records deliberately do NOT carry a nested `sources` field
|
|
63
|
+
* (the recursive `sources: {}` was spurious and does not exist in the Python
|
|
64
|
+
* reference), hence the split into a source-record type without `sources`.
|
|
65
|
+
*/
|
|
66
|
+
export interface TokenUsageSourceRecord {
|
|
60
67
|
total: number;
|
|
61
68
|
inputTokens: number;
|
|
62
69
|
outputTokens: number;
|
|
63
70
|
reasoningTokens: number;
|
|
64
71
|
cachedTokens: number;
|
|
65
|
-
|
|
72
|
+
}
|
|
73
|
+
export interface TokenUsageRecord extends TokenUsageSourceRecord {
|
|
74
|
+
sources: Record<string, TokenUsageSourceRecord>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Serialized token-usage form (snake_case) — mirrors Python
|
|
78
|
+
* `ReportGenerator.total_tokens` dict + per-source dicts. Used for the JSON
|
|
79
|
+
* report output and the ReportData handed to the HTML/Markdown renderers so
|
|
80
|
+
* consumers read snake_case consistently with the Python output.
|
|
81
|
+
*/
|
|
82
|
+
export interface TokenUsageSourceDict {
|
|
83
|
+
total: number;
|
|
84
|
+
input_tokens: number;
|
|
85
|
+
output_tokens: number;
|
|
86
|
+
reasoning_tokens: number;
|
|
87
|
+
cached_tokens: number;
|
|
88
|
+
}
|
|
89
|
+
export interface TokenUsageDict {
|
|
90
|
+
total: number;
|
|
91
|
+
input_tokens: number;
|
|
92
|
+
output_tokens: number;
|
|
93
|
+
reasoning_tokens: number;
|
|
94
|
+
cached_tokens: number;
|
|
95
|
+
sources: Record<string, TokenUsageSourceDict>;
|
|
66
96
|
}
|
|
67
97
|
export interface ReportData {
|
|
68
98
|
test_case: string;
|
|
69
99
|
task: string;
|
|
70
100
|
start_time: string | null;
|
|
71
101
|
end_time: string | null;
|
|
72
|
-
total_tokens:
|
|
102
|
+
total_tokens: TokenUsageDict;
|
|
73
103
|
step_tokens: Array<Record<string, unknown>>;
|
|
74
104
|
events: ReportEvent[];
|
|
105
|
+
/** Environment info (best-effort from config); mirrors Python _build_report_data. */
|
|
106
|
+
version?: string;
|
|
107
|
+
model_name?: string;
|
|
108
|
+
parse_mode?: string;
|
|
109
|
+
loaded_plugins?: Array<Record<string, unknown>>;
|
|
75
110
|
}
|
|
76
111
|
export interface ReportGenerator {
|
|
77
112
|
addEvent(event: ReportEvent): void;
|
|
113
|
+
/**
|
|
114
|
+
* 将子 agent 的缓冲事件挂到父步骤下指定类型的父事件上(对齐 Python
|
|
115
|
+
* report_generator.attach_sub_events)。子 agent 事件先缓冲(BufferingReportGenerator),
|
|
116
|
+
* 结束后调用本方法挂到父 run_subagent 的 mcp_tool_start 事件 subEvents 字段。
|
|
117
|
+
* 未找到父事件时 warning 丢弃(不阻断)。
|
|
118
|
+
*/
|
|
119
|
+
attachSubEvents(parentStep: number, parentEventType: string, subEvents: ReportEvent[]): void;
|
|
78
120
|
addTokenUsage(usage: unknown, source?: string, stepNumber?: number): void;
|
|
79
121
|
setTask(task: string): void;
|
|
80
122
|
setTestCase(testCase: string): void;
|
|
@@ -19,6 +19,11 @@ export interface CaseResultData {
|
|
|
19
19
|
category: string;
|
|
20
20
|
test_steps: string;
|
|
21
21
|
report_dir: string;
|
|
22
|
+
/**
|
|
23
|
+
* 执行报告 html 文件名(相对 report_dir,如 "001_case.html")。
|
|
24
|
+
* 中断续执行场景下历史 jsonl 行可能缺失该字段,gen_report 会走回退链。
|
|
25
|
+
*/
|
|
26
|
+
report_html?: string;
|
|
22
27
|
start_time: string;
|
|
23
28
|
end_time: string;
|
|
24
29
|
duration_seconds: number;
|
|
@@ -47,7 +52,13 @@ export declare class AutoTestBackend {
|
|
|
47
52
|
private config;
|
|
48
53
|
private mode;
|
|
49
54
|
private promptName;
|
|
50
|
-
|
|
55
|
+
/** t41: 插件参数 + 工具白名单(透传到 runTask TaskOptions)。 */
|
|
56
|
+
private pluginParam;
|
|
57
|
+
private allowedTools;
|
|
58
|
+
/** Per-case soft timeout (ms). runWithTimeout fires stopTask at this point so
|
|
59
|
+
* the agent breaks its loop + still generates the report (not a hard kill). */
|
|
60
|
+
private caseTimeoutMs;
|
|
61
|
+
constructor(agent: AgentAPIImpl, config?: string, mode?: string, promptName?: string, pluginParam?: string, allowedTools?: string, caseTimeoutMs?: number);
|
|
51
62
|
/** Execute a single test case. */
|
|
52
63
|
executeCase(testSteps: string, reportDir: string, caseMode?: string, skipClearProcess?: boolean): Promise<{
|
|
53
64
|
returnCode: number;
|
|
@@ -88,8 +99,35 @@ export interface BatchOptions {
|
|
|
88
99
|
workDir?: string;
|
|
89
100
|
maxCases?: number;
|
|
90
101
|
skipClearProcess?: boolean;
|
|
102
|
+
/** t41: 白名单/黑名单(过滤用例)。 */
|
|
103
|
+
whitelist?: string[];
|
|
104
|
+
blacklist?: string[];
|
|
105
|
+
/** t41: 插件参数 + 工具白名单(透传到 AutoTestBackend → runTask)。 */
|
|
106
|
+
pluginParam?: string;
|
|
107
|
+
allowedTools?: string;
|
|
108
|
+
/** Per-case soft timeout in ms (in-process path). */
|
|
109
|
+
caseTimeoutMs?: number;
|
|
91
110
|
}
|
|
92
111
|
/** Execute a batch of test cases. */
|
|
93
112
|
export declare function executeBatch(options: BatchOptions): Promise<SummaryData | null>;
|
|
94
113
|
/** CLI entry point. */
|
|
95
114
|
export declare function main(): Promise<number>;
|
|
115
|
+
interface IsolatedBatchOpts {
|
|
116
|
+
testcases: string;
|
|
117
|
+
config: string;
|
|
118
|
+
category: string;
|
|
119
|
+
taskDir: string;
|
|
120
|
+
workDir: string;
|
|
121
|
+
maxCases: number;
|
|
122
|
+
caseTimeout: number;
|
|
123
|
+
/** t41: 白名单/黑名单(过滤用例)。 */
|
|
124
|
+
whitelist?: string[];
|
|
125
|
+
blacklist?: string[];
|
|
126
|
+
/** t41: 插件参数 + 工具白名单(透传到子进程)。 */
|
|
127
|
+
pluginParam?: string;
|
|
128
|
+
allowedTools?: string;
|
|
129
|
+
}
|
|
130
|
+
/** Run each case in its own child `batch_runner.js` (no --isolated) with a hard
|
|
131
|
+
* timeout; aggregate results into <taskDir>/task_results.jsonl + write summary.json. */
|
|
132
|
+
export declare function executeIsolatedBatch(opts: IsolatedBatchOpts): Promise<number>;
|
|
133
|
+
export {};
|