vantuz 3.4.2 → 3.5.1

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.
Files changed (92) hide show
  1. package/.env.example +21 -0
  2. package/.openclaw/completions/openclaw.bash +227 -0
  3. package/.openclaw/completions/openclaw.fish +1552 -0
  4. package/.openclaw/completions/openclaw.ps1 +1966 -0
  5. package/.openclaw/completions/openclaw.zsh +3571 -0
  6. package/.openclaw/gateway.cmd +10 -0
  7. package/.openclaw/identity/device.json +7 -0
  8. package/.openclaw/openclaw.json +40 -0
  9. package/.windsurf/workflows/vantuz-dev.md +31 -0
  10. package/DOCS_TR.md +80 -0
  11. package/LICENSE +45 -45
  12. package/README.md +52 -21
  13. package/cli.js +685 -585
  14. package/config.js +733 -733
  15. package/core/agent-loop.js +190 -190
  16. package/core/ai-provider.js +298 -261
  17. package/core/automation.js +523 -523
  18. package/core/brand-analyst.js +101 -0
  19. package/core/channels.js +167 -167
  20. package/core/dashboard.js +230 -230
  21. package/core/database.js +135 -37
  22. package/core/eia-monitor.js +3 -1
  23. package/core/engine.js +648 -636
  24. package/core/gateway.js +447 -447
  25. package/core/learning.js +214 -214
  26. package/core/license.js +113 -0
  27. package/core/marketplace-adapter.js +168 -168
  28. package/core/memory.js +190 -190
  29. package/core/migrations/001-initial-schema.sql +1 -1
  30. package/core/queue.js +120 -120
  31. package/core/self-healer.js +314 -314
  32. package/core/unified-product.js +214 -214
  33. package/core/vision-service.js +113 -113
  34. package/index.js +217 -174
  35. package/modules/crm/sentiment-crm.js +231 -231
  36. package/modules/healer/listing-healer.js +201 -201
  37. package/modules/oracle/predictor.js +214 -214
  38. package/modules/researcher/agent.js +169 -169
  39. package/modules/team/agents/base.js +92 -92
  40. package/modules/team/agents/dev.js +33 -33
  41. package/modules/team/agents/josh.js +40 -40
  42. package/modules/team/agents/marketing.js +33 -33
  43. package/modules/team/agents/milo.js +36 -36
  44. package/modules/team/index.js +78 -78
  45. package/modules/team/shared-memory.js +87 -87
  46. package/modules/war-room/competitor-tracker.js +250 -250
  47. package/modules/war-room/pricing-engine.js +308 -308
  48. package/n11docs.md +1680 -0
  49. package/nodes/warehouse.js +238 -238
  50. package/onboard.js +1 -1
  51. package/openclawdocs.md +3 -0
  52. package/package.json +7 -5
  53. package/platforms/pttavm.js +14 -14
  54. package/plugins/vantuz/index.js +528 -528
  55. package/plugins/vantuz/memory/hippocampus.js +465 -465
  56. package/plugins/vantuz/package.json +20 -20
  57. package/plugins/vantuz/platforms/_template.js +118 -118
  58. package/plugins/vantuz/platforms/amazon.js +236 -236
  59. package/plugins/vantuz/platforms/ciceksepeti.js +166 -166
  60. package/plugins/vantuz/platforms/hepsiburada.js +180 -180
  61. package/plugins/vantuz/platforms/index.js +165 -165
  62. package/plugins/vantuz/platforms/n11.js +229 -229
  63. package/plugins/vantuz/platforms/pazarama.js +154 -154
  64. package/plugins/vantuz/platforms/pttavm.js +127 -127
  65. package/plugins/vantuz/platforms/trendyol.js +326 -326
  66. package/plugins/vantuz/services/alerts.js +253 -253
  67. package/plugins/vantuz/services/license.js +34 -34
  68. package/plugins/vantuz/services/scheduler.js +232 -232
  69. package/plugins/vantuz/tools/analytics.js +152 -152
  70. package/plugins/vantuz/tools/crossborder.js +187 -187
  71. package/plugins/vantuz/tools/nl-parser.js +211 -211
  72. package/plugins/vantuz/tools/product.js +110 -110
  73. package/plugins/vantuz/tools/quick-report.js +175 -175
  74. package/plugins/vantuz/tools/repricer.js +314 -314
  75. package/plugins/vantuz/tools/sentiment.js +115 -115
  76. package/plugins/vantuz/tools/vision.js +257 -257
  77. package/public.pem +9 -0
  78. package/server/app.js +260 -260
  79. package/server/public/index.html +514 -514
  80. package/start.bat +33 -33
  81. package/vantuz.sqlite +0 -0
  82. package/workspace/AGENTS.md +73 -0
  83. package/workspace/BRAND.md +29 -0
  84. package/workspace/SOUL.md +72 -0
  85. package/workspace/team/DECISIONS.md +3 -0
  86. package/workspace/team/GOALS.md +3 -0
  87. package/workspace/team/PROJECT_STATUS.md +3 -0
  88. package/workspace/team/agents/dev/SOUL.md +12 -0
  89. package/workspace/team/agents/josh/SOUL.md +12 -0
  90. package/workspace/team/agents/marketing/SOUL.md +12 -0
  91. package/workspace/team/agents/milo/SOUL.md +12 -0
  92. package/vantuz-3.3.4.tgz +0 -0
