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