@midscene/computer 1.5.4 → 1.5.5-beta-20260311070351.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,5 +1,5 @@
1
1
  import { CLIError, runToolsCLI } from "@midscene/shared/cli";
2
- import { getMidsceneLocationSchema, z } from "@midscene/core";
2
+ import { createSessionAgentOptions, exportSessionReport, getMidsceneLocationSchema, z } from "@midscene/core";
3
3
  import { getDebug } from "@midscene/shared/logger";
4
4
  import { BaseMidsceneTools } from "@midscene/shared/mcp";
5
5
  import { Agent } from "@midscene/core/agent";
@@ -299,7 +299,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
299
299
  }
300
300
  async healthCheck() {
301
301
  console.log('[HealthCheck] Starting health check...');
302
- console.log("[HealthCheck] @midscene/computer v1.5.4");
302
+ console.log("[HealthCheck] @midscene/computer v1.5.5-beta-20260311070351.0");
303
303
  console.log('[HealthCheck] Taking screenshot...');
304
304
  const screenshotTimeout = 15000;
305
305
  let timeoutId;
@@ -709,13 +709,20 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
709
709
  }
710
710
  if (this.agent) return this.agent;
711
711
  debug('Creating Computer agent with displayId:', displayId || 'primary');
712
+ const sessionOptions = createSessionAgentOptions({
713
+ sessionId: this.getInvocationStringArg('sessionId'),
714
+ platform: 'computer',
715
+ commandId: this.getInvocationCommandId(),
716
+ commandName: this.getInvocationCommandName()
717
+ });
712
718
  const opts = {
713
719
  ...displayId ? {
714
720
  displayId
715
721
  } : {},
716
722
  ...void 0 !== headless ? {
717
723
  headless
718
- } : {}
724
+ } : {},
725
+ ...sessionOptions
719
726
  };
720
727
  const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
721
728
  this.agent = agent;
@@ -730,19 +737,22 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
730
737
  displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
731
738
  headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
732
739
  },
733
- handler: async ({ displayId, headless })=>{
734
- const agent = await this.ensureAgent(displayId, headless);
735
- const screenshot = await agent.interface.screenshotBase64();
736
- return {
737
- content: [
738
- {
739
- type: 'text',
740
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
741
- },
742
- ...this.buildScreenshotContent(screenshot)
743
- ]
744
- };
745
- }
740
+ handler: async (args)=>this.runWithInvocationContext({
741
+ ...args,
742
+ __commandName: 'computer_connect'
743
+ }, async ()=>{
744
+ const agent = await this.ensureAgent(args.displayId, args.headless);
745
+ const screenshot = await agent.interface.screenshotBase64();
746
+ return {
747
+ content: [
748
+ {
749
+ type: 'text',
750
+ text: `Connected to computer${args.displayId ? ` (Display: ${args.displayId})` : ' (Primary display)'}`
751
+ },
752
+ ...this.buildScreenshotContent(screenshot)
753
+ ]
754
+ };
755
+ })
746
756
  },
747
757
  {
748
758
  name: 'computer_disconnect',
@@ -750,6 +760,27 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
750
760
  schema: {},
751
761
  handler: this.createDisconnectHandler('computer')
752
762
  },
