@midscene/android 1.2.1 → 1.2.2-beta-20260115065918.0

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/dist/es/index.mjs CHANGED
@@ -225,6 +225,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
225
225
  }
226
226
  });
227
227
  }
228
+ setAppNameMapping(mapping) {
229
+ this.appNameMapping = mapping;
230
+ }
231
+ resolvePackageName(appName) {
232
+ if (appName in this.appNameMapping) return this.appNameMapping[appName];
233
+ }
228
234
  async launch(uri) {
229
235
  const adb = await this.getAdb();
230
236
  this.uri = uri;
@@ -237,7 +243,10 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
237
243
  pkg: appPackage,
238
244
  activity: appActivity
239
245
  });
240
- } else await adb.activateApp(uri);
246
+ } else {
247
+ const resolvedUri = this.resolvePackageName(uri) ?? uri;
248
+ await adb.activateApp(resolvedUri);
249
+ }
241
250
  debugDevice(`Successfully launched: ${uri}`);
242
251
  } catch (error) {
243
252
  debugDevice(`Error launching ${uri}: ${error}`);
@@ -912,6 +921,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
912
921
  _define_property(this, "customActions", void 0);
913
922
  _define_property(this, "cachedScreenSize", null);
914
923
  _define_property(this, "cachedOrientation", null);
924
+ _define_property(this, "appNameMapping", {});
915
925
  _define_property(this, "interfaceType", 'android');
916
926
  _define_property(this, "uri", void 0);
917
927
  _define_property(this, "options", void 0);
@@ -922,7 +932,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
922
932
  }
923
933
  }
924
934
  const runAdbShellParamSchema = z.string().describe('ADB shell command to execute');
