uwonbot 1.1.9 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/agent.js +55 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uwonbot",
3
- "version": "1.1.9",
3
+ "version": "1.2.1",
4
4
  "description": "Uwonbot AI Assistant CLI — Your AI controls your computer",
5
5
  "main": "src/index.js",
6
6
  "bin": {
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');
@@ -93,6 +111,13 @@ async function loadNativeModules() {
93
111
  }
94
112
 
95
113
  async function getScreenSize() {
114
+ if (platform === 'darwin') {
115
+ try {
116
+ const { stdout } = await execAsync(`osascript -e 'tell application "Finder" to get bounds of window of desktop' 2>/dev/null || osascript -e 'tell application "System Events" to get {0, 0, 1920, 1080}'`);
117
+ const nums = stdout.trim().split(/[,\s]+/).map(Number);
118
+ if (nums.length >= 4) return { width: nums[2], height: nums[3] };
119
+ } catch {}
120
+ }
96
121
  if (robot?.screen?.width) {
97
122
  const w = await robot.screen.width();
98
123
  const h = await robot.screen.height();
@@ -109,22 +134,38 @@ async function moveMouse(x, y) {
109
134
  const px = Math.round(x * screen.width);
110
135
  const py = Math.round(y * screen.height);
111
136
 
112
- if (robot?.mouse?.setPosition) {
113
- const { Point } = await import('@nut-tree-fork/nut-js');
114
- await robot.mouse.setPosition(new Point(px, py));
115
- } else if (robot?.moveMouse) {
116
- robot.moveMouse(px, py);
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 {}
117
149
  }
118
150
  }
119
151
 
120
152
  async function mouseClick(button = 'left', double = false) {
121
- if (robot?.mouse?.click) {
122
- const { Button } = await import('@nut-tree-fork/nut-js');
123
- const btn = button === 'right' ? Button.RIGHT : Button.LEFT;
124
- await robot.mouse.click(btn);
125
- if (double) await robot.mouse.click(btn);
126
- } else if (robot?.mouseClick) {
127
- robot.mouseClick(button, double);
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 {}
128
169
  }
129
170
  }
130
171
 
@@ -458,9 +499,9 @@ async function openWebAssistant(assistantId) {
458
499
  const chatUrl = `${WEB_APP_URL}/assistant/live?id=${assistantId}`;
459
500
  try {
460
501
  if (platform === 'darwin') {
461
- await execAsync(`open -na "Google Chrome" --args --new-window --window-size=380,520 --window-position=1000,200 "${chatUrl}" 2>/dev/null || open "${chatUrl}"`);
502
+ await execAsync(`open -na "Google Chrome" --args --new-window --window-size=320,440 --window-position=1000,200 "${chatUrl}" 2>/dev/null || open "${chatUrl}"`);
462
503
  } else if (platform === 'win32') {
463
- await execAsync(`start chrome --new-window --window-size=380,520 --window-position=1000,200 "${chatUrl}" 2>nul || start "" "${chatUrl}"`);
504
+ await execAsync(`start chrome --new-window --window-size=320,440 --window-position=1000,200 "${chatUrl}" 2>nul || start "" "${chatUrl}"`);
464
505
  } else {
465
506
  await execAsync(`google-chrome --new-window "${chatUrl}" 2>/dev/null || xdg-open "${chatUrl}"`);
466
507
  }