Skip to content

Commit 8774841

Browse files
committed
Update types
1 parent 0ab21b9 commit 8774841

File tree

1 file changed

+105
-31
lines changed

1 file changed

+105
-31
lines changed

src/a2a/types.py

Lines changed: 105 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class AgentExtension(A2ABaseModel):
8888
If true, the client must understand and comply with the extension's requirements
8989
to interact with the agent.
9090
"""
91-
uri: AnyUrl
91+
uri: str
9292
"""
9393
The unique URI identifying the extension.
9494
"""
@@ -104,7 +104,7 @@ class AgentInterface(A2ABaseModel):
104104
"""
105105
The transport protocol supported at this URL.
106106
"""
107-
url: AnyUrl = Field(
107+
url: str = Field(
108108
...,
109109
examples=[
110110
'https://api.example.com/a2a/v1',
@@ -166,24 +166,44 @@ class AgentSkill(A2ABaseModel):
166166
The set of supported output MIME types for this skill, overriding the agent's defaults.
167167
"""
168168
tags: list[str] = Field(
169-
..., examples=[['cooking', 'customer support', 'billing']], min_length=1
169+
..., examples=[['cooking', 'customer support', 'billing']]
170170
)
171171
"""
172172
A set of keywords describing the skill's capabilities.
173173
"""
174174

175175

176+
class AuthenticatedExtendedCardNotConfiguredError(A2ABaseModel):
177+
"""
178+
An A2A-specific error indicating that the agent does not have an Authenticated Extended Card configured
179+
"""
180+
181+
code: Literal[-32007] = -32007
182+
"""
183+
The error code for when an authenticated extended card is not configured.
184+
"""
185+
data: Any | None = None
186+
"""
187+
A primitive or structured value containing additional information about the error.
188+
This may be omitted.
189+
"""
190+
message: str | None = 'Authenticated Extended Card is not configured'
191+
"""
192+
The error message.
193+
"""
194+
195+
176196
class AuthorizationCodeOAuthFlow(A2ABaseModel):
177197
"""
178198
Defines configuration details for the OAuth 2.0 Authorization Code flow.
179199
"""
180200

181-
authorization_url: AnyUrl
201+
authorization_url: str
182202
"""
183203
The authorization URL to be used for this flow.
184204
This MUST be a URL and use TLS.
185205
"""
186-
refresh_url: AnyUrl | None = None
206+
refresh_url: str | None = None
187207
"""
188208
The URL to be used for obtaining refresh tokens.
189209
This MUST be a URL and use TLS.
@@ -193,7 +213,7 @@ class AuthorizationCodeOAuthFlow(A2ABaseModel):
193213
The available scopes for the OAuth2 security scheme. A map between the scope
194214
name and a short description for it.
195215
"""
196-
token_url: AnyUrl
216+
token_url: str
197217
"""
198218
The token URL to be used for this flow.
199219
This MUST be a URL and use TLS.
@@ -205,7 +225,7 @@ class ClientCredentialsOAuthFlow(A2ABaseModel):
205225
Defines configuration details for the OAuth 2.0 Client Credentials flow.
206226
"""
207227

208-
refresh_url: AnyUrl | None = None
228+
refresh_url: str | None = None
209229
"""
210230
The URL to be used for obtaining refresh tokens. This MUST be a URL.
211231
"""
@@ -214,7 +234,7 @@ class ClientCredentialsOAuthFlow(A2ABaseModel):
214234
The available scopes for the OAuth2 security scheme. A map between the scope
215235
name and a short description for it.
216236
"""
217-
token_url: AnyUrl
237+
token_url: str
218238
"""
219239
The token URL to be used for this flow. This MUST be a URL.
220240
"""
@@ -370,12 +390,33 @@ class FileWithUri(A2ABaseModel):
370390
"""
371391
An optional name for the file (e.g., "document.pdf").
372392
"""
373-
uri: AnyUrl
393+
uri: str
374394
"""
375395
A URL pointing to the file's content.
376396
"""
377397

378398

399+
class GetAuthenticatedExtendedCardRequest(A2ABaseModel):
400+
"""
401+
Represents a JSON-RPC request for the `agent/getAuthenticatedExtendedCard` method.
402+
"""
403+
404+
id: str | int
405+
"""
406+
The identifier for this request.
407+
"""
408+
jsonrpc: Literal['2.0'] = '2.0'
409+
"""
410+
The version of the JSON-RPC protocol. MUST be exactly "2.0".
411+
"""
412+
method: Literal['agent/getAuthenticatedExtendedCard'] = (
413+
'agent/getAuthenticatedExtendedCard'
414+
)
415+
"""
416+
The method name. Must be 'agent/getAuthenticatedExtendedCard'.
417+
"""
418+
419+
379420
class GetTaskPushNotificationConfigParams(A2ABaseModel):
380421
"""
381422
Defines parameters for fetching a specific push notification configuration for a task.
@@ -426,11 +467,11 @@ class ImplicitOAuthFlow(A2ABaseModel):
426467
Defines configuration details for the OAuth 2.0 Implicit flow.
427468
"""
428469

429-
authorization_url: AnyUrl
470+
authorization_url: str
430471
"""
431472
The authorization URL to be used for this flow. This MUST be a URL.
432473
"""
433-
refresh_url: AnyUrl | None = None
474+
refresh_url: str | None = None
434475
"""
435476
The URL to be used for obtaining refresh tokens. This MUST be a URL.
436477
"""
@@ -699,7 +740,7 @@ class OpenIdConnectSecurityScheme(A2ABaseModel):
699740
"""
700741
An optional description for the security scheme.
701742
"""
702-
open_id_connect_url: AnyUrl
743+
open_id_connect_url: str
703744
"""
704745
The OpenID Connect Discovery URL for the OIDC provider's metadata.
705746
"""
@@ -725,7 +766,7 @@ class PasswordOAuthFlow(A2ABaseModel):
725766
Defines configuration details for the OAuth 2.0 Resource Owner Password flow.
726767
"""
727768

