fix(plugins): honor channels.<id>.enabled for bundled channels

This commit is contained in:
chilu18
2026-02-23 16:58:41 +00:00
committed by Peter Steinberger
parent 65d57eac12
commit 3cadc3eed1
2 changed files with 120 additions and 1 deletions

View File

@@ -195,6 +195,104 @@ describe("loadOpenClawPlugins", () => {
expect(registry.channels.some((entry) => entry.plugin.id === "telegram")).toBe(true);
});
it("loads bundled channel plugins when channels.<id>.enabled=true", () => {
const bundledDir = makeTempDir();
writePlugin({
id: "telegram",
body: `export default { id: "telegram", register(api) {
api.registerChannel({
plugin: {
id: "telegram",
meta: {
id: "telegram",
label: "Telegram",
selectionLabel: "Telegram",
docsPath: "/channels/telegram",
blurb: "telegram channel"
},
capabilities: { chatTypes: ["direct"] },
config: {
listAccountIds: () => [],
resolveAccount: () => ({ accountId: "default" })
},
outbound: { deliveryMode: "direct" }
}
});
} };`,
dir: bundledDir,
filename: "telegram.js",
});
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledDir;
const registry = loadOpenClawPlugins({
cache: false,
config: {
channels: {
telegram: {
enabled: true,
},
},
plugins: {
enabled: true,
},
},
});
const telegram = registry.plugins.find((entry) => entry.id === "telegram");
expect(telegram?.status).toBe("loaded");
expect(registry.channels.some((entry) => entry.plugin.id === "telegram")).toBe(true);
});
it("still respects explicit disable via plugins.entries for bundled channels", () => {
const bundledDir = makeTempDir();
writePlugin({
id: "telegram",
body: `export default { id: "telegram", register(api) {
api.registerChannel({
plugin: {
id: "telegram",
meta: {
id: "telegram",
label: "Telegram",
selectionLabel: "Telegram",
docsPath: "/channels/telegram",
blurb: "telegram channel"
},
capabilities: { chatTypes: ["direct"] },
config: {
listAccountIds: () => [],
resolveAccount: () => ({ accountId: "default" })
},
outbound: { deliveryMode: "direct" }
}
});
} };`,
dir: bundledDir,
filename: "telegram.js",
});
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledDir;
const registry = loadOpenClawPlugins({
cache: false,
config: {
channels: {
telegram: {
enabled: true,
},
},
plugins: {
entries: {
telegram: { enabled: false },
},
},
},
});
const telegram = registry.plugins.find((entry) => entry.id === "telegram");
expect(telegram?.status).toBe("disabled");
expect(telegram?.error).toBe("disabled in config");
});
it("enables bundled memory plugin when selected by slot", () => {
const registry = loadBundledMemoryPluginRegistry();