Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/a2a/client/grpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ async def set_task_callback(
Returns:
A `TaskPushNotificationConfig` object containing the config.
"""
config = await self.stub.CreateTaskPushNotification(
a2a_pb2.CreateTaskPushNotificationRequest(
config = await self.stub.CreateTaskPushNotificationConfig(
a2a_pb2.CreateTaskPushNotificationConfigRequest(
parent='',
config_id='',
config=proto_utils.ToProto.task_push_notification_config(
Expand All @@ -182,8 +182,8 @@ async def get_task_callback(
Returns:
A `TaskPushNotificationConfig` object containing the configuration.
"""
config = await self.stub.GetTaskPushNotification(
a2a_pb2.GetTaskPushNotificationRequest(
config = await self.stub.GetTaskPushNotificationConfig(
a2a_pb2.GetTaskPushNotificationConfigRequest(
name=f'tasks/{request.id}/pushNotification/undefined',
)
)
Expand Down
231 changes: 118 additions & 113 deletions src/a2a/grpc/a2a_pb2.py

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions src/a2a/grpc/a2a_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import datetime
from google.api import annotations_pb2 as _annotations_pb2
from google.api import client_pb2 as _client_pb2
from google.api import field_behavior_pb2 as _field_behavior_pb2
from google.protobuf import empty_pb2 as _empty_pb2
from google.protobuf import struct_pb2 as _struct_pb2
from google.protobuf import timestamp_pb2 as _timestamp_pb2
from google.protobuf.internal import containers as _containers
Expand Down Expand Up @@ -458,13 +459,19 @@ class CancelTaskRequest(_message.Message):
name: str
def __init__(self, name: _Optional[str] = ...) -> None: ...

class GetTaskPushNotificationRequest(_message.Message):
class GetTaskPushNotificationConfigRequest(_message.Message):
__slots__ = ("name",)
NAME_FIELD_NUMBER: _ClassVar[int]
name: str
def __init__(self, name: _Optional[str] = ...) -> None: ...

class CreateTaskPushNotificationRequest(_message.Message):
class DeleteTaskPushNotificationConfigRequest(_message.Message):
__slots__ = ("name",)
NAME_FIELD_NUMBER: _ClassVar[int]
name: str
def __init__(self, name: _Optional[str] = ...) -> None: ...

class CreateTaskPushNotificationConfigRequest(_message.Message):
__slots__ = ("parent", "config_id", "config")
PARENT_FIELD_NUMBER: _ClassVar[int]
CONFIG_ID_FIELD_NUMBER: _ClassVar[int]
Expand All @@ -480,7 +487,7 @@ class TaskSubscriptionRequest(_message.Message):
name: str
def __init__(self, name: _Optional[str] = ...) -> None: ...

class ListTaskPushNotificationRequest(_message.Message):
class ListTaskPushNotificationConfigRequest(_message.Message):
__slots__ = ("parent", "page_size", "page_token")
PARENT_FIELD_NUMBER: _ClassVar[int]
PAGE_SIZE_FIELD_NUMBER: _ClassVar[int]
Expand Down Expand Up @@ -514,7 +521,7 @@ class StreamResponse(_message.Message):
artifact_update: TaskArtifactUpdateEvent
def __init__(self, task: _Optional[_Union[Task, _Mapping]] = ..., msg: _Optional[_Union[Message, _Mapping]] = ..., status_update: _Optional[_Union[TaskStatusUpdateEvent, _Mapping]] = ..., artifact_update: _Optional[_Union[TaskArtifactUpdateEvent, _Mapping]] = ...) -> None: ...

class ListTaskPushNotificationResponse(_message.Message):
class ListTaskPushNotificationConfigResponse(_message.Message):
__slots__ = ("configs", "next_page_token")
CONFIGS_FIELD_NUMBER: _ClassVar[int]
NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int]
Expand Down
129 changes: 87 additions & 42 deletions src/a2a/grpc/a2a_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
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
TaskPushNotification.
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.
- TaskPushNotification are a resource whose parent is a task. They have get,
list and create 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.
fields are not present as they don't comply with AIP rules, and the
optional history_length on the get task method is not present as it also
Expand Down Expand Up @@ -52,38 +53,43 @@ def __init__(self, channel):
request_serializer=a2a__pb2.TaskSubscriptionRequest.SerializeToString,
response_deserializer=a2a__pb2.StreamResponse.FromString,
_registered_method=True)
self.CreateTaskPushNotification = channel.unary_unary(
'/a2a.v1.A2AService/CreateTaskPushNotification',
request_serializer=a2a__pb2.CreateTaskPushNotificationRequest.SerializeToString,
self.CreateTaskPushNotificationConfig = channel.unary_unary(
'/a2a.v1.A2AService/CreateTaskPushNotificationConfig',
request_serializer=a2a__pb2.CreateTaskPushNotificationConfigRequest.SerializeToString,
response_deserializer=a2a__pb2.TaskPushNotificationConfig.FromString,
_registered_method=True)
self.GetTaskPushNotification = channel.unary_unary(
'/a2a.v1.A2AService/GetTaskPushNotification',
request_serializer=a2a__pb2.GetTaskPushNotificationRequest.SerializeToString,
self.GetTaskPushNotificationConfig = channel.unary_unary(
'/a2a.v1.A2AService/GetTaskPushNotificationConfig',
request_serializer=a2a__pb2.GetTaskPushNotificationConfigRequest.SerializeToString,
response_deserializer=a2a__pb2.TaskPushNotificationConfig.FromString,
_registered_method=True)
self.ListTaskPushNotification = channel.unary_unary(
'/a2a.v1.A2AService/ListTaskPushNotification',
request_serializer=a2a__pb2.ListTaskPushNotificationRequest.SerializeToString,
response_deserializer=a2a__pb2.ListTaskPushNotificationResponse.FromString,
self.ListTaskPushNotificationConfig = channel.unary_unary(
'/a2a.v1.A2AService/ListTaskPushNotificationConfig',
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,
response_deserializer=a2a__pb2.AgentCard.FromString,
_registered_method=True)
self.DeleteTaskPushNotificationConfig = channel.unary_unary(
'/a2a.v1.A2AService/DeleteTaskPushNotificationConfig',
request_serializer=a2a__pb2.DeleteTaskPushNotificationConfigRequest.SerializeToString,
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
_registered_method=True)


class A2AServiceServicer(object):
"""A2AService defines the gRPC version of the A2A protocol. This has a slightly
different shape than the JSONRPC version to better conform to AIP-127,
where appropriate. The nouns are AgentCard, Message, Task and
TaskPushNotification.
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.
- TaskPushNotification are a resource whose parent is a task. They have get,
list and create 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.
fields are not present as they don't comply with AIP rules, and the
optional history_length on the get task method is not present as it also
Expand Down Expand Up @@ -131,21 +137,21 @@ def TaskSubscription(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def CreateTaskPushNotification(self, request, context):
def CreateTaskPushNotificationConfig(self, request, context):
"""Set a push notification config for a task.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def GetTaskPushNotification(self, request, context):
def GetTaskPushNotificationConfig(self, request, context):
"""Get a push notification config for a task.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def ListTaskPushNotification(self, request, context):
def ListTaskPushNotificationConfig(self, request, context):
"""Get a list of push notifications configured for a task.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
Expand All @@ -159,6 +165,13 @@ def GetAgentCard(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def DeleteTaskPushNotificationConfig(self, request, context):
"""Delete a push notification config for a task.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_A2AServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
Expand Down Expand Up @@ -187,26 +200,31 @@ def add_A2AServiceServicer_to_server(servicer, server):
request_deserializer=a2a__pb2.TaskSubscriptionRequest.FromString,
response_serializer=a2a__pb2.StreamResponse.SerializeToString,
),
'CreateTaskPushNotification': grpc.unary_unary_rpc_method_handler(
servicer.CreateTaskPushNotification,
request_deserializer=a2a__pb2.CreateTaskPushNotificationRequest.FromString,
'CreateTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler(
servicer.CreateTaskPushNotificationConfig,
request_deserializer=a2a__pb2.CreateTaskPushNotificationConfigRequest.FromString,
response_serializer=a2a__pb2.TaskPushNotificationConfig.SerializeToString,
),
'GetTaskPushNotification': grpc.unary_unary_rpc_method_handler(
servicer.GetTaskPushNotification,
request_deserializer=a2a__pb2.GetTaskPushNotificationRequest.FromString,
'GetTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler(
servicer.GetTaskPushNotificationConfig,
request_deserializer=a2a__pb2.GetTaskPushNotificationConfigRequest.FromString,
response_serializer=a2a__pb2.TaskPushNotificationConfig.SerializeToString,
),
'ListTaskPushNotification': grpc.unary_unary_rpc_method_handler(
servicer.ListTaskPushNotification,
request_deserializer=a2a__pb2.ListTaskPushNotificationRequest.FromString,
response_serializer=a2a__pb2.ListTaskPushNotificationResponse.SerializeToString,
'ListTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler(
servicer.ListTaskPushNotificationConfig,
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,
response_serializer=a2a__pb2.AgentCard.SerializeToString,
),
'DeleteTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler(
servicer.DeleteTaskPushNotificationConfig,
request_deserializer=a2a__pb2.DeleteTaskPushNotificationConfigRequest.FromString,
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'a2a.v1.A2AService', rpc_method_handlers)
Expand All @@ -219,12 +237,12 @@ 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
TaskPushNotification.
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.
- TaskPushNotification are a resource whose parent is a task. They have get,
list and create 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.
fields are not present as they don't comply with AIP rules, and the
optional history_length on the get task method is not present as it also
Expand Down Expand Up @@ -367,7 +385,7 @@ def TaskSubscription(request,
_registered_method=True)

@staticmethod
def CreateTaskPushNotification(request,
def CreateTaskPushNotificationConfig(request,
target,
options=(),
channel_credentials=None,
Expand All @@ -380,8 +398,8 @@ def CreateTaskPushNotification(request,
return grpc.experimental.unary_unary(
request,
target,
'/a2a.v1.A2AService/CreateTaskPushNotification',
a2a__pb2.CreateTaskPushNotificationRequest.SerializeToString,
'/a2a.v1.A2AService/CreateTaskPushNotificationConfig',
a2a__pb2.CreateTaskPushNotificationConfigRequest.SerializeToString,
a2a__pb2.TaskPushNotificationConfig.FromString,
options,
channel_credentials,
Expand All @@ -394,7 +412,7 @@ def CreateTaskPushNotification(request,
_registered_method=True)

@staticmethod
def GetTaskPushNotification(request,
def GetTaskPushNotificationConfig(request,
target,
options=(),
channel_credentials=None,
Expand All @@ -407,8 +425,8 @@ def GetTaskPushNotification(request,
return grpc.experimental.unary_unary(
request,
target,
'/a2a.v1.A2AService/GetTaskPushNotification',
a2a__pb2.GetTaskPushNotificationRequest.SerializeToString,
'/a2a.v1.A2AService/GetTaskPushNotificationConfig',
a2a__pb2.GetTaskPushNotificationConfigRequest.SerializeToString,
a2a__pb2.TaskPushNotificationConfig.FromString,
options,
channel_credentials,
Expand All @@ -421,7 +439,7 @@ def GetTaskPushNotification(request,
_registered_method=True)

@staticmethod
def ListTaskPushNotification(request,
def ListTaskPushNotificationConfig(request,
target,
options=(),
channel_credentials=None,
Expand All @@ -434,9 +452,9 @@ def ListTaskPushNotification(request,
return grpc.experimental.unary_unary(
request,
target,
'/a2a.v1.A2AService/ListTaskPushNotification',
a2a__pb2.ListTaskPushNotificationRequest.SerializeToString,
a2a__pb2.ListTaskPushNotificationResponse.FromString,
'/a2a.v1.A2AService/ListTaskPushNotificationConfig',
a2a__pb2.ListTaskPushNotificationConfigRequest.SerializeToString,
a2a__pb2.ListTaskPushNotificationConfigResponse.FromString,
options,
channel_credentials,
insecure,
Expand Down Expand Up @@ -473,3 +491,30 @@ def GetAgentCard(request,
timeout,
metadata,
_registered_method=True)

@staticmethod
def DeleteTaskPushNotificationConfig(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(
request,
target,
'/a2a.v1.A2AService/DeleteTaskPushNotificationConfig',
a2a__pb2.DeleteTaskPushNotificationConfigRequest.SerializeToString,
google_dot_protobuf_dot_empty__pb2.Empty.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True)
14 changes: 7 additions & 7 deletions src/a2a/server/request_handlers/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ async def TaskSubscription(
except ServerError as e:
await self.abort_context(e, context)

async def GetTaskPushNotification(
async def GetTaskPushNotificationConfig(
self,
request: a2a_pb2.GetTaskPushNotificationRequest,
request: a2a_pb2.GetTaskPushNotificationConfigRequest,
context: grpc.aio.ServicerContext,
) -> a2a_pb2.TaskPushNotificationConfig:
"""Handles the 'GetTaskPushNotification' gRPC method.
"""Handles the 'GetTaskPushNotificationConfig' gRPC method.

Args:
request: The incoming `GetTaskPushNotificationConfigRequest` object.
Expand All @@ -229,17 +229,17 @@ async def GetTaskPushNotification(
lambda self: self.agent_card.capabilities.pushNotifications,
'Push notifications are not supported by the agent',
)
async def CreateTaskPushNotification(
async def CreateTaskPushNotificationConfig(
self,
request: a2a_pb2.CreateTaskPushNotificationRequest,
request: a2a_pb2.CreateTaskPushNotificationConfigRequest,
context: grpc.aio.ServicerContext,
) -> a2a_pb2.TaskPushNotificationConfig:
"""Handles the 'CreateTaskPushNotification' gRPC method.
"""Handles the 'CreateTaskPushNotificationConfig' gRPC method.

Requires the agent to support push notifications.

Args:
request: The incoming `CreateTaskPushNotificationRequest` object.
request: The incoming `CreateTaskPushNotificationConfigRequest` object.
context: Context provided by the server.

Returns:
Expand Down
Loading