@midscene/ios 1.7.6 → 1.7.7-beta-20260428092036.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/bin.mjs +24 -7
- package/dist/es/cli.mjs +17 -2
- package/dist/es/index.mjs +17 -7
- package/dist/es/mcp-server.mjs +17 -2
- package/dist/lib/bin.js +24 -7
- package/dist/lib/cli.js +17 -2
- package/dist/lib/index.js +17 -7
- package/dist/lib/mcp-server.js +17 -2
- package/package.json +5 -5
- package/static/index.html +1 -1
- package/static/static/css/index.a02873b3.css +2 -0
- package/static/static/css/index.a02873b3.css.map +1 -0
- package/static/static/js/{index.8f7b788e.js → index.c01e1ead.js} +44 -44
- package/static/static/js/index.c01e1ead.js.map +1 -0
- package/static/static/css/index.dc500f18.css +0 -2
- package/static/static/css/index.dc500f18.css.map +0 -1
- package/static/static/js/index.8f7b788e.js.map +0 -1
- /package/static/static/js/{index.8f7b788e.js.LICENSE.txt → index.c01e1ead.js.LICENSE.txt} +0 -0
package/dist/es/bin.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { createMjpegPreviewDescriptor, definePlaygroundPlatform, launchPreparedP
|
|
|
3
3
|
import { DEFAULT_WDA_PORT, PLAYGROUND_SERVER_PORT } from "@midscene/shared/constants";
|
|
4
4
|
import { findAvailablePort } from "@midscene/shared/node";
|
|
5
5
|
import { Agent } from "@midscene/core/agent";
|
|
6
|
+
import { MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE } from "@midscene/shared/env";
|
|
6
7
|
import { getDebug } from "@midscene/shared/logger";
|
|
7
8
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison } from "@midscene/shared/utils";
|
|
8
9
|
import node_assert from "node:assert";
|
|
@@ -666,7 +667,7 @@ const WDA_HTTP_METHODS = [
|
|
|
666
667
|
'PUT'
|
|
667
668
|
];
|
|
668
669
|
const DEFAULT_WDA_MJPEG_PORT = 9100;
|
|
669
|
-
class
|
|
670
|
+
class IOSDevice {
|
|
670
671
|
actionSpace() {
|
|
671
672
|
const defaultActions = [
|
|
672
673
|
defineActionTap(async (param)=>{
|
|
@@ -1267,6 +1268,8 @@ const createPlatformActions = (device)=>({
|
|
|
1267
1268
|
sample: {
|
|
1268
1269
|
uri: 'com.apple.Preferences'
|
|
1269
1270
|
},
|
|
1271
|
+
delayBeforeRunner: 0,
|
|
1272
|
+
delayAfterRunner: 0,
|
|
1270
1273
|
call: async (param)=>{
|
|
1271
1274
|
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1272
1275
|
await device.terminate(param.uri);
|
|
@@ -1275,6 +1278,8 @@ const createPlatformActions = (device)=>({
|
|
|
1275
1278
|
IOSHomeButton: defineAction({
|
|
1276
1279
|
name: 'IOSHomeButton',
|
|
1277
1280
|
description: 'Trigger the system "home" operation on iOS devices',
|
|
1281
|
+
delayBeforeRunner: 0,
|
|
1282
|
+
delayAfterRunner: 0,
|
|
1278
1283
|
call: async ()=>{
|
|
1279
1284
|
await device.home();
|
|
1280
1285
|
}
|
|
@@ -1297,7 +1302,7 @@ function agent_define_property(obj, key, value) {
|
|
|
1297
1302
|
else obj[key] = value;
|
|
1298
1303
|
return obj;
|
|
1299
1304
|
}
|
|
1300
|
-
getDebug('ios:agent');
|
|
1305
|
+
const debugAgent = getDebug('ios:agent');
|
|
1301
1306
|
class IOSAgent extends Agent {
|
|
1302
1307
|
async launch(uri) {
|
|
1303
1308
|
const action = this.wrapActionInActionSpace('Launch');
|
|
@@ -1324,6 +1329,22 @@ class IOSAgent extends Agent {
|
|
|
1324
1329
|
this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
|
|
1325
1330
|
}
|
|
1326
1331
|
}
|
|
1332
|
+
async function agentFromWebDriverAgent(opts) {
|
|
1333
|
+
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1334
|
+
const overrideModule = opts?.iOSDeviceClassOverride?.trim() || opts?.iosDeviceClassOverride?.trim() || process.env[MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE]?.trim();
|
|
1335
|
+
let DeviceClass = IOSDevice;
|
|
1336
|
+
if (overrideModule) try {
|
|
1337
|
+
const overrideExports = await import(overrideModule);
|
|
1338
|
+
const overrideDeviceClass = Object.prototype.hasOwnProperty.call(overrideExports, 'IOSDevice') ? overrideExports.IOSDevice : overrideExports.default;
|
|
1339
|
+
if ('function' != typeof overrideDeviceClass) throw new Error(`Module "${overrideModule}" does not export a valid iOS device class (expected "IOSDevice" or default export).`);
|
|
1340
|
+
DeviceClass = overrideDeviceClass;
|
|
1341
|
+
} catch (error) {
|
|
1342
|
+
throw new Error(`Failed to load iOS device class override from "${overrideModule}". Please make sure the package is installed and exports IOSDevice (or default) with Midscene-compatible methods. Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
1343
|
+
}
|
|
1344
|
+
const device = new DeviceClass(opts || {});
|
|
1345
|
+
await device.connect();
|
|
1346
|
+
return new IOSAgent(device, opts);
|
|
1347
|
+
}
|
|
1327
1348
|
const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
1328
1349
|
id: 'ios',
|
|
1329
1350
|
title: 'Midscene iOS Playground',
|
|
@@ -1362,14 +1383,10 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
|
1362
1383
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
1363
1384
|
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? DEFAULT_WDA_PORT), 10);
|
|
1364
1385
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
1365
|
-
const connectAgent = async ()=>{
|
|
1366
|
-
const newDevice = new device_IOSDevice({
|
|
1386
|
+
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
1367
1387
|
wdaHost: host,
|
|
1368
1388
|
wdaPort: port
|
|
1369
1389
|
});
|
|
1370
|
-
await newDevice.connect();
|
|
1371
|
-
return new IOSAgent(newDevice);
|
|
1372
|
-
};
|
|
1373
1390
|
const agent = await connectAgent();
|
|
1374
1391
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
1375
1392
|
const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : `${host}:${port}`;
|
package/dist/es/cli.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { reportCLIError, runToolsCLI } from "@midscene/shared/cli";
|
|
|
3
3
|
import { getDebug } from "@midscene/shared/logger";
|
|
4
4
|
import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
|
|
5
5
|
import { Agent } from "@midscene/core/agent";
|
|
6
|
+
import { MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE } from "@midscene/shared/env";
|
|
6
7
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison } from "@midscene/shared/utils";
|
|
7
8
|
import node_assert from "node:assert";
|
|
8
9
|
import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionLongPress, defineActionPinch, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam, normalizePinchParam } from "@midscene/core/device";
|
|
@@ -1266,6 +1267,8 @@ const createPlatformActions = (device)=>({
|
|
|
1266
1267
|
sample: {
|
|
1267
1268
|
uri: 'com.apple.Preferences'
|
|
1268
1269
|
},
|
|
1270
|
+
delayBeforeRunner: 0,
|
|
1271
|
+
delayAfterRunner: 0,
|
|
1269
1272
|
call: async (param)=>{
|
|
1270
1273
|
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1271
1274
|
await device.terminate(param.uri);
|
|
@@ -1274,6 +1277,8 @@ const createPlatformActions = (device)=>({
|
|
|
1274
1277
|
IOSHomeButton: defineAction({
|
|
1275
1278
|
name: 'IOSHomeButton',
|
|
1276
1279
|
description: 'Trigger the system "home" operation on iOS devices',
|
|
1280
|
+
delayBeforeRunner: 0,
|
|
1281
|
+
delayAfterRunner: 0,
|
|
1277
1282
|
call: async ()=>{
|
|
1278
1283
|
await device.home();
|
|
1279
1284
|
}
|
|
@@ -1325,7 +1330,17 @@ class IOSAgent extends Agent {
|
|
|
1325
1330
|
}
|
|
1326
1331
|
async function agentFromWebDriverAgent(opts) {
|
|
1327
1332
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1328
|
-
const
|
|
1333
|
+
const overrideModule = opts?.iOSDeviceClassOverride?.trim() || opts?.iosDeviceClassOverride?.trim() || process.env[MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE]?.trim();
|
|
1334
|
+
let DeviceClass = IOSDevice;
|
|
1335
|
+
if (overrideModule) try {
|
|
1336
|
+
const overrideExports = await import(overrideModule);
|
|
1337
|
+
const overrideDeviceClass = Object.prototype.hasOwnProperty.call(overrideExports, 'IOSDevice') ? overrideExports.IOSDevice : overrideExports.default;
|
|
1338
|
+
if ('function' != typeof overrideDeviceClass) throw new Error(`Module "${overrideModule}" does not export a valid iOS device class (expected "IOSDevice" or default export).`);
|
|
1339
|
+
DeviceClass = overrideDeviceClass;
|
|
1340
|
+
} catch (error) {
|
|
1341
|
+
throw new Error(`Failed to load iOS device class override from "${overrideModule}". Please make sure the package is installed and exports IOSDevice (or default) with Midscene-compatible methods. Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
1342
|
+
}
|
|
1343
|
+
const device = new DeviceClass(opts || {});
|
|
1329
1344
|
await device.connect();
|
|
1330
1345
|
return new IOSAgent(device, opts);
|
|
1331
1346
|
}
|
|
@@ -1432,7 +1447,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
|
|
|
1432
1447
|
const tools = new IOSMidsceneTools();
|
|
1433
1448
|
runToolsCLI(tools, 'midscene-ios', {
|
|
1434
1449
|
stripPrefix: 'ios_',
|
|
1435
|
-
version: "1.7.
|
|
1450
|
+
version: "1.7.7-beta-20260428092036.0",
|
|
1436
1451
|
extraCommands: createReportCliCommands()
|
|
1437
1452
|
}).catch((e)=>{
|
|
1438
1453
|
process.exit(reportCLIError(e));
|
package/dist/es/index.mjs
CHANGED
|
@@ -8,8 +8,8 @@ import { getDebug } from "@midscene/shared/logger";
|
|
|
8
8
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison } from "@midscene/shared/utils";
|
|
9
9
|
import { WDAManager, WebDriverClient } from "@midscene/webdriver";
|
|
10
10
|
import { Agent } from "@midscene/core/agent";
|
|
11
|
+
import { MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE, overrideAIConfig } from "@midscene/shared/env";
|
|
11
12
|
import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
|
|
12
|
-
import { overrideAIConfig } from "@midscene/shared/env";
|
|
13
13
|
import { exec } from "node:child_process";
|
|
14
14
|
import { platform } from "node:os";
|
|
15
15
|
import { promisify } from "node:util";
|
|
@@ -1088,6 +1088,8 @@ const createPlatformActions = (device)=>({
|
|
|
1088
1088
|
sample: {
|
|
1089
1089
|
uri: 'com.apple.Preferences'
|
|
1090
1090
|
},
|
|
1091
|
+
delayBeforeRunner: 0,
|
|
1092
|
+
delayAfterRunner: 0,
|
|
1091
1093
|
call: async (param)=>{
|
|
1092
1094
|
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1093
1095
|
await device.terminate(param.uri);
|
|
@@ -1096,6 +1098,8 @@ const createPlatformActions = (device)=>({
|
|
|
1096
1098
|
IOSHomeButton: defineAction({
|
|
1097
1099
|
name: 'IOSHomeButton',
|
|
1098
1100
|
description: 'Trigger the system "home" operation on iOS devices',
|
|
1101
|
+
delayBeforeRunner: 0,
|
|
1102
|
+
delayAfterRunner: 0,
|
|
1099
1103
|
call: async ()=>{
|
|
1100
1104
|
await device.home();
|
|
1101
1105
|
}
|
|
@@ -1331,7 +1335,17 @@ class IOSAgent extends Agent {
|
|
|
1331
1335
|
}
|
|
1332
1336
|
async function agentFromWebDriverAgent(opts) {
|
|
1333
1337
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1334
|
-
const
|
|
1338
|
+
const overrideModule = opts?.iOSDeviceClassOverride?.trim() || opts?.iosDeviceClassOverride?.trim() || process.env[MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE]?.trim();
|
|
1339
|
+
let DeviceClass = IOSDevice;
|
|
1340
|
+
if (overrideModule) try {
|
|
1341
|
+
const overrideExports = await import(overrideModule);
|
|
1342
|
+
const overrideDeviceClass = Object.prototype.hasOwnProperty.call(overrideExports, 'IOSDevice') ? overrideExports.IOSDevice : overrideExports.default;
|
|
1343
|
+
if ('function' != typeof overrideDeviceClass) throw new Error(`Module "${overrideModule}" does not export a valid iOS device class (expected "IOSDevice" or default export).`);
|
|
1344
|
+
DeviceClass = overrideDeviceClass;
|
|
1345
|
+
} catch (error) {
|
|
1346
|
+
throw new Error(`Failed to load iOS device class override from "${overrideModule}". Please make sure the package is installed and exports IOSDevice (or default) with Midscene-compatible methods. Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
1347
|
+
}
|
|
1348
|
+
const device = new DeviceClass(opts || {});
|
|
1335
1349
|
await device.connect();
|
|
1336
1350
|
return new IOSAgent(device, opts);
|
|
1337
1351
|
}
|
|
@@ -1519,14 +1533,10 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
|
1519
1533
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
1520
1534
|
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? DEFAULT_WDA_PORT), 10);
|
|
1521
1535
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
1522
|
-
const connectAgent = async ()=>{
|
|
1523
|
-
const newDevice = new IOSDevice({
|
|
1536
|
+
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
1524
1537
|
wdaHost: host,
|
|
1525
1538
|
wdaPort: port
|
|
1526
1539
|
});
|
|
1527
|
-
await newDevice.connect();
|
|
1528
|
-
return new IOSAgent(newDevice);
|
|
1529
|
-
};
|
|
1530
1540
|
const agent = await connectAgent();
|
|
1531
1541
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
1532
1542
|
const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : `${host}:${port}`;
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseMCPServer, createMCPServerLauncher } from "@midscene/shared/mcp";
|
|
2
2
|
import { Agent } from "@midscene/core/agent";
|
|
3
|
+
import { MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE } from "@midscene/shared/env";
|
|
3
4
|
import { getDebug } from "@midscene/shared/logger";
|
|
4
5
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison } from "@midscene/shared/utils";
|
|
5
6
|
import node_assert from "node:assert";
|
|
@@ -1266,6 +1267,8 @@ const createPlatformActions = (device)=>({
|
|
|
1266
1267
|
sample: {
|
|
1267
1268
|
uri: 'com.apple.Preferences'
|
|
1268
1269
|
},
|
|
1270
|
+
delayBeforeRunner: 0,
|
|
1271
|
+
delayAfterRunner: 0,
|
|
1269
1272
|
call: async (param)=>{
|
|
1270
1273
|
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1271
1274
|
await device.terminate(param.uri);
|
|
@@ -1274,6 +1277,8 @@ const createPlatformActions = (device)=>({
|
|
|
1274
1277
|
IOSHomeButton: defineAction({
|
|
1275
1278
|
name: 'IOSHomeButton',
|
|
1276
1279
|
description: 'Trigger the system "home" operation on iOS devices',
|
|
1280
|
+
delayBeforeRunner: 0,
|
|
1281
|
+
delayAfterRunner: 0,
|
|
1277
1282
|
call: async ()=>{
|
|
1278
1283
|
await device.home();
|
|
1279
1284
|
}
|
|
@@ -1325,7 +1330,17 @@ class IOSAgent extends Agent {
|
|
|
1325
1330
|
}
|
|
1326
1331
|
async function agentFromWebDriverAgent(opts) {
|
|
1327
1332
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1328
|
-
const
|
|
1333
|
+
const overrideModule = opts?.iOSDeviceClassOverride?.trim() || opts?.iosDeviceClassOverride?.trim() || process.env[MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE]?.trim();
|
|
1334
|
+
let DeviceClass = IOSDevice;
|
|
1335
|
+
if (overrideModule) try {
|
|
1336
|
+
const overrideExports = await import(overrideModule);
|
|
1337
|
+
const overrideDeviceClass = Object.prototype.hasOwnProperty.call(overrideExports, 'IOSDevice') ? overrideExports.IOSDevice : overrideExports.default;
|
|
1338
|
+
if ('function' != typeof overrideDeviceClass) throw new Error(`Module "${overrideModule}" does not export a valid iOS device class (expected "IOSDevice" or default export).`);
|
|
1339
|
+
DeviceClass = overrideDeviceClass;
|
|
1340
|
+
} catch (error) {
|
|
1341
|
+
throw new Error(`Failed to load iOS device class override from "${overrideModule}". Please make sure the package is installed and exports IOSDevice (or default) with Midscene-compatible methods. Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
1342
|
+
}
|
|
1343
|
+
const device = new DeviceClass(opts || {});
|
|
1329
1344
|
await device.connect();
|
|
1330
1345
|
return new IOSAgent(device, opts);
|
|
1331
1346
|
}
|
|
@@ -1436,7 +1451,7 @@ class IOSMCPServer extends BaseMCPServer {
|
|
|
1436
1451
|
constructor(toolsManager){
|
|
1437
1452
|
super({
|
|
1438
1453
|
name: '@midscene/ios-mcp',
|
|
1439
|
-
version: "1.7.
|
|
1454
|
+
version: "1.7.7-beta-20260428092036.0",
|
|
1440
1455
|
description: 'Control the iOS device using natural language commands'
|
|
1441
1456
|
}, toolsManager);
|
|
1442
1457
|
}
|
package/dist/lib/bin.js
CHANGED
|
@@ -27,6 +27,7 @@ const playground_namespaceObject = require("@midscene/playground");
|
|
|
27
27
|
const constants_namespaceObject = require("@midscene/shared/constants");
|
|
28
28
|
const node_namespaceObject = require("@midscene/shared/node");
|
|
29
29
|
const agent_namespaceObject = require("@midscene/core/agent");
|
|
30
|
+
const env_namespaceObject = require("@midscene/shared/env");
|
|
30
31
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
31
32
|
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
32
33
|
const defaultAppNameMapping = {
|
|
@@ -691,7 +692,7 @@ const WDA_HTTP_METHODS = [
|
|
|
691
692
|
'PUT'
|
|
692
693
|
];
|
|
693
694
|
const DEFAULT_WDA_MJPEG_PORT = 9100;
|
|
694
|
-
class
|
|
695
|
+
class IOSDevice {
|
|
695
696
|
actionSpace() {
|
|
696
697
|
const defaultActions = [
|
|
697
698
|
(0, device_namespaceObject.defineActionTap)(async (param)=>{
|
|
@@ -1292,6 +1293,8 @@ const createPlatformActions = (device)=>({
|
|
|
1292
1293
|
sample: {
|
|
1293
1294
|
uri: 'com.apple.Preferences'
|
|
1294
1295
|
},
|
|
1296
|
+
delayBeforeRunner: 0,
|
|
1297
|
+
delayAfterRunner: 0,
|
|
1295
1298
|
call: async (param)=>{
|
|
1296
1299
|
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1297
1300
|
await device.terminate(param.uri);
|
|
@@ -1300,6 +1303,8 @@ const createPlatformActions = (device)=>({
|
|
|
1300
1303
|
IOSHomeButton: (0, device_namespaceObject.defineAction)({
|
|
1301
1304
|
name: 'IOSHomeButton',
|
|
1302
1305
|
description: 'Trigger the system "home" operation on iOS devices',
|
|
1306
|
+
delayBeforeRunner: 0,
|
|
1307
|
+
delayAfterRunner: 0,
|
|
1303
1308
|
call: async ()=>{
|
|
1304
1309
|
await device.home();
|
|
1305
1310
|
}
|
|
@@ -1322,7 +1327,7 @@ function agent_define_property(obj, key, value) {
|
|
|
1322
1327
|
else obj[key] = value;
|
|
1323
1328
|
return obj;
|
|
1324
1329
|
}
|
|
1325
|
-
(0, logger_namespaceObject.getDebug)('ios:agent');
|
|
1330
|
+
const debugAgent = (0, logger_namespaceObject.getDebug)('ios:agent');
|
|
1326
1331
|
class IOSAgent extends agent_namespaceObject.Agent {
|
|
1327
1332
|
async launch(uri) {
|
|
1328
1333
|
const action = this.wrapActionInActionSpace('Launch');
|
|
@@ -1349,6 +1354,22 @@ class IOSAgent extends agent_namespaceObject.Agent {
|
|
|
1349
1354
|
this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
|
|
1350
1355
|
}
|
|
1351
1356
|
}
|
|
1357
|
+
async function agentFromWebDriverAgent(opts) {
|
|
1358
|
+
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1359
|
+
const overrideModule = opts?.iOSDeviceClassOverride?.trim() || opts?.iosDeviceClassOverride?.trim() || process.env[env_namespaceObject.MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE]?.trim();
|
|
1360
|
+
let DeviceClass = IOSDevice;
|
|
1361
|
+
if (overrideModule) try {
|
|
1362
|
+
const overrideExports = await import(overrideModule);
|
|
1363
|
+
const overrideDeviceClass = Object.prototype.hasOwnProperty.call(overrideExports, 'IOSDevice') ? overrideExports.IOSDevice : overrideExports.default;
|
|
1364
|
+
if ('function' != typeof overrideDeviceClass) throw new Error(`Module "${overrideModule}" does not export a valid iOS device class (expected "IOSDevice" or default export).`);
|
|
1365
|
+
DeviceClass = overrideDeviceClass;
|
|
1366
|
+
} catch (error) {
|
|
1367
|
+
throw new Error(`Failed to load iOS device class override from "${overrideModule}". Please make sure the package is installed and exports IOSDevice (or default) with Midscene-compatible methods. Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
1368
|
+
}
|
|
1369
|
+
const device = new DeviceClass(opts || {});
|
|
1370
|
+
await device.connect();
|
|
1371
|
+
return new IOSAgent(device, opts);
|
|
1372
|
+
}
|
|
1352
1373
|
const iosPlaygroundPlatform = (0, playground_namespaceObject.definePlaygroundPlatform)({
|
|
1353
1374
|
id: 'ios',
|
|
1354
1375
|
title: 'Midscene iOS Playground',
|
|
@@ -1387,14 +1408,10 @@ const iosPlaygroundPlatform = (0, playground_namespaceObject.definePlaygroundPla
|
|
|
1387
1408
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
1388
1409
|
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? constants_namespaceObject.DEFAULT_WDA_PORT), 10);
|
|
1389
1410
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
1390
|
-
const connectAgent = async ()=>{
|
|
1391
|
-
const newDevice = new device_IOSDevice({
|
|
1411
|
+
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
1392
1412
|
wdaHost: host,
|
|
1393
1413
|
wdaPort: port
|
|
1394
1414
|
});
|
|
1395
|
-
await newDevice.connect();
|
|
1396
|
-
return new IOSAgent(newDevice);
|
|
1397
|
-
};
|
|
1398
1415
|
const agent = await connectAgent();
|
|
1399
1416
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
1400
1417
|
const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : `${host}:${port}`;
|
package/dist/lib/cli.js
CHANGED
|
@@ -26,6 +26,7 @@ const cli_namespaceObject = require("@midscene/shared/cli");
|
|
|
26
26
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
27
27
|
const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
|
|
28
28
|
const agent_namespaceObject = require("@midscene/core/agent");
|
|
29
|
+
const env_namespaceObject = require("@midscene/shared/env");
|
|
29
30
|
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
30
31
|
const defaultAppNameMapping = {
|
|
31
32
|
微信: 'com.tencent.xin',
|
|
@@ -1290,6 +1291,8 @@ const createPlatformActions = (device)=>({
|
|
|
1290
1291
|
sample: {
|
|
1291
1292
|
uri: 'com.apple.Preferences'
|
|
1292
1293
|
},
|
|
1294
|
+
delayBeforeRunner: 0,
|
|
1295
|
+
delayAfterRunner: 0,
|
|
1293
1296
|
call: async (param)=>{
|
|
1294
1297
|
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1295
1298
|
await device.terminate(param.uri);
|
|
@@ -1298,6 +1301,8 @@ const createPlatformActions = (device)=>({
|
|
|
1298
1301
|
IOSHomeButton: (0, device_namespaceObject.defineAction)({
|
|
1299
1302
|
name: 'IOSHomeButton',
|
|
1300
1303
|
description: 'Trigger the system "home" operation on iOS devices',
|
|
1304
|
+
delayBeforeRunner: 0,
|
|
1305
|
+
delayAfterRunner: 0,
|
|
1301
1306
|
call: async ()=>{
|
|
1302
1307
|
await device.home();
|
|
1303
1308
|
}
|
|
@@ -1349,7 +1354,17 @@ class IOSAgent extends agent_namespaceObject.Agent {
|
|
|
1349
1354
|
}
|
|
1350
1355
|
async function agentFromWebDriverAgent(opts) {
|
|
1351
1356
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1352
|
-
const
|
|
1357
|
+
const overrideModule = opts?.iOSDeviceClassOverride?.trim() || opts?.iosDeviceClassOverride?.trim() || process.env[env_namespaceObject.MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE]?.trim();
|
|
1358
|
+
let DeviceClass = IOSDevice;
|
|
1359
|
+
if (overrideModule) try {
|
|
1360
|
+
const overrideExports = await import(overrideModule);
|
|
1361
|
+
const overrideDeviceClass = Object.prototype.hasOwnProperty.call(overrideExports, 'IOSDevice') ? overrideExports.IOSDevice : overrideExports.default;
|
|
1362
|
+
if ('function' != typeof overrideDeviceClass) throw new Error(`Module "${overrideModule}" does not export a valid iOS device class (expected "IOSDevice" or default export).`);
|
|
1363
|
+
DeviceClass = overrideDeviceClass;
|
|
1364
|
+
} catch (error) {
|
|
1365
|
+
throw new Error(`Failed to load iOS device class override from "${overrideModule}". Please make sure the package is installed and exports IOSDevice (or default) with Midscene-compatible methods. Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
1366
|
+
}
|
|
1367
|
+
const device = new DeviceClass(opts || {});
|
|
1353
1368
|
await device.connect();
|
|
1354
1369
|
return new IOSAgent(device, opts);
|
|
1355
1370
|
}
|
|
@@ -1456,7 +1471,7 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
|
|
|
1456
1471
|
const tools = new IOSMidsceneTools();
|
|
1457
1472
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-ios', {
|
|
1458
1473
|
stripPrefix: 'ios_',
|
|
1459
|
-
version: "1.7.
|
|
1474
|
+
version: "1.7.7-beta-20260428092036.0",
|
|
1460
1475
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
1461
1476
|
}).catch((e)=>{
|
|
1462
1477
|
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|
package/dist/lib/index.js
CHANGED
|
@@ -1124,6 +1124,8 @@ const createPlatformActions = (device)=>({
|
|
|
1124
1124
|
sample: {
|
|
1125
1125
|
uri: 'com.apple.Preferences'
|
|
1126
1126
|
},
|
|
1127
|
+
delayBeforeRunner: 0,
|
|
1128
|
+
delayAfterRunner: 0,
|
|
1127
1129
|
call: async (param)=>{
|
|
1128
1130
|
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1129
1131
|
await device.terminate(param.uri);
|
|
@@ -1132,6 +1134,8 @@ const createPlatformActions = (device)=>({
|
|
|
1132
1134
|
IOSHomeButton: (0, device_namespaceObject.defineAction)({
|
|
1133
1135
|
name: 'IOSHomeButton',
|
|
1134
1136
|
description: 'Trigger the system "home" operation on iOS devices',
|
|
1137
|
+
delayBeforeRunner: 0,
|
|
1138
|
+
delayAfterRunner: 0,
|
|
1135
1139
|
call: async ()=>{
|
|
1136
1140
|
await device.home();
|
|
1137
1141
|
}
|
|
@@ -1145,6 +1149,7 @@ const createPlatformActions = (device)=>({
|
|
|
1145
1149
|
})
|
|
1146
1150
|
});
|
|
1147
1151
|
const agent_namespaceObject = require("@midscene/core/agent");
|
|
1152
|
+
const env_namespaceObject = require("@midscene/shared/env");
|
|
1148
1153
|
const defaultAppNameMapping = {
|
|
1149
1154
|
微信: 'com.tencent.xin',
|
|
1150
1155
|
企业微信: 'com.tencent.ww',
|
|
@@ -1368,7 +1373,17 @@ class IOSAgent extends agent_namespaceObject.Agent {
|
|
|
1368
1373
|
}
|
|
1369
1374
|
async function agentFromWebDriverAgent(opts) {
|
|
1370
1375
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1371
|
-
const
|
|
1376
|
+
const overrideModule = opts?.iOSDeviceClassOverride?.trim() || opts?.iosDeviceClassOverride?.trim() || process.env[env_namespaceObject.MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE]?.trim();
|
|
1377
|
+
let DeviceClass = IOSDevice;
|
|
1378
|
+
if (overrideModule) try {
|
|
1379
|
+
const overrideExports = await import(overrideModule);
|
|
1380
|
+
const overrideDeviceClass = Object.prototype.hasOwnProperty.call(overrideExports, 'IOSDevice') ? overrideExports.IOSDevice : overrideExports.default;
|
|
1381
|
+
if ('function' != typeof overrideDeviceClass) throw new Error(`Module "${overrideModule}" does not export a valid iOS device class (expected "IOSDevice" or default export).`);
|
|
1382
|
+
DeviceClass = overrideDeviceClass;
|
|
1383
|
+
} catch (error) {
|
|
1384
|
+
throw new Error(`Failed to load iOS device class override from "${overrideModule}". Please make sure the package is installed and exports IOSDevice (or default) with Midscene-compatible methods. Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
1385
|
+
}
|
|
1386
|
+
const device = new DeviceClass(opts || {});
|
|
1372
1387
|
await device.connect();
|
|
1373
1388
|
return new IOSAgent(device, opts);
|
|
1374
1389
|
}
|
|
@@ -1473,7 +1488,6 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
|
|
|
1473
1488
|
}), mcp_tools_define_property(this, "lastOptsSignature", void 0);
|
|
1474
1489
|
}
|
|
1475
1490
|
}
|
|
1476
|
-
const env_namespaceObject = require("@midscene/shared/env");
|
|
1477
1491
|
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
1478
1492
|
const external_node_os_namespaceObject = require("node:os");
|
|
1479
1493
|
const external_node_util_namespaceObject = require("node:util");
|
|
@@ -1565,14 +1579,10 @@ const iosPlaygroundPlatform = (0, playground_namespaceObject.definePlaygroundPla
|
|
|
1565
1579
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
1566
1580
|
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? constants_namespaceObject.DEFAULT_WDA_PORT), 10);
|
|
1567
1581
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
1568
|
-
const connectAgent = async ()=>{
|
|
1569
|
-
const newDevice = new IOSDevice({
|
|
1582
|
+
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
1570
1583
|
wdaHost: host,
|
|
1571
1584
|
wdaPort: port
|
|
1572
1585
|
});
|
|
1573
|
-
await newDevice.connect();
|
|
1574
|
-
return new IOSAgent(newDevice);
|
|
1575
|
-
};
|
|
1576
1586
|
const agent = await connectAgent();
|
|
1577
1587
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
1578
1588
|
const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : `${host}:${port}`;
|
package/dist/lib/mcp-server.js
CHANGED
|
@@ -39,6 +39,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
39
39
|
});
|
|
40
40
|
const mcp_namespaceObject = require("@midscene/shared/mcp");
|
|
41
41
|
const agent_namespaceObject = require("@midscene/core/agent");
|
|
42
|
+
const env_namespaceObject = require("@midscene/shared/env");
|
|
42
43
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
43
44
|
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
44
45
|
const defaultAppNameMapping = {
|
|
@@ -1305,6 +1306,8 @@ const createPlatformActions = (device)=>({
|
|
|
1305
1306
|
sample: {
|
|
1306
1307
|
uri: 'com.apple.Preferences'
|
|
1307
1308
|
},
|
|
1309
|
+
delayBeforeRunner: 0,
|
|
1310
|
+
delayAfterRunner: 0,
|
|
1308
1311
|
call: async (param)=>{
|
|
1309
1312
|
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1310
1313
|
await device.terminate(param.uri);
|
|
@@ -1313,6 +1316,8 @@ const createPlatformActions = (device)=>({
|
|
|
1313
1316
|
IOSHomeButton: (0, device_namespaceObject.defineAction)({
|
|
1314
1317
|
name: 'IOSHomeButton',
|
|
1315
1318
|
description: 'Trigger the system "home" operation on iOS devices',
|
|
1319
|
+
delayBeforeRunner: 0,
|
|
1320
|
+
delayAfterRunner: 0,
|
|
1316
1321
|
call: async ()=>{
|
|
1317
1322
|
await device.home();
|
|
1318
1323
|
}
|
|
@@ -1364,7 +1369,17 @@ class IOSAgent extends agent_namespaceObject.Agent {
|
|
|
1364
1369
|
}
|
|
1365
1370
|
async function agentFromWebDriverAgent(opts) {
|
|
1366
1371
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1367
|
-
const
|
|
1372
|
+
const overrideModule = opts?.iOSDeviceClassOverride?.trim() || opts?.iosDeviceClassOverride?.trim() || process.env[env_namespaceObject.MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE]?.trim();
|
|
1373
|
+
let DeviceClass = IOSDevice;
|
|
1374
|
+
if (overrideModule) try {
|
|
1375
|
+
const overrideExports = await import(overrideModule);
|
|
1376
|
+
const overrideDeviceClass = Object.prototype.hasOwnProperty.call(overrideExports, 'IOSDevice') ? overrideExports.IOSDevice : overrideExports.default;
|
|
1377
|
+
if ('function' != typeof overrideDeviceClass) throw new Error(`Module "${overrideModule}" does not export a valid iOS device class (expected "IOSDevice" or default export).`);
|
|
1378
|
+
DeviceClass = overrideDeviceClass;
|
|
1379
|
+
} catch (error) {
|
|
1380
|
+
throw new Error(`Failed to load iOS device class override from "${overrideModule}". Please make sure the package is installed and exports IOSDevice (or default) with Midscene-compatible methods. Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
1381
|
+
}
|
|
1382
|
+
const device = new DeviceClass(opts || {});
|
|
1368
1383
|
await device.connect();
|
|
1369
1384
|
return new IOSAgent(device, opts);
|
|
1370
1385
|
}
|
|
@@ -1476,7 +1491,7 @@ class IOSMCPServer extends mcp_namespaceObject.BaseMCPServer {
|
|
|
1476
1491
|
constructor(toolsManager){
|
|
1477
1492
|
super({
|
|
1478
1493
|
name: '@midscene/ios-mcp',
|
|
1479
|
-
version: "1.7.
|
|
1494
|
+
version: "1.7.7-beta-20260428092036.0",
|
|
1480
1495
|
description: 'Control the iOS device using natural language commands'
|
|
1481
1496
|
}, toolsManager);
|
|
1482
1497
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/ios",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.7-beta-20260428092036.0",
|
|
4
4
|
"description": "iOS automation library for Midscene",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"iOS UI automation",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@inquirer/prompts": "^7.8.6",
|
|
45
45
|
"open": "10.1.0",
|
|
46
|
-
"@midscene/core": "1.7.
|
|
47
|
-
"@midscene/
|
|
48
|
-
"@midscene/
|
|
49
|
-
"@midscene/playground": "1.7.
|
|
46
|
+
"@midscene/core": "1.7.7-beta-20260428092036.0",
|
|
47
|
+
"@midscene/shared": "1.7.7-beta-20260428092036.0",
|
|
48
|
+
"@midscene/webdriver": "1.7.7-beta-20260428092036.0",
|
|
49
|
+
"@midscene/playground": "1.7.7-beta-20260428092036.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@rslib/core": "^0.18.3",
|
package/static/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.7b1abe58.js"></script><script defer src="/static/js/883.516361ae.js"></script><script defer src="/static/js/index.
|
|
1
|
+
<!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.7b1abe58.js"></script><script defer src="/static/js/883.516361ae.js"></script><script defer src="/static/js/index.c01e1ead.js"></script><link href="/static/css/index.a02873b3.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
|