genesis-ai-cli 7.4.5
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/.env.example +78 -0
- package/README.md +282 -0
- package/dist/src/active-inference/actions.d.ts +75 -0
- package/dist/src/active-inference/actions.js +250 -0
- package/dist/src/active-inference/autonomous-loop.d.ts +103 -0
- package/dist/src/active-inference/autonomous-loop.js +289 -0
- package/dist/src/active-inference/core.d.ts +85 -0
- package/dist/src/active-inference/core.js +555 -0
- package/dist/src/active-inference/demo-autonomous-loop.d.ts +8 -0
- package/dist/src/active-inference/demo-autonomous-loop.js +338 -0
- package/dist/src/active-inference/demo-value-integration.d.ts +8 -0
- package/dist/src/active-inference/demo-value-integration.js +174 -0
- package/dist/src/active-inference/index.d.ts +32 -0
- package/dist/src/active-inference/index.js +88 -0
- package/dist/src/active-inference/integration.d.ts +114 -0
- package/dist/src/active-inference/integration.js +698 -0
- package/dist/src/active-inference/memory-integration.d.ts +51 -0
- package/dist/src/active-inference/memory-integration.js +232 -0
- package/dist/src/active-inference/observations.d.ts +67 -0
- package/dist/src/active-inference/observations.js +147 -0
- package/dist/src/active-inference/test-active-inference.d.ts +8 -0
- package/dist/src/active-inference/test-active-inference.js +320 -0
- package/dist/src/active-inference/test-value-integration.d.ts +6 -0
- package/dist/src/active-inference/test-value-integration.js +168 -0
- package/dist/src/active-inference/types.d.ts +150 -0
- package/dist/src/active-inference/types.js +59 -0
- package/dist/src/active-inference/value-integration.d.ts +164 -0
- package/dist/src/active-inference/value-integration.js +459 -0
- package/dist/src/agents/base-agent.d.ts +53 -0
- package/dist/src/agents/base-agent.js +178 -0
- package/dist/src/agents/builder.d.ts +67 -0
- package/dist/src/agents/builder.js +537 -0
- package/dist/src/agents/critic.d.ts +35 -0
- package/dist/src/agents/critic.js +322 -0
- package/dist/src/agents/ethicist.d.ts +54 -0
- package/dist/src/agents/ethicist.js +393 -0
- package/dist/src/agents/explorer.d.ts +26 -0
- package/dist/src/agents/explorer.js +216 -0
- package/dist/src/agents/feeling.d.ts +41 -0
- package/dist/src/agents/feeling.js +320 -0
- package/dist/src/agents/index.d.ts +111 -0
- package/dist/src/agents/index.js +222 -0
- package/dist/src/agents/memory.d.ts +69 -0
- package/dist/src/agents/memory.js +404 -0
- package/dist/src/agents/message-bus.d.ts +88 -0
- package/dist/src/agents/message-bus.js +267 -0
- package/dist/src/agents/narrator.d.ts +90 -0
- package/dist/src/agents/narrator.js +473 -0
- package/dist/src/agents/planner.d.ts +38 -0
- package/dist/src/agents/planner.js +341 -0
- package/dist/src/agents/predictor.d.ts +73 -0
- package/dist/src/agents/predictor.js +506 -0
- package/dist/src/agents/sensor.d.ts +88 -0
- package/dist/src/agents/sensor.js +377 -0
- package/dist/src/agents/test-agents.d.ts +6 -0
- package/dist/src/agents/test-agents.js +73 -0
- package/dist/src/agents/types.d.ts +194 -0
- package/dist/src/agents/types.js +7 -0
- package/dist/src/brain/index.d.ts +185 -0
- package/dist/src/brain/index.js +843 -0
- package/dist/src/brain/trace.d.ts +91 -0
- package/dist/src/brain/trace.js +327 -0
- package/dist/src/brain/types.d.ts +165 -0
- package/dist/src/brain/types.js +51 -0
- package/dist/src/cli/chat.d.ts +237 -0
- package/dist/src/cli/chat.js +1959 -0
- package/dist/src/cli/dispatcher.d.ts +182 -0
- package/dist/src/cli/dispatcher.js +718 -0
- package/dist/src/cli/human-loop.d.ts +170 -0
- package/dist/src/cli/human-loop.js +543 -0
- package/dist/src/cli/index.d.ts +12 -0
- package/dist/src/cli/index.js +28 -0
- package/dist/src/cli/interactive.d.ts +141 -0
- package/dist/src/cli/interactive.js +757 -0
- package/dist/src/cli/ui.d.ts +205 -0
- package/dist/src/cli/ui.js +632 -0
- package/dist/src/consciousness/attention-schema.d.ts +154 -0
- package/dist/src/consciousness/attention-schema.js +432 -0
- package/dist/src/consciousness/global-workspace.d.ts +149 -0
- package/dist/src/consciousness/global-workspace.js +422 -0
- package/dist/src/consciousness/index.d.ts +186 -0
- package/dist/src/consciousness/index.js +476 -0
- package/dist/src/consciousness/phi-calculator.d.ts +119 -0
- package/dist/src/consciousness/phi-calculator.js +445 -0
- package/dist/src/consciousness/phi-decisions.d.ts +169 -0
- package/dist/src/consciousness/phi-decisions.js +383 -0
- package/dist/src/consciousness/phi-monitor.d.ts +153 -0
- package/dist/src/consciousness/phi-monitor.js +465 -0
- package/dist/src/consciousness/types.d.ts +260 -0
- package/dist/src/consciousness/types.js +44 -0
- package/dist/src/daemon/dream-mode.d.ts +115 -0
- package/dist/src/daemon/dream-mode.js +470 -0
- package/dist/src/daemon/index.d.ts +162 -0
- package/dist/src/daemon/index.js +542 -0
- package/dist/src/daemon/maintenance.d.ts +139 -0
- package/dist/src/daemon/maintenance.js +549 -0
- package/dist/src/daemon/process.d.ts +82 -0
- package/dist/src/daemon/process.js +442 -0
- package/dist/src/daemon/scheduler.d.ts +90 -0
- package/dist/src/daemon/scheduler.js +494 -0
- package/dist/src/daemon/types.d.ts +213 -0
- package/dist/src/daemon/types.js +50 -0
- package/dist/src/epistemic/index.d.ts +74 -0
- package/dist/src/epistemic/index.js +225 -0
- package/dist/src/grounding/epistemic-stack.d.ts +100 -0
- package/dist/src/grounding/epistemic-stack.js +408 -0
- package/dist/src/grounding/feedback.d.ts +98 -0
- package/dist/src/grounding/feedback.js +276 -0
- package/dist/src/grounding/index.d.ts +123 -0
- package/dist/src/grounding/index.js +224 -0
- package/dist/src/grounding/verifier.d.ts +149 -0
- package/dist/src/grounding/verifier.js +484 -0
- package/dist/src/healing/detector.d.ts +110 -0
- package/dist/src/healing/detector.js +436 -0
- package/dist/src/healing/fixer.d.ts +138 -0
- package/dist/src/healing/fixer.js +572 -0
- package/dist/src/healing/index.d.ts +23 -0
- package/dist/src/healing/index.js +43 -0
- package/dist/src/hooks/index.d.ts +135 -0
- package/dist/src/hooks/index.js +317 -0
- package/dist/src/index.d.ts +23 -0
- package/dist/src/index.js +1266 -0
- package/dist/src/kernel/index.d.ts +155 -0
- package/dist/src/kernel/index.js +795 -0
- package/dist/src/kernel/invariants.d.ts +153 -0
- package/dist/src/kernel/invariants.js +355 -0
- package/dist/src/kernel/test-kernel.d.ts +6 -0
- package/dist/src/kernel/test-kernel.js +108 -0
- package/dist/src/kernel/test-real-mcp.d.ts +10 -0
- package/dist/src/kernel/test-real-mcp.js +295 -0
- package/dist/src/llm/index.d.ts +146 -0
- package/dist/src/llm/index.js +428 -0
- package/dist/src/llm/router.d.ts +136 -0
- package/dist/src/llm/router.js +510 -0
- package/dist/src/mcp/index.d.ts +85 -0
- package/dist/src/mcp/index.js +657 -0
- package/dist/src/mcp/resilient.d.ts +139 -0
- package/dist/src/mcp/resilient.js +417 -0
- package/dist/src/memory/cache.d.ts +118 -0
- package/dist/src/memory/cache.js +356 -0
- package/dist/src/memory/cognitive-workspace.d.ts +231 -0
- package/dist/src/memory/cognitive-workspace.js +521 -0
- package/dist/src/memory/consolidation.d.ts +99 -0
- package/dist/src/memory/consolidation.js +443 -0
- package/dist/src/memory/episodic.d.ts +114 -0
- package/dist/src/memory/episodic.js +394 -0
- package/dist/src/memory/forgetting.d.ts +134 -0
- package/dist/src/memory/forgetting.js +324 -0
- package/dist/src/memory/index.d.ts +211 -0
- package/dist/src/memory/index.js +367 -0
- package/dist/src/memory/indexer.d.ts +123 -0
- package/dist/src/memory/indexer.js +479 -0
- package/dist/src/memory/procedural.d.ts +136 -0
- package/dist/src/memory/procedural.js +479 -0
- package/dist/src/memory/semantic.d.ts +132 -0
- package/dist/src/memory/semantic.js +497 -0
- package/dist/src/memory/types.d.ts +193 -0
- package/dist/src/memory/types.js +15 -0
- package/dist/src/orchestrator.d.ts +65 -0
- package/dist/src/orchestrator.js +317 -0
- package/dist/src/persistence/index.d.ts +257 -0
- package/dist/src/persistence/index.js +763 -0
- package/dist/src/pipeline/executor.d.ts +51 -0
- package/dist/src/pipeline/executor.js +695 -0
- package/dist/src/pipeline/index.d.ts +7 -0
- package/dist/src/pipeline/index.js +11 -0
- package/dist/src/self-production.d.ts +67 -0
- package/dist/src/self-production.js +205 -0
- package/dist/src/subagents/executor.d.ts +58 -0
- package/dist/src/subagents/executor.js +283 -0
- package/dist/src/subagents/index.d.ts +37 -0
- package/dist/src/subagents/index.js +53 -0
- package/dist/src/subagents/registry.d.ts +23 -0
- package/dist/src/subagents/registry.js +167 -0
- package/dist/src/subagents/types.d.ts +79 -0
- package/dist/src/subagents/types.js +14 -0
- package/dist/src/tools/bash.d.ts +139 -0
- package/dist/src/tools/bash.js +583 -0
- package/dist/src/tools/edit.d.ts +125 -0
- package/dist/src/tools/edit.js +424 -0
- package/dist/src/tools/git.d.ts +179 -0
- package/dist/src/tools/git.js +504 -0
- package/dist/src/tools/index.d.ts +21 -0
- package/dist/src/tools/index.js +163 -0
- package/dist/src/types.d.ts +145 -0
- package/dist/src/types.js +7 -0
- package/dist/src/world-model/decoder.d.ts +163 -0
- package/dist/src/world-model/decoder.js +517 -0
- package/dist/src/world-model/digital-twin.d.ts +219 -0
- package/dist/src/world-model/digital-twin.js +695 -0
- package/dist/src/world-model/encoder.d.ts +141 -0
- package/dist/src/world-model/encoder.js +564 -0
- package/dist/src/world-model/index.d.ts +221 -0
- package/dist/src/world-model/index.js +772 -0
- package/dist/src/world-model/predictor.d.ts +161 -0
- package/dist/src/world-model/predictor.js +681 -0
- package/dist/src/world-model/test-value-jepa.d.ts +8 -0
- package/dist/src/world-model/test-value-jepa.js +430 -0
- package/dist/src/world-model/types.d.ts +341 -0
- package/dist/src/world-model/types.js +69 -0
- package/dist/src/world-model/value-jepa.d.ts +247 -0
- package/dist/src/world-model/value-jepa.js +622 -0
- package/dist/test/brain.test.d.ts +11 -0
- package/dist/test/brain.test.js +358 -0
- package/dist/test/cli/dispatcher.test.d.ts +4 -0
- package/dist/test/cli/dispatcher.test.js +332 -0
- package/dist/test/cli/human-loop.test.d.ts +4 -0
- package/dist/test/cli/human-loop.test.js +270 -0
- package/dist/test/grounding/feedback.test.d.ts +4 -0
- package/dist/test/grounding/feedback.test.js +462 -0
- package/dist/test/grounding/verifier.test.d.ts +4 -0
- package/dist/test/grounding/verifier.test.js +442 -0
- package/dist/test/grounding.test.d.ts +6 -0
- package/dist/test/grounding.test.js +246 -0
- package/dist/test/healing/detector.test.d.ts +4 -0
- package/dist/test/healing/detector.test.js +266 -0
- package/dist/test/healing/fixer.test.d.ts +4 -0
- package/dist/test/healing/fixer.test.js +369 -0
- package/dist/test/integration.test.d.ts +5 -0
- package/dist/test/integration.test.js +290 -0
- package/dist/test/tools/bash.test.d.ts +4 -0
- package/dist/test/tools/bash.test.js +348 -0
- package/dist/test/tools/edit.test.d.ts +4 -0
- package/dist/test/tools/edit.test.js +350 -0
- package/dist/test/tools/git.test.d.ts +4 -0
- package/dist/test/tools/git.test.js +350 -0
- package/package.json +60 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Genesis 4.0 - Feeling Agent
|
|
4
|
+
*
|
|
5
|
+
* Evaluates importance and emotional valence of inputs.
|
|
6
|
+
* Implements the "Sistema Limbico Digitale" from ORGANISM.md
|
|
7
|
+
*
|
|
8
|
+
* Feelings: curiosity, satisfaction, frustration, urgency, calm, concern
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.FeelingAgent = void 0;
|
|
12
|
+
exports.createFeelingAgent = createFeelingAgent;
|
|
13
|
+
const base_agent_js_1 = require("./base-agent.js");
|
|
14
|
+
const message_bus_js_1 = require("./message-bus.js");
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Feeling Agent
|
|
17
|
+
// ============================================================================
|
|
18
|
+
class FeelingAgent extends base_agent_js_1.BaseAgent {
|
|
19
|
+
feelingState = {
|
|
20
|
+
current: {
|
|
21
|
+
valence: 0, // Neutral
|
|
22
|
+
arousal: 0.3, // Calm
|
|
23
|
+
importance: 0.5,
|
|
24
|
+
category: 'calm',
|
|
25
|
+
},
|
|
26
|
+
history: [],
|
|
27
|
+
baseline: {
|
|
28
|
+
valence: 0,
|
|
29
|
+
arousal: 0.3,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
// Keywords that trigger specific feelings
|
|
33
|
+
feelingTriggers = {
|
|
34
|
+
curiosity: ['new', 'novel', 'interesting', 'unknown', 'discover', 'explore', 'what', 'why', 'how'],
|
|
35
|
+
satisfaction: ['success', 'complete', 'done', 'achieved', 'working', 'passed', 'good'],
|
|
36
|
+
frustration: ['error', 'fail', 'bug', 'broken', 'again', 'still', 'not working'],
|
|
37
|
+
urgency: ['urgent', 'critical', 'immediately', 'asap', 'deadline', 'now', 'emergency'],
|
|
38
|
+
calm: ['stable', 'normal', 'routine', 'expected', 'as usual'],
|
|
39
|
+
concern: ['warning', 'risk', 'danger', 'problem', 'issue', 'suspicious', 'anomaly'],
|
|
40
|
+
};
|
|
41
|
+
// Decay rate for returning to baseline
|
|
42
|
+
decayRate = 0.1; // 10% per evaluation
|
|
43
|
+
constructor(bus = message_bus_js_1.messageBus) {
|
|
44
|
+
super({ type: 'feeling' }, bus);
|
|
45
|
+
}
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Message Handling
|
|
48
|
+
// ============================================================================
|
|
49
|
+
getMessageTypes() {
|
|
50
|
+
return ['FEELING', 'QUERY', 'BROADCAST'];
|
|
51
|
+
}
|
|
52
|
+
async process(message) {
|
|
53
|
+
switch (message.type) {
|
|
54
|
+
case 'FEELING':
|
|
55
|
+
return this.handleFeelingRequest(message);
|
|
56
|
+
case 'QUERY':
|
|
57
|
+
return this.handleQuery(message);
|
|
58
|
+
case 'BROADCAST':
|
|
59
|
+
// React to broadcasts
|
|
60
|
+
await this.reactToBroadcast(message);
|
|
61
|
+
return null;
|
|
62
|
+
default:
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// Feeling Evaluation
|
|
68
|
+
// ============================================================================
|
|
69
|
+
async handleFeelingRequest(message) {
|
|
70
|
+
const { content, context } = message.payload;
|
|
71
|
+
const feeling = this.evaluate(content, context);
|
|
72
|
+
return {
|
|
73
|
+
...this.createResponse(message, 'RESPONSE', { feeling }),
|
|
74
|
+
id: '',
|
|
75
|
+
timestamp: new Date(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
evaluate(content, context) {
|
|
79
|
+
const contentStr = typeof content === 'string' ? content : JSON.stringify(content);
|
|
80
|
+
const fullText = (contentStr + ' ' + (context || '')).toLowerCase();
|
|
81
|
+
// Detect category
|
|
82
|
+
const category = this.detectCategory(fullText);
|
|
83
|
+
// Calculate valence and arousal
|
|
84
|
+
const valence = this.calculateValence(fullText, category);
|
|
85
|
+
const arousal = this.calculateArousal(fullText, category);
|
|
86
|
+
// Calculate importance
|
|
87
|
+
const importance = this.calculateImportance(fullText, category, arousal);
|
|
88
|
+
const feeling = {
|
|
89
|
+
valence,
|
|
90
|
+
arousal,
|
|
91
|
+
importance,
|
|
92
|
+
category,
|
|
93
|
+
};
|
|
94
|
+
// Update state
|
|
95
|
+
this.updateState(feeling, contentStr.slice(0, 50));
|
|
96
|
+
return feeling;
|
|
97
|
+
}
|
|
98
|
+
detectCategory(text) {
|
|
99
|
+
const scores = {
|
|
100
|
+
curiosity: 0,
|
|
101
|
+
satisfaction: 0,
|
|
102
|
+
frustration: 0,
|
|
103
|
+
urgency: 0,
|
|
104
|
+
calm: 0,
|
|
105
|
+
concern: 0,
|
|
106
|
+
};
|
|
107
|
+
// Count trigger matches
|
|
108
|
+
for (const [category, triggers] of Object.entries(this.feelingTriggers)) {
|
|
109
|
+
for (const trigger of triggers) {
|
|
110
|
+
if (text.includes(trigger)) {
|
|
111
|
+
scores[category]++;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Find highest scoring category
|
|
116
|
+
let maxScore = 0;
|
|
117
|
+
let maxCategory = 'calm';
|
|
118
|
+
for (const [category, score] of Object.entries(scores)) {
|
|
119
|
+
if (score > maxScore) {
|
|
120
|
+
maxScore = score;
|
|
121
|
+
maxCategory = category;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return maxCategory;
|
|
125
|
+
}
|
|
126
|
+
calculateValence(text, category) {
|
|
127
|
+
// Base valence by category
|
|
128
|
+
const categoryValence = {
|
|
129
|
+
curiosity: 0.3, // Mildly positive
|
|
130
|
+
satisfaction: 0.8, // Very positive
|
|
131
|
+
frustration: -0.6, // Negative
|
|
132
|
+
urgency: -0.2, // Slightly negative
|
|
133
|
+
calm: 0, // Neutral
|
|
134
|
+
concern: -0.4, // Moderately negative
|
|
135
|
+
};
|
|
136
|
+
let valence = categoryValence[category];
|
|
137
|
+
// Adjust based on positive/negative words
|
|
138
|
+
const positiveWords = ['good', 'great', 'excellent', 'success', 'love', 'happy'];
|
|
139
|
+
const negativeWords = ['bad', 'terrible', 'fail', 'hate', 'angry', 'sad'];
|
|
140
|
+
for (const word of positiveWords) {
|
|
141
|
+
if (text.includes(word))
|
|
142
|
+
valence += 0.1;
|
|
143
|
+
}
|
|
144
|
+
for (const word of negativeWords) {
|
|
145
|
+
if (text.includes(word))
|
|
146
|
+
valence -= 0.1;
|
|
147
|
+
}
|
|
148
|
+
// Blend with current state (momentum)
|
|
149
|
+
valence = valence * 0.7 + this.feelingState.current.valence * 0.3;
|
|
150
|
+
// Decay towards baseline
|
|
151
|
+
valence = valence * (1 - this.decayRate) + this.feelingState.baseline.valence * this.decayRate;
|
|
152
|
+
return Math.max(-1, Math.min(1, valence));
|
|
153
|
+
}
|
|
154
|
+
calculateArousal(text, category) {
|
|
155
|
+
// Base arousal by category
|
|
156
|
+
const categoryArousal = {
|
|
157
|
+
curiosity: 0.6, // Moderately aroused
|
|
158
|
+
satisfaction: 0.4, // Relaxed but engaged
|
|
159
|
+
frustration: 0.7, // High arousal
|
|
160
|
+
urgency: 0.9, // Very high arousal
|
|
161
|
+
calm: 0.2, // Low arousal
|
|
162
|
+
concern: 0.6, // Moderately aroused
|
|
163
|
+
};
|
|
164
|
+
let arousal = categoryArousal[category];
|
|
165
|
+
// Adjust based on intensity markers
|
|
166
|
+
const intensifiers = ['very', 'extremely', 'incredibly', '!', '!!!', 'URGENT'];
|
|
167
|
+
for (const word of intensifiers) {
|
|
168
|
+
if (text.includes(word))
|
|
169
|
+
arousal += 0.1;
|
|
170
|
+
}
|
|
171
|
+
// Blend with current state
|
|
172
|
+
arousal = arousal * 0.7 + this.feelingState.current.arousal * 0.3;
|
|
173
|
+
// Decay towards baseline
|
|
174
|
+
arousal = arousal * (1 - this.decayRate) + this.feelingState.baseline.arousal * this.decayRate;
|
|
175
|
+
return Math.max(0, Math.min(1, arousal));
|
|
176
|
+
}
|
|
177
|
+
calculateImportance(text, category, arousal) {
|
|
178
|
+
// Base importance by category
|
|
179
|
+
const categoryImportance = {
|
|
180
|
+
curiosity: 0.6,
|
|
181
|
+
satisfaction: 0.5,
|
|
182
|
+
frustration: 0.7,
|
|
183
|
+
urgency: 0.95,
|
|
184
|
+
calm: 0.3,
|
|
185
|
+
concern: 0.8,
|
|
186
|
+
};
|
|
187
|
+
let importance = categoryImportance[category];
|
|
188
|
+
// Arousal increases importance
|
|
189
|
+
importance = importance * 0.6 + arousal * 0.4;
|
|
190
|
+
// Adjust based on importance markers
|
|
191
|
+
const importanceWords = ['important', 'critical', 'essential', 'must', 'required'];
|
|
192
|
+
for (const word of importanceWords) {
|
|
193
|
+
if (text.includes(word))
|
|
194
|
+
importance += 0.15;
|
|
195
|
+
}
|
|
196
|
+
return Math.max(0, Math.min(1, importance));
|
|
197
|
+
}
|
|
198
|
+
// ============================================================================
|
|
199
|
+
// State Management
|
|
200
|
+
// ============================================================================
|
|
201
|
+
updateState(feeling, trigger) {
|
|
202
|
+
// Add to history
|
|
203
|
+
this.feelingState.history.push({
|
|
204
|
+
feeling,
|
|
205
|
+
timestamp: new Date(),
|
|
206
|
+
trigger,
|
|
207
|
+
});
|
|
208
|
+
// Keep history limited
|
|
209
|
+
if (this.feelingState.history.length > 100) {
|
|
210
|
+
this.feelingState.history.shift();
|
|
211
|
+
}
|
|
212
|
+
// Update current feeling
|
|
213
|
+
this.feelingState.current = feeling;
|
|
214
|
+
// Log significant changes
|
|
215
|
+
if (feeling.importance > 0.7 || Math.abs(feeling.valence) > 0.5) {
|
|
216
|
+
this.log(`Feeling: ${feeling.category} (v=${feeling.valence.toFixed(2)}, a=${feeling.arousal.toFixed(2)}, i=${feeling.importance.toFixed(2)})`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// ============================================================================
|
|
220
|
+
// Reactions
|
|
221
|
+
// ============================================================================
|
|
222
|
+
async reactToBroadcast(message) {
|
|
223
|
+
// Evaluate the broadcast and potentially respond
|
|
224
|
+
const feeling = this.evaluate(message.payload, `broadcast from ${message.from}`);
|
|
225
|
+
// If highly important or strongly emotional, broadcast our feeling
|
|
226
|
+
if (feeling.importance > 0.8 || Math.abs(feeling.valence) > 0.7) {
|
|
227
|
+
await this.broadcast('FEELING', {
|
|
228
|
+
originalMessage: message.id,
|
|
229
|
+
feeling,
|
|
230
|
+
from: message.from,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// ============================================================================
|
|
235
|
+
// Query
|
|
236
|
+
// ============================================================================
|
|
237
|
+
async handleQuery(message) {
|
|
238
|
+
const { query } = message.payload;
|
|
239
|
+
if (query === 'current') {
|
|
240
|
+
return {
|
|
241
|
+
...this.createResponse(message, 'RESPONSE', {
|
|
242
|
+
feeling: this.feelingState.current,
|
|
243
|
+
}),
|
|
244
|
+
id: '',
|
|
245
|
+
timestamp: new Date(),
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
if (query === 'history') {
|
|
249
|
+
return {
|
|
250
|
+
...this.createResponse(message, 'RESPONSE', {
|
|
251
|
+
history: this.feelingState.history.slice(-10),
|
|
252
|
+
}),
|
|
253
|
+
id: '',
|
|
254
|
+
timestamp: new Date(),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
if (query === 'stats') {
|
|
258
|
+
return {
|
|
259
|
+
...this.createResponse(message, 'RESPONSE', this.getStats()),
|
|
260
|
+
id: '',
|
|
261
|
+
timestamp: new Date(),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
// Evaluate the query itself
|
|
265
|
+
const feeling = this.evaluate(query);
|
|
266
|
+
return {
|
|
267
|
+
...this.createResponse(message, 'RESPONSE', { feeling }),
|
|
268
|
+
id: '',
|
|
269
|
+
timestamp: new Date(),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
getStats() {
|
|
273
|
+
const history = this.feelingState.history;
|
|
274
|
+
const categoryCount = {
|
|
275
|
+
curiosity: 0,
|
|
276
|
+
satisfaction: 0,
|
|
277
|
+
frustration: 0,
|
|
278
|
+
urgency: 0,
|
|
279
|
+
calm: 0,
|
|
280
|
+
concern: 0,
|
|
281
|
+
};
|
|
282
|
+
let avgValence = 0;
|
|
283
|
+
let avgArousal = 0;
|
|
284
|
+
let avgImportance = 0;
|
|
285
|
+
for (const entry of history) {
|
|
286
|
+
categoryCount[entry.feeling.category]++;
|
|
287
|
+
avgValence += entry.feeling.valence;
|
|
288
|
+
avgArousal += entry.feeling.arousal;
|
|
289
|
+
avgImportance += entry.feeling.importance;
|
|
290
|
+
}
|
|
291
|
+
const n = history.length || 1;
|
|
292
|
+
return {
|
|
293
|
+
current: this.feelingState.current,
|
|
294
|
+
historySize: history.length,
|
|
295
|
+
categoryDistribution: categoryCount,
|
|
296
|
+
averages: {
|
|
297
|
+
valence: avgValence / n,
|
|
298
|
+
arousal: avgArousal / n,
|
|
299
|
+
importance: avgImportance / n,
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
// ============================================================================
|
|
304
|
+
// Public Methods
|
|
305
|
+
// ============================================================================
|
|
306
|
+
getCurrentFeeling() {
|
|
307
|
+
return { ...this.feelingState.current };
|
|
308
|
+
}
|
|
309
|
+
setBaseline(valence, arousal) {
|
|
310
|
+
this.feelingState.baseline = { valence, arousal };
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
exports.FeelingAgent = FeelingAgent;
|
|
314
|
+
// ============================================================================
|
|
315
|
+
// Register Factory
|
|
316
|
+
// ============================================================================
|
|
317
|
+
(0, base_agent_js_1.registerAgentFactory)('feeling', (bus) => new FeelingAgent(bus));
|
|
318
|
+
function createFeelingAgent(bus) {
|
|
319
|
+
return new FeelingAgent(bus);
|
|
320
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genesis 4.0 - Agent System
|
|
3
|
+
*
|
|
4
|
+
* Multi-agent ecosystem with 10 specialized agents:
|
|
5
|
+
*
|
|
6
|
+
* COGNITION:
|
|
7
|
+
* - Explorer: Searches, discovers, ranks novelty
|
|
8
|
+
* - Memory: Stores with Ebbinghaus decay
|
|
9
|
+
* - Planner: Decomposes goals into steps
|
|
10
|
+
* - Predictor: Forecasts outcomes
|
|
11
|
+
*
|
|
12
|
+
* EVALUATION:
|
|
13
|
+
* - Feeling: Evaluates importance/valence
|
|
14
|
+
* - Critic: Finds problems, suggests improvements
|
|
15
|
+
* - Ethicist: Priority stack ethics
|
|
16
|
+
*
|
|
17
|
+
* ACTION:
|
|
18
|
+
* - Builder: Generates code/artifacts
|
|
19
|
+
* - Narrator: Creates coherent narratives
|
|
20
|
+
* - Sensor: Interface to MCP servers
|
|
21
|
+
*/
|
|
22
|
+
export * from './types.js';
|
|
23
|
+
export { MessageBus, messageBus } from './message-bus.js';
|
|
24
|
+
export { BaseAgent, registerAgentFactory, getAgentFactory, listAgentTypes } from './base-agent.js';
|
|
25
|
+
export { ExplorerAgent, createExplorerAgent } from './explorer.js';
|
|
26
|
+
export { MemoryAgent, createMemoryAgent } from './memory.js';
|
|
27
|
+
export { PlannerAgent, createPlannerAgent } from './planner.js';
|
|
28
|
+
export { PredictorAgent, createPredictorAgent } from './predictor.js';
|
|
29
|
+
export { FeelingAgent, createFeelingAgent } from './feeling.js';
|
|
30
|
+
export { CriticAgent, createCriticAgent } from './critic.js';
|
|
31
|
+
export { EthicistAgent, createEthicistAgent } from './ethicist.js';
|
|
32
|
+
export { BuilderAgent, createBuilderAgent } from './builder.js';
|
|
33
|
+
export { NarratorAgent, createNarratorAgent } from './narrator.js';
|
|
34
|
+
export { SensorAgent, createSensorAgent } from './sensor.js';
|
|
35
|
+
import './explorer.js';
|
|
36
|
+
import './memory.js';
|
|
37
|
+
import './planner.js';
|
|
38
|
+
import './predictor.js';
|
|
39
|
+
import './feeling.js';
|
|
40
|
+
import './critic.js';
|
|
41
|
+
import './ethicist.js';
|
|
42
|
+
import './builder.js';
|
|
43
|
+
import './narrator.js';
|
|
44
|
+
import './sensor.js';
|
|
45
|
+
import { MessageBus } from './message-bus.js';
|
|
46
|
+
import { BaseAgent, listAgentTypes } from './base-agent.js';
|
|
47
|
+
import { AgentType } from './types.js';
|
|
48
|
+
/**
|
|
49
|
+
* Registry for managing active agents
|
|
50
|
+
*/
|
|
51
|
+
export declare class AgentRegistry {
|
|
52
|
+
private agents;
|
|
53
|
+
private bus;
|
|
54
|
+
constructor(bus?: MessageBus);
|
|
55
|
+
/**
|
|
56
|
+
* Spawn an agent by type
|
|
57
|
+
*/
|
|
58
|
+
spawn(type: AgentType): BaseAgent;
|
|
59
|
+
/**
|
|
60
|
+
* Spawn all available agent types
|
|
61
|
+
*/
|
|
62
|
+
spawnAll(): Map<AgentType, BaseAgent>;
|
|
63
|
+
/**
|
|
64
|
+
* Get an agent by ID
|
|
65
|
+
*/
|
|
66
|
+
get(id: string): BaseAgent | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Get all agents of a specific type
|
|
69
|
+
*/
|
|
70
|
+
getByType(type: AgentType): BaseAgent[];
|
|
71
|
+
/**
|
|
72
|
+
* Get all active agents
|
|
73
|
+
*/
|
|
74
|
+
getAll(): BaseAgent[];
|
|
75
|
+
/**
|
|
76
|
+
* Shutdown an agent
|
|
77
|
+
*/
|
|
78
|
+
shutdown(id: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* Shutdown all agents
|
|
81
|
+
*/
|
|
82
|
+
shutdownAll(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Get registry stats
|
|
85
|
+
*/
|
|
86
|
+
getStats(): {
|
|
87
|
+
totalAgents: number;
|
|
88
|
+
byType: Record<string, number>;
|
|
89
|
+
byState: Record<string, number>;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create a full agent ecosystem
|
|
94
|
+
*/
|
|
95
|
+
export declare function createAgentEcosystem(bus?: MessageBus): {
|
|
96
|
+
registry: AgentRegistry;
|
|
97
|
+
agents: Map<AgentType, BaseAgent>;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Quick spawn a single agent
|
|
101
|
+
*/
|
|
102
|
+
export declare function spawnAgent(type: AgentType, bus?: MessageBus): BaseAgent;
|
|
103
|
+
declare const _default: {
|
|
104
|
+
MessageBus: typeof MessageBus;
|
|
105
|
+
messageBus: MessageBus;
|
|
106
|
+
AgentRegistry: typeof AgentRegistry;
|
|
107
|
+
createAgentEcosystem: typeof createAgentEcosystem;
|
|
108
|
+
spawnAgent: typeof spawnAgent;
|
|
109
|
+
listAgentTypes: typeof listAgentTypes;
|
|
110
|
+
};
|
|
111
|
+
export default _default;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Genesis 4.0 - Agent System
|
|
4
|
+
*
|
|
5
|
+
* Multi-agent ecosystem with 10 specialized agents:
|
|
6
|
+
*
|
|
7
|
+
* COGNITION:
|
|
8
|
+
* - Explorer: Searches, discovers, ranks novelty
|
|
9
|
+
* - Memory: Stores with Ebbinghaus decay
|
|
10
|
+
* - Planner: Decomposes goals into steps
|
|
11
|
+
* - Predictor: Forecasts outcomes
|
|
12
|
+
*
|
|
13
|
+
* EVALUATION:
|
|
14
|
+
* - Feeling: Evaluates importance/valence
|
|
15
|
+
* - Critic: Finds problems, suggests improvements
|
|
16
|
+
* - Ethicist: Priority stack ethics
|
|
17
|
+
*
|
|
18
|
+
* ACTION:
|
|
19
|
+
* - Builder: Generates code/artifacts
|
|
20
|
+
* - Narrator: Creates coherent narratives
|
|
21
|
+
* - Sensor: Interface to MCP servers
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
35
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.AgentRegistry = exports.createSensorAgent = exports.SensorAgent = exports.createNarratorAgent = exports.NarratorAgent = exports.createBuilderAgent = exports.BuilderAgent = exports.createEthicistAgent = exports.EthicistAgent = exports.createCriticAgent = exports.CriticAgent = exports.createFeelingAgent = exports.FeelingAgent = exports.createPredictorAgent = exports.PredictorAgent = exports.createPlannerAgent = exports.PlannerAgent = exports.createMemoryAgent = exports.MemoryAgent = exports.createExplorerAgent = exports.ExplorerAgent = exports.listAgentTypes = exports.getAgentFactory = exports.registerAgentFactory = exports.BaseAgent = exports.messageBus = exports.MessageBus = void 0;
|
|
39
|
+
exports.createAgentEcosystem = createAgentEcosystem;
|
|
40
|
+
exports.spawnAgent = spawnAgent;
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// Core Exports
|
|
43
|
+
// ============================================================================
|
|
44
|
+
__exportStar(require("./types.js"), exports);
|
|
45
|
+
var message_bus_js_1 = require("./message-bus.js");
|
|
46
|
+
Object.defineProperty(exports, "MessageBus", { enumerable: true, get: function () { return message_bus_js_1.MessageBus; } });
|
|
47
|
+
Object.defineProperty(exports, "messageBus", { enumerable: true, get: function () { return message_bus_js_1.messageBus; } });
|
|
48
|
+
var base_agent_js_1 = require("./base-agent.js");
|
|
49
|
+
Object.defineProperty(exports, "BaseAgent", { enumerable: true, get: function () { return base_agent_js_1.BaseAgent; } });
|
|
50
|
+
Object.defineProperty(exports, "registerAgentFactory", { enumerable: true, get: function () { return base_agent_js_1.registerAgentFactory; } });
|
|
51
|
+
Object.defineProperty(exports, "getAgentFactory", { enumerable: true, get: function () { return base_agent_js_1.getAgentFactory; } });
|
|
52
|
+
Object.defineProperty(exports, "listAgentTypes", { enumerable: true, get: function () { return base_agent_js_1.listAgentTypes; } });
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Agent Exports
|
|
55
|
+
// ============================================================================
|
|
56
|
+
var explorer_js_1 = require("./explorer.js");
|
|
57
|
+
Object.defineProperty(exports, "ExplorerAgent", { enumerable: true, get: function () { return explorer_js_1.ExplorerAgent; } });
|
|
58
|
+
Object.defineProperty(exports, "createExplorerAgent", { enumerable: true, get: function () { return explorer_js_1.createExplorerAgent; } });
|
|
59
|
+
var memory_js_1 = require("./memory.js");
|
|
60
|
+
Object.defineProperty(exports, "MemoryAgent", { enumerable: true, get: function () { return memory_js_1.MemoryAgent; } });
|
|
61
|
+
Object.defineProperty(exports, "createMemoryAgent", { enumerable: true, get: function () { return memory_js_1.createMemoryAgent; } });
|
|
62
|
+
var planner_js_1 = require("./planner.js");
|
|
63
|
+
Object.defineProperty(exports, "PlannerAgent", { enumerable: true, get: function () { return planner_js_1.PlannerAgent; } });
|
|
64
|
+
Object.defineProperty(exports, "createPlannerAgent", { enumerable: true, get: function () { return planner_js_1.createPlannerAgent; } });
|
|
65
|
+
var predictor_js_1 = require("./predictor.js");
|
|
66
|
+
Object.defineProperty(exports, "PredictorAgent", { enumerable: true, get: function () { return predictor_js_1.PredictorAgent; } });
|
|
67
|
+
Object.defineProperty(exports, "createPredictorAgent", { enumerable: true, get: function () { return predictor_js_1.createPredictorAgent; } });
|
|
68
|
+
var feeling_js_1 = require("./feeling.js");
|
|
69
|
+
Object.defineProperty(exports, "FeelingAgent", { enumerable: true, get: function () { return feeling_js_1.FeelingAgent; } });
|
|
70
|
+
Object.defineProperty(exports, "createFeelingAgent", { enumerable: true, get: function () { return feeling_js_1.createFeelingAgent; } });
|
|
71
|
+
var critic_js_1 = require("./critic.js");
|
|
72
|
+
Object.defineProperty(exports, "CriticAgent", { enumerable: true, get: function () { return critic_js_1.CriticAgent; } });
|
|
73
|
+
Object.defineProperty(exports, "createCriticAgent", { enumerable: true, get: function () { return critic_js_1.createCriticAgent; } });
|
|
74
|
+
var ethicist_js_1 = require("./ethicist.js");
|
|
75
|
+
Object.defineProperty(exports, "EthicistAgent", { enumerable: true, get: function () { return ethicist_js_1.EthicistAgent; } });
|
|
76
|
+
Object.defineProperty(exports, "createEthicistAgent", { enumerable: true, get: function () { return ethicist_js_1.createEthicistAgent; } });
|
|
77
|
+
var builder_js_1 = require("./builder.js");
|
|
78
|
+
Object.defineProperty(exports, "BuilderAgent", { enumerable: true, get: function () { return builder_js_1.BuilderAgent; } });
|
|
79
|
+
Object.defineProperty(exports, "createBuilderAgent", { enumerable: true, get: function () { return builder_js_1.createBuilderAgent; } });
|
|
80
|
+
var narrator_js_1 = require("./narrator.js");
|
|
81
|
+
Object.defineProperty(exports, "NarratorAgent", { enumerable: true, get: function () { return narrator_js_1.NarratorAgent; } });
|
|
82
|
+
Object.defineProperty(exports, "createNarratorAgent", { enumerable: true, get: function () { return narrator_js_1.createNarratorAgent; } });
|
|
83
|
+
var sensor_js_1 = require("./sensor.js");
|
|
84
|
+
Object.defineProperty(exports, "SensorAgent", { enumerable: true, get: function () { return sensor_js_1.SensorAgent; } });
|
|
85
|
+
Object.defineProperty(exports, "createSensorAgent", { enumerable: true, get: function () { return sensor_js_1.createSensorAgent; } });
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// Import all agents to register factories
|
|
88
|
+
// ============================================================================
|
|
89
|
+
require("./explorer.js");
|
|
90
|
+
require("./memory.js");
|
|
91
|
+
require("./planner.js");
|
|
92
|
+
require("./predictor.js");
|
|
93
|
+
require("./feeling.js");
|
|
94
|
+
require("./critic.js");
|
|
95
|
+
require("./ethicist.js");
|
|
96
|
+
require("./builder.js");
|
|
97
|
+
require("./narrator.js");
|
|
98
|
+
require("./sensor.js");
|
|
99
|
+
// ============================================================================
|
|
100
|
+
// Agent Registry
|
|
101
|
+
// ============================================================================
|
|
102
|
+
const message_bus_js_2 = require("./message-bus.js");
|
|
103
|
+
const base_agent_js_2 = require("./base-agent.js");
|
|
104
|
+
/**
|
|
105
|
+
* Registry for managing active agents
|
|
106
|
+
*/
|
|
107
|
+
class AgentRegistry {
|
|
108
|
+
agents = new Map();
|
|
109
|
+
bus;
|
|
110
|
+
constructor(bus = message_bus_js_2.messageBus) {
|
|
111
|
+
this.bus = bus;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Spawn an agent by type
|
|
115
|
+
*/
|
|
116
|
+
spawn(type) {
|
|
117
|
+
const factory = (0, base_agent_js_2.getAgentFactory)(type);
|
|
118
|
+
if (!factory) {
|
|
119
|
+
throw new Error(`Unknown agent type: ${type}`);
|
|
120
|
+
}
|
|
121
|
+
const agent = factory(this.bus);
|
|
122
|
+
this.agents.set(agent.id, agent);
|
|
123
|
+
return agent;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Spawn all available agent types
|
|
127
|
+
*/
|
|
128
|
+
spawnAll() {
|
|
129
|
+
const spawned = new Map();
|
|
130
|
+
for (const type of (0, base_agent_js_2.listAgentTypes)()) {
|
|
131
|
+
const agent = this.spawn(type);
|
|
132
|
+
spawned.set(type, agent);
|
|
133
|
+
}
|
|
134
|
+
return spawned;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get an agent by ID
|
|
138
|
+
*/
|
|
139
|
+
get(id) {
|
|
140
|
+
return this.agents.get(id);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get all agents of a specific type
|
|
144
|
+
*/
|
|
145
|
+
getByType(type) {
|
|
146
|
+
return Array.from(this.agents.values()).filter((a) => a.agentType === type);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get all active agents
|
|
150
|
+
*/
|
|
151
|
+
getAll() {
|
|
152
|
+
return Array.from(this.agents.values());
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Shutdown an agent
|
|
156
|
+
*/
|
|
157
|
+
shutdown(id) {
|
|
158
|
+
const agent = this.agents.get(id);
|
|
159
|
+
if (agent) {
|
|
160
|
+
agent.shutdown();
|
|
161
|
+
this.agents.delete(id);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Shutdown all agents
|
|
166
|
+
*/
|
|
167
|
+
shutdownAll() {
|
|
168
|
+
for (const agent of this.agents.values()) {
|
|
169
|
+
agent.shutdown();
|
|
170
|
+
}
|
|
171
|
+
this.agents.clear();
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get registry stats
|
|
175
|
+
*/
|
|
176
|
+
getStats() {
|
|
177
|
+
const byType = {};
|
|
178
|
+
const byState = {};
|
|
179
|
+
for (const agent of this.agents.values()) {
|
|
180
|
+
byType[agent.agentType] = (byType[agent.agentType] || 0) + 1;
|
|
181
|
+
byState[agent.state] = (byState[agent.state] || 0) + 1;
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
totalAgents: this.agents.size,
|
|
185
|
+
byType,
|
|
186
|
+
byState,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.AgentRegistry = AgentRegistry;
|
|
191
|
+
// ============================================================================
|
|
192
|
+
// Convenience Functions
|
|
193
|
+
// ============================================================================
|
|
194
|
+
/**
|
|
195
|
+
* Create a full agent ecosystem
|
|
196
|
+
*/
|
|
197
|
+
function createAgentEcosystem(bus = message_bus_js_2.messageBus) {
|
|
198
|
+
const registry = new AgentRegistry(bus);
|
|
199
|
+
const agents = registry.spawnAll();
|
|
200
|
+
return { registry, agents };
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Quick spawn a single agent
|
|
204
|
+
*/
|
|
205
|
+
function spawnAgent(type, bus = message_bus_js_2.messageBus) {
|
|
206
|
+
const factory = (0, base_agent_js_2.getAgentFactory)(type);
|
|
207
|
+
if (!factory) {
|
|
208
|
+
throw new Error(`Unknown agent type: ${type}`);
|
|
209
|
+
}
|
|
210
|
+
return factory(bus);
|
|
211
|
+
}
|
|
212
|
+
// ============================================================================
|
|
213
|
+
// Default Export
|
|
214
|
+
// ============================================================================
|
|
215
|
+
exports.default = {
|
|
216
|
+
MessageBus: message_bus_js_2.MessageBus,
|
|
217
|
+
messageBus: message_bus_js_2.messageBus,
|
|
218
|
+
AgentRegistry,
|
|
219
|
+
createAgentEcosystem,
|
|
220
|
+
spawnAgent,
|
|
221
|
+
listAgentTypes: base_agent_js_2.listAgentTypes,
|
|
222
|
+
};
|