@midscene/ios 1.7.5 → 1.7.6-beta-20260423130231.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 +35 -26
- package/dist/es/cli.mjs +36 -27
- package/dist/es/index.mjs +35 -26
- package/dist/es/mcp-server.mjs +36 -27
- package/dist/lib/bin.js +34 -25
- package/dist/lib/cli.js +35 -26
- package/dist/lib/index.js +34 -25
- package/dist/lib/mcp-server.js +35 -26
- package/dist/types/index.d.ts +10 -22
- package/dist/types/mcp-server.d.ts +10 -22
- package/package.json +5 -5
- package/static/index.html +1 -1
- package/static/static/js/{index.3bea1f00.js → index.40f13c41.js} +44 -40
- package/static/static/js/index.40f13c41.js.map +1 -0
- package/static/static/js/index.3bea1f00.js.map +0 -1
- /package/static/static/js/{index.3bea1f00.js.LICENSE.txt → index.40f13c41.js.LICENSE.txt} +0 -0
package/dist/es/bin.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { getDebug } from "@midscene/shared/logger";
|
|
|
7
7
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison } from "@midscene/shared/utils";
|
|
8
8
|
import node_assert from "node:assert";
|
|
9
9
|
import { getMidsceneLocationSchema, z } from "@midscene/core";
|
|
10
|
-
import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionPinch, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam, normalizePinchParam } from "@midscene/core/device";
|
|
10
|
+
import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionLongPress, defineActionPinch, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam, normalizePinchParam } from "@midscene/core/device";
|
|
11
11
|
import { sleep } from "@midscene/core/utils";
|
|
12
12
|
import { createImgBase64ByFormat } from "@midscene/shared/img";
|
|
13
13
|
import { WDAManager, WebDriverClient } from "@midscene/webdriver";
|
|
@@ -744,24 +744,11 @@ class device_IOSDevice {
|
|
|
744
744
|
await sleep(100);
|
|
745
745
|
}
|
|
746
746
|
}),
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
locate: getMidsceneLocationSchema().describe('The element to be long pressed')
|
|
753
|
-
}),
|
|
754
|
-
sample: {
|
|
755
|
-
locate: {
|
|
756
|
-
prompt: 'the message bubble'
|
|
757
|
-
}
|
|
758
|
-
},
|
|
759
|
-
call: async (param)=>{
|
|
760
|
-
const element = param.locate;
|
|
761
|
-
node_assert(element, 'LongPress requires an element to be located');
|
|
762
|
-
const [x, y] = element.center;
|
|
763
|
-
await this.longPress(x, y, param?.duration);
|
|
764
|
-
}
|
|
747
|
+
defineActionLongPress(async (param)=>{
|
|
748
|
+
const element = param.locate;
|
|
749
|
+
node_assert(element, 'LongPress requires an element to be located');
|
|
750
|
+
const [x, y] = element.center;
|
|
751
|
+
await this.longPress(x, y, param?.duration);
|
|
765
752
|
}),
|
|
766
753
|
defineActionPinch(async (param)=>{
|
|
767
754
|
const { centerX, centerY, startDistance, endDistance, duration } = normalizePinchParam(param, await this.size());
|
|
@@ -1241,8 +1228,12 @@ const runWdaRequestParamSchema = z.object({
|
|
|
1241
1228
|
endpoint: z.string().describe('WebDriver API endpoint'),
|
|
1242
1229
|
data: z.object({}).passthrough().optional().describe('Optional request body data as JSON object')
|
|
1243
1230
|
});
|
|
1244
|
-
const launchParamSchema = z.
|
|
1245
|
-
|
|
1231
|
+
const launchParamSchema = z.object({
|
|
1232
|
+
uri: z.string().describe('App name, bundle ID, or URL to launch. Prioritize using the exact bundle ID or URL the user has provided. If none provided, use the accurate app name.')
|
|
1233
|
+
});
|
|
1234
|
+
const terminateParamSchema = z.object({
|
|
1235
|
+
uri: z.string().describe('Bundle ID of the app to terminate (close). Use the exact bundle ID, e.g. com.apple.Preferences.')
|
|
1236
|
+
});
|
|
1246
1237
|
const createPlatformActions = (device)=>({
|
|
1247
1238
|
RunWdaRequest: defineAction({
|
|
1248
1239
|
name: 'RunWdaRequest',
|
|
@@ -1260,8 +1251,12 @@ const createPlatformActions = (device)=>({
|
|
|
1260
1251
|
description: 'Launch an iOS app or URL',
|
|
1261
1252
|
interfaceAlias: 'launch',
|
|
1262
1253
|
paramSchema: launchParamSchema,
|
|
1254
|
+
sample: {
|
|
1255
|
+
uri: 'com.apple.Preferences'
|
|
1256
|
+
},
|
|
1263
1257
|
call: async (param)=>{
|
|
1264
|
-
|
|
1258
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Launch requires a non-empty uri parameter');
|
|
1259
|
+
await device.launch(param.uri);
|
|
1265
1260
|
}
|
|
1266
1261
|
}),
|
|
1267
1262
|
Terminate: defineAction({
|
|
@@ -1269,8 +1264,12 @@ const createPlatformActions = (device)=>({
|
|
|
1269
1264
|
description: 'Terminate (close) an iOS app by its bundle ID',
|
|
1270
1265
|
interfaceAlias: 'terminate',
|
|
1271
1266
|
paramSchema: terminateParamSchema,
|
|
1267
|
+
sample: {
|
|
1268
|
+
uri: 'com.apple.Preferences'
|
|
1269
|
+
},
|
|
1272
1270
|
call: async (param)=>{
|
|
1273
|
-
|
|
1271
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1272
|
+
await device.terminate(param.uri);
|
|
1274
1273
|
}
|
|
1275
1274
|
}),
|
|
1276
1275
|
IOSHomeButton: defineAction({
|
|
@@ -1300,17 +1299,27 @@ function agent_define_property(obj, key, value) {
|
|
|
1300
1299
|
}
|
|
1301
1300
|
getDebug('ios:agent');
|
|
1302
1301
|
class IOSAgent extends Agent {
|
|
1302
|
+
async launch(uri) {
|
|
1303
|
+
const action = this.wrapActionInActionSpace('Launch');
|
|
1304
|
+
return action({
|
|
1305
|
+
uri
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
async terminate(uri) {
|
|
1309
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1310
|
+
return action({
|
|
1311
|
+
uri
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1303
1314
|
createActionWrapper(name) {
|
|
1304
1315
|
const action = this.wrapActionInActionSpace(name);
|
|
1305
1316
|
return (...args)=>action(args[0]);
|
|
1306
1317
|
}
|
|
1307
1318
|
constructor(device, opts){
|
|
1308
|
-
super(device, opts), agent_define_property(this, "
|
|
1319
|
+
super(device, opts), agent_define_property(this, "runWdaRequest", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "appSwitcher", void 0), agent_define_property(this, "appNameMapping", void 0);
|
|
1309
1320
|
this.appNameMapping = mergeAndNormalizeAppNameMapping(defaultAppNameMapping, opts?.appNameMapping);
|
|
1310
1321
|
device.setAppNameMapping(this.appNameMapping);
|
|
1311
|
-
this.launch = this.createActionWrapper('Launch');
|
|
1312
1322
|
this.runWdaRequest = this.createActionWrapper('RunWdaRequest');
|
|
1313
|
-
this.terminate = this.createActionWrapper('Terminate');
|
|
1314
1323
|
this.home = this.createActionWrapper('IOSHomeButton');
|
|
1315
1324
|
this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
|
|
1316
1325
|
}
|
package/dist/es/cli.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
|
|
|
5
5
|
import { Agent } from "@midscene/core/agent";
|
|
6
6
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison } from "@midscene/shared/utils";
|
|
7
7
|
import node_assert from "node:assert";
|
|
8
|
-
import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionPinch, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam, normalizePinchParam } from "@midscene/core/device";
|
|
8
|
+
import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionLongPress, defineActionPinch, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam, normalizePinchParam } from "@midscene/core/device";
|
|
9
9
|
import { sleep } from "@midscene/core/utils";
|
|
10
10
|
import { DEFAULT_WDA_PORT } from "@midscene/shared/constants";
|
|
11
11
|
import { createImgBase64ByFormat } from "@midscene/shared/img";
|
|
@@ -743,24 +743,11 @@ class IOSDevice {
|
|
|
743
743
|
await sleep(100);
|
|
744
744
|
}
|
|
745
745
|
}),
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
locate: getMidsceneLocationSchema().describe('The element to be long pressed')
|
|
752
|
-
}),
|
|
753
|
-
sample: {
|
|
754
|
-
locate: {
|
|
755
|
-
prompt: 'the message bubble'
|
|
756
|
-
}
|
|
757
|
-
},
|
|
758
|
-
call: async (param)=>{
|
|
759
|
-
const element = param.locate;
|
|
760
|
-
node_assert(element, 'LongPress requires an element to be located');
|
|
761
|
-
const [x, y] = element.center;
|
|
762
|
-
await this.longPress(x, y, param?.duration);
|
|
763
|
-
}
|
|
746
|
+
defineActionLongPress(async (param)=>{
|
|
747
|
+
const element = param.locate;
|
|
748
|
+
node_assert(element, 'LongPress requires an element to be located');
|
|
749
|
+
const [x, y] = element.center;
|
|
750
|
+
await this.longPress(x, y, param?.duration);
|
|
764
751
|
}),
|
|
765
752
|
defineActionPinch(async (param)=>{
|
|
766
753
|
const { centerX, centerY, startDistance, endDistance, duration } = normalizePinchParam(param, await this.size());
|
|
@@ -1240,8 +1227,12 @@ const runWdaRequestParamSchema = z.object({
|
|
|
1240
1227
|
endpoint: z.string().describe('WebDriver API endpoint'),
|
|
1241
1228
|
data: z.object({}).passthrough().optional().describe('Optional request body data as JSON object')
|
|
1242
1229
|
});
|
|
1243
|
-
const launchParamSchema = z.
|
|
1244
|
-
|
|
1230
|
+
const launchParamSchema = z.object({
|
|
1231
|
+
uri: z.string().describe('App name, bundle ID, or URL to launch. Prioritize using the exact bundle ID or URL the user has provided. If none provided, use the accurate app name.')
|
|
1232
|
+
});
|
|
1233
|
+
const terminateParamSchema = z.object({
|
|
1234
|
+
uri: z.string().describe('Bundle ID of the app to terminate (close). Use the exact bundle ID, e.g. com.apple.Preferences.')
|
|
1235
|
+
});
|
|
1245
1236
|
const createPlatformActions = (device)=>({
|
|
1246
1237
|
RunWdaRequest: defineAction({
|
|
1247
1238
|
name: 'RunWdaRequest',
|
|
@@ -1259,8 +1250,12 @@ const createPlatformActions = (device)=>({
|
|
|
1259
1250
|
description: 'Launch an iOS app or URL',
|
|
1260
1251
|
interfaceAlias: 'launch',
|
|
1261
1252
|
paramSchema: launchParamSchema,
|
|
1253
|
+
sample: {
|
|
1254
|
+
uri: 'com.apple.Preferences'
|
|
1255
|
+
},
|
|
1262
1256
|
call: async (param)=>{
|
|
1263
|
-
|
|
1257
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Launch requires a non-empty uri parameter');
|
|
1258
|
+
await device.launch(param.uri);
|
|
1264
1259
|
}
|
|
1265
1260
|
}),
|
|
1266
1261
|
Terminate: defineAction({
|
|
@@ -1268,8 +1263,12 @@ const createPlatformActions = (device)=>({
|
|
|
1268
1263
|
description: 'Terminate (close) an iOS app by its bundle ID',
|
|
1269
1264
|
interfaceAlias: 'terminate',
|
|
1270
1265
|
paramSchema: terminateParamSchema,
|
|
1266
|
+
sample: {
|
|
1267
|
+
uri: 'com.apple.Preferences'
|
|
1268
|
+
},
|
|
1271
1269
|
call: async (param)=>{
|
|
1272
|
-
|
|
1270
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1271
|
+
await device.terminate(param.uri);
|
|
1273
1272
|
}
|
|
1274
1273
|
}),
|
|
1275
1274
|
IOSHomeButton: defineAction({
|
|
@@ -1299,17 +1298,27 @@ function agent_define_property(obj, key, value) {
|
|
|
1299
1298
|
}
|
|
1300
1299
|
const debugAgent = getDebug('ios:agent');
|
|
1301
1300
|
class IOSAgent extends Agent {
|
|
1301
|
+
async launch(uri) {
|
|
1302
|
+
const action = this.wrapActionInActionSpace('Launch');
|
|
1303
|
+
return action({
|
|
1304
|
+
uri
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
async terminate(uri) {
|
|
1308
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1309
|
+
return action({
|
|
1310
|
+
uri
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1302
1313
|
createActionWrapper(name) {
|
|
1303
1314
|
const action = this.wrapActionInActionSpace(name);
|
|
1304
1315
|
return (...args)=>action(args[0]);
|
|
1305
1316
|
}
|
|
1306
1317
|
constructor(device, opts){
|
|
1307
|
-
super(device, opts), agent_define_property(this, "
|
|
1318
|
+
super(device, opts), agent_define_property(this, "runWdaRequest", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "appSwitcher", void 0), agent_define_property(this, "appNameMapping", void 0);
|
|
1308
1319
|
this.appNameMapping = mergeAndNormalizeAppNameMapping(defaultAppNameMapping, opts?.appNameMapping);
|
|
1309
1320
|
device.setAppNameMapping(this.appNameMapping);
|
|
1310
|
-
this.launch = this.createActionWrapper('Launch');
|
|
1311
1321
|
this.runWdaRequest = this.createActionWrapper('RunWdaRequest');
|
|
1312
|
-
this.terminate = this.createActionWrapper('Terminate');
|
|
1313
1322
|
this.home = this.createActionWrapper('IOSHomeButton');
|
|
1314
1323
|
this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
|
|
1315
1324
|
}
|
|
@@ -1407,7 +1416,7 @@ class IOSMidsceneTools extends BaseMidsceneTools {
|
|
|
1407
1416
|
const tools = new IOSMidsceneTools();
|
|
1408
1417
|
runToolsCLI(tools, 'midscene-ios', {
|
|
1409
1418
|
stripPrefix: 'ios_',
|
|
1410
|
-
version: "1.7.
|
|
1419
|
+
version: "1.7.6-beta-20260423130231.0",
|
|
1411
1420
|
extraCommands: createReportCliCommands()
|
|
1412
1421
|
}).catch((e)=>{
|
|
1413
1422
|
process.exit(reportCLIError(e));
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import node_assert from "node:assert";
|
|
2
2
|
import { getMidsceneLocationSchema, z } from "@midscene/core";
|
|
3
|
-
import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionPinch, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam, normalizePinchParam } from "@midscene/core/device";
|
|
3
|
+
import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionLongPress, defineActionPinch, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam, normalizePinchParam } from "@midscene/core/device";
|
|
4
4
|
import { sleep } from "@midscene/core/utils";
|
|
5
5
|
import { DEFAULT_WDA_PORT, PLAYGROUND_SERVER_PORT } from "@midscene/shared/constants";
|
|
6
6
|
import { createImgBase64ByFormat } from "@midscene/shared/img";
|
|
@@ -565,24 +565,11 @@ class IOSDevice {
|
|
|
565
565
|
await sleep(100);
|
|
566
566
|
}
|
|
567
567
|
}),
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
locate: getMidsceneLocationSchema().describe('The element to be long pressed')
|
|
574
|
-
}),
|
|
575
|
-
sample: {
|
|
576
|
-
locate: {
|
|
577
|
-
prompt: 'the message bubble'
|
|
578
|
-
}
|
|
579
|
-
},
|
|
580
|
-
call: async (param)=>{
|
|
581
|
-
const element = param.locate;
|
|
582
|
-
node_assert(element, 'LongPress requires an element to be located');
|
|
583
|
-
const [x, y] = element.center;
|
|
584
|
-
await this.longPress(x, y, param?.duration);
|
|
585
|
-
}
|
|
568
|
+
defineActionLongPress(async (param)=>{
|
|
569
|
+
const element = param.locate;
|
|
570
|
+
node_assert(element, 'LongPress requires an element to be located');
|
|
571
|
+
const [x, y] = element.center;
|
|
572
|
+
await this.longPress(x, y, param?.duration);
|
|
586
573
|
}),
|
|
587
574
|
defineActionPinch(async (param)=>{
|
|
588
575
|
const { centerX, centerY, startDistance, endDistance, duration } = normalizePinchParam(param, await this.size());
|
|
@@ -1062,8 +1049,12 @@ const runWdaRequestParamSchema = z.object({
|
|
|
1062
1049
|
endpoint: z.string().describe('WebDriver API endpoint'),
|
|
1063
1050
|
data: z.object({}).passthrough().optional().describe('Optional request body data as JSON object')
|
|
1064
1051
|
});
|
|
1065
|
-
const launchParamSchema = z.
|
|
1066
|
-
|
|
1052
|
+
const launchParamSchema = z.object({
|
|
1053
|
+
uri: z.string().describe('App name, bundle ID, or URL to launch. Prioritize using the exact bundle ID or URL the user has provided. If none provided, use the accurate app name.')
|
|
1054
|
+
});
|
|
1055
|
+
const terminateParamSchema = z.object({
|
|
1056
|
+
uri: z.string().describe('Bundle ID of the app to terminate (close). Use the exact bundle ID, e.g. com.apple.Preferences.')
|
|
1057
|
+
});
|
|
1067
1058
|
const createPlatformActions = (device)=>({
|
|
1068
1059
|
RunWdaRequest: defineAction({
|
|
1069
1060
|
name: 'RunWdaRequest',
|
|
@@ -1081,8 +1072,12 @@ const createPlatformActions = (device)=>({
|
|
|
1081
1072
|
description: 'Launch an iOS app or URL',
|
|
1082
1073
|
interfaceAlias: 'launch',
|
|
1083
1074
|
paramSchema: launchParamSchema,
|
|
1075
|
+
sample: {
|
|
1076
|
+
uri: 'com.apple.Preferences'
|
|
1077
|
+
},
|
|
1084
1078
|
call: async (param)=>{
|
|
1085
|
-
|
|
1079
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Launch requires a non-empty uri parameter');
|
|
1080
|
+
await device.launch(param.uri);
|
|
1086
1081
|
}
|
|
1087
1082
|
}),
|
|
1088
1083
|
Terminate: defineAction({
|
|
@@ -1090,8 +1085,12 @@ const createPlatformActions = (device)=>({
|
|
|
1090
1085
|
description: 'Terminate (close) an iOS app by its bundle ID',
|
|
1091
1086
|
interfaceAlias: 'terminate',
|
|
1092
1087
|
paramSchema: terminateParamSchema,
|
|
1088
|
+
sample: {
|
|
1089
|
+
uri: 'com.apple.Preferences'
|
|
1090
|
+
},
|
|
1093
1091
|
call: async (param)=>{
|
|
1094
|
-
|
|
1092
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1093
|
+
await device.terminate(param.uri);
|
|
1095
1094
|
}
|
|
1096
1095
|
}),
|
|
1097
1096
|
IOSHomeButton: defineAction({
|
|
@@ -1305,17 +1304,27 @@ function agent_define_property(obj, key, value) {
|
|
|
1305
1304
|
}
|
|
1306
1305
|
const debugAgent = getDebug('ios:agent');
|
|
1307
1306
|
class IOSAgent extends Agent {
|
|
1307
|
+
async launch(uri) {
|
|
1308
|
+
const action = this.wrapActionInActionSpace('Launch');
|
|
1309
|
+
return action({
|
|
1310
|
+
uri
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
async terminate(uri) {
|
|
1314
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1315
|
+
return action({
|
|
1316
|
+
uri
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1308
1319
|
createActionWrapper(name) {
|
|
1309
1320
|
const action = this.wrapActionInActionSpace(name);
|
|
1310
1321
|
return (...args)=>action(args[0]);
|
|
1311
1322
|
}
|
|
1312
1323
|
constructor(device, opts){
|
|
1313
|
-
super(device, opts), agent_define_property(this, "
|
|
1324
|
+
super(device, opts), agent_define_property(this, "runWdaRequest", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "appSwitcher", void 0), agent_define_property(this, "appNameMapping", void 0);
|
|
1314
1325
|
this.appNameMapping = mergeAndNormalizeAppNameMapping(defaultAppNameMapping, opts?.appNameMapping);
|
|
1315
1326
|
device.setAppNameMapping(this.appNameMapping);
|
|
1316
|
-
this.launch = this.createActionWrapper('Launch');
|
|
1317
1327
|
this.runWdaRequest = this.createActionWrapper('RunWdaRequest');
|
|
1318
|
-
this.terminate = this.createActionWrapper('Terminate');
|
|
1319
1328
|
this.home = this.createActionWrapper('IOSHomeButton');
|
|
1320
1329
|
this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
|
|
1321
1330
|
}
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { getDebug } from "@midscene/shared/logger";
|
|
|
4
4
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison } from "@midscene/shared/utils";
|
|
5
5
|
import node_assert from "node:assert";
|
|
6
6
|
import { getMidsceneLocationSchema, z } from "@midscene/core";
|
|
7
|
-
import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionPinch, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam, normalizePinchParam } from "@midscene/core/device";
|
|
7
|
+
import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionLongPress, defineActionPinch, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam, normalizePinchParam } from "@midscene/core/device";
|
|
8
8
|
import { sleep } from "@midscene/core/utils";
|
|
9
9
|
import { DEFAULT_WDA_PORT } from "@midscene/shared/constants";
|
|
10
10
|
import { createImgBase64ByFormat } from "@midscene/shared/img";
|
|
@@ -743,24 +743,11 @@ class IOSDevice {
|
|
|
743
743
|
await sleep(100);
|
|
744
744
|
}
|
|
745
745
|
}),
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
locate: getMidsceneLocationSchema().describe('The element to be long pressed')
|
|
752
|
-
}),
|
|
753
|
-
sample: {
|
|
754
|
-
locate: {
|
|
755
|
-
prompt: 'the message bubble'
|
|
756
|
-
}
|
|
757
|
-
},
|
|
758
|
-
call: async (param)=>{
|
|
759
|
-
const element = param.locate;
|
|
760
|
-
node_assert(element, 'LongPress requires an element to be located');
|
|
761
|
-
const [x, y] = element.center;
|
|
762
|
-
await this.longPress(x, y, param?.duration);
|
|
763
|
-
}
|
|
746
|
+
defineActionLongPress(async (param)=>{
|
|
747
|
+
const element = param.locate;
|
|
748
|
+
node_assert(element, 'LongPress requires an element to be located');
|
|
749
|
+
const [x, y] = element.center;
|
|
750
|
+
await this.longPress(x, y, param?.duration);
|
|
764
751
|
}),
|
|
765
752
|
defineActionPinch(async (param)=>{
|
|
766
753
|
const { centerX, centerY, startDistance, endDistance, duration } = normalizePinchParam(param, await this.size());
|
|
@@ -1240,8 +1227,12 @@ const runWdaRequestParamSchema = z.object({
|
|
|
1240
1227
|
endpoint: z.string().describe('WebDriver API endpoint'),
|
|
1241
1228
|
data: z.object({}).passthrough().optional().describe('Optional request body data as JSON object')
|
|
1242
1229
|
});
|
|
1243
|
-
const launchParamSchema = z.
|
|
1244
|
-
|
|
1230
|
+
const launchParamSchema = z.object({
|
|
1231
|
+
uri: z.string().describe('App name, bundle ID, or URL to launch. Prioritize using the exact bundle ID or URL the user has provided. If none provided, use the accurate app name.')
|
|
1232
|
+
});
|
|
1233
|
+
const terminateParamSchema = z.object({
|
|
1234
|
+
uri: z.string().describe('Bundle ID of the app to terminate (close). Use the exact bundle ID, e.g. com.apple.Preferences.')
|
|
1235
|
+
});
|
|
1245
1236
|
const createPlatformActions = (device)=>({
|
|
1246
1237
|
RunWdaRequest: defineAction({
|
|
1247
1238
|
name: 'RunWdaRequest',
|
|
@@ -1259,8 +1250,12 @@ const createPlatformActions = (device)=>({
|
|
|
1259
1250
|
description: 'Launch an iOS app or URL',
|
|
1260
1251
|
interfaceAlias: 'launch',
|
|
1261
1252
|
paramSchema: launchParamSchema,
|
|
1253
|
+
sample: {
|
|
1254
|
+
uri: 'com.apple.Preferences'
|
|
1255
|
+
},
|
|
1262
1256
|
call: async (param)=>{
|
|
1263
|
-
|
|
1257
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Launch requires a non-empty uri parameter');
|
|
1258
|
+
await device.launch(param.uri);
|
|
1264
1259
|
}
|
|
1265
1260
|
}),
|
|
1266
1261
|
Terminate: defineAction({
|
|
@@ -1268,8 +1263,12 @@ const createPlatformActions = (device)=>({
|
|
|
1268
1263
|
description: 'Terminate (close) an iOS app by its bundle ID',
|
|
1269
1264
|
interfaceAlias: 'terminate',
|
|
1270
1265
|
paramSchema: terminateParamSchema,
|
|
1266
|
+
sample: {
|
|
1267
|
+
uri: 'com.apple.Preferences'
|
|
1268
|
+
},
|
|
1271
1269
|
call: async (param)=>{
|
|
1272
|
-
|
|
1270
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1271
|
+
await device.terminate(param.uri);
|
|
1273
1272
|
}
|
|
1274
1273
|
}),
|
|
1275
1274
|
IOSHomeButton: defineAction({
|
|
@@ -1299,17 +1298,27 @@ function agent_define_property(obj, key, value) {
|
|
|
1299
1298
|
}
|
|
1300
1299
|
const debugAgent = getDebug('ios:agent');
|
|
1301
1300
|
class IOSAgent extends Agent {
|
|
1301
|
+
async launch(uri) {
|
|
1302
|
+
const action = this.wrapActionInActionSpace('Launch');
|
|
1303
|
+
return action({
|
|
1304
|
+
uri
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
async terminate(uri) {
|
|
1308
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1309
|
+
return action({
|
|
1310
|
+
uri
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1302
1313
|
createActionWrapper(name) {
|
|
1303
1314
|
const action = this.wrapActionInActionSpace(name);
|
|
1304
1315
|
return (...args)=>action(args[0]);
|
|
1305
1316
|
}
|
|
1306
1317
|
constructor(device, opts){
|
|
1307
|
-
super(device, opts), agent_define_property(this, "
|
|
1318
|
+
super(device, opts), agent_define_property(this, "runWdaRequest", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "appSwitcher", void 0), agent_define_property(this, "appNameMapping", void 0);
|
|
1308
1319
|
this.appNameMapping = mergeAndNormalizeAppNameMapping(defaultAppNameMapping, opts?.appNameMapping);
|
|
1309
1320
|
device.setAppNameMapping(this.appNameMapping);
|
|
1310
|
-
this.launch = this.createActionWrapper('Launch');
|
|
1311
1321
|
this.runWdaRequest = this.createActionWrapper('RunWdaRequest');
|
|
1312
|
-
this.terminate = this.createActionWrapper('Terminate');
|
|
1313
1322
|
this.home = this.createActionWrapper('IOSHomeButton');
|
|
1314
1323
|
this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
|
|
1315
1324
|
}
|
|
@@ -1411,7 +1420,7 @@ class IOSMCPServer extends BaseMCPServer {
|
|
|
1411
1420
|
constructor(toolsManager){
|
|
1412
1421
|
super({
|
|
1413
1422
|
name: '@midscene/ios-mcp',
|
|
1414
|
-
version: "1.7.
|
|
1423
|
+
version: "1.7.6-beta-20260423130231.0",
|
|
1415
1424
|
description: 'Control the iOS device using natural language commands'
|
|
1416
1425
|
}, toolsManager);
|
|
1417
1426
|
}
|
package/dist/lib/bin.js
CHANGED
|
@@ -769,24 +769,11 @@ class device_IOSDevice {
|
|
|
769
769
|
await (0, core_utils_namespaceObject.sleep)(100);
|
|
770
770
|
}
|
|
771
771
|
}),
|
|
772
|
-
(0, device_namespaceObject.
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
locate: (0, core_namespaceObject.getMidsceneLocationSchema)().describe('The element to be long pressed')
|
|
778
|
-
}),
|
|
779
|
-
sample: {
|
|
780
|
-
locate: {
|
|
781
|
-
prompt: 'the message bubble'
|
|
782
|
-
}
|
|
783
|
-
},
|
|
784
|
-
call: async (param)=>{
|
|
785
|
-
const element = param.locate;
|
|
786
|
-
external_node_assert_default()(element, 'LongPress requires an element to be located');
|
|
787
|
-
const [x, y] = element.center;
|
|
788
|
-
await this.longPress(x, y, param?.duration);
|
|
789
|
-
}
|
|
772
|
+
(0, device_namespaceObject.defineActionLongPress)(async (param)=>{
|
|
773
|
+
const element = param.locate;
|
|
774
|
+
external_node_assert_default()(element, 'LongPress requires an element to be located');
|
|
775
|
+
const [x, y] = element.center;
|
|
776
|
+
await this.longPress(x, y, param?.duration);
|
|
790
777
|
}),
|
|
791
778
|
(0, device_namespaceObject.defineActionPinch)(async (param)=>{
|
|
792
779
|
const { centerX, centerY, startDistance, endDistance, duration } = (0, device_namespaceObject.normalizePinchParam)(param, await this.size());
|
|
@@ -1266,8 +1253,12 @@ const runWdaRequestParamSchema = core_namespaceObject.z.object({
|
|
|
1266
1253
|
endpoint: core_namespaceObject.z.string().describe('WebDriver API endpoint'),
|
|
1267
1254
|
data: core_namespaceObject.z.object({}).passthrough().optional().describe('Optional request body data as JSON object')
|
|
1268
1255
|
});
|
|
1269
|
-
const launchParamSchema = core_namespaceObject.z.
|
|
1270
|
-
|
|
1256
|
+
const launchParamSchema = core_namespaceObject.z.object({
|
|
1257
|
+
uri: core_namespaceObject.z.string().describe('App name, bundle ID, or URL to launch. Prioritize using the exact bundle ID or URL the user has provided. If none provided, use the accurate app name.')
|
|
1258
|
+
});
|
|
1259
|
+
const terminateParamSchema = core_namespaceObject.z.object({
|
|
1260
|
+
uri: core_namespaceObject.z.string().describe('Bundle ID of the app to terminate (close). Use the exact bundle ID, e.g. com.apple.Preferences.')
|
|
1261
|
+
});
|
|
1271
1262
|
const createPlatformActions = (device)=>({
|
|
1272
1263
|
RunWdaRequest: (0, device_namespaceObject.defineAction)({
|
|
1273
1264
|
name: 'RunWdaRequest',
|
|
@@ -1285,8 +1276,12 @@ const createPlatformActions = (device)=>({
|
|
|
1285
1276
|
description: 'Launch an iOS app or URL',
|
|
1286
1277
|
interfaceAlias: 'launch',
|
|
1287
1278
|
paramSchema: launchParamSchema,
|
|
1279
|
+
sample: {
|
|
1280
|
+
uri: 'com.apple.Preferences'
|
|
1281
|
+
},
|
|
1288
1282
|
call: async (param)=>{
|
|
1289
|
-
|
|
1283
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Launch requires a non-empty uri parameter');
|
|
1284
|
+
await device.launch(param.uri);
|
|
1290
1285
|
}
|
|
1291
1286
|
}),
|
|
1292
1287
|
Terminate: (0, device_namespaceObject.defineAction)({
|
|
@@ -1294,8 +1289,12 @@ const createPlatformActions = (device)=>({
|
|
|
1294
1289
|
description: 'Terminate (close) an iOS app by its bundle ID',
|
|
1295
1290
|
interfaceAlias: 'terminate',
|
|
1296
1291
|
paramSchema: terminateParamSchema,
|
|
1292
|
+
sample: {
|
|
1293
|
+
uri: 'com.apple.Preferences'
|
|
1294
|
+
},
|
|
1297
1295
|
call: async (param)=>{
|
|
1298
|
-
|
|
1296
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1297
|
+
await device.terminate(param.uri);
|
|
1299
1298
|
}
|
|
1300
1299
|
}),
|
|
1301
1300
|
IOSHomeButton: (0, device_namespaceObject.defineAction)({
|
|
@@ -1325,17 +1324,27 @@ function agent_define_property(obj, key, value) {
|
|
|
1325
1324
|
}
|
|
1326
1325
|
(0, logger_namespaceObject.getDebug)('ios:agent');
|
|
1327
1326
|
class IOSAgent extends agent_namespaceObject.Agent {
|
|
1327
|
+
async launch(uri) {
|
|
1328
|
+
const action = this.wrapActionInActionSpace('Launch');
|
|
1329
|
+
return action({
|
|
1330
|
+
uri
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
async terminate(uri) {
|
|
1334
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1335
|
+
return action({
|
|
1336
|
+
uri
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1328
1339
|
createActionWrapper(name) {
|
|
1329
1340
|
const action = this.wrapActionInActionSpace(name);
|
|
1330
1341
|
return (...args)=>action(args[0]);
|
|
1331
1342
|
}
|
|
1332
1343
|
constructor(device, opts){
|
|
1333
|
-
super(device, opts), agent_define_property(this, "
|
|
1344
|
+
super(device, opts), agent_define_property(this, "runWdaRequest", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "appSwitcher", void 0), agent_define_property(this, "appNameMapping", void 0);
|
|
1334
1345
|
this.appNameMapping = (0, utils_namespaceObject.mergeAndNormalizeAppNameMapping)(defaultAppNameMapping, opts?.appNameMapping);
|
|
1335
1346
|
device.setAppNameMapping(this.appNameMapping);
|
|
1336
|
-
this.launch = this.createActionWrapper('Launch');
|
|
1337
1347
|
this.runWdaRequest = this.createActionWrapper('RunWdaRequest');
|
|
1338
|
-
this.terminate = this.createActionWrapper('Terminate');
|
|
1339
1348
|
this.home = this.createActionWrapper('IOSHomeButton');
|
|
1340
1349
|
this.appSwitcher = this.createActionWrapper('IOSAppSwitcher');
|
|
1341
1350
|
}
|