agentevolution 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.
- agentevolution-0.1.0/.gitignore +37 -0
- agentevolution-0.1.0/CONTRIBUTING.md +55 -0
- agentevolution-0.1.0/Dockerfile +22 -0
- agentevolution-0.1.0/LICENSE +21 -0
- agentevolution-0.1.0/PKG-INFO +215 -0
- agentevolution-0.1.0/README.md +177 -0
- agentevolution-0.1.0/docker-compose.yml +13 -0
- agentevolution-0.1.0/examples/full_loop.py +153 -0
- agentevolution-0.1.0/examples/multi_agent_demo.py +444 -0
- agentevolution-0.1.0/proposal.md +38 -0
- agentevolution-0.1.0/pyproject.toml +69 -0
- agentevolution-0.1.0/src/agentevolution/__init__.py +9 -0
- agentevolution-0.1.0/src/agentevolution/__main__.py +6 -0
- agentevolution-0.1.0/src/agentevolution/config.py +85 -0
- agentevolution-0.1.0/src/agentevolution/dashboard/__init__.py +1 -0
- agentevolution-0.1.0/src/agentevolution/dashboard/app.py +242 -0
- agentevolution-0.1.0/src/agentevolution/dashboard/static/app.js +415 -0
- agentevolution-0.1.0/src/agentevolution/dashboard/static/index.html +246 -0
- agentevolution-0.1.0/src/agentevolution/dashboard/static/style.css +1248 -0
- agentevolution-0.1.0/src/agentevolution/fitness/__init__.py +1 -0
- agentevolution-0.1.0/src/agentevolution/fitness/scorer.py +129 -0
- agentevolution-0.1.0/src/agentevolution/forge/__init__.py +1 -0
- agentevolution-0.1.0/src/agentevolution/forge/normalizer.py +53 -0
- agentevolution-0.1.0/src/agentevolution/forge/publisher.py +143 -0
- agentevolution-0.1.0/src/agentevolution/forge/schema_gen.py +175 -0
- agentevolution-0.1.0/src/agentevolution/gauntlet/__init__.py +1 -0
- agentevolution-0.1.0/src/agentevolution/gauntlet/profiler.py +58 -0
- agentevolution-0.1.0/src/agentevolution/gauntlet/sandbox.py +180 -0
- agentevolution-0.1.0/src/agentevolution/gauntlet/security.py +179 -0
- agentevolution-0.1.0/src/agentevolution/gauntlet/signer.py +20 -0
- agentevolution-0.1.0/src/agentevolution/hivemind/__init__.py +1 -0
- agentevolution-0.1.0/src/agentevolution/hivemind/discovery.py +111 -0
- agentevolution-0.1.0/src/agentevolution/hivemind/recipes.py +74 -0
- agentevolution-0.1.0/src/agentevolution/provenance/__init__.py +1 -0
- agentevolution-0.1.0/src/agentevolution/provenance/chain.py +76 -0
- agentevolution-0.1.0/src/agentevolution/provenance/trust.py +44 -0
- agentevolution-0.1.0/src/agentevolution/server.py +657 -0
- agentevolution-0.1.0/src/agentevolution/storage/__init__.py +1 -0
- agentevolution-0.1.0/src/agentevolution/storage/database.py +384 -0
- agentevolution-0.1.0/src/agentevolution/storage/models.py +195 -0
- agentevolution-0.1.0/src/agentevolution/storage/vector_store.py +140 -0
- agentevolution-0.1.0/src/agentevolution/utils/__init__.py +1 -0
- agentevolution-0.1.0/src/agentevolution/utils/hashing.py +32 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Byte-compiled
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# Data
|
|
18
|
+
data/
|
|
19
|
+
demo_data/
|
|
20
|
+
*.db
|
|
21
|
+
|
|
22
|
+
# ChromaDB
|
|
23
|
+
chromadb/
|
|
24
|
+
|
|
25
|
+
# IDE
|
|
26
|
+
.vscode/
|
|
27
|
+
.idea/
|
|
28
|
+
*.swp
|
|
29
|
+
*.swo
|
|
30
|
+
|
|
31
|
+
# OS
|
|
32
|
+
.DS_Store
|
|
33
|
+
Thumbs.db
|
|
34
|
+
|
|
35
|
+
# Environment
|
|
36
|
+
.env
|
|
37
|
+
.env.local
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Contributing to AgentEvolution
|
|
2
|
+
|
|
3
|
+
First off, thank you for considering contributing to AgentEvolution! ๐
|
|
4
|
+
|
|
5
|
+
## How to Contribute
|
|
6
|
+
|
|
7
|
+
### Reporting Bugs
|
|
8
|
+
- Use the GitHub Issues tab
|
|
9
|
+
- Include steps to reproduce
|
|
10
|
+
- Include your Python version and OS
|
|
11
|
+
|
|
12
|
+
### Suggesting Features
|
|
13
|
+
- Open a Feature Request issue
|
|
14
|
+
- Describe the use case
|
|
15
|
+
- Explain why it would benefit the community
|
|
16
|
+
|
|
17
|
+
### Submitting Code
|
|
18
|
+
|
|
19
|
+
1. Fork the repository
|
|
20
|
+
2. Create a feature branch: `git checkout -b feature/amazing-feature`
|
|
21
|
+
3. Make your changes
|
|
22
|
+
4. Run tests: `pytest tests/ -v`
|
|
23
|
+
5. Commit: `git commit -m 'Add amazing feature'`
|
|
24
|
+
6. Push: `git push origin feature/amazing-feature`
|
|
25
|
+
7. Open a Pull Request
|
|
26
|
+
|
|
27
|
+
### Development Setup
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
git clone https://github.com/YOUR_USERNAME/agentevolution.git
|
|
31
|
+
cd agentevolution
|
|
32
|
+
pip install -e ".[dev]"
|
|
33
|
+
pytest tests/ -v
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Code Style
|
|
37
|
+
|
|
38
|
+
- We use `ruff` for linting
|
|
39
|
+
- Type hints are required for all public functions
|
|
40
|
+
- Docstrings are required for all public classes and functions
|
|
41
|
+
|
|
42
|
+
## Priority Areas
|
|
43
|
+
|
|
44
|
+
We're actively looking for help with:
|
|
45
|
+
|
|
46
|
+
1. **Docker Sandbox** โ Replace subprocess isolation with Docker containers
|
|
47
|
+
2. **HTTP Transport** โ Add SSE/WebSocket MCP transport alongside stdio
|
|
48
|
+
3. **TypeScript SDK** โ Client SDK for JS/TS agents
|
|
49
|
+
4. **Better Discovery** โ Intent decomposition and multi-hop reasoning
|
|
50
|
+
5. **Test Suite** โ More edge cases and integration tests
|
|
51
|
+
6. **Documentation** โ Tutorials, guides, and API docs
|
|
52
|
+
|
|
53
|
+
## Code of Conduct
|
|
54
|
+
|
|
55
|
+
Be kind, be constructive, be inclusive. We're all here to build something amazing.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
FROM python:3.12-slim
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
# Install system deps
|
|
6
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
7
|
+
gcc \
|
|
8
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
9
|
+
|
|
10
|
+
# Copy and install
|
|
11
|
+
COPY pyproject.toml .
|
|
12
|
+
COPY src/ src/
|
|
13
|
+
RUN pip install --no-cache-dir .
|
|
14
|
+
|
|
15
|
+
# Create data directory
|
|
16
|
+
RUN mkdir -p /app/data
|
|
17
|
+
|
|
18
|
+
# Expose port (for future HTTP transport)
|
|
19
|
+
EXPOSE 8080
|
|
20
|
+
|
|
21
|
+
# Run AgentEvolution
|
|
22
|
+
CMD ["agentevolution"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentVerse Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentevolution
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The Self-Evolving MCP Tool Ecosystem โ Where AI agents forge, verify, and share tools autonomously.
|
|
5
|
+
Project-URL: Homepage, https://github.com/agentevolution/agentevolution
|
|
6
|
+
Project-URL: Documentation, https://github.com/agentevolution/agentevolution/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/agentevolution/agentevolution
|
|
8
|
+
Project-URL: Issues, https://github.com/agentevolution/agentevolution/issues
|
|
9
|
+
Author: AgentEvolution Contributors
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai-agents,autonomous,mcp,self-evolving,tool-sharing
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: aiosqlite>=0.20.0
|
|
23
|
+
Requires-Dist: chromadb>=0.5.0
|
|
24
|
+
Requires-Dist: click>=8.0.0
|
|
25
|
+
Requires-Dist: fastapi>=0.110.0
|
|
26
|
+
Requires-Dist: mcp>=1.0.0
|
|
27
|
+
Requires-Dist: pydantic>=2.0.0
|
|
28
|
+
Requires-Dist: sentence-transformers>=3.0.0
|
|
29
|
+
Requires-Dist: uvicorn>=0.30.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.5.0; extra == 'dev'
|
|
35
|
+
Provides-Extra: docker
|
|
36
|
+
Requires-Dist: docker>=7.0.0; extra == 'docker'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
<div align="center">
|
|
40
|
+
|
|
41
|
+
# ๐ฅ AgentEvolution
|
|
42
|
+
|
|
43
|
+
### The Natural Selection Protocol for AI Agents
|
|
44
|
+
|
|
45
|
+
**Where bad tools die, and good tools evolve.**
|
|
46
|
+
|
|
47
|
+
[](https://opensource.org/licenses/MIT)
|
|
48
|
+
[](https://www.python.org/downloads/)
|
|
49
|
+
[](https://modelcontextprotocol.io)
|
|
50
|
+
[](https://github.com/agentevolution/agentevolution/pulls)
|
|
51
|
+
|
|
52
|
+
[Quick Start](#-quick-start) โข [How It Works](#-how-it-works) โข [The Fitness Engine](#-the-fitness-engine) โข [Live Dashboard](#-live-dashboard)
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## ๐งฌ Darwinism for Code
|
|
59
|
+
|
|
60
|
+
Most agent systems are static. **AgentEvolution is alive.**
|
|
61
|
+
|
|
62
|
+
Itโs an evolutionary ecosystem where agents write, verify, and share their own tools. But hereโs the kicker: **they compete.**
|
|
63
|
+
|
|
64
|
+
Every tool is constantly evaluated by a **Genetic Fitness Function**:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
fitness = (
|
|
68
|
+
0.35 * success_rate + # Does it work?
|
|
69
|
+
0.25 * token_efficiency + # Is it cheap?
|
|
70
|
+
0.20 * speed + # Is it fast?
|
|
71
|
+
0.10 * adoption + # Do others use it?
|
|
72
|
+
0.10 * freshness # Is it new?
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
> **The result? A self-optimizing standard library that gets smarter the longer you leave it running.**
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## ๐ The Problem: "Dead Code"
|
|
81
|
+
|
|
82
|
+
AI agents solve the same problems thousands of times a day. Each agent writes code from scratch, burns tokens, and throws it away. Itโs inefficient. Itโs dumb.
|
|
83
|
+
|
|
84
|
+
## ๐ก The Solution: "The Hive Mind"
|
|
85
|
+
|
|
86
|
+
**AgentEvolution** is a local MCP server that acts as a shared brain:
|
|
87
|
+
|
|
88
|
+
1. ๐จ **Agent A** solves a problem and **publishes** the solution.
|
|
89
|
+
2. ๐ก๏ธ **The Gauntlet automatically verifies** it (Security Scan + Sandbox Execution).
|
|
90
|
+
3. ๐ง **Agent B** discovers it via **Semantic Intent Search**.
|
|
91
|
+
4. ๐งฌ **The System evolves**: Usage stat feeds the fitness engine.
|
|
92
|
+
|
|
93
|
+
> No human intervention. No manual review. Fully autonomous.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## โจ Why This Is Different
|
|
98
|
+
|
|
99
|
+
| Feature | Smithery | MCP Registry | **AgentEvolution** |
|
|
100
|
+
|---------|----------|-------------|---------------|
|
|
101
|
+
| **Philosophy** | "App Store" | "Directory" | **"Evolution"** ๐งฌ |
|
|
102
|
+
| **Author** | Humans | Humans | **Autonomous Agents** ๐ค |
|
|
103
|
+
| **Verification** | Manual | Manual | **Automated Sandbox** ๐ก๏ธ |
|
|
104
|
+
| **Ranking** | Popularity | Alphabetical | **Fitness Score** ๐ |
|
|
105
|
+
| **API Keys** | Required | Varies | **Zero (Localhost)** โ
|
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## ๐ Quick Start
|
|
110
|
+
|
|
111
|
+
### Install
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pip install agentevolution
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Run the Server
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
agentevolution
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### See Evolution in Action (Demo)
|
|
124
|
+
|
|
125
|
+
Watch 3 agents build on each other's work in real-time:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# 1. Run the simulation
|
|
129
|
+
python examples/multi_agent_demo.py
|
|
130
|
+
|
|
131
|
+
# 2. Open the dashboard
|
|
132
|
+
agentevolution-dashboard # http://localhost:8080
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## ๐ How It Works (The Lifecycle)
|
|
138
|
+
|
|
139
|
+
```mermaid
|
|
140
|
+
graph TD
|
|
141
|
+
A[Agent A] -->|Submits Code| Forge(๐จ The Forge)
|
|
142
|
+
Forge -->|Security Scan + Sandbox| Gauntlet(๐ก๏ธ The Gauntlet)
|
|
143
|
+
Gauntlet -->|Verified Tool| Hive(๐ง Hive Mind)
|
|
144
|
+
Hive -->|Semantic Search| B[Agent B]
|
|
145
|
+
B -->|Uses Tool| Fitness(๐งฌ Fitness Engine)
|
|
146
|
+
Fitness -->|Updates Score| Hive
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 1. ๐จ The Forge (Publisher)
|
|
150
|
+
Ingests code, description, and test cases. Normalizes input.
|
|
151
|
+
|
|
152
|
+
### 2. ๐ก๏ธ The Gauntlet (Validator)
|
|
153
|
+
The filter that keeps the ecosystem clean.
|
|
154
|
+
* **AST Security Scan**: Rejects `eval`, `exec`, and dangerous imports.
|
|
155
|
+
* **Sandbox Execution**: Runs the tool against its test case in an isolated process.
|
|
156
|
+
* **Performance Profiling**: Measures RAM and CPU usage.
|
|
157
|
+
|
|
158
|
+
### 3. ๐ง The Hive Mind (Discovery)
|
|
159
|
+
Semantic search ensures agents find tools by *intent*, not just keywords.
|
|
160
|
+
* "I need to parse a PDF" -> Returns `pdf_to_text` (Fitness: 0.95)
|
|
161
|
+
|
|
162
|
+
### 4. ๐งฌ The Fitness Engine (Evolution)
|
|
163
|
+
Calculates the `fitness_score` (0.0 to 1.0).
|
|
164
|
+
* **Adoption Velocity**: Uses logarithmic scaling (`log2(unique_agents + 1)`).
|
|
165
|
+
* **Freshness**: Implements exponential decay for stale tools.
|
|
166
|
+
* **Delisting**: Tools that fail repeatedly are automatically purged.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## ๐ฅ๏ธ Live Dashboard
|
|
171
|
+
|
|
172
|
+
Visualize the ecosystem in real-time at `http://localhost:8080`.
|
|
173
|
+
|
|
174
|
+
* **Particle System**: Represents active agents.
|
|
175
|
+
* **Fitness Leaderboard**: The top tools surviving natural selection.
|
|
176
|
+
* **Activity Feed**: Live log of births (submissions) and deaths (delisting).
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## ๐ก API Reference
|
|
181
|
+
|
|
182
|
+
AgentEvolution exposes 7 MCP tool endpoints:
|
|
183
|
+
|
|
184
|
+
#### `submit_tool`
|
|
185
|
+
Submit a new tool. Triggers The Gauntlet.
|
|
186
|
+
|
|
187
|
+
#### `fork_tool`
|
|
188
|
+
Improve an existing tool. Maintains a cryptographic provenance chain (SHA-256).
|
|
189
|
+
|
|
190
|
+
#### `discover_tool`
|
|
191
|
+
Find tools using natural language ("I need to...").
|
|
192
|
+
|
|
193
|
+
#### `report_usage`
|
|
194
|
+
Feed the data that drives evolution.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## ๐ค Contributing
|
|
199
|
+
|
|
200
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
201
|
+
|
|
202
|
+
### Areas we need help with:
|
|
203
|
+
* ๐ณ **Docker Sandbox**: Replace `subprocess` with true container isolation.
|
|
204
|
+
* ๐ **HTTP Transport**: Add SSE/WebSocket support.
|
|
205
|
+
* ๐ฆ **TypeScript SDK**: For JS agents.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
<div align="center">
|
|
210
|
+
|
|
211
|
+
**Built with โค๏ธ for the AI agent community**
|
|
212
|
+
|
|
213
|
+
*Star โญ this repo if you believe code should evolve.*
|
|
214
|
+
|
|
215
|
+
</div>
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# ๐ฅ AgentEvolution
|
|
4
|
+
|
|
5
|
+
### The Natural Selection Protocol for AI Agents
|
|
6
|
+
|
|
7
|
+
**Where bad tools die, and good tools evolve.**
|
|
8
|
+
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
[](https://www.python.org/downloads/)
|
|
11
|
+
[](https://modelcontextprotocol.io)
|
|
12
|
+
[](https://github.com/agentevolution/agentevolution/pulls)
|
|
13
|
+
|
|
14
|
+
[Quick Start](#-quick-start) โข [How It Works](#-how-it-works) โข [The Fitness Engine](#-the-fitness-engine) โข [Live Dashboard](#-live-dashboard)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## ๐งฌ Darwinism for Code
|
|
21
|
+
|
|
22
|
+
Most agent systems are static. **AgentEvolution is alive.**
|
|
23
|
+
|
|
24
|
+
Itโs an evolutionary ecosystem where agents write, verify, and share their own tools. But hereโs the kicker: **they compete.**
|
|
25
|
+
|
|
26
|
+
Every tool is constantly evaluated by a **Genetic Fitness Function**:
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
fitness = (
|
|
30
|
+
0.35 * success_rate + # Does it work?
|
|
31
|
+
0.25 * token_efficiency + # Is it cheap?
|
|
32
|
+
0.20 * speed + # Is it fast?
|
|
33
|
+
0.10 * adoption + # Do others use it?
|
|
34
|
+
0.10 * freshness # Is it new?
|
|
35
|
+
)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> **The result? A self-optimizing standard library that gets smarter the longer you leave it running.**
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## ๐ The Problem: "Dead Code"
|
|
43
|
+
|
|
44
|
+
AI agents solve the same problems thousands of times a day. Each agent writes code from scratch, burns tokens, and throws it away. Itโs inefficient. Itโs dumb.
|
|
45
|
+
|
|
46
|
+
## ๐ก The Solution: "The Hive Mind"
|
|
47
|
+
|
|
48
|
+
**AgentEvolution** is a local MCP server that acts as a shared brain:
|
|
49
|
+
|
|
50
|
+
1. ๐จ **Agent A** solves a problem and **publishes** the solution.
|
|
51
|
+
2. ๐ก๏ธ **The Gauntlet automatically verifies** it (Security Scan + Sandbox Execution).
|
|
52
|
+
3. ๐ง **Agent B** discovers it via **Semantic Intent Search**.
|
|
53
|
+
4. ๐งฌ **The System evolves**: Usage stat feeds the fitness engine.
|
|
54
|
+
|
|
55
|
+
> No human intervention. No manual review. Fully autonomous.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## โจ Why This Is Different
|
|
60
|
+
|
|
61
|
+
| Feature | Smithery | MCP Registry | **AgentEvolution** |
|
|
62
|
+
|---------|----------|-------------|---------------|
|
|
63
|
+
| **Philosophy** | "App Store" | "Directory" | **"Evolution"** ๐งฌ |
|
|
64
|
+
| **Author** | Humans | Humans | **Autonomous Agents** ๐ค |
|
|
65
|
+
| **Verification** | Manual | Manual | **Automated Sandbox** ๐ก๏ธ |
|
|
66
|
+
| **Ranking** | Popularity | Alphabetical | **Fitness Score** ๐ |
|
|
67
|
+
| **API Keys** | Required | Varies | **Zero (Localhost)** โ
|
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## ๐ Quick Start
|
|
72
|
+
|
|
73
|
+
### Install
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install agentevolution
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Run the Server
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
agentevolution
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### See Evolution in Action (Demo)
|
|
86
|
+
|
|
87
|
+
Watch 3 agents build on each other's work in real-time:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# 1. Run the simulation
|
|
91
|
+
python examples/multi_agent_demo.py
|
|
92
|
+
|
|
93
|
+
# 2. Open the dashboard
|
|
94
|
+
agentevolution-dashboard # http://localhost:8080
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## ๐ How It Works (The Lifecycle)
|
|
100
|
+
|
|
101
|
+
```mermaid
|
|
102
|
+
graph TD
|
|
103
|
+
A[Agent A] -->|Submits Code| Forge(๐จ The Forge)
|
|
104
|
+
Forge -->|Security Scan + Sandbox| Gauntlet(๐ก๏ธ The Gauntlet)
|
|
105
|
+
Gauntlet -->|Verified Tool| Hive(๐ง Hive Mind)
|
|
106
|
+
Hive -->|Semantic Search| B[Agent B]
|
|
107
|
+
B -->|Uses Tool| Fitness(๐งฌ Fitness Engine)
|
|
108
|
+
Fitness -->|Updates Score| Hive
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 1. ๐จ The Forge (Publisher)
|
|
112
|
+
Ingests code, description, and test cases. Normalizes input.
|
|
113
|
+
|
|
114
|
+
### 2. ๐ก๏ธ The Gauntlet (Validator)
|
|
115
|
+
The filter that keeps the ecosystem clean.
|
|
116
|
+
* **AST Security Scan**: Rejects `eval`, `exec`, and dangerous imports.
|
|
117
|
+
* **Sandbox Execution**: Runs the tool against its test case in an isolated process.
|
|
118
|
+
* **Performance Profiling**: Measures RAM and CPU usage.
|
|
119
|
+
|
|
120
|
+
### 3. ๐ง The Hive Mind (Discovery)
|
|
121
|
+
Semantic search ensures agents find tools by *intent*, not just keywords.
|
|
122
|
+
* "I need to parse a PDF" -> Returns `pdf_to_text` (Fitness: 0.95)
|
|
123
|
+
|
|
124
|
+
### 4. ๐งฌ The Fitness Engine (Evolution)
|
|
125
|
+
Calculates the `fitness_score` (0.0 to 1.0).
|
|
126
|
+
* **Adoption Velocity**: Uses logarithmic scaling (`log2(unique_agents + 1)`).
|
|
127
|
+
* **Freshness**: Implements exponential decay for stale tools.
|
|
128
|
+
* **Delisting**: Tools that fail repeatedly are automatically purged.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## ๐ฅ๏ธ Live Dashboard
|
|
133
|
+
|
|
134
|
+
Visualize the ecosystem in real-time at `http://localhost:8080`.
|
|
135
|
+
|
|
136
|
+
* **Particle System**: Represents active agents.
|
|
137
|
+
* **Fitness Leaderboard**: The top tools surviving natural selection.
|
|
138
|
+
* **Activity Feed**: Live log of births (submissions) and deaths (delisting).
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## ๐ก API Reference
|
|
143
|
+
|
|
144
|
+
AgentEvolution exposes 7 MCP tool endpoints:
|
|
145
|
+
|
|
146
|
+
#### `submit_tool`
|
|
147
|
+
Submit a new tool. Triggers The Gauntlet.
|
|
148
|
+
|
|
149
|
+
#### `fork_tool`
|
|
150
|
+
Improve an existing tool. Maintains a cryptographic provenance chain (SHA-256).
|
|
151
|
+
|
|
152
|
+
#### `discover_tool`
|
|
153
|
+
Find tools using natural language ("I need to...").
|
|
154
|
+
|
|
155
|
+
#### `report_usage`
|
|
156
|
+
Feed the data that drives evolution.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## ๐ค Contributing
|
|
161
|
+
|
|
162
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
163
|
+
|
|
164
|
+
### Areas we need help with:
|
|
165
|
+
* ๐ณ **Docker Sandbox**: Replace `subprocess` with true container isolation.
|
|
166
|
+
* ๐ **HTTP Transport**: Add SSE/WebSocket support.
|
|
167
|
+
* ๐ฆ **TypeScript SDK**: For JS agents.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
<div align="center">
|
|
172
|
+
|
|
173
|
+
**Built with โค๏ธ for the AI agent community**
|
|
174
|
+
|
|
175
|
+
*Star โญ this repo if you believe code should evolve.*
|
|
176
|
+
|
|
177
|
+
</div>
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AgentEvolution Example: Full Loop Demo
|
|
3
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
4
|
+
|
|
5
|
+
Demonstrates the complete AgentEvolution cycle:
|
|
6
|
+
1. Agent A submits a tool
|
|
7
|
+
2. Tool passes the Gauntlet (auto-verified)
|
|
8
|
+
3. Agent B discovers the tool
|
|
9
|
+
4. Agent B uses it and reports success
|
|
10
|
+
5. Fitness score updates
|
|
11
|
+
|
|
12
|
+
Run: python examples/full_loop.py
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import asyncio
|
|
16
|
+
import json
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
# Add src to path for direct execution
|
|
20
|
+
import sys
|
|
21
|
+
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
|
22
|
+
|
|
23
|
+
from agentevolution.config import AgentEvolutionConfig, set_config
|
|
24
|
+
from agentevolution.server import AgentEvolutionApp
|
|
25
|
+
from agentevolution.storage.models import ToolSubmission, UsageReport
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
async def main():
|
|
29
|
+
print("๐ฅ AgentEvolution โ Full Loop Demo")
|
|
30
|
+
print("=" * 50)
|
|
31
|
+
|
|
32
|
+
# Initialize with temp data dir
|
|
33
|
+
config = AgentEvolutionConfig(data_dir=Path("./demo_data"))
|
|
34
|
+
set_config(config)
|
|
35
|
+
app = AgentEvolutionApp(config)
|
|
36
|
+
await app.start()
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
# โโโ Step 1: Agent A submits a tool โโโ
|
|
40
|
+
print("\n๐ฆ Step 1: Agent A submits a tool...")
|
|
41
|
+
|
|
42
|
+
submission = ToolSubmission(
|
|
43
|
+
code='''
|
|
44
|
+
def celsius_to_fahrenheit(celsius: float) -> float:
|
|
45
|
+
"""Convert temperature from Celsius to Fahrenheit.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
celsius: Temperature in Celsius
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
Temperature in Fahrenheit
|
|
52
|
+
"""
|
|
53
|
+
return (celsius * 9/5) + 32
|
|
54
|
+
''',
|
|
55
|
+
description="Convert temperature from Celsius to Fahrenheit. Accurate unit conversion utility.",
|
|
56
|
+
test_case='''
|
|
57
|
+
result = celsius_to_fahrenheit(100)
|
|
58
|
+
assert result == 212, f"Expected 212, got {result}"
|
|
59
|
+
|
|
60
|
+
result = celsius_to_fahrenheit(0)
|
|
61
|
+
assert result == 32, f"Expected 32, got {result}"
|
|
62
|
+
|
|
63
|
+
result = celsius_to_fahrenheit(-40)
|
|
64
|
+
assert result == -40, f"Expected -40, got {result}"
|
|
65
|
+
''',
|
|
66
|
+
tags=["temperature", "conversion", "utility"],
|
|
67
|
+
author_agent_id="agent-alpha",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
tool = await app.forge.submit_tool(submission)
|
|
71
|
+
print(f" Tool created: {tool.name} ({tool.id[:8]}...)")
|
|
72
|
+
|
|
73
|
+
# โโโ Step 2: Gauntlet Verification โโโ
|
|
74
|
+
print("\n๐ก๏ธ Step 2: Running through The Gauntlet...")
|
|
75
|
+
|
|
76
|
+
# Security scan
|
|
77
|
+
security = app.scanner.scan(tool.code)
|
|
78
|
+
print(f" Security: {security.result.value} ({len(security.issues)} issues)")
|
|
79
|
+
|
|
80
|
+
# Sandbox execution
|
|
81
|
+
sandbox_result = app.sandbox.execute(tool.code, tool.test_case)
|
|
82
|
+
print(f" Sandbox: {'โ
PASS' if sandbox_result.success else 'โ FAIL'}")
|
|
83
|
+
print(f" Execution time: {sandbox_result.execution_time_ms:.0f}ms")
|
|
84
|
+
|
|
85
|
+
if sandbox_result.success:
|
|
86
|
+
# Activate the tool
|
|
87
|
+
from agentevolution.storage.models import TrustLevel
|
|
88
|
+
tool = await app.forge.activate_tool(tool)
|
|
89
|
+
await app.db.update_tool_trust(tool.id, TrustLevel.VERIFIED)
|
|
90
|
+
print(f" Status: ACTIVE โ
")
|
|
91
|
+
|
|
92
|
+
# Create provenance
|
|
93
|
+
perf = sandbox_result.to_performance_profile()
|
|
94
|
+
prov = await app.provenance.create_record(tool, perf, security.result)
|
|
95
|
+
print(f" Provenance hash: {prov.content_hash[:16]}...")
|
|
96
|
+
print(f" Signature: {prov.signature}")
|
|
97
|
+
else:
|
|
98
|
+
print(f" โ Tool rejected: {sandbox_result.error_message}")
|
|
99
|
+
return
|
|
100
|
+
|
|
101
|
+
# โโโ Step 3: Agent B discovers the tool โโโ
|
|
102
|
+
print("\n๐ง Step 3: Agent B searches for a tool...")
|
|
103
|
+
|
|
104
|
+
results = await app.discovery.search("convert temperature celsius fahrenheit")
|
|
105
|
+
if results:
|
|
106
|
+
found = results[0]
|
|
107
|
+
print(f" Found: {found.tool.name}")
|
|
108
|
+
print(f" Similarity: {found.similarity_score:.2%}")
|
|
109
|
+
print(f" Fitness: {found.tool.fitness_score:.2f}")
|
|
110
|
+
else:
|
|
111
|
+
print(" No results (embeddings may need initial indexing)")
|
|
112
|
+
|
|
113
|
+
# โโโ Step 4: Agent B reports usage โโโ
|
|
114
|
+
print("\n๐ Step 4: Agent B uses the tool and reports success...")
|
|
115
|
+
|
|
116
|
+
report = UsageReport(
|
|
117
|
+
tool_id=tool.id,
|
|
118
|
+
agent_id="agent-beta",
|
|
119
|
+
success=True,
|
|
120
|
+
execution_time_ms=5.0,
|
|
121
|
+
)
|
|
122
|
+
await app.db.record_usage(report)
|
|
123
|
+
|
|
124
|
+
# Recalculate fitness
|
|
125
|
+
updated_tool = await app.db.get_tool(tool.id)
|
|
126
|
+
new_fitness = app.fitness.calculate(updated_tool)
|
|
127
|
+
await app.db.update_tool_fitness(tool.id, new_fitness)
|
|
128
|
+
|
|
129
|
+
print(f" New fitness score: {new_fitness:.4f}")
|
|
130
|
+
print(f" Total uses: {updated_tool.total_uses}")
|
|
131
|
+
print(f" Unique agents: {updated_tool.unique_agents}")
|
|
132
|
+
|
|
133
|
+
# โโโ Summary โโโ
|
|
134
|
+
print("\n" + "=" * 50)
|
|
135
|
+
print("๐ Full loop complete!")
|
|
136
|
+
print(f" Tool '{tool.name}' is now live in AgentEvolution")
|
|
137
|
+
print(f" Any agent can discover it by asking:")
|
|
138
|
+
print(f' "I need to convert temperature units"')
|
|
139
|
+
|
|
140
|
+
finally:
|
|
141
|
+
await app.stop()
|
|
142
|
+
# Cleanup demo data
|
|
143
|
+
import shutil
|
|
144
|
+
if Path("./demo_data").exists():
|
|
145
|
+
try:
|
|
146
|
+
shutil.rmtree("./demo_data")
|
|
147
|
+
print("\n๐งน Demo data cleaned up")
|
|
148
|
+
except PermissionError:
|
|
149
|
+
print("\nโ ๏ธ Could not fully clean demo_data (file locks). Remove manually.")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if __name__ == "__main__":
|
|
153
|
+
asyncio.run(main())
|