@midscene/computer 1.7.5-beta-20260420031652.0 → 1.7.5-beta-20260420031920.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
@@ -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-20260420031652.0");
412
+ console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420031920.0");
413
413
  console.log('[HealthCheck] Taking screenshot...');
414
414
  const screenshotTimeout = 15000;
415
415
  let timeoutId;
@@ -815,13 +815,29 @@ 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
+ }
818
828
  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
+ };
819
833
  class ComputerMidsceneTools extends BaseMidsceneTools {
820
834
  createTemporaryDevice() {
821
835
  return new ComputerDevice({});
822
836
  }
823
- async ensureAgent(displayId, headless) {
824
- if (this.agent && displayId) {
837
+ async ensureAgent(opts) {
838
+ const displayId = opts?.displayId;
839
+ const headless = opts?.headless;
840
+ if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
825
841
  try {
826
842
  await this.agent.destroy?.();
827
843
  } catch (error) {
@@ -831,7 +847,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
831
847
  }
832
848
  if (this.agent) return this.agent;
833
849
  debug('Creating Computer agent with displayId:', displayId || 'primary');
834
- const opts = {
850
+ const agentOpts = {
835
851
  ...displayId ? {
836
852
  displayId
837
853
  } : {},
@@ -839,7 +855,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
839
855
  headless
840
856
  } : {}
841
857
  };
842
- const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
858
+ const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
843
859
  this.agent = agent;
844
860
  return agent;
845
861
  }
@@ -848,18 +864,17 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
848
864
  {
849
865
  name: 'computer_connect',
850
866
  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.',
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);
867
+ schema: this.getAgentInitArgSchema(),
868
+ cli: this.getAgentInitArgCliMetadata(),
869
+ handler: async (args)=>{
870
+ const initArgs = this.extractAgentInitParam(args);
871
+ const agent = await this.ensureAgent(initArgs);
857
872
  const screenshot = await agent.interface.screenshotBase64();
858
873
  return {
859
874
  content: [
860
875
  {
861
876
  type: 'text',
862
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
877
+ text: `Connected to computer${initArgs?.displayId ? ` (Display: ${initArgs.displayId})` : ' (Primary display)'}`
863
878
  },
864
879
  ...this.buildScreenshotContent(screenshot)
865
880
  ]
@@ -890,11 +905,21 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
890
905
  }
891
906
  ];
892
907
  }
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
+ }
893
918
  }
894
919
  const tools = new ComputerMidsceneTools();
895
920
  runToolsCLI(tools, 'midscene-computer', {
896
921
  stripPrefix: 'computer_',
897
- version: "1.7.5-beta-20260420031652.0",
922
+ version: "1.7.5-beta-20260420031920.0",
898
923
  extraCommands: createReportCliCommands()
899
924
  }).catch((e)=>{
900
925
  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-20260420031652.0");
412
+ console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420031920.0");
413
413
  console.log('[HealthCheck] Taking screenshot...');
414
414
  const screenshotTimeout = 15000;
415
415
  let timeoutId;
@@ -815,13 +815,29 @@ 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
+ }
818
828
  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
+ };
819
833
  class ComputerMidsceneTools extends BaseMidsceneTools {
820
834
  createTemporaryDevice() {
821
835
  return new ComputerDevice({});
822
836
  }
823
- async ensureAgent(displayId, headless) {
824
- if (this.agent && displayId) {
837
+ async ensureAgent(opts) {
838
+ const displayId = opts?.displayId;
839
+ const headless = opts?.headless;
840
+ if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
825
841
  try {
826
842
  await this.agent.destroy?.();
827
843
  } catch (error) {
@@ -831,7 +847,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
831
847
  }
832
848
  if (this.agent) return this.agent;
833
849
  debug('Creating Computer agent with displayId:', displayId || 'primary');
834
- const opts = {
850
+ const agentOpts = {
835
851
  ...displayId ? {
836
852
  displayId
837
853
  } : {},
@@ -839,7 +855,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
839
855
  headless
840
856
  } : {}
841
857
  };
842
- const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
858
+ const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
843
859
  this.agent = agent;
844
860
  return agent;
845
861
  }
@@ -848,18 +864,17 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
848
864
  {
849
865
  name: 'computer_connect',
850
866
  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.',
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);
867
+ schema: this.getAgentInitArgSchema(),
868
+ cli: this.getAgentInitArgCliMetadata(),
869
+ handler: async (args)=>{
870
+ const initArgs = this.extractAgentInitParam(args);
871
+ const agent = await this.ensureAgent(initArgs);
857
872
  const screenshot = await agent.interface.screenshotBase64();
858
873
  return {
859
874
  content: [
860
875
  {
861
876
  type: 'text',
862
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
877
+ text: `Connected to computer${initArgs?.displayId ? ` (Display: ${initArgs.displayId})` : ' (Primary display)'}`
863
878
  },
864
879
  ...this.buildScreenshotContent(screenshot)
865
880
  ]
@@ -890,9 +905,19 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
890
905
  }
891
906
  ];
892
907
  }
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
+ }
893
918
  }
