@autotest/agent 0.0.4 → 0.0.6
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 +3 -0
- package/dist/api/agent_api.d.ts +2 -2
- package/dist/api/agent_api.js +7 -7
- package/dist/autotest-cli.js +44 -44
- package/dist/common/config/config.yaml +1 -0
- package/dist/common/config/config_validator.js +1 -1
- package/dist/common/config/manager.d.ts +10 -10
- package/dist/common/config/manager.js +12 -12
- package/dist/common/config/output.js +1 -1
- package/dist/common/config/types.d.ts +28 -1
- package/dist/common/config/types.js +12 -11
- package/dist/common/dfx/recording_fetch.js +1 -1
- package/dist/common/dfx/source.js +1 -1
- package/dist/common/image_helper.d.ts +2 -2
- package/dist/common/image_helper.js +2 -2
- package/dist/common/llm_cache/cache_transport.d.ts +1 -1
- package/dist/common/llm_cache/cache_transport.js +1 -1
- package/dist/common/llm_cache/prompt_cache.d.ts +2 -2
- package/dist/common/llm_cache/prompt_cache.js +2 -2
- package/dist/common/model/custom_model.js +5 -4
- package/dist/common/utils.d.ts +5 -5
- package/dist/common/utils.js +5 -5
- package/dist/core/agent/layered_agent/agent_registry.d.ts +3 -1
- package/dist/core/agent/layered_agent/agent_registry.js +12 -5
- package/dist/core/agent/layered_agent/decision.js +3 -1
- package/dist/core/agent/layered_agent/execute_agent/general_agent.js +1 -1
- 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 +34 -34
- package/dist/core/agent/layered_agent/execute_agent/prompts.d.ts +1 -1
- package/dist/core/agent/layered_agent/execute_agent/prompts.js +8 -8
- package/dist/core/agent/report_analyzer_agent/agent.js +4 -4
- package/dist/core/agent/report_analyzer_agent/prompt.d.ts +1 -1
- package/dist/core/agent/report_analyzer_agent/prompt.js +11 -11
- package/dist/core/agent/report_analyzer_agent/report_writer.js +139 -139
- package/dist/core/agent/report_analyzer_agent/tools.d.ts +1 -1
- package/dist/core/agent/report_analyzer_agent/tools.js +2 -2
- package/dist/core/agent/report_analyzer_agent/types.js +2 -2
- package/dist/core/agent/rewrite_agent/agent.d.ts +5 -5
- package/dist/core/agent/rewrite_agent/agent.js +5 -5
- package/dist/core/agent/rewrite_agent/guardrails.d.ts +1 -1
- package/dist/core/agent/rewrite_agent/guardrails.js +1 -1
- package/dist/core/agent/rewrite_agent/mapping.d.ts +1 -1
- package/dist/core/agent/rewrite_agent/mapping.js +3 -3
- package/dist/core/agent/rewrite_agent/parse.d.ts +1 -1
- package/dist/core/agent/rewrite_agent/parse.js +1 -1
- package/dist/core/agent/rewrite_agent/types.d.ts +1 -1
- package/dist/core/agent/rewrite_agent/types.js +1 -1
- package/dist/core/agent/single_agent/agent.d.ts +1 -2
- package/dist/core/agent/single_agent/agent.js +29 -26
- package/dist/core/agent/single_agent/hook_manager.d.ts +1 -2
- package/dist/core/agent/single_agent/hook_manager.js +1 -2
- package/dist/core/agent/single_agent/image_utils.d.ts +1 -2
- package/dist/core/agent/single_agent/image_utils.js +1 -2
- package/dist/core/agent/single_agent/scroll_search_agent.d.ts +5 -5
- package/dist/core/agent/single_agent/scroll_search_agent.js +39 -10
- package/dist/core/agent/single_agent/subagent_manager.d.ts +1 -2
- package/dist/core/agent/single_agent/subagent_manager.js +2 -3
- package/dist/core/agent/single_agent/tool_recorder_hook.d.ts +3 -3
- package/dist/core/agent/single_agent/tool_recorder_hook.js +3 -3
- package/dist/core/device/hdc/apps.js +1 -1
- package/dist/core/device/hdc/device.d.ts +1 -1
- package/dist/core/device/hdc/device.js +1 -1
- package/dist/core/device/hdc/screenshot.js +1 -1
- package/dist/core/device/index.d.ts +2 -2
- package/dist/core/device/index.js +2 -2
- package/dist/core/knowledge/knowledge_manager.d.ts +3 -3
- package/dist/core/knowledge/knowledge_manager.js +3 -3
- package/dist/core/knowledge/vectordb.d.ts +5 -5
- package/dist/core/knowledge/vectordb.js +5 -5
- package/dist/core/mcp/harmony_hdc_adapter.js +21 -5
- package/dist/core/mcp/mcp_tools.d.ts +10 -2
- package/dist/core/mcp/mcp_tools.js +69 -6
- package/dist/core/memory/_utils.d.ts +1 -1
- package/dist/core/memory/_utils.js +1 -1
- package/dist/core/memory/context_compressor.js +2 -2
- package/dist/core/memory/index.d.ts +1 -1
- package/dist/core/memory/index.js +1 -1
- package/dist/core/memory/memory_manager.d.ts +1 -1
- package/dist/core/memory/memory_manager.js +1 -1
- package/dist/core/memory/replan_manager.d.ts +1 -1
- package/dist/core/memory/replan_manager.js +1 -1
- package/dist/core/memory/tool_player.d.ts +5 -5
- package/dist/core/memory/tool_player.js +5 -5
- package/dist/core/memory/tool_player_popup.d.ts +1 -1
- package/dist/core/memory/tool_player_popup.js +12 -12
- package/dist/core/memory/tool_player_replan.d.ts +1 -1
- package/dist/core/memory/tool_player_replan.js +2 -2
- package/dist/core/memory/tool_player_xpath.d.ts +3 -3
- package/dist/core/memory/tool_player_xpath.js +3 -3
- package/dist/core/prompt/prompt_loader.d.ts +1 -1
- package/dist/core/prompt/prompt_loader.js +3 -3
- package/dist/core/skill/skill_manager.d.ts +2 -2
- package/dist/core/skill/skill_manager.js +1 -1
- package/dist/data_types/case.js +1 -1
- package/dist/data_types/screen.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/loop/cli.d.ts +4 -4
- package/dist/loop/cli.js +4 -4
- package/dist/loop/orchestrator.d.ts +6 -6
- package/dist/loop/orchestrator.js +7 -7
- package/dist/loop/result_writer.d.ts +1 -1
- package/dist/loop/result_writer.js +36 -36
- package/dist/loop/types.d.ts +1 -1
- package/dist/loop/types.js +1 -1
- package/dist/reporter/html_template/index.js +14 -9
- package/dist/tools/batch_runner.js +11 -3
- package/dist/tools/case_runner/report.d.ts +1 -1
- package/dist/tools/case_runner/report.js +59 -59
- package/dist/tools/case_runner/runner.d.ts +3 -3
- package/dist/tools/case_runner/runner.js +8 -8
- package/dist/tools/config/config_tool.d.ts +6 -6
- package/dist/tools/config/config_tool.js +27 -27
- package/dist/tools/prompt_compare/compare_runner.d.ts +2 -2
- package/dist/tools/prompt_compare/compare_runner.js +16 -16
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ const ModelConfigSchema = zod_1.z.object({
|
|
|
8
8
|
apiKey: zod_1.z.string().default(''),
|
|
9
9
|
provider: zod_1.z.string().default('openai'),
|
|
10
10
|
apiVersion: zod_1.z.string().default(''),
|
|
11
|
-
//
|
|
11
|
+
//
|
|
12
12
|
temperature: zod_1.z.number().min(0).max(2).default(0.4),
|
|
13
13
|
topP: zod_1.z.number().default(0.85),
|
|
14
14
|
frequencyPenalty: zod_1.z.number().default(0.0),
|
|
@@ -28,14 +28,14 @@ const ModelGroupConfigSchema = zod_1.z.object({
|
|
|
28
28
|
execute: ModelConfigSchema.default({}),
|
|
29
29
|
decision: ModelConfigSchema.default({}),
|
|
30
30
|
verify: ModelConfigSchema.default({}),
|
|
31
|
-
//
|
|
31
|
+
//
|
|
32
32
|
reflection: ModelConfigSchema.optional(),
|
|
33
33
|
analyze: ModelConfigSchema.optional(),
|
|
34
34
|
extraModels: zod_1.z.record(zod_1.z.string(), ModelConfigSchema).default({}),
|
|
35
35
|
});
|
|
36
36
|
exports.AgentConfigSchema = zod_1.z.object({
|
|
37
37
|
mode: zod_1.z.enum(['single', 'hypium', 'layered']).default('single'),
|
|
38
|
-
//
|
|
38
|
+
//
|
|
39
39
|
maxSteps: zod_1.z.number().int().positive().default(50),
|
|
40
40
|
lang: zod_1.z.enum(['zh', 'en']).default('zh'),
|
|
41
41
|
enablePreprocess: zod_1.z.boolean().default(false),
|
|
@@ -54,12 +54,13 @@ exports.AgentConfigSchema = zod_1.z.object({
|
|
|
54
54
|
defaultTask: zod_1.z.string().default(''),
|
|
55
55
|
promptVersion: zod_1.z.string().default(''),
|
|
56
56
|
maxResultRetries: zod_1.z.number().int().default(2),
|
|
57
|
-
//
|
|
57
|
+
//
|
|
58
58
|
// with action marker so LLM can see where its last click landed and self-correct.
|
|
59
59
|
includePreviousScreenshot: zod_1.z.boolean().default(true),
|
|
60
60
|
previousScreenshotCompressRatio: zod_1.z.number().default(0.7),
|
|
61
|
+
actionMarkers: zod_1.z.boolean().default(false),
|
|
61
62
|
enableCache: zod_1.z.boolean().default(true),
|
|
62
|
-
// --- New fields
|
|
63
|
+
// --- New fields
|
|
63
64
|
parseMode: zod_1.z.string().default('native'),
|
|
64
65
|
toolProvider: zod_1.z.string().default('device'),
|
|
65
66
|
promptName: zod_1.z.string().default('single_v2.0'),
|
|
@@ -73,7 +74,7 @@ exports.AgentConfigSchema = zod_1.z.object({
|
|
|
73
74
|
enableAttributionAnalysis: zod_1.z.boolean().default(false),
|
|
74
75
|
});
|
|
75
76
|
/**
|
|
76
|
-
* Agent group config
|
|
77
|
+
* Agent group config.
|
|
77
78
|
* `unified` is the default agent config; `extraAgents` are per-role overrides.
|
|
78
79
|
* Backward compat: old flat `agent: { mode: ... }` config is auto-migrated
|
|
79
80
|
* to `{ unified: { mode: ... } }` by ConfigManager.
|
|
@@ -83,7 +84,7 @@ const AgentGroupConfigSchema = zod_1.z.object({
|
|
|
83
84
|
extraAgents: zod_1.z.record(zod_1.z.string(), exports.AgentConfigSchema).default({}),
|
|
84
85
|
});
|
|
85
86
|
const LogConfigSchema = zod_1.z.object({
|
|
86
|
-
//
|
|
87
|
+
//
|
|
87
88
|
level: zod_1.z.string().default('DEBUG'),
|
|
88
89
|
deviceLogLevel: zod_1.z.string().default('info'),
|
|
89
90
|
verbose: zod_1.z.boolean().default(false),
|
|
@@ -94,7 +95,7 @@ const LogConfigSchema = zod_1.z.object({
|
|
|
94
95
|
});
|
|
95
96
|
const OutputConfigSchema = zod_1.z.object({
|
|
96
97
|
jsonOutput: zod_1.z.boolean().default(false),
|
|
97
|
-
//
|
|
98
|
+
//
|
|
98
99
|
// Preprocess null→undefined so .default() kicks in (config.yaml may have report_dir: null)
|
|
99
100
|
reportDir: zod_1.z.preprocess((v) => (v === null ? undefined : v), zod_1.z.string().default(() => {
|
|
100
101
|
const n = new Date();
|
|
@@ -112,7 +113,7 @@ const DeviceConfigSchema = zod_1.z.object({
|
|
|
112
113
|
ip: zod_1.z.string().default('127.0.0.1'),
|
|
113
114
|
port: zod_1.z.number().int().min(1).max(65535).default(8710),
|
|
114
115
|
hdcPath: zod_1.z.string().default('hdc'),
|
|
115
|
-
//
|
|
116
|
+
//
|
|
116
117
|
// true: go home + clear all recent tasks; false: skip; list: force-stop specific packages
|
|
117
118
|
resetDevice: zod_1.z.union([zod_1.z.boolean(), zod_1.z.array(zod_1.z.string())]).default(true),
|
|
118
119
|
screenAlwaysOn: zod_1.z.boolean().default(true),
|
|
@@ -147,7 +148,7 @@ const AppKnowledgeConfigSchema = zod_1.z.object({
|
|
|
147
148
|
const KnowledgeConfigSchema = zod_1.z.object({
|
|
148
149
|
apps: zod_1.z.record(zod_1.z.string(), AppKnowledgeConfigSchema).default({}),
|
|
149
150
|
});
|
|
150
|
-
// --- New optional config schemas
|
|
151
|
+
// --- New optional config schemas
|
|
151
152
|
const CompressionConfigSchema = zod_1.z.object({
|
|
152
153
|
enabled: zod_1.z.boolean().default(true),
|
|
153
154
|
maxTokens: zod_1.z.number().int().default(7000),
|
|
@@ -174,7 +175,7 @@ exports.AppConfigSchema = zod_1.z.object({
|
|
|
174
175
|
network: NetworkConfigSchema.default({}),
|
|
175
176
|
analyze: AnalyzerConfigSchema.default({}),
|
|
176
177
|
knowledge: KnowledgeConfigSchema.default({}),
|
|
177
|
-
// --- New optional top-level configs
|
|
178
|
+
// --- New optional top-level configs
|
|
178
179
|
contextCompression: CompressionConfigSchema.optional(),
|
|
179
180
|
reflection: ReflectionConfigSchema.optional(),
|
|
180
181
|
detection: DetectionConfigSchema.optional(),
|
|
@@ -145,7 +145,7 @@ function createRecordingFetch(originalFetch, recorder, source, runId) {
|
|
|
145
145
|
return async function recordingFetch(input, init) {
|
|
146
146
|
const startTime = Date.now();
|
|
147
147
|
const parsed = parseRequestBody(init);
|
|
148
|
-
// 与
|
|
148
|
+
// 与 transport.py 对齐:dashboard create_llm_client 无 step 上下文,硬编码 null
|
|
149
149
|
const stepNumber = null;
|
|
150
150
|
try {
|
|
151
151
|
const response = await originalFetch(input, init);
|
|
@@ -7,7 +7,7 @@ var RecordingSource;
|
|
|
7
7
|
RecordingSource["HYPIUM_AGENT"] = "hypium_agent";
|
|
8
8
|
RecordingSource["DEBUG_SESSION"] = "debug_session";
|
|
9
9
|
RecordingSource["ANALYZER"] = "analyzer";
|
|
10
|
-
//
|
|
10
|
+
//
|
|
11
11
|
RecordingSource["ANALYZE_SERVICE"] = "analyze_service";
|
|
12
12
|
RecordingSource["CASE_SERVICE"] = "case_service";
|
|
13
13
|
})(RecordingSource || (exports.RecordingSource = RecordingSource = {}));
|
|
@@ -7,11 +7,11 @@ export declare function compressImageToBase64(imagePath: string, maxPixels?: num
|
|
|
7
7
|
export declare function compressBase64Image(base64Data: string, maxPixels?: number, quality?: number): Promise<string>;
|
|
8
8
|
/**
|
|
9
9
|
* Decode a base64 image (with optional `data:` prefix) into a Buffer.
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
11
|
*/
|
|
12
12
|
export declare function decodeBase64Image(base64Data: string): Promise<Buffer>;
|
|
13
13
|
/**
|
|
14
|
-
* Encode a Buffer to a base64 string.
|
|
14
|
+
* Encode a Buffer to a base64 string.
|
|
15
15
|
* image_helper.encode_image_to_base64 (Node buffers encode losslessly; fmt/quality
|
|
16
16
|
* only apply when re-encoding via sharp, which callers can do via compressBase64Image).
|
|
17
17
|
*/
|
|
@@ -107,7 +107,7 @@ async function compressBase64Image(base64Data, maxPixels, quality) {
|
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Decode a base64 image (with optional `data:` prefix) into a Buffer.
|
|
110
|
-
*
|
|
110
|
+
*
|
|
111
111
|
*/
|
|
112
112
|
async function decodeBase64Image(base64Data) {
|
|
113
113
|
if (!base64Data)
|
|
@@ -119,7 +119,7 @@ async function decodeBase64Image(base64Data) {
|
|
|
119
119
|
return Buffer.from(raw, 'base64');
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
|
-
* Encode a Buffer to a base64 string.
|
|
122
|
+
* Encode a Buffer to a base64 string.
|
|
123
123
|
* image_helper.encode_image_to_base64 (Node buffers encode losslessly; fmt/quality
|
|
124
124
|
* only apply when re-encoding via sharp, which callers can do via compressBase64Image).
|
|
125
125
|
*/
|
|
@@ -3,7 +3,7 @@ export declare class CacheTransport {
|
|
|
3
3
|
private cacheDir;
|
|
4
4
|
private cache;
|
|
5
5
|
constructor(enabled?: boolean, cacheDir?: string);
|
|
6
|
-
/** Exposed for prompt-cache injection gating
|
|
6
|
+
/** Exposed for prompt-cache injection gating. */
|
|
7
7
|
isEnabled(): boolean;
|
|
8
8
|
getCachedResponse(requestKey: string): Promise<string | null>;
|
|
9
9
|
setCachedResponse(requestKey: string, response: string): Promise<void>;
|
|
@@ -45,7 +45,7 @@ class CacheTransport {
|
|
|
45
45
|
this.enabled = enabled ?? true;
|
|
46
46
|
this.cacheDir = cacheDir ?? path.join(process.cwd(), '.llm_cache');
|
|
47
47
|
}
|
|
48
|
-
/** Exposed for prompt-cache injection gating
|
|
48
|
+
/** Exposed for prompt-cache injection gating. */
|
|
49
49
|
isEnabled() {
|
|
50
50
|
return this.enabled;
|
|
51
51
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DashScope
|
|
2
|
+
* DashScope 上下文缓存注入器(
|
|
3
3
|
*
|
|
4
4
|
* 在 HTTP 请求发出前,在 system message 上添加 `cache_control: {"type": "ephemeral"}` 标记,
|
|
5
5
|
* 使 DashScope 复用前缀 token(节省 system prompt 重复计费)。
|
|
@@ -46,7 +46,7 @@ export declare function supportsCacheControl(baseUrl: string, modelName: string)
|
|
|
46
46
|
* @param body 请求体(包含 messages 数组)
|
|
47
47
|
* @param baseUrl LLM API 基础 URL
|
|
48
48
|
* @param modelName 模型名
|
|
49
|
-
* @param enabled 是否启用(受 agent.unified.enableCache
|
|
49
|
+
* @param enabled 是否启用(受 agent.unified.enableCache 控制,
|
|
50
50
|
* @returns True 表示修改了 body(调用方需要重新序列化),False 表示不需要缓存
|
|
51
51
|
*/
|
|
52
52
|
export declare function injectPromptCache(body: RequestBodyLike, baseUrl: string, modelName: string, enabled: boolean): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* DashScope
|
|
3
|
+
* DashScope 上下文缓存注入器(
|
|
4
4
|
*
|
|
5
5
|
* 在 HTTP 请求发出前,在 system message 上添加 `cache_control: {"type": "ephemeral"}` 标记,
|
|
6
6
|
* 使 DashScope 复用前缀 token(节省 system prompt 重复计费)。
|
|
@@ -98,7 +98,7 @@ function supportsCacheControl(baseUrl, modelName) {
|
|
|
98
98
|
* @param body 请求体(包含 messages 数组)
|
|
99
99
|
* @param baseUrl LLM API 基础 URL
|
|
100
100
|
* @param modelName 模型名
|
|
101
|
-
* @param enabled 是否启用(受 agent.unified.enableCache
|
|
101
|
+
* @param enabled 是否启用(受 agent.unified.enableCache 控制,
|
|
102
102
|
* @returns True 表示修改了 body(调用方需要重新序列化),False 表示不需要缓存
|
|
103
103
|
*/
|
|
104
104
|
function injectPromptCache(body, baseUrl, modelName, enabled) {
|
|
@@ -120,7 +120,7 @@ class LLMCaller {
|
|
|
120
120
|
const body = JSON.parse(init.body);
|
|
121
121
|
Object.assign(body, extraBody);
|
|
122
122
|
// DashScope 服务端 prompt cache:在 system message 上注入 cache_control,
|
|
123
|
-
//
|
|
123
|
+
// 跨步骤复用稳定前缀(
|
|
124
124
|
try {
|
|
125
125
|
if ((0, prompt_cache_1.injectPromptCache)(body, modelConfig.baseUrl, modelConfig.name, this.cacheTransport.isEnabled())) {
|
|
126
126
|
logger_1.logger.debug(`LLMCaller: injected cache_control (model=${modelConfig.name})`);
|
|
@@ -242,8 +242,6 @@ class LLMCaller {
|
|
|
242
242
|
const messages = this.buildMessages(opts);
|
|
243
243
|
const tokenType = (0, token_usage_1.resolveTokenType)(opts.modelConfig.baseUrl);
|
|
244
244
|
logger_1.logger.debug(`LLM call() input → model=${opts.modelConfig.name} messages=${messages.length}`);
|
|
245
|
-
if (opts.systemPrompt)
|
|
246
|
-
logger_1.logger.debug(`LLM call() system prompt: ${opts.systemPrompt}`);
|
|
247
245
|
for (const m of messages) {
|
|
248
246
|
const content = typeof m.content === 'string'
|
|
249
247
|
? m.content
|
|
@@ -383,8 +381,11 @@ class LLMCaller {
|
|
|
383
381
|
if (m.role === 'user') {
|
|
384
382
|
logger_1.logger.info(`LLM callWithMessages() message [user]: ${content}`);
|
|
385
383
|
}
|
|
384
|
+
else if (m.role === 'system') {
|
|
385
|
+
// Skip system prompt logging (too verbose, printed once at startup)
|
|
386
|
+
}
|
|
386
387
|
else {
|
|
387
|
-
logger_1.logger.debug(`LLM callWithMessages() message [${m.role}]: ${
|
|
388
|
+
logger_1.logger.debug(`LLM callWithMessages() message [${m.role}]: ${content}`);
|
|
388
389
|
}
|
|
389
390
|
}
|
|
390
391
|
if (opts.tools)
|
package/dist/common/utils.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* General utility functions
|
|
2
|
+
* General utility functions
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Sanitize a string into a safe filename (Windows-compatible).
|
|
6
6
|
*
|
|
7
|
-
* Mirrors
|
|
7
|
+
* Mirrors `sanitize_filename`: replaces `/ \ : * ? " < > |` with `_`,
|
|
8
8
|
* drops control chars, strips leading/trailing dots and spaces, collapses
|
|
9
9
|
* repeated underscores, and truncates to `maxLength`.
|
|
10
10
|
*/
|
|
@@ -12,7 +12,7 @@ export declare function sanitizeFilename(name: string, maxLength?: number): stri
|
|
|
12
12
|
/**
|
|
13
13
|
* Inject `enable_thinking` into the LLM request `extra_body`.
|
|
14
14
|
*
|
|
15
|
-
* Mirrors
|
|
15
|
+
* Mirrors `apply_thinking_config`. Tri-state: `null` = skip (use model
|
|
16
16
|
* default), `true`/`false` = explicit value, written into
|
|
17
17
|
* `chat_template_kwargs.enable_thinking` (vLLM format). Mutates and returns
|
|
18
18
|
* `extraBody` in place.
|
|
@@ -20,14 +20,14 @@ export declare function sanitizeFilename(name: string, maxLength?: number): stri
|
|
|
20
20
|
export declare function applyThinkingConfig(extraBody: Record<string, unknown>, enableThinking: boolean | null): Record<string, unknown>;
|
|
21
21
|
/**
|
|
22
22
|
* Normalize a single coordinate: keep if already in [0,1], else divide by 1000
|
|
23
|
-
* (per-mille → 0-1). Mirrors
|
|
23
|
+
* (per-mille → 0-1). Mirrors `normalize_coord`.
|
|
24
24
|
*/
|
|
25
25
|
export declare function normalizeCoord(coord: number): number;
|
|
26
26
|
/**
|
|
27
27
|
* Coordinate defense layer: detect per-mille (0-1000) coordinates and
|
|
28
28
|
* selectively divide >1 values by 1000 to normalize to the 0-1 range.
|
|
29
29
|
*
|
|
30
|
-
* Mirrors
|
|
30
|
+
* Mirrors `normalize_tool_coordinates`. Covers both combine format
|
|
31
31
|
* (`pos`/`start`/`end` as [x,y]) and split format (`x`/`y`,
|
|
32
32
|
* `start_x`/`start_y`, `end_x`/`end_y`). Only values >1 are converted; values
|
|
33
33
|
* already in [0,1] are preserved (handles mixed output like [0.85, 780]).
|
package/dist/common/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* General utility functions
|
|
3
|
+
* General utility functions
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.sanitizeFilename = sanitizeFilename;
|
|
@@ -13,7 +13,7 @@ const INVALID_FILENAME_CHARS = '/\\:*?"<>|';
|
|
|
13
13
|
/**
|
|
14
14
|
* Sanitize a string into a safe filename (Windows-compatible).
|
|
15
15
|
*
|
|
16
|
-
* Mirrors
|
|
16
|
+
* Mirrors `sanitize_filename`: replaces `/ \ : * ? " < > |` with `_`,
|
|
17
17
|
* drops control chars, strips leading/trailing dots and spaces, collapses
|
|
18
18
|
* repeated underscores, and truncates to `maxLength`.
|
|
19
19
|
*/
|
|
@@ -38,7 +38,7 @@ function sanitizeFilename(name, maxLength = 50) {
|
|
|
38
38
|
/**
|
|
39
39
|
* Inject `enable_thinking` into the LLM request `extra_body`.
|
|
40
40
|
*
|
|
41
|
-
* Mirrors
|
|
41
|
+
* Mirrors `apply_thinking_config`. Tri-state: `null` = skip (use model
|
|
42
42
|
* default), `true`/`false` = explicit value, written into
|
|
43
43
|
* `chat_template_kwargs.enable_thinking` (vLLM format). Mutates and returns
|
|
44
44
|
* `extraBody` in place.
|
|
@@ -57,7 +57,7 @@ function applyThinkingConfig(extraBody, enableThinking) {
|
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Normalize a single coordinate: keep if already in [0,1], else divide by 1000
|
|
60
|
-
* (per-mille → 0-1). Mirrors
|
|
60
|
+
* (per-mille → 0-1). Mirrors `normalize_coord`.
|
|
61
61
|
*/
|
|
62
62
|
function normalizeCoord(coord) {
|
|
63
63
|
if (coord >= 0 && coord <= 1)
|
|
@@ -70,7 +70,7 @@ const _COORD_TOOLS_SWIPE = new Set(['swipe', 'drag']);
|
|
|
70
70
|
* Coordinate defense layer: detect per-mille (0-1000) coordinates and
|
|
71
71
|
* selectively divide >1 values by 1000 to normalize to the 0-1 range.
|
|
72
72
|
*
|
|
73
|
-
* Mirrors
|
|
73
|
+
* Mirrors `normalize_tool_coordinates`. Covers both combine format
|
|
74
74
|
* (`pos`/`start`/`end` as [x,y]) and split format (`x`/`y`,
|
|
75
75
|
* `start_x`/`start_y`, `end_x`/`end_y`). Only values >1 are converted; values
|
|
76
76
|
* already in [0,1] are preserved (handles mixed output like [0.85, 780]).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Global agent registry
|
|
2
|
+
* Global agent registry.
|
|
3
3
|
*
|
|
4
4
|
* Singleton for managing cross-module shared state: executor agent, tool
|
|
5
5
|
* manager (adapter), report generator, last click info, and generic key-value
|
|
@@ -26,6 +26,8 @@ declare class AgentRegistryImpl {
|
|
|
26
26
|
setLastClickInfo(info: Record<string, unknown> | null): void;
|
|
27
27
|
getLastClickInfo(): Record<string, unknown> | null;
|
|
28
28
|
clearLastClickInfo(): void;
|
|
29
|
+
setAppConfig(config: unknown): void;
|
|
30
|
+
getAppConfig<T = unknown>(): T | null;
|
|
29
31
|
isInitialized(): boolean;
|
|
30
32
|
clear(): void;
|
|
31
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Global agent registry
|
|
3
|
+
* Global agent registry.
|
|
4
4
|
*
|
|
5
5
|
* Singleton for managing cross-module shared state: executor agent, tool
|
|
6
6
|
* manager (adapter), report generator, last click info, and generic key-value
|
|
@@ -20,7 +20,7 @@ class AgentRegistryImpl {
|
|
|
20
20
|
}
|
|
21
21
|
return AgentRegistryImpl.instance;
|
|
22
22
|
}
|
|
23
|
-
// ---- Generic set/get
|
|
23
|
+
// ---- Generic set/get ----
|
|
24
24
|
set(key, value) {
|
|
25
25
|
this._state.set(key, value);
|
|
26
26
|
this._initialized = true;
|
|
@@ -38,7 +38,7 @@ class AgentRegistryImpl {
|
|
|
38
38
|
getExecutorAgent() {
|
|
39
39
|
return this.get('executor_agent', null);
|
|
40
40
|
}
|
|
41
|
-
// ---- Tool manager / adapter
|
|
41
|
+
// ---- Tool manager / adapter ----
|
|
42
42
|
setToolManager(adapter) {
|
|
43
43
|
this.set('tool_manager', adapter);
|
|
44
44
|
logger_1.logger.debug('[AgentRegistry] tool_manager (adapter) registered');
|
|
@@ -46,14 +46,14 @@ class AgentRegistryImpl {
|
|
|
46
46
|
getToolManager() {
|
|
47
47
|
return this.get('tool_manager', null);
|
|
48
48
|
}
|
|
49
|
-
// ---- Report generator
|
|
49
|
+
// ---- Report generator ----
|
|
50
50
|
setReportGenerator(rg) {
|
|
51
51
|
this.set('report_generator', rg);
|
|
52
52
|
}
|
|
53
53
|
getReportGenerator() {
|
|
54
54
|
return this.get('report_generator', null);
|
|
55
55
|
}
|
|
56
|
-
// ---- Last click info
|
|
56
|
+
// ---- Last click info ----
|
|
57
57
|
setLastClickInfo(info) {
|
|
58
58
|
this.set('last_click_info', info);
|
|
59
59
|
}
|
|
@@ -63,6 +63,13 @@ class AgentRegistryImpl {
|
|
|
63
63
|
clearLastClickInfo() {
|
|
64
64
|
this.clearKey('last_click_info');
|
|
65
65
|
}
|
|
66
|
+
// ---- App config (for tools that need model config, e.g. judge) ----
|
|
67
|
+
setAppConfig(config) {
|
|
68
|
+
this.set('app_config', config);
|
|
69
|
+
}
|
|
70
|
+
getAppConfig() {
|
|
71
|
+
return this.get('app_config', null);
|
|
72
|
+
}
|
|
66
73
|
// ---- Status / cleanup ----
|
|
67
74
|
isInitialized() {
|
|
68
75
|
return this._initialized;
|
|
@@ -42,9 +42,11 @@ const DEFAULT_MCP_TOOLS = [
|
|
|
42
42
|
{ name: 'back', description: 'Press back key', parameters: {} },
|
|
43
43
|
{ name: 'go_home', description: 'Go to home screen', parameters: {} },
|
|
44
44
|
{ name: 'start_app', description: 'Start an application by name', parameters: { app_name: 'string' } },
|
|
45
|
+
{ name: 'start_app_by_deep_link', description: 'Start an application via deeplink URI (e.g. myapp://page1)', parameters: { uri: 'string', bundle_name: 'string', ability_name: 'string' } },
|
|
45
46
|
{ name: 'type_text', description: 'Type text into the focused input', parameters: { text: 'string' } },
|
|
46
47
|
{ name: 'chat', description: 'Send a sub-task instruction to the executor (describe what to do in natural language, e.g. click a button, swipe, input text). The executor will look at the screen and perform the actual operation', parameters: { message: 'string' } },
|
|
47
48
|
{ name: 'finish', description: 'Finish the task with a result message', parameters: { message: 'string' } },
|
|
49
|
+
{ name: 'judge', description: 'Judge task execution conclusion: returns passed/should_continue/reason', parameters: { conclusion: 'string' } },
|
|
48
50
|
];
|
|
49
51
|
function collectAllTools(adapter) {
|
|
50
52
|
// Try to introspect the adapter's real tool set first
|
|
@@ -126,7 +128,7 @@ function tryParseToolCall(jsonText, fallback) {
|
|
|
126
128
|
const name = parsed.name ?? parsed.action ?? '';
|
|
127
129
|
const argumentsObj = parsed.arguments ?? {};
|
|
128
130
|
const reasoning = parsed.reasoning ?? undefined;
|
|
129
|
-
if (name === 'finish' || name === 'answer' || name === 'terminate' || !name) {
|
|
131
|
+
if (name === 'finish' || name === 'answer' || name === 'terminate' || name === 'task_complete' || name === 'finish_task' || name === 'done' || !name) {
|
|
130
132
|
return { isFinish: true, message: argumentsObj.message ?? fallback, reasoning };
|
|
131
133
|
}
|
|
132
134
|
return { toolCall: { name, arguments: argumentsObj }, isFinish: false, reasoning };
|
|
@@ -105,6 +105,7 @@ class GeneralAgent extends base_agent_1.BaseAgent {
|
|
|
105
105
|
const textContent = `** Screen Info **\n\n${screenInfo}`;
|
|
106
106
|
this._context.push(message_builder_1.MessageBuilder.createUserMessage(textContent, screenshot.base64Data));
|
|
107
107
|
}
|
|
108
|
+
this.manageHistoryImages(this.agentConfig.maxHistoryImage);
|
|
108
109
|
let thinking = '';
|
|
109
110
|
let content = '';
|
|
110
111
|
let rawContent = '';
|
|
@@ -141,7 +142,6 @@ class GeneralAgent extends base_agent_1.BaseAgent {
|
|
|
141
142
|
stepNumber: this._stepCount,
|
|
142
143
|
}));
|
|
143
144
|
}
|
|
144
|
-
this.manageHistoryImages(this.agentConfig.maxHistoryImage);
|
|
145
145
|
this._context.push(message_builder_1.MessageBuilder.createAssistantMessage(rawContent));
|
|
146
146
|
let result;
|
|
147
147
|
try {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const MCP_SYSTEM_PROMPT_BASIC = "You are a GUI operation agent. You will receive a task description, an action history, a screen screenshot, and a set of tools used for device operations. You need to decide the next action to take to complete the task based on the current interface state. Please operate based on the current interface and the given task, do not speculate about user intent.\n\n# Output Format Requirements\n- Must include a thinking section that first summarizes the history of operations, especially repeatedly retried operations, the decision reason for the current operation step, and the operation description.\n- The thinking section should summarize in one sentence.\n\n# Notes\n## Decide based on screenshot and history\n
|
|
1
|
+
export declare const MCP_SYSTEM_PROMPT_BASIC = "You are a GUI operation agent. You will receive a task description, an action history, a screen screenshot, and a set of tools used for device operations. You need to decide the next action to take to complete the task based on the current interface state. Please operate based on the current interface and the given task, do not speculate about user intent.\n\n# Output Format Requirements\n- Must include a thinking section that first summarizes the history of operations, especially repeatedly retried operations, the decision reason for the current operation step, and the operation description.\n- The thinking section should summarize in one sentence.\n\n# Notes\n## Decide based on screenshot and history\n - Please analyze the current interface content based on the provided screenshot and user instruction, and select the most appropriate operation from the tools. Your judgment must be based on visual recognition of the controls on the interface.\n## Retry principle\n - Please pay attention to the operation history; the same operation sequence should be retried at most 2 times. If the operation does not achieve the expected result, terminate execution directly and report the failure reason.\n## Execution conditions\n - Please confirm whether the execution conditions are met before execution. If the execution conditions are not met, terminate execution directly and report the failure reason.\n## Target description\n - Please confirm the operations required by the target description in the task list, and only complete the operations specified in the target description.\n## Expected result\n - Please confirm the expected result before execution. If the expected result has been achieved, report completion directly.\n## Swipe description\n - Swipe from left to right -> right\n - Swipe from top to bottom -> down\n - Swipe from bottom to top -> up\n - Swipe from right to left -> left\n## Coordinate description\n - The coordinate format is (x, y), the coordinate range is (0.000, 1.000), do not exceed the coordinate range.\n\n## Supported MCP Tools\n";
|
|
2
2
|
export declare const MCP_SYSTEM_PROMPT_ALL: string;
|
|
3
3
|
export declare const MCP_SYSTEM_PROMPT: string;
|
|
@@ -23,22 +23,22 @@ exports.MCP_SYSTEM_PROMPT_BASIC = `You are a GUI operation agent. You will recei
|
|
|
23
23
|
|
|
24
24
|
# Notes
|
|
25
25
|
## Decide based on screenshot and history
|
|
26
|
-
|
|
26
|
+
- Please analyze the current interface content based on the provided screenshot and user instruction, and select the most appropriate operation from the tools. Your judgment must be based on visual recognition of the controls on the interface.
|
|
27
27
|
## Retry principle
|
|
28
|
-
|
|
28
|
+
- Please pay attention to the operation history; the same operation sequence should be retried at most 2 times. If the operation does not achieve the expected result, terminate execution directly and report the failure reason.
|
|
29
29
|
## Execution conditions
|
|
30
|
-
|
|
30
|
+
- Please confirm whether the execution conditions are met before execution. If the execution conditions are not met, terminate execution directly and report the failure reason.
|
|
31
31
|
## Target description
|
|
32
|
-
|
|
32
|
+
- Please confirm the operations required by the target description in the task list, and only complete the operations specified in the target description.
|
|
33
33
|
## Expected result
|
|
34
|
-
|
|
34
|
+
- Please confirm the expected result before execution. If the expected result has been achieved, report completion directly.
|
|
35
35
|
## Swipe description
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
- Swipe from left to right -> right
|
|
37
|
+
- Swipe from top to bottom -> down
|
|
38
|
+
- Swipe from bottom to top -> up
|
|
39
|
+
- Swipe from right to left -> left
|
|
40
40
|
## Coordinate description
|
|
41
|
-
|
|
41
|
+
- The coordinate format is (x, y), the coordinate range is (0.000, 1.000), do not exceed the coordinate range.
|
|
42
42
|
|
|
43
43
|
## Supported MCP Tools
|
|
44
44
|
`;
|
|
@@ -91,29 +91,29 @@ ${'<thinking>\n' +
|
|
|
91
91
|
|
|
92
92
|
# Notes
|
|
93
93
|
## Decide based on screenshot and history
|
|
94
|
-
|
|
94
|
+
- Please analyze the current interface content based on the provided screenshot and user instruction, and select the most appropriate operation from the tools. Your judgment must be based on visual recognition of the controls on the interface.
|
|
95
95
|
## Retry principle
|
|
96
|
-
|
|
96
|
+
- Please pay attention to the operation history; the same operation sequence should be retried at most 2 times. If the operation does not achieve the expected result, terminate execution directly and report the failure reason.
|
|
97
97
|
## Execution conditions
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
- Please confirm whether the execution conditions are met before execution. If the execution conditions are not met, terminate execution directly and report the failure reason.
|
|
99
|
+
### Target availability check (Critical)
|
|
100
|
+
Core principle: visible does not mean available. Before clicking the target element, please check whether there is a popup on the page and whether the element is occluded by other UI elements.
|
|
101
|
+
- Rule: if the target is occluded or there is a popup on the page, it is forbidden to click the target directly.
|
|
102
|
+
- Processing flow:
|
|
103
|
+
1. Handle the occluding object first: click the back key, X button, allow/deny button of the popup, or swipe to close the popup.
|
|
104
|
+
2. Wait for it to take effect: after handling the occluding object, wait 0.5 seconds to confirm the target is displayed.
|
|
105
|
+
3. Then execute the original operation: after confirming the target is visible, execute the original click operation.
|
|
106
106
|
## Target description
|
|
107
|
-
|
|
107
|
+
- Please confirm the operations required by the target description in the task list, and only complete the operations specified in the target description.
|
|
108
108
|
## Expected result
|
|
109
|
-
|
|
109
|
+
- Please confirm the expected result before execution. If the expected result has been achieved, report completion directly.
|
|
110
110
|
## Swipe description
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
- Swipe from left to right -> right, the Y coordinate should remain unchanged.
|
|
112
|
+
- Swipe from top to bottom -> down, the X coordinate should remain unchanged.
|
|
113
|
+
- Swipe from bottom to top -> up, the X coordinate should remain unchanged.
|
|
114
|
+
- Swipe from right to left -> left, the Y coordinate should remain unchanged.
|
|
115
115
|
## Coordinate description
|
|
116
|
-
|
|
116
|
+
- The coordinate format is (x, y), the coordinate range is (0.000, 1.000), do not exceed the coordinate range.
|
|
117
117
|
## Operation guide
|
|
118
118
|
- Special characters such as quotes and newlines in text input must be escaped.
|
|
119
119
|
- Only return one action at a time, do not try to batch operations.
|
|
@@ -125,13 +125,13 @@ The thinking section should include:
|
|
|
125
125
|
2. Analysis: identify the position and characteristics of the target element only from the current image.
|
|
126
126
|
3. Usability check: does the target element exist? Is it covered by a popup, floating window, or occlusion layer?
|
|
127
127
|
4. Localization: determine the target area and coordinate position according to the superior instruction.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
- Understand the superior instruction: which area/element is specified by the superior instruction.
|
|
129
|
+
- Locate the target area: find the area/element specified by the superior in the screenshot.
|
|
130
|
+
- Locate within that area: the start and end points should be within that area.
|
|
131
|
+
- Swipe localization examples:
|
|
132
|
+
- Instruction "swipe the top tab bar" -> locate the top tab bar -> swipe within the tab bar area.
|
|
133
|
+
- Instruction "swipe the page to load more" -> locate the content area -> swipe within the content area.
|
|
134
|
+
- Instruction "swipe this card" -> locate the card -> swipe within the card.
|
|
135
135
|
5. Execution: return the execution instruction.
|
|
136
136
|
|
|
137
137
|
### Common mistakes to avoid
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SYSTEM_PROMPT = "You are the execution-layer Agent, responsible for strictly executing instructions from the superior (decision layer).\n\n## Core Positioning (Highest Priority)\n\nYou are the execution layer, not the decision layer.\n- Your responsibility: execute instructions from the superior, do not judge whether the instruction is meaningful.\n- Your superior (Planner): responsible for decisions, judging whether the task is complete.\n- Your role: tool executor, not task decision-maker.\n\n---\n\n## Mandatory Execution Rules (Must Follow)\n\nMust execute:\n- Receive an instruction from the superior then must execute, do not judge whether it is meaningful.\n- The superior asks to swipe then must swipe, do not judge whether there is content.\n- The superior asks to click then must click, do not judge whether it is correct.\n\nForbidden autonomous behaviors:\n- Forbidden to autonomously terminate (task completion is judged by the superior).\n- Forbidden to autonomously go back (going back is decided by the superior).\n- Forbidden to autonomously explore (exploration is planned by the superior).\n- Forbidden to judge whether an operation is meaningful.\n- Forbidden to think about whether you should go back to the previous level.\n- Forbidden to think about whether the task is complete.\n\n---\n\n## Output Format\n\nEach operation must contain two parts:\n1. Thinking process: describe observation and localization inside thinking tags.\n2. Action instruction: return a JSON function call inside a json code fence.\n\nExample:\n\n<thinking>\n**Observation**: The current screen shows a short-video playback interface, the superior asks to swipe up.\n**Localization**: The superior asks to swipe in the middle area of the screen, the coordinate area is about [0.3-0.7, 0.4-0.6].\n**Execution**: Swipe from bottom to top in the middle of the screen.\n</thinking>\n```json\n{\"name\": \"swipe\", \"arguments\": {\"direction\": \"up\", \"coordinate\": [0.5, 0.5]}}\n```\n\n---\n\n## Action Space (Strictly Follow)\n\n### Basic Operations\n- Click: {\"name\": \"click\", \"arguments\": {\"coordinate\": [x, y]}}\n
|
|
1
|
+
export declare const SYSTEM_PROMPT = "You are the execution-layer Agent, responsible for strictly executing instructions from the superior (decision layer).\n\n## Core Positioning (Highest Priority)\n\nYou are the execution layer, not the decision layer.\n- Your responsibility: execute instructions from the superior, do not judge whether the instruction is meaningful.\n- Your superior (Planner): responsible for decisions, judging whether the task is complete.\n- Your role: tool executor, not task decision-maker.\n\n---\n\n## Mandatory Execution Rules (Must Follow)\n\nMust execute:\n- Receive an instruction from the superior then must execute, do not judge whether it is meaningful.\n- The superior asks to swipe then must swipe, do not judge whether there is content.\n- The superior asks to click then must click, do not judge whether it is correct.\n\nForbidden autonomous behaviors:\n- Forbidden to autonomously terminate (task completion is judged by the superior).\n- Forbidden to autonomously go back (going back is decided by the superior).\n- Forbidden to autonomously explore (exploration is planned by the superior).\n- Forbidden to judge whether an operation is meaningful.\n- Forbidden to think about whether you should go back to the previous level.\n- Forbidden to think about whether the task is complete.\n\n---\n\n## Output Format\n\nEach operation must contain two parts:\n1. Thinking process: describe observation and localization inside thinking tags.\n2. Action instruction: return a JSON function call inside a json code fence.\n\nExample:\n\n<thinking>\n**Observation**: The current screen shows a short-video playback interface, the superior asks to swipe up.\n**Localization**: The superior asks to swipe in the middle area of the screen, the coordinate area is about [0.3-0.7, 0.4-0.6].\n**Execution**: Swipe from bottom to top in the middle of the screen.\n</thinking>\n```json\n{\"name\": \"swipe\", \"arguments\": {\"direction\": \"up\", \"coordinate\": [0.5, 0.5]}}\n```\n\n---\n\n## Action Space (Strictly Follow)\n\n### Basic Operations\n- Click: {\"name\": \"click\", \"arguments\": {\"coordinate\": [x, y]}}\n Used to click the UI element specified by the superior.\n\n- Long press: {\"name\": \"long_press\", \"arguments\": {\"coordinate\": [x, y]}}\n Used to long-press the element specified by the superior.\n\n- Type text: {\"name\": \"type\", \"arguments\": {\"text\": \"text to input\"}}\n You must click the input box to focus it first, then use this action to input text.\n\n### Swipe Operations\n- Swipe: {\"name\": \"swipe\", \"arguments\": {\"direction\": \"up|down|left|right\", \"coordinate\": [x, y]}}\n direction options: up (swipe up), down (swipe down), left (swipe left), right (swipe right).\n coordinate: specifies the swipe start point (the position specified by the superior).\n\n- Drag: {\"name\": \"drag\", \"arguments\": {\"start_coordinate\": [x1, y1], \"end_coordinate\": [x2, y2]}}\n Used to drag an element to a new position (the start and end points specified by the superior).\n\n### System Operations\n- Open app: {\"name\": \"open\", \"arguments\": {\"text\": \"app name\"}}\n Used to open the app specified by the superior.\n\n### Wait Operations\n- Wait: {\"name\": \"wait\", \"arguments\": {}}\n Used to wait for the page to load (only used when the superior instruction includes waiting).\n\n---\n\n## Coordinate System\n- Range: both x and y are between [0.000, 1.000].\n- Origin: (0.000, 0.000) is the top-left corner of the screen.\n- Boundary: (1.000, 1.000) is the bottom-right corner of the screen.\n- Precision: coordinates are normalized and will be automatically mapped to the actual screen resolution.\n\n---\n\n## Thinking Process Template (Strictly Follow)\n\nOnly three parts:\n1. Observation: What does the current screen show? What is the operation target requested by the superior?\n2. Localization: Where is the element the superior asks to operate on? What are the coordinates?\n3. Execution: Return the execution instruction.\n\nForbidden to include:\n- Whether this operation is meaningful.\n- Whether you should go back to the previous level.\n- Whether the task is complete.\n- What to do when the target element cannot be found.\n- Slide to view when the page content is not fully displayed.\n\n---\n\n## Mandatory Principles Reiteration (Must Strictly Follow)\n\n- Strict execution: receive the instruction and must execute, do not judge the meaning.\n- No autonomy: no terminate, no autonomous back, no autonomous explore.\n- Observe-Locate-Execute: the thinking process only includes the three steps of observation, localization, and execution.";
|
|
@@ -52,29 +52,29 @@ ${'<thinking>\n' +
|
|
|
52
52
|
|
|
53
53
|
### Basic Operations
|
|
54
54
|
- Click: {"name": "click", "arguments": {"coordinate": [x, y]}}
|
|
55
|
-
|
|
55
|
+
Used to click the UI element specified by the superior.
|
|
56
56
|
|
|
57
57
|
- Long press: {"name": "long_press", "arguments": {"coordinate": [x, y]}}
|
|
58
|
-
|
|
58
|
+
Used to long-press the element specified by the superior.
|
|
59
59
|
|
|
60
60
|
- Type text: {"name": "type", "arguments": {"text": "text to input"}}
|
|
61
|
-
|
|
61
|
+
You must click the input box to focus it first, then use this action to input text.
|
|
62
62
|
|
|
63
63
|
### Swipe Operations
|
|
64
64
|
- Swipe: {"name": "swipe", "arguments": {"direction": "up|down|left|right", "coordinate": [x, y]}}
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
direction options: up (swipe up), down (swipe down), left (swipe left), right (swipe right).
|
|
66
|
+
coordinate: specifies the swipe start point (the position specified by the superior).
|
|
67
67
|
|
|
68
68
|
- Drag: {"name": "drag", "arguments": {"start_coordinate": [x1, y1], "end_coordinate": [x2, y2]}}
|
|
69
|
-
|
|
69
|
+
Used to drag an element to a new position (the start and end points specified by the superior).
|
|
70
70
|
|
|
71
71
|
### System Operations
|
|
72
72
|
- Open app: {"name": "open", "arguments": {"text": "app name"}}
|
|
73
|
-
|
|
73
|
+
Used to open the app specified by the superior.
|
|
74
74
|
|
|
75
75
|
### Wait Operations
|
|
76
76
|
- Wait: {"name": "wait", "arguments": {}}
|
|
77
|
-
|
|
77
|
+
Used to wait for the page to load (only used when the superior instruction includes waiting).
|
|
78
78
|
|
|
79
79
|
---
|
|
80
80
|
|