Skip to content

Commit 0ab21b9

Browse files
committed
Update types
1 parent 2444034 commit 0ab21b9

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

src/a2a/types.py

Lines changed: 35 additions & 30 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.
@@ -177,12 +178,12 @@ class AuthorizationCodeOAuthFlow(A2ABaseModel):
177178
Defines configuration details for the OAuth 2.0 Authorization Code flow.
178179
"""
179180

180-
authorization_url: str
181+
authorization_url: AnyUrl
181182
"""
182183
The authorization URL to be used for this flow.
183184
This MUST be a URL and use TLS.
184185
"""
185-
refresh_url: str | None = None
186+
refresh_url: AnyUrl | None = None
186187
"""
187188
The URL to be used for obtaining refresh tokens.
188189
This MUST be a URL and use TLS.
@@ -192,7 +193,7 @@ class AuthorizationCodeOAuthFlow(A2ABaseModel):
192193
The available scopes for the OAuth2 security scheme. A map between the scope
193194
name and a short description for it.
194195
"""
195-
token_url: str
196+
token_url: AnyUrl
196197
"""
197198
The token URL to be used for this flow.
198199
This MUST be a URL and use TLS.
@@ -204,7 +205,7 @@ class ClientCredentialsOAuthFlow(A2ABaseModel):
204205
Defines configuration details for the OAuth 2.0 Client Credentials flow.
205206
"""
206207

207-
refresh_url: str | None = None
208+
refresh_url: AnyUrl | None = None
208209
"""
209210
The URL to be used for obtaining refresh tokens. This MUST be a URL.
210211
"""
@@ -213,7 +214,7 @@ class ClientCredentialsOAuthFlow(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. This MUST be a URL.
219220
"""
@@ -369,7 +370,7 @@ class FileWithUri(A2ABaseModel):
369370
"""
370371
An optional name for the file (e.g., "document.pdf").
371372
"""
372-
uri: str
373+
uri: AnyUrl
373374
"""
374375
A URL pointing to the file's content.
375376
"""
@@ -425,11 +426,11 @@ class ImplicitOAuthFlow(A2ABaseModel):
425426
Defines configuration details for the OAuth 2.0 Implicit flow.
426427
"""
427428

428-
authorization_url: str
429+
authorization_url: AnyUrl
429430
"""
430431
The authorization URL to be used for this flow. This MUST be a URL.
431432
"""
432-
refresh_url: str | None = None
433+
refresh_url: AnyUrl | None = None
433434
"""
434435
The URL to be used for obtaining refresh tokens. This MUST be a URL.
435436
"""
@@ -698,7 +699,7 @@ class OpenIdConnectSecurityScheme(A2ABaseModel):
698699
"""
699700
An optional description for the security scheme.
700701
"""
701-
open_id_connect_url: str
702+
open_id_connect_url: AnyUrl
702703
"""
703704
The OpenID Connect Discovery URL for the OIDC provider's metadata.
704705
"""
@@ -724,7 +725,7 @@ class PasswordOAuthFlow(A2ABaseModel):
724725
Defines configuration details for the OAuth 2.0 Resource Owner Password flow.
725726
"""
726727

