Skip to content

Conversation

@gspencergoog
Copy link
Collaborator

@gspencergoog gspencergoog commented Dec 19, 2025

Description

This temporarily replaces the a2a package 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 external a2a package once those issues are resolved, but for now this keeps our dependencies simpler, since we don't use the full feature set of the a2a package.

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

  • Local A2A Client Implementation: The pull request replaces the external a2a package 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.
  • New A2A Client Architecture: A comprehensive A2A client library has been built from scratch, adhering to the A2A specification. This includes new data models for agent cards, messages, tasks, events, and security schemes, along with dedicated transport mechanisms for HTTP and Server-Sent Events (SSE).
  • Dependency Management and Code Generation: The pubspec.yaml file has been updated to remove the old a2a dependency and introduce new packages like freezed_annotation, http, json_annotation, and sse_channel. Development dependencies for code generation (build_runner, freezed, json_serializable) have also been added, alongside a build.yaml for configuration.
  • A2uiAgentConnector Integration: The A2uiAgentConnector has 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.
  • Logging and Utility Improvements: Minor improvements include switching from print to debugPrint for logging in the Verdure example client and adding flutter/material.dart import for debugPrint functionality.
Changelog
  • examples/verdure/client/.metadata
    • Updated revision and channel to 'stable'.
    • Added 'web' platform to migration metadata.
  • examples/verdure/client/lib/core/logging.dart
    • Replaced print statements with debugPrint for better Flutter logging practices.
    • Added import for package:flutter/material.dart to support debugPrint.
  • packages/genui_a2ui/README.md
    • Updated genui and genui_a2ui package versions.
    • Removed the a2a package dependency from the example pubspec.yaml snippet.
  • packages/genui_a2ui/build.yaml
    • Added new file to configure json_serializable and source_gen builders for code generation.
  • packages/genui_a2ui/lib/src/a2a/a2a.dart
    • Added new file, serving as the main export for the new local A2A client library components.
  • packages/genui_a2ui/lib/src/a2a/client/a2a_client.dart
    • Added new file, implementing the core logic for interacting with an A2A server, including RPC calls and error handling.
  • packages/genui_a2ui/lib/src/a2a/client/a2a_exception.dart
    • Added new file defining a sealed class hierarchy for A2A-specific exceptions (JSON-RPC, network, parsing, etc.).
  • packages/genui_a2ui/lib/src/a2a/client/a2a_exception.freezed.dart
    • Added generated file for A2A exception data models.
  • packages/genui_a2ui/lib/src/a2a/client/a2a_exception.g.dart
    • Added generated file for A2A exception data models.
  • packages/genui_a2ui/lib/src/a2a/client/a2a_handler.dart
    • Added new file defining an abstract A2AHandler and A2AHandlerPipeline for intercepting requests and responses.
  • packages/genui_a2ui/lib/src/a2a/client/http_transport.dart
    • Added new file implementing the Transport interface using standard HTTP requests for non-streaming interactions.
  • packages/genui_a2ui/lib/src/a2a/client/sse_parser.dart
    • Added new file for parsing Server-Sent Events (SSE) streams into JSON objects.
  • packages/genui_a2ui/lib/src/a2a/client/sse_transport.dart
    • Added new file implementing the Transport interface for streaming responses using Server-Sent Events (SSE).
  • packages/genui_a2ui/lib/src/a2a/client/transport.dart
    • Added new file defining the abstract Transport interface for A2A communication.
  • packages/genui_a2ui/lib/src/a2a/core/agent_capabilities.dart
    • Added new file defining the AgentCapabilities data model.
  • packages/genui_a2ui/lib/src/a2a/core/agent_capabilities.freezed.dart
    • Added generated file for AgentCapabilities.
  • packages/genui_a2ui/lib/src/a2a/core/agent_capabilities.g.dart
    • Added generated file for AgentCapabilities.
  • packages/genui_a2ui/lib/src/a2a/core/agent_card.dart
    • Added new file defining the AgentCard data model.
  • packages/genui_a2ui/lib/src/a2a/core/agent_card.freezed.dart
    • Added generated file for AgentCard.
  • packages/genui_a2ui/lib/src/a2a/core/agent_card.g.dart
    • Added generated file for AgentCard.
  • packages/genui_a2ui/lib/src/a2a/core/agent_extension.dart
    • Added new file defining the AgentExtension data model.
  • packages/genui_a2ui/lib/src/a2a/core/agent_extension.freezed.dart
    • Added generated file for AgentExtension.
  • packages/genui_a2ui/lib/src/a2a/core/agent_extension.g.dart
    • Added generated file for AgentExtension.
  • packages/genui_a2ui/lib/src/a2a/core/agent_interface.dart
    • Added new file defining the AgentInterface and TransportProtocol data models.
  • packages/genui_a2ui/lib/src/a2a/core/agent_interface.freezed.dart
    • Added generated file for AgentInterface.
  • packages/genui_a2ui/lib/src/a2a/core/agent_interface.g.dart
    • Added generated file for AgentInterface.
  • packages/genui_a2ui/lib/src/a2a/core/agent_provider.dart
    • Added new file defining the AgentProvider data model.
  • packages/genui_a2ui/lib/src/a2a/core/agent_provider.freezed.dart
    • Added generated file for AgentProvider.
  • packages/genui_a2ui/lib/src/a2a/core/agent_provider.g.dart
    • Added generated file for AgentProvider.
  • packages/genui_a2ui/lib/src/a2a/core/agent_skill.dart
    • Added new file defining the AgentSkill data model.
  • packages/genui_a2ui/lib/src/a2a/core/agent_skill.freezed.dart
    • Added generated file for AgentSkill.
  • packages/genui_a2ui/lib/src/a2a/core/agent_skill.g.dart
    • Added generated file for AgentSkill.
  • packages/genui_a2ui/lib/src/a2a/core/events.dart
    • Added new file defining the Event sealed class for task status and artifact updates.
  • packages/genui_a2ui/lib/src/a2a/core/events.freezed.dart
    • Added generated file for Event.
  • packages/genui_a2ui/lib/src/a2a/core/events.g.dart
    • Added generated file for Event.
  • packages/genui_a2ui/lib/src/a2a/core/list_tasks_params.dart
    • Added new file defining the ListTasksParams data model.
  • packages/genui_a2ui/lib/src/a2a/core/list_tasks_params.freezed.dart
    • Added generated file for ListTasksParams.
  • packages/genui_a2ui/lib/src/a2a/core/list_tasks_params.g.dart
    • Added generated file for ListTasksParams.
  • packages/genui_a2ui/lib/src/a2a/core/list_tasks_result.dart
    • Added new file defining the ListTasksResult data model.
  • packages/genui_a2ui/lib/src/a2a/core/list_tasks_result.freezed.dart
    • Added generated file for ListTasksResult.
  • packages/genui_a2ui/lib/src/a2a/core/list_tasks_result.g.dart
    • Added generated file for ListTasksResult.
  • packages/genui_a2ui/lib/src/a2a/core/message.dart
    • Added new file defining the Message and Role data models.
  • packages/genui_a2ui/lib/src/a2a/core/message.freezed.dart
    • Added generated file for Message.
  • packages/genui_a2ui/lib/src/a2a/core/message.g.dart
    • Added generated file for Message.
  • packages/genui_a2ui/lib/src/a2a/core/part.dart
    • Added new file defining the Part sealed class and FileType for message content.
  • packages/genui_a2ui/lib/src/a2a/core/part.freezed.dart
    • Added generated file for Part.
  • packages/genui_a2ui/lib/src/a2a/core/part.g.dart
    • Added generated file for Part.
  • packages/genui_a2ui/lib/src/a2a/core/push_notification.dart
    • Added new file defining PushNotificationConfig, PushNotificationAuthenticationInfo, and TaskPushNotificationConfig data models.
  • packages/genui_a2ui/lib/src/a2a/core/push_notification.freezed.dart
    • Added generated file for push notification data models.
  • packages/genui_a2ui/lib/src/a2a/core/push_notification.g.dart
    • Added generated file for push notification data models.
  • packages/genui_a2ui/lib/src/a2a/core/security_scheme.dart
    • Added new file defining the SecurityScheme sealed class, OAuthFlows, and OAuthFlow data models.
  • packages/genui_a2ui/lib/src/a2a/core/security_scheme.freezed.dart
    • Added generated file for security scheme data models.
  • packages/genui_a2ui/lib/src/a2a/core/security_scheme.g.dart
    • Added generated file for security scheme data models.
  • packages/genui_a2ui/lib/src/a2a/core/task.dart
    • Added new file defining the Task, TaskStatus, TaskState, and Artifact data models.
  • packages/genui_a2ui/lib/src/a2a/core/task.freezed.dart
    • Added generated file for task data models.
  • packages/genui_a2ui/lib/src/a2a/core/task.g.dart
    • Added generated file for task data models.
  • packages/genui_a2ui/lib/src/a2ui_agent_connector.dart
    • Updated imports to use the new local A2A library.
    • Modified A2uiAgentConnector constructor to instantiate A2AClient with SseTransport and A2A extensions.
    • Simplified getAgentCard to directly return the new AgentCard object.
    • Refactored connectAndSend to use the new Message and Part data models and handle Event types from the stream.
    • Updated sendEvent to use the new Message and Part data models for sending client events.
  • packages/genui_a2ui/pubspec.yaml
    • Removed a2a dependency.
    • Added freezed_annotation, http, json_annotation, sse_channel as dependencies.
    • Added build_runner, dart_flutter_team_lints, freezed, json_serializable, lints as dev dependencies.
  • packages/genui_a2ui/test/a2a/client/a2a_client_compliance_test.dart
    • Added new test file to verify compliance of the new A2A client with A2A specification.
  • packages/genui_a2ui/test/a2a/client/a2a_client_test.dart
    • Added new test file for comprehensive testing of the new A2A client functionality.
  • packages/genui_a2ui/test/a2a/client/http_transport_test.dart
    • Added new test file for testing the HttpTransport implementation.
  • packages/genui_a2ui/test/a2a/client/sse_transport_test.dart
    • Added new test file for testing the SseTransport implementation, including multi-line data, comments, and error handling.
  • packages/genui_a2ui/test/a2a/core/agent_card_test.dart
    • Added new test file for AgentCard serialization and deserialization.
  • packages/genui_a2ui/test/a2a/core/data_models_test.dart
    • Added new test file for serialization and deserialization of various A2A data models.
  • packages/genui_a2ui/test/a2a/example_test.dart
    • Added a new example test demonstrating client-server interaction with the new A2A library.
  • packages/genui_a2ui/test/a2a/fake_transport.dart
    • Added new fake Transport implementation for testing purposes.
  • packages/genui_a2ui/test/a2a/fakes.dart
    • Added new fake HttpClient and Transport implementations for testing.
  • packages/genui_a2ui/test/a2ui_agent_connector_test.dart
    • Updated imports to use the new local A2A library.
    • Modified tests to reflect changes in A2uiAgentConnector and the new A2A client data models.
  • packages/genui_a2ui/test/a2ui_content_generator_test.dart
    • Updated imports and tests to align with the new local A2A library and data models.
  • packages/genui_a2ui/test/fakes.dart
    • Updated FakeA2AClient to conform to the new local A2A library interface and data models.
    • Updated FakeA2uiAgentConnector to return the new AgentCard object.
  • pubspec.lock
    • Updated package versions and hashes to reflect new dependencies and changes.
  • pubspec.yaml
    • Updated workspace paths to include various example projects.
  • tool/test_and_fix/GEMINI.md
    • Added a note clarifying that the test_and_fix tool is intended for pre-commit checks rather than specific test runs.

