How henrydaum/second-brain works
Second Brain is a local, extensible AI agent with terminal and web chat surfaces. The main workflow is a user message entering through a frontend, being handled by the agent runtime and an LLM, and—when needed—using sandboxed extensions before a response is shown. Its broader product includes persistent conversations, configurable model connections, installable packages, scheduled tasks, file indexing, attachments, and sandboxed HTML widgets. The graph combines README-documented capabilities with relationships visible in indexed source references; several subsystem links are omitted where implementation was not sampled.
Main entry points: conversation_runtime.py Agent runtime · bridge.py Sandbox bridge · event_bus.py Event bus · session.py Session state
Components 21
User interfaces
- Web chat
frame_ui/src/App.tsx - HTTP frontend
bundled/frontends/frontend_http.py - Terminal chat
bundled/frontends/frontend_repl.py - HTML widgets
frame_ui/src/lib/widgets.ts
Agent runtime
- Agent runtime
runtime/conversation_runtime.py - Model registry
llm/registry.py - Attachment parsing
attachments/parse.py
Extensions and sandbox
- Plugin discovery
plugins/plugin_discovery.py - Package manager
bundled/commands/helpers/package_manager.py - Sandbox bridge
sandbox/bridge.py - Plugin validator
sandbox/validator.py - Guest requests
sandbox/guest/requests.py
State and configuration
- Session state
runtime/session.py - Conversation state
state_machine/conversation.py - Application database
pipeline/database.py - Configuration
config/config_manager.py - Event bus
events/event_bus.py
Indexing and automation
- File pipeline
pipeline/orchestrator.py - Scheduled tasks
bundled/services/service_timekeeper.py
Other components
- User
- Model provider
Connections 24
- User → Web chat: sends message
README.md - User → Terminal chat: sends message
README.md - Web chat → HTTP frontend: uses frontend
README.md - Terminal chat → Agent runtime: submits turns
- HTTP frontend → Agent runtime: submits turns
- Agent runtime → Model registry: requests completion
- Model registry → Model provider: calls model
- Session state → Conversation state: uses state
runtime/session.py - Agent runtime → Session state: uses session
- Agent runtime → Attachment parsing: parses attachments
- Agent runtime → Sandbox bridge: invokes extensions
- Plugin discovery → Sandbox bridge: adapts plugins
plugins/plugin_discovery.py - Sandbox bridge → Plugin validator: validates code
sandbox/bridge.py - Sandbox bridge → Guest requests: exposes requests
sandbox/bridge.py - Package manager → Plugin discovery: manages plugins
bundled/commands/helpers/package_manager.py - Agent runtime → Application database: persists conversations
- Agent runtime → Event bus: publishes updates
- Session state → Event bus: sends notifications
runtime/session.py - Agent runtime → User: returns response
- File pipeline → Application database: records indexed files
pipeline/orchestrator.py - File pipeline → Event bus: publishes events
pipeline/orchestrator.py - Scheduled tasks → File pipeline: triggers tasks
- Configuration → Event bus: emits changes
config/config_manager.py - User → HTML widgets: views widgets
README.md