How bredrumb/tomoribot works
TomoriBot is a self-hosted Discord AI assistant and role-play system. Its principal workflow starts with a Discord message, builds a turn and context, invokes a configured model (and optionally tools), then responds in Discord. Separate branches cover slash-command configuration, personas and memory, media generation and transcription, web/MCP tools, and scheduled work. The graph uses documented capabilities and paths from the tree; sampled excerpts do not establish every runtime connection, so uncertain wiring is omitted.
Main entry points: toolRegistry.ts Tool registry · repositories Personas and memory · respond.ts Slash commands · contextPipelineIntent.ts Context builder
Components 24
Discord interface
- Message handler
src/events/messageCreate/tomoriChat.ts - Slash commands
src/commands/respond.ts
Conversation runtime
- Turn admission
src/utils/chat/admission.ts - Context builder
src/utils/chat/contextPipelineIntent.ts - Turn planning
src/utils/chat/turnPlanner.ts - Tool execution loop
src/utils/chat/toolLoop.ts - Response emitter
src/utils/chat/responseEmitter.ts
AI and tools
- Model providers
src/providers - Tool registry
src/tools/toolRegistry.ts - Web search
src/tools/webSearch/dispatcher.ts - URL fetching
src/tools/fetchUrl/dispatcher.ts - MCP servers
src/tools/mcpServers
Personas and state
- Configuration operations
src/commands - Personas and memory
src/utils/db/repositories - Scheduled work
src/timers/scheduledWorkCoordinator.ts
Multimodal
- Media commands
src/commands/generate - Media tools
src/tools/functionCalls - Audio services
src/utils/audio - Avatar storage
src/utils/storage/avatarStorage.ts
Other components
- Discord user
- Discord
- Model APIs
- PostgreSQL
- Local inference servers
servers
Connections 27
- Discord user → Discord: sends message
- Discord → Message handler: delivers event
- Discord → Slash commands: delivers command
- Message handler → Turn admission: starts turn
- Turn admission → Context builder: builds context
- Context builder → Personas and memory: loads context
- Context builder → Turn planning: provides context
- Turn planning → Model providers: requests generation
- Model providers → Model APIs: calls model
- Model providers → Tool execution loop: dispatches tool calls
- Tool execution loop → Tool registry: resolves tools
- Tool registry → Web search: dispatches search
- Tool registry → URL fetching: dispatches fetch
- Tool registry → MCP servers: dispatches MCP
- Tool execution loop → Personas and memory: updates memory
- Turn planning → Response emitter: provides result
- Response emitter → Discord: sends reply
- Slash commands → Configuration operations: invokes operations
- Configuration operations → Personas and memory: reads and writes
- Personas and memory → PostgreSQL: queries and persists
- Scheduled work → Personas and memory: updates state
- Slash commands → Media commands: invokes generation
- Tool registry → Media tools: dispatches media
- Media commands → Local inference servers: requests inference
- Media tools → Audio services: uses audio services
- Audio services → Local inference servers: requests inference
- Configuration operations → Avatar storage: stores persona assets