@autotest/agent 0.0.6 → 0.0.8
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 +7 -0
- package/dist/.buildstamp +1 -0
- package/dist/api/agent_api.d.ts +2 -2
- package/dist/autotest-cli.js +1 -397
- package/dist/common/config/config.yaml +4 -0
- package/dist/common/config/manager.d.ts +4 -4
- package/dist/common/config/types.d.ts +5 -0
- package/dist/common/dfx/index.d.ts +1 -1
- package/dist/core/agent/single_agent/agent.d.ts +1 -0
- package/dist/core/device/device_protocol.d.ts +1 -1
- package/dist/core/device/hdc/device.d.ts +5 -2
- package/dist/core/knowledge/knowledge_manager.d.ts +3 -3
- package/dist/core/knowledge/vectordb.d.ts +5 -5
- package/dist/core/mcp/harmony_hdc_adapter.d.ts +2 -0
- package/dist/core/mcp/mcp_tools.d.ts +1 -0
- package/dist/core/mcp/verify_tool.d.ts +12 -0
- package/dist/core/prompt/templates/single/single_v2.0.md +15 -0
- package/dist/data_types/device.d.ts +1 -1
- package/dist/data_types/index.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -163
- package/dist/tools/batch_runner.js +1 -745
- package/dist/tools/case_runner/runner.js +1 -410
- package/dist/tools/config/config_tool.js +1 -339
- package/dist/tools/prompt_compare/compare_runner.js +1 -360
- package/package.json +2 -2
- package/dist/api/agent_api.js +0 -550
- package/dist/api/autotest_agent.js +0 -205
- package/dist/api/types.js +0 -11
- package/dist/common/case_manager.js +0 -91
- package/dist/common/collect_case.js +0 -128
- package/dist/common/common_errors.js +0 -66
- package/dist/common/config/config_validator.js +0 -28
- package/dist/common/config/manager.js +0 -257
- package/dist/common/config/output.js +0 -59
- package/dist/common/config/types.js +0 -185
- package/dist/common/dfx/client_factory.js +0 -62
- package/dist/common/dfx/context.js +0 -23
- package/dist/common/dfx/index.js +0 -15
- package/dist/common/dfx/recorder.js +0 -191
- package/dist/common/dfx/recording_fetch.js +0 -228
- package/dist/common/dfx/source.js +0 -13
- package/dist/common/image_cacher.js +0 -36
- package/dist/common/image_helper.js +0 -128
- package/dist/common/image_similarity.js +0 -171
- package/dist/common/llm_cache/cache_transport.js +0 -102
- package/dist/common/llm_cache/prompt_cache.js +0 -113
- package/dist/common/logger.js +0 -158
- package/dist/common/model/custom_model.js +0 -487
- package/dist/common/model/index.js +0 -5
- package/dist/common/path_utils.js +0 -88
- package/dist/common/result_parser.js +0 -49
- package/dist/common/usage/token_usage.js +0 -117
- package/dist/common/utils.js +0 -125
- package/dist/core/agent/layered_agent/ability_helper.js +0 -125
- package/dist/core/agent/layered_agent/agent.js +0 -37
- package/dist/core/agent/layered_agent/agent_registry.js +0 -82
- package/dist/core/agent/layered_agent/decision.js +0 -518
- package/dist/core/agent/layered_agent/execute_agent/action_handler.js +0 -155
- package/dist/core/agent/layered_agent/execute_agent/agent_factory.js +0 -41
- package/dist/core/agent/layered_agent/execute_agent/base_agent.js +0 -112
- package/dist/core/agent/layered_agent/execute_agent/general_agent.js +0 -207
- package/dist/core/agent/layered_agent/execute_agent/glm_agent.js +0 -241
- package/dist/core/agent/layered_agent/execute_agent/i18n.js +0 -34
- package/dist/core/agent/layered_agent/execute_agent/index.js +0 -67
- package/dist/core/agent/layered_agent/execute_agent/mai_ui_agent.js +0 -316
- package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.js +0 -154
- package/dist/core/agent/layered_agent/execute_agent/parser/general_parser.js +0 -243
- package/dist/core/agent/layered_agent/execute_agent/parser/glm_parser.js +0 -139
- package/dist/core/agent/layered_agent/execute_agent/parser/index.js +0 -9
- package/dist/core/agent/layered_agent/execute_agent/parser/mai_ui_parser.js +0 -94
- package/dist/core/agent/layered_agent/execute_agent/prompts.js +0 -109
- package/dist/core/agent/layered_agent/execute_agent/simple_reporter.js +0 -33
- package/dist/core/agent/layered_agent/execute_agent/utils.js +0 -52
- package/dist/core/agent/report_analyzer_agent/agent.js +0 -565
- package/dist/core/agent/report_analyzer_agent/config.js +0 -22
- package/dist/core/agent/report_analyzer_agent/data_loader.js +0 -255
- package/dist/core/agent/report_analyzer_agent/guardrails.js +0 -99
- package/dist/core/agent/report_analyzer_agent/hooks.js +0 -31
- package/dist/core/agent/report_analyzer_agent/index.js +0 -52
- package/dist/core/agent/report_analyzer_agent/key_steps_builder.js +0 -42
- package/dist/core/agent/report_analyzer_agent/mapping.js +0 -133
- package/dist/core/agent/report_analyzer_agent/parse.js +0 -375
- package/dist/core/agent/report_analyzer_agent/prompt.js +0 -300
- package/dist/core/agent/report_analyzer_agent/report_writer.js +0 -558
- package/dist/core/agent/report_analyzer_agent/tools.js +0 -150
- package/dist/core/agent/report_analyzer_agent/types.js +0 -274
- package/dist/core/agent/rewrite_agent/agent.js +0 -209
- package/dist/core/agent/rewrite_agent/guardrails.js +0 -95
- package/dist/core/agent/rewrite_agent/mapping.js +0 -56
- package/dist/core/agent/rewrite_agent/parse.js +0 -121
- package/dist/core/agent/rewrite_agent/types.js +0 -37
- package/dist/core/agent/single_agent/agent.js +0 -801
- package/dist/core/agent/single_agent/hook_manager.js +0 -59
- package/dist/core/agent/single_agent/hooks.js +0 -288
- package/dist/core/agent/single_agent/image_utils.js +0 -158
- package/dist/core/agent/single_agent/scroll_search_agent.js +0 -405
- package/dist/core/agent/single_agent/subagent_manager.js +0 -72
- package/dist/core/agent/single_agent/tool_recorder_hook.js +0 -42
- package/dist/core/agent/types.js +0 -2
- package/dist/core/agent/utils/message_builder.js +0 -138
- package/dist/core/device/device_protocol.js +0 -2
- package/dist/core/device/hdc/apps.js +0 -437
- package/dist/core/device/hdc/device.js +0 -219
- package/dist/core/device/hdc/index.js +0 -31
- package/dist/core/device/hdc/input.js +0 -74
- package/dist/core/device/hdc/screenshot.js +0 -171
- package/dist/core/device/index.js +0 -70
- package/dist/core/device/types.js +0 -2
- package/dist/core/knowledge/knowledge_manager.js +0 -70
- package/dist/core/knowledge/vectordb.js +0 -283
- package/dist/core/mcp/adapter_factory.js +0 -99
- package/dist/core/mcp/android_adapter.js +0 -286
- package/dist/core/mcp/base_adapter.js +0 -86
- package/dist/core/mcp/harmony_hdc_adapter.js +0 -798
- package/dist/core/mcp/ios_adapter.js +0 -286
- package/dist/core/mcp/local_tools.js +0 -41
- package/dist/core/mcp/mcp_tools.js +0 -473
- package/dist/core/mcp/types.js +0 -6
- package/dist/core/memory/_utils.js +0 -140
- package/dist/core/memory/compressed_session.js +0 -182
- package/dist/core/memory/context_compressor.js +0 -176
- package/dist/core/memory/index.js +0 -22
- package/dist/core/memory/memory_manager.js +0 -28
- package/dist/core/memory/reflector.js +0 -95
- package/dist/core/memory/replan_manager.js +0 -12
- package/dist/core/memory/session_factory.js +0 -29
- package/dist/core/memory/tool_player.js +0 -225
- package/dist/core/memory/tool_player_popup.js +0 -276
- package/dist/core/memory/tool_player_replan.js +0 -226
- package/dist/core/memory/tool_player_xpath.js +0 -139
- package/dist/core/memory/tool_recorder.js +0 -126
- package/dist/core/preprocessor/task_splitter.js +0 -112
- package/dist/core/prompt/prompt_loader.js +0 -315
- package/dist/core/skill/skill_manager.js +0 -302
- package/dist/data_types/action.js +0 -2
- package/dist/data_types/agent.js +0 -2
- package/dist/data_types/case.js +0 -57
- package/dist/data_types/device.js +0 -2
- package/dist/data_types/index.js +0 -11
- package/dist/data_types/report.js +0 -6
- package/dist/data_types/screen.js +0 -23
- package/dist/data_types/task.js +0 -2
- package/dist/loop/cli.js +0 -127
- package/dist/loop/orchestrator.js +0 -314
- package/dist/loop/result_writer.js +0 -260
- package/dist/loop/types.js +0 -82
- package/dist/mcp-server/server.js +0 -341
- package/dist/mcp-server/types.js +0 -224
- package/dist/reporter/batch_summary.js +0 -197
- package/dist/reporter/generator.js +0 -286
- package/dist/reporter/html_template/index.js +0 -529
- package/dist/reporter/json_report.js +0 -6
- package/dist/reporter/types.js +0 -45
- package/dist/tools/case_runner/report.js +0 -264
package/dist/mcp-server/types.js
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TOOL_DESCRIPTIONS = exports.UpdateConfigInputSchema = exports.GetConfigInputSchema = exports.AnalyzeFailureInputSchema = exports.ResumeTaskInputSchema = exports.GetTaskResultInputSchema = exports.RunTaskInputSchema = exports.ListDevicesInputSchema = exports.GenerateReportInputSchema = exports.StopDataCollectInputSchema = exports.StartDataCollectInputSchema = exports.GetToastInputSchema = exports.StartListenToastInputSchema = exports.StopAllAppInputSchema = exports.RotateScreenInputSchema = exports.RotateGestureInputSchema = exports.PinchOutInputSchema = exports.PinchInInputSchema = exports.OpenNotificationCenterInputSchema = exports.OpenControlCenterInputSchema = exports.McpCleanUpInputSchema = exports.LayoutInputSchema = exports.ScreenshotInputSchema = exports.GetCurrentAppInputSchema = exports.EnterRecentTaskInputSchema = exports.ClearRecentTaskInputSchema = exports.UnlockScreenInputSchema = exports.ScreenOffInputSchema = exports.ScreenOnInputSchema = exports.PressKeyInputSchema = exports.WaitInputSchema = exports.ClearAppDataInputSchema = exports.StopAppInputSchema = exports.StartAppInputSchema = exports.GoHomeInputSchema = exports.GoBackInputSchema = exports.ClearTextInputSchema = exports.InputTextInputSchema = exports.DragInputSchema = exports.SwipeInputSchema = exports.LongClickInputSchema = exports.DoubleClickInputSchema = exports.ClickInputSchema = exports.McpServerToolName = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
var McpServerToolName;
|
|
6
|
-
(function (McpServerToolName) {
|
|
7
|
-
// Device operations (35 — aligned with adapter callTool)
|
|
8
|
-
McpServerToolName["CLICK"] = "click";
|
|
9
|
-
McpServerToolName["DOUBLE_CLICK"] = "double_click";
|
|
10
|
-
McpServerToolName["LONG_CLICK"] = "long_click";
|
|
11
|
-
McpServerToolName["SWIPE"] = "swipe";
|
|
12
|
-
McpServerToolName["DRAG"] = "drag";
|
|
13
|
-
McpServerToolName["INPUT_TEXT"] = "input_text";
|
|
14
|
-
McpServerToolName["CLEAR_TEXT"] = "clear_text";
|
|
15
|
-
McpServerToolName["GO_BACK"] = "go_back";
|
|
16
|
-
McpServerToolName["GO_HOME"] = "go_home";
|
|
17
|
-
McpServerToolName["START_APP"] = "start_app";
|
|
18
|
-
McpServerToolName["STOP_APP"] = "stop_app";
|
|
19
|
-
McpServerToolName["CLEAR_APP_DATA"] = "clear_app_data";
|
|
20
|
-
McpServerToolName["WAIT"] = "wait";
|
|
21
|
-
McpServerToolName["PRESS_KEY"] = "press_key";
|
|
22
|
-
McpServerToolName["SCREEN_ON"] = "screen_on";
|
|
23
|
-
McpServerToolName["SCREEN_OFF"] = "screen_off";
|
|
24
|
-
McpServerToolName["UNLOCK_SCREEN"] = "unlock_screen";
|
|
25
|
-
McpServerToolName["CLEAR_RECENT_TASK"] = "clear_recent_task";
|
|
26
|
-
McpServerToolName["ENTER_RECENT_TASK"] = "enter_recent_task";
|
|
27
|
-
McpServerToolName["GET_CURRENT_APP"] = "get_current_app";
|
|
28
|
-
McpServerToolName["SCREENSHOT"] = "screenshot";
|
|
29
|
-
McpServerToolName["LAYOUT"] = "layout";
|
|
30
|
-
McpServerToolName["MCP_CLEAN_UP"] = "mcp_clean_up";
|
|
31
|
-
McpServerToolName["OPEN_CONTROL_CENTER"] = "open_control_center";
|
|
32
|
-
McpServerToolName["OPEN_NOTIFICATION_CENTER"] = "open_notification_center";
|
|
33
|
-
McpServerToolName["PINCH_IN"] = "pinch_in";
|
|
34
|
-
McpServerToolName["PINCH_OUT"] = "pinch_out";
|
|
35
|
-
McpServerToolName["ROTATE_GESTURE"] = "rotate_gesture";
|
|
36
|
-
McpServerToolName["ROTATE_SCREEN"] = "rotate_screen";
|
|
37
|
-
McpServerToolName["STOP_ALL_APP"] = "stop_all_app";
|
|
38
|
-
McpServerToolName["START_LISTEN_TOAST"] = "start_listen_toast";
|
|
39
|
-
McpServerToolName["GET_TOAST"] = "get_toast";
|
|
40
|
-
McpServerToolName["START_DATA_COLLECT"] = "start_data_collect";
|
|
41
|
-
McpServerToolName["STOP_DATA_COLLECT"] = "stop_data_collect";
|
|
42
|
-
McpServerToolName["GENERATE_REPORT"] = "generate_report";
|
|
43
|
-
// Management (7)
|
|
44
|
-
McpServerToolName["LIST_DEVICES"] = "list_devices";
|
|
45
|
-
McpServerToolName["RUN_TASK"] = "run_task";
|
|
46
|
-
McpServerToolName["GET_TASK_RESULT"] = "get_task_result";
|
|
47
|
-
McpServerToolName["RESUME_TASK"] = "resume_task";
|
|
48
|
-
McpServerToolName["ANALYZE_FAILURE"] = "analyze_failure";
|
|
49
|
-
McpServerToolName["GET_CONFIG"] = "get_config";
|
|
50
|
-
McpServerToolName["UPDATE_CONFIG"] = "update_config";
|
|
51
|
-
})(McpServerToolName || (exports.McpServerToolName = McpServerToolName = {}));
|
|
52
|
-
// ---- Point helper: accepts pos:[x,y] or x/y pair ----
|
|
53
|
-
const PointSchema = zod_1.z.object({
|
|
54
|
-
pos: zod_1.z.array(zod_1.z.number()).length(2).optional(),
|
|
55
|
-
x: zod_1.z.number().optional(),
|
|
56
|
-
y: zod_1.z.number().optional(),
|
|
57
|
-
});
|
|
58
|
-
// ---- Device operation schemas ----
|
|
59
|
-
exports.ClickInputSchema = PointSchema;
|
|
60
|
-
exports.DoubleClickInputSchema = PointSchema;
|
|
61
|
-
exports.LongClickInputSchema = zod_1.z.object({
|
|
62
|
-
pos: zod_1.z.array(zod_1.z.number()).length(2).optional(),
|
|
63
|
-
x: zod_1.z.number().optional(),
|
|
64
|
-
y: zod_1.z.number().optional(),
|
|
65
|
-
duration: zod_1.z.number().default(2),
|
|
66
|
-
});
|
|
67
|
-
exports.SwipeInputSchema = zod_1.z.object({
|
|
68
|
-
start: zod_1.z.array(zod_1.z.number()).length(2),
|
|
69
|
-
end: zod_1.z.array(zod_1.z.number()).length(2),
|
|
70
|
-
direction: zod_1.z.string().optional(),
|
|
71
|
-
});
|
|
72
|
-
exports.DragInputSchema = zod_1.z.object({
|
|
73
|
-
start: zod_1.z.array(zod_1.z.number()).length(2),
|
|
74
|
-
end: zod_1.z.array(zod_1.z.number()).length(2),
|
|
75
|
-
});
|
|
76
|
-
exports.InputTextInputSchema = zod_1.z.object({
|
|
77
|
-
text: zod_1.z.string(),
|
|
78
|
-
});
|
|
79
|
-
exports.ClearTextInputSchema = zod_1.z.object({});
|
|
80
|
-
exports.GoBackInputSchema = zod_1.z.object({
|
|
81
|
-
times: zod_1.z.number().int().default(1),
|
|
82
|
-
});
|
|
83
|
-
exports.GoHomeInputSchema = zod_1.z.object({
|
|
84
|
-
times: zod_1.z.number().int().default(1),
|
|
85
|
-
});
|
|
86
|
-
exports.StartAppInputSchema = zod_1.z.object({
|
|
87
|
-
app_name: zod_1.z.string(),
|
|
88
|
-
cold_start: zod_1.z.boolean().default(false),
|
|
89
|
-
});
|
|
90
|
-
exports.StopAppInputSchema = zod_1.z.object({
|
|
91
|
-
app_name: zod_1.z.string(),
|
|
92
|
-
});
|
|
93
|
-
exports.ClearAppDataInputSchema = zod_1.z.object({
|
|
94
|
-
app_name: zod_1.z.string(),
|
|
95
|
-
});
|
|
96
|
-
exports.WaitInputSchema = zod_1.z.object({
|
|
97
|
-
duration: zod_1.z.number().default(3),
|
|
98
|
-
});
|
|
99
|
-
exports.PressKeyInputSchema = zod_1.z.object({
|
|
100
|
-
key_name: zod_1.z.enum(['home', 'power', 'volume_up', 'volume_down']),
|
|
101
|
-
});
|
|
102
|
-
exports.ScreenOnInputSchema = zod_1.z.object({});
|
|
103
|
-
exports.ScreenOffInputSchema = zod_1.z.object({});
|
|
104
|
-
exports.UnlockScreenInputSchema = zod_1.z.object({});
|
|
105
|
-
exports.ClearRecentTaskInputSchema = zod_1.z.object({});
|
|
106
|
-
exports.EnterRecentTaskInputSchema = zod_1.z.object({});
|
|
107
|
-
exports.GetCurrentAppInputSchema = zod_1.z.object({});
|
|
108
|
-
exports.ScreenshotInputSchema = zod_1.z.object({
|
|
109
|
-
save_path: zod_1.z.string().optional(),
|
|
110
|
-
});
|
|
111
|
-
exports.LayoutInputSchema = zod_1.z.object({});
|
|
112
|
-
exports.McpCleanUpInputSchema = zod_1.z.object({});
|
|
113
|
-
exports.OpenControlCenterInputSchema = zod_1.z.object({
|
|
114
|
-
full_screen: zod_1.z.boolean().default(false),
|
|
115
|
-
});
|
|
116
|
-
exports.OpenNotificationCenterInputSchema = zod_1.z.object({
|
|
117
|
-
full_screen: zod_1.z.boolean().default(false),
|
|
118
|
-
});
|
|
119
|
-
exports.PinchInInputSchema = zod_1.z.object({
|
|
120
|
-
pos: zod_1.z.array(zod_1.z.number()).length(2).optional(),
|
|
121
|
-
x: zod_1.z.number().optional(),
|
|
122
|
-
y: zod_1.z.number().optional(),
|
|
123
|
-
radius: zod_1.z.number().default(300),
|
|
124
|
-
scale: zod_1.z.number().default(0.2),
|
|
125
|
-
});
|
|
126
|
-
exports.PinchOutInputSchema = zod_1.z.object({
|
|
127
|
-
pos: zod_1.z.array(zod_1.z.number()).length(2).optional(),
|
|
128
|
-
x: zod_1.z.number().optional(),
|
|
129
|
-
y: zod_1.z.number().optional(),
|
|
130
|
-
radius: zod_1.z.number().default(300),
|
|
131
|
-
scale: zod_1.z.number().default(1.6),
|
|
132
|
-
});
|
|
133
|
-
exports.RotateGestureInputSchema = zod_1.z.object({
|
|
134
|
-
pos: zod_1.z.array(zod_1.z.number()).length(2).optional(),
|
|
135
|
-
x: zod_1.z.number().optional(),
|
|
136
|
-
y: zod_1.z.number().optional(),
|
|
137
|
-
angle: zod_1.z.number().default(90),
|
|
138
|
-
clockwise: zod_1.z.boolean().default(true),
|
|
139
|
-
radius: zod_1.z.number().default(300),
|
|
140
|
-
});
|
|
141
|
-
exports.RotateScreenInputSchema = zod_1.z.object({
|
|
142
|
-
direction: zod_1.z.enum(['portrait', 'landscape']),
|
|
143
|
-
});
|
|
144
|
-
exports.StopAllAppInputSchema = zod_1.z.object({});
|
|
145
|
-
exports.StartListenToastInputSchema = zod_1.z.object({});
|
|
146
|
-
exports.GetToastInputSchema = zod_1.z.object({
|
|
147
|
-
timeout: zod_1.z.number().default(3),
|
|
148
|
-
});
|
|
149
|
-
exports.StartDataCollectInputSchema = zod_1.z.object({});
|
|
150
|
-
exports.StopDataCollectInputSchema = zod_1.z.object({});
|
|
151
|
-
exports.GenerateReportInputSchema = zod_1.z.object({});
|
|
152
|
-
// ---- Management schemas ----
|
|
153
|
-
exports.ListDevicesInputSchema = zod_1.z.object({});
|
|
154
|
-
exports.RunTaskInputSchema = zod_1.z.object({
|
|
155
|
-
task: zod_1.z.string(),
|
|
156
|
-
agentMode: zod_1.z.enum(['single', 'hypium', 'layered']).default('single'),
|
|
157
|
-
deviceId: zod_1.z.string(),
|
|
158
|
-
platform: zod_1.z.enum(['harmony', 'android', 'ios']).default('harmony'),
|
|
159
|
-
promptVersion: zod_1.z.string().nullable().optional(),
|
|
160
|
-
configOverrides: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable().optional(),
|
|
161
|
-
reportDir: zod_1.z.string().nullable().optional(),
|
|
162
|
-
feedbackMode: zod_1.z.enum(['poll', 'stream', 'callback']).default('poll'),
|
|
163
|
-
callbackUrl: zod_1.z.string().nullable().optional(),
|
|
164
|
-
});
|
|
165
|
-
exports.GetTaskResultInputSchema = zod_1.z.object({
|
|
166
|
-
taskId: zod_1.z.string(),
|
|
167
|
-
});
|
|
168
|
-
exports.ResumeTaskInputSchema = zod_1.z.object({
|
|
169
|
-
taskId: zod_1.z.string(),
|
|
170
|
-
startIndex: zod_1.z.number().int().nullable().optional(),
|
|
171
|
-
});
|
|
172
|
-
exports.AnalyzeFailureInputSchema = zod_1.z.object({
|
|
173
|
-
taskId: zod_1.z.string(),
|
|
174
|
-
caseIdx: zod_1.z.number().int(),
|
|
175
|
-
});
|
|
176
|
-
exports.GetConfigInputSchema = zod_1.z.object({});
|
|
177
|
-
exports.UpdateConfigInputSchema = zod_1.z.object({
|
|
178
|
-
partial: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
179
|
-
});
|
|
180
|
-
// ---- Tool descriptions ----
|
|
181
|
-
exports.TOOL_DESCRIPTIONS = {
|
|
182
|
-
click: '在指定坐标执行点击操作',
|
|
183
|
-
double_click: '在指定坐标执行双击操作',
|
|
184
|
-
long_click: '在指定坐标执行长按操作',
|
|
185
|
-
swipe: '从起点滑动到终点',
|
|
186
|
-
drag: '从起点拖拽到终点',
|
|
187
|
-
input_text: '在当前光标位置输入文本',
|
|
188
|
-
clear_text: '清除当前光标位置的文本',
|
|
189
|
-
go_back: '返回上一级',
|
|
190
|
-
go_home: '返回桌面',
|
|
191
|
-
start_app: '在设备上启动应用程序',
|
|
192
|
-
stop_app: '在设备上停止应用程序',
|
|
193
|
-
clear_app_data: '清除应用程序的数据',
|
|
194
|
-
wait: '等待指定时间,最大600秒',
|
|
195
|
-
press_key: '按下按键 (home/power/volume_up/volume_down)',
|
|
196
|
-
screen_on: '打开设备屏幕',
|
|
197
|
-
screen_off: '关闭设备屏幕',
|
|
198
|
-
unlock_screen: '解锁设备屏幕',
|
|
199
|
-
clear_recent_task: '清空最近任务(清空后台)',
|
|
200
|
-
enter_recent_task: '进入系统最近任务页面',
|
|
201
|
-
get_current_app: '获取当前运行的应用程序的包名',
|
|
202
|
-
screenshot: '获取屏幕截图',
|
|
203
|
-
layout: '获取设备当前UI布局并提取有效元素',
|
|
204
|
-
mcp_clean_up: '释放所有缓存的设备连接',
|
|
205
|
-
open_control_center: '打开系统控制中心',
|
|
206
|
-
open_notification_center: '打开系统通知中心',
|
|
207
|
-
pinch_in: '在指定位置执行双指缩放',
|
|
208
|
-
pinch_out: '在指定位置执行双指放大',
|
|
209
|
-
rotate_gesture: '执行双指旋转手势',
|
|
210
|
-
rotate_screen: '旋转设备屏幕方向',
|
|
211
|
-
stop_all_app: '停止所有应用程序',
|
|
212
|
-
start_listen_toast: '开始监听 Toast 提示消息',
|
|
213
|
-
get_toast: '获取最新的 Toast 提示消息',
|
|
214
|
-
start_data_collect: '开始数据采集',
|
|
215
|
-
stop_data_collect: '结束数据采集',
|
|
216
|
-
generate_report: '生成测试报告',
|
|
217
|
-
list_devices: '列出所有已连接的设备',
|
|
218
|
-
run_task: '执行一个测试任务',
|
|
219
|
-
get_task_result: '获取任务执行结果',
|
|
220
|
-
resume_task: '从指定步骤恢复执行任务',
|
|
221
|
-
analyze_failure: '分析任务失败原因',
|
|
222
|
-
get_config: '获取当前配置',
|
|
223
|
-
update_config: '更新配置',
|
|
224
|
-
};
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.buildResultFromEvents = buildResultFromEvents;
|
|
37
|
-
exports.buildResultFromGenerator = buildResultFromGenerator;
|
|
38
|
-
exports.generateSummaryReport = generateSummaryReport;
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const path = __importStar(require("path"));
|
|
41
|
-
const logger_1 = require("../common/logger");
|
|
42
|
-
const types_1 = require("./types");
|
|
43
|
-
function buildResultFromEvents(name, events, startTime = null, endTime = null, reportPath, outputDir) {
|
|
44
|
-
let status = 'fail';
|
|
45
|
-
for (let i = events.length - 1; i >= 0; i--) {
|
|
46
|
-
const ev = events[i];
|
|
47
|
-
if (ev.eventType === types_1.EventType.TASK_END) {
|
|
48
|
-
const d = ev.data;
|
|
49
|
-
const agentStatus = String(d?.status ?? '').toLowerCase();
|
|
50
|
-
const content = ev.content?.replace(/^Task completed:\s*/, '') ?? '';
|
|
51
|
-
if (agentStatus === 'pass' || agentStatus === 'completed' || agentStatus === 'success') {
|
|
52
|
-
status = 'success';
|
|
53
|
-
}
|
|
54
|
-
else if (content.includes('通过') && !content.includes('不通过')) {
|
|
55
|
-
status = 'success';
|
|
56
|
-
}
|
|
57
|
-
else if (content.match(/PASS/i)) {
|
|
58
|
-
status = 'success';
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
status = 'fail';
|
|
62
|
-
}
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
let duration = 0;
|
|
67
|
-
if (startTime && endTime) {
|
|
68
|
-
const diff = new Date(endTime).getTime() - new Date(startTime).getTime();
|
|
69
|
-
duration = Math.max(diff / 1000, 0);
|
|
70
|
-
}
|
|
71
|
-
let relPath = reportPath ?? '';
|
|
72
|
-
if (relPath && outputDir) {
|
|
73
|
-
try {
|
|
74
|
-
if (path.isAbsolute(relPath)) {
|
|
75
|
-
relPath = path.relative(outputDir, relPath).replace(/\\/g, '/');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
catch { /* keep original */ }
|
|
79
|
-
}
|
|
80
|
-
else if (relPath) {
|
|
81
|
-
relPath = relPath.replace(/\\/g, '/');
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
name: name || '未命名用例',
|
|
85
|
-
status,
|
|
86
|
-
duration,
|
|
87
|
-
reportPath: relPath,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function buildResultFromGenerator(generator, reportPath, outputDir) {
|
|
91
|
-
const name = generator.testCase || generator.task || '未命名用例';
|
|
92
|
-
const status = (generator.status?.toUpperCase() === 'PASS') ? 'success' : 'fail';
|
|
93
|
-
let duration = 0;
|
|
94
|
-
if (generator.startTime && generator.endTime) {
|
|
95
|
-
const diff = new Date(generator.endTime).getTime() - new Date(generator.startTime).getTime();
|
|
96
|
-
duration = Math.max(diff / 1000, 0);
|
|
97
|
-
}
|
|
98
|
-
let relPath = reportPath;
|
|
99
|
-
if (!relPath && generator.reportDir && generator._baseFilename) {
|
|
100
|
-
relPath = path.join(generator.reportDir, `${generator._baseFilename}.html`);
|
|
101
|
-
}
|
|
102
|
-
if (relPath && outputDir) {
|
|
103
|
-
try {
|
|
104
|
-
if (path.isAbsolute(relPath)) {
|
|
105
|
-
relPath = path.relative(outputDir, relPath).replace(/\\/g, '/');
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
catch { /* keep */ }
|
|
109
|
-
}
|
|
110
|
-
else if (relPath) {
|
|
111
|
-
relPath = relPath.replace(/\\/g, '/');
|
|
112
|
-
}
|
|
113
|
-
return { name, status, duration, reportPath: relPath ?? '' };
|
|
114
|
-
}
|
|
115
|
-
function generateSummaryReport(results, totalDuration, outputDir) {
|
|
116
|
-
if (!outputDir)
|
|
117
|
-
return null;
|
|
118
|
-
const successCount = results.filter((r) => r.status === 'success').length;
|
|
119
|
-
const failCount = results.length - successCount;
|
|
120
|
-
const passRate = results.length > 0 ? (successCount / results.length) * 100 : 0;
|
|
121
|
-
const caseRows = results.map((c, i) => {
|
|
122
|
-
const statusClass = c.status === 'success' ? 'status-pass' : 'status-fail';
|
|
123
|
-
const statusText = c.status === 'success' ? '成功' : '失败';
|
|
124
|
-
const dur = `${c.duration.toFixed(2)}s`;
|
|
125
|
-
const link = c.reportPath
|
|
126
|
-
? `<a href="${c.reportPath}" target="_blank" class="report-link">查看报告</a>`
|
|
127
|
-
: '<span class="no-report">无报告</span>';
|
|
128
|
-
return `<tr><td>${i + 1}</td><td>${escapeHtml(c.name)}</td><td><span class="status-badge ${statusClass}">${statusText}</span></td><td>${dur}</td><td>${link}</td></tr>`;
|
|
129
|
-
}).join('\n');
|
|
130
|
-
const now = new Date().toLocaleString('zh-CN');
|
|
131
|
-
const html = `<!DOCTYPE html>
|
|
132
|
-
<html lang="zh-CN">
|
|
133
|
-
<head>
|
|
134
|
-
<meta charset="UTF-8">
|
|
135
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
136
|
-
<title>批量测试执行汇总报告</title>
|
|
137
|
-
<style>
|
|
138
|
-
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;margin:0;padding:20px;background:#f5f5f5}
|
|
139
|
-
.container{max-width:1200px;margin:0 auto;background:#fff;padding:30px;border-radius:8px;box-shadow:0 2px 10px rgba(0,0,0,.1)}
|
|
140
|
-
h1{color:#333;border-bottom:2px solid #4CAF50;padding-bottom:10px}
|
|
141
|
-
.overview{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:20px;margin:30px 0}
|
|
142
|
-
.overview-card{background:#f9f9f9;padding:20px;border-radius:8px;text-align:center;border-left:4px solid #4CAF50}
|
|
143
|
-
.overview-card.fail{border-left-color:#F44336}
|
|
144
|
-
.overview-card.total{border-left-color:#2196F3}
|
|
145
|
-
.overview-card.rate{border-left-color:#FF9800}
|
|
146
|
-
.card-title{font-size:14px;color:#666;margin-bottom:10px}
|
|
147
|
-
.card-value{font-size:32px;font-weight:bold;color:#333}
|
|
148
|
-
.progress-bar{width:100%;height:20px;background:#e0e0e0;border-radius:10px;overflow:hidden;margin:20px 0}
|
|
149
|
-
.progress-fill{height:100%;background:linear-gradient(90deg,#4CAF50 0%,#8BC34A 100%);width:${passRate.toFixed(1)}%;transition:width .5s ease}
|
|
150
|
-
.progress-text{text-align:center;font-size:14px;color:#666;margin-bottom:30px}
|
|
151
|
-
table{width:100%;border-collapse:collapse;margin-top:20px}
|
|
152
|
-
th,td{padding:12px 15px;text-align:left;border-bottom:1px solid #eee}
|
|
153
|
-
th{background:#f5f5f5;font-weight:600;color:#333}
|
|
154
|
-
tr:hover{background:#fafafa}
|
|
155
|
-
.status-badge{display:inline-block;padding:4px 12px;border-radius:15px;color:#fff;font-weight:bold;font-size:12px}
|
|
156
|
-
.status-pass{background:#4CAF50}
|
|
157
|
-
.status-fail{background:#F44336}
|
|
158
|
-
.report-link{display:inline-block;padding:6px 12px;background:#2196F3;color:#fff;text-decoration:none;border-radius:4px;font-size:12px}
|
|
159
|
-
.report-link:hover{background:#1976D2}
|
|
160
|
-
.no-report{color:#999;font-size:12px}
|
|
161
|
-
.meta-info{background:#f9f9f9;padding:15px;border-radius:5px;margin-bottom:20px;color:#666;font-size:14px}
|
|
162
|
-
</style>
|
|
163
|
-
</head>
|
|
164
|
-
<body>
|
|
165
|
-
<div class="container">
|
|
166
|
-
<h1>📊 批量测试执行汇总报告</h1>
|
|
167
|
-
<div class="meta-info">
|
|
168
|
-
<div><strong>执行时间:</strong> ${now}</div>
|
|
169
|
-
<div><strong>总耗时:</strong> ${totalDuration.toFixed(2)}s</div>
|
|
170
|
-
</div>
|
|
171
|
-
<div class="overview">
|
|
172
|
-
<div class="overview-card total"><div class="card-title">总用例数</div><div class="card-value">${results.length}</div></div>
|
|
173
|
-
<div class="overview-card"><div class="card-title">成功用例</div><div class="card-value" style="color:#4CAF50">${successCount}</div></div>
|
|
174
|
-
<div class="overview-card fail"><div class="card-title">失败用例</div><div class="card-value" style="color:#F44336">${failCount}</div></div>
|
|
175
|
-
<div class="overview-card rate"><div class="card-title">执行通过率</div><div class="card-value" style="color:#FF9800">${passRate.toFixed(1)}%</div></div>
|
|
176
|
-
</div>
|
|
177
|
-
<div class="progress-bar"><div class="progress-fill"></div></div>
|
|
178
|
-
<div class="progress-text">通过率: ${passRate.toFixed(1)}% (${successCount}/${results.length})</div>
|
|
179
|
-
<h2>用例执行详情</h2>
|
|
180
|
-
<table>
|
|
181
|
-
<thead><tr><th>序号</th><th>用例名称</th><th>执行状态</th><th>执行耗时</th><th>操作</th></tr></thead>
|
|
182
|
-
<tbody>
|
|
183
|
-
${caseRows}
|
|
184
|
-
</tbody>
|
|
185
|
-
</table>
|
|
186
|
-
</div>
|
|
187
|
-
</body>
|
|
188
|
-
</html>`;
|
|
189
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
190
|
-
const summaryPath = path.join(outputDir, 'index.html');
|
|
191
|
-
fs.writeFileSync(summaryPath, html, 'utf-8');
|
|
192
|
-
logger_1.logger.info(`Batch summary report generated: ${summaryPath}`);
|
|
193
|
-
return summaryPath;
|
|
194
|
-
}
|
|
195
|
-
function escapeHtml(s) {
|
|
196
|
-
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
197
|
-
}
|