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
13 RegisterProject register_project = 7;
14 RegisterProjectResponse register_project_response = 8;
15 UnregisterProject unregister_project = 9;
16 ShareProject share_project = 10;
17 UnshareProject unshare_project = 11;
18 JoinProject join_project = 12;
19 JoinProjectResponse join_project_response = 13;
20 LeaveProject leave_project = 14;
21 AddProjectCollaborator add_project_collaborator = 15;
22 RemoveProjectCollaborator remove_project_collaborator = 16;
23
24 RegisterWorktree register_worktree = 17;
25 UnregisterWorktree unregister_worktree = 18;
26 ShareWorktree share_worktree = 100;
27 UpdateWorktree update_worktree = 19;
28 UpdateDiagnosticSummary update_diagnostic_summary = 20;
29
30 OpenBuffer open_buffer = 22;
31 OpenBufferResponse open_buffer_response = 23;
32 CloseBuffer close_buffer = 24;
33 UpdateBuffer update_buffer = 25;
34 SaveBuffer save_buffer = 26;
35 BufferSaved buffer_saved = 27;
36
37 GetChannels get_channels = 28;
38 GetChannelsResponse get_channels_response = 29;
39 JoinChannel join_channel = 30;
40 JoinChannelResponse join_channel_response = 31;
41 LeaveChannel leave_channel = 32;
42 SendChannelMessage send_channel_message = 33;
43 SendChannelMessageResponse send_channel_message_response = 34;
44 ChannelMessageSent channel_message_sent = 35;
45 GetChannelMessages get_channel_messages = 36;
46 GetChannelMessagesResponse get_channel_messages_response = 37;
47
48 UpdateContacts update_contacts = 38;
49
50 GetUsers get_users = 39;
51 GetUsersResponse get_users_response = 40;
52 }
53}
54
55// Messages
56
57message Ping {}
58
59message Ack {}
60
61message Error {
62 string message = 1;
63}
64
65message RegisterProject {}
66
67message RegisterProjectResponse {
68 uint64 project_id = 1;
69}
70
71message UnregisterProject {
72 uint64 project_id = 1;
73}
74
75message ShareProject {
76 uint64 project_id = 1;
77}
78
79message UnshareProject {
80 uint64 project_id = 1;
81}
82
83message JoinProject {
84 uint64 project_id = 1;
85}
86
87message JoinProjectResponse {
88 uint32 replica_id = 2;
89 repeated Worktree worktrees = 3;
90 repeated Collaborator collaborators = 4;
91}
92
93message LeaveProject {
94 uint64 project_id = 1;
95}
96
97message RegisterWorktree {
98 uint64 project_id = 1;
99 uint64 worktree_id = 2;
100 string root_name = 3;
101 repeated string authorized_logins = 4;
102}
103
104message UnregisterWorktree {
105 uint64 project_id = 1;
106 uint64 worktree_id = 2;
107}
108
109message ShareWorktree {
110 uint64 project_id = 1;
111 Worktree worktree = 2;
112}
113
114message UpdateWorktree {
115 uint64 project_id = 1;
116 uint64 worktree_id = 2;
117 string root_name = 3;
118 repeated Entry updated_entries = 4;
119 repeated uint64 removed_entries = 5;
120}
121
122message AddProjectCollaborator {
123 uint64 project_id = 1;
124 Collaborator collaborator = 2;
125}
126
127message RemoveProjectCollaborator {
128 uint64 project_id = 1;
129 uint32 peer_id = 2;
130}
131
132message OpenBuffer {
133 uint64 project_id = 1;
134 uint64 worktree_id = 2;
135 string path = 3;
136}
137
138message OpenBufferResponse {
139 Buffer buffer = 1;
140}
141
142message CloseBuffer {
143 uint64 project_id = 1;
144 uint64 worktree_id = 2;
145 uint64 buffer_id = 3;
146}
147
148message UpdateBuffer {
149 uint64 project_id = 1;
150 uint64 worktree_id = 2;
151 uint64 buffer_id = 3;
152 repeated Operation operations = 4;
153}
154
155message SaveBuffer {
156 uint64 project_id = 1;
157 uint64 worktree_id = 2;
158 uint64 buffer_id = 3;
159}
160
161message BufferSaved {
162 uint64 project_id = 1;
163 uint64 worktree_id = 2;
164 uint64 buffer_id = 3;
165 repeated VectorClockEntry version = 4;
166 Timestamp mtime = 5;
167}
168
169message UpdateDiagnosticSummary {
170 uint64 project_id = 1;
171 uint64 worktree_id = 2;
172 string path = 3;
173 uint32 error_count = 4;
174 uint32 warning_count = 5;
175}
176
177message GetChannels {}
178
179message GetChannelsResponse {
180 repeated Channel channels = 1;
181}
182
183message JoinChannel {
184 uint64 channel_id = 1;
185}
186
187message JoinChannelResponse {
188 repeated ChannelMessage messages = 1;
189 bool done = 2;
190}
191
192message LeaveChannel {
193 uint64 channel_id = 1;
194}
195
196message GetUsers {
197 repeated uint64 user_ids = 1;
198}
199
200message GetUsersResponse {
201 repeated User users = 1;
202}
203
204message SendChannelMessage {
205 uint64 channel_id = 1;
206 string body = 2;
207 Nonce nonce = 3;
208}
209
210message SendChannelMessageResponse {
211 ChannelMessage message = 1;
212}
213
214message ChannelMessageSent {
215 uint64 channel_id = 1;
216 ChannelMessage message = 2;
217}
218
219message GetChannelMessages {
220 uint64 channel_id = 1;
221 uint64 before_message_id = 2;
222}
223
224message GetChannelMessagesResponse {
225 repeated ChannelMessage messages = 1;
226 bool done = 2;
227}
228
229message UpdateContacts {
230 repeated Contact contacts = 1;
231}
232
233// Entities
234
235message Collaborator {
236 uint32 peer_id = 1;
237 uint32 replica_id = 2;
238 uint64 user_id = 3;
239}
240
241message User {
242 uint64 id = 1;
243 string github_login = 2;
244 string avatar_url = 3;
245}
246
247message Worktree {
248 uint64 id = 1;
249 string root_name = 2;
250 repeated Entry entries = 3;
251}
252
253message Entry {
254 uint64 id = 1;
255 bool is_dir = 2;
256 string path = 3;
257 uint64 inode = 4;
258 Timestamp mtime = 5;
259 bool is_symlink = 6;
260 bool is_ignored = 7;
261}
262
263message Buffer {
264 uint64 id = 1;
265 string content = 2;
266 repeated Operation.Edit history = 3;
267 repeated SelectionSet selections = 4;
268 repeated Diagnostic diagnostics = 5;
269}
270
271message SelectionSet {
272 uint32 replica_id = 1;
273 repeated Selection selections = 2;
274}
275
276message Selection {
277 uint64 id = 1;
278 Anchor start = 2;
279 Anchor end = 3;
280 bool reversed = 4;
281}
282
283message Anchor {
284 uint32 replica_id = 1;
285 uint32 local_timestamp = 2;
286 uint64 offset = 3;
287 Bias bias = 4;
288}
289
290enum Bias {
291 Left = 0;
292 Right = 1;
293}
294
295message UpdateDiagnostics {
296 uint32 replica_id = 1;
297 uint32 lamport_timestamp = 2;
298 repeated Diagnostic diagnostics = 3;
299}
300
301message Diagnostic {
302 Anchor start = 1;
303 Anchor end = 2;
304 Severity severity = 3;
305 string message = 4;
306 uint64 group_id = 5;
307 bool is_primary = 6;
308 optional string code = 7;
309 optional string source = 8;
310 enum Severity {
311 None = 0;
312 Error = 1;
313 Warning = 2;
314 Information = 3;
315 Hint = 4;
316 }
317}
318
319message Operation {
320 oneof variant {
321 Edit edit = 1;
322 Undo undo = 2;
323 UpdateSelections update_selections = 3;
324 RemoveSelections remove_selections = 4;
325 UpdateDiagnostics update_diagnostics = 5;
326 }
327
328 message Edit {
329 uint32 replica_id = 1;
330 uint32 local_timestamp = 2;
331 uint32 lamport_timestamp = 3;
332 repeated VectorClockEntry version = 4;
333 repeated Range ranges = 5;
334 optional string new_text = 6;
335 }
336
337 message Undo {
338 uint32 replica_id = 1;
339 uint32 local_timestamp = 2;
340 uint32 lamport_timestamp = 3;
341 repeated Range ranges = 4;
342 repeated VectorClockEntry version = 5;
343 repeated UndoCount counts = 6;
344 }
345
346 message UndoCount {
347 uint32 replica_id = 1;
348 uint32 local_timestamp = 2;
349 uint32 count = 3;
350 }
351
352 message UpdateSelections {
353 uint32 replica_id = 1;
354 uint32 lamport_timestamp = 3;
355 repeated Selection selections = 4;
356 }
357
358 message RemoveSelections {
359 uint32 replica_id = 1;
360 uint32 lamport_timestamp = 3;
361 }
362}
363
364message VectorClockEntry {
365 uint32 replica_id = 1;
366 uint32 timestamp = 2;
367}
368
369message Timestamp {
370 uint64 seconds = 1;
371 uint32 nanos = 2;
372}
373
374message Range {
375 uint64 start = 1;
376 uint64 end = 2;
377}
378
379message Nonce {
380 uint64 upper_half = 1;
381 uint64 lower_half = 2;
382}
383
384message Channel {
385 uint64 id = 1;
386 string name = 2;
387}
388
389message ChannelMessage {
390 uint64 id = 1;
391 string body = 2;
392 uint64 timestamp = 3;
393 uint64 sender_id = 4;
394 Nonce nonce = 5;
395}
396
397message Contact {
398 uint64 user_id = 1;
399 repeated ProjectMetadata projects = 2;
400}
401
402message ProjectMetadata {
403 uint64 id = 1;
404 bool is_shared = 2;
405 repeated string worktree_root_names = 3;
406 repeated uint64 guests = 4;
407}