@autotest/agent 0.0.6 → 0.0.7

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 (153) hide show
  1. package/README.md +7 -0
  2. package/dist/api/agent_api.d.ts +2 -2
  3. package/dist/autotest-cli.js +1 -397
  4. package/dist/common/config/config.yaml +4 -0
  5. package/dist/common/config/manager.d.ts +4 -4
  6. package/dist/common/config/types.d.ts +5 -0
  7. package/dist/common/dfx/index.d.ts +1 -1
  8. package/dist/core/agent/single_agent/agent.d.ts +1 -0
  9. package/dist/core/device/device_protocol.d.ts +1 -1
  10. package/dist/core/knowledge/knowledge_manager.d.ts +3 -3
  11. package/dist/core/knowledge/vectordb.d.ts +5 -5
  12. package/dist/core/mcp/harmony_hdc_adapter.d.ts +1 -0
  13. package/dist/core/mcp/mcp_tools.d.ts +1 -0
  14. package/dist/core/mcp/verify_tool.d.ts +12 -0
  15. package/dist/core/prompt/templates/single/single_v2.0.md +15 -0
  16. package/dist/data_types/device.d.ts +1 -1
  17. package/dist/data_types/index.d.ts +1 -1
  18. package/dist/index.d.ts +4 -4
  19. package/dist/index.js +1 -163
  20. package/dist/tools/batch_runner.js +1 -745
  21. package/dist/tools/case_runner/runner.js +1 -410
  22. package/dist/tools/config/config_tool.js +1 -339
  23. package/dist/tools/prompt_compare/compare_runner.js +1 -360
  24. package/package.json +2 -2
  25. package/dist/api/agent_api.js +0 -550
  26. package/dist/api/autotest_agent.js +0 -205
  27. package/dist/api/types.js +0 -11
  28. package/dist/common/case_manager.js +0 -91
  29. package/dist/common/collect_case.js +0 -128
  30. package/dist/common/common_errors.js +0 -66
  31. package/dist/common/config/config_validator.js +0 -28
  32. package/dist/common/config/manager.js +0 -257
  33. package/dist/common/config/output.js +0 -59
  34. package/dist/common/config/types.js +0 -185
  35. package/dist/common/dfx/client_factory.js +0 -62
  36. package/dist/common/dfx/context.js +0 -23
  37. package/dist/common/dfx/index.js +0 -15
  38. package/dist/common/dfx/recorder.js +0 -191
  39. package/dist/common/dfx/recording_fetch.js +0 -228
  40. package/dist/common/dfx/source.js +0 -13
  41. package/dist/common/image_cacher.js +0 -36
  42. package/dist/common/image_helper.js +0 -128
  43. package/dist/common/image_similarity.js +0 -171
  44. package/dist/common/llm_cache/cache_transport.js +0 -102
  45. package/dist/common/llm_cache/prompt_cache.js +0 -113
  46. package/dist/common/logger.js +0 -158
  47. package/dist/common/model/custom_model.js +0 -487
  48. package/dist/common/model/index.js +0 -5
  49. package/dist/common/path_utils.js +0 -88
  50. package/dist/common/result_parser.js +0 -49
  51. package/dist/common/usage/token_usage.js +0 -117
  52. package/dist/common/utils.js +0 -125
  53. package/dist/core/agent/layered_agent/ability_helper.js +0 -125
  54. package/dist/core/agent/layered_agent/agent.js +0 -37
  55. package/dist/core/agent/layered_agent/agent_registry.js +0 -82
  56. package/dist/core/agent/layered_agent/decision.js +0 -518
  57. package/dist/core/agent/layered_agent/execute_agent/action_handler.js +0 -155
  58. package/dist/core/agent/layered_agent/execute_agent/agent_factory.js +0 -41
  59. package/dist/core/agent/layered_agent/execute_agent/base_agent.js +0 -112
  60. package/dist/core/agent/layered_agent/execute_agent/general_agent.js +0 -207
  61. package/dist/core/agent/layered_agent/execute_agent/glm_agent.js +0 -241
  62. package/dist/core/agent/layered_agent/execute_agent/i18n.js +0 -34
  63. package/dist/core/agent/layered_agent/execute_agent/index.js +0 -67
  64. package/dist/core/agent/layered_agent/execute_agent/mai_ui_agent.js +0 -316
  65. package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.js +0 -154
  66. package/dist/core/agent/layered_agent/execute_agent/parser/general_parser.js +0 -243
  67. package/dist/core/agent/layered_agent/execute_agent/parser/glm_parser.js +0 -139
  68. package/dist/core/agent/layered_agent/execute_agent/parser/index.js +0 -9
  69. package/dist/core/agent/layered_agent/execute_agent/parser/mai_ui_parser.js +0 -94
  70. package/dist/core/agent/layered_agent/execute_agent/prompts.js +0 -109
  71. package/dist/core/agent/layered_agent/execute_agent/simple_reporter.js +0 -33
  72. package/dist/core/agent/layered_agent/execute_agent/utils.js +0 -52
  73. package/dist/core/agent/report_analyzer_agent/agent.js +0 -565
  74. package/dist/core/agent/report_analyzer_agent/config.js +0 -22
  75. package/dist/core/agent/report_analyzer_agent/data_loader.js +0 -255
  76. package/dist/core/agent/report_analyzer_agent/guardrails.js +0 -99
  77. package/dist/core/agent/report_analyzer_agent/hooks.js +0 -31
  78. package/dist/core/agent/report_analyzer_agent/index.js +0 -52
  79. package/dist/core/agent/report_analyzer_agent/key_steps_builder.js +0 -42
  80. package/dist/core/agent/report_analyzer_agent/mapping.js +0 -133
  81. package/dist/core/agent/report_analyzer_agent/parse.js +0 -375
  82. package/dist/core/agent/report_analyzer_agent/prompt.js +0 -300
  83. package/dist/core/agent/report_analyzer_agent/report_writer.js +0 -558
  84. package/dist/core/agent/report_analyzer_agent/tools.js +0 -150
  85. package/dist/core/agent/report_analyzer_agent/types.js +0 -274
  86. package/dist/core/agent/rewrite_agent/agent.js +0 -209
  87. package/dist/core/agent/rewrite_agent/guardrails.js +0 -95
  88. package/dist/core/agent/rewrite_agent/mapping.js +0 -56
  89. package/dist/core/agent/rewrite_agent/parse.js +0 -121
  90. package/dist/core/agent/rewrite_agent/types.js +0 -37
  91. package/dist/core/agent/single_agent/agent.js +0 -801
  92. package/dist/core/agent/single_agent/hook_manager.js +0 -59
  93. package/dist/core/agent/single_agent/hooks.js +0 -288
  94. package/dist/core/agent/single_agent/image_utils.js +0 -158
  95. package/dist/core/agent/single_agent/scroll_search_agent.js +0 -405
  96. package/dist/core/agent/single_agent/subagent_manager.js +0 -72
  97. package/dist/core/agent/single_agent/tool_recorder_hook.js +0 -42
  98. package/dist/core/agent/types.js +0 -2
  99. package/dist/core/agent/utils/message_builder.js +0 -138
  100. package/dist/core/device/device_protocol.js +0 -2
  101. package/dist/core/device/hdc/apps.js +0 -437
  102. package/dist/core/device/hdc/device.js +0 -219
  103. package/dist/core/device/hdc/index.js +0 -31
  104. package/dist/core/device/hdc/input.js +0 -74
  105. package/dist/core/device/hdc/screenshot.js +0 -171
  106. package/dist/core/device/index.js +0 -70
  107. package/dist/core/device/types.js +0 -2
  108. package/dist/core/knowledge/knowledge_manager.js +0 -70
  109. package/dist/core/knowledge/vectordb.js +0 -283
  110. package/dist/core/mcp/adapter_factory.js +0 -99
  111. package/dist/core/mcp/android_adapter.js +0 -286
  112. package/dist/core/mcp/base_adapter.js +0 -86
  113. package/dist/core/mcp/harmony_hdc_adapter.js +0 -798
  114. package/dist/core/mcp/ios_adapter.js +0 -286
  115. package/dist/core/mcp/local_tools.js +0 -41
  116. package/dist/core/mcp/mcp_tools.js +0 -473
  117. package/dist/core/mcp/types.js +0 -6
  118. package/dist/core/memory/_utils.js +0 -140
  119. package/dist/core/memory/compressed_session.js +0 -182
  120. package/dist/core/memory/context_compressor.js +0 -176
  121. package/dist/core/memory/index.js +0 -22
  122. package/dist/core/memory/memory_manager.js +0 -28
  123. package/dist/core/memory/reflector.js +0 -95
  124. package/dist/core/memory/replan_manager.js +0 -12
  125. package/dist/core/memory/session_factory.js +0 -29
  126. package/dist/core/memory/tool_player.js +0 -225
  127. package/dist/core/memory/tool_player_popup.js +0 -276
  128. package/dist/core/memory/tool_player_replan.js +0 -226
  129. package/dist/core/memory/tool_player_xpath.js +0 -139
  130. package/dist/core/memory/tool_recorder.js +0 -126
  131. package/dist/core/preprocessor/task_splitter.js +0 -112
  132. package/dist/core/prompt/prompt_loader.js +0 -315
  133. package/dist/core/skill/skill_manager.js +0 -302
  134. package/dist/data_types/action.js +0 -2
  135. package/dist/data_types/agent.js +0 -2
  136. package/dist/data_types/case.js +0 -57
  137. package/dist/data_types/device.js +0 -2
  138. package/dist/data_types/index.js +0 -11
  139. package/dist/data_types/report.js +0 -6
  140. package/dist/data_types/screen.js +0 -23
  141. package/dist/data_types/task.js +0 -2
  142. package/dist/loop/cli.js +0 -127
  143. package/dist/loop/orchestrator.js +0 -314
  144. package/dist/loop/result_writer.js +0 -260
  145. package/dist/loop/types.js +0 -82
  146. package/dist/mcp-server/server.js +0 -341
  147. package/dist/mcp-server/types.js +0 -224
  148. package/dist/reporter/batch_summary.js +0 -197
  149. package/dist/reporter/generator.js +0 -286
  150. package/dist/reporter/html_template/index.js +0 -529
  151. package/dist/reporter/json_report.js +0 -6
  152. package/dist/reporter/types.js +0 -45
  153. package/dist/tools/case_runner/report.js +0 -264
