Skip to content

Commit dc9f7dc

Browse files
authored
refactor: extract JSON-RPC specific logic from client (#169)
# Description Currently `A2AClient` defined in `client.ts` uses JSON-RPC types in its interface, i.e. `sendMessage` uses [`SendMessageResponse`](https://github.com/a2aproject/a2a-js/blob/e7e8f35d5d5356d30a13131dea0caff97be8cd53/src/client/client.ts#L207) which contains [JSON-RPC fields like `id` and `jsonrpc` version](https://github.com/a2aproject/a2a-js/blob/e7e8f35d5d5356d30a13131dea0caff97be8cd53/src/types.ts#L2177-L2190). It was also the case for Python SDK which required introducing a new [client.py](https://github.com/a2aproject/a2a-python/blob/main/src/a2a/client/client.py) keeping the old one as [legacy.py](https://github.com/a2aproject/a2a-python/blob/main/src/a2a/client/legacy.py) for backward compatibility (see [#348](a2aproject/a2a-python#348)). As a first step of introducing a transport-agnostic client, extract JSON-RPC specific logic into a transport abstraction and switch existing `A2AClient` to it in a backward compatible way to take advantage of existing tests. **Note:** new types are not exported from `index.ts`, this will be done once new client is ready. # Changes 1. Define `A2ATransport` abstraction without using JSON-RPC types. 2. Implement `JsonRpcTransport` from existing `A2AClient`. 3. Use new `JsonRpcTransport` from `A2AClient` - new transports are **not going** to be added into this client as it uses JSON-RPC types. This is done in a backward compatible way, existing behavior is preserved: returning JSON-RPC errors as objects, populating JSON-RPC specific fields. 4. Define shared transport-agnostic errors for A2A specific errors defined in [the spec](https://a2a-protocol.org/latest/specification/#82-a2a-specific-errors). Re #137, #142
1 parent 4f07c0d commit dc9f7dc

File tree

4 files changed

+624
-355
lines changed

4 files changed

+624
-355
lines changed

0 commit comments

Comments
 (0)