763
+ {
764
+ name: 'computer_export_session_report',
765
+ description: 'Generate a merged HTML report from a persisted computer session',
766
+ schema: {
767
+ sessionId: z.string().describe('Persistent session ID to export')
768
+ },
769
+ handler: async (args)=>{
770
+ const sessionId = args.sessionId;
771
+ if ('string' != typeof sessionId || !sessionId) return {
772
+ content: [
773
+ {
774
+ type: 'text',
775
+ text: 'sessionId is required to export a session report'
776
+ }
777
+ ],
778
+ isError: true
779
+ };
780
+ const reportPath = exportSessionReport(sessionId);
781
+ return this.buildTextResult(`Session report generated: ${reportPath}`);
782
+ }
783
+ },
753
784
  {
754
785
  name: 'computer_list_displays',
755
786
  description: 'List all available displays/monitors',
@@ -772,7 +803,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
772
803
  const tools = new ComputerMidsceneTools();
773
804
  runToolsCLI(tools, 'midscene-computer', {
774
805
  stripPrefix: 'computer_',
775
- version: "1.5.4"
806
+ version: "1.5.5-beta-20260311070351.0"
776
807
  }).catch((e)=>{
777
808
  if (!(e instanceof CLIError)) console.error(e);
778
809
  process.exit(e instanceof CLIError ? e.exitCode : 1);
package/dist/es/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import node_assert from "node:assert";
2
2
  import { execSync, spawn } from "node:child_process";
3
3
  import { createRequire } from "node:module";
4
- import { getMidsceneLocationSchema, z } from "@midscene/core";
4
+ import { createSessionAgentOptions, exportSessionReport, getMidsceneLocationSchema, z } from "@midscene/core";
5
5
  import { actionHoverParamSchema, defineAction, defineActionClearInput, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionRightClick, defineActionScroll, defineActionTap } from "@midscene/core/device";
6
6
  import { sleep } from "@midscene/core/utils";
7
7
  import { createImgBase64ByFormat } from "@midscene/shared/img";
@@ -299,7 +299,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
299
299
  }
300
300
  async healthCheck() {
301
301
  console.log('[HealthCheck] Starting health check...');
302
- console.log("[HealthCheck] @midscene/computer v1.5.4");
302
+ console.log("[HealthCheck] @midscene/computer v1.5.5-beta-20260311070351.0");
303
303
  console.log('[HealthCheck] Taking screenshot...');
304
304
  const screenshotTimeout = 15000;
305
305
  let timeoutId;
@@ -709,13 +709,20 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
709
709
  }
710
710
  if (this.agent) return this.agent;
711
711
  debug('Creating Computer agent with displayId:', displayId || 'primary');
712
+ const sessionOptions = createSessionAgentOptions({
713
+ sessionId: this.getInvocationStringArg('sessionId'),
714
+ platform: 'computer',
715
+ commandId: this.getInvocationCommandId(),
716
+ commandName: this.getInvocationCommandName()
717
+ });
712
718
  const opts = {
713
719
  ...displayId ? {
714
720
  displayId
715
721
  } : {},
716
722
  ...void 0 !== headless ? {
717
723
  headless
718
- } : {}
724
+ } : {},
725
+ ...sessionOptions
719
726
  };
720
727
  const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
721
728
  this.agent = agent;
@@ -730,19 +737,22 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
730
737
  displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
731
738
  headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
732
739
  },
733
- handler: async ({ displayId, headless })=>{
734
- const agent = await this.ensureAgent(displayId, headless);
735
- const screenshot = await agent.interface.screenshotBase64();
736
- return {
737
- content: [
738
- {
739
- type: 'text',
740
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
741
- },
742
- ...this.buildScreenshotContent(screenshot)
743
- ]
744
- };
745
- }
740
+ handler: async (args)=>this.runWithInvocationContext({
741
+ ...args,
742
+ __commandName: 'computer_connect'
743
+ }, async ()=>{
744
+ const agent = await this.ensureAgent(args.displayId, args.headless);
745
+ const screenshot = await agent.interface.screenshotBase64();
746
+ return {
747
+ content: [
748
+ {
749
+ type: 'text',
750
+ text: `Connected to computer${args.displayId ? ` (Display: ${args.displayId})` : ' (Primary display)'}`
751
+ },
752
+ ...this.buildScreenshotContent(screenshot)
753
+ ]
754
+ };
755
+ })
746
756
  },
747
757
  {
748
758
  name: 'computer_disconnect',
@@ -750,6 +760,27 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
750
760
  schema: {},
751
761
  handler: this.createDisconnectHandler('computer')
752
762
  },
763
+ {
764
+ name: 'computer_export_session_report',
765
+ description: 'Generate a merged HTML report from a persisted computer session',
766
+ schema: {
767
+ sessionId: z.string().describe('Persistent session ID to export')
768
+ },
769
+ handler: async (args)=>{
770
+ const sessionId = args.sessionId;
771
+ if ('string' != typeof sessionId || !sessionId) return {
772
+ content: [
773
+ {
774
+ type: 'text',
775
+ text: 'sessionId is required to export a session report'
776
+ }
777
+ ],
778
+ isError: true
779
+ };
780
+ const reportPath = exportSessionReport(sessionId);
781
+ return this.buildTextResult(`Session report generated: ${reportPath}`);
782
+ }
783
+ },
753
784
  {
754
785
  name: 'computer_list_displays',
755
786
  description: 'List all available displays/monitors',
@@ -770,7 +801,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
770
801
  }
771
802
  }
772
803
  function version() {
773
- const currentVersion = "1.5.4";
804
+ const currentVersion = "1.5.5-beta-20260311070351.0";
774
805
  console.log(`@midscene/computer v${currentVersion}`);
775
806
  return currentVersion;
776
807
  }