894
919
  function version() {
895
- const currentVersion = "1.7.5-beta-20260420031652.0";
920
+ const currentVersion = "1.7.5-beta-20260420031920.0";
896
921
  console.log(`@midscene/computer v${currentVersion}`);
897
922
  return currentVersion;
898
923
  }
@@ -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-20260420031652.0");
411
+ console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420031920.0");
412
412
  console.log('[HealthCheck] Taking screenshot...');
413
413
  const screenshotTimeout = 15000;
414
414
  let timeoutId;
@@ -814,13 +814,29 @@ 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
+ }
817
827
  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
+ };
818
832
  class ComputerMidsceneTools extends BaseMidsceneTools {
819
833
  createTemporaryDevice() {
820
834
  return new ComputerDevice({});
821
835
  }
822
- async ensureAgent(displayId, headless) {
823
- if (this.agent && displayId) {
836
+ async ensureAgent(opts) {
837
+ const displayId = opts?.displayId;
838
+ const headless = opts?.headless;
839
+ if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
824
840
  try {
825
841
  await this.agent.destroy?.();
826
842
  } catch (error) {
@@ -830,7 +846,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
830
846
  }
831
847
  if (this.agent) return this.agent;
832
848
  debug('Creating Computer agent with displayId:', displayId || 'primary');
833
- const opts = {
849
+ const agentOpts = {
834
850
  ...displayId ? {
835
851
  displayId
836
852
  } : {},
@@ -838,7 +854,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
838
854
  headless
839
855
  } : {}
840
856
  };
841
- const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
857
+ const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
842
858
  this.agent = agent;
843
859
  return agent;
844
860
  }
@@ -847,18 +863,17 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
847
863
  {
848
864
  name: 'computer_connect',
849
865
  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.',
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);
866
+ schema: this.getAgentInitArgSchema(),
867
+ cli: this.getAgentInitArgCliMetadata(),
868
+ handler: async (args)=>{
869
+ const initArgs = this.extractAgentInitParam(args);
870
+ const agent = await this.ensureAgent(initArgs);
856
871
  const screenshot = await agent.interface.screenshotBase64();
857
872
  return {
858
873
  content: [
859
874
  {
860
875
  type: 'text',
861
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
876
+ text: `Connected to computer${initArgs?.displayId ? ` (Display: ${initArgs.displayId})` : ' (Primary display)'}`
862
877
  },
863
878
  ...this.buildScreenshotContent(screenshot)
864
879
  ]
@@ -889,6 +904,16 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
889
904
  }
890
905
  ];
891
906
  }
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
+ }
892
917
  }
