-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: add AgentController support to standalone Runner #5837
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
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import { | |
| } from '@eggjs/dal-plugin'; | ||
| import { | ||
| type EggPrototype, | ||
| EggPrototypeCreatorFactory, | ||
| EggPrototypeLifecycleUtil, | ||
| GlobalGraph, | ||
| type LoadUnit, | ||
|
|
@@ -40,6 +41,7 @@ import { | |
| ContextHandler, | ||
| EggContainerFactory, | ||
| type EggContext, | ||
| EggObjectFactory, | ||
| EggObjectLifecycleUtil, | ||
| type LoadUnitInstance, | ||
| LoadUnitInstanceFactory, | ||
|
|
@@ -48,6 +50,9 @@ import { | |
| import { CrosscutAdviceFactory } from '@eggjs/tegg/aop'; | ||
| import { StandaloneUtil, type MainRunner } from '@eggjs/tegg/standalone'; | ||
|
|
||
| import { AgentControllerObject } from '@eggjs/controller-plugin/lib/AgentControllerObject'; | ||
| import { AgentControllerProto } from '@eggjs/controller-plugin/lib/AgentControllerProto'; | ||
|
|
||
| import { ConfigSourceLoadUnitHook } from './ConfigSourceLoadUnitHook.ts'; | ||
| import { EggModuleLoader } from './EggModuleLoader.ts'; | ||
| import { StandaloneContext } from './StandaloneContext.ts'; | ||
|
|
@@ -246,6 +251,17 @@ export class Runner { | |
| EggPrototypeLifecycleUtil.registerLifecycle(this.dalTableEggPrototypeHook); | ||
| EggPrototypeLifecycleUtil.registerLifecycle(this.transactionPrototypeHook); | ||
| LoadUnitLifecycleUtil.registerLifecycle(this.dalModuleLoadUnitHook); | ||
|
|
||
| // AgentController support | ||
| EggPrototypeCreatorFactory.registerPrototypeCreator( | ||
| 'AGENT_CONTROLLER_PROTO', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a magic string like |
||
| AgentControllerProto.createProto, | ||
| ); | ||
| EggObjectFactory.registerEggObjectCreateMethod( | ||
| AgentControllerProto, | ||
| AgentControllerObject.createObject, | ||
| ); | ||
| AgentControllerObject.setLogger(logger as any); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§© Analysis chainπ Web query:
π‘ Result: The EggLogger interface in the Egg.js framework refers to the Logger class provided by the egg-logger module, which is the core logging system for Egg.js applications. It is not a formal TypeScript "interface" but the primary Logger class and its extensions used throughout Egg.js (e.g., app.logger, ctx.logger). Key aspects from official sources: - Logger is the base class from egg-logger that supports multiple Transports (e.g., file, console, custom). - Common methods: debug(msg), info(msg), warn(msg), error(err), supports printf-style formatting (%s, %j, %d). - Additional methods: set(name, transport), disable(name), enable(name), duplicate(target, options), redirect(level, logger). - Levels: NONE, DEBUG, INFO, WARN, ERROR. - Egg.js provides specialized loggers: appLogger (app-web.log), coreLogger (egg-web.log), errorLogger (common-error.log), agentLogger (egg-agent.log). - Custom loggers via config.customLogger. - Accessed as app.logger, ctx.logger, this.logger in controllers/services. Usage example: const Logger = require('egg-logger').Logger; const logger = new Logger; logger.set('console', new require('egg-logger').ConsoleTransport({ level: 'INFO' })); logger.info('Hello %s', 'world'); Egg.js loggers are instances of or wrap this Logger for enterprise features like multi-process safety, log rotation, and JSON output. Citations:
π Script executed: # First, let's examine the Runner.ts file around line 264
fd -t f "Runner.ts" | xargs wc -l | head -20Repository: eggjs/egg Length of output: 172 π Script executed: # Get the specific file path
find . -name "Runner.ts" -path "*/tegg/standalone/*" -type fRepository: eggjs/egg Length of output: 95 π Script executed: # Read the Runner.ts file to understand the context
fd -t f "Runner.ts" -path "*/tegg/standalone/*" | head -1 | xargs cat -n | sed -n '240,280p'Repository: eggjs/egg Length of output: 221 π Script executed: # Find AgentControllerObject and its setLogger method
rg "AgentControllerObject" -A 20 -B 5 | head -50Repository: eggjs/egg Length of output: 3863 π Script executed: # Search for AgentControllerObject class definition and setLogger method
fd -t f "\.ts$" -path "*/tegg/*" | xargs rg "setLogger" -B 3 -A 3Repository: eggjs/egg Length of output: 1702 π Script executed: # Read the Runner.ts constructor to find the logger type definition
cat -n tegg/standalone/standalone/src/Runner.ts | sed -n '230,270p'Repository: eggjs/egg Length of output: 2184 π Script executed: # Find the imports and logger type in Runner.ts
cat -n tegg/standalone/standalone/src/Runner.ts | sed -n '1,50p'Repository: eggjs/egg Length of output: 1547 π Script executed: # Read AgentControllerObject.ts to find EggLogger import
cat -n tegg/plugin/controller/src/lib/AgentControllerObject.ts | sed -n '1,50p'Repository: eggjs/egg Length of output: 2161 π Script executed: # Check for Logger and EggLogger type definitions
rg "type Logger|interface Logger|class Logger" -B 2 -A 5 | head -80Repository: eggjs/egg Length of output: 5588 Remove the
Consider:
π€ Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of |
||
| } | ||
|
|
||
| async init(): Promise<void> { | ||
|
|
||
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.
Importing directly from the
libdirectory of@eggjs/controller-pluginis generally discouraged as it relies on internal implementation details that can change without notice, leading to potential breakages. It would be better to import these from the package's public API if they are exposed, for example:import { AgentControllerObject, AgentControllerProto } from '@eggjs/controller-plugin';. If they are not exported, it might be worth considering exposing them from the plugin package to create a stable API contract.