vantuz 3.0.0
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/LICENSE +45 -0
- package/README.md +44 -0
- package/cli.js +420 -0
- package/core/ai-analyst.js +46 -0
- package/core/database.js +74 -0
- package/core/license-manager.js +50 -0
- package/core/product-manager.js +134 -0
- package/package.json +72 -0
- package/plugins/vantuz/index.js +480 -0
- package/plugins/vantuz/memory/hippocampus.js +464 -0
- package/plugins/vantuz/package.json +21 -0
- package/plugins/vantuz/platforms/amazon.js +239 -0
- package/plugins/vantuz/platforms/ciceksepeti.js +175 -0
- package/plugins/vantuz/platforms/hepsiburada.js +189 -0
- package/plugins/vantuz/platforms/index.js +215 -0
- package/plugins/vantuz/platforms/n11.js +263 -0
- package/plugins/vantuz/platforms/pazarama.js +171 -0
- package/plugins/vantuz/platforms/pttavm.js +136 -0
- package/plugins/vantuz/platforms/trendyol.js +307 -0
- package/plugins/vantuz/services/alerts.js +253 -0
- package/plugins/vantuz/services/license.js +237 -0
- package/plugins/vantuz/services/scheduler.js +232 -0
- package/plugins/vantuz/tools/analytics.js +152 -0
- package/plugins/vantuz/tools/crossborder.js +187 -0
- package/plugins/vantuz/tools/nl-parser.js +211 -0
- package/plugins/vantuz/tools/product.js +110 -0
- package/plugins/vantuz/tools/quick-report.js +175 -0
- package/plugins/vantuz/tools/repricer.js +314 -0
- package/plugins/vantuz/tools/sentiment.js +115 -0
- package/plugins/vantuz/tools/vision.js +257 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const inquirer = require('inquirer');
|
|
3
|
+
const ora = require('ora');
|
|
4
|
+
const { table } = require('table');
|
|
5
|
+
const { Product, Store } = require('./database');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const axios = require('axios');
|
|
8
|
+
const FormData = require('form-data');
|
|
9
|
+
|
|
10
|
+
// AI Konfigürasyonunu yükle
|
|
11
|
+
const Config = require('conf');
|
|
12
|
+
const conf = new Config({ projectName: 'vantuz' });
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
async manageProducts() {
|
|
16
|
+
console.log(chalk.bold('\n🛍️ VANTUZ Ürün Merkezi\n'));
|
|
17
|
+
|
|
18
|
+
const { action } = await inquirer.prompt([
|
|
19
|
+
{
|
|
20
|
+
type: 'list',
|
|
21
|
+
name: 'action',
|
|
22
|
+
message: 'İşlem Seçiniz:',
|
|
23
|
+
choices: [
|
|
24
|
+
{ name: '👁️ AI Vision: Fotoğraftan Ürün Ekle', value: 'vision_add' },
|
|
25
|
+
{ name: '📋 Ürün Listesi', value: 'list' },
|
|
26
|
+
{ name: '🔙 Geri Dön', value: 'back' }
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
if (action === 'vision_add') await this.visionAdd();
|
|
32
|
+
else if (action === 'list') await this.listProducts();
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
async visionAdd() {
|
|
36
|
+
// AI Config Kontrolü
|
|
37
|
+
const aiConfig = conf.get('ai');
|
|
38
|
+
if (!aiConfig || !aiConfig.apiKey) {
|
|
39
|
+
console.log(chalk.red('\n❌ AI Vision özelliği için API Anahtarı gerekli.'));
|
|
40
|
+
console.log(chalk.yellow('Lütfen ana menüden "Ayarlar > AI Konfigürasyon" kısmından OpenAI API Key giriniz.\n'));
|
|
41
|
+
await inquirer.prompt([{type: 'input', name: 'c', message: 'Devam...' }]);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log(chalk.magenta('\n👁️ AI Vision Modu Aktif'));
|
|
46
|
+
|
|
47
|
+
const { imagePath } = await inquirer.prompt([
|
|
48
|
+
{ type: 'input', name: 'imagePath', message: 'Fotoğraf Dosya Yolu (Örn: /home/user/gomlek.jpg):' }
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
if (!fs.existsSync(imagePath)) {
|
|
52
|
+
console.log(chalk.red('❌ Dosya bulunamadı!'));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const spinner = ora('Görsel taranıyor ve analiz ediliyor...').start();
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
// OpenAI Vision API İsteği
|
|
60
|
+
const base64Image = fs.readFileSync(imagePath, { encoding: 'base64' });
|
|
61
|
+
const dataUrl = `data:image/jpeg;base64,${base64Image}`;
|
|
62
|
+
|
|
63
|
+
const response = await axios.post('https://api.openai.com/v1/chat/completions', {
|
|
64
|
+
model: "gpt-4o", // Vision destekli model
|
|
65
|
+
messages: [
|
|
66
|
+
{
|
|
67
|
+
role: "user",
|
|
68
|
+
content: [
|
|
69
|
+
{ type: "text", text: "Bu ürünün bir e-ticaret sitesi için satış başlığını, SEO uyumlu açıklamasını, kategorisini (Trendyol ağacı) ve tahmini piyasa fiyatını (TRY) JSON formatında ver. Örnek: {title, description, category, price}" },
|
|
70
|
+
{ type: "image_url", image_url: { url: dataUrl } }
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
max_tokens: 500
|
|
75
|
+
}, {
|
|
76
|
+
headers: {
|
|
77
|
+
'Authorization': `Bearer ${aiConfig.apiKey}`,
|
|
78
|
+
'Content-Type': 'application/json'
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
spinner.succeed('Analiz Tamamlandı!');
|
|
83
|
+
|
|
84
|
+
// Yanıtı temizle ve parse et (JSON bloğunu ayıkla)
|
|
85
|
+
let content = response.data.choices[0].message.content;
|
|
86
|
+
content = content.replace(/```json/g, '').replace(/```/g, ''); // Markdown temizliği
|
|
87
|
+
const analysis = JSON.parse(content);
|
|
88
|
+
|
|
89
|
+
console.log(chalk.cyan('\n🔍 AI Tespiti:'));
|
|
90
|
+
console.log(`📌 Başlık: ${analysis.title}`);
|
|
91
|
+
console.log(`📄 Açıklama: ${analysis.description.substring(0, 100)}...`);
|
|
92
|
+
console.log(`📂 Kategori: ${analysis.category}`);
|
|
93
|
+
console.log(`💰 Tahmini Fiyat: ${analysis.price} TL\n`);
|
|
94
|
+
|
|
95
|
+
const { confirm } = await inquirer.prompt([
|
|
96
|
+
{ type: 'confirm', name: 'confirm', message: 'Bu bilgilerle ürün oluşturulsun mu?' }
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
if (confirm) {
|
|
100
|
+
await Product.create({
|
|
101
|
+
name: analysis.title,
|
|
102
|
+
description: analysis.description,
|
|
103
|
+
images: [imagePath], // Gerçekte S3/Cloud upload gerekir
|
|
104
|
+
marketData: { trendyol: { price: analysis.price, stock: 0 } }
|
|
105
|
+
});
|
|
106
|
+
console.log(chalk.green('✅ Ürün veritabanına eklendi!'));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
} catch (error) {
|
|
110
|
+
spinner.fail('Analiz Hatası');
|
|
111
|
+
console.error(chalk.red(error.message));
|
|
112
|
+
if (error.response) console.error(chalk.red(JSON.stringify(error.response.data)));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
await inquirer.prompt([{type: 'input', name: 'c', message: 'Devam...' }]);
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
async listProducts() {
|
|
119
|
+
const products = await Product.findAll();
|
|
120
|
+
if (products.length === 0) {
|
|
121
|
+
console.log(chalk.yellow('Kayıtlı ürün yok.'));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const data = [['ID', 'Ürün Adı', 'Fiyat']];
|
|
126
|
+
products.forEach(p => {
|
|
127
|
+
const price = p.marketData?.trendyol?.price || 0;
|
|
128
|
+
data.push([p.id, p.name, price + ' TL']);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
console.log(table(data));
|
|
132
|
+
await inquirer.prompt([{type: 'input', name: 'c', message: 'Devam...' }]);
|
|
133
|
+
}
|
|
134
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vantuz",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Yapay Zeka Destekli E-Ticaret Yönetim Platformu - 7 Pazaryeri Entegrasyonu",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "cli.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"vantuz": "cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node cli.js tui",
|
|
12
|
+
"tui": "node cli.js tui",
|
|
13
|
+
"config": "node cli.js config",
|
|
14
|
+
"status": "node cli.js status",
|
|
15
|
+
"postinstall": "echo '🐙 Vantuz kuruldu! Başlatmak için: npx vantuz config'",
|
|
16
|
+
"test": "node --test",
|
|
17
|
+
"lint": "eslint plugins/"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"ecommerce",
|
|
21
|
+
"e-ticaret",
|
|
22
|
+
"trendyol",
|
|
23
|
+
"hepsiburada",
|
|
24
|
+
"amazon",
|
|
25
|
+
"n11",
|
|
26
|
+
"ciceksepeti",
|
|
27
|
+
"pttavm",
|
|
28
|
+
"pazarama",
|
|
29
|
+
"marketplace",
|
|
30
|
+
"pazaryeri",
|
|
31
|
+
"ai",
|
|
32
|
+
"yapay-zeka",
|
|
33
|
+
"repricer",
|
|
34
|
+
"fiyatlama"
|
|
35
|
+
],
|
|
36
|
+
"author": {
|
|
37
|
+
"name": "Nuri Can Avşar",
|
|
38
|
+
"email": "nuricanavsar2000@gmail.com"
|
|
39
|
+
},
|
|
40
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/nuricanavsar/vantuz.git"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://vantuz.ai",
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/nuricanavsar/vantuz/issues"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"axios": "^1.6.0",
|
|
51
|
+
"xml2js": "^0.6.2",
|
|
52
|
+
"dotenv": "^16.0.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"eslint": "^8.0.0"
|
|
56
|
+
},
|
|
57
|
+
"os": [
|
|
58
|
+
"darwin",
|
|
59
|
+
"linux",
|
|
60
|
+
"win32"
|
|
61
|
+
],
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=18.0.0"
|
|
64
|
+
},
|
|
65
|
+
"files": [
|
|
66
|
+
"cli.js",
|
|
67
|
+
"plugins/",
|
|
68
|
+
"core/",
|
|
69
|
+
"README.md",
|
|
70
|
+
"LICENSE"
|
|
71
|
+
]
|
|
72
|
+
}
|
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🐙 VANTUZ AI v3.0 - OpenClaw Plugin
|
|
3
|
+
* E-Ticaretin Yapay Zeka Beyni
|
|
4
|
+
*
|
|
5
|
+
* Bu plugin şunları sağlar:
|
|
6
|
+
* - 7 Pazaryeri API Entegrasyonu (Trendyol, HB, N11, Amazon, CS, PTT, Pazarama)
|
|
7
|
+
* - E-ticaret araçları (repricer, vision, sentiment, crossborder)
|
|
8
|
+
* - Özel komutlar (/stok, /fiyat, /rapor, /uyari)
|
|
9
|
+
* - Cron zamanlama ve otomasyon
|
|
10
|
+
* - Hippocampus hafıza sistemi
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { Hippocampus } from './memory/hippocampus.js';
|
|
14
|
+
import { LicenseManager } from './services/license.js';
|
|
15
|
+
import SchedulerService from './services/scheduler.js';
|
|
16
|
+
import AlertService from './services/alerts.js';
|
|
17
|
+
|
|
18
|
+
// Tools
|
|
19
|
+
import { repricerTool } from './tools/repricer.js';
|
|
20
|
+
import { visionTool } from './tools/vision.js';
|
|
21
|
+
import { sentimentTool } from './tools/sentiment.js';
|
|
22
|
+
import { crossborderTool } from './tools/crossborder.js';
|
|
23
|
+
import { productTool } from './tools/product.js';
|
|
24
|
+
import { analyticsTool } from './tools/analytics.js';
|
|
25
|
+
import { quickReportTool } from './tools/quick-report.js';
|
|
26
|
+
import NLParser from './tools/nl-parser.js';
|
|
27
|
+
|
|
28
|
+
// Platform APIs
|
|
29
|
+
import platformHub, {
|
|
30
|
+
trendyolApi,
|
|
31
|
+
hepsiburadaApi,
|
|
32
|
+
n11Api,
|
|
33
|
+
amazonApi,
|
|
34
|
+
ciceksepetiApi,
|
|
35
|
+
pttavmApi,
|
|
36
|
+
pazaramaApi
|
|
37
|
+
} from './platforms/index.js';
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const PLUGIN_ID = 'vantuz';
|
|
41
|
+
const PLUGIN_VERSION = '3.0.0';
|
|
42
|
+
|
|
43
|
+
export default function (api) {
|
|
44
|
+
const logger = api.logger;
|
|
45
|
+
const config = api.config;
|
|
46
|
+
|
|
47
|
+
// Hippocampus hafıza sistemi
|
|
48
|
+
const memory = new Hippocampus(api);
|
|
49
|
+
|
|
50
|
+
// Lisans yöneticisi
|
|
51
|
+
const license = new LicenseManager(api);
|
|
52
|
+
|
|
53
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
54
|
+
// 🔧 TOOLS - AI tarafından çağrılabilir araçlar
|
|
55
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
56
|
+
|
|
57
|
+
// 🩸 Kan Emici Repricer
|
|
58
|
+
api.registerTool({
|
|
59
|
+
name: 'vantuz.repricer',
|
|
60
|
+
description: `Rakip fiyatlarını analiz et ve optimal fiyat öner.
|
|
61
|
+
Akıllı kararlar verir:
|
|
62
|
+
- Rakip stoku azsa → Fiyatı yükselt
|
|
63
|
+
- Rakip fiyat düşürdüyse → Kar marjına göre takip et
|
|
64
|
+
- Satış hızı yüksekse → Fiyatı optimize et`,
|
|
65
|
+
parameters: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
properties: {
|
|
68
|
+
barcode: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
description: 'Ürün barkodu veya SKU'
|
|
71
|
+
},
|
|
72
|
+
platform: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
enum: ['trendyol', 'hepsiburada', 'amazon', 'n11', 'all'],
|
|
75
|
+
description: 'Hedef pazaryeri'
|
|
76
|
+
},
|
|
77
|
+
targetMargin: {
|
|
78
|
+
type: 'number',
|
|
79
|
+
description: 'Hedef kar marjı yüzdesi (örn: 20)'
|
|
80
|
+
},
|
|
81
|
+
action: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
enum: ['analyze', 'apply', 'schedule'],
|
|
84
|
+
description: 'Sadece analiz, uygula veya zamanla'
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
required: ['barcode']
|
|
88
|
+
},
|
|
89
|
+
handler: async (params) => repricerTool.execute(params, { api, memory, license })
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// 👁️ Vision AI
|
|
93
|
+
api.registerTool({
|
|
94
|
+
name: 'vantuz.vision',
|
|
95
|
+
description: `Fotoğraftan ürün bilgisi çıkar ve pazaryerlerine ekle.
|
|
96
|
+
- SEO uyumlu başlık oluşturur
|
|
97
|
+
- Detaylı açıklama yazar
|
|
98
|
+
- Kategori eşleştirir (5 pazaryeri için)
|
|
99
|
+
- Tahmini fiyat önerir`,
|
|
100
|
+
parameters: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
imageUrl: {
|
|
104
|
+
type: 'string',
|
|
105
|
+
description: 'Ürün fotoğrafı URL veya base64'
|
|
106
|
+
},
|
|
107
|
+
targetPlatforms: {
|
|
108
|
+
type: 'array',
|
|
109
|
+
items: { type: 'string' },
|
|
110
|
+
description: 'Hedef pazaryerleri: trendyol, hepsiburada, amazon_de, amazon_us, n11'
|
|
111
|
+
},
|
|
112
|
+
autoPublish: {
|
|
113
|
+
type: 'boolean',
|
|
114
|
+
description: 'Otomatik yayınla (true) veya önizleme (false)'
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
required: ['imageUrl']
|
|
118
|
+
},
|
|
119
|
+
handler: async (params) => visionTool.execute(params, { api, memory, license })
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// 🧠 Sentiment AI
|
|
123
|
+
api.registerTool({
|
|
124
|
+
name: 'vantuz.sentiment',
|
|
125
|
+
description: `Müşteri yorumlarını analiz et ve aksiyon öner.
|
|
126
|
+
- Pozitif/negatif oranları
|
|
127
|
+
- Ana şikayet konuları tespit
|
|
128
|
+
- Tedarikçi kalite sorunları
|
|
129
|
+
- Otomatik yanıt önerileri`,
|
|
130
|
+
parameters: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
properties: {
|
|
133
|
+
productId: {
|
|
134
|
+
type: 'string',
|
|
135
|
+
description: 'Ürün ID veya barkod'
|
|
136
|
+
},
|
|
137
|
+
platform: {
|
|
138
|
+
type: 'string',
|
|
139
|
+
enum: ['trendyol', 'hepsiburada', 'amazon', 'n11', 'all'],
|
|
140
|
+
description: 'Pazaryeri'
|
|
141
|
+
},
|
|
142
|
+
period: {
|
|
143
|
+
type: 'string',
|
|
144
|
+
enum: ['7d', '30d', '90d', 'all'],
|
|
145
|
+
description: 'Analiz dönemi'
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
required: ['productId']
|
|
149
|
+
},
|
|
150
|
+
handler: async (params) => sentimentTool.execute(params, { api, memory, license })
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// 🌍 Cross-Border
|
|
154
|
+
api.registerTool({
|
|
155
|
+
name: 'vantuz.crossborder',
|
|
156
|
+
description: `Ürünü yurt dışı pazarına uyarla ve sat.
|
|
157
|
+
- Dil çevirisi (Almanca, İngilizce)
|
|
158
|
+
- Döviz hesaplama
|
|
159
|
+
- Kargo + FBA komisyon hesabı
|
|
160
|
+
- Optimal satış fiyatı`,
|
|
161
|
+
parameters: {
|
|
162
|
+
type: 'object',
|
|
163
|
+
properties: {
|
|
164
|
+
productId: {
|
|
165
|
+
type: 'string',
|
|
166
|
+
description: 'Kaynak ürün ID veya barkod'
|
|
167
|
+
},
|
|
168
|
+
sourcePlatform: {
|
|
169
|
+
type: 'string',
|
|
170
|
+
enum: ['trendyol', 'hepsiburada', 'n11'],
|
|
171
|
+
description: 'Kaynak pazaryeri'
|
|
172
|
+
},
|
|
173
|
+
targetMarket: {
|
|
174
|
+
type: 'string',
|
|
175
|
+
enum: ['de', 'us', 'uk', 'fr'],
|
|
176
|
+
description: 'Hedef pazar'
|
|
177
|
+
},
|
|
178
|
+
fulfillment: {
|
|
179
|
+
type: 'string',
|
|
180
|
+
enum: ['fba', 'fbm', 'self'],
|
|
181
|
+
description: 'Fulfillment yöntemi'
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
required: ['productId', 'targetMarket']
|
|
185
|
+
},
|
|
186
|
+
handler: async (params) => crossborderTool.execute(params, { api, memory, license })
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// 📦 Ürün Yönetimi
|
|
190
|
+
api.registerTool({
|
|
191
|
+
name: 'vantuz.product',
|
|
192
|
+
description: `Ürün işlemleri: liste, güncelle, stok, fiyat.`,
|
|
193
|
+
parameters: {
|
|
194
|
+
type: 'object',
|
|
195
|
+
properties: {
|
|
196
|
+
action: {
|
|
197
|
+
type: 'string',
|
|
198
|
+
enum: ['list', 'get', 'update', 'updatePrice', 'updateStock', 'publish', 'unpublish'],
|
|
199
|
+
description: 'Yapılacak işlem'
|
|
200
|
+
},
|
|
201
|
+
productId: { type: 'string' },
|
|
202
|
+
platform: { type: 'string' },
|
|
203
|
+
data: { type: 'object', description: 'Güncelleme verisi' }
|
|
204
|
+
},
|
|
205
|
+
required: ['action']
|
|
206
|
+
},
|
|
207
|
+
handler: async (params) => productTool.execute(params, { api, memory, license })
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// 📊 Analitik
|
|
211
|
+
api.registerTool({
|
|
212
|
+
name: 'vantuz.analytics',
|
|
213
|
+
description: `Satış, stok ve performans raporları.`,
|
|
214
|
+
parameters: {
|
|
215
|
+
type: 'object',
|
|
216
|
+
properties: {
|
|
217
|
+
reportType: {
|
|
218
|
+
type: 'string',
|
|
219
|
+
enum: ['sales', 'stock', 'profit', 'competitors', 'trends'],
|
|
220
|
+
description: 'Rapor türü'
|
|
221
|
+
},
|
|
222
|
+
platform: { type: 'string' },
|
|
223
|
+
period: {
|
|
224
|
+
type: 'string',
|
|
225
|
+
enum: ['today', '7d', '30d', '90d'],
|
|
226
|
+
description: 'Dönem'
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
required: ['reportType']
|
|
230
|
+
},
|
|
231
|
+
handler: async (params) => analyticsTool.execute(params, { api, memory, license })
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// 🧠 Hafıza Arama
|
|
235
|
+
api.registerTool({
|
|
236
|
+
name: 'vantuz.memory_search',
|
|
237
|
+
description: `Hippocampus hafıza sisteminde arama yap.
|
|
238
|
+
Geçmiş kararları, fiyat değişikliklerini, ürün geçmişini sorgula.`,
|
|
239
|
+
parameters: {
|
|
240
|
+
type: 'object',
|
|
241
|
+
properties: {
|
|
242
|
+
query: { type: 'string', description: 'Arama sorgusu' },
|
|
243
|
+
type: {
|
|
244
|
+
type: 'string',
|
|
245
|
+
enum: ['decision', 'price_change', 'product', 'conversation', 'all'],
|
|
246
|
+
description: 'Hafıza türü'
|
|
247
|
+
},
|
|
248
|
+
limit: { type: 'number', description: 'Maksimum sonuç' }
|
|
249
|
+
},
|
|
250
|
+
required: ['query']
|
|
251
|
+
},
|
|
252
|
+
handler: async (params) => memory.search(params)
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
256
|
+
// 📝 COMMANDS - Kullanıcı tarafından doğrudan çağrılan komutlar
|
|
257
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
258
|
+
|
|
259
|
+
api.registerCommand({
|
|
260
|
+
name: 'stok',
|
|
261
|
+
description: 'Stok durumunu göster',
|
|
262
|
+
acceptsArgs: true,
|
|
263
|
+
handler: async (ctx) => {
|
|
264
|
+
const platform = ctx.args?.trim() || 'all';
|
|
265
|
+
const stocks = await productTool.getStockSummary(platform, { api, memory });
|
|
266
|
+
return { text: formatStockReport(stocks) };
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
api.registerCommand({
|
|
271
|
+
name: 'fiyat',
|
|
272
|
+
description: 'Ürün fiyatını güncelle',
|
|
273
|
+
acceptsArgs: true,
|
|
274
|
+
handler: async (ctx) => {
|
|
275
|
+
// Parse: "iPhone kılıf 199 TL" veya "SKU-123 %10 indirim"
|
|
276
|
+
const result = await productTool.parseAndUpdatePrice(ctx.args, { api, memory });
|
|
277
|
+
return { text: result.message };
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
api.registerCommand({
|
|
282
|
+
name: 'rapor',
|
|
283
|
+
description: 'Satış raporu göster',
|
|
284
|
+
acceptsArgs: true,
|
|
285
|
+
handler: async (ctx) => {
|
|
286
|
+
const period = ctx.args?.trim() || '7d';
|
|
287
|
+
const report = await analyticsTool.getSalesReport(period, { api, memory });
|
|
288
|
+
return { text: formatSalesReport(report) };
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
api.registerCommand({
|
|
293
|
+
name: 'rakip',
|
|
294
|
+
description: 'Rakip fiyatlarını kontrol et',
|
|
295
|
+
acceptsArgs: true,
|
|
296
|
+
handler: async (ctx) => {
|
|
297
|
+
const barcode = ctx.args?.trim();
|
|
298
|
+
if (!barcode) return { text: '❌ Barkod veya ürün adı belirtin.' };
|
|
299
|
+
const result = await repricerTool.analyzeCompetitors(barcode, { api, memory });
|
|
300
|
+
return { text: formatCompetitorReport(result) };
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
api.registerCommand({
|
|
305
|
+
name: 'lisans',
|
|
306
|
+
description: 'Lisans durumunu göster',
|
|
307
|
+
handler: async () => {
|
|
308
|
+
const status = await license.getStatus();
|
|
309
|
+
return { text: formatLicenseStatus(status) };
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
api.registerCommand({
|
|
314
|
+
name: 'uyari',
|
|
315
|
+
description: 'Uyarıları göster',
|
|
316
|
+
handler: async () => {
|
|
317
|
+
const alerts = alertService.alerts.filter(a => !a.read);
|
|
318
|
+
return { text: alertService.formatAlerts(alerts) };
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
api.registerCommand({
|
|
323
|
+
name: 'zamanlama',
|
|
324
|
+
description: 'Zamanlanmış görevleri göster',
|
|
325
|
+
acceptsArgs: true,
|
|
326
|
+
handler: async (ctx) => {
|
|
327
|
+
if (ctx.args?.includes('ekle')) {
|
|
328
|
+
const templates = scheduler.getTemplates();
|
|
329
|
+
let msg = '📅 **Hazır Şablonlar**\n\n';
|
|
330
|
+
templates.forEach(t => {
|
|
331
|
+
msg += `• \`${t.name}\`: ${t.scheduleHuman}\n`;
|
|
332
|
+
});
|
|
333
|
+
msg += '\n*Eklemek için: /zamanlama ekle [şablon]*';
|
|
334
|
+
return { text: msg };
|
|
335
|
+
}
|
|
336
|
+
const jobs = await scheduler.listJobs();
|
|
337
|
+
return { text: formatScheduleList(jobs) };
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
api.registerCommand({
|
|
342
|
+
name: 'platformlar',
|
|
343
|
+
description: 'Bağlı platformları göster',
|
|
344
|
+
handler: async () => {
|
|
345
|
+
const result = quickReportTool.generatePlatformStatus();
|
|
346
|
+
return { text: result.report };
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
351
|
+
// ⚙️ SERVICES - Arka plan servisleri
|
|
352
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
353
|
+
|
|
354
|
+
// Lisans Doğrulama Servisi
|
|
355
|
+
api.registerService({
|
|
356
|
+
id: 'vantuz-license',
|
|
357
|
+
start: async () => {
|
|
358
|
+
logger.info('🔐 Lisans servisi başlatılıyor...');
|
|
359
|
+
await license.initialize();
|
|
360
|
+
|
|
361
|
+
// Her 24 saatte bir lisans kontrolü
|
|
362
|
+
setInterval(() => license.verify(), 24 * 60 * 60 * 1000);
|
|
363
|
+
},
|
|
364
|
+
stop: () => {
|
|
365
|
+
logger.info('🔐 Lisans servisi durduruluyor...');
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// Hippocampus Hafıza Servisi
|
|
370
|
+
api.registerService({
|
|
371
|
+
id: 'vantuz-memory',
|
|
372
|
+
start: async () => {
|
|
373
|
+
logger.info('🧠 Hippocampus hafıza sistemi başlatılıyor...');
|
|
374
|
+
await memory.initialize();
|
|
375
|
+
},
|
|
376
|
+
stop: async () => {
|
|
377
|
+
logger.info('🧠 Hippocampus kapatılıyor...');
|
|
378
|
+
await memory.close();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// Repricer Daemon (Arka planda fiyat kontrolü)
|
|
383
|
+
api.registerService({
|
|
384
|
+
id: 'vantuz-repricer-daemon',
|
|
385
|
+
start: () => {
|
|
386
|
+
logger.info('🩸 Kan Emici Repricer daemon başlatılıyor...');
|
|
387
|
+
|
|
388
|
+
// Her 15 dakikada bir fiyat kontrolü
|
|
389
|
+
const interval = setInterval(async () => {
|
|
390
|
+
if (!license.isValid()) return;
|
|
391
|
+
|
|
392
|
+
try {
|
|
393
|
+
const decisions = await repricerTool.runAutoCycle({ api, memory, license });
|
|
394
|
+
if (decisions.length > 0) {
|
|
395
|
+
logger.info(`💰 ${decisions.length} fiyat kararı alındı.`);
|
|
396
|
+
}
|
|
397
|
+
} catch (err) {
|
|
398
|
+
logger.error('Repricer hatası:', err);
|
|
399
|
+
}
|
|
400
|
+
}, 15 * 60 * 1000);
|
|
401
|
+
|
|
402
|
+
// Store interval for cleanup
|
|
403
|
+
this._repricerInterval = interval;
|
|
404
|
+
},
|
|
405
|
+
stop: () => {
|
|
406
|
+
if (this._repricerInterval) {
|
|
407
|
+
clearInterval(this._repricerInterval);
|
|
408
|
+
}
|
|
409
|
+
logger.info('🩸 Repricer daemon durduruluyor...');
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
414
|
+
// 🚀 GATEWAY RPC - Harici API metodları
|
|
415
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
416
|
+
|
|
417
|
+
api.registerGatewayMethod('vantuz.status', ({ respond }) => {
|
|
418
|
+
respond(true, {
|
|
419
|
+
version: PLUGIN_VERSION,
|
|
420
|
+
license: license.getStatus(),
|
|
421
|
+
memory: memory.getStats(),
|
|
422
|
+
platforms: platformHub.getStatus()
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
api.registerGatewayMethod('vantuz.config', ({ respond, params }) => {
|
|
427
|
+
if (params.action === 'get') {
|
|
428
|
+
respond(true, config.get('vantuz') || {});
|
|
429
|
+
} else if (params.action === 'set') {
|
|
430
|
+
config.set('vantuz', params.data);
|
|
431
|
+
respond(true, { success: true });
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
436
|
+
// 📊 HELPER FUNCTIONS
|
|
437
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
438
|
+
|
|
439
|
+
function formatStockReport(stocks) {
|
|
440
|
+
let report = '📦 **Stok Durumu**\n\n';
|
|
441
|
+
for (const [platform, data] of Object.entries(stocks)) {
|
|
442
|
+
report += `**${platform}**\n`;
|
|
443
|
+
report += `• Toplam: ${data.total} ürün\n`;
|
|
444
|
+
report += `• Kritik (<5): ${data.critical} ürün\n`;
|
|
445
|
+
report += `• Sıfır stok: ${data.zero} ürün\n\n`;
|
|
446
|
+
}
|
|
447
|
+
return report;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function formatSalesReport(report) {
|
|
451
|
+
return `📊 **Satış Raporu (${report.period})**
|
|
452
|
+
|
|
453
|
+
💰 Toplam Ciro: ${report.revenue.toLocaleString('tr-TR')} ₺
|
|
454
|
+
📦 Toplam Sipariş: ${report.orders}
|
|
455
|
+
📈 Ortalama Sepet: ${report.avgBasket.toLocaleString('tr-TR')} ₺
|
|
456
|
+
🏆 En Çok Satan: ${report.topProduct}`;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function formatCompetitorReport(result) {
|
|
460
|
+
let report = `🔍 **Rakip Analizi: ${result.product}**\n\n`;
|
|
461
|
+
for (const comp of result.competitors) {
|
|
462
|
+
report += `• ${comp.name}: ${comp.price} ₺ (Stok: ${comp.stock})\n`;
|
|
463
|
+
}
|
|
464
|
+
report += `\n💡 **Öneri**: ${result.recommendation}`;
|
|
465
|
+
return report;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function formatLicenseStatus(status) {
|
|
469
|
+
if (!status.valid) {
|
|
470
|
+
return `❌ **Lisans Geçersiz**\nNeden: ${status.reason}`;
|
|
471
|
+
}
|
|
472
|
+
return `✅ **Lisans Aktif**
|
|
473
|
+
👤 Müşteri: ${status.customer}
|
|
474
|
+
📅 Bitiş: ${status.expiry}
|
|
475
|
+
⏰ Kalan: ${status.daysLeft} gün`;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// Plugin yüklendi
|
|
479
|
+
logger.info(`🐙 Vantuz AI v${PLUGIN_VERSION} yüklendi!`);
|
|
480
|
+
}
|