predators-protocol 1.2.0 → 1.2.2
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/bin/predators-cli.js +70 -7
- package/bundle/.claude/commands/encarnar.md +3 -3
- package/bundle/QUICKSTART-SOCIO.md +3 -3
- package/bundle/docs/CANON/SELF-HEALING-LOG-CANON.json +638 -583
- package/bundle/predators/apex/aguia-pescadora/constitution.md +469 -0
- package/bundle/predators/apex/aguia-pescadora/predator.json +66 -0
- package/bundle/predators/apex/aguia-real/constitution.md +11 -0
- package/bundle/predators/builder/camaleao/constitution.md +8 -0
- package/bundle/predators/builder/polvo/constitution.md +8 -0
- package/bundle/predators/builder/tatu-bola/constitution.md +8 -0
- package/bundle/predators/intel/jiboia/predator.json +2 -1
- package/bundle/predators/intel/lobo-solitario/constitution.md +15 -0
- package/lib/access-token-client.js +8 -1
- package/lib/config.js +4 -3
- package/lib/gen-token-client.js +1 -1
- package/lib/invoke-client.js +138 -0
- package/package.json +1 -1
package/lib/config.js
CHANGED
|
@@ -28,9 +28,10 @@ const DEFAULT_CONFIG = {
|
|
|
28
28
|
anonymous_id: null, // UUID v4 gerado no primeiro opt-in · zero PII
|
|
29
29
|
sync_count: 0, // total syncs locais executados
|
|
30
30
|
last_sync_at: null, // último sync ISO timestamp
|
|
31
|
-
// Canon endpoint
|
|
32
|
-
// null = local-only (zero network calls).
|
|
33
|
-
|
|
31
|
+
// Canon endpoint: dominio de marca vivo predadores.online (predadores.io EXPIROU ·
|
|
32
|
+
// DNS verificado morto 2026-06-08). null = local-only (zero network calls).
|
|
33
|
+
// telemetry e opt-in default-off + fire-and-forget com catch silencioso (zero impacto UX).
|
|
34
|
+
endpoint: "https://predadores.online/api/telemetry",
|
|
34
35
|
},
|
|
35
36
|
syncs: {
|
|
36
37
|
total: 0,
|
package/lib/gen-token-client.js
CHANGED
|
@@ -18,7 +18,7 @@ const { URL } = require("url");
|
|
|
18
18
|
|
|
19
19
|
const API_ENDPOINT_DEFAULT =
|
|
20
20
|
process.env.PREDATORS_API_ENDPOINT ||
|
|
21
|
-
"https://
|
|
21
|
+
"https://predadores.online/api/admin/access-tokens";
|
|
22
22
|
|
|
23
23
|
function parseArgs(argv) {
|
|
24
24
|
const args = {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// packages/predators-protocol/lib/invoke-client.js
|
|
2
|
+
//
|
|
3
|
+
// ONDA-SAAS Onda 4b · CLI vira cliente de API real: invoca um predador via /api/invoke usando a chave
|
|
4
|
+
// Bearer que o user criou em /settings (planos PRO/APEX). Onca-pintada + Tubarao N2 SEVERA.
|
|
5
|
+
//
|
|
6
|
+
// Lei #1: a chave (PREDATORS_API_KEY) NUNCA vai na URL nem em log · so no header Authorization. A
|
|
7
|
+
// autenticacao e enforcada server-side (resolveBearerScope: chave invalida/revogada/sem "invoke" → 401).
|
|
8
|
+
// O gasto e bounded pela quota semanal do plano + rate-limit 30/min/token (na rota /api/invoke).
|
|
9
|
+
// Lei #13 Pureza: zero dep externa · node:https built-in.
|
|
10
|
+
|
|
11
|
+
"use strict";
|
|
12
|
+
|
|
13
|
+
const https = require("https");
|
|
14
|
+
const { URL } = require("url");
|
|
15
|
+
|
|
16
|
+
const DEFAULT_ENDPOINT =
|
|
17
|
+
process.env.PREDATORS_API_ENDPOINT || "https://predadores.online/api/invoke";
|
|
18
|
+
|
|
19
|
+
function printHelp() {
|
|
20
|
+
console.log(`
|
|
21
|
+
predators-protocol invoke · invoca um predador via API (token Bearer)
|
|
22
|
+
|
|
23
|
+
USO:
|
|
24
|
+
npx predators-protocol invoke <predator-id> "<tarefa>"
|
|
25
|
+
|
|
26
|
+
AUTENTICACAO:
|
|
27
|
+
export PREDATORS_API_KEY="OWN_..." # crie em https://predadores.online/settings (planos PRO/APEX)
|
|
28
|
+
|
|
29
|
+
ENDPOINT (override opcional):
|
|
30
|
+
export PREDATORS_API_ENDPOINT="https://meu-deploy/api/invoke"
|
|
31
|
+
|
|
32
|
+
EXEMPLO:
|
|
33
|
+
npx predators-protocol invoke tubarao-branco "audite este contrato"
|
|
34
|
+
|
|
35
|
+
A chave age com o seu acesso e gasta a sua quota semanal. Revogue em /settings se vazar.
|
|
36
|
+
`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function makeRequest(endpoint, apiKey, body) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const url = new URL(endpoint);
|
|
42
|
+
const reqBody = JSON.stringify(body);
|
|
43
|
+
const req = https.request(
|
|
44
|
+
{
|
|
45
|
+
hostname: url.hostname,
|
|
46
|
+
port: url.port || 443,
|
|
47
|
+
path: url.pathname + (url.search || ""),
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: {
|
|
50
|
+
"Content-Type": "application/json",
|
|
51
|
+
// Lei #1 [ok3]-analog: credencial no header · NUNCA na query string (evita leak em logs/URL).
|
|
52
|
+
Authorization: `Bearer ${apiKey}`,
|
|
53
|
+
"User-Agent": "predators-protocol-cli/invoke",
|
|
54
|
+
"Content-Length": Buffer.byteLength(reqBody),
|
|
55
|
+
},
|
|
56
|
+
timeout: 120_000,
|
|
57
|
+
},
|
|
58
|
+
(res) => {
|
|
59
|
+
let data = "";
|
|
60
|
+
res.on("data", (chunk) => (data += chunk));
|
|
61
|
+
res.on("end", () => {
|
|
62
|
+
try {
|
|
63
|
+
resolve({ status: res.statusCode, body: JSON.parse(data) });
|
|
64
|
+
} catch {
|
|
65
|
+
resolve({ status: res.statusCode, body: { raw: data } });
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
req.on("error", reject);
|
|
71
|
+
req.on("timeout", () => {
|
|
72
|
+
req.destroy();
|
|
73
|
+
reject(new Error("timeout"));
|
|
74
|
+
});
|
|
75
|
+
req.write(reqBody);
|
|
76
|
+
req.end();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function runInvoke() {
|
|
81
|
+
const args = process.argv.slice(3);
|
|
82
|
+
if (args.includes("--help") || args.includes("-h") || args.length === 0) {
|
|
83
|
+
printHelp();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const predatorId = args[0];
|
|
88
|
+
const task = args.slice(1).filter((a) => !a.startsWith("-")).join(" ");
|
|
89
|
+
|
|
90
|
+
const apiKey = process.env.PREDATORS_API_KEY;
|
|
91
|
+
if (!apiKey) {
|
|
92
|
+
console.error("ERRO: PREDATORS_API_KEY nao-setada.");
|
|
93
|
+
console.error(" Crie uma chave em https://predadores.online/settings (planos PRO/APEX) e rode:");
|
|
94
|
+
console.error(' export PREDATORS_API_KEY="OWN_..."');
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
if (!predatorId || !task) {
|
|
98
|
+
console.error('ERRO: uso: npx predators-protocol invoke <predator-id> "<tarefa>"');
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
console.log(`Invocando ${predatorId}...`);
|
|
103
|
+
let result;
|
|
104
|
+
try {
|
|
105
|
+
result = await makeRequest(DEFAULT_ENDPOINT, apiKey, { predator_id: predatorId, task });
|
|
106
|
+
} catch (err) {
|
|
107
|
+
console.error(`Falha de rede: ${err && err.message ? err.message : err}`);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (result.status === 401) {
|
|
112
|
+
console.error("Acesso negado (401): chave invalida, revogada ou sem permissao 'invoke'. Confira em /settings.");
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
if (result.status === 429) {
|
|
116
|
+
const retry = (result.body && result.body.retry_after_seconds) || 60;
|
|
117
|
+
console.error(`Rate limit (429): muitas chamadas. Tente de novo em ${retry}s.`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
if (result.status >= 400) {
|
|
121
|
+
console.error(`Erro HTTP ${result.status}: ${JSON.stringify(result.body)}`);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Sucesso (200/202). Imprime o resultado de forma robusta (campo varia: output/result/note/stub).
|
|
126
|
+
const b = result.body || {};
|
|
127
|
+
console.log("");
|
|
128
|
+
console.log(`status: ${b.status || "ok"} · invocation: ${b.invocation_id || "—"}`);
|
|
129
|
+
const out = b.output || b.result || b.note;
|
|
130
|
+
if (out) {
|
|
131
|
+
console.log("");
|
|
132
|
+
console.log(out);
|
|
133
|
+
} else {
|
|
134
|
+
console.log(JSON.stringify(b, null, 2));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = { runInvoke, printHelp };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "predators-protocol",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Predators Protocol \u00b7 multi-agent predatory framework \u00b7 64 predators in 10 layers \u00b7 14 canonical laws \u00b7 5 byte-canon imutables \u00b7 Synapse + Cyber Squad + Brain 11 daemons LIVE \u00b7 H\u00edbrida full transition \u00b7 STABLE 1.0.0 \u00b7 proprietary Alex Gonzaga (Tubarao-Apex)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"predators-protocol",
|