@midscene/android 1.0.1-beta-20251029093754.0 → 1.0.1-beta-20251103074550.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
@@ -173,9 +173,11 @@ class AndroidDevice {
173
173
  await this.clearInput(element);
174
174
  })
175
175
  ];
176
+ const platformSpecificActions = Object.values(createPlatformActions(this));
176
177
  const customActions = this.customActions || [];
177
178
  return [
178
179
  ...defaultActions,
180
+ ...platformSpecificActions,
179
181
  ...customActions
180
182
  ];
181
183
  }
@@ -945,6 +947,29 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
945
947
  this.customActions = null == options ? void 0 : options.customActions;
946
948
  }
947
949
  }
950
+ const runAdbShellParamSchema = z.string().describe('ADB shell command to execute');
951
+ const launchParamSchema = z.string().describe('App package name or URL to launch');
952
+ const createPlatformActions = (device)=>({
953
+ RunAdbShell: defineAction({
954
+ name: 'RunAdbShell',
955
+ description: 'Execute ADB shell command on Android device',
956
+ interfaceAlias: 'runAdbShell',
957
+ paramSchema: runAdbShellParamSchema,
958
+ call: async (param)=>{
959
+ const adb = await device.getAdb();
960
+ return await adb.shell(param);
961
+ }
962
+ }),
963
+ Launch: defineAction({
964
+ name: 'Launch',
965
+ description: 'Launch an Android app or URL',
966
+ interfaceAlias: 'launch',
967
+ paramSchema: launchParamSchema,
968
+ call: async (param)=>{
969
+ await device.launch(param);
970
+ }
971
+ })
972
+ });
948
973
  const debugUtils = getDebug('android:utils');
949
974
  async function getConnectedDevices() {
950
975
  try {
@@ -961,15 +986,22 @@ async function getConnectedDevices() {
961
986
  });
962
987
  }
963
988
  }
989
+ function agent_define_property(obj, key, value) {
990
+ if (key in obj) Object.defineProperty(obj, key, {
991
+ value: value,
992
+ enumerable: true,
993
+ configurable: true,
994
+ writable: true
995
+ });
996
+ else obj[key] = value;
997
+ return obj;
998
+ }
964
999
  const debugAgent = getDebug('android:agent');
965
1000
  class AndroidAgent extends Agent {
966
- async launch(uri) {
967
- const device = this.page;
968
- await device.launch(uri);
969
- }
970
- async runAdbShell(command) {
971
- const adb = await this.page.getAdb();
972
- return await adb.shell(command);
1001
+ constructor(device, opts){
1002
+ super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0);
1003
+ this.launch = this.wrapActionInActionSpace('Launch');
1004
+ this.runAdbShell = this.wrapActionInActionSpace('RunAdbShell');
973
1005
  }
974
1006
  }
975
1007
  async function agentFromAdbDevice(deviceId, opts) {
package/dist/lib/index.js CHANGED
@@ -219,9 +219,11 @@ class AndroidDevice {
219
219
  await this.clearInput(element);
220
220
  })
221
221
  ];
222
+ const platformSpecificActions = Object.values(createPlatformActions(this));
222
223
  const customActions = this.customActions || [];
223
224
  return [
224
225
  ...defaultActions,
226
+ ...platformSpecificActions,
225
227
  ...customActions
226
228
  ];
227
229
  }
@@ -991,6 +993,29 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
991
993
  this.customActions = null == options ? void 0 : options.customActions;
992
994
  }
993
995
  }
996
+ const runAdbShellParamSchema = core_namespaceObject.z.string().describe('ADB shell command to execute');
997
+ const launchParamSchema = core_namespaceObject.z.string().describe('App package name or URL to launch');
998
+ const createPlatformActions = (device)=>({
999
+ RunAdbShell: (0, device_namespaceObject.defineAction)({
1000
+ name: 'RunAdbShell',
1001
+ description: 'Execute ADB shell command on Android device',
1002
+ interfaceAlias: 'runAdbShell',
1003
+ paramSchema: runAdbShellParamSchema,
1004
+ call: async (param)=>{
1005
+ const adb = await device.getAdb();
1006
+ return await adb.shell(param);
1007
+ }
1008
+ }),
1009
+ Launch: (0, device_namespaceObject.defineAction)({
1010
+ name: 'Launch',
1011
+ description: 'Launch an Android app or URL',
1012
+ interfaceAlias: 'launch',
1013
+ paramSchema: launchParamSchema,
1014
+ call: async (param)=>{
1015
+ await device.launch(param);
1016
+ }
1017
+ })
1018
+ });
994
1019
  const agent_namespaceObject = require("@midscene/core/agent");
995
1020
  const debugUtils = (0, logger_namespaceObject.getDebug)('android:utils');
996
1021
  async function getConnectedDevices() {
@@ -1008,15 +1033,22 @@ async function getConnectedDevices() {
1008
1033
  });
1009
1034
  }
1010
1035
  }
