mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 00:02:55 +00:00
fix: restore helper imports and plugin hook test exports
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { PluginRegistry } from "./registry.js";
|
||||
import type { PluginHookAgentContext, PluginHookRegistration } from "./types.js";
|
||||
|
||||
export function createMockPluginRegistry(
|
||||
hooks: Array<{ hookName: string; handler: (...args: unknown[]) => unknown }>,
|
||||
@@ -22,3 +23,27 @@ export function createMockPluginRegistry(
|
||||
commands: [],
|
||||
} as unknown as PluginRegistry;
|
||||
}
|
||||
|
||||
export const TEST_PLUGIN_AGENT_CTX: PluginHookAgentContext = {
|
||||
agentId: "test-agent",
|
||||
sessionKey: "test-session",
|
||||
sessionId: "test-session-id",
|
||||
workspaceDir: "/tmp/openclaw-test",
|
||||
messageProvider: "test",
|
||||
};
|
||||
|
||||
export function addTestHook(params: {
|
||||
registry: PluginRegistry;
|
||||
pluginId: string;
|
||||
hookName: PluginHookRegistration["hookName"];
|
||||
handler: PluginHookRegistration["handler"];
|
||||
priority?: number;
|
||||
}) {
|
||||
params.registry.typedHooks.push({
|
||||
pluginId: params.pluginId,
|
||||
hookName: params.hookName,
|
||||
handler: params.handler,
|
||||
priority: params.priority ?? 0,
|
||||
source: "test",
|
||||
} as PluginHookRegistration);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user