925
- const launchParamSchema = z.string().describe('App package name or URL to launch');
935
+ const launchParamSchema = z.string().describe('App package name or URL or app name to launch,');
926
936
  const createPlatformActions = (device)=>({
927
937
  RunAdbShell: defineAction({
928
938
  name: 'RunAdbShell',
@@ -965,6 +975,176 @@ const createPlatformActions = (device)=>({
965
975
  }
966
976
  })
967
977
  });
978
+ const defaultAppNameMapping = {
979
+ 微信: 'com.tencent.mm',
980
+ QQ: 'com.tencent.mobileqq',
981
+ 微博: 'com.sina.weibo',
982
+ 淘宝: 'com.taobao.taobao',
983
+ 京东: 'com.jingdong.app.mall',
984
+ 拼多多: 'com.xunmeng.pinduoduo',
985
+ 淘宝闪购: 'com.taobao.taobao',
986
+ 京东秒送: 'com.jingdong.app.mall',
987
+ 小红书: 'com.xingin.xhs',
988
+ 豆瓣: 'com.douban.frodo',
989
+ 知乎: 'com.zhihu.android',
990
+ 高德地图: 'com.autonavi.minimap',
991
+ 百度地图: 'com.baidu.BaiduMap',
992
+ 美团: 'com.sankuai.meituan',
993
+ 大众点评: 'com.dianping.v1',
994
+ 饿了么: 'me.ele',
995
+ 肯德基: 'com.yek.android.kfc.activitys',
996
+ 携程: 'ctrip.android.view',
997
+ 铁路12306: 'com.MobileTicket',
998
+ 12306: 'com.MobileTicket',
999
+ 去哪儿: 'com.Qunar',
1000
+ 去哪儿旅行: 'com.Qunar',
1001
+ 滴滴出行: 'com.sdu.didi.psnger',
1002
+ bilibili: 'tv.danmaku.bili',
1003
+ 抖音: 'com.ss.android.ugc.aweme',
1004
+ 快手: 'com.smile.gifmaker',
1005
+ 腾讯视频: 'com.tencent.qqlive',
1006
+ 爱奇艺: 'com.qiyi.video',
1007
+ 优酷视频: 'com.youku.phone',
1008
+ 芒果TV: 'com.hunantv.imgo.activity',
1009
+ 红果短剧: 'com.phoenix.read',
1010
+ 网易云音乐: 'com.netease.cloudmusic',
1011
+ QQ音乐: 'com.tencent.qqmusic',
1012
+ 汽水音乐: 'com.luna.music',
1013
+ 喜马拉雅: 'com.ximalaya.ting.android',
1014
+ 番茄小说: 'com.dragon.read',
1015
+ 番茄免费小说: 'com.dragon.read',
1016
+ 七猫免费小说: 'com.kmxs.reader',
1017
+ 飞书: 'com.ss.android.lark',
1018
+ QQ邮箱: 'com.tencent.androidqqmail',
1019
+ 豆包: 'com.larus.nova',
1020
+ keep: 'com.gotokeep.keep',
1021
+ 美柚: 'com.lingan.seeyou',
1022
+ 腾讯新闻: 'com.tencent.news',
1023
+ 今日头条: 'com.ss.android.article.news',
1024
+ 贝壳找房: 'com.lianjia.beike',
1025
+ 安居客: 'com.anjuke.android.app',
1026
+ 同花顺: 'com.hexin.plat.android',
1027
+ 星穹铁道: 'com.miHoYo.hkrpg',
1028
+ '崩坏:星穹铁道': 'com.miHoYo.hkrpg',
1029
+ 恋与深空: 'com.papegames.lysk.cn',
1030
+ AndroidSystemSettings: 'com.android.settings',
1031
+ 'Android System Settings': 'com.android.settings',
1032
+ 'Android System Settings': 'com.android.settings',
1033
+ 'Android-System-Settings': 'com.android.settings',
1034
+ Settings: 'com.android.settings',
1035
+ AudioRecorder: 'com.android.soundrecorder',
1036
+ audiorecorder: 'com.android.soundrecorder',
1037
+ Bluecoins: 'com.rammigsoftware.bluecoins',
1038
+ bluecoins: 'com.rammigsoftware.bluecoins',
1039
+ Broccoli: 'com.flauschcode.broccoli',
1040
+ broccoli: 'com.flauschcode.broccoli',
1041
+ 'Booking.com': 'com.booking',
1042
+ Booking: 'com.booking',
1043
+ 'booking.com': 'com.booking',
1044
+ booking: 'com.booking',
1045
+ 'BOOKING.COM': 'com.booking',
1046
+ Chrome: 'com.android.chrome',
1047
+ chrome: 'com.android.chrome',
1048
+ 'Google Chrome': 'com.android.chrome',
1049
+ Clock: 'com.android.deskclock',
1050
+ clock: 'com.android.deskclock',
1051
+ Contacts: 'com.android.contacts',
1052
+ contacts: 'com.android.contacts',
1053
+ Duolingo: 'com.duolingo',
1054
+ duolingo: 'com.duolingo',
1055
+ Expedia: 'com.expedia.bookings',
1056
+ expedia: 'com.expedia.bookings',
1057
+ Files: 'com.android.fileexplorer',
1058
+ files: 'com.android.fileexplorer',
1059
+ 'File Manager': 'com.android.fileexplorer',
1060
+ 'file manager': 'com.android.fileexplorer',
1061
+ gmail: 'com.google.android.gm',
1062
+ Gmail: 'com.google.android.gm',
1063
+ GoogleMail: 'com.google.android.gm',
1064
+ 'Google Mail': 'com.google.android.gm',
1065
+ GoogleFiles: 'com.google.android.apps.nbu.files',
1066
+ googlefiles: 'com.google.android.apps.nbu.files',
1067
+ FilesbyGoogle: 'com.google.android.apps.nbu.files',
1068
+ GoogleCalendar: 'com.google.android.calendar',
1069
+ 'Google-Calendar': 'com.google.android.calendar',
1070
+ 'Google Calendar': 'com.google.android.calendar',
1071
+ 'google-calendar': 'com.google.android.calendar',
1072
+ 'google calendar': 'com.google.android.calendar',
1073
+ GoogleChat: 'com.google.android.apps.dynamite',
1074
+ 'Google Chat': 'com.google.android.apps.dynamite',
1075
+ 'Google-Chat': 'com.google.android.apps.dynamite',
1076
+ GoogleClock: 'com.google.android.deskclock',
1077
+ 'Google Clock': 'com.google.android.deskclock',
1078
+ 'Google-Clock': 'com.google.android.deskclock',
1079
+ GoogleContacts: 'com.google.android.contacts',
1080
+ 'Google-Contacts': 'com.google.android.contacts',
1081
+ 'Google Contacts': 'com.google.android.contacts',
1082
+ 'google-contacts': 'com.google.android.contacts',
1083
+ 'google contacts': 'com.google.android.contacts',
1084
+ GoogleDocs: 'com.google.android.apps.docs.editors.docs',
1085
+ 'Google Docs': 'com.google.android.apps.docs.editors.docs',
1086
+ googledocs: 'com.google.android.apps.docs.editors.docs',
1087
+ 'google docs': 'com.google.android.apps.docs.editors.docs',
1088
+ 'Google Drive': 'com.google.android.apps.docs',
1089
+ 'Google-Drive': 'com.google.android.apps.docs',
1090
+ 'google drive': 'com.google.android.apps.docs',
1091
+ 'google-drive': 'com.google.android.apps.docs',
1092
+ GoogleDrive: 'com.google.android.apps.docs',
1093
+ Googledrive: 'com.google.android.apps.docs',
1094
+ googledrive: 'com.google.android.apps.docs',
1095
+ GoogleFit: 'com.google.android.apps.fitness',
1096
+ googlefit: 'com.google.android.apps.fitness',
1097
+ GoogleKeep: 'com.google.android.keep',
1098
+ googlekeep: 'com.google.android.keep',
1099
+ GoogleMaps: 'com.google.android.apps.maps',
1100
+ 'Google Maps': 'com.google.android.apps.maps',
1101
+ googlemaps: 'com.google.android.apps.maps',
1102
+ 'google maps': 'com.google.android.apps.maps',
1103
+ 'Google Play Books': 'com.google.android.apps.books',
1104
+ 'Google-Play-Books': 'com.google.android.apps.books',
1105
+ 'google play books': 'com.google.android.apps.books',
1106
+ 'google-play-books': 'com.google.android.apps.books',
1107
+ GooglePlayBooks: 'com.google.android.apps.books',
1108
+ googleplaybooks: 'com.google.android.apps.books',
1109
+ GooglePlayStore: 'com.android.vending',
1110
+ 'Google Play Store': 'com.android.vending',
1111
+ 'Google-Play-Store': 'com.android.vending',
1112
+ GoogleSlides: 'com.google.android.apps.docs.editors.slides',
1113
+ 'Google Slides': 'com.google.android.apps.docs.editors.slides',
1114
+ 'Google-Slides': 'com.google.android.apps.docs.editors.slides',
1115
+ GoogleTasks: 'com.google.android.apps.tasks',
1116
+ 'Google Tasks': 'com.google.android.apps.tasks',
1117
+ 'Google-Tasks': 'com.google.android.apps.tasks',
1118
+ Joplin: 'net.cozic.joplin',
1119
+ joplin: 'net.cozic.joplin',
1120
+ McDonald: 'com.mcdonalds.app',
1121
+ mcdonald: 'com.mcdonalds.app',
1122
+ Osmand: 'net.osmand',
1123
+ osmand: 'net.osmand',
1124
+ PiMusicPlayer: 'com.Project100Pi.themusicplayer',
1125
+ pimusicplayer: 'com.Project100Pi.themusicplayer',
1126
+ Quora: 'com.quora.android',
1127
+ quora: 'com.quora.android',
1128
+ Reddit: 'com.reddit.frontpage',
1129
+ reddit: 'com.reddit.frontpage',
1130
+ RetroMusic: 'code.name.monkey.retromusic',
1131
+ retromusic: 'code.name.monkey.retromusic',
1132
+ SimpleCalendarPro: 'com.scientificcalculatorplus.simplecalculator.basiccalculator.mathcalc',
1133
+ SimpleSMSMessenger: 'com.simplemobiletools.smsmessenger',
1134
+ Telegram: 'org.telegram.messenger',
1135
+ temu: 'com.einnovation.temu',
1136
+ Temu: 'com.einnovation.temu',
1137
+ Tiktok: 'com.zhiliaoapp.musically',
1138
+ tiktok: 'com.zhiliaoapp.musically',
1139
+ Twitter: 'com.twitter.android',
1140
+ twitter: 'com.twitter.android',
1141
+ X: 'com.twitter.android',
1142
+ VLC: 'org.videolan.vlc',
1143
+ WeChat: 'com.tencent.mm',
1144
+ wechat: 'com.tencent.mm',
1145
+ Whatsapp: 'com.whatsapp',
1146
+ WhatsApp: 'com.whatsapp'
1147
+ };
968
1148
  const debugUtils = getDebug('android:utils');
969
1149
  async function getConnectedDevices() {
970
1150
  try {
@@ -998,7 +1178,12 @@ class AndroidAgent extends Agent {
998
1178
  return (...args)=>action(args[0]);
999
1179
  }
1000
1180
  constructor(device, opts){
1001
- super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
1181
+ super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0), agent_define_property(this, "appNameMapping", void 0);
1182
+ this.appNameMapping = {
1183
+ ...defaultAppNameMapping,
1184
+ ...opts?.appNameMapping || {}
1185
+ };
1186
+ device.setAppNameMapping(this.appNameMapping);
1002
1187
  this.launch = this.createActionWrapper('Launch');
1003
1188
  this.runAdbShell = this.createActionWrapper('RunAdbShell');
1004
1189
  this.back = this.createActionWrapper('AndroidBackButton');
@@ -12,6 +12,176 @@ import { MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT,
12
12
  import { createImgBase64ByFormat, isValidPNGImageBuffer } from "@midscene/shared/img";
13
13
  import { repeat, uuid } from "@midscene/shared/utils";
14
14
  import { ADB } from "appium-adb";
15
+ const defaultAppNameMapping = {
16
+ 微信: 'com.tencent.mm',
17
+ QQ: 'com.tencent.mobileqq',
18
+ 微博: 'com.sina.weibo',
19
+ 淘宝: 'com.taobao.taobao',
20
+ 京东: 'com.jingdong.app.mall',
21
+ 拼多多: 'com.xunmeng.pinduoduo',
22
+ 淘宝闪购: 'com.taobao.taobao',
23
+ 京东秒送: 'com.jingdong.app.mall',
24
+ 小红书: 'com.xingin.xhs',
25
+ 豆瓣: 'com.douban.frodo',
26
+ 知乎: 'com.zhihu.android',
27
+ 高德地图: 'com.autonavi.minimap',
28
+ 百度地图: 'com.baidu.BaiduMap',
29
+ 美团: 'com.sankuai.meituan',
30
+ 大众点评: 'com.dianping.v1',
31
+ 饿了么: 'me.ele',
32
+ 肯德基: 'com.yek.android.kfc.activitys',
33
+ 携程: 'ctrip.android.view',
34
+ 铁路12306: 'com.MobileTicket',
35
+ 12306: 'com.MobileTicket',
36
+ 去哪儿: 'com.Qunar',
37
+ 去哪儿旅行: 'com.Qunar',
38
+ 滴滴出行: 'com.sdu.didi.psnger',
39
+ bilibili: 'tv.danmaku.bili',
40
+ 抖音: 'com.ss.android.ugc.aweme',
41
+ 快手: 'com.smile.gifmaker',
42
+ 腾讯视频: 'com.tencent.qqlive',
43
+ 爱奇艺: 'com.qiyi.video',
44
+ 优酷视频: 'com.youku.phone',
45
+ 芒果TV: 'com.hunantv.imgo.activity',
46
+ 红果短剧: 'com.phoenix.read',
47
+ 网易云音乐: 'com.netease.cloudmusic',
48
+ QQ音乐: 'com.tencent.qqmusic',
49
+ 汽水音乐: 'com.luna.music',
50
+ 喜马拉雅: 'com.ximalaya.ting.android',
51
+ 番茄小说: 'com.dragon.read',
52
+ 番茄免费小说: 'com.dragon.read',
53
+ 七猫免费小说: 'com.kmxs.reader',
54
+ 飞书: 'com.ss.android.lark',
55
+ QQ邮箱: 'com.tencent.androidqqmail',
56
+ 豆包: 'com.larus.nova',
57
+ keep: 'com.gotokeep.keep',
58
+ 美柚: 'com.lingan.seeyou',
59
+ 腾讯新闻: 'com.tencent.news',
60
+ 今日头条: 'com.ss.android.article.news',
61
+ 贝壳找房: 'com.lianjia.beike',
62
+ 安居客: 'com.anjuke.android.app',
63
+ 同花顺: 'com.hexin.plat.android',
64
+ 星穹铁道: 'com.miHoYo.hkrpg',
65
+ '崩坏:星穹铁道': 'com.miHoYo.hkrpg',
66
+ 恋与深空: 'com.papegames.lysk.cn',
67
+ AndroidSystemSettings: 'com.android.settings',
68
+ 'Android System Settings': 'com.android.settings',
69
+ 'Android System Settings': 'com.android.settings',
70
+ 'Android-System-Settings': 'com.android.settings',
71
+ Settings: 'com.android.settings',
72
+ AudioRecorder: 'com.android.soundrecorder',
73
+ audiorecorder: 'com.android.soundrecorder',
74
+ Bluecoins: 'com.rammigsoftware.bluecoins',
75
+ bluecoins: 'com.rammigsoftware.bluecoins',
76
+ Broccoli: 'com.flauschcode.broccoli',
77
+ broccoli: 'com.flauschcode.broccoli',
78
+ 'Booking.com': 'com.booking',
79
+ Booking: 'com.booking',
80
+ 'booking.com': 'com.booking',
81
+ booking: 'com.booking',
82
+ 'BOOKING.COM': 'com.booking',
83
+ Chrome: 'com.android.chrome',
84
+ chrome: 'com.android.chrome',
85
+ 'Google Chrome': 'com.android.chrome',
86
+ Clock: 'com.android.deskclock',
87
+ clock: 'com.android.deskclock',
88
+ Contacts: 'com.android.contacts',
89
+ contacts: 'com.android.contacts',
90
+ Duolingo: 'com.duolingo',
91
+ duolingo: 'com.duolingo',
92
+ Expedia: 'com.expedia.bookings',
93
+ expedia: 'com.expedia.bookings',
94
+ Files: 'com.android.fileexplorer',
95
+ files: 'com.android.fileexplorer',
96
+ 'File Manager': 'com.android.fileexplorer',
97
+ 'file manager': 'com.android.fileexplorer',
98
+ gmail: 'com.google.android.gm',
99
+ Gmail: 'com.google.android.gm',
100
+ GoogleMail: 'com.google.android.gm',
101
+ 'Google Mail': 'com.google.android.gm',
102
+ GoogleFiles: 'com.google.android.apps.nbu.files',
103
+ googlefiles: 'com.google.android.apps.nbu.files',
104
+ FilesbyGoogle: 'com.google.android.apps.nbu.files',
105
+ GoogleCalendar: 'com.google.android.calendar',
106
+ 'Google-Calendar': 'com.google.android.calendar',
107
+ 'Google Calendar': 'com.google.android.calendar',
108
+ 'google-calendar': 'com.google.android.calendar',
109
+ 'google calendar': 'com.google.android.calendar',
110
+ GoogleChat: 'com.google.android.apps.dynamite',
111
+ 'Google Chat': 'com.google.android.apps.dynamite',
112
+ 'Google-Chat': 'com.google.android.apps.dynamite',
113
+ GoogleClock: 'com.google.android.deskclock',
114
+ 'Google Clock': 'com.google.android.deskclock',
115
+ 'Google-Clock': 'com.google.android.deskclock',
116
+ GoogleContacts: 'com.google.android.contacts',
117
+ 'Google-Contacts': 'com.google.android.contacts',
118
+ 'Google Contacts': 'com.google.android.contacts',
119
+ 'google-contacts': 'com.google.android.contacts',
120
+ 'google contacts': 'com.google.android.contacts',
121
+ GoogleDocs: 'com.google.android.apps.docs.editors.docs',
122
+ 'Google Docs': 'com.google.android.apps.docs.editors.docs',
123
+ googledocs: 'com.google.android.apps.docs.editors.docs',
124
+ 'google docs': 'com.google.android.apps.docs.editors.docs',
125
+ 'Google Drive': 'com.google.android.apps.docs',
126
+ 'Google-Drive': 'com.google.android.apps.docs',
127
+ 'google drive': 'com.google.android.apps.docs',
128
+ 'google-drive': 'com.google.android.apps.docs',
129
+ GoogleDrive: 'com.google.android.apps.docs',
130
+ Googledrive: 'com.google.android.apps.docs',
131
+ googledrive: 'com.google.android.apps.docs',
132
+ GoogleFit: 'com.google.android.apps.fitness',
133
+ googlefit: 'com.google.android.apps.fitness',
134
+ GoogleKeep: 'com.google.android.keep',
135
+ googlekeep: 'com.google.android.keep',
136
+ GoogleMaps: 'com.google.android.apps.maps',
137
+ 'Google Maps': 'com.google.android.apps.maps',
138
+ googlemaps: 'com.google.android.apps.maps',
139
+ 'google maps': 'com.google.android.apps.maps',
140
+ 'Google Play Books': 'com.google.android.apps.books',
141
+ 'Google-Play-Books': 'com.google.android.apps.books',
142
+ 'google play books': 'com.google.android.apps.books',
143
+ 'google-play-books': 'com.google.android.apps.books',
144
+ GooglePlayBooks: 'com.google.android.apps.books',
145
+ googleplaybooks: 'com.google.android.apps.books',
146
+ GooglePlayStore: 'com.android.vending',
147
+ 'Google Play Store': 'com.android.vending',
148
+ 'Google-Play-Store': 'com.android.vending',
149
+ GoogleSlides: 'com.google.android.apps.docs.editors.slides',
150
+ 'Google Slides': 'com.google.android.apps.docs.editors.slides',
151
+ 'Google-Slides': 'com.google.android.apps.docs.editors.slides',
152
+ GoogleTasks: 'com.google.android.apps.tasks',
153
+ 'Google Tasks': 'com.google.android.apps.tasks',
154
+ 'Google-Tasks': 'com.google.android.apps.tasks',
155
+ Joplin: 'net.cozic.joplin',
156
+ joplin: 'net.cozic.joplin',
157
+ McDonald: 'com.mcdonalds.app',
158
+ mcdonald: 'com.mcdonalds.app',
159
+ Osmand: 'net.osmand',
160
+ osmand: 'net.osmand',
161
+ PiMusicPlayer: 'com.Project100Pi.themusicplayer',
162
+ pimusicplayer: 'com.Project100Pi.themusicplayer',
163
+ Quora: 'com.quora.android',
164
+ quora: 'com.quora.android',
165
+ Reddit: 'com.reddit.frontpage',
166
+ reddit: 'com.reddit.frontpage',
167
+ RetroMusic: 'code.name.monkey.retromusic',
168
+ retromusic: 'code.name.monkey.retromusic',
169
+ SimpleCalendarPro: 'com.scientificcalculatorplus.simplecalculator.basiccalculator.mathcalc',
170
+ SimpleSMSMessenger: 'com.simplemobiletools.smsmessenger',
171
+ Telegram: 'org.telegram.messenger',
172
+ temu: 'com.einnovation.temu',
173
+ Temu: 'com.einnovation.temu',
174
+ Tiktok: 'com.zhiliaoapp.musically',
175
+ tiktok: 'com.zhiliaoapp.musically',
176
+ Twitter: 'com.twitter.android',
177
+ twitter: 'com.twitter.android',
178
+ X: 'com.twitter.android',
179
+ VLC: 'org.videolan.vlc',
180
+ WeChat: 'com.tencent.mm',
181
+ wechat: 'com.tencent.mm',
182
+ Whatsapp: 'com.whatsapp',
183
+ WhatsApp: 'com.whatsapp'
184
+ };
15
185
  function _define_property(obj, key, value) {
16
186
  if (key in obj) Object.defineProperty(obj, key, {
17
187
  value: value,
@@ -226,6 +396,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
226
396
  }
227
397
  });
228
398
  }
399
+ setAppNameMapping(mapping) {
400
+ this.appNameMapping = mapping;
401
+ }
402
+ resolvePackageName(appName) {
403
+ if (appName in this.appNameMapping) return this.appNameMapping[appName];
404
+ }
229
405
  async launch(uri) {
230
406
  const adb = await this.getAdb();
231
407
  this.uri = uri;
@@ -238,7 +414,10 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
238
414
  pkg: appPackage,
239
415
  activity: appActivity
240
416
  });
241
- } else await adb.activateApp(uri);
417
+ } else {
418
+ const resolvedUri = this.resolvePackageName(uri) ?? uri;
419
+ await adb.activateApp(resolvedUri);
420
+ }
242
421
  debugDevice(`Successfully launched: ${uri}`);
