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