

























@@ -15,6 +15,7 @@ import type { loadOpenClawPlugins as loadOpenClawPluginsType } from "../../plugi
1515import type { PluginManifestRecord } from "../../plugins/manifest-registry.js";
1616import { loadPluginManifestRegistryForPluginRegistry } from "../../plugins/plugin-registry.js";
1717import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../routing/session-key.js";
18+import { normalizeOptionalString } from "../../shared/string-coerce.js";
1819import { sanitizeForLog } from "../../terminal/ansi.js";
1920import { getBundledChannelSetupPlugin } from "./bundled.js";
2021import { listChannelPlugins } from "./registry.js";
@@ -72,6 +73,10 @@ type ReadOnlyChannelPluginResolution = {
7273missingConfiguredChannelIds: string[];
7374};
7475type ManifestChannelConfigRecord = NonNullable<PluginManifestRecord["channelConfigs"]>[string];
76+type ChannelCommandDefaults = Pick<
77+NonNullable<ChannelPlugin["commands"]>,
78+"nativeCommandsAutoEnabled" | "nativeSkillsAutoEnabled"
79+>;
75807681function addChannelPlugins(
7782byId: Map<string, ChannelPlugin>,
@@ -125,6 +130,26 @@ function normalizeManifestText(value: string | undefined, fallback: string): str
125130return sanitizeForLog(value?.trim() || fallback).trim();
126131}
127132133+function normalizeChannelCommandDefaults(
134+value: ChannelCommandDefaults | undefined,
135+): ChannelCommandDefaults | undefined {
136+if (!value) {
137+return undefined;
138+}
139+const nativeCommandsAutoEnabled =
140+typeof value.nativeCommandsAutoEnabled === "boolean"
141+ ? value.nativeCommandsAutoEnabled
142+ : undefined;
143+const nativeSkillsAutoEnabled =
144+typeof value.nativeSkillsAutoEnabled === "boolean" ? value.nativeSkillsAutoEnabled : undefined;
145+return nativeCommandsAutoEnabled !== undefined || nativeSkillsAutoEnabled !== undefined
146+ ? {
147+ ...(nativeCommandsAutoEnabled !== undefined ? { nativeCommandsAutoEnabled } : {}),
148+ ...(nativeSkillsAutoEnabled !== undefined ? { nativeSkillsAutoEnabled } : {}),
149+}
150+ : undefined;
151+}
152+128153function rebindChannelConfig(
129154cfg: OpenClawConfig,
130155sourceChannelId: string,
@@ -258,6 +283,9 @@ function buildManifestChannelPlugin(params: {
258283channelConfig?.description ?? catalogMeta?.blurb,
259284params.record.description || "",
260285);
286+const commands = normalizeChannelCommandDefaults(
287+channelConfig?.commands ?? catalogMeta?.commands,
288+);
261289return {
262290id: params.channelId,
263291meta: {
@@ -273,6 +301,7 @@ function buildManifestChannelPlugin(params: {
273301 : {}),
274302},
275303capabilities: { chatTypes: ["direct"] },
304+ ...(commands ? { commands } : {}),
276305 ...(channelConfig
277306 ? {
278307configSchema: {
@@ -318,6 +347,47 @@ function canUseManifestChannelPlugin(record: PluginManifestRecord, channelId: st
318347return record.channelCatalogMeta?.id === channelId;
319348}
320349350+export function resolveReadOnlyChannelCommandDefaults(
351+channelId: string,
352+options: {
353+env?: NodeJS.ProcessEnv;
354+stateDir?: string;
355+workspaceDir?: string;
356+} = {},
357+): ChannelCommandDefaults | undefined {
358+const normalizedChannelId = normalizeOptionalString(channelId) ?? "";
359+if (!normalizedChannelId || !isSafeManifestChannelId(normalizedChannelId)) {
360+return undefined;
361+}
362+const registry = loadPluginManifestRegistryForPluginRegistry({
363+stateDir: options.stateDir,
364+workspaceDir: options.workspaceDir,
365+env: options.env ?? process.env,
366+includeDisabled: true,
367+});
368+for (const record of registry.plugins) {
369+if (!record.channels.includes(normalizedChannelId)) {
370+continue;
371+}
372+const channelConfigValue = record.channelConfigs
373+ ? readOwnRecordValue(record.channelConfigs as Record<string, unknown>, normalizedChannelId)
374+ : undefined;
375+const channelConfig =
376+channelConfigValue &&
377+typeof channelConfigValue === "object" &&
378+!Array.isArray(channelConfigValue)
379+ ? (channelConfigValue as ManifestChannelConfigRecord)
380+ : undefined;
381+const commands = normalizeChannelCommandDefaults(
382+channelConfig?.commands ?? record.channelCatalogMeta?.commands,
383+);
384+if (commands) {
385+return commands;
386+}
387+}
388+return undefined;
389+}
390+321391function rebindChannelPluginConfig(
322392config: ChannelPlugin["config"],
323393sourceChannelId: string,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。