From 4deceb0df1c42ea0fb60e9d7b1e95dc2d41e6763 Mon Sep 17 00:00:00 2001 From: rafaelreis-r Date: Fri, 10 Apr 2026 23:07:46 -0300 Subject: [PATCH] fix: address review feedback on plugin command gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- extensions/slack/src/monitor/slash.ts | 6 ++++-- src/plugins/command-registry-state.ts | 6 +++--- src/plugins/commands.test.ts | 11 +++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/extensions/slack/src/monitor/slash.ts b/extensions/slack/src/monitor/slash.ts index 188214f89f5..95de43f0e81 100644 --- a/extensions/slack/src/monitor/slash.ts +++ b/extensions/slack/src/monitor/slash.ts @@ -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); } diff --git a/src/plugins/command-registry-state.ts b/src/plugins/command-registry-state.ts index 92bf3a7637d..dcd2f871e90 100644 --- a/src/plugins/command-registry-state.ts +++ b/src/plugins/command-registry-state.ts @@ -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 []; } diff --git a/src/plugins/commands.test.ts b/src/plugins/commands.test.ts index f04d7e4cdc0..a2a5e53210d 100644 --- a/src/plugins/commands.test.ts +++ b/src/plugins/commands.test.ts @@ -202,6 +202,17 @@ beforeEach(() => { }, }, }, + { + pluginId: "slack", + source: "test", + plugin: { + ...createChannelTestPluginBase({ + id: "slack", + label: "Slack", + capabilities: { nativeCommands: true, chatTypes: ["direct", "group"] }, + }), + }, + }, ]), ); });