refactor: extract JSON-RPC specific logic from client#169
Merged
Conversation
c156b2f to
ede8673
Compare
yarolegovich
requested changes
Nov 12, 2025
This was referenced Nov 12, 2025
Closed
a9487aa to
4317636
Compare
yarolegovich
approved these changes
Nov 12, 2025
swapydapy
requested changes
Nov 13, 2025
swapydapy
approved these changes
Nov 19, 2025
ishymko
added a commit
that referenced
this pull request
Nov 27, 2025
# Description As a next step after #169, define a transport agnostic client. # Changes ## Main - Define `Client` built around core types, not JSON-RPC wrappers. - Define `ClientFactory` to dynamically select transport among available based on agent card and factory level preferences. ## Misc - Rename `A2ATransport` to `Transport` (this type is not yet exported via `index.ts`). - Add `AbortSignal` to `Transport` and new client for cancellation. - Add basic E2E test for `sendMessage` and `sendMessageStream` using server SDK wired up with real expressjs app and invoked via newly created client. - Fix `getTaskPushNotificationConfig` types in transport. # TODOs - Client interceptors. - Extensions support. Re #137, #142 Release-As: 0.3.6
4 tasks
ishymko
pushed a commit
that referenced
this pull request
Feb 11, 2026
## Summary Replaces `console.error`/`console.warn` calls with thrown errors when a JSON-RPC response id does not match the request id. Per the JSON-RPC 2.0 specification, this is a protocol invariant violation — continuing execution with a mismatched response can lead to silent data corruption. ### Changes - **`_sendRpcRequest`**: `console.error` → `throw new Error` on id mismatch - **`_processSseEventData`**: `console.warn` → `throw new Error` on id mismatch - **`_processSseEventData` catch block**: Added the new error message to the pass-through condition so it is not swallowed and re-wrapped as a parse error ### Context From the code review on PR #169: *"Go SDK doesn't perform any validation, but I'd probably be throwing in case of a mismatch"* — @yarolegovich Fixes #176 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently
A2AClientdefined inclient.tsuses JSON-RPC types in its interface, i.e.sendMessageusesSendMessageResponsewhich contains JSON-RPC fields likeidandjsonrpcversion. It was also the case for Python SDK which required introducing a new client.py keeping the old one as legacy.py for backward compatibility (see #348).As a first step of introducing a transport-agnostic client, extract JSON-RPC specific logic into a transport abstraction and switch existing
A2AClientto 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
A2ATransportabstraction without using JSON-RPC types.JsonRpcTransportfrom existingA2AClient.JsonRpcTransportfromA2AClient- 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.Re #137, #142