@timmeck/brain-core 2.36.19 → 2.36.20
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 +93 -135
- package/command-center.html +158 -15
- package/dist/consciousness/__tests__/thought-stream.test.d.ts +1 -0
- package/dist/consciousness/__tests__/thought-stream.test.js +62 -0
- package/dist/consciousness/__tests__/thought-stream.test.js.map +1 -0
- package/dist/consciousness/thought-stream.d.ts +2 -0
- package/dist/consciousness/thought-stream.js +4 -0
- package/dist/consciousness/thought-stream.js.map +1 -1
- package/dist/dashboard/__tests__/command-center-server.test.js +8 -2
- package/dist/dashboard/__tests__/command-center-server.test.js.map +1 -1
- package/dist/dashboard/command-center-server.d.ts +5 -0
- package/dist/dashboard/command-center-server.js +39 -1
- package/dist/dashboard/command-center-server.js.map +1 -1
- package/dist/debate/debate-engine.js +1 -1
- package/dist/debate/debate-engine.js.map +1 -1
- package/dist/missions/__tests__/mission-engine.test.d.ts +1 -0
- package/dist/missions/__tests__/mission-engine.test.js +66 -0
- package/dist/missions/__tests__/mission-engine.test.js.map +1 -0
- package/dist/missions/mission-engine.js +5 -0
- package/dist/missions/mission-engine.js.map +1 -1
- package/dist/plugin/example-plugin.d.ts +40 -0
- package/dist/plugin/example-plugin.js +91 -0
- package/dist/plugin/example-plugin.js.map +1 -0
- package/dist/prediction/prediction-engine.js +1 -1
- package/dist/research/research-orchestrator.js +9 -0
- package/dist/research/research-orchestrator.js.map +1 -1
- package/dist/utils/__tests__/logger.test.js +27 -0
- package/dist/utils/__tests__/logger.test.js.map +1 -1
- package/dist/utils/logger.js +10 -3
- package/dist/utils/logger.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](https://github.com/timmeck/brain-ecosystem)
|
|
7
7
|
|
|
8
|
-
**Shared infrastructure for the Brain Ecosystem —
|
|
8
|
+
**Shared infrastructure for the Brain Ecosystem — 60+ autonomous engines, synapses, IPC, MCP, LLM service, consciousness, research missions, notifications, self-modification, and more.**
|
|
9
9
|
|
|
10
|
-
Brain Core is the nervous system that powers all three Brain MCP servers ([Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/brain), [Trading Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/trading-brain), [Marketing Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/marketing-brain)). A 40-step feedback orchestrator runs
|
|
10
|
+
Brain Core is the nervous system that powers all three Brain MCP servers ([Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/brain), [Trading Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/trading-brain), [Marketing Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/marketing-brain)). A 40-step feedback orchestrator runs 60+ engines in autonomic cycles — the brain observes itself, forms hypotheses, runs experiments, dreams, debates, reasons in chains, feels emotions, evolves strategies genetically, and modifies its own source code.
|
|
11
11
|
|
|
12
12
|
## What's Included
|
|
13
13
|
|
|
@@ -16,15 +16,22 @@ Brain Core is the nervous system that powers all three Brain MCP servers ([Brain
|
|
|
16
16
|
| Module | Description |
|
|
17
17
|
|--------|-------------|
|
|
18
18
|
| **IPC Protocol** | Length-prefixed JSON frames over named pipes / Unix sockets |
|
|
19
|
-
| **IPC Server** | Named pipe server with auto-recovery
|
|
20
|
-
| **IPC Client** | Request/response with timeouts and notification support |
|
|
19
|
+
| **IPC Server/Client** | Named pipe server with auto-recovery, request/response with timeouts |
|
|
21
20
|
| **MCP Server** | Stdio transport for Claude Code with auto-daemon-start |
|
|
22
21
|
| **MCP HTTP Server** | SSE transport for Cursor, Windsurf, Cline, Continue |
|
|
23
22
|
| **REST API Server** | HTTP server with CORS, auth, SSE events, batch RPC |
|
|
24
|
-
| **IPC Validation** | Parameter validation (string 10KB, array 1000, depth 10) |
|
|
25
|
-
| **IPC Errors** | Structured errors: IpcError, ValidationError, NotFoundError, TimeoutError |
|
|
26
23
|
| **Security Middleware** | RateLimiter (token bucket), body size limits, security headers |
|
|
27
24
|
|
|
25
|
+
### LLM Service
|
|
26
|
+
|
|
27
|
+
| Module | Description |
|
|
28
|
+
|--------|-------------|
|
|
29
|
+
| **Multi-Provider** | Anthropic Claude + Ollama local models, auto-routing by task |
|
|
30
|
+
| **Smart Caching** | Content-hash cache with TTL, avoid duplicate API calls |
|
|
31
|
+
| **Rate Limiting** | Per-hour and per-day token/call budgets with automatic throttling |
|
|
32
|
+
| **Usage Tracking** | Detailed stats: calls, tokens, latency, cache hit rate, cost tracking |
|
|
33
|
+
| **Prompt Templates** | Reusable templates for analysis, summarization, classification, coding |
|
|
34
|
+
|
|
28
35
|
### Synapse Network & Learning
|
|
29
36
|
|
|
30
37
|
| Module | Description |
|
|
@@ -33,118 +40,107 @@ Brain Core is the nervous system that powers all three Brain MCP servers ([Brain
|
|
|
33
40
|
| **Synapse Decay** | Exponential half-life decay for freshness |
|
|
34
41
|
| **Spreading Activation** | BFS-based energy propagation through the graph |
|
|
35
42
|
| **A* Pathfinding** | Find shortest paths between nodes |
|
|
36
|
-
| **BaseSynapseManager** | Abstract manager with strengthen/weaken/activate/findPath/decay |
|
|
37
|
-
| **BaseLearningEngine** | Abstract timer-managed learning engine |
|
|
38
|
-
| **BaseResearchEngine** | Abstract timer-managed research engine |
|
|
39
|
-
| **BaseMemoryEngine** | Abstract memory engine for expiry/consolidation/decay |
|
|
40
43
|
| **Wilson Score** | Statistical confidence intervals for win rates |
|
|
41
|
-
| **Time Decay** | Exponential half-life decay for rule freshness |
|
|
42
44
|
|
|
43
|
-
###
|
|
45
|
+
### 60+ Autonomous Engines
|
|
44
46
|
|
|
45
|
-
####
|
|
47
|
+
#### Observation & Data
|
|
46
48
|
|
|
47
49
|
| Engine | Description |
|
|
48
50
|
|--------|-------------|
|
|
49
|
-
| **SelfObserver** |
|
|
51
|
+
| **SelfObserver** | Observes own performance metrics, generates insights |
|
|
50
52
|
| **AnomalyDetective** | Detects statistical outliers using Z-scores and drift analysis |
|
|
51
|
-
| **
|
|
52
|
-
| **
|
|
53
|
-
| **
|
|
54
|
-
| **KnowledgeDistiller** | Extracts principles from confirmed hypotheses |
|
|
55
|
-
| **ResearchAgenda** | Prioritizes what should be researched next |
|
|
56
|
-
| **CounterfactualEngine** | "What if" analysis — estimates impact of hypothetical interventions |
|
|
57
|
-
| **ResearchJournal** | Logs all discoveries, experiments, and breakthroughs |
|
|
53
|
+
| **DataScout** | External data from GitHub/npm/Hacker News |
|
|
54
|
+
| **SignalScanner** | GitHub trending repos, HN mentions, crypto signals |
|
|
55
|
+
| **TechRadarEngine** | Daily tech trend scanning, repo watching, LLM relevance scoring |
|
|
58
56
|
|
|
59
|
-
####
|
|
57
|
+
#### Understanding & Analysis
|
|
60
58
|
|
|
61
59
|
| Engine | Description |
|
|
62
60
|
|--------|-------------|
|
|
63
61
|
| **AttentionEngine** | Dynamic focus, context detection, burst detection, engine weight allocation |
|
|
64
|
-
| **
|
|
65
|
-
| **
|
|
62
|
+
| **CausalGraph** | Granger causality analysis for event relationships |
|
|
63
|
+
| **CrossDomainEngine** | Finds correlations between events across brains |
|
|
64
|
+
| **PatternEngine** | Discovers recurring patterns in data |
|
|
65
|
+
|
|
66
|
+
#### Ideas & Hypotheses
|
|
67
|
+
|
|
68
|
+
| Engine | Description |
|
|
69
|
+
|--------|-------------|
|
|
70
|
+
| **HypothesisEngine** | Forms and tests hypotheses (temporal, correlation, threshold, creative) |
|
|
66
71
|
| **CuriosityEngine** | Knowledge gap detection, UCB1 explore/exploit, blind spot detection |
|
|
67
|
-
| **
|
|
68
|
-
| **DebateEngine** | Multi-agent debates,
|
|
69
|
-
| **ReasoningEngine** | Forward chaining, abductive reasoning, temporal inference, counterfactuals |
|
|
70
|
-
| **EmotionalModel** | 8 emotion dimensions, 6 moods, mood-based behavior recommendations |
|
|
72
|
+
| **DreamEngine** | Offline consolidation — memory replay, synapse pruning, compression, decay |
|
|
73
|
+
| **DebateEngine** | Multi-agent debates, Advocatus Diaboli principle challenges, consensus synthesis |
|
|
71
74
|
|
|
72
|
-
####
|
|
75
|
+
#### Testing & Experimentation
|
|
73
76
|
|
|
74
77
|
| Engine | Description |
|
|
75
78
|
|--------|-------------|
|
|
76
|
-
| **
|
|
77
|
-
| **MetaCognitionLayer** | Engine performance grading (A-F), frequency adjustment |
|
|
79
|
+
| **ExperimentEngine** | A/B tests on brain parameters |
|
|
78
80
|
| **AutoExperimentEngine** | Autonomous parameter tuning with snapshot/rollback |
|
|
79
|
-
| **
|
|
80
|
-
| **
|
|
81
|
-
| **MemoryPalace** | Knowledge graph with BFS pathfinding and auto-connection building |
|
|
81
|
+
| **SimulationEngine** | What-if scenarios via CausalGraph + PredictionEngine |
|
|
82
|
+
| **PredictionEngine** | Holt-Winters + EWMA forecasting with auto-calibration |
|
|
82
83
|
|
|
83
|
-
####
|
|
84
|
+
#### Knowledge & Memory
|
|
84
85
|
|
|
85
86
|
| Engine | Description |
|
|
86
87
|
|--------|-------------|
|
|
87
|
-
| **
|
|
88
|
-
| **
|
|
89
|
-
| **
|
|
90
|
-
| **
|
|
91
|
-
| **SelfScanner** | Indexes own TypeScript source code with SHA256 change detection |
|
|
92
|
-
| **SelfModificationEngine** | Generates and tests code changes autonomously via Claude API |
|
|
93
|
-
| **BootstrapService** | Cold-start fix: seeds data so engines produce output from cycle 1 |
|
|
88
|
+
| **KnowledgeDistiller** | Extracts principles from confirmed hypotheses |
|
|
89
|
+
| **MemoryPalace** | Knowledge graph with BFS pathfinding and connection building |
|
|
90
|
+
| **ResearchJournal** | Logs all discoveries, experiments, breakthroughs |
|
|
91
|
+
| **ConceptAbstraction** | Abstract concept formation from concrete observations |
|
|
94
92
|
|
|
95
|
-
|
|
93
|
+
#### Action & Self-Improvement
|
|
96
94
|
|
|
97
|
-
|
|
|
95
|
+
| Engine | Description |
|
|
98
96
|
|--------|-------------|
|
|
99
|
-
| **
|
|
100
|
-
| **
|
|
101
|
-
| **
|
|
102
|
-
| **
|
|
103
|
-
| **
|
|
104
|
-
| **
|
|
105
|
-
| **
|
|
106
|
-
| **
|
|
97
|
+
| **SelfModificationEngine** | Scans own code, generates improvements via Claude API, tests before applying |
|
|
98
|
+
| **GoalEngine** | Goal planning with progress tracking and forecasting |
|
|
99
|
+
| **AdaptiveStrategy** | Adjusts strategies based on outcomes, reverts if performance drops |
|
|
100
|
+
| **MetaCognitionLayer** | Engine performance grading (A-F), frequency adjustment |
|
|
101
|
+
| **EvolutionEngine** | Genetic algorithm — tournament selection, crossover, mutation, elitism |
|
|
102
|
+
| **ReasoningEngine** | Forward chaining, abductive reasoning, temporal inference, counterfactuals |
|
|
103
|
+
| **EmotionalModel** | 8 emotion dimensions, 6 moods, mood-based behavior recommendations |
|
|
104
|
+
| **NarrativeEngine** | Brain explains itself in natural language, finds contradictions |
|
|
105
|
+
| **TransferEngine** | Cross-brain knowledge transfer, analogies, cross-domain rules |
|
|
107
106
|
|
|
108
|
-
###
|
|
107
|
+
### Research Missions
|
|
109
108
|
|
|
110
109
|
| Module | Description |
|
|
111
110
|
|--------|-------------|
|
|
112
|
-
| **
|
|
113
|
-
| **
|
|
114
|
-
| **
|
|
115
|
-
| **ConsciousnessServer** | HTTP + SSE server with live Consciousness Entity visualization (legacy — now part of Mission Control) |
|
|
116
|
-
| **Consciousness Entity** | Animated Canvas 2D visualization: mood-colored pulsing orb, organic tentacles, 8-dimension ring, ambient particles, floating thoughts, inner eye tracking attention. 6 moods (flow/excited/anxious/reflective/bored/determined). Data from EmotionalModel via `/api/emotional` |
|
|
111
|
+
| **ResearchMissionEngine** | 5-phase autonomous web research pipeline |
|
|
112
|
+
| **Web Research Chain** | Brave Search + Jina Reader + Playwright + Firecrawl fallback |
|
|
113
|
+
| **Phase Pipeline** | Decompose → Gather → Hypothesize → Analyze → Synthesize |
|
|
117
114
|
|
|
118
|
-
###
|
|
115
|
+
### Notifications
|
|
119
116
|
|
|
120
117
|
| Module | Description |
|
|
121
118
|
|--------|-------------|
|
|
122
|
-
| **
|
|
123
|
-
| **
|
|
124
|
-
| **
|
|
125
|
-
| **
|
|
126
|
-
| **
|
|
127
|
-
| **SignalScanner** | GitHub trending repos, Hacker News, crypto signal tracking |
|
|
119
|
+
| **NotificationService** | Multi-provider notification routing |
|
|
120
|
+
| **Discord Provider** | Webhook-based Discord notifications |
|
|
121
|
+
| **Telegram Provider** | Bot API Telegram notifications |
|
|
122
|
+
| **Email Provider** | SMTP email notifications |
|
|
123
|
+
| **Notification Bridge** | IPC-based cross-brain notification relay |
|
|
128
124
|
|
|
129
125
|
### Dashboards
|
|
130
126
|
|
|
131
127
|
| Dashboard | Port | Description |
|
|
132
128
|
|-----------|------|-------------|
|
|
133
|
-
| **Mission Control** | 7788 |
|
|
134
|
-
|
|
135
|
-
<p align="center"><img src="../../docs/assets/mission-control.png" alt="Mission Control Dashboard" width="700"></p>
|
|
129
|
+
| **Mission Control** | 7788 | 7-tab dashboard: Overview, Consciousness Entity, Thoughts, CodeGen, Self-Mod, Engines, Intelligence |
|
|
130
|
+
| **Command Center** | 7790 | 8-page ecosystem dashboard with live visualizations, debates, challenges, error log, self-mod feed, missions, knowledge growth |
|
|
136
131
|
|
|
137
|
-
### Cross-Brain &
|
|
132
|
+
### Cross-Brain & Ecosystem
|
|
138
133
|
|
|
139
134
|
| Module | Description |
|
|
140
135
|
|--------|-------------|
|
|
141
136
|
| **CrossBrainClient** | Discover and query peer brains over IPC |
|
|
142
137
|
| **CrossBrainNotifier** | Push event notifications to peers |
|
|
143
|
-
| **CrossBrainCorrelator** | Correlate events across brains
|
|
138
|
+
| **CrossBrainCorrelator** | Correlate events across brains |
|
|
139
|
+
| **BorgSyncEngine** | Collective knowledge synchronization between all brains |
|
|
144
140
|
| **EcosystemService** | Aggregated status, health score 0–100, analytics |
|
|
145
|
-
| **
|
|
146
|
-
| **
|
|
147
|
-
| **
|
|
141
|
+
| **WatchdogService** | Process monitoring, auto-restart, health checks |
|
|
142
|
+
| **PluginRegistry** | Community plugin loading, lifecycle hooks, MCP tools, IPC routes |
|
|
143
|
+
| **WindowsServiceManager** | NSSM/SC.exe service install/uninstall/status |
|
|
148
144
|
|
|
149
145
|
### Utilities
|
|
150
146
|
|
|
@@ -152,11 +148,9 @@ Brain Core is the nervous system that powers all three Brain MCP servers ([Brain
|
|
|
152
148
|
|--------|-------------|
|
|
153
149
|
| **DB Connection** | SQLite (better-sqlite3) with WAL mode, foreign keys, caching |
|
|
154
150
|
| **Logger** | Winston-based structured logging with file rotation |
|
|
155
|
-
| **
|
|
156
|
-
| **CLI Colors** | Shared color palette, formatting helpers (header, table, badges) |
|
|
157
|
-
| **Config Loader** | `deepMerge()` + `loadConfigFile()` for layered config |
|
|
151
|
+
| **CLI Colors** | Shared color palette, formatting helpers |
|
|
158
152
|
| **Embedding Engine** | Local vector embeddings with @huggingface/transformers |
|
|
159
|
-
| **
|
|
153
|
+
| **Webhook / Export / Backup** | HMAC webhooks, JSON/CSV export, SQLite backups |
|
|
160
154
|
|
|
161
155
|
## Installation
|
|
162
156
|
|
|
@@ -172,77 +166,41 @@ npm install @timmeck/brain-core
|
|
|
172
166
|
import {
|
|
173
167
|
createConnection, IpcServer, startMcpServer,
|
|
174
168
|
ResearchOrchestrator, DreamEngine, ThoughtStream,
|
|
175
|
-
|
|
169
|
+
CommandCenterServer, LLMService,
|
|
176
170
|
} from '@timmeck/brain-core';
|
|
177
171
|
|
|
178
172
|
// 1. Database
|
|
179
173
|
const db = createConnection('~/.my-brain/my-brain.db');
|
|
180
174
|
|
|
181
|
-
// 2.
|
|
175
|
+
// 2. LLM Service (multi-provider)
|
|
176
|
+
const llm = new LLMService(db, {
|
|
177
|
+
anthropicApiKey: process.env.ANTHROPIC_API_KEY,
|
|
178
|
+
ollamaBaseUrl: 'http://localhost:11434',
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// 3. Research Orchestrator (60+ engines, 40-step feedback cycle)
|
|
182
182
|
const orchestrator = new ResearchOrchestrator(db, { brainName: 'my-brain' });
|
|
183
183
|
orchestrator.start();
|
|
184
184
|
|
|
185
|
-
//
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
// Unified Mission Control dashboard (includes Consciousness Entity, Thoughts, CodeGen, Self-Mod, Engines)
|
|
194
|
-
const dashboard = new UnifiedDashboardServer({ port: 7790, thoughtStream, ... });
|
|
185
|
+
// 4. Command Center Dashboard
|
|
186
|
+
const dashboard = new CommandCenterServer({
|
|
187
|
+
port: 7790,
|
|
188
|
+
selfName: 'my-brain',
|
|
189
|
+
crossBrain, ecosystemService, correlator,
|
|
190
|
+
thoughtStream: orchestrator.thoughtStream,
|
|
191
|
+
getLLMStats: () => llm.getStats(),
|
|
192
|
+
});
|
|
195
193
|
dashboard.start();
|
|
196
|
-
|
|
197
|
-
// 5. Predictions
|
|
198
|
-
const prediction = new PredictionEngine(db, { brainName: 'my-brain' });
|
|
199
|
-
orchestrator.setPredictionEngine(prediction);
|
|
200
|
-
prediction.start();
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
## Architecture
|
|
204
|
-
|
|
205
|
-
```
|
|
206
|
-
@timmeck/brain-core
|
|
207
|
-
├── IPC ────────── protocol, server, client, validation, errors
|
|
208
|
-
├── MCP ────────── stdio server, HTTP/SSE server
|
|
209
|
-
├── API ────────── BaseApiServer, RateLimiter, security middleware
|
|
210
|
-
├── Synapses ───── Hebbian, Decay, Activation, Pathfinder, BaseSynapseManager
|
|
211
|
-
├── Research ───── ResearchOrchestrator (40 steps), DataMiner, BootstrapService
|
|
212
|
-
│ ├── Core ───── SelfObserver, AnomalyDetective, Experiment, Adaptive, Agenda
|
|
213
|
-
│ ├── Core ───── KnowledgeDistiller, Counterfactual, CrossDomain, Journal
|
|
214
|
-
│ └── AutoResp ─ AutoResponder (anomaly → action)
|
|
215
|
-
├── Intelligence ─ Attention, Transfer, Narrative, Curiosity, Emergence, Debate
|
|
216
|
-
├── Reasoning ──── ReasoningEngine (forward chain, abduction, temporal, counterfactual)
|
|
217
|
-
├── Emotional ──── EmotionalModel (8 dimensions, 6 moods)
|
|
218
|
-
├── MetaCog ────── ParameterRegistry, MetaCognitionLayer, AutoExperimentEngine
|
|
219
|
-
├── Evolution ──── EvolutionEngine (genetic algorithm)
|
|
220
|
-
├── Goals ─────── GoalEngine (planning, progress, forecasting)
|
|
221
|
-
├── MemoryPalace ─ Knowledge graph, BFS pathfinding
|
|
222
|
-
├── SelfAware ──── SelfTest, Teach, DataScout, Simulation
|
|
223
|
-
├── SelfMod ────── SelfScanner, SelfModificationEngine
|
|
224
|
-
├── Dream ──────── DreamEngine, DreamConsolidator
|
|
225
|
-
├── Consciousness ThoughtStream, ConsciousnessServer
|
|
226
|
-
├── Prediction ─── PredictionEngine, Holt-Winters, EWMA, Calibration
|
|
227
|
-
├── CodeGen ────── CodeGenerator, CodeMiner, PatternExtractor, CodegenServer
|
|
228
|
-
├── Scanner ────── SignalScanner, GitHubCollector, HnCollector, CryptoCollector
|
|
229
|
-
├── Causal ─────── CausalGraph (Granger causality), HypothesisEngine
|
|
230
|
-
├── Cross-Brain ── Client, Notifier, Correlator, Subscriptions
|
|
231
|
-
├── Dashboard ──── Mission Control (Unified), Consciousness*, CodeGen*, Hub*, Research*
|
|
232
|
-
├── Services ───── Webhook, Export, Backup, Ecosystem
|
|
233
|
-
├── Memory ─────── BaseMemoryEngine, types
|
|
234
|
-
├── DB ─────────── SQLite connection (WAL mode)
|
|
235
|
-
└── Utils ─────── hash, logger, paths, events, math, config, CLI
|
|
236
194
|
```
|
|
237
195
|
|
|
238
196
|
## Brain Ecosystem
|
|
239
197
|
|
|
240
|
-
| Brain |
|
|
241
|
-
|
|
242
|
-
| [Brain](../brain) |
|
|
243
|
-
| [Trading Brain](../trading-brain) |
|
|
244
|
-
| [Marketing Brain](../marketing-brain) |
|
|
245
|
-
| **Brain Core**
|
|
198
|
+
| Brain | Purpose | Ports |
|
|
199
|
+
|-------|---------|-------|
|
|
200
|
+
| [Brain](../brain) | Error memory, code intelligence, full autonomy & self-modification | 7777/7778/7788/7790 |
|
|
201
|
+
| [Trading Brain](../trading-brain) | Adaptive trading intelligence with signal learning & paper trading | 7779/7780 |
|
|
202
|
+
| [Marketing Brain](../marketing-brain) | Content strategy, social engagement & cross-platform optimization | 7781/7782/7783 |
|
|
203
|
+
| **Brain Core** (this) | Shared infrastructure — 60+ engines | — |
|
|
246
204
|
|
|
247
205
|
## Support
|
|
248
206
|
|
package/command-center.html
CHANGED
|
@@ -234,6 +234,7 @@ canvas{display:block;width:100%;height:100%}
|
|
|
234
234
|
<div class="nav-item" data-page="marketing"><span class="nav-icon">📣</span><span class="nav-label">Marketing Flow</span></div>
|
|
235
235
|
<div class="nav-section">System</div>
|
|
236
236
|
<div class="nav-item" data-page="crossbrain"><span class="nav-icon">🔗</span><span class="nav-label">Cross-Brain</span></div>
|
|
237
|
+
<div class="nav-item" data-page="debates"><span class="nav-icon">⚖</span><span class="nav-label">Debates</span></div>
|
|
237
238
|
<div class="nav-item" data-page="activity"><span class="nav-icon">⚡</span><span class="nav-label">Aktivität</span></div>
|
|
238
239
|
<div class="nav-item" data-page="infra"><span class="nav-icon">⚙</span><span class="nav-label">Infrastruktur</span></div>
|
|
239
240
|
</div>
|
|
@@ -534,27 +535,67 @@ canvas{display:block;width:100%;height:100%}
|
|
|
534
535
|
</div>
|
|
535
536
|
</div>
|
|
536
537
|
|
|
537
|
-
<!-- ════ Page 7:
|
|
538
|
+
<!-- ════ Page 7: Debates & Challenges ═════════════════ -->
|
|
539
|
+
<div class="page" id="page-debates">
|
|
540
|
+
<!-- Debate Engine Status -->
|
|
541
|
+
<div class="section">
|
|
542
|
+
<div class="section-title"><span class="icon">⚖</span> Debate Engine</div>
|
|
543
|
+
<p style="font-size:12px;color:var(--text-dim);margin-bottom:12px">Multi-Perspektiven-Debatten zu Schlüsselfragen. Jeder Brain liefert seine Sichtweise basierend auf Prinzipien, Hypothesen und Vorhersagen.</p>
|
|
544
|
+
<div class="grid grid-4" id="debateStats">
|
|
545
|
+
<div class="card" style="text-align:center"><div class="card-value" id="db-total" style="color:var(--cyan)">0</div><div class="card-sub">Debatten gesamt</div></div>
|
|
546
|
+
<div class="card" style="text-align:center"><div class="card-value" id="db-open" style="color:var(--yellow)">0</div><div class="card-sub">Offen</div></div>
|
|
547
|
+
<div class="card" style="text-align:center"><div class="card-value" id="db-synthesized" style="color:var(--green)">0</div><div class="card-sub">Synthesiert</div></div>
|
|
548
|
+
<div class="card" style="text-align:center"><div class="card-value" id="db-challenges" style="color:var(--red)">0</div><div class="card-sub">Challenges</div></div>
|
|
549
|
+
</div>
|
|
550
|
+
</div>
|
|
551
|
+
|
|
552
|
+
<!-- Recent Debates -->
|
|
553
|
+
<div class="section">
|
|
554
|
+
<div class="section-title"><span class="icon">💬</span> Letzte Debatten</div>
|
|
555
|
+
<div id="debateList" style="margin-top:8px"><div class="empty">Noch keine Debatten gestartet</div></div>
|
|
556
|
+
</div>
|
|
557
|
+
|
|
558
|
+
<!-- Advocatus Diaboli: Principle Challenges -->
|
|
559
|
+
<div class="section">
|
|
560
|
+
<div class="section-title"><span class="icon">🔥</span> Advocatus Diaboli — Prinzip-Challenges</div>
|
|
561
|
+
<p style="font-size:12px;color:var(--text-dim);margin-bottom:12px">Jedes Prinzip wird aktiv hinterfragt. Überlebt es die Gegenargumente, oder wird es geschwächt/widerlegt?</p>
|
|
562
|
+
<div id="challengeList" style="margin-top:8px"><div class="empty">Noch keine Challenges durchgeführt</div></div>
|
|
563
|
+
</div>
|
|
564
|
+
|
|
565
|
+
<!-- Most Vulnerable Principles -->
|
|
566
|
+
<div class="section">
|
|
567
|
+
<div class="section-title"><span class="icon">⚠</span> Verwundbarste Prinzipien</div>
|
|
568
|
+
<p style="font-size:12px;color:var(--text-dim);margin-bottom:12px">Prinzipien mit den niedrigsten Resilienz-Scores — die schwächsten Überzeugungen, die überprüft werden sollten.</p>
|
|
569
|
+
<div id="vulnerableList" style="margin-top:8px"><div class="empty">Keine verwundbaren Prinzipien</div></div>
|
|
570
|
+
</div>
|
|
571
|
+
</div>
|
|
572
|
+
|
|
573
|
+
<!-- ════ Page 8: Infrastruktur ══════════════════════ -->
|
|
538
574
|
<div class="page" id="page-infra">
|
|
575
|
+
<div class="section">
|
|
576
|
+
<div class="section-title"><span class="icon">🛡</span> Watchdog — Daemon-Überwachung</div>
|
|
577
|
+
<p style="font-size:12px;color:var(--text-dim);margin-bottom:12px">Überwacht alle Brain-Daemons. Grün = gesund, Gelb = läuft aber Healthcheck fehlgeschlagen, Rot = gestoppt. Auto-Update alle 30s.</p>
|
|
578
|
+
<div class="grid grid-3" id="watchdogCards"><div class="empty">Loading...</div></div>
|
|
579
|
+
</div>
|
|
580
|
+
<div class="section">
|
|
581
|
+
<div class="section-title"><span class="icon">✅</span> System Health Check</div>
|
|
582
|
+
<div class="card" id="healthCheckCard"><div class="empty">Loading...</div></div>
|
|
583
|
+
</div>
|
|
539
584
|
<div class="grid grid-2">
|
|
540
|
-
<div class="section">
|
|
541
|
-
<div class="section-title"><span class="icon">🛡</span> Watchdog — Hält alles am Laufen</div>
|
|
542
|
-
<div class="card" id="watchdogCard"><div class="empty">Loading...</div></div>
|
|
543
|
-
</div>
|
|
544
585
|
<div class="section">
|
|
545
586
|
<div class="section-title"><span class="icon">🧩</span> Plugins — Erweiterungen</div>
|
|
546
587
|
<div class="card" id="pluginCard"><div class="empty">Loading...</div></div>
|
|
547
588
|
</div>
|
|
589
|
+
<div class="section" style="min-height:100px">
|
|
590
|
+
<div class="section-title"><span class="icon">📊</span> Dienst-Statistik</div>
|
|
591
|
+
<div class="card" id="watchdogStatsCard"><div class="empty">Loading...</div></div>
|
|
592
|
+
</div>
|
|
548
593
|
</div>
|
|
549
594
|
<div class="section">
|
|
550
595
|
<div class="section-title"><span class="icon">🏭</span> Alle Engines auf einen Blick</div>
|
|
551
596
|
<p style="font-size:12px;color:var(--text-dim);margin-bottom:8px">Grün = aktiv, Gelb = bereit, Grau = aus. Die Zahl zeigt wie viele Gedanken die Engine produziert hat.</p>
|
|
552
597
|
<div class="engine-grid" id="allEngineGrid"><div class="empty">Loading...</div></div>
|
|
553
598
|
</div>
|
|
554
|
-
<div class="section">
|
|
555
|
-
<div class="section-title"><span class="icon">✅</span> System Health Check</div>
|
|
556
|
-
<div class="card" id="healthCheckCard"><div class="empty">Loading...</div></div>
|
|
557
|
-
</div>
|
|
558
599
|
</div>
|
|
559
600
|
</div>
|
|
560
601
|
</div>
|
|
@@ -576,6 +617,7 @@ const titles = {
|
|
|
576
617
|
marketing:'Marketing Flow',
|
|
577
618
|
crossbrain:'Cross-Brain & Borg',
|
|
578
619
|
activity:'Aktivität & Missionen',
|
|
620
|
+
debates:'Debates & Challenges',
|
|
579
621
|
infra:'Infrastruktur'
|
|
580
622
|
};
|
|
581
623
|
document.querySelectorAll('.nav-item').forEach(item => {
|
|
@@ -603,6 +645,7 @@ function connectSSE() {
|
|
|
603
645
|
es.addEventListener('selfmod', e => { state.selfmod = JSON.parse(e.data); renderSelfMod(); });
|
|
604
646
|
es.addEventListener('missions', e => { state.missions = JSON.parse(e.data); renderMissions(); });
|
|
605
647
|
es.addEventListener('knowledge', e => { state.knowledge = JSON.parse(e.data); renderKnowledge(); });
|
|
648
|
+
es.addEventListener('debates', e => { state.debates = JSON.parse(e.data); renderDebates(); });
|
|
606
649
|
es.onerror = () => { state.connected = false; updateConnection(); };
|
|
607
650
|
}
|
|
608
651
|
|
|
@@ -621,10 +664,11 @@ async function loadInitial() {
|
|
|
621
664
|
state.borg = data.borg; state.analytics = data.analytics; state.llm = data.llm;
|
|
622
665
|
state.errors = data.errors; state.selfmod = data.selfmod;
|
|
623
666
|
state.missions = data.missions; state.knowledge = data.knowledge;
|
|
667
|
+
state.debates = data.debates;
|
|
624
668
|
if (data.thoughts) { state.thoughts = data.thoughts; renderThoughts(); }
|
|
625
669
|
renderEcosystem(); renderEngines(); renderWatchdog(); renderPlugins();
|
|
626
670
|
renderBorg(); renderAnalytics(); renderLLM(); renderErrors();
|
|
627
|
-
renderSelfMod(); renderMissions(); renderKnowledge();
|
|
671
|
+
renderSelfMod(); renderMissions(); renderKnowledge(); renderDebates();
|
|
628
672
|
} catch {}
|
|
629
673
|
}
|
|
630
674
|
|
|
@@ -943,14 +987,47 @@ function num(v) { if (v == null) return 0; if (typeof v === 'object') return v.t
|
|
|
943
987
|
|
|
944
988
|
// ── Render: Watchdog ──────────────────────────────────────
|
|
945
989
|
function renderWatchdog() {
|
|
946
|
-
const el = document.getElementById('
|
|
990
|
+
const el = document.getElementById('watchdogCards');
|
|
947
991
|
const d = state.watchdog || [];
|
|
948
|
-
if (!d.length) { el.innerHTML = '<div class="empty">Kein Watchdog konfiguriert</div>'; return; }
|
|
949
|
-
|
|
950
|
-
|
|
992
|
+
if (!d.length) { el.innerHTML = '<div class="empty">Kein Watchdog konfiguriert — starte Brain mit <code>brain start</code></div>'; return; }
|
|
993
|
+
|
|
994
|
+
// Daemon cards — color-coded
|
|
995
|
+
el.innerHTML = d.map(x => {
|
|
996
|
+
const borderColor = !x.running ? 'var(--red)' : x.healthy ? 'var(--green)' : 'var(--orange)';
|
|
997
|
+
const bgColor = !x.running ? 'rgba(239,68,68,0.08)' : x.healthy ? 'rgba(34,197,94,0.08)' : 'rgba(234,179,8,0.08)';
|
|
998
|
+
const statusText = !x.running ? 'Gestoppt' : x.healthy ? 'Gesund' : 'Problem';
|
|
999
|
+
const statusIcon = !x.running ? '🔴' : x.healthy ? '🟢' : '🟡';
|
|
1000
|
+
const uptime = x.uptime ? fmtUp(x.uptime / 1000) : '-';
|
|
1001
|
+
return `<div class="card" style="border-left:3px solid ${borderColor};background:${bgColor};padding:16px">
|
|
1002
|
+
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
|
|
1003
|
+
<div style="font-size:15px;font-weight:700">${x.name}</div>
|
|
1004
|
+
<span style="font-size:14px">${statusIcon} ${statusText}</span>
|
|
1005
|
+
</div>
|
|
1006
|
+
<div style="display:grid;grid-template-columns:1fr 1fr;gap:8px;font-size:12px">
|
|
1007
|
+
<div><span style="color:var(--text-dim)">PID</span><br><span style="font-weight:600;font-size:14px">${x.pid || '-'}</span></div>
|
|
1008
|
+
<div><span style="color:var(--text-dim)">Laufzeit</span><br><span style="font-weight:600;font-size:14px">${uptime}</span></div>
|
|
1009
|
+
<div><span style="color:var(--text-dim)">Neustarts</span><br><span style="font-weight:600;font-size:14px;color:${x.restarts > 0 ? 'var(--orange)' : 'inherit'}">${x.restarts || 0}</span></div>
|
|
1010
|
+
<div><span style="color:var(--text-dim)">Letzter Crash</span><br><span style="font-weight:600;font-size:11px">${x.lastCrash ? new Date(x.lastCrash).toLocaleString('de') : '-'}</span></div>
|
|
1011
|
+
</div>
|
|
1012
|
+
</div>`;
|
|
1013
|
+
}).join('');
|
|
1014
|
+
|
|
1015
|
+
// Health check summary
|
|
951
1016
|
const hc = document.getElementById('healthCheckCard');
|
|
952
1017
|
const ok = d.every(x => x.running && x.healthy), off = d.filter(x => !x.running).length;
|
|
953
|
-
|
|
1018
|
+
const unhealthy = d.filter(x => x.running && !x.healthy).length;
|
|
1019
|
+
hc.innerHTML = `<div style="display:flex;gap:20px;align-items:center"><span style="font-size:32px">${ok?'✅':off?'🚨':'⚠'}</span><div><div style="font-size:15px;font-weight:600;color:${ok?'var(--green)':off?'var(--red)':'var(--orange)'}">${ok?'Alle Systeme laufen':off?`${off} Dienste offline`:`${unhealthy} Dienste mit Problemen`}</div><div style="font-size:12px;color:var(--text-dim);margin-top:4px">${d.length} Dienste überwacht • ${d.filter(x=>x.running).length} laufen • ${d.filter(x=>x.running&&x.healthy).length} gesund</div></div></div>`;
|
|
1020
|
+
|
|
1021
|
+
// Stats card
|
|
1022
|
+
const sc = document.getElementById('watchdogStatsCard');
|
|
1023
|
+
const totalRestarts = d.reduce((s, x) => s + (x.restarts || 0), 0);
|
|
1024
|
+
const avgUptime = d.filter(x => x.uptime).map(x => x.uptime);
|
|
1025
|
+
const maxUp = avgUptime.length ? fmtUp(Math.max(...avgUptime) / 1000) : '-';
|
|
1026
|
+
sc.innerHTML = `<div style="display:flex;gap:24px;font-size:13px">
|
|
1027
|
+
<div><span style="color:var(--text-dim)">Gesamt-Neustarts</span><br><span style="font-size:20px;font-weight:700;color:${totalRestarts>0?'var(--orange)':'var(--green)'}">${totalRestarts}</span></div>
|
|
1028
|
+
<div><span style="color:var(--text-dim)">Längste Laufzeit</span><br><span style="font-size:20px;font-weight:700">${maxUp}</span></div>
|
|
1029
|
+
<div><span style="color:var(--text-dim)">Dienste</span><br><span style="font-size:20px;font-weight:700">${d.length}</span></div>
|
|
1030
|
+
</div>`;
|
|
954
1031
|
}
|
|
955
1032
|
|
|
956
1033
|
function renderPlugins() {
|
|
@@ -979,6 +1056,72 @@ document.getElementById('borgToggle').addEventListener('click', async () => {
|
|
|
979
1056
|
try { await fetch('/api/borg/toggle', { method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({enabled:!state.borg.status.enabled}) }); } catch {}
|
|
980
1057
|
});
|
|
981
1058
|
|
|
1059
|
+
// ── Render: Debates ──────────────────────────────────────
|
|
1060
|
+
function renderDebates() {
|
|
1061
|
+
const d = state.debates; if (!d) return;
|
|
1062
|
+
const s = d.status;
|
|
1063
|
+
if (s) {
|
|
1064
|
+
const el = (id) => document.getElementById(id);
|
|
1065
|
+
el('db-total').textContent = s.totalDebates ?? 0;
|
|
1066
|
+
el('db-open').textContent = s.openDebates ?? 0;
|
|
1067
|
+
el('db-synthesized').textContent = s.synthesizedDebates ?? 0;
|
|
1068
|
+
el('db-challenges').textContent = s.totalChallenges ?? 0;
|
|
1069
|
+
}
|
|
1070
|
+
// Recent debates
|
|
1071
|
+
const list = d.recent || [];
|
|
1072
|
+
const listEl = document.getElementById('debateList');
|
|
1073
|
+
if (!list.length) { listEl.innerHTML = '<div class="empty">Noch keine Debatten gestartet</div>'; }
|
|
1074
|
+
else {
|
|
1075
|
+
listEl.innerHTML = list.map(db => {
|
|
1076
|
+
const statusCol = db.status === 'synthesized' ? 'var(--green)' : db.status === 'open' ? 'var(--yellow)' : 'var(--cyan)';
|
|
1077
|
+
const persp = (db.perspectives || []).length;
|
|
1078
|
+
return `<div class="card" style="margin-bottom:8px;padding:10px 14px">
|
|
1079
|
+
<div style="display:flex;justify-content:space-between;align-items:center">
|
|
1080
|
+
<strong style="color:var(--cyan)">#${db.id}: ${db.question?.substring(0,80)||'?'}</strong>
|
|
1081
|
+
<span style="color:${statusCol};font-size:11px;text-transform:uppercase">${db.status}</span>
|
|
1082
|
+
</div>
|
|
1083
|
+
<div style="font-size:11px;color:var(--text-dim);margin-top:4px">${persp} Perspektiven | ${db.created_at ? new Date(db.created_at).toLocaleString('de-DE') : ''}</div>
|
|
1084
|
+
${db.synthesis ? `<div style="font-size:11px;margin-top:4px;color:var(--green)">Konsens: ${(db.synthesis.consensus||'').substring(0,120)}...</div>` : ''}
|
|
1085
|
+
</div>`;
|
|
1086
|
+
}).join('');
|
|
1087
|
+
}
|
|
1088
|
+
// Challenges
|
|
1089
|
+
const chList = d.challenges || [];
|
|
1090
|
+
const chEl = document.getElementById('challengeList');
|
|
1091
|
+
if (!chList.length) { chEl.innerHTML = '<div class="empty">Noch keine Challenges durchgeführt</div>'; }
|
|
1092
|
+
else {
|
|
1093
|
+
chEl.innerHTML = chList.map(c => {
|
|
1094
|
+
const icon = c.outcome === 'survived' ? '\u2705' : c.outcome === 'weakened' ? '\u26A0\uFE0F' : '\u274C';
|
|
1095
|
+
const col = c.outcome === 'survived' ? 'var(--green)' : c.outcome === 'weakened' ? 'var(--yellow)' : 'var(--red)';
|
|
1096
|
+
const pct = ((c.resilienceScore || 0) * 100).toFixed(0);
|
|
1097
|
+
return `<div class="card" style="margin-bottom:6px;padding:8px 14px;border-left:3px solid ${col}">
|
|
1098
|
+
<div style="display:flex;justify-content:space-between;align-items:center">
|
|
1099
|
+
<span>${icon} ${(c.principleStatement||'').substring(0,80)}</span>
|
|
1100
|
+
<span style="color:${col};font-size:12px;font-weight:bold">${c.outcome?.toUpperCase()} ${pct}%</span>
|
|
1101
|
+
</div>
|
|
1102
|
+
</div>`;
|
|
1103
|
+
}).join('');
|
|
1104
|
+
}
|
|
1105
|
+
// Vulnerable
|
|
1106
|
+
const vulList = d.vulnerable || [];
|
|
1107
|
+
const vulEl = document.getElementById('vulnerableList');
|
|
1108
|
+
if (!vulList.length) { vulEl.innerHTML = '<div class="empty">Keine verwundbaren Prinzipien</div>'; }
|
|
1109
|
+
else {
|
|
1110
|
+
vulEl.innerHTML = vulList.map(v => {
|
|
1111
|
+
const pct = ((v.resilienceScore || 0) * 100).toFixed(0);
|
|
1112
|
+
const barCol = pct < 30 ? 'var(--red)' : pct < 60 ? 'var(--yellow)' : 'var(--green)';
|
|
1113
|
+
return `<div class="card" style="margin-bottom:6px;padding:8px 14px">
|
|
1114
|
+
<div style="font-size:13px;color:var(--text)">${(v.principleStatement||'').substring(0,100)}</div>
|
|
1115
|
+
<div style="display:flex;align-items:center;gap:8px;margin-top:6px">
|
|
1116
|
+
<div style="flex:1;height:6px;background:rgba(255,255,255,0.05);border-radius:3px;overflow:hidden"><div style="width:${pct}%;height:100%;background:${barCol};border-radius:3px"></div></div>
|
|
1117
|
+
<span style="font-size:11px;color:${barCol};min-width:40px">${pct}%</span>
|
|
1118
|
+
<span style="font-size:11px;color:var(--text-dim)">${v.outcome}</span>
|
|
1119
|
+
</div>
|
|
1120
|
+
</div>`;
|
|
1121
|
+
}).join('');
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
|
|
982
1125
|
// ── Quick Actions ─────────────────────────────────────────
|
|
983
1126
|
document.querySelectorAll('.action-btn').forEach(btn => {
|
|
984
1127
|
btn.addEventListener('click', async () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|