@midscene/mcp 1.2.1-beta-20260108154312.0 → 1.2.1-beta-20260109060244.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/index.js CHANGED
@@ -24034,12 +24034,6 @@ var __webpack_modules__ = {
24034
24034
  thought: lib.z.string().describe('The thought of the assertion, like "I can see there are A, B, C elements on the page, which means ... , so the assertion is true"'),
24035
24035
  result: lib.z.boolean().describe('The result of the assertion, true or false')
24036
24036
  });
24037
- lib.z.object({
24038
- millisecond: lib.z.number().default(1000).optional().describe('Sleep duration in milliseconds, defaults to 1000ms (1 second)')
24039
- });
24040
- lib.z.object({
24041
- message: lib.z.string().optional().describe('The conclusion, data, or return value that the user needs. This message will be provided to the user when the task is finalized.')
24042
- });
24043
24037
  require("node:assert");
24044
24038
  __webpack_require__("../../node_modules/.pnpm/semver@7.5.2/node_modules/semver/index.js");
24045
24039
  __webpack_require__("../../node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js");
@@ -24093,7 +24087,7 @@ var __webpack_modules__ = {
24093
24087
  }
24094
24088
  return false;
24095
24089
  }
24096
- function getZodTypeName(field, locatorTypeDescription) {
24090
+ function zod_schema_utils_getZodTypeName(field, locatorTypeDescription) {
24097
24091
  const actualField = unwrapZodField(field);
24098
24092
  const fieldTypeName = actualField._def?.typeName;
24099
24093
  if ('ZodString' === fieldTypeName) return 'string';
@@ -24111,14 +24105,14 @@ var __webpack_modules__ = {
24111
24105
  if ('ZodUnion' === fieldTypeName) {
24112
24106
  const options = actualField._def?.options;
24113
24107
  if (options && options.length > 0) {
24114
- const types = options.map((opt)=>getZodTypeName(opt, locatorTypeDescription));
24108
+ const types = options.map((opt)=>zod_schema_utils_getZodTypeName(opt, locatorTypeDescription));
24115
24109
  return types.join(' | ');
24116
24110
  }
24117
24111
  return 'union';
24118
24112
  }
24119
24113
  return 'unknown';
24120
24114
  }
24121
- function getZodDescription(field) {
24115
+ function zod_schema_utils_getZodDescription(field) {
24122
24116
  if ("description" in field) return field.description || null;
24123
24117
  const actualField = unwrapZodField(field);
24124
24118
  if ("description" in actualField) return actualField.description || null;
@@ -24134,16 +24128,16 @@ var __webpack_modules__ = {
24134
24128
  const schema = action.paramSchema;
24135
24129
  const isZodObjectType = schema._def?.typeName === 'ZodObject';
24136
24130
  if (!isZodObjectType || !schema.shape) {
24137
- const typeName = getZodTypeName(schema);
24138
- const description = getZodDescription(schema);
24131
+ const typeName = zod_schema_utils_getZodTypeName(schema);
24132
+ const description = zod_schema_utils_getZodDescription(schema);
24139
24133
  const paramDesc = description ? `${typeName} - ${description}` : typeName;
24140
24134
  return `${action.name} action, ${actionDesc}. Parameter: ${paramDesc}`;
24141
24135
  }
24142
24136
  const paramDescriptions = [];
24143
24137
  for (const [key, field] of Object.entries(schema.shape))if (field && 'object' == typeof field) {
24144
24138
  const isFieldOptional = 'function' == typeof field.isOptional && field.isOptional();
24145
- const typeName = getZodTypeName(field);
24146
- const description = getZodDescription(field);
24139
+ const typeName = zod_schema_utils_getZodTypeName(field);
24140
+ const description = zod_schema_utils_getZodDescription(field);
24147
24141
  let paramStr = `${key}${isFieldOptional ? '?' : ''} (${typeName})`;
24148
24142
  if (description) paramStr += ` - ${description}`;
24149
24143
  paramDescriptions.push(paramStr);
@@ -24154,7 +24148,7 @@ var __webpack_modules__ = {
24154
24148
  function isZodOptional(value) {
24155
24149
  return '_def' in value && value._def?.typeName === 'ZodOptional';
24156
24150
  }
24157
- function isZodObject(value) {
24151
+ function tool_generator_isZodObject(value) {
24158
24152
  return '_def' in value && value._def?.typeName === 'ZodObject' && 'shape' in value;
24159
24153
  }
24160
24154
  function unwrapOptional(value) {
@@ -24168,7 +24162,7 @@ var __webpack_modules__ = {
24168
24162
  };
24169
24163
  }
24170
24164
  function isLocateField(value) {
24171
- if (!isZodObject(value)) return false;
24165
+ if (!tool_generator_isZodObject(value)) return false;
24172
24166
  return 'prompt' in value.shape;
24173
24167
  }
24174
24168
  function makePromptOptional(value, wrapInOptional) {
@@ -24182,7 +24176,7 @@ var __webpack_modules__ = {
24182
24176
  }
24183
24177
  function transformSchemaField(key, value) {
24184
24178
  const { innerValue, isOptional } = unwrapOptional(value);
24185
- if (isZodObject(innerValue) && isLocateField(innerValue)) return [
24179
+ if (tool_generator_isZodObject(innerValue) && isLocateField(innerValue)) return [
24186
24180
  key,
24187
24181
  makePromptOptional(innerValue, isOptional)
24188
24182
  ];
@@ -24194,7 +24188,7 @@ var __webpack_modules__ = {
24194
24188
  function extractActionSchema(paramSchema) {
24195
24189
  if (!paramSchema) return {};
24196
24190
  const schema = paramSchema;
24197
- if (!isZodObject(schema)) return schema;
24191
+ if (!tool_generator_isZodObject(schema)) return schema;
24198
24192
  return Object.fromEntries(Object.entries(schema.shape).map(([key, value])=>transformSchemaField(key, value)));
24199
24193
  }
24200
24194
  function serializeArgsToDescription(args) {
@@ -24292,8 +24286,7 @@ var __webpack_modules__ = {
24292
24286
  console.error(`Error in handler for "${action.name}":`, errorMessage);
24293
24287
  return createErrorResult(`Failed to get agent or execute action "${action.name}": ${errorMessage}`);
24294
24288
  }
24295
- },
24296
- autoDestroy: true
24289
+ }
24297
24290
  };
24298
24291
  });
24299
24292
  }
@@ -24323,8 +24316,7 @@ var __webpack_modules__ = {
24323
24316
  console.error('Error taking screenshot:', errorMessage);
24324
24317
  return createErrorResult(`Failed to capture screenshot: ${errorMessage}`);
24325
24318
  }
24326
- },
24327
- autoDestroy: true
24319
+ }
24328
24320
  }
24329
24321
  ];
24330
24322
  }
@@ -24368,27 +24360,9 @@ var __webpack_modules__ = {
24368
24360
  attachToServer(server) {
24369
24361
  this.mcpServer = server;
24370
24362
  if (0 === this.toolDefinitions.length) base_tools_debug('Warning: No tools to register. Tools may be initialized lazily.');
24371
- for (const toolDef of this.toolDefinitions)if (toolDef.autoDestroy) this.toolWithAutoDestroy(toolDef.name, toolDef.description, toolDef.schema, toolDef.handler);
24372
- else this.mcpServer.tool(toolDef.name, toolDef.description, toolDef.schema, toolDef.handler);
24363
+ for (const toolDef of this.toolDefinitions)this.mcpServer.tool(toolDef.name, toolDef.description, toolDef.schema, toolDef.handler);
24373
24364
  base_tools_debug('Registered', this.toolDefinitions.length, 'tools');
24374
24365
  }
24375
- toolWithAutoDestroy(name, description, schema, handler) {
24376
- if (!this.mcpServer) throw new Error('MCP server not attached');
24377
- this.mcpServer.tool(name, description, schema, async (...args)=>{
24378
- try {
24379
- return await handler(...args);
24380
- } finally{
24381
- if (!process.env.MIDSCENE_MCP_DISABLE_AGENT_AUTO_DESTROY) {
24382
- try {
24383
- await this.agent?.destroy?.();
24384
- } catch (error) {
24385
- base_tools_debug('Failed to destroy agent during cleanup:', error);
24386
- }
24387
- this.agent = void 0;
24388
- }
24389
- }
24390
- });
24391
- }
24392
24366
  async closeBrowser() {
24393
24367
  await this.agent?.destroy?.();
24394
24368
  }
@@ -24568,8 +24542,7 @@ For more information, visit: https://midscenejs.com/mcp-migration
24568
24542
  text: DEPRECATION_MESSAGE
24569
24543
  }
24570
24544
  ]
24571
- }),
24572
- autoDestroy: false
24545
+ })
24573
24546
  }));
