agent-did-a2a 1.0.0rc1__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,172 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-did-a2a
3
+ Version: 1.0.0rc1
4
+ Summary: Google A2A protocol integration for Agent-DID — DID-based identity, AgentCard enrichment, and HTTP Signature authentication for agent-to-agent communication.
5
+ Author-email: Edison Munoz <edison.munoz@agent-did.org>
6
+ License-Expression: Apache-2.0
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: agent-did-sdk==1.0.0rc1
10
+ Requires-Dist: pydantic>=2.0
11
+ Provides-Extra: dev
12
+ Requires-Dist: build>=1.2; extra == "dev"
13
+ Requires-Dist: pytest<9.0,>=8.0; extra == "dev"
14
+ Requires-Dist: pytest-asyncio<1.0,>=0.23; extra == "dev"
15
+ Requires-Dist: ruff>=0.4; extra == "dev"
16
+ Requires-Dist: mypy>=1.10; extra == "dev"
17
+
18
+ # Agent-DID × Google A2A Integration
19
+
20
+ > **Roadmap item:** F2-02 — Google A2A proof-of-concept
21
+
22
+ Agent-DID as the identity layer for the [Google A2A (Agent-to-Agent)](https://google.github.io/A2A/) protocol. This integration provides DID-based cryptographic identity for A2A agent discovery, request signing, and mutual authentication.
23
+
24
+ ## What This Solves
25
+
26
+ The A2A protocol is **auth-agnostic** — it defines how agents communicate (JSON-RPC 2.0 over HTTPS) and discover each other (AgentCards), but deliberately leaves authentication to the implementer. This creates a gap:
27
+
28
+ | A2A Gap | What Agent-DID Provides |
29
+ |---|---|
30
+ | No native cryptographic identity | DID anchored to the agent's model, prompt, and capabilities |
31
+ | AgentCard has no verifiable identity proof | DID fields embedded directly in the AgentCard |
32
+ | Request authenticity depends on external auth | Ed25519 HTTP Message Signatures on every JSON-RPC request |
33
+ | No standard for mutual agent authentication | DID-based verification of the counterparty agent |
34
+
35
+ ## Features
36
+
37
+ - **DID-Enriched AgentCards** — generate A2A-compliant AgentCards with embedded DID, controller, and `http-signature-did` authentication scheme
38
+ - **Request Signing** — sign outgoing `tasks/send`, `tasks/get` requests using Agent-DID HTTP Signatures
39
+ - **Request Verification** — verify incoming signed requests using the sender's DID
40
+ - **JSON-RPC Helpers** — Pydantic models for A2A JSON-RPC 2.0 messages
41
+ - **Observability** — structured, sanitized event emission for signing, verification, and card generation
42
+ - **Secure Defaults** — sensitive fields redacted, private network targets blocked, extra config fields rejected
43
+
44
+ ## Identity Composition Contract
45
+
46
+ The canonical A2A identity invariant for this repository is documented in [RFC-001-A2A-Identity-Composition-Contract.md](../../docs/RFC-001-A2A-Identity-Composition-Contract.md), co-drafted with APS during Public Review.
47
+
48
+ The contract defines how two identity surfaces compose:
49
+
50
+ - **Identity-at-rest**: the published AgentCard and its DID-published key material.
51
+ - **Identity-in-motion**: the per-request HTTP signature and its `keyid`.
52
+
53
+ An A2A verifier must treat those surfaces as a single trust boundary: the per-request signing key must compose with the AgentCard and DID document key material, and the signing key must be authorized for the operation context described in §6.3 of the contract.
54
+
55
+ Current integration behavior publishes DID-enriched AgentCards and signs/verifies A2A requests with Agent-DID HTTP signatures. The stricter SDK-level enforcement of §6.3 verification-relationship binding is tracked in [issue #34](https://github.com/edisonduran/agent-did/issues/34); the umbrella closure work for the composition contract remains tracked in [issue #30](https://github.com/edisonduran/agent-did/issues/30).
56
+
57
+ ## Installation
58
+
59
+ ```bash
60
+ cd integrations/a2a
61
+ python -m pip install -e ".[dev]"
62
+ ```
63
+
64
+ Requires the Python SDK installed in dev mode:
65
+
66
+ ```bash
67
+ cd sdk-python
68
+ python -m pip install -e ".[dev]"
69
+ ```
70
+
71
+ ## Quick Start
72
+
73
+ ```python
74
+ from agent_did_sdk import AgentIdentity, AgentIdentityConfig, CreateAgentParams, InMemoryAgentRegistry
75
+ from agent_did_a2a import A2ASkill, create_agent_did_a2a_integration
76
+
77
+ # Create identity
78
+ AgentIdentity.set_registry(InMemoryAgentRegistry())
79
+ identity = AgentIdentity(AgentIdentityConfig(signer_address="0x..."))
80
+ runtime = await identity.create(
81
+ CreateAgentParams(name="MyAgent", core_model="gpt-4.1", system_prompt="...")
82
+ )
83
+
84
+ # Create A2A integration
85
+ integration = create_agent_did_a2a_integration(
86
+ agent_identity=identity,
87
+ runtime_identity=runtime,
88
+ )
89
+
90
+ # Generate AgentCard for /.well-known/agent.json
91
+ card = integration.agent_card_json(
92
+ agent_url="https://my-agent.example.com",
93
+ skills=[A2ASkill(id="task-1", name="My Skill", description="Does something useful")],
94
+ )
95
+
96
+ # Sign an outgoing A2A request
97
+ signed = await integration.send_task(
98
+ target_url="https://remote-agent.example.com/a2a",
99
+ request_id=1,
100
+ task_id="task-001",
101
+ message={"role": "user", "parts": [{"type": "text", "text": "Hello"}]},
102
+ )
103
+
104
+ # Verify an incoming request
105
+ is_valid = await integration.verify_request(
106
+ method="POST",
107
+ url="https://my-agent.example.com/a2a",
108
+ headers=incoming_headers,
109
+ body=incoming_body,
110
+ )
111
+ ```
112
+
113
+ ## Examples
114
+
115
+ | Example | Description |
116
+ |---|---|
117
+ | [a2a_agent_did_discovery.py](examples/a2a_agent_did_discovery.py) | Agent publishes a DID-enriched AgentCard |
118
+ | [a2a_mutual_auth_demo.py](examples/a2a_mutual_auth_demo.py) | Two agents authenticate each other via DID HTTP Signatures |
119
+
120
+ ## Running Tests
121
+
122
+ ```bash
123
+ cd integrations/a2a
124
+ python -m pytest tests/ -q
125
+ ```
126
+
127
+ Full quality gates:
128
+
129
+ ```bash
130
+ python -m ruff check src/ tests/ examples/
131
+ python -m mypy src/
132
+ python -m pytest tests/ -q
133
+ ```
134
+
135
+ ## Architecture
136
+
137
+ ```
138
+ ┌─────────────────────────────────────────────────────────┐
139
+ │ Agent A (Client) │
140
+ │ ┌─────────────────────────────────────────────────┐ │
141
+ │ │ AgentDidA2AIntegration │ │
142
+ │ │ → build_agent_card() → /.well-known/agent.json │ │
143
+ │ │ → sign_request() → Signature + Signature-Input │ │
144
+ │ │ → send_task() → signed JSON-RPC POST │ │
145
+ │ └─────────────────────┬───────────────────────────┘ │
146
+ ├─────────────────────────┼───────────────────────────────┤
147
+ │ HTTPS + Ed25519 HTTP Message Signatures │
148
+ ├─────────────────────────┼───────────────────────────────┤
149
+ │ Agent B (Server) ▼ │
150
+ │ ┌─────────────────────────────────────────────────┐ │
151
+ │ │ AgentDidA2AIntegration │ │
152
+ │ │ → verify_request() → validate Signature header │ │
153
+ │ │ → resolve DID → fetch sender's public key │ │
154
+ │ │ → ✓ authenticated → process A2A task │ │
155
+ │ └─────────────────────────────────────────────────┘ │
156
+ └─────────────────────────────────────────────────────────┘
157
+ ```
158
+
159
+ ## How It Fits With A2A
160
+
161
+ This integration uses A2A's **authentication extension point**. The A2A spec expects an `authentication` field in the AgentCard with one or more schemes. Agent-DID adds `http-signature-did` as a scheme, meaning:
162
+
163
+ 1. The AgentCard declares the agent's DID and authentication key
164
+ 2. Outgoing requests include `Signature` and `Signature-Input` headers per IETF HTTP Message Signatures
165
+ 3. The receiving agent resolves the sender's DID to obtain the public key
166
+ 4. Signature verification proves request authenticity and integrity
167
+
168
+ This approach is **complementary** to OAuth 2.0, mTLS, or any other A2A auth scheme — agents can support multiple schemes simultaneously.
169
+
170
+ ## License
171
+
172
+ [Apache-2.0](../../LICENSE)
@@ -0,0 +1,155 @@
1
+ # Agent-DID × Google A2A Integration
2
+
3
+ > **Roadmap item:** F2-02 — Google A2A proof-of-concept
4
+
5
+ Agent-DID as the identity layer for the [Google A2A (Agent-to-Agent)](https://google.github.io/A2A/) protocol. This integration provides DID-based cryptographic identity for A2A agent discovery, request signing, and mutual authentication.
6
+
7
+ ## What This Solves
8
+
9
+ The A2A protocol is **auth-agnostic** — it defines how agents communicate (JSON-RPC 2.0 over HTTPS) and discover each other (AgentCards), but deliberately leaves authentication to the implementer. This creates a gap:
10
+
11
+ | A2A Gap | What Agent-DID Provides |
12
+ |---|---|
13
+ | No native cryptographic identity | DID anchored to the agent's model, prompt, and capabilities |
14
+ | AgentCard has no verifiable identity proof | DID fields embedded directly in the AgentCard |
15
+ | Request authenticity depends on external auth | Ed25519 HTTP Message Signatures on every JSON-RPC request |
16
+ | No standard for mutual agent authentication | DID-based verification of the counterparty agent |
17
+
18
+ ## Features
19
+
20
+ - **DID-Enriched AgentCards** — generate A2A-compliant AgentCards with embedded DID, controller, and `http-signature-did` authentication scheme
21
+ - **Request Signing** — sign outgoing `tasks/send`, `tasks/get` requests using Agent-DID HTTP Signatures
22
+ - **Request Verification** — verify incoming signed requests using the sender's DID
23
+ - **JSON-RPC Helpers** — Pydantic models for A2A JSON-RPC 2.0 messages
24
+ - **Observability** — structured, sanitized event emission for signing, verification, and card generation
25
+ - **Secure Defaults** — sensitive fields redacted, private network targets blocked, extra config fields rejected
26
+
27
+ ## Identity Composition Contract
28
+
29
+ The canonical A2A identity invariant for this repository is documented in [RFC-001-A2A-Identity-Composition-Contract.md](../../docs/RFC-001-A2A-Identity-Composition-Contract.md), co-drafted with APS during Public Review.
30
+
31
+ The contract defines how two identity surfaces compose:
32
+
33
+ - **Identity-at-rest**: the published AgentCard and its DID-published key material.
34
+ - **Identity-in-motion**: the per-request HTTP signature and its `keyid`.
35
+
36
+ An A2A verifier must treat those surfaces as a single trust boundary: the per-request signing key must compose with the AgentCard and DID document key material, and the signing key must be authorized for the operation context described in §6.3 of the contract.
37
+
38
+ Current integration behavior publishes DID-enriched AgentCards and signs/verifies A2A requests with Agent-DID HTTP signatures. The stricter SDK-level enforcement of §6.3 verification-relationship binding is tracked in [issue #34](https://github.com/edisonduran/agent-did/issues/34); the umbrella closure work for the composition contract remains tracked in [issue #30](https://github.com/edisonduran/agent-did/issues/30).
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ cd integrations/a2a
44
+ python -m pip install -e ".[dev]"
45
+ ```
46
+
47
+ Requires the Python SDK installed in dev mode:
48
+
49
+ ```bash
50
+ cd sdk-python
51
+ python -m pip install -e ".[dev]"
52
+ ```
53
+
54
+ ## Quick Start
55
+
56
+ ```python
57
+ from agent_did_sdk import AgentIdentity, AgentIdentityConfig, CreateAgentParams, InMemoryAgentRegistry
58
+ from agent_did_a2a import A2ASkill, create_agent_did_a2a_integration
59
+
60
+ # Create identity
61
+ AgentIdentity.set_registry(InMemoryAgentRegistry())
62
+ identity = AgentIdentity(AgentIdentityConfig(signer_address="0x..."))
63
+ runtime = await identity.create(
64
+ CreateAgentParams(name="MyAgent", core_model="gpt-4.1", system_prompt="...")
65
+ )
66
+
67
+ # Create A2A integration
68
+ integration = create_agent_did_a2a_integration(
69
+ agent_identity=identity,
70
+ runtime_identity=runtime,
71
+ )
72
+
73
+ # Generate AgentCard for /.well-known/agent.json
74
+ card = integration.agent_card_json(
75
+ agent_url="https://my-agent.example.com",
76
+ skills=[A2ASkill(id="task-1", name="My Skill", description="Does something useful")],
77
+ )
78
+
79
+ # Sign an outgoing A2A request
80
+ signed = await integration.send_task(
81
+ target_url="https://remote-agent.example.com/a2a",
82
+ request_id=1,
83
+ task_id="task-001",
84
+ message={"role": "user", "parts": [{"type": "text", "text": "Hello"}]},
85
+ )
86
+
87
+ # Verify an incoming request
88
+ is_valid = await integration.verify_request(
89
+ method="POST",
90
+ url="https://my-agent.example.com/a2a",
91
+ headers=incoming_headers,
92
+ body=incoming_body,
93
+ )
94
+ ```
95
+
96
+ ## Examples
97
+
98
+ | Example | Description |
99
+ |---|---|
100
+ | [a2a_agent_did_discovery.py](examples/a2a_agent_did_discovery.py) | Agent publishes a DID-enriched AgentCard |
101
+ | [a2a_mutual_auth_demo.py](examples/a2a_mutual_auth_demo.py) | Two agents authenticate each other via DID HTTP Signatures |
102
+
103
+ ## Running Tests
104
+
105
+ ```bash
106
+ cd integrations/a2a
107
+ python -m pytest tests/ -q
108
+ ```
109
+
110
+ Full quality gates:
111
+
112
+ ```bash
113
+ python -m ruff check src/ tests/ examples/
114
+ python -m mypy src/
115
+ python -m pytest tests/ -q
116
+ ```
117
+
118
+ ## Architecture
119
+
120
+ ```
121
+ ┌─────────────────────────────────────────────────────────┐
122
+ │ Agent A (Client) │
123
+ │ ┌─────────────────────────────────────────────────┐ │
124
+ │ │ AgentDidA2AIntegration │ │
125
+ │ │ → build_agent_card() → /.well-known/agent.json │ │
126
+ │ │ → sign_request() → Signature + Signature-Input │ │
127
+ │ │ → send_task() → signed JSON-RPC POST │ │
128
+ │ └─────────────────────┬───────────────────────────┘ │
129
+ ├─────────────────────────┼───────────────────────────────┤
130
+ │ HTTPS + Ed25519 HTTP Message Signatures │
131
+ ├─────────────────────────┼───────────────────────────────┤
132
+ │ Agent B (Server) ▼ │
133
+ │ ┌─────────────────────────────────────────────────┐ │
134
+ │ │ AgentDidA2AIntegration │ │
135
+ │ │ → verify_request() → validate Signature header │ │
136
+ │ │ → resolve DID → fetch sender's public key │ │
137
+ │ │ → ✓ authenticated → process A2A task │ │
138
+ │ └─────────────────────────────────────────────────┘ │
139
+ └─────────────────────────────────────────────────────────┘
140
+ ```
141
+
142
+ ## How It Fits With A2A
143
+
144
+ This integration uses A2A's **authentication extension point**. The A2A spec expects an `authentication` field in the AgentCard with one or more schemes. Agent-DID adds `http-signature-did` as a scheme, meaning:
145
+
146
+ 1. The AgentCard declares the agent's DID and authentication key
147
+ 2. Outgoing requests include `Signature` and `Signature-Input` headers per IETF HTTP Message Signatures
148
+ 3. The receiving agent resolves the sender's DID to obtain the public key
149
+ 4. Signature verification proves request authenticity and integrity
150
+
151
+ This approach is **complementary** to OAuth 2.0, mTLS, or any other A2A auth scheme — agents can support multiple schemes simultaneously.
152
+
153
+ ## License
154
+
155
+ [Apache-2.0](../../LICENSE)
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-did-a2a"
7
+ version = "1.0.0rc1"
8
+ description = "Google A2A protocol integration for Agent-DID — DID-based identity, AgentCard enrichment, and HTTP Signature authentication for agent-to-agent communication."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ authors = [
13
+ { name = "Edison Munoz", email = "edison.munoz@agent-did.org" }
14
+ ]
15
+ dependencies = [
16
+ "agent-did-sdk==1.0.0rc1",
17
+ "pydantic>=2.0",
18
+ ]
19
+
20
+ [project.optional-dependencies]
21
+ dev = [
22
+ "build>=1.2",
23
+ "pytest>=8.0,<9.0",
24
+ "pytest-asyncio>=0.23,<1.0",
25
+ "ruff>=0.4",
26
+ "mypy>=1.10",
27
+ ]
28
+
29
+ [tool.setuptools.packages.find]
30
+ where = ["src"]
31
+
32
+ [tool.pytest.ini_options]
33
+ testpaths = ["tests"]
34
+ asyncio_mode = "auto"
35
+
36
+ [tool.ruff]
37
+ target-version = "py310"
38
+ line-length = 120
39
+
40
+ [tool.ruff.lint]
41
+ select = ["E", "F", "I", "W", "UP"]
42
+
43
+ [tool.mypy]
44
+ strict = true
45
+ python_version = "3.10"
46
+
47
+ [tool.agent-did]
48
+ status = "functional"
49
+ roadmap = "F2-02"
50
+ implementation = "proof-of-concept"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,62 @@
1
+ """Public package surface for the Agent-DID A2A integration."""
2
+
3
+ from .agent_card import A2AAgentCard, A2AAuthenticationInfo, A2ASkill, agent_card_to_json, build_agent_card
4
+ from .config import AgentDidA2AConfig, AgentDidA2AExposureConfig
5
+ from .context import build_agent_did_a2a_context
6
+ from .integration import AgentDidA2AIntegration, create_agent_did_a2a_integration
7
+ from .jsonrpc import (
8
+ JsonRpcError,
9
+ JsonRpcRequest,
10
+ JsonRpcResponse,
11
+ SignedA2ARequest,
12
+ build_task_get_request,
13
+ build_task_send_request,
14
+ parse_jsonrpc_response,
15
+ sign_a2a_request,
16
+ verify_a2a_request,
17
+ )
18
+ from .observability import (
19
+ AgentDidA2AObservabilityEvent,
20
+ compose_event_handlers,
21
+ create_json_logger_event_handler,
22
+ serialize_observability_event,
23
+ )
24
+ from .snapshot import AgentDidIdentitySnapshot, build_agent_did_identity_snapshot
25
+
26
+ PACKAGE_STATUS = "functional"
27
+
28
+ __all__ = [
29
+ "PACKAGE_STATUS",
30
+ # Agent Card
31
+ "A2AAgentCard",
32
+ "A2AAuthenticationInfo",
33
+ "A2ASkill",
34
+ "build_agent_card",
35
+ "agent_card_to_json",
36
+ # Config
37
+ "AgentDidA2AConfig",
38
+ "AgentDidA2AExposureConfig",
39
+ # Context
40
+ "build_agent_did_a2a_context",
41
+ # Integration
42
+ "AgentDidA2AIntegration",
43
+ "create_agent_did_a2a_integration",
44
+ # JSON-RPC
45
+ "JsonRpcError",
46
+ "JsonRpcRequest",
47
+ "JsonRpcResponse",
48
+ "SignedA2ARequest",
49
+ "build_task_get_request",
50
+ "build_task_send_request",
51
+ "parse_jsonrpc_response",
52
+ "sign_a2a_request",
53
+ "verify_a2a_request",
54
+ # Observability
55
+ "AgentDidA2AObservabilityEvent",
56
+ "compose_event_handlers",
57
+ "create_json_logger_event_handler",
58
+ "serialize_observability_event",
59
+ # Snapshot
60
+ "AgentDidIdentitySnapshot",
61
+ "build_agent_did_identity_snapshot",
62
+ ]
@@ -0,0 +1,108 @@
1
+ """A2A AgentCard builder enriched with Agent-DID identity.
2
+
3
+ An AgentCard is the discovery document that A2A agents expose at
4
+ ``/.well-known/agent.json``. This module generates spec-compliant
5
+ AgentCards that embed the agent's DID, verification methods, and
6
+ DID-based HTTP Signature authentication scheme.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import Any
12
+
13
+ from pydantic import BaseModel, ConfigDict, Field
14
+
15
+ from .config import AgentDidA2AConfig
16
+ from .snapshot import AgentDidIdentitySnapshot
17
+
18
+
19
+ class A2ASkill(BaseModel):
20
+ """An A2A skill declaration."""
21
+
22
+ model_config = ConfigDict(extra="allow")
23
+
24
+ id: str
25
+ name: str
26
+ description: str
27
+ input_modes: list[str] = Field(default_factory=lambda: ["text/plain"])
28
+ output_modes: list[str] = Field(default_factory=lambda: ["text/plain"])
29
+ tags: list[str] = Field(default_factory=list)
30
+
31
+
32
+ class A2AAuthenticationInfo(BaseModel):
33
+ """A2A authentication info block with Agent-DID extension."""
34
+
35
+ model_config = ConfigDict(extra="allow")
36
+
37
+ schemes: list[str] = Field(default_factory=list)
38
+ credentials: str | None = None
39
+
40
+
41
+ class A2AAgentCard(BaseModel):
42
+ """A2A-compliant AgentCard enriched with Agent-DID identity.
43
+
44
+ Standard A2A fields:
45
+ name, description, url, skills, capabilities, authentication
46
+
47
+ Agent-DID extensions:
48
+ did, controller, authentication_key_id, verification_endpoint
49
+ """
50
+
51
+ model_config = ConfigDict(extra="allow")
52
+
53
+ # --- Standard A2A fields ---
54
+ name: str
55
+ description: str | None = None
56
+ url: str
57
+ version: str = "0.1.0"
58
+ skills: list[A2ASkill] = Field(default_factory=list)
59
+ capabilities: dict[str, bool] = Field(default_factory=dict)
60
+ authentication: A2AAuthenticationInfo = Field(default_factory=A2AAuthenticationInfo)
61
+
62
+ # --- Agent-DID identity extensions ---
63
+ did: str
64
+ controller: str
65
+ authentication_key_id: str | None = None
66
+ verification_endpoint: str | None = None
67
+
68
+
69
+ def build_agent_card(
70
+ *,
71
+ identity_snapshot: AgentDidIdentitySnapshot,
72
+ agent_url: str,
73
+ skills: list[A2ASkill] | None = None,
74
+ capabilities: dict[str, bool] | None = None,
75
+ config: AgentDidA2AConfig | None = None,
76
+ verification_endpoint: str | None = None,
77
+ ) -> A2AAgentCard:
78
+ """Build an A2A AgentCard enriched with Agent-DID identity.
79
+
80
+ The card declares ``http-signature-did`` as an authentication scheme
81
+ so that consuming agents know they can verify the agent's identity
82
+ via DID-based HTTP Message Signatures.
83
+ """
84
+
85
+ effective_config = config or AgentDidA2AConfig()
86
+
87
+ schemes = ["http-signature-did"]
88
+ for extra in effective_config.additional_auth_schemes:
89
+ schemes.append(extra.scheme)
90
+
91
+ return A2AAgentCard(
92
+ name=identity_snapshot.name,
93
+ description=identity_snapshot.description,
94
+ url=agent_url,
95
+ version=identity_snapshot.version,
96
+ skills=skills or [],
97
+ capabilities=capabilities or {"streaming": False, "pushNotifications": False},
98
+ authentication=A2AAuthenticationInfo(schemes=schemes),
99
+ did=identity_snapshot.did,
100
+ controller=identity_snapshot.controller,
101
+ authentication_key_id=identity_snapshot.authentication_key_id,
102
+ verification_endpoint=verification_endpoint,
103
+ )
104
+
105
+
106
+ def agent_card_to_json(card: A2AAgentCard) -> dict[str, Any]:
107
+ """Serialize an AgentCard to a JSON-compatible dict for ``/.well-known/agent.json``."""
108
+ return card.model_dump(exclude_none=True)
@@ -0,0 +1,39 @@
1
+ """Configuration models for the Agent-DID A2A integration."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pydantic import BaseModel, ConfigDict, Field
6
+
7
+
8
+ class AgentDidA2AAuthScheme(BaseModel):
9
+ """A2A-compatible authentication scheme declaring DID-based HTTP Signatures."""
10
+
11
+ model_config = ConfigDict(extra="forbid")
12
+
13
+ scheme: str = "https"
14
+ credentials: str | None = None
15
+
16
+
17
+ class AgentDidA2AExposureConfig(BaseModel):
18
+ """Feature exposure flags with secure defaults for A2A operations."""
19
+
20
+ model_config = ConfigDict(extra="forbid")
21
+
22
+ sign_requests: bool = True
23
+ verify_requests: bool = True
24
+ enrich_agent_card: bool = True
25
+ resolve_remote_did: bool = True
26
+ document_history: bool = False
27
+ rotate_keys: bool = False
28
+
29
+
30
+ class AgentDidA2AConfig(BaseModel):
31
+ """Top-level integration config consumed by the public factory."""
32
+
33
+ model_config = ConfigDict(extra="forbid")
34
+
35
+ expose: AgentDidA2AExposureConfig = Field(default_factory=AgentDidA2AExposureConfig)
36
+ agent_card_url: str = "/.well-known/agent.json"
37
+ allow_private_network_targets: bool = False
38
+ default_request_timeout_seconds: int = 30
39
+ additional_auth_schemes: list[AgentDidA2AAuthScheme] = Field(default_factory=list)
@@ -0,0 +1,30 @@
1
+ """A2A session context helpers with DID identity injection."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .snapshot import AgentDidIdentitySnapshot
6
+
7
+
8
+ def build_agent_did_a2a_context(snapshot: AgentDidIdentitySnapshot) -> str:
9
+ """Build a human-readable A2A context block for system prompts or session metadata."""
10
+
11
+ capabilities = ", ".join(snapshot.capabilities) if snapshot.capabilities else "none declared"
12
+
13
+ lines = [
14
+ "Agent-DID A2A identity context:",
15
+ f"- DID: {snapshot.did}",
16
+ f"- Controller: {snapshot.controller}",
17
+ f"- Name: {snapshot.name}",
18
+ f"- Version: {snapshot.version}",
19
+ f"- Capabilities: {capabilities}",
20
+ f"- Authentication key: {snapshot.authentication_key_id or 'none'}",
21
+ "- All outgoing A2A requests are signed with HTTP Message Signatures.",
22
+ "- Verify incoming AgentCards against the declared DID before delegating tasks.",
23
+ ]
24
+
25
+ if snapshot.description:
26
+ lines.insert(4, f"- Description: {snapshot.description}")
27
+ if snapshot.member_of:
28
+ lines.insert(-2, f"- Member of: {snapshot.member_of}")
29
+
30
+ return "\n".join(lines)