zeph_commands/handlers/
model.rs1use std::future::Future;
7use std::pin::Pin;
8
9use crate::context::CommandContext;
10use crate::{CommandError, CommandHandler, CommandOutput, SlashCategory};
11
12pub struct ModelCommand;
18
19impl CommandHandler<CommandContext<'_>> for ModelCommand {
20 fn name(&self) -> &'static str {
21 "/model"
22 }
23
24 fn description(&self) -> &'static str {
25 "Show or switch the active model"
26 }
27
28 fn args_hint(&self) -> &'static str {
29 "[id|refresh]"
30 }
31
32 fn category(&self) -> SlashCategory {
33 SlashCategory::Configuration
34 }
35
36 fn handle<'a>(
37 &'a self,
38 ctx: &'a mut CommandContext<'_>,
39 args: &'a str,
40 ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>> {
41 Box::pin(async move {
42 let result = ctx.agent.handle_model(args).await;
43 if result.is_empty() {
44 Ok(CommandOutput::Silent)
45 } else {
46 Ok(CommandOutput::Message(result))
47 }
48 })
49 }
50}
51
52pub struct ProviderCommand;
57
58impl CommandHandler<CommandContext<'_>> for ProviderCommand {
59 fn name(&self) -> &'static str {
60 "/provider"
61 }
62
63 fn description(&self) -> &'static str {
64 "List configured providers or switch to one by name"
65 }
66
67 fn args_hint(&self) -> &'static str {
68 "[name|status]"
69 }
70
71 fn category(&self) -> SlashCategory {
72 SlashCategory::Configuration
73 }
74
75 fn handle<'a>(
76 &'a self,
77 ctx: &'a mut CommandContext<'_>,
78 args: &'a str,
79 ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>> {
80 Box::pin(async move {
81 let result = ctx.agent.handle_provider(args).await;
82 if result.is_empty() {
83 Ok(CommandOutput::Silent)
84 } else {
85 Ok(CommandOutput::Message(result))
86 }
87 })
88 }
89}