Skip to content

Commit e87bb3d

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

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
@@ -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,7 +504,52 @@ class JSONRPCSuccessResponse(BaseModel):
484504
"""
485505

486506

487-
class Role(str, Enum):
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+
552+
class Role(Enum):
488553
"""
489554
Message sender's role
490555
"""
@@ -820,6 +885,25 @@ class A2AError(
820885
)
821886

822887

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

10641148

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

0 commit comments

Comments
 (0)