vantuz 3.2.4 → 3.2.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.
@@ -0,0 +1,340 @@
1
+ /**
2
+ * 🌐 VANTUZ GATEWAY BRIDGE v1.0
3
+ * Vantuz ↔ Vantuz Gateway iletişim katmanı
4
+ *
5
+ * Gateway üzerinden:
6
+ * - AI model yönlendirmesi
7
+ * - Kanal yönetimi (WhatsApp, Telegram)
8
+ * - Plugin RPC çağrıları
9
+ * - Sistem durumu sorgulama
10
+ */
11
+
12
+ import axios from 'axios';
13
+ import fs from 'fs';
14
+ import path from 'path';
15
+ import os from 'os';
16
+ import { log } from './ai-provider.js';
17
+
18
+ // ═══════════════════════════════════════════════════════════════════════════
19
+ // CONFIG - Gateway ayarları
20
+ // ═══════════════════════════════════════════════════════════════════════════
21
+
22
+ const OPENCLAW_HOME = path.join(process.cwd(), '.openclaw');
23
+ const OPENCLAW_CONFIG = path.join(OPENCLAW_HOME, 'openclaw.json');
24
+ const VANTUZ_HOME = path.join(os.homedir(), '.vantuz');
25
+
26
+ function loadGatewayConfig() {
27
+ try {
28
+ if (fs.existsSync(OPENCLAW_CONFIG)) {
29
+ return JSON.parse(fs.readFileSync(OPENCLAW_CONFIG, 'utf-8'));
30
+ }
31
+ } catch (e) {
32
+ log('WARN', 'Gateway config okunamadı', { error: e.message });
33
+ }
34
+ return null;
35
+ }
36
+
37
+ function getGatewayUrl() {
38
+ // Gateway cmd dosyasından port oku
39
+ const gatewayCmd = path.join(OPENCLAW_HOME, 'gateway.cmd');
40
+ let port = 18789; // Varsayılan
41
+
42
+ try {
43
+ if (fs.existsSync(gatewayCmd)) {
44
+ const content = fs.readFileSync(gatewayCmd, 'utf-8');
45
+ const portMatch = content.match(/OPENCLAW_GATEWAY_PORT=(\d+)/);
46
+ if (portMatch) port = parseInt(portMatch[1]);
47
+ }
48
+ } catch (e) { }
49
+
50
+ return `http://localhost:${port}`;
51
+ }
52
+
53
+ function getGatewayToken() {
54
+ const config = loadGatewayConfig();
55
+ return config?.gateway?.auth?.token || null;
56
+ }
57
+
58
+ // ═══════════════════════════════════════════════════════════════════════════
59
+ // GATEWAY CLIENT
60
+ // ═══════════════════════════════════════════════════════════════════════════
61
+
62
+ export class VantuzGateway {
63
+ constructor() {
64
+ this.baseUrl = getGatewayUrl();
65
+ this.token = getGatewayToken();
66
+ this.connected = false;
67
+ this.version = null;
68
+ this.config = loadGatewayConfig();
69
+ }
70
+
71
+ /**
72
+ * HTTP Headers (token auth)
73
+ */
74
+ _headers() {
75
+ const headers = { 'Content-Type': 'application/json' };
76
+ if (this.token) {
77
+ headers['Authorization'] = `Bearer ${this.token}`;
78
+ }
79
+ return headers;
80
+ }
81
+
82
+ /**
83
+ * Gateway'e HTTP isteği gönder
84
+ */
85
+ async _request(method, endpoint, data = null, timeout = 10000) {
86
+ try {
87
+ const config = {
88
+ method,
89
+ url: `${this.baseUrl}${endpoint}`,
90
+ headers: this._headers(),
91
+ timeout
92
+ };
93
+
94
+ if (data) config.data = data;
95
+
96
+ const response = await axios(config);
97
+ return { success: true, data: response.data };
98
+ } catch (error) {
99
+ if (error.code === 'ECONNREFUSED') {
100
+ return { success: false, error: 'Gateway çalışmıyor', code: 'NOT_RUNNING' };
101
+ }
102
+ if (error.response?.status === 401) {
103
+ return { success: false, error: 'Token geçersiz', code: 'AUTH_FAILED' };
104
+ }
105
+ return {
106
+ success: false,
107
+ error: error.message,
108
+ code: error.code || 'UNKNOWN'
109
+ };
110
+ }
111
+ }
112
+
113
+ // ═══════════════════════════════════════════════════════════════════════
114
+ // SAĞLIK & DURUM
115
+ // ═══════════════════════════════════════════════════════════════════════
116
+
117
+ /**
118
+ * Gateway sağlık kontrolü
119
+ */
120
+ async health() {
121
+ const result = await this._request('GET', '/health');
122
+ this.connected = result.success;
123
+ if (result.success) {
124
+ this.version = result.data?.version || 'unknown';
125
+ }
126
+ return result;
127
+ }
128
+
129
+ /**
130
+ * Detaylı sistem durumu
131
+ */
132
+ async status() {
133
+ const result = await this._request('GET', '/status');
134
+ if (result.success) {
135
+ this.connected = true;
136
+ }
137
+ return result;
138
+ }
139
+
140
+ /**
141
+ * Gateway bağlı mı?
142
+ */
143
+ isConnected() {
144
+ return this.connected;
145
+ }
146
+
147
+ /**
148
+ * Gateway bilgileri
149
+ */
150
+ getInfo() {
151
+ return {
152
+ url: this.baseUrl,
153
+ connected: this.connected,
154
+ version: this.version,
155
+ hasToken: !!this.token,
156
+ configFound: !!this.config
157
+ };
158
+ }
159
+
160
+ // ═══════════════════════════════════════════════════════════════════════
161
+ // AI MODEL YÖNLENDİRME
162
+ // ═══════════════════════════════════════════════════════════════════════
163
+
164
+ /**
165
+ * Gateway üzerinden AI chat
166
+ * Gateway AI model routing sağlıyorsa kullan
167
+ */
168
+ async chat(message, options = {}) {
169
+ const result = await this._request('POST', '/v1/chat/completions', {
170
+ messages: [
171
+ ...(options.systemPrompt ? [{ role: 'system', content: options.systemPrompt }] : []),
172
+ { role: 'user', content: message }
173
+ ],
174
+ model: options.model || 'default',
175
+ max_tokens: options.maxTokens || 1000,
176
+ temperature: options.temperature || 0.7
177
+ }, 30000);
178
+
179
+ if (result.success) {
180
+ const text = result.data?.choices?.[0]?.message?.content;
181
+ return { success: true, response: text };
182
+ }
183
+
184
+ return { success: false, error: result.error };
185
+ }
186
+
187
+ /**
188
+ * Kullanılabilir AI modelleri
189
+ */
190
+ async getModels() {
191
+ return await this._request('GET', '/v1/models');
192
+ }
193
+
194
+ // ═══════════════════════════════════════════════════════════════════════
195
+ // KANAL YÖNETİMİ
196
+ // ═══════════════════════════════════════════════════════════════════════
197
+
198
+ /**
199
+ * Kanal listesi ve durumları
200
+ */
201
+ async getChannels() {
202
+ return await this._request('GET', '/channels');
203
+ }
204
+
205
+ /**
206
+ * Kanal bağlantı durumu
207
+ */
208
+ async getChannelStatus(channelName) {
209
+ return await this._request('GET', `/channels/${channelName}/status`);
210
+ }
211
+
212
+ /**
213
+ * Kanal üzerinden mesaj gönder
214
+ */
215
+ async sendMessage(channel, to, message) {
216
+ return await this._request('POST', `/channels/${channel}/send`, {
217
+ to,
218
+ message,
219
+ type: 'text'
220
+ });
221
+ }
222
+
223
+ // ═══════════════════════════════════════════════════════════════════════
224
+ // RPC - Plugin Gateway Methodları
225
+ // ═══════════════════════════════════════════════════════════════════════
226
+
227
+ /**
228
+ * Gateway RPC çağrısı
229
+ */
230
+ async call(method, params = {}) {
231
+ return await this._request('POST', '/rpc', {
232
+ method,
233
+ params
234
+ });
235
+ }
236
+
237
+ /**
238
+ * Vantuz plugin durumu
239
+ */
240
+ async getPluginStatus() {
241
+ return await this.call('vantuz.status');
242
+ }
243
+
244
+ /**
245
+ * Vantuz plugin config
246
+ */
247
+ async getPluginConfig() {
248
+ return await this.call('vantuz.config', { action: 'get' });
249
+ }
250
+
251
+ // ═══════════════════════════════════════════════════════════════════════
252
+ // CRON & ZAMANLAMA
253
+ // ═══════════════════════════════════════════════════════════════════════
254
+
255
+ /**
256
+ * Zamanlanmış görev listesi
257
+ */
258
+ async getCronJobs() {
259
+ return await this._request('GET', '/cron');
260
+ }
261
+
262
+ /**
263
+ * Zamanlanmış görev ekle
264
+ */
265
+ async addCronJob(schedule, command, description) {
266
+ return await this._request('POST', '/cron', {
267
+ schedule,
268
+ command,
269
+ description
270
+ });
271
+ }
272
+
273
+ // ═══════════════════════════════════════════════════════════════════════
274
+ // HAFIZA (Memory)
275
+ // ═══════════════════════════════════════════════════════════════════════
276
+
277
+ /**
278
+ * Gateway hafıza durumu
279
+ */
280
+ async getMemoryStatus() {
281
+ return await this._request('GET', '/memory/status');
282
+ }
283
+
284
+ /**
285
+ * Hafıza araması
286
+ */
287
+ async searchMemory(query) {
288
+ return await this._request('POST', '/memory/search', { query });
289
+ }
290
+
291
+ // ═══════════════════════════════════════════════════════════════════════
292
+ // LOGLAR
293
+ // ═══════════════════════════════════════════════════════════════════════
294
+
295
+ /**
296
+ * Gateway logları
297
+ */
298
+ async getLogs(limit = 50) {
299
+ return await this._request('GET', `/logs?limit=${limit}`);
300
+ }
301
+ }
302
+
303
+ // ═══════════════════════════════════════════════════════════════════════════
304
+ // SINGLETON & FACTORY
305
+ // ═══════════════════════════════════════════════════════════════════════════
306
+
307
+ let gatewayInstance = null;
308
+
309
+ /**
310
+ * Vantuz Gateway singleton instance
311
+ * Otomatik bağlantı kontrolü yapar
312
+ */
313
+ export async function getGateway() {
314
+ if (!gatewayInstance) {
315
+ gatewayInstance = new VantuzGateway();
316
+
317
+ // İlk bağlantı denemesi
318
+ const health = await gatewayInstance.health();
319
+ if (health.success) {
320
+ log('INFO', 'Vantuz Gateway bağlantısı başarılı', {
321
+ url: gatewayInstance.baseUrl,
322
+ version: gatewayInstance.version
323
+ });
324
+ } else {
325
+ log('WARN', 'Vantuz Gateway erişilemez, direkt mod kullanılacak', {
326
+ error: health.error
327
+ });
328
+ }
329
+ }
330
+ return gatewayInstance;
331
+ }
332
+
333
+ /**
334
+ * Gateway durumunu sıfırla (reconnect için)
335
+ */
336
+ export function resetGateway() {
337
+ gatewayInstance = null;
338
+ }
339
+
340
+ export default VantuzGateway;
package/onboard.js CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  /**
4
4
  * VANTUZ - Profesyonel Kurulum Sihirbazı
5
- * v3.2.2 Fix - Stable Input Handling
5
+ * v3.2.5 - OpenClaw Gateway Entegrasyonlu
6
6
  */
