1+ // Shared protocol between daemon and server
2+
13use serde:: { Deserialize , Serialize } ;
24
3- /// Protocol messages exchanged between agent and daemon
5+ /// Snapshot metadata (shared between daemon and server)
6+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
7+ pub struct SnapshotInfo {
8+ pub id : String ,
9+ pub created_at : u64 , // Unix timestamp in milliseconds
10+ pub message : String ,
11+ pub tags : Vec < String > ,
12+ pub file_count : usize ,
13+ pub total_size : u64 ,
14+ }
15+
416#[ derive( Debug , Clone , Serialize , Deserialize ) ]
517#[ serde( tag = "type" , rename_all = "snake_case" ) ]
618pub enum Message {
7- // Connection management
819 Register {
920 daemon_id : String ,
1021 metadata : DaemonMetadata ,
@@ -15,8 +26,6 @@ pub enum Message {
1526 } ,
1627 Heartbeat ,
1728 Pong ,
18-
19- // Command execution (simple mode)
2029 ExecuteCommand {
2130 request_id : String ,
2231 command : String ,
@@ -38,8 +47,6 @@ pub enum Message {
3847 request_id : String ,
3948 error : String ,
4049 } ,
41-
42- // Interactive session (PTY mode)
4350 NewSession {
4451 session_id : String ,
4552 rows : u16 ,
@@ -74,14 +81,12 @@ pub enum Message {
7481 session_id : String ,
7582 exit_code : i32 ,
7683 } ,
77-
78- // File transfer
7984 FileUploadStart {
8085 request_id : String ,
8186 path : String ,
8287 total_size : u64 ,
8388 #[ serde( default ) ]
84- mode : Option < u32 > , // Unix file permissions
89+ mode : Option < u32 > ,
8590 } ,
8691 FileUploadChunk {
8792 request_id : String ,
@@ -109,7 +114,6 @@ pub enum Message {
109114 request_id : String ,
110115 error : String ,
111116 } ,
112-
113117 // Snapshot operations
114118 CreateSnapshot {
115119 request_id : String ,
@@ -138,7 +142,7 @@ pub enum Message {
138142 } ,
139143 SnapshotList {
140144 request_id : String ,
141- snapshots : Vec < serde_json :: Value > ,
145+ snapshots : Vec < SnapshotInfo > ,
142146 } ,
143147 FindSnapshotByTag {
144148 request_id : String ,
@@ -150,7 +154,7 @@ pub enum Message {
150154 } ,
151155 SnapshotDetails {
152156 request_id : String ,
153- snapshot : Option < serde_json :: Value > ,
157+ snapshot : Option < SnapshotInfo > ,
154158 } ,
155159 DeleteSnapshot {
156160 request_id : String ,
@@ -163,8 +167,6 @@ pub enum Message {
163167 request_id : String ,
164168 error : String ,
165169 } ,
166-
167- // Error handling
168170 Error {
169171 message : String ,
170172 #[ serde( default ) ]
@@ -184,14 +186,13 @@ pub struct DaemonMetadata {
184186}
185187
186188fn default_timeout ( ) -> u64 {
187- 300 // 5 minutes
189+ 300
188190}
189191
190192fn default_term ( ) -> String {
191193 "xterm-256color" . to_string ( )
192194}
193195
194- // Base64 encoding for binary data in JSON
195196mod base64_bytes {
196197 use serde:: { Deserialize , Deserializer , Serializer } ;
197198
@@ -209,7 +210,6 @@ mod base64_bytes {
209210 . map_err ( serde:: de:: Error :: custom)
210211 }
211212}
212-
213213#[ cfg( test) ]
214214mod tests {
215215 use super :: * ;
0 commit comments