warderbox 0.3.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.
Files changed (57) hide show
  1. warderbox-0.3.0/.gitignore +21 -0
  2. warderbox-0.3.0/CHANGELOG.md +75 -0
  3. warderbox-0.3.0/LICENSE +21 -0
  4. warderbox-0.3.0/PKG-INFO +482 -0
  5. warderbox-0.3.0/README.md +435 -0
  6. warderbox-0.3.0/assets/logo.png +0 -0
  7. warderbox-0.3.0/docs/index.html +302 -0
  8. warderbox-0.3.0/examples/demo.py +136 -0
  9. warderbox-0.3.0/examples/demo_full.py +259 -0
  10. warderbox-0.3.0/examples/demo_multiagent.py +101 -0
  11. warderbox-0.3.0/examples/demo_openai.py +185 -0
  12. warderbox-0.3.0/examples/policy.json +50 -0
  13. warderbox-0.3.0/pyproject.toml +67 -0
  14. warderbox-0.3.0/site/index.html +302 -0
  15. warderbox-0.3.0/src/warderbox/__init__.py +53 -0
  16. warderbox-0.3.0/src/warderbox/__main__.py +3 -0
  17. warderbox-0.3.0/src/warderbox/action.py +50 -0
  18. warderbox-0.3.0/src/warderbox/approval.py +275 -0
  19. warderbox-0.3.0/src/warderbox/async_shield.py +195 -0
  20. warderbox-0.3.0/src/warderbox/budget.py +76 -0
  21. warderbox-0.3.0/src/warderbox/capabilities.py +211 -0
  22. warderbox-0.3.0/src/warderbox/chaos.py +193 -0
  23. warderbox-0.3.0/src/warderbox/circuitbreaker.py +150 -0
  24. warderbox-0.3.0/src/warderbox/cli.py +117 -0
  25. warderbox-0.3.0/src/warderbox/compliance.py +306 -0
  26. warderbox-0.3.0/src/warderbox/config.py +91 -0
  27. warderbox-0.3.0/src/warderbox/dashboard.py +212 -0
  28. warderbox-0.3.0/src/warderbox/forecast.py +174 -0
  29. warderbox-0.3.0/src/warderbox/integrations/__init__.py +1 -0
  30. warderbox-0.3.0/src/warderbox/integrations/anthropic_sdk.py +119 -0
  31. warderbox-0.3.0/src/warderbox/integrations/autogen.py +116 -0
  32. warderbox-0.3.0/src/warderbox/integrations/crewai.py +115 -0
  33. warderbox-0.3.0/src/warderbox/integrations/langchain.py +127 -0
  34. warderbox-0.3.0/src/warderbox/integrations/openai_agents.py +138 -0
  35. warderbox-0.3.0/src/warderbox/logger.py +112 -0
  36. warderbox-0.3.0/src/warderbox/masking.py +185 -0
  37. warderbox-0.3.0/src/warderbox/metrics.py +159 -0
  38. warderbox-0.3.0/src/warderbox/multiagent.py +160 -0
  39. warderbox-0.3.0/src/warderbox/policy.py +126 -0
  40. warderbox-0.3.0/src/warderbox/ratelimit.py +109 -0
  41. warderbox-0.3.0/src/warderbox/replay.py +187 -0
  42. warderbox-0.3.0/src/warderbox/retry.py +106 -0
  43. warderbox-0.3.0/src/warderbox/rules.py +116 -0
  44. warderbox-0.3.0/src/warderbox/scoring.py +229 -0
  45. warderbox-0.3.0/src/warderbox/shield.py +474 -0
  46. warderbox-0.3.0/src/warderbox/snapshot.py +67 -0
  47. warderbox-0.3.0/src/warderbox/tracing.py +256 -0
  48. warderbox-0.3.0/src/warderbox/webhooks.py +113 -0
  49. warderbox-0.3.0/tests/__init__.py +0 -0
  50. warderbox-0.3.0/tests/test_config_and_logger.py +103 -0
  51. warderbox-0.3.0/tests/test_phase3.py +228 -0
  52. warderbox-0.3.0/tests/test_phase4.py +249 -0
  53. warderbox-0.3.0/tests/test_phase5.py +223 -0
  54. warderbox-0.3.0/tests/test_phase6.py +229 -0
  55. warderbox-0.3.0/tests/test_phase7.py +467 -0
  56. warderbox-0.3.0/tests/test_phase8.py +460 -0
  57. warderbox-0.3.0/tests/test_shield.py +138 -0
