diff --git a/src/test-utils/plugin-runtime-env.ts b/src/test-utils/plugin-runtime-env.ts index cb993f567be..f9482fc1d90 100644 --- a/src/test-utils/plugin-runtime-env.ts +++ b/src/test-utils/plugin-runtime-env.ts @@ -1,7 +1,15 @@ import type { OutputRuntimeEnv } from "openclaw/plugin-sdk/runtime"; import { vi } from "vitest"; -export function createRuntimeEnv(options?: { throwOnExit?: boolean }): OutputRuntimeEnv { +type RuntimeEnvOptions = { + throwOnExit?: boolean; +}; + +type TypedRuntimeEnvOptions = RuntimeEnvOptions & { + readonly __runtimeShape?: (runtime: TRuntime) => void; +}; + +export function createRuntimeEnv(options?: RuntimeEnvOptions): OutputRuntimeEnv { const throwOnExit = options?.throwOnExit ?? true; return { log: vi.fn(), @@ -16,8 +24,9 @@ export function createRuntimeEnv(options?: { throwOnExit?: boolean }): OutputRun }; } -// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper lets plugin suites ascribe runtime extension shape. -export function createTypedRuntimeEnv(options?: { throwOnExit?: boolean }): TRuntime { +export function createTypedRuntimeEnv( + options?: TypedRuntimeEnvOptions, +): TRuntime { return createRuntimeEnv(options) as TRuntime; } @@ -25,7 +34,8 @@ export function createNonExitingRuntimeEnv(): OutputRuntimeEnv { return createRuntimeEnv({ throwOnExit: false }); } -// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper lets plugin suites ascribe runtime extension shape. -export function createNonExitingTypedRuntimeEnv(): TRuntime { - return createTypedRuntimeEnv({ throwOnExit: false }); +export function createNonExitingTypedRuntimeEnv( + runtimeShape?: (runtime: TRuntime) => void, +): TRuntime { + return createTypedRuntimeEnv({ throwOnExit: false, __runtimeShape: runtimeShape }); }