Skip to content

Commit 8bfa846

Browse files
pstephengooglegemini-code-assist[bot]holtskinner
committed
refactor: Refactor client code to support multi-transport interactions and simplify client interfaces (#342)
# Description Refactor the client codebase to support automated, configurable, client factory to generate a client based on the agent card details. Adds support for generation of clients based on JSONRPC, gRPC and RESTful interfaces. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Holt Skinner <[email protected]> Co-authored-by: Holt Skinner <[email protected]>
1 parent 2fa0964 commit 8bfa846

File tree

14 files changed

+2301
-420
lines changed

14 files changed

+2301
-420
lines changed

.github/actions/spelling/allow.txt

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,6 @@ AServers
1717
AService
1818
AStarlette
1919
AUser
20-
DSNs
21-
EUR
22-
GBP
23-
GVsb
24-
INR
25-
JPY
26-
JSONRPCt
27-
Llm
28-
POSTGRES
29-
RUF
30-
Tful
31-
aconnect
32-
adk
33-
agentic
34-
aio
35-
aiomysql
36-
aproject
3720
autouse
3821
backticks
3922
cla
@@ -82,6 +65,7 @@ pyi
8265
pypistats
8366
pyupgrade
8467
pyversions
68+
redef
8569
respx
8670
resub
8771
RUF
@@ -91,5 +75,6 @@ sse
9175
tagwords
9276
taskupdate
9377
testuuid
78+
Tful
9479
typeerror
9580
vulnz

src/a2a/client/__init__.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,47 @@
77
CredentialService,
88
InMemoryContextCredentialStore,
99
)
10-
from a2a.client.client import A2ACardResolver, A2AClient
10+
from a2a.client.client import (
11+
A2ACardResolver,
12+
Client,
13+
ClientConfig,
14+
ClientEvent,
15+
Consumer,
16+
)
17+
from a2a.client.client_factory import (
18+
ClientFactory,
19+
ClientProducer,
20+
minimal_agent_card,
21+
)
1122
from a2a.client.errors import (
1223
A2AClientError,
1324
A2AClientHTTPError,
1425
A2AClientJSONError,
1526
A2AClientTimeoutError,
1627
)
28+
from a2a.client.grpc_client import (
29+
GrpcClient,
30+
GrpcTransportClient,
31+
NewGrpcClient,
32+
)
1733
from a2a.client.helpers import create_text_message_object
34+
from a2a.client.jsonrpc_client import (
35+
JsonRpcClient,
36+
JsonRpcTransportClient,
37+
NewJsonRpcClient,
38+
)
1839
from a2a.client.middleware import ClientCallContext, ClientCallInterceptor
40+
from a2a.client.rest_client import (
41+
NewRestfulClient,
42+
RestClient,
43+
RestTransportClient,
44+
)
45+
1946

47+
# For backward compatability define this alias. This will be deprecated in
48+
# a future release.
49+
A2AClient = JsonRpcTransportClient
50+
A2AGrpcClient = GrpcTransportClient
2051

2152
logger = logging.getLogger(__name__)
2253

@@ -41,16 +72,32 @@ def __init__(self, *args, **kwargs):
4172

4273
__all__ = [
4374
'A2ACardResolver',
44-
'A2AClient',
75+
'A2AClient', # for backward compatability
4576
'A2AClientError',
4677
'A2AClientHTTPError',
4778
'A2AClientJSONError',
4879
'A2AClientTimeoutError',
49-
'A2AGrpcClient',
80+
'A2AGrpcClient', # for backward compatability
5081
'AuthInterceptor',
82+
'Client',
5183
'ClientCallContext',
5284
'ClientCallInterceptor',
85+
'ClientConfig',
86+
'ClientEvent',
87+
'ClientFactory',
88+
'ClientProducer',
89+
'Consumer',
5390
'CredentialService',
91+
'GrpcClient',
92+
'GrpcTransportClient',
5493
'InMemoryContextCredentialStore',
94+
'JsonRpcClient',
95+
'JsonRpcTransportClient',
96+
'NewGrpcClient',
97+
'NewJsonRpcClient',
98+
'NewRestfulClient',
99+
'RestClient',
100+
'RestTransportClient',
55101
'create_text_message_object',
102+
'minimal_agent_card',
56103
]

0 commit comments

Comments
 (0)