agentguard-python-sdk 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. agentguard_python_sdk-0.2.2/LICENSE +21 -0
  2. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/PKG-INFO +29 -3
  3. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/README.md +26 -2
  4. agentguard_python_sdk-0.2.2/agentguard/__init__.py +57 -0
  5. agentguard_python_sdk-0.2.2/agentguard/auth.py +20 -0
  6. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/agentguard/client.py +639 -420
  7. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/agentguard/config.py +48 -34
  8. agentguard_python_sdk-0.2.2/agentguard/consent.py +63 -0
  9. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/agentguard/errors.py +95 -83
  10. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/agentguard/observability.py +52 -52
  11. agentguard_python_sdk-0.2.2/agentguard/types.py +68 -0
  12. agentguard_python_sdk-0.2.2/agentguard_crypto/__init__.py +1 -0
  13. agentguard_python_sdk-0.2.2/agentguard_crypto/canonical.py +34 -0
  14. agentguard_python_sdk-0.2.2/agentguard_crypto/models.py +108 -0
  15. agentguard_python_sdk-0.2.2/agentguard_crypto/signing.py +76 -0
  16. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/agentguard_python_sdk.egg-info/PKG-INFO +29 -3
  17. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/agentguard_python_sdk.egg-info/SOURCES.txt +5 -0
  18. agentguard_python_sdk-0.2.2/agentguard_python_sdk.egg-info/top_level.txt +2 -0
  19. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/pyproject.toml +2 -2
  20. agentguard_python_sdk-0.2.0/agentguard/__init__.py +0 -4
  21. agentguard_python_sdk-0.2.0/agentguard/auth.py +0 -54
  22. agentguard_python_sdk-0.2.0/agentguard/consent.py +0 -79
  23. agentguard_python_sdk-0.2.0/agentguard/types.py +0 -25
  24. agentguard_python_sdk-0.2.0/agentguard_python_sdk.egg-info/top_level.txt +0 -1
  25. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/agentguard_python_sdk.egg-info/dependency_links.txt +0 -0
  26. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/agentguard_python_sdk.egg-info/requires.txt +0 -0
  27. {agentguard_python_sdk-0.2.0 → agentguard_python_sdk-0.2.2}/setup.cfg +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AgentGuard Team
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.
@@ -1,16 +1,18 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentguard-python-sdk
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A production-grade middleware for AI agents to perform on-chain payments and verifiable consent.
5
5
  Author: AgentGuard Team
6
6
  License-Expression: MIT
7
7
  Requires-Python: >=3.9
8
8
  Description-Content-Type: text/markdown
9
+ License-File: LICENSE
9
10
  Requires-Dist: httpx>=0.27.0
10
11
  Requires-Dist: pydantic>=2.0.0
11
12
  Requires-Dist: pydantic-settings>=2.0.0
12
13
  Requires-Dist: pynacl>=1.5.0
13
14
  Requires-Dist: py-algorand-sdk>=2.0.0
15
+ Dynamic: license-file
14
16
 
15
17
  # AgentGuard SDK
16
18
 
@@ -29,16 +31,40 @@ pip install agentguard-python-sdk
29
31
  ```python
30
32
  import asyncio
31
33
  from agentguard import AgentGuardClient
34
+ from agentguard.types import DelegatedAuthorization, AuthorizationConstraints, NonceContext, AuthorizationMetadata
32
35
 
33
36
  async def main():
34
37
  # 1. Initialize the client
35
- async with AgentGuardClient(wallet_address="YOUR_WALLET_ADDRESS") as client:
38
+ # NOTE: The backend requires a cryptographic signature on `/pay`.
39
+ # Provide `private_key` as a base64-encoded Algorand private key seed for request signing.
40
+ async with AgentGuardClient(
41
+ wallet_address="YOUR_WALLET_ADDRESS",
42
+ private_key="YOUR_PRIVATE_KEY_B64",
43
+ backend_url="https://agentguard-backend-9s8j.onrender.com"
44
+ ) as client:
45
+
46
+ # 1.5 Authorize a capability (LogicSig)
47
+ auth = DelegatedAuthorization(
48
+ authorization_id="YOUR_AUTHORIZATION_ID",
49
+ principal_id="YOUR_WALLET_ADDRESS",
50
+ logic_sig_b64="YOUR_SIGNED_LOGICSIG_BASE64",
51
+ constraints=AuthorizationConstraints(
52
+ max_amount_microalgos=1000000,
53
+ expires_at_unix=1900000000,
54
+ max_txns_per_window=10,
55
+ window_seconds=3600
56
+ ),
57
+ nonce_context=NonceContext(lease_strategy="deterministic", scope="session"),
58
+ metadata=AuthorizationMetadata(created_at=1716000000, sdk_version="0.2.2", delegation_type="LogicSig")
59
+ )
60
+ await client.authorize(auth)
36
61
 
37
62
  # 2. Perform a secure payment (includes automatic DPDP consent hashing)
38
63
  receipt = await client.pay_and_fetch(
39
64
  resource_url="https://api.stock.com/reliance",
40
65
  amount_algo="0.05",
41
- purpose="Financial Analysis"
66
+ purpose="Financial Analysis",
67
+ authorization_id="YOUR_AUTHORIZATION_ID"
42
68
  )
43
69
  print(f"Payment Successful! TX ID: {receipt.tx_id}")
44
70
 
@@ -15,16 +15,40 @@ pip install agentguard-python-sdk
15
15
  ```python
