natureco-cli 2.23.29 → 2.23.31

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 (111) hide show
  1. package/README.md +94 -11
  2. package/bin/natureco.js +495 -94
  3. package/package.json +1 -1
  4. package/src/commands/acp.js +39 -0
  5. package/src/commands/admin-rpc.js +302 -0
  6. package/src/commands/agent.js +280 -0
  7. package/src/commands/agents.js +114 -30
  8. package/src/commands/approvals.js +214 -0
  9. package/src/commands/backup.js +124 -0
  10. package/src/commands/bonjour.js +167 -0
  11. package/src/commands/browser.js +815 -0
  12. package/src/commands/capability.js +237 -0
  13. package/src/commands/channels.js +422 -267
  14. package/src/commands/chat.js +5 -8
  15. package/src/commands/clawbot.js +19 -0
  16. package/src/commands/clickclack.js +130 -0
  17. package/src/commands/code.js +3 -2
  18. package/src/commands/commitments.js +148 -0
  19. package/src/commands/completion.js +84 -0
  20. package/src/commands/config.js +219 -30
  21. package/src/commands/configure.js +110 -0
  22. package/src/commands/crestodian.js +92 -0
  23. package/src/commands/cron.js +239 -19
  24. package/src/commands/daemon.js +90 -0
  25. package/src/commands/dashboard.js +47 -374
  26. package/src/commands/device-pair.js +248 -0
  27. package/src/commands/devices.js +137 -0
  28. package/src/commands/directory.js +179 -0
  29. package/src/commands/dns.js +196 -0
  30. package/src/commands/docs.js +136 -0
  31. package/src/commands/doctor.js +143 -492
  32. package/src/commands/exec-policy.js +80 -0
  33. package/src/commands/gateway-server.js +1155 -24
  34. package/src/commands/gateway.js +492 -249
  35. package/src/commands/health.js +148 -0
  36. package/src/commands/help.js +24 -25
  37. package/src/commands/hooks.js +141 -87
  38. package/src/commands/imessage.js +128 -14
  39. package/src/commands/infer.js +1474 -0
  40. package/src/commands/irc.js +64 -15
  41. package/src/commands/logs.js +122 -99
  42. package/src/commands/mattermost.js +114 -12
  43. package/src/commands/mcp.js +121 -309
  44. package/src/commands/memory-cmd.js +134 -1
  45. package/src/commands/memory.js +128 -0
  46. package/src/commands/message.js +720 -134
  47. package/src/commands/migrate.js +213 -2
  48. package/src/commands/models.js +39 -1
  49. package/src/commands/node.js +98 -0
  50. package/src/commands/nodes.js +362 -0
  51. package/src/commands/oc-path.js +200 -0
  52. package/src/commands/onboard.js +129 -0
  53. package/src/commands/open-prose.js +67 -0
  54. package/src/commands/pairing.js +108 -107
  55. package/src/commands/path.js +206 -0
  56. package/src/commands/plugins.js +35 -1
  57. package/src/commands/policy.js +176 -0
  58. package/src/commands/proxy.js +306 -0
  59. package/src/commands/qr.js +70 -0
  60. package/src/commands/reset.js +101 -94
  61. package/src/commands/sandbox.js +125 -0
  62. package/src/commands/secrets.js +201 -0
  63. package/src/commands/sessions.js +110 -51
  64. package/src/commands/setup.js +102 -543
  65. package/src/commands/signal.js +447 -18
  66. package/src/commands/skills.js +67 -1
  67. package/src/commands/sms.js +123 -19
  68. package/src/commands/status.js +101 -127
  69. package/src/commands/system.js +53 -0
  70. package/src/commands/tasks.js +208 -100
  71. package/src/commands/terminal.js +139 -0
  72. package/src/commands/thread-ownership.js +157 -0
  73. package/src/commands/transcripts.js +95 -0
  74. package/src/commands/tui.js +41 -0
  75. package/src/commands/uninstall.js +73 -92
  76. package/src/commands/update.js +146 -91
  77. package/src/commands/voice.js +82 -0
  78. package/src/commands/vydra.js +98 -0
  79. package/src/commands/webhooks.js +58 -66
  80. package/src/commands/wiki.js +783 -0
  81. package/src/commands/workboard.js +207 -0
  82. package/src/tools/audio_understanding.js +154 -0
  83. package/src/tools/browser.js +112 -0
  84. package/src/tools/canvas.js +104 -0
  85. package/src/tools/document_extract.js +84 -0
  86. package/src/tools/duckduckgo.js +54 -0
  87. package/src/tools/exa_search.js +66 -0
  88. package/src/tools/firecrawl.js +104 -0
  89. package/src/tools/image_generation.js +99 -0
  90. package/src/tools/llm_task.js +118 -0
  91. package/src/tools/media_understanding.js +128 -0
  92. package/src/tools/music_generation.js +113 -0
  93. package/src/tools/parallel_search.js +77 -0
  94. package/src/tools/phone_control.js +80 -0
  95. package/src/tools/phone_control_enhanced.js +184 -0
  96. package/src/tools/searxng.js +61 -0
  97. package/src/tools/speech_to_text.js +135 -0
  98. package/src/tools/text_to_speech.js +105 -0
  99. package/src/tools/thread_ownership.js +88 -0
  100. package/src/tools/video_generation.js +72 -0
  101. package/src/tools/web_readability.js +104 -0
  102. package/src/utils/agents-md.js +85 -0
  103. package/src/utils/api.js +39 -40
  104. package/src/utils/format.js +144 -0
  105. package/src/utils/headless.js +2 -1
  106. package/src/utils/memory.js +200 -0
  107. package/src/utils/parallel-tools.js +106 -0
  108. package/src/utils/sub-agent.js +148 -0
  109. package/src/utils/token-budget.js +304 -0
  110. package/src/utils/tool-runner.js +7 -5
  111. package/src/utils/web-fetch.js +107 -0
