vantuz 3.3.4 → 3.3.6

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/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  /**
4
4
  * 🐙 VANTUZ CLI v3.2
@@ -72,46 +72,46 @@ function saveConfigJson(config) {
72
72
  }
73
73
  }
74
74
 
75
- function clearScreen() {
76
- process.stdout.write('\x1Bc');
77
- }
78
-
79
- async function promptInput(question) {
80
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
81
- const answer = await new Promise(resolve => rl.question(question, resolve));
82
- rl.close();
83
- return answer.trim();
84
- }
85
-
86
- function normalizePhone(input) {
87
- if (!input) return '';
88
- const cleaned = input.replace(/[\s-]/g, '');
89
- return cleaned.startsWith('+') ? cleaned : `+${cleaned}`;
90
- }
91
-
92
- function loadOpenclawConfig(configPath) {
93
- try {
94
- if (fs.existsSync(configPath)) {
95
- return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
96
- }
97
- } catch (e) {
98
- console.log(c('red', `Gateway config okunamadı: ${e.message}`));
99
- }
100
- return {};
101
- }
102
-
103
- function saveOpenclawConfig(configPath, config) {
104
- try {
105
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
106
- return true;
107
- } catch (e) {
108
- console.log(c('red', `Gateway config yazılamadı: ${e.message}`));
109
- return false;
110
- }
111
- }
112
-
75
+ function clearScreen() {
76
+ process.stdout.write('\x1Bc');
77
+ }
78
+
79
+ async function promptInput(question) {
80
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
81
+ const answer = await new Promise(resolve => rl.question(question, resolve));
82
+ rl.close();
83
+ return answer.trim();
84
+ }
85
+
86
+ function normalizePhone(input) {
87
+ if (!input) return '';
88
+ const cleaned = input.replace(/[\s-]/g, '');
89
+ return cleaned.startsWith('+') ? cleaned : `+${cleaned}`;
90
+ }
91
+
92
+ function loadOpenclawConfig(configPath) {
93
+ try {
94
+ if (fs.existsSync(configPath)) {
95
+ return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
96
+ }
97
+ } catch (e) {
98
+ console.log(c('red', `Gateway config okunamadı: ${e.message}`));
99
+ }
100
+ return {};
101
+ }
102
+
103
+ function saveOpenclawConfig(configPath, config) {
104
+ try {
105
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
106
+ return true;
107
+ } catch (e) {
108
+ console.log(c('red', `Gateway config yazılamadı: ${e.message}`));
109
+ return false;
110
+ }
111
+ }
112
+
113
113
  function printHeader() {
114
- const version = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url))).version;
114
+ const version = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf-8')).version;
115
115
  console.log(c('cyan', `
116
116
  ██╗ ██╗ █████╗ ███╗ ██╗████████╗██╗ ██╗███████╗
117
117
  ██║ ██║██╔══██╗████╗ ██║╚══██╔══╝██║ ██║╚══███╔╝
@@ -121,7 +121,7 @@ function printHeader() {
121
121
  ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚══════╝
122
122
  `));
123
123
  console.log(c('magenta', ` Enterprise E-Commerce Management System v${version}`));
124
- console.log(c('dim', ' Powered by Vantuz Gateway'));
124
+ console.log(c('dim', ' Powered by nca'));
125
125
  console.log(c('dim', ' ----------------------------------------------------------\n'));
126
126
  }
127
127
 
@@ -141,7 +141,7 @@ async function showSpinner(text, duration = 1000) {
141
141
  // COMMANDS
142
142
  // ═══════════════════════════════════════════════════════════════════════════
143
143
 
144
- async function runTUI() {
144
+ async function runTUI() {
145
145
  clearScreen();
146
146
  printHeader();
147
147
 
@@ -161,7 +161,7 @@ async function runTUI() {
161
161
 
162
162
  console.log(`${c('green', '●')} Sistem Aktif ${c('dim', `(${status.connectedCount}/${status.totalPlatforms} Platform Bağlı)`)}`);
163
163
  console.log(`${c('blue', 'ℹ')} AI Sağlayıcı: ${c('bold', status.aiProvider || 'Gemini')}`);
164
- console.log(`${c('yellow', '⚡')} Komutlar: ${c('cyan', '/stok, /siparis, /rapor, /analiz, /durum, /temizle, /exit')}\n`);
164
+ console.log(`${c('yellow', '⚡')} Komutlar: ${c('cyan', '/stok, /siparis, /rapor, /analiz, /durum, /temizle, /exit')}\n`);
165
165
 
166
166
  const rl = readline.createInterface({
167
167
  input: process.stdin,
@@ -194,42 +194,42 @@ async function runTUI() {
194
194
  console.log(` ${c('cyan', '/temizle')} - Ekranı temizler`);
195
195
  console.log(` ${c('cyan', '/exit')} - Çıkış\n`);
196
196
  break;
197
- case '/stok':
198
- console.log(c('dim', 'Stok verileri çekiliyor...'));
199
- const stocks = await engine.getStock();
200
- if (stocks.length === 0) console.log(c('yellow', 'Bağlı platform bulunamadı.'));
201
- stocks.forEach(s => {
202
- console.log(`\n${s.icon} ${c('bold', s.platform.toUpperCase())}`);
203
- s.products.slice(0, 5).forEach(p => {
204
- console.log(` - ${p.title}: ${c('green', p.stock)} Adet | ${c('yellow', p.price)} TL`);
205
- });
206
- });
207
- break;
208
- case '/analiz':
209
- process.stdout.write(c('dim', 'Analiz hazırlanıyor... '));
210
- const analysis = await engine.chat('satış ve stok analiz raporu hazırla');
211
- process.stdout.write('\r' + ' '.repeat(30) + '\r');
212
- console.log(`\n${analysis}\n`);
213
- break;
214
- case '/siparis':
215
- console.log(c('dim', 'Siparişler çekiliyor...'));
216
- const orders = await engine.getOrders({ size: 50, allStatuses: true });
217
- const activeOrders = Array.isArray(orders)
218
- ? orders.filter(o => ['Created', 'Picking', 'UnPacked'].includes(String(o.status || o.shipmentPackageStatus || o.orderStatus)))
219
- : [];
220
- const visible = activeOrders.slice(0, 5);
221
- if (!Array.isArray(orders) || visible.length === 0) {
222
- console.log(c('yellow', 'Son sipariş bulunamadı.'));
223
- break;
224
- }
225
- visible.forEach(o => {
226
- const names = Array.isArray(o.lines)
227
- ? o.lines.map(l => l?.productName || l?.name).filter(Boolean)
228
- : [];
229
- const namePart = names.length > 0 ? ` | ${names.join(', ')}` : '';
230
- console.log(`${o._icon} [#${o.orderNumber || o.id}] ${c('bold', o.customerName || 'Müşteri')}: ${c('green', o.totalPrice ?? o.totalAmount ?? o.total ?? '—')} TL (${o._platform})${namePart}`);
231
- });
232
- break;
197
+ case '/stok':
198
+ console.log(c('dim', 'Stok verileri çekiliyor...'));
199
+ const stocks = await engine.getStock();
200
+ if (stocks.length === 0) console.log(c('yellow', 'Bağlı platform bulunamadı.'));
201
+ stocks.forEach(s => {
202
+ console.log(`\n${s.icon} ${c('bold', s.platform.toUpperCase())}`);
203
+ s.products.slice(0, 5).forEach(p => {
204
+ console.log(` - ${p.title}: ${c('green', p.stock)} Adet | ${c('yellow', p.price)} TL`);
205
+ });
206
+ });
207
+ break;
208
+ case '/analiz':
209
+ process.stdout.write(c('dim', 'Analiz hazırlanıyor... '));
210
+ const analysis = await engine.chat('satış ve stok analiz raporu hazırla');
211
+ process.stdout.write('\r' + ' '.repeat(30) + '\r');
212
+ console.log(`\n${analysis}\n`);
213
+ break;
214
+ case '/siparis':
215
+ console.log(c('dim', 'Siparişler çekiliyor...'));
216
+ const orders = await engine.getOrders({ size: 50, allStatuses: true });
217
+ const activeOrders = Array.isArray(orders)
218
+ ? orders.filter(o => ['Created', 'Picking', 'UnPacked'].includes(String(o.status || o.shipmentPackageStatus || o.orderStatus)))
219
+ : [];
220
+ const visible = activeOrders.slice(0, 5);
221
+ if (!Array.isArray(orders) || visible.length === 0) {
222
+ console.log(c('yellow', 'Son sipariş bulunamadı.'));
223
+ break;
224
+ }
225
+ visible.forEach(o => {
226
+ const names = Array.isArray(o.lines)
227
+ ? o.lines.map(l => l?.productName || l?.name).filter(Boolean)
228
+ : [];
229
+ const namePart = names.length > 0 ? ` | ${names.join(', ')}` : '';
230
+ console.log(`${o._icon} [#${o.orderNumber || o.id}] ${c('bold', o.customerName || 'Müşteri')}: ${c('green', o.totalPrice ?? o.totalAmount ?? o.total ?? '—')} TL (${o._platform})${namePart}`);
231
+ });
232
+ break;
233
233
  case '/durum':
234
234
  const s = engine.getStatus();
235
235
  console.log(c('yellow', '\n── Sistem Durumu ──'));
@@ -242,12 +242,12 @@ async function runTUI() {
242
242
  default:
243
243
  console.log(c('red', `[HATA] Bilinmeyen komut: ${cmd}. /help yazın.`));
244
244
  }
245
- } else {
246
- process.stdout.write(c('dim', 'Düşünüyor... '));
247
- const response = await engine.handleMessage(input, { channel: 'local', from: 'local' });
248
- process.stdout.write('\r' + ' '.repeat(20) + '\r');
249
- console.log(`\n${c('cyan', '🐙 Vantuz:')}\n${response}\n`);
250
- }
245
+ } else {
246
+ process.stdout.write(c('dim', 'Düşünüyor... '));
247
+ const response = await engine.handleMessage(input, { channel: 'local', from: 'local' });
248
+ process.stdout.write('\r' + ' '.repeat(20) + '\r');
249
+ console.log(`\n${c('cyan', '🐙 Vantuz:')}\n${response}\n`);
250
+ }
251
251
  } catch (e) {
252
252
  console.log(c('red', `\n[HATA] ${e.message}`));
253
253
  }
@@ -324,7 +324,7 @@ async function runLogs(args) {
324
324
  console.log(getLogs(n));
325
325
  }
326
326
 
327
- async function runGateway(args) {
327
+ async function runGateway(args) {
328
328
  const sub = args[1]?.toLowerCase();
329
329
  const gw = await getGateway();
330
330
  const info = gw.getInfo();
@@ -340,8 +340,8 @@ async function runGateway(args) {
340
340
  console.log('');
341
341
 
342
342
  if (!info.connected) {
343
- console.log(c('dim', ' Gateway başlatmak için: vantuz gateway run'));
344
- console.log(c('dim', ' Veya: start.bat\n'));
343
+ console.log(c('dim', ' Gateway başlatmak için: vantuz gateway run'));
344
+ console.log(c('dim', ' Veya: start.bat\n'));
345
345
  }
346
346
  return;
347
347
  }
@@ -375,18 +375,18 @@ async function runGateway(args) {
375
375
  return;
376
376
  }
377
377
 
378
- if (sub === 'run' || sub === 'start') {
379
- console.log(c('cyan', 'Gateway başlatılıyor...'));
380
- const result = await gw.start();
381
- if (result.success) {
382
- console.log(c('green', '✔ Gateway arka planda başlatıldı.'));
383
- console.log(c('dim', 'Birkaç saniye içinde hazır olacak.'));
384
- console.log(c('dim', 'Kontrol için: vantuz gateway status'));
385
- } else {
386
- console.log(c('red', result.error || 'Gateway başlatılamadı'));
387
- }
388
- return;
389
- }
378
+ if (sub === 'run' || sub === 'start') {
379
+ console.log(c('cyan', 'Gateway başlatılıyor...'));
380
+ const result = await gw.start();
381
+ if (result.success) {
382
+ console.log(c('green', '✔ Gateway arka planda başlatıldı.'));
383
+ console.log(c('dim', 'Birkaç saniye içinde hazır olacak.'));
384
+ console.log(c('dim', 'Kontrol için: vantuz gateway status'));
385
+ } else {
386
+ console.log(c('red', result.error || 'Gateway başlatılamadı'));
387
+ }
388
+ return;
389
+ }
390
390
 
391
391
  console.log(c('red', 'Kullanım: vantuz gateway [status|health|models|run]'));
392
392
  }
@@ -436,72 +436,72 @@ async function runDoctor() {
436
436
  console.log('');
437
437
  }
438
438
 
439
- async function runChannels(args) {
440
- const sub = args[1]?.toLowerCase();
441
- if (sub === 'login') {
442
- printHeader();
443
- console.log(c('yellow', '── WhatsApp Login ──\n'));
444
-
445
- const openclawDir = path.join(os.homedir(), '.openclaw');
446
- const configPath = path.join(openclawDir, 'openclaw.json');
447
-
448
- if (!fs.existsSync(openclawDir)) {
449
- fs.mkdirSync(openclawDir, { recursive: true });
450
- }
451
-
452
- const rawPhone = await promptInput('WhatsApp numaranız (E.164, örn: +905551112233): ');
453
- const phone = normalizePhone(rawPhone);
454
- if (!phone || phone === '+') {
455
- console.log(c('red', 'Geçerli bir numara girilmedi.'));
456
- process.exitCode = 2;
457
- return;
458
- }
459
-
460
- const config = loadOpenclawConfig(configPath);
461
- if (!config.channels) config.channels = {};
462
- if (!config.channels.whatsapp) config.channels.whatsapp = {};
463
-
464
- if (!config.channels.whatsapp.dmPolicy) {
465
- config.channels.whatsapp.dmPolicy = 'allowlist';
466
- }
467
-
468
- const allowFrom = Array.isArray(config.channels.whatsapp.allowFrom)
469
- ? config.channels.whatsapp.allowFrom
470
- : [];
471
- if (!allowFrom.includes(phone)) {
472
- allowFrom.push(phone);
473
- }
474
- config.channels.whatsapp.allowFrom = allowFrom;
475
-
476
- const saved = saveOpenclawConfig(configPath, config);
477
- if (!saved) {
478
- process.exitCode = 1;
479
- return;
480
- }
481
-
482
- console.log(c('green', '✔ Gateway config güncellendi.'));
483
- console.log(c('dim', 'Şimdi QR için login başlatılıyor...\n'));
484
-
485
- try {
486
- const { spawn } = await import('child_process');
487
- const child = spawn('openclaw', ['channels', 'login'], {
488
- stdio: 'inherit',
489
- shell: true
490
- });
491
- await new Promise((resolve, reject) => {
492
- child.on('exit', code => (code === 0 ? resolve() : reject(new Error(`gateway exit ${code}`))));
493
- child.on('error', reject);
494
- });
495
- console.log(c('green', '\n✔ QR eşleştirme tamamlandı.'));
496
- console.log(c('dim', 'Gateway başlatmak için: vantuz gateway run'));
497
- } catch (e) {
498
- console.log(c('red', `Login çalıştırılamadı: ${e.message}`));
499
- }
500
- return;
501
- }
502
-
503
- printHeader();
504
- console.log(c('yellow', '── İletişim Kanalları ──\n'));
439
+ async function runChannels(args) {
440
+ const sub = args[1]?.toLowerCase();
441
+ if (sub === 'login') {
442
+ printHeader();
443
+ console.log(c('yellow', '── WhatsApp Login ──\n'));
444
+
445
+ const openclawDir = path.join(os.homedir(), '.openclaw');
446
+ const configPath = path.join(openclawDir, 'openclaw.json');
447
+
448
+ if (!fs.existsSync(openclawDir)) {
449
+ fs.mkdirSync(openclawDir, { recursive: true });
450
+ }
451
+
452
+ const rawPhone = await promptInput('WhatsApp numaranız (E.164, örn: +905551112233): ');
453
+ const phone = normalizePhone(rawPhone);
454
+ if (!phone || phone === '+') {
455
+ console.log(c('red', 'Geçerli bir numara girilmedi.'));
456
+ process.exitCode = 2;
457
+ return;
458
+ }
459
+
460
+ const config = loadOpenclawConfig(configPath);
461
+ if (!config.channels) config.channels = {};
462
+ if (!config.channels.whatsapp) config.channels.whatsapp = {};
463
+
464
+ if (!config.channels.whatsapp.dmPolicy) {
465
+ config.channels.whatsapp.dmPolicy = 'allowlist';
466
+ }
467
+
468
+ const allowFrom = Array.isArray(config.channels.whatsapp.allowFrom)
469
+ ? config.channels.whatsapp.allowFrom
470
+ : [];
471
+ if (!allowFrom.includes(phone)) {
472
+ allowFrom.push(phone);
473
+ }
474
+ config.channels.whatsapp.allowFrom = allowFrom;
475
+
476
+ const saved = saveOpenclawConfig(configPath, config);
477
+ if (!saved) {
478
+ process.exitCode = 1;
479
+ return;
480
+ }
481
+
482
+ console.log(c('green', '✔ Gateway config güncellendi.'));
483
+ console.log(c('dim', 'Şimdi QR için login başlatılıyor...\n'));
484
+
485
+ try {
486
+ const { spawn } = await import('child_process');
487
+ const child = spawn('openclaw', ['channels', 'login'], {
488
+ stdio: 'inherit',
489
+ shell: true
490
+ });
491
+ await new Promise((resolve, reject) => {
492
+ child.on('exit', code => (code === 0 ? resolve() : reject(new Error(`gateway exit ${code}`))));
493
+ child.on('error', reject);
494
+ });
495
+ console.log(c('green', '\n✔ QR eşleştirme tamamlandı.'));
496
+ console.log(c('dim', 'Gateway başlatmak için: vantuz gateway run'));
497
+ } catch (e) {
498
+ console.log(c('red', `Login çalıştırılamadı: ${e.message}`));
499
+ }
500
+ return;
501
+ }
502
+
503
+ printHeader();
504
+ console.log(c('yellow', '── İletişim Kanalları ──\n'));
505
505
 
506
506
  const engine = await getEngine();
507
507
  const status = engine.getStatus();
@@ -573,9 +573,9 @@ async function main() {
573
573
  console.log(` ${c('cyan', 'vantuz status')} - Durum kontrolü`);
574
574
  console.log(` ${c('cyan', 'vantuz gateway')} - Gateway yönetimi`);
575
575
  console.log(` ${c('cyan', 'vantuz doctor')} - Sistem sağlık kontrolü`);
576
- console.log(` ${c('cyan', 'vantuz channels')} - İletişim kanalları`);
577
- console.log(` ${c('cyan', 'vantuz channels login')} - WhatsApp QR login`);
578
- console.log(` ${c('cyan', 'vantuz config')} - Ayarları göster/güncelle`);
576
+ console.log(` ${c('cyan', 'vantuz channels')} - İletişim kanalları`);
577
+ console.log(` ${c('cyan', 'vantuz channels login')} - WhatsApp QR login`);
578
+ console.log(` ${c('cyan', 'vantuz config')} - Ayarları göster/güncelle`);
579
579
  console.log(` ${c('cyan', 'vantuz logs')} - Logları göster`);
580
580
  console.log(`\nKurulum ve başlangıç ayarları için: ${c('cyan', 'vantuz config init')}`);
581
581
  process.exitCode = command ? 2 : 0;