fix(configure): defer web search setup runtime

Keep web-search configure and channel command defaults on cold plugin metadata, harden persisted registry reads, and require active config for manifest command defaults.\n\nThanks @vincentkoc
This commit is contained in:
Vincent Koc
2026-04-26 01:41:57 -07:00
committed by GitHub
parent 218636a0ea
commit 2652c9eacf
13 changed files with 353 additions and 98 deletions

View File

@@ -1,6 +1,10 @@
import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { isBlockedObjectKey } from "../../infra/prototype-keys.js";
import type { PluginManifestRecord } from "../../plugins/manifest-registry.js";
import { loadPluginManifestRegistryForPluginRegistry } from "../../plugins/plugin-registry.js";
import {
isPluginEnabled,
loadPluginManifestRegistryForPluginRegistry,
} from "../../plugins/plugin-registry.js";
import { normalizeOptionalString } from "../../shared/string-coerce.js";
import type { ChannelPlugin } from "./types.plugin.js";
@@ -36,12 +40,17 @@ export function normalizeChannelCommandDefaults(
: undefined;
const nativeSkillsAutoEnabled =
typeof value.nativeSkillsAutoEnabled === "boolean" ? value.nativeSkillsAutoEnabled : undefined;
return nativeCommandsAutoEnabled !== undefined || nativeSkillsAutoEnabled !== undefined
? {
...(nativeCommandsAutoEnabled !== undefined ? { nativeCommandsAutoEnabled } : {}),
...(nativeSkillsAutoEnabled !== undefined ? { nativeSkillsAutoEnabled } : {}),
}
: undefined;
if (nativeCommandsAutoEnabled === undefined && nativeSkillsAutoEnabled === undefined) {
return undefined;
}
const defaults: ChannelCommandDefaults = {};
if (nativeCommandsAutoEnabled !== undefined) {
defaults.nativeCommandsAutoEnabled = nativeCommandsAutoEnabled;
}
if (nativeSkillsAutoEnabled !== undefined) {
defaults.nativeSkillsAutoEnabled = nativeSkillsAutoEnabled;
}
return defaults;
}
export function resolveReadOnlyChannelCommandDefaults(
@@ -50,13 +59,15 @@ export function resolveReadOnlyChannelCommandDefaults(
env?: NodeJS.ProcessEnv;
stateDir?: string;
workspaceDir?: string;
} = {},
config: OpenClawConfig;
},
): ChannelCommandDefaults | undefined {
const normalizedChannelId = normalizeOptionalString(channelId) ?? "";
if (!normalizedChannelId || !isSafeManifestChannelId(normalizedChannelId)) {
return undefined;
}
const registry = loadPluginManifestRegistryForPluginRegistry({
config: options.config,
stateDir: options.stateDir,
workspaceDir: options.workspaceDir,
env: options.env ?? process.env,
@@ -66,6 +77,23 @@ export function resolveReadOnlyChannelCommandDefaults(
if (!record.channels.includes(normalizedChannelId)) {
continue;
}
if (
record.id !== normalizedChannelId &&
record.channelCatalogMeta?.id !== normalizedChannelId
) {
continue;
}
if (
!isPluginEnabled({
pluginId: record.id,
config: options.config,
stateDir: options.stateDir,
workspaceDir: options.workspaceDir,
env: options.env ?? process.env,
})
) {
continue;
}
const channelConfigValue = record.channelConfigs
? readOwnRecordValue(record.channelConfigs as Record<string, unknown>, normalizedChannelId)
: undefined;