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 GetDefinition get_definition = 17;
24 GetDefinitionResponse get_definition_response = 18;
25
26 RegisterWorktree register_worktree = 19;
27 UnregisterWorktree unregister_worktree = 20;
28 ShareWorktree share_worktree = 21;
29 UpdateWorktree update_worktree = 22;
30 UpdateDiagnosticSummary update_diagnostic_summary = 23;
31 DiskBasedDiagnosticsUpdating disk_based_diagnostics_updating = 24;
32 DiskBasedDiagnosticsUpdated disk_based_diagnostics_updated = 25;
33
34 OpenBuffer open_buffer = 26;
35 OpenBufferResponse open_buffer_response = 27;
36 CloseBuffer close_buffer = 28;
37 UpdateBuffer update_buffer = 29;
38 UpdateBufferFile update_buffer_file = 30;
39 SaveBuffer save_buffer = 31;
40 BufferSaved buffer_saved = 32;
41 BufferReloaded buffer_reloaded = 33;
42 FormatBuffer format_buffer = 34;
43 GetCompletions get_completions = 35;
44 GetCompletionsResponse get_completions_response = 36;
45 ApplyCompletionAdditionalEdits apply_completion_additional_edits = 37;
46 ApplyCompletionAdditionalEditsResponse apply_completion_additional_edits_response = 38;
47 GetCodeActions get_code_actions = 39;
48 GetCodeActionsResponse get_code_actions_response = 40;
49 ApplyCodeAction apply_code_action = 41;
50 ApplyCodeActionResponse apply_code_action_response = 42;
51
52 GetChannels get_channels = 43;
53 GetChannelsResponse get_channels_response = 44;
54 JoinChannel join_channel = 45;
55 JoinChannelResponse join_channel_response = 46;
56 LeaveChannel leave_channel = 47;
57 SendChannelMessage send_channel_message = 48;
58 SendChannelMessageResponse send_channel_message_response = 49;
59 ChannelMessageSent channel_message_sent = 50;
60 GetChannelMessages get_channel_messages = 51;
61 GetChannelMessagesResponse get_channel_messages_response = 52;
62
63 UpdateContacts update_contacts = 53;
64
65 GetUsers get_users = 54;
66 GetUsersResponse get_users_response = 55;
67 }
68}
69
70// Messages
71
72message Ping {}
73
74message Ack {}
75
76message Error {
77 string message = 1;
78}
79
80message RegisterProject {}
81
82message RegisterProjectResponse {
83 uint64 project_id = 1;
84}
85
86message UnregisterProject {
87 uint64 project_id = 1;
88}
89
90message ShareProject {
91 uint64 project_id = 1;
92}
93
94message UnshareProject {
95 uint64 project_id = 1;
96}
97
98message JoinProject {
99 uint64 project_id = 1;
100}
101
102message JoinProjectResponse {
103 uint32 replica_id = 1;
104 repeated Worktree worktrees = 2;
105 repeated Collaborator collaborators = 3;
106}
107
108message LeaveProject {
109 uint64 project_id = 1;
110}
111
112message RegisterWorktree {
113 uint64 project_id = 1;
114 uint64 worktree_id = 2;
115 string root_name = 3;
116 repeated string authorized_logins = 4;
117}
118
119message UnregisterWorktree {
120 uint64 project_id = 1;
121 uint64 worktree_id = 2;
122}
123
124message ShareWorktree {
125 uint64 project_id = 1;
126 Worktree worktree = 2;
127}
128
129message UpdateWorktree {
130 uint64 project_id = 1;
131 uint64 worktree_id = 2;
132 string root_name = 3;
133 repeated Entry updated_entries = 4;
134 repeated uint64 removed_entries = 5;
135}
136
137message AddProjectCollaborator {
138 uint64 project_id = 1;
139 Collaborator collaborator = 2;
140}
141
142message RemoveProjectCollaborator {
143 uint64 project_id = 1;
144 uint32 peer_id = 2;
145}
146
147message GetDefinition {
148 uint64 project_id = 1;
149 uint64 buffer_id = 2;
150 Anchor position = 3;
151 }
152
153message GetDefinitionResponse {
154 repeated Definition definitions = 1;
155}
156
157message Definition {
158 Buffer buffer = 1;
159 Anchor target_start = 2;
160 Anchor target_end = 3;
161}
162
163message OpenBuffer {
164 uint64 project_id = 1;
165 uint64 worktree_id = 2;
166 string path = 3;
167}
168
169message OpenBufferResponse {
170 Buffer buffer = 1;
171}
172
173message CloseBuffer {
174 uint64 project_id = 1;
175 uint64 buffer_id = 2;
176}
177
178message UpdateBuffer {
179 uint64 project_id = 1;
180 uint64 buffer_id = 2;
181 repeated Operation operations = 3;
182}
183
184message UpdateBufferFile {
185 uint64 project_id = 1;
186 uint64 buffer_id = 2;
187 File file = 3;
188}
189
190message SaveBuffer {
191 uint64 project_id = 1;
192 uint64 buffer_id = 2;
193}
194
195message BufferSaved {
196 uint64 project_id = 1;
197 uint64 buffer_id = 2;
198 repeated VectorClockEntry version = 3;
199 Timestamp mtime = 4;
200}
201
202message BufferReloaded {
203 uint64 project_id = 1;
204 uint64 buffer_id = 2;
205 repeated VectorClockEntry version = 3;
206 Timestamp mtime = 4;
207}
208
209message FormatBuffer {
210 uint64 project_id = 1;
211 uint64 buffer_id = 2;
212}
213
214message GetCompletions {
215 uint64 project_id = 1;
216 uint64 buffer_id = 2;
217 Anchor position = 3;
218}
219
220message GetCompletionsResponse {
221 repeated Completion completions = 1;
222}
223
224message ApplyCompletionAdditionalEdits {
225 uint64 project_id = 1;
226 uint64 buffer_id = 2;
227 Completion completion = 3;
228}
229
230message ApplyCompletionAdditionalEditsResponse {
231 Transaction transaction = 1;
232}
233
234message Completion {
235 Anchor old_start = 1;
236 Anchor old_end = 2;
237 string new_text = 3;
238 bytes lsp_completion = 4;
239}
240
241message GetCodeActions {
242 uint64 project_id = 1;
243 uint64 buffer_id = 2;
244 Anchor position = 3;
245}
246
247message GetCodeActionsResponse {
248 repeated CodeAction actions = 1;
249}
250
251message ApplyCodeAction {
252 uint64 project_id = 1;
253 uint64 buffer_id = 2;
254 CodeAction action = 3;
255}
256
257message ApplyCodeActionResponse {
258 ProjectTransaction transaction = 1;
259}
260
261message CodeAction {
262 Anchor position = 1;
263 bytes lsp_action = 2;
264}
265
266message ProjectTransaction {
267 repeated Buffer buffers = 1;
268 repeated Transaction transactions = 2;
269}
270
271message Transaction {
272 LocalTimestamp id = 1;
273 repeated LocalTimestamp edit_ids = 2;
274 repeated VectorClockEntry start = 3;
275 repeated VectorClockEntry end = 4;
276 repeated Range ranges = 5;
277}
278
279message LocalTimestamp {
280 uint32 replica_id = 1;
281 uint32 value = 2;
282}
283
284message UpdateDiagnosticSummary {
285 uint64 project_id = 1;
286 uint64 worktree_id = 2;
287 DiagnosticSummary summary = 3;
288}
289
290message DiagnosticSummary {
291 string path = 1;
292 uint32 error_count = 2;
293 uint32 warning_count = 3;
294 uint32 info_count = 4;
295 uint32 hint_count = 5;
296}
297
298message DiskBasedDiagnosticsUpdating {
299 uint64 project_id = 1;
300}
301
302message DiskBasedDiagnosticsUpdated {
303 uint64 project_id = 1;
304}
305
306message GetChannels {}
307
308message GetChannelsResponse {
309 repeated Channel channels = 1;
310}
311
312message JoinChannel {
313 uint64 channel_id = 1;
314}
315
316message JoinChannelResponse {
317 repeated ChannelMessage messages = 1;
318 bool done = 2;
319}
320
321message LeaveChannel {
322 uint64 channel_id = 1;
323}
324
325message GetUsers {
326 repeated uint64 user_ids = 1;
327}
328
329message GetUsersResponse {
330 repeated User users = 1;
331}
332
333message SendChannelMessage {
334 uint64 channel_id = 1;
335 string body = 2;
336 Nonce nonce = 3;
337}
338
339message SendChannelMessageResponse {
340 ChannelMessage message = 1;
341}
342
343message ChannelMessageSent {
344 uint64 channel_id = 1;
345 ChannelMessage message = 2;
346}
347
348message GetChannelMessages {
349 uint64 channel_id = 1;
350 uint64 before_message_id = 2;
351}
352
353message GetChannelMessagesResponse {
354 repeated ChannelMessage messages = 1;
355 bool done = 2;
356}
357
358message UpdateContacts {
359 repeated Contact contacts = 1;
360}
361
362// Entities
363
364message Collaborator {
365 uint32 peer_id = 1;
366 uint32 replica_id = 2;
367 uint64 user_id = 3;
368}
369
370message User {
371 uint64 id = 1;
372 string github_login = 2;
373 string avatar_url = 3;
374}
375
376message Worktree {
377 uint64 id = 1;
378 string root_name = 2;
379 repeated Entry entries = 3;
380 repeated DiagnosticSummary diagnostic_summaries = 4;
381 bool weak = 5;
382}
383
384message File {
385 uint64 worktree_id = 1;
386 optional uint64 entry_id = 2;
387 string path = 3;
388 Timestamp mtime = 4;
389}
390
391message Entry {
392 uint64 id = 1;
393 bool is_dir = 2;
394 string path = 3;
395 uint64 inode = 4;
396 Timestamp mtime = 5;
397 bool is_symlink = 6;
398 bool is_ignored = 7;
399}
400
401message Buffer {
402 oneof variant {
403 uint64 id = 1;
404 BufferState state = 2;
405 }
406}
407
408message BufferState {
409 uint64 id = 1;
410 optional File file = 2;
411 string base_text = 3;
412 repeated Operation operations = 4;
413 repeated SelectionSet selections = 5;
414 repeated Diagnostic diagnostics = 6;
415 repeated string completion_triggers = 7;
416}
417
418message BufferFragment {
419 uint32 replica_id = 1;
420 uint32 local_timestamp = 2;
421 uint32 lamport_timestamp = 3;
422 uint32 insertion_offset = 4;
423 uint32 len = 5;
424 bool visible = 6;
425 repeated VectorClockEntry deletions = 7;
426 repeated VectorClockEntry max_undos = 8;
427}
428
429message SelectionSet {
430 uint32 replica_id = 1;
431 repeated Selection selections = 2;
432 uint32 lamport_timestamp = 3;
433}
434
435message Selection {
436 uint64 id = 1;
437 Anchor start = 2;
438 Anchor end = 3;
439 bool reversed = 4;
440}
441
442message Anchor {
443 uint32 replica_id = 1;
444 uint32 local_timestamp = 2;
445 uint64 offset = 3;
446 Bias bias = 4;
447}
448
449enum Bias {
450 Left = 0;
451 Right = 1;
452}
453
454message UpdateDiagnostics {
455 uint32 replica_id = 1;
456 uint32 lamport_timestamp = 2;
457 repeated Diagnostic diagnostics = 3;
458}
459
460message Diagnostic {
461 Anchor start = 1;
462 Anchor end = 2;
463 Severity severity = 3;
464 string message = 4;
465 optional string code = 5;
466 uint64 group_id = 6;
467 bool is_primary = 7;
468 bool is_valid = 8;
469 bool is_disk_based = 9;
470
471 enum Severity {
472 None = 0;
473 Error = 1;
474 Warning = 2;
475 Information = 3;
476 Hint = 4;
477 }
478}
479
480message Operation {
481 oneof variant {
482 Edit edit = 1;
483 Undo undo = 2;
484 UpdateSelections update_selections = 3;
485 UpdateDiagnostics update_diagnostics = 4;
486 UpdateCompletionTriggers update_completion_triggers = 5;
487 }
488
489 message Edit {
490 uint32 replica_id = 1;
491 uint32 local_timestamp = 2;
492 uint32 lamport_timestamp = 3;
493 repeated VectorClockEntry version = 4;
494 repeated Range ranges = 5;
495 optional string new_text = 6;
496 }
497
498 message Undo {
499 uint32 replica_id = 1;
500 uint32 local_timestamp = 2;
501 uint32 lamport_timestamp = 3;
502 repeated Range ranges = 4;
503 repeated VectorClockEntry version = 5;
504 repeated UndoCount counts = 6;
505 }
506
507 message UpdateSelections {
508 uint32 replica_id = 1;
509 uint32 lamport_timestamp = 2;
510 repeated Selection selections = 3;
511 }
512
513 message UpdateCompletionTriggers {
514 uint32 replica_id = 1;
515 uint32 lamport_timestamp = 2;
516 repeated string triggers = 3;
517 }
518}
519
520message UndoMapEntry {
521 uint32 replica_id = 1;
522 uint32 local_timestamp = 2;
523 repeated UndoCount counts = 3;
524}
525
526message UndoCount {
527 uint32 replica_id = 1;
528 uint32 local_timestamp = 2;
529 uint32 count = 3;
530}
531
532message VectorClockEntry {
533 uint32 replica_id = 1;
534 uint32 timestamp = 2;
535}
536
537message Timestamp {
538 uint64 seconds = 1;
539 uint32 nanos = 2;
540}
541
542message Range {
543 uint64 start = 1;
544 uint64 end = 2;
545}
546
547message Nonce {
548 uint64 upper_half = 1;
549 uint64 lower_half = 2;
550}
551
552message Channel {
553 uint64 id = 1;
554 string name = 2;
555}
556
557message ChannelMessage {
558 uint64 id = 1;
559 string body = 2;
560 uint64 timestamp = 3;
561 uint64 sender_id = 4;
562 Nonce nonce = 5;
563}
564
565message Contact {
566 uint64 user_id = 1;
567 repeated ProjectMetadata projects = 2;
568}
569
570message ProjectMetadata {
571 uint64 id = 1;
572 bool is_shared = 2;
573 repeated string worktree_root_names = 3;
574 repeated uint64 guests = 4;
575}