Skip to main content

matrixcode_core/command/handlers/
config.rs

1//! /config 命令处理器
2
3use std::future::Future;
4use std::pin::Pin;
5
6use crate::command::{BackendContext, Command};
7
8pub struct Config;
9
10impl Command for Config {
11    fn name(&self) -> &'static str {
12        "config"
13    }
14
15    fn help(&self) -> Option<&'static str> {
16        Some("显示当前配置")
17    }
18
19    fn execute<'a>(
20        &'a self,
21        ctx: &'a mut BackendContext<'_>,
22    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>> {
23        Box::pin(async move {
24            let mut info = "⚙️ 当前配置:\n\n".to_string();
25            info.push_str(&format!(
26                "Provider: {}\n",
27                ctx.config.provider.as_deref().unwrap_or("auto")
28            ));
29            info.push_str(&format!("Model: {}\n", ctx.model));
30            info.push_str(&format!("Think: {}\n", ctx.config.think));
31            info.push_str(&format!("Max Tokens: {}\n", ctx.config.max_tokens));
32            let _ = ctx
33                .event_tx
34                .send(crate::AgentEvent::progress(info, None))
35                .await;
36            false
37        })
38    }
39}