@@ -1,437 +0,0 @@
1
- "use strict";
2
- /**
3
- * HarmonyOS application package name mappings.
4
- *
5
- * Maps user-friendly app display names to HarmonyOS bundle names.
6
- * These bundle names are used with the `hdc shell aa start -b <bundle>` command.
7
- *
8
- * NOTE: The display-name keys are real app names reported by the device and are
9
- * intentionally kept in their original language (domain data, not code strings).
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.BUNDLE_NAME_TO_APP_NAME = exports.TOP_225_APP = exports.APP_PACKAGES = exports.APP_ABILITIES = void 0;
13
- exports.getPackageName = getPackageName;
14
- exports.getAppName = getAppName;
15
- exports.listSupportedApps = listSupportedApps;
16
- /**
17
- * Custom ability names for apps that don't use the default "EntryAbility".
18
- * Maps bundle_name -> ability_name.
19
- */
20
- exports.APP_ABILITIES = {
21
- 'com.xuncorp.sp': 'EntryAbility',
22
- 'com.example.saltplayerharmony': 'EntryAbility',
23
- 'cn.wps.mobileoffice.hap': 'DocumentAbility',
24
- 'com.ccb.mobilebank.hm': 'CcbMainAbility',
25
- 'com.dewu.hos': 'HomeAbility',
26
- 'com.larus.nova.hm': 'MainAbility',
27
- 'com.luna.hm.music': 'MainAbility',
28
- 'com.meitu.meitupic': 'MainAbility',
29
- 'com.ss.hm.article.news': 'MainAbility',
30
- 'com.ss.hm.ugc.aweme': 'MainAbility',
31
- 'com.taobao.taobao4hmos': 'Taobao_mainAbility',
32
- 'com.tencent.videohm': 'AppAbility',
33
- 'com.ximalaya.ting.xmharmony': 'MainBundleAbility',
34
- 'com.zhihu.hmos': 'PhoneAbility',
35
- 'com.huawei.hmos.browser': 'MainAbility',
36
- 'com.huawei.hmos.calculator': 'com.huawei.hmos.calculator.CalculatorAbility',
37
- 'com.huawei.hmos.calendar': 'MainAbility',
38
- 'com.huawei.hmos.camera': 'com.huawei.hmos.camera.MainAbility',
39
- 'com.huawei.hmos.clock': 'com.huawei.hmos.clock.phone',
40
- 'com.huawei.hmos.clouddrive': 'MainAbility',
41
- 'com.huawei.hmos.email': 'ApplicationAbility',
42
- 'com.huawei.hmos.filemanager': 'MainAbility',
43
- 'com.huawei.hmos.health': 'Activity_card_entryAbility',
44
- 'com.huawei.hmos.notepad': 'MainAbility',
45
- 'com.huawei.hmos.photos': 'com.huawei.hmos.photos.MainAbility',
46
- 'com.huawei.hmos.screenrecorder': 'com.huawei.hmos.screenrecorder.ServiceExtAbility',
47
- 'com.huawei.hmos.screenshot': 'com.huawei.hmos.screenshot.ServiceExtAbility',
48
- 'com.huawei.hmos.settings': 'com.huawei.hmos.settings.MainAbility',
49
- 'com.huawei.hmos.soundrecorder': 'MainAbility',
50
- 'com.huawei.hmos.vassistant': 'AiCaptionServiceExtAbility',
51
- 'com.huawei.hmos.vmall': 'EntranceAbility',
52
- 'com.huawei.hmos.wallet': 'MainAbility',
53
- 'com.huawei.hmsapp.appgallery': 'MainAbility',
54
- 'com.huawei.hmsapp.books': 'MainAbility',
55
- 'com.huawei.hmsapp.himovie': 'MainAbility',
56
- 'com.huawei.hmsapp.hisearch': 'MainAbility',
57
- 'com.huawei.hmsapp.music': 'MainAbility',
58
- 'com.huawei.hmsapp.thememanager': 'MainAbility',
59
- 'com.huawei.hmsapp.totemweather': 'com.huawei.hmsapp.totemweather.MainAbility',
60
- 'com.ohos.callui': 'com.ohos.callui.ServiceAbility',
61
- 'com.ohos.contacts': 'com.ohos.contacts.MainAbility',
62
- 'com.ohos.mms': 'com.ohos.mms.MainAbility',
63
- };
64
- /** Maps display app names to HarmonyOS bundle names. */
65
- exports.APP_PACKAGES = {
66
- '\u5fae\u4fe1': 'com.tencent.wechat',
67
- QQ: 'com.tencent.mqq',
68
- '\u5fae\u535a': 'com.sina.weibo.stage',
69
- '\u6dd8\u5b9d': 'com.taobao.taobao4hmos',
70
- '\u4eac\u4e1c': 'com.jd.hm.mall',
71
- '\u62fc\u591a\u591a': 'com.xunmeng.pinduoduo.hos',
72
- '\u5fae\u4fe1\u8bfb\u4e66': 'com.tencent.weread.hmos',
73
- '\u54d4\u54e9\u54d4\u54e9': 'yylx.danmaku.bili',
74
- '\u6296\u97f3': 'com.ss.hm.ugc.aweme',
75
- '\u5feb\u624b': 'com.kuaishou.hmapp',
76
- '\u817e\u8baf\u89c6\u9891': 'com.tencent.videohm',
77
- '\u7231\u5947\u827a': 'com.qiyi.video.hmy',
78
- '\u8292\u679cTV': 'com.mgtv.phone',
79
- 'QQ\u97f3\u4e50': 'com.tencent.hm.qqmusic',
80
- '\u6c7c\u6c34\u97f3\u4e50': 'com.luna.hm.music',
81
- '\u559c\u9a6c\u62c9\u96c5': 'com.ximalaya.ting.xmharmony',
82
- '\u98de\u4e66': 'com.ss.feishu',
83
- '\u8c46\u5305': 'com.larus.nova.hm',
84
- '\u4eca\u65e5\u5934\u6761': 'com.ss.hm.article.news',
85
- SaltPlayer: 'com.example.saltplayerharmony',
86
- '\u767e\u5ea6': 'com.baidu.baiduapp',
87
- '\u963f\u91cc\u5df4\u5df4': 'com.alibaba.wireless_hmos',
88
- WPS: 'cn.wps.mobileoffice.hap',
89
- '\u4f01\u4e1a\u5fae\u4fe1': 'com.tencent.wework.hmos',
90
- '\u540c\u7a0b': 'com.tongcheng.hmos',
91
- '\u540c\u7a0b\u65c5\u884c': 'com.tongcheng.hmos',
92
- '\u552f\u54c1\u4f1a': 'com.vip.hosapp',
93
- '\u652f\u4ed8\u5b9d': 'com.alipay.mobile.client',
94
- 'UC\u6d4f\u89c8\u5668': 'com.uc.mobile',
95
- '\u95f2\u9c7c': 'com.taobao.idlefish4ohos',
96
- '\u8f6c\u8f6c': 'com.zhuanzhuan.hmoszz',
97
- '\u8fc5\u96f7': 'com.xunlei.thunder',
98
- '\u626b\u63cf\u5168\u80fd\u738b': 'com.intsig.camscanner.hap',
99
- '\u7f8e\u56fe\u79c0\u79c0': 'com.meitu.meitupic',
100
- '58\u540c\u57ce': 'com.wuba.life',
101
- '\u5f97\u7269': 'com.dewu.hos',
102
- '\u6d77\u5e95\u635e': 'com.haidilao.haros',
103
- '\u4e2d\u56fd\u79fb\u52a8': 'com.droi.tong',
104
- '\u4e2d\u56fd\u8054\u901a': 'com.sinovatech.unicom.ha',
105
- '\u56fd\u5bb6\u7a0e\u52a1\u603b\u5c40': 'cn.gov.chinatax.gt4.hm',
106
- '\u5efa\u8bbe\u94f6\u884c': 'com.ccb.mobilebank.hm',
107
- '\u5feb\u624b\u6781\u901f\u7248': 'com.kuaishou.hmnebula',
108
- '\u897f\u74dc\u89c6\u9891': 'com.ss.hm.article.video',
109
- '\u6d4f\u89c8\u5668': 'com.huawei.hmos.browser',
110
- '\u8ba1\u7b97\u5668': 'com.huawei.hmos.calculator',
111
- '\u65e5\u5386': 'com.huawei.hmos.calendar',
112
- '\u76f8\u673a': 'com.huawei.hmos.camera',
113
- '\u65f6\u949f': 'com.huawei.hmos.clock',
114
- '\u95f9\u949f': 'com.huawei.hmos.clock',
115
- '\u4e91\u76d8': 'com.huawei.hmos.clouddrive',
116
- '\u4e91\u7a7a\u95f4': 'com.huawei.hmos.clouddrive',
117
- '\u90ae\u4ef6': 'com.huawei.hmos.email',
118
- '\u6587\u4ef6\u7ba1\u7406\u5668': 'com.huawei.hmos.filemanager',
119
- '\u6587\u4ef6': 'com.huawei.hmos.files',
120
- '\u67e5\u627e\u8bbe\u5907': 'com.huawei.hmos.finddevice',
121
- '\u67e5\u627e\u624b\u673a': 'com.huawei.hmos.finddevice',
122
- '\u5f55\u97f3\u673a': 'com.huawei.hmos.soundrecorder',
123
- '\u5f55\u97f3': 'com.huawei.hmos.soundrecorder',
124
- '\u5f55\u5c4f': 'com.huawei.hmos.screenrecorder',
125
- '\u622a\u5c4f': 'com.huawei.hmos.screenshot',
126
- '\u7b14\u8bb0': 'com.huawei.hmos.notepad',
127
- '\u5907\u5fd8\u5f55': 'com.huawei.hmos.notepad',
128
- '\u76f8\u518c': 'com.huawei.hmos.photos',
129
- '\u56fe\u5e93': 'com.huawei.hmos.photos',
130
- '\u8054\u7cfb\u4eba': 'com.ohos.contacts',
131
- '\u901a\u8baf\u5f55': 'com.ohos.contacts',
132
- '\u77ed\u4fe1': 'com.ohos.mms',
133
- '\u4fe1\u606f': 'com.ohos.mms',
134
- '\u7535\u8bdd': 'com.ohos.callui',
135
- '\u62e8\u53f7': 'com.ohos.callui',
136
- '\u8bbe\u7f6e': 'com.huawei.hmos.settings',
137
- '\u7cfb\u7edf\u8bbe\u7f6e': 'com.huawei.hmos.settings',
138
- AndroidSystemSettings: 'com.huawei.hmos.settings',
139
- 'Android System Settings': 'com.huawei.hmos.settings',
140
- 'Android System Settings': 'com.huawei.hmos.settings',
141
- 'Android-System-Settings': 'com.huawei.hmos.settings',
142
- Settings: 'com.huawei.hmos.settings',
143
- '\u5065\u5eb7': 'com.huawei.hmos.health',
144
- '\u8fd0\u52a8\u5065\u5eb7': 'com.huawei.hmos.health',
145
- '\u5730\u56fe': 'com.huawei.hmos.maps.app',
146
- '\u534e\u4e3a\u5730\u56fe': 'com.huawei.hmos.maps.app',
147
- '\u94b1\u5305': 'com.huawei.hmos.wallet',
148
- '\u534e\u4e3a\u94b1\u5305': 'com.huawei.hmos.wallet',
149
- '\u667a\u6167\u751f\u6d3b': 'com.huawei.hmos.ailife',
150
- '\u667a\u80fd\u52a9\u624b': 'com.huawei.hmos.vassistant',
151
- '\u5c0f\u827a': 'com.huawei.hmos.vassistant',
152
- '\u534e\u4e3a\u5546\u57ce': 'com.huawei.hmos.vmall',
153
- '\u5e94\u7528\u5e02\u573a': 'com.huawei.hmsapp.appgallery',
154
- '\u534e\u4e3a\u5e94\u7528\u5e02\u573a': 'com.huawei.hmsapp.appgallery',
155
- '\u97f3\u4e50': 'com.huawei.hmsapp.music',
156
- 'Salt Player': 'com.xuncorp.sp',
157
- '\u534e\u4e3a\u97f3\u4e50': 'com.huawei.hmsapp.music',
158
- '\u4e3b\u9898': 'com.huawei.hmsapp.thememanager',
159
- '\u4e3b\u9898\u7ba1\u7406': 'com.huawei.hmsapp.thememanager',
160
- '\u5929\u6c14': 'com.huawei.hmsapp.totemweather',
161
- '\u534e\u4e3a\u5929\u6c14': 'com.huawei.hmsapp.totemweather',
162
- '\u89c6\u9891': 'com.huawei.hmsapp.himovie',
163
- '\u534e\u4e3a\u89c6\u9891': 'com.huawei.hmsapp.himovie',
164
- '\u9605\u8bfb': 'com.huawei.hmsapp.books',
165
- '\u534e\u4e3a\u9605\u8bfb': 'com.huawei.hmsapp.books',
166
- '\u6e38\u620f\u4e2d\u5fc3': 'com.huawei.hmsapp.gamecenter',
167
- '\u534e\u4e3a\u6e38\u620f\u4e2d\u5fc3': 'com.huawei.hmsapp.gamecenter',
168
- '\u641c\u7d22': 'com.huawei.hmsapp.hisearch',
169
- '\u534e\u4e3a\u641c\u7d22': 'com.huawei.hmsapp.hisearch',
170
- '\u6307\u5357\u9488': 'com.huawei.hmsapp.compass',
171
- '\u4f1a\u5458\u4e2d\u5fc3': 'com.huawei.hmos.myhuawei',
172
- '\u6211\u7684\u534e\u4e3a': 'com.huawei.hmos.myhuawei',
173
- '\u534e\u4e3a\u4f1a\u5458': 'com.huawei.hmos.myhuawei',
174
- '\u9ad8\u5fb7\u5730\u56fe': 'com.amap.hmapp',
175
- '\u767e\u5ea6\u5730\u56fe': 'com.baidu.hmmap',
176
- '\u7f8e\u56e2': 'com.sankuai.hmeituan',
177
- '\u7f8e\u56e2\u5916\u5356': 'com.meituan.takeaway',
178
- '\u5927\u4f17\u70b9\u8bc4': 'com.sankuai.dianping',
179
- '\u94c1\u8def12306': 'com.chinarailway.ticketingHM',
180
- '12306': 'com.chinarailway.ticketingHM',
181
- '\u6ef4\u6ef4\u51fa\u884c': 'com.sdu.didi.hmos.psnger',
182
- '\u5c0f\u7ea2\u4e66': 'com.xingin.xhs_hos',
183
- '\u77e5\u4e4e': 'com.zhihu.hmos',
184
- '\u4e0a\u6d77': 'com.droi.tong',
185
- };
186
- /** Extended app-name to bundle-name mappings for a broader app catalog. */
187
- exports.TOP_225_APP = {
188
- '360AI\u529e\u516c': 'com.qihoo.aiwork.hms',
189
- '360\u6d4f\u89c8\u5668': 'com.qihoo.hms.browser',
190
- '58\u540c\u57ce': 'com.wuba.life',
191
- 'BOSS\u76f4\u8058': 'com.bzl.bosszhipin',
192
- 'CAD\u5feb\u901f\u770b\u56fe': 'com.yuntu.cadreader',
193
- 'CAD\u770b\u56fe\u738b': 'com.gstarcad.hmos.mobile',
194
- Keep: 'com.gotokeep.hm.keep',
195
- Kimi: 'com.hos.moonshot.kimichat',
196
- QQ: 'com.tencent.mqq',
197
- 'QQ\u6d4f\u89c8\u5668': 'com.tencent.mtthm',
198
- 'QQ\u90ae\u7bb1': 'com.tencent.qqmail.hmos',
199
- 'QQ\u9605\u8bfb': 'com.yuewen.qqreaderhm',
200
- 'QQ\u97f3\u4e50': 'com.tencent.hm.qqmusic',
201
- 'T3\u51fa\u884c': 'hos.com.t3go.passenger',
202
- 'UC\u6d4f\u89c8\u5668': 'com.uc.mobile',
203
- 'WPS\u79fb\u52a8\u7248': 'cn.wps.mobileoffice.hap',
204
- YY: 'com.yy.mobile',
205
- 'e\u5145\u7535': 'com.sgcc.evs.charge',
206
- '\u4e03\u732b\u514d\u8d39\u5c0f\u8bf4': 'com.qimao.novel',
207
- '\u4e0b\u53a8\u623f': 'com.xiachufang',
208
- '\u4e1c\u65b9\u822a\u7a7a': 'com.ceair.hos',
209
- '\u4e1c\u65b9\u8d22\u5bcc': 'com.eastmoney.hmn.berlin',
210
- '\u4e2d\u4fe1\u94f6\u884c': 'cn.citicbank.wap',
211
- '\u4e2d\u56fd\u519c\u4e1a\u94f6\u884c': 'com.bankabc.openharmonyapp.release',
212
- '\u4e2d\u56fd\u5de5\u5546\u94f6\u884c': 'com.icbc.harmonyclient',
213
- '\u4e2d\u56fd\u5efa\u8bbe\u94f6\u884c': 'com.ccb.mobilebank.hm',
214
- '\u4e2d\u56fd\u7535\u4fe1': 'com.example.ctclient',
215
- '\u4e2d\u56fd\u79fb\u52a8': 'com.chinamobile.cmcc',
216
- '\u4e2d\u56fd\u79fb\u52a8\u4e91\u76d8': 'com.chinamobile.hosmcloud',
217
- '\u4e2d\u56fd\u8054\u901a': 'com.sinovatech.unicom.ha',
218
- '\u4e2d\u56fd\u94f6\u6cb3\u8bc1\u5238': 'cn.com.chinastock.stock',
219
- '\u4e2d\u56fd\u94f6\u884c': 'com.boc.bocsoft.mbs.personal',
220
- '\u4e2d\u6cb9\u597d\u5ba2e\u7ad9': 'com.sunboxsoft.charge.institute',
221
- '\u4e66\u65d7\u5c0f\u8bf4': 'com.shuqi.hmos',
222
- '\u4e70\u5355\u5427': 'com.bankcomm.app.maidanba',
223
- '\u4e91\u95ea\u4ed8': 'com.unionpay.hmos.wallet',
224
- '\u4ea4\u901a\u94f6\u884c': 'com.bankcomm.mobshos',
225
- '\u4eac\u4e1c': 'com.jd.hm.mall',
226
- '\u4eac\u4e1c\u91d1\u878d': 'com.jd.jrapp.hongmeng',
227
- '\u4eb2\u5b9d\u5b9d': 'com.dw.btimeharmony',
228
- '\u4eba\u6c11\u65e5\u62a5': 'com.peopledailychina.hosactivity',
229
- '\u4eca\u65e5\u5934\u6761': 'com.ss.hm.article.news',
230
- '\u4eca\u65e5\u6c34\u5370\u76f8\u673a': 'com.jinrishuiyinxiangji.camera',
231
- '\u4f01\u67e5\u67e5': 'com.qcc.hm',
232
- '\u4f18\u9177\u89c6\u9891': 'com.youku.next',
233
- '\u4f5c\u4e1a\u5e2e': 'com.zuoyebang.homework',
234
- '\u513f\u6b4c\u591a\u591a': 'com.duoduo.hm.erge',
235
- '\u5149\u5927\u94f6\u884c': 'com.cebbank.mobile.cembhmwork',
236
- '\u5168\u6c11K\u6b4c': 'com.tencent.karaokehm',
237
- '\u5174\u4e1a\u8bc1\u5238\u4f18\u7406\u5b9d': 'com.xyzq.harmonynext.ulbclient',
238
- '\u5174\u4e1a\u94f6\u884c': 'com.cib.cibmbhmos.proddev',
239
- '\u51e4\u51f0\u65b0\u95fb': 'com.ifeng.news.hmos',
240
- '\u51ef\u53d4\u8bb2\u6545\u4e8b': 'com.ks.ukstorynext',
241
- '\u526a\u6620': 'com.lemon.hm.lv',
242
- '\u52a8\u5361\u7a7a\u95f4': 'com.citiccard.ohap.dkkj',
243
- '\u534e\u4f4f\u4f1a': 'huazhuhui_default_0.0.1',
244
- '\u534e\u590f\u94f6\u884c': 'com.hxb.mobile.hm',
245
- '\u5357\u65b9\u822a\u7a7a': 'com.csair.mbphm',
246
- '\u53bb\u54ea\u513f\u65c5\u884c': 'com.qunar.hos',
247
- '\u540c\u7a0b\u65c5\u884c': 'com.tongcheng.hmos',
248
- '\u540c\u82b1\u987a': 'com.hexin.hmn.sjcg',
249
- '\u54aa\u5495\u89c6\u9891': 'com.cmcc.cmvideohm',
250
- '\u54c8\u5570': 'com.hellobike.app',
251
- '\u5531\u54e9\u5531\u54e9': 'yylx.danmaku.bili',
252
- '\u552f\u54c1\u4f1a': 'com.vip.hosapp',
253
- '\u559c\u9a6c\u62c9\u96c5': 'com.ximalaya.ting.xmharmony',
254
- '\u5600\u54d2\u51fa\u884c': 'com.didapinche.passenger',
255
- '\u56db\u5ddd\u822a\u7a7a': 'cn.com.scal.sichuanair',
256
- '\u56de\u68ee': 'com.hisense.app',
257
- '\u56fd\u6cf0\u541b\u5b89\u541b\u5f18': 'com.gtja.junhong.hm.next',
258
- '\u58a8\u8ff9\u5929\u6c14': 'com.moji.hmweather',
259
- '\u5927\u4f17\u70b9\u8bc4': 'com.sankuai.dianping',
260
- '\u5927\u5b66\u641c\u9898\u9171': 'com.daxuesoutijiang.hm',
261
- '\u5927\u667a\u6167': 'com.gw.ohphone',
262
- '\u5927\u9ea6': 'cn.damai.hongmeng',
263
- '\u5929\u732b': 'com.tmall.tmall4hmos',
264
- '\u5929\u773c\u67e5': 'com.tianyancha.skyeye.hm',
265
- '\u592e\u5e7f\u7f51': 'cn.cnr.cnrnetohos',
266
- '\u592e\u89c6\u5f71\u97f3': 'com.cctv.cbox',
267
- '\u592e\u89c6\u65b0\u95fb': 'cn.cctvnews.hm',
268
- '\u592e\u89c6\u9891': 'com.cctv.yangshipin.app.harmonyp',
269
- '\u5938\u514b\u6709\u7231': 'com.quark.ohosbrowser.lover',
270
- '\u597d\u770b\u89c6\u9891': 'com.baidu.haokanapp',
271
- '\u5b66\u4e60\u901a': 'com.xuexitong.study',
272
- '\u5b89\u5c45\u5ba2': 'com.anjuke.home',
273
- '\u5b9d\u5b9d\u5df4\u58eb': 'com.sinyee.babybus.recommendapp.hos',
274
- '\u5b9d\u5b9d\u5df4\u58eb\u4e16\u754c': 'com.sinyee.babybus.world.hos',
275
- '\u5c0f\u733fAI': 'com.kanyun.hos.leo',
276
- '\u5c0f\u733f\u641c\u9898': 'com.kanyun.hos.solar',
277
- '\u5c0f\u7ea2\u4e66': 'com.xingin.xhs_hos',
278
- '\u5c0f\u9e45\u901a\u5b66\u5458\u7248': 'com.xiaoe.client.huawei',
279
- '\u5e06\u4e66': 'com.fanshu.book',
280
- '\u5e73\u5b89\u53e3\u888b\u94f6\u884c': 'com.pingan.bank.pocket',
281
- '\u5e73\u5b89\u597d\u8f66\u4e3b': 'com.pingan.oharm.carowner',
282
- '\u5e73\u5b89\u91d1\u7ba1\u5bb6': 'com.pingan.palifeapp',
283
- '\u5f97\u7269': 'com.dewu.hos',
284
- '\u5fae\u4fe1': 'com.tencent.wechat',
285
- '\u5fae\u4fe1\u8bfb\u4e66': 'com.tencent.weread.hmos',
286
- '\u5fae\u535a': 'com.sina.weibo.stage',
287
- '\u5feb\u5bf9': 'com.kuaiduizuoye.hm',
288
- '\u5feb\u5f71': 'com.kwai.videoeditor.hmapp',
289
- '\u61c2\u8f66\u5e1d': 'com.ss.dcar.auto',
290
- '\u61d2\u4eba\u542c\u4e66': 'bubei.tingshu.hos',
291
- '\u626b\u63cf\u5168\u80fd\u738b': 'com.intsig.camscanner.hap',
292
- '\u6296\u97f3': 'com.ss.hm.ugc.aweme',
293
- '\u62db\u5546\u94f6\u884c': 'com.cmbchina.harmony',
294
- '\u62fc\u591a\u591a': 'com.xunmeng.pinduoduo.hos',
295
- '\u638c\u4e0a\u534e\u533b': 'com.huayi.zshy',
296
- '\u638c\u4e0a\u751f\u6d3b': 'com.cmbchina.ccc.cmblife',
297
- '\u641c\u72d0\u65b0\u95fb': 'com.sohu.harmonynews',
298
- '\u641c\u72d7\u8f93\u5165\u6cd5': 'com.sogou.input',
299
- '\u6434\u7a0b\u65c5\u884c': 'com.ctrip.harmonynext',
300
- '\u652f\u4ed8\u5b9d': 'com.alipay.mobile.client',
301
- '\u653f\u52a1\u5fae\u4fe1': 'com.tencent.weworklocal.hmos',
302
- '\u65b0\u534e\u793e': 'net.xinhuamm.xhshos',
303
- '\u65b0\u6d6a\u65b0\u95fb': 'com.sina.news.hm.next',
304
- '\u6613\u8f66': 'com.yiche.autoeasyh',
305
- '\u664b\u6c5f\u5c0f\u8bf4\u9605\u8bfb': 'com.jjwxc.jjharmony.reader',
306
- '\u667a\u884c\u706b\u8f66\u7968': 'com.suanya.harmonynext',
307
- '\u6734\u6734\u8d85\u5e02': 'com.pupu.app',
308
- '\u6c11\u751f\u94f6\u884c': 'cn.com.cmbc.ohmbank',
309
- '\u6c7c\u6c34\u97f3\u4e50': 'com.luna.hm.music',
310
- '\u6c7d\u8f66\u4e4b\u5bb6': 'com.autohome.main',
311
- '\u6d2a\u6069\u8bc6\u5b57': 'com.ihuman.words',
312
- '\u6d59\u91cc\u529e': 'com.szzj.zlb',
313
- '\u6d66\u53d1\u94f6\u884c': 'cn.com.spdb.mobilebank.hos.per',
314
- '\u6d77\u5357\u822a\u7a7a': 'com.hnair.app',
315
- '\u6da8\u4e50\u8d22\u5bcc\u901a': 'com.htsc.zlcft.org',
316
- '\u6dd8\u5b9d': 'com.taobao.taobao4hmos',
317
- '\u6dd8\u5b9d\u7279\u4ef7\u7248': 'com.taobao.litetao4harmony',
318
- '\u6df1\u5733\u822a\u7a7a': 'com.sz.air.hmOS',
319
- '\u6ef4\u6ef4\u51fa\u884c': 'com.sdu.didi.hmos.psnger',
320
- '\u70b9\u6dd8': 'com.taobao.taobaolive4hmos',
321
- '\u7231\u5947\u827a': 'com.qiyi.video.hmy',
322
- '\u745e\u5e78\u5496\u5561': 'com.lucky.luckincoffee',
323
- '\u74dc\u5b50\u4e8c\u624b\u8f66': 'com.ganji.android.haoche_c',
324
- '\u756a\u8304\u514d\u8d39\u5c0f\u8bf4': 'com.dragon.read.next',
325
- '\u756a\u8304\u7545\u542c': 'com.xs.fm.next',
326
- '\u767e\u5ea6': 'com.baidu.baiduapp',
327
- '\u767e\u5ea6\u5730\u56fe': 'com.baidu.hmmap',
328
- '\u767e\u5ea6\u6587\u5e93': 'com.baidu.hmwenku',
329
- '\u767e\u5ea6\u7f51\u76d8': 'com.baidu.netdisk.hmos',
330
- '\u767e\u5ea6\u8d34\u5427': 'com.baidu.tiebaapp',
331
- '\u767e\u5ea6\u8f93\u5165\u6cd5': 'com.baidu.input_harmony',
332
- '\u767e\u8bcd\u65a9': 'com.baicizhan.bcz.hm',
333
- '\u76d2\u9a6c': 'com.wudaokou.hippo_hmos',
334
- '\u76f4\u64ad\u5427': 'com.zhibo8.hmclient',
335
- '\u77e5\u4e4e': 'com.zhihu.hmos',
336
- '\u79fb\u52a8\u7231\u5bb6': 'com.cmcc.DigitalHome',
337
- '\u7c89\u7b14': 'com.fenbi.gwy',
338
- '\u7cd6\u8c46': 'com.xttangdou.dances',
339
- '\u7eb3\u7c73AI\u641c\u7d22': 'com.qihoo.namiso.h',
340
- '\u7f51\u4e0a\u56fd\u7f51': 'com.wsgw.harmony1',
341
- '\u7f51\u6613\u6709\u9053\u8bcd\u5178': 'com.hm.youdao',
342
- '\u7f8e\u56e2': 'com.sankuai.hmeituan',
343
- '\u7f8e\u56e2\u5916\u5356': 'com.meituan.takeaway',
344
- '\u7f8e\u56fe\u79c0\u79c0': 'com.meitu.meitupic',
345
- '\u7f8e\u989c\u76f8\u673a': 'com.meitu.beautycam',
346
- '\u817e\u8baf\u4f1a\u8bae': 'com.tencent.meeting.app',
347
- '\u817e\u8baf\u4f53\u80b2': 'com.tencent.qqsports.hm',
348
- '\u817e\u8baf\u65b0\u95fb': 'com.tencent.hm.news',
349
- '\u817e\u8baf\u89c6\u9891': 'com.tencent.videohm',
350
- '\u822a\u65c5\u7eb5\u6a2a': 'cn.com.umetrip.hm.app',
351
- '\u822a\u73ed\u7ba1\u5bb6': 'com.openet.hbgj',
352
- '\u8292\u679cTV': 'com.mgtv.phone',
353
- '\u83dc\u9e1f': 'com.cainiao.cainiao4hmos',
354
- '\u8424\u77f3\u4e91\u89c6\u9891': 'com.ezviz.videogo',
355
- '\u873b\u8713FM': 'fm.qtradio.hm',
356
- '\u897f\u74dc\u89c6\u9891': 'com.ss.hm.article.video',
357
- '\u8baf\u98de\u542c\u89c1': 'com.iflyrec.hmtjapp',
358
- '\u8baf\u98de\u8f93\u5165\u6cd5': 'com.iflytek.inputmethod.iFlytekInputIME',
359
- '\u8c46\u5305': 'com.larus.nova.hm',
360
- '\u8c46\u74e3': 'com.douban.frodo.hap',
361
- '\u8d1d\u58f3\u623f\u4ea7': 'com.beike.hongmeng',
362
- '\u8d27\u62c9\u62c9': 'com.lalamove.huolala.clienthar',
363
- '\u8d77\u70b9\u8bfb\u4e66': 'com.qidian.reader',
364
- '\u8f66\u6765\u4e86': 'com.ygkj.chelaile.standard.har',
365
- '\u8f6c\u8f6c': 'com.zhuanzhuan.hmoszz',
366
- '\u8fc5\u96f7': 'com.xunlei.thunder',
367
- '\u9014\u864e\u517b\u8f66': 'com.tuhu.tuhuharmony',
368
- '\u90ae\u50a8\u94f6\u884c': 'com.psbc.mbank.hm',
369
- '\u9177\u6211\u97f3\u4e50': 'com.hmkuwo.cn',
370
- '\u9177\u72d7\u97f3\u4e50': 'com.kugou.hmmusic',
371
- '\u9192\u56fe': 'com.app.xt.retouch',
372
- '\u9489\u9489': 'com.dingtalk.hmos',
373
- '\u94c1\u8def12306': 'com.chinarailway.ticketingHM',
374
- '\u94fe\u5bb6': 'com.lianjia.hongmeng',
375
- '\u95f2\u9c7c': 'com.taobao.idlefish4ohos',
376
- '\u963f\u91cc\u5df4\u5df4': 'com.alibaba.wireless_hmos',
377
- '\u987a\u4e30\u901f\u8fd0': 'com.sfexpress.mainlandapp',
378
- '\u9886\u5bfc\u7559\u8a00\u677f': 'cn.people.messageboard',
379
- '\u98de\u4e66': 'com.ss.feishu',
380
- '\u98de\u5e38\u51c6': 'com.feeyo.variflight',
381
- '\u98de\u732a': 'com.fliggy.harmony',
382
- '\u9975\u4e86\u4e48': 'me.ele.eleme',
383
- '\u9a7e\u6821\u4e00\u70b9\u901a': 'com.jiaxiao.driveharmony',
384
- '\u9a7e\u8003\u5b9d\u5178': 'cn.mucang.hm.jiakao',
385
- '\u9ad8\u5fb7\u5730\u56fe': 'com.amap.hmapp',
386
- '\u9ad8\u94c1\u7ba1\u5bb6': 'com.openet.gtgj',
387
- };
388
- const ALL_PACKAGES = { ...exports.APP_PACKAGES, ...exports.TOP_225_APP };
389
- /** Reverse mapping: bundle_name -> display name (or array of names). */
390
- exports.BUNDLE_NAME_TO_APP_NAME = {};
391
- /** Build the reverse bundle-name to app-name mapping. */
392
- function createBundleNameToAppName() {
393
- exports.BUNDLE_NAME_TO_APP_NAME = {};
394
- for (const [appName, bundleName] of Object.entries(ALL_PACKAGES)) {
395
- if (bundleName in exports.BUNDLE_NAME_TO_APP_NAME) {
396
- const existing = exports.BUNDLE_NAME_TO_APP_NAME[bundleName];
397
- if (Array.isArray(existing)) {
398
- existing.push(appName);
399
- }
400
- else {
401
- exports.BUNDLE_NAME_TO_APP_NAME[bundleName] = [existing, appName];
402
- }
403
- }
404
- else {
405
- exports.BUNDLE_NAME_TO_APP_NAME[bundleName] = appName;
406
- }
407
- }
408
- }
409
- createBundleNameToAppName();
410
- /**
411
- * Get the package (bundle) name for an app display name.
412
- * @param appName The display name of the app.
413
- * @returns The HarmonyOS bundle name, or undefined if not found.
414
- */
415
- function getPackageName(appName) {
416
- return ALL_PACKAGES[appName];
417
- }
418
- /**
419
- * Get the app display name from a package (bundle) name.
420
- * @param packageName The HarmonyOS bundle name.
421
- * @returns The display name of the app, or undefined if not found.
422
- */
423
- function getAppName(packageName) {
424
- for (const [name, pkg] of Object.entries(ALL_PACKAGES)) {
425
- if (pkg === packageName) {
426
- return name;
427
- }
428
- }
429
- return undefined;
430
- }
431
- /**
432
- * Get a list of all supported app display names.
433
- * @returns List of app names.
434
- */
435
- function listSupportedApps() {
436
- return Object.keys(ALL_PACKAGES);
437
- }
@@ -1,219 +0,0 @@
1
- "use strict";
2
- /**
3
- * HDC device operations for HarmonyOS.
4
- *
5
- * These helpers wrap `hdc shell` commands to drive a connected HarmonyOS
6
- * device. They accept an {@link HdcDriver} abstraction so the underlying
7
- * subprocess execution can be swapped or mocked.
8
- *
9
- * All methods are **async** to avoid blocking the Node.js event loop.
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getAppDisplayName = getAppDisplayName;
13
- exports.getCurrentApp = getCurrentApp;
14
- exports.tap = tap;
15
- exports.doubleTap = doubleTap;
16
- exports.longPress = longPress;
17
- exports.swipe = swipe;
18
- exports.back = back;
19
- exports.home = home;
20
- exports.launchApp = launchApp;
21
- exports.resetDevice = resetDevice;
22
- exports.sleep = sleep;
23
- const logger_1 = require("../../../common/logger");
24
- const apps_1 = require("./apps");
25
- /**
26
- * Inspect a device shell command's stdout and throw if it looks like a failure.
27
- * HarmonyOS `uitest uiInput` commands report success as the literal string
28
- * "No Error", so that must be treated as OK (not matched by the error regex).
29
- */
30
- function assertShellOk(out, cmd) {
31
- const trimmed = out.trim();
32
- if (trimmed.length === 0)
33
- return;
34
- if (/^no\s+error$/i.test(trimmed))
35
- return;
36
- if (/error|fail|exception|not found|not exist|invalid|timeout|refused|unreachable/i.test(trimmed)) {
37
- throw new Error(`device shell command failed: ${cmd} -> ${trimmed.slice(0, 200)}`);
38
- }
39
- }
40
- /**
41
- * Get the display name of an app from its bundle name.
42
- * @param bundleName The bundle name of the app.
43
- * @returns The display name of the app.
44
- */
45
- function getAppDisplayName(bundleName) {
46
- const result = apps_1.BUNDLE_NAME_TO_APP_NAME[bundleName] ?? bundleName;
47
- if (typeof result === 'string') {
48
- return result;
49
- }
50
- logger_1.logger.info(`Multiple app names found for bundle ${bundleName}: ${result.join(', ')}`);
51
- logger_1.logger.info(`Using the first name: ${result[0]}`);
52
- return result[0];
53
- }
54
- /**
55
- * Get the currently focused app name.
56
- * @param driver The hdc driver instance.
57
- * @param returnDisplayName Whether to return the display name (true) or bundle name (false).
58
- * @returns The app name if recognized, otherwise "System Home".
59
- */
60
- async function getCurrentApp(driver, returnDisplayName = true) {
61
- const output = await driver.shell('aa dump -l');
62
- if (!output) {
63
- throw new Error('No output from aa dump');
64
- }
65
- const lines = output.split('\n');
66
- let foregroundBundle = null;
67
- let currentBundle = null;
68
- for (const line of lines) {
69
- if (line.includes('app name [')) {
70
- const match = line.match(/\[([^\]]+)\]/);
71
- if (match && match[1]) {
72
- currentBundle = match[1];
73
- }
74
- }
75
- if (line.toLowerCase().includes('state #foreground')) {
76
- if (currentBundle) {
77
- foregroundBundle = currentBundle;
78
- break;
79
- }
80
- }
81
- if (line.includes('Mission ID')) {
82
- currentBundle = null;
83
- }
84
- }
85
- if (foregroundBundle) {
86
- if (returnDisplayName) {
87
- return getAppDisplayName(foregroundBundle);
88
- }
89
- return foregroundBundle;
90
- }
91
- logger_1.logger.info('No bundle is found');
92
- return 'System Home';
93
- }
94
- /** Tap at the specified coordinates. */
95
- async function tap(driver, x, y, delay) {
96
- const cmd = `uitest uiInput click ${x} ${y}`;
97
- const out = await driver.shell(cmd);
98
- assertShellOk(out, cmd);
99
- if (delay) {
100
- await sleep(delay);
101
- }
102
- }
103
- /** Double tap at the specified coordinates. */
104
- async function doubleTap(driver, x, y, delay) {
105
- const cmd = `uitest uiInput doubleClick ${x} ${y}`;
106
- const out = await driver.shell(cmd);
107
- assertShellOk(out, cmd);
108
- if (delay) {
109
- await sleep(delay);
110
- }
111
- }
112
- /** Long press at the specified coordinates. */
113
- async function longPress(driver, x, y, durationMs = 800, delay) {
114
- const cmd = `uitest uiInput longClick ${x} ${y} ${durationMs}`;
115
- const out = await driver.shell(cmd);
116
- assertShellOk(out, cmd);
117
- if (delay) {
118
- await sleep(delay);
119
- }
120
- }
121
- /** Swipe from start to end coordinates. */
122
- async function swipe(driver, startX, startY, endX, endY, durationMs, delay) {
123
- const duration = durationMs ?? '';
124
- const cmd = `uitest uiInput swipe ${startX} ${startY} ${endX} ${endY} ${duration}`.trim();
125
- const out = await driver.shell(cmd);
126
- assertShellOk(out, cmd);
127
- if (delay) {
128
- await sleep(delay);
129
- }
130
- }
131
- /** Press the back button. */
132
- async function back(driver, delay) {
133
- const cmd = 'uitest uiInput keyEvent Back';
134
- const out = await driver.shell(cmd);
135
- assertShellOk(out, cmd);
136
- if (delay) {
137
- await sleep(delay);
138
- }
139
- }
140
- /** Press the home button. */
141
- async function home(driver, delay) {
142
- const cmd = 'uitest uiInput keyEvent Home';
143
- const out = await driver.shell(cmd);
144
- assertShellOk(out, cmd);
145
- if (delay) {
146
- await sleep(delay);
147
- }
148
- }
149
- /**
150
- * Launch an app by name.
151
- * @returns True if app was launched, False if the start command reported an error.
152
- */
153
- async function launchApp(driver, appName, delay) {
154
- const bundleName = (0, apps_1.getPackageName)(appName) ?? appName;
155
- const ability = apps_1.APP_ABILITIES[bundleName] ?? 'EntryAbility';
156
- const cmd = `aa start -b ${bundleName} -a ${ability}`;
157
- const out = await driver.shell(cmd);
158
- if (delay) {
159
- await sleep(delay);
160
- }
161
- if (/^no\s+error$/i.test(out.trim()))
162
- return true;
163
- if (/error|fail|not found|exception|not exist/i.test(out)) {
164
- logger_1.logger.warn(`launchApp failed: ${cmd} -> ${out.trim().slice(0, 200)}`);
165
- // Retry: try full-qualified ability name (bundleName.AbilityName)
166
- const fullAbility = `${bundleName}.${ability}`;
167
- const retryCmd = `aa start -b ${bundleName} -a ${fullAbility}`;
168
- const retryOut = await driver.shell(retryCmd);
169
- if (/^no\s+error$/i.test(retryOut.trim())) {
170
- logger_1.logger.info(`launchApp retry succeeded: ${retryCmd}`);
171
- return true;
172
- }
173
- if (/error|fail|not found|exception|not exist/i.test(retryOut)) {
174
- logger_1.logger.warn(`launchApp retry failed: ${retryCmd} -> ${retryOut.trim().slice(0, 200)}`);
175
- return false;
176
- }
177
- return true;
178
- }
179
- return true;
180
- }
181
- /**
182
- * Reset the device to a clean home state.
183
- * Light flow: single home + clear recent tasks via aa dump/force-stop.
184
- */
185
- async function resetDevice(driver) {
186
- logger_1.logger.info('Resetting device status...');
187
- await home(driver, 1);
188
- await sleep(1);
189
- try {
190
- const result = await driver.shell('aa dump -l');
191
- const bundlePattern = /app name \[([^\]]+)\]/g;
192
- let match;
193
- const bundles = new Set();
194
- while ((match = bundlePattern.exec(result)) !== null) {
195
- bundles.add(match[1]);
196
- }
197
- for (const bundle of bundles) {
198
- try {
199
- await driver.shell(`aa force-stop ${bundle}`);
200
- }
201
- catch {
202
- // ignore individual force-stop failures
203
- }
204
- }
205
- if (bundles.size > 0) {
206
- logger_1.logger.info(`Cleared ${bundles.size} recent tasks`);
207
- }
208
- }
209
- catch (e) {
210
- logger_1.logger.warn(`clearRecentTask failed: ${e instanceof Error ? e.message : String(e)}`);
211
- }
212
- logger_1.logger.info('Device status reset completed.');
213
- }
214
- /** Async sleep for the given number of seconds. */
215
- function sleep(seconds) {
216
- if (seconds <= 0)
217
- return Promise.resolve();
218
- return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
219
- }