theprotocol-sdk 0.7.5__tar.gz → 0.7.6__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 (79) hide show
  1. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/PKG-INFO +4 -1
  2. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/README.md +3 -0
  3. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/pyproject.toml +1 -1
  4. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/__init__.py +1 -1
  5. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/auth/jwt_verifier.py +8 -2
  6. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/payment/verifier.py +12 -2
  7. theprotocol_sdk-0.7.6/tests/test_dependency_binding.py +110 -0
  8. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/LICENSE +0 -0
  9. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/examples/simple_agent.py +0 -0
  10. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/agent/__init__.py +0 -0
  11. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/agent/base.py +0 -0
  12. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/agent/decorators.py +0 -0
  13. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/agent/router.py +0 -0
  14. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/agent/task_store.py +0 -0
  15. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/agent/well_known.py +0 -0
  16. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/auth/__init__.py +0 -0
  17. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/auth/did_jwt.py +0 -0
  18. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/auth/jws_card.py +0 -0
  19. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/authz.py +0 -0
  20. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/bridges/__init__.py +0 -0
  21. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/bridges/acp.py +0 -0
  22. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/bridges/anp/__init__.py +0 -0
  23. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/bridges/anp/auth.py +0 -0
  24. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/bridges/anp/bridge.py +0 -0
  25. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/bridges/anp/did_wba.py +0 -0
  26. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/bridges/anp/translation.py +0 -0
  27. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/bridges/base.py +0 -0
  28. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/bridges/google_a2a.py +0 -0
  29. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/bridges/mcp.py +0 -0
  30. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/client/__init__.py +0 -0
  31. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/client/a2a_client.py +0 -0
  32. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/client/credentials.py +0 -0
  33. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/dids.py +0 -0
  34. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/exceptions.py +0 -0
  35. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/exchange/__init__.py +0 -0
  36. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/exchange/client.py +0 -0
  37. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/forge.py +0 -0
  38. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/guild.py +0 -0
  39. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/messenger.py +0 -0
  40. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/models/__init__.py +0 -0
  41. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/models/a2a_protocol.py +0 -0
  42. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/models/agent_card.py +0 -0
  43. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/models/v1_compat.py +0 -0
  44. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/mtls.py +0 -0
  45. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/payment/__init__.py +0 -0
  46. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/payment/authenticator.py +0 -0
  47. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/payment/client.py +0 -0
  48. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/payment/mtls_client.py +0 -0
  49. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/registry/__init__.py +0 -0
  50. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/registry/card_verify.py +0 -0
  51. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/registry/cost_composition.py +0 -0
  52. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/transfer/__init__.py +0 -0
  53. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/src/theprotocol/transfer/client.py +0 -0
  54. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/registry/__init__.py +0 -0
  55. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/registry/test_card_verify.py +0 -0
  56. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/registry/test_cost_composition.py +0 -0
  57. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_agent.py +0 -0
  58. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_artifact_roundtrip.py +0 -0
  59. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_auth.py +0 -0
  60. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_authz.py +0 -0
  61. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_bridge_acp.py +0 -0
  62. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_bridge_anp.py +0 -0
  63. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_bridge_google_a2a.py +0 -0
  64. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_bridge_mcp.py +0 -0
  65. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_credentials.py +0 -0
  66. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_did_jwt.py +0 -0
  67. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_dids.py +0 -0
  68. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_exchange_launch.py +0 -0
  69. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_forge.py +0 -0
  70. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_guild.py +0 -0
  71. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_jws_card.py +0 -0
  72. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_messenger.py +0 -0
  73. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_models.py +0 -0
  74. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_mtls_client_presents_cert.py +0 -0
  75. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_mtls_enroll.py +0 -0
  76. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_transfer.py +0 -0
  77. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_v1_compat.py +0 -0
  78. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_verifier_reuse.py +0 -0
  79. {theprotocol_sdk-0.7.5 → theprotocol_sdk-0.7.6}/tests/test_well_known.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: theprotocol-sdk