@@ -3,7 +3,7 @@ import { Agent } from "@midscene/core/agent";
3
3
  import node_assert from "node:assert";
4
4
  import { execSync, spawn } from "node:child_process";
5
5
  import { createRequire } from "node:module";
6
- import { getMidsceneLocationSchema, z } from "@midscene/core";
6
+ import { createSessionAgentOptions, exportSessionReport, getMidsceneLocationSchema, z } from "@midscene/core";
7
7
  import { actionHoverParamSchema, defineAction, defineActionClearInput, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionRightClick, defineActionScroll, defineActionTap } from "@midscene/core/device";
8
8
  import { sleep } from "@midscene/core/utils";
9
9
  import { createImgBase64ByFormat } from "@midscene/shared/img";
@@ -298,7 +298,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
298
298
  }
299
299
  async healthCheck() {
300
300
  console.log('[HealthCheck] Starting health check...');
301
- console.log("[HealthCheck] @midscene/computer v1.5.4");
301
+ console.log("[HealthCheck] @midscene/computer v1.5.5-beta-20260311070351.0");
302
302
  console.log('[HealthCheck] Taking screenshot...');
303
303
  const screenshotTimeout = 15000;
304
304
  let timeoutId;
@@ -708,13 +708,20 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
708
708
  }
709
709
  if (this.agent) return this.agent;
710
710
  debug('Creating Computer agent with displayId:', displayId || 'primary');
711
+ const sessionOptions = createSessionAgentOptions({
712
+ sessionId: this.getInvocationStringArg('sessionId'),
713
+ platform: 'computer',
714
+ commandId: this.getInvocationCommandId(),
715
+ commandName: this.getInvocationCommandName()
716
+ });
711
717
  const opts = {
712
718
  ...displayId ? {
713
719
  displayId
714
720
  } : {},
715
721
  ...void 0 !== headless ? {
716
722
  headless
717
- } : {}
723
+ } : {},
724
+ ...sessionOptions
718
725
  };
719
726
  const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
720
727
  this.agent = agent;
@@ -729,19 +736,22 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
729
736
  displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
730
737
  headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
731
738
  },
732
- handler: async ({ displayId, headless })=>{
733
- const agent = await this.ensureAgent(displayId, headless);
734
- const screenshot = await agent.interface.screenshotBase64();
735
- return {
736
- content: [
737
- {
738
- type: 'text',
739
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
740
- },
741
- ...this.buildScreenshotContent(screenshot)
742
- ]
743
- };
744
- }
739
+ handler: async (args)=>this.runWithInvocationContext({
740
+ ...args,
741
+ __commandName: 'computer_connect'
742
+ }, async ()=>{
743
+ const agent = await this.ensureAgent(args.displayId, args.headless);
744
+ const screenshot = await agent.interface.screenshotBase64();
745
+ return {
746
+ content: [
747
+ {
748
+ type: 'text',
749
+ text: `Connected to computer${args.displayId ? ` (Display: ${args.displayId})` : ' (Primary display)'}`
750
+ },
751
+ ...this.buildScreenshotContent(screenshot)
752
+ ]
753
+ };
754
+ })
745
755
  },
746
756
  {
747
757
  name: 'computer_disconnect',
@@ -749,6 +759,27 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
749
759
  schema: {},
750
760
  handler: this.createDisconnectHandler('computer')
751
761
  },
