natureco-cli 4.7.1 → 4.7.3

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.1",
3
+ "version": "4.7.3",
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) {
@@ -319,6 +319,9 @@ async function startRepl(args) {
319
319
  `Sen Claude, GPT veya başka bir marka değilsin — sen ${memory.botName || 'İchigo'}'sin.`,
320
320
  'Kullanıcı Türkçe yazıyorsa Türkçe cevap ver, İngilizce yazıyorsa İngilizce.',
321
321
  'Cevapların kısa, net ve faydalı olsun. Markdown kullanabilirsin ama abartma.',
322
+ // v4.7.3: Tool call simülasyonunu kapat — model tool isteyemez,
323
+ // sadece açıklayıcı text yazar. CLI tool sistemi kullanıcı isteğiyle çalışır.
324
+ 'ÖNEMLİ: <tool_call>, <invoke>, function_call veya benzeri XML/JSON formatında tool çağrısı SİMÜLE ETME. Sadece düz metin cevap ver. Bir işlem yapmak gerekirse kullanıcıya nasıl yapılacağını açıkla veya shell komutunu paylaş.',
322
325
  memory.nickname && memory.name
323
326
  ? `Kullanıcının adı: ${memory.name}. Sana "${memory.nickname}" diye hitap etmesinden hoşlanıyor.`
324
327
  : memory.name ? `Kullanıcının adı: ${memory.name}.` : '',