Metadata-Version: 2.4
Name: grantex-a2a
Version: 0.1.1
Summary: Google A2A protocol bridge for Grantex — inject grant tokens into agent-to-agent communication
Project-URL: Homepage, https://grantex.dev
Project-URL: Documentation, https://docs.grantex.dev/integrations/a2a
Project-URL: Repository, https://github.com/mishrasanjeev/grantex
Project-URL: Issues, https://github.com/mishrasanjeev/grantex/issues
License: Apache-2.0
Keywords: a2a,agent-to-agent,ai-agents,authorization,google-a2a,grantex,jwt,oauth
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Requires-Dist: grantex>=0.1.0
Provides-Extra: dev
Requires-Dist: httpx>=0.25.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.12; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Provides-Extra: httpx
Requires-Dist: httpx>=0.25.0; extra == 'httpx'
Description-Content-Type: text/markdown

# grantex-a2a

Google A2A protocol bridge for [Grantex](https://grantex.dev) — inject grant tokens into agent-to-agent communication.

## Installation

```bash
pip install grantex-a2a
```

## Usage

### Client — Send tasks to A2A agents with grant token auth

```python
from grantex_a2a import A2AGrantexClient, A2AGrantexClientOptions, TaskSendParams, A2AMessage, A2APart

client = A2AGrantexClient(A2AGrantexClientOptions(
    agent_url="https://agent.example.com/a2a",
    grant_token="eyJ...",
))

task = client.send_task(TaskSendParams(
    message=A2AMessage(role="user", parts=[A2APart(type="text", text="Hello")])
))
```

### Server middleware — Validate incoming grant tokens

```python
from grantex_a2a import create_a2a_auth_middleware, A2AAuthMiddlewareOptions

middleware = create_a2a_auth_middleware(
    A2AAuthMiddlewareOptions(jwks_uri="https://grantex.dev/.well-known/jwks.json")
)

# In your request handler:
grant = middleware(dict(request.headers))
print(grant.principal_id, grant.scopes)
```

### Agent Card — Build A2A-compliant agent cards

```python
from grantex_a2a import build_grantex_agent_card, GrantexAgentCardOptions

card = build_grantex_agent_card(GrantexAgentCardOptions(
    name="My Agent",
    description="An agent",
    url="https://my-agent.example.com/a2a",
    jwks_uri="https://grantex.dev/.well-known/jwks.json",
    issuer="https://grantex.dev",
))
```
