# fangxm233/cortex-agent architecture

> Architecture diagram of the GitHub repository fangxm233/cortex-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fangxm233/cortex-agent
- Repository: https://github.com/fangxm233/cortex-agent

## Overview

Cortex is a long-running autonomous project agent: a user submits a mission through a shared interface, work is organized into verifiable tasks and agent runs, and progress is retained as project files. The README also documents multi-agent thread pipelines, scheduling, skills/plugins, and remote-machine access. The sampled source is partial and mostly covers backend engines and web controllers, so subsystem links below follow documented behavior and omit uncertain implementation-level wiring.

Main entry points: [`agent-server/src/orchestration/orchestrator.ts`](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/orchestration/orchestrator.ts) (Message orchestration), [`agent-server/src/domain/runs/service.ts`](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/runs/service.ts) (Agent run service), [`agent-server/src/entry/daemon.ts`](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/entry/daemon.ts) (Cortex daemon), [`agent-server/src/domain/tasks/dispatcher.ts`](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/tasks/dispatcher.ts) (Task dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_web_ui["Web workbench"]
  node_chat["Chat integrations"]
  node_terminal["Terminal interface"]
end

subgraph group_execution["Work execution"]
  node_orchestrator["Message orchestration<br/>[orchestrator.ts]"]
  node_task_lifecycle["Task lifecycle"]
  node_task_dispatch["Task dispatch<br/>[dispatcher.ts]"]
  node_thread_pipeline["Thread pipelines"]
  node_run_service["Agent run service<br/>[service.ts]"]
  node_engine_adapters["Backend adapters"]
end

subgraph group_project_state["Project state"]
  node_project_log["Project log"]
  node_memory["Project memory"]
  node_task_files["Task records<br/>[store.ts]"]
end

subgraph group_capabilities["Extensions and access"]
  node_scheduler["Scheduler<br/>[scheduler.ts]"]
  node_plugins["Skills and plugins"]
  node_remote["Remote machines"]
end

subgraph group_platform["Server platform"]
  node_daemon["Cortex daemon<br/>[daemon.ts]"]
  node_ui_service["UI service<br/>[ui-service.ts]"]
  node_events["Live events<br/>[event-bus.ts]"]
  node_config[("Configuration<br/>[settings.ts]")]
end

node_user(("Project owner"))

node_user -->|"submits work"| node_web_ui
node_user -->|"messages"| node_chat
node_user -->|"runs commands"| node_terminal
node_web_ui -->|"queries and mutates"| node_ui_service
node_chat -->|"delivers messages"| node_orchestrator
node_terminal -->|"starts and controls"| node_daemon
node_daemon -->|"serves requests"| node_orchestrator
node_ui_service -->|"manages tasks"| node_task_lifecycle
node_orchestrator -->|"dispatches work"| node_task_dispatch
node_task_dispatch -->|"starts runs"| node_run_service
node_thread_pipeline -->|"runs pipeline stages"| node_run_service
node_run_service -->|"executes via"| node_engine_adapters
node_task_lifecycle -->|"tracks progress"| node_task_files
node_memory -->|"maintains context"| node_project_log
node_run_service -->|"records progress"| node_project_log
node_scheduler -->|"dispatches scheduled work"| node_task_dispatch
node_plugins -.->|"extends agent runtime"| node_engine_adapters
node_remote -.->|"provides remote access"| node_engine_adapters
node_orchestrator -->|"publishes updates"| node_events
node_daemon -->|"loads settings"| node_config

click node_daemon "https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/entry/daemon.ts"
click node_web_ui "https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/ui-service"
click node_chat "https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/mcp"
click node_terminal "https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/entry"
click node_ui_service "https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/ui-service/ui-service.ts"
click node_orchestrator "https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/orchestration/orchestrator.ts"
click node_task_lifecycle "https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/tasks"
click node_task_dispatch "https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/tasks/dispatcher.ts"
click node_thread_pipeline "https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/threads"
click node_run_service "https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/runs/service.ts"
click node_engine_adapters "https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/agent-adapter"
click node_project_log "https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/projects"
click node_memory "https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/memory"
click node_task_files "https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/tasks/store.ts"
click node_scheduler "https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/scheduling/scheduler.ts"
click node_plugins "https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/plugins"
click node_remote "https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/remote"
click node_events "https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/events/event-bus.ts"
click node_config "https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/core/settings.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_ui,node_chat,node_terminal toneBlue
class node_orchestrator,node_task_lifecycle,node_task_dispatch,node_thread_pipeline,node_run_service,node_engine_adapters toneAmber
class node_project_log,node_memory,node_task_files toneMint
class node_scheduler,node_plugins,node_remote toneRose
class node_daemon,node_ui_service,node_events,node_config,node_user toneIndigo
```

## Components

### User interfaces

- [Web workbench](https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/ui-service): `agent-server/src/domain/ui-service`
- [Chat integrations](https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/mcp): `agent-server/src/domain/mcp`
- [Terminal interface](https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/entry): `agent-server/src/entry`

### Work execution

- [Message orchestration](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/orchestration/orchestrator.ts): `agent-server/src/orchestration/orchestrator.ts`
- [Task lifecycle](https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/tasks): `agent-server/src/domain/tasks`
- [Task dispatch](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/tasks/dispatcher.ts): `agent-server/src/domain/tasks/dispatcher.ts`
- [Thread pipelines](https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/threads): `agent-server/src/domain/threads`
- [Agent run service](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/runs/service.ts): `agent-server/src/domain/runs/service.ts`
- [Backend adapters](https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/agent-adapter): `agent-server/src/agent-adapter`

### Project state

- [Project log](https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/projects): `agent-server/src/domain/projects`
- [Project memory](https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/memory): `agent-server/src/domain/memory`
- [Task records](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/tasks/store.ts): `agent-server/src/domain/tasks/store.ts`

### Extensions and access

- [Scheduler](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/scheduling/scheduler.ts): `agent-server/src/domain/scheduling/scheduler.ts`
- [Skills and plugins](https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/plugins): `agent-server/src/domain/plugins`
- [Remote machines](https://github.com/fangxm233/cortex-agent/tree/main/agent-server/src/domain/remote): `agent-server/src/domain/remote`

### Server platform

- [Cortex daemon](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/entry/daemon.ts): `agent-server/src/entry/daemon.ts`
- [UI service](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/domain/ui-service/ui-service.ts): `agent-server/src/domain/ui-service/ui-service.ts`
- [Live events](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/events/event-bus.ts): `agent-server/src/events/event-bus.ts`
- [Configuration](https://github.com/fangxm233/cortex-agent/blob/main/agent-server/src/core/settings.ts): `agent-server/src/core/settings.ts`

### Other components

- **Project owner**

## Connections

- Project owner → Web workbench: submits work
- Project owner → Chat integrations: messages
- Project owner → Terminal interface: runs commands
- Web workbench → UI service: queries and mutates
- Chat integrations → Message orchestration: delivers messages
- Terminal interface → Cortex daemon: starts and controls
- Cortex daemon → Message orchestration: serves requests
- UI service → Task lifecycle: manages tasks
- Message orchestration → Task dispatch: dispatches work
- Task dispatch → Agent run service: starts runs
- Thread pipelines → Agent run service: runs pipeline stages
- Agent run service → Backend adapters: executes via
- Task lifecycle → Task records: tracks progress
- Project memory → Project log: maintains context
- Agent run service → Project log: records progress
- Scheduler → Task dispatch: dispatches scheduled work
- Skills and plugins → Backend adapters: extends agent runtime
- Remote machines → Backend adapters: provides remote access
- Message orchestration → Live events: publishes updates
- Cortex daemon → Configuration: loads settings
