uwonbot 1.2.3 → 1.2.5

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 +34 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uwonbot",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
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
@@ -109,9 +109,20 @@ async function loadNativeModules() {
109
109
  console.log(chalk.green(' ✓ screenshot-desktop loaded'));
110
110
  } catch {
111
111
  console.log(chalk.yellow(' ⚠ screenshot-desktop not found.'));
112
- console.log(chalk.yellow(' Install: npm install -g screenshot-desktop'));
113
112
  screenshotDesktop = null;
114
113
  }
114
+
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
+ const screen = await getScreenSize();
125
+ console.log(chalk.gray(` Screen: ${screen.width}x${screen.height}`));
115
126
  }
116
127
 
117
128
  async function getScreenSize() {
@@ -147,6 +158,7 @@ $.CGEventPost($.kCGHIDEventTap, e);`;
147
158
 
148
159
  let _lastKnownPos = { x: 960, y: 540 };
149
160
 
161
+ let _moveLogCount = 0;
150
162
  async function moveMouse(x, y) {
151
163
  const screen = await getScreenSize();
152
164
  const px = Math.round(x * screen.width);
@@ -157,16 +169,23 @@ async function moveMouse(x, y) {
157
169
  if (robot?.mouse?.setPosition) {
158
170
  const { Point } = await import('@nut-tree-fork/nut-js');
159
171
  await robot.mouse.setPosition(new Point(px, py));
172
+ if (_moveLogCount++ < 3) console.log(chalk.green(` [mouse] nut-js → (${px},${py})`));
160
173
  return;
161
174
  } else if (robot?.moveMouse) {
162
175
  robot.moveMouse(px, py);
176
+ if (_moveLogCount++ < 3) console.log(chalk.green(` [mouse] robotjs → (${px},${py})`));
163
177
  return;
164
178
  }
165
179
  } catch (e) {
166
- console.log(chalk.gray(` [mouse] nut-js fallback: ${e.message}`));
180
+ if (_moveLogCount++ < 5) console.log(chalk.yellow(` [mouse] nut-js failed: ${e.message}, trying CoreGraphics`));
167
181
  }
168
182
  if (platform === 'darwin') {
169
- try { await cgMoveMouse(px, py); } catch {}
183
+ try {
184
+ await cgMoveMouse(px, py);
185
+ if (_moveLogCount++ < 3) console.log(chalk.green(` [mouse] CoreGraphics → (${px},${py})`));
186
+ } catch (e) {
187
+ if (_moveLogCount++ < 5) console.log(chalk.red(` [mouse] CoreGraphics failed: ${e.message}`));
188
+ }
170
189
  }
171
190
  }
172
191
 
@@ -501,9 +520,14 @@ async function openTerminalWithChat(assistantName) {
501
520
  }
502
521
  }
503
522
 
523
+ let _logThrottle = 0;
504
524
  async function handleCommand(msg) {
505
525
  try {
506
526
  const cmd = JSON.parse(msg);
527
+ if (cmd.type !== 'mouse_move' || Date.now() - _logThrottle > 2000) {
528
+ if (cmd.type === 'mouse_move') _logThrottle = Date.now();
529
+ console.log(chalk.gray(` ← ${cmd.type}${cmd.type === 'mouse_move' ? ` (${cmd.x?.toFixed(3)},${cmd.y?.toFixed(3)})` : ''}`));
530
+ }
507
531
  switch (cmd.type) {
508
532
  case 'mouse_move':
509
533
  await moveMouse(cmd.x, cmd.y);
@@ -589,10 +613,10 @@ async function openWebAssistant(assistantId) {
589
613
 
590
614
  async function activateAllAssistants(assistants) {
591
615
  const opened = [];
592
- for (const a of assistants) {
593
- await openWebAssistant(a.id);
594
- opened.push({ name: a.name, mode: 'web' });
595
- await new Promise(r => setTimeout(r, 500));
616
+ const first = assistants[0];
617
+ if (first) {
618
+ await openWebAssistant(first.id);
619
+ opened.push({ name: first.name, mode: 'web' });
596
620
  }
597
621
  return opened;
598
622
  }
@@ -708,19 +732,9 @@ export async function startAgent(port = 9876, options = {}) {
708
732
  return;
709
733
  }
710
734
 
711
- console.log(chalk.cyan(` → ${userAssistants.length}개 비서 모두 활성화`));
712
- const opened = await activateAllAssistants(userAssistants);
713
- opened.forEach(o => {
714
- console.log(chalk.gray(` ✓ ${o.name} (${o.mode})`));
715
- });
716
-
717
- const geminiKey = userAssistants.find(a => a.apiKey)?.apiKey;
718
- if (geminiKey) {
719
- await listenForName(userAssistants, geminiKey);
720
- } else {
721
- console.log(chalk.gray(' → 모든 비서가 활성 상태로 유지됩니다.'));
722
- console.log(chalk.gray(' (비서 이름을 말해 선택하려면 API 키가 필요합니다)'));
723
- }
735
+ const first = userAssistants[0];
736
+ console.log(chalk.green(` → ${first.name} 실행 (비서 ${userAssistants.length}개 중 첫 번째)`));
737
+ await openWebAssistant(first.id);
724
738
  });
725
739
  await clapListener.start();
726
740
  console.log('');