agentarc 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.
- agentarc-0.1.0/CHANGELOG.md +121 -0
- agentarc-0.1.0/CONTRIBUTING.md +209 -0
- agentarc-0.1.0/LICENSE +24 -0
- agentarc-0.1.0/MANIFEST.in +14 -0
- agentarc-0.1.0/PKG-INFO +673 -0
- agentarc-0.1.0/README.md +638 -0
- agentarc-0.1.0/agentarc/__init__.py +26 -0
- agentarc-0.1.0/agentarc/__main__.py +318 -0
- agentarc-0.1.0/agentarc/calldata_parser.py +190 -0
- agentarc-0.1.0/agentarc/llm_judge.py +789 -0
- agentarc-0.1.0/agentarc/logger.py +153 -0
- agentarc-0.1.0/agentarc/policy_engine.py +830 -0
- agentarc-0.1.0/agentarc/rules/__init__.py +27 -0
- agentarc-0.1.0/agentarc/rules/validators.py +217 -0
- agentarc-0.1.0/agentarc/simulator.py +165 -0
- agentarc-0.1.0/agentarc/simulators/__init__.py +14 -0
- agentarc-0.1.0/agentarc/simulators/tenderly.py +536 -0
- agentarc-0.1.0/agentarc/wallet_wrapper.py +177 -0
- agentarc-0.1.0/agentarc.egg-info/PKG-INFO +673 -0
- agentarc-0.1.0/agentarc.egg-info/SOURCES.txt +27 -0
- agentarc-0.1.0/agentarc.egg-info/dependency_links.txt +1 -0
- agentarc-0.1.0/agentarc.egg-info/entry_points.txt +2 -0
- agentarc-0.1.0/agentarc.egg-info/requires.txt +16 -0
- agentarc-0.1.0/agentarc.egg-info/top_level.txt +1 -0
- agentarc-0.1.0/pyproject.toml +64 -0
- agentarc-0.1.0/setup.cfg +4 -0
- agentarc-0.1.0/tests/test_complete_system.py +317 -0
- agentarc-0.1.0/tests/test_llm_judge.py +492 -0
- agentarc-0.1.0/tests/test_llm_patterns.py +631 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to AgentArc will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-01-02
|
|
9
|
+
|
|
10
|
+
### 🎉 Initial Release
|
|
11
|
+
|
|
12
|
+
First stable release of AgentArc - A comprehensive security and policy enforcement layer for AI blockchain agents.
|
|
13
|
+
|
|
14
|
+
### ✨ Features
|
|
15
|
+
|
|
16
|
+
#### Core Security Pipeline
|
|
17
|
+
- **Multi-Stage Validation Pipeline**: 4-stage validation (Intent Judge → Policy Validation → Simulation → LLM Analysis)
|
|
18
|
+
- **Zero Agent Modifications**: Pure wrapper pattern for seamless AgentKit integration
|
|
19
|
+
- **3-Line Integration**: Simple API for wrapping any wallet provider
|
|
20
|
+
|
|
21
|
+
#### Policy Engine (7 Policy Types)
|
|
22
|
+
- **ETH Value Limit**: Prevent large ETH transfers per transaction
|
|
23
|
+
- **Address Denylist**: Block transactions to sanctioned/malicious addresses
|
|
24
|
+
- **Address Allowlist**: Whitelist mode - only allow pre-approved addresses
|
|
25
|
+
- **Per-Asset Limits**: Token-specific spending limits (USDC, DAI, etc.)
|
|
26
|
+
- **Token Amount Limit**: Global ERC20 token transfer limits
|
|
27
|
+
- **Gas Limit**: Prevent expensive transactions
|
|
28
|
+
- **Function Allowlist**: Only allow specific function calls
|
|
29
|
+
|
|
30
|
+
#### Transaction Simulation
|
|
31
|
+
- **Tenderly Integration**: Advanced simulation with full execution traces
|
|
32
|
+
- **Asset Change Tracking**: Monitor balance changes before execution
|
|
33
|
+
- **Gas Estimation**: Accurate gas predictions
|
|
34
|
+
- **Revert Detection**: Catch failures before broadcasting
|
|
35
|
+
- **Detailed Trace Output**: Optional `print_trace` for debugging
|
|
36
|
+
|
|
37
|
+
#### Honeypot Detection (Stage 3.5)
|
|
38
|
+
- **Automatic Buy/Sell Testing**: Simulates token purchase then sale
|
|
39
|
+
- **Zero Manual Blacklisting**: Detects unknown honeypots via simulation
|
|
40
|
+
- **Transfer Event Validation**: Verifies actual token movement
|
|
41
|
+
- **Balance Verification**: Ensures balance changes match expectations
|
|
42
|
+
- **Known Token Whitelist**: Skips checks for WETH, USDC, DAI, etc.
|
|
43
|
+
|
|
44
|
+
#### LLM-based Security Analysis (Stage 4)
|
|
45
|
+
- **AI-Powered Threat Detection**: GPT-4/Claude analysis of transactions
|
|
46
|
+
- **Pattern Recognition**: Detects hidden approvals, unusual fund flows, reentrancy
|
|
47
|
+
- **Risk Scoring**: Confidence levels and risk ratings (LOW/MEDIUM/HIGH/CRITICAL)
|
|
48
|
+
- **Configurable Thresholds**: Block at 70%, warn at 40% (customizable)
|
|
49
|
+
- **Multiple Providers**: Support for OpenAI and Anthropic
|
|
50
|
+
|
|
51
|
+
#### Logging & Observability
|
|
52
|
+
- **Three Logging Levels**: minimal, info, debug
|
|
53
|
+
- **Structured Output**: Clear stage-by-stage validation results
|
|
54
|
+
- **Asset Change Reporting**: Show balance changes inline
|
|
55
|
+
- **Error Context**: Detailed failure reasons and recommendations
|
|
56
|
+
|
|
57
|
+
#### Examples & Documentation
|
|
58
|
+
- **Basic Usage Example**: Mock wallet demonstration
|
|
59
|
+
- **OnChain Agent**: Production-ready AgentKit chatbot
|
|
60
|
+
- **Autonomous Portfolio Agent**: AI portfolio manager with honeypot protection
|
|
61
|
+
- **Comprehensive README**: Complete setup and configuration guide
|
|
62
|
+
- **Policy Templates**: Ready-to-use YAML configurations
|
|
63
|
+
|
|
64
|
+
### 🛠️ Technical Implementation
|
|
65
|
+
|
|
66
|
+
#### Architecture
|
|
67
|
+
- **PolicyEngine**: Core validation orchestrator
|
|
68
|
+
- **PolicyWalletProvider**: Transparent wallet wrapper
|
|
69
|
+
- **CalldataParser**: ABI decoding for ERC20 and custom functions
|
|
70
|
+
- **TenderlySimulator**: Advanced simulation client
|
|
71
|
+
- **LLMJudge**: AI security analysis engine
|
|
72
|
+
- **Rule Validators**: Modular policy enforcement
|
|
73
|
+
|
|
74
|
+
#### Compatibility
|
|
75
|
+
- ✅ CDP EVM Wallet Provider
|
|
76
|
+
- ✅ CDP Smart Wallet Provider
|
|
77
|
+
- ✅ Ethereum Account Wallet Provider
|
|
78
|
+
- ✅ Base, Base Sepolia, Ethereum Mainnet, Arbitrum, Optimism
|
|
79
|
+
|
|
80
|
+
### 📦 Dependencies
|
|
81
|
+
|
|
82
|
+
#### Required
|
|
83
|
+
- Python 3.10+
|
|
84
|
+
- web3.py
|
|
85
|
+
- pyyaml
|
|
86
|
+
- cdp-sdk (for CDP wallet integration)
|
|
87
|
+
|
|
88
|
+
#### Optional
|
|
89
|
+
- requests (for Tenderly simulation)
|
|
90
|
+
- openai / anthropic (for LLM validation)
|
|
91
|
+
|
|
92
|
+
### 🔧 Configuration
|
|
93
|
+
|
|
94
|
+
Default `policy.yaml` includes:
|
|
95
|
+
- ETH limit: 1 ETH per transaction
|
|
96
|
+
- Per-asset limits for USDC (10) and DAI (100)
|
|
97
|
+
- Gas limit: 500k
|
|
98
|
+
- Simulation enabled
|
|
99
|
+
- LLM validation disabled by default
|
|
100
|
+
|
|
101
|
+
### 🐛 Known Issues
|
|
102
|
+
|
|
103
|
+
- None reported in initial release
|
|
104
|
+
|
|
105
|
+
### 📝 Breaking Changes
|
|
106
|
+
|
|
107
|
+
- N/A (initial release)
|
|
108
|
+
|
|
109
|
+
### 🔒 Security
|
|
110
|
+
|
|
111
|
+
- All transactions validated before execution
|
|
112
|
+
- No credentials stored in logs
|
|
113
|
+
- Simulation uses read-only `eth_call`
|
|
114
|
+
- Tenderly API keys required for advanced features
|
|
115
|
+
|
|
116
|
+
### 📚 Documentation
|
|
117
|
+
|
|
118
|
+
- Comprehensive README with examples
|
|
119
|
+
- Inline code documentation
|
|
120
|
+
- Example projects with setup guides
|
|
121
|
+
- Policy configuration templates
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Contributing to AgentARC
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to AgentARC! This document provides guidelines for contributing to the project.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- Python 3.10 or higher
|
|
10
|
+
- pip or poetry
|
|
11
|
+
|
|
12
|
+
### Installation for Development
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Clone the repository
|
|
16
|
+
git clone https://github.com/yourusername/agentarc.git
|
|
17
|
+
cd agentarc
|
|
18
|
+
|
|
19
|
+
# Install in editable mode with development dependencies
|
|
20
|
+
pip install -e ".[dev]"
|
|
21
|
+
|
|
22
|
+
# Or with poetry
|
|
23
|
+
poetry install --with dev
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Project Structure
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
agentarc/
|
|
30
|
+
├── agentarc/ # Main package source code
|
|
31
|
+
│ ├── __init__.py # Package exports
|
|
32
|
+
│ ├── __main__.py # CLI entry point
|
|
33
|
+
│ ├── policy_engine.py # Core validation engine
|
|
34
|
+
│ ├── wallet_wrapper.py # Wallet provider wrapper
|
|
35
|
+
│ ├── calldata_parser.py # Transaction parsing
|
|
36
|
+
│ ├── simulator.py # Transaction simulation
|
|
37
|
+
│ ├── logger.py # Logging system
|
|
38
|
+
│ └── rules/ # Policy validators
|
|
39
|
+
│ ├── __init__.py
|
|
40
|
+
│ └── validators.py # All policy validators
|
|
41
|
+
├── tests/ # Test suite
|
|
42
|
+
├── examples/ # Usage examples
|
|
43
|
+
├── docs/ # Documentation
|
|
44
|
+
└── pyproject.toml # Package configuration
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Testing
|
|
48
|
+
|
|
49
|
+
### Running Tests
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Run all tests
|
|
53
|
+
cd tests
|
|
54
|
+
python test_complete_system.py
|
|
55
|
+
|
|
56
|
+
# Run specific test
|
|
57
|
+
python test_fix.py
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Writing Tests
|
|
61
|
+
|
|
62
|
+
When adding new features, please include tests:
|
|
63
|
+
|
|
64
|
+
1. Create test file in `tests/`
|
|
65
|
+
2. Test all success and failure cases
|
|
66
|
+
3. Verify logging output
|
|
67
|
+
4. Check edge cases
|
|
68
|
+
|
|
69
|
+
## Code Style
|
|
70
|
+
|
|
71
|
+
- Follow PEP 8 style guidelines
|
|
72
|
+
- Use type hints where applicable
|
|
73
|
+
- Write docstrings for all public functions and classes
|
|
74
|
+
- Keep functions focused and single-purpose
|
|
75
|
+
|
|
76
|
+
### Example
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
def validate_transaction(self, tx: Dict[str, Any], from_address: str) -> tuple[bool, str]:
|
|
80
|
+
"""
|
|
81
|
+
Validate transaction against all configured policies.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
tx: Transaction dictionary with to, value, data, etc.
|
|
85
|
+
from_address: Sender address for simulation
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
Tuple of (passed: bool, reason: str)
|
|
89
|
+
"""
|
|
90
|
+
# Implementation
|
|
91
|
+
pass
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Adding New Policy Types
|
|
95
|
+
|
|
96
|
+
To add a new policy validator:
|
|
97
|
+
|
|
98
|
+
1. Create validator class in `agentarc/rules/validators.py`
|
|
99
|
+
2. Inherit from `PolicyValidator` base class
|
|
100
|
+
3. Implement `validate()` method
|
|
101
|
+
4. Register in `PolicyEngine._create_validators()`
|
|
102
|
+
5. Add configuration example to default policy.yaml
|
|
103
|
+
6. Write tests
|
|
104
|
+
7. Update documentation
|
|
105
|
+
|
|
106
|
+
### Example
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
class MyCustomValidator(PolicyValidator):
|
|
110
|
+
"""Description of what this validator does"""
|
|
111
|
+
|
|
112
|
+
def validate(self, parsed_tx: ParsedTransaction) -> ValidationResult:
|
|
113
|
+
if not self.enabled:
|
|
114
|
+
return ValidationResult(passed=True)
|
|
115
|
+
|
|
116
|
+
# Your validation logic here
|
|
117
|
+
if some_condition:
|
|
118
|
+
return ValidationResult(
|
|
119
|
+
passed=False,
|
|
120
|
+
reason="Description of why it failed",
|
|
121
|
+
rule_name="my_custom_rule"
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
return ValidationResult(passed=True)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Submitting Changes
|
|
128
|
+
|
|
129
|
+
### Pull Request Process
|
|
130
|
+
|
|
131
|
+
1. Fork the repository
|
|
132
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
133
|
+
3. Make your changes
|
|
134
|
+
4. Add tests for new functionality
|
|
135
|
+
5. Update documentation
|
|
136
|
+
6. Run tests to ensure they pass
|
|
137
|
+
7. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
138
|
+
8. Push to the branch (`git push origin feature/amazing-feature`)
|
|
139
|
+
9. Open a Pull Request
|
|
140
|
+
|
|
141
|
+
### Pull Request Guidelines
|
|
142
|
+
|
|
143
|
+
- Provide a clear description of the changes
|
|
144
|
+
- Reference any related issues
|
|
145
|
+
- Include test coverage for new features
|
|
146
|
+
- Update CHANGELOG.md
|
|
147
|
+
- Ensure all tests pass
|
|
148
|
+
- Follow existing code style
|
|
149
|
+
|
|
150
|
+
## Documentation
|
|
151
|
+
|
|
152
|
+
When adding new features:
|
|
153
|
+
|
|
154
|
+
1. Update README.md if needed
|
|
155
|
+
2. Add examples to `examples/`
|
|
156
|
+
3. Update CHANGELOG.md
|
|
157
|
+
4. Add inline code documentation
|
|
158
|
+
5. Update configuration examples
|
|
159
|
+
|
|
160
|
+
## Reporting Issues
|
|
161
|
+
|
|
162
|
+
### Bug Reports
|
|
163
|
+
|
|
164
|
+
Include:
|
|
165
|
+
- Clear description of the issue
|
|
166
|
+
- Steps to reproduce
|
|
167
|
+
- Expected behavior
|
|
168
|
+
- Actual behavior
|
|
169
|
+
- AgentARC version
|
|
170
|
+
- Python version
|
|
171
|
+
- Error messages/logs
|
|
172
|
+
|
|
173
|
+
### Feature Requests
|
|
174
|
+
|
|
175
|
+
Include:
|
|
176
|
+
- Clear description of the feature
|
|
177
|
+
- Use case / motivation
|
|
178
|
+
- Proposed implementation (if any)
|
|
179
|
+
- Examples
|
|
180
|
+
|
|
181
|
+
## Code of Conduct
|
|
182
|
+
|
|
183
|
+
### Our Standards
|
|
184
|
+
|
|
185
|
+
- Be respectful and inclusive
|
|
186
|
+
- Focus on constructive feedback
|
|
187
|
+
- Accept differing viewpoints
|
|
188
|
+
- Prioritize community benefit
|
|
189
|
+
|
|
190
|
+
### Unacceptable Behavior
|
|
191
|
+
|
|
192
|
+
- Harassment or discriminatory language
|
|
193
|
+
- Personal attacks
|
|
194
|
+
- Trolling or insulting comments
|
|
195
|
+
- Publishing private information
|
|
196
|
+
|
|
197
|
+
## Questions?
|
|
198
|
+
|
|
199
|
+
- Open an issue for questions
|
|
200
|
+
- Check existing documentation
|
|
201
|
+
- Review examples in `examples/`
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
Thank you for contributing to AgentARC! 🎉
|
agentarc-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Galaar Authors
|
|
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.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
Portions of this software were originally released under the MIT License, Copyright (c) 2025 BuildBear Labs.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Include documentation
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
include CHANGELOG.md
|
|
5
|
+
include CONTRIBUTING.md
|
|
6
|
+
|
|
7
|
+
# Include package data
|
|
8
|
+
recursive-include agentarc *.py
|
|
9
|
+
|
|
10
|
+
# Exclude compiled files
|
|
11
|
+
global-exclude *.pyc
|
|
12
|
+
global-exclude __pycache__
|
|
13
|
+
global-exclude *.so
|
|
14
|
+
global-exclude .DS_Store
|