fix(ci): repair helper typing regressions

This commit is contained in:
Peter Steinberger
2026-03-14 03:01:33 +00:00
parent eee5d7c6b0
commit 8bc163d15f
9 changed files with 84 additions and 98 deletions

View File

@@ -1,3 +1,5 @@
import type { ChannelDirectoryAdapter } from "../../src/channels/plugins/types.js";
export function createDirectoryTestRuntime() {
return {
log: () => {},
@@ -8,15 +10,7 @@ export function createDirectoryTestRuntime() {
};
}
export function expectDirectorySurface(
directory:
| {
listPeers?: unknown;
listGroups?: unknown;
}
| null
| undefined,
) {
export function expectDirectorySurface(directory: ChannelDirectoryAdapter | null | undefined) {
if (!directory) {
throw new Error("expected directory");
}
@@ -27,7 +21,7 @@ export function expectDirectorySurface(
throw new Error("expected listGroups");
}
return directory as {
listPeers: NonNullable<typeof directory.listPeers>;
listGroups: NonNullable<typeof directory.listGroups>;
listPeers: NonNullable<ChannelDirectoryAdapter["listPeers"]>;
listGroups: NonNullable<ChannelDirectoryAdapter["listGroups"]>;
};
}

View File

@@ -1,29 +1,11 @@
type TestLogger = {
info: () => void;
warn: () => void;
error: () => void;
debug?: () => void;
};
import type { OpenClawPluginApi } from "../../src/plugins/types.js";
type TestPluginApiDefaults = {
logger: TestLogger;
registerTool: () => void;
registerHook: () => void;
registerHttpRoute: () => void;
registerChannel: () => void;
registerGatewayMethod: () => void;
registerCli: () => void;
registerService: () => void;
registerProvider: () => void;
registerCommand: () => void;
registerContextEngine: () => void;
resolvePath: (input: string) => string;
on: () => void;
};
type TestPluginApiInput = Partial<OpenClawPluginApi> &
Pick<OpenClawPluginApi, "id" | "name" | "source" | "config" | "runtime">;
export function createTestPluginApi<T extends object>(api: T): T & TestPluginApiDefaults {
export function createTestPluginApi(api: TestPluginApiInput): OpenClawPluginApi {
return {
logger: { info() {}, warn() {}, error() {} },
logger: { info() {}, warn() {}, error() {}, debug() {} },
registerTool() {},
registerHook() {},
registerHttpRoute() {},