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