types.go
 1  package fileserver
 2  
 3  // === Request messages (Server → Agent via WebSocket) ===
 4  
 5  type FileListRequest struct {
 6  	Type      string `json:"type"`
 7  	RequestID string `json:"requestId"`
 8  	Path      string `json:"path"`
 9  }
10  
11  type FileDownloadRequest struct {
12  	Type      string `json:"type"`
13  	RequestID string `json:"requestId"`
14  	Path      string `json:"path"`
15  }
16  
17  type FileUploadStartRequest struct {
18  	Type      string `json:"type"`
19  	RequestID string `json:"requestId"`
20  	Path      string `json:"path"`
21  	Size      int64  `json:"size"`
22  }
23  
24  type FileUploadChunkRequest struct {
25  	Type      string `json:"type"`
26  	RequestID string `json:"requestId"`
27  	Index     int    `json:"index"`
28  	Data      string `json:"data"`
29  	Final     bool   `json:"final"`
30  }
31  
32  type FileMkdirRequest struct {
33  	Type      string `json:"type"`
34  	RequestID string `json:"requestId"`
35  	Path      string `json:"path"`
36  }
37  
38  type FileDeleteRequest struct {
39  	Type      string `json:"type"`
40  	RequestID string `json:"requestId"`
41  	Path      string `json:"path"`
42  }
43  
44  type FileRenameRequest struct {
45  	Type      string `json:"type"`
46  	RequestID string `json:"requestId"`
47  	OldPath   string `json:"oldPath"`
48  	NewPath   string `json:"newPath"`
49  }
50  
51  // === Response messages (Agent → Server via WebSocket) ===
52  
53  type FileListResponse struct {
54  	Type      string     `json:"type"`
55  	RequestID string     `json:"requestId"`
56  	Success   bool       `json:"success"`
57  	Error     string     `json:"error,omitempty"`
58  	Path      string     `json:"path"`
59  	Entries   []FileInfo `json:"entries,omitempty"`
60  }
61  
62  type FileInfo struct {
63  	Name    string `json:"name"`
64  	IsDir   bool   `json:"isDir"`
65  	Size    int64  `json:"size"`
66  	Mode    string `json:"mode"`
67  	ModTime int64  `json:"modTime"`
68  }
69  
70  type FileDownloadChunk struct {
71  	Type      string `json:"type"`
72  	RequestID string `json:"requestId"`
73  	Index     int    `json:"index"`
74  	Data      string `json:"data"`
75  	Final     bool   `json:"final"`
76  	TotalSize int64  `json:"totalSize"`
77  }
78  
79  type FileOperationResult struct {
80  	Type      string `json:"type"`
81  	RequestID string `json:"requestId"`
82  	Success   bool   `json:"success"`
83  	Error     string `json:"error,omitempty"`
84  }