762
+ {
763
+ name: 'computer_export_session_report',
764
+ description: 'Generate a merged HTML report from a persisted computer session',
765
+ schema: {
766
+ sessionId: z.string().describe('Persistent session ID to export')
767
+ },
768
+ handler: async (args)=>{
769
+ const sessionId = args.sessionId;
770
+ if ('string' != typeof sessionId || !sessionId) return {
771
+ content: [
772
+ {
773
+ type: 'text',
774
+ text: 'sessionId is required to export a session report'
775
+ }
776
+ ],
777
+ isError: true
778
+ };
779
+ const reportPath = exportSessionReport(sessionId);
780
+ return this.buildTextResult(`Session report generated: ${reportPath}`);
781
+ }
782
+ },
752
783
  {
753
784
  name: 'computer_list_displays',
754
785
  description: 'List all available displays/monitors',
@@ -775,7 +806,7 @@ class ComputerMCPServer extends BaseMCPServer {
775
806
  constructor(toolsManager){
776
807
  super({
777
808
  name: '@midscene/computer-mcp',
778
- version: "1.5.4",
809
+ version: "1.5.5-beta-20260311070351.0",
779
810
  description: 'Control the computer desktop using natural language commands'
780
811
  }, toolsManager);
781
812
  }
package/dist/lib/cli.js CHANGED
@@ -327,7 +327,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
327
327
  }
328
328
  async healthCheck() {
329
329
  console.log('[HealthCheck] Starting health check...');
330
- console.log("[HealthCheck] @midscene/computer v1.5.4");
330
+ console.log("[HealthCheck] @midscene/computer v1.5.5-beta-20260311070351.0");
331
331
  console.log('[HealthCheck] Taking screenshot...');
332
332
  const screenshotTimeout = 15000;
333
333
  let timeoutId;
@@ -737,13 +737,20 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
737
737
  }
738
738
  if (this.agent) return this.agent;
739
739
  debug('Creating Computer agent with displayId:', displayId || 'primary');
740
+ const sessionOptions = (0, core_namespaceObject.createSessionAgentOptions)({
741
+ sessionId: this.getInvocationStringArg('sessionId'),
742
+ platform: 'computer',
743
+ commandId: this.getInvocationCommandId(),
744
+ commandName: this.getInvocationCommandName()
745
+ });
740
746
  const opts = {
741
747
  ...displayId ? {
742
748
  displayId
743
749
  } : {},
744
750
  ...void 0 !== headless ? {
745
751
  headless
746
- } : {}
752
+ } : {},
753
+ ...sessionOptions
747
754
  };
748
755
  const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
749
756
  this.agent = agent;
@@ -758,19 +765,22 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
758
765
  displayId: core_namespaceObject.z.string().optional().describe('Display ID (from computer_list_displays)'),
759
766
  headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
760
767
  },
761
- handler: async ({ displayId, headless })=>{
762
- const agent = await this.ensureAgent(displayId, headless);
763
- const screenshot = await agent.interface.screenshotBase64();
764
- return {
765
- content: [
766
- {
767
- type: 'text',
768
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
769
- },
770
- ...this.buildScreenshotContent(screenshot)
771
- ]
772
- };
773
- }
768
+ handler: async (args)=>this.runWithInvocationContext({
769
+ ...args,
770
+ __commandName: 'computer_connect'
771
+ }, async ()=>{
772
+ const agent = await this.ensureAgent(args.displayId, args.headless);
773
+ const screenshot = await agent.interface.screenshotBase64();
774
+ return {
775
+ content: [
776
+ {
777
+ type: 'text',
778
+ text: `Connected to computer${args.displayId ? ` (Display: ${args.displayId})` : ' (Primary display)'}`
779
+ },
780
+ ...this.buildScreenshotContent(screenshot)
781
+ ]
782
+ };
783
+ })
774
784
  },
775
785
  {
776
786
  name: 'computer_disconnect',
@@ -778,6 +788,27 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
778
788
  schema: {},
779
789
  handler: this.createDisconnectHandler('computer')
780
790
  },
