vantuz 3.2.6 β 3.3.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/.openclaw/completions/openclaw.bash +227 -0
- package/.openclaw/completions/openclaw.fish +1552 -0
- package/.openclaw/completions/openclaw.ps1 +1966 -0
- package/.openclaw/completions/openclaw.zsh +3571 -0
- package/.openclaw/gateway.cmd +10 -0
- package/.openclaw/identity/device.json +7 -0
- package/.openclaw/openclaw.json +32 -0
- package/DOCS_TR.md +298 -0
- package/core/ai-provider.js +95 -141
- package/core/database.js +70 -60
- package/core/eia-brain.js +102 -0
- package/core/eia-monitor.js +220 -0
- package/core/engine.js +99 -39
- package/core/gateway.js +5 -21
- package/core/migrations/001-initial-schema.js +28 -0
- package/core/scheduler.js +80 -0
- package/core/scrapers/Scraper.js +61 -0
- package/core/scrapers/TrendyolScraper.js +76 -0
- package/core/vector-db.js +97 -0
- package/onboard.js +29 -3
- package/package.json +20 -10
- package/platforms/amazon.js +11 -0
- package/platforms/ciceksepeti.js +10 -0
- package/platforms/hepsiburada.js +15 -0
- package/platforms/n11.js +11 -0
- package/platforms/pazarama.js +10 -0
- package/platforms/trendyol.js +61 -0
- package/plugins/vantuz/platforms/index.js +13 -9
- package/server/app.js +130 -0
- package/server/public/index.html +516 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
rem OpenClaw Gateway (v2026.2.9)
|
|
3
|
+
set PATH=C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python27\python.exe;C:\Python27\Scripts;C:\Program Files (x86)\Nmap\;c:\Users\OSMBILISIM\AppData\Local\Programs\cursor\resources\app\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\CMake\bin;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\PostgreSQL\15\bin;C:\Users\Osmbilisimsatis\AppData\Roaming\npm;C:\Users\OSMBILISIM\scoop\shims;C:\Users\OSMBILISIM\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\OSMBILISIM\AppData\Local\Programs\Python\Python310\;C:\Users\OSMBILISIM\AppData\Local\Microsoft\WindowsApps;C:\Users\OSMBILISIM\AppData\Local\Programs\Git\cmd;C:\Users\OSMBILISIM\AppData\Roaming\npm;C:\Users\OSMBILISIM\AppData\Local\Programs\Windsurf\bin;C:\Users\OSMBILISIM\AppData\Local\Programs\cursor\resources\app\bin;c:\Users\OSMBILISIM\AppData\Local\Programs\cursor\resources\app\bin;C:\Program Files\GitHub CLI\;C:\Program Files\Void\bin;C:\Users\OSMBILISIM\Downloads\flutter\bin;C:\Users\OSMBILISIM\Downloads\php-8.4.11-nts-Win32-vs17-x64;C:\Users\OSMBILISIM\Downloads\flutter\bin;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Ruby34-x64\msys64\ucrt64\bin;C:\Ruby34-x64\bin;C:\Users\OSMBILISIM\AppData\Local\Programs\Python\Python310\python.exe;C:\Users\OSMBILISIM\go\bin;C:\Program Files\Go\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program Files\nodejs\;C:\Program Files\dotnet\;C:\Program Files\cursor\resources\app\bin;C:\Program Files\Tailscale\;C:\Python27\python.exe;C:\Python27\Scripts;C:\Program Files (x86)\Nmap\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\CMake\bin;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\PostgreSQL\15\bin;C:\Users\Osmbilisimsatis\AppData\Roaming\npm;C:\Users\OSMBILISIM\scoop\shims;C:\Users\OSMBILISIM\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\OSMBILISIM\AppData\Local\Programs\Python\Python310\;C:\Users\OSMBILISIM\AppData\Local\Microsoft\WindowsApps;C:\Users\OSMBILISIM\AppData\Local\Programs\Git\cmd;C:\Users\OSMBILISIM\AppData\Local\Programs\Windsurf\bin;C:\Program Files\GitHub CLI\;C:\Program Files;C:\Users\OSMBILISIM\go\bin;C:\Users\OSMBILISIM\AppData\Local\Programs\Qoder\bin;C:\Users\OSMBILISIM\AppData\Roaming\npm;C:\Users\OSMBILISIM\AppData\Local\Programs\Antigravity\bin;C:\Users\OSMBILISIM\AppData\Local\Programs\Ollama
|
|
4
|
+
set OPENCLAW_GATEWAY_PORT=18789
|
|
5
|
+
set OPENCLAW_GATEWAY_TOKEN=e432e1210dcfb65a16122ce44ccaabeb6fefac299759b841
|
|
6
|
+
set OPENCLAW_SYSTEMD_UNIT=openclaw-gateway.service
|
|
7
|
+
set OPENCLAW_SERVICE_MARKER=openclaw
|
|
8
|
+
set OPENCLAW_SERVICE_KIND=gateway
|
|
9
|
+
set OPENCLAW_SERVICE_VERSION=2026.2.9
|
|
10
|
+
call npx openclaw gateway --port 18789 --allow-unconfigured
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"deviceId": "b37c08a4ffb5fb274c735d5c4a9dafa001447d8ac18b05102129e2cafed4307c",
|
|
4
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA/WoKlAj3d+1nj3EEJaiCy+N4drHLu3/+q00EJeNDXtk=\n-----END PUBLIC KEY-----\n",
|
|
5
|
+
"privateKeyPem": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIGk9gpUGGch4gQg/ozBZf0R63/MXlTqQju9U6IuZQpaB\n-----END PRIVATE KEY-----\n",
|
|
6
|
+
"createdAtMs": 1770715930222
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"messages": {
|
|
3
|
+
"ackReactionScope": "group-mentions"
|
|
4
|
+
},
|
|
5
|
+
"agents": {
|
|
6
|
+
"defaults": {
|
|
7
|
+
"maxConcurrent": 4,
|
|
8
|
+
"subagents": {
|
|
9
|
+
"maxConcurrent": 8
|
|
10
|
+
},
|
|
11
|
+
"compaction": {
|
|
12
|
+
"mode": "safeguard"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"gateway": {
|
|
17
|
+
"auth": {
|
|
18
|
+
"mode": "token",
|
|
19
|
+
"token": "e432e1210dcfb65a16122ce44ccaabeb6fefac299759b841"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"wizard": {
|
|
23
|
+
"lastRunAt": "2026-02-10T09:32:30.166Z",
|
|
24
|
+
"lastRunVersion": "2026.2.9",
|
|
25
|
+
"lastRunCommand": "doctor",
|
|
26
|
+
"lastRunMode": "local"
|
|
27
|
+
},
|
|
28
|
+
"meta": {
|
|
29
|
+
"lastTouchedVersion": "2026.2.9",
|
|
30
|
+
"lastTouchedAt": "2026-02-10T09:32:30.181Z"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/DOCS_TR.md
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# π Vantuz AI - TΓΌrkΓ§e Teknik DokΓΌmantasyon
|
|
2
|
+
|
|
3
|
+
## Δ°Γ§indekiler
|
|
4
|
+
|
|
5
|
+
1. [Mimari Genel BakΔ±Ε](#mimari)
|
|
6
|
+
2. [Plugin YapΔ±sΔ±](#plugin-yapΔ±sΔ±)
|
|
7
|
+
3. [Tools (AraΓ§lar)](#tools)
|
|
8
|
+
4. [Commands (Komutlar)](#commands)
|
|
9
|
+
5. [Services (Servisler)](#services)
|
|
10
|
+
6. [Hippocampus HafΔ±za](#hippocampus)
|
|
11
|
+
7. [YapΔ±landΔ±rma](#yapΔ±landΔ±rma)
|
|
12
|
+
8. [API ReferansΔ±](#api-referansΔ±)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Mimari
|
|
17
|
+
|
|
18
|
+
Vantuz, **OpenClaw Gateway** ΓΌzerine inΕa edilmiΕ bir plugin sistemidir.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
+
β OpenClaw Gateway β
|
|
23
|
+
β ββββββββββββ ββββββββββββ ββββββββββββ β
|
|
24
|
+
β β WhatsApp β β Telegram β β Discord β β
|
|
25
|
+
β ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
|
|
26
|
+
β β β β β
|
|
27
|
+
β βββββββββββββββΌββββββββββββββ β
|
|
28
|
+
β βΌ β
|
|
29
|
+
β βββββββββββββββ β
|
|
30
|
+
β β Vantuz Core β β
|
|
31
|
+
β β Plugin β β
|
|
32
|
+
β βββββββ¬ββββββββ β
|
|
33
|
+
β β β
|
|
34
|
+
β βββββββββ¬ββββββββΌββββββββ¬ββββββββ β
|
|
35
|
+
β βΌ βΌ βΌ βΌ βΌ β
|
|
36
|
+
β ββββββββββββββββββββββββββββββββββββββββ β
|
|
37
|
+
β βRepri-ββVisionββSenti-ββCross-ββAnaly-β β
|
|
38
|
+
β βcer ββ AI ββment ββBorderββtics β β
|
|
39
|
+
β ββββββββββββββββββββββββββββββββββββββββ β
|
|
40
|
+
β β β
|
|
41
|
+
β βββββββΌββββββββ β
|
|
42
|
+
β β Hippocampus β β
|
|
43
|
+
β β Memory β β
|
|
44
|
+
β βββββββββββββββ β
|
|
45
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Plugin YapΔ±sΔ±
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
plugins/vantuz/
|
|
54
|
+
βββ index.js # Ana plugin entry point
|
|
55
|
+
βββ package.json # Plugin manifest
|
|
56
|
+
βββ tools/
|
|
57
|
+
β βββ repricer.js # Kan Emici fiyat robotu
|
|
58
|
+
β βββ vision.js # FotoΔraf β ΓΌrΓΌn
|
|
59
|
+
β βββ sentiment.js # Yorum analizi
|
|
60
|
+
β βββ crossborder.js # SΔ±nΔ±r ΓΆtesi satΔ±Ε
|
|
61
|
+
β βββ product.js # ΓrΓΌn CRUD
|
|
62
|
+
β βββ analytics.js # Raporlama
|
|
63
|
+
βββ services/
|
|
64
|
+
β βββ license.js # Lisans doΔrulama
|
|
65
|
+
βββ memory/
|
|
66
|
+
β βββ hippocampus.js # HafΔ±za sistemi
|
|
67
|
+
βββ platforms/
|
|
68
|
+
βββ index.js # Pazaryeri API stubs
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Tools
|
|
74
|
+
|
|
75
|
+
### vantuz.repricer
|
|
76
|
+
|
|
77
|
+
Rakip fiyatlarΔ±nΔ± analiz eder ve karar verir.
|
|
78
|
+
|
|
79
|
+
**Parametreler:**
|
|
80
|
+
| Param | Tip | Zorunlu | AΓ§Δ±klama |
|
|
81
|
+
|-------|-----|---------|----------|
|
|
82
|
+
| barcode | string | β
| ΓrΓΌn barkodu/SKU |
|
|
83
|
+
| platform | string | - | trendyol, hepsiburada, amazon, n11, all |
|
|
84
|
+
| targetMargin | number | - | Hedef kar marjΔ± % |
|
|
85
|
+
| action | string | - | analyze, apply, schedule |
|
|
86
|
+
|
|
87
|
+
**Γrnek:**
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"name": "vantuz.repricer",
|
|
91
|
+
"parameters": {
|
|
92
|
+
"barcode": "SKU-12345",
|
|
93
|
+
"platform": "trendyol",
|
|
94
|
+
"targetMargin": 25,
|
|
95
|
+
"action": "analyze"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### vantuz.vision
|
|
103
|
+
|
|
104
|
+
FotoΔraftan ΓΌrΓΌn bilgisi Γ§Δ±karΔ±r.
|
|
105
|
+
|
|
106
|
+
**Parametreler:**
|
|
107
|
+
| Param | Tip | Zorunlu | AΓ§Δ±klama |
|
|
108
|
+
|-------|-----|---------|----------|
|
|
109
|
+
| imageUrl | string | β
| GΓΆrsel URL veya base64 |
|
|
110
|
+
| targetPlatforms | array | - | Hedef pazaryerleri |
|
|
111
|
+
| autoPublish | boolean | - | Otomatik yayΔ±nla |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### vantuz.sentiment
|
|
116
|
+
|
|
117
|
+
MΓΌΕteri yorumlarΔ±nΔ± analiz eder.
|
|
118
|
+
|
|
119
|
+
**Parametreler:**
|
|
120
|
+
| Param | Tip | Zorunlu | AΓ§Δ±klama |
|
|
121
|
+
|-------|-----|---------|----------|
|
|
122
|
+
| productId | string | β
| ΓrΓΌn ID/barkod |
|
|
123
|
+
| platform | string | - | Pazaryeri |
|
|
124
|
+
| period | string | - | 7d, 30d, 90d, all |
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### vantuz.crossborder
|
|
129
|
+
|
|
130
|
+
UluslararasΔ± satΔ±Ε hazΔ±rlΔ±ΔΔ± yapar.
|
|
131
|
+
|
|
132
|
+
**Parametreler:**
|
|
133
|
+
| Param | Tip | Zorunlu | AΓ§Δ±klama |
|
|
134
|
+
|-------|-----|---------|----------|
|
|
135
|
+
| productId | string | β
| Kaynak ΓΌrΓΌn ID |
|
|
136
|
+
| targetMarket | string | β
| de, us, uk, fr |
|
|
137
|
+
| fulfillment | string | - | fba, fbm, self |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Commands
|
|
142
|
+
|
|
143
|
+
KullanΔ±cΔ±lar WhatsApp/Telegram'dan doΔrudan kullanabilir:
|
|
144
|
+
|
|
145
|
+
| Komut | AΓ§Δ±klama | Γrnek |
|
|
146
|
+
|-------|----------|-------|
|
|
147
|
+
| `/stok` | Stok ΓΆzeti | `/stok trendyol` |
|
|
148
|
+
| `/fiyat` | Fiyat gΓΌncelle | `/fiyat SKU123 199` |
|
|
149
|
+
| `/rapor` | SatΔ±Ε raporu | `/rapor 7d` |
|
|
150
|
+
| `/rakip` | Rakip analizi | `/rakip SKU123` |
|
|
151
|
+
| `/lisans` | Lisans durumu | `/lisans` |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Services
|
|
156
|
+
|
|
157
|
+
### vantuz-license
|
|
158
|
+
BaΕlatmada lisans doΔrulamasΔ± yapar. Her 24 saatte bir kontrol tekrarlanΔ±r.
|
|
159
|
+
|
|
160
|
+
### vantuz-memory
|
|
161
|
+
Hippocampus hafΔ±za sistemini baΕlatΔ±r ve yΓΆnetir.
|
|
162
|
+
|
|
163
|
+
### vantuz-repricer-daemon
|
|
164
|
+
Her 15 dakikada bir otomatik fiyat kontrolΓΌ yapar.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Hippocampus
|
|
169
|
+
|
|
170
|
+
SQLite tabanlΔ± geliΕmiΕ hafΔ±za sistemi.
|
|
171
|
+
|
|
172
|
+
### Tablolar
|
|
173
|
+
|
|
174
|
+
**Memory** - Genel hafΔ±za
|
|
175
|
+
- type: decision, price_change, product, conversation, insight
|
|
176
|
+
- content: HafΔ±za iΓ§eriΔi
|
|
177
|
+
- importance: 0-1 ΓΆnem skoru
|
|
178
|
+
- accessCount: EriΕim sayΔ±sΔ±
|
|
179
|
+
|
|
180
|
+
**PricingDecision** - Fiyat kararlarΔ±
|
|
181
|
+
- barcode, previousPrice, newPrice, reason, outcome
|
|
182
|
+
|
|
183
|
+
**ProductContext** - ΓrΓΌn baΔlamΔ±
|
|
184
|
+
- avgSalePrice, competitorHistory, customerSentiment
|
|
185
|
+
|
|
186
|
+
**LearnedRule** - ΓΔrenilen kurallar
|
|
187
|
+
- trigger, condition, action, confidence
|
|
188
|
+
|
|
189
|
+
### Γzellikler
|
|
190
|
+
|
|
191
|
+
- **Konsolidasyon**: Her gece 03:00'te eski/ΓΆnemsiz hafΔ±zalar temizlenir
|
|
192
|
+
- **ΓΔrenme**: BaΕarΔ±lΔ± kararlar otomatik kural olur
|
|
193
|
+
- **BaΔlamsal HatΔ±rlama**: Δ°lgili hafΔ±zalar sorgulanabilir
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## YapΔ±landΔ±rma
|
|
198
|
+
|
|
199
|
+
### .openclaw/openclaw.json
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"agents": {
|
|
204
|
+
"defaults": {
|
|
205
|
+
"workspace": "./workspace"
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"channels": {
|
|
209
|
+
"whatsapp": { "enabled": true },
|
|
210
|
+
"telegram": {
|
|
211
|
+
"enabled": true,
|
|
212
|
+
"botToken": "${TELEGRAM_BOT_TOKEN}"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"models": {
|
|
216
|
+
"openai": {
|
|
217
|
+
"apiKey": "${OPENAI_API_KEY}"
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
"plugins": {
|
|
221
|
+
"load": {
|
|
222
|
+
"paths": ["./plugins/vantuz"]
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### .env
|
|
229
|
+
|
|
230
|
+
```env
|
|
231
|
+
OPENAI_API_KEY=sk-...
|
|
232
|
+
TELEGRAM_BOT_TOKEN=123456:ABC...
|
|
233
|
+
VANTUZ_LICENSE_KEY=...
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## API ReferansΔ±
|
|
239
|
+
|
|
240
|
+
### Gateway RPC
|
|
241
|
+
|
|
242
|
+
**vantuz.status**
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"version": "2.0.0",
|
|
246
|
+
"license": { "valid": true, "customer": "..." },
|
|
247
|
+
"memory": { "memories": 150, "decisions": 45 },
|
|
248
|
+
"platforms": { "trendyol": true, "hepsiburada": true }
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**vantuz.config**
|
|
253
|
+
```json
|
|
254
|
+
// GET
|
|
255
|
+
{ "action": "get" }
|
|
256
|
+
|
|
257
|
+
// SET
|
|
258
|
+
{ "action": "set", "data": { "repricerInterval": 30 } }
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## GeliΕtirme
|
|
264
|
+
|
|
265
|
+
### Yeni Tool Ekleme
|
|
266
|
+
|
|
267
|
+
```javascript
|
|
268
|
+
// plugins/vantuz/tools/myTool.js
|
|
269
|
+
export const myTool = {
|
|
270
|
+
name: 'my-tool',
|
|
271
|
+
async execute(params, context) {
|
|
272
|
+
const { api, memory, license } = context;
|
|
273
|
+
// ...
|
|
274
|
+
return { success: true, data: {} };
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// index.js'de register et
|
|
279
|
+
api.registerTool({
|
|
280
|
+
name: 'vantuz.mytool',
|
|
281
|
+
description: '...',
|
|
282
|
+
parameters: { ... },
|
|
283
|
+
handler: (params) => myTool.execute(params, context)
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Yeni Command Ekleme
|
|
288
|
+
|
|
289
|
+
```javascript
|
|
290
|
+
api.registerCommand({
|
|
291
|
+
name: 'mycommand',
|
|
292
|
+
description: 'AΓ§Δ±klama',
|
|
293
|
+
acceptsArgs: true,
|
|
294
|
+
handler: async (ctx) => {
|
|
295
|
+
return { text: 'YanΔ±t' };
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
```
|
package/core/ai-provider.js
CHANGED
|
@@ -10,6 +10,75 @@ import os from 'os';
|
|
|
10
10
|
|
|
11
11
|
const LOG_FILE = path.join(os.homedir(), '.vantuz', 'vantuz.log');
|
|
12
12
|
|
|
13
|
+
const PROVIDER_CONFIG = {
|
|
14
|
+
gemini: {
|
|
15
|
+
url: (apiKey) => `https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=${apiKey}`,
|
|
16
|
+
body: (systemPrompt, message) => ({
|
|
17
|
+
contents: [{ parts: [{ text: `${systemPrompt}\n\nKullanΔ±cΔ±: ${message}` }] }]
|
|
18
|
+
}),
|
|
19
|
+
headers: { 'Content-Type': 'application/json' },
|
|
20
|
+
parseResponse: (data) => data?.candidates?.[0]?.content?.parts?.[0]?.text,
|
|
21
|
+
errorMsg: 'Gemini yanΔ±t vermedi'
|
|
22
|
+
},
|
|
23
|
+
groq: {
|
|
24
|
+
url: 'https://api.groq.com/openai/v1/chat/completions',
|
|
25
|
+
body: (systemPrompt, message) => ({
|
|
26
|
+
model: 'llama-3.3-70b-versatile',
|
|
27
|
+
messages: [
|
|
28
|
+
{ role: 'system', content: systemPrompt },
|
|
29
|
+
{ role: 'user', content: message }
|
|
30
|
+
],
|
|
31
|
+
max_tokens: 1000,
|
|
32
|
+
temperature: 0.7
|
|
33
|
+
}),
|
|
34
|
+
headers: (apiKey) => ({ 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }),
|
|
35
|
+
parseResponse: (data) => data?.choices?.[0]?.message?.content,
|
|
36
|
+
errorMsg: 'Groq yanΔ±t vermedi'
|
|
37
|
+
},
|
|
38
|
+
openai: {
|
|
39
|
+
url: 'https://api.openai.com/v1/chat/completions',
|
|
40
|
+
body: (systemPrompt, message) => ({
|
|
41
|
+
model: 'gpt-4o-mini',
|
|
42
|
+
messages: [
|
|
43
|
+
{ role: 'system', content: systemPrompt },
|
|
44
|
+
{ role: 'user', content: message }
|
|
45
|
+
],
|
|
46
|
+
max_tokens: 1000
|
|
47
|
+
}),
|
|
48
|
+
headers: (apiKey) => ({ 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }),
|
|
49
|
+
parseResponse: (data) => data?.choices?.[0]?.message?.content,
|
|
50
|
+
errorMsg: 'OpenAI yanΔ±t vermedi'
|
|
51
|
+
},
|
|
52
|
+
anthropic: {
|
|
53
|
+
url: 'https://api.anthropic.com/v1/messages',
|
|
54
|
+
body: (systemPrompt, message) => ({
|
|
55
|
+
model: 'claude-3-haiku-20240307',
|
|
56
|
+
max_tokens: 1000,
|
|
57
|
+
messages: [
|
|
58
|
+
{ role: 'user', content: message }
|
|
59
|
+
],
|
|
60
|
+
system: systemPrompt
|
|
61
|
+
}),
|
|
62
|
+
headers: (apiKey) => ({ 'x-api-key': apiKey, 'anthropic-version': '2023-06-01', 'Content-Type': 'application/json' }),
|
|
63
|
+
parseResponse: (data) => data?.content?.[0]?.text,
|
|
64
|
+
errorMsg: 'Anthropic yanΔ±t vermedi'
|
|
65
|
+
},
|
|
66
|
+
deepseek: {
|
|
67
|
+
url: 'https://api.deepseek.com/v1/chat/completions',
|
|
68
|
+
body: (systemPrompt, message) => ({
|
|
69
|
+
model: 'deepseek-chat',
|
|
70
|
+
messages: [
|
|
71
|
+
{ role: 'system', content: systemPrompt },
|
|
72
|
+
{ role: 'user', content: message }
|
|
73
|
+
],
|
|
74
|
+
max_tokens: 1000
|
|
75
|
+
}),
|
|
76
|
+
headers: (apiKey) => ({ 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }),
|
|
77
|
+
parseResponse: (data) => data?.choices?.[0]?.message?.content,
|
|
78
|
+
errorMsg: 'DeepSeek yanΔ±t vermedi'
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
13
82
|
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
14
83
|
// LOGGING
|
|
15
84
|
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -91,8 +160,28 @@ const VANTUZ_SYSTEM_PROMPT = `Sen Vantuz AI, e-ticaret operasyonlarΔ±nΔ± yΓΆnete
|
|
|
91
160
|
// AI CHAT
|
|
92
161
|
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
93
162
|
|
|
163
|
+
async function _makeApiRequest(providerName, providerConfig, message, apiKey, systemPrompt) {
|
|
164
|
+
if (!apiKey) throw new Error(`${providerName.toUpperCase()}_API_KEY ayarlanmamΔ±Ε`);
|
|
165
|
+
|
|
166
|
+
const url = typeof providerConfig.url === 'function' ? providerConfig.url(apiKey) : providerConfig.url;
|
|
167
|
+
const headers = typeof providerConfig.headers === 'function' ? providerConfig.headers(apiKey) : providerConfig.headers;
|
|
168
|
+
const body = providerConfig.body(systemPrompt, message);
|
|
169
|
+
|
|
170
|
+
const response = await axios.post(url, body, {
|
|
171
|
+
headers,
|
|
172
|
+
timeout: 30000
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const text = providerConfig.parseResponse(response.data);
|
|
176
|
+
if (!text) throw new Error(providerConfig.errorMsg);
|
|
177
|
+
|
|
178
|
+
log('INFO', `${providerName} yanΔ±tΔ± alΔ±ndΔ±`, { chars: text.length });
|
|
179
|
+
return text;
|
|
180
|
+
}
|
|
181
|
+
|
|
94
182
|
export async function chat(message, config, env) {
|
|
95
183
|
const provider = config.aiProvider || 'gemini';
|
|
184
|
+
const providerConfig = PROVIDER_CONFIG[provider];
|
|
96
185
|
|
|
97
186
|
// Context bilgisi ekle
|
|
98
187
|
const contextInfo = config.systemContext || '';
|
|
@@ -100,154 +189,19 @@ export async function chat(message, config, env) {
|
|
|
100
189
|
|
|
101
190
|
log('INFO', `AI isteΔi: ${provider}`, { message: message.slice(0, 100) });
|
|
102
191
|
|
|
192
|
+
if (!providerConfig) {
|
|
193
|
+
return 'Desteklenmeyen AI saΔlayΔ±cΔ±: ' + provider;
|
|
194
|
+
}
|
|
195
|
+
|
|
103
196
|
try {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return await chatGemini(message, env.GEMINI_API_KEY, fullSystemPrompt);
|
|
107
|
-
case 'groq':
|
|
108
|
-
return await chatGroq(message, env.GROQ_API_KEY, fullSystemPrompt);
|
|
109
|
-
case 'openai':
|
|
110
|
-
return await chatOpenAI(message, env.OPENAI_API_KEY, fullSystemPrompt);
|
|
111
|
-
case 'anthropic':
|
|
112
|
-
return await chatAnthropic(message, env.ANTHROPIC_API_KEY, fullSystemPrompt);
|
|
113
|
-
case 'deepseek':
|
|
114
|
-
return await chatDeepSeek(message, env.DEEPSEEK_API_KEY, fullSystemPrompt);
|
|
115
|
-
default:
|
|
116
|
-
return 'Desteklenmeyen AI saΔlayΔ±cΔ±: ' + provider;
|
|
117
|
-
}
|
|
197
|
+
const apiKey = env[`${provider.toUpperCase()}_API_KEY`];
|
|
198
|
+
return await _makeApiRequest(provider, providerConfig, message, apiKey, fullSystemPrompt);
|
|
118
199
|
} catch (error) {
|
|
119
200
|
log('ERROR', `AI hatasΔ±: ${error.message}`, { provider });
|
|
120
201
|
return `AI hatasΔ±: ${error.message}. /logs komutu ile detay gΓΆrΓΌn.`;
|
|
121
202
|
}
|
|
122
203
|
}
|
|
123
204
|
|
|
124
|
-
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
125
|
-
// PROVIDER IMPLEMENTATIONS
|
|
126
|
-
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
127
|
-
|
|
128
|
-
async function chatGemini(message, apiKey, systemPrompt) {
|
|
129
|
-
if (!apiKey) throw new Error('GEMINI_API_KEY ayarlanmamΔ±Ε');
|
|
130
|
-
|
|
131
|
-
const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=${apiKey}`;
|
|
132
|
-
|
|
133
|
-
const response = await axios.post(url, {
|
|
134
|
-
contents: [{
|
|
135
|
-
parts: [{
|
|
136
|
-
text: `${systemPrompt}\n\nKullanΔ±cΔ±: ${message}`
|
|
137
|
-
}]
|
|
138
|
-
}]
|
|
139
|
-
}, {
|
|
140
|
-
headers: { 'Content-Type': 'application/json' },
|
|
141
|
-
timeout: 30000
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
const text = response.data?.candidates?.[0]?.content?.parts?.[0]?.text;
|
|
145
|
-
if (!text) throw new Error('Gemini yanΔ±t vermedi');
|
|
146
|
-
|
|
147
|
-
log('INFO', 'Gemini yanΔ±tΔ± alΔ±ndΔ±', { chars: text.length });
|
|
148
|
-
return text;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
async function chatGroq(message, apiKey, systemPrompt) {
|
|
152
|
-
if (!apiKey) throw new Error('GROQ_API_KEY ayarlanmamΔ±Ε');
|
|
153
|
-
|
|
154
|
-
const response = await axios.post('https://api.groq.com/openai/v1/chat/completions', {
|
|
155
|
-
model: 'llama-3.3-70b-versatile',
|
|
156
|
-
messages: [
|
|
157
|
-
{ role: 'system', content: systemPrompt },
|
|
158
|
-
{ role: 'user', content: message }
|
|
159
|
-
],
|
|
160
|
-
max_tokens: 1000,
|
|
161
|
-
temperature: 0.7
|
|
162
|
-
}, {
|
|
163
|
-
headers: {
|
|
164
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
165
|
-
'Content-Type': 'application/json'
|
|
166
|
-
},
|
|
167
|
-
timeout: 30000
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const text = response.data?.choices?.[0]?.message?.content;
|
|
171
|
-
if (!text) throw new Error('Groq yanΔ±t vermedi');
|
|
172
|
-
|
|
173
|
-
log('INFO', 'Groq yanΔ±tΔ± alΔ±ndΔ±', { chars: text.length });
|
|
174
|
-
return text;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
async function chatOpenAI(message, apiKey, systemPrompt) {
|
|
178
|
-
if (!apiKey) throw new Error('OPENAI_API_KEY ayarlanmamΔ±Ε');
|
|
179
|
-
|
|
180
|
-
const response = await axios.post('https://api.openai.com/v1/chat/completions', {
|
|
181
|
-
model: 'gpt-4o-mini',
|
|
182
|
-
messages: [
|
|
183
|
-
{ role: 'system', content: systemPrompt },
|
|
184
|
-
{ role: 'user', content: message }
|
|
185
|
-
],
|
|
186
|
-
max_tokens: 1000
|
|
187
|
-
}, {
|
|
188
|
-
headers: {
|
|
189
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
190
|
-
'Content-Type': 'application/json'
|
|
191
|
-
},
|
|
192
|
-
timeout: 30000
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
const text = response.data?.choices?.[0]?.message?.content;
|
|
196
|
-
if (!text) throw new Error('OpenAI yanΔ±t vermedi');
|
|
197
|
-
|
|
198
|
-
log('INFO', 'OpenAI yanΔ±tΔ± alΔ±ndΔ±', { chars: text.length });
|
|
199
|
-
return text;
|
|
200
|
-
}
|
|
201
205
|
|
|
202
|
-
async function chatAnthropic(message, apiKey, systemPrompt) {
|
|
203
|
-
if (!apiKey) throw new Error('ANTHROPIC_API_KEY ayarlanmamΔ±Ε');
|
|
204
|
-
|
|
205
|
-
const response = await axios.post('https://api.anthropic.com/v1/messages', {
|
|
206
|
-
model: 'claude-3-haiku-20240307',
|
|
207
|
-
max_tokens: 1000,
|
|
208
|
-
messages: [
|
|
209
|
-
{ role: 'user', content: message }
|
|
210
|
-
],
|
|
211
|
-
system: systemPrompt
|
|
212
|
-
}, {
|
|
213
|
-
headers: {
|
|
214
|
-
'x-api-key': apiKey,
|
|
215
|
-
'anthropic-version': '2023-06-01',
|
|
216
|
-
'Content-Type': 'application/json'
|
|
217
|
-
},
|
|
218
|
-
timeout: 30000
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
const text = response.data?.content?.[0]?.text;
|
|
222
|
-
if (!text) throw new Error('Anthropic yanΔ±t vermedi');
|
|
223
|
-
|
|
224
|
-
log('INFO', 'Anthropic yanΔ±tΔ± alΔ±ndΔ±', { chars: text.length });
|
|
225
|
-
return text;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
async function chatDeepSeek(message, apiKey, systemPrompt) {
|
|
229
|
-
if (!apiKey) throw new Error('DEEPSEEK_API_KEY ayarlanmamΔ±Ε');
|
|
230
|
-
|
|
231
|
-
const response = await axios.post('https://api.deepseek.com/v1/chat/completions', {
|
|
232
|
-
model: 'deepseek-chat',
|
|
233
|
-
messages: [
|
|
234
|
-
{ role: 'system', content: systemPrompt },
|
|
235
|
-
{ role: 'user', content: message }
|
|
236
|
-
],
|
|
237
|
-
max_tokens: 1000
|
|
238
|
-
}, {
|
|
239
|
-
headers: {
|
|
240
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
241
|
-
'Content-Type': 'application/json'
|
|
242
|
-
},
|
|
243
|
-
timeout: 30000
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
const text = response.data?.choices?.[0]?.message?.content;
|
|
247
|
-
if (!text) throw new Error('DeepSeek yanΔ±t vermedi');
|
|
248
|
-
|
|
249
|
-
log('INFO', 'DeepSeek yanΔ±tΔ± alΔ±ndΔ±', { chars: text.length });
|
|
250
|
-
return text;
|
|
251
|
-
}
|
|
252
206
|
|
|
253
207
|
export default { chat, log, getLogs, clearLogs };
|