cdp-edge 1.23.2 → 1.23.3
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 +44 -20
- package/contracts/agent-versions.json +42 -41
- package/dist/commands/install.js +1 -1
- package/dist/commands/server.js +4 -4
- package/extracted-skill/tracking-events-generator/agents/database-agent.md +5 -4
- package/extracted-skill/tracking-events-generator/agents/fraud-detection-agent.md +0 -1
- package/extracted-skill/tracking-events-generator/agents/linkedin-agent.md +1 -1
- package/extracted-skill/tracking-events-generator/agents/ltv-predictor-agent.md +4 -4
- package/extracted-skill/tracking-events-generator/agents/ml-clustering-agent.md +81 -70
- package/extracted-skill/tracking-events-generator/agents/page-analyzer.md +6 -2
- package/extracted-skill/tracking-events-generator/cdpTrack.js +7 -0
- package/extracted-skill/tracking-events-generator/models/lancamento-imobiliario.md +344 -0
- package/extracted-skill/tracking-events-generator/route-intent-capture.js +222 -0
- package/package.json +3 -2
- package/server-edge-tracker/INSTALAR.md +5 -5
- package/server-edge-tracker/index.js +109 -4
- package/server-edge-tracker/modules/db.js +71 -0
- package/server-edge-tracker/modules/dispatch/meta.js +12 -0
- package/server-edge-tracker/modules/ml/fraud.js +1 -16
- package/server-edge-tracker/modules/ml/ltv.js +62 -11
- package/server-edge-tracker/modules/ml/segmentation.js +157 -127
- package/server-edge-tracker/modules/utils.js +78 -0
- package/server-edge-tracker/schema-ltv-feedback.sql +11 -0
- package/server-edge-tracker/wrangler.toml +26 -8
- package/templates/lancamento-imobiliario.md +344 -0
- package/server-edge-tracker/worker.js +0 -4577
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Padrão Quantum Tracking: 100% Cloudflare Edge.** Sem GTM. Sem Stape. Sem cookies de terceiros.
|
|
4
4
|
|
|
5
|
-
> **v2.0
|
|
5
|
+
> **v2.2.0** — Granite 4.0 Micro · K-means Vetorial Real (bge-m3) · Sem emails descartáveis · Cloudflare Workers · Meta CAPI v22.0 · GA4 MP · TikTok Events API v1.3
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Meu ecossistema opera como um Cérebro de Conversão Privado na borda. Quando um evento de Lead bate no endpoint `/track`:
|
|
15
15
|
1. **O Escudo Frontal (Fraud Gate):** Inspeciono IP, ASN e Velocity na borda. Bloqueio bots silenciosamente antes mesmo deles carregarem.
|
|
16
16
|
2. **A Roleta Invisível (A/B LTV):** Faço o sorteio de prompts para testes A/B via KV Cache em ~0ms.
|
|
17
|
-
3. **O Cérebro Financeiro (LTV Predictor):** Rodo Machine Learning (
|
|
17
|
+
3. **O Cérebro Financeiro (LTV Predictor):** Rodo Machine Learning (Granite 4.0 Micro) para qualificar a intenção e gerar o LTV Preditivo.
|
|
18
18
|
4. **Envio para as Plataformas:** O Facebook/Google/LinkedIn recebem um payload limpo (sem bot) recheado com valor financeiro de intenção extrema.
|
|
19
19
|
5. **Máquina Autônoma (Background):** Meu banco SQLite (D1) retroalimenta os processos de Clustering (Fase 1) e Bidding (Fase 2) de forma autônoma pelas costas do usuário (`ctx.waitUntil`).
|
|
20
20
|
|
|
@@ -25,6 +25,25 @@ Meu ecossistema opera como um Cérebro de Conversão Privado na borda. Quando um
|
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
|
+
## 📋 CHANGELOG v2.2.0 (10 de Abril de 2026)
|
|
29
|
+
|
|
30
|
+
### 🤖 AI Engine Upgrade — Novos Modelos
|
|
31
|
+
|
|
32
|
+
- **LTV Prediction**: `@cf/meta/llama-3.1-8b-instruct` → **`@cf/ibm-granite/granite-4.0-h-micro`** (menor latência, otimizado para edge e function calling)
|
|
33
|
+
- **ML Clustering**: algoritmo LLM simulado → **K-means vetorial real** com embeddings `@cf/baai/bge-m3` (distância cosseno, K-means++ inicialização, silhouette score real)
|
|
34
|
+
- Granite continua sendo usado para naming dos segmentos pós-clustering
|
|
35
|
+
|
|
36
|
+
### 🧹 Limpeza (Zero Lixo)
|
|
37
|
+
|
|
38
|
+
- Removido: detecção de emails descartáveis (mailinator, guerrilla, tempmail, etc.) do Fraud Gate e do agente `fraud-detection-agent.md`
|
|
39
|
+
- Removido: secrets `WEBHOOK_SECRET_HOTMART` e `WEBHOOK_SECRET_KIWIFY` (wrangler + wrangler.toml)
|
|
40
|
+
|
|
41
|
+
### 🔧 Observability
|
|
42
|
+
|
|
43
|
+
- Adicionado bloco `[observability]` no `wrangler.toml` (`logs.enabled = true`, `traces.enabled = false`)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
28
47
|
## 📋 CHANGELOG v2.0.7 (10 de Abril de 2026)
|
|
29
48
|
|
|
30
49
|
### 🔧 Audit Completo — 45 Agentes
|
|
@@ -78,14 +97,14 @@ Meu ecossistema opera como um Cérebro de Conversão Privado na borda. Quando um
|
|
|
78
97
|
- **`GET /api/fraud/blocklist`** — IPs/fingerprints atualmente bloqueados
|
|
79
98
|
- **`POST /api/fraud/blocklist/add`** — Bloquear IP ou fingerprint (via KV, efeito imediato)
|
|
80
99
|
- **`DELETE /api/fraud/blocklist/remove`** — Remover do blocklist
|
|
81
|
-
- Sinais detectados: bot_score, datacenter IP, velocity attack,
|
|
100
|
+
- Sinais detectados: bot_score, datacenter IP, velocity attack, headless UA, sem Accept-Language
|
|
82
101
|
- Schema D1: `fraud_signals`, `fraud_alerts` + VIEW `v_fraud_dashboard`
|
|
83
102
|
- Agente: `fraud-detection-agent.md`
|
|
84
103
|
|
|
85
104
|
### 🔧 Fix: `wrangler.toml` atualizado
|
|
86
105
|
- Todos os placeholders (`SEU_D1_DATABASE_ID`, `SEU_KV_NAMESPACE_ID`) substituídos pelos IDs reais da conta Cloudflare
|
|
87
|
-
- D1: `
|
|
88
|
-
- KV: `
|
|
106
|
+
- D1: `SEU_DATABASE_ID`
|
|
107
|
+
- KV: `SEU_KV_ID`
|
|
89
108
|
|
|
90
109
|
---
|
|
91
110
|
|
|
@@ -98,7 +117,7 @@ graph TD
|
|
|
98
117
|
FraudGate -->|score ≥ 80: Silent Drop 200| Void[/dev/null]
|
|
99
118
|
FraudGate -->|score < 80: Permitido| Worker[Cloudflare Worker Agent]
|
|
100
119
|
Worker -->|Identity Graph + _cdp_uid| D1[(D1 SQL — 21 tabelas)]
|
|
101
|
-
Worker -->|LTV + A/B Prompt| AI[Workers AI
|
|
120
|
+
Worker -->|LTV + A/B Prompt| AI[Workers AI Granite 4.0 Micro]
|
|
102
121
|
Worker -->|Segmento ML| Cluster[ML Clustering Engine]
|
|
103
122
|
Cluster -->|Bid otimizado| Bidding[Bidding Recommendations]
|
|
104
123
|
Worker -->|Background| Queue[Cloudflare Queues]
|
|
@@ -138,7 +157,7 @@ O sistema é composto por **43+ agentes** coordenados pelo **Master Orchestrator
|
|
|
138
157
|
### 🤖 Enterprise Intelligence (Fase 1–4)
|
|
139
158
|
| Agente | Endpoint Principal | Impacto |
|
|
140
159
|
|---|---|---|
|
|
141
|
-
| **ML Clustering Agent** | `POST /api/segmentation/cluster` |
|
|
160
|
+
| **ML Clustering Agent** | `POST /api/segmentation/cluster` | K-means vetorial real (bge-m3 embeddings + Granite naming) |
|
|
142
161
|
| **Bidding Agent** | `POST /api/bidding/recommend` | -20% CPA via bid por segmento de LTV |
|
|
143
162
|
| **A/B LTV Agent** | `POST /api/ltv/ab-test/create` | +25% precisão LTV via test de prompts |
|
|
144
163
|
| **Fraud Detection Agent** | Auto em `/track` | Bloqueia click fraud, bots, velocity attacks |
|
|
@@ -187,7 +206,7 @@ POST /track (evento Lead)
|
|
|
187
206
|
├─ [2] 🔮 A/B LTV Testing — sorteia variação ativa (KV cache ~0ms)
|
|
188
207
|
│ └─ passa customSystemPrompt para predictLtv()
|
|
189
208
|
│
|
|
190
|
-
├─ [3] 🧮 LTV Prediction — Workers AI
|
|
209
|
+
├─ [3] 🧮 LTV Prediction — Workers AI Granite 4.0 Micro
|
|
191
210
|
│ └─ Score 0-100 → class High/Medium/Low → valor em BRL
|
|
192
211
|
│
|
|
193
212
|
├─ [4] 💾 D1 Writes (background via ctx.waitUntil)
|
|
@@ -203,27 +222,34 @@ POST /track (evento Lead)
|
|
|
203
222
|
|
|
204
223
|
## 💻 INSTALAÇÃO E USO
|
|
205
224
|
|
|
206
|
-
|
|
225
|
+
### OPÇÃO 1 — Instalação via npm (Recomendada)
|
|
207
226
|
|
|
208
|
-
|
|
227
|
+
Abra o terminal dentro da pasta do projeto do cliente e rode:
|
|
209
228
|
|
|
210
|
-
|
|
229
|
+
```bash
|
|
230
|
+
npx cdp-edge install
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Ou instale globalmente e use em qualquer projeto:
|
|
211
234
|
|
|
212
235
|
```bash
|
|
213
|
-
|
|
236
|
+
npm install -g cdp-edge
|
|
237
|
+
cdp-edge install . --name "Nome do Projeto"
|
|
214
238
|
```
|
|
215
|
-
*(O ponto no final garante que os arquivos desçam diretamente dentro da pasta atual).*
|
|
216
239
|
|
|
217
|
-
|
|
240
|
+
> **Já tem o CDP Edge instalado globalmente?** Atualize para a versão mais recente:
|
|
241
|
+
> ```bash
|
|
242
|
+
> npm install -g cdp-edge@latest
|
|
243
|
+
> ```
|
|
218
244
|
|
|
219
|
-
|
|
245
|
+
### OPÇÃO 2 — Instalação via Git Clone
|
|
220
246
|
|
|
221
247
|
```bash
|
|
222
|
-
|
|
223
|
-
cdp-edge install . --name "Nome do Projeto"
|
|
248
|
+
git clone https://github.com/ricardosoli777/CDP-Edge-Premium.git .
|
|
224
249
|
```
|
|
250
|
+
*(O ponto no final garante que os arquivos desçam diretamente dentro da pasta atual).*
|
|
225
251
|
|
|
226
|
-
###
|
|
252
|
+
### Ativar no Claude Code
|
|
227
253
|
|
|
228
254
|
```bash
|
|
229
255
|
claude .
|
|
@@ -279,8 +305,6 @@ wrangler deploy
|
|
|
279
305
|
|---|---|---|
|
|
280
306
|
| `/track` | POST | Evento principal (browser → CAPI) |
|
|
281
307
|
| `/health` | GET | Smoke test completo |
|
|
282
|
-
| `/webhook/hotmart` | POST | Webhook Hotmart Purchase |
|
|
283
|
-
| `/webhook/kiwify` | POST | Webhook Kiwify Purchase |
|
|
284
308
|
| `/webhook/ticto` | POST | Webhook Ticto Purchase |
|
|
285
309
|
|
|
286
310
|
### Intelligence ML
|
|
@@ -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/install.js
CHANGED
|
@@ -32,7 +32,7 @@ function printBanner() {
|
|
|
32
32
|
console.log(chalk.cyan('╚██████╗██████╔╝██║ ███████╗██████╔╝╚██████╔╝███████╗'));
|
|
33
33
|
console.log(chalk.cyan(' ╚═════╝╚═════╝ ╚═╝ ╚══════╝╚═════╝ ╚═════╝╚══════╝'));
|
|
34
34
|
console.log('');
|
|
35
|
-
console.log(chalk.gray(' Customer Data Platform on the Edge · Global Edge Tracking · v2.0.
|
|
35
|
+
console.log(chalk.gray(' Customer Data Platform on the Edge · Global Edge Tracking · v2.0.9'));
|
|
36
36
|
console.log('');
|
|
37
37
|
console.log(chalk.gray('═'.repeat(68)));
|
|
38
38
|
console.log('');
|
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]]
|
|
@@ -467,9 +467,10 @@ await env.AUDIT_LOGS.put(logKey, JSON.stringify({
|
|
|
467
467
|
|
|
468
468
|
### Modelo em Uso
|
|
469
469
|
```
|
|
470
|
-
@cf/
|
|
471
|
-
|
|
472
|
-
|
|
470
|
+
@cf/ibm-granite/granite-4.0-h-micro ← LTV Prediction + Naming de Clusters
|
|
471
|
+
@cf/baai/bge-m3 ← Embeddings para K-means vetorial (ML Clustering)
|
|
472
|
+
Custo Granite: ~20-35 neurônios/requisição (3x mais eficiente que Llama 3.1 8B)
|
|
473
|
+
Limite Free: 10.000 neurônios/dia (~350 predições/dia com Granite)
|
|
473
474
|
```
|
|
474
475
|
|
|
475
476
|
### Uso no Worker (LTV Prediction)
|
|
@@ -485,7 +486,7 @@ async function predictLtv(leadData, env) {
|
|
|
485
486
|
Responda apenas: {"class": "high|medium|low", "value": 0-1000}
|
|
486
487
|
`;
|
|
487
488
|
|
|
488
|
-
const response = await env.AI.run('@cf/
|
|
489
|
+
const response = await env.AI.run('@cf/ibm-granite/granite-4.0-h-micro', {
|
|
489
490
|
messages: [{ role: 'user', content: prompt }],
|
|
490
491
|
max_tokens: 50
|
|
491
492
|
});
|
|
@@ -71,7 +71,6 @@ checkFraudGate(env, request, payload)
|
|
|
71
71
|
| IP de datacenter | ASN = AWS, GCP, Azure, DigitalOcean, Linode | +35 pts |
|
|
72
72
|
| Sem headers de browser | Accept-Language ausente | +20 pts |
|
|
73
73
|
| Geo impossível | IP country ≠ país esperado (BR fora da LATAM) | +10 pts |
|
|
74
|
-
| Email temporário | @mailinator, @guerrilla, @tempmail, etc. | +25 pts |
|
|
75
74
|
|
|
76
75
|
### 4. Threshold de Ação
|
|
77
76
|
```
|
|
@@ -43,7 +43,7 @@ import { predictLtv } from './ltv-predictor.js';
|
|
|
43
43
|
* @param {Request} request - request original
|
|
44
44
|
*/
|
|
45
45
|
async function dispatchLinkedIn(env, leadData, request) {
|
|
46
|
-
// 1. Obter LTV predito pelo ML (Workers AI —
|
|
46
|
+
// 1. Obter LTV predito pelo ML (Workers AI — Granite 4.0 Micro)
|
|
47
47
|
let conversionValue = 0;
|
|
48
48
|
try {
|
|
49
49
|
const ltvResult = await predictLtv(env, leadData, request);
|
|
@@ -14,7 +14,7 @@ Sua única responsabilidade é instruir o Cloudflare Architect a imbuir modelos
|
|
|
14
14
|
|
|
15
15
|
## 📦 O PACOTE DE ENTREGA OBRIGATÓRIO
|
|
16
16
|
Sempre que o Orquestrador invocar a Otimização de Baleias (LTV Prediction):
|
|
17
|
-
1. **Snippet de Injeção de ML**: Entregue ao Server Architect o bloco `await env.AI.run('@cf/
|
|
17
|
+
1. **Snippet de Injeção de ML**: Entregue ao Server Architect o bloco `await env.AI.run('@cf/ibm-granite/granite-4.0-h-micro', ...)` ajustado para predição puramente matemática.
|
|
18
18
|
2. **Override de Event Valuation**: Modifique como o evento `Lead` ou `Purchase` é envernizado com lucro preditivo antes do dispatch da CAPI.
|
|
19
19
|
|
|
20
20
|
> 👁️ "Não pague por cliques hoje. Compre os clientes de amanhã. Faça o algoritmo apostar sempre nas suas fichas vencedoras."
|
|
@@ -27,7 +27,7 @@ Sempre que o Orquestrador invocar a Otimização de Baleias (LTV Prediction):
|
|
|
27
27
|
- Dados de UTM: `utm_source`, `utm_medium`, `utm_campaign`
|
|
28
28
|
- `request.cf.asOrganization` e `request.cf.country` (sinais de qualidade do tráfego)
|
|
29
29
|
- Histórico D1 do `_cdp_uid`: páginas visitadas, tempo na página, eventos anteriores
|
|
30
|
-
- Binding `env.AI` (Cloudflare Workers AI — `@cf/
|
|
30
|
+
- Binding `env.AI` (Cloudflare Workers AI — `@cf/ibm-granite/granite-4.0-h-micro`)
|
|
31
31
|
|
|
32
32
|
## RESPONSABILIDADE
|
|
33
33
|
|
|
@@ -35,7 +35,7 @@ Sempre que o Orquestrador invocar a Otimização de Baleias (LTV Prediction):
|
|
|
35
35
|
- Classificar o lead em `predicted_ltv_class: 'High' | 'Medium' | 'Low'`
|
|
36
36
|
- Substituir `value: 0` do evento `Lead` pelo valor preditivo antes do dispatch CAPI/GA4/TikTok
|
|
37
37
|
- Registrar no D1 `identity_graph`: `predicted_ltv`, `predicted_ltv_class`
|
|
38
|
-
- Consumo
|
|
38
|
+
- Consumo: ~20–35 neurônios/request com Granite 4.0 Micro (~350 predições/dia no free tier, ilimitado no paid)
|
|
39
39
|
|
|
40
40
|
## SAÍDA
|
|
41
41
|
|
|
@@ -44,7 +44,7 @@ Sempre que o Orquestrador invocar a Otimização de Baleias (LTV Prediction):
|
|
|
44
44
|
"arquivos_criados": [
|
|
45
45
|
"cloudflare/ltv-predictor.js"
|
|
46
46
|
],
|
|
47
|
-
"modelo_ai": "@cf/
|
|
47
|
+
"modelo_ai": "@cf/ibm-granite/granite-4.0-h-micro",
|
|
48
48
|
"campo_substituido": "value",
|
|
49
49
|
"exemplo": {
|
|
50
50
|
"evento": "Lead",
|