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