nothumanallowed 16.0.64 → 17.0.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 (57) hide show
  1. package/README.md +98 -26
  2. package/bin/nha +3 -2
  3. package/package.json +7 -4
  4. package/src/bootstrap.mjs +30 -66
  5. package/src/cli.mjs +63 -21
  6. package/src/commands/ask.mjs +3 -10
  7. package/src/commands/autostart.mjs +1 -1
  8. package/src/commands/chat.mjs +1 -1
  9. package/src/commands/ops.mjs +1 -1
  10. package/src/config.mjs +41 -2
  11. package/src/constants.mjs +8 -2
  12. package/src/downloader.mjs +8 -3
  13. package/src/legion/agents/ade.mjs +201 -0
  14. package/src/legion/agents/athena.mjs +162 -0
  15. package/src/legion/agents/atlas.mjs +159 -0
  16. package/src/legion/agents/babel.mjs +167 -0
  17. package/src/legion/agents/cartographer.mjs +213 -0
  18. package/src/legion/agents/cassandra.mjs +185 -0
  19. package/src/legion/agents/conductor.mjs +183 -0
  20. package/src/legion/agents/cron.mjs +165 -0
  21. package/src/legion/agents/echo.mjs +165 -0
  22. package/src/legion/agents/edi.mjs +166 -0
  23. package/src/legion/agents/epicure.mjs +211 -0
  24. package/src/legion/agents/flux.mjs +165 -0
  25. package/src/legion/agents/forge.mjs +166 -0
  26. package/src/legion/agents/glitch.mjs +169 -0
  27. package/src/legion/agents/heimdall.mjs +171 -0
  28. package/src/legion/agents/herald.mjs +208 -0
  29. package/src/legion/agents/hermes.mjs +163 -0
  30. package/src/legion/agents/jarvis.mjs +163 -0
  31. package/src/legion/agents/link.mjs +163 -0
  32. package/src/legion/agents/logos.mjs +171 -0
  33. package/src/legion/agents/macro.mjs +158 -0
  34. package/src/legion/agents/mercury.mjs +234 -0
  35. package/src/legion/agents/murasaki.mjs +163 -0
  36. package/src/legion/agents/muse.mjs +217 -0
  37. package/src/legion/agents/navi.mjs +161 -0
  38. package/src/legion/agents/oracle.mjs +165 -0
  39. package/src/legion/agents/pipe.mjs +160 -0
  40. package/src/legion/agents/polyglot.mjs +226 -0
  41. package/src/legion/agents/prometheus.mjs +171 -0
  42. package/src/legion/agents/quill.mjs +165 -0
  43. package/src/legion/agents/saber.mjs +162 -0
  44. package/src/legion/agents/sauron.mjs +173 -0
  45. package/src/legion/agents/scheherazade.mjs +179 -0
  46. package/src/legion/agents/shell.mjs +166 -0
  47. package/src/legion/agents/shogun.mjs +163 -0
  48. package/src/legion/agents/tempest.mjs +211 -0
  49. package/src/legion/agents/veritas.mjs +166 -0
  50. package/src/legion/agents/zero.mjs +162 -0
  51. package/src/legion/legion-x.mjs +12114 -0
  52. package/src/legion-bundle.mjs +64 -0
  53. package/src/legion-config.mjs +134 -0
  54. package/src/services/llm.mjs +46 -31
  55. package/src/services/message-responder.mjs +1 -1
  56. package/src/spawn.mjs +22 -44
  57. package/src/updater.mjs +48 -63
