diff --git a/src/agents/pi-tools.before-tool-call.integration.e2e.test.ts b/src/agents/pi-tools.before-tool-call.integration.e2e.test.ts index 9e48728fb9d..be7233891b6 100644 --- a/src/agents/pi-tools.before-tool-call.integration.e2e.test.ts +++ b/src/agents/pi-tools.before-tool-call.integration.e2e.test.ts @@ -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; diff --git a/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts b/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts index 8486273dc8c..3e8e4dc9162 100644 --- a/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts +++ b/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts @@ -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 +): ReturnType { + if (!capturedGetReplyFromConfig) { + throw new Error("Expected trigger handling reply harness to install getReplyFromConfig"); + } + return capturedGetReplyFromConfig(...args); +} + const BASE_MESSAGE = { Body: "hello", From: "+1002",