agentguard-spend 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.
- agentguard_spend-0.1.0/.gitignore +70 -0
- agentguard_spend-0.1.0/LICENSE +87 -0
- agentguard_spend-0.1.0/PATENTS.md +37 -0
- agentguard_spend-0.1.0/PKG-INFO +358 -0
- agentguard_spend-0.1.0/README.md +232 -0
- agentguard_spend-0.1.0/agentguard_spend/__init__.py +141 -0
- agentguard_spend-0.1.0/agentguard_spend/bindings/__init__.py +19 -0
- agentguard_spend-0.1.0/agentguard_spend/bindings/anthropic_binding.py +160 -0
- agentguard_spend-0.1.0/agentguard_spend/bindings/bedrock_binding.py +215 -0
- agentguard_spend-0.1.0/agentguard_spend/bindings/openai_binding.py +223 -0
- agentguard_spend-0.1.0/agentguard_spend/cost_table.py +134 -0
- agentguard_spend-0.1.0/agentguard_spend/decision_log.py +325 -0
- agentguard_spend-0.1.0/agentguard_spend/policy.py +277 -0
- agentguard_spend-0.1.0/agentguard_spend/spend_guard.py +309 -0
- agentguard_spend-0.1.0/agentguard_spend/store_memory.py +93 -0
- agentguard_spend-0.1.0/agentguard_spend/types.py +240 -0
- agentguard_spend-0.1.0/pyproject.toml +81 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
.vercel
|
|
2
|
+
.next/
|
|
3
|
+
node_modules/
|
|
4
|
+
|
|
5
|
+
/generated/prisma
|
|
6
|
+
|
|
7
|
+
# clerk configuration (can include secrets)
|
|
8
|
+
/.clerk/
|
|
9
|
+
|
|
10
|
+
# Environment files (NEVER commit secrets!)
|
|
11
|
+
.env
|
|
12
|
+
.env.local
|
|
13
|
+
.env.*.local
|
|
14
|
+
agent/.env
|
|
15
|
+
*.pem
|
|
16
|
+
|
|
17
|
+
# Hardhat artifacts
|
|
18
|
+
cache/
|
|
19
|
+
artifacts/
|
|
20
|
+
.env*.local
|
|
21
|
+
.env.production
|
|
22
|
+
supabase/.temp/
|
|
23
|
+
|
|
24
|
+
# Git worktrees
|
|
25
|
+
.worktrees/
|
|
26
|
+
|
|
27
|
+
# Sentinela ML model artifacts (large binary files — stored in GCS, not git)
|
|
28
|
+
models/sentinela/l1-xlmr-v1/
|
|
29
|
+
models/sentinela/l2-xgboost-v1/
|
|
30
|
+
models/sentinela/training_data.jsonl
|
|
31
|
+
!models/sentinela/.gitkeep
|
|
32
|
+
*.onnx
|
|
33
|
+
*.ubj
|
|
34
|
+
|
|
35
|
+
# Sentinela L1 Cloud Run -- large artifacts (downloaded in CI, never committed)
|
|
36
|
+
agents/sentinela-l1/models/*.onnx
|
|
37
|
+
agents/sentinela-l1/tokenizer/
|
|
38
|
+
!agents/sentinela-l1/models/.gitkeep
|
|
39
|
+
!agents/sentinela-l1/tokenizer/.gitkeep
|
|
40
|
+
|
|
41
|
+
# Python artifacts
|
|
42
|
+
__pycache__/
|
|
43
|
+
*.egg-info/
|
|
44
|
+
dist/
|
|
45
|
+
|
|
46
|
+
# Playwright MCP cache
|
|
47
|
+
.playwright-mcp/
|
|
48
|
+
|
|
49
|
+
# Vercel check artifacts
|
|
50
|
+
.env.vercel-check
|
|
51
|
+
|
|
52
|
+
# Build/test artifacts
|
|
53
|
+
*.tsbuildinfo
|
|
54
|
+
.turbo/
|
|
55
|
+
|
|
56
|
+
# Debug/log files
|
|
57
|
+
firebase-debug.log
|
|
58
|
+
|
|
59
|
+
# Script output artifacts
|
|
60
|
+
scripts/*.json
|
|
61
|
+
list-all-products.js
|
|
62
|
+
find-starter-product.js
|
|
63
|
+
create-starter-product.js
|
|
64
|
+
test-stripe-key.js
|
|
65
|
+
broadcast/
|
|
66
|
+
.DS_Store
|
|
67
|
+
|
|
68
|
+
# TypeScript build cache (auto-generated)
|
|
69
|
+
tsconfig.tsbuildinfo
|
|
70
|
+
*.tsbuildinfo
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
AgentGuard(TM) Spend SDK — Alpha License
|
|
2
|
+
Copyright (c) 2026 Dunecrest Ventures Inc.
|
|
3
|
+
|
|
4
|
+
1. SCOPE.
|
|
5
|
+
This software, including all files under packages/agentguard-spend-python/agentguard_spend/, is
|
|
6
|
+
licensed by Dunecrest Ventures Inc. ("Licensor") subject to the following
|
|
7
|
+
thresholds:
|
|
8
|
+
|
|
9
|
+
(a) Evaluation Use. Internal evaluation, prototyping, and non-commercial
|
|
10
|
+
development at any call volume.
|
|
11
|
+
|
|
12
|
+
(b) Free Production Threshold. Production deployments processing 10,000
|
|
13
|
+
or fewer enforcement calls per calendar month, in aggregate across
|
|
14
|
+
all instances operated by the licensee, are permitted under this
|
|
15
|
+
License without additional fee.
|
|
16
|
+
|
|
17
|
+
(c) Commercial License Required. Production deployments processing more
|
|
18
|
+
than 10,000 enforcement calls per calendar month, deployments
|
|
19
|
+
operated for the benefit of third parties as a service, redistribution,
|
|
20
|
+
sublicensing, public hosting, and republication each require a
|
|
21
|
+
separate commercial license agreement with Licensor.
|
|
22
|
+
|
|
23
|
+
Commercial-license inquiries: invest@agentguard.run
|
|
24
|
+
|
|
25
|
+
2. NO PATENT LICENSE GRANTED.
|
|
26
|
+
Nothing in this License grants, expressly or by implication, any patent license
|
|
27
|
+
to any patent, patent application, or other intellectual property right of
|
|
28
|
+
Licensor. All patent rights are expressly reserved. The patent applications
|
|
29
|
+
identified in Section 7 are not licensed by this License.
|
|
30
|
+
|
|
31
|
+
3. SEPARATE GRANT FOR DEMONSTRATION ASSETS.
|
|
32
|
+
The following assets, and ONLY these assets, are released under the Apache
|
|
33
|
+
License, Version 2.0, the text of which is reproduced or available at
|
|
34
|
+
https://www.apache.org/licenses/LICENSE-2.0:
|
|
35
|
+
|
|
36
|
+
- The test vectors under packages/agentguard-spend-python/test_vectors/
|
|
37
|
+
- The documentation examples under packages/agentguard-spend-python/examples/
|
|
38
|
+
- The contents of packages/agentguard-spend-python/README.md
|
|
39
|
+
|
|
40
|
+
The source code under packages/agentguard-spend-python/agentguard_spend/ is NOT included in this
|
|
41
|
+
Apache License 2.0 grant. The Python type definitions, policy engine,
|
|
42
|
+
decision log, store implementation, cost table, and wrapper code under
|
|
43
|
+
agentguard_spend/ are licensed only under the alpha evaluation terms of
|
|
44
|
+
Section 1 above.
|
|
45
|
+
|
|
46
|
+
4. WARRANTY DISCLAIMER.
|
|
47
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
48
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
49
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
50
|
+
DUNECREST VENTURES INC. BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY
|
|
51
|
+
ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
52
|
+
DEALINGS IN THE SOFTWARE.
|
|
53
|
+
|
|
54
|
+
5. SUCCESSORS AND ASSIGNS.
|
|
55
|
+
This License binds and benefits the parties' respective successors and assigns.
|
|
56
|
+
In the event of an asset sale, merger, change of control, or other transfer of
|
|
57
|
+
the Licensor's rights in this software, all rights and obligations under this
|
|
58
|
+
License inure to the benefit of and are binding upon Licensor's successor or
|
|
59
|
+
assignee. Outstanding evaluation grants survive change-of-control, but the
|
|
60
|
+
successor or assignee may, upon thirty (30) days' written notice, terminate
|
|
61
|
+
ongoing evaluation grants in favor of a commercial-license requirement.
|
|
62
|
+
|
|
63
|
+
6. TERMINATION.
|
|
64
|
+
Licensor may terminate this License with thirty (30) days' written notice for
|
|
65
|
+
any reason or no reason. Upon termination, Licensee shall cease all use of the
|
|
66
|
+
software under agentguard_spend/ and shall destroy all copies in Licensee's possession.
|
|
67
|
+
|
|
68
|
+
7. PATENT NOTICE (35 U.S.C. § 287).
|
|
69
|
+
Protected by U.S. patent-pending technology, including the following
|
|
70
|
+
provisional patent applications filed with the United States Patent and
|
|
71
|
+
Trademark Office:
|
|
72
|
+
|
|
73
|
+
- Application No. 63/983,615 (filed February 15, 2026)
|
|
74
|
+
- Application No. 63/983,621 (filed February 15, 2026)
|
|
75
|
+
- Application No. 63/983,843 (filed February 16, 2026)
|
|
76
|
+
- Application No. 63/984,626 (filed February 17, 2026)
|
|
77
|
+
- Application No. 64/071,781 (filed May 21, 2026)
|
|
78
|
+
- Application No. 64/071,789 (filed May 21, 2026)
|
|
79
|
+
|
|
80
|
+
Additional patents pending. All patent rights expressly reserved per
|
|
81
|
+
Section 2 above.
|
|
82
|
+
|
|
83
|
+
AgentGuard(TM) is a trademark of Dunecrest Ventures Inc. (USPTO Serial
|
|
84
|
+
No. 99462472, pending). MerchantGuard(TM) is a trademark of Dunecrest
|
|
85
|
+
Ventures Inc. (USPTO Serial No. 99051215, pending).
|
|
86
|
+
|
|
87
|
+
For commercial licensing: invest@agentguard.run
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Patent Notice
|
|
2
|
+
|
|
3
|
+
`agentguard-spend` (Python) is protected by U.S. patent-pending technology, including the
|
|
4
|
+
following provisional patent applications filed with the United States Patent and
|
|
5
|
+
Trademark Office by Dunecrest Ventures Inc.:
|
|
6
|
+
|
|
7
|
+
| Application No. | Filing Date | Subject Matter (summary) |
|
|
8
|
+
|-----------------|-------------------|---------------------------------------------------------------------|
|
|
9
|
+
| 63/983,615 | February 15, 2026 | Agent identity, scope derivation, and policy substrate |
|
|
10
|
+
| 63/983,621 | February 15, 2026 | Tamper-evident signed decision logging for agent enforcement |
|
|
11
|
+
| 63/983,843 | February 16, 2026 | Capability gating and in-flight model routing |
|
|
12
|
+
| 63/984,626 | February 17, 2026 | DAG Trust Attestation Token framework (§7.3 capability substrate) |
|
|
13
|
+
| 64/071,781 | May 21, 2026 | Hard monetary spend caps with multi-action response and downgrade |
|
|
14
|
+
| 64/071,789 | May 21, 2026 | Hierarchical scope-key resolution and coordination-free windowing |
|
|
15
|
+
|
|
16
|
+
Additional patent applications are pending.
|
|
17
|
+
|
|
18
|
+
## No Patent License Granted
|
|
19
|
+
|
|
20
|
+
This package and its accompanying LICENSE grant copyright permission for use within the
|
|
21
|
+
thresholds described in Section 1 of the LICENSE. **Nothing in this package grants, expressly
|
|
22
|
+
or by implication, any patent license** to any patent, patent application, or other
|
|
23
|
+
intellectual property right of Dunecrest Ventures Inc. All patent rights are expressly
|
|
24
|
+
reserved.
|
|
25
|
+
|
|
26
|
+
## Patent marking (35 U.S.C. § 287)
|
|
27
|
+
|
|
28
|
+
This file serves as virtual patent marking pursuant to 35 U.S.C. § 287(a). It is a
|
|
29
|
+
constructive-notice declaration that the technology embodied in `agentguard-spend` is the
|
|
30
|
+
subject of pending United States patent applications.
|
|
31
|
+
|
|
32
|
+
For commercial licensing, OEM agreements, or strategic partnership inquiries, contact
|
|
33
|
+
`invest@agentguard.run`.
|
|
34
|
+
|
|
35
|
+
AgentGuard(TM) is a trademark of Dunecrest Ventures Inc. (USPTO Serial No. 99462472, pending).
|
|
36
|
+
MerchantGuard(TM) is a trademark of Dunecrest Ventures Inc. (USPTO Serial No. 99051215,
|
|
37
|
+
pending).
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentguard-spend
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local-runtime spend caps and capability-gated model routing for AI agents. Prompts, API keys, and signing keys stay inside the customer runtime. Zero data plane involvement.
|
|
5
|
+
Project-URL: Homepage, https://agentguard.run
|
|
6
|
+
Project-URL: Contact, https://agentguard.run/contact
|
|
7
|
+
Project-URL: Repository, https://github.com/MerchantGuardOps/agentguard-site
|
|
8
|
+
Author-email: "Dunecrest Ventures Inc." <hello@agentguard.run>
|
|
9
|
+
License: AgentGuard(TM) Spend SDK — Alpha License
|
|
10
|
+
Copyright (c) 2026 Dunecrest Ventures Inc.
|
|
11
|
+
|
|
12
|
+
1. SCOPE.
|
|
13
|
+
This software, including all files under packages/agentguard-spend-python/agentguard_spend/, is
|
|
14
|
+
licensed by Dunecrest Ventures Inc. ("Licensor") subject to the following
|
|
15
|
+
thresholds:
|
|
16
|
+
|
|
17
|
+
(a) Evaluation Use. Internal evaluation, prototyping, and non-commercial
|
|
18
|
+
development at any call volume.
|
|
19
|
+
|
|
20
|
+
(b) Free Production Threshold. Production deployments processing 10,000
|
|
21
|
+
or fewer enforcement calls per calendar month, in aggregate across
|
|
22
|
+
all instances operated by the licensee, are permitted under this
|
|
23
|
+
License without additional fee.
|
|
24
|
+
|
|
25
|
+
(c) Commercial License Required. Production deployments processing more
|
|
26
|
+
than 10,000 enforcement calls per calendar month, deployments
|
|
27
|
+
operated for the benefit of third parties as a service, redistribution,
|
|
28
|
+
sublicensing, public hosting, and republication each require a
|
|
29
|
+
separate commercial license agreement with Licensor.
|
|
30
|
+
|
|
31
|
+
Commercial-license inquiries: invest@agentguard.run
|
|
32
|
+
|
|
33
|
+
2. NO PATENT LICENSE GRANTED.
|
|
34
|
+
Nothing in this License grants, expressly or by implication, any patent license
|
|
35
|
+
to any patent, patent application, or other intellectual property right of
|
|
36
|
+
Licensor. All patent rights are expressly reserved. The patent applications
|
|
37
|
+
identified in Section 7 are not licensed by this License.
|
|
38
|
+
|
|
39
|
+
3. SEPARATE GRANT FOR DEMONSTRATION ASSETS.
|
|
40
|
+
The following assets, and ONLY these assets, are released under the Apache
|
|
41
|
+
License, Version 2.0, the text of which is reproduced or available at
|
|
42
|
+
https://www.apache.org/licenses/LICENSE-2.0:
|
|
43
|
+
|
|
44
|
+
- The test vectors under packages/agentguard-spend-python/test_vectors/
|
|
45
|
+
- The documentation examples under packages/agentguard-spend-python/examples/
|
|
46
|
+
- The contents of packages/agentguard-spend-python/README.md
|
|
47
|
+
|
|
48
|
+
The source code under packages/agentguard-spend-python/agentguard_spend/ is NOT included in this
|
|
49
|
+
Apache License 2.0 grant. The Python type definitions, policy engine,
|
|
50
|
+
decision log, store implementation, cost table, and wrapper code under
|
|
51
|
+
agentguard_spend/ are licensed only under the alpha evaluation terms of
|
|
52
|
+
Section 1 above.
|
|
53
|
+
|
|
54
|
+
4. WARRANTY DISCLAIMER.
|
|
55
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
56
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
57
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
58
|
+
DUNECREST VENTURES INC. BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY
|
|
59
|
+
ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
60
|
+
DEALINGS IN THE SOFTWARE.
|
|
61
|
+
|
|
62
|
+
5. SUCCESSORS AND ASSIGNS.
|
|
63
|
+
This License binds and benefits the parties' respective successors and assigns.
|
|
64
|
+
In the event of an asset sale, merger, change of control, or other transfer of
|
|
65
|
+
the Licensor's rights in this software, all rights and obligations under this
|
|
66
|
+
License inure to the benefit of and are binding upon Licensor's successor or
|
|
67
|
+
assignee. Outstanding evaluation grants survive change-of-control, but the
|
|
68
|
+
successor or assignee may, upon thirty (30) days' written notice, terminate
|
|
69
|
+
ongoing evaluation grants in favor of a commercial-license requirement.
|
|
70
|
+
|
|
71
|
+
6. TERMINATION.
|
|
72
|
+
Licensor may terminate this License with thirty (30) days' written notice for
|
|
73
|
+
any reason or no reason. Upon termination, Licensee shall cease all use of the
|
|
74
|
+
software under agentguard_spend/ and shall destroy all copies in Licensee's possession.
|
|
75
|
+
|
|
76
|
+
7. PATENT NOTICE (35 U.S.C. § 287).
|
|
77
|
+
Protected by U.S. patent-pending technology, including the following
|
|
78
|
+
provisional patent applications filed with the United States Patent and
|
|
79
|
+
Trademark Office:
|
|
80
|
+
|
|
81
|
+
- Application No. 63/983,615 (filed February 15, 2026)
|
|
82
|
+
- Application No. 63/983,621 (filed February 15, 2026)
|
|
83
|
+
- Application No. 63/983,843 (filed February 16, 2026)
|
|
84
|
+
- Application No. 63/984,626 (filed February 17, 2026)
|
|
85
|
+
- Application No. 64/071,781 (filed May 21, 2026)
|
|
86
|
+
- Application No. 64/071,789 (filed May 21, 2026)
|
|
87
|
+
|
|
88
|
+
Additional patents pending. All patent rights expressly reserved per
|
|
89
|
+
Section 2 above.
|
|
90
|
+
|
|
91
|
+
AgentGuard(TM) is a trademark of Dunecrest Ventures Inc. (USPTO Serial
|
|
92
|
+
No. 99462472, pending). MerchantGuard(TM) is a trademark of Dunecrest
|
|
93
|
+
Ventures Inc. (USPTO Serial No. 99051215, pending).
|
|
94
|
+
|
|
95
|
+
For commercial licensing: invest@agentguard.run
|
|
96
|
+
License-File: LICENSE
|
|
97
|
+
Keywords: agent-governance,ai-agent-security,ai-agents,anthropic,audit-log,bedrock,cryptographic-attestation,ed25519,llm,local-first,model-routing,no-proxy,openai,policy-enforcement,spend-control,tamper-evident
|
|
98
|
+
Classifier: Development Status :: 3 - Alpha
|
|
99
|
+
Classifier: Intended Audience :: Developers
|
|
100
|
+
Classifier: License :: Other/Proprietary License
|
|
101
|
+
Classifier: Operating System :: OS Independent
|
|
102
|
+
Classifier: Programming Language :: Python :: 3
|
|
103
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
104
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
105
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
106
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
107
|
+
Classifier: Topic :: Security
|
|
108
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
109
|
+
Requires-Python: >=3.10
|
|
110
|
+
Requires-Dist: cryptography>=42
|
|
111
|
+
Provides-Extra: all
|
|
112
|
+
Requires-Dist: anthropic>=0.30; extra == 'all'
|
|
113
|
+
Requires-Dist: boto3>=1.34; extra == 'all'
|
|
114
|
+
Requires-Dist: openai>=1.0; extra == 'all'
|
|
115
|
+
Provides-Extra: anthropic
|
|
116
|
+
Requires-Dist: anthropic>=0.30; extra == 'anthropic'
|
|
117
|
+
Provides-Extra: bedrock
|
|
118
|
+
Requires-Dist: boto3>=1.34; extra == 'bedrock'
|
|
119
|
+
Provides-Extra: dev
|
|
120
|
+
Requires-Dist: build>=1.0; extra == 'dev'
|
|
121
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
122
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
123
|
+
Provides-Extra: openai
|
|
124
|
+
Requires-Dist: openai>=1.0; extra == 'openai'
|
|
125
|
+
Description-Content-Type: text/markdown
|
|
126
|
+
|
|
127
|
+
# agentguard-spend (Python)
|
|
128
|
+
|
|
129
|
+
> Local-runtime spend caps and capability-gated model routing for AI agents.
|
|
130
|
+
|
|
131
|
+
Python 3.10+ port of [`@agentguard-run/spend`](https://www.npmjs.com/package/@agentguard-run/spend).
|
|
132
|
+
Byte-identical decision-log format and Ed25519 signing — verifiable across both
|
|
133
|
+
runtimes with the same public key.
|
|
134
|
+
|
|
135
|
+
Every policy decision runs inside your process. Prompts, provider API keys, and
|
|
136
|
+
signing keys never leave your runtime. Each enforcement decision produces an
|
|
137
|
+
Ed25519-signed, hash-chained receipt suitable for audit and compliance review.
|
|
138
|
+
|
|
139
|
+
## Why no proxy
|
|
140
|
+
|
|
141
|
+
Every funded competitor in AI spend governance (Portkey, Helicone, LiteLLM,
|
|
142
|
+
Cloudflare AI Gateway, Vercel AI Gateway) proxies your traffic. That means your
|
|
143
|
+
prompts and provider keys flow through their infrastructure. `agentguard-spend`
|
|
144
|
+
never sees any of that. The policy runs in your process. The signed log lives
|
|
145
|
+
in your storage.
|
|
146
|
+
|
|
147
|
+
The procurement consequence: your security review covers this SDK like any
|
|
148
|
+
other library, not like a vendor that handles your data.
|
|
149
|
+
|
|
150
|
+
## Status
|
|
151
|
+
|
|
152
|
+
Private preview. Designed for enterprise, OEM, and platform integration.
|
|
153
|
+
|
|
154
|
+
For evaluation access, OEM licensing, or strategic partnership inquiries:
|
|
155
|
+
`invest@agentguard.run`
|
|
156
|
+
|
|
157
|
+
## Install
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pip install agentguard-spend
|
|
161
|
+
# Optional provider extras:
|
|
162
|
+
pip install "agentguard-spend[openai]"
|
|
163
|
+
pip install "agentguard-spend[anthropic]"
|
|
164
|
+
pip install "agentguard-spend[bedrock]"
|
|
165
|
+
# Or all of them:
|
|
166
|
+
pip install "agentguard-spend[all]"
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Production dependency: `cryptography>=42` (for Ed25519). The provider SDKs
|
|
170
|
+
(openai, anthropic, boto3) are **peer/optional**; install only what you use.
|
|
171
|
+
|
|
172
|
+
## Quickstart
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
import asyncio
|
|
176
|
+
from openai import OpenAI
|
|
177
|
+
|
|
178
|
+
from agentguard_spend import (
|
|
179
|
+
SpendPolicy,
|
|
180
|
+
SpendScope,
|
|
181
|
+
SpendCap,
|
|
182
|
+
SigningKeys,
|
|
183
|
+
SpendGuardConfig,
|
|
184
|
+
InMemorySpendStore,
|
|
185
|
+
InMemoryDecisionLogStore,
|
|
186
|
+
generate_keypair,
|
|
187
|
+
with_spend_guard,
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# Generate or load signing keys. They never leave your runtime.
|
|
191
|
+
# In production these come from your HSM / KMS / Vault.
|
|
192
|
+
private_key, public_key = generate_keypair() # 32-byte seed + 32-byte pubkey
|
|
193
|
+
|
|
194
|
+
policy = SpendPolicy(
|
|
195
|
+
id="finance-ops-v1",
|
|
196
|
+
name="Finance ops daily caps",
|
|
197
|
+
scope=SpendScope(tenantId="acme-corp"),
|
|
198
|
+
caps=[
|
|
199
|
+
SpendCap(
|
|
200
|
+
amountCents=500,
|
|
201
|
+
window="per_day",
|
|
202
|
+
action="downgrade",
|
|
203
|
+
downgradeTo="claude-sonnet-4-6",
|
|
204
|
+
reason="Opus daily soft cap reached, route to Sonnet",
|
|
205
|
+
),
|
|
206
|
+
SpendCap(
|
|
207
|
+
amountCents=1000,
|
|
208
|
+
window="per_day",
|
|
209
|
+
action="block",
|
|
210
|
+
reason="Hard daily ceiling",
|
|
211
|
+
),
|
|
212
|
+
],
|
|
213
|
+
mode="enforce",
|
|
214
|
+
version=1,
|
|
215
|
+
effectiveFrom="2026-05-23T00:00:00.000Z",
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
openai_client = OpenAI()
|
|
219
|
+
guarded = with_spend_guard(
|
|
220
|
+
openai_client,
|
|
221
|
+
policy=policy,
|
|
222
|
+
scope=SpendScope(tenantId="acme-corp", userId="alice", agentId="finance-bot"),
|
|
223
|
+
config=SpendGuardConfig(
|
|
224
|
+
policy=policy,
|
|
225
|
+
spendStore=InMemorySpendStore(),
|
|
226
|
+
logStore=InMemoryDecisionLogStore(),
|
|
227
|
+
signingKeys=SigningKeys(privateKey=private_key, publicKey=public_key),
|
|
228
|
+
),
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
# Drop-in: same API as openai.chat.completions.create
|
|
232
|
+
completion = guarded.chat.completions.create(
|
|
233
|
+
model="gpt-4o",
|
|
234
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
235
|
+
)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
When the policy fires:
|
|
239
|
+
|
|
240
|
+
| Action | Result |
|
|
241
|
+
|-------------|-------------------------------------------------------------------------|
|
|
242
|
+
| `allow` | Call passes through unchanged |
|
|
243
|
+
| `downgrade` | The `model` parameter is rewritten to `downgradeTo`, then the call proceeds |
|
|
244
|
+
| `block` | An `AgentGuardBlockedError` is raised before the provider is contacted |
|
|
245
|
+
| `shadow` | Call passes through; the decision is logged for analysis only |
|
|
246
|
+
|
|
247
|
+
## Anthropic and Bedrock bindings
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
from anthropic import Anthropic
|
|
251
|
+
from agentguard_spend.bindings import with_anthropic_spend_guard
|
|
252
|
+
|
|
253
|
+
raw = Anthropic()
|
|
254
|
+
guarded = with_anthropic_spend_guard(
|
|
255
|
+
raw,
|
|
256
|
+
policy=policy,
|
|
257
|
+
scope=SpendScope(tenantId="acme-corp"),
|
|
258
|
+
)
|
|
259
|
+
guarded.messages.create(
|
|
260
|
+
model="claude-opus-4-7",
|
|
261
|
+
max_tokens=1024,
|
|
262
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
263
|
+
)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
import boto3
|
|
268
|
+
from agentguard_spend.bindings import with_bedrock_spend_guard
|
|
269
|
+
|
|
270
|
+
raw = boto3.client("bedrock-runtime")
|
|
271
|
+
guarded = with_bedrock_spend_guard(
|
|
272
|
+
raw,
|
|
273
|
+
policy=policy,
|
|
274
|
+
scope=SpendScope(tenantId="acme-corp"),
|
|
275
|
+
)
|
|
276
|
+
guarded.invoke_model(
|
|
277
|
+
modelId="anthropic.claude-sonnet-4-v1:0",
|
|
278
|
+
body=b'{"messages":[{"role":"user","content":"hi"}],"max_tokens":256}',
|
|
279
|
+
)
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Capability-gated escalation
|
|
283
|
+
|
|
284
|
+
You can require a capability tier on a policy:
|
|
285
|
+
|
|
286
|
+
```python
|
|
287
|
+
policy = SpendPolicy(
|
|
288
|
+
# ...
|
|
289
|
+
requiredCapability="payment_initiate",
|
|
290
|
+
)
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Calls that do not present a `capabilityClaim` at or above this tier are blocked
|
|
294
|
+
immediately. Tiers (ascending): `read_only` < `data_write` < `payment_initiate`
|
|
295
|
+
< `payment_execute`.
|
|
296
|
+
|
|
297
|
+
## Verifying a signed log
|
|
298
|
+
|
|
299
|
+
Anyone with the public key can verify the chain:
|
|
300
|
+
|
|
301
|
+
```python
|
|
302
|
+
from agentguard_spend import verify_chain
|
|
303
|
+
|
|
304
|
+
entries = await load_entries() # from your storage
|
|
305
|
+
result = await verify_chain(entries, public_key)
|
|
306
|
+
if not result.ok:
|
|
307
|
+
print(f"chain invalid at sequence {result.sequence}: {result.reason}")
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Each entry binds the previous entry's hash via SHA-256 and is signed with
|
|
311
|
+
Ed25519. Tampering with any field of any entry invalidates the chain from that
|
|
312
|
+
point forward.
|
|
313
|
+
|
|
314
|
+
## Cross-language interoperability
|
|
315
|
+
|
|
316
|
+
`agentguard-spend` (Python) and `@agentguard-run/spend` (TypeScript) produce
|
|
317
|
+
**byte-identical canonical-JSON serialization** for the same `SpendDecision`.
|
|
318
|
+
That means an Ed25519 signature created in either runtime verifies in the
|
|
319
|
+
other. The repo includes a cross-language parity test:
|
|
320
|
+
|
|
321
|
+
- Fixture: `test_vectors/fixed_decision.json`
|
|
322
|
+
- TS reference generator: `test_vectors/compute_expected_ts.js`
|
|
323
|
+
- Python assertion: `tests/test_cross_language_parity.py`
|
|
324
|
+
|
|
325
|
+
## License and usage thresholds
|
|
326
|
+
|
|
327
|
+
The SDK is **free** for:
|
|
328
|
+
|
|
329
|
+
- Evaluation, prototyping, and non-commercial development at any volume
|
|
330
|
+
- Production deployments processing **up to 10,000 enforcement calls per
|
|
331
|
+
calendar month**
|
|
332
|
+
|
|
333
|
+
A separate commercial license is required for:
|
|
334
|
+
|
|
335
|
+
- Production deployments processing **more than 10,000 enforcement calls per
|
|
336
|
+
month**
|
|
337
|
+
- Deployments operated as a service to third parties
|
|
338
|
+
- Redistribution, sublicensing, public hosting, republication
|
|
339
|
+
|
|
340
|
+
Inbound commercial-license inquiries: `invest@agentguard.run`
|
|
341
|
+
|
|
342
|
+
Full terms in `LICENSE`. All patent rights expressly reserved (see Section 2 of
|
|
343
|
+
`LICENSE`).
|
|
344
|
+
|
|
345
|
+
## Patent notice
|
|
346
|
+
|
|
347
|
+
Protected by 6 U.S. patent-pending applications:
|
|
348
|
+
|
|
349
|
+
- 63/983,615 · 63/983,621 · 63/983,843 · 63/984,626 (filed February 2026)
|
|
350
|
+
- 64/071,781 · 64/071,789 (filed May 21, 2026)
|
|
351
|
+
|
|
352
|
+
See `LICENSE` Section 7 and `PATENTS.md`.
|
|
353
|
+
|
|
354
|
+
## Links
|
|
355
|
+
|
|
356
|
+
- agentguard.run
|
|
357
|
+
- Contact: `invest@agentguard.run`
|
|
358
|
+
- TypeScript SDK: [`@agentguard-run/spend`](https://www.npmjs.com/package/@agentguard-run/spend)
|