use compact_str::CompactString;
use serde::{Deserialize, Serialize};
pub mod codec;
pub const PROTOCOL_VERSION: &str = "0.1";
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ClientMessage {
Send {
agent: CompactString,
content: String,
},
Stream {
agent: CompactString,
content: String,
},
ClearSession {
agent: CompactString,
},
ListAgents,
AgentInfo {
agent: CompactString,
},
ListMemory,
GetMemory {
key: String,
},
Download {
model: CompactString,
},
ReloadSkills,
McpAdd {
name: CompactString,
command: String,
#[serde(default)]
args: Vec<String>,
#[serde(default)]
env: std::collections::BTreeMap<String, String>,
},
McpRemove {
name: CompactString,
},
McpReload,
McpList,
Ping,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ServerMessage {
Response {
agent: CompactString,
content: String,
},
StreamStart {
agent: CompactString,
},
StreamChunk {
content: String,
},
StreamEnd {
agent: CompactString,
},
SessionCleared {
agent: CompactString,
},
AgentList {
agents: Vec<AgentSummary>,
},
AgentDetail {
name: CompactString,
description: CompactString,
tools: Vec<CompactString>,
skill_tags: Vec<CompactString>,
system_prompt: String,
},
MemoryList {
entries: Vec<(String, String)>,
},
MemoryEntry {
key: String,
value: Option<String>,
},
DownloadStart {
model: CompactString,
},
DownloadFileStart {
filename: String,
size: u64,
},
DownloadProgress {
bytes: u64,
},
DownloadFileEnd {
filename: String,
},
DownloadEnd {
model: CompactString,
},
Error {
code: u16,
message: String,
},
SkillsReloaded {
count: usize,
},
McpAdded {
name: CompactString,
tools: Vec<CompactString>,
},
McpRemoved {
name: CompactString,
tools: Vec<CompactString>,
},
McpReloaded {
servers: Vec<McpServerSummary>,
},
McpServerList {
servers: Vec<McpServerSummary>,
},
Pong,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct McpServerSummary {
pub name: CompactString,
pub tools: Vec<CompactString>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentSummary {
pub name: CompactString,
pub description: CompactString,
}