aether_core/events/
user_message.rs1use llm::{ChatMessage, ContentBlock, ReasoningEffort, StreamingModelProvider, ToolDefinition};
2
3#[derive(Debug)]
8pub enum Command {
9 UserCommand(UserCommand),
10 AgentCommand(AgentCommand),
11}
12
13impl Command {
14 pub fn text(text: impl Into<String>) -> Self {
15 Self::with_content(vec![ContentBlock::text(text)])
16 }
17
18 pub fn with_content(content: Vec<ContentBlock>) -> Self {
19 Self::UserCommand(UserCommand::Text { content })
20 }
21
22 pub fn cancel() -> Self {
23 Self::UserCommand(UserCommand::Cancel)
24 }
25
26 pub fn clear_context() -> Self {
27 Self::UserCommand(UserCommand::ClearContext)
28 }
29
30 pub fn agent(command: AgentCommand) -> Self {
31 Self::AgentCommand(command)
32 }
33}
34
35pub enum UserCommand {
37 Text { content: Vec<ContentBlock> },
38 Cancel,
39 ClearContext,
40}
41
42impl std::fmt::Debug for UserCommand {
43 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44 match self {
45 UserCommand::Text { content } => f.debug_struct("Text").field("content_blocks", &content.len()).finish(),
46 UserCommand::Cancel => write!(f, "Cancel"),
47 UserCommand::ClearContext => write!(f, "ClearContext"),
48 }
49 }
50}
51
52pub enum AgentCommand {
58 SwitchModel(Box<dyn StreamingModelProvider>),
59 UpdateTools(Vec<ToolDefinition>),
60 UpdateMcpInstructions { server: String, body: Option<String> },
61 SetReasoningEffort(Option<ReasoningEffort>),
62 ReplaceConversation(Vec<ChatMessage>),
63}
64
65impl std::fmt::Debug for AgentCommand {
66 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67 match self {
68 AgentCommand::SwitchModel(provider) => {
69 f.debug_tuple("SwitchModel").field(&provider.display_name()).finish()
70 }
71 AgentCommand::UpdateTools(tools) => f.debug_tuple("UpdateTools").field(&tools.len()).finish(),
72 AgentCommand::UpdateMcpInstructions { server, body } => f
73 .debug_struct("UpdateMcpInstructions")
74 .field("server", server)
75 .field("body_len", &body.as_ref().map(String::len))
76 .finish(),
77 AgentCommand::SetReasoningEffort(effort) => f.debug_tuple("SetReasoningEffort").field(effort).finish(),
78 AgentCommand::ReplaceConversation(messages) => {
79 f.debug_tuple("ReplaceConversation").field(&messages.len()).finish()
80 }
81 }
82 }
83}