@midscene/computer 1.8.4 → 1.8.5-beta-20260522100653.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 +22 -6
- package/dist/es/index.mjs +22 -6
- package/dist/es/mcp-server.mjs +22 -6
- package/dist/lib/cli.js +22 -6
- package/dist/lib/index.js +22 -6
- package/dist/lib/mcp-server.js +22 -6
- package/dist/types/index.d.ts +1 -0
- package/dist/types/mcp-server.d.ts +1 -0
- package/package.json +3 -3
package/dist/es/cli.mjs
CHANGED
|
@@ -107,7 +107,7 @@ const EDGE_SCROLL_TOTAL_PX = 50000;
|
|
|
107
107
|
const EDGE_SCROLL_STEPS = 400;
|
|
108
108
|
const PHASED_PIXELS_PER_STEP = 30;
|
|
109
109
|
const PHASED_MIN_STEPS = 10;
|
|
110
|
-
const
|
|
110
|
+
const DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
111
111
|
const EDGE_SCROLL_SPEC = {
|
|
112
112
|
scrollToTop: {
|
|
113
113
|
direction: 'up',
|
|
@@ -402,7 +402,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
402
402
|
}
|
|
403
403
|
async healthCheck() {
|
|
404
404
|
console.log('[HealthCheck] Starting health check...');
|
|
405
|
-
console.log("[HealthCheck] @midscene/computer v1.8.
|
|
405
|
+
console.log("[HealthCheck] @midscene/computer v1.8.5-beta-20260522100653.0");
|
|
406
406
|
console.log('[HealthCheck] Taking screenshot...');
|
|
407
407
|
const screenshotTimeout = 15000;
|
|
408
408
|
let timeoutId;
|
|
@@ -601,15 +601,23 @@ Original error: ${lastRawMessage}`);
|
|
|
601
601
|
return;
|
|
602
602
|
}
|
|
603
603
|
if ('singleAction' === scrollType || !scrollType) {
|
|
604
|
-
const distance = param?.distance || 500;
|
|
605
604
|
const direction = param?.direction || 'down';
|
|
606
605
|
const isKnownDirection = 'up' === direction || 'down' === direction || 'left' === direction || 'right' === direction;
|
|
606
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
607
|
+
let distance = param?.distance ?? void 0;
|
|
608
|
+
let screenSize;
|
|
609
|
+
if (!distance) {
|
|
610
|
+
screenSize = await this.size();
|
|
611
|
+
const base = isHorizontal ? screenSize.width : screenSize.height;
|
|
612
|
+
distance = Math.max(1, Math.round(base * DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
613
|
+
}
|
|
607
614
|
if (isKnownDirection) {
|
|
608
615
|
const steps = Math.max(PHASED_MIN_STEPS, Math.round(distance / PHASED_PIXELS_PER_STEP));
|
|
609
616
|
if (runPhasedScroll(direction, distance, steps)) return void await sleep(SCROLL_COMPLETE_DELAY);
|
|
610
617
|
}
|
|
611
618
|
if (this.useAppleScript && ('up' === direction || 'down' === direction)) {
|
|
612
|
-
|
|
619
|
+
if (!screenSize) screenSize = await this.size();
|
|
620
|
+
const pages = Math.max(1, Math.round(distance / screenSize.height));
|
|
613
621
|
const key = 'up' === direction ? 'pageup' : 'pagedown';
|
|
614
622
|
for(let i = 0; i < pages; i++){
|
|
615
623
|
sendKeyViaAppleScript(key);
|
|
@@ -1105,6 +1113,7 @@ const device_INPUT_CLEAR_DELAY = 150;
|
|
|
1105
1113
|
const device_SCROLL_STEP_DELAY = 100;
|
|
1106
1114
|
const device_SCROLL_COMPLETE_DELAY = 500;
|
|
1107
1115
|
const DEFAULT_SCROLL_DISTANCE = 480;
|
|
1116
|
+
const device_DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
1108
1117
|
const device_EDGE_SCROLL_STEPS = 10;
|
|
1109
1118
|
const DEFAULT_SCROLL_STEP_AMOUNT = 120;
|
|
1110
1119
|
class RDPDevice {
|
|
@@ -1200,6 +1209,13 @@ class RDPDevice {
|
|
|
1200
1209
|
throw new Error(`Unsupported scroll type: ${scrollType}`);
|
|
1201
1210
|
}
|
|
1202
1211
|
}
|
|
1212
|
+
defaultScrollDistance(direction) {
|
|
1213
|
+
const size = this.connectionInfo?.size;
|
|
1214
|
+
if (!size) return DEFAULT_SCROLL_DISTANCE;
|
|
1215
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
1216
|
+
const base = isHorizontal ? size.width : size.height;
|
|
1217
|
+
return Math.max(1, Math.round(base * device_DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
1218
|
+
}
|
|
1203
1219
|
async movePointer(targetX, targetY, options) {
|
|
1204
1220
|
this.assertConnected();
|
|
1205
1221
|
const start = this.cursorPosition || [
|
|
@@ -1340,7 +1356,7 @@ class RDPDevice {
|
|
|
1340
1356
|
await sleep(device_SCROLL_COMPLETE_DELAY);
|
|
1341
1357
|
return;
|
|
1342
1358
|
}
|
|
1343
|
-
await this.performWheel(param.direction || 'down', param.distance ||
|
|
1359
|
+
await this.performWheel(param.direction || 'down', param.distance || this.defaultScrollDistance(param.direction || 'down'), target?.center[0], target?.center[1]);
|
|
1344
1360
|
await sleep(device_SCROLL_COMPLETE_DELAY);
|
|
1345
1361
|
}
|
|
1346
1362
|
}
|
|
@@ -1572,7 +1588,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
1572
1588
|
const tools = new ComputerMidsceneTools();
|
|
1573
1589
|
runToolsCLI(tools, 'midscene-computer', {
|
|
1574
1590
|
stripPrefix: 'computer_',
|
|
1575
|
-
version: "1.8.
|
|
1591
|
+
version: "1.8.5-beta-20260522100653.0",
|
|
1576
1592
|
extraCommands: createReportCliCommands()
|
|
1577
1593
|
}).catch((e)=>{
|
|
1578
1594
|
process.exit(reportCLIError(e));
|
package/dist/es/index.mjs
CHANGED
|
@@ -107,7 +107,7 @@ const EDGE_SCROLL_TOTAL_PX = 50000;
|
|
|
107
107
|
const EDGE_SCROLL_STEPS = 400;
|
|
108
108
|
const PHASED_PIXELS_PER_STEP = 30;
|
|
109
109
|
const PHASED_MIN_STEPS = 10;
|
|
110
|
-
const
|
|
110
|
+
const DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
111
111
|
const EDGE_SCROLL_SPEC = {
|
|
112
112
|
scrollToTop: {
|
|
113
113
|
direction: 'up',
|
|
@@ -402,7 +402,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
402
402
|
}
|
|
403
403
|
async healthCheck() {
|
|
404
404
|
console.log('[HealthCheck] Starting health check...');
|
|
405
|
-
console.log("[HealthCheck] @midscene/computer v1.8.
|
|
405
|
+
console.log("[HealthCheck] @midscene/computer v1.8.5-beta-20260522100653.0");
|
|
406
406
|
console.log('[HealthCheck] Taking screenshot...');
|
|
407
407
|
const screenshotTimeout = 15000;
|
|
408
408
|
let timeoutId;
|
|
@@ -601,15 +601,23 @@ Original error: ${lastRawMessage}`);
|
|
|
601
601
|
return;
|
|
602
602
|
}
|
|
603
603
|
if ('singleAction' === scrollType || !scrollType) {
|
|
604
|
-
const distance = param?.distance || 500;
|
|
605
604
|
const direction = param?.direction || 'down';
|
|
606
605
|
const isKnownDirection = 'up' === direction || 'down' === direction || 'left' === direction || 'right' === direction;
|
|
606
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
607
|
+
let distance = param?.distance ?? void 0;
|
|
608
|
+
let screenSize;
|
|
609
|
+
if (!distance) {
|
|
610
|
+
screenSize = await this.size();
|
|
611
|
+
const base = isHorizontal ? screenSize.width : screenSize.height;
|
|
612
|
+
distance = Math.max(1, Math.round(base * DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
613
|
+
}
|
|
607
614
|
if (isKnownDirection) {
|
|
608
615
|
const steps = Math.max(PHASED_MIN_STEPS, Math.round(distance / PHASED_PIXELS_PER_STEP));
|
|
609
616
|
if (runPhasedScroll(direction, distance, steps)) return void await sleep(SCROLL_COMPLETE_DELAY);
|
|
610
617
|
}
|
|
611
618
|
if (this.useAppleScript && ('up' === direction || 'down' === direction)) {
|
|
612
|
-
|
|
619
|
+
if (!screenSize) screenSize = await this.size();
|
|
620
|
+
const pages = Math.max(1, Math.round(distance / screenSize.height));
|
|
613
621
|
const key = 'up' === direction ? 'pageup' : 'pagedown';
|
|
614
622
|
for(let i = 0; i < pages; i++){
|
|
615
623
|
sendKeyViaAppleScript(key);
|
|
@@ -1148,6 +1156,7 @@ const device_INPUT_CLEAR_DELAY = 150;
|
|
|
1148
1156
|
const device_SCROLL_STEP_DELAY = 100;
|
|
1149
1157
|
const device_SCROLL_COMPLETE_DELAY = 500;
|
|
1150
1158
|
const DEFAULT_SCROLL_DISTANCE = 480;
|
|
1159
|
+
const device_DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
1151
1160
|
const device_EDGE_SCROLL_STEPS = 10;
|
|
1152
1161
|
const DEFAULT_SCROLL_STEP_AMOUNT = 120;
|
|
1153
1162
|
class RDPDevice {
|
|
@@ -1243,6 +1252,13 @@ class RDPDevice {
|
|
|
1243
1252
|
throw new Error(`Unsupported scroll type: ${scrollType}`);
|
|
1244
1253
|
}
|
|
1245
1254
|
}
|
|
1255
|
+
defaultScrollDistance(direction) {
|
|
1256
|
+
const size = this.connectionInfo?.size;
|
|
1257
|
+
if (!size) return DEFAULT_SCROLL_DISTANCE;
|
|
1258
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
1259
|
+
const base = isHorizontal ? size.width : size.height;
|
|
1260
|
+
return Math.max(1, Math.round(base * device_DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
1261
|
+
}
|
|
1246
1262
|
async movePointer(targetX, targetY, options) {
|
|
1247
1263
|
this.assertConnected();
|
|
1248
1264
|
const start = this.cursorPosition || [
|
|
@@ -1383,7 +1399,7 @@ class RDPDevice {
|
|
|
1383
1399
|
await sleep(device_SCROLL_COMPLETE_DELAY);
|
|
1384
1400
|
return;
|
|
1385
1401
|
}
|
|
1386
|
-
await this.performWheel(param.direction || 'down', param.distance ||
|
|
1402
|
+
await this.performWheel(param.direction || 'down', param.distance || this.defaultScrollDistance(param.direction || 'down'), target?.center[0], target?.center[1]);
|
|
1387
1403
|
await sleep(device_SCROLL_COMPLETE_DELAY);
|
|
1388
1404
|
}
|
|
1389
1405
|
}
|
|
@@ -1613,7 +1629,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
1613
1629
|
}
|
|
1614
1630
|
}
|
|
1615
1631
|
function version() {
|
|
1616
|
-
const currentVersion = "1.8.
|
|
1632
|
+
const currentVersion = "1.8.5-beta-20260522100653.0";
|
|
1617
1633
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
1618
1634
|
return currentVersion;
|
|
1619
1635
|
}
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -107,7 +107,7 @@ const EDGE_SCROLL_TOTAL_PX = 50000;
|
|
|
107
107
|
const EDGE_SCROLL_STEPS = 400;
|
|
108
108
|
const PHASED_PIXELS_PER_STEP = 30;
|
|
109
109
|
const PHASED_MIN_STEPS = 10;
|
|
110
|
-
const
|
|
110
|
+
const DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
111
111
|
const EDGE_SCROLL_SPEC = {
|
|
112
112
|
scrollToTop: {
|
|
113
113
|
direction: 'up',
|
|
@@ -402,7 +402,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
402
402
|
}
|
|
403
403
|
async healthCheck() {
|
|
404
404
|
console.log('[HealthCheck] Starting health check...');
|
|
405
|
-
console.log("[HealthCheck] @midscene/computer v1.8.
|
|
405
|
+
console.log("[HealthCheck] @midscene/computer v1.8.5-beta-20260522100653.0");
|
|
406
406
|
console.log('[HealthCheck] Taking screenshot...');
|
|
407
407
|
const screenshotTimeout = 15000;
|
|
408
408
|
let timeoutId;
|
|
@@ -601,15 +601,23 @@ Original error: ${lastRawMessage}`);
|
|
|
601
601
|
return;
|
|
602
602
|
}
|
|
603
603
|
if ('singleAction' === scrollType || !scrollType) {
|
|
604
|
-
const distance = param?.distance || 500;
|
|
605
604
|
const direction = param?.direction || 'down';
|
|
606
605
|
const isKnownDirection = 'up' === direction || 'down' === direction || 'left' === direction || 'right' === direction;
|
|
606
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
607
|
+
let distance = param?.distance ?? void 0;
|
|
608
|
+
let screenSize;
|
|
609
|
+
if (!distance) {
|
|
610
|
+
screenSize = await this.size();
|
|
611
|
+
const base = isHorizontal ? screenSize.width : screenSize.height;
|
|
612
|
+
distance = Math.max(1, Math.round(base * DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
613
|
+
}
|
|
607
614
|
if (isKnownDirection) {
|
|
608
615
|
const steps = Math.max(PHASED_MIN_STEPS, Math.round(distance / PHASED_PIXELS_PER_STEP));
|
|
609
616
|
if (runPhasedScroll(direction, distance, steps)) return void await sleep(SCROLL_COMPLETE_DELAY);
|
|
610
617
|
}
|
|
611
618
|
if (this.useAppleScript && ('up' === direction || 'down' === direction)) {
|
|
612
|
-
|
|
619
|
+
if (!screenSize) screenSize = await this.size();
|
|
620
|
+
const pages = Math.max(1, Math.round(distance / screenSize.height));
|
|
613
621
|
const key = 'up' === direction ? 'pageup' : 'pagedown';
|
|
614
622
|
for(let i = 0; i < pages; i++){
|
|
615
623
|
sendKeyViaAppleScript(key);
|
|
@@ -1105,6 +1113,7 @@ const device_INPUT_CLEAR_DELAY = 150;
|
|
|
1105
1113
|
const device_SCROLL_STEP_DELAY = 100;
|
|
1106
1114
|
const device_SCROLL_COMPLETE_DELAY = 500;
|
|
1107
1115
|
const DEFAULT_SCROLL_DISTANCE = 480;
|
|
1116
|
+
const device_DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
1108
1117
|
const device_EDGE_SCROLL_STEPS = 10;
|
|
1109
1118
|
const DEFAULT_SCROLL_STEP_AMOUNT = 120;
|
|
1110
1119
|
class RDPDevice {
|
|
@@ -1200,6 +1209,13 @@ class RDPDevice {
|
|
|
1200
1209
|
throw new Error(`Unsupported scroll type: ${scrollType}`);
|
|
1201
1210
|
}
|
|
1202
1211
|
}
|
|
1212
|
+
defaultScrollDistance(direction) {
|
|
1213
|
+
const size = this.connectionInfo?.size;
|
|
1214
|
+
if (!size) return DEFAULT_SCROLL_DISTANCE;
|
|
1215
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
1216
|
+
const base = isHorizontal ? size.width : size.height;
|
|
1217
|
+
return Math.max(1, Math.round(base * device_DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
1218
|
+
}
|
|
1203
1219
|
async movePointer(targetX, targetY, options) {
|
|
1204
1220
|
this.assertConnected();
|
|
1205
1221
|
const start = this.cursorPosition || [
|
|
@@ -1340,7 +1356,7 @@ class RDPDevice {
|
|
|
1340
1356
|
await sleep(device_SCROLL_COMPLETE_DELAY);
|
|
1341
1357
|
return;
|
|
1342
1358
|
}
|
|
1343
|
-
await this.performWheel(param.direction || 'down', param.distance ||
|
|
1359
|
+
await this.performWheel(param.direction || 'down', param.distance || this.defaultScrollDistance(param.direction || 'down'), target?.center[0], target?.center[1]);
|
|
1344
1360
|
await sleep(device_SCROLL_COMPLETE_DELAY);
|
|
1345
1361
|
}
|
|
1346
1362
|
}
|
|
@@ -1576,7 +1592,7 @@ class ComputerMCPServer extends BaseMCPServer {
|
|
|
1576
1592
|
constructor(toolsManager){
|
|
1577
1593
|
super({
|
|
1578
1594
|
name: '@midscene/computer-mcp',
|
|
1579
|
-
version: "1.8.
|
|
1595
|
+
version: "1.8.5-beta-20260522100653.0",
|
|
1580
1596
|
description: 'Control the computer desktop using natural language commands'
|
|
1581
1597
|
}, toolsManager);
|
|
1582
1598
|
}
|
package/dist/lib/cli.js
CHANGED
|
@@ -133,7 +133,7 @@ const EDGE_SCROLL_TOTAL_PX = 50000;
|
|
|
133
133
|
const EDGE_SCROLL_STEPS = 400;
|
|
134
134
|
const PHASED_PIXELS_PER_STEP = 30;
|
|
135
135
|
const PHASED_MIN_STEPS = 10;
|
|
136
|
-
const
|
|
136
|
+
const DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
137
137
|
const EDGE_SCROLL_SPEC = {
|
|
138
138
|
scrollToTop: {
|
|
139
139
|
direction: 'up',
|
|
@@ -428,7 +428,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
428
428
|
}
|
|
429
429
|
async healthCheck() {
|
|
430
430
|
console.log('[HealthCheck] Starting health check...');
|
|
431
|
-
console.log("[HealthCheck] @midscene/computer v1.8.
|
|
431
|
+
console.log("[HealthCheck] @midscene/computer v1.8.5-beta-20260522100653.0");
|
|
432
432
|
console.log('[HealthCheck] Taking screenshot...');
|
|
433
433
|
const screenshotTimeout = 15000;
|
|
434
434
|
let timeoutId;
|
|
@@ -627,15 +627,23 @@ Original error: ${lastRawMessage}`);
|
|
|
627
627
|
return;
|
|
628
628
|
}
|
|
629
629
|
if ('singleAction' === scrollType || !scrollType) {
|
|
630
|
-
const distance = param?.distance || 500;
|
|
631
630
|
const direction = param?.direction || 'down';
|
|
632
631
|
const isKnownDirection = 'up' === direction || 'down' === direction || 'left' === direction || 'right' === direction;
|
|
632
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
633
|
+
let distance = param?.distance ?? void 0;
|
|
634
|
+
let screenSize;
|
|
635
|
+
if (!distance) {
|
|
636
|
+
screenSize = await this.size();
|
|
637
|
+
const base = isHorizontal ? screenSize.width : screenSize.height;
|
|
638
|
+
distance = Math.max(1, Math.round(base * DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
639
|
+
}
|
|
633
640
|
if (isKnownDirection) {
|
|
634
641
|
const steps = Math.max(PHASED_MIN_STEPS, Math.round(distance / PHASED_PIXELS_PER_STEP));
|
|
635
642
|
if (runPhasedScroll(direction, distance, steps)) return void await (0, utils_namespaceObject.sleep)(SCROLL_COMPLETE_DELAY);
|
|
636
643
|
}
|
|
637
644
|
if (this.useAppleScript && ('up' === direction || 'down' === direction)) {
|
|
638
|
-
|
|
645
|
+
if (!screenSize) screenSize = await this.size();
|
|
646
|
+
const pages = Math.max(1, Math.round(distance / screenSize.height));
|
|
639
647
|
const key = 'up' === direction ? 'pageup' : 'pagedown';
|
|
640
648
|
for(let i = 0; i < pages; i++){
|
|
641
649
|
sendKeyViaAppleScript(key);
|
|
@@ -1132,6 +1140,7 @@ const device_INPUT_CLEAR_DELAY = 150;
|
|
|
1132
1140
|
const device_SCROLL_STEP_DELAY = 100;
|
|
1133
1141
|
const device_SCROLL_COMPLETE_DELAY = 500;
|
|
1134
1142
|
const DEFAULT_SCROLL_DISTANCE = 480;
|
|
1143
|
+
const device_DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
1135
1144
|
const device_EDGE_SCROLL_STEPS = 10;
|
|
1136
1145
|
const DEFAULT_SCROLL_STEP_AMOUNT = 120;
|
|
1137
1146
|
class RDPDevice {
|
|
@@ -1227,6 +1236,13 @@ class RDPDevice {
|
|
|
1227
1236
|
throw new Error(`Unsupported scroll type: ${scrollType}`);
|
|
1228
1237
|
}
|
|
1229
1238
|
}
|
|
1239
|
+
defaultScrollDistance(direction) {
|
|
1240
|
+
const size = this.connectionInfo?.size;
|
|
1241
|
+
if (!size) return DEFAULT_SCROLL_DISTANCE;
|
|
1242
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
1243
|
+
const base = isHorizontal ? size.width : size.height;
|
|
1244
|
+
return Math.max(1, Math.round(base * device_DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
1245
|
+
}
|
|
1230
1246
|
async movePointer(targetX, targetY, options) {
|
|
1231
1247
|
this.assertConnected();
|
|
1232
1248
|
const start = this.cursorPosition || [
|
|
@@ -1367,7 +1383,7 @@ class RDPDevice {
|
|
|
1367
1383
|
await (0, utils_namespaceObject.sleep)(device_SCROLL_COMPLETE_DELAY);
|
|
1368
1384
|
return;
|
|
1369
1385
|
}
|
|
1370
|
-
await this.performWheel(param.direction || 'down', param.distance ||
|
|
1386
|
+
await this.performWheel(param.direction || 'down', param.distance || this.defaultScrollDistance(param.direction || 'down'), target?.center[0], target?.center[1]);
|
|
1371
1387
|
await (0, utils_namespaceObject.sleep)(device_SCROLL_COMPLETE_DELAY);
|
|
1372
1388
|
}
|
|
1373
1389
|
}
|
|
@@ -1599,7 +1615,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
1599
1615
|
const tools = new ComputerMidsceneTools();
|
|
1600
1616
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-computer', {
|
|
1601
1617
|
stripPrefix: 'computer_',
|
|
1602
|
-
version: "1.8.
|
|
1618
|
+
version: "1.8.5-beta-20260522100653.0",
|
|
1603
1619
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
1604
1620
|
}).catch((e)=>{
|
|
1605
1621
|
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|
package/dist/lib/index.js
CHANGED
|
@@ -160,7 +160,7 @@ const EDGE_SCROLL_TOTAL_PX = 50000;
|
|
|
160
160
|
const EDGE_SCROLL_STEPS = 400;
|
|
161
161
|
const PHASED_PIXELS_PER_STEP = 30;
|
|
162
162
|
const PHASED_MIN_STEPS = 10;
|
|
163
|
-
const
|
|
163
|
+
const DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
164
164
|
const EDGE_SCROLL_SPEC = {
|
|
165
165
|
scrollToTop: {
|
|
166
166
|
direction: 'up',
|
|
@@ -455,7 +455,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
455
455
|
}
|
|
456
456
|
async healthCheck() {
|
|
457
457
|
console.log('[HealthCheck] Starting health check...');
|
|
458
|
-
console.log("[HealthCheck] @midscene/computer v1.8.
|
|
458
|
+
console.log("[HealthCheck] @midscene/computer v1.8.5-beta-20260522100653.0");
|
|
459
459
|
console.log('[HealthCheck] Taking screenshot...');
|
|
460
460
|
const screenshotTimeout = 15000;
|
|
461
461
|
let timeoutId;
|
|
@@ -654,15 +654,23 @@ Original error: ${lastRawMessage}`);
|
|
|
654
654
|
return;
|
|
655
655
|
}
|
|
656
656
|
if ('singleAction' === scrollType || !scrollType) {
|
|
657
|
-
const distance = param?.distance || 500;
|
|
658
657
|
const direction = param?.direction || 'down';
|
|
659
658
|
const isKnownDirection = 'up' === direction || 'down' === direction || 'left' === direction || 'right' === direction;
|
|
659
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
660
|
+
let distance = param?.distance ?? void 0;
|
|
661
|
+
let screenSize;
|
|
662
|
+
if (!distance) {
|
|
663
|
+
screenSize = await this.size();
|
|
664
|
+
const base = isHorizontal ? screenSize.width : screenSize.height;
|
|
665
|
+
distance = Math.max(1, Math.round(base * DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
666
|
+
}
|
|
660
667
|
if (isKnownDirection) {
|
|
661
668
|
const steps = Math.max(PHASED_MIN_STEPS, Math.round(distance / PHASED_PIXELS_PER_STEP));
|
|
662
669
|
if (runPhasedScroll(direction, distance, steps)) return void await (0, utils_namespaceObject.sleep)(SCROLL_COMPLETE_DELAY);
|
|
663
670
|
}
|
|
664
671
|
if (this.useAppleScript && ('up' === direction || 'down' === direction)) {
|
|
665
|
-
|
|
672
|
+
if (!screenSize) screenSize = await this.size();
|
|
673
|
+
const pages = Math.max(1, Math.round(distance / screenSize.height));
|
|
666
674
|
const key = 'up' === direction ? 'pageup' : 'pagedown';
|
|
667
675
|
for(let i = 0; i < pages; i++){
|
|
668
676
|
sendKeyViaAppleScript(key);
|
|
@@ -1203,6 +1211,7 @@ const device_INPUT_CLEAR_DELAY = 150;
|
|
|
1203
1211
|
const device_SCROLL_STEP_DELAY = 100;
|
|
1204
1212
|
const device_SCROLL_COMPLETE_DELAY = 500;
|
|
1205
1213
|
const DEFAULT_SCROLL_DISTANCE = 480;
|
|
1214
|
+
const device_DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
1206
1215
|
const device_EDGE_SCROLL_STEPS = 10;
|
|
1207
1216
|
const DEFAULT_SCROLL_STEP_AMOUNT = 120;
|
|
1208
1217
|
class RDPDevice {
|
|
@@ -1298,6 +1307,13 @@ class RDPDevice {
|
|
|
1298
1307
|
throw new Error(`Unsupported scroll type: ${scrollType}`);
|
|
1299
1308
|
}
|
|
1300
1309
|
}
|
|
1310
|
+
defaultScrollDistance(direction) {
|
|
1311
|
+
const size = this.connectionInfo?.size;
|
|
1312
|
+
if (!size) return DEFAULT_SCROLL_DISTANCE;
|
|
1313
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
1314
|
+
const base = isHorizontal ? size.width : size.height;
|
|
1315
|
+
return Math.max(1, Math.round(base * device_DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
1316
|
+
}
|
|
1301
1317
|
async movePointer(targetX, targetY, options) {
|
|
1302
1318
|
this.assertConnected();
|
|
1303
1319
|
const start = this.cursorPosition || [
|
|
@@ -1438,7 +1454,7 @@ class RDPDevice {
|
|
|
1438
1454
|
await (0, utils_namespaceObject.sleep)(device_SCROLL_COMPLETE_DELAY);
|
|
1439
1455
|
return;
|
|
1440
1456
|
}
|
|
1441
|
-
await this.performWheel(param.direction || 'down', param.distance ||
|
|
1457
|
+
await this.performWheel(param.direction || 'down', param.distance || this.defaultScrollDistance(param.direction || 'down'), target?.center[0], target?.center[1]);
|
|
1442
1458
|
await (0, utils_namespaceObject.sleep)(device_SCROLL_COMPLETE_DELAY);
|
|
1443
1459
|
}
|
|
1444
1460
|
}
|
|
@@ -1671,7 +1687,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
1671
1687
|
}
|
|
1672
1688
|
const env_namespaceObject = require("@midscene/shared/env");
|
|
1673
1689
|
function version() {
|
|
1674
|
-
const currentVersion = "1.8.
|
|
1690
|
+
const currentVersion = "1.8.5-beta-20260522100653.0";
|
|
1675
1691
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
1676
1692
|
return currentVersion;
|
|
1677
1693
|
}
|
package/dist/lib/mcp-server.js
CHANGED
|
@@ -147,7 +147,7 @@ const EDGE_SCROLL_TOTAL_PX = 50000;
|
|
|
147
147
|
const EDGE_SCROLL_STEPS = 400;
|
|
148
148
|
const PHASED_PIXELS_PER_STEP = 30;
|
|
149
149
|
const PHASED_MIN_STEPS = 10;
|
|
150
|
-
const
|
|
150
|
+
const DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
151
151
|
const EDGE_SCROLL_SPEC = {
|
|
152
152
|
scrollToTop: {
|
|
153
153
|
direction: 'up',
|
|
@@ -442,7 +442,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
442
442
|
}
|
|
443
443
|
async healthCheck() {
|
|
444
444
|
console.log('[HealthCheck] Starting health check...');
|
|
445
|
-
console.log("[HealthCheck] @midscene/computer v1.8.
|
|
445
|
+
console.log("[HealthCheck] @midscene/computer v1.8.5-beta-20260522100653.0");
|
|
446
446
|
console.log('[HealthCheck] Taking screenshot...');
|
|
447
447
|
const screenshotTimeout = 15000;
|
|
448
448
|
let timeoutId;
|
|
@@ -641,15 +641,23 @@ Original error: ${lastRawMessage}`);
|
|
|
641
641
|
return;
|
|
642
642
|
}
|
|
643
643
|
if ('singleAction' === scrollType || !scrollType) {
|
|
644
|
-
const distance = param?.distance || 500;
|
|
645
644
|
const direction = param?.direction || 'down';
|
|
646
645
|
const isKnownDirection = 'up' === direction || 'down' === direction || 'left' === direction || 'right' === direction;
|
|
646
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
647
|
+
let distance = param?.distance ?? void 0;
|
|
648
|
+
let screenSize;
|
|
649
|
+
if (!distance) {
|
|
650
|
+
screenSize = await this.size();
|
|
651
|
+
const base = isHorizontal ? screenSize.width : screenSize.height;
|
|
652
|
+
distance = Math.max(1, Math.round(base * DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
653
|
+
}
|
|
647
654
|
if (isKnownDirection) {
|
|
648
655
|
const steps = Math.max(PHASED_MIN_STEPS, Math.round(distance / PHASED_PIXELS_PER_STEP));
|
|
649
656
|
if (runPhasedScroll(direction, distance, steps)) return void await (0, utils_namespaceObject.sleep)(SCROLL_COMPLETE_DELAY);
|
|
650
657
|
}
|
|
651
658
|
if (this.useAppleScript && ('up' === direction || 'down' === direction)) {
|
|
652
|
-
|
|
659
|
+
if (!screenSize) screenSize = await this.size();
|
|
660
|
+
const pages = Math.max(1, Math.round(distance / screenSize.height));
|
|
653
661
|
const key = 'up' === direction ? 'pageup' : 'pagedown';
|
|
654
662
|
for(let i = 0; i < pages; i++){
|
|
655
663
|
sendKeyViaAppleScript(key);
|
|
@@ -1146,6 +1154,7 @@ const device_INPUT_CLEAR_DELAY = 150;
|
|
|
1146
1154
|
const device_SCROLL_STEP_DELAY = 100;
|
|
1147
1155
|
const device_SCROLL_COMPLETE_DELAY = 500;
|
|
1148
1156
|
const DEFAULT_SCROLL_DISTANCE = 480;
|
|
1157
|
+
const device_DEFAULT_SCROLL_VIEWPORT_RATIO = 0.7;
|
|
1149
1158
|
const device_EDGE_SCROLL_STEPS = 10;
|
|
1150
1159
|
const DEFAULT_SCROLL_STEP_AMOUNT = 120;
|
|
1151
1160
|
class RDPDevice {
|
|
@@ -1241,6 +1250,13 @@ class RDPDevice {
|
|
|
1241
1250
|
throw new Error(`Unsupported scroll type: ${scrollType}`);
|
|
1242
1251
|
}
|
|
1243
1252
|
}
|
|
1253
|
+
defaultScrollDistance(direction) {
|
|
1254
|
+
const size = this.connectionInfo?.size;
|
|
1255
|
+
if (!size) return DEFAULT_SCROLL_DISTANCE;
|
|
1256
|
+
const isHorizontal = 'left' === direction || 'right' === direction;
|
|
1257
|
+
const base = isHorizontal ? size.width : size.height;
|
|
1258
|
+
return Math.max(1, Math.round(base * device_DEFAULT_SCROLL_VIEWPORT_RATIO));
|
|
1259
|
+
}
|
|
1244
1260
|
async movePointer(targetX, targetY, options) {
|
|
1245
1261
|
this.assertConnected();
|
|
1246
1262
|
const start = this.cursorPosition || [
|
|
@@ -1381,7 +1397,7 @@ class RDPDevice {
|
|
|
1381
1397
|
await (0, utils_namespaceObject.sleep)(device_SCROLL_COMPLETE_DELAY);
|
|
1382
1398
|
return;
|
|
1383
1399
|
}
|
|
1384
|
-
await this.performWheel(param.direction || 'down', param.distance ||
|
|
1400
|
+
await this.performWheel(param.direction || 'down', param.distance || this.defaultScrollDistance(param.direction || 'down'), target?.center[0], target?.center[1]);
|
|
1385
1401
|
await (0, utils_namespaceObject.sleep)(device_SCROLL_COMPLETE_DELAY);
|
|
1386
1402
|
}
|
|
1387
1403
|
}
|
|
@@ -1619,7 +1635,7 @@ class ComputerMCPServer extends mcp_namespaceObject.BaseMCPServer {
|
|
|
1619
1635
|
constructor(toolsManager){
|
|
1620
1636
|
super({
|
|
1621
1637
|
name: '@midscene/computer-mcp',
|
|
1622
|
-
version: "1.8.
|
|
1638
|
+
version: "1.8.5-beta-20260522100653.0",
|
|
1623
1639
|
description: 'Control the computer desktop using natural language commands'
|
|
1624
1640
|
}, toolsManager);
|
|
1625
1641
|
}
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/computer",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.5-beta-20260522100653.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/
|
|
42
|
-
"@midscene/
|
|
41
|
+
"@midscene/core": "1.8.5-beta-20260522100653.0",
|
|
42
|
+
"@midscene/shared": "1.8.5-beta-20260522100653.0"
|
|
43
43
|
},
|
|
44
44
|
"optionalDependencies": {
|
|
45
45
|
"node-mac-permissions": "2.5.0"
|