728-
refresh_url: AnyUrl | None = None
769+
refresh_url: str | None = None
729770
"""
730771
The URL to be used for obtaining refresh tokens. This MUST be a URL.
731772
"""
@@ -734,7 +775,7 @@ class PasswordOAuthFlow(A2ABaseModel):
734775
The available scopes for the OAuth2 security scheme. A map between the scope
735776
name and a short description for it.
736777
"""
737-
token_url: AnyUrl
778+
token_url: str
738779
"""
739780
The token URL to be used for this flow. This MUST be a URL.
740781
"""
@@ -749,7 +790,7 @@ class PushNotificationAuthenticationInfo(A2ABaseModel):
749790
"""
750791
Optional credentials required by the push notification endpoint.
751792
"""
752-
schemes: list[str] = Field(..., min_length=1)
793+
schemes: list[str]
753794
"""
754795
A list of supported authentication schemes (e.g., 'Basic', 'Bearer').
755796
"""
@@ -773,7 +814,7 @@ class PushNotificationConfig(A2ABaseModel):
773814
"""
774815
A unique token for this task or session to validate incoming push notifications.
775816
"""
776-
url: AnyUrl
817+
url: str
777818
"""
778819
The callback URL where the agent should send push notifications.
779820
"""
@@ -1000,6 +1041,7 @@ class A2AError(
10001041
| UnsupportedOperationError
10011042
| ContentTypeNotSupportedError
10021043
| InvalidAgentResponseError
1044+
| AuthenticatedExtendedCardNotConfiguredError
10031045
]
10041046
):
10051047
root: (
@@ -1014,6 +1056,7 @@ class A2AError(
10141056
| UnsupportedOperationError
10151057
| ContentTypeNotSupportedError
10161058
| InvalidAgentResponseError
1059+
| AuthenticatedExtendedCardNotConfiguredError
10171060
)
10181061
"""
10191062
A discriminated union of all standard JSON-RPC and A2A-specific error types.
@@ -1171,6 +1214,7 @@ class JSONRPCErrorResponse(A2ABaseModel):
11711214
| UnsupportedOperationError
11721215
| ContentTypeNotSupportedError
11731216
| InvalidAgentResponseError
1217+
| AuthenticatedExtendedCardNotConfiguredError
11741218
)
11751219
"""
11761220
An object describing the error that occurred.
@@ -1327,7 +1371,7 @@ class Artifact(A2ABaseModel):
13271371
"""
13281372
An optional, human-readable name for the artifact.
13291373
"""
1330-
parts: list[Part] = Field(..., min_length=1)
1374+
parts: list[Part]
13311375
"""
13321376
An array of content parts that make up the artifact.
13331377
"""
@@ -1391,7 +1435,7 @@ class Message(A2ABaseModel):
13911435
"""
13921436
Optional metadata for extensions. The key is an extension-specific identifier.
13931437
"""
1394-
parts: list[Part] = Field(..., min_length=1)
1438+
parts: list[Part]
13951439
"""
13961440
An array of content parts that form the message body. A message can be
13971441
composed of multiple parts of different types (e.g., text and files).
@@ -1626,6 +1670,7 @@ class A2ARequest(
16261670
| TaskResubscriptionRequest
16271671
| ListTaskPushNotificationConfigRequest
16281672
| DeleteTaskPushNotificationConfigRequest
1673+
| GetAuthenticatedExtendedCardRequest
16291674
]
16301675
):
16311676
root: (
@@ -1638,6 +1683,7 @@ class A2ARequest(
16381683
| TaskResubscriptionRequest
16391684
| ListTaskPushNotificationConfigRequest
16401685
| DeleteTaskPushNotificationConfigRequest
1686+
| GetAuthenticatedExtendedCardRequest
16411687
)
16421688
"""
16431689
A discriminated union representing all possible JSON-RPC 2.0 requests supported by the A2A specification.
@@ -1669,12 +1715,12 @@ class AgentCard(A2ABaseModel):
16691715
"""
16701716
A declaration of optional capabilities supported by the agent.
16711717
"""
1672-
default_input_modes: list[str] = Field(..., min_length=1)
1718+
default_input_modes: list[str]
16731719
"""
16741720
Default set of supported input MIME types for all skills, which can be
16751721
overridden on a per-skill basis.
16761722
"""
1677-
default_output_modes: list[str] = Field(..., min_length=1)
1723+
default_output_modes: list[str]
16781724
"""
16791725
Default set of supported output MIME types for all skills, which can be
16801726
overridden on a per-skill basis.
@@ -1686,11 +1732,11 @@ class AgentCard(A2ABaseModel):
16861732
A human-readable description of the agent, assisting users and other agents
16871733
in understanding its purpose.
16881734
"""
1689-
documentation_url: AnyUrl | None = None
1735+
documentation_url: str | None = None
16901736
"""
16911737
An optional URL to the agent's documentation.
16921738
"""
1693-
icon_url: AnyUrl | None = None
1739+
icon_url: str | None = None
16941740
"""
16951741
An optional URL to an icon for the agent.
16961742
"""
@@ -1731,7 +1777,7 @@ class AgentCard(A2ABaseModel):
17311777
"""
17321778
JSON Web Signatures computed for this AgentCard.
17331779
"""
1734-
skills: list[AgentSkill] = Field(..., min_length=1)
1780+
skills: list[AgentSkill]
17351781
"""
17361782
The set of skills, or distinct capabilities, that the agent can perform.
17371783
"""
@@ -1740,18 +1786,33 @@ class AgentCard(A2ABaseModel):
17401786
If true, the agent can provide an extended agent card with additional details
17411787
to authenticated users. Defaults to false.
17421788
"""
1743-
url: AnyUrl = Field(..., examples=['https://api.example.com/a2a/v1'])
1789+
url: str = Field(..., examples=['https://api.example.com/a2a/v1'])
17441790
"""
17451791
The preferred endpoint URL for interacting with the agent.
17461792
This URL MUST support the transport specified by 'preferredTransport'.
17471793
"""
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-
)
1794+
version: str = Field(..., examples=['1.0.0'])
1795+
"""
1796+
The agent's own version number. The format is defined by the provider.
1797+
"""
1798+
1799+
1800+
class GetAuthenticatedExtendedCardSuccessResponse(A2ABaseModel):
1801+
"""
1802+
Represents a successful JSON-RPC response for the `agent/getAuthenticatedExtendedCard` method.
1803+
"""
1804+
1805+
id: str | int | None = None
17531806
"""
1754-
The agent's own version number. Semantic Versioning MUST be used.
1807+
The identifier established by the client.
1808+
"""
1809+
jsonrpc: Literal['2.0'] = '2.0'
1810+
"""
1811+
The version of the JSON-RPC protocol. MUST be exactly "2.0".
1812+
"""
1813+
result: AgentCard
1814+
"""
1815+
The result is an Agent Card object.
17551816
"""
17561817

