@midscene/computer 1.8.0 → 1.8.1-beta-20260513084557.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 +734 -61
- package/dist/es/index.mjs +73 -12
- package/dist/es/mcp-server.mjs +734 -61
- package/dist/lib/cli.js +688 -16
- package/dist/lib/index.js +73 -12
- package/dist/lib/mcp-server.js +688 -16
- package/dist/types/index.d.ts +16 -1
- package/dist/types/mcp-server.d.ts +16 -1
- package/package.json +3 -3
package/dist/es/index.mjs
CHANGED
|
@@ -411,7 +411,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
411
411
|
}
|
|
412
412
|
async healthCheck() {
|
|
413
413
|
console.log('[HealthCheck] Starting health check...');
|
|
414
|
-
console.log("[HealthCheck] @midscene/computer v1.8.0");
|
|
414
|
+
console.log("[HealthCheck] @midscene/computer v1.8.1-beta-20260513084557.0");
|
|
415
415
|
console.log('[HealthCheck] Taking screenshot...');
|
|
416
416
|
const screenshotTimeout = 15000;
|
|
417
417
|
let timeoutId;
|
|
@@ -1495,10 +1495,61 @@ function mcp_tools_define_property(obj, key, value) {
|
|
|
1495
1495
|
return obj;
|
|
1496
1496
|
}
|
|
1497
1497
|
const mcp_tools_debug = getDebug('mcp:computer-tools');
|
|
1498
|
+
const RDP_SECURITY_PROTOCOLS = [
|
|
1499
|
+
'auto',
|
|
1500
|
+
'tls',
|
|
1501
|
+
'nla',
|
|
1502
|
+
'rdp'
|
|
1503
|
+
];
|
|
1498
1504
|
const computerInitArgShape = {
|
|
1499
|
-
displayId: z.string().optional().describe('Display ID (from computer_list_displays)'),
|
|
1500
|
-
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux only)')
|
|
1505
|
+
displayId: z.string().optional().describe('Display ID for local mode (from computer_list_displays). Ignored when host is set.'),
|
|
1506
|
+
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux local mode only). Ignored when host is set.'),
|
|
1507
|
+
host: z.string().optional().describe('RDP host (FQDN or IP). Set this to switch into RDP mode.'),
|
|
1508
|
+
port: z.number().optional().describe('RDP port (default 3389). Requires host.'),
|
|
1509
|
+
username: z.string().optional().describe('RDP username. Requires host.'),
|
|
1510
|
+
password: z.string().optional().describe('RDP password. Requires host. Prefer setting via environment or a secrets manager.'),
|
|
1511
|
+
domain: z.string().optional().describe('RDP domain. Requires host.'),
|
|
1512
|
+
adminSession: z.boolean().optional().describe('Attach to the RDP admin/console session. Requires host.'),
|
|
1513
|
+
ignoreCertificate: z.boolean().optional().describe('Skip TLS certificate validation. Requires host.'),
|
|
1514
|
+
securityProtocol: z["enum"](RDP_SECURITY_PROTOCOLS).optional().describe('RDP security protocol negotiation (default auto). Requires host.'),
|
|
1515
|
+
desktopWidth: z.number().optional().describe('Remote desktop width in pixels. Requires host.'),
|
|
1516
|
+
desktopHeight: z.number().optional().describe('Remote desktop height in pixels. Requires host.')
|
|
1501
1517
|
};
|
|
1518
|
+
function adaptComputerInitArgs(extracted) {
|
|
1519
|
+
if (!extracted || 0 === Object.keys(extracted).length) return;
|
|
1520
|
+
if (extracted.host) {
|
|
1521
|
+
const { displayId: _d, headless: _h, ...rdpFields } = extracted;
|
|
1522
|
+
return {
|
|
1523
|
+
mode: 'rdp',
|
|
1524
|
+
...rdpFields,
|
|
1525
|
+
host: extracted.host
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
return {
|
|
1529
|
+
mode: 'local',
|
|
1530
|
+
displayId: extracted.displayId,
|
|
1531
|
+
headless: extracted.headless
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
function shouldRetargetAgent(opts) {
|
|
1535
|
+
if (!opts) return false;
|
|
1536
|
+
if ('rdp' === opts.mode) return true;
|
|
1537
|
+
return void 0 !== opts.displayId || void 0 !== opts.headless;
|
|
1538
|
+
}
|
|
1539
|
+
function describeConnectTarget(opts) {
|
|
1540
|
+
if (opts?.mode === 'rdp') {
|
|
1541
|
+
const portSuffix = opts.port ? `:${opts.port}` : '';
|
|
1542
|
+
const userSuffix = opts.username ? ` as ${opts.username}` : '';
|
|
1543
|
+
return ` via RDP (${opts.host}${portSuffix}${userSuffix})`;
|
|
1544
|
+
}
|
|
1545
|
+
if (opts?.mode === 'local' && opts.displayId) return ` (Display: ${opts.displayId})`;
|
|
1546
|
+
return ' (Primary display)';
|
|
1547
|
+
}
|
|
1548
|
+
function getCliReportSessionTarget(opts) {
|
|
1549
|
+
if (opts?.mode === 'rdp') return `rdp:${opts.host}`;
|
|
1550
|
+
if (opts?.mode === 'local' && opts.displayId) return opts.displayId;
|
|
1551
|
+
return 'primary';
|
|
1552
|
+
}
|
|
1502
1553
|
class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
1503
1554
|
getCliReportSessionName() {
|
|
1504
1555
|
return 'midscene-computer';
|
|
@@ -1507,9 +1558,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
1507
1558
|
return new ComputerDevice({});
|
|
1508
1559
|
}
|
|
1509
1560
|
async ensureAgent(opts) {
|
|
1510
|
-
|
|
1511
|
-
const headless = opts?.headless;
|
|
1512
|
-
if (this.agent && (void 0 !== displayId || void 0 !== headless)) {
|
|
1561
|
+
if (this.agent && shouldRetargetAgent(opts)) {
|
|
1513
1562
|
try {
|
|
1514
1563
|
await this.agent.destroy?.();
|
|
1515
1564
|
} catch (error) {
|
|
@@ -1518,8 +1567,20 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
1518
1567
|
this.agent = void 0;
|
|
1519
1568
|
}
|
|
1520
1569
|
if (this.agent) return this.agent;
|
|
1521
|
-
mcp_tools_debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
1522
1570
|
const reportOptions = this.readCliReportAgentOptions();
|
|
1571
|
+
if (opts?.mode === 'rdp') {
|
|
1572
|
+
mcp_tools_debug('Creating RDP Computer agent for host:', opts.host);
|
|
1573
|
+
const { mode: _mode, ...rdpFields } = opts;
|
|
1574
|
+
const agent = await agentForRDPComputer({
|
|
1575
|
+
...rdpFields,
|
|
1576
|
+
...reportOptions ?? {}
|
|
1577
|
+
});
|
|
1578
|
+
this.agent = agent;
|
|
1579
|
+
return agent;
|
|
1580
|
+
}
|
|
1581
|
+
const displayId = opts?.mode === 'local' ? opts.displayId : void 0;
|
|
1582
|
+
const headless = opts?.mode === 'local' ? opts.headless : void 0;
|
|
1583
|
+
mcp_tools_debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
1523
1584
|
const agentOpts = {
|
|
1524
1585
|
...displayId ? {
|
|
1525
1586
|
displayId
|
|
@@ -1537,12 +1598,12 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
1537
1598
|
return [
|
|
1538
1599
|
{
|
|
1539
1600
|
name: 'computer_connect',
|
|
1540
|
-
description:
|
|
1601
|
+
description: "Connect to a computer desktop. Default (local) mode controls the local machine; pass displayId to target a specific local display (see computer_list_displays). Pass host to switch to RDP mode and connect to a remote Windows desktop via the RDP helper binary. RDP-related options (port/username/password/domain/securityProtocol/ignoreCertificate/adminSession/desktopWidth/desktopHeight) only take effect when host is set.",
|
|
1541
1602
|
schema: this.getAgentInitArgSchema(),
|
|
1542
1603
|
cli: this.getAgentInitArgCliMetadata(),
|
|
1543
1604
|
handler: async (args)=>{
|
|
1544
1605
|
const initArgs = this.extractAgentInitParam(args);
|
|
1545
|
-
const reportSession = this.createNewCliReportSession(initArgs
|
|
1606
|
+
const reportSession = this.createNewCliReportSession(getCliReportSessionTarget(initArgs));
|
|
1546
1607
|
this.commitCliReportSession(reportSession);
|
|
1547
1608
|
if (this.agent) {
|
|
1548
1609
|
try {
|
|
@@ -1558,7 +1619,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
1558
1619
|
content: [
|
|
1559
1620
|
{
|
|
1560
1621
|
type: 'text',
|
|
1561
|
-
text: `Connected to computer${
|
|
1622
|
+
text: `Connected to computer${describeConnectTarget(initArgs)}`
|
|
1562
1623
|
},
|
|
1563
1624
|
...this.buildScreenshotContent(screenshot)
|
|
1564
1625
|
]
|
|
@@ -1596,12 +1657,12 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
1596
1657
|
cli: {
|
|
1597
1658
|
preferBareKeys: true
|
|
1598
1659
|
},
|
|
1599
|
-
adapt: (extracted)=>extracted
|
|
1660
|
+
adapt: (extracted)=>adaptComputerInitArgs(extracted)
|
|
1600
1661
|
});
|
|
1601
1662
|
}
|
|
1602
1663
|
}
|
|
1603
1664
|
function version() {
|
|
1604
|
-
const currentVersion = "1.8.0";
|
|
1665
|
+
const currentVersion = "1.8.1-beta-20260513084557.0";
|
|
1605
1666
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
1606
1667
|
return currentVersion;
|
|
1607
1668
|
}
|