How smixs/agent-second-brain works
Agent Second Brain accepts Telegram messages and media, preserves incoming material in an Obsidian vault, and routes conversation through a persistent interactive Claude Code session. Separate scheduled-job and nightly-processing paths extend the core workflow; watchdog and doctor services support uptime. The README documents autograph’s graph-memory capabilities, but its implementation is supplied as a vault skill and was not sampled. Some subsystem links below rely on README statements or SOURCE INDEX references rather than inspected implementation details.
Main entry points: runtime.py Session runtime · main.py Bot runtime · chat.py Chat and media · commands.py Commands
Components 27
Telegram interface
- Bot runtime
src/d_brain/bot/main.py - Chat and media
src/d_brain/bot/handlers/chat.py - Commands
src/d_brain/bot/handlers/commands.py - Keyboard buttons
src/d_brain/bot/handlers/buttons.py - Telegram formatting
src/d_brain/bot/formatters.py - Voice transcription
src/d_brain/services/transcription.py - Manual processing
src/d_brain/bot/handlers/process.py
Claude sessions
- Chat session manager
src/d_brain/services/chat_session.py - Session runtime
src/d_brain/services/runtime.py - Interactive Claude session
src/d_brain/services/claude_session.py - Pane state parsing
src/d_brain/services/tmux_parse.py
Vault and knowledge
- Daily notes and attachments
src/d_brain/services/storage.py - Interaction history
src/d_brain/services/session.py - Obsidian vault
vault - Autograph memory engine
vault/.claude/skills/autograph - Vault Git sync
src/d_brain/services/git.py
Automation and health
- Configuration
src/d_brain/config.py - Daily processor
src/d_brain/services/processor.py - Nightly pipeline
src/d_brain/pipeline.py - Scheduled job runner
src/d_brain/services/cron_runner.py - Cron job store
src/d_brain/services/cron_store.py - Daily health doctor
src/d_brain/services/doctor.py - Session watchdog
src/d_brain/services/watchdog.py - Service notifications
src/d_brain/services/systemd_notify.py
Other components
- Telegram user
- Telegram
- Deepgram
Connections 39
- Telegram user → Telegram: sends messages
README.md - Telegram → Bot runtime: delivers updates
README.md - Bot runtime → Chat and media: routes chat
src/d_brain/bot/main.py - Bot runtime → Commands: registers commands
src/d_brain/bot/main.py - Bot runtime → Keyboard buttons: registers buttons
src/d_brain/bot/main.py - Chat and media → Voice transcription: transcribes voice
src/d_brain/bot/handlers/chat.py - Voice transcription → Deepgram: sends audio
README.md - Chat and media → Daily notes and attachments: saves entries
src/d_brain/bot/handlers/chat.py - Chat and media → Interaction history: records history
src/d_brain/bot/handlers/chat.py - Chat and media → Chat session manager: routes prompts
src/d_brain/bot/handlers/chat.py - Chat and media → Telegram formatting: formats replies
src/d_brain/bot/handlers/chat.py - Commands → Daily notes and attachments: reads daily notes
src/d_brain/bot/handlers/commands.py - Commands → Interaction history: reads history
src/d_brain/bot/handlers/commands.py - Commands → Chat session manager: controls session
src/d_brain/bot/handlers/commands.py - Keyboard buttons → Commands: calls status/help
src/d_brain/bot/handlers/buttons.py - Keyboard buttons → Manual processing: calls processing
src/d_brain/bot/handlers/buttons.py - Chat session manager → Session runtime: gets session
src/d_brain/services/chat_session.py - Session runtime → Interactive Claude session: builds session
src/d_brain/services/runtime.py - Interactive Claude session → Pane state parsing: classifies pane
src/d_brain/services/claude_session.py - Session runtime → Daily processor: builds processor
src/d_brain/services/runtime.py - Daily processor → Interactive Claude session: uses session
src/d_brain/services/processor.py - Interactive Claude session → Obsidian vault: reads and writes
README.md - Obsidian vault → Autograph memory engine: uses memory skill
README.md - Bot runtime → Configuration: uses settings
src/d_brain/bot/main.py - Manual processing → Session runtime: gets processor
src/d_brain/bot/handlers/process.py - Manual processing → Vault Git sync: commits changes
src/d_brain/bot/handlers/process.py - Manual processing → Telegram formatting: formats report
src/d_brain/bot/handlers/process.py - Nightly pipeline → Session runtime: gets runtime
src/d_brain/pipeline.py - Nightly pipeline → Obsidian vault: processes daily entries
README.md - Bot runtime → Scheduled job runner: starts ticker
src/d_brain/bot/main.py - Scheduled job runner → Cron job store: loads jobs
src/d_brain/services/cron_runner.py - Scheduled job runner → Session runtime: gets session
src/d_brain/services/cron_runner.py - Scheduled job runner → Telegram formatting: formats notices
src/d_brain/services/cron_runner.py - Bot runtime → Service notifications: sends readiness
src/d_brain/bot/main.py - Session watchdog → Session runtime: checks session
src/d_brain/services/watchdog.py - Session watchdog → Pane state parsing: checks pane state
src/d_brain/services/watchdog.py - Session watchdog → Service notifications: signals service
src/d_brain/services/watchdog.py - Daily health doctor → Session watchdog: checks health
src/d_brain/services/doctor.py - Daily health doctor → Session runtime: checks runtime
src/d_brain/services/doctor.py