@midscene/android 1.12.4-beta-20260903111111.0 → 1.12.4
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/cli.mjs +111 -1
- package/dist/es/index.mjs +111 -1
- package/dist/es/test-runner.mjs +105 -0
- package/dist/lib/cli.js +117 -1
- package/dist/lib/index.js +138 -3
- package/dist/lib/test-runner.js +151 -0
- package/dist/types/index.d.ts +32 -1
- package/dist/types/test-runner.d.ts +31 -0
- package/package.json +10 -5
package/dist/es/cli.mjs
CHANGED
|
@@ -15,6 +15,8 @@ import { createDefaultMobileActions, defineAction, resolveTextInputOptions, send
|
|
|
15
15
|
import { getTmpFile, sleep } from "@midscene/core/utils";
|
|
16
16
|
import { MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT, MIDSCENE_ANDROID_IME_STRATEGY, MIDSCENE_ANDROID_SCREENSHOT_STRATEGY, globalConfigManager } from "@midscene/shared/env";
|
|
17
17
|
import { ADB, getSdkRootFromEnv } from "appium-adb";
|
|
18
|
+
import { createAgentTestRunnerNodeDefinition } from "@midscene/core/agent/test-runner";
|
|
19
|
+
import { z as v4_z } from "zod/v4";
|
|
18
20
|
var __webpack_modules__ = {
|
|
19
21
|
"./src/resource-path.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
20
22
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -3225,6 +3227,108 @@ const createPlatformActions = (visualActions)=>({
|
|
|
3225
3227
|
}
|
|
3226
3228
|
})
|
|
3227
3229
|
});
|
|
3230
|
+
const defineAndroidAgentNode = createAgentTestRunnerNodeDefinition('an Android Agent');
|
|
3231
|
+
const nonBlankText = (description)=>v4_z.string().regex(/\S/, 'value must contain a non-whitespace character').describe(description);
|
|
3232
|
+
const launchInputSchema = v4_z.strictObject({
|
|
3233
|
+
uri: nonBlankText('The app, URL, URI, or package name to launch.')
|
|
3234
|
+
});
|
|
3235
|
+
const terminateInputSchema = v4_z.strictObject({
|
|
3236
|
+
uri: nonBlankText('The package name or app name to terminate.')
|
|
3237
|
+
});
|
|
3238
|
+
const runAdbShellOptionsInputSchema = v4_z.strictObject({
|
|
3239
|
+
timeout: v4_z.number().int().positive().optional().describe('ADB shell command timeout in milliseconds.')
|
|
3240
|
+
});
|
|
3241
|
+
const runAdbShellInputSchema = v4_z.strictObject({
|
|
3242
|
+
command: nonBlankText('The shell command to execute, without an adb shell prefix.'),
|
|
3243
|
+
options: runAdbShellOptionsInputSchema.optional()
|
|
3244
|
+
});
|
|
3245
|
+
const emptyInputSchema = v4_z.strictObject({});
|
|
3246
|
+
const launchNode = defineAndroidAgentNode({
|
|
3247
|
+
method: 'launch',
|
|
3248
|
+
description: 'Launch an application through the current Android Agent.',
|
|
3249
|
+
stringInputKey: 'uri',
|
|
3250
|
+
inputSchema: launchInputSchema,
|
|
3251
|
+
toArgs: (input)=>[
|
|
3252
|
+
input.uri
|
|
3253
|
+
],
|
|
3254
|
+
toResult: (_output, input)=>({
|
|
3255
|
+
summary: `Launched ${input.uri}`
|
|
3256
|
+
})
|
|
3257
|
+
});
|
|
3258
|
+
const terminateNode = defineAndroidAgentNode({
|
|
3259
|
+
method: 'terminate',
|
|
3260
|
+
description: 'Terminate an application through the current Android Agent.',
|
|
3261
|
+
stringInputKey: 'uri',
|
|
3262
|
+
inputSchema: terminateInputSchema,
|
|
3263
|
+
toArgs: (input)=>[
|
|
3264
|
+
input.uri
|
|
3265
|
+
],
|
|
3266
|
+
toResult: (_output, input)=>({
|
|
3267
|
+
summary: `Terminated ${input.uri}`
|
|
3268
|
+
})
|
|
3269
|
+
});
|
|
3270
|
+
const runAdbShellNode = defineAndroidAgentNode({
|
|
3271
|
+
method: 'runAdbShell',
|
|
3272
|
+
title: 'Run an ADB shell command',
|
|
3273
|
+
description: 'Execute a shell command through the current Android Agent. Pass only the shell command, without the adb shell prefix.',
|
|
3274
|
+
stringInputKey: 'command',
|
|
3275
|
+
inputSchema: runAdbShellInputSchema,
|
|
3276
|
+
toArgs (input, context) {
|
|
3277
|
+
context.signal.throwIfAborted();
|
|
3278
|
+
if (/^\s*adb(?:\s|$)/i.test(input.command)) throw new TypeError('command must not include an adb or adb shell prefix.');
|
|
3279
|
+
return [
|
|
3280
|
+
input.command,
|
|
3281
|
+
input.options
|
|
3282
|
+
];
|
|
3283
|
+
},
|
|
3284
|
+
toResult (stdout) {
|
|
3285
|
+
if ('string' != typeof stdout) throw new TypeError('runAdbShell() must return stdout as a string.');
|
|
3286
|
+
return {
|
|
3287
|
+
summary: `Executed ADB shell command (${stdout.length} stdout characters)`,
|
|
3288
|
+
data: {
|
|
3289
|
+
stdout
|
|
3290
|
+
}
|
|
3291
|
+
};
|
|
3292
|
+
}
|
|
3293
|
+
});
|
|
3294
|
+
const backNode = defineAndroidAgentNode({
|
|
3295
|
+
method: 'back',
|
|
3296
|
+
description: 'Trigger the Android system back operation.',
|
|
3297
|
+
stringInputKey: false,
|
|
3298
|
+
inputSchema: emptyInputSchema,
|
|
3299
|
+
toArgs: ()=>[],
|
|
3300
|
+
toResult: ()=>({
|
|
3301
|
+
summary: 'Triggered Android back'
|
|
3302
|
+
})
|
|
3303
|
+
});
|
|
3304
|
+
const homeNode = defineAndroidAgentNode({
|
|
3305
|
+
method: 'home',
|
|
3306
|
+
description: 'Trigger the Android system home operation.',
|
|
3307
|
+
stringInputKey: false,
|
|
3308
|
+
inputSchema: emptyInputSchema,
|
|
3309
|
+
toArgs: ()=>[],
|
|
3310
|
+
toResult: ()=>({
|
|
3311
|
+
summary: 'Triggered Android home'
|
|
3312
|
+
})
|
|
3313
|
+
});
|
|
3314
|
+
const recentAppsNode = defineAndroidAgentNode({
|
|
3315
|
+
method: 'recentApps',
|
|
3316
|
+
description: 'Trigger the Android system recent apps operation.',
|
|
3317
|
+
stringInputKey: false,
|
|
3318
|
+
inputSchema: emptyInputSchema,
|
|
3319
|
+
toArgs: ()=>[],
|
|
3320
|
+
toResult: ()=>({
|
|
3321
|
+
summary: 'Triggered Android recentApps'
|
|
3322
|
+
})
|
|
3323
|
+
});
|
|
3324
|
+
const androidAgentTestRunnerNodeDefinitions = [
|
|
3325
|
+
launchNode,
|
|
3326
|
+
terminateNode,
|
|
3327
|
+
runAdbShellNode,
|
|
3328
|
+
backNode,
|
|
3329
|
+
homeNode,
|
|
3330
|
+
recentAppsNode
|
|
3331
|
+
];
|
|
3228
3332
|
const debugUtils = (0, logger_.getDebug)('android:utils');
|
|
3229
3333
|
async function getConnectedDevices(deviceOptions) {
|
|
3230
3334
|
let adbExecutable;
|
|
@@ -3257,6 +3361,12 @@ function agent_define_property(obj, key, value) {
|
|
|
3257
3361
|
}
|
|
3258
3362
|
const debugAgent = (0, logger_.getDebug)('android:agent');
|
|
3259
3363
|
class AndroidAgent extends Agent {
|
|
3364
|
+
static getTestRunnerNodeDefinitions() {
|
|
3365
|
+
return [
|
|
3366
|
+
...Agent.getTestRunnerNodeDefinitions(),
|
|
3367
|
+
...androidAgentTestRunnerNodeDefinitions
|
|
3368
|
+
];
|
|
3369
|
+
}
|
|
3260
3370
|
async launch(uri) {
|
|
3261
3371
|
const action = this.wrapActionInActionSpace('Launch');
|
|
3262
3372
|
return action({
|
|
@@ -3430,7 +3540,7 @@ class AndroidMidsceneTools extends BaseMidsceneTools {
|
|
|
3430
3540
|
const tools = new AndroidMidsceneTools();
|
|
3431
3541
|
runToolsCLI(tools, 'midscene-android', {
|
|
3432
3542
|
stripPrefix: 'android_',
|
|
3433
|
-
version: "1.12.4
|
|
3543
|
+
version: "1.12.4",
|
|
3434
3544
|
extraCommands: createReportCliCommands()
|
|
3435
3545
|
}).catch((e)=>{
|
|
3436
3546
|
process.exit(reportCLIError(e));
|
package/dist/es/index.mjs
CHANGED
|
@@ -12,6 +12,8 @@ import { MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT,
|
|
|
12
12
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
|
|
13
13
|
import { ADB, getSdkRootFromEnv } from "appium-adb";
|
|
14
14
|
import { Agent } from "@midscene/core/agent";
|
|
15
|
+
import { createAgentTestRunnerNodeDefinition } from "@midscene/core/agent/test-runner";
|
|
16
|
+
import { z as v4_z } from "zod/v4";
|
|
15
17
|
import { agentBehaviorInitArgShape, extractAgentBehaviorInitArgs, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs } from "@midscene/shared/agent-tools/agent-behavior-init-args";
|
|
16
18
|
import { BaseMidsceneTools } from "@midscene/shared/agent-tools/base-tools";
|
|
17
19
|
var __webpack_modules__ = {
|
|
@@ -3224,6 +3226,108 @@ const defaultAppNameMapping = {
|
|
|
3224
3226
|
WeChat: 'com.tencent.mm',
|
|
3225
3227
|
WhatsApp: 'com.whatsapp'
|
|
3226
3228
|
};
|
|
3229
|
+
const defineAndroidAgentNode = createAgentTestRunnerNodeDefinition('an Android Agent');
|
|
3230
|
+
const nonBlankText = (description)=>v4_z.string().regex(/\S/, 'value must contain a non-whitespace character').describe(description);
|
|
3231
|
+
const launchInputSchema = v4_z.strictObject({
|
|
3232
|
+
uri: nonBlankText('The app, URL, URI, or package name to launch.')
|
|
3233
|
+
});
|
|
3234
|
+
const terminateInputSchema = v4_z.strictObject({
|
|
3235
|
+
uri: nonBlankText('The package name or app name to terminate.')
|
|
3236
|
+
});
|
|
3237
|
+
const runAdbShellOptionsInputSchema = v4_z.strictObject({
|
|
3238
|
+
timeout: v4_z.number().int().positive().optional().describe('ADB shell command timeout in milliseconds.')
|
|
3239
|
+
});
|
|
3240
|
+
const runAdbShellInputSchema = v4_z.strictObject({
|
|
3241
|
+
command: nonBlankText('The shell command to execute, without an adb shell prefix.'),
|
|
3242
|
+
options: runAdbShellOptionsInputSchema.optional()
|
|
3243
|
+
});
|
|
3244
|
+
const emptyInputSchema = v4_z.strictObject({});
|
|
3245
|
+
const launchNode = defineAndroidAgentNode({
|
|
3246
|
+
method: 'launch',
|
|
3247
|
+
description: 'Launch an application through the current Android Agent.',
|
|
3248
|
+
stringInputKey: 'uri',
|
|
3249
|
+
inputSchema: launchInputSchema,
|
|
3250
|
+
toArgs: (input)=>[
|
|
3251
|
+
input.uri
|
|
3252
|
+
],
|
|
3253
|
+
toResult: (_output, input)=>({
|
|
3254
|
+
summary: `Launched ${input.uri}`
|
|
3255
|
+
})
|
|
3256
|
+
});
|
|
3257
|
+
const terminateNode = defineAndroidAgentNode({
|
|
3258
|
+
method: 'terminate',
|
|
3259
|
+
description: 'Terminate an application through the current Android Agent.',
|
|
3260
|
+
stringInputKey: 'uri',
|
|
3261
|
+
inputSchema: terminateInputSchema,
|
|
3262
|
+
toArgs: (input)=>[
|
|
3263
|
+
input.uri
|
|
3264
|
+
],
|
|
3265
|
+
toResult: (_output, input)=>({
|
|
3266
|
+
summary: `Terminated ${input.uri}`
|
|
3267
|
+
})
|
|
3268
|
+
});
|
|
3269
|
+
const runAdbShellNode = defineAndroidAgentNode({
|
|
3270
|
+
method: 'runAdbShell',
|
|
3271
|
+
title: 'Run an ADB shell command',
|
|
3272
|
+
description: 'Execute a shell command through the current Android Agent. Pass only the shell command, without the adb shell prefix.',
|
|
3273
|
+
stringInputKey: 'command',
|
|
3274
|
+
inputSchema: runAdbShellInputSchema,
|
|
3275
|
+
toArgs (input, context) {
|
|
3276
|
+
context.signal.throwIfAborted();
|
|
3277
|
+
if (/^\s*adb(?:\s|$)/i.test(input.command)) throw new TypeError('command must not include an adb or adb shell prefix.');
|
|
3278
|
+
return [
|
|
3279
|
+
input.command,
|
|
3280
|
+
input.options
|
|
3281
|
+
];
|
|
3282
|
+
},
|
|
3283
|
+
toResult (stdout) {
|
|
3284
|
+
if ('string' != typeof stdout) throw new TypeError('runAdbShell() must return stdout as a string.');
|
|
3285
|
+
return {
|
|
3286
|
+
summary: `Executed ADB shell command (${stdout.length} stdout characters)`,
|
|
3287
|
+
data: {
|
|
3288
|
+
stdout
|
|
3289
|
+
}
|
|
3290
|
+
};
|
|
3291
|
+
}
|
|
3292
|
+
});
|
|
3293
|
+
const backNode = defineAndroidAgentNode({
|
|
3294
|
+
method: 'back',
|
|
3295
|
+
description: 'Trigger the Android system back operation.',
|
|
3296
|
+
stringInputKey: false,
|
|
3297
|
+
inputSchema: emptyInputSchema,
|
|
3298
|
+
toArgs: ()=>[],
|
|
3299
|
+
toResult: ()=>({
|
|
3300
|
+
summary: 'Triggered Android back'
|
|
3301
|
+
})
|
|
3302
|
+
});
|
|
3303
|
+
const homeNode = defineAndroidAgentNode({
|
|
3304
|
+
method: 'home',
|
|
3305
|
+
description: 'Trigger the Android system home operation.',
|
|
3306
|
+
stringInputKey: false,
|
|
3307
|
+
inputSchema: emptyInputSchema,
|
|
3308
|
+
toArgs: ()=>[],
|
|
3309
|
+
toResult: ()=>({
|
|
3310
|
+
summary: 'Triggered Android home'
|
|
3311
|
+
})
|
|
3312
|
+
});
|
|
3313
|
+
const recentAppsNode = defineAndroidAgentNode({
|
|
3314
|
+
method: 'recentApps',
|
|
3315
|
+
description: 'Trigger the Android system recent apps operation.',
|
|
3316
|
+
stringInputKey: false,
|
|
3317
|
+
inputSchema: emptyInputSchema,
|
|
3318
|
+
toArgs: ()=>[],
|
|
3319
|
+
toResult: ()=>({
|
|
3320
|
+
summary: 'Triggered Android recentApps'
|
|
3321
|
+
})
|
|
3322
|
+
});
|
|
3323
|
+
const androidAgentTestRunnerNodeDefinitions = [
|
|
3324
|
+
launchNode,
|
|
3325
|
+
terminateNode,
|
|
3326
|
+
runAdbShellNode,
|
|
3327
|
+
backNode,
|
|
3328
|
+
homeNode,
|
|
3329
|
+
recentAppsNode
|
|
3330
|
+
];
|
|
3227
3331
|
const debugUtils = (0, logger_.getDebug)('android:utils');
|
|
3228
3332
|
const DETAIL_LOOKUP_ADB_TIMEOUT_MS = 8000;
|
|
3229
3333
|
const DETAIL_LOOKUP_STEP_TIMEOUT_MS = 2000;
|
|
@@ -3324,6 +3428,12 @@ function agent_define_property(obj, key, value) {
|
|
|
3324
3428
|
}
|
|
3325
3429
|
const debugAgent = (0, logger_.getDebug)('android:agent');
|
|
3326
3430
|
class AndroidAgent extends Agent {
|
|
3431
|
+
static getTestRunnerNodeDefinitions() {
|
|
3432
|
+
return [
|
|
3433
|
+
...Agent.getTestRunnerNodeDefinitions(),
|
|
3434
|
+
...androidAgentTestRunnerNodeDefinitions
|
|
3435
|
+
];
|
|
3436
|
+
}
|
|
3327
3437
|
async launch(uri) {
|
|
3328
3438
|
const action = this.wrapActionInActionSpace('Launch');
|
|
3329
3439
|
return action({
|
|
@@ -3495,4 +3605,4 @@ class AndroidMidsceneTools extends BaseMidsceneTools {
|
|
|
3495
3605
|
}
|
|
3496
3606
|
}
|
|
3497
3607
|
var __webpack_exports__resolveExternalResourcePath = resource_path.J;
|
|
3498
|
-
export { AndroidAgent, AndroidDevice, AndroidMidsceneTools, ScrcpyDeviceAdapter, agentFromAdbDevice, getConnectedDevices, getConnectedDevicesWithDetails, overrideAIConfig, __webpack_exports__resolveExternalResourcePath as resolveExternalResourcePath };
|
|
3608
|
+
export { AndroidAgent, AndroidDevice, AndroidMidsceneTools, ScrcpyDeviceAdapter, agentFromAdbDevice, androidAgentTestRunnerNodeDefinitions, getConnectedDevices, getConnectedDevicesWithDetails, launchInputSchema, overrideAIConfig, runAdbShellInputSchema, runAdbShellOptionsInputSchema, terminateInputSchema, __webpack_exports__resolveExternalResourcePath as resolveExternalResourcePath };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createAgentTestRunnerNodeDefinition } from "@midscene/core/agent/test-runner";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
const defineAndroidAgentNode = createAgentTestRunnerNodeDefinition('an Android Agent');
|
|
4
|
+
const nonBlankText = (description)=>z.string().regex(/\S/, 'value must contain a non-whitespace character').describe(description);
|
|
5
|
+
const launchInputSchema = z.strictObject({
|
|
6
|
+
uri: nonBlankText('The app, URL, URI, or package name to launch.')
|
|
7
|
+
});
|
|
8
|
+
const terminateInputSchema = z.strictObject({
|
|
9
|
+
uri: nonBlankText('The package name or app name to terminate.')
|
|
10
|
+
});
|
|
11
|
+
const runAdbShellOptionsInputSchema = z.strictObject({
|
|
12
|
+
timeout: z.number().int().positive().optional().describe('ADB shell command timeout in milliseconds.')
|
|
13
|
+
});
|
|
14
|
+
const runAdbShellInputSchema = z.strictObject({
|
|
15
|
+
command: nonBlankText('The shell command to execute, without an adb shell prefix.'),
|
|
16
|
+
options: runAdbShellOptionsInputSchema.optional()
|
|
17
|
+
});
|
|
18
|
+
const emptyInputSchema = z.strictObject({});
|
|
19
|
+
const launchNode = defineAndroidAgentNode({
|
|
20
|
+
method: 'launch',
|
|
21
|
+
description: 'Launch an application through the current Android Agent.',
|
|
22
|
+
stringInputKey: 'uri',
|
|
23
|
+
inputSchema: launchInputSchema,
|
|
24
|
+
toArgs: (input)=>[
|
|
25
|
+
input.uri
|
|
26
|
+
],
|
|
27
|
+
toResult: (_output, input)=>({
|
|
28
|
+
summary: `Launched ${input.uri}`
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
const terminateNode = defineAndroidAgentNode({
|
|
32
|
+
method: 'terminate',
|
|
33
|
+
description: 'Terminate an application through the current Android Agent.',
|
|
34
|
+
stringInputKey: 'uri',
|
|
35
|
+
inputSchema: terminateInputSchema,
|
|
36
|
+
toArgs: (input)=>[
|
|
37
|
+
input.uri
|
|
38
|
+
],
|
|
39
|
+
toResult: (_output, input)=>({
|
|
40
|
+
summary: `Terminated ${input.uri}`
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
const runAdbShellNode = defineAndroidAgentNode({
|
|
44
|
+
method: 'runAdbShell',
|
|
45
|
+
title: 'Run an ADB shell command',
|
|
46
|
+
description: 'Execute a shell command through the current Android Agent. Pass only the shell command, without the adb shell prefix.',
|
|
47
|
+
stringInputKey: 'command',
|
|
48
|
+
inputSchema: runAdbShellInputSchema,
|
|
49
|
+
toArgs (input, context) {
|
|
50
|
+
context.signal.throwIfAborted();
|
|
51
|
+
if (/^\s*adb(?:\s|$)/i.test(input.command)) throw new TypeError('command must not include an adb or adb shell prefix.');
|
|
52
|
+
return [
|
|
53
|
+
input.command,
|
|
54
|
+
input.options
|
|
55
|
+
];
|
|
56
|
+
},
|
|
57
|
+
toResult (stdout) {
|
|
58
|
+
if ('string' != typeof stdout) throw new TypeError('runAdbShell() must return stdout as a string.');
|
|
59
|
+
return {
|
|
60
|
+
summary: `Executed ADB shell command (${stdout.length} stdout characters)`,
|
|
61
|
+
data: {
|
|
62
|
+
stdout
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const backNode = defineAndroidAgentNode({
|
|
68
|
+
method: 'back',
|
|
69
|
+
description: 'Trigger the Android system back operation.',
|
|
70
|
+
stringInputKey: false,
|
|
71
|
+
inputSchema: emptyInputSchema,
|
|
72
|
+
toArgs: ()=>[],
|
|
73
|
+
toResult: ()=>({
|
|
74
|
+
summary: 'Triggered Android back'
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
const homeNode = defineAndroidAgentNode({
|
|
78
|
+
method: 'home',
|
|
79
|
+
description: 'Trigger the Android system home operation.',
|
|
80
|
+
stringInputKey: false,
|
|
81
|
+
inputSchema: emptyInputSchema,
|
|
82
|
+
toArgs: ()=>[],
|
|
83
|
+
toResult: ()=>({
|
|
84
|
+
summary: 'Triggered Android home'
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
const recentAppsNode = defineAndroidAgentNode({
|
|
88
|
+
method: 'recentApps',
|
|
89
|
+
description: 'Trigger the Android system recent apps operation.',
|
|
90
|
+
stringInputKey: false,
|
|
91
|
+
inputSchema: emptyInputSchema,
|
|
92
|
+
toArgs: ()=>[],
|
|
93
|
+
toResult: ()=>({
|
|
94
|
+
summary: 'Triggered Android recentApps'
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
const androidAgentTestRunnerNodeDefinitions = [
|
|
98
|
+
launchNode,
|
|
99
|
+
terminateNode,
|
|
100
|
+
runAdbShellNode,
|
|
101
|
+
backNode,
|
|
102
|
+
homeNode,
|
|
103
|
+
recentAppsNode
|
|
104
|
+
];
|
|
105
|
+
export { androidAgentTestRunnerNodeDefinitions, launchInputSchema, runAdbShellInputSchema, runAdbShellOptionsInputSchema, terminateInputSchema };
|
package/dist/lib/cli.js
CHANGED
|
@@ -1017,6 +1017,115 @@ var __webpack_modules__ = {
|
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
1019
|
},
|
|
1020
|
+
"./src/test-runner-nodes.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1021
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1022
|
+
androidAgentTestRunnerNodeDefinitions: ()=>androidAgentTestRunnerNodeDefinitions
|
|
1023
|
+
});
|
|
1024
|
+
const test_runner_namespaceObject = require("@midscene/core/agent/test-runner");
|
|
1025
|
+
const v4_namespaceObject = require("zod/v4");
|
|
1026
|
+
const defineAndroidAgentNode = (0, test_runner_namespaceObject.createAgentTestRunnerNodeDefinition)('an Android Agent');
|
|
1027
|
+
const nonBlankText = (description)=>v4_namespaceObject.z.string().regex(/\S/, 'value must contain a non-whitespace character').describe(description);
|
|
1028
|
+
const launchInputSchema = v4_namespaceObject.z.strictObject({
|
|
1029
|
+
uri: nonBlankText('The app, URL, URI, or package name to launch.')
|
|
1030
|
+
});
|
|
1031
|
+
const terminateInputSchema = v4_namespaceObject.z.strictObject({
|
|
1032
|
+
uri: nonBlankText('The package name or app name to terminate.')
|
|
1033
|
+
});
|
|
1034
|
+
const runAdbShellOptionsInputSchema = v4_namespaceObject.z.strictObject({
|
|
1035
|
+
timeout: v4_namespaceObject.z.number().int().positive().optional().describe('ADB shell command timeout in milliseconds.')
|
|
1036
|
+
});
|
|
1037
|
+
const runAdbShellInputSchema = v4_namespaceObject.z.strictObject({
|
|
1038
|
+
command: nonBlankText('The shell command to execute, without an adb shell prefix.'),
|
|
1039
|
+
options: runAdbShellOptionsInputSchema.optional()
|
|
1040
|
+
});
|
|
1041
|
+
const emptyInputSchema = v4_namespaceObject.z.strictObject({});
|
|
1042
|
+
const launchNode = defineAndroidAgentNode({
|
|
1043
|
+
method: 'launch',
|
|
1044
|
+
description: 'Launch an application through the current Android Agent.',
|
|
1045
|
+
stringInputKey: 'uri',
|
|
1046
|
+
inputSchema: launchInputSchema,
|
|
1047
|
+
toArgs: (input)=>[
|
|
1048
|
+
input.uri
|
|
1049
|
+
],
|
|
1050
|
+
toResult: (_output, input)=>({
|
|
1051
|
+
summary: `Launched ${input.uri}`
|
|
1052
|
+
})
|
|
1053
|
+
});
|
|
1054
|
+
const terminateNode = defineAndroidAgentNode({
|
|
1055
|
+
method: 'terminate',
|
|
1056
|
+
description: 'Terminate an application through the current Android Agent.',
|
|
1057
|
+
stringInputKey: 'uri',
|
|
1058
|
+
inputSchema: terminateInputSchema,
|
|
1059
|
+
toArgs: (input)=>[
|
|
1060
|
+
input.uri
|
|
1061
|
+
],
|
|
1062
|
+
toResult: (_output, input)=>({
|
|
1063
|
+
summary: `Terminated ${input.uri}`
|
|
1064
|
+
})
|
|
1065
|
+
});
|
|
1066
|
+
const runAdbShellNode = defineAndroidAgentNode({
|
|
1067
|
+
method: 'runAdbShell',
|
|
1068
|
+
title: 'Run an ADB shell command',
|
|
1069
|
+
description: 'Execute a shell command through the current Android Agent. Pass only the shell command, without the adb shell prefix.',
|
|
1070
|
+
stringInputKey: 'command',
|
|
1071
|
+
inputSchema: runAdbShellInputSchema,
|
|
1072
|
+
toArgs (input, context) {
|
|
1073
|
+
context.signal.throwIfAborted();
|
|
1074
|
+
if (/^\s*adb(?:\s|$)/i.test(input.command)) throw new TypeError('command must not include an adb or adb shell prefix.');
|
|
1075
|
+
return [
|
|
1076
|
+
input.command,
|
|
1077
|
+
input.options
|
|
1078
|
+
];
|
|
1079
|
+
},
|
|
1080
|
+
toResult (stdout) {
|
|
1081
|
+
if ('string' != typeof stdout) throw new TypeError('runAdbShell() must return stdout as a string.');
|
|
1082
|
+
return {
|
|
1083
|
+
summary: `Executed ADB shell command (${stdout.length} stdout characters)`,
|
|
1084
|
+
data: {
|
|
1085
|
+
stdout
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1090
|
+
const backNode = defineAndroidAgentNode({
|
|
1091
|
+
method: 'back',
|
|
1092
|
+
description: 'Trigger the Android system back operation.',
|
|
1093
|
+
stringInputKey: false,
|
|
1094
|
+
inputSchema: emptyInputSchema,
|
|
1095
|
+
toArgs: ()=>[],
|
|
1096
|
+
toResult: ()=>({
|
|
1097
|
+
summary: 'Triggered Android back'
|
|
1098
|
+
})
|
|
1099
|
+
});
|
|
1100
|
+
const homeNode = defineAndroidAgentNode({
|
|
1101
|
+
method: 'home',
|
|
1102
|
+
description: 'Trigger the Android system home operation.',
|
|
1103
|
+
stringInputKey: false,
|
|
1104
|
+
inputSchema: emptyInputSchema,
|
|
1105
|
+
toArgs: ()=>[],
|
|
1106
|
+
toResult: ()=>({
|
|
1107
|
+
summary: 'Triggered Android home'
|
|
1108
|
+
})
|
|
1109
|
+
});
|
|
1110
|
+
const recentAppsNode = defineAndroidAgentNode({
|
|
1111
|
+
method: 'recentApps',
|
|
1112
|
+
description: 'Trigger the Android system recent apps operation.',
|
|
1113
|
+
stringInputKey: false,
|
|
1114
|
+
inputSchema: emptyInputSchema,
|
|
1115
|
+
toArgs: ()=>[],
|
|
1116
|
+
toResult: ()=>({
|
|
1117
|
+
summary: 'Triggered Android recentApps'
|
|
1118
|
+
})
|
|
1119
|
+
});
|
|
1120
|
+
const androidAgentTestRunnerNodeDefinitions = [
|
|
1121
|
+
launchNode,
|
|
1122
|
+
terminateNode,
|
|
1123
|
+
runAdbShellNode,
|
|
1124
|
+
backNode,
|
|
1125
|
+
homeNode,
|
|
1126
|
+
recentAppsNode
|
|
1127
|
+
];
|
|
1128
|
+
},
|
|
1020
1129
|
"@midscene/shared/img" (module) {
|
|
1021
1130
|
module.exports = require("@midscene/shared/img");
|
|
1022
1131
|
},
|
|
@@ -3239,6 +3348,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
3239
3348
|
}
|
|
3240
3349
|
})
|
|
3241
3350
|
});
|
|
3351
|
+
var test_runner_nodes = __webpack_require__("./src/test-runner-nodes.ts");
|
|
3242
3352
|
const debugUtils = (0, logger_.getDebug)('android:utils');
|
|
3243
3353
|
async function getConnectedDevices(deviceOptions) {
|
|
3244
3354
|
let adbExecutable;
|
|
@@ -3271,6 +3381,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
3271
3381
|
}
|
|
3272
3382
|
const debugAgent = (0, logger_.getDebug)('android:agent');
|
|
3273
3383
|
class AndroidAgent extends agent_namespaceObject.Agent {
|
|
3384
|
+
static getTestRunnerNodeDefinitions() {
|
|
3385
|
+
return [
|
|
3386
|
+
...agent_namespaceObject.Agent.getTestRunnerNodeDefinitions(),
|
|
3387
|
+
...test_runner_nodes.androidAgentTestRunnerNodeDefinitions
|
|
3388
|
+
];
|
|
3389
|
+
}
|
|
3274
3390
|
async launch(uri) {
|
|
3275
3391
|
const action = this.wrapActionInActionSpace('Launch');
|
|
3276
3392
|
return action({
|
|
@@ -3444,7 +3560,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
3444
3560
|
const tools = new AndroidMidsceneTools();
|
|
3445
3561
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-android', {
|
|
3446
3562
|
stripPrefix: 'android_',
|
|
3447
|
-
version: "1.12.4
|
|
3563
|
+
version: "1.12.4",
|
|
3448
3564
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
3449
3565
|
}).catch((e)=>{
|
|
3450
3566
|
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|
package/dist/lib/index.js
CHANGED
|
@@ -1017,6 +1017,119 @@ var __webpack_modules__ = {
|
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
1019
|
},
|
|
1020
|
+
"./src/test-runner-nodes.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1021
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1022
|
+
androidAgentTestRunnerNodeDefinitions: ()=>androidAgentTestRunnerNodeDefinitions,
|
|
1023
|
+
terminateInputSchema: ()=>terminateInputSchema,
|
|
1024
|
+
runAdbShellInputSchema: ()=>runAdbShellInputSchema,
|
|
1025
|
+
runAdbShellOptionsInputSchema: ()=>runAdbShellOptionsInputSchema,
|
|
1026
|
+
launchInputSchema: ()=>launchInputSchema
|
|
1027
|
+
});
|
|
1028
|
+
const test_runner_namespaceObject = require("@midscene/core/agent/test-runner");
|
|
1029
|
+
const v4_namespaceObject = require("zod/v4");
|
|
1030
|
+
const defineAndroidAgentNode = (0, test_runner_namespaceObject.createAgentTestRunnerNodeDefinition)('an Android Agent');
|
|
1031
|
+
const nonBlankText = (description)=>v4_namespaceObject.z.string().regex(/\S/, 'value must contain a non-whitespace character').describe(description);
|
|
1032
|
+
const launchInputSchema = v4_namespaceObject.z.strictObject({
|
|
1033
|
+
uri: nonBlankText('The app, URL, URI, or package name to launch.')
|
|
1034
|
+
});
|
|
1035
|
+
const terminateInputSchema = v4_namespaceObject.z.strictObject({
|
|
1036
|
+
uri: nonBlankText('The package name or app name to terminate.')
|
|
1037
|
+
});
|
|
1038
|
+
const runAdbShellOptionsInputSchema = v4_namespaceObject.z.strictObject({
|
|
1039
|
+
timeout: v4_namespaceObject.z.number().int().positive().optional().describe('ADB shell command timeout in milliseconds.')
|
|
1040
|
+
});
|
|
1041
|
+
const runAdbShellInputSchema = v4_namespaceObject.z.strictObject({
|
|
1042
|
+
command: nonBlankText('The shell command to execute, without an adb shell prefix.'),
|
|
1043
|
+
options: runAdbShellOptionsInputSchema.optional()
|
|
1044
|
+
});
|
|
1045
|
+
const emptyInputSchema = v4_namespaceObject.z.strictObject({});
|
|
1046
|
+
const launchNode = defineAndroidAgentNode({
|
|
1047
|
+
method: 'launch',
|
|
1048
|
+
description: 'Launch an application through the current Android Agent.',
|
|
1049
|
+
stringInputKey: 'uri',
|
|
1050
|
+
inputSchema: launchInputSchema,
|
|
1051
|
+
toArgs: (input)=>[
|
|
1052
|
+
input.uri
|
|
1053
|
+
],
|
|
1054
|
+
toResult: (_output, input)=>({
|
|
1055
|
+
summary: `Launched ${input.uri}`
|
|
1056
|
+
})
|
|
1057
|
+
});
|
|
1058
|
+
const terminateNode = defineAndroidAgentNode({
|
|
1059
|
+
method: 'terminate',
|
|
1060
|
+
description: 'Terminate an application through the current Android Agent.',
|
|
1061
|
+
stringInputKey: 'uri',
|
|
1062
|
+
inputSchema: terminateInputSchema,
|
|
1063
|
+
toArgs: (input)=>[
|
|
1064
|
+
input.uri
|
|
1065
|
+
],
|
|
1066
|
+
toResult: (_output, input)=>({
|
|
1067
|
+
summary: `Terminated ${input.uri}`
|
|
1068
|
+
})
|
|
1069
|
+
});
|
|
1070
|
+
const runAdbShellNode = defineAndroidAgentNode({
|
|
1071
|
+
method: 'runAdbShell',
|
|
1072
|
+
title: 'Run an ADB shell command',
|
|
1073
|
+
description: 'Execute a shell command through the current Android Agent. Pass only the shell command, without the adb shell prefix.',
|
|
1074
|
+
stringInputKey: 'command',
|
|
1075
|
+
inputSchema: runAdbShellInputSchema,
|
|
1076
|
+
toArgs (input, context) {
|
|
1077
|
+
context.signal.throwIfAborted();
|
|
1078
|
+
if (/^\s*adb(?:\s|$)/i.test(input.command)) throw new TypeError('command must not include an adb or adb shell prefix.');
|
|
1079
|
+
return [
|
|
1080
|
+
input.command,
|
|
1081
|
+
input.options
|
|
1082
|
+
];
|
|
1083
|
+
},
|
|
1084
|
+
toResult (stdout) {
|
|
1085
|
+
if ('string' != typeof stdout) throw new TypeError('runAdbShell() must return stdout as a string.');
|
|
1086
|
+
return {
|
|
1087
|
+
summary: `Executed ADB shell command (${stdout.length} stdout characters)`,
|
|
1088
|
+
data: {
|
|
1089
|
+
stdout
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1094
|
+
const backNode = defineAndroidAgentNode({
|
|
1095
|
+
method: 'back',
|
|
1096
|
+
description: 'Trigger the Android system back operation.',
|
|
1097
|
+
stringInputKey: false,
|
|
1098
|
+
inputSchema: emptyInputSchema,
|
|
1099
|
+
toArgs: ()=>[],
|
|
1100
|
+
toResult: ()=>({
|
|
1101
|
+
summary: 'Triggered Android back'
|
|
1102
|
+
})
|
|
1103
|
+
});
|
|
1104
|
+
const homeNode = defineAndroidAgentNode({
|
|
1105
|
+
method: 'home',
|
|
1106
|
+
description: 'Trigger the Android system home operation.',
|
|
1107
|
+
stringInputKey: false,
|
|
1108
|
+
inputSchema: emptyInputSchema,
|
|
1109
|
+
toArgs: ()=>[],
|
|
1110
|
+
toResult: ()=>({
|
|
1111
|
+
summary: 'Triggered Android home'
|
|
1112
|
+
})
|
|
1113
|
+
});
|
|
1114
|
+
const recentAppsNode = defineAndroidAgentNode({
|
|
1115
|
+
method: 'recentApps',
|
|
1116
|
+
description: 'Trigger the Android system recent apps operation.',
|
|
1117
|
+
stringInputKey: false,
|
|
1118
|
+
inputSchema: emptyInputSchema,
|
|
1119
|
+
toArgs: ()=>[],
|
|
1120
|
+
toResult: ()=>({
|
|
1121
|
+
summary: 'Triggered Android recentApps'
|
|
1122
|
+
})
|
|
1123
|
+
});
|
|
1124
|
+
const androidAgentTestRunnerNodeDefinitions = [
|
|
1125
|
+
launchNode,
|
|
1126
|
+
terminateNode,
|
|
1127
|
+
runAdbShellNode,
|
|
1128
|
+
backNode,
|
|
1129
|
+
homeNode,
|
|
1130
|
+
recentAppsNode
|
|
1131
|
+
];
|
|
1132
|
+
},
|
|
1020
1133
|
"@midscene/shared/img" (module) {
|
|
1021
1134
|
module.exports = require("@midscene/shared/img");
|
|
1022
1135
|
},
|
|
@@ -1077,14 +1190,19 @@ var __webpack_exports__ = {};
|
|
|
1077
1190
|
(()=>{
|
|
1078
1191
|
__webpack_require__.r(__webpack_exports__);
|
|
1079
1192
|
__webpack_require__.d(__webpack_exports__, {
|
|
1193
|
+
launchInputSchema: ()=>test_runner_nodes.launchInputSchema,
|
|
1194
|
+
androidAgentTestRunnerNodeDefinitions: ()=>test_runner_nodes.androidAgentTestRunnerNodeDefinitions,
|
|
1080
1195
|
AndroidAgent: ()=>AndroidAgent,
|
|
1081
1196
|
agentFromAdbDevice: ()=>agentFromAdbDevice,
|
|
1082
|
-
|
|
1197
|
+
runAdbShellInputSchema: ()=>test_runner_nodes.runAdbShellInputSchema,
|
|
1083
1198
|
ScrcpyDeviceAdapter: ()=>ScrcpyDeviceAdapter,
|
|
1084
|
-
AndroidMidsceneTools: ()=>AndroidMidsceneTools,
|
|
1085
1199
|
AndroidDevice: ()=>AndroidDevice,
|
|
1200
|
+
AndroidMidsceneTools: ()=>AndroidMidsceneTools,
|
|
1201
|
+
getConnectedDevicesWithDetails: ()=>getConnectedDevicesWithDetails,
|
|
1086
1202
|
overrideAIConfig: ()=>env_namespaceObject.overrideAIConfig,
|
|
1087
1203
|
resolveExternalResourcePath: ()=>resource_path.J,
|
|
1204
|
+
terminateInputSchema: ()=>test_runner_nodes.terminateInputSchema,
|
|
1205
|
+
runAdbShellOptionsInputSchema: ()=>test_runner_nodes.runAdbShellOptionsInputSchema,
|
|
1088
1206
|
getConnectedDevices: ()=>getConnectedDevices
|
|
1089
1207
|
});
|
|
1090
1208
|
const external_node_assert_namespaceObject = require("node:assert");
|
|
@@ -3258,6 +3376,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
3258
3376
|
WeChat: 'com.tencent.mm',
|
|
3259
3377
|
WhatsApp: 'com.whatsapp'
|
|
3260
3378
|
};
|
|
3379
|
+
var test_runner_nodes = __webpack_require__("./src/test-runner-nodes.ts");
|
|
3261
3380
|
const debugUtils = (0, logger_.getDebug)('android:utils');
|
|
3262
3381
|
const DETAIL_LOOKUP_ADB_TIMEOUT_MS = 8000;
|
|
3263
3382
|
const DETAIL_LOOKUP_STEP_TIMEOUT_MS = 2000;
|
|
@@ -3358,6 +3477,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
3358
3477
|
}
|
|
3359
3478
|
const debugAgent = (0, logger_.getDebug)('android:agent');
|
|
3360
3479
|
class AndroidAgent extends agent_namespaceObject.Agent {
|
|
3480
|
+
static getTestRunnerNodeDefinitions() {
|
|
3481
|
+
return [
|
|
3482
|
+
...agent_namespaceObject.Agent.getTestRunnerNodeDefinitions(),
|
|
3483
|
+
...test_runner_nodes.androidAgentTestRunnerNodeDefinitions
|
|
3484
|
+
];
|
|
3485
|
+
}
|
|
3361
3486
|
async launch(uri) {
|
|
3362
3487
|
const action = this.wrapActionInActionSpace('Launch');
|
|
3363
3488
|
return action({
|
|
@@ -3536,20 +3661,30 @@ exports.AndroidDevice = __webpack_exports__.AndroidDevice;
|
|
|
3536
3661
|
exports.AndroidMidsceneTools = __webpack_exports__.AndroidMidsceneTools;
|
|
3537
3662
|
exports.ScrcpyDeviceAdapter = __webpack_exports__.ScrcpyDeviceAdapter;
|
|
3538
3663
|
exports.agentFromAdbDevice = __webpack_exports__.agentFromAdbDevice;
|
|
3664
|
+
exports.androidAgentTestRunnerNodeDefinitions = __webpack_exports__.androidAgentTestRunnerNodeDefinitions;
|
|
3539
3665
|
exports.getConnectedDevices = __webpack_exports__.getConnectedDevices;
|
|
3540
3666
|
exports.getConnectedDevicesWithDetails = __webpack_exports__.getConnectedDevicesWithDetails;
|
|
3667
|
+
exports.launchInputSchema = __webpack_exports__.launchInputSchema;
|
|
3541
3668
|
exports.overrideAIConfig = __webpack_exports__.overrideAIConfig;
|
|
3542
3669
|
exports.resolveExternalResourcePath = __webpack_exports__.resolveExternalResourcePath;
|
|
3670
|
+
exports.runAdbShellInputSchema = __webpack_exports__.runAdbShellInputSchema;
|
|
3671
|
+
exports.runAdbShellOptionsInputSchema = __webpack_exports__.runAdbShellOptionsInputSchema;
|
|
3672
|
+
exports.terminateInputSchema = __webpack_exports__.terminateInputSchema;
|
|
3543
3673
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
3544
3674
|
"AndroidAgent",
|
|
3545
3675
|
"AndroidDevice",
|
|
3546
3676
|
"AndroidMidsceneTools",
|
|
3547
3677
|
"ScrcpyDeviceAdapter",
|
|
3548
3678
|
"agentFromAdbDevice",
|
|
3679
|
+
"androidAgentTestRunnerNodeDefinitions",
|
|
3549
3680
|
"getConnectedDevices",
|
|
3550
3681
|
"getConnectedDevicesWithDetails",
|
|
3682
|
+
"launchInputSchema",
|
|
3551
3683
|
"overrideAIConfig",
|
|
3552
|
-
"resolveExternalResourcePath"
|
|
3684
|
+
"resolveExternalResourcePath",
|
|
3685
|
+
"runAdbShellInputSchema",
|
|
3686
|
+
"runAdbShellOptionsInputSchema",
|
|
3687
|
+
"terminateInputSchema"
|
|
3553
3688
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
3554
3689
|
Object.defineProperty(exports, '__esModule', {
|
|
3555
3690
|
value: true
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
androidAgentTestRunnerNodeDefinitions: ()=>androidAgentTestRunnerNodeDefinitions,
|
|
28
|
+
terminateInputSchema: ()=>terminateInputSchema,
|
|
29
|
+
runAdbShellInputSchema: ()=>runAdbShellInputSchema,
|
|
30
|
+
runAdbShellOptionsInputSchema: ()=>runAdbShellOptionsInputSchema,
|
|
31
|
+
launchInputSchema: ()=>launchInputSchema
|
|
32
|
+
});
|
|
33
|
+
const test_runner_namespaceObject = require("@midscene/core/agent/test-runner");
|
|
34
|
+
const v4_namespaceObject = require("zod/v4");
|
|
35
|
+
const defineAndroidAgentNode = (0, test_runner_namespaceObject.createAgentTestRunnerNodeDefinition)('an Android Agent');
|
|
36
|
+
const nonBlankText = (description)=>v4_namespaceObject.z.string().regex(/\S/, 'value must contain a non-whitespace character').describe(description);
|
|
37
|
+
const launchInputSchema = v4_namespaceObject.z.strictObject({
|
|
38
|
+
uri: nonBlankText('The app, URL, URI, or package name to launch.')
|
|
39
|
+
});
|
|
40
|
+
const terminateInputSchema = v4_namespaceObject.z.strictObject({
|
|
41
|
+
uri: nonBlankText('The package name or app name to terminate.')
|
|
42
|
+
});
|
|
43
|
+
const runAdbShellOptionsInputSchema = v4_namespaceObject.z.strictObject({
|
|
44
|
+
timeout: v4_namespaceObject.z.number().int().positive().optional().describe('ADB shell command timeout in milliseconds.')
|
|
45
|
+
});
|
|
46
|
+
const runAdbShellInputSchema = v4_namespaceObject.z.strictObject({
|
|
47
|
+
command: nonBlankText('The shell command to execute, without an adb shell prefix.'),
|
|
48
|
+
options: runAdbShellOptionsInputSchema.optional()
|
|
49
|
+
});
|
|
50
|
+
const emptyInputSchema = v4_namespaceObject.z.strictObject({});
|
|
51
|
+
const launchNode = defineAndroidAgentNode({
|
|
52
|
+
method: 'launch',
|
|
53
|
+
description: 'Launch an application through the current Android Agent.',
|
|
54
|
+
stringInputKey: 'uri',
|
|
55
|
+
inputSchema: launchInputSchema,
|
|
56
|
+
toArgs: (input)=>[
|
|
57
|
+
input.uri
|
|
58
|
+
],
|
|
59
|
+
toResult: (_output, input)=>({
|
|
60
|
+
summary: `Launched ${input.uri}`
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
const terminateNode = defineAndroidAgentNode({
|
|
64
|
+
method: 'terminate',
|
|
65
|
+
description: 'Terminate an application through the current Android Agent.',
|
|
66
|
+
stringInputKey: 'uri',
|
|
67
|
+
inputSchema: terminateInputSchema,
|
|
68
|
+
toArgs: (input)=>[
|
|
69
|
+
input.uri
|
|
70
|
+
],
|
|
71
|
+
toResult: (_output, input)=>({
|
|
72
|
+
summary: `Terminated ${input.uri}`
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
const runAdbShellNode = defineAndroidAgentNode({
|
|
76
|
+
method: 'runAdbShell',
|
|
77
|
+
title: 'Run an ADB shell command',
|
|
78
|
+
description: 'Execute a shell command through the current Android Agent. Pass only the shell command, without the adb shell prefix.',
|
|
79
|
+
stringInputKey: 'command',
|
|
80
|
+
inputSchema: runAdbShellInputSchema,
|
|
81
|
+
toArgs (input, context) {
|
|
82
|
+
context.signal.throwIfAborted();
|
|
83
|
+
if (/^\s*adb(?:\s|$)/i.test(input.command)) throw new TypeError('command must not include an adb or adb shell prefix.');
|
|
84
|
+
return [
|
|
85
|
+
input.command,
|
|
86
|
+
input.options
|
|
87
|
+
];
|
|
88
|
+
},
|
|
89
|
+
toResult (stdout) {
|
|
90
|
+
if ('string' != typeof stdout) throw new TypeError('runAdbShell() must return stdout as a string.');
|
|
91
|
+
return {
|
|
92
|
+
summary: `Executed ADB shell command (${stdout.length} stdout characters)`,
|
|
93
|
+
data: {
|
|
94
|
+
stdout
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const backNode = defineAndroidAgentNode({
|
|
100
|
+
method: 'back',
|
|
101
|
+
description: 'Trigger the Android system back operation.',
|
|
102
|
+
stringInputKey: false,
|
|
103
|
+
inputSchema: emptyInputSchema,
|
|
104
|
+
toArgs: ()=>[],
|
|
105
|
+
toResult: ()=>({
|
|
106
|
+
summary: 'Triggered Android back'
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
const homeNode = defineAndroidAgentNode({
|
|
110
|
+
method: 'home',
|
|
111
|
+
description: 'Trigger the Android system home operation.',
|
|
112
|
+
stringInputKey: false,
|
|
113
|
+
inputSchema: emptyInputSchema,
|
|
114
|
+
toArgs: ()=>[],
|
|
115
|
+
toResult: ()=>({
|
|
116
|
+
summary: 'Triggered Android home'
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
const recentAppsNode = defineAndroidAgentNode({
|
|
120
|
+
method: 'recentApps',
|
|
121
|
+
description: 'Trigger the Android system recent apps operation.',
|
|
122
|
+
stringInputKey: false,
|
|
123
|
+
inputSchema: emptyInputSchema,
|
|
124
|
+
toArgs: ()=>[],
|
|
125
|
+
toResult: ()=>({
|
|
126
|
+
summary: 'Triggered Android recentApps'
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
const androidAgentTestRunnerNodeDefinitions = [
|
|
130
|
+
launchNode,
|
|
131
|
+
terminateNode,
|
|
132
|
+
runAdbShellNode,
|
|
133
|
+
backNode,
|
|
134
|
+
homeNode,
|
|
135
|
+
recentAppsNode
|
|
136
|
+
];
|
|
137
|
+
exports.androidAgentTestRunnerNodeDefinitions = __webpack_exports__.androidAgentTestRunnerNodeDefinitions;
|
|
138
|
+
exports.launchInputSchema = __webpack_exports__.launchInputSchema;
|
|
139
|
+
exports.runAdbShellInputSchema = __webpack_exports__.runAdbShellInputSchema;
|
|
140
|
+
exports.runAdbShellOptionsInputSchema = __webpack_exports__.runAdbShellOptionsInputSchema;
|
|
141
|
+
exports.terminateInputSchema = __webpack_exports__.terminateInputSchema;
|
|
142
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
143
|
+
"androidAgentTestRunnerNodeDefinitions",
|
|
144
|
+
"launchInputSchema",
|
|
145
|
+
"runAdbShellInputSchema",
|
|
146
|
+
"runAdbShellOptionsInputSchema",
|
|
147
|
+
"terminateInputSchema"
|
|
148
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
149
|
+
Object.defineProperty(exports, '__esModule', {
|
|
150
|
+
value: true
|
|
151
|
+
});
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { Adb } from '@yume-chan/adb';
|
|
|
6
6
|
import { Agent } from '@midscene/core/agent';
|
|
7
7
|
import { AgentBehaviorInitArgs } from '@midscene/shared/agent-tools/agent-behavior-init-args';
|
|
8
8
|
import { AgentOpt } from '@midscene/core/agent';
|
|
9
|
+
import { AgentTestRunnerNodeDefinition } from '@midscene/core/agent';
|
|
10
|
+
import { AgentTestRunnerNodeDefinition as AgentTestRunnerNodeDefinition_2 } from '@midscene/core/agent/test-runner';
|
|
9
11
|
import { AndroidDeviceInputOpt } from '@midscene/core/device';
|
|
10
12
|
import { AndroidDeviceOpt } from '@midscene/core/device';
|
|
11
13
|
import { BaseMidsceneTools } from '@midscene/shared/agent-tools/base-tools';
|
|
@@ -20,12 +22,14 @@ import { Point } from '@midscene/core';
|
|
|
20
22
|
import { Size } from '@midscene/core';
|
|
21
23
|
import type { ToolDefinition } from '@midscene/shared/agent-tools/types';
|
|
22
24
|
import { UITreeSnapshot } from '@midscene/core';
|
|
25
|
+
import { z } from 'zod/v4';
|
|
23
26
|
|
|
24
27
|
declare type ActionArgs<T extends DeviceAction> = [ActionParam<T>] extends [undefined] ? [] : [ActionParam<T>];
|
|
25
28
|
|
|
26
29
|
export declare function agentFromAdbDevice(deviceId?: string, opts?: AndroidAgentOpt & AndroidDeviceOpt): Promise<AndroidAgent>;
|
|
27
30
|
|
|
28
31
|
export declare class AndroidAgent extends Agent<AndroidDevice> {
|
|
32
|
+
static getTestRunnerNodeDefinitions(): readonly AgentTestRunnerNodeDefinition[];
|
|
29
33
|
/**
|
|
30
34
|
* Trigger the system back operation on Android devices
|
|
31
35
|
*/
|
|
@@ -70,6 +74,8 @@ export declare type AndroidAgentOpt = AgentOpt & {
|
|
|
70
74
|
appNameMapping?: Record<string, string>;
|
|
71
75
|
};
|
|
72
76
|
|
|
77
|
+
export declare const androidAgentTestRunnerNodeDefinitions: readonly AgentTestRunnerNodeDefinition_2[];
|
|
78
|
+
|
|
73
79
|
export declare interface AndroidConnectedDevice extends Device {
|
|
74
80
|
model?: string;
|
|
75
81
|
brand?: string;
|
|
@@ -368,6 +374,12 @@ export declare function getConnectedDevices(deviceOptions?: AndroidDeviceOpt): P
|
|
|
368
374
|
|
|
369
375
|
export declare function getConnectedDevicesWithDetails(deviceOptions?: AndroidDeviceOpt): Promise<AndroidConnectedDevice[]>;
|
|
370
376
|
|
|
377
|
+
export declare const launchInputSchema: z.ZodObject<{
|
|
378
|
+
uri: z.ZodString;
|
|
379
|
+
}, z.core.$strict>;
|
|
380
|
+
|
|
381
|
+
export declare type LaunchNodeInput = z.infer<typeof launchInputSchema>;
|
|
382
|
+
|
|
371
383
|
export { overrideAIConfig }
|
|
372
384
|
|
|
373
385
|
/**
|
|
@@ -404,13 +416,26 @@ export declare function resolveExternalResourcePath(resourcePath: string, pathEx
|
|
|
404
416
|
|
|
405
417
|
export declare type ResolveScrcpyAdbBackend = () => ScrcpyAdbBackend | Promise<ScrcpyAdbBackend>;
|
|
406
418
|
|
|
407
|
-
declare
|
|
419
|
+
export declare const runAdbShellInputSchema: z.ZodObject<{
|
|
420
|
+
command: z.ZodString;
|
|
421
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
422
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
423
|
+
}, z.core.$strict>>;
|
|
424
|
+
}, z.core.$strict>;
|
|
425
|
+
|
|
426
|
+
export declare type RunAdbShellNodeInput = z.infer<typeof runAdbShellInputSchema>;
|
|
427
|
+
|
|
428
|
+
export declare type RunAdbShellOpt = {
|
|
408
429
|
/**
|
|
409
430
|
* ADB shell command execution timeout in milliseconds.
|
|
410
431
|
*/
|
|
411
432
|
timeout?: number;
|
|
412
433
|
};
|
|
413
434
|
|
|
435
|
+
export declare const runAdbShellOptionsInputSchema: z.ZodObject<{
|
|
436
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
437
|
+
}, z.core.$strict>;
|
|
438
|
+
|
|
414
439
|
/** ADB capabilities scrcpy needs from the canonical Appium transport. */
|
|
415
440
|
export declare interface ScrcpyAdbBackend {
|
|
416
441
|
adbHost?: string;
|
|
@@ -756,6 +781,12 @@ export declare interface ScrcpyStatus {
|
|
|
756
781
|
|
|
757
782
|
declare type ScrollDirection = 'up' | 'down' | 'left' | 'right';
|
|
758
783
|
|
|
784
|
+
export declare const terminateInputSchema: z.ZodObject<{
|
|
785
|
+
uri: z.ZodString;
|
|
786
|
+
}, z.core.$strict>;
|
|
787
|
+
|
|
788
|
+
export declare type TerminateNodeInput = z.infer<typeof terminateInputSchema>;
|
|
789
|
+
|
|
759
790
|
/**
|
|
760
791
|
* Helper type to convert DeviceAction to wrapped method signature
|
|
761
792
|
*/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AgentTestRunnerNodeDefinition } from '@midscene/core/agent/test-runner';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
|
|
4
|
+
export declare const androidAgentTestRunnerNodeDefinitions: readonly AgentTestRunnerNodeDefinition[];
|
|
5
|
+
|
|
6
|
+
export declare const launchInputSchema: z.ZodObject<{
|
|
7
|
+
uri: z.ZodString;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
|
|
10
|
+
export declare type LaunchNodeInput = z.infer<typeof launchInputSchema>;
|
|
11
|
+
|
|
12
|
+
export declare const runAdbShellInputSchema: z.ZodObject<{
|
|
13
|
+
command: z.ZodString;
|
|
14
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
}, z.core.$strict>>;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
|
|
19
|
+
export declare type RunAdbShellNodeInput = z.infer<typeof runAdbShellInputSchema>;
|
|
20
|
+
|
|
21
|
+
export declare const runAdbShellOptionsInputSchema: z.ZodObject<{
|
|
22
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
|
|
25
|
+
export declare const terminateInputSchema: z.ZodObject<{
|
|
26
|
+
uri: z.ZodString;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
|
|
29
|
+
export declare type TerminateNodeInput = z.infer<typeof terminateInputSchema>;
|
|
30
|
+
|
|
31
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/android",
|
|
3
|
-
"version": "1.12.4
|
|
3
|
+
"version": "1.12.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/midscene.git",
|
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
"import": "./dist/es/index.mjs",
|
|
32
32
|
"require": "./dist/lib/index.js"
|
|
33
33
|
},
|
|
34
|
+
"./test-runner": {
|
|
35
|
+
"types": "./dist/types/test-runner.d.ts",
|
|
36
|
+
"import": "./dist/es/test-runner.mjs",
|
|
37
|
+
"require": "./dist/lib/test-runner.js"
|
|
38
|
+
},
|
|
34
39
|
"./package.json": "./package.json"
|
|
35
40
|
},
|
|
36
41
|
"dependencies": {
|
|
@@ -41,8 +46,9 @@
|
|
|
41
46
|
"@yume-chan/stream-extra": "2.6.1",
|
|
42
47
|
"appium-adb": "12.12.1",
|
|
43
48
|
"sharp": "^0.34.3",
|
|
44
|
-
"
|
|
45
|
-
"@midscene/
|
|
49
|
+
"zod": "^3.25.1",
|
|
50
|
+
"@midscene/core": "1.12.4",
|
|
51
|
+
"@midscene/shared": "1.12.4"
|
|
46
52
|
},
|
|
47
53
|
"optionalDependencies": {
|
|
48
54
|
"@ffmpeg-installer/ffmpeg": "^1.1.0"
|
|
@@ -55,8 +61,7 @@
|
|
|
55
61
|
"tsx": "^4.19.2",
|
|
56
62
|
"typescript": "^5.8.3",
|
|
57
63
|
"undici": "^6.0.0",
|
|
58
|
-
"
|
|
59
|
-
"@midscene/playground": "1.12.4-beta-20260903111111.0"
|
|
64
|
+
"@midscene/playground": "1.12.4"
|
|
60
65
|
},
|
|
61
66
|
"license": "MIT",
|
|
62
67
|
"scripts": {
|