109 lines
3.5 KiB
Rust
109 lines
3.5 KiB
Rust
pub mod adapter;
|
|
pub mod adapters;
|
|
pub mod context;
|
|
pub mod handler;
|
|
pub mod handlers;
|
|
pub mod response;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// 统一命令枚举 - 与渠道无关
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(tag = "type", rename_all = "snake_case")]
|
|
pub enum Command {
|
|
/// 创建新话题(在同一个 Session 内)
|
|
CreateSession { title: Option<String> },
|
|
/// 保存当前话题内容到 Markdown 文件
|
|
SaveTopic {
|
|
filepath: Option<String>,
|
|
include_subagents: bool,
|
|
},
|
|
/// 保存会话内容到 Markdown 文件
|
|
SaveSession {
|
|
filepath: Option<String>,
|
|
include_all: bool,
|
|
include_subagents: bool,
|
|
},
|
|
/// 列出当前 Session 的所有话题
|
|
ListSessions { include_archived: bool },
|
|
/// 加载指定话题
|
|
LoadTopic { topic_id: String },
|
|
/// 切换到指定话题(清理当前历史并加载新话题)
|
|
SwitchTopic { topic_id: String },
|
|
/// 获取当前话题信息
|
|
GetCurrentSession,
|
|
/// 显示所有支持的命令
|
|
Help,
|
|
/// 列出所有可用通道
|
|
ListChannels,
|
|
/// 列出指定通道的所有会话
|
|
ListSessionsByChannel {
|
|
channel_name: String,
|
|
include_archived: bool,
|
|
},
|
|
/// 列出 Session 的所有 Topics
|
|
ListTopics { session_id: String },
|
|
/// 加载子智能体任务的消息历史
|
|
LoadTaskMessages { task_id: String },
|
|
/// 列出所有定时任务
|
|
ListSchedulerJobs,
|
|
/// 加载指定 channel + chat_id 的对话消息
|
|
LoadChatMessages {
|
|
channel: String,
|
|
chat_id: String,
|
|
},
|
|
/// 删除指定话题
|
|
DeleteTopic { topic_id: String },
|
|
/// 停止当前正在执行的 Agent
|
|
StopExecution,
|
|
/// 列出所有记忆
|
|
ListMemories,
|
|
/// 创建新记忆
|
|
CreateMemory {
|
|
namespace: String,
|
|
key: String,
|
|
content: String,
|
|
},
|
|
/// 更新已有记忆
|
|
UpdateMemory {
|
|
id: String,
|
|
content: String,
|
|
},
|
|
/// 删除记忆
|
|
DeleteMemory { id: String },
|
|
/// 列出所有技能
|
|
ListSkills,
|
|
/// 列出当前 Todo 列表
|
|
ListTodos,
|
|
}
|
|
|
|
impl Command {
|
|
/// 获取命令名称(用于日志和调试)
|
|
pub fn name(&self) -> &'static str {
|
|
match self {
|
|
Command::CreateSession { .. } => "create_session",
|
|
Command::SaveTopic { .. } => "save_topic",
|
|
Command::SaveSession { .. } => "save_session",
|
|
Command::ListSessions { .. } => "list_sessions",
|
|
Command::LoadTopic { .. } => "load_topic",
|
|
Command::SwitchTopic { .. } => "switch_topic",
|
|
Command::GetCurrentSession => "get_current_session",
|
|
Command::Help => "help",
|
|
Command::ListChannels => "list_channels",
|
|
Command::ListSessionsByChannel { .. } => "list_sessions_by_channel",
|
|
Command::ListTopics { .. } => "list_topics",
|
|
Command::LoadTaskMessages { .. } => "load_task_messages",
|
|
Command::ListSchedulerJobs => "list_scheduler_jobs",
|
|
Command::LoadChatMessages { .. } => "load_chat_messages",
|
|
Command::DeleteTopic { .. } => "delete_topic",
|
|
Command::StopExecution => "stop_execution",
|
|
Command::ListMemories => "list_memories",
|
|
Command::CreateMemory { .. } => "create_memory",
|
|
Command::UpdateMemory { .. } => "update_memory",
|
|
Command::DeleteMemory { .. } => "delete_memory",
|
|
Command::ListSkills => "list_skills",
|
|
Command::ListTodos => "list_todos",
|
|
}
|
|
}
|
|
}
|