diff --git a/src/plugins/loader.cli-metadata.test.ts b/src/plugins/loader.cli-metadata.test.ts index e5caefe3751..1068ae632b6 100644 --- a/src/plugins/loader.cli-metadata.test.ts +++ b/src/plugins/loader.cli-metadata.test.ts @@ -19,6 +19,33 @@ afterAll(() => { cleanupPluginLoaderFixturesForTest(); }); +function inlineChannelPluginEntryFactorySource(): string { + return `function defineChannelPluginEntry(options) { + return { + id: options.id, + name: options.name, + description: options.description, + configSchema: { schema: { type: "object" } }, + channelPlugin: options.plugin, + setChannelRuntime: options.setRuntime, + register(api) { + if (api.registrationMode === "cli-metadata") { + options.registerCliMetadata?.(api); + return; + } + options.setRuntime?.(api.runtime); + api.registerChannel({ plugin: options.plugin }); + if (api.registrationMode !== "full") { + return; + } + options.registerCliMetadata?.(api); + options.registerFull?.(api); + }, + }; +} +`; +} + describe("plugin loader CLI metadata", () => { it("suppresses trust warning logs during CLI metadata loads", async () => { useNoBundledPlugins(); @@ -162,7 +189,7 @@ describe("plugin loader CLI metadata", () => { ); fs.writeFileSync( path.join(pluginDir, "index.cjs"), - `const { defineChannelPluginEntry } = require("openclaw/plugin-sdk/core"); + `${inlineChannelPluginEntryFactorySource()} require("node:fs").writeFileSync(${JSON.stringify(fullMarker)}, "loaded", "utf-8"); module.exports = { ...defineChannelPluginEntry({ @@ -485,7 +512,7 @@ module.exports = { ); fs.writeFileSync( path.join(pluginDir, "index.cjs"), - `const { defineChannelPluginEntry } = require("openclaw/plugin-sdk/core"); + `${inlineChannelPluginEntryFactorySource()} module.exports = { ...defineChannelPluginEntry({ id: "full-cli-metadata-channel",