feat: add AgentController support to standalone Runner#413
Conversation
The standalone Runner bypasses egg plugin lifecycle, so AgentControllerProto/Object registration needs to be done manually, similar to how it's done in the controller plugin's app.ts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, 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 enhances the @eggjs/tegg-standalone package by integrating AgentController support directly into its Runner component. This crucial update allows applications utilizing @AgentController decorators to operate seamlessly in a standalone environment, independent of the full Egg.js plugin lifecycle. The change ensures greater flexibility and feature parity for standalone deployments. Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe pull request adds egg framework controller plugin support by introducing two new dependencies ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can disable the changed files summary in the walkthrough.Disable the |
There was a problem hiding this comment.
Code Review
This pull request adds support for @AgentController in the standalone Runner. This is achieved by adding the necessary dependencies and registering the prototype creator and object factory for agent controllers. The changes are logical and follow the intended goal. However, I've identified a couple of areas for improvement: one is a maintainability issue in package.json regarding dependency sorting, and the other is a more significant correctness concern in Runner.ts where a type assertion as any is used to pass a logger of an incompatible type, which could lead to runtime errors.
| // AgentController support | ||
| EggPrototypeCreatorFactory.registerPrototypeCreator( | ||
| AGENT_CONTROLLER_PROTO_IMPL_TYPE, AgentControllerProto.createProto); | ||
| AgentControllerObject.setLogger(logger as any); |
There was a problem hiding this comment.
The type assertion as any hides a potential type mismatch and should be avoided. The logger variable is of type Logger (from @eggjs/tegg) or console, but AgentControllerObject.setLogger expects an EggLogger (from egg). This could lead to runtime errors if agent-runtime (which receives this logger) calls methods specific to EggLogger that are not present on the provided logger object. Please resolve this type incompatibility properly instead of suppressing the type error.
| "@eggjs/tegg-dynamic-inject-runtime": "^3.72.0", | ||
| "@eggjs/tegg-lifecycle": "^3.72.0", | ||
| "@eggjs/tegg-loader": "^3.72.0", | ||
| "@eggjs/tegg-controller-plugin": "^3.72.0", |
Summary
AgentControllerProto.createProtoandAgentControllerObject.createObjectin the standaloneRunnerconstructor, mirroring the registration done in@eggjs/tegg-controller-plugin/app.ts@eggjs/tegg-controller-pluginand@eggjs/tegg-typesas dependencies of@eggjs/tegg-standalone@AgentControllerdecorated classes to work in standalone mode (without the egg plugin lifecycle)Test plan
@AgentControllerclass and confirm it initializes correctly🤖 Generated with Claude Code
Summary by CodeRabbit