24574
24547
  }
24575
24548
  }
@@ -24580,7 +24553,7 @@ For more information, visit: https://midscenejs.com/mcp-migration
24580
24553
  constructor(){
24581
24554
  super({
24582
24555
  name: '@midscene/mcp',
24583
- version: '1.2.1-beta-20260108154312.0',
24556
+ version: '1.2.1-beta-20260109060244.0',
24584
24557
  description: 'Deprecated - Use @midscene/web-bridge-mcp, @midscene/android-mcp, or @midscene/ios-mcp'
24585
24558
  });
24586
24559
  }
package/dist/server.js CHANGED
@@ -31234,12 +31234,6 @@ var __webpack_exports__ = {};
31234
31234
  thought: lib.z.string().describe('The thought of the assertion, like "I can see there are A, B, C elements on the page, which means ... , so the assertion is true"'),
31235
31235
  result: lib.z.boolean().describe('The result of the assertion, true or false')
31236
31236
  });
31237
- lib.z.object({
31238
- millisecond: lib.z.number().default(1000).optional().describe('Sleep duration in milliseconds, defaults to 1000ms (1 second)')
31239
- });
31240
- lib.z.object({
31241
- message: lib.z.string().optional().describe('The conclusion, data, or return value that the user needs. This message will be provided to the user when the task is finalized.')
31242
- });
31243
31237
  require("node:assert");
