Skip to content

feat(types): Refactor Part deserialization to use concrete types#104

Merged
edenreich merged 8 commits intomainfrom
claude/issue-102-20251011-1529
Oct 11, 2025
Merged

feat(types): Refactor Part deserialization to use concrete types#104
edenreich merged 8 commits intomainfrom
claude/issue-102-20251011-1529

Conversation

@edenreich
Copy link
Copy Markdown
Contributor

Implements #102

This PR refactors Part deserialization to use concrete types (TextPart, DataPart, FilePart) instead of map[string]any, improving type safety and developer experience.

Changes

  • Add custom JSON marshaling/unmarshaling for Part interface
  • Update ConvertFromSDK to create concrete types
  • Add helper functions for type-safe Part creation
  • Update client examples with typed assertions (backward compatible)
  • Add comprehensive test coverage

Benefits

  • Type safety: textPart.Text instead of complex map assertions
  • IDE autocompletion and compile-time checking
  • Performance: Direct field access vs map lookups
  • Maintains backward compatibility

Generated with Claude Code

…ead of map[string]any

- Implement custom JSON marshaling/unmarshaling for Part interface
- Add UnmarshalPart() function to deserialize into TextPart, DataPart, FilePart
- Add helper functions CreateTextPart(), CreateDataPart(), CreateFilePart()
- Update ConvertFromSDK to use concrete types instead of map[string]any
- Update client example to use typed assertions with backward compatibility
- Add comprehensive tests for new marshaling functionality
- All existing tests updated and passing

This change improves type safety and developer experience by allowing:
- part.(types.TextPart) instead of complex map assertions
- Direct field access (textPart.Text) vs map lookups
- IDE autocompletion and compile-time checking
- Maintains backward compatibility for existing map[string]any usage

Fixes #102

Co-authored-by: Eden Reich <edenreich@users.noreply.github.com>
…haling and marshaling more solid

Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
@edenreich edenreich merged commit 22d192e into main Oct 11, 2025
1 check passed
@edenreich edenreich deleted the claude/issue-102-20251011-1529 branch October 11, 2025 16:29
ig-semantic-release-bot bot added a commit that referenced this pull request Oct 11, 2025
## [0.14.0](v0.13.1...v0.14.0) (2025-10-11)

### ✨ Features

* Add the callbacks ready to be used by the agent ([#94](#94)) ([84632f3](84632f3))
* **types:** Refactor Part deserialization to use concrete types ([#104](#104)) ([22d192e](22d192e)), closes [#102](#102)

### ♻️ Improvements

* Consolidate the logic of the agent and remove redundancy ([#93](#93)) ([54e5e71](54e5e71))
* **docker-compose:** Remove port mappings for server service to avoid confusion ([3df7b08](3df7b08))
* **server:** Remove handler duplication between A2AServerImpl and DefaultA2AProtocolHandler ([#101](#101)) ([75b9c20](75b9c20))

### 🐛 Bug Fixes

* Improve validation logic for task handler configuration ([#98](#98)) ([34d6354](34d6354))

### 👷 CI

* Add Prettier setup and formatting steps for Go and markdown files ([#105](#105)) ([f2a1994](f2a1994))

### 📚 Documentation

* **examples:** Add input-required flow examples ([#96](#96)) ([17764f3](17764f3))

### 🔧 Miscellaneous

* **deps:** Update claude-code to 2.0.8 and install gh cli version 2.81.0 in flox environment ([4d6e41a](4d6e41a))
@ig-semantic-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant