How supermemoryai/company-brain works
Company Brain is a Slack-based company teammate: it observes conversations, builds permission-scoped memory, answers questions, and can act through connected tools. Its principal runtime path runs from Slack events through a brain turn to memory and tool access, then returns responses to Slack. The repository also provides scheduled research and digests, proactive replies, code execution, and a web dashboard for workspace configuration and memory inspection. Wiring beyond the sampled worker, journey, and setup code is based on README-described capabilities and the source tree; uncertain direct calls are omitted.
Main entry points: agent.ts Brain turn · app.tsx Dashboard app · index.ts Brain API routes · worker.ts Worker router
Components 27
Slack conversation runtime
- Slack routes
src/routes/slack/index.ts - Slack events
src/brain/slack/events.ts - Brain turn
src/brain/turn/agent.ts - Slack delivery
src/brain/slack/client.ts
Brain and knowledge
- Prompt building
src/brain/prompt/build.ts - Memory and recall
src/brain/memory/index.ts - Research journeys
src/brain/auto-research/run.ts - Proactive journeys
src/brain/journey/engine.ts
Actions and integrations
- Tool execution
src/brain/turn/tools.ts - MCP integrations
src/brain/tools/mcp/execute.ts - Code sandbox
src/brain/tools/sandbox/tools.ts - Web research
src/brain/tools/web/index.ts - Scheduled work
src/brain/tools/scheduler.ts
Workspace operations
- Setup routes
src/setup/routes.ts - Slack sign-in
src/auth/routes.ts - Brain API routes
src/routes/index.ts - Workspace database
src/db/index.ts
Web interface
- Dashboard app
web/app.tsx - Configuration views
web/components/configure-view.tsx - Memory graph view
web/components/memory-graph/graph-view.tsx
Other components
- Team member
- Slack workspace
- Worker router
src/worker.ts - Memory service
- Workspace administrator
- Model provider
- Connected services
Connections 33
- Slack workspace → Slack routes: sends events
- Worker router → Slack routes: dispatches
- Slack routes → Slack events: handles events
- Slack events → Brain turn: starts turns
- Brain turn → Prompt building: builds context
- Brain turn → Memory and recall: recalls and updates
- Memory and recall → Memory service: reads and writes
- Brain turn → Model provider: requests inference
- Brain turn → Tool execution: runs tools
- Tool execution → MCP integrations: dispatches MCP
- MCP integrations → Connected services: calls tools
- Tool execution → Code sandbox: runs code
- Tool execution → Web research: searches web
- Brain turn → Slack delivery: sends replies
- Slack delivery → Slack workspace: posts messages
- Scheduled work → Research journeys: schedules research
- Research journeys → Brain turn: starts research turns
- Proactive journeys → Brain turn: starts proactive turns
- Worker router → Setup routes: dispatches
- Worker router → Slack sign-in: dispatches
- Worker router → Brain API routes: dispatches
- Setup routes → Workspace database: checks workspace
- Setup routes → Slack workspace: configures app
- Slack sign-in → Workspace database: reads and writes accounts
- Team member → Slack workspace: asks and receives
- Workspace administrator → Dashboard app: uses
- Dashboard app → Slack sign-in: checks session
- Dashboard app → Brain API routes: requests dashboard data
- Dashboard app → Configuration views: shows configuration
- Dashboard app → Memory graph view: shows memory graph
- Configuration views → Brain API routes: updates settings
- Memory graph view → Brain API routes: fetches graph
- Brain API routes → Workspace database: reads and writes