


























@@ -6,6 +6,10 @@ import {
66import type { AgentHarness } from "../agents/harness/types.js";
77import type { AnyAgentTool } from "../agents/tools/common.js";
88import type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
9+import {
10+normalizeCommandDescriptorName,
11+sanitizeCommandDescriptorDescription,
12+} from "../cli/program/command-descriptor-utils.js";
913import {
1014clearContextEnginesForOwner,
1115registerContextEngineForOwner,
@@ -1003,19 +1007,39 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
10031007registrar: OpenClawPluginCliRegistrar,
10041008opts?: { commands?: string[]; descriptors?: OpenClawPluginCliCommandDescriptor[] },
10051009) => {
1010+const normalizeCommandRoot = (raw: string, source: "command" | "descriptor") => {
1011+const normalized = normalizeCommandDescriptorName(raw);
1012+if (!normalized) {
1013+pushDiagnostic({
1014+level: "error",
1015+pluginId: record.id,
1016+source: record.source,
1017+message: `invalid cli ${source} name: ${JSON.stringify(raw.trim())}`,
1018+});
1019+}
1020+return normalized;
1021+};
10061022const descriptors = (opts?.descriptors ?? [])
1007-.map((descriptor) => ({
1008-name: descriptor.name.trim(),
1009-description: descriptor.description.trim(),
1010-hasSubcommands: descriptor.hasSubcommands,
1011-}))
1012-.filter((descriptor) => descriptor.name && descriptor.description);
1023+.map((descriptor) => {
1024+const name = normalizeCommandRoot(descriptor.name, "descriptor");
1025+const description = sanitizeCommandDescriptorDescription(descriptor.description);
1026+return name && description
1027+ ? {
1028+ name,
1029+ description,
1030+hasSubcommands: descriptor.hasSubcommands,
1031+}
1032+ : null;
1033+})
1034+.filter(
1035+(descriptor): descriptor is OpenClawPluginCliCommandDescriptor => descriptor !== null,
1036+);
10131037const commands = [
10141038 ...(opts?.commands ?? []),
10151039 ...descriptors.map((descriptor) => descriptor.name),
10161040]
1017-.map((cmd) => cmd.trim())
1018-.filter(Boolean);
1041+.map((cmd) => normalizeCommandRoot(cmd, "command"))
1042+.filter((command): command is string => command !== null);
10191043if (commands.length === 0) {
10201044pushDiagnostic({
10211045level: "error",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。