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
@@ -1,35 +1,35 @@
1
- /**
2
- * 🟡 AMAZON SP-API Entegrasyonu
3
- * developer-docs.amazon.com/sp-api
4
- */
5
-
1
+ /**
2
+ * 🟡 AMAZON SP-API Entegrasyonu
3
+ * developer-docs.amazon.com/sp-api
4
+ */
5
+
6
6
  import axios from 'axios';
7
7
  import crypto from 'crypto';
8
8
  import { requestWithRetry } from './_request.js';
9
-
10
- const REGIONS = {
11
- eu: {
12
- endpoint: 'https://sellingpartnerapi-eu.amazon.com',
13
- marketplace: 'A1PA6795UKMFR9' // DE
14
- },
15
- na: {
16
- endpoint: 'https://sellingpartnerapi-na.amazon.com',
17
- marketplace: 'ATVPDKIKX0DER' // US
18
- },
19
- tr: {
20
- endpoint: 'https://sellingpartnerapi-eu.amazon.com',
21
- marketplace: 'A33AVAJ2PDY3EV' // TR
22
- }
23
- };
24
-
25
- export class AmazonAPI {
26
- constructor(config) {
27
- this.region = config.region || 'eu';
28
- this.sellerId = config.sellerId;
29
- this.clientId = config.clientId;
30
- this.clientSecret = config.clientSecret;
31
- this.refreshToken = config.refreshToken;
32
-
9
+
10
+ const REGIONS = {
11
+ eu: {
12
+ endpoint: 'https://sellingpartnerapi-eu.amazon.com',
13
+ marketplace: 'A1PA6795UKMFR9' // DE
14
+ },
15
+ na: {
16
+ endpoint: 'https://sellingpartnerapi-na.amazon.com',
17
+ marketplace: 'ATVPDKIKX0DER' // US
18
+ },
19
+ tr: {
20
+ endpoint: 'https://sellingpartnerapi-eu.amazon.com',
21
+ marketplace: 'A33AVAJ2PDY3EV' // TR
22
+ }
23
+ };
24
+
25
+ export class AmazonAPI {
26
+ constructor(config) {
27
+ this.region = config.region || 'eu';
28
+ this.sellerId = config.sellerId;
29
+ this.clientId = config.clientId;
30
+ this.clientSecret = config.clientSecret;
31
+ this.refreshToken = config.refreshToken;
32
+
33
33
  this.regionConfig = REGIONS[this.region];
34
34
  this.accessToken = null;
35
35
  this.tokenExpiry = null;
@@ -37,46 +37,46 @@ export class AmazonAPI {
37
37
  }
38
38
 
39
39
  async _getAccessToken() {
40
- if (this.accessToken && this.tokenExpiry > Date.now()) {
41
- return this.accessToken;
42
- }
43
- if (this._tokenPromise) {
44
- return await this._tokenPromise;
45
- }
46
-
47
- this._tokenPromise = (async () => {
48
- try {
49
- const response = await requestWithRetry(axios, {
50
- method: 'POST',
51
- url: 'https://api.amazon.com/auth/o2/token',
52
- data: {
53
- grant_type: 'refresh_token',
54
- refresh_token: this.refreshToken,
55
- client_id: this.clientId,
56
- client_secret: this.clientSecret
57
- }
58
- }, {
59
- retries: 3,
60
- baseDelayMs: 500,
61
- maxDelayMs: 4000
62
- });
63
-
64
- this.accessToken = response.data.access_token;
65
- this.tokenExpiry = Date.now() + (response.data.expires_in * 1000) - 60000;
66
- return this.accessToken;
67
- } catch (error) {
68
- throw new Error('Token alınamadı: ' + error.message);
69
- } finally {
70
- this._tokenPromise = null;
71
- }
72
- })();
73
-
74
- return await this._tokenPromise;
75
- }
76
-
77
- async _request(method, path, data = null, params = null) {
78
- try {
79
- const token = await this._getAccessToken();
40
+ if (this.accessToken && this.tokenExpiry > Date.now()) {
41
+ return this.accessToken;
42
+ }
43
+ if (this._tokenPromise) {
44
+ return await this._tokenPromise;
45
+ }
46
+
47
+ this._tokenPromise = (async () => {
48
+ try {
49
+ const response = await requestWithRetry(axios, {
50
+ method: 'POST',
51
+ url: 'https://api.amazon.com/auth/o2/token',
52
+ data: {
53
+ grant_type: 'refresh_token',
54
+ refresh_token: this.refreshToken,
55
+ client_id: this.clientId,
56
+ client_secret: this.clientSecret
57
+ }
58
+ }, {
59
+ retries: 3,
60
+ baseDelayMs: 500,
61
+ maxDelayMs: 4000
62
+ });
63
+
64
+ this.accessToken = response.data.access_token;
65
+ this.tokenExpiry = Date.now() + (response.data.expires_in * 1000) - 60000;
66
+ return this.accessToken;
67
+ } catch (error) {
68
+ throw new Error('Token alınamadı: ' + error.message);
69
+ } finally {
70
+ this._tokenPromise = null;
71
+ }
72
+ })();
73
+
74
+ return await this._tokenPromise;
75
+ }
76
+
77
+ async _request(method, path, data = null, params = null) {
78
+ try {
79
+ const token = await this._getAccessToken();
80
80
  const response = await requestWithRetry(axios, {
81
81
  method,
82
82
  url: `${this.regionConfig.endpoint}${path}`,
@@ -94,170 +94,170 @@ export class AmazonAPI {
94
94
  baseDelayMs: 500,
95
95
  maxDelayMs: 4000
96
96
  });
97
- return { success: true, data: response.data };
98
- } catch (error) {
99
- return {
100
- success: false,
101
- error: error.response?.data?.errors || error.message
102
- };
103
- }
104
- }
105
-
106
- // ═══════════════════════════════════════════════════════════════════════════
107
- // ÜRÜN İŞLEMLERİ
108
- // ═══════════════════════════════════════════════════════════════════════════
109
-
110
- async getInventory(params = {}) {
111
- const { nextToken, skus } = params;
112
- return await this._request('GET', '/fba/inventory/v1/summaries', null, {
113
- details: true,
114
- granularityType: 'Marketplace',
115
- granularityId: this.regionConfig.marketplace,
116
- sellerSkus: skus?.join(','),
117
- nextToken
118
- });
119
- }
120
-
121
- async getCatalogItem(asin) {
122
- return await this._request('GET', `/catalog/2022-04-01/items/${asin}`, null, {
123
- includedData: 'summaries,attributes,images,productTypes,salesRanks'
124
- });
125
- }
126
-
127
- async searchCatalog(keywords) {
128
- return await this._request('GET', '/catalog/2022-04-01/items', null, {
129
- keywords,
130
- includedData: 'summaries,images'
131
- });
132
- }
133
-
134
- async createListing(sku, productType, attributes) {
135
- return await this._request('PUT', `/listings/2021-08-01/items/${this.sellerId}/${sku}`, {
136
- productType,
137
- attributes,
138
- requirements: 'LISTING'
139
- });
140
- }
141
-
142
- // ═══════════════════════════════════════════════════════════════════════════
143
- // FİYAT
144
- // ═══════════════════════════════════════════════════════════════════════════
145
-
146
- async getPricing(skus) {
147
- return await this._request('GET', '/products/pricing/v0/price', null, {
148
- ItemType: 'Sku',
149
- Skus: skus.join(',')
150
- });
151
- }
152
-
153
- async getCompetitivePricing(asins) {
154
- return await this._request('GET', '/products/pricing/v0/competitivePrice', null, {
155
- ItemType: 'Asin',
156
- Asins: asins.join(',')
157
- });
158
- }
159
-
160
- async updatePrice(sku, price, currency = 'EUR') {
161
- // SP-API için feed sistemi gerekir - basitleştirilmiş örnek
162
- const feed = {
163
- header: { sellerId: this.sellerId, version: '2.0' },
164
- messages: [{
165
- messageId: 1,
166
- sku,
167
- operationType: 'PARTIAL_UPDATE',
168
- productType: 'PRODUCT',
169
- attributes: {
170
- purchasable_offer: [{
171
- our_price: [{ schedule: [{ value_with_tax: price }] }],
172
- currency
173
- }]
174
- }
175
- }]
176
- };
177
- return await this._request('POST', '/feeds/2021-06-30/feeds', {
178
- feedType: 'JSON_LISTINGS_FEED',
179
- marketplaceIds: [this.regionConfig.marketplace]
180
- });
181
- }
182
-
183
- // ═══════════════════════════════════════════════════════════════════════════
184
- // SİPARİŞ
185
- // ═══════════════════════════════════════════════════════════════════════════
186
-
187
- async getOrders(params = {}) {
188
- const { createdAfter, orderStatuses, nextToken } = params;
189
- return await this._request('GET', '/orders/v0/orders', null, {
190
- CreatedAfter: createdAfter || new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(),
191
- OrderStatuses: orderStatuses?.join(','),
192
- NextToken: nextToken
193
- });
194
- }
195
-
196
- async getOrderItems(orderId) {
197
- return await this._request('GET', `/orders/v0/orders/${orderId}/orderItems`);
198
- }
199
-
200
- async confirmShipment(orderId, items) {
201
- return await this._request('POST', `/orders/v0/orders/${orderId}/shipmentConfirmation`, {
202
- packageDetail: {
203
- packageReferenceId: `pkg-${Date.now()}`,
204
- carrierCode: 'OTHER',
205
- shippingMethod: 'Standard',
206
- trackingNumber: items.trackingNumber,
207
- shipFromSupplySourceId: this.sellerId
208
- },
209
- codCollectionMethod: 'DirectPayment',
210
- marketplaceId: this.regionConfig.marketplace
211
- });
212
- }
213
-
214
- // ═══════════════════════════════════════════════════════════════════════════
215
- // FBA
216
- // ═══════════════════════════════════════════════════════════════════════════
217
-
218
- async getFbaInventory(params = {}) {
219
- return await this._request('GET', '/fba/inventory/v1/summaries', null, {
220
- details: true,
221
- granularityType: 'Marketplace',
222
- granularityId: this.regionConfig.marketplace,
223
- ...params
224
- });
225
- }
226
-
227
- async getInboundShipments(params = {}) {
228
- return await this._request('GET', '/fba/inbound/v0/shipments', null, params);
229
- }
230
-
231
- // ═══════════════════════════════════════════════════════════════════════════
232
- // HELPER
233
- // ═══════════════════════════════════════════════════════════════════════════
234
-
235
- async testConnection() {
236
- try {
237
- await this._getAccessToken();
238
- return true;
239
- } catch {
240
- return false;
241
- }
242
- }
243
-
244
- isConnected() {
245
- return !!(this.sellerId && this.clientId && this.refreshToken);
246
- }
247
- }
248
-
249
- let instances = {};
250
-
251
- export const amazonApi = {
252
- init(config, region = 'eu') {
253
- instances[region] = new AmazonAPI({ ...config, region });
254
- return instances[region];
255
- },
256
- getInstance(region = 'eu') { return instances[region]; },
257
- isConnected(region = 'eu') { return instances[region]?.isConnected() || false; },
258
-
259
- async getProducts(params, region) { return instances[region]?.getInventory(params); },
260
- async updatePrice(sku, price, region) { return instances[region]?.updatePrice(sku, price); },
261
- async getOrders(params, region) { return instances[region]?.getOrders(params); }
262
- };
263
-
97
+ return { success: true, data: response.data };
98
+ } catch (error) {
99
+ return {
100
+ success: false,
101
+ error: error.response?.data?.errors || error.message
102
+ };
103
+ }
104
+ }
105
+
106
+ // ═══════════════════════════════════════════════════════════════════════════
107
+ // ÜRÜN İŞLEMLERİ
108
+ // ═══════════════════════════════════════════════════════════════════════════
109
+
110
+ async getInventory(params = {}) {
111
+ const { nextToken, skus } = params;
112
+ return await this._request('GET', '/fba/inventory/v1/summaries', null, {
113
+ details: true,
114
+ granularityType: 'Marketplace',
115
+ granularityId: this.regionConfig.marketplace,
116
+ sellerSkus: skus?.join(','),
117
+ nextToken
118
+ });
119
+ }
120
+
121
+ async getCatalogItem(asin) {
122
+ return await this._request('GET', `/catalog/2022-04-01/items/${asin}`, null, {
123
+ includedData: 'summaries,attributes,images,productTypes,salesRanks'
124
+ });
125
+ }
126
+
127
+ async searchCatalog(keywords) {
128
+ return await this._request('GET', '/catalog/2022-04-01/items', null, {
129
+ keywords,
130
+ includedData: 'summaries,images'
131
+ });
132
+ }
133
+
134
+ async createListing(sku, productType, attributes) {
135
+ return await this._request('PUT', `/listings/2021-08-01/items/${this.sellerId}/${sku}`, {
136
+ productType,
137
+ attributes,
138
+ requirements: 'LISTING'
139
+ });
140
+ }
141
+
142
+ // ═══════════════════════════════════════════════════════════════════════════
143
+ // FİYAT
144
+ // ═══════════════════════════════════════════════════════════════════════════
145
+
146
+ async getPricing(skus) {
147
+ return await this._request('GET', '/products/pricing/v0/price', null, {
148
+ ItemType: 'Sku',
149
+ Skus: skus.join(',')
150
+ });
151
+ }
152
+
153
+ async getCompetitivePricing(asins) {
154
+ return await this._request('GET', '/products/pricing/v0/competitivePrice', null, {
155
+ ItemType: 'Asin',
156
+ Asins: asins.join(',')
157
+ });
158
+ }
159
+
160
+ async updatePrice(sku, price, currency = 'EUR') {
161
+ // SP-API için feed sistemi gerekir - basitleştirilmiş örnek
162
+ const feed = {
163
+ header: { sellerId: this.sellerId, version: '2.0' },
164
+ messages: [{
165
+ messageId: 1,
166
+ sku,
167
+ operationType: 'PARTIAL_UPDATE',
168
+ productType: 'PRODUCT',
169
+ attributes: {
170
+ purchasable_offer: [{
171
+ our_price: [{ schedule: [{ value_with_tax: price }] }],
172
+ currency
173
+ }]
174
+ }
175
+ }]
176
+ };
177
+ return await this._request('POST', '/feeds/2021-06-30/feeds', {
178
+ feedType: 'JSON_LISTINGS_FEED',
179
+ marketplaceIds: [this.regionConfig.marketplace]
180
+ });
181
+ }
182
+
183
+ // ═══════════════════════════════════════════════════════════════════════════
184
+ // SİPARİŞ
185
+ // ═══════════════════════════════════════════════════════════════════════════
186
+
187
+ async getOrders(params = {}) {
188
+ const { createdAfter, orderStatuses, nextToken } = params;
189
+ return await this._request('GET', '/orders/v0/orders', null, {
190
+ CreatedAfter: createdAfter || new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(),
191
+ OrderStatuses: orderStatuses?.join(','),
192
+ NextToken: nextToken
193
+ });
194
+ }
195
+
196
+ async getOrderItems(orderId) {
197
+ return await this._request('GET', `/orders/v0/orders/${orderId}/orderItems`);
198
+ }
199
+
200
+ async confirmShipment(orderId, items) {
201
+ return await this._request('POST', `/orders/v0/orders/${orderId}/shipmentConfirmation`, {
202
+ packageDetail: {
203
+ packageReferenceId: `pkg-${Date.now()}`,
204
+ carrierCode: 'OTHER',
205
+ shippingMethod: 'Standard',
206
+ trackingNumber: items.trackingNumber,
207
+ shipFromSupplySourceId: this.sellerId
208
+ },
209
+ codCollectionMethod: 'DirectPayment',
210
+ marketplaceId: this.regionConfig.marketplace
211
+ });
212
+ }
213
+
214
+ // ═══════════════════════════════════════════════════════════════════════════
215
+ // FBA
216
+ // ═══════════════════════════════════════════════════════════════════════════
217
+
218
+ async getFbaInventory(params = {}) {
219
+ return await this._request('GET', '/fba/inventory/v1/summaries', null, {
220
+ details: true,
221
+ granularityType: 'Marketplace',
222
+ granularityId: this.regionConfig.marketplace,
223
+ ...params
224
+ });
225
+ }
226
+
227
+ async getInboundShipments(params = {}) {
228
+ return await this._request('GET', '/fba/inbound/v0/shipments', null, params);
229
+ }
230
+
231
+ // ═══════════════════════════════════════════════════════════════════════════
232
+ // HELPER
233
+ // ═══════════════════════════════════════════════════════════════════════════
234
+
235
+ async testConnection() {
236
+ try {
237
+ await this._getAccessToken();
238
+ return true;
239
+ } catch {
240
+ return false;
241
+ }
242
+ }
243
+
244
+ isConnected() {
245
+ return !!(this.sellerId && this.clientId && this.refreshToken);
246
+ }
247
+ }
248
+
249
+ let instances = {};
250
+
251
+ export const amazonApi = {
252
+ init(config, region = 'eu') {
253
+ instances[region] = new AmazonAPI({ ...config, region });
254
+ return instances[region];
255
+ },
256
+ getInstance(region = 'eu') { return instances[region]; },
257
+ isConnected(region = 'eu') { return instances[region]?.isConnected() || false; },
258
+
259
+ async getProducts(params, region) { return instances[region]?.getInventory(params); },
260
+ async updatePrice(sku, price, region) { return instances[region]?.updatePrice(sku, price); },
261
+ async getOrders(params, region) { return instances[region]?.getOrders(params); }
262
+ };
263
+