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

@@ -2,6 +2,7 @@ import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { createJiti } from "jiti";
import { normalizeChatChannelId } from "../channels/registry.js";
import type { OpenClawConfig } from "../config/config.js";
import type { GatewayRequestHandler } from "../gateway/server-methods/types.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
@@ -175,6 +176,19 @@ function createPluginRecord(params: {
};
}
function isBundledChannelEnabledByChannelConfig(cfg: OpenClawConfig, pluginId: string): boolean {
const channelId = normalizeChatChannelId(pluginId);
if (!channelId) {
return false;
}
const channels = cfg.channels as Record<string, unknown> | undefined;
const entry = channels?.[channelId];
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
return false;
}
return (entry as Record<string, unknown>).enabled === true;
}
function recordPluginError(params: {
logger: PluginLogger;
registry: PluginRegistry;
@@ -472,7 +486,14 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
continue;
}
const enableState = resolveEnableState(pluginId, candidate.origin, normalized);
let enableState = resolveEnableState(pluginId, candidate.origin, normalized);
if (
!enableState.enabled &&
enableState.reason === "bundled (disabled by default)" &&
isBundledChannelEnabledByChannelConfig(cfg, pluginId)
) {
enableState = { enabled: true };
}
const entry = normalized.entries[pluginId];
const record = createPluginRecord({
id: pluginId,