Skip to content

Commit 68fcd85

Browse files
committed
fix(tasks): narrow control runtime override type
1 parent a866c51 commit 68fcd85

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

src/tasks/task-registry.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,26 @@ 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-
>;
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+
};
7073
const TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY = Symbol.for(
7174
"openclaw.taskRegistry.deliveryRuntimeOverride",
7275
);
7376
const TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY = Symbol.for(
7477
"openclaw.taskRegistry.controlRuntimeOverride",
7578
);
76-
type TaskRegistryGlobalWithDeliveryOverride = typeof globalThis & {
79+
type TaskRegistryGlobalWithRuntimeOverrides = typeof globalThis & {
7780
[TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY]?: TaskRegistryDeliveryRuntime | null;
7881
[TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY]?: TaskRegistryControlRuntime | null;
7982
};
8083
let deliveryRuntimePromise: Promise<typeof import("./task-registry-delivery-runtime.js")> | null =
8184
null;
82-
let controlRuntimePromise: Promise<typeof import("./task-registry-control.runtime.js")> | null =
83-
null;
85+
let controlRuntimePromise: Promise<TaskRegistryControlRuntime> | null = null;
8486

8587
type TaskDeliveryOwner = {
8688
sessionKey?: string;
@@ -376,7 +378,7 @@ function appendTaskEvent(event: {
376378
}
377379

378380
function loadTaskRegistryDeliveryRuntime() {
379-
const deliveryRuntimeOverride = (globalThis as TaskRegistryGlobalWithDeliveryOverride)[
381+
const deliveryRuntimeOverride = (globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
380382
TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY
381383
];
382384
if (deliveryRuntimeOverride) {
@@ -387,7 +389,7 @@ function loadTaskRegistryDeliveryRuntime() {
387389
}
388390

389391
function loadTaskRegistryControlRuntime() {
390-
const controlRuntimeOverride = (globalThis as TaskRegistryGlobalWithDeliveryOverride)[
392+
const controlRuntimeOverride = (globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
391393
TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
392394
];
393395
if (controlRuntimeOverride) {
@@ -1978,28 +1980,28 @@ export function resetTaskRegistryForTests(opts?: { persist?: boolean }) {
19781980
}
19791981

19801982
export function resetTaskRegistryDeliveryRuntimeForTests() {
1981-
(globalThis as TaskRegistryGlobalWithDeliveryOverride)[
1983+
(globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
19821984
TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY
19831985
] = null;
19841986
deliveryRuntimePromise = null;
19851987
}
19861988

19871989
export function setTaskRegistryDeliveryRuntimeForTests(runtime: TaskRegistryDeliveryRuntime): void {
1988-
(globalThis as TaskRegistryGlobalWithDeliveryOverride)[
1990+
(globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
19891991
TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY
19901992
] = runtime;
19911993
deliveryRuntimePromise = null;
19921994
}
19931995

19941996
export function resetTaskRegistryControlRuntimeForTests() {
1995-
(globalThis as TaskRegistryGlobalWithDeliveryOverride)[
1997+
(globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
19961998
TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
19971999
] = null;
19982000
controlRuntimePromise = null;
19992001
}
20002002

20012003
export function setTaskRegistryControlRuntimeForTests(runtime: TaskRegistryControlRuntime): void {
2002-
(globalThis as TaskRegistryGlobalWithDeliveryOverride)[
2004+
(globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
20032005
TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
20042006
] = runtime;
20052007
controlRuntimePromise = null;

0 commit comments

Comments
 (0)