Skip to content

Commit 1343fa1

Browse files
committed
Regenerate python types from updated spec, per a2aproject/A2A#590
1 parent d266fc0 commit 1343fa1

File tree

1 file changed

+221
-66
lines changed

1 file changed

+221
-66
lines changed

src/a2a/types.py

Lines changed: 221 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,41 @@
66
from enum import Enum
77
from typing import Any, Literal
88

9-
from pydantic import BaseModel, RootModel
9+
from pydantic import BaseModel, Field, RootModel
1010

1111

1212
class A2A(RootModel[Any]):
1313
root: Any
1414

1515

16-
class AgentAuthentication(BaseModel):
16+
class In(Enum):
1717
"""
18-
Defines authentication requirements for an agent.
19-
Intended to match OpenAPI authentication structure.
18+
The location of the API key. Valid values are "query", "header", or "cookie".
2019
"""
2120

22-
credentials: str | None = None
21+
cookie = 'cookie'
22+
header = 'header'
23+
query = 'query'
24+
25+
26+
class APIKeySecurityScheme(BaseModel):
2327
"""
24-
credentials a client should use for private cards
28+
API Key security scheme.
2529
"""
26-
schemes: list[str]
30+
31+
description: str | None = None
32+
"""
33+
description of this security scheme
2734
"""
28-
e.g. Basic, Bearer
35+
in_: In = Field(..., alias='in')
2936
"""
37+
The location of the API key. Valid values are "query", "header", or "cookie".
38+
"""
39+
name: str
40+
"""
41+
The name of the header, query or cookie parameter to be used.
42+
"""
43+
type: Literal['apiKey'] = 'apiKey'
3044

3145

3246
class AgentCapabilities(BaseModel):
@@ -193,6 +207,30 @@ class FileWithUri(BaseModel):
193207
uri: str
194208

195209

210+
class HTTPAuthSecurityScheme(BaseModel):
211+
"""
212+
HTTP Authentication security scheme.
213+
"""
214+
215+
bearerFormat: str | None = None
216+
"""
217+
A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually
218+
generated by an authorization server, so this information is primarily for documentation
219+
purposes.
220+
"""
221+
description: str | None = None
222+
"""
223+
description of this security scheme
224+
"""
225+
scheme: str
226+
"""
227+
The name of the HTTP Authentication scheme to be used in the Authorization header as defined
228+
in RFC7235. The values used SHOULD be registered in the IANA Authentication Scheme registry.
229+
The value is case-insensitive, as defined in RFC7235.
230+
"""
231+
type: Literal['http'] = 'http'
232+
233+
196234
class InternalError(BaseModel):
197235
"""
198236
JSON-RPC error indicating an internal JSON-RPC error on the server.
@@ -403,6 +441,72 @@ class MethodNotFoundError(BaseModel):
403441
"""
404442

405443

444+
class OAuthFlow(BaseModel):
445+
"""
446+
Configuration details for a supported OAuth Flow
447+
"""
448+
449+
authorizationUrl: str
450+
"""
451+
The authorization URL to be used for this flow. This MUST be in the form of a URL. The OAuth2
452+
standard requires the use of TLS
453+
"""
454+
refreshUrl: str
455+
"""
456+
The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. The OAuth2
457+
standard requires the use of TLS.
458+
"""
459+
scopes: dict[str, str]
460+
"""
461+
The available scopes for the OAuth2 security scheme. A map between the scope name and a short
462+
description for it. The map MAY be empty.
463+
"""
464+
tokenUrl: str
465+
"""
466+
The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard
467+
requires the use of TLS.
468+
"""
469+
470+
471+
class OAuthFlows(BaseModel):
472+
"""
473+
Allows configuration of the supported OAuth Flows
474+
"""
475+
476+
authorizationCode: OAuthFlow | None = None
477+
"""
478+
Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.
479+
"""
480+
clientCredentials: OAuthFlow | None = None
481+
"""
482+
Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0
483+
"""
484+
implicit: OAuthFlow | None = None
485+
"""
486+
Configuration for the OAuth Implicit flow
487+
"""
488+
password: OAuthFlow | None = None
489+
"""
490+
Configuration for the OAuth Resource Owner Password flow
491+
"""
492+
493+
494+
class OpenIdConnectSecurityScheme(BaseModel):
495+
"""
496+
OpenID Connect security scheme configuration.
497+
"""
498+
499+
description: str | None = None
500+
"""
501+
description of this security scheme
502+
"""
503+
openIdConnectUrl: str
504+
"""
505+
Well-known URL to discover the [[OpenID-Connect-Discovery]] provider metadata.
506+
"""
507+
type: Literal['openIdConnect'] = 'openIdConnect'
508+
509+
406510
class PartBase(BaseModel):
407511
"""
408512
Base properties common to all message parts.
@@ -465,6 +569,17 @@ class PushNotificationNotSupportedError(BaseModel):
465569
"""
466570

467571

