@autotest/agent 0.0.1

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.
Files changed (142) hide show
  1. package/README.md +648 -0
  2. package/dist/api/agent_api.d.ts +37 -0
  3. package/dist/api/autotest_agent.d.ts +60 -0
  4. package/dist/api/types.d.ts +86 -0
  5. package/dist/autotest-cli.d.ts +2 -0
  6. package/dist/common/case_manager.d.ts +10 -0
  7. package/dist/common/collect_case.d.ts +29 -0
  8. package/dist/common/common_errors.d.ts +30 -0
  9. package/dist/common/config/config.yaml +113 -0
  10. package/dist/common/config/config_validator.d.ts +8 -0
  11. package/dist/common/config/manager.d.ts +38 -0
  12. package/dist/common/config/output.d.ts +11 -0
  13. package/dist/common/config/types.d.ts +2963 -0
  14. package/dist/common/dfx/client_factory.d.ts +23 -0
  15. package/dist/common/dfx/context.d.ts +4 -0
  16. package/dist/common/dfx/index.d.ts +6 -0
  17. package/dist/common/dfx/recorder.d.ts +59 -0
  18. package/dist/common/dfx/recording_fetch.d.ts +4 -0
  19. package/dist/common/dfx/source.d.ts +9 -0
  20. package/dist/common/image_cacher.d.ts +10 -0
  21. package/dist/common/image_helper.d.ts +19 -0
  22. package/dist/common/image_similarity.d.ts +7 -0
  23. package/dist/common/llm_cache/cache_transport.d.ts +10 -0
  24. package/dist/common/logger.d.ts +17 -0
  25. package/dist/common/model/custom_model.d.ts +52 -0
  26. package/dist/common/model/index.d.ts +3 -0
  27. package/dist/common/path_utils.d.ts +11 -0
  28. package/dist/common/result_parser.d.ts +10 -0
  29. package/dist/common/usage/token_usage.d.ts +23 -0
  30. package/dist/common/utils.d.ts +44 -0
  31. package/dist/core/agent/layered_agent/ability_helper.d.ts +36 -0
  32. package/dist/core/agent/layered_agent/agent.d.ts +15 -0
  33. package/dist/core/agent/layered_agent/agent_registry.d.ts +34 -0
  34. package/dist/core/agent/layered_agent/decision.d.ts +82 -0
  35. package/dist/core/agent/layered_agent/execute_agent/action_handler.d.ts +26 -0
  36. package/dist/core/agent/layered_agent/execute_agent/agent_factory.d.ts +24 -0
  37. package/dist/core/agent/layered_agent/execute_agent/base_agent.d.ts +83 -0
  38. package/dist/core/agent/layered_agent/execute_agent/general_agent.d.ts +33 -0
  39. package/dist/core/agent/layered_agent/execute_agent/glm_agent.d.ts +36 -0
  40. package/dist/core/agent/layered_agent/execute_agent/i18n.d.ts +26 -0
  41. package/dist/core/agent/layered_agent/execute_agent/index.d.ts +16 -0
  42. package/dist/core/agent/layered_agent/execute_agent/mai_ui_agent.d.ts +52 -0
  43. package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.d.ts +4 -0
  44. package/dist/core/agent/layered_agent/execute_agent/parser/general_parser.d.ts +22 -0
  45. package/dist/core/agent/layered_agent/execute_agent/parser/glm_parser.d.ts +14 -0
  46. package/dist/core/agent/layered_agent/execute_agent/parser/index.d.ts +7 -0
  47. package/dist/core/agent/layered_agent/execute_agent/parser/mai_ui_parser.d.ts +17 -0
  48. package/dist/core/agent/layered_agent/execute_agent/prompts.d.ts +2 -0
  49. package/dist/core/agent/layered_agent/execute_agent/simple_reporter.d.ts +13 -0
  50. package/dist/core/agent/layered_agent/execute_agent/utils.d.ts +6 -0
  51. package/dist/core/agent/report_analyzer_agent/agent.d.ts +22 -0
  52. package/dist/core/agent/report_analyzer_agent/config.d.ts +5 -0
  53. package/dist/core/agent/report_analyzer_agent/data_loader.d.ts +26 -0
  54. package/dist/core/agent/report_analyzer_agent/guardrails.d.ts +9 -0
  55. package/dist/core/agent/report_analyzer_agent/hooks.d.ts +6 -0
  56. package/dist/core/agent/report_analyzer_agent/index.d.ts +17 -0
  57. package/dist/core/agent/report_analyzer_agent/key_steps_builder.d.ts +9 -0
  58. package/dist/core/agent/report_analyzer_agent/mapping.d.ts +6 -0
  59. package/dist/core/agent/report_analyzer_agent/parse.d.ts +4 -0
  60. package/dist/core/agent/report_analyzer_agent/prompt.d.ts +2 -0
  61. package/dist/core/agent/report_analyzer_agent/prompts/main_agent.md +198 -0
  62. package/dist/core/agent/report_analyzer_agent/prompts/main_agent_v2.0.md +420 -0
  63. package/dist/core/agent/report_analyzer_agent/report_writer.d.ts +8 -0
  64. package/dist/core/agent/report_analyzer_agent/tools.d.ts +26 -0
  65. package/dist/core/agent/report_analyzer_agent/types.d.ts +97 -0
  66. package/dist/core/agent/rewrite_agent/agent.d.ts +27 -0
  67. package/dist/core/agent/rewrite_agent/guardrails.d.ts +16 -0
  68. package/dist/core/agent/rewrite_agent/mapping.d.ts +25 -0
  69. package/dist/core/agent/rewrite_agent/parse.d.ts +14 -0
  70. package/dist/core/agent/rewrite_agent/prompts/rewriter_v1.0.md +168 -0
  71. package/dist/core/agent/rewrite_agent/types.d.ts +50 -0
  72. package/dist/core/agent/single_agent/agent.d.ts +43 -0
  73. package/dist/core/agent/single_agent/hook_manager.d.ts +43 -0
  74. package/dist/core/agent/single_agent/hooks.d.ts +23 -0
  75. package/dist/core/agent/single_agent/image_utils.d.ts +38 -0
  76. package/dist/core/agent/single_agent/scroll_search_agent.d.ts +58 -0
  77. package/dist/core/agent/single_agent/subagent_manager.d.ts +51 -0
  78. package/dist/core/agent/single_agent/tool_recorder_hook.d.ts +20 -0
  79. package/dist/core/agent/types.d.ts +43 -0
  80. package/dist/core/agent/utils/message_builder.d.ts +38 -0
  81. package/dist/core/device/device_protocol.d.ts +3 -0
  82. package/dist/core/device/hdc/apps.d.ts +38 -0
  83. package/dist/core/device/hdc/device.d.ts +59 -0
  84. package/dist/core/device/hdc/index.d.ts +9 -0
  85. package/dist/core/device/hdc/input.d.ts +20 -0
  86. package/dist/core/device/hdc/screenshot.d.ts +19 -0
  87. package/dist/core/device/index.d.ts +49 -0
  88. package/dist/core/device/types.d.ts +37 -0
  89. package/dist/core/knowledge/knowledge_manager.d.ts +22 -0
  90. package/dist/core/knowledge/vectordb.d.ts +44 -0
  91. package/dist/core/mcp/adapter_factory.d.ts +10 -0
  92. package/dist/core/mcp/android_adapter.d.ts +30 -0
  93. package/dist/core/mcp/base_adapter.d.ts +26 -0
  94. package/dist/core/mcp/harmony_hdc_adapter.d.ts +49 -0
  95. package/dist/core/mcp/ios_adapter.d.ts +30 -0
  96. package/dist/core/mcp/local_tools.d.ts +20 -0
  97. package/dist/core/mcp/mcp_tools.d.ts +51 -0
  98. package/dist/core/mcp/types.d.ts +24 -0
  99. package/dist/core/memory/compressed_session.d.ts +46 -0
  100. package/dist/core/memory/context_compressor.d.ts +24 -0
  101. package/dist/core/memory/index.d.ts +7 -0
  102. package/dist/core/memory/memory_manager.d.ts +21 -0
  103. package/dist/core/memory/reflector.d.ts +20 -0
  104. package/dist/core/memory/session_factory.d.ts +17 -0
  105. package/dist/core/memory/tool_player.d.ts +82 -0
  106. package/dist/core/memory/tool_recorder.d.ts +33 -0
  107. package/dist/core/preprocessor/task_splitter.d.ts +26 -0
  108. package/dist/core/prompt/prompt_loader.d.ts +24 -0
  109. package/dist/core/prompt/templates/debug/planner/planner_v0.0.md +290 -0
  110. package/dist/core/prompt/templates/debug/planner/planner_v1.0.md +221 -0
  111. package/dist/core/prompt/templates/debug/planner/planner_v1.1-dy.md +74 -0
  112. package/dist/core/prompt/templates/debug/planner/planner_v2.0.md +319 -0
  113. package/dist/core/prompt/templates/fast_action/fast_action_v1.0.md +46 -0
  114. package/dist/core/prompt/templates/hypium/hypium_v1.0.md +33 -0
  115. package/dist/core/prompt/templates/hypium/hypium_v2.0.md +285 -0
  116. package/dist/core/prompt/templates/planner/planner_v2.0.md +319 -0
  117. package/dist/core/prompt/templates/single/single_v1.0.md +452 -0
  118. package/dist/core/prompt/templates/single/single_v2.0.md +306 -0
  119. package/dist/core/prompt/templates/single/single_v2.0_eco.md +313 -0
  120. package/dist/core/prompt/templates/single/single_v3.0.md +200 -0
  121. package/dist/core/prompt/templates/splitter/task_splitter_v1.0.md +141 -0
  122. package/dist/core/skill/skill_manager.d.ts +54 -0
  123. package/dist/data_types/action.d.ts +2 -0
  124. package/dist/data_types/agent.d.ts +2 -0
  125. package/dist/data_types/device.d.ts +2 -0
  126. package/dist/data_types/index.d.ts +6 -0
  127. package/dist/data_types/report.d.ts +2 -0
  128. package/dist/data_types/task.d.ts +2 -0
  129. package/dist/hypium_generator/generator.d.ts +38 -0
  130. package/dist/index.d.ts +46 -0
  131. package/dist/index.js +1 -0
  132. package/dist/loop/cli.d.ts +39 -0
  133. package/dist/loop/orchestrator.d.ts +47 -0
  134. package/dist/loop/result_writer.d.ts +12 -0
  135. package/dist/loop/types.d.ts +77 -0
  136. package/dist/mcp-server/server.d.ts +15 -0
  137. package/dist/mcp-server/types.d.ts +196 -0
  138. package/dist/reporter/batch_summary.d.ts +19 -0
  139. package/dist/reporter/generator.d.ts +46 -0
  140. package/dist/reporter/types.d.ts +88 -0
  141. package/dist/tools/batch_runner.d.ts +92 -0
  142. package/package.json +51 -0
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ToolRecorderHook — cross-cutting hook that auto-records every tool call via
3
+ * the global HookManager (aligned with python hybrid_agent/hooks/tool_recorder_hook.py).
4
+ *
5
+ * Register once at agent startup:
6
+ * const recorder = new ToolRecorder(taskId, storageDir);
7
+ * hookManager.register('tool_recorder', new ToolRecorderHook(recorder));
8
+ * Call finalize() at agent end to persist.
9
+ */
10
+ import type { AgentHook, HookContext } from './hook_manager';
11
+ import { ToolRecorder } from '../../memory/tool_recorder';
12
+ export declare class ToolRecorderHook implements AgentHook {
13
+ private recorder;
14
+ private _finalized;
15
+ constructor(recorder: ToolRecorder);
16
+ onToolEnd(ctx: HookContext): Promise<void>;
17
+ /** Persist the recorded session to disk. Call at agent end. */
18
+ finalize(): string | null;
19
+ }
20
+ //# sourceMappingURL=tool_recorder_hook.d.ts.map
@@ -0,0 +1,43 @@
1
+ export type AgentMode = 'single' | 'hypium' | 'layered';
2
+ export type AgentStatus = 'SUCCESS' | 'FAILED' | 'STOPPED' | 'ERROR' | 'STOP_BY_USER' | 'PASS' | 'FAIL' | 'UNKNOWN';
3
+ export type SingleAgentStatus = 'PASS' | 'FAIL' | 'UNKNOWN';
4
+ export interface AgentResult {
5
+ finalOutput: string;
6
+ status: AgentStatus;
7
+ savedFiles?: Record<string, string>;
8
+ }
9
+ export interface StepResult {
10
+ success: boolean;
11
+ finished: boolean;
12
+ action?: Record<string, unknown>;
13
+ thinking: string;
14
+ message?: string;
15
+ }
16
+ export interface ActionResult {
17
+ success: boolean;
18
+ shouldFinish: boolean;
19
+ message?: string;
20
+ }
21
+ export interface AgentHooks {
22
+ onAgentStart(agentName: string): Promise<void>;
23
+ onAgentEnd(agentName: string, output: unknown): Promise<void>;
24
+ onLLMStart(agentName: string, stepNumber: number): Promise<void>;
25
+ onLLMEnd(agentName: string, stepNumber: number, response: unknown): Promise<void>;
26
+ onToolStart(agentName: string, toolName: string, args?: Record<string, unknown>): Promise<void>;
27
+ onToolEnd(agentName: string, toolName: string, result: string, stepNumber: number): Promise<void>;
28
+ }
29
+ export interface SingleAgentArgs {
30
+ task: string;
31
+ taskName?: string;
32
+ caseNum?: string;
33
+ device?: string;
34
+ ip?: string;
35
+ port?: number;
36
+ verbose?: boolean;
37
+ jsonOutput?: boolean;
38
+ reportDir?: string;
39
+ config?: string;
40
+ mode?: AgentMode;
41
+ runId?: string;
42
+ }
43
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,38 @@
1
+ import type { ModelMessage } from 'ai';
2
+ export type MessageContentPart = {
3
+ type: 'text';
4
+ text: string;
5
+ } | {
6
+ type: 'image_url';
7
+ image_url: {
8
+ url: string;
9
+ };
10
+ };
11
+ export interface LLMMessage {
12
+ role: 'system' | 'user' | 'assistant' | 'tool';
13
+ name?: string;
14
+ content: string | MessageContentPart[];
15
+ }
16
+ export declare function toModelMessages(messages: LLMMessage[]): ModelMessage[];
17
+ export interface ScreenInfo {
18
+ current_app: string;
19
+ [key: string]: unknown;
20
+ }
21
+ export declare class MessageBuilder {
22
+ private messages;
23
+ static createSystemMessage(content: string): LLMMessage;
24
+ static createUserMessage(text: string, imageBase64?: string | null, mimeType?: string): LLMMessage;
25
+ static createAssistantMessage(content: string): LLMMessage;
26
+ static removeImagesFromMessage(message: LLMMessage): LLMMessage;
27
+ static buildScreenInfo(currentApp: string, extraInfo?: Record<string, unknown>): string;
28
+ addSystemPrompt(prompt: string): void;
29
+ addUserMessage(content: string): void;
30
+ addScreenshot(base64Data: string, mimeType?: string): void;
31
+ addAssistantMessage(content: string): void;
32
+ addProgressHint(stepCount: number, historyActions: string[]): void;
33
+ getMessages(): LLMMessage[];
34
+ clear(): void;
35
+ compressHistory(maxImageMessages?: number): LLMMessage[];
36
+ private findLastUserMessage;
37
+ }
38
+ //# sourceMappingURL=message_builder.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { DeviceProtocol, Screenshot, ToolDefine, ToolCallResult } from './types';
2
+ export type { DeviceProtocol, Screenshot, ToolDefine, ToolCallResult, };
3
+ //# sourceMappingURL=device_protocol.d.ts.map
@@ -0,0 +1,38 @@
1
+ /**
2
+ * HarmonyOS application package name mappings.
3
+ *
4
+ * Maps user-friendly app display names to HarmonyOS bundle names.
5
+ * These bundle names are used with the `hdc shell aa start -b <bundle>` command.
6
+ *
7
+ * NOTE: The display-name keys are real app names reported by the device and are
8
+ * intentionally kept in their original language (domain data, not code strings).
9
+ */
10
+ /**
11
+ * Custom ability names for apps that don't use the default "EntryAbility".
12
+ * Maps bundle_name -> ability_name.
13
+ */
14
+ export declare const APP_ABILITIES: Record<string, string>;
15
+ /** Maps display app names to HarmonyOS bundle names. */
16
+ export declare const APP_PACKAGES: Record<string, string>;
17
+ /** Extended app-name to bundle-name mappings for a broader app catalog. */
18
+ export declare const TOP_225_APP: Record<string, string>;
19
+ /** Reverse mapping: bundle_name -> display name (or array of names). */
20
+ export declare let BUNDLE_NAME_TO_APP_NAME: Record<string, string | string[]>;
21
+ /**
22
+ * Get the package (bundle) name for an app display name.
23
+ * @param appName The display name of the app.
24
+ * @returns The HarmonyOS bundle name, or undefined if not found.
25
+ */
26
+ export declare function getPackageName(appName: string): string | undefined;
27
+ /**
28
+ * Get the app display name from a package (bundle) name.
29
+ * @param packageName The HarmonyOS bundle name.
30
+ * @returns The display name of the app, or undefined if not found.
31
+ */
32
+ export declare function getAppName(packageName: string): string | undefined;
33
+ /**
34
+ * Get a list of all supported app display names.
35
+ * @returns List of app names.
36
+ */
37
+ export declare function listSupportedApps(): string[];
38
+ //# sourceMappingURL=apps.d.ts.map
@@ -0,0 +1,59 @@
1
+ /**
2
+ * HDC device operations for HarmonyOS.
3
+ *
4
+ * These helpers wrap `hdc shell` commands to drive a connected HarmonyOS
5
+ * device. They accept an {@link HdcDriver} abstraction so the underlying
6
+ * subprocess execution can be swapped or mocked.
7
+ *
8
+ * All methods are **async** to avoid blocking the Node.js event loop.
9
+ */
10
+ /** Abstraction over an hdc-connected device used by the hdc helpers. */
11
+ export interface HdcDriver {
12
+ readonly deviceSn: string;
13
+ /** Run a shell command on the device and return stdout. Rejects on failure. */
14
+ shell(command: string, timeout?: number): Promise<string>;
15
+ /** Pull a file from the device to the local filesystem. Returns false on failure. */
16
+ fileRecv(remotePath: string, localPath: string): Promise<boolean>;
17
+ /** Push a local file to the device. Returns false on failure. */
18
+ fileSend(localPath: string, remotePath: string): Promise<boolean>;
19
+ /** Run the host-side `hdc list targets` and return its raw stdout. */
20
+ listTargets(): Promise<string>;
21
+ }
22
+ /**
23
+ * Get the display name of an app from its bundle name.
24
+ * @param bundleName The bundle name of the app.
25
+ * @returns The display name of the app.
26
+ */
27
+ export declare function getAppDisplayName(bundleName: string): string;
28
+ /**
29
+ * Get the currently focused app name.
30
+ * @param driver The hdc driver instance.
31
+ * @param returnDisplayName Whether to return the display name (true) or bundle name (false).
32
+ * @returns The app name if recognized, otherwise "System Home".
33
+ */
34
+ export declare function getCurrentApp(driver: HdcDriver, returnDisplayName?: boolean): Promise<string>;
35
+ /** Tap at the specified coordinates. */
36
+ export declare function tap(driver: HdcDriver, x: number, y: number, delay?: number | null): Promise<void>;
37
+ /** Double tap at the specified coordinates. */
38
+ export declare function doubleTap(driver: HdcDriver, x: number, y: number, delay?: number | null): Promise<void>;
39
+ /** Long press at the specified coordinates. */
40
+ export declare function longPress(driver: HdcDriver, x: number, y: number, durationMs?: number, delay?: number | null): Promise<void>;
41
+ /** Swipe from start to end coordinates. */
42
+ export declare function swipe(driver: HdcDriver, startX: number, startY: number, endX: number, endY: number, durationMs?: number | null, delay?: number | null): Promise<void>;
43
+ /** Press the back button. */
44
+ export declare function back(driver: HdcDriver, delay?: number | null): Promise<void>;
45
+ /** Press the home button. */
46
+ export declare function home(driver: HdcDriver, delay?: number | null): Promise<void>;
47
+ /**
48
+ * Launch an app by name.
49
+ * @returns True if app was launched, False if the start command reported an error.
50
+ */
51
+ export declare function launchApp(driver: HdcDriver, appName: string, delay?: number | null): Promise<boolean>;
52
+ /**
53
+ * Reset the device to a clean home state (aligned with python reset_device).
54
+ * Light flow: single home + clear recent tasks via aa dump/force-stop.
55
+ */
56
+ export declare function resetDevice(driver: HdcDriver): Promise<void>;
57
+ /** Async sleep for the given number of seconds. */
58
+ export declare function sleep(seconds: number): Promise<void>;
59
+ //# sourceMappingURL=device.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * HDC utilities for HarmonyOS device interaction.
3
+ */
4
+ export type { HdcDriver } from './device';
5
+ export { getScreenshot } from './screenshot';
6
+ export { inputText, typeText, clearText } from './input';
7
+ export { APP_PACKAGES, APP_ABILITIES, TOP_225_APP, BUNDLE_NAME_TO_APP_NAME, getPackageName, getAppName, listSupportedApps, } from './apps';
8
+ export { getAppDisplayName, getCurrentApp, tap, doubleTap, longPress, swipe, back, home, launchApp, resetDevice, } from './device';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Input utilities for HarmonyOS device text input.
3
+ *
4
+ * Uses `hdc shell uitest uiInput text` to inject text into the focused field.
5
+ *
6
+ * All methods are **async** to avoid blocking the Node.js event loop.
7
+ */
8
+ import type { HdcDriver } from './device';
9
+ /** Inject text into the currently focused input field. */
10
+ export declare function inputText(driver: HdcDriver, text: string): Promise<void>;
11
+ /**
12
+ * Type text into the currently focused input field.
13
+ *
14
+ * Supports multi-line text by splitting on newlines and sending ENTER key
15
+ * events (key code 2054) between lines.
16
+ */
17
+ export declare function typeText(driver: HdcDriver, text: string): Promise<void>;
18
+ /** Clear text in the currently focused input field (select-all then delete). */
19
+ export declare function clearText(driver: HdcDriver): Promise<void>;
20
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Screenshot utilities for capturing the HarmonyOS device screen.
3
+ *
4
+ * Uses `hdc shell snapshot_display` to capture and `hdc file recv` to pull the
5
+ * image. A fallback black image is returned when capture fails.
6
+ *
7
+ * All methods are **async** to avoid blocking the Node.js event loop.
8
+ */
9
+ import type { HdcDriver } from './device';
10
+ import type { Screenshot } from '../types';
11
+ /**
12
+ * Capture a screenshot from the connected HarmonyOS device.
13
+ *
14
+ * @param driver The hdc driver instance.
15
+ * @param withLayout Whether to also capture the UI layout.
16
+ * @returns Screenshot object containing base64 data and dimensions.
17
+ */
18
+ export declare function getScreenshot(driver: HdcDriver, withLayout?: boolean): Promise<Screenshot>;
19
+ //# sourceMappingURL=screenshot.d.ts.map
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Device layer entry point (aligned with python core/device/__init__.py).
3
+ *
4
+ * Re-exports the device protocol types and provides a `createDevice` factory
5
+ * with a pluggable registry. `MockDevice` is available for offline/test runs.
6
+ */
7
+ import type { DeviceProtocol, Screenshot, ToolCallResult, ToolDefine } from './types';
8
+ export type { DeviceProtocol, Screenshot, ToolCallResult, ToolDefine };
9
+ /**
10
+ * Minimal in-memory device for tests/offline runs. Implements DeviceProtocol
11
+ * with no-op actions and canned responses; records calls for assertions.
12
+ */
13
+ export declare class MockDevice implements DeviceProtocol {
14
+ readonly deviceId: string;
15
+ calls: Array<{
16
+ tool: string;
17
+ args: Record<string, unknown>;
18
+ }>;
19
+ private _currentApp;
20
+ constructor(deviceId?: string);
21
+ getScreenshot(): Screenshot;
22
+ tap(x: number, y: number): void;
23
+ doubleTap(x: number, y: number): void;
24
+ longPress(x: number, y: number, durationMs?: number): void;
25
+ swipe(sx: number, sy: number, ex: number, ey: number): void;
26
+ typeText(text: string): void;
27
+ clearText(): void;
28
+ back(): void;
29
+ home(): void;
30
+ launchApp(appName: string): boolean;
31
+ getCurrentApp(): string;
32
+ listTools(): ToolDefine[];
33
+ callTool(toolName: string, toolArgs: Record<string, unknown>): ToolCallResult;
34
+ cleanUp(): void;
35
+ }
36
+ export interface CreateDeviceOptions {
37
+ deviceImpl?: string;
38
+ deviceSn?: string;
39
+ ip?: string;
40
+ port?: number;
41
+ }
42
+ /**
43
+ * Create a device by implementation name (aligned with python create_device).
44
+ * 'MockDevice' returns an in-memory mock; real HDC devices are created via the
45
+ * MCP adapter factory (`createAdapterFromDeviceInfo`), which is the Node
46
+ * equivalent of HDCDevice.
47
+ */
48
+ export declare function createDevice(opts?: CreateDeviceOptions): DeviceProtocol;
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,37 @@
1
+ export interface Screenshot {
2
+ base64Data: string;
3
+ layoutData: string;
4
+ width: number;
5
+ height: number;
6
+ isSensitive: boolean;
7
+ screenshotPath: string | null;
8
+ }
9
+ export interface ToolDefine {
10
+ name: string;
11
+ description: string;
12
+ inputSchema: Record<string, unknown>;
13
+ outputSchema: Record<string, unknown>;
14
+ }
15
+ export interface ToolCallResult {
16
+ output: string;
17
+ success: boolean;
18
+ errorMsg: string;
19
+ }
20
+ export interface DeviceProtocol {
21
+ readonly deviceId: string;
22
+ getScreenshot(timeout?: number, saveToReport?: boolean): Screenshot;
23
+ tap(x: number, y: number, delay?: number): void;
24
+ doubleTap(x: number, y: number, delay?: number): void;
25
+ longPress(x: number, y: number, durationMs?: number, delay?: number): void;
26
+ swipe(startX: number, startY: number, endX: number, endY: number): void;
27
+ typeText(text: string): void;
28
+ clearText(): void;
29
+ back(delay?: number): void;
30
+ home(delay?: number): void;
31
+ launchApp(appName: string, delay?: number): boolean;
32
+ getCurrentApp(): string;
33
+ listTools(): ToolDefine[];
34
+ callTool(toolName: string, toolArgs: Record<string, unknown>): ToolCallResult;
35
+ cleanUp(): void;
36
+ }
37
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,22 @@
1
+ declare class KnowledgeManagerImpl {
2
+ private ldManager;
3
+ private initialized;
4
+ init(): void;
5
+ addKnowledge(task: string): string;
6
+ enrichTask(task: string): Promise<string>;
7
+ search(query: string, topK?: number): Promise<string[]>;
8
+ addDocument(doc: string, metadata?: Record<string, unknown>): Promise<void>;
9
+ /**
10
+ * Incremental single-doc write (aligned with python knowledge_manager.write_knowledge).
11
+ * Delegates to LanceDBManager.addSingle (non-destructive + jsonl fallback).
12
+ */
13
+ writeKnowledge(doc: {
14
+ text: string;
15
+ category?: string;
16
+ source?: string;
17
+ }): void;
18
+ deleteCollection(): Promise<void>;
19
+ }
20
+ export declare const KnowledgeManager: KnowledgeManagerImpl;
21
+ export {};
22
+ //# sourceMappingURL=knowledge_manager.d.ts.map
@@ -0,0 +1,44 @@
1
+ export interface KnowledgeDoc {
2
+ id: string;
3
+ text: string;
4
+ metadata?: Record<string, unknown>;
5
+ vector?: number[];
6
+ }
7
+ export interface SearchResult {
8
+ doc: KnowledgeDoc;
9
+ score: number;
10
+ }
11
+ export declare class LanceDBManager {
12
+ private static _instance;
13
+ private static _initialized;
14
+ private dbPath;
15
+ private knowledgeDir;
16
+ private tableName;
17
+ private docs;
18
+ private docTokens;
19
+ private idf;
20
+ private constructor();
21
+ static getInstance(dbPath?: string, knowledgeDir?: string): LanceDBManager;
22
+ init(): void;
23
+ private rebuildIndex;
24
+ private loadFromStore;
25
+ private loadFromKnowledgeDir;
26
+ insertDocuments(docs: KnowledgeDoc[]): void;
27
+ addDocument(doc: KnowledgeDoc): void;
28
+ /**
29
+ * Incremental single-doc write (aligned with python vectordb.add_single).
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
+ addSingle(doc: KnowledgeDoc): void;
35
+ /** Append a single doc to `_pending.jsonl` (crash-safe fallback). */
36
+ private _writeJsonlFallback;
37
+ deleteCollection(): void;
38
+ searchRaw(query: string, limit?: number): KnowledgeDoc[];
39
+ searchWithScores(query: string, limit?: number): SearchResult[];
40
+ search(query: string, limit?: number): string;
41
+ getDocCount(): number;
42
+ private persist;
43
+ }
44
+ //# sourceMappingURL=vectordb.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { ConfigManager } from '../../common/config/manager';
2
+ import type { MCPDeviceAdapter, DevicePlatform } from './types';
3
+ export declare function createAdapterFromDeviceInfo(deviceInfo: {
4
+ platform: DevicePlatform;
5
+ deviceSn: string;
6
+ ip?: string;
7
+ port?: number;
8
+ }, configManager: ConfigManager): MCPDeviceAdapter;
9
+ export declare function detectDevicePlatform(deviceSn: string, config: Record<string, unknown>): DevicePlatform;
10
+ //# sourceMappingURL=adapter_factory.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { MCPDeviceAdapterBase } from './base_adapter';
2
+ import type { ServiceHealth, DevicePlatform } from './types';
3
+ import type { Screenshot } from '../device/types';
4
+ import { ConfigManager } from '../../common/config/manager';
5
+ export declare class AndroidMCPAdapter extends MCPDeviceAdapterBase {
6
+ readonly platform: DevicePlatform;
7
+ readonly adbPath: string;
8
+ private mcpProcess;
9
+ private mcpServerUrl;
10
+ private logFilePath;
11
+ private logStream;
12
+ private static readonly MCP_SERVICE_PORT;
13
+ private static readonly SCREENSHOT_TOOL_NAME;
14
+ private static readonly PRESS_BUTTON_TOOL;
15
+ constructor(adbPath: string | undefined, configManager: ConfigManager);
16
+ getDefaultServerUrl(): string;
17
+ getMcpServicePort(): number;
18
+ useSseTransport(): boolean;
19
+ startMcpService(): Promise<string>;
20
+ checkServiceHealth(serverUrl: string): Promise<ServiceHealth>;
21
+ killProcessByPort(port: number): Promise<void>;
22
+ callTool(toolName: string, args?: Record<string, unknown>, timeout?: number, retryOnFailure?: boolean): Promise<unknown>;
23
+ getScreenshot(): Promise<Screenshot>;
24
+ reset(): Promise<void>;
25
+ connect(): Promise<void>;
26
+ disconnect(): Promise<void>;
27
+ private closeLogStream;
28
+ private isPortListening;
29
+ }
30
+ //# sourceMappingURL=android_adapter.d.ts.map
@@ -0,0 +1,26 @@
1
+ import type { MCPDeviceAdapter, DevicePlatform, ServiceHealth } from './types';
2
+ import type { Screenshot } from '../device/types';
3
+ import { ConfigManager } from '../../common/config/manager';
4
+ export declare abstract class MCPDeviceAdapterBase implements MCPDeviceAdapter {
5
+ abstract readonly platform: DevicePlatform;
6
+ protected configManager: ConfigManager;
7
+ protected connected: boolean;
8
+ private _abortController;
9
+ constructor(configManager: ConfigManager);
10
+ abstract getDefaultServerUrl(): string;
11
+ abstract getMcpServicePort(): number;
12
+ abstract startMcpService(): Promise<string>;
13
+ abstract checkServiceHealth(serverUrl: string): Promise<ServiceHealth>;
14
+ abstract useSseTransport(): boolean;
15
+ abstract killProcessByPort(port: number): Promise<void>;
16
+ connect(): Promise<void>;
17
+ disconnect(): Promise<void>;
18
+ setAbortController(ac: AbortController | null): void;
19
+ isAborted(): boolean;
20
+ protected getCallSignal(timeoutMs: number): AbortSignal;
21
+ callTool(toolName: string, args?: Record<string, unknown>, timeout?: number, retryOnFailure?: boolean): Promise<unknown>;
22
+ getScreenshot(saveDir?: string): Promise<Screenshot>;
23
+ reset(): Promise<void>;
24
+ ensureServiceRunning(forceRestart?: boolean): Promise<void>;
25
+ }
26
+ //# sourceMappingURL=base_adapter.d.ts.map
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Pure-TypeScript HarmonyOS device adapter.
3
+ *
4
+ * Drives a connected HarmonyOS device directly through the local `hdc` CLI,
5
+ * reimplementing the MCP tool surface that `hypium_mcp` previously provided
6
+ * over HTTP. Coordinates arriving from the agent are relative 0.0~1.0 values
7
+ * and are scaled to absolute pixels using the real screen resolution captured
8
+ * from the device screenshots. Tool result messages report the original
9
+ * relative coordinates so they stay aligned with the LLM/agent output.
10
+ */
11
+ import { MCPDeviceAdapterBase } from './base_adapter';
12
+ import type { DevicePlatform, ServiceHealth } from './types';
13
+ import type { Screenshot } from '../device/types';
14
+ import { ConfigManager } from '../../common/config/manager';
15
+ export declare class HarmonyHdcAdapter extends MCPDeviceAdapterBase {
16
+ readonly platform: DevicePlatform;
17
+ private readonly hdcPath;
18
+ private readonly driver;
19
+ private readonly ip;
20
+ private readonly port;
21
+ private screenWidth;
22
+ private screenHeight;
23
+ private screenAlwaysOn;
24
+ private readonly deviceResetDevice;
25
+ private readonly deviceScreenAlwaysOn;
26
+ private readonly deviceOperationMode;
27
+ constructor(hdcPath: string, configManager: ConfigManager);
28
+ getDefaultServerUrl(): string;
29
+ getMcpServicePort(): number;
30
+ useSseTransport(): boolean;
31
+ startMcpService(): Promise<string>;
32
+ checkServiceHealth(_serverUrl: string): Promise<ServiceHealth>;
33
+ killProcessByPort(_port: number): Promise<void>;
34
+ connect(): Promise<void>;
35
+ disconnect(): Promise<void>;
36
+ getScreenshot(saveDir?: string): Promise<Screenshot>;
37
+ reset(): Promise<void>;
38
+ callTool(toolName: string, args?: Record<string, unknown>, _timeout?: number, _retryOnFailure?: boolean): Promise<unknown>;
39
+ private checkDeviceConnected;
40
+ private setScreenAlwaysOn;
41
+ private isDisplayLocked;
42
+ private getScreenSize;
43
+ private toAbsolute;
44
+ private fmt;
45
+ private extractPoint;
46
+ private keyNameToCode;
47
+ private clearRecentTasks;
48
+ }
49
+ //# sourceMappingURL=harmony_hdc_adapter.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { MCPDeviceAdapterBase } from './base_adapter';
2
+ import type { ServiceHealth, DevicePlatform } from './types';
3
+ import type { Screenshot } from '../device/types';
4
+ import { ConfigManager } from '../../common/config/manager';
5
+ export declare class IOSMCPAdapter extends MCPDeviceAdapterBase {
6
+ readonly platform: DevicePlatform;
7
+ readonly devicectlPath: string;
8
+ private mcpProcess;
9
+ private mcpServerUrl;
10
+ private logFilePath;
11
+ private logStream;
12
+ private static readonly MCP_SERVICE_PORT;
13
+ private static readonly SCREENSHOT_TOOL_NAME;
14
+ private static readonly PRESS_BUTTON_TOOL;
15
+ constructor(devicectlPath: string | undefined, configManager: ConfigManager);
16
+ getDefaultServerUrl(): string;
17
+ getMcpServicePort(): number;
18
+ useSseTransport(): boolean;
19
+ startMcpService(): Promise<string>;
20
+ checkServiceHealth(serverUrl: string): Promise<ServiceHealth>;
21
+ killProcessByPort(port: number): Promise<void>;
22
+ callTool(toolName: string, args?: Record<string, unknown>, timeout?: number, retryOnFailure?: boolean): Promise<unknown>;
23
+ getScreenshot(): Promise<Screenshot>;
24
+ reset(): Promise<void>;
25
+ connect(): Promise<void>;
26
+ disconnect(): Promise<void>;
27
+ private closeLogStream;
28
+ private isPortListening;
29
+ }
30
+ //# sourceMappingURL=ios_adapter.d.ts.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Local helper tools executed directly (not via the MCP protocol).
3
+ *
4
+ * Current tools:
5
+ * - wait: sleep for a number of seconds
6
+ * - load_skill: load skill step content from the skill manager
7
+ */
8
+ /**
9
+ * Wait for the given number of seconds.
10
+ * @param seconds Seconds to wait (e.g. 1, 2, 5).
11
+ * @returns A message confirming the wait completed.
12
+ */
13
+ export declare function wait(seconds: number): Promise<string>;
14
+ /**
15
+ * Load the detailed steps for a named skill.
16
+ * @param skillName The skill name to load.
17
+ * @returns The skill content, or a not-found message.
18
+ */
19
+ export declare function loadSkill(skillName: string): Promise<string>;
20
+ //# sourceMappingURL=local_tools.d.ts.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * MCP tool definitions for the agent.
3
+ *
4
+ * Registers async tool functions that drive the executor device (start/stop
5
+ * apps, navigation, waiting, skill loading, verification, etc.). Tools are
6
+ * collected into a registry so they can be enumerated and invoked by name.
7
+ */
8
+ /** A registered async tool function. */
9
+ export type ToolFunction = (...args: any[]) => Promise<string>;
10
+ /** Registry of all collected tool functions, keyed by name. */
11
+ export declare const TOOL_REGISTRY: Record<string, ToolFunction>;
12
+ /**
13
+ * Register a tool function into {@link TOOL_REGISTRY} and return it.
14
+ */
15
+ export declare function collectFunctionTool<T extends ToolFunction>(name: string, fn: T): T;
16
+ /** Get all registered tool functions. */
17
+ export declare function getRegisteredTools(): ToolFunction[];
18
+ export declare const chat: (message: string) => Promise<string>;
19
+ /** Get the mapping of supported app display names to bundle names. */
20
+ export declare function getPackageNameMap(): Promise<Record<string, string>>;
21
+ /** Start an app by display name or bundle name. */
22
+ export declare const startApp: (appName: string) => Promise<string>;
23
+ /** Stop an app by display name or bundle name. */
24
+ export declare const stopApp: (appName: string) => Promise<string>;
25
+ /** Clear an app's data to simulate a first-install state. */
26
+ export declare const clearApp: (appName: string) => Promise<string>;
27
+ /** Press the back button once. */
28
+ export declare const goBack: () => Promise<string>;
29
+ /** Press the back button twice. */
30
+ export declare const goBackTwice: () => Promise<string>;
31
+ /** Wait for a number of seconds. */
32
+ export declare const wait: (times: number) => Promise<string>;
33
+ /** Press the home button to return to the desktop. */
34
+ export declare const goHome: () => Promise<string>;
35
+ /** Login placeholder tool. */
36
+ export declare const login: () => Promise<string>;
37
+ /** Resolve the main ability name for a bundle name. */
38
+ export declare function getMainAbilityForBundle(bundleName: string): string;
39
+ /**
40
+ * Load the detailed steps for a named skill.
41
+ * @param skillName The skill name to load.
42
+ * @returns The skill content, or a not-found message.
43
+ */
44
+ export declare const loadSkill: (skillName: string) => Promise<string>;
45
+ /**
46
+ * Verify the task result based on recent execution history (screenshots + logs).
47
+ * @param verificationDescription What to verify.
48
+ * @returns JSON with `verified` (boolean) and `reason` (string).
49
+ */
50
+ export declare function verify(verificationDescription: string): Promise<string>;
51
+ //# sourceMappingURL=mcp_tools.d.ts.map