@midscene/ios 1.9.7 → 1.9.8-beta-20260618091332.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/cli.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createReportCliCommands, z } from "@midscene/core";
2
2
  import { reportCLIError, runToolsCLI } from "@midscene/shared/cli";
3
3
  import { getDebug } from "@midscene/shared/logger";
4
+ import { agentBehaviorInitArgShape, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs } from "@midscene/shared/mcp/agent-behavior-init-args";
4
5
  import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
5
6
  import { Agent } from "@midscene/core/agent";
6
7
  import { MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE } from "@midscene/shared/env";
@@ -1356,7 +1357,8 @@ const iosInitArgShape = {
1356
1357
  wdaPort: z.number().optional().describe('WebDriverAgent port'),
1357
1358
  sessionId: z.string().optional().describe('Existing WebDriverAgent session ID to reuse'),
1358
1359
  useWDA: z.boolean().optional().describe('Whether to reuse an existing WebDriverAgent session'),
1359
- wdaMjpegPort: z.number().optional().describe('WebDriverAgent MJPEG streaming port')
1360
+ wdaMjpegPort: z.number().optional().describe('WebDriverAgent MJPEG streaming port'),
1361
+ ...agentBehaviorInitArgShape
1360
1362
  };
1361
1363
  function getTargetIdentity(initArgs) {
1362
1364
  if (initArgs?.deviceId) return initArgs.sessionId ? `${initArgs.deviceId}-session-${initArgs.sessionId}` : initArgs.deviceId;
@@ -1376,9 +1378,8 @@ class IOSMidsceneTools extends BaseMidsceneTools {
1376
1378
  return new IOSDevice({});
1377
1379
  }
1378
1380
  async ensureAgent(opts) {
1379
- const hasOpts = !!opts && Object.keys(opts).length > 0;
1380
- const nextSignature = hasOpts ? JSON.stringify(opts) : void 0;
1381
- if (this.agent && hasOpts && nextSignature !== this.lastOptsSignature) {
1381
+ const nextSignature = getAgentInitArgsSignature(opts);
1382
+ if (this.agent && shouldRebuildAgentForInitArgs(this.lastOptsSignature, nextSignature)) {
1382
1383
  try {
1383
1384
  await this.agent.destroy?.();
1384
1385
  } catch (error) {
@@ -1416,6 +1417,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
1416
1417
  debug('Failed to destroy agent during connect:', error);
1417
1418
  }
1418
1419
  this.agent = void 0;
1420
+ this.lastOptsSignature = void 0;
1419
1421
  }
1420
1422
  const agent = await this.ensureAgent(initArgs);
1421
1423
  const screenshot = await agent.page.screenshotBase64();
@@ -1453,7 +1455,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
1453
1455
  const tools = new IOSMidsceneTools();
1454
1456
  runToolsCLI(tools, 'midscene-ios', {
1455
1457
  stripPrefix: 'ios_',
1456
- version: "1.9.7",
1458
+ version: "1.9.8-beta-20260618091332.0",
1457
1459
  extraCommands: createReportCliCommands()
1458
1460
  }).catch((e)=>{
1459
1461
  process.exit(reportCLIError(e));
package/dist/es/index.mjs CHANGED
@@ -9,6 +9,7 @@ import { mergeAndNormalizeAppNameMapping, normalizeForComparison } from "@midsce
9
9
  import { WDAManager, WebDriverClient } from "@midscene/webdriver";
10
10
  import { Agent } from "@midscene/core/agent";
11
11
  import { MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE, overrideAIConfig } from "@midscene/shared/env";
12
+ import { agentBehaviorInitArgShape, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs } from "@midscene/shared/mcp/agent-behavior-init-args";
12
13
  import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
13
14
  import { exec } from "node:child_process";
14
15
  import { platform } from "node:os";
@@ -1361,7 +1362,8 @@ const iosInitArgShape = {
1361
1362
  wdaPort: z.number().optional().describe('WebDriverAgent port'),
1362
1363
  sessionId: z.string().optional().describe('Existing WebDriverAgent session ID to reuse'),
1363
1364
  useWDA: z.boolean().optional().describe('Whether to reuse an existing WebDriverAgent session'),
1364
- wdaMjpegPort: z.number().optional().describe('WebDriverAgent MJPEG streaming port')
1365
+ wdaMjpegPort: z.number().optional().describe('WebDriverAgent MJPEG streaming port'),
1366
+ ...agentBehaviorInitArgShape
1365
1367
  };
1366
1368
  function getTargetIdentity(initArgs) {
1367
1369
  if (initArgs?.deviceId) return initArgs.sessionId ? `${initArgs.deviceId}-session-${initArgs.sessionId}` : initArgs.deviceId;
@@ -1381,9 +1383,8 @@ class IOSMidsceneTools extends BaseMidsceneTools {
1381
1383
  return new IOSDevice({});
1382
1384
  }
1383
1385
  async ensureAgent(opts) {
1384
- const hasOpts = !!opts && Object.keys(opts).length > 0;
1385
- const nextSignature = hasOpts ? JSON.stringify(opts) : void 0;
1386
- if (this.agent && hasOpts && nextSignature !== this.lastOptsSignature) {
1386
+ const nextSignature = getAgentInitArgsSignature(opts);
1387
+ if (this.agent && shouldRebuildAgentForInitArgs(this.lastOptsSignature, nextSignature)) {
1387
1388
  try {
1388
1389
  await this.agent.destroy?.();
1389
1390
  } catch (error) {
@@ -1421,6 +1422,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
1421
1422
  debug('Failed to destroy agent during connect:', error);
1422
1423
  }
1423
1424
  this.agent = void 0;
1425
+ this.lastOptsSignature = void 0;
1424
1426
  }
1425
1427
  const agent = await this.ensureAgent(initArgs);
1426
1428
  const screenshot = await agent.page.screenshotBase64();
@@ -10,6 +10,7 @@ import { sleep } from "@midscene/core/utils";
10
10
  import { DEFAULT_WDA_PORT } from "@midscene/shared/constants";
11
11
  import { createImgBase64ByFormat } from "@midscene/shared/img";
12
12
  import { WDAManager, WebDriverClient } from "@midscene/webdriver";
13
+ import { agentBehaviorInitArgShape, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs } from "@midscene/shared/mcp/agent-behavior-init-args";
13
14
  import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
14
15
  const defaultAppNameMapping = {
15
16
  微信: 'com.tencent.xin',
@@ -1356,7 +1357,8 @@ const iosInitArgShape = {
1356
1357
  wdaPort: z.number().optional().describe('WebDriverAgent port'),
1357
1358
  sessionId: z.string().optional().describe('Existing WebDriverAgent session ID to reuse'),
1358
1359
  useWDA: z.boolean().optional().describe('Whether to reuse an existing WebDriverAgent session'),
1359
- wdaMjpegPort: z.number().optional().describe('WebDriverAgent MJPEG streaming port')
1360
+ wdaMjpegPort: z.number().optional().describe('WebDriverAgent MJPEG streaming port'),
1361
+ ...agentBehaviorInitArgShape
1360
1362
  };
1361
1363
  function getTargetIdentity(initArgs) {
1362
1364
  if (initArgs?.deviceId) return initArgs.sessionId ? `${initArgs.deviceId}-session-${initArgs.sessionId}` : initArgs.deviceId;
@@ -1376,9 +1378,8 @@ class IOSMidsceneTools extends BaseMidsceneTools {
1376
1378
  return new IOSDevice({});
1377
1379
  }
1378
1380
  async ensureAgent(opts) {
1379
- const hasOpts = !!opts && Object.keys(opts).length > 0;
1380
- const nextSignature = hasOpts ? JSON.stringify(opts) : void 0;
1381
- if (this.agent && hasOpts && nextSignature !== this.lastOptsSignature) {
1381
+ const nextSignature = getAgentInitArgsSignature(opts);
1382
+ if (this.agent && shouldRebuildAgentForInitArgs(this.lastOptsSignature, nextSignature)) {
1382
1383
  try {
1383
1384
  await this.agent.destroy?.();
1384
1385
  } catch (error) {
@@ -1416,6 +1417,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
1416
1417
  debug('Failed to destroy agent during connect:', error);
1417
1418
  }
1418
1419
  this.agent = void 0;
1420
+ this.lastOptsSignature = void 0;
1419
1421
  }
1420
1422
  const agent = await this.ensureAgent(initArgs);
1421
1423
  const screenshot = await agent.page.screenshotBase64();
@@ -1457,7 +1459,7 @@ class IOSMCPServer extends BaseMCPServer {
1457
1459
  constructor(toolsManager){
1458
1460
  super({
1459
1461
  name: '@midscene/ios-mcp',
1460
- version: "1.9.7",
1462
+ version: "1.9.8-beta-20260618091332.0",
1461
1463
  description: 'Control the iOS device using natural language commands'
1462
1464
  }, toolsManager);
1463
1465
  }
package/dist/lib/cli.js CHANGED
@@ -24,6 +24,7 @@ var __webpack_exports__ = {};
24
24
  const core_namespaceObject = require("@midscene/core");
25
25
  const cli_namespaceObject = require("@midscene/shared/cli");
26
26
  const logger_namespaceObject = require("@midscene/shared/logger");
27
+ const agent_behavior_init_args_namespaceObject = require("@midscene/shared/mcp/agent-behavior-init-args");
27
28
  const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
28
29
  const agent_namespaceObject = require("@midscene/core/agent");
29
30
  const env_namespaceObject = require("@midscene/shared/env");
@@ -1380,7 +1381,8 @@ const iosInitArgShape = {
1380
1381
  wdaPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent port'),
1381
1382
  sessionId: core_namespaceObject.z.string().optional().describe('Existing WebDriverAgent session ID to reuse'),
1382
1383
  useWDA: core_namespaceObject.z.boolean().optional().describe('Whether to reuse an existing WebDriverAgent session'),
1383
- wdaMjpegPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent MJPEG streaming port')
1384
+ wdaMjpegPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent MJPEG streaming port'),
1385
+ ...agent_behavior_init_args_namespaceObject.agentBehaviorInitArgShape
1384
1386
  };
1385
1387
  function getTargetIdentity(initArgs) {
1386
1388
  if (initArgs?.deviceId) return initArgs.sessionId ? `${initArgs.deviceId}-session-${initArgs.sessionId}` : initArgs.deviceId;
@@ -1400,9 +1402,8 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
1400
1402
  return new IOSDevice({});
1401
1403
  }
1402
1404
  async ensureAgent(opts) {
1403
- const hasOpts = !!opts && Object.keys(opts).length > 0;
1404
- const nextSignature = hasOpts ? JSON.stringify(opts) : void 0;
1405
- if (this.agent && hasOpts && nextSignature !== this.lastOptsSignature) {
1405
+ const nextSignature = (0, agent_behavior_init_args_namespaceObject.getAgentInitArgsSignature)(opts);
1406
+ if (this.agent && (0, agent_behavior_init_args_namespaceObject.shouldRebuildAgentForInitArgs)(this.lastOptsSignature, nextSignature)) {
1406
1407
  try {
1407
1408
  await this.agent.destroy?.();
1408
1409
  } catch (error) {
@@ -1440,6 +1441,7 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
1440
1441
  debug('Failed to destroy agent during connect:', error);
1441
1442
  }
1442
1443
  this.agent = void 0;
1444
+ this.lastOptsSignature = void 0;
1443
1445
  }
1444
1446
  const agent = await this.ensureAgent(initArgs);
1445
1447
  const screenshot = await agent.page.screenshotBase64();
@@ -1477,7 +1479,7 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
1477
1479
  const tools = new IOSMidsceneTools();
1478
1480
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-ios', {
1479
1481
  stripPrefix: 'ios_',
1480
- version: "1.9.7",
1482
+ version: "1.9.8-beta-20260618091332.0",
1481
1483
  extraCommands: (0, core_namespaceObject.createReportCliCommands)()
1482
1484
  }).catch((e)=>{
1483
1485
  process.exit((0, cli_namespaceObject.reportCLIError)(e));
package/dist/lib/index.js CHANGED
@@ -1382,6 +1382,7 @@ async function agentFromWebDriverAgent(opts) {
1382
1382
  await device.connect();
1383
1383
  return new IOSAgent(device, opts);
1384
1384
  }
1385
+ const agent_behavior_init_args_namespaceObject = require("@midscene/shared/mcp/agent-behavior-init-args");
1385
1386
  const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
1386
1387
  function mcp_tools_define_property(obj, key, value) {
1387
1388
  if (key in obj) Object.defineProperty(obj, key, {
@@ -1400,7 +1401,8 @@ const iosInitArgShape = {
1400
1401
  wdaPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent port'),
1401
1402
  sessionId: core_namespaceObject.z.string().optional().describe('Existing WebDriverAgent session ID to reuse'),
1402
1403
  useWDA: core_namespaceObject.z.boolean().optional().describe('Whether to reuse an existing WebDriverAgent session'),
1403
- wdaMjpegPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent MJPEG streaming port')
1404
+ wdaMjpegPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent MJPEG streaming port'),
1405
+ ...agent_behavior_init_args_namespaceObject.agentBehaviorInitArgShape
1404
1406
  };
1405
1407
  function getTargetIdentity(initArgs) {
1406
1408
  if (initArgs?.deviceId) return initArgs.sessionId ? `${initArgs.deviceId}-session-${initArgs.sessionId}` : initArgs.deviceId;
@@ -1420,9 +1422,8 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
1420
1422
  return new IOSDevice({});
1421
1423
  }
1422
1424
  async ensureAgent(opts) {
1423
- const hasOpts = !!opts && Object.keys(opts).length > 0;
1424
- const nextSignature = hasOpts ? JSON.stringify(opts) : void 0;
1425
- if (this.agent && hasOpts && nextSignature !== this.lastOptsSignature) {
1425
+ const nextSignature = (0, agent_behavior_init_args_namespaceObject.getAgentInitArgsSignature)(opts);
1426
+ if (this.agent && (0, agent_behavior_init_args_namespaceObject.shouldRebuildAgentForInitArgs)(this.lastOptsSignature, nextSignature)) {
1426
1427
  try {
1427
1428
  await this.agent.destroy?.();
1428
1429
  } catch (error) {
@@ -1460,6 +1461,7 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
1460
1461
  debug('Failed to destroy agent during connect:', error);
1461
1462
  }
1462
1463
  this.agent = void 0;
1464
+ this.lastOptsSignature = void 0;
1463
1465
  }
1464
1466
  const agent = await this.ensureAgent(initArgs);
1465
1467
  const screenshot = await agent.page.screenshotBase64();
@@ -1378,6 +1378,7 @@ async function agentFromWebDriverAgent(opts) {
1378
1378
  await device.connect();
1379
1379
  return new IOSAgent(device, opts);
1380
1380
  }
1381
+ const agent_behavior_init_args_namespaceObject = require("@midscene/shared/mcp/agent-behavior-init-args");
1381
1382
  const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
1382
1383
  function mcp_tools_define_property(obj, key, value) {
1383
1384
  if (key in obj) Object.defineProperty(obj, key, {
@@ -1396,7 +1397,8 @@ const iosInitArgShape = {
1396
1397
  wdaPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent port'),
1397
1398
  sessionId: core_namespaceObject.z.string().optional().describe('Existing WebDriverAgent session ID to reuse'),
1398
1399
  useWDA: core_namespaceObject.z.boolean().optional().describe('Whether to reuse an existing WebDriverAgent session'),
1399
- wdaMjpegPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent MJPEG streaming port')
1400
+ wdaMjpegPort: core_namespaceObject.z.number().optional().describe('WebDriverAgent MJPEG streaming port'),
1401
+ ...agent_behavior_init_args_namespaceObject.agentBehaviorInitArgShape
1400
1402
  };
1401
1403
  function getTargetIdentity(initArgs) {
1402
1404
  if (initArgs?.deviceId) return initArgs.sessionId ? `${initArgs.deviceId}-session-${initArgs.sessionId}` : initArgs.deviceId;
@@ -1416,9 +1418,8 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
1416
1418
  return new IOSDevice({});
1417
1419
  }
1418
1420
  async ensureAgent(opts) {
1419
- const hasOpts = !!opts && Object.keys(opts).length > 0;
1420
- const nextSignature = hasOpts ? JSON.stringify(opts) : void 0;
1421
- if (this.agent && hasOpts && nextSignature !== this.lastOptsSignature) {
1421
+ const nextSignature = (0, agent_behavior_init_args_namespaceObject.getAgentInitArgsSignature)(opts);
1422
+ if (this.agent && (0, agent_behavior_init_args_namespaceObject.shouldRebuildAgentForInitArgs)(this.lastOptsSignature, nextSignature)) {
1422
1423
  try {
1423
1424
  await this.agent.destroy?.();
1424
1425
  } catch (error) {
@@ -1456,6 +1457,7 @@ class IOSMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
1456
1457
  debug('Failed to destroy agent during connect:', error);
1457
1458
  }
1458
1459
  this.agent = void 0;
1460
+ this.lastOptsSignature = void 0;
1459
1461
  }
1460
1462
  const agent = await this.ensureAgent(initArgs);
1461
1463
  const screenshot = await agent.page.screenshotBase64();
@@ -1497,7 +1499,7 @@ class IOSMCPServer extends mcp_namespaceObject.BaseMCPServer {
1497
1499
  constructor(toolsManager){
1498
1500
  super({
1499
1501
  name: '@midscene/ios-mcp',
1500
- version: "1.9.7",
1502
+ version: "1.9.8-beta-20260618091332.0",
1501
1503
  description: 'Control the iOS device using natural language commands'
1502
1504
  }, toolsManager);
1503
1505
  }
@@ -2,6 +2,7 @@ import { AbstractInterface } from '@midscene/core/device';
2
2
  import type { ActionParam } from '@midscene/core';
3
3
  import type { ActionReturn } from '@midscene/core';
4
4
  import { Agent } from '@midscene/core/agent';
5
+ import { AgentBehaviorInitArgs } from '@midscene/shared/mcp/agent-behavior-init-args';
5
6
  import { AgentOpt } from '@midscene/core/agent';
6
7
  import { BaseMidsceneTools } from '@midscene/shared/mcp/base-tools';
7
8
  import { DeviceAction } from '@midscene/core';
@@ -178,7 +179,7 @@ export declare class IOSDevice implements AbstractInterface {
178
179
  destroy(): Promise<void>;
179
180
  }
180
181
 
181
- declare type IOSInitArgs = Pick<IOSDeviceOpt, 'deviceId' | 'wdaHost' | 'wdaPort' | 'sessionId' | 'useWDA' | 'wdaMjpegPort'>;
182
+ declare type IOSInitArgs = AgentBehaviorInitArgs & Pick<IOSDeviceOpt, 'deviceId' | 'wdaHost' | 'wdaPort' | 'sessionId' | 'useWDA' | 'wdaMjpegPort'>;
182
183
 
183
184
  /**
184
185
  * iOS-specific tools manager
@@ -2,6 +2,7 @@ import { AbstractInterface } from '@midscene/core/device';
2
2
  import type { ActionParam } from '@midscene/core';
3
3
  import type { ActionReturn } from '@midscene/core';
4
4
  import { Agent } from '@midscene/core/agent';
5
+ import { AgentBehaviorInitArgs } from '@midscene/shared/mcp/agent-behavior-init-args';
5
6
  import { AgentOpt } from '@midscene/core/agent';
6
7
  import { BaseMCPServer } from '@midscene/shared/mcp';
7
8
  import { BaseMidsceneTools } from '@midscene/shared/mcp/base-tools';
@@ -172,7 +173,7 @@ declare class IOSDevice implements AbstractInterface {
172
173
  destroy(): Promise<void>;
173
174
  }
174
175
 
175
- declare type IOSInitArgs = Pick<IOSDeviceOpt, 'deviceId' | 'wdaHost' | 'wdaPort' | 'sessionId' | 'useWDA' | 'wdaMjpegPort'>;
176
+ declare type IOSInitArgs = AgentBehaviorInitArgs & Pick<IOSDeviceOpt, 'deviceId' | 'wdaHost' | 'wdaPort' | 'sessionId' | 'useWDA' | 'wdaMjpegPort'>;
176
177
 
177
178
  /**
178
179
  * iOS MCP Server
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/ios",
3
- "version": "1.9.7",
3
+ "version": "1.9.8-beta-20260618091332.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/midscene.git",
@@ -48,10 +48,10 @@
48
48
  "dependencies": {
49
49
  "@inquirer/prompts": "^7.8.6",
50
50
  "open": "10.1.0",
51
- "@midscene/core": "1.9.7",
52
- "@midscene/webdriver": "1.9.7",
53
- "@midscene/shared": "1.9.7",
54
- "@midscene/playground": "1.9.7"
51
+ "@midscene/core": "1.9.8-beta-20260618091332.0",
52
+ "@midscene/webdriver": "1.9.8-beta-20260618091332.0",
53
+ "@midscene/playground": "1.9.8-beta-20260618091332.0",
54
+ "@midscene/shared": "1.9.8-beta-20260618091332.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@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/905.8d12588e.js"></script><script defer src="/static/js/index.50e06ed5.js"></script><link href="/static/css/index.1293237f.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
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/905.8d12588e.js"></script><script defer src="/static/js/index.64bb287d.js"></script><link href="/static/css/index.1293237f.css" rel="stylesheet"></head><body><div id="root"></div></body></html>