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