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        ShareWorktree share_worktree = 7;
 13        ShareWorktreeResponse share_worktree_response = 8;
 14        JoinWorktree join_worktree = 9;
 15        JoinWorktreeResponse join_worktree_response = 10;
 16        UpdateWorktree update_worktree = 11;
 17        CloseWorktree close_worktree = 12;
 18        OpenBuffer open_buffer = 13;
 19        OpenBufferResponse open_buffer_response = 14;
 20        CloseBuffer close_buffer = 15;
 21        UpdateBuffer update_buffer = 16;
 22        SaveBuffer save_buffer = 17;
 23        BufferSaved buffer_saved = 18;
 24        AddCollaborator add_collaborator = 19;
 25        RemoveCollaborator remove_collaborator = 20;
 26        GetChannels get_channels = 21;
 27        GetChannelsResponse get_channels_response = 22;
 28        GetUsers get_users = 23;
 29        GetUsersResponse get_users_response = 24;
 30        JoinChannel join_channel = 25;
 31        JoinChannelResponse join_channel_response = 26;
 32        LeaveChannel leave_channel = 27;
 33        SendChannelMessage send_channel_message = 28;
 34        SendChannelMessageResponse send_channel_message_response = 29;
 35        ChannelMessageSent channel_message_sent = 30;
 36        GetChannelMessages get_channel_messages = 31;
 37        GetChannelMessagesResponse get_channel_messages_response = 32;
 38        OpenWorktree open_worktree = 33;
 39        OpenWorktreeResponse open_worktree_response = 34;
 40        UnshareWorktree unshare_worktree = 35;
 41        UpdateContacts update_contacts = 36;
 42        LeaveWorktree leave_worktree = 37;
 43        UpdateDiagnosticSummary update_diagnostic_summary = 38;
 44    }
 45}
 46
 47// Messages
 48
 49message Ping {}
 50
 51message Ack {}
 52
 53message Error {
 54    string message = 1;
 55}
 56
 57message OpenWorktree {
 58    string root_name = 1;
 59    repeated string authorized_logins = 2;
 60}
 61
 62message OpenWorktreeResponse {
 63    uint64 worktree_id = 1;
 64}
 65
 66message ShareWorktree {
 67    Worktree worktree = 1;
 68}
 69
 70message ShareWorktreeResponse {}
 71
 72message UnshareWorktree {
 73    uint64 worktree_id = 1;
 74}
 75
 76message JoinWorktree {
 77    uint64 worktree_id = 1;
 78}
 79
 80message LeaveWorktree {
 81    uint64 worktree_id = 1;
 82}
 83
 84message JoinWorktreeResponse {
 85    Worktree worktree = 2;
 86    uint32 replica_id = 3;
 87    repeated Collaborator collaborators = 4;
 88}
 89
 90message UpdateWorktree {
 91    uint64 worktree_id = 1;
 92    repeated Entry updated_entries = 2;
 93    repeated uint64 removed_entries = 3;
 94}
 95
 96message CloseWorktree {
 97    uint64 worktree_id = 1;
 98}
 99
