walrus_protocol/message/server.rs
1//! Messages sent by the gateway to the client.
2
3use crate::message::{AgentSummary, McpServerSummary};
4use compact_str::CompactString;
5use serde::{Deserialize, Serialize};
6
7/// Messages sent by the gateway to the client.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(tag = "type", rename_all = "snake_case")]
10pub enum ServerMessage {
11 /// Complete response from an agent.
12 Response {
13 /// Source agent identifier.
14 agent: CompactString,
15 /// Response content.
16 content: String,
17 },
18 /// Start of a streamed response.
19 StreamStart {
20 /// Source agent identifier.
21 agent: CompactString,
22 },
23 /// A chunk of streamed content.
24 StreamChunk {
25 /// Chunk content.
26 content: String,
27 },
28 /// End of a streamed response.
29 StreamEnd {
30 /// Source agent identifier.
31 agent: CompactString,
32 },
33 /// Session cleared for an agent.
34 SessionCleared {
35 /// Agent whose session was cleared.
36 agent: CompactString,
37 },
38 /// List of registered agents.
39 AgentList {
40 /// Agent summaries.
41 agents: Vec<AgentSummary>,
42 },
43 /// Detailed agent information.
44 AgentDetail {
45 /// Agent name.
46 name: CompactString,
47 /// Agent description.
48 description: CompactString,
49 /// Registered tool names.
50 tools: Vec<CompactString>,
51 /// Skill tags.
52 skill_tags: Vec<CompactString>,
53 /// System prompt.
54 system_prompt: String,
55 },
56 /// List of memory entries.
57 MemoryList {
58 /// Key-value pairs.
59 entries: Vec<(String, String)>,
60 },
61 /// A single memory entry.
62 MemoryEntry {
63 /// Memory key.
64 key: String,
65 /// Memory value (None if not found).
66 value: Option<String>,
67 },
68 /// Download has started for a model.
69 DownloadStart {
70 /// Model being downloaded.
71 model: CompactString,
72 },
73 /// A file download has started.
74 DownloadFileStart {
75 /// Filename within the repo.
76 filename: String,
77 /// Total size in bytes.
78 size: u64,
79 },
80 /// Download progress for current file (delta, not cumulative).
81 DownloadProgress {
82 /// Bytes downloaded in this chunk (delta).
83 bytes: u64,
84 },
85 /// A file download has completed.
86 DownloadFileEnd {
87 /// Filename within the repo.
88 filename: String,
89 },
90 /// All downloads complete for a model.
91 DownloadEnd {
92 /// Model that was downloaded.
93 model: CompactString,
94 },
95 /// Error response.
96 Error {
97 /// Error code.
98 code: u16,
99 /// Error message.
100 message: String,
101 },
102 /// Skills were reloaded successfully.
103 SkillsReloaded {
104 /// Number of skills loaded.
105 count: usize,
106 },
107 /// MCP server added successfully.
108 McpAdded {
109 /// Server name.
110 name: CompactString,
111 /// Tools provided by this server.
112 tools: Vec<CompactString>,
113 },
114 /// MCP server removed successfully.
115 McpRemoved {
116 /// Server name.
117 name: CompactString,
118 /// Tools that were removed.
119 tools: Vec<CompactString>,
120 },
121 /// MCP servers reloaded from config.
122 McpReloaded {
123 /// Connected servers after reload.
124 servers: Vec<McpServerSummary>,
125 },
126 /// List of connected MCP servers.
127 McpServerList {
128 /// Connected servers.
129 servers: Vec<McpServerSummary>,
130 },
131 /// Pong response to client ping.
132 Pong,
133}