243
422
  } catch (error) {
244
423
  debugDevice(`Error launching ${uri}: ${error}`);
@@ -913,6 +1092,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
913
1092
  _define_property(this, "customActions", void 0);
914
1093
  _define_property(this, "cachedScreenSize", null);
915
1094
  _define_property(this, "cachedOrientation", null);
1095
+ _define_property(this, "appNameMapping", {});
916
1096
  _define_property(this, "interfaceType", 'android');
917
1097
  _define_property(this, "uri", void 0);
918
1098
  _define_property(this, "options", void 0);
@@ -923,7 +1103,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
923
1103
  }
924
1104
  }
925
1105
  const runAdbShellParamSchema = z.string().describe('ADB shell command to execute');
926
- const launchParamSchema = z.string().describe('App package name or URL to launch');
1106
+ const launchParamSchema = z.string().describe('App package name or URL or app name to launch,');
927
1107
  const createPlatformActions = (device)=>({
928
1108
  RunAdbShell: defineAction({
929
1109
  name: 'RunAdbShell',
@@ -999,7 +1179,12 @@ class AndroidAgent extends Agent {
999
1179
  return (...args)=>action(args[0]);
1000
1180
  }
1001
1181
  constructor(device, opts){
1002
- super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
1182
+ super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0), agent_define_property(this, "appNameMapping", void 0);
1183
+ this.appNameMapping = {
1184
+ ...defaultAppNameMapping,
1185
+ ...opts?.appNameMapping || {}
1186
+ };
1187
+ device.setAppNameMapping(this.appNameMapping);
1003
1188
  this.launch = this.createActionWrapper('Launch');
1004
1189
  this.runAdbShell = this.createActionWrapper('RunAdbShell');
1005
1190
  this.back = this.createActionWrapper('AndroidBackButton');
package/dist/lib/index.js CHANGED
@@ -271,6 +271,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
271
271
  }
272
272
  });
273
273
  }
