How kim0040/masamong2 works
Masamong is a self-hosted Discord companion bot with a local web console. Its main workflow is Discord messages entering through the gateway, being handled by the chat runtime and its tools or room-scoped memory, then producing a reply back to Discord. Operators configure the service, memory, and integrations through the loopback console. The repository also contains a separate experimental Python RAG sandbox; its indexing and retrieval relationships are supported by the sampled source and SOURCE INDEX. Most Go runtime wiring was not sampled, so those links rely on README-documented behavior; uncertain internal calls are omitted.
Main entry points: engine_retrieve.py Sandbox retrieval · runtime.go Chat runtime · engine_index.py Sandbox indexing · tools.go Conversation tools
Components 27
Discord conversation
- Discord gateway
internal/connectors/discord/gateway.go - Inbound messages
internal/connectors/discord/inbound.go - Chat runtime
internal/chat/runtime.go - Application services
internal/application/service.go - Conversation tools
internal/tools/tools.go
Room memory
- Memory engine
internal/memory/engine/engine.go - Memory retrieval
internal/memory/search/retrieve.go - Memory store
internal/memory/store/store.go
Operations and console
- Application storage
internal/storage/store.go - Web console
internal/transport/web/server.go - Console API
internal/transport/web/api.go
External services
- AI model providers
internal/providers/client.go - Web search providers
internal/providers/websearch/websearch.go
Experimental RAG sandbox
- Sandbox indexing
experimental/rag-leaf-parent/engine_index.py - Sandbox context
experimental/rag-leaf-parent/engine_context.py - Sandbox retrieval
experimental/rag-leaf-parent/engine_retrieve.py - Query intent
experimental/rag-leaf-parent/engine_query.py - Candidate fusion
experimental/rag-leaf-parent/candidates.py - Person retrieval
experimental/rag-leaf-parent/person_retrieval.py - Retrieval config
experimental/rag-leaf-parent/retrieval_config.py - Evidence packing
experimental/rag-leaf-parent/evidence_packing.py - Message vectors
experimental/rag-leaf-parent/message_vectors.py - Memory blocks
experimental/rag-leaf-parent/memory_blocks.py - Query embeddings
experimental/rag-leaf-parent/query_embed.py - Time parsing
experimental/rag-leaf-parent/timeparse.py
Other components
- Discord participants
- Local operator
Connections 27
- Discord participants → Discord gateway: sends messages
README.md - Discord gateway → Inbound messages: receives events
- Inbound messages → Chat runtime: handles messages
- Chat runtime → Application services: uses services
- Chat runtime → Memory engine: retrieves room memory
README.md - Memory engine → Memory retrieval: runs retrieval
- Memory retrieval → Memory store: reads memory
- Chat runtime → Conversation tools: invokes tools
README.md - Conversation tools → AI model providers: requests model output
- Conversation tools → Web search providers: searches web
README.md - Chat runtime → Discord gateway: posts replies
README.md - Local operator → Web console: configures service
README.md - Web console → Console API: calls API
- Console API → Application services: updates settings
- Application services → Application storage: persists state
- Sandbox indexing → Sandbox context: uses paths
experimental/rag-leaf-parent/engine_index.py - Sandbox retrieval → Sandbox indexing: loads index
experimental/rag-leaf-parent/engine_retrieve.py - Sandbox retrieval → Query intent: resolves intent
experimental/rag-leaf-parent/engine_query.py - Sandbox retrieval → Candidate fusion: fuses candidates
experimental/rag-leaf-parent/engine_retrieve.py - Query intent → Person retrieval: resolves people
experimental/rag-leaf-parent/engine_query.py - Sandbox retrieval → Person retrieval: retrieves speakers
experimental/rag-leaf-parent/engine_retrieve.py - Sandbox retrieval → Retrieval config: reads settings
experimental/rag-leaf-parent/engine_retrieve.py - Sandbox retrieval → Evidence packing: packs evidence
experimental/rag-leaf-parent/engine_retrieve.py - Sandbox indexing → Message vectors: prepares vectors
experimental/rag-leaf-parent/engine_index.py - Sandbox indexing → Memory blocks: indexes blocks
experimental/rag-leaf-parent/engine_index.py - Sandbox retrieval → Query embeddings: embeds query
experimental/rag-leaf-parent/engine_retrieve.py - Sandbox indexing → Time parsing: parses timestamps
experimental/rag-leaf-parent/engine_index.py