572+
class SecuritySchemeBase(BaseModel):
573+
"""
574+
Base properties shared by all security schemes.
575+
"""
576+
577+
description: str | None = None
578+
"""
579+
description of this security scheme
580+
"""
581+
582+
468583
class TaskIdParams(BaseModel):
469584
"""
470585
Parameters containing only a task ID, used for simple task operations.
@@ -654,64 +769,6 @@ class A2AError(
654769
)
655770

656771

657-
class AgentCard(BaseModel):
658-
"""
659-
An AgentCard conveys key information:
660-
- Overall details (version, name, description, uses)
661-
- Skills: A set of capabilities the agent can perform
662-
- Default modalities/content types supported by the agent.
663-
- Authentication requirements
664-
"""
665-
666-
authentication: AgentAuthentication
667-
"""
668-
Authentication requirements for the agent.
669-
"""
670-
capabilities: AgentCapabilities
671-
"""
672-
Optional capabilities supported by the agent.
673-
"""
674-
defaultInputModes: list[str]
675-
"""
676-
The set of interaction modes that the agent
677-
supports across all skills. This can be overridden per-skill.
678-
Supported mime types for input.
679-
"""
680-
defaultOutputModes: list[str]
681-
"""
682-
Supported mime types for output.
683-
"""
684-
description: str
685-
"""
686-
A human-readable description of the agent. Used to assist users and
687-
other agents in understanding what the agent can do.
688-
"""
689-
documentationUrl: str | None = None
690-
"""
691-
A URL to documentation for the agent.
692-
"""
693-
name: str
694-
"""
695-
Human readable name of the agent.
696-
"""
697-
provider: AgentProvider | None = None
698-
"""
699-
The service provider of the agent
700-
"""
701-
skills: list[AgentSkill]
702-
"""
703-
Skills are a unit of capability that an agent can perform.
704-
"""
705-
url: str
706-
"""
707-
A URL to the address the agent is hosted at.
708-
"""
709-
version: str
710-
"""
711-
The version of the agent - format is up to the provider.
712-
"""
713-
714-
715772
class CancelTaskRequest(BaseModel):
716773
"""
717774
JSON-RPC request model for the 'tasks/cancel' method.
@@ -878,13 +935,49 @@ class MessageSendConfiguration(BaseModel):
878935
"""
879936

880937

938+
class OAuth2SecurityScheme(BaseModel):
939+
"""
940+
OAuth2.0 security scheme configuration.
941+
"""
942+
943+
description: str | None = None
944+
"""
945+
description of this security scheme
946+
"""
947+
flows: OAuthFlows
948+
"""
949+
An object containing configuration information for the flow types supported.
950+
"""
951+
type: Literal['oauth2'] = 'oauth2'
952+
953+
881954
class Part(RootModel[TextPart | FilePart | DataPart]):
882955
root: TextPart | FilePart | DataPart
883956
"""
884957
Represents a part of a message, which can be text, a file, or structured data.
885958
"""
886959

887960

961+
class SecurityScheme(
962+
RootModel[
963+
APIKeySecurityScheme
964+
| HTTPAuthSecurityScheme
965+
| OAuth2SecurityScheme
966+
| OpenIdConnectSecurityScheme
967+
]
968+
):
969+
root: (
970+
APIKeySecurityScheme
971+
| HTTPAuthSecurityScheme
972+
| OAuth2SecurityScheme
973+
| OpenIdConnectSecurityScheme
974+
)
975+
"""
976+
Mirrors the OpenAPI Security Scheme Object
977+
(https://swagger.io/specification/#security-scheme-object)
978+
"""
979+
980+
888981
class SetTaskPushNotificationConfigRequest(BaseModel):
889982
"""
890983
JSON-RPC request model for the 'tasks/pushNotificationConfig/set' method.
@@ -931,6 +1024,68 @@ class SetTaskPushNotificationConfigSuccessResponse(BaseModel):
9311024
"""
9321025

9331026

1027+
class AgentCard(BaseModel):
1028+
"""
1029+
An AgentCard conveys key information:
1030+
- Overall details (version, name, description, uses)
1031+
- Skills: A set of capabilities the agent can perform
1032+
- Default modalities/content types supported by the agent.
1033+
- Authentication requirements
1034+
"""
1035+
1036+
capabilities: AgentCapabilities
1037+
"""
1038+
Optional capabilities supported by the agent.
1039+
"""
1040+
defaultInputModes: list[str]
1041+
"""
1042+
The set of interaction modes that the agent
1043+
supports across all skills. This can be overridden per-skill.
1044+
Supported mime types for input.
1045+
"""
1046+
defaultOutputModes: list[str]
1047+
"""
1048+
Supported mime types for output.
1049+
"""
1050+
description: str
1051+
"""
1052+
A human-readable description of the agent. Used to assist users and
1053+
other agents in understanding what the agent can do.
1054+
"""
1055+
documentationUrl: str | None = None
1056+
"""
1057+
A URL to documentation for the agent.
1058+
"""
1059+
name: str
1060+
"""
1061+
Human readable name of the agent.
1062+
"""
1063+
provider: AgentProvider | None = None
1064+
"""
1065+
The service provider of the agent
1066+
"""
1067+
security: list[dict[str, list[str]]] | None = None
1068+
"""
1069+
Security requirements for contacting the agent.
1070+
"""
1071+
securitySchemes: dict[str, SecurityScheme] | None = None
1072+
"""
1073+
Security scheme details used for authenticating with this agent.
1074+
"""
1075+
skills: list[AgentSkill]
1076+
"""
1077+
Skills are a unit of capability that an agent can perform.
1078+
"""
1079+
url: str
1080+
"""
1081+
A URL to the address the agent is hosted at.
1082+
"""
1083+
version: str
1084+
"""
1085+
The version of the agent - format is up to the provider.
1086+
"""
1087+
1088+
9341089
class Artifact(BaseModel):
9351090
"""
9361091
Represents an artifact generated for a task task.

0 commit comments

Comments
 (0)