mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
fix(tasks): narrow control runtime override type
This commit is contained in:
@@ -63,24 +63,26 @@ type TaskRegistryDeliveryRuntime = Pick<
|
||||
typeof import("./task-registry-delivery-runtime.js"),
|
||||
"sendMessage"
|
||||
>;
|
||||
type TaskRegistryControlRuntime = Pick<
|
||||
typeof import("./task-registry-control.runtime.js"),
|
||||
"getAcpSessionManager" | "killSubagentRunAdmin"
|
||||
>;
|
||||
type TaskRegistryControlRuntime = {
|
||||
getAcpSessionManager: () => Pick<
|
||||
ReturnType<(typeof import("./task-registry-control.runtime.js"))["getAcpSessionManager"]>,
|
||||
"cancelSession"
|
||||
>;
|
||||
killSubagentRunAdmin: (typeof import("./task-registry-control.runtime.js"))["killSubagentRunAdmin"];
|
||||
};
|
||||
const TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY = Symbol.for(
|
||||
"openclaw.taskRegistry.deliveryRuntimeOverride",
|
||||
);
|
||||
const TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY = Symbol.for(
|
||||
"openclaw.taskRegistry.controlRuntimeOverride",
|
||||
);
|
||||
type TaskRegistryGlobalWithDeliveryOverride = typeof globalThis & {
|
||||
type TaskRegistryGlobalWithRuntimeOverrides = typeof globalThis & {
|
||||
[TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY]?: TaskRegistryDeliveryRuntime | null;
|
||||
[TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY]?: TaskRegistryControlRuntime | null;
|
||||
};
|
||||
let deliveryRuntimePromise: Promise<typeof import("./task-registry-delivery-runtime.js")> | null =
|
||||
null;
|
||||
let controlRuntimePromise: Promise<typeof import("./task-registry-control.runtime.js")> | null =
|
||||
null;
|
||||
let controlRuntimePromise: Promise<TaskRegistryControlRuntime> | null = null;
|
||||
|
||||
type TaskDeliveryOwner = {
|
||||
sessionKey?: string;
|
||||
@@ -376,7 +378,7 @@ function appendTaskEvent(event: {
|
||||
}
|
||||
|
||||
function loadTaskRegistryDeliveryRuntime() {
|
||||
const deliveryRuntimeOverride = (globalThis as TaskRegistryGlobalWithDeliveryOverride)[
|
||||
const deliveryRuntimeOverride = (globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
|
||||
TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY
|
||||
];
|
||||
if (deliveryRuntimeOverride) {
|
||||
@@ -387,7 +389,7 @@ function loadTaskRegistryDeliveryRuntime() {
|
||||
}
|
||||
|
||||
function loadTaskRegistryControlRuntime() {
|
||||
const controlRuntimeOverride = (globalThis as TaskRegistryGlobalWithDeliveryOverride)[
|
||||
const controlRuntimeOverride = (globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
|
||||
TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
|
||||
];
|
||||
if (controlRuntimeOverride) {
|
||||
@@ -1978,28 +1980,28 @@ export function resetTaskRegistryForTests(opts?: { persist?: boolean }) {
|
||||
}
|
||||
|
||||
export function resetTaskRegistryDeliveryRuntimeForTests() {
|
||||
(globalThis as TaskRegistryGlobalWithDeliveryOverride)[
|
||||
(globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
|
||||
TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY
|
||||
] = null;
|
||||
deliveryRuntimePromise = null;
|
||||
}
|
||||
|
||||
export function setTaskRegistryDeliveryRuntimeForTests(runtime: TaskRegistryDeliveryRuntime): void {
|
||||
(globalThis as TaskRegistryGlobalWithDeliveryOverride)[
|
||||
(globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
|
||||
TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY
|
||||
] = runtime;
|
||||
deliveryRuntimePromise = null;
|
||||
}
|
||||
|
||||
export function resetTaskRegistryControlRuntimeForTests() {
|
||||
(globalThis as TaskRegistryGlobalWithDeliveryOverride)[
|
||||
(globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
|
||||
TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
|
||||
] = null;
|
||||
controlRuntimePromise = null;
|
||||
}
|
||||
|
||||
export function setTaskRegistryControlRuntimeForTests(runtime: TaskRegistryControlRuntime): void {
|
||||
(globalThis as TaskRegistryGlobalWithDeliveryOverride)[
|
||||
(globalThis as TaskRegistryGlobalWithRuntimeOverrides)[
|
||||
TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY
|
||||
] = runtime;
|
||||
controlRuntimePromise = null;
|
||||
|
||||
Reference in New Issue
Block a user