@midscene/computer 1.9.2-beta-20260608084200.0 → 1.9.2-beta-20260608092543.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.
Binary file
package/dist/es/cli.mjs CHANGED
@@ -642,7 +642,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
642
642
  }
643
643
  async healthCheck() {
644
644
  console.log('[HealthCheck] Starting health check...');
645
- console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608084200.0");
645
+ console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608092543.0");
646
646
  console.log('[HealthCheck] Taking screenshot...');
647
647
  const screenshotTimeout = 15000;
648
648
  let timeoutId;
@@ -1095,24 +1095,6 @@ function createPlatformActions() {
1095
1095
  })
1096
1096
  };
1097
1097
  }
1098
- function normalizeRdpHost(host) {
1099
- const trimmed = host.trim();
1100
- if (trimmed.length >= 2 && trimmed.startsWith('[') && trimmed.endsWith(']') && trimmed.includes(':')) return trimmed.slice(1, -1);
1101
- return trimmed;
1102
- }
1103
- function formatRdpHost(host) {
1104
- const normalizedHost = normalizeRdpHost(host);
1105
- return normalizedHost.includes(':') ? `[${normalizedHost}]` : normalizedHost;
1106
- }
1107
- function formatRdpServerAddress(host, port) {
1108
- return `${formatRdpHost(host)}:${port}`;
1109
- }
1110
- function normalizeRdpConnectionConfig(config) {
1111
- return {
1112
- ...config,
1113
- host: normalizeRdpHost(config.host)
1114
- };
1115
- }
1116
1098
  const platformBinaryMap = {
1117
1099
  darwin: {
1118
1100
  directory: 'darwin',
@@ -1167,7 +1149,7 @@ class HelperProcessRDPBackendClient {
1167
1149
  await this.ensureHelperStarted();
1168
1150
  const response = await this.send({
1169
1151
  type: 'connect',
1170
- config: normalizeRdpConnectionConfig(config)
1152
+ config
1171
1153
  });
1172
1154
  if ('connected' !== response.type) throw new Error(`Expected connected response, got ${response.type}`);
1173
1155
  this.connected = true;
@@ -1441,10 +1423,9 @@ const DEFAULT_SCROLL_STEP_AMOUNT = 120;
1441
1423
  class RDPDevice {
1442
1424
  describe() {
1443
1425
  const port = this.options.port || 3389;
1444
- const server = formatRdpServerAddress(this.options.host, port);
1445
1426
  const username = this.options.username ? ` as ${this.options.username}` : '';
1446
1427
  const session = this.connectionInfo?.sessionId ? ` [session ${this.connectionInfo.sessionId}]` : '';
1447
- return `RDP Device ${server}${username}${session}`;
1428
+ return `RDP Device ${this.options.host}:${port}${username}${session}`;
1448
1429
  }
1449
1430
  async connect() {
1450
1431
  this.throwIfDestroyed();
@@ -1484,11 +1465,10 @@ class RDPDevice {
1484
1465
  call: async ()=>{
1485
1466
  this.assertConnected();
1486
1467
  const size = await this.size();
1487
- const server = this.connectionInfo?.server || formatRdpServerAddress(this.options.host, this.options.port || 3389);
1488
1468
  return [
1489
1469
  {
1490
1470
  id: this.connectionInfo?.sessionId || this.options.host,
1491
- name: `RDP ${server} (${size.width}x${size.height})`,
1471
+ name: `RDP ${this.connectionInfo?.server || this.options.host} (${size.width}x${size.height})`,
1492
1472
  primary: true
1493
1473
  }
1494
1474
  ];
@@ -1686,12 +1666,11 @@ class RDPDevice {
1686
1666
  }
1687
1667
  }
1688
1668
  });
1689
- const normalizedOptions = normalizeRdpConnectionConfig(options);
1690
1669
  this.options = {
1691
1670
  port: 3389,
1692
1671
  securityProtocol: 'auto',
1693
1672
  ignoreCertificate: false,
1694
- ...normalizedOptions
1673
+ ...options
1695
1674
  };
1696
1675
  this.backend = options.backend || createDefaultRDPBackendClient();
1697
1676
  }
@@ -1769,11 +1748,10 @@ function adaptComputerInitArgs(extracted) {
1769
1748
  if (!extracted || 0 === Object.keys(extracted).length) return;
1770
1749
  if (extracted.host) {
1771
1750
  const { displayId: _d, headless: _h, ...rdpFields } = extracted;
1772
- const host = normalizeRdpHost(extracted.host);
1773
1751
  return {
1774
1752
  mode: 'rdp',
1775
1753
  ...rdpFields,
1776
- host
1754
+ host: extracted.host
1777
1755
  };
1778
1756
  }
1779
1757
  return {
@@ -1789,15 +1767,15 @@ function shouldRetargetAgent(opts) {
1789
1767
  }
1790
1768
  function describeConnectTarget(opts) {
1791
1769
  if (opts?.mode === 'rdp') {
1792
- const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
1770
+ const portSuffix = opts.port ? `:${opts.port}` : '';
1793
1771
  const userSuffix = opts.username ? ` as ${opts.username}` : '';
1794
- return ` via RDP (${target}${userSuffix})`;
1772
+ return ` via RDP (${opts.host}${portSuffix}${userSuffix})`;
1795
1773
  }
1796
1774
  if (opts?.mode === 'local' && opts.displayId) return ` (Display: ${opts.displayId})`;
1797
1775
  return ' (Primary display)';
1798
1776
  }
1799
1777
  function getCliReportSessionTarget(opts) {
1800
- if (opts?.mode === 'rdp') return `rdp:${formatRdpHost(opts.host)}`;
1778
+ if (opts?.mode === 'rdp') return `rdp:${opts.host}`;
1801
1779
  if (opts?.mode === 'local' && opts.displayId) return opts.displayId;
1802
1780
  return 'primary';
1803
1781
  }
@@ -1915,7 +1893,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1915
1893
  const tools = new ComputerMidsceneTools();
1916
1894
  runToolsCLI(tools, 'midscene-computer', {
1917
1895
  stripPrefix: 'computer_',
1918
- version: "1.9.2-beta-20260608084200.0",
1896
+ version: "1.9.2-beta-20260608092543.0",
1919
1897
  extraCommands: createReportCliCommands()
1920
1898
  }).catch((e)=>{
1921
1899
  process.exit(reportCLIError(e));
package/dist/es/index.mjs CHANGED
@@ -642,7 +642,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
642
642
  }
643
643
  async healthCheck() {
644
644
  console.log('[HealthCheck] Starting health check...');
645
- console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608084200.0");
645
+ console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608092543.0");
646
646
  console.log('[HealthCheck] Taking screenshot...');
647
647
  const screenshotTimeout = 15000;
648
648
  let timeoutId;
@@ -1095,24 +1095,6 @@ function createPlatformActions() {
1095
1095
  })
1096
1096
  };
1097
1097
  }
1098
- function normalizeRdpHost(host) {
1099
- const trimmed = host.trim();
1100
- if (trimmed.length >= 2 && trimmed.startsWith('[') && trimmed.endsWith(']') && trimmed.includes(':')) return trimmed.slice(1, -1);
1101
- return trimmed;
1102
- }
1103
- function formatRdpHost(host) {
1104
- const normalizedHost = normalizeRdpHost(host);
1105
- return normalizedHost.includes(':') ? `[${normalizedHost}]` : normalizedHost;
1106
- }
1107
- function formatRdpServerAddress(host, port) {
1108
- return `${formatRdpHost(host)}:${port}`;
1109
- }
1110
- function normalizeRdpConnectionConfig(config) {
1111
- return {
1112
- ...config,
1113
- host: normalizeRdpHost(config.host)
1114
- };
1115
- }
1116
1098
  const platformBinaryMap = {
1117
1099
  darwin: {
1118
1100
  directory: 'darwin',
@@ -1210,7 +1192,7 @@ class HelperProcessRDPBackendClient {
1210
1192
  await this.ensureHelperStarted();
1211
1193
  const response = await this.send({
1212
1194
  type: 'connect',
1213
- config: normalizeRdpConnectionConfig(config)
1195
+ config
1214
1196
  });
1215
1197
  if ('connected' !== response.type) throw new Error(`Expected connected response, got ${response.type}`);
1216
1198
  this.connected = true;
@@ -1484,10 +1466,9 @@ const DEFAULT_SCROLL_STEP_AMOUNT = 120;
1484
1466
  class RDPDevice {
1485
1467
  describe() {
1486
1468
  const port = this.options.port || 3389;
1487
- const server = formatRdpServerAddress(this.options.host, port);
1488
1469
  const username = this.options.username ? ` as ${this.options.username}` : '';
1489
1470
  const session = this.connectionInfo?.sessionId ? ` [session ${this.connectionInfo.sessionId}]` : '';
1490
- return `RDP Device ${server}${username}${session}`;
1471
+ return `RDP Device ${this.options.host}:${port}${username}${session}`;
1491
1472
  }
1492
1473
  async connect() {
1493
1474
  this.throwIfDestroyed();
@@ -1527,11 +1508,10 @@ class RDPDevice {
1527
1508
  call: async ()=>{
1528
1509
  this.assertConnected();
1529
1510
  const size = await this.size();
1530
- const server = this.connectionInfo?.server || formatRdpServerAddress(this.options.host, this.options.port || 3389);
1531
1511
  return [
1532
1512
  {
1533
1513
  id: this.connectionInfo?.sessionId || this.options.host,
1534
- name: `RDP ${server} (${size.width}x${size.height})`,
1514
+ name: `RDP ${this.connectionInfo?.server || this.options.host} (${size.width}x${size.height})`,
1535
1515
  primary: true
1536
1516
  }
1537
1517
  ];
@@ -1729,12 +1709,11 @@ class RDPDevice {
1729
1709
  }
1730
1710
  }
1731
1711
  });
1732
- const normalizedOptions = normalizeRdpConnectionConfig(options);
1733
1712
  this.options = {
1734
1713
  port: 3389,
1735
1714
  securityProtocol: 'auto',
1736
1715
  ignoreCertificate: false,
1737
- ...normalizedOptions
1716
+ ...options
1738
1717
  };
1739
1718
  this.backend = options.backend || createDefaultRDPBackendClient();
1740
1719
  }
@@ -1812,11 +1791,10 @@ function adaptComputerInitArgs(extracted) {
1812
1791
  if (!extracted || 0 === Object.keys(extracted).length) return;
1813
1792
  if (extracted.host) {
1814
1793
  const { displayId: _d, headless: _h, ...rdpFields } = extracted;
1815
- const host = normalizeRdpHost(extracted.host);
1816
1794
  return {
1817
1795
  mode: 'rdp',
1818
1796
  ...rdpFields,
1819
- host
1797
+ host: extracted.host
1820
1798
  };
1821
1799
  }
1822
1800
  return {
@@ -1832,15 +1810,15 @@ function shouldRetargetAgent(opts) {
1832
1810
  }
1833
1811
  function describeConnectTarget(opts) {
1834
1812
  if (opts?.mode === 'rdp') {
1835
- const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
1813
+ const portSuffix = opts.port ? `:${opts.port}` : '';
1836
1814
  const userSuffix = opts.username ? ` as ${opts.username}` : '';
1837
- return ` via RDP (${target}${userSuffix})`;
1815
+ return ` via RDP (${opts.host}${portSuffix}${userSuffix})`;
1838
1816
  }
1839
1817
  if (opts?.mode === 'local' && opts.displayId) return ` (Display: ${opts.displayId})`;
1840
1818
  return ' (Primary display)';
1841
1819
  }
1842
1820
  function getCliReportSessionTarget(opts) {
1843
- if (opts?.mode === 'rdp') return `rdp:${formatRdpHost(opts.host)}`;
1821
+ if (opts?.mode === 'rdp') return `rdp:${opts.host}`;
1844
1822
  if (opts?.mode === 'local' && opts.displayId) return opts.displayId;
1845
1823
  return 'primary';
1846
1824
  }
@@ -1956,7 +1934,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
1956
1934
  }
1957
1935
  }
1958
1936
  function version() {
1959
- const currentVersion = "1.9.2-beta-20260608084200.0";
1937
+ const currentVersion = "1.9.2-beta-20260608092543.0";
1960
1938
  console.log(`@midscene/computer v${currentVersion}`);
1961
1939
  return currentVersion;
1962
1940
  }
@@ -642,7 +642,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
642
642
  }
643
643
  async healthCheck() {
644
644
  console.log('[HealthCheck] Starting health check...');
645
- console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608084200.0");
645
+ console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608092543.0");
646
646
  console.log('[HealthCheck] Taking screenshot...');
647
647
  const screenshotTimeout = 15000;
648
648
  let timeoutId;
@@ -1095,24 +1095,6 @@ function createPlatformActions() {
1095
1095
  })
1096
1096
  };
1097
1097
  }
1098
- function normalizeRdpHost(host) {
1099
- const trimmed = host.trim();
1100
- if (trimmed.length >= 2 && trimmed.startsWith('[') && trimmed.endsWith(']') && trimmed.includes(':')) return trimmed.slice(1, -1);
1101
- return trimmed;
1102
- }
1103
- function formatRdpHost(host) {
1104
- const normalizedHost = normalizeRdpHost(host);
1105
- return normalizedHost.includes(':') ? `[${normalizedHost}]` : normalizedHost;
1106
- }
1107
- function formatRdpServerAddress(host, port) {
1108
- return `${formatRdpHost(host)}:${port}`;
1109
- }
1110
- function normalizeRdpConnectionConfig(config) {
1111
- return {
1112
- ...config,
1113
- host: normalizeRdpHost(config.host)
1114
- };
1115
- }
1116
1098
  const platformBinaryMap = {
1117
1099
  darwin: {
1118
1100
  directory: 'darwin',
@@ -1167,7 +1149,7 @@ class HelperProcessRDPBackendClient {
1167
1149
  await this.ensureHelperStarted();
1168
1150
  const response = await this.send({
1169
1151
  type: 'connect',
1170
- config: normalizeRdpConnectionConfig(config)
1152
+ config
1171
1153
  });
1172
1154
  if ('connected' !== response.type) throw new Error(`Expected connected response, got ${response.type}`);
1173
1155
  this.connected = true;
@@ -1441,10 +1423,9 @@ const DEFAULT_SCROLL_STEP_AMOUNT = 120;
1441
1423
  class RDPDevice {
1442
1424
  describe() {
1443
1425
  const port = this.options.port || 3389;
1444
- const server = formatRdpServerAddress(this.options.host, port);
1445
1426
  const username = this.options.username ? ` as ${this.options.username}` : '';
1446
1427
  const session = this.connectionInfo?.sessionId ? ` [session ${this.connectionInfo.sessionId}]` : '';
1447
- return `RDP Device ${server}${username}${session}`;
1428
+ return `RDP Device ${this.options.host}:${port}${username}${session}`;
1448
1429
  }
1449
1430
  async connect() {
1450
1431
  this.throwIfDestroyed();
@@ -1484,11 +1465,10 @@ class RDPDevice {
1484
1465
  call: async ()=>{
1485
1466
  this.assertConnected();
1486
1467
  const size = await this.size();
1487
- const server = this.connectionInfo?.server || formatRdpServerAddress(this.options.host, this.options.port || 3389);
1488
1468
  return [
1489
1469
  {
1490
1470
  id: this.connectionInfo?.sessionId || this.options.host,
1491
- name: `RDP ${server} (${size.width}x${size.height})`,
1471
+ name: `RDP ${this.connectionInfo?.server || this.options.host} (${size.width}x${size.height})`,
1492
1472
  primary: true
1493
1473
  }
1494
1474
  ];
@@ -1686,12 +1666,11 @@ class RDPDevice {
1686
1666
  }
1687
1667
  }
1688
1668
  });
1689
- const normalizedOptions = normalizeRdpConnectionConfig(options);
1690
1669
  this.options = {
1691
1670
  port: 3389,
1692
1671
  securityProtocol: 'auto',
1693
1672
  ignoreCertificate: false,
1694
- ...normalizedOptions
1673
+ ...options
1695
1674
  };
1696
1675
  this.backend = options.backend || createDefaultRDPBackendClient();
1697
1676
  }
@@ -1769,11 +1748,10 @@ function adaptComputerInitArgs(extracted) {
1769
1748
  if (!extracted || 0 === Object.keys(extracted).length) return;
1770
1749
  if (extracted.host) {
1771
1750
  const { displayId: _d, headless: _h, ...rdpFields } = extracted;
1772
- const host = normalizeRdpHost(extracted.host);
1773
1751
  return {
1774
1752
  mode: 'rdp',
1775
1753
  ...rdpFields,
1776
- host
1754
+ host: extracted.host
1777
1755
  };
1778
1756
  }
1779
1757
  return {
@@ -1789,15 +1767,15 @@ function shouldRetargetAgent(opts) {
1789
1767
  }
1790
1768
  function describeConnectTarget(opts) {
1791
1769
  if (opts?.mode === 'rdp') {
1792
- const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
1770
+ const portSuffix = opts.port ? `:${opts.port}` : '';
1793
1771
  const userSuffix = opts.username ? ` as ${opts.username}` : '';
1794
- return ` via RDP (${target}${userSuffix})`;
1772
+ return ` via RDP (${opts.host}${portSuffix}${userSuffix})`;
1795
1773
  }
1796
1774
  if (opts?.mode === 'local' && opts.displayId) return ` (Display: ${opts.displayId})`;
1797
1775
  return ' (Primary display)';
1798
1776
  }
1799
1777
  function getCliReportSessionTarget(opts) {
1800
- if (opts?.mode === 'rdp') return `rdp:${formatRdpHost(opts.host)}`;
1778
+ if (opts?.mode === 'rdp') return `rdp:${opts.host}`;
1801
1779
  if (opts?.mode === 'local' && opts.displayId) return opts.displayId;
1802
1780
  return 'primary';
1803
1781
  }
@@ -1919,7 +1897,7 @@ class ComputerMCPServer extends BaseMCPServer {
1919
1897
  constructor(toolsManager){
1920
1898
  super({
1921
1899
  name: '@midscene/computer-mcp',
1922
- version: "1.9.2-beta-20260608084200.0",
1900
+ version: "1.9.2-beta-20260608092543.0",
1923
1901
  description: 'Control the computer desktop using natural language commands'
1924
1902
  }, toolsManager);
1925
1903
  }
package/dist/lib/cli.js CHANGED
@@ -668,7 +668,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
668
668
  }
669
669
  async healthCheck() {
670
670
  console.log('[HealthCheck] Starting health check...');
671
- console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608084200.0");
671
+ console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608092543.0");
672
672
  console.log('[HealthCheck] Taking screenshot...');
673
673
  const screenshotTimeout = 15000;
674
674
  let timeoutId;
@@ -1121,24 +1121,6 @@ function createPlatformActions() {
1121
1121
  })
1122
1122
  };
1123
1123
  }
1124
- function normalizeRdpHost(host) {
1125
- const trimmed = host.trim();
1126
- if (trimmed.length >= 2 && trimmed.startsWith('[') && trimmed.endsWith(']') && trimmed.includes(':')) return trimmed.slice(1, -1);
1127
- return trimmed;
1128
- }
1129
- function formatRdpHost(host) {
1130
- const normalizedHost = normalizeRdpHost(host);
1131
- return normalizedHost.includes(':') ? `[${normalizedHost}]` : normalizedHost;
1132
- }
1133
- function formatRdpServerAddress(host, port) {
1134
- return `${formatRdpHost(host)}:${port}`;
1135
- }
1136
- function normalizeRdpConnectionConfig(config) {
1137
- return {
1138
- ...config,
1139
- host: normalizeRdpHost(config.host)
1140
- };
1141
- }
1142
1124
  const external_node_events_namespaceObject = require("node:events");
1143
1125
  const external_node_readline_namespaceObject = require("node:readline");
1144
1126
  const platformBinaryMap = {
@@ -1194,7 +1176,7 @@ class HelperProcessRDPBackendClient {
1194
1176
  await this.ensureHelperStarted();
1195
1177
  const response = await this.send({
1196
1178
  type: 'connect',
1197
- config: normalizeRdpConnectionConfig(config)
1179
+ config
1198
1180
  });
1199
1181
  if ('connected' !== response.type) throw new Error(`Expected connected response, got ${response.type}`);
1200
1182
  this.connected = true;
@@ -1468,10 +1450,9 @@ const DEFAULT_SCROLL_STEP_AMOUNT = 120;
1468
1450
  class RDPDevice {
1469
1451
  describe() {
1470
1452
  const port = this.options.port || 3389;
1471
- const server = formatRdpServerAddress(this.options.host, port);
1472
1453
  const username = this.options.username ? ` as ${this.options.username}` : '';
1473
1454
  const session = this.connectionInfo?.sessionId ? ` [session ${this.connectionInfo.sessionId}]` : '';
1474
- return `RDP Device ${server}${username}${session}`;
1455
+ return `RDP Device ${this.options.host}:${port}${username}${session}`;
1475
1456
  }
1476
1457
  async connect() {
1477
1458
  this.throwIfDestroyed();
@@ -1511,11 +1492,10 @@ class RDPDevice {
1511
1492
  call: async ()=>{
1512
1493
  this.assertConnected();
1513
1494
  const size = await this.size();
1514
- const server = this.connectionInfo?.server || formatRdpServerAddress(this.options.host, this.options.port || 3389);
1515
1495
  return [
1516
1496
  {
1517
1497
  id: this.connectionInfo?.sessionId || this.options.host,
1518
- name: `RDP ${server} (${size.width}x${size.height})`,
1498
+ name: `RDP ${this.connectionInfo?.server || this.options.host} (${size.width}x${size.height})`,
1519
1499
  primary: true
1520
1500
  }
1521
1501
  ];
@@ -1713,12 +1693,11 @@ class RDPDevice {
1713
1693
  }
1714
1694
  }
1715
1695
  });
1716
- const normalizedOptions = normalizeRdpConnectionConfig(options);
1717
1696
  this.options = {
1718
1697
  port: 3389,
1719
1698
  securityProtocol: 'auto',
1720
1699
  ignoreCertificate: false,
1721
- ...normalizedOptions
1700
+ ...options
1722
1701
  };
1723
1702
  this.backend = options.backend || createDefaultRDPBackendClient();
1724
1703
  }
@@ -1796,11 +1775,10 @@ function adaptComputerInitArgs(extracted) {
1796
1775
  if (!extracted || 0 === Object.keys(extracted).length) return;
1797
1776
  if (extracted.host) {
1798
1777
  const { displayId: _d, headless: _h, ...rdpFields } = extracted;
1799
- const host = normalizeRdpHost(extracted.host);
1800
1778
  return {
1801
1779
  mode: 'rdp',
1802
1780
  ...rdpFields,
1803
- host
1781
+ host: extracted.host
1804
1782
  };
1805
1783
  }
1806
1784
  return {
@@ -1816,15 +1794,15 @@ function shouldRetargetAgent(opts) {
1816
1794
  }
1817
1795
  function describeConnectTarget(opts) {
1818
1796
  if (opts?.mode === 'rdp') {
1819
- const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
1797
+ const portSuffix = opts.port ? `:${opts.port}` : '';
1820
1798
  const userSuffix = opts.username ? ` as ${opts.username}` : '';
1821
- return ` via RDP (${target}${userSuffix})`;
1799
+ return ` via RDP (${opts.host}${portSuffix}${userSuffix})`;
1822
1800
  }
1823
1801
  if (opts?.mode === 'local' && opts.displayId) return ` (Display: ${opts.displayId})`;
1824
1802
  return ' (Primary display)';
1825
1803
  }
1826
1804
  function getCliReportSessionTarget(opts) {
1827
- if (opts?.mode === 'rdp') return `rdp:${formatRdpHost(opts.host)}`;
1805
+ if (opts?.mode === 'rdp') return `rdp:${opts.host}`;
1828
1806
  if (opts?.mode === 'local' && opts.displayId) return opts.displayId;
1829
1807
  return 'primary';
1830
1808
  }
@@ -1942,7 +1920,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
1942
1920
  const tools = new ComputerMidsceneTools();
1943
1921
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-computer', {
1944
1922
  stripPrefix: 'computer_',
1945
- version: "1.9.2-beta-20260608084200.0",
1923
+ version: "1.9.2-beta-20260608092543.0",
1946
1924
  extraCommands: (0, core_namespaceObject.createReportCliCommands)()
1947
1925
  }).catch((e)=>{
1948
1926
  process.exit((0, cli_namespaceObject.reportCLIError)(e));
package/dist/lib/index.js CHANGED
@@ -695,7 +695,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
695
695
  }
696
696
  async healthCheck() {
697
697
  console.log('[HealthCheck] Starting health check...');
698
- console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608084200.0");
698
+ console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608092543.0");
699
699
  console.log('[HealthCheck] Taking screenshot...');
700
700
  const screenshotTimeout = 15000;
701
701
  let timeoutId;
@@ -1149,24 +1149,6 @@ function createPlatformActions() {
1149
1149
  };
1150
1150
  }
1151
1151
  const agent_namespaceObject = require("@midscene/core/agent");
1152
- function normalizeRdpHost(host) {
1153
- const trimmed = host.trim();
1154
- if (trimmed.length >= 2 && trimmed.startsWith('[') && trimmed.endsWith(']') && trimmed.includes(':')) return trimmed.slice(1, -1);
1155
- return trimmed;
1156
- }
1157
- function formatRdpHost(host) {
1158
- const normalizedHost = normalizeRdpHost(host);
1159
- return normalizedHost.includes(':') ? `[${normalizedHost}]` : normalizedHost;
1160
- }
1161
- function formatRdpServerAddress(host, port) {
1162
- return `${formatRdpHost(host)}:${port}`;
1163
- }
1164
- function normalizeRdpConnectionConfig(config) {
1165
- return {
1166
- ...config,
1167
- host: normalizeRdpHost(config.host)
1168
- };
1169
- }
1170
1152
  const external_node_events_namespaceObject = require("node:events");
1171
1153
  const external_node_readline_namespaceObject = require("node:readline");
1172
1154
  const platformBinaryMap = {
@@ -1265,7 +1247,7 @@ class HelperProcessRDPBackendClient {
1265
1247
  await this.ensureHelperStarted();
1266
1248
  const response = await this.send({
1267
1249
  type: 'connect',
1268
- config: normalizeRdpConnectionConfig(config)
1250
+ config
1269
1251
  });
1270
1252
  if ('connected' !== response.type) throw new Error(`Expected connected response, got ${response.type}`);
1271
1253
  this.connected = true;
@@ -1539,10 +1521,9 @@ const DEFAULT_SCROLL_STEP_AMOUNT = 120;
1539
1521
  class RDPDevice {
1540
1522
  describe() {
1541
1523
  const port = this.options.port || 3389;
1542
- const server = formatRdpServerAddress(this.options.host, port);
1543
1524
  const username = this.options.username ? ` as ${this.options.username}` : '';
1544
1525
  const session = this.connectionInfo?.sessionId ? ` [session ${this.connectionInfo.sessionId}]` : '';
1545
- return `RDP Device ${server}${username}${session}`;
1526
+ return `RDP Device ${this.options.host}:${port}${username}${session}`;
1546
1527
  }
1547
1528
  async connect() {
1548
1529
  this.throwIfDestroyed();
@@ -1582,11 +1563,10 @@ class RDPDevice {
1582
1563
  call: async ()=>{
1583
1564
  this.assertConnected();
1584
1565
  const size = await this.size();
1585
- const server = this.connectionInfo?.server || formatRdpServerAddress(this.options.host, this.options.port || 3389);
1586
1566
  return [
1587
1567
  {
1588
1568
  id: this.connectionInfo?.sessionId || this.options.host,
1589
- name: `RDP ${server} (${size.width}x${size.height})`,
1569
+ name: `RDP ${this.connectionInfo?.server || this.options.host} (${size.width}x${size.height})`,
1590
1570
  primary: true
1591
1571
  }
1592
1572
  ];
@@ -1784,12 +1764,11 @@ class RDPDevice {
1784
1764
  }
1785
1765
  }
1786
1766
  });
1787
- const normalizedOptions = normalizeRdpConnectionConfig(options);
1788
1767
  this.options = {
1789
1768
  port: 3389,
1790
1769
  securityProtocol: 'auto',
1791
1770
  ignoreCertificate: false,
1792
- ...normalizedOptions
1771
+ ...options
1793
1772
  };
1794
1773
  this.backend = options.backend || createDefaultRDPBackendClient();
1795
1774
  }
@@ -1869,11 +1848,10 @@ function adaptComputerInitArgs(extracted) {
1869
1848
  if (!extracted || 0 === Object.keys(extracted).length) return;
1870
1849
  if (extracted.host) {
1871
1850
  const { displayId: _d, headless: _h, ...rdpFields } = extracted;
1872
- const host = normalizeRdpHost(extracted.host);
1873
1851
  return {
1874
1852
  mode: 'rdp',
1875
1853
  ...rdpFields,
1876
- host
1854
+ host: extracted.host
1877
1855
  };
1878
1856
  }
1879
1857
  return {
@@ -1889,15 +1867,15 @@ function shouldRetargetAgent(opts) {
1889
1867
  }
1890
1868
  function describeConnectTarget(opts) {
1891
1869
  if (opts?.mode === 'rdp') {
1892
- const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
1870
+ const portSuffix = opts.port ? `:${opts.port}` : '';
1893
1871
  const userSuffix = opts.username ? ` as ${opts.username}` : '';
1894
- return ` via RDP (${target}${userSuffix})`;
1872
+ return ` via RDP (${opts.host}${portSuffix}${userSuffix})`;
1895
1873
  }
1896
1874
  if (opts?.mode === 'local' && opts.displayId) return ` (Display: ${opts.displayId})`;
1897
1875
  return ' (Primary display)';
1898
1876
  }
1899
1877
  function getCliReportSessionTarget(opts) {
1900
- if (opts?.mode === 'rdp') return `rdp:${formatRdpHost(opts.host)}`;
1878
+ if (opts?.mode === 'rdp') return `rdp:${opts.host}`;
1901
1879
  if (opts?.mode === 'local' && opts.displayId) return opts.displayId;
1902
1880
  return 'primary';
1903
1881
  }
@@ -2014,7 +1992,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
2014
1992
  }
2015
1993
  const env_namespaceObject = require("@midscene/shared/env");
2016
1994
  function version() {
2017
- const currentVersion = "1.9.2-beta-20260608084200.0";
1995
+ const currentVersion = "1.9.2-beta-20260608092543.0";
2018
1996
  console.log(`@midscene/computer v${currentVersion}`);
2019
1997
  return currentVersion;
2020
1998
  }
@@ -682,7 +682,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
682
682
  }
683
683
  async healthCheck() {
684
684
  console.log('[HealthCheck] Starting health check...');
685
- console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608084200.0");
685
+ console.log("[HealthCheck] @midscene/computer v1.9.2-beta-20260608092543.0");
686
686
  console.log('[HealthCheck] Taking screenshot...');
687
687
  const screenshotTimeout = 15000;
688
688
  let timeoutId;
@@ -1135,24 +1135,6 @@ function createPlatformActions() {
1135
1135
  })
1136
1136
  };
1137
1137
  }
1138
- function normalizeRdpHost(host) {
1139
- const trimmed = host.trim();
1140
- if (trimmed.length >= 2 && trimmed.startsWith('[') && trimmed.endsWith(']') && trimmed.includes(':')) return trimmed.slice(1, -1);
1141
- return trimmed;
1142
- }
1143
- function formatRdpHost(host) {
1144
- const normalizedHost = normalizeRdpHost(host);
1145
- return normalizedHost.includes(':') ? `[${normalizedHost}]` : normalizedHost;
1146
- }
1147
- function formatRdpServerAddress(host, port) {
1148
- return `${formatRdpHost(host)}:${port}`;
1149
- }
1150
- function normalizeRdpConnectionConfig(config) {
1151
- return {
1152
- ...config,
1153
- host: normalizeRdpHost(config.host)
1154
- };
1155
- }
1156
1138
  const external_node_events_namespaceObject = require("node:events");
1157
1139
  const external_node_readline_namespaceObject = require("node:readline");
1158
1140
  const platformBinaryMap = {
@@ -1208,7 +1190,7 @@ class HelperProcessRDPBackendClient {
1208
1190
  await this.ensureHelperStarted();
1209
1191
  const response = await this.send({
1210
1192
  type: 'connect',
1211
- config: normalizeRdpConnectionConfig(config)
1193
+ config
1212
1194
  });
1213
1195
  if ('connected' !== response.type) throw new Error(`Expected connected response, got ${response.type}`);
1214
1196
  this.connected = true;
@@ -1482,10 +1464,9 @@ const DEFAULT_SCROLL_STEP_AMOUNT = 120;
1482
1464
  class RDPDevice {
1483
1465
  describe() {
1484
1466
  const port = this.options.port || 3389;
1485
- const server = formatRdpServerAddress(this.options.host, port);
1486
1467
  const username = this.options.username ? ` as ${this.options.username}` : '';
1487
1468
  const session = this.connectionInfo?.sessionId ? ` [session ${this.connectionInfo.sessionId}]` : '';
1488
- return `RDP Device ${server}${username}${session}`;
1469
+ return `RDP Device ${this.options.host}:${port}${username}${session}`;
1489
1470
  }
1490
1471
  async connect() {
1491
1472
  this.throwIfDestroyed();
@@ -1525,11 +1506,10 @@ class RDPDevice {
1525
1506
  call: async ()=>{
1526
1507
  this.assertConnected();
1527
1508
  const size = await this.size();
1528
- const server = this.connectionInfo?.server || formatRdpServerAddress(this.options.host, this.options.port || 3389);
1529
1509
  return [
1530
1510
  {
1531
1511
  id: this.connectionInfo?.sessionId || this.options.host,
1532
- name: `RDP ${server} (${size.width}x${size.height})`,
1512
+ name: `RDP ${this.connectionInfo?.server || this.options.host} (${size.width}x${size.height})`,
1533
1513
  primary: true
1534
1514
  }
1535
1515
  ];
@@ -1727,12 +1707,11 @@ class RDPDevice {
1727
1707
  }
1728
1708
  }
1729
1709
  });
1730
- const normalizedOptions = normalizeRdpConnectionConfig(options);
1731
1710
  this.options = {
1732
1711
  port: 3389,
1733
1712
  securityProtocol: 'auto',
1734
1713
  ignoreCertificate: false,
1735
- ...normalizedOptions
1714
+ ...options
1736
1715
  };
1737
1716
  this.backend = options.backend || createDefaultRDPBackendClient();
1738
1717
  }
@@ -1812,11 +1791,10 @@ function adaptComputerInitArgs(extracted) {
1812
1791
  if (!extracted || 0 === Object.keys(extracted).length) return;
1813
1792
  if (extracted.host) {
1814
1793
  const { displayId: _d, headless: _h, ...rdpFields } = extracted;
1815
- const host = normalizeRdpHost(extracted.host);
1816
1794
  return {
1817
1795
  mode: 'rdp',
1818
1796
  ...rdpFields,
1819
- host
1797
+ host: extracted.host
1820
1798
  };
1821
1799
  }
1822
1800
  return {
@@ -1832,15 +1810,15 @@ function shouldRetargetAgent(opts) {
1832
1810
  }
1833
1811
  function describeConnectTarget(opts) {
1834
1812
  if (opts?.mode === 'rdp') {
1835
- const target = opts.port ? formatRdpServerAddress(opts.host, opts.port) : formatRdpHost(opts.host);
1813
+ const portSuffix = opts.port ? `:${opts.port}` : '';
1836
1814
  const userSuffix = opts.username ? ` as ${opts.username}` : '';
1837
- return ` via RDP (${target}${userSuffix})`;
1815
+ return ` via RDP (${opts.host}${portSuffix}${userSuffix})`;
1838
1816
  }
1839
1817
  if (opts?.mode === 'local' && opts.displayId) return ` (Display: ${opts.displayId})`;
1840
1818
  return ' (Primary display)';
1841
1819
  }
1842
1820
  function getCliReportSessionTarget(opts) {
1843
- if (opts?.mode === 'rdp') return `rdp:${formatRdpHost(opts.host)}`;
1821
+ if (opts?.mode === 'rdp') return `rdp:${opts.host}`;
1844
1822
  if (opts?.mode === 'local' && opts.displayId) return opts.displayId;
1845
1823
  return 'primary';
1846
1824
  }
@@ -1962,7 +1940,7 @@ class ComputerMCPServer extends mcp_namespaceObject.BaseMCPServer {
1962
1940
  constructor(toolsManager){
1963
1941
  super({
1964
1942
  name: '@midscene/computer-mcp',
1965
- version: "1.9.2-beta-20260608084200.0",
1943
+ version: "1.9.2-beta-20260608092543.0",
1966
1944
  description: 'Control the computer desktop using natural language commands'
1967
1945
  }, toolsManager);
1968
1946
  }
@@ -12,14 +12,6 @@ namespace midscene::rdp {
12
12
 
13
13
  namespace {
14
14
 
15
- std::string NormalizeRdpHost(std::string_view host) {
16
- if (host.size() >= 2 && host.front() == '[' && host.back() == ']' &&
17
- host.find(':') != std::string_view::npos) {
18
- return std::string(host.substr(1, host.size() - 2));
19
- }
20
- return std::string(host);
21
- }
22
-
23
15
  ConnectionConfig ParseConnectionConfig(const JsonObject& payload) {
24
16
  const JsonObject* config = GetObjectField(payload, "config");
25
17
  if (!config) {
@@ -32,7 +24,7 @@ ConnectionConfig ParseConnectionConfig(const JsonObject& payload) {
32
24
  }
33
25
 
34
26
  ConnectionConfig parsed;
35
- parsed.host = NormalizeRdpHost(*host);
27
+ parsed.host = *host;
36
28
  if (const auto port = GetIntField(*config, "port"); port.has_value()) {
37
29
  parsed.port = static_cast<uint16_t>(*port);
38
30
  }
@@ -186,18 +186,6 @@ std::string GenerateSessionId() {
186
186
  return session_id.str();
187
187
  }
188
188
 
189
- std::string FormatServerAddress(std::string_view host, UINT32 port) {
190
- std::ostringstream server;
191
- if (host.find(':') != std::string_view::npos &&
192
- !(host.size() >= 2 && host.front() == '[' && host.back() == ']')) {
193
- server << '[' << host << ']';
194
- } else {
195
- server << host;
196
- }
197
- server << ':' << port;
198
- return server.str();
199
- }
200
-
201
189
  DWORD VerifyCertificateEx(freerdp* instance,
202
190
  const char* host,
203
191
  UINT16 port,
@@ -600,7 +588,9 @@ ConnectionInfo FreeRdpSessionTransport::Connect(const ConnectionConfig& config)
600
588
  const char* host = freerdp_settings_get_server_name(settings);
601
589
  const UINT32 port =
602
590
  freerdp_settings_get_uint32(settings, FreeRDP_ServerPort);
603
- info.server = FormatServerAddress(host ? host : "", port);
591
+ std::ostringstream server;
592
+ server << (host ? host : "") << ":" << port;
593
+ info.server = server.str();
604
594
  if (instance_->context && instance_->context->gdi) {
605
595
  info.size.width = instance_->context->gdi->width;
606
596
  info.size.height = instance_->context->gdi->height;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/computer",
3
- "version": "1.9.2-beta-20260608084200.0",
3
+ "version": "1.9.2-beta-20260608092543.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/shared": "1.9.2-beta-20260608084200.0",
42
- "@midscene/core": "1.9.2-beta-20260608084200.0"
41
+ "@midscene/core": "1.9.2-beta-20260608092543.0",
42
+ "@midscene/shared": "1.9.2-beta-20260608092543.0"
43
43
  },
44
44
  "optionalDependencies": {
45
45
  "node-mac-permissions": "2.5.0"