31244
31238
  __webpack_require__("../../node_modules/.pnpm/semver@7.5.2/node_modules/semver/index.js");
31245
31239
  __webpack_require__("../../node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js");
@@ -31293,7 +31287,7 @@ var __webpack_exports__ = {};
31293
31287
  }
31294
31288
  return false;
31295
31289
  }
31296
- function getZodTypeName(field, locatorTypeDescription) {
31290
+ function zod_schema_utils_getZodTypeName(field, locatorTypeDescription) {
31297
31291
  const actualField = unwrapZodField(field);
31298
31292
  const fieldTypeName = actualField._def?.typeName;
31299
31293
  if ('ZodString' === fieldTypeName) return 'string';
@@ -31311,14 +31305,14 @@ var __webpack_exports__ = {};
31311
31305
  if ('ZodUnion' === fieldTypeName) {
31312
31306
  const options = actualField._def?.options;
31313
31307
  if (options && options.length > 0) {
31314
- const types = options.map((opt)=>getZodTypeName(opt, locatorTypeDescription));
31308
+ const types = options.map((opt)=>zod_schema_utils_getZodTypeName(opt, locatorTypeDescription));
31315
31309
  return types.join(' | ');
31316
31310
  }
31317
31311
  return 'union';
31318
31312
  }
31319
31313
  return 'unknown';
31320
31314
  }
31321
- function getZodDescription(field) {
31315
+ function zod_schema_utils_getZodDescription(field) {
31322
31316
  if ("description" in field) return field.description || null;
31323
31317
  const actualField = unwrapZodField(field);
31324
31318
  if ("description" in actualField) return actualField.description || null;
@@ -31334,16 +31328,16 @@ var __webpack_exports__ = {};
31334
31328
  const schema = action.paramSchema;
31335
31329
  const isZodObjectType = schema._def?.typeName === 'ZodObject';
31336
31330
  if (!isZodObjectType || !schema.shape) {
31337
- const typeName = getZodTypeName(schema);
31338
- const description = getZodDescription(schema);
31331
+ const typeName = zod_schema_utils_getZodTypeName(schema);
31332
+ const description = zod_schema_utils_getZodDescription(schema);
31339
31333
  const paramDesc = description ? `${typeName} - ${description}` : typeName;
31340
31334
  return `${action.name} action, ${actionDesc}. Parameter: ${paramDesc}`;
31341
31335
  }
31342
31336
  const paramDescriptions = [];
31343
31337
  for (const [key, field] of Object.entries(schema.shape))if (field && 'object' == typeof field) {
31344
31338
  const isFieldOptional = 'function' == typeof field.isOptional && field.isOptional();
31345
- const typeName = getZodTypeName(field);
31346
- const description = getZodDescription(field);
31339
+ const typeName = zod_schema_utils_getZodTypeName(field);
31340
+ const description = zod_schema_utils_getZodDescription(field);
31347
31341
  let paramStr = `${key}${isFieldOptional ? '?' : ''} (${typeName})`;
31348
31342
  if (description) paramStr += ` - ${description}`;
31349
31343
  paramDescriptions.push(paramStr);
@@ -31354,7 +31348,7 @@ var __webpack_exports__ = {};
31354
31348
  function isZodOptional(value) {
31355
31349
  return '_def' in value && value._def?.typeName === 'ZodOptional';
31356
31350
  }
31357
- function isZodObject(value) {
31351
+ function tool_generator_isZodObject(value) {
31358
31352
  return '_def' in value && value._def?.typeName === 'ZodObject' && 'shape' in value;
31359
31353
  }
31360
31354
  function unwrapOptional(value) {
@@ -31368,7 +31362,7 @@ var __webpack_exports__ = {};
31368
31362
  };
31369
31363
  }
31370
31364
  function isLocateField(value) {
31371
- if (!isZodObject(value)) return false;
31365
+ if (!tool_generator_isZodObject(value)) return false;
31372
31366
  return 'prompt' in value.shape;
31373
31367
  }
31374
31368
  function makePromptOptional(value, wrapInOptional) {
@@ -31382,7 +31376,7 @@ var __webpack_exports__ = {};
31382
31376
  }
31383
31377
  function transformSchemaField(key, value) {
31384
31378
  const { innerValue, isOptional } = unwrapOptional(value);
31385
- if (isZodObject(innerValue) && isLocateField(innerValue)) return [
31379
+ if (tool_generator_isZodObject(innerValue) && isLocateField(innerValue)) return [
31386
31380
  key,
31387
31381
  makePromptOptional(innerValue, isOptional)
31388
31382
  ];
@@ -31394,7 +31388,7 @@ var __webpack_exports__ = {};
31394
31388
  function extractActionSchema(paramSchema) {
31395
31389
  if (!paramSchema) return {};
31396
31390
  const schema = paramSchema;
31397
- if (!isZodObject(schema)) return schema;
31391
+ if (!tool_generator_isZodObject(schema)) return schema;
31398
31392
  return Object.fromEntries(Object.entries(schema.shape).map(([key, value])=>transformSchemaField(key, value)));
31399
31393
  }
31400
31394
  function serializeArgsToDescription(args) {
@@ -31492,8 +31486,7 @@ var __webpack_exports__ = {};
31492
31486
  console.error(`Error in handler for "${action.name}":`, errorMessage);
31493
31487
  return createErrorResult(`Failed to get agent or execute action "${action.name}": ${errorMessage}`);
31494
31488
  }
31495
- },
31496
- autoDestroy: true
31489
+ }
31497
31490
  };
31498
31491
  });
31499
31492
  }
