test: remove final async placeholders

This commit is contained in:
Peter Steinberger
2026-05-08 20:20:07 +01:00
parent 579f091cc4
commit 4016a4f96d
2 changed files with 18 additions and 33 deletions

View File

@@ -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>;

View File

@@ -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",