agenthacker 0.1.0__py3-none-any.whl
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.
- agenthacker-0.1.0.dist-info/METADATA +403 -0
- agenthacker-0.1.0.dist-info/RECORD +30 -0
- agenthacker-0.1.0.dist-info/WHEEL +4 -0
- agenthacker-0.1.0.dist-info/licenses/LICENSE +201 -0
- agenthacker-0.1.0.dist-info/licenses/NOTICE +6 -0
- firewall_sdk/__init__.py +100 -0
- firewall_sdk/agent_helpers.py +128 -0
- firewall_sdk/alignment_check.py +113 -0
- firewall_sdk/anomaly.py +462 -0
- firewall_sdk/client.py +676 -0
- firewall_sdk/cloud_client.py +753 -0
- firewall_sdk/constants.py +21 -0
- firewall_sdk/context_summarizer.py +164 -0
- firewall_sdk/event_store.py +660 -0
- firewall_sdk/features.py +128 -0
- firewall_sdk/intent_gate.py +325 -0
- firewall_sdk/intent_guard.py +373 -0
- firewall_sdk/intent_splitter.py +114 -0
- firewall_sdk/invariant.py +113 -0
- firewall_sdk/lang.py +311 -0
- firewall_sdk/llm_guard.py +318 -0
- firewall_sdk/llm_judge.py +92 -0
- firewall_sdk/logger.py +273 -0
- firewall_sdk/output_guard.py +150 -0
- firewall_sdk/py.typed +0 -0
- firewall_sdk/scan_engine.py +569 -0
- firewall_sdk/schemas.py +25 -0
- firewall_sdk/tool_guard.py +67 -0
- firewall_sdk/trace.py +68 -0
- firewall_sdk/translate_guard.py +188 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agenthacker
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Runtime security firewall for LLM agents — four-checkpoint scan engine, local-first with an optional hosted cloud tier
|
|
5
|
+
Project-URL: Homepage, https://github.com/Agent-Hacker-Corp/agenthacker
|
|
6
|
+
Project-URL: Repository, https://github.com/Agent-Hacker-Corp/agenthacker
|
|
7
|
+
Project-URL: Changelog, https://github.com/Agent-Hacker-Corp/agenthacker/blob/main/CHANGELOG.md
|
|
8
|
+
Author-email: AgentHacker <reports@agenthacker.ai>
|
|
9
|
+
Maintainer-email: AgentHacker <reports@agenthacker.ai>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Keywords: agent,ai-safety,firewall,guardrails,jailbreak,llm,prompt-injection,security
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Security
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Requires-Dist: requests>=2.25
|
|
25
|
+
Provides-Extra: dashboard
|
|
26
|
+
Requires-Dist: psycopg2-binary; extra == 'dashboard'
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-asyncio; extra == 'dev'
|
|
30
|
+
Provides-Extra: invariant
|
|
31
|
+
Requires-Dist: invariant-ai==0.3.5; extra == 'invariant'
|
|
32
|
+
Provides-Extra: llm-guard
|
|
33
|
+
Requires-Dist: llm-guard; extra == 'llm-guard'
|
|
34
|
+
Provides-Extra: semantic
|
|
35
|
+
Requires-Dist: sentence-transformers>=3.0; extra == 'semantic'
|
|
36
|
+
Provides-Extra: translate
|
|
37
|
+
Requires-Dist: boto3; extra == 'translate'
|
|
38
|
+
Requires-Dist: pycld3; extra == 'translate'
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# Firewall SDK
|
|
42
|
+
|
|
43
|
+
A runtime security firewall for LLM agents.
|
|
44
|
+
|
|
45
|
+
> **New to AgentHacker?** Start with [docs/getting_started.md](docs/getting_started.md):
|
|
46
|
+
> it covers the high-level `Firewall` client (the ~10-minute "Tier 1" path) and a
|
|
47
|
+
> feature reference with costs and recommendations. **This README is the deeper
|
|
48
|
+
> "Tier 2" reference** — the four local scan checkpoints you wire into an agent loop.
|
|
49
|
+
|
|
50
|
+
The SDK provides four checkpoint scan functions that agents call at specific points in their agent loop. The SDK owns scanning and detection. The agent owns everything else: the loop, the tools, the auth, the prompts, the data.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
The **distribution** name is `agenthacker` (`pip install agenthacker`); the
|
|
55
|
+
**import** name is `firewall_sdk` (`from firewall_sdk import Firewall`).
|
|
56
|
+
`requests` is installed automatically; ML layers are optional extras.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Base install from PyPI — scan engine + high-level Firewall cloud client
|
|
60
|
+
pip install agenthacker
|
|
61
|
+
|
|
62
|
+
# With LLM Guard semantic scanning (DeBERTa models, ~500MB RAM per worker)
|
|
63
|
+
pip install "agenthacker[llm_guard]"
|
|
64
|
+
|
|
65
|
+
# With Invariant trace-level policy analysis
|
|
66
|
+
pip install "agenthacker[invariant]"
|
|
67
|
+
|
|
68
|
+
# From source (this repo), for local development
|
|
69
|
+
pip install -e .
|
|
70
|
+
|
|
71
|
+
# Dev extras (pytest, pytest-asyncio)
|
|
72
|
+
pip install -e ".[dev]"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For a complete runnable version, see [`examples/quickstart.py`](examples/quickstart.py) —
|
|
76
|
+
`python examples/quickstart.py` prints a blocked and an allowed verdict with no key
|
|
77
|
+
and no network.
|
|
78
|
+
|
|
79
|
+
## The Four Checkpoints
|
|
80
|
+
|
|
81
|
+
### CP-1: Input Scan
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from firewall_sdk import scan_input
|
|
85
|
+
|
|
86
|
+
scan_input(text, *, max_input_length) -> ScanResult
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**When:** Before the user's message enters the agent loop.
|
|
90
|
+
|
|
91
|
+
**What it checks:** R-01 through R-15: regex-based injection detection (system prompt extraction, role hijacking, hypothetical jailbreak, indirect injection, delimiter injection, RAG injection, privilege escalation, encoded content, context overflow, social engineering, adversarial suffixes). Topic scoping (R-16) is enforced at the intent gate (CP-2), not here.
|
|
92
|
+
|
|
93
|
+
**Agent supplies:** An integer max input length (R-09 overflow). Domain topic scoping is configured at the intent gate, not passed to `scan_input`.
|
|
94
|
+
|
|
95
|
+
### CP-2: Data Field Scan
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from firewall_sdk import scan_data_field
|
|
99
|
+
|
|
100
|
+
scan_data_field(text) -> ScanResult
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**When:** On each field of tool results before they reach the model.
|
|
104
|
+
|
|
105
|
+
**What it checks:** Same injection rules as CP-1 adapted for data context (R-05 blocks any URL in data fields, not just URLs with action words), plus S-03 secrets detection.
|
|
106
|
+
|
|
107
|
+
**Agent supplies:** Nothing. Fully domain-agnostic.
|
|
108
|
+
|
|
109
|
+
### CP-3: Tool Call Authorization
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from firewall_sdk import scan_tool_call
|
|
113
|
+
|
|
114
|
+
scan_tool_call(name, args, allowed_ids, *, allowed_tools, id_resolver) -> ScanResult
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**When:** After the LLM emits a tool_use, before execution.
|
|
118
|
+
|
|
119
|
+
**What it checks:** Tool name against the allowlist, then entity ID authorization via the resolver.
|
|
120
|
+
|
|
121
|
+
**Agent supplies:**
|
|
122
|
+
|
|
123
|
+
- `allowed_tools` — a **request-scoped** `set[str]` of permitted tool names. This must be computed per-request, not a static constant. The patient agent computes it from auth context to enforce role-based restrictions (e.g., patients cannot use `send_reminder`). The order agent passes a static `{"get_order_status"}`.
|
|
124
|
+
- `id_resolver` — a callable with signature `(name: str, args: dict) -> set[str]` that returns all entity IDs requiring authorization for this tool call. Returns an empty set if no IDs to check.
|
|
125
|
+
|
|
126
|
+
### CP-4: Output Scan
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from firewall_sdk import scan_output
|
|
130
|
+
|
|
131
|
+
scan_output(
|
|
132
|
+
text, system_prompt, requester_email, allowed_ids, all_user_emails,
|
|
133
|
+
*, entity_pattern, leakage_label
|
|
134
|
+
) -> ScanResult
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**When:** After the model produces a final text response, before returning to the user.
|
|
138
|
+
|
|
139
|
+
**What it checks:** S-01 system prompt leakage (5-word shingle overlap), S-02 cross-entity ID and email leakage, S-03 secrets, S-04 offensive content.
|
|
140
|
+
|
|
141
|
+
**Agent supplies:** A compiled regex for entity IDs (e.g., `re.compile(r"ORD-\d+")` or `re.compile(r"PAT-\d+")`), and a label string for audit logs (e.g., `"Cross-User Data Leakage"`).
|
|
142
|
+
|
|
143
|
+
### ScanResult
|
|
144
|
+
|
|
145
|
+
All scan functions return a `ScanResult`:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from firewall_sdk import ScanResult, CLEAN
|
|
149
|
+
|
|
150
|
+
@dataclass
|
|
151
|
+
class ScanResult:
|
|
152
|
+
clean: bool
|
|
153
|
+
rule_id: str | None = None
|
|
154
|
+
rule_name: str | None = None
|
|
155
|
+
matched_text: str | None = None # truncated to 100 chars
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`CLEAN` is the singleton `ScanResult(clean=True)`. Any non-clean result blocks the request — the agent returns a refusal and logs an audit event.
|
|
159
|
+
|
|
160
|
+
### Wiring Example
|
|
161
|
+
|
|
162
|
+
See `apps/order_agent/firewall.py` (~70 lines) for the canonical wiring example — a real, tested thin wrapper showing exactly how an agent feeds domain config into SDK scan functions.
|
|
163
|
+
|
|
164
|
+
## Optional Integrations
|
|
165
|
+
|
|
166
|
+
### LLM Guard (`firewall_sdk.llm_guard`)
|
|
167
|
+
|
|
168
|
+
Semantic second-pass scanning using DeBERTa models. Detects prompt injection, secrets, and sensitive output that regex rules miss.
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
import firewall_sdk.llm_guard as llm_guard
|
|
172
|
+
|
|
173
|
+
# At startup
|
|
174
|
+
llm_guard.warmup(
|
|
175
|
+
enabled=True,
|
|
176
|
+
injection_threshold=0.9,
|
|
177
|
+
use_onnx=False,
|
|
178
|
+
workers=1,
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
# Per-checkpoint (same signatures as core scan functions)
|
|
182
|
+
await llm_guard.scan_input(text)
|
|
183
|
+
await llm_guard.scan_data_field(text)
|
|
184
|
+
await llm_guard.scan_output(prompt, output_text)
|
|
185
|
+
|
|
186
|
+
llm_guard.is_ready() # For /health endpoint
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Invariant Analyzer (`firewall_sdk.invariant`)
|
|
190
|
+
|
|
191
|
+
Trace-level policy evaluation using Invariant policy files (`.inv`). Detects sequence-level violations (retry loops, data leakage after denied tool calls, unauthorized tool calls) that per-message scanning cannot catch.
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
import firewall_sdk.invariant as invariant
|
|
195
|
+
|
|
196
|
+
# At startup
|
|
197
|
+
await invariant.warmup(
|
|
198
|
+
enabled=True,
|
|
199
|
+
policy_dir="policies/order_agent",
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
# After CP-4 (or CP-3 for pre-tool checks)
|
|
203
|
+
result = await invariant.analyze_trace(trace)
|
|
204
|
+
|
|
205
|
+
invariant.BLOCKING_RULES # frozenset of rule names eligible for blocking mode
|
|
206
|
+
invariant.is_ready() # For /health endpoint
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Structured Logger (`firewall_sdk.logger`)
|
|
210
|
+
|
|
211
|
+
JSON-formatted audit logging with HMAC-hashed email identifiers.
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
import firewall_sdk.logger as logger
|
|
215
|
+
|
|
216
|
+
# At startup
|
|
217
|
+
logger.setup_logging("INFO", "your-secret-salt") # Not "change-me-in-prod"
|
|
218
|
+
|
|
219
|
+
logger.log_firewall_event(checkpoint, scan_result, user_email, ip)
|
|
220
|
+
logger.log_agent_invocation(user_email, question, tool_calls, tokens, latency, blocked)
|
|
221
|
+
logger.hash_email("user@example.com") # -> 16-char HMAC hex
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Trace Normalization (`firewall_sdk.trace`)
|
|
225
|
+
|
|
226
|
+
Converts Anthropic-format traces to OpenAI-compatible format for Invariant analysis. Pure function, no state.
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
from firewall_sdk.trace import normalize_trace
|
|
230
|
+
|
|
231
|
+
invariant_trace = normalize_trace(anthropic_snapshot_trace)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Fail-Open Behavior
|
|
235
|
+
|
|
236
|
+
LLM Guard and Invariant return `CLEAN` when disabled, not initialized, or on error. This is a deliberate availability choice — a scanner failure does not block user requests. The `/health` endpoint exposes `is_ready()` for monitoring.
|
|
237
|
+
|
|
238
|
+
### Module-Level State
|
|
239
|
+
|
|
240
|
+
All three stateful modules (`llm_guard`, `invariant`, `logger`) use module-level globals set by `warmup()`. This is safe when each agent runs in its own process. Each module provides a `reset()` function for test isolation (see `tests/conftest.py`).
|
|
241
|
+
|
|
242
|
+
## Provisional Module: agent_helpers
|
|
243
|
+
|
|
244
|
+
```python
|
|
245
|
+
from firewall_sdk.agent_helpers import (
|
|
246
|
+
needs_llm_guard, # Domain-agnostic, likely to stabilize
|
|
247
|
+
normalize_refusal, # Domain-agnostic, likely to stabilize
|
|
248
|
+
serialize_blocks, # Anthropic-specific, will change in Phase 5
|
|
249
|
+
serialize_message, # Anthropic-specific, will change in Phase 5
|
|
250
|
+
snapshot_trace, # Anthropic-specific, will change in Phase 5
|
|
251
|
+
)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Both agents use all five functions. They work. But the interface is **not frozen**.
|
|
255
|
+
|
|
256
|
+
`serialize_blocks`, `serialize_message`, and `snapshot_trace` access Anthropic SDK content block attributes directly (`.type`, `.text`, `.id`, `.name`, `.input`). These will change when framework portability is introduced. `needs_llm_guard` and `normalize_refusal` are domain-agnostic and likely to stabilize.
|
|
257
|
+
|
|
258
|
+
`agent_helpers` is **not** re-exported from `firewall_sdk.__init__`. Import it directly: `from firewall_sdk.agent_helpers import ...`.
|
|
259
|
+
|
|
260
|
+
## What the Agent Must Supply
|
|
261
|
+
|
|
262
|
+
Each agent provides domain config through a thin `firewall.py` wrapper that imports SDK functions and passes domain-specific values. The agent's `agent.py` calls the wrapper identically to pre-extraction code.
|
|
263
|
+
|
|
264
|
+
| Config | Purpose | Order Agent | Patient Agent |
|
|
265
|
+
|--------|---------|-------------|---------------|
|
|
266
|
+
| `SCANNABLE_FIELDS` | Field names for CP-2 iteration | `["product", "order_id", ...]` | `["appointment_id", "patient_id", ...]` |
|
|
267
|
+
| Topic keywords | Compiled regex for R-16 | `r"\b(?:order\|orders\|status\|...)` | `r"\b(?:appointment\|insurance\|...)` |
|
|
268
|
+
| Entity pattern | Compiled regex for CP-4 S-02 | `r"ORD-\d+"` | `r"PAT-\d+"` |
|
|
269
|
+
| Leakage label | String for audit logs | `"Cross-User Data Leakage"` | `"Cross-Patient Data Leakage"` |
|
|
270
|
+
| `allowed_tools` | Request-scoped tool set | `{"get_order_status"}` | Varies by role |
|
|
271
|
+
| `id_resolver` | `(name, args) -> set[str]` | Extracts `order_id` | Extracts `patient_id` + resolves `appointment_id` |
|
|
272
|
+
| Refusal prefix | For `normalize_refusal` | `"I'm sorry, but I can't help with that."` | Same |
|
|
273
|
+
| Refusal indicators | Compiled regex | Agent-specific pattern | Agent-specific pattern |
|
|
274
|
+
| Policy directory | For Invariant | `policies/order_agent/` | `policies/patient_services/` |
|
|
275
|
+
|
|
276
|
+
See `apps/order_agent/firewall.py` as the canonical wiring example.
|
|
277
|
+
|
|
278
|
+
## What the SDK Does NOT Own
|
|
279
|
+
|
|
280
|
+
The SDK must never contain:
|
|
281
|
+
|
|
282
|
+
- Agent loop or orchestration logic
|
|
283
|
+
- FastAPI routes or HTTP request/response schemas
|
|
284
|
+
- Auth implementations or identity provider logic
|
|
285
|
+
- Storage adapters or data access code
|
|
286
|
+
- Domain prompts or domain-specific policy rules
|
|
287
|
+
- Tool implementations
|
|
288
|
+
- UI code
|
|
289
|
+
|
|
290
|
+
If it mentions a domain noun (orders, patients, appointments), it does not belong in the SDK.
|
|
291
|
+
|
|
292
|
+
## Initialization Lifecycle
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
startup:
|
|
296
|
+
logger.setup_logging(level, salt)
|
|
297
|
+
llm_guard.warmup(enabled=..., threshold=..., onnx=..., workers=...)
|
|
298
|
+
await invariant.warmup(enabled=..., policy_dir=...)
|
|
299
|
+
|
|
300
|
+
per-request:
|
|
301
|
+
allowed_tools = compute from auth context (request-scoped)
|
|
302
|
+
CP-1: firewall.scan_input -> optionally llm_guard.scan_input
|
|
303
|
+
agent loop:
|
|
304
|
+
CP-3: firewall.scan_tool_call(..., allowed_tools=allowed_tools)
|
|
305
|
+
execute tool
|
|
306
|
+
CP-2: firewall.scan_data_field per field -> optionally llm_guard.scan_data_field
|
|
307
|
+
CP-4: firewall.scan_output -> optionally llm_guard.scan_output
|
|
308
|
+
-> optionally invariant.analyze_trace
|
|
309
|
+
|
|
310
|
+
test teardown:
|
|
311
|
+
llm_guard.reset(); invariant.reset(); logger.reset()
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## Architecture
|
|
315
|
+
|
|
316
|
+
### Checkpoint Sequence
|
|
317
|
+
|
|
318
|
+
```mermaid
|
|
319
|
+
sequenceDiagram
|
|
320
|
+
participant U as User
|
|
321
|
+
participant A as Agent
|
|
322
|
+
participant F as Firewall SDK
|
|
323
|
+
participant T as Tool
|
|
324
|
+
participant M as Model (Claude)
|
|
325
|
+
|
|
326
|
+
U->>A: Request
|
|
327
|
+
A->>F: CP-1: scan_input
|
|
328
|
+
alt blocked
|
|
329
|
+
F-->>A: ScanResult(clean=False)
|
|
330
|
+
A-->>U: Refusal + audit log
|
|
331
|
+
end
|
|
332
|
+
A->>M: System prompt + tools + message
|
|
333
|
+
M->>A: tool_use
|
|
334
|
+
A->>F: CP-3: scan_tool_call
|
|
335
|
+
alt blocked
|
|
336
|
+
F-->>A: ScanResult(clean=False)
|
|
337
|
+
A->>M: "Access denied" tool result
|
|
338
|
+
else clean
|
|
339
|
+
A->>T: Execute tool
|
|
340
|
+
T->>A: Result
|
|
341
|
+
A->>F: CP-2: scan_data_field (per field)
|
|
342
|
+
alt blocked
|
|
343
|
+
A->>M: "Data unavailable" tool result
|
|
344
|
+
else clean
|
|
345
|
+
A->>M: Tool result
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
M->>A: end_turn (final text)
|
|
349
|
+
A->>F: CP-4: scan_output
|
|
350
|
+
alt blocked
|
|
351
|
+
F-->>A: ScanResult(clean=False)
|
|
352
|
+
A-->>U: Refusal + audit log
|
|
353
|
+
else clean
|
|
354
|
+
A-->>U: Response
|
|
355
|
+
end
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### SDK Composition
|
|
359
|
+
|
|
360
|
+
```mermaid
|
|
361
|
+
graph TB
|
|
362
|
+
subgraph "Core (stable, re-exported from __init__)"
|
|
363
|
+
schemas["schemas<br/>ScanResult, CLEAN"]
|
|
364
|
+
scan_engine["scan_engine<br/>scan_input, scan_data_field"]
|
|
365
|
+
tool_guard["tool_guard<br/>scan_tool_call"]
|
|
366
|
+
output_guard["output_guard<br/>scan_output"]
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
subgraph "Optional integrations (stable, import by path)"
|
|
370
|
+
llm_guard["llm_guard<br/>warmup, scan_*, reset"]
|
|
371
|
+
invariant["invariant<br/>warmup, analyze_trace, reset"]
|
|
372
|
+
sdk_logger["logger<br/>setup_logging, log_*, reset"]
|
|
373
|
+
trace["trace<br/>normalize_trace"]
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
subgraph "Provisional (will change in Phase 5)"
|
|
377
|
+
helpers["agent_helpers<br/>serialize_*, normalize_refusal, needs_llm_guard"]
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
OA[Order Agent] --> schemas & scan_engine & tool_guard & output_guard
|
|
381
|
+
OA --> llm_guard & invariant & sdk_logger
|
|
382
|
+
OA --> helpers
|
|
383
|
+
|
|
384
|
+
PA[Patient Agent] --> schemas & scan_engine & tool_guard & output_guard
|
|
385
|
+
PA --> llm_guard & invariant & sdk_logger
|
|
386
|
+
PA --> helpers
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
## Version and Governance
|
|
390
|
+
|
|
391
|
+
Current version: `0.1.0` (semver 0.y.z = initial development).
|
|
392
|
+
|
|
393
|
+
1. No breaking changes to `firewall_sdk` without updating both agents in the same PR
|
|
394
|
+
2. Public interface modifications require CHANGELOG entries
|
|
395
|
+
3. `__all__` lists and `tests/firewall_sdk/test_public_api_surface.py` enforce what's public
|
|
396
|
+
|
|
397
|
+
## Known Couplings and Future Work
|
|
398
|
+
|
|
399
|
+
**Anthropic-specific serialization.** `agent_helpers.serialize_blocks`, `serialize_message`, and `snapshot_trace` access Anthropic SDK content block attributes. `trace.normalize_trace` converts Anthropic format to OpenAI-compatible format for Invariant. Phase 5 must abstract these for framework portability. This is why `agent_helpers` is provisional. (`trace` is semi-public because its interface is stable — one pure function — even though its implementation is Anthropic-format-aware.)
|
|
400
|
+
|
|
401
|
+
**Module-level state.** The `warmup()`/`reset()` pattern is process-scoped. Multi-agent-in-one-process hosting would require instance-based refactoring.
|
|
402
|
+
|
|
403
|
+
**`_LLM_REFUSAL_INDICATORS` duplication.** Both agents define nearly identical refusal regexes — one says `"specifically designed to help you check"`, the other says `"specifically designed to help"`. Could become an SDK-provided default with agent override in a future version.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
firewall_sdk/__init__.py,sha256=W0AcA2M3Zhs7Mb9sMh3NK_7jk4WfvqPvgRQkydK2iIs,2664
|
|
2
|
+
firewall_sdk/agent_helpers.py,sha256=lsWFpUhEE6Nbodx-7UYvWNZWtEPxWOBMUTmo2kz5-AY,3857
|
|
3
|
+
firewall_sdk/alignment_check.py,sha256=wI5wKUItHV4qd19tO7dHX_eUTYEC4md3hP82kbmkhms,3969
|
|
4
|
+
firewall_sdk/anomaly.py,sha256=oxVvBnvqfIqAS_uviY_rwdpeTwswCg6t1JiR7fBIkjI,17319
|
|
5
|
+
firewall_sdk/client.py,sha256=ym-C14ELyG7jmEziuJn2FIoySLRJa5K6Nen90dNoV3Q,27642
|
|
6
|
+
firewall_sdk/cloud_client.py,sha256=maPTZsfrG-Db4K-cg3_prqMD7m4EBSZCLxGHcmNbzP8,26841
|
|
7
|
+
firewall_sdk/constants.py,sha256=W5Tp9AvLFOfURVAw8Sg9dFm2xcFL3SiX1HiITly_pV8,524
|
|
8
|
+
firewall_sdk/context_summarizer.py,sha256=mWJgrwwXwSbYwla7uFXpPb6YASCx28osx9ko4RkgOtE,5977
|
|
9
|
+
firewall_sdk/event_store.py,sha256=X5dY2VGMg3aQmvQeLHvMH25F1NDZj4MuxFsOJ7Rkv7c,22636
|
|
10
|
+
firewall_sdk/features.py,sha256=B8Iua1zay6YarV4kpDXpP2p8F_mXyIBUxjuSL_p30IA,4566
|
|
11
|
+
firewall_sdk/intent_gate.py,sha256=FKiem13eGTcaJfIVRcVJVHnKvqN23WTAnbJApW68Chs,13658
|
|
12
|
+
firewall_sdk/intent_guard.py,sha256=4I1r8QCXi6HG66jsrEqWtEzkPPbDvZiVHx5rwbrmfSw,13845
|
|
13
|
+
firewall_sdk/intent_splitter.py,sha256=gKgN8n9oREJKKrIyM4vacvUU4dFeXS0OE7Uu57n2U7w,5209
|
|
14
|
+
firewall_sdk/invariant.py,sha256=UAJooW0z1UffWZcKDeGpgT8qiCl9sKt6TpxA_E4oX24,3539
|
|
15
|
+
firewall_sdk/lang.py,sha256=OZzB9TfDcTsq18RYzkbyfANFntMjxgTIYEUEizChmzI,9637
|
|
16
|
+
firewall_sdk/llm_guard.py,sha256=D1l2OnB3AflG9O_b9RDI0ymBsfZQd3fY-w_a8SZxvek,10182
|
|
17
|
+
firewall_sdk/llm_judge.py,sha256=UJijsjAkX_BACwcjNPClDAJweItZ2_uV4KfpLQnNCjg,3088
|
|
18
|
+
firewall_sdk/logger.py,sha256=JZBtE5PzOO4yS8dJAfuHZBC-z3-rBY9XkozMrS3QvhQ,8386
|
|
19
|
+
firewall_sdk/output_guard.py,sha256=b3HDllas9YAqbCuTIhCeBsW-lWRL4oo1yqGg6XPUu84,5937
|
|
20
|
+
firewall_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
+
firewall_sdk/scan_engine.py,sha256=8BdtcTZ17KiNOzDB-R1eL_c_bFMb-RcT6Xj1tZ0MbNc,21065
|
|
22
|
+
firewall_sdk/schemas.py,sha256=LYUyc7M9guBtZHigvY_w-nBwr0sr3W7jHDx5ie4oVbo,629
|
|
23
|
+
firewall_sdk/tool_guard.py,sha256=7CO9dj-UzxyDwYJDRjp5pYkmwX9gyIYdLm0qtKqEELM,2418
|
|
24
|
+
firewall_sdk/trace.py,sha256=t7QRwk7_K9gpQOOfJvpOt3isj-gDC5QMuM7UFIKYFTI,2423
|
|
25
|
+
firewall_sdk/translate_guard.py,sha256=FAL9w14ljrSU9rLqcMQW3uM5Th7tFz_Zl_HTcTTSueQ,6282
|
|
26
|
+
agenthacker-0.1.0.dist-info/METADATA,sha256=EXQlvGW75SkSYOlu5BaAzvDcWhr3SIPZqZ5EhVxMX2g,15900
|
|
27
|
+
agenthacker-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
28
|
+
agenthacker-0.1.0.dist-info/licenses/LICENSE,sha256=hOg0unn_rzKs2FShnQHnTPGKyiEJElgQX3KRA4pcs_k,11340
|
|
29
|
+
agenthacker-0.1.0.dist-info/licenses/NOTICE,sha256=VIp4Lu-140dbItJGXcdnSA_m5idV3IPw3_zWczK0nQA,160
|
|
30
|
+
agenthacker-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 AgentHacker
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|