@midscene/android 1.6.3-beta-20260402103943.0 → 1.6.3
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 +37 -2
- package/dist/es/index.mjs +34 -0
- package/dist/es/mcp-server.mjs +35 -1
- package/dist/lib/cli.js +37 -2
- package/dist/lib/index.js +34 -0
- package/dist/lib/mcp-server.js +35 -1
- package/dist/types/index.d.ts +11 -0
- package/dist/types/mcp-server.d.ts +11 -0
- package/package.json +4 -4
package/dist/es/cli.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import * as __rspack_external__midscene_shared_logger_b1dc2426 from "@midscene/s
|
|
|
2
2
|
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
|
+
import { createReportCliCommands, getMidsceneLocationSchema, z } from "@midscene/core";
|
|
5
6
|
import { CLIError, runToolsCLI } from "@midscene/shared/cli";
|
|
6
|
-
import { getMidsceneLocationSchema, z } from "@midscene/core";
|
|
7
7
|
import { BaseMidsceneTools } from "@midscene/shared/mcp";
|
|
8
8
|
import { Agent } from "@midscene/core/agent";
|
|
9
9
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
|
|
@@ -973,6 +973,21 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
973
973
|
}
|
|
974
974
|
return this;
|
|
975
975
|
}
|
|
976
|
+
async terminate(uri) {
|
|
977
|
+
const packagePart = uri.includes('/') ? uri.split('/')[0] : uri;
|
|
978
|
+
const resolved = this.resolvePackageName(packagePart) ?? packagePart;
|
|
979
|
+
const adb = await this.getAdb();
|
|
980
|
+
try {
|
|
981
|
+
debugDevice(`Terminating app: ${resolved}`);
|
|
982
|
+
await adb.shell(`am force-stop ${resolved}`);
|
|
983
|
+
debugDevice(`Successfully terminated: ${resolved}`);
|
|
984
|
+
} catch (error) {
|
|
985
|
+
debugDevice(`Error terminating ${resolved}: ${error}`);
|
|
986
|
+
throw new Error(`Failed to terminate ${resolved}: ${error.message}`, {
|
|
987
|
+
cause: error
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
}
|
|
976
991
|
async execYadb(keyboardContent, options) {
|
|
977
992
|
await this.ensureYadb();
|
|
978
993
|
const adb = await this.getAdb();
|
|
@@ -1751,6 +1766,9 @@ const runAdbShellParamSchema = z.object({
|
|
|
1751
1766
|
const launchParamSchema = z.object({
|
|
1752
1767
|
uri: z.string().describe('App name, package name, or URL to launch. Prioritize using the exact package name or URL the user has provided. If none provided, use the accurate app name.')
|
|
1753
1768
|
});
|
|
1769
|
+
const terminateParamSchema = z.object({
|
|
1770
|
+
uri: z.string().describe('Package name or app name to terminate. Use the exact package name, e.g. com.android.settings.')
|
|
1771
|
+
});
|
|
1754
1772
|
const createPlatformActions = (device)=>({
|
|
1755
1773
|
RunAdbShell: defineAction({
|
|
1756
1774
|
name: 'RunAdbShell',
|
|
@@ -1779,6 +1797,16 @@ const createPlatformActions = (device)=>({
|
|
|
1779
1797
|
await device.launch(param.uri);
|
|
1780
1798
|
}
|
|
1781
1799
|
}),
|
|
1800
|
+
Terminate: defineAction({
|
|
1801
|
+
name: 'Terminate',
|
|
1802
|
+
description: 'Terminate (force-stop) an Android app by package name',
|
|
1803
|
+
interfaceAlias: 'terminate',
|
|
1804
|
+
paramSchema: terminateParamSchema,
|
|
1805
|
+
call: async (param)=>{
|
|
1806
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1807
|
+
await device.terminate(param.uri);
|
|
1808
|
+
}
|
|
1809
|
+
}),
|
|
1782
1810
|
AndroidBackButton: defineAction({
|
|
1783
1811
|
name: 'AndroidBackButton',
|
|
1784
1812
|
description: 'Trigger the system "back" operation on Android devices',
|
|
@@ -1835,6 +1863,12 @@ class AndroidAgent extends Agent {
|
|
|
1835
1863
|
uri
|
|
1836
1864
|
});
|
|
1837
1865
|
}
|
|
1866
|
+
async terminate(uri) {
|
|
1867
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1868
|
+
return action({
|
|
1869
|
+
uri
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1838
1872
|
async runAdbShell(command) {
|
|
1839
1873
|
const action = this.wrapActionInActionSpace('RunAdbShell');
|
|
1840
1874
|
return action({
|
|
@@ -1922,7 +1956,8 @@ class AndroidMidsceneTools extends BaseMidsceneTools {
|
|
|
1922
1956
|
const tools = new AndroidMidsceneTools();
|
|
1923
1957
|
runToolsCLI(tools, 'midscene-android', {
|
|
1924
1958
|
stripPrefix: 'android_',
|
|
1925
|
-
version: "1.6.3
|
|
1959
|
+
version: "1.6.3",
|
|
1960
|
+
extraCommands: createReportCliCommands()
|
|
1926
1961
|
}).catch((e)=>{
|
|
1927
1962
|
if (!(e instanceof CLIError)) console.error(e);
|
|
1928
1963
|
process.exit(e instanceof CLIError ? e.exitCode : 1);
|
package/dist/es/index.mjs
CHANGED
|
@@ -876,6 +876,21 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
876
876
|
}
|
|
877
877
|
return this;
|
|
878
878
|
}
|
|
879
|
+
async terminate(uri) {
|
|
880
|
+
const packagePart = uri.includes('/') ? uri.split('/')[0] : uri;
|
|
881
|
+
const resolved = this.resolvePackageName(packagePart) ?? packagePart;
|
|
882
|
+
const adb = await this.getAdb();
|
|
883
|
+
try {
|
|
884
|
+
debugDevice(`Terminating app: ${resolved}`);
|
|
885
|
+
await adb.shell(`am force-stop ${resolved}`);
|
|
886
|
+
debugDevice(`Successfully terminated: ${resolved}`);
|
|
887
|
+
} catch (error) {
|
|
888
|
+
debugDevice(`Error terminating ${resolved}: ${error}`);
|
|
889
|
+
throw new Error(`Failed to terminate ${resolved}: ${error.message}`, {
|
|
890
|
+
cause: error
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
}
|
|
879
894
|
async execYadb(keyboardContent, options) {
|
|
880
895
|
await this.ensureYadb();
|
|
881
896
|
const adb = await this.getAdb();
|
|
@@ -1654,6 +1669,9 @@ const runAdbShellParamSchema = z.object({
|
|
|
1654
1669
|
const launchParamSchema = z.object({
|
|
1655
1670
|
uri: z.string().describe('App name, package name, or URL to launch. Prioritize using the exact package name or URL the user has provided. If none provided, use the accurate app name.')
|
|
1656
1671
|
});
|
|
1672
|
+
const terminateParamSchema = z.object({
|
|
1673
|
+
uri: z.string().describe('Package name or app name to terminate. Use the exact package name, e.g. com.android.settings.')
|
|
1674
|
+
});
|
|
1657
1675
|
const createPlatformActions = (device)=>({
|
|
1658
1676
|
RunAdbShell: defineAction({
|
|
1659
1677
|
name: 'RunAdbShell',
|
|
@@ -1682,6 +1700,16 @@ const createPlatformActions = (device)=>({
|
|
|
1682
1700
|
await device.launch(param.uri);
|
|
1683
1701
|
}
|
|
1684
1702
|
}),
|
|
1703
|
+
Terminate: defineAction({
|
|
1704
|
+
name: 'Terminate',
|
|
1705
|
+
description: 'Terminate (force-stop) an Android app by package name',
|
|
1706
|
+
interfaceAlias: 'terminate',
|
|
1707
|
+
paramSchema: terminateParamSchema,
|
|
1708
|
+
call: async (param)=>{
|
|
1709
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1710
|
+
await device.terminate(param.uri);
|
|
1711
|
+
}
|
|
1712
|
+
}),
|
|
1685
1713
|
AndroidBackButton: defineAction({
|
|
1686
1714
|
name: 'AndroidBackButton',
|
|
1687
1715
|
description: 'Trigger the system "back" operation on Android devices',
|
|
@@ -1901,6 +1929,12 @@ class AndroidAgent extends Agent {
|
|
|
1901
1929
|
uri
|
|
1902
1930
|
});
|
|
1903
1931
|
}
|
|
1932
|
+
async terminate(uri) {
|
|
1933
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1934
|
+
return action({
|
|
1935
|
+
uri
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1904
1938
|
async runAdbShell(command) {
|
|
1905
1939
|
const action = this.wrapActionInActionSpace('RunAdbShell');
|
|
1906
1940
|
return action({
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -972,6 +972,21 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
972
972
|
}
|
|
973
973
|
return this;
|
|
974
974
|
}
|
|
975
|
+
async terminate(uri) {
|
|
976
|
+
const packagePart = uri.includes('/') ? uri.split('/')[0] : uri;
|
|
977
|
+
const resolved = this.resolvePackageName(packagePart) ?? packagePart;
|
|
978
|
+
const adb = await this.getAdb();
|
|
979
|
+
try {
|
|
980
|
+
debugDevice(`Terminating app: ${resolved}`);
|
|
981
|
+
await adb.shell(`am force-stop ${resolved}`);
|
|
982
|
+
debugDevice(`Successfully terminated: ${resolved}`);
|
|
983
|
+
} catch (error) {
|
|
984
|
+
debugDevice(`Error terminating ${resolved}: ${error}`);
|
|
985
|
+
throw new Error(`Failed to terminate ${resolved}: ${error.message}`, {
|
|
986
|
+
cause: error
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
}
|
|
975
990
|
async execYadb(keyboardContent, options) {
|
|
976
991
|
await this.ensureYadb();
|
|
977
992
|
const adb = await this.getAdb();
|
|
@@ -1750,6 +1765,9 @@ const runAdbShellParamSchema = z.object({
|
|
|
1750
1765
|
const launchParamSchema = z.object({
|
|
1751
1766
|
uri: z.string().describe('App name, package name, or URL to launch. Prioritize using the exact package name or URL the user has provided. If none provided, use the accurate app name.')
|
|
1752
1767
|
});
|
|
1768
|
+
const terminateParamSchema = z.object({
|
|
1769
|
+
uri: z.string().describe('Package name or app name to terminate. Use the exact package name, e.g. com.android.settings.')
|
|
1770
|
+
});
|
|
1753
1771
|
const createPlatformActions = (device)=>({
|
|
1754
1772
|
RunAdbShell: defineAction({
|
|
1755
1773
|
name: 'RunAdbShell',
|
|
@@ -1778,6 +1796,16 @@ const createPlatformActions = (device)=>({
|
|
|
1778
1796
|
await device.launch(param.uri);
|
|
1779
1797
|
}
|
|
1780
1798
|
}),
|
|
1799
|
+
Terminate: defineAction({
|
|
1800
|
+
name: 'Terminate',
|
|
1801
|
+
description: 'Terminate (force-stop) an Android app by package name',
|
|
1802
|
+
interfaceAlias: 'terminate',
|
|
1803
|
+
paramSchema: terminateParamSchema,
|
|
1804
|
+
call: async (param)=>{
|
|
1805
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1806
|
+
await device.terminate(param.uri);
|
|
1807
|
+
}
|
|
1808
|
+
}),
|
|
1781
1809
|
AndroidBackButton: defineAction({
|
|
1782
1810
|
name: 'AndroidBackButton',
|
|
1783
1811
|
description: 'Trigger the system "back" operation on Android devices',
|
|
@@ -1834,6 +1862,12 @@ class AndroidAgent extends Agent {
|
|
|
1834
1862
|
uri
|
|
1835
1863
|
});
|
|
1836
1864
|
}
|
|
1865
|
+
async terminate(uri) {
|
|
1866
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1867
|
+
return action({
|
|
1868
|
+
uri
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1837
1871
|
async runAdbShell(command) {
|
|
1838
1872
|
const action = this.wrapActionInActionSpace('RunAdbShell');
|
|
1839
1873
|
return action({
|
|
@@ -1925,7 +1959,7 @@ class AndroidMCPServer extends BaseMCPServer {
|
|
|
1925
1959
|
constructor(toolsManager){
|
|
1926
1960
|
super({
|
|
1927
1961
|
name: '@midscene/android-mcp',
|
|
1928
|
-
version: "1.6.3
|
|
1962
|
+
version: "1.6.3",
|
|
1929
1963
|
description: 'Control the Android device using natural language commands'
|
|
1930
1964
|
}, toolsManager);
|
|
1931
1965
|
}
|
package/dist/lib/cli.js
CHANGED
|
@@ -446,8 +446,8 @@ function __webpack_require__(moduleId) {
|
|
|
446
446
|
})();
|
|
447
447
|
var __webpack_exports__ = {};
|
|
448
448
|
(()=>{
|
|
449
|
-
const cli_namespaceObject = require("@midscene/shared/cli");
|
|
450
449
|
const core_namespaceObject = require("@midscene/core");
|
|
450
|
+
const cli_namespaceObject = require("@midscene/shared/cli");
|
|
451
451
|
var logger_ = __webpack_require__("@midscene/shared/logger");
|
|
452
452
|
const mcp_namespaceObject = require("@midscene/shared/mcp");
|
|
453
453
|
const agent_namespaceObject = require("@midscene/core/agent");
|
|
@@ -988,6 +988,21 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
988
988
|
}
|
|
989
989
|
return this;
|
|
990
990
|
}
|
|
991
|
+
async terminate(uri) {
|
|
992
|
+
const packagePart = uri.includes('/') ? uri.split('/')[0] : uri;
|
|
993
|
+
const resolved = this.resolvePackageName(packagePart) ?? packagePart;
|
|
994
|
+
const adb = await this.getAdb();
|
|
995
|
+
try {
|
|
996
|
+
debugDevice(`Terminating app: ${resolved}`);
|
|
997
|
+
await adb.shell(`am force-stop ${resolved}`);
|
|
998
|
+
debugDevice(`Successfully terminated: ${resolved}`);
|
|
999
|
+
} catch (error) {
|
|
1000
|
+
debugDevice(`Error terminating ${resolved}: ${error}`);
|
|
1001
|
+
throw new Error(`Failed to terminate ${resolved}: ${error.message}`, {
|
|
1002
|
+
cause: error
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
991
1006
|
async execYadb(keyboardContent, options) {
|
|
992
1007
|
await this.ensureYadb();
|
|
993
1008
|
const adb = await this.getAdb();
|
|
@@ -1766,6 +1781,9 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1766
1781
|
const launchParamSchema = core_namespaceObject.z.object({
|
|
1767
1782
|
uri: core_namespaceObject.z.string().describe('App name, package name, or URL to launch. Prioritize using the exact package name or URL the user has provided. If none provided, use the accurate app name.')
|
|
1768
1783
|
});
|
|
1784
|
+
const terminateParamSchema = core_namespaceObject.z.object({
|
|
1785
|
+
uri: core_namespaceObject.z.string().describe('Package name or app name to terminate. Use the exact package name, e.g. com.android.settings.')
|
|
1786
|
+
});
|
|
1769
1787
|
const createPlatformActions = (device)=>({
|
|
1770
1788
|
RunAdbShell: (0, device_namespaceObject.defineAction)({
|
|
1771
1789
|
name: 'RunAdbShell',
|
|
@@ -1794,6 +1812,16 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1794
1812
|
await device.launch(param.uri);
|
|
1795
1813
|
}
|
|
1796
1814
|
}),
|
|
1815
|
+
Terminate: (0, device_namespaceObject.defineAction)({
|
|
1816
|
+
name: 'Terminate',
|
|
1817
|
+
description: 'Terminate (force-stop) an Android app by package name',
|
|
1818
|
+
interfaceAlias: 'terminate',
|
|
1819
|
+
paramSchema: terminateParamSchema,
|
|
1820
|
+
call: async (param)=>{
|
|
1821
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1822
|
+
await device.terminate(param.uri);
|
|
1823
|
+
}
|
|
1824
|
+
}),
|
|
1797
1825
|
AndroidBackButton: (0, device_namespaceObject.defineAction)({
|
|
1798
1826
|
name: 'AndroidBackButton',
|
|
1799
1827
|
description: 'Trigger the system "back" operation on Android devices',
|
|
@@ -1850,6 +1878,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1850
1878
|
uri
|
|
1851
1879
|
});
|
|
1852
1880
|
}
|
|
1881
|
+
async terminate(uri) {
|
|
1882
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1883
|
+
return action({
|
|
1884
|
+
uri
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1853
1887
|
async runAdbShell(command) {
|
|
1854
1888
|
const action = this.wrapActionInActionSpace('RunAdbShell');
|
|
1855
1889
|
return action({
|
|
@@ -1937,7 +1971,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1937
1971
|
const tools = new AndroidMidsceneTools();
|
|
1938
1972
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-android', {
|
|
1939
1973
|
stripPrefix: 'android_',
|
|
1940
|
-
version: "1.6.3
|
|
1974
|
+
version: "1.6.3",
|
|
1975
|
+
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
1941
1976
|
}).catch((e)=>{
|
|
1942
1977
|
if (!(e instanceof cli_namespaceObject.CLIError)) console.error(e);
|
|
1943
1978
|
process.exit(e instanceof cli_namespaceObject.CLIError ? e.exitCode : 1);
|
package/dist/lib/index.js
CHANGED
|
@@ -910,6 +910,21 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
910
910
|
}
|
|
911
911
|
return this;
|
|
912
912
|
}
|
|
913
|
+
async terminate(uri) {
|
|
914
|
+
const packagePart = uri.includes('/') ? uri.split('/')[0] : uri;
|
|
915
|
+
const resolved = this.resolvePackageName(packagePart) ?? packagePart;
|
|
916
|
+
const adb = await this.getAdb();
|
|
917
|
+
try {
|
|
918
|
+
debugDevice(`Terminating app: ${resolved}`);
|
|
919
|
+
await adb.shell(`am force-stop ${resolved}`);
|
|
920
|
+
debugDevice(`Successfully terminated: ${resolved}`);
|
|
921
|
+
} catch (error) {
|
|
922
|
+
debugDevice(`Error terminating ${resolved}: ${error}`);
|
|
923
|
+
throw new Error(`Failed to terminate ${resolved}: ${error.message}`, {
|
|
924
|
+
cause: error
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
}
|
|
913
928
|
async execYadb(keyboardContent, options) {
|
|
914
929
|
await this.ensureYadb();
|
|
915
930
|
const adb = await this.getAdb();
|
|
@@ -1688,6 +1703,9 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1688
1703
|
const launchParamSchema = core_namespaceObject.z.object({
|
|
1689
1704
|
uri: core_namespaceObject.z.string().describe('App name, package name, or URL to launch. Prioritize using the exact package name or URL the user has provided. If none provided, use the accurate app name.')
|
|
1690
1705
|
});
|
|
1706
|
+
const terminateParamSchema = core_namespaceObject.z.object({
|
|
1707
|
+
uri: core_namespaceObject.z.string().describe('Package name or app name to terminate. Use the exact package name, e.g. com.android.settings.')
|
|
1708
|
+
});
|
|
1691
1709
|
const createPlatformActions = (device)=>({
|
|
1692
1710
|
RunAdbShell: (0, device_namespaceObject.defineAction)({
|
|
1693
1711
|
name: 'RunAdbShell',
|
|
@@ -1716,6 +1734,16 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1716
1734
|
await device.launch(param.uri);
|
|
1717
1735
|
}
|
|
1718
1736
|
}),
|
|
1737
|
+
Terminate: (0, device_namespaceObject.defineAction)({
|
|
1738
|
+
name: 'Terminate',
|
|
1739
|
+
description: 'Terminate (force-stop) an Android app by package name',
|
|
1740
|
+
interfaceAlias: 'terminate',
|
|
1741
|
+
paramSchema: terminateParamSchema,
|
|
1742
|
+
call: async (param)=>{
|
|
1743
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1744
|
+
await device.terminate(param.uri);
|
|
1745
|
+
}
|
|
1746
|
+
}),
|
|
1719
1747
|
AndroidBackButton: (0, device_namespaceObject.defineAction)({
|
|
1720
1748
|
name: 'AndroidBackButton',
|
|
1721
1749
|
description: 'Trigger the system "back" operation on Android devices',
|
|
@@ -1936,6 +1964,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1936
1964
|
uri
|
|
1937
1965
|
});
|
|
1938
1966
|
}
|
|
1967
|
+
async terminate(uri) {
|
|
1968
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1969
|
+
return action({
|
|
1970
|
+
uri
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1939
1973
|
async runAdbShell(command) {
|
|
1940
1974
|
const action = this.wrapActionInActionSpace('RunAdbShell');
|
|
1941
1975
|
return action({
|
package/dist/lib/mcp-server.js
CHANGED
|
@@ -1003,6 +1003,21 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1003
1003
|
}
|
|
1004
1004
|
return this;
|
|
1005
1005
|
}
|
|
1006
|
+
async terminate(uri) {
|
|
1007
|
+
const packagePart = uri.includes('/') ? uri.split('/')[0] : uri;
|
|
1008
|
+
const resolved = this.resolvePackageName(packagePart) ?? packagePart;
|
|
1009
|
+
const adb = await this.getAdb();
|
|
1010
|
+
try {
|
|
1011
|
+
debugDevice(`Terminating app: ${resolved}`);
|
|
1012
|
+
await adb.shell(`am force-stop ${resolved}`);
|
|
1013
|
+
debugDevice(`Successfully terminated: ${resolved}`);
|
|
1014
|
+
} catch (error) {
|
|
1015
|
+
debugDevice(`Error terminating ${resolved}: ${error}`);
|
|
1016
|
+
throw new Error(`Failed to terminate ${resolved}: ${error.message}`, {
|
|
1017
|
+
cause: error
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1006
1021
|
async execYadb(keyboardContent, options) {
|
|
1007
1022
|
await this.ensureYadb();
|
|
1008
1023
|
const adb = await this.getAdb();
|
|
@@ -1781,6 +1796,9 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1781
1796
|
const launchParamSchema = core_namespaceObject.z.object({
|
|
1782
1797
|
uri: core_namespaceObject.z.string().describe('App name, package name, or URL to launch. Prioritize using the exact package name or URL the user has provided. If none provided, use the accurate app name.')
|
|
1783
1798
|
});
|
|
1799
|
+
const terminateParamSchema = core_namespaceObject.z.object({
|
|
1800
|
+
uri: core_namespaceObject.z.string().describe('Package name or app name to terminate. Use the exact package name, e.g. com.android.settings.')
|
|
1801
|
+
});
|
|
1784
1802
|
const createPlatformActions = (device)=>({
|
|
1785
1803
|
RunAdbShell: (0, device_namespaceObject.defineAction)({
|
|
1786
1804
|
name: 'RunAdbShell',
|
|
@@ -1809,6 +1827,16 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1809
1827
|
await device.launch(param.uri);
|
|
1810
1828
|
}
|
|
1811
1829
|
}),
|
|
1830
|
+
Terminate: (0, device_namespaceObject.defineAction)({
|
|
1831
|
+
name: 'Terminate',
|
|
1832
|
+
description: 'Terminate (force-stop) an Android app by package name',
|
|
1833
|
+
interfaceAlias: 'terminate',
|
|
1834
|
+
paramSchema: terminateParamSchema,
|
|
1835
|
+
call: async (param)=>{
|
|
1836
|
+
if (!param.uri || '' === param.uri.trim()) throw new Error('Terminate requires a non-empty uri parameter');
|
|
1837
|
+
await device.terminate(param.uri);
|
|
1838
|
+
}
|
|
1839
|
+
}),
|
|
1812
1840
|
AndroidBackButton: (0, device_namespaceObject.defineAction)({
|
|
1813
1841
|
name: 'AndroidBackButton',
|
|
1814
1842
|
description: 'Trigger the system "back" operation on Android devices',
|
|
@@ -1865,6 +1893,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1865
1893
|
uri
|
|
1866
1894
|
});
|
|
1867
1895
|
}
|
|
1896
|
+
async terminate(uri) {
|
|
1897
|
+
const action = this.wrapActionInActionSpace('Terminate');
|
|
1898
|
+
return action({
|
|
1899
|
+
uri
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1868
1902
|
async runAdbShell(command) {
|
|
1869
1903
|
const action = this.wrapActionInActionSpace('RunAdbShell');
|
|
1870
1904
|
return action({
|
|
@@ -1956,7 +1990,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1956
1990
|
constructor(toolsManager){
|
|
1957
1991
|
super({
|
|
1958
1992
|
name: '@midscene/android-mcp',
|
|
1959
|
-
version: "1.6.3
|
|
1993
|
+
version: "1.6.3",
|
|
1960
1994
|
description: 'Control the Android device using natural language commands'
|
|
1961
1995
|
}, toolsManager);
|
|
1962
1996
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -44,6 +44,11 @@ export declare class AndroidAgent extends Agent<AndroidDevice> {
|
|
|
44
44
|
* @param uri - App package name, URL, or app name to launch
|
|
45
45
|
*/
|
|
46
46
|
launch(uri: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Terminate (force-stop) an Android app by package name
|
|
49
|
+
* @param uri - Package name or app name to terminate
|
|
50
|
+
*/
|
|
51
|
+
terminate(uri: string): Promise<void>;
|
|
47
52
|
/**
|
|
48
53
|
* Execute ADB shell command on Android device
|
|
49
54
|
* @param command - ADB shell command to execute
|
|
@@ -114,6 +119,12 @@ export declare class AndroidDevice implements AbstractInterface {
|
|
|
114
119
|
*/
|
|
115
120
|
private resolvePackageName;
|
|
116
121
|
launch(uri: string): Promise<AndroidDevice>;
|
|
122
|
+
/**
|
|
123
|
+
* Terminate (force-stop) an Android app by package name.
|
|
124
|
+
* Supports app name resolution via setAppNameMapping.
|
|
125
|
+
* If uri contains "/" (e.g. com.example.app/.MainActivity), only the package part is used.
|
|
126
|
+
*/
|
|
127
|
+
terminate(uri: string): Promise<void>;
|
|
117
128
|
execYadb(keyboardContent: string, options?: {
|
|
118
129
|
overwrite?: boolean;
|
|
119
130
|
}): Promise<void>;
|
|
@@ -43,6 +43,11 @@ declare class AndroidAgent extends Agent<AndroidDevice> {
|
|
|
43
43
|
* @param uri - App package name, URL, or app name to launch
|
|
44
44
|
*/
|
|
45
45
|
launch(uri: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Terminate (force-stop) an Android app by package name
|
|
48
|
+
* @param uri - Package name or app name to terminate
|
|
49
|
+
*/
|
|
50
|
+
terminate(uri: string): Promise<void>;
|
|
46
51
|
/**
|
|
47
52
|
* Execute ADB shell command on Android device
|
|
48
53
|
* @param command - ADB shell command to execute
|
|
@@ -106,6 +111,12 @@ declare class AndroidDevice implements AbstractInterface {
|
|
|
106
111
|
*/
|
|
107
112
|
private resolvePackageName;
|
|
108
113
|
launch(uri: string): Promise<AndroidDevice>;
|
|
114
|
+
/**
|
|
115
|
+
* Terminate (force-stop) an Android app by package name.
|
|
116
|
+
* Supports app name resolution via setAppNameMapping.
|
|
117
|
+
* If uri contains "/" (e.g. com.example.app/.MainActivity), only the package part is used.
|
|
118
|
+
*/
|
|
119
|
+
terminate(uri: string): Promise<void>;
|
|
109
120
|
execYadb(keyboardContent: string, options?: {
|
|
110
121
|
overwrite?: boolean;
|
|
111
122
|
}): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/android",
|
|
3
|
-
"version": "1.6.3
|
|
3
|
+
"version": "1.6.3",
|
|
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": "2.1.0",
|
|
42
42
|
"appium-adb": "12.12.1",
|
|
43
43
|
"sharp": "^0.34.3",
|
|
44
|
-
"@midscene/core": "1.6.3
|
|
45
|
-
"@midscene/shared": "1.6.3
|
|
44
|
+
"@midscene/core": "1.6.3",
|
|
45
|
+
"@midscene/shared": "1.6.3"
|
|
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.6.3
|
|
59
|
+
"@midscene/playground": "1.6.3"
|
|
60
60
|
},
|
|
61
61
|
"license": "MIT",
|
|
62
62
|
"scripts": {
|