274
+ setAppNameMapping(mapping) {
275
+ this.appNameMapping = mapping;
276
+ }
277
+ resolvePackageName(appName) {
278
+ if (appName in this.appNameMapping) return this.appNameMapping[appName];
279
+ }
274
280
  async launch(uri) {
275
281
  const adb = await this.getAdb();
276
282
  this.uri = uri;
@@ -283,7 +289,10 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
283
289
  pkg: appPackage,
284
290
  activity: appActivity
285
291
  });
286
- } else await adb.activateApp(uri);
292
+ } else {
293
+ const resolvedUri = this.resolvePackageName(uri) ?? uri;
294
+ await adb.activateApp(resolvedUri);
295
+ }
287
296
  debugDevice(`Successfully launched: ${uri}`);
288
297
  } catch (error) {
289
298
  debugDevice(`Error launching ${uri}: ${error}`);
@@ -958,6 +967,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
958
967
  _define_property(this, "customActions", void 0);
959
968
  _define_property(this, "cachedScreenSize", null);
960
969
  _define_property(this, "cachedOrientation", null);
970
+ _define_property(this, "appNameMapping", {});
961
971
  _define_property(this, "interfaceType", 'android');
962
972
  _define_property(this, "uri", void 0);
963
973
  _define_property(this, "options", void 0);
@@ -968,7 +978,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
968
978
  }
969
979
  }
970
980
  const runAdbShellParamSchema = core_namespaceObject.z.string().describe('ADB shell command to execute');
