uwonbot 1.2.5 → 1.2.7

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 +45 -51
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uwonbot",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
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,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
- const accessOk = await checkAccessibility();
65
+ robot = null;
79
66
 
80
- try {
81
- robot = (await import('@nut-tree-fork/nut-js')).default || (await import('@nut-tree-fork/nut-js'));
82
- if (robot.mouse) {
83
- robot.mouse.config.autoDelayMs = 0;
84
- robot.mouse.config.mouseSpeed = 2000;
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
- } catch (nutErr) {
74
+ } else {
91
75
  try {
92
- const rjs = await import('robotjs');
93
- robot = rjs.default || rjs;
94
- console.log(chalk.green(' ✓ robotjs loaded (mouse/keyboard control)'));
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
- robot = null;
97
- if (platform === 'darwin') {
98
- console.log(chalk.green(' ✓ CoreGraphics 직접 제어 모드 (macOS 네이티브)'));
99
- } else {
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
  }
@@ -585,6 +563,16 @@ async function handleCommand(msg) {
585
563
  const wl = await windowList();
586
564
  return { ok: true, windows: wl };
587
565
  }
566
+ case 'open_url': {
567
+ const url = cmd.url;
568
+ if (!url) return { ok: false, error: 'No URL provided' };
569
+ try {
570
+ if (platform === 'darwin') await execAsync(`open "${url}"`);
571
+ else if (platform === 'win32') await execAsync(`start "" "${url}"`);
572
+ else await execAsync(`xdg-open "${url}"`);
573
+ return { ok: true };
574
+ } catch (e) { return { ok: false, error: e.message }; }
575
+ }
588
576
  case 'ping':
589
577
  return { ok: true, pong: true };
590
578
  default:
@@ -706,10 +694,22 @@ export async function startAgent(port = 9876, options = {}) {
706
694
  } catch {}
707
695
  console.log('');
708
696
 
697
+ let _assistantOpen = false;
698
+ let _clapCooldown = false;
699
+
709
700
  if (!options.noMic) {
710
701
  await ensureSox();
711
702
  const clapListener = new ClapListener(async () => {
703
+ if (_assistantOpen) {
704
+ console.log(chalk.gray(' 👏 박수 감지 — 이미 비서가 활성 상태입니다.'));
705
+ return;
706
+ }
707
+ if (_clapCooldown) return;
708
+ _clapCooldown = true;
709
+ setTimeout(() => { _clapCooldown = false; }, 5000);
710
+
712
711
  console.log(chalk.bold.cyan(' 👏 박수 감지! 비서 활성화 중...'));
712
+ _assistantOpen = true;
713
713
 
714
714
  if (userAssistants.length === 0) {
715
715
  console.log(chalk.gray(' → 기본 Uwonbot 웹 실행'));
@@ -725,16 +725,9 @@ export async function startAgent(port = 9876, options = {}) {
725
725
  return;
726
726
  }
727
727
 
728
- if (userAssistants.length === 1) {
729
- const a = userAssistants[0];
730
- console.log(chalk.green(` → ${a.name} 웹 실행`));
731
- await openWebAssistant(a.id);
732
- return;
733
- }
734
-
735
- const first = userAssistants[0];
736
- console.log(chalk.green(` → ${first.name} 웹 실행 (비서 ${userAssistants.length}개 중 첫 번째)`));
737
- await openWebAssistant(first.id);
728
+ const target = userAssistants[0];
729
+ console.log(chalk.green(` → ${target.name} 실행`));
730
+ await openWebAssistant(target.id);
738
731
  });
739
732
  await clapListener.start();
740
733
  console.log('');
@@ -757,6 +750,7 @@ export async function startAgent(port = 9876, options = {}) {
757
750
 
758
751
  ws.on('close', () => {
759
752
  console.log(chalk.yellow(' ○ Client disconnected'));
753
+ _assistantOpen = false;
760
754
  });
761
755
 
762
756
  ws.send(JSON.stringify({ type: 'welcome', agent: 'uwonbot', version: '1.1.2', uid }));