@midscene/ios 1.7.7-beta-20260430031647.0 → 1.7.9
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 +20 -7
- package/dist/es/cli.mjs +13 -2
- package/dist/es/index.mjs +13 -7
- package/dist/es/mcp-server.mjs +13 -2
- package/dist/lib/bin.js +20 -7
- package/dist/lib/cli.js +13 -2
- package/dist/lib/index.js +13 -7
- package/dist/lib/mcp-server.js +13 -2
- package/package.json +5 -5
- package/static/index.html +1 -1
- package/static/static/js/{index.6e9d4950.js → index.5bb455e1.js} +6 -6
- package/static/static/js/{index.6e9d4950.js.map → index.5bb455e1.js.map} +1 -1
- /package/static/static/js/{index.6e9d4950.js.LICENSE.txt → index.5bb455e1.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)=>{
|
|
@@ -1301,7 +1302,7 @@ function agent_define_property(obj, key, value) {
|
|
|
1301
1302
|
else obj[key] = value;
|
|
1302
1303
|
return obj;
|
|
1303
1304
|
}
|
|
1304
|
-
getDebug('ios:agent');
|
|
1305
|
+
const debugAgent = getDebug('ios:agent');
|
|
1305
1306
|
class IOSAgent extends Agent {
|
|
1306
1307
|
async launch(uri) {
|
|
1307
1308
|
const action = this.wrapActionInActionSpace('Launch');
|
|
@@ -1328,6 +1329,22 @@ class IOSAgent extends Agent {
|
|
|
1328
1329
|
this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
|
|
1329
1330
|
}
|
|
1330
1331
|
}
|
|
1332
|
+
async function agentFromWebDriverAgent(opts) {
|
|
1333
|
+
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1334
|
+
const overrideModule = 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
|
+
}
|
|
1331
1348
|
const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
1332
1349
|
id: 'ios',
|
|
1333
1350
|
title: 'Midscene iOS Playground',
|
|
@@ -1366,14 +1383,10 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
|
1366
1383
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
1367
1384
|
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? DEFAULT_WDA_PORT), 10);
|
|
1368
1385
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
1369
|
-
const connectAgent = async ()=>{
|
|
1370
|
-
const newDevice = new device_IOSDevice({
|
|
1386
|
+
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
1371
1387
|
wdaHost: host,
|
|
1372
1388
|
wdaPort: port
|
|
1373
1389
|
});
|
|
1374
|
-
await newDevice.connect();
|
|
1375
|
-
return new IOSAgent(newDevice);
|
|
1376
|
-
};
|
|
1377
1390
|
const agent = await connectAgent();
|
|
1378
1391
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
1379
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";
|
|
@@ -1329,7 +1330,17 @@ class IOSAgent extends Agent {
|
|
|
1329
1330
|
}
|
|
1330
1331
|
async function agentFromWebDriverAgent(opts) {
|
|
1331
1332
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1332
|
-
const
|
|
1333
|
+
const overrideModule = 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 || {});
|
|
1333
1344
|
await device.connect();
|
|
1334
1345
|
return new IOSAgent(device, opts);
|
|
1335
1346
|
}
|
|
@@ -1436,7 +1447,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
|
|
|
1436
1447
|
const tools = new IOSMidsceneTools();
|
|
1437
1448
|
runToolsCLI(tools, 'midscene-ios', {
|
|
1438
1449
|
stripPrefix: 'ios_',
|
|
1439
|
-
version: "1.7.
|
|
1450
|
+
version: "1.7.9",
|
|
1440
1451
|
extraCommands: createReportCliCommands()
|
|
1441
1452
|
}).catch((e)=>{
|
|
1442
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";
|
|
@@ -1335,7 +1335,17 @@ class IOSAgent extends Agent {
|
|
|
1335
1335
|
}
|
|
1336
1336
|
async function agentFromWebDriverAgent(opts) {
|
|
1337
1337
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1338
|
-
const
|
|
1338
|
+
const overrideModule = 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 || {});
|
|
1339
1349
|
await device.connect();
|
|
1340
1350
|
return new IOSAgent(device, opts);
|
|
1341
1351
|
}
|
|
@@ -1523,14 +1533,10 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
|
|
|
1523
1533
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
1524
1534
|
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? DEFAULT_WDA_PORT), 10);
|
|
1525
1535
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
1526
|
-
const connectAgent = async ()=>{
|
|
1527
|
-
const newDevice = new IOSDevice({
|
|
1536
|
+
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
1528
1537
|
wdaHost: host,
|
|
1529
1538
|
wdaPort: port
|
|
1530
1539
|
});
|
|
1531
|
-
await newDevice.connect();
|
|
1532
|
-
return new IOSAgent(newDevice);
|
|
1533
|
-
};
|
|
1534
1540
|
const agent = await connectAgent();
|
|
1535
1541
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
1536
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";
|
|
@@ -1329,7 +1330,17 @@ class IOSAgent extends Agent {
|
|
|
1329
1330
|
}
|
|
1330
1331
|
async function agentFromWebDriverAgent(opts) {
|
|
1331
1332
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1332
|
-
const
|
|
1333
|
+
const overrideModule = 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 || {});
|
|
1333
1344
|
await device.connect();
|
|
1334
1345
|
return new IOSAgent(device, opts);
|
|
1335
1346
|
}
|
|
@@ -1440,7 +1451,7 @@ class IOSMCPServer extends BaseMCPServer {
|
|
|
1440
1451
|
constructor(toolsManager){
|
|
1441
1452
|
super({
|
|
1442
1453
|
name: '@midscene/ios-mcp',
|
|
1443
|
-
version: "1.7.
|
|
1454
|
+
version: "1.7.9",
|
|
1444
1455
|
description: 'Control the iOS device using natural language commands'
|
|
1445
1456
|
}, toolsManager);
|
|
1446
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)=>{
|
|
@@ -1326,7 +1327,7 @@ function agent_define_property(obj, key, value) {
|
|
|
1326
1327
|
else obj[key] = value;
|
|
1327
1328
|
return obj;
|
|
1328
1329
|
}
|
|
1329
|
-
(0, logger_namespaceObject.getDebug)('ios:agent');
|
|
1330
|
+
const debugAgent = (0, logger_namespaceObject.getDebug)('ios:agent');
|
|
1330
1331
|
class IOSAgent extends agent_namespaceObject.Agent {
|
|
1331
1332
|
async launch(uri) {
|
|
1332
1333
|
const action = this.wrapActionInActionSpace('Launch');
|
|
@@ -1353,6 +1354,22 @@ class IOSAgent extends agent_namespaceObject.Agent {
|
|
|
1353
1354
|
this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
|
|
1354
1355
|
}
|
|
1355
1356
|
}
|
|
1357
|
+
async function agentFromWebDriverAgent(opts) {
|
|
1358
|
+
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1359
|
+
const overrideModule = 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
|
+
}
|
|
1356
1373
|
const iosPlaygroundPlatform = (0, playground_namespaceObject.definePlaygroundPlatform)({
|
|
1357
1374
|
id: 'ios',
|
|
1358
1375
|
title: 'Midscene iOS Playground',
|
|
@@ -1391,14 +1408,10 @@ const iosPlaygroundPlatform = (0, playground_namespaceObject.definePlaygroundPla
|
|
|
1391
1408
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
1392
1409
|
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? constants_namespaceObject.DEFAULT_WDA_PORT), 10);
|
|
1393
1410
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
1394
|
-
const connectAgent = async ()=>{
|
|
1395
|
-
const newDevice = new device_IOSDevice({
|
|
1411
|
+
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
1396
1412
|
wdaHost: host,
|
|
1397
1413
|
wdaPort: port
|
|
1398
1414
|
});
|
|
1399
|
-
await newDevice.connect();
|
|
1400
|
-
return new IOSAgent(newDevice);
|
|
1401
|
-
};
|
|
1402
1415
|
const agent = await connectAgent();
|
|
1403
1416
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
1404
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',
|
|
@@ -1353,7 +1354,17 @@ class IOSAgent extends agent_namespaceObject.Agent {
|
|
|
1353
1354
|
}
|
|
1354
1355
|
async function agentFromWebDriverAgent(opts) {
|
|
1355
1356
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1356
|
-
const
|
|
1357
|
+
const overrideModule = 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 || {});
|
|
1357
1368
|
await device.connect();
|
|
1358
1369
|
return new IOSAgent(device, opts);
|
|
1359
1370
|
}
|
|
@@ -1460,7 +1471,7 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
|
|
|
1460
1471
|
const tools = new IOSMidsceneTools();
|
|
1461
1472
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-ios', {
|
|
1462
1473
|
stripPrefix: 'ios_',
|
|
1463
|
-
version: "1.7.
|
|
1474
|
+
version: "1.7.9",
|
|
1464
1475
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
1465
1476
|
}).catch((e)=>{
|
|
1466
1477
|
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|
package/dist/lib/index.js
CHANGED
|
@@ -1149,6 +1149,7 @@ const createPlatformActions = (device)=>({
|
|
|
1149
1149
|
})
|
|
1150
1150
|
});
|
|
1151
1151
|
const agent_namespaceObject = require("@midscene/core/agent");
|
|
1152
|
+
const env_namespaceObject = require("@midscene/shared/env");
|
|
1152
1153
|
const defaultAppNameMapping = {
|
|
1153
1154
|
微信: 'com.tencent.xin',
|
|
1154
1155
|
企业微信: 'com.tencent.ww',
|
|
@@ -1372,7 +1373,17 @@ class IOSAgent extends agent_namespaceObject.Agent {
|
|
|
1372
1373
|
}
|
|
1373
1374
|
async function agentFromWebDriverAgent(opts) {
|
|
1374
1375
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1375
|
-
const
|
|
1376
|
+
const overrideModule = 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 || {});
|
|
1376
1387
|
await device.connect();
|
|
1377
1388
|
return new IOSAgent(device, opts);
|
|
1378
1389
|
}
|
|
@@ -1477,7 +1488,6 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
|
|
|
1477
1488
|
}), mcp_tools_define_property(this, "lastOptsSignature", void 0);
|
|
1478
1489
|
}
|
|
1479
1490
|
}
|
|
1480
|
-
const env_namespaceObject = require("@midscene/shared/env");
|
|
1481
1491
|
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
1482
1492
|
const external_node_os_namespaceObject = require("node:os");
|
|
1483
1493
|
const external_node_util_namespaceObject = require("node:util");
|
|
@@ -1569,14 +1579,10 @@ const iosPlaygroundPlatform = (0, playground_namespaceObject.definePlaygroundPla
|
|
|
1569
1579
|
const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
|
|
1570
1580
|
const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? constants_namespaceObject.DEFAULT_WDA_PORT), 10);
|
|
1571
1581
|
if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
|
|
1572
|
-
const connectAgent = async ()=>{
|
|
1573
|
-
const newDevice = new IOSDevice({
|
|
1582
|
+
const connectAgent = async ()=>agentFromWebDriverAgent({
|
|
1574
1583
|
wdaHost: host,
|
|
1575
1584
|
wdaPort: port
|
|
1576
1585
|
});
|
|
1577
|
-
await newDevice.connect();
|
|
1578
|
-
return new IOSAgent(newDevice);
|
|
1579
|
-
};
|
|
1580
1586
|
const agent = await connectAgent();
|
|
1581
1587
|
const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
|
|
1582
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 = {
|
|
@@ -1368,7 +1369,17 @@ class IOSAgent extends agent_namespaceObject.Agent {
|
|
|
1368
1369
|
}
|
|
1369
1370
|
async function agentFromWebDriverAgent(opts) {
|
|
1370
1371
|
debugAgent('Creating iOS agent with WebDriverAgent');
|
|
1371
|
-
const
|
|
1372
|
+
const overrideModule = 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 || {});
|
|
1372
1383
|
await device.connect();
|
|
1373
1384
|
return new IOSAgent(device, opts);
|
|
1374
1385
|
}
|
|
@@ -1480,7 +1491,7 @@ class IOSMCPServer extends mcp_namespaceObject.BaseMCPServer {
|
|
|
1480
1491
|
constructor(toolsManager){
|
|
1481
1492
|
super({
|
|
1482
1493
|
name: '@midscene/ios-mcp',
|
|
1483
|
-
version: "1.7.
|
|
1494
|
+
version: "1.7.9",
|
|
1484
1495
|
description: 'Control the iOS device using natural language commands'
|
|
1485
1496
|
}, toolsManager);
|
|
1486
1497
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/ios",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
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/
|
|
47
|
-
"@midscene/
|
|
48
|
-
"@midscene/
|
|
49
|
-
"@midscene/playground": "1.7.
|
|
46
|
+
"@midscene/core": "1.7.9",
|
|
47
|
+
"@midscene/shared": "1.7.9",
|
|
48
|
+
"@midscene/webdriver": "1.7.9",
|
|
49
|
+
"@midscene/playground": "1.7.9"
|
|
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/382.f480feba.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/382.f480feba.js"></script><script defer src="/static/js/index.5bb455e1.js"></script><link href="/static/css/index.0c9d926c.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
|