From 6281827070a1afdae746e50d656249a7c91c280c Mon Sep 17 00:00:00 2001 From: jerry Date: Thu, 19 Mar 2026 11:09:57 +0800 Subject: [PATCH] feat: add AgentController support to standalone Runner 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 --- tegg/standalone/standalone/package.json | 1 + tegg/standalone/standalone/src/Runner.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tegg/standalone/standalone/package.json b/tegg/standalone/standalone/package.json index 5c8b757cbd..0c5b7f32ba 100644 --- a/tegg/standalone/standalone/package.json +++ b/tegg/standalone/standalone/package.json @@ -44,6 +44,7 @@ }, "dependencies": { "@eggjs/aop-runtime": "workspace:*", + "@eggjs/controller-plugin": "workspace:*", "@eggjs/dal-plugin": "workspace:*", "@eggjs/lifecycle": "workspace:*", "@eggjs/metadata": "workspace:*", diff --git a/tegg/standalone/standalone/src/Runner.ts b/tegg/standalone/standalone/src/Runner.ts index cdb63ed797..d7cf0ed4cc 100644 --- a/tegg/standalone/standalone/src/Runner.ts +++ b/tegg/standalone/standalone/src/Runner.ts @@ -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', + AgentControllerProto.createProto, + ); + EggObjectFactory.registerEggObjectCreateMethod( + AgentControllerProto, + AgentControllerObject.createObject, + ); + AgentControllerObject.setLogger(logger as any); } async init(): Promise {