893
918
  class ComputerMCPServer extends BaseMCPServer {
894
919
  createToolsManager() {
@@ -897,7 +922,7 @@ class ComputerMCPServer extends BaseMCPServer {
897
922
  constructor(toolsManager){
898
923
  super({
899
924
  name: '@midscene/computer-mcp',
900
- version: "1.7.5-beta-20260420031652.0",
925
+ version: "1.7.5-beta-20260420031920.0",
901
926
  description: 'Control the computer desktop using natural language commands'
902
927
  }, toolsManager);
903
928
  }
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-20260420031652.0");
440
+ console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420031920.0");
441
441
  console.log('[HealthCheck] Taking screenshot...');
442
442
  const screenshotTimeout = 15000;
443
443
  let timeoutId;
@@ -843,13 +843,29 @@ 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
+ }
846
856
  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
+ };
847
861
  class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
848
862
  createTemporaryDevice() {
849
863
  return new ComputerDevice({});
850
864
  }
851
- async ensureAgent(displayId, headless) {
852
- if (this.agent && displayId) {
865
+ async ensureAgent(opts) {
866
+ const displayId = opts?.displayId;
867
+ const headless = opts?.headless;
868
+ if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
853
869
  try {
854
870
  await this.agent.destroy?.();
855
871
  } catch (error) {
@@ -859,7 +875,7 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
859
875
  }
860
876
  if (this.agent) return this.agent;
861
877
  debug('Creating Computer agent with displayId:', displayId || 'primary');
862
- const opts = {
878
+ const agentOpts = {
863
879
  ...displayId ? {
864
880
  displayId
865
881
  } : {},
@@ -867,7 +883,7 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
867
883
  headless
868
884
  } : {}
869
885
  };
870
- const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
886
+ const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
871
887
  this.agent = agent;
872
888
  return agent;
873
889
  }
@@ -876,18 +892,17 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
876
892
  {
877
893
  name: 'computer_connect',
878
894
  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.',
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);
895
+ schema: this.getAgentInitArgSchema(),
896
+ cli: this.getAgentInitArgCliMetadata(),
897
+ handler: async (args)=>{
898
+ const initArgs = this.extractAgentInitParam(args);
899
+ const agent = await this.ensureAgent(initArgs);
885
900
  const screenshot = await agent.interface.screenshotBase64();
886
901
  return {
887
902
  content: [
888
903
  {
889
904
  type: 'text',
890
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
905
+ text: `Connected to computer${initArgs?.displayId ? ` (Display: ${initArgs.displayId})` : ' (Primary display)'}`
891
906
  },
892
907
  ...this.buildScreenshotContent(screenshot)
893
908
  ]
@@ -918,11 +933,21 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
918
933
  }
919
934
  ];
920
935
  }
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
+ }
921
946
  }
922
947
  const tools = new ComputerMidsceneTools();
923
948
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-computer', {
924
949
  stripPrefix: 'computer_',
925
- version: "1.7.5-beta-20260420031652.0",
950
+ version: "1.7.5-beta-20260420031920.0",
926
951
  extraCommands: (0, core_namespaceObject.createReportCliCommands)()
927
952
  }).catch((e)=>{
928
953
  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-20260420031652.0");
461
+ console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420031920.0");
462
462
  console.log('[HealthCheck] Taking screenshot...');
463
463
  const screenshotTimeout = 15000;
464
464
  let timeoutId;
@@ -866,13 +866,29 @@ 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
+ }
869
879
  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
+ };
870
884
  class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
871
885
  createTemporaryDevice() {
872
886
  return new ComputerDevice({});
873
887
  }
