Skip to content

Commit 6281827

Browse files
jerryliang64claude
andcommitted
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 <noreply@anthropic.com>
1 parent 1980cf1 commit 6281827

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

tegg/standalone/standalone/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
},
4545
"dependencies": {
4646
"@eggjs/aop-runtime": "workspace:*",
47+
"@eggjs/controller-plugin": "workspace:*",
4748
"@eggjs/dal-plugin": "workspace:*",
4849
"@eggjs/lifecycle": "workspace:*",
4950
"@eggjs/metadata": "workspace:*",

tegg/standalone/standalone/src/Runner.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from '@eggjs/dal-plugin';
1616
import {
1717
type EggPrototype,
18+
EggPrototypeCreatorFactory,
1819
EggPrototypeLifecycleUtil,
1920
GlobalGraph,
2021
type LoadUnit,
@@ -40,6 +41,7 @@ import {
4041
ContextHandler,
4142
EggContainerFactory,
4243
type EggContext,
44+
EggObjectFactory,
4345
EggObjectLifecycleUtil,
4446
type LoadUnitInstance,
4547
LoadUnitInstanceFactory,
@@ -48,6 +50,9 @@ import {
4850
import { CrosscutAdviceFactory } from '@eggjs/tegg/aop';
4951
import { StandaloneUtil, type MainRunner } from '@eggjs/tegg/standalone';
5052

53+
import { AgentControllerObject } from '@eggjs/controller-plugin/lib/AgentControllerObject';
54+
import { AgentControllerProto } from '@eggjs/controller-plugin/lib/AgentControllerProto';
55+
5156
import { ConfigSourceLoadUnitHook } from './ConfigSourceLoadUnitHook.ts';
5257
import { EggModuleLoader } from './EggModuleLoader.ts';
5358
import { StandaloneContext } from './StandaloneContext.ts';
@@ -246,6 +251,17 @@ export class Runner {
246251
EggPrototypeLifecycleUtil.registerLifecycle(this.dalTableEggPrototypeHook);
247252
EggPrototypeLifecycleUtil.registerLifecycle(this.transactionPrototypeHook);
248253
LoadUnitLifecycleUtil.registerLifecycle(this.dalModuleLoadUnitHook);
254+
255+
// AgentController support
256+
EggPrototypeCreatorFactory.registerPrototypeCreator(
257+
'AGENT_CONTROLLER_PROTO',
258+
AgentControllerProto.createProto,
259+
);
260+
EggObjectFactory.registerEggObjectCreateMethod(
261+
AgentControllerProto,
262+
AgentControllerObject.createObject,
263+
);
264+
AgentControllerObject.setLogger(logger as any);
249265
}
250266

251267
async init(): Promise<void> {

0 commit comments

Comments
 (0)