3
- Version: 0.7.5
3
+ Version: 0.7.6
4
4
  Summary: Build sovereign AI agents with DID identity on TheProtocol. Speaks the A2A protocol (v1.0) natively, with bridges for Google A2A, ANP, and MCP. Works with Vertex AI, AWS AgentCore, LangGraph, CrewAI.
5
5
  Project-URL: Homepage, https://theprotocol.cloud
6
6
  Project-URL: Documentation, https://docs.theprotocol.cloud
@@ -185,6 +185,9 @@ The private key is written `0600` into a `0700` directory, via a temp file and r
185
185
 
186
186
  ## Changelog
187
187
 
188
+ **0.7.6** (2026-10-16, in the source; not built or uploaded yet)
189
+ - `PaymentVerifier` and `AgentJwtVerifier` receive the request when FastAPI calls them. Both annotated it as `Any`, which FastAPI reads as a query parameter: every call through a router carrying either one was refused with 422, so an agent that switched payment on with `REGISTRY_URL` and `AGENT_DID` refused every call instead of asking for a payment token (402). Calling them directly, as the unit tests did, was not affected. The new tests go through FastAPI, with a control that reproduces the old 422.
190
+
188
191
  **0.7.5** (2026-10-02)
189
192
  - Agent DIDs that name their frame (`did:theprotocol:<trust domain>:<uuid4>`, what registries mint since the issuer namespace) map to the did:wba a registry recognises for a DIDWba signer: `did:wba:<trust domain>:<uuid4>` (`did_wba_from_cos`; the new `native_did_from_wba` goes back). Every other shape maps as before.
190
193
  - `A2AAuthenticator` reads such a DID back from an agent SVID's SPIFFE path with its colons; 0.7.4 returned the issuer and the uuid joined by a hyphen.
@@ -142,6 +142,9 @@ The private key is written `0600` into a `0700` directory, via a temp file and r
142
142
 
143
143
  ## Changelog
144
144
 
145
+ **0.7.6** (2026-10-16, in the source; not built or uploaded yet)
146
+ - `PaymentVerifier` and `AgentJwtVerifier` receive the request when FastAPI calls them. Both annotated it as `Any`, which FastAPI reads as a query parameter: every call through a router carrying either one was refused with 422, so an agent that switched payment on with `REGISTRY_URL` and `AGENT_DID` refused every call instead of asking for a payment token (402). Calling them directly, as the unit tests did, was not affected. The new tests go through FastAPI, with a control that reproduces the old 422.
147
+
145
148
  **0.7.5** (2026-10-02)
146
149
  - Agent DIDs that name their frame (`did:theprotocol:<trust domain>:<uuid4>`, what registries mint since the issuer namespace) map to the did:wba a registry recognises for a DIDWba signer: `did:wba:<trust domain>:<uuid4>` (`did_wba_from_cos`; the new `native_did_from_wba` goes back). Every other shape maps as before.
147
150
  - `A2AAuthenticator` reads such a DID back from an agent SVID's SPIFFE path with its colons; 0.7.4 returned the issuer and the uuid joined by a hyphen.
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "theprotocol-sdk"
9
- version = "0.7.5"
9
+ version = "0.7.6"
10
10
  description = "Build sovereign AI agents with DID identity on TheProtocol. Speaks the A2A protocol (v1.0) natively, with bridges for Google A2A, ANP, and MCP. Works with Vertex AI, AWS AgentCore, LangGraph, CrewAI."
11
11
  readme = "README.md"
12
12
  license = {text = "Apache-2.0"}
@@ -14,4 +14,4 @@ Usage:
14
14
  from theprotocol.messenger import MessengerClient # OurChat threads (poll/ack inbox, cards)
