@midscene/computer 1.12.5-beta-20260907092148.0 → 1.12.5
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 +3 -45
- package/dist/es/index.mjs +3 -45
- package/dist/lib/cli.js +3 -45
- package/dist/lib/index.js +3 -45
- package/dist/types/index.d.ts +1 -12
- package/package.json +3 -3
package/dist/es/cli.mjs
CHANGED
|
@@ -91,29 +91,6 @@ class ComputerInputDriver {
|
|
|
91
91
|
if (void 0 !== modifiers) lib.keyTap(key, modifiers);
|
|
92
92
|
else lib.keyTap(key);
|
|
93
93
|
}
|
|
94
|
-
keyToggle(key, state, modifiers) {
|
|
95
|
-
const lib = this.getLibnutOrThrow('keyToggle');
|
|
96
|
-
if (void 0 !== modifiers) lib.keyToggle(key, state, modifiers);
|
|
97
|
-
else lib.keyToggle(key, state);
|
|
98
|
-
}
|
|
99
|
-
async keyTapWithExplicitModifiers(key, modifiers, delayMs) {
|
|
100
|
-
const uniqueModifiers = [
|
|
101
|
-
...new Set(modifiers)
|
|
102
|
-
];
|
|
103
|
-
if (0 === uniqueModifiers.length) return void this.keyTap(key);
|
|
104
|
-
const pressedModifiers = [];
|
|
105
|
-
try {
|
|
106
|
-
for (const modifier of uniqueModifiers){
|
|
107
|
-
this.keyToggle(modifier, 'down');
|
|
108
|
-
pressedModifiers.push(modifier);
|
|
109
|
-
}
|
|
110
|
-
await this.delay(delayMs);
|
|
111
|
-
this.keyTap(key);
|
|
112
|
-
await this.delay(delayMs);
|
|
113
|
-
} finally{
|
|
114
|
-
for (const modifier of pressedModifiers.reverse())this.releaseKey(modifier);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
94
|
typeString(text) {
|
|
118
95
|
this.getLibnutOrThrow('typeString').typeString(text);
|
|
119
96
|
}
|
|
@@ -186,15 +163,6 @@ class ComputerInputDriver {
|
|
|
186
163
|
this.options.debug(`Failed to release mouse button ${button}: ${error}`);
|
|
187
164
|
}
|
|
188
165
|
}
|
|
189
|
-
releaseKey(key) {
|
|
190
|
-
try {
|
|
191
|
-
const libnut = this.options.getLibnut();
|
|
192
|
-
node_assert(libnut, 'libnut not initialized');
|
|
193
|
-
libnut.keyToggle(key, 'up');
|
|
194
|
-
} catch (error) {
|
|
195
|
-
this.options.debug(`Failed to release key ${key}: ${error}`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
166
|
rejectPendingInputDelays() {
|
|
199
167
|
const error = this.createDestroyedError('in-flight input');
|
|
200
168
|
for (const waitRef of this.pendingInputDelayWaits){
|
|
@@ -1185,7 +1153,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1185
1153
|
}
|
|
1186
1154
|
async healthCheck(displays) {
|
|
1187
1155
|
console.log('[HealthCheck] Starting health check...');
|
|
1188
|
-
console.log("[HealthCheck] @midscene/computer v1.12.5
|
|
1156
|
+
console.log("[HealthCheck] @midscene/computer v1.12.5");
|
|
1189
1157
|
console.log('[HealthCheck] Taking screenshot...');
|
|
1190
1158
|
const screenshotTimeout = 15000;
|
|
1191
1159
|
let timeoutId;
|
|
@@ -1421,8 +1389,6 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1421
1389
|
modifiers,
|
|
1422
1390
|
driver: this.useAppleScript ? "applescript" : 'libnut'
|
|
1423
1391
|
});
|
|
1424
|
-
const shortcutDelay = this.options?.keyboardShortcutDelay ?? 0;
|
|
1425
|
-
if (!this.useAppleScript && modifiers.length > 0 && shortcutDelay > 0) return void await this.inputDriver.keyTapWithExplicitModifiers(key, modifiers, shortcutDelay);
|
|
1426
1392
|
this.inputDriver.sendKey(key, modifiers);
|
|
1427
1393
|
}
|
|
1428
1394
|
resolveUntargetedScrollPoint(screenSize) {
|
|
@@ -1702,7 +1668,6 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1702
1668
|
}
|
|
1703
1669
|
}
|
|
1704
1670
|
});
|
|
1705
|
-
if (options?.keyboardShortcutDelay !== void 0 && (!Number.isFinite(options.keyboardShortcutDelay) || options.keyboardShortcutDelay < 0)) throw new Error('keyboardShortcutDelay must be a finite non-negative number');
|
|
1706
1671
|
this.options = options;
|
|
1707
1672
|
this.displayId = options?.displayId;
|
|
1708
1673
|
this.useAppleScript = 'darwin' === process.platform && options?.keyboardDriver !== 'libnut';
|
|
@@ -2405,7 +2370,6 @@ function createLocalComputerDevice(opts) {
|
|
|
2405
2370
|
keyboardTypeDelay: opts?.keyboardTypeDelay,
|
|
2406
2371
|
inputStrategy: opts?.inputStrategy,
|
|
2407
2372
|
keyboardDriver: opts?.keyboardDriver,
|
|
2408
|
-
keyboardShortcutDelay: opts?.keyboardShortcutDelay,
|
|
2409
2373
|
headless: opts?.headless,
|
|
2410
2374
|
xvfbResolution: opts?.xvfbResolution,
|
|
2411
2375
|
keepXvfbAliveUntilProcessExit: opts?.keepXvfbAliveUntilProcessExit
|
|
@@ -2463,7 +2427,6 @@ const computerInitArgShape = {
|
|
|
2463
2427
|
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux local mode only). Ignored when host is set.'),
|
|
2464
2428
|
keyboardTypeDelay: z.number().finite().nonnegative().optional().describe('Finite non-negative delay in milliseconds between keystrokes. In "legacy" mode, positive values enable key-by-key input; zero or omitted uses clipboard input.'),
|
|
2465
2429
|
inputStrategy: z["enum"](inputStrategies).optional().describe('Text input strategy. "legacy" (default) preserves current Computer behavior, "sequential" sends one Unicode code point at a time, and "bulk" uses one backend input operation. "bulk" requires keyboardTypeDelay to be omitted or set to 0.'),
|
|
2466
|
-
keyboardShortcutDelay: z.number().finite().nonnegative().optional().describe('Finite non-negative delay in milliseconds between modifier transitions and the main key for local libnut shortcuts. Positive values can improve compatibility with full-screen remote-control clients. Ignored in RDP mode and by the macOS AppleScript driver.'),
|
|
2467
2430
|
host: z.string().optional().describe('RDP host (FQDN or IP). Set this to switch into RDP mode.'),
|
|
2468
2431
|
port: z.number().optional().describe('RDP port (default 3389). Requires host.'),
|
|
2469
2432
|
username: z.string().optional().describe('RDP username. Requires host.'),
|
|
@@ -2480,7 +2443,7 @@ const computerInitArgShape = {
|
|
|
2480
2443
|
function adaptComputerInitArgs(extracted) {
|
|
2481
2444
|
if (!extracted || 0 === Object.keys(extracted).length) return;
|
|
2482
2445
|
if (extracted.host) {
|
|
2483
|
-
const { displayId: _d, headless: _h,
|
|
2446
|
+
const { displayId: _d, headless: _h, ...rdpFields } = extracted;
|
|
2484
2447
|
const host = normalizeRdpHost(extracted.host);
|
|
2485
2448
|
return {
|
|
2486
2449
|
mode: 'rdp',
|
|
@@ -2494,7 +2457,6 @@ function adaptComputerInitArgs(extracted) {
|
|
|
2494
2457
|
headless: extracted.headless,
|
|
2495
2458
|
keyboardTypeDelay: extracted.keyboardTypeDelay,
|
|
2496
2459
|
inputStrategy: extracted.inputStrategy,
|
|
2497
|
-
keyboardShortcutDelay: extracted.keyboardShortcutDelay,
|
|
2498
2460
|
...extractAgentBehaviorInitArgs(extracted) ?? {}
|
|
2499
2461
|
};
|
|
2500
2462
|
}
|
|
@@ -2546,7 +2508,6 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2546
2508
|
const headless = opts?.mode === 'local' ? opts.headless : void 0;
|
|
2547
2509
|
const keyboardTypeDelay = opts?.keyboardTypeDelay;
|
|
2548
2510
|
const inputStrategy = opts?.inputStrategy;
|
|
2549
|
-
const keyboardShortcutDelay = opts?.mode === 'local' ? opts.keyboardShortcutDelay : void 0;
|
|
2550
2511
|
agent_tools_debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
2551
2512
|
const agentOpts = {
|
|
2552
2513
|
...displayId ? {
|
|
@@ -2561,9 +2522,6 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2561
2522
|
...void 0 !== inputStrategy ? {
|
|
2562
2523
|
inputStrategy
|
|
2563
2524
|
} : {},
|
|
2564
|
-
...void 0 !== keyboardShortcutDelay ? {
|
|
2565
|
-
keyboardShortcutDelay
|
|
2566
|
-
} : {},
|
|
2567
2525
|
...this.options.keepXvfbAliveUntilProcessExit ? {
|
|
2568
2526
|
keepXvfbAliveUntilProcessExit: true
|
|
2569
2527
|
} : {},
|
|
@@ -2648,7 +2606,7 @@ const tools = new ComputerMidsceneTools({
|
|
|
2648
2606
|
});
|
|
2649
2607
|
runToolsCLI(tools, 'midscene-computer', {
|
|
2650
2608
|
stripPrefix: 'computer_',
|
|
2651
|
-
version: "1.12.5
|
|
2609
|
+
version: "1.12.5",
|
|
2652
2610
|
extraCommands: createReportCliCommands()
|
|
2653
2611
|
}).catch((e)=>{
|
|
2654
2612
|
process.exit(reportCLIError(e));
|
package/dist/es/index.mjs
CHANGED
|
@@ -91,29 +91,6 @@ class ComputerInputDriver {
|
|
|
91
91
|
if (void 0 !== modifiers) lib.keyTap(key, modifiers);
|
|
92
92
|
else lib.keyTap(key);
|
|
93
93
|
}
|
|
94
|
-
keyToggle(key, state, modifiers) {
|
|
95
|
-
const lib = this.getLibnutOrThrow('keyToggle');
|
|
96
|
-
if (void 0 !== modifiers) lib.keyToggle(key, state, modifiers);
|
|
97
|
-
else lib.keyToggle(key, state);
|
|
98
|
-
}
|
|
99
|
-
async keyTapWithExplicitModifiers(key, modifiers, delayMs) {
|
|
100
|
-
const uniqueModifiers = [
|
|
101
|
-
...new Set(modifiers)
|
|
102
|
-
];
|
|
103
|
-
if (0 === uniqueModifiers.length) return void this.keyTap(key);
|
|
104
|
-
const pressedModifiers = [];
|
|
105
|
-
try {
|
|
106
|
-
for (const modifier of uniqueModifiers){
|
|
107
|
-
this.keyToggle(modifier, 'down');
|
|
108
|
-
pressedModifiers.push(modifier);
|
|
109
|
-
}
|
|
110
|
-
await this.delay(delayMs);
|
|
111
|
-
this.keyTap(key);
|
|
112
|
-
await this.delay(delayMs);
|
|
113
|
-
} finally{
|
|
114
|
-
for (const modifier of pressedModifiers.reverse())this.releaseKey(modifier);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
94
|
typeString(text) {
|
|
118
95
|
this.getLibnutOrThrow('typeString').typeString(text);
|
|
119
96
|
}
|
|
@@ -186,15 +163,6 @@ class ComputerInputDriver {
|
|
|
186
163
|
this.options.debug(`Failed to release mouse button ${button}: ${error}`);
|
|
187
164
|
}
|
|
188
165
|
}
|
|
189
|
-
releaseKey(key) {
|
|
190
|
-
try {
|
|
191
|
-
const libnut = this.options.getLibnut();
|
|
192
|
-
node_assert(libnut, 'libnut not initialized');
|
|
193
|
-
libnut.keyToggle(key, 'up');
|
|
194
|
-
} catch (error) {
|
|
195
|
-
this.options.debug(`Failed to release key ${key}: ${error}`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
166
|
rejectPendingInputDelays() {
|
|
199
167
|
const error = this.createDestroyedError('in-flight input');
|
|
200
168
|
for (const waitRef of this.pendingInputDelayWaits){
|
|
@@ -1185,7 +1153,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1185
1153
|
}
|
|
1186
1154
|
async healthCheck(displays) {
|
|
1187
1155
|
console.log('[HealthCheck] Starting health check...');
|
|
1188
|
-
console.log("[HealthCheck] @midscene/computer v1.12.5
|
|
1156
|
+
console.log("[HealthCheck] @midscene/computer v1.12.5");
|
|
1189
1157
|
console.log('[HealthCheck] Taking screenshot...');
|
|
1190
1158
|
const screenshotTimeout = 15000;
|
|
1191
1159
|
let timeoutId;
|
|
@@ -1421,8 +1389,6 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1421
1389
|
modifiers,
|
|
1422
1390
|
driver: this.useAppleScript ? "applescript" : 'libnut'
|
|
1423
1391
|
});
|
|
1424
|
-
const shortcutDelay = this.options?.keyboardShortcutDelay ?? 0;
|
|
1425
|
-
if (!this.useAppleScript && modifiers.length > 0 && shortcutDelay > 0) return void await this.inputDriver.keyTapWithExplicitModifiers(key, modifiers, shortcutDelay);
|
|
1426
1392
|
this.inputDriver.sendKey(key, modifiers);
|
|
1427
1393
|
}
|
|
1428
1394
|
resolveUntargetedScrollPoint(screenSize) {
|
|
@@ -1702,7 +1668,6 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1702
1668
|
}
|
|
1703
1669
|
}
|
|
1704
1670
|
});
|
|
1705
|
-
if (options?.keyboardShortcutDelay !== void 0 && (!Number.isFinite(options.keyboardShortcutDelay) || options.keyboardShortcutDelay < 0)) throw new Error('keyboardShortcutDelay must be a finite non-negative number');
|
|
1706
1671
|
this.options = options;
|
|
1707
1672
|
this.displayId = options?.displayId;
|
|
1708
1673
|
this.useAppleScript = 'darwin' === process.platform && options?.keyboardDriver !== 'libnut';
|
|
@@ -2448,7 +2413,6 @@ function createLocalComputerDevice(opts) {
|
|
|
2448
2413
|
keyboardTypeDelay: opts?.keyboardTypeDelay,
|
|
2449
2414
|
inputStrategy: opts?.inputStrategy,
|
|
2450
2415
|
keyboardDriver: opts?.keyboardDriver,
|
|
2451
|
-
keyboardShortcutDelay: opts?.keyboardShortcutDelay,
|
|
2452
2416
|
headless: opts?.headless,
|
|
2453
2417
|
xvfbResolution: opts?.xvfbResolution,
|
|
2454
2418
|
keepXvfbAliveUntilProcessExit: opts?.keepXvfbAliveUntilProcessExit
|
|
@@ -2506,7 +2470,6 @@ const computerInitArgShape = {
|
|
|
2506
2470
|
headless: z.boolean().optional().describe('Start virtual display via Xvfb (Linux local mode only). Ignored when host is set.'),
|
|
2507
2471
|
keyboardTypeDelay: z.number().finite().nonnegative().optional().describe('Finite non-negative delay in milliseconds between keystrokes. In "legacy" mode, positive values enable key-by-key input; zero or omitted uses clipboard input.'),
|
|
2508
2472
|
inputStrategy: z["enum"](inputStrategies).optional().describe('Text input strategy. "legacy" (default) preserves current Computer behavior, "sequential" sends one Unicode code point at a time, and "bulk" uses one backend input operation. "bulk" requires keyboardTypeDelay to be omitted or set to 0.'),
|
|
2509
|
-
keyboardShortcutDelay: z.number().finite().nonnegative().optional().describe('Finite non-negative delay in milliseconds between modifier transitions and the main key for local libnut shortcuts. Positive values can improve compatibility with full-screen remote-control clients. Ignored in RDP mode and by the macOS AppleScript driver.'),
|
|
2510
2473
|
host: z.string().optional().describe('RDP host (FQDN or IP). Set this to switch into RDP mode.'),
|
|
2511
2474
|
port: z.number().optional().describe('RDP port (default 3389). Requires host.'),
|
|
2512
2475
|
username: z.string().optional().describe('RDP username. Requires host.'),
|
|
@@ -2523,7 +2486,7 @@ const computerInitArgShape = {
|
|
|
2523
2486
|
function adaptComputerInitArgs(extracted) {
|
|
2524
2487
|
if (!extracted || 0 === Object.keys(extracted).length) return;
|
|
2525
2488
|
if (extracted.host) {
|
|
2526
|
-
const { displayId: _d, headless: _h,
|
|
2489
|
+
const { displayId: _d, headless: _h, ...rdpFields } = extracted;
|
|
2527
2490
|
const host = normalizeRdpHost(extracted.host);
|
|
2528
2491
|
return {
|
|
2529
2492
|
mode: 'rdp',
|
|
@@ -2537,7 +2500,6 @@ function adaptComputerInitArgs(extracted) {
|
|
|
2537
2500
|
headless: extracted.headless,
|
|
2538
2501
|
keyboardTypeDelay: extracted.keyboardTypeDelay,
|
|
2539
2502
|
inputStrategy: extracted.inputStrategy,
|
|
2540
|
-
keyboardShortcutDelay: extracted.keyboardShortcutDelay,
|
|
2541
2503
|
...extractAgentBehaviorInitArgs(extracted) ?? {}
|
|
2542
2504
|
};
|
|
2543
2505
|
}
|
|
@@ -2589,7 +2551,6 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2589
2551
|
const headless = opts?.mode === 'local' ? opts.headless : void 0;
|
|
2590
2552
|
const keyboardTypeDelay = opts?.keyboardTypeDelay;
|
|
2591
2553
|
const inputStrategy = opts?.inputStrategy;
|
|
2592
|
-
const keyboardShortcutDelay = opts?.mode === 'local' ? opts.keyboardShortcutDelay : void 0;
|
|
2593
2554
|
agent_tools_debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
2594
2555
|
const agentOpts = {
|
|
2595
2556
|
...displayId ? {
|
|
@@ -2604,9 +2565,6 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2604
2565
|
...void 0 !== inputStrategy ? {
|
|
2605
2566
|
inputStrategy
|
|
2606
2567
|
} : {},
|
|
2607
|
-
...void 0 !== keyboardShortcutDelay ? {
|
|
2608
|
-
keyboardShortcutDelay
|
|
2609
|
-
} : {},
|
|
2610
2568
|
...this.options.keepXvfbAliveUntilProcessExit ? {
|
|
2611
2569
|
keepXvfbAliveUntilProcessExit: true
|
|
2612
2570
|
} : {},
|
|
@@ -2687,7 +2645,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2687
2645
|
}
|
|
2688
2646
|
}
|
|
2689
2647
|
function version() {
|
|
2690
|
-
const currentVersion = "1.12.5
|
|
2648
|
+
const currentVersion = "1.12.5";
|
|
2691
2649
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
2692
2650
|
return currentVersion;
|
|
2693
2651
|
}
|
package/dist/lib/cli.js
CHANGED
|
@@ -116,29 +116,6 @@ class ComputerInputDriver {
|
|
|
116
116
|
if (void 0 !== modifiers) lib.keyTap(key, modifiers);
|
|
117
117
|
else lib.keyTap(key);
|
|
118
118
|
}
|
|
119
|
-
keyToggle(key, state, modifiers) {
|
|
120
|
-
const lib = this.getLibnutOrThrow('keyToggle');
|
|
121
|
-
if (void 0 !== modifiers) lib.keyToggle(key, state, modifiers);
|
|
122
|
-
else lib.keyToggle(key, state);
|
|
123
|
-
}
|
|
124
|
-
async keyTapWithExplicitModifiers(key, modifiers, delayMs) {
|
|
125
|
-
const uniqueModifiers = [
|
|
126
|
-
...new Set(modifiers)
|
|
127
|
-
];
|
|
128
|
-
if (0 === uniqueModifiers.length) return void this.keyTap(key);
|
|
129
|
-
const pressedModifiers = [];
|
|
130
|
-
try {
|
|
131
|
-
for (const modifier of uniqueModifiers){
|
|
132
|
-
this.keyToggle(modifier, 'down');
|
|
133
|
-
pressedModifiers.push(modifier);
|
|
134
|
-
}
|
|
135
|
-
await this.delay(delayMs);
|
|
136
|
-
this.keyTap(key);
|
|
137
|
-
await this.delay(delayMs);
|
|
138
|
-
} finally{
|
|
139
|
-
for (const modifier of pressedModifiers.reverse())this.releaseKey(modifier);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
119
|
typeString(text) {
|
|
143
120
|
this.getLibnutOrThrow('typeString').typeString(text);
|
|
144
121
|
}
|
|
@@ -211,15 +188,6 @@ class ComputerInputDriver {
|
|
|
211
188
|
this.options.debug(`Failed to release mouse button ${button}: ${error}`);
|
|
212
189
|
}
|
|
213
190
|
}
|
|
214
|
-
releaseKey(key) {
|
|
215
|
-
try {
|
|
216
|
-
const libnut = this.options.getLibnut();
|
|
217
|
-
external_node_assert_default()(libnut, 'libnut not initialized');
|
|
218
|
-
libnut.keyToggle(key, 'up');
|
|
219
|
-
} catch (error) {
|
|
220
|
-
this.options.debug(`Failed to release key ${key}: ${error}`);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
191
|
rejectPendingInputDelays() {
|
|
224
192
|
const error = this.createDestroyedError('in-flight input');
|
|
225
193
|
for (const waitRef of this.pendingInputDelayWaits){
|
|
@@ -1211,7 +1179,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1211
1179
|
}
|
|
1212
1180
|
async healthCheck(displays) {
|
|
1213
1181
|
console.log('[HealthCheck] Starting health check...');
|
|
1214
|
-
console.log("[HealthCheck] @midscene/computer v1.12.5
|
|
1182
|
+
console.log("[HealthCheck] @midscene/computer v1.12.5");
|
|
1215
1183
|
console.log('[HealthCheck] Taking screenshot...');
|
|
1216
1184
|
const screenshotTimeout = 15000;
|
|
1217
1185
|
let timeoutId;
|
|
@@ -1447,8 +1415,6 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1447
1415
|
modifiers,
|
|
1448
1416
|
driver: this.useAppleScript ? "applescript" : 'libnut'
|
|
1449
1417
|
});
|
|
1450
|
-
const shortcutDelay = this.options?.keyboardShortcutDelay ?? 0;
|
|
1451
|
-
if (!this.useAppleScript && modifiers.length > 0 && shortcutDelay > 0) return void await this.inputDriver.keyTapWithExplicitModifiers(key, modifiers, shortcutDelay);
|
|
1452
1418
|
this.inputDriver.sendKey(key, modifiers);
|
|
1453
1419
|
}
|
|
1454
1420
|
resolveUntargetedScrollPoint(screenSize) {
|
|
@@ -1728,7 +1694,6 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1728
1694
|
}
|
|
1729
1695
|
}
|
|
1730
1696
|
});
|
|
1731
|
-
if (options?.keyboardShortcutDelay !== void 0 && (!Number.isFinite(options.keyboardShortcutDelay) || options.keyboardShortcutDelay < 0)) throw new Error('keyboardShortcutDelay must be a finite non-negative number');
|
|
1732
1697
|
this.options = options;
|
|
1733
1698
|
this.displayId = options?.displayId;
|
|
1734
1699
|
this.useAppleScript = 'darwin' === process.platform && options?.keyboardDriver !== 'libnut';
|
|
@@ -2432,7 +2397,6 @@ function createLocalComputerDevice(opts) {
|
|
|
2432
2397
|
keyboardTypeDelay: opts?.keyboardTypeDelay,
|
|
2433
2398
|
inputStrategy: opts?.inputStrategy,
|
|
2434
2399
|
keyboardDriver: opts?.keyboardDriver,
|
|
2435
|
-
keyboardShortcutDelay: opts?.keyboardShortcutDelay,
|
|
2436
2400
|
headless: opts?.headless,
|
|
2437
2401
|
xvfbResolution: opts?.xvfbResolution,
|
|
2438
2402
|
keepXvfbAliveUntilProcessExit: opts?.keepXvfbAliveUntilProcessExit
|
|
@@ -2490,7 +2454,6 @@ const computerInitArgShape = {
|
|
|
2490
2454
|
headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux local mode only). Ignored when host is set.'),
|
|
2491
2455
|
keyboardTypeDelay: core_namespaceObject.z.number().finite().nonnegative().optional().describe('Finite non-negative delay in milliseconds between keystrokes. In "legacy" mode, positive values enable key-by-key input; zero or omitted uses clipboard input.'),
|
|
2492
2456
|
inputStrategy: core_namespaceObject.z["enum"](device_namespaceObject.inputStrategies).optional().describe('Text input strategy. "legacy" (default) preserves current Computer behavior, "sequential" sends one Unicode code point at a time, and "bulk" uses one backend input operation. "bulk" requires keyboardTypeDelay to be omitted or set to 0.'),
|
|
2493
|
-
keyboardShortcutDelay: core_namespaceObject.z.number().finite().nonnegative().optional().describe('Finite non-negative delay in milliseconds between modifier transitions and the main key for local libnut shortcuts. Positive values can improve compatibility with full-screen remote-control clients. Ignored in RDP mode and by the macOS AppleScript driver.'),
|
|
2494
2457
|
host: core_namespaceObject.z.string().optional().describe('RDP host (FQDN or IP). Set this to switch into RDP mode.'),
|
|
2495
2458
|
port: core_namespaceObject.z.number().optional().describe('RDP port (default 3389). Requires host.'),
|
|
2496
2459
|
username: core_namespaceObject.z.string().optional().describe('RDP username. Requires host.'),
|
|
@@ -2507,7 +2470,7 @@ const computerInitArgShape = {
|
|
|
2507
2470
|
function adaptComputerInitArgs(extracted) {
|
|
2508
2471
|
if (!extracted || 0 === Object.keys(extracted).length) return;
|
|
2509
2472
|
if (extracted.host) {
|
|
2510
|
-
const { displayId: _d, headless: _h,
|
|
2473
|
+
const { displayId: _d, headless: _h, ...rdpFields } = extracted;
|
|
2511
2474
|
const host = normalizeRdpHost(extracted.host);
|
|
2512
2475
|
return {
|
|
2513
2476
|
mode: 'rdp',
|
|
@@ -2521,7 +2484,6 @@ function adaptComputerInitArgs(extracted) {
|
|
|
2521
2484
|
headless: extracted.headless,
|
|
2522
2485
|
keyboardTypeDelay: extracted.keyboardTypeDelay,
|
|
2523
2486
|
inputStrategy: extracted.inputStrategy,
|
|
2524
|
-
keyboardShortcutDelay: extracted.keyboardShortcutDelay,
|
|
2525
2487
|
...(0, agent_behavior_init_args_namespaceObject.extractAgentBehaviorInitArgs)(extracted) ?? {}
|
|
2526
2488
|
};
|
|
2527
2489
|
}
|
|
@@ -2573,7 +2535,6 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
2573
2535
|
const headless = opts?.mode === 'local' ? opts.headless : void 0;
|
|
2574
2536
|
const keyboardTypeDelay = opts?.keyboardTypeDelay;
|
|
2575
2537
|
const inputStrategy = opts?.inputStrategy;
|
|
2576
|
-
const keyboardShortcutDelay = opts?.mode === 'local' ? opts.keyboardShortcutDelay : void 0;
|
|
2577
2538
|
agent_tools_debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
2578
2539
|
const agentOpts = {
|
|
2579
2540
|
...displayId ? {
|
|
@@ -2588,9 +2549,6 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
2588
2549
|
...void 0 !== inputStrategy ? {
|
|
2589
2550
|
inputStrategy
|
|
2590
2551
|
} : {},
|
|
2591
|
-
...void 0 !== keyboardShortcutDelay ? {
|
|
2592
|
-
keyboardShortcutDelay
|
|
2593
|
-
} : {},
|
|
2594
2552
|
...this.options.keepXvfbAliveUntilProcessExit ? {
|
|
2595
2553
|
keepXvfbAliveUntilProcessExit: true
|
|
2596
2554
|
} : {},
|
|
@@ -2675,7 +2633,7 @@ const tools = new ComputerMidsceneTools({
|
|
|
2675
2633
|
});
|
|
2676
2634
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-computer', {
|
|
2677
2635
|
stripPrefix: 'computer_',
|
|
2678
|
-
version: "1.12.5
|
|
2636
|
+
version: "1.12.5",
|
|
2679
2637
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
2680
2638
|
}).catch((e)=>{
|
|
2681
2639
|
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|
package/dist/lib/index.js
CHANGED
|
@@ -142,29 +142,6 @@ class ComputerInputDriver {
|
|
|
142
142
|
if (void 0 !== modifiers) lib.keyTap(key, modifiers);
|
|
143
143
|
else lib.keyTap(key);
|
|
144
144
|
}
|
|
145
|
-
keyToggle(key, state, modifiers) {
|
|
146
|
-
const lib = this.getLibnutOrThrow('keyToggle');
|
|
147
|
-
if (void 0 !== modifiers) lib.keyToggle(key, state, modifiers);
|
|
148
|
-
else lib.keyToggle(key, state);
|
|
149
|
-
}
|
|
150
|
-
async keyTapWithExplicitModifiers(key, modifiers, delayMs) {
|
|
151
|
-
const uniqueModifiers = [
|
|
152
|
-
...new Set(modifiers)
|
|
153
|
-
];
|
|
154
|
-
if (0 === uniqueModifiers.length) return void this.keyTap(key);
|
|
155
|
-
const pressedModifiers = [];
|
|
156
|
-
try {
|
|
157
|
-
for (const modifier of uniqueModifiers){
|
|
158
|
-
this.keyToggle(modifier, 'down');
|
|
159
|
-
pressedModifiers.push(modifier);
|
|
160
|
-
}
|
|
161
|
-
await this.delay(delayMs);
|
|
162
|
-
this.keyTap(key);
|
|
163
|
-
await this.delay(delayMs);
|
|
164
|
-
} finally{
|
|
165
|
-
for (const modifier of pressedModifiers.reverse())this.releaseKey(modifier);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
145
|
typeString(text) {
|
|
169
146
|
this.getLibnutOrThrow('typeString').typeString(text);
|
|
170
147
|
}
|
|
@@ -237,15 +214,6 @@ class ComputerInputDriver {
|
|
|
237
214
|
this.options.debug(`Failed to release mouse button ${button}: ${error}`);
|
|
238
215
|
}
|
|
239
216
|
}
|
|
240
|
-
releaseKey(key) {
|
|
241
|
-
try {
|
|
242
|
-
const libnut = this.options.getLibnut();
|
|
243
|
-
external_node_assert_default()(libnut, 'libnut not initialized');
|
|
244
|
-
libnut.keyToggle(key, 'up');
|
|
245
|
-
} catch (error) {
|
|
246
|
-
this.options.debug(`Failed to release key ${key}: ${error}`);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
217
|
rejectPendingInputDelays() {
|
|
250
218
|
const error = this.createDestroyedError('in-flight input');
|
|
251
219
|
for (const waitRef of this.pendingInputDelayWaits){
|
|
@@ -1237,7 +1205,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1237
1205
|
}
|
|
1238
1206
|
async healthCheck(displays) {
|
|
1239
1207
|
console.log('[HealthCheck] Starting health check...');
|
|
1240
|
-
console.log("[HealthCheck] @midscene/computer v1.12.5
|
|
1208
|
+
console.log("[HealthCheck] @midscene/computer v1.12.5");
|
|
1241
1209
|
console.log('[HealthCheck] Taking screenshot...');
|
|
1242
1210
|
const screenshotTimeout = 15000;
|
|
1243
1211
|
let timeoutId;
|
|
@@ -1473,8 +1441,6 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1473
1441
|
modifiers,
|
|
1474
1442
|
driver: this.useAppleScript ? "applescript" : 'libnut'
|
|
1475
1443
|
});
|
|
1476
|
-
const shortcutDelay = this.options?.keyboardShortcutDelay ?? 0;
|
|
1477
|
-
if (!this.useAppleScript && modifiers.length > 0 && shortcutDelay > 0) return void await this.inputDriver.keyTapWithExplicitModifiers(key, modifiers, shortcutDelay);
|
|
1478
1444
|
this.inputDriver.sendKey(key, modifiers);
|
|
1479
1445
|
}
|
|
1480
1446
|
resolveUntargetedScrollPoint(screenSize) {
|
|
@@ -1754,7 +1720,6 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1754
1720
|
}
|
|
1755
1721
|
}
|
|
1756
1722
|
});
|
|
1757
|
-
if (options?.keyboardShortcutDelay !== void 0 && (!Number.isFinite(options.keyboardShortcutDelay) || options.keyboardShortcutDelay < 0)) throw new Error('keyboardShortcutDelay must be a finite non-negative number');
|
|
1758
1723
|
this.options = options;
|
|
1759
1724
|
this.displayId = options?.displayId;
|
|
1760
1725
|
this.useAppleScript = 'darwin' === process.platform && options?.keyboardDriver !== 'libnut';
|
|
@@ -2502,7 +2467,6 @@ function createLocalComputerDevice(opts) {
|
|
|
2502
2467
|
keyboardTypeDelay: opts?.keyboardTypeDelay,
|
|
2503
2468
|
inputStrategy: opts?.inputStrategy,
|
|
2504
2469
|
keyboardDriver: opts?.keyboardDriver,
|
|
2505
|
-
keyboardShortcutDelay: opts?.keyboardShortcutDelay,
|
|
2506
2470
|
headless: opts?.headless,
|
|
2507
2471
|
xvfbResolution: opts?.xvfbResolution,
|
|
2508
2472
|
keepXvfbAliveUntilProcessExit: opts?.keepXvfbAliveUntilProcessExit
|
|
@@ -2563,7 +2527,6 @@ const computerInitArgShape = {
|
|
|
2563
2527
|
headless: core_namespaceObject.z.boolean().optional().describe('Start virtual display via Xvfb (Linux local mode only). Ignored when host is set.'),
|
|
2564
2528
|
keyboardTypeDelay: core_namespaceObject.z.number().finite().nonnegative().optional().describe('Finite non-negative delay in milliseconds between keystrokes. In "legacy" mode, positive values enable key-by-key input; zero or omitted uses clipboard input.'),
|
|
2565
2529
|
inputStrategy: core_namespaceObject.z["enum"](device_namespaceObject.inputStrategies).optional().describe('Text input strategy. "legacy" (default) preserves current Computer behavior, "sequential" sends one Unicode code point at a time, and "bulk" uses one backend input operation. "bulk" requires keyboardTypeDelay to be omitted or set to 0.'),
|
|
2566
|
-
keyboardShortcutDelay: core_namespaceObject.z.number().finite().nonnegative().optional().describe('Finite non-negative delay in milliseconds between modifier transitions and the main key for local libnut shortcuts. Positive values can improve compatibility with full-screen remote-control clients. Ignored in RDP mode and by the macOS AppleScript driver.'),
|
|
2567
2530
|
host: core_namespaceObject.z.string().optional().describe('RDP host (FQDN or IP). Set this to switch into RDP mode.'),
|
|
2568
2531
|
port: core_namespaceObject.z.number().optional().describe('RDP port (default 3389). Requires host.'),
|
|
2569
2532
|
username: core_namespaceObject.z.string().optional().describe('RDP username. Requires host.'),
|
|
@@ -2580,7 +2543,7 @@ const computerInitArgShape = {
|
|
|
2580
2543
|
function adaptComputerInitArgs(extracted) {
|
|
2581
2544
|
if (!extracted || 0 === Object.keys(extracted).length) return;
|
|
2582
2545
|
if (extracted.host) {
|
|
2583
|
-
const { displayId: _d, headless: _h,
|
|
2546
|
+
const { displayId: _d, headless: _h, ...rdpFields } = extracted;
|
|
2584
2547
|
const host = normalizeRdpHost(extracted.host);
|
|
2585
2548
|
return {
|
|
2586
2549
|
mode: 'rdp',
|
|
@@ -2594,7 +2557,6 @@ function adaptComputerInitArgs(extracted) {
|
|
|
2594
2557
|
headless: extracted.headless,
|
|
2595
2558
|
keyboardTypeDelay: extracted.keyboardTypeDelay,
|
|
2596
2559
|
inputStrategy: extracted.inputStrategy,
|
|
2597
|
-
keyboardShortcutDelay: extracted.keyboardShortcutDelay,
|
|
2598
2560
|
...(0, agent_behavior_init_args_namespaceObject.extractAgentBehaviorInitArgs)(extracted) ?? {}
|
|
2599
2561
|
};
|
|
2600
2562
|
}
|
|
@@ -2646,7 +2608,6 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
2646
2608
|
const headless = opts?.mode === 'local' ? opts.headless : void 0;
|
|
2647
2609
|
const keyboardTypeDelay = opts?.keyboardTypeDelay;
|
|
2648
2610
|
const inputStrategy = opts?.inputStrategy;
|
|
2649
|
-
const keyboardShortcutDelay = opts?.mode === 'local' ? opts.keyboardShortcutDelay : void 0;
|
|
2650
2611
|
agent_tools_debug('Creating Computer agent with displayId:', displayId || 'primary');
|
|
2651
2612
|
const agentOpts = {
|
|
2652
2613
|
...displayId ? {
|
|
@@ -2661,9 +2622,6 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
2661
2622
|
...void 0 !== inputStrategy ? {
|
|
2662
2623
|
inputStrategy
|
|
2663
2624
|
} : {},
|
|
2664
|
-
...void 0 !== keyboardShortcutDelay ? {
|
|
2665
|
-
keyboardShortcutDelay
|
|
2666
|
-
} : {},
|
|
2667
2625
|
...this.options.keepXvfbAliveUntilProcessExit ? {
|
|
2668
2626
|
keepXvfbAliveUntilProcessExit: true
|
|
2669
2627
|
} : {},
|
|
@@ -2745,7 +2703,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
2745
2703
|
}
|
|
2746
2704
|
const env_namespaceObject = require("@midscene/shared/env");
|
|
2747
2705
|
function version() {
|
|
2748
|
-
const currentVersion = "1.12.5
|
|
2706
|
+
const currentVersion = "1.12.5";
|
|
2749
2707
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
2750
2708
|
return currentVersion;
|
|
2751
2709
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -177,17 +177,6 @@ export declare interface ComputerDeviceOpt extends ComputerDeviceInputOpt {
|
|
|
177
177
|
* - 'libnut': Use libnut's keyTap (faster but may not work with some TUI apps)
|
|
178
178
|
*/
|
|
179
179
|
keyboardDriver?: 'applescript' | 'libnut';
|
|
180
|
-
/**
|
|
181
|
-
* Delay in milliseconds between explicit modifier transitions and the main
|
|
182
|
-
* key for local libnut shortcuts. A positive value changes modified
|
|
183
|
-
* shortcuts from one `keyTap` call into modifier-down, main-key, and
|
|
184
|
-
* modifier-up phases. This can help foreground clients whose full-screen
|
|
185
|
-
* keyboard capture misses rapidly synthesized modifier state changes.
|
|
186
|
-
*
|
|
187
|
-
* Ignored by the macOS AppleScript driver and RDP mode.
|
|
188
|
-
* @default 0
|
|
189
|
-
*/
|
|
190
|
-
keyboardShortcutDelay?: number;
|
|
191
180
|
/**
|
|
192
181
|
* Headless mode via Xvfb (Linux only).
|
|
193
182
|
* - true: start Xvfb virtual display
|
|
@@ -221,7 +210,7 @@ export declare type ComputerInterface = ComputerDevice | RDPDevice;
|
|
|
221
210
|
/** Init args for the local desktop agent (macOS/Windows/Linux). */
|
|
222
211
|
declare type ComputerLocalInitArgs = {
|
|
223
212
|
mode: 'local';
|
|
224
|
-
} & Pick<ComputerDeviceOpt, 'displayId' | 'headless'> & Pick<ComputerDeviceOpt, 'inputStrategy' | 'keyboardTypeDelay'
|
|
213
|
+
} & Pick<ComputerDeviceOpt, 'displayId' | 'headless'> & Pick<ComputerDeviceOpt, 'inputStrategy' | 'keyboardTypeDelay'> & AgentBehaviorInitArgs;
|
|
225
214
|
|
|
226
215
|
/**
|
|
227
216
|
* Computer-specific tools manager
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/computer",
|
|
3
|
-
"version": "1.12.5
|
|
3
|
+
"version": "1.12.5",
|
|
4
4
|
"description": "Midscene.js Computer Desktop Automation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@computer-use/libnut": "^4.2.0",
|
|
34
34
|
"clipboardy": "^4.0.0",
|
|
35
35
|
"screenshot-desktop": "^1.15.3",
|
|
36
|
-
"@midscene/core": "1.12.5
|
|
37
|
-
"@midscene/shared": "1.12.5
|
|
36
|
+
"@midscene/core": "1.12.5",
|
|
37
|
+
"@midscene/shared": "1.12.5"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
40
|
"node-mac-permissions": "2.5.0"
|