@@ -31523,8 +31516,7 @@ var __webpack_exports__ = {};
31523
31516
  console.error('Error taking screenshot:', errorMessage);
31524
31517
  return createErrorResult(`Failed to capture screenshot: ${errorMessage}`);
31525
31518
  }
31526
- },
31527
- autoDestroy: true
31519
+ }
31528
31520
  }
31529
31521
  ];
31530
31522
  }
@@ -31568,27 +31560,9 @@ var __webpack_exports__ = {};
31568
31560
  attachToServer(server) {
31569
31561
  this.mcpServer = server;
31570
31562
  if (0 === this.toolDefinitions.length) base_tools_debug('Warning: No tools to register. Tools may be initialized lazily.');
31571
- for (const toolDef of this.toolDefinitions)if (toolDef.autoDestroy) this.toolWithAutoDestroy(toolDef.name, toolDef.description, toolDef.schema, toolDef.handler);
31572
- else this.mcpServer.tool(toolDef.name, toolDef.description, toolDef.schema, toolDef.handler);
31563
+ for (const toolDef of this.toolDefinitions)this.mcpServer.tool(toolDef.name, toolDef.description, toolDef.schema, toolDef.handler);
31573
31564
  base_tools_debug('Registered', this.toolDefinitions.length, 'tools');
31574
31565
  }