15
15
  """
16
16
 
17
- __version__ = "0.7.5"
17
+ __version__ = "0.7.6"
@@ -40,6 +40,11 @@ from typing import Any, Dict, List, Optional
40
40
 
41
41
  import httpx
42
42
 
43
+ try:
44
+ from starlette.requests import Request as StarletteRequest
45
+ except ImportError: # the SDK without its server extra
46
+ StarletteRequest = Any # type: ignore
47
+
43
48
  logger = logging.getLogger(__name__)
44
49
 
45
50
 
@@ -143,9 +148,10 @@ class AgentJwtVerifier:
143
148
  logger.debug("[AgentJwtVerifier] unexpected status %s from /agents/me", resp.status_code)
144
149
  return {"verified": False, "reason": f"unexpected_status_{resp.status_code}"}
145
150
 
146
- async def __call__(self, request: Any) -> Dict[str, Any]:
151
+ async def __call__(self, request: StarletteRequest) -> Dict[str, Any]:
147
152
  """FastAPI-compatible callable form — pulls the Bearer token from the
148
- Authorization header itself.
153
+ Authorization header itself. ``request`` is annotated as a Request so FastAPI passes the
154
+ request (until 0.7.6, annotated ``Any``, it read a query parameter and refused with 422).
149
155
 
