vantuz 3.4.1 → 3.5.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.
Files changed (70) hide show
  1. package/LICENSE +45 -45
  2. package/admin-keygen.js +51 -0
  3. package/cli.js +685 -585
  4. package/config.js +733 -733
  5. package/core/agent-loop.js +190 -190
  6. package/core/ai-provider.js +298 -261
  7. package/core/automation.js +523 -523
  8. package/core/brand-analyst.js +101 -0
  9. package/core/channels.js +167 -167
  10. package/core/dashboard.js +230 -230
  11. package/core/database.js +135 -36
  12. package/core/eia-monitor.js +3 -1
  13. package/core/engine.js +648 -636
  14. package/core/gateway.js +447 -447
  15. package/core/learning.js +214 -214
  16. package/core/license.js +113 -0
  17. package/core/marketplace-adapter.js +168 -168
  18. package/core/memory.js +190 -190
  19. package/core/migrations/001-initial-schema.sql +1 -1
  20. package/core/queue.js +120 -120
  21. package/core/self-healer.js +314 -314
  22. package/core/unified-product.js +214 -214
  23. package/core/vision-service.js +113 -113
  24. package/index.js +217 -174
  25. package/modules/crm/sentiment-crm.js +231 -231
  26. package/modules/healer/listing-healer.js +201 -201
  27. package/modules/oracle/predictor.js +214 -214
  28. package/modules/researcher/agent.js +169 -169
  29. package/modules/team/agents/base.js +92 -92
  30. package/modules/team/agents/dev.js +33 -33
  31. package/modules/team/agents/josh.js +40 -40
  32. package/modules/team/agents/marketing.js +33 -33
  33. package/modules/team/agents/milo.js +36 -36
  34. package/modules/team/index.js +78 -78
  35. package/modules/team/shared-memory.js +87 -87
  36. package/modules/war-room/competitor-tracker.js +250 -250
  37. package/modules/war-room/pricing-engine.js +308 -308
  38. package/nodes/warehouse.js +238 -238
  39. package/onboard.js +1 -1
  40. package/package.json +7 -6
  41. package/platforms/pttavm.js +14 -14
  42. package/plugins/vantuz/index.js +528 -528
  43. package/plugins/vantuz/memory/hippocampus.js +465 -464
  44. package/plugins/vantuz/package.json +20 -20
  45. package/plugins/vantuz/platforms/_template.js +118 -118
  46. package/plugins/vantuz/platforms/amazon.js +236 -236
  47. package/plugins/vantuz/platforms/ciceksepeti.js +166 -166
  48. package/plugins/vantuz/platforms/hepsiburada.js +180 -180
  49. package/plugins/vantuz/platforms/index.js +165 -165
  50. package/plugins/vantuz/platforms/n11.js +229 -229
  51. package/plugins/vantuz/platforms/pazarama.js +154 -154
  52. package/plugins/vantuz/platforms/pttavm.js +127 -127
  53. package/plugins/vantuz/platforms/trendyol.js +326 -326
  54. package/plugins/vantuz/services/alerts.js +253 -253
  55. package/plugins/vantuz/services/license.js +34 -34
  56. package/plugins/vantuz/services/scheduler.js +232 -232
  57. package/plugins/vantuz/tools/analytics.js +152 -152
  58. package/plugins/vantuz/tools/crossborder.js +187 -187
  59. package/plugins/vantuz/tools/nl-parser.js +211 -211
  60. package/plugins/vantuz/tools/product.js +110 -110
  61. package/plugins/vantuz/tools/quick-report.js +175 -175
  62. package/plugins/vantuz/tools/repricer.js +314 -314
  63. package/plugins/vantuz/tools/sentiment.js +115 -115
  64. package/plugins/vantuz/tools/vision.js +257 -257
  65. package/private.pem +28 -0
  66. package/public.pem +9 -0
  67. package/server/app.js +260 -260
  68. package/server/public/index.html +514 -514
  69. package/start.bat +33 -33
  70. package/vantuz.sqlite +0 -0
