mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 02:00:42 +00:00
test: remove final async placeholders
This commit is contained in:
@@ -13,37 +13,13 @@ import { patchPluginSessionExtension } from "../plugins/host-hook-state.js";
|
||||
import { createEmptyPluginRegistry } from "../plugins/registry.js";
|
||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import type { PluginHookRegistration } from "../plugins/types.js";
|
||||
|
||||
type ToolDefinitionAdapterModule = typeof import("./pi-tool-definition-adapter.js");
|
||||
type PiToolsAbortModule = typeof import("./pi-tools.abort.js");
|
||||
type BeforeToolCallModule = typeof import("./pi-tools.before-tool-call.js");
|
||||
|
||||
type ToClientToolDefinitions = ToolDefinitionAdapterModule["toClientToolDefinitions"];
|
||||
type ToToolDefinitions = ToolDefinitionAdapterModule["toToolDefinitions"];
|
||||
type WrapToolWithAbortSignal = PiToolsAbortModule["wrapToolWithAbortSignal"];
|
||||
type BeforeToolCallTesting = BeforeToolCallModule["__testing"];
|
||||
type ConsumeAdjustedParamsForToolCall = BeforeToolCallModule["consumeAdjustedParamsForToolCall"];
|
||||
type WrapToolWithBeforeToolCallHook = BeforeToolCallModule["wrapToolWithBeforeToolCallHook"];
|
||||
|
||||
let toClientToolDefinitions!: ToClientToolDefinitions;
|
||||
let toToolDefinitions!: ToToolDefinitions;
|
||||
let wrapToolWithAbortSignal!: WrapToolWithAbortSignal;
|
||||
let beforeToolCallTesting!: BeforeToolCallTesting;
|
||||
let consumeAdjustedParamsForToolCall!: ConsumeAdjustedParamsForToolCall;
|
||||
let wrapToolWithBeforeToolCallHook!: WrapToolWithBeforeToolCallHook;
|
||||
|
||||
beforeEach(async () => {
|
||||
if (!wrapToolWithBeforeToolCallHook) {
|
||||
({ toClientToolDefinitions, toToolDefinitions } =
|
||||
await import("./pi-tool-definition-adapter.js"));
|
||||
({ wrapToolWithAbortSignal } = await import("./pi-tools.abort.js"));
|
||||
({
|
||||
__testing: beforeToolCallTesting,
|
||||
consumeAdjustedParamsForToolCall,
|
||||
wrapToolWithBeforeToolCallHook,
|
||||
} = await import("./pi-tools.before-tool-call.js"));
|
||||
}
|
||||
});
|
||||
import { toClientToolDefinitions, toToolDefinitions } from "./pi-tool-definition-adapter.js";
|
||||
import { wrapToolWithAbortSignal } from "./pi-tools.abort.js";
|
||||
import {
|
||||
__testing as beforeToolCallTesting,
|
||||
consumeAdjustedParamsForToolCall,
|
||||
wrapToolWithBeforeToolCallHook,
|
||||
} from "./pi-tools.before-tool-call.js";
|
||||
|
||||
type BeforeToolCallHandlerMock = ReturnType<typeof vi.fn>;
|
||||
|
||||
|
||||
@@ -92,11 +92,20 @@ vi.mock("./reply/agent-runner.runtime.js", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
let getReplyFromConfig!: GetReplyFromConfig;
|
||||
let capturedGetReplyFromConfig: GetReplyFromConfig | undefined;
|
||||
installTriggerHandlingReplyHarness((impl) => {
|
||||
getReplyFromConfig = impl;
|
||||
capturedGetReplyFromConfig = impl;
|
||||
});
|
||||
|
||||
function getReplyFromConfig(
|
||||
...args: Parameters<GetReplyFromConfig>
|
||||
): ReturnType<GetReplyFromConfig> {
|
||||
if (!capturedGetReplyFromConfig) {
|
||||
throw new Error("Expected trigger handling reply harness to install getReplyFromConfig");
|
||||
}
|
||||
return capturedGetReplyFromConfig(...args);
|
||||
}
|
||||
|
||||
const BASE_MESSAGE = {
|
||||
Body: "hello",
|
||||
From: "+1002",
|
||||
|
||||
Reference in New Issue
Block a user