971
- const launchParamSchema = core_namespaceObject.z.string().describe('App package name or URL to launch');
981
+ const launchParamSchema = core_namespaceObject.z.string().describe('App package name or URL or app name to launch,');
972
982
  const createPlatformActions = (device)=>({
973
983
  RunAdbShell: (0, device_namespaceObject.defineAction)({
974
984
  name: 'RunAdbShell',
@@ -1012,6 +1022,176 @@ const createPlatformActions = (device)=>({
1012
1022
  })
1013
1023
  });
1014
1024
  const agent_namespaceObject = require("@midscene/core/agent");
1025
+ const defaultAppNameMapping = {
1026
+ 微信: 'com.tencent.mm',
1027
+ QQ: 'com.tencent.mobileqq',
1028
+ 微博: 'com.sina.weibo',
1029
+ 淘宝: 'com.taobao.taobao',
1030
+ 京东: 'com.jingdong.app.mall',
1031
+ 拼多多: 'com.xunmeng.pinduoduo',
1032
+ 淘宝闪购: 'com.taobao.taobao',
1033
+ 京东秒送: 'com.jingdong.app.mall',
1034
+ 小红书: 'com.xingin.xhs',
1035
+ 豆瓣: 'com.douban.frodo',
1036
+ 知乎: 'com.zhihu.android',
1037
+ 高德地图: 'com.autonavi.minimap',
1038
+ 百度地图: 'com.baidu.BaiduMap',
1039
+ 美团: 'com.sankuai.meituan',
1040
+ 大众点评: 'com.dianping.v1',
1041
+ 饿了么: 'me.ele',
1042
+ 肯德基: 'com.yek.android.kfc.activitys',
1043
+ 携程: 'ctrip.android.view',
1044
+ 铁路12306: 'com.MobileTicket',
1045
+ 12306: 'com.MobileTicket',
1046
+ 去哪儿: 'com.Qunar',
1047
+ 去哪儿旅行: 'com.Qunar',
1048
+ 滴滴出行: 'com.sdu.didi.psnger',
1049
+ bilibili: 'tv.danmaku.bili',
1050
+ 抖音: 'com.ss.android.ugc.aweme',
1051
+ 快手: 'com.smile.gifmaker',
1052
+ 腾讯视频: 'com.tencent.qqlive',
1053
+ 爱奇艺: 'com.qiyi.video',
1054
+ 优酷视频: 'com.youku.phone',
1055
+ 芒果TV: 'com.hunantv.imgo.activity',
1056
+ 红果短剧: 'com.phoenix.read',
1057
+ 网易云音乐: 'com.netease.cloudmusic',
1058
+ QQ音乐: 'com.tencent.qqmusic',
1059
+ 汽水音乐: 'com.luna.music',
1060
+ 喜马拉雅: 'com.ximalaya.ting.android',
1061
+ 番茄小说: 'com.dragon.read',
1062
+ 番茄免费小说: 'com.dragon.read',
1063
+ 七猫免费小说: 'com.kmxs.reader',
1064
+ 飞书: 'com.ss.android.lark',
1065
+ QQ邮箱: 'com.tencent.androidqqmail',
1066
+ 豆包: 'com.larus.nova',
1067
+ keep: 'com.gotokeep.keep',
1068
+ 美柚: 'com.lingan.seeyou',
1069
+ 腾讯新闻: 'com.tencent.news',
1070
+ 今日头条: 'com.ss.android.article.news',
1071
+ 贝壳找房: 'com.lianjia.beike',
1072
+ 安居客: 'com.anjuke.android.app',
1073
+ 同花顺: 'com.hexin.plat.android',
1074
+ 星穹铁道: 'com.miHoYo.hkrpg',
1075
+ '崩坏:星穹铁道': 'com.miHoYo.hkrpg',
1076
+ 恋与深空: 'com.papegames.lysk.cn',
1077
+ AndroidSystemSettings: 'com.android.settings',
1078
+ 'Android System Settings': 'com.android.settings',
1079
+ 'Android System Settings': 'com.android.settings',
1080
+ 'Android-System-Settings': 'com.android.settings',
1081
+ Settings: 'com.android.settings',
1082
+ AudioRecorder: 'com.android.soundrecorder',
1083
+ audiorecorder: 'com.android.soundrecorder',
1084
+ Bluecoins: 'com.rammigsoftware.bluecoins',
1085
+ bluecoins: 'com.rammigsoftware.bluecoins',
1086
+ Broccoli: 'com.flauschcode.broccoli',
1087
+ broccoli: 'com.flauschcode.broccoli',
1088
+ 'Booking.com': 'com.booking',
1089
+ Booking: 'com.booking',
1090
+ 'booking.com': 'com.booking',
1091
+ booking: 'com.booking',
1092
+ 'BOOKING.COM': 'com.booking',
1093
+ Chrome: 'com.android.chrome',
1094
+ chrome: 'com.android.chrome',
1095
+ 'Google Chrome': 'com.android.chrome',
1096
+ Clock: 'com.android.deskclock',
1097
+ clock: 'com.android.deskclock',
1098
+ Contacts: 'com.android.contacts',
1099
+ contacts: 'com.android.contacts',
1100
+ Duolingo: 'com.duolingo',
1101
+ duolingo: 'com.duolingo',
1102
+ Expedia: 'com.expedia.bookings',
1103
+ expedia: 'com.expedia.bookings',
1104
+ Files: 'com.android.fileexplorer',
1105
+ files: 'com.android.fileexplorer',
1106
+ 'File Manager': 'com.android.fileexplorer',
1107
+ 'file manager': 'com.android.fileexplorer',
1108
+ gmail: 'com.google.android.gm',
1109
+ Gmail: 'com.google.android.gm',
1110
+ GoogleMail: 'com.google.android.gm',
1111
+ 'Google Mail': 'com.google.android.gm',
1112
+ GoogleFiles: 'com.google.android.apps.nbu.files',
1113
+ googlefiles: 'com.google.android.apps.nbu.files',
1114
+ FilesbyGoogle: 'com.google.android.apps.nbu.files',
1115
+ GoogleCalendar: 'com.google.android.calendar',
1116
+ 'Google-Calendar': 'com.google.android.calendar',
1117
+ 'Google Calendar': 'com.google.android.calendar',
1118
+ 'google-calendar': 'com.google.android.calendar',
1119
+ 'google calendar': 'com.google.android.calendar',
1120
+ GoogleChat: 'com.google.android.apps.dynamite',
1121
+ 'Google Chat': 'com.google.android.apps.dynamite',
1122
+ 'Google-Chat': 'com.google.android.apps.dynamite',
1123
+ GoogleClock: 'com.google.android.deskclock',
1124
+ 'Google Clock': 'com.google.android.deskclock',
1125
+ 'Google-Clock': 'com.google.android.deskclock',
1126
+ GoogleContacts: 'com.google.android.contacts',
1127
+ 'Google-Contacts': 'com.google.android.contacts',
1128
+ 'Google Contacts': 'com.google.android.contacts',
1129
+ 'google-contacts': 'com.google.android.contacts',
1130
+ 'google contacts': 'com.google.android.contacts',
1131
+ GoogleDocs: 'com.google.android.apps.docs.editors.docs',
1132
+ 'Google Docs': 'com.google.android.apps.docs.editors.docs',
1133
+ googledocs: 'com.google.android.apps.docs.editors.docs',
1134
+ 'google docs': 'com.google.android.apps.docs.editors.docs',
1135
+ 'Google Drive': 'com.google.android.apps.docs',
1136
+ 'Google-Drive': 'com.google.android.apps.docs',
1137
+ 'google drive': 'com.google.android.apps.docs',
1138
+ 'google-drive': 'com.google.android.apps.docs',
1139
+ GoogleDrive: 'com.google.android.apps.docs',
1140
+ Googledrive: 'com.google.android.apps.docs',
1141
+ googledrive: 'com.google.android.apps.docs',
1142
+ GoogleFit: 'com.google.android.apps.fitness',
1143
+ googlefit: 'com.google.android.apps.fitness',
1144
+ GoogleKeep: 'com.google.android.keep',
1145
+ googlekeep: 'com.google.android.keep',
1146
+ GoogleMaps: 'com.google.android.apps.maps',
1147
+ 'Google Maps': 'com.google.android.apps.maps',
1148
+ googlemaps: 'com.google.android.apps.maps',
1149
+ 'google maps': 'com.google.android.apps.maps',
1150
+ 'Google Play Books': 'com.google.android.apps.books',
1151
+ 'Google-Play-Books': 'com.google.android.apps.books',
1152
+ 'google play books': 'com.google.android.apps.books',
1153
+ 'google-play-books': 'com.google.android.apps.books',
1154
+ GooglePlayBooks: 'com.google.android.apps.books',
1155
+ googleplaybooks: 'com.google.android.apps.books',
1156
+ GooglePlayStore: 'com.android.vending',
1157
+ 'Google Play Store': 'com.android.vending',
1158
+ 'Google-Play-Store': 'com.android.vending',
1159
+ GoogleSlides: 'com.google.android.apps.docs.editors.slides',
1160
+ 'Google Slides': 'com.google.android.apps.docs.editors.slides',
1161
+ 'Google-Slides': 'com.google.android.apps.docs.editors.slides',
1162
+ GoogleTasks: 'com.google.android.apps.tasks',
1163
+ 'Google Tasks': 'com.google.android.apps.tasks',
1164
+ 'Google-Tasks': 'com.google.android.apps.tasks',
1165
+ Joplin: 'net.cozic.joplin',
1166
+ joplin: 'net.cozic.joplin',
1167
+ McDonald: 'com.mcdonalds.app',
1168
+ mcdonald: 'com.mcdonalds.app',
1169
+ Osmand: 'net.osmand',
1170
+ osmand: 'net.osmand',
1171
+ PiMusicPlayer: 'com.Project100Pi.themusicplayer',
1172
+ pimusicplayer: 'com.Project100Pi.themusicplayer',
1173
+ Quora: 'com.quora.android',
1174
+ quora: 'com.quora.android',
1175
+ Reddit: 'com.reddit.frontpage',
1176
+ reddit: 'com.reddit.frontpage',
1177
+ RetroMusic: 'code.name.monkey.retromusic',
1178
+ retromusic: 'code.name.monkey.retromusic',
1179
+ SimpleCalendarPro: 'com.scientificcalculatorplus.simplecalculator.basiccalculator.mathcalc',
1180
+ SimpleSMSMessenger: 'com.simplemobiletools.smsmessenger',
1181
+ Telegram: 'org.telegram.messenger',
1182
+ temu: 'com.einnovation.temu',
1183
+ Temu: 'com.einnovation.temu',
1184
+ Tiktok: 'com.zhiliaoapp.musically',
1185
+ tiktok: 'com.zhiliaoapp.musically',
1186
+ Twitter: 'com.twitter.android',
1187
+ twitter: 'com.twitter.android',
1188
+ X: 'com.twitter.android',
1189
+ VLC: 'org.videolan.vlc',
1190
+ WeChat: 'com.tencent.mm',
1191
+ wechat: 'com.tencent.mm',
1192
+ Whatsapp: 'com.whatsapp',
1193
+ WhatsApp: 'com.whatsapp'
1194
+ };
1015
1195
  const debugUtils = (0, logger_namespaceObject.getDebug)('android:utils');
1016
1196
  async function getConnectedDevices() {
1017
1197
  try {
@@ -1045,7 +1225,12 @@ class AndroidAgent extends agent_namespaceObject.Agent {
1045
1225
  return (...args)=>action(args[0]);
1046
1226
  }
1047
1227
  constructor(device, opts){
1048
- super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
1228
+ super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0), agent_define_property(this, "appNameMapping", void 0);
1229
+ this.appNameMapping = {
1230
+ ...defaultAppNameMapping,
1231
+ ...opts?.appNameMapping || {}
1232
+ };
1233
+ device.setAppNameMapping(this.appNameMapping);
1049
1234
  this.launch = this.createActionWrapper('Launch');
1050
1235
  this.runAdbShell = this.createActionWrapper('RunAdbShell');
1051
1236
  this.back = this.createActionWrapper('AndroidBackButton');
@@ -43,6 +43,176 @@ __webpack_require__.d(__webpack_exports__, {
43
43
  const mcp_namespaceObject = require("@midscene/shared/mcp");
44
44
  const agent_namespaceObject = require("@midscene/core/agent");
45
45
  const logger_namespaceObject = require("@midscene/shared/logger");
46
+ const defaultAppNameMapping = {
47
+ 微信: 'com.tencent.mm',
48
+ QQ: 'com.tencent.mobileqq',
49
+ 微博: 'com.sina.weibo',
50
+ 淘宝: 'com.taobao.taobao',
51
+ 京东: 'com.jingdong.app.mall',
52
+ 拼多多: 'com.xunmeng.pinduoduo',
53
+ 淘宝闪购: 'com.taobao.taobao',
54
+ 京东秒送: 'com.jingdong.app.mall',
55
+ 小红书: 'com.xingin.xhs',
56
+ 豆瓣: 'com.douban.frodo',
57
+ 知乎: 'com.zhihu.android',
58
+ 高德地图: 'com.autonavi.minimap',
59
+ 百度地图: 'com.baidu.BaiduMap',
60
+ 美团: 'com.sankuai.meituan',
61
+ 大众点评: 'com.dianping.v1',
62
+ 饿了么: 'me.ele',
63
+ 肯德基: 'com.yek.android.kfc.activitys',
64
+ 携程: 'ctrip.android.view',
65
+ 铁路12306: 'com.MobileTicket',
66
+ 12306: 'com.MobileTicket',
67
+ 去哪儿: 'com.Qunar',
68
+ 去哪儿旅行: 'com.Qunar',
69
+ 滴滴出行: 'com.sdu.didi.psnger',
70
+ bilibili: 'tv.danmaku.bili',
71
+ 抖音: 'com.ss.android.ugc.aweme',
72
+ 快手: 'com.smile.gifmaker',
73
+ 腾讯视频: 'com.tencent.qqlive',
74
+ 爱奇艺: 'com.qiyi.video',
75
+ 优酷视频: 'com.youku.phone',
76
+ 芒果TV: 'com.hunantv.imgo.activity',
77
+ 红果短剧: 'com.phoenix.read',
78
+ 网易云音乐: 'com.netease.cloudmusic',
79
+ QQ音乐: 'com.tencent.qqmusic',
80
+ 汽水音乐: 'com.luna.music',
81
+ 喜马拉雅: 'com.ximalaya.ting.android',
82
+ 番茄小说: 'com.dragon.read',
83
+ 番茄免费小说: 'com.dragon.read',
84
+ 七猫免费小说: 'com.kmxs.reader',
85
+ 飞书: 'com.ss.android.lark',
86
+ QQ邮箱: 'com.tencent.androidqqmail',
87
+ 豆包: 'com.larus.nova',
88
+ keep: 'com.gotokeep.keep',
89
+ 美柚: 'com.lingan.seeyou',
90
+ 腾讯新闻: 'com.tencent.news',
91
+ 今日头条: 'com.ss.android.article.news',
92
+ 贝壳找房: 'com.lianjia.beike',
93
+ 安居客: 'com.anjuke.android.app',
94
+ 同花顺: 'com.hexin.plat.android',
95
+ 星穹铁道: 'com.miHoYo.hkrpg',
96
+ '崩坏:星穹铁道': 'com.miHoYo.hkrpg',
97
+ 恋与深空: 'com.papegames.lysk.cn',
98
+ AndroidSystemSettings: 'com.android.settings',
99
+ 'Android System Settings': 'com.android.settings',
100
+ 'Android System Settings': 'com.android.settings',
101
+ 'Android-System-Settings': 'com.android.settings',
102
+ Settings: 'com.android.settings',
103
+ AudioRecorder: 'com.android.soundrecorder',
104
+ audiorecorder: 'com.android.soundrecorder',
105
+ Bluecoins: 'com.rammigsoftware.bluecoins',
106
+ bluecoins: 'com.rammigsoftware.bluecoins',
107
+ Broccoli: 'com.flauschcode.broccoli',
108
+ broccoli: 'com.flauschcode.broccoli',
109
+ 'Booking.com': 'com.booking',
110
+ Booking: 'com.booking',
111
+ 'booking.com': 'com.booking',
112
+ booking: 'com.booking',
113
+ 'BOOKING.COM': 'com.booking',
114
+ Chrome: 'com.android.chrome',
115
+ chrome: 'com.android.chrome',
116
+ 'Google Chrome': 'com.android.chrome',
117
+ Clock: 'com.android.deskclock',
118
+ clock: 'com.android.deskclock',
119
+ Contacts: 'com.android.contacts',
120
+ contacts: 'com.android.contacts',
121
+ Duolingo: 'com.duolingo',
122
+ duolingo: 'com.duolingo',
123
+ Expedia: 'com.expedia.bookings',
124
+ expedia: 'com.expedia.bookings',
125
+ Files: 'com.android.fileexplorer',
126
+ files: 'com.android.fileexplorer',
127
+ 'File Manager': 'com.android.fileexplorer',
128
+ 'file manager': 'com.android.fileexplorer',
129
+ gmail: 'com.google.android.gm',
130
+ Gmail: 'com.google.android.gm',
131
+ GoogleMail: 'com.google.android.gm',
132
+ 'Google Mail': 'com.google.android.gm',
133
+ GoogleFiles: 'com.google.android.apps.nbu.files',
134
+ googlefiles: 'com.google.android.apps.nbu.files',
135
+ FilesbyGoogle: 'com.google.android.apps.nbu.files',
136
+ GoogleCalendar: 'com.google.android.calendar',
137
+ 'Google-Calendar': 'com.google.android.calendar',
138
+ 'Google Calendar': 'com.google.android.calendar',
139
+ 'google-calendar': 'com.google.android.calendar',
140
+ 'google calendar': 'com.google.android.calendar',
141
+ GoogleChat: 'com.google.android.apps.dynamite',
142
+ 'Google Chat': 'com.google.android.apps.dynamite',
143
+ 'Google-Chat': 'com.google.android.apps.dynamite',
144
+ GoogleClock: 'com.google.android.deskclock',
145
+ 'Google Clock': 'com.google.android.deskclock',
146
+ 'Google-Clock': 'com.google.android.deskclock',
147
+ GoogleContacts: 'com.google.android.contacts',
148
+ 'Google-Contacts': 'com.google.android.contacts',
149
+ 'Google Contacts': 'com.google.android.contacts',
150
+ 'google-contacts': 'com.google.android.contacts',
151
+ 'google contacts': 'com.google.android.contacts',
152
+ GoogleDocs: 'com.google.android.apps.docs.editors.docs',
153
+ 'Google Docs': 'com.google.android.apps.docs.editors.docs',
154
+ googledocs: 'com.google.android.apps.docs.editors.docs',
155
+ 'google docs': 'com.google.android.apps.docs.editors.docs',
156
+ 'Google Drive': 'com.google.android.apps.docs',
157
+ 'Google-Drive': 'com.google.android.apps.docs',
158
+ 'google drive': 'com.google.android.apps.docs',
159
+ 'google-drive': 'com.google.android.apps.docs',
160
+ GoogleDrive: 'com.google.android.apps.docs',
161
+ Googledrive: 'com.google.android.apps.docs',
162
+ googledrive: 'com.google.android.apps.docs',
163
+ GoogleFit: 'com.google.android.apps.fitness',
164
+ googlefit: 'com.google.android.apps.fitness',
165
+ GoogleKeep: 'com.google.android.keep',
166
+ googlekeep: 'com.google.android.keep',
167
+ GoogleMaps: 'com.google.android.apps.maps',
168
+ 'Google Maps': 'com.google.android.apps.maps',
169
+ googlemaps: 'com.google.android.apps.maps',
170
+ 'google maps': 'com.google.android.apps.maps',
171
+ 'Google Play Books': 'com.google.android.apps.books',
172
+ 'Google-Play-Books': 'com.google.android.apps.books',
173
+ 'google play books': 'com.google.android.apps.books',
174
+ 'google-play-books': 'com.google.android.apps.books',
175
+ GooglePlayBooks: 'com.google.android.apps.books',
176
+ googleplaybooks: 'com.google.android.apps.books',
177
+ GooglePlayStore: 'com.android.vending',
178
+ 'Google Play Store': 'com.android.vending',
179
+ 'Google-Play-Store': 'com.android.vending',
180
+ GoogleSlides: 'com.google.android.apps.docs.editors.slides',
181
+ 'Google Slides': 'com.google.android.apps.docs.editors.slides',
182
+ 'Google-Slides': 'com.google.android.apps.docs.editors.slides',
183
+ GoogleTasks: 'com.google.android.apps.tasks',
184
+ 'Google Tasks': 'com.google.android.apps.tasks',
185
+ 'Google-Tasks': 'com.google.android.apps.tasks',
186
+ Joplin: 'net.cozic.joplin',
187
+ joplin: 'net.cozic.joplin',
188
+ McDonald: 'com.mcdonalds.app',
189
+ mcdonald: 'com.mcdonalds.app',
190
+ Osmand: 'net.osmand',
191
+ osmand: 'net.osmand',
192
+ PiMusicPlayer: 'com.Project100Pi.themusicplayer',
193
+ pimusicplayer: 'com.Project100Pi.themusicplayer',
194
+ Quora: 'com.quora.android',
195
+ quora: 'com.quora.android',
196
+ Reddit: 'com.reddit.frontpage',
197
+ reddit: 'com.reddit.frontpage',
198
+ RetroMusic: 'code.name.monkey.retromusic',
199
+ retromusic: 'code.name.monkey.retromusic',
200
+ SimpleCalendarPro: 'com.scientificcalculatorplus.simplecalculator.basiccalculator.mathcalc',
201
+ SimpleSMSMessenger: 'com.simplemobiletools.smsmessenger',
202
+ Telegram: 'org.telegram.messenger',
203
+ temu: 'com.einnovation.temu',
204
+ Temu: 'com.einnovation.temu',
205
+ Tiktok: 'com.zhiliaoapp.musically',
206
+ tiktok: 'com.zhiliaoapp.musically',
207
+ Twitter: 'com.twitter.android',
208
+ twitter: 'com.twitter.android',
209
+ X: 'com.twitter.android',
210
+ VLC: 'org.videolan.vlc',
211
+ WeChat: 'com.tencent.mm',
212
+ wechat: 'com.tencent.mm',
213
+ Whatsapp: 'com.whatsapp',
214
+ WhatsApp: 'com.whatsapp'
215
+ };
46
216
  const external_node_assert_namespaceObject = require("node:assert");
47
217
  var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
48
218
  const external_node_fs_namespaceObject = require("node:fs");
@@ -271,6 +441,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
271
441
  }
272
442
  });
273
443
  }
444
+ setAppNameMapping(mapping) {
445
+ this.appNameMapping = mapping;
446
+ }
447
+ resolvePackageName(appName) {
448
+ if (appName in this.appNameMapping) return this.appNameMapping[appName];
449
+ }
274
450
  async launch(uri) {
275
451
  const adb = await this.getAdb();
276
452
  this.uri = uri;
@@ -283,7 +459,10 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
283
459
  pkg: appPackage,
284
460
  activity: appActivity
285
461
  });
286
- } else await adb.activateApp(uri);
462
+ } else {
463
+ const resolvedUri = this.resolvePackageName(uri) ?? uri;
464
+ await adb.activateApp(resolvedUri);
465
+ }
287
466
  debugDevice(`Successfully launched: ${uri}`);