874
- async ensureAgent(displayId, headless) {
875
- if (this.agent && displayId) {
888
+ async ensureAgent(opts) {
889
+ const displayId = opts?.displayId;
890
+ const headless = opts?.headless;
891
+ if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
876
892
  try {
877
893
  await this.agent.destroy?.();
878
894
  } catch (error) {
@@ -882,7 +898,7 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
882
898
  }
883
899
  if (this.agent) return this.agent;
884
900
  debug('Creating Computer agent with displayId:', displayId || 'primary');
885
- const opts = {
901
+ const agentOpts = {
886
902
  ...displayId ? {
887
903
  displayId
888
904
  } : {},
@@ -890,7 +906,7 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
890
906
  headless
891
907
  } : {}
892
908
  };
893
- const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
909
+ const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
894
910
  this.agent = agent;
895
911
  return agent;
896
912
  }
@@ -899,18 +915,17 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
899
915
  {
900
916
  name: 'computer_connect',
901
917
  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.',
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);
918
+ schema: this.getAgentInitArgSchema(),
919
+ cli: this.getAgentInitArgCliMetadata(),
920
+ handler: async (args)=>{
921
+ const initArgs = this.extractAgentInitParam(args);
922
+ const agent = await this.ensureAgent(initArgs);
908
923
  const screenshot = await agent.interface.screenshotBase64();
909
924
  return {
910
925
  content: [
911
926
  {
912
927
  type: 'text',
913
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
928
+ text: `Connected to computer${initArgs?.displayId ? ` (Display: ${initArgs.displayId})` : ' (Primary display)'}`
914
929
  },
915
930
  ...this.buildScreenshotContent(screenshot)
916
931
  ]
@@ -941,10 +956,20 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
941
956
  }
942
957
  ];
943
958
  }
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
+ }
944
969
  }
945
970
  const env_namespaceObject = require("@midscene/shared/env");
946
971
  function version() {
947
- const currentVersion = "1.7.5-beta-20260420031652.0";
972
+ const currentVersion = "1.7.5-beta-20260420031920.0";
948
973
  console.log(`@midscene/computer v${currentVersion}`);
949
974
  return currentVersion;
950
975
  }
@@ -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-20260420031652.0");
455
+ console.log("[HealthCheck] @midscene/computer v1.7.5-beta-20260420031920.0");
456
456
  console.log('[HealthCheck] Taking screenshot...');
457
457
  const screenshotTimeout = 15000;
458
458
  let timeoutId;
@@ -858,13 +858,29 @@ 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
+ }
861
871
  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
+ };
862
876
  class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
863
877
  createTemporaryDevice() {
864
878
  return new ComputerDevice({});
865
879
  }
866
- async ensureAgent(displayId, headless) {
867
- if (this.agent && displayId) {
880
+ async ensureAgent(opts) {
881
+ const displayId = opts?.displayId;
882
+ const headless = opts?.headless;
883
+ if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
868
884
  try {
869
885
  await this.agent.destroy?.();
870
886
  } catch (error) {
@@ -874,7 +890,7 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
874
890
  }
875
891
  if (this.agent) return this.agent;
876
892
  debug('Creating Computer agent with displayId:', displayId || 'primary');
877
- const opts = {
893
+ const agentOpts = {
878
894
  ...displayId ? {
879
895
  displayId
880
896
  } : {},
@@ -882,7 +898,7 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
882
898
  headless
883
899
  } : {}
884
900
  };
885
- const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
901
+ const agent = await agentFromComputer(Object.keys(agentOpts).length > 0 ? agentOpts : void 0);
886
902
  this.agent = agent;
887
903
  return agent;
888
904
  }
@@ -891,18 +907,17 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
891
907
  {
892
908
  name: 'computer_connect',
893
909
  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.',
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);
910
+ schema: this.getAgentInitArgSchema(),
911
+ cli: this.getAgentInitArgCliMetadata(),
912
+ handler: async (args)=>{
913
+ const initArgs = this.extractAgentInitParam(args);
914
+ const agent = await this.ensureAgent(initArgs);
900
915
  const screenshot = await agent.interface.screenshotBase64();
901
916
  return {
902
917
  content: [
903
918
  {
904
919
  type: 'text',
905
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
920
+ text: `Connected to computer${initArgs?.displayId ? ` (Display: ${initArgs.displayId})` : ' (Primary display)'}`
906
921
  },
907
922
  ...this.buildScreenshotContent(screenshot)
908
923
  ]
@@ -933,6 +948,16 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
933
948
  }
934
949
  ];
935
950
  }
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
+ }
936
961
  }
