Skip to content

Commit 0d9cf0e

Browse files
committed
Update Types from spec restrictions
1 parent 74dcdb5 commit 0d9cf0e

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed

src/a2a/types.py

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# generated by datamodel-codegen:
2-
# filename: https://raw.githubusercontent.com/a2aproject/A2A/refs/heads/main/specification/json/a2a.json
2+
# filename: https://raw.githubusercontent.com/a2aproject/A2A/refs/heads/jsdoc-strings/specification/json/a2a.json
33

44
from __future__ import annotations
55

6+
from datetime import datetime
67
from enum import Enum
78
from typing import Any, Literal
89

9-
from pydantic import Field, RootModel
10+
from pydantic import AnyUrl, Field, RootModel
1011

1112
from a2a._base import A2ABaseModel
1213

@@ -87,7 +88,7 @@ class AgentExtension(A2ABaseModel):
8788
If true, the client must understand and comply with the extension's requirements
8889
to interact with the agent.
8990
"""
90-
uri: str
91+
uri: AnyUrl
9192
"""
9293
The unique URI identifying the extension.
9394
"""
@@ -103,7 +104,7 @@ class AgentInterface(A2ABaseModel):
103104
"""
104105
The transport protocol supported at this URL.
105106
"""
106-
url: str = Field(
107+
url: AnyUrl = Field(
107108
...,
108109
examples=[
109110
'https://api.example.com/a2a/v1',
@@ -125,7 +126,7 @@ class AgentProvider(A2ABaseModel):
125126
"""
126127
The name of the agent provider's organization.
127128
"""
128-
url: str
129+
url: AnyUrl
129130
"""
130131
A URL for the agent provider's website or relevant documentation.
131132
"""
@@ -165,7 +166,7 @@ class AgentSkill(A2ABaseModel):
165166
The set of supported output MIME types for this skill, overriding the agent's defaults.
166167
"""
167168
tags: list[str] = Field(
168-
..., examples=[['cooking', 'customer support', 'billing']]
169+
..., examples=[['cooking', 'customer support', 'billing']], min_length=1
169170
)
170171
"""
171172
A set of keywords describing the skill's capabilities.
@@ -187,7 +188,7 @@ class AuthenticatedExtendedCardNotConfiguredError(A2ABaseModel):
187188
A primitive or structured value containing additional information about the error.
188189
This may be omitted.
189190
"""
190-
message: str | None = 'Authenticated Extended Card not configured'
191+
message: str | None = 'Authenticated Extended Card is not configured'
191192
"""
192193
The error message.
193194
"""
@@ -198,12 +199,12 @@ class AuthorizationCodeOAuthFlow(A2ABaseModel):
198199
Defines configuration details for the OAuth 2.0 Authorization Code flow.
199200
"""
200201

201-
authorization_url: str
202+
authorization_url: AnyUrl
202203
"""
203204
The authorization URL to be used for this flow.
204205
This MUST be a URL and use TLS.
205206
"""
206-
refresh_url: str | None = None
207+
refresh_url: AnyUrl | None = None
207208
"""
208209
The URL to be used for obtaining refresh tokens.
209210
This MUST be a URL and use TLS.
@@ -213,7 +214,7 @@ class AuthorizationCodeOAuthFlow(A2ABaseModel):
213214
The available scopes for the OAuth2 security scheme. A map between the scope
214215
name and a short description for it.
215216
"""
216-
token_url: str
217+
token_url: AnyUrl
217218
"""
218219
The token URL to be used for this flow.
219220
This MUST be a URL and use TLS.
@@ -225,7 +226,7 @@ class ClientCredentialsOAuthFlow(A2ABaseModel):
225226
Defines configuration details for the OAuth 2.0 Client Credentials flow.
226227
"""
227228

228-
refresh_url: str | None = None
229+
refresh_url: AnyUrl | None = None
229230
"""
230231
The URL to be used for obtaining refresh tokens. This MUST be a URL.
231232
"""
@@ -234,7 +235,7 @@ class ClientCredentialsOAuthFlow(A2ABaseModel):
234235
The available scopes for the OAuth2 security scheme. A map between the scope
235236
name and a short description for it.
236237
"""
237-
token_url: str
238+
token_url: AnyUrl
238239
"""
239240
The token URL to be used for this flow. This MUST be a URL.
240241
"""
@@ -390,7 +391,7 @@ class FileWithUri(A2ABaseModel):
390391
"""
391392
An optional name for the file (e.g., "document.pdf").
392393
"""
393-
uri: str
394+
uri: AnyUrl
394395
"""
395396
A URL pointing to the file's content.
396397
"""
@@ -467,11 +468,11 @@ class ImplicitOAuthFlow(A2ABaseModel):
467468
Defines configuration details for the OAuth 2.0 Implicit flow.
468469
"""
469470

470-
authorization_url: str
471+
authorization_url: AnyUrl
471472
"""
472473
The authorization URL to be used for this flow. This MUST be a URL.
473474
"""
474-
refresh_url: str | None = None
475+
refresh_url: AnyUrl | None = None
475476
"""
476477
The URL to be used for obtaining refresh tokens. This MUST be a URL.
477478
"""
@@ -740,7 +741,7 @@ class OpenIdConnectSecurityScheme(A2ABaseModel):
740741
"""
741742
An optional description for the security scheme.
742743
"""
743-
open_id_connect_url: str
744+
open_id_connect_url: AnyUrl
744745
"""
745746
The OpenID Connect Discovery URL for the OIDC provider's metadata.
746747
"""
@@ -766,7 +767,7 @@ class PasswordOAuthFlow(A2ABaseModel):
766767
Defines configuration details for the OAuth 2.0 Resource Owner Password flow.
767768
"""
768769

