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