diff --git a/src/plugin-sdk/command-auth.ts b/src/plugin-sdk/command-auth.ts index e3eaf56ff02..192b71b7b83 100644 --- a/src/plugin-sdk/command-auth.ts +++ b/src/plugin-sdk/command-auth.ts @@ -77,8 +77,7 @@ export { listSkillCommandsForWorkspace, resolveSkillCommandInvocation, } from "../auto-reply/skill-commands.js"; -export { getPluginCommandSpecs } from "../plugins/command-specs.js"; -export { listProviderPluginCommandSpecs } from "../plugins/command-registry-state.js"; +export { getPluginCommandSpecs, listProviderPluginCommandSpecs } from "../plugins/command-specs.js"; export type { SkillCommandSpec } from "../agents/skills.js"; export { buildModelsProviderData, diff --git a/src/plugins/command-registration.ts b/src/plugins/command-registration.ts index 385f2faa462..cd17250109a 100644 --- a/src/plugins/command-registration.ts +++ b/src/plugins/command-registration.ts @@ -8,7 +8,6 @@ import { clearPluginCommands, clearPluginCommandsForPlugin, isPluginCommandRegistryLocked, - listProviderPluginCommandSpecs, pluginCommands, type RegisteredPluginCommand, } from "./command-registry-state.js"; @@ -236,5 +235,5 @@ export function registerPluginCommand( return { ok: true }; } -export { clearPluginCommands, clearPluginCommandsForPlugin, listProviderPluginCommandSpecs }; +export { clearPluginCommands, clearPluginCommandsForPlugin }; export type { RegisteredPluginCommand }; diff --git a/src/plugins/command-registry-state.ts b/src/plugins/command-registry-state.ts index 0bdde72630b..99ab301a134 100644 --- a/src/plugins/command-registry-state.ts +++ b/src/plugins/command-registry-state.ts @@ -1,6 +1,3 @@ -import { getLoadedChannelPlugin } from "../channels/plugins/index.js"; -import { resolveReadOnlyChannelCommandDefaults } from "../channels/plugins/read-only-command-defaults.js"; -import type { OpenClawConfig } from "../config/types.openclaw.js"; import { resolveGlobalSingleton } from "../shared/global-singleton.js"; import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js"; import type { OpenClawPluginCommandDefinition } from "./types.js"; @@ -83,63 +80,3 @@ export function restorePluginCommands(commands: readonly RegisteredPluginCommand pluginCommands.set(`/${name}`, command); } } - -function resolvePluginNativeName( - command: OpenClawPluginCommandDefinition, - provider?: string, -): string { - const providerName = normalizeOptionalLowercaseString(provider); - const providerOverride = providerName ? command.nativeNames?.[providerName] : undefined; - if (typeof providerOverride === "string" && providerOverride.trim()) { - return providerOverride.trim(); - } - const defaultOverride = command.nativeNames?.default; - if (typeof defaultOverride === "string" && defaultOverride.trim()) { - return defaultOverride.trim(); - } - return command.name; -} - -export function getPluginCommandSpecs( - provider?: string, - options: { - env?: NodeJS.ProcessEnv; - stateDir?: string; - workspaceDir?: string; - config?: OpenClawConfig; - } = {}, -): Array<{ - name: string; - description: string; - acceptsArgs: boolean; -}> { - const providerName = normalizeOptionalLowercaseString(provider); - const commandDefaults = - providerName && options.config - ? resolveReadOnlyChannelCommandDefaults(providerName, { - ...options, - config: options.config, - }) - : undefined; - if ( - providerName && - (getLoadedChannelPlugin(providerName)?.commands ?? commandDefaults) - ?.nativeCommandsAutoEnabled !== true - ) { - return []; - } - return listProviderPluginCommandSpecs(provider); -} - -/** Resolve plugin command specs for a provider's native naming surface without support gating. */ -export function listProviderPluginCommandSpecs(provider?: string): Array<{ - name: string; - description: string; - acceptsArgs: boolean; -}> { - return Array.from(pluginCommands.values()).map((cmd) => ({ - name: resolvePluginNativeName(cmd, provider), - description: cmd.description, - acceptsArgs: cmd.acceptsArgs ?? false, - })); -} diff --git a/src/plugins/command-specs.ts b/src/plugins/command-specs.ts index e1742289302..e8f72963fda 100644 --- a/src/plugins/command-specs.ts +++ b/src/plugins/command-specs.ts @@ -2,7 +2,24 @@ import { getLoadedChannelPlugin } from "../channels/plugins/index.js"; import { resolveReadOnlyChannelCommandDefaults } from "../channels/plugins/read-only-command-defaults.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js"; -import { listProviderPluginCommandSpecs } from "./command-registry-state.js"; +import { pluginCommands } from "./command-registry-state.js"; +import type { OpenClawPluginCommandDefinition } from "./types.js"; + +function resolvePluginNativeName( + command: OpenClawPluginCommandDefinition, + provider?: string, +): string { + const providerName = normalizeOptionalLowercaseString(provider); + const providerOverride = providerName ? command.nativeNames?.[providerName] : undefined; + if (typeof providerOverride === "string" && providerOverride.trim()) { + return providerOverride.trim(); + } + const defaultOverride = command.nativeNames?.default; + if (typeof defaultOverride === "string" && defaultOverride.trim()) { + return defaultOverride.trim(); + } + return command.name; +} export function getPluginCommandSpecs( provider?: string, @@ -34,3 +51,16 @@ export function getPluginCommandSpecs( } return listProviderPluginCommandSpecs(provider); } + +/** Resolve plugin command specs for a provider's native naming surface without support gating. */ +export function listProviderPluginCommandSpecs(provider?: string): Array<{ + name: string; + description: string; + acceptsArgs: boolean; +}> { + return Array.from(pluginCommands.values()).map((cmd) => ({ + name: resolvePluginNativeName(cmd, provider), + description: cmd.description, + acceptsArgs: cmd.acceptsArgs ?? false, + })); +} diff --git a/src/plugins/commands.ts b/src/plugins/commands.ts index 0314dfb5fc5..0b50df6c6db 100644 --- a/src/plugins/commands.ts +++ b/src/plugins/commands.ts @@ -14,7 +14,6 @@ import { clearPluginCommands, clearPluginCommandsForPlugin, listPluginInvocationKeys, - listProviderPluginCommandSpecs, registerPluginCommand, validateCommandName, validatePluginCommandDefinition, @@ -24,7 +23,7 @@ import { setPluginCommandRegistryLocked, type RegisteredPluginCommand, } from "./command-registry-state.js"; -import { getPluginCommandSpecs } from "./command-specs.js"; +import { getPluginCommandSpecs, listProviderPluginCommandSpecs } from "./command-specs.js"; import { detachPluginConversationBinding, getCurrentPluginConversationBinding,