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
 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}
195
196message DiskBasedDiagnosticsUpdated {
197    uint64 project_id = 1;
198}
199
200message GetChannels {}
201
202message GetChannelsResponse {
203    repeated Channel channels = 1;
204}
205
206message JoinChannel {
207    uint64 channel_id = 1;
208}
209
210message JoinChannelResponse {
211    repeated ChannelMessage messages = 1;
212    bool done = 2;
213}
214
215message LeaveChannel {
216    uint64 channel_id = 1;
217}
218
219message GetUsers {
220    repeated uint64 user_ids = 1;
221}
222
223message GetUsersResponse {
224    repeated User users = 1;
225}
226
227message SendChannelMessage {
228    uint64 channel_id = 1;
229    string body = 2;
230    Nonce nonce = 3;
231}
232
233message SendChannelMessageResponse {
234    ChannelMessage message = 1;
235}
236
237message ChannelMessageSent {
238    uint64 channel_id = 1;
239    ChannelMessage message = 2;
240}
241
242message GetChannelMessages {
243    uint64 channel_id = 1;
244    uint64 before_message_id = 2;
245}
246
247message GetChannelMessagesResponse {
248    repeated ChannelMessage messages = 1;
249    bool done = 2;
250}
251
252message UpdateContacts {
253    repeated Contact contacts = 1;
254}
255
256// Entities
257
258message Collaborator {
259    uint32 peer_id = 1;
260    uint32 replica_id = 2;
261    uint64 user_id = 3;
262}
263
264message User {
265    uint64 id = 1;
266    string github_login = 2;
267    string avatar_url = 3;
268}
269
270message Worktree {
271    uint64 id = 1;
272    string root_name = 2;
273    repeated Entry entries = 3;
274    repeated DiagnosticSummary diagnostic_summaries = 4;
275}
276
277message Entry {
278    uint64 id = 1;
279    bool is_dir = 2;
280    string path = 3;
281    uint64 inode = 4;
282    Timestamp mtime = 5;
283    bool is_symlink = 6;
284    bool is_ignored = 7;
285}
286
287message Buffer {
288    uint64 id = 1;
289    string visible_text = 2;
290    string deleted_text = 3;
291    repeated BufferFragment fragments = 4;
292    repeated UndoMapEntry undo_map = 5;
293    repeated VectorClockEntry version = 6;
294    repeated SelectionSet selections = 7;
295    repeated Diagnostic diagnostics = 8;
296    uint32 lamport_timestamp = 9;
297    repeated Operation deferred_operations = 10;
298}
299
300message BufferFragment {
301    uint32 replica_id = 1;
302    uint32 local_timestamp = 2;
303    uint32 lamport_timestamp = 3;
304    uint32 insertion_offset = 4;
305    uint32 len = 5;
306    bool visible =  6;
307    repeated VectorClockEntry deletions = 7;
308    repeated VectorClockEntry max_undos = 8;
309}
310
311message SelectionSet {
312    uint32 replica_id = 1;
313    repeated Selection selections = 2;
314    uint32 lamport_timestamp = 3;
315}
316
317message Selection {
318    uint64 id = 1;
319    Anchor start = 2;
320    Anchor end = 3;
321    bool reversed = 4;
322}
323
324message Anchor {
325    uint32 replica_id = 1;
326    uint32 local_timestamp = 2;
327    uint64 offset = 3;
328    Bias bias = 4;
329}
330
331enum Bias {
332    Left = 0;
333    Right = 1;
334}
335
336message UpdateDiagnostics {
337    uint32 replica_id = 1;
338    uint32 lamport_timestamp = 2;
339    repeated Diagnostic diagnostics = 3;
340}
341
342message Diagnostic {
343    Anchor start = 1;
344    Anchor end = 2;
345    Severity severity = 3;
346    string message = 4;
347    optional string code = 5;
348    uint64 group_id = 6;
349    bool is_primary = 7;
350    bool is_valid = 8;
351    bool is_disk_based = 9;
352
353    enum Severity {
354        None = 0;
355        Error = 1;
356        Warning = 2;
357        Information = 3;
358        Hint = 4;
359    }
360}
361
362message Operation {
363    oneof variant {
364        Edit edit = 1;
365        Undo undo = 2;
366        UpdateSelections update_selections = 3;
367        UpdateDiagnostics update_diagnostics = 4;
368    }
369
370    message Edit {
371        uint32 replica_id = 1;
372        uint32 local_timestamp = 2;
373        uint32 lamport_timestamp = 3;
374        repeated VectorClockEntry version = 4;
375        repeated Range ranges = 5;
376        optional string new_text = 6;
377    }
378
379    message Undo {
380        uint32 replica_id = 1;
381        uint32 local_timestamp = 2;
382        uint32 lamport_timestamp = 3;
383        repeated Range ranges = 4;
384        repeated VectorClockEntry version = 5;
385        repeated UndoCount counts = 6;
386    }
387
388    message UpdateSelections {
389        uint32 replica_id = 1;
390        uint32 lamport_timestamp = 3;
391        repeated Selection selections = 4;
392    }
393}
394
395message UndoMapEntry {
396    uint32 replica_id = 1;
397    uint32 local_timestamp = 2;
398    repeated UndoCount counts = 3;
399}
400
401message UndoCount {
402    uint32 replica_id = 1;
403    uint32 local_timestamp = 2;
404    uint32 count = 3;
405}
406
407message VectorClockEntry {
408    uint32 replica_id = 1;
409    uint32 timestamp = 2;
410}
411
412message Timestamp {
413    uint64 seconds = 1;
414    uint32 nanos = 2;
415}
416
417message Range {
418    uint64 start = 1;
419    uint64 end = 2;
420}
421
422message Nonce {
423    uint64 upper_half = 1;
424    uint64 lower_half = 2;
425}
426
427message Channel {
428    uint64 id = 1;
429    string name = 2;
430}
431
432message ChannelMessage {
433    uint64 id = 1;
434    string body = 2;
435    uint64 timestamp = 3;
436    uint64 sender_id = 4;
437    Nonce nonce = 5;
438}
439
440message Contact {
441    uint64 user_id = 1;
442    repeated ProjectMetadata projects = 2;
443}
444
445message ProjectMetadata {
446    uint64 id = 1;
447    bool is_shared = 2;
448    repeated string worktree_root_names = 3;
449    repeated uint64 guests = 4;
450}