937
962
  class ComputerMCPServer extends mcp_namespaceObject.BaseMCPServer {
938
963
  createToolsManager() {
@@ -941,7 +966,7 @@ class ComputerMCPServer extends mcp_namespaceObject.BaseMCPServer {
941
966
  constructor(toolsManager){
942
967
  super({
943
968
  name: '@midscene/computer-mcp',
944
- version: "1.7.5-beta-20260420031652.0",
969
+ version: "1.7.5-beta-20260420031920.0",
945
970
  description: 'Control the computer desktop using natural language commands'
946
971
  }, toolsManager);
947
972
  }
@@ -3,6 +3,7 @@ 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';
6
7
  import { InterfaceType } from '@midscene/core';
7
8
  import { overrideAIConfig } from '@midscene/shared/env';
8
9
  import { Size } from '@midscene/core';
@@ -113,13 +114,16 @@ export declare interface ComputerDeviceOpt {
113
114
  xvfbResolution?: string;
114
115
  }
115
116
 
117
+ declare type ComputerInitArgs = Pick<ComputerDeviceOpt, 'displayId' | 'headless'>;
118
+
116
119
  /**
117
120
  * Computer-specific tools manager
118
121
  * Extends BaseMidsceneTools to provide desktop automation tools
119
122
  */
120
- export declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent> {
123
+ export declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent, ComputerInitArgs> {
124
+ protected readonly initArgSpec: InitArgSpec<ComputerInitArgs>;
121
125
  protected createTemporaryDevice(): ComputerDevice;
122
- protected ensureAgent(displayId?: string, headless?: boolean): Promise<ComputerAgent>;
126
+ protected ensureAgent(opts?: ComputerInitArgs): Promise<ComputerAgent>;
123
127
  /**
124
128
  * Provide Computer-specific platform tools
125
129
  */
@@ -3,6 +3,7 @@ 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';
6
7
  import { InterfaceType } from '@midscene/core';
7
8
  import { LaunchMCPServerOptions } from '@midscene/shared/mcp';
8
9
  import { LaunchMCPServerResult } from '@midscene/shared/mcp';
@@ -84,6 +85,8 @@ declare interface ComputerDeviceOpt {
84
85
  xvfbResolution?: string;
85
86
  }
86
87
 
88
+ declare type ComputerInitArgs = Pick<ComputerDeviceOpt, 'displayId' | 'headless'>;
89
+
87
90
  /**
88
91
  * Computer MCP Server
89
92
  * Provides MCP tools for computer desktop automation
@@ -97,9 +100,10 @@ export declare class ComputerMCPServer extends BaseMCPServer {
97
100
  * Computer-specific tools manager
98
101
  * Extends BaseMidsceneTools to provide desktop automation tools
99
102
  */
100
- declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent> {
103
+ declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent, ComputerInitArgs> {
104
+ protected readonly initArgSpec: InitArgSpec<ComputerInitArgs>;
101
105
  protected createTemporaryDevice(): ComputerDevice;
102
- protected ensureAgent(displayId?: string, headless?: boolean): Promise<ComputerAgent>;
106
+ protected ensureAgent(opts?: ComputerInitArgs): Promise<ComputerAgent>;
103
107
  /**
104
108
  * Provide Computer-specific platform tools
105
109
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/computer",
3
- "version": "1.7.5-beta-20260420031652.0",
3
+ "version": "1.7.5-beta-20260420031920.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-20260420031652.0",
40
- "@midscene/shared": "1.7.5-beta-20260420031652.0"
39
+ "@midscene/core": "1.7.5-beta-20260420031920.0",
40
+ "@midscene/shared": "1.7.5-beta-20260420031920.0"
41
41
  },
42
42
  "optionalDependencies": {
43
43
  "node-mac-permissions": "2.5.0"