@midscene/computer 1.4.4 → 1.4.5-beta-20260214073330.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 +2 -25
- package/dist/es/index.mjs +2 -25
- package/dist/es/mcp-server.mjs +2 -25
- package/dist/lib/cli.js +2 -25
- package/dist/lib/index.js +2 -25
- package/dist/lib/mcp-server.js +2 -25
- package/dist/types/index.d.ts +3 -10
- package/dist/types/mcp-server.d.ts +3 -10
- package/package.json +3 -3
package/dist/es/cli.mjs
CHANGED
|
@@ -31,8 +31,6 @@ const INPUT_CLEAR_DELAY = 150;
|
|
|
31
31
|
const SCROLL_REPEAT_COUNT = 10;
|
|
32
32
|
const SCROLL_STEP_DELAY = 100;
|
|
33
33
|
const SCROLL_COMPLETE_DELAY = 500;
|
|
34
|
-
const INPUT_STRATEGY_ALWAYS_CLIPBOARD = 'always-clipboard';
|
|
35
|
-
const INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII = 'clipboard-for-non-ascii';
|
|
36
34
|
const APPLESCRIPT_KEY_CODE_MAP = {
|
|
37
35
|
return: 36,
|
|
38
36
|
enter: 36,
|
|
@@ -73,14 +71,6 @@ const APPLESCRIPT_MODIFIER_MAP = {
|
|
|
73
71
|
option: 'option down',
|
|
74
72
|
meta: 'command down'
|
|
75
73
|
};
|
|
76
|
-
function typeStringViaAppleScript(text) {
|
|
77
|
-
const escaped = text.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
78
|
-
const script = `tell application "System Events" to keystroke "${escaped}"`;
|
|
79
|
-
debugDevice('typeStringViaAppleScript', {
|
|
80
|
-
text
|
|
81
|
-
});
|
|
82
|
-
execSync(`osascript -e '${script}'`);
|
|
83
|
-
}
|
|
84
74
|
function sendKeyViaAppleScript(key, modifiers = []) {
|
|
85
75
|
const lowerKey = key.toLowerCase();
|
|
86
76
|
const keyCode = APPLESCRIPT_KEY_CODE_MAP[lowerKey];
|
|
@@ -240,6 +230,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
240
230
|
console.log('[HealthCheck] Health check passed');
|
|
241
231
|
}
|
|
242
232
|
async screenshotBase64() {
|
|
233
|
+
if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
|
|
243
234
|
debugDevice('Taking screenshot', {
|
|
244
235
|
displayId: this.displayId
|
|
245
236
|
});
|
|
@@ -273,10 +264,6 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
273
264
|
throw new Error(`Failed to get screen size: ${error}`);
|
|
274
265
|
}
|
|
275
266
|
}
|
|
276
|
-
shouldUseClipboardForText(text) {
|
|
277
|
-
const hasNonAscii = /[\x80-\uFFFF]/.test(text);
|
|
278
|
-
return hasNonAscii;
|
|
279
|
-
}
|
|
280
267
|
async typeViaClipboard(text) {
|
|
281
268
|
node_assert(libnut, 'libnut not initialized');
|
|
282
269
|
debugDevice('Using clipboard to input text', {
|
|
@@ -306,17 +293,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
306
293
|
}
|
|
307
294
|
async smartTypeString(text) {
|
|
308
295
|
node_assert(libnut, 'libnut not initialized');
|
|
309
|
-
|
|
310
|
-
if (this.useAppleScript) if (this.shouldUseClipboardForText(text)) await this.typeViaClipboard(text);
|
|
311
|
-
else typeStringViaAppleScript(text);
|
|
312
|
-
else libnut.typeString(text);
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const inputStrategy = this.options?.inputStrategy ?? INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII;
|
|
316
|
-
if (inputStrategy === INPUT_STRATEGY_ALWAYS_CLIPBOARD) return void await this.typeViaClipboard(text);
|
|
317
|
-
const shouldUseClipboard = this.shouldUseClipboardForText(text);
|
|
318
|
-
if (shouldUseClipboard) await this.typeViaClipboard(text);
|
|
319
|
-
else libnut.typeString(text);
|
|
296
|
+
await this.typeViaClipboard(text);
|
|
320
297
|
}
|
|
321
298
|
actionSpace() {
|
|
322
299
|
const defaultActions = [
|
package/dist/es/index.mjs
CHANGED
|
@@ -30,8 +30,6 @@ const INPUT_CLEAR_DELAY = 150;
|
|
|
30
30
|
const SCROLL_REPEAT_COUNT = 10;
|
|
31
31
|
const SCROLL_STEP_DELAY = 100;
|
|
32
32
|
const SCROLL_COMPLETE_DELAY = 500;
|
|
33
|
-
const INPUT_STRATEGY_ALWAYS_CLIPBOARD = 'always-clipboard';
|
|
34
|
-
const INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII = 'clipboard-for-non-ascii';
|
|
35
33
|
const APPLESCRIPT_KEY_CODE_MAP = {
|
|
36
34
|
return: 36,
|
|
37
35
|
enter: 36,
|
|
@@ -72,14 +70,6 @@ const APPLESCRIPT_MODIFIER_MAP = {
|
|
|
72
70
|
option: 'option down',
|
|
73
71
|
meta: 'command down'
|
|
74
72
|
};
|
|
75
|
-
function typeStringViaAppleScript(text) {
|
|
76
|
-
const escaped = text.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
77
|
-
const script = `tell application "System Events" to keystroke "${escaped}"`;
|
|
78
|
-
debugDevice('typeStringViaAppleScript', {
|
|
79
|
-
text
|
|
80
|
-
});
|
|
81
|
-
execSync(`osascript -e '${script}'`);
|
|
82
|
-
}
|
|
83
73
|
function sendKeyViaAppleScript(key, modifiers = []) {
|
|
84
74
|
const lowerKey = key.toLowerCase();
|
|
85
75
|
const keyCode = APPLESCRIPT_KEY_CODE_MAP[lowerKey];
|
|
@@ -239,6 +229,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
239
229
|
console.log('[HealthCheck] Health check passed');
|
|
240
230
|
}
|
|
241
231
|
async screenshotBase64() {
|
|
232
|
+
if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
|
|
242
233
|
debugDevice('Taking screenshot', {
|
|
243
234
|
displayId: this.displayId
|
|
244
235
|
});
|
|
@@ -272,10 +263,6 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
272
263
|
throw new Error(`Failed to get screen size: ${error}`);
|
|
273
264
|
}
|
|
274
265
|
}
|
|
275
|
-
shouldUseClipboardForText(text) {
|
|
276
|
-
const hasNonAscii = /[\x80-\uFFFF]/.test(text);
|
|
277
|
-
return hasNonAscii;
|
|
278
|
-
}
|
|
279
266
|
async typeViaClipboard(text) {
|
|
280
267
|
node_assert(device_libnut, 'libnut not initialized');
|
|
281
268
|
debugDevice('Using clipboard to input text', {
|
|
@@ -305,17 +292,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
305
292
|
}
|
|
306
293
|
async smartTypeString(text) {
|
|
307
294
|
node_assert(device_libnut, 'libnut not initialized');
|
|
308
|
-
|
|
309
|
-
if (this.useAppleScript) if (this.shouldUseClipboardForText(text)) await this.typeViaClipboard(text);
|
|
310
|
-
else typeStringViaAppleScript(text);
|
|
311
|
-
else device_libnut.typeString(text);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
const inputStrategy = this.options?.inputStrategy ?? INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII;
|
|
315
|
-
if (inputStrategy === INPUT_STRATEGY_ALWAYS_CLIPBOARD) return void await this.typeViaClipboard(text);
|
|
316
|
-
const shouldUseClipboard = this.shouldUseClipboardForText(text);
|
|
317
|
-
if (shouldUseClipboard) await this.typeViaClipboard(text);
|
|
318
|
-
else device_libnut.typeString(text);
|
|
295
|
+
await this.typeViaClipboard(text);
|
|
319
296
|
}
|
|
320
297
|
actionSpace() {
|
|
321
298
|
const defaultActions = [
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -30,8 +30,6 @@ const INPUT_CLEAR_DELAY = 150;
|
|
|
30
30
|
const SCROLL_REPEAT_COUNT = 10;
|
|
31
31
|
const SCROLL_STEP_DELAY = 100;
|
|
32
32
|
const SCROLL_COMPLETE_DELAY = 500;
|
|
33
|
-
const INPUT_STRATEGY_ALWAYS_CLIPBOARD = 'always-clipboard';
|
|
34
|
-
const INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII = 'clipboard-for-non-ascii';
|
|
35
33
|
const APPLESCRIPT_KEY_CODE_MAP = {
|
|
36
34
|
return: 36,
|
|
37
35
|
enter: 36,
|
|
@@ -72,14 +70,6 @@ const APPLESCRIPT_MODIFIER_MAP = {
|
|
|
72
70
|
option: 'option down',
|
|
73
71
|
meta: 'command down'
|
|
74
72
|
};
|
|
75
|
-
function typeStringViaAppleScript(text) {
|
|
76
|
-
const escaped = text.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
77
|
-
const script = `tell application "System Events" to keystroke "${escaped}"`;
|
|
78
|
-
debugDevice('typeStringViaAppleScript', {
|
|
79
|
-
text
|
|
80
|
-
});
|
|
81
|
-
execSync(`osascript -e '${script}'`);
|
|
82
|
-
}
|
|
83
73
|
function sendKeyViaAppleScript(key, modifiers = []) {
|
|
84
74
|
const lowerKey = key.toLowerCase();
|
|
85
75
|
const keyCode = APPLESCRIPT_KEY_CODE_MAP[lowerKey];
|
|
@@ -239,6 +229,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
239
229
|
console.log('[HealthCheck] Health check passed');
|
|
240
230
|
}
|
|
241
231
|
async screenshotBase64() {
|
|
232
|
+
if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
|
|
242
233
|
debugDevice('Taking screenshot', {
|
|
243
234
|
displayId: this.displayId
|
|
244
235
|
});
|
|
@@ -272,10 +263,6 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
272
263
|
throw new Error(`Failed to get screen size: ${error}`);
|
|
273
264
|
}
|
|
274
265
|
}
|
|
275
|
-
shouldUseClipboardForText(text) {
|
|
276
|
-
const hasNonAscii = /[\x80-\uFFFF]/.test(text);
|
|
277
|
-
return hasNonAscii;
|
|
278
|
-
}
|
|
279
266
|
async typeViaClipboard(text) {
|
|
280
267
|
node_assert(libnut, 'libnut not initialized');
|
|
281
268
|
debugDevice('Using clipboard to input text', {
|
|
@@ -305,17 +292,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
305
292
|
}
|
|
306
293
|
async smartTypeString(text) {
|
|
307
294
|
node_assert(libnut, 'libnut not initialized');
|
|
308
|
-
|
|
309
|
-
if (this.useAppleScript) if (this.shouldUseClipboardForText(text)) await this.typeViaClipboard(text);
|
|
310
|
-
else typeStringViaAppleScript(text);
|
|
311
|
-
else libnut.typeString(text);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
const inputStrategy = this.options?.inputStrategy ?? INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII;
|
|
315
|
-
if (inputStrategy === INPUT_STRATEGY_ALWAYS_CLIPBOARD) return void await this.typeViaClipboard(text);
|
|
316
|
-
const shouldUseClipboard = this.shouldUseClipboardForText(text);
|
|
317
|
-
if (shouldUseClipboard) await this.typeViaClipboard(text);
|
|
318
|
-
else libnut.typeString(text);
|
|
295
|
+
await this.typeViaClipboard(text);
|
|
319
296
|
}
|
|
320
297
|
actionSpace() {
|
|
321
298
|
const defaultActions = [
|
package/dist/lib/cli.js
CHANGED
|
@@ -59,8 +59,6 @@ const INPUT_CLEAR_DELAY = 150;
|
|
|
59
59
|
const SCROLL_REPEAT_COUNT = 10;
|
|
60
60
|
const SCROLL_STEP_DELAY = 100;
|
|
61
61
|
const SCROLL_COMPLETE_DELAY = 500;
|
|
62
|
-
const INPUT_STRATEGY_ALWAYS_CLIPBOARD = 'always-clipboard';
|
|
63
|
-
const INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII = 'clipboard-for-non-ascii';
|
|
64
62
|
const APPLESCRIPT_KEY_CODE_MAP = {
|
|
65
63
|
return: 36,
|
|
66
64
|
enter: 36,
|
|
@@ -101,14 +99,6 @@ const APPLESCRIPT_MODIFIER_MAP = {
|
|
|
101
99
|
option: 'option down',
|
|
102
100
|
meta: 'command down'
|
|
103
101
|
};
|
|
104
|
-
function typeStringViaAppleScript(text) {
|
|
105
|
-
const escaped = text.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
106
|
-
const script = `tell application "System Events" to keystroke "${escaped}"`;
|
|
107
|
-
debugDevice('typeStringViaAppleScript', {
|
|
108
|
-
text
|
|
109
|
-
});
|
|
110
|
-
(0, external_node_child_process_namespaceObject.execSync)(`osascript -e '${script}'`);
|
|
111
|
-
}
|
|
112
102
|
function sendKeyViaAppleScript(key, modifiers = []) {
|
|
113
103
|
const lowerKey = key.toLowerCase();
|
|
114
104
|
const keyCode = APPLESCRIPT_KEY_CODE_MAP[lowerKey];
|
|
@@ -268,6 +258,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
268
258
|
console.log('[HealthCheck] Health check passed');
|
|
269
259
|
}
|
|
270
260
|
async screenshotBase64() {
|
|
261
|
+
if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
|
|
271
262
|
debugDevice('Taking screenshot', {
|
|
272
263
|
displayId: this.displayId
|
|
273
264
|
});
|
|
@@ -301,10 +292,6 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
301
292
|
throw new Error(`Failed to get screen size: ${error}`);
|
|
302
293
|
}
|
|
303
294
|
}
|
|
304
|
-
shouldUseClipboardForText(text) {
|
|
305
|
-
const hasNonAscii = /[\x80-\uFFFF]/.test(text);
|
|
306
|
-
return hasNonAscii;
|
|
307
|
-
}
|
|
308
295
|
async typeViaClipboard(text) {
|
|
309
296
|
external_node_assert_default()(libnut, 'libnut not initialized');
|
|
310
297
|
debugDevice('Using clipboard to input text', {
|
|
@@ -334,17 +321,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
334
321
|
}
|
|
335
322
|
async smartTypeString(text) {
|
|
336
323
|
external_node_assert_default()(libnut, 'libnut not initialized');
|
|
337
|
-
|
|
338
|
-
if (this.useAppleScript) if (this.shouldUseClipboardForText(text)) await this.typeViaClipboard(text);
|
|
339
|
-
else typeStringViaAppleScript(text);
|
|
340
|
-
else libnut.typeString(text);
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
const inputStrategy = this.options?.inputStrategy ?? INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII;
|
|
344
|
-
if (inputStrategy === INPUT_STRATEGY_ALWAYS_CLIPBOARD) return void await this.typeViaClipboard(text);
|
|
345
|
-
const shouldUseClipboard = this.shouldUseClipboardForText(text);
|
|
346
|
-
if (shouldUseClipboard) await this.typeViaClipboard(text);
|
|
347
|
-
else libnut.typeString(text);
|
|
324
|
+
await this.typeViaClipboard(text);
|
|
348
325
|
}
|
|
349
326
|
actionSpace() {
|
|
350
327
|
const defaultActions = [
|
package/dist/lib/index.js
CHANGED
|
@@ -76,8 +76,6 @@ const INPUT_CLEAR_DELAY = 150;
|
|
|
76
76
|
const SCROLL_REPEAT_COUNT = 10;
|
|
77
77
|
const SCROLL_STEP_DELAY = 100;
|
|
78
78
|
const SCROLL_COMPLETE_DELAY = 500;
|
|
79
|
-
const INPUT_STRATEGY_ALWAYS_CLIPBOARD = 'always-clipboard';
|
|
80
|
-
const INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII = 'clipboard-for-non-ascii';
|
|
81
79
|
const APPLESCRIPT_KEY_CODE_MAP = {
|
|
82
80
|
return: 36,
|
|
83
81
|
enter: 36,
|
|
@@ -118,14 +116,6 @@ const APPLESCRIPT_MODIFIER_MAP = {
|
|
|
118
116
|
option: 'option down',
|
|
119
117
|
meta: 'command down'
|
|
120
118
|
};
|
|
121
|
-
function typeStringViaAppleScript(text) {
|
|
122
|
-
const escaped = text.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
123
|
-
const script = `tell application "System Events" to keystroke "${escaped}"`;
|
|
124
|
-
debugDevice('typeStringViaAppleScript', {
|
|
125
|
-
text
|
|
126
|
-
});
|
|
127
|
-
(0, external_node_child_process_namespaceObject.execSync)(`osascript -e '${script}'`);
|
|
128
|
-
}
|
|
129
119
|
function sendKeyViaAppleScript(key, modifiers = []) {
|
|
130
120
|
const lowerKey = key.toLowerCase();
|
|
131
121
|
const keyCode = APPLESCRIPT_KEY_CODE_MAP[lowerKey];
|
|
@@ -285,6 +275,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
285
275
|
console.log('[HealthCheck] Health check passed');
|
|
286
276
|
}
|
|
287
277
|
async screenshotBase64() {
|
|
278
|
+
if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
|
|
288
279
|
debugDevice('Taking screenshot', {
|
|
289
280
|
displayId: this.displayId
|
|
290
281
|
});
|
|
@@ -318,10 +309,6 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
318
309
|
throw new Error(`Failed to get screen size: ${error}`);
|
|
319
310
|
}
|
|
320
311
|
}
|
|
321
|
-
shouldUseClipboardForText(text) {
|
|
322
|
-
const hasNonAscii = /[\x80-\uFFFF]/.test(text);
|
|
323
|
-
return hasNonAscii;
|
|
324
|
-
}
|
|
325
312
|
async typeViaClipboard(text) {
|
|
326
313
|
external_node_assert_default()(device_libnut, 'libnut not initialized');
|
|
327
314
|
debugDevice('Using clipboard to input text', {
|
|
@@ -351,17 +338,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
351
338
|
}
|
|
352
339
|
async smartTypeString(text) {
|
|
353
340
|
external_node_assert_default()(device_libnut, 'libnut not initialized');
|
|
354
|
-
|
|
355
|
-
if (this.useAppleScript) if (this.shouldUseClipboardForText(text)) await this.typeViaClipboard(text);
|
|
356
|
-
else typeStringViaAppleScript(text);
|
|
357
|
-
else device_libnut.typeString(text);
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
const inputStrategy = this.options?.inputStrategy ?? INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII;
|
|
361
|
-
if (inputStrategy === INPUT_STRATEGY_ALWAYS_CLIPBOARD) return void await this.typeViaClipboard(text);
|
|
362
|
-
const shouldUseClipboard = this.shouldUseClipboardForText(text);
|
|
363
|
-
if (shouldUseClipboard) await this.typeViaClipboard(text);
|
|
364
|
-
else device_libnut.typeString(text);
|
|
341
|
+
await this.typeViaClipboard(text);
|
|
365
342
|
}
|
|
366
343
|
actionSpace() {
|
|
367
344
|
const defaultActions = [
|
package/dist/lib/mcp-server.js
CHANGED
|
@@ -74,8 +74,6 @@ const INPUT_CLEAR_DELAY = 150;
|
|
|
74
74
|
const SCROLL_REPEAT_COUNT = 10;
|
|
75
75
|
const SCROLL_STEP_DELAY = 100;
|
|
76
76
|
const SCROLL_COMPLETE_DELAY = 500;
|
|
77
|
-
const INPUT_STRATEGY_ALWAYS_CLIPBOARD = 'always-clipboard';
|
|
78
|
-
const INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII = 'clipboard-for-non-ascii';
|
|
79
77
|
const APPLESCRIPT_KEY_CODE_MAP = {
|
|
80
78
|
return: 36,
|
|
81
79
|
enter: 36,
|
|
@@ -116,14 +114,6 @@ const APPLESCRIPT_MODIFIER_MAP = {
|
|
|
116
114
|
option: 'option down',
|
|
117
115
|
meta: 'command down'
|
|
118
116
|
};
|
|
119
|
-
function typeStringViaAppleScript(text) {
|
|
120
|
-
const escaped = text.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
121
|
-
const script = `tell application "System Events" to keystroke "${escaped}"`;
|
|
122
|
-
debugDevice('typeStringViaAppleScript', {
|
|
123
|
-
text
|
|
124
|
-
});
|
|
125
|
-
(0, external_node_child_process_namespaceObject.execSync)(`osascript -e '${script}'`);
|
|
126
|
-
}
|
|
127
117
|
function sendKeyViaAppleScript(key, modifiers = []) {
|
|
128
118
|
const lowerKey = key.toLowerCase();
|
|
129
119
|
const keyCode = APPLESCRIPT_KEY_CODE_MAP[lowerKey];
|
|
@@ -283,6 +273,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
283
273
|
console.log('[HealthCheck] Health check passed');
|
|
284
274
|
}
|
|
285
275
|
async screenshotBase64() {
|
|
276
|
+
if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
|
|
286
277
|
debugDevice('Taking screenshot', {
|
|
287
278
|
displayId: this.displayId
|
|
288
279
|
});
|
|
@@ -316,10 +307,6 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
316
307
|
throw new Error(`Failed to get screen size: ${error}`);
|
|
317
308
|
}
|
|
318
309
|
}
|
|
319
|
-
shouldUseClipboardForText(text) {
|
|
320
|
-
const hasNonAscii = /[\x80-\uFFFF]/.test(text);
|
|
321
|
-
return hasNonAscii;
|
|
322
|
-
}
|
|
323
310
|
async typeViaClipboard(text) {
|
|
324
311
|
external_node_assert_default()(libnut, 'libnut not initialized');
|
|
325
312
|
debugDevice('Using clipboard to input text', {
|
|
@@ -349,17 +336,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
349
336
|
}
|
|
350
337
|
async smartTypeString(text) {
|
|
351
338
|
external_node_assert_default()(libnut, 'libnut not initialized');
|
|
352
|
-
|
|
353
|
-
if (this.useAppleScript) if (this.shouldUseClipboardForText(text)) await this.typeViaClipboard(text);
|
|
354
|
-
else typeStringViaAppleScript(text);
|
|
355
|
-
else libnut.typeString(text);
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
const inputStrategy = this.options?.inputStrategy ?? INPUT_STRATEGY_CLIPBOARD_FOR_NON_ASCII;
|
|
359
|
-
if (inputStrategy === INPUT_STRATEGY_ALWAYS_CLIPBOARD) return void await this.typeViaClipboard(text);
|
|
360
|
-
const shouldUseClipboard = this.shouldUseClipboardForText(text);
|
|
361
|
-
if (shouldUseClipboard) await this.typeViaClipboard(text);
|
|
362
|
-
else libnut.typeString(text);
|
|
339
|
+
await this.typeViaClipboard(text);
|
|
363
340
|
}
|
|
364
341
|
actionSpace() {
|
|
365
342
|
const defaultActions = [
|
package/dist/types/index.d.ts
CHANGED
|
@@ -57,11 +57,6 @@ export declare class ComputerDevice implements AbstractInterface {
|
|
|
57
57
|
private healthCheck;
|
|
58
58
|
screenshotBase64(): Promise<string>;
|
|
59
59
|
size(): Promise<Size>;
|
|
60
|
-
/**
|
|
61
|
-
* Check if text contains non-ASCII characters
|
|
62
|
-
* Matches: Chinese, Japanese, Korean, Latin extended characters (café, niño), emoji, etc.
|
|
63
|
-
*/
|
|
64
|
-
private shouldUseClipboardForText;
|
|
65
60
|
/**
|
|
66
61
|
* Type text via clipboard (paste)
|
|
67
62
|
* This method:
|
|
@@ -72,10 +67,9 @@ export declare class ComputerDevice implements AbstractInterface {
|
|
|
72
67
|
*/
|
|
73
68
|
private typeViaClipboard;
|
|
74
69
|
/**
|
|
75
|
-
*
|
|
76
|
-
* -
|
|
77
|
-
*
|
|
78
|
-
* - Windows/Linux: Use clipboard for non-ASCII characters
|
|
70
|
+
* Always use clipboard paste to input text, avoiding IME interference.
|
|
71
|
+
* Keystroke-based input (AppleScript/libnut) goes through the active input method,
|
|
72
|
+
* which can swallow characters or convert them when a non-English IME is active.
|
|
79
73
|
*/
|
|
80
74
|
private smartTypeString;
|
|
81
75
|
actionSpace(): DeviceAction<any>[];
|
|
@@ -86,7 +80,6 @@ export declare class ComputerDevice implements AbstractInterface {
|
|
|
86
80
|
export declare interface ComputerDeviceOpt {
|
|
87
81
|
displayId?: string;
|
|
88
82
|
customActions?: DeviceAction<any>[];
|
|
89
|
-
inputStrategy?: 'always-clipboard' | 'clipboard-for-non-ascii';
|
|
90
83
|
/**
|
|
91
84
|
* Keyboard driver for sending key events (macOS only)
|
|
92
85
|
* - 'applescript': Use AppleScript via osascript (default on macOS, more reliable)
|
|
@@ -35,11 +35,6 @@ declare class ComputerDevice implements AbstractInterface {
|
|
|
35
35
|
private healthCheck;
|
|
36
36
|
screenshotBase64(): Promise<string>;
|
|
37
37
|
size(): Promise<Size>;
|
|
38
|
-
/**
|
|
39
|
-
* Check if text contains non-ASCII characters
|
|
40
|
-
* Matches: Chinese, Japanese, Korean, Latin extended characters (café, niño), emoji, etc.
|
|
41
|
-
*/
|
|
42
|
-
private shouldUseClipboardForText;
|
|
43
38
|
/**
|
|
44
39
|
* Type text via clipboard (paste)
|
|
45
40
|
* This method:
|
|
@@ -50,10 +45,9 @@ declare class ComputerDevice implements AbstractInterface {
|
|
|
50
45
|
*/
|
|
51
46
|
private typeViaClipboard;
|
|
52
47
|
/**
|
|
53
|
-
*
|
|
54
|
-
* -
|
|
55
|
-
*
|
|
56
|
-
* - Windows/Linux: Use clipboard for non-ASCII characters
|
|
48
|
+
* Always use clipboard paste to input text, avoiding IME interference.
|
|
49
|
+
* Keystroke-based input (AppleScript/libnut) goes through the active input method,
|
|
50
|
+
* which can swallow characters or convert them when a non-English IME is active.
|
|
57
51
|
*/
|
|
58
52
|
private smartTypeString;
|
|
59
53
|
actionSpace(): DeviceAction<any>[];
|
|
@@ -64,7 +58,6 @@ declare class ComputerDevice implements AbstractInterface {
|
|
|
64
58
|
declare interface ComputerDeviceOpt {
|
|
65
59
|
displayId?: string;
|
|
66
60
|
customActions?: DeviceAction<any>[];
|
|
67
|
-
inputStrategy?: 'always-clipboard' | 'clipboard-for-non-ascii';
|
|
68
61
|
/**
|
|
69
62
|
* Keyboard driver for sending key events (macOS only)
|
|
70
63
|
* - 'applescript': Use AppleScript via osascript (default on macOS, more reliable)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/computer",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5-beta-20260214073330.0",
|
|
4
4
|
"description": "Midscene.js Computer Desktop Automation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@computer-use/libnut": "^4.2.0",
|
|
37
37
|
"clipboardy": "^4.0.0",
|
|
38
38
|
"screenshot-desktop": "^1.15.3",
|
|
39
|
-
"@midscene/core": "1.4.
|
|
40
|
-
"@midscene/shared": "1.4.
|
|
39
|
+
"@midscene/core": "1.4.5-beta-20260214073330.0",
|
|
40
|
+
"@midscene/shared": "1.4.5-beta-20260214073330.0"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
43
|
"node-mac-permissions": "2.5.0"
|