@midscene/computer 1.9.5 → 1.9.6-beta-20260612050456.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 CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createReportCliCommands, z } from "@midscene/core";
2
2
  import { reportCLIError, runToolsCLI } from "@midscene/shared/cli";
3
3
  import { getDebug } from "@midscene/shared/logger";
4
+ import { agentBehaviorInitArgShape, extractAgentBehaviorInitArgs, getAgentInitArgsSignature } from "@midscene/shared/mcp/agent-behavior-init-args";
4
5
  import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
5
6
  import { Agent } from "@midscene/core/agent";
6
7
  import { execFileSync, execSync, spawn, spawnSync } from "node:child_process";
@@ -656,7 +657,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
656
657
  }
657
658
  async healthCheck() {
658
659
  console.log('[HealthCheck] Starting health check...');
659
- console.log("[HealthCheck] @midscene/computer v1.9.5");
660
+ console.log("[HealthCheck] @midscene/computer v1.9.6-beta-20260612050456.0");
660
661
  console.log('[HealthCheck] Taking screenshot...');
661
662
  const screenshotTimeout = 15000;
662
663
  let timeoutId;
@@ -1846,7 +1847,8 @@ const computerInitArgShape = {
1846
1847
  ignoreCertificate: z.boolean().optional().describe('Skip TLS certificate validation. Requires host.'),
1847
1848
  securityProtocol: z["enum"](RDP_SECURITY_PROTOCOLS).optional().describe('RDP security protocol negotiation (default auto). Requires host.'),
1848
1849
  desktopWidth: z.number().optional().describe('Remote desktop width in pixels. Requires host.'),
1849
- desktopHeight: z.number().optional().describe('Remote desktop height in pixels. Requires host.')
1850
+ desktopHeight: z.number().optional().describe('Remote desktop height in pixels. Requires host.'),
1851
+ ...agentBehaviorInitArgShape
1850
1852
  };
1851
1853
  function adaptComputerInitArgs(extracted) {
1852
1854
  if (!extracted || 0 === Object.keys(extracted).length) return;
@@ -1862,14 +1864,10 @@ function adaptComputerInitArgs(extracted) {
1862
1864
  return {
1863
1865
  mode: 'local',
1864
1866
  displayId: extracted.displayId,
1865
- headless: extracted.headless
1867
+ headless: extracted.headless,
1868
+ ...extractAgentBehaviorInitArgs(extracted) ?? {}
1866
1869
  };
1867
1870
  }
1868
- function shouldRetargetAgent(opts) {
1869
- if (!opts) return false;
1870
- if ('rdp' === opts.mode) return true;
1871
- return void 0 !== opts.displayId || void 0 !== opts.headless;
1872
- }
1873
1871
  function describeConnectTarget(opts) {
1874
1872
  if (opts?.mode === 'rdp') {
1875
1873
  const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
@@ -1892,7 +1890,8 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1892
1890
  return new ComputerDevice({});
1893
1891
  }
1894
1892
  async ensureAgent(opts) {
1895
- if (this.agent && shouldRetargetAgent(opts)) {
1893
+ const nextSignature = getAgentInitArgsSignature(opts);
1894
+ if (this.agent && nextSignature && nextSignature !== this.lastInitArgsSignature) {
1896
1895
  try {
1897
1896
  await this.agent.destroy?.();
1898
1897
  } catch (error) {
@@ -1910,6 +1909,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1910
1909
  ...reportOptions ?? {}
1911
1910
  });
1912
1911
  this.agent = agent;
1912
+ this.lastInitArgsSignature = nextSignature;
1913
1913
  return agent;
1914
1914
  }
1915
1915
  const displayId = opts?.mode === 'local' ? opts.displayId : void 0;
@@ -1922,10 +1922,12 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1922
1922
  ...void 0 !== headless ? {
1923
1923
  headless
1924
1924
  } : {},
1925
+ ...extractAgentBehaviorInitArgs(opts) ?? {},
1925
1926
  ...reportOptions ?? {}
1926
1927
  };
1927
1928
  const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
1928
1929
  this.agent = agent;
1930
+ this.lastInitArgsSignature = nextSignature;
1929
1931
  return agent;
1930
1932
  }
1931
1933
  preparePlatformTools() {
@@ -1946,6 +1948,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1946
1948
  mcp_tools_debug('Failed to destroy agent during connect:', error);
1947
1949
  }
1948
1950
  this.agent = void 0;
1951
+ this.lastInitArgsSignature = void 0;
1949
1952
  }
1950
1953
  const agent = await this.ensureAgent(initArgs);
1951
1954
  const screenshot = await agent.interface.screenshotBase64();
@@ -1985,7 +1988,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1985
1988
  ];
1986
1989
  }
