From b3487352a86f113127c5b326407a793182154b24 Mon Sep 17 00:00:00 2001 From: Sam Betts <1769706+Tehsmash@users.noreply.github.com> Date: Thu, 20 Nov 2025 14:00:02 +0000 Subject: [PATCH] [DRAFT] feat: Upgrade A2A to v1.0 This updates the SDK to be A2A v1.0 compliant, all types are generated from the v1.0 a2a.proto. JSONRPC/HTTP+JSON transports are converted to use the a2a types encoded using ProtoJSON directly from the generated types. --- buf.gen.yaml | 8 +- pyproject.toml | 17 +- src/a2a/client/auth/interceptor.py | 2 +- src/a2a/client/base_client.py | 131 +- src/a2a/client/card_resolver.py | 5 +- src/a2a/client/client.py | 42 +- src/a2a/client/client_factory.py | 33 +- src/a2a/client/client_task_manager.py | 118 +- src/a2a/client/errors.py | 2 +- src/a2a/client/helpers.py | 2 +- src/a2a/client/legacy.py | 344 --- src/a2a/client/legacy_grpc.py | 44 - src/a2a/client/middleware.py | 2 +- src/a2a/client/transports/base.py | 47 +- src/a2a/client/transports/grpc.py | 122 +- src/a2a/client/transports/jsonrpc.py | 208 +- src/a2a/client/transports/rest.py | 168 +- src/a2a/extensions/common.py | 2 +- src/a2a/grpc/__init__.py | 0 src/a2a/grpc/a2a_pb2.py | 195 -- .../server/agent_execution/agent_executor.py | 2 +- src/a2a/server/agent_execution/context.py | 2 +- .../request_context_builder.py | 2 +- .../simple_request_context_builder.py | 2 +- src/a2a/server/apps/jsonrpc/fastapi_app.py | 2 +- src/a2a/server/apps/jsonrpc/jsonrpc_app.py | 2 +- src/a2a/server/apps/jsonrpc/starlette_app.py | 2 +- src/a2a/server/apps/rest/fastapi_app.py | 2 +- src/a2a/server/apps/rest/rest_adapter.py | 5 +- src/a2a/server/events/event_consumer.py | 14 +- src/a2a/server/events/event_queue.py | 2 +- src/a2a/server/models.py | 2 +- .../default_request_handler.py | 12 +- .../server/request_handlers/grpc_handler.py | 6 +- .../request_handlers/jsonrpc_handler.py | 2 +- .../request_handlers/request_handler.py | 2 +- .../request_handlers/response_helpers.py | 2 +- .../server/request_handlers/rest_handler.py | 4 +- .../tasks/base_push_notification_sender.py | 2 +- ...database_push_notification_config_store.py | 2 +- src/a2a/server/tasks/database_task_store.py | 2 +- ...inmemory_push_notification_config_store.py | 2 +- src/a2a/server/tasks/inmemory_task_store.py | 2 +- .../tasks/push_notification_config_store.py | 2 +- .../server/tasks/push_notification_sender.py | 2 +- src/a2a/server/tasks/result_aggregator.py | 4 +- src/a2a/server/tasks/task_manager.py | 4 +- src/a2a/server/tasks/task_store.py | 2 +- src/a2a/server/tasks/task_updater.py | 26 +- src/a2a/types.py | 2041 ----------------- src/a2a/types/a2a_pb2.py | 312 +++ src/a2a/{grpc => types}/a2a_pb2.pyi | 278 ++- src/a2a/{grpc => types}/a2a_pb2_grpc.py | 162 +- src/a2a/utils/artifact.py | 2 +- src/a2a/utils/error_handlers.py | 2 +- src/a2a/utils/errors.py | 2 +- src/a2a/utils/helpers.py | 4 +- src/a2a/utils/message.py | 2 +- src/a2a/utils/parts.py | 8 +- src/a2a/utils/proto_utils.py | 1066 --------- src/a2a/utils/task.py | 22 +- tests/client/test_auth_middleware.py | 2 +- tests/client/test_base_client.py | 8 +- tests/client/test_client_factory.py | 2 +- tests/client/test_client_task_manager.py | 12 +- tests/client/test_legacy_client.py | 6 +- tests/client/transports/test_grpc_client.py | 12 +- .../client/transports/test_jsonrpc_client.py | 2 +- tests/client/transports/test_rest_client.py | 2 +- tests/e2e/push_notifications/agent_app.py | 2 +- .../push_notifications/notifications_app.py | 2 +- .../test_default_push_notification_support.py | 4 +- tests/extensions/test_common.py | 2 +- .../test_client_server_integration.py | 14 +- tests/server/agent_execution/test_context.py | 2 +- .../test_simple_request_context_builder.py | 4 +- tests/server/apps/jsonrpc/test_fastapi_app.py | 2 +- tests/server/apps/jsonrpc/test_jsonrpc_app.py | 2 +- .../server/apps/jsonrpc/test_serialization.py | 2 +- .../server/apps/jsonrpc/test_starlette_app.py | 2 +- .../server/apps/rest/test_rest_fastapi_app.py | 6 +- tests/server/events/test_event_consumer.py | 6 +- tests/server/events/test_event_queue.py | 4 +- .../test_default_request_handler.py | 68 +- .../request_handlers/test_grpc_handler.py | 12 +- .../request_handlers/test_jsonrpc_handler.py | 14 +- .../request_handlers/test_response_helpers.py | 4 +- ...database_push_notification_config_store.py | 4 +- .../server/tasks/test_database_task_store.py | 26 +- .../tasks/test_inmemory_push_notifications.py | 9 +- .../server/tasks/test_inmemory_task_store.py | 2 +- .../tasks/test_push_notification_sender.py | 4 +- tests/server/tasks/test_result_aggregator.py | 24 +- tests/server/tasks/test_task_manager.py | 22 +- tests/server/tasks/test_task_updater.py | 56 +- tests/server/test_integration.py | 4 +- tests/server/test_models.py | 4 +- tests/test_types.py | 14 +- tests/utils/test_artifact.py | 2 +- tests/utils/test_error_handlers.py | 2 +- tests/utils/test_helpers.py | 6 +- tests/utils/test_message.py | 2 +- tests/utils/test_parts.py | 2 +- tests/utils/test_proto_utils.py | 10 +- tests/utils/test_task.py | 2 +- uv.lock | 13 +- 106 files changed, 1252 insertions(+), 4664 deletions(-) delete mode 100644 src/a2a/client/legacy.py delete mode 100644 src/a2a/client/legacy_grpc.py delete mode 100644 src/a2a/grpc/__init__.py delete mode 100644 src/a2a/grpc/a2a_pb2.py delete mode 100644 src/a2a/types.py create mode 100644 src/a2a/types/a2a_pb2.py rename src/a2a/{grpc => types}/a2a_pb2.pyi (54%) rename src/a2a/{grpc => types}/a2a_pb2_grpc.py (77%) delete mode 100644 src/a2a/utils/proto_utils.py diff --git a/buf.gen.yaml b/buf.gen.yaml index c70bf9e77..846c49d80 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -2,7 +2,7 @@ version: v2 inputs: - git_repo: https://github.com/a2aproject/A2A.git - ref: main + ref: transports subdir: specification/grpc managed: enabled: true @@ -21,11 +21,11 @@ plugins: # Generate python protobuf related code # Generates *_pb2.py files, one for each .proto - remote: buf.build/protocolbuffers/python:v29.3 - out: src/a2a/grpc + out: src/a2a/types # Generate python service code. # Generates *_pb2_grpc.py - remote: buf.build/grpc/python - out: src/a2a/grpc + out: src/a2a/types # Generates *_pb2.pyi files. - remote: buf.build/protocolbuffers/pyi - out: src/a2a/grpc + out: src/a2a/types diff --git a/pyproject.toml b/pyproject.toml index 46f7400a9..3937210af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ dependencies = [ "pydantic>=2.11.3", "protobuf>=5.29.5", "google-api-core>=1.26.0", + "json-rpc>=1.15.0", ] classifiers = [ @@ -114,7 +115,7 @@ explicit = true [tool.mypy] plugins = ["pydantic.mypy"] -exclude = ["src/a2a/grpc/"] +exclude = ["src/a2a/types/a2a_pb2\\.py", "src/a2a/types/a2a_pb2_grpc\\.py"] disable_error_code = [ "import-not-found", "annotation-unchecked", @@ -134,7 +135,8 @@ exclude = [ "**/node_modules", "**/venv", "**/.venv", - "src/a2a/grpc/", + "src/a2a/types/a2a_pb2.py", + "src/a2a/types/a2a_pb2_grpc.py", ] reportMissingImports = "none" reportMissingModuleSource = "none" @@ -145,7 +147,8 @@ omit = [ "*/tests/*", "*/site-packages/*", "*/__init__.py", - "src/a2a/grpc/*", + "src/a2a/types/a2a_pb2.py", + "src/a2a/types/a2a_pb2_grpc.py", ] [tool.coverage.report] @@ -257,7 +260,9 @@ exclude = [ "node_modules", "venv", "*/migrations/*", - "src/a2a/grpc/**", + "src/a2a/types/a2a_pb2.py", + "src/a2a/types/a2a_pb2.pyi", + "src/a2a/types/a2a_pb2_grpc.py", "tests/**", ] @@ -311,7 +316,9 @@ inline-quotes = "single" [tool.ruff.format] exclude = [ - "src/a2a/grpc/**", + "src/a2a/types/a2a_pb2.py", + "src/a2a/types/a2a_pb2.pyi", + "src/a2a/types/a2a_pb2_grpc.py", ] docstring-code-format = true docstring-code-line-length = "dynamic" diff --git a/src/a2a/client/auth/interceptor.py b/src/a2a/client/auth/interceptor.py index 65c971921..951babc02 100644 --- a/src/a2a/client/auth/interceptor.py +++ b/src/a2a/client/auth/interceptor.py @@ -3,7 +3,7 @@ from a2a.client.auth.credentials import CredentialService from a2a.client.middleware import ClientCallContext, ClientCallInterceptor -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCard, APIKeySecurityScheme, HTTPAuthSecurityScheme, diff --git a/src/a2a/client/base_client.py b/src/a2a/client/base_client.py index 5719bc1b0..6f85ac852 100644 --- a/src/a2a/client/base_client.py +++ b/src/a2a/client/base_client.py @@ -1,29 +1,33 @@ -from collections.abc import AsyncIterator +from collections.abc import AsyncIterator, AsyncGenerator from typing import Any from a2a.client.client import ( Client, ClientCallContext, ClientConfig, - ClientEvent, Consumer, + ClientEvent, ) from a2a.client.client_task_manager import ClientTaskManager from a2a.client.errors import A2AClientInvalidStateError from a2a.client.middleware import ClientCallInterceptor from a2a.client.transports.base import ClientTransport -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCard, - GetTaskPushNotificationConfigParams, Message, - MessageSendConfiguration, - MessageSendParams, + SendMessageConfiguration, + SendMessageRequest, Task, TaskArtifactUpdateEvent, - TaskIdParams, + SubscribeToTaskRequest, + CancelTaskRequest, TaskPushNotificationConfig, - TaskQueryParams, + GetTaskRequest, TaskStatusUpdateEvent, + StreamResponse, + SetTaskPushNotificationConfigRequest, + GetExtendedAgentCardRequest, + GetTaskPushNotificationConfigRequest, ) @@ -50,7 +54,7 @@ async def send_message( context: ClientCallContext | None = None, request_metadata: dict[str, Any] | None = None, extensions: list[str] | None = None, - ) -> AsyncIterator[ClientEvent | Message]: + ) -> AsyncIterator[ClientEvent]: """Sends a message to the agent. This method handles both streaming and non-streaming (polling) interactions @@ -64,9 +68,9 @@ async def send_message( extensions: List of extensions to be activated. Yields: - An async iterator of `ClientEvent` or a final `Message` response. + An async iterator of `ClientEvent` """ - config = MessageSendConfiguration( + config = SendMessageConfiguration( accepted_output_modes=self._config.accepted_output_modes, blocking=not self._config.polling, push_notification_config=( @@ -75,59 +79,59 @@ async def send_message( else None ), ) - params = MessageSendParams( - message=request, configuration=config, metadata=request_metadata + sendMessageRequest = SendMessageRequest( + request=request, configuration=config, metadata=request_metadata ) if not self._config.streaming or not self._card.capabilities.streaming: response = await self._transport.send_message( - params, context=context, extensions=extensions - ) - result = ( - (response, None) if isinstance(response, Task) else response + sendMessageRequest, context=context, extensions=extensions ) - await self.consume(result, self._card) - yield result - return - tracker = ClientTaskManager() - stream = self._transport.send_message_streaming( - params, context=context, extensions=extensions - ) + # 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"): + stream_response.task = response.task + client_event = (stream_response, response.task) - first_event = await anext(stream) - # The response from a server may be either exactly one Message or a - # series of Task updates. Separate out the first message for special - # case handling, which allows us to simplify further stream processing. - if isinstance(first_event, Message): - await self.consume(first_event, self._card) - yield first_event - return + elif response.HasField("message"): + stream_response.msg = response.msg + client_event = (stream_response, None) - yield await self._process_response(tracker, first_event) + await self.consume(client_event, self._card) + yield client_event + return - async for event in stream: - yield await self._process_response(tracker, event) + stream = self._transport.send_message_streaming( + sendMessageRequest, context=context, extensions=extensions + ) + async for client_event in self._process_stream(stream): + yield client_event - async def _process_response( - self, - tracker: ClientTaskManager, - event: Task | Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, - ) -> ClientEvent: - if isinstance(event, Message): - raise A2AClientInvalidStateError( - 'received a streamed Message from server after first response; this is not supported' - ) - await tracker.process(event) - task = tracker.get_task_or_raise() - update = None if isinstance(event, Task) else event - client_event = (task, update) - await self.consume(client_event, self._card) - return client_event + async def _process_stream(self, stream: AsyncIterator[StreamResponse]) -> AsyncGenerator[ClientEvent]: + tracker = ClientTaskManager() + async for stream_response in stream: + 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) + 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) + updated_task = tracker.get_task_or_raise() + client_event = (stream_response, updated_task) + await self.consume(client_event, self._card) + yield client_event async def get_task( self, - request: TaskQueryParams, + request: GetTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -135,7 +139,7 @@ async def get_task( """Retrieves the current state and history of a specific task. Args: - request: The `TaskQueryParams` object specifying the task ID. + request: The `GetTaskRequest` object specifying the task ID. context: The client call context. extensions: List of extensions to be activated. @@ -148,7 +152,7 @@ async def get_task( async def cancel_task( self, - request: TaskIdParams, + request: CancelTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -156,7 +160,7 @@ async def cancel_task( """Requests the agent to cancel a specific task. Args: - request: The `TaskIdParams` object specifying the task ID. + request: The `CancelTaskRequest` object specifying the task ID. context: The client call context. extensions: List of extensions to be activated. @@ -169,7 +173,7 @@ async def cancel_task( async def set_task_callback( self, - request: TaskPushNotificationConfig, + request: SetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -190,7 +194,7 @@ async def set_task_callback( async def get_task_callback( self, - request: GetTaskPushNotificationConfigParams, + request: GetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -209,9 +213,9 @@ async def get_task_callback( request, context=context, extensions=extensions ) - async def resubscribe( + async def subscribe( self, - request: TaskIdParams, + request: SubscribeToTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -240,12 +244,13 @@ async def resubscribe( # 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. - async for event in self._transport.resubscribe( + stream = self._transport.subscribe( request, context=context, extensions=extensions - ): - yield await self._process_response(tracker, event) + ) + async for client_event in self._process_stream(stream): + yield client_event - async def get_card( + async def get_extended_agent_card( self, *, context: ClientCallContext | None = None, @@ -263,7 +268,7 @@ async def get_card( Returns: The `AgentCard` for the agent. """ - card = await self._transport.get_card( + card = await self._transport.get_extended_agent_card( context=context, extensions=extensions ) self._card = card diff --git a/src/a2a/client/card_resolver.py b/src/a2a/client/card_resolver.py index f13fe3ab6..921cce383 100644 --- a/src/a2a/client/card_resolver.py +++ b/src/a2a/client/card_resolver.py @@ -7,11 +7,12 @@ from pydantic import ValidationError +from google.protobuf.json_format import ParseDict from a2a.client.errors import ( A2AClientHTTPError, A2AClientJSONError, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCard, ) from a2a.utils.constants import AGENT_CARD_WELL_KNOWN_PATH @@ -85,7 +86,7 @@ async def get_agent_card( target_url, agent_card_data, ) - agent_card = AgentCard.model_validate(agent_card_data) + agent_card = ParseDict(agent_card_data, AgentCard()) except httpx.HTTPStatusError as e: raise A2AClientHTTPError( e.response.status_code, diff --git a/src/a2a/client/client.py b/src/a2a/client/client.py index fd97b4d14..4d6788988 100644 --- a/src/a2a/client/client.py +++ b/src/a2a/client/client.py @@ -9,18 +9,21 @@ from a2a.client.middleware import ClientCallContext, ClientCallInterceptor from a2a.client.optionals import Channel -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCard, - GetTaskPushNotificationConfigParams, Message, PushNotificationConfig, Task, TaskArtifactUpdateEvent, - TaskIdParams, TaskPushNotificationConfig, - TaskQueryParams, TaskStatusUpdateEvent, - TransportProtocol, + StreamResponse, + SendMessageRequest, + GetTaskRequest, + CancelTaskRequest, + SetTaskPushNotificationConfigRequest, + GetTaskPushNotificationConfigRequest, + SubscribeToTaskRequest, ) @@ -45,7 +48,7 @@ class ClientConfig: grpc_channel_factory: Callable[[str], Channel] | None = None """Generates a grpc connection channel for a given url.""" - supported_transports: list[TransportProtocol | str] = dataclasses.field( + supported_protocol_bindings: list[str] = dataclasses.field( default_factory=list ) """Ordered list of transports for connecting to agent @@ -71,14 +74,11 @@ class ClientConfig: """A list of extension URIs the client supports.""" -UpdateEvent = TaskStatusUpdateEvent | TaskArtifactUpdateEvent | None -# Alias for emitted events from client -ClientEvent = tuple[Task, UpdateEvent] +ClientEvent = tuple[StreamResponse, Task | None] + # Alias for an event consuming callback. It takes either a (task, update) pair # or a message as well as the agent card for the agent this came from. -Consumer = Callable[ - [ClientEvent | Message, AgentCard], Coroutine[None, Any, Any] -] +Consumer = Callable[[ClientEvent, AgentCard], Coroutine[None, Any, Any]] class Client(ABC): @@ -115,7 +115,7 @@ async def send_message( context: ClientCallContext | None = None, request_metadata: dict[str, Any] | None = None, extensions: list[str] | None = None, - ) -> AsyncIterator[ClientEvent | Message]: + ) -> AsyncIterator[ClientEvent]: """Sends a message to the server. This will automatically use the streaming or non-streaming approach @@ -130,7 +130,7 @@ async def send_message( @abstractmethod async def get_task( self, - request: TaskQueryParams, + request: GetTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -140,7 +140,7 @@ async def get_task( @abstractmethod async def cancel_task( self, - request: TaskIdParams, + request: CancelTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -150,7 +150,7 @@ async def cancel_task( @abstractmethod async def set_task_callback( self, - request: TaskPushNotificationConfig, + request: SetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -160,7 +160,7 @@ async def set_task_callback( @abstractmethod async def get_task_callback( self, - request: GetTaskPushNotificationConfigParams, + request: GetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -168,9 +168,9 @@ async def get_task_callback( """Retrieves the push notification configuration for a specific task.""" @abstractmethod - async def resubscribe( + async def subscribe( self, - request: TaskIdParams, + request: SubscribeToTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -180,7 +180,7 @@ async def resubscribe( yield @abstractmethod - async def get_card( + async def get_extended_agent_card( self, *, context: ClientCallContext | None = None, @@ -200,7 +200,7 @@ async def add_request_middleware( async def consume( self, - event: tuple[Task, UpdateEvent] | Message | None, + event: ClientEvent, card: AgentCard, ) -> None: """Processes the event via all the registered `Consumer`s.""" diff --git a/src/a2a/client/client_factory.py b/src/a2a/client/client_factory.py index fabd7270f..2ae67885d 100644 --- a/src/a2a/client/client_factory.py +++ b/src/a2a/client/client_factory.py @@ -14,13 +14,16 @@ from a2a.client.transports.base import ClientTransport from a2a.client.transports.jsonrpc import JsonRpcTransport from a2a.client.transports.rest import RestTransport -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCapabilities, AgentCard, AgentInterface, - TransportProtocol, ) +TRANSPORT_PROTOCOLS_JSONRPC = 'JSONRPC' +TRANSPORT_PROTOCOLS_GRPC = 'GRPC' +TRANSPORT_PROTOCOLS_HTTP_JSON = 'HTTP+JSON' + try: from a2a.client.transports.grpc import GrpcTransport @@ -66,15 +69,15 @@ def __init__( self._config = config self._consumers = consumers self._registry: dict[str, TransportProducer] = {} - self._register_defaults(config.supported_transports) + self._register_defaults(config.supported_protocol_bindings) def _register_defaults( - self, supported: list[str | TransportProtocol] + self, supported: list[str] ) -> None: # Empty support list implies JSON-RPC only. - if TransportProtocol.jsonrpc in supported or not supported: + if TRANSPORT_PROTOCOLS_JSONRPC in supported or not supported: self.register( - TransportProtocol.jsonrpc, + TRANSPORT_PROTOCOLS_JSONRPC, lambda card, url, config, interceptors: JsonRpcTransport( config.httpx_client or httpx.AsyncClient(), card, @@ -83,9 +86,9 @@ def _register_defaults( config.extensions or None, ), ) - if TransportProtocol.http_json in supported: + if TRANSPORT_PROTOCOLS_HTTP_JSON in supported: self.register( - TransportProtocol.http_json, + TRANSPORT_PROTOCOLS_HTTP_JSON, lambda card, url, config, interceptors: RestTransport( config.httpx_client or httpx.AsyncClient(), card, @@ -94,14 +97,14 @@ def _register_defaults( config.extensions or None, ), ) - if TransportProtocol.grpc in supported: + if TRANSPORT_PROTOCOLS_GRPC in supported: if GrpcTransport is None: raise ImportError( 'To use GrpcClient, its dependencies must be installed. ' 'You can install them with \'pip install "a2a-sdk[grpc]"\'' ) self.register( - TransportProtocol.grpc, + TRANSPORT_PROTOCOLS_GRPC, GrpcTransport.create, ) @@ -200,14 +203,14 @@ def create( If there is no valid matching of the client configuration with the server configuration, a `ValueError` is raised. """ - server_preferred = card.preferred_transport or TransportProtocol.jsonrpc + server_preferred = card.preferred_transport or TRANSPORT_PROTOCOLS_JSONRPC server_set = {server_preferred: card.url} if card.additional_interfaces: server_set.update( - {x.transport: x.url for x in card.additional_interfaces} + {x.protocol_binding: x.url for x in card.additional_interfaces} ) - client_set = self._config.supported_transports or [ - TransportProtocol.jsonrpc + client_set = self._config.supported_protocol_bindings or [ + TRANSPORT_PROTOCOLS_JSONRPC ] transport_protocol = None transport_url = None @@ -267,7 +270,7 @@ def minimal_agent_card( url=url, preferred_transport=transports[0] if transports else None, additional_interfaces=[ - AgentInterface(transport=t, url=url) for t in transports[1:] + AgentInterface(protocol_binding=t, url=url) for t in transports[1:] ] if len(transports) > 1 else [], diff --git a/src/a2a/client/client_task_manager.py b/src/a2a/client/client_task_manager.py index 060983e13..a107ea994 100644 --- a/src/a2a/client/client_task_manager.py +++ b/src/a2a/client/client_task_manager.py @@ -5,13 +5,14 @@ A2AClientInvalidStateError, ) from a2a.server.events.event_queue import Event -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Message, Task, TaskArtifactUpdateEvent, TaskState, TaskStatus, TaskStatusUpdateEvent, + StreamResponse, ) from a2a.utils import append_artifact_to_task @@ -66,8 +67,8 @@ def get_task_or_raise(self) -> Task: raise A2AClientInvalidStateError('no current Task') return task - async def save_task_event( - self, event: Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent + async def process( + self, event: StreamResponse, ) -> Task | None: """Processes a task-related event (Task, Status, Artifact) and saves the updated task state. @@ -83,74 +84,58 @@ async def save_task_event( ClientError: If the task ID in the event conflicts with the TaskManager's ID when the TaskManager's ID is already set. """ - if isinstance(event, Task): + if event.HasField('message'): + # Messages are not processed here. + return None + + if event.HasField('task'): if self._current_task: raise A2AClientInvalidArgsError( 'Task is already set, create new manager for new tasks.' ) - await self._save_task(event) - return event - task_id_from_event = ( - event.id if isinstance(event, Task) else event.task_id - ) - if not self._task_id: - self._task_id = task_id_from_event - if not self._context_id: - self._context_id = event.context_id - - logger.debug( - 'Processing save of task event of type %s for task_id: %s', - type(event).__name__, - task_id_from_event, - ) + await self._save_task(event.task) + return event.task task = self._current_task - if not task: - task = Task( - status=TaskStatus(state=TaskState.unknown), - id=task_id_from_event, - context_id=self._context_id if self._context_id else '', - ) - if isinstance(event, TaskStatusUpdateEvent): + + if event.HasField('status_update'): + status_update = event.status_update + if not task: + task = Task( + status=TaskStatus(state=TaskState.TASK_STATE_UNSPECIFIED), + id=status_update.task_id, + context_id=status_update.context_id, + ) + logger.debug( 'Updating task %s status to: %s', - event.task_id, - event.status.state, + status_update.task_id, + status_update.status.state, ) - if event.status.message: - if not task.history: - task.history = [event.status.message] - else: - task.history.append(event.status.message) - if event.metadata: - if not task.metadata: - task.metadata = {} - task.metadata.update(event.metadata) - task.status = event.status - else: - logger.debug('Appending artifact to task %s', task.id) - append_artifact_to_task(task, event) - self._current_task = task - return task - - async def process(self, event: Event) -> Event: - """Processes an event, updates the task state if applicable, stores it, and returns the event. - - If the event is task-related (`Task`, `TaskStatusUpdateEvent`, `TaskArtifactUpdateEvent`), - the internal task state is updated and persisted. - - Args: - event: The event object received from the agent. + if status_update.status.message: + # "Repeated" fields are merged by appending. + task.history.MergeFrom([status_update.status.message]) + + if status_update.metadata: + task.metadata.MergeFrom(status_update.metadata) + + task.status = status_update.status + await self._save_task(task) + + if event.HasField('artifact_update'): + artifact_update = event.artifact_update + if not task: + task = Task( + status=TaskStatus(state=TaskState.TASK_STATE_UNSPECIFIED), + id=artifact_update.task_id, + context_id=artifact_update.context_id, + ) - Returns: - The same event object that was processed. - """ - if isinstance( - event, Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent - ): - await self.save_task_event(event) + logger.debug('Appending artifact to task %s', task.id) + append_artifact_to_task(task, artifact_update) + await self._save_task(task) - return event + return self._current_task async def _save_task(self, task: Task) -> None: """Saves the given task to the `_current_task` and updated `_task_id` and `_context_id`. @@ -179,14 +164,9 @@ def update_with_message(self, message: Message, task: Task) -> Task: The updated `Task` object (updated in-place). """ if task.status.message: - if task.history: - task.history.append(task.status.message) - else: - task.history = [task.status.message] - task.status.message = None - if task.history: - task.history.append(message) - else: - task.history = [message] + task.history.MergeFrom([task.status.message]) + task.status.ClearField('message') + + task.history.MergeFrom([message]) self._current_task = task return task diff --git a/src/a2a/client/errors.py b/src/a2a/client/errors.py index 890c3726a..f15422133 100644 --- a/src/a2a/client/errors.py +++ b/src/a2a/client/errors.py @@ -1,6 +1,6 @@ """Custom exceptions for the A2A client.""" -from a2a.types import JSONRPCErrorResponse +from a2a.types.a2a_pb2 import JSONRPCErrorResponse class A2AClientError(Exception): diff --git a/src/a2a/client/helpers.py b/src/a2a/client/helpers.py index 930c71e6b..57e5d52ce 100644 --- a/src/a2a/client/helpers.py +++ b/src/a2a/client/helpers.py @@ -2,7 +2,7 @@ from uuid import uuid4 -from a2a.types import Message, Part, Role, TextPart +from a2a.types.a2a_pb2 import Message, Part, Role, TextPart def create_text_message_object( diff --git a/src/a2a/client/legacy.py b/src/a2a/client/legacy.py deleted file mode 100644 index 4318543d6..000000000 --- a/src/a2a/client/legacy.py +++ /dev/null @@ -1,344 +0,0 @@ -"""Backwards compatibility layer for legacy A2A clients.""" - -import warnings - -from collections.abc import AsyncGenerator -from typing import Any - -import httpx - -from a2a.client.errors import A2AClientJSONRPCError -from a2a.client.middleware import ClientCallContext, ClientCallInterceptor -from a2a.client.transports.jsonrpc import JsonRpcTransport -from a2a.types import ( - AgentCard, - CancelTaskRequest, - CancelTaskResponse, - CancelTaskSuccessResponse, - GetTaskPushNotificationConfigParams, - GetTaskPushNotificationConfigRequest, - GetTaskPushNotificationConfigResponse, - GetTaskPushNotificationConfigSuccessResponse, - GetTaskRequest, - GetTaskResponse, - GetTaskSuccessResponse, - JSONRPCErrorResponse, - SendMessageRequest, - SendMessageResponse, - SendMessageSuccessResponse, - SendStreamingMessageRequest, - SendStreamingMessageResponse, - SendStreamingMessageSuccessResponse, - SetTaskPushNotificationConfigRequest, - SetTaskPushNotificationConfigResponse, - SetTaskPushNotificationConfigSuccessResponse, - TaskIdParams, - TaskResubscriptionRequest, -) - - -class A2AClient: - """[DEPRECATED] Backwards compatibility wrapper for the JSON-RPC client.""" - - def __init__( - self, - httpx_client: httpx.AsyncClient, - agent_card: AgentCard | None = None, - url: str | None = None, - interceptors: list[ClientCallInterceptor] | None = None, - ): - warnings.warn( - 'A2AClient is deprecated and will be removed in a future version. ' - 'Use ClientFactory to create a client with a JSON-RPC transport.', - DeprecationWarning, - stacklevel=2, - ) - self._transport = JsonRpcTransport( - httpx_client, agent_card, url, interceptors - ) - - async def send_message( - self, - request: SendMessageRequest, - *, - http_kwargs: dict[str, Any] | None = None, - context: ClientCallContext | None = None, - ) -> SendMessageResponse: - """Sends a non-streaming message request to the agent. - - Args: - request: The `SendMessageRequest` object containing the message and configuration. - http_kwargs: Optional dictionary of keyword arguments to pass to the - underlying httpx.post request. - context: The client call context. - - Returns: - A `SendMessageResponse` object containing the agent's response (Task or Message) or an error. - - Raises: - A2AClientHTTPError: If an HTTP error occurs during the request. - A2AClientJSONError: If the response body cannot be decoded as JSON or validated. - """ - if not context and http_kwargs: - context = ClientCallContext(state={'http_kwargs': http_kwargs}) - - try: - result = await self._transport.send_message( - request.params, context=context - ) - return SendMessageResponse( - root=SendMessageSuccessResponse( - id=request.id, jsonrpc='2.0', result=result - ) - ) - except A2AClientJSONRPCError as e: - return SendMessageResponse(JSONRPCErrorResponse(error=e.error)) - - async def send_message_streaming( - self, - request: SendStreamingMessageRequest, - *, - http_kwargs: dict[str, Any] | None = None, - context: ClientCallContext | None = None, - ) -> AsyncGenerator[SendStreamingMessageResponse, None]: - """Sends a streaming message request to the agent and yields responses as they arrive. - - This method uses Server-Sent Events (SSE) to receive a stream of updates from the agent. - - Args: - request: The `SendStreamingMessageRequest` object containing the message and configuration. - http_kwargs: Optional dictionary of keyword arguments to pass to the - underlying httpx.post request. A default `timeout=None` is set but can be overridden. - context: The client call context. - - Yields: - `SendStreamingMessageResponse` objects as they are received in the SSE stream. - These can be Task, Message, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent. - - Raises: - A2AClientHTTPError: If an HTTP or SSE protocol error occurs during the request. - A2AClientJSONError: If an SSE event data cannot be decoded as JSON or validated. - """ - if not context and http_kwargs: - context = ClientCallContext(state={'http_kwargs': http_kwargs}) - - async for result in self._transport.send_message_streaming( - request.params, context=context - ): - yield SendStreamingMessageResponse( - root=SendStreamingMessageSuccessResponse( - id=request.id, jsonrpc='2.0', result=result - ) - ) - - async def get_task( - self, - request: GetTaskRequest, - *, - http_kwargs: dict[str, Any] | None = None, - context: ClientCallContext | None = None, - ) -> GetTaskResponse: - """Retrieves the current state and history of a specific task. - - Args: - request: The `GetTaskRequest` object specifying the task ID and history length. - http_kwargs: Optional dictionary of keyword arguments to pass to the - underlying httpx.post request. - context: The client call context. - - Returns: - A `GetTaskResponse` object containing the Task or an error. - - Raises: - A2AClientHTTPError: If an HTTP error occurs during the request. - A2AClientJSONError: If the response body cannot be decoded as JSON or validated. - """ - if not context and http_kwargs: - context = ClientCallContext(state={'http_kwargs': http_kwargs}) - try: - result = await self._transport.get_task( - request.params, context=context - ) - return GetTaskResponse( - root=GetTaskSuccessResponse( - id=request.id, jsonrpc='2.0', result=result - ) - ) - except A2AClientJSONRPCError as e: - return GetTaskResponse(root=JSONRPCErrorResponse(error=e.error)) - - async def cancel_task( - self, - request: CancelTaskRequest, - *, - http_kwargs: dict[str, Any] | None = None, - context: ClientCallContext | None = None, - ) -> CancelTaskResponse: - """Requests the agent to cancel a specific task. - - Args: - request: The `CancelTaskRequest` object specifying the task ID. - http_kwargs: Optional dictionary of keyword arguments to pass to the - underlying httpx.post request. - context: The client call context. - - Returns: - A `CancelTaskResponse` object containing the updated Task with canceled status or an error. - - Raises: - A2AClientHTTPError: If an HTTP error occurs during the request. - A2AClientJSONError: If the response body cannot be decoded as JSON or validated. - """ - if not context and http_kwargs: - context = ClientCallContext(state={'http_kwargs': http_kwargs}) - try: - result = await self._transport.cancel_task( - request.params, context=context - ) - return CancelTaskResponse( - root=CancelTaskSuccessResponse( - id=request.id, jsonrpc='2.0', result=result - ) - ) - except A2AClientJSONRPCError as e: - return CancelTaskResponse(JSONRPCErrorResponse(error=e.error)) - - async def set_task_callback( - self, - request: SetTaskPushNotificationConfigRequest, - *, - http_kwargs: dict[str, Any] | None = None, - context: ClientCallContext | None = None, - ) -> SetTaskPushNotificationConfigResponse: - """Sets or updates the push notification configuration for a specific task. - - Args: - request: The `SetTaskPushNotificationConfigRequest` object specifying the task ID and configuration. - http_kwargs: Optional dictionary of keyword arguments to pass to the - underlying httpx.post request. - context: The client call context. - - Returns: - A `SetTaskPushNotificationConfigResponse` object containing the confirmation or an error. - - Raises: - A2AClientHTTPError: If an HTTP error occurs during the request. - A2AClientJSONError: If the response body cannot be decoded as JSON or validated. - """ - if not context and http_kwargs: - context = ClientCallContext(state={'http_kwargs': http_kwargs}) - try: - result = await self._transport.set_task_callback( - request.params, context=context - ) - return SetTaskPushNotificationConfigResponse( - root=SetTaskPushNotificationConfigSuccessResponse( - id=request.id, jsonrpc='2.0', result=result - ) - ) - except A2AClientJSONRPCError as e: - return SetTaskPushNotificationConfigResponse( - JSONRPCErrorResponse(error=e.error) - ) - - async def get_task_callback( - self, - request: GetTaskPushNotificationConfigRequest, - *, - http_kwargs: dict[str, Any] | None = None, - context: ClientCallContext | None = None, - ) -> GetTaskPushNotificationConfigResponse: - """Retrieves the push notification configuration for a specific task. - - Args: - request: The `GetTaskPushNotificationConfigRequest` object specifying the task ID. - http_kwargs: Optional dictionary of keyword arguments to pass to the - underlying httpx.post request. - context: The client call context. - - Returns: - A `GetTaskPushNotificationConfigResponse` object containing the configuration or an error. - - Raises: - A2AClientHTTPError: If an HTTP error occurs during the request. - A2AClientJSONError: If the response body cannot be decoded as JSON or validated. - """ - if not context and http_kwargs: - context = ClientCallContext(state={'http_kwargs': http_kwargs}) - params = request.params - if isinstance(params, TaskIdParams): - params = GetTaskPushNotificationConfigParams(id=request.params.id) - try: - result = await self._transport.get_task_callback( - params, context=context - ) - return GetTaskPushNotificationConfigResponse( - root=GetTaskPushNotificationConfigSuccessResponse( - id=request.id, jsonrpc='2.0', result=result - ) - ) - except A2AClientJSONRPCError as e: - return GetTaskPushNotificationConfigResponse( - JSONRPCErrorResponse(error=e.error) - ) - - async def resubscribe( - self, - request: TaskResubscriptionRequest, - *, - http_kwargs: dict[str, Any] | None = None, - context: ClientCallContext | None = None, - ) -> AsyncGenerator[SendStreamingMessageResponse, None]: - """Reconnects to get task updates. - - This method uses Server-Sent Events (SSE) to receive a stream of updates from the agent. - - Args: - request: The `TaskResubscriptionRequest` object containing the task information to reconnect to. - http_kwargs: Optional dictionary of keyword arguments to pass to the - underlying httpx.post request. A default `timeout=None` is set but can be overridden. - context: The client call context. - - Yields: - `SendStreamingMessageResponse` objects as they are received in the SSE stream. - These can be Task, Message, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent. - - Raises: - A2AClientHTTPError: If an HTTP or SSE protocol error occurs during the request. - A2AClientJSONError: If an SSE event data cannot be decoded as JSON or validated. - """ - if not context and http_kwargs: - context = ClientCallContext(state={'http_kwargs': http_kwargs}) - - async for result in self._transport.resubscribe( - request.params, context=context - ): - yield SendStreamingMessageResponse( - root=SendStreamingMessageSuccessResponse( - id=request.id, jsonrpc='2.0', result=result - ) - ) - - async def get_card( - self, - *, - http_kwargs: dict[str, Any] | None = None, - context: ClientCallContext | None = None, - ) -> AgentCard: - """Retrieves the authenticated card (if necessary) or the public one. - - Args: - http_kwargs: Optional dictionary of keyword arguments to pass to the - underlying httpx.post request. - context: The client call context. - - Returns: - A `AgentCard` object containing the card or an error. - - Raises: - A2AClientHTTPError: If an HTTP error occurs during the request. - A2AClientJSONError: If the response body cannot be decoded as JSON or validated. - """ - if not context and http_kwargs: - context = ClientCallContext(state={'http_kwargs': http_kwargs}) - return await self._transport.get_card(context=context) diff --git a/src/a2a/client/legacy_grpc.py b/src/a2a/client/legacy_grpc.py deleted file mode 100644 index 0b62b0096..000000000 --- a/src/a2a/client/legacy_grpc.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Backwards compatibility layer for the legacy A2A gRPC client.""" - -import warnings - -from typing import TYPE_CHECKING - -from a2a.client.transports.grpc import GrpcTransport -from a2a.types import AgentCard - - -if TYPE_CHECKING: - from a2a.grpc.a2a_pb2_grpc import A2AServiceStub - - -class A2AGrpcClient(GrpcTransport): - """[DEPRECATED] Backwards compatibility wrapper for the gRPC client.""" - - def __init__( # pylint: disable=super-init-not-called - self, - grpc_stub: 'A2AServiceStub', - agent_card: AgentCard, - ): - warnings.warn( - 'A2AGrpcClient is deprecated and will be removed in a future version. ' - 'Use ClientFactory to create a client with a gRPC transport.', - DeprecationWarning, - stacklevel=2, - ) - # The old gRPC client accepted a stub directly. The new one accepts a - # channel and builds the stub itself. We just have a stub here, so we - # need to handle initialization ourselves. - self.stub = grpc_stub - self.agent_card = agent_card - self._needs_extended_card = ( - agent_card.supports_authenticated_extended_card - if agent_card - else True - ) - - class _NopChannel: - async def close(self) -> None: - pass - - self.channel = _NopChannel() diff --git a/src/a2a/client/middleware.py b/src/a2a/client/middleware.py index 73ada982f..c9e1d1927 100644 --- a/src/a2a/client/middleware.py +++ b/src/a2a/client/middleware.py @@ -8,7 +8,7 @@ if TYPE_CHECKING: - from a2a.types import AgentCard + from a2a.types.a2a_pb2 import AgentCard class ClientCallContext(BaseModel): diff --git a/src/a2a/client/transports/base.py b/src/a2a/client/transports/base.py index 8f114d95d..d2751cc18 100644 --- a/src/a2a/client/transports/base.py +++ b/src/a2a/client/transports/base.py @@ -2,17 +2,18 @@ from collections.abc import AsyncGenerator from a2a.client.middleware import ClientCallContext -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCard, - GetTaskPushNotificationConfigParams, - Message, - MessageSendParams, + CancelTaskRequest, + GetTaskPushNotificationConfigRequest, + GetTaskRequest, + SendMessageRequest, + SendMessageResponse, + SetTaskPushNotificationConfigRequest, + StreamResponse, + SubscribeToTaskRequest, Task, - TaskArtifactUpdateEvent, - TaskIdParams, TaskPushNotificationConfig, - TaskQueryParams, - TaskStatusUpdateEvent, ) @@ -22,23 +23,21 @@ class ClientTransport(ABC): @abstractmethod async def send_message( self, - request: MessageSendParams, + request: SendMessageRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> Task | Message: + ) -> SendMessageResponse: """Sends a non-streaming message request to the agent.""" @abstractmethod async def send_message_streaming( self, - request: MessageSendParams, + request: SendMessageRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> AsyncGenerator[ - Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent - ]: + ) -> AsyncGenerator[StreamResponse]: """Sends a streaming message request to the agent and yields responses as they arrive.""" return yield @@ -46,7 +45,7 @@ async def send_message_streaming( @abstractmethod async def get_task( self, - request: TaskQueryParams, + request: GetTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -56,7 +55,7 @@ async def get_task( @abstractmethod async def cancel_task( self, - request: TaskIdParams, + request: CancelTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -66,7 +65,7 @@ async def cancel_task( @abstractmethod async def set_task_callback( self, - request: TaskPushNotificationConfig, + request: SetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -76,7 +75,7 @@ async def set_task_callback( @abstractmethod async def get_task_callback( self, - request: GetTaskPushNotificationConfigParams, + request: GetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, @@ -84,27 +83,25 @@ async def get_task_callback( """Retrieves the push notification configuration for a specific task.""" @abstractmethod - async def resubscribe( + async def subscribe( self, - request: TaskIdParams, + request: SubscribeToTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> AsyncGenerator[ - Task | Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent - ]: + ) -> AsyncGenerator[StreamResponse]: """Reconnects to get task updates.""" return yield @abstractmethod - async def get_card( + async def get_extended_agent_card( self, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> AgentCard: - """Retrieves the AgentCard.""" + """Retrieves the Extended AgentCard.""" @abstractmethod async def close(self) -> None: diff --git a/src/a2a/client/transports/grpc.py b/src/a2a/client/transports/grpc.py index 4e27953af..f1c5b108f 100644 --- a/src/a2a/client/transports/grpc.py +++ b/src/a2a/client/transports/grpc.py @@ -18,20 +18,20 @@ from a2a.client.optionals import Channel from a2a.client.transports.base import ClientTransport from a2a.extensions.common import HTTP_EXTENSION_HEADER -from a2a.grpc import a2a_pb2, a2a_pb2_grpc -from a2a.types import ( +from a2a.types import a2a_pb2, a2a_pb2_grpc +from a2a.types.a2a_pb2 import ( AgentCard, - GetTaskPushNotificationConfigParams, - Message, - MessageSendParams, + CancelTaskRequest, + GetTaskPushNotificationConfigRequest, + GetTaskRequest, + SendMessageRequest, + SendMessageResponse, + SetTaskPushNotificationConfigRequest, + StreamResponse, + SubscribeToTaskRequest, Task, - TaskArtifactUpdateEvent, - TaskIdParams, TaskPushNotificationConfig, - TaskQueryParams, - TaskStatusUpdateEvent, ) -from a2a.utils import proto_utils from a2a.utils.telemetry import SpanKind, trace_class @@ -85,160 +85,116 @@ def create( async def send_message( self, - request: MessageSendParams, + request: SendMessageRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> Task | Message: + ) -> SendMessageResponse: """Sends a non-streaming message request to the agent.""" - response = await self.stub.SendMessage( - a2a_pb2.SendMessageRequest( - request=proto_utils.ToProto.message(request.message), - configuration=proto_utils.ToProto.message_send_configuration( - request.configuration - ), - metadata=proto_utils.ToProto.metadata(request.metadata), - ), + return await self.stub.SendMessage( + request, metadata=self._get_grpc_metadata(extensions), ) - if response.HasField('task'): - return proto_utils.FromProto.task(response.task) - return proto_utils.FromProto.message(response.msg) async def send_message_streaming( self, - request: MessageSendParams, + request: SendMessageRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> AsyncGenerator[ - Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent - ]: + ) -> AsyncGenerator[StreamResponse]: """Sends a streaming message request to the agent and yields responses as they arrive.""" stream = self.stub.SendStreamingMessage( - a2a_pb2.SendMessageRequest( - request=proto_utils.ToProto.message(request.message), - configuration=proto_utils.ToProto.message_send_configuration( - request.configuration - ), - metadata=proto_utils.ToProto.metadata(request.metadata), - ), + request, metadata=self._get_grpc_metadata(extensions), ) while True: response = await stream.read() if response == grpc.aio.EOF: # pyright: ignore[reportAttributeAccessIssue] break - yield proto_utils.FromProto.stream_response(response) + yield response - async def resubscribe( + async def subscribe( self, - request: TaskIdParams, + request: SubscribeToTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> AsyncGenerator[ - Task | Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent - ]: + ) -> AsyncGenerator[StreamResponse]: """Reconnects to get task updates.""" - stream = self.stub.TaskSubscription( - a2a_pb2.TaskSubscriptionRequest(name=f'tasks/{request.id}'), + stream = self.stub.SubscribeToTask( + request, metadata=self._get_grpc_metadata(extensions), ) while True: response = await stream.read() if response == grpc.aio.EOF: # pyright: ignore[reportAttributeAccessIssue] break - yield proto_utils.FromProto.stream_response(response) + yield response async def get_task( self, - request: TaskQueryParams, + request: GetTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> Task: """Retrieves the current state and history of a specific task.""" - task = await self.stub.GetTask( - a2a_pb2.GetTaskRequest( - name=f'tasks/{request.id}', - history_length=request.history_length, - ), + return await self.stub.GetTask( + request, metadata=self._get_grpc_metadata(extensions), ) - return proto_utils.FromProto.task(task) async def cancel_task( self, - request: TaskIdParams, + request: CancelTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> Task: """Requests the agent to cancel a specific task.""" - task = await self.stub.CancelTask( - a2a_pb2.CancelTaskRequest(name=f'tasks/{request.id}'), + return await self.stub.CancelTask( + request, metadata=self._get_grpc_metadata(extensions), ) - return proto_utils.FromProto.task(task) async def set_task_callback( self, - request: TaskPushNotificationConfig, + request: SetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> TaskPushNotificationConfig: """Sets or updates the push notification configuration for a specific task.""" - config = await self.stub.CreateTaskPushNotificationConfig( - a2a_pb2.CreateTaskPushNotificationConfigRequest( - parent=f'tasks/{request.task_id}', - config_id=request.push_notification_config.id, - config=proto_utils.ToProto.task_push_notification_config( - request - ), - ), + return await self.stub.SetTaskPushNotificationConfig( + request, metadata=self._get_grpc_metadata(extensions), ) - return proto_utils.FromProto.task_push_notification_config(config) async def get_task_callback( self, - request: GetTaskPushNotificationConfigParams, + request: GetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> TaskPushNotificationConfig: """Retrieves the push notification configuration for a specific task.""" - config = await self.stub.GetTaskPushNotificationConfig( - a2a_pb2.GetTaskPushNotificationConfigRequest( - name=f'tasks/{request.id}/pushNotificationConfigs/{request.push_notification_config_id}', - ), + return await self.stub.GetTaskPushNotificationConfig( + request, metadata=self._get_grpc_metadata(extensions), ) - return proto_utils.FromProto.task_push_notification_config(config) - async def get_card( + async def get_extended_agent_card( self, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> AgentCard: """Retrieves the agent's card.""" - card = self.agent_card - if card and not self._needs_extended_card: - return card - if card is None and not self._needs_extended_card: - raise ValueError('Agent card is not available.') - - card_pb = await self.stub.GetAgentCard( - a2a_pb2.GetAgentCardRequest(), + return await self.stub.GetExtendedAgentCard( + a2a_pb2.GetExtendedAgentCardRequest(), metadata=self._get_grpc_metadata(extensions), ) - card = proto_utils.FromProto.agent_card(card_pb) - self.agent_card = card - self._needs_extended_card = False - return card async def close(self) -> None: """Closes the gRPC channel.""" diff --git a/src/a2a/client/transports/jsonrpc.py b/src/a2a/client/transports/jsonrpc.py index d8011cf4d..d09626397 100644 --- a/src/a2a/client/transports/jsonrpc.py +++ b/src/a2a/client/transports/jsonrpc.py @@ -7,9 +7,10 @@ import httpx +from google.protobuf import json_format from httpx_sse import SSEError, aconnect_sse +from jsonrpc.jsonrpc2 import JSONRPC20Request, JSONRPC20Response -from a2a.client.card_resolver import A2ACardResolver from a2a.client.errors import ( A2AClientHTTPError, A2AClientJSONError, @@ -19,33 +20,19 @@ from a2a.client.middleware import ClientCallContext, ClientCallInterceptor from a2a.client.transports.base import ClientTransport from a2a.extensions.common import update_extension_header -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCard, CancelTaskRequest, - CancelTaskResponse, - GetAuthenticatedExtendedCardRequest, - GetAuthenticatedExtendedCardResponse, - GetTaskPushNotificationConfigParams, + GetExtendedAgentCardRequest, GetTaskPushNotificationConfigRequest, - GetTaskPushNotificationConfigResponse, GetTaskRequest, - GetTaskResponse, - JSONRPCErrorResponse, - Message, - MessageSendParams, SendMessageRequest, SendMessageResponse, - SendStreamingMessageRequest, - SendStreamingMessageResponse, SetTaskPushNotificationConfigRequest, - SetTaskPushNotificationConfigResponse, + StreamResponse, + SubscribeToTaskRequest, Task, - TaskArtifactUpdateEvent, - TaskIdParams, TaskPushNotificationConfig, - TaskQueryParams, - TaskResubscriptionRequest, - TaskStatusUpdateEvent, ) from a2a.utils.telemetry import SpanKind, trace_class @@ -76,11 +63,6 @@ def __init__( self.httpx_client = httpx_client self.agent_card = agent_card self.interceptors = interceptors or [] - self._needs_extended_card = ( - agent_card.supports_authenticated_extended_card - if agent_card - else True - ) self.extensions = extensions async def _apply_interceptors( @@ -113,41 +95,44 @@ def _get_http_args( async def send_message( self, - request: MessageSendParams, + request: SendMessageRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> Task | Message: + ) -> SendMessageResponse: """Sends a non-streaming message request to the agent.""" - rpc_request = SendMessageRequest(params=request, id=str(uuid4())) + rpc_request = JSONRPC20Request( + params=json_format.MessageToDict(request), id=str(uuid4()) + ) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, ) payload, modified_kwargs = await self._apply_interceptors( 'message/send', - rpc_request.model_dump(mode='json', exclude_none=True), + rpc_request.data, modified_kwargs, context, ) response_data = await self._send_request(payload, modified_kwargs) - response = SendMessageResponse.model_validate(response_data) - if isinstance(response.root, JSONRPCErrorResponse): - raise A2AClientJSONRPCError(response.root) - return response.root.result + json_rpc_response = JSONRPC20Response.from_data(response_data) + if json_rpc_response.error: + raise A2AClientJSONRPCError(json_rpc_response.error) + response: SendMessageResponse = json_format.ParseDict( + json_rpc_response.result, SendMessageResponse() + ) + return response async def send_message_streaming( self, - request: MessageSendParams, + request: SendMessageRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> AsyncGenerator[ - Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent - ]: + ) -> AsyncGenerator[StreamResponse]: """Sends a streaming message request to the agent and yields responses as they arrive.""" - rpc_request = SendStreamingMessageRequest( - params=request, id=str(uuid4()) + rpc_request = JSONRPC20Request( + params=json_format.MessageToDict(request), id=str(uuid4()) ) modified_kwargs = update_extension_header( self._get_http_args(context), @@ -155,7 +140,7 @@ async def send_message_streaming( ) payload, modified_kwargs = await self._apply_interceptors( 'message/stream', - rpc_request.model_dump(mode='json', exclude_none=True), + rpc_request.data, modified_kwargs, context, ) @@ -175,12 +160,13 @@ async def send_message_streaming( ) as event_source: try: async for sse in event_source.aiter_sse(): - response = SendStreamingMessageResponse.model_validate( - json.loads(sse.data) + json_rpc_response = JSONRPC20Response.from_json(sse.data) + if json_rpc_response.error: + raise A2AClientJSONRPCError(json_rpc_response.error) + response: StreamResponse = json_format.ParseDict( + json_rpc_response.result, StreamResponse() ) - if isinstance(response.root, JSONRPCErrorResponse): - raise A2AClientJSONRPCError(response.root) - yield response.root.result + yield response except SSEError as e: raise A2AClientHTTPError( 400, f'Invalid SSE response or protocol error: {e}' @@ -216,93 +202,98 @@ async def _send_request( async def get_task( self, - request: TaskQueryParams, + request: GetTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> Task: """Retrieves the current state and history of a specific task.""" - rpc_request = GetTaskRequest(params=request, id=str(uuid4())) + rpc_request = JSONRPC20Request( + params=json_format.MessageToDict(request), id=str(uuid4()) + ) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, ) payload, modified_kwargs = await self._apply_interceptors( 'tasks/get', - rpc_request.model_dump(mode='json', exclude_none=True), + rpc_request.data, modified_kwargs, context, ) response_data = await self._send_request(payload, modified_kwargs) - response = GetTaskResponse.model_validate(response_data) - if isinstance(response.root, JSONRPCErrorResponse): - raise A2AClientJSONRPCError(response.root) - return response.root.result + json_rpc_response = JSONRPC20Response.from_data(response_data) + if json_rpc_response.error: + raise A2AClientJSONRPCError(json_rpc_response.error) + response: Task = json_format.ParseDict(json_rpc_response.result, Task()) + return response async def cancel_task( self, - request: TaskIdParams, + request: CancelTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> Task: """Requests the agent to cancel a specific task.""" - rpc_request = CancelTaskRequest(params=request, id=str(uuid4())) + rpc_request = JSONRPC20Request( + params=json_format.MessageToDict(request), id=str(uuid4()) + ) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, ) payload, modified_kwargs = await self._apply_interceptors( 'tasks/cancel', - rpc_request.model_dump(mode='json', exclude_none=True), + rpc_request.data, modified_kwargs, context, ) response_data = await self._send_request(payload, modified_kwargs) - response = CancelTaskResponse.model_validate(response_data) - if isinstance(response.root, JSONRPCErrorResponse): - raise A2AClientJSONRPCError(response.root) - return response.root.result + json_rpc_response = JSONRPC20Response.from_data(response_data) + if json_rpc_response.error: + raise A2AClientJSONRPCError(json_rpc_response.error) + response: Task = json_format.ParseDict(json_rpc_response.result, Task()) + return response async def set_task_callback( self, - request: TaskPushNotificationConfig, + request: SetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> TaskPushNotificationConfig: """Sets or updates the push notification configuration for a specific task.""" - rpc_request = SetTaskPushNotificationConfigRequest( - params=request, id=str(uuid4()) - ) + rpc_request = JSONRPC20Request(params=request, id=str(uuid4())) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, ) payload, modified_kwargs = await self._apply_interceptors( 'tasks/pushNotificationConfig/set', - rpc_request.model_dump(mode='json', exclude_none=True), + rpc_request.data, modified_kwargs, context, ) response_data = await self._send_request(payload, modified_kwargs) - response = SetTaskPushNotificationConfigResponse.model_validate( - response_data + json_rpc_response = JSONRPC20Response.from_data(response_data) + if json_rpc_response.error: + raise A2AClientJSONRPCError(json_rpc_response.error) + response: TaskPushNotificationConfig = json_format.ParseDict( + json_rpc_response.result, TaskPushNotificationConfig() ) - if isinstance(response.root, JSONRPCErrorResponse): - raise A2AClientJSONRPCError(response.root) - return response.root.result + return response async def get_task_callback( self, - request: GetTaskPushNotificationConfigParams, + request: GetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> TaskPushNotificationConfig: """Retrieves the push notification configuration for a specific task.""" - rpc_request = GetTaskPushNotificationConfigRequest( - params=request, id=str(uuid4()) + rpc_request = JSONRPC20Request( + params=json_format.MessageToDict(request), id=str(uuid4()) ) modified_kwargs = update_extension_header( self._get_http_args(context), @@ -310,36 +301,37 @@ async def get_task_callback( ) payload, modified_kwargs = await self._apply_interceptors( 'tasks/pushNotificationConfig/get', - rpc_request.model_dump(mode='json', exclude_none=True), + rpc_request.data, modified_kwargs, context, ) response_data = await self._send_request(payload, modified_kwargs) - response = GetTaskPushNotificationConfigResponse.model_validate( - response_data + json_rpc_response = JSONRPC20Response.from_data(response_data) + if json_rpc_response.error: + raise A2AClientJSONRPCError(json_rpc_response.error) + response: TaskPushNotificationConfig = json_format.ParseDict( + json_rpc_response.result, TaskPushNotificationConfig() ) - if isinstance(response.root, JSONRPCErrorResponse): - raise A2AClientJSONRPCError(response.root) - return response.root.result + return response - async def resubscribe( + async def subscribe( self, - request: TaskIdParams, + request: SubscribeToTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> AsyncGenerator[ - Task | Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent - ]: + ) -> AsyncGenerator[StreamResponse]: """Reconnects to get task updates.""" - rpc_request = TaskResubscriptionRequest(params=request, id=str(uuid4())) + rpc_request = JSONRPC20Request( + params=json_format.MessageToDict(request), id=str(uuid4()) + ) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, ) payload, modified_kwargs = await self._apply_interceptors( 'tasks/resubscribe', - rpc_request.model_dump(mode='json', exclude_none=True), + rpc_request.data, modified_kwargs, context, ) @@ -354,12 +346,13 @@ async def resubscribe( ) as event_source: try: async for sse in event_source.aiter_sse(): - response = SendStreamingMessageResponse.model_validate_json( - sse.data + json_rpc_response = JSONRPC20Response.from_json(sse.data) + if json_rpc_response.error: + raise A2AClientJSONRPCError(json_rpc_response.error) + response: StreamResponse = json_format.ParseDict( + json_rpc_response.result, StreamResponse() ) - if isinstance(response.root, JSONRPCErrorResponse): - raise A2AClientJSONRPCError(response.root) - yield response.root.result + yield response except SSEError as e: raise A2AClientHTTPError( 400, f'Invalid SSE response or protocol error: {e}' @@ -371,35 +364,25 @@ async def resubscribe( 503, f'Network communication error: {e}' ) from e - async def get_card( + async def get_extended_agent_card( self, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> AgentCard: """Retrieves the agent's card.""" - card = self.agent_card - if not card: - resolver = A2ACardResolver(self.httpx_client, self.url) - card = await resolver.get_agent_card( - http_kwargs=self._get_http_args(context) - ) - self._needs_extended_card = ( - card.supports_authenticated_extended_card - ) - self.agent_card = card - - if not self._needs_extended_card: - return card + request = GetExtendedAgentCardRequest() + rpc_request = JSONRPC20Request( + params=json_format.MessageToDict(request), id=str(uuid4()) + ) - request = GetAuthenticatedExtendedCardRequest(id=str(uuid4())) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, ) payload, modified_kwargs = await self._apply_interceptors( - request.method, - request.model_dump(mode='json', exclude_none=True), + 'GetExtendedAgentCard', + rpc_request.data, modified_kwargs, context, ) @@ -407,14 +390,13 @@ async def get_card( payload, modified_kwargs, ) - response = GetAuthenticatedExtendedCardResponse.model_validate( - response_data + json_rpc_response = JSONRPC20Response.from_data(response_data) + if json_rpc_response.error: + raise A2AClientJSONRPCError(json_rpc_response.error) + response: AgentCard = json_format.ParseDict( + json_rpc_response.result, AgentCard() ) - if isinstance(response.root, JSONRPCErrorResponse): - raise A2AClientJSONRPCError(response.root) - self.agent_card = response.root.result - self._needs_extended_card = False - return card + return response async def close(self) -> None: """Closes the httpx client.""" diff --git a/src/a2a/client/transports/rest.py b/src/a2a/client/transports/rest.py index 83c267873..aedb7177d 100644 --- a/src/a2a/client/transports/rest.py +++ b/src/a2a/client/transports/rest.py @@ -9,25 +9,23 @@ from google.protobuf.json_format import MessageToDict, Parse, ParseDict from httpx_sse import SSEError, aconnect_sse -from a2a.client.card_resolver import A2ACardResolver from a2a.client.errors import A2AClientHTTPError, A2AClientJSONError from a2a.client.middleware import ClientCallContext, ClientCallInterceptor from a2a.client.transports.base import ClientTransport from a2a.extensions.common import update_extension_header -from a2a.grpc import a2a_pb2 -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCard, - GetTaskPushNotificationConfigParams, - Message, - MessageSendParams, + CancelTaskRequest, + GetTaskPushNotificationConfigRequest, + GetTaskRequest, + SendMessageRequest, + SendMessageResponse, + SetTaskPushNotificationConfigRequest, + StreamResponse, + SubscribeToTaskRequest, Task, - TaskArtifactUpdateEvent, - TaskIdParams, TaskPushNotificationConfig, - TaskQueryParams, - TaskStatusUpdateEvent, ) -from a2a.utils import proto_utils from a2a.utils.telemetry import SpanKind, trace_class @@ -83,22 +81,11 @@ def _get_http_args( async def _prepare_send_message( self, - request: MessageSendParams, + request: SendMessageRequest, context: ClientCallContext | None, extensions: list[str] | None = None, ) -> tuple[dict[str, Any], dict[str, Any]]: - pb = a2a_pb2.SendMessageRequest( - request=proto_utils.ToProto.message(request.message), - configuration=proto_utils.ToProto.message_send_configuration( - request.configuration - ), - metadata=( - proto_utils.ToProto.metadata(request.metadata) - if request.metadata - else None - ), - ) - payload = MessageToDict(pb) + payload = MessageToDict(request) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, @@ -112,11 +99,11 @@ async def _prepare_send_message( async def send_message( self, - request: MessageSendParams, + request: SendMessageRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> Task | Message: + ) -> SendMessageResponse: """Sends a non-streaming message request to the agent.""" payload, modified_kwargs = await self._prepare_send_message( request, context, extensions @@ -124,19 +111,18 @@ async def send_message( response_data = await self._send_post_request( '/v1/message:send', payload, modified_kwargs ) - response_pb = a2a_pb2.SendMessageResponse() - ParseDict(response_data, response_pb) - return proto_utils.FromProto.task_or_message(response_pb) + response: SendMessageResponse = ParseDict( + response_data, SendMessageResponse() + ) + return response async def send_message_streaming( self, - request: MessageSendParams, + request: SendMessageRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> AsyncGenerator[ - Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent | Message - ]: + ) -> AsyncGenerator[StreamResponse]: """Sends a streaming message request to the agent and yields responses as they arrive.""" payload, modified_kwargs = await self._prepare_send_message( request, context, extensions @@ -153,9 +139,8 @@ async def send_message_streaming( ) as event_source: try: async for sse in event_source.aiter_sse(): - event = a2a_pb2.StreamResponse() - Parse(sse.data, event) - yield proto_utils.FromProto.stream_response(event) + event: StreamResponse = Parse(sse.data, StreamResponse()) + yield event except SSEError as e: raise A2AClientHTTPError( 400, f'Invalid SSE response or protocol error: {e}' @@ -213,42 +198,42 @@ async def _send_get_request( async def get_task( self, - request: TaskQueryParams, + request: GetTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> Task: """Retrieves the current state and history of a specific task.""" + params = MessageToDict(request) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, ) _payload, modified_kwargs = await self._apply_interceptors( - request.model_dump(mode='json', exclude_none=True), + params, modified_kwargs, context, ) + + del params['name'] # name is part of the URL path, not query params + response_data = await self._send_get_request( - f'/v1/tasks/{request.id}', - {'historyLength': str(request.history_length)} - if request.history_length is not None - else {}, + f'/v1/{request.name}', + params, modified_kwargs, ) - task = a2a_pb2.Task() - ParseDict(response_data, task) - return proto_utils.FromProto.task(task) + response: Task = ParseDict(response_data, Task()) + return response async def cancel_task( self, - request: TaskIdParams, + request: CancelTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> Task: """Requests the agent to cancel a specific task.""" - pb = a2a_pb2.CancelTaskRequest(name=f'tasks/{request.id}') - payload = MessageToDict(pb) + payload = MessageToDict(request) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, @@ -259,26 +244,20 @@ async def cancel_task( context, ) response_data = await self._send_post_request( - f'/v1/tasks/{request.id}:cancel', payload, modified_kwargs + f'/v1/{request.name}:cancel', payload, modified_kwargs ) - task = a2a_pb2.Task() - ParseDict(response_data, task) - return proto_utils.FromProto.task(task) + response: Task = ParseDict(response_data, Task()) + return response async def set_task_callback( self, - request: TaskPushNotificationConfig, + request: SetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> TaskPushNotificationConfig: """Sets or updates the push notification configuration for a specific task.""" - pb = a2a_pb2.CreateTaskPushNotificationConfigRequest( - parent=f'tasks/{request.task_id}', - config_id=request.push_notification_config.id, - config=proto_utils.ToProto.task_push_notification_config(request), - ) - payload = MessageToDict(pb) + payload = MessageToDict(request) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, @@ -287,53 +266,51 @@ async def set_task_callback( payload, modified_kwargs, context ) response_data = await self._send_post_request( - f'/v1/tasks/{request.task_id}/pushNotificationConfigs', + f'/v1/{request.parent}/pushNotificationConfigs', payload, modified_kwargs, ) - config = a2a_pb2.TaskPushNotificationConfig() - ParseDict(response_data, config) - return proto_utils.FromProto.task_push_notification_config(config) + response: TaskPushNotificationConfig = ParseDict( + response_data, TaskPushNotificationConfig() + ) + return response async def get_task_callback( self, - request: GetTaskPushNotificationConfigParams, + request: GetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> TaskPushNotificationConfig: """Retrieves the push notification configuration for a specific task.""" - pb = a2a_pb2.GetTaskPushNotificationConfigRequest( - name=f'tasks/{request.id}/pushNotificationConfigs/{request.push_notification_config_id}', - ) - payload = MessageToDict(pb) + params = MessageToDict(request) modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, ) - payload, modified_kwargs = await self._apply_interceptors( - payload, + params, modified_kwargs = await self._apply_interceptors( + params, modified_kwargs, context, ) + del params['name'] # name is part of the URL path, not query params response_data = await self._send_get_request( - f'/v1/tasks/{request.id}/pushNotificationConfigs/{request.push_notification_config_id}', - {}, + f'/v1/{request.name}', + params, modified_kwargs, ) - config = a2a_pb2.TaskPushNotificationConfig() - ParseDict(response_data, config) - return proto_utils.FromProto.task_push_notification_config(config) + response: TaskPushNotificationConfig = ParseDict( + response_data, TaskPushNotificationConfig() + ) + return response - async def resubscribe( + async def subscribe( self, - request: TaskIdParams, + request: SubscribeToTaskRequest, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, - ) -> AsyncGenerator[ - Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent | Message - ]: + ) -> AsyncGenerator[StreamResponse]: """Reconnects to get task updates.""" modified_kwargs = update_extension_header( self._get_http_args(context), @@ -344,14 +321,13 @@ async def resubscribe( async with aconnect_sse( self.httpx_client, 'GET', - f'{self.url}/v1/tasks/{request.id}:subscribe', + f'{self.url}/v1/{request.name}:subscribe', **modified_kwargs, ) as event_source: try: async for sse in event_source.aiter_sse(): - event = a2a_pb2.StreamResponse() - Parse(sse.data, event) - yield proto_utils.FromProto.stream_response(event) + event: StreamResponse = Parse(sse.data, StreamResponse()) + yield event except SSEError as e: raise A2AClientHTTPError( 400, f'Invalid SSE response or protocol error: {e}' @@ -363,27 +339,13 @@ async def resubscribe( 503, f'Network communication error: {e}' ) from e - async def get_card( + async def get_extended_agent_card( self, *, context: ClientCallContext | None = None, extensions: list[str] | None = None, ) -> AgentCard: - """Retrieves the agent's card.""" - card = self.agent_card - if not card: - resolver = A2ACardResolver(self.httpx_client, self.url) - card = await resolver.get_agent_card( - http_kwargs=self._get_http_args(context) - ) - self._needs_extended_card = ( - card.supports_authenticated_extended_card - ) - self.agent_card = card - - if not self._needs_extended_card: - return card - + """Retrieves the Extended AgentCard.""" modified_kwargs = update_extension_header( self._get_http_args(context), extensions if extensions is not None else self.extensions, @@ -396,10 +358,8 @@ async def get_card( response_data = await self._send_get_request( '/v1/card', {}, modified_kwargs ) - card = AgentCard.model_validate(response_data) - self.agent_card = card - self._needs_extended_card = False - return card + response: AgentCard = ParseDict(response_data, AgentCard()) + return response async def close(self) -> None: """Closes the httpx client.""" diff --git a/src/a2a/extensions/common.py b/src/a2a/extensions/common.py index cba3517e4..f4e2135bb 100644 --- a/src/a2a/extensions/common.py +++ b/src/a2a/extensions/common.py @@ -1,6 +1,6 @@ from typing import Any -from a2a.types import AgentCard, AgentExtension +from a2a.types.a2a_pb2 import AgentCard, AgentExtension HTTP_EXTENSION_HEADER = 'X-A2A-Extensions' diff --git a/src/a2a/grpc/__init__.py b/src/a2a/grpc/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/a2a/grpc/a2a_pb2.py b/src/a2a/grpc/a2a_pb2.py deleted file mode 100644 index 9b4b73013..000000000 --- a/src/a2a/grpc/a2a_pb2.py +++ /dev/null @@ -1,195 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# NO CHECKED-IN PROTOBUF GENCODE -# source: a2a.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.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\ta2a.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/*}Bi\n\ncom.a2a.v1B\x08\x41\x32\x61ProtoP\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_pb2', _globals) -if not _descriptor._USE_C_DESCRIPTORS: - _globals['DESCRIPTOR']._loaded_options = None - _globals['DESCRIPTOR']._serialized_options = b'\n\ncom.a2a.v1B\010A2aProtoP\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=8066 - _globals['_TASKSTATE']._serialized_end=8316 - _globals['_ROLE']._serialized_start=8318 - _globals['_ROLE']._serialized_end=8377 - _globals['_SENDMESSAGECONFIGURATION']._serialized_start=202 - _globals['_SENDMESSAGECONFIGURATION']._serialized_end=424 - _globals['_TASK']._serialized_start=427 - _globals['_TASK']._serialized_end=668 - _globals['_TASKSTATUS']._serialized_start=671 - _globals['_TASKSTATUS']._serialized_end=824 - _globals['_PART']._serialized_start=827 - _globals['_PART']._serialized_end=996 - _globals['_FILEPART']._serialized_start=999 - _globals['_FILEPART']._serialized_end=1146 - _globals['_DATAPART']._serialized_start=1148 - _globals['_DATAPART']._serialized_end=1203 - _globals['_MESSAGE']._serialized_start=1206 - _globals['_MESSAGE']._serialized_end=1461 - _globals['_ARTIFACT']._serialized_start=1464 - _globals['_ARTIFACT']._serialized_end=1682 - _globals['_TASKSTATUSUPDATEEVENT']._serialized_start=1685 - _globals['_TASKSTATUSUPDATEEVENT']._serialized_end=1883 - _globals['_TASKARTIFACTUPDATEEVENT']._serialized_start=1886 - _globals['_TASKARTIFACTUPDATEEVENT']._serialized_end=2121 - _globals['_PUSHNOTIFICATIONCONFIG']._serialized_start=2124 - _globals['_PUSHNOTIFICATIONCONFIG']._serialized_end=2272 - _globals['_AUTHENTICATIONINFO']._serialized_start=2274 - _globals['_AUTHENTICATIONINFO']._serialized_end=2354 - _globals['_AGENTINTERFACE']._serialized_start=2356 - _globals['_AGENTINTERFACE']._serialized_end=2420 - _globals['_AGENTCARD']._serialized_start=2423 - _globals['_AGENTCARD']._serialized_end=3391 - _globals['_AGENTCARD_SECURITYSCHEMESENTRY']._serialized_start=3301 - _globals['_AGENTCARD_SECURITYSCHEMESENTRY']._serialized_end=3391 - _globals['_AGENTPROVIDER']._serialized_start=3393 - _globals['_AGENTPROVIDER']._serialized_end=3462 - _globals['_AGENTCAPABILITIES']._serialized_start=3465 - _globals['_AGENTCAPABILITIES']._serialized_end=3617 - _globals['_AGENTEXTENSION']._serialized_start=3620 - _globals['_AGENTEXTENSION']._serialized_end=3765 - _globals['_AGENTSKILL']._serialized_start=3768 - _globals['_AGENTSKILL']._serialized_end=4012 - _globals['_AGENTCARDSIGNATURE']._serialized_start=4015 - _globals['_AGENTCARDSIGNATURE']._serialized_end=4154 - _globals['_TASKPUSHNOTIFICATIONCONFIG']._serialized_start=4157 - _globals['_TASKPUSHNOTIFICATIONCONFIG']._serialized_end=4295 - _globals['_STRINGLIST']._serialized_start=4297 - _globals['_STRINGLIST']._serialized_end=4329 - _globals['_SECURITY']._serialized_start=4332 - _globals['_SECURITY']._serialized_end=4479 - _globals['_SECURITY_SCHEMESENTRY']._serialized_start=4401 - _globals['_SECURITY_SCHEMESENTRY']._serialized_end=4479 - _globals['_SECURITYSCHEME']._serialized_start=4482 - _globals['_SECURITYSCHEME']._serialized_end=4968 - _globals['_APIKEYSECURITYSCHEME']._serialized_start=4970 - _globals['_APIKEYSECURITYSCHEME']._serialized_end=5074 - _globals['_HTTPAUTHSECURITYSCHEME']._serialized_start=5076 - _globals['_HTTPAUTHSECURITYSCHEME']._serialized_end=5195 - _globals['_OAUTH2SECURITYSCHEME']._serialized_start=5198 - _globals['_OAUTH2SECURITYSCHEME']._serialized_end=5344 - _globals['_OPENIDCONNECTSECURITYSCHEME']._serialized_start=5346 - _globals['_OPENIDCONNECTSECURITYSCHEME']._serialized_end=5456 - _globals['_MUTUALTLSSECURITYSCHEME']._serialized_start=5458 - _globals['_MUTUALTLSSECURITYSCHEME']._serialized_end=5517 - _globals['_OAUTHFLOWS']._serialized_start=5520 - _globals['_OAUTHFLOWS']._serialized_end=5824 - _globals['_AUTHORIZATIONCODEOAUTHFLOW']._serialized_start=5827 - _globals['_AUTHORIZATIONCODEOAUTHFLOW']._serialized_end=6093 - _globals['_AUTHORIZATIONCODEOAUTHFLOW_SCOPESENTRY']._serialized_start=6036 - _globals['_AUTHORIZATIONCODEOAUTHFLOW_SCOPESENTRY']._serialized_end=6093 - _globals['_CLIENTCREDENTIALSOAUTHFLOW']._serialized_start=6096 - _globals['_CLIENTCREDENTIALSOAUTHFLOW']._serialized_end=6317 - _globals['_CLIENTCREDENTIALSOAUTHFLOW_SCOPESENTRY']._serialized_start=6036 - _globals['_CLIENTCREDENTIALSOAUTHFLOW_SCOPESENTRY']._serialized_end=6093 - _globals['_IMPLICITOAUTHFLOW']._serialized_start=6320 - _globals['_IMPLICITOAUTHFLOW']._serialized_end=6539 - _globals['_IMPLICITOAUTHFLOW_SCOPESENTRY']._serialized_start=6036 - _globals['_IMPLICITOAUTHFLOW_SCOPESENTRY']._serialized_end=6093 - _globals['_PASSWORDOAUTHFLOW']._serialized_start=6542 - _globals['_PASSWORDOAUTHFLOW']._serialized_end=6745 - _globals['_PASSWORDOAUTHFLOW_SCOPESENTRY']._serialized_start=6036 - _globals['_PASSWORDOAUTHFLOW_SCOPESENTRY']._serialized_end=6093 - _globals['_SENDMESSAGEREQUEST']._serialized_start=6748 - _globals['_SENDMESSAGEREQUEST']._serialized_end=6941 - _globals['_GETTASKREQUEST']._serialized_start=6943 - _globals['_GETTASKREQUEST']._serialized_end=7023 - _globals['_CANCELTASKREQUEST']._serialized_start=7025 - _globals['_CANCELTASKREQUEST']._serialized_end=7064 - _globals['_GETTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=7066 - _globals['_GETTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=7124 - _globals['_DELETETASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=7126 - _globals['_DELETETASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=7187 - _globals['_CREATETASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=7190 - _globals['_CREATETASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=7359 - _globals['_TASKSUBSCRIPTIONREQUEST']._serialized_start=7361 - _globals['_TASKSUBSCRIPTIONREQUEST']._serialized_end=7406 - _globals['_LISTTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=7408 - _globals['_LISTTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=7531 - _globals['_GETAGENTCARDREQUEST']._serialized_start=7533 - _globals['_GETAGENTCARDREQUEST']._serialized_end=7554 - _globals['_SENDMESSAGERESPONSE']._serialized_start=7556 - _globals['_SENDMESSAGERESPONSE']._serialized_end=7665 - _globals['_STREAMRESPONSE']._serialized_start=7668 - _globals['_STREAMRESPONSE']._serialized_end=7918 - _globals['_LISTTASKPUSHNOTIFICATIONCONFIGRESPONSE']._serialized_start=7921 - _globals['_LISTTASKPUSHNOTIFICATIONCONFIGRESPONSE']._serialized_end=8063 - _globals['_A2ASERVICE']._serialized_start=8380 - _globals['_A2ASERVICE']._serialized_end=9719 -# @@protoc_insertion_point(module_scope) diff --git a/src/a2a/server/agent_execution/agent_executor.py b/src/a2a/server/agent_execution/agent_executor.py index 38be9c11c..74d7af6c1 100644 --- a/src/a2a/server/agent_execution/agent_executor.py +++ b/src/a2a/server/agent_execution/agent_executor.py @@ -36,7 +36,7 @@ async def cancel( The agent should attempt to stop the task identified by the task_id in the context and publish a `TaskStatusUpdateEvent` with state - `TaskState.canceled` to the `event_queue`. + `TaskState.TASK_STATE_CANCELLED` to the `event_queue`. Args: context: The request context containing the task ID to cancel. diff --git a/src/a2a/server/agent_execution/context.py b/src/a2a/server/agent_execution/context.py index cd9f8f973..d0a092574 100644 --- a/src/a2a/server/agent_execution/context.py +++ b/src/a2a/server/agent_execution/context.py @@ -6,7 +6,7 @@ IDGeneratorContext, UUIDGenerator, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( InvalidParamsError, Message, MessageSendConfiguration, diff --git a/src/a2a/server/agent_execution/request_context_builder.py b/src/a2a/server/agent_execution/request_context_builder.py index 2a3ad4db5..1b2a19076 100644 --- a/src/a2a/server/agent_execution/request_context_builder.py +++ b/src/a2a/server/agent_execution/request_context_builder.py @@ -2,7 +2,7 @@ from a2a.server.agent_execution import RequestContext from a2a.server.context import ServerCallContext -from a2a.types import MessageSendParams, Task +from a2a.types.a2a_pb2 import MessageSendParams, Task class RequestContextBuilder(ABC): diff --git a/src/a2a/server/agent_execution/simple_request_context_builder.py b/src/a2a/server/agent_execution/simple_request_context_builder.py index 3eca44356..c1fe0449c 100644 --- a/src/a2a/server/agent_execution/simple_request_context_builder.py +++ b/src/a2a/server/agent_execution/simple_request_context_builder.py @@ -3,7 +3,7 @@ from a2a.server.agent_execution import RequestContext, RequestContextBuilder from a2a.server.context import ServerCallContext from a2a.server.tasks import TaskStore -from a2a.types import MessageSendParams, Task +from a2a.types.a2a_pb2 import MessageSendParams, Task class SimpleRequestContextBuilder(RequestContextBuilder): diff --git a/src/a2a/server/apps/jsonrpc/fastapi_app.py b/src/a2a/server/apps/jsonrpc/fastapi_app.py index ace2c6ae3..fed5cd3aa 100644 --- a/src/a2a/server/apps/jsonrpc/fastapi_app.py +++ b/src/a2a/server/apps/jsonrpc/fastapi_app.py @@ -24,7 +24,7 @@ ) from a2a.server.context import ServerCallContext from a2a.server.request_handlers.jsonrpc_handler import RequestHandler -from a2a.types import A2ARequest, AgentCard +from a2a.types.a2a_pb2 import A2ARequest, AgentCard from a2a.utils.constants import ( AGENT_CARD_WELL_KNOWN_PATH, DEFAULT_RPC_URL, diff --git a/src/a2a/server/apps/jsonrpc/jsonrpc_app.py b/src/a2a/server/apps/jsonrpc/jsonrpc_app.py index 3e7c2854b..af65c52a1 100644 --- a/src/a2a/server/apps/jsonrpc/jsonrpc_app.py +++ b/src/a2a/server/apps/jsonrpc/jsonrpc_app.py @@ -18,7 +18,7 @@ from a2a.server.context import ServerCallContext from a2a.server.request_handlers.jsonrpc_handler import JSONRPCHandler from a2a.server.request_handlers.request_handler import RequestHandler -from a2a.types import ( +from a2a.types.a2a_pb2 import ( A2AError, A2ARequest, AgentCard, diff --git a/src/a2a/server/apps/jsonrpc/starlette_app.py b/src/a2a/server/apps/jsonrpc/starlette_app.py index 1effa9d51..5530845ca 100644 --- a/src/a2a/server/apps/jsonrpc/starlette_app.py +++ b/src/a2a/server/apps/jsonrpc/starlette_app.py @@ -28,7 +28,7 @@ ) from a2a.server.context import ServerCallContext from a2a.server.request_handlers.jsonrpc_handler import RequestHandler -from a2a.types import AgentCard +from a2a.types.a2a_pb2 import AgentCard from a2a.utils.constants import ( AGENT_CARD_WELL_KNOWN_PATH, DEFAULT_RPC_URL, diff --git a/src/a2a/server/apps/rest/fastapi_app.py b/src/a2a/server/apps/rest/fastapi_app.py index 3ae5ad6fe..02493f373 100644 --- a/src/a2a/server/apps/rest/fastapi_app.py +++ b/src/a2a/server/apps/rest/fastapi_app.py @@ -28,7 +28,7 @@ from a2a.server.apps.rest.rest_adapter import RESTAdapter from a2a.server.context import ServerCallContext from a2a.server.request_handlers.request_handler import RequestHandler -from a2a.types import AgentCard +from a2a.types.a2a_pb2 import AgentCard from a2a.utils.constants import AGENT_CARD_WELL_KNOWN_PATH diff --git a/src/a2a/server/apps/rest/rest_adapter.py b/src/a2a/server/apps/rest/rest_adapter.py index cdf86ab14..c9e93b739 100644 --- a/src/a2a/server/apps/rest/rest_adapter.py +++ b/src/a2a/server/apps/rest/rest_adapter.py @@ -34,7 +34,10 @@ from a2a.server.context import ServerCallContext from a2a.server.request_handlers.request_handler import RequestHandler from a2a.server.request_handlers.rest_handler import RESTHandler -from a2a.types import AgentCard, AuthenticatedExtendedCardNotConfiguredError +from a2a.types.a2a_pb2 import ( + AgentCard, + AuthenticatedExtendedCardNotConfiguredError, +) from a2a.utils.error_handlers import ( rest_error_handler, rest_stream_error_handler, diff --git a/src/a2a/server/events/event_consumer.py b/src/a2a/server/events/event_consumer.py index de0f6bd9d..efe952638 100644 --- a/src/a2a/server/events/event_consumer.py +++ b/src/a2a/server/events/event_consumer.py @@ -7,7 +7,7 @@ from pydantic import ValidationError from a2a.server.events.event_queue import Event, EventQueue -from a2a.types import ( +from a2a.types.a2a_pb2 import ( InternalError, Message, Task, @@ -109,12 +109,12 @@ async def consume_all(self) -> AsyncGenerator[Event]: isinstance(event, Task) and event.status.state in ( - TaskState.completed, - TaskState.canceled, - TaskState.failed, - TaskState.rejected, - TaskState.unknown, - TaskState.input_required, + TaskState.TASK_STATE_COMPLETED, + TaskState.TASK_STATE_CANCELLED, + TaskState.TASK_STATE_FAILED, + TaskState.TASK_STATE_REJECTED, + TaskState.TASK_STATE_UNSPECIFIED, + TaskState.TASK_STATE_INPUT_REQUIRED, ) ) ) diff --git a/src/a2a/server/events/event_queue.py b/src/a2a/server/events/event_queue.py index f6599ccae..5704147d3 100644 --- a/src/a2a/server/events/event_queue.py +++ b/src/a2a/server/events/event_queue.py @@ -2,7 +2,7 @@ import logging import sys -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Message, Task, TaskArtifactUpdateEvent, diff --git a/src/a2a/server/models.py b/src/a2a/server/models.py index 4b0f7504c..1fbbb8085 100644 --- a/src/a2a/server/models.py +++ b/src/a2a/server/models.py @@ -12,7 +12,7 @@ def override(func): # noqa: ANN001, ANN201 from pydantic import BaseModel -from a2a.types import Artifact, Message, TaskStatus +from a2a.types.a2a_pb2 import Artifact, Message, TaskStatus try: diff --git a/src/a2a/server/request_handlers/default_request_handler.py b/src/a2a/server/request_handlers/default_request_handler.py index 30d1ee891..5468b47ff 100644 --- a/src/a2a/server/request_handlers/default_request_handler.py +++ b/src/a2a/server/request_handlers/default_request_handler.py @@ -26,7 +26,7 @@ TaskManager, TaskStore, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( DeleteTaskPushNotificationConfigParams, GetTaskPushNotificationConfigParams, InternalError, @@ -51,10 +51,10 @@ logger = logging.getLogger(__name__) TERMINAL_TASK_STATES = { - TaskState.completed, - TaskState.canceled, - TaskState.failed, - TaskState.rejected, + TaskState.TASK_STATE_COMPLETED, + TaskState.TASK_STATE_CANCELLED, + TaskState.TASK_STATE_FAILED, + TaskState.TASK_STATE_REJECTED, } @@ -175,7 +175,7 @@ async def on_cancel_task( ) ) - if result.status.state != TaskState.canceled: + if result.status.state != TaskState.TASK_STATE_CANCELLED: raise ServerError( error=TaskNotCancelableError( message=f'Task cannot be canceled - current state: {result.status.state}' diff --git a/src/a2a/server/request_handlers/grpc_handler.py b/src/a2a/server/request_handlers/grpc_handler.py index e2ec69a15..18c8c4071 100644 --- a/src/a2a/server/request_handlers/grpc_handler.py +++ b/src/a2a/server/request_handlers/grpc_handler.py @@ -20,7 +20,7 @@ from collections.abc import Callable -import a2a.grpc.a2a_pb2_grpc as a2a_grpc +import a2a.types.a2a_pb2_grpc as a2a_grpc from a2a import types from a2a.auth.user import UnauthenticatedUser @@ -28,10 +28,10 @@ HTTP_EXTENSION_HEADER, get_requested_extensions, ) -from a2a.grpc import a2a_pb2 from a2a.server.context import ServerCallContext from a2a.server.request_handlers.request_handler import RequestHandler -from a2a.types import AgentCard, TaskNotFoundError +from a2a.types import a2a_pb2 +from a2a.types.a2a_pb2 import AgentCard, TaskNotFoundError from a2a.utils import proto_utils from a2a.utils.errors import ServerError from a2a.utils.helpers import validate, validate_async_generator diff --git a/src/a2a/server/request_handlers/jsonrpc_handler.py b/src/a2a/server/request_handlers/jsonrpc_handler.py index 567c61484..6172ac635 100644 --- a/src/a2a/server/request_handlers/jsonrpc_handler.py +++ b/src/a2a/server/request_handlers/jsonrpc_handler.py @@ -5,7 +5,7 @@ from a2a.server.context import ServerCallContext from a2a.server.request_handlers.request_handler import RequestHandler from a2a.server.request_handlers.response_helpers import prepare_response_object -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCard, AuthenticatedExtendedCardNotConfiguredError, CancelTaskRequest, diff --git a/src/a2a/server/request_handlers/request_handler.py b/src/a2a/server/request_handlers/request_handler.py index 7ce76cc90..d20989bcf 100644 --- a/src/a2a/server/request_handlers/request_handler.py +++ b/src/a2a/server/request_handlers/request_handler.py @@ -3,7 +3,7 @@ from a2a.server.context import ServerCallContext from a2a.server.events.event_queue import Event -from a2a.types import ( +from a2a.types.a2a_pb2 import ( DeleteTaskPushNotificationConfigParams, GetTaskPushNotificationConfigParams, ListTaskPushNotificationConfigParams, diff --git a/src/a2a/server/request_handlers/response_helpers.py b/src/a2a/server/request_handlers/response_helpers.py index 4c55c4197..301c0e985 100644 --- a/src/a2a/server/request_handlers/response_helpers.py +++ b/src/a2a/server/request_handlers/response_helpers.py @@ -3,7 +3,7 @@ # response types from typing import TypeVar -from a2a.types import ( +from a2a.types.a2a_pb2 import ( A2AError, CancelTaskResponse, CancelTaskSuccessResponse, diff --git a/src/a2a/server/request_handlers/rest_handler.py b/src/a2a/server/request_handlers/rest_handler.py index 59057487c..22c829ef5 100644 --- a/src/a2a/server/request_handlers/rest_handler.py +++ b/src/a2a/server/request_handlers/rest_handler.py @@ -15,10 +15,10 @@ Request = Any -from a2a.grpc import a2a_pb2 from a2a.server.context import ServerCallContext from a2a.server.request_handlers.request_handler import RequestHandler -from a2a.types import ( +from a2a.types import a2a_pb2 +from a2a.types.a2a_pb2 import ( AgentCard, GetTaskPushNotificationConfigParams, TaskIdParams, diff --git a/src/a2a/server/tasks/base_push_notification_sender.py b/src/a2a/server/tasks/base_push_notification_sender.py index 087d2973d..68c8c85d4 100644 --- a/src/a2a/server/tasks/base_push_notification_sender.py +++ b/src/a2a/server/tasks/base_push_notification_sender.py @@ -7,7 +7,7 @@ PushNotificationConfigStore, ) from a2a.server.tasks.push_notification_sender import PushNotificationSender -from a2a.types import PushNotificationConfig, Task +from a2a.types.a2a_pb2 import PushNotificationConfig, Task logger = logging.getLogger(__name__) diff --git a/src/a2a/server/tasks/database_push_notification_config_store.py b/src/a2a/server/tasks/database_push_notification_config_store.py index e125f22a1..cdcf2f4fa 100644 --- a/src/a2a/server/tasks/database_push_notification_config_store.py +++ b/src/a2a/server/tasks/database_push_notification_config_store.py @@ -37,7 +37,7 @@ from a2a.server.tasks.push_notification_config_store import ( PushNotificationConfigStore, ) -from a2a.types import PushNotificationConfig +from a2a.types.a2a_pb2 import PushNotificationConfig if TYPE_CHECKING: diff --git a/src/a2a/server/tasks/database_task_store.py b/src/a2a/server/tasks/database_task_store.py index 07ba7e970..5c5b8646b 100644 --- a/src/a2a/server/tasks/database_task_store.py +++ b/src/a2a/server/tasks/database_task_store.py @@ -22,7 +22,7 @@ from a2a.server.context import ServerCallContext from a2a.server.models import Base, TaskModel, create_task_model from a2a.server.tasks.task_store import TaskStore -from a2a.types import Task # Task is the Pydantic model +from a2a.types.a2a_pb2 import Task # Task is the Pydantic model logger = logging.getLogger(__name__) diff --git a/src/a2a/server/tasks/inmemory_push_notification_config_store.py b/src/a2a/server/tasks/inmemory_push_notification_config_store.py index c5bc5dbe6..6117dbe3a 100644 --- a/src/a2a/server/tasks/inmemory_push_notification_config_store.py +++ b/src/a2a/server/tasks/inmemory_push_notification_config_store.py @@ -4,7 +4,7 @@ from a2a.server.tasks.push_notification_config_store import ( PushNotificationConfigStore, ) -from a2a.types import PushNotificationConfig +from a2a.types.a2a_pb2 import PushNotificationConfig logger = logging.getLogger(__name__) diff --git a/src/a2a/server/tasks/inmemory_task_store.py b/src/a2a/server/tasks/inmemory_task_store.py index 4e192af08..aa7fe56f4 100644 --- a/src/a2a/server/tasks/inmemory_task_store.py +++ b/src/a2a/server/tasks/inmemory_task_store.py @@ -3,7 +3,7 @@ from a2a.server.context import ServerCallContext from a2a.server.tasks.task_store import TaskStore -from a2a.types import Task +from a2a.types.a2a_pb2 import Task logger = logging.getLogger(__name__) diff --git a/src/a2a/server/tasks/push_notification_config_store.py b/src/a2a/server/tasks/push_notification_config_store.py index efe46b40a..a1c049e90 100644 --- a/src/a2a/server/tasks/push_notification_config_store.py +++ b/src/a2a/server/tasks/push_notification_config_store.py @@ -1,6 +1,6 @@ from abc import ABC, abstractmethod -from a2a.types import PushNotificationConfig +from a2a.types.a2a_pb2 import PushNotificationConfig class PushNotificationConfigStore(ABC): diff --git a/src/a2a/server/tasks/push_notification_sender.py b/src/a2a/server/tasks/push_notification_sender.py index d9389d4a4..a3dfed69a 100644 --- a/src/a2a/server/tasks/push_notification_sender.py +++ b/src/a2a/server/tasks/push_notification_sender.py @@ -1,6 +1,6 @@ from abc import ABC, abstractmethod -from a2a.types import Task +from a2a.types.a2a_pb2 import Task class PushNotificationSender(ABC): diff --git a/src/a2a/server/tasks/result_aggregator.py b/src/a2a/server/tasks/result_aggregator.py index fb1ab62ef..b2e20c6e9 100644 --- a/src/a2a/server/tasks/result_aggregator.py +++ b/src/a2a/server/tasks/result_aggregator.py @@ -5,7 +5,7 @@ from a2a.server.events import Event, EventConsumer from a2a.server.tasks.task_manager import TaskManager -from a2a.types import Message, Task, TaskState, TaskStatusUpdateEvent +from a2a.types.a2a_pb2 import Message, Task, TaskState, TaskStatusUpdateEvent logger = logging.getLogger(__name__) @@ -134,7 +134,7 @@ async def consume_and_break_on_interrupt( should_interrupt = False is_auth_required = ( isinstance(event, Task | TaskStatusUpdateEvent) - and event.status.state == TaskState.auth_required + and event.status.state == TaskState.TASK_STATE_AUTH_REQUIRED ) # Always interrupt on auth_required, as it needs external action. diff --git a/src/a2a/server/tasks/task_manager.py b/src/a2a/server/tasks/task_manager.py index 5c363703b..f405e23ca 100644 --- a/src/a2a/server/tasks/task_manager.py +++ b/src/a2a/server/tasks/task_manager.py @@ -3,7 +3,7 @@ from a2a.server.context import ServerCallContext from a2a.server.events.event_queue import Event from a2a.server.tasks.task_store import TaskStore -from a2a.types import ( +from a2a.types.a2a_pb2 import ( InvalidParamsError, Message, Task, @@ -226,7 +226,7 @@ def _init_task_obj(self, task_id: str, context_id: str) -> Task: return Task( id=task_id, context_id=context_id, - status=TaskStatus(state=TaskState.submitted), + status=TaskStatus(state=TaskState.TASK_STATE_SUBMITTED), history=history, ) diff --git a/src/a2a/server/tasks/task_store.py b/src/a2a/server/tasks/task_store.py index 16b36edb9..a28af7ccd 100644 --- a/src/a2a/server/tasks/task_store.py +++ b/src/a2a/server/tasks/task_store.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod from a2a.server.context import ServerCallContext -from a2a.types import Task +from a2a.types.a2a_pb2 import Task class TaskStore(ABC): diff --git a/src/a2a/server/tasks/task_updater.py b/src/a2a/server/tasks/task_updater.py index b61ab7001..12debcc23 100644 --- a/src/a2a/server/tasks/task_updater.py +++ b/src/a2a/server/tasks/task_updater.py @@ -9,7 +9,7 @@ IDGeneratorContext, UUIDGenerator, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Artifact, Message, Part, @@ -50,10 +50,10 @@ def __init__( self._lock = asyncio.Lock() self._terminal_state_reached = False self._terminal_states = { - TaskState.completed, - TaskState.canceled, - TaskState.failed, - TaskState.rejected, + TaskState.TASK_STATE_COMPLETED, + TaskState.TASK_STATE_CANCELLED, + TaskState.TASK_STATE_FAILED, + TaskState.TASK_STATE_REJECTED, } self._artifact_id_generator = ( artifact_id_generator if artifact_id_generator else UUIDGenerator() @@ -154,39 +154,39 @@ async def add_artifact( # noqa: PLR0913 async def complete(self, message: Message | None = None) -> None: """Marks the task as completed and publishes a final status update.""" await self.update_status( - TaskState.completed, + TaskState.TASK_STATE_COMPLETED, message=message, final=True, ) async def failed(self, message: Message | None = None) -> None: """Marks the task as failed and publishes a final status update.""" - await self.update_status(TaskState.failed, message=message, final=True) + await self.update_status(TaskState.TASK_STATE_FAILED, message=message, final=True) async def reject(self, message: Message | None = None) -> None: """Marks the task as rejected and publishes a final status update.""" await self.update_status( - TaskState.rejected, message=message, final=True + TaskState.TASK_STATE_REJECTED, message=message, final=True ) async def submit(self, message: Message | None = None) -> None: """Marks the task as submitted and publishes a status update.""" await self.update_status( - TaskState.submitted, + TaskState.TASK_STATE_SUBMITTED, message=message, ) async def start_work(self, message: Message | None = None) -> None: """Marks the task as working and publishes a status update.""" await self.update_status( - TaskState.working, + TaskState.TASK_STATE_WORKING, message=message, ) async def cancel(self, message: Message | None = None) -> None: """Marks the task as cancelled and publishes a finalstatus update.""" await self.update_status( - TaskState.canceled, message=message, final=True + TaskState.TASK_STATE_CANCELLED, message=message, final=True ) async def requires_input( @@ -194,7 +194,7 @@ async def requires_input( ) -> None: """Marks the task as input required and publishes a status update.""" await self.update_status( - TaskState.input_required, + TaskState.TASK_STATE_INPUT_REQUIRED, message=message, final=final, ) @@ -204,7 +204,7 @@ async def requires_auth( ) -> None: """Marks the task as auth required and publishes a status update.""" await self.update_status( - TaskState.auth_required, message=message, final=final + TaskState.TASK_STATE_AUTH_REQUIRED, message=message, final=final ) def new_agent_message( diff --git a/src/a2a/types.py b/src/a2a/types.py deleted file mode 100644 index 918a06b5e..000000000 --- a/src/a2a/types.py +++ /dev/null @@ -1,2041 +0,0 @@ -# generated by datamodel-codegen: -# filename: https://raw.githubusercontent.com/a2aproject/A2A/refs/heads/main/specification/json/a2a.json - -from __future__ import annotations - -from enum import Enum -from typing import Any, Literal - -from pydantic import Field, RootModel - -from a2a._base import A2ABaseModel - - -class A2A(RootModel[Any]): - root: Any - - -class In(str, Enum): - """ - The location of the API key. - """ - - cookie = 'cookie' - header = 'header' - query = 'query' - - -class APIKeySecurityScheme(A2ABaseModel): - """ - Defines a security scheme using an API key. - """ - - description: str | None = None - """ - An optional description for the security scheme. - """ - in_: In - """ - The location of the API key. - """ - name: str - """ - The name of the header, query, or cookie parameter to be used. - """ - type: Literal['apiKey'] = 'apiKey' - """ - The type of the security scheme. Must be 'apiKey'. - """ - - -class AgentCardSignature(A2ABaseModel): - """ - AgentCardSignature represents a JWS signature of an AgentCard. - This follows the JSON format of an RFC 7515 JSON Web Signature (JWS). - """ - - header: dict[str, Any] | None = None - """ - The unprotected JWS header values. - """ - protected: str - """ - The protected JWS header for the signature. This is a Base64url-encoded - JSON object, as per RFC 7515. - """ - signature: str - """ - The computed signature, Base64url-encoded. - """ - - -class AgentExtension(A2ABaseModel): - """ - A declaration of a protocol extension supported by an Agent. - """ - - description: str | None = None - """ - A human-readable description of how this agent uses the extension. - """ - params: dict[str, Any] | None = None - """ - Optional, extension-specific configuration parameters. - """ - required: bool | None = None - """ - If true, the client must understand and comply with the extension's requirements - to interact with the agent. - """ - uri: str - """ - The unique URI identifying the extension. - """ - - -class AgentInterface(A2ABaseModel): - """ - Declares a combination of a target URL and a transport protocol for interacting with the agent. - This allows agents to expose the same functionality over multiple transport mechanisms. - """ - - transport: str = Field(..., examples=['JSONRPC', 'GRPC', 'HTTP+JSON']) - """ - The transport protocol supported at this URL. - """ - url: str = Field( - ..., - examples=[ - 'https://api.example.com/a2a/v1', - 'https://grpc.example.com/a2a', - 'https://rest.example.com/v1', - ], - ) - """ - The URL where this interface is available. Must be a valid absolute HTTPS URL in production. - """ - - -class AgentProvider(A2ABaseModel): - """ - Represents the service provider of an agent. - """ - - organization: str - """ - The name of the agent provider's organization. - """ - url: str - """ - A URL for the agent provider's website or relevant documentation. - """ - - -class AgentSkill(A2ABaseModel): - """ - Represents a distinct capability or function that an agent can perform. - """ - - description: str - """ - A detailed description of the skill, intended to help clients or users - understand its purpose and functionality. - """ - examples: list[str] | None = Field( - default=None, examples=[['I need a recipe for bread']] - ) - """ - Example prompts or scenarios that this skill can handle. Provides a hint to - the client on how to use the skill. - """ - id: str - """ - A unique identifier for the agent's skill. - """ - input_modes: list[str] | None = None - """ - The set of supported input MIME types for this skill, overriding the agent's defaults. - """ - name: str - """ - A human-readable name for the skill. - """ - output_modes: list[str] | None = None - """ - The set of supported output MIME types for this skill, overriding the agent's defaults. - """ - security: list[dict[str, list[str]]] | None = Field( - default=None, examples=[[{'google': ['oidc']}]] - ) - """ - 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). - """ - tags: list[str] = Field( - ..., examples=[['cooking', 'customer support', 'billing']] - ) - """ - A set of keywords describing the skill's capabilities. - """ - - -class AuthenticatedExtendedCardNotConfiguredError(A2ABaseModel): - """ - An A2A-specific error indicating that the agent does not have an Authenticated Extended Card configured - """ - - code: Literal[-32007] = -32007 - """ - The error code for when an authenticated extended card is not configured. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Authenticated Extended Card is not configured' - """ - The error message. - """ - - -class AuthorizationCodeOAuthFlow(A2ABaseModel): - """ - Defines configuration details for the OAuth 2.0 Authorization Code flow. - """ - - authorization_url: str - """ - The authorization URL to be used for this flow. - This MUST be a URL and use TLS. - """ - refresh_url: str | None = None - """ - The URL to be used for obtaining refresh tokens. - This MUST be a URL and use TLS. - """ - scopes: dict[str, str] - """ - The available scopes for the OAuth2 security scheme. A map between the scope - name and a short description for it. - """ - token_url: str - """ - The token URL to be used for this flow. - This MUST be a URL and use TLS. - """ - - -class ClientCredentialsOAuthFlow(A2ABaseModel): - """ - Defines configuration details for the OAuth 2.0 Client Credentials flow. - """ - - refresh_url: str | None = None - """ - The URL to be used for obtaining refresh tokens. This MUST be a URL. - """ - scopes: dict[str, str] - """ - The available scopes for the OAuth2 security scheme. A map between the scope - name and a short description for it. - """ - token_url: str - """ - The token URL to be used for this flow. This MUST be a URL. - """ - - -class ContentTypeNotSupportedError(A2ABaseModel): - """ - An A2A-specific error indicating an incompatibility between the requested - content types and the agent's capabilities. - """ - - code: Literal[-32005] = -32005 - """ - The error code for an unsupported content type. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Incompatible content types' - """ - The error message. - """ - - -class DataPart(A2ABaseModel): - """ - Represents a structured data segment (e.g., JSON) within a message or artifact. - """ - - data: dict[str, Any] - """ - The structured data content. - """ - kind: Literal['data'] = 'data' - """ - The type of this part, used as a discriminator. Always 'data'. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata associated with this part. - """ - - -class DeleteTaskPushNotificationConfigParams(A2ABaseModel): - """ - Defines parameters for deleting a specific push notification configuration for a task. - """ - - id: str - """ - The unique identifier (e.g. UUID) of the task. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata associated with the request. - """ - push_notification_config_id: str - """ - The ID of the push notification configuration to delete. - """ - - -class DeleteTaskPushNotificationConfigRequest(A2ABaseModel): - """ - Represents a JSON-RPC request for the `tasks/pushNotificationConfig/delete` method. - """ - - id: str | int - """ - The identifier for this request. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: Literal['tasks/pushNotificationConfig/delete'] = ( - 'tasks/pushNotificationConfig/delete' - ) - """ - The method name. Must be 'tasks/pushNotificationConfig/delete'. - """ - params: DeleteTaskPushNotificationConfigParams - """ - The parameters identifying the push notification configuration to delete. - """ - - -class DeleteTaskPushNotificationConfigSuccessResponse(A2ABaseModel): - """ - Represents a successful JSON-RPC response for the `tasks/pushNotificationConfig/delete` method. - """ - - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - result: None - """ - The result is null on successful deletion. - """ - - -class FileBase(A2ABaseModel): - """ - Defines base properties for a file. - """ - - mime_type: str | None = None - """ - The MIME type of the file (e.g., "application/pdf"). - """ - name: str | None = None - """ - An optional name for the file (e.g., "document.pdf"). - """ - - -class FileWithBytes(A2ABaseModel): - """ - Represents a file with its content provided directly as a base64-encoded string. - """ - - bytes: str - """ - The base64-encoded content of the file. - """ - mime_type: str | None = None - """ - The MIME type of the file (e.g., "application/pdf"). - """ - name: str | None = None - """ - An optional name for the file (e.g., "document.pdf"). - """ - - -class FileWithUri(A2ABaseModel): - """ - Represents a file with its content located at a specific URI. - """ - - mime_type: str | None = None - """ - The MIME type of the file (e.g., "application/pdf"). - """ - name: str | None = None - """ - An optional name for the file (e.g., "document.pdf"). - """ - uri: str - """ - A URL pointing to the file's content. - """ - - -class GetAuthenticatedExtendedCardRequest(A2ABaseModel): - """ - Represents a JSON-RPC request for the `agent/getAuthenticatedExtendedCard` method. - """ - - id: str | int - """ - The identifier for this request. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: Literal['agent/getAuthenticatedExtendedCard'] = ( - 'agent/getAuthenticatedExtendedCard' - ) - """ - The method name. Must be 'agent/getAuthenticatedExtendedCard'. - """ - - -class GetTaskPushNotificationConfigParams(A2ABaseModel): - """ - Defines parameters for fetching a specific push notification configuration for a task. - """ - - id: str - """ - The unique identifier (e.g. UUID) of the task. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata associated with the request. - """ - push_notification_config_id: str | None = None - """ - The ID of the push notification configuration to retrieve. - """ - - -class HTTPAuthSecurityScheme(A2ABaseModel): - """ - Defines a security scheme using HTTP authentication. - """ - - bearer_format: str | None = None - """ - A hint to the client to identify how the bearer token is formatted (e.g., "JWT"). - This is primarily for documentation purposes. - """ - description: str | None = None - """ - An optional description for the security scheme. - """ - scheme: str - """ - The name of the HTTP Authentication scheme to be used in the Authorization header, - as defined in RFC7235 (e.g., "Bearer"). - This value should be registered in the IANA Authentication Scheme registry. - """ - type: Literal['http'] = 'http' - """ - The type of the security scheme. Must be 'http'. - """ - - -class ImplicitOAuthFlow(A2ABaseModel): - """ - Defines configuration details for the OAuth 2.0 Implicit flow. - """ - - authorization_url: str - """ - The authorization URL to be used for this flow. This MUST be a URL. - """ - refresh_url: str | None = None - """ - The URL to be used for obtaining refresh tokens. This MUST be a URL. - """ - scopes: dict[str, str] - """ - The available scopes for the OAuth2 security scheme. A map between the scope - name and a short description for it. - """ - - -class InternalError(A2ABaseModel): - """ - An error indicating an internal error on the server. - """ - - code: Literal[-32603] = -32603 - """ - The error code for an internal server error. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Internal error' - """ - The error message. - """ - - -class InvalidAgentResponseError(A2ABaseModel): - """ - An A2A-specific error indicating that the agent returned a response that - does not conform to the specification for the current method. - """ - - code: Literal[-32006] = -32006 - """ - The error code for an invalid agent response. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Invalid agent response' - """ - The error message. - """ - - -class InvalidParamsError(A2ABaseModel): - """ - An error indicating that the method parameters are invalid. - """ - - code: Literal[-32602] = -32602 - """ - The error code for an invalid parameters error. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Invalid parameters' - """ - The error message. - """ - - -class InvalidRequestError(A2ABaseModel): - """ - An error indicating that the JSON sent is not a valid Request object. - """ - - code: Literal[-32600] = -32600 - """ - The error code for an invalid request. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Request payload validation error' - """ - The error message. - """ - - -class JSONParseError(A2ABaseModel): - """ - An error indicating that the server received invalid JSON. - """ - - code: Literal[-32700] = -32700 - """ - The error code for a JSON parse error. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Invalid JSON payload' - """ - The error message. - """ - - -class JSONRPCError(A2ABaseModel): - """ - Represents a JSON-RPC 2.0 Error object, included in an error response. - """ - - code: int - """ - A number that indicates the error type that occurred. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str - """ - A string providing a short description of the error. - """ - - -class JSONRPCMessage(A2ABaseModel): - """ - Defines the base structure for any JSON-RPC 2.0 request, response, or notification. - """ - - id: str | int | None = None - """ - A unique identifier established by the client. It must be a String, a Number, or null. - The server must reply with the same value in the response. This property is omitted for notifications. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - - -class JSONRPCRequest(A2ABaseModel): - """ - Represents a JSON-RPC 2.0 Request object. - """ - - id: str | int | None = None - """ - A unique identifier established by the client. It must be a String, a Number, or null. - The server must reply with the same value in the response. This property is omitted for notifications. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: str - """ - A string containing the name of the method to be invoked. - """ - params: dict[str, Any] | None = None - """ - A structured value holding the parameter values to be used during the method invocation. - """ - - -class JSONRPCSuccessResponse(A2ABaseModel): - """ - Represents a successful JSON-RPC 2.0 Response object. - """ - - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - result: Any - """ - The value of this member is determined by the method invoked on the Server. - """ - - -class ListTaskPushNotificationConfigParams(A2ABaseModel): - """ - Defines parameters for listing all push notification configurations associated with a task. - """ - - id: str - """ - The unique identifier (e.g. UUID) of the task. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata associated with the request. - """ - - -class ListTaskPushNotificationConfigRequest(A2ABaseModel): - """ - Represents a JSON-RPC request for the `tasks/pushNotificationConfig/list` method. - """ - - id: str | int - """ - The identifier for this request. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: Literal['tasks/pushNotificationConfig/list'] = ( - 'tasks/pushNotificationConfig/list' - ) - """ - The method name. Must be 'tasks/pushNotificationConfig/list'. - """ - params: ListTaskPushNotificationConfigParams - """ - The parameters identifying the task whose configurations are to be listed. - """ - - -class Role(str, Enum): - """ - Identifies the sender of the message. `user` for the client, `agent` for the service. - """ - - agent = 'agent' - user = 'user' - - -class MethodNotFoundError(A2ABaseModel): - """ - An error indicating that the requested method does not exist or is not available. - """ - - code: Literal[-32601] = -32601 - """ - The error code for a method not found error. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Method not found' - """ - The error message. - """ - - -class MutualTLSSecurityScheme(A2ABaseModel): - """ - Defines a security scheme using mTLS authentication. - """ - - description: str | None = None - """ - An optional description for the security scheme. - """ - type: Literal['mutualTLS'] = 'mutualTLS' - """ - The type of the security scheme. Must be 'mutualTLS'. - """ - - -class OpenIdConnectSecurityScheme(A2ABaseModel): - """ - Defines a security scheme using OpenID Connect. - """ - - description: str | None = None - """ - An optional description for the security scheme. - """ - open_id_connect_url: str - """ - The OpenID Connect Discovery URL for the OIDC provider's metadata. - """ - type: Literal['openIdConnect'] = 'openIdConnect' - """ - The type of the security scheme. Must be 'openIdConnect'. - """ - - -class PartBase(A2ABaseModel): - """ - Defines base properties common to all message or artifact parts. - """ - - metadata: dict[str, Any] | None = None - """ - Optional metadata associated with this part. - """ - - -class PasswordOAuthFlow(A2ABaseModel): - """ - Defines configuration details for the OAuth 2.0 Resource Owner Password flow. - """ - - refresh_url: str | None = None - """ - The URL to be used for obtaining refresh tokens. This MUST be a URL. - """ - scopes: dict[str, str] - """ - The available scopes for the OAuth2 security scheme. A map between the scope - name and a short description for it. - """ - token_url: str - """ - The token URL to be used for this flow. This MUST be a URL. - """ - - -class PushNotificationAuthenticationInfo(A2ABaseModel): - """ - Defines authentication details for a push notification endpoint. - """ - - credentials: str | None = None - """ - Optional credentials required by the push notification endpoint. - """ - schemes: list[str] - """ - A list of supported authentication schemes (e.g., 'Basic', 'Bearer'). - """ - - -class PushNotificationConfig(A2ABaseModel): - """ - Defines the configuration for setting up push notifications for task updates. - """ - - authentication: PushNotificationAuthenticationInfo | None = None - """ - Optional authentication details for the agent to use when calling the notification URL. - """ - id: str | None = None - """ - A unique identifier (e.g. UUID) for the push notification configuration, set by the client - to support multiple notification callbacks. - """ - token: str | None = None - """ - A unique token for this task or session to validate incoming push notifications. - """ - url: str - """ - The callback URL where the agent should send push notifications. - """ - - -class PushNotificationNotSupportedError(A2ABaseModel): - """ - An A2A-specific error indicating that the agent does not support push notifications. - """ - - code: Literal[-32003] = -32003 - """ - The error code for when push notifications are not supported. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Push Notification is not supported' - """ - The error message. - """ - - -class SecuritySchemeBase(A2ABaseModel): - """ - Defines base properties shared by all security scheme objects. - """ - - description: str | None = None - """ - An optional description for the security scheme. - """ - - -class TaskIdParams(A2ABaseModel): - """ - Defines parameters containing a task ID, used for simple task operations. - """ - - id: str - """ - The unique identifier (e.g. UUID) of the task. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata associated with the request. - """ - - -class TaskNotCancelableError(A2ABaseModel): - """ - An A2A-specific error indicating that the task is in a state where it cannot be canceled. - """ - - code: Literal[-32002] = -32002 - """ - The error code for a task that cannot be canceled. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Task cannot be canceled' - """ - The error message. - """ - - -class TaskNotFoundError(A2ABaseModel): - """ - An A2A-specific error indicating that the requested task ID was not found. - """ - - code: Literal[-32001] = -32001 - """ - The error code for a task not found error. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'Task not found' - """ - The error message. - """ - - -class TaskPushNotificationConfig(A2ABaseModel): - """ - A container associating a push notification configuration with a specific task. - """ - - push_notification_config: PushNotificationConfig - """ - The push notification configuration for this task. - """ - task_id: str - """ - The unique identifier (e.g. UUID) of the task. - """ - - -class TaskQueryParams(A2ABaseModel): - """ - Defines parameters for querying a task, with an option to limit history length. - """ - - history_length: int | None = None - """ - The number of most recent messages from the task's history to retrieve. - """ - id: str - """ - The unique identifier (e.g. UUID) of the task. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata associated with the request. - """ - - -class TaskResubscriptionRequest(A2ABaseModel): - """ - Represents a JSON-RPC request for the `tasks/resubscribe` method, used to resume a streaming connection. - """ - - id: str | int - """ - The identifier for this request. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: Literal['tasks/resubscribe'] = 'tasks/resubscribe' - """ - The method name. Must be 'tasks/resubscribe'. - """ - params: TaskIdParams - """ - The parameters identifying the task to resubscribe to. - """ - - -class TaskState(str, Enum): - """ - Defines the lifecycle states of a Task. - """ - - submitted = 'submitted' - working = 'working' - input_required = 'input-required' - completed = 'completed' - canceled = 'canceled' - failed = 'failed' - rejected = 'rejected' - auth_required = 'auth-required' - unknown = 'unknown' - - -class TextPart(A2ABaseModel): - """ - Represents a text segment within a message or artifact. - """ - - kind: Literal['text'] = 'text' - """ - The type of this part, used as a discriminator. Always 'text'. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata associated with this part. - """ - text: str - """ - The string content of the text part. - """ - - -class TransportProtocol(str, Enum): - """ - Supported A2A transport protocols. - """ - - jsonrpc = 'JSONRPC' - grpc = 'GRPC' - http_json = 'HTTP+JSON' - - -class UnsupportedOperationError(A2ABaseModel): - """ - An A2A-specific error indicating that the requested operation is not supported by the agent. - """ - - code: Literal[-32004] = -32004 - """ - The error code for an unsupported operation. - """ - data: Any | None = None - """ - A primitive or structured value containing additional information about the error. - This may be omitted. - """ - message: str | None = 'This operation is not supported' - """ - The error message. - """ - - -class A2AError( - RootModel[ - JSONParseError - | InvalidRequestError - | MethodNotFoundError - | InvalidParamsError - | InternalError - | TaskNotFoundError - | TaskNotCancelableError - | PushNotificationNotSupportedError - | UnsupportedOperationError - | ContentTypeNotSupportedError - | InvalidAgentResponseError - | AuthenticatedExtendedCardNotConfiguredError - ] -): - root: ( - JSONParseError - | InvalidRequestError - | MethodNotFoundError - | InvalidParamsError - | InternalError - | TaskNotFoundError - | TaskNotCancelableError - | PushNotificationNotSupportedError - | UnsupportedOperationError - | ContentTypeNotSupportedError - | InvalidAgentResponseError - | AuthenticatedExtendedCardNotConfiguredError - ) - """ - A discriminated union of all standard JSON-RPC and A2A-specific error types. - """ - - -class AgentCapabilities(A2ABaseModel): - """ - Defines optional capabilities supported by an agent. - """ - - extensions: list[AgentExtension] | None = None - """ - A list of protocol extensions supported by the agent. - """ - push_notifications: bool | None = None - """ - Indicates if the agent supports sending push notifications for asynchronous task updates. - """ - state_transition_history: bool | None = None - """ - Indicates if the agent provides a history of state transitions for a task. - """ - streaming: bool | None = None - """ - Indicates if the agent supports Server-Sent Events (SSE) for streaming responses. - """ - - -class CancelTaskRequest(A2ABaseModel): - """ - Represents a JSON-RPC request for the `tasks/cancel` method. - """ - - id: str | int - """ - The identifier for this request. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: Literal['tasks/cancel'] = 'tasks/cancel' - """ - The method name. Must be 'tasks/cancel'. - """ - params: TaskIdParams - """ - The parameters identifying the task to cancel. - """ - - -class FilePart(A2ABaseModel): - """ - Represents a file segment within a message or artifact. The file content can be - provided either directly as bytes or as a URI. - """ - - file: FileWithBytes | FileWithUri - """ - The file content, represented as either a URI or as base64-encoded bytes. - """ - kind: Literal['file'] = 'file' - """ - The type of this part, used as a discriminator. Always 'file'. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata associated with this part. - """ - - -class GetTaskPushNotificationConfigRequest(A2ABaseModel): - """ - Represents a JSON-RPC request for the `tasks/pushNotificationConfig/get` method. - """ - - id: str | int - """ - The identifier for this request. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: Literal['tasks/pushNotificationConfig/get'] = ( - 'tasks/pushNotificationConfig/get' - ) - """ - The method name. Must be 'tasks/pushNotificationConfig/get'. - """ - params: TaskIdParams | GetTaskPushNotificationConfigParams - """ - The parameters for getting a push notification configuration. - """ - - -class GetTaskPushNotificationConfigSuccessResponse(A2ABaseModel): - """ - Represents a successful JSON-RPC response for the `tasks/pushNotificationConfig/get` method. - """ - - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - result: TaskPushNotificationConfig - """ - The result, containing the requested push notification configuration. - """ - - -class GetTaskRequest(A2ABaseModel): - """ - Represents a JSON-RPC request for the `tasks/get` method. - """ - - id: str | int - """ - The identifier for this request. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: Literal['tasks/get'] = 'tasks/get' - """ - The method name. Must be 'tasks/get'. - """ - params: TaskQueryParams - """ - The parameters for querying a task. - """ - - -class JSONRPCErrorResponse(A2ABaseModel): - """ - Represents a JSON-RPC 2.0 Error Response object. - """ - - error: ( - JSONRPCError - | JSONParseError - | InvalidRequestError - | MethodNotFoundError - | InvalidParamsError - | InternalError - | TaskNotFoundError - | TaskNotCancelableError - | PushNotificationNotSupportedError - | UnsupportedOperationError - | ContentTypeNotSupportedError - | InvalidAgentResponseError - | AuthenticatedExtendedCardNotConfiguredError - ) - """ - An object describing the error that occurred. - """ - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - - -class ListTaskPushNotificationConfigSuccessResponse(A2ABaseModel): - """ - Represents a successful JSON-RPC response for the `tasks/pushNotificationConfig/list` method. - """ - - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - result: list[TaskPushNotificationConfig] - """ - The result, containing an array of all push notification configurations for the task. - """ - - -class MessageSendConfiguration(A2ABaseModel): - """ - Defines configuration options for a `message/send` or `message/stream` request. - """ - - accepted_output_modes: list[str] | None = None - """ - A list of output MIME types the client is prepared to accept in the response. - """ - blocking: bool | None = None - """ - If true, the client will wait for the task to complete. The server may reject this if the task is long-running. - """ - history_length: int | None = None - """ - The number of most recent messages from the task's history to retrieve in the response. - """ - push_notification_config: PushNotificationConfig | None = None - """ - Configuration for the agent to send push notifications for updates after the initial response. - """ - - -class OAuthFlows(A2ABaseModel): - """ - Defines the configuration for the supported OAuth 2.0 flows. - """ - - authorization_code: AuthorizationCodeOAuthFlow | None = None - """ - Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0. - """ - client_credentials: ClientCredentialsOAuthFlow | None = None - """ - Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. - """ - implicit: ImplicitOAuthFlow | None = None - """ - Configuration for the OAuth Implicit flow. - """ - password: PasswordOAuthFlow | None = None - """ - Configuration for the OAuth Resource Owner Password flow. - """ - - -class Part(RootModel[TextPart | FilePart | DataPart]): - root: TextPart | FilePart | DataPart - """ - A discriminated union representing a part of a message or artifact, which can - be text, a file, or structured data. - """ - - -class SetTaskPushNotificationConfigRequest(A2ABaseModel): - """ - Represents a JSON-RPC request for the `tasks/pushNotificationConfig/set` method. - """ - - id: str | int - """ - The identifier for this request. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: Literal['tasks/pushNotificationConfig/set'] = ( - 'tasks/pushNotificationConfig/set' - ) - """ - The method name. Must be 'tasks/pushNotificationConfig/set'. - """ - params: TaskPushNotificationConfig - """ - The parameters for setting the push notification configuration. - """ - - -class SetTaskPushNotificationConfigSuccessResponse(A2ABaseModel): - """ - Represents a successful JSON-RPC response for the `tasks/pushNotificationConfig/set` method. - """ - - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - result: TaskPushNotificationConfig - """ - The result, containing the configured push notification settings. - """ - - -class Artifact(A2ABaseModel): - """ - Represents a file, data structure, or other resource generated by an agent during a task. - """ - - artifact_id: str - """ - A unique identifier (e.g. UUID) for the artifact within the scope of the task. - """ - description: str | None = None - """ - An optional, human-readable description of the artifact. - """ - extensions: list[str] | None = None - """ - The URIs of extensions that are relevant to this artifact. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata for extensions. The key is an extension-specific identifier. - """ - name: str | None = None - """ - An optional, human-readable name for the artifact. - """ - parts: list[Part] - """ - An array of content parts that make up the artifact. - """ - - -class DeleteTaskPushNotificationConfigResponse( - RootModel[ - JSONRPCErrorResponse | DeleteTaskPushNotificationConfigSuccessResponse - ] -): - root: JSONRPCErrorResponse | DeleteTaskPushNotificationConfigSuccessResponse - """ - Represents a JSON-RPC response for the `tasks/pushNotificationConfig/delete` method. - """ - - -class GetTaskPushNotificationConfigResponse( - RootModel[ - JSONRPCErrorResponse | GetTaskPushNotificationConfigSuccessResponse - ] -): - root: JSONRPCErrorResponse | GetTaskPushNotificationConfigSuccessResponse - """ - Represents a JSON-RPC response for the `tasks/pushNotificationConfig/get` method. - """ - - -class ListTaskPushNotificationConfigResponse( - RootModel[ - JSONRPCErrorResponse | ListTaskPushNotificationConfigSuccessResponse - ] -): - root: JSONRPCErrorResponse | ListTaskPushNotificationConfigSuccessResponse - """ - Represents a JSON-RPC response for the `tasks/pushNotificationConfig/list` method. - """ - - -class Message(A2ABaseModel): - """ - Represents a single message in the conversation between a user and an agent. - """ - - context_id: str | None = None - """ - The context ID for this message, used to group related interactions. - """ - extensions: list[str] | None = None - """ - The URIs of extensions that are relevant to this message. - """ - kind: Literal['message'] = 'message' - """ - The type of this object, used as a discriminator. Always 'message' for a Message. - """ - message_id: str - """ - A unique identifier for the message, typically a UUID, generated by the sender. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata for extensions. The key is an extension-specific identifier. - """ - parts: list[Part] - """ - An array of content parts that form the message body. A message can be - composed of multiple parts of different types (e.g., text and files). - """ - reference_task_ids: list[str] | None = None - """ - A list of other task IDs that this message references for additional context. - """ - role: Role - """ - Identifies the sender of the message. `user` for the client, `agent` for the service. - """ - task_id: str | None = None - """ - The ID of the task this message is part of. Can be omitted for the first message of a new task. - """ - - -class MessageSendParams(A2ABaseModel): - """ - Defines the parameters for a request to send a message to an agent. This can be used - to create a new task, continue an existing one, or restart a task. - """ - - configuration: MessageSendConfiguration | None = None - """ - Optional configuration for the send request. - """ - message: Message - """ - The message object being sent to the agent. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata for extensions. - """ - - -class OAuth2SecurityScheme(A2ABaseModel): - """ - Defines a security scheme using OAuth 2.0. - """ - - description: str | None = None - """ - An optional description for the security scheme. - """ - flows: OAuthFlows - """ - An object containing configuration information for the supported OAuth 2.0 flows. - """ - oauth2_metadata_url: str | None = None - """ - URL to the oauth2 authorization server metadata - [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414). TLS is required. - """ - type: Literal['oauth2'] = 'oauth2' - """ - The type of the security scheme. Must be 'oauth2'. - """ - - -class SecurityScheme( - RootModel[ - APIKeySecurityScheme - | HTTPAuthSecurityScheme - | OAuth2SecurityScheme - | OpenIdConnectSecurityScheme - | MutualTLSSecurityScheme - ] -): - root: ( - APIKeySecurityScheme - | HTTPAuthSecurityScheme - | OAuth2SecurityScheme - | OpenIdConnectSecurityScheme - | MutualTLSSecurityScheme - ) - """ - Defines a security scheme that can be used to secure an agent's endpoints. - This is a discriminated union type based on the OpenAPI 3.0 Security Scheme Object. - """ - - -class SendMessageRequest(A2ABaseModel): - """ - Represents a JSON-RPC request for the `message/send` method. - """ - - id: str | int - """ - The identifier for this request. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: Literal['message/send'] = 'message/send' - """ - The method name. Must be 'message/send'. - """ - params: MessageSendParams - """ - The parameters for sending a message. - """ - - -class SendStreamingMessageRequest(A2ABaseModel): - """ - Represents a JSON-RPC request for the `message/stream` method. - """ - - id: str | int - """ - The identifier for this request. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - method: Literal['message/stream'] = 'message/stream' - """ - The method name. Must be 'message/stream'. - """ - params: MessageSendParams - """ - The parameters for sending a message. - """ - - -class SetTaskPushNotificationConfigResponse( - RootModel[ - JSONRPCErrorResponse | SetTaskPushNotificationConfigSuccessResponse - ] -): - root: JSONRPCErrorResponse | SetTaskPushNotificationConfigSuccessResponse - """ - Represents a JSON-RPC response for the `tasks/pushNotificationConfig/set` method. - """ - - -class TaskArtifactUpdateEvent(A2ABaseModel): - """ - An event sent by the agent to notify the client that an artifact has been - generated or updated. This is typically used in streaming models. - """ - - append: bool | None = None - """ - If true, the content of this artifact should be appended to a previously sent artifact with the same ID. - """ - artifact: Artifact - """ - The artifact that was generated or updated. - """ - context_id: str - """ - The context ID associated with the task. - """ - kind: Literal['artifact-update'] = 'artifact-update' - """ - The type of this event, used as a discriminator. Always 'artifact-update'. - """ - last_chunk: bool | None = None - """ - If true, this is the final chunk of the artifact. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata for extensions. - """ - task_id: str - """ - The ID of the task this artifact belongs to. - """ - - -class TaskStatus(A2ABaseModel): - """ - Represents the status of a task at a specific point in time. - """ - - message: Message | None = None - """ - An optional, human-readable message providing more details about the current status. - """ - state: TaskState - """ - The current state of the task's lifecycle. - """ - timestamp: str | None = Field( - default=None, examples=['2023-10-27T10:00:00Z'] - ) - """ - An ISO 8601 datetime string indicating when this status was recorded. - """ - - -class TaskStatusUpdateEvent(A2ABaseModel): - """ - An event sent by the agent to notify the client of a change in a task's status. - This is typically used in streaming or subscription models. - """ - - context_id: str - """ - The context ID associated with the task. - """ - final: bool - """ - If true, this is the final event in the stream for this interaction. - """ - kind: Literal['status-update'] = 'status-update' - """ - The type of this event, used as a discriminator. Always 'status-update'. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata for extensions. - """ - status: TaskStatus - """ - The new status of the task. - """ - task_id: str - """ - The ID of the task that was updated. - """ - - -class A2ARequest( - RootModel[ - SendMessageRequest - | SendStreamingMessageRequest - | GetTaskRequest - | CancelTaskRequest - | SetTaskPushNotificationConfigRequest - | GetTaskPushNotificationConfigRequest - | TaskResubscriptionRequest - | ListTaskPushNotificationConfigRequest - | DeleteTaskPushNotificationConfigRequest - | GetAuthenticatedExtendedCardRequest - ] -): - root: ( - SendMessageRequest - | SendStreamingMessageRequest - | GetTaskRequest - | CancelTaskRequest - | SetTaskPushNotificationConfigRequest - | GetTaskPushNotificationConfigRequest - | TaskResubscriptionRequest - | ListTaskPushNotificationConfigRequest - | DeleteTaskPushNotificationConfigRequest - | GetAuthenticatedExtendedCardRequest - ) - """ - A discriminated union representing all possible JSON-RPC 2.0 requests supported by the A2A specification. - """ - - -class AgentCard(A2ABaseModel): - """ - The AgentCard is a self-describing manifest for an agent. It provides essential - metadata including the agent's identity, capabilities, skills, supported - communication methods, and security requirements. - """ - - additional_interfaces: list[AgentInterface] | None = None - """ - A list of additional supported interfaces (transport and URL combinations). - This allows agents to expose multiple transports, potentially at different URLs. - - Best practices: - - SHOULD include all supported transports for completeness - - SHOULD include an entry matching the main 'url' and 'preferredTransport' - - MAY reuse URLs if multiple transports are available at the same endpoint - - MUST accurately declare the transport available at each URL - - Clients can select any interface from this list based on their transport capabilities - and preferences. This enables transport negotiation and fallback scenarios. - """ - capabilities: AgentCapabilities - """ - A declaration of optional capabilities supported by the agent. - """ - default_input_modes: list[str] - """ - Default set of supported input MIME types for all skills, which can be - overridden on a per-skill basis. - """ - default_output_modes: list[str] - """ - Default set of supported output MIME types for all skills, which can be - overridden on a per-skill basis. - """ - description: str = Field( - ..., examples=['Agent that helps users with recipes and cooking.'] - ) - """ - A human-readable description of the agent, assisting users and other agents - in understanding its purpose. - """ - documentation_url: str | None = None - """ - An optional URL to the agent's documentation. - """ - icon_url: str | None = None - """ - An optional URL to an icon for the agent. - """ - name: str = Field(..., examples=['Recipe Agent']) - """ - A human-readable name for the agent. - """ - preferred_transport: str | None = Field( - default='JSONRPC', examples=['JSONRPC', 'GRPC', 'HTTP+JSON'] - ) - """ - The transport protocol for the preferred endpoint (the main 'url' field). - If not specified, defaults to 'JSONRPC'. - - IMPORTANT: The transport specified here MUST be available at the main 'url'. - This creates a binding between the main URL and its supported transport protocol. - Clients should prefer this transport and URL combination when both are supported. - """ - protocol_version: str | None = '0.3.0' - """ - The version of the A2A protocol this agent supports. - """ - provider: AgentProvider | None = None - """ - Information about the agent's service provider. - """ - security: list[dict[str, list[str]]] | None = Field( - default=None, - examples=[[{'oauth': ['read']}, {'api-key': [], 'mtls': []}]], - ) - """ - A list of security requirement objects that apply to all agent interactions. Each object - lists security schemes that can be used. Follows the OpenAPI 3.0 Security Requirement Object. - 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." - """ - security_schemes: dict[str, SecurityScheme] | None = None - """ - A declaration of the security schemes available to authorize requests. The key is the - scheme name. Follows the OpenAPI 3.0 Security Scheme Object. - """ - signatures: list[AgentCardSignature] | None = None - """ - JSON Web Signatures computed for this AgentCard. - """ - skills: list[AgentSkill] - """ - The set of skills, or distinct capabilities, that the agent can perform. - """ - supports_authenticated_extended_card: bool | None = None - """ - If true, the agent can provide an extended agent card with additional details - to authenticated users. Defaults to false. - """ - url: str = Field(..., examples=['https://api.example.com/a2a/v1']) - """ - The preferred endpoint URL for interacting with the agent. - This URL MUST support the transport specified by 'preferredTransport'. - """ - version: str = Field(..., examples=['1.0.0']) - """ - The agent's own version number. The format is defined by the provider. - """ - - -class GetAuthenticatedExtendedCardSuccessResponse(A2ABaseModel): - """ - Represents a successful JSON-RPC response for the `agent/getAuthenticatedExtendedCard` method. - """ - - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - result: AgentCard - """ - The result is an Agent Card object. - """ - - -class Task(A2ABaseModel): - """ - Represents a single, stateful operation or conversation between a client and an agent. - """ - - artifacts: list[Artifact] | None = None - """ - A collection of artifacts generated by the agent during the execution of the task. - """ - context_id: str - """ - A server-generated unique identifier (e.g. UUID) for maintaining context across multiple related tasks or interactions. - """ - history: list[Message] | None = None - """ - An array of messages exchanged during the task, representing the conversation history. - """ - id: str - """ - A unique identifier (e.g. UUID) for the task, generated by the server for a new task. - """ - kind: Literal['task'] = 'task' - """ - The type of this object, used as a discriminator. Always 'task' for a Task. - """ - metadata: dict[str, Any] | None = None - """ - Optional metadata for extensions. The key is an extension-specific identifier. - """ - status: TaskStatus - """ - The current status of the task, including its state and a descriptive message. - """ - - -class CancelTaskSuccessResponse(A2ABaseModel): - """ - Represents a successful JSON-RPC response for the `tasks/cancel` method. - """ - - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - result: Task - """ - The result, containing the final state of the canceled Task object. - """ - - -class GetAuthenticatedExtendedCardResponse( - RootModel[ - JSONRPCErrorResponse | GetAuthenticatedExtendedCardSuccessResponse - ] -): - root: JSONRPCErrorResponse | GetAuthenticatedExtendedCardSuccessResponse - """ - Represents a JSON-RPC response for the `agent/getAuthenticatedExtendedCard` method. - """ - - -class GetTaskSuccessResponse(A2ABaseModel): - """ - Represents a successful JSON-RPC response for the `tasks/get` method. - """ - - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - result: Task - """ - The result, containing the requested Task object. - """ - - -class SendMessageSuccessResponse(A2ABaseModel): - """ - Represents a successful JSON-RPC response for the `message/send` method. - """ - - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - result: Task | Message - """ - The result, which can be a direct reply Message or the initial Task object. - """ - - -class SendStreamingMessageSuccessResponse(A2ABaseModel): - """ - Represents a successful JSON-RPC response for the `message/stream` method. - The server may send multiple response objects for a single request. - """ - - id: str | int | None = None - """ - The identifier established by the client. - """ - jsonrpc: Literal['2.0'] = '2.0' - """ - The version of the JSON-RPC protocol. MUST be exactly "2.0". - """ - result: Task | Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent - """ - The result, which can be a Message, Task, or a streaming update event. - """ - - -class CancelTaskResponse( - RootModel[JSONRPCErrorResponse | CancelTaskSuccessResponse] -): - root: JSONRPCErrorResponse | CancelTaskSuccessResponse - """ - Represents a JSON-RPC response for the `tasks/cancel` method. - """ - - -class GetTaskResponse(RootModel[JSONRPCErrorResponse | GetTaskSuccessResponse]): - root: JSONRPCErrorResponse | GetTaskSuccessResponse - """ - Represents a JSON-RPC response for the `tasks/get` method. - """ - - -class JSONRPCResponse( - RootModel[ - JSONRPCErrorResponse - | SendMessageSuccessResponse - | SendStreamingMessageSuccessResponse - | GetTaskSuccessResponse - | CancelTaskSuccessResponse - | SetTaskPushNotificationConfigSuccessResponse - | GetTaskPushNotificationConfigSuccessResponse - | ListTaskPushNotificationConfigSuccessResponse - | DeleteTaskPushNotificationConfigSuccessResponse - | GetAuthenticatedExtendedCardSuccessResponse - ] -): - root: ( - JSONRPCErrorResponse - | SendMessageSuccessResponse - | SendStreamingMessageSuccessResponse - | GetTaskSuccessResponse - | CancelTaskSuccessResponse - | SetTaskPushNotificationConfigSuccessResponse - | GetTaskPushNotificationConfigSuccessResponse - | ListTaskPushNotificationConfigSuccessResponse - | DeleteTaskPushNotificationConfigSuccessResponse - | GetAuthenticatedExtendedCardSuccessResponse - ) - """ - A discriminated union representing all possible JSON-RPC 2.0 responses - for the A2A specification methods. - """ - - -class SendMessageResponse( - RootModel[JSONRPCErrorResponse | SendMessageSuccessResponse] -): - root: JSONRPCErrorResponse | SendMessageSuccessResponse - """ - Represents a JSON-RPC response for the `message/send` method. - """ - - -class SendStreamingMessageResponse( - RootModel[JSONRPCErrorResponse | SendStreamingMessageSuccessResponse] -): - root: JSONRPCErrorResponse | SendStreamingMessageSuccessResponse - """ - Represents a JSON-RPC response for the `message/stream` method. - """ diff --git a/src/a2a/types/a2a_pb2.py b/src/a2a/types/a2a_pb2.py new file mode 100644 index 000000000..1d6220d4c --- /dev/null +++ b/src/a2a/types/a2a_pb2.py @@ -0,0 +1,312 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: a2a.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.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\ta2a.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"\x83\x02\n\x18SendMessageConfiguration\x12\x32\n\x15\x61\x63\x63\x65pted_output_modes\x18\x01 \x03(\tR\x13\x61\x63\x63\x65ptedOutputModes\x12X\n\x18push_notification_config\x18\x02 \x01(\x0b\x32\x1e.a2a.v1.PushNotificationConfigR\x16pushNotificationConfig\x12*\n\x0ehistory_length\x18\x03 \x01(\x05H\x00R\rhistoryLength\x88\x01\x01\x12\x1a\n\x08\x62locking\x18\x04 \x01(\x08R\x08\x62lockingB\x11\n\x0f_history_length"\x80\x02\n\x04Task\x12\x13\n\x02id\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x02id\x12"\n\ncontext_id\x18\x02 \x01(\tB\x03\xe0\x41\x02R\tcontextId\x12/\n\x06status\x18\x03 \x01(\x0b\x32\x12.a2a.v1.TaskStatusB\x03\xe0\x41\x02R\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"\x9f\x01\n\nTaskStatus\x12,\n\x05state\x18\x01 \x01(\x0e\x32\x11.a2a.v1.TaskStateB\x03\xe0\x41\x02R\x05state\x12)\n\x07message\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"\x95\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\x1d\n\nmedia_type\x18\x03 \x01(\tR\tmediaType\x12\x12\n\x04name\x18\x04 \x01(\tR\x04nameB\x06\n\x04\x66ile"<\n\x08\x44\x61taPart\x12\x30\n\x04\x64\x61ta\x18\x01 \x01(\x0b\x32\x17.google.protobuf.StructB\x03\xe0\x41\x02R\x04\x64\x61ta"\xb8\x02\n\x07Message\x12"\n\nmessage_id\x18\x01 \x01(\tB\x03\xe0\x41\x02R\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.RoleB\x03\xe0\x41\x02R\x04role\x12\'\n\x05parts\x18\x05 \x03(\x0b\x32\x0c.a2a.v1.PartB\x03\xe0\x41\x02R\x05parts\x12\x33\n\x08metadata\x18\x06 \x01(\x0b\x32\x17.google.protobuf.StructR\x08metadata\x12\x1e\n\nextensions\x18\x07 \x03(\tR\nextensions\x12,\n\x12reference_task_ids\x18\x08 \x03(\tR\x10referenceTaskIds"\xe4\x01\n\x08\x41rtifact\x12$\n\x0b\x61rtifact_id\x18\x01 \x01(\tB\x03\xe0\x41\x02R\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.PartB\x03\xe0\x41\x02R\x05parts\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\x15TaskStatusUpdateEvent\x12\x1c\n\x07task_id\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x06taskId\x12"\n\ncontext_id\x18\x02 \x01(\tB\x03\xe0\x41\x02R\tcontextId\x12/\n\x06status\x18\x03 \x01(\x0b\x32\x12.a2a.v1.TaskStatusB\x03\xe0\x41\x02R\x06status\x12\x19\n\x05\x66inal\x18\x04 \x01(\x08\x42\x03\xe0\x41\x02R\x05\x66inal\x12\x33\n\x08metadata\x18\x05 \x01(\x0b\x32\x17.google.protobuf.StructR\x08metadata"\xfa\x01\n\x17TaskArtifactUpdateEvent\x12\x1c\n\x07task_id\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x06taskId\x12"\n\ncontext_id\x18\x02 \x01(\tB\x03\xe0\x41\x02R\tcontextId\x12\x31\n\x08\x61rtifact\x18\x03 \x01(\x0b\x32\x10.a2a.v1.ArtifactB\x03\xe0\x41\x02R\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"\x99\x01\n\x16PushNotificationConfig\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x15\n\x03url\x18\x02 \x01(\tB\x03\xe0\x41\x02R\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"U\n\x12\x41uthenticationInfo\x12\x1d\n\x07schemes\x18\x01 \x03(\tB\x03\xe0\x41\x02R\x07schemes\x12 \n\x0b\x63redentials\x18\x02 \x01(\tR\x0b\x63redentials"W\n\x0e\x41gentInterface\x12\x15\n\x03url\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x03url\x12.\n\x10protocol_binding\x18\x02 \x01(\tB\x03\xe0\x41\x02R\x0fprotocolBinding"\xe6\t\n\tAgentCard\x12\x33\n\x10protocol_version\x18\x10 \x01(\tB\x03\xe0\x41\x02H\x00R\x0fprotocolVersion\x88\x01\x01\x12\x17\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x04name\x12%\n\x0b\x64\x65scription\x18\x02 \x01(\tB\x03\xe0\x41\x02R\x0b\x64\x65scription\x12I\n\x14supported_interfaces\x18\x13 \x03(\x0b\x32\x16.a2a.v1.AgentInterfaceR\x13supportedInterfaces\x12\x19\n\x03url\x18\x03 \x01(\tB\x02\x18\x01H\x01R\x03url\x88\x01\x01\x12\x38\n\x13preferred_transport\x18\x0e \x01(\tB\x02\x18\x01H\x02R\x12preferredTransport\x88\x01\x01\x12O\n\x15\x61\x64\x64itional_interfaces\x18\x0f \x03(\x0b\x32\x16.a2a.v1.AgentInterfaceB\x02\x18\x01R\x14\x61\x64\x64itionalInterfaces\x12\x31\n\x08provider\x18\x04 \x01(\x0b\x32\x15.a2a.v1.AgentProviderR\x08provider\x12\x1d\n\x07version\x18\x05 \x01(\tB\x03\xe0\x41\x02R\x07version\x12\x30\n\x11\x64ocumentation_url\x18\x06 \x01(\tH\x03R\x10\x64ocumentationUrl\x88\x01\x01\x12\x42\n\x0c\x63\x61pabilities\x18\x07 \x01(\x0b\x32\x19.a2a.v1.AgentCapabilitiesB\x03\xe0\x41\x02R\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\x33\n\x13\x64\x65\x66\x61ult_input_modes\x18\n \x03(\tB\x03\xe0\x41\x02R\x11\x64\x65\x66\x61ultInputModes\x12\x35\n\x14\x64\x65\x66\x61ult_output_modes\x18\x0b \x03(\tB\x03\xe0\x41\x02R\x12\x64\x65\x66\x61ultOutputModes\x12/\n\x06skills\x18\x0c \x03(\x0b\x32\x12.a2a.v1.AgentSkillB\x03\xe0\x41\x02R\x06skills\x12T\n$supports_authenticated_extended_card\x18\r \x01(\x08H\x04R!supportsAuthenticatedExtendedCard\x88\x01\x01\x12:\n\nsignatures\x18\x11 \x03(\x0b\x32\x1a.a2a.v1.AgentCardSignatureR\nsignatures\x12\x1e\n\x08icon_url\x18\x12 \x01(\tH\x05R\x07iconUrl\x88\x01\x01\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\x42\x13\n\x11_protocol_versionB\x06\n\x04_urlB\x16\n\x14_preferred_transportB\x14\n\x12_documentation_urlB\'\n%_supports_authenticated_extended_cardB\x0b\n\t_icon_url"O\n\rAgentProvider\x12\x15\n\x03url\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x03url\x12\'\n\x0corganization\x18\x02 \x01(\tB\x03\xe0\x41\x02R\x0corganization"\xa3\x02\n\x11\x41gentCapabilities\x12!\n\tstreaming\x18\x01 \x01(\x08H\x00R\tstreaming\x88\x01\x01\x12\x32\n\x12push_notifications\x18\x02 \x01(\x08H\x01R\x11pushNotifications\x88\x01\x01\x12\x36\n\nextensions\x18\x03 \x03(\x0b\x32\x16.a2a.v1.AgentExtensionR\nextensions\x12=\n\x18state_transition_history\x18\x04 \x01(\x08H\x02R\x16stateTransitionHistory\x88\x01\x01\x42\x0c\n\n_streamingB\x15\n\x13_push_notificationsB\x1b\n\x19_state_transition_history"\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"\x88\x02\n\nAgentSkill\x12\x13\n\x02id\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x02id\x12\x17\n\x04name\x18\x02 \x01(\tB\x03\xe0\x41\x02R\x04name\x12%\n\x0b\x64\x65scription\x18\x03 \x01(\tB\x03\xe0\x41\x02R\x0b\x64\x65scription\x12\x17\n\x04tags\x18\x04 \x03(\tB\x03\xe0\x41\x02R\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"\x94\x01\n\x1aTaskPushNotificationConfig\x12\x17\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x04name\x12]\n\x18push_notification_config\x18\x02 \x01(\x0b\x32\x1e.a2a.v1.PushNotificationConfigB\x03\xe0\x41\x02R\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"r\n\x14\x41PIKeySecurityScheme\x12 \n\x0b\x64\x65scription\x18\x01 \x01(\tR\x0b\x64\x65scription\x12\x1f\n\x08location\x18\x02 \x01(\tB\x03\xe0\x41\x02R\x08location\x12\x17\n\x04name\x18\x03 \x01(\tB\x03\xe0\x41\x02R\x04name"|\n\x16HTTPAuthSecurityScheme\x12 \n\x0b\x64\x65scription\x18\x01 \x01(\tR\x0b\x64\x65scription\x12\x1b\n\x06scheme\x18\x02 \x01(\tB\x03\xe0\x41\x02R\x06scheme\x12#\n\rbearer_format\x18\x03 \x01(\tR\x0c\x62\x65\x61rerFormat"\x97\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.OAuthFlowsB\x03\xe0\x41\x02R\x05\x66lows\x12.\n\x13oauth2_metadata_url\x18\x03 \x01(\tR\x11oauth2MetadataUrl"s\n\x1bOpenIdConnectSecurityScheme\x12 \n\x0b\x64\x65scription\x18\x01 \x01(\tR\x0b\x64\x65scription\x12\x32\n\x13open_id_connect_url\x18\x02 \x01(\tB\x03\xe0\x41\x02R\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"\x99\x02\n\x1a\x41uthorizationCodeOAuthFlow\x12\x30\n\x11\x61uthorization_url\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x10\x61uthorizationUrl\x12 \n\ttoken_url\x18\x02 \x01(\tB\x03\xe0\x41\x02R\x08tokenUrl\x12\x1f\n\x0brefresh_url\x18\x03 \x01(\tR\nrefreshUrl\x12K\n\x06scopes\x18\x04 \x03(\x0b\x32..a2a.v1.AuthorizationCodeOAuthFlow.ScopesEntryB\x03\xe0\x41\x02R\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"\xe7\x01\n\x1a\x43lientCredentialsOAuthFlow\x12 \n\ttoken_url\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x08tokenUrl\x12\x1f\n\x0brefresh_url\x18\x02 \x01(\tR\nrefreshUrl\x12K\n\x06scopes\x18\x03 \x03(\x0b\x32..a2a.v1.ClientCredentialsOAuthFlow.ScopesEntryB\x03\xe0\x41\x02R\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"\xe5\x01\n\x11ImplicitOAuthFlow\x12\x30\n\x11\x61uthorization_url\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x10\x61uthorizationUrl\x12\x1f\n\x0brefresh_url\x18\x02 \x01(\tR\nrefreshUrl\x12\x42\n\x06scopes\x18\x03 \x03(\x0b\x32%.a2a.v1.ImplicitOAuthFlow.ScopesEntryB\x03\xe0\x41\x02R\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"\xd5\x01\n\x11PasswordOAuthFlow\x12 \n\ttoken_url\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x08tokenUrl\x12\x1f\n\x0brefresh_url\x18\x02 \x01(\tR\nrefreshUrl\x12\x42\n\x06scopes\x18\x03 \x03(\x0b\x32%.a2a.v1.PasswordOAuthFlow.ScopesEntryB\x03\xe0\x41\x02R\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"h\n\x0eGetTaskRequest\x12\x17\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02R\x04name\x12*\n\x0ehistory_length\x18\x02 \x01(\x05H\x00R\rhistoryLength\x88\x01\x01\x42\x11\n\x0f_history_length"\x95\x03\n\x10ListTasksRequest\x12\x1d\n\ncontext_id\x18\x01 \x01(\tR\tcontextId\x12)\n\x06status\x18\x02 \x01(\x0e\x32\x11.a2a.v1.TaskStateR\x06status\x12 \n\tpage_size\x18\x03 \x01(\x05H\x00R\x08pageSize\x88\x01\x01\x12\x1d\n\npage_token\x18\x04 \x01(\tR\tpageToken\x12*\n\x0ehistory_length\x18\x05 \x01(\x05H\x01R\rhistoryLength\x88\x01\x01\x12,\n\x12last_updated_after\x18\x06 \x01(\x03R\x10lastUpdatedAfter\x12\x30\n\x11include_artifacts\x18\x07 \x01(\x08H\x02R\x10includeArtifacts\x88\x01\x01\x12\x33\n\x08metadata\x18\x08 \x01(\x0b\x32\x17.google.protobuf.StructR\x08metadataB\x0c\n\n_page_sizeB\x11\n\x0f_history_lengthB\x14\n\x12_include_artifacts"\xaf\x01\n\x11ListTasksResponse\x12\'\n\x05tasks\x18\x01 \x03(\x0b\x32\x0c.a2a.v1.TaskB\x03\xe0\x41\x02R\x05tasks\x12+\n\x0fnext_page_token\x18\x02 \x01(\tB\x03\xe0\x41\x02R\rnextPageToken\x12 \n\tpage_size\x18\x03 \x01(\x05\x42\x03\xe0\x41\x02R\x08pageSize\x12"\n\ntotal_size\x18\x04 \x01(\x05\x42\x03\xe0\x41\x02R\ttotalSize"\'\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"\xa6\x01\n$SetTaskPushNotificationConfigRequest\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\x16SubscribeToTaskRequest\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"\x1d\n\x1bGetExtendedAgentCardRequest"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\xa5\x0b\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/*}\x12S\n\tListTasks\x12\x18.a2a.v1.ListTasksRequest\x1a\x19.a2a.v1.ListTasksResponse"\x11\x82\xd3\xe4\x93\x02\x0b\x12\t/v1/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*\x12q\n\x0fSubscribeToTask\x12\x1e.a2a.v1.SubscribeToTaskRequest\x1a\x16.a2a.v1.StreamResponse"$\x82\xd3\xe4\x93\x02\x1e\x12\x1c/v1/{name=tasks/*}:subscribe0\x01\x12\xbf\x01\n\x1dSetTaskPushNotificationConfig\x12,.a2a.v1.SetTaskPushNotificationConfigRequest\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\x12m\n\x14GetExtendedAgentCard\x12#.a2a.v1.GetExtendedAgentCardRequest\x1a\x11.a2a.v1.AgentCard"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/v1/extendedAgentCard\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/*}Bi\n\ncom.a2a.v1B\x08\x41\x32\x61ProtoP\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_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\ncom.a2a.v1B\010A2aProtoP\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['_TASK'].fields_by_name['id']._loaded_options = None + _globals['_TASK'].fields_by_name['id']._serialized_options = b'\340A\002' + _globals['_TASK'].fields_by_name['context_id']._loaded_options = None + _globals['_TASK'].fields_by_name['context_id']._serialized_options = b'\340A\002' + _globals['_TASK'].fields_by_name['status']._loaded_options = None + _globals['_TASK'].fields_by_name['status']._serialized_options = b'\340A\002' + _globals['_TASKSTATUS'].fields_by_name['state']._loaded_options = None + _globals['_TASKSTATUS'].fields_by_name['state']._serialized_options = b'\340A\002' + _globals['_DATAPART'].fields_by_name['data']._loaded_options = None + _globals['_DATAPART'].fields_by_name['data']._serialized_options = b'\340A\002' + _globals['_MESSAGE'].fields_by_name['message_id']._loaded_options = None + _globals['_MESSAGE'].fields_by_name['message_id']._serialized_options = b'\340A\002' + _globals['_MESSAGE'].fields_by_name['role']._loaded_options = None + _globals['_MESSAGE'].fields_by_name['role']._serialized_options = b'\340A\002' + _globals['_MESSAGE'].fields_by_name['parts']._loaded_options = None + _globals['_MESSAGE'].fields_by_name['parts']._serialized_options = b'\340A\002' + _globals['_ARTIFACT'].fields_by_name['artifact_id']._loaded_options = None + _globals['_ARTIFACT'].fields_by_name['artifact_id']._serialized_options = b'\340A\002' + _globals['_ARTIFACT'].fields_by_name['parts']._loaded_options = None + _globals['_ARTIFACT'].fields_by_name['parts']._serialized_options = b'\340A\002' + _globals['_TASKSTATUSUPDATEEVENT'].fields_by_name['task_id']._loaded_options = None + _globals['_TASKSTATUSUPDATEEVENT'].fields_by_name['task_id']._serialized_options = b'\340A\002' + _globals['_TASKSTATUSUPDATEEVENT'].fields_by_name['context_id']._loaded_options = None + _globals['_TASKSTATUSUPDATEEVENT'].fields_by_name['context_id']._serialized_options = b'\340A\002' + _globals['_TASKSTATUSUPDATEEVENT'].fields_by_name['status']._loaded_options = None + _globals['_TASKSTATUSUPDATEEVENT'].fields_by_name['status']._serialized_options = b'\340A\002' + _globals['_TASKSTATUSUPDATEEVENT'].fields_by_name['final']._loaded_options = None + _globals['_TASKSTATUSUPDATEEVENT'].fields_by_name['final']._serialized_options = b'\340A\002' + _globals['_TASKARTIFACTUPDATEEVENT'].fields_by_name['task_id']._loaded_options = None + _globals['_TASKARTIFACTUPDATEEVENT'].fields_by_name['task_id']._serialized_options = b'\340A\002' + _globals['_TASKARTIFACTUPDATEEVENT'].fields_by_name['context_id']._loaded_options = None + _globals['_TASKARTIFACTUPDATEEVENT'].fields_by_name['context_id']._serialized_options = b'\340A\002' + _globals['_TASKARTIFACTUPDATEEVENT'].fields_by_name['artifact']._loaded_options = None + _globals['_TASKARTIFACTUPDATEEVENT'].fields_by_name['artifact']._serialized_options = b'\340A\002' + _globals['_PUSHNOTIFICATIONCONFIG'].fields_by_name['url']._loaded_options = None + _globals['_PUSHNOTIFICATIONCONFIG'].fields_by_name['url']._serialized_options = b'\340A\002' + _globals['_AUTHENTICATIONINFO'].fields_by_name['schemes']._loaded_options = None + _globals['_AUTHENTICATIONINFO'].fields_by_name['schemes']._serialized_options = b'\340A\002' + _globals['_AGENTINTERFACE'].fields_by_name['url']._loaded_options = None + _globals['_AGENTINTERFACE'].fields_by_name['url']._serialized_options = b'\340A\002' + _globals['_AGENTINTERFACE'].fields_by_name['protocol_binding']._loaded_options = None + _globals['_AGENTINTERFACE'].fields_by_name['protocol_binding']._serialized_options = b'\340A\002' + _globals['_AGENTCARD_SECURITYSCHEMESENTRY']._loaded_options = None + _globals['_AGENTCARD_SECURITYSCHEMESENTRY']._serialized_options = b'8\001' + _globals['_AGENTCARD'].fields_by_name['protocol_version']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['protocol_version']._serialized_options = b'\340A\002' + _globals['_AGENTCARD'].fields_by_name['name']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['name']._serialized_options = b'\340A\002' + _globals['_AGENTCARD'].fields_by_name['description']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['description']._serialized_options = b'\340A\002' + _globals['_AGENTCARD'].fields_by_name['url']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['url']._serialized_options = b'\030\001' + _globals['_AGENTCARD'].fields_by_name['preferred_transport']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['preferred_transport']._serialized_options = b'\030\001' + _globals['_AGENTCARD'].fields_by_name['additional_interfaces']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['additional_interfaces']._serialized_options = b'\030\001' + _globals['_AGENTCARD'].fields_by_name['version']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['version']._serialized_options = b'\340A\002' + _globals['_AGENTCARD'].fields_by_name['capabilities']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['capabilities']._serialized_options = b'\340A\002' + _globals['_AGENTCARD'].fields_by_name['default_input_modes']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['default_input_modes']._serialized_options = b'\340A\002' + _globals['_AGENTCARD'].fields_by_name['default_output_modes']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['default_output_modes']._serialized_options = b'\340A\002' + _globals['_AGENTCARD'].fields_by_name['skills']._loaded_options = None + _globals['_AGENTCARD'].fields_by_name['skills']._serialized_options = b'\340A\002' + _globals['_AGENTPROVIDER'].fields_by_name['url']._loaded_options = None + _globals['_AGENTPROVIDER'].fields_by_name['url']._serialized_options = b'\340A\002' + _globals['_AGENTPROVIDER'].fields_by_name['organization']._loaded_options = None + _globals['_AGENTPROVIDER'].fields_by_name['organization']._serialized_options = b'\340A\002' + _globals['_AGENTSKILL'].fields_by_name['id']._loaded_options = None + _globals['_AGENTSKILL'].fields_by_name['id']._serialized_options = b'\340A\002' + _globals['_AGENTSKILL'].fields_by_name['name']._loaded_options = None + _globals['_AGENTSKILL'].fields_by_name['name']._serialized_options = b'\340A\002' + _globals['_AGENTSKILL'].fields_by_name['description']._loaded_options = None + _globals['_AGENTSKILL'].fields_by_name['description']._serialized_options = b'\340A\002' + _globals['_AGENTSKILL'].fields_by_name['tags']._loaded_options = None + _globals['_AGENTSKILL'].fields_by_name['tags']._serialized_options = b'\340A\002' + _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['_TASKPUSHNOTIFICATIONCONFIG'].fields_by_name['name']._loaded_options = None + _globals['_TASKPUSHNOTIFICATIONCONFIG'].fields_by_name['name']._serialized_options = b'\340A\002' + _globals['_TASKPUSHNOTIFICATIONCONFIG'].fields_by_name['push_notification_config']._loaded_options = None + _globals['_TASKPUSHNOTIFICATIONCONFIG'].fields_by_name['push_notification_config']._serialized_options = b'\340A\002' + _globals['_SECURITY_SCHEMESENTRY']._loaded_options = None + _globals['_SECURITY_SCHEMESENTRY']._serialized_options = b'8\001' + _globals['_APIKEYSECURITYSCHEME'].fields_by_name['location']._loaded_options = None + _globals['_APIKEYSECURITYSCHEME'].fields_by_name['location']._serialized_options = b'\340A\002' + _globals['_APIKEYSECURITYSCHEME'].fields_by_name['name']._loaded_options = None + _globals['_APIKEYSECURITYSCHEME'].fields_by_name['name']._serialized_options = b'\340A\002' + _globals['_HTTPAUTHSECURITYSCHEME'].fields_by_name['scheme']._loaded_options = None + _globals['_HTTPAUTHSECURITYSCHEME'].fields_by_name['scheme']._serialized_options = b'\340A\002' + _globals['_OAUTH2SECURITYSCHEME'].fields_by_name['flows']._loaded_options = None + _globals['_OAUTH2SECURITYSCHEME'].fields_by_name['flows']._serialized_options = b'\340A\002' + _globals['_OPENIDCONNECTSECURITYSCHEME'].fields_by_name['open_id_connect_url']._loaded_options = None + _globals['_OPENIDCONNECTSECURITYSCHEME'].fields_by_name['open_id_connect_url']._serialized_options = b'\340A\002' + _globals['_AUTHORIZATIONCODEOAUTHFLOW_SCOPESENTRY']._loaded_options = None + _globals['_AUTHORIZATIONCODEOAUTHFLOW_SCOPESENTRY']._serialized_options = b'8\001' + _globals['_AUTHORIZATIONCODEOAUTHFLOW'].fields_by_name['authorization_url']._loaded_options = None + _globals['_AUTHORIZATIONCODEOAUTHFLOW'].fields_by_name['authorization_url']._serialized_options = b'\340A\002' + _globals['_AUTHORIZATIONCODEOAUTHFLOW'].fields_by_name['token_url']._loaded_options = None + _globals['_AUTHORIZATIONCODEOAUTHFLOW'].fields_by_name['token_url']._serialized_options = b'\340A\002' + _globals['_AUTHORIZATIONCODEOAUTHFLOW'].fields_by_name['scopes']._loaded_options = None + _globals['_AUTHORIZATIONCODEOAUTHFLOW'].fields_by_name['scopes']._serialized_options = b'\340A\002' + _globals['_CLIENTCREDENTIALSOAUTHFLOW_SCOPESENTRY']._loaded_options = None + _globals['_CLIENTCREDENTIALSOAUTHFLOW_SCOPESENTRY']._serialized_options = b'8\001' + _globals['_CLIENTCREDENTIALSOAUTHFLOW'].fields_by_name['token_url']._loaded_options = None + _globals['_CLIENTCREDENTIALSOAUTHFLOW'].fields_by_name['token_url']._serialized_options = b'\340A\002' + _globals['_CLIENTCREDENTIALSOAUTHFLOW'].fields_by_name['scopes']._loaded_options = None + _globals['_CLIENTCREDENTIALSOAUTHFLOW'].fields_by_name['scopes']._serialized_options = b'\340A\002' + _globals['_IMPLICITOAUTHFLOW_SCOPESENTRY']._loaded_options = None + _globals['_IMPLICITOAUTHFLOW_SCOPESENTRY']._serialized_options = b'8\001' + _globals['_IMPLICITOAUTHFLOW'].fields_by_name['authorization_url']._loaded_options = None + _globals['_IMPLICITOAUTHFLOW'].fields_by_name['authorization_url']._serialized_options = b'\340A\002' + _globals['_IMPLICITOAUTHFLOW'].fields_by_name['scopes']._loaded_options = None + _globals['_IMPLICITOAUTHFLOW'].fields_by_name['scopes']._serialized_options = b'\340A\002' + _globals['_PASSWORDOAUTHFLOW_SCOPESENTRY']._loaded_options = None + _globals['_PASSWORDOAUTHFLOW_SCOPESENTRY']._serialized_options = b'8\001' + _globals['_PASSWORDOAUTHFLOW'].fields_by_name['token_url']._loaded_options = None + _globals['_PASSWORDOAUTHFLOW'].fields_by_name['token_url']._serialized_options = b'\340A\002' + _globals['_PASSWORDOAUTHFLOW'].fields_by_name['scopes']._loaded_options = None + _globals['_PASSWORDOAUTHFLOW'].fields_by_name['scopes']._serialized_options = b'\340A\002' + _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['_LISTTASKSRESPONSE'].fields_by_name['tasks']._loaded_options = None + _globals['_LISTTASKSRESPONSE'].fields_by_name['tasks']._serialized_options = b'\340A\002' + _globals['_LISTTASKSRESPONSE'].fields_by_name['next_page_token']._loaded_options = None + _globals['_LISTTASKSRESPONSE'].fields_by_name['next_page_token']._serialized_options = b'\340A\002' + _globals['_LISTTASKSRESPONSE'].fields_by_name['page_size']._loaded_options = None + _globals['_LISTTASKSRESPONSE'].fields_by_name['page_size']._serialized_options = b'\340A\002' + _globals['_LISTTASKSRESPONSE'].fields_by_name['total_size']._loaded_options = None + _globals['_LISTTASKSRESPONSE'].fields_by_name['total_size']._serialized_options = b'\340A\002' + _globals['_SETTASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['parent']._loaded_options = None + _globals['_SETTASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['parent']._serialized_options = b'\340A\002' + _globals['_SETTASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['config_id']._loaded_options = None + _globals['_SETTASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['config_id']._serialized_options = b'\340A\002' + _globals['_SETTASKPUSHNOTIFICATIONCONFIGREQUEST'].fields_by_name['config']._loaded_options = None + _globals['_SETTASKPUSHNOTIFICATIONCONFIGREQUEST'].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['ListTasks']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['ListTasks']._serialized_options = b'\202\323\344\223\002\013\022\t/v1/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['SubscribeToTask']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['SubscribeToTask']._serialized_options = b'\202\323\344\223\002\036\022\034/v1/{name=tasks/*}:subscribe' + _globals['_A2ASERVICE'].methods_by_name['SetTaskPushNotificationConfig']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['SetTaskPushNotificationConfig']._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['GetExtendedAgentCard']._loaded_options = None + _globals['_A2ASERVICE'].methods_by_name['GetExtendedAgentCard']._serialized_options = b'\202\323\344\223\002\027\022\025/v1/extendedAgentCard' + _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=9415 + _globals['_TASKSTATE']._serialized_end=9665 + _globals['_ROLE']._serialized_start=9667 + _globals['_ROLE']._serialized_end=9726 + _globals['_SENDMESSAGECONFIGURATION']._serialized_start=202 + _globals['_SENDMESSAGECONFIGURATION']._serialized_end=461 + _globals['_TASK']._serialized_start=464 + _globals['_TASK']._serialized_end=720 + _globals['_TASKSTATUS']._serialized_start=723 + _globals['_TASKSTATUS']._serialized_end=882 + _globals['_PART']._serialized_start=885 + _globals['_PART']._serialized_end=1054 + _globals['_FILEPART']._serialized_start=1057 + _globals['_FILEPART']._serialized_end=1206 + _globals['_DATAPART']._serialized_start=1208 + _globals['_DATAPART']._serialized_end=1268 + _globals['_MESSAGE']._serialized_start=1271 + _globals['_MESSAGE']._serialized_end=1583 + _globals['_ARTIFACT']._serialized_start=1586 + _globals['_ARTIFACT']._serialized_end=1814 + _globals['_TASKSTATUSUPDATEEVENT']._serialized_start=1817 + _globals['_TASKSTATUSUPDATEEVENT']._serialized_end=2035 + _globals['_TASKARTIFACTUPDATEEVENT']._serialized_start=2038 + _globals['_TASKARTIFACTUPDATEEVENT']._serialized_end=2288 + _globals['_PUSHNOTIFICATIONCONFIG']._serialized_start=2291 + _globals['_PUSHNOTIFICATIONCONFIG']._serialized_end=2444 + _globals['_AUTHENTICATIONINFO']._serialized_start=2446 + _globals['_AUTHENTICATIONINFO']._serialized_end=2531 + _globals['_AGENTINTERFACE']._serialized_start=2533 + _globals['_AGENTINTERFACE']._serialized_end=2620 + _globals['_AGENTCARD']._serialized_start=2623 + _globals['_AGENTCARD']._serialized_end=3877 + _globals['_AGENTCARD_SECURITYSCHEMESENTRY']._serialized_start=3658 + _globals['_AGENTCARD_SECURITYSCHEMESENTRY']._serialized_end=3748 + _globals['_AGENTPROVIDER']._serialized_start=3879 + _globals['_AGENTPROVIDER']._serialized_end=3958 + _globals['_AGENTCAPABILITIES']._serialized_start=3961 + _globals['_AGENTCAPABILITIES']._serialized_end=4252 + _globals['_AGENTEXTENSION']._serialized_start=4255 + _globals['_AGENTEXTENSION']._serialized_end=4400 + _globals['_AGENTSKILL']._serialized_start=4403 + _globals['_AGENTSKILL']._serialized_end=4667 + _globals['_AGENTCARDSIGNATURE']._serialized_start=4670 + _globals['_AGENTCARDSIGNATURE']._serialized_end=4809 + _globals['_TASKPUSHNOTIFICATIONCONFIG']._serialized_start=4812 + _globals['_TASKPUSHNOTIFICATIONCONFIG']._serialized_end=4960 + _globals['_STRINGLIST']._serialized_start=4962 + _globals['_STRINGLIST']._serialized_end=4994 + _globals['_SECURITY']._serialized_start=4997 + _globals['_SECURITY']._serialized_end=5144 + _globals['_SECURITY_SCHEMESENTRY']._serialized_start=5066 + _globals['_SECURITY_SCHEMESENTRY']._serialized_end=5144 + _globals['_SECURITYSCHEME']._serialized_start=5147 + _globals['_SECURITYSCHEME']._serialized_end=5633 + _globals['_APIKEYSECURITYSCHEME']._serialized_start=5635 + _globals['_APIKEYSECURITYSCHEME']._serialized_end=5749 + _globals['_HTTPAUTHSECURITYSCHEME']._serialized_start=5751 + _globals['_HTTPAUTHSECURITYSCHEME']._serialized_end=5875 + _globals['_OAUTH2SECURITYSCHEME']._serialized_start=5878 + _globals['_OAUTH2SECURITYSCHEME']._serialized_end=6029 + _globals['_OPENIDCONNECTSECURITYSCHEME']._serialized_start=6031 + _globals['_OPENIDCONNECTSECURITYSCHEME']._serialized_end=6146 + _globals['_MUTUALTLSSECURITYSCHEME']._serialized_start=6148 + _globals['_MUTUALTLSSECURITYSCHEME']._serialized_end=6207 + _globals['_OAUTHFLOWS']._serialized_start=6210 + _globals['_OAUTHFLOWS']._serialized_end=6514 + _globals['_AUTHORIZATIONCODEOAUTHFLOW']._serialized_start=6517 + _globals['_AUTHORIZATIONCODEOAUTHFLOW']._serialized_end=6798 + _globals['_AUTHORIZATIONCODEOAUTHFLOW_SCOPESENTRY']._serialized_start=6741 + _globals['_AUTHORIZATIONCODEOAUTHFLOW_SCOPESENTRY']._serialized_end=6798 + _globals['_CLIENTCREDENTIALSOAUTHFLOW']._serialized_start=6801 + _globals['_CLIENTCREDENTIALSOAUTHFLOW']._serialized_end=7032 + _globals['_CLIENTCREDENTIALSOAUTHFLOW_SCOPESENTRY']._serialized_start=6741 + _globals['_CLIENTCREDENTIALSOAUTHFLOW_SCOPESENTRY']._serialized_end=6798 + _globals['_IMPLICITOAUTHFLOW']._serialized_start=7035 + _globals['_IMPLICITOAUTHFLOW']._serialized_end=7264 + _globals['_IMPLICITOAUTHFLOW_SCOPESENTRY']._serialized_start=6741 + _globals['_IMPLICITOAUTHFLOW_SCOPESENTRY']._serialized_end=6798 + _globals['_PASSWORDOAUTHFLOW']._serialized_start=7267 + _globals['_PASSWORDOAUTHFLOW']._serialized_end=7480 + _globals['_PASSWORDOAUTHFLOW_SCOPESENTRY']._serialized_start=6741 + _globals['_PASSWORDOAUTHFLOW_SCOPESENTRY']._serialized_end=6798 + _globals['_SENDMESSAGEREQUEST']._serialized_start=7483 + _globals['_SENDMESSAGEREQUEST']._serialized_end=7676 + _globals['_GETTASKREQUEST']._serialized_start=7678 + _globals['_GETTASKREQUEST']._serialized_end=7782 + _globals['_LISTTASKSREQUEST']._serialized_start=7785 + _globals['_LISTTASKSREQUEST']._serialized_end=8190 + _globals['_LISTTASKSRESPONSE']._serialized_start=8193 + _globals['_LISTTASKSRESPONSE']._serialized_end=8368 + _globals['_CANCELTASKREQUEST']._serialized_start=8370 + _globals['_CANCELTASKREQUEST']._serialized_end=8409 + _globals['_GETTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=8411 + _globals['_GETTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=8469 + _globals['_DELETETASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=8471 + _globals['_DELETETASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=8532 + _globals['_SETTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=8535 + _globals['_SETTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=8701 + _globals['_SUBSCRIBETOTASKREQUEST']._serialized_start=8703 + _globals['_SUBSCRIBETOTASKREQUEST']._serialized_end=8747 + _globals['_LISTTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_start=8749 + _globals['_LISTTASKPUSHNOTIFICATIONCONFIGREQUEST']._serialized_end=8872 + _globals['_GETEXTENDEDAGENTCARDREQUEST']._serialized_start=8874 + _globals['_GETEXTENDEDAGENTCARDREQUEST']._serialized_end=8903 + _globals['_SENDMESSAGERESPONSE']._serialized_start=8905 + _globals['_SENDMESSAGERESPONSE']._serialized_end=9014 + _globals['_STREAMRESPONSE']._serialized_start=9017 + _globals['_STREAMRESPONSE']._serialized_end=9267 + _globals['_LISTTASKPUSHNOTIFICATIONCONFIGRESPONSE']._serialized_start=9270 + _globals['_LISTTASKPUSHNOTIFICATIONCONFIGRESPONSE']._serialized_end=9412 + _globals['_A2ASERVICE']._serialized_start=9729 + _globals['_A2ASERVICE']._serialized_end=11174 +# @@protoc_insertion_point(module_scope) diff --git a/src/a2a/grpc/a2a_pb2.pyi b/src/a2a/types/a2a_pb2.pyi similarity index 54% rename from src/a2a/grpc/a2a_pb2.pyi rename to src/a2a/types/a2a_pb2.pyi index 06005e850..ac3d1da0e 100644 --- a/src/a2a/grpc/a2a_pb2.pyi +++ b/src/a2a/types/a2a_pb2.pyi @@ -1,17 +1,15 @@ 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 collections.abc import Iterable as _Iterable +from collections.abc import Mapping as _Mapping +from typing import ClassVar as _ClassVar + +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message 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 @@ -46,19 +44,19 @@ ROLE_USER: Role ROLE_AGENT: Role class SendMessageConfiguration(_message.Message): - __slots__ = ("accepted_output_modes", "push_notification", "history_length", "blocking") + __slots__ = () ACCEPTED_OUTPUT_MODES_FIELD_NUMBER: _ClassVar[int] - PUSH_NOTIFICATION_FIELD_NUMBER: _ClassVar[int] + PUSH_NOTIFICATION_CONFIG_FIELD_NUMBER: _ClassVar[int] HISTORY_LENGTH_FIELD_NUMBER: _ClassVar[int] BLOCKING_FIELD_NUMBER: _ClassVar[int] accepted_output_modes: _containers.RepeatedScalarFieldContainer[str] - push_notification: PushNotificationConfig + push_notification_config: 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: ... + def __init__(self, accepted_output_modes: _Iterable[str] | None = ..., push_notification_config: PushNotificationConfig | _Mapping | None = ..., history_length: int | None = ..., blocking: bool | None = ...) -> None: ... class Task(_message.Message): - __slots__ = ("id", "context_id", "status", "artifacts", "history", "metadata") + __slots__ = () ID_FIELD_NUMBER: _ClassVar[int] CONTEXT_ID_FIELD_NUMBER: _ClassVar[int] STATUS_FIELD_NUMBER: _ClassVar[int] @@ -71,20 +69,20 @@ class Task(_message.Message): 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: ... + def __init__(self, id: str | None = ..., context_id: str | None = ..., status: TaskStatus | _Mapping | None = ..., artifacts: _Iterable[Artifact | _Mapping] | None = ..., history: _Iterable[Message | _Mapping] | None = ..., metadata: _struct_pb2.Struct | _Mapping | None = ...) -> None: ... class TaskStatus(_message.Message): - __slots__ = ("state", "update", "timestamp") + __slots__ = () STATE_FIELD_NUMBER: _ClassVar[int] - UPDATE_FIELD_NUMBER: _ClassVar[int] + MESSAGE_FIELD_NUMBER: _ClassVar[int] TIMESTAMP_FIELD_NUMBER: _ClassVar[int] state: TaskState - update: Message + message: 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: ... + def __init__(self, state: TaskState | str | None = ..., message: Message | _Mapping | None = ..., timestamp: datetime.datetime | _timestamp_pb2.Timestamp | _Mapping | None = ...) -> None: ... class Part(_message.Message): - __slots__ = ("text", "file", "data", "metadata") + __slots__ = () TEXT_FIELD_NUMBER: _ClassVar[int] FILE_FIELD_NUMBER: _ClassVar[int] DATA_FIELD_NUMBER: _ClassVar[int] @@ -93,46 +91,48 @@ class Part(_message.Message): 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: ... + def __init__(self, text: str | None = ..., file: FilePart | _Mapping | None = ..., data: DataPart | _Mapping | None = ..., metadata: _struct_pb2.Struct | _Mapping | None = ...) -> None: ... class FilePart(_message.Message): - __slots__ = ("file_with_uri", "file_with_bytes", "mime_type", "name") + __slots__ = () FILE_WITH_URI_FIELD_NUMBER: _ClassVar[int] FILE_WITH_BYTES_FIELD_NUMBER: _ClassVar[int] - MIME_TYPE_FIELD_NUMBER: _ClassVar[int] + MEDIA_TYPE_FIELD_NUMBER: _ClassVar[int] NAME_FIELD_NUMBER: _ClassVar[int] file_with_uri: str file_with_bytes: bytes - mime_type: str + media_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: ... + def __init__(self, file_with_uri: str | None = ..., file_with_bytes: bytes | None = ..., media_type: str | None = ..., name: str | None = ...) -> None: ... class DataPart(_message.Message): - __slots__ = ("data",) + __slots__ = () DATA_FIELD_NUMBER: _ClassVar[int] data: _struct_pb2.Struct - def __init__(self, data: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ... + def __init__(self, data: _struct_pb2.Struct | _Mapping | None = ...) -> None: ... class Message(_message.Message): - __slots__ = ("message_id", "context_id", "task_id", "role", "content", "metadata", "extensions") + __slots__ = () 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] + PARTS_FIELD_NUMBER: _ClassVar[int] METADATA_FIELD_NUMBER: _ClassVar[int] EXTENSIONS_FIELD_NUMBER: _ClassVar[int] + REFERENCE_TASK_IDS_FIELD_NUMBER: _ClassVar[int] message_id: str context_id: str task_id: str role: Role - content: _containers.RepeatedCompositeFieldContainer[Part] + parts: _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: ... + reference_task_ids: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, message_id: str | None = ..., context_id: str | None = ..., task_id: str | None = ..., role: Role | str | None = ..., parts: _Iterable[Part | _Mapping] | None = ..., metadata: _struct_pb2.Struct | _Mapping | None = ..., extensions: _Iterable[str] | None = ..., reference_task_ids: _Iterable[str] | None = ...) -> None: ... class Artifact(_message.Message): - __slots__ = ("artifact_id", "name", "description", "parts", "metadata", "extensions") + __slots__ = () ARTIFACT_ID_FIELD_NUMBER: _ClassVar[int] NAME_FIELD_NUMBER: _ClassVar[int] DESCRIPTION_FIELD_NUMBER: _ClassVar[int] @@ -145,10 +145,10 @@ class Artifact(_message.Message): 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: ... + def __init__(self, artifact_id: str | None = ..., name: str | None = ..., description: str | None = ..., parts: _Iterable[Part | _Mapping] | None = ..., metadata: _struct_pb2.Struct | _Mapping | None = ..., extensions: _Iterable[str] | None = ...) -> None: ... class TaskStatusUpdateEvent(_message.Message): - __slots__ = ("task_id", "context_id", "status", "final", "metadata") + __slots__ = () TASK_ID_FIELD_NUMBER: _ClassVar[int] CONTEXT_ID_FIELD_NUMBER: _ClassVar[int] STATUS_FIELD_NUMBER: _ClassVar[int] @@ -159,10 +159,10 @@ class TaskStatusUpdateEvent(_message.Message): 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: ... + def __init__(self, task_id: str | None = ..., context_id: str | None = ..., status: TaskStatus | _Mapping | None = ..., final: bool | None = ..., metadata: _struct_pb2.Struct | _Mapping | None = ...) -> None: ... class TaskArtifactUpdateEvent(_message.Message): - __slots__ = ("task_id", "context_id", "artifact", "append", "last_chunk", "metadata") + __slots__ = () TASK_ID_FIELD_NUMBER: _ClassVar[int] CONTEXT_ID_FIELD_NUMBER: _ClassVar[int] ARTIFACT_FIELD_NUMBER: _ClassVar[int] @@ -175,10 +175,10 @@ class TaskArtifactUpdateEvent(_message.Message): 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: ... + def __init__(self, task_id: str | None = ..., context_id: str | None = ..., artifact: Artifact | _Mapping | None = ..., append: bool | None = ..., last_chunk: bool | None = ..., metadata: _struct_pb2.Struct | _Mapping | None = ...) -> None: ... class PushNotificationConfig(_message.Message): - __slots__ = ("id", "url", "token", "authentication") + __slots__ = () ID_FIELD_NUMBER: _ClassVar[int] URL_FIELD_NUMBER: _ClassVar[int] TOKEN_FIELD_NUMBER: _ClassVar[int] @@ -187,36 +187,37 @@ class PushNotificationConfig(_message.Message): url: str token: str authentication: AuthenticationInfo - def __init__(self, id: _Optional[str] = ..., url: _Optional[str] = ..., token: _Optional[str] = ..., authentication: _Optional[_Union[AuthenticationInfo, _Mapping]] = ...) -> None: ... + def __init__(self, id: str | None = ..., url: str | None = ..., token: str | None = ..., authentication: AuthenticationInfo | _Mapping | None = ...) -> None: ... class AuthenticationInfo(_message.Message): - __slots__ = ("schemes", "credentials") + __slots__ = () 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: ... + def __init__(self, schemes: _Iterable[str] | None = ..., credentials: str | None = ...) -> None: ... class AgentInterface(_message.Message): - __slots__ = ("url", "transport") + __slots__ = () URL_FIELD_NUMBER: _ClassVar[int] - TRANSPORT_FIELD_NUMBER: _ClassVar[int] + PROTOCOL_BINDING_FIELD_NUMBER: _ClassVar[int] url: str - transport: str - def __init__(self, url: _Optional[str] = ..., transport: _Optional[str] = ...) -> None: ... + protocol_binding: str + def __init__(self, url: str | None = ..., protocol_binding: str | None = ...) -> 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") + __slots__ = () class SecuritySchemesEntry(_message.Message): - __slots__ = ("key", "value") + __slots__ = () 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: ... + def __init__(self, key: str | None = ..., value: SecurityScheme | _Mapping | None = ...) -> None: ... PROTOCOL_VERSION_FIELD_NUMBER: _ClassVar[int] NAME_FIELD_NUMBER: _ClassVar[int] DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + SUPPORTED_INTERFACES_FIELD_NUMBER: _ClassVar[int] URL_FIELD_NUMBER: _ClassVar[int] PREFERRED_TRANSPORT_FIELD_NUMBER: _ClassVar[int] ADDITIONAL_INTERFACES_FIELD_NUMBER: _ClassVar[int] @@ -235,6 +236,7 @@ class AgentCard(_message.Message): protocol_version: str name: str description: str + supported_interfaces: _containers.RepeatedCompositeFieldContainer[AgentInterface] url: str preferred_transport: str additional_interfaces: _containers.RepeatedCompositeFieldContainer[AgentInterface] @@ -250,28 +252,30 @@ class AgentCard(_message.Message): 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: ... + def __init__(self, protocol_version: str | None = ..., name: str | None = ..., description: str | None = ..., supported_interfaces: _Iterable[AgentInterface | _Mapping] | None = ..., url: str | None = ..., preferred_transport: str | None = ..., additional_interfaces: _Iterable[AgentInterface | _Mapping] | None = ..., provider: AgentProvider | _Mapping | None = ..., version: str | None = ..., documentation_url: str | None = ..., capabilities: AgentCapabilities | _Mapping | None = ..., security_schemes: _Mapping[str, SecurityScheme] | None = ..., security: _Iterable[Security | _Mapping] | None = ..., default_input_modes: _Iterable[str] | None = ..., default_output_modes: _Iterable[str] | None = ..., skills: _Iterable[AgentSkill | _Mapping] | None = ..., supports_authenticated_extended_card: bool | None = ..., signatures: _Iterable[AgentCardSignature | _Mapping] | None = ..., icon_url: str | None = ...) -> None: ... class AgentProvider(_message.Message): - __slots__ = ("url", "organization") + __slots__ = () URL_FIELD_NUMBER: _ClassVar[int] ORGANIZATION_FIELD_NUMBER: _ClassVar[int] url: str organization: str - def __init__(self, url: _Optional[str] = ..., organization: _Optional[str] = ...) -> None: ... + def __init__(self, url: str | None = ..., organization: str | None = ...) -> None: ... class AgentCapabilities(_message.Message): - __slots__ = ("streaming", "push_notifications", "extensions") + __slots__ = () STREAMING_FIELD_NUMBER: _ClassVar[int] PUSH_NOTIFICATIONS_FIELD_NUMBER: _ClassVar[int] EXTENSIONS_FIELD_NUMBER: _ClassVar[int] + STATE_TRANSITION_HISTORY_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: ... + state_transition_history: bool + def __init__(self, streaming: bool | None = ..., push_notifications: bool | None = ..., extensions: _Iterable[AgentExtension | _Mapping] | None = ..., state_transition_history: bool | None = ...) -> None: ... class AgentExtension(_message.Message): - __slots__ = ("uri", "description", "required", "params") + __slots__ = () URI_FIELD_NUMBER: _ClassVar[int] DESCRIPTION_FIELD_NUMBER: _ClassVar[int] REQUIRED_FIELD_NUMBER: _ClassVar[int] @@ -280,10 +284,10 @@ class AgentExtension(_message.Message): 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: ... + def __init__(self, uri: str | None = ..., description: str | None = ..., required: bool | None = ..., params: _struct_pb2.Struct | _Mapping | None = ...) -> None: ... class AgentSkill(_message.Message): - __slots__ = ("id", "name", "description", "tags", "examples", "input_modes", "output_modes", "security") + __slots__ = () ID_FIELD_NUMBER: _ClassVar[int] NAME_FIELD_NUMBER: _ClassVar[int] DESCRIPTION_FIELD_NUMBER: _ClassVar[int] @@ -300,47 +304,47 @@ class AgentSkill(_message.Message): 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: ... + def __init__(self, id: str | None = ..., name: str | None = ..., description: str | None = ..., tags: _Iterable[str] | None = ..., examples: _Iterable[str] | None = ..., input_modes: _Iterable[str] | None = ..., output_modes: _Iterable[str] | None = ..., security: _Iterable[Security | _Mapping] | None = ...) -> None: ... class AgentCardSignature(_message.Message): - __slots__ = ("protected", "signature", "header") + __slots__ = () 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: ... + def __init__(self, protected: str | None = ..., signature: str | None = ..., header: _struct_pb2.Struct | _Mapping | None = ...) -> None: ... class TaskPushNotificationConfig(_message.Message): - __slots__ = ("name", "push_notification_config") + __slots__ = () 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: ... + def __init__(self, name: str | None = ..., push_notification_config: PushNotificationConfig | _Mapping | None = ...) -> None: ... class StringList(_message.Message): - __slots__ = ("list",) + __slots__ = () LIST_FIELD_NUMBER: _ClassVar[int] list: _containers.RepeatedScalarFieldContainer[str] - def __init__(self, list: _Optional[_Iterable[str]] = ...) -> None: ... + def __init__(self, list: _Iterable[str] | None = ...) -> None: ... class Security(_message.Message): - __slots__ = ("schemes",) + __slots__ = () class SchemesEntry(_message.Message): - __slots__ = ("key", "value") + __slots__ = () 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: ... + def __init__(self, key: str | None = ..., value: StringList | _Mapping | None = ...) -> None: ... SCHEMES_FIELD_NUMBER: _ClassVar[int] schemes: _containers.MessageMap[str, StringList] - def __init__(self, schemes: _Optional[_Mapping[str, StringList]] = ...) -> None: ... + def __init__(self, schemes: _Mapping[str, StringList] | None = ...) -> 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") + __slots__ = () API_KEY_SECURITY_SCHEME_FIELD_NUMBER: _ClassVar[int] HTTP_AUTH_SECURITY_SCHEME_FIELD_NUMBER: _ClassVar[int] OAUTH2_SECURITY_SCHEME_FIELD_NUMBER: _ClassVar[int] @@ -351,54 +355,54 @@ class SecurityScheme(_message.Message): 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: ... + def __init__(self, api_key_security_scheme: APIKeySecurityScheme | _Mapping | None = ..., http_auth_security_scheme: HTTPAuthSecurityScheme | _Mapping | None = ..., oauth2_security_scheme: OAuth2SecurityScheme | _Mapping | None = ..., open_id_connect_security_scheme: OpenIdConnectSecurityScheme | _Mapping | None = ..., mtls_security_scheme: MutualTlsSecurityScheme | _Mapping | None = ...) -> None: ... class APIKeySecurityScheme(_message.Message): - __slots__ = ("description", "location", "name") + __slots__ = () 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: ... + def __init__(self, description: str | None = ..., location: str | None = ..., name: str | None = ...) -> None: ... class HTTPAuthSecurityScheme(_message.Message): - __slots__ = ("description", "scheme", "bearer_format") + __slots__ = () 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: ... + def __init__(self, description: str | None = ..., scheme: str | None = ..., bearer_format: str | None = ...) -> None: ... class OAuth2SecurityScheme(_message.Message): - __slots__ = ("description", "flows", "oauth2_metadata_url") + __slots__ = () 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: ... + def __init__(self, description: str | None = ..., flows: OAuthFlows | _Mapping | None = ..., oauth2_metadata_url: str | None = ...) -> None: ... class OpenIdConnectSecurityScheme(_message.Message): - __slots__ = ("description", "open_id_connect_url") + __slots__ = () 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: ... + def __init__(self, description: str | None = ..., open_id_connect_url: str | None = ...) -> None: ... class MutualTlsSecurityScheme(_message.Message): - __slots__ = ("description",) + __slots__ = () DESCRIPTION_FIELD_NUMBER: _ClassVar[int] description: str - def __init__(self, description: _Optional[str] = ...) -> None: ... + def __init__(self, description: str | None = ...) -> None: ... class OAuthFlows(_message.Message): - __slots__ = ("authorization_code", "client_credentials", "implicit", "password") + __slots__ = () AUTHORIZATION_CODE_FIELD_NUMBER: _ClassVar[int] CLIENT_CREDENTIALS_FIELD_NUMBER: _ClassVar[int] IMPLICIT_FIELD_NUMBER: _ClassVar[int] @@ -407,17 +411,17 @@ class OAuthFlows(_message.Message): 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: ... + def __init__(self, authorization_code: AuthorizationCodeOAuthFlow | _Mapping | None = ..., client_credentials: ClientCredentialsOAuthFlow | _Mapping | None = ..., implicit: ImplicitOAuthFlow | _Mapping | None = ..., password: PasswordOAuthFlow | _Mapping | None = ...) -> None: ... class AuthorizationCodeOAuthFlow(_message.Message): - __slots__ = ("authorization_url", "token_url", "refresh_url", "scopes") + __slots__ = () class ScopesEntry(_message.Message): - __slots__ = ("key", "value") + __slots__ = () KEY_FIELD_NUMBER: _ClassVar[int] VALUE_FIELD_NUMBER: _ClassVar[int] key: str value: str - def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ... + def __init__(self, key: str | None = ..., value: str | None = ...) -> None: ... AUTHORIZATION_URL_FIELD_NUMBER: _ClassVar[int] TOKEN_URL_FIELD_NUMBER: _ClassVar[int] REFRESH_URL_FIELD_NUMBER: _ClassVar[int] @@ -426,135 +430,167 @@ class AuthorizationCodeOAuthFlow(_message.Message): 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: ... + def __init__(self, authorization_url: str | None = ..., token_url: str | None = ..., refresh_url: str | None = ..., scopes: _Mapping[str, str] | None = ...) -> None: ... class ClientCredentialsOAuthFlow(_message.Message): - __slots__ = ("token_url", "refresh_url", "scopes") + __slots__ = () class ScopesEntry(_message.Message): - __slots__ = ("key", "value") + __slots__ = () KEY_FIELD_NUMBER: _ClassVar[int] VALUE_FIELD_NUMBER: _ClassVar[int] key: str value: str - def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ... + def __init__(self, key: str | None = ..., value: str | None = ...) -> 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: ... + def __init__(self, token_url: str | None = ..., refresh_url: str | None = ..., scopes: _Mapping[str, str] | None = ...) -> None: ... class ImplicitOAuthFlow(_message.Message): - __slots__ = ("authorization_url", "refresh_url", "scopes") + __slots__ = () class ScopesEntry(_message.Message): - __slots__ = ("key", "value") + __slots__ = () KEY_FIELD_NUMBER: _ClassVar[int] VALUE_FIELD_NUMBER: _ClassVar[int] key: str value: str - def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ... + def __init__(self, key: str | None = ..., value: str | None = ...) -> 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: ... + def __init__(self, authorization_url: str | None = ..., refresh_url: str | None = ..., scopes: _Mapping[str, str] | None = ...) -> None: ... class PasswordOAuthFlow(_message.Message): - __slots__ = ("token_url", "refresh_url", "scopes") + __slots__ = () class ScopesEntry(_message.Message): - __slots__ = ("key", "value") + __slots__ = () KEY_FIELD_NUMBER: _ClassVar[int] VALUE_FIELD_NUMBER: _ClassVar[int] key: str value: str - def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ... + def __init__(self, key: str | None = ..., value: str | None = ...) -> 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: ... + def __init__(self, token_url: str | None = ..., refresh_url: str | None = ..., scopes: _Mapping[str, str] | None = ...) -> None: ... class SendMessageRequest(_message.Message): - __slots__ = ("request", "configuration", "metadata") + __slots__ = () 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: ... + def __init__(self, request: Message | _Mapping | None = ..., configuration: SendMessageConfiguration | _Mapping | None = ..., metadata: _struct_pb2.Struct | _Mapping | None = ...) -> None: ... class GetTaskRequest(_message.Message): - __slots__ = ("name", "history_length") + __slots__ = () 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: ... + def __init__(self, name: str | None = ..., history_length: int | None = ...) -> None: ... + +class ListTasksRequest(_message.Message): + __slots__ = () + CONTEXT_ID_FIELD_NUMBER: _ClassVar[int] + STATUS_FIELD_NUMBER: _ClassVar[int] + PAGE_SIZE_FIELD_NUMBER: _ClassVar[int] + PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + HISTORY_LENGTH_FIELD_NUMBER: _ClassVar[int] + LAST_UPDATED_AFTER_FIELD_NUMBER: _ClassVar[int] + INCLUDE_ARTIFACTS_FIELD_NUMBER: _ClassVar[int] + METADATA_FIELD_NUMBER: _ClassVar[int] + context_id: str + status: TaskState + page_size: int + page_token: str + history_length: int + last_updated_after: int + include_artifacts: bool + metadata: _struct_pb2.Struct + def __init__(self, context_id: str | None = ..., status: TaskState | str | None = ..., page_size: int | None = ..., page_token: str | None = ..., history_length: int | None = ..., last_updated_after: int | None = ..., include_artifacts: bool | None = ..., metadata: _struct_pb2.Struct | _Mapping | None = ...) -> None: ... + +class ListTasksResponse(_message.Message): + __slots__ = () + TASKS_FIELD_NUMBER: _ClassVar[int] + NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + PAGE_SIZE_FIELD_NUMBER: _ClassVar[int] + TOTAL_SIZE_FIELD_NUMBER: _ClassVar[int] + tasks: _containers.RepeatedCompositeFieldContainer[Task] + next_page_token: str + page_size: int + total_size: int + def __init__(self, tasks: _Iterable[Task | _Mapping] | None = ..., next_page_token: str | None = ..., page_size: int | None = ..., total_size: int | None = ...) -> None: ... class CancelTaskRequest(_message.Message): - __slots__ = ("name",) + __slots__ = () NAME_FIELD_NUMBER: _ClassVar[int] name: str - def __init__(self, name: _Optional[str] = ...) -> None: ... + def __init__(self, name: str | None = ...) -> None: ... class GetTaskPushNotificationConfigRequest(_message.Message): - __slots__ = ("name",) + __slots__ = () NAME_FIELD_NUMBER: _ClassVar[int] name: str - def __init__(self, name: _Optional[str] = ...) -> None: ... + def __init__(self, name: str | None = ...) -> None: ... class DeleteTaskPushNotificationConfigRequest(_message.Message): - __slots__ = ("name",) + __slots__ = () NAME_FIELD_NUMBER: _ClassVar[int] name: str - def __init__(self, name: _Optional[str] = ...) -> None: ... + def __init__(self, name: str | None = ...) -> None: ... -class CreateTaskPushNotificationConfigRequest(_message.Message): - __slots__ = ("parent", "config_id", "config") +class SetTaskPushNotificationConfigRequest(_message.Message): + __slots__ = () 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: ... + def __init__(self, parent: str | None = ..., config_id: str | None = ..., config: TaskPushNotificationConfig | _Mapping | None = ...) -> None: ... -class TaskSubscriptionRequest(_message.Message): - __slots__ = ("name",) +class SubscribeToTaskRequest(_message.Message): + __slots__ = () NAME_FIELD_NUMBER: _ClassVar[int] name: str - def __init__(self, name: _Optional[str] = ...) -> None: ... + def __init__(self, name: str | None = ...) -> None: ... class ListTaskPushNotificationConfigRequest(_message.Message): - __slots__ = ("parent", "page_size", "page_token") + __slots__ = () 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: ... + def __init__(self, parent: str | None = ..., page_size: int | None = ..., page_token: str | None = ...) -> None: ... -class GetAgentCardRequest(_message.Message): +class GetExtendedAgentCardRequest(_message.Message): __slots__ = () def __init__(self) -> None: ... class SendMessageResponse(_message.Message): - __slots__ = ("task", "msg") + __slots__ = () 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: ... + def __init__(self, task: Task | _Mapping | None = ..., msg: Message | _Mapping | None = ...) -> None: ... class StreamResponse(_message.Message): - __slots__ = ("task", "msg", "status_update", "artifact_update") + __slots__ = () TASK_FIELD_NUMBER: _ClassVar[int] MSG_FIELD_NUMBER: _ClassVar[int] STATUS_UPDATE_FIELD_NUMBER: _ClassVar[int] @@ -563,12 +599,12 @@ class StreamResponse(_message.Message): 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: ... + def __init__(self, task: Task | _Mapping | None = ..., msg: Message | _Mapping | None = ..., status_update: TaskStatusUpdateEvent | _Mapping | None = ..., artifact_update: TaskArtifactUpdateEvent | _Mapping | None = ...) -> None: ... class ListTaskPushNotificationConfigResponse(_message.Message): - __slots__ = ("configs", "next_page_token") + __slots__ = () 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: ... + def __init__(self, configs: _Iterable[TaskPushNotificationConfig | _Mapping] | None = ..., next_page_token: str | None = ...) -> None: ... diff --git a/src/a2a/grpc/a2a_pb2_grpc.py b/src/a2a/types/a2a_pb2_grpc.py similarity index 77% rename from src/a2a/grpc/a2a_pb2_grpc.py rename to src/a2a/types/a2a_pb2_grpc.py index 9b0ad41bc..ec930afff 100644 --- a/src/a2a/grpc/a2a_pb2_grpc.py +++ b/src/a2a/types/a2a_pb2_grpc.py @@ -1,22 +1,13 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! """Client and server classes corresponding to protobuf-defined services.""" +import a2a_pb2 as a2a__pb2 import grpc -from . import a2a_pb2 as a2a__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. +class A2AServiceStub: + """A2AService defines the operations of the A2A protocol. """ def __init__(self, channel): @@ -40,19 +31,24 @@ def __init__(self, channel): request_serializer=a2a__pb2.GetTaskRequest.SerializeToString, response_deserializer=a2a__pb2.Task.FromString, _registered_method=True) + self.ListTasks = channel.unary_unary( + '/a2a.v1.A2AService/ListTasks', + request_serializer=a2a__pb2.ListTasksRequest.SerializeToString, + response_deserializer=a2a__pb2.ListTasksResponse.FromString, + _registered_method=True) self.CancelTask = channel.unary_unary( '/a2a.v1.A2AService/CancelTask', request_serializer=a2a__pb2.CancelTaskRequest.SerializeToString, response_deserializer=a2a__pb2.Task.FromString, _registered_method=True) - self.TaskSubscription = channel.unary_stream( - '/a2a.v1.A2AService/TaskSubscription', - request_serializer=a2a__pb2.TaskSubscriptionRequest.SerializeToString, + self.SubscribeToTask = channel.unary_stream( + '/a2a.v1.A2AService/SubscribeToTask', + request_serializer=a2a__pb2.SubscribeToTaskRequest.SerializeToString, response_deserializer=a2a__pb2.StreamResponse.FromString, _registered_method=True) - self.CreateTaskPushNotificationConfig = channel.unary_unary( - '/a2a.v1.A2AService/CreateTaskPushNotificationConfig', - request_serializer=a2a__pb2.CreateTaskPushNotificationConfigRequest.SerializeToString, + self.SetTaskPushNotificationConfig = channel.unary_unary( + '/a2a.v1.A2AService/SetTaskPushNotificationConfig', + request_serializer=a2a__pb2.SetTaskPushNotificationConfigRequest.SerializeToString, response_deserializer=a2a__pb2.TaskPushNotificationConfig.FromString, _registered_method=True) self.GetTaskPushNotificationConfig = channel.unary_unary( @@ -65,9 +61,9 @@ def __init__(self, channel): request_serializer=a2a__pb2.ListTaskPushNotificationConfigRequest.SerializeToString, response_deserializer=a2a__pb2.ListTaskPushNotificationConfigResponse.FromString, _registered_method=True) - self.GetAgentCard = channel.unary_unary( - '/a2a.v1.A2AService/GetAgentCard', - request_serializer=a2a__pb2.GetAgentCardRequest.SerializeToString, + self.GetExtendedAgentCard = channel.unary_unary( + '/a2a.v1.A2AService/GetExtendedAgentCard', + request_serializer=a2a__pb2.GetExtendedAgentCardRequest.SerializeToString, response_deserializer=a2a__pb2.AgentCard.FromString, _registered_method=True) self.DeleteTaskPushNotificationConfig = channel.unary_unary( @@ -77,30 +73,19 @@ def __init__(self, channel): _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. +class A2AServiceServicer: + """A2AService defines the operations of the A2A protocol. """ 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. + """Send a message to the agent. """ 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. + """SendStreamingMessage is a streaming version of SendMessage. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -113,25 +98,29 @@ def GetTask(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def ListTasks(self, request, context): + """List tasks with optional filtering and pagination. + """ + 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. + """Cancel a 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. + def SubscribeToTask(self, request, context): + """SubscribeToTask allows subscribing to task updates for tasks not in terminal state. + Returns UnsupportedOperationError if task is in terminal state (completed, failed, cancelled, rejected). """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') - def CreateTaskPushNotificationConfig(self, request, context): + def SetTaskPushNotificationConfig(self, request, context): """Set a push notification config for a task. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) @@ -152,8 +141,8 @@ def ListTaskPushNotificationConfig(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') - def GetAgentCard(self, request, context): - """GetAgentCard returns the agent card for the agent. + def GetExtendedAgentCard(self, request, context): + """GetExtendedAgentCard returns the extended agent card for authenticated agents. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -184,19 +173,24 @@ def add_A2AServiceServicer_to_server(servicer, server): request_deserializer=a2a__pb2.GetTaskRequest.FromString, response_serializer=a2a__pb2.Task.SerializeToString, ), + 'ListTasks': grpc.unary_unary_rpc_method_handler( + servicer.ListTasks, + request_deserializer=a2a__pb2.ListTasksRequest.FromString, + response_serializer=a2a__pb2.ListTasksResponse.SerializeToString, + ), 'CancelTask': grpc.unary_unary_rpc_method_handler( servicer.CancelTask, request_deserializer=a2a__pb2.CancelTaskRequest.FromString, response_serializer=a2a__pb2.Task.SerializeToString, ), - 'TaskSubscription': grpc.unary_stream_rpc_method_handler( - servicer.TaskSubscription, - request_deserializer=a2a__pb2.TaskSubscriptionRequest.FromString, + 'SubscribeToTask': grpc.unary_stream_rpc_method_handler( + servicer.SubscribeToTask, + request_deserializer=a2a__pb2.SubscribeToTaskRequest.FromString, response_serializer=a2a__pb2.StreamResponse.SerializeToString, ), - 'CreateTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler( - servicer.CreateTaskPushNotificationConfig, - request_deserializer=a2a__pb2.CreateTaskPushNotificationConfigRequest.FromString, + 'SetTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler( + servicer.SetTaskPushNotificationConfig, + request_deserializer=a2a__pb2.SetTaskPushNotificationConfigRequest.FromString, response_serializer=a2a__pb2.TaskPushNotificationConfig.SerializeToString, ), 'GetTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler( @@ -209,9 +203,9 @@ def add_A2AServiceServicer_to_server(servicer, server): request_deserializer=a2a__pb2.ListTaskPushNotificationConfigRequest.FromString, response_serializer=a2a__pb2.ListTaskPushNotificationConfigResponse.SerializeToString, ), - 'GetAgentCard': grpc.unary_unary_rpc_method_handler( - servicer.GetAgentCard, - request_deserializer=a2a__pb2.GetAgentCardRequest.FromString, + 'GetExtendedAgentCard': grpc.unary_unary_rpc_method_handler( + servicer.GetExtendedAgentCard, + request_deserializer=a2a__pb2.GetExtendedAgentCardRequest.FromString, response_serializer=a2a__pb2.AgentCard.SerializeToString, ), 'DeleteTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler( @@ -227,17 +221,8 @@ def add_A2AServiceServicer_to_server(servicer, server): # 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. +class A2AService: + """A2AService defines the operations of the A2A protocol. """ @staticmethod @@ -321,6 +306,33 @@ def GetTask(request, metadata, _registered_method=True) + @staticmethod + def ListTasks(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/ListTasks', + a2a__pb2.ListTasksRequest.SerializeToString, + a2a__pb2.ListTasksResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + @staticmethod def CancelTask(request, target, @@ -349,7 +361,7 @@ def CancelTask(request, _registered_method=True) @staticmethod - def TaskSubscription(request, + def SubscribeToTask(request, target, options=(), channel_credentials=None, @@ -362,8 +374,8 @@ def TaskSubscription(request, return grpc.experimental.unary_stream( request, target, - '/a2a.v1.A2AService/TaskSubscription', - a2a__pb2.TaskSubscriptionRequest.SerializeToString, + '/a2a.v1.A2AService/SubscribeToTask', + a2a__pb2.SubscribeToTaskRequest.SerializeToString, a2a__pb2.StreamResponse.FromString, options, channel_credentials, @@ -376,7 +388,7 @@ def TaskSubscription(request, _registered_method=True) @staticmethod - def CreateTaskPushNotificationConfig(request, + def SetTaskPushNotificationConfig(request, target, options=(), channel_credentials=None, @@ -389,8 +401,8 @@ def CreateTaskPushNotificationConfig(request, return grpc.experimental.unary_unary( request, target, - '/a2a.v1.A2AService/CreateTaskPushNotificationConfig', - a2a__pb2.CreateTaskPushNotificationConfigRequest.SerializeToString, + '/a2a.v1.A2AService/SetTaskPushNotificationConfig', + a2a__pb2.SetTaskPushNotificationConfigRequest.SerializeToString, a2a__pb2.TaskPushNotificationConfig.FromString, options, channel_credentials, @@ -457,7 +469,7 @@ def ListTaskPushNotificationConfig(request, _registered_method=True) @staticmethod - def GetAgentCard(request, + def GetExtendedAgentCard(request, target, options=(), channel_credentials=None, @@ -470,8 +482,8 @@ def GetAgentCard(request, return grpc.experimental.unary_unary( request, target, - '/a2a.v1.A2AService/GetAgentCard', - a2a__pb2.GetAgentCardRequest.SerializeToString, + '/a2a.v1.A2AService/GetExtendedAgentCard', + a2a__pb2.GetExtendedAgentCardRequest.SerializeToString, a2a__pb2.AgentCard.FromString, options, channel_credentials, diff --git a/src/a2a/utils/artifact.py b/src/a2a/utils/artifact.py index 5053ca421..86172ff22 100644 --- a/src/a2a/utils/artifact.py +++ b/src/a2a/utils/artifact.py @@ -4,7 +4,7 @@ from typing import Any -from a2a.types import Artifact, DataPart, Part, TextPart +from a2a.types.a2a_pb2 import Artifact, DataPart, Part, TextPart from a2a.utils.parts import get_text_parts diff --git a/src/a2a/utils/error_handlers.py b/src/a2a/utils/error_handlers.py index d13c5e506..9e12e5528 100644 --- a/src/a2a/utils/error_handlers.py +++ b/src/a2a/utils/error_handlers.py @@ -16,7 +16,7 @@ from a2a._base import A2ABaseModel -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AuthenticatedExtendedCardNotConfiguredError, ContentTypeNotSupportedError, InternalError, diff --git a/src/a2a/utils/errors.py b/src/a2a/utils/errors.py index f2b6cc2b4..c272d461d 100644 --- a/src/a2a/utils/errors.py +++ b/src/a2a/utils/errors.py @@ -1,6 +1,6 @@ """Custom exceptions for A2A server-side errors.""" -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AuthenticatedExtendedCardNotConfiguredError, ContentTypeNotSupportedError, InternalError, diff --git a/src/a2a/utils/helpers.py b/src/a2a/utils/helpers.py index 96c1646a7..a9a0ad61d 100644 --- a/src/a2a/utils/helpers.py +++ b/src/a2a/utils/helpers.py @@ -8,7 +8,7 @@ from typing import Any from uuid import uuid4 -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Artifact, MessageSendParams, Part, @@ -43,7 +43,7 @@ def create_task_obj(message_send_params: MessageSendParams) -> Task: return Task( id=str(uuid4()), context_id=message_send_params.message.context_id, - status=TaskStatus(state=TaskState.submitted), + status=TaskStatus(state=TaskState.TASK_STATE_SUBMITTED), history=[message_send_params.message], ) diff --git a/src/a2a/utils/message.py b/src/a2a/utils/message.py index bfd675fdf..16c2f47ef 100644 --- a/src/a2a/utils/message.py +++ b/src/a2a/utils/message.py @@ -2,7 +2,7 @@ import uuid -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Message, Part, Role, diff --git a/src/a2a/utils/parts.py b/src/a2a/utils/parts.py index f32076c8c..fc91bf591 100644 --- a/src/a2a/utils/parts.py +++ b/src/a2a/utils/parts.py @@ -2,7 +2,7 @@ from typing import Any -from a2a.types import ( +from a2a.types.a2a_pb2 import ( DataPart, FilePart, FileWithBytes, @@ -21,7 +21,7 @@ def get_text_parts(parts: list[Part]) -> list[str]: Returns: A list of strings containing the text content from any `TextPart` objects found. """ - return [part.root.text for part in parts if isinstance(part.root, TextPart)] + return [part.text for part in parts if part.HasField("text")] def get_data_parts(parts: list[Part]) -> list[dict[str, Any]]: @@ -33,7 +33,7 @@ def get_data_parts(parts: list[Part]) -> list[dict[str, Any]]: Returns: A list of dictionaries containing the data from any `DataPart` objects found. """ - return [part.root.data for part in parts if isinstance(part.root, DataPart)] + return [part.data.data for part in parts if part.HasField("data")] def get_file_parts(parts: list[Part]) -> list[FileWithBytes | FileWithUri]: @@ -45,4 +45,4 @@ def get_file_parts(parts: list[Part]) -> list[FileWithBytes | FileWithUri]: Returns: A list of `FileWithBytes` or `FileWithUri` objects containing the file data from any `FilePart` objects found. """ - return [part.root.file for part in parts if isinstance(part.root, FilePart)] + return [part.file for part in parts if part.HasField("file")] diff --git a/src/a2a/utils/proto_utils.py b/src/a2a/utils/proto_utils.py deleted file mode 100644 index d077d62bf..000000000 --- a/src/a2a/utils/proto_utils.py +++ /dev/null @@ -1,1066 +0,0 @@ -# mypy: disable-error-code="arg-type" -"""Utils for converting between proto and Python types.""" - -import json -import logging -import re - -from typing import Any - -from google.protobuf import json_format, struct_pb2 - -from a2a import types -from a2a.grpc import a2a_pb2 -from a2a.utils.errors import ServerError - - -logger = logging.getLogger(__name__) - - -# Regexp patterns for matching -_TASK_NAME_MATCH = re.compile(r'tasks/([^/]+)') -_TASK_PUSH_CONFIG_NAME_MATCH = re.compile( - r'tasks/([^/]+)/pushNotificationConfigs/([^/]+)' -) - - -def dict_to_struct(dictionary: dict[str, Any]) -> struct_pb2.Struct: - """Converts a Python dict to a Struct proto. - - Unfortunately, using `json_format.ParseDict` does not work because this - wants the dictionary to be an exact match of the Struct proto with fields - and keys and values, not the traditional Python dict structure. - - Args: - dictionary: The Python dict to convert. - - Returns: - The Struct proto. - """ - struct = struct_pb2.Struct() - for key, val in dictionary.items(): - if isinstance(val, dict): - struct[key] = dict_to_struct(val) - else: - struct[key] = val - return struct - - -def make_dict_serializable(value: Any) -> Any: - """Dict pre-processing utility: converts non-serializable values to serializable form. - - Use this when you want to normalize a dictionary before dict->Struct conversion. - - Args: - value: The value to convert. - - Returns: - A serializable value. - """ - if isinstance(value, str | int | float | bool) or value is None: - return value - if isinstance(value, dict): - return {k: make_dict_serializable(v) for k, v in value.items()} - if isinstance(value, list | tuple): - return [make_dict_serializable(item) for item in value] - return str(value) - - -def normalize_large_integers_to_strings( - value: Any, max_safe_digits: int = 15 -) -> Any: - """Integer preprocessing utility: converts large integers to strings. - - Use this when you want to convert large integers to strings considering - JavaScript's MAX_SAFE_INTEGER (2^53 - 1) limitation. - - Args: - value: The value to convert. - max_safe_digits: Maximum safe integer digits (default: 15). - - Returns: - A normalized value. - """ - max_safe_int = 10**max_safe_digits - 1 - - def _normalize(item: Any) -> Any: - if isinstance(item, int) and abs(item) > max_safe_int: - return str(item) - if isinstance(item, dict): - return {k: _normalize(v) for k, v in item.items()} - if isinstance(item, list | tuple): - return [_normalize(i) for i in item] - return item - - return _normalize(value) - - -def parse_string_integers_in_dict(value: Any, max_safe_digits: int = 15) -> Any: - """String post-processing utility: converts large integer strings back to integers. - - Use this when you want to restore large integer strings to integers - after Struct->dict conversion. - - Args: - value: The value to convert. - max_safe_digits: Maximum safe integer digits (default: 15). - - Returns: - A parsed value. - """ - if isinstance(value, dict): - return { - k: parse_string_integers_in_dict(v, max_safe_digits) - for k, v in value.items() - } - if isinstance(value, list | tuple): - return [ - parse_string_integers_in_dict(item, max_safe_digits) - for item in value - ] - if isinstance(value, str): - # Handle potential negative numbers. - stripped_value = value.lstrip('-') - if stripped_value.isdigit() and len(stripped_value) > max_safe_digits: - return int(value) - return value - - -class ToProto: - """Converts Python types to proto types.""" - - @classmethod - def message(cls, message: types.Message | None) -> a2a_pb2.Message | None: - if message is None: - return None - return a2a_pb2.Message( - message_id=message.message_id, - content=[cls.part(p) for p in message.parts], - context_id=message.context_id or '', - task_id=message.task_id or '', - role=cls.role(message.role), - metadata=cls.metadata(message.metadata), - extensions=message.extensions or [], - ) - - @classmethod - def metadata( - cls, metadata: dict[str, Any] | None - ) -> struct_pb2.Struct | None: - if metadata is None: - return None - return dict_to_struct(metadata) - - @classmethod - def part(cls, part: types.Part) -> a2a_pb2.Part: - if isinstance(part.root, types.TextPart): - return a2a_pb2.Part( - text=part.root.text, metadata=cls.metadata(part.root.metadata) - ) - if isinstance(part.root, types.FilePart): - return a2a_pb2.Part( - file=cls.file(part.root.file), - metadata=cls.metadata(part.root.metadata), - ) - if isinstance(part.root, types.DataPart): - return a2a_pb2.Part( - data=cls.data(part.root.data), - metadata=cls.metadata(part.root.metadata), - ) - raise ValueError(f'Unsupported part type: {part.root}') - - @classmethod - def data(cls, data: dict[str, Any]) -> a2a_pb2.DataPart: - return a2a_pb2.DataPart(data=dict_to_struct(data)) - - @classmethod - def file( - cls, file: types.FileWithUri | types.FileWithBytes - ) -> a2a_pb2.FilePart: - if isinstance(file, types.FileWithUri): - return a2a_pb2.FilePart( - file_with_uri=file.uri, mime_type=file.mime_type, name=file.name - ) - return a2a_pb2.FilePart( - file_with_bytes=file.bytes.encode('utf-8'), - mime_type=file.mime_type, - name=file.name, - ) - - @classmethod - def task(cls, task: types.Task) -> a2a_pb2.Task: - return a2a_pb2.Task( - id=task.id, - context_id=task.context_id, - status=cls.task_status(task.status), - artifacts=( - [cls.artifact(a) for a in task.artifacts] - if task.artifacts - else None - ), - history=( - [cls.message(h) for h in task.history] # type: ignore[misc] - if task.history - else None - ), - ) - - @classmethod - def task_status(cls, status: types.TaskStatus) -> a2a_pb2.TaskStatus: - return a2a_pb2.TaskStatus( - state=cls.task_state(status.state), - update=cls.message(status.message), - ) - - @classmethod - def task_state(cls, state: types.TaskState) -> a2a_pb2.TaskState: - match state: - case types.TaskState.submitted: - return a2a_pb2.TaskState.TASK_STATE_SUBMITTED - case types.TaskState.working: - return a2a_pb2.TaskState.TASK_STATE_WORKING - case types.TaskState.completed: - return a2a_pb2.TaskState.TASK_STATE_COMPLETED - case types.TaskState.canceled: - return a2a_pb2.TaskState.TASK_STATE_CANCELLED - case types.TaskState.failed: - return a2a_pb2.TaskState.TASK_STATE_FAILED - case types.TaskState.input_required: - return a2a_pb2.TaskState.TASK_STATE_INPUT_REQUIRED - case types.TaskState.auth_required: - return a2a_pb2.TaskState.TASK_STATE_AUTH_REQUIRED - case _: - return a2a_pb2.TaskState.TASK_STATE_UNSPECIFIED - - @classmethod - def artifact(cls, artifact: types.Artifact) -> a2a_pb2.Artifact: - return a2a_pb2.Artifact( - artifact_id=artifact.artifact_id, - description=artifact.description, - metadata=cls.metadata(artifact.metadata), - name=artifact.name, - parts=[cls.part(p) for p in artifact.parts], - extensions=artifact.extensions or [], - ) - - @classmethod - def authentication_info( - cls, info: types.PushNotificationAuthenticationInfo - ) -> a2a_pb2.AuthenticationInfo: - return a2a_pb2.AuthenticationInfo( - schemes=info.schemes, - credentials=info.credentials, - ) - - @classmethod - def push_notification_config( - cls, config: types.PushNotificationConfig - ) -> a2a_pb2.PushNotificationConfig: - auth_info = ( - cls.authentication_info(config.authentication) - if config.authentication - else None - ) - return a2a_pb2.PushNotificationConfig( - id=config.id or '', - url=config.url, - token=config.token, - authentication=auth_info, - ) - - @classmethod - def task_artifact_update_event( - cls, event: types.TaskArtifactUpdateEvent - ) -> a2a_pb2.TaskArtifactUpdateEvent: - return a2a_pb2.TaskArtifactUpdateEvent( - task_id=event.task_id, - context_id=event.context_id, - artifact=cls.artifact(event.artifact), - metadata=cls.metadata(event.metadata), - append=event.append or False, - last_chunk=event.last_chunk or False, - ) - - @classmethod - def task_status_update_event( - cls, event: types.TaskStatusUpdateEvent - ) -> a2a_pb2.TaskStatusUpdateEvent: - return a2a_pb2.TaskStatusUpdateEvent( - task_id=event.task_id, - context_id=event.context_id, - status=cls.task_status(event.status), - metadata=cls.metadata(event.metadata), - final=event.final, - ) - - @classmethod - def message_send_configuration( - cls, config: types.MessageSendConfiguration | None - ) -> a2a_pb2.SendMessageConfiguration: - if not config: - return a2a_pb2.SendMessageConfiguration() - return a2a_pb2.SendMessageConfiguration( - accepted_output_modes=config.accepted_output_modes, - push_notification=cls.push_notification_config( - config.push_notification_config - ) - if config.push_notification_config - else None, - history_length=config.history_length, - blocking=config.blocking or False, - ) - - @classmethod - def update_event( - cls, - event: types.Task - | types.Message - | types.TaskStatusUpdateEvent - | types.TaskArtifactUpdateEvent, - ) -> a2a_pb2.StreamResponse: - """Converts a task, message, or task update event to a StreamResponse.""" - return cls.stream_response(event) - - @classmethod - def task_or_message( - cls, event: types.Task | types.Message - ) -> a2a_pb2.SendMessageResponse: - if isinstance(event, types.Message): - return a2a_pb2.SendMessageResponse( - msg=cls.message(event), - ) - return a2a_pb2.SendMessageResponse( - task=cls.task(event), - ) - - @classmethod - def stream_response( - cls, - event: ( - types.Message - | types.Task - | types.TaskStatusUpdateEvent - | types.TaskArtifactUpdateEvent - ), - ) -> a2a_pb2.StreamResponse: - if isinstance(event, types.Message): - return a2a_pb2.StreamResponse(msg=cls.message(event)) - if isinstance(event, types.Task): - return a2a_pb2.StreamResponse(task=cls.task(event)) - if isinstance(event, types.TaskStatusUpdateEvent): - return a2a_pb2.StreamResponse( - status_update=cls.task_status_update_event(event), - ) - if isinstance(event, types.TaskArtifactUpdateEvent): - return a2a_pb2.StreamResponse( - artifact_update=cls.task_artifact_update_event(event), - ) - raise ValueError(f'Unsupported event type: {type(event)}') - - @classmethod - def task_push_notification_config( - cls, config: types.TaskPushNotificationConfig - ) -> a2a_pb2.TaskPushNotificationConfig: - return a2a_pb2.TaskPushNotificationConfig( - name=f'tasks/{config.task_id}/pushNotificationConfigs/{config.push_notification_config.id}', - push_notification_config=cls.push_notification_config( - config.push_notification_config, - ), - ) - - @classmethod - def agent_card( - cls, - card: types.AgentCard, - ) -> a2a_pb2.AgentCard: - return a2a_pb2.AgentCard( - capabilities=cls.capabilities(card.capabilities), - default_input_modes=list(card.default_input_modes), - default_output_modes=list(card.default_output_modes), - description=card.description, - documentation_url=card.documentation_url, - name=card.name, - provider=cls.provider(card.provider), - security=cls.security(card.security), - security_schemes=cls.security_schemes(card.security_schemes), - skills=[cls.skill(x) for x in card.skills] if card.skills else [], - url=card.url, - version=card.version, - supports_authenticated_extended_card=bool( - card.supports_authenticated_extended_card - ), - preferred_transport=card.preferred_transport, - protocol_version=card.protocol_version, - additional_interfaces=[ - cls.agent_interface(x) for x in card.additional_interfaces - ] - if card.additional_interfaces - else None, - ) - - @classmethod - def agent_interface( - cls, - interface: types.AgentInterface, - ) -> a2a_pb2.AgentInterface: - return a2a_pb2.AgentInterface( - transport=interface.transport, - url=interface.url, - ) - - @classmethod - def capabilities( - cls, capabilities: types.AgentCapabilities - ) -> a2a_pb2.AgentCapabilities: - return a2a_pb2.AgentCapabilities( - streaming=bool(capabilities.streaming), - push_notifications=bool(capabilities.push_notifications), - extensions=[ - cls.extension(x) for x in capabilities.extensions or [] - ], - ) - - @classmethod - def extension( - cls, - extension: types.AgentExtension, - ) -> a2a_pb2.AgentExtension: - return a2a_pb2.AgentExtension( - uri=extension.uri, - description=extension.description, - params=dict_to_struct(extension.params) - if extension.params - else None, - required=extension.required, - ) - - @classmethod - def provider( - cls, provider: types.AgentProvider | None - ) -> a2a_pb2.AgentProvider | None: - if not provider: - return None - return a2a_pb2.AgentProvider( - organization=provider.organization, - url=provider.url, - ) - - @classmethod - def security( - cls, - security: list[dict[str, list[str]]] | None, - ) -> list[a2a_pb2.Security] | None: - if not security: - return None - return [ - a2a_pb2.Security( - schemes={k: a2a_pb2.StringList(list=v) for (k, v) in s.items()} - ) - for s in security - ] - - @classmethod - def security_schemes( - cls, - schemes: dict[str, types.SecurityScheme] | None, - ) -> dict[str, a2a_pb2.SecurityScheme] | None: - if not schemes: - return None - return {k: cls.security_scheme(v) for (k, v) in schemes.items()} - - @classmethod - def security_scheme( - cls, - scheme: types.SecurityScheme, - ) -> a2a_pb2.SecurityScheme: - if isinstance(scheme.root, types.APIKeySecurityScheme): - return a2a_pb2.SecurityScheme( - api_key_security_scheme=a2a_pb2.APIKeySecurityScheme( - description=scheme.root.description, - location=scheme.root.in_.value, - name=scheme.root.name, - ) - ) - if isinstance(scheme.root, types.HTTPAuthSecurityScheme): - return a2a_pb2.SecurityScheme( - http_auth_security_scheme=a2a_pb2.HTTPAuthSecurityScheme( - description=scheme.root.description, - scheme=scheme.root.scheme, - bearer_format=scheme.root.bearer_format, - ) - ) - if isinstance(scheme.root, types.OAuth2SecurityScheme): - return a2a_pb2.SecurityScheme( - oauth2_security_scheme=a2a_pb2.OAuth2SecurityScheme( - description=scheme.root.description, - flows=cls.oauth2_flows(scheme.root.flows), - ) - ) - if isinstance(scheme.root, types.MutualTLSSecurityScheme): - return a2a_pb2.SecurityScheme( - mtls_security_scheme=a2a_pb2.MutualTlsSecurityScheme( - description=scheme.root.description, - ) - ) - return a2a_pb2.SecurityScheme( - open_id_connect_security_scheme=a2a_pb2.OpenIdConnectSecurityScheme( - description=scheme.root.description, - open_id_connect_url=scheme.root.open_id_connect_url, - ) - ) - - @classmethod - def oauth2_flows(cls, flows: types.OAuthFlows) -> a2a_pb2.OAuthFlows: - if flows.authorization_code: - return a2a_pb2.OAuthFlows( - authorization_code=a2a_pb2.AuthorizationCodeOAuthFlow( - authorization_url=flows.authorization_code.authorization_url, - refresh_url=flows.authorization_code.refresh_url, - scopes=dict(flows.authorization_code.scopes.items()), - token_url=flows.authorization_code.token_url, - ), - ) - if flows.client_credentials: - return a2a_pb2.OAuthFlows( - client_credentials=a2a_pb2.ClientCredentialsOAuthFlow( - refresh_url=flows.client_credentials.refresh_url, - scopes=dict(flows.client_credentials.scopes.items()), - token_url=flows.client_credentials.token_url, - ), - ) - if flows.implicit: - return a2a_pb2.OAuthFlows( - implicit=a2a_pb2.ImplicitOAuthFlow( - authorization_url=flows.implicit.authorization_url, - refresh_url=flows.implicit.refresh_url, - scopes=dict(flows.implicit.scopes.items()), - ), - ) - if flows.password: - return a2a_pb2.OAuthFlows( - password=a2a_pb2.PasswordOAuthFlow( - refresh_url=flows.password.refresh_url, - scopes=dict(flows.password.scopes.items()), - token_url=flows.password.token_url, - ), - ) - raise ValueError('Unknown oauth flow definition') - - @classmethod - def skill(cls, skill: types.AgentSkill) -> a2a_pb2.AgentSkill: - return a2a_pb2.AgentSkill( - id=skill.id, - name=skill.name, - description=skill.description, - tags=skill.tags, - examples=skill.examples, - input_modes=skill.input_modes, - output_modes=skill.output_modes, - ) - - @classmethod - def role(cls, role: types.Role) -> a2a_pb2.Role: - match role: - case types.Role.user: - return a2a_pb2.Role.ROLE_USER - case types.Role.agent: - return a2a_pb2.Role.ROLE_AGENT - case _: - return a2a_pb2.Role.ROLE_UNSPECIFIED - - -class FromProto: - """Converts proto types to Python types.""" - - @classmethod - def message(cls, message: a2a_pb2.Message) -> types.Message: - return types.Message( - message_id=message.message_id, - parts=[cls.part(p) for p in message.content], - context_id=message.context_id or None, - task_id=message.task_id or None, - role=cls.role(message.role), - metadata=cls.metadata(message.metadata), - extensions=list(message.extensions) or None, - ) - - @classmethod - def metadata(cls, metadata: struct_pb2.Struct) -> dict[str, Any]: - if not metadata.fields: - return {} - return json_format.MessageToDict(metadata) - - @classmethod - def part(cls, part: a2a_pb2.Part) -> types.Part: - if part.HasField('text'): - return types.Part( - root=types.TextPart( - text=part.text, - metadata=cls.metadata(part.metadata) - if part.metadata - else None, - ), - ) - if part.HasField('file'): - return types.Part( - root=types.FilePart( - file=cls.file(part.file), - metadata=cls.metadata(part.metadata) - if part.metadata - else None, - ), - ) - if part.HasField('data'): - return types.Part( - root=types.DataPart( - data=cls.data(part.data), - metadata=cls.metadata(part.metadata) - if part.metadata - else None, - ), - ) - raise ValueError(f'Unsupported part type: {part}') - - @classmethod - def data(cls, data: a2a_pb2.DataPart) -> dict[str, Any]: - json_data = json_format.MessageToJson(data.data) - return json.loads(json_data) - - @classmethod - def file( - cls, file: a2a_pb2.FilePart - ) -> types.FileWithUri | types.FileWithBytes: - common_args = { - 'mime_type': file.mime_type or None, - 'name': file.name or None, - } - if file.HasField('file_with_uri'): - return types.FileWithUri( - uri=file.file_with_uri, - **common_args, - ) - return types.FileWithBytes( - bytes=file.file_with_bytes.decode('utf-8'), - **common_args, - ) - - @classmethod - def task_or_message( - cls, event: a2a_pb2.SendMessageResponse - ) -> types.Task | types.Message: - if event.HasField('msg'): - return cls.message(event.msg) - return cls.task(event.task) - - @classmethod - def task(cls, task: a2a_pb2.Task) -> types.Task: - return types.Task( - id=task.id, - context_id=task.context_id, - status=cls.task_status(task.status), - artifacts=[cls.artifact(a) for a in task.artifacts], - history=[cls.message(h) for h in task.history], - ) - - @classmethod - def task_status(cls, status: a2a_pb2.TaskStatus) -> types.TaskStatus: - return types.TaskStatus( - state=cls.task_state(status.state), - message=cls.message(status.update), - ) - - @classmethod - def task_state(cls, state: a2a_pb2.TaskState) -> types.TaskState: - match state: - case a2a_pb2.TaskState.TASK_STATE_SUBMITTED: - return types.TaskState.submitted - case a2a_pb2.TaskState.TASK_STATE_WORKING: - return types.TaskState.working - case a2a_pb2.TaskState.TASK_STATE_COMPLETED: - return types.TaskState.completed - case a2a_pb2.TaskState.TASK_STATE_CANCELLED: - return types.TaskState.canceled - case a2a_pb2.TaskState.TASK_STATE_FAILED: - return types.TaskState.failed - case a2a_pb2.TaskState.TASK_STATE_INPUT_REQUIRED: - return types.TaskState.input_required - case a2a_pb2.TaskState.TASK_STATE_AUTH_REQUIRED: - return types.TaskState.auth_required - case _: - return types.TaskState.unknown - - @classmethod - def artifact(cls, artifact: a2a_pb2.Artifact) -> types.Artifact: - return types.Artifact( - artifact_id=artifact.artifact_id, - description=artifact.description, - metadata=cls.metadata(artifact.metadata), - name=artifact.name, - parts=[cls.part(p) for p in artifact.parts], - extensions=artifact.extensions or None, - ) - - @classmethod - def task_artifact_update_event( - cls, event: a2a_pb2.TaskArtifactUpdateEvent - ) -> types.TaskArtifactUpdateEvent: - return types.TaskArtifactUpdateEvent( - task_id=event.task_id, - context_id=event.context_id, - artifact=cls.artifact(event.artifact), - metadata=cls.metadata(event.metadata), - append=event.append, - last_chunk=event.last_chunk, - ) - - @classmethod - def task_status_update_event( - cls, event: a2a_pb2.TaskStatusUpdateEvent - ) -> types.TaskStatusUpdateEvent: - return types.TaskStatusUpdateEvent( - task_id=event.task_id, - context_id=event.context_id, - status=cls.task_status(event.status), - metadata=cls.metadata(event.metadata), - final=event.final, - ) - - @classmethod - def push_notification_config( - cls, config: a2a_pb2.PushNotificationConfig - ) -> types.PushNotificationConfig: - return types.PushNotificationConfig( - id=config.id, - url=config.url, - token=config.token, - authentication=cls.authentication_info(config.authentication) - if config.HasField('authentication') - else None, - ) - - @classmethod - def authentication_info( - cls, info: a2a_pb2.AuthenticationInfo - ) -> types.PushNotificationAuthenticationInfo: - return types.PushNotificationAuthenticationInfo( - schemes=list(info.schemes), - credentials=info.credentials, - ) - - @classmethod - def message_send_configuration( - cls, config: a2a_pb2.SendMessageConfiguration - ) -> types.MessageSendConfiguration: - return types.MessageSendConfiguration( - accepted_output_modes=list(config.accepted_output_modes), - push_notification_config=cls.push_notification_config( - config.push_notification - ) - if config.HasField('push_notification') - else None, - history_length=config.history_length, - blocking=config.blocking, - ) - - @classmethod - def message_send_params( - cls, request: a2a_pb2.SendMessageRequest - ) -> types.MessageSendParams: - return types.MessageSendParams( - configuration=cls.message_send_configuration(request.configuration), - message=cls.message(request.request), - metadata=cls.metadata(request.metadata), - ) - - @classmethod - def task_id_params( - cls, - request: ( - a2a_pb2.CancelTaskRequest - | a2a_pb2.TaskSubscriptionRequest - | a2a_pb2.GetTaskPushNotificationConfigRequest - ), - ) -> types.TaskIdParams: - if isinstance(request, a2a_pb2.GetTaskPushNotificationConfigRequest): - m = _TASK_PUSH_CONFIG_NAME_MATCH.match(request.name) - if not m: - raise ServerError( - error=types.InvalidParamsError( - message=f'No task for {request.name}' - ) - ) - return types.TaskIdParams(id=m.group(1)) - m = _TASK_NAME_MATCH.match(request.name) - if not m: - raise ServerError( - error=types.InvalidParamsError( - message=f'No task for {request.name}' - ) - ) - return types.TaskIdParams(id=m.group(1)) - - @classmethod - def task_push_notification_config_request( - cls, - request: a2a_pb2.CreateTaskPushNotificationConfigRequest, - ) -> types.TaskPushNotificationConfig: - m = _TASK_NAME_MATCH.match(request.parent) - if not m: - raise ServerError( - error=types.InvalidParamsError( - message=f'No task for {request.parent}' - ) - ) - return types.TaskPushNotificationConfig( - push_notification_config=cls.push_notification_config( - request.config.push_notification_config, - ), - task_id=m.group(1), - ) - - @classmethod - def task_push_notification_config( - cls, - config: a2a_pb2.TaskPushNotificationConfig, - ) -> types.TaskPushNotificationConfig: - m = _TASK_PUSH_CONFIG_NAME_MATCH.match(config.name) - if not m: - raise ServerError( - error=types.InvalidParamsError( - message=f'Bad TaskPushNotificationConfig resource name {config.name}' - ) - ) - return types.TaskPushNotificationConfig( - push_notification_config=cls.push_notification_config( - config.push_notification_config, - ), - task_id=m.group(1), - ) - - @classmethod - def agent_card( - cls, - card: a2a_pb2.AgentCard, - ) -> types.AgentCard: - return types.AgentCard( - capabilities=cls.capabilities(card.capabilities), - default_input_modes=list(card.default_input_modes), - default_output_modes=list(card.default_output_modes), - description=card.description, - documentation_url=card.documentation_url, - name=card.name, - provider=cls.provider(card.provider), - security=cls.security(list(card.security)), - security_schemes=cls.security_schemes(dict(card.security_schemes)), - skills=[cls.skill(x) for x in card.skills] if card.skills else [], - url=card.url, - version=card.version, - supports_authenticated_extended_card=card.supports_authenticated_extended_card, - preferred_transport=card.preferred_transport, - protocol_version=card.protocol_version, - additional_interfaces=[ - cls.agent_interface(x) for x in card.additional_interfaces - ] - if card.additional_interfaces - else None, - ) - - @classmethod - def agent_interface( - cls, - interface: a2a_pb2.AgentInterface, - ) -> types.AgentInterface: - return types.AgentInterface( - transport=interface.transport, - url=interface.url, - ) - - @classmethod - def task_query_params( - cls, - request: a2a_pb2.GetTaskRequest, - ) -> types.TaskQueryParams: - m = _TASK_NAME_MATCH.match(request.name) - if not m: - raise ServerError( - error=types.InvalidParamsError( - message=f'No task for {request.name}' - ) - ) - return types.TaskQueryParams( - history_length=request.history_length - if request.history_length - else None, - id=m.group(1), - metadata=None, - ) - - @classmethod - def capabilities( - cls, capabilities: a2a_pb2.AgentCapabilities - ) -> types.AgentCapabilities: - return types.AgentCapabilities( - streaming=capabilities.streaming, - push_notifications=capabilities.push_notifications, - extensions=[ - cls.agent_extension(x) for x in capabilities.extensions - ], - ) - - @classmethod - def agent_extension( - cls, - extension: a2a_pb2.AgentExtension, - ) -> types.AgentExtension: - return types.AgentExtension( - uri=extension.uri, - description=extension.description, - params=json_format.MessageToDict(extension.params), - required=extension.required, - ) - - @classmethod - def security( - cls, - security: list[a2a_pb2.Security] | None, - ) -> list[dict[str, list[str]]] | None: - if not security: - return None - return [ - {k: list(v.list) for (k, v) in s.schemes.items()} for s in security - ] - - @classmethod - def provider( - cls, provider: a2a_pb2.AgentProvider | None - ) -> types.AgentProvider | None: - if not provider: - return None - return types.AgentProvider( - organization=provider.organization, - url=provider.url, - ) - - @classmethod - def security_schemes( - cls, schemes: dict[str, a2a_pb2.SecurityScheme] - ) -> dict[str, types.SecurityScheme]: - return {k: cls.security_scheme(v) for (k, v) in schemes.items()} - - @classmethod - def security_scheme( - cls, - scheme: a2a_pb2.SecurityScheme, - ) -> types.SecurityScheme: - if scheme.HasField('api_key_security_scheme'): - return types.SecurityScheme( - root=types.APIKeySecurityScheme( - description=scheme.api_key_security_scheme.description, - name=scheme.api_key_security_scheme.name, - in_=types.In(scheme.api_key_security_scheme.location), # type: ignore[call-arg] - ) - ) - if scheme.HasField('http_auth_security_scheme'): - return types.SecurityScheme( - root=types.HTTPAuthSecurityScheme( - description=scheme.http_auth_security_scheme.description, - scheme=scheme.http_auth_security_scheme.scheme, - bearer_format=scheme.http_auth_security_scheme.bearer_format, - ) - ) - if scheme.HasField('oauth2_security_scheme'): - return types.SecurityScheme( - root=types.OAuth2SecurityScheme( - description=scheme.oauth2_security_scheme.description, - flows=cls.oauth2_flows(scheme.oauth2_security_scheme.flows), - ) - ) - if scheme.HasField('mtls_security_scheme'): - return types.SecurityScheme( - root=types.MutualTLSSecurityScheme( - description=scheme.mtls_security_scheme.description, - ) - ) - return types.SecurityScheme( - root=types.OpenIdConnectSecurityScheme( - description=scheme.open_id_connect_security_scheme.description, - open_id_connect_url=scheme.open_id_connect_security_scheme.open_id_connect_url, - ) - ) - - @classmethod - def oauth2_flows(cls, flows: a2a_pb2.OAuthFlows) -> types.OAuthFlows: - if flows.HasField('authorization_code'): - return types.OAuthFlows( - authorization_code=types.AuthorizationCodeOAuthFlow( - authorization_url=flows.authorization_code.authorization_url, - refresh_url=flows.authorization_code.refresh_url, - scopes=dict(flows.authorization_code.scopes.items()), - token_url=flows.authorization_code.token_url, - ), - ) - if flows.HasField('client_credentials'): - return types.OAuthFlows( - client_credentials=types.ClientCredentialsOAuthFlow( - refresh_url=flows.client_credentials.refresh_url, - scopes=dict(flows.client_credentials.scopes.items()), - token_url=flows.client_credentials.token_url, - ), - ) - if flows.HasField('implicit'): - return types.OAuthFlows( - implicit=types.ImplicitOAuthFlow( - authorization_url=flows.implicit.authorization_url, - refresh_url=flows.implicit.refresh_url, - scopes=dict(flows.implicit.scopes.items()), - ), - ) - return types.OAuthFlows( - password=types.PasswordOAuthFlow( - refresh_url=flows.password.refresh_url, - scopes=dict(flows.password.scopes.items()), - token_url=flows.password.token_url, - ), - ) - - @classmethod - def stream_response( - cls, - response: a2a_pb2.StreamResponse, - ) -> ( - types.Message - | types.Task - | types.TaskStatusUpdateEvent - | types.TaskArtifactUpdateEvent - ): - if response.HasField('msg'): - return cls.message(response.msg) - if response.HasField('task'): - return cls.task(response.task) - if response.HasField('status_update'): - return cls.task_status_update_event(response.status_update) - if response.HasField('artifact_update'): - return cls.task_artifact_update_event(response.artifact_update) - raise ValueError('Unsupported StreamResponse type') - - @classmethod - def skill(cls, skill: a2a_pb2.AgentSkill) -> types.AgentSkill: - return types.AgentSkill( - id=skill.id, - name=skill.name, - description=skill.description, - tags=list(skill.tags), - examples=list(skill.examples), - input_modes=list(skill.input_modes), - output_modes=list(skill.output_modes), - ) - - @classmethod - def role(cls, role: a2a_pb2.Role) -> types.Role: - match role: - case a2a_pb2.Role.ROLE_USER: - return types.Role.user - case a2a_pb2.Role.ROLE_AGENT: - return types.Role.agent - case _: - return types.Role.agent diff --git a/src/a2a/utils/task.py b/src/a2a/utils/task.py index d8215cec0..cc9ede0a4 100644 --- a/src/a2a/utils/task.py +++ b/src/a2a/utils/task.py @@ -2,7 +2,13 @@ import uuid -from a2a.types import Artifact, Message, Task, TaskState, TaskStatus, TextPart +from a2a.types.a2a_pb2 import ( + Artifact, + Message, + Task, + TaskState, + TaskStatus, +) def new_task(request: Message) -> Task: @@ -25,11 +31,11 @@ def new_task(request: Message) -> Task: if not request.parts: raise ValueError('Message parts cannot be empty') for part in request.parts: - if isinstance(part.root, TextPart) and not part.root.text: - raise ValueError('TextPart content cannot be empty') + if part.text is not None and not part.text: + raise ValueError('Message.text cannot be empty') return Task( - status=TaskStatus(state=TaskState.submitted), + status=TaskStatus(state=TaskState.TASK_STATE_SUBMITTED), id=request.task_id or str(uuid.uuid4()), context_id=request.context_id or str(uuid.uuid4()), history=[request], @@ -64,7 +70,7 @@ def completed_task( if history is None: history = [] return Task( - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), id=task_id, context_id=context_id, artifacts=artifacts, @@ -87,6 +93,8 @@ def apply_history_length(task: Task, history_length: int | None) -> Task: # Limit history to the most recent N messages limited_history = task.history[-history_length:] # Create a new task instance with limited history - return task.model_copy(update={'history': limited_history}) - + task_copy = Task() + task_copy.CopyFrom(task) + task_copy.history = limited_history + return task_copy return task diff --git a/tests/client/test_auth_middleware.py b/tests/client/test_auth_middleware.py index c41b45017..5de3f2b6a 100644 --- a/tests/client/test_auth_middleware.py +++ b/tests/client/test_auth_middleware.py @@ -17,7 +17,7 @@ ClientFactory, InMemoryContextCredentialStore, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( APIKeySecurityScheme, AgentCapabilities, AgentCard, diff --git a/tests/client/test_base_client.py b/tests/client/test_base_client.py index f5ab25432..84e4c6f6a 100644 --- a/tests/client/test_base_client.py +++ b/tests/client/test_base_client.py @@ -5,7 +5,7 @@ from a2a.client.base_client import BaseClient from a2a.client.client import ClientConfig from a2a.client.transports.base import ClientTransport -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCapabilities, AgentCard, Message, @@ -68,7 +68,7 @@ async def create_stream(*args, **kwargs): yield Task( id='task-123', context_id='ctx-456', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), ) mock_transport.send_message_streaming.return_value = create_stream() @@ -94,7 +94,7 @@ async def test_send_message_non_streaming( mock_transport.send_message.return_value = Task( id='task-456', context_id='ctx-789', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), ) meta = {'test': 1} @@ -116,7 +116,7 @@ async def test_send_message_non_streaming_agent_capability_false( mock_transport.send_message.return_value = Task( id='task-789', context_id='ctx-101', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), ) events = [event async for event in base_client.send_message(sample_message)] diff --git a/tests/client/test_client_factory.py b/tests/client/test_client_factory.py index 16a1433fb..65aab9394 100644 --- a/tests/client/test_client_factory.py +++ b/tests/client/test_client_factory.py @@ -7,7 +7,7 @@ from a2a.client import ClientConfig, ClientFactory from a2a.client.transports import JsonRpcTransport, RestTransport -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCapabilities, AgentCard, AgentInterface, diff --git a/tests/client/test_client_task_manager.py b/tests/client/test_client_task_manager.py index 63f98d8b9..7f6d87cf6 100644 --- a/tests/client/test_client_task_manager.py +++ b/tests/client/test_client_task_manager.py @@ -7,7 +7,7 @@ A2AClientInvalidArgsError, A2AClientInvalidStateError, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Artifact, Message, Part, @@ -31,7 +31,7 @@ def sample_task() -> Task: return Task( id='task123', context_id='context456', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), history=[], artifacts=[], ) @@ -89,11 +89,11 @@ async def test_save_task_event_with_status_update( status_update = TaskStatusUpdateEvent( task_id=sample_task.id, context_id=sample_task.context_id, - status=TaskStatus(state=TaskState.completed, message=sample_message), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED, message=sample_message), final=True, ) updated_task = await task_manager.save_task_event(status_update) - assert updated_task.status.state == TaskState.completed + assert updated_task.status.state == TaskState.TASK_STATE_COMPLETED assert updated_task.history == [sample_message] @@ -125,13 +125,13 @@ async def test_save_task_event_creates_task_if_not_exists( status_update = TaskStatusUpdateEvent( task_id='new_task', context_id='new_context', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), final=False, ) updated_task = await task_manager.save_task_event(status_update) assert updated_task is not None assert updated_task.id == 'new_task' - assert updated_task.status.state == TaskState.working + assert updated_task.status.state == TaskState.TASK_STATE_WORKING @pytest.mark.asyncio diff --git a/tests/client/test_legacy_client.py b/tests/client/test_legacy_client.py index 1bd9e4ae2..ce55b404f 100644 --- a/tests/client/test_legacy_client.py +++ b/tests/client/test_legacy_client.py @@ -6,7 +6,7 @@ import pytest from a2a.client import A2AClient, A2AGrpcClient -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCapabilities, AgentCard, Message, @@ -76,7 +76,7 @@ async def test_a2a_client_send_message( mock_response_task = Task( id='task-123', context_id='ctx-456', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), ) client._transport.send_message = AsyncMock(return_value=mock_response_task) @@ -103,7 +103,7 @@ async def test_a2a_grpc_client_get_task( mock_response_task = Task( id='task-456', context_id='ctx-789', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), ) client.get_task = AsyncMock(return_value=mock_response_task) diff --git a/tests/client/transports/test_grpc_client.py b/tests/client/transports/test_grpc_client.py index 111e44ba6..689cd5d65 100644 --- a/tests/client/transports/test_grpc_client.py +++ b/tests/client/transports/test_grpc_client.py @@ -5,8 +5,8 @@ from a2a.client.transports.grpc import GrpcTransport from a2a.extensions.common import HTTP_EXTENSION_HEADER -from a2a.grpc import a2a_pb2, a2a_pb2_grpc -from a2a.types import ( +from a2a.types import a2a_pb2, a2a_pb2_grpc +from a2a.types.a2a_pb2 import ( AgentCapabilities, AgentCard, Artifact, @@ -95,7 +95,7 @@ def sample_task() -> Task: return Task( id='task-1', context_id='ctx-1', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), ) @@ -128,7 +128,7 @@ def sample_task_status_update_event() -> TaskStatusUpdateEvent: return TaskStatusUpdateEvent( task_id='task-1', context_id='ctx-1', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), final=False, metadata={}, ) @@ -351,7 +351,7 @@ async def test_cancel_task( ) -> None: """Test cancelling a task.""" cancelled_task = sample_task.model_copy() - cancelled_task.status.state = TaskState.canceled + cancelled_task.status.state = TaskState.TASK_STATE_CANCELLED mock_grpc_stub.CancelTask.return_value = proto_utils.ToProto.task( cancelled_task ) @@ -365,7 +365,7 @@ async def test_cancel_task( a2a_pb2.CancelTaskRequest(name=f'tasks/{sample_task.id}'), metadata=[(HTTP_EXTENSION_HEADER, 'https://example.com/test-ext/v3')], ) - assert response.status.state == TaskState.canceled + assert response.status.state == TaskState.TASK_STATE_CANCELLED @pytest.mark.asyncio diff --git a/tests/client/transports/test_jsonrpc_client.py b/tests/client/transports/test_jsonrpc_client.py index bd705d93c..a8ef75f48 100644 --- a/tests/client/transports/test_jsonrpc_client.py +++ b/tests/client/transports/test_jsonrpc_client.py @@ -18,7 +18,7 @@ ) from a2a.client.transports.jsonrpc import JsonRpcTransport from a2a.extensions.common import HTTP_EXTENSION_HEADER -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCapabilities, AgentCard, AgentSkill, diff --git a/tests/client/transports/test_rest_client.py b/tests/client/transports/test_rest_client.py index 04bd10361..2851655ed 100644 --- a/tests/client/transports/test_rest_client.py +++ b/tests/client/transports/test_rest_client.py @@ -9,7 +9,7 @@ from a2a.client import create_text_message_object from a2a.client.transports.rest import RestTransport from a2a.extensions.common import HTTP_EXTENSION_HEADER -from a2a.types import AgentCard, MessageSendParams, Role +from a2a.types.a2a_pb2 import AgentCard, MessageSendParams, Role @pytest.fixture diff --git a/tests/e2e/push_notifications/agent_app.py b/tests/e2e/push_notifications/agent_app.py index 1fa9bc546..07b287604 100644 --- a/tests/e2e/push_notifications/agent_app.py +++ b/tests/e2e/push_notifications/agent_app.py @@ -12,7 +12,7 @@ InMemoryTaskStore, TaskUpdater, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCapabilities, AgentCard, AgentSkill, diff --git a/tests/e2e/push_notifications/notifications_app.py b/tests/e2e/push_notifications/notifications_app.py index ed032dcb5..7349f5588 100644 --- a/tests/e2e/push_notifications/notifications_app.py +++ b/tests/e2e/push_notifications/notifications_app.py @@ -5,7 +5,7 @@ from fastapi import FastAPI, HTTPException, Path, Request from pydantic import BaseModel, ValidationError -from a2a.types import Task +from a2a.types.a2a_pb2 import Task class Notification(BaseModel): diff --git a/tests/e2e/push_notifications/test_default_push_notification_support.py b/tests/e2e/push_notifications/test_default_push_notification_support.py index 775bd7fb8..0afb5f8e1 100644 --- a/tests/e2e/push_notifications/test_default_push_notification_support.py +++ b/tests/e2e/push_notifications/test_default_push_notification_support.py @@ -19,7 +19,7 @@ ClientFactory, minimal_agent_card, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Message, Part, PushNotificationConfig, @@ -172,7 +172,7 @@ async def test_notification_triggering_after_config_change_e2e( assert isinstance(responses[0], tuple) assert isinstance(responses[0][0], Task) task = responses[0][0] - assert task.status.state == TaskState.input_required + assert task.status.state == TaskState.TASK_STATE_INPUT_REQUIRED # Verify that no notification has been sent yet. response = await http_client.get( diff --git a/tests/extensions/test_common.py b/tests/extensions/test_common.py index b3123028a..c6f94c6f9 100644 --- a/tests/extensions/test_common.py +++ b/tests/extensions/test_common.py @@ -5,7 +5,7 @@ get_requested_extensions, update_extension_header, ) -from a2a.types import AgentCapabilities, AgentCard, AgentExtension +from a2a.types.a2a_pb2 import AgentCapabilities, AgentCard, AgentExtension def test_get_requested_extensions(): diff --git a/tests/integration/test_client_server_integration.py b/tests/integration/test_client_server_integration.py index e0a564eee..62dc7e670 100644 --- a/tests/integration/test_client_server_integration.py +++ b/tests/integration/test_client_server_integration.py @@ -14,10 +14,10 @@ from a2a.client.transports import JsonRpcTransport, RestTransport from a2a.client.transports.base import ClientTransport from a2a.client.transports.grpc import GrpcTransport -from a2a.grpc import a2a_pb2_grpc +from a2a.types import a2a_pb2_grpc from a2a.server.apps import A2AFastAPIApplication, A2ARESTFastAPIApplication from a2a.server.request_handlers import GrpcHandler, RequestHandler -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCapabilities, AgentCard, AgentInterface, @@ -43,28 +43,28 @@ TASK_FROM_STREAM = Task( id='task-123-stream', context_id='ctx-456-stream', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), kind='task', ) TASK_FROM_BLOCKING = Task( id='task-789-blocking', context_id='ctx-101-blocking', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), kind='task', ) GET_TASK_RESPONSE = Task( id='task-get-456', context_id='ctx-get-789', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), kind='task', ) CANCEL_TASK_RESPONSE = Task( id='task-cancel-789', context_id='ctx-cancel-101', - status=TaskStatus(state=TaskState.canceled), + status=TaskStatus(state=TaskState.TASK_STATE_CANCELLED), kind='task', ) @@ -78,7 +78,7 @@ RESUBSCRIBE_EVENT = TaskStatusUpdateEvent( task_id='task-resub-456', context_id='ctx-resub-789', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), final=False, ) diff --git a/tests/server/agent_execution/test_context.py b/tests/server/agent_execution/test_context.py index 979978add..33b201e75 100644 --- a/tests/server/agent_execution/test_context.py +++ b/tests/server/agent_execution/test_context.py @@ -7,7 +7,7 @@ from a2a.server.agent_execution import RequestContext from a2a.server.context import ServerCallContext from a2a.server.id_generator import IDGenerator -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Message, MessageSendParams, Task, diff --git a/tests/server/agent_execution/test_simple_request_context_builder.py b/tests/server/agent_execution/test_simple_request_context_builder.py index 5e1b8fd81..2575a95e4 100644 --- a/tests/server/agent_execution/test_simple_request_context_builder.py +++ b/tests/server/agent_execution/test_simple_request_context_builder.py @@ -11,7 +11,7 @@ ) from a2a.server.context import ServerCallContext from a2a.server.tasks.task_store import TaskStore -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Message, MessageSendParams, Part, @@ -42,7 +42,7 @@ def create_sample_message( # Helper to create a simple task def create_sample_task( task_id: str = 'task1', - status_state: TaskState = TaskState.submitted, + status_state: TaskState = TaskState.TASK_STATE_SUBMITTED, context_id: str = 'ctx1', ) -> Task: return Task( diff --git a/tests/server/apps/jsonrpc/test_fastapi_app.py b/tests/server/apps/jsonrpc/test_fastapi_app.py index ddb68691f..f60ce2e1f 100644 --- a/tests/server/apps/jsonrpc/test_fastapi_app.py +++ b/tests/server/apps/jsonrpc/test_fastapi_app.py @@ -8,7 +8,7 @@ from a2a.server.request_handlers.request_handler import ( RequestHandler, # For mock spec ) -from a2a.types import AgentCard # For mock spec +from a2a.types.a2a_pb2 import AgentCard # For mock spec # --- A2AFastAPIApplication Tests --- diff --git a/tests/server/apps/jsonrpc/test_jsonrpc_app.py b/tests/server/apps/jsonrpc/test_jsonrpc_app.py index 36309872e..1c3261347 100644 --- a/tests/server/apps/jsonrpc/test_jsonrpc_app.py +++ b/tests/server/apps/jsonrpc/test_jsonrpc_app.py @@ -25,7 +25,7 @@ from a2a.server.request_handlers.request_handler import ( RequestHandler, ) # For mock spec -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCard, Message, MessageSendParams, diff --git a/tests/server/apps/jsonrpc/test_serialization.py b/tests/server/apps/jsonrpc/test_serialization.py index f67780461..48d297ef1 100644 --- a/tests/server/apps/jsonrpc/test_serialization.py +++ b/tests/server/apps/jsonrpc/test_serialization.py @@ -7,7 +7,7 @@ from starlette.testclient import TestClient from a2a.server.apps import A2AFastAPIApplication, A2AStarletteApplication -from a2a.types import ( +from a2a.types.a2a_pb2 import ( APIKeySecurityScheme, AgentCapabilities, AgentCard, diff --git a/tests/server/apps/jsonrpc/test_starlette_app.py b/tests/server/apps/jsonrpc/test_starlette_app.py index 6a1472c8c..f567dc1d2 100644 --- a/tests/server/apps/jsonrpc/test_starlette_app.py +++ b/tests/server/apps/jsonrpc/test_starlette_app.py @@ -8,7 +8,7 @@ from a2a.server.request_handlers.request_handler import ( RequestHandler, # For mock spec ) -from a2a.types import AgentCard # For mock spec +from a2a.types.a2a_pb2 import AgentCard # For mock spec # --- A2AStarletteApplication Tests --- diff --git a/tests/server/apps/rest/test_rest_fastapi_app.py b/tests/server/apps/rest/test_rest_fastapi_app.py index 3010c3a56..a6330a8d5 100644 --- a/tests/server/apps/rest/test_rest_fastapi_app.py +++ b/tests/server/apps/rest/test_rest_fastapi_app.py @@ -9,12 +9,12 @@ from google.protobuf import json_format from httpx import ASGITransport, AsyncClient -from a2a.grpc import a2a_pb2 +from a2a.types import a2a_pb2 from a2a.server.apps.rest import fastapi_app, rest_adapter from a2a.server.apps.rest.fastapi_app import A2ARESTFastAPIApplication from a2a.server.apps.rest.rest_adapter import RESTAdapter from a2a.server.request_handlers.request_handler import RequestHandler -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCard, Message, Part, @@ -237,7 +237,7 @@ async def test_send_message_success_task( id='test_task_id', context_id='test_context_id', status=TaskStatus( - state=TaskState.completed, + state=TaskState.TASK_STATE_COMPLETED, message=Message( message_id='test', role=Role.agent, diff --git a/tests/server/events/test_event_consumer.py b/tests/server/events/test_event_consumer.py index d306418ec..b69f00867 100644 --- a/tests/server/events/test_event_consumer.py +++ b/tests/server/events/test_event_consumer.py @@ -9,7 +9,7 @@ from a2a.server.events.event_consumer import EventConsumer, QueueClosed from a2a.server.events.event_queue import EventQueue -from a2a.types import ( +from a2a.types.a2a_pb2 import ( A2AError, Artifact, InternalError, @@ -137,7 +137,7 @@ async def test_consume_all_multiple_events( TaskStatusUpdateEvent( task_id='task_123', context_id='session-xyz', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), final=True, ), ] @@ -180,7 +180,7 @@ async def test_consume_until_message( TaskStatusUpdateEvent( task_id='task_123', context_id='session-xyz', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), final=True, ), ] diff --git a/tests/server/events/test_event_queue.py b/tests/server/events/test_event_queue.py index 0ff966cc3..8a2038833 100644 --- a/tests/server/events/test_event_queue.py +++ b/tests/server/events/test_event_queue.py @@ -11,7 +11,7 @@ import pytest from a2a.server.events.event_queue import DEFAULT_MAX_QUEUE_SIZE, EventQueue -from a2a.types import ( +from a2a.types.a2a_pb2 import ( A2AError, Artifact, JSONRPCError, @@ -103,7 +103,7 @@ async def test_dequeue_event_wait(event_queue: EventQueue) -> None: event = TaskStatusUpdateEvent( task_id='task_123', context_id='session-xyz', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), final=True, ) await event_queue.enqueue_event(event) diff --git a/tests/server/request_handlers/test_default_request_handler.py b/tests/server/request_handlers/test_default_request_handler.py index 88dd77ab4..cedd628ab 100644 --- a/tests/server/request_handlers/test_default_request_handler.py +++ b/tests/server/request_handlers/test_default_request_handler.py @@ -30,7 +30,7 @@ TaskStore, TaskUpdater, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( DeleteTaskPushNotificationConfigParams, GetTaskPushNotificationConfigParams, InternalError, @@ -67,7 +67,7 @@ async def execute(self, context: RequestContext, event_queue: EventQueue): parts = [Part(root=TextPart(text=f'Event {i}'))] try: await task_updater.update_status( - TaskState.working, + TaskState.TASK_STATE_WORKING, message=task_updater.new_agent_message(parts), ) except RuntimeError: @@ -84,7 +84,7 @@ async def cancel(self, context: RequestContext, event_queue: EventQueue): # Helper to create a simple task for tests def create_sample_task( - task_id='task1', status_state=TaskState.submitted, context_id='ctx1' + task_id='task1', status_state=TaskState.TASK_STATE_SUBMITTED, context_id='ctx1' ) -> Task: return Task( id=task_id, @@ -189,7 +189,7 @@ async def test_on_cancel_task_queue_tap_returns_none(): mock_result_aggregator_instance.consume_all.return_value = ( create_sample_task( task_id='tap_none_task', - status_state=TaskState.canceled, # Expected final state + status_state=TaskState.TASK_STATE_CANCELLED, # Expected final state ) ) @@ -220,7 +220,7 @@ async def test_on_cancel_task_queue_tap_returns_none(): mock_result_aggregator_instance.consume_all.assert_awaited_once() assert result_task is not None - assert result_task.status.state == TaskState.canceled + assert result_task.status.state == TaskState.TASK_STATE_CANCELLED @pytest.mark.asyncio @@ -240,7 +240,7 @@ async def test_on_cancel_task_cancels_running_agent(): # Mock ResultAggregator mock_result_aggregator_instance = AsyncMock(spec=ResultAggregator) mock_result_aggregator_instance.consume_all.return_value = ( - create_sample_task(task_id=task_id, status_state=TaskState.canceled) + create_sample_task(task_id=task_id, status_state=TaskState.TASK_STATE_CANCELLED) ) request_handler = DefaultRequestHandler( @@ -282,7 +282,7 @@ async def test_on_cancel_task_completes_during_cancellation(): # Mock ResultAggregator mock_result_aggregator_instance = AsyncMock(spec=ResultAggregator) mock_result_aggregator_instance.consume_all.return_value = ( - create_sample_task(task_id=task_id, status_state=TaskState.completed) + create_sample_task(task_id=task_id, status_state=TaskState.TASK_STATE_COMPLETED) ) request_handler = DefaultRequestHandler( @@ -371,7 +371,7 @@ async def test_on_message_send_with_push_notification(): task_id = 'push_task_1' context_id = 'push_ctx_1' sample_initial_task = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.submitted + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_SUBMITTED ) # TaskManager will be created inside on_message_send. @@ -416,7 +416,7 @@ async def test_on_message_send_with_push_notification(): # Mock ResultAggregator and its consume_and_break_on_interrupt mock_result_aggregator_instance = AsyncMock(spec=ResultAggregator) final_task_result = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.completed + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_COMPLETED ) mock_result_aggregator_instance.consume_and_break_on_interrupt.return_value = ( final_task_result, @@ -471,12 +471,12 @@ async def test_on_message_send_with_push_notification_in_non_blocking_request(): # Create a task that will be returned after the first event initial_task = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.working + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_WORKING ) # Create a final task that will be available during background processing final_task = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.completed + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_COMPLETED ) mock_task_store.get.return_value = None @@ -626,7 +626,7 @@ async def test_on_message_send_with_push_notification_no_existing_Task(): # Mock ResultAggregator and its consume_and_break_on_interrupt mock_result_aggregator_instance = AsyncMock(spec=ResultAggregator) final_task_result = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.completed + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_COMPLETED ) mock_result_aggregator_instance.consume_and_break_on_interrupt.return_value = ( final_task_result, @@ -777,7 +777,7 @@ async def execute(self, context: RequestContext, event_queue: EventQueue): try: parts = [Part(root=TextPart(text='I am working'))] await updater.update_status( - TaskState.working, + TaskState.TASK_STATE_WORKING, message=updater.new_agent_message(parts), ) except Exception as e: @@ -821,7 +821,7 @@ async def test_on_message_send_non_blocking(): assert result is not None assert isinstance(result, Task) - assert result.status.state == TaskState.submitted + assert result.status.state == TaskState.TASK_STATE_SUBMITTED # Polling for 500ms until task is completed. task: Task | None = None @@ -829,11 +829,11 @@ async def test_on_message_send_non_blocking(): await asyncio.sleep(0.1) task = await task_store.get(result.id) assert task is not None - if task.status.state == TaskState.completed: + if task.status.state == TaskState.TASK_STATE_COMPLETED: break assert task is not None - assert task.status.state == TaskState.completed + assert task.status.state == TaskState.TASK_STATE_COMPLETED assert ( result.history and task.history @@ -872,7 +872,7 @@ async def test_on_message_send_limit_history(): assert result is not None assert isinstance(result, Task) assert result.history is not None and len(result.history) == 1 - assert result.status.state == TaskState.completed + assert result.status.state == TaskState.TASK_STATE_COMPLETED # verify that history is still persisted to the store task = await task_store.get(result.id) @@ -945,7 +945,7 @@ async def test_on_message_send_interrupted_flow(): mock_result_aggregator_instance = AsyncMock(spec=ResultAggregator) interrupt_task_result = create_sample_task( - task_id=task_id, status_state=TaskState.auth_required + task_id=task_id, status_state=TaskState.TASK_STATE_AUTH_REQUIRED ) mock_result_aggregator_instance.consume_and_break_on_interrupt.return_value = ( interrupt_task_result, @@ -1002,12 +1002,12 @@ async def test_on_message_send_stream_with_push_notification(): # Initial task state for TaskManager initial_task_for_tm = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.submitted + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_SUBMITTED ) # Task state for RequestContext task_for_rc = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.working + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_WORKING ) # Example state after message update mock_task_store.get.return_value = None # New task for TaskManager @@ -1056,10 +1056,10 @@ async def exec_side_effect(*args, **kwargs): # Events to be yielded by consume_and_emit event1_task_update = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.working + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_WORKING ) event2_final_task = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.completed + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_COMPLETED ) async def event_stream_gen(): @@ -1291,7 +1291,7 @@ async def test_stream_disconnect_then_resubscribe_receives_future_events(): # Task exists and is non-final task_for_resub = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.working + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_WORKING ) mock_task_store.get.return_value = task_for_resub @@ -1317,10 +1317,10 @@ async def test_stream_disconnect_then_resubscribe_receives_future_events(): allow_finish = asyncio.Event() first_event = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.working + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_WORKING ) second_event = create_sample_task( - task_id=task_id, context_id=context_id, status_state=TaskState.completed + task_id=task_id, context_id=context_id, status_state=TaskState.TASK_STATE_COMPLETED ) async def exec_side_effect(_request, queue: EventQueue): @@ -1513,9 +1513,9 @@ async def execute( cast('str', context.task_id), cast('str', context.context_id), ) - await updater.update_status(TaskState.working) + await updater.update_status(TaskState.TASK_STATE_WORKING) await self.allow_finish.wait() - await updater.update_status(TaskState.completed) + await updater.update_status(TaskState.TASK_STATE_COMPLETED) async def cancel( self, context: RequestContext, event_queue: EventQueue @@ -1540,11 +1540,11 @@ async def cancel( agen = handler.on_message_send_stream(params, create_server_call_context()) first = await agen.__anext__() if isinstance(first, TaskStatusUpdateEvent): - assert first.status.state == TaskState.working + assert first.status.state == TaskState.TASK_STATE_WORKING task_id = first.task_id else: assert ( - isinstance(first, Task) and first.status.state == TaskState.working + isinstance(first, Task) and first.status.state == TaskState.TASK_STATE_WORKING ) task_id = first.id @@ -1567,7 +1567,7 @@ async def cancel( # Verify task is persisted as completed persisted = await task_store.get(task_id, create_server_call_context()) assert persisted is not None - assert persisted.status.state == TaskState.completed + assert persisted.status.state == TaskState.TASK_STATE_COMPLETED async def wait_until(predicate, timeout: float = 0.2, interval: float = 0.0): @@ -2431,10 +2431,10 @@ async def test_delete_task_push_notification_config_info_with_config_and_no_id() TERMINAL_TASK_STATES = { - TaskState.completed, - TaskState.canceled, - TaskState.failed, - TaskState.rejected, + TaskState.TASK_STATE_COMPLETED, + TaskState.TASK_STATE_CANCELLED, + TaskState.TASK_STATE_FAILED, + TaskState.TASK_STATE_REJECTED, } diff --git a/tests/server/request_handlers/test_grpc_handler.py b/tests/server/request_handlers/test_grpc_handler.py index 26f923c14..c26dcbea3 100644 --- a/tests/server/request_handlers/test_grpc_handler.py +++ b/tests/server/request_handlers/test_grpc_handler.py @@ -6,7 +6,7 @@ from a2a import types from a2a.extensions.common import HTTP_EXTENSION_HEADER -from a2a.grpc import a2a_pb2 +from a2a.types import a2a_pb2 from a2a.server.context import ServerCallContext from a2a.server.request_handlers import GrpcHandler, RequestHandler from a2a.utils.errors import ServerError @@ -69,7 +69,7 @@ async def test_send_message_success( response_model = types.Task( id='task-1', context_id='ctx-1', - status=types.TaskStatus(state=types.TaskState.completed), + status=types.TaskStatus(state=types.TaskState.TASK_STATE_COMPLETED), ) mock_request_handler.on_message_send.return_value = response_model @@ -110,7 +110,7 @@ async def test_get_task_success( response_model = types.Task( id='task-1', context_id='ctx-1', - status=types.TaskStatus(state=types.TaskState.working), + status=types.TaskStatus(state=types.TaskState.TASK_STATE_WORKING), ) mock_request_handler.on_get_task.return_value = response_model @@ -169,7 +169,7 @@ async def mock_stream(): yield types.Task( id='task-1', context_id='ctx-1', - status=types.TaskStatus(state=types.TaskState.working), + status=types.TaskStatus(state=types.TaskState.TASK_STATE_WORKING), ) mock_request_handler.on_message_send_stream.return_value = mock_stream() @@ -332,7 +332,7 @@ def side_effect(request, context: ServerCallContext): return types.Task( id='task-1', context_id='ctx-1', - status=types.TaskStatus(state=types.TaskState.completed), + status=types.TaskStatus(state=types.TaskState.TASK_STATE_COMPLETED), ) mock_request_handler.on_message_send.side_effect = side_effect @@ -397,7 +397,7 @@ async def side_effect(request, context: ServerCallContext): yield types.Task( id='task-1', context_id='ctx-1', - status=types.TaskStatus(state=types.TaskState.working), + status=types.TaskStatus(state=types.TaskState.TASK_STATE_WORKING), ) mock_request_handler.on_message_send_stream.side_effect = side_effect diff --git a/tests/server/request_handlers/test_jsonrpc_handler.py b/tests/server/request_handlers/test_jsonrpc_handler.py index d1ead0211..4f0062f9c 100644 --- a/tests/server/request_handlers/test_jsonrpc_handler.py +++ b/tests/server/request_handlers/test_jsonrpc_handler.py @@ -24,7 +24,7 @@ PushNotificationSender, TaskStore, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCapabilities, AgentCard, Artifact, @@ -151,7 +151,7 @@ async def test_on_cancel_task_success(self) -> None: call_context = ServerCallContext(state={'foo': 'bar'}) async def streaming_coro(): - mock_task.status.state = TaskState.canceled + mock_task.status.state = TaskState.TASK_STATE_CANCELLED yield mock_task with patch( @@ -163,7 +163,7 @@ async def streaming_coro(): assert mock_agent_executor.cancel.call_count == 1 self.assertIsInstance(response.root, CancelTaskSuccessResponse) assert response.root.result == mock_task # type: ignore - assert response.root.result.status.state == TaskState.canceled + assert response.root.result.status.state == TaskState.TASK_STATE_CANCELLED mock_agent_executor.cancel.assert_called_once() async def test_on_cancel_task_not_supported(self) -> None: @@ -358,7 +358,7 @@ async def test_on_message_stream_new_message_success( TaskStatusUpdateEvent( task_id='task_123', context_id='session-xyz', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), final=True, ), ] @@ -424,7 +424,7 @@ async def test_on_message_stream_new_message_existing_task_success( TaskStatusUpdateEvent( task_id='task_123', context_id='session-xyz', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), final=True, ), ] @@ -585,7 +585,7 @@ async def test_on_message_stream_new_message_send_push_notification_success( TaskStatusUpdateEvent( task_id='task_123', context_id='session-xyz', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), final=True, ), ] @@ -696,7 +696,7 @@ async def test_on_resubscribe_existing_task_success( TaskStatusUpdateEvent( task_id='task_123', context_id='session-xyz', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), final=True, ), ] diff --git a/tests/server/request_handlers/test_response_helpers.py b/tests/server/request_handlers/test_response_helpers.py index 36de78e62..5fb6518ca 100644 --- a/tests/server/request_handlers/test_response_helpers.py +++ b/tests/server/request_handlers/test_response_helpers.py @@ -6,7 +6,7 @@ build_error_response, prepare_response_object, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( A2AError, GetTaskResponse, GetTaskSuccessResponse, @@ -99,7 +99,7 @@ def _create_sample_task( return Task( id=task_id, context_id=context_id, - status=TaskStatus(state=TaskState.submitted), + status=TaskStatus(state=TaskState.TASK_STATE_SUBMITTED), history=[], ) diff --git a/tests/server/tasks/test_database_push_notification_config_store.py b/tests/server/tasks/test_database_push_notification_config_store.py index 0c3bd4683..502b0f104 100644 --- a/tests/server/tasks/test_database_push_notification_config_store.py +++ b/tests/server/tasks/test_database_push_notification_config_store.py @@ -30,7 +30,7 @@ PushNotificationConfigModel, ) # Important: To get Base.metadata from a2a.server.tasks import DatabasePushNotificationConfigStore -from a2a.types import ( +from a2a.types.a2a_pb2 import ( PushNotificationConfig, Task, TaskState, @@ -81,7 +81,7 @@ # Minimal Task object for testing - remains the same task_status_submitted = TaskStatus( - state=TaskState.submitted, timestamp='2023-01-01T00:00:00Z' + state=TaskState.TASK_STATE_SUBMITTED, timestamp='2023-01-01T00:00:00Z' ) MINIMAL_TASK_OBJ = Task( id='task-abc', diff --git a/tests/server/tasks/test_database_task_store.py b/tests/server/tasks/test_database_task_store.py index 87069be46..64e537956 100644 --- a/tests/server/tasks/test_database_task_store.py +++ b/tests/server/tasks/test_database_task_store.py @@ -17,7 +17,7 @@ from a2a.server.models import Base, TaskModel # Important: To get Base.metadata from a2a.server.tasks.database_task_store import DatabaseTaskStore -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Artifact, Message, Part, @@ -72,7 +72,7 @@ # Minimal Task object for testing - remains the same task_status_submitted = TaskStatus( - state=TaskState.submitted, timestamp='2023-01-01T00:00:00Z' + state=TaskState.TASK_STATE_SUBMITTED, timestamp='2023-01-01T00:00:00Z' ) MINIMAL_TASK_OBJ = Task( id='task-abc', @@ -167,7 +167,7 @@ async def test_get_task(db_store_parameterized: DatabaseTaskStore) -> None: assert retrieved_task is not None assert retrieved_task.id == task_to_save.id assert retrieved_task.context_id == task_to_save.context_id - assert retrieved_task.status.state == TaskState.submitted + assert retrieved_task.status.state == TaskState.TASK_STATE_SUBMITTED await db_store_parameterized.delete(task_to_save.id) # Cleanup @@ -214,7 +214,7 @@ async def test_save_and_get_detailed_task( id=task_id, context_id='test-session-1', status=TaskStatus( - state=TaskState.working, timestamp='2023-01-01T12:00:00Z' + state=TaskState.TASK_STATE_WORKING, timestamp='2023-01-01T12:00:00Z' ), kind='task', metadata={'key1': 'value1', 'key2': 123}, @@ -239,7 +239,7 @@ async def test_save_and_get_detailed_task( assert retrieved_task is not None assert retrieved_task.id == test_task.id assert retrieved_task.context_id == test_task.context_id - assert retrieved_task.status.state == TaskState.working + assert retrieved_task.status.state == TaskState.TASK_STATE_WORKING assert retrieved_task.status.timestamp == '2023-01-01T12:00:00Z' assert retrieved_task.metadata == {'key1': 'value1', 'key2': 123} @@ -265,7 +265,7 @@ async def test_update_task(db_store_parameterized: DatabaseTaskStore) -> None: id=task_id, context_id='session-update', status=TaskStatus( - state=TaskState.submitted, timestamp='2023-01-02T10:00:00Z' + state=TaskState.TASK_STATE_SUBMITTED, timestamp='2023-01-02T10:00:00Z' ), kind='task', metadata=None, # Explicitly None @@ -276,11 +276,11 @@ async def test_update_task(db_store_parameterized: DatabaseTaskStore) -> None: retrieved_before_update = await db_store_parameterized.get(task_id) assert retrieved_before_update is not None - assert retrieved_before_update.status.state == TaskState.submitted + assert retrieved_before_update.status.state == TaskState.TASK_STATE_SUBMITTED assert retrieved_before_update.metadata is None updated_task = original_task.model_copy(deep=True) - updated_task.status.state = TaskState.completed + updated_task.status.state = TaskState.TASK_STATE_COMPLETED updated_task.status.timestamp = '2023-01-02T11:00:00Z' updated_task.metadata = {'update_key': 'update_value'} @@ -288,7 +288,7 @@ async def test_update_task(db_store_parameterized: DatabaseTaskStore) -> None: retrieved_after_update = await db_store_parameterized.get(task_id) assert retrieved_after_update is not None - assert retrieved_after_update.status.state == TaskState.completed + assert retrieved_after_update.status.state == TaskState.TASK_STATE_COMPLETED assert retrieved_after_update.metadata == {'update_key': 'update_value'} await db_store_parameterized.delete(task_id) @@ -311,7 +311,7 @@ async def test_metadata_field_mapping( task_no_metadata = Task( id='task-metadata-test-1', context_id='session-meta-1', - status=TaskStatus(state=TaskState.submitted), + status=TaskStatus(state=TaskState.TASK_STATE_SUBMITTED), kind='task', metadata=None, ) @@ -327,7 +327,7 @@ async def test_metadata_field_mapping( task_simple_metadata = Task( id='task-metadata-test-2', context_id='session-meta-2', - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), kind='task', metadata=simple_metadata, ) @@ -352,7 +352,7 @@ async def test_metadata_field_mapping( task_complex_metadata = Task( id='task-metadata-test-3', context_id='session-meta-3', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), kind='task', metadata=complex_metadata, ) @@ -365,7 +365,7 @@ async def test_metadata_field_mapping( task_update_metadata = Task( id='task-metadata-test-4', context_id='session-meta-4', - status=TaskStatus(state=TaskState.submitted), + status=TaskStatus(state=TaskState.TASK_STATE_SUBMITTED), kind='task', metadata=None, ) diff --git a/tests/server/tasks/test_inmemory_push_notifications.py b/tests/server/tasks/test_inmemory_push_notifications.py index 375ed97ca..37d1829f5 100644 --- a/tests/server/tasks/test_inmemory_push_notifications.py +++ b/tests/server/tasks/test_inmemory_push_notifications.py @@ -10,7 +10,12 @@ from a2a.server.tasks.inmemory_push_notification_config_store import ( InMemoryPushNotificationConfigStore, ) -from a2a.types import PushNotificationConfig, Task, TaskState, TaskStatus +from a2a.types.a2a_pb2 import ( + PushNotificationConfig, + Task, + TaskState, + TaskStatus, +) # Suppress logging for cleaner test output, can be enabled for debugging @@ -18,7 +23,7 @@ def create_sample_task( - task_id: str = 'task123', status_state: TaskState = TaskState.completed + task_id: str = 'task123', status_state: TaskState = TaskState.TASK_STATE_COMPLETED ) -> Task: return Task( id=task_id, diff --git a/tests/server/tasks/test_inmemory_task_store.py b/tests/server/tasks/test_inmemory_task_store.py index c41e3559f..910c059f3 100644 --- a/tests/server/tasks/test_inmemory_task_store.py +++ b/tests/server/tasks/test_inmemory_task_store.py @@ -3,7 +3,7 @@ import pytest from a2a.server.tasks import InMemoryTaskStore -from a2a.types import Task +from a2a.types.a2a_pb2 import Task MINIMAL_TASK: dict[str, Any] = { diff --git a/tests/server/tasks/test_push_notification_sender.py b/tests/server/tasks/test_push_notification_sender.py index a3272c2c1..9fa531243 100644 --- a/tests/server/tasks/test_push_notification_sender.py +++ b/tests/server/tasks/test_push_notification_sender.py @@ -7,7 +7,7 @@ from a2a.server.tasks.base_push_notification_sender import ( BasePushNotificationSender, ) -from a2a.types import ( +from a2a.types.a2a_pb2 import ( PushNotificationConfig, Task, TaskState, @@ -16,7 +16,7 @@ def create_sample_task( - task_id: str = 'task123', status_state: TaskState = TaskState.completed + task_id: str = 'task123', status_state: TaskState = TaskState.TASK_STATE_COMPLETED ) -> Task: return Task( id=task_id, diff --git a/tests/server/tasks/test_result_aggregator.py b/tests/server/tasks/test_result_aggregator.py index bc970246b..6cf11f41b 100644 --- a/tests/server/tasks/test_result_aggregator.py +++ b/tests/server/tasks/test_result_aggregator.py @@ -9,7 +9,7 @@ from a2a.server.events.event_consumer import EventConsumer from a2a.server.tasks.result_aggregator import ResultAggregator from a2a.server.tasks.task_manager import TaskManager -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Message, Part, Role, @@ -35,7 +35,7 @@ def create_sample_message( # Helper to create a simple task def create_sample_task( task_id: str = 'task1', - status_state: TaskState = TaskState.submitted, + status_state: TaskState = TaskState.TASK_STATE_SUBMITTED, context_id: str = 'ctx1', ) -> Task: return Task( @@ -48,7 +48,7 @@ def create_sample_task( # Helper to create a TaskStatusUpdateEvent def create_sample_status_update( task_id: str = 'task1', - status_state: TaskState = TaskState.working, + status_state: TaskState = TaskState.TASK_STATE_WORKING, context_id: str = 'ctx1', ) -> TaskStatusUpdateEvent: return TaskStatusUpdateEvent( @@ -92,10 +92,10 @@ async def test_current_result_property_with_message_none(self) -> None: async def test_consume_and_emit(self) -> None: event1 = create_sample_message(content='event one', msg_id='e1') event2 = create_sample_task( - task_id='task_event', status_state=TaskState.working + task_id='task_event', status_state=TaskState.TASK_STATE_WORKING ) event3 = create_sample_status_update( - task_id='task_event', status_state=TaskState.completed + task_id='task_event', status_state=TaskState.TASK_STATE_COMPLETED ) # Mock event_consumer.consume() to be an async generator @@ -146,10 +146,10 @@ async def mock_consume_generator(): async def test_consume_all_other_event_types(self) -> None: task_event = create_sample_task(task_id='task_other_event') status_update_event = create_sample_status_update( - task_id='task_other_event', status_state=TaskState.completed + task_id='task_other_event', status_state=TaskState.TASK_STATE_COMPLETED ) final_task_state = create_sample_task( - task_id='task_other_event', status_state=TaskState.completed + task_id='task_other_event', status_state=TaskState.TASK_STATE_COMPLETED ) async def mock_consume_generator(): @@ -243,7 +243,7 @@ async def test_consume_and_break_on_auth_required_task_event( self, mock_create_task: MagicMock ) -> None: auth_task = create_sample_task( - task_id='auth_task', status_state=TaskState.auth_required + task_id='auth_task', status_state=TaskState.TASK_STATE_AUTH_REQUIRED ) event_after_auth = create_sample_message('after auth') @@ -295,10 +295,10 @@ async def test_consume_and_break_on_auth_required_status_update_event( self, mock_create_task: MagicMock ) -> None: auth_status_update = create_sample_status_update( - task_id='auth_status_task', status_state=TaskState.auth_required + task_id='auth_status_task', status_state=TaskState.TASK_STATE_AUTH_REQUIRED ) current_task_state_after_update = create_sample_task( - task_id='auth_status_task', status_state=TaskState.auth_required + task_id='auth_status_task', status_state=TaskState.TASK_STATE_AUTH_REQUIRED ) async def mock_consume_generator(): @@ -336,7 +336,7 @@ async def test_consume_and_break_completes_normally(self) -> None: event1 = create_sample_message('event one normal', msg_id='n1') event2 = create_sample_task('normal_task') final_task_state = create_sample_task( - 'normal_task', status_state=TaskState.completed + 'normal_task', status_state=TaskState.TASK_STATE_COMPLETED ) async def mock_consume_generator(): @@ -437,7 +437,7 @@ async def test_continue_consuming_processes_remaining_events( # the events *after* the interrupting one are processed by _continue_consuming. auth_event = create_sample_task( - 'task_auth_for_continue', status_state=TaskState.auth_required + 'task_auth_for_continue', status_state=TaskState.TASK_STATE_AUTH_REQUIRED ) event_after_auth1 = create_sample_message( 'after auth 1', msg_id='cont1' diff --git a/tests/server/tasks/test_task_manager.py b/tests/server/tasks/test_task_manager.py index 8208ca780..628919d03 100644 --- a/tests/server/tasks/test_task_manager.py +++ b/tests/server/tasks/test_task_manager.py @@ -4,7 +4,7 @@ import pytest from a2a.server.tasks import TaskManager -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Artifact, InvalidParamsError, Message, @@ -100,7 +100,7 @@ async def test_save_task_event_status_update( initial_task = Task(**MINIMAL_TASK) mock_task_store.get.return_value = initial_task new_status = TaskStatus( - state=TaskState.working, + state=TaskState.TASK_STATE_WORKING, message=Message( role=Role.agent, parts=[Part(TextPart(text='content'))], @@ -155,7 +155,7 @@ async def test_save_task_event_metadata_update( task_id=MINIMAL_TASK['id'], context_id=MINIMAL_TASK['context_id'], metadata=new_metadata, - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), final=False, ) await task_manager.save_task_event(event) @@ -174,7 +174,7 @@ async def test_ensure_task_existing( event = TaskStatusUpdateEvent( task_id=MINIMAL_TASK['id'], context_id=MINIMAL_TASK['context_id'], - status=TaskStatus(state=TaskState.working), + status=TaskStatus(state=TaskState.TASK_STATE_WORKING), final=False, ) retrieved_task = await task_manager.ensure_task(event) @@ -197,13 +197,13 @@ async def test_ensure_task_nonexistent( event = TaskStatusUpdateEvent( task_id='new-task', context_id='some-context', - status=TaskStatus(state=TaskState.submitted), + status=TaskStatus(state=TaskState.TASK_STATE_SUBMITTED), final=False, ) new_task = await task_manager_without_id.ensure_task(event) assert new_task.id == 'new-task' assert new_task.context_id == 'some-context' - assert new_task.status.state == TaskState.submitted + assert new_task.status.state == TaskState.TASK_STATE_SUBMITTED mock_task_store.save.assert_called_once_with(new_task, None) assert task_manager_without_id.task_id == 'new-task' assert task_manager_without_id.context_id == 'some-context' @@ -214,7 +214,7 @@ def test_init_task_obj(task_manager: TaskManager) -> None: new_task = task_manager._init_task_obj('new-task', 'new-context') # type: ignore assert new_task.id == 'new-task' assert new_task.context_id == 'new-context' - assert new_task.status.state == TaskState.submitted + assert new_task.status.state == TaskState.TASK_STATE_SUBMITTED assert new_task.history == [] @@ -237,7 +237,7 @@ async def test_save_task_event_mismatched_id_raises_error( mismatched_task = Task( id='wrong-id', context_id='session-xyz', - status=TaskStatus(state=TaskState.submitted), + status=TaskStatus(state=TaskState.TASK_STATE_SUBMITTED), ) with pytest.raises(ServerError) as exc_info: @@ -268,7 +268,7 @@ async def test_save_task_event_new_task_no_task_id( assert task_manager_without_id.task_id == 'new-task-id' assert task_manager_without_id.context_id == 'some-context' # initial submit should be updated to working - assert task.status.state == TaskState.working + assert task.status.state == TaskState.TASK_STATE_WORKING @pytest.mark.asyncio @@ -302,7 +302,7 @@ async def test_save_task_event_no_task_existing( event = TaskStatusUpdateEvent( task_id='event-task-id', context_id='some-context', - status=TaskStatus(state=TaskState.completed), + status=TaskStatus(state=TaskState.TASK_STATE_COMPLETED), final=True, ) await task_manager_without_id.save_task_event(event) @@ -312,6 +312,6 @@ async def test_save_task_event_no_task_existing( saved_task = call_args[0][0] assert saved_task.id == 'event-task-id' assert saved_task.context_id == 'some-context' - assert saved_task.status.state == TaskState.completed + assert saved_task.status.state == TaskState.TASK_STATE_COMPLETED assert task_manager_without_id.task_id == 'event-task-id' assert task_manager_without_id.context_id == 'some-context' diff --git a/tests/server/tasks/test_task_updater.py b/tests/server/tasks/test_task_updater.py index 891f8a10b..8fd1f0996 100644 --- a/tests/server/tasks/test_task_updater.py +++ b/tests/server/tasks/test_task_updater.py @@ -8,7 +8,7 @@ from a2a.server.events import EventQueue from a2a.server.id_generator import IDGenerator from a2a.server.tasks import TaskUpdater -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Message, Part, Role, @@ -71,7 +71,7 @@ async def test_update_status_without_message( task_updater: TaskUpdater, event_queue: AsyncMock ) -> None: """Test updating status without a message.""" - await task_updater.update_status(TaskState.working) + await task_updater.update_status(TaskState.TASK_STATE_WORKING) event_queue.enqueue_event.assert_called_once() event = event_queue.enqueue_event.call_args[0][0] @@ -80,7 +80,7 @@ async def test_update_status_without_message( assert event.task_id == 'test-task-id' assert event.context_id == 'test-context-id' assert event.final is False - assert event.status.state == TaskState.working + assert event.status.state == TaskState.TASK_STATE_WORKING assert event.status.message is None @@ -89,7 +89,7 @@ async def test_update_status_with_message( task_updater: TaskUpdater, event_queue: AsyncMock, sample_message: Message ) -> None: """Test updating status with a message.""" - await task_updater.update_status(TaskState.working, message=sample_message) + await task_updater.update_status(TaskState.TASK_STATE_WORKING, message=sample_message) event_queue.enqueue_event.assert_called_once() event = event_queue.enqueue_event.call_args[0][0] @@ -98,7 +98,7 @@ async def test_update_status_with_message( assert event.task_id == 'test-task-id' assert event.context_id == 'test-context-id' assert event.final is False - assert event.status.state == TaskState.working + assert event.status.state == TaskState.TASK_STATE_WORKING assert event.status.message == sample_message @@ -107,14 +107,14 @@ async def test_update_status_final( task_updater: TaskUpdater, event_queue: AsyncMock ) -> None: """Test updating status with final=True.""" - await task_updater.update_status(TaskState.completed, final=True) + await task_updater.update_status(TaskState.TASK_STATE_COMPLETED, final=True) event_queue.enqueue_event.assert_called_once() event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) assert event.final is True - assert event.status.state == TaskState.completed + assert event.status.state == TaskState.TASK_STATE_COMPLETED @pytest.mark.asyncio @@ -224,7 +224,7 @@ async def test_complete_without_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.completed + assert event.status.state == TaskState.TASK_STATE_COMPLETED assert event.final is True assert event.status.message is None @@ -240,7 +240,7 @@ async def test_complete_with_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.completed + assert event.status.state == TaskState.TASK_STATE_COMPLETED assert event.final is True assert event.status.message == sample_message @@ -256,7 +256,7 @@ async def test_submit_without_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.submitted + assert event.status.state == TaskState.TASK_STATE_SUBMITTED assert event.final is False assert event.status.message is None @@ -272,7 +272,7 @@ async def test_submit_with_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.submitted + assert event.status.state == TaskState.TASK_STATE_SUBMITTED assert event.final is False assert event.status.message == sample_message @@ -288,7 +288,7 @@ async def test_start_work_without_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.working + assert event.status.state == TaskState.TASK_STATE_WORKING assert event.final is False assert event.status.message is None @@ -304,7 +304,7 @@ async def test_start_work_with_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.working + assert event.status.state == TaskState.TASK_STATE_WORKING assert event.final is False assert event.status.message == sample_message @@ -378,7 +378,7 @@ async def test_failed_without_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.failed + assert event.status.state == TaskState.TASK_STATE_FAILED assert event.final is True assert event.status.message is None @@ -394,7 +394,7 @@ async def test_failed_with_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.failed + assert event.status.state == TaskState.TASK_STATE_FAILED assert event.final is True assert event.status.message == sample_message @@ -410,7 +410,7 @@ async def test_reject_without_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.rejected + assert event.status.state == TaskState.TASK_STATE_REJECTED assert event.final is True assert event.status.message is None @@ -426,7 +426,7 @@ async def test_reject_with_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.rejected + assert event.status.state == TaskState.TASK_STATE_REJECTED assert event.final is True assert event.status.message == sample_message @@ -442,7 +442,7 @@ async def test_requires_input_without_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.input_required + assert event.status.state == TaskState.TASK_STATE_INPUT_REQUIRED assert event.final is False assert event.status.message is None @@ -458,7 +458,7 @@ async def test_requires_input_with_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.input_required + assert event.status.state == TaskState.TASK_STATE_INPUT_REQUIRED assert event.final is False assert event.status.message == sample_message @@ -474,7 +474,7 @@ async def test_requires_input_final_true( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.input_required + assert event.status.state == TaskState.TASK_STATE_INPUT_REQUIRED assert event.final is True assert event.status.message is None @@ -490,7 +490,7 @@ async def test_requires_input_with_message_and_final( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.input_required + assert event.status.state == TaskState.TASK_STATE_INPUT_REQUIRED assert event.final is True assert event.status.message == sample_message @@ -506,7 +506,7 @@ async def test_requires_auth_without_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.auth_required + assert event.status.state == TaskState.TASK_STATE_AUTH_REQUIRED assert event.final is False assert event.status.message is None @@ -522,7 +522,7 @@ async def test_requires_auth_with_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.auth_required + assert event.status.state == TaskState.TASK_STATE_AUTH_REQUIRED assert event.final is False assert event.status.message == sample_message @@ -538,7 +538,7 @@ async def test_requires_auth_final_true( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.auth_required + assert event.status.state == TaskState.TASK_STATE_AUTH_REQUIRED assert event.final is True assert event.status.message is None @@ -554,7 +554,7 @@ async def test_requires_auth_with_message_and_final( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.auth_required + assert event.status.state == TaskState.TASK_STATE_AUTH_REQUIRED assert event.final is True assert event.status.message == sample_message @@ -570,7 +570,7 @@ async def test_cancel_without_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.canceled + assert event.status.state == TaskState.TASK_STATE_CANCELLED assert event.final is True assert event.status.message is None @@ -586,7 +586,7 @@ async def test_cancel_with_message( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) - assert event.status.state == TaskState.canceled + assert event.status.state == TaskState.TASK_STATE_CANCELLED assert event.final is True assert event.status.message == sample_message @@ -652,4 +652,4 @@ async def test_reject_concurrently_with_complete( event = event_queue.enqueue_event.call_args[0][0] assert isinstance(event, TaskStatusUpdateEvent) assert event.final is True - assert event.status.state in [TaskState.rejected, TaskState.completed] + assert event.status.state in [TaskState.TASK_STATE_REJECTED, TaskState.TASK_STATE_COMPLETED] diff --git a/tests/server/test_integration.py b/tests/server/test_integration.py index d65657dea..cb3d96242 100644 --- a/tests/server/test_integration.py +++ b/tests/server/test_integration.py @@ -23,7 +23,7 @@ A2AStarletteApplication, ) from a2a.server.context import ServerCallContext -from a2a.types import ( +from a2a.types.a2a_pb2 import ( AgentCapabilities, AgentCard, Artifact, @@ -457,7 +457,7 @@ def test_cancel_task(client: TestClient, handler: mock.AsyncMock): """Test cancelling a task.""" # Setup mock response task_status = TaskStatus(**MINIMAL_TASK_STATUS) - task_status.state = TaskState.canceled # 'cancelled' # + task_status.state = TaskState.TASK_STATE_CANCELLED # 'cancelled' # task = Task(id='task1', context_id='ctx1', status=task_status) handler.on_cancel_task.return_value = task diff --git a/tests/server/test_models.py b/tests/server/test_models.py index 64fed1008..aa5cbb227 100644 --- a/tests/server/test_models.py +++ b/tests/server/test_models.py @@ -10,7 +10,7 @@ create_push_notification_config_model, create_task_model, ) -from a2a.types import Artifact, TaskState, TaskStatus, TextPart +from a2a.types.a2a_pb2 import Artifact, TaskState, TaskStatus, TextPart class TestPydanticType: @@ -18,7 +18,7 @@ class TestPydanticType: def test_process_bind_param_with_pydantic_model(self): pydantic_type = PydanticType(TaskStatus) - status = TaskStatus(state=TaskState.working) + status = TaskStatus(state=TaskState.TASK_STATE_WORKING) dialect = MagicMock() result = pydantic_type.process_bind_param(status, dialect) diff --git a/tests/test_types.py b/tests/test_types.py index 73e6af7bb..7c310a799 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -4,7 +4,7 @@ from pydantic import ValidationError -from a2a.types import ( +from a2a.types.a2a_pb2 import ( A2AError, A2ARequest, APIKeySecurityScheme, @@ -379,12 +379,12 @@ def test_message(): def test_task_status(): status = TaskStatus(**MINIMAL_TASK_STATUS) - assert status.state == TaskState.submitted + assert status.state == TaskState.TASK_STATE_SUBMITTED assert status.message is None assert status.timestamp is None status_full = TaskStatus(**FULL_TASK_STATUS) - assert status_full.state == TaskState.working + assert status_full.state == TaskState.TASK_STATE_WORKING assert isinstance(status_full.message, Message) assert status_full.timestamp == '2023-10-27T10:00:00Z' @@ -396,14 +396,14 @@ def test_task(): task = Task(**MINIMAL_TASK) assert task.id == 'task-abc' assert task.context_id == 'session-xyz' - assert task.status.state == TaskState.submitted + assert task.status.state == TaskState.TASK_STATE_SUBMITTED assert task.history is None assert task.artifacts is None assert task.metadata is None task_full = Task(**FULL_TASK) assert task_full.id == 'task-abc' - assert task_full.status.state == TaskState.working + assert task_full.status.state == TaskState.TASK_STATE_WORKING assert task_full.history is not None and len(task_full.history) == 2 assert isinstance(task_full.history[0], Message) assert task_full.artifacts is not None and len(task_full.artifacts) == 1 @@ -672,7 +672,7 @@ def test_send_message_streaming_status_update_response() -> None: assert response.root.id == 1 assert isinstance(response.root, SendStreamingMessageSuccessResponse) assert isinstance(response.root.result, TaskStatusUpdateEvent) - assert response.root.result.status.state == TaskState.submitted + assert response.root.result.status.state == TaskState.TASK_STATE_SUBMITTED assert response.root.result.task_id == '1' assert not response.root.result.final @@ -1525,7 +1525,7 @@ def test_subclass_enums() -> None: assert Role.user == 'user' - assert TaskState.working == 'working' + assert TaskState.TASK_STATE_WORKING == 'working' def test_get_task_push_config_params() -> None: diff --git a/tests/utils/test_artifact.py b/tests/utils/test_artifact.py index 489c047c4..204f57040 100644 --- a/tests/utils/test_artifact.py +++ b/tests/utils/test_artifact.py @@ -3,7 +3,7 @@ from unittest.mock import patch -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Artifact, DataPart, Part, diff --git a/tests/utils/test_error_handlers.py b/tests/utils/test_error_handlers.py index ec41dc1f5..4175158fb 100644 --- a/tests/utils/test_error_handlers.py +++ b/tests/utils/test_error_handlers.py @@ -4,7 +4,7 @@ import pytest -from a2a.types import ( +from a2a.types.a2a_pb2 import ( InternalError, InvalidRequestError, MethodNotFoundError, diff --git a/tests/utils/test_helpers.py b/tests/utils/test_helpers.py index 28acd27ce..1ebcb7fa4 100644 --- a/tests/utils/test_helpers.py +++ b/tests/utils/test_helpers.py @@ -5,7 +5,7 @@ import pytest -from a2a.types import ( +from a2a.types.a2a_pb2 import ( Artifact, Message, MessageSendParams, @@ -54,7 +54,7 @@ def test_create_task_obj(): task = create_task_obj(send_params) assert task.id is not None assert task.context_id == message.context_id - assert task.status.state == TaskState.submitted + assert task.status.state == TaskState.TASK_STATE_SUBMITTED assert len(task.history) == 1 assert task.history[0] == message @@ -107,7 +107,7 @@ def test_append_artifact_to_task(): task = Task(**MINIMAL_TASK) assert task.id == 'task-abc' assert task.context_id == 'session-xyz' - assert task.status.state == TaskState.submitted + assert task.status.state == TaskState.TASK_STATE_SUBMITTED assert task.history is None assert task.artifacts is None assert task.metadata is None diff --git a/tests/utils/test_message.py b/tests/utils/test_message.py index 11523cbdf..a05b4ff02 100644 --- a/tests/utils/test_message.py +++ b/tests/utils/test_message.py @@ -2,7 +2,7 @@ from unittest.mock import patch -from a2a.types import ( +from a2a.types.a2a_pb2 import ( DataPart, Message, Part, diff --git a/tests/utils/test_parts.py b/tests/utils/test_parts.py index dcb027c2b..f03f2d623 100644 --- a/tests/utils/test_parts.py +++ b/tests/utils/test_parts.py @@ -1,4 +1,4 @@ -from a2a.types import ( +from a2a.types.a2a_pb2 import ( DataPart, FilePart, FileWithBytes, diff --git a/tests/utils/test_proto_utils.py b/tests/utils/test_proto_utils.py index da54f833f..da66d2494 100644 --- a/tests/utils/test_proto_utils.py +++ b/tests/utils/test_proto_utils.py @@ -3,7 +3,7 @@ import pytest from a2a import types -from a2a.grpc import a2a_pb2 +from a2a.types import a2a_pb2 from a2a.utils import proto_utils from a2a.utils.errors import ServerError @@ -41,7 +41,7 @@ def sample_task(sample_message: types.Message) -> types.Task: id='task-1', context_id='ctx-1', status=types.TaskStatus( - state=types.TaskState.working, message=sample_message + state=types.TaskState.TASK_STATE_WORKING, message=sample_message ), history=[sample_message], artifacts=[ @@ -170,7 +170,7 @@ def test_enum_conversions(self): ) for state in types.TaskState: - if state not in (types.TaskState.unknown, types.TaskState.rejected): + if state not in (types.TaskState.TASK_STATE_UNSPECIFIED, types.TaskState.TASK_STATE_REJECTED): proto_state = proto_utils.ToProto.task_state(state) assert proto_utils.FromProto.task_state(proto_state) == state @@ -179,10 +179,10 @@ def test_enum_conversions(self): proto_utils.FromProto.task_state( a2a_pb2.TaskState.TASK_STATE_UNSPECIFIED ) - == types.TaskState.unknown + == types.TaskState.TASK_STATE_UNSPECIFIED ) assert ( - proto_utils.ToProto.task_state(types.TaskState.unknown) + proto_utils.ToProto.task_state(types.TaskState.TASK_STATE_UNSPECIFIED) == a2a_pb2.TaskState.TASK_STATE_UNSPECIFIED ) diff --git a/tests/utils/test_task.py b/tests/utils/test_task.py index cb3dc3868..ed08c3348 100644 --- a/tests/utils/test_task.py +++ b/tests/utils/test_task.py @@ -5,7 +5,7 @@ import pytest -from a2a.types import Artifact, Message, Part, Role, TextPart +from a2a.types.a2a_pb2 import Artifact, Message, Part, Role, TextPart from a2a.utils.task import completed_task, new_task diff --git a/uv.lock b/uv.lock index 5003ac402..dd4d1a8ee 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 2 +revision = 3 requires-python = ">=3.10" resolution-markers = [ "python_full_version >= '3.13'", @@ -13,6 +13,7 @@ dependencies = [ { name = "google-api-core" }, { name = "httpx" }, { name = "httpx-sse" }, + { name = "json-rpc" }, { name = "protobuf" }, { name = "pydantic" }, ] @@ -99,6 +100,7 @@ requires-dist = [ { name = "grpcio-tools", marker = "extra == 'grpc'", specifier = ">=1.60" }, { name = "httpx", specifier = ">=0.28.1" }, { name = "httpx-sse", specifier = ">=0.4.0" }, + { name = "json-rpc", specifier = ">=1.15.0" }, { name = "opentelemetry-api", marker = "extra == 'all'", specifier = ">=1.33.0" }, { name = "opentelemetry-api", marker = "extra == 'telemetry'", specifier = ">=1.33.0" }, { name = "opentelemetry-sdk", marker = "extra == 'all'", specifier = ">=1.33.0" }, @@ -1050,6 +1052,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload-time = "2025-03-05T20:05:00.369Z" }, ] +[[package]] +name = "json-rpc" +version = "1.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6d/9e/59f4a5b7855ced7346ebf40a2e9a8942863f644378d956f68bcef2c88b90/json-rpc-1.15.0.tar.gz", hash = "sha256:e6441d56c1dcd54241c937d0a2dcd193bdf0bdc539b5316524713f554b7f85b9", size = 28854, upload-time = "2023-06-11T09:45:49.078Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/94/9e/820c4b086ad01ba7d77369fb8b11470a01fac9b4977f02e18659cf378b6b/json_rpc-1.15.0-py2.py3-none-any.whl", hash = "sha256:4a4668bbbe7116feb4abbd0f54e64a4adcf4b8f648f19ffa0848ad0f6606a9bf", size = 39450, upload-time = "2023-06-11T09:45:47.136Z" }, +] + [[package]] name = "libcst" version = "1.8.2"