@midscene/harmony 1.5.4 → 1.5.5-beta-20260311070351.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 +48 -17
- package/dist/es/index.mjs +47 -16
- package/dist/es/mcp-server.mjs +48 -17
- package/dist/lib/cli.js +47 -16
- package/dist/lib/index.js +46 -15
- package/dist/lib/mcp-server.js +47 -16
- package/package.json +4 -4
- package/static/index.html +1 -1
- package/static/static/js/{index.1f580227.js → index.025d3abf.js} +5 -5
- package/static/static/js/index.025d3abf.js.map +1 -0
- package/static/static/js/index.1f580227.js.map +0 -1
- /package/static/static/js/{index.1f580227.js.LICENSE.txt → index.025d3abf.js.LICENSE.txt} +0 -0
package/dist/es/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CLIError, runToolsCLI } from "@midscene/shared/cli";
|
|
2
|
-
import { getMidsceneLocationSchema, z } from "@midscene/core";
|
|
2
|
+
import { createSessionAgentOptions, exportSessionReport, getMidsceneLocationSchema, z } from "@midscene/core";
|
|
3
3
|
import { getDebug } from "@midscene/shared/logger";
|
|
4
4
|
import { BaseMidsceneTools } from "@midscene/shared/mcp";
|
|
5
5
|
import { Agent } from "@midscene/core/agent";
|
|
@@ -910,8 +910,15 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
910
910
|
}
|
|
911
911
|
if (this.agent) return this.agent;
|
|
912
912
|
debug('Creating Harmony agent with deviceId:', deviceId || 'auto-detect');
|
|
913
|
+
const sessionOptions = createSessionAgentOptions({
|
|
914
|
+
sessionId: this.getInvocationStringArg('sessionId'),
|
|
915
|
+
platform: 'harmony',
|
|
916
|
+
commandId: this.getInvocationCommandId(),
|
|
917
|
+
commandName: this.getInvocationCommandName()
|
|
918
|
+
});
|
|
913
919
|
const agent = await agentFromHdcDevice(deviceId, {
|
|
914
|
-
autoDismissKeyboard: false
|
|
920
|
+
autoDismissKeyboard: false,
|
|
921
|
+
...sessionOptions
|
|
915
922
|
});
|
|
916
923
|
this.agent = agent;
|
|
917
924
|
return agent;
|
|
@@ -924,26 +931,50 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
924
931
|
schema: {
|
|
925
932
|
deviceId: z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
926
933
|
},
|
|
927
|
-
handler: async (
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
934
|
+
handler: async (args)=>this.runWithInvocationContext({
|
|
935
|
+
...args,
|
|
936
|
+
__commandName: 'harmony_connect'
|
|
937
|
+
}, async ()=>{
|
|
938
|
+
const agent = await this.ensureAgent(args.deviceId);
|
|
939
|
+
const screenshot = await agent.page.screenshotBase64();
|
|
940
|
+
return {
|
|
941
|
+
content: [
|
|
942
|
+
{
|
|
943
|
+
type: 'text',
|
|
944
|
+
text: `Connected to HarmonyOS device${args.deviceId ? `: ${args.deviceId}` : ' (auto-detected)'}`
|
|
945
|
+
},
|
|
946
|
+
...this.buildScreenshotContent(screenshot)
|
|
947
|
+
],
|
|
948
|
+
isError: false
|
|
949
|
+
};
|
|
950
|
+
})
|
|
941
951
|
},
|
|
942
952
|
{
|
|
943
953
|
name: 'harmony_disconnect',
|
|
944
954
|
description: 'Disconnect from current HarmonyOS device and release HDC resources',
|
|
945
955
|
schema: {},
|
|
946
956
|
handler: this.createDisconnectHandler('HarmonyOS device')
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
name: 'harmony_export_session_report',
|
|
960
|
+
description: 'Generate a merged HTML report from a persisted HarmonyOS session',
|
|
961
|
+
schema: {
|
|
962
|
+
sessionId: z.string().describe('Persistent session ID to export')
|
|
963
|
+
},
|
|
964
|
+
handler: async (args)=>{
|
|
965
|
+
const sessionId = args.sessionId;
|
|
966
|
+
if ('string' != typeof sessionId || !sessionId) return {
|
|
967
|
+
content: [
|
|
968
|
+
{
|
|
969
|
+
type: 'text',
|
|
970
|
+
text: 'sessionId is required to export a session report'
|
|
971
|
+
}
|
|
972
|
+
],
|
|
973
|
+
isError: true
|
|
974
|
+
};
|
|
975
|
+
const reportPath = exportSessionReport(sessionId);
|
|
976
|
+
return this.buildTextResult(`Session report generated: ${reportPath}`);
|
|
977
|
+
}
|
|
947
978
|
}
|
|
948
979
|
];
|
|
949
980
|
}
|
|
@@ -951,7 +982,7 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
951
982
|
const tools = new HarmonyMidsceneTools();
|
|
952
983
|
runToolsCLI(tools, 'midscene-harmony', {
|
|
953
984
|
stripPrefix: 'harmony_',
|
|
954
|
-
version: "1.5.
|
|
985
|
+
version: "1.5.5-beta-20260311070351.0"
|
|
955
986
|
}).catch((e)=>{
|
|
956
987
|
if (!(e instanceof CLIError)) console.error(e);
|
|
957
988
|
process.exit(e instanceof CLIError ? e.exitCode : 1);
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import node_assert from "node:assert";
|
|
2
2
|
import node_fs, { accessSync, constants } from "node:fs";
|
|
3
|
-
import { getMidsceneLocationSchema, z } from "@midscene/core";
|
|
3
|
+
import { createSessionAgentOptions, exportSessionReport, getMidsceneLocationSchema, z } from "@midscene/core";
|
|
4
4
|
import { defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionScroll, defineActionSwipe, defineActionTap, normalizeMobileSwipeParam } from "@midscene/core/device";
|
|
5
5
|
import { getTmpFile, sleep } from "@midscene/core/utils";
|
|
6
6
|
import { createImgBase64ByFormat } from "@midscene/shared/img";
|
|
@@ -910,8 +910,15 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
910
910
|
}
|
|
911
911
|
if (this.agent) return this.agent;
|
|
912
912
|
debug('Creating Harmony agent with deviceId:', deviceId || 'auto-detect');
|
|
913
|
+
const sessionOptions = createSessionAgentOptions({
|
|
914
|
+
sessionId: this.getInvocationStringArg('sessionId'),
|
|
915
|
+
platform: 'harmony',
|
|
916
|
+
commandId: this.getInvocationCommandId(),
|
|
917
|
+
commandName: this.getInvocationCommandName()
|
|
918
|
+
});
|
|
913
919
|
const agent = await agentFromHdcDevice(deviceId, {
|
|
914
|
-
autoDismissKeyboard: false
|
|
920
|
+
autoDismissKeyboard: false,
|
|
921
|
+
...sessionOptions
|
|
915
922
|
});
|
|
916
923
|
this.agent = agent;
|
|
917
924
|
return agent;
|
|
@@ -924,26 +931,50 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
924
931
|
schema: {
|
|
925
932
|
deviceId: z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
926
933
|
},
|
|
927
|
-
handler: async (
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
934
|
+
handler: async (args)=>this.runWithInvocationContext({
|
|
935
|
+
...args,
|
|
936
|
+
__commandName: 'harmony_connect'
|
|
937
|
+
}, async ()=>{
|
|
938
|
+
const agent = await this.ensureAgent(args.deviceId);
|
|
939
|
+
const screenshot = await agent.page.screenshotBase64();
|
|
940
|
+
return {
|
|
941
|
+
content: [
|
|
942
|
+
{
|
|
943
|
+
type: 'text',
|
|
944
|
+
text: `Connected to HarmonyOS device${args.deviceId ? `: ${args.deviceId}` : ' (auto-detected)'}`
|
|
945
|
+
},
|
|
946
|
+
...this.buildScreenshotContent(screenshot)
|
|
947
|
+
],
|
|
948
|
+
isError: false
|
|
949
|
+
};
|
|
950
|
+
})
|
|
941
951
|
},
|
|
942
952
|
{
|
|
943
953
|
name: 'harmony_disconnect',
|
|
944
954
|
description: 'Disconnect from current HarmonyOS device and release HDC resources',
|
|
945
955
|
schema: {},
|
|
946
956
|
handler: this.createDisconnectHandler('HarmonyOS device')
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
name: 'harmony_export_session_report',
|
|
960
|
+
description: 'Generate a merged HTML report from a persisted HarmonyOS session',
|
|
961
|
+
schema: {
|
|
962
|
+
sessionId: z.string().describe('Persistent session ID to export')
|
|
963
|
+
},
|
|
964
|
+
handler: async (args)=>{
|
|
965
|
+
const sessionId = args.sessionId;
|
|
966
|
+
if ('string' != typeof sessionId || !sessionId) return {
|
|
967
|
+
content: [
|
|
968
|
+
{
|
|
969
|
+
type: 'text',
|
|
970
|
+
text: 'sessionId is required to export a session report'
|
|
971
|
+
}
|
|
972
|
+
],
|
|
973
|
+
isError: true
|
|
974
|
+
};
|
|
975
|
+
const reportPath = exportSessionReport(sessionId);
|
|
976
|
+
return this.buildTextResult(`Session report generated: ${reportPath}`);
|
|
977
|
+
}
|
|
947
978
|
}
|
|
948
979
|
];
|
|
949
980
|
}
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseMCPServer, BaseMidsceneTools, createMCPServerLauncher } from "@midscene/shared/mcp";
|
|
2
|
-
import { getMidsceneLocationSchema, z } from "@midscene/core";
|
|
2
|
+
import { createSessionAgentOptions, exportSessionReport, getMidsceneLocationSchema, z } from "@midscene/core";
|
|
3
3
|
import { getDebug } from "@midscene/shared/logger";
|
|
4
4
|
import { Agent } from "@midscene/core/agent";
|
|
5
5
|
import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
|
|
@@ -909,8 +909,15 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
909
909
|
}
|
|
910
910
|
if (this.agent) return this.agent;
|
|
911
911
|
debug('Creating Harmony agent with deviceId:', deviceId || 'auto-detect');
|
|
912
|
+
const sessionOptions = createSessionAgentOptions({
|
|
913
|
+
sessionId: this.getInvocationStringArg('sessionId'),
|
|
914
|
+
platform: 'harmony',
|
|
915
|
+
commandId: this.getInvocationCommandId(),
|
|
916
|
+
commandName: this.getInvocationCommandName()
|
|
917
|
+
});
|
|
912
918
|
const agent = await agentFromHdcDevice(deviceId, {
|
|
913
|
-
autoDismissKeyboard: false
|
|
919
|
+
autoDismissKeyboard: false,
|
|
920
|
+
...sessionOptions
|
|
914
921
|
});
|
|
915
922
|
this.agent = agent;
|
|
916
923
|
return agent;
|
|
@@ -923,26 +930,50 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
923
930
|
schema: {
|
|
924
931
|
deviceId: z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
925
932
|
},
|
|
926
|
-
handler: async (
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
933
|
+
handler: async (args)=>this.runWithInvocationContext({
|
|
934
|
+
...args,
|
|
935
|
+
__commandName: 'harmony_connect'
|
|
936
|
+
}, async ()=>{
|
|
937
|
+
const agent = await this.ensureAgent(args.deviceId);
|
|
938
|
+
const screenshot = await agent.page.screenshotBase64();
|
|
939
|
+
return {
|
|
940
|
+
content: [
|
|
941
|
+
{
|
|
942
|
+
type: 'text',
|
|
943
|
+
text: `Connected to HarmonyOS device${args.deviceId ? `: ${args.deviceId}` : ' (auto-detected)'}`
|
|
944
|
+
},
|
|
945
|
+
...this.buildScreenshotContent(screenshot)
|
|
946
|
+
],
|
|
947
|
+
isError: false
|
|
948
|
+
};
|
|
949
|
+
})
|
|
940
950
|
},
|
|
941
951
|
{
|
|
942
952
|
name: 'harmony_disconnect',
|
|
943
953
|
description: 'Disconnect from current HarmonyOS device and release HDC resources',
|
|
944
954
|
schema: {},
|
|
945
955
|
handler: this.createDisconnectHandler('HarmonyOS device')
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
name: 'harmony_export_session_report',
|
|
959
|
+
description: 'Generate a merged HTML report from a persisted HarmonyOS session',
|
|
960
|
+
schema: {
|
|
961
|
+
sessionId: z.string().describe('Persistent session ID to export')
|
|
962
|
+
},
|
|
963
|
+
handler: async (args)=>{
|
|
964
|
+
const sessionId = args.sessionId;
|
|
965
|
+
if ('string' != typeof sessionId || !sessionId) return {
|
|
966
|
+
content: [
|
|
967
|
+
{
|
|
968
|
+
type: 'text',
|
|
969
|
+
text: 'sessionId is required to export a session report'
|
|
970
|
+
}
|
|
971
|
+
],
|
|
972
|
+
isError: true
|
|
973
|
+
};
|
|
974
|
+
const reportPath = exportSessionReport(sessionId);
|
|
975
|
+
return this.buildTextResult(`Session report generated: ${reportPath}`);
|
|
976
|
+
}
|
|
946
977
|
}
|
|
947
978
|
];
|
|
948
979
|
}
|
|
@@ -954,7 +985,7 @@ class HarmonyMCPServer extends BaseMCPServer {
|
|
|
954
985
|
constructor(toolsManager){
|
|
955
986
|
super({
|
|
956
987
|
name: '@midscene/harmony-mcp',
|
|
957
|
-
version: "1.5.
|
|
988
|
+
version: "1.5.5-beta-20260311070351.0",
|
|
958
989
|
description: 'Control the HarmonyOS device using natural language commands'
|
|
959
990
|
}, toolsManager);
|
|
960
991
|
}
|
package/dist/lib/cli.js
CHANGED
|
@@ -935,8 +935,15 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
935
935
|
}
|
|
936
936
|
if (this.agent) return this.agent;
|
|
937
937
|
debug('Creating Harmony agent with deviceId:', deviceId || 'auto-detect');
|
|
938
|
+
const sessionOptions = (0, core_namespaceObject.createSessionAgentOptions)({
|
|
939
|
+
sessionId: this.getInvocationStringArg('sessionId'),
|
|
940
|
+
platform: 'harmony',
|
|
941
|
+
commandId: this.getInvocationCommandId(),
|
|
942
|
+
commandName: this.getInvocationCommandName()
|
|
943
|
+
});
|
|
938
944
|
const agent = await agentFromHdcDevice(deviceId, {
|
|
939
|
-
autoDismissKeyboard: false
|
|
945
|
+
autoDismissKeyboard: false,
|
|
946
|
+
...sessionOptions
|
|
940
947
|
});
|
|
941
948
|
this.agent = agent;
|
|
942
949
|
return agent;
|
|
@@ -949,26 +956,50 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
949
956
|
schema: {
|
|
950
957
|
deviceId: core_namespaceObject.z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
951
958
|
},
|
|
952
|
-
handler: async (
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
959
|
+
handler: async (args)=>this.runWithInvocationContext({
|
|
960
|
+
...args,
|
|
961
|
+
__commandName: 'harmony_connect'
|
|
962
|
+
}, async ()=>{
|
|
963
|
+
const agent = await this.ensureAgent(args.deviceId);
|
|
964
|
+
const screenshot = await agent.page.screenshotBase64();
|
|
965
|
+
return {
|
|
966
|
+
content: [
|
|
967
|
+
{
|
|
968
|
+
type: 'text',
|
|
969
|
+
text: `Connected to HarmonyOS device${args.deviceId ? `: ${args.deviceId}` : ' (auto-detected)'}`
|
|
970
|
+
},
|
|
971
|
+
...this.buildScreenshotContent(screenshot)
|
|
972
|
+
],
|
|
973
|
+
isError: false
|
|
974
|
+
};
|
|
975
|
+
})
|
|
966
976
|
},
|
|
967
977
|
{
|
|
968
978
|
name: 'harmony_disconnect',
|
|
969
979
|
description: 'Disconnect from current HarmonyOS device and release HDC resources',
|
|
970
980
|
schema: {},
|
|
971
981
|
handler: this.createDisconnectHandler('HarmonyOS device')
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
name: 'harmony_export_session_report',
|
|
985
|
+
description: 'Generate a merged HTML report from a persisted HarmonyOS session',
|
|
986
|
+
schema: {
|
|
987
|
+
sessionId: core_namespaceObject.z.string().describe('Persistent session ID to export')
|
|
988
|
+
},
|
|
989
|
+
handler: async (args)=>{
|
|
990
|
+
const sessionId = args.sessionId;
|
|
991
|
+
if ('string' != typeof sessionId || !sessionId) return {
|
|
992
|
+
content: [
|
|
993
|
+
{
|
|
994
|
+
type: 'text',
|
|
995
|
+
text: 'sessionId is required to export a session report'
|
|
996
|
+
}
|
|
997
|
+
],
|
|
998
|
+
isError: true
|
|
999
|
+
};
|
|
1000
|
+
const reportPath = (0, core_namespaceObject.exportSessionReport)(sessionId);
|
|
1001
|
+
return this.buildTextResult(`Session report generated: ${reportPath}`);
|
|
1002
|
+
}
|
|
972
1003
|
}
|
|
973
1004
|
];
|
|
974
1005
|
}
|
|
@@ -976,7 +1007,7 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
976
1007
|
const tools = new HarmonyMidsceneTools();
|
|
977
1008
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-harmony', {
|
|
978
1009
|
stripPrefix: 'harmony_',
|
|
979
|
-
version: "1.5.
|
|
1010
|
+
version: "1.5.5-beta-20260311070351.0"
|
|
980
1011
|
}).catch((e)=>{
|
|
981
1012
|
if (!(e instanceof cli_namespaceObject.CLIError)) console.error(e);
|
|
982
1013
|
process.exit(e instanceof cli_namespaceObject.CLIError ? e.exitCode : 1);
|
package/dist/lib/index.js
CHANGED
|
@@ -953,8 +953,15 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
953
953
|
}
|
|
954
954
|
if (this.agent) return this.agent;
|
|
955
955
|
debug('Creating Harmony agent with deviceId:', deviceId || 'auto-detect');
|
|
956
|
+
const sessionOptions = (0, core_namespaceObject.createSessionAgentOptions)({
|
|
957
|
+
sessionId: this.getInvocationStringArg('sessionId'),
|
|
958
|
+
platform: 'harmony',
|
|
959
|
+
commandId: this.getInvocationCommandId(),
|
|
960
|
+
commandName: this.getInvocationCommandName()
|
|
961
|
+
});
|
|
956
962
|
const agent = await agentFromHdcDevice(deviceId, {
|
|
957
|
-
autoDismissKeyboard: false
|
|
963
|
+
autoDismissKeyboard: false,
|
|
964
|
+
...sessionOptions
|
|
958
965
|
});
|
|
959
966
|
this.agent = agent;
|
|
960
967
|
return agent;
|
|
@@ -967,26 +974,50 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
967
974
|
schema: {
|
|
968
975
|
deviceId: core_namespaceObject.z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
969
976
|
},
|
|
970
|
-
handler: async (
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
977
|
+
handler: async (args)=>this.runWithInvocationContext({
|
|
978
|
+
...args,
|
|
979
|
+
__commandName: 'harmony_connect'
|
|
980
|
+
}, async ()=>{
|
|
981
|
+
const agent = await this.ensureAgent(args.deviceId);
|
|
982
|
+
const screenshot = await agent.page.screenshotBase64();
|
|
983
|
+
return {
|
|
984
|
+
content: [
|
|
985
|
+
{
|
|
986
|
+
type: 'text',
|
|
987
|
+
text: `Connected to HarmonyOS device${args.deviceId ? `: ${args.deviceId}` : ' (auto-detected)'}`
|
|
988
|
+
},
|
|
989
|
+
...this.buildScreenshotContent(screenshot)
|
|
990
|
+
],
|
|
991
|
+
isError: false
|
|
992
|
+
};
|
|
993
|
+
})
|
|
984
994
|
},
|
|
985
995
|
{
|
|
986
996
|
name: 'harmony_disconnect',
|
|
987
997
|
description: 'Disconnect from current HarmonyOS device and release HDC resources',
|
|
988
998
|
schema: {},
|
|
989
999
|
handler: this.createDisconnectHandler('HarmonyOS device')
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
name: 'harmony_export_session_report',
|
|
1003
|
+
description: 'Generate a merged HTML report from a persisted HarmonyOS session',
|
|
1004
|
+
schema: {
|
|
1005
|
+
sessionId: core_namespaceObject.z.string().describe('Persistent session ID to export')
|
|
1006
|
+
},
|
|
1007
|
+
handler: async (args)=>{
|
|
1008
|
+
const sessionId = args.sessionId;
|
|
1009
|
+
if ('string' != typeof sessionId || !sessionId) return {
|
|
1010
|
+
content: [
|
|
1011
|
+
{
|
|
1012
|
+
type: 'text',
|
|
1013
|
+
text: 'sessionId is required to export a session report'
|
|
1014
|
+
}
|
|
1015
|
+
],
|
|
1016
|
+
isError: true
|
|
1017
|
+
};
|
|
1018
|
+
const reportPath = (0, core_namespaceObject.exportSessionReport)(sessionId);
|
|
1019
|
+
return this.buildTextResult(`Session report generated: ${reportPath}`);
|
|
1020
|
+
}
|
|
990
1021
|
}
|
|
991
1022
|
];
|
|
992
1023
|
}
|
package/dist/lib/mcp-server.js
CHANGED
|
@@ -950,8 +950,15 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
950
950
|
}
|
|
951
951
|
if (this.agent) return this.agent;
|
|
952
952
|
debug('Creating Harmony agent with deviceId:', deviceId || 'auto-detect');
|
|
953
|
+
const sessionOptions = (0, core_namespaceObject.createSessionAgentOptions)({
|
|
954
|
+
sessionId: this.getInvocationStringArg('sessionId'),
|
|
955
|
+
platform: 'harmony',
|
|
956
|
+
commandId: this.getInvocationCommandId(),
|
|
957
|
+
commandName: this.getInvocationCommandName()
|
|
958
|
+
});
|
|
953
959
|
const agent = await agentFromHdcDevice(deviceId, {
|
|
954
|
-
autoDismissKeyboard: false
|
|
960
|
+
autoDismissKeyboard: false,
|
|
961
|
+
...sessionOptions
|
|
955
962
|
});
|
|
956
963
|
this.agent = agent;
|
|
957
964
|
return agent;
|
|
@@ -964,26 +971,50 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
964
971
|
schema: {
|
|
965
972
|
deviceId: core_namespaceObject.z.string().optional().describe('HarmonyOS device ID (from hdc list targets)')
|
|
966
973
|
},
|
|
967
|
-
handler: async (
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
974
|
+
handler: async (args)=>this.runWithInvocationContext({
|
|
975
|
+
...args,
|
|
976
|
+
__commandName: 'harmony_connect'
|
|
977
|
+
}, async ()=>{
|
|
978
|
+
const agent = await this.ensureAgent(args.deviceId);
|
|
979
|
+
const screenshot = await agent.page.screenshotBase64();
|
|
980
|
+
return {
|
|
981
|
+
content: [
|
|
982
|
+
{
|
|
983
|
+
type: 'text',
|
|
984
|
+
text: `Connected to HarmonyOS device${args.deviceId ? `: ${args.deviceId}` : ' (auto-detected)'}`
|
|
985
|
+
},
|
|
986
|
+
...this.buildScreenshotContent(screenshot)
|
|
987
|
+
],
|
|
988
|
+
isError: false
|
|
989
|
+
};
|
|
990
|
+
})
|
|
981
991
|
},
|
|
982
992
|
{
|
|
983
993
|
name: 'harmony_disconnect',
|
|
984
994
|
description: 'Disconnect from current HarmonyOS device and release HDC resources',
|
|
985
995
|
schema: {},
|
|
986
996
|
handler: this.createDisconnectHandler('HarmonyOS device')
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
name: 'harmony_export_session_report',
|
|
1000
|
+
description: 'Generate a merged HTML report from a persisted HarmonyOS session',
|
|
1001
|
+
schema: {
|
|
1002
|
+
sessionId: core_namespaceObject.z.string().describe('Persistent session ID to export')
|
|
1003
|
+
},
|
|
1004
|
+
handler: async (args)=>{
|
|
1005
|
+
const sessionId = args.sessionId;
|
|
1006
|
+
if ('string' != typeof sessionId || !sessionId) return {
|
|
1007
|
+
content: [
|
|
1008
|
+
{
|
|
1009
|
+
type: 'text',
|
|
1010
|
+
text: 'sessionId is required to export a session report'
|
|
1011
|
+
}
|
|
1012
|
+
],
|
|
1013
|
+
isError: true
|
|
1014
|
+
};
|
|
1015
|
+
const reportPath = (0, core_namespaceObject.exportSessionReport)(sessionId);
|
|
1016
|
+
return this.buildTextResult(`Session report generated: ${reportPath}`);
|
|
1017
|
+
}
|
|
987
1018
|
}
|
|
988
1019
|
];
|
|
989
1020
|
}
|
|
@@ -995,7 +1026,7 @@ class HarmonyMCPServer extends mcp_namespaceObject.BaseMCPServer {
|
|
|
995
1026
|
constructor(toolsManager){
|
|
996
1027
|
super({
|
|
997
1028
|
name: '@midscene/harmony-mcp',
|
|
998
|
-
version: "1.5.
|
|
1029
|
+
version: "1.5.5-beta-20260311070351.0",
|
|
999
1030
|
description: 'Control the HarmonyOS device using natural language commands'
|
|
1000
1031
|
}, toolsManager);
|
|
1001
1032
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/harmony",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5-beta-20260311070351.0",
|
|
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/core": "1.5.
|
|
45
|
-
"@midscene/
|
|
46
|
-
"@midscene/
|
|
44
|
+
"@midscene/core": "1.5.5-beta-20260311070351.0",
|
|
45
|
+
"@midscene/shared": "1.5.5-beta-20260311070351.0",
|
|
46
|
+
"@midscene/playground": "1.5.5-beta-20260311070351.0"
|
|
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/148.23cd9828.js"></script><script defer src="/static/js/index.
|
|
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/148.23cd9828.js"></script><script defer src="/static/js/index.025d3abf.js"></script><link href="/static/css/index.b190a147.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
|