arca-agent 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,220 @@
1
+ Metadata-Version: 2.4
2
+ Name: arca-agent
3
+ Version: 0.1.0
4
+ Summary: ARCA — Local RL-powered Autonomous Cyber Pentesting Agent with LangGraph
5
+ Home-page: https://github.com/dipayandasgupta/arca
6
+ Author: Dipayan Dasgupta
7
+ Author-email: Dipayan Dasgupta <deep.dasgupta2006@gmail.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/DipayanDasgupta/arca
10
+ Project-URL: Repository, https://github.com/DipayanDasgupta/arca
11
+ Keywords: reinforcement-learning,cybersecurity,pentesting,langgraph,agentic-ai,pybind11
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest; extra == "dev"
16
+ Requires-Dist: black; extra == "dev"
17
+ Requires-Dist: ruff; extra == "dev"
18
+ Requires-Dist: mypy; extra == "dev"
19
+ Provides-Extra: cpp
20
+ Requires-Dist: pybind11>=2.11; extra == "cpp"
21
+ Provides-Extra: viz
22
+ Requires-Dist: dash>=2.16; extra == "viz"
23
+ Provides-Extra: all
24
+ Requires-Dist: pybind11>=2.11; extra == "all"
25
+ Requires-Dist: dash>=2.16; extra == "all"
26
+ Requires-Dist: ollama>=0.2; extra == "all"
27
+ Dynamic: author
28
+ Dynamic: home-page
29
+ Dynamic: requires-python
30
+
31
+ # ARCA — Autonomous Reinforcement Cyber Agent
32
+
33
+ > **A fully local, pip-installable RL-powered cyber pentesting simulation framework with LangGraph orchestration and optional C++ acceleration.**
34
+
35
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://python.org)
36
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
37
+ [![RL](https://img.shields.io/badge/RL-PPO%20%7C%20A2C%20%7C%20DQN-orange)](https://stable-baselines3.readthedocs.io)
38
+ [![LangGraph](https://img.shields.io/badge/Orchestration-LangGraph-purple)](https://langchain-ai.github.io/langgraph)
39
+
40
+ ---
41
+
42
+ ## What is ARCA?
43
+
44
+ ARCA trains a reinforcement learning agent to autonomously discover and exploit vulnerabilities in simulated computer networks. It combines:
45
+
46
+ - **Gymnasium-compatible environment** — realistic hosts, subnets, CVEs, and network topology
47
+ - **PPO/A2C/DQN via Stable-Baselines3** — policy training with eval callbacks and checkpointing
48
+ - **LangGraph multi-agent orchestration** — Analyst → Attacker → Critic → Reflection pipeline with LLM-powered explanations
49
+ - **C++ acceleration via pybind11** — BFS reachability, batch exploit simulation, Floyd-Warshall (with pure-Python fallback)
50
+ - **FastAPI REST interface** — `/train`, `/audit`, `/reflect`, `/visualize` endpoints
51
+ - **Rich visualization suite** — Plotly network graphs, training curves, attack path overlays, vulnerability heatmaps
52
+ - **Full CLI** via Typer: `arca train`, `arca serve`, `arca audit`, `arca viz`
53
+
54
+ Everything runs **100% locally** — no cloud, no data leaves your machine.
55
+
56
+ ---
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ git clone https://github.com/dipayandasgupta/arca.git
62
+ cd arca
63
+
64
+ # Create virtual environment
65
+ python -m venv venv
66
+ source venv/bin/activate # Windows: venv\Scripts\activate
67
+
68
+ # Install (pure Python — always works)
69
+ pip install -e .
70
+
71
+ # Install with C++ acceleration (requires g++/clang and pybind11)
72
+ pip install -e ".[cpp]"
73
+
74
+ # Install dev dependencies
75
+ pip install -e ".[dev]"
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Quickstart
81
+
82
+ ```python
83
+ from arca import ARCAAgent, NetworkEnv, ARCAConfig
84
+
85
+ # Create environment
86
+ env = NetworkEnv.from_preset("small_office")
87
+
88
+ # Create and train agent
89
+ agent = ARCAAgent(env=env)
90
+ agent.train(timesteps=50_000)
91
+
92
+ # Run one episode
93
+ result = agent.run_episode(render=True)
94
+ print(result.summary())
95
+
96
+ # LangGraph reflection
97
+ agent.enable_langgraph()
98
+ report = agent.reflect(env.get_state_dict())
99
+ print(report["reflection"])
100
+ ```
101
+
102
+ Or via CLI:
103
+
104
+ ```bash
105
+ arca train --timesteps 50000 --preset small_office
106
+ arca serve # starts FastAPI at http://localhost:8000
107
+ arca audit --preset enterprise # one-shot audit report
108
+ arca viz --output ./figures # generate all plots
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Network Presets
114
+
115
+ | Preset | Hosts | Subnets | Vuln Density | Max Steps |
116
+ |---------------|-------|---------|--------------|-----------|
117
+ | `small_office` | 8 | 2 | 50% | 150 |
118
+ | `enterprise` | 25 | 5 | 35% | 300 |
119
+ | `dmz` | 15 | 3 | 45% | 200 |
120
+ | `iot_network` | 20 | 4 | 60% | 250 |
121
+
122
+ ---
123
+
124
+ ## Actions
125
+
126
+ | Action | Description |
127
+ |-------------|------------------------------------------------------|
128
+ | `SCAN` | Discover a reachable host and its services/vulns |
129
+ | `EXPLOIT` | Attempt to compromise a discovered host via a CVE |
130
+ | `PIVOT` | Move attacker's position to a compromised host |
131
+ | `EXFILTRATE`| Extract data value from a compromised host |
132
+
133
+ ---
134
+
135
+ ## LangGraph Architecture
136
+
137
+ ```
138
+ START → analyst_node → attacker_node → critic_node → reflect_node → END
139
+ ↑___________________________|
140
+ (reflection loop)
141
+ ```
142
+
143
+ Each node uses a local LLM (via Ollama, default: `llama3`) for natural-language analysis. Falls back to rule-based logic if Ollama is not running.
144
+
145
+ ---
146
+
147
+ ## C++ Acceleration
148
+
149
+ The optional `_cpp_sim` module (built via pybind11) provides:
150
+
151
+ - `compute_reachability(adj, n)` — BFS all-pairs reachability (~10x faster than NetworkX for dense graphs)
152
+ - `floyd_warshall(weights, n)` — All-pairs shortest path
153
+ - `batch_exploit(hosts, actions, seed)` — Vectorised exploit simulation
154
+
155
+ Falls back to pure Python automatically if not compiled.
156
+
157
+ ---
158
+
159
+ ## API Endpoints
160
+
161
+ Once you run `arca serve`:
162
+
163
+ | Endpoint | Method | Description |
164
+ |-----------------------|--------|------------------------------------|
165
+ | `/` | GET | Health check + status |
166
+ | `/train` | POST | Start a training run |
167
+ | `/audit` | POST | Run an audit episode + get report |
168
+ | `/reflect` | POST | Run LangGraph reflection on state |
169
+ | `/status` | GET | Current training / agent status |
170
+ | `/docs` | GET | Auto-generated Swagger UI |
171
+
172
+ ---
173
+
174
+ ## Project Structure
175
+
176
+ ```
177
+ arca/
178
+ ├── arca/
179
+ │ ├── __init__.py # public API
180
+ │ ├── __version__.py
181
+ │ ├── cli.py # Typer CLI
182
+ │ ├── core/
183
+ │ │ ├── config.py # ARCAConfig dataclass
184
+ │ │ ├── agent.py # ARCAAgent (PPO wrapper + LangGraph)
185
+ │ │ └── trainer.py # SB3 training harness
186
+ │ ├── sim/
187
+ │ │ ├── environment.py # Gymnasium NetworkEnv
188
+ │ │ ├── host.py # Host dataclass
189
+ │ │ ├── action.py # Action / ActionResult types
190
+ │ │ └── network_generator.py
191
+ │ ├── agents/
192
+ │ │ └── langgraph_orchestrator.py
193
+ │ ├── cpp_ext/
194
+ │ │ ├── __init__.py # Python fallback + CPP_AVAILABLE flag
195
+ │ │ └── sim_engine.cpp # pybind11 C++ module
196
+ │ ├── viz/
197
+ │ │ └── visualizer.py # Plotly + NetworkX charts
198
+ │ └── api/
199
+ │ └── server.py # FastAPI app
200
+ ├── tests/
201
+ │ └── test_arca.py
202
+ ├── examples/
203
+ │ └── quickstart.py
204
+ ├── pyproject.toml
205
+ ├── setup.py
206
+ └── README.md
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Disclaimer
212
+
213
+ ARCA is a **simulation and education tool only**. All attack actions run inside a sandboxed in-memory graph. It does **not** perform any real network scanning, exploitation, or traffic generation. For authorised security testing only.
214
+
215
+ ---
216
+
217
+ ## Author
218
+
219
+ **Dipayan Dasgupta** — IIT Madras, Civil Engineering
220
+ [GitHub](https://github.com/dipayandasgupta) · [LinkedIn](https://www.linkedin.com/in/dipayan-dasgupta-24a24719b/)
@@ -0,0 +1,190 @@
1
+ # ARCA — Autonomous Reinforcement Cyber Agent
2
+
3
+ > **A fully local, pip-installable RL-powered cyber pentesting simulation framework with LangGraph orchestration and optional C++ acceleration.**
4
+
5
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://python.org)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
7
+ [![RL](https://img.shields.io/badge/RL-PPO%20%7C%20A2C%20%7C%20DQN-orange)](https://stable-baselines3.readthedocs.io)
8
+ [![LangGraph](https://img.shields.io/badge/Orchestration-LangGraph-purple)](https://langchain-ai.github.io/langgraph)
9
+
10
+ ---
11
+
12
+ ## What is ARCA?
13
+
14
+ ARCA trains a reinforcement learning agent to autonomously discover and exploit vulnerabilities in simulated computer networks. It combines:
15
+
16
+ - **Gymnasium-compatible environment** — realistic hosts, subnets, CVEs, and network topology
17
+ - **PPO/A2C/DQN via Stable-Baselines3** — policy training with eval callbacks and checkpointing
18
+ - **LangGraph multi-agent orchestration** — Analyst → Attacker → Critic → Reflection pipeline with LLM-powered explanations
19
+ - **C++ acceleration via pybind11** — BFS reachability, batch exploit simulation, Floyd-Warshall (with pure-Python fallback)
20
+ - **FastAPI REST interface** — `/train`, `/audit`, `/reflect`, `/visualize` endpoints
21
+ - **Rich visualization suite** — Plotly network graphs, training curves, attack path overlays, vulnerability heatmaps
22
+ - **Full CLI** via Typer: `arca train`, `arca serve`, `arca audit`, `arca viz`
23
+
24
+ Everything runs **100% locally** — no cloud, no data leaves your machine.
25
+
26
+ ---
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ git clone https://github.com/dipayandasgupta/arca.git
32
+ cd arca
33
+
34
+ # Create virtual environment
35
+ python -m venv venv
36
+ source venv/bin/activate # Windows: venv\Scripts\activate
37
+
38
+ # Install (pure Python — always works)
39
+ pip install -e .
40
+
41
+ # Install with C++ acceleration (requires g++/clang and pybind11)
42
+ pip install -e ".[cpp]"
43
+
44
+ # Install dev dependencies
45
+ pip install -e ".[dev]"
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Quickstart
51
+
52
+ ```python
53
+ from arca import ARCAAgent, NetworkEnv, ARCAConfig
54
+
55
+ # Create environment
56
+ env = NetworkEnv.from_preset("small_office")
57
+
58
+ # Create and train agent
59
+ agent = ARCAAgent(env=env)
60
+ agent.train(timesteps=50_000)
61
+
62
+ # Run one episode
63
+ result = agent.run_episode(render=True)
64
+ print(result.summary())
65
+
66
+ # LangGraph reflection
67
+ agent.enable_langgraph()
68
+ report = agent.reflect(env.get_state_dict())
69
+ print(report["reflection"])
70
+ ```
71
+
72
+ Or via CLI:
73
+
74
+ ```bash
75
+ arca train --timesteps 50000 --preset small_office
76
+ arca serve # starts FastAPI at http://localhost:8000
77
+ arca audit --preset enterprise # one-shot audit report
78
+ arca viz --output ./figures # generate all plots
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Network Presets
84
+
85
+ | Preset | Hosts | Subnets | Vuln Density | Max Steps |
86
+ |---------------|-------|---------|--------------|-----------|
87
+ | `small_office` | 8 | 2 | 50% | 150 |
88
+ | `enterprise` | 25 | 5 | 35% | 300 |
89
+ | `dmz` | 15 | 3 | 45% | 200 |
90
+ | `iot_network` | 20 | 4 | 60% | 250 |
91
+
92
+ ---
93
+
94
+ ## Actions
95
+
96
+ | Action | Description |
97
+ |-------------|------------------------------------------------------|
98
+ | `SCAN` | Discover a reachable host and its services/vulns |
99
+ | `EXPLOIT` | Attempt to compromise a discovered host via a CVE |
100
+ | `PIVOT` | Move attacker's position to a compromised host |
101
+ | `EXFILTRATE`| Extract data value from a compromised host |
102
+
103
+ ---
104
+
105
+ ## LangGraph Architecture
106
+
107
+ ```
108
+ START → analyst_node → attacker_node → critic_node → reflect_node → END
109
+ ↑___________________________|
110
+ (reflection loop)
111
+ ```
112
+
113
+ Each node uses a local LLM (via Ollama, default: `llama3`) for natural-language analysis. Falls back to rule-based logic if Ollama is not running.
114
+
115
+ ---
116
+
117
+ ## C++ Acceleration
118
+
119
+ The optional `_cpp_sim` module (built via pybind11) provides:
120
+
121
+ - `compute_reachability(adj, n)` — BFS all-pairs reachability (~10x faster than NetworkX for dense graphs)
122
+ - `floyd_warshall(weights, n)` — All-pairs shortest path
123
+ - `batch_exploit(hosts, actions, seed)` — Vectorised exploit simulation
124
+
125
+ Falls back to pure Python automatically if not compiled.
126
+
127
+ ---
128
+
129
+ ## API Endpoints
130
+
131
+ Once you run `arca serve`:
132
+
133
+ | Endpoint | Method | Description |
134
+ |-----------------------|--------|------------------------------------|
135
+ | `/` | GET | Health check + status |
136
+ | `/train` | POST | Start a training run |
137
+ | `/audit` | POST | Run an audit episode + get report |
138
+ | `/reflect` | POST | Run LangGraph reflection on state |
139
+ | `/status` | GET | Current training / agent status |
140
+ | `/docs` | GET | Auto-generated Swagger UI |
141
+
142
+ ---
143
+
144
+ ## Project Structure
145
+
146
+ ```
147
+ arca/
148
+ ├── arca/
149
+ │ ├── __init__.py # public API
150
+ │ ├── __version__.py
151
+ │ ├── cli.py # Typer CLI
152
+ │ ├── core/
153
+ │ │ ├── config.py # ARCAConfig dataclass
154
+ │ │ ├── agent.py # ARCAAgent (PPO wrapper + LangGraph)
155
+ │ │ └── trainer.py # SB3 training harness
156
+ │ ├── sim/
157
+ │ │ ├── environment.py # Gymnasium NetworkEnv
158
+ │ │ ├── host.py # Host dataclass
159
+ │ │ ├── action.py # Action / ActionResult types
160
+ │ │ └── network_generator.py
161
+ │ ├── agents/
162
+ │ │ └── langgraph_orchestrator.py
163
+ │ ├── cpp_ext/
164
+ │ │ ├── __init__.py # Python fallback + CPP_AVAILABLE flag
165
+ │ │ └── sim_engine.cpp # pybind11 C++ module
166
+ │ ├── viz/
167
+ │ │ └── visualizer.py # Plotly + NetworkX charts
168
+ │ └── api/
169
+ │ └── server.py # FastAPI app
170
+ ├── tests/
171
+ │ └── test_arca.py
172
+ ├── examples/
173
+ │ └── quickstart.py
174
+ ├── pyproject.toml
175
+ ├── setup.py
176
+ └── README.md
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Disclaimer
182
+
183
+ ARCA is a **simulation and education tool only**. All attack actions run inside a sandboxed in-memory graph. It does **not** perform any real network scanning, exploitation, or traffic generation. For authorised security testing only.
184
+
185
+ ---
186
+
187
+ ## Author
188
+
189
+ **Dipayan Dasgupta** — IIT Madras, Civil Engineering
190
+ [GitHub](https://github.com/dipayandasgupta) · [LinkedIn](https://www.linkedin.com/in/dipayan-dasgupta-24a24719b/)
@@ -0,0 +1,40 @@
1
+ """
2
+ ARCA — Autonomous Reinforcement Cyber Agent
3
+ ============================================
4
+ A fully local RL-powered autonomous pentesting agent with:
5
+ • Custom network simulation environment (Gymnasium-compatible)
6
+ • PPO-based reinforcement learning (Stable-Baselines3)
7
+ • LangGraph multi-agent orchestration with LLM critic & reflection
8
+ • C++ accelerated simulation via pybind11 (optional)
9
+ • FastAPI REST interface
10
+ • Rich visualization suite (Plotly + NetworkX)
11
+ • Full CLI via Typer
12
+
13
+ Quickstart
14
+ ----------
15
+ from arca import ARCAAgent, NetworkEnv, ARCAConfig
16
+
17
+ env = NetworkEnv.from_preset("small_office")
18
+ agent = ARCAAgent(env=env)
19
+ agent.train(timesteps=50_000)
20
+ result = agent.run_episode()
21
+ print(result.summary())
22
+ """
23
+
24
+ """ARCA — Autonomous Reinforcement Cyber Agent"""
25
+
26
+ from arca.__version__ import __version__
27
+ from arca.core.config import ARCAConfig
28
+ from arca.sim.environment import NetworkEnv
29
+ from arca.core.agent import ARCAAgent
30
+ from arca.core.trainer import ARCATrainer
31
+ from arca.viz.visualizer import ARCAVisualizer
32
+
33
+ __all__ = [
34
+ "__version__",
35
+ "ARCAConfig",
36
+ "NetworkEnv",
37
+ "ARCAAgent",
38
+ "ARCATrainer",
39
+ "ARCAVisualizer",
40
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"