beast-agent 1.9.0 → 2.0.0

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 (52) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +130 -130
  3. package/bin/beast-agent.js +137 -137
  4. package/package.json +1 -1
  5. package/scripts/fix-electron.js +138 -138
  6. package/scripts/release.js +137 -131
  7. package/scripts/swap-electron.js +40 -40
  8. package/src/agent/agentdefs.js +122 -122
  9. package/src/agent/bots.js +580 -580
  10. package/src/agent/bus.js +389 -389
  11. package/src/agent/computeruse.js +200 -200
  12. package/src/agent/config.js +284 -284
  13. package/src/agent/discord.js +332 -332
  14. package/src/agent/engine.js +75 -10
  15. package/src/agent/kb.js +123 -123
  16. package/src/agent/llm.js +430 -430
  17. package/src/agent/logger.js +90 -90
  18. package/src/agent/mcp.js +427 -427
  19. package/src/agent/mem0.js +605 -605
  20. package/src/agent/memory.js +427 -427
  21. package/src/agent/mqueue.js +124 -124
  22. package/src/agent/pdf.js +20 -20
  23. package/src/agent/research.js +133 -133
  24. package/src/agent/scripts/news.py +113 -113
  25. package/src/agent/scripts/stealthsearch.py +30 -30
  26. package/src/agent/scripts/websearch.py +225 -225
  27. package/src/agent/searxng.js +325 -325
  28. package/src/agent/seeds/brainstorming/SKILL.md +90 -90
  29. package/src/agent/seeds/dispatching-parallel-agents/SKILL.md +120 -120
  30. package/src/agent/seeds/executing-plans/SKILL.md +60 -60
  31. package/src/agent/seeds/subagent-driven-development/SKILL.md +167 -167
  32. package/src/agent/seeds/systematic-debugging/SKILL.md +131 -131
  33. package/src/agent/seeds/test-driven-development/SKILL.md +152 -152
  34. package/src/agent/seeds/verification-before-completion/SKILL.md +63 -63
  35. package/src/agent/seeds/writing-plans/SKILL.md +162 -162
  36. package/src/agent/seeds/writing-skills/SKILL.md +229 -229
  37. package/src/agent/skills.js +652 -652
  38. package/src/agent/store.js +378 -378
  39. package/src/agent/telegram.js +155 -155
  40. package/src/agent/tokens.js +39 -39
  41. package/src/agent/usage.js +125 -125
  42. package/src/agent/watchers.js +312 -312
  43. package/src/agent/watext.js +80 -80
  44. package/src/agent/whatsapp.js +555 -555
  45. package/src/cron.js +255 -255
  46. package/src/main.js +348 -6
  47. package/src/preload.js +9 -0
  48. package/src/renderer/browserPreload.js +73 -73
  49. package/src/renderer/i18n.js +4 -0
  50. package/src/renderer/index.html +448 -409
  51. package/src/renderer/renderer.js +824 -41
  52. package/src/renderer/style.css +264 -5