gemini-code-assist[bot]

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@flutter flutter deleted a comment from gemini-code-assist bot Dec 19, 2025
Copy link
Collaborator

@andrewkolos andrewkolos left a 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 🤷

@andrewkolos
Copy link
Collaborator

andrewkolos commented Dec 19, 2025

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 A2AMCPBridge and A2AMCServer (and whatever else a2a depends on but isn't exported by mcp_server on web) that are conditionally-imported on web while waiting on a fix for shamblett/a2a#65.

@gspencergoog
Copy link
Collaborator Author

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 🤷

I was able to get verdure to run, and also the example app in genui_a2ui to run with the restaurant_finder server in the a2ui repo.

@gspencergoog
Copy link
Collaborator Author

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 A2AMCPBridge and A2AMCServer (and whatever else a2a depends on but isn't exported by mcp_server on web) that are conditionally-imported on web while waiting on a fix for shamblett/a2a#65.

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.

@gspencergoog
Copy link
Collaborator Author

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.

@gspencergoog gspencergoog merged commit ab584f9 into flutter:main Dec 20, 2025
36 checks passed
csells pushed a commit to csells/flutter_genui that referenced this pull request Dec 22, 2025
csells pushed a commit to csells/flutter_genui that referenced this pull request Dec 22, 2025
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.

mcp_dart 1.1.1 causes compiler crashes on Flutter Web.

2 participants