From e38d44fe6672eaf7532941d61c5305bb80f43275 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 9 Mar 2026 13:24:30 +0000 Subject: [PATCH 01/28] wip --- src/a2a/client/__init__.py | 4 +- src/a2a/client/auth/credentials.py | 2 +- src/a2a/client/auth/interceptor.py | 2 +- src/a2a/client/base_client.py | 179 ++++++++++++++++-- src/a2a/client/client.py | 22 +-- src/a2a/client/client_factory.py | 12 +- src/a2a/client/interceptors.py | 78 ++++++++ src/a2a/client/middleware.py | 57 ------ src/a2a/client/transports/base.py | 2 +- src/a2a/client/transports/grpc.py | 4 +- src/a2a/client/transports/http_helpers.py | 2 +- src/a2a/client/transports/jsonrpc.py | 4 +- src/a2a/client/transports/rest.py | 4 +- src/a2a/client/transports/tenant_decorator.py | 2 +- src/a2a/compat/v0_3/grpc_transport.py | 3 +- tests/client/transports/test_grpc_client.py | 4 +- .../client/transports/test_jsonrpc_client.py | 6 +- tests/client/transports/test_rest_client.py | 8 +- .../test_client_server_integration.py | 2 +- 19 files changed, 272 insertions(+), 125 deletions(-) create mode 100644 src/a2a/client/interceptors.py delete mode 100644 src/a2a/client/middleware.py diff --git a/src/a2a/client/__init__.py b/src/a2a/client/__init__.py index 90237d8e5..bd97b0edd 100644 --- a/src/a2a/client/__init__.py +++ b/src/a2a/client/__init__.py @@ -17,7 +17,7 @@ AgentCardResolutionError, ) from a2a.client.helpers import create_text_message_object -from a2a.client.middleware import ClientCallContext, ClientCallInterceptor +from a2a.client.interceptors import ClientCallContext, ClientCallInterceptor logger = logging.getLogger(__name__) @@ -30,9 +30,9 @@ 'AgentCardResolutionError', 'AuthInterceptor', 'BaseClient', + 'CallInterceptor', 'Client', 'ClientCallContext', - 'ClientCallInterceptor', 'ClientConfig', 'ClientEvent', 'ClientFactory', diff --git a/src/a2a/client/auth/credentials.py b/src/a2a/client/auth/credentials.py index 11f323709..3a9d4f863 100644 --- a/src/a2a/client/auth/credentials.py +++ b/src/a2a/client/auth/credentials.py @@ -1,6 +1,6 @@ from abc import ABC, abstractmethod -from a2a.client.middleware import ClientCallContext +from a2a.client.interceptors import ClientCallContext class CredentialService(ABC): diff --git a/src/a2a/client/auth/interceptor.py b/src/a2a/client/auth/interceptor.py index a19c7a8ed..6762b8be6 100644 --- a/src/a2a/client/auth/interceptor.py +++ b/src/a2a/client/auth/interceptor.py @@ -2,7 +2,7 @@ from typing import Any from a2a.client.auth.credentials import CredentialService -from a2a.client.middleware import ClientCallContext, ClientCallInterceptor +from a2a.client.interceptors import ClientCallContext, ClientCallInterceptor from a2a.types.a2a_pb2 import AgentCard logger = logging.getLogger(__name__) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 5195d8ccc..3814785f2 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -1,4 +1,5 @@ -from collections.abc import AsyncGenerator, AsyncIterator, Callable +from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable +from typing import Any from a2a.client.client import ( Client, @@ -7,7 +8,14 @@ Consumer, ) from a2a.client.client_task_manager import ClientTaskManager -from a2a.client.middleware import ClientCallContext, ClientCallInterceptor +from a2a.client.interceptors import ( + AfterArgs, + BeforeArgs, + ClientCallContext, + ClientCallInterceptor, + MethodInput, + MethodResult, +) from a2a.client.transports.base import ClientTransport from a2a.types.a2a_pb2 import ( AgentCard, @@ -38,12 +46,13 @@ def __init__( config: ClientConfig, transport: ClientTransport, consumers: list[Consumer], - middleware: list[ClientCallInterceptor], + interceptors: list[ClientCallInterceptor], ): - super().__init__(consumers, middleware) + super().__init__(consumers, interceptors) self._card = card self._config = config self._transport = transport + self._interceptors = interceptors async def send_message( self, @@ -66,18 +75,26 @@ async def send_message( """ self._apply_client_config(request) if not self._config.streaming or not self._card.capabilities.streaming: - response = await self._transport.send_message( - request, context=context + response = await self._execute_with_interceptors( + input_data=MethodInput(method='send_message', value=request), + context=context, + transport_call=lambda req, ctx: self._transport.send_message( + req, context=ctx + ), ) # In non-streaming case we convert to a StreamResponse so that the # client always sees the same iterator. stream_response = StreamResponse() client_event: ClientEvent - if response.HasField('task'): + if getattr(response, 'task', None) or ( + hasattr(response, 'HasField') and response.HasField('task') + ): stream_response.task.CopyFrom(response.task) client_event = (stream_response, response.task) - elif response.HasField('message'): + elif getattr(response, 'message', None) or ( + hasattr(response, 'HasField') and response.HasField('message') + ): stream_response.message.CopyFrom(response.message) client_event = (stream_response, None) else: @@ -148,7 +165,13 @@ async def get_task( Returns: A `Task` object representing the current state of the task. """ - return await self._transport.get_task(request, context=context) + return await self._execute_with_interceptors( + input_data=MethodInput(method='get_task', value=request), + context=context, + transport_call=lambda req, ctx: self._transport.get_task( + req, context=ctx + ), + ) async def list_tasks( self, @@ -157,7 +180,13 @@ async def list_tasks( context: ClientCallContext | None = None, ) -> ListTasksResponse: """Retrieves tasks for an agent.""" - return await self._transport.list_tasks(request, context=context) + return await self._execute_with_interceptors( + input_data=MethodInput(method='list_tasks', value=request), + context=context, + transport_call=lambda req, ctx: self._transport.list_tasks( + req, context=ctx + ), + ) async def cancel_task( self, @@ -174,7 +203,13 @@ async def cancel_task( Returns: A `Task` object containing the updated task status. """ - return await self._transport.cancel_task(request, context=context) + return await self._execute_with_interceptors( + input_data=MethodInput(method='cancel_task', value=request), + context=context, + transport_call=lambda req, ctx: self._transport.cancel_task( + req, context=ctx + ), + ) async def create_task_push_notification_config( self, @@ -191,8 +226,16 @@ async def create_task_push_notification_config( Returns: The created or updated `TaskPushNotificationConfig` object. """ - return await self._transport.create_task_push_notification_config( - request, context=context + return await self._execute_with_interceptors( + input_data=MethodInput( + method='create_task_push_notification_config', value=request + ), + context=context, + transport_call=lambda req, ctx: ( + self._transport.create_task_push_notification_config( + req, context=ctx + ) + ), ) async def get_task_push_notification_config( @@ -210,8 +253,16 @@ async def get_task_push_notification_config( Returns: A `TaskPushNotificationConfig` object containing the configuration. """ - return await self._transport.get_task_push_notification_config( - request, context=context + return await self._execute_with_interceptors( + input_data=MethodInput( + method='get_task_push_notification_config', value=request + ), + context=context, + transport_call=lambda req, ctx: ( + self._transport.get_task_push_notification_config( + req, context=ctx + ) + ), ) async def list_task_push_notification_configs( @@ -229,8 +280,16 @@ async def list_task_push_notification_configs( Returns: A `ListTaskPushNotificationConfigsResponse` object. """ - return await self._transport.list_task_push_notification_configs( - request, context=context + return await self._execute_with_interceptors( + input_data=MethodInput( + method='list_task_push_notification_configs', value=request + ), + context=context, + transport_call=lambda req, ctx: ( + self._transport.list_task_push_notification_configs( + req, context=ctx + ) + ), ) async def delete_task_push_notification_config( @@ -245,8 +304,16 @@ async def delete_task_push_notification_config( request: The `DeleteTaskPushNotificationConfigRequest` object specifying the request. context: Optional client call context. """ - await self._transport.delete_task_push_notification_config( - request, context=context + return await self._execute_with_interceptors( + input_data=MethodInput( + method='delete_task_push_notification_config', value=request + ), + context=context, + transport_call=lambda req, ctx: ( + self._transport.delete_task_push_notification_config( + req, context=ctx + ) + ), ) async def subscribe( @@ -312,3 +379,77 @@ async def get_extended_agent_card( async def close(self) -> None: """Closes the underlying transport.""" await self._transport.close() + + async def _execute_with_interceptors( + self, + input_data: MethodInput, + context: ClientCallContext | None, + transport_call: Callable[ + [Any, ClientCallContext | None], Awaitable[Any] + ], + ) -> Any: + before_args = BeforeArgs( + input=input_data, + agent_card=self._card, + context=context, + ) + before_result = await self._intercept_before(before_args) + + if before_result is not None: + after_args = AfterArgs( + result=MethodResult( + method=input_data.method, + value=before_result['early_return'].value, + ), + agent_card=self._card, + context=before_args.context, + ) + await self._intercept_after(after_args, before_result['executed']) + return after_args.result.value + + result = await transport_call( + before_args.input.value, before_args.context + ) + + after_args = AfterArgs( + result=MethodResult(method=input_data.method, value=result), + agent_card=self._card, + context=before_args.context, + ) + await self._intercept_after(after_args) + + return after_args.result.value + + async def _intercept_before( + self, + args: BeforeArgs, + ) -> dict[str, Any] | None: + if not self._interceptors or len(self._interceptors) == 0: + return None + executed: list[ClientCallInterceptor] = [] + for interceptor in self._interceptors: + await interceptor.before(args) + executed.append(interceptor) + if args.early_return: + return { + 'early_return': args.early_return, + 'executed': executed, + } + return None + + async def _intercept_after( + self, + args: AfterArgs, + interceptors: list[ClientCallInterceptor] | None = None, + ) -> None: + interceptors_to_use = ( + interceptors if interceptors is not None else self._interceptors + ) + if not interceptors_to_use: + interceptors_to_use = [] + + reversed_interceptors = list(reversed(interceptors_to_use)) + for interceptor in reversed_interceptors: + await interceptor.after(args) + if args.early_return: + return diff --git a/src/a2a/client/client.py b/src/a2a/client/client.py index cb150b19a..cf9d429dd 100644 --- a/src/a2a/client/client.py +++ b/src/a2a/client/client.py @@ -10,7 +10,7 @@ from typing_extensions import Self -from a2a.client.middleware import ClientCallContext, ClientCallInterceptor +from a2a.client.interceptors import ClientCallContext, ClientCallInterceptor from a2a.client.optionals import Channel from a2a.types.a2a_pb2 import ( AgentCard, @@ -95,20 +95,20 @@ class Client(ABC): def __init__( self, consumers: list[Consumer] | None = None, - middleware: list[ClientCallInterceptor] | None = None, + interceptors: list[ClientCallInterceptor] | None = None, ): - """Initializes the client with consumers and middleware. + """Initializes the client with consumers and interceptors. Args: consumers: A list of callables to process events from the agent. - middleware: A list of interceptors to process requests and responses. + interceptors: A list of interceptors to process requests and responses. """ - if middleware is None: - middleware = [] + if interceptors is None: + interceptors = [] if consumers is None: consumers = [] self._consumers = consumers - self._middleware = middleware + self._interceptors = interceptors async def __aenter__(self) -> Self: """Enters the async context manager.""" @@ -229,11 +229,9 @@ async def add_event_consumer(self, consumer: Consumer) -> None: """Attaches additional consumers to the `Client`.""" self._consumers.append(consumer) - async def add_request_middleware( - self, middleware: ClientCallInterceptor - ) -> None: - """Attaches additional middleware to the `Client`.""" - self._middleware.append(middleware) + async def add_interceptor(self, interceptor: ClientCallInterceptor) -> None: + """Attaches additional interceptors to the `Client`.""" + self._interceptors.append(interceptor) async def consume( self, diff --git a/src/a2a/client/client_factory.py b/src/a2a/client/client_factory.py index 1d2c524e0..35cfa8995 100644 --- a/src/a2a/client/client_factory.py +++ b/src/a2a/client/client_factory.py @@ -12,7 +12,7 @@ from a2a.client.base_client import BaseClient from a2a.client.card_resolver import A2ACardResolver from a2a.client.client import Client, ClientConfig, Consumer -from a2a.client.middleware import ClientCallInterceptor +from a2a.client.interceptors import ClientCallInterceptor from a2a.client.transports.base import ClientTransport from a2a.client.transports.jsonrpc import JsonRpcTransport from a2a.client.transports.rest import RestTransport @@ -98,7 +98,6 @@ def _register_defaults(self, supported: list[str]) -> None: cast('httpx.AsyncClient', config.httpx_client), card, url, - interceptors, ), ) if TransportProtocol.HTTP_JSON in supported: @@ -108,7 +107,6 @@ def _register_defaults(self, supported: list[str]) -> None: cast('httpx.AsyncClient', config.httpx_client), card, url, - interceptors, ), ) if TransportProtocol.GRPC in supported: @@ -146,17 +144,13 @@ def grpc_transport_producer( <= v < Version(PROTOCOL_VERSION_1_0) ): - return compat_transport.create( - card, url, config, interceptors - ) + return compat_transport.create(card, url, config) except InvalidVersion: pass grpc_transport = GrpcTransport if grpc_transport is not None: - return grpc_transport.create( - card, url, config, interceptors - ) + return grpc_transport.create(card, url, config) raise ImportError( 'GrpcTransport is not available. ' diff --git a/src/a2a/client/interceptors.py b/src/a2a/client/interceptors.py new file mode 100644 index 000000000..cffcee170 --- /dev/null +++ b/src/a2a/client/interceptors.py @@ -0,0 +1,78 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from collections.abc import MutableMapping # noqa: TC003 +from dataclasses import dataclass +from typing import TYPE_CHECKING, Any + +from pydantic import BaseModel, Field + +from a2a.client.service_parameters import ServiceParameters # noqa: TC001 + + +if TYPE_CHECKING: + from a2a.types.a2a_pb2 import AgentCard + + +class ClientCallContext(BaseModel): + """A context passed with each client call, allowing for call-specific. + + configuration and data passing. Such as authentication details or + request deadlines. + """ + + state: MutableMapping[str, Any] = Field(default_factory=dict) + timeout: float | None = None + service_parameters: ServiceParameters | None = None + + +class ClientCallInterceptor(ABC): + """An abstract base class for client-side call interceptors. + + Interceptors can inspect and modify requests before they are sent, + which is ideal for concerns like authentication, logging, or tracing. + """ + + @abstractmethod + async def before(self, args: BeforeArgs) -> None: + """Invoked before transport method.""" + + @abstractmethod + async def after(self, args: AfterArgs) -> None: + """Invoked after transport method.""" + + +@dataclass +class MethodInput: + """Represents the method and its associated input arguments payload.""" + + method: str + value: Any + + +@dataclass +class MethodResult: + """Represents the method and its associated result payload.""" + + method: str + value: Any + + +@dataclass +class BeforeArgs: + """Arguments passed to the interceptor before a method call.""" + + input: MethodInput + agent_card: AgentCard + context: ClientCallContext | None = None + early_return: MethodResult | None = None + + +@dataclass +class AfterArgs: + """Arguments passed to the interceptor after a method call completes.""" + + result: MethodResult + agent_card: AgentCard + context: ClientCallContext | None = None + early_return: bool = False diff --git a/src/a2a/client/middleware.py b/src/a2a/client/middleware.py deleted file mode 100644 index a852c93a7..000000000 --- a/src/a2a/client/middleware.py +++ /dev/null @@ -1,57 +0,0 @@ -from __future__ import annotations - -from abc import ABC, abstractmethod -from collections.abc import MutableMapping # noqa: TC003 -from typing import TYPE_CHECKING, Any - -from pydantic import BaseModel, Field - -from a2a.client.service_parameters import ServiceParameters # noqa: TC001 - - -if TYPE_CHECKING: - from a2a.types.a2a_pb2 import AgentCard - - -class ClientCallContext(BaseModel): - """A context passed with each client call, allowing for call-specific. - - configuration and data passing. Such as authentication details or - request deadlines. - """ - - state: MutableMapping[str, Any] = Field(default_factory=dict) - timeout: float | None = None - service_parameters: ServiceParameters | None = None - - -class ClientCallInterceptor(ABC): - """An abstract base class for client-side call interceptors. - - Interceptors can inspect and modify requests before they are sent, - which is ideal for concerns like authentication, logging, or tracing. - """ - - @abstractmethod - async def intercept( - self, - method_name: str, - request_payload: dict[str, Any], - http_kwargs: dict[str, Any], - agent_card: AgentCard | None, - context: ClientCallContext | None, - ) -> tuple[dict[str, Any], dict[str, Any]]: - """ - Intercepts a client call before the request is sent. - - Args: - method_name: The name of the RPC method (e.g., 'message/send'). - request_payload: The JSON RPC request payload dictionary. - http_kwargs: The keyword arguments for the httpx request. - agent_card: The AgentCard associated with the client. - context: The ClientCallContext for this specific call. - - Returns: - A tuple containing the (potentially modified) request_payload - and http_kwargs. - """ diff --git a/src/a2a/client/transports/base.py b/src/a2a/client/transports/base.py index 70e1384a1..13790f6d4 100644 --- a/src/a2a/client/transports/base.py +++ b/src/a2a/client/transports/base.py @@ -4,7 +4,7 @@ from typing_extensions import Self -from a2a.client.middleware import ClientCallContext +from a2a.client.interceptors import ClientCallContext from a2a.types.a2a_pb2 import ( AgentCard, CancelTaskRequest, diff --git a/src/a2a/client/transports/grpc.py b/src/a2a/client/transports/grpc.py index 231c1ebb3..6b9922766 100644 --- a/src/a2a/client/transports/grpc.py +++ b/src/a2a/client/transports/grpc.py @@ -4,7 +4,7 @@ from functools import wraps from typing import Any, NoReturn -from a2a.client.middleware import ClientCallContext +from a2a.client.interceptors import ClientCallContext from a2a.utils.errors import JSON_RPC_ERROR_CODE_MAP @@ -20,7 +20,6 @@ from a2a.client.client import ClientConfig from a2a.client.errors import A2AClientError, A2AClientTimeoutError -from a2a.client.middleware import ClientCallInterceptor from a2a.client.optionals import Channel from a2a.client.transports.base import ClientTransport from a2a.types import a2a_pb2_grpc @@ -116,7 +115,6 @@ def create( card: AgentCard, url: str, config: ClientConfig, - interceptors: list[ClientCallInterceptor], ) -> 'GrpcTransport': """Creates a gRPC transport for the A2A client.""" if config.grpc_channel_factory is None: diff --git a/src/a2a/client/transports/http_helpers.py b/src/a2a/client/transports/http_helpers.py index 43969dc40..08b3b2695 100644 --- a/src/a2a/client/transports/http_helpers.py +++ b/src/a2a/client/transports/http_helpers.py @@ -9,7 +9,7 @@ from httpx_sse import SSEError, aconnect_sse from a2a.client.errors import A2AClientError, A2AClientTimeoutError -from a2a.client.middleware import ClientCallContext +from a2a.client.interceptors import ClientCallContext @contextmanager diff --git a/src/a2a/client/transports/jsonrpc.py b/src/a2a/client/transports/jsonrpc.py index 7cb927ded..7369fc52a 100644 --- a/src/a2a/client/transports/jsonrpc.py +++ b/src/a2a/client/transports/jsonrpc.py @@ -10,7 +10,7 @@ from jsonrpc.jsonrpc2 import JSONRPC20Request, JSONRPC20Response from a2a.client.errors import A2AClientError -from a2a.client.middleware import ClientCallContext, ClientCallInterceptor +from a2a.client.interceptors import ClientCallContext from a2a.client.transports.base import ClientTransport from a2a.client.transports.http_helpers import ( get_http_args, @@ -56,13 +56,11 @@ def __init__( httpx_client: httpx.AsyncClient, agent_card: AgentCard, url: str, - interceptors: list[ClientCallInterceptor] | None = None, ): """Initializes the JsonRpcTransport.""" self.url = url self.httpx_client = httpx_client self.agent_card = agent_card - self.interceptors = interceptors or [] self._needs_extended_card = agent_card.capabilities.extended_agent_card async def send_message( diff --git a/src/a2a/client/transports/rest.py b/src/a2a/client/transports/rest.py index e8812dcd9..94c168ff0 100644 --- a/src/a2a/client/transports/rest.py +++ b/src/a2a/client/transports/rest.py @@ -9,7 +9,7 @@ from google.protobuf.json_format import MessageToDict, Parse, ParseDict from a2a.client.errors import A2AClientError -from a2a.client.middleware import ClientCallContext, ClientCallInterceptor +from a2a.client.interceptors import ClientCallContext from a2a.client.transports.base import ClientTransport from a2a.client.transports.http_helpers import ( get_http_args, @@ -55,13 +55,11 @@ def __init__( httpx_client: httpx.AsyncClient, agent_card: AgentCard, url: str, - interceptors: list[ClientCallInterceptor] | None = None, ): """Initializes the RestTransport.""" self.url = url.removesuffix('/') self.httpx_client = httpx_client self.agent_card = agent_card - self.interceptors = interceptors or [] self._needs_extended_card = agent_card.capabilities.extended_agent_card async def send_message( diff --git a/src/a2a/client/transports/tenant_decorator.py b/src/a2a/client/transports/tenant_decorator.py index 71744e9c8..db410cba3 100644 --- a/src/a2a/client/transports/tenant_decorator.py +++ b/src/a2a/client/transports/tenant_decorator.py @@ -1,6 +1,6 @@ from collections.abc import AsyncGenerator, Callable -from a2a.client.middleware import ClientCallContext +from a2a.client.interceptors import ClientCallContext from a2a.client.transports.base import ClientTransport from a2a.types.a2a_pb2 import ( AgentCard, diff --git a/src/a2a/compat/v0_3/grpc_transport.py b/src/a2a/compat/v0_3/grpc_transport.py index 4d925ff2a..1747ffd31 100644 --- a/src/a2a/compat/v0_3/grpc_transport.py +++ b/src/a2a/compat/v0_3/grpc_transport.py @@ -19,7 +19,7 @@ from a2a.client.client import ClientConfig -from a2a.client.middleware import ClientCallContext, ClientCallInterceptor +from a2a.client.interceptors import ClientCallContext from a2a.client.optionals import Channel from a2a.client.transports.base import ClientTransport from a2a.compat.v0_3 import ( @@ -97,7 +97,6 @@ def create( card: a2a_pb2.AgentCard, url: str, config: ClientConfig, - interceptors: list[ClientCallInterceptor], ) -> 'CompatGrpcTransport': """Creates a gRPC transport for the A2A client.""" if config.grpc_channel_factory is None: diff --git a/tests/client/transports/test_grpc_client.py b/tests/client/transports/test_grpc_client.py index a070b18f3..13172b4a2 100644 --- a/tests/client/transports/test_grpc_client.py +++ b/tests/client/transports/test_grpc_client.py @@ -3,7 +3,7 @@ import grpc import pytest -from a2a.client.middleware import ClientCallContext +from a2a.client.interceptors import ClientCallContext from a2a.client.transports.grpc import GrpcTransport from a2a.extensions.common import HTTP_EXTENSION_HEADER from a2a.utils.constants import VERSION_HEADER, PROTOCOL_VERSION_CURRENT @@ -237,7 +237,7 @@ async def test_send_message_with_timeout_context( sample_task: Task, ) -> None: """Test send_message passes context timeout to grpc stub.""" - from a2a.client.middleware import ClientCallContext + from a2a.client.interceptors import ClientCallContext mock_grpc_stub.SendMessage.return_value = a2a_pb2.SendMessageResponse( task=sample_task diff --git a/tests/client/transports/test_jsonrpc_client.py b/tests/client/transports/test_jsonrpc_client.py index 5ae7a4028..a3206f1cf 100644 --- a/tests/client/transports/test_jsonrpc_client.py +++ b/tests/client/transports/test_jsonrpc_client.py @@ -229,7 +229,7 @@ async def test_send_message_with_timeout_context( self, transport, mock_httpx_client ): """Test that send_message passes context timeout to build_request.""" - from a2a.client.middleware import ClientCallContext + from a2a.client.interceptors import ClientCallContext mock_response = MagicMock() mock_response.json.return_value = { @@ -546,7 +546,7 @@ async def test_extensions_added_to_request( request = create_send_message_request() - from a2a.client.middleware import ClientCallContext + from a2a.client.interceptors import ClientCallContext context = ClientCallContext( service_parameters={'X-A2A-Extensions': 'https://example.com/ext1'} @@ -633,7 +633,7 @@ async def test_get_card_with_extended_card_support_with_extensions( 'result': json_format.MessageToDict(extended_card), } - from a2a.client.middleware import ClientCallContext + from a2a.client.interceptors import ClientCallContext context = ClientCallContext( service_parameters={HTTP_EXTENSION_HEADER: extensions_header_val} diff --git a/tests/client/transports/test_rest_client.py b/tests/client/transports/test_rest_client.py index d96d3eccf..8bb436b3f 100644 --- a/tests/client/transports/test_rest_client.py +++ b/tests/client/transports/test_rest_client.py @@ -147,7 +147,7 @@ async def test_send_message_with_timeout_context( self, mock_httpx_client: AsyncMock, mock_agent_card: MagicMock ): """Test that send_message passes context timeout to build_request.""" - from a2a.client.middleware import ClientCallContext + from a2a.client.interceptors import ClientCallContext client = RestTransport( httpx_client=mock_httpx_client, @@ -202,7 +202,7 @@ async def test_send_message_with_default_extensions( mock_response.status_code = 200 mock_httpx_client.send.return_value = mock_response - from a2a.client.middleware import ClientCallContext + from a2a.client.interceptors import ClientCallContext context = ClientCallContext( service_parameters={ @@ -246,7 +246,7 @@ async def test_send_message_streaming_with_new_extensions( mock_event_source ) - from a2a.client.middleware import ClientCallContext + from a2a.client.interceptors import ClientCallContext context = ClientCallContext( service_parameters={ @@ -348,7 +348,7 @@ async def test_get_card_with_extended_card_support_with_extensions( request = GetExtendedAgentCardRequest() - from a2a.client.middleware import ClientCallContext + from a2a.client.interceptors import ClientCallContext context = ClientCallContext( service_parameters={HTTP_EXTENSION_HEADER: extensions_str} diff --git a/tests/integration/test_client_server_integration.py b/tests/integration/test_client_server_integration.py index fa8cd3142..fa7607073 100644 --- a/tests/integration/test_client_server_integration.py +++ b/tests/integration/test_client_server_integration.py @@ -12,7 +12,7 @@ from jwt.api_jwk import PyJWK from a2a.client import ClientConfig -from a2a.client.middleware import ClientCallContext +from a2a.client.interceptors import ClientCallContext from a2a.client.service_parameters import ( ServiceParametersFactory, with_a2a_extensions, From 61b73049dc89b49d28455f0f41679045daa81fd3 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 9 Mar 2026 18:55:57 +0000 Subject: [PATCH 02/28] feat: Implement and apply interceptors directly within BaseClient methods for request and response processing. --- src/a2a/client/base_client.py | 90 ++++++++++++++++--- src/a2a/client/transports/jsonrpc.py | 1 - src/a2a/client/transports/rest.py | 1 - tests/client/test_base_client.py | 2 +- .../test_client_server_integration.py | 6 +- 5 files changed, 81 insertions(+), 19 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 859a54821..8c5b569e7 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -104,10 +104,34 @@ async def send_message( yield client_event return + before_args = BeforeArgs( + input=MethodInput(method='send_message_streaming', value=request), + agent_card=self._card, + context=context, + ) + before_result = await self._intercept_before(before_args) + + if before_result is not None: + after_args = AfterArgs( + result=MethodResult( + method=before_args.input.method, + value=before_result['early_return'].value, + ), + agent_card=self._card, + context=before_args.context, + ) + await self._intercept_after(after_args, before_result['executed']) + yield after_args.result.value + return + stream = self._transport.send_message_streaming( - request, context=context + before_args.input.value, context=before_args.context ) - async for client_event in self._process_stream(stream): + + async for client_event in self._process_stream( + stream, + before_args=before_args, + ): yield client_event def _apply_client_config(self, request: SendMessageRequest) -> None: @@ -129,23 +153,34 @@ def _apply_client_config(self, request: SendMessageRequest) -> None: ) async def _process_stream( - self, stream: AsyncIterator[StreamResponse] + self, + stream: AsyncIterator[StreamResponse], + before_args: BeforeArgs, ) -> AsyncGenerator[ClientEvent]: tracker = ClientTaskManager() async for stream_response in stream: + after_args = AfterArgs( + result=MethodResult( + method=before_args.input.method, value=stream_response + ), + agent_card=self._card, + context=before_args.context, + ) + await self._intercept_after(after_args) + intercepted_response = after_args.result.value client_event: ClientEvent # When we get a message in the stream then we don't expect any # further messages so yield and return - if stream_response.HasField('message'): - client_event = (stream_response, None) + if intercepted_response.HasField('message'): + client_event = (intercepted_response, None) await self.consume(client_event, self._card) yield client_event return # Otherwise track the task / task update then yield to the client - await tracker.process(stream_response) + await tracker.process(intercepted_response) updated_task = tracker.get_task_or_raise() - client_event = (stream_response, updated_task) + client_event = (intercepted_response, updated_task) await self.consume(client_event, self._card) yield client_event @@ -341,10 +376,34 @@ async def subscribe( ) # Note: resubscribe can only be called on an existing task. As such, - # we should never see Message updates, despite the typing of the service - # definition indicating it may be possible. - stream = self._transport.subscribe(request, context=context) - async for client_event in self._process_stream(stream): + before_args = BeforeArgs( + input=MethodInput(method='subscribe', value=request), + agent_card=self._card, + context=context, + ) + before_result = await self._intercept_before(before_args) + + if before_result is not None: + after_args = AfterArgs( + result=MethodResult( + method=before_args.input.method, + value=before_result['early_return'].value, + ), + agent_card=self._card, + context=before_args.context, + ) + await self._intercept_after(after_args, before_result['executed']) + yield after_args.result.value + return + + stream = self._transport.subscribe( + before_args.input.value, context=before_args.context + ) + + async for client_event in self._process_stream( + stream, + before_args=before_args, + ): yield client_event async def get_extended_agent_card( @@ -367,9 +426,14 @@ async def get_extended_agent_card( Returns: The `AgentCard` for the agent. """ - card = await self._transport.get_extended_agent_card( - request, + card = await self._execute_with_interceptors( + input_data=MethodInput( + method='get_extended_agent_card', value=request + ), context=context, + transport_call=lambda req, ctx: ( + self._transport.get_extended_agent_card(req, context=ctx) + ), ) if signature_verifier: signature_verifier(card) diff --git a/src/a2a/client/transports/jsonrpc.py b/src/a2a/client/transports/jsonrpc.py index 7fe02c3c9..a3066a5e8 100644 --- a/src/a2a/client/transports/jsonrpc.py +++ b/src/a2a/client/transports/jsonrpc.py @@ -60,7 +60,6 @@ def __init__( self.url = url self.httpx_client = httpx_client self.agent_card = agent_card - self.interceptors = interceptors or [] async def send_message( self, diff --git a/src/a2a/client/transports/rest.py b/src/a2a/client/transports/rest.py index 2bf812b4d..f4480c9a9 100644 --- a/src/a2a/client/transports/rest.py +++ b/src/a2a/client/transports/rest.py @@ -59,7 +59,6 @@ def __init__( self.url = url.removesuffix('/') self.httpx_client = httpx_client self.agent_card = agent_card - self.interceptors = interceptors or [] async def send_message( self, diff --git a/tests/client/test_base_client.py b/tests/client/test_base_client.py index 98bc33061..37774caa9 100644 --- a/tests/client/test_base_client.py +++ b/tests/client/test_base_client.py @@ -73,7 +73,7 @@ def base_client( config=config, transport=mock_transport, consumers=[], - middleware=[], + interceptors=[], ) diff --git a/tests/integration/test_client_server_integration.py b/tests/integration/test_client_server_integration.py index b69c85d18..920c0dc55 100644 --- a/tests/integration/test_client_server_integration.py +++ b/tests/integration/test_client_server_integration.py @@ -968,7 +968,7 @@ async def test_json_transport_base_client_send_message_with_extensions( config=ClientConfig(streaming=False), transport=transport, consumers=[], - middleware=[], + interceptors=[], ) message_to_send = Message( @@ -1130,7 +1130,7 @@ async def test_client_get_signed_extended_card( config=ClientConfig(streaming=False), transport=transport, consumers=[], - middleware=[], + interceptors=[], ) signature_verifier = create_signature_verifier( @@ -1217,7 +1217,7 @@ async def test_client_get_signed_base_and_extended_cards( config=ClientConfig(streaming=False), transport=transport, consumers=[], - middleware=[], + interceptors=[], ) # 3. Fetch extended card via client From c8b25501ef5283a80b8d022e41d736c58020bc27 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 09:03:14 +0000 Subject: [PATCH 03/28] wip --- src/a2a/client/__init__.py | 10 +- src/a2a/client/auth/credentials.py | 2 +- src/a2a/client/auth/interceptor.py | 3 +- src/a2a/client/base_client.py | 75 ++++---- src/a2a/client/client.py | 18 +- src/a2a/client/interceptors.py | 165 +++++++++++++----- src/a2a/client/transports/base.py | 2 +- src/a2a/client/transports/grpc.py | 2 +- src/a2a/client/transports/http_helpers.py | 2 +- src/a2a/client/transports/jsonrpc.py | 2 +- src/a2a/client/transports/rest.py | 2 +- src/a2a/client/transports/tenant_decorator.py | 2 +- src/a2a/compat/v0_3/grpc_transport.py | 3 +- tests/client/transports/test_grpc_client.py | 4 +- .../client/transports/test_jsonrpc_client.py | 6 +- tests/client/transports/test_rest_client.py | 8 +- .../test_client_server_integration.py | 2 +- 17 files changed, 206 insertions(+), 102 deletions(-) diff --git a/src/a2a/client/__init__.py b/src/a2a/client/__init__.py index bd97b0edd..98555f909 100644 --- a/src/a2a/client/__init__.py +++ b/src/a2a/client/__init__.py @@ -9,7 +9,13 @@ ) from a2a.client.base_client import BaseClient from a2a.client.card_resolver import A2ACardResolver -from a2a.client.client import Client, ClientConfig, ClientEvent, Consumer +from a2a.client.client import ( + Client, + ClientCallContext, + ClientConfig, + ClientEvent, + Consumer, +) from a2a.client.client_factory import ClientFactory, minimal_agent_card from a2a.client.errors import ( A2AClientError, @@ -17,7 +23,7 @@ AgentCardResolutionError, ) from a2a.client.helpers import create_text_message_object -from a2a.client.interceptors import ClientCallContext, ClientCallInterceptor +from a2a.client.interceptors import ClientCallInterceptor logger = logging.getLogger(__name__) diff --git a/src/a2a/client/auth/credentials.py b/src/a2a/client/auth/credentials.py index 3a9d4f863..e3d74e4af 100644 --- a/src/a2a/client/auth/credentials.py +++ b/src/a2a/client/auth/credentials.py @@ -1,6 +1,6 @@ from abc import ABC, abstractmethod -from a2a.client.interceptors import ClientCallContext +from a2a.client.client import ClientCallContext class CredentialService(ABC): diff --git a/src/a2a/client/auth/interceptor.py b/src/a2a/client/auth/interceptor.py index 6762b8be6..dfe48dda1 100644 --- a/src/a2a/client/auth/interceptor.py +++ b/src/a2a/client/auth/interceptor.py @@ -2,7 +2,8 @@ from typing import Any from a2a.client.auth.credentials import CredentialService -from a2a.client.interceptors import ClientCallContext, ClientCallInterceptor +from a2a.client.client import ClientCallContext +from a2a.client.interceptors import ClientCallInterceptor from a2a.types.a2a_pb2 import AgentCard logger = logging.getLogger(__name__) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 8c5b569e7..d665fc5a4 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -1,8 +1,9 @@ from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable -from typing import Any +from typing import Any, Literal from a2a.client.client import ( Client, + ClientCallContext, ClientConfig, ClientEvent, Consumer, @@ -11,10 +12,12 @@ from a2a.client.interceptors import ( AfterArgs, BeforeArgs, - ClientCallContext, + ClientCallInput, ClientCallInterceptor, - MethodInput, - MethodResult, + ClientCallResult, + M, + P, + R, ) from a2a.client.transports.base import ClientTransport from a2a.types.a2a_pb2 import ( @@ -75,7 +78,9 @@ async def send_message( self._apply_client_config(request) if not self._config.streaming or not self._card.capabilities.streaming: response = await self._execute_with_interceptors( - input_data=MethodInput(method='send_message', value=request), + input_data=ClientCallInput( + method='send_message', value=request + ), context=context, transport_call=lambda req, ctx: self._transport.send_message( req, context=ctx @@ -104,8 +109,14 @@ async def send_message( yield client_event return - before_args = BeforeArgs( - input=MethodInput(method='send_message_streaming', value=request), + before_args: BeforeArgs[ + Literal['send_message_streaming'], + SendMessageRequest, + StreamResponse, + ] = BeforeArgs( + input=ClientCallInput( + method='send_message_streaming', value=request + ), agent_card=self._card, context=context, ) @@ -113,7 +124,7 @@ async def send_message( if before_result is not None: after_args = AfterArgs( - result=MethodResult( + result=ClientCallResult( method=before_args.input.method, value=before_result['early_return'].value, ), @@ -160,7 +171,7 @@ async def _process_stream( tracker = ClientTaskManager() async for stream_response in stream: after_args = AfterArgs( - result=MethodResult( + result=ClientCallResult( method=before_args.input.method, value=stream_response ), agent_card=self._card, @@ -200,7 +211,7 @@ async def get_task( A `Task` object representing the current state of the task. """ return await self._execute_with_interceptors( - input_data=MethodInput(method='get_task', value=request), + input_data=ClientCallInput(method='get_task', value=request), context=context, transport_call=lambda req, ctx: self._transport.get_task( req, context=ctx @@ -215,7 +226,7 @@ async def list_tasks( ) -> ListTasksResponse: """Retrieves tasks for an agent.""" return await self._execute_with_interceptors( - input_data=MethodInput(method='list_tasks', value=request), + input_data=ClientCallInput(method='list_tasks', value=request), context=context, transport_call=lambda req, ctx: self._transport.list_tasks( req, context=ctx @@ -238,7 +249,7 @@ async def cancel_task( A `Task` object containing the updated task status. """ return await self._execute_with_interceptors( - input_data=MethodInput(method='cancel_task', value=request), + input_data=ClientCallInput(method='cancel_task', value=request), context=context, transport_call=lambda req, ctx: self._transport.cancel_task( req, context=ctx @@ -261,7 +272,7 @@ async def create_task_push_notification_config( The created or updated `TaskPushNotificationConfig` object. """ return await self._execute_with_interceptors( - input_data=MethodInput( + input_data=ClientCallInput( method='create_task_push_notification_config', value=request ), context=context, @@ -288,7 +299,7 @@ async def get_task_push_notification_config( A `TaskPushNotificationConfig` object containing the configuration. """ return await self._execute_with_interceptors( - input_data=MethodInput( + input_data=ClientCallInput( method='get_task_push_notification_config', value=request ), context=context, @@ -315,7 +326,7 @@ async def list_task_push_notification_configs( A `ListTaskPushNotificationConfigsResponse` object. """ return await self._execute_with_interceptors( - input_data=MethodInput( + input_data=ClientCallInput( method='list_task_push_notification_configs', value=request ), context=context, @@ -339,7 +350,7 @@ async def delete_task_push_notification_config( context: Optional client call context. """ return await self._execute_with_interceptors( - input_data=MethodInput( + input_data=ClientCallInput( method='delete_task_push_notification_config', value=request ), context=context, @@ -376,8 +387,10 @@ async def subscribe( ) # Note: resubscribe can only be called on an existing task. As such, - before_args = BeforeArgs( - input=MethodInput(method='subscribe', value=request), + before_args: BeforeArgs[ + Literal['subscribe'], SubscribeToTaskRequest, StreamResponse + ] = BeforeArgs( + input=ClientCallInput(method='subscribe', value=request), agent_card=self._card, context=context, ) @@ -385,7 +398,7 @@ async def subscribe( if before_result is not None: after_args = AfterArgs( - result=MethodResult( + result=ClientCallResult( method=before_args.input.method, value=before_result['early_return'].value, ), @@ -427,7 +440,7 @@ async def get_extended_agent_card( The `AgentCard` for the agent. """ card = await self._execute_with_interceptors( - input_data=MethodInput( + input_data=ClientCallInput( method='get_extended_agent_card', value=request ), context=context, @@ -447,13 +460,11 @@ async def close(self) -> None: async def _execute_with_interceptors( self, - input_data: MethodInput, + input_data: ClientCallInput[M, P], context: ClientCallContext | None, - transport_call: Callable[ - [Any, ClientCallContext | None], Awaitable[Any] - ], - ) -> Any: - before_args = BeforeArgs( + transport_call: Callable[[P, ClientCallContext | None], Awaitable[R]], + ) -> R: + before_args: BeforeArgs[M, P, R] = BeforeArgs( input=input_data, agent_card=self._card, context=context, @@ -461,8 +472,8 @@ async def _execute_with_interceptors( before_result = await self._intercept_before(before_args) if before_result is not None: - after_args = AfterArgs( - result=MethodResult( + after_args: AfterArgs[M, R] = AfterArgs( + result=ClientCallResult( method=input_data.method, value=before_result['early_return'].value, ), @@ -476,8 +487,8 @@ async def _execute_with_interceptors( before_args.input.value, before_args.context ) - after_args = AfterArgs( - result=MethodResult(method=input_data.method, value=result), + after_args: AfterArgs[M, R] = AfterArgs( + result=ClientCallResult(method=input_data.method, value=result), agent_card=self._card, context=before_args.context, ) @@ -487,7 +498,7 @@ async def _execute_with_interceptors( async def _intercept_before( self, - args: BeforeArgs, + args: BeforeArgs[M, P, R], ) -> dict[str, Any] | None: if not self._interceptors or len(self._interceptors) == 0: return None @@ -504,7 +515,7 @@ async def _intercept_before( async def _intercept_after( self, - args: AfterArgs, + args: AfterArgs[M, R], interceptors: list[ClientCallInterceptor] | None = None, ) -> None: interceptors_to_use = ( diff --git a/src/a2a/client/client.py b/src/a2a/client/client.py index 5b951316f..fa521ec22 100644 --- a/src/a2a/client/client.py +++ b/src/a2a/client/client.py @@ -2,16 +2,18 @@ import logging from abc import ABC, abstractmethod -from collections.abc import AsyncIterator, Callable, Coroutine +from collections.abc import AsyncIterator, Callable, Coroutine, MutableMapping from types import TracebackType from typing import Any import httpx +from pydantic import BaseModel, Field from typing_extensions import Self -from a2a.client.interceptors import ClientCallContext, ClientCallInterceptor +from a2a.client.interceptors import ClientCallInterceptor from a2a.client.optionals import Channel +from a2a.client.service_parameters import ServiceParameters from a2a.types.a2a_pb2 import ( AgentCard, CancelTaskRequest, @@ -82,6 +84,18 @@ class ClientConfig: Consumer = Callable[[ClientEvent, AgentCard], Coroutine[None, Any, Any]] +class ClientCallContext(BaseModel): + """A context passed with each client call, allowing for call-specific. + + configuration and data passing. Such as authentication details or + request deadlines. + """ + + state: MutableMapping[str, Any] = Field(default_factory=dict) + timeout: float | None = None + service_parameters: ServiceParameters | None = None + + class Client(ABC): """Abstract base class defining the interface for an A2A client. diff --git a/src/a2a/client/interceptors.py b/src/a2a/client/interceptors.py index cffcee170..911929301 100644 --- a/src/a2a/client/interceptors.py +++ b/src/a2a/client/interceptors.py @@ -1,78 +1,151 @@ from __future__ import annotations from abc import ABC, abstractmethod -from collections.abc import MutableMapping # noqa: TC003 from dataclasses import dataclass -from typing import TYPE_CHECKING, Any - -from pydantic import BaseModel, Field - -from a2a.client.service_parameters import ServiceParameters # noqa: TC001 +from typing import TYPE_CHECKING, Generic, Literal, TypeAlias, TypeVar if TYPE_CHECKING: - from a2a.types.a2a_pb2 import AgentCard - - -class ClientCallContext(BaseModel): - """A context passed with each client call, allowing for call-specific. - - configuration and data passing. Such as authentication details or - request deadlines. - """ - - state: MutableMapping[str, Any] = Field(default_factory=dict) - timeout: float | None = None - service_parameters: ServiceParameters | None = None - - -class ClientCallInterceptor(ABC): - """An abstract base class for client-side call interceptors. - - Interceptors can inspect and modify requests before they are sent, - which is ideal for concerns like authentication, logging, or tracing. - """ - - @abstractmethod - async def before(self, args: BeforeArgs) -> None: - """Invoked before transport method.""" - - @abstractmethod - async def after(self, args: AfterArgs) -> None: - """Invoked after transport method.""" + from a2a.client.client import ClientCallContext + +from a2a.types.a2a_pb2 import ( # noqa: TC001 + AgentCard, + CancelTaskRequest, + DeleteTaskPushNotificationConfigRequest, + GetExtendedAgentCardRequest, + GetTaskPushNotificationConfigRequest, + GetTaskRequest, + ListTaskPushNotificationConfigsRequest, + ListTaskPushNotificationConfigsResponse, + ListTasksRequest, + ListTasksResponse, + SendMessageRequest, + SendMessageResponse, + StreamResponse, + SubscribeToTaskRequest, + Task, + TaskPushNotificationConfig, +) + + +M = TypeVar('M') +P = TypeVar('P') +R = TypeVar('R') @dataclass -class MethodInput: +class ClientCallInput(Generic[M, P]): """Represents the method and its associated input arguments payload.""" - method: str - value: Any + method: M + value: P @dataclass -class MethodResult: +class ClientCallResult(Generic[M, R]): """Represents the method and its associated result payload.""" - method: str - value: Any + method: M + value: R @dataclass -class BeforeArgs: +class BeforeArgs(Generic[M, P, R]): """Arguments passed to the interceptor before a method call.""" - input: MethodInput + input: ClientCallInput[M, P] agent_card: AgentCard context: ClientCallContext | None = None - early_return: MethodResult | None = None + early_return: ClientCallResult[M, R] | None = None @dataclass -class AfterArgs: +class AfterArgs(Generic[M, R]): """Arguments passed to the interceptor after a method call completes.""" - result: MethodResult + result: ClientCallResult[M, R] agent_card: AgentCard context: ClientCallContext | None = None early_return: bool = False + + +class ClientCallInterceptor(ABC, Generic[M, P, R]): + """An abstract base class for client-side call interceptors. + + Interceptors can inspect and modify requests before they are sent, + which is ideal for concerns like authentication, logging, or tracing. + """ + + @abstractmethod + async def before(self, args: UnionBeforeArgs) -> None: + """Invoked before transport method.""" + + @abstractmethod + async def after(self, args: UnionAfterArgs) -> None: + """Invoked after transport method.""" + + +UnionBeforeArgs: TypeAlias = ( + BeforeArgs[ + Literal['send_message'], 'SendMessageRequest', 'SendMessageResponse' + ] + | BeforeArgs[ + Literal['send_message_streaming'], + 'SendMessageRequest', + 'StreamResponse', + ] + | BeforeArgs[Literal['get_task'], 'GetTaskRequest', 'Task'] + | BeforeArgs[Literal['list_tasks'], 'ListTasksRequest', 'ListTasksResponse'] + | BeforeArgs[Literal['cancel_task'], 'CancelTaskRequest', 'Task'] + | BeforeArgs[ + Literal['create_task_push_notification_config'], + 'TaskPushNotificationConfig', + 'TaskPushNotificationConfig', + ] + | BeforeArgs[ + Literal['get_task_push_notification_config'], + 'GetTaskPushNotificationConfigRequest', + 'TaskPushNotificationConfig', + ] + | BeforeArgs[ + Literal['list_task_push_notification_configs'], + 'ListTaskPushNotificationConfigsRequest', + 'ListTaskPushNotificationConfigsResponse', + ] + | BeforeArgs[ + Literal['delete_task_push_notification_config'], + 'DeleteTaskPushNotificationConfigRequest', + None, + ] + | BeforeArgs[ + Literal['subscribe'], 'SubscribeToTaskRequest', 'StreamResponse' + ] + | BeforeArgs[ + Literal['get_extended_agent_card'], + 'GetExtendedAgentCardRequest', + 'AgentCard', + ] +) + +UnionAfterArgs: TypeAlias = ( + AfterArgs[Literal['send_message'], 'SendMessageResponse'] + | AfterArgs[Literal['send_message_streaming'], 'StreamResponse'] + | AfterArgs[Literal['get_task'], 'Task'] + | AfterArgs[Literal['list_tasks'], 'ListTasksResponse'] + | AfterArgs[Literal['cancel_task'], 'Task'] + | AfterArgs[ + Literal['create_task_push_notification_config'], + 'TaskPushNotificationConfig', + ] + | AfterArgs[ + Literal['get_task_push_notification_config'], + 'TaskPushNotificationConfig', + ] + | AfterArgs[ + Literal['list_task_push_notification_configs'], + 'ListTaskPushNotificationConfigsResponse', + ] + | AfterArgs[Literal['delete_task_push_notification_config'], None] + | AfterArgs[Literal['subscribe'], 'StreamResponse'] + | AfterArgs[Literal['get_extended_agent_card'], 'AgentCard'] +) diff --git a/src/a2a/client/transports/base.py b/src/a2a/client/transports/base.py index e37dd2e2f..e46aae25e 100644 --- a/src/a2a/client/transports/base.py +++ b/src/a2a/client/transports/base.py @@ -4,7 +4,7 @@ from typing_extensions import Self -from a2a.client.interceptors import ClientCallContext +from a2a.client.client import ClientCallContext from a2a.types.a2a_pb2 import ( AgentCard, CancelTaskRequest, diff --git a/src/a2a/client/transports/grpc.py b/src/a2a/client/transports/grpc.py index 1c52fd3ec..f1efab0a5 100644 --- a/src/a2a/client/transports/grpc.py +++ b/src/a2a/client/transports/grpc.py @@ -4,7 +4,7 @@ from functools import wraps from typing import Any, NoReturn -from a2a.client.interceptors import ClientCallContext +from a2a.client.client import ClientCallContext from a2a.utils.errors import JSON_RPC_ERROR_CODE_MAP diff --git a/src/a2a/client/transports/http_helpers.py b/src/a2a/client/transports/http_helpers.py index 08b3b2695..0a5721b50 100644 --- a/src/a2a/client/transports/http_helpers.py +++ b/src/a2a/client/transports/http_helpers.py @@ -8,8 +8,8 @@ from httpx_sse import SSEError, aconnect_sse +from a2a.client.client import ClientCallContext from a2a.client.errors import A2AClientError, A2AClientTimeoutError -from a2a.client.interceptors import ClientCallContext @contextmanager diff --git a/src/a2a/client/transports/jsonrpc.py b/src/a2a/client/transports/jsonrpc.py index a3066a5e8..9854aabb0 100644 --- a/src/a2a/client/transports/jsonrpc.py +++ b/src/a2a/client/transports/jsonrpc.py @@ -9,8 +9,8 @@ from google.protobuf import json_format from jsonrpc.jsonrpc2 import JSONRPC20Request, JSONRPC20Response +from a2a.client.client import ClientCallContext from a2a.client.errors import A2AClientError -from a2a.client.interceptors import ClientCallContext from a2a.client.transports.base import ClientTransport from a2a.client.transports.http_helpers import ( get_http_args, diff --git a/src/a2a/client/transports/rest.py b/src/a2a/client/transports/rest.py index f4480c9a9..f8a0bd2d5 100644 --- a/src/a2a/client/transports/rest.py +++ b/src/a2a/client/transports/rest.py @@ -8,8 +8,8 @@ from google.protobuf.json_format import MessageToDict, Parse, ParseDict +from a2a.client.client import ClientCallContext from a2a.client.errors import A2AClientError -from a2a.client.interceptors import ClientCallContext from a2a.client.transports.base import ClientTransport from a2a.client.transports.http_helpers import ( get_http_args, diff --git a/src/a2a/client/transports/tenant_decorator.py b/src/a2a/client/transports/tenant_decorator.py index 0279b85ed..d1059d757 100644 --- a/src/a2a/client/transports/tenant_decorator.py +++ b/src/a2a/client/transports/tenant_decorator.py @@ -1,6 +1,6 @@ from collections.abc import AsyncGenerator -from a2a.client.interceptors import ClientCallContext +from a2a.client.client import ClientCallContext from a2a.client.transports.base import ClientTransport from a2a.types.a2a_pb2 import ( AgentCard, diff --git a/src/a2a/compat/v0_3/grpc_transport.py b/src/a2a/compat/v0_3/grpc_transport.py index e07f965e6..725b4ee9f 100644 --- a/src/a2a/compat/v0_3/grpc_transport.py +++ b/src/a2a/compat/v0_3/grpc_transport.py @@ -18,8 +18,7 @@ ) from e -from a2a.client.client import ClientConfig -from a2a.client.interceptors import ClientCallContext +from a2a.client.client import ClientCallContext, ClientConfig from a2a.client.optionals import Channel from a2a.client.transports.base import ClientTransport from a2a.compat.v0_3 import ( diff --git a/tests/client/transports/test_grpc_client.py b/tests/client/transports/test_grpc_client.py index 60c9a7e6f..394785ecc 100644 --- a/tests/client/transports/test_grpc_client.py +++ b/tests/client/transports/test_grpc_client.py @@ -3,7 +3,7 @@ import grpc import pytest -from a2a.client.interceptors import ClientCallContext +from a2a.client.client import ClientCallContext from a2a.client.transports.grpc import GrpcTransport from a2a.extensions.common import HTTP_EXTENSION_HEADER from a2a.utils.constants import VERSION_HEADER, PROTOCOL_VERSION_CURRENT @@ -227,7 +227,7 @@ async def test_send_message_with_timeout_context( sample_task: Task, ) -> None: """Test send_message passes context timeout to grpc stub.""" - from a2a.client.interceptors import ClientCallContext + from a2a.client.client import ClientCallContext mock_grpc_stub.SendMessage.return_value = a2a_pb2.SendMessageResponse( task=sample_task diff --git a/tests/client/transports/test_jsonrpc_client.py b/tests/client/transports/test_jsonrpc_client.py index c30e7ff71..c96f166ec 100644 --- a/tests/client/transports/test_jsonrpc_client.py +++ b/tests/client/transports/test_jsonrpc_client.py @@ -229,7 +229,7 @@ async def test_send_message_with_timeout_context( self, transport, mock_httpx_client ): """Test that send_message passes context timeout to build_request.""" - from a2a.client.interceptors import ClientCallContext + from a2a.client.client import ClientCallContext mock_response = MagicMock() mock_response.json.return_value = { @@ -544,7 +544,7 @@ async def test_extensions_added_to_request( request = create_send_message_request() - from a2a.client.interceptors import ClientCallContext + from a2a.client.client import ClientCallContext context = ClientCallContext( service_parameters={'X-A2A-Extensions': 'https://example.com/ext1'} @@ -631,7 +631,7 @@ async def test_get_card_with_extended_card_support_with_extensions( 'result': json_format.MessageToDict(extended_card), } - from a2a.client.interceptors import ClientCallContext + from a2a.client.client import ClientCallContext context = ClientCallContext( service_parameters={HTTP_EXTENSION_HEADER: extensions_header_val} diff --git a/tests/client/transports/test_rest_client.py b/tests/client/transports/test_rest_client.py index 062d7c7be..2db3b25e6 100644 --- a/tests/client/transports/test_rest_client.py +++ b/tests/client/transports/test_rest_client.py @@ -147,7 +147,7 @@ async def test_send_message_with_timeout_context( self, mock_httpx_client: AsyncMock, mock_agent_card: MagicMock ): """Test that send_message passes context timeout to build_request.""" - from a2a.client.interceptors import ClientCallContext + from a2a.client.client import ClientCallContext client = RestTransport( httpx_client=mock_httpx_client, @@ -202,7 +202,7 @@ async def test_send_message_with_default_extensions( mock_response.status_code = 200 mock_httpx_client.send.return_value = mock_response - from a2a.client.interceptors import ClientCallContext + from a2a.client.client import ClientCallContext context = ClientCallContext( service_parameters={ @@ -246,7 +246,7 @@ async def test_send_message_streaming_with_new_extensions( mock_event_source ) - from a2a.client.interceptors import ClientCallContext + from a2a.client.client import ClientCallContext context = ClientCallContext( service_parameters={ @@ -348,7 +348,7 @@ async def test_get_card_with_extended_card_support_with_extensions( request = GetExtendedAgentCardRequest() - from a2a.client.interceptors import ClientCallContext + from a2a.client.client import ClientCallContext context = ClientCallContext( service_parameters={HTTP_EXTENSION_HEADER: extensions_str} diff --git a/tests/integration/test_client_server_integration.py b/tests/integration/test_client_server_integration.py index 920c0dc55..020695cee 100644 --- a/tests/integration/test_client_server_integration.py +++ b/tests/integration/test_client_server_integration.py @@ -12,7 +12,7 @@ from jwt.api_jwk import PyJWK from a2a.client import ClientConfig -from a2a.client.interceptors import ClientCallContext +from a2a.client.client import ClientCallContext from a2a.client.service_parameters import ( ServiceParametersFactory, with_a2a_extensions, From 68db81ec0b9f1e68e277d6233301c9d8c8e640c4 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 09:38:44 +0000 Subject: [PATCH 04/28] add tests --- src/a2a/client/auth/interceptor.py | 3 +- src/a2a/client/base_client.py | 20 ++- tests/client/test_base_client_interceptors.py | 144 ++++++++++++++++++ tests/client/test_client_factory_grpc.py | 6 +- .../client/transports/test_jsonrpc_client.py | 11 -- 5 files changed, 160 insertions(+), 24 deletions(-) create mode 100644 tests/client/test_base_client_interceptors.py diff --git a/src/a2a/client/auth/interceptor.py b/src/a2a/client/auth/interceptor.py index dfe48dda1..61613081d 100644 --- a/src/a2a/client/auth/interceptor.py +++ b/src/a2a/client/auth/interceptor.py @@ -3,13 +3,12 @@ from a2a.client.auth.credentials import CredentialService from a2a.client.client import ClientCallContext -from a2a.client.interceptors import ClientCallInterceptor from a2a.types.a2a_pb2 import AgentCard logger = logging.getLogger(__name__) -class AuthInterceptor(ClientCallInterceptor): +class AuthInterceptor: """An interceptor that automatically adds authentication details to requests. Based on the agent's security schemes. diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index d665fc5a4..14deb689e 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -1,5 +1,5 @@ from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable -from typing import Any, Literal +from typing import Any, Literal, cast from a2a.client.client import ( Client, @@ -15,6 +15,8 @@ ClientCallInput, ClientCallInterceptor, ClientCallResult, + UnionAfterArgs, + UnionBeforeArgs, M, P, R, @@ -469,10 +471,10 @@ async def _execute_with_interceptors( agent_card=self._card, context=context, ) - before_result = await self._intercept_before(before_args) + before_result = await self._intercept_before(cast(UnionBeforeArgs, before_args)) if before_result is not None: - after_args: AfterArgs[M, R] = AfterArgs( + early_after_args: AfterArgs[M, R] = AfterArgs( result=ClientCallResult( method=input_data.method, value=before_result['early_return'].value, @@ -480,8 +482,10 @@ async def _execute_with_interceptors( agent_card=self._card, context=before_args.context, ) - await self._intercept_after(after_args, before_result['executed']) - return after_args.result.value + await self._intercept_after( + cast(UnionAfterArgs, early_after_args), before_result['executed'] + ) + return early_after_args.result.value result = await transport_call( before_args.input.value, before_args.context @@ -492,13 +496,13 @@ async def _execute_with_interceptors( agent_card=self._card, context=before_args.context, ) - await self._intercept_after(after_args) + await self._intercept_after(cast(UnionAfterArgs, after_args)) return after_args.result.value async def _intercept_before( self, - args: BeforeArgs[M, P, R], + args: UnionBeforeArgs, ) -> dict[str, Any] | None: if not self._interceptors or len(self._interceptors) == 0: return None @@ -515,7 +519,7 @@ async def _intercept_before( async def _intercept_after( self, - args: AfterArgs[M, R], + args: UnionAfterArgs, interceptors: list[ClientCallInterceptor] | None = None, ) -> None: interceptors_to_use = ( diff --git a/tests/client/test_base_client_interceptors.py b/tests/client/test_base_client_interceptors.py new file mode 100644 index 000000000..093cd6c6f --- /dev/null +++ b/tests/client/test_base_client_interceptors.py @@ -0,0 +1,144 @@ +# ruff: noqa: INP001 +from unittest.mock import AsyncMock, MagicMock + +import pytest + +from a2a.client.base_client import BaseClient +from a2a.client.client import ClientConfig +from a2a.client.interceptors import ( + AfterArgs, + BeforeArgs, + ClientCallInput, + ClientCallInterceptor, + ClientCallResult, +) +from a2a.client.transports.base import ClientTransport +from a2a.types.a2a_pb2 import ( + AgentCapabilities, + AgentCard, + AgentInterface, +) + + +@pytest.fixture +def mock_transport() -> AsyncMock: + return AsyncMock(spec=ClientTransport) + + +@pytest.fixture +def sample_agent_card() -> AgentCard: + return AgentCard( + name='Test Agent', + description='An agent for testing', + supported_interfaces=[ + AgentInterface(url='http://test.com', protocol_binding='HTTP+JSON') + ], + version='1.0', + capabilities=AgentCapabilities(streaming=True), + default_input_modes=['text/plain'], + default_output_modes=['text/plain'], + skills=[], + ) + + +@pytest.fixture +def mock_interceptor() -> AsyncMock: + return AsyncMock(spec=ClientCallInterceptor) + + +@pytest.fixture +def base_client( + sample_agent_card: AgentCard, + mock_transport: AsyncMock, + mock_interceptor: AsyncMock, +) -> BaseClient: + config = ClientConfig(streaming=True) + return BaseClient( + card=sample_agent_card, + config=config, + transport=mock_transport, + consumers=[], + interceptors=[mock_interceptor], + ) + + +class TestBaseClientInterceptors: + @pytest.mark.asyncio + async def test_execute_with_interceptors_normal_flow( + self, + base_client: BaseClient, + mock_interceptor: AsyncMock, + ): + input_data = ClientCallInput(method='get_task', value=MagicMock()) + context = MagicMock() + mock_transport_call = AsyncMock(return_value='transport_result') + + # Set up mock interceptor to just pass through + mock_interceptor.before.return_value = None + + result = await base_client._execute_with_interceptors( + input_data=input_data, + context=context, + transport_call=mock_transport_call, + ) + + assert result == 'transport_result' + + # Verify before was called + mock_interceptor.before.assert_called_once() + before_args = mock_interceptor.before.call_args[0][0] + assert isinstance(before_args, BeforeArgs) + assert before_args.input == input_data + assert before_args.context == context + + # Verify transport call was made + mock_transport_call.assert_called_once_with(input_data.value, context) + + # Verify after was called + mock_interceptor.after.assert_called_once() + after_args = mock_interceptor.after.call_args[0][0] + assert isinstance(after_args, AfterArgs) + assert after_args.result.method == input_data.method + assert after_args.result.value == 'transport_result' + assert after_args.context == context + + @pytest.mark.asyncio + async def test_execute_with_interceptors_early_return( + self, + base_client: BaseClient, + mock_interceptor: AsyncMock, + ): + input_data = ClientCallInput(method='get_task', value=MagicMock()) + context = MagicMock() + mock_transport_call = AsyncMock() + + # Set up early return in before + early_return_result = ClientCallResult( + method='get_task', value='early_result' + ) + + async def mock_before_with_early_return(args: BeforeArgs): + args.early_return = early_return_result + + mock_interceptor.before.side_effect = mock_before_with_early_return + + result = await base_client._execute_with_interceptors( + input_data=input_data, + context=context, + transport_call=mock_transport_call, + ) + + assert result == 'early_result' + + # Verify before was called + mock_interceptor.before.assert_called_once() + + # Verify transport call was NOT made + mock_transport_call.assert_not_called() + + # Verify after was called with early return value + mock_interceptor.after.assert_called_once() + after_args = mock_interceptor.after.call_args[0][0] + assert isinstance(after_args, AfterArgs) + assert after_args.result.value == 'early_result' + assert after_args.context == context diff --git a/tests/client/test_client_factory_grpc.py b/tests/client/test_client_factory_grpc.py index 1e7563248..47423d0ab 100644 --- a/tests/client/test_client_factory_grpc.py +++ b/tests/client/test_client_factory_grpc.py @@ -60,7 +60,7 @@ def test_grpc_priority_1_0(grpc_agent_card): # Priority 1: 1.0 -> GrpcTransport mock_grpc.create.assert_called_once_with( - grpc_agent_card, 'url10', config, [] + grpc_agent_card, 'url10', config ) mock_compat.create.assert_not_called() @@ -101,7 +101,7 @@ def test_grpc_priority_gt_1_0(grpc_agent_card): # Priority 2: > 1.0 -> GrpcTransport (first matching is 1.1) mock_grpc.create.assert_called_once_with( - grpc_agent_card, 'url11', config, [] + grpc_agent_card, 'url11', config ) mock_compat.create.assert_not_called() @@ -171,5 +171,5 @@ def test_grpc_unspecified_version_uses_grpc_transport(grpc_agent_card): factory.create(grpc_agent_card) mock_grpc.create.assert_called_once_with( - grpc_agent_card, 'url_no_version', config, [] + grpc_agent_card, 'url_no_version', config ) diff --git a/tests/client/transports/test_jsonrpc_client.py b/tests/client/transports/test_jsonrpc_client.py index c96f166ec..b568865e6 100644 --- a/tests/client/transports/test_jsonrpc_client.py +++ b/tests/client/transports/test_jsonrpc_client.py @@ -117,17 +117,6 @@ def test_init_with_agent_card(self, mock_httpx_client, agent_card): assert transport.url == 'http://test-agent.example.com' assert transport.agent_card == agent_card - def test_init_with_interceptors(self, mock_httpx_client, agent_card): - """Test initialization with interceptors.""" - interceptor = MagicMock() - transport = JsonRpcTransport( - httpx_client=mock_httpx_client, - agent_card=agent_card, - url='http://test-agent.example.com', - interceptors=[interceptor], - ) - assert transport.interceptors == [interceptor] - class TestSendMessage: """Tests for the send_message method.""" From 1235d9f8b3876d7904dc4919a7eb28c7a3134a2b Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 09:48:46 +0000 Subject: [PATCH 05/28] run ruff --- src/a2a/client/base_client.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 14deb689e..8032aeb29 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -15,11 +15,11 @@ ClientCallInput, ClientCallInterceptor, ClientCallResult, - UnionAfterArgs, - UnionBeforeArgs, M, P, R, + UnionAfterArgs, + UnionBeforeArgs, ) from a2a.client.transports.base import ClientTransport from a2a.types.a2a_pb2 import ( @@ -471,7 +471,9 @@ async def _execute_with_interceptors( agent_card=self._card, context=context, ) - before_result = await self._intercept_before(cast(UnionBeforeArgs, before_args)) + before_result = await self._intercept_before( + cast('UnionBeforeArgs', before_args) + ) if before_result is not None: early_after_args: AfterArgs[M, R] = AfterArgs( @@ -483,7 +485,8 @@ async def _execute_with_interceptors( context=before_args.context, ) await self._intercept_after( - cast(UnionAfterArgs, early_after_args), before_result['executed'] + cast('UnionAfterArgs', early_after_args), + before_result['executed'], ) return early_after_args.result.value @@ -496,7 +499,7 @@ async def _execute_with_interceptors( agent_card=self._card, context=before_args.context, ) - await self._intercept_after(cast(UnionAfterArgs, after_args)) + await self._intercept_after(cast('UnionAfterArgs', after_args)) return after_args.result.value From 4967d97014c338dfa57189120ac49fc4c6cb077e Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 09:53:03 +0000 Subject: [PATCH 06/28] add cast --- src/a2a/client/base_client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 8032aeb29..3c9186c68 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -122,7 +122,7 @@ async def send_message( agent_card=self._card, context=context, ) - before_result = await self._intercept_before(before_args) + before_result = await self._intercept_before(cast('UnionBeforeArgs', before_args)) if before_result is not None: after_args = AfterArgs( @@ -133,7 +133,7 @@ async def send_message( agent_card=self._card, context=before_args.context, ) - await self._intercept_after(after_args, before_result['executed']) + await self._intercept_after(cast('UnionAfterArgs', after_args), before_result['executed']) yield after_args.result.value return @@ -179,7 +179,7 @@ async def _process_stream( agent_card=self._card, context=before_args.context, ) - await self._intercept_after(after_args) + await self._intercept_after(cast('UnionAfterArgs', after_args)) intercepted_response = after_args.result.value client_event: ClientEvent # When we get a message in the stream then we don't expect any @@ -396,7 +396,7 @@ async def subscribe( agent_card=self._card, context=context, ) - before_result = await self._intercept_before(before_args) + before_result = await self._intercept_before(cast('UnionBeforeArgs', before_args)) if before_result is not None: after_args = AfterArgs( @@ -407,7 +407,7 @@ async def subscribe( agent_card=self._card, context=before_args.context, ) - await self._intercept_after(after_args, before_result['executed']) + await self._intercept_after(cast('UnionAfterArgs', after_args), before_result['executed']) yield after_args.result.value return From eaf1792505ca276ee8ae942ea0a6487329aa8dbe Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 09:55:44 +0000 Subject: [PATCH 07/28] refactor: Simplify BeforeArgs initialization in send_message_streaming and subscribe methods --- src/a2a/client/base_client.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 3c9186c68..f5732ce69 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -111,11 +111,7 @@ async def send_message( yield client_event return - before_args: BeforeArgs[ - Literal['send_message_streaming'], - SendMessageRequest, - StreamResponse, - ] = BeforeArgs( + before_args = BeforeArgs( input=ClientCallInput( method='send_message_streaming', value=request ), @@ -389,9 +385,7 @@ async def subscribe( ) # Note: resubscribe can only be called on an existing task. As such, - before_args: BeforeArgs[ - Literal['subscribe'], SubscribeToTaskRequest, StreamResponse - ] = BeforeArgs( + before_args = BeforeArgs( input=ClientCallInput(method='subscribe', value=request), agent_card=self._card, context=context, From 1d5319c26d4a07ec75bcc442fb7431a3b79e291e Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 10:01:21 +0000 Subject: [PATCH 08/28] refactor: Add explicit type hints to `BeforeArgs` and remove redundant `cast` calls. --- src/a2a/client/base_client.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index f5732ce69..3e13f20fc 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -111,14 +111,18 @@ async def send_message( yield client_event return - before_args = BeforeArgs( + before_args: BeforeArgs[ + Literal['send_message_streaming'], + SendMessageRequest, + StreamResponse, + ] = BeforeArgs( input=ClientCallInput( method='send_message_streaming', value=request ), agent_card=self._card, context=context, ) - before_result = await self._intercept_before(cast('UnionBeforeArgs', before_args)) + before_result = await self._intercept_before(before_args) if before_result is not None: after_args = AfterArgs( @@ -129,7 +133,9 @@ async def send_message( agent_card=self._card, context=before_args.context, ) - await self._intercept_after(cast('UnionAfterArgs', after_args), before_result['executed']) + await self._intercept_after( + cast('UnionAfterArgs', after_args), before_result['executed'] + ) yield after_args.result.value return @@ -385,12 +391,14 @@ async def subscribe( ) # Note: resubscribe can only be called on an existing task. As such, - before_args = BeforeArgs( + before_args: BeforeArgs[ + Literal['subscribe'], SubscribeToTaskRequest, StreamResponse + ] = BeforeArgs( input=ClientCallInput(method='subscribe', value=request), agent_card=self._card, context=context, ) - before_result = await self._intercept_before(cast('UnionBeforeArgs', before_args)) + before_result = await self._intercept_before(before_args) if before_result is not None: after_args = AfterArgs( @@ -401,7 +409,9 @@ async def subscribe( agent_card=self._card, context=before_args.context, ) - await self._intercept_after(cast('UnionAfterArgs', after_args), before_result['executed']) + await self._intercept_after( + cast('UnionAfterArgs', after_args), before_result['executed'] + ) yield after_args.result.value return From f3796792d9daec2197edd297a6b61d1baf8a0451 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 10:19:12 +0000 Subject: [PATCH 09/28] revert change --- src/a2a/client/base_client.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 3e13f20fc..d80a7f978 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -93,14 +93,10 @@ async def send_message( # client always sees the same iterator. stream_response = StreamResponse() client_event: ClientEvent - if getattr(response, 'task', None) or ( - hasattr(response, 'HasField') and response.HasField('task') - ): + if response.HasField('task'): stream_response.task.CopyFrom(response.task) client_event = (stream_response, response.task) - elif getattr(response, 'message', None) or ( - hasattr(response, 'HasField') and response.HasField('message') - ): + elif response.HasField('message'): stream_response.message.CopyFrom(response.message) client_event = (stream_response, None) else: From 8affcb31128de58d03714da78384422818204901 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 11:06:04 +0000 Subject: [PATCH 10/28] refactor: Rename `CallInterceptor` to `ClientCallInterceptor` and simplify default list assignments in the `Client` constructor. --- src/a2a/client/__init__.py | 2 +- src/a2a/client/client.py | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/a2a/client/__init__.py b/src/a2a/client/__init__.py index 98555f909..3f1588a0b 100644 --- a/src/a2a/client/__init__.py +++ b/src/a2a/client/__init__.py @@ -36,9 +36,9 @@ 'AgentCardResolutionError', 'AuthInterceptor', 'BaseClient', - 'CallInterceptor', 'Client', 'ClientCallContext', + 'ClientCallInterceptor', 'ClientConfig', 'ClientEvent', 'ClientFactory', diff --git a/src/a2a/client/client.py b/src/a2a/client/client.py index fa521ec22..6c715e5f0 100644 --- a/src/a2a/client/client.py +++ b/src/a2a/client/client.py @@ -115,12 +115,8 @@ def __init__( consumers: A list of callables to process events from the agent. interceptors: A list of interceptors to process requests and responses. """ - if interceptors is None: - interceptors = [] - if consumers is None: - consumers = [] - self._consumers = consumers - self._interceptors = interceptors + self._consumers = consumers or [] + self._interceptors = interceptors or [] async def __aenter__(self) -> Self: """Enters the async context manager.""" From ef658ffeb0f568257740f751104138c8071be629 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 11:08:55 +0000 Subject: [PATCH 11/28] fix --- src/a2a/client/base_client.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index d80a7f978..de010b29a 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -507,7 +507,7 @@ async def _intercept_before( self, args: UnionBeforeArgs, ) -> dict[str, Any] | None: - if not self._interceptors or len(self._interceptors) == 0: + if not self._interceptors: return None executed: list[ClientCallInterceptor] = [] for interceptor in self._interceptors: @@ -528,8 +528,6 @@ async def _intercept_after( interceptors_to_use = ( interceptors if interceptors is not None else self._interceptors ) - if not interceptors_to_use: - interceptors_to_use = [] reversed_interceptors = list(reversed(interceptors_to_use)) for interceptor in reversed_interceptors: From ab134b320024818307ae7dcdada4e9f8b147dc92 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 11:27:43 +0000 Subject: [PATCH 12/28] refactor: centralize stream interception and execution logic into `_execute_stream_with_interceptors` and add `_format_stream_event`. --- src/a2a/client/base_client.py | 119 +++++++++++++++------------------- 1 file changed, 52 insertions(+), 67 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index de010b29a..3e43cff77 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -107,43 +107,12 @@ async def send_message( yield client_event return - before_args: BeforeArgs[ - Literal['send_message_streaming'], - SendMessageRequest, - StreamResponse, - ] = BeforeArgs( - input=ClientCallInput( - method='send_message_streaming', value=request - ), - agent_card=self._card, + async for event in self._execute_stream_with_interceptors( + input_data=ClientCallInput(method='send_message_streaming', value=request), context=context, - ) - before_result = await self._intercept_before(before_args) - - if before_result is not None: - after_args = AfterArgs( - result=ClientCallResult( - method=before_args.input.method, - value=before_result['early_return'].value, - ), - agent_card=self._card, - context=before_args.context, - ) - await self._intercept_after( - cast('UnionAfterArgs', after_args), before_result['executed'] - ) - yield after_args.result.value - return - - stream = self._transport.send_message_streaming( - before_args.input.value, context=before_args.context - ) - - async for client_event in self._process_stream( - stream, - before_args=before_args, + transport_call=lambda req, ctx: self._transport.send_message_streaming(req, context=ctx), ): - yield client_event + yield event def _apply_client_config(self, request: SendMessageRequest) -> None: if not request.configuration.blocking and self._config.polling: @@ -386,40 +355,12 @@ async def subscribe( 'client and/or server do not support resubscription.' ) - # Note: resubscribe can only be called on an existing task. As such, - before_args: BeforeArgs[ - Literal['subscribe'], SubscribeToTaskRequest, StreamResponse - ] = BeforeArgs( - input=ClientCallInput(method='subscribe', value=request), - agent_card=self._card, + async for event in self._execute_stream_with_interceptors( + input_data=ClientCallInput(method='subscribe', value=request), context=context, - ) - before_result = await self._intercept_before(before_args) - - if before_result is not None: - after_args = AfterArgs( - result=ClientCallResult( - method=before_args.input.method, - value=before_result['early_return'].value, - ), - agent_card=self._card, - context=before_args.context, - ) - await self._intercept_after( - cast('UnionAfterArgs', after_args), before_result['executed'] - ) - yield after_args.result.value - return - - stream = self._transport.subscribe( - before_args.input.value, context=before_args.context - ) - - async for client_event in self._process_stream( - stream, - before_args=before_args, + transport_call=lambda req, ctx: self._transport.subscribe(req, context=ctx), ): - yield client_event + yield event async def get_extended_agent_card( self, @@ -502,6 +443,39 @@ async def _execute_with_interceptors( await self._intercept_after(cast('UnionAfterArgs', after_args)) return after_args.result.value + + async def _execute_stream_with_interceptors( + self, + input_data: ClientCallInput[M, P], + context: ClientCallContext | None, + transport_call: Callable[[P, ClientCallContext | None], AsyncIterator[StreamResponse]], + ) -> AsyncIterator[ClientEvent]: + + before_args: BeforeArgs[M, P, StreamResponse] = BeforeArgs( + input=input_data, + agent_card=self._card, + context=context, + ) + before_result = await self._intercept_before(cast('UnionBeforeArgs', before_args)) + + if before_result: + after_args: AfterArgs[M, StreamResponse] = AfterArgs( + result=before_result.early_return, + agent_card=self._card, + context=before_args.context, + ) + await self._intercept_after( + cast('UnionAfterArgs', after_args), + before_result.executed + ) + + yield await self._format_stream_event(after_args.result.value) + return + + stream = transport_call(before_args.input.value, before_args.context) + + async for client_event in self._process_stream(stream, before_args): + yield client_event async def _intercept_before( self, @@ -534,3 +508,14 @@ async def _intercept_after( await interceptor.after(args) if args.early_return: return + + async def _format_stream_event(self, stream_response: StreamResponse) -> ClientEvent: + if stream_response.HasField('message'): + client_event = (stream_response, None) + elif stream_response.HasField('task'): + client_event = (stream_response, stream_response.task) + else: + client_event = (stream_response, None) + + await self.consume(client_event, self._card) + return client_event From 92bc02f4989137d4fa3e2f77e40483ab767bdf75 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 12:37:20 +0000 Subject: [PATCH 13/28] refactor: Update stream event processing to use a task manager, adjust `_intercept_before` return type, and optimize message event handling. --- src/a2a/client/base_client.py | 69 +++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 3e43cff77..95e695862 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -1,5 +1,5 @@ from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable -from typing import Any, Literal, cast +from typing import Any, cast from a2a.client.client import ( Client, @@ -108,9 +108,13 @@ async def send_message( return async for event in self._execute_stream_with_interceptors( - input_data=ClientCallInput(method='send_message_streaming', value=request), + input_data=ClientCallInput( + method='send_message_streaming', value=request + ), context=context, - transport_call=lambda req, ctx: self._transport.send_message_streaming(req, context=ctx), + transport_call=lambda req, ctx: ( + self._transport.send_message_streaming(req, context=ctx) + ), ): yield event @@ -148,22 +152,13 @@ async def _process_stream( ) await self._intercept_after(cast('UnionAfterArgs', after_args)) intercepted_response = after_args.result.value - client_event: ClientEvent - # When we get a message in the stream then we don't expect any - # further messages so yield and return + client_event = await self._format_stream_event( + intercepted_response, tracker + ) + yield client_event if intercepted_response.HasField('message'): - client_event = (intercepted_response, None) - await self.consume(client_event, self._card) - yield client_event return - # Otherwise track the task / task update then yield to the client - await tracker.process(intercepted_response) - updated_task = tracker.get_task_or_raise() - client_event = (intercepted_response, updated_task) - await self.consume(client_event, self._card) - yield client_event - async def get_task( self, request: GetTaskRequest, @@ -358,7 +353,9 @@ async def subscribe( async for event in self._execute_stream_with_interceptors( input_data=ClientCallInput(method='subscribe', value=request), context=context, - transport_call=lambda req, ctx: self._transport.subscribe(req, context=ctx), + transport_call=lambda req, ctx: self._transport.subscribe( + req, context=ctx + ), ): yield event @@ -443,12 +440,14 @@ async def _execute_with_interceptors( await self._intercept_after(cast('UnionAfterArgs', after_args)) return after_args.result.value - + async def _execute_stream_with_interceptors( self, input_data: ClientCallInput[M, P], context: ClientCallContext | None, - transport_call: Callable[[P, ClientCallContext | None], AsyncIterator[StreamResponse]], + transport_call: Callable[ + [P, ClientCallContext | None], AsyncIterator[StreamResponse] + ], ) -> AsyncIterator[ClientEvent]: before_args: BeforeArgs[M, P, StreamResponse] = BeforeArgs( @@ -456,20 +455,24 @@ async def _execute_stream_with_interceptors( agent_card=self._card, context=context, ) - before_result = await self._intercept_before(cast('UnionBeforeArgs', before_args)) + before_result = await self._intercept_before( + cast('UnionBeforeArgs', before_args) + ) if before_result: after_args: AfterArgs[M, StreamResponse] = AfterArgs( - result=before_result.early_return, + result=before_result['early_return'], agent_card=self._card, context=before_args.context, ) await self._intercept_after( - cast('UnionAfterArgs', after_args), - before_result.executed + cast('UnionAfterArgs', after_args), before_result['executed'] + ) + + tracker = ClientTaskManager() + yield await self._format_stream_event( + after_args.result.value, tracker ) - - yield await self._format_stream_event(after_args.result.value) return stream = transport_call(before_args.input.value, before_args.context) @@ -509,13 +512,17 @@ async def _intercept_after( if args.early_return: return - async def _format_stream_event(self, stream_response: StreamResponse) -> ClientEvent: + async def _format_stream_event( + self, stream_response: StreamResponse, tracker: ClientTaskManager + ) -> ClientEvent: if stream_response.HasField('message'): client_event = (stream_response, None) - elif stream_response.HasField('task'): - client_event = (stream_response, stream_response.task) - else: - client_event = (stream_response, None) - + await self.consume(client_event, self._card) + return client_event + + await tracker.process(stream_response) + updated_task = tracker.get_task_or_raise() + client_event = (stream_response, updated_task) + await self.consume(client_event, self._card) return client_event From 0dad45db2ea3d8bdda56e3d679678821c6881f56 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 13:24:40 +0000 Subject: [PATCH 14/28] refactor: Migrate authentication logic to the new interceptor pattern and add streaming support to base client interceptors. --- src/a2a/client/auth/interceptor.py | 59 ++++++----- src/a2a/client/base_client.py | 1 + ...middleware.py => test_auth_interceptor.py} | 51 ++++----- tests/client/test_base_client_interceptors.py | 100 ++++++++++++++++++ 4 files changed, 155 insertions(+), 56 deletions(-) rename tests/client/{test_auth_middleware.py => test_auth_interceptor.py} (91%) diff --git a/src/a2a/client/auth/interceptor.py b/src/a2a/client/auth/interceptor.py index 61613081d..aeac4fef8 100644 --- a/src/a2a/client/auth/interceptor.py +++ b/src/a2a/client/auth/interceptor.py @@ -1,14 +1,17 @@ import logging # noqa: I001 -from typing import Any from a2a.client.auth.credentials import CredentialService from a2a.client.client import ClientCallContext -from a2a.types.a2a_pb2 import AgentCard +from a2a.client.interceptors import ( + ClientCallInterceptor, + UnionAfterArgs, + UnionBeforeArgs, +) logger = logging.getLogger(__name__) -class AuthInterceptor: +class AuthInterceptor(ClientCallInterceptor): """An interceptor that automatically adds authentication details to requests. Based on the agent's security schemes. @@ -17,36 +20,34 @@ class AuthInterceptor: def __init__(self, credential_service: CredentialService): self._credential_service = credential_service - async def intercept( - self, - method_name: str, - request_payload: dict[str, Any], - http_kwargs: dict[str, Any], - agent_card: AgentCard | None, - context: ClientCallContext | None, - ) -> tuple[dict[str, Any], dict[str, Any]]: + async def before(self, args: UnionBeforeArgs) -> None: """Applies authentication headers to the request if credentials are available.""" + agent_card = args.agent_card + # Proto3 repeated fields (security) and maps (security_schemes) do not track presence. # HasField() raises ValueError for them. # We check for truthiness to see if they are non-empty. if ( - agent_card is None - or not agent_card.security_requirements + not agent_card.security_requirements or not agent_card.security_schemes ): - return request_payload, http_kwargs + return for requirement in agent_card.security_requirements: for scheme_name in requirement.schemes: credential = await self._credential_service.get_credentials( - scheme_name, context + scheme_name, args.context ) if credential and scheme_name in agent_card.security_schemes: scheme = agent_card.security_schemes.get(scheme_name) if not scheme: continue - headers = http_kwargs.get('headers', {}) + if args.context is None: + args.context = ClientCallContext() + + if args.context.service_parameters is None: + args.context.service_parameters = {} # HTTP Bearer authentication if ( @@ -54,25 +55,27 @@ async def intercept( and scheme.http_auth_security_scheme.scheme.lower() == 'bearer' ): - headers['Authorization'] = f'Bearer {credential}' + args.context.service_parameters['Authorization'] = ( + f'Bearer {credential}' + ) logger.debug( "Added Bearer token for scheme '%s'.", scheme_name, ) - http_kwargs['headers'] = headers - return request_payload, http_kwargs + return # OAuth2 and OIDC schemes are implicitly Bearer if scheme.HasField( 'oauth2_security_scheme' ) or scheme.HasField('open_id_connect_security_scheme'): - headers['Authorization'] = f'Bearer {credential}' + args.context.service_parameters['Authorization'] = ( + f'Bearer {credential}' + ) logger.debug( "Added Bearer token for scheme '%s'.", scheme_name, ) - http_kwargs['headers'] = headers - return request_payload, http_kwargs + return # API Key in Header if ( @@ -80,16 +83,16 @@ async def intercept( and scheme.api_key_security_scheme.location.lower() == 'header' ): - headers[scheme.api_key_security_scheme.name] = ( - credential - ) + args.context.service_parameters[ + scheme.api_key_security_scheme.name + ] = credential logger.debug( "Added API Key Header for scheme '%s'.", scheme_name, ) - http_kwargs['headers'] = headers - return request_payload, http_kwargs + return # Note: Other cases like API keys in query/cookie are not handled and will be skipped. - return request_payload, http_kwargs + async def after(self, args: UnionAfterArgs) -> None: + """Invoked after the method is executed.""" diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 95e695862..49d0e3f42 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -515,6 +515,7 @@ async def _intercept_after( async def _format_stream_event( self, stream_response: StreamResponse, tracker: ClientTaskManager ) -> ClientEvent: + client_event: ClientEvent if stream_response.HasField('message'): client_event = (stream_response, None) await self.consume(client_event, self._card) diff --git a/tests/client/test_auth_middleware.py b/tests/client/test_auth_interceptor.py similarity index 91% rename from tests/client/test_auth_middleware.py rename to tests/client/test_auth_interceptor.py index 4d7f9f7fa..c0e11f1c3 100644 --- a/tests/client/test_auth_middleware.py +++ b/tests/client/test_auth_interceptor.py @@ -17,7 +17,7 @@ ClientFactory, InMemoryContextCredentialStore, ) -from a2a.utils.constants import TransportProtocol +from a2a.client.interceptors import BeforeArgs, ClientCallInput from a2a.types.a2a_pb2 import ( APIKeySecurityScheme, AgentCapabilities, @@ -36,6 +36,7 @@ SendMessageResponse, StringList, ) +from a2a.utils.constants import TransportProtocol class HeaderInterceptor(ClientCallInterceptor): @@ -64,7 +65,6 @@ async def intercept( def build_success_response(request: httpx.Request) -> httpx.Response: """Creates a valid JSON-RPC success response based on the request.""" - from a2a.types.a2a_pb2 import SendMessageResponse request_payload = json.loads(request.content) message = Message( @@ -120,19 +120,17 @@ async def test_auth_interceptor_skips_when_no_agent_card( store: InMemoryContextCredentialStore, ) -> None: """Tests that the AuthInterceptor does not modify the request when no AgentCard is provided.""" - request_payload = {'foo': 'bar'} - http_kwargs = {'fizz': 'buzz'} auth_interceptor = AuthInterceptor(credential_service=store) - - new_payload, new_kwargs = await auth_interceptor.intercept( - method_name='SendMessage', - request_payload=request_payload, - http_kwargs=http_kwargs, - agent_card=None, - context=ClientCallContext(state={}), + request = SendMessageRequest(message=Message()) + context = ClientCallContext(state={}) + args = BeforeArgs( + input=ClientCallInput(method='send_message', value=request), + agent_card=AgentCard(), + context=context, ) - assert new_payload == request_payload - assert new_kwargs == http_kwargs + + await auth_interceptor.before(args) + assert context.service_parameters is None @pytest.mark.asyncio @@ -210,14 +208,13 @@ def wrap_security_scheme(scheme: Any) -> SecurityScheme: """Wraps a security scheme in the correct SecurityScheme proto field.""" if isinstance(scheme, APIKeySecurityScheme): return SecurityScheme(api_key_security_scheme=scheme) - elif isinstance(scheme, HTTPAuthSecurityScheme): + if isinstance(scheme, HTTPAuthSecurityScheme): return SecurityScheme(http_auth_security_scheme=scheme) - elif isinstance(scheme, OAuth2SecurityScheme): + if isinstance(scheme, OAuth2SecurityScheme): return SecurityScheme(oauth2_security_scheme=scheme) - elif isinstance(scheme, OpenIdConnectSecurityScheme): + if isinstance(scheme, OpenIdConnectSecurityScheme): return SecurityScheme(open_id_connect_security_scheme=scheme) - else: - raise ValueError(f'Unknown security scheme type: {type(scheme)}') + raise ValueError(f'Unknown security scheme type: {type(scheme)}') @dataclass @@ -363,8 +360,6 @@ async def test_auth_interceptor_skips_when_scheme_not_in_security_schemes( scheme_name = 'missing' session_id = 'session-id' credential = 'test-token' - request_payload = {'foo': 'bar'} - http_kwargs = {'fizz': 'buzz'} await store.set_credentials(session_id, scheme_name, credential) auth_interceptor = AuthInterceptor(credential_service=store) agent_card = AgentCard( @@ -386,13 +381,13 @@ async def test_auth_interceptor_skips_when_scheme_not_in_security_schemes( ], security_schemes={}, ) - - new_payload, new_kwargs = await auth_interceptor.intercept( - method_name='SendMessage', - request_payload=request_payload, - http_kwargs=http_kwargs, + request = SendMessageRequest(message=Message()) + context = ClientCallContext(state={'sessionId': session_id}) + args = BeforeArgs( + input=ClientCallInput(method='send_message', value=request), agent_card=agent_card, - context=ClientCallContext(state={'sessionId': session_id}), + context=context, ) - assert new_payload == request_payload - assert new_kwargs == http_kwargs + + await auth_interceptor.before(args) + assert context.service_parameters is None diff --git a/tests/client/test_base_client_interceptors.py b/tests/client/test_base_client_interceptors.py index 093cd6c6f..31bd8d87d 100644 --- a/tests/client/test_base_client_interceptors.py +++ b/tests/client/test_base_client_interceptors.py @@ -17,6 +17,8 @@ AgentCapabilities, AgentCard, AgentInterface, + Message, + StreamResponse, ) @@ -142,3 +144,101 @@ async def mock_before_with_early_return(args: BeforeArgs): assert isinstance(after_args, AfterArgs) assert after_args.result.value == 'early_result' assert after_args.context == context + + @pytest.mark.asyncio + async def test_execute_stream_with_interceptors_normal_flow( + self, + base_client: BaseClient, + mock_interceptor: AsyncMock, + ): + input_data = ClientCallInput( + method='send_message_streaming', value=MagicMock() + ) + context = MagicMock() + + async def mock_transport_call(*args, **kwargs): + yield StreamResponse(message=Message(message_id='1')) + + # Set up mock interceptor to just pass through + mock_interceptor.before.return_value = None + + events = [ + e + async for e in base_client._execute_stream_with_interceptors( + input_data=input_data, + context=context, + transport_call=mock_transport_call, + ) + ] + + assert len(events) == 1 + + # Verify before was called + mock_interceptor.before.assert_called_once() + before_args = mock_interceptor.before.call_args[0][0] + assert isinstance(before_args, BeforeArgs) + assert before_args.input == input_data + assert before_args.context == context + + # Verify after was called + mock_interceptor.after.assert_called_once() + after_args = mock_interceptor.after.call_args[0][0] + assert isinstance(after_args, AfterArgs) + assert after_args.result.method == 'send_message_streaming' + + @pytest.mark.asyncio + async def test_execute_stream_with_interceptors_early_return( + self, + base_client: BaseClient, + mock_interceptor: AsyncMock, + ): + input_data = ClientCallInput( + method='send_message_streaming', value=MagicMock() + ) + context = MagicMock() + mock_transport_call = AsyncMock() + + # Set up early return in before + early_return_result = ClientCallResult( + method='send_message_streaming', + value=StreamResponse(message=Message(message_id='2')), + ) + + async def mock_before_with_early_return(args: BeforeArgs): + args.early_return = early_return_result + return { + 'early_return': early_return_result, + 'executed': [mock_interceptor], + } + + mock_interceptor.before.side_effect = mock_before_with_early_return + + # Override BaseClient's _intercept_before to respect our early return setup + # as the test's mock interceptor replaces the actual list items + base_client._intercept_before = AsyncMock( + return_value={ + 'early_return': early_return_result, + 'executed': [mock_interceptor], + } + ) + + events = [ + e + async for e in base_client._execute_stream_with_interceptors( + input_data=input_data, + context=context, + transport_call=mock_transport_call, + ) + ] + + assert len(events) == 1 + + # Verify transport call was NOT made + mock_transport_call.assert_not_called() + + # Verify after was called with early return value + mock_interceptor.after.assert_called_once() + after_args = mock_interceptor.after.call_args[0][0] + assert isinstance(after_args, AfterArgs) + assert after_args.result.method == 'send_message_streaming' + assert after_args.context == context From 191c9700fd61d2ad4f9c7b443b86867fb201167c Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Tue, 10 Mar 2026 16:21:25 +0000 Subject: [PATCH 15/28] refactor: simplify interceptor argument types by removing generic type variables and union aliases. --- src/a2a/client/auth/interceptor.py | 8 +- src/a2a/client/base_client.py | 51 +++++-------- src/a2a/client/interceptors.py | 118 ++++------------------------- 3 files changed, 41 insertions(+), 136 deletions(-) diff --git a/src/a2a/client/auth/interceptor.py b/src/a2a/client/auth/interceptor.py index aeac4fef8..a29f9881c 100644 --- a/src/a2a/client/auth/interceptor.py +++ b/src/a2a/client/auth/interceptor.py @@ -3,9 +3,9 @@ from a2a.client.auth.credentials import CredentialService from a2a.client.client import ClientCallContext from a2a.client.interceptors import ( + AfterArgs, + BeforeArgs, ClientCallInterceptor, - UnionAfterArgs, - UnionBeforeArgs, ) logger = logging.getLogger(__name__) @@ -20,7 +20,7 @@ class AuthInterceptor(ClientCallInterceptor): def __init__(self, credential_service: CredentialService): self._credential_service = credential_service - async def before(self, args: UnionBeforeArgs) -> None: + async def before(self, args: BeforeArgs) -> None: """Applies authentication headers to the request if credentials are available.""" agent_card = args.agent_card @@ -94,5 +94,5 @@ async def before(self, args: UnionBeforeArgs) -> None: # Note: Other cases like API keys in query/cookie are not handled and will be skipped. - async def after(self, args: UnionAfterArgs) -> None: + async def after(self, args: AfterArgs) -> None: """Invoked after the method is executed.""" diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 49d0e3f42..71e475903 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -1,5 +1,5 @@ from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable -from typing import Any, cast +from typing import Any from a2a.client.client import ( Client, @@ -15,11 +15,6 @@ ClientCallInput, ClientCallInterceptor, ClientCallResult, - M, - P, - R, - UnionAfterArgs, - UnionBeforeArgs, ) from a2a.client.transports.base import ClientTransport from a2a.types.a2a_pb2 import ( @@ -150,7 +145,7 @@ async def _process_stream( agent_card=self._card, context=before_args.context, ) - await self._intercept_after(cast('UnionAfterArgs', after_args)) + await self._intercept_after(after_args) intercepted_response = after_args.result.value client_event = await self._format_stream_event( intercepted_response, tracker @@ -400,21 +395,21 @@ async def close(self) -> None: async def _execute_with_interceptors( self, - input_data: ClientCallInput[M, P], + input_data: ClientCallInput, context: ClientCallContext | None, - transport_call: Callable[[P, ClientCallContext | None], Awaitable[R]], - ) -> R: - before_args: BeforeArgs[M, P, R] = BeforeArgs( + transport_call: Callable[ + [Any, ClientCallContext | None], Awaitable[Any] + ], + ) -> Any: + before_args = BeforeArgs( input=input_data, agent_card=self._card, context=context, ) - before_result = await self._intercept_before( - cast('UnionBeforeArgs', before_args) - ) + before_result = await self._intercept_before(before_args) if before_result is not None: - early_after_args: AfterArgs[M, R] = AfterArgs( + early_after_args = AfterArgs( result=ClientCallResult( method=input_data.method, value=before_result['early_return'].value, @@ -423,7 +418,7 @@ async def _execute_with_interceptors( context=before_args.context, ) await self._intercept_after( - cast('UnionAfterArgs', early_after_args), + early_after_args, before_result['executed'], ) return early_after_args.result.value @@ -432,42 +427,38 @@ async def _execute_with_interceptors( before_args.input.value, before_args.context ) - after_args: AfterArgs[M, R] = AfterArgs( + after_args = AfterArgs( result=ClientCallResult(method=input_data.method, value=result), agent_card=self._card, context=before_args.context, ) - await self._intercept_after(cast('UnionAfterArgs', after_args)) + await self._intercept_after(after_args) return after_args.result.value async def _execute_stream_with_interceptors( self, - input_data: ClientCallInput[M, P], + input_data: ClientCallInput, context: ClientCallContext | None, transport_call: Callable[ - [P, ClientCallContext | None], AsyncIterator[StreamResponse] + [Any, ClientCallContext | None], AsyncIterator[StreamResponse] ], ) -> AsyncIterator[ClientEvent]: - before_args: BeforeArgs[M, P, StreamResponse] = BeforeArgs( + before_args = BeforeArgs( input=input_data, agent_card=self._card, context=context, ) - before_result = await self._intercept_before( - cast('UnionBeforeArgs', before_args) - ) + before_result = await self._intercept_before(before_args) if before_result: - after_args: AfterArgs[M, StreamResponse] = AfterArgs( + after_args = AfterArgs( result=before_result['early_return'], agent_card=self._card, context=before_args.context, ) - await self._intercept_after( - cast('UnionAfterArgs', after_args), before_result['executed'] - ) + await self._intercept_after(after_args, before_result['executed']) tracker = ClientTaskManager() yield await self._format_stream_event( @@ -482,7 +473,7 @@ async def _execute_stream_with_interceptors( async def _intercept_before( self, - args: UnionBeforeArgs, + args: BeforeArgs, ) -> dict[str, Any] | None: if not self._interceptors: return None @@ -499,7 +490,7 @@ async def _intercept_before( async def _intercept_after( self, - args: UnionAfterArgs, + args: AfterArgs, interceptors: list[ClientCallInterceptor] | None = None, ) -> None: interceptors_to_use = ( diff --git a/src/a2a/client/interceptors.py b/src/a2a/client/interceptors.py index 911929301..e9ddbfd3c 100644 --- a/src/a2a/client/interceptors.py +++ b/src/a2a/client/interceptors.py @@ -1,8 +1,8 @@ from __future__ import annotations -from abc import ABC, abstractmethod +from abc import abstractmethod from dataclasses import dataclass -from typing import TYPE_CHECKING, Generic, Literal, TypeAlias, TypeVar +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: @@ -10,66 +10,46 @@ from a2a.types.a2a_pb2 import ( # noqa: TC001 AgentCard, - CancelTaskRequest, - DeleteTaskPushNotificationConfigRequest, - GetExtendedAgentCardRequest, - GetTaskPushNotificationConfigRequest, - GetTaskRequest, - ListTaskPushNotificationConfigsRequest, - ListTaskPushNotificationConfigsResponse, - ListTasksRequest, - ListTasksResponse, - SendMessageRequest, - SendMessageResponse, - StreamResponse, - SubscribeToTaskRequest, - Task, - TaskPushNotificationConfig, ) -M = TypeVar('M') -P = TypeVar('P') -R = TypeVar('R') - - @dataclass -class ClientCallInput(Generic[M, P]): +class ClientCallInput: """Represents the method and its associated input arguments payload.""" - method: M - value: P + method: str + value: Any @dataclass -class ClientCallResult(Generic[M, R]): +class ClientCallResult: """Represents the method and its associated result payload.""" - method: M - value: R + method: str + value: Any @dataclass -class BeforeArgs(Generic[M, P, R]): +class BeforeArgs: """Arguments passed to the interceptor before a method call.""" - input: ClientCallInput[M, P] + input: ClientCallInput agent_card: AgentCard context: ClientCallContext | None = None - early_return: ClientCallResult[M, R] | None = None + early_return: ClientCallResult | None = None @dataclass -class AfterArgs(Generic[M, R]): +class AfterArgs: """Arguments passed to the interceptor after a method call completes.""" - result: ClientCallResult[M, R] + result: ClientCallResult agent_card: AgentCard context: ClientCallContext | None = None early_return: bool = False -class ClientCallInterceptor(ABC, Generic[M, P, R]): +class ClientCallInterceptor: """An abstract base class for client-side call interceptors. Interceptors can inspect and modify requests before they are sent, @@ -77,75 +57,9 @@ class ClientCallInterceptor(ABC, Generic[M, P, R]): """ @abstractmethod - async def before(self, args: UnionBeforeArgs) -> None: + async def before(self, args: BeforeArgs) -> None: """Invoked before transport method.""" @abstractmethod - async def after(self, args: UnionAfterArgs) -> None: + async def after(self, args: AfterArgs) -> None: """Invoked after transport method.""" - - -UnionBeforeArgs: TypeAlias = ( - BeforeArgs[ - Literal['send_message'], 'SendMessageRequest', 'SendMessageResponse' - ] - | BeforeArgs[ - Literal['send_message_streaming'], - 'SendMessageRequest', - 'StreamResponse', - ] - | BeforeArgs[Literal['get_task'], 'GetTaskRequest', 'Task'] - | BeforeArgs[Literal['list_tasks'], 'ListTasksRequest', 'ListTasksResponse'] - | BeforeArgs[Literal['cancel_task'], 'CancelTaskRequest', 'Task'] - | BeforeArgs[ - Literal['create_task_push_notification_config'], - 'TaskPushNotificationConfig', - 'TaskPushNotificationConfig', - ] - | BeforeArgs[ - Literal['get_task_push_notification_config'], - 'GetTaskPushNotificationConfigRequest', - 'TaskPushNotificationConfig', - ] - | BeforeArgs[ - Literal['list_task_push_notification_configs'], - 'ListTaskPushNotificationConfigsRequest', - 'ListTaskPushNotificationConfigsResponse', - ] - | BeforeArgs[ - Literal['delete_task_push_notification_config'], - 'DeleteTaskPushNotificationConfigRequest', - None, - ] - | BeforeArgs[ - Literal['subscribe'], 'SubscribeToTaskRequest', 'StreamResponse' - ] - | BeforeArgs[ - Literal['get_extended_agent_card'], - 'GetExtendedAgentCardRequest', - 'AgentCard', - ] -) - -UnionAfterArgs: TypeAlias = ( - AfterArgs[Literal['send_message'], 'SendMessageResponse'] - | AfterArgs[Literal['send_message_streaming'], 'StreamResponse'] - | AfterArgs[Literal['get_task'], 'Task'] - | AfterArgs[Literal['list_tasks'], 'ListTasksResponse'] - | AfterArgs[Literal['cancel_task'], 'Task'] - | AfterArgs[ - Literal['create_task_push_notification_config'], - 'TaskPushNotificationConfig', - ] - | AfterArgs[ - Literal['get_task_push_notification_config'], - 'TaskPushNotificationConfig', - ] - | AfterArgs[ - Literal['list_task_push_notification_configs'], - 'ListTaskPushNotificationConfigsResponse', - ] - | AfterArgs[Literal['delete_task_push_notification_config'], None] - | AfterArgs[Literal['subscribe'], 'StreamResponse'] - | AfterArgs[Literal['get_extended_agent_card'], 'AgentCard'] -) From afb7df9c3a5733f8fbfb4e37c3088e359c185460 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Fri, 13 Mar 2026 13:40:38 +0000 Subject: [PATCH 16/28] refactor: make ClientCallInterceptor an abstract base class --- src/a2a/client/interceptors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/a2a/client/interceptors.py b/src/a2a/client/interceptors.py index e9ddbfd3c..707c08549 100644 --- a/src/a2a/client/interceptors.py +++ b/src/a2a/client/interceptors.py @@ -1,6 +1,6 @@ from __future__ import annotations -from abc import abstractmethod +from abc import ABC, abstractmethod from dataclasses import dataclass from typing import TYPE_CHECKING, Any @@ -49,7 +49,7 @@ class AfterArgs: early_return: bool = False -class ClientCallInterceptor: +class ClientCallInterceptor(ABC): """An abstract base class for client-side call interceptors. Interceptors can inspect and modify requests before they are sent, From 19da397dd23d4974b7579b488c237edb2a117ce6 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Fri, 13 Mar 2026 14:22:12 +0000 Subject: [PATCH 17/28] fix --- src/a2a/client/base_client.py | 86 +++++++++---------- src/a2a/client/client_factory.py | 17 ++-- src/a2a/client/interceptors.py | 25 ++---- src/a2a/compat/v0_3/jsonrpc_transport.py | 4 +- src/a2a/compat/v0_3/rest_transport.py | 4 +- tests/client/test_auth_interceptor.py | 67 ++------------- tests/client/test_base_client_interceptors.py | 45 +++++----- tests/client/transports/test_grpc_client.py | 2 +- 8 files changed, 83 insertions(+), 167 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 776d798a6..d96a8c404 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -12,9 +12,7 @@ from a2a.client.interceptors import ( AfterArgs, BeforeArgs, - ClientCallInput, ClientCallInterceptor, - ClientCallResult, ) from a2a.client.transports.base import ClientTransport from a2a.types.a2a_pb2 import ( @@ -75,9 +73,8 @@ async def send_message( self._apply_client_config(request) if not self._config.streaming or not self._card.capabilities.streaming: response = await self._execute_with_interceptors( - input_data=ClientCallInput( - method='send_message', value=request - ), + input_data=request, + method='send_message', context=context, transport_call=lambda req, ctx: self._transport.send_message( req, context=ctx @@ -103,9 +100,8 @@ async def send_message( return async for event in self._execute_stream_with_interceptors( - input_data=ClientCallInput( - method='send_message_streaming', value=request - ), + input_data=request, + method='send_message_streaming', context=context, transport_call=lambda req, ctx: ( self._transport.send_message_streaming(req, context=ctx) @@ -138,14 +134,13 @@ async def _process_stream( tracker = ClientTaskManager() async for stream_response in stream: after_args = AfterArgs( - result=ClientCallResult( - method=before_args.input.method, value=stream_response - ), + result=stream_response, + method=before_args.method, agent_card=self._card, context=before_args.context, ) await self._intercept_after(after_args) - intercepted_response = after_args.result.value + intercepted_response = after_args.result client_event = await self._format_stream_event( intercepted_response, tracker ) @@ -169,7 +164,8 @@ async def get_task( A `Task` object representing the current state of the task. """ return await self._execute_with_interceptors( - input_data=ClientCallInput(method='get_task', value=request), + input_data=request, + method='get_task', context=context, transport_call=lambda req, ctx: self._transport.get_task( req, context=ctx @@ -184,7 +180,8 @@ async def list_tasks( ) -> ListTasksResponse: """Retrieves tasks for an agent.""" return await self._execute_with_interceptors( - input_data=ClientCallInput(method='list_tasks', value=request), + input_data=request, + method='list_tasks', context=context, transport_call=lambda req, ctx: self._transport.list_tasks( req, context=ctx @@ -207,7 +204,8 @@ async def cancel_task( A `Task` object containing the updated task status. """ return await self._execute_with_interceptors( - input_data=ClientCallInput(method='cancel_task', value=request), + input_data=request, + method='cancel_task', context=context, transport_call=lambda req, ctx: self._transport.cancel_task( req, context=ctx @@ -230,9 +228,8 @@ async def create_task_push_notification_config( The created or updated `TaskPushNotificationConfig` object. """ return await self._execute_with_interceptors( - input_data=ClientCallInput( - method='create_task_push_notification_config', value=request - ), + input_data=request, + method='create_task_push_notification_config', context=context, transport_call=lambda req, ctx: ( self._transport.create_task_push_notification_config( @@ -257,9 +254,8 @@ async def get_task_push_notification_config( A `TaskPushNotificationConfig` object containing the configuration. """ return await self._execute_with_interceptors( - input_data=ClientCallInput( - method='get_task_push_notification_config', value=request - ), + input_data=request, + method='get_task_push_notification_config', context=context, transport_call=lambda req, ctx: ( self._transport.get_task_push_notification_config( @@ -284,9 +280,8 @@ async def list_task_push_notification_configs( A `ListTaskPushNotificationConfigsResponse` object. """ return await self._execute_with_interceptors( - input_data=ClientCallInput( - method='list_task_push_notification_configs', value=request - ), + input_data=request, + method='list_task_push_notification_configs', context=context, transport_call=lambda req, ctx: ( self._transport.list_task_push_notification_configs( @@ -308,9 +303,8 @@ async def delete_task_push_notification_config( context: Optional client call context. """ return await self._execute_with_interceptors( - input_data=ClientCallInput( - method='delete_task_push_notification_config', value=request - ), + input_data=request, + method='delete_task_push_notification_config', context=context, transport_call=lambda req, ctx: ( self._transport.delete_task_push_notification_config( @@ -345,7 +339,8 @@ async def subscribe( ) async for event in self._execute_stream_with_interceptors( - input_data=ClientCallInput(method='subscribe', value=request), + input_data=request, + method='subscribe', context=context, transport_call=lambda req, ctx: self._transport.subscribe( req, context=ctx @@ -374,9 +369,8 @@ async def get_extended_agent_card( The `AgentCard` for the agent. """ card = await self._execute_with_interceptors( - input_data=ClientCallInput( - method='get_extended_agent_card', value=request - ), + input_data=request, + method='get_extended_agent_card', context=context, transport_call=lambda req, ctx: ( self._transport.get_extended_agent_card(req, context=ctx) @@ -394,7 +388,8 @@ async def close(self) -> None: async def _execute_with_interceptors( self, - input_data: ClientCallInput, + input_data: Any, + method: str, context: ClientCallContext | None, transport_call: Callable[ [Any, ClientCallContext | None], Awaitable[Any] @@ -402,6 +397,7 @@ async def _execute_with_interceptors( ) -> Any: before_args = BeforeArgs( input=input_data, + method=method, agent_card=self._card, context=context, ) @@ -409,10 +405,8 @@ async def _execute_with_interceptors( if before_result is not None: early_after_args = AfterArgs( - result=ClientCallResult( - method=input_data.method, - value=before_result['early_return'].value, - ), + result=before_result['early_return'], + method=method, agent_card=self._card, context=before_args.context, ) @@ -420,24 +414,24 @@ async def _execute_with_interceptors( early_after_args, before_result['executed'], ) - return early_after_args.result.value + return early_after_args.result - result = await transport_call( - before_args.input.value, before_args.context - ) + result = await transport_call(before_args.input, before_args.context) after_args = AfterArgs( - result=ClientCallResult(method=input_data.method, value=result), + result=result, + method=method, agent_card=self._card, context=before_args.context, ) await self._intercept_after(after_args) - return after_args.result.value + return after_args.result async def _execute_stream_with_interceptors( self, - input_data: ClientCallInput, + input_data: Any, + method: str, context: ClientCallContext | None, transport_call: Callable[ [Any, ClientCallContext | None], AsyncIterator[StreamResponse] @@ -446,6 +440,7 @@ async def _execute_stream_with_interceptors( before_args = BeforeArgs( input=input_data, + method=method, agent_card=self._card, context=context, ) @@ -454,6 +449,7 @@ async def _execute_stream_with_interceptors( if before_result: after_args = AfterArgs( result=before_result['early_return'], + method=method, agent_card=self._card, context=before_args.context, ) @@ -461,11 +457,11 @@ async def _execute_stream_with_interceptors( tracker = ClientTaskManager() yield await self._format_stream_event( - after_args.result.value, tracker + after_args.result, tracker ) return - stream = transport_call(before_args.input.value, before_args.context) + stream = transport_call(before_args.input, before_args.context) async for client_event in self._process_stream(stream, before_args): yield client_event diff --git a/src/a2a/client/client_factory.py b/src/a2a/client/client_factory.py index 1763a327d..311f2a020 100644 --- a/src/a2a/client/client_factory.py +++ b/src/a2a/client/client_factory.py @@ -12,10 +12,10 @@ from a2a.client.base_client import BaseClient from a2a.client.card_resolver import A2ACardResolver from a2a.client.client import Client, ClientConfig, Consumer -from a2a.client.interceptors import ClientCallInterceptor from a2a.client.transports.base import ClientTransport from a2a.client.transports.jsonrpc import JsonRpcTransport from a2a.client.transports.rest import RestTransport +from a2a.client.interceptors import ClientCallInterceptor from a2a.client.transports.tenant_decorator import TenantTransportDecorator from a2a.types.a2a_pb2 import ( AgentCapabilities, @@ -46,7 +46,7 @@ TransportProducer = Callable[ - [AgentCard, str, ClientConfig, list[ClientCallInterceptor]], + [AgentCard, str, ClientConfig], ClientTransport, ] @@ -96,7 +96,6 @@ def jsonrpc_transport_producer( card: AgentCard, url: str, config: ClientConfig, - interceptors: list[ClientCallInterceptor], ) -> ClientTransport: interface = ClientFactory._find_best_interface( list(card.supported_interfaces), @@ -118,14 +117,12 @@ def jsonrpc_transport_producer( cast('httpx.AsyncClient', config.httpx_client), card, url, - interceptors, ) return JsonRpcTransport( cast('httpx.AsyncClient', config.httpx_client), card, url, - interceptors, ) self.register( @@ -138,7 +135,6 @@ def rest_transport_producer( card: AgentCard, url: str, config: ClientConfig, - interceptors: list[ClientCallInterceptor], ) -> ClientTransport: interface = ClientFactory._find_best_interface( list(card.supported_interfaces), @@ -160,14 +156,12 @@ def rest_transport_producer( cast('httpx.AsyncClient', config.httpx_client), card, url, - interceptors, ) return RestTransport( cast('httpx.AsyncClient', config.httpx_client), card, url, - interceptors, ) self.register( @@ -185,7 +179,6 @@ def grpc_transport_producer( card: AgentCard, url: str, config: ClientConfig, - interceptors: list[ClientCallInterceptor], ) -> ClientTransport: # The interface has already been selected and passed as `url`. # We determine its version to use the appropriate transport implementation. @@ -205,11 +198,11 @@ def grpc_transport_producer( and CompatGrpcTransport is not None ): return CompatGrpcTransport.create( - card, url, config, interceptors + card, url, config ) if GrpcTransport is not None: - return GrpcTransport.create(card, url, config, interceptors) + return GrpcTransport.create(card, url, config) raise ImportError( 'GrpcTransport is not available. ' @@ -410,7 +403,7 @@ def create( all_consumers.extend(consumers) transport = self._registry[transport_protocol]( - card, selected_interface.url, self._config, interceptors or [] + card, selected_interface.url, self._config ) if selected_interface.tenant: diff --git a/src/a2a/client/interceptors.py b/src/a2a/client/interceptors.py index 707c08549..32a5b00f0 100644 --- a/src/a2a/client/interceptors.py +++ b/src/a2a/client/interceptors.py @@ -12,38 +12,23 @@ AgentCard, ) - -@dataclass -class ClientCallInput: - """Represents the method and its associated input arguments payload.""" - - method: str - value: Any - - -@dataclass -class ClientCallResult: - """Represents the method and its associated result payload.""" - - method: str - value: Any - - @dataclass class BeforeArgs: """Arguments passed to the interceptor before a method call.""" - input: ClientCallInput + input: Any + method: str agent_card: AgentCard context: ClientCallContext | None = None - early_return: ClientCallResult | None = None + early_return: Any | None = None @dataclass class AfterArgs: """Arguments passed to the interceptor after a method call completes.""" - result: ClientCallResult + result: Any + method: str agent_card: AgentCard context: ClientCallContext | None = None early_return: bool = False diff --git a/src/a2a/compat/v0_3/jsonrpc_transport.py b/src/a2a/compat/v0_3/jsonrpc_transport.py index 0bfb854fd..5868414d7 100644 --- a/src/a2a/compat/v0_3/jsonrpc_transport.py +++ b/src/a2a/compat/v0_3/jsonrpc_transport.py @@ -10,7 +10,7 @@ from jsonrpc.jsonrpc2 import JSONRPC20Request, JSONRPC20Response from a2a.client.errors import A2AClientError -from a2a.client.middleware import ClientCallContext, ClientCallInterceptor +from a2a.client.client import ClientCallContext from a2a.client.transports.base import ClientTransport from a2a.client.transports.http_helpers import ( get_http_args, @@ -58,13 +58,11 @@ def __init__( httpx_client: httpx.AsyncClient, agent_card: AgentCard | None, url: str, - interceptors: list[ClientCallInterceptor] | None = None, ): """Initializes the CompatJsonRpcTransport.""" self.url = url self.httpx_client = httpx_client self.agent_card = agent_card - self.interceptors = interceptors or [] async def send_message( self, diff --git a/src/a2a/compat/v0_3/rest_transport.py b/src/a2a/compat/v0_3/rest_transport.py index f7f2d71c5..10aafef5e 100644 --- a/src/a2a/compat/v0_3/rest_transport.py +++ b/src/a2a/compat/v0_3/rest_transport.py @@ -9,8 +9,8 @@ from google.protobuf.json_format import MessageToDict, Parse, ParseDict from a2a.client.errors import A2AClientError -from a2a.client.middleware import ClientCallContext, ClientCallInterceptor from a2a.client.transports.base import ClientTransport +from a2a.client.client import ClientCallContext from a2a.client.transports.http_helpers import ( get_http_args, send_http_request, @@ -63,13 +63,11 @@ def __init__( httpx_client: httpx.AsyncClient, agent_card: AgentCard | None, url: str, - interceptors: list[ClientCallInterceptor] | None = None, ): """Initializes the CompatRestTransport.""" self.url = url.removesuffix('/') self.httpx_client = httpx_client self.agent_card = agent_card - self.interceptors = interceptors or [] async def send_message( self, diff --git a/tests/client/test_auth_interceptor.py b/tests/client/test_auth_interceptor.py index c0e11f1c3..ba313f6f1 100644 --- a/tests/client/test_auth_interceptor.py +++ b/tests/client/test_auth_interceptor.py @@ -1,3 +1,4 @@ +# ruff: noqa: INP001, S106 import json from collections.abc import Callable @@ -8,16 +9,17 @@ import pytest import respx +from google.protobuf import json_format + from a2a.client import ( AuthInterceptor, Client, ClientCallContext, - ClientCallInterceptor, ClientConfig, ClientFactory, InMemoryContextCredentialStore, ) -from a2a.client.interceptors import BeforeArgs, ClientCallInput +from a2a.client.interceptors import BeforeArgs from a2a.types.a2a_pb2 import ( APIKeySecurityScheme, AgentCapabilities, @@ -39,30 +41,6 @@ from a2a.utils.constants import TransportProtocol -class HeaderInterceptor(ClientCallInterceptor): - """A simple mock interceptor for testing basic middleware functionality.""" - - def __init__(self, header_name: str, header_value: str): - self.header_name = header_name - self.header_value = header_value - - async def intercept( - self, - method_name: str, - request_payload: dict[str, Any], - http_kwargs: dict[str, Any], - agent_card: AgentCard | None, - context: ClientCallContext | None, - ) -> tuple[dict[str, Any], dict[str, Any]]: - headers = http_kwargs.get('headers', {}) - headers[self.header_name] = self.header_value - http_kwargs['headers'] = headers - return request_payload, http_kwargs - - -from google.protobuf import json_format - - def build_success_response(request: httpx.Request) -> httpx.Response: """Creates a valid JSON-RPC success response based on the request.""" @@ -124,7 +102,8 @@ async def test_auth_interceptor_skips_when_no_agent_card( request = SendMessageRequest(message=Message()) context = ClientCallContext(state={}) args = BeforeArgs( - input=ClientCallInput(method='send_message', value=request), + input=request, + method='send_message', agent_card=AgentCard(), context=context, ) @@ -170,38 +149,7 @@ async def test_in_memory_context_credential_store( assert await store.get_credentials(scheme_name, context) == new_credential -@pytest.mark.skip( - reason='Interceptors not explicitly being tested as per use request' -) -@pytest.mark.asyncio -@respx.mock -async def test_client_with_simple_interceptor() -> None: - """Ensures that a custom HeaderInterceptor correctly injects a static header into outbound HTTP requests from the A2AClient.""" - url = 'http://agent.com/rpc' - interceptor = HeaderInterceptor('X-Test-Header', 'Test-Value-123') - card = AgentCard( - supported_interfaces=[ - AgentInterface(url=url, protocol_binding=TransportProtocol.JSONRPC) - ], - name='testbot', - description='test bot', - version='1.0', - default_input_modes=[], - default_output_modes=[], - skills=[], - capabilities=AgentCapabilities(), - ) - - async with httpx.AsyncClient() as http_client: - config = ClientConfig( - httpx_client=http_client, - supported_protocol_bindings=[TransportProtocol.JSONRPC], - ) - factory = ClientFactory(config) - client = factory.create(card, interceptors=[interceptor]) - request = await send_message(client, url) - assert request.headers['x-test-header'] == 'Test-Value-123' def wrap_security_scheme(scheme: Any) -> SecurityScheme: @@ -384,7 +332,8 @@ async def test_auth_interceptor_skips_when_scheme_not_in_security_schemes( request = SendMessageRequest(message=Message()) context = ClientCallContext(state={'sessionId': session_id}) args = BeforeArgs( - input=ClientCallInput(method='send_message', value=request), + input=request, + method='send_message', agent_card=agent_card, context=context, ) diff --git a/tests/client/test_base_client_interceptors.py b/tests/client/test_base_client_interceptors.py index 31bd8d87d..0e7328440 100644 --- a/tests/client/test_base_client_interceptors.py +++ b/tests/client/test_base_client_interceptors.py @@ -8,9 +8,7 @@ from a2a.client.interceptors import ( AfterArgs, BeforeArgs, - ClientCallInput, ClientCallInterceptor, - ClientCallResult, ) from a2a.client.transports.base import ClientTransport from a2a.types.a2a_pb2 import ( @@ -71,7 +69,8 @@ async def test_execute_with_interceptors_normal_flow( base_client: BaseClient, mock_interceptor: AsyncMock, ): - input_data = ClientCallInput(method='get_task', value=MagicMock()) + input_data = MagicMock() + method = 'get_task' context = MagicMock() mock_transport_call = AsyncMock(return_value='transport_result') @@ -80,6 +79,7 @@ async def test_execute_with_interceptors_normal_flow( result = await base_client._execute_with_interceptors( input_data=input_data, + method=method, context=context, transport_call=mock_transport_call, ) @@ -94,14 +94,14 @@ async def test_execute_with_interceptors_normal_flow( assert before_args.context == context # Verify transport call was made - mock_transport_call.assert_called_once_with(input_data.value, context) + mock_transport_call.assert_called_once_with(input_data, context) # Verify after was called mock_interceptor.after.assert_called_once() after_args = mock_interceptor.after.call_args[0][0] assert isinstance(after_args, AfterArgs) - assert after_args.result.method == input_data.method - assert after_args.result.value == 'transport_result' + assert after_args.method == method + assert after_args.result == 'transport_result' assert after_args.context == context @pytest.mark.asyncio @@ -110,14 +110,13 @@ async def test_execute_with_interceptors_early_return( base_client: BaseClient, mock_interceptor: AsyncMock, ): - input_data = ClientCallInput(method='get_task', value=MagicMock()) + input_data = MagicMock() + method = 'get_task' context = MagicMock() mock_transport_call = AsyncMock() # Set up early return in before - early_return_result = ClientCallResult( - method='get_task', value='early_result' - ) + early_return_result = 'early_result' async def mock_before_with_early_return(args: BeforeArgs): args.early_return = early_return_result @@ -126,6 +125,7 @@ async def mock_before_with_early_return(args: BeforeArgs): result = await base_client._execute_with_interceptors( input_data=input_data, + method=method, context=context, transport_call=mock_transport_call, ) @@ -142,7 +142,7 @@ async def mock_before_with_early_return(args: BeforeArgs): mock_interceptor.after.assert_called_once() after_args = mock_interceptor.after.call_args[0][0] assert isinstance(after_args, AfterArgs) - assert after_args.result.value == 'early_result' + assert after_args.result == 'early_result' assert after_args.context == context @pytest.mark.asyncio @@ -151,9 +151,8 @@ async def test_execute_stream_with_interceptors_normal_flow( base_client: BaseClient, mock_interceptor: AsyncMock, ): - input_data = ClientCallInput( - method='send_message_streaming', value=MagicMock() - ) + input_data = MagicMock() + method = 'send_message_streaming' context = MagicMock() async def mock_transport_call(*args, **kwargs): @@ -166,6 +165,7 @@ async def mock_transport_call(*args, **kwargs): e async for e in base_client._execute_stream_with_interceptors( input_data=input_data, + method=method, context=context, transport_call=mock_transport_call, ) @@ -184,7 +184,7 @@ async def mock_transport_call(*args, **kwargs): mock_interceptor.after.assert_called_once() after_args = mock_interceptor.after.call_args[0][0] assert isinstance(after_args, AfterArgs) - assert after_args.result.method == 'send_message_streaming' + assert after_args.method == method @pytest.mark.asyncio async def test_execute_stream_with_interceptors_early_return( @@ -192,17 +192,13 @@ async def test_execute_stream_with_interceptors_early_return( base_client: BaseClient, mock_interceptor: AsyncMock, ): - input_data = ClientCallInput( - method='send_message_streaming', value=MagicMock() - ) + input_data = MagicMock() + method = 'send_message_streaming' context = MagicMock() mock_transport_call = AsyncMock() # Set up early return in before - early_return_result = ClientCallResult( - method='send_message_streaming', - value=StreamResponse(message=Message(message_id='2')), - ) + early_return_result = StreamResponse(message=Message(message_id='2')) async def mock_before_with_early_return(args: BeforeArgs): args.early_return = early_return_result @@ -215,7 +211,7 @@ async def mock_before_with_early_return(args: BeforeArgs): # Override BaseClient's _intercept_before to respect our early return setup # as the test's mock interceptor replaces the actual list items - base_client._intercept_before = AsyncMock( + base_client._intercept_before = AsyncMock( # type: ignore return_value={ 'early_return': early_return_result, 'executed': [mock_interceptor], @@ -226,6 +222,7 @@ async def mock_before_with_early_return(args: BeforeArgs): e async for e in base_client._execute_stream_with_interceptors( input_data=input_data, + method=method, context=context, transport_call=mock_transport_call, ) @@ -240,5 +237,5 @@ async def mock_before_with_early_return(args: BeforeArgs): mock_interceptor.after.assert_called_once() after_args = mock_interceptor.after.call_args[0][0] assert isinstance(after_args, AfterArgs) - assert after_args.result.method == 'send_message_streaming' + assert after_args.method == method assert after_args.context == context diff --git a/tests/client/transports/test_grpc_client.py b/tests/client/transports/test_grpc_client.py index 49c631cac..9e81bd71e 100644 --- a/tests/client/transports/test_grpc_client.py +++ b/tests/client/transports/test_grpc_client.py @@ -6,7 +6,7 @@ from google.protobuf import any_pb2 from google.rpc import error_details_pb2, status_pb2 -from a2a.client.middleware import ClientCallContext +from a2a.client.client import ClientCallContext from a2a.client.transports.grpc import GrpcTransport from a2a.extensions.common import HTTP_EXTENSION_HEADER from a2a.utils.constants import VERSION_HEADER, PROTOCOL_VERSION_CURRENT From 8f562e4fb1339e988b0644abe5bcab762f756fc8 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Fri, 13 Mar 2026 14:43:07 +0000 Subject: [PATCH 18/28] refactor --- src/a2a/client/base_client.py | 4 +--- src/a2a/client/client_factory.py | 11 ++++++----- src/a2a/client/interceptors.py | 1 + src/a2a/client/transports/grpc.py | 2 +- src/a2a/compat/v0_3/jsonrpc_transport.py | 2 +- src/a2a/compat/v0_3/rest_transport.py | 2 +- tests/client/test_auth_interceptor.py | 3 --- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index d96a8c404..a825ef50c 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -456,9 +456,7 @@ async def _execute_stream_with_interceptors( await self._intercept_after(after_args, before_result['executed']) tracker = ClientTaskManager() - yield await self._format_stream_event( - after_args.result, tracker - ) + yield await self._format_stream_event(after_args.result, tracker) return stream = transport_call(before_args.input, before_args.context) diff --git a/src/a2a/client/client_factory.py b/src/a2a/client/client_factory.py index 311f2a020..400647b59 100644 --- a/src/a2a/client/client_factory.py +++ b/src/a2a/client/client_factory.py @@ -3,7 +3,7 @@ import logging from collections.abc import Callable -from typing import Any, cast +from typing import TYPE_CHECKING, Any, cast import httpx @@ -15,7 +15,6 @@ from a2a.client.transports.base import ClientTransport from a2a.client.transports.jsonrpc import JsonRpcTransport from a2a.client.transports.rest import RestTransport -from a2a.client.interceptors import ClientCallInterceptor from a2a.client.transports.tenant_decorator import TenantTransportDecorator from a2a.types.a2a_pb2 import ( AgentCapabilities, @@ -31,6 +30,10 @@ ) +if TYPE_CHECKING: + from a2a.client.interceptors import ClientCallInterceptor + + try: from a2a.client.transports.grpc import GrpcTransport except ImportError: @@ -197,9 +200,7 @@ def grpc_transport_producer( ClientFactory._is_legacy_version(version) and CompatGrpcTransport is not None ): - return CompatGrpcTransport.create( - card, url, config - ) + return CompatGrpcTransport.create(card, url, config) if GrpcTransport is not None: return GrpcTransport.create(card, url, config) diff --git a/src/a2a/client/interceptors.py b/src/a2a/client/interceptors.py index 32a5b00f0..9903708f3 100644 --- a/src/a2a/client/interceptors.py +++ b/src/a2a/client/interceptors.py @@ -12,6 +12,7 @@ AgentCard, ) + @dataclass class BeforeArgs: """Arguments passed to the interceptor before a method call.""" diff --git a/src/a2a/client/transports/grpc.py b/src/a2a/client/transports/grpc.py index f05283b00..02c418eb3 100644 --- a/src/a2a/client/transports/grpc.py +++ b/src/a2a/client/transports/grpc.py @@ -4,8 +4,8 @@ from functools import wraps from typing import Any, NoReturn, cast -from a2a.client.errors import A2AClientError, A2AClientTimeoutError from a2a.client.client import ClientCallContext +from a2a.client.errors import A2AClientError, A2AClientTimeoutError try: diff --git a/src/a2a/compat/v0_3/jsonrpc_transport.py b/src/a2a/compat/v0_3/jsonrpc_transport.py index 5868414d7..6153ccfc0 100644 --- a/src/a2a/compat/v0_3/jsonrpc_transport.py +++ b/src/a2a/compat/v0_3/jsonrpc_transport.py @@ -9,8 +9,8 @@ from jsonrpc.jsonrpc2 import JSONRPC20Request, JSONRPC20Response -from a2a.client.errors import A2AClientError from a2a.client.client import ClientCallContext +from a2a.client.errors import A2AClientError from a2a.client.transports.base import ClientTransport from a2a.client.transports.http_helpers import ( get_http_args, diff --git a/src/a2a/compat/v0_3/rest_transport.py b/src/a2a/compat/v0_3/rest_transport.py index 10aafef5e..7b04f9d70 100644 --- a/src/a2a/compat/v0_3/rest_transport.py +++ b/src/a2a/compat/v0_3/rest_transport.py @@ -8,9 +8,9 @@ from google.protobuf.json_format import MessageToDict, Parse, ParseDict +from a2a.client.client import ClientCallContext from a2a.client.errors import A2AClientError from a2a.client.transports.base import ClientTransport -from a2a.client.client import ClientCallContext from a2a.client.transports.http_helpers import ( get_http_args, send_http_request, diff --git a/tests/client/test_auth_interceptor.py b/tests/client/test_auth_interceptor.py index ba313f6f1..8713c54eb 100644 --- a/tests/client/test_auth_interceptor.py +++ b/tests/client/test_auth_interceptor.py @@ -149,9 +149,6 @@ async def test_in_memory_context_credential_store( assert await store.get_credentials(scheme_name, context) == new_credential - - - def wrap_security_scheme(scheme: Any) -> SecurityScheme: """Wraps a security scheme in the correct SecurityScheme proto field.""" if isinstance(scheme, APIKeySecurityScheme): From 126283d248977e7be61277ec3a14dd68905b4ed4 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 16 Mar 2026 09:09:13 +0000 Subject: [PATCH 19/28] refactor: Streamline A2A type generation workflow by using a shell script for generation and `gh` CLI for PRs, and remove direct `buf` installation from unit tests. --- .github/workflows/unit-tests.yml | 3 +- .github/workflows/update-a2a-types.yml | 93 +++++++++++++++----------- .gitignore | 1 - pyproject.toml | 8 +-- 4 files changed, 55 insertions(+), 50 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 3b1c07fed..2d5d9b0d0 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -52,8 +52,7 @@ jobs: - name: Add uv to PATH run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Install Buf - uses: bufbuild/buf-setup-action@v1 + - name: Install dependencies run: uv sync --locked - name: Run tests and check coverage diff --git a/.github/workflows/update-a2a-types.yml b/.github/workflows/update-a2a-types.yml index 46dcb130b..2ba32499e 100644 --- a/.github/workflows/update-a2a-types.yml +++ b/.github/workflows/update-a2a-types.yml @@ -1,9 +1,6 @@ --- name: Update A2A Schema from Specification on: -# TODO (https://github.com/a2aproject/a2a-python/issues/559): bring back once types are migrated, currently it generates many broken PRs -# repository_dispatch: -# types: [a2a_json_update] workflow_dispatch: jobs: generate_and_pr: @@ -14,42 +11,58 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v6 - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: '3.10' - - name: Install uv - uses: astral-sh/setup-uv@v7 - - name: Configure uv shell - run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Define output file variable - id: vars + - name: Run scripts/gen_proto.sh run: | - GENERATED_FILE="./src/a2a/types" - echo "GENERATED_FILE=$GENERATED_FILE" >> "$GITHUB_OUTPUT" - - name: Install Buf - uses: bufbuild/buf-setup-action@v1 - - name: Run buf generate - run: | - set -euo pipefail # Exit immediately if a command exits with a non-zero status - echo "Running buf generate..." - buf generate - echo "Buf generate finished." + set -euo pipefail + echo "Running scripts/gen_proto.sh..." + bash scripts/gen_proto.sh + echo "Scripts/gen_proto.sh finished." - name: Create Pull Request with Updates - uses: peter-evans/create-pull-request@v8 - with: - token: ${{ secrets.A2A_BOT_PAT }} - committer: a2a-bot - author: a2a-bot - commit-message: '${{ github.event.client_payload.message }}' - title: '${{ github.event.client_payload.message }}' - body: | - Commit: https://github.com/a2aproject/A2A/commit/${{ github.event.client_payload.sha }} - branch: auto-update-a2a-types-${{ github.event.client_payload.sha }} - base: main - labels: | - automated - dependencies - add-paths: |- - ${{ steps.vars.outputs.GENERATED_FILE }} - src/a2a/grpc/ + env: + GH_TOKEN: ${{ secrets.A2A_BOT_PAT }} + run: | + set -euo pipefail + + # Configure Git + git config --global user.name "a2a-bot" + git config --global user.email "a2a-bot@google.com" + + # Configure remote to use PAT + git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}" + + # Branch name + BRANCH_NAME="auto-update-a2a-types-${{ github.event.client_payload.sha }}" + + # Add files + git add src/a2a/types/ src/a2a/compat/v0_3/ + + # Check for changes + if git diff --staged --quiet; then + echo "No changes to commit. Skipping PR creation." + exit 0 + fi + + # Create and switch to branch + git checkout -b "$BRANCH_NAME" + + # Commit + git commit -m "${{ github.event.client_payload.message }}" + + # Push + # Force push if branch exists (safe if branch name is unique) + git push -u origin "$BRANCH_NAME" --force + + # Check if open PR exists + if gh pr list --head "$BRANCH_NAME" --state open --json url --jq '.[0].url' | grep -q http; then + echo "Open PR already exists. Updating..." + gh pr edit "$BRANCH_NAME" --title "${{ github.event.client_payload.message }}" --body "Commit: https://github.com/a2aproject/A2A/commit/${{ github.event.client_payload.sha }}" + else + echo "Creating new PR..." + gh pr create \ + --title "${{ github.event.client_payload.message }}" \ + --body "Commit: https://github.com/a2aproject/A2A/commit/${{ github.event.client_payload.sha }}" \ + --base main \ + --head "$BRANCH_NAME" \ + --label "automated" \ + --label "dependencies" + fi diff --git a/.gitignore b/.gitignore index 9306b42a1..fcb4f2e92 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,5 @@ test_venv/ coverage.xml .nox spec.json -src/a2a/types/a2a.json docker-compose.yaml .geminiignore diff --git a/pyproject.toml b/pyproject.toml index c57824aed..02b3d24f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,15 +62,9 @@ changelog = "https://github.com/a2aproject/a2a-python/blob/main/CHANGELOG.md" documentation = "https://a2a-protocol.org/latest/sdk/python/" [build-system] -requires = ["hatchling", "uv-dynamic-versioning", "hatch-build-scripts"] +requires = ["hatchling", "uv-dynamic-versioning"] build-backend = "hatchling.build" -[tool.hatch.build.hooks.build-scripts] -artifacts = ["src/a2a/types/a2a.json"] - -[[tool.hatch.build.hooks.build-scripts.scripts]] -commands = ["bash scripts/gen_proto.sh"] -work_dir = "." [tool.hatch.version] source = "uv-dynamic-versioning" From af7eea221a4009f97385d11a4fd49f8410869d49 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 16 Mar 2026 09:26:01 +0000 Subject: [PATCH 20/28] refactor: Extract v0.3 compatibility protobuf generation into a dedicated script and commit generated files. --- scripts/gen_proto.sh | 6 - scripts/gen_proto_compat.sh | 10 + src/a2a/compat/v0_3/.gitignore | 4 - src/a2a/compat/v0_3/a2a_v0_3.proto | 735 +++++++++++++++++++++++ src/a2a/compat/v0_3/a2a_v0_3_pb2.py | 195 ++++++ src/a2a/compat/v0_3/a2a_v0_3_pb2.pyi | 574 ++++++++++++++++++ src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py | 511 ++++++++++++++++ 7 files changed, 2025 insertions(+), 10 deletions(-) create mode 100644 scripts/gen_proto_compat.sh delete mode 100644 src/a2a/compat/v0_3/.gitignore create mode 100644 src/a2a/compat/v0_3/a2a_v0_3.proto create mode 100644 src/a2a/compat/v0_3/a2a_v0_3_pb2.py create mode 100644 src/a2a/compat/v0_3/a2a_v0_3_pb2.pyi create mode 100644 src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py diff --git a/scripts/gen_proto.sh b/scripts/gen_proto.sh index 163ba789b..34ff96ae0 100755 --- a/scripts/gen_proto.sh +++ b/scripts/gen_proto.sh @@ -25,10 +25,4 @@ echo "Downloading legacy v0.3 proto file..." # Commit hash was selected as a2a.proto version from 0.3 branch with latests fixes. curl -o src/a2a/compat/v0_3/a2a_v0_3.proto https://raw.githubusercontent.com/a2aproject/A2A/b3b266d127dde3d1000ec103b252d1de81289e83/specification/grpc/a2a.proto -# Generate legacy v0.3 compatibility protobuf code -echo "Generating legacy v0.3 compatibility protobuf code" -npx --yes @bufbuild/buf generate src/a2a/compat/v0_3 --template buf.compat.gen.yaml -# Fix imports in legacy generated grpc file -echo "Fixing imports in src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py" -sed 's/import a2a_v0_3_pb2 as a2a__v0__3__pb2/from . import a2a_v0_3_pb2 as a2a__v0__3__pb2/g' src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py > src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py.tmp && mv src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py.tmp src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py diff --git a/scripts/gen_proto_compat.sh b/scripts/gen_proto_compat.sh new file mode 100644 index 000000000..c85d2efe2 --- /dev/null +++ b/scripts/gen_proto_compat.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +# Generate legacy v0.3 compatibility protobuf code +echo "Generating legacy v0.3 compatibility protobuf code" +npx --yes @bufbuild/buf generate src/a2a/compat/v0_3 --template buf.compat.gen.yaml + +# Fix imports in legacy generated grpc file +echo "Fixing imports in src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py" +sed 's/import a2a_v0_3_pb2 as a2a__v0__3__pb2/from . import a2a_v0_3_pb2 as a2a__v0__3__pb2/g' src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py > src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py.tmp && mv src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py.tmp src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py diff --git a/src/a2a/compat/v0_3/.gitignore b/src/a2a/compat/v0_3/.gitignore deleted file mode 100644 index fec2beefb..000000000 --- a/src/a2a/compat/v0_3/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*_pb2.py -*_pb2_grpc.py -*_pb2.pyi -a2a_v0_3.proto diff --git a/src/a2a/compat/v0_3/a2a_v0_3.proto b/src/a2a/compat/v0_3/a2a_v0_3.proto new file mode 100644 index 000000000..41eaa0341 --- /dev/null +++ b/src/a2a/compat/v0_3/a2a_v0_3.proto @@ -0,0 +1,735 @@ +// Older protoc compilers don't understand edition yet. +syntax = "proto3"; +package a2a.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "A2a.V1"; +option go_package = "google.golang.org/a2a/v1"; +option java_multiple_files = true; +option java_outer_classname = "A2A"; +option java_package = "com.google.a2a.v1"; + +// A2AService defines the gRPC version of the A2A protocol. This has a slightly +// different shape than the JSONRPC version to better conform to AIP-127, +// where appropriate. The nouns are AgentCard, Message, Task and +// TaskPushNotificationConfig. +// - Messages are not a standard resource so there is no get/delete/update/list +// interface, only a send and stream custom methods. +// - Tasks have a get interface and custom cancel and subscribe methods. +// - TaskPushNotificationConfig are a resource whose parent is a task. +// They have get, list and create methods. +// - AgentCard is a static resource with only a get method. +service A2AService { + // Send a message to the agent. This is a blocking call that will return the + // task once it is completed, or a LRO if requested. + rpc SendMessage(SendMessageRequest) returns (SendMessageResponse) { + option (google.api.http) = { + post: "/v1/message:send" + body: "*" + }; + } + // SendStreamingMessage is a streaming call that will return a stream of + // task update events until the Task is in an interrupted or terminal state. + rpc SendStreamingMessage(SendMessageRequest) returns (stream StreamResponse) { + option (google.api.http) = { + post: "/v1/message:stream" + body: "*" + }; + } + + // Get the current state of a task from the agent. + rpc GetTask(GetTaskRequest) returns (Task) { + option (google.api.http) = { + get: "/v1/{name=tasks/*}" + }; + option (google.api.method_signature) = "name"; + } + // Cancel a task from the agent. If supported one should expect no + // more task updates for the task. + rpc CancelTask(CancelTaskRequest) returns (Task) { + option (google.api.http) = { + post: "/v1/{name=tasks/*}:cancel" + body: "*" + }; + } + // TaskSubscription is a streaming call that will return a stream of task + // update events. This attaches the stream to an existing in process task. + // If the task is complete the stream will return the completed task (like + // GetTask) and close the stream. + rpc TaskSubscription(TaskSubscriptionRequest) + returns (stream StreamResponse) { + option (google.api.http) = { + get: "/v1/{name=tasks/*}:subscribe" + }; + } + + // Set a push notification config for a task. + rpc CreateTaskPushNotificationConfig(CreateTaskPushNotificationConfigRequest) + returns (TaskPushNotificationConfig) { + option (google.api.http) = { + post: "/v1/{parent=tasks/*/pushNotificationConfigs}" + body: "config" + }; + option (google.api.method_signature) = "parent,config"; + } + // Get a push notification config for a task. + rpc GetTaskPushNotificationConfig(GetTaskPushNotificationConfigRequest) + returns (TaskPushNotificationConfig) { + option (google.api.http) = { + get: "/v1/{name=tasks/*/pushNotificationConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + // Get a list of push notifications configured for a task. + rpc ListTaskPushNotificationConfig(ListTaskPushNotificationConfigRequest) + returns (ListTaskPushNotificationConfigResponse) { + option (google.api.http) = { + get: "/v1/{parent=tasks/*}/pushNotificationConfigs" + }; + option (google.api.method_signature) = "parent"; + } + // GetAgentCard returns the agent card for the agent. + rpc GetAgentCard(GetAgentCardRequest) returns (AgentCard) { + option (google.api.http) = { + get: "/v1/card" + }; + } + // Delete a push notification config for a task. + rpc DeleteTaskPushNotificationConfig(DeleteTaskPushNotificationConfigRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=tasks/*/pushNotificationConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } +} + +///////// Data Model //////////// + +// Configuration of a send message request. +message SendMessageConfiguration { + // The output modes that the agent is expected to respond with. + repeated string accepted_output_modes = 1; + // A configuration of a webhook that can be used to receive updates + PushNotificationConfig push_notification = 2; + // The maximum number of messages to include in the history. if 0, the + // history will be unlimited. + int32 history_length = 3; + // If true, the message will be blocking until the task is completed. If + // false, the message will be non-blocking and the task will be returned + // immediately. It is the caller's responsibility to check for any task + // updates. + bool blocking = 4; +} + +// Task is the core unit of action for A2A. It has a current status +// and when results are created for the task they are stored in the +// artifact. If there are multiple turns for a task, these are stored in +// history. +message Task { + // Unique identifier (e.g. UUID) for the task, generated by the server for a + // new task. + string id = 1; + // Unique identifier (e.g. UUID) for the contextual collection of interactions + // (tasks and messages). Created by the A2A server. + string context_id = 2; + // The current status of a Task, including state and a message. + TaskStatus status = 3; + // A set of output artifacts for a Task. + repeated Artifact artifacts = 4; + // protolint:disable REPEATED_FIELD_NAMES_PLURALIZED + // The history of interactions from a task. + repeated Message history = 5; + // protolint:enable REPEATED_FIELD_NAMES_PLURALIZED + // A key/value object to store custom metadata about a task. + google.protobuf.Struct metadata = 6; +} + +// The set of states a Task can be in. +enum TaskState { + TASK_STATE_UNSPECIFIED = 0; + // Represents the status that acknowledges a task is created + TASK_STATE_SUBMITTED = 1; + // Represents the status that a task is actively being processed + TASK_STATE_WORKING = 2; + // Represents the status a task is finished. This is a terminal state + TASK_STATE_COMPLETED = 3; + // Represents the status a task is done but failed. This is a terminal state + TASK_STATE_FAILED = 4; + // Represents the status a task was cancelled before it finished. + // This is a terminal state. + TASK_STATE_CANCELLED = 5; + // Represents the status that the task requires information to complete. + // This is an interrupted state. + TASK_STATE_INPUT_REQUIRED = 6; + // Represents the status that the agent has decided to not perform the task. + // This may be done during initial task creation or later once an agent + // has determined it can't or won't proceed. This is a terminal state. + TASK_STATE_REJECTED = 7; + // Represents the state that some authentication is needed from the upstream + // client. Authentication is expected to come out-of-band thus this is not + // an interrupted or terminal state. + TASK_STATE_AUTH_REQUIRED = 8; +} + +// A container for the status of a task +message TaskStatus { + // The current state of this task + TaskState state = 1; + // A message associated with the status. + Message update = 2 [json_name = "message"]; + // Timestamp when the status was recorded. + // Example: "2023-10-27T10:00:00Z" + google.protobuf.Timestamp timestamp = 3; +} + +// Part represents a container for a section of communication content. +// Parts can be purely textual, some sort of file (image, video, etc) or +// a structured data blob (i.e. JSON). +message Part { + oneof part { + string text = 1; + FilePart file = 2; + DataPart data = 3; + } + // Optional metadata associated with this part. + google.protobuf.Struct metadata = 4; +} + +// FilePart represents the different ways files can be provided. If files are +// small, directly feeding the bytes is supported via file_with_bytes. If the +// file is large, the agent should read the content as appropriate directly +// from the file_with_uri source. +message FilePart { + oneof file { + string file_with_uri = 1; + bytes file_with_bytes = 2; + } + string mime_type = 3; + string name = 4; +} + +// DataPart represents a structured blob. This is most commonly a JSON payload. +message DataPart { + google.protobuf.Struct data = 1; +} + +enum Role { + ROLE_UNSPECIFIED = 0; + // USER role refers to communication from the client to the server. + ROLE_USER = 1; + // AGENT role refers to communication from the server to the client. + ROLE_AGENT = 2; +} + +// Message is one unit of communication between client and server. It is +// associated with a context and optionally a task. Since the server is +// responsible for the context definition, it must always provide a context_id +// in its messages. The client can optionally provide the context_id if it +// knows the context to associate the message to. Similarly for task_id, +// except the server decides if a task is created and whether to include the +// task_id. +message Message { + // The unique identifier (e.g. UUID)of the message. This is required and + // created by the message creator. + string message_id = 1; + // The context id of the message. This is optional and if set, the message + // will be associated with the given context. + string context_id = 2; + // The task id of the message. This is optional and if set, the message + // will be associated with the given task. + string task_id = 3; + // A role for the message. + Role role = 4; + // protolint:disable REPEATED_FIELD_NAMES_PLURALIZED + // Content is the container of the message content. + repeated Part content = 5; + // protolint:enable REPEATED_FIELD_NAMES_PLURALIZED + // Any optional metadata to provide along with the message. + google.protobuf.Struct metadata = 6; + // The URIs of extensions that are present or contributed to this Message. + repeated string extensions = 7; +} + +// Artifacts are the container for task completed results. These are similar +// to Messages but are intended to be the product of a task, as opposed to +// point-to-point communication. +message Artifact { + // Unique identifier (e.g. UUID) for the artifact. It must be at least unique + // within a task. + string artifact_id = 1; + // A human readable name for the artifact. + string name = 3; + // A human readable description of the artifact, optional. + string description = 4; + // The content of the artifact. + repeated Part parts = 5; + // Optional metadata included with the artifact. + google.protobuf.Struct metadata = 6; + // The URIs of extensions that are present or contributed to this Artifact. + repeated string extensions = 7; +} + +// TaskStatusUpdateEvent is a delta even on a task indicating that a task +// has changed. +message TaskStatusUpdateEvent { + // The id of the task that is changed + string task_id = 1; + // The id of the context that the task belongs to + string context_id = 2; + // The new status of the task. + TaskStatus status = 3; + // Whether this is the last status update expected for this task. + bool final = 4; + // Optional metadata to associate with the task update. + google.protobuf.Struct metadata = 5; +} + +// TaskArtifactUpdateEvent represents a task delta where an artifact has +// been generated. +message TaskArtifactUpdateEvent { + // The id of the task for this artifact + string task_id = 1; + // The id of the context that this task belongs too + string context_id = 2; + // The artifact itself + Artifact artifact = 3; + // Whether this should be appended to a prior one produced + bool append = 4; + // Whether this represents the last part of an artifact + bool last_chunk = 5; + // Optional metadata associated with the artifact update. + google.protobuf.Struct metadata = 6; +} + +// Configuration for setting up push notifications for task updates. +message PushNotificationConfig { + // A unique identifier (e.g. UUID) for this push notification. + string id = 1; + // Url to send the notification too + string url = 2; + // Token unique for this task/session + string token = 3; + // Information about the authentication to sent with the notification + AuthenticationInfo authentication = 4; +} + +// Defines authentication details, used for push notifications. +message AuthenticationInfo { + // Supported authentication schemes - e.g. Basic, Bearer, etc + repeated string schemes = 1; + // Optional credentials + string credentials = 2; +} + +// Defines additional transport information for the agent. +message AgentInterface { + // The url this interface is found at. + string url = 1; + // The transport supported this url. This is an open form string, to be + // easily extended for many transport protocols. The core ones officially + // supported are JSONRPC, GRPC and HTTP+JSON. + string transport = 2; +} + +// AgentCard conveys key information: +// - Overall details (version, name, description, uses) +// - Skills; a set of actions/solutions the agent can perform +// - Default modalities/content types supported by the agent. +// - Authentication requirements +// Next ID: 19 +message AgentCard { + // The version of the A2A protocol this agent supports. + string protocol_version = 16; + // A human readable name for the agent. + // Example: "Recipe Agent" + string name = 1; + // A description of the agent's domain of action/solution space. + // Example: "Agent that helps users with recipes and cooking." + string description = 2; + // A URL to the address the agent is hosted at. This represents the + // preferred endpoint as declared by the agent. + string url = 3; + // The transport of the preferred endpoint. If empty, defaults to JSONRPC. + string preferred_transport = 14; + // Announcement of additional supported transports. Client can use any of + // the supported transports. + repeated AgentInterface additional_interfaces = 15; + // The service provider of the agent. + AgentProvider provider = 4; + // The version of the agent. + // Example: "1.0.0" + string version = 5; + // A url to provide additional documentation about the agent. + string documentation_url = 6; + // A2A Capability set supported by the agent. + AgentCapabilities capabilities = 7; + // The security scheme details used for authenticating with this agent. + map security_schemes = 8; + // protolint:disable REPEATED_FIELD_NAMES_PLURALIZED + // Security requirements for contacting the agent. + // This list can be seen as an OR of ANDs. Each object in the list describes + // one possible set of security requirements that must be present on a + // request. This allows specifying, for example, "callers must either use + // OAuth OR an API Key AND mTLS." + // Example: + // security { + // schemes { key: "oauth" value { list: ["read"] } } + // } + // security { + // schemes { key: "api-key" } + // schemes { key: "mtls" } + // } + repeated Security security = 9; + // protolint:enable REPEATED_FIELD_NAMES_PLURALIZED + // The set of interaction modes that the agent supports across all skills. + // This can be overridden per skill. Defined as mime types. + repeated string default_input_modes = 10; + // The mime types supported as outputs from this agent. + repeated string default_output_modes = 11; + // Skills represent a unit of ability an agent can perform. This may + // somewhat abstract but represents a more focused set of actions that the + // agent is highly likely to succeed at. + repeated AgentSkill skills = 12; + // Whether the agent supports providing an extended agent card when + // the user is authenticated, i.e. is the card from .well-known + // different than the card from GetAgentCard. + bool supports_authenticated_extended_card = 13; + // JSON Web Signatures computed for this AgentCard. + repeated AgentCardSignature signatures = 17; + // An optional URL to an icon for the agent. + string icon_url = 18; +} + +// Represents information about the service provider of an agent. +message AgentProvider { + // The providers reference url + // Example: "https://ai.google.dev" + string url = 1; + // The providers organization name + // Example: "Google" + string organization = 2; +} + +// Defines the A2A feature set supported by the agent +message AgentCapabilities { + // If the agent will support streaming responses + bool streaming = 1; + // If the agent can send push notifications to the clients webhook + bool push_notifications = 2; + // Extensions supported by this agent. + repeated AgentExtension extensions = 3; +} + +// A declaration of an extension supported by an Agent. +message AgentExtension { + // The URI of the extension. + // Example: "https://developers.google.com/identity/protocols/oauth2" + string uri = 1; + // A description of how this agent uses this extension. + // Example: "Google OAuth 2.0 authentication" + string description = 2; + // Whether the client must follow specific requirements of the extension. + // Example: false + bool required = 3; + // Optional configuration for the extension. + google.protobuf.Struct params = 4; +} + +// AgentSkill represents a unit of action/solution that the agent can perform. +// One can think of this as a type of highly reliable solution that an agent +// can be tasked to provide. Agents have the autonomy to choose how and when +// to use specific skills, but clients should have confidence that if the +// skill is defined that unit of action can be reliably performed. +message AgentSkill { + // Unique identifier of the skill within this agent. + string id = 1; + // A human readable name for the skill. + string name = 2; + // A human (or llm) readable description of the skill + // details and behaviors. + string description = 3; + // A set of tags for the skill to enhance categorization/utilization. + // Example: ["cooking", "customer support", "billing"] + repeated string tags = 4; + // A set of example queries that this skill is designed to address. + // These examples should help the caller to understand how to craft requests + // to the agent to achieve specific goals. + // Example: ["I need a recipe for bread"] + repeated string examples = 5; + // Possible input modalities supported. + repeated string input_modes = 6; + // Possible output modalities produced + repeated string output_modes = 7; + // protolint:disable REPEATED_FIELD_NAMES_PLURALIZED + // Security schemes necessary for the agent to leverage this skill. + // As in the overall AgentCard.security, this list represents a logical OR of + // security requirement objects. Each object is a set of security schemes + // that must be used together (a logical AND). + repeated Security security = 8; + // protolint:enable REPEATED_FIELD_NAMES_PLURALIZED +} + +// AgentCardSignature represents a JWS signature of an AgentCard. +// This follows the JSON format of an RFC 7515 JSON Web Signature (JWS). +message AgentCardSignature { + // The protected JWS header for the signature. This is always a + // base64url-encoded JSON object. Required. + string protected = 1 [(google.api.field_behavior) = REQUIRED]; + // The computed signature, base64url-encoded. Required. + string signature = 2 [(google.api.field_behavior) = REQUIRED]; + // The unprotected JWS header values. + google.protobuf.Struct header = 3; +} + +message TaskPushNotificationConfig { + // The resource name of the config. + // Format: tasks/{task_id}/pushNotificationConfigs/{config_id} + string name = 1; + // The push notification configuration details. + PushNotificationConfig push_notification_config = 2; +} + +// protolint:disable REPEATED_FIELD_NAMES_PLURALIZED +message StringList { + repeated string list = 1; +} +// protolint:enable REPEATED_FIELD_NAMES_PLURALIZED + +message Security { + map schemes = 1; +} + +message SecurityScheme { + oneof scheme { + APIKeySecurityScheme api_key_security_scheme = 1; + HTTPAuthSecurityScheme http_auth_security_scheme = 2; + OAuth2SecurityScheme oauth2_security_scheme = 3; + OpenIdConnectSecurityScheme open_id_connect_security_scheme = 4; + MutualTlsSecurityScheme mtls_security_scheme = 5; + } +} + +message APIKeySecurityScheme { + // Description of this security scheme. + string description = 1; + // Location of the API key, valid values are "query", "header", or "cookie" + string location = 2; + // Name of the header, query or cookie parameter to be used. + string name = 3; +} + +message HTTPAuthSecurityScheme { + // Description of this security scheme. + string description = 1; + // The name of the HTTP Authentication scheme to be used in the + // Authorization header as defined in RFC7235. The values used SHOULD be + // registered in the IANA Authentication Scheme registry. + // The value is case-insensitive, as defined in RFC7235. + string scheme = 2; + // A hint to the client to identify how the bearer token is formatted. + // Bearer tokens are usually generated by an authorization server, so + // this information is primarily for documentation purposes. + string bearer_format = 3; +} + +message OAuth2SecurityScheme { + // Description of this security scheme. + string description = 1; + // An object containing configuration information for the flow types supported + OAuthFlows flows = 2; + // URL to the oauth2 authorization server metadata + // [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414). TLS is required. + string oauth2_metadata_url = 3; +} + +message OpenIdConnectSecurityScheme { + // Description of this security scheme. + string description = 1; + // Well-known URL to discover the [[OpenID-Connect-Discovery]] provider + // metadata. + string open_id_connect_url = 2; +} + +message MutualTlsSecurityScheme { + // Description of this security scheme. + string description = 1; +} + +message OAuthFlows { + oneof flow { + AuthorizationCodeOAuthFlow authorization_code = 1; + ClientCredentialsOAuthFlow client_credentials = 2; + ImplicitOAuthFlow implicit = 3; + PasswordOAuthFlow password = 4; + } +} + +message AuthorizationCodeOAuthFlow { + // The authorization URL to be used for this flow. This MUST be in the + // form of a URL. The OAuth2 standard requires the use of TLS + string authorization_url = 1; + // The token URL to be used for this flow. This MUST be in the form of a URL. + // The OAuth2 standard requires the use of TLS. + string token_url = 2; + // The URL to be used for obtaining refresh tokens. This MUST be in the + // form of a URL. The OAuth2 standard requires the use of TLS. + string refresh_url = 3; + // The available scopes for the OAuth2 security scheme. A map between the + // scope name and a short description for it. The map MAY be empty. + map scopes = 4; +} + +message ClientCredentialsOAuthFlow { + // The token URL to be used for this flow. This MUST be in the form of a URL. + // The OAuth2 standard requires the use of TLS. + string token_url = 1; + // The URL to be used for obtaining refresh tokens. This MUST be in the + // form of a URL. The OAuth2 standard requires the use of TLS. + string refresh_url = 2; + // The available scopes for the OAuth2 security scheme. A map between the + // scope name and a short description for it. The map MAY be empty. + map scopes = 3; +} + +message ImplicitOAuthFlow { + // The authorization URL to be used for this flow. This MUST be in the + // form of a URL. The OAuth2 standard requires the use of TLS + string authorization_url = 1; + // The URL to be used for obtaining refresh tokens. This MUST be in the + // form of a URL. The OAuth2 standard requires the use of TLS. + string refresh_url = 2; + // The available scopes for the OAuth2 security scheme. A map between the + // scope name and a short description for it. The map MAY be empty. + map scopes = 3; +} + +message PasswordOAuthFlow { + // The token URL to be used for this flow. This MUST be in the form of a URL. + // The OAuth2 standard requires the use of TLS. + string token_url = 1; + // The URL to be used for obtaining refresh tokens. This MUST be in the + // form of a URL. The OAuth2 standard requires the use of TLS. + string refresh_url = 2; + // The available scopes for the OAuth2 security scheme. A map between the + // scope name and a short description for it. The map MAY be empty. + map scopes = 3; +} + +///////////// Request Messages /////////// +message SendMessageRequest { + // The message to send to the agent. + Message request = 1 + [(google.api.field_behavior) = REQUIRED, json_name = "message"]; + // Configuration for the send request. + SendMessageConfiguration configuration = 2; + // Optional metadata for the request. + google.protobuf.Struct metadata = 3; +} + +message GetTaskRequest { + // The resource name of the task. + // Format: tasks/{task_id} + string name = 1 [(google.api.field_behavior) = REQUIRED]; + // The number of most recent messages from the task's history to retrieve. + int32 history_length = 2; +} + +message CancelTaskRequest { + // The resource name of the task to cancel. + // Format: tasks/{task_id} + string name = 1; +} + +message GetTaskPushNotificationConfigRequest { + // The resource name of the config to retrieve. + // Format: tasks/{task_id}/pushNotificationConfigs/{config_id} + string name = 1; +} + +message DeleteTaskPushNotificationConfigRequest { + // The resource name of the config to delete. + // Format: tasks/{task_id}/pushNotificationConfigs/{config_id} + string name = 1; +} + +message CreateTaskPushNotificationConfigRequest { + // The parent task resource for this config. + // Format: tasks/{task_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED + ]; + // The ID for the new config. + string config_id = 2 [(google.api.field_behavior) = REQUIRED]; + // The configuration to create. + TaskPushNotificationConfig config = 3 + [(google.api.field_behavior) = REQUIRED]; +} + +message TaskSubscriptionRequest { + // The resource name of the task to subscribe to. + // Format: tasks/{task_id} + string name = 1; +} + +message ListTaskPushNotificationConfigRequest { + // The parent task resource. + // Format: tasks/{task_id} + string parent = 1; + // For AIP-158 these fields are present. Usually not used/needed. + // The maximum number of configurations to return. + // If unspecified, all configs will be returned. + int32 page_size = 2; + + // A page token received from a previous + // ListTaskPushNotificationConfigRequest call. + // Provide this to retrieve the subsequent page. + // When paginating, all other parameters provided to + // `ListTaskPushNotificationConfigRequest` must match the call that provided + // the page token. + string page_token = 3; +} + +message GetAgentCardRequest { + // Empty. Added to fix linter violation. +} + +//////// Response Messages /////////// +message SendMessageResponse { + oneof payload { + Task task = 1; + Message msg = 2 [json_name = "message"]; + } +} + +// The stream response for a message. The stream should be one of the following +// sequences: +// If the response is a message, the stream should contain one, and only one, +// message and then close +// If the response is a task lifecycle, the first response should be a Task +// object followed by zero or more TaskStatusUpdateEvents and +// TaskArtifactUpdateEvents. The stream should complete when the Task +// if in an interrupted or terminal state. A stream that ends before these +// conditions are met are +message StreamResponse { + oneof payload { + Task task = 1; + Message msg = 2 [json_name = "message"]; + TaskStatusUpdateEvent status_update = 3; + TaskArtifactUpdateEvent artifact_update = 4; + } +} + +message ListTaskPushNotificationConfigResponse { + // The list of push notification configurations. + repeated TaskPushNotificationConfig configs = 1; + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} diff --git a/src/a2a/compat/v0_3/a2a_v0_3_pb2.py b/src/a2a/compat/v0_3/a2a_v0_3_pb2.py new file mode 100644 index 000000000..e310e530b --- /dev/null +++ b/src/a2a/compat/v0_3/a2a_v0_3_pb2.py @@ -0,0 +1,195 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: a2a_v0_3.proto +# Protobuf Python Version: 5.29.3 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 29, + 3, + '', + 'a2a_v0_3.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0e\x61\x32\x61_v0_3.proto\x12\x06\x61\x32\x61.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xde\x01\n\x18SendMessageConfiguration\x12\x32\n\x15\x61\x63\x63\x65pted_output_modes\x18\x01 \x03(\tR\x13\x61\x63\x63\x65ptedOutputModes\x12K\n\x11push_notification\x18\x02 \x01(\x0b\x32\x1e.a2a.v1.PushNotificationConfigR\x10pushNotification\x12%\n\x0ehistory_length\x18\x03 \x01(\x05R\rhistoryLength\x12\x1a\n\x08\x62locking\x18\x04 \x01(\x08R\x08\x62locking\"\xf1\x01\n\x04Task\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x1d\n\ncontext_id\x18\x02 \x01(\tR\tcontextId\x12*\n\x06status\x18\x03 \x01(\x0b\x32\x12.a2a.v1.TaskStatusR\x06status\x12.\n\tartifacts\x18\x04 \x03(\x0b\x32\x10.a2a.v1.ArtifactR\tartifacts\x12)\n\x07history\x18\x05 \x03(\x0b\x32\x0f.a2a.v1.MessageR\x07history\x12\x33\n\x08metadata\x18\x06 \x01(\x0b\x32\x17.google.protobuf.StructR\x08metadata\"\x99\x01\n\nTaskStatus\x12\'\n\x05state\x18\x01 \x01(\x0e\x32\x11.a2a.v1.TaskStateR\x05state\x12(\n\x06update\x18\x02 \x01(\x0b\x32\x0f.a2a.v1.MessageR\x07message\x12\x38\n\ttimestamp\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.TimestampR\ttimestamp\"\xa9\x01\n\x04Part\x12\x14\n\x04text\x18\x01 \x01(\tH\x00R\x04text\x12&\n\x04\x66ile\x18\x02 \x01(\x0b\x32\x10.a2a.v1.FilePartH\x00R\x04\x66ile\x12&\n\x04\x64\x61ta\x18\x03 \x01(\x0b\x32\x10.a2a.v1.DataPartH\x00R\x04\x64\x61ta\x12\x33\n\x08metadata\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructR\x08metadataB\x06\n\x04part\"\x93\x01\n\x08\x46ilePart\x12$\n\rfile_with_uri\x18\x01 \x01(\tH\x00R\x0b\x66ileWithUri\x12(\n\x0f\x66ile_with_bytes\x18\x02 \x01(\x0cH\x00R\rfileWithBytes\x12\x1b\n\tmime_type\x18\x03 \x01(\tR\x08mimeType\x12\x12\n\x04name\x18\x04 \x01(\tR\x04nameB\x06\n\x04\x66ile\"7\n\x08\x44\x61taPart\x12+\n\x04\x64\x61ta\x18\x01 \x01(\x0b\x32\x17.google.protobuf.StructR\x04\x64\x61ta\"\xff\x01\n\x07Message\x12\x1d\n\nmessage_id\x18\x01 \x01(\tR\tmessageId\x12\x1d\n\ncontext_id\x18\x02 \x01(\tR\tcontextId\x12\x17\n\x07task_id\x18\x03 \x01(\tR\x06taskId\x12 \n\x04role\x18\x04 \x01(\x0e\x32\x0c.a2a.v1.RoleR\x04role\x12&\n\x07\x63ontent\x18\x05 \x03(\x0b\x32\x0c.a2a.v1.PartR\x07\x63ontent\x12\x33\n\x08metadata\x18\x06 \x01(\x0b\x32\x17.google.protobuf.StructR\x08metadata\x12\x1e\n\nextensions\x18\x07 \x03(\tR\nextensions\"\xda\x01\n\x08\x41rtifact\x12\x1f\n\x0b\x61rtifact_id\x18\x01 \x01(\tR\nartifactId\x12\x12\n\x04name\x18\x03 \x01(\tR\x04name\x12 \n\x0b\x64\x65scription\x18\x04 \x01(\tR\x0b\x64\x65scription\x12\"\n\x05parts\x18\x05 \x03(\x0b\x32\x0c.a2a.v1.PartR\x05parts\x12\x33\n\x08metadata\x18\x06 \x01(\x0b\x32\x17.google.protobuf.StructR\x08metadata\x12\x1e\n\nextensions\x18\x07 \x03(\tR\nextensions\"\xc6\x01\n\x15TaskStatusUpdateEvent\x12\x17\n\x07task_id\x18\x01 \x01(\tR\x06taskId\x12\x1d\n\ncontext_id\x18\x02 \x01(\tR\tcontextId\x12*\n\x06status\x18\x03 \x01(\x0b\x32\x12.a2a.v1.TaskStatusR\x06status\x12\x14\n\x05\x66inal\x18\x04 \x01(\x08R\x05\x66inal\x12\x33\n\x08metadata\x18\x05 \x01(\x0b\x32\x17.google.protobuf.StructR\x08metadata\"\xeb\x01\n\x17TaskArtifactUpdateEvent\x12\x17\n\x07task_id\x18\x01 \x01(\tR\x06taskId\x12\x1d\n\ncontext_id\x18\x02 \x01(\tR\tcontextId\x12,\n\x08\x61rtifact\x18\x03 \x01(\x0b\x32\x10.a2a.v1.ArtifactR\x08\x61rtifact\x12\x16\n\x06\x61ppend\x18\x04 \x01(\x08R\x06\x61ppend\x12\x1d\n\nlast_chunk\x18\x05 \x01(\x08R\tlastChunk\x12\x33\n\x08metadata\x18\x06 \x01(\x0b\x32\x17.google.protobuf.StructR\x08metadata\"\x94\x01\n\x16PushNotificationConfig\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x10\n\x03url\x18\x02 \x01(\tR\x03url\x12\x14\n\x05token\x18\x03 \x01(\tR\x05token\x12\x42\n\x0e\x61uthentication\x18\x04 \x01(\x0b\x32\x1a.a2a.v1.AuthenticationInfoR\x0e\x61uthentication\"P\n\x12\x41uthenticationInfo\x12\x18\n\x07schemes\x18\x01 \x03(\tR\x07schemes\x12 \n\x0b\x63redentials\x18\x02 \x01(\tR\x0b\x63redentials\"@\n\x0e\x41gentInterface\x12\x10\n\x03url\x18\x01 \x01(\tR\x03url\x12\x1c\n\ttransport\x18\x02 \x01(\tR\ttransport\"\xc8\x07\n\tAgentCard\x12)\n\x10protocol_version\x18\x10 \x01(\tR\x0fprotocolVersion\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12 \n\x0b\x64\x65scription\x18\x02 \x01(\tR\x0b\x64\x65scription\x12\x10\n\x03url\x18\x03 \x01(\tR\x03url\x12/\n\x13preferred_transport\x18\x0e \x01(\tR\x12preferredTransport\x12K\n\x15\x61\x64\x64itional_interfaces\x18\x0f \x03(\x0b\x32\x16.a2a.v1.AgentInterfaceR\x14\x61\x64\x64itionalInterfaces\x12\x31\n\x08provider\x18\x04 \x01(\x0b\x32\x15.a2a.v1.AgentProviderR\x08provider\x12\x18\n\x07version\x18\x05 \x01(\tR\x07version\x12+\n\x11\x64ocumentation_url\x18\x06 \x01(\tR\x10\x64ocumentationUrl\x12=\n\x0c\x63\x61pabilities\x18\x07 \x01(\x0b\x32\x19.a2a.v1.AgentCapabilitiesR\x0c\x63\x61pabilities\x12Q\n\x10security_schemes\x18\x08 \x03(\x0b\x32&.a2a.v1.AgentCard.SecuritySchemesEntryR\x0fsecuritySchemes\x12,\n\x08security\x18\t \x03(\x0b\x32\x10.a2a.v1.SecurityR\x08security\x12.\n\x13\x64\x65\x66\x61ult_input_modes\x18\n \x03(\tR\x11\x64\x65\x66\x61ultInputModes\x12\x30\n\x14\x64\x65\x66\x61ult_output_modes\x18\x0b \x03(\tR\x12\x64\x65\x66\x61ultOutputModes\x12*\n\x06skills\x18\x0c \x03(\x0b\x32\x12.a2a.v1.AgentSkillR\x06skills\x12O\n$supports_authenticated_extended_card\x18\r \x01(\x08R!supportsAuthenticatedExtendedCard\x12:\n\nsignatures\x18\x11 \x03(\x0b\x32\x1a.a2a.v1.AgentCardSignatureR\nsignatures\x12\x19\n\x08icon_url\x18\x12 \x01(\tR\x07iconUrl\x1aZ\n\x14SecuritySchemesEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12,\n\x05value\x18\x02 \x01(\x0b\x32\x16.a2a.v1.SecuritySchemeR\x05value:\x02\x38\x01\"E\n\rAgentProvider\x12\x10\n\x03url\x18\x01 \x01(\tR\x03url\x12\"\n\x0corganization\x18\x02 \x01(\tR\x0corganization\"\x98\x01\n\x11\x41gentCapabilities\x12\x1c\n\tstreaming\x18\x01 \x01(\x08R\tstreaming\x12-\n\x12push_notifications\x18\x02 \x01(\x08R\x11pushNotifications\x12\x36\n\nextensions\x18\x03 \x03(\x0b\x32\x16.a2a.v1.AgentExtensionR\nextensions\"\x91\x01\n\x0e\x41gentExtension\x12\x10\n\x03uri\x18\x01 \x01(\tR\x03uri\x12 \n\x0b\x64\x65scription\x18\x02 \x01(\tR\x0b\x64\x65scription\x12\x1a\n\x08required\x18\x03 \x01(\x08R\x08required\x12/\n\x06params\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructR\x06params\"\xf4\x01\n\nAgentSkill\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n\x04name\x18\x02 \x01(\tR\x04name\x12 \n\x0b\x64\x65scription\x18\x03 \x01(\tR\x0b\x64\x65scription\x12\x12\n\x04tags\x18\x04 \x03(\tR\x04tags\x12\x1a\n\x08\x65xamples\x18\x05 \x03(\tR\x08\x65xamples\x12\x1f\n\x0binput_modes\x18\x06 \x03(\tR\ninputModes\x12!\n\x0coutput_modes\x18\x07 \x03(\tR\x0boutputModes\x12,\n\x08security\x18\x08 \x03(\x0b\x32\x10.a2a.v1.SecurityR\x08security\"\x8b\x01\n\x12\x41gentCardSignature\x12!\n\tprotected\x18\x01 \x01(\tB\x03\xe0\x41\x02R\tprotected\x12!\n\tsignature\x18\x02 \x01(\tB\x03\xe0\x41\x02R\tsignature\x12/\n\x06header\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructR\x06header\"\x8a\x01\n\x1aTaskPushNotificationConfig\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12X\n\x18push_notification_config\x18\x02 \x01(\x0b\x32\x1e.a2a.v1.PushNotificationConfigR\x16pushNotificationConfig\" \n\nStringList\x12\x12\n\x04list\x18\x01 \x03(\tR\x04list\"\x93\x01\n\x08Security\x12\x37\n\x07schemes\x18\x01 \x03(\x0b\x32\x1d.a2a.v1.Security.SchemesEntryR\x07schemes\x1aN\n\x0cSchemesEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12(\n\x05value\x18\x02 \x01(\x0b\x32\x12.a2a.v1.StringListR\x05value:\x02\x38\x01\"\xe6\x03\n\x0eSecurityScheme\x12U\n\x17\x61pi_key_security_scheme\x18\x01 \x01(\x0b\x32\x1c.a2a.v1.APIKeySecuritySchemeH\x00R\x14\x61piKeySecurityScheme\x12[\n\x19http_auth_security_scheme\x18\x02 \x01(\x0b\x32\x1e.a2a.v1.HTTPAuthSecuritySchemeH\x00R\x16httpAuthSecurityScheme\x12T\n\x16oauth2_security_scheme\x18\x03 \x01(\x0b\x32\x1c.a2a.v1.OAuth2SecuritySchemeH\x00R\x14oauth2SecurityScheme\x12k\n\x1fopen_id_connect_security_scheme\x18\x04 \x01(\x0b\x32#.a2a.v1.OpenIdConnectSecuritySchemeH\x00R\x1bopenIdConnectSecurityScheme\x12S\n\x14mtls_security_scheme\x18\x05 \x01(\x0b\x32\x1f.a2a.v1.MutualTlsSecuritySchemeH\x00R\x12mtlsSecuritySchemeB\x08\n\x06scheme\"h\n\x14\x41PIKeySecurityScheme\x12 \n\x0b\x64\x65scription\x18\x01 \x01(\tR\x0b\x64\x65scription\x12\x1a\n\x08location\x18\x02 \x01(\tR\x08location\x12\x12\n\x04name\x18\x03 \x01(\tR\x04name\"w\n\x16HTTPAuthSecurityScheme\x12 \n\x0b\x64\x65scription\x18\x01 \x01(\tR\x0b\x64\x65scription\x12\x16\n\x06scheme\x18\x02 \x01(\tR\x06scheme\x12#\n\rbearer_format\x18\x03 \x01(\tR\x0c\x62\x65\x61rerFormat\"\x92\x01\n\x14OAuth2SecurityScheme\x12 \n\x0b\x64\x65scription\x18\x01 \x01(\tR\x0b\x64\x65scription\x12(\n\x05\x66lows\x18\x02 \x01(\x0b\x32\x12.a2a.v1.OAuthFlowsR\x05\x66lows\x12.\n\x13oauth2_metadata_url\x18\x03 \x01(\tR\x11oauth2MetadataUrl\"n\n\x1bOpenIdConnectSecurityScheme\x12 \n\x0b\x64\x65scription\x18\x01 \x01(\tR\x0b\x64\x65scription\x12-\n\x13open_id_connect_url\x18\x02 \x01(\tR\x10openIdConnectUrl\";\n\x17MutualTlsSecurityScheme\x12 \n\x0b\x64\x65scription\x18\x01 \x01(\tR\x0b\x64\x65scription\"\xb0\x02\n\nOAuthFlows\x12S\n\x12\x61uthorization_code\x18\x01 \x01(\x0b\x32\".a2a.v1.AuthorizationCodeOAuthFlowH\x00R\x11\x61uthorizationCode\x12S\n\x12\x63lient_credentials\x18\x02 \x01(\x0b\x32\".a2a.v1.ClientCredentialsOAuthFlowH\x00R\x11\x63lientCredentials\x12\x37\n\x08implicit\x18\x03 \x01(\x0b\x32\x19.a2a.v1.ImplicitOAuthFlowH\x00R\x08implicit\x12\x37\n\x08password\x18\x04 \x01(\x0b\x32\x19.a2a.v1.PasswordOAuthFlowH\x00R\x08passwordB\x06\n\x04\x66low\"\x8a\x02\n\x1a\x41uthorizationCodeOAuthFlow\x12+\n\x11\x61uthorization_url\x18\x01 \x01(\tR\x10\x61uthorizationUrl\x12\x1b\n\ttoken_url\x18\x02 \x01(\tR\x08tokenUrl\x12\x1f\n\x0brefresh_url\x18\x03 \x01(\tR\nrefreshUrl\x12\x46\n\x06scopes\x18\x04 \x03(\x0b\x32..a2a.v1.AuthorizationCodeOAuthFlow.ScopesEntryR\x06scopes\x1a\x39\n\x0bScopesEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01\"\xdd\x01\n\x1a\x43lientCredentialsOAuthFlow\x12\x1b\n\ttoken_url\x18\x01 \x01(\tR\x08tokenUrl\x12\x1f\n\x0brefresh_url\x18\x02 \x01(\tR\nrefreshUrl\x12\x46\n\x06scopes\x18\x03 \x03(\x0b\x32..a2a.v1.ClientCredentialsOAuthFlow.ScopesEntryR\x06scopes\x1a\x39\n\x0bScopesEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01\"\xdb\x01\n\x11ImplicitOAuthFlow\x12+\n\x11\x61uthorization_url\x18\x01 \x01(\tR\x10\x61uthorizationUrl\x12\x1f\n\x0brefresh_url\x18\x02 \x01(\tR\nrefreshUrl\x12=\n\x06scopes\x18\x03 \x03(\x0b\x32%.a2a.v1.ImplicitOAuthFlow.ScopesEntryR\x06scopes\x1a\x39\n\x0bScopesEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01\"\xcb\x01\n\x11PasswordOAuthFlow\x12\x1b\n\ttoken_url\x18\x01 \x01(\tR\x08tokenUrl\x12\x1f\n\x0brefresh_url\x18\x02 \x01(\tR\nrefreshUrl\x12=\n\x06scopes\x18\x03 \x03(\x0b\x32%.a2a.v1.PasswordOAuthFlow.ScopesEntryR\x06scopes\x1a\x39\n\x0bScopesEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01\"\xc1\x01\n\x12SendMessageRequest\x12.\n\x07request\x18\x01 \x01(\x0b\x32\x0f.a2a.v1.MessageB\x03\xe0\x41\x02R\x07message\x12\x46\n\rconfiguration\x18\x02 \x01(\x0b\x32 .a2a.v1.SendMessageConfigurationR\rconfiguration\x12\x33\n\x08metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructR\x08metadata\"P\n\x0eGetTaskRequest\x12\x17\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x04name\x12%\n\x0ehistory_length\x18\x02 \x01(\x05R\rhistoryLength\"\'\n\x11\x43\x61ncelTaskRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\":\n$GetTaskPushNotificationConfigRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\"=\n\'DeleteTaskPushNotificationConfigRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\"\xa9\x01\n\'CreateTaskPushNotificationConfigRequest\x12\x1b\n\x06parent\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x06parent\x12 \n\tconfig_id\x18\x02 \x01(\tB\x03\xe0\x41\x02R\x08\x63onfigId\x12?\n\x06\x63onfig\x18\x03 \x01(\x0b\x32\".a2a.v1.TaskPushNotificationConfigB\x03\xe0\x41\x02R\x06\x63onfig\"-\n\x17TaskSubscriptionRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\"{\n%ListTaskPushNotificationConfigRequest\x12\x16\n\x06parent\x18\x01 \x01(\tR\x06parent\x12\x1b\n\tpage_size\x18\x02 \x01(\x05R\x08pageSize\x12\x1d\n\npage_token\x18\x03 \x01(\tR\tpageToken\"\x15\n\x13GetAgentCardRequest\"m\n\x13SendMessageResponse\x12\"\n\x04task\x18\x01 \x01(\x0b\x32\x0c.a2a.v1.TaskH\x00R\x04task\x12\'\n\x03msg\x18\x02 \x01(\x0b\x32\x0f.a2a.v1.MessageH\x00R\x07messageB\t\n\x07payload\"\xfa\x01\n\x0eStreamResponse\x12\"\n\x04task\x18\x01 \x01(\x0b\x32\x0c.a2a.v1.TaskH\x00R\x04task\x12\'\n\x03msg\x18\x02 \x01(\x0b\x32\x0f.a2a.v1.MessageH\x00R\x07message\x12\x44\n\rstatus_update\x18\x03 \x01(\x0b\x32\x1d.a2a.v1.TaskStatusUpdateEventH\x00R\x0cstatusUpdate\x12J\n\x0f\x61rtifact_update\x18\x04 \x01(\x0b\x32\x1f.a2a.v1.TaskArtifactUpdateEventH\x00R\x0e\x61rtifactUpdateB\t\n\x07payload\"\x8e\x01\n&ListTaskPushNotificationConfigResponse\x12<\n\x07\x63onfigs\x18\x01 \x03(\x0b\x32\".a2a.v1.TaskPushNotificationConfigR\x07\x63onfigs\x12&\n\x0fnext_page_token\x18\x02 \x01(\tR\rnextPageToken*\xfa\x01\n\tTaskState\x12\x1a\n\x16TASK_STATE_UNSPECIFIED\x10\x00\x12\x18\n\x14TASK_STATE_SUBMITTED\x10\x01\x12\x16\n\x12TASK_STATE_WORKING\x10\x02\x12\x18\n\x14TASK_STATE_COMPLETED\x10\x03\x12\x15\n\x11TASK_STATE_FAILED\x10\x04\x12\x18\n\x14TASK_STATE_CANCELLED\x10\x05\x12\x1d\n\x19TASK_STATE_INPUT_REQUIRED\x10\x06\x12\x17\n\x13TASK_STATE_REJECTED\x10\x07\x12\x1c\n\x18TASK_STATE_AUTH_REQUIRED\x10\x08*;\n\x04Role\x12\x14\n\x10ROLE_UNSPECIFIED\x10\x00\x12\r\n\tROLE_USER\x10\x01\x12\x0e\n\nROLE_AGENT\x10\x02\x32\xbb\n\n\nA2AService\x12\x63\n\x0bSendMessage\x12\x1a.a2a.v1.SendMessageRequest\x1a\x1b.a2a.v1.SendMessageResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\"\x10/v1/message:send:\x01*\x12k\n\x14SendStreamingMessage\x12\x1a.a2a.v1.SendMessageRequest\x1a\x16.a2a.v1.StreamResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\"\x12/v1/message:stream:\x01*0\x01\x12R\n\x07GetTask\x12\x16.a2a.v1.GetTaskRequest\x1a\x0c.a2a.v1.Task\"!\xda\x41\x04name\x82\xd3\xe4\x93\x02\x14\x12\x12/v1/{name=tasks/*}\x12[\n\nCancelTask\x12\x19.a2a.v1.CancelTaskRequest\x1a\x0c.a2a.v1.Task\"$\x82\xd3\xe4\x93\x02\x1e\"\x19/v1/{name=tasks/*}:cancel:\x01*\x12s\n\x10TaskSubscription\x12\x1f.a2a.v1.TaskSubscriptionRequest\x1a\x16.a2a.v1.StreamResponse\"$\x82\xd3\xe4\x93\x02\x1e\x12\x1c/v1/{name=tasks/*}:subscribe0\x01\x12\xc5\x01\n CreateTaskPushNotificationConfig\x12/.a2a.v1.CreateTaskPushNotificationConfigRequest\x1a\".a2a.v1.TaskPushNotificationConfig\"L\xda\x41\rparent,config\x82\xd3\xe4\x93\x02\x36\",/v1/{parent=tasks/*/pushNotificationConfigs}:\x06\x63onfig\x12\xae\x01\n\x1dGetTaskPushNotificationConfig\x12,.a2a.v1.GetTaskPushNotificationConfigRequest\x1a\".a2a.v1.TaskPushNotificationConfig\";\xda\x41\x04name\x82\xd3\xe4\x93\x02.\x12,/v1/{name=tasks/*/pushNotificationConfigs/*}\x12\xbe\x01\n\x1eListTaskPushNotificationConfig\x12-.a2a.v1.ListTaskPushNotificationConfigRequest\x1a..a2a.v1.ListTaskPushNotificationConfigResponse\"=\xda\x41\x06parent\x82\xd3\xe4\x93\x02.\x12,/v1/{parent=tasks/*}/pushNotificationConfigs\x12P\n\x0cGetAgentCard\x12\x1b.a2a.v1.GetAgentCardRequest\x1a\x11.a2a.v1.AgentCard\"\x10\x82\xd3\xe4\x93\x02\n\x12\x08/v1/card\x12\xa8\x01\n DeleteTaskPushNotificationConfig\x12/.a2a.v1.DeleteTaskPushNotificationConfigRequest\x1a\x16.google.protobuf.Empty\";\xda\x41\x04name\x82\xd3\xe4\x93\x02.*,/v1/{name=tasks/*/pushNotificationConfigs/*}Bl\n\ncom.a2a.v1B\x0b\x41\x32\x61V03ProtoP\x01Z\x18google.golang.org/a2a/v1\xa2\x02\x03\x41XX\xaa\x02\x06\x41\x32\x61.V1\xca\x02\x06\x41\x32\x61\\V1\xe2\x02\x12\x41\x32\x61\\V1\\GPBMetadata\xea\x02\x07\x41\x32\x61::V1b\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'a2a_v0_3_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\ncom.a2a.v1B\013A2aV03ProtoP\001Z\030google.golang.org/a2a/v1\242\002\003AXX\252\002\006A2a.V1\312\002\006A2a\\V1\342\002\022A2a\\V1\\GPBMetadata\352\002\007A2a::V1' + _globals['_AGENTCARD_SECURITYSCHEMESENTRY']._loaded_options = None + _globals['_AGENTCARD_SECURITYSCHEMESENTRY']._serialized_options = b'8\001' + _globals['_AGENTCARDSIGNATURE'].fields_by_name['protected']._loaded_options = None + _globals['_AGENTCARDSIGNATURE'].fields_by_name['protected']._serialized_options = b'\340A\002' + _globals['_AGENTCARDSIGNATURE'].fields_by_name['signature']._loaded_options = None + _globals['_AGENTCARDSIGNATURE'].fields_by_name['signature']._serialized_options = b'\340A\002' + _globals['_SECURITY_SCHEMESENTRY']._loaded_options = None + _globals['_SECURITY_SCHEMESENTRY']._serialized_options = b'8\001' + _globals['_AUTHORIZATIONCODEOAUTHFLOW_SCOPESENTRY']._loaded_options = None + _globals['_AUTHORIZATIONCODEOAUTHFLOW_SCOPESENTRY']._serialized_options = b'8\001' + _globals['_CLIENTCREDENTIALSOAUTHFLOW_SCOPESENTRY']._loaded_options = None + _globals['_CLIENTCREDENTIALSOAUTHFLOW_SCOPESENTRY']._serialized_options = b'8\001' + _globals['_IMPLICITOAUTHFLOW_SCOPESENTRY']._loaded_options = None + _globals['_IMPLICITOAUTHFLOW_SCOPESENTRY']._serialized_options = b'8\001' + _globals['_PASSWORDOAUTHFLOW_SCOPESENTRY']._loaded_options = None + _globals['_PASSWORDOAUTHFLOW_SCOPESENTRY']._serialized_options = b'8\001' + _globals['_SENDMESSAGEREQUEST'].fields_by_name['request']._loaded_options = None + _globals['_SENDMESSAGEREQUEST'].fields_by_name['request']._serialized_options = b'\340A\002' + _globals['_GETTASKREQUEST'].fields_by_name['name']._loaded_options = None + _globals['_GETTASKREQUEST'].fields_by_name['name']._serialized_options = b'\340A\002' + _globals['_CREATETASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['parent']._loaded_options = None + _globals['_CREATETASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['parent']._serialized_options = b'\340A\002' + _globals['_CREATETASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['config_id']._loaded_options = None + _globals['_CREATETASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['config_id']._serialized_options = b'\340A\002' + _globals['_CREATETASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['config']._loaded_options = None + _globals['_CREATETASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['config']._serialized_options = b'\340A\002' + _globals['_A2ASERVICE'].methods_by_name['SendMessage']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['SendMessage']._serialized_options = b'\202\323\344\223\002\025\"\020/v1/message:send:\001*' + _globals['_A2ASERVICE'].methods_by_name['SendStreamingMessage']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['SendStreamingMessage']._serialized_options = b'\202\323\344\223\002\027\"\022/v1/message:stream:\001*' + _globals['_A2ASERVICE'].methods_by_name['GetTask']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['GetTask']._serialized_options = b'\332A\004name\202\323\344\223\002\024\022\022/v1/{name=tasks/*}' + _globals['_A2ASERVICE'].methods_by_name['CancelTask']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['CancelTask']._serialized_options = b'\202\323\344\223\002\036\"\031/v1/{name=tasks/*}:cancel:\001*' + _globals['_A2ASERVICE'].methods_by_name['TaskSubscription']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['TaskSubscription']._serialized_options = b'\202\323\344\223\002\036\022\034/v1/{name=tasks/*}:subscribe' + _globals['_A2ASERVICE'].methods_by_name['CreateTaskPushNotificationConfig']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['CreateTaskPushNotificationConfig']._serialized_options = b'\332A\rparent,config\202\323\344\223\0026\",/v1/{parent=tasks/*/pushNotificationConfigs}:\006config' + _globals['_A2ASERVICE'].methods_by_name['GetTaskPushNotificationConfig']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['GetTaskPushNotificationConfig']._serialized_options = b'\332A\004name\202\323\344\223\002.\022,/v1/{name=tasks/*/pushNotificationConfigs/*}' + _globals['_A2ASERVICE'].methods_by_name['ListTaskPushNotificationConfig']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['ListTaskPushNotificationConfig']._serialized_options = b'\332A\006parent\202\323\344\223\002.\022,/v1/{parent=tasks/*}/pushNotificationConfigs' + _globals['_A2ASERVICE'].methods_by_name['GetAgentCard']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['GetAgentCard']._serialized_options = b'\202\323\344\223\002\n\022\010/v1/card' + _globals['_A2ASERVICE'].methods_by_name['DeleteTaskPushNotificationConfig']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['DeleteTaskPushNotificationConfig']._serialized_options = b'\332A\004name\202\323\344\223\002.*,/v1/{name=tasks/*/pushNotificationConfigs/*}' + _globals['_TASKSTATE']._serialized_start=8071 + _globals['_TASKSTATE']._serialized_end=8321 + _globals['_ROLE']._serialized_start=8323 + _globals['_ROLE']._serialized_end=8382 + _globals['_SENDMESSAGECONFIGURATION']._serialized_start=207 + _globals['_SENDMESSAGECONFIGURATION']._serialized_end=429 + _globals['_TASK']._serialized_start=432 + _globals['_TASK']._serialized_end=673 + _globals['_TASKSTATUS']._serialized_start=676 + _globals['_TASKSTATUS']._serialized_end=829 + _globals['_PART']._serialized_start=832 + _globals['_PART']._serialized_end=1001 + _globals['_FILEPART']._serialized_start=1004 + _globals['_FILEPART']._serialized_end=1151 + _globals['_DATAPART']._serialized_start=1153 + _globals['_DATAPART']._serialized_end=1208 + _globals['_MESSAGE']._serialized_start=1211 + _globals['_MESSAGE']._serialized_end=1466 + _globals['_ARTIFACT']._serialized_start=1469 + _globals['_ARTIFACT']._serialized_end=1687 + _globals['_TASKSTATUSUPDATEEVENT']._serialized_start=1690 + _globals['_TASKSTATUSUPDATEEVENT']._serialized_end=1888 + _globals['_TASKARTIFACTUPDATEEVENT']._serialized_start=1891 + _globals['_TASKARTIFACTUPDATEEVENT']._serialized_end=2126 + _globals['_PUSHNOTIFICATIONCONFIG']._serialized_start=2129 + _globals['_PUSHNOTIFICATIONCONFIG']._serialized_end=2277 + _globals['_AUTHENTICATIONINFO']._serialized_start=2279 + _globals['_AUTHENTICATIONINFO']._serialized_end=2359 + _globals['_AGENTINTERFACE']._serialized_start=2361 + _globals['_AGENTINTERFACE']._serialized_end=2425 + _globals['_AGENTCARD']._serialized_start=2428 + _globals['_AGENTCARD']._serialized_end=3396 + _globals['_AGENTCARD_SECURITYSCHEMESENTRY']._serialized_start=3306 + _globals['_AGENTCARD_SECURITYSCHEMESENTRY']._serialized_end=3396 + _globals['_AGENTPROVIDER']._serialized_start=3398 + _globals['_AGENTPROVIDER']._serialized_end=3467 + _globals['_AGENTCAPABILITIES']._serialized_start=3470 + _globals['_AGENTCAPABILITIES']._serialized_end=3622 + _globals['_AGENTEXTENSION']._serialized_start=3625 + _globals['_AGENTEXTENSION']._serialized_end=3770 + _globals['_AGENTSKILL']._serialized_start=3773 + _globals['_AGENTSKILL']._serialized_end=4017 + _globals['_AGENTCARDSIGNATURE']._serialized_start=4020 + _globals['_AGENTCARDSIGNATURE']._serialized_end=4159 + _globals['_TASKPUSHNOTIFICATIONCONFIG']._serialized_start=4162 + _globals['_TASKPUSHNOTIFICATIONCONFIG']._serialized_end=4300 + _globals['_STRINGLIST']._serialized_start=4302 + _globals['_STRINGLIST']._serialized_end=4334 + _globals['_SECURITY']._serialized_start=4337 + _globals['_SECURITY']._serialized_end=4484 + _globals['_SECURITY_SCHEMESENTRY']._serialized_start=4406 + _globals['_SECURITY_SCHEMESENTRY']._serialized_end=4484 + _globals['_SECURITYSCHEME']._serialized_start=4487 + _globals['_SECURITYSCHEME']._serialized_end=4973 + _globals['_APIKEYSECURITYSCHEME']._serialized_start=4975 + _globals['_APIKEYSECURITYSCHEME']._serialized_end=5079 + _globals['_HTTPAUTHSECURITYSCHEME']._serialized_start=5081 + _globals['_HTTPAUTHSECURITYSCHEME']._serialized_end=5200 + _globals['_OAUTH2SECURITYSCHEME']._serialized_start=5203 + _globals['_OAUTH2SECURITYSCHEME']._serialized_end=5349 + _globals['_OPENIDCONNECTSECURITYSCHEME']._serialized_start=5351 + _globals['_OPENIDCONNECTSECURITYSCHEME']._serialized_end=5461 + _globals['_MUTUALTLSSECURITYSCHEME']._serialized_start=5463 + _globals['_MUTUALTLSSECURITYSCHEME']._serialized_end=5522 + _globals['_OAUTHFLOWS']._serialized_start=5525 + _globals['_OAUTHFLOWS']._serialized_end=5829 + _globals['_AUTHORIZATIONCODEOAUTHFLOW']._serialized_start=5832 + _globals['_AUTHORIZATIONCODEOAUTHFLOW']._serialized_end=6098 + _globals['_AUTHORIZATIONCODEOAUTHFLOW_SCOPESENTRY']._serialized_start=6041 + _globals['_AUTHORIZATIONCODEOAUTHFLOW_SCOPESENTRY']._serialized_end=6098 + _globals['_CLIENTCREDENTIALSOAUTHFLOW']._serialized_start=6101 + _globals['_CLIENTCREDENTIALSOAUTHFLOW']._serialized_end=6322 + _globals['_CLIENTCREDENTIALSOAUTHFLOW_SCOPESENTRY']._serialized_start=6041 + _globals['_CLIENTCREDENTIALSOAUTHFLOW_SCOPESENTRY']._serialized_end=6098 + _globals['_IMPLICITOAUTHFLOW']._serialized_start=6325 + _globals['_IMPLICITOAUTHFLOW']._serialized_end=6544 + _globals['_IMPLICITOAUTHFLOW_SCOPESENTRY']._serialized_start=6041 + _globals['_IMPLICITOAUTHFLOW_SCOPESENTRY']._serialized_end=6098 + _globals['_PASSWORDOAUTHFLOW']._serialized_start=6547 + _globals['_PASSWORDOAUTHFLOW']._serialized_end=6750 + _globals['_PASSWORDOAUTHFLOW_SCOPESENTRY']._serialized_start=6041 + _globals['_PASSWORDOAUTHFLOW_SCOPESENTRY']._serialized_end=6098 + _globals['_SENDMESSAGEREQUEST']._serialized_start=6753 + _globals['_SENDMESSAGEREQUEST']._serialized_end=6946 + _globals['_GETTASKREQUEST']._serialized_start=6948 + _globals['_GETTASKREQUEST']._serialized_end=7028 + _globals['_CANCELTASKREQUEST']._serialized_start=7030 + _globals['_CANCELTASKREQUEST']._serialized_end=7069 + _globals['_GETTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=7071 + _globals['_GETTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=7129 + _globals['_DELETETASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=7131 + _globals['_DELETETASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=7192 + _globals['_CREATETASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=7195 + _globals['_CREATETASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=7364 + _globals['_TASKSUBSCRIPTIONREQUEST']._serialized_start=7366 + _globals['_TASKSUBSCRIPTIONREQUEST']._serialized_end=7411 + _globals['_LISTTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=7413 + _globals['_LISTTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=7536 + _globals['_GETAGENTCARDREQUEST']._serialized_start=7538 + _globals['_GETAGENTCARDREQUEST']._serialized_end=7559 + _globals['_SENDMESSAGERESPONSE']._serialized_start=7561 + _globals['_SENDMESSAGERESPONSE']._serialized_end=7670 + _globals['_STREAMRESPONSE']._serialized_start=7673 + _globals['_STREAMRESPONSE']._serialized_end=7923 + _globals['_LISTTASKPUSHNOTIFICATIONCONFIGRESPONSE']._serialized_start=7926 + _globals['_LISTTASKPUSHNOTIFICATIONCONFIGRESPONSE']._serialized_end=8068 + _globals['_A2ASERVICE']._serialized_start=8385 + _globals['_A2ASERVICE']._serialized_end=9724 +# @@protoc_insertion_point(module_scope) diff --git a/src/a2a/compat/v0_3/a2a_v0_3_pb2.pyi b/src/a2a/compat/v0_3/a2a_v0_3_pb2.pyi new file mode 100644 index 000000000..06005e850 --- /dev/null +++ b/src/a2a/compat/v0_3/a2a_v0_3_pb2.pyi @@ -0,0 +1,574 @@ +import datetime + +from google.api import annotations_pb2 as _annotations_pb2 +from google.api import client_pb2 as _client_pb2 +from google.api import field_behavior_pb2 as _field_behavior_pb2 +from google.protobuf import empty_pb2 as _empty_pb2 +from google.protobuf import struct_pb2 as _struct_pb2 +from google.protobuf import timestamp_pb2 as _timestamp_pb2 +from google.protobuf.internal import containers as _containers +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from collections.abc import Iterable as _Iterable, Mapping as _Mapping +from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class TaskState(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + TASK_STATE_UNSPECIFIED: _ClassVar[TaskState] + TASK_STATE_SUBMITTED: _ClassVar[TaskState] + TASK_STATE_WORKING: _ClassVar[TaskState] + TASK_STATE_COMPLETED: _ClassVar[TaskState] + TASK_STATE_FAILED: _ClassVar[TaskState] + TASK_STATE_CANCELLED: _ClassVar[TaskState] + TASK_STATE_INPUT_REQUIRED: _ClassVar[TaskState] + TASK_STATE_REJECTED: _ClassVar[TaskState] + TASK_STATE_AUTH_REQUIRED: _ClassVar[TaskState] + +class Role(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + ROLE_UNSPECIFIED: _ClassVar[Role] + ROLE_USER: _ClassVar[Role] + ROLE_AGENT: _ClassVar[Role] +TASK_STATE_UNSPECIFIED: TaskState +TASK_STATE_SUBMITTED: TaskState +TASK_STATE_WORKING: TaskState +TASK_STATE_COMPLETED: TaskState +TASK_STATE_FAILED: TaskState +TASK_STATE_CANCELLED: TaskState +TASK_STATE_INPUT_REQUIRED: TaskState +TASK_STATE_REJECTED: TaskState +TASK_STATE_AUTH_REQUIRED: TaskState +ROLE_UNSPECIFIED: Role +ROLE_USER: Role +ROLE_AGENT: Role + +class SendMessageConfiguration(_message.Message): + __slots__ = ("accepted_output_modes", "push_notification", "history_length", "blocking") + ACCEPTED_OUTPUT_MODES_FIELD_NUMBER: _ClassVar[int] + PUSH_NOTIFICATION_FIELD_NUMBER: _ClassVar[int] + HISTORY_LENGTH_FIELD_NUMBER: _ClassVar[int] + BLOCKING_FIELD_NUMBER: _ClassVar[int] + accepted_output_modes: _containers.RepeatedScalarFieldContainer[str] + push_notification: PushNotificationConfig + history_length: int + blocking: bool + def __init__(self, accepted_output_modes: _Optional[_Iterable[str]] = ..., push_notification: _Optional[_Union[PushNotificationConfig, _Mapping]] = ..., history_length: _Optional[int] = ..., blocking: _Optional[bool] = ...) -> None: ... + +class Task(_message.Message): + __slots__ = ("id", "context_id", "status", "artifacts", "history", "metadata") + ID_FIELD_NUMBER: _ClassVar[int] + CONTEXT_ID_FIELD_NUMBER: _ClassVar[int] + STATUS_FIELD_NUMBER: _ClassVar[int] + ARTIFACTS_FIELD_NUMBER: _ClassVar[int] + HISTORY_FIELD_NUMBER: _ClassVar[int] + METADATA_FIELD_NUMBER: _ClassVar[int] + id: str + context_id: str + status: TaskStatus + artifacts: _containers.RepeatedCompositeFieldContainer[Artifact] + history: _containers.RepeatedCompositeFieldContainer[Message] + metadata: _struct_pb2.Struct + def __init__(self, id: _Optional[str] = ..., context_id: _Optional[str] = ..., status: _Optional[_Union[TaskStatus, _Mapping]] = ..., artifacts: _Optional[_Iterable[_Union[Artifact, _Mapping]]] = ..., history: _Optional[_Iterable[_Union[Message, _Mapping]]] = ..., metadata: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ... + +class TaskStatus(_message.Message): + __slots__ = ("state", "update", "timestamp") + STATE_FIELD_NUMBER: _ClassVar[int] + UPDATE_FIELD_NUMBER: _ClassVar[int] + TIMESTAMP_FIELD_NUMBER: _ClassVar[int] + state: TaskState + update: Message + timestamp: _timestamp_pb2.Timestamp + def __init__(self, state: _Optional[_Union[TaskState, str]] = ..., update: _Optional[_Union[Message, _Mapping]] = ..., timestamp: _Optional[_Union[datetime.datetime, _timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ... + +class Part(_message.Message): + __slots__ = ("text", "file", "data", "metadata") + TEXT_FIELD_NUMBER: _ClassVar[int] + FILE_FIELD_NUMBER: _ClassVar[int] + DATA_FIELD_NUMBER: _ClassVar[int] + METADATA_FIELD_NUMBER: _ClassVar[int] + text: str + file: FilePart + data: DataPart + metadata: _struct_pb2.Struct + def __init__(self, text: _Optional[str] = ..., file: _Optional[_Union[FilePart, _Mapping]] = ..., data: _Optional[_Union[DataPart, _Mapping]] = ..., metadata: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ... + +class FilePart(_message.Message): + __slots__ = ("file_with_uri", "file_with_bytes", "mime_type", "name") + FILE_WITH_URI_FIELD_NUMBER: _ClassVar[int] + FILE_WITH_BYTES_FIELD_NUMBER: _ClassVar[int] + MIME_TYPE_FIELD_NUMBER: _ClassVar[int] + NAME_FIELD_NUMBER: _ClassVar[int] + file_with_uri: str + file_with_bytes: bytes + mime_type: str + name: str + def __init__(self, file_with_uri: _Optional[str] = ..., file_with_bytes: _Optional[bytes] = ..., mime_type: _Optional[str] = ..., name: _Optional[str] = ...) -> None: ... + +class DataPart(_message.Message): + __slots__ = ("data",) + DATA_FIELD_NUMBER: _ClassVar[int] + data: _struct_pb2.Struct + def __init__(self, data: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ... + +class Message(_message.Message): + __slots__ = ("message_id", "context_id", "task_id", "role", "content", "metadata", "extensions") + MESSAGE_ID_FIELD_NUMBER: _ClassVar[int] + CONTEXT_ID_FIELD_NUMBER: _ClassVar[int] + TASK_ID_FIELD_NUMBER: _ClassVar[int] + ROLE_FIELD_NUMBER: _ClassVar[int] + CONTENT_FIELD_NUMBER: _ClassVar[int] + METADATA_FIELD_NUMBER: _ClassVar[int] + EXTENSIONS_FIELD_NUMBER: _ClassVar[int] + message_id: str + context_id: str + task_id: str + role: Role + content: _containers.RepeatedCompositeFieldContainer[Part] + metadata: _struct_pb2.Struct + extensions: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, message_id: _Optional[str] = ..., context_id: _Optional[str] = ..., task_id: _Optional[str] = ..., role: _Optional[_Union[Role, str]] = ..., content: _Optional[_Iterable[_Union[Part, _Mapping]]] = ..., metadata: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., extensions: _Optional[_Iterable[str]] = ...) -> None: ... + +class Artifact(_message.Message): + __slots__ = ("artifact_id", "name", "description", "parts", "metadata", "extensions") + ARTIFACT_ID_FIELD_NUMBER: _ClassVar[int] + NAME_FIELD_NUMBER: _ClassVar[int] + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + PARTS_FIELD_NUMBER: _ClassVar[int] + METADATA_FIELD_NUMBER: _ClassVar[int] + EXTENSIONS_FIELD_NUMBER: _ClassVar[int] + artifact_id: str + name: str + description: str + parts: _containers.RepeatedCompositeFieldContainer[Part] + metadata: _struct_pb2.Struct + extensions: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, artifact_id: _Optional[str] = ..., name: _Optional[str] = ..., description: _Optional[str] = ..., parts: _Optional[_Iterable[_Union[Part, _Mapping]]] = ..., metadata: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., extensions: _Optional[_Iterable[str]] = ...) -> None: ... + +class TaskStatusUpdateEvent(_message.Message): + __slots__ = ("task_id", "context_id", "status", "final", "metadata") + TASK_ID_FIELD_NUMBER: _ClassVar[int] + CONTEXT_ID_FIELD_NUMBER: _ClassVar[int] + STATUS_FIELD_NUMBER: _ClassVar[int] + FINAL_FIELD_NUMBER: _ClassVar[int] + METADATA_FIELD_NUMBER: _ClassVar[int] + task_id: str + context_id: str + status: TaskStatus + final: bool + metadata: _struct_pb2.Struct + def __init__(self, task_id: _Optional[str] = ..., context_id: _Optional[str] = ..., status: _Optional[_Union[TaskStatus, _Mapping]] = ..., final: _Optional[bool] = ..., metadata: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ... + +class TaskArtifactUpdateEvent(_message.Message): + __slots__ = ("task_id", "context_id", "artifact", "append", "last_chunk", "metadata") + TASK_ID_FIELD_NUMBER: _ClassVar[int] + CONTEXT_ID_FIELD_NUMBER: _ClassVar[int] + ARTIFACT_FIELD_NUMBER: _ClassVar[int] + APPEND_FIELD_NUMBER: _ClassVar[int] + LAST_CHUNK_FIELD_NUMBER: _ClassVar[int] + METADATA_FIELD_NUMBER: _ClassVar[int] + task_id: str + context_id: str + artifact: Artifact + append: bool + last_chunk: bool + metadata: _struct_pb2.Struct + def __init__(self, task_id: _Optional[str] = ..., context_id: _Optional[str] = ..., artifact: _Optional[_Union[Artifact, _Mapping]] = ..., append: _Optional[bool] = ..., last_chunk: _Optional[bool] = ..., metadata: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ... + +class PushNotificationConfig(_message.Message): + __slots__ = ("id", "url", "token", "authentication") + ID_FIELD_NUMBER: _ClassVar[int] + URL_FIELD_NUMBER: _ClassVar[int] + TOKEN_FIELD_NUMBER: _ClassVar[int] + AUTHENTICATION_FIELD_NUMBER: _ClassVar[int] + id: str + url: str + token: str + authentication: AuthenticationInfo + def __init__(self, id: _Optional[str] = ..., url: _Optional[str] = ..., token: _Optional[str] = ..., authentication: _Optional[_Union[AuthenticationInfo, _Mapping]] = ...) -> None: ... + +class AuthenticationInfo(_message.Message): + __slots__ = ("schemes", "credentials") + SCHEMES_FIELD_NUMBER: _ClassVar[int] + CREDENTIALS_FIELD_NUMBER: _ClassVar[int] + schemes: _containers.RepeatedScalarFieldContainer[str] + credentials: str + def __init__(self, schemes: _Optional[_Iterable[str]] = ..., credentials: _Optional[str] = ...) -> None: ... + +class AgentInterface(_message.Message): + __slots__ = ("url", "transport") + URL_FIELD_NUMBER: _ClassVar[int] + TRANSPORT_FIELD_NUMBER: _ClassVar[int] + url: str + transport: str + def __init__(self, url: _Optional[str] = ..., transport: _Optional[str] = ...) -> None: ... + +class AgentCard(_message.Message): + __slots__ = ("protocol_version", "name", "description", "url", "preferred_transport", "additional_interfaces", "provider", "version", "documentation_url", "capabilities", "security_schemes", "security", "default_input_modes", "default_output_modes", "skills", "supports_authenticated_extended_card", "signatures", "icon_url") + class SecuritySchemesEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: SecurityScheme + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[SecurityScheme, _Mapping]] = ...) -> None: ... + PROTOCOL_VERSION_FIELD_NUMBER: _ClassVar[int] + NAME_FIELD_NUMBER: _ClassVar[int] + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + URL_FIELD_NUMBER: _ClassVar[int] + PREFERRED_TRANSPORT_FIELD_NUMBER: _ClassVar[int] + ADDITIONAL_INTERFACES_FIELD_NUMBER: _ClassVar[int] + PROVIDER_FIELD_NUMBER: _ClassVar[int] + VERSION_FIELD_NUMBER: _ClassVar[int] + DOCUMENTATION_URL_FIELD_NUMBER: _ClassVar[int] + CAPABILITIES_FIELD_NUMBER: _ClassVar[int] + SECURITY_SCHEMES_FIELD_NUMBER: _ClassVar[int] + SECURITY_FIELD_NUMBER: _ClassVar[int] + DEFAULT_INPUT_MODES_FIELD_NUMBER: _ClassVar[int] + DEFAULT_OUTPUT_MODES_FIELD_NUMBER: _ClassVar[int] + SKILLS_FIELD_NUMBER: _ClassVar[int] + SUPPORTS_AUTHENTICATED_EXTENDED_CARD_FIELD_NUMBER: _ClassVar[int] + SIGNATURES_FIELD_NUMBER: _ClassVar[int] + ICON_URL_FIELD_NUMBER: _ClassVar[int] + protocol_version: str + name: str + description: str + url: str + preferred_transport: str + additional_interfaces: _containers.RepeatedCompositeFieldContainer[AgentInterface] + provider: AgentProvider + version: str + documentation_url: str + capabilities: AgentCapabilities + security_schemes: _containers.MessageMap[str, SecurityScheme] + security: _containers.RepeatedCompositeFieldContainer[Security] + default_input_modes: _containers.RepeatedScalarFieldContainer[str] + default_output_modes: _containers.RepeatedScalarFieldContainer[str] + skills: _containers.RepeatedCompositeFieldContainer[AgentSkill] + supports_authenticated_extended_card: bool + signatures: _containers.RepeatedCompositeFieldContainer[AgentCardSignature] + icon_url: str + def __init__(self, protocol_version: _Optional[str] = ..., name: _Optional[str] = ..., description: _Optional[str] = ..., url: _Optional[str] = ..., preferred_transport: _Optional[str] = ..., additional_interfaces: _Optional[_Iterable[_Union[AgentInterface, _Mapping]]] = ..., provider: _Optional[_Union[AgentProvider, _Mapping]] = ..., version: _Optional[str] = ..., documentation_url: _Optional[str] = ..., capabilities: _Optional[_Union[AgentCapabilities, _Mapping]] = ..., security_schemes: _Optional[_Mapping[str, SecurityScheme]] = ..., security: _Optional[_Iterable[_Union[Security, _Mapping]]] = ..., default_input_modes: _Optional[_Iterable[str]] = ..., default_output_modes: _Optional[_Iterable[str]] = ..., skills: _Optional[_Iterable[_Union[AgentSkill, _Mapping]]] = ..., supports_authenticated_extended_card: _Optional[bool] = ..., signatures: _Optional[_Iterable[_Union[AgentCardSignature, _Mapping]]] = ..., icon_url: _Optional[str] = ...) -> None: ... + +class AgentProvider(_message.Message): + __slots__ = ("url", "organization") + URL_FIELD_NUMBER: _ClassVar[int] + ORGANIZATION_FIELD_NUMBER: _ClassVar[int] + url: str + organization: str + def __init__(self, url: _Optional[str] = ..., organization: _Optional[str] = ...) -> None: ... + +class AgentCapabilities(_message.Message): + __slots__ = ("streaming", "push_notifications", "extensions") + STREAMING_FIELD_NUMBER: _ClassVar[int] + PUSH_NOTIFICATIONS_FIELD_NUMBER: _ClassVar[int] + EXTENSIONS_FIELD_NUMBER: _ClassVar[int] + streaming: bool + push_notifications: bool + extensions: _containers.RepeatedCompositeFieldContainer[AgentExtension] + def __init__(self, streaming: _Optional[bool] = ..., push_notifications: _Optional[bool] = ..., extensions: _Optional[_Iterable[_Union[AgentExtension, _Mapping]]] = ...) -> None: ... + +class AgentExtension(_message.Message): + __slots__ = ("uri", "description", "required", "params") + URI_FIELD_NUMBER: _ClassVar[int] + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + REQUIRED_FIELD_NUMBER: _ClassVar[int] + PARAMS_FIELD_NUMBER: _ClassVar[int] + uri: str + description: str + required: bool + params: _struct_pb2.Struct + def __init__(self, uri: _Optional[str] = ..., description: _Optional[str] = ..., required: _Optional[bool] = ..., params: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ... + +class AgentSkill(_message.Message): + __slots__ = ("id", "name", "description", "tags", "examples", "input_modes", "output_modes", "security") + ID_FIELD_NUMBER: _ClassVar[int] + NAME_FIELD_NUMBER: _ClassVar[int] + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + TAGS_FIELD_NUMBER: _ClassVar[int] + EXAMPLES_FIELD_NUMBER: _ClassVar[int] + INPUT_MODES_FIELD_NUMBER: _ClassVar[int] + OUTPUT_MODES_FIELD_NUMBER: _ClassVar[int] + SECURITY_FIELD_NUMBER: _ClassVar[int] + id: str + name: str + description: str + tags: _containers.RepeatedScalarFieldContainer[str] + examples: _containers.RepeatedScalarFieldContainer[str] + input_modes: _containers.RepeatedScalarFieldContainer[str] + output_modes: _containers.RepeatedScalarFieldContainer[str] + security: _containers.RepeatedCompositeFieldContainer[Security] + def __init__(self, id: _Optional[str] = ..., name: _Optional[str] = ..., description: _Optional[str] = ..., tags: _Optional[_Iterable[str]] = ..., examples: _Optional[_Iterable[str]] = ..., input_modes: _Optional[_Iterable[str]] = ..., output_modes: _Optional[_Iterable[str]] = ..., security: _Optional[_Iterable[_Union[Security, _Mapping]]] = ...) -> None: ... + +class AgentCardSignature(_message.Message): + __slots__ = ("protected", "signature", "header") + PROTECTED_FIELD_NUMBER: _ClassVar[int] + SIGNATURE_FIELD_NUMBER: _ClassVar[int] + HEADER_FIELD_NUMBER: _ClassVar[int] + protected: str + signature: str + header: _struct_pb2.Struct + def __init__(self, protected: _Optional[str] = ..., signature: _Optional[str] = ..., header: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ... + +class TaskPushNotificationConfig(_message.Message): + __slots__ = ("name", "push_notification_config") + NAME_FIELD_NUMBER: _ClassVar[int] + PUSH_NOTIFICATION_CONFIG_FIELD_NUMBER: _ClassVar[int] + name: str + push_notification_config: PushNotificationConfig + def __init__(self, name: _Optional[str] = ..., push_notification_config: _Optional[_Union[PushNotificationConfig, _Mapping]] = ...) -> None: ... + +class StringList(_message.Message): + __slots__ = ("list",) + LIST_FIELD_NUMBER: _ClassVar[int] + list: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, list: _Optional[_Iterable[str]] = ...) -> None: ... + +class Security(_message.Message): + __slots__ = ("schemes",) + class SchemesEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: StringList + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[StringList, _Mapping]] = ...) -> None: ... + SCHEMES_FIELD_NUMBER: _ClassVar[int] + schemes: _containers.MessageMap[str, StringList] + def __init__(self, schemes: _Optional[_Mapping[str, StringList]] = ...) -> None: ... + +class SecurityScheme(_message.Message): + __slots__ = ("api_key_security_scheme", "http_auth_security_scheme", "oauth2_security_scheme", "open_id_connect_security_scheme", "mtls_security_scheme") + API_KEY_SECURITY_SCHEME_FIELD_NUMBER: _ClassVar[int] + HTTP_AUTH_SECURITY_SCHEME_FIELD_NUMBER: _ClassVar[int] + OAUTH2_SECURITY_SCHEME_FIELD_NUMBER: _ClassVar[int] + OPEN_ID_CONNECT_SECURITY_SCHEME_FIELD_NUMBER: _ClassVar[int] + MTLS_SECURITY_SCHEME_FIELD_NUMBER: _ClassVar[int] + api_key_security_scheme: APIKeySecurityScheme + http_auth_security_scheme: HTTPAuthSecurityScheme + oauth2_security_scheme: OAuth2SecurityScheme + open_id_connect_security_scheme: OpenIdConnectSecurityScheme + mtls_security_scheme: MutualTlsSecurityScheme + def __init__(self, api_key_security_scheme: _Optional[_Union[APIKeySecurityScheme, _Mapping]] = ..., http_auth_security_scheme: _Optional[_Union[HTTPAuthSecurityScheme, _Mapping]] = ..., oauth2_security_scheme: _Optional[_Union[OAuth2SecurityScheme, _Mapping]] = ..., open_id_connect_security_scheme: _Optional[_Union[OpenIdConnectSecurityScheme, _Mapping]] = ..., mtls_security_scheme: _Optional[_Union[MutualTlsSecurityScheme, _Mapping]] = ...) -> None: ... + +class APIKeySecurityScheme(_message.Message): + __slots__ = ("description", "location", "name") + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + LOCATION_FIELD_NUMBER: _ClassVar[int] + NAME_FIELD_NUMBER: _ClassVar[int] + description: str + location: str + name: str + def __init__(self, description: _Optional[str] = ..., location: _Optional[str] = ..., name: _Optional[str] = ...) -> None: ... + +class HTTPAuthSecurityScheme(_message.Message): + __slots__ = ("description", "scheme", "bearer_format") + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + SCHEME_FIELD_NUMBER: _ClassVar[int] + BEARER_FORMAT_FIELD_NUMBER: _ClassVar[int] + description: str + scheme: str + bearer_format: str + def __init__(self, description: _Optional[str] = ..., scheme: _Optional[str] = ..., bearer_format: _Optional[str] = ...) -> None: ... + +class OAuth2SecurityScheme(_message.Message): + __slots__ = ("description", "flows", "oauth2_metadata_url") + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + FLOWS_FIELD_NUMBER: _ClassVar[int] + OAUTH2_METADATA_URL_FIELD_NUMBER: _ClassVar[int] + description: str + flows: OAuthFlows + oauth2_metadata_url: str + def __init__(self, description: _Optional[str] = ..., flows: _Optional[_Union[OAuthFlows, _Mapping]] = ..., oauth2_metadata_url: _Optional[str] = ...) -> None: ... + +class OpenIdConnectSecurityScheme(_message.Message): + __slots__ = ("description", "open_id_connect_url") + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + OPEN_ID_CONNECT_URL_FIELD_NUMBER: _ClassVar[int] + description: str + open_id_connect_url: str + def __init__(self, description: _Optional[str] = ..., open_id_connect_url: _Optional[str] = ...) -> None: ... + +class MutualTlsSecurityScheme(_message.Message): + __slots__ = ("description",) + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + description: str + def __init__(self, description: _Optional[str] = ...) -> None: ... + +class OAuthFlows(_message.Message): + __slots__ = ("authorization_code", "client_credentials", "implicit", "password") + AUTHORIZATION_CODE_FIELD_NUMBER: _ClassVar[int] + CLIENT_CREDENTIALS_FIELD_NUMBER: _ClassVar[int] + IMPLICIT_FIELD_NUMBER: _ClassVar[int] + PASSWORD_FIELD_NUMBER: _ClassVar[int] + authorization_code: AuthorizationCodeOAuthFlow + client_credentials: ClientCredentialsOAuthFlow + implicit: ImplicitOAuthFlow + password: PasswordOAuthFlow + def __init__(self, authorization_code: _Optional[_Union[AuthorizationCodeOAuthFlow, _Mapping]] = ..., client_credentials: _Optional[_Union[ClientCredentialsOAuthFlow, _Mapping]] = ..., implicit: _Optional[_Union[ImplicitOAuthFlow, _Mapping]] = ..., password: _Optional[_Union[PasswordOAuthFlow, _Mapping]] = ...) -> None: ... + +class AuthorizationCodeOAuthFlow(_message.Message): + __slots__ = ("authorization_url", "token_url", "refresh_url", "scopes") + class ScopesEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: str + def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ... + AUTHORIZATION_URL_FIELD_NUMBER: _ClassVar[int] + TOKEN_URL_FIELD_NUMBER: _ClassVar[int] + REFRESH_URL_FIELD_NUMBER: _ClassVar[int] + SCOPES_FIELD_NUMBER: _ClassVar[int] + authorization_url: str + token_url: str + refresh_url: str + scopes: _containers.ScalarMap[str, str] + def __init__(self, authorization_url: _Optional[str] = ..., token_url: _Optional[str] = ..., refresh_url: _Optional[str] = ..., scopes: _Optional[_Mapping[str, str]] = ...) -> None: ... + +class ClientCredentialsOAuthFlow(_message.Message): + __slots__ = ("token_url", "refresh_url", "scopes") + class ScopesEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: str + def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ... + TOKEN_URL_FIELD_NUMBER: _ClassVar[int] + REFRESH_URL_FIELD_NUMBER: _ClassVar[int] + SCOPES_FIELD_NUMBER: _ClassVar[int] + token_url: str + refresh_url: str + scopes: _containers.ScalarMap[str, str] + def __init__(self, token_url: _Optional[str] = ..., refresh_url: _Optional[str] = ..., scopes: _Optional[_Mapping[str, str]] = ...) -> None: ... + +class ImplicitOAuthFlow(_message.Message): + __slots__ = ("authorization_url", "refresh_url", "scopes") + class ScopesEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: str + def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ... + AUTHORIZATION_URL_FIELD_NUMBER: _ClassVar[int] + REFRESH_URL_FIELD_NUMBER: _ClassVar[int] + SCOPES_FIELD_NUMBER: _ClassVar[int] + authorization_url: str + refresh_url: str + scopes: _containers.ScalarMap[str, str] + def __init__(self, authorization_url: _Optional[str] = ..., refresh_url: _Optional[str] = ..., scopes: _Optional[_Mapping[str, str]] = ...) -> None: ... + +class PasswordOAuthFlow(_message.Message): + __slots__ = ("token_url", "refresh_url", "scopes") + class ScopesEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: str + def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ... + TOKEN_URL_FIELD_NUMBER: _ClassVar[int] + REFRESH_URL_FIELD_NUMBER: _ClassVar[int] + SCOPES_FIELD_NUMBER: _ClassVar[int] + token_url: str + refresh_url: str + scopes: _containers.ScalarMap[str, str] + def __init__(self, token_url: _Optional[str] = ..., refresh_url: _Optional[str] = ..., scopes: _Optional[_Mapping[str, str]] = ...) -> None: ... + +class SendMessageRequest(_message.Message): + __slots__ = ("request", "configuration", "metadata") + REQUEST_FIELD_NUMBER: _ClassVar[int] + CONFIGURATION_FIELD_NUMBER: _ClassVar[int] + METADATA_FIELD_NUMBER: _ClassVar[int] + request: Message + configuration: SendMessageConfiguration + metadata: _struct_pb2.Struct + def __init__(self, request: _Optional[_Union[Message, _Mapping]] = ..., configuration: _Optional[_Union[SendMessageConfiguration, _Mapping]] = ..., metadata: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ... + +class GetTaskRequest(_message.Message): + __slots__ = ("name", "history_length") + NAME_FIELD_NUMBER: _ClassVar[int] + HISTORY_LENGTH_FIELD_NUMBER: _ClassVar[int] + name: str + history_length: int + def __init__(self, name: _Optional[str] = ..., history_length: _Optional[int] = ...) -> None: ... + +class CancelTaskRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class GetTaskPushNotificationConfigRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class DeleteTaskPushNotificationConfigRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class CreateTaskPushNotificationConfigRequest(_message.Message): + __slots__ = ("parent", "config_id", "config") + PARENT_FIELD_NUMBER: _ClassVar[int] + CONFIG_ID_FIELD_NUMBER: _ClassVar[int] + CONFIG_FIELD_NUMBER: _ClassVar[int] + parent: str + config_id: str + config: TaskPushNotificationConfig + def __init__(self, parent: _Optional[str] = ..., config_id: _Optional[str] = ..., config: _Optional[_Union[TaskPushNotificationConfig, _Mapping]] = ...) -> None: ... + +class TaskSubscriptionRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class ListTaskPushNotificationConfigRequest(_message.Message): + __slots__ = ("parent", "page_size", "page_token") + PARENT_FIELD_NUMBER: _ClassVar[int] + PAGE_SIZE_FIELD_NUMBER: _ClassVar[int] + PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + parent: str + page_size: int + page_token: str + def __init__(self, parent: _Optional[str] = ..., page_size: _Optional[int] = ..., page_token: _Optional[str] = ...) -> None: ... + +class GetAgentCardRequest(_message.Message): + __slots__ = () + def __init__(self) -> None: ... + +class SendMessageResponse(_message.Message): + __slots__ = ("task", "msg") + TASK_FIELD_NUMBER: _ClassVar[int] + MSG_FIELD_NUMBER: _ClassVar[int] + task: Task + msg: Message + def __init__(self, task: _Optional[_Union[Task, _Mapping]] = ..., msg: _Optional[_Union[Message, _Mapping]] = ...) -> None: ... + +class StreamResponse(_message.Message): + __slots__ = ("task", "msg", "status_update", "artifact_update") + TASK_FIELD_NUMBER: _ClassVar[int] + MSG_FIELD_NUMBER: _ClassVar[int] + STATUS_UPDATE_FIELD_NUMBER: _ClassVar[int] + ARTIFACT_UPDATE_FIELD_NUMBER: _ClassVar[int] + task: Task + msg: Message + status_update: TaskStatusUpdateEvent + artifact_update: TaskArtifactUpdateEvent + def __init__(self, task: _Optional[_Union[Task, _Mapping]] = ..., msg: _Optional[_Union[Message, _Mapping]] = ..., status_update: _Optional[_Union[TaskStatusUpdateEvent, _Mapping]] = ..., artifact_update: _Optional[_Union[TaskArtifactUpdateEvent, _Mapping]] = ...) -> None: ... + +class ListTaskPushNotificationConfigResponse(_message.Message): + __slots__ = ("configs", "next_page_token") + CONFIGS_FIELD_NUMBER: _ClassVar[int] + NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + configs: _containers.RepeatedCompositeFieldContainer[TaskPushNotificationConfig] + next_page_token: str + def __init__(self, configs: _Optional[_Iterable[_Union[TaskPushNotificationConfig, _Mapping]]] = ..., next_page_token: _Optional[str] = ...) -> None: ... diff --git a/src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py b/src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py new file mode 100644 index 000000000..3bbd4dec7 --- /dev/null +++ b/src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py @@ -0,0 +1,511 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc + +from . import a2a_v0_3_pb2 as a2a__v0__3__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +class A2AServiceStub(object): + """A2AService defines the gRPC version of the A2A protocol. This has a slightly + different shape than the JSONRPC version to better conform to AIP-127, + where appropriate. The nouns are AgentCard, Message, Task and + TaskPushNotificationConfig. + - Messages are not a standard resource so there is no get/delete/update/list + interface, only a send and stream custom methods. + - Tasks have a get interface and custom cancel and subscribe methods. + - TaskPushNotificationConfig are a resource whose parent is a task. + They have get, list and create methods. + - AgentCard is a static resource with only a get method. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.SendMessage = channel.unary_unary( + '/a2a.v1.A2AService/SendMessage', + request_serializer=a2a__v0__3__pb2.SendMessageRequest.SerializeToString, + response_deserializer=a2a__v0__3__pb2.SendMessageResponse.FromString, + _registered_method=True) + self.SendStreamingMessage = channel.unary_stream( + '/a2a.v1.A2AService/SendStreamingMessage', + request_serializer=a2a__v0__3__pb2.SendMessageRequest.SerializeToString, + response_deserializer=a2a__v0__3__pb2.StreamResponse.FromString, + _registered_method=True) + self.GetTask = channel.unary_unary( + '/a2a.v1.A2AService/GetTask', + request_serializer=a2a__v0__3__pb2.GetTaskRequest.SerializeToString, + response_deserializer=a2a__v0__3__pb2.Task.FromString, + _registered_method=True) + self.CancelTask = channel.unary_unary( + '/a2a.v1.A2AService/CancelTask', + request_serializer=a2a__v0__3__pb2.CancelTaskRequest.SerializeToString, + response_deserializer=a2a__v0__3__pb2.Task.FromString, + _registered_method=True) + self.TaskSubscription = channel.unary_stream( + '/a2a.v1.A2AService/TaskSubscription', + request_serializer=a2a__v0__3__pb2.TaskSubscriptionRequest.SerializeToString, + response_deserializer=a2a__v0__3__pb2.StreamResponse.FromString, + _registered_method=True) + self.CreateTaskPushNotificationConfig = channel.unary_unary( + '/a2a.v1.A2AService/CreateTaskPushNotificationConfig', + request_serializer=a2a__v0__3__pb2.CreateTaskPushNotificationConfigRequest.SerializeToString, + response_deserializer=a2a__v0__3__pb2.TaskPushNotificationConfig.FromString, + _registered_method=True) + self.GetTaskPushNotificationConfig = channel.unary_unary( + '/a2a.v1.A2AService/GetTaskPushNotificationConfig', + request_serializer=a2a__v0__3__pb2.GetTaskPushNotificationConfigRequest.SerializeToString, + response_deserializer=a2a__v0__3__pb2.TaskPushNotificationConfig.FromString, + _registered_method=True) + self.ListTaskPushNotificationConfig = channel.unary_unary( + '/a2a.v1.A2AService/ListTaskPushNotificationConfig', + request_serializer=a2a__v0__3__pb2.ListTaskPushNotificationConfigRequest.SerializeToString, + response_deserializer=a2a__v0__3__pb2.ListTaskPushNotificationConfigResponse.FromString, + _registered_method=True) + self.GetAgentCard = channel.unary_unary( + '/a2a.v1.A2AService/GetAgentCard', + request_serializer=a2a__v0__3__pb2.GetAgentCardRequest.SerializeToString, + response_deserializer=a2a__v0__3__pb2.AgentCard.FromString, + _registered_method=True) + self.DeleteTaskPushNotificationConfig = channel.unary_unary( + '/a2a.v1.A2AService/DeleteTaskPushNotificationConfig', + request_serializer=a2a__v0__3__pb2.DeleteTaskPushNotificationConfigRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + _registered_method=True) + + +class A2AServiceServicer(object): + """A2AService defines the gRPC version of the A2A protocol. This has a slightly + different shape than the JSONRPC version to better conform to AIP-127, + where appropriate. The nouns are AgentCard, Message, Task and + TaskPushNotificationConfig. + - Messages are not a standard resource so there is no get/delete/update/list + interface, only a send and stream custom methods. + - Tasks have a get interface and custom cancel and subscribe methods. + - TaskPushNotificationConfig are a resource whose parent is a task. + They have get, list and create methods. + - AgentCard is a static resource with only a get method. + """ + + def SendMessage(self, request, context): + """Send a message to the agent. This is a blocking call that will return the + task once it is completed, or a LRO if requested. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def SendStreamingMessage(self, request, context): + """SendStreamingMessage is a streaming call that will return a stream of + task update events until the Task is in an interrupted or terminal state. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetTask(self, request, context): + """Get the current state of a task from the agent. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CancelTask(self, request, context): + """Cancel a task from the agent. If supported one should expect no + more task updates for the task. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def TaskSubscription(self, request, context): + """TaskSubscription is a streaming call that will return a stream of task + update events. This attaches the stream to an existing in process task. + If the task is complete the stream will return the completed task (like + GetTask) and close the stream. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CreateTaskPushNotificationConfig(self, request, context): + """Set a push notification config for a task. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetTaskPushNotificationConfig(self, request, context): + """Get a push notification config for a task. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def ListTaskPushNotificationConfig(self, request, context): + """Get a list of push notifications configured for a task. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetAgentCard(self, request, context): + """GetAgentCard returns the agent card for the agent. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def DeleteTaskPushNotificationConfig(self, request, context): + """Delete a push notification config for a task. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_A2AServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'SendMessage': grpc.unary_unary_rpc_method_handler( + servicer.SendMessage, + request_deserializer=a2a__v0__3__pb2.SendMessageRequest.FromString, + response_serializer=a2a__v0__3__pb2.SendMessageResponse.SerializeToString, + ), + 'SendStreamingMessage': grpc.unary_stream_rpc_method_handler( + servicer.SendStreamingMessage, + request_deserializer=a2a__v0__3__pb2.SendMessageRequest.FromString, + response_serializer=a2a__v0__3__pb2.StreamResponse.SerializeToString, + ), + 'GetTask': grpc.unary_unary_rpc_method_handler( + servicer.GetTask, + request_deserializer=a2a__v0__3__pb2.GetTaskRequest.FromString, + response_serializer=a2a__v0__3__pb2.Task.SerializeToString, + ), + 'CancelTask': grpc.unary_unary_rpc_method_handler( + servicer.CancelTask, + request_deserializer=a2a__v0__3__pb2.CancelTaskRequest.FromString, + response_serializer=a2a__v0__3__pb2.Task.SerializeToString, + ), + 'TaskSubscription': grpc.unary_stream_rpc_method_handler( + servicer.TaskSubscription, + request_deserializer=a2a__v0__3__pb2.TaskSubscriptionRequest.FromString, + response_serializer=a2a__v0__3__pb2.StreamResponse.SerializeToString, + ), + 'CreateTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler( + servicer.CreateTaskPushNotificationConfig, + request_deserializer=a2a__v0__3__pb2.CreateTaskPushNotificationConfigRequest.FromString, + response_serializer=a2a__v0__3__pb2.TaskPushNotificationConfig.SerializeToString, + ), + 'GetTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler( + servicer.GetTaskPushNotificationConfig, + request_deserializer=a2a__v0__3__pb2.GetTaskPushNotificationConfigRequest.FromString, + response_serializer=a2a__v0__3__pb2.TaskPushNotificationConfig.SerializeToString, + ), + 'ListTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler( + servicer.ListTaskPushNotificationConfig, + request_deserializer=a2a__v0__3__pb2.ListTaskPushNotificationConfigRequest.FromString, + response_serializer=a2a__v0__3__pb2.ListTaskPushNotificationConfigResponse.SerializeToString, + ), + 'GetAgentCard': grpc.unary_unary_rpc_method_handler( + servicer.GetAgentCard, + request_deserializer=a2a__v0__3__pb2.GetAgentCardRequest.FromString, + response_serializer=a2a__v0__3__pb2.AgentCard.SerializeToString, + ), + 'DeleteTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler( + servicer.DeleteTaskPushNotificationConfig, + request_deserializer=a2a__v0__3__pb2.DeleteTaskPushNotificationConfigRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'a2a.v1.A2AService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + server.add_registered_method_handlers('a2a.v1.A2AService', rpc_method_handlers) + + + # This class is part of an EXPERIMENTAL API. +class A2AService(object): + """A2AService defines the gRPC version of the A2A protocol. This has a slightly + different shape than the JSONRPC version to better conform to AIP-127, + where appropriate. The nouns are AgentCard, Message, Task and + TaskPushNotificationConfig. + - Messages are not a standard resource so there is no get/delete/update/list + interface, only a send and stream custom methods. + - Tasks have a get interface and custom cancel and subscribe methods. + - TaskPushNotificationConfig are a resource whose parent is a task. + They have get, list and create methods. + - AgentCard is a static resource with only a get method. + """ + + @staticmethod + def SendMessage(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/a2a.v1.A2AService/SendMessage', + a2a__v0__3__pb2.SendMessageRequest.SerializeToString, + a2a__v0__3__pb2.SendMessageResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def SendStreamingMessage(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_stream( + request, + target, + '/a2a.v1.A2AService/SendStreamingMessage', + a2a__v0__3__pb2.SendMessageRequest.SerializeToString, + a2a__v0__3__pb2.StreamResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetTask(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/a2a.v1.A2AService/GetTask', + a2a__v0__3__pb2.GetTaskRequest.SerializeToString, + a2a__v0__3__pb2.Task.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def CancelTask(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/a2a.v1.A2AService/CancelTask', + a2a__v0__3__pb2.CancelTaskRequest.SerializeToString, + a2a__v0__3__pb2.Task.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def TaskSubscription(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_stream( + request, + target, + '/a2a.v1.A2AService/TaskSubscription', + a2a__v0__3__pb2.TaskSubscriptionRequest.SerializeToString, + a2a__v0__3__pb2.StreamResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def CreateTaskPushNotificationConfig(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/a2a.v1.A2AService/CreateTaskPushNotificationConfig', + a2a__v0__3__pb2.CreateTaskPushNotificationConfigRequest.SerializeToString, + a2a__v0__3__pb2.TaskPushNotificationConfig.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetTaskPushNotificationConfig(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/a2a.v1.A2AService/GetTaskPushNotificationConfig', + a2a__v0__3__pb2.GetTaskPushNotificationConfigRequest.SerializeToString, + a2a__v0__3__pb2.TaskPushNotificationConfig.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def ListTaskPushNotificationConfig(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/a2a.v1.A2AService/ListTaskPushNotificationConfig', + a2a__v0__3__pb2.ListTaskPushNotificationConfigRequest.SerializeToString, + a2a__v0__3__pb2.ListTaskPushNotificationConfigResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetAgentCard(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/a2a.v1.A2AService/GetAgentCard', + a2a__v0__3__pb2.GetAgentCardRequest.SerializeToString, + a2a__v0__3__pb2.AgentCard.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def DeleteTaskPushNotificationConfig(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/a2a.v1.A2AService/DeleteTaskPushNotificationConfig', + a2a__v0__3__pb2.DeleteTaskPushNotificationConfigRequest.SerializeToString, + google_dot_protobuf_dot_empty__pb2.Empty.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) From 7da93727d2e09ab1992a9a39fe28ac5b16e2a1b9 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 16 Mar 2026 10:49:08 +0000 Subject: [PATCH 21/28] update workflow --- .github/workflows/update-a2a-types.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-a2a-types.yml b/.github/workflows/update-a2a-types.yml index 2ba32499e..cd58f32da 100644 --- a/.github/workflows/update-a2a-types.yml +++ b/.github/workflows/update-a2a-types.yml @@ -2,6 +2,15 @@ name: Update A2A Schema from Specification on: workflow_dispatch: + inputs: + message: + description: 'Commit message' + required: true + type: string + sha: + description: 'SHA of the specification from which with types are being updated' + required: true + type: string jobs: generate_and_pr: runs-on: ubuntu-latest @@ -31,7 +40,7 @@ jobs: git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}" # Branch name - BRANCH_NAME="auto-update-a2a-types-${{ github.event.client_payload.sha }}" + BRANCH_NAME="auto-update-a2a-types-${{ inputs.sha }}" # Add files git add src/a2a/types/ src/a2a/compat/v0_3/ @@ -46,7 +55,7 @@ jobs: git checkout -b "$BRANCH_NAME" # Commit - git commit -m "${{ github.event.client_payload.message }}" + git commit -m "${{ inputs.message }}" # Push # Force push if branch exists (safe if branch name is unique) @@ -55,12 +64,12 @@ jobs: # Check if open PR exists if gh pr list --head "$BRANCH_NAME" --state open --json url --jq '.[0].url' | grep -q http; then echo "Open PR already exists. Updating..." - gh pr edit "$BRANCH_NAME" --title "${{ github.event.client_payload.message }}" --body "Commit: https://github.com/a2aproject/A2A/commit/${{ github.event.client_payload.sha }}" + gh pr edit "$BRANCH_NAME" --title "${{ inputs.message }}" --body "Commit: https://github.com/a2aproject/A2A/commit/${{ inputs.sha }}" else echo "Creating new PR..." gh pr create \ - --title "${{ github.event.client_payload.message }}" \ - --body "Commit: https://github.com/a2aproject/A2A/commit/${{ github.event.client_payload.sha }}" \ + --title "${{ inputs.message }}" \ + --body "Commit: https://github.com/a2aproject/A2A/commit/${{ inputs.sha }}" \ --base main \ --head "$BRANCH_NAME" \ --label "automated" \ From 147296e9991f209062fd69034df45ff691fffa65 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 16 Mar 2026 10:51:37 +0000 Subject: [PATCH 22/28] set token --- .github/workflows/update-a2a-types.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-a2a-types.yml b/.github/workflows/update-a2a-types.yml index cd58f32da..4fa55223e 100644 --- a/.github/workflows/update-a2a-types.yml +++ b/.github/workflows/update-a2a-types.yml @@ -28,7 +28,7 @@ jobs: echo "Scripts/gen_proto.sh finished." - name: Create Pull Request with Updates env: - GH_TOKEN: ${{ secrets.A2A_BOT_PAT }} + GH_TOKEN: ${{ github.token }} run: | set -euo pipefail From 1581fb572592a6d754cfa11bc3a148875fbd5236 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 16 Mar 2026 10:53:06 +0000 Subject: [PATCH 23/28] fix workflow --- .github/workflows/update-a2a-types.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/update-a2a-types.yml b/.github/workflows/update-a2a-types.yml index 4fa55223e..9be21d9a3 100644 --- a/.github/workflows/update-a2a-types.yml +++ b/.github/workflows/update-a2a-types.yml @@ -71,7 +71,5 @@ jobs: --title "${{ inputs.message }}" \ --body "Commit: https://github.com/a2aproject/A2A/commit/${{ inputs.sha }}" \ --base main \ - --head "$BRANCH_NAME" \ - --label "automated" \ - --label "dependencies" + --head "$BRANCH_NAME" fi From 117bb5daa9901ed1dee8d1f929bc051be5b937b7 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 16 Mar 2026 11:09:24 +0000 Subject: [PATCH 24/28] fix workflow --- .github/workflows/update-a2a-types.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/update-a2a-types.yml b/.github/workflows/update-a2a-types.yml index 9be21d9a3..840611279 100644 --- a/.github/workflows/update-a2a-types.yml +++ b/.github/workflows/update-a2a-types.yml @@ -4,11 +4,7 @@ on: workflow_dispatch: inputs: message: - description: 'Commit message' - required: true - type: string - sha: - description: 'SHA of the specification from which with types are being updated' + description: 'Commit and PR title' required: true type: string jobs: @@ -20,6 +16,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v6 + with: + ref: main - name: Run scripts/gen_proto.sh run: | set -euo pipefail @@ -40,7 +38,7 @@ jobs: git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}" # Branch name - BRANCH_NAME="auto-update-a2a-types-${{ inputs.sha }}" + BRANCH_NAME="auto-update-a2a-types" # Add files git add src/a2a/types/ src/a2a/compat/v0_3/ @@ -64,12 +62,12 @@ jobs: # Check if open PR exists if gh pr list --head "$BRANCH_NAME" --state open --json url --jq '.[0].url' | grep -q http; then echo "Open PR already exists. Updating..." - gh pr edit "$BRANCH_NAME" --title "${{ inputs.message }}" --body "Commit: https://github.com/a2aproject/A2A/commit/${{ inputs.sha }}" + gh pr edit "$BRANCH_NAME" --title "${{ inputs.message }}" --body "Automated update of A2A types from specification." else echo "Creating new PR..." gh pr create \ --title "${{ inputs.message }}" \ - --body "Commit: https://github.com/a2aproject/A2A/commit/${{ inputs.sha }}" \ + --body "Automated update of A2A types from specification." \ --base main \ --head "$BRANCH_NAME" fi From 713c7f5871f3c3ae89911b77fa50ee6861d0e24b Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 16 Mar 2026 14:35:38 +0000 Subject: [PATCH 25/28] fix --- .github/workflows/update-a2a-types.yml | 73 - scripts/gen_proto_compat.sh | 0 src/a2a/types/a2a.json | 2266 ++++++++++++++++++++++++ 3 files changed, 2266 insertions(+), 73 deletions(-) delete mode 100644 .github/workflows/update-a2a-types.yml mode change 100644 => 100755 scripts/gen_proto_compat.sh create mode 100644 src/a2a/types/a2a.json diff --git a/.github/workflows/update-a2a-types.yml b/.github/workflows/update-a2a-types.yml deleted file mode 100644 index 840611279..000000000 --- a/.github/workflows/update-a2a-types.yml +++ /dev/null @@ -1,73 +0,0 @@ ---- -name: Update A2A Schema from Specification -on: - workflow_dispatch: - inputs: - message: - description: 'Commit and PR title' - required: true - type: string -jobs: - generate_and_pr: - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - steps: - - name: Checkout code - uses: actions/checkout@v6 - with: - ref: main - - name: Run scripts/gen_proto.sh - run: | - set -euo pipefail - echo "Running scripts/gen_proto.sh..." - bash scripts/gen_proto.sh - echo "Scripts/gen_proto.sh finished." - - name: Create Pull Request with Updates - env: - GH_TOKEN: ${{ github.token }} - run: | - set -euo pipefail - - # Configure Git - git config --global user.name "a2a-bot" - git config --global user.email "a2a-bot@google.com" - - # Configure remote to use PAT - git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}" - - # Branch name - BRANCH_NAME="auto-update-a2a-types" - - # Add files - git add src/a2a/types/ src/a2a/compat/v0_3/ - - # Check for changes - if git diff --staged --quiet; then - echo "No changes to commit. Skipping PR creation." - exit 0 - fi - - # Create and switch to branch - git checkout -b "$BRANCH_NAME" - - # Commit - git commit -m "${{ inputs.message }}" - - # Push - # Force push if branch exists (safe if branch name is unique) - git push -u origin "$BRANCH_NAME" --force - - # Check if open PR exists - if gh pr list --head "$BRANCH_NAME" --state open --json url --jq '.[0].url' | grep -q http; then - echo "Open PR already exists. Updating..." - gh pr edit "$BRANCH_NAME" --title "${{ inputs.message }}" --body "Automated update of A2A types from specification." - else - echo "Creating new PR..." - gh pr create \ - --title "${{ inputs.message }}" \ - --body "Automated update of A2A types from specification." \ - --base main \ - --head "$BRANCH_NAME" - fi diff --git a/scripts/gen_proto_compat.sh b/scripts/gen_proto_compat.sh old mode 100644 new mode 100755 diff --git a/src/a2a/types/a2a.json b/src/a2a/types/a2a.json new file mode 100644 index 000000000..851f44a4d --- /dev/null +++ b/src/a2a/types/a2a.json @@ -0,0 +1,2266 @@ +{ + "swagger": "2.0", + "info": { + "title": "a2a.proto", + "version": "version not set" + }, + "tags": [ + { + "name": "A2AService" + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/extendedAgentCard": { + "get": { + "summary": "Gets the extended agent card for the authenticated agent.", + "operationId": "A2AService_GetExtendedAgentCard", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1AgentCard" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/message:send": { + "post": { + "summary": "Sends a message to an agent.", + "operationId": "A2AService_SendMessage", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1SendMessageResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "description": "Represents a request for the `SendMessage` method.", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1SendMessageRequest" + } + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/message:stream": { + "post": { + "summary": "Sends a streaming message to an agent, allowing for real-time interaction and status updates.\nStreaming version of `SendMessage`", + "operationId": "A2AService_SendStreamingMessage", + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/v1StreamResponse" + }, + "error": { + "$ref": "#/definitions/rpcStatus" + } + }, + "title": "Stream result of v1StreamResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "description": "Represents a request for the `SendMessage` method.", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1SendMessageRequest" + } + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/tasks": { + "get": { + "summary": "Lists tasks that match the specified filter.", + "operationId": "A2AService_ListTasks", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1ListTasksResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Tenant ID, provided as a path parameter.", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "contextId", + "description": "Filter tasks by context ID to get tasks from a specific conversation or session.", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "status", + "description": "Filter tasks by their current status state.\n\n - TASK_STATE_UNSPECIFIED: The task is in an unknown or indeterminate state.\n - TASK_STATE_SUBMITTED: Indicates that a task has been successfully submitted and acknowledged.\n - TASK_STATE_WORKING: Indicates that a task is actively being processed by the agent.\n - TASK_STATE_COMPLETED: Indicates that a task has finished successfully. This is a terminal state.\n - TASK_STATE_FAILED: Indicates that a task has finished with an error. This is a terminal state.\n - TASK_STATE_CANCELED: Indicates that a task was canceled before completion. This is a terminal state.\n - TASK_STATE_INPUT_REQUIRED: Indicates that the agent requires additional user input to proceed. This is an interrupted state.\n - TASK_STATE_REJECTED: Indicates that the agent has decided to not perform the task.\nThis may be done during initial task creation or later once an agent\nhas determined it can't or won't proceed. This is a terminal state.\n - TASK_STATE_AUTH_REQUIRED: Indicates that authentication is required to proceed. This is an interrupted state.", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "TASK_STATE_UNSPECIFIED", + "TASK_STATE_SUBMITTED", + "TASK_STATE_WORKING", + "TASK_STATE_COMPLETED", + "TASK_STATE_FAILED", + "TASK_STATE_CANCELED", + "TASK_STATE_INPUT_REQUIRED", + "TASK_STATE_REJECTED", + "TASK_STATE_AUTH_REQUIRED" + ], + "default": "TASK_STATE_UNSPECIFIED" + }, + { + "name": "pageSize", + "description": "The maximum number of tasks to return. The service may return fewer than this value.\nIf unspecified, at most 50 tasks will be returned.\nThe minimum value is 1.\nThe maximum value is 100.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageToken", + "description": "A page token, received from a previous `ListTasks` call.\n`ListTasksResponse.next_page_token`.\nProvide this to retrieve the subsequent page.", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "historyLength", + "description": "The maximum number of messages to include in each task's history.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "statusTimestampAfter", + "description": "Filter tasks which have a status updated after the provided timestamp in ISO 8601 format (e.g., \"2023-10-27T10:00:00Z\").\nOnly tasks with a status timestamp time greater than or equal to this value will be returned.", + "in": "query", + "required": false, + "type": "string", + "format": "date-time" + }, + { + "name": "includeArtifacts", + "description": "Whether to include artifacts in the returned tasks.\nDefaults to false to reduce payload size.", + "in": "query", + "required": false, + "type": "boolean" + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/tasks/{id}": { + "get": { + "summary": "Gets the latest state of a task.", + "operationId": "A2AService_GetTask", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1Task" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "The resource ID of the task to retrieve.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "historyLength", + "description": "The maximum number of most recent messages from the task's history to retrieve. An\nunset value means the client does not impose any limit. A value of zero is\na request to not include any messages. The server MUST NOT return more\nmessages than the provided value, but MAY apply a lower limit.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/tasks/{id}:cancel": { + "post": { + "summary": "Cancels a task in progress.", + "operationId": "A2AService_CancelTask", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1Task" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "The resource ID of the task to cancel.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/A2AServiceCancelTaskBody" + } + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/tasks/{id}:subscribe": { + "get": { + "summary": "Subscribes to task updates for tasks not in a terminal state.\nReturns `UnsupportedOperationError` if the task is already in a terminal state (completed, failed, canceled, rejected).", + "operationId": "A2AService_SubscribeToTask", + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/v1StreamResponse" + }, + "error": { + "$ref": "#/definitions/rpcStatus" + } + }, + "title": "Stream result of v1StreamResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "The resource ID of the task to subscribe to.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/tasks/{taskId}/pushNotificationConfigs": { + "get": { + "summary": "Get a list of push notifications configured for a task.", + "operationId": "A2AService_ListTaskPushNotificationConfigs", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1ListTaskPushNotificationConfigsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "taskId", + "description": "The parent task resource ID.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "pageSize", + "description": "The maximum number of configurations to return.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageToken", + "description": "A page token received from a previous `ListTaskPushNotificationConfigsRequest` call.", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "A2AService" + ] + }, + "post": { + "summary": "Creates a push notification config for a task.", + "operationId": "A2AService_CreateTaskPushNotificationConfig", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1TaskPushNotificationConfig" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "taskId", + "description": "The ID of the task this configuration is associated with.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/A2AServiceCreateTaskPushNotificationConfigBody" + } + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/tasks/{taskId}/pushNotificationConfigs/{id}": { + "get": { + "summary": "Gets a push notification config for a task.", + "operationId": "A2AService_GetTaskPushNotificationConfig", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1TaskPushNotificationConfig" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "taskId", + "description": "The parent task resource ID.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "id", + "description": "The resource ID of the configuration to retrieve.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "A2AService" + ] + }, + "delete": { + "summary": "Deletes a push notification config for a task.", + "operationId": "A2AService_DeleteTaskPushNotificationConfig", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "taskId", + "description": "The parent task resource ID.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "id", + "description": "The resource ID of the configuration to delete.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/{tenant}/extendedAgentCard": { + "get": { + "summary": "Gets the extended agent card for the authenticated agent.", + "operationId": "A2AService_GetExtendedAgentCard2", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1AgentCard" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/{tenant}/message:send": { + "post": { + "summary": "Sends a message to an agent.", + "operationId": "A2AService_SendMessage2", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1SendMessageResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/A2AServiceSendMessageBody" + } + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/{tenant}/message:stream": { + "post": { + "summary": "Sends a streaming message to an agent, allowing for real-time interaction and status updates.\nStreaming version of `SendMessage`", + "operationId": "A2AService_SendStreamingMessage2", + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/v1StreamResponse" + }, + "error": { + "$ref": "#/definitions/rpcStatus" + } + }, + "title": "Stream result of v1StreamResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/A2AServiceSendStreamingMessageBody" + } + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/{tenant}/tasks": { + "get": { + "summary": "Lists tasks that match the specified filter.", + "operationId": "A2AService_ListTasks2", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1ListTasksResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Tenant ID, provided as a path parameter.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "contextId", + "description": "Filter tasks by context ID to get tasks from a specific conversation or session.", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "status", + "description": "Filter tasks by their current status state.\n\n - TASK_STATE_UNSPECIFIED: The task is in an unknown or indeterminate state.\n - TASK_STATE_SUBMITTED: Indicates that a task has been successfully submitted and acknowledged.\n - TASK_STATE_WORKING: Indicates that a task is actively being processed by the agent.\n - TASK_STATE_COMPLETED: Indicates that a task has finished successfully. This is a terminal state.\n - TASK_STATE_FAILED: Indicates that a task has finished with an error. This is a terminal state.\n - TASK_STATE_CANCELED: Indicates that a task was canceled before completion. This is a terminal state.\n - TASK_STATE_INPUT_REQUIRED: Indicates that the agent requires additional user input to proceed. This is an interrupted state.\n - TASK_STATE_REJECTED: Indicates that the agent has decided to not perform the task.\nThis may be done during initial task creation or later once an agent\nhas determined it can't or won't proceed. This is a terminal state.\n - TASK_STATE_AUTH_REQUIRED: Indicates that authentication is required to proceed. This is an interrupted state.", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "TASK_STATE_UNSPECIFIED", + "TASK_STATE_SUBMITTED", + "TASK_STATE_WORKING", + "TASK_STATE_COMPLETED", + "TASK_STATE_FAILED", + "TASK_STATE_CANCELED", + "TASK_STATE_INPUT_REQUIRED", + "TASK_STATE_REJECTED", + "TASK_STATE_AUTH_REQUIRED" + ], + "default": "TASK_STATE_UNSPECIFIED" + }, + { + "name": "pageSize", + "description": "The maximum number of tasks to return. The service may return fewer than this value.\nIf unspecified, at most 50 tasks will be returned.\nThe minimum value is 1.\nThe maximum value is 100.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageToken", + "description": "A page token, received from a previous `ListTasks` call.\n`ListTasksResponse.next_page_token`.\nProvide this to retrieve the subsequent page.", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "historyLength", + "description": "The maximum number of messages to include in each task's history.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "statusTimestampAfter", + "description": "Filter tasks which have a status updated after the provided timestamp in ISO 8601 format (e.g., \"2023-10-27T10:00:00Z\").\nOnly tasks with a status timestamp time greater than or equal to this value will be returned.", + "in": "query", + "required": false, + "type": "string", + "format": "date-time" + }, + { + "name": "includeArtifacts", + "description": "Whether to include artifacts in the returned tasks.\nDefaults to false to reduce payload size.", + "in": "query", + "required": false, + "type": "boolean" + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/{tenant}/tasks/{id}": { + "get": { + "summary": "Gets the latest state of a task.", + "operationId": "A2AService_GetTask2", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1Task" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "id", + "description": "The resource ID of the task to retrieve.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "historyLength", + "description": "The maximum number of most recent messages from the task's history to retrieve. An\nunset value means the client does not impose any limit. A value of zero is\na request to not include any messages. The server MUST NOT return more\nmessages than the provided value, but MAY apply a lower limit.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/{tenant}/tasks/{id}:cancel": { + "post": { + "summary": "Cancels a task in progress.", + "operationId": "A2AService_CancelTask2", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1Task" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "id", + "description": "The resource ID of the task to cancel.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/A2AServiceCancelTaskBody" + } + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/{tenant}/tasks/{id}:subscribe": { + "get": { + "summary": "Subscribes to task updates for tasks not in a terminal state.\nReturns `UnsupportedOperationError` if the task is already in a terminal state (completed, failed, canceled, rejected).", + "operationId": "A2AService_SubscribeToTask2", + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/v1StreamResponse" + }, + "error": { + "$ref": "#/definitions/rpcStatus" + } + }, + "title": "Stream result of v1StreamResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "id", + "description": "The resource ID of the task to subscribe to.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/{tenant}/tasks/{taskId}/pushNotificationConfigs": { + "get": { + "summary": "Get a list of push notifications configured for a task.", + "operationId": "A2AService_ListTaskPushNotificationConfigs2", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1ListTaskPushNotificationConfigsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "taskId", + "description": "The parent task resource ID.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "pageSize", + "description": "The maximum number of configurations to return.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageToken", + "description": "A page token received from a previous `ListTaskPushNotificationConfigsRequest` call.", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "A2AService" + ] + }, + "post": { + "summary": "Creates a push notification config for a task.", + "operationId": "A2AService_CreateTaskPushNotificationConfig2", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1TaskPushNotificationConfig" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "taskId", + "description": "The ID of the task this configuration is associated with.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/A2AServiceCreateTaskPushNotificationConfigBody" + } + } + ], + "tags": [ + "A2AService" + ] + } + }, + "/{tenant}/tasks/{taskId}/pushNotificationConfigs/{id}": { + "get": { + "summary": "Gets a push notification config for a task.", + "operationId": "A2AService_GetTaskPushNotificationConfig2", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1TaskPushNotificationConfig" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "taskId", + "description": "The parent task resource ID.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "id", + "description": "The resource ID of the configuration to retrieve.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + } + ], + "tags": [ + "A2AService" + ] + }, + "delete": { + "summary": "Deletes a push notification config for a task.", + "operationId": "A2AService_DeleteTaskPushNotificationConfig2", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "tenant", + "description": "Optional. Tenant ID, provided as a path parameter.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "taskId", + "description": "The parent task resource ID.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + }, + { + "name": "id", + "description": "The resource ID of the configuration to delete.", + "in": "path", + "required": true, + "type": "string", + "pattern": "[^/]+" + } + ], + "tags": [ + "A2AService" + ] + } + } + }, + "definitions": { + "A2AServiceCancelTaskBody": { + "type": "object", + "properties": { + "metadata": { + "type": "object", + "description": "A flexible key-value map for passing additional context or parameters." + } + }, + "description": "Represents a request for the `CancelTask` method." + }, + "A2AServiceCreateTaskPushNotificationConfigBody": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The push notification configuration details.\nA unique identifier (e.g. UUID) for this push notification configuration." + }, + "url": { + "type": "string", + "description": "The URL where the notification should be sent." + }, + "token": { + "type": "string", + "description": "A token unique for this task or session." + }, + "authentication": { + "$ref": "#/definitions/v1AuthenticationInfo", + "description": "Authentication information required to send the notification." + } + }, + "description": "A container associating a push notification configuration with a specific task.", + "required": [ + "url" + ] + }, + "A2AServiceSendMessageBody": { + "type": "object", + "properties": { + "message": { + "$ref": "#/definitions/v1Message", + "description": "The message to send to the agent." + }, + "configuration": { + "$ref": "#/definitions/v1SendMessageConfiguration", + "description": "Configuration for the send request." + }, + "metadata": { + "type": "object", + "description": "A flexible key-value map for passing additional context or parameters." + } + }, + "description": "Represents a request for the `SendMessage` method.", + "required": [ + "message" + ] + }, + "A2AServiceSendStreamingMessageBody": { + "type": "object", + "properties": { + "message": { + "$ref": "#/definitions/v1Message", + "description": "The message to send to the agent." + }, + "configuration": { + "$ref": "#/definitions/v1SendMessageConfiguration", + "description": "Configuration for the send request." + }, + "metadata": { + "type": "object", + "description": "A flexible key-value map for passing additional context or parameters." + } + }, + "description": "Represents a request for the `SendMessage` method.", + "required": [ + "message" + ] + }, + "protobufAny": { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "protobufNullValue": { + "type": "string", + "enum": [ + "NULL_VALUE" + ], + "default": "NULL_VALUE", + "description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\nThe JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value." + }, + "rpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/protobufAny" + } + } + } + }, + "v1APIKeySecurityScheme": { + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "An optional description for the security scheme." + }, + "location": { + "type": "string", + "description": "The location of the API key. Valid values are \"query\", \"header\", or \"cookie\"." + }, + "name": { + "type": "string", + "description": "The name of the header, query, or cookie parameter to be used." + } + }, + "description": "Defines a security scheme using an API key.", + "required": [ + "location", + "name" + ] + }, + "v1AgentCapabilities": { + "type": "object", + "properties": { + "streaming": { + "type": "boolean", + "description": "Indicates if the agent supports streaming responses." + }, + "pushNotifications": { + "type": "boolean", + "description": "Indicates if the agent supports sending push notifications for asynchronous task updates." + }, + "extensions": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1AgentExtension" + }, + "description": "A list of protocol extensions supported by the agent." + }, + "extendedAgentCard": { + "type": "boolean", + "description": "Indicates if the agent supports providing an extended agent card when authenticated." + } + }, + "description": "Defines optional capabilities supported by an agent." + }, + "v1AgentCard": { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "A human readable name for the agent.\nExample: \"Recipe Agent\"" + }, + "description": { + "type": "string", + "title": "A human-readable description of the agent, assisting users and other agents\nin understanding its purpose.\nExample: \"Agent that helps users with recipes and cooking.\"" + }, + "supportedInterfaces": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1AgentInterface" + }, + "description": "Ordered list of supported interfaces. The first entry is preferred." + }, + "provider": { + "$ref": "#/definitions/v1AgentProvider", + "description": "The service provider of the agent." + }, + "version": { + "type": "string", + "title": "The version of the agent.\nExample: \"1.0.0\"" + }, + "documentationUrl": { + "type": "string", + "description": "A URL providing additional documentation about the agent." + }, + "capabilities": { + "$ref": "#/definitions/v1AgentCapabilities", + "description": "A2A Capability set supported by the agent." + }, + "securitySchemes": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/v1SecurityScheme" + }, + "description": "The security scheme details used for authenticating with this agent." + }, + "securityRequirements": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1SecurityRequirement" + }, + "description": "Security requirements for contacting the agent." + }, + "defaultInputModes": { + "type": "array", + "items": { + "type": "string" + }, + "description": "protolint:enable REPEATED_FIELD_NAMES_PLURALIZED\nThe set of interaction modes that the agent supports across all skills.\nThis can be overridden per skill. Defined as media types." + }, + "defaultOutputModes": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The media types supported as outputs from this agent." + }, + "skills": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1AgentSkill" + }, + "description": "Skills represent the abilities of an agent.\nIt is largely a descriptive concept but represents a more focused set of behaviors that the\nagent is likely to succeed at." + }, + "signatures": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1AgentCardSignature" + }, + "description": "JSON Web Signatures computed for this `AgentCard`." + }, + "iconUrl": { + "type": "string", + "description": "Optional. A URL to an icon for the agent." + } + }, + "title": "A self-describing manifest for an agent. It provides essential\nmetadata including the agent's identity, capabilities, skills, supported\ncommunication methods, and security requirements.\nNext ID: 20", + "required": [ + "name", + "description", + "supportedInterfaces", + "version", + "capabilities", + "defaultInputModes", + "defaultOutputModes", + "skills" + ] + }, + "v1AgentCardSignature": { + "type": "object", + "properties": { + "protected": { + "type": "string", + "description": "\nRequired. The protected JWS header for the signature. This is always a\nbase64url-encoded JSON object." + }, + "signature": { + "type": "string", + "description": "Required. The computed signature, base64url-encoded." + }, + "header": { + "type": "object", + "description": "The unprotected JWS header values." + } + }, + "description": "AgentCardSignature represents a JWS signature of an AgentCard.\nThis follows the JSON format of an RFC 7515 JSON Web Signature (JWS).", + "required": [ + "protected", + "signature" + ] + }, + "v1AgentExtension": { + "type": "object", + "properties": { + "uri": { + "type": "string", + "description": "The unique URI identifying the extension." + }, + "description": { + "type": "string", + "description": "A human-readable description of how this agent uses the extension." + }, + "required": { + "type": "boolean", + "description": "If true, the client must understand and comply with the extension's requirements." + }, + "params": { + "type": "object", + "description": "Optional. Extension-specific configuration parameters." + } + }, + "description": "A declaration of a protocol extension supported by an Agent." + }, + "v1AgentInterface": { + "type": "object", + "properties": { + "url": { + "type": "string", + "title": "The URL where this interface is available. Must be a valid absolute HTTPS URL in production.\nExample: \"https://api.example.com/a2a/v1\", \"https://grpc.example.com/a2a\"" + }, + "protocolBinding": { + "type": "string", + "description": "The protocol binding supported at this URL. This is an open form string, to be\neasily extended for other protocol bindings. The core ones officially\nsupported are `JSONRPC`, `GRPC` and `HTTP+JSON`." + }, + "tenant": { + "type": "string", + "description": "Tenant ID to be used in the request when calling the agent." + }, + "protocolVersion": { + "type": "string", + "title": "The version of the A2A protocol this interface exposes.\nUse the latest supported minor version per major version.\nExamples: \"0.3\", \"1.0\"" + } + }, + "description": "Declares a combination of a target URL, transport and protocol version for interacting with the agent.\nThis allows agents to expose the same functionality over multiple protocol binding mechanisms.", + "required": [ + "url", + "protocolBinding", + "protocolVersion" + ] + }, + "v1AgentProvider": { + "type": "object", + "properties": { + "url": { + "type": "string", + "title": "A URL for the agent provider's website or relevant documentation.\nExample: \"https://ai.google.dev\"" + }, + "organization": { + "type": "string", + "title": "The name of the agent provider's organization.\nExample: \"Google\"" + } + }, + "description": "Represents the service provider of an agent.", + "required": [ + "url", + "organization" + ] + }, + "v1AgentSkill": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "A unique identifier for the agent's skill." + }, + "name": { + "type": "string", + "description": "A human-readable name for the skill." + }, + "description": { + "type": "string", + "description": "A detailed description of the skill." + }, + "tags": { + "type": "array", + "items": { + "type": "string" + }, + "description": "A set of keywords describing the skill's capabilities." + }, + "examples": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Example prompts or scenarios that this skill can handle." + }, + "inputModes": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The set of supported input media types for this skill, overriding the agent's defaults." + }, + "outputModes": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The set of supported output media types for this skill, overriding the agent's defaults." + }, + "securityRequirements": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1SecurityRequirement" + }, + "description": "Security schemes necessary for this skill." + } + }, + "description": "Represents a distinct capability or function that an agent can perform.", + "required": [ + "id", + "name", + "description", + "tags" + ] + }, + "v1Artifact": { + "type": "object", + "properties": { + "artifactId": { + "type": "string", + "description": "Unique identifier (e.g. UUID) for the artifact. It must be unique within a task." + }, + "name": { + "type": "string", + "description": "A human readable name for the artifact." + }, + "description": { + "type": "string", + "description": "Optional. A human readable description of the artifact." + }, + "parts": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Part" + }, + "description": "The content of the artifact. Must contain at least one part." + }, + "metadata": { + "type": "object", + "description": "Optional. Metadata included with the artifact." + }, + "extensions": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The URIs of extensions that are present or contributed to this Artifact." + } + }, + "description": "Artifacts represent task outputs.", + "required": [ + "artifactId", + "parts" + ] + }, + "v1AuthenticationInfo": { + "type": "object", + "properties": { + "scheme": { + "type": "string", + "description": "HTTP Authentication Scheme from the [IANA registry](https://www.iana.org/assignments/http-authschemes/).\nExamples: `Bearer`, `Basic`, `Digest`.\nScheme names are case-insensitive per [RFC 9110 Section 11.1](https://www.rfc-editor.org/rfc/rfc9110#section-11.1)." + }, + "credentials": { + "type": "string", + "description": "Push Notification credentials. Format depends on the scheme (e.g., token for Bearer)." + } + }, + "description": "Defines authentication details, used for push notifications.", + "required": [ + "scheme" + ] + }, + "v1AuthorizationCodeOAuthFlow": { + "type": "object", + "properties": { + "authorizationUrl": { + "type": "string", + "description": "The authorization URL to be used for this flow." + }, + "tokenUrl": { + "type": "string", + "description": "The token URL to be used for this flow." + }, + "refreshUrl": { + "type": "string", + "description": "The URL to be used for obtaining refresh tokens." + }, + "scopes": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "The available scopes for the OAuth2 security scheme." + }, + "pkceRequired": { + "type": "boolean", + "description": "Indicates if PKCE (RFC 7636) is required for this flow.\nPKCE should always be used for public clients and is recommended for all clients." + } + }, + "description": "Defines configuration details for the OAuth 2.0 Authorization Code flow.", + "required": [ + "authorizationUrl", + "tokenUrl", + "scopes" + ] + }, + "v1ClientCredentialsOAuthFlow": { + "type": "object", + "properties": { + "tokenUrl": { + "type": "string", + "description": "The token URL to be used for this flow." + }, + "refreshUrl": { + "type": "string", + "description": "The URL to be used for obtaining refresh tokens." + }, + "scopes": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "The available scopes for the OAuth2 security scheme." + } + }, + "description": "Defines configuration details for the OAuth 2.0 Client Credentials flow.", + "required": [ + "tokenUrl", + "scopes" + ] + }, + "v1DeviceCodeOAuthFlow": { + "type": "object", + "properties": { + "deviceAuthorizationUrl": { + "type": "string", + "description": "The device authorization endpoint URL." + }, + "tokenUrl": { + "type": "string", + "description": "The token URL to be used for this flow." + }, + "refreshUrl": { + "type": "string", + "description": "The URL to be used for obtaining refresh tokens." + }, + "scopes": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "The available scopes for the OAuth2 security scheme." + } + }, + "description": "Defines configuration details for the OAuth 2.0 Device Code flow (RFC 8628).\nThis flow is designed for input-constrained devices such as IoT devices,\nand CLI tools where the user authenticates on a separate device.", + "required": [ + "deviceAuthorizationUrl", + "tokenUrl", + "scopes" + ] + }, + "v1HTTPAuthSecurityScheme": { + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "An optional description for the security scheme." + }, + "scheme": { + "type": "string", + "description": "The name of the HTTP Authentication scheme to be used in the Authorization header,\nas defined in RFC7235 (e.g., \"Bearer\").\nThis value should be registered in the IANA Authentication Scheme registry." + }, + "bearerFormat": { + "type": "string", + "description": "A hint to the client to identify how the bearer token is formatted (e.g., \"JWT\").\nPrimarily for documentation purposes." + } + }, + "description": "Defines a security scheme using HTTP authentication.", + "required": [ + "scheme" + ] + }, + "v1ImplicitOAuthFlow": { + "type": "object", + "properties": { + "authorizationUrl": { + "type": "string", + "title": "The authorization URL to be used for this flow. This MUST be in the\nform of a URL. The OAuth2 standard requires the use of TLS" + }, + "refreshUrl": { + "type": "string", + "description": "The URL to be used for obtaining refresh tokens. This MUST be in the\nform of a URL. The OAuth2 standard requires the use of TLS." + }, + "scopes": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "The available scopes for the OAuth2 security scheme. A map between the\nscope name and a short description for it. The map MAY be empty." + } + }, + "description": "Deprecated: Use Authorization Code + PKCE instead." + }, + "v1ListTaskPushNotificationConfigsResponse": { + "type": "object", + "properties": { + "configs": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1TaskPushNotificationConfig" + }, + "description": "The list of push notification configurations." + }, + "nextPageToken": { + "type": "string", + "description": "A token to retrieve the next page of results, or empty if there are no more results in the list." + } + }, + "description": "Represents a successful response for the `ListTaskPushNotificationConfigs`\nmethod." + }, + "v1ListTasksResponse": { + "type": "object", + "properties": { + "tasks": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Task" + }, + "description": "Array of tasks matching the specified criteria." + }, + "nextPageToken": { + "type": "string", + "description": "A token to retrieve the next page of results, or empty if there are no more results in the list." + }, + "pageSize": { + "type": "integer", + "format": "int32", + "description": "The page size used for this response." + }, + "totalSize": { + "type": "integer", + "format": "int32", + "description": "Total number of tasks available (before pagination)." + } + }, + "description": "Result object for `ListTasks` method containing an array of tasks and pagination information.", + "required": [ + "tasks", + "nextPageToken", + "pageSize", + "totalSize" + ] + }, + "v1Message": { + "type": "object", + "properties": { + "messageId": { + "type": "string", + "description": "The unique identifier (e.g. UUID) of the message. This is created by the message creator." + }, + "contextId": { + "type": "string", + "description": "Optional. The context id of the message. If set, the message will be associated with the given context." + }, + "taskId": { + "type": "string", + "description": "Optional. The task id of the message. If set, the message will be associated with the given task." + }, + "role": { + "$ref": "#/definitions/v1Role", + "description": "Identifies the sender of the message." + }, + "parts": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Part" + }, + "description": "Parts is the container of the message content." + }, + "metadata": { + "type": "object", + "description": "Optional. Any metadata to provide along with the message." + }, + "extensions": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The URIs of extensions that are present or contributed to this Message." + }, + "referenceTaskIds": { + "type": "array", + "items": { + "type": "string" + }, + "description": "A list of task IDs that this message references for additional context." + } + }, + "description": "`Message` is one unit of communication between client and server. It can be\nassociated with a context and/or a task. For server messages, `context_id` must\nbe provided, and `task_id` only if a task was created. For client messages, both\nfields are optional, with the caveat that if both are provided, they have to\nmatch (the `context_id` has to be the one that is set on the task). If only\n`task_id` is provided, the server will infer `context_id` from it.", + "required": [ + "messageId", + "role", + "parts" + ] + }, + "v1MutualTlsSecurityScheme": { + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "An optional description for the security scheme." + } + }, + "description": "Defines a security scheme using mTLS authentication." + }, + "v1OAuth2SecurityScheme": { + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "An optional description for the security scheme." + }, + "flows": { + "$ref": "#/definitions/v1OAuthFlows", + "description": "An object containing configuration information for the supported OAuth 2.0 flows." + }, + "oauth2MetadataUrl": { + "type": "string", + "description": "URL to the OAuth2 authorization server metadata [RFC 8414](https://datatracker.ietf.org/doc/html/rfc8414).\nTLS is required." + } + }, + "description": "Defines a security scheme using OAuth 2.0.", + "required": [ + "flows" + ] + }, + "v1OAuthFlows": { + "type": "object", + "properties": { + "authorizationCode": { + "$ref": "#/definitions/v1AuthorizationCodeOAuthFlow", + "description": "Configuration for the OAuth Authorization Code flow." + }, + "clientCredentials": { + "$ref": "#/definitions/v1ClientCredentialsOAuthFlow", + "description": "Configuration for the OAuth Client Credentials flow." + }, + "implicit": { + "$ref": "#/definitions/v1ImplicitOAuthFlow", + "description": "Deprecated: Use Authorization Code + PKCE instead." + }, + "password": { + "$ref": "#/definitions/v1PasswordOAuthFlow", + "description": "Deprecated: Use Authorization Code + PKCE or Device Code." + }, + "deviceCode": { + "$ref": "#/definitions/v1DeviceCodeOAuthFlow", + "description": "Configuration for the OAuth Device Code flow." + } + }, + "description": "Defines the configuration for the supported OAuth 2.0 flows." + }, + "v1OpenIdConnectSecurityScheme": { + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "An optional description for the security scheme." + }, + "openIdConnectUrl": { + "type": "string", + "description": "The [OpenID Connect Discovery URL](https://openid.net/specs/openid-connect-discovery-1_0.html) for the OIDC provider's metadata." + } + }, + "description": "Defines a security scheme using OpenID Connect.", + "required": [ + "openIdConnectUrl" + ] + }, + "v1Part": { + "type": "object", + "properties": { + "text": { + "type": "string", + "description": "The string content of the `text` part." + }, + "raw": { + "type": "string", + "format": "byte", + "description": "The `raw` byte content of a file. In JSON serialization, this is encoded as a base64 string." + }, + "url": { + "type": "string", + "description": "A `url` pointing to the file's content." + }, + "data": { + "description": "Arbitrary structured `data` as a JSON value (object, array, string, number, boolean, or null)." + }, + "metadata": { + "type": "object", + "description": "Optional. metadata associated with this part." + }, + "filename": { + "type": "string", + "description": "An optional `filename` for the file (e.g., \"document.pdf\")." + }, + "mediaType": { + "type": "string", + "description": "The `media_type` (MIME type) of the part content (e.g., \"text/plain\", \"application/json\", \"image/png\").\nThis field is available for all part types." + } + }, + "description": "`Part` represents a container for a section of communication content.\nParts can be purely textual, some sort of file (image, video, etc) or\na structured data blob (i.e. JSON)." + }, + "v1PasswordOAuthFlow": { + "type": "object", + "properties": { + "tokenUrl": { + "type": "string", + "description": "The token URL to be used for this flow. This MUST be in the form of a URL.\nThe OAuth2 standard requires the use of TLS." + }, + "refreshUrl": { + "type": "string", + "description": "The URL to be used for obtaining refresh tokens. This MUST be in the\nform of a URL. The OAuth2 standard requires the use of TLS." + }, + "scopes": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "The available scopes for the OAuth2 security scheme. A map between the\nscope name and a short description for it. The map MAY be empty." + } + }, + "description": "Deprecated: Use Authorization Code + PKCE or Device Code." + }, + "v1Role": { + "type": "string", + "enum": [ + "ROLE_UNSPECIFIED", + "ROLE_USER", + "ROLE_AGENT" + ], + "default": "ROLE_UNSPECIFIED", + "description": "Defines the sender of a message in A2A protocol communication.\n\n - ROLE_UNSPECIFIED: The role is unspecified.\n - ROLE_USER: The message is from the client to the server.\n - ROLE_AGENT: The message is from the server to the client." + }, + "v1SecurityRequirement": { + "type": "object", + "properties": { + "schemes": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/v1StringList" + }, + "description": "A map of security schemes to the required scopes." + } + }, + "description": "Defines the security requirements for an agent." + }, + "v1SecurityScheme": { + "type": "object", + "properties": { + "apiKeySecurityScheme": { + "$ref": "#/definitions/v1APIKeySecurityScheme", + "description": "API key-based authentication." + }, + "httpAuthSecurityScheme": { + "$ref": "#/definitions/v1HTTPAuthSecurityScheme", + "description": "HTTP authentication (Basic, Bearer, etc.)." + }, + "oauth2SecurityScheme": { + "$ref": "#/definitions/v1OAuth2SecurityScheme", + "description": "OAuth 2.0 authentication." + }, + "openIdConnectSecurityScheme": { + "$ref": "#/definitions/v1OpenIdConnectSecurityScheme", + "description": "OpenID Connect authentication." + }, + "mtlsSecurityScheme": { + "$ref": "#/definitions/v1MutualTlsSecurityScheme", + "description": "Mutual TLS authentication." + } + }, + "title": "Defines a security scheme that can be used to secure an agent's endpoints.\nThis is a discriminated union type based on the OpenAPI 3.2 Security Scheme Object.\nSee: https://spec.openapis.org/oas/v3.2.0.html#security-scheme-object" + }, + "v1SendMessageConfiguration": { + "type": "object", + "properties": { + "acceptedOutputModes": { + "type": "array", + "items": { + "type": "string" + }, + "description": "A list of media types the client is prepared to accept for response parts.\nAgents SHOULD use this to tailor their output." + }, + "taskPushNotificationConfig": { + "$ref": "#/definitions/v1TaskPushNotificationConfig", + "description": "Configuration for the agent to send push notifications for task updates.\nTask id should be empty when sending this configuration in a `SendMessage` request." + }, + "historyLength": { + "type": "integer", + "format": "int32", + "description": "The maximum number of most recent messages from the task's history to retrieve in\nthe response. An unset value means the client does not impose any limit. A\nvalue of zero is a request to not include any messages. The server MUST NOT\nreturn more messages than the provided value, but MAY apply a lower limit." + }, + "returnImmediately": { + "type": "boolean", + "description": "If `true`, the operation returns immediately after creating the task,\neven if processing is still in progress.\nIf `false` (default), the operation MUST wait until the task reaches a\nterminal (`COMPLETED`, `FAILED`, `CANCELED`, `REJECTED`) or interrupted\n(`INPUT_REQUIRED`, `AUTH_REQUIRED`) state before returning." + } + }, + "description": "Configuration of a send message request." + }, + "v1SendMessageRequest": { + "type": "object", + "properties": { + "tenant": { + "type": "string", + "description": "Optional. Tenant ID, provided as a path parameter." + }, + "message": { + "$ref": "#/definitions/v1Message", + "description": "The message to send to the agent." + }, + "configuration": { + "$ref": "#/definitions/v1SendMessageConfiguration", + "description": "Configuration for the send request." + }, + "metadata": { + "type": "object", + "description": "A flexible key-value map for passing additional context or parameters." + } + }, + "description": "Represents a request for the `SendMessage` method.", + "required": [ + "message" + ] + }, + "v1SendMessageResponse": { + "type": "object", + "properties": { + "task": { + "$ref": "#/definitions/v1Task", + "description": "The task created or updated by the message." + }, + "message": { + "$ref": "#/definitions/v1Message", + "description": "A message from the agent." + } + }, + "description": "Represents the response for the `SendMessage` method." + }, + "v1StreamResponse": { + "type": "object", + "properties": { + "task": { + "$ref": "#/definitions/v1Task", + "description": "A Task object containing the current state of the task." + }, + "message": { + "$ref": "#/definitions/v1Message", + "description": "A Message object containing a message from the agent." + }, + "statusUpdate": { + "$ref": "#/definitions/v1TaskStatusUpdateEvent", + "description": "An event indicating a task status update." + }, + "artifactUpdate": { + "$ref": "#/definitions/v1TaskArtifactUpdateEvent", + "description": "An event indicating a task artifact update." + } + }, + "description": "A wrapper object used in streaming operations to encapsulate different types of response data." + }, + "v1StringList": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The individual string values." + } + }, + "description": "protolint:disable REPEATED_FIELD_NAMES_PLURALIZED\nA list of strings." + }, + "v1Task": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Unique identifier (e.g. UUID) for the task, generated by the server for a\nnew task." + }, + "contextId": { + "type": "string", + "description": "Unique identifier (e.g. UUID) for the contextual collection of interactions\n(tasks and messages)." + }, + "status": { + "$ref": "#/definitions/v1TaskStatus", + "description": "The current status of a `Task`, including `state` and a `message`." + }, + "artifacts": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Artifact" + }, + "description": "A set of output artifacts for a `Task`." + }, + "history": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Message" + }, + "description": "protolint:disable REPEATED_FIELD_NAMES_PLURALIZED\nThe history of interactions from a `Task`." + }, + "metadata": { + "type": "object", + "description": "protolint:enable REPEATED_FIELD_NAMES_PLURALIZED\nA key/value object to store custom metadata about a task." + } + }, + "description": "`Task` is the core unit of action for A2A. It has a current status\nand when results are created for the task they are stored in the\nartifact. If there are multiple turns for a task, these are stored in\nhistory.", + "required": [ + "id", + "status" + ] + }, + "v1TaskArtifactUpdateEvent": { + "type": "object", + "properties": { + "taskId": { + "type": "string", + "description": "The ID of the task for this artifact." + }, + "contextId": { + "type": "string", + "description": "The ID of the context that this task belongs to." + }, + "artifact": { + "$ref": "#/definitions/v1Artifact", + "description": "The artifact that was generated or updated." + }, + "append": { + "type": "boolean", + "description": "If true, the content of this artifact should be appended to a previously\nsent artifact with the same ID." + }, + "lastChunk": { + "type": "boolean", + "description": "If true, this is the final chunk of the artifact." + }, + "metadata": { + "type": "object", + "description": "Optional. Metadata associated with the artifact update." + } + }, + "description": "A task delta where an artifact has been generated.", + "required": [ + "taskId", + "contextId", + "artifact" + ] + }, + "v1TaskPushNotificationConfig": { + "type": "object", + "properties": { + "tenant": { + "type": "string", + "description": "Optional. Tenant ID." + }, + "id": { + "type": "string", + "description": "The push notification configuration details.\nA unique identifier (e.g. UUID) for this push notification configuration." + }, + "taskId": { + "type": "string", + "description": "The ID of the task this configuration is associated with." + }, + "url": { + "type": "string", + "description": "The URL where the notification should be sent." + }, + "token": { + "type": "string", + "description": "A token unique for this task or session." + }, + "authentication": { + "$ref": "#/definitions/v1AuthenticationInfo", + "description": "Authentication information required to send the notification." + } + }, + "description": "A container associating a push notification configuration with a specific task.", + "required": [ + "url" + ] + }, + "v1TaskState": { + "type": "string", + "enum": [ + "TASK_STATE_UNSPECIFIED", + "TASK_STATE_SUBMITTED", + "TASK_STATE_WORKING", + "TASK_STATE_COMPLETED", + "TASK_STATE_FAILED", + "TASK_STATE_CANCELED", + "TASK_STATE_INPUT_REQUIRED", + "TASK_STATE_REJECTED", + "TASK_STATE_AUTH_REQUIRED" + ], + "default": "TASK_STATE_UNSPECIFIED", + "description": "Defines the possible lifecycle states of a `Task`.\n\n - TASK_STATE_UNSPECIFIED: The task is in an unknown or indeterminate state.\n - TASK_STATE_SUBMITTED: Indicates that a task has been successfully submitted and acknowledged.\n - TASK_STATE_WORKING: Indicates that a task is actively being processed by the agent.\n - TASK_STATE_COMPLETED: Indicates that a task has finished successfully. This is a terminal state.\n - TASK_STATE_FAILED: Indicates that a task has finished with an error. This is a terminal state.\n - TASK_STATE_CANCELED: Indicates that a task was canceled before completion. This is a terminal state.\n - TASK_STATE_INPUT_REQUIRED: Indicates that the agent requires additional user input to proceed. This is an interrupted state.\n - TASK_STATE_REJECTED: Indicates that the agent has decided to not perform the task.\nThis may be done during initial task creation or later once an agent\nhas determined it can't or won't proceed. This is a terminal state.\n - TASK_STATE_AUTH_REQUIRED: Indicates that authentication is required to proceed. This is an interrupted state." + }, + "v1TaskStatus": { + "type": "object", + "properties": { + "state": { + "$ref": "#/definitions/v1TaskState", + "description": "The current state of this task." + }, + "message": { + "$ref": "#/definitions/v1Message", + "description": "A message associated with the status." + }, + "timestamp": { + "type": "string", + "format": "date-time", + "title": "ISO 8601 Timestamp when the status was recorded.\nExample: \"2023-10-27T10:00:00Z\"" + } + }, + "title": "A container for the status of a task", + "required": [ + "state" + ] + }, + "v1TaskStatusUpdateEvent": { + "type": "object", + "properties": { + "taskId": { + "type": "string", + "description": "The ID of the task that has changed." + }, + "contextId": { + "type": "string", + "description": "The ID of the context that the task belongs to." + }, + "status": { + "$ref": "#/definitions/v1TaskStatus", + "description": "The new status of the task." + }, + "metadata": { + "type": "object", + "description": "Optional. Metadata associated with the task update." + } + }, + "description": "An event sent by the agent to notify the client of a change in a task's status.", + "required": [ + "taskId", + "contextId", + "status" + ] + } + } +} From 96d6049c1579c7e1a2a3304390cdc119d8e73937 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 16 Mar 2026 14:52:19 +0000 Subject: [PATCH 26/28] fix spelling --- .github/actions/spelling/excludes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt index 89f938aaa..1538a2e70 100644 --- a/.github/actions/spelling/excludes.txt +++ b/.github/actions/spelling/excludes.txt @@ -89,6 +89,7 @@ CHANGELOG.md ^src/a2a/grpc/ ^src/a2a/types/ +^src/a2a/compat/v0_3/a2a_v0_3* ^tests/ .pre-commit-config.yaml (?:^|/)a2a\.json$ From 30338438efde888343092cedb756a28f9e048377 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 16 Mar 2026 15:09:37 +0000 Subject: [PATCH 27/28] exclude types from linter --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c7d673efb..5742b9c9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -285,6 +285,9 @@ exclude = [ "src/a2a/types/a2a_pb2.py", "src/a2a/types/a2a_pb2.pyi", "src/a2a/types/a2a_pb2_grpc.py", + "src/a2a/compat/v0_3/*_pb2.py", + "src/a2a/compat/v0_3/*_pb2.pyi", + "src/a2a/compat/v0_3/*_pb2_grpc.py", "tests/**", ] @@ -341,6 +344,9 @@ exclude = [ "src/a2a/types/a2a_pb2.py", "src/a2a/types/a2a_pb2.pyi", "src/a2a/types/a2a_pb2_grpc.py", + "src/a2a/compat/v0_3/*_pb2.py", + "src/a2a/compat/v0_3/*_pb2.pyi", + "src/a2a/compat/v0_3/*_pb2_grpc.py", ] docstring-code-format = true docstring-code-line-length = "dynamic" From 21885b8b513b02490f7be9a2d0da8d9489f64cd0 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 16 Mar 2026 15:10:58 +0000 Subject: [PATCH 28/28] remove buf --- .github/workflows/linter.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 7ae013f35..95fba28c5 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -22,8 +22,6 @@ jobs: - name: Add uv to PATH run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Install Buf - uses: bufbuild/buf-setup-action@v1 - name: Install dependencies run: uv sync --locked