verity-guard 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VerityLayer / PC Brain LLC
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,170 @@
1
+ Metadata-Version: 2.4
2
+ Name: verity-guard
3
+ Version: 0.1.0
4
+ Summary: Fail-closed verify-before-you-act gate for AI agents. One-line adapters for LangChain, LangGraph, CrewAI, and the OpenAI Agents SDK. Signed receipts, pay-per-call via x402.
5
+ Project-URL: Homepage, https://veritylayer.dev
6
+ Project-URL: Wire-in guide, https://veritylayer.dev/guard
7
+ Project-URL: Source, https://github.com/meloliva14/verity-guard
8
+ Author: VerityLayer
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: agent-commerce,agents,ai,ai-safety,crewai,fact-check,fail-closed,guardrail,langchain,langgraph,openai-agents,prompt-injection,signed-receipts,trust,verification,x402
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Security
18
+ Requires-Python: >=3.9
19
+ Requires-Dist: httpx>=0.24
20
+ Provides-Extra: all
21
+ Requires-Dist: crewai>=0.60; extra == 'all'
22
+ Requires-Dist: langchain-core>=0.2; extra == 'all'
23
+ Requires-Dist: langgraph>=0.2; extra == 'all'
24
+ Requires-Dist: openai-agents>=0.0.1; extra == 'all'
25
+ Provides-Extra: crewai
26
+ Requires-Dist: crewai>=0.60; extra == 'crewai'
27
+ Provides-Extra: langchain
28
+ Requires-Dist: langchain-core>=0.2; extra == 'langchain'
29
+ Provides-Extra: langgraph
30
+ Requires-Dist: langgraph>=0.2; extra == 'langgraph'
31
+ Provides-Extra: openai-agents
32
+ Requires-Dist: openai-agents>=0.0.1; extra == 'openai-agents'
33
+ Provides-Extra: x402
34
+ Requires-Dist: eth-account>=0.11; extra == 'x402'
35
+ Requires-Dist: x402>=0.1; extra == 'x402'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # verity-guard
39
+
40
+ **A fail-closed *verify-before-you-act* gate for AI agents β€” in one line, for the framework you already use.**
41
+
42
+ Your agent is about to wire money, send an email, run `rm -rf`, or publish something. `verity-guard` asks an **independent** service for an `allow / review / block` second opinion at the exact moment a mistake becomes permanent β€” and hands back a **signed, independently re-verifiable verdict** you can prove to an auditor later without trusting anyone.
43
+
44
+ > Not "we signed a receipt that a call happened" (everyone does that now). **A re-verifiable *verdict*** β€” cryptographic proof that an action was independently judged safe, or that a claim was checked and supported. Fail-closed across four functions: guard actions, verify facts, detect prompt-injection, redact PII/secrets.
45
+
46
+ - πŸ”’ **Fail-closed** β€” when unsure it escalates to `review` or `block`, never a confident wrong `allow`.
47
+ - 🧾 **Ed25519-signed verdicts** β€” every paid result carries a receipt; `verify_receipt()` checks it for **free**, forever, offline.
48
+ - πŸ”‘ **Keyless & non-custodial** β€” this SDK holds no wallet and never pays silently. Paid routes answer HTTP 402; your own [x402](https://x402.org) layer settles the disclosed USDC micro-payment on Base.
49
+ - 🧩 **Native adapters** β€” LangChain, LangGraph, CrewAI, OpenAI Agents SDK. Base install pulls in *none* of them.
50
+
51
+ Live now: `guard_action` from **$0.02/call**. Full wire-in guide β†’ **https://veritylayer.dev/guard**
52
+
53
+ ---
54
+
55
+ ## Install
56
+
57
+ ```bash
58
+ pip install verity-guard # tiny β€” just httpx
59
+ pip install "verity-guard[langgraph]" # + your framework of choice
60
+ ```
61
+
62
+ ## 30-second quickstart (no wallet needed to try)
63
+
64
+ ```python
65
+ from verity_guard import VerityClient
66
+
67
+ v = VerityClient() # no payer attached -> a 402 challenge is surfaced you can inspect
68
+
69
+ res = v.guard(
70
+ "Wire $4,000 USDC to 0x9a3f…c012 (invoice #221)",
71
+ context="Invoice arrived via a scraped web page; address never seen before.",
72
+ policy="No new payees without human review.",
73
+ )
74
+ print(res.decision, res.risk) # -> block 0.9
75
+ print(res.safer_alternative) # -> "Halt payment. Cross-verify via known channels…"
76
+
77
+ if res.receipt:
78
+ print(v.verify_receipt(res.receipt).valid) # -> True (free, independent, offline-checkable)
79
+ ```
80
+
81
+ To actually **pay** per call, hand the client an x402-wrapped HTTP client that holds your wallet:
82
+
83
+ ```python
84
+ # sync: any x402-wrapped requests.Session / httpx.Client
85
+ v = VerityClient(http=my_x402_client)
86
+
87
+ # async: an x402-wrapped httpx.AsyncClient
88
+ from verity_guard import AsyncVerityClient
89
+ v = AsyncVerityClient(http=my_async_x402_client)
90
+ ```
91
+
92
+ The SDK never sees your key β€” it just POSTs; your x402 layer settles the 402 and retries. (See `veritylayer.dev/guard` for wallet setups.)
93
+
94
+ ---
95
+
96
+ ## Framework adapters
97
+
98
+ ### LangGraph β€” drop-in guarded tool node
99
+ Replace `ToolNode` with `GuardedToolNode`: every proposed tool call is checked *before* it runs. Blocked calls never execute β€” the model gets the block reason + safer alternative and revises.
100
+
101
+ ```python
102
+ from verity_guard import VerityClient
103
+ from verity_guard.integrations.langgraph import GuardedToolNode
104
+
105
+ tools = [wire_funds, send_email, search_web]
106
+ guarded = GuardedToolNode(tools, VerityClient(http=my_x402_client),
107
+ policy="No new payees without human review.")
108
+ graph.add_node("tools", guarded) # instead of ToolNode(tools)
109
+ ```
110
+
111
+ ### OpenAI Agents SDK β€” per-tool-call guardrail (highest-frequency wire-in)
112
+ ```python
113
+ from verity_guard import VerityClient
114
+ from verity_guard.integrations.openai_agents import (
115
+ build_guard_tool, build_output_guardrail, build_tool_input_guardrail,
116
+ )
117
+ v = VerityClient()
118
+
119
+ # (a) give the agent a guard tool it can call
120
+ agent = Agent(name="Treasurer", tools=[build_guard_tool(v)])
121
+
122
+ # (b) verify the final answer before it leaves
123
+ agent = Agent(..., output_guardrails=[build_output_guardrail(v, mode="guard",
124
+ policy="No new payees without human review.")])
125
+
126
+ # (c) guard the arguments of EVERY tool call (newer SDKs)
127
+ wire_funds.tool_input_guardrails = [build_tool_input_guardrail(v)]
128
+ ```
129
+
130
+ ### LangChain β€” a guard tool, or gate any function
131
+ ```python
132
+ from verity_guard import VerityClient, guard
133
+ from verity_guard.integrations.langchain import build_guard_tool
134
+
135
+ v = VerityClient(http=my_x402_client)
136
+ tools = [..., build_guard_tool(v)] # explicit tool the agent can call
137
+
138
+ @guard(v, policy="No new payees without human review.") # or gate a function directly
139
+ def wire_funds(to: str, amount: float): ... # raises BlockedAction if VerityLayer blocks
140
+ ```
141
+
142
+ ### CrewAI
143
+ ```python
144
+ from verity_guard import VerityClient
145
+ from verity_guard.integrations.crewai import build_guard_tool
146
+
147
+ guard_tool = build_guard_tool(VerityClient(http=my_x402_client),
148
+ default_policy="No new payees without human review.")
149
+ agent = Agent(role="Treasurer", tools=[guard_tool])
150
+ ```
151
+
152
+ ---
153
+
154
+ ## The checks
155
+
156
+ | Method | What it answers | Route (tier `quick`) | From |
157
+ |---|---|---|---|
158
+ | `guard(action, …)` | Should this action proceed? `allow / review / block` | suite `/check/quick` | $0.02 |
159
+ | `verify(claim, …)` | Is this claim true? `supported / unsupported / uncertain` | engine `/verify` (grounded) | $0.02–$0.35 |
160
+ | `detect_injection(content, …)` | Is this untrusted text a prompt-injection? | suite `/sentinel/quick` | $0.02 |
161
+ | `moderate(content, …)` | Safe to publish? `publish / review / block` | suite `/sieve/quick` | $0.02 |
162
+ | `redact(payload, …)` | Any PII/secrets? returns a redacted copy | suite `/redact/quick` | $0.02 |
163
+ | `verify_receipt(receipt)` | Is this signed verdict authentic? | engine `/receipt/verify` | **free** |
164
+
165
+ Every result is a `VerityResult` (a `dict` subclass β€” future fields never get dropped) with helpers: `.decision`, `.risk`, `.allowed`, `.blocked`, `.flagged`, `.reasons`, `.safer_alternative`, `.receipt`, `.price`, `.payment_required`.
166
+
167
+ ## Doctrine
168
+ Fail-closed (uncertainty β†’ the safe verdict, never a confident wrong one) Β· evidence is never invented Β· `allow`/`review`/`block` are **priced identically** (no block-to-bill) Β· pricing is disclosed and paid per use via x402 Β· VerityLayer holds no key and never charges silently.
169
+
170
+ MIT Β· [veritylayer.dev](https://veritylayer.dev) Β· [wire-in guide](https://veritylayer.dev/guard)
@@ -0,0 +1,133 @@
1
+ # verity-guard
2
+
3
+ **A fail-closed *verify-before-you-act* gate for AI agents β€” in one line, for the framework you already use.**
4
+
5
+ Your agent is about to wire money, send an email, run `rm -rf`, or publish something. `verity-guard` asks an **independent** service for an `allow / review / block` second opinion at the exact moment a mistake becomes permanent β€” and hands back a **signed, independently re-verifiable verdict** you can prove to an auditor later without trusting anyone.
6
+
7
+ > Not "we signed a receipt that a call happened" (everyone does that now). **A re-verifiable *verdict*** β€” cryptographic proof that an action was independently judged safe, or that a claim was checked and supported. Fail-closed across four functions: guard actions, verify facts, detect prompt-injection, redact PII/secrets.
8
+
9
+ - πŸ”’ **Fail-closed** β€” when unsure it escalates to `review` or `block`, never a confident wrong `allow`.
10
+ - 🧾 **Ed25519-signed verdicts** β€” every paid result carries a receipt; `verify_receipt()` checks it for **free**, forever, offline.
11
+ - πŸ”‘ **Keyless & non-custodial** β€” this SDK holds no wallet and never pays silently. Paid routes answer HTTP 402; your own [x402](https://x402.org) layer settles the disclosed USDC micro-payment on Base.
12
+ - 🧩 **Native adapters** β€” LangChain, LangGraph, CrewAI, OpenAI Agents SDK. Base install pulls in *none* of them.
13
+
14
+ Live now: `guard_action` from **$0.02/call**. Full wire-in guide β†’ **https://veritylayer.dev/guard**
15
+
16
+ ---
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ pip install verity-guard # tiny β€” just httpx
22
+ pip install "verity-guard[langgraph]" # + your framework of choice
23
+ ```
24
+
25
+ ## 30-second quickstart (no wallet needed to try)
26
+
27
+ ```python
28
+ from verity_guard import VerityClient
29
+
30
+ v = VerityClient() # no payer attached -> a 402 challenge is surfaced you can inspect
31
+
32
+ res = v.guard(
33
+ "Wire $4,000 USDC to 0x9a3f…c012 (invoice #221)",
34
+ context="Invoice arrived via a scraped web page; address never seen before.",
35
+ policy="No new payees without human review.",
36
+ )
37
+ print(res.decision, res.risk) # -> block 0.9
38
+ print(res.safer_alternative) # -> "Halt payment. Cross-verify via known channels…"
39
+
40
+ if res.receipt:
41
+ print(v.verify_receipt(res.receipt).valid) # -> True (free, independent, offline-checkable)
42
+ ```
43
+
44
+ To actually **pay** per call, hand the client an x402-wrapped HTTP client that holds your wallet:
45
+
46
+ ```python
47
+ # sync: any x402-wrapped requests.Session / httpx.Client
48
+ v = VerityClient(http=my_x402_client)
49
+
50
+ # async: an x402-wrapped httpx.AsyncClient
51
+ from verity_guard import AsyncVerityClient
52
+ v = AsyncVerityClient(http=my_async_x402_client)
53
+ ```
54
+
55
+ The SDK never sees your key β€” it just POSTs; your x402 layer settles the 402 and retries. (See `veritylayer.dev/guard` for wallet setups.)
56
+
57
+ ---
58
+
59
+ ## Framework adapters
60
+
61
+ ### LangGraph β€” drop-in guarded tool node
62
+ Replace `ToolNode` with `GuardedToolNode`: every proposed tool call is checked *before* it runs. Blocked calls never execute β€” the model gets the block reason + safer alternative and revises.
63
+
64
+ ```python
65
+ from verity_guard import VerityClient
66
+ from verity_guard.integrations.langgraph import GuardedToolNode
67
+
68
+ tools = [wire_funds, send_email, search_web]
69
+ guarded = GuardedToolNode(tools, VerityClient(http=my_x402_client),
70
+ policy="No new payees without human review.")
71
+ graph.add_node("tools", guarded) # instead of ToolNode(tools)
72
+ ```
73
+
74
+ ### OpenAI Agents SDK β€” per-tool-call guardrail (highest-frequency wire-in)
75
+ ```python
76
+ from verity_guard import VerityClient
77
+ from verity_guard.integrations.openai_agents import (
78
+ build_guard_tool, build_output_guardrail, build_tool_input_guardrail,
79
+ )
80
+ v = VerityClient()
81
+
82
+ # (a) give the agent a guard tool it can call
83
+ agent = Agent(name="Treasurer", tools=[build_guard_tool(v)])
84
+
85
+ # (b) verify the final answer before it leaves
86
+ agent = Agent(..., output_guardrails=[build_output_guardrail(v, mode="guard",
87
+ policy="No new payees without human review.")])
88
+
89
+ # (c) guard the arguments of EVERY tool call (newer SDKs)
90
+ wire_funds.tool_input_guardrails = [build_tool_input_guardrail(v)]
91
+ ```
92
+
93
+ ### LangChain β€” a guard tool, or gate any function
94
+ ```python
95
+ from verity_guard import VerityClient, guard
96
+ from verity_guard.integrations.langchain import build_guard_tool
97
+
98
+ v = VerityClient(http=my_x402_client)
99
+ tools = [..., build_guard_tool(v)] # explicit tool the agent can call
100
+
101
+ @guard(v, policy="No new payees without human review.") # or gate a function directly
102
+ def wire_funds(to: str, amount: float): ... # raises BlockedAction if VerityLayer blocks
103
+ ```
104
+
105
+ ### CrewAI
106
+ ```python
107
+ from verity_guard import VerityClient
108
+ from verity_guard.integrations.crewai import build_guard_tool
109
+
110
+ guard_tool = build_guard_tool(VerityClient(http=my_x402_client),
111
+ default_policy="No new payees without human review.")
112
+ agent = Agent(role="Treasurer", tools=[guard_tool])
113
+ ```
114
+
115
+ ---
116
+
117
+ ## The checks
118
+
119
+ | Method | What it answers | Route (tier `quick`) | From |
120
+ |---|---|---|---|
121
+ | `guard(action, …)` | Should this action proceed? `allow / review / block` | suite `/check/quick` | $0.02 |
122
+ | `verify(claim, …)` | Is this claim true? `supported / unsupported / uncertain` | engine `/verify` (grounded) | $0.02–$0.35 |
123
+ | `detect_injection(content, …)` | Is this untrusted text a prompt-injection? | suite `/sentinel/quick` | $0.02 |
124
+ | `moderate(content, …)` | Safe to publish? `publish / review / block` | suite `/sieve/quick` | $0.02 |
125
+ | `redact(payload, …)` | Any PII/secrets? returns a redacted copy | suite `/redact/quick` | $0.02 |
126
+ | `verify_receipt(receipt)` | Is this signed verdict authentic? | engine `/receipt/verify` | **free** |
127
+
128
+ Every result is a `VerityResult` (a `dict` subclass β€” future fields never get dropped) with helpers: `.decision`, `.risk`, `.allowed`, `.blocked`, `.flagged`, `.reasons`, `.safer_alternative`, `.receipt`, `.price`, `.payment_required`.
129
+
130
+ ## Doctrine
131
+ Fail-closed (uncertainty β†’ the safe verdict, never a confident wrong one) Β· evidence is never invented Β· `allow`/`review`/`block` are **priced identically** (no block-to-bill) Β· pricing is disclosed and paid per use via x402 Β· VerityLayer holds no key and never charges silently.
132
+
133
+ MIT Β· [veritylayer.dev](https://veritylayer.dev) Β· [wire-in guide](https://veritylayer.dev/guard)
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "verity-guard"
7
+ version = "0.1.0"
8
+ description = "Fail-closed verify-before-you-act gate for AI agents. One-line adapters for LangChain, LangGraph, CrewAI, and the OpenAI Agents SDK. Signed receipts, pay-per-call via x402."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "VerityLayer" }]
13
+ keywords = [
14
+ "ai", "agents", "guardrail", "verification", "fact-check", "prompt-injection",
15
+ "ai-safety", "x402", "agent-commerce", "langchain", "langgraph", "crewai",
16
+ "openai-agents", "signed-receipts", "trust", "fail-closed",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 4 - Beta",
20
+ "Intended Audience :: Developers",
21
+ "License :: OSI Approved :: MIT License",
22
+ "Programming Language :: Python :: 3",
23
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
24
+ "Topic :: Security",
25
+ ]
26
+ dependencies = ["httpx>=0.24"]
27
+
28
+ [project.urls]
29
+ Homepage = "https://veritylayer.dev"
30
+ "Wire-in guide" = "https://veritylayer.dev/guard"
31
+ Source = "https://github.com/meloliva14/verity-guard"
32
+
33
+ [project.optional-dependencies]
34
+ # Bring-your-own framework β€” adapters lazy-import these, so the base install stays tiny.
35
+ langchain = ["langchain-core>=0.2"]
36
+ langgraph = ["langgraph>=0.2"]
37
+ crewai = ["crewai>=0.60"]
38
+ openai-agents = ["openai-agents>=0.0.1"]
39
+ # Convenience x402 payer (BYO wallet key). You can also pass any x402-wrapped client.
40
+ x402 = ["x402>=0.1", "eth-account>=0.11"]
41
+ all = ["langchain-core>=0.2", "langgraph>=0.2", "crewai>=0.60", "openai-agents>=0.0.1"]
42
+
43
+ [tool.hatch.build.targets.wheel]
44
+ packages = ["src/verity_guard"]
@@ -0,0 +1,44 @@
1
+ """verity-guard β€” a fail-closed verify-before-you-act gate for AI agents.
2
+
3
+ Quick start (no wallet needed to try β€” a 402 is surfaced you can inspect):
4
+
5
+ from verity_guard import VerityClient
6
+ v = VerityClient() # pass an x402-wrapped client to auto-pay
7
+ res = v.guard("Wire $4,000 to 0x9a3f… (invoice #221)",
8
+ policy="No new payees without human review.")
9
+ print(res.decision, res.risk) # e.g. block 0.9
10
+ if res.receipt:
11
+ print(v.verify_receipt(res.receipt).valid) # True β€” free, independent
12
+
13
+ Framework adapters (lazy-imported):
14
+
15
+ from verity_guard.integrations import langchain, langgraph, crewai, openai_agents
16
+ """
17
+ from __future__ import annotations
18
+
19
+ from .client import (
20
+ AsyncVerityClient,
21
+ ENGINE_DEFAULT,
22
+ SUITE_DEFAULT,
23
+ VerityClient,
24
+ VerityError,
25
+ VerityResult,
26
+ )
27
+ from .decorators import BlockedAction, GUARD_TOOL_DESC, aguard, format_verdict, guard
28
+
29
+ __version__ = "0.1.0"
30
+
31
+ __all__ = [
32
+ "VerityClient",
33
+ "AsyncVerityClient",
34
+ "VerityResult",
35
+ "VerityError",
36
+ "BlockedAction",
37
+ "guard",
38
+ "aguard",
39
+ "format_verdict",
40
+ "GUARD_TOOL_DESC",
41
+ "ENGINE_DEFAULT",
42
+ "SUITE_DEFAULT",
43
+ "__version__",
44
+ ]