openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
70 lines (69 loc) • 2.74 kB
TypeScript
/**
* Plugin Command Registry
*
* Manages commands registered by plugins that bypass the LLM agent.
* These commands are processed before built-in commands and before agent invocation.
*/
import type { OpenClawConfig } from "../config/config.js";
import { clearPluginCommands, clearPluginCommandsForPlugin, getPluginCommandSpecs, registerPluginCommand, validateCommandName, validatePluginCommandDefinition } from "./command-registration.js";
import { type RegisteredPluginCommand } from "./command-registry-state.js";
import type { PluginCommandContext, PluginCommandResult } from "./types.js";
export { clearPluginCommands, clearPluginCommandsForPlugin, getPluginCommandSpecs, registerPluginCommand, validateCommandName, validatePluginCommandDefinition, };
/**
* Check if a command body matches a registered plugin command.
* Returns the command definition and parsed args if matched.
*
* Note: If a command has `acceptsArgs: false` and the user provides arguments,
* the command will not match. This allows the message to fall through to
* built-in handlers or the agent. Document this behavior to plugin authors.
*/
export declare function matchPluginCommand(commandBody: string): {
command: RegisteredPluginCommand;
args?: string;
} | null;
declare function resolveBindingConversationFromCommand(params: {
channel: string;
from?: string;
to?: string;
accountId?: string;
messageThreadId?: string | number;
}): {
channel: string;
accountId: string;
conversationId: string;
parentConversationId?: string;
threadId?: string | number;
} | null;
/**
* Execute a plugin command handler.
*
* Note: Plugin authors should still validate and sanitize ctx.args for their
* specific use case. This function provides basic defense-in-depth sanitization.
*/
export declare function executePluginCommand(params: {
command: RegisteredPluginCommand;
args?: string;
senderId?: string;
channel: string;
channelId?: PluginCommandContext["channelId"];
isAuthorizedSender: boolean;
gatewayClientScopes?: PluginCommandContext["gatewayClientScopes"];
commandBody: string;
config: OpenClawConfig;
from?: PluginCommandContext["from"];
to?: PluginCommandContext["to"];
accountId?: PluginCommandContext["accountId"];
messageThreadId?: PluginCommandContext["messageThreadId"];
}): Promise<PluginCommandResult>;
/**
* List all registered plugin commands.
* Used for /help and /commands output.
*/
export declare function listPluginCommands(): Array<{
name: string;
description: string;
pluginId: string;
}>;
export declare const __testing: {
resolveBindingConversationFromCommand: typeof resolveBindingConversationFromCommand;
};