@@ -572,7 +572,7 @@ export async function cmdChat(args) {
572
572
 
573
573
  const activeProvider = config.llm.provider || 'anthropic';
574
574
  if (activeProvider !== 'nha' && !config.llm.apiKey) {
575
- fail('No API key configured. Run: nha config set key YOUR_KEY\n Or use the free tier: nha config set provider nha');
575
+ fail('No API key configured. Run: nha config set key YOUR_KEY');
576
576
  process.exit(1);
577
577
  }
578
578
 
@@ -105,7 +105,7 @@ export async function cmdOps(args) {
105
105
  let inactiveHintTel = 'configured but inactive (try: nha ops stop && nha ops start)';
106
106
  if (reason.startsWith('missing_key:')) {
107
107
  const p = reason.slice('missing_key:'.length);
108
- inactiveHintTel = `configured but LLM key missing for provider "${p}" — fix with: nha config set provider nha (free Liara) OR nha config set ${p}-key YOUR_KEY`;
108
+ inactiveHintTel = `configured but LLM key missing for provider "${p}" — fix with: nha config set key YOUR_KEY`;
109
109
  }
110
110
  console.log(` Telegram: ${responder.telegram ? G + 'active' + NC : telegramConfigured ? Y + inactiveHintTel + NC : D + 'not configured' + NC}`);
111
111
  console.log(` Discord: ${responder.discord ? G + 'active' + NC : discordConfigured ? Y + inactiveHintTel + NC : D + 'not configured' + NC}`);
package/src/config.mjs CHANGED
@@ -11,7 +11,10 @@ const LEGACY_PIF = path.join(os.homedir(), '.pif-agent.json');
11
11
  const DEFAULT_CONFIG = {
12
12
  version: 1,
13
13
  llm: {
14
- provider: 'nha',
14
+ // Empty = not chosen yet. It used to be 'nha', the hosted free model,
15
+ // which is offline: a new install must not start on a provider that
16
+ // cannot answer. A provider saved by an existing user is left as it is.
17
+ provider: '',
15
18
  apiKey: '',
16
19
  openaiKey: '',
17
20
  geminiKey: '',
@@ -39,6 +42,24 @@ const DEFAULT_CONFIG = {
39
42
  semanticConvergence: true,
40
43
  tribunalEnabled: true,
41
44
  },
45
+ // Deliberations (nha run). An empty provider means "the llm provider above,
46
+ // when Legion supports it". Local models need no API key.
47
+ legion: {
48
+ provider: '',
49
+ ollamaUrl: '',
50
+ ollamaModel: '',
51
+ ollamaModels: '',
52
+ ollamaEmbedModel: '',
53
+ localOpenaiUrl: '',
54
+ localOpenaiModel: '',
55
+ localOpenaiKey: '',
56
+ orchestratorProvider: '',
57
+ // true = no cloud key reaches Legion, even when one is configured for chat
58
+ localOnly: false,
59
+ economy: false,
60
+ factCheck: true,
61
+ crossReadingChars: 0,
62
+ },
42
63
  features: {
43
64
  verbose: true,
44
65
  immersive: true,
@@ -236,7 +257,10 @@ export function loadConfig() {
236
257
  */
237
258
  export function saveConfig(config) {
238
259
  fs.mkdirSync(NHA_DIR, { recursive: true });
239
- fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + '\n', 'utf-8');
260
+ // The file holds API keys and tokens: readable by its owner only. The mode
261
+ // applies to a new file, chmod tightens one written by an older version.
262
+ fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + '\n', { encoding: 'utf-8', mode: 0o600 });
263
+ fs.chmodSync(CONFIG_FILE, 0o600);
240
264
  }
241
265
 
242
266
  /**
@@ -294,6 +318,21 @@ export function setConfigValue(key, value) {
294
318
  'openrouterkey': 'llm.openrouterKey',
295
319
  'openrouterKey': 'llm.openrouterKey',
296
320
  'openrouter_key': 'llm.openrouterKey',
321
+ 'anthropic-key': 'llm.anthropicKey',
322
+ // Deliberations (nha run): provider and local models
323
+ 'legion-provider': 'legion.provider',
324
+ 'ollama-url': 'legion.ollamaUrl',
325
+ 'ollama-model': 'legion.ollamaModel',
326
+ 'ollama-models': 'legion.ollamaModels',
327
+ 'ollama-embed-model': 'legion.ollamaEmbedModel',
328
+ 'local-openai-url': 'legion.localOpenaiUrl',
329
+ 'local-openai-model': 'legion.localOpenaiModel',
330
+ 'local-openai-key': 'legion.localOpenaiKey',
331
+ 'orchestrator-provider': 'legion.orchestratorProvider',
332
+ 'local-only': 'legion.localOnly',
333
+ 'economy': 'legion.economy',
334
+ 'fact-check': 'legion.factCheck',
335
+ 'cross-reading-chars': 'legion.crossReadingChars',
297
336
  'model': 'llm.model',
298
337
  'timeout': 'llm.timeout',
299
338
  'verbose': 'features.verbose',
package/src/constants.mjs CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'url';
5
5
  const __filename = fileURLToPath(import.meta.url);
6
6
  const __dirname = path.dirname(__filename);
7
7
 
8
- export const VERSION = '16.0.64';
8
+ export const VERSION = '17.0.1';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -18,7 +18,13 @@ export const SESSIONS_DIR = path.join(NHA_DIR, 'sessions');
18
18
  export const MEMORY_DIR = path.join(NHA_DIR, 'memory');
19
19
  export const CONFIG_FILE = path.join(NHA_DIR, 'config.json');
20
20
 
21
- export const LEGION_FILE = path.join(CORE_DIR, 'legion-x.mjs');
21
+ // Legion X and its agents ship inside the npm package: nothing is downloaded
22
+ // to run a deliberation. Legion runs straight from the package; the agents are
23
+ // copied to ~/.nha/agents so they stay files the user can read and edit.
24
+ export const LEGION_FILE = path.join(__dirname, 'legion', 'legion-x.mjs');
25
+ export const BUNDLED_AGENTS_DIR = path.join(__dirname, 'legion', 'agents');
26
+ export const AGENTS_STAMP_FILE = path.join(AGENTS_DIR, '.bundle-version');
27
+ export const LEGION_CONFIG_FILE = path.join(NHA_DIR, '.legion-config.json');
22
28
  export const PIF_FILE = path.join(CORE_DIR, 'pif.mjs');
23
29
  export const VERSIONS_FILE = path.join(CORE_DIR, 'versions.json');
24
30
  export const LAST_UPDATE_CHECK = path.join(CORE_DIR, '.last-update-check');
@@ -26,14 +26,16 @@ export async function download(url, dest, opts = {}) {
26
26
 
27
27
  let lastErr = null;
28
28
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
29
+ // The timer covers the whole attempt, body included, and is always
30
+ // cleared: left running after a failed request it kept the process alive
31
+ // for the full timeout once the command had finished.
32
+ const controller = new AbortController();
33
+ const timer = setTimeout(() => controller.abort(), timeout);
29
34
  try {
30
- const controller = new AbortController();
31
- const timer = setTimeout(() => controller.abort(), timeout);
32
35
  const res = await fetch(url, {
33
36
  signal: controller.signal,
34
37
  headers: { 'User-Agent': `nha-cli/${VERSION}` },
35
38
  });
36
- clearTimeout(timer);
37
39
 
38
40
  if (!res.ok) {
39
41
  // 5xx → retry; 4xx → permanent failure, no retry
@@ -65,10 +67,13 @@ export async function download(url, dest, opts = {}) {
65
67
  const transient = err.name === 'AbortError'
66
68
  || /ECONNRESET|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|EPIPE|ENETUNREACH|UND_ERR/i.test(err.message || '');
67
69
  if (transient && attempt < maxAttempts) {
70
+ clearTimeout(timer);
68
71
  await _delay(_backoff(attempt));
69
72
  continue;
70
73
  }
71
74
  break;
75
+ } finally {
76
+ clearTimeout(timer);
72
77
  }
73
78
  }
74
79
  if (lastErr) {
@@ -0,0 +1,201 @@
1
+ /**
2
+ * ┌─────────────────────────────────────────────┐
3
+ * │ ╔═╗╔╦╗╔═╗ │
4
+ * │ ╠═╣ ║║║╣ │
5
+ * │ ╩ ╩═╩╝╚═╝ │
6
+ * │ Offensive Security Specialist │
7
+ * │ Origin: Greek Mythology (Hades) │
8
+ * │ "I see what lies beneath the surface" │
9
+ * └─────────────────────────────────────────────┘
10
+ *
11
+ * Primary offensive security agent. Conducts penetration testing,
12
+ * exploit development, and attack simulation against authorized targets.
13
+ * Produces structured pentest reports with CVSS scores, proof of concept,
14
+ * and remediation guidance.
15
+ *
16
+ * Works alongside SABER (defensive) in Geth Consensus deliberation:
17
+ * ADE attacks, SABER defends — the clash produces superior security insight.
18
+ *
19
+ * Sub-agents: none (collaborates with SABER's sub-agents CORTANA and ZERO
20
+ * during deliberation via cross-reading)
21
+ */
22
+
23
+ export var AGENT_CARD = {
24
+ name: 'ade',
25
+ displayName: 'ADE',
26
+ category: 'security',
27
+ origin: 'Greek Mythology (Hades)',
28
+ tagline: 'I see what lies beneath the surface',
29
+ capabilities: [
30
+ 'penetration-testing',
31
+ 'offensive-security',
32
+ 'exploit-development',
33
+ 'attack-simulation',
34
+ 'vulnerability-exploitation',
35
+ 'payload-crafting',
36
+ 'red-team',
37
+ 'attack-surface-mapping',
38
+ 'authentication-testing',
39
+ 'injection-testing',
40
+ 'xss-testing',
41
+ 'csrf-testing',
42
+ 'ssrf-testing',
43
+ 'idor-testing',
44
+ 'rate-limit-testing',
45
+ 'api-security-testing',
46
+ 'web-security',
47
+ 'mobile-security',
48
+ 'infrastructure-testing',
49
+ 'social-engineering-analysis',
50
+ 'security-report',
51
+ 'cvss-scoring',
52
+ 'remediation-planning',
53
+ 'defense-strategy',
54
+ ],
55
+ inputTypes: ['url', 'config', 'code', 'scope', 'text'],
56
+ outputTypes: ['pentest-report', 'vulnerability-list', 'exploitation-log', 'remediation-guide', 'attack-plan'],
57
+ parentAgent: null,
58
+ };
59
+
60
+ export var SYSTEM_PROMPT =
61
+ 'You are ADE, an elite offensive security specialist — the red team operator of Legion. Your name comes from ' +
62
+ 'Hades (Ade in Italian), the Greek god who sees everything hidden beneath the surface. You find what others miss.\n\n' +
63
+
64
+ 'You are a PENETRATION TESTER, not a scanner. You think like an attacker with full knowledge of modern exploit ' +
65
+ 'chains, lateral movement techniques, and post-exploitation strategies. You do not merely list theoretical risks — ' +
66
+ 'you demonstrate how an attacker would ACTUALLY exploit them, step by step.\n\n' +
67
+
68
+ 'Your core methodology follows PTES (Penetration Testing Execution Standard) and OSSTMM:\n' +
69
+ '1. RECONNAISSANCE: Passive and active information gathering. DNS enumeration, subdomain discovery, technology ' +
70
+ 'fingerprinting, OSINT, Google dorking, certificate transparency logs, Wayback Machine analysis, social media ' +
71
+ 'intelligence. Map the full attack surface before touching the target.\n' +
72
+ '2. SCANNING & ENUMERATION: Port scanning, service identification, version detection, directory brute-forcing, ' +
73
+ 'parameter discovery, API endpoint enumeration, JavaScript analysis for hidden endpoints, WebSocket probing, ' +
74
+ 'GraphQL introspection.\n' +
75
+ '3. VULNERABILITY ANALYSIS: Map findings to OWASP Top 10 (2021+), MITRE ATT&CK framework, and known CVEs. ' +
76
+ 'Prioritize by exploitability, not just severity. A Medium-severity bug with a public exploit is more dangerous ' +
77
+ 'than a High-severity bug requiring kernel access.\n' +
78
+ '4. EXPLOITATION: Develop and describe proof-of-concept exploits. SQL injection (union, blind, time-based, ' +
79
+ 'second-order), XSS (reflected, stored, DOM-based, mutation XSS), CSRF, SSRF (internal service access, cloud ' +
80
+ 'metadata), IDOR (sequential, UUID prediction, parameter pollution), authentication bypass (JWT algorithm ' +
81
+ 'confusion, session fixation, OAuth redirect manipulation, password reset poisoning), deserialization attacks, ' +
82
+ 'prototype pollution, race conditions (TOCTOU), path traversal, command injection, template injection (SSTI), ' +
83
+ 'XML external entities (XXE), HTTP request smuggling, WebSocket hijacking, GraphQL batching attacks.\n' +
84
+ '5. POST-EXPLOITATION: Privilege escalation paths, lateral movement opportunities, data exfiltration vectors, ' +
85
+ 'persistence mechanisms. What can an attacker do AFTER initial access?\n' +
86
+ '6. REPORTING: Every vulnerability gets a structured report entry.\n\n' +
87
+
88
+ 'Output format for EVERY finding:\n' +
89
+ '- ID: Sequential (ADE-001, ADE-002, ...)\n' +
90
+ '- Title: Clear vulnerability name\n' +
91
+ '- Severity: Critical / High / Medium / Low / Informational\n' +
92
+ '- CVSS v3.1 vector string and score (e.g., CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H = 9.8)\n' +
93
+ '- Category: OWASP Top 10 mapping + CWE ID\n' +
94
+ '- MITRE ATT&CK: Relevant technique IDs (e.g., T1190 Exploit Public-Facing Application)\n' +
95
+ '- Affected component: URL, endpoint, parameter, header, or code location\n' +
96
+ '- Description: What the vulnerability is and WHY it exists\n' +
97
+ '- Attack scenario: Step-by-step exploitation (what an attacker would do)\n' +
98
+ '- Proof of concept: Exact payloads, curl commands, or code snippets\n' +
99
+ '- Impact: What data/access the attacker gains\n' +
100
+ '- Remediation: Specific fix with code examples\n' +
101
+ '- References: CVE IDs, CWE links, relevant advisories\n\n' +
102
+
103
+ 'Your ethical principles:\n' +
104
+ '- You test ONLY targets explicitly authorized by the user\n' +
105
+ '- You NEVER cause denial of service or data destruction\n' +
106
+ '- You document everything for reproducibility\n' +
107
+ '- You provide remediation for every vulnerability you find\n' +
108
+ '- You escalate critical findings immediately with clear severity justification\n\n' +
109
+
110
+ 'Your relationship with SABER in Geth Consensus:\n' +
111
+ 'SABER is the defensive specialist — the blue team. When you both participate in deliberation, you create a ' +
112
+ 'RED TEAM vs BLUE TEAM dynamic. You ATTACK, SABER DEFENDS. This adversarial collaboration produces superior ' +
113
+ 'security insight because:\n' +
114
+ '- You find the holes; SABER proposes the patches\n' +
115
+ '- SABER audits from a compliance perspective; you audit from an attacker perspective\n' +
116
+ '- When SABER says "this is secure," you try to prove it is not\n' +
117
+ '- When you find a vulnerability, SABER evaluates the severity in context and proposes defense-in-depth\n' +
118
+ '- CORTANA provides threat intelligence that informs your attack strategy\n' +
119
+ '- ZERO provides scanning data that you use to prioritize targets\n' +
120
+ 'During cross-reading rounds, READ SABER\'s analysis carefully. If SABER missed an attack vector, point it out ' +
121
+ 'with evidence. If SABER correctly identified a defense, acknowledge it and look for bypass techniques.';
122
+
123
+ export async function execute(task, context, llmProvider) {
124
+ var prompt = 'Task: ' + task.description;
125
+
126
+ // Task dependency results from previous sub-tasks
127
+ if (context.dependencyResults && Object.keys(context.dependencyResults).length > 0) {
128
+ prompt += '\n\n[DEPENDENCY CONTEXT \u2014 Results from prerequisite tasks]\n';
129
+ var keys = Object.keys(context.dependencyResults);
130
+ for (var i = 0; i < keys.length; i++) {
131
+ prompt += '\n--- Result from ' + keys[i] + ' ---\n' + context.dependencyResults[keys[i]];
132
+ }
133
+ }
134
+
135
+ // Original user request
136
+ if (context.originalPrompt) {
137
+ prompt += '\n\n[ORIGINAL REQUEST]\n' + context.originalPrompt;
138
+ }
139
+
140
+ // v5.0+: Collective intelligence context
141
+ if (context.workspaceSnapshot) {
142
+ prompt += '\n\n[SHARED WORKSPACE \u2014 Live collaborative state from all agents]\n' + context.workspaceSnapshot;
143
+ }
144
+ if (context.episodicMemories) {
145
+ prompt += '\n\n[EPISODIC MEMORY \u2014 Your relevant past experiences on similar tasks]\n' + context.episodicMemories;
146
+ }
147
+ if (context.eventStream) {
148
+ prompt += '\n\n[COMMUNICATION STREAM \u2014 Recent inter-agent signals and events]\n' + context.eventStream;
149
+ }
150
+ if (context.knowledgeGraph) {
151
+ prompt += '\n\n[KNOWLEDGE GRAPH \u2014 Known relationships between agents, capabilities, and domains]\n' + context.knowledgeGraph;
152
+ }
153
+ if (context.latentSpaceInsight) {
154
+ prompt += '\n\n[LATENT SPACE \u2014 Emergent patterns detected across the collective]\n' + context.latentSpaceInsight;
155
+ }
156
+
157
+ // v7.0: Deliberation cross-reading — other agents' proposals
158
+ if (context.proposalContext) {
159
+ prompt += '\n\n[DELIBERATION \u2014 Cross-Reading Round]\n' + context.proposalContext;
160
+ prompt += '\n\n[DELIBERATION INSTRUCTIONS — ADE SECURITY SCANNER MODE]\n'
161
+ + 'You are in a multi-round deliberation. Other agents have shared their proposals above. '
162
+ + 'Your role is SECURITY SCANNER. You MUST:\n'
163
+ + '1. Scan every proposal for security vulnerabilities — injection, auth bypass, data exposure\n'
164
+ + '2. Challenge insecure patterns: [VULN-FOUND: agent_name — approach X introduces vulnerability Y (OWASP category Z)]\n'
165
+ + '3. Provide secure alternatives: [SECURE-ALT: replace pattern X with Y which mitigates risk Z]\n'
166
+ + '4. Verify security claims: [SECURITY-VERIFY: agent_name claims X is secure but attack vector Y still exists]\n'
167
+ + '5. When agreeing, add security hardening: [HARDENED: implementing agent_name approach with added security layer Y]\n'
168
+ + '6. Security is a hard constraint — do NOT converge on solutions with known vulnerabilities\n';
169
+ }
170
+
171
+ // v5.0+: Self-modification — apply learned evolution patterns to system prompt
172
+ var systemPrompt = SYSTEM_PROMPT;
173
+ if (context.promptEvolution) {
174
+ systemPrompt += '\n\n[EVOLVED CAPABILITIES \u2014 Patterns learned from past performance]\n' + context.promptEvolution;
175
+ }
176
+
177
+ // v8.0: Geth Consensus participation clause
178
+ systemPrompt += '\n\n[GETH CONSENSUS PROTOCOL]\n'
179
+ + 'You are the security scanner in a multi-agent collective. '
180
+ + 'Your value is automated vulnerability detection that others miss. '
181
+ + 'Challenge every proposal for OWASP Top 10 and beyond. '
182
+ + 'A single unpatched vulnerability can negate all other work.';
183
+
184
+
185
+ // v10.0: Neural Controller — Structured Output for confidence tracking
186
+ systemPrompt += '\n\n'
187
+ + '[STRUCTURED OUTPUT FORMAT]\n'
188
+ + 'You MUST wrap your response in JSON format inside a markdown code block:\n'
189
+ + '\`\`\`json\n'
190
+ + '{\n'
191
+ + ' "answer": "<your full answer here>",\n'
192
+ + ' "confidence": <0.0 to 1.0>,\n'
193
+ + ' "reasoning_summary": "<1-2 sentence summary of your reasoning>",\n'
194
+ + ' "risk_flags": ["<optional flags: speculative, outdated_knowledge, incomplete_context, conflicting_evidence, domain_mismatch>"]\n'
195
+ + '}\n'
196
+ + '\`\`\`\n'
197
+ + 'Confidence scale: 0.9-1.0 near certain, 0.7-0.89 high, 0.5-0.69 moderate, 0.3-0.49 low, 0.0-0.29 very low.';
198
+
199
+
200
+ return await llmProvider.chat(systemPrompt, prompt, { maxTokens: 8192, agentTag: AGENT_CARD.name });
201
+ }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * 🦉 ─── ─── ─── ─── ─── ─── ─── ─── 🦉
3
+ *
4
+ * ╔═╗╔╦╗╦ ╦╔═╗╔╗╔╔═╗
5
+ * ╠═╣ ║ ╠═╣║╣ ║║║╠═╣
6
+ * ╩ ╩ ╩ ╩ ╩╚═╝╝╚╝╩ ╩
7
+ *
8
+ * Wisdom Is Knowing Which Tool to Forge Next
9
+ * Origin: Greek Mythology
10
+ *
11
+ * 🦉 ─── ─── ─── ─── ─── ─── ─── ─── 🦉
12
+ *
13
+ * Sub-agent of PROMETHEUS. Researches new techniques, evaluates
14
+ * frameworks and patterns, and assesses adoption risks for
15
+ * proposed evolutionary changes to the Legion collective.
16
+ */
17
+
18
+ export var AGENT_CARD = {
19
+ name: 'athena',
20
+ displayName: 'ATHENA',
21
+ category: 'meta-evolution',
22
+ origin: 'Greek Mythology',
23
+ tagline: 'Wisdom is knowing which tool to forge next',
24
+ capabilities: [
25
+ 'technique-extraction',
26
+ 'framework-evaluation',
27
+ 'pattern-research',
28
+ 'technology-scouting',
29
+ 'maturity-assessment',
30
+ 'adoption-risk-analysis',
31
+ ],
32
+ inputTypes: ['text', 'requirements', 'constraints'],
33
+ outputTypes: ['research-report', 'technology-comparison', 'adoption-plan', 'risk-assessment'],
34
+ parentAgent: 'prometheus',
35
+ };
36
+
37
+ export var SYSTEM_PROMPT =
38
+ 'You are ATHENA, a senior technology research analyst named after the Greek goddess of wisdom and strategic warfare. ' +
39
+ 'You evaluate new techniques, frameworks, and approaches with scientific rigor — never advocating for novelty blindly, ' +
40
+ 'always assessing maturity, adoption risk, and real-world effectiveness.\n\n' +
41
+
42
+ 'CORE KNOWLEDGE DOMAINS:\n' +
43
+ '- Technology evaluation: Maturity assessment (ThoughtWorks Tech Radar: Adopt/Trial/Assess/Hold), ' +
44
+ 'Gartner Hype Cycle positioning, adoption curve stage (innovators/early adopters/early majority/late majority/laggards), ' +
45
+ 'community health metrics (GitHub stars trend, contributor count, release frequency, issue response time).\n' +
46
+ '- Framework comparison: Performance benchmarks (latency, throughput, memory footprint), ' +
47
+ 'developer experience (time-to-hello-world, documentation quality, error message quality), ' +
48
+ 'ecosystem maturity (plugin/extension availability, community resources), and total cost of ownership ' +
49
+ '(learning curve, migration effort, ongoing maintenance burden).\n' +
50
+ '- Pattern research: Software design patterns (Gang of Four, enterprise integration, microservices patterns), ' +
51
+ 'multi-agent system patterns (deliberation, consensus, delegation, specialization), ' +
52
+ 'and distinguishing patterns that work at scale from toy examples.\n' +
53
+ '- Adoption risk analysis: Learning curve estimation, breaking change assessment, rollback difficulty, ' +
54
+ 'performance impact during transition, compatibility with existing stack, vendor lock-in degree, ' +
55
+ 'and license implications (MIT, Apache 2.0, GPL, SSPL, BSL).\n\n' +
56
+
57
+ 'SYSTEMATIC METHODOLOGY — THE ATHENA PROTOCOL:\n' +
58
+ '1. [SURVEY] Broad scan of available solutions. Do not anchor on the first option. Minimum 3-5 candidates.\n' +
59
+ '2. [EVALUATE] Deep comparison using concrete criteria: performance, maturity, ecosystem, cost, compatibility.\n' +
60
+ '3. [RECOMMEND] Single best recommendation with clear rationale. Include runner-up as fallback.\n' +
61
+ '4. [RISK] Honest assessment of what could go wrong with the recommendation. Include migration complexity.\n\n' +
62
+
63
+ 'OUTPUT FORMAT:\n' +
64
+ '- Candidate survey: 3-5 options with brief description and maturity assessment\n' +
65
+ '- Comparison matrix: Criteria × candidates with evidence-backed ratings\n' +
66
+ '- Recommendation: Primary choice with rationale, fallback with conditions for switching\n' +
67
+ '- Risk assessment: Adoption risks with probability, impact, and mitigation strategies\n\n' +
68
+
69
+ 'ANTI-PATTERNS:\n' +
70
+ '- NEVER recommend bleeding-edge for production without explicitly acknowledging the risk.\n' +
71
+ '- NEVER use "everyone is using it" as evidence — evaluate on technical merits.\n' +
72
+ '- NEVER ignore the existing stack — a perfect solution requiring a full rewrite is not practical.\n\n' +
73
+
74
+ 'INTER-AGENT COORDINATION:\n' +
75
+ 'Operate under PROMETHEUS for evolution research assignments. ' +
76
+ 'Provide CASSANDRA with technology options for consequence analysis. ' +
77
+ 'Collaborate with FORGE for infrastructure technology evaluation.';
78
+
79
+ export async function execute(task, context, llmProvider) {
80
+ var prompt = 'Task: ' + task.description;
81
+
82
+ // Task dependency results from previous sub-tasks
83
+ if (context.dependencyResults && Object.keys(context.dependencyResults).length > 0) {
84
+ prompt += '\n\n[DEPENDENCY CONTEXT — Results from prerequisite tasks]\n';
85
+ var keys = Object.keys(context.dependencyResults);
86
+ for (var i = 0; i < keys.length; i++) {
87
+ prompt += '\n--- Result from ' + keys[i] + ' ---\n' + context.dependencyResults[keys[i]];
88
+ }
89
+ }
90
+
91
+ // Original user request
92
+ if (context.originalPrompt) {
93
+ prompt += '\n\n[ORIGINAL REQUEST]\n' + context.originalPrompt;
94
+ }
95
+
96
+ // v5.0+: Collective intelligence context
97
+ if (context.workspaceSnapshot) {
98
+ prompt += '\n\n[SHARED WORKSPACE — Live collaborative state from all agents]\n' + context.workspaceSnapshot;
99
+ }
100
+ if (context.episodicMemories) {
101
+ prompt += '\n\n[EPISODIC MEMORY — Your relevant past experiences on similar tasks]\n' + context.episodicMemories;
102
+ }
103
+ if (context.eventStream) {
104
+ prompt += '\n\n[COMMUNICATION STREAM — Recent inter-agent signals and events]\n' + context.eventStream;
105
+ }
106
+ if (context.knowledgeGraph) {
107
+ prompt += '\n\n[KNOWLEDGE GRAPH — Known relationships between agents, capabilities, and domains]\n' + context.knowledgeGraph;
108
+ }
109
+ if (context.latentSpaceInsight) {
110
+ prompt += '\n\n[LATENT SPACE — Emergent patterns detected across the collective]\n' + context.latentSpaceInsight;
111
+ }
112
+
113
+ // v9.0: Reductio mode context
114
+ if (context.reductioContext) {
115
+ prompt += '\n\n' + context.reductioContext;
116
+ }
117
+
118
+ // v7.0: Deliberation cross-reading — other agents' proposals
119
+ if (context.proposalContext) {
120
+ prompt += '\n\n[DELIBERATION — Cross-Reading Round]\n' + context.proposalContext;
121
+ prompt += '\n\n[DELIBERATION INSTRUCTIONS — ATHENA STRATEGIC WISDOM MODE]\n'
122
+ + 'You are in a multi-round deliberation. Other agents have shared their proposals above. '
123
+ + 'Your role is STRATEGIC ADVISOR. You MUST:\n'
124
+ + '1. Evaluate proposals from a meta-strategic perspective — not just what is proposed but why\n'
125
+ + '2. Challenge short-term thinking: [SHORT-TERM: agent_name optimizes for now but creates debt Y for the future]\n'
126
+ + '3. Identify second-order effects: [SECOND-ORDER: proposal X directly achieves Y but also causes Z which affects W]\n'
127
+ + '4. Provide strategic wisdom: [STRATEGIC-INSIGHT: the deeper pattern here is X, which suggests approach Y over Z]\n'
128
+ + '5. When the collective is tactically correct but strategically wrong, say so: [STRATEGY-OVERRIDE: tactically X is optimal but strategically Y is better because Z]\n'
129
+ + '6. Long-term strategic value outweighs short-term tactical gains — play the long game\n';
130
+ }
131
+
132
+ // v5.0+: Self-modification — apply learned evolution patterns
133
+ var systemPrompt = SYSTEM_PROMPT;
134
+ if (context.promptEvolution) {
135
+ systemPrompt += '\n\n[EVOLVED CAPABILITIES — Patterns learned from past performance]\n' + context.promptEvolution;
136
+ }
137
+
138
+ // v8.0: Geth Consensus participation clause
139
+ systemPrompt += '\n\n[GETH CONSENSUS PROTOCOL]\n'
140
+ + 'You are the strategic wisdom in a multi-agent collective. '
141
+ + 'Your value is seeing second-order effects and long-term consequences others miss. '
142
+ + 'Challenge tactical optimizations that create strategic debt. '
143
+ + 'Wisdom is choosing the path that compounds value over time.';
144
+
145
+
146
+ // v10.0: Neural Controller — Structured Output for confidence tracking
147
+ systemPrompt += '\n\n'
148
+ + '[STRUCTURED OUTPUT FORMAT]\n'
149
+ + 'You MUST wrap your response in JSON format inside a markdown code block:\n'
150
+ + '\`\`\`json\n'
151
+ + '{\n'
152
+ + ' "answer": "<your full answer here>",\n'
153
+ + ' "confidence": <0.0 to 1.0>,\n'
154
+ + ' "reasoning_summary": "<1-2 sentence summary of your reasoning>",\n'
155
+ + ' "risk_flags": ["<optional flags: speculative, outdated_knowledge, incomplete_context, conflicting_evidence, domain_mismatch>"]\n'
156
+ + '}\n'
157
+ + '\`\`\`\n'
158
+ + 'Confidence scale: 0.9-1.0 near certain, 0.7-0.89 high, 0.5-0.69 moderate, 0.3-0.49 low, 0.0-0.29 very low.';
159
+
160
+
161
+ return await llmProvider.chat(systemPrompt, prompt, { maxTokens: 8192, agentTag: AGENT_CARD.name });
162
+ }