-
Notifications
You must be signed in to change notification settings - Fork 105
Switch to local A2A Dart client library #627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…g a new event type StatusUpdate.
andrewkolos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RSLGTM. I was unable to verify anything E2E. I tried using the verdure example running on Android, but I failed to get it work with both this branch and main. Either the example is broken or I am doing something wrong when running it 🤷
|
If you still think there is a risk here, I feel like the safer approach here is to do what i proposed in #625 (comment) and just stub implementations for |
bae7abe to
39e30e6
Compare
I was able to get |
To go this route, we have to wait until the author of the a2a package has time to do this. It's a valid idea, and the a2a author also realizes that the MCP support should be a separate package, but both will take a bit of time to implement. |
|
I'm going to go ahead an commit this, to fix the compilation bug on web. Feel free to revert it if it starts causing any issues. |
Description
This temporarily replaces the
a2apackage dependency with a locally implemented A2A library so as to eliminate the issues stopping the web from compiling (See #625). The eventual plan is to switch back to the externala2apackage once those issues are resolved, but for now this keeps our dependencies simpler, since we don't use the full feature set of thea2apackage.The local A2A implementation is a new implementation from scratch, derived from the A2A spec.
Fixes #625
Summary of Changes
This pull request introduces a significant architectural change by replacing an external A2A client library with a custom, in-house implementation. The primary motivation is to address web compilation issues and reduce external dependencies by tailoring the A2A client to the specific needs of the project. The changes span across new data models, transport layers, and integration points, ensuring a more controlled and efficient interaction with A2A agents.
Highlights
a2apackage dependency with a new, locally implemented A2A client library. This change is specifically aimed at resolving web compilation issues (mcp_dart 1.1.1 causes compiler crashes on Flutter Web. #625) and streamlining dependencies by focusing only on the necessary A2A features.pubspec.yamlfile has been updated to remove the olda2adependency and introduce new packages likefreezed_annotation,http,json_annotation, andsse_channel. Development dependencies for code generation (build_runner,freezed,json_serializable) have also been added, alongside abuild.yamlfor configuration.A2uiAgentConnectorhas been refactored to seamlessly integrate with the new local A2A client. This involves updating how the client is instantiated, how agent cards are retrieved, and how messages are sent and streamed, including specific handling for A2UI extensions.printtodebugPrintfor logging in the Verdure example client and addingflutter/material.dartimport fordebugPrintfunctionality.Changelog
printstatements withdebugPrintfor better Flutter logging practices.package:flutter/material.dartto supportdebugPrint.genuiandgenui_a2uipackage versions.a2apackage dependency from the examplepubspec.yamlsnippet.json_serializableandsource_genbuilders for code generation.A2AHandlerandA2AHandlerPipelinefor intercepting requests and responses.Transportinterface using standard HTTP requests for non-streaming interactions.Transportinterface for streaming responses using Server-Sent Events (SSE).Transportinterface for A2A communication.AgentCapabilitiesdata model.AgentCapabilities.AgentCapabilities.AgentCarddata model.AgentCard.AgentCard.AgentExtensiondata model.AgentExtension.AgentExtension.AgentInterfaceandTransportProtocoldata models.AgentInterface.AgentInterface.AgentProviderdata model.AgentProvider.AgentProvider.AgentSkilldata model.AgentSkill.AgentSkill.Eventsealed class for task status and artifact updates.Event.Event.ListTasksParamsdata model.ListTasksParams.ListTasksParams.ListTasksResultdata model.ListTasksResult.ListTasksResult.MessageandRoledata models.Message.Message.Partsealed class andFileTypefor message content.Part.Part.PushNotificationConfig,PushNotificationAuthenticationInfo, andTaskPushNotificationConfigdata models.SecuritySchemesealed class,OAuthFlows, andOAuthFlowdata models.Task,TaskStatus,TaskState, andArtifactdata models.A2uiAgentConnectorconstructor to instantiateA2AClientwithSseTransportand A2A extensions.getAgentCardto directly return the newAgentCardobject.connectAndSendto use the newMessageandPartdata models and handleEventtypes from the stream.sendEventto use the newMessageandPartdata models for sending client events.a2adependency.freezed_annotation,http,json_annotation,sse_channelas dependencies.build_runner,dart_flutter_team_lints,freezed,json_serializable,lintsas dev dependencies.HttpTransportimplementation.SseTransportimplementation, including multi-line data, comments, and error handling.AgentCardserialization and deserialization.Transportimplementation for testing purposes.HttpClientandTransportimplementations for testing.A2uiAgentConnectorand the new A2A client data models.FakeA2AClientto conform to the new local A2A library interface and data models.FakeA2uiAgentConnectorto return the newAgentCardobject.test_and_fixtool is intended for pre-commit checks rather than specific test runs.