7
7
 
8
8
  import fs from 'fs';
@@ -10,7 +10,6 @@ import path from 'path';
10
10
  import os from 'os';
11
11
  import readline from 'readline';
12
12
  import { fileURLToPath } from 'url';
13
- import { LicenseManager } from './plugins/vantuz/services/license.js';
14
13
 
15
14
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
16
15
  const VANTUZ_HOME = path.join(os.homedir(), '.vantuz');
@@ -39,10 +38,10 @@ const WELCOME_BOX = `
39
38
 
40
39
  Bu sihirbaz kurulumu tamamlamanıza yardımcı olacak:
41
40
 
42
- [ ] Lisans Aktivasyonu (Zorunlu)
43
41
  [ ] AI Servis Seçimi
44
42
  [ ] Pazaryeri Bağlantıları
45
43
  [ ] İletişim Kanalları
44
+ [ ] OpenClaw Gateway Yapılandırması
46
45
 
47
46
  -----------------------------------------------------------------
48
47
  `;
@@ -51,8 +50,7 @@ class OnboardingWizard {
51
50
  constructor() {
52
51
  this.envVars = {};
53
52
  this.step = 0;
54
- this.totalSteps = 4;
55
- this.licenseManager = new LicenseManager();
53
+ this.totalSteps = 5;
56
54
  }
57
55
 
58
56
  clear() { console.clear(); }
@@ -67,10 +65,11 @@ class OnboardingWizard {
67
65
  try {
68
66
  await this.showLogo();
69
67
  await this.showWelcome();
70
- await this.step1_License();
71
- await this.step2_AIProvider();
72
- await this.step3_Platforms();
73
- await this.step4_Channels();
68
+ console.log(c('green', '⚡ Geliştirici Modu: Lisans kontrolü atlandı.\n'));
69
+ await this.step1_AIProvider();
70
+ await this.step2_Platforms();
71
+ await this.step3_Channels();
72
+ await this.step4_Gateway();
74
73
  await this.step5_Save();
75
74
  await this.showSuccess();
76
75
  } catch (error) {
@@ -91,41 +90,9 @@ class OnboardingWizard {
91
90
  await this.prompt(c('dim', 'Devam etmek için Enter\'a basın...'));
92
91
  }
93
92
 
94
- // ADIM 1: LİSANS (ZORUNLU - DEMO YOK)
95
- async step1_License() {
93
+ // ADIM 1: AI PROVIDER
94
+ async step1_AIProvider() {
96
95
  this.step = 1;
97
- this.printHeader('LİSANS AKTİVASYONU');
98
-
99
- console.log('Vantuz AI kullanımı için geçerli bir lisans anahtarı gereklidir.');
100
- console.log(c('dim', 'Format: VNTUZ-Payload.Signature (RSA İmzalı)\n'));
101
-
102
- while (true) {
103
- const key = await this.prompt('Lisans Anahtarı: '); // Changed from promptSecret to avoid issues
104
-
105
- if (!key) {
106
- console.log(c('red', '\n[HATA] Lisans anahtarı boş olamaz.'));
107
- continue;
108
- }
109
-
110
- console.log(c('dim', '\nKontrol ediliyor...'));
111
- const formatCheck = this.licenseManager.validateFormat(key);
112
-
113
- if (!formatCheck.valid) {
114
- console.log(c('red', `\n[HATA] Geçersiz format: ${formatCheck.error}`));
115
- continue;
116
- }
117
-
118
- // Valid
119
- this.envVars.VANTUZ_LICENSE_KEY = key;
120
- console.log(c('green', '\n[OK] Lisans formatı geçerli.\n'));
121
- await sleep(800);
122
- break;
123
- }
124
- }
125
-
126
- // ADIM 2: AI PROVIDER
127
- async step2_AIProvider() {
128
- this.step = 2;
129
96
  this.printHeader('YAPAY ZEKA SERVİSİ');
130
97
 
131
98
  console.log('Kullanılacak AI modelini seçin:\n');
@@ -155,8 +122,7 @@ class OnboardingWizard {
155
122
  const selected = providers[choice] || providers['1'];
156
123
  console.log(c('green', `\n[SEÇİLDİ] ${selected.label}\n`));
157
124
 
158
- // Use standard prompt to prevent crashes, relying on user environment security
159
- const key = await this.prompt(`${selected.label} API Key (görünür giriş): `);
125
+ const key = await this.prompt(`${selected.label} API Key: `);
160
126
 
161
127
  if (key && key.trim()) {
162
128
  this.envVars[selected.env] = key.trim();
@@ -167,9 +133,9 @@ class OnboardingWizard {
167
133
  await sleep(1000);
168
134
  }
169
135
 
170
- // ADIM 3: PAZARYERLERİ
171
- async step3_Platforms() {
172
- this.step = 3;
136
+ // ADIM 2: PAZARYERLERİ
137
+ async step2_Platforms() {
138
+ this.step = 2;
173
139
  this.printHeader('PAZARYERİ ENTEGRASYONLARI');
174
140
 
175
141
  console.log('Hangi pazaryerini yapılandırmak istersiniz?\n');
@@ -181,13 +147,10 @@ class OnboardingWizard {
181
147
 
182
148
  const choice = await this.prompt('Seçiminiz (1-4 veya S) [1]: ') || '1';
183
149
 
184
- if (choice.toLowerCase() === 's') {
185
- return;
186
- }
150
+ if (choice.toLowerCase() === 's') return;
187
151
 
188
- if (choice === '1') { // Trendyol
152
+ if (choice === '1') {
189
153
  console.log(c('cyan', '\nTrendyol Yapılandırması\n'));
190
- console.log('Lütfen Trendyol Partner panelinden aldığınız bilgileri girin.');
191
154
  console.log(c('dim', '(Boş bırakıp Enter\'a basarak geçebilirsiniz)\n'));
192
155
 
193
156
  const supplierId = await this.prompt('Supplier ID: ');
@@ -208,9 +171,9 @@ class OnboardingWizard {
208
171
  }
209
172
  }
210
173
 
211
- // ADIM 4: KANALLAR
212
- async step4_Channels() {
213
- this.step = 4;
174
+ // ADIM 3: KANALLAR
175
+ async step3_Channels() {
176
+ this.step = 3;
214
177
  this.printHeader('İLETİŞİM KANALLARI');
215
178
 
216
179
  console.log('WhatsApp ve Telegram entegrasyonu.\n');
@@ -225,12 +188,45 @@ class OnboardingWizard {
225
188
  }
226
189
  }
227
190
 
228
- console.log(c('dim', '\nNot: WhatsApp bağlantısı kurulum sonrasında "vantuz gateway" komutu ile yapılabilir.\n'));
191
+ console.log(c('dim', '\nNot: WhatsApp bağlantısı "openclaw channels login" ile yapılır.\n'));
229
192
  await sleep(1500);
230
193
  }
231
194
 
195
+ // ADIM 4: VANTUZ GATEWAY
196
+ async step4_Gateway() {
197
+ this.step = 4;
198
+ this.printHeader('VANTUZ GATEWAY');
199
+
200
+ console.log('Vantuz Gateway, AI ve kanal yönetimini güçlendirir.\n');
201
+
202
+ // .openclaw/ klasörü kontrolü
203
+ const openclawDir = path.join(process.cwd(), '.openclaw');
204
+ const openclawConfig = path.join(openclawDir, 'openclaw.json');
205
+
206
+ if (fs.existsSync(openclawConfig)) {
207
+ console.log(c('green', '✔ Gateway yapılandırması bulundu.'));
208
+ try {
209
+ const config = JSON.parse(fs.readFileSync(openclawConfig, 'utf-8'));
210
+ if (config.gateway?.auth?.token) {
211
+ console.log(c('green', '✔ Token ve güvenlik anahtarları hazır.'));
212
+ }
213
+ } catch (e) {
214
+ console.log(c('yellow', '⚠ Config okunamadı.'));
215
+ }
216
+ } else {
217
+ console.log(c('yellow', '⚠ Gateway yapılandırması eksik.'));
218
+ console.log(c('dim', '\nOtomatik olarak oluşturulacak...\n'));
219
+ }
220
+
221
+ console.log(c('dim', '\nBaşlatmak için sadece: start.bat'));
222
+ console.log(c('dim', 'Durum kontrolü: vantuz gateway status\n'));
223
+
224
+ await this.prompt(c('dim', 'Devam etmek için Enter\'a basın...'));
225
+ }
226
+
232
227
  // KAYDET
233
228
  async step5_Save() {
229
+ this.step = 5;
234
230
  this.printHeader('AYARLAR KAYDEDİLİYOR');
235
231
 
236
232
  console.log('Yapılandırma dosyası oluşturuluyor...');
@@ -270,15 +266,16 @@ class OnboardingWizard {
270
266
  console.log('\n');
271
267
  console.log('Vantuz AI kullanıma hazırdır.\n');
272
268
  console.log('Başlamak için şu komutları kullanabilirsiniz:');
273
- console.log(c('cyan', ' vantuz tui') + ' - Sohbet arayüzünü başlatır');
274
- console.log(c('cyan', ' vantuz status') + ' - Sistem durumunu gösterir');
269
+ console.log(c('cyan', ' vantuz tui') + ' - Sohbet arayüzünü başlatır');
270
+ console.log(c('cyan', ' vantuz status') + ' - Sistem durumunu gösterir');
271
+ console.log(c('cyan', ' vantuz gateway') + ' - Gateway durumunu gösterir');
272
+ console.log(c('cyan', ' vantuz doctor') + ' - Sistem sağlık kontrolü');
275
273
  console.log('\n');
276
274
 
277
- // Final prompt to prevent immediate exit
278
275
  await this.prompt(c('dim', 'Çıkmak için Enter\'a basın...'));
279
276
  }
280
277
 
281
- // ARAÇLAR - Stable Implementation
278
+ // ARAÇLAR
282
279
  prompt(question) {
283
280
  return new Promise((resolve) => {
284
281
  const rl = readline.createInterface({
@@ -292,11 +289,6 @@ class OnboardingWizard {
292
289
  });
293
290
  });
294
291
  }
295
-
296
- // Deprecated insecure secret prompt - using standard prompt for stability
297
- promptSecret(question) {
298
- return this.prompt(question);
299
- }
300
292
  }
301
293
 
302
294
  // BAŞLAT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vantuz",
3
- "version": "3.2.4",
3
+ "version": "3.2.6",
4
4
  "description": "Yapay Zeka Destekli E-Ticaret Yönetim Platformu - 7 Pazaryeri + WhatsApp/Telegram",
5
5
  "type": "module",
6
6
  "main": "cli.js",
@@ -53,8 +53,11 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "axios": "^1.6.0",
56
- "xml2js": "^0.6.2",
57
- "dotenv": "^16.0.0"
56
+ "body-parser": "^2.2.2",
57
+ "cors": "^2.8.6",
58
+ "dotenv": "^16.0.0",
59
+ "express": "^5.2.1",
60
+ "xml2js": "^0.6.2"
58
61
  },
59
62
  "devDependencies": {
60
63
  "eslint": "^8.0.0"
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 🐙 VANTUZ AI v3.0 - OpenClaw Plugin
2
+ * 🐙 VANTUZ AI v3.1
3
3
  * E-Ticaretin Yapay Zeka Beyni
4
4
  *
5
5
  * Bu plugin şunları sağlar: