@midscene/ios 1.6.0 → 1.6.1-beta-20260327104111.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 CHANGED
@@ -1,6 +1,5 @@
1
1
  import node_path from "node:path";
2
2
  import { createMjpegPreviewDescriptor, definePlaygroundPlatform, launchPreparedPlaygroundPlatform } from "@midscene/playground";
3
- import { input, select as prompts_select } from "@inquirer/prompts";
4
3
  import { DEFAULT_WDA_PORT, PLAYGROUND_SERVER_PORT } from "@midscene/shared/constants";
5
4
  import { findAvailablePort } from "@midscene/shared/node";
6
5
  import { Agent } from "@midscene/core/agent";
@@ -1316,134 +1315,76 @@ class IOSAgent extends Agent {
1316
1315
  this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
1317
1316
  }
1318
1317
  }
1319
- async function configureWebDriverAgent() {
1320
- console.log('🔧 WebDriverAgent Configuration');
1321
- console.log(`Default: localhost:${DEFAULT_WDA_PORT}`);
1322
- const useDefault = await prompts_select({
1323
- message: `Use default WebDriverAgent address (localhost:${DEFAULT_WDA_PORT})?`,
1324
- choices: [
1325
- {
1326
- name: `Yes, use localhost:${DEFAULT_WDA_PORT}`,
1327
- value: true
1328
- },
1329
- {
1330
- name: 'No, specify custom address',
1331
- value: false
1332
- }
1333
- ]
1334
- });
1335
- if (useDefault) return {
1336
- host: 'localhost',
1337
- port: DEFAULT_WDA_PORT
1338
- };
1339
- const hostInput = await input({
1340
- message: 'WebDriverAgent host:',
1341
- default: 'localhost'
1342
- });
1343
- const host = hostInput.replace(/^https?:\/\//, '');
1344
- const portInput = await input({
1345
- message: 'WebDriverAgent port:',
1346
- default: DEFAULT_WDA_PORT.toString()
1347
- });
1348
- const port = Number.parseInt(portInput, 10);
1349
- if (Number.isNaN(port) || port < 1 || port > 65535) {
1350
- console.error(`❌ Invalid port number. Using default ${DEFAULT_WDA_PORT}.`);
1351
- return {
1352
- host,
1353
- port: DEFAULT_WDA_PORT
1354
- };
1355
- }
1356
- return {
1357
- host,
1358
- port
1359
- };
1360
- }
1361
1318
  const iosPlaygroundPlatform = definePlaygroundPlatform({
1362
1319
  id: 'ios',
1363
1320
  title: 'Midscene iOS Playground',
1364
1321
  description: "iOS playground platform descriptor",
1365
1322
  async prepare (options) {
1366
1323
  const staticDir = options?.staticDir || node_path.join(__dirname, '../../static');
1367
- let wdaConfig = {
1368
- host: options?.host || 'localhost',
1369
- port: options?.port || DEFAULT_WDA_PORT
1370
- };
1371
- let connected = false;
1372
- while(!connected)try {
1373
- const device = new device_IOSDevice({
1374
- wdaHost: wdaConfig.host,
1375
- wdaPort: wdaConfig.port
1376
- });
1377
- console.log(`🔌 Connecting to WebDriverAgent at ${wdaConfig.host}:${wdaConfig.port}...`);
1378
- await device.connect();
1379
- connected = true;
1380
- const deviceInfo = await device.getConnectedDeviceInfo();
1381
- console.log('✅ Connected to WebDriverAgent successfully!');
1382
- if (deviceInfo) {
1383
- console.log(`📱 Connected to: ${deviceInfo.name} (${deviceInfo.model})`);
1384
- console.log(`🔑 Device UDID: ${deviceInfo.udid}`);
1385
- }
1386
- } catch (error) {
1387
- console.error(`❌ Failed to connect to WebDriverAgent: ${error instanceof Error ? error.message : String(error)}`);
1388
- const action = await prompts_select({
1389
- message: 'What would you like to do?',
1390
- choices: [
1391
- {
1392
- name: '🔧 Configure different WebDriverAgent address',
1393
- value: 'configure'
1394
- },
1395
- {
1396
- name: '📖 Show setup instructions',
1397
- value: 'instructions'
1398
- },
1399
- {
1400
- name: '🚪 Exit',
1401
- value: 'exit'
1402
- }
1403
- ]
1404
- });
1405
- if ('exit' === action) {
1406
- console.log('👋 Goodbye!');
1407
- process.exit(0);
1408
- }
1409
- if ('instructions' === action) {
1410
- console.log(`
1411
- 🔧 WebDriverAgent Setup Instructions:
1412
-
1413
- 1. Install WebDriverAgent:
1414
- npm install appium-webdriveragent
1415
-
1416
- 2. Open WebDriverAgent project in Xcode:
1417
- node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj
1418
-
1419
- 3. Select your target device/simulator in Xcode
1420
-
1421
- 4. Build and run the WebDriverAgentRunner scheme
1422
-
1423
- 5. WebDriverAgent will bind to your selected device and listen on port ${DEFAULT_WDA_PORT}
1424
-
1425
- 6. Restart this playground to connect
1426
-
1427
- 💡 The WebDriverAgent service is already bound to the device you selected in Xcode.
1428
- 💡 For more details, visit: https://github.com/appium/WebDriverAgent
1429
- `);
1430
- continue;
1431
- }
1432
- wdaConfig = await configureWebDriverAgent();
1433
- }
1434
1324
  const availablePlaygroundPort = await findAvailablePort(PLAYGROUND_SERVER_PORT);
1435
1325
  if (availablePlaygroundPort !== PLAYGROUND_SERVER_PORT) console.log(`⚠️ Port ${PLAYGROUND_SERVER_PORT} is busy, using port ${availablePlaygroundPort} instead`);
1326
+ const sessionManager = {
1327
+ async getSetupSchema () {
1328
+ return {
1329
+ title: 'Connect WebDriverAgent',
1330
+ description: 'Provide the WebDriverAgent host and port that are already running for your selected iPhone or simulator.',
1331
+ primaryActionLabel: 'Create Agent',
1332
+ fields: [
1333
+ {
1334
+ key: 'host',
1335
+ label: 'WebDriverAgent host',
1336
+ type: 'text',
1337
+ required: true,
1338
+ defaultValue: 'localhost',
1339
+ placeholder: 'localhost'
1340
+ },
1341
+ {
1342
+ key: 'port',
1343
+ label: 'WebDriverAgent port',
1344
+ type: 'number',
1345
+ required: true,
1346
+ defaultValue: DEFAULT_WDA_PORT,
1347
+ placeholder: DEFAULT_WDA_PORT.toString()
1348
+ }
1349
+ ]
1350
+ };
1351
+ },
1352
+ async createSession (input) {
1353
+ const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
1354
+ const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? DEFAULT_WDA_PORT), 10);
1355
+ if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
1356
+ const connectAgent = async ()=>{
1357
+ const newDevice = new device_IOSDevice({
1358
+ wdaHost: host,
1359
+ wdaPort: port
1360
+ });
1361
+ await newDevice.connect();
1362
+ return new IOSAgent(newDevice);
1363
+ };
1364
+ const agent = await connectAgent();
1365
+ const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
1366
+ const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : `${host}:${port}`;
1367
+ return {
1368
+ agent,
1369
+ agentFactory: connectAgent,
1370
+ preview: createMjpegPreviewDescriptor({
1371
+ title: 'iOS device preview'
1372
+ }),
1373
+ displayName,
1374
+ metadata: {
1375
+ wdaHost: host,
1376
+ wdaPort: port,
1377
+ ...deviceInfo ? {
1378
+ deviceInfo
1379
+ } : {}
1380
+ }
1381
+ };
1382
+ }
1383
+ };
1436
1384
  return {
1437
1385
  platformId: 'ios',
1438
1386
  title: 'Midscene iOS Playground',
1439
- agentFactory: async ()=>{
1440
- const newDevice = new device_IOSDevice({
1441
- wdaHost: wdaConfig.host,
1442
- wdaPort: wdaConfig.port
1443
- });
1444
- await newDevice.connect();
1445
- return new IOSAgent(newDevice);
1446
- },
1387
+ sessionManager,
1447
1388
  launchOptions: {
1448
1389
  port: availablePlaygroundPort,
1449
1390
  openBrowser: false,
@@ -1454,8 +1395,8 @@ const iosPlaygroundPlatform = definePlaygroundPlatform({
1454
1395
  title: 'iOS device preview'
1455
1396
  }),
1456
1397
  metadata: {
1457
- wdaHost: wdaConfig.host,
1458
- wdaPort: wdaConfig.port
1398
+ sessionConnected: false,
1399
+ setupState: 'required'
1459
1400
  }
1460
1401
  };
1461
1402
  }
@@ -1469,13 +1410,9 @@ const main = async ()=>{
1469
1410
  staticDir: bin_staticDir
1470
1411
  });
1471
1412
  const { server: playgroundServer } = await launchPreparedPlaygroundPlatform(prepared);
1472
- const wdaHost = String(prepared.metadata?.wdaHost ?? 'localhost');
1473
- const wdaPort = String(prepared.metadata?.wdaPort ?? '');
1474
1413
  console.log('');
1475
1414
  console.log('✨ Midscene iOS Playground is ready!');
1476
1415
  console.log(`🎮 Playground: http://localhost:${playgroundServer.port}`);
1477
- console.log('📱 Device: WebDriverAgent Connected');
1478
- console.log(`🔧 WebDriverAgent: ${wdaHost}:${wdaPort}`);
1479
1416
  console.log(`🔑 Generated Server ID: ${playgroundServer.id}`);
1480
1417
  console.log('');
1481
1418
  open(`http://localhost:${playgroundServer.port}`);
package/dist/es/cli.mjs CHANGED
@@ -1366,7 +1366,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
1366
1366
  const tools = new IOSMidsceneTools();
1367
1367
  runToolsCLI(tools, 'midscene-ios', {
1368
1368
  stripPrefix: 'ios_',
1369
- version: "1.6.0"
1369
+ version: "1.6.1-beta-20260327104111.0"
1370
1370
  }).catch((e)=>{
1371
1371
  if (!(e instanceof CLIError)) console.error(e);
1372
1372
  process.exit(e instanceof CLIError ? e.exitCode : 1);
package/dist/es/index.mjs CHANGED
@@ -2,7 +2,7 @@ import node_assert from "node:assert";
2
2
  import { getMidsceneLocationSchema, z } from "@midscene/core";
3
3
  import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionPinch, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam, normalizePinchParam } from "@midscene/core/device";
4
4
  import { sleep } from "@midscene/core/utils";
5
- import { DEFAULT_WDA_PORT } from "@midscene/shared/constants";
5
+ import { DEFAULT_WDA_PORT, PLAYGROUND_SERVER_PORT } from "@midscene/shared/constants";
6
6
  import { createImgBase64ByFormat } from "@midscene/shared/img";
7
7
  import { getDebug } from "@midscene/shared/logger";
8
8
  import { mergeAndNormalizeAppNameMapping, normalizeForComparison } from "@midscene/shared/utils";
@@ -13,6 +13,9 @@ 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";
16
+ import node_path from "node:path";
17
+ import { createMjpegPreviewDescriptor, definePlaygroundPlatform } from "@midscene/playground";
18
+ import { findAvailablePort } from "@midscene/shared/node";
16
19
  const debugIOS = getDebug('webdriver:ios');
17
20
  const WDA_MJPEG_SCREENSHOT_QUALITY = 50;
18
21
  const WDA_MJPEG_FRAMERATE = 30;
@@ -1412,4 +1415,90 @@ async function checkIOSEnvironment() {
1412
1415
  };
1413
1416
  }
1414
1417
  }