@@ -1,201 +1,201 @@
1
- // modules/healer/listing-healer.js
2
- // Self-Healing Listings for Vantuz OS V2
3
- // Audits product listings and optimizes underperforming ones.
4
-
5
- import { log } from '../../core/ai-provider.js';
6
-
7
- // ═══════════════════════════════════════════════════════════════════════════
8
- // LISTING HEALTH CHECKS
9
- // ═══════════════════════════════════════════════════════════════════════════
10
-
11
- const HEALTH_RULES = [
12
- {
13
- name: 'short_title',
14
- check: (p) => (p.title || '').length < 40,
15
- severity: 'warning',
16
- message: 'Başlık çok kısa — SEO performansı düşük',
17
- fix: 'title_optimization'
18
- },
19
- {
20
- name: 'no_images',
21
- check: (p) => !p.images || p.images.length === 0,
22
- severity: 'critical',
23
- message: 'Ürün görseli yok — satış ihtimali çok düşük',
24
- fix: 'add_images'
25
- },
26
- {
27
- name: 'few_images',
28
- check: (p) => p.images && p.images.length > 0 && p.images.length < 3,
29
- severity: 'warning',
30
- message: 'Görsel sayısı az — en az 3 görsel önerilir',
31
- fix: 'add_images'
32
- },
33
- {
34
- name: 'no_brand',
35
- check: (p) => !p.brand || p.brand.trim() === '',
36
- severity: 'info',
37
- message: 'Marka belirtilmemiş',
38
- fix: 'add_brand'
39
- },
40
- {
41
- name: 'zero_stock',
42
- check: (p) => p.stock === 0 && p.onSale,
43
- severity: 'critical',
44
- message: 'Stok sıfır ama satışta — phantom listing',
45
- fix: 'deactivate_or_restock'
46
- },
47
- {
48
- name: 'turkish_chars_missing',
49
- check: (p) => {
50
- const title = p.title || '';
51
- // Titles with Turkish words but no Turkish chars might be poorly optimized
52
- const hasTurkish = /[çğıöşüÇĞİÖŞÜ]/.test(title);
53
- const looksLatin = /^[a-zA-Z0-9\s\-\+\.\,\/\(\)]+$/.test(title);
54
- return looksLatin && title.length > 20; // Might be missing Turkish chars
55
- },
56
- severity: 'info',
57
- message: 'Başlıkta Türkçe karakter yok — arama sıralaması düşebilir',
58
- fix: 'title_optimization'
59
- },
60
- {
61
- name: 'high_price_no_sales',
62
- check: (p) => p.salesVelocity === 0 && p.margin > 40,
63
- severity: 'warning',
64
- message: 'Yüksek marj ama sıfır satış — fiyat çok yüksek olabilir',
65
- fix: 'price_review'
66
- }
67
- ];
68
-
69
- // ═══════════════════════════════════════════════════════════════════════════
70
- // LISTING HEALER
71
- // ═══════════════════════════════════════════════════════════════════════════
72
-
73
- class ListingHealer {
74
- constructor() {
75
- this.auditResults = [];
76
- log('INFO', 'ListingHealer initialized');
77
- }
78
-
79
- /**
80
- * Audit a single product listing.
81
- * @param {object} product - Unified product from catalog.
82
- * @returns {{ barcode, issues: array, score: number }}
83
- */
84
- audit(product) {
85
- const issues = [];
86
-
87
- for (const rule of HEALTH_RULES) {
88
- try {
89
- if (rule.check(product)) {
90
- issues.push({
91
- rule: rule.name,
92
- severity: rule.severity,
93
- message: rule.message,
94
- suggestedFix: rule.fix
95
- });
96
- }
97
- } catch (e) {
98
- // Rule check error — skip silently
99
- }
100
- }
101
-
102
- // Health score: 100 = perfect
103
- const penalties = {
104
- critical: 30,
105
- warning: 15,
106
- info: 5
107
- };
108
- const totalPenalty = issues.reduce((sum, i) => sum + (penalties[i.severity] || 0), 0);
109
- const score = Math.max(0, 100 - totalPenalty);
110
-
111
- return {
112
- barcode: product.barcode || product.sku,
113
- title: product.title,
114
- score,
115
- issues,
116
- auditedAt: new Date().toISOString()
117
- };
118
- }
119
-
120
- /**
121
- * Audit all products in the catalog.
122
- * @param {object[]} products - Array of unified products.
123
- * @returns {{ healthy, warning, critical, results }}
124
- */
125
- auditAll(products) {
126
- const results = products.map(p => this.audit(p));
127
-
128
- const healthy = results.filter(r => r.score >= 80).length;
129
- const warning = results.filter(r => r.score >= 50 && r.score < 80).length;
130
- const critical = results.filter(r => r.score < 50).length;
131
-
132
- // Sort by worst first
133
- results.sort((a, b) => a.score - b.score);
134
-
135
- this.auditResults = results;
136
-
137
- const report = {
138
- total: results.length,
139
- healthy,
140
- warning,
141
- critical,
142
- avgScore: results.length > 0
143
- ? Math.round(results.reduce((s, r) => s + r.score, 0) / results.length)
144
- : 0,
145
- worstListings: results.slice(0, 10), // Top 10 worst
146
- auditedAt: new Date().toISOString()
147
- };
148
-
149
- log('INFO', 'Listing audit complete', {
150
- total: report.total,
151
- healthy,
152
- warning,
153
- critical,
154
- avgScore: report.avgScore
155
- });
156
-
157
- return report;
158
- }
159
-
160
- /**
161
- * Generate AI-powered title suggestions for a product.
162
- * @param {object} product - Unified product.
163
- * @param {function} aiChat - AI chat function for generating suggestions.
164
- * @returns {string} Suggested title.
165
- */
166
- async suggestTitle(product, aiChat) {
167
- if (!aiChat) return product.title;
168
-
169
- const prompt = `Şu ürün başlığını SEO için optimize et. Türkçe arama trendlerine uygun olsun. Mevcut: "${product.title}". Kategori: ${product.category || 'bilinmiyor'}. Sadece optimize edilmiş başlığı yaz, başka bir şey yazma.`;
170
-
171
- try {
172
- const response = await aiChat(prompt);
173
- return response.trim();
174
- } catch (e) {
175
- log('WARN', 'Title suggestion failed', { error: e.message });
176
- return product.title;
177
- }
178
- }
179
-
180
- getStatus() {
181
- const results = this.auditResults;
182
- return {
183
- lastAuditSize: results.length,
184
- avgScore: results.length > 0
185
- ? Math.round(results.reduce((s, r) => s + r.score, 0) / results.length)
186
- : 0,
187
- criticalCount: results.filter(r => r.score < 50).length
188
- };
189
- }
190
- }
191
-
192
- let healerInstance = null;
193
-
194
- export function getListingHealer() {
195
- if (!healerInstance) {
196
- healerInstance = new ListingHealer();
197
- }
198
- return healerInstance;
199
- }
200
-
201
- export default ListingHealer;
1
+ // modules/healer/listing-healer.js
2
+ // Self-Healing Listings for Vantuz OS V2
3
+ // Audits product listings and optimizes underperforming ones.
4
+
5
+ import { log } from '../../core/ai-provider.js';
6
+
7
+ // ═══════════════════════════════════════════════════════════════════════════
8
+ // LISTING HEALTH CHECKS
9
+ // ═══════════════════════════════════════════════════════════════════════════
10
+
11
+ const HEALTH_RULES = [
12
+ {
13
+ name: 'short_title',
14
+ check: (p) => (p.title || '').length < 40,
15
+ severity: 'warning',
16
+ message: 'Başlık çok kısa — SEO performansı düşük',
17
+ fix: 'title_optimization'
18
+ },
19
+ {
20
+ name: 'no_images',
21
+ check: (p) => !p.images || p.images.length === 0,
22
+ severity: 'critical',
23
+ message: 'Ürün görseli yok — satış ihtimali çok düşük',
24
+ fix: 'add_images'
25
+ },
26
+ {
27
+ name: 'few_images',
28
+ check: (p) => p.images && p.images.length > 0 && p.images.length < 3,
29
+ severity: 'warning',
30
+ message: 'Görsel sayısı az — en az 3 görsel önerilir',
31
+ fix: 'add_images'
32
+ },
33
+ {
34
+ name: 'no_brand',
35
+ check: (p) => !p.brand || p.brand.trim() === '',
36
+ severity: 'info',
37
+ message: 'Marka belirtilmemiş',
38
+ fix: 'add_brand'
39
+ },
40
+ {
41
+ name: 'zero_stock',
42
+ check: (p) => p.stock === 0 && p.onSale,
43
+ severity: 'critical',
44
+ message: 'Stok sıfır ama satışta — phantom listing',
45
+ fix: 'deactivate_or_restock'
46
+ },
47
+ {
48
+ name: 'turkish_chars_missing',
49
+ check: (p) => {
50
+ const title = p.title || '';
51
+ // Titles with Turkish words but no Turkish chars might be poorly optimized
52
+ const hasTurkish = /[çğıöşüÇĞİÖŞÜ]/.test(title);
53
+ const looksLatin = /^[a-zA-Z0-9\s\-\+\.\,\/\(\)]+$/.test(title);
54
+ return looksLatin && title.length > 20; // Might be missing Turkish chars
55
+ },
56
+ severity: 'info',
57
+ message: 'Başlıkta Türkçe karakter yok — arama sıralaması düşebilir',
58
+ fix: 'title_optimization'
59
+ },
60
+ {
61
+ name: 'high_price_no_sales',
62
+ check: (p) => p.salesVelocity === 0 && p.margin > 40,
63
+ severity: 'warning',
64
+ message: 'Yüksek marj ama sıfır satış — fiyat çok yüksek olabilir',
65
+ fix: 'price_review'
66
+ }
67
+ ];
68
+
69
+ // ═══════════════════════════════════════════════════════════════════════════
70
+ // LISTING HEALER
71
+ // ═══════════════════════════════════════════════════════════════════════════
72
+
73
+ class ListingHealer {
74
+ constructor() {
75
+ this.auditResults = [];
76
+ log('INFO', 'ListingHealer initialized');
77
+ }
78
+
79
+ /**
80
+ * Audit a single product listing.
81
+ * @param {object} product - Unified product from catalog.
82
+ * @returns {{ barcode, issues: array, score: number }}
83
+ */
84
+ audit(product) {
85
+ const issues = [];
86
+
87
+ for (const rule of HEALTH_RULES) {
88
+ try {
89
+ if (rule.check(product)) {
90
+ issues.push({
91
+ rule: rule.name,
92
+ severity: rule.severity,
93
+ message: rule.message,
94
+ suggestedFix: rule.fix
95
+ });
96
+ }
97
+ } catch (e) {
98
+ // Rule check error — skip silently
99
+ }
100
+ }
101
+
102
+ // Health score: 100 = perfect
103
+ const penalties = {
104
+ critical: 30,
105
+ warning: 15,
106
+ info: 5
107
+ };
108
+ const totalPenalty = issues.reduce((sum, i) => sum + (penalties[i.severity] || 0), 0);
109
+ const score = Math.max(0, 100 - totalPenalty);
110
+
111
+ return {
112
+ barcode: product.barcode || product.sku,
113
+ title: product.title,
114
+ score,
115
+ issues,
116
+ auditedAt: new Date().toISOString()
117
+ };
118
+ }
119
+
120
+ /**
121
+ * Audit all products in the catalog.
122
+ * @param {object[]} products - Array of unified products.
123
+ * @returns {{ healthy, warning, critical, results }}
124
+ */
125
+ auditAll(products) {
126
+ const results = products.map(p => this.audit(p));
127
+
128
+ const healthy = results.filter(r => r.score >= 80).length;
129
+ const warning = results.filter(r => r.score >= 50 && r.score < 80).length;
130
+ const critical = results.filter(r => r.score < 50).length;
131
+
132
+ // Sort by worst first
133
+ results.sort((a, b) => a.score - b.score);
134
+
135
+ this.auditResults = results;
136
+
137
+ const report = {
138
+ total: results.length,
139
+ healthy,
140
+ warning,
141
+ critical,
142
+ avgScore: results.length > 0
143
+ ? Math.round(results.reduce((s, r) => s + r.score, 0) / results.length)
144
+ : 0,
145
+ worstListings: results.slice(0, 10), // Top 10 worst
146
+ auditedAt: new Date().toISOString()
147
+ };
148
+
149
+ log('INFO', 'Listing audit complete', {
150
+ total: report.total,
151
+ healthy,
152
+ warning,
153
+ critical,
154
+ avgScore: report.avgScore
155
+ });
156
+
157
+ return report;
158
+ }
159
+
160
+ /**
161
+ * Generate AI-powered title suggestions for a product.
162
+ * @param {object} product - Unified product.
163
+ * @param {function} aiChat - AI chat function for generating suggestions.
164
+ * @returns {string} Suggested title.
165
+ */
166
+ async suggestTitle(product, aiChat) {
167
+ if (!aiChat) return product.title;
168
+
169
+ const prompt = `Şu ürün başlığını SEO için optimize et. Türkçe arama trendlerine uygun olsun. Mevcut: "${product.title}". Kategori: ${product.category || 'bilinmiyor'}. Sadece optimize edilmiş başlığı yaz, başka bir şey yazma.`;
170
+
171
+ try {
172
+ const response = await aiChat(prompt);
173
+ return response.trim();
174
+ } catch (e) {
175
+ log('WARN', 'Title suggestion failed', { error: e.message });
176
+ return product.title;
177
+ }
178
+ }
179
+
180
+ getStatus() {
181
+ const results = this.auditResults;
182
+ return {
183
+ lastAuditSize: results.length,
184
+ avgScore: results.length > 0
185
+ ? Math.round(results.reduce((s, r) => s + r.score, 0) / results.length)
186
+ : 0,
187
+ criticalCount: results.filter(r => r.score < 50).length
188
+ };
189
+ }
190
+ }
191
+
192
+ let healerInstance = null;
193
+
194
+ export function getListingHealer() {
195
+ if (!healerInstance) {
196
+ healerInstance = new ListingHealer();
197
+ }
198
+ return healerInstance;
199
+ }
200
+
201
+ export default ListingHealer;