727-
refresh_url: str | None = None
728+
refresh_url: AnyUrl | None = None
728729
"""
729730
The URL to be used for obtaining refresh tokens. This MUST be a URL.
730731
"""
@@ -733,7 +734,7 @@ class PasswordOAuthFlow(A2ABaseModel):
733734
The available scopes for the OAuth2 security scheme. A map between the scope
734735
name and a short description for it.
735736
"""
736-
token_url: str
737+
token_url: AnyUrl
737738
"""
738739
The token URL to be used for this flow. This MUST be a URL.
739740
"""
@@ -748,7 +749,7 @@ class PushNotificationAuthenticationInfo(A2ABaseModel):
748749
"""
749750
Optional credentials required by the push notification endpoint.
750751
"""
751-
schemes: list[str]
752+
schemes: list[str] = Field(..., min_length=1)
752753
"""
753754
A list of supported authentication schemes (e.g., 'Basic', 'Bearer').
754755
"""
@@ -772,7 +773,7 @@ class PushNotificationConfig(A2ABaseModel):
772773
"""
773774
A unique token for this task or session to validate incoming push notifications.
774775
"""
775-
url: str
776+
url: AnyUrl
776777
"""
777778
The callback URL where the agent should send push notifications.
778779
"""
@@ -1326,7 +1327,7 @@ class Artifact(A2ABaseModel):
13261327
"""
13271328
An optional, human-readable name for the artifact.
13281329
"""
1329-
parts: list[Part]
1330+
parts: list[Part] = Field(..., min_length=1)
13301331
"""
13311332
An array of content parts that make up the artifact.
13321333
"""
@@ -1390,7 +1391,7 @@ class Message(A2ABaseModel):
13901391
"""
13911392
Optional metadata for extensions. The key is an extension-specific identifier.
13921393
"""
1393-
parts: list[Part]
1394+
parts: list[Part] = Field(..., min_length=1)
13941395
"""
13951396
An array of content parts that form the message body. A message can be
13961397
composed of multiple parts of different types (e.g., text and files).
@@ -1574,7 +1575,7 @@ class TaskStatus(A2ABaseModel):
15741575
"""
15751576
The current state of the task's lifecycle.
15761577
"""
1577-
timestamp: str | None = Field(
1578+
timestamp: datetime | None = Field(
15781579
default=None, examples=['2023-10-27T10:00:00Z']
15791580
)
15801581
"""
@@ -1668,12 +1669,12 @@ class AgentCard(A2ABaseModel):
16681669
"""
16691670
A declaration of optional capabilities supported by the agent.
16701671
"""
1671-
default_input_modes: list[str]
1672+
default_input_modes: list[str] = Field(..., min_length=1)
16721673
"""
16731674
Default set of supported input MIME types for all skills, which can be
16741675
overridden on a per-skill basis.
16751676
"""
1676-
default_output_modes: list[str]
1677+
default_output_modes: list[str] = Field(..., min_length=1)
16771678
"""
16781679
Default set of supported output MIME types for all skills, which can be
16791680
overridden on a per-skill basis.
@@ -1685,11 +1686,11 @@ class AgentCard(A2ABaseModel):
16851686
A human-readable description of the agent, assisting users and other agents
16861687
in understanding its purpose.
16871688
"""
1688-
documentation_url: str | None = None
1689+
documentation_url: AnyUrl | None = None
16891690
"""
16901691
An optional URL to the agent's documentation.
16911692
"""
1692-
icon_url: str | None = None
1693+
icon_url: AnyUrl | None = None
16931694
"""
16941695
An optional URL to an icon for the agent.
16951696
"""
@@ -1730,7 +1731,7 @@ class AgentCard(A2ABaseModel):
17301731
"""
17311732
JSON Web Signatures computed for this AgentCard.
17321733
"""
1733-
skills: list[AgentSkill]
1734+
skills: list[AgentSkill] = Field(..., min_length=1)
17341735
"""
17351736
The set of skills, or distinct capabilities, that the agent can perform.
17361737
"""
@@ -1739,14 +1740,18 @@ class AgentCard(A2ABaseModel):
17391740
If true, the agent can provide an extended agent card with additional details
17401741
to authenticated users. Defaults to false.
17411742
"""
1742-
url: str = Field(..., examples=['https://api.example.com/a2a/v1'])
1743+
url: AnyUrl = Field(..., examples=['https://api.example.com/a2a/v1'])
17431744
"""
17441745
The preferred endpoint URL for interacting with the agent.
17451746
This URL MUST support the transport specified by 'preferredTransport'.
17461747
"""
1747-
version: str = Field(..., examples=['1.0.0'])
1748+
version: str = Field(
1749+
...,
1750+
examples=['1.0.0'],
1751+
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-]+)*))?$',
1752+
)
17481753
"""
1749-
The agent's own version number. The format is defined by the provider.
1754+
The agent's own version number. Semantic Versioning MUST be used.
17501755
"""
17511756

17521757

0 commit comments

Comments
 (0)