Skip to content

Commit 4b520d7

Browse files
authored
Merge branch '1.0-dev' into tenant
2 parents be01104 + 26835ad commit 4b520d7

59 files changed

Lines changed: 7228 additions & 927 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/spelling/allow.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ notif
8686
npx
8787
oauthoidc
8888
oidc
89+
Oneof
8990
OpenAPI
9091
openapiv
9192
openapiv2

buf.compat.gen.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Protobuf generation for legacy v0.3 A2A protocol buffer modules.
2+
---
3+
version: v2
4+
managed:
5+
enabled: true
6+
plugins:
7+
- remote: buf.build/protocolbuffers/python:v29.3
8+
out: src/a2a/compat/v0_3
9+
- remote: buf.build/grpc/python
10+
out: src/a2a/compat/v0_3
11+
- remote: buf.build/protocolbuffers/pyi
12+
out: src/a2a/compat/v0_3

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ exclude = [
162162
"**/venv",
163163
"**/.venv",
164164
"src/a2a/types",
165+
"src/a2a/compat/v0_3/*_pb2*.py",
166+
"src/a2a/compat/v0_3/proto_utils.py",
165167
]
166168
venvPath = "."
167169
venv = ".venv"

scripts/gen_proto.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,16 @@ fi
1919
# Fix imports in generated grpc file
2020
echo "Fixing imports in src/a2a/types/a2a_pb2_grpc.py"
2121
sed 's/import a2a_pb2 as a2a__pb2/from . import a2a_pb2 as a2a__pb2/g' src/a2a/types/a2a_pb2_grpc.py > src/a2a/types/a2a_pb2_grpc.py.tmp && mv src/a2a/types/a2a_pb2_grpc.py.tmp src/a2a/types/a2a_pb2_grpc.py
22+
23+
# Download legacy v0.3 compatibility protobuf code
24+
echo "Downloading legacy v0.3 proto file..."
25+
# Commit hash was selected as a2a.proto version from 0.3 branch with latests fixes.
26+
curl -o src/a2a/compat/v0_3/a2a_v0_3.proto https://raw.githubusercontent.com/a2aproject/A2A/b3b266d127dde3d1000ec103b252d1de81289e83/specification/grpc/a2a.proto
27+
28+
# Generate legacy v0.3 compatibility protobuf code
29+
echo "Generating legacy v0.3 compatibility protobuf code"
30+
npx --yes @bufbuild/buf generate src/a2a/compat/v0_3 --template buf.compat.gen.yaml
31+
32+
# Fix imports in legacy generated grpc file
33+
echo "Fixing imports in src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py"
34+
sed 's/import a2a_v0_3_pb2 as a2a__v0__3__pb2/from . import a2a_v0_3_pb2 as a2a__v0__3__pb2/g' src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py > src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py.tmp && mv src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py.tmp src/a2a/compat/v0_3/a2a_v0_3_pb2_grpc.py

src/a2a/client/base_client.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from collections.abc import AsyncGenerator, AsyncIterator, Callable
2-
from types import TracebackType
32
from typing import Any
43