17571818

@@ -1774,7 +1835,7 @@ class Task(A2ABaseModel):
17741835
"""
17751836
id: str
17761837
"""
1777-
A unique identifier for the task, generated by the client for a new task or provided by the agent.
1838+
A unique identifier for the task, generated by the server for a new task.
17781839
"""
17791840
kind: Literal['task'] = 'task'
17801841
"""
@@ -1809,6 +1870,17 @@ class CancelTaskSuccessResponse(A2ABaseModel):
18091870
"""
18101871

18111872

1873+
class GetAuthenticatedExtendedCardResponse(
1874+
RootModel[
1875+
JSONRPCErrorResponse | GetAuthenticatedExtendedCardSuccessResponse
1876+
]
1877+
):
1878+
root: JSONRPCErrorResponse | GetAuthenticatedExtendedCardSuccessResponse
1879+
"""
1880+
Represents a JSON-RPC response for the `agent/getAuthenticatedExtendedCard` method.
1881+
"""
1882+
1883+
18121884
class GetTaskSuccessResponse(A2ABaseModel):
18131885
"""
18141886
Represents a successful JSON-RPC response for the `tasks/get` method.
@@ -1894,6 +1966,7 @@ class JSONRPCResponse(
18941966
| GetTaskPushNotificationConfigSuccessResponse
18951967
| ListTaskPushNotificationConfigSuccessResponse
18961968
| DeleteTaskPushNotificationConfigSuccessResponse
1969+
| GetAuthenticatedExtendedCardSuccessResponse
18971970
]
18981971
):
18991972
root: (
@@ -1906,6 +1979,7 @@ class JSONRPCResponse(
19061979
| GetTaskPushNotificationConfigSuccessResponse
19071980
| ListTaskPushNotificationConfigSuccessResponse
19081981
| DeleteTaskPushNotificationConfigSuccessResponse
1982+
| GetAuthenticatedExtendedCardSuccessResponse
19091983
)
19101984
"""
19111985
A discriminated union representing all possible JSON-RPC 2.0 responses

0 commit comments

Comments
 (0)