@@ -0,0 +1,21 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ *.egg
8
+ .eggs/
9
+ venv/
10
+ .venv/
11
+ env/
12
+ .env
13
+ *.db
14
+ *.sqlite3
15
+ logs/
16
+ .pytest_cache/
17
+ .mypy_cache/
18
+ .ruff_cache/
19
+ *.whl
20
+ *.tar.gz
21
+ .DS_Store
@@ -0,0 +1,75 @@
1
+ # Changelog
2
+
3
+ All notable changes to WarderBox (formerly OpShield) are documented here.
4
+
5
+ ## [0.3.0] - 2026-10-15
6
+
7
+ ### Changed — Rename
8
+ - **Project renamed from OpShield to WarderBox** to avoid trademark conflict with GE Digital's OpShield
9
+ - All imports: `from warderbox import WarderBox` (was `from opshield import OpShield`)
10
+ - CLI command: `warderbox` (was `opshield`)
11
+ - PyPI package: `pip install warderbox`
12
+
13
+ ## [0.2.0] - 2026-10-08
14
+
15
+ ### Added — Phase 7: Enterprise Safety
16
+ - **Circuit Breaker** (`circuitbreaker.py`): CLOSED/OPEN/HALF_OPEN states, configurable failure threshold, reset timeout, success threshold for recovery, on_open/on_close callbacks
17
+ - **Approval Workflows** (`approval.py`): Human-in-the-loop with configurable timeout, auto-deny, callback-based approve/deny, risk-based approval, escalation chains
18
+ - **Agent Capabilities** (`capabilities.py`): Per-agent allowlist/denylist, argument constraints (args_deny/args_require), max cost per tool, max calls per hour, time-based schedules
19
+ - **Compliance Reports** (`compliance.py`): Structured audit reports from SQLite logs, anomaly detection (high block/error rate, CRITICAL attempts), risk breakdown, JSON/HTML export
20
+
21
+ ### Added — Phase 8: Observability & Resilience
22
+ - **Distributed Tracing** (`tracing.py`): OpenTelemetry-compatible spans with trace/span IDs, nested spans via context manager, JSON and OTLP export, trace grouping
23
+ - **Chaos Engineering** (`chaos.py`): Fault injection (ERROR, LATENCY, TIMEOUT, CORRUPT_OUTPUT), probability control, conditional triggers, wildcard rules, max injection limits
24
+ - **Cost Forecasting** (`forecast.py`): Burn rate analysis (per minute/hour), budget exhaustion prediction, trend detection (increasing/decreasing/stable), cost-by-tool breakdown
25
+ - **Agent Scoring** (`scoring.py`): Safety/reliability/efficiency/risk dimensions (0-100), A-F grading, configurable weights, multi-agent pool ranking via PoolScorer
26
+
27
+ ### Added — Phase 9: Polish & Market Readiness
28
+ - Full README rewrite covering all 32+ modules
29
+ - Landing page (`site/index.html`) with feature showcase and market data
30
+ - Comprehensive end-to-end demo (`examples/demo_full.py`)
31
+ - This CHANGELOG
32
+
33
+ ### Changed
34
+ - `shield.py`: Integrated circuit breaker, capabilities, chaos, and tracing into execution pipeline
35
+ - `__init__.py`: Added exports for all new modules (ApprovalManager, CapabilityManager, CircuitBreaker, ChaosEngine, ComplianceReporter, CostForecaster, AgentScorer, PoolScorer, Tracer, FaultType, CircuitState)
36
+
37
+ ## [0.1.0] - 2026-10-08
38
+
39
+ ### Added — Phase 1: Core
40
+ - `WarderBox` main class with tool decorator
41
+ - Risk classification engine (LOW/MEDIUM/HIGH/CRITICAL)
42
+ - Budget tracking with per-action cost
43
+ - State snapshots and rollback
44
+ - Test/simulation mode
45
+
46
+ ### Added — Phase 2: Infrastructure
47
+ - Dict-based configuration system
48
+ - SQLite-backed action logging
49
+ - OpenAI Agents SDK integration
50
+ - LangChain integration
51
+ - CLI tool (stats, logs, export, validate, dashboard)
52
+ - pip install support via pyproject.toml
53
+
54
+ ### Added — Phase 3: Rate Limiting & Events
55
+ - Sliding-window rate limiter (global RPM/RPH, per-tool limits)
56
+ - Webhook/event notification system (HTTP + callbacks)
57
+ - Anthropic Claude SDK integration
58
+ - AsyncOpShield with async_tool decorator
59
+
60
+ ### Added — Phase 4: Policy & Dashboard
61
+ - Policy-as-code (JSON/YAML files)
62
+ - Retry with exponential backoff and conditional retry
63
+ - CrewAI integration
64
+ - Web dashboard (dark theme, auto-refresh, stats cards)
65
+
66
+ ### Added — Phase 5: Multi-Agent & Metrics
67
+ - AgentPool for multi-agent management with isolated budgets
68
+ - Microsoft AutoGen integration
69
+ - Prometheus-compatible metrics export (OpenMetrics text format)
70
+
71
+ ### Added — Phase 6: Privacy & Debug
72
+ - DataMasker with 10 built-in PII/secret patterns
73
+ - Custom masking patterns support
74
+ - ActionReplayer for debugging/audit from SQLite logs
75
+ - Dry-run and single-action replay
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ali Çelik
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,482 @@
1
+ Metadata-Version: 2.5
2
+ Name: warderbox
3
+ Version: 0.3.0
4
+ Summary: AI agent safety platform: rollback, cost control, circuit breakers, tracing, compliance, and chaos testing.
5
+ Project-URL: Homepage, https://alicelik-games.github.io/warderbox/
6
+ Project-URL: Documentation, https://github.com/alicelik-games/warderbox#readme
7
+ Project-URL: Issues, https://github.com/alicelik-games/warderbox/issues
8
+ Project-URL: Changelog, https://github.com/alicelik-games/warderbox/blob/main/CHANGELOG.md
9
+ Author-email: Ali Çelik <alicelik1980@gmail.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: agent,ai,chaos-engineering,circuit-breaker,compliance,cost-control,guardrails,multi-agent,observability,rate-limiting,rollback,safety,testing,tracing
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Security
22
+ Classifier: Topic :: Software Development :: Libraries
23
+ Requires-Python: >=3.11
24
+ Provides-Extra: all
25
+ Requires-Dist: anthropic>=0.18; extra == 'all'
26
+ Requires-Dist: crewai>=0.1; extra == 'all'
27
+ Requires-Dist: langchain-core>=0.1; extra == 'all'
28
+ Requires-Dist: openai>=1.0; extra == 'all'
29
+ Requires-Dist: pyautogen>=0.2; extra == 'all'
30
+ Requires-Dist: pyyaml>=6.0; extra == 'all'
31
+ Provides-Extra: anthropic
32
+ Requires-Dist: anthropic>=0.18; extra == 'anthropic'
33
+ Provides-Extra: autogen
34
+ Requires-Dist: pyautogen>=0.2; extra == 'autogen'
35
+ Provides-Extra: crewai
36
+ Requires-Dist: crewai>=0.1; extra == 'crewai'
37
+ Provides-Extra: dev
38
+ Requires-Dist: pytest>=7.0; extra == 'dev'
39
+ Requires-Dist: ruff>=0.1; extra == 'dev'
40
+ Provides-Extra: langchain
41
+ Requires-Dist: langchain-core>=0.1; extra == 'langchain'
42
+ Provides-Extra: openai
43
+ Requires-Dist: openai>=1.0; extra == 'openai'
44
+ Provides-Extra: yaml
45
+ Requires-Dist: pyyaml>=6.0; extra == 'yaml'
46
+ Description-Content-Type: text/markdown
47
+
48
+ <p align="center">
49
+ <img src="https://raw.githubusercontent.com/alicelik-games/warderbox/main/assets/logo.png" alt="WarderBox Logo" width="180"/>
50
+ </p>
51
+
52
+ <h1 align="center">WarderBox</h1>
53
+
54
+ <p align="center">
55
+ <strong>The safety layer between AI agents and the real world.</strong>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <a href="https://pypi.org/project/warderbox/"><img src="https://img.shields.io/pypi/v/warderbox?color=blue" alt="PyPI"/></a>
60
+ <a href="https://github.com/alicelik-games/warderbox/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="License"/></a>
61
+ <a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.11+-blue" alt="Python"/></a>
62
+ <a href="https://pypi.org/project/warderbox/"><img src="https://img.shields.io/pypi/dm/warderbox?color=orange" alt="Downloads"/></a>
63
+ </p>
64
+
65
+ WarderBox intercepts every tool call your AI agent makes and provides rollback, cost control, rate limiting, circuit breakers, approval workflows, distributed tracing, chaos testing, and compliance reporting — so agents can work autonomously without causing damage.
66
+
67
+ **Zero mandatory dependencies. One `pip install`. Works with every major agent framework.**
68
+
69
+ > **Market context:** With Guardrails AI acquired by Harvey (Sept 2026) and the AI agent safety market projected to grow from $610M to $6.85B at 41% CAGR, WarderBox fills the gap as a comprehensive, framework-agnostic agent operations platform.
70
+
71
+ ## Why WarderBox?
72
+
73
+ | Problem | WarderBox Solution |
74
+ |---------|---------------------|
75
+ | Agent runs `DROP TABLE` | Auto-blocked by risk classification |
76
+ | Agent overspends API budget | Budget limits + cost forecasting |
77
+ | Want to test without side effects | Test mode simulates everything |
78
+ | Agent made a mistake | One-call rollback via state snapshots |
79
+ | Agent spams an API | Rate limiting (RPM/RPH per tool) |
80
+ | Tool keeps failing | Circuit breaker auto-disables it |
81
+ | Need human approval | Approval workflows with timeout/escalation |
82
+ | Different agents, different rules | AgentPool with isolated budgets + capabilities |
83
+ | Sensitive data in logs | Automatic PII/secret masking |
84
+ | Need audit trail | SQLite logging + Prometheus + compliance reports |
85
+ | Test agent resilience | Chaos engineering with fault injection |
86
+ | Track every action | OpenTelemetry-compatible distributed tracing |
87
+ | Evaluate agent quality | Safety/performance scoring (A-F grades) |
88
+
89
+ ## Install
90
+
91
+ ```bash
92
+ pip install warderbox
93
+ ```
94
+
95
+ With framework integrations:
96
+
97
+ ```bash
98
+ pip install warderbox[openai] # OpenAI Agents SDK
99
+ pip install warderbox[anthropic] # Anthropic Claude SDK
100
+ pip install warderbox[langchain] # LangChain
101
+ pip install warderbox[crewai] # CrewAI
102
+ pip install warderbox[autogen] # Microsoft AutoGen
103
+ pip install warderbox[yaml] # YAML policy files
104
+ pip install warderbox[all] # Everything
105
+ ```
106
+
107
+ ## Quick Start
108
+
109
+ ```python
110
+ from warderbox import WarderBox
111
+
112
+ shield = WarderBox(budget=5.00, auto_snapshot=True)
113
+
114
+ @shield.tool(cost=0.03)
115
+ def query_db(sql: str) -> str:
116
+ return db.execute(sql)
117
+
118
+ # Normal execution
119
+ result = query_db(sql="SELECT * FROM users")
120
+ print(result.output) # Works fine
121
+
122
+ # Destructive SQL is auto-blocked
123
+ result = query_db(sql="DROP TABLE users")
124
+ print(result.blocked) # True
125
+ print(result.block_reason) # "CRITICAL risk blocked: Destructive SQL detected"
126
+
127
+ # Undo the last action
128
+ shield.rollback()
129
+ ```
130
+
131
+ ## Core Features
132
+
133
+ ### Policy-as-Code
134
+
135
+ Define rules in JSON or YAML files:
136
+
137
+ ```json
138
+ {
139
+ "budget": 25.00,
140
+ "mode": "production",
141
+ "global_rpm": 120,
142
+ "tool_limits": {"send_email": {"rpm": 10, "rph": 100}},
143
+ "rules": [
144
+ {
145
+ "name": "no_prod_access",
146
+ "match": {"args_regex": "production|prod-db"},
147
+ "risk": "critical",
148
+ "reason": "Production database access blocked"
149
+ }
150
+ ],
151
+ "webhooks": [
152
+ {"url": "https://hooks.slack.com/...", "events": ["action_blocked"]}
153
+ ]
154
+ }
155
+ ```
156
+
157
+ ```python
158
+ from warderbox import load_policy
159
+ shield = load_policy("policy.json")
160
+ ```
161
+
162
+ ### Multi-Agent Support
163
+
164
+ ```python
165
+ from warderbox import AgentPool
166
+
167
+ pool = AgentPool(default_budget=5.00)
168
+ researcher = pool.register("researcher", budget=3.00)
169
+ coder = pool.register("coder", budget=10.00)
170
+ reviewer = pool.register("reviewer", budget=1.00, mode="test")
171
+
172
+ pool.stats() # Aggregated view across all agents
173
+ pool.over_budget() # ["researcher"] if over budget
174
+ ```
175
+
176
+ ### Rate Limiting
177
+
178
+ ```python
179
+ from warderbox import WarderBox, ToolLimit
180
+
181
+ shield = WarderBox(
182
+ budget=10.00,
183
+ global_rpm=60, # 60 calls/min globally
184
+ tool_limits={"send_email": ToolLimit(rpm=5)}, # 5 emails/min
185
+ )
186
+ ```
187
+
188
+ ### Retry with Backoff
189
+
190
+ ```python
191
+ from warderbox import RetryPolicy
192
+
193
+ policy = RetryPolicy(max_retries=3, backoff_base=1.0, jitter=0.5)
194
+
195
+ @shield.tool(cost=0.05, retry=policy)
196
+ def flaky_api(query: str) -> str:
197
+ return requests.get(f"https://api.example.com?q={query}").text
198
+ ```
199
+
200
+ ### Sensitive Data Masking
201
+
202
+ ```python
203
+ from warderbox import DataMasker
204
+
205
+ masker = DataMasker()
206
+ shield.set_masker(masker)
207
+
208
+ # Emails, API keys, credit cards, SSNs, JWTs are auto-masked in logs
209
+ masker.add_pattern("project_id", r"PROJ-\d{6}", "PROJ-******")
210
+ ```
211
+
212
+ ## Enterprise Safety
213
+
214
+ ### Circuit Breaker
215
+
216
+ Auto-disable tools that fail repeatedly (CLOSED -> OPEN -> HALF_OPEN):
217
+
218
+ ```python
219
+ from warderbox import CircuitBreaker
220
+
221
+ cb = CircuitBreaker(failure_threshold=5, reset_timeout=60.0)
222
+ shield.set_circuit_breaker(cb)
223
+ # After 5 consecutive failures, the tool is auto-disabled for 60s
224
+ # Then one probe call is allowed (HALF_OPEN) to test recovery
225
+ ```
226
+
227
+ ### Human-in-the-Loop Approval
228
+
229
+ ```python
230
+ from warderbox import ApprovalManager
231
+
232
+ approver = ApprovalManager(default_timeout=30.0)
233
+ approver.require_approval("send_email", timeout=60.0)
234
+ approver.require_approval_for_risk("HIGH")
235
+ shield.set_approval(approver)
236
+
237
+ # From another thread or webhook handler:
238
+ approver.approve(request_id, approver="admin@company.com")
239
+ ```
240
+
241
+ ### Agent Capabilities / Permissions
242
+
243
+ Fine-grained tool access control per agent:
244
+
245
+ ```python
246
+ from warderbox import CapabilityManager
247
+
248
+ caps = CapabilityManager()
249
+ caps.grant("researcher", allow=["search", "read_file"])
250
+ caps.grant("intern_bot", deny=["delete_record", "send_email"])
251
+ caps.add_constraint("coder", "run_sql", args_deny=["DROP", "TRUNCATE"])
252
+ shield.set_capabilities(caps)
253
+ ```
254
+
255
+ ### Compliance & Audit Reports
256
+
257
+ ```python
258
+ from warderbox import ComplianceReporter
259
+
260
+ reporter = ComplianceReporter(db_path="audit.db")
261
+ report = reporter.generate_report(start="2026-01-01", end="2026-12-31")
262
+ print(report.summary) # Text summary with anomaly detection
263
+ reporter.export_json("audit.json")
264
+ html = reporter.to_html() # Full HTML report
265
+ ```
266
+
267
+ ## Observability
268
+
269
+ ### Distributed Tracing
270
+
271
+ OpenTelemetry-compatible span system:
272
+
273
+ ```python
274
+ from warderbox import Tracer
275
+
276
+ tracer = Tracer(service_name="my-agent")
277
+ shield.set_tracer(tracer)
278
+
279
+ # Every tool call automatically generates spans
280
+ # Nested spans for complex workflows:
281
+ with tracer.span("data_pipeline") as parent:
282
+ with tracer.span("extract", parent=parent):
283
+ extract_data()
284
+ with tracer.span("transform", parent=parent):
285
+ transform_data()
286
+
287
+ tracer.export_json("traces.json") # JSON export
288
+ tracer.export_otlp() # OTLP-compatible dict
289
+ ```
290
+
291
+ ### Cost Forecasting
292
+
293
+ ```python
294
+ from warderbox import CostForecaster
295
+
296
+ forecaster = CostForecaster(shield)
297
+ report = forecaster.forecast()
298
+ print(report.burn_rate_per_hour) # $/hour
299
+ print(report.estimated_exhaustion) # datetime
300
+ print(report.estimated_actions_remaining)
301
+ print(report.trend) # "increasing" / "stable" / "decreasing"
302
+ ```
303
+
304
+ ### Agent Scoring & Benchmarking
305
+
306
+ ```python
307
+ from warderbox import AgentScorer, PoolScorer
308
+
309
+ scorer = AgentScorer(shield, agent_name="my-bot")
310
+ report = scorer.score()
311
+ print(report.overall_score) # 0-100
312
+ print(report.grade) # A/B/C/D/F
313
+ print(report.safety_score) # Safety dimension
314
+ print(report.reliability_score)
315
+
316
+ # Rank all agents in a pool
317
+ pool_scorer = PoolScorer(pool)
318
+ print(pool_scorer.summary()) # Ranked leaderboard
319
+ ```
320
+
321
+ ### Web Dashboard
322
+
323
+ ```bash
324
+ warderbox --db audit.db dashboard --port 8080
325
+ ```
326
+
327
+ Real-time web UI showing actions, blocks, budget, and rate limits.
328
+
329
+ ### Prometheus Metrics
330
+
331
+ ```python
332
+ from warderbox.metrics import start_metrics_server
333
+ start_metrics_server(shield, port=9090)
334
+ # Scrape http://localhost:9090/metrics
335
+ ```
336
+
337
+ Exports: `warderbox_actions_total`, `warderbox_actions_blocked_total`, `warderbox_budget_spent_dollars`, per-tool and per-agent labels.
338
+
339
+ ### Webhook Notifications
340
+
341
+ ```python
342
+ shield.notifier.add_webhook(
343
+ url="https://hooks.slack.com/services/xxx",
344
+ events={"action_blocked", "budget_exceeded"},
345
+ )
346
+
347
+ shield.notifier.on("action_blocked", lambda event, data: print(f"Alert: {data}"))
348
+ ```
349
+
350
+ ## Resilience Testing
351
+
352
+ ### Chaos Engineering
353
+
354
+ Test agent resilience with controlled fault injection:
355
+
356
+ ```python
357
+ from warderbox import ChaosEngine, FaultType
358
+
359
+ chaos = ChaosEngine()
360
+ shield.set_chaos(chaos)
361
+
362
+ # Random failures (20% of calls)
363
+ chaos.add_fault("search_api", FaultType.ERROR, probability=0.2)
364
+
365
+ # Latency injection
366
+ chaos.add_fault("slow_api", FaultType.LATENCY, latency_ms=2000)
367
+
368
+ # Conditional faults
369
+ chaos.add_fault("db_query", FaultType.ERROR,
370
+ condition=lambda args: "prod" in str(args))
371
+
372
+ # Wildcard — affect all tools
373
+ chaos.add_fault("*", FaultType.LATENCY, latency_ms=500, probability=0.1)
374
+ ```
375
+
376
+ ### Action Replay
377
+
378
+ ```python
379
+ from warderbox.replay import ActionReplayer
380
+
381
+ replayer = ActionReplayer(db_path="audit.db", executors={"run_sql": my_fn})
382
+ report = replayer.replay_all(shield)
383
+ print(f"Match rate: {report.success_rate:.0%}")
384
+ ```
385
+
386
+ ### Async Support
387
+
388
+ ```python
389
+ from warderbox import AsyncWarderBox
390
+
391
+ shield = AsyncWarderBox(budget=5.00)
392
+
393
+ @shield.async_tool(cost=0.05)
394
+ async def async_query(sql: str) -> str:
395
+ return await db.execute(sql)
396
+ ```
397
+
398
+ ## Framework Integrations
399
+
400
+ | Framework | Module | Pattern |
401
+ |-----------|--------|---------|
402
+ | OpenAI Agents SDK | `integrations.openai_agents` | Middleware |
403
+ | Anthropic Claude | `integrations.anthropic_sdk` | Middleware |
404
+ | LangChain | `integrations.langchain` | Tool wrapper |
405
+ | CrewAI | `integrations.crewai` | Tool wrapper |
406
+ | Microsoft AutoGen | `integrations.autogen` | Function wrapper |
407
+
408
+ ```python
409
+ # OpenAI
410
+ from warderbox.integrations.openai_agents import OpenAIShieldMiddleware
411
+ middleware = OpenAIShieldMiddleware(shield=shield, executors={...})
412
+
413
+ # Anthropic
414
+ from warderbox.integrations.anthropic_sdk import AnthropicShieldMiddleware
415
+ middleware = AnthropicShieldMiddleware(shield=shield, executors={...})
416
+
417
+ # LangChain
418
+ from warderbox.integrations.langchain import shield_langchain_tools
419
+
420
+ # CrewAI
421
+ from warderbox.integrations.crewai import shield_crewai_tools
422
+
423
+ # AutoGen
424
+ from warderbox.integrations.autogen import shield_autogen_functions
425
+ ```
426
+
427
+ ## CLI
428
+
429
+ ```bash
430
+ warderbox stats # Action statistics
431
+ warderbox logs # View action log
432
+ warderbox logs --blocked # Only blocked actions
433
+ warderbox export audit.json # Export to JSON
434
+ warderbox validate policy.json # Validate a policy file
435
+ warderbox dashboard --port 8080 # Start web dashboard
436
+ ```
437
+
438
+ ## Risk Levels
439
+
440
+ | Level | Behavior | Examples |
441
+ |-------|----------|----------|
442
+ | LOW | Execute normally | SELECT queries, file reads |
443
+ | MEDIUM | Execute with logging | Outbound messages, moderate operations |
444
+ | HIGH | Ask user for approval | Bulk operations (>100 items) |
445
+ | CRITICAL | Auto-block | DROP TABLE, TRUNCATE, DELETE FROM |
446
+
447
+ ## Architecture
448
+
449
+ ```
450
+ Agent -> WarderBox -> Tool
451
+ |-- Capability Check (permissions)
452
+ |-- Circuit Breaker (fail-fast)
453
+ |-- Risk Classification (rules engine)
454
+ |-- Approval Workflow (human-in-the-loop)
455
+ |-- Budget Check + Forecast
456
+ |-- Rate Limit Check
457
+ |-- Snapshot (for rollback)
458
+ |-- Chaos Injection (testing)
459
+ |-- Execute (or simulate in test mode)
460
+ |-- Retry (on failure, with backoff)
461
+ |-- Data Masking (for logs)
462
+ |-- Log to SQLite
463
+ |-- Emit webhook/callback events
464
+ |-- Record span (distributed tracing)
465
+ |-- Agent Scoring
466
+ |-- Prometheus metrics
467
+ ```
468
+
469
+ ## Stats
470
+
471
+ - **32+ Python modules**, 107+ tests
472
+ - **Zero mandatory dependencies**
473
+ - **5 framework integrations**
474
+ - Works with Python 3.11+
475
+
476
+ ## Author
477
+
478
+ **Ali Celik** — [LinkedIn](https://linkedin.com/in/alicelik1980) · [Email](mailto:alicelik1980@gmail.com)
479
+
480
+ ## License
481
+
482
+ MIT — see [LICENSE](LICENSE) for details.