How xiaoyuanda666-ship-it/bailongma works
Bailongma is a continuously running desktop AI agent: users send messages through Brain UI or connected social channels, the local service routes them into the agent loop, and the agent responds using an LLM and selectively exposed tools. Around that path, it injects context and persistent memory, supports knowledge and media features, and streams state back to the UI. The README documents these major subsystems and their interactions; sampled source offers only limited additional relationship evidence, so unsampled internals are represented at subsystem level.
Main entry points: index.js Agent loop · app.js Brain UI · gatherer.js Context selection · api.js Local HTTP service
Components 18
Desktop and access
- Electron shell
electron/main.cjs - Local HTTP service
src/api.js
Agent runtime
- Agent loop
src/index.js - LLM layer
src/llm.js
Memory and context
- Context selection
src/context/gatherer.js - Memory system
src/memory/injector.js - SQLite persistence
src/db.js - Knowledge retrieval
src/knowledge/retrieval.js - Local resource sensing
src/local-resources-scanner.js
Capabilities and integrations
- Capability registry
src/capabilities/capability-registry.js - Tool executor
src/capabilities/executor.js - Built-in tools
src/capabilities/tools - Browser and MCP
src/mcp/client-manager.js - Social connectors
src/social/index.js
User-facing features
- Brain UI
src/ui/brain-ui/app.js - Voice services
src/voice/manager.js - UI panels and cards
src/ui/brain-ui/knowledge.js
Other components
- User
Connections 20
- User → Brain UI: sends messages
- Brain UI → Local HTTP service: calls HTTP APIs
- Local HTTP service → Agent loop: routes messages
- Social connectors → Agent loop: forwards inbound messages
- Agent loop → LLM layer: requests completions
- Agent loop → Context selection: selects runtime context
- Context selection → Memory system: injects relevant memory
- Context selection → Knowledge retrieval: adds retrieved knowledge
- Memory system → SQLite persistence: reads and writes
- Agent loop → Capability registry: selects tools
- Capability registry → Tool executor: routes tool calls
- Tool executor → Built-in tools: executes tools
- Built-in tools → Browser and MCP: uses browser tools
src/mcp/client-manager.js - Agent loop → Social connectors: routes replies
- Agent loop → Voice services: generates speech
- Local resource sensing → Context selection: provides host context
- SQLite persistence → Brain UI: shares chat state
- Local HTTP service → UI panels and cards: serves panel APIs
- Brain UI → Voice services: configures voice
- Electron shell → Brain UI: hosts desktop UI