uwonbot 1.2.6 → 1.2.8
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/package.json +1 -1
- package/src/agent.js +28 -44
package/package.json
CHANGED
package/src/agent.js
CHANGED
|
@@ -61,42 +61,30 @@ const platform = process.platform;
|
|
|
61
61
|
let robot = null;
|
|
62
62
|
let screenshotDesktop = null;
|
|
63
63
|
|
|
64
|
-
async function checkAccessibility() {
|
|
65
|
-
if (platform !== 'darwin') return true;
|
|
66
|
-
try {
|
|
67
|
-
const perms = await import('@nut-tree-fork/node-mac-permissions');
|
|
68
|
-
const p = perms.default || perms;
|
|
69
|
-
const status = p.getAuthStatus('accessibility');
|
|
70
|
-
if (status === 'authorized') return true;
|
|
71
|
-
console.log(chalk.yellow(` ⚠ 손쉬운 사용 권한: ${status}`));
|
|
72
|
-
console.log(chalk.yellow(' 시스템 설정 > 개인정보 보호 및 보안 > 손쉬운 사용에서 터미널을 허용해주세요.'));
|
|
73
|
-
return false;
|
|
74
|
-
} catch { return true; }
|
|
75
|
-
}
|
|
76
|
-
|
|
77
64
|
async function loadNativeModules() {
|
|
78
|
-
|
|
65
|
+
robot = null;
|
|
79
66
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
console.log(chalk.green(' ✓ nut-js loaded (mouse/keyboard control)'));
|
|
87
|
-
if (!accessOk) {
|
|
88
|
-
console.log(chalk.yellow(' ⚠ 접근성 권한이 없어 CoreGraphics 폴백을 사용합니다.'));
|
|
67
|
+
if (platform === 'darwin') {
|
|
68
|
+
try {
|
|
69
|
+
await execAsync(`osascript -l JavaScript -e 'ObjC.import("CoreGraphics"); 0'`);
|
|
70
|
+
console.log(chalk.green(' ✓ CoreGraphics 네이티브 마우스/키보드 제어'));
|
|
71
|
+
} catch {
|
|
72
|
+
console.log(chalk.red(' ✗ CoreGraphics 사용 불가'));
|
|
89
73
|
}
|
|
90
|
-
}
|
|
74
|
+
} else {
|
|
91
75
|
try {
|
|
92
|
-
|
|
93
|
-
robot
|
|
94
|
-
|
|
76
|
+
robot = (await import('@nut-tree-fork/nut-js')).default || (await import('@nut-tree-fork/nut-js'));
|
|
77
|
+
if (robot.mouse) {
|
|
78
|
+
robot.mouse.config.autoDelayMs = 0;
|
|
79
|
+
robot.mouse.config.mouseSpeed = 2000;
|
|
80
|
+
}
|
|
81
|
+
console.log(chalk.green(' ✓ nut-js loaded (mouse/keyboard control)'));
|
|
95
82
|
} catch {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
83
|
+
try {
|
|
84
|
+
const rjs = await import('robotjs');
|
|
85
|
+
robot = rjs.default || rjs;
|
|
86
|
+
console.log(chalk.green(' ✓ robotjs loaded (mouse/keyboard control)'));
|
|
87
|
+
} catch {
|
|
100
88
|
console.log(chalk.yellow(' ⚠ No mouse/keyboard module found.'));
|
|
101
89
|
console.log(chalk.yellow(' Install: npm install -g @nut-tree-fork/nut-js'));
|
|
102
90
|
}
|
|
@@ -108,19 +96,9 @@ async function loadNativeModules() {
|
|
|
108
96
|
screenshotDesktop = mod.default || mod;
|
|
109
97
|
console.log(chalk.green(' ✓ screenshot-desktop loaded'));
|
|
110
98
|
} catch {
|
|
111
|
-
console.log(chalk.yellow(' ⚠ screenshot-desktop not found.'));
|
|
112
99
|
screenshotDesktop = null;
|
|
113
100
|
}
|
|
114
101
|
|
|
115
|
-
if (platform === 'darwin' && !robot) {
|
|
116
|
-
try {
|
|
117
|
-
await execAsync(`osascript -l JavaScript -e 'ObjC.import("CoreGraphics"); 0'`);
|
|
118
|
-
console.log(chalk.green(' ✓ CoreGraphics 마우스 제어 테스트 성공'));
|
|
119
|
-
} catch {
|
|
120
|
-
console.log(chalk.red(' ✗ CoreGraphics 사용 불가'));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
102
|
const screen = await getScreenSize();
|
|
125
103
|
console.log(chalk.gray(` Screen: ${screen.width}x${screen.height}`));
|
|
126
104
|
}
|
|
@@ -128,9 +106,15 @@ async function loadNativeModules() {
|
|
|
128
106
|
async function getScreenSize() {
|
|
129
107
|
if (platform === 'darwin') {
|
|
130
108
|
try {
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
|
|
109
|
+
const script = `ObjC.import("CoreGraphics"); var d = $.CGMainDisplayID(); var w = $.CGDisplayPixelsWide(d); var h = $.CGDisplayPixelsHigh(d); JSON.stringify({w:w,h:h})`;
|
|
110
|
+
const { stdout } = await execAsync(`osascript -l JavaScript -e '${script}'`, { timeout: 3000 });
|
|
111
|
+
const parsed = JSON.parse(stdout.trim());
|
|
112
|
+
if (parsed.w && parsed.h) return { width: Number(parsed.w), height: Number(parsed.h) };
|
|
113
|
+
} catch {}
|
|
114
|
+
try {
|
|
115
|
+
const { stdout } = await execAsync(`system_profiler SPDisplaysDataType 2>/dev/null | grep Resolution | head -1`, { timeout: 3000 });
|
|
116
|
+
const m = stdout.match(/(\d+)\s*x\s*(\d+)/);
|
|
117
|
+
if (m) return { width: parseInt(m[1]), height: parseInt(m[2]) };
|
|
134
118
|
} catch {}
|
|
135
119
|
}
|
|
136
120
|
if (robot?.screen?.width) {
|