@@ -63,11 +63,19 @@ type TaskRegistryDeliveryRuntime = Pick<
6363 typeof import ( "./task-registry-delivery-runtime.js" ) ,
6464 "sendMessage"
6565> ;
66+ type TaskRegistryControlRuntime = Pick <
67+ typeof import ( "./task-registry-control.runtime.js" ) ,
68+ "getAcpSessionManager" | "killSubagentRunAdmin"
69+ > ;
6670const TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY = Symbol . for (
6771 "openclaw.taskRegistry.deliveryRuntimeOverride" ,
6872) ;
73+ const TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY = Symbol . for (
74+ "openclaw.taskRegistry.controlRuntimeOverride" ,
75+ ) ;
6976type TaskRegistryGlobalWithDeliveryOverride = typeof globalThis & {
7077 [ TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY ] ?: TaskRegistryDeliveryRuntime | null ;
78+ [ TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY ] ?: TaskRegistryControlRuntime | null ;
7179} ;
7280let deliveryRuntimePromise : Promise < typeof import ( "./task-registry-delivery-runtime.js" ) > | null =
7381 null ;
@@ -379,6 +387,12 @@ function loadTaskRegistryDeliveryRuntime() {
379387}
380388
381389function loadTaskRegistryControlRuntime ( ) {
390+ const controlRuntimeOverride = ( globalThis as TaskRegistryGlobalWithDeliveryOverride ) [
391+ TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
392+ ] ;
393+ if ( controlRuntimeOverride ) {
394+ return Promise . resolve ( controlRuntimeOverride ) ;
395+ }
382396 // Registry reads happen far more often than task cancellation, so keep the ACP/subagent
383397 // control graph off the default import path until a cancellation flow actually needs it.
384398 controlRuntimePromise ??= import ( "./task-registry-control.runtime.js" ) ;
@@ -1976,3 +1990,17 @@ export function setTaskRegistryDeliveryRuntimeForTests(runtime: TaskRegistryDeli
19761990 ] = runtime ;
19771991 deliveryRuntimePromise = null ;
19781992}
1993+
1994+ export function resetTaskRegistryControlRuntimeForTests ( ) {
1995+ ( globalThis as TaskRegistryGlobalWithDeliveryOverride ) [
1996+ TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
1997+ ] = null ;
1998+ controlRuntimePromise = null ;
1999+ }
2000+
2001+ export function setTaskRegistryControlRuntimeForTests ( runtime : TaskRegistryControlRuntime ) : void {
2002+ ( globalThis as TaskRegistryGlobalWithDeliveryOverride ) [
2003+ TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
2004+ ] = runtime ;
2005+ controlRuntimePromise = null ;
2006+ }
0 commit comments