chore: add translation units#481
Conversation
🧪 Code Coverage
Generated by coverage-comment.yml |
There was a problem hiding this comment.
Code Review
This pull request implements a comprehensive translation layer for bidirectional conversion between v1.0 protobuf and legacy v0.3 JSON types, covering entities like agent cards, messages, tasks, and security schemes. Reviewer feedback suggests using structuredClone for deep copying in the cloneMetadata utility to avoid side effects, adding validation for security scheme locations to prevent invalid casts, and fixing a file path typo in the README.
…and default unknown values to header
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive translation layer for the legacy A2A v0.3 protocol, enabling bidirectional conversion between v1.0 protobuf types and v0.3 JSON types. The implementation covers core entities including agent cards, messages, tasks, security schemes, and RPC requests/responses, supported by a dedicated deep-cloning utility and protocol version helpers. Extensive unit tests are provided for each translation unit. Feedback suggests replacing a generic error with A2AError.invalidParams in the task artifact update translator to maintain consistency across the translation layer.
Description
This PR introduces translatios for v0_3 compatibility layer
The
translate/subdirectory contains bidirectional payload translators between the modern v1.0 protobuf types (insrc/types/pb/a2a.ts) and the legacy v0.3 JSON types (insrc/compat/v0_3/types/types.ts).The naming convention is direction-anchored:
toCore<Entity>converts a v0.3 value into the equivalent v1.0 proto value.toCompat<Entity>converts a v1.0 proto value into the equivalent v0.3 JSON value.Translators are split per entity group (
parts.ts,messages.ts,tasks.ts,push_notifications.ts,security.ts,agent_card.ts,requests.ts,enums.ts,versions.ts) for clarity and tree-shaking. The full surface is re-exported fromtranslate/index.ts.Notable policy decisions based on A2A Python SDK compat layer:
PushNotificationAuthenticationInfo.schemesis truncated to a single scheme going v0.3 → v1.0; only the first entry is kept.OAuthFlows.deviceCodeflow is silently dropped going v1.0 → v0.3 (v0.3 has no equivalent).TaskStatusUpdateEvent.finalis computed from the status state going v1.0 → v0.3 (trueforcompleted,canceled,failed,rejected).SendMessageConfiguration.returnImmediately↔MessageSendConfiguration.blockingwith inverted polarity.toCompatAgentCardfilterssupportedInterfacesto those whoseprotocolVersionis empty or in[0.3, 1.0)and throwsVersionNotSupportedErrorif none qualify.Closes #473 🦕