@midscene/harmony 1.7.5-beta-20260421030751.0 → 1.7.5
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 +30 -9
- package/dist/es/index.mjs +27 -5
- package/dist/es/mcp-server.mjs +29 -6
- package/dist/lib/cli.js +30 -9
- package/dist/lib/index.js +28 -6
- package/dist/lib/mcp-server.js +29 -6
- package/dist/types/index.d.ts +5 -3
- package/dist/types/mcp-server.d.ts +5 -3
- package/package.json +4 -4
- package/static/index.html +1 -1
- package/static/static/css/index.dc500f18.css +2 -0
- package/static/static/css/index.dc500f18.css.map +1 -0
- package/static/static/js/{263.25db3a75.js → 883.516361ae.js} +30 -30
- package/static/static/js/{263.25db3a75.js.LICENSE.txt → 883.516361ae.js.LICENSE.txt} +16 -0
- package/static/static/js/883.516361ae.js.map +1 -0
- package/static/static/js/{index.b24f9a87.js → index.3bea1f00.js} +27 -17
- package/static/static/js/index.3bea1f00.js.map +1 -0
- package/static/static/css/index.1946f9fa.css +0 -2
- package/static/static/css/index.1946f9fa.css.map +0 -1
- package/static/static/js/263.25db3a75.js.map +0 -1
- package/static/static/js/index.b24f9a87.js.map +0 -1
- /package/static/static/js/{index.b24f9a87.js.LICENSE.txt → index.3bea1f00.js.LICENSE.txt} +0 -0
package/dist/es/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createReportCliCommands, getMidsceneLocationSchema, z } from "@midscene/core";
|
|
2
|
-
import {
|
|
2
|
+
import { reportCLIError, runToolsCLI } from "@midscene/shared/cli";
|
|
3
3
|
import { getDebug } from "@midscene/shared/logger";
|
|
4
|
-
import { BaseMidsceneTools } from "@midscene/shared/mcp";
|
|
4
|
+
import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
|
|
5
5
|
import { Agent } from "@midscene/core/agent";
|
|
6
6
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
|
|
7
7
|
import node_assert from "node:assert";
|
|
@@ -933,6 +933,16 @@ async function agentFromHdcDevice(deviceId, opts) {
|
|
|
933
933
|
await device.connect();
|
|
934
934
|
return new HarmonyAgent(device, opts);
|
|
935
935
|
}
|
|
936
|
+
function mcp_tools_define_property(obj, key, value) {
|
|
937
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
938
|
+
value: value,
|
|
939
|
+
enumerable: true,
|
|
940
|
+
configurable: true,
|
|
941
|
+
writable: true
|
|
942
|
+
});
|
|
943
|
+
else obj[key] = value;
|
|
944
|
+
return obj;
|
|
945
|
+
}
|
|
936
946
|
const debug = getDebug('mcp:harmony-tools');
|
|
937
947
|
class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
938
948
|
createTemporaryDevice() {
|
|
@@ -960,10 +970,10 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
960
970
|
{
|
|
961
971
|
name: 'harmony_connect',
|
|
962
972
|
description: 'Connect to HarmonyOS device via HDC. If deviceId not provided, uses the first available device.',
|
|
963
|
-
schema:
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
973
|
+
schema: this.getAgentInitArgSchema(),
|
|
974
|
+
cli: this.getAgentInitArgCliMetadata(),
|
|
975
|
+
handler: async (args)=>{
|
|
976
|
+
const deviceId = this.extractAgentInitParam(args);
|
|
967
977
|
const agent = await this.ensureAgent(deviceId);
|
|
968
978
|
const screenshot = await agent.page.screenshotBase64();
|
|
969
979
|
return {
|
|
@@ -986,13 +996,24 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
986
996
|
}
|
|
987
997
|
];
|
|
988
998
|
}
|
|
999
|
+
constructor(...args){
|
|
1000
|
+
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
1001
|
+
namespace: 'harmony',
|
|
1002
|
+
shape: {
|
|
1003
|
+
deviceId: z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
1004
|
+
},
|
|
1005
|
+
cli: {
|
|
1006
|
+
preferBareKeys: true
|
|
1007
|
+
},
|
|
1008
|
+
adapt: (extracted)=>extracted?.deviceId
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
989
1011
|
}
|
|
990
1012
|
const tools = new HarmonyMidsceneTools();
|
|
991
1013
|
runToolsCLI(tools, 'midscene-harmony', {
|
|
992
1014
|
stripPrefix: 'harmony_',
|
|
993
|
-
version: "1.7.5
|
|
1015
|
+
version: "1.7.5",
|
|
994
1016
|
extraCommands: createReportCliCommands()
|
|
995
1017
|
}).catch((e)=>{
|
|
996
|
-
|
|
997
|
-
process.exit(e instanceof CLIError ? e.exitCode : 1);
|
|
1018
|
+
process.exit(reportCLIError(e));
|
|
998
1019
|
});
|
package/dist/es/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from
|
|
|
9
9
|
import { execFile } from "node:child_process";
|
|
10
10
|
import { promisify } from "node:util";
|
|
11
11
|
import { Agent } from "@midscene/core/agent";
|
|
12
|
-
import { BaseMidsceneTools } from "@midscene/shared/mcp";
|
|
12
|
+
import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
|
|
13
13
|
import { overrideAIConfig } from "@midscene/shared/env";
|
|
14
14
|
import node_path from "node:path";
|
|
15
15
|
import { select as prompts_select } from "@inquirer/prompts";
|
|
@@ -938,6 +938,16 @@ async function agentFromHdcDevice(deviceId, opts) {
|
|
|
938
938
|
await device.connect();
|
|
939
939
|
return new HarmonyAgent(device, opts);
|
|
940
940
|
}
|
|
941
|
+
function mcp_tools_define_property(obj, key, value) {
|
|
942
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
943
|
+
value: value,
|
|
944
|
+
enumerable: true,
|
|
945
|
+
configurable: true,
|
|
946
|
+
writable: true
|
|
947
|
+
});
|
|
948
|
+
else obj[key] = value;
|
|
949
|
+
return obj;
|
|
950
|
+
}
|
|
941
951
|
const debug = getDebug('mcp:harmony-tools');
|
|
942
952
|
class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
943
953
|
createTemporaryDevice() {
|
|
@@ -965,10 +975,10 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
965
975
|
{
|
|
966
976
|
name: 'harmony_connect',
|
|
967
977
|
description: 'Connect to HarmonyOS device via HDC. If deviceId not provided, uses the first available device.',
|
|
968
|
-
schema:
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
978
|
+
schema: this.getAgentInitArgSchema(),
|
|
979
|
+
cli: this.getAgentInitArgCliMetadata(),
|
|
980
|
+
handler: async (args)=>{
|
|
981
|
+
const deviceId = this.extractAgentInitParam(args);
|
|
972
982
|
const agent = await this.ensureAgent(deviceId);
|
|
973
983
|
const screenshot = await agent.page.screenshotBase64();
|
|
974
984
|
return {
|
|
@@ -991,6 +1001,18 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
991
1001
|
}
|
|
992
1002
|
];
|
|
993
1003
|
}
|
|
1004
|
+
constructor(...args){
|
|
1005
|
+
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
1006
|
+
namespace: 'harmony',
|
|
1007
|
+
shape: {
|
|
1008
|
+
deviceId: z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
1009
|
+
},
|
|
1010
|
+
cli: {
|
|
1011
|
+
preferBareKeys: true
|
|
1012
|
+
},
|
|
1013
|
+
adapt: (extracted)=>extracted?.deviceId
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
994
1016
|
}
|
|
995
1017
|
async function selectDevice() {
|
|
996
1018
|
console.log('🔍 Scanning for HarmonyOS devices...');
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { BaseMCPServer,
|
|
1
|
+
import { BaseMCPServer, createMCPServerLauncher } from "@midscene/shared/mcp";
|
|
2
2
|
import { getMidsceneLocationSchema, z } from "@midscene/core";
|
|
3
3
|
import { getDebug } from "@midscene/shared/logger";
|
|
4
|
+
import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
|
|
4
5
|
import { Agent } from "@midscene/core/agent";
|
|
5
6
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
|
|
6
7
|
import node_assert from "node:assert";
|
|
@@ -932,6 +933,16 @@ async function agentFromHdcDevice(deviceId, opts) {
|
|
|
932
933
|
await device.connect();
|
|
933
934
|
return new HarmonyAgent(device, opts);
|
|
934
935
|
}
|
|
936
|
+
function mcp_tools_define_property(obj, key, value) {
|
|
937
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
938
|
+
value: value,
|
|
939
|
+
enumerable: true,
|
|
940
|
+
configurable: true,
|
|
941
|
+
writable: true
|
|
942
|
+
});
|
|
943
|
+
else obj[key] = value;
|
|
944
|
+
return obj;
|
|
945
|
+
}
|
|
935
946
|
const debug = getDebug('mcp:harmony-tools');
|
|
936
947
|
class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
937
948
|
createTemporaryDevice() {
|
|
@@ -959,10 +970,10 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
959
970
|
{
|
|
960
971
|
name: 'harmony_connect',
|
|
961
972
|
description: 'Connect to HarmonyOS device via HDC. If deviceId not provided, uses the first available device.',
|
|
962
|
-
schema:
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
973
|
+
schema: this.getAgentInitArgSchema(),
|
|
974
|
+
cli: this.getAgentInitArgCliMetadata(),
|
|
975
|
+
handler: async (args)=>{
|
|
976
|
+
const deviceId = this.extractAgentInitParam(args);
|
|
966
977
|
const agent = await this.ensureAgent(deviceId);
|
|
967
978
|
const screenshot = await agent.page.screenshotBase64();
|
|
968
979
|
return {
|
|
@@ -985,6 +996,18 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
985
996
|
}
|
|
986
997
|
];
|
|
987
998
|
}
|
|
999
|
+
constructor(...args){
|
|
1000
|
+
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
1001
|
+
namespace: 'harmony',
|
|
1002
|
+
shape: {
|
|
1003
|
+
deviceId: z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
1004
|
+
},
|
|
1005
|
+
cli: {
|
|
1006
|
+
preferBareKeys: true
|
|
1007
|
+
},
|
|
1008
|
+
adapt: (extracted)=>extracted?.deviceId
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
988
1011
|
}
|
|
989
1012
|
class HarmonyMCPServer extends BaseMCPServer {
|
|
990
1013
|
createToolsManager() {
|
|
@@ -993,7 +1016,7 @@ class HarmonyMCPServer extends BaseMCPServer {
|
|
|
993
1016
|
constructor(toolsManager){
|
|
994
1017
|
super({
|
|
995
1018
|
name: '@midscene/harmony-mcp',
|
|
996
|
-
version: "1.7.5
|
|
1019
|
+
version: "1.7.5",
|
|
997
1020
|
description: 'Control the HarmonyOS device using natural language commands'
|
|
998
1021
|
}, toolsManager);
|
|
999
1022
|
}
|
package/dist/lib/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ var __webpack_exports__ = {};
|
|
|
24
24
|
const core_namespaceObject = require("@midscene/core");
|
|
25
25
|
const cli_namespaceObject = require("@midscene/shared/cli");
|
|
26
26
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
27
|
-
const
|
|
27
|
+
const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
|
|
28
28
|
const agent_namespaceObject = require("@midscene/core/agent");
|
|
29
29
|
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
30
30
|
const defaultAppNameMapping = {
|
|
@@ -958,8 +958,18 @@ async function agentFromHdcDevice(deviceId, opts) {
|
|
|
958
958
|
await device.connect();
|
|
959
959
|
return new HarmonyAgent(device, opts);
|
|
960
960
|
}
|
|
961
|
+
function mcp_tools_define_property(obj, key, value) {
|
|
962
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
963
|
+
value: value,
|
|
964
|
+
enumerable: true,
|
|
965
|
+
configurable: true,
|
|
966
|
+
writable: true
|
|
967
|
+
});
|
|
968
|
+
else obj[key] = value;
|
|
969
|
+
return obj;
|
|
970
|
+
}
|
|
961
971
|
const debug = (0, logger_namespaceObject.getDebug)('mcp:harmony-tools');
|
|
962
|
-
class HarmonyMidsceneTools extends
|
|
972
|
+
class HarmonyMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
|
|
963
973
|
createTemporaryDevice() {
|
|
964
974
|
return new HarmonyDevice('temp-for-action-space', {});
|
|
965
975
|
}
|
|
@@ -985,10 +995,10 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
985
995
|
{
|
|
986
996
|
name: 'harmony_connect',
|
|
987
997
|
description: 'Connect to HarmonyOS device via HDC. If deviceId not provided, uses the first available device.',
|
|
988
|
-
schema:
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
998
|
+
schema: this.getAgentInitArgSchema(),
|
|
999
|
+
cli: this.getAgentInitArgCliMetadata(),
|
|
1000
|
+
handler: async (args)=>{
|
|
1001
|
+
const deviceId = this.extractAgentInitParam(args);
|
|
992
1002
|
const agent = await this.ensureAgent(deviceId);
|
|
993
1003
|
const screenshot = await agent.page.screenshotBase64();
|
|
994
1004
|
return {
|
|
@@ -1011,15 +1021,26 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
1011
1021
|
}
|
|
1012
1022
|
];
|
|
1013
1023
|
}
|
|
1024
|
+
constructor(...args){
|
|
1025
|
+
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
1026
|
+
namespace: 'harmony',
|
|
1027
|
+
shape: {
|
|
1028
|
+
deviceId: core_namespaceObject.z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
1029
|
+
},
|
|
1030
|
+
cli: {
|
|
1031
|
+
preferBareKeys: true
|
|
1032
|
+
},
|
|
1033
|
+
adapt: (extracted)=>extracted?.deviceId
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1014
1036
|
}
|
|
1015
1037
|
const tools = new HarmonyMidsceneTools();
|
|
1016
1038
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-harmony', {
|
|
1017
1039
|
stripPrefix: 'harmony_',
|
|
1018
|
-
version: "1.7.5
|
|
1040
|
+
version: "1.7.5",
|
|
1019
1041
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
1020
1042
|
}).catch((e)=>{
|
|
1021
|
-
|
|
1022
|
-
process.exit(e instanceof cli_namespaceObject.CLIError ? e.exitCode : 1);
|
|
1043
|
+
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|
|
1023
1044
|
});
|
|
1024
1045
|
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
1025
1046
|
Object.defineProperty(exports, '__esModule', {
|
package/dist/lib/index.js
CHANGED
|
@@ -976,9 +976,19 @@ async function agentFromHdcDevice(deviceId, opts) {
|
|
|
976
976
|
await device.connect();
|
|
977
977
|
return new HarmonyAgent(device, opts);
|
|
978
978
|
}
|
|
979
|
-
const
|
|
979
|
+
const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
|
|
980
|
+
function mcp_tools_define_property(obj, key, value) {
|
|
981
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
982
|
+
value: value,
|
|
983
|
+
enumerable: true,
|
|
984
|
+
configurable: true,
|
|
985
|
+
writable: true
|
|
986
|
+
});
|
|
987
|
+
else obj[key] = value;
|
|
988
|
+
return obj;
|
|
989
|
+
}
|
|
980
990
|
const debug = (0, logger_namespaceObject.getDebug)('mcp:harmony-tools');
|
|
981
|
-
class HarmonyMidsceneTools extends
|
|
991
|
+
class HarmonyMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
|
|
982
992
|
createTemporaryDevice() {
|
|
983
993
|
return new HarmonyDevice('temp-for-action-space', {});
|
|
984
994
|
}
|
|
@@ -1004,10 +1014,10 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
1004
1014
|
{
|
|
1005
1015
|
name: 'harmony_connect',
|
|
1006
1016
|
description: 'Connect to HarmonyOS device via HDC. If deviceId not provided, uses the first available device.',
|
|
1007
|
-
schema:
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1017
|
+
schema: this.getAgentInitArgSchema(),
|
|
1018
|
+
cli: this.getAgentInitArgCliMetadata(),
|
|
1019
|
+
handler: async (args)=>{
|
|
1020
|
+
const deviceId = this.extractAgentInitParam(args);
|
|
1011
1021
|
const agent = await this.ensureAgent(deviceId);
|
|
1012
1022
|
const screenshot = await agent.page.screenshotBase64();
|
|
1013
1023
|
return {
|
|
@@ -1030,6 +1040,18 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
1030
1040
|
}
|
|
1031
1041
|
];
|
|
1032
1042
|
}
|
|
1043
|
+
constructor(...args){
|
|
1044
|
+
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
1045
|
+
namespace: 'harmony',
|
|
1046
|
+
shape: {
|
|
1047
|
+
deviceId: core_namespaceObject.z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
1048
|
+
},
|
|
1049
|
+
cli: {
|
|
1050
|
+
preferBareKeys: true
|
|
1051
|
+
},
|
|
1052
|
+
adapt: (extracted)=>extracted?.deviceId
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1033
1055
|
}
|
|
1034
1056
|
const env_namespaceObject = require("@midscene/shared/env");
|
|
1035
1057
|
const external_node_path_namespaceObject = require("node:path");
|
package/dist/lib/mcp-server.js
CHANGED
|
@@ -40,6 +40,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
40
40
|
const mcp_namespaceObject = require("@midscene/shared/mcp");
|
|
41
41
|
const core_namespaceObject = require("@midscene/core");
|
|
42
42
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
43
|
+
const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
|
|
43
44
|
const agent_namespaceObject = require("@midscene/core/agent");
|
|
44
45
|
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
45
46
|
const defaultAppNameMapping = {
|
|
@@ -973,8 +974,18 @@ async function agentFromHdcDevice(deviceId, opts) {
|
|
|
973
974
|
await device.connect();
|
|
974
975
|
return new HarmonyAgent(device, opts);
|
|
975
976
|
}
|
|
977
|
+
function mcp_tools_define_property(obj, key, value) {
|
|
978
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
979
|
+
value: value,
|
|
980
|
+
enumerable: true,
|
|
981
|
+
configurable: true,
|
|
982
|
+
writable: true
|
|
983
|
+
});
|
|
984
|
+
else obj[key] = value;
|
|
985
|
+
return obj;
|
|
986
|
+
}
|
|
976
987
|
const debug = (0, logger_namespaceObject.getDebug)('mcp:harmony-tools');
|
|
977
|
-
class HarmonyMidsceneTools extends
|
|
988
|
+
class HarmonyMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
|
|
978
989
|
createTemporaryDevice() {
|
|
979
990
|
return new HarmonyDevice('temp-for-action-space', {});
|
|
980
991
|
}
|
|
@@ -1000,10 +1011,10 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
1000
1011
|
{
|
|
1001
1012
|
name: 'harmony_connect',
|
|
1002
1013
|
description: 'Connect to HarmonyOS device via HDC. If deviceId not provided, uses the first available device.',
|
|
1003
|
-
schema:
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1014
|
+
schema: this.getAgentInitArgSchema(),
|
|
1015
|
+
cli: this.getAgentInitArgCliMetadata(),
|
|
1016
|
+
handler: async (args)=>{
|
|
1017
|
+
const deviceId = this.extractAgentInitParam(args);
|
|
1007
1018
|
const agent = await this.ensureAgent(deviceId);
|
|
1008
1019
|
const screenshot = await agent.page.screenshotBase64();
|
|
1009
1020
|
return {
|
|
@@ -1026,6 +1037,18 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
1026
1037
|
}
|
|
1027
1038
|
];
|
|
1028
1039
|
}
|
|
1040
|
+
constructor(...args){
|
|
1041
|
+
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
1042
|
+
namespace: 'harmony',
|
|
1043
|
+
shape: {
|
|
1044
|
+
deviceId: core_namespaceObject.z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
1045
|
+
},
|
|
1046
|
+
cli: {
|
|
1047
|
+
preferBareKeys: true
|
|
1048
|
+
},
|
|
1049
|
+
adapt: (extracted)=>extracted?.deviceId
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1029
1052
|
}
|
|
1030
1053
|
class HarmonyMCPServer extends mcp_namespaceObject.BaseMCPServer {
|
|
1031
1054
|
createToolsManager() {
|
|
@@ -1034,7 +1057,7 @@ class HarmonyMCPServer extends mcp_namespaceObject.BaseMCPServer {
|
|
|
1034
1057
|
constructor(toolsManager){
|
|
1035
1058
|
super({
|
|
1036
1059
|
name: '@midscene/harmony-mcp',
|
|
1037
|
-
version: "1.7.5
|
|
1060
|
+
version: "1.7.5",
|
|
1038
1061
|
description: 'Control the HarmonyOS device using natural language commands'
|
|
1039
1062
|
}, toolsManager);
|
|
1040
1063
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,17 +3,18 @@ import type { ActionParam } from '@midscene/core';
|
|
|
3
3
|
import type { ActionReturn } from '@midscene/core';
|
|
4
4
|
import { Agent } from '@midscene/core/agent';
|
|
5
5
|
import { AgentOpt } from '@midscene/core/agent';
|
|
6
|
-
import { BaseMidsceneTools } from '@midscene/shared/mcp';
|
|
6
|
+
import { BaseMidsceneTools } from '@midscene/shared/mcp/base-tools';
|
|
7
7
|
import { DeviceAction } from '@midscene/core';
|
|
8
8
|
import type { ElementInfo } from '@midscene/shared/extractor';
|
|
9
9
|
import { HarmonyDeviceOpt } from '@midscene/core/device';
|
|
10
|
+
import { InitArgSpec } from '@midscene/shared/mcp/base-tools';
|
|
10
11
|
import { InterfaceType } from '@midscene/core';
|
|
11
12
|
import { LocateResultElement } from '@midscene/core';
|
|
12
13
|
import { overrideAIConfig } from '@midscene/shared/env';
|
|
13
14
|
import { PlaygroundPlatformDescriptor } from '@midscene/playground';
|
|
14
15
|
import { Point } from '@midscene/core';
|
|
15
16
|
import { Size } from '@midscene/core';
|
|
16
|
-
import { ToolDefinition } from '@midscene/shared/mcp';
|
|
17
|
+
import type { ToolDefinition } from '@midscene/shared/mcp/types';
|
|
17
18
|
|
|
18
19
|
declare type ActionArgs<T extends DeviceAction> = [ActionParam<T>] extends [undefined] ? [] : [ActionParam<T>];
|
|
19
20
|
|
|
@@ -111,7 +112,8 @@ declare interface HarmonyDeviceInfo {
|
|
|
111
112
|
deviceId: string;
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
export declare class HarmonyMidsceneTools extends BaseMidsceneTools<HarmonyAgent> {
|
|
115
|
+
export declare class HarmonyMidsceneTools extends BaseMidsceneTools<HarmonyAgent, string> {
|
|
116
|
+
protected readonly initArgSpec: InitArgSpec<string>;
|
|
115
117
|
protected createTemporaryDevice(): HarmonyDevice;
|
|
116
118
|
protected ensureAgent(deviceId?: string): Promise<HarmonyAgent>;
|
|
117
119
|
protected preparePlatformTools(): ToolDefinition[];
|
|
@@ -4,10 +4,11 @@ import type { ActionReturn } from '@midscene/core';
|
|
|
4
4
|
import { Agent } from '@midscene/core/agent';
|
|
5
5
|
import { AgentOpt } from '@midscene/core/agent';
|
|
6
6
|
import { BaseMCPServer } from '@midscene/shared/mcp';
|
|
7
|
-
import { BaseMidsceneTools } from '@midscene/shared/mcp';
|
|
7
|
+
import { BaseMidsceneTools } from '@midscene/shared/mcp/base-tools';
|
|
8
8
|
import { DeviceAction } from '@midscene/core';
|
|
9
9
|
import type { ElementInfo } from '@midscene/shared/extractor';
|
|
10
10
|
import { HarmonyDeviceOpt } from '@midscene/core/device';
|
|
11
|
+
import { InitArgSpec } from '@midscene/shared/mcp/base-tools';
|
|
11
12
|
import { InterfaceType } from '@midscene/core';
|
|
12
13
|
import { LaunchMCPServerOptions } from '@midscene/shared/mcp';
|
|
13
14
|
import { LaunchMCPServerResult } from '@midscene/shared/mcp';
|
|
@@ -15,7 +16,7 @@ import { LocateResultElement } from '@midscene/core';
|
|
|
15
16
|
import { Point } from '@midscene/core';
|
|
16
17
|
import { Size } from '@midscene/core';
|
|
17
18
|
import { Tool } from '@midscene/shared/mcp';
|
|
18
|
-
import { ToolDefinition } from '@midscene/shared/mcp';
|
|
19
|
+
import type { ToolDefinition } from '@midscene/shared/mcp/types';
|
|
19
20
|
|
|
20
21
|
declare type ActionArgs<T extends DeviceAction> = [ActionParam<T>] extends [undefined] ? [] : [ActionParam<T>];
|
|
21
22
|
|
|
@@ -110,7 +111,8 @@ export declare class HarmonyMCPServer extends BaseMCPServer {
|
|
|
110
111
|
protected createToolsManager(): HarmonyMidsceneTools;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
declare class HarmonyMidsceneTools extends BaseMidsceneTools<HarmonyAgent> {
|
|
114
|
+
declare class HarmonyMidsceneTools extends BaseMidsceneTools<HarmonyAgent, string> {
|
|
115
|
+
protected readonly initArgSpec: InitArgSpec<string>;
|
|
114
116
|
protected createTemporaryDevice(): HarmonyDevice;
|
|
115
117
|
protected ensureAgent(deviceId?: string): Promise<HarmonyAgent>;
|
|
116
118
|
protected preparePlatformTools(): ToolDefinition[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/harmony",
|
|
3
|
-
"version": "1.7.5
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "HarmonyOS automation library for Midscene",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"HarmonyOS UI automation",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@inquirer/prompts": "^7.8.6",
|
|
43
43
|
"open": "10.1.0",
|
|
44
|
-
"@midscene/
|
|
45
|
-
"@midscene/
|
|
46
|
-
"@midscene/shared": "1.7.5
|
|
44
|
+
"@midscene/playground": "1.7.5",
|
|
45
|
+
"@midscene/core": "1.7.5",
|
|
46
|
+
"@midscene/shared": "1.7.5"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@rslib/core": "^0.18.3",
|
package/static/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.7b1abe58.js"></script><script defer src="/static/js/
|
|
1
|
+
<!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.7b1abe58.js"></script><script defer src="/static/js/883.516361ae.js"></script><script defer src="/static/js/index.3bea1f00.js"></script><link href="/static/css/index.dc500f18.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
|