1syntax = "proto3";
2package zed.messages;
3
4message Envelope {
5 uint32 id = 1;
6 optional uint32 responding_to = 2;
7 optional uint32 original_sender_id = 3;
8 oneof payload {
9 Ack ack = 4;
10 Error error = 5;
11 Ping ping = 6;
12 ShareWorktree share_worktree = 7;
13 ShareWorktreeResponse share_worktree_response = 8;
14 JoinWorktree join_worktree = 9;
15 JoinWorktreeResponse join_worktree_response = 10;
16 UpdateWorktree update_worktree = 11;
17 CloseWorktree close_worktree = 12;
18 OpenBuffer open_buffer = 13;
19 OpenBufferResponse open_buffer_response = 14;
20 CloseBuffer close_buffer = 15;
21 UpdateBuffer update_buffer = 16;
22 SaveBuffer save_buffer = 17;
23 BufferSaved buffer_saved = 18;
24 AddPeer add_peer = 19;
25 RemovePeer remove_peer = 20;
26 GetChannels get_channels = 21;
27 GetChannelsResponse get_channels_response = 22;
28 GetUsers get_users = 23;
29 GetUsersResponse get_users_response = 24;
30 JoinChannel join_channel = 25;
31 JoinChannelResponse join_channel_response = 26;
32 LeaveChannel leave_channel = 27;
33 SendChannelMessage send_channel_message = 28;
34 SendChannelMessageResponse send_channel_message_response = 29;
35 ChannelMessageSent channel_message_sent = 30;
36 GetChannelMessages get_channel_messages = 31;
37 GetChannelMessagesResponse get_channel_messages_response = 32;
38 OpenWorktree open_worktree = 33;
39 OpenWorktreeResponse open_worktree_response = 34;
40 UnshareWorktree unshare_worktree = 35;
41 UpdateCollaborators update_collaborators = 36;
42 LeaveWorktree leave_worktree = 37;
43 }
44}
45
46// Messages
47
48message Ping {}
49
50message Ack {}
51
52message Error {
53 string message = 1;
54}
55
56message OpenWorktree {
57 string root_name = 1;
58 repeated string collaborator_logins = 2;
59}
60
61message OpenWorktreeResponse {
62 uint64 worktree_id = 1;
63}
64
65message ShareWorktree {
66 Worktree worktree = 1;
67}
68
69message ShareWorktreeResponse {}
70
71message UnshareWorktree {
72 uint64 worktree_id = 1;
73}
74
75message JoinWorktree {
76 uint64 worktree_id = 1;
77}
78
79message LeaveWorktree {
80 uint64 worktree_id = 1;
81}
82
83message JoinWorktreeResponse {
84 Worktree worktree = 2;
85 uint32 replica_id = 3;
86 repeated Peer peers = 4;
87}
88
89message UpdateWorktree {
90 uint64 worktree_id = 1;
91 repeated Entry updated_entries = 2;
92 repeated uint64 removed_entries = 3;
93}
94
95message CloseWorktree {
96 uint64 worktree_id = 1;
97}
98
99message AddPeer {
100 uint64 worktree_id = 1;
101 Peer peer = 2;
102}
103
104message RemovePeer {
105 uint64 worktree_id = 1;
106 uint32 peer_id = 2;
107}
108
109message OpenBuffer {
110 uint64 worktree_id = 1;
111 string path = 2;
112}
113
114message OpenBufferResponse {
115 Buffer buffer = 1;
116}
117
118message CloseBuffer {
119 uint64 worktree_id = 1;
120 uint64 buffer_id = 2;
121}
122
123message UpdateBuffer {
124 uint64 worktree_id = 1;
125 uint64 buffer_id = 2;
126 repeated Operation operations = 3;
127}
128
129message SaveBuffer {
130 uint64 worktree_id = 1;
131 uint64 buffer_id = 2;
132}
133
134message BufferSaved {
135 uint64 worktree_id = 1;
136 uint64 buffer_id = 2;
137 repeated VectorClockEntry version = 3;
138 Timestamp mtime = 4;
139}
140
141message GetChannels {}
142
143message GetChannelsResponse {
144 repeated Channel channels = 1;
145}
146
147message JoinChannel {
148 uint64 channel_id = 1;
149}
150
151message JoinChannelResponse {
152 repeated ChannelMessage messages = 1;
153 bool done = 2;
154}
155
156message LeaveChannel {
157 uint64 channel_id = 1;
158}
159
160message GetUsers {
161 repeated uint64 user_ids = 1;
162}
163
164message GetUsersResponse {
165 repeated User users = 1;
166}
167
168message SendChannelMessage {
169 uint64 channel_id = 1;
170 string body = 2;
171 Nonce nonce = 3;
172}
173
174message SendChannelMessageResponse {
175 ChannelMessage message = 1;
176}
177
178message ChannelMessageSent {
179 uint64 channel_id = 1;
180 ChannelMessage message = 2;
181}
182
183message GetChannelMessages {
184 uint64 channel_id = 1;
185 uint64 before_message_id = 2;
186}
187
188message GetChannelMessagesResponse {
189 repeated ChannelMessage messages = 1;
190 bool done = 2;
191}
192
193message UpdateCollaborators {
194 repeated Collaborator collaborators = 1;
195}
196
197// Entities
198
199message Peer {
200 uint32 peer_id = 1;
201 uint32 replica_id = 2;
202}
203
204message User {
205 uint64 id = 1;
206 string github_login = 2;
207 string avatar_url = 3;
208}
209
210message Worktree {
211 uint64 id = 1;
212 string root_name = 2;
213 repeated Entry entries = 3;
214}
215
216message Entry {
217 uint64 id = 1;
218 bool is_dir = 2;
219 string path = 3;
220 uint64 inode = 4;
221 Timestamp mtime = 5;
222 bool is_symlink = 6;
223 bool is_ignored = 7;
224}
225
226message Buffer {
227 uint64 id = 1;
228 string content = 2;
229 repeated Operation.Edit history = 3;
230 repeated SelectionSet selections = 4;
231 DiagnosticSet diagnostics = 5;
232}
233
234message SelectionSet {
235 uint32 replica_id = 1;
236 uint32 lamport_timestamp = 2;
237 bool is_active = 3;
238 repeated VectorClockEntry version = 4;
239 repeated Selection selections = 5;
240}
241
242message Selection {
243 uint64 id = 1;
244 uint64 start = 2;
245 uint64 end = 3;
246 bool reversed = 4;
247}
248
249message DiagnosticSet {
250 repeated VectorClockEntry version = 1;
251 repeated Diagnostic diagnostics = 2;
252}
253
254message Diagnostic {
255 uint64 start = 1;
256 uint64 end = 2;
257 Severity severity = 3;
258 string message = 4;
259 enum Severity {
260 None = 0;
261 Error = 1;
262 Warning = 2;
263 Information = 3;
264 Hint = 4;
265 }
266}
267
268
269
270message Operation {
271 oneof variant {
272 Edit edit = 1;
273 Undo undo = 2;
274 UpdateSelections update_selections = 3;
275 RemoveSelections remove_selections = 4;
276 SetActiveSelections set_active_selections = 5;
277 DiagnosticSet update_diagnostics = 6;
278 }
279
280 message Edit {
281 uint32 replica_id = 1;
282 uint32 local_timestamp = 2;
283 uint32 lamport_timestamp = 3;
284 repeated VectorClockEntry version = 4;
285 repeated Range ranges = 5;
286 optional string new_text = 6;
287 }
288
289 message Undo {
290 uint32 replica_id = 1;
291 uint32 local_timestamp = 2;
292 uint32 lamport_timestamp = 3;
293 repeated Range ranges = 4;
294 repeated VectorClockEntry version = 5;
295 repeated UndoCount counts = 6;
296 }
297
298 message UndoCount {
299 uint32 replica_id = 1;
300 uint32 local_timestamp = 2;
301 uint32 count = 3;
302 }
303
304 message UpdateSelections {
305 uint32 replica_id = 1;
306 uint32 local_timestamp = 2;
307 uint32 lamport_timestamp = 3;
308 repeated VectorClockEntry version = 4;
309 repeated Selection selections = 5;
310 }
311
312 message RemoveSelections {
313 uint32 replica_id = 1;
314 uint32 local_timestamp = 2;
315 uint32 lamport_timestamp = 3;
316 }
317
318 message SetActiveSelections {
319 uint32 replica_id = 1;
320 optional uint32 local_timestamp = 2;
321 uint32 lamport_timestamp = 3;
322 }
323}
324
325message VectorClockEntry {
326 uint32 replica_id = 1;
327 uint32 timestamp = 2;
328}
329
330message Timestamp {
331 uint64 seconds = 1;
332 uint32 nanos = 2;
333}
334
335message Range {
336 uint64 start = 1;
337 uint64 end = 2;
338}
339
340message Nonce {
341 uint64 upper_half = 1;
342 uint64 lower_half = 2;
343}
344
345message Channel {
346 uint64 id = 1;
347 string name = 2;
348}
349
350message ChannelMessage {
351 uint64 id = 1;
352 string body = 2;
353 uint64 timestamp = 3;
354 uint64 sender_id = 4;
355 Nonce nonce = 5;
356}
357
358message Collaborator {
359 uint64 user_id = 1;
360 repeated WorktreeMetadata worktrees = 2;
361}
362
363message WorktreeMetadata {
364 uint64 id = 1;
365 string root_name = 2;
366 bool is_shared = 3;
367 repeated uint64 guests = 4;
368}