perf: narrow slack command imports

This commit is contained in:
Peter Steinberger
2026-04-24 00:35:47 +01:00
parent a3aa13df9b
commit 5be5233250
3 changed files with 16 additions and 6 deletions

View File

@@ -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,

View File

@@ -0,0 +1 @@
export { listProviderPluginCommandSpecs } from "openclaw/plugin-sdk/command-auth";

View File

@@ -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<typeof import("./slash-commands.runtime
null;
let slashDispatchRuntimePromise: Promise<typeof import("./slash-dispatch.runtime.js")> | 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)) {