@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
|
@@ -46,9 +46,9 @@ class KnowledgeManagerImpl {
|
|
|
46
46
|
logger_1.logger.debug(`KnowledgeManager.addDocument: added doc length=${doc.length}`);
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
* Incremental single-doc write.
|
|
50
|
+
* Delegates to LanceDBManager.addSingle (non-destructive + jsonl fallback).
|
|
51
|
+
*/
|
|
52
52
|
writeKnowledge(doc) {
|
|
53
53
|
this.init();
|
|
54
54
|
this.ldManager.addSingle({
|
|
@@ -26,11 +26,11 @@ export declare class LanceDBManager {
|
|
|
26
26
|
insertDocuments(docs: KnowledgeDoc[]): void;
|
|
27
27
|
addDocument(doc: KnowledgeDoc): void;
|
|
28
28
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
* Incremental single-doc write.
|
|
30
|
+
* Non-destructive: appends to the in-memory store (dedup by text) without
|
|
31
|
+
* clobbering existing records. Falls back to appending a `_pending.jsonl`
|
|
32
|
+
* line when persistence fails, so records are never lost.
|
|
33
|
+
*/
|
|
34
34
|
addSingle(doc: KnowledgeDoc): void;
|
|
35
35
|
/** Append a single doc to `_pending.jsonl` (crash-safe fallback). */
|
|
36
36
|
private _writeJsonlFallback;
|
|
@@ -190,11 +190,11 @@ class LanceDBManager {
|
|
|
190
190
|
this.rebuildIndex();
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
* Incremental single-doc write.
|
|
194
|
+
* Non-destructive: appends to the in-memory store (dedup by text) without
|
|
195
|
+
* clobbering existing records. Falls back to appending a `_pending.jsonl`
|
|
196
|
+
* line when persistence fails, so records are never lost.
|
|
197
|
+
*/
|
|
198
198
|
addSingle(doc) {
|
|
199
199
|
if (!doc.text)
|
|
200
200
|
return;
|
|
@@ -237,7 +237,7 @@ class HarmonyHdcAdapter extends base_adapter_1.MCPDeviceAdapterBase {
|
|
|
237
237
|
this.screenWidth = shot.width;
|
|
238
238
|
this.screenHeight = shot.height;
|
|
239
239
|
}
|
|
240
|
-
// Fallback saveDir to config.output.rootDir/log
|
|
240
|
+
// Fallback saveDir to config.output.rootDir/log
|
|
241
241
|
const effectiveSaveDir = saveDir ?? path.join(this.configManager.getEffectiveConfig().output.rootDir, 'log');
|
|
242
242
|
let screenshotPath = null;
|
|
243
243
|
if (effectiveSaveDir && shot.base64Data) {
|
|
@@ -265,15 +265,16 @@ class HarmonyHdcAdapter extends base_adapter_1.MCPDeviceAdapterBase {
|
|
|
265
265
|
throw new common_errors_1.AgentError('DEVICE_NOT_CONNECTED', 'Adapter not connected');
|
|
266
266
|
}
|
|
267
267
|
if (!this.deviceResetDevice) {
|
|
268
|
-
|
|
268
|
+
logger_1.logger.info('[HarmonyHdcAdapter] reset skipped (resetDevice=false)');
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
271
|
try {
|
|
272
|
+
logger_1.logger.info('[HarmonyHdcAdapter] reset: go home + clear recent tasks');
|
|
272
273
|
await (0, hdc_1.home)(this.driver, 1);
|
|
273
274
|
if (Array.isArray(this.deviceResetDevice)) {
|
|
274
275
|
// list mode: force-stop specific packages instead of clearing all
|
|
275
276
|
for (const pkg of this.deviceResetDevice) {
|
|
276
|
-
logger_1.logger.info(`[
|
|
277
|
+
logger_1.logger.info(`[HarmonyHdcAdapter] force-stop: ${pkg}`);
|
|
277
278
|
await this.callTool('stop_app', { app_name: pkg });
|
|
278
279
|
}
|
|
279
280
|
}
|
|
@@ -281,9 +282,10 @@ class HarmonyHdcAdapter extends base_adapter_1.MCPDeviceAdapterBase {
|
|
|
281
282
|
// true mode: clear all recent tasks
|
|
282
283
|
await this.callTool('clear_recent_task', undefined, 15, false);
|
|
283
284
|
}
|
|
285
|
+
logger_1.logger.info('[HarmonyHdcAdapter] reset completed');
|
|
284
286
|
}
|
|
285
|
-
catch {
|
|
286
|
-
|
|
287
|
+
catch (e) {
|
|
288
|
+
logger_1.logger.warn(`[HarmonyHdcAdapter] reset failed (best-effort): ${e instanceof Error ? e.message : String(e)}`);
|
|
287
289
|
}
|
|
288
290
|
}
|
|
289
291
|
async callTool(toolName, args, _timeout, _retryOnFailure) {
|
|
@@ -375,6 +377,20 @@ class HarmonyHdcAdapter extends base_adapter_1.MCPDeviceAdapterBase {
|
|
|
375
377
|
const ok = await (0, hdc_1.launchApp)(this.driver, appName, 1);
|
|
376
378
|
return ok ? `start_app ${appName} successfully` : `start_app ${appName} failed`;
|
|
377
379
|
}
|
|
380
|
+
case 'start_app_by_deep_link': {
|
|
381
|
+
const uri = typeof a.uri === 'string' ? a.uri : '';
|
|
382
|
+
if (!uri)
|
|
383
|
+
return 'start_app_by_deep_link failed: uri is required';
|
|
384
|
+
const parts = ['aa', 'start', '-U', uri];
|
|
385
|
+
if (a.bundle_name)
|
|
386
|
+
parts.push('-b', String(a.bundle_name));
|
|
387
|
+
if (a.ability_name)
|
|
388
|
+
parts.push('-a', String(a.ability_name));
|
|
389
|
+
const cmd = parts.join(' ');
|
|
390
|
+
const out = await this.driver.shell(cmd);
|
|
391
|
+
const success = !out.toLowerCase().includes('error') && !out.toLowerCase().includes('fail');
|
|
392
|
+
return success ? `start_app_by_deep_link ${uri} successfully` : `start_app_by_deep_link ${uri} failed: ${out}`;
|
|
393
|
+
}
|
|
378
394
|
case 'stop_app': {
|
|
379
395
|
const appName = typeof a.app_name === 'string' ? a.app_name : '';
|
|
380
396
|
const bundle = (0, hdc_1.getPackageName)(appName) ?? appName;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/** A registered async tool function. */
|
|
9
9
|
export type ToolFunction = (...args: any[]) => Promise<string>;
|
|
10
|
-
/** Metadata for a registered tool
|
|
10
|
+
/** Metadata for a registered tool. */
|
|
11
11
|
export interface ToolEntry {
|
|
12
12
|
name: string;
|
|
13
13
|
description: string;
|
|
@@ -20,7 +20,7 @@ export declare const TOOL_REGISTRY: Record<string, ToolFunction>;
|
|
|
20
20
|
export declare function addToBlacklist(...names: string[]): void;
|
|
21
21
|
/**
|
|
22
22
|
* Register a tool function with metadata into the registry.
|
|
23
|
-
*
|
|
23
|
+
*
|
|
24
24
|
* its description/parameters so collectAllTools can build the Available Tools
|
|
25
25
|
* list dynamically instead of a hardcoded array.
|
|
26
26
|
*/
|
|
@@ -37,6 +37,8 @@ export declare const chat: (message: string) => Promise<string>;
|
|
|
37
37
|
export declare function getPackageNameMap(): Promise<Record<string, string>>;
|
|
38
38
|
/** Start an app by display name or bundle name. */
|
|
39
39
|
export declare const startApp: (appName: string) => Promise<string>;
|
|
40
|
+
/** Start an app via deeplink URI. */
|
|
41
|
+
export declare const startAppByDeepLink: (uri: string, bundleName?: string, abilityName?: string) => Promise<string>;
|
|
40
42
|
/** Stop an app by display name or bundle name. */
|
|
41
43
|
export declare const stopApp: (appName: string) => Promise<string>;
|
|
42
44
|
/** Clear an app's data to simulate a first-install state. */
|
|
@@ -65,3 +67,9 @@ export declare const loadSkill: (skillName: string) => Promise<string>;
|
|
|
65
67
|
* @returns JSON with `verified` (boolean) and `reason` (string).
|
|
66
68
|
*/
|
|
67
69
|
export declare function verify(verificationDescription: string): Promise<string>;
|
|
70
|
+
export interface JudgeResult {
|
|
71
|
+
passed: boolean;
|
|
72
|
+
shouldContinue: boolean;
|
|
73
|
+
reason: string;
|
|
74
|
+
}
|
|
75
|
+
export declare const judge: (conclusion: string) => Promise<string>;
|
|
@@ -40,7 +40,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
40
40
|
};
|
|
41
41
|
})();
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.loadSkill = exports.login = exports.goHome = exports.wait = exports.goBackTwice = exports.goBack = exports.clearApp = exports.stopApp = exports.startApp = exports.chat = exports.TOOL_REGISTRY = void 0;
|
|
43
|
+
exports.judge = exports.loadSkill = exports.login = exports.goHome = exports.wait = exports.goBackTwice = exports.goBack = exports.clearApp = exports.stopApp = exports.startAppByDeepLink = exports.startApp = exports.chat = exports.TOOL_REGISTRY = void 0;
|
|
44
44
|
exports.addToBlacklist = addToBlacklist;
|
|
45
45
|
exports.collectFunctionTool = collectFunctionTool;
|
|
46
46
|
exports.getToolEntries = getToolEntries;
|
|
@@ -57,9 +57,9 @@ const types_1 = require("../../reporter/types");
|
|
|
57
57
|
const custom_model_1 = require("../../common/model/custom_model");
|
|
58
58
|
/** Registry of all collected tool functions, keyed by name. */
|
|
59
59
|
exports.TOOL_REGISTRY = {};
|
|
60
|
-
/** Ordered list of tool entries with metadata
|
|
60
|
+
/** Ordered list of tool entries with metadata. */
|
|
61
61
|
const _TOOL_ENTRIES = [];
|
|
62
|
-
/** Tool blacklist — names excluded from getToolEntries()
|
|
62
|
+
/** Tool blacklist — names excluded from getToolEntries(). */
|
|
63
63
|
const _TOOL_BLACKLIST = new Set(['login']);
|
|
64
64
|
/** Add tool names to the blacklist. */
|
|
65
65
|
function addToBlacklist(...names) {
|
|
@@ -69,7 +69,7 @@ function addToBlacklist(...names) {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Register a tool function with metadata into the registry.
|
|
72
|
-
*
|
|
72
|
+
*
|
|
73
73
|
* its description/parameters so collectAllTools can build the Available Tools
|
|
74
74
|
* list dynamically instead of a hardcoded array.
|
|
75
75
|
*/
|
|
@@ -105,7 +105,7 @@ function getExecutorAgent() {
|
|
|
105
105
|
/**
|
|
106
106
|
* Get the executor device for the current agent.
|
|
107
107
|
* Hybrid-style: prefers tool_manager (adapter) from registry, falls back to
|
|
108
|
-
* executor agent's device
|
|
108
|
+
* executor agent's device._device).
|
|
109
109
|
*/
|
|
110
110
|
function getExecutorDevice() {
|
|
111
111
|
// Hybrid path: get adapter directly from registry
|
|
@@ -123,7 +123,7 @@ function getExecutorDevice() {
|
|
|
123
123
|
*/
|
|
124
124
|
let _chatLock = null;
|
|
125
125
|
exports.chat = collectFunctionTool('chat', async (message) => {
|
|
126
|
-
// Serialize concurrent chat calls —
|
|
126
|
+
// Serialize concurrent chat calls —
|
|
127
127
|
while (_chatLock) {
|
|
128
128
|
await _chatLock.catch(() => { });
|
|
129
129
|
}
|
|
@@ -236,6 +236,16 @@ async function doStartApp(appName) {
|
|
|
236
236
|
exports.startApp = collectFunctionTool('start_app', async (appName) => {
|
|
237
237
|
return doStartApp(appName);
|
|
238
238
|
}, { description: 'Start an application by display name or bundle name', parameters: { app_name: 'string' } });
|
|
239
|
+
/** Start an app via deeplink URI. */
|
|
240
|
+
exports.startAppByDeepLink = collectFunctionTool('start_app_by_deep_link', async (uri, bundleName, abilityName) => {
|
|
241
|
+
const device = getExecutorDevice();
|
|
242
|
+
const args = { uri };
|
|
243
|
+
if (bundleName)
|
|
244
|
+
args.bundle_name = bundleName;
|
|
245
|
+
if (abilityName)
|
|
246
|
+
args.ability_name = abilityName;
|
|
247
|
+
return await device.callTool('start_app_by_deep_link', args);
|
|
248
|
+
}, { description: 'Start an application via deeplink URI (e.g. myapp://page1). Optional bundle_name and ability_name for explicit targeting', parameters: { uri: 'string', bundle_name: 'string', ability_name: 'string' } });
|
|
239
249
|
/** Stop an app by display name or bundle name. */
|
|
240
250
|
exports.stopApp = collectFunctionTool('stop_app', async (appName) => {
|
|
241
251
|
const device = getExecutorDevice();
|
|
@@ -408,3 +418,56 @@ function getReportEvents(reportGenerator) {
|
|
|
408
418
|
function sleep(seconds) {
|
|
409
419
|
return new Promise((resolve) => setTimeout(resolve, Math.max(0, seconds) * 1000));
|
|
410
420
|
}
|
|
421
|
+
const JUDGE_SYSTEM_PROMPT = `You are a task execution result judge. The user provides a conclusion description of a task execution. You analyze it and output strict JSON (no other content).
|
|
422
|
+
Output format:
|
|
423
|
+
{
|
|
424
|
+
"passed": bool,
|
|
425
|
+
"should_continue": bool,
|
|
426
|
+
"reason": str
|
|
427
|
+
}
|
|
428
|
+
Rules:
|
|
429
|
+
- passed=true means the task overall succeeded; false means failed or has obvious issues.
|
|
430
|
+
- should_continue judgment (strict order):
|
|
431
|
+
1. If all steps completed, set to false (no need to continue).
|
|
432
|
+
2. If there are exceptions, errors, stuck or repeated retries, set to false even if steps incomplete.
|
|
433
|
+
3. If steps incomplete and no exceptions reported, set to true (can continue).
|
|
434
|
+
- reason should briefly explain the judgment basis.
|
|
435
|
+
- Only output JSON, no other text.`;
|
|
436
|
+
exports.judge = collectFunctionTool('judge', async (conclusion) => {
|
|
437
|
+
try {
|
|
438
|
+
const appConfig = agent_registry_1.agentRegistry.getAppConfig();
|
|
439
|
+
if (!appConfig) {
|
|
440
|
+
return JSON.stringify({ passed: false, should_continue: true, reason: 'No config available for judge tool' });
|
|
441
|
+
}
|
|
442
|
+
const { getModel } = await Promise.resolve().then(() => __importStar(require('../../common/config/manager')));
|
|
443
|
+
const modelConfig = getModel(appConfig.model, 'judge');
|
|
444
|
+
const llmCaller = new custom_model_1.LLMCaller();
|
|
445
|
+
const result = await llmCaller.call({
|
|
446
|
+
systemPrompt: JUDGE_SYSTEM_PROMPT,
|
|
447
|
+
userPrompt: conclusion,
|
|
448
|
+
modelConfig,
|
|
449
|
+
});
|
|
450
|
+
const raw = result.text.trim();
|
|
451
|
+
const jsonStart = raw.indexOf('{');
|
|
452
|
+
const jsonEnd = raw.lastIndexOf('}') + 1;
|
|
453
|
+
if (jsonStart >= 0 && jsonEnd > jsonStart) {
|
|
454
|
+
const data = JSON.parse(raw.slice(jsonStart, jsonEnd));
|
|
455
|
+
return JSON.stringify({
|
|
456
|
+
passed: _toBool(data.passed),
|
|
457
|
+
should_continue: _toBool(data.should_continue),
|
|
458
|
+
reason: String(data.reason ?? ''),
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return JSON.stringify({ passed: false, should_continue: true, reason: `Failed to parse judge response: ${raw.slice(0, 200)}` });
|
|
462
|
+
}
|
|
463
|
+
catch (e) {
|
|
464
|
+
return JSON.stringify({ passed: false, should_continue: true, reason: `judge error: ${e instanceof Error ? e.message : String(e)}` });
|
|
465
|
+
}
|
|
466
|
+
}, { description: 'Judge task execution conclusion: input conclusion text, returns JudgeResult with passed/should_continue/reason', parameters: { conclusion: 'string' } });
|
|
467
|
+
function _toBool(value) {
|
|
468
|
+
if (typeof value === 'boolean')
|
|
469
|
+
return value;
|
|
470
|
+
if (typeof value === 'string')
|
|
471
|
+
return ['true', 'yes', '1'].includes(value.toLowerCase());
|
|
472
|
+
return Boolean(value);
|
|
473
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal utility functions shared across memory module.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* Provides helpers for response text extraction, message filtering, retry
|
|
6
6
|
* decoration, and a lightweight TimeCalculate class used by ToolPlayer.
|
|
7
7
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Internal utility functions shared across memory module.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* Provides helpers for response text extraction, message filtering, retry
|
|
7
7
|
* decoration, and a lightweight TimeCalculate class used by ToolPlayer.
|
|
8
8
|
*/
|
|
@@ -37,7 +37,7 @@ const COMPRESSION_PROMPT = `你是一个对话摘要专家。你的任务是将
|
|
|
37
37
|
{conversation_history}
|
|
38
38
|
`;
|
|
39
39
|
function estimateTokens(messages) {
|
|
40
|
-
//
|
|
40
|
+
//
|
|
41
41
|
// Base64 image data (~400KB/screenshot) would inflate token count ~67x if counted
|
|
42
42
|
// as text, causing compression to trigger on every getItems() call.
|
|
43
43
|
const filtered = messages.map(msg => filterImagesFromMessage(msg));
|
|
@@ -91,7 +91,7 @@ function filterImagesFromMessage(msg) {
|
|
|
91
91
|
const p = part;
|
|
92
92
|
const type = p.type;
|
|
93
93
|
// Filter out all image-bearing part types:
|
|
94
|
-
// - input_image / image_url / image (OpenAI SDK format, used by
|
|
94
|
+
// - input_image / image_url / image (OpenAI SDK format, used by )
|
|
95
95
|
// - file (Vercel AI SDK format, used by Node agent — contains data:image/jpeg;base64,...)
|
|
96
96
|
if (type === 'input_image' || type === 'image_url' || type === 'image')
|
|
97
97
|
return false;
|
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
/**
|
|
18
|
-
* Memory subsystem barrel
|
|
18
|
+
* Memory subsystem barrel.
|
|
19
19
|
*
|
|
20
20
|
* Re-exports the memory facade plus the session input filter helper.
|
|
21
21
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Memory subsystem facade
|
|
2
|
+
* Memory subsystem facade.
|
|
3
3
|
*
|
|
4
4
|
* The legacy monolithic MemoryManager (apps/summary markdown store) was removed
|
|
5
5
|
* together with the hypium_agent package. This module now re-exports the new
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Memory subsystem facade
|
|
3
|
+
* Memory subsystem facade.
|
|
4
4
|
*
|
|
5
5
|
* The legacy monolithic MemoryManager (apps/summary markdown store) was removed
|
|
6
6
|
* together with the hypium_agent package. This module now re-exports the new
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { RecordingSession } from './tool_recorder';
|
|
2
2
|
import type { ModelConfig } from '../../common/config/types';
|
|
3
|
-
/** Mock tool object for report generator
|
|
3
|
+
/** Mock tool object for report generator. */
|
|
4
4
|
export interface MockTool {
|
|
5
5
|
name: string;
|
|
6
6
|
}
|
|
7
|
-
/** Configuration for popup handling during playback
|
|
7
|
+
/** Configuration for popup handling during playback. */
|
|
8
8
|
export interface PopupHandlingConfig {
|
|
9
9
|
enabled: boolean;
|
|
10
10
|
maxRetryAttempts: number;
|
|
11
11
|
skipPopupSteps: boolean;
|
|
12
12
|
}
|
|
13
13
|
export declare const DEFAULT_POPUP_CONFIG: PopupHandlingConfig;
|
|
14
|
-
/** Map recorded tool names to device action display names
|
|
14
|
+
/** Map recorded tool names to device action display names. */
|
|
15
15
|
export declare const ACTION_MAP: Record<string, string>;
|
|
16
16
|
export interface ToolPlayerOptions {
|
|
17
17
|
recording?: RecordingSession;
|
|
@@ -74,8 +74,8 @@ export declare class ToolPlayer {
|
|
|
74
74
|
private _detectPopup;
|
|
75
75
|
/** Basic popup close: try pressing back/home to dismiss. */
|
|
76
76
|
private _tryClosePopup;
|
|
77
|
-
/** Judge the playback result with a detailed LLM prompt
|
|
77
|
+
/** Judge the playback result with a detailed LLM prompt. */
|
|
78
78
|
judgeResult(playbackResult: PlaybackResult): Promise<string>;
|
|
79
|
-
/** Build the detailed judge prompt
|
|
79
|
+
/** Build the detailed judge prompt. */
|
|
80
80
|
private _buildJudgePrompt;
|
|
81
81
|
}
|
|
@@ -9,7 +9,7 @@ exports.DEFAULT_POPUP_CONFIG = {
|
|
|
9
9
|
maxRetryAttempts: 1,
|
|
10
10
|
skipPopupSteps: true,
|
|
11
11
|
};
|
|
12
|
-
/** Map recorded tool names to device action display names
|
|
12
|
+
/** Map recorded tool names to device action display names. */
|
|
13
13
|
exports.ACTION_MAP = {
|
|
14
14
|
click: 'Tap',
|
|
15
15
|
double_click: 'Double Tap',
|
|
@@ -96,7 +96,7 @@ class ToolPlayer {
|
|
|
96
96
|
try {
|
|
97
97
|
const result = await this._device.callTool(record.toolName, record.arguments);
|
|
98
98
|
const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
|
|
99
|
-
// Popup detection
|
|
99
|
+
// Popup detection
|
|
100
100
|
if (this._popupConfig.enabled && this._detectPopup(resultStr)) {
|
|
101
101
|
this._popupStats.detected++;
|
|
102
102
|
const closed = await this._tryClosePopup();
|
|
@@ -134,7 +134,7 @@ class ToolPlayer {
|
|
|
134
134
|
details.push({ step: i + 1, tool: record.toolName, success: false, error: lastError });
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
// Replan trigger
|
|
137
|
+
// Replan trigger
|
|
138
138
|
if (failure > 0 && this._replanCallback && !this._replanTriggered) {
|
|
139
139
|
this._replanTriggered = true;
|
|
140
140
|
logger_1.logger.info('[ToolPlayer] Triggering replan due to playback failures');
|
|
@@ -174,7 +174,7 @@ class ToolPlayer {
|
|
|
174
174
|
return false;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
/** Judge the playback result with a detailed LLM prompt
|
|
177
|
+
/** Judge the playback result with a detailed LLM prompt. */
|
|
178
178
|
async judgeResult(playbackResult) {
|
|
179
179
|
if (!this._modelConfig)
|
|
180
180
|
return playbackResult.summary;
|
|
@@ -196,7 +196,7 @@ class ToolPlayer {
|
|
|
196
196
|
return playbackResult.summary;
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
/** Build the detailed judge prompt
|
|
199
|
+
/** Build the detailed judge prompt. */
|
|
200
200
|
_buildJudgePrompt(taskInfo, resultsText, playbackResult) {
|
|
201
201
|
return `## Task
|
|
202
202
|
${taskInfo}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Popup handling and LLM screenshot analysis mixin for ToolPlayer.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* Detects unexpected popups during playback via LLM screenshot analysis,
|
|
6
6
|
* closes them, and retries the failed step. Also handles skipping popup
|
|
7
7
|
* steps that are no longer relevant.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Popup handling and LLM screenshot analysis mixin for ToolPlayer.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* Detects unexpected popups during playback via LLM screenshot analysis,
|
|
7
7
|
* closes them, and retries the failed step. Also handles skipping popup
|
|
8
8
|
* steps that are no longer relevant.
|
|
@@ -107,15 +107,15 @@ class PopupMixin {
|
|
|
107
107
|
请按以下JSON格式回答(只返回JSON,不要包含其他文字):
|
|
108
108
|
如果存在弹窗,请找出处理该弹窗需要点击的按钮的中心坐标(用0-1的归一化坐标表示,0=最左边/最上边,1=最右边/最下边):
|
|
109
109
|
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
"has_popup": true,
|
|
111
|
+
"popup_type": "弹窗类型(如:隐私协议确认、系统权限弹窗、广告弹窗、更新提示、确认对话框等)",
|
|
112
|
+
"action": "需要点击的按钮文本(如:同意、关闭、确定、取消、允许等)",
|
|
113
|
+
"close_x": 按钮中心的X坐标(0-1范围),
|
|
114
|
+
"close_y": 按钮中心的Y坐标(0-1范围)
|
|
115
115
|
}
|
|
116
116
|
如果不存在弹窗:
|
|
117
117
|
{
|
|
118
|
-
|
|
118
|
+
"has_popup": false
|
|
119
119
|
}`;
|
|
120
120
|
const responseText = await this.analyzeScreenshotWithLlm(prompt);
|
|
121
121
|
if (!responseText)
|
|
@@ -229,11 +229,11 @@ class PopupMixin {
|
|
|
229
229
|
|
|
230
230
|
请按以下JSON格式回答(只返回JSON,不要包含其他文字):
|
|
231
231
|
{
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
232
|
+
"is_popup_operation": true或false,
|
|
233
|
+
"has_popup": true或false,
|
|
234
|
+
"popup_type": "如果存在弹窗,填写弹窗类型;否则填空字符串",
|
|
235
|
+
"close_x": 如果存在弹窗,填写处理该弹窗需要点击的按钮的X坐标(0-1归一化);否则填0,
|
|
236
|
+
"close_y": 如果存在弹窗,填写处理该弹窗需要点击的按钮的Y坐标(0-1归一化);否则填0
|
|
237
237
|
}`;
|
|
238
238
|
const responseText = await this.analyzeScreenshotWithLlm(prompt);
|
|
239
239
|
if (!responseText)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Replan mixin for ToolPlayer.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* Contains the replan prompt builder and the triggerReplan method.
|
|
6
6
|
* Delegates to a replanCallback callable so the host application owns the
|
|
7
7
|
* replanning lifecycle.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Replan mixin for ToolPlayer.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* Contains the replan prompt builder and the triggerReplan method.
|
|
7
7
|
* Delegates to a replanCallback callable so the host application owns the
|
|
8
8
|
* replanning lifecycle.
|
|
@@ -86,7 +86,7 @@ ${suggestion ? suggestion + '\n' : ''}
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
const statusIcon = isSuccess ? '✅' : '❌';
|
|
89
|
-
lines.push(`
|
|
89
|
+
lines.push(` ${i + 1}. ${statusIcon} ${stepSummary}`);
|
|
90
90
|
}
|
|
91
91
|
return lines.join('\n');
|
|
92
92
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* XPath-based component finding and tool execution mixin for ToolPlayer.
|
|
3
3
|
*
|
|
4
|
-
* Ported from python core/memory/tool_player_xpath.py.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* NOTE: The version depends on `hypium` (a -only HarmonyOS UI
|
|
7
7
|
* test framework that provides XPath-based component finding via UiDriver)
|
|
8
|
-
* and the
|
|
8
|
+
* and the `agents` SDK (ToolContext/Usage). Neither exists in Node.js.
|
|
9
9
|
*
|
|
10
10
|
* The framework-agnostic helpers (coordinate parsing, normalization, bounds
|
|
11
11
|
* center calculation) are ported faithfully. The hypium-dependent methods
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* XPath-based component finding and tool execution mixin for ToolPlayer.
|
|
4
4
|
*
|
|
5
|
-
* Ported from python core/memory/tool_player_xpath.py.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* NOTE: The version depends on `hypium` (a -only HarmonyOS UI
|
|
8
8
|
* test framework that provides XPath-based component finding via UiDriver)
|
|
9
|
-
* and the
|
|
9
|
+
* and the `agents` SDK (ToolContext/Usage). Neither exists in Node.js.
|
|
10
10
|
*
|
|
11
11
|
* The framework-agnostic helpers (coordinate parsing, normalization, bounds
|
|
12
12
|
* center calculation) are ported faithfully. The hypium-dependent methods
|
|
@@ -16,7 +16,7 @@ export declare function listAllPrompts(category: PromptCategory): Array<{
|
|
|
16
16
|
date: string;
|
|
17
17
|
description: string;
|
|
18
18
|
}>;
|
|
19
|
-
/** Register extra directories to scan for prompts
|
|
19
|
+
/** Register extra directories to scan for prompts. */
|
|
20
20
|
export declare function registerScanPaths(paths: string[]): void;
|
|
21
21
|
/** Return the registered extra scan directories. */
|
|
22
22
|
export declare function getScanDirs(): string[];
|
|
@@ -231,7 +231,7 @@ function listAllPrompts(category) {
|
|
|
231
231
|
return versions.map((v) => _getVersionInfo(category, v));
|
|
232
232
|
}
|
|
233
233
|
const _extraScanPaths = [];
|
|
234
|
-
/** Register extra directories to scan for prompts
|
|
234
|
+
/** Register extra directories to scan for prompts. */
|
|
235
235
|
function registerScanPaths(paths) {
|
|
236
236
|
for (const p of paths) {
|
|
237
237
|
if (!p)
|
|
@@ -247,7 +247,7 @@ function getScanDirs() {
|
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
249
249
|
* Find a prompt by filename, searching extra scan paths (recursive, highest
|
|
250
|
-
* priority) before the built-in templates dir.
|
|
250
|
+
* priority) before the built-in templates dir.
|
|
251
251
|
* _find_prompt_by_name. Returns raw file content or null.
|
|
252
252
|
*/
|
|
253
253
|
function _findPromptByName(name) {
|
|
@@ -281,7 +281,7 @@ function _findPromptByName(name) {
|
|
|
281
281
|
}
|
|
282
282
|
return null;
|
|
283
283
|
};
|
|
284
|
-
//
|
|
284
|
+
//
|
|
285
285
|
// 1. built-in templates (recursive)
|
|
286
286
|
const hit1 = scanDir(TEMPLATES_DIR);
|
|
287
287
|
if (hit1)
|
|
@@ -2,7 +2,7 @@ export interface SkillMatch {
|
|
|
2
2
|
name: string;
|
|
3
3
|
score: number;
|
|
4
4
|
}
|
|
5
|
-
/** A loaded skill: metadata + body + resource subdirs
|
|
5
|
+
/** A loaded skill: metadata + body + resource subdirs. */
|
|
6
6
|
interface SkillData {
|
|
7
7
|
metadata: Record<string, unknown>;
|
|
8
8
|
content: string;
|
|
@@ -13,7 +13,7 @@ interface SkillData {
|
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Manages Agent Skills following the Agent Skills specification (aligned with
|
|
16
|
-
*
|
|
16
|
+
* core/skill/skill_manager.py).
|
|
17
17
|
*
|
|
18
18
|
* Each skill is a directory containing a SKILL.md with YAML frontmatter
|
|
19
19
|
* (name/description/license/compatibility) + markdown body, plus optional
|
|
@@ -47,7 +47,7 @@ function tokenize(text) {
|
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Manages Agent Skills following the Agent Skills specification (aligned with
|
|
50
|
-
*
|
|
50
|
+
* core/skill/skill_manager.py).
|
|
51
51
|
*
|
|
52
52
|
* Each skill is a directory containing a SKILL.md with YAML frontmatter
|
|
53
53
|
* (name/description/license/compatibility) + markdown body, plus optional
|
package/dist/data_types/case.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
2
|
+
//
|
|
3
3
|
// Used by case_runner (tools/case_runner) and batch runner CaseInfo-mode.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.CaseInfo = exports.AppInfo = void 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
2
|
+
//
|
|
3
3
|
// Standalone screen metadata; distinct from the agent-internal ScreenInfo
|
|
4
4
|
// in core/agent/utils/message_builder.ts (current_app/extra).
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|