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