Skip to content

chore: add translation units#481

Open
JakubWorek wants to merge 5 commits into
epic/1.0_breaking_changesfrom
jakubworek/add-translation-units
Open

chore: add translation units#481
JakubWorek wants to merge 5 commits into
epic/1.0_breaking_changesfrom
jakubworek/add-translation-units

Conversation

@JakubWorek
Copy link
Copy Markdown
Collaborator

Description

This PR introduces translatios for v0_3 compatibility layer

The translate/ subdirectory contains bidirectional payload translators between the modern v1.0 protobuf types (in src/types/pb/a2a.ts) and the legacy v0.3 JSON types (in src/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 from translate/index.ts.

Notable policy decisions based on A2A Python SDK compat layer:

  • PushNotificationAuthenticationInfo.schemes is truncated to a single scheme going v0.3 → v1.0; only the first entry is kept.
  • The v1.0 OAuthFlows.deviceCode flow is silently dropped going v1.0 → v0.3 (v0.3 has no equivalent).
  • TaskStatusUpdateEvent.final is computed from the status state going v1.0 → v0.3 (true for completed, canceled, failed, rejected).
  • SendMessageConfiguration.returnImmediatelyMessageSendConfiguration.blocking with inverted polarity.
  • toCompatAgentCard filters supportedInterfaces to those whose protocolVersion is empty or in [0.3, 1.0) and throws VersionNotSupportedError if none qualify.

Closes #473 🦕

@JakubWorek JakubWorek requested a review from a team as a code owner May 18, 2026 10:35
@JakubWorek JakubWorek linked an issue May 18, 2026 that may be closed by this pull request
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

🧪 Code Coverage

⬇️ Download Full Report

Base PR Delta
src/server/store.ts 68.13% 65.93% 🔴 -2.20%
src/compat/v0_3/translate/_clone.ts (new) 100%
src/compat/v0_3/translate/agent_card.ts (new) 88.55%
src/compat/v0_3/translate/enums.ts (new) 93.75%
src/compat/v0_3/translate/index.ts (new) 0%
src/compat/v0_3/translate/messages.ts (new) 100%
src/compat/v0_3/translate/parts.ts (new) 98.24%
src/compat/v0_3/translate/push_notifications.ts (new) 100%
src/compat/v0_3/translate/requests.ts (new) 93.56%
src/compat/v0_3/translate/security.ts (new) 98.32%
src/compat/v0_3/translate/tasks.ts (new) 99.09%
src/compat/v0_3/translate/versions.ts (new) 100%
Total 88.79% 89.78% 🟢 +0.99%

Generated by coverage-comment.yml

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/compat/v0_3/translate/agent_card.ts Outdated
Comment thread src/compat/v0_3/translate/messages.ts Outdated
Comment thread src/compat/v0_3/translate/parts.ts Outdated
Comment thread src/compat/v0_3/translate/requests.ts Outdated
Comment thread src/compat/v0_3/translate/security.ts Outdated
Comment thread src/compat/v0_3/translate/tasks.ts Outdated
Comment thread src/compat/v0_3/README.md Outdated
@JakubWorek
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/compat/v0_3/translate/tasks.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(compat): Add translation units

1 participant