@midscene/android 1.5.3 → 1.5.4-beta-20260310084708.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 +5 -1
- package/dist/es/index.mjs +59 -1
- package/dist/es/mcp-server.mjs +4 -1
- package/dist/lib/cli.js +5 -1
- package/dist/lib/index.js +61 -0
- package/dist/lib/mcp-server.js +4 -1
- package/dist/types/index.d.ts +15 -0
- package/package.json +4 -4
package/dist/es/cli.mjs
CHANGED
|
@@ -961,6 +961,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
961
961
|
}
|
|
962
962
|
async getScreenSize() {
|
|
963
963
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
964
|
+
debugDevice(`getScreenSize: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedSize=${!!this.cachedScreenSize}`);
|
|
964
965
|
if (shouldCache && this.cachedScreenSize) return this.cachedScreenSize;
|
|
965
966
|
const adb = await this.getAdb();
|
|
966
967
|
if ('number' == typeof this.options?.displayId) try {
|
|
@@ -1094,6 +1095,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1094
1095
|
}
|
|
1095
1096
|
async getDisplayOrientation() {
|
|
1096
1097
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1098
|
+
debugDevice(`getDisplayOrientation: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedOrientation=${null !== this.cachedOrientation}`);
|
|
1097
1099
|
if (shouldCache && null !== this.cachedOrientation) return this.cachedOrientation;
|
|
1098
1100
|
const adb = await this.getAdb();
|
|
1099
1101
|
let orientation = 0;
|
|
@@ -1138,6 +1140,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1138
1140
|
}
|
|
1139
1141
|
async getAdjustScale() {
|
|
1140
1142
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1143
|
+
debugDevice(`getAdjustScale: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedScale=${!!this.cachedAdjustScale}`);
|
|
1141
1144
|
if (shouldCache && this.cachedAdjustScale) return this.cachedAdjustScale;
|
|
1142
1145
|
const physical = await this.getOrientedPhysicalSize();
|
|
1143
1146
|
const { width: logicalW, height: logicalH } = await this.size();
|
|
@@ -1881,7 +1884,8 @@ class AndroidMidsceneTools extends BaseMidsceneTools {
|
|
|
1881
1884
|
}
|
|
1882
1885
|
const tools = new AndroidMidsceneTools();
|
|
1883
1886
|
runToolsCLI(tools, 'midscene-android', {
|
|
1884
|
-
stripPrefix: 'android_'
|
|
1887
|
+
stripPrefix: 'android_',
|
|
1888
|
+
version: "1.5.4-beta-20260310084708.0"
|
|
1885
1889
|
}).catch((e)=>{
|
|
1886
1890
|
if (!(e instanceof CLIError)) console.error(e);
|
|
1887
1891
|
process.exit(e instanceof CLIError ? e.exitCode : 1);
|
package/dist/es/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { createImgBase64ByFormat, isValidImageBuffer } from "@midscene/shared/im
|
|
|
12
12
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
|
|
13
13
|
import { ADB } from "appium-adb";
|
|
14
14
|
import { Agent } from "@midscene/core/agent";
|
|
15
|
+
import { BaseMidsceneTools } from "@midscene/shared/mcp";
|
|
15
16
|
var __webpack_modules__ = {
|
|
16
17
|
"./src/scrcpy-manager.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
17
18
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -863,6 +864,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
863
864
|
}
|
|
864
865
|
async getScreenSize() {
|
|
865
866
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
867
|
+
debugDevice(`getScreenSize: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedSize=${!!this.cachedScreenSize}`);
|
|
866
868
|
if (shouldCache && this.cachedScreenSize) return this.cachedScreenSize;
|
|
867
869
|
const adb = await this.getAdb();
|
|
868
870
|
if ('number' == typeof this.options?.displayId) try {
|
|
@@ -996,6 +998,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
996
998
|
}
|
|
997
999
|
async getDisplayOrientation() {
|
|
998
1000
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1001
|
+
debugDevice(`getDisplayOrientation: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedOrientation=${null !== this.cachedOrientation}`);
|
|
999
1002
|
if (shouldCache && null !== this.cachedOrientation) return this.cachedOrientation;
|
|
1000
1003
|
const adb = await this.getAdb();
|
|
1001
1004
|
let orientation = 0;
|
|
@@ -1040,6 +1043,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1040
1043
|
}
|
|
1041
1044
|
async getAdjustScale() {
|
|
1042
1045
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1046
|
+
debugDevice(`getAdjustScale: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedScale=${!!this.cachedAdjustScale}`);
|
|
1043
1047
|
if (shouldCache && this.cachedAdjustScale) return this.cachedAdjustScale;
|
|
1044
1048
|
const physical = await this.getOrientedPhysicalSize();
|
|
1045
1049
|
const { width: logicalW, height: logicalH } = await this.size();
|
|
@@ -1823,4 +1827,58 @@ async function agentFromAdbDevice(deviceId, opts) {
|
|
|
1823
1827
|
await device.connect();
|
|
1824
1828
|
return new AndroidAgent(device, opts);
|
|
1825
1829
|
}
|
|
1826
|
-
|
|
1830
|
+
const debug = (0, logger_.getDebug)('mcp:android-tools');
|
|
1831
|
+
class AndroidMidsceneTools extends BaseMidsceneTools {
|
|
1832
|
+
createTemporaryDevice() {
|
|
1833
|
+
return new AndroidDevice('temp-for-action-space', {});
|
|
1834
|
+
}
|
|
1835
|
+
async ensureAgent(deviceId) {
|
|
1836
|
+
if (this.agent && deviceId) {
|
|
1837
|
+
try {
|
|
1838
|
+
await this.agent.destroy?.();
|
|
1839
|
+
} catch (error) {
|
|
1840
|
+
debug('Failed to destroy agent during cleanup:', error);
|
|
1841
|
+
}
|
|
1842
|
+
this.agent = void 0;
|
|
1843
|
+
}
|
|
1844
|
+
if (this.agent) return this.agent;
|
|
1845
|
+
debug('Creating Android agent with deviceId:', deviceId || 'auto-detect');
|
|
1846
|
+
const agent = await agentFromAdbDevice(deviceId, {
|
|
1847
|
+
autoDismissKeyboard: false
|
|
1848
|
+
});
|
|
1849
|
+
this.agent = agent;
|
|
1850
|
+
return agent;
|
|
1851
|
+
}
|
|
1852
|
+
preparePlatformTools() {
|
|
1853
|
+
return [
|
|
1854
|
+
{
|
|
1855
|
+
name: 'android_connect',
|
|
1856
|
+
description: 'Connect to Android device via ADB. If deviceId not provided, uses the first available device.',
|
|
1857
|
+
schema: {
|
|
1858
|
+
deviceId: z.string().optional().describe('Android device ID (from adb devices)')
|
|
1859
|
+
},
|
|
1860
|
+
handler: async ({ deviceId })=>{
|
|
1861
|
+
const agent = await this.ensureAgent(deviceId);
|
|
1862
|
+
const screenshot = await agent.page.screenshotBase64();
|
|
1863
|
+
return {
|
|
1864
|
+
content: [
|
|
1865
|
+
{
|
|
1866
|
+
type: 'text',
|
|
1867
|
+
text: `Connected to Android device${deviceId ? `: ${deviceId}` : ' (auto-detected)'}`
|
|
1868
|
+
},
|
|
1869
|
+
...this.buildScreenshotContent(screenshot)
|
|
1870
|
+
],
|
|
1871
|
+
isError: false
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
},
|
|
1875
|
+
{
|
|
1876
|
+
name: 'android_disconnect',
|
|
1877
|
+
description: 'Disconnect from current Android device and release ADB resources',
|
|
1878
|
+
schema: {},
|
|
1879
|
+
handler: this.createDisconnectHandler('Android device')
|
|
1880
|
+
}
|
|
1881
|
+
];
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
export { AndroidAgent, AndroidDevice, AndroidMidsceneTools, ScrcpyDeviceAdapter, agentFromAdbDevice, getConnectedDevices, overrideAIConfig };
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -960,6 +960,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
960
960
|
}
|
|
961
961
|
async getScreenSize() {
|
|
962
962
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
963
|
+
debugDevice(`getScreenSize: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedSize=${!!this.cachedScreenSize}`);
|
|
963
964
|
if (shouldCache && this.cachedScreenSize) return this.cachedScreenSize;
|
|
964
965
|
const adb = await this.getAdb();
|
|
965
966
|
if ('number' == typeof this.options?.displayId) try {
|
|
@@ -1093,6 +1094,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1093
1094
|
}
|
|
1094
1095
|
async getDisplayOrientation() {
|
|
1095
1096
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1097
|
+
debugDevice(`getDisplayOrientation: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedOrientation=${null !== this.cachedOrientation}`);
|
|
1096
1098
|
if (shouldCache && null !== this.cachedOrientation) return this.cachedOrientation;
|
|
1097
1099
|
const adb = await this.getAdb();
|
|
1098
1100
|
let orientation = 0;
|
|
@@ -1137,6 +1139,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1137
1139
|
}
|
|
1138
1140
|
async getAdjustScale() {
|
|
1139
1141
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1142
|
+
debugDevice(`getAdjustScale: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedScale=${!!this.cachedAdjustScale}`);
|
|
1140
1143
|
if (shouldCache && this.cachedAdjustScale) return this.cachedAdjustScale;
|
|
1141
1144
|
const physical = await this.getOrientedPhysicalSize();
|
|
1142
1145
|
const { width: logicalW, height: logicalH } = await this.size();
|
|
@@ -1885,7 +1888,7 @@ class AndroidMCPServer extends BaseMCPServer {
|
|
|
1885
1888
|
constructor(toolsManager){
|
|
1886
1889
|
super({
|
|
1887
1890
|
name: '@midscene/android-mcp',
|
|
1888
|
-
version:
|
|
1891
|
+
version: "1.5.4-beta-20260310084708.0",
|
|
1889
1892
|
description: 'Control the Android device using natural language commands'
|
|
1890
1893
|
}, toolsManager);
|
|
1891
1894
|
}
|
package/dist/lib/cli.js
CHANGED
|
@@ -976,6 +976,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
976
976
|
}
|
|
977
977
|
async getScreenSize() {
|
|
978
978
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
979
|
+
debugDevice(`getScreenSize: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedSize=${!!this.cachedScreenSize}`);
|
|
979
980
|
if (shouldCache && this.cachedScreenSize) return this.cachedScreenSize;
|
|
980
981
|
const adb = await this.getAdb();
|
|
981
982
|
if ('number' == typeof this.options?.displayId) try {
|
|
@@ -1109,6 +1110,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1109
1110
|
}
|
|
1110
1111
|
async getDisplayOrientation() {
|
|
1111
1112
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1113
|
+
debugDevice(`getDisplayOrientation: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedOrientation=${null !== this.cachedOrientation}`);
|
|
1112
1114
|
if (shouldCache && null !== this.cachedOrientation) return this.cachedOrientation;
|
|
1113
1115
|
const adb = await this.getAdb();
|
|
1114
1116
|
let orientation = 0;
|
|
@@ -1153,6 +1155,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1153
1155
|
}
|
|
1154
1156
|
async getAdjustScale() {
|
|
1155
1157
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1158
|
+
debugDevice(`getAdjustScale: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedScale=${!!this.cachedAdjustScale}`);
|
|
1156
1159
|
if (shouldCache && this.cachedAdjustScale) return this.cachedAdjustScale;
|
|
1157
1160
|
const physical = await this.getOrientedPhysicalSize();
|
|
1158
1161
|
const { width: logicalW, height: logicalH } = await this.size();
|
|
@@ -1896,7 +1899,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1896
1899
|
}
|
|
1897
1900
|
const tools = new AndroidMidsceneTools();
|
|
1898
1901
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-android', {
|
|
1899
|
-
stripPrefix: 'android_'
|
|
1902
|
+
stripPrefix: 'android_',
|
|
1903
|
+
version: "1.5.4-beta-20260310084708.0"
|
|
1900
1904
|
}).catch((e)=>{
|
|
1901
1905
|
if (!(e instanceof cli_namespaceObject.CLIError)) console.error(e);
|
|
1902
1906
|
process.exit(e instanceof cli_namespaceObject.CLIError ? e.exitCode : 1);
|
package/dist/lib/index.js
CHANGED
|
@@ -458,6 +458,7 @@ var __webpack_exports__ = {};
|
|
|
458
458
|
(()=>{
|
|
459
459
|
__webpack_require__.r(__webpack_exports__);
|
|
460
460
|
__webpack_require__.d(__webpack_exports__, {
|
|
461
|
+
AndroidMidsceneTools: ()=>AndroidMidsceneTools,
|
|
461
462
|
getConnectedDevices: ()=>getConnectedDevices,
|
|
462
463
|
overrideAIConfig: ()=>env_namespaceObject.overrideAIConfig,
|
|
463
464
|
AndroidAgent: ()=>AndroidAgent,
|
|
@@ -896,6 +897,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
896
897
|
}
|
|
897
898
|
async getScreenSize() {
|
|
898
899
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
900
|
+
debugDevice(`getScreenSize: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedSize=${!!this.cachedScreenSize}`);
|
|
899
901
|
if (shouldCache && this.cachedScreenSize) return this.cachedScreenSize;
|
|
900
902
|
const adb = await this.getAdb();
|
|
901
903
|
if ('number' == typeof this.options?.displayId) try {
|
|
@@ -1029,6 +1031,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1029
1031
|
}
|
|
1030
1032
|
async getDisplayOrientation() {
|
|
1031
1033
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1034
|
+
debugDevice(`getDisplayOrientation: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedOrientation=${null !== this.cachedOrientation}`);
|
|
1032
1035
|
if (shouldCache && null !== this.cachedOrientation) return this.cachedOrientation;
|
|
1033
1036
|
const adb = await this.getAdb();
|
|
1034
1037
|
let orientation = 0;
|
|
@@ -1073,6 +1076,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1073
1076
|
}
|
|
1074
1077
|
async getAdjustScale() {
|
|
1075
1078
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1079
|
+
debugDevice(`getAdjustScale: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedScale=${!!this.cachedAdjustScale}`);
|
|
1076
1080
|
if (shouldCache && this.cachedAdjustScale) return this.cachedAdjustScale;
|
|
1077
1081
|
const physical = await this.getOrientedPhysicalSize();
|
|
1078
1082
|
const { width: logicalW, height: logicalH } = await this.size();
|
|
@@ -1857,9 +1861,65 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1857
1861
|
await device.connect();
|
|
1858
1862
|
return new AndroidAgent(device, opts);
|
|
1859
1863
|
}
|
|
1864
|
+
const mcp_namespaceObject = require("@midscene/shared/mcp");
|
|
1865
|
+
const debug = (0, logger_.getDebug)('mcp:android-tools');
|
|
1866
|
+
class AndroidMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
1867
|
+
createTemporaryDevice() {
|
|
1868
|
+
return new AndroidDevice('temp-for-action-space', {});
|
|
1869
|
+
}
|
|
1870
|
+
async ensureAgent(deviceId) {
|
|
1871
|
+
if (this.agent && deviceId) {
|
|
1872
|
+
try {
|
|
1873
|
+
await this.agent.destroy?.();
|
|
1874
|
+
} catch (error) {
|
|
1875
|
+
debug('Failed to destroy agent during cleanup:', error);
|
|
1876
|
+
}
|
|
1877
|
+
this.agent = void 0;
|
|
1878
|
+
}
|
|
1879
|
+
if (this.agent) return this.agent;
|
|
1880
|
+
debug('Creating Android agent with deviceId:', deviceId || 'auto-detect');
|
|
1881
|
+
const agent = await agentFromAdbDevice(deviceId, {
|
|
1882
|
+
autoDismissKeyboard: false
|
|
1883
|
+
});
|
|
1884
|
+
this.agent = agent;
|
|
1885
|
+
return agent;
|
|
1886
|
+
}
|
|
1887
|
+
preparePlatformTools() {
|
|
1888
|
+
return [
|
|
1889
|
+
{
|
|
1890
|
+
name: 'android_connect',
|
|
1891
|
+
description: 'Connect to Android device via ADB. If deviceId not provided, uses the first available device.',
|
|
1892
|
+
schema: {
|
|
1893
|
+
deviceId: core_namespaceObject.z.string().optional().describe('Android device ID (from adb devices)')
|
|
1894
|
+
},
|
|
1895
|
+
handler: async ({ deviceId })=>{
|
|
1896
|
+
const agent = await this.ensureAgent(deviceId);
|
|
1897
|
+
const screenshot = await agent.page.screenshotBase64();
|
|
1898
|
+
return {
|
|
1899
|
+
content: [
|
|
1900
|
+
{
|
|
1901
|
+
type: 'text',
|
|
1902
|
+
text: `Connected to Android device${deviceId ? `: ${deviceId}` : ' (auto-detected)'}`
|
|
1903
|
+
},
|
|
1904
|
+
...this.buildScreenshotContent(screenshot)
|
|
1905
|
+
],
|
|
1906
|
+
isError: false
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
},
|
|
1910
|
+
{
|
|
1911
|
+
name: 'android_disconnect',
|
|
1912
|
+
description: 'Disconnect from current Android device and release ADB resources',
|
|
1913
|
+
schema: {},
|
|
1914
|
+
handler: this.createDisconnectHandler('Android device')
|
|
1915
|
+
}
|
|
1916
|
+
];
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1860
1919
|
})();
|
|
1861
1920
|
exports.AndroidAgent = __webpack_exports__.AndroidAgent;
|
|
1862
1921
|
exports.AndroidDevice = __webpack_exports__.AndroidDevice;
|
|
1922
|
+
exports.AndroidMidsceneTools = __webpack_exports__.AndroidMidsceneTools;
|
|
1863
1923
|
exports.ScrcpyDeviceAdapter = __webpack_exports__.ScrcpyDeviceAdapter;
|
|
1864
1924
|
exports.agentFromAdbDevice = __webpack_exports__.agentFromAdbDevice;
|
|
1865
1925
|
exports.getConnectedDevices = __webpack_exports__.getConnectedDevices;
|
|
@@ -1867,6 +1927,7 @@ exports.overrideAIConfig = __webpack_exports__.overrideAIConfig;
|
|
|
1867
1927
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
1868
1928
|
"AndroidAgent",
|
|
1869
1929
|
"AndroidDevice",
|
|
1930
|
+
"AndroidMidsceneTools",
|
|
1870
1931
|
"ScrcpyDeviceAdapter",
|
|
1871
1932
|
"agentFromAdbDevice",
|
|
1872
1933
|
"getConnectedDevices",
|
package/dist/lib/mcp-server.js
CHANGED
|
@@ -991,6 +991,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
991
991
|
}
|
|
992
992
|
async getScreenSize() {
|
|
993
993
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
994
|
+
debugDevice(`getScreenSize: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedSize=${!!this.cachedScreenSize}`);
|
|
994
995
|
if (shouldCache && this.cachedScreenSize) return this.cachedScreenSize;
|
|
995
996
|
const adb = await this.getAdb();
|
|
996
997
|
if ('number' == typeof this.options?.displayId) try {
|
|
@@ -1124,6 +1125,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1124
1125
|
}
|
|
1125
1126
|
async getDisplayOrientation() {
|
|
1126
1127
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1128
|
+
debugDevice(`getDisplayOrientation: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedOrientation=${null !== this.cachedOrientation}`);
|
|
1127
1129
|
if (shouldCache && null !== this.cachedOrientation) return this.cachedOrientation;
|
|
1128
1130
|
const adb = await this.getAdb();
|
|
1129
1131
|
let orientation = 0;
|
|
@@ -1168,6 +1170,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1168
1170
|
}
|
|
1169
1171
|
async getAdjustScale() {
|
|
1170
1172
|
const shouldCache = !(this.options?.alwaysRefreshScreenInfo ?? false);
|
|
1173
|
+
debugDevice(`getAdjustScale: alwaysRefreshScreenInfo=${this.options?.alwaysRefreshScreenInfo}, shouldCache=${shouldCache}, hasCachedScale=${!!this.cachedAdjustScale}`);
|
|
1171
1174
|
if (shouldCache && this.cachedAdjustScale) return this.cachedAdjustScale;
|
|
1172
1175
|
const physical = await this.getOrientedPhysicalSize();
|
|
1173
1176
|
const { width: logicalW, height: logicalH } = await this.size();
|
|
@@ -1916,7 +1919,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1916
1919
|
constructor(toolsManager){
|
|
1917
1920
|
super({
|
|
1918
1921
|
name: '@midscene/android-mcp',
|
|
1919
|
-
version:
|
|
1922
|
+
version: "1.5.4-beta-20260310084708.0",
|
|
1920
1923
|
description: 'Control the Android device using natural language commands'
|
|
1921
1924
|
}, toolsManager);
|
|
1922
1925
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Agent } from '@midscene/core/agent';
|
|
|
7
7
|
import { AgentOpt } from '@midscene/core/agent';
|
|
8
8
|
import { AndroidDeviceInputOpt } from '@midscene/core/device';
|
|
9
9
|
import { AndroidDeviceOpt } from '@midscene/core/device';
|
|
10
|
+
import { BaseMidsceneTools } from '@midscene/shared/mcp';
|
|
10
11
|
import { Device } from 'appium-adb';
|
|
11
12
|
import { DeviceAction } from '@midscene/core';
|
|
12
13
|
import type { ElementInfo } from '@midscene/shared/extractor';
|
|
@@ -14,6 +15,7 @@ import { InterfaceType } from '@midscene/core';
|
|
|
14
15
|
import { overrideAIConfig } from '@midscene/shared/env';
|
|
15
16
|
import { Point } from '@midscene/core';
|
|
16
17
|
import { Size } from '@midscene/core';
|
|
18
|
+
import { ToolDefinition } from '@midscene/shared/mcp';
|
|
17
19
|
|
|
18
20
|
declare type ActionArgs<T extends DeviceAction> = [ActionParam<T>] extends [undefined] ? [] : [ActionParam<T>];
|
|
19
21
|
|
|
@@ -212,6 +214,19 @@ export declare class AndroidDevice implements AbstractInterface {
|
|
|
212
214
|
hideKeyboard(options?: AndroidDeviceInputOpt, timeoutMs?: number): Promise<boolean>;
|
|
213
215
|
}
|
|
214
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Android-specific tools manager
|
|
219
|
+
* Extends BaseMidsceneTools to provide Android ADB device connection tools
|
|
220
|
+
*/
|
|
221
|
+
export declare class AndroidMidsceneTools extends BaseMidsceneTools<AndroidAgent> {
|
|
222
|
+
protected createTemporaryDevice(): AndroidDevice;
|
|
223
|
+
protected ensureAgent(deviceId?: string): Promise<AndroidAgent>;
|
|
224
|
+
/**
|
|
225
|
+
* Provide Android-specific platform tools
|
|
226
|
+
*/
|
|
227
|
+
protected preparePlatformTools(): ToolDefinition[];
|
|
228
|
+
}
|
|
229
|
+
|
|
215
230
|
declare type DeviceActionAndroidBackButton = DeviceAction<undefined, void>;
|
|
216
231
|
|
|
217
232
|
declare type DeviceActionAndroidHomeButton = DeviceAction<undefined, void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/android",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4-beta-20260310084708.0",
|
|
4
4
|
"description": "Android automation library for Midscene",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Android UI automation",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"@yume-chan/stream-extra": "^1.0.0",
|
|
42
42
|
"appium-adb": "12.12.1",
|
|
43
43
|
"sharp": "^0.34.3",
|
|
44
|
-
"@midscene/core": "1.5.
|
|
45
|
-
"@midscene/shared": "1.5.
|
|
44
|
+
"@midscene/core": "1.5.4-beta-20260310084708.0",
|
|
45
|
+
"@midscene/shared": "1.5.4-beta-20260310084708.0"
|
|
46
46
|
},
|
|
47
47
|
"optionalDependencies": {
|
|
48
48
|
"@ffmpeg-installer/ffmpeg": "^1.1.0"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"tsx": "^4.19.2",
|
|
57
57
|
"vitest": "3.0.5",
|
|
58
58
|
"zod": "3.24.3",
|
|
59
|
-
"@midscene/playground": "1.5.
|
|
59
|
+
"@midscene/playground": "1.5.4-beta-20260310084708.0"
|
|
60
60
|
},
|
|
61
61
|
"license": "MIT",
|
|
62
62
|
"scripts": {
|