Frontend Wiring
How the 36-engine cognitive loop connects to React. MindProvider creates the entire brain, hooks subscribe to its state, and panels render the streams for the user to observe.
MindProvider
MindProvider
src/components/mind-provider.tsxHooks
Full brain state: engines, signals, selfState
Returns the complete snapshot of all 36 engines, recent signals, and current 6D self-state. Backed by useSyncExternalStore for efficient React re-rendering. Updates every 3rd frame or when there is cognitive activity.
6D emotional state (valence, arousal, confidence, energy, social, curiosity)
Subscribes to self-state changes. Values update via EMA (damping 0.35) with breathing oscillation on arousal. Includes drive pulse outputs.
Consciousness stream (last 20 thoughts)
Returns the most recent 20 consciousness stream entries. Each entry has a flavor (wandering, emotional, memory, curiosity, reflection, urge, metacognitive), timestamp, and intensity (0-1).
Single engine: status, tickCount, debugInfo
Targeted subscription for a single engine. Returns its current status, tick count, last tick time, and engine-specific debug information.
UI Panels
Displays consciousness stream entries with flavor colors
Text input + speech-to-text toggle
Streaming voice output display with waveform
Chat history with ThoughtBridge responses
SVG visualization of all 36 engines + signal flows
Debug info per engine (tick count, last signal, state)
Recent signals with priority coloring and timestamps
Decision tracing: why the arbiter chose this response
6D state history graph over time
React Data Flow
MindProvider (mount)
├── CognitiveLoop
│ ├── 36 Engines (tick at own rates)
│ ├── SignalBus (pub/sub)
│ └── SelfStateManager (6D + drives)
├── ThoughtBridge
│ ├── listens: 'thought' signals
│ ├── calls: /api/mind/think-stream
│ └── emits: 'claude-response' signals
└── BodyBridge
├── listens: 'body-intent' signals
├── calls: /api/body/execute
└── polls: /api/body/tasks (2s interval)
React Tree
└── MindContext.Provider
├── useMind() → full snapshot
├── useSelfState() → 6D state
├── useStream() → consciousness
└── useEngineStatus() → per-engine
useSyncExternalStore binds loop → React
Updates: every 3rd frame OR on activityExample: Grieving User Flow
User: "I'm grieving"
1. TextInput → emit 'text-input' (arousal +0.03, social +0.05)
2. Perception → salience: 0.9 (emotional keywords) → emit 'perception-result'
3. EmotionInfer → regex: grief (valence:-0.6, arousal:-0.3) → 'emotion-detected'
4. PersonState → update 12D state for user
5. Attention → passes threshold → emit 'attention-focus'
6. Binder → fuse text + memory + emotion → 'bound-representation'
7. Arbiter → needsClaude=true, gather empathic+tom+memories
8. Arbiter → emit 'thought' with ActionDecision context
9. ThoughtBridge → POST /api/mind/think-stream
10. System Prompt → "User is experiencing grief. Be gentle. Do NOT redirect."
11. Claude → empathetic response + SHIFT: {valence:-0.2, social:+0.15}
12. ThoughtBridge → parse shift, emit 'claude-response'
13. Arbiter → apply shift to selfState, emit 'voice-output'
14. Voice → TTS: warm, measured tone
15. Expression → empathetic facial expression
16. MemoryWrite → significance 0.7 → persist
17. Persistence → save selfState to IndexedDB