cdp-edge 2.2.2 → 2.2.4
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/README.md
CHANGED
|
@@ -103,8 +103,8 @@ Meu ecossistema opera como um Cérebro de Conversão Privado na borda. Quando um
|
|
|
103
103
|
|
|
104
104
|
### 🔧 Fix: `wrangler.toml` atualizado
|
|
105
105
|
- Todos os placeholders (`SEU_D1_DATABASE_ID`, `SEU_KV_NAMESPACE_ID`) substituídos pelos IDs reais da conta Cloudflare
|
|
106
|
-
- D1: `
|
|
107
|
-
- KV: `
|
|
106
|
+
- D1: `SEU_DATABASE_ID`
|
|
107
|
+
- KV: `SEU_KV_ID`
|
|
108
108
|
|
|
109
109
|
---
|
|
110
110
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_comment": "Fonte de verdade para versões dos agent files. Atualizar
|
|
3
|
-
"worker_version": "2.
|
|
4
|
-
"worker_hash_date": "2026-04-
|
|
2
|
+
"_comment": "Fonte de verdade para versões dos agent files. Atualizar quando modules/ ou index.js mudarem. Use scripts/validate-agents.js para detectar drifts.",
|
|
3
|
+
"worker_version": "2.2.3",
|
|
4
|
+
"worker_hash_date": "2026-04-11",
|
|
5
5
|
"agents": {
|
|
6
6
|
"master-orchestrator": {
|
|
7
7
|
"version": "2.0.7",
|
|
8
8
|
"last_synced": "2026-04-10",
|
|
9
9
|
"depends_on": [
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
10
|
+
"index.js:fetch",
|
|
11
|
+
"index.js:endpoints",
|
|
12
|
+
"modules/utils.js:VALID_EVENT_NAMES"
|
|
13
13
|
],
|
|
14
14
|
"critical_sections": [
|
|
15
15
|
"endpoints",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"version": "2.0.7",
|
|
24
24
|
"last_synced": "2026-04-10",
|
|
25
25
|
"depends_on": [
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
26
|
+
"index.js:fetch",
|
|
27
|
+
"modules/db.js:saveLead",
|
|
28
|
+
"modules/db.js:upsertProfile",
|
|
29
|
+
"index.js:bindings"
|
|
30
30
|
],
|
|
31
31
|
"critical_sections": [
|
|
32
32
|
"endpoint /track",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"version": "2.0.7",
|
|
41
41
|
"last_synced": "2026-04-10",
|
|
42
42
|
"depends_on": [
|
|
43
|
-
"
|
|
43
|
+
"modules/dispatch/meta.js:sendMetaCapi",
|
|
44
44
|
"contracts/api-versions.json:meta"
|
|
45
45
|
],
|
|
46
46
|
"critical_sections": [
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"version": "2.0.7",
|
|
55
55
|
"last_synced": "2026-04-10",
|
|
56
56
|
"depends_on": [
|
|
57
|
-
"
|
|
57
|
+
"modules/dispatch/ga4.js:sendGA4Mp",
|
|
58
58
|
"contracts/api-versions.json:google"
|
|
59
59
|
],
|
|
60
60
|
"critical_sections": [
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"version": "2.0.7",
|
|
68
68
|
"last_synced": "2026-04-10",
|
|
69
69
|
"depends_on": [
|
|
70
|
-
"
|
|
70
|
+
"modules/dispatch/tiktok.js:sendTikTokApi",
|
|
71
71
|
"contracts/api-versions.json:tiktok"
|
|
72
72
|
],
|
|
73
73
|
"critical_sections": [
|
|
@@ -93,8 +93,8 @@
|
|
|
93
93
|
"version": "2.0.7",
|
|
94
94
|
"last_synced": "2026-04-10",
|
|
95
95
|
"depends_on": [
|
|
96
|
-
"
|
|
97
|
-
"
|
|
96
|
+
"modules/dispatch/whatsapp.js:sendWhatsApp",
|
|
97
|
+
"modules/dispatch/whatsapp.js:processWhatsAppWebhook"
|
|
98
98
|
],
|
|
99
99
|
"critical_sections": [
|
|
100
100
|
"WHATSAPP_ACCESS_TOKEN",
|
|
@@ -107,8 +107,7 @@
|
|
|
107
107
|
"version": "2.0.7",
|
|
108
108
|
"last_synced": "2026-04-10",
|
|
109
109
|
"depends_on": [
|
|
110
|
-
"
|
|
111
|
-
"worker.js:checkApiVersionsIntelligence"
|
|
110
|
+
"modules/intelligence.js:runIntelligenceAgent"
|
|
112
111
|
],
|
|
113
112
|
"critical_sections": [
|
|
114
113
|
"cron schedule",
|
|
@@ -121,8 +120,8 @@
|
|
|
121
120
|
"version": "2.0.7",
|
|
122
121
|
"last_synced": "2026-04-10",
|
|
123
122
|
"depends_on": [
|
|
124
|
-
"
|
|
125
|
-
"
|
|
123
|
+
"modules/ml/fraud.js:checkFraudGate",
|
|
124
|
+
"modules/ml/fraud.js:handleFraudAlerts",
|
|
126
125
|
"schema-fraud.sql"
|
|
127
126
|
],
|
|
128
127
|
"critical_sections": [
|
|
@@ -136,7 +135,7 @@
|
|
|
136
135
|
"version": "2.0.7",
|
|
137
136
|
"last_synced": "2026-04-10",
|
|
138
137
|
"depends_on": [
|
|
139
|
-
"
|
|
138
|
+
"modules/ml/segmentation.js:handleSegmentationCluster",
|
|
140
139
|
"schema-segmentation.sql"
|
|
141
140
|
],
|
|
142
141
|
"critical_sections": [
|
|
@@ -150,7 +149,7 @@
|
|
|
150
149
|
"version": "2.0.7",
|
|
151
150
|
"last_synced": "2026-04-10",
|
|
152
151
|
"depends_on": [
|
|
153
|
-
"
|
|
152
|
+
"modules/ml/bidding.js:handleBiddingRecommend",
|
|
154
153
|
"schema-bidding.sql"
|
|
155
154
|
],
|
|
156
155
|
"critical_sections": [
|
|
@@ -163,8 +162,8 @@
|
|
|
163
162
|
"version": "2.0.7",
|
|
164
163
|
"last_synced": "2026-04-10",
|
|
165
164
|
"depends_on": [
|
|
166
|
-
"
|
|
167
|
-
"
|
|
165
|
+
"modules/ml/ltv.js:predictLtv",
|
|
166
|
+
"modules/ml/ltv.js:getLtvAbVariation",
|
|
168
167
|
"schema-ab-ltv.sql"
|
|
169
168
|
],
|
|
170
169
|
"critical_sections": [
|
|
@@ -177,8 +176,8 @@
|
|
|
177
176
|
"version": "2.0.7",
|
|
178
177
|
"last_synced": "2026-04-10",
|
|
179
178
|
"depends_on": [
|
|
180
|
-
"
|
|
181
|
-
"
|
|
179
|
+
"modules/ml/fraud.js:checkFraudGate",
|
|
180
|
+
"modules/dispatch/whatsapp.js:verifyHmac"
|
|
182
181
|
],
|
|
183
182
|
"critical_sections": [
|
|
184
183
|
"env.DB.prepare",
|
|
@@ -191,9 +190,9 @@
|
|
|
191
190
|
"version": "2.0.7",
|
|
192
191
|
"last_synced": "2026-04-10",
|
|
193
192
|
"depends_on": [
|
|
194
|
-
"
|
|
195
|
-
"
|
|
196
|
-
"
|
|
193
|
+
"modules/db.js:saveLead",
|
|
194
|
+
"modules/dispatch/meta.js:sendMetaCapi",
|
|
195
|
+
"modules/dispatch/tiktok.js:sendTikTokApi"
|
|
197
196
|
],
|
|
198
197
|
"critical_sections": [
|
|
199
198
|
"env.DB.prepare",
|
|
@@ -225,7 +224,8 @@
|
|
|
225
224
|
"version": "2.0.7",
|
|
226
225
|
"last_synced": "2026-04-10",
|
|
227
226
|
"depends_on": [
|
|
228
|
-
"
|
|
227
|
+
"index.js",
|
|
228
|
+
"modules/",
|
|
229
229
|
"all agents"
|
|
230
230
|
],
|
|
231
231
|
"critical_sections": [
|
|
@@ -239,7 +239,7 @@
|
|
|
239
239
|
"version": "2.0.7",
|
|
240
240
|
"last_synced": "2026-04-10",
|
|
241
241
|
"depends_on": [
|
|
242
|
-
"
|
|
242
|
+
"modules/ml/ltv.js:predictLtv"
|
|
243
243
|
],
|
|
244
244
|
"critical_sections": [
|
|
245
245
|
"@cf/meta/llama-3.1-8b-instruct model name"
|
|
@@ -268,7 +268,7 @@
|
|
|
268
268
|
"version": "2.0.7",
|
|
269
269
|
"last_synced": "2026-04-10",
|
|
270
270
|
"depends_on": [
|
|
271
|
-
"
|
|
271
|
+
"index.js:GET /health"
|
|
272
272
|
],
|
|
273
273
|
"critical_sections": [
|
|
274
274
|
"env.DB.prepare",
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
"version": "2.0.7",
|
|
281
281
|
"last_synced": "2026-04-10",
|
|
282
282
|
"depends_on": [
|
|
283
|
-
"
|
|
283
|
+
"modules/intelligence.js:runIntelligenceAgent"
|
|
284
284
|
],
|
|
285
285
|
"critical_sections": [
|
|
286
286
|
"env.DB.prepare",
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
"version": "2.0.7",
|
|
306
306
|
"last_synced": "2026-04-10",
|
|
307
307
|
"depends_on": [
|
|
308
|
-
"
|
|
308
|
+
"index.js",
|
|
309
309
|
"all endpoints"
|
|
310
310
|
],
|
|
311
311
|
"critical_sections": [
|
|
@@ -319,8 +319,8 @@
|
|
|
319
319
|
"version": "2.0.7",
|
|
320
320
|
"last_synced": "2026-04-10",
|
|
321
321
|
"depends_on": [
|
|
322
|
-
"
|
|
323
|
-
"
|
|
322
|
+
"modules/db.js:saveLead",
|
|
323
|
+
"modules/db.js:upsertProfile"
|
|
324
324
|
],
|
|
325
325
|
"critical_sections": [
|
|
326
326
|
"env.DB.prepare",
|
|
@@ -332,7 +332,8 @@
|
|
|
332
332
|
"version": "2.0.7",
|
|
333
333
|
"last_synced": "2026-04-10",
|
|
334
334
|
"depends_on": [
|
|
335
|
-
"
|
|
335
|
+
"index.js",
|
|
336
|
+
"modules/"
|
|
336
337
|
],
|
|
337
338
|
"critical_sections": [
|
|
338
339
|
"env.GEO_CACHE (not env.CACHE_KV)"
|
|
@@ -353,12 +354,12 @@
|
|
|
353
354
|
}
|
|
354
355
|
},
|
|
355
356
|
"change_triggers": {
|
|
356
|
-
"
|
|
357
|
-
"
|
|
358
|
-
"
|
|
359
|
-
"
|
|
357
|
+
"index.js:addNewEndpoint": "Atualizar: master-orchestrator, server-tracking, browser-tracking, debug-agent, intelligence-agent",
|
|
358
|
+
"index.js:changeSecretName": "Atualizar: devops-agent, server-tracking, intelligence-agent, whatsapp-ctwa-setup-agent, database-agent",
|
|
359
|
+
"modules/utils.js:VALID_EVENT_NAMES": "Atualizar: master-orchestrator, youtube-agent, validator-agent, browser-tracking",
|
|
360
|
+
"modules/ml/ltv.js:changeAIModel": "Atualizar: ml-clustering-agent, ab-ltv-agent, ltv-predictor-agent",
|
|
360
361
|
"schema.sql:addTable": "Atualizar: database-agent (table count), devops-agent (migration order)",
|
|
361
362
|
"wrangler.toml:addBinding": "Atualizar: devops-agent, database-agent, debug-agent",
|
|
362
363
|
"contracts/api-versions.json:bumpVersion": "Atualizar: agent especialista + master-orchestrator"
|
|
363
364
|
}
|
|
364
|
-
}
|
|
365
|
+
}
|
package/dist/commands/server.js
CHANGED
|
@@ -13,7 +13,7 @@ export async function runServer(dir) {
|
|
|
13
13
|
const spinner = ora('Gerando infraestrutura...').start();
|
|
14
14
|
|
|
15
15
|
try {
|
|
16
|
-
// Gerar
|
|
16
|
+
// Gerar index.js
|
|
17
17
|
await generateWorker(dir);
|
|
18
18
|
|
|
19
19
|
// Gerar schema.sql
|
|
@@ -25,7 +25,7 @@ export async function runServer(dir) {
|
|
|
25
25
|
spinner.succeed(chalk.green('Infraestrutura gerada!'));
|
|
26
26
|
|
|
27
27
|
console.log('\n' + chalk.yellow('Arquivos gerados:'));
|
|
28
|
-
console.log(` ${chalk.gray('├─')}
|
|
28
|
+
console.log(` ${chalk.gray('├─')} index.js`);
|
|
29
29
|
console.log(` ${chalk.gray('├─')} schema.sql`);
|
|
30
30
|
console.log(` ${chalk.gray('└─')} wrangler.toml`);
|
|
31
31
|
|
|
@@ -44,7 +44,7 @@ export async function runServer(dir) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
async function generateWorker(dir) {
|
|
47
|
-
const workerPath = join(dir, '
|
|
47
|
+
const workerPath = join(dir, 'index.js');
|
|
48
48
|
await fs.writeFile(workerPath, generateWorkerCode());
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -163,7 +163,7 @@ function generateWranglerCode() {
|
|
|
163
163
|
# Auto-generated by cdp-edge npx
|
|
164
164
|
|
|
165
165
|
name = "cdp-edge-worker"
|
|
166
|
-
main = "
|
|
166
|
+
main = "index.js"
|
|
167
167
|
compatibility_date = "2024-01-01"
|
|
168
168
|
|
|
169
169
|
[[d1_databases]]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cdp-edge",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "CDP Edge - Quantum Tracking - Sistema multi-agente para tracking digital Cloudflare Native (Workers + D1)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,11 +23,12 @@
|
|
|
23
23
|
"build": "node build.js",
|
|
24
24
|
"dev": "node build.js --watch",
|
|
25
25
|
"test": "node test.js",
|
|
26
|
-
"test:unit": "node tests/unit/normalization.test.js && node tests/unit/hashing.test.js && node tests/unit/deduplication.test.js && node tests/unit/payload-validation.test.js && node tests/unit/new-features.test.js",
|
|
26
|
+
"test:unit": "node tests/unit/normalization.test.js && node tests/unit/hashing.test.js && node tests/unit/deduplication.test.js && node tests/unit/payload-validation.test.js && node tests/unit/new-features.test.js && node tests/unit/utils.test.js",
|
|
27
27
|
"test:unit:normalize": "node tests/unit/normalization.test.js",
|
|
28
28
|
"test:unit:hash": "node tests/unit/hashing.test.js",
|
|
29
29
|
"test:unit:dedup": "node tests/unit/deduplication.test.js",
|
|
30
30
|
"test:unit:payload": "node tests/unit/payload-validation.test.js",
|
|
31
|
+
"test:unit:utils": "node tests/unit/utils.test.js",
|
|
31
32
|
"test:all": "npm run test:unit",
|
|
32
33
|
"test:integration": "cd tests/integration && npx vitest run",
|
|
33
34
|
"agents:check": "node scripts/validate-agents.js",
|
|
@@ -298,7 +298,7 @@ wrangler d1 execute cdp-edge-db --remote --command="SELECT event_name, email, ci
|
|
|
298
298
|
```
|
|
299
299
|
ERROR: Can't deploy routes that are assigned to another worker.
|
|
300
300
|
"server-edge-tracker" is already assigned to routes:
|
|
301
|
-
-
|
|
301
|
+
- SEU_DOMINIO/track*
|
|
302
302
|
```
|
|
303
303
|
|
|
304
304
|
### SOLUÇÃO 1 — Via Painel Cloudflare (RECOMENDADO):
|
|
@@ -306,7 +306,7 @@ ERROR: Can't deploy routes that are assigned to another worker.
|
|
|
306
306
|
1. Acesse: https://dash.cloudflare.com/[ID_DA_CONTA]/workers/overview
|
|
307
307
|
2. Clique no worker que está usando as rotas do seu domínio
|
|
308
308
|
3. Vá em Settings → Triggers → Routes
|
|
309
|
-
4. Clique "Delete" nas rotas do domínio `
|
|
309
|
+
4. Clique "Delete" nas rotas do domínio `SEU_DOMINIO`
|
|
310
310
|
5. Repita o `wrangler deploy`
|
|
311
311
|
|
|
312
312
|
### SOLUÇÃO 2 — Via Wrangler CLI:
|
|
@@ -325,11 +325,11 @@ Se não quiser remover rotas existentes, use sufixo:
|
|
|
325
325
|
|
|
326
326
|
```toml
|
|
327
327
|
[[routes]]
|
|
328
|
-
pattern = "
|
|
329
|
-
zone_name = "
|
|
328
|
+
pattern = "SEU_DOMINIO/track-worker-novo*"
|
|
329
|
+
zone_name = "SEU_DOMINIO"
|
|
330
330
|
```
|
|
331
331
|
|
|
332
|
-
**URL do tracking:** `https://
|
|
332
|
+
**URL do tracking:** `https://SEU_DOMINIO/track-worker-novo`
|
|
333
333
|
|
|
334
334
|
---
|
|
335
335
|
|
|
@@ -17,19 +17,19 @@ workers_dev = true
|
|
|
17
17
|
# zone_name = "SEU_DOMINIO"
|
|
18
18
|
|
|
19
19
|
[[routes]]
|
|
20
|
-
pattern = "
|
|
21
|
-
zone_name = "
|
|
20
|
+
pattern = "SEU_DOMINIO/track*"
|
|
21
|
+
zone_name = "SEU_DOMINIO"
|
|
22
22
|
|
|
23
23
|
[[routes]]
|
|
24
|
-
pattern = "*.
|
|
25
|
-
zone_name = "
|
|
24
|
+
pattern = "*.SEU_DOMINIO/track*"
|
|
25
|
+
zone_name = "SEU_DOMINIO"
|
|
26
26
|
|
|
27
27
|
# ── Variáveis públicas (não são segredos) ─────────────────────────────────────
|
|
28
28
|
[vars]
|
|
29
|
-
META_PIXEL_ID = "
|
|
30
|
-
GA4_MEASUREMENT_ID = "
|
|
31
|
-
TIKTOK_PIXEL_ID = "
|
|
32
|
-
SITE_DOMAIN = "
|
|
29
|
+
META_PIXEL_ID = ""
|
|
30
|
+
GA4_MEASUREMENT_ID = ""
|
|
31
|
+
TIKTOK_PIXEL_ID = ""
|
|
32
|
+
SITE_DOMAIN = "SEU_DOMINIO"
|
|
33
33
|
|
|
34
34
|
# ── Banco D1 ──────────────────────────────────────────────────────────────────
|
|
35
35
|
# Após criar o banco com "wrangler d1 create cdp-edge-db",
|
|
@@ -37,7 +37,7 @@ SITE_DOMAIN = "lancamentosabc.com.br"
|
|
|
37
37
|
[[d1_databases]]
|
|
38
38
|
binding = "DB"
|
|
39
39
|
database_name = "cdp-edge-db"
|
|
40
|
-
database_id = "
|
|
40
|
+
database_id = "SEU_DATABASE_ID"
|
|
41
41
|
|
|
42
42
|
# ── Queues — Retry + Dead Letter Queue ───────────────────────────────────────
|
|
43
43
|
# Produtor: worker envia eventos com falha para cdp-edge-retry
|