zed.proto

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