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