# capgym/cap-x architecture

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

- Interactive diagram: https://gitdiagram.com/capgym/cap-x
- Repository: https://github.com/capgym/cap-x

## Overview

CaP-X is a framework for benchmarking and improving coding agents for robot manipulation. In the main evaluation workflow, an engineer launches a configured trial; it builds a code-execution environment, queries an LLM for robot-control code, and runs that code against a task environment and simulator, with results and artifacts collected. The framework also provides perception and motion-planning APIs, interactive web trials, skill-library support, and an RL reward path. Several subsystems are represented at directory level because their individual runtime files were not sampled.

Main entry points: [`capx/envs/trial.py`](https://github.com/capgym/cap-x/blob/main/capx/envs/trial.py) (Trial loop), [`capx/envs/launch.py`](https://github.com/capgym/cap-x/blob/main/capx/envs/launch.py) (Evaluation launch), [`capx/envs/tasks/base.py`](https://github.com/capgym/cap-x/blob/main/capx/envs/tasks/base.py) (Code execution), [`capx/web/server.py`](https://github.com/capgym/cap-x/blob/main/capx/web/server.py) (Web server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_eval["Evaluation runtime"]
  node_launch["Evaluation launch<br/>[launch.py]"]
  node_config["Config loading<br/>[loader.py]"]
  node_instantiate["Environment setup<br/>[instantiate.py]"]
  node_runner["Batch runner<br/>[runner.py]"]
  node_trial["Trial loop<br/>[trial.py]"]
  node_llm["LLM client<br/>[client.py]"]
  node_llmservice["LLM proxy"]
  node_artifacts["Trial artifacts"]
end

subgraph group_robot["Robot environments"]
  node_taskenv["Code execution<br/>[base.py]"]
  node_taskregistry["Task catalog<br/>[__init__.py]"]
  node_simulators["Simulators"]
  node_baseenv["Simulator interface<br/>[base.py]"]
end

subgraph group_apis["Robot APIs"]
  node_api["Robot control APIs<br/>[base_api.py]"]
  node_vision["Vision integrations"]
  node_motion["Motion planning"]
end

subgraph group_web["Interactive UI"]
  node_webui["Web interface<br/>[App.tsx]"]
  node_webserver["Web server<br/>[server.py]"]
  node_sessions["Trial sessions<br/>[session_manager.py]"]
  node_webtrial["Interactive runner"]
end

subgraph group_agent["Agent extensions"]
  node_skills["Skill libraries<br/>[library.py]"]
  node_reward["RL rewards"]
end

node_engineer(("Engineer"))

node_engineer -->|"starts evaluation"| node_launch
node_launch -->|"loads configuration"| node_config
node_launch -->|"starts trials"| node_runner
node_runner -.->|"builds environment"| node_instantiate
node_instantiate -.->|"selects task"| node_taskregistry
node_taskregistry -->|"registers environments"| node_taskenv
node_taskenv -->|"wraps simulator"| node_baseenv
node_baseenv -.->|"runs task simulation"| node_simulators
node_runner -->|"executes trial"| node_trial
node_trial -->|"requests code"| node_llm
node_llm -->|"sends model request"| node_llmservice
node_taskenv -->|"exposes control APIs"| node_api
node_api -->|"composes perception"| node_vision
node_api -->|"uses motion planning"| node_motion
node_trial -.->|"records results"| node_artifacts
node_engineer -->|"starts interactive trial"| node_webui
node_webui -.->|"calls trial service"| node_webserver
node_launch -->|"starts web mode"| node_webserver
node_webserver -->|"manages sessions"| node_sessions
node_webserver -->|"dispatches trial"| node_webtrial
node_webtrial -->|"runs trial logic"| node_trial
node_trial -->|"uses skill libraries"| node_skills
node_taskenv -->|"supplies environment rewards"| node_reward

click node_launch "https://github.com/capgym/cap-x/blob/main/capx/envs/launch.py"
click node_config "https://github.com/capgym/cap-x/blob/main/capx/envs/configs/loader.py"
click node_instantiate "https://github.com/capgym/cap-x/blob/main/capx/envs/configs/instantiate.py"
click node_runner "https://github.com/capgym/cap-x/blob/main/capx/envs/runner.py"
click node_trial "https://github.com/capgym/cap-x/blob/main/capx/envs/trial.py"
click node_llm "https://github.com/capgym/cap-x/blob/main/capx/llm/client.py"
click node_llmservice "https://github.com/capgym/cap-x/blob/main/capx/serving/openrouter_server.py"
click node_taskenv "https://github.com/capgym/cap-x/blob/main/capx/envs/tasks/base.py"
click node_taskregistry "https://github.com/capgym/cap-x/blob/main/capx/envs/tasks/__init__.py"
click node_simulators "https://github.com/capgym/cap-x/tree/main/capx/envs/simulators"
click node_baseenv "https://github.com/capgym/cap-x/blob/main/capx/envs/base.py"
click node_api "https://github.com/capgym/cap-x/blob/main/capx/integrations/base_api.py"
click node_vision "https://github.com/capgym/cap-x/tree/main/capx/integrations/vision"
click node_motion "https://github.com/capgym/cap-x/tree/main/capx/integrations/motion"
click node_artifacts "https://github.com/capgym/cap-x/blob/main/capx/utils/execution_logger.py"
click node_webui "https://github.com/capgym/cap-x/blob/main/web-ui/src/App.tsx"
click node_webserver "https://github.com/capgym/cap-x/blob/main/capx/web/server.py"
click node_sessions "https://github.com/capgym/cap-x/blob/main/capx/web/session_manager.py"
click node_webtrial "https://github.com/capgym/cap-x/blob/main/capx/web/async_trial_runner.py"
click node_skills "https://github.com/capgym/cap-x/blob/main/capx/skills/library.py"
click node_reward "https://github.com/capgym/cap-x/blob/main/verl_agent_reward/capx_franka_reward.py"

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_launch,node_config,node_instantiate,node_runner,node_trial,node_llm,node_llmservice,node_artifacts toneBlue
class node_taskenv,node_taskregistry,node_simulators,node_baseenv toneAmber
class node_api,node_vision,node_motion toneMint
class node_webui,node_webserver,node_sessions,node_webtrial toneRose
class node_skills,node_reward,node_engineer toneIndigo
```

## Components

### Evaluation runtime

- [Evaluation launch](https://github.com/capgym/cap-x/blob/main/capx/envs/launch.py): `capx/envs/launch.py`
- [Config loading](https://github.com/capgym/cap-x/blob/main/capx/envs/configs/loader.py): `capx/envs/configs/loader.py`
- [Environment setup](https://github.com/capgym/cap-x/blob/main/capx/envs/configs/instantiate.py): `capx/envs/configs/instantiate.py`
- [Batch runner](https://github.com/capgym/cap-x/blob/main/capx/envs/runner.py): `capx/envs/runner.py`
- [Trial loop](https://github.com/capgym/cap-x/blob/main/capx/envs/trial.py): `capx/envs/trial.py`
- [LLM client](https://github.com/capgym/cap-x/blob/main/capx/llm/client.py): `capx/llm/client.py`
- [LLM proxy](https://github.com/capgym/cap-x/blob/main/capx/serving/openrouter_server.py): `capx/serving/openrouter_server.py`
- [Trial artifacts](https://github.com/capgym/cap-x/blob/main/capx/utils/execution_logger.py): `capx/utils/execution_logger.py`

### Robot environments

- [Code execution](https://github.com/capgym/cap-x/blob/main/capx/envs/tasks/base.py): `capx/envs/tasks/base.py`
- [Task catalog](https://github.com/capgym/cap-x/blob/main/capx/envs/tasks/__init__.py): `capx/envs/tasks/__init__.py`
- [Simulators](https://github.com/capgym/cap-x/tree/main/capx/envs/simulators): `capx/envs/simulators`
- [Simulator interface](https://github.com/capgym/cap-x/blob/main/capx/envs/base.py): `capx/envs/base.py`

### Robot APIs

- [Robot control APIs](https://github.com/capgym/cap-x/blob/main/capx/integrations/base_api.py): `capx/integrations/base_api.py`
- [Vision integrations](https://github.com/capgym/cap-x/tree/main/capx/integrations/vision): `capx/integrations/vision`
- [Motion planning](https://github.com/capgym/cap-x/tree/main/capx/integrations/motion): `capx/integrations/motion`

### Interactive UI

- [Web interface](https://github.com/capgym/cap-x/blob/main/web-ui/src/App.tsx): `web-ui/src/App.tsx`
- [Web server](https://github.com/capgym/cap-x/blob/main/capx/web/server.py): `capx/web/server.py`
- [Trial sessions](https://github.com/capgym/cap-x/blob/main/capx/web/session_manager.py): `capx/web/session_manager.py`
- [Interactive runner](https://github.com/capgym/cap-x/blob/main/capx/web/async_trial_runner.py): `capx/web/async_trial_runner.py`

### Agent extensions

- [Skill libraries](https://github.com/capgym/cap-x/blob/main/capx/skills/library.py): `capx/skills/library.py`
- [RL rewards](https://github.com/capgym/cap-x/blob/main/verl_agent_reward/capx_franka_reward.py): `verl_agent_reward/capx_franka_reward.py`

### Other components

- **Engineer**

## Connections

- Engineer → Evaluation launch: starts evaluation
- Evaluation launch → Config loading: loads configuration (evidence: `capx/utils/launch_utils.py`)
- Evaluation launch → Batch runner: starts trials (evidence: `capx/envs/launch.py`)
- Batch runner → Environment setup: builds environment
- Environment setup → Task catalog: selects task
- Task catalog → Code execution: registers environments (evidence: `capx/envs/tasks/__init__.py`)
- Code execution → Simulator interface: wraps simulator (evidence: `capx/envs/tasks/base.py`)
- Simulator interface → Simulators: runs task simulation (evidence: `capx/envs/simulators/r1pro_b1k.py`)
- Batch runner → Trial loop: executes trial
- Trial loop → LLM client: requests code (evidence: `capx/envs/trial.py`)
- LLM client → LLM proxy: sends model request (evidence: `capx/llm/client.py`)
- Code execution → Robot control APIs: exposes control APIs (evidence: `capx/envs/tasks/base.py`)
- Robot control APIs → Vision integrations: composes perception (evidence: `capx/integrations/franka/libero.py`)
- Robot control APIs → Motion planning: uses motion planning (evidence: `capx/integrations/franka/libero.py`)
- Trial loop → Trial artifacts: records results
- Engineer → Web interface: starts interactive trial
- Web interface → Web server: calls trial service
- Evaluation launch → Web server: starts web mode (evidence: `capx/envs/launch.py`)
- Web server → Trial sessions: manages sessions (evidence: `capx/web/server.py`)
- Web server → Interactive runner: dispatches trial (evidence: `capx/web/server.py`)
- Interactive runner → Trial loop: runs trial logic (evidence: `capx/web/async_trial_runner.py`)
- Trial loop → Skill libraries: uses skill libraries (evidence: `capx/envs/trial.py`)
- Code execution → RL rewards: supplies environment rewards (evidence: `verl_agent_reward/capx_franka_reward.py`)
