-
Notifications
You must be signed in to change notification settings - Fork 107
feat!: make Express dependency optional for edge environment compatibility #71
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
feat!: make Express dependency optional for edge environment compatibility #71
Conversation
- Move A2AExpressApp to separate module at server/express/ - Remove A2AExpressApp from main server exports to avoid forcing Express import - Move express, cors, and body-parser to peerDependencies and devDependencies - Add new package.json export for ./server/express - Update import statements in samples and documentation - Enables usage in Cloudflare Workers, Vercel Edge, and other non-Node environments Fixes #[issue-number] - Express dependency breaks edge environments
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.
Summary of Changes
Hello @ajaynagotha, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses a critical compatibility issue by refactoring the A2A SDK to make its Express.js integration optional. This change significantly improves the SDK's flexibility, allowing it to be deployed in resource-constrained edge environments like Cloudflare Workers and Vercel Edge, while maintaining full functionality for traditional Node.js users. It achieves this by modularizing the Express-specific components and adjusting dependency management.
Highlights
- Dependency Modularization: The
A2AExpressAppcomponent, along with its Express.js, CORS, and body-parser dependencies, has been extracted into a separate, optional module (src/server/express/). - Dependency Management: Express.js and related packages are now listed as
peerDependenciesanddevDependenciesinstead of harddependencies, making them optional for users who don't require Express integration. - Package Exports: A new package export path (
./server/express) has been added topackage.json, allowing consumers to explicitly import the Express integration only when needed. - Edge Environment Compatibility: This change resolves a critical issue preventing the SDK from being used in non-Node.js edge environments (e.g., Cloudflare Workers, Vercel Edge) by removing the mandatory Express dependency.
- Codebase Updates: Sample code and documentation (README) have been updated to reflect the new import paths for
A2AExpressApp, guiding users on how to adopt the modularized approach.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request effectively decouples the Express.js dependency, enabling the SDK to be used in edge environments. The changes are well-structured, moving Express-specific code into a separate module and updating dependencies to be peerDependencies.
My review includes a high-severity comment regarding the breaking nature of these changes and how it should be reflected in the conventional commit message for proper versioning. I've also added a couple of medium-severity comments about code style to ensure consistency.
Overall, great work on making the SDK more modular and versatile!
|
package-lock.json file is not pushed because it will create conflicts. let me know |
Resolve linting issues Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
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.
Code Review
This pull request modularizes the Express.js dependency, improving compatibility with edge environments. The changes to package.json and module exports are well-structured, and the documentation has been updated. The feedback focuses on refining the package dependencies to ensure that users are not required to install unnecessary packages, aligning with the goal of making the SDK more lightweight and modular.
- Remove cors and body-parser from both devDependencies and peerDependencies - A2AExpressApp uses express.json() which is built into Express, making body-parser unnecessary - cors is an application-level concern that developers should add to their Express app if needed - These dependencies were forcing unnecessary installations for package consumers - Only express remains as a peerDependency, accurately reflecting actual requirements
…ajaynagotha/a2a-js into fix-optional-express-dependency
|
/gemini review |
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.
Code Review
This pull request effectively decouples the Express.js dependency, enabling the SDK to be used in edge environments. The changes are well-structured, moving Express-specific code into a separate, optional module. My review focuses on ensuring consistency between the implementation and the detailed pull request description, particularly regarding dependency management in package.json. I've also included a couple of minor suggestions to adhere to file formatting best practices.
Fix liniting issues Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Fix linting issues Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
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.
Code Review
This pull request effectively makes the Express dependency optional, which is a great step towards compatibility with edge environments. The refactoring is clean, moving Express-specific code into a separate, optional module. The changes to package.json are correct, and the documentation updates are clear. Adding peerDependenciesMeta to package.json to prevent installation warnings for users who don't need Express would complete the goal of making it truly optional from a developer experience perspective.
Add peerDependenciesMeta to mark express as optional, preventing package manager warnings when express is not installed. This improves developer experience for users in non-Node/edge environments where express is not needed.
…ajaynagotha/a2a-js into fix-optional-express-dependency
|
/gemini review |
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.
Code Review
This pull request makes the Express dependency optional, which enables the SDK to be used in edge environments. The changes are well-structured, and the PR description is clear. The installation instructions in the README.md should be updated to reflect that express is now a peer dependency.
|
/gemini review |
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.
Code Review
This pull request effectively refactors the project to make the Express.js dependency optional, which is a great improvement for supporting edge environments. The changes are well-structured, moving Express-specific code into a separate module and updating package.json accordingly. The documentation and sample code have also been correctly updated to reflect these changes.
My main concern is with the package versions specified in package.json. Several of the specified versions for express and @types/express do not exist on the public npm registry, which will cause installation failures. I've left specific comments with suggestions for valid versions. Once those are addressed, this PR will be in excellent shape.
|
/gemini summary |
- Add Express peer dependency installation instructions to README - Include note in A2A Server section about Express requirement - Prevents runtime errors when using A2AExpressApp without Express
Summary of ChangesThis pull request significantly refactors the SDK's server-side architecture to enhance compatibility with edge and serverless environments. It achieves this by decoupling the Highlights
Changelog
Activity
|
|
@ajaynagotha this looks great! Hopefully the team can get this merged soon :) Would be great to also add a small example showing how the new approach allows the usage of something like Hono for serving the requests. |
Sure I will try to present code example |
|
@swapydapy Thank you for reviewing and merging this! Getting contributions accepted really motivates me to keep contributing to the project and the community. |
Release-As: 0.3.0
BEGIN_COMMIT_OVERRIDE
feat!: make Express dependency optional
END_COMMIT_OVERRIDE
fix: make Express dependency optional for edge environment compatibility
Summary
Fixes #69 - Express dependency breaks edge environments
Description
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.Fixes #69 🦕
Problem
The A2A SDK had a hard dependency on Express.js that prevented usage in edge environments like Cloudflare Workers, Vercel Edge Runtime, and other platforms that don't support Node.js core APIs.
Issues identified:
A2AExpressAppwas exported from main server module, forcing Express import even when not usedSolution
1. Modularized Express Integration
A2AExpressAppto separatesrc/server/express/modulesrc/server/index.ts"./server/express"2. Cleaned Up Dependencies
{ "dependencies": { "uuid": "^11.1.0" }, "peerDependencies": { "express": "^4.21.2" }, "devDependencies": { "@types/express": "^4.17.23", "express": "^4.21.2" } }Key dependency decisions:
A2AExpressAppA2AExpressAppusesexpress.json()instead3. Updated Package Exports
{ "./server/express": { "types": "./dist/server/express/index.d.ts", "import": "./dist/server/express/index.js", "require": "./dist/server/express/index.cjs" } }Breaking Changes & Migration
Before (❌ Problematic)
After (✅ Clean)
For Express users, install peer dependency:
For users who need CORS support, add it to your Express app:
Benefits
Dependency Analysis
Why body-parser was removed:
A2AExpressAppusesexpress.json()which is built into Express 4.16+body-parserin the codebaseWhy cors was removed:
corsin the codebaseTesting
Files Changed
package.json- Updated exports and cleaned up dependency structuresrc/server/index.ts- RemovedA2AExpressAppexportsrc/server/express/- New modular Express integrationREADME.md- Updated import examplessrc/samples/agents/movie-agent/index.ts- Updated to use new import pathsImpact
This change enables the A2A SDK to be used in:
The dependency cleanup also:
Type: Bug fix
Breaking Change: Minimal (import path only)
SemVer: Patch