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
13 RegisterProject register_project = 7;
14 RegisterProjectResponse register_project_response = 8;
15 UnregisterProject unregister_project = 9;
16 ShareProject share_project = 10;
17 UnshareProject unshare_project = 11;
18 JoinProject join_project = 12;
19 JoinProjectResponse join_project_response = 13;
20 LeaveProject leave_project = 14;
21 AddProjectCollaborator add_project_collaborator = 15;
22 RemoveProjectCollaborator remove_project_collaborator = 16;
23
24 RegisterWorktree register_worktree = 17;
25 UnregisterWorktree unregister_worktree = 18;
26 ShareWorktree share_worktree = 19;
27 UpdateWorktree update_worktree = 20;
28 UpdateDiagnosticSummary update_diagnostic_summary = 21;
29 DiskBasedDiagnosticsUpdating disk_based_diagnostics_updating = 22;
30 DiskBasedDiagnosticsUpdated disk_based_diagnostics_updated = 23;
31
32 OpenBuffer open_buffer = 24;
33 OpenBufferResponse open_buffer_response = 25;
34 CloseBuffer close_buffer = 26;
35 UpdateBuffer update_buffer = 27;
36 SaveBuffer save_buffer = 28;
37 BufferSaved buffer_saved = 29;
38
39 GetChannels get_channels = 30;
40 GetChannelsResponse get_channels_response = 31;
41 JoinChannel join_channel = 32;
42 JoinChannelResponse join_channel_response = 33;
43 LeaveChannel leave_channel = 34;
44 SendChannelMessage send_channel_message = 35;
45 SendChannelMessageResponse send_channel_message_response = 36;
46 ChannelMessageSent channel_message_sent = 37;
47 GetChannelMessages get_channel_messages = 38;
48 GetChannelMessagesResponse get_channel_messages_response = 39;
49
50 UpdateContacts update_contacts = 40;
51
52 GetUsers get_users = 41;
53 GetUsersResponse get_users_response = 42;
54 }
55}
56
57// Messages
58
59message Ping {}
60
61message Ack {}
62
63message Error {
64 string message = 1;
65}
66
67message RegisterProject {}
68
69message RegisterProjectResponse {
70 uint64 project_id = 1;
71}
72
73message UnregisterProject {
74 uint64 project_id = 1;
75}
76
77message ShareProject {
78 uint64 project_id = 1;
79}
80
81message UnshareProject {
82 uint64 project_id = 1;
83}
84
85message JoinProject {
86 uint64 project_id = 1;
87}
88
89message JoinProjectResponse {
90 uint32 replica_id = 2;
91 repeated Worktree worktrees = 3;
92 repeated Collaborator collaborators = 4;
93}
94
95message LeaveProject {
96 uint64 project_id = 1;
97}
98
99message RegisterWorktree {
100 uint64 project_id = 1;
101 uint64 worktree_id = 2;
102 string root_name = 3;
103 repeated string authorized_logins = 4;
104}
105
106message UnregisterWorktree {
107 uint64 project_id = 1;
108 uint64 worktree_id = 2;
109}
110
111message ShareWorktree {
112 uint64 project_id = 1;
113 Worktree worktree = 2;
114}
115
116message UpdateWorktree {
117 uint64 project_id = 1;
118 uint64 worktree_id = 2;
119 string root_name = 3;
120 repeated Entry updated_entries = 4;
121 repeated uint64 removed_entries = 5;
122}
123
124message AddProjectCollaborator {
125 uint64 project_id = 1;
126 Collaborator collaborator = 2;
127}
128
129message RemoveProjectCollaborator {
130 uint64 project_id = 1;
131 uint32 peer_id = 2;
132}
133
134message OpenBuffer {
135 uint64 project_id = 1;
136 uint64 worktree_id = 2;
137 string path = 3;
138}
139
140message OpenBufferResponse {
141 Buffer buffer = 1;
142}
143
144message CloseBuffer {
145 uint64 project_id = 1;
146 uint64 worktree_id = 2;
147 uint64 buffer_id = 3;
148}
149
150message UpdateBuffer {
151 uint64 project_id = 1;
152 uint64 worktree_id = 2;
153 uint64 buffer_id = 3;
154 repeated Operation operations = 4;
155}
156
157message SaveBuffer {
158 uint64 project_id = 1;
159 uint64 worktree_id = 2;
160 uint64 buffer_id = 3;
161}
162
163message BufferSaved {
164 uint64 project_id = 1;
165 uint64 worktree_id = 2;
166 uint64 buffer_id = 3;
167 repeated VectorClockEntry version = 4;
168 Timestamp mtime = 5;
169}
170
171message UpdateDiagnosticSummary {
172 uint64 project_id = 1;
173 uint64 worktree_id = 2;
174 DiagnosticSummary summary = 3;
175}
176
177message DiagnosticSummary {
178 string path = 3;
179 uint32 error_count = 4;
180 uint32 warning_count = 5;
181 uint32 info_count = 6;
182 uint32 hint_count = 7;
183}
184
185message DiskBasedDiagnosticsUpdating {
186 uint64 project_id = 1;
187 uint64 worktree_id = 2;
188}
189
190message DiskBasedDiagnosticsUpdated {
191 uint64 project_id = 1;
192 uint64 worktree_id = 2;
193}
194
195message GetChannels {}
196
197message GetChannelsResponse {
198 repeated Channel channels = 1;
199}
200
201message JoinChannel {
202 uint64 channel_id = 1;
203}
204
205message JoinChannelResponse {
206 repeated ChannelMessage messages = 1;
207 bool done = 2;
208}
209
210message LeaveChannel {
211 uint64 channel_id = 1;
212}
213
214message GetUsers {
215 repeated uint64 user_ids = 1;
216}
217
218message GetUsersResponse {
219 repeated User users = 1;
220}
221
222message SendChannelMessage {
223 uint64 channel_id = 1;
224 string body = 2;
225 Nonce nonce = 3;
226}
227
228message SendChannelMessageResponse {
229 ChannelMessage message = 1;
230}
231
232message ChannelMessageSent {
233 uint64 channel_id = 1;
234 ChannelMessage message = 2;
235}
236
237message GetChannelMessages {
238 uint64 channel_id = 1;
239 uint64 before_message_id = 2;
240}
241
242message GetChannelMessagesResponse {
243 repeated ChannelMessage messages = 1;
244 bool done = 2;
245}
246
247message UpdateContacts {
248 repeated Contact contacts = 1;
249}
250
251// Entities
252
253message Collaborator {
254 uint32 peer_id = 1;
255 uint32 replica_id = 2;
256 uint64 user_id = 3;
257}
258
259message User {
260 uint64 id = 1;
261 string github_login = 2;
262 string avatar_url = 3;
263}
264
265message Worktree {
266 uint64 id = 1;
267 string root_name = 2;
268 repeated Entry entries = 3;
269 repeated DiagnosticSummary diagnostic_summaries = 4;
270}
271
272message Entry {
273 uint64 id = 1;
274 bool is_dir = 2;
275 string path = 3;
276 uint64 inode = 4;
277 Timestamp mtime = 5;
278 bool is_symlink = 6;
279 bool is_ignored = 7;
280}
281
282message Buffer {
283 uint64 id = 1;
284 string visible_text = 2;
285 string deleted_text = 3;
286 repeated BufferFragment fragments = 4;
287 repeated UndoMapEntry undo_map = 5;
288 repeated VectorClockEntry version = 6;
289 repeated SelectionSet selections = 7;
290 repeated Diagnostic diagnostics = 8;
291 uint32 lamport_timestamp = 9;
292 repeated Operation deferred_operations = 10;
293}
294
295message BufferFragment {
296 uint32 replica_id = 1;
297 uint32 local_timestamp = 2;
298 uint32 lamport_timestamp = 3;
299 uint32 insertion_offset = 4;
300 uint32 len = 5;
301 bool visible = 6;
302 repeated VectorClockEntry deletions = 7;
303 repeated VectorClockEntry max_undos = 8;
304}
305
306message SelectionSet {
307 uint32 replica_id = 1;
308 repeated Selection selections = 2;
309 uint32 lamport_timestamp = 3;
310}
311
312message Selection {
313 uint64 id = 1;
314 Anchor start = 2;
315 Anchor end = 3;
316 bool reversed = 4;
317}
318
319message Anchor {
320 uint32 replica_id = 1;
321 uint32 local_timestamp = 2;
322 uint64 offset = 3;
323 Bias bias = 4;
324}
325
326enum Bias {
327 Left = 0;
328 Right = 1;
329}
330
331message UpdateDiagnostics {
332 uint32 replica_id = 1;
333 uint32 lamport_timestamp = 2;
334 repeated Diagnostic diagnostics = 3;
335}
336
337message Diagnostic {
338 Anchor start = 1;
339 Anchor end = 2;
340 Severity severity = 3;
341 string message = 4;
342 optional string code = 5;
343 uint64 group_id = 6;
344 bool is_primary = 7;
345 bool is_valid = 8;
346 bool is_disk_based = 9;
347
348 enum Severity {
349 None = 0;
350 Error = 1;
351 Warning = 2;
352 Information = 3;
353 Hint = 4;
354 }
355}
356
357message Operation {
358 oneof variant {
359 Edit edit = 1;
360 Undo undo = 2;
361 UpdateSelections update_selections = 3;
362 UpdateDiagnostics update_diagnostics = 4;
363 }
364
365 message Edit {
366 uint32 replica_id = 1;
367 uint32 local_timestamp = 2;
368 uint32 lamport_timestamp = 3;
369 repeated VectorClockEntry version = 4;
370 repeated Range ranges = 5;
371 optional string new_text = 6;
372 }
373
374 message Undo {
375 uint32 replica_id = 1;
376 uint32 local_timestamp = 2;
377 uint32 lamport_timestamp = 3;
378 repeated Range ranges = 4;
379 repeated VectorClockEntry version = 5;
380 repeated UndoCount counts = 6;
381 }
382
383 message UpdateSelections {
384 uint32 replica_id = 1;
385 uint32 lamport_timestamp = 3;
386 repeated Selection selections = 4;
387 }
388}
389
390message UndoMapEntry {
391 uint32 replica_id = 1;
392 uint32 local_timestamp = 2;
393 repeated UndoCount counts = 3;
394}
395
396message UndoCount {
397 uint32 replica_id = 1;
398 uint32 local_timestamp = 2;
399 uint32 count = 3;
400}
401
402message VectorClockEntry {
403 uint32 replica_id = 1;
404 uint32 timestamp = 2;
405}
406
407message Timestamp {
408 uint64 seconds = 1;
409 uint32 nanos = 2;
410}
411
412message Range {
413 uint64 start = 1;
414 uint64 end = 2;
415}
416
417message Nonce {
418 uint64 upper_half = 1;
419 uint64 lower_half = 2;
420}
421
422message Channel {
423 uint64 id = 1;
424 string name = 2;
425}
426
427message ChannelMessage {
428 uint64 id = 1;
429 string body = 2;
430 uint64 timestamp = 3;
431 uint64 sender_id = 4;
432 Nonce nonce = 5;
433}
434
435message Contact {
436 uint64 user_id = 1;
437 repeated ProjectMetadata projects = 2;
438}
439
440message ProjectMetadata {
441 uint64 id = 1;
442 bool is_shared = 2;
443 repeated string worktree_root_names = 3;
444 repeated uint64 guests = 4;
445}