mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-31 15:53:31 +00:00
refactor: unify typing dispatch lifecycle and policy boundaries
This commit is contained in:
@@ -90,6 +90,24 @@ describe("handleFeishuMessage command authorization", () => {
|
||||
const mockDispatchReplyFromConfig = vi
|
||||
.fn()
|
||||
.mockResolvedValue({ queuedFinal: false, counts: { final: 1 } });
|
||||
const mockWithReplyDispatcher = vi.fn(
|
||||
async ({
|
||||
dispatcher,
|
||||
run,
|
||||
onSettled,
|
||||
}: Parameters<PluginRuntime["channel"]["reply"]["withReplyDispatcher"]>[0]) => {
|
||||
try {
|
||||
return await run();
|
||||
} finally {
|
||||
dispatcher.markComplete();
|
||||
try {
|
||||
await dispatcher.waitForIdle();
|
||||
} finally {
|
||||
await onSettled?.();
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
const mockResolveCommandAuthorizedFromAuthorizers = vi.fn(() => false);
|
||||
const mockShouldComputeCommandAuthorized = vi.fn(() => true);
|
||||
const mockReadAllowFromStore = vi.fn().mockResolvedValue([]);
|
||||
@@ -127,6 +145,7 @@ describe("handleFeishuMessage command authorization", () => {
|
||||
formatAgentEnvelope: vi.fn((params: { body: string }) => params.body),
|
||||
finalizeInboundContext: mockFinalizeInboundContext,
|
||||
dispatchReplyFromConfig: mockDispatchReplyFromConfig,
|
||||
withReplyDispatcher: mockWithReplyDispatcher,
|
||||
},
|
||||
commands: {
|
||||
shouldComputeCommandAuthorized: mockShouldComputeCommandAuthorized,
|
||||
|
||||
Reference in New Issue
Block a user