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        RequestJoinProject request_join_project = 11;
 18        RespondToJoinProjectRequest respond_to_join_project_request = 12;
 19        JoinProjectRequestCancelled join_project_request_cancelled = 13;
 20        JoinProject join_project = 14;
 21        JoinProjectResponse join_project_response = 15;
 22        LeaveProject leave_project = 16;
 23        AddProjectCollaborator add_project_collaborator = 17;
 24        RemoveProjectCollaborator remove_project_collaborator = 18;
 25        ProjectUnshared project_unshared = 19;
 26
 27        GetDefinition get_definition = 20;
 28        GetDefinitionResponse get_definition_response = 21;
 29        GetReferences get_references = 22;
 30        GetReferencesResponse get_references_response = 23;
 31        GetDocumentHighlights get_document_highlights = 24;
 32        GetDocumentHighlightsResponse get_document_highlights_response = 25;
 33        GetProjectSymbols get_project_symbols = 26;
 34        GetProjectSymbolsResponse get_project_symbols_response = 27;
 35        OpenBufferForSymbol open_buffer_for_symbol = 28;
 36        OpenBufferForSymbolResponse open_buffer_for_symbol_response = 29;
 37
 38        RegisterWorktree register_worktree = 30;
 39        UnregisterWorktree unregister_worktree = 31;
 40        UpdateWorktree update_worktree = 32;
 41
 42        CreateProjectEntry create_project_entry = 33;
 43        RenameProjectEntry rename_project_entry = 34;
 44        DeleteProjectEntry delete_project_entry = 35;
 45        ProjectEntryResponse project_entry_response = 36;
 46
 47        UpdateDiagnosticSummary update_diagnostic_summary = 37;
 48        StartLanguageServer start_language_server = 38;
 49        UpdateLanguageServer update_language_server = 39;
 50
 51        OpenBufferById open_buffer_by_id = 40;
 52        OpenBufferByPath open_buffer_by_path = 41;
 53        OpenBufferResponse open_buffer_response = 42;
 54        UpdateBuffer update_buffer = 43;
 55        UpdateBufferFile update_buffer_file = 44;
 56        SaveBuffer save_buffer = 45;
 57        BufferSaved buffer_saved = 46;
 58        BufferReloaded buffer_reloaded = 47;
 59        ReloadBuffers reload_buffers = 48;
 60        ReloadBuffersResponse reload_buffers_response = 49;
 61        FormatBuffers format_buffers = 50;
 62        FormatBuffersResponse format_buffers_response = 51;
 63        GetCompletions get_completions = 52;
 64        GetCompletionsResponse get_completions_response = 53;
 65        ApplyCompletionAdditionalEdits apply_completion_additional_edits = 54;
 66        ApplyCompletionAdditionalEditsResponse apply_completion_additional_edits_response = 55;
 67        GetCodeActions get_code_actions = 56;
 68        GetCodeActionsResponse get_code_actions_response = 57;
 69        ApplyCodeAction apply_code_action = 58;
 70        ApplyCodeActionResponse apply_code_action_response = 59;
 71        PrepareRename prepare_rename = 60;
 72        PrepareRenameResponse prepare_rename_response = 61;
 73        PerformRename perform_rename = 62;
 74        PerformRenameResponse perform_rename_response = 63;
 75        SearchProject search_project = 64;
 76        SearchProjectResponse search_project_response = 65;
 77
 78        GetChannels get_channels = 66;
 79        GetChannelsResponse get_channels_response = 67;
 80        JoinChannel join_channel = 68;
 81        JoinChannelResponse join_channel_response = 69;
 82        LeaveChannel leave_channel = 70;
 83        SendChannelMessage send_channel_message = 71;
 84        SendChannelMessageResponse send_channel_message_response = 72;
 85        ChannelMessageSent channel_message_sent = 73;
 86        GetChannelMessages get_channel_messages = 74;
 87        GetChannelMessagesResponse get_channel_messages_response = 75;
 88
 89        UpdateContacts update_contacts = 76;
 90
 91        GetUsers get_users = 77;
 92        FuzzySearchUsers fuzzy_search_users = 78;
 93        UsersResponse users_response = 79;
 94        RequestContact request_contact = 80;
 95        RespondToContactRequest respond_to_contact_request = 81;
 96        RemoveContact remove_contact = 82;
 97
 98        Follow follow = 83;
 99        FollowResponse follow_response = 84;
