@midscene/android 1.8.4-beta-20260521070317.0 → 1.8.4

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
@@ -8,7 +8,6 @@ import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
8
8
  import { Agent } from "@midscene/core/agent";
9
9
  import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
10
10
  import node_assert from "node:assert";
11
- import { Buffer } from "node:buffer";
12
11
  import { execFile } from "node:child_process";
13
12
  import { createDefaultMobileActions, defineAction } from "@midscene/core/device";
14
13
  import { getTmpFile, sleep } from "@midscene/core/utils";
@@ -680,6 +679,9 @@ const debugDevice = (0, logger_.getDebug)('android:device');
680
679
  const warnDevice = (0, logger_.getDebug)('android:device', {
681
680
  console: true
682
681
  });
682
+ function escapeForShell(text) {
683
+ return text.replace(/'/g, "'\\''").replace(/\n/g, '\\n');
684
+ }
683
685
  class AndroidDevice {
684
686
  actionSpace() {
685
687
  const mobileActionContext = {
@@ -913,9 +915,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
913
915
  async execYadb(keyboardContent) {
914
916
  await this.ensureYadb();
915
917
  const adb = await this.getAdb();
916
- const encodedKeyboardContent = Buffer.from(keyboardContent, 'utf8').toString('base64');
917
- await adb.shell(`YADB_INPUT=$(printf '%s' '${encodedKeyboardContent}' | base64 -d); app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -writeClipboard "$YADB_INPUT"`);
918
- await adb.keyevent(279);
918
+ await adb.shell(`app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -keyboard '${keyboardContent}'`);
919
919
  }
920
920
  async getElementsInfo() {
921
921
  return [];
@@ -1434,7 +1434,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1434
1434
  const IME_STRATEGY = (this.options?.imeStrategy || globalConfigManager.getEnvConfigValue(MIDSCENE_ANDROID_IME_STRATEGY)) ?? IME_STRATEGY_YADB_FOR_NON_ASCII;
1435
1435
  const shouldAutoDismissKeyboard = options?.autoDismissKeyboard ?? this.options?.autoDismissKeyboard ?? true;
1436
1436
  const useYadb = IME_STRATEGY === IME_STRATEGY_ALWAYS_YADB || IME_STRATEGY === IME_STRATEGY_YADB_FOR_NON_ASCII && this.shouldUseYadbForText(text);
1437
- if (useYadb) await this.execYadb(text);
1437
+ if (useYadb) await this.execYadb(escapeForShell(text));
1438
1438
  else {
1439
1439
  const segments = text.split('\n');
1440
1440
  for(let i = 0; i < segments.length; i++){
@@ -1988,7 +1988,7 @@ class AndroidMidsceneTools extends BaseMidsceneTools {
1988
1988
  const tools = new AndroidMidsceneTools();
1989
1989
  runToolsCLI(tools, 'midscene-android', {
1990
1990
  stripPrefix: 'android_',
1991
- version: "1.8.4-beta-20260521070317.0",
1991
+ version: "1.8.4",
1992
1992
  extraCommands: createReportCliCommands()
1993
1993
  }).catch((e)=>{
1994
1994
  process.exit(reportCLIError(e));
package/dist/es/index.mjs CHANGED
@@ -3,7 +3,6 @@ import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
3
3
  import * as __rspack_external_node_module_ab9f2194 from "node:module";
4
4
  import * as __rspack_external_node_path_c5b9b54f from "node:path";
5
5
  import node_assert from "node:assert";
6
- import { Buffer } from "node:buffer";
7
6
  import { execFile } from "node:child_process";
8
7
  import { getMidsceneLocationSchema, z } from "@midscene/core";
9
8
  import { createDefaultMobileActions, defineAction } from "@midscene/core/device";
@@ -583,6 +582,9 @@ const debugDevice = (0, logger_.getDebug)('android:device');
583
582
  const warnDevice = (0, logger_.getDebug)('android:device', {
584
583
  console: true
585
584
  });
585
+ function escapeForShell(text) {
586
+ return text.replace(/'/g, "'\\''").replace(/\n/g, '\\n');
587
+ }
586
588
  class AndroidDevice {
587
589
  actionSpace() {
588
590
  const mobileActionContext = {
@@ -816,9 +818,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
816
818
  async execYadb(keyboardContent) {
817
819
  await this.ensureYadb();
818
820
  const adb = await this.getAdb();
819
- const encodedKeyboardContent = Buffer.from(keyboardContent, 'utf8').toString('base64');
820
- await adb.shell(`YADB_INPUT=$(printf '%s' '${encodedKeyboardContent}' | base64 -d); app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -writeClipboard "$YADB_INPUT"`);
821
- await adb.keyevent(279);
821
+ await adb.shell(`app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -keyboard '${keyboardContent}'`);
822
822
  }
823
823
  async getElementsInfo() {
824
824
  return [];
@@ -1337,7 +1337,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1337
1337
  const IME_STRATEGY = (this.options?.imeStrategy || globalConfigManager.getEnvConfigValue(MIDSCENE_ANDROID_IME_STRATEGY)) ?? IME_STRATEGY_YADB_FOR_NON_ASCII;
1338
1338
  const shouldAutoDismissKeyboard = options?.autoDismissKeyboard ?? this.options?.autoDismissKeyboard ?? true;
1339
1339
  const useYadb = IME_STRATEGY === IME_STRATEGY_ALWAYS_YADB || IME_STRATEGY === IME_STRATEGY_YADB_FOR_NON_ASCII && this.shouldUseYadbForText(text);
1340
- if (useYadb) await this.execYadb(text);
1340
+ if (useYadb) await this.execYadb(escapeForShell(text));
1341
1341
  else {
1342
1342
  const segments = text.split('\n');
1343
1343
  for(let i = 0; i < segments.length; i++){
@@ -6,7 +6,6 @@ import { BaseMCPServer, createMCPServerLauncher } from "@midscene/shared/mcp";
6
6
  import { Agent } from "@midscene/core/agent";
7
7
  import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
8
8
  import node_assert from "node:assert";
9
- import { Buffer } from "node:buffer";
10
9
  import { execFile } from "node:child_process";
11
10
  import { getMidsceneLocationSchema, z } from "@midscene/core";
12
11
  import { createDefaultMobileActions, defineAction } from "@midscene/core/device";
@@ -680,6 +679,9 @@ const debugDevice = (0, logger_.getDebug)('android:device');
680
679
  const warnDevice = (0, logger_.getDebug)('android:device', {
681
680
  console: true
682
681
  });
682
+ function escapeForShell(text) {
683
+ return text.replace(/'/g, "'\\''").replace(/\n/g, '\\n');
684
+ }
683
685
  class AndroidDevice {
684
686
  actionSpace() {
685
687
  const mobileActionContext = {
@@ -913,9 +915,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
913
915
  async execYadb(keyboardContent) {
914
916
  await this.ensureYadb();
915
917
  const adb = await this.getAdb();
916
- const encodedKeyboardContent = Buffer.from(keyboardContent, 'utf8').toString('base64');
917
- await adb.shell(`YADB_INPUT=$(printf '%s' '${encodedKeyboardContent}' | base64 -d); app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -writeClipboard "$YADB_INPUT"`);
918
- await adb.keyevent(279);
918
+ await adb.shell(`app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -keyboard '${keyboardContent}'`);
919
919
  }
920
920
  async getElementsInfo() {
921
921
  return [];
@@ -1434,7 +1434,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1434
1434
  const IME_STRATEGY = (this.options?.imeStrategy || globalConfigManager.getEnvConfigValue(MIDSCENE_ANDROID_IME_STRATEGY)) ?? IME_STRATEGY_YADB_FOR_NON_ASCII;
1435
1435
  const shouldAutoDismissKeyboard = options?.autoDismissKeyboard ?? this.options?.autoDismissKeyboard ?? true;
1436
1436
  const useYadb = IME_STRATEGY === IME_STRATEGY_ALWAYS_YADB || IME_STRATEGY === IME_STRATEGY_YADB_FOR_NON_ASCII && this.shouldUseYadbForText(text);
1437
- if (useYadb) await this.execYadb(text);
1437
+ if (useYadb) await this.execYadb(escapeForShell(text));
1438
1438
  else {
1439
1439
  const segments = text.split('\n');
1440
1440
  for(let i = 0; i < segments.length; i++){
@@ -1992,7 +1992,7 @@ class AndroidMCPServer extends BaseMCPServer {
1992
1992
  constructor(toolsManager){
1993
1993
  super({
1994
1994
  name: '@midscene/android-mcp',
1995
- version: "1.8.4-beta-20260521070317.0",
1995
+ version: "1.8.4",
1996
1996
  description: 'Control the Android device using natural language commands'
1997
1997
  }, toolsManager);
1998
1998
  }
package/dist/lib/cli.js CHANGED
@@ -550,7 +550,6 @@ var __webpack_exports__ = {};
550
550
  };
551
551
  const external_node_assert_namespaceObject = require("node:assert");
552
552
  var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
553
- const external_node_buffer_namespaceObject = require("node:buffer");
554
553
  const external_node_child_process_namespaceObject = require("node:child_process");
555
554
  var external_node_fs_ = __webpack_require__("node:fs");
556
555
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_);
@@ -695,6 +694,9 @@ var __webpack_exports__ = {};
695
694
  const warnDevice = (0, logger_.getDebug)('android:device', {
696
695
  console: true
697
696
  });
697
+ function escapeForShell(text) {
698
+ return text.replace(/'/g, "'\\''").replace(/\n/g, '\\n');
699
+ }
698
700
  class AndroidDevice {
699
701
  actionSpace() {
700
702
  const mobileActionContext = {
@@ -928,9 +930,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
928
930
  async execYadb(keyboardContent) {
929
931
  await this.ensureYadb();
930
932
  const adb = await this.getAdb();
931
- const encodedKeyboardContent = external_node_buffer_namespaceObject.Buffer.from(keyboardContent, 'utf8').toString('base64');
932
- await adb.shell(`YADB_INPUT=$(printf '%s' '${encodedKeyboardContent}' | base64 -d); app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -writeClipboard "$YADB_INPUT"`);
933
- await adb.keyevent(279);
933
+ await adb.shell(`app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -keyboard '${keyboardContent}'`);
934
934
  }
935
935
  async getElementsInfo() {
936
936
  return [];
@@ -1449,7 +1449,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1449
1449
  const IME_STRATEGY = (this.options?.imeStrategy || env_namespaceObject.globalConfigManager.getEnvConfigValue(env_namespaceObject.MIDSCENE_ANDROID_IME_STRATEGY)) ?? IME_STRATEGY_YADB_FOR_NON_ASCII;
1450
1450
  const shouldAutoDismissKeyboard = options?.autoDismissKeyboard ?? this.options?.autoDismissKeyboard ?? true;
1451
1451
  const useYadb = IME_STRATEGY === IME_STRATEGY_ALWAYS_YADB || IME_STRATEGY === IME_STRATEGY_YADB_FOR_NON_ASCII && this.shouldUseYadbForText(text);
1452
- if (useYadb) await this.execYadb(text);
1452
+ if (useYadb) await this.execYadb(escapeForShell(text));
1453
1453
  else {
1454
1454
  const segments = text.split('\n');
1455
1455
  for(let i = 0; i < segments.length; i++){
@@ -2003,7 +2003,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2003
2003
  const tools = new AndroidMidsceneTools();
2004
2004
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-android', {
2005
2005
  stripPrefix: 'android_',
2006
- version: "1.8.4-beta-20260521070317.0",
2006
+ version: "1.8.4",
2007
2007
  extraCommands: (0, core_namespaceObject.createReportCliCommands)()
2008
2008
  }).catch((e)=>{
2009
2009
  process.exit((0, cli_namespaceObject.reportCLIError)(e));
package/dist/lib/index.js CHANGED
@@ -469,7 +469,6 @@ var __webpack_exports__ = {};
469
469
  });
470
470
  const external_node_assert_namespaceObject = require("node:assert");
471
471
  var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
472
- const external_node_buffer_namespaceObject = require("node:buffer");
473
472
  const external_node_child_process_namespaceObject = require("node:child_process");
474
473
  var external_node_fs_ = __webpack_require__("node:fs");
475
474
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_);
@@ -617,6 +616,9 @@ var __webpack_exports__ = {};
617
616
  const warnDevice = (0, logger_.getDebug)('android:device', {
618
617
  console: true
619
618
  });
619
+ function escapeForShell(text) {
620
+ return text.replace(/'/g, "'\\''").replace(/\n/g, '\\n');
621
+ }
620
622
  class AndroidDevice {
621
623
  actionSpace() {
622
624
  const mobileActionContext = {
@@ -850,9 +852,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
850
852
  async execYadb(keyboardContent) {
851
853
  await this.ensureYadb();
852
854
  const adb = await this.getAdb();
853
- const encodedKeyboardContent = external_node_buffer_namespaceObject.Buffer.from(keyboardContent, 'utf8').toString('base64');
854
- await adb.shell(`YADB_INPUT=$(printf '%s' '${encodedKeyboardContent}' | base64 -d); app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -writeClipboard "$YADB_INPUT"`);
855
- await adb.keyevent(279);
855
+ await adb.shell(`app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -keyboard '${keyboardContent}'`);
856
856
  }
857
857
  async getElementsInfo() {
858
858
  return [];
@@ -1371,7 +1371,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1371
1371
  const IME_STRATEGY = (this.options?.imeStrategy || env_namespaceObject.globalConfigManager.getEnvConfigValue(env_namespaceObject.MIDSCENE_ANDROID_IME_STRATEGY)) ?? IME_STRATEGY_YADB_FOR_NON_ASCII;
1372
1372
  const shouldAutoDismissKeyboard = options?.autoDismissKeyboard ?? this.options?.autoDismissKeyboard ?? true;
1373
1373
  const useYadb = IME_STRATEGY === IME_STRATEGY_ALWAYS_YADB || IME_STRATEGY === IME_STRATEGY_YADB_FOR_NON_ASCII && this.shouldUseYadbForText(text);
1374
- if (useYadb) await this.execYadb(text);
1374
+ if (useYadb) await this.execYadb(escapeForShell(text));
1375
1375
  else {
1376
1376
  const segments = text.split('\n');
1377
1377
  for(let i = 0; i < segments.length; i++){
@@ -564,7 +564,6 @@ var __webpack_exports__ = {};
564
564
  };
565
565
  const external_node_assert_namespaceObject = require("node:assert");
566
566
  var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
567
- const external_node_buffer_namespaceObject = require("node:buffer");
568
567
  const external_node_child_process_namespaceObject = require("node:child_process");
569
568
  var external_node_fs_ = __webpack_require__("node:fs");
570
569
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_);
@@ -710,6 +709,9 @@ var __webpack_exports__ = {};
710
709
  const warnDevice = (0, logger_.getDebug)('android:device', {
711
710
  console: true
712
711
  });
712
+ function escapeForShell(text) {
713
+ return text.replace(/'/g, "'\\''").replace(/\n/g, '\\n');
714
+ }
713
715
  class AndroidDevice {
714
716
  actionSpace() {
715
717
  const mobileActionContext = {
@@ -943,9 +945,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
943
945
  async execYadb(keyboardContent) {
944
946
  await this.ensureYadb();
945
947
  const adb = await this.getAdb();
946
- const encodedKeyboardContent = external_node_buffer_namespaceObject.Buffer.from(keyboardContent, 'utf8').toString('base64');
947
- await adb.shell(`YADB_INPUT=$(printf '%s' '${encodedKeyboardContent}' | base64 -d); app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -writeClipboard "$YADB_INPUT"`);
948
- await adb.keyevent(279);
948
+ await adb.shell(`app_process${this.getDisplayArg()} -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -keyboard '${keyboardContent}'`);
949
949
  }
950
950
  async getElementsInfo() {
951
951
  return [];
@@ -1464,7 +1464,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1464
1464
  const IME_STRATEGY = (this.options?.imeStrategy || env_namespaceObject.globalConfigManager.getEnvConfigValue(env_namespaceObject.MIDSCENE_ANDROID_IME_STRATEGY)) ?? IME_STRATEGY_YADB_FOR_NON_ASCII;
1465
1465
  const shouldAutoDismissKeyboard = options?.autoDismissKeyboard ?? this.options?.autoDismissKeyboard ?? true;
1466
1466
  const useYadb = IME_STRATEGY === IME_STRATEGY_ALWAYS_YADB || IME_STRATEGY === IME_STRATEGY_YADB_FOR_NON_ASCII && this.shouldUseYadbForText(text);
1467
- if (useYadb) await this.execYadb(text);
1467
+ if (useYadb) await this.execYadb(escapeForShell(text));
1468
1468
  else {
1469
1469
  const segments = text.split('\n');
1470
1470
  for(let i = 0; i < segments.length; i++){
@@ -2023,7 +2023,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2023
2023
  constructor(toolsManager){
2024
2024
  super({
2025
2025
  name: '@midscene/android-mcp',
2026
- version: "1.8.4-beta-20260521070317.0",
2026
+ version: "1.8.4",
2027
2027
  description: 'Control the Android device using natural language commands'
2028
2028
  }, toolsManager);
2029
2029
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/android",
3
- "version": "1.8.4-beta-20260521070317.0",
3
+ "version": "1.8.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/midscene.git",
@@ -46,8 +46,8 @@
46
46
  "@yume-chan/stream-extra": "2.1.0",
47
47
  "appium-adb": "12.12.1",
48
48
  "sharp": "^0.34.3",
49
- "@midscene/core": "1.8.4-beta-20260521070317.0",
50
- "@midscene/shared": "1.8.4-beta-20260521070317.0"
49
+ "@midscene/core": "1.8.4",
50
+ "@midscene/shared": "1.8.4"
51
51
  },
52
52
  "optionalDependencies": {
53
53
  "@ffmpeg-installer/ffmpeg": "^1.1.0"
@@ -61,7 +61,7 @@
61
61
  "undici": "^6.0.0",
62
62
  "vitest": "3.0.5",
63
63
  "zod": "^3.25.1",
64
- "@midscene/playground": "1.8.4-beta-20260521070317.0"
64
+ "@midscene/playground": "1.8.4"
65
65
  },
66
66
  "license": "MIT",
67
67
  "scripts": {