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