fix: address review feedback on plugin command gate

- Deny unknown/unloaded providers by default (!channelPlugin → return [])
- Add Slack to test registry with capabilities.nativeCommands to validate
  the intended code path instead of null-fallback
- Consolidate duplicate getPluginCommandSpecs import in slash.ts
- Regenerate plugin-sdk API baseline

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
rafaelreis-r
2026-04-10 23:07:46 -03:00
committed by Josh Lehman
parent 052ff9464d
commit 4deceb0df1
3 changed files with 18 additions and 5 deletions

View File

@@ -3,13 +3,13 @@ import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pi
import {
resolveCommandAuthorizedFromAuthorizers,
resolveNativeCommandSessionTargets,
getPluginCommandSpecs,
} from "openclaw/plugin-sdk/command-auth";
import { type ChatCommandDefinition, type CommandArgs } from "openclaw/plugin-sdk/command-auth";
import {
resolveNativeCommandsEnabled,
resolveNativeSkillsEnabled,
} from "openclaw/plugin-sdk/config-runtime";
import { getPluginCommandSpecs } from "openclaw/plugin-sdk/command-auth";
import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
import { danger, logVerbose } from "openclaw/plugin-sdk/runtime-env";
import { chunkItems, normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
@@ -676,7 +676,9 @@ export async function registerSlackMonitorSlashCommands(params: {
);
for (const pluginCommand of getPluginCommandSpecs("slack")) {
const normalizedName = normalizeLowercaseStringOrEmpty(pluginCommand.name);
if (!normalizedName || existingNativeNames.has(normalizedName)) continue;
if (!normalizedName || existingNativeNames.has(normalizedName)) {
continue;
}
existingNativeNames.add(normalizedName);
nativeCommands.push(pluginCommand);
}

View File

@@ -76,9 +76,9 @@ export function getPluginCommandSpecs(provider?: string): Array<{
if (providerName) {
const channelPlugin = getChannelPlugin(providerName);
if (
channelPlugin &&
!channelPlugin.capabilities?.nativeCommands &&
!channelPlugin.commands?.nativeCommandsAutoEnabled
!channelPlugin ||
(!channelPlugin.capabilities?.nativeCommands &&
!channelPlugin.commands?.nativeCommandsAutoEnabled)
) {
return [];
}

View File

@@ -202,6 +202,17 @@ beforeEach(() => {
},
},
},
{
pluginId: "slack",
source: "test",
plugin: {
...createChannelTestPluginBase({
id: "slack",
label: "Slack",
capabilities: { nativeCommands: true, chatTypes: ["direct", "group"] },
}),
},
},
]),
);
});