uwonbot 1.2.0 → 1.2.1
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 +48 -14
package/package.json
CHANGED
package/src/agent.js
CHANGED
|
@@ -61,7 +61,22 @@ 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
|
+
|
|
64
77
|
async function loadNativeModules() {
|
|
78
|
+
const accessOk = await checkAccessibility();
|
|
79
|
+
|
|
65
80
|
try {
|
|
66
81
|
robot = (await import('@nut-tree-fork/nut-js')).default || (await import('@nut-tree-fork/nut-js'));
|
|
67
82
|
if (robot.mouse) {
|
|
@@ -69,6 +84,9 @@ async function loadNativeModules() {
|
|
|
69
84
|
robot.mouse.config.mouseSpeed = 2000;
|
|
70
85
|
}
|
|
71
86
|
console.log(chalk.green(' ✓ nut-js loaded (mouse/keyboard control)'));
|
|
87
|
+
if (!accessOk) {
|
|
88
|
+
console.log(chalk.yellow(' ⚠ 접근성 권한이 없어 마우스/키보드 제어가 제한될 수 있습니다.'));
|
|
89
|
+
}
|
|
72
90
|
} catch {
|
|
73
91
|
try {
|
|
74
92
|
const rjs = await import('robotjs');
|
|
@@ -116,22 +134,38 @@ async function moveMouse(x, y) {
|
|
|
116
134
|
const px = Math.round(x * screen.width);
|
|
117
135
|
const py = Math.round(y * screen.height);
|
|
118
136
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
137
|
+
try {
|
|
138
|
+
if (robot?.mouse?.setPosition) {
|
|
139
|
+
const { Point } = await import('@nut-tree-fork/nut-js');
|
|
140
|
+
await robot.mouse.setPosition(new Point(px, py));
|
|
141
|
+
return;
|
|
142
|
+
} else if (robot?.moveMouse) {
|
|
143
|
+
robot.moveMouse(px, py);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
} catch {}
|
|
147
|
+
if (platform === 'darwin') {
|
|
148
|
+
try { await execAsync(`osascript -e 'tell application "System Events" to set position of mouse to {${px}, ${py}}'`); } catch {}
|
|
124
149
|
}
|
|
125
150
|
}
|
|
126
151
|
|
|
127
152
|
async function mouseClick(button = 'left', double = false) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
153
|
+
try {
|
|
154
|
+
if (robot?.mouse?.click) {
|
|
155
|
+
const { Button } = await import('@nut-tree-fork/nut-js');
|
|
156
|
+
const btn = button === 'right' ? Button.RIGHT : Button.LEFT;
|
|
157
|
+
await robot.mouse.click(btn);
|
|
158
|
+
if (double) await robot.mouse.click(btn);
|
|
159
|
+
return;
|
|
160
|
+
} else if (robot?.mouseClick) {
|
|
161
|
+
robot.mouseClick(button, double);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
} catch {}
|
|
165
|
+
if (platform === 'darwin') {
|
|
166
|
+
const clickType = button === 'right' ? 'right' : 'left';
|
|
167
|
+
const script = `osascript -e 'tell application "System Events" to click'`;
|
|
168
|
+
try { await execAsync(script); } catch {}
|
|
135
169
|
}
|
|
136
170
|
}
|
|
137
171
|
|
|
@@ -465,9 +499,9 @@ async function openWebAssistant(assistantId) {
|
|
|
465
499
|
const chatUrl = `${WEB_APP_URL}/assistant/live?id=${assistantId}`;
|
|
466
500
|
try {
|
|
467
501
|
if (platform === 'darwin') {
|
|
468
|
-
await execAsync(`open -na "Google Chrome" --args --new-window --window-size=
|
|
502
|
+
await execAsync(`open -na "Google Chrome" --args --new-window --window-size=320,440 --window-position=1000,200 "${chatUrl}" 2>/dev/null || open "${chatUrl}"`);
|
|
469
503
|
} else if (platform === 'win32') {
|
|
470
|
-
await execAsync(`start chrome --new-window --window-size=
|
|
504
|
+
await execAsync(`start chrome --new-window --window-size=320,440 --window-position=1000,200 "${chatUrl}" 2>nul || start "" "${chatUrl}"`);
|
|
471
505
|
} else {
|
|
472
506
|
await execAsync(`google-chrome --new-window "${chatUrl}" 2>/dev/null || xdg-open "${chatUrl}"`);
|
|
473
507
|
}
|