mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 04:00:34 +00:00
fix: sync built-in channel enablement across config paths
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user