31575
- toolWithAutoDestroy(name, description, schema, handler) {
31576
- if (!this.mcpServer) throw new Error('MCP server not attached');
31577
- this.mcpServer.tool(name, description, schema, async (...args)=>{
31578
- try {
31579
- return await handler(...args);
31580
- } finally{
31581
- if (!process.env.MIDSCENE_MCP_DISABLE_AGENT_AUTO_DESTROY) {
31582
- try {
31583
- await this.agent?.destroy?.();
31584
- } catch (error) {
31585
- base_tools_debug('Failed to destroy agent during cleanup:', error);
31586
- }
31587
- this.agent = void 0;
31588
- }
31589
- }
31590
- });
31591
- }
31592
31566
  async closeBrowser() {
31593
31567
  await this.agent?.destroy?.();
31594
31568
  }
@@ -31768,8 +31742,7 @@ For more information, visit: https://midscenejs.com/mcp-migration
31768
31742
  text: DEPRECATION_MESSAGE
31769
31743
  }
31770
31744
  ]
31771
- }),
31772
- autoDestroy: false
31745
+ })
31773
31746
  }));
31774
31747
  }
31775
31748
  }
@@ -31780,7 +31753,7 @@ For more information, visit: https://midscenejs.com/mcp-migration
31780
31753
  constructor(){
31781
31754
  super({
31782
31755
  name: '@midscene/mcp',
31783
- version: '1.2.1-beta-20260108154312.0',
31756
+ version: '1.2.1-beta-20260109060244.0',
31784
31757
  description: 'Deprecated - Use @midscene/web-bridge-mcp, @midscene/android-mcp, or @midscene/ios-mcp'
31785
31758
  });
31786
31759
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/mcp",
3
- "version": "1.2.1-beta-20260108154312.0",
3
+ "version": "1.2.1-beta-20260109060244.0",
4
4
  "description": "Deprecated - Use @midscene/web-bridge-mcp, @midscene/android-mcp, or @midscene/ios-mcp",
5
5
  "bin": "dist/index.js",
6
6
  "files": [
@@ -25,11 +25,11 @@
25
25
  "@rslib/core": "^0.18.3",
26
26
  "@types/node": "^18.0.0",
27
27
  "typescript": "^5.8.3",
28
- "@midscene/android": "1.2.1-beta-20260108154312.0",
28
+ "@midscene/android": "1.2.1-beta-20260109060244.0",
29
29
  "@midscene/report": "1.0.0",
30
- "@midscene/core": "1.2.1-beta-20260108154312.0",
31
- "@midscene/shared": "1.2.1-beta-20260108154312.0",
32
- "@midscene/web": "1.2.1-beta-20260108154312.0"
30
+ "@midscene/core": "1.2.1-beta-20260109060244.0",
31
+ "@midscene/shared": "1.2.1-beta-20260109060244.0",
32
+ "@midscene/web": "1.2.1-beta-20260109060244.0"
33
33
  },
34
34
  "license": "MIT",
35
35
  "scripts": {