From 5be5233250f096ea6e87fca8ef6d22f9ef8a7ab6 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 24 Apr 2026 00:35:47 +0100 Subject: [PATCH] perf: narrow slack command imports --- .../slack/src/monitor/message-handler/prepare.ts | 6 +++--- .../src/monitor/slash-plugin-commands.runtime.ts | 1 + extensions/slack/src/monitor/slash.ts | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 extensions/slack/src/monitor/slash-plugin-commands.runtime.ts diff --git a/extensions/slack/src/monitor/message-handler/prepare.ts b/extensions/slack/src/monitor/message-handler/prepare.ts index 975874bb89b..08730d1e4aa 100644 --- a/extensions/slack/src/monitor/message-handler/prepare.ts +++ b/extensions/slack/src/monitor/message-handler/prepare.ts @@ -12,9 +12,9 @@ import { resolveEnvelopeFormatOptions, resolveInboundMentionDecision, } from "openclaw/plugin-sdk/channel-inbound"; -import { resolveControlCommandGate } from "openclaw/plugin-sdk/command-auth"; -import { hasControlCommand } from "openclaw/plugin-sdk/command-auth"; -import { shouldHandleTextCommands } from "openclaw/plugin-sdk/command-auth"; +import { hasControlCommand } from "openclaw/plugin-sdk/command-detection"; +import { resolveControlCommandGate } from "openclaw/plugin-sdk/command-gating"; +import { shouldHandleTextCommands } from "openclaw/plugin-sdk/command-surface"; import { resolveRuntimeConversationBindingRoute, type RuntimeConversationBindingRouteResult, diff --git a/extensions/slack/src/monitor/slash-plugin-commands.runtime.ts b/extensions/slack/src/monitor/slash-plugin-commands.runtime.ts new file mode 100644 index 00000000000..6c89e635aac --- /dev/null +++ b/extensions/slack/src/monitor/slash-plugin-commands.runtime.ts @@ -0,0 +1 @@ +export { listProviderPluginCommandSpecs } from "openclaw/plugin-sdk/command-auth"; diff --git a/extensions/slack/src/monitor/slash.ts b/extensions/slack/src/monitor/slash.ts index a9449432b0e..2ac0fbb1086 100644 --- a/extensions/slack/src/monitor/slash.ts +++ b/extensions/slack/src/monitor/slash.ts @@ -1,11 +1,11 @@ import type { SlackActionMiddlewareArgs, SlackCommandMiddlewareArgs } from "@slack/bolt"; import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pipeline"; +import type { ChatCommandDefinition } from "openclaw/plugin-sdk/command-auth"; import { + type CommandArgs, resolveCommandAuthorizedFromAuthorizers, resolveNativeCommandSessionTargets, - listProviderPluginCommandSpecs, -} from "openclaw/plugin-sdk/command-auth"; -import { type ChatCommandDefinition, type CommandArgs } from "openclaw/plugin-sdk/command-auth"; +} from "openclaw/plugin-sdk/command-auth-native"; import { resolveNativeCommandsEnabled, resolveNativeSkillsEnabled, @@ -47,6 +47,9 @@ let slashCommandsRuntimePromise: Promise | null = null; +let slackPluginCommandsRuntimePromise: Promise< + typeof import("./slash-plugin-commands.runtime.js") +> | null = null; let slashSkillCommandsRuntimePromise: Promise< typeof import("./slash-skill-commands.runtime.js") > | null = null; @@ -61,6 +64,11 @@ function loadSlashDispatchRuntime() { return slashDispatchRuntimePromise; } +function loadSlackPluginCommandsRuntime() { + slackPluginCommandsRuntimePromise ??= import("./slash-plugin-commands.runtime.js"); + return slackPluginCommandsRuntimePromise; +} + function loadSlashSkillCommandsRuntime() { slashSkillCommandsRuntimePromise ??= import("./slash-skill-commands.runtime.js"); return slashSkillCommandsRuntimePromise; @@ -685,6 +693,7 @@ export async function registerSlackMonitorSlashCommands(params: { const existingNativeNames = new Set( nativeCommands.map((c) => normalizeLowercaseStringOrEmpty(c.name)).filter(Boolean), ); + const { listProviderPluginCommandSpecs } = await loadSlackPluginCommandsRuntime(); for (const pluginCommand of listProviderPluginCommandSpecs("slack")) { const normalizedName = normalizeLowercaseStringOrEmpty(pluginCommand.name); if (!normalizedName || existingNativeNames.has(normalizedName)) {