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