100        UpdateFollowers update_followers = 85;
101        Unfollow unfollow = 86;
102    }
103}
104
105// Messages
106
107message Ping {}
108
109message Ack {}
110
111message Error {
112    string message = 1;
113}
114
115message Test {
116    uint64 id = 1;
117}
118
119message RegisterProject {}
120
121message RegisterProjectResponse {
122    uint64 project_id = 1;
123}
124
125message UnregisterProject {
126    uint64 project_id = 1;
127}
128
129message RequestJoinProject {
130    uint64 requester_id = 1;
131    uint64 project_id = 2;
132}
133
134message RespondToJoinProjectRequest {
135    uint64 requester_id = 1;
136    uint64 project_id = 2;
137    bool allow = 3;
138}
139
140message JoinProjectRequestCancelled {
141    uint64 requester_id = 1;
142    uint64 project_id = 2;
143}
144
145message JoinProject {
146    uint64 project_id = 1;
147}
148
149message JoinProjectResponse {
150    oneof variant {
151        Accept accept = 1;
152        Decline decline = 2;
153    }
154
155    message Accept {
156        uint32 replica_id = 1;
157        repeated Worktree worktrees = 2;
158        repeated Collaborator collaborators = 3;
159        repeated LanguageServer language_servers = 4;        
160    }
161    
162    message Decline {
163        Reason reason = 1;
164
165        enum Reason {
166            Declined = 0;
167            Closed = 1;
168            WentOffline = 2;
169        }
170    }
171}
172
173message LeaveProject {
174    uint64 project_id = 1;
175}
176
177message RegisterWorktree {
178    uint64 project_id = 1;
179    uint64 worktree_id = 2;
180    string root_name = 3;
181    bool visible = 4;
182}
183
184message UnregisterWorktree {
185    uint64 project_id = 1;
186    uint64 worktree_id = 2;
187}
188
189message UpdateWorktree {
190    uint64 project_id = 1;
191    uint64 worktree_id = 2;
192    string root_name = 3;
193    repeated Entry updated_entries = 4;
194    repeated uint64 removed_entries = 5;
195    uint64 scan_id = 6;
196}
197
198message CreateProjectEntry {
199    uint64 project_id = 1;
200    uint64 worktree_id = 2;
201    bytes path = 3;
202    bool is_directory = 4;
203}
204
205message RenameProjectEntry {
206    uint64 project_id = 1;
207    uint64 entry_id = 2;
208    bytes new_path = 3;
209}
210
211message DeleteProjectEntry {
212    uint64 project_id = 1;
213    uint64 entry_id = 2;
214}
215
216message ProjectEntryResponse {
217    Entry entry = 1;
218    uint64 worktree_scan_id = 2;
219}
220
221message AddProjectCollaborator {
222    uint64 project_id = 1;
223    Collaborator collaborator = 2;
224}
225
226message RemoveProjectCollaborator {
227    uint64 project_id = 1;
228    uint32 peer_id = 2;
229}
230
231message ProjectUnshared {
232    uint64 project_id = 1;
233}
234
235message GetDefinition {
236     uint64 project_id = 1;
237     uint64 buffer_id = 2;
238     Anchor position = 3;
239     repeated VectorClockEntry version = 4;
240 }
241
242message GetDefinitionResponse {
243    repeated Location locations = 1;
244}
245
246message GetReferences {
247     uint64 project_id = 1;
248     uint64 buffer_id = 2;
249     Anchor position = 3;
250     repeated VectorClockEntry version = 4;
251 }
252
253message GetReferencesResponse {
254    repeated Location locations = 1;
255}
256
257message GetDocumentHighlights {
258     uint64 project_id = 1;
259     uint64 buffer_id = 2;
260     Anchor position = 3;
261     repeated VectorClockEntry version = 4;
262 }
263
264message GetDocumentHighlightsResponse {
265    repeated DocumentHighlight highlights = 1;
266}
267
268message Location {
269    Buffer buffer = 1;
270    Anchor start = 2;
271    Anchor end = 3;
272}
273
274message DocumentHighlight {
275    Kind kind = 1;
276    Anchor start = 2;
277    Anchor end = 3;
278
279    enum Kind {
280        Text = 0;
281        Read = 1;
282        Write = 2;
283    }
284}
285
286message GetProjectSymbols {
287    uint64 project_id = 1;
288    string query = 2;
289}
290
291message GetProjectSymbolsResponse {
292    repeated Symbol symbols = 4;
293}
294
295message Symbol {
296    uint64 source_worktree_id = 1;
297    uint64 worktree_id = 2;
298    string language_server_name = 3;
299    string name = 4;
300    int32 kind = 5;
301    string path = 6;
302    Point start = 7;
303    Point end = 8;
304    bytes signature = 9;
305}
306
307message OpenBufferForSymbol {
308    uint64 project_id = 1;
309    Symbol symbol = 2;
310}
311
312message OpenBufferForSymbolResponse {
313    Buffer buffer = 1;
314}
315
316message OpenBufferByPath {
317    uint64 project_id = 1;
318    uint64 worktree_id = 2;
319    string path = 3;
320}
321
322message OpenBufferById {
323    uint64 project_id = 1;
324    uint64 id = 2;
325}
326
327message OpenBufferResponse {
328    Buffer buffer = 1;
329}
330
331message CloseBuffer {
332    uint64 project_id = 1;
333    uint64 buffer_id = 2;
334}
335
336message UpdateBuffer {
337    uint64 project_id = 1;
338    uint64 buffer_id = 2;
339    repeated Operation operations = 3;
340}
341
342message UpdateBufferFile {
343    uint64 project_id = 1;
344    uint64 buffer_id = 2;
345    File file = 3;
346}
347
348message SaveBuffer {
349    uint64 project_id = 1;
350    uint64 buffer_id = 2;
351    repeated VectorClockEntry version = 3;
352}
353
354message BufferSaved {
355    uint64 project_id = 1;
356    uint64 buffer_id = 2;
357    repeated VectorClockEntry version = 3;
358    Timestamp mtime = 4;
359}
360
361message BufferReloaded {
362    uint64 project_id = 1;
363    uint64 buffer_id = 2;
364    repeated VectorClockEntry version = 3;
365    Timestamp mtime = 4;
366}
367
368message ReloadBuffers {
369    uint64 project_id = 1;
370    repeated uint64 buffer_ids = 2;
371}
372
373message ReloadBuffersResponse {
374    ProjectTransaction transaction = 1;
375}
376
377message FormatBuffers {
378    uint64 project_id = 1;
379    repeated uint64 buffer_ids = 2;
380}
381
382message FormatBuffersResponse {
383    ProjectTransaction transaction = 1;
384}
385
386message GetCompletions {
387    uint64 project_id = 1;
388    uint64 buffer_id = 2;
389    Anchor position = 3;
390    repeated VectorClockEntry version = 4;
391}
392
393message GetCompletionsResponse {
394    repeated Completion completions = 1;
395    repeated VectorClockEntry version = 2;
396}
397
398message ApplyCompletionAdditionalEdits {
399    uint64 project_id = 1;
400    uint64 buffer_id = 2;
401    Completion completion = 3;
402}
403
404message ApplyCompletionAdditionalEditsResponse {
405    Transaction transaction = 1;
406}
407
408message Completion {
409    Anchor old_start = 1;
410    Anchor old_end = 2;
411    string new_text = 3;
412    bytes lsp_completion = 4;
413}
414
415message GetCodeActions {
416    uint64 project_id = 1;
417    uint64 buffer_id = 2;
418    Anchor start = 3;
419    Anchor end = 4;
420    repeated VectorClockEntry version = 5;
421}
422
423message GetCodeActionsResponse {
424    repeated CodeAction actions = 1;
425    repeated VectorClockEntry version = 2;
426}
427
428message ApplyCodeAction {
429    uint64 project_id = 1;
430    uint64 buffer_id = 2;
431    CodeAction action = 3;
432}
433
434message ApplyCodeActionResponse {
435    ProjectTransaction transaction = 1;
436}
437
438message PrepareRename {
439    uint64 project_id = 1;
440    uint64 buffer_id = 2;
441    Anchor position = 3;
442    repeated VectorClockEntry version = 4;
443}
444
445message PrepareRenameResponse {
446    bool can_rename = 1;
447    Anchor start = 2;
448    Anchor end = 3;
449    repeated VectorClockEntry version = 4;
450}
451
452message PerformRename {
453    uint64 project_id = 1;
454    uint64 buffer_id = 2;
455    Anchor position = 3;
456    string new_name = 4;
457    repeated VectorClockEntry version = 5;
458}
459
460message PerformRenameResponse {
461    ProjectTransaction transaction = 2;
462}
463
464message SearchProject {
465    uint64 project_id = 1;
466    string query = 2;
467    bool regex = 3;
468    bool whole_word = 4;
469    bool case_sensitive = 5;
470}
471
472message SearchProjectResponse {
473    repeated Location locations = 1;
474}
475
476message CodeAction {
477    Anchor start = 1;
478    Anchor end = 2;
479    bytes lsp_action = 3;
480}
481
482message ProjectTransaction {
483    repeated Buffer buffers = 1;
484    repeated Transaction transactions = 2;
485}
486
487message Transaction {
488    LocalTimestamp id = 1;
489    repeated LocalTimestamp edit_ids = 2;
490    repeated VectorClockEntry start = 3;
491    repeated VectorClockEntry end = 4;
492    repeated Range ranges = 5;
493}
494
495message LocalTimestamp {
496    uint32 replica_id = 1;
497    uint32 value = 2;
498}
499
500message LanguageServer {
501    uint64 id = 1;
502    string name = 2;
503}
504
505message StartLanguageServer {
506    uint64 project_id = 1;
507    LanguageServer server = 2;
508}
509
510message UpdateDiagnosticSummary {
511    uint64 project_id = 1;
512    uint64 worktree_id = 2;
513    DiagnosticSummary summary = 3;
514}
515
516message DiagnosticSummary {
517    string path = 1;
518    uint32 error_count = 2;
519    uint32 warning_count = 3;
520}
521
522message UpdateLanguageServer {
523    uint64 project_id = 1;
524    uint64 language_server_id = 2;
525    oneof variant {
526        LspWorkStart work_start = 3;
527        LspWorkProgress work_progress = 4;
528        LspWorkEnd work_end = 5;
529        LspDiskBasedDiagnosticsUpdating disk_based_diagnostics_updating = 6;
530        LspDiskBasedDiagnosticsUpdated disk_based_diagnostics_updated = 7;
531    }
532}
533
534message LspWorkStart {
535    string token = 1;
536}
537
538message LspWorkProgress {
539    string token = 1;
540    optional string message = 2;
541    optional uint32 percentage = 3;
542}
543
544message LspWorkEnd {
545    string token = 1;
546}
547
548message LspDiskBasedDiagnosticsUpdating {}
549
550message LspDiskBasedDiagnosticsUpdated {}
551
552message GetChannels {}
553
554message GetChannelsResponse {
555    repeated Channel channels = 1;
556}
557
558message JoinChannel {
559    uint64 channel_id = 1;
560}
561
562message JoinChannelResponse {
563    repeated ChannelMessage messages = 1;
564    bool done = 2;
565}
566
567message LeaveChannel {
568    uint64 channel_id = 1;
569}
570
571message GetUsers {
572    repeated uint64 user_ids = 1;
573}
574
575message FuzzySearchUsers {
576    string query = 1;
577}
578
579message UsersResponse {
580    repeated User users = 1;
581}
582
583message RequestContact {
584    uint64 responder_id = 1;
585}
586
587message RemoveContact {
588    uint64 user_id = 1;
589}
590
591message RespondToContactRequest {
592    uint64 requester_id = 1;
593    ContactRequestResponse response = 2;
594}
595
596enum ContactRequestResponse {
597    Accept = 0;
598    Decline = 1;
599    Block = 2;
600    Dismiss = 3;
601}
602
603message SendChannelMessage {
604    uint64 channel_id = 1;
605    string body = 2;
606    Nonce nonce = 3;
607}
608
609message SendChannelMessageResponse {
610    ChannelMessage message = 1;
611}
612
613message ChannelMessageSent {
614    uint64 channel_id = 1;
615    ChannelMessage message = 2;
616}
617
618message GetChannelMessages {
619    uint64 channel_id = 1;
620    uint64 before_message_id = 2;
621}
622
623message GetChannelMessagesResponse {
624    repeated ChannelMessage messages = 1;
625    bool done = 2;
626}
627
628message UpdateContacts {
629    repeated Contact contacts = 1;
630    repeated uint64 remove_contacts = 2;
631    repeated IncomingContactRequest incoming_requests = 3;
632    repeated uint64 remove_incoming_requests = 4;
633    repeated uint64 outgoing_requests = 5;
634    repeated uint64 remove_outgoing_requests = 6;
635}
636
637message IncomingContactRequest {
638    uint64 requester_id = 1;
639    bool should_notify = 2;
640}
641
642message UpdateDiagnostics {
643    uint32 replica_id = 1;
644    uint32 lamport_timestamp = 2;
645    repeated Diagnostic diagnostics = 3;
646}
647
648message Follow {
649    uint64 project_id = 1;
650    uint32 leader_id = 2;
651}
652
653message FollowResponse {
654    optional uint64 active_view_id = 1;
655    repeated View views = 2;
656}
657
658message UpdateFollowers {
659    uint64 project_id = 1;
660    repeated uint32 follower_ids = 2;
661    oneof variant {
662        UpdateActiveView update_active_view = 3;
663        View create_view = 4;
664        UpdateView update_view = 5;
665    }
666}
667
668message Unfollow {
669    uint64 project_id = 1;
670    uint32 leader_id = 2;
671}
672
673// Entities
674
675message UpdateActiveView {
676    optional uint64 id = 1;
677    optional uint32 leader_id = 2;
678}
679
680message UpdateView {
681    uint64 id = 1;
682    optional uint32 leader_id = 2;
683
684    oneof variant {
685        Editor editor = 3;
686    }
687
688    message Editor {
689        repeated Selection selections = 1;
690        Anchor scroll_top_anchor = 2;
691        float scroll_x = 3;
692        float scroll_y = 4;
693    }
694}
695
696message View {
697    uint64 id = 1;
698    optional uint32 leader_id = 2;
699
700    oneof variant {
701        Editor editor = 3;
702    }
703
704    message Editor {
705        uint64 buffer_id = 1;
706        repeated Selection selections = 2;
707        Anchor scroll_top_anchor = 3;
708        float scroll_x = 4;
709        float scroll_y = 5;
710    }
711}
712
713message Collaborator {
714    uint32 peer_id = 1;
715    uint32 replica_id = 2;
716    uint64 user_id = 3;
717}
718
719message User {
720    uint64 id = 1;
721    string github_login = 2;
722    string avatar_url = 3;
723}
724
725message Worktree {
726    uint64 id = 1;
727    string root_name = 2;
728    repeated Entry entries = 3;
729    repeated DiagnosticSummary diagnostic_summaries = 4;
730    bool visible = 5;
731    uint64 scan_id = 6;
732}
733
734message File {
735    uint64 worktree_id = 1;
736    optional uint64 entry_id = 2;
737    string path = 3;
738    Timestamp mtime = 4;
739}
740
741message Entry {
742    uint64 id = 1;
743    bool is_dir = 2;
744    bytes path = 3;
745    uint64 inode = 4;
746    Timestamp mtime = 5;
747    bool is_symlink = 6;
748    bool is_ignored = 7;
749}
750
751message Buffer {
752    oneof variant {
753        uint64 id = 1;
754        BufferState state = 2;
755    }
756}
757
758message BufferState {
759    uint64 id = 1;
760    optional File file = 2;
761    string base_text = 3;
762    repeated Operation operations = 4;
763    repeated SelectionSet selections = 5;
764    repeated Diagnostic diagnostics = 6;
765    uint32 diagnostics_timestamp = 7;
766    repeated string completion_triggers = 8;
767}
768
769message SelectionSet {
770    uint32 replica_id = 1;
771    repeated Selection selections = 2;
772    uint32 lamport_timestamp = 3;
773}
774
775message Selection {
776    uint64 id = 1;
777    Anchor start = 2;
778    Anchor end = 3;
779    bool reversed = 4;
780}
781
782message Anchor {
783    uint32 replica_id = 1;
784    uint32 local_timestamp = 2;
785    uint64 offset = 3;
786    Bias bias = 4;
787    optional uint64 buffer_id = 5;
788}
789
790enum Bias {
791    Left = 0;
792    Right = 1;
793}
794
795message Diagnostic {
796    Anchor start = 1;
797    Anchor end = 2;
798    Severity severity = 3;
799    string message = 4;
800    optional string code = 5;
801    uint64 group_id = 6;
802    bool is_primary = 7;
803    bool is_valid = 8;
804    bool is_disk_based = 9;
805    bool is_unnecessary = 10;
806
807    enum Severity {
808        None = 0;
809        Error = 1;
810        Warning = 2;
811        Information = 3;
812        Hint = 4;
813    }
814}
815
816message Operation {
817    oneof variant {
818        Edit edit = 1;
819        Undo undo = 2;
820        UpdateSelections update_selections = 3;
821        UpdateDiagnostics update_diagnostics = 4;
822        UpdateCompletionTriggers update_completion_triggers = 5;
823    }
824
825    message Edit {
826        uint32 replica_id = 1;
827        uint32 local_timestamp = 2;
828        uint32 lamport_timestamp = 3;
829        repeated VectorClockEntry version = 4;
830        repeated Range ranges = 5;
831        repeated string new_text = 6;
832    }
833
834    message Undo {
835        uint32 replica_id = 1;
836        uint32 local_timestamp = 2;
837        uint32 lamport_timestamp = 3;
838        repeated VectorClockEntry version = 4;
839        repeated Range transaction_ranges = 5;
840        repeated VectorClockEntry transaction_version = 6;
841        repeated UndoCount counts = 7;
842    }
843
844    message UpdateSelections {
845        uint32 replica_id = 1;
846        uint32 lamport_timestamp = 2;
847        repeated Selection selections = 3;
848    }
849
850    message UpdateCompletionTriggers {
851        uint32 replica_id = 1;
852        uint32 lamport_timestamp = 2;
853        repeated string triggers = 3;
854    }
855}
856
857message UndoMapEntry {
858    uint32 replica_id = 1;
859    uint32 local_timestamp = 2;
860    repeated UndoCount counts = 3;
861}
862
863message UndoCount {
864    uint32 replica_id = 1;
865    uint32 local_timestamp = 2;
866    uint32 count = 3;
867}
868
869message VectorClockEntry {
870    uint32 replica_id = 1;
871    uint32 timestamp = 2;
872}
873
874message Timestamp {
875    uint64 seconds = 1;
876    uint32 nanos = 2;
877}
878
879message Range {
880    uint64 start = 1;
881    uint64 end = 2;
882}
883
884message Point {
885    uint32 row = 1;
886    uint32 column = 2;
887}
888
889message Nonce {
890    uint64 upper_half = 1;
891    uint64 lower_half = 2;
892}
893
894message Channel {
895    uint64 id = 1;
896    string name = 2;
897}
898
899message ChannelMessage {
900    uint64 id = 1;
901    string body = 2;
902    uint64 timestamp = 3;
903    uint64 sender_id = 4;
904    Nonce nonce = 5;
905}
906
907message Contact {
908    uint64 user_id = 1;
909    repeated ProjectMetadata projects = 2;
910    bool online = 3;
911    bool should_notify = 4;
912}
913
914message ProjectMetadata {
915    uint64 id = 1;
916    repeated string worktree_root_names = 3;
917    repeated uint64 guests = 4;
918}