* Plugins: add inbound claim and Telegram interaction seams * Plugins: add Discord interaction surface * Chore: fix formatting after plugin rebase * fix(hooks): preserve observers after inbound claim * test(hooks): cover claimed inbound observer delivery * fix(plugins): harden typing lease refreshes * fix(discord): pass real auth to plugin interactions * fix(plugins): remove raw session binding runtime exposure * fix(plugins): tighten interactive callback handling * Plugins: gate conversation binding with approvals * Plugins: migrate legacy plugin binding records * Plugins/phone-control: update test command context * Plugins: migrate legacy binding ids * Plugins: migrate legacy codex session bindings * Discord: fix plugin interaction handling * Discord: support direct plugin conversation binds * Plugins: preserve Discord command bind targets * Tests: fix plugin binding and interactive fallout * Discord: stabilize directory lookup tests * Discord: route bound DMs to plugins * Discord: restore plugin bindings after restart * Telegram: persist detached plugin bindings * Plugins: limit binding APIs to Telegram and Discord * Plugins: harden bound conversation routing * Plugins: fix extension target imports * Plugins: fix Telegram runtime extension imports * Plugins: format rebased binding handlers * Discord: bind group DM interactions by channel --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import type { PluginRegistry } from "./registry.js";
|
|
import type { PluginHookAgentContext, PluginHookRegistration } from "./types.js";
|
|
|
|
export function createMockPluginRegistry(
|
|
hooks: Array<{ hookName: string; handler: (...args: unknown[]) => unknown }>,
|
|
): PluginRegistry {
|
|
return {
|
|
plugins: [
|
|
{
|
|
id: "test-plugin",
|
|
name: "Test Plugin",
|
|
source: "test",
|
|
origin: "workspace",
|
|
enabled: true,
|
|
status: "loaded",
|
|
toolNames: [],
|
|
hookNames: [],
|
|
channelIds: [],
|
|
providerIds: [],
|
|
gatewayMethods: [],
|
|
cliCommands: [],
|
|
services: [],
|
|
commands: [],
|
|
httpRoutes: 0,
|
|
hookCount: hooks.length,
|
|
configSchema: false,
|
|
},
|
|
],
|
|
hooks: hooks as never[],
|
|
typedHooks: hooks.map((h) => ({
|
|
pluginId: "test-plugin",
|
|
hookName: h.hookName,
|
|
handler: h.handler,
|
|
priority: 0,
|
|
source: "test",
|
|
})),
|
|
tools: [],
|
|
httpRoutes: [],
|
|
channelRegistrations: [],
|
|
gatewayHandlers: {},
|
|
cliRegistrars: [],
|
|
services: [],
|
|
providers: [],
|
|
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);
|
|
}
|