100message AddCollaborator {
101    uint64 worktree_id = 1;
102    Collaborator collaborator = 2;
103}
104
105message RemoveCollaborator {
106    uint64 worktree_id = 1;
107    uint32 peer_id = 2;
108}
109
110message OpenBuffer {
111    uint64 worktree_id = 1;
112    string path = 2;
113}
114
115message OpenBufferResponse {
116    Buffer buffer = 1;
117}
118
119message CloseBuffer {
120    uint64 worktree_id = 1;
121    uint64 buffer_id = 2;
122}
123
124message UpdateBuffer {
125    uint64 worktree_id = 1;
126    uint64 buffer_id = 2;
127    repeated Operation operations = 3;
128}
129
130message SaveBuffer {
131    uint64 worktree_id = 1;
132    uint64 buffer_id = 2;
133}
134
135message BufferSaved {
136    uint64 worktree_id = 1;
137    uint64 buffer_id = 2;
138    repeated VectorClockEntry version = 3;
139    Timestamp mtime = 4;
140}
141
142message UpdateDiagnosticSummary {
143    uint64 worktree_id = 1;
144    string path = 2;
145    uint32 error_count = 3;
146    uint32 warning_count = 4;
147}
148
149message GetChannels {}
150
151message GetChannelsResponse {
152    repeated Channel channels = 1;
153}
154
155message JoinChannel {
156    uint64 channel_id = 1;
157}
158
159message JoinChannelResponse {
160    repeated ChannelMessage messages = 1;
161    bool done = 2;
162}
163
164message LeaveChannel {
165    uint64 channel_id = 1;
166}
167
168message GetUsers {
169    repeated uint64 user_ids = 1;
170}
171
172message GetUsersResponse {
173    repeated User users = 1;
174}
175
176message SendChannelMessage {
177    uint64 channel_id = 1;
178    string body = 2;
179    Nonce nonce = 3;
180}
181
182message SendChannelMessageResponse {
183    ChannelMessage message = 1;
184}
185
186message ChannelMessageSent {
187    uint64 channel_id = 1;
188    ChannelMessage message = 2;
189}
190
191message GetChannelMessages {
192    uint64 channel_id = 1;
193    uint64 before_message_id = 2;
194}
195
196message GetChannelMessagesResponse {
197    repeated ChannelMessage messages = 1;
198    bool done = 2;
199}
200
201message UpdateContacts {
202    repeated Contact contacts = 1;
203}
204
205// Entities
206
207message Collaborator {
208    uint32 peer_id = 1;
209    uint32 replica_id = 2;
210    uint64 user_id = 3;
211}
212
213message User {
214    uint64 id = 1;
215    string github_login = 2;
216    string avatar_url = 3;
217}
218
219message Worktree {
220    uint64 id = 1;
221    string root_name = 2;
222    repeated Entry entries = 3;
223}
224
225message Entry {
226    uint64 id = 1;
227    bool is_dir = 2;
228    string path = 3;
229    uint64 inode = 4;
230    Timestamp mtime = 5;
231    bool is_symlink = 6;
232    bool is_ignored = 7;
233}
234
235message Buffer {
236    uint64 id = 1;
237    string content = 2;
238    repeated Operation.Edit history = 3;
239    repeated SelectionSet selections = 4;
240    repeated Diagnostic diagnostics = 5;
241}
242
243message SelectionSet {
244    uint32 replica_id = 1;
245    repeated Selection selections = 2;
246}
247
248message Selection {
249    uint64 id = 1;
250    Anchor start = 2;
251    Anchor end = 3;
252    bool reversed = 4;
253}
254
255message Anchor {
256    uint32 replica_id = 1;
257    uint32 local_timestamp = 2;
258    uint64 offset = 3;
259    Bias bias = 4;
260}
261
262enum Bias {
263    Left = 0;
264    Right = 1;
265}
266
267message UpdateDiagnostics {
268    uint32 replica_id = 1;
269    uint32 lamport_timestamp = 2;
270    repeated Diagnostic diagnostics = 3;
271}
272
273message Diagnostic {
274    Anchor start = 1;
275    Anchor end = 2;
276    Severity severity = 3;
277    string message = 4;
278    uint64 group_id = 5;
279    bool is_primary = 6;
280    optional string code = 7;
281    optional string source = 8;
282    enum Severity {
283        None = 0;
284        Error = 1;
285        Warning = 2;
286        Information = 3;
287        Hint = 4;
288    }
289}
290
291message Operation {
292    oneof variant {
293        Edit edit = 1;
294        Undo undo = 2;
295        UpdateSelections update_selections = 3;
296        RemoveSelections remove_selections = 4;
297        UpdateDiagnostics update_diagnostics = 5;
298    }
299
300    message Edit {
301        uint32 replica_id = 1;
302        uint32 local_timestamp = 2;
303        uint32 lamport_timestamp = 3;
304        repeated VectorClockEntry version = 4;
305        repeated Range ranges = 5;
306        optional string new_text = 6;
307    }
308
309    message Undo {
310        uint32 replica_id = 1;
311        uint32 local_timestamp = 2;
312        uint32 lamport_timestamp = 3;
313        repeated Range ranges = 4;
314        repeated VectorClockEntry version = 5;
315        repeated UndoCount counts = 6;
316    }
317
318    message UndoCount {
319        uint32 replica_id = 1;
320        uint32 local_timestamp = 2;
321        uint32 count = 3;
322    }
323
324    message UpdateSelections {
325        uint32 replica_id = 1;
326        uint32 lamport_timestamp = 3;
327        repeated Selection selections = 4;
328    }
329
330    message RemoveSelections {
331        uint32 replica_id = 1;
332        uint32 lamport_timestamp = 3;
333    }
334}
335
336message VectorClockEntry {
337    uint32 replica_id = 1;
338    uint32 timestamp = 2;
339}
340
341message Timestamp {
342    uint64 seconds = 1;
343    uint32 nanos = 2;
344}
345
346message Range {
347    uint64 start = 1;
348    uint64 end = 2;
349}
350
351message Nonce {
352    uint64 upper_half = 1;
353    uint64 lower_half = 2;
354}
355
356message Channel {
357    uint64 id = 1;
358    string name = 2;
359}
360
361message ChannelMessage {
362    uint64 id = 1;
363    string body = 2;
364    uint64 timestamp = 3;
365    uint64 sender_id = 4;
366    Nonce nonce = 5;
367}
368
369message Contact {
370    uint64 user_id = 1;
371    repeated WorktreeMetadata worktrees = 2;
372}
373
374message WorktreeMetadata {
375    uint64 id = 1;
376    string root_name = 2;
377    bool is_shared = 3;
378    repeated uint64 guests = 4;
379}