@@ -63,16 +63,26 @@ type TaskRegistryDeliveryRuntime = Pick<
6363 typeof import ( "./task-registry-delivery-runtime.js" ) ,
6464 "sendMessage"
6565> ;
66+ type TaskRegistryControlRuntime = {
67+ getAcpSessionManager : ( ) => Pick <
68+ ReturnType < ( typeof import ( "./task-registry-control.runtime.js" ) ) [ "getAcpSessionManager" ] > ,
69+ "cancelSession"
70+ > ;
71+ killSubagentRunAdmin : ( typeof import ( "./task-registry-control.runtime.js" ) ) [ "killSubagentRunAdmin" ] ;
72+ } ;
6673const TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY = Symbol . for (
6774 "openclaw.taskRegistry.deliveryRuntimeOverride" ,
6875) ;
69- type TaskRegistryGlobalWithDeliveryOverride = typeof globalThis & {
76+ const TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY = Symbol . for (
77+ "openclaw.taskRegistry.controlRuntimeOverride" ,
78+ ) ;
79+ type TaskRegistryGlobalWithRuntimeOverrides = typeof globalThis & {
7080 [ TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY ] ?: TaskRegistryDeliveryRuntime | null ;
81+ [ TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY ] ?: TaskRegistryControlRuntime | null ;
7182} ;
7283let deliveryRuntimePromise : Promise < typeof import ( "./task-registry-delivery-runtime.js" ) > | null =
7384 null ;
74- let controlRuntimePromise : Promise < typeof import ( "./task-registry-control.runtime.js" ) > | null =
75- null ;
85+ let controlRuntimePromise : Promise < TaskRegistryControlRuntime > | null = null ;
7686
7787type TaskDeliveryOwner = {
7888 sessionKey ?: string ;
@@ -368,7 +378,7 @@ function appendTaskEvent(event: {
368378}
369379
370380function loadTaskRegistryDeliveryRuntime ( ) {
371- const deliveryRuntimeOverride = ( globalThis as TaskRegistryGlobalWithDeliveryOverride ) [
381+ const deliveryRuntimeOverride = ( globalThis as TaskRegistryGlobalWithRuntimeOverrides ) [
372382 TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY
373383 ] ;
374384 if ( deliveryRuntimeOverride ) {
@@ -379,6 +389,12 @@ function loadTaskRegistryDeliveryRuntime() {
379389}
380390
381391function loadTaskRegistryControlRuntime ( ) {
392+ const controlRuntimeOverride = ( globalThis as TaskRegistryGlobalWithRuntimeOverrides ) [
393+ TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
394+ ] ;
395+ if ( controlRuntimeOverride ) {
396+ return Promise . resolve ( controlRuntimeOverride ) ;
397+ }
382398 // Registry reads happen far more often than task cancellation, so keep the ACP/subagent
383399 // control graph off the default import path until a cancellation flow actually needs it.
384400 controlRuntimePromise ??= import ( "./task-registry-control.runtime.js" ) ;
@@ -1964,15 +1980,29 @@ export function resetTaskRegistryForTests(opts?: { persist?: boolean }) {
19641980}
19651981
19661982export function resetTaskRegistryDeliveryRuntimeForTests ( ) {
1967- ( globalThis as TaskRegistryGlobalWithDeliveryOverride ) [
1983+ ( globalThis as TaskRegistryGlobalWithRuntimeOverrides ) [
19681984 TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY
19691985 ] = null ;
19701986 deliveryRuntimePromise = null ;
19711987}
19721988
19731989export function setTaskRegistryDeliveryRuntimeForTests ( runtime : TaskRegistryDeliveryRuntime ) : void {
1974- ( globalThis as TaskRegistryGlobalWithDeliveryOverride ) [
1990+ ( globalThis as TaskRegistryGlobalWithRuntimeOverrides ) [
19751991 TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY
19761992 ] = runtime ;
19771993 deliveryRuntimePromise = null ;
19781994}
1995+
1996+ export function resetTaskRegistryControlRuntimeForTests ( ) {
1997+ ( globalThis as TaskRegistryGlobalWithRuntimeOverrides ) [
1998+ TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
1999+ ] = null ;
2000+ controlRuntimePromise = null ;
2001+ }
2002+
2003+ export function setTaskRegistryControlRuntimeForTests ( runtime : TaskRegistryControlRuntime ) : void {
2004+ ( globalThis as TaskRegistryGlobalWithRuntimeOverrides ) [
2005+ TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
2006+ ] = runtime ;
2007+ controlRuntimePromise = null ;
2008+ }
0 commit comments