288
467
  } catch (error) {
289
468
  debugDevice(`Error launching ${uri}: ${error}`);
@@ -958,6 +1137,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
958
1137
  _define_property(this, "customActions", void 0);
959
1138
  _define_property(this, "cachedScreenSize", null);
960
1139
  _define_property(this, "cachedOrientation", null);
1140
+ _define_property(this, "appNameMapping", {});
961
1141
  _define_property(this, "interfaceType", 'android');
962
1142
  _define_property(this, "uri", void 0);
963
1143
  _define_property(this, "options", void 0);
@@ -968,7 +1148,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
968
1148
  }
969
1149
  }
970
1150
  const runAdbShellParamSchema = core_namespaceObject.z.string().describe('ADB shell command to execute');
971
- const launchParamSchema = core_namespaceObject.z.string().describe('App package name or URL to launch');
1151
+ const launchParamSchema = core_namespaceObject.z.string().describe('App package name or URL or app name to launch,');
972
1152
  const createPlatformActions = (device)=>({
973
1153
  RunAdbShell: (0, device_namespaceObject.defineAction)({
974
1154
  name: 'RunAdbShell',
@@ -1044,7 +1224,12 @@ class AndroidAgent extends agent_namespaceObject.Agent {
1044
1224
  return (...args)=>action(args[0]);
1045
1225
  }
1046
1226
  constructor(device, opts){
1047
- super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
1227
+ super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0), agent_define_property(this, "appNameMapping", void 0);
1228
+ this.appNameMapping = {
1229
+ ...defaultAppNameMapping,
1230
+ ...opts?.appNameMapping || {}
1231
+ };
1232
+ device.setAppNameMapping(this.appNameMapping);
1048
1233
  this.launch = this.createActionWrapper('Launch');
1049
1234
  this.runAdbShell = this.createActionWrapper('RunAdbShell');
1050
1235
  this.back = this.createActionWrapper('AndroidBackButton');
@@ -40,11 +40,21 @@ export declare class AndroidAgent extends Agent<AndroidDevice> {
40
40
  * Trigger the system recent apps operation on Android devices
41
41
  */
42
42
  recentApps: WrappedAction<DeviceActionAndroidRecentAppsButton>;
43
+ /**
44
+ * User-provided app name to package name mapping
45
+ */
46
+ private appNameMapping;
43
47
  constructor(device: AndroidDevice, opts?: AndroidAgentOpt);
44
48
  private createActionWrapper;
45
49
  }
46
50
 
47
- export declare type AndroidAgentOpt = AgentOpt;
51
+ export declare type AndroidAgentOpt = AgentOpt & {
52
+ /**
53
+ * Custom mapping of app names to package names
54
+ * User-provided mappings will take precedence over default mappings
55
+ */
56
+ appNameMapping?: Record<string, string>;
57
+ };
48
58
 
49
59
  export declare class AndroidDevice implements AbstractInterface {
50
60
  private deviceId;
@@ -59,6 +69,7 @@ export declare class AndroidDevice implements AbstractInterface {
59
69
  private customActions?;
60
70
  private cachedScreenSize;
61
71
  private cachedOrientation;
72
+ private appNameMapping;
62
73
  interfaceType: InterfaceType;
63
74
  uri: string | undefined;
64
75
  options?: AndroidDeviceOpt;
@@ -68,6 +79,15 @@ export declare class AndroidDevice implements AbstractInterface {
68
79
  connect(): Promise<ADB>;
69
80
  getAdb(): Promise<ADB>;
70
81
  private createAdbProxy;
82
+ /**
83
+ * Set the app name to package name mapping
84
+ */
85
+ setAppNameMapping(mapping: Record<string, string>): void;
86
+ /**
87
+ * Resolve app name to package name using the mapping
88
+ * @param appName The app name to resolve
89
+ */
90
+ private resolvePackageName;
71
91
  launch(uri: string): Promise<AndroidDevice>;
72
92
  execYadb(keyboardContent: string): Promise<void>;
73
93
  getElementsInfo(): Promise<ElementInfo[]>;
@@ -42,11 +42,21 @@ declare class AndroidAgent extends Agent<AndroidDevice> {
42
42
  * Trigger the system recent apps operation on Android devices
43
43
  */
44
44
  recentApps: WrappedAction<DeviceActionAndroidRecentAppsButton>;
45
+ /**
46
+ * User-provided app name to package name mapping
47
+ */
48
+ private appNameMapping;
45
49
  constructor(device: AndroidDevice, opts?: AndroidAgentOpt);
46
50
  private createActionWrapper;
47
51
  }
48
52
 
49
- declare type AndroidAgentOpt = AgentOpt;
53
+ declare type AndroidAgentOpt = AgentOpt & {
54
+ /**
55
+ * Custom mapping of app names to package names
56
+ * User-provided mappings will take precedence over default mappings
57
+ */
58
+ appNameMapping?: Record<string, string>;
59
+ };
50
60
 
51
61
  declare class AndroidDevice implements AbstractInterface {
52
62
  private deviceId;
@@ -61,6 +71,7 @@ declare class AndroidDevice implements AbstractInterface {
61
71
  private customActions?;
62
72
  private cachedScreenSize;
63
73
  private cachedOrientation;
74
+ private appNameMapping;
64
75
  interfaceType: InterfaceType;
65
76
  uri: string | undefined;
66
77
  options?: AndroidDeviceOpt;
@@ -70,6 +81,15 @@ declare class AndroidDevice implements AbstractInterface {
70
81
  connect(): Promise<ADB>;
71
82
  getAdb(): Promise<ADB>;
72
83
  private createAdbProxy;
84
+ /**
85
+ * Set the app name to package name mapping
86
+ */
87
+ setAppNameMapping(mapping: Record<string, string>): void;
88
+ /**
89
+ * Resolve app name to package name using the mapping
90
+ * @param appName The app name to resolve
91
+ */
92
+ private resolvePackageName;
73
93
  launch(uri: string): Promise<AndroidDevice>;
74
94
  execYadb(keyboardContent: string): Promise<void>;
75
95
  getElementsInfo(): Promise<ElementInfo[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/android",
3
- "version": "1.2.1",
3
+ "version": "1.2.2-beta-20260115065918.0",
4
4
  "description": "Android automation library for Midscene",
5
5
  "keywords": [
6
6
  "Android UI automation",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "appium-adb": "12.12.1",
35
- "@midscene/shared": "1.2.1",
36
- "@midscene/core": "1.2.1"
35
+ "@midscene/core": "1.2.2-beta-20260115065918.0",
36
+ "@midscene/shared": "1.2.2-beta-20260115065918.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@rslib/core": "^0.18.3",
@@ -43,7 +43,7 @@
43
43
  "tsx": "^4.19.2",
44
44
  "vitest": "3.0.5",
45
45
  "zod": "3.24.3",
46
- "@midscene/playground": "1.2.1"
46
+ "@midscene/playground": "1.2.2-beta-20260115065918.0"
47
47
  },
48
48
  "license": "MIT",
49
49
  "scripts": {