1415
- export { IOSAgent, IOSDevice, IOSMidsceneTools, IOSWebDriverClient, agentFromWebDriverAgent, checkIOSEnvironment, overrideAIConfig };
1418
+ const iosPlaygroundPlatform = definePlaygroundPlatform({
1419
+ id: 'ios',
1420
+ title: 'Midscene iOS Playground',
1421
+ description: "iOS playground platform descriptor",
1422
+ async prepare (options) {
1423
+ const staticDir = options?.staticDir || node_path.join(__dirname, '../../static');
1424
+ const availablePlaygroundPort = await findAvailablePort(PLAYGROUND_SERVER_PORT);
1425
+ if (availablePlaygroundPort !== PLAYGROUND_SERVER_PORT) console.log(`⚠️ Port ${PLAYGROUND_SERVER_PORT} is busy, using port ${availablePlaygroundPort} instead`);
1426
+ const sessionManager = {
1427
+ async getSetupSchema () {
1428
+ return {
1429
+ title: 'Connect WebDriverAgent',
1430
+ description: 'Provide the WebDriverAgent host and port that are already running for your selected iPhone or simulator.',
1431
+ primaryActionLabel: 'Create Agent',
1432
+ fields: [
1433
+ {
1434
+ key: 'host',
1435
+ label: 'WebDriverAgent host',
1436
+ type: 'text',
1437
+ required: true,
1438
+ defaultValue: 'localhost',
1439
+ placeholder: 'localhost'
1440
+ },
1441
+ {
1442
+ key: 'port',
1443
+ label: 'WebDriverAgent port',
1444
+ type: 'number',
1445
+ required: true,
1446
+ defaultValue: DEFAULT_WDA_PORT,
1447
+ placeholder: DEFAULT_WDA_PORT.toString()
1448
+ }
1449
+ ]
1450
+ };
1451
+ },
1452
+ async createSession (input) {
1453
+ const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
1454
+ const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? DEFAULT_WDA_PORT), 10);
1455
+ if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
1456
+ const connectAgent = async ()=>{
1457
+ const newDevice = new IOSDevice({
1458
+ wdaHost: host,
1459
+ wdaPort: port
1460
+ });
1461
+ await newDevice.connect();
1462
+ return new IOSAgent(newDevice);
1463
+ };
1464
+ const agent = await connectAgent();
1465
+ const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
1466
+ const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : `${host}:${port}`;
1467
+ return {
1468
+ agent,
1469
+ agentFactory: connectAgent,
1470
+ preview: createMjpegPreviewDescriptor({
1471
+ title: 'iOS device preview'
1472
+ }),
1473
+ displayName,
1474
+ metadata: {
1475
+ wdaHost: host,
1476
+ wdaPort: port,
1477
+ ...deviceInfo ? {
1478
+ deviceInfo
1479
+ } : {}
1480
+ }
1481
+ };
1482
+ }
1483
+ };
1484
+ return {
1485
+ platformId: 'ios',
1486
+ title: 'Midscene iOS Playground',
1487
+ sessionManager,
1488
+ launchOptions: {
1489
+ port: availablePlaygroundPort,
1490
+ openBrowser: false,
1491
+ verbose: false,
1492
+ staticPath: staticDir
1493
+ },
1494
+ preview: createMjpegPreviewDescriptor({
1495
+ title: 'iOS device preview'
1496
+ }),
1497
+ metadata: {
1498
+ sessionConnected: false,
1499
+ setupState: 'required'
1500
+ }
1501
+ };
1502
+ }
1503
+ });
1504
+ export { IOSAgent, IOSDevice, IOSMidsceneTools, IOSWebDriverClient, agentFromWebDriverAgent, checkIOSEnvironment, iosPlaygroundPlatform, overrideAIConfig };
@@ -1369,7 +1369,7 @@ class IOSMCPServer extends BaseMCPServer {
1369
1369
  constructor(toolsManager){
1370
1370
  super({
1371
1371
  name: '@midscene/ios-mcp',
1372
- version: "1.6.0",
1372
+ version: "1.6.1-beta-20260327104111.0",
1373
1373
  description: 'Control the iOS device using natural language commands'
1374
1374
  }, toolsManager);
1375
1375
  }
package/dist/lib/bin.js CHANGED
@@ -24,7 +24,6 @@ var __webpack_exports__ = {};
24
24
  const external_node_path_namespaceObject = require("node:path");
25
25
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
26
26
  const playground_namespaceObject = require("@midscene/playground");
27
- const prompts_namespaceObject = require("@inquirer/prompts");
28
27
  const constants_namespaceObject = require("@midscene/shared/constants");
29
28
  const node_namespaceObject = require("@midscene/shared/node");
30
29
  const agent_namespaceObject = require("@midscene/core/agent");
@@ -1341,134 +1340,76 @@ class IOSAgent extends agent_namespaceObject.Agent {
1341
1340
  this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
1342
1341
  }
1343
1342
  }
