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