769-
refresh_url: str | None = None
770+
refresh_url: AnyUrl | None = None
770771
"""
771772
The URL to be used for obtaining refresh tokens. This MUST be a URL.
772773
"""
@@ -775,7 +776,7 @@ class PasswordOAuthFlow(A2ABaseModel):
775776
The available scopes for the OAuth2 security scheme. A map between the scope
776777
name and a short description for it.
777778
"""
778-
token_url: str
779+
token_url: AnyUrl
779780
"""
780781
The token URL to be used for this flow. This MUST be a URL.
781782
"""
@@ -790,7 +791,7 @@ class PushNotificationAuthenticationInfo(A2ABaseModel):
790791
"""
791792
Optional credentials required by the push notification endpoint.
792793
"""
793-
schemes: list[str]
794+
schemes: list[str] = Field(..., min_length=1)
794795
"""
795796
A list of supported authentication schemes (e.g., 'Basic', 'Bearer').
796797
"""
@@ -814,7 +815,7 @@ class PushNotificationConfig(A2ABaseModel):
814815
"""
815816
A unique token for this task or session to validate incoming push notifications.
816817
"""
817-
url: str
818+
url: AnyUrl
818819
"""
819820
The callback URL where the agent should send push notifications.
820821
"""
@@ -1371,7 +1372,7 @@ class Artifact(A2ABaseModel):
13711372
"""
13721373
An optional, human-readable name for the artifact.
13731374
"""
1374-
parts: list[Part]
1375+
parts: list[Part] = Field(..., min_length=1)
13751376
"""
13761377
An array of content parts that make up the artifact.
13771378
"""
@@ -1435,7 +1436,7 @@ class Message(A2ABaseModel):
14351436
"""
14361437
Optional metadata for extensions. The key is an extension-specific identifier.
14371438
"""
1438-
parts: list[Part]
1439+
parts: list[Part] = Field(..., min_length=1)
14391440
"""
14401441
An array of content parts that form the message body. A message can be
14411442
composed of multiple parts of different types (e.g., text and files).
@@ -1619,7 +1620,7 @@ class TaskStatus(A2ABaseModel):
16191620
"""
16201621
The current state of the task's lifecycle.
16211622
"""
1622-
timestamp: str | None = Field(
1623+
timestamp: datetime | None = Field(
16231624
default=None, examples=['2023-10-27T10:00:00Z']
16241625
)
16251626
"""
@@ -1715,12 +1716,12 @@ class AgentCard(A2ABaseModel):
17151716
"""
17161717
A declaration of optional capabilities supported by the agent.
17171718
"""
1718-
default_input_modes: list[str]
1719+
default_input_modes: list[str] = Field(..., min_length=1)
17191720
"""
17201721
Default set of supported input MIME types for all skills, which can be
17211722
overridden on a per-skill basis.
17221723
"""
1723-
default_output_modes: list[str]
1724+
default_output_modes: list[str] = Field(..., min_length=1)
17241725
"""
17251726
Default set of supported output MIME types for all skills, which can be
17261727
overridden on a per-skill basis.
@@ -1732,11 +1733,11 @@ class AgentCard(A2ABaseModel):
17321733
A human-readable description of the agent, assisting users and other agents
17331734
in understanding its purpose.
17341735
"""
1735-
documentation_url: str | None = None
1736+
documentation_url: AnyUrl | None = None
17361737
"""
17371738
An optional URL to the agent's documentation.
17381739
"""
1739-
icon_url: str | None = None
1740+
icon_url: AnyUrl | None = None
17401741
"""
17411742
An optional URL to an icon for the agent.
17421743
"""
@@ -1777,7 +1778,7 @@ class AgentCard(A2ABaseModel):
17771778
"""
17781779
JSON Web Signatures computed for this AgentCard.
17791780
"""
1780-
skills: list[AgentSkill]
1781+
skills: list[AgentSkill] = Field(..., min_length=1)
17811782
"""
17821783
The set of skills, or distinct capabilities, that the agent can perform.
17831784
"""
@@ -1786,14 +1787,18 @@ class AgentCard(A2ABaseModel):
17861787
If true, the agent can provide an extended agent card with additional details
17871788
to authenticated users. Defaults to false.
17881789
"""
1789-
url: str = Field(..., examples=['https://api.example.com/a2a/v1'])
1790+
url: AnyUrl = Field(..., examples=['https://api.example.com/a2a/v1'])
17901791
"""
17911792
The preferred endpoint URL for interacting with the agent.
17921793
This URL MUST support the transport specified by 'preferredTransport'.
17931794
"""
1794-
version: str = Field(..., examples=['1.0.0'])
1795+
version: str = Field(
1796+
...,
1797+
examples=['1.0.0'],
1798+
pattern='^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$',
1799+
)
17951800
"""
1796-
The agent's own version number. The format is defined by the provider.
1801+
The agent's own version number. Semantic Versioning MUST be used.
17971802
"""
17981803

17991804

0 commit comments

Comments
 (0)