1344
- async function configureWebDriverAgent() {
1345
- console.log('🔧 WebDriverAgent Configuration');
1346
- console.log(`Default: localhost:${constants_namespaceObject.DEFAULT_WDA_PORT}`);
1347
- const useDefault = await (0, prompts_namespaceObject.select)({
1348
- message: `Use default WebDriverAgent address (localhost:${constants_namespaceObject.DEFAULT_WDA_PORT})?`,
1349
- choices: [
1350
- {
1351
- name: `Yes, use localhost:${constants_namespaceObject.DEFAULT_WDA_PORT}`,
1352
- value: true
1353
- },
1354
- {
1355
- name: 'No, specify custom address',
1356
- value: false
1357
- }
1358
- ]
1359
- });
1360
- if (useDefault) return {
1361
- host: 'localhost',
1362
- port: constants_namespaceObject.DEFAULT_WDA_PORT
1363
- };
1364
- const hostInput = await (0, prompts_namespaceObject.input)({
1365
- message: 'WebDriverAgent host:',
1366
- default: 'localhost'
1367
- });
1368
- const host = hostInput.replace(/^https?:\/\//, '');
1369
- const portInput = await (0, prompts_namespaceObject.input)({
1370
- message: 'WebDriverAgent port:',
1371
- default: constants_namespaceObject.DEFAULT_WDA_PORT.toString()
1372
- });
1373
- const port = Number.parseInt(portInput, 10);
1374
- if (Number.isNaN(port) || port < 1 || port > 65535) {
1375
- console.error(`❌ Invalid port number. Using default ${constants_namespaceObject.DEFAULT_WDA_PORT}.`);
1376
- return {
1377
- host,
1378
- port: constants_namespaceObject.DEFAULT_WDA_PORT
1379
- };
1380
- }
1381
- return {
1382
- host,
1383
- port
1384
- };
1385
- }
1386
1343
  const iosPlaygroundPlatform = (0, playground_namespaceObject.definePlaygroundPlatform)({
1387
1344
  id: 'ios',
1388
1345
  title: 'Midscene iOS Playground',
1389
1346
  description: "iOS playground platform descriptor",
1390
1347
  async prepare (options) {
1391
1348
  const staticDir = options?.staticDir || external_node_path_default().join(__dirname, '../../static');
1392
- let wdaConfig = {
1393
- host: options?.host || 'localhost',
1394
- port: options?.port || constants_namespaceObject.DEFAULT_WDA_PORT
1395
- };
1396
- let connected = false;
1397
- while(!connected)try {
1398
- const device = new device_IOSDevice({
1399
- wdaHost: wdaConfig.host,
1400
- wdaPort: wdaConfig.port
1401
- });
1402
- console.log(`🔌 Connecting to WebDriverAgent at ${wdaConfig.host}:${wdaConfig.port}...`);
1403
- await device.connect();
1404
- connected = true;
1405
- const deviceInfo = await device.getConnectedDeviceInfo();
1406
- console.log('✅ Connected to WebDriverAgent successfully!');
1407
- if (deviceInfo) {
1408
- console.log(`📱 Connected to: ${deviceInfo.name} (${deviceInfo.model})`);
1409
- console.log(`🔑 Device UDID: ${deviceInfo.udid}`);
1410
- }
1411
- } catch (error) {
1412
- console.error(`❌ Failed to connect to WebDriverAgent: ${error instanceof Error ? error.message : String(error)}`);
1413
- const action = await (0, prompts_namespaceObject.select)({
1414
- message: 'What would you like to do?',
1415
- choices: [
1416
- {
1417
- name: '🔧 Configure different WebDriverAgent address',
1418
- value: 'configure'
1419
- },
1420
- {
1421
- name: '📖 Show setup instructions',
1422
- value: 'instructions'
1423
- },
1424
- {
1425
- name: '🚪 Exit',
1426
- value: 'exit'
1427
- }
1428
- ]
1429
- });
1430
- if ('exit' === action) {
1431
- console.log('👋 Goodbye!');
1432
- process.exit(0);
1433
- }
1434
- if ('instructions' === action) {
1435
- console.log(`
1436
- 🔧 WebDriverAgent Setup Instructions:
1437
-
1438
- 1. Install WebDriverAgent:
1439
- npm install appium-webdriveragent
1440
-
1441
- 2. Open WebDriverAgent project in Xcode:
1442
- node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj
1443
-
1444
- 3. Select your target device/simulator in Xcode
1445
-
1446
- 4. Build and run the WebDriverAgentRunner scheme
1447
-
1448
- 5. WebDriverAgent will bind to your selected device and listen on port ${constants_namespaceObject.DEFAULT_WDA_PORT}
1449
-
1450
- 6. Restart this playground to connect
1451
-
1452
- 💡 The WebDriverAgent service is already bound to the device you selected in Xcode.
1453
- 💡 For more details, visit: https://github.com/appium/WebDriverAgent
1454
- `);
1455
- continue;
1456
- }
1457
- wdaConfig = await configureWebDriverAgent();
1458
- }
1459
1349
  const availablePlaygroundPort = await (0, node_namespaceObject.findAvailablePort)(constants_namespaceObject.PLAYGROUND_SERVER_PORT);
1460
1350
  if (availablePlaygroundPort !== constants_namespaceObject.PLAYGROUND_SERVER_PORT) console.log(`⚠️ Port ${constants_namespaceObject.PLAYGROUND_SERVER_PORT} is busy, using port ${availablePlaygroundPort} instead`);
1351
+ const sessionManager = {
1352
+ async getSetupSchema () {
1353
+ return {
1354
+ title: 'Connect WebDriverAgent',
1355
+ description: 'Provide the WebDriverAgent host and port that are already running for your selected iPhone or simulator.',
1356
+ primaryActionLabel: 'Create Agent',
1357
+ fields: [
1358
+ {
1359
+ key: 'host',
1360
+ label: 'WebDriverAgent host',
1361
+ type: 'text',
1362
+ required: true,
1363
+ defaultValue: 'localhost',
1364
+ placeholder: 'localhost'
1365
+ },
1366
+ {
1367
+ key: 'port',
1368
+ label: 'WebDriverAgent port',
1369
+ type: 'number',
1370
+ required: true,
1371
+ defaultValue: constants_namespaceObject.DEFAULT_WDA_PORT,
1372
+ placeholder: constants_namespaceObject.DEFAULT_WDA_PORT.toString()
1373
+ }
1374
+ ]
1375
+ };
1376
+ },
1377
+ async createSession (input) {
1378
+ const host = 'string' == typeof input?.host && input.host.trim() ? input.host.trim().replace(/^https?:\/\//, '') : 'localhost';
1379
+ const port = 'number' == typeof input?.port ? input.port : Number.parseInt(String(input?.port ?? constants_namespaceObject.DEFAULT_WDA_PORT), 10);
1380
+ if (Number.isNaN(port) || port < 1 || port > 65535) throw new Error(`Invalid WebDriverAgent port: ${String(input?.port)}`);
1381
+ const connectAgent = async ()=>{
1382
+ const newDevice = new device_IOSDevice({
1383
+ wdaHost: host,
1384
+ wdaPort: port
1385
+ });
1386
+ await newDevice.connect();
1387
+ return new IOSAgent(newDevice);
1388
+ };
1389
+ const agent = await connectAgent();
1390
+ const deviceInfo = await agent.interface.getConnectedDeviceInfo?.();
1391
+ const displayName = deviceInfo ? `${deviceInfo.name} (${deviceInfo.model})` : `${host}:${port}`;
1392
+ return {
1393
+ agent,
1394
+ agentFactory: connectAgent,
1395
+ preview: (0, playground_namespaceObject.createMjpegPreviewDescriptor)({
1396
+ title: 'iOS device preview'
1397
+ }),
1398
+ displayName,
1399
+ metadata: {
1400
+ wdaHost: host,
1401
+ wdaPort: port,
1402
+ ...deviceInfo ? {
1403
+ deviceInfo
1404
+ } : {}
1405
+ }
1406
+ };
1407
+ }
1408
+ };
1461
1409
  return {
1462
1410
  platformId: 'ios',
1463
1411
  title: 'Midscene iOS Playground',
1464
- agentFactory: async ()=>{
1465
- const newDevice = new device_IOSDevice({
1466
- wdaHost: wdaConfig.host,
1467
- wdaPort: wdaConfig.port
1468
- });
1469
- await newDevice.connect();
1470
- return new IOSAgent(newDevice);
1471
- },
1412
+ sessionManager,
1472
1413
  launchOptions: {
1473
1414
  port: availablePlaygroundPort,
1474
1415
  openBrowser: false,
@@ -1479,8 +1420,8 @@ const iosPlaygroundPlatform = (0, playground_namespaceObject.definePlaygroundPla
1479
1420
  title: 'iOS device preview'
1480
1421
  }),
1481
1422
  metadata: {
1482
- wdaHost: wdaConfig.host,
1483
- wdaPort: wdaConfig.port
1423
+ sessionConnected: false,
1424
+ setupState: 'required'
1484
1425
  }
1485
1426
  };
1486
1427
  }
@@ -1494,13 +1435,9 @@ const main = async ()=>{
1494
1435
  staticDir: bin_staticDir
1495
1436
  });
1496
1437
  const { server: playgroundServer } = await (0, playground_namespaceObject.launchPreparedPlaygroundPlatform)(prepared);
1497
- const wdaHost = String(prepared.metadata?.wdaHost ?? 'localhost');
1498
- const wdaPort = String(prepared.metadata?.wdaPort ?? '');
1499
1438
  console.log('');
1500
1439
  console.log('✨ Midscene iOS Playground is ready!');
1501
1440
  console.log(`🎮 Playground: http://localhost:${playgroundServer.port}`);
1502
- console.log('📱 Device: WebDriverAgent Connected');
1503
- console.log(`🔧 WebDriverAgent: ${wdaHost}:${wdaPort}`);
1504
1441
  console.log(`🔑 Generated Server ID: ${playgroundServer.id}`);
1505
1442
  console.log('');
1506
1443
  open(`http://localhost:${playgroundServer.port}`);
package/dist/lib/cli.js CHANGED
@@ -1390,7 +1390,7 @@ class IOSMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
1390
1390
  const tools = new IOSMidsceneTools();
1391
1391
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-ios', {
1392
1392
  stripPrefix: 'ios_',
1393
- version: "1.6.0"
1393
+ version: "1.6.1-beta-20260327104111.0"
1394
1394
  }).catch((e)=>{
1395
1395
  if (!(e instanceof cli_namespaceObject.CLIError)) console.error(e);
1396
1396
  process.exit(e instanceof cli_namespaceObject.CLIError ? e.exitCode : 1);