@midscene/computer 1.9.8-beta-20260618014851.0 → 1.9.8
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 +11 -11
- package/dist/es/index.mjs +11 -11
- package/dist/es/mcp-server.mjs +2088 -0
- package/dist/lib/cli.js +11 -11
- package/dist/lib/index.js +11 -11
- package/dist/lib/mcp-server.js +2141 -0
- package/dist/types/index.d.ts +5 -5
- package/dist/types/mcp-server.d.ts +245 -0
- package/package.json +8 -3
package/dist/es/cli.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createReportCliCommands, z } from "@midscene/core";
|
|
2
2
|
import { reportCLIError, runToolsCLI } from "@midscene/shared/cli";
|
|
3
|
-
import { agentBehaviorInitArgShape, extractAgentBehaviorInitArgs, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs } from "@midscene/shared/agent-tools/agent-behavior-init-args";
|
|
4
|
-
import { BaseMidsceneTools } from "@midscene/shared/agent-tools/base-tools";
|
|
5
3
|
import { getDebug } from "@midscene/shared/logger";
|
|
4
|
+
import { agentBehaviorInitArgShape, extractAgentBehaviorInitArgs, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs } from "@midscene/shared/mcp/agent-behavior-init-args";
|
|
5
|
+
import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
|
|
6
6
|
import { Agent } from "@midscene/core/agent";
|
|
7
7
|
import { execFileSync, execSync, spawn, spawnSync } from "node:child_process";
|
|
8
8
|
import { chmodSync, existsSync, statSync } from "node:fs";
|
|
@@ -695,7 +695,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
695
695
|
}
|
|
696
696
|
async healthCheck() {
|
|
697
697
|
console.log('[HealthCheck] Starting health check...');
|
|
698
|
-
console.log("[HealthCheck] @midscene/computer v1.9.8
|
|
698
|
+
console.log("[HealthCheck] @midscene/computer v1.9.8");
|
|
699
699
|
console.log('[HealthCheck] Taking screenshot...');
|
|
700
700
|
const screenshotTimeout = 15000;
|
|
701
701
|
let timeoutId;
|
|
@@ -1874,7 +1874,7 @@ async function agentForRDPComputer(opts) {
|
|
|
1874
1874
|
await device.connect();
|
|
1875
1875
|
return new ComputerAgent(device, opts);
|
|
1876
1876
|
}
|
|
1877
|
-
function
|
|
1877
|
+
function mcp_tools_define_property(obj, key, value) {
|
|
1878
1878
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
1879
1879
|
value: value,
|
|
1880
1880
|
enumerable: true,
|
|
@@ -1884,7 +1884,7 @@ function agent_tools_define_property(obj, key, value) {
|
|
|
1884
1884
|
else obj[key] = value;
|
|
1885
1885
|
return obj;
|
|
1886
1886
|
}
|
|
1887
|
-
const
|
|
1887
|
+
const mcp_tools_debug = getDebug('mcp:computer-tools');
|
|
1888
1888
|
const RDP_SECURITY_PROTOCOLS = [
|
|
1889
1889
|
'auto',
|
|
1890
1890
|
'tls',
|
|
@@ -1952,14 +1952,14 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
1952
1952
|
try {
|
|
1953
1953
|
await this.agent.destroy?.();
|
|
1954
1954
|
} catch (error) {
|
|
1955
|
-
|
|
1955
|
+
mcp_tools_debug('Failed to destroy agent during cleanup:', error);
|
|
1956
1956
|
}
|
|
1957
1957
|
this.agent = void 0;
|
|
1958
1958
|
}
|
|
1959
1959
|
if (this.agent) return this.agent;
|
|
1960
1960
|
const reportOptions = this.readCliReportAgentOptions();
|
|
1961
1961
|
if (opts?.mode === 'rdp') {
|
|
1962
|
-
|
|
1962
|
+
mcp_tools_debug('Creating RDP Computer agent for host:', opts.host);
|
|
1963
1963
|
const { mode: _mode, ...rdpFields } = opts;
|
|
1964
1964
|
const agent = await agentForRDPComputer({
|
|
1965
1965
|
...rdpFields,
|
|
@@ -1971,7 +1971,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
1971
1971
|
}
|
|
1972
1972
|
const displayId = opts?.mode === 'local' ? opts.displayId : void 0;
|
|
1973
1973
|
const headless = opts?.mode === 'local' ? opts.headless : void 0;
|
|
1974
|
-
|
|
1974
|
+
mcp_tools_debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
1975
1975
|
const agentOpts = {
|
|
1976
1976
|
...displayId ? {
|
|
1977
1977
|
displayId
|
|
@@ -2002,7 +2002,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2002
2002
|
try {
|
|
2003
2003
|
await this.agent.destroy?.();
|
|
2004
2004
|
} catch (error) {
|
|
2005
|
-
|
|
2005
|
+
mcp_tools_debug('Failed to destroy agent during connect:', error);
|
|
2006
2006
|
}
|
|
2007
2007
|
this.agent = void 0;
|
|
2008
2008
|
this.lastInitArgsSignature = void 0;
|
|
@@ -2045,7 +2045,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2045
2045
|
];
|
|
2046
2046
|
}
|
|
2047
2047
|
constructor(...args){
|
|
2048
|
-
super(...args),
|
|
2048
|
+
super(...args), mcp_tools_define_property(this, "lastInitArgsSignature", void 0), mcp_tools_define_property(this, "initArgSpec", {
|
|
2049
2049
|
namespace: 'computer',
|
|
2050
2050
|
shape: computerInitArgShape,
|
|
2051
2051
|
cli: {
|
|
@@ -2058,7 +2058,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2058
2058
|
const tools = new ComputerMidsceneTools();
|
|
2059
2059
|
runToolsCLI(tools, 'midscene-computer', {
|
|
2060
2060
|
stripPrefix: 'computer_',
|
|
2061
|
-
version: "1.9.8
|
|
2061
|
+
version: "1.9.8",
|
|
2062
2062
|
extraCommands: createReportCliCommands()
|
|
2063
2063
|
}).catch((e)=>{
|
|
2064
2064
|
process.exit(reportCLIError(e));
|
package/dist/es/index.mjs
CHANGED
|
@@ -13,8 +13,8 @@ import { Agent } from "@midscene/core/agent";
|
|
|
13
13
|
import { once } from "node:events";
|
|
14
14
|
import { createInterface } from "node:readline";
|
|
15
15
|
import { z } from "@midscene/core";
|
|
16
|
-
import { agentBehaviorInitArgShape, extractAgentBehaviorInitArgs, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs } from "@midscene/shared/
|
|
17
|
-
import { BaseMidsceneTools } from "@midscene/shared/
|
|
16
|
+
import { agentBehaviorInitArgShape, extractAgentBehaviorInitArgs, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs } from "@midscene/shared/mcp/agent-behavior-init-args";
|
|
17
|
+
import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
|
|
18
18
|
import { overrideAIConfig } from "@midscene/shared/env";
|
|
19
19
|
function _define_property(obj, key, value) {
|
|
20
20
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -695,7 +695,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
695
695
|
}
|
|
696
696
|
async healthCheck() {
|
|
697
697
|
console.log('[HealthCheck] Starting health check...');
|
|
698
|
-
console.log("[HealthCheck] @midscene/computer v1.9.8
|
|
698
|
+
console.log("[HealthCheck] @midscene/computer v1.9.8");
|
|
699
699
|
console.log('[HealthCheck] Taking screenshot...');
|
|
700
700
|
const screenshotTimeout = 15000;
|
|
701
701
|
let timeoutId;
|
|
@@ -1917,7 +1917,7 @@ async function agentForRDPComputer(opts) {
|
|
|
1917
1917
|
await device.connect();
|
|
1918
1918
|
return new ComputerAgent(device, opts);
|
|
1919
1919
|
}
|
|
1920
|
-
function
|
|
1920
|
+
function mcp_tools_define_property(obj, key, value) {
|
|
1921
1921
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
1922
1922
|
value: value,
|
|
1923
1923
|
enumerable: true,
|
|
@@ -1927,7 +1927,7 @@ function agent_tools_define_property(obj, key, value) {
|
|
|
1927
1927
|
else obj[key] = value;
|
|
1928
1928
|
return obj;
|
|
1929
1929
|
}
|
|
1930
|
-
const
|
|
1930
|
+
const mcp_tools_debug = getDebug('mcp:computer-tools');
|
|
1931
1931
|
const RDP_SECURITY_PROTOCOLS = [
|
|
1932
1932
|
'auto',
|
|
1933
1933
|
'tls',
|
|
@@ -1995,14 +1995,14 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
1995
1995
|
try {
|
|
1996
1996
|
await this.agent.destroy?.();
|
|
1997
1997
|
} catch (error) {
|
|
1998
|
-
|
|
1998
|
+
mcp_tools_debug('Failed to destroy agent during cleanup:', error);
|
|
1999
1999
|
}
|
|
2000
2000
|
this.agent = void 0;
|
|
2001
2001
|
}
|
|
2002
2002
|
if (this.agent) return this.agent;
|
|
2003
2003
|
const reportOptions = this.readCliReportAgentOptions();
|
|
2004
2004
|
if (opts?.mode === 'rdp') {
|
|
2005
|
-
|
|
2005
|
+
mcp_tools_debug('Creating RDP Computer agent for host:', opts.host);
|
|
2006
2006
|
const { mode: _mode, ...rdpFields } = opts;
|
|
2007
2007
|
const agent = await agentForRDPComputer({
|
|
2008
2008
|
...rdpFields,
|
|
@@ -2014,7 +2014,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2014
2014
|
}
|
|
2015
2015
|
const displayId = opts?.mode === 'local' ? opts.displayId : void 0;
|
|
2016
2016
|
const headless = opts?.mode === 'local' ? opts.headless : void 0;
|
|
2017
|
-
|
|
2017
|
+
mcp_tools_debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
2018
2018
|
const agentOpts = {
|
|
2019
2019
|
...displayId ? {
|
|
2020
2020
|
displayId
|
|
@@ -2045,7 +2045,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2045
2045
|
try {
|
|
2046
2046
|
await this.agent.destroy?.();
|
|
2047
2047
|
} catch (error) {
|
|
2048
|
-
|
|
2048
|
+
mcp_tools_debug('Failed to destroy agent during connect:', error);
|
|
2049
2049
|
}
|
|
2050
2050
|
this.agent = void 0;
|
|
2051
2051
|
this.lastInitArgsSignature = void 0;
|
|
@@ -2088,7 +2088,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2088
2088
|
];
|
|
2089
2089
|
}
|
|
2090
2090
|
constructor(...args){
|
|
2091
|
-
super(...args),
|
|
2091
|
+
super(...args), mcp_tools_define_property(this, "lastInitArgsSignature", void 0), mcp_tools_define_property(this, "initArgSpec", {
|
|
2092
2092
|
namespace: 'computer',
|
|
2093
2093
|
shape: computerInitArgShape,
|
|
2094
2094
|
cli: {
|
|
@@ -2099,7 +2099,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2099
2099
|
}
|
|
2100
2100
|
}
|
|
2101
2101
|
function version() {
|
|
2102
|
-
const currentVersion = "1.9.8
|
|
2102
|
+
const currentVersion = "1.9.8";
|
|
2103
2103
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
2104
2104
|
return currentVersion;
|
|
2105
2105
|
}
|