zeph_commands/handlers/
scheduler.rs1use std::future::Future;
7use std::pin::Pin;
8
9use crate::context::CommandContext;
10use crate::{CommandError, CommandHandler, CommandOutput, SlashCategory};
11
12pub struct SchedulerCommand;
16
17impl CommandHandler<CommandContext<'_>> for SchedulerCommand {
18 fn name(&self) -> &'static str {
19 "/scheduler"
20 }
21
22 fn description(&self) -> &'static str {
23 "List scheduled tasks"
24 }
25
26 fn args_hint(&self) -> &'static str {
27 "[list]"
28 }
29
30 fn category(&self) -> SlashCategory {
31 SlashCategory::Advanced
32 }
33
34 fn feature_gate(&self) -> Option<&'static str> {
35 Some("scheduler")
36 }
37
38 fn handle<'a>(
39 &'a self,
40 ctx: &'a mut CommandContext<'_>,
41 args: &'a str,
42 ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>> {
43 Box::pin(async move {
44 if !args.is_empty() && args != "list" {
45 return Ok(CommandOutput::Message(
46 "Unknown /scheduler subcommand. Available: /scheduler list".to_owned(),
47 ));
48 }
49 match ctx.agent.list_scheduled_tasks().await? {
50 Some(msg) if msg.is_empty() => Ok(CommandOutput::Silent),
51 Some(msg) => Ok(CommandOutput::Message(msg)),
52 None => Ok(CommandOutput::Message(
53 "Scheduler is not enabled or list_tasks tool is unavailable.".to_owned(),
54 )),
55 }
56 })
57 }
58}