natureco-cli 4.7.0 → 4.7.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natureco-cli",
3
- "version": "4.7.0",
3
+ "version": "4.7.2",
4
4
  "description": "OpenClaw'dan daha güvenli, daha hızlı, daha ucuz AI agent CLI. Multi-agent, self-evolving skills, audit log, maliyet optimizasyonu ve NatureCo platform-native.",
5
5
  "bin": {
6
6
  "natureco": "bin/natureco.js"
@@ -237,6 +237,23 @@ async function gateway(action, ...args) {
237
237
  return;
238
238
  }
239
239
 
240
+ if (action === 'stop') {
241
+ const pidFile = path.join(os.homedir(), '.natureco', 'gateway.pid');
242
+ if (!fs.existsSync(pidFile)) {
243
+ console.log('\n' + tui.C.muted(' Gateway zaten durmuş.') + '\n');
244
+ return;
245
+ }
246
+ const pid = parseInt(fs.readFileSync(pidFile, 'utf8').trim(), 10);
247
+ try {
248
+ process.kill(pid, 'SIGTERM');
249
+ fs.unlinkSync(pidFile);
250
+ console.log('\n' + tui.styled(' ✓ Gateway durduruldu (PID: ' + pid + ')', { color: tui.PALETTE.success, bold: true }) + '\n');
251
+ } catch (e) {
252
+ console.log('\n' + tui.C.warning(' Gateway durdurulamadı: ' + e.message) + '\n');
253
+ }
254
+ return;
255
+ }
256
+
240
257
  if (action === 'diagnostics') {
241
258
  const sub = args[0];
242
259
  if (sub === 'export') {
@@ -340,33 +357,64 @@ async function gateway(action, ...args) {
340
357
 
341
358
  async function startGateway() {
342
359
  const config = getConfig();
343
-
360
+
344
361
  if (!config || !config.apiKey) {
345
- F.error('Not logged in. Run "natureco login" first.');
362
+ console.log('\n' + tui.C.red(' ❌ Not logged in. Run "natureco login" first.') + '\n');
346
363
  process.exit(1);
347
364
  }
348
-
349
- F.header('Gateway');
350
-
351
- // WhatsApp provider başlat
352
- if (config.whatsappConnected && config.whatsappBotId) {
353
- const sessionDir = path.join(os.homedir(), '.natureco', 'whatsapp-sessions', config.whatsappBotId);
354
-
355
- if (fs.existsSync(sessionDir)) {
356
- console.log(chalk.cyan('[whatsapp]'), chalk.white(`starting provider (${config.whatsappPhone || 'unknown'})`));
357
- await startWhatsAppProvider(sessionDir, config);
358
- } else {
359
- console.log(chalk.yellow('[whatsapp]'), chalk.gray('session not found, skipping'));
365
+
366
+ // PID dosyası kontrol — zaten çalışıyor mu?
367
+ const pidFile = path.join(os.homedir(), '.natureco', 'gateway.pid');
368
+ if (fs.existsSync(pidFile)) {
369
+ const existingPid = parseInt(fs.readFileSync(pidFile, 'utf8').trim(), 10);
370
+ try {
371
+ process.kill(existingPid, 0); // Test et, canlı mı
372
+ console.log('\n' + tui.styled(' ⚠️ Gateway zaten çalışıyor (PID: ' + existingPid + ')', { color: tui.PALETTE.warning, bold: true }) + '\n');
373
+ console.log(' ' + tui.C.muted('Durdurmak için: ') + tui.C.brand('natureco gateway stop'));
374
+ console.log(' ' + tui.C.muted('Durum için: ') + tui.C.brand('natureco gateway status'));
375
+ console.log('');
376
+ return;
377
+ } catch {
378
+ // Process ölmüş, eski pid dosyasını sil
379
+ fs.unlinkSync(pidFile);
360
380
  }
361
381
  }
362
-
363
- F.success('Gateway started');
364
-
365
- // Keep process alive
366
- process.on('SIGINT', () => {
367
- F.warning('Gateway stopped');
368
- process.exit(0);
382
+
383
+ console.log('\n' + tui.styled(' 🚀 Gateway Başlatılıyor...', { color: tui.PALETTE.primary, bold: true }));
384
+ console.log(tui.styled(' ' + '─'.repeat(56), { color: tui.PALETTE.border }));
385
+
386
+ // Log dosyası
387
+ const logFile = path.join(os.homedir(), '.natureco', 'gateway.log');
388
+ const out = fs.openSync(logFile, 'a');
389
+ const err = fs.openSync(logFile, 'a');
390
+
391
+ // Child process olarak gateway-server.js başlat
392
+ const gatewayPath = path.join(__dirname, 'gateway-server.js');
393
+ const child = spawn(process.execPath, [gatewayPath, '--gateway-worker'], {
394
+ detached: true,
395
+ stdio: ['ignore', out, err],
396
+ env: { ...process.env },
369
397
  });
398
+
399
+ // PID kaydet
400
+ fs.writeFileSync(pidFile, String(child.pid));
401
+ child.unref();
402
+
403
+ // Başarı kartı
404
+ const cardW = 54;
405
+ console.log(tui.styled(' ╭' + '─'.repeat(cardW) + '╮', { color: tui.PALETTE.border }));
406
+ console.log(tui.styled(' │ ', { color: tui.PALETTE.border }) + tui.C.muted('Durum ') + tui.styled(' ✓ Çalışıyor '.padEnd(36), { bg: tui.PALETTE.success, color: '#000', bold: true }) + tui.styled(' │', { color: tui.PALETTE.border }));
407
+ console.log(tui.styled(' │ ', { color: tui.PALETTE.border }) + tui.C.muted('PID ') + tui.styled(String(child.pid).padEnd(40), { color: tui.PALETTE.text, bold: true }) + tui.styled(' │', { color: tui.PALETTE.border }));
408
+ console.log(tui.styled(' │ ', { color: tui.PALETTE.border }) + tui.C.muted('Log dosyası ') + tui.styled(logFile.padEnd(40).slice(0, 40), { color: tui.PALETTE.text }) + tui.styled(' │', { color: tui.PALETTE.border }));
409
+ console.log(tui.styled(' │ ', { color: tui.PALETTE.border }) + tui.C.muted('Provider ') + tui.styled((config.providerUrl || '—').replace('https://', '').padEnd(40).slice(0, 40), { color: tui.PALETTE.text }) + tui.styled(' │', { color: tui.PALETTE.border }));
410
+ console.log(tui.styled(' │ ', { color: tui.PALETTE.border }) + tui.C.muted('Telegram ') + tui.styled((config.telegramToken ? '✓ Token ayarlı' : '✗ Token yok').padEnd(40), { color: config.telegramToken ? tui.PALETTE.success : tui.PALETTE.warning, bold: true }) + tui.styled(' │', { color: tui.PALETTE.border }));
411
+ console.log(tui.styled(' ╰' + '─'.repeat(cardW) + '╯', { color: tui.PALETTE.border }));
412
+
413
+ console.log('\n ' + tui.C.muted('Komutlar:'));
414
+ console.log(' ' + tui.C.muted(' Durum: ') + tui.C.brand('natureco gateway status'));
415
+ console.log(' ' + tui.C.muted(' Log: ') + tui.C.brand('natureco gateway logs') + ' ' + tui.C.muted('veya ') + tui.C.brand('tail -f ' + logFile));
416
+ console.log(' ' + tui.C.muted(' Dur: ') + tui.C.brand('natureco gateway stop'));
417
+ console.log('');
370
418
  }
371
419
 
372
420
  async function startWhatsAppProvider(sessionDir, config) {
@@ -144,10 +144,16 @@ async function cmdWizard() {
144
144
  console.log(chalk.gray(' Atlamak için hepsini boş bırakın, sonra: natureco <kanal> connect\n'));
145
145
 
146
146
  const integrations = [
147
- { key: 'telegramToken', name: 'Telegram', hint: 'BotFather\'dan al (@BotFather → /newbot → token)' },
148
- { key: 'whatsappPhone', name: 'WhatsApp', hint: 'Telefon numaranızı girin (örn: +905422842631)' },
149
- { key: 'discordToken', name: 'Discord', hint: 'Discord bot token (Discord Developer Portal)' },
150
- { key: 'slackToken', name: 'Slack', hint: 'Slack bot token (api.slack.com/apps)' },
147
+ { key: 'telegramToken', name: 'Telegram', hint: 'BotFather\'dan al (@BotFather → /newbot → token)' },
148
+ { key: 'whatsappPhone', name: 'WhatsApp', hint: 'Telefon numaranızı girin (örn: +905422842631)' },
149
+ { key: 'discordToken', name: 'Discord', hint: 'Discord bot token (Discord Developer Portal)' },
150
+ { key: 'slackToken', name: 'Slack', hint: 'Slack bot token (api.slack.com/apps)' },
151
+ { key: 'signalBotId', name: 'Signal', hint: 'Signal bot numarası veya ID' },
152
+ { key: 'ircBotId', name: 'IRC', hint: 'IRC bot kullanıcı adı (örn: NatureCoBot)' },
153
+ { key: 'mattermostBotId', name: 'Mattermost', hint: 'Mattermost bot kullanıcı adı' },
154
+ { key: 'imessageBotId', name: 'iMessage', hint: 'iMessage bridge endpoint veya ad' },
155
+ { key: 'smsBotId', name: 'SMS (Twilio)', hint: 'Twilio hesap SID veya bot ID' },
156
+ { key: 'webhooks', name: 'Webhooks', hint: 'Webhook URL (veya boş bırakın, sonra: natureco webhooks add)' },
151
157
  ];
152
158
 
153
159
  for (const integ of integrations) {