fix: sync built-in channel enablement across config paths

This commit is contained in:
Peter Steinberger
2026-02-23 19:40:32 +00:00
parent 69b17a37e8
commit 87603b5c45
10 changed files with 213 additions and 86 deletions

View File

@@ -1,3 +1,4 @@
import { normalizeChatChannelId } from "../channels/registry.js";
import type { OpenClawConfig } from "../config/config.js";
import type { PluginRecord } from "./registry.js";
import { defaultSlotIdForKey } from "./slots.js";
@@ -194,6 +195,42 @@ export function resolveEnableState(
return { enabled: true };
}
export function isBundledChannelEnabledByChannelConfig(
cfg: OpenClawConfig | undefined,
pluginId: string,
): boolean {
if (!cfg) {
return false;
}
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;
}
export function resolveEffectiveEnableState(params: {
id: string;
origin: PluginRecord["origin"];
config: NormalizedPluginsConfig;
rootConfig?: OpenClawConfig;
}): { enabled: boolean; reason?: string } {
const base = resolveEnableState(params.id, params.origin, params.config);
if (
!base.enabled &&
base.reason === "bundled (disabled by default)" &&
isBundledChannelEnabledByChannelConfig(params.rootConfig, params.id)
) {
return { enabled: true };
}
return base;
}
export function resolveMemorySlotDecision(params: {
id: string;
kind?: string;