1036
+ function agent_define_property(obj, key, value) {
1037
+ if (key in obj) Object.defineProperty(obj, key, {
1038
+ value: value,
1039
+ enumerable: true,
1040
+ configurable: true,
1041
+ writable: true
1042
+ });
1043
+ else obj[key] = value;
1044
+ return obj;
1045
+ }
1011
1046
  const debugAgent = (0, logger_namespaceObject.getDebug)('android:agent');
1012
1047
  class AndroidAgent extends agent_namespaceObject.Agent {
1013
- async launch(uri) {
1014
- const device = this.page;
1015
- await device.launch(uri);
1016
- }
1017
- async runAdbShell(command) {
1018
- const adb = await this.page.getAdb();
1019
- return await adb.shell(command);
1048
+ constructor(device, opts){
1049
+ super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0);
1050
+ this.launch = this.wrapActionInActionSpace('Launch');
1051
+ this.runAdbShell = this.wrapActionInActionSpace('RunAdbShell');
1020
1052
  }
1021
1053
  }
1022
1054
  async function agentFromAdbDevice(deviceId, opts) {
@@ -1,4 +1,6 @@
1
1
  import { AbstractInterface } from '@midscene/core/device';
2
+ import type { ActionParam } from '@midscene/core';
3
+ import type { ActionReturn } from '@midscene/core';
2
4
  import { ADB } from 'appium-adb';
3
5
  import { Agent } from '@midscene/core/agent';
4
6
  import { AgentOpt } from '@midscene/core/agent';
@@ -11,12 +13,20 @@ import { InterfaceType } from '@midscene/core';
11
13
  import { overrideAIConfig } from '@midscene/shared/env';
12
14
  import { Point } from '@midscene/core';
13
15
  import { Size } from '@midscene/core';
16
+ import { z } from '@midscene/core';
14
17
 
15
18
  export declare function agentFromAdbDevice(deviceId?: string, opts?: AndroidAgentOpt & AndroidDeviceOpt): Promise<AndroidAgent>;
16
19
 
17
20
  export declare class AndroidAgent extends Agent<AndroidDevice> {
18
- launch(uri: string): Promise<void>;
19
- runAdbShell(command: string): Promise<string>;
21
+ /**
22
+ * Launch an Android app or URL
23
+ */
24
+ launch: WrappedAction<DeviceActionLaunch>;
25
+ /**
26
+ * Execute ADB shell command on Android device
27
+ */
28
+ runAdbShell: WrappedAction<DeviceActionRunAdbShell>;
29
+ constructor(device: AndroidDevice, opts?: AndroidAgentOpt);
20
30
  }
21
31
 
22
32
  declare type AndroidAgentOpt = AgentOpt;
@@ -116,8 +126,29 @@ export declare class AndroidDevice implements AbstractInterface {
116
126
  hideKeyboard(options?: AndroidDeviceInputOpt, timeoutMs?: number): Promise<boolean>;
117
127
  }
118
128
 
129
+ declare type DeviceActionLaunch = DeviceAction<LaunchParam, void>;
130
+
131
+ declare type DeviceActionRunAdbShell = DeviceAction<RunAdbShellParam, string>;
132
+
119
133
  export declare function getConnectedDevices(): Promise<Device[]>;
120
134
 
135
+ declare type LaunchParam = z.infer<typeof launchParamSchema>;
136
+
137
+ declare const launchParamSchema: z.ZodString;
138
+
121
139
  export { overrideAIConfig }
122
140
 
141
+ declare type RunAdbShellParam = z.infer<typeof runAdbShellParamSchema>;
142
+
143
+ /**
144
+ * Platform-specific action definitions for Android
145
+ * Single source of truth for both runtime behavior and type definitions
146
+ */
147
+ declare const runAdbShellParamSchema: z.ZodString;
148
+
149
+ /**
150
+ * Helper type to convert DeviceAction to wrapped method signature
151
+ */
152
+ declare type WrappedAction<T extends DeviceAction> = (param: ActionParam<T>) => Promise<ActionReturn<T>>;
153
+
123
154
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/android",
3
- "version": "1.0.1-beta-20251029093754.0",
3
+ "version": "1.0.1-beta-20251103074550.0",
4
4
  "description": "Android automation library for Midscene",
5
5
  "keywords": [
6
6
  "Android UI automation",
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "appium-adb": "12.12.1",
30
- "@midscene/shared": "1.0.1-beta-20251029093754.0",
31
- "@midscene/core": "1.0.1-beta-20251029093754.0"
30
+ "@midscene/core": "1.0.1-beta-20251103074550.0",
31
+ "@midscene/shared": "1.0.1-beta-20251103074550.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@rslib/core": "^0.11.2",
@@ -37,7 +37,8 @@
37
37
  "typescript": "^5.8.3",
38
38
  "tsx": "^4.19.2",
39
39
  "vitest": "3.0.5",
40
- "@midscene/playground": "1.0.1-beta-20251029093754.0"
40
+ "zod": "3.24.3",
41
+ "@midscene/playground": "1.0.1-beta-20251103074550.0"
41
42
  },
42
43
  "license": "MIT",
43
44
  "scripts": {