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        DiskBasedDiagnosticsUpdating disk_based_diagnostics_updating = 33;
 41        DiskBasedDiagnosticsUpdated disk_based_diagnostics_updated = 34;
 42
 43        OpenBuffer open_buffer = 35;
 44        OpenBufferResponse open_buffer_response = 36;
 45        CloseBuffer close_buffer = 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}
 85
 86// Messages
 87
 88message Ping {}
 89
 90message Ack {}
 91
 92message Error {
 93    string message = 1;
 94}
 95
 96message Test {
 97    uint64 id = 1;
 98}
 99
100message RegisterProject {}
101
102message RegisterProjectResponse {
103    uint64 project_id = 1;
104}
105
106message UnregisterProject {
107    uint64 project_id = 1;
108}
109
110message ShareProject {
111    uint64 project_id = 1;
112}
113
114message UnshareProject {
115    uint64 project_id = 1;
116}
117
118message JoinProject {
119    uint64 project_id = 1;
120}
121
122message JoinProjectResponse {
123    uint32 replica_id = 1;
124    repeated Worktree worktrees = 2;
125    repeated Collaborator collaborators = 3;
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 UpdateDiagnosticSummary {
415    uint64 project_id = 1;
416    uint64 worktree_id = 2;
417    DiagnosticSummary summary = 3;
418}
419
420message DiagnosticSummary {
421    string path = 1;
422    uint32 error_count = 2;
423    uint32 warning_count = 3;
424    uint32 info_count = 4;
425    uint32 hint_count = 5;
426}
427
428message DiskBasedDiagnosticsUpdating {
429    uint64 project_id = 1;
430}
431
432message DiskBasedDiagnosticsUpdated {
433    uint64 project_id = 1;
434}
435
436message GetChannels {}
437
438message GetChannelsResponse {
439    repeated Channel channels = 1;
440}
441
442message JoinChannel {
443    uint64 channel_id = 1;
444}
445
446message JoinChannelResponse {
447    repeated ChannelMessage messages = 1;
448    bool done = 2;
449}
450
451message LeaveChannel {
452    uint64 channel_id = 1;
453}
454
455message GetUsers {
456    repeated uint64 user_ids = 1;
457}
458
459message GetUsersResponse {
460    repeated User users = 1;
461}
462
463message SendChannelMessage {
464    uint64 channel_id = 1;
465    string body = 2;
466    Nonce nonce = 3;
467}
468
469message SendChannelMessageResponse {
470    ChannelMessage message = 1;
471}
472
473message ChannelMessageSent {
474    uint64 channel_id = 1;
475    ChannelMessage message = 2;
476}
477
478message GetChannelMessages {
479    uint64 channel_id = 1;
480    uint64 before_message_id = 2;
481}
482
483message GetChannelMessagesResponse {
484    repeated ChannelMessage messages = 1;
485    bool done = 2;
486}
487
488message UpdateContacts {
489    repeated Contact contacts = 1;
490}
491
492// Entities
493
494message Collaborator {
495    uint32 peer_id = 1;
496    uint32 replica_id = 2;
497    uint64 user_id = 3;
498}
499
500message User {
501    uint64 id = 1;
502    string github_login = 2;
503    string avatar_url = 3;
504}
505
506message Worktree {
507    uint64 id = 1;
508    string root_name = 2;
509    repeated Entry entries = 3;
510    repeated DiagnosticSummary diagnostic_summaries = 4;
511    bool visible = 5;
512}
513
514message File {
515    uint64 worktree_id = 1;
516    optional uint64 entry_id = 2;
517    string path = 3;
518    Timestamp mtime = 4;
519}
520
521message Entry {
522    uint64 id = 1;
523    bool is_dir = 2;
524    string path = 3;
525    uint64 inode = 4;
526    Timestamp mtime = 5;
527    bool is_symlink = 6;
528    bool is_ignored = 7;
529}
530
531message Buffer {
532    oneof variant {
533        uint64 id = 1;
534        BufferState state = 2;
535    }
536}
537
538message BufferState {
539    uint64 id = 1;
540    optional File file = 2;
541    string base_text = 3;
542    repeated Operation operations = 4;
543    repeated SelectionSet selections = 5;
544    repeated Diagnostic diagnostics = 6;
545    uint32 diagnostics_timestamp = 7;
546    repeated string completion_triggers = 8;
547}
548
549message BufferFragment {
550    uint32 replica_id = 1;
551    uint32 local_timestamp = 2;
552    uint32 lamport_timestamp = 3;
553    uint32 insertion_offset = 4;
554    uint32 len = 5;
555    bool visible = 6;
556    repeated VectorClockEntry deletions = 7;
557    repeated VectorClockEntry max_undos = 8;
558}
559
560message SelectionSet {
561    uint32 replica_id = 1;
562    repeated Selection selections = 2;
563    uint32 lamport_timestamp = 3;
564}
565
566message Selection {
567    uint64 id = 1;
568    Anchor start = 2;
569    Anchor end = 3;
570    bool reversed = 4;
571}
572
573message Anchor {
574    uint32 replica_id = 1;
575    uint32 local_timestamp = 2;
576    uint64 offset = 3;
577    Bias bias = 4;
578}
579
580enum Bias {
581    Left = 0;
582    Right = 1;
583}
584
585message UpdateDiagnostics {
586    uint32 replica_id = 1;
587    uint32 lamport_timestamp = 2;
588    repeated Diagnostic diagnostics = 3;
589}
590
591message Diagnostic {
592    Anchor start = 1;
593    Anchor end = 2;
594    Severity severity = 3;
595    string message = 4;
596    optional string code = 5;
597    uint64 group_id = 6;
598    bool is_primary = 7;
599    bool is_valid = 8;
600    bool is_disk_based = 9;
601
602    enum Severity {
603        None = 0;
604        Error = 1;
605        Warning = 2;
606        Information = 3;
607        Hint = 4;
608    }
609}
610
611message Operation {
612    oneof variant {
613        Edit edit = 1;
614        Undo undo = 2;
615        UpdateSelections update_selections = 3;
616        UpdateDiagnostics update_diagnostics = 4;
617        UpdateCompletionTriggers update_completion_triggers = 5;
618    }
619
620    message Edit {
621        uint32 replica_id = 1;
622        uint32 local_timestamp = 2;
623        uint32 lamport_timestamp = 3;
624        repeated VectorClockEntry version = 4;
625        repeated Range ranges = 5;
626        optional string new_text = 6;
627    }
628
629    message Undo {
630        uint32 replica_id = 1;
631        uint32 local_timestamp = 2;
632        uint32 lamport_timestamp = 3;
633        repeated VectorClockEntry version = 4;
634        repeated Range transaction_ranges = 5;
635        repeated VectorClockEntry transaction_version = 6;
636        repeated UndoCount counts = 7;
637    }
638
639    message UpdateSelections {
640        uint32 replica_id = 1;
641        uint32 lamport_timestamp = 2;
642        repeated Selection selections = 3;
643    }
644
645    message UpdateCompletionTriggers {
646        uint32 replica_id = 1;
647        uint32 lamport_timestamp = 2;
648        repeated string triggers = 3;
649    }
650}
651
652message UndoMapEntry {
653    uint32 replica_id = 1;
654    uint32 local_timestamp = 2;
655    repeated UndoCount counts = 3;
656}
657
658message UndoCount {
659    uint32 replica_id = 1;
660    uint32 local_timestamp = 2;
661    uint32 count = 3;
662}
663
664message VectorClockEntry {
665    uint32 replica_id = 1;
666    uint32 timestamp = 2;
667}
668
669message Timestamp {
670    uint64 seconds = 1;
671    uint32 nanos = 2;
672}
673
674message Range {
675    uint64 start = 1;
676    uint64 end = 2;
677}
678
679message Point {
680    uint32 row = 1;
681    uint32 column = 2;
682}
683
684message Nonce {
685    uint64 upper_half = 1;
686    uint64 lower_half = 2;
687}
688
689message Channel {
690    uint64 id = 1;
691    string name = 2;
692}
693
694message ChannelMessage {
695    uint64 id = 1;
696    string body = 2;
697    uint64 timestamp = 3;
698    uint64 sender_id = 4;
699    Nonce nonce = 5;
700}
701
702message Contact {
703    uint64 user_id = 1;
704    repeated ProjectMetadata projects = 2;
705}
706
707message ProjectMetadata {
708    uint64 id = 1;
709    bool is_shared = 2;
710    repeated string worktree_root_names = 3;
711    repeated uint64 guests = 4;
712}