@@ -1,200 +1,200 @@
1
- 'use strict';
2
-
3
- /* Beast Computer Use (#4): Windows GUI otomasyonu — ekran görüntüsü +
4
- fare/klavye kontrolü. Ek paket YOK: Electron nativeImage ekranı verir,
5
- mouse/klavye PowerShell üzerinden user32 API ile sürülür.
6
-
7
- Güvenlik: yalnızca engine araç çağrılarıyla çalışır; koordinat sınırlı,
8
- hız limiting'li (aksiyon arası min gecikme) ve yazma metni kırpılır. */
9
-
10
- const { execFile } = require('child_process');
11
-
12
- /* aksiyonlar arası minimum boşluk — wx'i art arda tıklarla donatmamak için */
13
- let lastActionAt = 0;
14
- function pace() {
15
- const wait = 120 - (Date.now() - lastActionAt);
16
- lastActionAt = Date.now();
17
- if (wait > 0) return new Promise((r) => setTimeout(r, wait));
18
- return Promise.resolve();
19
- }
20
-
21
- function ps(script) {
22
- return new Promise((resolve, reject) => {
23
- execFile(
24
- 'powershell.exe',
25
- ['-NoProfile', '-NonInteractive', '-Command', script],
26
- { timeout: 20000, windowsHide: true },
27
- (err, stdout) => (err ? reject(err) : resolve(String(stdout || '').trim()))
28
- );
29
- });
30
- }
31
-
32
- /** Sanal masaüstü çözünürlüğü */
33
- async function screenSize() {
34
- const out = await ps(
35
- 'Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width.ToString() + "x" + [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height'
36
- );
37
- const m = out.match(/(\d+)x(\d+)/);
38
- if (!m) throw new Error('çözünürlük alınamadı');
39
- return { w: Number(m[1]), h: Number(m[2]) };
40
- }
41
-
42
- /**
43
- * Aksiyon uygula. op:
44
- * click x y → sol tık
45
- * dblclick x y → çift tık
46
- * rightclick x y → sağ tık
47
- * move x y → imleci taşı
48
- * type text → klavyeyle yaz (Unicode destekli, SendInput WM_CHAR benzeri)
49
- * key combo → "enter", "ctrl+s", "alt+tab", "win" ...
50
- * scroll dx dy → tekerlek
51
- */
52
- async function act(op, args = {}) {
53
- await pace();
54
- const x = Math.max(0, Math.round(Number(args.x) || 0));
55
- const y = Math.max(0, Math.round(Number(args.y) || 0));
56
- switch (op) {
57
- case 'move':
58
- await mouseMove(x, y);
59
- return { ok: true };
60
- case 'click':
61
- await mouseMove(x, y);
62
- await clickSimple('left');
63
- return { ok: true, at: { x, y } };
64
- case 'dblclick':
65
- await mouseMove(x, y);
66
- await clickSimple('left');
67
- await sleep(70);
68
- await clickSimple('left');
69
- return { ok: true, at: { x, y } };
70
- case 'rightclick':
71
- await mouseMove(x, y);
72
- await clickSimple('right');
73
- return { ok: true, at: { x, y } };
74
- case 'type': {
75
- const text = String(args.text ?? '').slice(0, 2000);
76
- if (!text) return { ok: false, error: 'boş metin' };
77
- /* Add-Type SendInput tabanlı Unicode typer */
78
- await ps(buildTyperScript(text));
79
- return { ok: true, chars: text.length };
80
- }
81
- case 'key': {
82
- const combo = String(args.combo || args.key || '').trim().slice(0, 40);
83
- if (!combo) return { ok: false, error: 'tuş gerekli' };
84
- await ps(buildKeyScript(combo));
85
- return { ok: true, key: combo };
86
- }
87
- case 'scroll': {
88
- const dy = Math.max(-10, Math.min(10, Math.round(Number(args.dy) || 0)));
89
- if (!dy) return { ok: false, error: 'dy gerekli (-10..10)' };
90
- await mouseMove(x || 640, y || 360);
91
- const clicks = Math.abs(dy) * 3;
92
- for (let i = 0; i < clicks; i++) {
93
- await wheel(dy > 0 ? 1 : -1); // pozitif dy = aşağı
94
- }
95
- return { ok: true, dy };
96
- }
97
- default:
98
- return { ok: false, error: `bilinmeyen op: ${op}` };
99
- }
100
- }
101
-
102
- function sleep(ms) {
103
- return new Promise((r) => setTimeout(r, ms));
104
- }
105
-
106
- /* ---------- PowerShell snippet üreticileri ---------- */
107
-
108
- const MOUSE_MOVE_TPL = `
109
- Add-Type @"
110
- using System;
111
- using System.Runtime.InteropServices;
112
- public class BM {
113
- [DllImport("user32.dll")] public static extern bool SetCursorPos(int X, int Y);
114
- }
115
- "@
116
- [BM]::SetCursorPos(%%X%%, %%Y%%) | Out-Null
117
- `;
118
-
119
- const WHEEL_TPL = `
120
- Add-Type @"
121
- using System;
122
- using System.Runtime.InteropServices;
123
- public class BW {
124
- [DllImport("user32.dll")] public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
125
- }
126
- "@
127
- [BW]::mouse_event(0x0800, 0, 0, %%DELTA%%, [UIntPtr]::Zero)
128
- `;
129
-
130
- /* Unicode güvenli yazım: SendInput yerine pano + Ctrl+V fallback'u en sağlamı.
131
- Panoyu geri yüklemek yerine tek seferlik kullanıp bırakıyoruz (hız öncelik). */
132
- function buildTyperScript(text) {
133
- const b64 = Buffer.from(text, 'utf16le').toString('base64');
134
- return `
135
- $t = [System.Text.Encoding]::Unicode.GetString([Convert]::FromBase64String("${b64}"))
136
- Add-Type -AssemblyName System.Windows.Forms
137
- [System.Windows.Forms.Clipboard]::SetText($t)
138
- Start-Sleep -Milliseconds 80
139
- [System.Windows.Forms.SendKeys]::SendWait("^v")
140
- `;
141
- }
142
-
143
- /* Tuş kombosu: enter/tab/esc/f1-12, ctrl/alt/shift+x, win vb. */
144
- function buildKeyScript(combo) {
145
- const map = {
146
- enter: '{ENTER}', tab: '{TAB}', esc: '{ESC}', escape: '{ESC}',
147
- backspace: '{BACKSPACE}', delete: '{DELETE}', del: '{DELETE}',
148
- home: '{HOME}', end: '{END}', pgup: '{PGUP}', pgdn: '{PGDN}',
149
- up: '{UP}', down: '{DOWN}', left: '{LEFT}', right: '{RIGHT}',
150
- space: ' ', win: '^({ESC})',
151
- };
152
- let out = '';
153
- const parts = String(combo).toLowerCase().split('+').map((p) => p.trim());
154
- let mods = '';
155
- for (const p of parts) {
156
- if (p === 'ctrl') mods += '^';
157
- else if (p === 'alt') mods += '%';
158
- else if (p === 'shift') mods += '+';
159
- else if (p === 'win') out += ''; // win ayrı ele
160
- else if (/^f\d{1,2}$/.test(p)) out += '{' + p.toUpperCase() + '}';
161
- else if (map[p]) out += map[p];
162
- else out += p.slice(0, 1).toUpperCase(); // tek harf/tuş
163
- }
164
- const seq = mods && out ? mods + '(' + out + ')' : mods + out;
165
- const b64 = Buffer.from(seq, 'utf16le').toString('base64');
166
- return `
167
- $s = [System.Text.Encoding]::Unicode.GetString([Convert]::FromBase64String("${b64}"))
168
- Add-Type -AssemblyName System.Windows.Forms
169
- [System.Windows.Forms.SendKeys]::SendWait($s)
170
- `;
171
- }
172
-
173
- async function mouseMove(x, y) {
174
- await ps(MOUSE_MOVE_TPL.replace(/%%X%%/g, String(x)).replace(/%%Y%%/g, String(y)));
175
- }
176
-
177
- /* down+up tek script'te — karışık replace zinciri yerine bu kullanılır */
178
- async function clickSimple(button) {
179
- const down = button === 'right' ? 0x0008 : 0x0002;
180
- const up = button === 'right' ? 0x0010 : 0x0004;
181
- await ps(`
182
- Add-Type @"
183
- using System;
184
- using System.Runtime.InteropServices;
185
- public class BC2 {
186
- [DllImport("user32.dll")] public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
187
- }
188
- "@
189
- [BC2]::mouse_event(${down}, 0, 0, 0, [UIntPtr]::Zero)
190
- Start-Sleep -Milliseconds 45
191
- [BC2]::mouse_event(${up}, 0, 0, 0, [UIntPtr]::Zero)
192
- `);
193
- }
194
-
195
- async function wheel(dir) {
196
- const delta = dir < 0 ? -240 : 240; // WHEEL_DELTA=120 katları; negatif=yukarı görüntüde aşağı kayar bazı app'lerde
197
- await ps(WHEEL_TPL.replace(/%%DELTA%%/g, String(delta)));
198
- }
199
-
200
- module.exports = { act, screenSize, clickSimple, mouseMove };
1
+ 'use strict';
2
+
3
+ /* Beast Computer Use (#4): Windows GUI otomasyonu — ekran görüntüsü +
4
+ fare/klavye kontrolü. Ek paket YOK: Electron nativeImage ekranı verir,
5
+ mouse/klavye PowerShell üzerinden user32 API ile sürülür.
6
+
7
+ Güvenlik: yalnızca engine araç çağrılarıyla çalışır; koordinat sınırlı,
8
+ hız limiting'li (aksiyon arası min gecikme) ve yazma metni kırpılır. */
9
+
10
+ const { execFile } = require('child_process');
11
+
12
+ /* aksiyonlar arası minimum boşluk — wx'i art arda tıklarla donatmamak için */
13
+ let lastActionAt = 0;
14
+ function pace() {
15
+ const wait = 120 - (Date.now() - lastActionAt);
16
+ lastActionAt = Date.now();
17
+ if (wait > 0) return new Promise((r) => setTimeout(r, wait));
18
+ return Promise.resolve();
19
+ }
20
+
21
+ function ps(script) {
22
+ return new Promise((resolve, reject) => {
23
+ execFile(
24
+ 'powershell.exe',
25
+ ['-NoProfile', '-NonInteractive', '-Command', script],
26
+ { timeout: 20000, windowsHide: true },
27
+ (err, stdout) => (err ? reject(err) : resolve(String(stdout || '').trim()))
28
+ );
29
+ });
30
+ }
31
+
32
+ /** Sanal masaüstü çözünürlüğü */
33
+ async function screenSize() {
34
+ const out = await ps(
35
+ 'Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width.ToString() + "x" + [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height'
36
+ );
37
+ const m = out.match(/(\d+)x(\d+)/);
38
+ if (!m) throw new Error('çözünürlük alınamadı');
39
+ return { w: Number(m[1]), h: Number(m[2]) };
40
+ }
41
+
42
+ /**
43
+ * Aksiyon uygula. op:
44
+ * click x y → sol tık
45
+ * dblclick x y → çift tık
46
+ * rightclick x y → sağ tık
47
+ * move x y → imleci taşı
48
+ * type text → klavyeyle yaz (Unicode destekli, SendInput WM_CHAR benzeri)
49
+ * key combo → "enter", "ctrl+s", "alt+tab", "win" ...
50
+ * scroll dx dy → tekerlek
51
+ */
52
+ async function act(op, args = {}) {
53
+ await pace();
54
+ const x = Math.max(0, Math.round(Number(args.x) || 0));
55
+ const y = Math.max(0, Math.round(Number(args.y) || 0));
56
+ switch (op) {
57
+ case 'move':
58
+ await mouseMove(x, y);
59
+ return { ok: true };
60
+ case 'click':
61
+ await mouseMove(x, y);
62
+ await clickSimple('left');
63
+ return { ok: true, at: { x, y } };
64
+ case 'dblclick':
65
+ await mouseMove(x, y);
66
+ await clickSimple('left');
67
+ await sleep(70);
68
+ await clickSimple('left');
69
+ return { ok: true, at: { x, y } };
70
+ case 'rightclick':
71
+ await mouseMove(x, y);
72
+ await clickSimple('right');
73
+ return { ok: true, at: { x, y } };
74
+ case 'type': {
75
+ const text = String(args.text ?? '').slice(0, 2000);
76
+ if (!text) return { ok: false, error: 'boş metin' };
77
+ /* Add-Type SendInput tabanlı Unicode typer */
78
+ await ps(buildTyperScript(text));
79
+ return { ok: true, chars: text.length };
80
+ }
81
+ case 'key': {
82
+ const combo = String(args.combo || args.key || '').trim().slice(0, 40);
83
+ if (!combo) return { ok: false, error: 'tuş gerekli' };
84
+ await ps(buildKeyScript(combo));
85
+ return { ok: true, key: combo };
86
+ }
87
+ case 'scroll': {
88
+ const dy = Math.max(-10, Math.min(10, Math.round(Number(args.dy) || 0)));
89
+ if (!dy) return { ok: false, error: 'dy gerekli (-10..10)' };
90
+ await mouseMove(x || 640, y || 360);
91
+ const clicks = Math.abs(dy) * 3;
92
+ for (let i = 0; i < clicks; i++) {
93
+ await wheel(dy > 0 ? 1 : -1); // pozitif dy = aşağı
94
+ }
95
+ return { ok: true, dy };
96
+ }
97
+ default:
98
+ return { ok: false, error: `bilinmeyen op: ${op}` };
99
+ }
100
+ }
101
+
102
+ function sleep(ms) {
103
+ return new Promise((r) => setTimeout(r, ms));
104
+ }
105
+
106
+ /* ---------- PowerShell snippet üreticileri ---------- */
107
+
108
+ const MOUSE_MOVE_TPL = `
109
+ Add-Type @"
110
+ using System;
111
+ using System.Runtime.InteropServices;
112
+ public class BM {
113
+ [DllImport("user32.dll")] public static extern bool SetCursorPos(int X, int Y);
114
+ }
115
+ "@
116
+ [BM]::SetCursorPos(%%X%%, %%Y%%) | Out-Null
117
+ `;
118
+
119
+ const WHEEL_TPL = `
120
+ Add-Type @"
121
+ using System;
122
+ using System.Runtime.InteropServices;
123
+ public class BW {
124
+ [DllImport("user32.dll")] public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
125
+ }
126
+ "@
127
+ [BW]::mouse_event(0x0800, 0, 0, %%DELTA%%, [UIntPtr]::Zero)
128
+ `;
129
+
130
+ /* Unicode güvenli yazım: SendInput yerine pano + Ctrl+V fallback'u en sağlamı.
131
+ Panoyu geri yüklemek yerine tek seferlik kullanıp bırakıyoruz (hız öncelik). */
132
+ function buildTyperScript(text) {
133
+ const b64 = Buffer.from(text, 'utf16le').toString('base64');
134
+ return `
135
+ $t = [System.Text.Encoding]::Unicode.GetString([Convert]::FromBase64String("${b64}"))
136
+ Add-Type -AssemblyName System.Windows.Forms
137
+ [System.Windows.Forms.Clipboard]::SetText($t)
138
+ Start-Sleep -Milliseconds 80
139
+ [System.Windows.Forms.SendKeys]::SendWait("^v")
140
+ `;
141
+ }
142
+
143
+ /* Tuş kombosu: enter/tab/esc/f1-12, ctrl/alt/shift+x, win vb. */
144
+ function buildKeyScript(combo) {
145
+ const map = {
146
+ enter: '{ENTER}', tab: '{TAB}', esc: '{ESC}', escape: '{ESC}',
147
+ backspace: '{BACKSPACE}', delete: '{DELETE}', del: '{DELETE}',
148
+ home: '{HOME}', end: '{END}', pgup: '{PGUP}', pgdn: '{PGDN}',
149
+ up: '{UP}', down: '{DOWN}', left: '{LEFT}', right: '{RIGHT}',
150
+ space: ' ', win: '^({ESC})',
151
+ };
152
+ let out = '';
153
+ const parts = String(combo).toLowerCase().split('+').map((p) => p.trim());
154
+ let mods = '';
155
+ for (const p of parts) {
156
+ if (p === 'ctrl') mods += '^';
157
+ else if (p === 'alt') mods += '%';
158
+ else if (p === 'shift') mods += '+';
159
+ else if (p === 'win') out += ''; // win ayrı ele
160
+ else if (/^f\d{1,2}$/.test(p)) out += '{' + p.toUpperCase() + '}';
161
+ else if (map[p]) out += map[p];
162
+ else out += p.slice(0, 1).toUpperCase(); // tek harf/tuş
163
+ }
164
+ const seq = mods && out ? mods + '(' + out + ')' : mods + out;
165
+ const b64 = Buffer.from(seq, 'utf16le').toString('base64');
166
+ return `
167
+ $s = [System.Text.Encoding]::Unicode.GetString([Convert]::FromBase64String("${b64}"))
168
+ Add-Type -AssemblyName System.Windows.Forms
169
+ [System.Windows.Forms.SendKeys]::SendWait($s)
170
+ `;
171
+ }
172
+
173
+ async function mouseMove(x, y) {
174
+ await ps(MOUSE_MOVE_TPL.replace(/%%X%%/g, String(x)).replace(/%%Y%%/g, String(y)));
175
+ }
176
+
177
+ /* down+up tek script'te — karışık replace zinciri yerine bu kullanılır */
178
+ async function clickSimple(button) {
179
+ const down = button === 'right' ? 0x0008 : 0x0002;
180
+ const up = button === 'right' ? 0x0010 : 0x0004;
181
+ await ps(`
182
+ Add-Type @"
183
+ using System;
184
+ using System.Runtime.InteropServices;
185
+ public class BC2 {
186
+ [DllImport("user32.dll")] public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
187
+ }
188
+ "@
189
+ [BC2]::mouse_event(${down}, 0, 0, 0, [UIntPtr]::Zero)
190
+ Start-Sleep -Milliseconds 45
191
+ [BC2]::mouse_event(${up}, 0, 0, 0, [UIntPtr]::Zero)
192
+ `);
193
+ }
194
+
195
+ async function wheel(dir) {
196
+ const delta = dir < 0 ? -240 : 240; // WHEEL_DELTA=120 katları; negatif=yukarı görüntüde aşağı kayar bazı app'lerde
197
+ await ps(WHEEL_TPL.replace(/%%DELTA%%/g, String(delta)));
198
+ }
199
+
200
+ module.exports = { act, screenSize, clickSimple, mouseMove };