16
16
  import asyncio
17
17
  from agentguard import AgentGuardClient
18
+ from agentguard.types import DelegatedAuthorization, AuthorizationConstraints, NonceContext, AuthorizationMetadata
18
19
 
19
20
  async def main():
20
21
  # 1. Initialize the client
21
- async with AgentGuardClient(wallet_address="YOUR_WALLET_ADDRESS") as client:
22
+ # NOTE: The backend requires a cryptographic signature on `/pay`.
23
+ # Provide `private_key` as a base64-encoded Algorand private key seed for request signing.
24
+ async with AgentGuardClient(
25
+ wallet_address="YOUR_WALLET_ADDRESS",
26
+ private_key="YOUR_PRIVATE_KEY_B64",
27
+ backend_url="https://agentguard-backend-9s8j.onrender.com"
28
+ ) as client:
29
+
30
+ # 1.5 Authorize a capability (LogicSig)
31
+ auth = DelegatedAuthorization(
32
+ authorization_id="YOUR_AUTHORIZATION_ID",
33
+ principal_id="YOUR_WALLET_ADDRESS",
34
+ logic_sig_b64="YOUR_SIGNED_LOGICSIG_BASE64",
35
+ constraints=AuthorizationConstraints(
36
+ max_amount_microalgos=1000000,
37
+ expires_at_unix=1900000000,
38
+ max_txns_per_window=10,
39
+ window_seconds=3600
40
+ ),
41
+ nonce_context=NonceContext(lease_strategy="deterministic", scope="session"),
42
+ metadata=AuthorizationMetadata(created_at=1716000000, sdk_version="0.2.2", delegation_type="LogicSig")
43
+ )
44
+ await client.authorize(auth)
22
45
 
23
46
  # 2. Perform a secure payment (includes automatic DPDP consent hashing)
24
47
  receipt = await client.pay_and_fetch(
25
48
  resource_url="https://api.stock.com/reliance",
26
49
  amount_algo="0.05",
27
- purpose="Financial Analysis"
50
+ purpose="Financial Analysis",
51
+ authorization_id="YOUR_AUTHORIZATION_ID"
28
52
  )
29
53
  print(f"Payment Successful! TX ID: {receipt.tx_id}")
30
54
 
@@ -0,0 +1,57 @@
1
+ from .client import AgentGuardClient
2
+ from .config import AgentGuardConfig
3
+ from .errors import (
4
+ AgentGuardError,
5
+ ValidationError,
6
+ TransportError,
7
+ AuthenticationError,
8
+ InvalidSignatureError,
9
+ ExpiredSignatureError,
10
+ PaymentError,
11
+ ReplayAttackError,
12
+ DuplicatePaymentError,
13
+ BudgetExceededError,
14
+ VerificationError,
15
+ SecurityError,
16
+ UnknownExecutionStateError,
17
+ AuthorizationRequiredError
18
+ )
19
+ from .types import (
20
+ AgentGuardReceipt,
21
+ AuditProof,
22
+ AuthorizationConstraints,
23
+ NonceContext,
24
+ AuthorizationMetadata,
25
+ DelegatedAuthorization,
26
+ AuthorizationReceipt,
27
+ RevocationReceipt
28
+ )
29
+
30
+ __version__ = "0.2.2"
31
+
32
+ __all__ = [
33
+ "AgentGuardClient",
34
+ "AgentGuardConfig",
35
+ "AgentGuardError",
36
+ "ValidationError",
37
+ "TransportError",
38
+ "AuthenticationError",
39
+ "InvalidSignatureError",
40
+ "ExpiredSignatureError",
41
+ "PaymentError",
42
+ "ReplayAttackError",
43
+ "DuplicatePaymentError",
44
+ "BudgetExceededError",
45
+ "VerificationError",
46
+ "SecurityError",
47
+ "UnknownExecutionStateError",
48
+ "AuthorizationRequiredError",
49
+ "AgentGuardReceipt",
50
+ "AuditProof",
51
+ "AuthorizationConstraints",
52
+ "NonceContext",
53
+ "AuthorizationMetadata",
54
+ "DelegatedAuthorization",
55
+ "AuthorizationReceipt",
56
+ "RevocationReceipt",
57
+ ]
@@ -0,0 +1,20 @@
1
+ import json
2
+ import unicodedata
3
+ import hashlib
4
+ import base64
5
+ import time
6
+ from typing import Dict, Any
7
+ import nacl.signing
8
+ import nacl.encoding
9
+
10
+ from agentguard_crypto.signing import sign_payload
11
+
12
+ def sign_request(payload: Any, private_key_b64: str) -> str:
13
+ """
14
+ Signs a request using the shared cryptographic source of truth.
15
+ Payload MUST be a strictly typed canonical model.
16
+ """
17
+ if isinstance(payload, dict):
18
+ raise TypeError("Dictionary payloads are strictly prohibited. You must use a Canonical Payload model.")
19
+
20
+ return sign_payload(payload, private_key_b64)