1987
1990
  constructor(...args){
1988
- super(...args), mcp_tools_define_property(this, "initArgSpec", {
1991
+ super(...args), mcp_tools_define_property(this, "lastInitArgsSignature", void 0), mcp_tools_define_property(this, "initArgSpec", {
1989
1992
  namespace: 'computer',
1990
1993
  shape: computerInitArgShape,
1991
1994
  cli: {
@@ -1998,7 +2001,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1998
2001
  const tools = new ComputerMidsceneTools();
1999
2002
  runToolsCLI(tools, 'midscene-computer', {
2000
2003
  stripPrefix: 'computer_',
2001
- version: "1.9.5",
2004
+ version: "1.9.6-beta-20260612050456.0",
2002
2005
  extraCommands: createReportCliCommands()
2003
2006
  }).catch((e)=>{
2004
2007
  process.exit(reportCLIError(e));
package/dist/es/index.mjs CHANGED
@@ -13,6 +13,7 @@ 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 } from "@midscene/shared/mcp/agent-behavior-init-args";
16
17
  import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
17
18
  import { overrideAIConfig } from "@midscene/shared/env";
18
19
  function _define_property(obj, key, value) {
@@ -656,7 +657,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
656
657
  }
657
658
  async healthCheck() {
658
659
  console.log('[HealthCheck] Starting health check...');
659
- console.log("[HealthCheck] @midscene/computer v1.9.5");
660
+ console.log("[HealthCheck] @midscene/computer v1.9.6-beta-20260612050456.0");
660
661
  console.log('[HealthCheck] Taking screenshot...');
661
662
  const screenshotTimeout = 15000;
662
663
  let timeoutId;
@@ -1889,7 +1890,8 @@ const computerInitArgShape = {
1889
1890
  ignoreCertificate: z.boolean().optional().describe('Skip TLS certificate validation. Requires host.'),
1890
1891
  securityProtocol: z["enum"](RDP_SECURITY_PROTOCOLS).optional().describe('RDP security protocol negotiation (default auto). Requires host.'),
1891
1892
  desktopWidth: z.number().optional().describe('Remote desktop width in pixels. Requires host.'),
1892
- desktopHeight: z.number().optional().describe('Remote desktop height in pixels. Requires host.')
1893
+ desktopHeight: z.number().optional().describe('Remote desktop height in pixels. Requires host.'),
1894
+ ...agentBehaviorInitArgShape
1893
1895
  };
1894
1896
  function adaptComputerInitArgs(extracted) {
1895
1897
  if (!extracted || 0 === Object.keys(extracted).length) return;
@@ -1905,14 +1907,10 @@ function adaptComputerInitArgs(extracted) {
1905
1907
  return {
1906
1908
  mode: 'local',
1907
1909
  displayId: extracted.displayId,
1908
- headless: extracted.headless
1910
+ headless: extracted.headless,
1911
+ ...extractAgentBehaviorInitArgs(extracted) ?? {}
1909
1912
  };
1910
1913
  }
1911
- function shouldRetargetAgent(opts) {
1912
- if (!opts) return false;
1913
- if ('rdp' === opts.mode) return true;
1914
- return void 0 !== opts.displayId || void 0 !== opts.headless;
1915
- }
1916
1914
  function describeConnectTarget(opts) {
1917
1915
  if (opts?.mode === 'rdp') {
1918
1916
  const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
@@ -1935,7 +1933,8 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1935
1933
  return new ComputerDevice({});
1936
1934
  }
1937
1935
  async ensureAgent(opts) {
1938
- if (this.agent && shouldRetargetAgent(opts)) {
1936
+ const nextSignature = getAgentInitArgsSignature(opts);
1937
+ if (this.agent && nextSignature && nextSignature !== this.lastInitArgsSignature) {
1939
1938
  try {
1940
1939
  await this.agent.destroy?.();
1941
1940
  } catch (error) {
@@ -1953,6 +1952,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1953
1952
  ...reportOptions ?? {}
1954
1953
  });
1955
1954
  this.agent = agent;
1955
+ this.lastInitArgsSignature = nextSignature;
1956
1956
  return agent;
1957
1957
  }
1958
1958
  const displayId = opts?.mode === 'local' ? opts.displayId : void 0;
@@ -1965,10 +1965,12 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1965
1965
  ...void 0 !== headless ? {
1966
1966
  headless
1967
1967
  } : {},
1968
+ ...extractAgentBehaviorInitArgs(opts) ?? {},
1968
1969
  ...reportOptions ?? {}
1969
1970
  };
1970
1971
  const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
1971
1972
  this.agent = agent;
1973
+ this.lastInitArgsSignature = nextSignature;
1972
1974
  return agent;
1973
1975
  }
1974
1976
  preparePlatformTools() {
@@ -1989,6 +1991,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1989
1991
  mcp_tools_debug('Failed to destroy agent during connect:', error);
1990
1992
  }
1991
1993
  this.agent = void 0;
1994
+ this.lastInitArgsSignature = void 0;
1992
1995
  }
1993
1996
  const agent = await this.ensureAgent(initArgs);
1994
1997
  const screenshot = await agent.interface.screenshotBase64();
@@ -2028,7 +2031,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
2028
2031
  ];
2029
2032
  }
2030
2033
  constructor(...args){
2031
- super(...args), mcp_tools_define_property(this, "initArgSpec", {
2034
+ super(...args), mcp_tools_define_property(this, "lastInitArgsSignature", void 0), mcp_tools_define_property(this, "initArgSpec", {
2032
2035
  namespace: 'computer',
2033
2036
  shape: computerInitArgShape,
2034
2037
  cli: {
@@ -2039,7 +2042,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
2039
2042
  }
2040
2043
  }
2041
2044
  function version() {
2042
- const currentVersion = "1.9.5";
2045
+ const currentVersion = "1.9.6-beta-20260612050456.0";
2043
2046
  console.log(`@midscene/computer v${currentVersion}`);
2044
2047
  return currentVersion;
2045
2048
  }
@@ -14,6 +14,7 @@ import node_assert from "node:assert";
14
14
  import { once } from "node:events";
15
15
  import { createInterface } from "node:readline";
16
16
  import { z } from "@midscene/core";
17
+ import { agentBehaviorInitArgShape, extractAgentBehaviorInitArgs, getAgentInitArgsSignature } from "@midscene/shared/mcp/agent-behavior-init-args";
17
18
  import { BaseMidsceneTools } from "@midscene/shared/mcp/base-tools";
18
19
  function _define_property(obj, key, value) {
19
20
  if (key in obj) Object.defineProperty(obj, key, {
@@ -656,7 +657,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
656
657
  }
657
658
  async healthCheck() {
658
659
  console.log('[HealthCheck] Starting health check...');
659
- console.log("[HealthCheck] @midscene/computer v1.9.5");
660
+ console.log("[HealthCheck] @midscene/computer v1.9.6-beta-20260612050456.0");
660
661
  console.log('[HealthCheck] Taking screenshot...');
661
662
  const screenshotTimeout = 15000;
662
663
  let timeoutId;
@@ -1846,7 +1847,8 @@ const computerInitArgShape = {
1846
1847
  ignoreCertificate: z.boolean().optional().describe('Skip TLS certificate validation. Requires host.'),
1847
1848
  securityProtocol: z["enum"](RDP_SECURITY_PROTOCOLS).optional().describe('RDP security protocol negotiation (default auto). Requires host.'),
1848
1849
  desktopWidth: z.number().optional().describe('Remote desktop width in pixels. Requires host.'),
1849
- desktopHeight: z.number().optional().describe('Remote desktop height in pixels. Requires host.')
1850
+ desktopHeight: z.number().optional().describe('Remote desktop height in pixels. Requires host.'),
1851
+ ...agentBehaviorInitArgShape
1850
1852
  };
1851
1853
  function adaptComputerInitArgs(extracted) {
1852
1854
  if (!extracted || 0 === Object.keys(extracted).length) return;
@@ -1862,14 +1864,10 @@ function adaptComputerInitArgs(extracted) {
1862
1864
  return {
1863
1865
  mode: 'local',
1864
1866
  displayId: extracted.displayId,
1865
- headless: extracted.headless
1867
+ headless: extracted.headless,
1868
+ ...extractAgentBehaviorInitArgs(extracted) ?? {}
1866
1869
  };
1867
1870
  }
1868
- function shouldRetargetAgent(opts) {
1869
- if (!opts) return false;
1870
- if ('rdp' === opts.mode) return true;
1871
- return void 0 !== opts.displayId || void 0 !== opts.headless;
1872
- }
1873
1871
  function describeConnectTarget(opts) {
1874
1872
  if (opts?.mode === 'rdp') {
1875
1873
  const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
@@ -1892,7 +1890,8 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1892
1890
  return new ComputerDevice({});
1893
1891
  }
1894
1892
  async ensureAgent(opts) {
1895
- if (this.agent && shouldRetargetAgent(opts)) {
1893
+ const nextSignature = getAgentInitArgsSignature(opts);
1894
+ if (this.agent && nextSignature && nextSignature !== this.lastInitArgsSignature) {
1896
1895
  try {
1897
1896
  await this.agent.destroy?.();
1898
1897
  } catch (error) {
@@ -1910,6 +1909,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1910
1909
  ...reportOptions ?? {}
1911
1910
  });
1912
1911
  this.agent = agent;
1912
+ this.lastInitArgsSignature = nextSignature;
1913
1913
  return agent;
1914
1914
  }
1915
1915
  const displayId = opts?.mode === 'local' ? opts.displayId : void 0;
@@ -1922,10 +1922,12 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1922
1922
  ...void 0 !== headless ? {
1923
1923
  headless
1924
1924
  } : {},
1925
+ ...extractAgentBehaviorInitArgs(opts) ?? {},
1925
1926
  ...reportOptions ?? {}
1926
1927
  };
1927
1928
  const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
1928
1929
  this.agent = agent;
1930
+ this.lastInitArgsSignature = nextSignature;
1929
1931
  return agent;
1930
1932
  }
1931
1933
  preparePlatformTools() {
@@ -1946,6 +1948,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1946
1948
  mcp_tools_debug('Failed to destroy agent during connect:', error);
1947
1949
  }
1948
1950
  this.agent = void 0;
1951
+ this.lastInitArgsSignature = void 0;
1949
1952
  }
1950
1953
  const agent = await this.ensureAgent(initArgs);
1951
1954
  const screenshot = await agent.interface.screenshotBase64();
@@ -1985,7 +1988,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1985
1988
  ];
1986
1989
  }
1987
1990
  constructor(...args){
1988
- super(...args), mcp_tools_define_property(this, "initArgSpec", {
1991
+ super(...args), mcp_tools_define_property(this, "lastInitArgsSignature", void 0), mcp_tools_define_property(this, "initArgSpec", {
1989
1992
  namespace: 'computer',
1990
1993
  shape: computerInitArgShape,
1991
1994
  cli: {
@@ -2002,7 +2005,7 @@ class ComputerMCPServer extends BaseMCPServer {
2002
2005
  constructor(toolsManager){
2003
2006
  super({
2004
2007
  name: '@midscene/computer-mcp',
2005
- version: "1.9.5",
2008
+ version: "1.9.6-beta-20260612050456.0",
2006
2009
  description: 'Control the computer desktop using natural language commands'
2007
2010
  }, toolsManager);
2008
2011
  }
package/dist/lib/cli.js CHANGED
@@ -27,6 +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 agent_behavior_init_args_namespaceObject = require("@midscene/shared/mcp/agent-behavior-init-args");
30
31
  const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
31
32
  const agent_namespaceObject = require("@midscene/core/agent");
32
33
  const external_node_child_process_namespaceObject = require("node:child_process");
@@ -682,7 +683,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
682
683
  }
683
684
  async healthCheck() {
684
685
  console.log('[HealthCheck] Starting health check...');
685
- console.log("[HealthCheck] @midscene/computer v1.9.5");
686
+ console.log("[HealthCheck] @midscene/computer v1.9.6-beta-20260612050456.0");
686
687
  console.log('[HealthCheck] Taking screenshot...');
687
688
  const screenshotTimeout = 15000;
688
689
  let timeoutId;
@@ -1873,7 +1874,8 @@ const computerInitArgShape = {
1873
1874
  ignoreCertificate: core_namespaceObject.z.boolean().optional().describe('Skip TLS certificate validation. Requires host.'),
1874
1875
  securityProtocol: core_namespaceObject.z["enum"](RDP_SECURITY_PROTOCOLS).optional().describe('RDP security protocol negotiation (default auto). Requires host.'),
1875
1876
  desktopWidth: core_namespaceObject.z.number().optional().describe('Remote desktop width in pixels. Requires host.'),
1876
- desktopHeight: core_namespaceObject.z.number().optional().describe('Remote desktop height in pixels. Requires host.')
1877
+ desktopHeight: core_namespaceObject.z.number().optional().describe('Remote desktop height in pixels. Requires host.'),
1878
+ ...agent_behavior_init_args_namespaceObject.agentBehaviorInitArgShape
1877
1879
  };
1878
1880
  function adaptComputerInitArgs(extracted) {
1879
1881
  if (!extracted || 0 === Object.keys(extracted).length) return;
@@ -1889,14 +1891,10 @@ function adaptComputerInitArgs(extracted) {
1889
1891
  return {
1890
1892
  mode: 'local',
1891
1893
  displayId: extracted.displayId,
1892
- headless: extracted.headless
1894
+ headless: extracted.headless,
1895
+ ...(0, agent_behavior_init_args_namespaceObject.extractAgentBehaviorInitArgs)(extracted) ?? {}
1893
1896
  };
1894
1897
  }
1895
- function shouldRetargetAgent(opts) {
1896
- if (!opts) return false;
1897
- if ('rdp' === opts.mode) return true;
1898
- return void 0 !== opts.displayId || void 0 !== opts.headless;
1899
- }
1900
1898
  function describeConnectTarget(opts) {
1901
1899
  if (opts?.mode === 'rdp') {
1902
1900
  const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
@@ -1919,7 +1917,8 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
1919
1917
  return new ComputerDevice({});
1920
1918
  }
1921
1919
  async ensureAgent(opts) {
1922
- if (this.agent && shouldRetargetAgent(opts)) {
1920
+ const nextSignature = (0, agent_behavior_init_args_namespaceObject.getAgentInitArgsSignature)(opts);
1921
+ if (this.agent && nextSignature && nextSignature !== this.lastInitArgsSignature) {
1923
1922
  try {
1924
1923
  await this.agent.destroy?.();
1925
1924
  } catch (error) {
@@ -1937,6 +1936,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
1937
1936
  ...reportOptions ?? {}
1938
1937
  });
1939
1938
  this.agent = agent;
1939
+ this.lastInitArgsSignature = nextSignature;
1940
1940
  return agent;
1941
1941
  }
1942
1942
  const displayId = opts?.mode === 'local' ? opts.displayId : void 0;
@@ -1949,10 +1949,12 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
1949
1949
  ...void 0 !== headless ? {
1950
1950
  headless
1951
1951
  } : {},
1952
+ ...(0, agent_behavior_init_args_namespaceObject.extractAgentBehaviorInitArgs)(opts) ?? {},
1952
1953
  ...reportOptions ?? {}
1953
1954
  };
1954
1955
  const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
1955
1956
  this.agent = agent;
1957
+ this.lastInitArgsSignature = nextSignature;
1956
1958
  return agent;
1957
1959
  }
1958
1960
  preparePlatformTools() {
@@ -1973,6 +1975,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
1973
1975
  mcp_tools_debug('Failed to destroy agent during connect:', error);
1974
1976
  }
1975
1977
  this.agent = void 0;
1978
+ this.lastInitArgsSignature = void 0;
1976
1979
  }
1977
1980
  const agent = await this.ensureAgent(initArgs);
1978
1981
  const screenshot = await agent.interface.screenshotBase64();
@@ -2012,7 +2015,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
2012
2015
  ];
2013
2016
  }
2014
2017
  constructor(...args){
2015
- super(...args), mcp_tools_define_property(this, "initArgSpec", {
2018
+ super(...args), mcp_tools_define_property(this, "lastInitArgsSignature", void 0), mcp_tools_define_property(this, "initArgSpec", {
2016
2019
  namespace: 'computer',
2017
2020
  shape: computerInitArgShape,
2018
2021
  cli: {
@@ -2025,7 +2028,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
2025
2028
  const tools = new ComputerMidsceneTools();
2026
2029
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-computer', {
2027
2030
  stripPrefix: 'computer_',
2028
- version: "1.9.5",
2031
+ version: "1.9.6-beta-20260612050456.0",
2029
2032
  extraCommands: (0, core_namespaceObject.createReportCliCommands)()
2030
2033
  }).catch((e)=>{
2031
2034
  process.exit((0, cli_namespaceObject.reportCLIError)(e));
package/dist/lib/index.js CHANGED
@@ -709,7 +709,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
709
709
  }
710
710
  async healthCheck() {
711
711
  console.log('[HealthCheck] Starting health check...');
712
- console.log("[HealthCheck] @midscene/computer v1.9.5");
712
+ console.log("[HealthCheck] @midscene/computer v1.9.6-beta-20260612050456.0");
713
713
  console.log('[HealthCheck] Taking screenshot...');
714
714
  const screenshotTimeout = 15000;
715
715
  let timeoutId;
@@ -1915,6 +1915,7 @@ async function agentForRDPComputer(opts) {
1915
1915
  return new ComputerAgent(device, opts);
1916
1916
  }
1917
1917
  const core_namespaceObject = require("@midscene/core");
1918
+ const agent_behavior_init_args_namespaceObject = require("@midscene/shared/mcp/agent-behavior-init-args");
1918
1919
  const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
1919
1920
  function mcp_tools_define_property(obj, key, value) {
1920
1921
  if (key in obj) Object.defineProperty(obj, key, {
@@ -1946,7 +1947,8 @@ const computerInitArgShape = {
1946
1947
  ignoreCertificate: core_namespaceObject.z.boolean().optional().describe('Skip TLS certificate validation. Requires host.'),
1947
1948
  securityProtocol: core_namespaceObject.z["enum"](RDP_SECURITY_PROTOCOLS).optional().describe('RDP security protocol negotiation (default auto). Requires host.'),
1948
1949
  desktopWidth: core_namespaceObject.z.number().optional().describe('Remote desktop width in pixels. Requires host.'),
1949
- desktopHeight: core_namespaceObject.z.number().optional().describe('Remote desktop height in pixels. Requires host.')
1950
+ desktopHeight: core_namespaceObject.z.number().optional().describe('Remote desktop height in pixels. Requires host.'),
1951
+ ...agent_behavior_init_args_namespaceObject.agentBehaviorInitArgShape
1950
1952
  };
1951
1953
  function adaptComputerInitArgs(extracted) {
1952
1954
  if (!extracted || 0 === Object.keys(extracted).length) return;
@@ -1962,14 +1964,10 @@ function adaptComputerInitArgs(extracted) {
1962
1964
  return {
1963
1965
  mode: 'local',
1964
1966
  displayId: extracted.displayId,
1965
- headless: extracted.headless
1967
+ headless: extracted.headless,
1968
+ ...(0, agent_behavior_init_args_namespaceObject.extractAgentBehaviorInitArgs)(extracted) ?? {}
1966
1969
  };
1967
1970
  }
1968
- function shouldRetargetAgent(opts) {
1969
- if (!opts) return false;
1970
- if ('rdp' === opts.mode) return true;
1971
- return void 0 !== opts.displayId || void 0 !== opts.headless;
1972
- }
1973
1971
  function describeConnectTarget(opts) {
1974
1972
  if (opts?.mode === 'rdp') {
1975
1973
  const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
@@ -1992,7 +1990,8 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
1992
1990
  return new ComputerDevice({});
1993
1991
  }
1994
1992
  async ensureAgent(opts) {
1995
- if (this.agent && shouldRetargetAgent(opts)) {
1993
+ const nextSignature = (0, agent_behavior_init_args_namespaceObject.getAgentInitArgsSignature)(opts);
1994
+ if (this.agent && nextSignature && nextSignature !== this.lastInitArgsSignature) {
1996
1995
  try {
1997
1996
  await this.agent.destroy?.();
1998
1997
  } catch (error) {
@@ -2010,6 +2009,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
2010
2009
  ...reportOptions ?? {}
2011
2010
  });
2012
2011
  this.agent = agent;
2012
+ this.lastInitArgsSignature = nextSignature;
2013
2013
  return agent;
2014
2014
  }
2015
2015
  const displayId = opts?.mode === 'local' ? opts.displayId : void 0;
@@ -2022,10 +2022,12 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
2022
2022
  ...void 0 !== headless ? {
2023
2023
  headless
2024
2024
  } : {},
2025
+ ...(0, agent_behavior_init_args_namespaceObject.extractAgentBehaviorInitArgs)(opts) ?? {},
2025
2026
  ...reportOptions ?? {}
2026
2027
  };
2027
2028
  const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
2028
2029
  this.agent = agent;
2030
+ this.lastInitArgsSignature = nextSignature;
2029
2031
  return agent;
2030
2032
  }
2031
2033
  preparePlatformTools() {
@@ -2046,6 +2048,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
2046
2048
  mcp_tools_debug('Failed to destroy agent during connect:', error);
2047
2049
  }
2048
2050
  this.agent = void 0;
2051
+ this.lastInitArgsSignature = void 0;
2049
2052
  }
2050
2053
  const agent = await this.ensureAgent(initArgs);
2051
2054
  const screenshot = await agent.interface.screenshotBase64();
@@ -2085,7 +2088,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
2085
2088
  ];
2086
2089
  }
2087
2090
  constructor(...args){
2088
- super(...args), mcp_tools_define_property(this, "initArgSpec", {
2091
+ super(...args), mcp_tools_define_property(this, "lastInitArgsSignature", void 0), mcp_tools_define_property(this, "initArgSpec", {
2089
2092
  namespace: 'computer',
2090
2093
  shape: computerInitArgShape,
2091
2094
  cli: {
@@ -2097,7 +2100,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
2097
2100
  }
2098
2101
  const env_namespaceObject = require("@midscene/shared/env");
2099
2102
  function version() {
2100
- const currentVersion = "1.9.5";
2103
+ const currentVersion = "1.9.6-beta-20260612050456.0";
2101
2104
  console.log(`@midscene/computer v${currentVersion}`);
2102
2105
  return currentVersion;
2103
2106
  }
@@ -696,7 +696,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
696
696
  }
697
697
  async healthCheck() {
698
698
  console.log('[HealthCheck] Starting health check...');
699
- console.log("[HealthCheck] @midscene/computer v1.9.5");
699
+ console.log("[HealthCheck] @midscene/computer v1.9.6-beta-20260612050456.0");
700
700
  console.log('[HealthCheck] Taking screenshot...');
701
701
  const screenshotTimeout = 15000;
702
702
  let timeoutId;
@@ -1858,6 +1858,7 @@ async function agentForRDPComputer(opts) {
1858
1858
  return new ComputerAgent(device, opts);
1859
1859
  }
1860
1860
  const core_namespaceObject = require("@midscene/core");
1861
+ const agent_behavior_init_args_namespaceObject = require("@midscene/shared/mcp/agent-behavior-init-args");
1861
1862
  const base_tools_namespaceObject = require("@midscene/shared/mcp/base-tools");
1862
1863
  function mcp_tools_define_property(obj, key, value) {
1863
1864
  if (key in obj) Object.defineProperty(obj, key, {
@@ -1889,7 +1890,8 @@ const computerInitArgShape = {
1889
1890
  ignoreCertificate: core_namespaceObject.z.boolean().optional().describe('Skip TLS certificate validation. Requires host.'),
1890
1891
  securityProtocol: core_namespaceObject.z["enum"](RDP_SECURITY_PROTOCOLS).optional().describe('RDP security protocol negotiation (default auto). Requires host.'),
1891
1892
  desktopWidth: core_namespaceObject.z.number().optional().describe('Remote desktop width in pixels. Requires host.'),
1892
- desktopHeight: core_namespaceObject.z.number().optional().describe('Remote desktop height in pixels. Requires host.')
1893
+ desktopHeight: core_namespaceObject.z.number().optional().describe('Remote desktop height in pixels. Requires host.'),
1894
+ ...agent_behavior_init_args_namespaceObject.agentBehaviorInitArgShape
1893
1895
  };
1894
1896
  function adaptComputerInitArgs(extracted) {
1895
1897
  if (!extracted || 0 === Object.keys(extracted).length) return;
@@ -1905,14 +1907,10 @@ function adaptComputerInitArgs(extracted) {
1905
1907
  return {
1906
1908
  mode: 'local',
1907
1909
  displayId: extracted.displayId,
1908
- headless: extracted.headless
1910
+ headless: extracted.headless,
1911
+ ...(0, agent_behavior_init_args_namespaceObject.extractAgentBehaviorInitArgs)(extracted) ?? {}
1909
1912
  };
1910
1913
  }
1911
- function shouldRetargetAgent(opts) {
1912
- if (!opts) return false;
1913
- if ('rdp' === opts.mode) return true;
1914
- return void 0 !== opts.displayId || void 0 !== opts.headless;
1915
- }
1916
1914
  function describeConnectTarget(opts) {
1917
1915
  if (opts?.mode === 'rdp') {
1918
1916
  const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
@@ -1935,7 +1933,8 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
1935
1933
  return new ComputerDevice({});
1936
1934
  }
1937
1935
  async ensureAgent(opts) {
1938
- if (this.agent && shouldRetargetAgent(opts)) {
1936
+ const nextSignature = (0, agent_behavior_init_args_namespaceObject.getAgentInitArgsSignature)(opts);
1937
+ if (this.agent && nextSignature && nextSignature !== this.lastInitArgsSignature) {
1939
1938
  try {
1940
1939
  await this.agent.destroy?.();
1941
1940
  } catch (error) {
@@ -1953,6 +1952,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
1953
1952
  ...reportOptions ?? {}
1954
1953
  });
1955
1954
  this.agent = agent;
1955
+ this.lastInitArgsSignature = nextSignature;
1956
1956
  return agent;
1957
1957
  }
1958
1958
  const displayId = opts?.mode === 'local' ? opts.displayId : void 0;
@@ -1965,10 +1965,12 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
1965
1965
  ...void 0 !== headless ? {
1966
1966
  headless
1967
1967
  } : {},
1968
+ ...(0, agent_behavior_init_args_namespaceObject.extractAgentBehaviorInitArgs)(opts) ?? {},
1968
1969
  ...reportOptions ?? {}
1969
1970
  };
1970
1971
  const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
1971
1972
  this.agent = agent;
1973
+ this.lastInitArgsSignature = nextSignature;
1972
1974
  return agent;
1973
1975
  }
1974
1976
  preparePlatformTools() {
@@ -1989,6 +1991,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
1989
1991
  mcp_tools_debug('Failed to destroy agent during connect:', error);
1990
1992
  }
1991
1993
  this.agent = void 0;
1994
+ this.lastInitArgsSignature = void 0;
1992
1995
  }
1993
1996
  const agent = await this.ensureAgent(initArgs);
1994
1997
  const screenshot = await agent.interface.screenshotBase64();
@@ -2028,7 +2031,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
2028
2031
  ];
2029
2032
  }
2030
2033
  constructor(...args){
2031
- super(...args), mcp_tools_define_property(this, "initArgSpec", {
2034
+ super(...args), mcp_tools_define_property(this, "lastInitArgsSignature", void 0), mcp_tools_define_property(this, "initArgSpec", {
2032
2035
  namespace: 'computer',
2033
2036
  shape: computerInitArgShape,
2034
2037
  cli: {
@@ -2045,7 +2048,7 @@ class ComputerMCPServer extends mcp_namespaceObject.BaseMCPServer {
2045
2048
  constructor(toolsManager){
2046
2049
  super({
2047
2050
  name: '@midscene/computer-mcp',
2048
- version: "1.9.5",
2051
+ version: "1.9.6-beta-20260612050456.0",
2049
2052
  description: 'Control the computer desktop using natural language commands'
2050
2053
  }, toolsManager);
2051
2054
  }
@@ -1,5 +1,6 @@
1
1
  import { AbstractInterface } from '@midscene/core/device';
2
2
  import { Agent } from '@midscene/core/agent';
3
+ import { AgentBehaviorInitArgs } from '@midscene/shared/mcp/agent-behavior-init-args';
3
4
  import { AgentOpt } from '@midscene/core/agent';
4
5
  import { BaseMidsceneTools } from '@midscene/shared/mcp/base-tools';
5
6
  import { ChildProcessWithoutNullStreams } from 'node:child_process';
@@ -159,13 +160,14 @@ export declare type ComputerInterface = ComputerDevice | RDPDevice;
159
160
  /** Init args for the local desktop agent (macOS/Windows/Linux). */
160
161
  declare type ComputerLocalInitArgs = {
161
162
  mode: 'local';
162
- } & Pick<ComputerDeviceOpt, 'displayId' | 'headless'>;
163
+ } & Pick<ComputerDeviceOpt, 'displayId' | 'headless'> & AgentBehaviorInitArgs;
163
164
 
164
165
  /**
165
166
  * Computer-specific tools manager
166
167
  * Extends BaseMidsceneTools to provide desktop automation tools
167
168
  */
168
169
  export declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent, ComputerInitArgs> {
170
+ private lastInitArgsSignature?;
169
171
  protected getCliReportSessionName(): string;
170
172
  protected readonly initArgSpec: InitArgSpec<ComputerInitArgs>;
171
173
  protected createTemporaryDevice(): ComputerDevice;
@@ -179,7 +181,7 @@ export declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAge
179
181
  /** Init args for the RDP remote-desktop agent. */
180
182
  declare type ComputerRDPInitArgs = {
181
183
  mode: 'rdp';
182
- } & RDPConnectionConfig;
184
+ } & RDPConnectionConfig & AgentBehaviorInitArgs;
183
185
 
184
186
  export declare function createDefaultRDPBackendClient(): RDPBackendClient;
185
187
 
@@ -1,5 +1,6 @@
1
1
  import { AbstractInterface } from '@midscene/core/device';
2
2
  import { Agent } from '@midscene/core/agent';
3
+ import { AgentBehaviorInitArgs } from '@midscene/shared/mcp/agent-behavior-init-args';
3
4
  import { BaseMCPServer } from '@midscene/shared/mcp';
4
5
  import { BaseMidsceneTools } from '@midscene/shared/mcp/base-tools';
5
6
  import { ComputerInputPrimitives } from '@midscene/core/device';
@@ -111,7 +112,7 @@ declare type ComputerInterface = ComputerDevice | RDPDevice;
111
112
  /** Init args for the local desktop agent (macOS/Windows/Linux). */
112
113
  declare type ComputerLocalInitArgs = {
113
114
  mode: 'local';
114
- } & Pick<ComputerDeviceOpt, 'displayId' | 'headless'>;
115
+ } & Pick<ComputerDeviceOpt, 'displayId' | 'headless'> & AgentBehaviorInitArgs;
115
116
 
116
117
  /**
117
118
  * Computer MCP Server
@@ -127,6 +128,7 @@ export declare class ComputerMCPServer extends BaseMCPServer {
127
128
  * Extends BaseMidsceneTools to provide desktop automation tools
128
129
  */
129
130
  declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent, ComputerInitArgs> {
131
+ private lastInitArgsSignature?;
130
132
  protected getCliReportSessionName(): string;
131
133
  protected readonly initArgSpec: InitArgSpec<ComputerInitArgs>;
132
134
  protected createTemporaryDevice(): ComputerDevice;
@@ -140,7 +142,7 @@ declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent, Com
140
142
  /** Init args for the RDP remote-desktop agent. */
141
143
  declare type ComputerRDPInitArgs = {
142
144
  mode: 'rdp';
143
- } & RDPConnectionConfig;
145
+ } & RDPConnectionConfig & AgentBehaviorInitArgs;
144
146
 
145
147
  declare interface DisplayInfo {
146
148
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/computer",
3
- "version": "1.9.5",
3
+ "version": "1.9.6-beta-20260612050456.0",
4
4
  "description": "Midscene.js Computer Desktop Automation",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "@computer-use/libnut": "^4.2.0",
39
39
  "clipboardy": "^4.0.0",
40
40
  "screenshot-desktop": "^1.15.3",
41
- "@midscene/core": "1.9.5",
42
- "@midscene/shared": "1.9.5"
41
+ "@midscene/core": "1.9.6-beta-20260612050456.0",
42
+ "@midscene/shared": "1.9.6-beta-20260612050456.0"
43
43
  },
44
44
  "optionalDependencies": {
45
45
  "node-mac-permissions": "2.5.0"