ardenpy 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.
- ardenpy-0.1.0/LICENSE +21 -0
- ardenpy-0.1.0/MANIFEST.in +11 -0
- ardenpy-0.1.0/PKG-INFO +251 -0
- ardenpy-0.1.0/README.md +218 -0
- ardenpy-0.1.0/ardenpy/__init__.py +52 -0
- ardenpy-0.1.0/ardenpy/client.py +256 -0
- ardenpy-0.1.0/ardenpy/config.py +175 -0
- ardenpy-0.1.0/ardenpy/guard.py +341 -0
- ardenpy-0.1.0/ardenpy/types.py +75 -0
- ardenpy-0.1.0/ardenpy.egg-info/PKG-INFO +251 -0
- ardenpy-0.1.0/ardenpy.egg-info/SOURCES.txt +25 -0
- ardenpy-0.1.0/ardenpy.egg-info/dependency_links.txt +1 -0
- ardenpy-0.1.0/ardenpy.egg-info/requires.txt +5 -0
- ardenpy-0.1.0/ardenpy.egg-info/top_level.txt +1 -0
- ardenpy-0.1.0/examples/README.md +113 -0
- ardenpy-0.1.0/examples/approval_workflows_demo.py +280 -0
- ardenpy-0.1.0/examples/autogpt_integration.py +399 -0
- ardenpy-0.1.0/examples/crewai_integration.py +332 -0
- ardenpy-0.1.0/examples/custom_agent.py +438 -0
- ardenpy-0.1.0/examples/direct_openai_integration.py +405 -0
- ardenpy-0.1.0/examples/getting_started.py +113 -0
- ardenpy-0.1.0/examples/langchain_integration.py +294 -0
- ardenpy-0.1.0/examples/simple_agent.py +111 -0
- ardenpy-0.1.0/examples/webhook_server.py +370 -0
- ardenpy-0.1.0/policies.yaml.example +100 -0
- ardenpy-0.1.0/pyproject.toml +60 -0
- ardenpy-0.1.0/setup.cfg +4 -0
ardenpy-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Arden
|
|
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,11 @@
|
|
|
1
|
+
include README.md LICENSE
|
|
2
|
+
include policies.yaml.example
|
|
3
|
+
include ardenpy/py.typed
|
|
4
|
+
recursive-include ardenpy *.py
|
|
5
|
+
recursive-include examples *.py *.md
|
|
6
|
+
global-exclude *.pyc
|
|
7
|
+
global-exclude __pycache__
|
|
8
|
+
global-exclude .DS_Store
|
|
9
|
+
global-exclude *.pyo
|
|
10
|
+
global-exclude .git*
|
|
11
|
+
prune .git
|
ardenpy-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ardenpy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI Agent Warden - Keep your AI agents in check with policy enforcement and human oversight
|
|
5
|
+
Author-email: Arden Team <team@arden.dev>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://arden.sh
|
|
8
|
+
Project-URL: Documentation, https://arden.sh/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/arden/ardenpy
|
|
10
|
+
Project-URL: Issues, https://github.com/arden/ardenpy/issues
|
|
11
|
+
Keywords: ai,agent,security,policy,approval,llm,safety
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: Security
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: httpx>=0.24.0
|
|
28
|
+
Requires-Dist: pydantic>=2.0.0
|
|
29
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
30
|
+
Requires-Dist: packaging>=21.0
|
|
31
|
+
Requires-Dist: requests>=2.25.0
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# Arden Python SDK
|
|
35
|
+
|
|
36
|
+
**AI Agent Warden - Keep Your AI Agents in Check**
|
|
37
|
+
|
|
38
|
+
Arden is the warden for your AI agents. Enforce policies, require human approval for sensitive actions, and maintain control over what your agents can actually do - no matter which framework you use.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install ardenpy
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
### 1. Get API Key
|
|
49
|
+
Visit [https://arden.sh](https://arden.sh) to get your free test API key.
|
|
50
|
+
|
|
51
|
+
Your test API key will start with `test_` and automatically connect to the test environment at `https://api-test.arden.sh`.
|
|
52
|
+
|
|
53
|
+
### 2. Protect Your Functions
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from ardenpy import guard_tool, configure
|
|
57
|
+
|
|
58
|
+
# Configure once
|
|
59
|
+
configure(api_key="test_12345_your_api_key_here")
|
|
60
|
+
|
|
61
|
+
# Protect different types of functions
|
|
62
|
+
def read_file(filename: str):
|
|
63
|
+
# Low-risk operation - typically ALLOWED
|
|
64
|
+
return f"Reading {filename}"
|
|
65
|
+
|
|
66
|
+
def send_email(to: str, subject: str, message: str):
|
|
67
|
+
# Medium-risk operation - typically REQUIRES APPROVAL
|
|
68
|
+
return f"Email sent to {to}: {subject}"
|
|
69
|
+
|
|
70
|
+
def delete_database(table: str):
|
|
71
|
+
# High-risk operation - typically BLOCKED
|
|
72
|
+
return f"Deleted table {table}"
|
|
73
|
+
|
|
74
|
+
# Apply protection with descriptive tool names
|
|
75
|
+
safe_read = guard_tool("file.read", read_file)
|
|
76
|
+
safe_email = guard_tool("communication.email", send_email)
|
|
77
|
+
safe_delete = guard_tool("database.delete", delete_database)
|
|
78
|
+
|
|
79
|
+
# Use normally - Arden enforces your policies
|
|
80
|
+
result1 = safe_read("report.txt") # ✅ Executes immediately (allowed)
|
|
81
|
+
result2 = safe_email("user@co.com", "Hi", "Hello") # ⏳ Waits for approval
|
|
82
|
+
result3 = safe_delete("users") # ❌ Throws error (blocked)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## How Arden Works
|
|
86
|
+
|
|
87
|
+
**Step 1: Protect your functions with descriptive names**
|
|
88
|
+
```python
|
|
89
|
+
def read_config(filename: str):
|
|
90
|
+
return f"Config from {filename}"
|
|
91
|
+
|
|
92
|
+
def send_email(to: str, message: str):
|
|
93
|
+
return f"Email sent to {to}: {message}"
|
|
94
|
+
|
|
95
|
+
def delete_files(pattern: str):
|
|
96
|
+
return f"Deleted files matching {pattern}"
|
|
97
|
+
|
|
98
|
+
# Use descriptive tool names that match your policies
|
|
99
|
+
safe_read = guard_tool("config.read", read_config) # Low risk
|
|
100
|
+
safe_email = guard_tool("communication.email", send_email) # Medium risk
|
|
101
|
+
safe_delete = guard_tool("file.delete", delete_files) # High risk
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Step 2: Use in any framework**
|
|
105
|
+
```python
|
|
106
|
+
# Policy enforcement happens automatically:
|
|
107
|
+
config = safe_read("app.json") # ✅ Allowed - executes immediately
|
|
108
|
+
safe_email("user@co.com", "Hello") # ⏳ Requires approval - waits for human
|
|
109
|
+
safe_delete("*.tmp") # ❌ Blocked - throws PolicyError
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Step 3: Configure policies by risk level**
|
|
113
|
+
Set policies at [https://arden.sh/dashboard](https://arden.sh/dashboard) based on risk:
|
|
114
|
+
|
|
115
|
+
**Low Risk (Allow)**: `config.read`, `data.read`, `file.read`
|
|
116
|
+
**Medium Risk (Requires Approval)**: `communication.*`, `api.post`, `file.write`
|
|
117
|
+
**High Risk (Block)**: `file.delete`, `database.drop`, `system.exec`
|
|
118
|
+
|
|
119
|
+
**Step 4: Choose approval workflow**
|
|
120
|
+
You can choose how approvals work (all examples work with any framework):
|
|
121
|
+
|
|
122
|
+
### Default: Wait for Approval
|
|
123
|
+
```python
|
|
124
|
+
safe_email = guard_tool("communication.email", send_email)
|
|
125
|
+
result = safe_email("user@example.com", "Hello") # Pauses until approved
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Advanced: Async Callbacks
|
|
129
|
+
```python
|
|
130
|
+
# For sensitive operations that need approval but shouldn't block
|
|
131
|
+
safe_deploy = guard_tool(
|
|
132
|
+
"deployment.production", deploy_to_prod,
|
|
133
|
+
approval_mode="async",
|
|
134
|
+
on_approval=lambda result: notify_team(f"Deployment successful: {result}"),
|
|
135
|
+
on_denial=lambda error: alert_team(f"Deployment blocked: {error}")
|
|
136
|
+
)
|
|
137
|
+
safe_deploy("v2.1.0") # Returns immediately, callbacks handle result
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Production: Webhooks
|
|
141
|
+
```python
|
|
142
|
+
# For high-volume operations with external approval systems
|
|
143
|
+
safe_payment = guard_tool(
|
|
144
|
+
"payment.process", process_payment,
|
|
145
|
+
approval_mode="webhook",
|
|
146
|
+
webhook_url="https://approval-system.company.com/webhook"
|
|
147
|
+
)
|
|
148
|
+
safe_payment(amount=1000, customer="cust_123") # Webhook notifies approval system
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Framework Integration
|
|
152
|
+
|
|
153
|
+
The same protected functions work with any agent framework:
|
|
154
|
+
|
|
155
|
+
### LangChain
|
|
156
|
+
```python
|
|
157
|
+
from langchain.tools import Tool
|
|
158
|
+
from ardenpy import guard_tool
|
|
159
|
+
|
|
160
|
+
# Protect different risk levels
|
|
161
|
+
def web_search(query: str):
|
|
162
|
+
return f"Search results for: {query}"
|
|
163
|
+
|
|
164
|
+
def send_slack_message(channel: str, message: str):
|
|
165
|
+
return f"Posted to #{channel}: {message}"
|
|
166
|
+
|
|
167
|
+
def execute_sql(query: str):
|
|
168
|
+
return f"Executed: {query}"
|
|
169
|
+
|
|
170
|
+
# Apply appropriate protection levels
|
|
171
|
+
safe_search = guard_tool("web.search", web_search) # Low risk - allow
|
|
172
|
+
safe_slack = guard_tool("communication.slack", send_slack_message) # Medium risk - approval
|
|
173
|
+
safe_sql = guard_tool("database.execute", execute_sql) # High risk - block
|
|
174
|
+
|
|
175
|
+
tools = [
|
|
176
|
+
Tool(name="search", func=safe_search, description="Search the web"),
|
|
177
|
+
Tool(name="slack", func=safe_slack, description="Send Slack messages"),
|
|
178
|
+
Tool(name="sql", func=safe_sql, description="Execute SQL queries")
|
|
179
|
+
]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### CrewAI
|
|
183
|
+
```python
|
|
184
|
+
from crewai import Tool
|
|
185
|
+
from ardenpy import guard_tool
|
|
186
|
+
|
|
187
|
+
# Realistic agent tools with different risk profiles
|
|
188
|
+
@tool("research_tool")
|
|
189
|
+
def research_web(topic: str):
|
|
190
|
+
protected_search = guard_tool("research.web", lambda q: f"Research on {q}")
|
|
191
|
+
return protected_search(topic) # Allowed - research is low risk
|
|
192
|
+
|
|
193
|
+
@tool("communication_tool")
|
|
194
|
+
def send_email(recipient: str, content: str):
|
|
195
|
+
protected_email = guard_tool("communication.email", lambda r, c: f"Email to {r}")
|
|
196
|
+
return protected_email(recipient, content) # Requires approval - external communication
|
|
197
|
+
|
|
198
|
+
@tool("system_tool")
|
|
199
|
+
def deploy_code(environment: str):
|
|
200
|
+
protected_deploy = guard_tool("deployment.production", lambda e: f"Deploy to {e}")
|
|
201
|
+
return protected_deploy(environment) # Blocked or requires approval - high risk
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Custom Agents
|
|
205
|
+
```python
|
|
206
|
+
class SecurityAwareAgent:
|
|
207
|
+
def __init__(self):
|
|
208
|
+
# Different protection levels for different capabilities
|
|
209
|
+
self.read_data = guard_tool("data.read", self._read_data) # Allow
|
|
210
|
+
self.send_email = guard_tool("communication.email", self._send_email) # Approval
|
|
211
|
+
self.delete_files = guard_tool("file.delete", self._delete_files) # Block
|
|
212
|
+
|
|
213
|
+
def _read_data(self, source: str):
|
|
214
|
+
return f"Reading data from {source}"
|
|
215
|
+
|
|
216
|
+
def _send_email(self, to: str, message: str):
|
|
217
|
+
return f"Email sent to {to}: {message}"
|
|
218
|
+
|
|
219
|
+
def _delete_files(self, pattern: str):
|
|
220
|
+
return f"Deleted files matching {pattern}"
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Examples
|
|
224
|
+
|
|
225
|
+
See the `examples/` directory for complete working examples:
|
|
226
|
+
|
|
227
|
+
- **getting_started.py** - Simple 3-step introduction
|
|
228
|
+
- **langchain_integration.py** - LangChain + Arden
|
|
229
|
+
- **crewai_integration.py** - CrewAI + Arden
|
|
230
|
+
- **autogpt_integration.py** - AutoGPT + Arden
|
|
231
|
+
- **direct_openai_integration.py** - Direct OpenAI (no frameworks)
|
|
232
|
+
|
|
233
|
+
## Publishing
|
|
234
|
+
|
|
235
|
+
Use the included publishing script:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
python publish.py
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Links
|
|
242
|
+
|
|
243
|
+
- **Website**: [https://arden.sh](https://arden.sh)
|
|
244
|
+
- **Dashboard**: [https://arden.sh/dashboard](https://arden.sh/dashboard)
|
|
245
|
+
- **Documentation**: [https://arden.sh/docs](https://arden.sh/docs)
|
|
246
|
+
- **Support**: [team@arden.sh](mailto:team@arden.sh)
|
|
247
|
+
- **PyPI Package**: [https://pypi.org/project/ardenpy/](https://pypi.org/project/ardenpy/)
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
MIT License - see LICENSE file for details.
|
ardenpy-0.1.0/README.md
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Arden Python SDK
|
|
2
|
+
|
|
3
|
+
**AI Agent Warden - Keep Your AI Agents in Check**
|
|
4
|
+
|
|
5
|
+
Arden is the warden for your AI agents. Enforce policies, require human approval for sensitive actions, and maintain control over what your agents can actually do - no matter which framework you use.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install ardenpy
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### 1. Get API Key
|
|
16
|
+
Visit [https://arden.sh](https://arden.sh) to get your free test API key.
|
|
17
|
+
|
|
18
|
+
Your test API key will start with `test_` and automatically connect to the test environment at `https://api-test.arden.sh`.
|
|
19
|
+
|
|
20
|
+
### 2. Protect Your Functions
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from ardenpy import guard_tool, configure
|
|
24
|
+
|
|
25
|
+
# Configure once
|
|
26
|
+
configure(api_key="test_12345_your_api_key_here")
|
|
27
|
+
|
|
28
|
+
# Protect different types of functions
|
|
29
|
+
def read_file(filename: str):
|
|
30
|
+
# Low-risk operation - typically ALLOWED
|
|
31
|
+
return f"Reading {filename}"
|
|
32
|
+
|
|
33
|
+
def send_email(to: str, subject: str, message: str):
|
|
34
|
+
# Medium-risk operation - typically REQUIRES APPROVAL
|
|
35
|
+
return f"Email sent to {to}: {subject}"
|
|
36
|
+
|
|
37
|
+
def delete_database(table: str):
|
|
38
|
+
# High-risk operation - typically BLOCKED
|
|
39
|
+
return f"Deleted table {table}"
|
|
40
|
+
|
|
41
|
+
# Apply protection with descriptive tool names
|
|
42
|
+
safe_read = guard_tool("file.read", read_file)
|
|
43
|
+
safe_email = guard_tool("communication.email", send_email)
|
|
44
|
+
safe_delete = guard_tool("database.delete", delete_database)
|
|
45
|
+
|
|
46
|
+
# Use normally - Arden enforces your policies
|
|
47
|
+
result1 = safe_read("report.txt") # ✅ Executes immediately (allowed)
|
|
48
|
+
result2 = safe_email("user@co.com", "Hi", "Hello") # ⏳ Waits for approval
|
|
49
|
+
result3 = safe_delete("users") # ❌ Throws error (blocked)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## How Arden Works
|
|
53
|
+
|
|
54
|
+
**Step 1: Protect your functions with descriptive names**
|
|
55
|
+
```python
|
|
56
|
+
def read_config(filename: str):
|
|
57
|
+
return f"Config from {filename}"
|
|
58
|
+
|
|
59
|
+
def send_email(to: str, message: str):
|
|
60
|
+
return f"Email sent to {to}: {message}"
|
|
61
|
+
|
|
62
|
+
def delete_files(pattern: str):
|
|
63
|
+
return f"Deleted files matching {pattern}"
|
|
64
|
+
|
|
65
|
+
# Use descriptive tool names that match your policies
|
|
66
|
+
safe_read = guard_tool("config.read", read_config) # Low risk
|
|
67
|
+
safe_email = guard_tool("communication.email", send_email) # Medium risk
|
|
68
|
+
safe_delete = guard_tool("file.delete", delete_files) # High risk
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Step 2: Use in any framework**
|
|
72
|
+
```python
|
|
73
|
+
# Policy enforcement happens automatically:
|
|
74
|
+
config = safe_read("app.json") # ✅ Allowed - executes immediately
|
|
75
|
+
safe_email("user@co.com", "Hello") # ⏳ Requires approval - waits for human
|
|
76
|
+
safe_delete("*.tmp") # ❌ Blocked - throws PolicyError
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Step 3: Configure policies by risk level**
|
|
80
|
+
Set policies at [https://arden.sh/dashboard](https://arden.sh/dashboard) based on risk:
|
|
81
|
+
|
|
82
|
+
**Low Risk (Allow)**: `config.read`, `data.read`, `file.read`
|
|
83
|
+
**Medium Risk (Requires Approval)**: `communication.*`, `api.post`, `file.write`
|
|
84
|
+
**High Risk (Block)**: `file.delete`, `database.drop`, `system.exec`
|
|
85
|
+
|
|
86
|
+
**Step 4: Choose approval workflow**
|
|
87
|
+
You can choose how approvals work (all examples work with any framework):
|
|
88
|
+
|
|
89
|
+
### Default: Wait for Approval
|
|
90
|
+
```python
|
|
91
|
+
safe_email = guard_tool("communication.email", send_email)
|
|
92
|
+
result = safe_email("user@example.com", "Hello") # Pauses until approved
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Advanced: Async Callbacks
|
|
96
|
+
```python
|
|
97
|
+
# For sensitive operations that need approval but shouldn't block
|
|
98
|
+
safe_deploy = guard_tool(
|
|
99
|
+
"deployment.production", deploy_to_prod,
|
|
100
|
+
approval_mode="async",
|
|
101
|
+
on_approval=lambda result: notify_team(f"Deployment successful: {result}"),
|
|
102
|
+
on_denial=lambda error: alert_team(f"Deployment blocked: {error}")
|
|
103
|
+
)
|
|
104
|
+
safe_deploy("v2.1.0") # Returns immediately, callbacks handle result
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Production: Webhooks
|
|
108
|
+
```python
|
|
109
|
+
# For high-volume operations with external approval systems
|
|
110
|
+
safe_payment = guard_tool(
|
|
111
|
+
"payment.process", process_payment,
|
|
112
|
+
approval_mode="webhook",
|
|
113
|
+
webhook_url="https://approval-system.company.com/webhook"
|
|
114
|
+
)
|
|
115
|
+
safe_payment(amount=1000, customer="cust_123") # Webhook notifies approval system
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Framework Integration
|
|
119
|
+
|
|
120
|
+
The same protected functions work with any agent framework:
|
|
121
|
+
|
|
122
|
+
### LangChain
|
|
123
|
+
```python
|
|
124
|
+
from langchain.tools import Tool
|
|
125
|
+
from ardenpy import guard_tool
|
|
126
|
+
|
|
127
|
+
# Protect different risk levels
|
|
128
|
+
def web_search(query: str):
|
|
129
|
+
return f"Search results for: {query}"
|
|
130
|
+
|
|
131
|
+
def send_slack_message(channel: str, message: str):
|
|
132
|
+
return f"Posted to #{channel}: {message}"
|
|
133
|
+
|
|
134
|
+
def execute_sql(query: str):
|
|
135
|
+
return f"Executed: {query}"
|
|
136
|
+
|
|
137
|
+
# Apply appropriate protection levels
|
|
138
|
+
safe_search = guard_tool("web.search", web_search) # Low risk - allow
|
|
139
|
+
safe_slack = guard_tool("communication.slack", send_slack_message) # Medium risk - approval
|
|
140
|
+
safe_sql = guard_tool("database.execute", execute_sql) # High risk - block
|
|
141
|
+
|
|
142
|
+
tools = [
|
|
143
|
+
Tool(name="search", func=safe_search, description="Search the web"),
|
|
144
|
+
Tool(name="slack", func=safe_slack, description="Send Slack messages"),
|
|
145
|
+
Tool(name="sql", func=safe_sql, description="Execute SQL queries")
|
|
146
|
+
]
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### CrewAI
|
|
150
|
+
```python
|
|
151
|
+
from crewai import Tool
|
|
152
|
+
from ardenpy import guard_tool
|
|
153
|
+
|
|
154
|
+
# Realistic agent tools with different risk profiles
|
|
155
|
+
@tool("research_tool")
|
|
156
|
+
def research_web(topic: str):
|
|
157
|
+
protected_search = guard_tool("research.web", lambda q: f"Research on {q}")
|
|
158
|
+
return protected_search(topic) # Allowed - research is low risk
|
|
159
|
+
|
|
160
|
+
@tool("communication_tool")
|
|
161
|
+
def send_email(recipient: str, content: str):
|
|
162
|
+
protected_email = guard_tool("communication.email", lambda r, c: f"Email to {r}")
|
|
163
|
+
return protected_email(recipient, content) # Requires approval - external communication
|
|
164
|
+
|
|
165
|
+
@tool("system_tool")
|
|
166
|
+
def deploy_code(environment: str):
|
|
167
|
+
protected_deploy = guard_tool("deployment.production", lambda e: f"Deploy to {e}")
|
|
168
|
+
return protected_deploy(environment) # Blocked or requires approval - high risk
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Custom Agents
|
|
172
|
+
```python
|
|
173
|
+
class SecurityAwareAgent:
|
|
174
|
+
def __init__(self):
|
|
175
|
+
# Different protection levels for different capabilities
|
|
176
|
+
self.read_data = guard_tool("data.read", self._read_data) # Allow
|
|
177
|
+
self.send_email = guard_tool("communication.email", self._send_email) # Approval
|
|
178
|
+
self.delete_files = guard_tool("file.delete", self._delete_files) # Block
|
|
179
|
+
|
|
180
|
+
def _read_data(self, source: str):
|
|
181
|
+
return f"Reading data from {source}"
|
|
182
|
+
|
|
183
|
+
def _send_email(self, to: str, message: str):
|
|
184
|
+
return f"Email sent to {to}: {message}"
|
|
185
|
+
|
|
186
|
+
def _delete_files(self, pattern: str):
|
|
187
|
+
return f"Deleted files matching {pattern}"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Examples
|
|
191
|
+
|
|
192
|
+
See the `examples/` directory for complete working examples:
|
|
193
|
+
|
|
194
|
+
- **getting_started.py** - Simple 3-step introduction
|
|
195
|
+
- **langchain_integration.py** - LangChain + Arden
|
|
196
|
+
- **crewai_integration.py** - CrewAI + Arden
|
|
197
|
+
- **autogpt_integration.py** - AutoGPT + Arden
|
|
198
|
+
- **direct_openai_integration.py** - Direct OpenAI (no frameworks)
|
|
199
|
+
|
|
200
|
+
## Publishing
|
|
201
|
+
|
|
202
|
+
Use the included publishing script:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
python publish.py
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Links
|
|
209
|
+
|
|
210
|
+
- **Website**: [https://arden.sh](https://arden.sh)
|
|
211
|
+
- **Dashboard**: [https://arden.sh/dashboard](https://arden.sh/dashboard)
|
|
212
|
+
- **Documentation**: [https://arden.sh/docs](https://arden.sh/docs)
|
|
213
|
+
- **Support**: [team@arden.sh](mailto:team@arden.sh)
|
|
214
|
+
- **PyPI Package**: [https://pypi.org/project/ardenpy/](https://pypi.org/project/ardenpy/)
|
|
215
|
+
|
|
216
|
+
## License
|
|
217
|
+
|
|
218
|
+
MIT License - see LICENSE file for details.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Arden - AI Agent Tool Call Gate
|
|
3
|
+
|
|
4
|
+
A Python SDK for protecting AI agent tool calls with policy enforcement
|
|
5
|
+
and human approval workflows.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .guard import guard_tool, with_guard, GuardContext
|
|
9
|
+
from .config import configure, get_config, is_configured, configure_test, configure_live, ArdenConfig
|
|
10
|
+
from .client import ArdenClient
|
|
11
|
+
from .types import (
|
|
12
|
+
ActionStatus,
|
|
13
|
+
PolicyDecision,
|
|
14
|
+
ArdenError,
|
|
15
|
+
PolicyDeniedError,
|
|
16
|
+
ApprovalTimeoutError,
|
|
17
|
+
ConfigurationError,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__version__ = "0.1.0"
|
|
21
|
+
__author__ = "Arden Team"
|
|
22
|
+
__email__ = "team@arden.dev"
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
# Main API
|
|
26
|
+
"guard_tool",
|
|
27
|
+
"configure",
|
|
28
|
+
"configure_test",
|
|
29
|
+
"configure_live",
|
|
30
|
+
"get_config",
|
|
31
|
+
"is_configured",
|
|
32
|
+
|
|
33
|
+
# Context management
|
|
34
|
+
"with_guard",
|
|
35
|
+
"GuardContext",
|
|
36
|
+
|
|
37
|
+
# Client
|
|
38
|
+
"ArdenClient",
|
|
39
|
+
|
|
40
|
+
# Configuration
|
|
41
|
+
"ArdenConfig",
|
|
42
|
+
|
|
43
|
+
# Types and enums
|
|
44
|
+
"ActionStatus",
|
|
45
|
+
"PolicyDecision",
|
|
46
|
+
|
|
47
|
+
# Exceptions
|
|
48
|
+
"ArdenError",
|
|
49
|
+
"PolicyDeniedError",
|
|
50
|
+
"ApprovalTimeoutError",
|
|
51
|
+
"ConfigurationError",
|
|
52
|
+
]
|