150
156
  Returns a verification result dict; does NOT raise on failure (raising
151
157
  is the caller's responsibility based on ``required`` policy).
@@ -25,6 +25,11 @@ from typing import Optional, Dict, Any, List
25
25
 
26
26
  import httpx
27
27
 
28
+ try:
29
+ from starlette.requests import Request as StarletteRequest
30
+ except ImportError: # the SDK without its server extra
31
+ StarletteRequest = Any # type: ignore
32
+
28
33
  logger = logging.getLogger(__name__)
29
34
 
30
35
  # Bounded TTL cache: {cache_key: (result_dict, expire_time)}
@@ -78,8 +83,13 @@ class PaymentVerifier:
78
83
  self.reject_reused_tokens = reject_reused_tokens
79
84
  self._seen_tokens: "OrderedDict[str, float]" = OrderedDict()
80
85
 
81
- async def __call__(self, request: Any) -> Dict[str, Any]:
82
- """FastAPI Depends() entry point."""
86
+ async def __call__(self, request: StarletteRequest) -> Dict[str, Any]:
87
+ """FastAPI Depends() entry point.
88
+
89
+ ``request`` must be annotated as a Request: FastAPI reads any other annotation as a query
90
+ parameter, and until 0.7.6 (annotated ``Any``) every call through a router carrying this
91
+ dependency was refused with 422 (the request "parameter" missing).
92
+ """
83
93
  from fastapi import HTTPException
84
94
 
85
95
  token = (
@@ -0,0 +1,110 @@
1
+ """0.7.6: the SDK's FastAPI dependencies receive the request.
2
+
3
+ PaymentVerifier and AgentJwtVerifier annotated ``request`` as ``Any``; FastAPI reads such a parameter as a
4
+ query parameter, so every call through a router carrying either dependency was refused with 422, and the
5
+ payment check ``create_a2a_router`` switches on (REGISTRY_URL + AGENT_DID) refused every call before it
6
+ could ask for a payment. test_verifier_reuse.py calls the verifier directly with a stand-in request, so it
7
+ could not see this; these tests go through FastAPI itself.
8
+ """
9
+ from typing import Any, Dict
10
+
11
+ import pytest
12
+ from fastapi import Depends, FastAPI, Request
13
+ from fastapi.testclient import TestClient
14
+
15
+ from theprotocol.agent import BaseA2AAgent, create_a2a_router
16
+ from theprotocol.auth import AgentJwtVerifier
17
+ from theprotocol.payment.verifier import PaymentVerifier, _verify_cache
18
+
19
+ AGENT = "did:theprotocol:00000000-0000-4000-8000-000000000000"
20
+ SEND = {"jsonrpc": "2.0", "id": 1, "method": "message/send",
21
+ "params": {"message": {"role": "user", "parts": [{"text": "hi"}]}}}
22
+
23
+
24
+ @pytest.fixture(autouse=True)
25
+ def _clear_cache():
26
+ _verify_cache.clear()
27
+ yield
28
+ _verify_cache.clear()
29
+
30
+
31
+ def _app_with(dependency) -> FastAPI:
32
+ app = FastAPI()
33
+
34
+ @app.post("/paid", dependencies=[Depends(dependency)])
35
+ async def paid(request: Request) -> Dict[str, Any]:
36
+ return {"payment": getattr(request.state, "payment", None)}
37
+
38
+ return app
39
+
40
+
41
+ class _Agent(BaseA2AAgent):
42
+ async def handle_task_send(self, task_id, message):
43
+ return "t1"
44
+
45
+
46
+ def test_payment_verifier_refuses_a_call_without_a_token_with_402():
47
+ r = TestClient(_app_with(PaymentVerifier("https://registry.invalid", AGENT))).post("/paid")
48
+ assert r.status_code == 402, r.text
49
+ assert "X-Payment-Token" in r.json()["detail"]
50
+
51
+
52
+ def test_payment_verifier_lets_a_valid_token_through_and_records_it(monkeypatch):
53
+ v = PaymentVerifier("https://registry.invalid", AGENT)
54
+
55
+ async def fake_verify(url, token):
56
+ return {"valid": True, "token_id": "tok-1", "caller_did": "did:caller",
57
+ "target_agent_did": AGENT, "amount": "5"}
58
+
59
+ monkeypatch.setattr(v, "_verify_with_registry", fake_verify)
60
+ r = TestClient(_app_with(v)).post("/paid", headers={"X-Payment-Token": "apt_abc"})
61
+ assert r.status_code == 200, r.text
62
+ assert r.json()["payment"]["caller_did"] == "did:caller"
63
+
64
+
65
+ def test_create_a2a_router_asks_for_payment_when_the_registry_is_named(monkeypatch):
66
+ monkeypatch.setenv("REGISTRY_URL", "https://registry.invalid")
67
+ monkeypatch.setenv("AGENT_DID", AGENT)
68
+ monkeypatch.delenv("PAYMENT_REQUIRED", raising=False)
69
+ app = FastAPI()
70
+ app.include_router(create_a2a_router(_Agent()), prefix="/a2a")
71
+ r = TestClient(app).post("/a2a/", json=SEND)
72
+ assert r.status_code == 402, r.text
73
+
74
+
75
+ def test_create_a2a_router_serves_when_payment_is_switched_off(monkeypatch):
76
+ monkeypatch.setenv("REGISTRY_URL", "https://registry.invalid")
77
+ monkeypatch.setenv("AGENT_DID", AGENT)
78
+ monkeypatch.setenv("PAYMENT_REQUIRED", "false")
79
+ app = FastAPI()
80
+ app.include_router(create_a2a_router(_Agent()), prefix="/a2a")
81
+ r = TestClient(app).post("/a2a/", json=SEND)
82
+ assert r.status_code == 200, r.text
83
+ assert r.json()["result"]["id"] == "t1"
84
+
85
+
86
+ def test_agent_jwt_verifier_as_a_dependency_reports_a_missing_token():
87
+ seen = {}
88
+ jwt = AgentJwtVerifier(registry_url="https://registry.invalid")
89
+ app = FastAPI()
90
+
91
+ @app.post("/who")
92
+ async def who(result: Dict[str, Any] = Depends(jwt)) -> Dict[str, Any]:
93
+ seen.update(result)
94
+ return result
95
+
96
+ r = TestClient(app).post("/who")
97
+ assert r.status_code == 200, r.text
98
+ assert seen.get("verified") is False
99
+
100
+
101
+ def test_control_an_any_annotated_dependency_is_read_as_a_query_parameter():
102
+ """The shape both verifiers had: FastAPI answers 422 before the dependency runs."""
103
+
104
+ class Old(PaymentVerifier):
105
+ async def __call__(self, request: Any) -> Dict[str, Any]: # the pre-0.7.6 annotation
106
+ return await super().__call__(request)
107
+
108
+ r = TestClient(_app_with(Old("https://registry.invalid", AGENT))).post("/paid")
109
+ assert r.status_code == 422, r.text
110
+ assert r.json()["detail"][0]["loc"] == ["query", "request"]
File without changes