Skip to main content

CommandHandler

Trait CommandHandler 

Source
pub trait CommandHandler<Ctx: ?Sized>: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn description(&self) -> &'static str;
    fn category(&self) -> SlashCategory;
    fn handle<'a>(
        &'a self,
        ctx: &'a mut Ctx,
        args: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>>;

    // Provided methods
    fn args_hint(&self) -> &'static str { ... }
    fn feature_gate(&self) -> Option<&'static str> { ... }
}
Expand description

A slash command handler that can be registered with CommandRegistry.

Implementors must be Send + Sync because the registry is constructed at agent initialization time and handlers may be invoked from async contexts.

§Object safety

The handle method uses Pin<Box<dyn Future>> instead of async fn to remain object-safe, enabling the registry to store Box<dyn CommandHandler<Ctx>>. Slash commands are user-initiated so the box allocation is negligible.

Required Methods§

Source

fn name(&self) -> &'static str

Command name including the leading slash, e.g. "/help".

Must be unique per registry. Used as the dispatch key.

Source

fn description(&self) -> &'static str

One-line description shown in /help output.

Source

fn category(&self) -> SlashCategory

Category for grouping in /help.

Source

fn handle<'a>( &'a self, ctx: &'a mut Ctx, args: &'a str, ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>>

Execute the command.

§Arguments
  • ctx: Typed access to agent subsystems.
  • args: Trimmed text after the command name. Empty string when no args given.
§Errors

Returns Err(CommandError) when the command fails. The dispatch site logs and reports the error to the user.

Provided Methods§

Source

fn args_hint(&self) -> &'static str

Argument hint shown after the command name in help, e.g. "[path]".

Return an empty string if the command takes no arguments.

Source

fn feature_gate(&self) -> Option<&'static str>

Feature gate label, if this command is conditionally compiled.

Implementors§

Source§

impl CommandHandler<CommandContext<'_>> for AgentCommand

Source§

impl CommandHandler<CommandContext<'_>> for CompactCommand

Source§

impl CommandHandler<CommandContext<'_>> for NewConversationCommand

Source§

impl CommandHandler<CommandContext<'_>> for RecapCommand

Source§

impl CommandHandler<CommandContext<'_>> for DebugDumpCommand

Source§

impl CommandHandler<CommandContext<'_>> for DumpFormatCommand

Source§

impl CommandHandler<CommandContext<'_>> for LogCommand

Source§

impl CommandHandler<CommandContext<'_>> for ExperimentCommand

Source§

impl CommandHandler<CommandContext<'_>> for HelpCommand

Source§

impl CommandHandler<CommandContext<'_>> for LspCommand

Source§

impl CommandHandler<CommandContext<'_>> for McpCommand

Source§

impl CommandHandler<CommandContext<'_>> for GraphCommand

Source§

impl CommandHandler<CommandContext<'_>> for GuidelinesCommand

Source§

impl CommandHandler<CommandContext<'_>> for MemoryCommand

Source§

impl CommandHandler<CommandContext<'_>> for CacheStatsCommand

Source§

impl CommandHandler<CommandContext<'_>> for ImageCommand

Source§

impl CommandHandler<CommandContext<'_>> for ModelCommand

Source§

impl CommandHandler<CommandContext<'_>> for ProviderCommand

Source§

impl CommandHandler<CommandContext<'_>> for PlanCommand

Source§

impl CommandHandler<CommandContext<'_>> for PolicyCommand

Source§

impl CommandHandler<CommandContext<'_>> for SchedulerCommand

Source§

impl CommandHandler<CommandContext<'_>> for ClearCommand

Source§

impl CommandHandler<CommandContext<'_>> for ClearQueueCommand

Source§

impl CommandHandler<CommandContext<'_>> for ExitCommand

Source§

impl CommandHandler<CommandContext<'_>> for QuitCommand

Source§

impl CommandHandler<CommandContext<'_>> for ResetCommand

Source§

impl CommandHandler<CommandContext<'_>> for FeedbackCommand

Source§

impl CommandHandler<CommandContext<'_>> for SkillCommand

Source§

impl CommandHandler<CommandContext<'_>> for SkillsCommand

Source§

impl CommandHandler<CommandContext<'_>> for FocusCommand

Source§

impl CommandHandler<CommandContext<'_>> for GuardrailCommand

Source§

impl CommandHandler<CommandContext<'_>> for SideQuestCommand

Source§

impl CommandHandler<CommandContext<'_>> for StatusCommand