5-
from typing_extensions import Self
6-
74
from a2a.client.client import (
85
Client,
96
ClientCallContext,
@@ -51,19 +48,6 @@ def __init__(
5148
self._config = config
5249
self._transport = transport
5350

54-
async def __aenter__(self) -> Self:
55-
"""Enters the async context manager, returning the client itself."""
56-
return self
57-
58-
async def __aexit__(
59-
self,
60-
exc_type: type[BaseException] | None,
61-
exc_val: BaseException | None,
62-
exc_tb: TracebackType | None,
63-
) -> None:
64-
"""Exits the async context manager, ensuring close() is called."""
65-
await self.close()
66-
6751
async def send_message(
6852
self,
6953
request: Message,
@@ -208,7 +192,7 @@ async def cancel_task(
208192
request, context=context, extensions=extensions
209193
)
210194

211-
async def set_task_callback(
195+
async def create_task_push_notification_config(
212196
self,
213197
request: CreateTaskPushNotificationConfigRequest,
214198
*,
@@ -225,11 +209,11 @@ async def set_task_callback(
225209
Returns:
226210
The created or updated `TaskPushNotificationConfig` object.
227211
"""
228-
return await self._transport.set_task_callback(
212+
return await self._transport.create_task_push_notification_config(
229213
request, context=context, extensions=extensions
230214
)
231215

232-
async def get_task_callback(
216+
async def get_task_push_notification_config(
233217
self,
234218
request: GetTaskPushNotificationConfigRequest,
235219
*,
@@ -246,11 +230,11 @@ async def get_task_callback(
246230
Returns:
247231
A `TaskPushNotificationConfig` object containing the configuration.
248232
"""
249-
return await self._transport.get_task_callback(
233+
return await self._transport.get_task_push_notification_config(
250234
request, context=context, extensions=extensions
251235
)
252236

253-
async def list_task_callback(
237+
async def list_task_push_notification_configs(
254238
self,
255239
request: ListTaskPushNotificationConfigsRequest,
256240
*,
@@ -267,11 +251,11 @@ async def list_task_callback(
267251
Returns:
268252
A `ListTaskPushNotificationConfigsResponse` object.
269253
"""
270-
return await self._transport.list_task_callback(
254+
return await self._transport.list_task_push_notification_configs(
271255
request, context=context, extensions=extensions
272256
)
273257

274-
async def delete_task_callback(
258+
async def delete_task_push_notification_config(
275259
self,
276260
request: DeleteTaskPushNotificationConfigRequest,
277261
*,
@@ -285,7 +269,7 @@ async def delete_task_callback(
285269
context: The client call context.
286270
extensions: List of extensions to be activated.
287271
"""
288-
await self._transport.delete_task_callback(
272+
await self._transport.delete_task_push_notification_config(
289273
request, context=context, extensions=extensions
290274
)
291275

src/a2a/client/client.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33

44
from abc import ABC, abstractmethod
55
from collections.abc import AsyncIterator, Callable, Coroutine
6+
from types import TracebackType
67
from typing import Any
78

89
import httpx
910

11+
from typing_extensions import Self
12+
1013
from a2a.client.middleware import ClientCallContext, ClientCallInterceptor
1114
from a2a.client.optionals import Channel
1215
from a2a.types.a2a_pb2 import (
@@ -71,7 +74,7 @@ class ClientConfig:
7174
push_notification_configs: list[PushNotificationConfig] = dataclasses.field(
7275
default_factory=list
7376
)
74-
"""Push notification callbacks to use for every request."""
77+
"""Push notification configurations to use for every request."""
7578

7679
extensions: list[str] = dataclasses.field(default_factory=list)
7780
"""A list of extension URIs the client supports."""
@@ -110,6 +113,19 @@ def __init__(
110113
self._consumers = consumers
111114
self._middleware = middleware
112115

116+
async def __aenter__(self) -> Self:
117+
"""Enters the async context manager."""
118+
return self
119+
120+
async def __aexit__(
121+
self,
122+
exc_type: type[BaseException] | None,
123+
exc_val: BaseException | None,
124+
exc_tb: TracebackType | None,
125+
) -> None:
126+
"""Exits the async context manager and closes the client."""
127+
await self.close()
128+
113129
@abstractmethod
114130
async def send_message(
115131
self,
@@ -161,7 +177,7 @@ async def cancel_task(
161177
"""Requests the agent to cancel a specific task."""
162178

163179
@abstractmethod
164-
async def set_task_callback(
180+
async def create_task_push_notification_config(
165181
self,
166182
request: CreateTaskPushNotificationConfigRequest,
167183
*,
@@ -171,7 +187,7 @@ async def set_task_callback(
171187
"""Sets or updates the push notification configuration for a specific task."""
172188

173189
@abstractmethod
174-
async def get_task_callback(
190+
async def get_task_push_notification_config(
175191
self,
176192
request: GetTaskPushNotificationConfigRequest,
177193
*,
@@ -181,7 +197,7 @@ async def get_task_callback(
181197
"""Retrieves the push notification configuration for a specific task."""
182198

183199
@abstractmethod
184-
async def list_task_callback(
200+
async def list_task_push_notification_configs(
185201
self,
186202
request: ListTaskPushNotificationConfigsRequest,
187203
*,
@@ -191,7 +207,7 @@ async def list_task_callback(
191207
"""Lists push notification configurations for a specific task."""
192208

193209
@abstractmethod
194-
async def delete_task_callback(
210+
async def delete_task_push_notification_config(
195211
self,
196212
request: DeleteTaskPushNotificationConfigRequest,
197213
*,
@@ -242,3 +258,7 @@ async def consume(
242258
return
243259
for c in self._consumers:
244260
await c(event, card)
261+
262+
@abstractmethod
263+
async def close(self) -> None:
264+
"""Closes the client and releases any underlying resources."""

src/a2a/client/transports/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async def cancel_task(
9595
"""Requests the agent to cancel a specific task."""
9696

9797
@abstractmethod
98-
async def set_task_callback(
98+
async def create_task_push_notification_config(
9999
self,
100100
request: CreateTaskPushNotificationConfigRequest,
101101
*,
@@ -105,7 +105,7 @@ async def set_task_callback(
105105
"""Sets or updates the push notification configuration for a specific task."""
106106

107107
@abstractmethod
108-
async def get_task_callback(
108+
async def get_task_push_notification_config(
109109
self,
110110
request: GetTaskPushNotificationConfigRequest,
111111
*,
@@ -115,7 +115,7 @@ async def get_task_callback(
115115
"""Retrieves the push notification configuration for a specific task."""
116116

117117
@abstractmethod
118-
async def list_task_callback(
118+
async def list_task_push_notification_configs(
119119
self,
120120
request: ListTaskPushNotificationConfigsRequest,
121121
*,
@@ -125,7 +125,7 @@ async def list_task_callback(
125125
"""Lists push notification configurations for a specific task."""
126126

127127
@abstractmethod
128-
async def delete_task_callback(
128+
async def delete_task_push_notification_config(
129129
self,
130130
request: DeleteTaskPushNotificationConfigRequest,
131131
*,

src/a2a/client/transports/grpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ async def cancel_task(
175175
metadata=self._get_grpc_metadata(extensions),
176176
)
177177

178-
async def set_task_callback(
178+
async def create_task_push_notification_config(
179179
self,
180180
request: CreateTaskPushNotificationConfigRequest,
181181
*,
@@ -188,7 +188,7 @@ async def set_task_callback(
188188
metadata=self._get_grpc_metadata(extensions),
189189
)
190190

191-
async def get_task_callback(
191+
async def get_task_push_notification_config(
192192
self,
193193
request: GetTaskPushNotificationConfigRequest,
194194
*,
@@ -201,7 +201,7 @@ async def get_task_callback(
201201
metadata=self._get_grpc_metadata(extensions),
202202
)
203203

204-
async def list_task_callback(
204+
async def list_task_push_notification_configs(
205205
self,
206206
request: ListTaskPushNotificationConfigsRequest,
207207
*,
@@ -214,7 +214,7 @@ async def list_task_callback(
214214
metadata=self._get_grpc_metadata(extensions),
215215
)
216216

217-
async def delete_task_callback(
217+
async def delete_task_push_notification_config(
218218
self,
219219
request: DeleteTaskPushNotificationConfigRequest,
220220
*,

src/a2a/client/transports/jsonrpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ async def cancel_task(
303303
response: Task = json_format.ParseDict(json_rpc_response.result, Task())
304304
return response
305305

306-
async def set_task_callback(
306+
async def create_task_push_notification_config(
307307
self,
308308
request: CreateTaskPushNotificationConfigRequest,
309309
*,
@@ -335,7 +335,7 @@ async def set_task_callback(
335335
)
336336
return response
337337

338-
async def get_task_callback(
338+
async def get_task_push_notification_config(
339339
self,
340340
request: GetTaskPushNotificationConfigRequest,
341341
*,
@@ -367,7 +367,7 @@ async def get_task_callback(
367367
)
368368
return response
369369

370-
async def list_task_callback(
370+
async def list_task_push_notification_configs(
371371
self,
372372
request: ListTaskPushNotificationConfigsRequest,
373373
*,
@@ -402,7 +402,7 @@ async def list_task_callback(
402402
)
403403
return response
404404

405-
async def delete_task_callback(
405+
async def delete_task_push_notification_config(
406406
self,
407407
request: DeleteTaskPushNotificationConfigRequest,
408408
*,

src/a2a/client/transports/rest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ async def cancel_task(
321321
response: Task = ParseDict(response_data, Task())
322322
return response
323323

324-
async def set_task_callback(
324+
async def create_task_push_notification_config(
325325
self,
326326
request: CreateTaskPushNotificationConfigRequest,
327327
*,
@@ -353,7 +353,7 @@ async def set_task_callback(
353353
)
354354
return response
355355

356-
async def get_task_callback(
356+
async def get_task_push_notification_config(
357357
self,
358358
request: GetTaskPushNotificationConfigRequest,
359359
*,
@@ -392,7 +392,7 @@ async def get_task_callback(
392392
)
393393
return response
394394

395-
async def list_task_callback(
395+
async def list_task_push_notification_configs(
396396
self,
397397
request: ListTaskPushNotificationConfigsRequest,
398398
*,
@@ -428,7 +428,7 @@ async def list_task_callback(
428428
)
429429
return response
430430

431-
async def delete_task_callback(
431+
async def delete_task_push_notification_config(
432432
self,
433433
request: DeleteTaskPushNotificationConfigRequest,
434434
*,

0 commit comments

Comments
 (0)