mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:50:43 +00:00
fix: break plugin command spec import cycle
This commit is contained in:
@@ -2454,7 +2454,8 @@ describe("spawnAcpDirect", () => {
|
||||
conversation: expect.objectContaining({
|
||||
channel: "telegram",
|
||||
accountId: "default",
|
||||
conversationId: "-1003342490704:topic:2",
|
||||
conversationId: "2",
|
||||
parentConversationId: "-1003342490704",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -79,7 +79,7 @@ vi.mock("../../auto-reply/commands-registry.js", () => ({
|
||||
vi.mock("../../auto-reply/skill-commands.js", () => ({
|
||||
listSkillCommandsForAgents: vi.fn(() => mockSkillCommands),
|
||||
}));
|
||||
vi.mock("../../plugins/command-registry-state.js", () => ({
|
||||
vi.mock("../../plugins/command-specs.js", () => ({
|
||||
getPluginCommandSpecs: vi.fn((provider?: string) => {
|
||||
if (provider === "whatsapp") {
|
||||
return [];
|
||||
|
||||
@@ -9,7 +9,7 @@ import { listSkillCommandsForAgents } from "../../auto-reply/skill-commands.js";
|
||||
import { getChannelPlugin } from "../../channels/plugins/index.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import { getPluginCommandSpecs } from "../../plugins/command-registry-state.js";
|
||||
import { getPluginCommandSpecs } from "../../plugins/command-specs.js";
|
||||
import { listPluginCommands } from "../../plugins/commands.js";
|
||||
import { normalizeOptionalLowercaseString } from "../../shared/string-coerce.js";
|
||||
import type { CommandEntry, CommandsListResult } from "../protocol/index.js";
|
||||
|
||||
@@ -77,10 +77,8 @@ export {
|
||||
listSkillCommandsForWorkspace,
|
||||
resolveSkillCommandInvocation,
|
||||
} from "../auto-reply/skill-commands.js";
|
||||
export {
|
||||
getPluginCommandSpecs,
|
||||
listProviderPluginCommandSpecs,
|
||||
} from "../plugins/command-registration.js";
|
||||
export { getPluginCommandSpecs } from "../plugins/command-specs.js";
|
||||
export { listProviderPluginCommandSpecs } from "../plugins/command-registry-state.js";
|
||||
export type { SkillCommandSpec } from "../agents/skills.js";
|
||||
export {
|
||||
buildModelsProviderData,
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
import {
|
||||
clearPluginCommands,
|
||||
clearPluginCommandsForPlugin,
|
||||
getPluginCommandSpecs,
|
||||
isPluginCommandRegistryLocked,
|
||||
listProviderPluginCommandSpecs,
|
||||
pluginCommands,
|
||||
@@ -197,10 +196,5 @@ export function registerPluginCommand(
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
export {
|
||||
clearPluginCommands,
|
||||
clearPluginCommandsForPlugin,
|
||||
getPluginCommandSpecs,
|
||||
listProviderPluginCommandSpecs,
|
||||
};
|
||||
export { clearPluginCommands, clearPluginCommandsForPlugin, listProviderPluginCommandSpecs };
|
||||
export type { RegisteredPluginCommand };
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { getLoadedChannelPlugin } from "../channels/plugins/index.js";
|
||||
import { resolveReadOnlyChannelCommandDefaults } from "../channels/plugins/read-only-command-defaults.js";
|
||||
import { resolveGlobalSingleton } from "../shared/global-singleton.js";
|
||||
import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js";
|
||||
import type { OpenClawPluginCommandDefinition } from "./types.js";
|
||||
@@ -83,24 +81,6 @@ function resolvePluginNativeName(
|
||||
return command.name;
|
||||
}
|
||||
|
||||
export function getPluginCommandSpecs(provider?: string): Array<{
|
||||
name: string;
|
||||
description: string;
|
||||
acceptsArgs: boolean;
|
||||
}> {
|
||||
const providerName = normalizeOptionalLowercaseString(provider);
|
||||
if (
|
||||
providerName &&
|
||||
(
|
||||
getLoadedChannelPlugin(providerName)?.commands ??
|
||||
resolveReadOnlyChannelCommandDefaults(providerName)
|
||||
)?.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;
|
||||
|
||||
22
src/plugins/command-specs.ts
Normal file
22
src/plugins/command-specs.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { getLoadedChannelPlugin } from "../channels/plugins/index.js";
|
||||
import { resolveReadOnlyChannelCommandDefaults } from "../channels/plugins/read-only.js";
|
||||
import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js";
|
||||
import { listProviderPluginCommandSpecs } from "./command-registry-state.js";
|
||||
|
||||
export function getPluginCommandSpecs(provider?: string): Array<{
|
||||
name: string;
|
||||
description: string;
|
||||
acceptsArgs: boolean;
|
||||
}> {
|
||||
const providerName = normalizeOptionalLowercaseString(provider);
|
||||
if (
|
||||
providerName &&
|
||||
(
|
||||
getLoadedChannelPlugin(providerName)?.commands ??
|
||||
resolveReadOnlyChannelCommandDefaults(providerName)
|
||||
)?.nativeCommandsAutoEnabled !== true
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
return listProviderPluginCommandSpecs(provider);
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
|
||||
import {
|
||||
clearPluginCommands,
|
||||
clearPluginCommandsForPlugin,
|
||||
getPluginCommandSpecs,
|
||||
listPluginInvocationKeys,
|
||||
listProviderPluginCommandSpecs,
|
||||
registerPluginCommand,
|
||||
@@ -24,6 +23,7 @@ import {
|
||||
setPluginCommandRegistryLocked,
|
||||
type RegisteredPluginCommand,
|
||||
} from "./command-registry-state.js";
|
||||
import { getPluginCommandSpecs } from "./command-specs.js";
|
||||
import {
|
||||
detachPluginConversationBinding,
|
||||
getCurrentPluginConversationBinding,
|
||||
|
||||
@@ -22,7 +22,8 @@ import {
|
||||
type DetachedTaskLifecycleRuntime,
|
||||
} from "../tasks/detached-task-runtime-state.js";
|
||||
import { withEnv } from "../test-utils/env.js";
|
||||
import { clearPluginCommands, getPluginCommandSpecs } from "./command-registry-state.js";
|
||||
import { clearPluginCommands } from "./command-registry-state.js";
|
||||
import { getPluginCommandSpecs } from "./command-specs.js";
|
||||
import {
|
||||
getGlobalHookRunner,
|
||||
getGlobalPluginRegistry,
|
||||
|
||||
Reference in New Issue
Block a user