@midscene/computer 1.7.5-beta-20260420052829.0 → 1.7.5-beta-20260420061332.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 +14 -39
- package/dist/es/index.mjs +14 -39
- package/dist/es/mcp-server.mjs +14 -40
- package/dist/lib/cli.js +15 -40
- package/dist/lib/index.js +15 -40
- package/dist/lib/mcp-server.js +14 -40
- package/dist/types/index.d.ts +4 -8
- package/dist/types/mcp-server.d.ts +4 -8
- package/package.json +3 -3
package/dist/es/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createReportCliCommands, getMidsceneLocationSchema, z } from "@midscene/core";
|
|
2
2
|
import { CLIError, 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";
|
|
5
5
|
import { Agent } from "@midscene/core/agent";
|
|
6
6
|
import node_assert from "node:assert";
|
|
7
7
|
import { execFileSync, execSync, spawn, spawnSync } from "node:child_process";
|
|
@@ -409,7 +409,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
409
409
|
}
|
|
410
410
|
async healthCheck() {
|
|
411
411
|
console.log('[HealthCheck] Starting health check...');
|
|
412
|
-
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-
|
|
412
|
+
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420061332.0");
|
|
413
413
|
console.log('[HealthCheck] Taking screenshot...');
|
|
414
414
|
const screenshotTimeout = 15000;
|
|
415
415
|
let timeoutId;
|
|
@@ -815,29 +815,13 @@ async function agentFromComputer(opts) {
|
|
|
815
815
|
await device.connect();
|
|
816
816
|
return new ComputerAgent(device, opts);
|
|
817
817
|
}
|
|
818
|
-
function mcp_tools_define_property(obj, key, value) {
|
|
819
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
820
|
-
value: value,
|
|
821
|
-
enumerable: true,
|
|
822
|
-
configurable: true,
|
|
823
|
-
writable: true
|
|
824
|
-
});
|
|
825
|
-
else obj[key] = value;
|
|
826
|
-
return obj;
|
|
827
|
-
}
|
|
828
818
|
const debug = getDebug('mcp:computer-tools');
|
|
829
|
-
const computerInitArgShape = {
|
|
830
|
-
displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
831
|
-
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
832
|
-
};
|
|
833
819
|
class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
834
820
|
createTemporaryDevice() {
|
|
835
821
|
return new ComputerDevice({});
|
|
836
822
|
}
|
|
837
|
-
async ensureAgent(
|
|
838
|
-
|
|
839
|
-
const headless = opts?.headless;
|
|
840
|
-
if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
|
|
823
|
+
async ensureAgent(displayId, headless) {
|
|
824
|
+
if (this.agent && displayId) {
|
|
841
825
|
try {
|
|
842
826
|
await this.agent.destroy?.();
|
|
843
827
|
} catch (error) {
|
|
@@ -847,7 +831,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
847
831
|
}
|
|
848
832
|
if (this.agent) return this.agent;
|
|
849
833
|
debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
850
|
-
const
|
|
834
|
+
const opts = {
|
|
851
835
|
...displayId ? {
|
|
852
836
|
displayId
|
|
853
837
|
} : {},
|
|
@@ -855,7 +839,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
855
839
|
headless
|
|
856
840
|
} : {}
|
|
857
841
|
};
|
|
858
|
-
const agent = await agentFromComputer(Object.keys(
|
|
842
|
+
const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
|
|
859
843
|
this.agent = agent;
|
|
860
844
|
return agent;
|
|
861
845
|
}
|
|
@@ -864,17 +848,18 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
864
848
|
{
|
|
865
849
|
name: 'computer_connect',
|
|
866
850
|
description: 'Connect to computer desktop. Provide displayId to connect to a specific display (use computer_list_displays to get available IDs). If not provided, uses the primary display.',
|
|
867
|
-
schema:
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
851
|
+
schema: {
|
|
852
|
+
displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
853
|
+
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
854
|
+
},
|
|
855
|
+
handler: async ({ displayId, headless })=>{
|
|
856
|
+
const agent = await this.ensureAgent(displayId, headless);
|
|
872
857
|
const screenshot = await agent.interface.screenshotBase64();
|
|
873
858
|
return {
|
|
874
859
|
content: [
|
|
875
860
|
{
|
|
876
861
|
type: 'text',
|
|
877
|
-
text: `Connected to computer${
|
|
862
|
+
text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
|
|
878
863
|
},
|
|
879
864
|
...this.buildScreenshotContent(screenshot)
|
|
880
865
|
]
|
|
@@ -905,21 +890,11 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
905
890
|
}
|
|
906
891
|
];
|
|
907
892
|
}
|
|
908
|
-
constructor(...args){
|
|
909
|
-
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
910
|
-
namespace: 'computer',
|
|
911
|
-
shape: computerInitArgShape,
|
|
912
|
-
cli: {
|
|
913
|
-
preferBareKeys: true
|
|
914
|
-
},
|
|
915
|
-
adapt: (extracted)=>extracted
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
893
|
}
|
|
919
894
|
const tools = new ComputerMidsceneTools();
|
|
920
895
|
runToolsCLI(tools, 'midscene-computer', {
|
|
921
896
|
stripPrefix: 'computer_',
|
|
922
|
-
version: "1.7.5-beta-
|
|
897
|
+
version: "1.7.5-beta-20260420061332.0",
|
|
923
898
|
extraCommands: createReportCliCommands()
|
|
924
899
|
}).catch((e)=>{
|
|
925
900
|
if (!(e instanceof CLIError)) console.error(e);
|
package/dist/es/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { createImgBase64ByFormat } from "@midscene/shared/img";
|
|
|
11
11
|
import { getDebug } from "@midscene/shared/logger";
|
|
12
12
|
import screenshot_desktop from "screenshot-desktop";
|
|
13
13
|
import { Agent } from "@midscene/core/agent";
|
|
14
|
-
import { BaseMidsceneTools } from "@midscene/shared/mcp
|
|
14
|
+
import { BaseMidsceneTools } from "@midscene/shared/mcp";
|
|
15
15
|
import { overrideAIConfig } from "@midscene/shared/env";
|
|
16
16
|
const debugXvfb = getDebug('computer:xvfb');
|
|
17
17
|
function checkXvfbInstalled() {
|
|
@@ -409,7 +409,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
409
409
|
}
|
|
410
410
|
async healthCheck() {
|
|
411
411
|
console.log('[HealthCheck] Starting health check...');
|
|
412
|
-
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-
|
|
412
|
+
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420061332.0");
|
|
413
413
|
console.log('[HealthCheck] Taking screenshot...');
|
|
414
414
|
const screenshotTimeout = 15000;
|
|
415
415
|
let timeoutId;
|
|
@@ -815,29 +815,13 @@ async function agentFromComputer(opts) {
|
|
|
815
815
|
await device.connect();
|
|
816
816
|
return new ComputerAgent(device, opts);
|
|
817
817
|
}
|
|
818
|
-
function mcp_tools_define_property(obj, key, value) {
|
|
819
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
820
|
-
value: value,
|
|
821
|
-
enumerable: true,
|
|
822
|
-
configurable: true,
|
|
823
|
-
writable: true
|
|
824
|
-
});
|
|
825
|
-
else obj[key] = value;
|
|
826
|
-
return obj;
|
|
827
|
-
}
|
|
828
818
|
const debug = getDebug('mcp:computer-tools');
|
|
829
|
-
const computerInitArgShape = {
|
|
830
|
-
displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
831
|
-
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
832
|
-
};
|
|
833
819
|
class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
834
820
|
createTemporaryDevice() {
|
|
835
821
|
return new ComputerDevice({});
|
|
836
822
|
}
|
|
837
|
-
async ensureAgent(
|
|
838
|
-
|
|
839
|
-
const headless = opts?.headless;
|
|
840
|
-
if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
|
|
823
|
+
async ensureAgent(displayId, headless) {
|
|
824
|
+
if (this.agent && displayId) {
|
|
841
825
|
try {
|
|
842
826
|
await this.agent.destroy?.();
|
|
843
827
|
} catch (error) {
|
|
@@ -847,7 +831,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
847
831
|
}
|
|
848
832
|
if (this.agent) return this.agent;
|
|
849
833
|
debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
850
|
-
const
|
|
834
|
+
const opts = {
|
|
851
835
|
...displayId ? {
|
|
852
836
|
displayId
|
|
853
837
|
} : {},
|
|
@@ -855,7 +839,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
855
839
|
headless
|
|
856
840
|
} : {}
|
|
857
841
|
};
|
|
858
|
-
const agent = await agentFromComputer(Object.keys(
|
|
842
|
+
const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
|
|
859
843
|
this.agent = agent;
|
|
860
844
|
return agent;
|
|
861
845
|
}
|
|
@@ -864,17 +848,18 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
864
848
|
{
|
|
865
849
|
name: 'computer_connect',
|
|
866
850
|
description: 'Connect to computer desktop. Provide displayId to connect to a specific display (use computer_list_displays to get available IDs). If not provided, uses the primary display.',
|
|
867
|
-
schema:
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
851
|
+
schema: {
|
|
852
|
+
displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
853
|
+
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
854
|
+
},
|
|
855
|
+
handler: async ({ displayId, headless })=>{
|
|
856
|
+
const agent = await this.ensureAgent(displayId, headless);
|
|
872
857
|
const screenshot = await agent.interface.screenshotBase64();
|
|
873
858
|
return {
|
|
874
859
|
content: [
|
|
875
860
|
{
|
|
876
861
|
type: 'text',
|
|
877
|
-
text: `Connected to computer${
|
|
862
|
+
text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
|
|
878
863
|
},
|
|
879
864
|
...this.buildScreenshotContent(screenshot)
|
|
880
865
|
]
|
|
@@ -905,19 +890,9 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
905
890
|
}
|
|
906
891
|
];
|
|
907
892
|
}
|
|
908
|
-
constructor(...args){
|
|
909
|
-
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
910
|
-
namespace: 'computer',
|
|
911
|
-
shape: computerInitArgShape,
|
|
912
|
-
cli: {
|
|
913
|
-
preferBareKeys: true
|
|
914
|
-
},
|
|
915
|
-
adapt: (extracted)=>extracted
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
893
|
}
|
|
919
894
|
function version() {
|
|
920
|
-
const currentVersion = "1.7.5-beta-
|
|
895
|
+
const currentVersion = "1.7.5-beta-20260420061332.0";
|
|
921
896
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
922
897
|
return currentVersion;
|
|
923
898
|
}
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseMCPServer, createMCPServerLauncher } from "@midscene/shared/mcp";
|
|
1
|
+
import { BaseMCPServer, BaseMidsceneTools, createMCPServerLauncher } from "@midscene/shared/mcp";
|
|
2
2
|
import { Agent } from "@midscene/core/agent";
|
|
3
3
|
import node_assert from "node:assert";
|
|
4
4
|
import { execFileSync, execSync, spawn, spawnSync } from "node:child_process";
|
|
@@ -12,7 +12,6 @@ import { sleep } from "@midscene/core/utils";
|
|
|
12
12
|
import { createImgBase64ByFormat } from "@midscene/shared/img";
|
|
13
13
|
import { getDebug } from "@midscene/shared/logger";
|
|
14
14
|
import screenshot_desktop from "screenshot-desktop";
|
|
15
|
-
import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
|
|
16
15
|
const debugXvfb = getDebug('computer:xvfb');
|
|
17
16
|
function checkXvfbInstalled() {
|
|
18
17
|
try {
|
|
@@ -409,7 +408,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
409
408
|
}
|
|
410
409
|
async healthCheck() {
|
|
411
410
|
console.log('[HealthCheck] Starting health check...');
|
|
412
|
-
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-
|
|
411
|
+
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420061332.0");
|
|
413
412
|
console.log('[HealthCheck] Taking screenshot...');
|
|
414
413
|
const screenshotTimeout = 15000;
|
|
415
414
|
let timeoutId;
|
|
@@ -815,29 +814,13 @@ async function agentFromComputer(opts) {
|
|
|
815
814
|
await device.connect();
|
|
816
815
|
return new ComputerAgent(device, opts);
|
|
817
816
|
}
|
|
818
|
-
function mcp_tools_define_property(obj, key, value) {
|
|
819
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
820
|
-
value: value,
|
|
821
|
-
enumerable: true,
|
|
822
|
-
configurable: true,
|
|
823
|
-
writable: true
|
|
824
|
-
});
|
|
825
|
-
else obj[key] = value;
|
|
826
|
-
return obj;
|
|
827
|
-
}
|
|
828
817
|
const debug = getDebug('mcp:computer-tools');
|
|
829
|
-
const computerInitArgShape = {
|
|
830
|
-
displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
831
|
-
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
832
|
-
};
|
|
833
818
|
class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
834
819
|
createTemporaryDevice() {
|
|
835
820
|
return new ComputerDevice({});
|
|
836
821
|
}
|
|
837
|
-
async ensureAgent(
|
|
838
|
-
|
|
839
|
-
const headless = opts?.headless;
|
|
840
|
-
if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
|
|
822
|
+
async ensureAgent(displayId, headless) {
|
|
823
|
+
if (this.agent && displayId) {
|
|
841
824
|
try {
|
|
842
825
|
await this.agent.destroy?.();
|
|
843
826
|
} catch (error) {
|
|
@@ -847,7 +830,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
847
830
|
}
|
|
848
831
|
if (this.agent) return this.agent;
|
|
849
832
|
debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
850
|
-
const
|
|
833
|
+
const opts = {
|
|
851
834
|
...displayId ? {
|
|
852
835
|
displayId
|
|
853
836
|
} : {},
|
|
@@ -855,7 +838,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
855
838
|
headless
|
|
856
839
|
} : {}
|
|
857
840
|
};
|
|
858
|
-
const agent = await agentFromComputer(Object.keys(
|
|
841
|
+
const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
|
|
859
842
|
this.agent = agent;
|
|
860
843
|
return agent;
|
|
861
844
|
}
|
|
@@ -864,17 +847,18 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
864
847
|
{
|
|
865
848
|
name: 'computer_connect',
|
|
866
849
|
description: 'Connect to computer desktop. Provide displayId to connect to a specific display (use computer_list_displays to get available IDs). If not provided, uses the primary display.',
|
|
867
|
-
schema:
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
850
|
+
schema: {
|
|
851
|
+
displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
852
|
+
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
853
|
+
},
|
|
854
|
+
handler: async ({ displayId, headless })=>{
|
|
855
|
+
const agent = await this.ensureAgent(displayId, headless);
|
|
872
856
|
const screenshot = await agent.interface.screenshotBase64();
|
|
873
857
|
return {
|
|
874
858
|
content: [
|
|
875
859
|
{
|
|
876
860
|
type: 'text',
|
|
877
|
-
text: `Connected to computer${
|
|
861
|
+
text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
|
|
878
862
|
},
|
|
879
863
|
...this.buildScreenshotContent(screenshot)
|
|
880
864
|
]
|
|
@@ -905,16 +889,6 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
905
889
|
}
|
|
906
890
|
];
|
|
907
891
|
}
|
|
908
|
-
constructor(...args){
|
|
909
|
-
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
910
|
-
namespace: 'computer',
|
|
911
|
-
shape: computerInitArgShape,
|
|
912
|
-
cli: {
|
|
913
|
-
preferBareKeys: true
|
|
914
|
-
},
|
|
915
|
-
adapt: (extracted)=>extracted
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
892
|
}
|
|
919
893
|
class ComputerMCPServer extends BaseMCPServer {
|
|
920
894
|
createToolsManager() {
|
|
@@ -923,7 +897,7 @@ class ComputerMCPServer extends BaseMCPServer {
|
|
|
923
897
|
constructor(toolsManager){
|
|
924
898
|
super({
|
|
925
899
|
name: '@midscene/computer-mcp',
|
|
926
|
-
version: "1.7.5-beta-
|
|
900
|
+
version: "1.7.5-beta-20260420061332.0",
|
|
927
901
|
description: 'Control the computer desktop using natural language commands'
|
|
928
902
|
}, toolsManager);
|
|
929
903
|
}
|
package/dist/lib/cli.js
CHANGED
|
@@ -27,7 +27,7 @@ var __webpack_exports__ = {};
|
|
|
27
27
|
const core_namespaceObject = require("@midscene/core");
|
|
28
28
|
const cli_namespaceObject = require("@midscene/shared/cli");
|
|
29
29
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
30
|
-
const
|
|
30
|
+
const mcp_namespaceObject = require("@midscene/shared/mcp");
|
|
31
31
|
const agent_namespaceObject = require("@midscene/core/agent");
|
|
32
32
|
const external_node_assert_namespaceObject = require("node:assert");
|
|
33
33
|
var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
|
|
@@ -437,7 +437,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
437
437
|
}
|
|
438
438
|
async healthCheck() {
|
|
439
439
|
console.log('[HealthCheck] Starting health check...');
|
|
440
|
-
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-
|
|
440
|
+
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420061332.0");
|
|
441
441
|
console.log('[HealthCheck] Taking screenshot...');
|
|
442
442
|
const screenshotTimeout = 15000;
|
|
443
443
|
let timeoutId;
|
|
@@ -843,29 +843,13 @@ async function agentFromComputer(opts) {
|
|
|
843
843
|
await device.connect();
|
|
844
844
|
return new ComputerAgent(device, opts);
|
|
845
845
|
}
|
|
846
|
-
function mcp_tools_define_property(obj, key, value) {
|
|
847
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
848
|
-
value: value,
|
|
849
|
-
enumerable: true,
|
|
850
|
-
configurable: true,
|
|
851
|
-
writable: true
|
|
852
|
-
});
|
|
853
|
-
else obj[key] = value;
|
|
854
|
-
return obj;
|
|
855
|
-
}
|
|
856
846
|
const debug = (0, logger_namespaceObject.getDebug)('mcp:computer-tools');
|
|
857
|
-
|
|
858
|
-
displayId: core_namespaceObject.z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
859
|
-
headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
860
|
-
};
|
|
861
|
-
class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
|
|
847
|
+
class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
862
848
|
createTemporaryDevice() {
|
|
863
849
|
return new ComputerDevice({});
|
|
864
850
|
}
|
|
865
|
-
async ensureAgent(
|
|
866
|
-
|
|
867
|
-
const headless = opts?.headless;
|
|
868
|
-
if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
|
|
851
|
+
async ensureAgent(displayId, headless) {
|
|
852
|
+
if (this.agent && displayId) {
|
|
869
853
|
try {
|
|
870
854
|
await this.agent.destroy?.();
|
|
871
855
|
} catch (error) {
|
|
@@ -875,7 +859,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
875
859
|
}
|
|
876
860
|
if (this.agent) return this.agent;
|
|
877
861
|
debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
878
|
-
const
|
|
862
|
+
const opts = {
|
|
879
863
|
...displayId ? {
|
|
880
864
|
displayId
|
|
881
865
|
} : {},
|
|
@@ -883,7 +867,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
883
867
|
headless
|
|
884
868
|
} : {}
|
|
885
869
|
};
|
|
886
|
-
const agent = await agentFromComputer(Object.keys(
|
|
870
|
+
const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
|
|
887
871
|
this.agent = agent;
|
|
888
872
|
return agent;
|
|
889
873
|
}
|
|
@@ -892,17 +876,18 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
892
876
|
{
|
|
893
877
|
name: 'computer_connect',
|
|
894
878
|
description: 'Connect to computer desktop. Provide displayId to connect to a specific display (use computer_list_displays to get available IDs). If not provided, uses the primary display.',
|
|
895
|
-
schema:
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
879
|
+
schema: {
|
|
880
|
+
displayId: core_namespaceObject.z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
881
|
+
headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
882
|
+
},
|
|
883
|
+
handler: async ({ displayId, headless })=>{
|
|
884
|
+
const agent = await this.ensureAgent(displayId, headless);
|
|
900
885
|
const screenshot = await agent.interface.screenshotBase64();
|
|
901
886
|
return {
|
|
902
887
|
content: [
|
|
903
888
|
{
|
|
904
889
|
type: 'text',
|
|
905
|
-
text: `Connected to computer${
|
|
890
|
+
text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
|
|
906
891
|
},
|
|
907
892
|
...this.buildScreenshotContent(screenshot)
|
|
908
893
|
]
|
|
@@ -933,21 +918,11 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
933
918
|
}
|
|
934
919
|
];
|
|
935
920
|
}
|
|
936
|
-
constructor(...args){
|
|
937
|
-
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
938
|
-
namespace: 'computer',
|
|
939
|
-
shape: computerInitArgShape,
|
|
940
|
-
cli: {
|
|
941
|
-
preferBareKeys: true
|
|
942
|
-
},
|
|
943
|
-
adapt: (extracted)=>extracted
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
921
|
}
|
|
947
922
|
const tools = new ComputerMidsceneTools();
|
|
948
923
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-computer', {
|
|
949
924
|
stripPrefix: 'computer_',
|
|
950
|
-
version: "1.7.5-beta-
|
|
925
|
+
version: "1.7.5-beta-20260420061332.0",
|
|
951
926
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
952
927
|
}).catch((e)=>{
|
|
953
928
|
if (!(e instanceof cli_namespaceObject.CLIError)) console.error(e);
|
package/dist/lib/index.js
CHANGED
|
@@ -458,7 +458,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
458
458
|
}
|
|
459
459
|
async healthCheck() {
|
|
460
460
|
console.log('[HealthCheck] Starting health check...');
|
|
461
|
-
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-
|
|
461
|
+
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420061332.0");
|
|
462
462
|
console.log('[HealthCheck] Taking screenshot...');
|
|
463
463
|
const screenshotTimeout = 15000;
|
|
464
464
|
let timeoutId;
|
|
@@ -865,30 +865,14 @@ async function agentFromComputer(opts) {
|
|
|
865
865
|
await device.connect();
|
|
866
866
|
return new ComputerAgent(device, opts);
|
|
867
867
|
}
|
|
868
|
-
const
|
|
869
|
-
function mcp_tools_define_property(obj, key, value) {
|
|
870
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
871
|
-
value: value,
|
|
872
|
-
enumerable: true,
|
|
873
|
-
configurable: true,
|
|
874
|
-
writable: true
|
|
875
|
-
});
|
|
876
|
-
else obj[key] = value;
|
|
877
|
-
return obj;
|
|
878
|
-
}
|
|
868
|
+
const mcp_namespaceObject = require("@midscene/shared/mcp");
|
|
879
869
|
const debug = (0, logger_namespaceObject.getDebug)('mcp:computer-tools');
|
|
880
|
-
|
|
881
|
-
displayId: core_namespaceObject.z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
882
|
-
headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
883
|
-
};
|
|
884
|
-
class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
|
|
870
|
+
class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
885
871
|
createTemporaryDevice() {
|
|
886
872
|
return new ComputerDevice({});
|
|
887
873
|
}
|
|
888
|
-
async ensureAgent(
|
|
889
|
-
|
|
890
|
-
const headless = opts?.headless;
|
|
891
|
-
if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
|
|
874
|
+
async ensureAgent(displayId, headless) {
|
|
875
|
+
if (this.agent && displayId) {
|
|
892
876
|
try {
|
|
893
877
|
await this.agent.destroy?.();
|
|
894
878
|
} catch (error) {
|
|
@@ -898,7 +882,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
898
882
|
}
|
|
899
883
|
if (this.agent) return this.agent;
|
|
900
884
|
debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
901
|
-
const
|
|
885
|
+
const opts = {
|
|
902
886
|
...displayId ? {
|
|
903
887
|
displayId
|
|
904
888
|
} : {},
|
|
@@ -906,7 +890,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
906
890
|
headless
|
|
907
891
|
} : {}
|
|
908
892
|
};
|
|
909
|
-
const agent = await agentFromComputer(Object.keys(
|
|
893
|
+
const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
|
|
910
894
|
this.agent = agent;
|
|
911
895
|
return agent;
|
|
912
896
|
}
|
|
@@ -915,17 +899,18 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
915
899
|
{
|
|
916
900
|
name: 'computer_connect',
|
|
917
901
|
description: 'Connect to computer desktop. Provide displayId to connect to a specific display (use computer_list_displays to get available IDs). If not provided, uses the primary display.',
|
|
918
|
-
schema:
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
902
|
+
schema: {
|
|
903
|
+
displayId: core_namespaceObject.z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
904
|
+
headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
905
|
+
},
|
|
906
|
+
handler: async ({ displayId, headless })=>{
|
|
907
|
+
const agent = await this.ensureAgent(displayId, headless);
|
|
923
908
|
const screenshot = await agent.interface.screenshotBase64();
|
|
924
909
|
return {
|
|
925
910
|
content: [
|
|
926
911
|
{
|
|
927
912
|
type: 'text',
|
|
928
|
-
text: `Connected to computer${
|
|
913
|
+
text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
|
|
929
914
|
},
|
|
930
915
|
...this.buildScreenshotContent(screenshot)
|
|
931
916
|
]
|
|
@@ -956,20 +941,10 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
956
941
|
}
|
|
957
942
|
];
|
|
958
943
|
}
|
|
959
|
-
constructor(...args){
|
|
960
|
-
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
961
|
-
namespace: 'computer',
|
|
962
|
-
shape: computerInitArgShape,
|
|
963
|
-
cli: {
|
|
964
|
-
preferBareKeys: true
|
|
965
|
-
},
|
|
966
|
-
adapt: (extracted)=>extracted
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
944
|
}
|
|
970
945
|
const env_namespaceObject = require("@midscene/shared/env");
|
|
971
946
|
function version() {
|
|
972
|
-
const currentVersion = "1.7.5-beta-
|
|
947
|
+
const currentVersion = "1.7.5-beta-20260420061332.0";
|
|
973
948
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
974
949
|
return currentVersion;
|
|
975
950
|
}
|
package/dist/lib/mcp-server.js
CHANGED
|
@@ -452,7 +452,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
452
452
|
}
|
|
453
453
|
async healthCheck() {
|
|
454
454
|
console.log('[HealthCheck] Starting health check...');
|
|
455
|
-
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-
|
|
455
|
+
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420061332.0");
|
|
456
456
|
console.log('[HealthCheck] Taking screenshot...');
|
|
457
457
|
const screenshotTimeout = 15000;
|
|
458
458
|
let timeoutId;
|
|
@@ -858,30 +858,13 @@ async function agentFromComputer(opts) {
|
|
|
858
858
|
await device.connect();
|
|
859
859
|
return new ComputerAgent(device, opts);
|
|
860
860
|
}
|
|
861
|
-
const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
|
|
862
|
-
function mcp_tools_define_property(obj, key, value) {
|
|
863
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
864
|
-
value: value,
|
|
865
|
-
enumerable: true,
|
|
866
|
-
configurable: true,
|
|
867
|
-
writable: true
|
|
868
|
-
});
|
|
869
|
-
else obj[key] = value;
|
|
870
|
-
return obj;
|
|
871
|
-
}
|
|
872
861
|
const debug = (0, logger_namespaceObject.getDebug)('mcp:computer-tools');
|
|
873
|
-
|
|
874
|
-
displayId: core_namespaceObject.z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
875
|
-
headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
876
|
-
};
|
|
877
|
-
class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools {
|
|
862
|
+
class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
878
863
|
createTemporaryDevice() {
|
|
879
864
|
return new ComputerDevice({});
|
|
880
865
|
}
|
|
881
|
-
async ensureAgent(
|
|
882
|
-
|
|
883
|
-
const headless = opts?.headless;
|
|
884
|
-
if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
|
|
866
|
+
async ensureAgent(displayId, headless) {
|
|
867
|
+
if (this.agent && displayId) {
|
|
885
868
|
try {
|
|
886
869
|
await this.agent.destroy?.();
|
|
887
870
|
} catch (error) {
|
|
@@ -891,7 +874,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
891
874
|
}
|
|
892
875
|
if (this.agent) return this.agent;
|
|
893
876
|
debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
894
|
-
const
|
|
877
|
+
const opts = {
|
|
895
878
|
...displayId ? {
|
|
896
879
|
displayId
|
|
897
880
|
} : {},
|
|
@@ -899,7 +882,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
899
882
|
headless
|
|
900
883
|
} : {}
|
|
901
884
|
};
|
|
902
|
-
const agent = await agentFromComputer(Object.keys(
|
|
885
|
+
const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
|
|
903
886
|
this.agent = agent;
|
|
904
887
|
return agent;
|
|
905
888
|
}
|
|
@@ -908,17 +891,18 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
908
891
|
{
|
|
909
892
|
name: 'computer_connect',
|
|
910
893
|
description: 'Connect to computer desktop. Provide displayId to connect to a specific display (use computer_list_displays to get available IDs). If not provided, uses the primary display.',
|
|
911
|
-
schema:
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
894
|
+
schema: {
|
|
895
|
+
displayId: core_namespaceObject.z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
896
|
+
headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
897
|
+
},
|
|
898
|
+
handler: async ({ displayId, headless })=>{
|
|
899
|
+
const agent = await this.ensureAgent(displayId, headless);
|
|
916
900
|
const screenshot = await agent.interface.screenshotBase64();
|
|
917
901
|
return {
|
|
918
902
|
content: [
|
|
919
903
|
{
|
|
920
904
|
type: 'text',
|
|
921
|
-
text: `Connected to computer${
|
|
905
|
+
text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
|
|
922
906
|
},
|
|
923
907
|
...this.buildScreenshotContent(screenshot)
|
|
924
908
|
]
|
|
@@ -949,16 +933,6 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
949
933
|
}
|
|
950
934
|
];
|
|
951
935
|
}
|
|
952
|
-
constructor(...args){
|
|
953
|
-
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
954
|
-
namespace: 'computer',
|
|
955
|
-
shape: computerInitArgShape,
|
|
956
|
-
cli: {
|
|
957
|
-
preferBareKeys: true
|
|
958
|
-
},
|
|
959
|
-
adapt: (extracted)=>extracted
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
936
|
}
|
|
963
937
|
class ComputerMCPServer extends mcp_namespaceObject.BaseMCPServer {
|
|
964
938
|
createToolsManager() {
|
|
@@ -967,7 +941,7 @@ class ComputerMCPServer extends mcp_namespaceObject.BaseMCPServer {
|
|
|
967
941
|
constructor(toolsManager){
|
|
968
942
|
super({
|
|
969
943
|
name: '@midscene/computer-mcp',
|
|
970
|
-
version: "1.7.5-beta-
|
|
944
|
+
version: "1.7.5-beta-20260420061332.0",
|
|
971
945
|
description: 'Control the computer desktop using natural language commands'
|
|
972
946
|
}, toolsManager);
|
|
973
947
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { AbstractInterface } from '@midscene/core/device';
|
|
2
2
|
import { Agent } from '@midscene/core/agent';
|
|
3
3
|
import { AgentOpt } from '@midscene/core/agent';
|
|
4
|
-
import { BaseMidsceneTools } from '@midscene/shared/mcp
|
|
4
|
+
import { BaseMidsceneTools } from '@midscene/shared/mcp';
|
|
5
5
|
import { DeviceAction } from '@midscene/core';
|
|
6
|
-
import { InitArgSpec } from '@midscene/shared/mcp/base-tools';
|
|
7
6
|
import { InterfaceType } from '@midscene/core';
|
|
8
7
|
import { overrideAIConfig } from '@midscene/shared/env';
|
|
9
8
|
import { Size } from '@midscene/core';
|
|
10
|
-
import
|
|
9
|
+
import { ToolDefinition } from '@midscene/shared/mcp';
|
|
11
10
|
|
|
12
11
|
declare interface AccessibilityCheckResult {
|
|
13
12
|
hasPermission: boolean;
|
|
@@ -114,16 +113,13 @@ export declare interface ComputerDeviceOpt {
|
|
|
114
113
|
xvfbResolution?: string;
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
declare type ComputerInitArgs = Pick<ComputerDeviceOpt, 'displayId' | 'headless'>;
|
|
118
|
-
|
|
119
116
|
/**
|
|
120
117
|
* Computer-specific tools manager
|
|
121
118
|
* Extends BaseMidsceneTools to provide desktop automation tools
|
|
122
119
|
*/
|
|
123
|
-
export declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent
|
|
124
|
-
protected readonly initArgSpec: InitArgSpec<ComputerInitArgs>;
|
|
120
|
+
export declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent> {
|
|
125
121
|
protected createTemporaryDevice(): ComputerDevice;
|
|
126
|
-
protected ensureAgent(
|
|
122
|
+
protected ensureAgent(displayId?: string, headless?: boolean): Promise<ComputerAgent>;
|
|
127
123
|
/**
|
|
128
124
|
* Provide Computer-specific platform tools
|
|
129
125
|
*/
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { AbstractInterface } from '@midscene/core/device';
|
|
2
2
|
import { Agent } from '@midscene/core/agent';
|
|
3
3
|
import { BaseMCPServer } from '@midscene/shared/mcp';
|
|
4
|
-
import { BaseMidsceneTools } from '@midscene/shared/mcp
|
|
4
|
+
import { BaseMidsceneTools } from '@midscene/shared/mcp';
|
|
5
5
|
import { DeviceAction } from '@midscene/core';
|
|
6
|
-
import { InitArgSpec } from '@midscene/shared/mcp/base-tools';
|
|
7
6
|
import { InterfaceType } from '@midscene/core';
|
|
8
7
|
import { LaunchMCPServerOptions } from '@midscene/shared/mcp';
|
|
9
8
|
import { LaunchMCPServerResult } from '@midscene/shared/mcp';
|
|
10
9
|
import { Size } from '@midscene/core';
|
|
11
10
|
import { Tool } from '@midscene/shared/mcp';
|
|
12
|
-
import
|
|
11
|
+
import { ToolDefinition } from '@midscene/shared/mcp';
|
|
13
12
|
|
|
14
13
|
declare class ComputerAgent extends Agent<ComputerDevice> {
|
|
15
14
|
}
|
|
@@ -85,8 +84,6 @@ declare interface ComputerDeviceOpt {
|
|
|
85
84
|
xvfbResolution?: string;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
declare type ComputerInitArgs = Pick<ComputerDeviceOpt, 'displayId' | 'headless'>;
|
|
89
|
-
|
|
90
87
|
/**
|
|
91
88
|
* Computer MCP Server
|
|
92
89
|
* Provides MCP tools for computer desktop automation
|
|
@@ -100,10 +97,9 @@ export declare class ComputerMCPServer extends BaseMCPServer {
|
|
|
100
97
|
* Computer-specific tools manager
|
|
101
98
|
* Extends BaseMidsceneTools to provide desktop automation tools
|
|
102
99
|
*/
|
|
103
|
-
declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent
|
|
104
|
-
protected readonly initArgSpec: InitArgSpec<ComputerInitArgs>;
|
|
100
|
+
declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent> {
|
|
105
101
|
protected createTemporaryDevice(): ComputerDevice;
|
|
106
|
-
protected ensureAgent(
|
|
102
|
+
protected ensureAgent(displayId?: string, headless?: boolean): Promise<ComputerAgent>;
|
|
107
103
|
/**
|
|
108
104
|
* Provide Computer-specific platform tools
|
|
109
105
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/computer",
|
|
3
|
-
"version": "1.7.5-beta-
|
|
3
|
+
"version": "1.7.5-beta-20260420061332.0",
|
|
4
4
|
"description": "Midscene.js Computer Desktop Automation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@computer-use/libnut": "^4.2.0",
|
|
37
37
|
"clipboardy": "^4.0.0",
|
|
38
38
|
"screenshot-desktop": "^1.15.3",
|
|
39
|
-
"@midscene/core": "1.7.5-beta-
|
|
40
|
-
"@midscene/shared": "1.7.5-beta-
|
|
39
|
+
"@midscene/core": "1.7.5-beta-20260420061332.0",
|
|
40
|
+
"@midscene/shared": "1.7.5-beta-20260420061332.0"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
43
|
"node-mac-permissions": "2.5.0"
|