mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-16 19:30:43 +00:00
* tasks: register detached runtime plugins * tasks: harden detached runtime ownership * tasks: extract detached runtime contract types * changelog: note detached runtime contract * changelog: attribute detached runtime contract
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { vi } from "vitest";
|
|
import { resetDetachedTaskLifecycleRuntimeForTests } from "../../tasks/detached-task-runtime.js";
|
|
import {
|
|
resetTaskRegistryControlRuntimeForTests,
|
|
resetTaskRegistryDeliveryRuntimeForTests,
|
|
resetTaskRegistryForTests,
|
|
setTaskRegistryControlRuntimeForTests,
|
|
setTaskRegistryDeliveryRuntimeForTests,
|
|
} from "../../tasks/runtime-internal.js";
|
|
import { resetTaskFlowRegistryForTests } from "../../tasks/task-flow-runtime-internal.js";
|
|
|
|
const runtimeTaskMocks = vi.hoisted(() => ({
|
|
sendMessageMock: vi.fn(),
|
|
cancelSessionMock: vi.fn(),
|
|
killSubagentRunAdminMock: vi.fn(),
|
|
}));
|
|
|
|
export function getRuntimeTaskMocks() {
|
|
return runtimeTaskMocks;
|
|
}
|
|
|
|
export function installRuntimeTaskDeliveryMock(): void {
|
|
setTaskRegistryDeliveryRuntimeForTests({
|
|
sendMessage: runtimeTaskMocks.sendMessageMock,
|
|
});
|
|
setTaskRegistryControlRuntimeForTests({
|
|
getAcpSessionManager: () => ({
|
|
cancelSession: runtimeTaskMocks.cancelSessionMock,
|
|
}),
|
|
killSubagentRunAdmin: (params: unknown) => runtimeTaskMocks.killSubagentRunAdminMock(params),
|
|
});
|
|
}
|
|
|
|
export function resetRuntimeTaskTestState(
|
|
taskRegistryOptions?: Parameters<typeof resetTaskRegistryForTests>[0],
|
|
): void {
|
|
resetDetachedTaskLifecycleRuntimeForTests();
|
|
resetTaskRegistryControlRuntimeForTests();
|
|
resetTaskRegistryDeliveryRuntimeForTests();
|
|
resetTaskRegistryForTests(taskRegistryOptions);
|
|
resetTaskFlowRegistryForTests({ persist: false });
|
|
vi.clearAllMocks();
|
|
}
|