@midscene/computer 1.2.3-beta-20260122071913.0 → 1.2.3-beta-20260123062401.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/index.mjs +38 -1
- package/dist/es/mcp-server.mjs +38 -1
- package/dist/lib/index.js +39 -1
- package/dist/lib/mcp-server.js +39 -1
- package/dist/types/index.d.ts +21 -0
- package/dist/types/mcp-server.d.ts +21 -0
- package/package.json +4 -3
- package/src/device.ts +88 -1
- package/tests/ai/chinese-input.test.ts +153 -0
- package/tests/unit-test/input-strategy.test.ts +58 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { ComputerDevice } from '../../src';
|
|
3
|
+
|
|
4
|
+
describe('Input Strategy', () => {
|
|
5
|
+
it('should create device with default input strategy', () => {
|
|
6
|
+
const device = new ComputerDevice({});
|
|
7
|
+
expect(device).toBeDefined();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should create device with always-clipboard strategy', () => {
|
|
11
|
+
const device = new ComputerDevice({
|
|
12
|
+
inputStrategy: 'always-clipboard',
|
|
13
|
+
});
|
|
14
|
+
expect(device).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should create device with clipboard-for-non-ascii strategy', () => {
|
|
18
|
+
const device = new ComputerDevice({
|
|
19
|
+
inputStrategy: 'clipboard-for-non-ascii',
|
|
20
|
+
});
|
|
21
|
+
expect(device).toBeDefined();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should detect non-ASCII characters correctly', () => {
|
|
25
|
+
// Test regex pattern used in shouldUseClipboardForText
|
|
26
|
+
const nonAsciiRegex = /[\x80-\uFFFF]/;
|
|
27
|
+
|
|
28
|
+
// ASCII characters (should not match)
|
|
29
|
+
expect(nonAsciiRegex.test('Hello World')).toBe(false);
|
|
30
|
+
expect(nonAsciiRegex.test('hello123')).toBe(false);
|
|
31
|
+
expect(nonAsciiRegex.test('test@example.com')).toBe(false);
|
|
32
|
+
expect(nonAsciiRegex.test('abc_def-ghi')).toBe(false);
|
|
33
|
+
|
|
34
|
+
// Non-ASCII characters (should match)
|
|
35
|
+
expect(nonAsciiRegex.test('你好世界')).toBe(true); // Chinese
|
|
36
|
+
expect(nonAsciiRegex.test('こんにちは')).toBe(true); // Japanese
|
|
37
|
+
expect(nonAsciiRegex.test('안녕하세요')).toBe(true); // Korean
|
|
38
|
+
expect(nonAsciiRegex.test('café')).toBe(true); // Latin extended
|
|
39
|
+
expect(nonAsciiRegex.test('niño')).toBe(true); // Latin extended
|
|
40
|
+
expect(nonAsciiRegex.test('😀🎉')).toBe(true); // Emoji
|
|
41
|
+
expect(nonAsciiRegex.test('Привет')).toBe(true); // Cyrillic
|
|
42
|
+
|
|
43
|
+
// Mixed text (should match)
|
|
44
|
+
expect(nonAsciiRegex.test('Hello 你好')).toBe(true);
|
|
45
|
+
expect(nonAsciiRegex.test('test café')).toBe(true);
|
|
46
|
+
expect(nonAsciiRegex.test('abc 😀')).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should have Input action in action space', () => {
|
|
50
|
+
const device = new ComputerDevice({});
|
|
51
|
+
const actions = device.actionSpace();
|
|
52
|
+
|
|
53
|
+
const inputAction = actions.find((a) => a.name === 'Input');
|
|
54
|
+
expect(inputAction).toBeDefined();
|
|
55
|
+
expect(inputAction?.name).toBe('Input');
|
|
56
|
+
expect(inputAction?.description).toBe('Input text into the input field');
|
|
57
|
+
});
|
|
58
|
+
});
|