diff --git a/src/a2a/types.py b/src/a2a/types.py index 918a06b5..f154cada 100644 --- a/src/a2a/types.py +++ b/src/a2a/types.py @@ -93,13 +93,30 @@ class AgentExtension(A2ABaseModel): """ +class TransportProtocol(str, Enum): + """ + Supported A2A transport protocols. + """ + + JSONRPC = 'JSONRPC' + GRPC = 'GRPC' + HTTP_JSON = 'HTTP+JSON' + + class AgentInterface(A2ABaseModel): """ Declares a combination of a target URL and a transport protocol for interacting with the agent. This allows agents to expose the same functionality over multiple transport mechanisms. """ - transport: str = Field(..., examples=['JSONRPC', 'GRPC', 'HTTP+JSON']) + transport: TransportProtocol = Field( + ..., + examples=[ + TransportProtocol.JSONRPC, + TransportProtocol.GRPC, + TransportProtocol.HTTP_JSON, + ], + ) """ The transport protocol supported at this URL. """ @@ -1021,16 +1038,6 @@ class TextPart(A2ABaseModel): """ -class TransportProtocol(str, Enum): - """ - Supported A2A transport protocols. - """ - - jsonrpc = 'JSONRPC' - grpc = 'GRPC' - http_json = 'HTTP+JSON' - - class UnsupportedOperationError(A2ABaseModel): """ An A2A-specific error indicating that the requested operation is not supported by the agent. @@ -1774,8 +1781,13 @@ class AgentCard(A2ABaseModel): """ A human-readable name for the agent. """ - preferred_transport: str | None = Field( - default='JSONRPC', examples=['JSONRPC', 'GRPC', 'HTTP+JSON'] + preferred_transport: TransportProtocol | None = Field( + default=TransportProtocol.JSONRPC, + examples=[ + TransportProtocol.JSONRPC, + TransportProtocol.GRPC, + TransportProtocol.HTTP_JSON, + ], ) """ The transport protocol for the preferred endpoint (the main 'url' field).