@midscene/computer 1.7.5-beta-20260420031920.0 → 1.7.5-beta-20260420032657.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 +13 -38
- package/dist/es/index.mjs +13 -38
- package/dist/es/mcp-server.mjs +13 -38
- package/dist/lib/cli.js +13 -38
- package/dist/lib/index.js +13 -38
- package/dist/lib/mcp-server.js +13 -38
- package/dist/types/index.d.ts +2 -6
- package/dist/types/mcp-server.d.ts +2 -6
- package/package.json +3 -3
package/dist/es/cli.mjs
CHANGED
|
@@ -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-20260420032657.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-20260420032657.0",
|
|
923
898
|
extraCommands: createReportCliCommands()
|
|
924
899
|
}).catch((e)=>{
|
|
925
900
|
if (!(e instanceof CLIError)) console.error(e);
|
package/dist/es/index.mjs
CHANGED
|
@@ -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-20260420032657.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-20260420032657.0";
|
|
921
896
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
922
897
|
return currentVersion;
|
|
923
898
|
}
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -408,7 +408,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
408
408
|
}
|
|
409
409
|
async healthCheck() {
|
|
410
410
|
console.log('[HealthCheck] Starting health check...');
|
|
411
|
-
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-
|
|
411
|
+
console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420032657.0");
|
|
412
412
|
console.log('[HealthCheck] Taking screenshot...');
|
|
413
413
|
const screenshotTimeout = 15000;
|
|
414
414
|
let timeoutId;
|
|
@@ -814,29 +814,13 @@ async function agentFromComputer(opts) {
|
|
|
814
814
|
await device.connect();
|
|
815
815
|
return new ComputerAgent(device, opts);
|
|
816
816
|
}
|
|
817
|
-
function mcp_tools_define_property(obj, key, value) {
|
|
818
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
819
|
-
value: value,
|
|
820
|
-
enumerable: true,
|
|
821
|
-
configurable: true,
|
|
822
|
-
writable: true
|
|
823
|
-
});
|
|
824
|
-
else obj[key] = value;
|
|
825
|
-
return obj;
|
|
826
|
-
}
|
|
827
817
|
const debug = getDebug('mcp:computer-tools');
|
|
828
|
-
const computerInitArgShape = {
|
|
829
|
-
displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
830
|
-
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
831
|
-
};
|
|
832
818
|
class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
833
819
|
createTemporaryDevice() {
|
|
834
820
|
return new ComputerDevice({});
|
|
835
821
|
}
|
|
836
|
-
async ensureAgent(
|
|
837
|
-
|
|
838
|
-
const headless = opts?.headless;
|
|
839
|
-
if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
|
|
822
|
+
async ensureAgent(displayId, headless) {
|
|
823
|
+
if (this.agent && displayId) {
|
|
840
824
|
try {
|
|
841
825
|
await this.agent.destroy?.();
|
|
842
826
|
} catch (error) {
|
|
@@ -846,7 +830,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
846
830
|
}
|
|
847
831
|
if (this.agent) return this.agent;
|
|
848
832
|
debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
849
|
-
const
|
|
833
|
+
const opts = {
|
|
850
834
|
...displayId ? {
|
|
851
835
|
displayId
|
|
852
836
|
} : {},
|
|
@@ -854,7 +838,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
854
838
|
headless
|
|
855
839
|
} : {}
|
|
856
840
|
};
|
|
857
|
-
const agent = await agentFromComputer(Object.keys(
|
|
841
|
+
const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
|
|
858
842
|
this.agent = agent;
|
|
859
843
|
return agent;
|
|
860
844
|
}
|
|
@@ -863,17 +847,18 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
863
847
|
{
|
|
864
848
|
name: 'computer_connect',
|
|
865
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.',
|
|
866
|
-
schema:
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
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);
|
|
871
856
|
const screenshot = await agent.interface.screenshotBase64();
|
|
872
857
|
return {
|
|
873
858
|
content: [
|
|
874
859
|
{
|
|
875
860
|
type: 'text',
|
|
876
|
-
text: `Connected to computer${
|
|
861
|
+
text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
|
|
877
862
|
},
|
|
878
863
|
...this.buildScreenshotContent(screenshot)
|
|
879
864
|
]
|
|
@@ -904,16 +889,6 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
904
889
|
}
|
|
905
890
|
];
|
|
906
891
|
}
|
|
907
|
-
constructor(...args){
|
|
908
|
-
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
909
|
-
namespace: 'computer',
|
|
910
|
-
shape: computerInitArgShape,
|
|
911
|
-
cli: {
|
|
912
|
-
preferBareKeys: true
|
|
913
|
-
},
|
|
914
|
-
adapt: (extracted)=>extracted
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
892
|
}
|
|
918
893
|
class ComputerMCPServer extends BaseMCPServer {
|
|
919
894
|
createToolsManager() {
|
|
@@ -922,7 +897,7 @@ class ComputerMCPServer extends BaseMCPServer {
|
|
|
922
897
|
constructor(toolsManager){
|
|
923
898
|
super({
|
|
924
899
|
name: '@midscene/computer-mcp',
|
|
925
|
-
version: "1.7.5-beta-
|
|
900
|
+
version: "1.7.5-beta-20260420032657.0",
|
|
926
901
|
description: 'Control the computer desktop using natural language commands'
|
|
927
902
|
}, toolsManager);
|
|
928
903
|
}
|
package/dist/lib/cli.js
CHANGED
|
@@ -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-20260420032657.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
|
-
const computerInitArgShape = {
|
|
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
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 mcp_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 mcp_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 mcp_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 mcp_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-20260420032657.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-20260420032657.0");
|
|
462
462
|
console.log('[HealthCheck] Taking screenshot...');
|
|
463
463
|
const screenshotTimeout = 15000;
|
|
464
464
|
let timeoutId;
|
|
@@ -866,29 +866,13 @@ async function agentFromComputer(opts) {
|
|
|
866
866
|
return new ComputerAgent(device, opts);
|
|
867
867
|
}
|
|
868
868
|
const mcp_namespaceObject = require("@midscene/shared/mcp");
|
|
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
|
-
}
|
|
879
869
|
const debug = (0, logger_namespaceObject.getDebug)('mcp:computer-tools');
|
|
880
|
-
const computerInitArgShape = {
|
|
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
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 mcp_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 mcp_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 mcp_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 mcp_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-20260420032657.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-20260420032657.0");
|
|
456
456
|
console.log('[HealthCheck] Taking screenshot...');
|
|
457
457
|
const screenshotTimeout = 15000;
|
|
458
458
|
let timeoutId;
|
|
@@ -858,29 +858,13 @@ async function agentFromComputer(opts) {
|
|
|
858
858
|
await device.connect();
|
|
859
859
|
return new ComputerAgent(device, opts);
|
|
860
860
|
}
|
|
861
|
-
function mcp_tools_define_property(obj, key, value) {
|
|
862
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
863
|
-
value: value,
|
|
864
|
-
enumerable: true,
|
|
865
|
-
configurable: true,
|
|
866
|
-
writable: true
|
|
867
|
-
});
|
|
868
|
-
else obj[key] = value;
|
|
869
|
-
return obj;
|
|
870
|
-
}
|
|
871
861
|
const debug = (0, logger_namespaceObject.getDebug)('mcp:computer-tools');
|
|
872
|
-
const computerInitArgShape = {
|
|
873
|
-
displayId: core_namespaceObject.z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
874
|
-
headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
875
|
-
};
|
|
876
862
|
class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
877
863
|
createTemporaryDevice() {
|
|
878
864
|
return new ComputerDevice({});
|
|
879
865
|
}
|
|
880
|
-
async ensureAgent(
|
|
881
|
-
|
|
882
|
-
const headless = opts?.headless;
|
|
883
|
-
if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
|
|
866
|
+
async ensureAgent(displayId, headless) {
|
|
867
|
+
if (this.agent && displayId) {
|
|
884
868
|
try {
|
|
885
869
|
await this.agent.destroy?.();
|
|
886
870
|
} catch (error) {
|
|
@@ -890,7 +874,7 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
890
874
|
}
|
|
891
875
|
if (this.agent) return this.agent;
|
|
892
876
|
debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
893
|
-
const
|
|
877
|
+
const opts = {
|
|
894
878
|
...displayId ? {
|
|
895
879
|
displayId
|
|
896
880
|
} : {},
|
|
@@ -898,7 +882,7 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
898
882
|
headless
|
|
899
883
|
} : {}
|
|
900
884
|
};
|
|
901
|
-
const agent = await agentFromComputer(Object.keys(
|
|
885
|
+
const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
|
|
902
886
|
this.agent = agent;
|
|
903
887
|
return agent;
|
|
904
888
|
}
|
|
@@ -907,17 +891,18 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
907
891
|
{
|
|
908
892
|
name: 'computer_connect',
|
|
909
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.',
|
|
910
|
-
schema:
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
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);
|
|
915
900
|
const screenshot = await agent.interface.screenshotBase64();
|
|
916
901
|
return {
|
|
917
902
|
content: [
|
|
918
903
|
{
|
|
919
904
|
type: 'text',
|
|
920
|
-
text: `Connected to computer${
|
|
905
|
+
text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
|
|
921
906
|
},
|
|
922
907
|
...this.buildScreenshotContent(screenshot)
|
|
923
908
|
]
|
|
@@ -948,16 +933,6 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
|
|
|
948
933
|
}
|
|
949
934
|
];
|
|
950
935
|
}
|
|
951
|
-
constructor(...args){
|
|
952
|
-
super(...args), mcp_tools_define_property(this, "initArgSpec", {
|
|
953
|
-
namespace: 'computer',
|
|
954
|
-
shape: computerInitArgShape,
|
|
955
|
-
cli: {
|
|
956
|
-
preferBareKeys: true
|
|
957
|
-
},
|
|
958
|
-
adapt: (extracted)=>extracted
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
936
|
}
|
|
962
937
|
class ComputerMCPServer extends mcp_namespaceObject.BaseMCPServer {
|
|
963
938
|
createToolsManager() {
|
|
@@ -966,7 +941,7 @@ class ComputerMCPServer extends mcp_namespaceObject.BaseMCPServer {
|
|
|
966
941
|
constructor(toolsManager){
|
|
967
942
|
super({
|
|
968
943
|
name: '@midscene/computer-mcp',
|
|
969
|
-
version: "1.7.5-beta-
|
|
944
|
+
version: "1.7.5-beta-20260420032657.0",
|
|
970
945
|
description: 'Control the computer desktop using natural language commands'
|
|
971
946
|
}, toolsManager);
|
|
972
947
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Agent } from '@midscene/core/agent';
|
|
|
3
3
|
import { AgentOpt } from '@midscene/core/agent';
|
|
4
4
|
import { BaseMidsceneTools } from '@midscene/shared/mcp';
|
|
5
5
|
import { DeviceAction } from '@midscene/core';
|
|
6
|
-
import { InitArgSpec } from '@midscene/shared/mcp';
|
|
7
6
|
import { InterfaceType } from '@midscene/core';
|
|
8
7
|
import { overrideAIConfig } from '@midscene/shared/env';
|
|
9
8
|
import { Size } from '@midscene/core';
|
|
@@ -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
|
*/
|
|
@@ -3,7 +3,6 @@ import { Agent } from '@midscene/core/agent';
|
|
|
3
3
|
import { BaseMCPServer } from '@midscene/shared/mcp';
|
|
4
4
|
import { BaseMidsceneTools } from '@midscene/shared/mcp';
|
|
5
5
|
import { DeviceAction } from '@midscene/core';
|
|
6
|
-
import { InitArgSpec } from '@midscene/shared/mcp';
|
|
7
6
|
import { InterfaceType } from '@midscene/core';
|
|
8
7
|
import { LaunchMCPServerOptions } from '@midscene/shared/mcp';
|
|
9
8
|
import { LaunchMCPServerResult } from '@midscene/shared/mcp';
|
|
@@ -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-20260420032657.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/
|
|
40
|
-
"@midscene/
|
|
39
|
+
"@midscene/shared": "1.7.5-beta-20260420032657.0",
|
|
40
|
+
"@midscene/core": "1.7.5-beta-20260420032657.0"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
43
|
"node-mac-permissions": "2.5.0"
|