@@ -1,396 +1,69 @@
1
- const http = require('http');
2
- const fs = require('fs');
3
- const path = require('path');
4
- const os = require('os');
5
1
  const chalk = require('chalk');
2
+ const http = require('http');
3
+ const net = require('net');
6
4
 
7
- const CONFIG_DIR = path.join(os.homedir(), '.natureco');
8
- const PID_FILE = path.join(CONFIG_DIR, 'dashboard.pid');
9
- const PORT = 3848;
10
-
11
- function getConfig() {
12
- try { return JSON.parse(fs.readFileSync(path.join(CONFIG_DIR, 'config.json'), 'utf8')); }
13
- catch { return {}; }
14
- }
15
-
16
- function getSkills() {
17
- try {
18
- const skillsUtil = require('../utils/skills');
19
- return skillsUtil.getSkills().map(s => s.name || s.slug);
20
- } catch { return []; }
21
- }
22
-
23
- function getMemory(botId) {
24
- try {
25
- const memFile = path.join(CONFIG_DIR, 'memory', `${botId}.json`);
26
- return JSON.parse(fs.readFileSync(memFile, 'utf8'));
27
- } catch { return {}; }
28
- }
29
-
30
- function openBrowser(url) {
31
- const { exec } = require('child_process');
32
- const p = process.platform;
33
- exec(p === 'darwin' ? `open ${url}` : p === 'win32' ? `start ${url}` : `xdg-open ${url}`);
34
- }
35
-
36
- const HTML = `<!DOCTYPE html>
37
- <html lang="tr">
38
- <head>
39
- <meta charset="UTF-8">
40
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
41
- <title>NatureCo Dashboard</title>
42
- <style>
43
- *{margin:0;padding:0;box-sizing:border-box;font-family:system-ui,-apple-system,sans-serif}
44
- html,body{height:100%;overflow:hidden}
45
- body{
46
- background:#0B0E11;
47
- color:#eceff1;
48
- font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif;
49
- display:flex;
50
- height:100vh;
51
- overflow:hidden;
52
- position:relative;
53
- }
54
- body::before{
55
- content:'';
56
- position:fixed;
57
- top:0;left:0;
58
- width:100%;height:100%;
59
- background:
60
- radial-gradient(circle at 20% 80%,rgba(16,185,129,0.3) 0%,transparent 50%),
61
- radial-gradient(circle at 80% 20%,rgba(99,102,241,0.2) 0%,transparent 50%),
62
- radial-gradient(circle at 40% 40%,rgba(245,158,11,0.1) 0%,transparent 50%),
63
- linear-gradient(180deg,#06080A 0%,#0B0E11 100%);
64
- z-index:-1;
65
- pointer-events:none;
66
- }
67
- .app{display:flex;height:100vh}
68
- .sidebar{
69
- width:240px;min-width:240px;
70
- background:rgba(0,10,5,0.75);
71
- backdrop-filter:blur(20px);
72
- border-right:1px solid rgba(0,230,118,0.12);
73
- display:flex;flex-direction:column;
74
- overflow-y:auto;
75
- }
76
- .sidebar::-webkit-scrollbar{width:3px}
77
- .sidebar::-webkit-scrollbar-thumb{background:rgba(0,230,118,0.25);border-radius:2px}
78
- .logo-area{padding:18px 16px;border-bottom:1px solid rgba(0,230,118,0.08);flex-shrink:0}
79
- .logo{color:#00E676;font-size:17px;font-weight:700;letter-spacing:-0.4px}
80
- .logo-sub{color:rgba(0,230,118,0.35);font-size:10px;margin-top:2px}
81
- .section{padding:12px 14px}
82
- .section-label{color:rgba(0,230,118,0.35);font-size:9px;font-weight:600;letter-spacing:1.8px;text-transform:uppercase;margin-bottom:8px}
83
- .bot-card{background:rgba(0,230,118,0.06);border:1px solid rgba(0,230,118,0.2);border-radius:8px;padding:10px;display:flex;align-items:center;gap:8px;cursor:pointer;transition:all 0.2s}
84
- .bot-card:hover{background:rgba(0,230,118,0.1);border-color:rgba(0,230,118,0.35)}
85
- .avatar{width:32px;height:32px;border-radius:50%;background:linear-gradient(135deg,#00C853,#00E676);display:flex;align-items:center;justify-content:center;color:#000;font-weight:700;font-size:13px;flex-shrink:0}
86
- .bot-info .name{color:#e8f5e9;font-size:13px;font-weight:500}
87
- .bot-info .model{color:rgba(0,230,118,0.45);font-size:10px;margin-top:1px}
88
- .online-dot{width:7px;height:7px;background:#00E676;border-radius:50%;margin-left:auto;flex-shrink:0;box-shadow:0 0 6px rgba(0,230,118,0.8);animation:pulse 2s infinite}
89
- @keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}
90
- .other-bot{padding:5px 0;color:rgba(0,230,118,0.4);font-size:12px;cursor:pointer;transition:color 0.2s;display:flex;align-items:center;gap:6px}
91
- .other-bot:hover{color:#a5d6a7}
92
- .other-avatar{width:22px;height:22px;border-radius:50%;background:rgba(0,230,118,0.1);border:1px solid rgba(0,230,118,0.15);display:flex;align-items:center;justify-content:center;color:rgba(0,230,118,0.5);font-size:9px;font-weight:700}
93
- .ch-row{display:flex;align-items:center;gap:7px;padding:4px 0}
94
- .ch-dot{width:6px;height:6px;border-radius:50%;flex-shrink:0}
95
- .ch-dot.on{background:#00E676;box-shadow:0 0 5px rgba(0,230,118,0.7)}
96
- .ch-dot.off{background:rgba(255,255,255,0.15)}
97
- .ch-name{font-size:12px}
98
- .ch-name.on{color:#a5d6a7}
99
- .ch-name.off{color:rgba(255,255,255,0.25)}
100
- .skill-tag{display:inline-block;background:rgba(0,230,118,0.06);border:1px solid rgba(0,230,118,0.15);border-radius:4px;padding:3px 8px;color:#81c784;font-size:10px;margin:2px 2px 2px 0}
101
- .mem-row{font-size:11px;padding:2px 0}
102
- .mem-key{color:rgba(0,230,118,0.4);font-size:9px;letter-spacing:0.5px;text-transform:uppercase;margin-top:5px}
103
- .mem-val{color:#a5d6a7}
104
- .sidebar-footer{margin-top:auto;padding:12px 14px;border-top:1px solid rgba(0,230,118,0.06);flex-shrink:0}
105
- .footer-link{color:rgba(0,230,118,0.25);font-size:10px;text-decoration:none}
106
- .footer-link:hover{color:rgba(0,230,118,0.5)}
107
- .chat-area{flex:1;display:flex;flex-direction:column;min-width:0}
108
- .chat-header{
109
- padding:14px 20px;
110
- border-bottom:1px solid rgba(0,230,118,0.08);
111
- display:flex;align-items:center;gap:12px;
112
- background:rgba(0,10,5,0.6);
113
- backdrop-filter:blur(10px);
114
- flex-shrink:0;
115
- }
116
- .header-bot-name{color:#e8f5e9;font-size:14px;font-weight:500}
117
- .header-bot-model{color:rgba(0,230,118,0.4);font-size:11px}
118
- .version-badge{margin-left:auto;background:rgba(0,230,118,0.06);border:1px solid rgba(0,230,118,0.15);border-radius:20px;padding:3px 10px;color:rgba(0,230,118,0.5);font-size:10px}
119
- .messages{flex:1;padding:16px 20px;overflow-y:auto;display:flex;flex-direction:column;gap:12px}
120
- .messages::-webkit-scrollbar{width:3px}
121
- .messages::-webkit-scrollbar-thumb{background:rgba(0,230,118,0.2);border-radius:2px}
122
- .msg{display:flex;gap:8px;align-items:flex-end;animation:fadeIn 0.3s ease}
123
- @keyframes fadeIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
124
- .msg.user{flex-direction:row-reverse}
125
- .msg-avatar{width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:11px;flex-shrink:0}
126
- .msg-avatar.bot{background:linear-gradient(135deg,#00C853,#00E676);color:#000}
127
- .msg-avatar.user{background:rgba(0,230,118,0.15);border:1px solid rgba(0,230,118,0.3);color:#00E676}
128
- .bubble{padding:10px 14px;border-radius:12px;font-size:13px;line-height:1.6;max-width:72%}
129
- .bubble.user{background:linear-gradient(135deg,#00C853,#00E676);color:#000;font-weight:500;border-radius:12px 12px 0 12px}
130
- .bubble.bot{background:rgba(255,255,255,0.04);border:1px solid rgba(0,230,118,0.1);color:#c8e6c9;border-radius:12px 12px 12px 0}
131
- .typing{display:flex;gap:4px;padding:10px 14px;background:rgba(255,255,255,0.04);border:1px solid rgba(0,230,118,0.1);border-radius:12px 12px 12px 0;width:fit-content}
132
- .typing span{width:6px;height:6px;background:rgba(0,230,118,0.5);border-radius:50%;animation:typing 1.2s infinite}
133
- .typing span:nth-child(2){animation-delay:0.2s}
134
- .typing span:nth-child(3){animation-delay:0.4s}
135
- @keyframes typing{0%,60%,100%{transform:translateY(0)}30%{transform:translateY(-6px)}}
136
- .input-area{
137
- padding:14px 20px;
138
- border-top:1px solid rgba(0,230,118,0.08);
139
- display:flex;gap:10px;
140
- background:rgba(0,10,5,0.6);
141
- backdrop-filter:blur(10px);
142
- flex-shrink:0;
143
- }
144
- .input-box{
145
- flex:1;
146
- background:rgba(255,255,255,0.04);
147
- border:1px solid rgba(0,230,118,0.15);
148
- border-radius:8px;
149
- padding:10px 14px;
150
- color:#e8f5e9;
151
- font-size:13px;
152
- outline:none;
153
- transition:border-color 0.2s;
154
- }
155
- .input-box:focus{border-color:rgba(0,230,118,0.4)}
156
- .input-box::placeholder{color:rgba(0,230,118,0.25)}
157
- .send-btn{
158
- background:linear-gradient(135deg,#00C853,#00E676);
159
- border:none;border-radius:8px;
160
- padding:10px 18px;
161
- color:#000;font-weight:600;font-size:13px;
162
- cursor:pointer;transition:opacity 0.2s,transform 0.1s;
163
- white-space:nowrap;
164
- }
165
- .send-btn:hover{opacity:0.9}
166
- .send-btn:active{transform:scale(0.97)}
167
- </style>
168
- </head>
169
- <body>
170
- <div class="app">
171
- <div class="sidebar" id="sidebar">
172
- <div class="logo-area">
173
- <div class="logo">NatureCo</div>
174
- <div class="logo-sub" id="ver-label">Terminal</div>
175
- </div>
176
- <div class="section" id="active-bot-section">
177
- <div class="section-label">Aktif Bot</div>
178
- <div class="bot-card">
179
- <div class="avatar">N</div>
180
- <div class="bot-info">
181
- <div class="name" id="active-bot-name">Yükleniyor...</div>
182
- <div class="model" id="active-bot-model">NatureCo</div>
183
- </div>
184
- <div class="online-dot"></div>
185
- </div>
186
- </div>
187
- <div class="section" id="other-bots-section" style="padding-top:0">
188
- <div class="section-label">Diğer Botlar</div>
189
- <div id="other-bots-list"></div>
190
- </div>
191
- <div class="section" style="padding-top:0">
192
- <div class="section-label">Kanallar</div>
193
- <div id="channels-list"></div>
194
- </div>
195
- <div class="section" style="padding-top:0">
196
- <div class="section-label">Skill'ler</div>
197
- <div id="skills-list"></div>
198
- </div>
199
- <div class="section" style="padding-top:0">
200
- <div class="section-label">Hafıza</div>
201
- <div id="memory-section"></div>
202
- </div>
203
- <div class="sidebar-footer">
204
- <a href="https://natureco.me" class="footer-link">natureco.me</a>
205
- </div>
206
- </div>
207
- <div class="chat-area">
208
- <div class="chat-header">
209
- <div class="avatar" style="width:36px;height:36px;font-size:14px">N</div>
210
- <div>
211
- <div class="header-bot-name" id="header-bot-name">Nature Bot</div>
212
- <div class="header-bot-model" id="header-bot-model">NatureCo</div>
213
- </div>
214
- <div class="version-badge" id="version-badge">v2.17.6</div>
215
- </div>
216
- <div class="messages" id="messages"></div>
217
- <div class="input-area">
218
- <input class="input-box" id="input" placeholder="Mesaj yaz..." />
219
- <button class="send-btn" onclick="send()">Gönder</button>
220
- </div>
221
- </div>
222
- </div>
223
- <script>
224
- let cfg = {}, activeBotId = null;
225
-
226
- async function init() {
227
- try {
228
- const r = await fetch('/config');
229
- cfg = await r.json();
230
- activeBotId = cfg.defaultBotId;
231
- document.getElementById('active-bot-name').textContent = cfg.defaultBot || 'Bot';
232
- document.getElementById('header-bot-name').textContent = cfg.defaultBot || 'Bot';
233
- document.getElementById('ver-label').textContent = 'Terminal ' + (cfg.version || '');
234
-
235
- const others = (cfg.bots || []).filter(b => b.id !== activeBotId);
236
- const ol = document.getElementById('other-bots-list');
237
- ol.innerHTML = others.map(b => \`<div class="other-bot" onclick="switchBot('\${b.id}','\${b.name}')"><div class="other-avatar">\${b.name[0]}</div>\${b.name}</div>\`).join('');
238
-
239
- const channels = [
240
- { name: 'Telegram', key: 'telegramToken' },
241
- { name: 'WhatsApp', key: 'whatsappConnected' },
242
- { name: 'Discord', key: 'discordToken' },
243
- { name: 'Gateway', key: 'gatewayRunning' },
244
- ];
245
- document.getElementById('channels-list').innerHTML = channels.map(c => {
246
- const on = !!(cfg[c.key]);
247
- return \`<div class="ch-row"><div class="ch-dot \${on?'on':'off'}"></div><div class="ch-name \${on?'on':'off'}">\${c.name}</div></div>\`;
248
- }).join('');
249
- } catch(e) { console.error(e); }
250
-
251
- try {
252
- const sr = await fetch('/skills');
253
- const skills = await sr.json();
254
- document.getElementById('skills-list').innerHTML = skills.map(s => \`<span class="skill-tag">\${s}</span>\`).join('');
255
- } catch {}
5
+ const DASHBOARD_URL = 'http://127.0.0.1:18789';
256
6
 
7
+ function dashboard(params) {
257
8
  try {
258
- const mr = await fetch('/memory');
259
- const mem = await mr.json();
260
- let html = '';
261
- if (mem.name) html += \`<div class="mem-key">İsim</div><div class="mem-row mem-val">\${mem.name}</div>\`;
262
- if (mem.facts && mem.facts.length) html += \`<div class="mem-key">Bilgiler</div><div class="mem-row mem-val">\${mem.facts.map(f=>typeof f==='object'?f.value:f).join(' · ')}</div>\`;
263
- document.getElementById('memory-section').innerHTML = html || \`<div class="mem-row" style="color:rgba(0,230,118,0.25)">Hafıza boş</div>\`;
264
- } catch {}
265
- }
9
+ const [action] = params || [];
266
10
 
267
- function switchBot(id, name) {
268
- activeBotId = id;
269
- document.getElementById('active-bot-name').textContent = name;
270
- document.getElementById('header-bot-name').textContent = name;
271
- document.getElementById('messages').innerHTML = '';
272
- }
11
+ if (!action || action === 'open') return cmdOpen();
12
+ if (action === 'status') return cmdStatus();
13
+ if (action === 'url') return cmdUrl();
273
14
 
274
- function addMsg(type, text) {
275
- const m = document.getElementById('messages');
276
- const initials = type === 'user' ? 'G' : 'N';
277
- m.innerHTML += \`<div class="msg \${type}"><div class="msg-avatar \${type}">\${initials}</div><div class="bubble \${type}">\${text}</div></div>\`;
278
- m.scrollTop = m.scrollHeight;
15
+ console.log(chalk.red(`\n Unknown dashboard action: ${action}\n`));
16
+ console.log(chalk.gray(' Usage: natureco dashboard [open|status|url]\n'));
17
+ } catch (err) {
18
+ console.log(chalk.red(`\n Dashboard error: ${err.message}\n`));
19
+ }
279
20
  }
280
21
 
281
- function showTyping() {
282
- const m = document.getElementById('messages');
283
- m.innerHTML += \`<div class="msg" id="typing-row"><div class="msg-avatar bot">N</div><div class="typing"><span></span><span></span><span></span></div></div>\`;
284
- m.scrollTop = m.scrollHeight;
285
- }
22
+ function cmdOpen() {
23
+ const { exec } = require('child_process');
24
+ const platform = process.platform;
286
25
 
287
- function hideTyping() {
288
- const t = document.getElementById('typing-row');
289
- if (t) t.remove();
290
- }
26
+ console.log(chalk.cyan('\n Opening dashboard at ' + DASHBOARD_URL + '\n'));
291
27
 
292
- async function send() {
293
- const inp = document.getElementById('input');
294
- const msg = inp.value.trim();
295
- if (!msg || !cfg.apiKey) return;
296
- inp.value = '';
297
- addMsg('user', msg);
298
- showTyping();
299
28
  try {
300
- const r = await fetch('https://api.natureco.me/api/agent/chat', {
301
- method: 'POST',
302
- headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + cfg.apiKey, 'X-User-ID': 'dashboard-user' },
303
- body: JSON.stringify({ agent_id: activeBotId, message: msg, platform: 'dashboard', user_id: 'dashboard-user' })
304
- });
305
- const d = await r.json();
306
- hideTyping();
307
- addMsg('bot', d.reply || d.message || 'Hata');
308
- } catch { hideTyping(); addMsg('bot', 'Bağlantı hatası'); }
29
+ if (platform === 'win32') {
30
+ exec('start ' + DASHBOARD_URL);
31
+ } else if (platform === 'darwin') {
32
+ exec('open ' + DASHBOARD_URL);
33
+ } else {
34
+ exec('xdg-open ' + DASHBOARD_URL);
35
+ }
36
+ } catch (e) {
37
+ console.log(chalk.yellow(' Could not open browser. Visit: ' + DASHBOARD_URL + '\n'));
38
+ }
309
39
  }
310
40
 
311
- document.getElementById('input').addEventListener('keydown', e => { if (e.key === 'Enter') send(); });
312
- init();
313
- </script>
314
- </body>
315
- </html>`;
316
-
317
- function dashboard(action) {
318
- action = action || 'start';
319
- if (action === 'start') {
320
- const cfg = getConfig();
321
- const skills = getSkills();
322
- const fs2 = require('fs');
323
-
324
- let gatewayRunning = false;
325
- try {
326
- const pid = parseInt(fs2.readFileSync(path.join(CONFIG_DIR, 'gateway.pid'), 'utf8'));
327
- process.kill(pid, 0);
328
- gatewayRunning = true;
329
- } catch {}
41
+ function cmdStatus() {
42
+ const socket = new net.Socket();
43
+ const timeout = 2000;
330
44
 
331
- const bots = [];
45
+ socket.setTimeout(timeout);
332
46
 
333
- const server = http.createServer(async (req, res) => {
334
- const cors = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET,POST,DELETE', 'Access-Control-Allow-Headers': 'Content-Type' };
335
-
336
- if (req.method === 'OPTIONS') { res.writeHead(204, cors); res.end(); return; }
47
+ socket.on('connect', () => {
48
+ socket.destroy();
49
+ console.log(chalk.green('\n Dashboard is running at ' + DASHBOARD_URL + '\n'));
50
+ });
337
51
 
338
- if (req.url === '/config') {
339
- res.writeHead(200, { ...cors, 'Content-Type': 'application/json' });
340
- res.end(JSON.stringify({
341
- apiKey: cfg.apiKey,
342
- defaultBot: cfg.defaultBot,
343
- defaultBotId: cfg.defaultBotId,
344
- version: 'v2.17.6',
345
- bots: cfg.bots || [],
346
- telegramToken: cfg.telegramToken || null,
347
- whatsappConnected: cfg.whatsappConnected || false,
348
- discordToken: cfg.discordToken || null,
349
- gatewayRunning,
350
- }));
351
- } else if (req.url === '/skills') {
352
- res.writeHead(200, { ...cors, 'Content-Type': 'application/json' });
353
- res.end(JSON.stringify(skills));
354
- } else if (req.url === '/memory') {
355
- res.writeHead(200, { ...cors, 'Content-Type': 'application/json' });
356
- res.end(JSON.stringify(getMemory(cfg.defaultBotId || '')));
357
- } else {
358
- res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
359
- res.end(HTML);
360
- }
361
- });
52
+ socket.on('timeout', () => {
53
+ socket.destroy();
54
+ console.log(chalk.yellow('\n Dashboard is not responding at ' + DASHBOARD_URL + '\n'));
55
+ });
362
56
 
363
- server.listen(PORT, () => {
364
- fs.mkdirSync(CONFIG_DIR, { recursive: true });
365
- fs.writeFileSync(PID_FILE, String(process.pid));
366
- console.log(chalk.green('\n✅ Dashboard başlatıldı!'));
367
- console.log(chalk.cyan('URL: ') + `http://localhost:${PORT}`);
368
- console.log(chalk.gray('Durdurmak için: Ctrl+C\n'));
369
- openBrowser(`http://localhost:${PORT}`);
370
- });
57
+ socket.on('error', () => {
58
+ socket.destroy();
59
+ console.log(chalk.yellow('\n Dashboard is not running at ' + DASHBOARD_URL + '\n'));
60
+ });
371
61
 
372
- process.on('SIGINT', () => {
373
- try { fs.unlinkSync(PID_FILE); } catch {}
374
- server.close();
375
- process.exit(0);
376
- });
62
+ socket.connect(18789, '127.0.0.1');
63
+ }
377
64
 
378
- } else if (action === 'stop') {
379
- try {
380
- const pid = parseInt(fs.readFileSync(PID_FILE, 'utf8'));
381
- process.kill(pid);
382
- fs.unlinkSync(PID_FILE);
383
- console.log(chalk.green('✅ Dashboard durduruldu'));
384
- } catch { console.log(chalk.red('❌ Dashboard çalışmıyor')); }
385
- } else if (action === 'status') {
386
- try {
387
- const pid = parseInt(fs.readFileSync(PID_FILE, 'utf8'));
388
- process.kill(pid, 0);
389
- console.log(chalk.green('✅ Dashboard çalışıyor'));
390
- console.log('PID:', pid);
391
- console.log('URL: http://localhost:' + PORT);
392
- } catch { console.log(chalk.gray('⚪ Dashboard çalışmıyor')); }
393
- }
65
+ function cmdUrl() {
66
+ console.log(DASHBOARD_URL);
394
67
  }
395
68
 
396
69
  module.exports = dashboard;