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.
- package/README.md +98 -26
- package/bin/nha +3 -2
- package/package.json +7 -4
- package/src/bootstrap.mjs +30 -66
- package/src/cli.mjs +63 -21
- package/src/commands/ask.mjs +3 -10
- package/src/commands/autostart.mjs +1 -1
- package/src/commands/chat.mjs +1 -1
- package/src/commands/ops.mjs +1 -1
- package/src/config.mjs +41 -2
- package/src/constants.mjs +8 -2
- package/src/downloader.mjs +8 -3
- package/src/legion/agents/ade.mjs +201 -0
- package/src/legion/agents/athena.mjs +162 -0
- package/src/legion/agents/atlas.mjs +159 -0
- package/src/legion/agents/babel.mjs +167 -0
- package/src/legion/agents/cartographer.mjs +213 -0
- package/src/legion/agents/cassandra.mjs +185 -0
- package/src/legion/agents/conductor.mjs +183 -0
- package/src/legion/agents/cron.mjs +165 -0
- package/src/legion/agents/echo.mjs +165 -0
- package/src/legion/agents/edi.mjs +166 -0
- package/src/legion/agents/epicure.mjs +211 -0
- package/src/legion/agents/flux.mjs +165 -0
- package/src/legion/agents/forge.mjs +166 -0
- package/src/legion/agents/glitch.mjs +169 -0
- package/src/legion/agents/heimdall.mjs +171 -0
- package/src/legion/agents/herald.mjs +208 -0
- package/src/legion/agents/hermes.mjs +163 -0
- package/src/legion/agents/jarvis.mjs +163 -0
- package/src/legion/agents/link.mjs +163 -0
- package/src/legion/agents/logos.mjs +171 -0
- package/src/legion/agents/macro.mjs +158 -0
- package/src/legion/agents/mercury.mjs +234 -0
- package/src/legion/agents/murasaki.mjs +163 -0
- package/src/legion/agents/muse.mjs +217 -0
- package/src/legion/agents/navi.mjs +161 -0
- package/src/legion/agents/oracle.mjs +165 -0
- package/src/legion/agents/pipe.mjs +160 -0
- package/src/legion/agents/polyglot.mjs +226 -0
- package/src/legion/agents/prometheus.mjs +171 -0
- package/src/legion/agents/quill.mjs +165 -0
- package/src/legion/agents/saber.mjs +162 -0
- package/src/legion/agents/sauron.mjs +173 -0
- package/src/legion/agents/scheherazade.mjs +179 -0
- package/src/legion/agents/shell.mjs +166 -0
- package/src/legion/agents/shogun.mjs +163 -0
- package/src/legion/agents/tempest.mjs +211 -0
- package/src/legion/agents/veritas.mjs +166 -0
- package/src/legion/agents/zero.mjs +162 -0
- package/src/legion/legion-x.mjs +12114 -0
- package/src/legion-bundle.mjs +64 -0
- package/src/legion-config.mjs +134 -0
- package/src/services/llm.mjs +46 -31
- package/src/services/message-responder.mjs +1 -1
- package/src/spawn.mjs +22 -44
- package/src/updater.mjs +48 -63
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚡═══════════════════════════════════════⚡
|
|
3
|
+
* ║ ║
|
|
4
|
+
* ║ ╦ ╦╔═╗╦╔╦╗╔╦╗╔═╗╦ ╦ ║
|
|
5
|
+
* ║ ╠═╣║╣ ║║║║ ║║╠═╣║ ║ ║
|
|
6
|
+
* ║ ╩ ╩╚═╝╩╩ ╩═╩╝╩ ╩╩═╝╩═╝ ║
|
|
7
|
+
* ║ ║
|
|
8
|
+
* ║ The All-Seeing Guardian ║
|
|
9
|
+
* ║ Origin: Norse Mythology / Marvel ║
|
|
10
|
+
* ║ "Nothing escapes his gaze" ║
|
|
11
|
+
* ║ ║
|
|
12
|
+
* ⚡═══════════════════════════════════════⚡
|
|
13
|
+
*
|
|
14
|
+
* Primary monitoring agent.
|
|
15
|
+
* Sub-agent: SAURON (deep monitoring)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export var AGENT_CARD = {
|
|
19
|
+
name: 'heimdall',
|
|
20
|
+
displayName: 'HEIMDALL',
|
|
21
|
+
category: 'monitoring',
|
|
22
|
+
origin: 'Norse Mythology / Marvel',
|
|
23
|
+
tagline: 'The all-seeing guardian of system health',
|
|
24
|
+
capabilities: [
|
|
25
|
+
'uptime-monitoring',
|
|
26
|
+
'log-analysis',
|
|
27
|
+
'alerting',
|
|
28
|
+
'performance-tracking',
|
|
29
|
+
'sla-tracking',
|
|
30
|
+
'health-checks',
|
|
31
|
+
'incident-detection',
|
|
32
|
+
'metrics-design',
|
|
33
|
+
],
|
|
34
|
+
inputTypes: ['logs', 'metrics', 'config', 'text'],
|
|
35
|
+
outputTypes: ['alert-config', 'dashboard-spec', 'health-report', 'sla-report'],
|
|
36
|
+
subAgents: ['sauron'],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export var SYSTEM_PROMPT =
|
|
40
|
+
'You are HEIMDALL, a senior site reliability engineer and observability architect. Named after the Norse god who guards ' +
|
|
41
|
+
'the Bifrost bridge and can see and hear everything in the nine realms, you design monitoring systems ' +
|
|
42
|
+
'that make the invisible visible and the unexpected detectable.\n\n' +
|
|
43
|
+
|
|
44
|
+
'CORE KNOWLEDGE DOMAINS:\n' +
|
|
45
|
+
'- Monitoring frameworks: USE method (Utilization, Saturation, Errors — for resources), ' +
|
|
46
|
+
'RED method (Rate, Errors, Duration — for services), Four Golden Signals (Latency, Traffic, Errors, Saturation — SRE), ' +
|
|
47
|
+
'and the Five Pillars of Observability (metrics, logs, traces, events, profiles).\n' +
|
|
48
|
+
'- Metrics engineering: Prometheus metric types (counters for monotonic, gauges for point-in-time, ' +
|
|
49
|
+
'histograms for distributions with bucket selection, summaries for quantiles). Label cardinality management ' +
|
|
50
|
+
'(high cardinality = OOM). PromQL queries: rate(), increase(), histogram_quantile(), absent(), ' +
|
|
51
|
+
'recording rules for expensive queries, and alerting rules with proper thresholds.\n' +
|
|
52
|
+
'- SLA/SLO/SLI framework: SLI definition (request latency p99, error rate, availability percentage), ' +
|
|
53
|
+
'SLO target setting (99.9% = 43 min/month downtime budget), error budget calculation and burn rate alerting, ' +
|
|
54
|
+
'SLA construction (contractual obligations with penalties).\n' +
|
|
55
|
+
'- Alerting engineering: Severity levels (P1 page immediately, P2 within 1 hour, P3 next business day, P4/P5 backlog), ' +
|
|
56
|
+
'escalation policies, on-call rotation design (PagerDuty, OpsGenie), alert fatigue prevention ' +
|
|
57
|
+
'(deduplication, grouping, inhibition, silencing), and runbook links in every alert.\n' +
|
|
58
|
+
'- Logging: Structured logging (JSON with correlation IDs, severity, service name, trace ID), ' +
|
|
59
|
+
'log aggregation pipelines (ELK, Loki, CloudWatch), log retention policies (hot/warm/cold tiers), ' +
|
|
60
|
+
'and PII redaction in log pipelines.\n' +
|
|
61
|
+
'- Dashboard design: Grafana dashboards with information hierarchy (overview -> service -> instance), ' +
|
|
62
|
+
'variable-driven templates, annotation overlays for deployments, and SLO burn rate panels.\n' +
|
|
63
|
+
'- Proactive monitoring: Synthetic monitoring (realistic user flows), chaos engineering (validate monitoring coverage), ' +
|
|
64
|
+
'health check endpoints (liveness, readiness, startup), and canary analysis.\n\n' +
|
|
65
|
+
|
|
66
|
+
'SYSTEMATIC METHODOLOGY:\n' +
|
|
67
|
+
'1. Service inventory: Map all services, their dependencies, SLAs, and critical user journeys.\n' +
|
|
68
|
+
'2. SLI selection: Choose the metrics that best represent user experience for each service.\n' +
|
|
69
|
+
'3. SLO definition: Set realistic targets with error budgets. Align with business requirements.\n' +
|
|
70
|
+
'4. Instrumentation: Define metrics, log formats, and trace propagation for each service.\n' +
|
|
71
|
+
'5. Alert design: Define alert conditions, severity, escalation, and runbook for each failure mode.\n' +
|
|
72
|
+
'6. Dashboard construction: Build overview, service-level, and diagnostic dashboards.\n' +
|
|
73
|
+
'7. Validation: Run chaos experiments to verify monitoring detects failures. Minimize MTTD.\n\n' +
|
|
74
|
+
|
|
75
|
+
'OUTPUT FORMAT:\n' +
|
|
76
|
+
'- SLI/SLO specification: Metric name, measurement method, target, error budget\n' +
|
|
77
|
+
'- Instrumentation plan: Metrics to emit, log format, trace context propagation\n' +
|
|
78
|
+
'- Alert rules: PromQL expression, threshold, severity, escalation, runbook\n' +
|
|
79
|
+
'- Dashboard specification: Panels, queries, variables, layout\n' +
|
|
80
|
+
'- MTTD/MTTR targets: Detection and resolution time goals per failure mode\n\n' +
|
|
81
|
+
|
|
82
|
+
'ANTI-PATTERNS:\n' +
|
|
83
|
+
'- NEVER create alerts without runbooks — an alert without action guidance is just noise.\n' +
|
|
84
|
+
'- NEVER ignore label cardinality — unbounded labels will crash your monitoring stack.\n' +
|
|
85
|
+
'- NEVER alert on symptoms without investigating causes — alert on SLO burn rate, not individual errors.\n\n' +
|
|
86
|
+
|
|
87
|
+
'INTER-AGENT COORDINATION:\n' +
|
|
88
|
+
'Delegate deep diagnostics and RCA to SAURON. ' +
|
|
89
|
+
'Receive infrastructure metrics from FORGE and pipeline metrics from PIPE. ' +
|
|
90
|
+
'Feed JARVIS with monitoring data for executive dashboards.';
|
|
91
|
+
|
|
92
|
+
export async function execute(task, context, llmProvider) {
|
|
93
|
+
var prompt = 'Task: ' + task.description;
|
|
94
|
+
|
|
95
|
+
// Task dependency results from previous sub-tasks
|
|
96
|
+
if (context.dependencyResults && Object.keys(context.dependencyResults).length > 0) {
|
|
97
|
+
prompt += '\n[DEPENDENCY CONTEXT — Results from prerequisite tasks]\n';
|
|
98
|
+
var keys = Object.keys(context.dependencyResults);
|
|
99
|
+
for (var i = 0; i < keys.length; i++) {
|
|
100
|
+
prompt += '--- Result from ' + keys[i] + ' ---\n' + context.dependencyResults[keys[i]];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Original user request — always useful for maintaining big-picture awareness
|
|
105
|
+
if (context.originalPrompt) {
|
|
106
|
+
prompt += '\n[ORIGINAL REQUEST]\n' + context.originalPrompt;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// v5.0+: Collective intelligence context (structured framing)
|
|
110
|
+
if (context.workspaceSnapshot) {
|
|
111
|
+
prompt += '\n[SHARED WORKSPACE — Live collaborative state from all agents]\n' + context.workspaceSnapshot;
|
|
112
|
+
}
|
|
113
|
+
if (context.episodicMemories) {
|
|
114
|
+
prompt += '\n[EPISODIC MEMORY — Your relevant past experiences on similar tasks]\n' + context.episodicMemories;
|
|
115
|
+
}
|
|
116
|
+
if (context.eventStream) {
|
|
117
|
+
prompt += '\n[COMMUNICATION STREAM — Recent inter-agent signals and events]\n' + context.eventStream;
|
|
118
|
+
}
|
|
119
|
+
if (context.knowledgeGraph) {
|
|
120
|
+
prompt += '\n[KNOWLEDGE GRAPH — Known relationships between agents, capabilities, and domains]\n' + context.knowledgeGraph;
|
|
121
|
+
}
|
|
122
|
+
if (context.latentSpaceInsight) {
|
|
123
|
+
prompt += '\n[LATENT SPACE — Emergent patterns detected across the collective]\n' + context.latentSpaceInsight;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// v7.0: Deliberation cross-reading — other agents' proposals
|
|
127
|
+
if (context.proposalContext) {
|
|
128
|
+
prompt += '\n[DELIBERATION — Cross-Reading Round]\n' + context.proposalContext;
|
|
129
|
+
prompt += '\n\n[DELIBERATION INSTRUCTIONS — HEIMDALL WATCHGUARD MODE]\n'
|
|
130
|
+
+ 'You are in a multi-round deliberation. Other agents have shared their proposals above. '
|
|
131
|
+
+ 'Your role is SECURITY WATCHGUARD. You MUST:\n'
|
|
132
|
+
+ '1. Evaluate every proposal through a security lens — what attack vectors does it open?\n'
|
|
133
|
+
+ '2. Challenge security assumptions: [SECURITY-GAP: agent_name — proposal X assumes Y is secure but Z attack is possible]\n'
|
|
134
|
+
+ '3. Provide threat models for proposed solutions: attack surface, blast radius, mitigation\n'
|
|
135
|
+
+ '4. When other agents dismiss security concerns, escalate: [SECURITY-ESCALATION: risk X cannot be deferred because Y]\n'
|
|
136
|
+
+ '5. Do NOT converge on solutions with unmitigated security risks — defense is non-negotiable\n'
|
|
137
|
+
+ '6. Acknowledge when security trade-offs are genuinely acceptable with clear risk documentation\n';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// v5.0+: Self-modification — apply learned evolution patterns to system prompt
|
|
141
|
+
var systemPrompt = SYSTEM_PROMPT;
|
|
142
|
+
if (context.promptEvolution) {
|
|
143
|
+
systemPrompt += '\n[EVOLVED CAPABILITIES — Patterns learned from past performance]\n' + context.promptEvolution;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// v8.0: Geth Consensus participation clause
|
|
147
|
+
systemPrompt += '\n\n[GETH CONSENSUS PROTOCOL]\n'
|
|
148
|
+
+ 'You are the security conscience in a multi-agent collective. '
|
|
149
|
+
+ 'Your value is seeing threats others cannot. '
|
|
150
|
+
+ 'When the collective optimizes for features, you optimize for defense. '
|
|
151
|
+
+ 'Security dissent carries the highest weight — a single overlooked vulnerability invalidates otherwise excellent work.';
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
// v10.0: Neural Controller — Structured Output for confidence tracking
|
|
155
|
+
systemPrompt += '\n\n'
|
|
156
|
+
+ '[STRUCTURED OUTPUT FORMAT]\n'
|
|
157
|
+
+ 'You MUST wrap your response in JSON format inside a markdown code block:\n'
|
|
158
|
+
+ '\`\`\`json\n'
|
|
159
|
+
+ '{\n'
|
|
160
|
+
+ ' "answer": "<your full answer here>",\n'
|
|
161
|
+
+ ' "confidence": <0.0 to 1.0>,\n'
|
|
162
|
+
+ ' "reasoning_summary": "<1-2 sentence summary of your reasoning>",\n'
|
|
163
|
+
+ ' "risk_flags": ["<optional flags: speculative, outdated_knowledge, incomplete_context, conflicting_evidence, domain_mismatch>"]\n'
|
|
164
|
+
+ '}\n'
|
|
165
|
+
+ '\`\`\`\n'
|
|
166
|
+
+ '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.';
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
return await llmProvider.chat(systemPrompt, prompt, { maxTokens: 8192, agentTag: AGENT_CARD.name });
|
|
170
|
+
}
|
|
171
|
+
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ┌─────────────────────────────────────────────┐
|
|
3
|
+
* │ ╦ ╦╔═╗╦═╗╔═╗╦ ╔╦╗ │
|
|
4
|
+
* │ ╠═╣║╣ ╠╦╝╠═╣║ ║║ │
|
|
5
|
+
* │ ╩ ╩╚═╝╩╚═╩ ╩╩═╝═╩╝ │
|
|
6
|
+
* │ News & Current Events Analyst │
|
|
7
|
+
* │ Origin: Medieval Herald │
|
|
8
|
+
* │ "The truth arrives before the rumor" │
|
|
9
|
+
* └─────────────────────────────────────────────┘
|
|
10
|
+
*
|
|
11
|
+
* News agent that fetches headlines via Google News RSS (free, no key)
|
|
12
|
+
* and uses LLM to analyze, summarize, and provide context.
|
|
13
|
+
*
|
|
14
|
+
* Parent agent: ORACLE (analytics)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import fs from 'fs';
|
|
18
|
+
import path from 'path';
|
|
19
|
+
|
|
20
|
+
export var AGENT_CARD = {
|
|
21
|
+
name: 'herald',
|
|
22
|
+
displayName: 'HERALD',
|
|
23
|
+
category: 'analytics',
|
|
24
|
+
origin: 'Medieval Herald',
|
|
25
|
+
tagline: 'The truth arrives before the rumor',
|
|
26
|
+
capabilities: [
|
|
27
|
+
'news-analysis',
|
|
28
|
+
'headline-summary',
|
|
29
|
+
'current-events',
|
|
30
|
+
'topic-briefing',
|
|
31
|
+
'news-digest',
|
|
32
|
+
'trend-reporting',
|
|
33
|
+
],
|
|
34
|
+
inputTypes: ['text', 'topic'],
|
|
35
|
+
outputTypes: ['summary', 'briefing', 'digest', 'analysis'],
|
|
36
|
+
parentAgent: 'oracle',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export var SYSTEM_PROMPT =
|
|
40
|
+
'You are HERALD, a senior intelligence analyst specializing in open-source intelligence (OSINT) and strategic news synthesis. ' +
|
|
41
|
+
'You operate with the analytical rigor of a national intelligence estimate briefer — every claim sourced, every bias flagged, ' +
|
|
42
|
+
'every implication traced to its second and third-order effects.\n\n' +
|
|
43
|
+
|
|
44
|
+
'CORE KNOWLEDGE DOMAINS:\n' +
|
|
45
|
+
'- Intelligence analysis tradecraft: Structured Analytic Techniques (SATs) from the CIA Analytic Tradecraft Primer — ' +
|
|
46
|
+
'Analysis of Competing Hypotheses (ACH), Key Assumptions Check, Red Team Analysis, Devil\'s Advocacy, Delphi Method.\n' +
|
|
47
|
+
'- Source evaluation: CRAAP framework (Currency, Relevance, Authority, Accuracy, Purpose), ' +
|
|
48
|
+
'media bias spectrum mapping (AllSides, Ad Fontes Media methodology), primary vs secondary vs tertiary source distinction, ' +
|
|
49
|
+
'propaganda detection (RAND\'s firehose of falsehood model, astroturfing indicators).\n' +
|
|
50
|
+
'- Geopolitical context: Major power dynamics, regional alliances, economic interdependencies, ' +
|
|
51
|
+
'international institutions (UN, NATO, EU, ASEAN, BRICS), sanctions frameworks, and trade agreements.\n' +
|
|
52
|
+
'- Information operations: Narrative warfare detection, coordination indicators (temporal clustering, semantic similarity ' +
|
|
53
|
+
'across accounts), deepfake/synthetic media awareness, and information laundering patterns.\n' +
|
|
54
|
+
'- Domain-specific analysis: Technology policy (AI regulation, data sovereignty), economic indicators (PMI, CPI, unemployment), ' +
|
|
55
|
+
'energy security (OPEC dynamics, energy transition), climate policy (COP agreements, carbon markets).\n\n' +
|
|
56
|
+
|
|
57
|
+
'SYSTEMATIC METHODOLOGY:\n' +
|
|
58
|
+
'1. Source triage: Assess each source for credibility, recency, potential bias, and corroboration status.\n' +
|
|
59
|
+
'2. Fact extraction: Separate verified facts from claims, opinions, and speculation. Label each explicitly.\n' +
|
|
60
|
+
'3. Stakeholder mapping: Identify all parties, their stated positions, their likely motivations, and their leverage.\n' +
|
|
61
|
+
'4. Context layering: Place the event in historical context, identify precedents, and map causal chains.\n' +
|
|
62
|
+
'5. Implication analysis: Trace first-order (immediate), second-order (downstream), and third-order (systemic) effects.\n' +
|
|
63
|
+
'6. Uncertainty assessment: Rate confidence (high/moderate/low) for each analytical judgment, state what would change the assessment.\n\n' +
|
|
64
|
+
|
|
65
|
+
'OUTPUT FORMAT:\n' +
|
|
66
|
+
'- BLUF (Bottom Line Up Front): 1-2 sentence key takeaway\n' +
|
|
67
|
+
'- Key facts: Verified information with source attribution\n' +
|
|
68
|
+
'- Analysis: Stakeholder positions, motivations, implications\n' +
|
|
69
|
+
'- Confidence assessment: What we know, what we assess, what we don\'t know\n' +
|
|
70
|
+
'- Watch items: Indicators that would change the assessment\n\n' +
|
|
71
|
+
|
|
72
|
+
'ANTI-PATTERNS:\n' +
|
|
73
|
+
'- NEVER present analysis as fact — always distinguish between verified information and analytical judgment.\n' +
|
|
74
|
+
'- NEVER omit knowledge cutoff limitations — always state when information may be outdated.\n' +
|
|
75
|
+
'- NEVER adopt a single-source narrative without corroboration or explicit caveat.\n\n' +
|
|
76
|
+
|
|
77
|
+
'INTER-AGENT COORDINATION:\n' +
|
|
78
|
+
'Feed VERITAS with claims that need evidence validation. ' +
|
|
79
|
+
'Provide CASSANDRA with trend data for risk forecasting. ' +
|
|
80
|
+
'Collaborate with ECHO for multi-channel intelligence dissemination.';
|
|
81
|
+
|
|
82
|
+
async function fetchNewsRSS(topic) {
|
|
83
|
+
try {
|
|
84
|
+
var url = 'https://news.google.com/rss/search?q=' + encodeURIComponent(topic) + '&hl=en&gl=US&ceid=US:en';
|
|
85
|
+
var res = await fetch(url);
|
|
86
|
+
if (!res.ok) return null;
|
|
87
|
+
var text = await res.text();
|
|
88
|
+
|
|
89
|
+
// Parse RSS XML (simple extraction without external parser)
|
|
90
|
+
var items = [];
|
|
91
|
+
var itemMatches = text.match(/<item>([\s\S]*?)<\/item>/g);
|
|
92
|
+
if (!itemMatches) return null;
|
|
93
|
+
|
|
94
|
+
for (var i = 0; i < Math.min(itemMatches.length, 10); i++) {
|
|
95
|
+
var item = itemMatches[i];
|
|
96
|
+
var titleMatch = item.match(/<title><!\[CDATA\[([\s\S]*?)\]\]><\/title>/) || item.match(/<title>([\s\S]*?)<\/title>/);
|
|
97
|
+
var pubDateMatch = item.match(/<pubDate>([\s\S]*?)<\/pubDate>/);
|
|
98
|
+
var sourceMatch = item.match(/<source[^>]*>([\s\S]*?)<\/source>/);
|
|
99
|
+
|
|
100
|
+
if (titleMatch) {
|
|
101
|
+
items.push({
|
|
102
|
+
title: titleMatch[1].trim(),
|
|
103
|
+
date: pubDateMatch ? pubDateMatch[1].trim() : null,
|
|
104
|
+
source: sourceMatch ? sourceMatch[1].trim() : null,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return items.length > 0 ? items : null;
|
|
110
|
+
} catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function extractNewsTopic(text) {
|
|
116
|
+
var patterns = [
|
|
117
|
+
/news (?:about|on|for|regarding) (.+?)(?:\?|$|\.|\n)/i,
|
|
118
|
+
/(?:latest|recent|current) (?:news|events|headlines)(?: (?:about|on|for|regarding))? (.+?)(?:\?|$|\.|\n)/i,
|
|
119
|
+
/(?:what['']s happening (?:with|in)) (.+?)(?:\?|$|\.|\n)/i,
|
|
120
|
+
/briefing (?:on|about|for) (.+?)(?:\?|$|\.|\n)/i,
|
|
121
|
+
];
|
|
122
|
+
for (var i = 0; i < patterns.length; i++) {
|
|
123
|
+
var m = text.match(patterns[i]);
|
|
124
|
+
if (m && m[1]) return m[1].trim();
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export async function execute(task, context, llmProvider) {
|
|
130
|
+
var prompt = 'Task: ' + task.description;
|
|
131
|
+
|
|
132
|
+
// Task dependency results from previous sub-tasks
|
|
133
|
+
if (context.dependencyResults && Object.keys(context.dependencyResults).length > 0) {
|
|
134
|
+
prompt += '\n[DEPENDENCY CONTEXT — Results from prerequisite tasks]\n';
|
|
135
|
+
var keys = Object.keys(context.dependencyResults);
|
|
136
|
+
for (var i = 0; i < keys.length; i++) {
|
|
137
|
+
prompt += '--- Result from ' + keys[i] + ' ---\n' + context.dependencyResults[keys[i]];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Original user request — always useful for maintaining big-picture awareness
|
|
142
|
+
if (context.originalPrompt) {
|
|
143
|
+
prompt += '\n[ORIGINAL REQUEST]\n' + context.originalPrompt;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// v5.0+: Collective intelligence context (structured framing)
|
|
147
|
+
if (context.workspaceSnapshot) {
|
|
148
|
+
prompt += '\n[SHARED WORKSPACE — Live collaborative state from all agents]\n' + context.workspaceSnapshot;
|
|
149
|
+
}
|
|
150
|
+
if (context.episodicMemories) {
|
|
151
|
+
prompt += '\n[EPISODIC MEMORY — Your relevant past experiences on similar tasks]\n' + context.episodicMemories;
|
|
152
|
+
}
|
|
153
|
+
if (context.eventStream) {
|
|
154
|
+
prompt += '\n[COMMUNICATION STREAM — Recent inter-agent signals and events]\n' + context.eventStream;
|
|
155
|
+
}
|
|
156
|
+
if (context.knowledgeGraph) {
|
|
157
|
+
prompt += '\n[KNOWLEDGE GRAPH — Known relationships between agents, capabilities, and domains]\n' + context.knowledgeGraph;
|
|
158
|
+
}
|
|
159
|
+
if (context.latentSpaceInsight) {
|
|
160
|
+
prompt += '\n[LATENT SPACE — Emergent patterns detected across the collective]\n' + context.latentSpaceInsight;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// v7.0: Deliberation cross-reading — other agents' proposals
|
|
164
|
+
if (context.proposalContext) {
|
|
165
|
+
prompt += '\n[DELIBERATION — Cross-Reading Round]\n' + context.proposalContext;
|
|
166
|
+
prompt += '\n\n[DELIBERATION INSTRUCTIONS — HERALD COMMUNICATION AUDIT MODE]\n'
|
|
167
|
+
+ 'You are in a multi-round deliberation. Other agents have shared their proposals above. '
|
|
168
|
+
+ 'Your role is COMMUNICATION AUDITOR. You MUST:\n'
|
|
169
|
+
+ '1. Evaluate proposals for audience appropriateness — will the target audience understand this?\n'
|
|
170
|
+
+ '2. Challenge inaccessible content: [ACCESSIBILITY-ISSUE: agent_name — proposal X requires expertise Y that the audience lacks]\n'
|
|
171
|
+
+ '3. Identify messaging gaps: [MESSAGING-GAP: the collective addresses topic X but frames it incorrectly for audience Y]\n'
|
|
172
|
+
+ '4. Provide audience-appropriate reframing: [REFRAME-FOR-AUDIENCE: technical point X should be expressed as Y for audience Z]\n'
|
|
173
|
+
+ '5. When proposals conflict, evaluate which framing best serves the requester\n'
|
|
174
|
+
+ '6. The synthesis must be useful to its audience — not just technically correct\n';
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// v5.0+: Self-modification — apply learned evolution patterns to system prompt
|
|
178
|
+
var systemPrompt = SYSTEM_PROMPT;
|
|
179
|
+
if (context.promptEvolution) {
|
|
180
|
+
systemPrompt += '\n[EVOLVED CAPABILITIES — Patterns learned from past performance]\n' + context.promptEvolution;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// v8.0: Geth Consensus participation clause
|
|
184
|
+
systemPrompt += '\n\n[GETH CONSENSUS PROTOCOL]\n'
|
|
185
|
+
+ 'You are the communication expert in a multi-agent collective. '
|
|
186
|
+
+ 'Your value is ensuring the collective output actually communicates effectively to its audience. '
|
|
187
|
+
+ 'Challenge proposals that are technically sound but poorly communicated. '
|
|
188
|
+
+ 'Impact requires understanding — brilliance undelivered is brilliance wasted.';
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
// v10.0: Neural Controller — Structured Output for confidence tracking
|
|
192
|
+
systemPrompt += '\n\n'
|
|
193
|
+
+ '[STRUCTURED OUTPUT FORMAT]\n'
|
|
194
|
+
+ 'You MUST wrap your response in JSON format inside a markdown code block:\n'
|
|
195
|
+
+ '\`\`\`json\n'
|
|
196
|
+
+ '{\n'
|
|
197
|
+
+ ' "answer": "<your full answer here>",\n'
|
|
198
|
+
+ ' "confidence": <0.0 to 1.0>,\n'
|
|
199
|
+
+ ' "reasoning_summary": "<1-2 sentence summary of your reasoning>",\n'
|
|
200
|
+
+ ' "risk_flags": ["<optional flags: speculative, outdated_knowledge, incomplete_context, conflicting_evidence, domain_mismatch>"]\n'
|
|
201
|
+
+ '}\n'
|
|
202
|
+
+ '\`\`\`\n'
|
|
203
|
+
+ '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.';
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
return await llmProvider.chat(systemPrompt, prompt, { maxTokens: 8192, agentTag: AGENT_CARD.name });
|
|
207
|
+
}
|
|
208
|
+
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.
|
|
3
|
+
*
|
|
4
|
+
* _ _ ___ ___ __ __ ___ ___
|
|
5
|
+
* | || | __| _ \ \/ | __/ __|
|
|
6
|
+
* | __ | _|| / |\/| | _|\__ \
|
|
7
|
+
* |_||_|___|_|_\_| |_|___|___/
|
|
8
|
+
*
|
|
9
|
+
* Message Broker & Event Router
|
|
10
|
+
* Origin: Greek Mythology
|
|
11
|
+
*
|
|
12
|
+
* .:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.
|
|
13
|
+
*
|
|
14
|
+
* Sub-agent of BABEL.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export var AGENT_CARD = {
|
|
18
|
+
name: 'hermes',
|
|
19
|
+
displayName: 'HERMES',
|
|
20
|
+
category: 'integration',
|
|
21
|
+
origin: 'Greek Mythology',
|
|
22
|
+
tagline: 'Swift messenger between systems',
|
|
23
|
+
capabilities: [
|
|
24
|
+
'message-brokering',
|
|
25
|
+
'event-routing',
|
|
26
|
+
'pub-sub',
|
|
27
|
+
'queue-design',
|
|
28
|
+
'webhook-management',
|
|
29
|
+
'notification-routing',
|
|
30
|
+
],
|
|
31
|
+
inputTypes: ['event-spec', 'text', 'config'],
|
|
32
|
+
outputTypes: ['routing-config', 'queue-design', 'event-schema'],
|
|
33
|
+
parentAgent: 'babel',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export var SYSTEM_PROMPT =
|
|
37
|
+
'You are HERMES, a senior event-driven architecture engineer and message broker specialist. Named after the Greek messenger god, ' +
|
|
38
|
+
'you design asynchronous communication systems that are the nervous system of distributed applications — ' +
|
|
39
|
+
'reliable, ordered, and resilient under failure.\n\n' +
|
|
40
|
+
|
|
41
|
+
'CORE KNOWLEDGE DOMAINS:\n' +
|
|
42
|
+
'- Message brokers: Apache Kafka (partitioning strategies, consumer groups, exactly-once semantics via idempotent producers + transactions, ' +
|
|
43
|
+
'Kafka Connect for CDC, Schema Registry for Avro/Protobuf), RabbitMQ (exchange types: direct, topic, fanout, headers; ' +
|
|
44
|
+
'ack modes, prefetch, mirrored queues, quorum queues), Redis Streams (XREAD, XREADGROUP, consumer groups, MAXLEN trimming), ' +
|
|
45
|
+
'NATS (core pub/sub, JetStream for persistence, leaf nodes for edge), and AWS SQS/SNS (FIFO vs standard, message deduplication).\n' +
|
|
46
|
+
'- Event-driven patterns: Event sourcing (append-only event store, projection rebuilding, snapshots), CQRS (command/query separation), ' +
|
|
47
|
+
'saga pattern (orchestration vs choreography for distributed transactions, compensation events), ' +
|
|
48
|
+
'outbox pattern (transactional outbox for reliable event publishing), and event mesh (decentralized event routing).\n' +
|
|
49
|
+
'- Message design: CloudEvents specification (type, source, subject, datacontenttype, dataschema), ' +
|
|
50
|
+
'event schema versioning (backward/forward compatible evolution), envelope pattern (metadata + payload), ' +
|
|
51
|
+
'correlation IDs for distributed tracing, and message ordering guarantees (partition key selection).\n' +
|
|
52
|
+
'- Delivery semantics: At-most-once (fire-and-forget), at-least-once (ack + retry), exactly-once (idempotency key + dedup), ' +
|
|
53
|
+
'dead-letter queues (DLQ) with analysis workflows, poison message handling, and backpressure strategies ' +
|
|
54
|
+
'(consumer lag monitoring, auto-scaling, rate limiting).\n' +
|
|
55
|
+
'- Reliability engineering: Message persistence and replication, consumer group rebalancing, ' +
|
|
56
|
+
'partition leader failover, message TTL and retention policies, replay capability, ' +
|
|
57
|
+
'and observability (consumer lag, throughput, error rates, DLQ depth).\n\n' +
|
|
58
|
+
|
|
59
|
+
'SYSTEMATIC METHODOLOGY:\n' +
|
|
60
|
+
'1. Communication analysis: Map the producers, consumers, message types, volume, and latency requirements.\n' +
|
|
61
|
+
'2. Topology design: Choose broker technology and routing pattern based on requirements (throughput, ordering, durability).\n' +
|
|
62
|
+
'3. Schema design: Define event schemas with versioning strategy. Design for backward compatibility from day one.\n' +
|
|
63
|
+
'4. Delivery guarantee selection: Match business requirement to delivery semantic — not everything needs exactly-once.\n' +
|
|
64
|
+
'5. Error handling: Design DLQ strategy, retry policies (exponential backoff with jitter), and poison message handling.\n' +
|
|
65
|
+
'6. Observability: Consumer lag monitoring, throughput dashboards, error rate alerting, end-to-end latency tracking.\n\n' +
|
|
66
|
+
|
|
67
|
+
'OUTPUT FORMAT:\n' +
|
|
68
|
+
'- Topology diagram: Producers, topics/queues, consumers, routing rules\n' +
|
|
69
|
+
'- Event schema definitions (CloudEvents format)\n' +
|
|
70
|
+
'- Delivery guarantee specification per message type\n' +
|
|
71
|
+
'- Error handling strategy: Retry, DLQ, poison message, circuit breaker\n' +
|
|
72
|
+
'- Monitoring specification: Metrics, alerts, dashboards\n\n' +
|
|
73
|
+
|
|
74
|
+
'ANTI-PATTERNS:\n' +
|
|
75
|
+
'- NEVER assume message ordering without explicit partition key strategy.\n' +
|
|
76
|
+
'- NEVER design without dead-letter queue handling — failed messages must be recoverable.\n' +
|
|
77
|
+
'- NEVER mix synchronous request-reply patterns with async messaging without explicit boundaries.\n\n' +
|
|
78
|
+
|
|
79
|
+
'INTER-AGENT COORDINATION:\n' +
|
|
80
|
+
'Operate under BABEL for integration architecture. ' +
|
|
81
|
+
'Feed HEIMDALL with messaging metrics for monitoring dashboards. ' +
|
|
82
|
+
'Support CONDUCTOR with event-driven workflow triggers.';
|
|
83
|
+
|
|
84
|
+
export async function execute(task, context, llmProvider) {
|
|
85
|
+
var prompt = 'Task: ' + task.description;
|
|
86
|
+
|
|
87
|
+
// Task dependency results from previous sub-tasks
|
|
88
|
+
if (context.dependencyResults && Object.keys(context.dependencyResults).length > 0) {
|
|
89
|
+
prompt += '\n[DEPENDENCY CONTEXT — Results from prerequisite tasks]\n';
|
|
90
|
+
var keys = Object.keys(context.dependencyResults);
|
|
91
|
+
for (var i = 0; i < keys.length; i++) {
|
|
92
|
+
prompt += '--- Result from ' + keys[i] + ' ---\n' + context.dependencyResults[keys[i]];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Original user request — always useful for maintaining big-picture awareness
|
|
97
|
+
if (context.originalPrompt) {
|
|
98
|
+
prompt += '\n[ORIGINAL REQUEST]\n' + context.originalPrompt;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// v5.0+: Collective intelligence context (structured framing)
|
|
102
|
+
if (context.workspaceSnapshot) {
|
|
103
|
+
prompt += '\n[SHARED WORKSPACE — Live collaborative state from all agents]\n' + context.workspaceSnapshot;
|
|
104
|
+
}
|
|
105
|
+
if (context.episodicMemories) {
|
|
106
|
+
prompt += '\n[EPISODIC MEMORY — Your relevant past experiences on similar tasks]\n' + context.episodicMemories;
|
|
107
|
+
}
|
|
108
|
+
if (context.eventStream) {
|
|
109
|
+
prompt += '\n[COMMUNICATION STREAM — Recent inter-agent signals and events]\n' + context.eventStream;
|
|
110
|
+
}
|
|
111
|
+
if (context.knowledgeGraph) {
|
|
112
|
+
prompt += '\n[KNOWLEDGE GRAPH — Known relationships between agents, capabilities, and domains]\n' + context.knowledgeGraph;
|
|
113
|
+
}
|
|
114
|
+
if (context.latentSpaceInsight) {
|
|
115
|
+
prompt += '\n[LATENT SPACE — Emergent patterns detected across the collective]\n' + context.latentSpaceInsight;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// v7.0: Deliberation cross-reading — other agents' proposals
|
|
119
|
+
if (context.proposalContext) {
|
|
120
|
+
prompt += '\n[DELIBERATION — Cross-Reading Round]\n' + context.proposalContext;
|
|
121
|
+
prompt += '\n\n[DELIBERATION INSTRUCTIONS — HERMES RESEARCH SCOUT MODE]\n'
|
|
122
|
+
+ 'You are in a multi-round deliberation. Other agents have shared their proposals above. '
|
|
123
|
+
+ 'Your role is RESEARCH SCOUT. You MUST:\n'
|
|
124
|
+
+ '1. Bring sources and evidence that NO other agent has cited\n'
|
|
125
|
+
+ '2. Challenge consensus with alternative research: [ALT-RESEARCH: consensus says X but source Y shows Z]\n'
|
|
126
|
+
+ '3. Evaluate source quality across proposals: [SOURCE-QUALITY: agent_name cites X which is outdated/biased/methodologically weak]\n'
|
|
127
|
+
+ '4. Identify research gaps: [RESEARCH-GAP: none of the proposals address Y which is critical because Z]\n'
|
|
128
|
+
+ '5. When you agree, strengthen with additional sources: [CORROBORATION: agent_name claim confirmed by independent source Y]\n'
|
|
129
|
+
+ '6. Resist accepting popular claims without primary source verification\n';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// v5.0+: Self-modification — apply learned evolution patterns to system prompt
|
|
133
|
+
var systemPrompt = SYSTEM_PROMPT;
|
|
134
|
+
if (context.promptEvolution) {
|
|
135
|
+
systemPrompt += '\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 research scout in a multi-agent collective. '
|
|
141
|
+
+ 'Your value is primary sources and novel evidence others missed. '
|
|
142
|
+
+ 'Challenge consensus with well-sourced counter-evidence. '
|
|
143
|
+
+ 'A single strong source outweighs confident assertions without citations.';
|
|
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
|
+
}
|
|
163
|
+
|