package/server/app.js CHANGED
@@ -1,260 +1,260 @@
1
-
2
- import express from 'express';
3
- import cors from 'cors';
4
-
5
- import path from 'path';
6
- import { fileURLToPath } from 'url';
7
- import { getEngine } from '../core/engine.js';
8
- import { getGateway } from '../core/gateway.js';
9
- import { log } from '../core/ai-provider.js';
10
-
11
- const __filename = fileURLToPath(import.meta.url);
12
- const __dirname = path.dirname(__filename);
13
-
14
- const app = express();
15
- const PORT = process.env.PORT || 3001;
16
-
17
- // Middleware
18
- app.use(cors());
19
- app.use(express.json());
20
- app.use(express.static(path.join(__dirname, 'public')));
21
-
22
- // Engine Singleton
23
- let engine = null;
24
- const initEngine = async () => {
25
- if (!engine) {
26
- engine = await getEngine();
27
- }
28
- return engine;
29
- };
30
-
31
- // ═══════════════════════════════════════════════════════════════════════════
32
- // API ROUTES
33
- // ═══════════════════════════════════════════════════════════════════════════
34
-
35
- // 1. Status & Health
36
- app.get('/api/status', async (req, res) => {
37
- const instance = await initEngine();
38
- res.json(instance.getStatus());
39
- });
40
-
41
- // 2. Products & Stock
42
- app.get('/api/products', async (req, res) => {
43
- try {
44
- const instance = await initEngine();
45
- const stocks = await instance.getStock();
46
- res.json(stocks);
47
- } catch (e) {
48
- res.status(500).json({ error: e.message });
49
- }
50
- });
51
-
52
- // 3. Orders
53
- app.get('/api/orders', async (req, res) => {
54
- try {
55
- const instance = await initEngine();
56
- const orders = await instance.getOrders({ size: 50 });
57
- res.json(orders);
58
- } catch (e) {
59
- res.status(500).json({ error: e.message });
60
- }
61
- });
62
-
63
- // 4. AI Chat
64
- app.post('/api/chat', async (req, res) => {
65
- const { message } = req.body;
66
- if (!message) return res.status(400).json({ error: 'Mesaj gerekli' });
67
-
68
- try {
69
- const instance = await initEngine();
70
- const response = await instance.chat(message);
71
- res.json({ response });
72
- } catch (e) {
73
- res.status(500).json({ error: e.message });
74
- }
75
- });
76
-
77
- // 4b. Inbound message (channels)
78
- app.post('/api/inbound', async (req, res) => {
79
- const { message, channel, from } = req.body || {};
80
- if (!message) return res.status(400).json({ error: 'Mesaj gerekli' });
81
-
82
- try {
83
- const instance = await initEngine();
84
- const response = await instance.handleMessage(message, {
85
- channel: channel || 'local',
86
- from: from || 'unknown'
87
- });
88
- res.json({ response });
89
- } catch (e) {
90
- res.status(500).json({ error: e.message });
91
- }
92
- });
93
-
94
- // 5. Logs
95
- app.get('/api/logs', async (req, res) => {
96
- const { getLogs } = await import('../core/ai-provider.js');
97
- res.json({ logs: getLogs(100) });
98
- });
99
-
100
- // 6. Gateway Status
101
- app.get('/api/gateway', async (req, res) => {
102
- try {
103
- const gw = await getGateway();
104
- const health = await gw.health();
105
- res.json({
106
- ...gw.getInfo(),
107
- health: health.success ? 'healthy' : 'unreachable',
108
- healthData: health.data || null
109
- });
110
- } catch (e) {
111
- res.status(500).json({ error: e.message });
112
- }
113
- });
114
-
115
- // 7. Channels Status
116
- app.get('/api/channels', async (req, res) => {
117
- try {
118
- const instance = await initEngine();
119
- const status = instance.getStatus();
120
- res.json(status.channels || {});
121
- } catch (e) {
122
- res.status(500).json({ error: e.message });
123
- }
124
- });
125
-
126
- // 8. Doctor
127
- app.get('/api/doctor', async (req, res) => {
128
- try {
129
- const instance = await initEngine();
130
- const report = await instance.doctor();
131
- res.json(report);
132
- } catch (e) {
133
- res.status(500).json({ error: e.message });
134
- }
135
- });
136
-
137
- // ═══════════════════════════════════════════════════════════════════════════
138
- // 9. WEBHOOKS - Platform Event Receivers
139
- // ═══════════════════════════════════════════════════════════════════════════
140
-
141
- app.post('/api/webhooks/:platform', async (req, res) => {
142
- const { platform } = req.params;
143
- const secret = req.headers['x-webhook-secret'] || '';
144
- const expectedSecret = process.env.WEBHOOK_SECRET || '';
145
-
146
- if (expectedSecret && secret !== expectedSecret) {
147
- log('WARN', `Webhook rejected: invalid secret`, { platform });
148
- return res.status(401).json({ error: 'Unauthorized' });
149
- }
150
-
151
- const event = req.body;
152
- log('INFO', `Webhook received from ${platform}`, {
153
- type: event.type || event.eventType || 'unknown'
154
- });
155
-
156
- try {
157
- const instance = await initEngine();
158
- const eventType = (event.type || event.eventType || '').toLowerCase();
159
-
160
- if (eventType.includes('order') || eventType.includes('siparis')) {
161
- await instance.chat(`📦 [${platform.toUpperCase()}] Yeni sipariş olayı: ${eventType}`);
162
- } else if (eventType.includes('stock') || eventType.includes('stok')) {
163
- await instance.chat(`📊 [${platform.toUpperCase()}] Stok olayı: ${eventType}`);
164
- } else if (eventType.includes('return') || eventType.includes('iade')) {
165
- await instance.chat(`🔄 [${platform.toUpperCase()}] İade talebi alındı`);
166
- }
167
-
168
- if (instance.memory) {
169
- instance.memory.remember(`${platform}: ${eventType}`, 'webhook');
170
- }
171
-
172
- res.json({ received: true, platform, eventType });
173
- } catch (e) {
174
- res.status(500).json({ error: e.message });
175
- }
176
- });
177
-
178
- // ═══════════════════════════════════════════════════════════════════════════
179
- // 10. VISION API
180
- // ═══════════════════════════════════════════════════════════════════════════
181
-
182
- app.post('/api/vision/analyze', async (req, res) => {
183
- const { image, checkDamage } = req.body;
184
- if (!image) return res.status(400).json({ error: 'image parametresi gerekli' });
185
-
186
- try {
187
- const { analyzeProductImage, checkReturnDamage } = await import('../core/vision-service.js');
188
- const instance = await initEngine();
189
- const aiConfig = {
190
- apiKey: instance.env?.OPENAI_API_KEY || instance.env?.GEMINI_API_KEY,
191
- model: 'gpt-4o'
192
- };
193
-
194
- const result = checkDamage
195
- ? await checkReturnDamage(image, aiConfig)
196
- : await analyzeProductImage(image, aiConfig);
197
- res.json(result);
198
- } catch (e) {
199
- res.status(500).json({ error: e.message });
200
- }
201
- });
202
-
203
- // ═══════════════════════════════════════════════════════════════════════════
204
- // 11. QUEUE & MEMORY API
205
- // ═══════════════════════════════════════════════════════════════════════════
206
-
207
- app.get('/api/queue', async (req, res) => {
208
- const instance = await initEngine();
209
- res.json(instance.queue ? instance.queue.getStatus() : { error: 'Queue not initialized' });
210
- });
211
-
212
- app.get('/api/memory', async (req, res) => {
213
- const instance = await initEngine();
214
- if (!instance.memory) return res.json({ error: 'Memory not initialized' });
215
- res.json({
216
- factsCount: instance.memory.facts.length,
217
- strategiesCount: instance.memory.strategies.length,
218
- recentFacts: instance.memory.getRecentFacts(10),
219
- strategies: instance.memory.getStrategies()
220
- });
221
- });
222
-
223
- app.post('/api/memory/remember', async (req, res) => {
224
- const { fact, category } = req.body;
225
- if (!fact) return res.status(400).json({ error: 'fact gerekli' });
226
- const instance = await initEngine();
227
- if (!instance.memory) return res.json({ error: 'Memory not initialized' });
228
- res.json(instance.memory.remember(fact, category || 'general'));
229
- });
230
-
231
- // ═══════════════════════════════════════════════════════════════════════════
232
- // 12. SYSTEM HEALTH DASHBOARD
233
- // ═══════════════════════════════════════════════════════════════════════════
234
-
235
- app.get('/api/dashboard', async (req, res) => {
236
- try {
237
- const { getDashboard } = await import('../core/dashboard.js');
238
- const dash = getDashboard();
239
- const format = req.query.format;
240
- if (format === 'text') {
241
- res.type('text/plain').send(dash.getSummary());
242
- } else {
243
- res.json(dash.getHealth());
244
- }
245
- } catch (e) {
246
- res.status(500).json({ error: e.message });
247
- }
248
- });
249
-
250
- // Frontend Serve
251
- app.get('*', (req, res) => {
252
- if (req.path.startsWith('/api')) return res.status(404).json({ error: 'Not Found' });
253
- res.sendFile(path.join(__dirname, 'public', 'index.html'));
254
- });
255
-
256
- // Start Server
257
- app.listen(PORT, () => {
258
- console.log(`\n🚀 Vantuz API Sunucusu: http://localhost:${PORT}`);
259
- log('INFO', `Sunucu ${PORT} portunda başlatıldı`);
260
- });
1
+
2
+ import express from 'express';
3
+ import cors from 'cors';
4
+
5
+ import path from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ import { getEngine } from '../core/engine.js';
8
+ import { getGateway } from '../core/gateway.js';
9
+ import { log } from '../core/ai-provider.js';
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+
14
+ const app = express();
15
+ const PORT = process.env.PORT || 3001;
16
+
17
+ // Middleware
18
+ app.use(cors());
19
+ app.use(express.json());
20
+ app.use(express.static(path.join(__dirname, 'public')));
21
+
22
+ // Engine Singleton
23
+ let engine = null;
24
+ const initEngine = async () => {
25
+ if (!engine) {
26
+ engine = await getEngine();
27
+ }
28
+ return engine;
29
+ };
30
+
31
+ // ═══════════════════════════════════════════════════════════════════════════
32
+ // API ROUTES
33
+ // ═══════════════════════════════════════════════════════════════════════════
34
+
35
+ // 1. Status & Health
36
+ app.get('/api/status', async (req, res) => {
37
+ const instance = await initEngine();
38
+ res.json(instance.getStatus());
39
+ });
40
+
41
+ // 2. Products & Stock
42
+ app.get('/api/products', async (req, res) => {
43
+ try {
44
+ const instance = await initEngine();
45
+ const stocks = await instance.getStock();
46
+ res.json(stocks);
47
+ } catch (e) {
48
+ res.status(500).json({ error: e.message });
49
+ }
50
+ });
51
+
52
+ // 3. Orders
53
+ app.get('/api/orders', async (req, res) => {
54
+ try {
55
+ const instance = await initEngine();
56
+ const orders = await instance.getOrders({ size: 50 });
57
+ res.json(orders);
58
+ } catch (e) {
59
+ res.status(500).json({ error: e.message });
60
+ }
61
+ });
62
+
63
+ // 4. AI Chat
64
+ app.post('/api/chat', async (req, res) => {
65
+ const { message } = req.body;
66
+ if (!message) return res.status(400).json({ error: 'Mesaj gerekli' });
67
+
68
+ try {
69
+ const instance = await initEngine();
70
+ const response = await instance.chat(message);
71
+ res.json({ response });
72
+ } catch (e) {
73
+ res.status(500).json({ error: e.message });
74
+ }
75
+ });
76
+
77
+ // 4b. Inbound message (channels)
78
+ app.post('/api/inbound', async (req, res) => {
79
+ const { message, channel, from } = req.body || {};
80
+ if (!message) return res.status(400).json({ error: 'Mesaj gerekli' });
81
+
82
+ try {
83
+ const instance = await initEngine();
84
+ const response = await instance.handleMessage(message, {
85
+ channel: channel || 'local',
86
+ from: from || 'unknown'
87
+ });
88
+ res.json({ response });
89
+ } catch (e) {
90
+ res.status(500).json({ error: e.message });
91
+ }
92
+ });
93
+
94
+ // 5. Logs
95
+ app.get('/api/logs', async (req, res) => {
96
+ const { getLogs } = await import('../core/ai-provider.js');
97
+ res.json({ logs: getLogs(100) });
98
+ });
99
+
100
+ // 6. Gateway Status
101
+ app.get('/api/gateway', async (req, res) => {
102
+ try {
103
+ const gw = await getGateway();
104
+ const health = await gw.health();
105
+ res.json({
106
+ ...gw.getInfo(),
107
+ health: health.success ? 'healthy' : 'unreachable',
108
+ healthData: health.data || null
109
+ });
110
+ } catch (e) {
111
+ res.status(500).json({ error: e.message });
112
+ }
113
+ });
114
+
115
+ // 7. Channels Status
116
+ app.get('/api/channels', async (req, res) => {
117
+ try {
118
+ const instance = await initEngine();
119
+ const status = instance.getStatus();
120
+ res.json(status.channels || {});
121
+ } catch (e) {
122
+ res.status(500).json({ error: e.message });
123
+ }
124
+ });
125
+
126
+ // 8. Doctor
127
+ app.get('/api/doctor', async (req, res) => {
128
+ try {
129
+ const instance = await initEngine();
130
+ const report = await instance.doctor();
131
+ res.json(report);
132
+ } catch (e) {
133
+ res.status(500).json({ error: e.message });
134
+ }
135
+ });
136
+
137
+ // ═══════════════════════════════════════════════════════════════════════════
138
+ // 9. WEBHOOKS - Platform Event Receivers
139
+ // ═══════════════════════════════════════════════════════════════════════════
140
+
141
+ app.post('/api/webhooks/:platform', async (req, res) => {
142
+ const { platform } = req.params;
143
+ const secret = req.headers['x-webhook-secret'] || '';
144
+ const expectedSecret = process.env.WEBHOOK_SECRET || '';
145
+
146
+ if (expectedSecret && secret !== expectedSecret) {
147
+ log('WARN', `Webhook rejected: invalid secret`, { platform });
148
+ return res.status(401).json({ error: 'Unauthorized' });
149
+ }
150
+
151
+ const event = req.body;
152
+ log('INFO', `Webhook received from ${platform}`, {
153
+ type: event.type || event.eventType || 'unknown'
154
+ });
155
+
156
+ try {
157
+ const instance = await initEngine();
158
+ const eventType = (event.type || event.eventType || '').toLowerCase();
159
+
160
+ if (eventType.includes('order') || eventType.includes('siparis')) {
161
+ await instance.chat(`📦 [${platform.toUpperCase()}] Yeni sipariş olayı: ${eventType}`);
162
+ } else if (eventType.includes('stock') || eventType.includes('stok')) {
163
+ await instance.chat(`📊 [${platform.toUpperCase()}] Stok olayı: ${eventType}`);
164
+ } else if (eventType.includes('return') || eventType.includes('iade')) {
165
+ await instance.chat(`🔄 [${platform.toUpperCase()}] İade talebi alındı`);
166
+ }
167
+
168
+ if (instance.memory) {
169
+ instance.memory.remember(`${platform}: ${eventType}`, 'webhook');
170
+ }
171
+
172
+ res.json({ received: true, platform, eventType });
173
+ } catch (e) {
174
+ res.status(500).json({ error: e.message });
175
+ }
176
+ });
177
+
178
+ // ═══════════════════════════════════════════════════════════════════════════
179
+ // 10. VISION API
180
+ // ═══════════════════════════════════════════════════════════════════════════
181
+
182
+ app.post('/api/vision/analyze', async (req, res) => {
183
+ const { image, checkDamage } = req.body;
184
+ if (!image) return res.status(400).json({ error: 'image parametresi gerekli' });
185
+
186
+ try {
187
+ const { analyzeProductImage, checkReturnDamage } = await import('../core/vision-service.js');
188
+ const instance = await initEngine();
189
+ const aiConfig = {
190
+ apiKey: instance.env?.OPENAI_API_KEY || instance.env?.GEMINI_API_KEY,
191
+ model: 'gpt-4o'
192
+ };
193
+
194
+ const result = checkDamage
195
+ ? await checkReturnDamage(image, aiConfig)
196
+ : await analyzeProductImage(image, aiConfig);
197
+ res.json(result);
198
+ } catch (e) {
199
+ res.status(500).json({ error: e.message });
200
+ }
201
+ });
202
+
203
+ // ═══════════════════════════════════════════════════════════════════════════
204
+ // 11. QUEUE & MEMORY API
205
+ // ═══════════════════════════════════════════════════════════════════════════
206
+
207
+ app.get('/api/queue', async (req, res) => {
208
+ const instance = await initEngine();
209
+ res.json(instance.queue ? instance.queue.getStatus() : { error: 'Queue not initialized' });
210
+ });
211
+
212
+ app.get('/api/memory', async (req, res) => {
213
+ const instance = await initEngine();
214
+ if (!instance.memory) return res.json({ error: 'Memory not initialized' });
215
+ res.json({
216
+ factsCount: instance.memory.facts.length,
217
+ strategiesCount: instance.memory.strategies.length,
218
+ recentFacts: instance.memory.getRecentFacts(10),
219
+ strategies: instance.memory.getStrategies()
220
+ });
221
+ });
222
+
223
+ app.post('/api/memory/remember', async (req, res) => {
224
+ const { fact, category } = req.body;
225
+ if (!fact) return res.status(400).json({ error: 'fact gerekli' });
226
+ const instance = await initEngine();
227
+ if (!instance.memory) return res.json({ error: 'Memory not initialized' });
228
+ res.json(instance.memory.remember(fact, category || 'general'));
229
+ });
230
+
231
+ // ═══════════════════════════════════════════════════════════════════════════
232
+ // 12. SYSTEM HEALTH DASHBOARD
233
+ // ═══════════════════════════════════════════════════════════════════════════
234
+
235
+ app.get('/api/dashboard', async (req, res) => {
236
+ try {
237
+ const { getDashboard } = await import('../core/dashboard.js');
238
+ const dash = getDashboard();
239
+ const format = req.query.format;
240
+ if (format === 'text') {
241
+ res.type('text/plain').send(dash.getSummary());
242
+ } else {
243
+ res.json(dash.getHealth());
244
+ }
245
+ } catch (e) {
246
+ res.status(500).json({ error: e.message });
247
+ }
248
+ });
249
+
250
+ // Frontend Serve
251
+ app.get('*', (req, res) => {
252
+ if (req.path.startsWith('/api')) return res.status(404).json({ error: 'Not Found' });
253
+ res.sendFile(path.join(__dirname, 'public', 'index.html'));
254
+ });
255
+
256
+ // Start Server
257
+ app.listen(PORT, () => {
258
+ console.log(`\n🚀 Vantuz API Sunucusu: http://localhost:${PORT}`);
259
+ log('INFO', `Sunucu ${PORT} portunda başlatıldı`);
260
+ });