@@ -6,44 +6,26 @@ import { getGlobalHookRunner } from "../../plugins/hook-runner-global.js";
66import { isAcpSessionKey , resolveAgentIdFromSessionKey } from "../../routing/session-key.js" ;
77import { resolveSendPolicy } from "../../sessions/send-policy.js" ;
88import { shouldHandleTextCommands } from "../commands-registry.js" ;
9- import { handleAcpCommand } from "./commands-acp.js" ;
109import { resolveBoundAcpThreadSessionKey } from "./commands-acp/targets.js" ;
11- import { handleAllowlistCommand } from "./commands-allowlist.js" ;
12- import { handleApproveCommand } from "./commands-approve.js" ;
13- import { handleBashCommand } from "./commands-bash.js" ;
14- import { handleBtwCommand } from "./commands-btw.js" ;
15- import { handleCompactCommand } from "./commands-compact.js" ;
16- import { handleConfigCommand , handleDebugCommand } from "./commands-config.js" ;
17- import {
18- handleCommandsListCommand ,
19- handleContextCommand ,
20- handleExportSessionCommand ,
21- handleHelpCommand ,
22- handleStatusCommand ,
23- handleWhoamiCommand ,
24- } from "./commands-info.js" ;
25- import { handleMcpCommand } from "./commands-mcp.js" ;
26- import { handleModelsCommand } from "./commands-models.js" ;
27- import { handlePluginCommand } from "./commands-plugin.js" ;
28- import { handlePluginsCommand } from "./commands-plugins.js" ;
29- import {
30- handleAbortTrigger ,
31- handleActivationCommand ,
32- handleFastCommand ,
33- handleRestartCommand ,
34- handleSessionCommand ,
35- handleSendPolicyCommand ,
36- handleStopCommand ,
37- handleUsageCommand ,
38- } from "./commands-session.js" ;
39- import { handleSubagentsCommand } from "./commands-subagents.js" ;
40- import { handleTtsCommands } from "./commands-tts.js" ;
4110import type {
4211 CommandHandler ,
4312 CommandHandlerResult ,
4413 HandleCommandsParams ,
4514} from "./commands-types.js" ;
46- import { routeReply } from "./route-reply.js" ;
15+
16+ let routeReplyRuntimePromise : Promise < typeof import ( "./route-reply.runtime.js" ) > | null = null ;
17+ let commandHandlersRuntimePromise : Promise < typeof import ( "./commands-handlers.runtime.js" ) > | null =
18+ null ;
19+
20+ function loadRouteReplyRuntime ( ) {
21+ routeReplyRuntimePromise ??= import ( "./route-reply.runtime.js" ) ;
22+ return routeReplyRuntimePromise ;
23+ }
24+
25+ function loadCommandHandlersRuntime ( ) {
26+ commandHandlersRuntimePromise ??= import ( "./commands-handlers.runtime.js" ) ;
27+ return commandHandlersRuntimePromise ;
28+ }
4729
4830let HANDLERS : CommandHandler [ ] | null = null ;
4931
@@ -82,6 +64,7 @@ export async function emitResetCommandHooks(params: {
8264 const to = params . ctx . OriginatingTo || params . command . from || params . command . to ;
8365
8466 if ( channel && to ) {
67+ const { routeReply } = await loadRouteReplyRuntime ( ) ;
8568 const hookReply = { text : hookEvent . messages . join ( "\n\n" ) } ;
8669 await routeReply ( {
8770 payload : hookReply ,
@@ -174,37 +157,7 @@ function resolveSessionEntryForHookSessionKey(
174157
175158export async function handleCommands ( params : HandleCommandsParams ) : Promise < CommandHandlerResult > {
176159 if ( HANDLERS === null ) {
177- HANDLERS = [
178- // Plugin commands are processed first, before built-in commands
179- handlePluginCommand ,
180- handleBtwCommand ,
181- handleBashCommand ,
182- handleActivationCommand ,
183- handleSendPolicyCommand ,
184- handleFastCommand ,
185- handleUsageCommand ,
186- handleSessionCommand ,
187- handleRestartCommand ,
188- handleTtsCommands ,
189- handleHelpCommand ,
190- handleCommandsListCommand ,
191- handleStatusCommand ,
192- handleAllowlistCommand ,
193- handleApproveCommand ,
194- handleContextCommand ,
195- handleExportSessionCommand ,
196- handleWhoamiCommand ,
197- handleSubagentsCommand ,
198- handleAcpCommand ,
199- handleMcpCommand ,
200- handlePluginsCommand ,
201- handleConfigCommand ,
202- handleDebugCommand ,
203- handleModelsCommand ,
204- handleStopCommand ,
205- handleCompactCommand ,
206- handleAbortTrigger ,
207- ] ;
160+ HANDLERS = ( await loadCommandHandlersRuntime ( ) ) . loadCommandHandlers ( ) ;
208161 }
209162 const resetMatch = params . command . commandBodyNormalized . match ( / ^ \/ ( n e w | r e s e t ) (?: \s | $ ) / ) ;
210163 const resetRequested = Boolean ( resetMatch ) ;
0 commit comments