791
+ {
792
+ name: 'computer_export_session_report',
793
+ description: 'Generate a merged HTML report from a persisted computer session',
794
+ schema: {
795
+ sessionId: core_namespaceObject.z.string().describe('Persistent session ID to export')
796
+ },
797
+ handler: async (args)=>{
798
+ const sessionId = args.sessionId;
799
+ if ('string' != typeof sessionId || !sessionId) return {
800
+ content: [
801
+ {
802
+ type: 'text',
803
+ text: 'sessionId is required to export a session report'
804
+ }
805
+ ],
806
+ isError: true
807
+ };
808
+ const reportPath = (0, core_namespaceObject.exportSessionReport)(sessionId);
809
+ return this.buildTextResult(`Session report generated: ${reportPath}`);
810
+ }
811
+ },
781
812
  {
782
813
  name: 'computer_list_displays',
783
814
  description: 'List all available displays/monitors',
@@ -800,7 +831,7 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
800
831
  const tools = new ComputerMidsceneTools();
801
832
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-computer', {
802
833
  stripPrefix: 'computer_',
803
- version: "1.5.4"
834
+ version: "1.5.5-beta-20260311070351.0"
804
835
  }).catch((e)=>{
805
836
  if (!(e instanceof cli_namespaceObject.CLIError)) console.error(e);
806
837
  process.exit(e instanceof cli_namespaceObject.CLIError ? e.exitCode : 1);
package/dist/lib/index.js CHANGED
@@ -348,7 +348,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
348
348
  }
349
349
  async healthCheck() {
350
350
  console.log('[HealthCheck] Starting health check...');
351
- console.log("[HealthCheck] @midscene/computer v1.5.4");
351
+ console.log("[HealthCheck] @midscene/computer v1.5.5-beta-20260311070351.0");
352
352
  console.log('[HealthCheck] Taking screenshot...');
353
353
  const screenshotTimeout = 15000;
354
354
  let timeoutId;
@@ -760,13 +760,20 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
760
760
  }
761
761
  if (this.agent) return this.agent;
762
762
  debug('Creating Computer agent with displayId:', displayId || 'primary');
763
+ const sessionOptions = (0, core_namespaceObject.createSessionAgentOptions)({
764
+ sessionId: this.getInvocationStringArg('sessionId'),
765
+ platform: 'computer',
766
+ commandId: this.getInvocationCommandId(),
767
+ commandName: this.getInvocationCommandName()
768
+ });
763
769
  const opts = {
764
770
  ...displayId ? {
765
771
  displayId
766
772
  } : {},
767
773
  ...void 0 !== headless ? {
768
774
  headless
769
- } : {}
775
+ } : {},
776
+ ...sessionOptions
770
777
  };
771
778
  const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
772
779
  this.agent = agent;
@@ -781,19 +788,22 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
781
788
  displayId: core_namespaceObject.z.string().optional().describe('Display ID (from computer_list_displays)'),
782
789
  headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
783
790
  },
784
- handler: async ({ displayId, headless })=>{
785
- const agent = await this.ensureAgent(displayId, headless);
786
- const screenshot = await agent.interface.screenshotBase64();
787
- return {
788
- content: [
789
- {
790
- type: 'text',
791
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
792
- },
793
- ...this.buildScreenshotContent(screenshot)
794
- ]
795
- };
796
- }
791
+ handler: async (args)=>this.runWithInvocationContext({
792
+ ...args,
793
+ __commandName: 'computer_connect'
794
+ }, async ()=>{
795
+ const agent = await this.ensureAgent(args.displayId, args.headless);
796
+ const screenshot = await agent.interface.screenshotBase64();
797
+ return {
798
+ content: [
799
+ {
800
+ type: 'text',
801
+ text: `Connected to computer${args.displayId ? ` (Display: ${args.displayId})` : ' (Primary display)'}`
802
+ },
803
+ ...this.buildScreenshotContent(screenshot)
804
+ ]
805
+ };
806
+ })
797
807
  },
798
808
  {
799
809
  name: 'computer_disconnect',
@@ -801,6 +811,27 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
801
811
  schema: {},
802
812
  handler: this.createDisconnectHandler('computer')
803
813
  },
814
+ {
815
+ name: 'computer_export_session_report',
816
+ description: 'Generate a merged HTML report from a persisted computer session',
817
+ schema: {
818
+ sessionId: core_namespaceObject.z.string().describe('Persistent session ID to export')
819
+ },
820
+ handler: async (args)=>{
821
+ const sessionId = args.sessionId;
822
+ if ('string' != typeof sessionId || !sessionId) return {
823
+ content: [
824
+ {
825
+ type: 'text',
826
+ text: 'sessionId is required to export a session report'
827
+ }
828
+ ],
829
+ isError: true
830
+ };
831
+ const reportPath = (0, core_namespaceObject.exportSessionReport)(sessionId);
832
+ return this.buildTextResult(`Session report generated: ${reportPath}`);
833
+ }
834
+ },
804
835
  {
805
836
  name: 'computer_list_displays',
806
837
  description: 'List all available displays/monitors',
@@ -822,7 +853,7 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
822
853
  }
823
854
  const env_namespaceObject = require("@midscene/shared/env");
824
855
  function version() {
825
- const currentVersion = "1.5.4";
856
+ const currentVersion = "1.5.5-beta-20260311070351.0";
826
857
  console.log(`@midscene/computer v${currentVersion}`);
827
858
  return currentVersion;
828
859
  }
@@ -342,7 +342,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
342
342
  }
343
343
  async healthCheck() {
344
344
  console.log('[HealthCheck] Starting health check...');
345
- console.log("[HealthCheck] @midscene/computer v1.5.4");
345
+ console.log("[HealthCheck] @midscene/computer v1.5.5-beta-20260311070351.0");
346
346
  console.log('[HealthCheck] Taking screenshot...');
347
347
  const screenshotTimeout = 15000;
348
348
  let timeoutId;
@@ -752,13 +752,20 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
752
752
  }
