Skip to content

Commit d11ca2d

Browse files
committed
build: locally generate pydantic v2 models via datamodel-codegen
Signed-off-by: Shingo OKAWA <[email protected]>
1 parent 20f0826 commit d11ca2d

File tree

1 file changed

+100
-1
lines changed

1 file changed

+100
-1
lines changed

src/a2a/types.py

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# generated by datamodel-codegen:
2-
# filename: https://raw.githubusercontent.com/google/A2A/refs/heads/main/specification/json/a2a.json
2+
# filename: https://raw.githubusercontent.com/ognis1205/A2A/refs/heads/poc/agent-catalog/specification/json/a2a.json
33

44
from __future__ import annotations
55

@@ -62,6 +62,26 @@ class AgentCapabilities(BaseModel):
6262
"""
6363

6464

65+
class AgentLinkTarget(BaseModel):
66+
"""
67+
Represents a Link Target Object that specifically points to an agent card
68+
in JSON format. This is a specialization of the generic LinkTarget,
69+
with a fixed media type of "application/json" as required for agent metadata.
70+
"""
71+
72+
href: str
73+
"""
74+
The target URI of the link.
75+
MUST be a valid URI reference (RFC 3986).
76+
SHOULD NOT be a relative reference.
77+
"""
78+
type: Literal['application/json'] = 'application/json'
79+
"""
80+
The media type of the target resource.
81+
MUST be "application/json" to indicate the agent card is in JSON format.
82+
"""
83+
84+
6585
class AgentProvider(BaseModel):
6686
"""
6787
Represents the service provider of an agent.
@@ -484,6 +504,51 @@ class JSONRPCResult(BaseModel):
484504
"""
485505

486506

507+
class LinkContext(BaseModel):
508+
"""
509+
Represents a Link Context Object as defined in RFC 9264 Section 4.2.2.
510+
See: https://www.rfc-editor.org/rfc/rfc9264#section-4.2.2
511+
"""
512+
513+
anchor: str | None = None
514+
"""
515+
The URI reference representing the link context.
516+
MUST be a valid URI reference (RFC 3986).
517+
SHOULD NOT be a relative reference.
518+
"""
519+
520+
521+
class LinkTarget(BaseModel):
522+
"""
523+
Represents a Link Target Object as defined in RFC 9264 Section 4.2.3.
524+
See: https://www.rfc-editor.org/rfc/rfc9264#section-4.2.3
525+
526+
While not a complete implementation of all target attributes defined in
527+
RFC 8288, this interface captures the minimal structure required for the
528+
current use case and leaves room for extension.
529+
"""
530+
531+
href: str
532+
"""
533+
The target URI of the link.
534+
MUST be a valid URI reference (RFC 3986).
535+
SHOULD NOT be a relative reference.
536+
"""
537+
538+
539+
class Linkset(BaseModel):
540+
"""
541+
Represents a Linkset document as defined in RFC 9264.
542+
See: https://www.rfc-editor.org/rfc/rfc9264
543+
"""
544+
545+
linkset: list[LinkContext]
546+
"""
547+
An array of Link Context Objects.
548+
Each object defines a set of related links for a given anchor (context URI).
549+
"""
550+
551+
487552
class Role(Enum):
488553
"""
489554
Message sender's role
@@ -816,6 +881,25 @@ class A2AError(
816881
)
817882

818883

884+
class AgentLinkContext(BaseModel):
885+
"""
886+
Represents a Link Context object specifically for agents.
887+
Extends the general LinkContext structure by requiring an `anchor` field
888+
and including a `describedby` relation to link to the agent's card endpoint.
889+
"""
890+
891+
anchor: str
892+
"""
893+
A URI reference identifying the agent's endpoint.
894+
MUST be a valid URI reference (RFC 3986).
895+
SHOULD NOT be a relative reference.
896+
"""
897+
describedby: list[AgentLinkTarget]
898+
"""
899+
A list of links that describe the agent's metadata (agent card).
900+
"""
901+
902+
819903
class CancelTaskRequest(BaseModel):
820904
"""
821905
JSON-RPC request model for the 'tasks/cancel' method.
@@ -1058,6 +1142,21 @@ class SetTaskPushNotificationConfigSuccessResponse(BaseModel):
10581142
"""
10591143

10601144

1145+
class AgentCatalog(BaseModel):
1146+
"""
1147+
Represents an API Catalog document, extending the Linkset structure defined in RFC 9264.
1148+
This specialized catalog uses AgentLinkContext objects to describe agent-specific metadata.
1149+
See: https://www.ietf.org/archive/id/draft-ietf-httpapi-api-catalog-08.html
1150+
"""
1151+
1152+
linkset: list[AgentLinkContext]
1153+
"""
1154+
An array of AgentLinkContext objects.
1155+
Each object uses the `anchor` to specify the agent’s endpoint and the `describedby` link to
1156+
indicate the endpoint of its agent card.
1157+
"""
1158+
1159+
10611160
class Artifact(BaseModel):
10621161
"""
10631162
Represents an artifact generated for a task.

0 commit comments

Comments
 (0)