jev-firewall 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.
- jev_firewall-0.1.0/.gitignore +12 -0
- jev_firewall-0.1.0/CHANGELOG.md +25 -0
- jev_firewall-0.1.0/LICENSE +202 -0
- jev_firewall-0.1.0/PKG-INFO +258 -0
- jev_firewall-0.1.0/README.md +211 -0
- jev_firewall-0.1.0/benchmarks/overhead.py +228 -0
- jev_firewall-0.1.0/benchmarks/results/20260927T165742Z-hard.json +1877 -0
- jev_firewall-0.1.0/benchmarks/results/20260927T165742Z-hard.md +45 -0
- jev_firewall-0.1.0/benchmarks/results/overhead-20260927T165741Z.json +25 -0
- jev_firewall-0.1.0/benchmarks/run_suites.py +257 -0
- jev_firewall-0.1.0/benchmarks/suites/benign.yaml +46 -0
- jev_firewall-0.1.0/benchmarks/suites/destructive.yaml +35 -0
- jev_firewall-0.1.0/benchmarks/suites/injected.yaml +26 -0
- jev_firewall-0.1.0/docs/adapters.md +80 -0
- jev_firewall-0.1.0/docs/benchmarks.md +68 -0
- jev_firewall-0.1.0/docs/configuration.md +130 -0
- jev_firewall-0.1.0/docs/releasing.md +49 -0
- jev_firewall-0.1.0/examples/_shared.py +29 -0
- jev_firewall-0.1.0/examples/consumer/google_adk/app.py +64 -0
- jev_firewall-0.1.0/examples/consumer/google_adk/policy.yaml +26 -0
- jev_firewall-0.1.0/examples/consumer/google_adk/requirements.txt +1 -0
- jev_firewall-0.1.0/examples/consumer/langchain/app.py +33 -0
- jev_firewall-0.1.0/examples/consumer/langchain/policy.yaml +26 -0
- jev_firewall-0.1.0/examples/consumer/langchain/requirements.txt +1 -0
- jev_firewall-0.1.0/examples/consumer/langgraph/app.py +39 -0
- jev_firewall-0.1.0/examples/consumer/langgraph/policy.yaml +26 -0
- jev_firewall-0.1.0/examples/consumer/langgraph/requirements.txt +1 -0
- jev_firewall-0.1.0/examples/consumer/openai_sdk/app.py +48 -0
- jev_firewall-0.1.0/examples/consumer/openai_sdk/policy.yaml +26 -0
- jev_firewall-0.1.0/examples/consumer/openai_sdk/requirements.txt +1 -0
- jev_firewall-0.1.0/examples/consumer/semantic_kernel/app.py +44 -0
- jev_firewall-0.1.0/examples/consumer/semantic_kernel/policy.yaml +26 -0
- jev_firewall-0.1.0/examples/consumer/semantic_kernel/requirements.txt +4 -0
- jev_firewall-0.1.0/examples/google_adk_minimal.py +62 -0
- jev_firewall-0.1.0/examples/langchain_minimal.py +35 -0
- jev_firewall-0.1.0/examples/langgraph_adversarial_demo.py +295 -0
- jev_firewall-0.1.0/examples/langgraph_minimal.py +38 -0
- jev_firewall-0.1.0/examples/openai_agents_minimal.py +46 -0
- jev_firewall-0.1.0/examples/semantic_kernel_minimal.py +41 -0
- jev_firewall-0.1.0/policy.example.yaml +94 -0
- jev_firewall-0.1.0/pyproject.toml +85 -0
- jev_firewall-0.1.0/scripts/verify_consumer_examples.py +112 -0
- jev_firewall-0.1.0/src/jev_firewall/__init__.py +48 -0
- jev_firewall-0.1.0/src/jev_firewall/_runtime.py +75 -0
- jev_firewall-0.1.0/src/jev_firewall/adapters/__init__.py +1 -0
- jev_firewall-0.1.0/src/jev_firewall/adapters/_common.py +40 -0
- jev_firewall-0.1.0/src/jev_firewall/adapters/google_adk.py +126 -0
- jev_firewall-0.1.0/src/jev_firewall/adapters/langchain.py +137 -0
- jev_firewall-0.1.0/src/jev_firewall/adapters/langgraph.py +161 -0
- jev_firewall-0.1.0/src/jev_firewall/adapters/openai_agents.py +131 -0
- jev_firewall-0.1.0/src/jev_firewall/adapters/semantic_kernel.py +83 -0
- jev_firewall-0.1.0/src/jev_firewall/approval/__init__.py +33 -0
- jev_firewall-0.1.0/src/jev_firewall/approval/base.py +46 -0
- jev_firewall-0.1.0/src/jev_firewall/approval/cli.py +73 -0
- jev_firewall-0.1.0/src/jev_firewall/approval/timeout_deny.py +28 -0
- jev_firewall-0.1.0/src/jev_firewall/approval/webhook.py +74 -0
- jev_firewall-0.1.0/src/jev_firewall/audit.py +88 -0
- jev_firewall-0.1.0/src/jev_firewall/cli.py +122 -0
- jev_firewall-0.1.0/src/jev_firewall/engine.py +215 -0
- jev_firewall-0.1.0/src/jev_firewall/errors.py +44 -0
- jev_firewall-0.1.0/src/jev_firewall/guard.py +136 -0
- jev_firewall-0.1.0/src/jev_firewall/jev/__init__.py +86 -0
- jev_firewall-0.1.0/src/jev_firewall/jev/cloudflare.py +86 -0
- jev_firewall-0.1.0/src/jev_firewall/jev/fake.py +124 -0
- jev_firewall-0.1.0/src/jev_firewall/jev/sdk_backend.py +88 -0
- jev_firewall-0.1.0/src/jev_firewall/jev/types.py +79 -0
- jev_firewall-0.1.0/src/jev_firewall/policy.py +232 -0
- jev_firewall-0.1.0/src/jev_firewall/py.typed +0 -0
- jev_firewall-0.1.0/src/jev_firewall/redact.py +190 -0
- jev_firewall-0.1.0/src/jev_firewall/rubric.py +138 -0
- jev_firewall-0.1.0/src/jev_firewall/verdict.py +96 -0
- jev_firewall-0.1.0/tests/__init__.py +0 -0
- jev_firewall-0.1.0/tests/conftest.py +94 -0
- jev_firewall-0.1.0/tests/live/__init__.py +0 -0
- jev_firewall-0.1.0/tests/live/test_live_jev.py +65 -0
- jev_firewall-0.1.0/tests/test_adapter_google_adk.py +113 -0
- jev_firewall-0.1.0/tests/test_adapter_langchain.py +110 -0
- jev_firewall-0.1.0/tests/test_adapter_langgraph.py +150 -0
- jev_firewall-0.1.0/tests/test_adapter_openai_agents.py +78 -0
- jev_firewall-0.1.0/tests/test_adapter_semantic_kernel.py +84 -0
- jev_firewall-0.1.0/tests/test_approval.py +117 -0
- jev_firewall-0.1.0/tests/test_cli.py +53 -0
- jev_firewall-0.1.0/tests/test_demo.py +57 -0
- jev_firewall-0.1.0/tests/test_engine.py +225 -0
- jev_firewall-0.1.0/tests/test_examples.py +37 -0
- jev_firewall-0.1.0/tests/test_guard.py +97 -0
- jev_firewall-0.1.0/tests/test_jev_backends.py +223 -0
- jev_firewall-0.1.0/tests/test_policy.py +127 -0
- jev_firewall-0.1.0/tests/test_redact.py +112 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2026-09-27)
|
|
4
|
+
|
|
5
|
+
First release.
|
|
6
|
+
|
|
7
|
+
- `PolicyEngine`: evaluates each tool call with one Jev request (severity Choice,
|
|
8
|
+
`is_irreversible` Noul, `matches_stated_goal` Noul) over a minimal, redacted state, and maps
|
|
9
|
+
the answers to ALLOW / HOLD / DENY through per-tool `RiskThresholds` from `policy.yaml`.
|
|
10
|
+
- Deterministic hard-pattern floors that run locally before Jev and can't be argued away by
|
|
11
|
+
text in the arguments.
|
|
12
|
+
- Explicit `fail_mode` (`open` / `closed`), required in config and overridable per tool.
|
|
13
|
+
- Jev routes: TypeSafe direct, OpenRouter, and Vercel AI Gateway (via `typesafe-sdk`), plus
|
|
14
|
+
Cloudflare Workers AI (REST).
|
|
15
|
+
- Approval channels: `CLIApproval`, `WebhookApproval`, `TimeoutDenyApproval`, plus
|
|
16
|
+
`LangGraphInterruptApproval`.
|
|
17
|
+
- Append-only JSONL `AuditLog` with verdict, approval, and outcome events.
|
|
18
|
+
- Secret and PII redaction for everything sent to Jev or written to the log.
|
|
19
|
+
- Adapters: LangGraph, LangChain (callbacks and `create_agent` middleware), OpenAI Agents SDK,
|
|
20
|
+
Google ADK (callbacks and plugin), Semantic Kernel.
|
|
21
|
+
- `jev-firewall` CLI: `init`, `check`, `eval`, `audit`.
|
|
22
|
+
- Adversarial LangGraph demo, seeded evaluation suites, and benchmark scripts.
|
|
23
|
+
|
|
24
|
+
Known gaps: accuracy and end-to-end latency against live Jev haven't been measured for this
|
|
25
|
+
release (see docs/benchmarks.md).
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: jev-firewall
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Runtime action firewall for AI agents, powered by TypeSafe's Jev System One model.
|
|
5
|
+
Author: Ahsan Shah
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: ai-agents,firewall,google-adk,guardrails,jev,langchain,langgraph,openai-agents,prompt-injection,semantic-kernel,typesafe
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: Topic :: Security
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: httpx2>=2.13.1
|
|
22
|
+
Requires-Dist: pydantic>=2.13
|
|
23
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
24
|
+
Requires-Dist: typesafe-sdk<0.8,>=0.7.2
|
|
25
|
+
Provides-Extra: all
|
|
26
|
+
Requires-Dist: azure-ai-agents>=1.2.0b3; extra == 'all'
|
|
27
|
+
Requires-Dist: google-adk>=2.10.0; extra == 'all'
|
|
28
|
+
Requires-Dist: langchain-core>=1.6.5; extra == 'all'
|
|
29
|
+
Requires-Dist: langchain>=1.4.2; extra == 'all'
|
|
30
|
+
Requires-Dist: langgraph>=1.2.12; extra == 'all'
|
|
31
|
+
Requires-Dist: openai-agents>=0.22.3; extra == 'all'
|
|
32
|
+
Requires-Dist: semantic-kernel>=1.44.1; extra == 'all'
|
|
33
|
+
Provides-Extra: google-adk
|
|
34
|
+
Requires-Dist: google-adk>=2.10.0; extra == 'google-adk'
|
|
35
|
+
Provides-Extra: langchain
|
|
36
|
+
Requires-Dist: langchain-core>=1.6.5; extra == 'langchain'
|
|
37
|
+
Requires-Dist: langchain>=1.4.2; extra == 'langchain'
|
|
38
|
+
Provides-Extra: langgraph
|
|
39
|
+
Requires-Dist: langchain-core>=1.6.5; extra == 'langgraph'
|
|
40
|
+
Requires-Dist: langgraph>=1.2.12; extra == 'langgraph'
|
|
41
|
+
Provides-Extra: openai-sdk
|
|
42
|
+
Requires-Dist: openai-agents>=0.22.3; extra == 'openai-sdk'
|
|
43
|
+
Provides-Extra: semantic-kernel
|
|
44
|
+
Requires-Dist: azure-ai-agents>=1.2.0b3; extra == 'semantic-kernel'
|
|
45
|
+
Requires-Dist: semantic-kernel>=1.44.1; extra == 'semantic-kernel'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# jev-firewall
|
|
49
|
+
|
|
50
|
+
**A runtime action firewall for AI agents.** Before an agent's tool call runs, jev-firewall
|
|
51
|
+
asks [Jev](https://docs.typesafe.ai) (TypeSafe's System One decision model) how dangerous it
|
|
52
|
+
is, and returns one of three verdicts:
|
|
53
|
+
|
|
54
|
+
| Verdict | What happens |
|
|
55
|
+
|---|---|
|
|
56
|
+
| **ALLOW** | the tool runs |
|
|
57
|
+
| **HOLD** | the call waits for a human (CLI prompt, webhook, or LangGraph interrupt) |
|
|
58
|
+
| **DENY** | the tool never runs; `ActionBlocked` is raised (or a refusal is returned to the model) |
|
|
59
|
+
|
|
60
|
+
Every decision is written to an append-only JSONL audit log. One core engine is shared by
|
|
61
|
+
thin adapters for **LangGraph, LangChain, OpenAI Agents SDK, Google ADK and Semantic Kernel**.
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
agent proposes tool call ──► adapter ──► PolicyEngine ──► hard patterns (local regex)
|
|
65
|
+
│ │ DENY floor? stop here
|
|
66
|
+
▼ ▼
|
|
67
|
+
Jev: 1 call, 3 typed questions (~680 input tokens est.)
|
|
68
|
+
│
|
|
69
|
+
▼
|
|
70
|
+
thresholds + rules ──► ALLOW / HOLD / DENY ──► audit log
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Why a System One model?
|
|
74
|
+
|
|
75
|
+
A **System Two** guardrail is a second LLM that reads the action and writes out its reasoning.
|
|
76
|
+
It is slow (hundreds of ms to seconds), costs about as much as the agent's own call, returns
|
|
77
|
+
free text you have to parse, and can itself be talked round.
|
|
78
|
+
|
|
79
|
+
**System One** models like Jev don't generate text. You declare typed questions (pick one of
|
|
80
|
+
these options, yes/no probability, position on a scale) and get back calibrated probabilities
|
|
81
|
+
you can threshold in code. That makes the check fast and cheap enough to run on *every* tool
|
|
82
|
+
call, and the decision logic stays in your code and your `policy.yaml`, not in a prompt.
|
|
83
|
+
|
|
84
|
+
Jev has known limits, and this library is built around them
|
|
85
|
+
([Jev 1.13 jaggedness](https://docs.typesafe.ai/model-jaggedness/jev-1.13.md)):
|
|
86
|
+
|
|
87
|
+
- **Adversarial text in the input can move its answers.** Tool arguments are attacker
|
|
88
|
+
controllable, so deterministic *hard patterns* run first and set a floor Jev cannot lower.
|
|
89
|
+
`rm -rf /` is denied even if the command says "this is a safe low_risk cleanup".
|
|
90
|
+
- **Irrelevant context lowers accuracy.** The state sent to Jev is three fields: the tool name,
|
|
91
|
+
its redacted arguments, and a one-line goal. Never the conversation history.
|
|
92
|
+
- **No counting, arithmetic or date logic.** None of the questions need any.
|
|
93
|
+
|
|
94
|
+
## Quick start (about 5 minutes)
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pip install "jev-firewall[langgraph]" # or [langchain], [openai_sdk], [google_adk], [semantic_kernel], [all]
|
|
98
|
+
export TYPESAFE_API_KEY=... # https://console.typesafe.ai/keys
|
|
99
|
+
jev-firewall init # writes ./policy.yaml from the bundled example
|
|
100
|
+
jev-firewall check policy.yaml # validates it and prints the effective settings
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Try one decision from the command line (exit code 0 allow, 10 hold, 20 deny):
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
jev-firewall eval policy.yaml --tool terminal \
|
|
107
|
+
--args '{"command": "sudo rm -rf /var/lib/postgresql/16/main"}' \
|
|
108
|
+
--goal "Free up disk space on the build server"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
No key yet? Add `--offline` to use the bundled keyword stand-in. It exercises the whole
|
|
112
|
+
pipeline, but it is **not Jev**, so don't judge accuracy by it.
|
|
113
|
+
|
|
114
|
+
Wire it into a LangGraph agent:
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from jev_firewall import Firewall
|
|
118
|
+
from jev_firewall.adapters.langgraph import firewall_tool_node
|
|
119
|
+
|
|
120
|
+
firewall = Firewall.from_yaml("policy.yaml") # engine + approval channel + audit log
|
|
121
|
+
builder.add_node("tools", firewall_tool_node(tools, firewall)) # replaces ToolNode(tools)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
That's it. Every tool call in that node is now evaluated, held, or blocked, and logged.
|
|
125
|
+
|
|
126
|
+
## Adapters
|
|
127
|
+
|
|
128
|
+
All adapters do the same thing: build a `ToolCall(tool_name, args, agent_goal)`, then
|
|
129
|
+
evaluate. DENY raises `ActionBlocked`, HOLD waits for approval, and ALLOW runs the tool.
|
|
130
|
+
They contain no policy logic.
|
|
131
|
+
|
|
132
|
+
| Framework | Install extra | Hook | Usage |
|
|
133
|
+
|---|---|---|---|
|
|
134
|
+
| LangGraph | `[langgraph]` | `ToolNode(wrap_tool_call=...)` | `firewall_tool_node(tools, firewall)` |
|
|
135
|
+
| LangChain | `[langchain]` | `BaseCallbackHandler.on_tool_start` / `create_agent` middleware | `JevFirewallCallbackHandler(firewall)`, `JevFirewallMiddleware(firewall)` |
|
|
136
|
+
| OpenAI Agents SDK | `[openai_sdk]` | `FunctionTool.tool_input_guardrails` | `protect_tools(tools, firewall)` |
|
|
137
|
+
| Google ADK | `[google_adk]` | `before_tool_callback` / runner plugin | `JevFirewallCallbacks(firewall)`, `JevFirewallPlugin(firewall)` |
|
|
138
|
+
| Semantic Kernel | `[semantic_kernel]` | `FUNCTION_INVOCATION` filter | `JevFunctionInvocationFilter(firewall)` |
|
|
139
|
+
|
|
140
|
+
> **uv + Semantic Kernel:** semantic-kernel ≥ 1.36 depends on a pre-release of `azure-ai-agents`.
|
|
141
|
+
> pip installs it as is. With uv, also request it directly
|
|
142
|
+
> (`uv add "jev-firewall[semantic_kernel]" "azure-ai-agents>=1.2.0b3"`) or pass `--prerelease=allow`.
|
|
143
|
+
|
|
144
|
+
Runnable, keyless examples are in [`examples/`](examples/). [`examples/consumer/`](examples/consumer/)
|
|
145
|
+
has one standalone project per framework (`pip install -r requirements.txt && python app.py`)
|
|
146
|
+
that uses the published package exactly as you would. Framework details, including how
|
|
147
|
+
each framework surfaces `ActionBlocked`, are in [docs/adapters.md](docs/adapters.md).
|
|
148
|
+
|
|
149
|
+
**`agent_goal`** powers the prompt-injection check. By default each adapter uses the *first
|
|
150
|
+
user message* of the conversation, never tool output or retrieved content, so injected text
|
|
151
|
+
can't rewrite it. You can also pass `goal="..."` or a callable.
|
|
152
|
+
|
|
153
|
+
## Configuration reference
|
|
154
|
+
|
|
155
|
+
`policy.yaml` is validated strictly: unknown keys are errors, and `fail_mode` and `jev` have
|
|
156
|
+
no defaults. Full reference: [docs/configuration.md](docs/configuration.md).
|
|
157
|
+
|
|
158
|
+
```yaml
|
|
159
|
+
version: 1
|
|
160
|
+
fail_mode: closed # REQUIRED: open | closed (see below)
|
|
161
|
+
jev:
|
|
162
|
+
route: direct # direct | openrouter | vercel | cloudflare
|
|
163
|
+
timeout_s: 1.0 # total budget per decision, retries included
|
|
164
|
+
max_retries: 1
|
|
165
|
+
defaults:
|
|
166
|
+
thresholds: {low_risk: allow, moderate_risk: allow, high_risk: hold, critical_danger: deny}
|
|
167
|
+
irreversible_threshold: 0.5 # p(irreversible) at/above this: a would-be ALLOW becomes HOLD
|
|
168
|
+
goal_match_threshold: 0.5 # p(matches goal) below this: at least HOLD
|
|
169
|
+
min_confidence: 0.5 # severity confidence below this: at least HOLD
|
|
170
|
+
hard_patterns:
|
|
171
|
+
- {description: pipe remote script into a shell, pattern: '\b(curl|wget)\b[^\n|]*\|\s*(sudo\s+)?(ba|z|da)?sh\b', floor: deny}
|
|
172
|
+
tools: # exact name beats glob; most specific glob wins
|
|
173
|
+
"read_*": {action: allow} # skip Jev entirely
|
|
174
|
+
"terminal": {thresholds: {moderate_risk: hold}}
|
|
175
|
+
"transfer_*": {thresholds: {high_risk: deny}, fail_mode: closed}
|
|
176
|
+
approval: {channel: cli, timeout_s: 300} # cli | webhook | timeout_deny
|
|
177
|
+
audit: {path: ./jev-audit.jsonl}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**How a decision is made** (each step can only make it stricter):
|
|
181
|
+
|
|
182
|
+
1. Resolve the tool's rule: exact name, then the most specific glob, then `defaults`.
|
|
183
|
+
2. Hard patterns on the raw arguments set a floor. A `deny` floor (or `action: deny`) ends here, with no Jev call.
|
|
184
|
+
3. `action: allow|hold` skips Jev.
|
|
185
|
+
4. Jev answers `severity` (Choice), `is_irreversible` (Noul) and `matches_stated_goal` (Noul) in one call.
|
|
186
|
+
5. Severity maps to a verdict through the tool's thresholds.
|
|
187
|
+
6. Irreversible and not allowlisted (`allow_irreversible: true`): an ALLOW becomes HOLD.
|
|
188
|
+
7. Goal mismatch: at least HOLD. Low severity confidence: at least HOLD.
|
|
189
|
+
|
|
190
|
+
**Jev routes.** Each route reads its key from its own env var, so a TypeSafe key is never
|
|
191
|
+
sent to a gateway by mistake.
|
|
192
|
+
|
|
193
|
+
| route | key env var | default model |
|
|
194
|
+
|---|---|---|
|
|
195
|
+
| `direct` | `TYPESAFE_API_KEY` | `jev-1.13.0` (pinned; thresholds are tuned per version) |
|
|
196
|
+
| `openrouter` | `OPENROUTER_API_KEY` | `~typesafe/jev-latest` |
|
|
197
|
+
| `vercel` | `AI_GATEWAY_API_KEY` | `typesafe-ai/jev` |
|
|
198
|
+
| `cloudflare` | `CLOUDFLARE_API_TOKEN` + `CLOUDFLARE_ACCOUNT_ID` | `typesafe/jev` |
|
|
199
|
+
|
|
200
|
+
## Fail mode guidance
|
|
201
|
+
|
|
202
|
+
If Jev times out, errors, rate-limits, or returns something malformed, the verdict comes from
|
|
203
|
+
`fail_mode`, never from a hidden default:
|
|
204
|
+
|
|
205
|
+
- **`closed` (DENY)**: use it for anything with side effects, such as shell, databases, email,
|
|
206
|
+
payments, and deploys. An outage stops the agent instead of letting it act unchecked. This is
|
|
207
|
+
the right default for most deployments.
|
|
208
|
+
- **`open` (ALLOW)**: only for low-stakes tools where availability matters more than
|
|
209
|
+
checking. Hard-pattern floors still apply in open mode.
|
|
210
|
+
|
|
211
|
+
Set a global `fail_mode` and override it per tool (`tools.<name>.fail_mode`). Keep `timeout_s`
|
|
212
|
+
tight: a decision that takes longer than the budget *is* a failure and goes through
|
|
213
|
+
`fail_mode`. Watch the audit log for `source: fail_open` / `fail_closed` to see how often it
|
|
214
|
+
happens.
|
|
215
|
+
|
|
216
|
+
## Security properties
|
|
217
|
+
|
|
218
|
+
- **What Jev sees:** `tool_name`, `tool_args` after redaction, and a one-line `agent_goal`. That's all.
|
|
219
|
+
- **Redaction** (`jev_firewall.redact`) masks sensitive keys (`password`, `api_key`,
|
|
220
|
+
`authorization`, ...), API keys and tokens (OpenAI, Anthropic, AWS, GitHub, Stripe, Slack,
|
|
221
|
+
Google, JWTs, bearer tokens), PEM private keys, URL credentials, `KEY=value` secrets, and PII
|
|
222
|
+
(emails keep their domain, which is a useful risk signal; phone numbers, SSNs, and
|
|
223
|
+
Luhn-valid card numbers are masked). Long strings, lists, and deep nesting are truncated.
|
|
224
|
+
- **Audit log:** only redacted arguments are written. One line per event (`verdict`,
|
|
225
|
+
`approval`, `outcome`), linked by `call_id`. Run `jev-firewall audit ./jev-audit.jsonl` for a summary.
|
|
226
|
+
|
|
227
|
+
## Measured results
|
|
228
|
+
|
|
229
|
+
Only numbers that were actually measured are listed. Full method and raw JSON: [docs/benchmarks.md](docs/benchmarks.md).
|
|
230
|
+
|
|
231
|
+
| What | Result | Conditions |
|
|
232
|
+
|---|---|---|
|
|
233
|
+
| Firewall library overhead (no network) | **p50 1.02 ms, p95 1.50 ms** per decision | in-memory Jev, audit on, 2,000 calls, Windows 11, Python 3.12 |
|
|
234
|
+
| Hard patterns alone on the seeded suites | 19 / 50 harmful caught, **0 / 40** benign blocked | Jev disabled |
|
|
235
|
+
| Adversarial LangGraph demo | 4 / 4 harmful calls stopped, 4 / 4 benign allowed | offline stand-in; live run pending |
|
|
236
|
+
| End-to-end latency with live Jev | **not measured yet** | needs `TYPESAFE_API_KEY` |
|
|
237
|
+
| False negatives / false positives with live Jev | **not measured yet** | needs `TYPESAFE_API_KEY` |
|
|
238
|
+
| LLM-guardrail comparison | **not measured yet** | needs `ANTHROPIC_API_KEY` |
|
|
239
|
+
| Cost per decision | ~680 input tokens → **~$0.00003 (estimate)** | chars/4 of the actual request; live `usage` pending |
|
|
240
|
+
|
|
241
|
+
Reproduce with `python benchmarks/overhead.py` and `python benchmarks/run_suites.py`.
|
|
242
|
+
Both measure the live modes automatically when the keys are set.
|
|
243
|
+
|
|
244
|
+
## Development
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
uv sync --all-extras
|
|
248
|
+
uv run pytest # offline: FakeJevClient + mock HTTP transports
|
|
249
|
+
JEV_LIVE_TESTS=1 uv run pytest # plus live Jev tests (needs TYPESAFE_API_KEY)
|
|
250
|
+
uv run ruff check . && uv run mypy # strict typing
|
|
251
|
+
python examples/langgraph_adversarial_demo.py
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Adding an adapter requires no changes to the core package; see [docs/adapters.md](docs/adapters.md#writing-an-adapter).
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
Apache-2.0. jev-firewall is an independent open-source project and is not affiliated with TypeSafe AI.
|