Skip to content

Commit 1fbf600

Browse files
a2a-botholtskinner
andauthored
feat!: Update A2A types from specification 🤖 (#197)
This PR updates `src/a2a/types.py` based on the latest `specification/json/a2a.json` from [google-a2a/A2A](a2aproject/A2A@f355d3e). --------- Co-authored-by: Holt Skinner <[email protected]> Co-authored-by: Holt Skinner <[email protected]>
1 parent c983481 commit 1fbf600

File tree

7 files changed

+384
-174
lines changed

7 files changed

+384
-174
lines changed

src/a2a/client/grpc_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ async def set_task_callback(
159159
Returns:
160160
A `TaskPushNotificationConfig` object containing the config.
161161
"""
162-
config = await self.stub.CreateTaskPushNotification(
163-
a2a_pb2.CreateTaskPushNotificationRequest(
162+
config = await self.stub.CreateTaskPushNotificationConfig(
163+
a2a_pb2.CreateTaskPushNotificationConfigRequest(
164164
parent='',
165165
config_id='',
166166
config=proto_utils.ToProto.task_push_notification_config(
@@ -182,8 +182,8 @@ async def get_task_callback(
182182
Returns:
183183
A `TaskPushNotificationConfig` object containing the configuration.
184184
"""
185-
config = await self.stub.GetTaskPushNotification(
186-
a2a_pb2.GetTaskPushNotificationRequest(
185+
config = await self.stub.GetTaskPushNotificationConfig(
186+
a2a_pb2.GetTaskPushNotificationConfigRequest(
187187
name=f'tasks/{request.id}/pushNotification/undefined',
188188
)
189189
)

src/a2a/grpc/a2a_pb2.py

Lines changed: 118 additions & 113 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/a2a/grpc/a2a_pb2.pyi

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import datetime
33
from google.api import annotations_pb2 as _annotations_pb2
44
from google.api import client_pb2 as _client_pb2
55
from google.api import field_behavior_pb2 as _field_behavior_pb2
6+
from google.protobuf import empty_pb2 as _empty_pb2
67
from google.protobuf import struct_pb2 as _struct_pb2
78
from google.protobuf import timestamp_pb2 as _timestamp_pb2
89
from google.protobuf.internal import containers as _containers
@@ -458,13 +459,19 @@ class CancelTaskRequest(_message.Message):
458459
name: str
459460
def __init__(self, name: _Optional[str] = ...) -> None: ...
460461

461-
class GetTaskPushNotificationRequest(_message.Message):
462+
class GetTaskPushNotificationConfigRequest(_message.Message):
462463
__slots__ = ("name",)
463464
NAME_FIELD_NUMBER: _ClassVar[int]
464465
name: str
465466
def __init__(self, name: _Optional[str] = ...) -> None: ...
466467

467-
class CreateTaskPushNotificationRequest(_message.Message):
468+
class DeleteTaskPushNotificationConfigRequest(_message.Message):
469+
__slots__ = ("name",)
470+
NAME_FIELD_NUMBER: _ClassVar[int]
471+
name: str
472+
def __init__(self, name: _Optional[str] = ...) -> None: ...
473+
474+
class CreateTaskPushNotificationConfigRequest(_message.Message):
468475
__slots__ = ("parent", "config_id", "config")
469476
PARENT_FIELD_NUMBER: _ClassVar[int]
470477
CONFIG_ID_FIELD_NUMBER: _ClassVar[int]
@@ -480,7 +487,7 @@ class TaskSubscriptionRequest(_message.Message):
480487
name: str
481488
def __init__(self, name: _Optional[str] = ...) -> None: ...
482489

483-
class ListTaskPushNotificationRequest(_message.Message):
490+
class ListTaskPushNotificationConfigRequest(_message.Message):
484491
__slots__ = ("parent", "page_size", "page_token")
485492
PARENT_FIELD_NUMBER: _ClassVar[int]
486493
PAGE_SIZE_FIELD_NUMBER: _ClassVar[int]
@@ -514,7 +521,7 @@ class StreamResponse(_message.Message):
514521
artifact_update: TaskArtifactUpdateEvent
515522
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: ...
516523

517-
class ListTaskPushNotificationResponse(_message.Message):
524+
class ListTaskPushNotificationConfigResponse(_message.Message):
518525
__slots__ = ("configs", "next_page_token")
519526
CONFIGS_FIELD_NUMBER: _ClassVar[int]
520527
NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int]

src/a2a/grpc/a2a_pb2_grpc.py

Lines changed: 87 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
import grpc
44

55
from . import a2a_pb2 as a2a__pb2
6+
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
67

78

89
class A2AServiceStub(object):
910
"""A2AService defines the gRPC version of the A2A protocol. This has a slightly
1011
different shape than the JSONRPC version to better conform to AIP-127,
1112
where appropriate. The nouns are AgentCard, Message, Task and
12-
TaskPushNotification.
13+
TaskPushNotificationConfig.
1314
- Messages are not a standard resource so there is no get/delete/update/list
1415
interface, only a send and stream custom methods.
1516
- Tasks have a get interface and custom cancel and subscribe methods.
16-
- TaskPushNotification are a resource whose parent is a task. They have get,
17-
list and create methods.
17+
- TaskPushNotificationConfig are a resource whose parent is a task.
18+
They have get, list and create methods.
1819
- AgentCard is a static resource with only a get method.
1920
fields are not present as they don't comply with AIP rules, and the
2021
optional history_length on the get task method is not present as it also
@@ -52,38 +53,43 @@ def __init__(self, channel):
5253
request_serializer=a2a__pb2.TaskSubscriptionRequest.SerializeToString,
5354
response_deserializer=a2a__pb2.StreamResponse.FromString,
5455
_registered_method=True)
55-
self.CreateTaskPushNotification = channel.unary_unary(
56-
'/a2a.v1.A2AService/CreateTaskPushNotification',
57-
request_serializer=a2a__pb2.CreateTaskPushNotificationRequest.SerializeToString,
56+
self.CreateTaskPushNotificationConfig = channel.unary_unary(
57+
'/a2a.v1.A2AService/CreateTaskPushNotificationConfig',
58+
request_serializer=a2a__pb2.CreateTaskPushNotificationConfigRequest.SerializeToString,
5859
response_deserializer=a2a__pb2.TaskPushNotificationConfig.FromString,
5960
_registered_method=True)
60-
self.GetTaskPushNotification = channel.unary_unary(
61-
'/a2a.v1.A2AService/GetTaskPushNotification',
62-
request_serializer=a2a__pb2.GetTaskPushNotificationRequest.SerializeToString,
61+
self.GetTaskPushNotificationConfig = channel.unary_unary(
62+
'/a2a.v1.A2AService/GetTaskPushNotificationConfig',
63+
request_serializer=a2a__pb2.GetTaskPushNotificationConfigRequest.SerializeToString,
6364
response_deserializer=a2a__pb2.TaskPushNotificationConfig.FromString,
6465
_registered_method=True)
65-
self.ListTaskPushNotification = channel.unary_unary(
66-
'/a2a.v1.A2AService/ListTaskPushNotification',
67-
request_serializer=a2a__pb2.ListTaskPushNotificationRequest.SerializeToString,
68-
response_deserializer=a2a__pb2.ListTaskPushNotificationResponse.FromString,
66+
self.ListTaskPushNotificationConfig = channel.unary_unary(
67+
'/a2a.v1.A2AService/ListTaskPushNotificationConfig',
68+
request_serializer=a2a__pb2.ListTaskPushNotificationConfigRequest.SerializeToString,
69+
response_deserializer=a2a__pb2.ListTaskPushNotificationConfigResponse.FromString,
6970
_registered_method=True)
7071
self.GetAgentCard = channel.unary_unary(
7172
'/a2a.v1.A2AService/GetAgentCard',
7273
request_serializer=a2a__pb2.GetAgentCardRequest.SerializeToString,
7374
response_deserializer=a2a__pb2.AgentCard.FromString,
7475
_registered_method=True)
76+
self.DeleteTaskPushNotificationConfig = channel.unary_unary(
77+
'/a2a.v1.A2AService/DeleteTaskPushNotificationConfig',
78+
request_serializer=a2a__pb2.DeleteTaskPushNotificationConfigRequest.SerializeToString,
79+
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
80+
_registered_method=True)
7581

7682

7783
class A2AServiceServicer(object):
7884
"""A2AService defines the gRPC version of the A2A protocol. This has a slightly
7985
different shape than the JSONRPC version to better conform to AIP-127,
8086
where appropriate. The nouns are AgentCard, Message, Task and
81-
TaskPushNotification.
87+
TaskPushNotificationConfig.
8288
- Messages are not a standard resource so there is no get/delete/update/list
8389
interface, only a send and stream custom methods.
8490
- Tasks have a get interface and custom cancel and subscribe methods.
85-
- TaskPushNotification are a resource whose parent is a task. They have get,
86-
list and create methods.
91+
- TaskPushNotificationConfig are a resource whose parent is a task.
92+
They have get, list and create methods.
8793
- AgentCard is a static resource with only a get method.
8894
fields are not present as they don't comply with AIP rules, and the
8995
optional history_length on the get task method is not present as it also
@@ -131,21 +137,21 @@ def TaskSubscription(self, request, context):
131137
context.set_details('Method not implemented!')
132138
raise NotImplementedError('Method not implemented!')
133139

134-
def CreateTaskPushNotification(self, request, context):
140+
def CreateTaskPushNotificationConfig(self, request, context):
135141
"""Set a push notification config for a task.
136142
"""
137143
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
138144
context.set_details('Method not implemented!')
139145
raise NotImplementedError('Method not implemented!')
140146

141-
def GetTaskPushNotification(self, request, context):
147+
def GetTaskPushNotificationConfig(self, request, context):
142148
"""Get a push notification config for a task.
143149
"""
144150
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
145151
context.set_details('Method not implemented!')
146152
raise NotImplementedError('Method not implemented!')
147153

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

168+
def DeleteTaskPushNotificationConfig(self, request, context):
169+
"""Delete a push notification config for a task.
170+
"""
171+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
172+
context.set_details('Method not implemented!')
173+
raise NotImplementedError('Method not implemented!')
174+
162175

163176
def add_A2AServiceServicer_to_server(servicer, server):
164177
rpc_method_handlers = {
@@ -187,26 +200,31 @@ def add_A2AServiceServicer_to_server(servicer, server):
187200
request_deserializer=a2a__pb2.TaskSubscriptionRequest.FromString,
188201
response_serializer=a2a__pb2.StreamResponse.SerializeToString,
189202
),
190-
'CreateTaskPushNotification': grpc.unary_unary_rpc_method_handler(
191-
servicer.CreateTaskPushNotification,
192-
request_deserializer=a2a__pb2.CreateTaskPushNotificationRequest.FromString,
203+
'CreateTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler(
204+
servicer.CreateTaskPushNotificationConfig,
205+
request_deserializer=a2a__pb2.CreateTaskPushNotificationConfigRequest.FromString,
193206
response_serializer=a2a__pb2.TaskPushNotificationConfig.SerializeToString,
194207
),
195-
'GetTaskPushNotification': grpc.unary_unary_rpc_method_handler(
196-
servicer.GetTaskPushNotification,
197-
request_deserializer=a2a__pb2.GetTaskPushNotificationRequest.FromString,
208+
'GetTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler(
209+
servicer.GetTaskPushNotificationConfig,
210+
request_deserializer=a2a__pb2.GetTaskPushNotificationConfigRequest.FromString,
198211
response_serializer=a2a__pb2.TaskPushNotificationConfig.SerializeToString,
199212
),
200-
'ListTaskPushNotification': grpc.unary_unary_rpc_method_handler(
201-
servicer.ListTaskPushNotification,
202-
request_deserializer=a2a__pb2.ListTaskPushNotificationRequest.FromString,
203-
response_serializer=a2a__pb2.ListTaskPushNotificationResponse.SerializeToString,
213+
'ListTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler(
214+
servicer.ListTaskPushNotificationConfig,
215+
request_deserializer=a2a__pb2.ListTaskPushNotificationConfigRequest.FromString,
216+
response_serializer=a2a__pb2.ListTaskPushNotificationConfigResponse.SerializeToString,
204217
),
205218
'GetAgentCard': grpc.unary_unary_rpc_method_handler(
206219
servicer.GetAgentCard,
207220
request_deserializer=a2a__pb2.GetAgentCardRequest.FromString,
208221
response_serializer=a2a__pb2.AgentCard.SerializeToString,
209222
),
223+
'DeleteTaskPushNotificationConfig': grpc.unary_unary_rpc_method_handler(
224+
servicer.DeleteTaskPushNotificationConfig,
225+
request_deserializer=a2a__pb2.DeleteTaskPushNotificationConfigRequest.FromString,
226+
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
227+
),
210228
}
211229
generic_handler = grpc.method_handlers_generic_handler(
212230
'a2a.v1.A2AService', rpc_method_handlers)
@@ -219,12 +237,12 @@ class A2AService(object):
219237
"""A2AService defines the gRPC version of the A2A protocol. This has a slightly
220238
different shape than the JSONRPC version to better conform to AIP-127,
221239
where appropriate. The nouns are AgentCard, Message, Task and
222-
TaskPushNotification.
240+
TaskPushNotificationConfig.
223241
- Messages are not a standard resource so there is no get/delete/update/list
224242
interface, only a send and stream custom methods.
225243
- Tasks have a get interface and custom cancel and subscribe methods.
226-
- TaskPushNotification are a resource whose parent is a task. They have get,
227-
list and create methods.
244+
- TaskPushNotificationConfig are a resource whose parent is a task.
245+
They have get, list and create methods.
228246
- AgentCard is a static resource with only a get method.
229247
fields are not present as they don't comply with AIP rules, and the
230248
optional history_length on the get task method is not present as it also
@@ -367,7 +385,7 @@ def TaskSubscription(request,
367385
_registered_method=True)
368386

369387
@staticmethod
370-
def CreateTaskPushNotification(request,
388+
def CreateTaskPushNotificationConfig(request,
371389
target,
372390
options=(),
373391
channel_credentials=None,
@@ -380,8 +398,8 @@ def CreateTaskPushNotification(request,
380398
return grpc.experimental.unary_unary(
381399
request,
382400
target,
383-
'/a2a.v1.A2AService/CreateTaskPushNotification',
384-
a2a__pb2.CreateTaskPushNotificationRequest.SerializeToString,
401+
'/a2a.v1.A2AService/CreateTaskPushNotificationConfig',
402+
a2a__pb2.CreateTaskPushNotificationConfigRequest.SerializeToString,
385403
a2a__pb2.TaskPushNotificationConfig.FromString,
386404
options,
387405
channel_credentials,
@@ -394,7 +412,7 @@ def CreateTaskPushNotification(request,
394412
_registered_method=True)
395413

396414
@staticmethod
397-
def GetTaskPushNotification(request,
415+
def GetTaskPushNotificationConfig(request,
398416
target,
399417
options=(),
400418
channel_credentials=None,
@@ -407,8 +425,8 @@ def GetTaskPushNotification(request,
407425
return grpc.experimental.unary_unary(
408426
request,
409427
target,
410-
'/a2a.v1.A2AService/GetTaskPushNotification',
411-
a2a__pb2.GetTaskPushNotificationRequest.SerializeToString,
428+
'/a2a.v1.A2AService/GetTaskPushNotificationConfig',
429+
a2a__pb2.GetTaskPushNotificationConfigRequest.SerializeToString,
412430
a2a__pb2.TaskPushNotificationConfig.FromString,
413431
options,
414432
channel_credentials,
@@ -421,7 +439,7 @@ def GetTaskPushNotification(request,
421439
_registered_method=True)
422440

423441
@staticmethod
424-
def ListTaskPushNotification(request,
442+
def ListTaskPushNotificationConfig(request,
425443
target,
426444
options=(),
427445
channel_credentials=None,
@@ -434,9 +452,9 @@ def ListTaskPushNotification(request,
434452
return grpc.experimental.unary_unary(
435453
request,
436454
target,
437-
'/a2a.v1.A2AService/ListTaskPushNotification',
438-
a2a__pb2.ListTaskPushNotificationRequest.SerializeToString,
439-
a2a__pb2.ListTaskPushNotificationResponse.FromString,
455+
'/a2a.v1.A2AService/ListTaskPushNotificationConfig',
456+
a2a__pb2.ListTaskPushNotificationConfigRequest.SerializeToString,
457+
a2a__pb2.ListTaskPushNotificationConfigResponse.FromString,
440458
options,
441459
channel_credentials,
442460
insecure,
@@ -473,3 +491,30 @@ def GetAgentCard(request,
473491
timeout,
474492
metadata,
475493
_registered_method=True)
494+
495+
@staticmethod
496+
def DeleteTaskPushNotificationConfig(request,
497+
target,
498+
options=(),
499+
channel_credentials=None,
500+
call_credentials=None,
501+
insecure=False,
502+
compression=None,
503+
wait_for_ready=None,
504+
timeout=None,
505+
metadata=None):
506+
return grpc.experimental.unary_unary(
507+
request,
508+
target,
509+
'/a2a.v1.A2AService/DeleteTaskPushNotificationConfig',
510+
a2a__pb2.DeleteTaskPushNotificationConfigRequest.SerializeToString,
511+
google_dot_protobuf_dot_empty__pb2.Empty.FromString,
512+
options,
513+
channel_credentials,
514+
insecure,
515+
call_credentials,
516+
compression,
517+
wait_for_ready,
518+
timeout,
519+
metadata,
520+
_registered_method=True)

src/a2a/server/request_handlers/grpc_handler.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ async def TaskSubscription(
198198
except ServerError as e:
199199
await self.abort_context(e, context)
200200

201-
async def GetTaskPushNotification(
201+
async def GetTaskPushNotificationConfig(
202202
self,
203-
request: a2a_pb2.GetTaskPushNotificationRequest,
203+
request: a2a_pb2.GetTaskPushNotificationConfigRequest,
204204
context: grpc.aio.ServicerContext,
205205
) -> a2a_pb2.TaskPushNotificationConfig:
206-
"""Handles the 'GetTaskPushNotification' gRPC method.
206+
"""Handles the 'GetTaskPushNotificationConfig' gRPC method.
207207
208208
Args:
209209
request: The incoming `GetTaskPushNotificationConfigRequest` object.
@@ -229,17 +229,17 @@ async def GetTaskPushNotification(
229229
lambda self: self.agent_card.capabilities.pushNotifications,
230230
'Push notifications are not supported by the agent',
231231
)
232-
async def CreateTaskPushNotification(
232+
async def CreateTaskPushNotificationConfig(
233233
self,
234-
request: a2a_pb2.CreateTaskPushNotificationRequest,
234+
request: a2a_pb2.CreateTaskPushNotificationConfigRequest,
235235
context: grpc.aio.ServicerContext,
236236
) -> a2a_pb2.TaskPushNotificationConfig:
237-
"""Handles the 'CreateTaskPushNotification' gRPC method.
237+
"""Handles the 'CreateTaskPushNotificationConfig' gRPC method.
238238
239239
Requires the agent to support push notifications.
240240
241241
Args:
242-
request: The incoming `CreateTaskPushNotificationRequest` object.
242+
request: The incoming `CreateTaskPushNotificationConfigRequest` object.
243243
context: Context provided by the server.
244244
245245
Returns:

0 commit comments

Comments
 (0)