753
753
  if (this.agent) return this.agent;
754
754
  debug('Creating Computer agent with displayId:', displayId || 'primary');
755
+ const sessionOptions = (0, core_namespaceObject.createSessionAgentOptions)({
756
+ sessionId: this.getInvocationStringArg('sessionId'),
757
+ platform: 'computer',
758
+ commandId: this.getInvocationCommandId(),
759
+ commandName: this.getInvocationCommandName()
760
+ });
755
761
  const opts = {
756
762
  ...displayId ? {
757
763
  displayId
758
764
  } : {},
759
765
  ...void 0 !== headless ? {
760
766
  headless
761
- } : {}
767
+ } : {},
768
+ ...sessionOptions
762
769
  };
763
770
  const agent = await agentFromComputer(Object.keys(opts).length > 0 ? opts : void 0);
764
771
  this.agent = agent;
@@ -773,19 +780,22 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
773
780
  displayId: core_namespaceObject.z.string().optional().describe('Display ID (from computer_list_displays)'),
774
781
  headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
775
782
  },
776
- handler: async ({ displayId, headless })=>{
777
- const agent = await this.ensureAgent(displayId, headless);
778
- const screenshot = await agent.interface.screenshotBase64();
779
- return {
780
- content: [
781
- {
782
- type: 'text',
783
- text: `Connected to computer${displayId ? ` (Display: ${displayId})` : ' (Primary display)'}`
784
- },
785
- ...this.buildScreenshotContent(screenshot)
786
- ]
787
- };
788
- }
783
+ handler: async (args)=>this.runWithInvocationContext({
784
+ ...args,
785
+ __commandName: 'computer_connect'
786
+ }, async ()=>{
787
+ const agent = await this.ensureAgent(args.displayId, args.headless);
788
+ const screenshot = await agent.interface.screenshotBase64();
789
+ return {
790
+ content: [
791
+ {
792
+ type: 'text',
793
+ text: `Connected to computer${args.displayId ? ` (Display: ${args.displayId})` : ' (Primary display)'}`
794
+ },
795
+ ...this.buildScreenshotContent(screenshot)
796
+ ]
797
+ };
798
+ })
789
799
  },
790
800
  {
791
801
  name: 'computer_disconnect',
@@ -793,6 +803,27 @@ class ComputerMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
793
803
  schema: {},
794
804
  handler: this.createDisconnectHandler('computer')
795
805
  },
806
+ {
807
+ name: 'computer_export_session_report',
808
+ description: 'Generate a merged HTML report from a persisted computer session',
809
+ schema: {
810
+ sessionId: core_namespaceObject.z.string().describe('Persistent session ID to export')
811
+ },
812
+ handler: async (args)=>{
813
+ const sessionId = args.sessionId;
814
+ if ('string' != typeof sessionId || !sessionId) return {
815
+ content: [
816
+ {
817
+ type: 'text',
818
+ text: 'sessionId is required to export a session report'
819
+ }
820
+ ],
821
+ isError: true
822
+ };
823
+ const reportPath = (0, core_namespaceObject.exportSessionReport)(sessionId);
824
+ return this.buildTextResult(`Session report generated: ${reportPath}`);
825
+ }
826
+ },
796
827
  {
797
828
  name: 'computer_list_displays',
798
829
  description: 'List all available displays/monitors',
@@ -819,7 +850,7 @@ class ComputerMCPServer extends mcp_namespaceObject.BaseMCPServer {
819
850
  constructor(toolsManager){
820
851
  super({
821
852
  name: '@midscene/computer-mcp',
822
- version: "1.5.4",
853
+ version: "1.5.5-beta-20260311070351.0",
823
854
  description: 'Control the computer desktop using natural language commands'
824
855
  }, toolsManager);
825
856
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/computer",
3
- "version": "1.5.4",
3
+ "version": "1.5.5-beta-20260311070351.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/shared": "1.5.4",
40
- "@midscene/core": "1.5.4"
39
+ "@midscene/shared": "1.5.5-beta-20260311070351.0",
40
+ "@midscene/core": "1.5.5-beta-20260311070351.0"
41
41
  },
42
42
  "optionalDependencies": {
43
43
  "node-mac-permissions": "2.5.0"