Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T03:40:54.424Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

proto.rs

1127 lines · 38.9 KB · rust
1#![allow(non_snake_case)]
2
3pub mod error;
4mod macros;
5mod typed_envelope;
6
7pub use error::*;
8pub use prost::{DecodeError, Message};
9use std::{
10    cmp,
11    fmt::Debug,
12    iter, mem,
13    time::{Duration, SystemTime, UNIX_EPOCH},
14};
15pub use typed_envelope::*;
16
17include!(concat!(env!("OUT_DIR"), "/zed.messages.rs"));
18
19pub const REMOTE_SERVER_PEER_ID: PeerId = PeerId { owner_id: 0, id: 0 };
20pub const REMOTE_SERVER_PROJECT_ID: u64 = 0;
21
22messages!(
23    (Ack, Foreground),
24    (AckBufferOperation, Background),
25    (AckChannelMessage, Background),
26    (ActivateToolchain, Foreground),
27    (ActiveToolchain, Foreground),
28    (ActiveToolchainResponse, Foreground),
29    (ResolveToolchain, Background),
30    (ResolveToolchainResponse, Background),
31    (AddNotification, Foreground),
32    (AddProjectCollaborator, Foreground),
33    (AddWorktree, Foreground),
34    (AddWorktreeResponse, Foreground),
35    (AllocateWorktreeId, Foreground),
36    (AllocateWorktreeIdResponse, Foreground),
37    (ApplyCodeAction, Background),
38    (ApplyCodeActionResponse, Background),
39    (ApplyCompletionAdditionalEdits, Background),
40    (ApplyCompletionAdditionalEditsResponse, Background),
41    (BlameBuffer, Foreground),
42    (BlameBufferResponse, Foreground),
43    (BufferReloaded, Foreground),
44    (BufferSaved, Foreground),
45    (Call, Foreground),
46    (CallCanceled, Foreground),
47    (CancelCall, Foreground),
48    (CancelLanguageServerWork, Foreground),
49    (ChannelMessageSent, Foreground),
50    (ChannelMessageUpdate, Foreground),
51    (CloseBuffer, Foreground),
52    (Commit, Background),
53    (RunGitHook, Background),
54    (CopyProjectEntry, Foreground),
55    (CreateBufferForPeer, Foreground),
56    (CreateImageForPeer, Foreground),
57    (CreateFileForPeer, Foreground),
58    (CreateChannel, Foreground),
59    (CreateChannelResponse, Foreground),
60    (CreateProjectEntry, Foreground),
61    (CreateRoom, Foreground),
62    (CreateRoomResponse, Foreground),
63    (DeclineCall, Foreground),
64    (DeleteChannel, Foreground),
65    (DeleteNotification, Foreground),
66    (DeleteProjectEntry, Foreground),
67    (TrashProjectEntry, Foreground),
68    (TrashProjectEntryResponse, Foreground),
69    (RestoreProjectEntry, Foreground),
70    (RestoreProjectEntryResponse, Foreground),
71    (DownloadFileByPath, Background),
72    (DownloadFileResponse, Background),
73    (EndStream, Foreground),
74    (Error, Foreground),
75    (ExpandProjectEntry, Foreground),
76    (ExpandProjectEntryResponse, Foreground),
77    (FindSearchCandidates, Background),
78    (FlushBufferedMessages, Foreground),
79    (ExpandAllForProjectEntry, Foreground),
80    (ExpandAllForProjectEntryResponse, Foreground),
81    (Follow, Foreground),
82    (FollowResponse, Foreground),
83    (ApplyCodeActionKind, Foreground),
84    (ApplyCodeActionKindResponse, Foreground),
85    (FormatBuffers, Foreground),
86    (FormatBuffersResponse, Foreground),
87    (FuzzySearchUsers, Foreground),
88    (GetChannelMembers, Foreground),
89    (GetChannelMembersResponse, Foreground),
90    (GetChannelMessages, Background),
91    (GetChannelMessagesById, Background),
92    (GetChannelMessagesResponse, Background),
93    (GetCodeActions, Background),
94    (GetCodeActionsResponse, Background),
95    (GetCompletions, Background),
96    (GetCompletionsResponse, Background),
97    (GetDeclaration, Background),
98    (GetDeclarationResponse, Background),
99    (GetDefinition, Background),
100    (GetDefinitionResponse, Background),
101    (GetEditPredictionDefinition, Background),
102    (GetEditPredictionDefinitionResponse, Background),
103    (GetEditPredictionTypeDefinition, Background),
104    (GetEditPredictionTypeDefinitionResponse, Background),
105    (GetDocumentHighlights, Background),
106    (GetDocumentHighlightsResponse, Background),
107    (GetDocumentSymbols, Background),
108    (GetDocumentSymbolsResponse, Background),
109    (GetHover, Background),
110    (GetHoverResponse, Background),
111    (GetNotifications, Foreground),
112    (GetNotificationsResponse, Foreground),
113    (GetCrashFiles, Background),
114    (GetCrashFilesResponse, Background),
115    (GetPathMetadata, Background),
116    (GetPathMetadataResponse, Background),
117    (GetPermalinkToLine, Foreground),
118    (GetProcesses, Background),
119    (GetProcessesResponse, Background),
120    (GetPermalinkToLineResponse, Foreground),
121    (GetProjectSymbols, Background),
122    (GetProjectSymbolsResponse, Background),
123    (GetReferences, Background),
124    (GetReferencesResponse, Background),
125    (GetSignatureHelp, Background),
126    (GetSignatureHelpResponse, Background),
127    (GetTypeDefinition, Background),
128    (GetTypeDefinitionResponse, Background),
129    (GetImplementation, Background),
130    (GetImplementationResponse, Background),
131    (OpenUnstagedDiff, Foreground),
132    (OpenUnstagedDiffResponse, Foreground),
133    (OpenUncommittedDiff, Foreground),
134    (OpenUncommittedDiffResponse, Foreground),
135    (GetUsers, Foreground),
136    (GitGetBranches, Background),
137    (GitBranchesResponse, Background),
138    (Hello, Foreground),
139    (HideToast, Background),
140    (IncomingCall, Foreground),
141    (InlayHints, Background),
142    (InlayHintsResponse, Background),
143    (SemanticTokens, Background),
144    (SemanticTokensResponse, Background),
145    (InstallExtension, Background),
146    (InviteChannelMember, Foreground),
147    (JoinChannel, Foreground),
148    (JoinChannelBuffer, Foreground),
149    (JoinChannelBufferResponse, Foreground),
150    (JoinChannelChat, Foreground),
151    (JoinChannelChatResponse, Foreground),
152    (JoinProject, Foreground),
153    (JoinProjectResponse, Foreground),
154    (JoinRoom, Foreground),
155    (JoinRoomResponse, Foreground),
156    (LanguageServerLog, Foreground),
157    (LanguageServerPromptRequest, Foreground),
158    (LanguageServerPromptResponse, Foreground),
159    (LeaveChannelBuffer, Background),
160    (LeaveChannelChat, Foreground),
161    (LeaveProject, Foreground),
162    (LeaveRoom, Foreground),
163    (LinkedEditingRange, Background),
164    (LinkedEditingRangeResponse, Background),
165    (ListRemoteDirectory, Background),
166    (ListRemoteDirectoryResponse, Background),
167    (ListToolchains, Foreground),
168    (ListToolchainsResponse, Foreground),
169    (LoadCommitDiff, Foreground),
170    (LoadCommitDiffResponse, Foreground),
171    (LspExtExpandMacro, Background),
172    (LspExtExpandMacroResponse, Background),
173    (LspExtOpenDocs, Background),
174    (LspExtOpenDocsResponse, Background),
175    (LspExtRunnables, Background),
176    (LspExtRunnablesResponse, Background),
177    (LspExtSwitchSourceHeader, Background),
178    (LspExtSwitchSourceHeaderResponse, Background),
179    (LspExtGoToParentModule, Background),
180    (LspExtGoToParentModuleResponse, Background),
181    (LspExtCancelFlycheck, Background),
182    (LspExtRunFlycheck, Background),
183    (LspExtClearFlycheck, Background),
184    (MarkNotificationRead, Foreground),
185    (MoveChannel, Foreground),
186    (ReorderChannel, Foreground),
187    (LspQuery, Background),
188    (LspQueryResponse, Background),
189    (OnTypeFormatting, Background),
190    (OnTypeFormattingResponse, Background),
191    (OpenBufferById, Background),
192    (OpenBufferByPath, Background),
193    (OpenImageByPath, Background),
194    (OpenBufferForSymbol, Background),
195    (OpenBufferForSymbolResponse, Background),
196    (OpenBufferResponse, Background),
197    (OpenImageResponse, Background),
198    (OpenCommitMessageBuffer, Background),
199    (OpenNewBuffer, Foreground),
200    (OpenServerSettings, Foreground),
201    (PerformRename, Background),
202    (PerformRenameResponse, Background),
203    (Ping, Foreground),
204    (PrepareRename, Background),
205    (PrepareRenameResponse, Background),
206    (ProjectEntryResponse, Foreground),
207    (RefreshInlayHints, Background),
208    (RefreshSemanticTokens, Background),
209    (RefreshDocumentColors, Background),
210    (RefreshDocumentLinks, Background),
211    (RefreshFoldingRanges, Background),
212    (RefreshDocumentSymbols, Background),
213    (RegisterBufferWithLanguageServers, Background),
214    (RejoinChannelBuffers, Foreground),
215    (RejoinChannelBuffersResponse, Foreground),
216    (RejoinRemoteProjects, Foreground),
217    (RejoinRemoteProjectsResponse, Foreground),
218    (RejoinRoom, Foreground),
219    (RejoinRoomResponse, Foreground),
220    (ReloadBuffers, Foreground),
221    (ReloadBuffersResponse, Foreground),
222    (RemoveChannelMember, Foreground),
223    (RemoveChannelMessage, Foreground),
224    (RemoveContact, Foreground),
225    (RemoveProjectCollaborator, Foreground),
226    (RemoveWorktree, Foreground),
227    (RenameChannel, Foreground),
228    (RenameChannelResponse, Foreground),
229    (RenameProjectEntry, Foreground),
230    (RequestContact, Foreground),
231    (ResolveCompletionDocumentation, Background),
232    (ResolveCompletionDocumentationResponse, Background),
233    (ResolveInlayHint, Background),
234    (ResolveInlayHintResponse, Background),
235    (GetDocumentColor, Background),
236    (GetDocumentColorResponse, Background),
237    (GetColorPresentation, Background),
238    (GetColorPresentationResponse, Background),
239    (GetDocumentLinks, Background),
240    (GetDocumentLinksResponse, Background),
241    (ResolveDocumentLink, Background),
242    (ResolveDocumentLinkResponse, Background),
243    (GetFoldingRanges, Background),
244    (GetFoldingRangesResponse, Background),
245    (RefreshCodeLens, Background),
246    (GetCodeLens, Background),
247    (GetCodeLensResponse, Background),
248    (ResolveCodeAction, Background),
249    (ResolveCodeActionResponse, Background),
250    (RespondToChannelInvite, Foreground),
251    (RespondToContactRequest, Foreground),
252    (RestartLanguageServers, Foreground),
253    (StopLanguageServers, Background),
254    (RoomUpdated, Foreground),
255    (SaveBuffer, Foreground),
256    (SendChannelMessage, Background),
257    (SendChannelMessageResponse, Background),
258    (SetChannelMemberRole, Foreground),
259    (SetChannelVisibility, Foreground),
260    (SetRoomParticipantRole, Foreground),
261    (ShareProject, Foreground),
262    (ShareProjectResponse, Foreground),
263    (ShowContacts, Foreground),
264    (ShutdownRemoteServer, Foreground),
265    (Stage, Background),
266    (StartLanguageServer, Foreground),
267    (SubscribeToChannels, Foreground),
268    (SyncExtensions, Background),
269    (SyncExtensionsResponse, Background),
270    (BreakpointsForFile, Background),
271    (ToggleBreakpoint, Foreground),
272    (SynchronizeBuffers, Foreground),
273    (SynchronizeBuffersResponse, Foreground),
274    (TaskContext, Background),
275    (TaskContextForLocation, Background),
276    (TelemetryEvent, Background),
277    (Test, Foreground),
278    (Toast, Background),
279    (Unfollow, Foreground),
280    (UnshareProject, Foreground),
281    (Unstage, Background),
282    (Stash, Background),
283    (StashPop, Background),
284    (StashApply, Background),
285    (StashDrop, Background),
286    (UpdateBuffer, Foreground),
287    (UpdateBufferFile, Foreground),
288    (UpdateChannelBuffer, Foreground),
289    (UpdateChannelBufferCollaborators, Foreground),
290    (UpdateChannelMessage, Foreground),
291    (UpdateChannels, Foreground),
292    (UpdateContacts, Foreground),
293    (UpdateDiagnosticSummary, Foreground),
294    (UpdateDiffBases, Foreground),
295    (UpdateFollowers, Foreground),
296    (UpdateGitBranch, Background),
297    (UpdateLanguageServer, Foreground),
298    (UpdateNotification, Foreground),
299    (UpdateParticipantLocation, Foreground),
300    (UpdateProject, Foreground),
301    (UpdateProjectCollaborator, Foreground),
302    (UpdateUserChannels, Foreground),
303    (UpdateWorktree, Foreground),
304    (UpdateWorktreeSettings, Foreground),
305    (UpdateUserSettings, Background),
306    (UpdateRepository, Foreground),
307    (RemoveRepository, Foreground),
308    (UsersResponse, Foreground),
309    (GitReset, Background),
310    (GitDeleteBranch, Background),
311    (GitCheckoutFiles, Background),
312    (GitAddPathToGitignore, Background),
313    (GitAddPathToGitInfoExclude, Background),
314    (GitShow, Background),
315    (GitCommitDetails, Background),
316    (GitCreateCheckpoint, Background),
317    (GitCreateCheckpointResponse, Background),
318    (GitCreateArchiveCheckpoint, Background),
319    (GitCreateArchiveCheckpointResponse, Background),
320    (GitRestoreCheckpoint, Background),
321    (GitRestoreArchiveCheckpoint, Background),
322    (GitCompareCheckpoints, Background),
323    (GitCompareCheckpointsResponse, Background),
324    (GitDiffCheckpoints, Background),
325    (GitDiffCheckpointsResponse, Background),
326    (SetIndexText, Background),
327    (Push, Background),
328    (Fetch, Background),
329    (GetRemotes, Background),
330    (GetRemotesResponse, Background),
331    (Pull, Background),
332    (RemoteMessageResponse, Background),
333    (AskPassRequest, Background),
334    (AskPassResponse, Background),
335    (GitCreateRemote, Background),
336    (GitRemoveRemote, Background),
337    (GitCreateBranch, Background),
338    (GitChangeBranch, Background),
339    (GitRenameBranch, Background),
340    (TrustWorktrees, Background),
341    (RestrictWorktrees, Background),
342    (CheckForPushedCommits, Background),
343    (CheckForPushedCommitsResponse, Background),
344    (GitDiff, Background),
345    (GitDiffResponse, Background),
346    (GitInit, Background),
347    (GetDebugAdapterBinary, Background),
348    (DebugAdapterBinary, Background),
349    (RunDebugLocators, Background),
350    (DebugRequest, Background),
351    (LogToDebugConsole, Background),
352    (GetDocumentDiagnostics, Background),
353    (GetDocumentDiagnosticsResponse, Background),
354    (PullWorkspaceDiagnostics, Background),
355    (GetDefaultBranch, Background),
356    (GetDefaultBranchResponse, Background),
357    (GetTreeDiff, Background),
358    (GetTreeDiffResponse, Background),
359    (GetBlobContent, Background),
360    (GetBlobContentResponse, Background),
361    (LoadCommitTemplate, Background),
362    (LoadCommitTemplateResponse, Background),
363    (GitClone, Background),
364    (GitCloneResponse, Background),
365    (ToggleLspLogs, Background),
366    (GetDirectoryEnvironment, Background),
367    (DirectoryEnvironment, Background),
368    (GetAgentServerCommand, Background),
369    (AgentServerCommand, Background),
370    (GetContextServerCommand, Background),
371    (ContextServerCommand, Background),
372    (ExternalAgentsUpdated, Background),
373    (ExternalExtensionAgentsUpdated, Background),
374    (ExternalAgentLoadingStatusUpdated, Background),
375    (NewExternalAgentVersionAvailable, Background),
376    (RemoteStarted, Background),
377    (GitGetWorktrees, Background),
378    (GitGetHeadSha, Background),
379    (GitGetHeadShaResponse, Background),
380    (GitEditRef, Background),
381    (GitRepairWorktrees, Background),
382    (GetCommitData, Background),
383    (GetCommitDataResponse, Background),
384    (GetInitialGraphData, Background),
385    (GetInitialGraphDataResponse, Background),
386    (SearchCommits, Background),
387    (SearchCommitsResponse, Background),
388    (GitWorktreesResponse, Background),
389    (GitCreateWorktree, Background),
390    (GitRemoveWorktree, Background),
391    (GitRenameWorktree, Background),
392    (GitWorktreeCreatedAt, Background),
393    (GitWorktreeCreatedAtResponse, Background),
394    (FindSearchCandidatesChunk, Background),
395    (FindSearchCandidatesCancelled, Background),
396    (SpawnKernel, Background),
397    (SpawnKernelResponse, Background),
398    (KillKernel, Background),
399    (GetRemoteProfilingData, Background),
400    (GetRemoteProfilingDataResponse, Background),
401);
402
403request_messages!(
404    (AllocateWorktreeId, AllocateWorktreeIdResponse),
405    (ApplyCodeAction, ApplyCodeActionResponse),
406    (
407        ApplyCompletionAdditionalEdits,
408        ApplyCompletionAdditionalEditsResponse
409    ),
410    (Call, Ack),
411    (CancelCall, Ack),
412    (Commit, Ack),
413    (RunGitHook, Ack),
414    (CopyProjectEntry, ProjectEntryResponse),
415    (CreateChannel, CreateChannelResponse),
416    (CreateProjectEntry, ProjectEntryResponse),
417    (CreateRoom, CreateRoomResponse),
418    (DeclineCall, Ack),
419    (DeleteChannel, Ack),
420    (DeleteProjectEntry, ProjectEntryResponse),
421    (TrashProjectEntry, TrashProjectEntryResponse),
422    (RestoreProjectEntry, RestoreProjectEntryResponse),
423    (DownloadFileByPath, DownloadFileResponse),
424    (ExpandProjectEntry, ExpandProjectEntryResponse),
425    (ExpandAllForProjectEntry, ExpandAllForProjectEntryResponse),
426    (Follow, FollowResponse),
427    (ApplyCodeActionKind, ApplyCodeActionKindResponse),
428    (FormatBuffers, FormatBuffersResponse),
429    (FuzzySearchUsers, UsersResponse),
430    (GetChannelMembers, GetChannelMembersResponse),
431    (GetChannelMessages, GetChannelMessagesResponse),
432    (GetChannelMessagesById, GetChannelMessagesResponse),
433    (GetCodeActions, GetCodeActionsResponse),
434    (GetCompletions, GetCompletionsResponse),
435    (GetDefinition, GetDefinitionResponse),
436    (
437        GetEditPredictionDefinition,
438        GetEditPredictionDefinitionResponse
439    ),
440    (
441        GetEditPredictionTypeDefinition,
442        GetEditPredictionTypeDefinitionResponse
443    ),
444    (GetDeclaration, GetDeclarationResponse),
445    (GetImplementation, GetImplementationResponse),
446    (GetDocumentHighlights, GetDocumentHighlightsResponse),
447    (GetDocumentSymbols, GetDocumentSymbolsResponse),
448    (GetHover, GetHoverResponse),
449    (GetNotifications, GetNotificationsResponse),
450    (GetProjectSymbols, GetProjectSymbolsResponse),
451    (GetReferences, GetReferencesResponse),
452    (GetSignatureHelp, GetSignatureHelpResponse),
453    (OpenUnstagedDiff, OpenUnstagedDiffResponse),
454    (OpenUncommittedDiff, OpenUncommittedDiffResponse),
455    (GetTypeDefinition, GetTypeDefinitionResponse),
456    (LinkedEditingRange, LinkedEditingRangeResponse),
457    (ListRemoteDirectory, ListRemoteDirectoryResponse),
458    (GetUsers, UsersResponse),
459    (IncomingCall, Ack),
460    (InlayHints, InlayHintsResponse),
461    (SemanticTokens, SemanticTokensResponse),
462    (GetCodeLens, GetCodeLensResponse),
463    (InviteChannelMember, Ack),
464    (JoinChannel, JoinRoomResponse),
465    (JoinChannelBuffer, JoinChannelBufferResponse),
466    (JoinChannelChat, JoinChannelChatResponse),
467    (JoinProject, JoinProjectResponse),
468    (JoinRoom, JoinRoomResponse),
469    (LeaveChannelBuffer, Ack),
470    (LeaveRoom, Ack),
471    (LoadCommitDiff, LoadCommitDiffResponse),
472    (MarkNotificationRead, Ack),
473    (MoveChannel, Ack),
474    (OnTypeFormatting, OnTypeFormattingResponse),
475    (OpenBufferById, OpenBufferResponse),
476    (OpenBufferByPath, OpenBufferResponse),
477    (OpenImageByPath, OpenImageResponse),
478    (OpenBufferForSymbol, OpenBufferForSymbolResponse),
479    (OpenCommitMessageBuffer, OpenBufferResponse),
480    (OpenNewBuffer, OpenBufferResponse),
481    (PerformRename, PerformRenameResponse),
482    (Ping, Ack),
483    (PrepareRename, PrepareRenameResponse),
484    (RefreshInlayHints, Ack),
485    (RefreshSemanticTokens, Ack),
486    (RefreshCodeLens, Ack),
487    (RefreshDocumentColors, Ack),
488    (RefreshDocumentLinks, Ack),
489    (RefreshFoldingRanges, Ack),
490    (RefreshDocumentSymbols, Ack),
491    (RejoinChannelBuffers, RejoinChannelBuffersResponse),
492    (RejoinRoom, RejoinRoomResponse),
493    (ReloadBuffers, ReloadBuffersResponse),
494    (RemoveChannelMember, Ack),
495    (RemoveChannelMessage, Ack),
496    (UpdateChannelMessage, Ack),
497    (RemoveContact, Ack),
498    (RenameChannel, RenameChannelResponse),
499    (RenameProjectEntry, ProjectEntryResponse),
500    (ReorderChannel, Ack),
501    (RequestContact, Ack),
502    (
503        ResolveCompletionDocumentation,
504        ResolveCompletionDocumentationResponse
505    ),
506    (ResolveInlayHint, ResolveInlayHintResponse),
507    (ResolveCodeAction, ResolveCodeActionResponse),
508    (GetDocumentColor, GetDocumentColorResponse),
509    (GetDocumentLinks, GetDocumentLinksResponse),
510    (ResolveDocumentLink, ResolveDocumentLinkResponse),
511    (GetFoldingRanges, GetFoldingRangesResponse),
512    (GetColorPresentation, GetColorPresentationResponse),
513    (RespondToChannelInvite, Ack),
514    (RespondToContactRequest, Ack),
515    (SaveBuffer, BufferSaved),
516    (Stage, Ack),
517    (FindSearchCandidates, Ack),
518    (SendChannelMessage, SendChannelMessageResponse),
519    (SetChannelMemberRole, Ack),
520    (SetChannelVisibility, Ack),
521    (ShareProject, ShareProjectResponse),
522    (SynchronizeBuffers, SynchronizeBuffersResponse),
523    (TaskContextForLocation, TaskContext),
524    (Test, Test),
525    (Unstage, Ack),
526    (Stash, Ack),
527    (StashPop, Ack),
528    (StashApply, Ack),
529    (StashDrop, Ack),
530    (UpdateBuffer, Ack),
531    (UpdateParticipantLocation, Ack),
532    (UpdateProject, Ack),
533    (UpdateWorktree, Ack),
534    (UpdateRepository, Ack),
535    (RemoveRepository, Ack),
536    (LspExtExpandMacro, LspExtExpandMacroResponse),
537    (LspExtOpenDocs, LspExtOpenDocsResponse),
538    (LspExtRunnables, LspExtRunnablesResponse),
539    (SetRoomParticipantRole, Ack),
540    (BlameBuffer, BlameBufferResponse),
541    (RejoinRemoteProjects, RejoinRemoteProjectsResponse),
542    (LspQuery, Ack),
543    (LspQueryResponse, Ack),
544    (RestartLanguageServers, Ack),
545    (StopLanguageServers, Ack),
546    (LspExtSwitchSourceHeader, LspExtSwitchSourceHeaderResponse),
547    (LspExtGoToParentModule, LspExtGoToParentModuleResponse),
548    (LspExtCancelFlycheck, Ack),
549    (LspExtRunFlycheck, Ack),
550    (LspExtClearFlycheck, Ack),
551    (AddWorktree, AddWorktreeResponse),
552    (ShutdownRemoteServer, Ack),
553    (RemoveWorktree, Ack),
554    (OpenServerSettings, OpenBufferResponse),
555    (GetPermalinkToLine, GetPermalinkToLineResponse),
556    (FlushBufferedMessages, Ack),
557    (LanguageServerPromptRequest, LanguageServerPromptResponse),
558    (GitGetBranches, GitBranchesResponse),
559    (UpdateGitBranch, Ack),
560    (ListToolchains, ListToolchainsResponse),
561    (ActivateToolchain, Ack),
562    (ActiveToolchain, ActiveToolchainResponse),
563    (ResolveToolchain, ResolveToolchainResponse),
564    (GetPathMetadata, GetPathMetadataResponse),
565    (GetCrashFiles, GetCrashFilesResponse),
566    (CancelLanguageServerWork, Ack),
567    (SyncExtensions, SyncExtensionsResponse),
568    (InstallExtension, Ack),
569    (RegisterBufferWithLanguageServers, Ack),
570    (GitShow, GitCommitDetails),
571    (GitCreateCheckpoint, GitCreateCheckpointResponse),
572    (
573        GitCreateArchiveCheckpoint,
574        GitCreateArchiveCheckpointResponse
575    ),
576    (GitRestoreCheckpoint, Ack),
577    (GitRestoreArchiveCheckpoint, Ack),
578    (GitCompareCheckpoints, GitCompareCheckpointsResponse),
579    (GitDiffCheckpoints, GitDiffCheckpointsResponse),
580    (GitReset, Ack),
581    (GitDeleteBranch, Ack),
582    (GitCheckoutFiles, Ack),
583    (GitAddPathToGitignore, Ack),
584    (GitAddPathToGitInfoExclude, Ack),
585    (SetIndexText, Ack),
586    (Push, RemoteMessageResponse),
587    (Fetch, RemoteMessageResponse),
588    (GetRemotes, GetRemotesResponse),
589    (Pull, RemoteMessageResponse),
590    (AskPassRequest, AskPassResponse),
591    (GitCreateRemote, Ack),
592    (GitRemoveRemote, Ack),
593    (GitCreateBranch, Ack),
594    (GitChangeBranch, Ack),
595    (GitRenameBranch, Ack),
596    (CheckForPushedCommits, CheckForPushedCommitsResponse),
597    (GitDiff, GitDiffResponse),
598    (GitInit, Ack),
599    (ToggleBreakpoint, Ack),
600    (GetDebugAdapterBinary, DebugAdapterBinary),
601    (RunDebugLocators, DebugRequest),
602    (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse),
603    (PullWorkspaceDiagnostics, Ack),
604    (GetDefaultBranch, GetDefaultBranchResponse),
605    (GetBlobContent, GetBlobContentResponse),
606    (LoadCommitTemplate, LoadCommitTemplateResponse),
607    (GetTreeDiff, GetTreeDiffResponse),
608    (GitClone, GitCloneResponse),
609    (ToggleLspLogs, Ack),
610    (GetDirectoryEnvironment, DirectoryEnvironment),
611    (GetProcesses, GetProcessesResponse),
612    (GetAgentServerCommand, AgentServerCommand),
613    (GetContextServerCommand, ContextServerCommand),
614    (RemoteStarted, Ack),
615    (GitGetWorktrees, GitWorktreesResponse),
616    (GitGetHeadSha, GitGetHeadShaResponse),
617    (GitEditRef, Ack),
618    (GitRepairWorktrees, Ack),
619    (GetCommitData, GetCommitDataResponse),
620    (GetInitialGraphData, GetInitialGraphDataResponse),
621    (SearchCommits, SearchCommitsResponse),
622    (GitCreateWorktree, Ack),
623    (GitRemoveWorktree, Ack),
624    (GitRenameWorktree, Ack),
625    (GitWorktreeCreatedAt, GitWorktreeCreatedAtResponse),
626    (TrustWorktrees, Ack),
627    (RestrictWorktrees, Ack),
628    (FindSearchCandidatesChunk, Ack),
629    (SpawnKernel, SpawnKernelResponse),
630    (KillKernel, Ack),
631    (GetRemoteProfilingData, GetRemoteProfilingDataResponse),
632);
633
634lsp_messages!(
635    (GetReferences, GetReferencesResponse, true),
636    (GetDocumentColor, GetDocumentColorResponse, true),
637    (GetFoldingRanges, GetFoldingRangesResponse, true),
638    (GetDocumentSymbols, GetDocumentSymbolsResponse, true),
639    (GetDocumentLinks, GetDocumentLinksResponse, true),
640    (GetHover, GetHoverResponse, true),
641    (GetCodeActions, GetCodeActionsResponse, true),
642    (GetSignatureHelp, GetSignatureHelpResponse, true),
643    (GetCodeLens, GetCodeLensResponse, true),
644    (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse, true),
645    (GetDefinition, GetDefinitionResponse, true),
646    (
647        GetEditPredictionDefinition,
648        GetEditPredictionDefinitionResponse,
649        true
650    ),
651    (
652        GetEditPredictionTypeDefinition,
653        GetEditPredictionTypeDefinitionResponse,
654        true
655    ),
656    (GetDeclaration, GetDeclarationResponse, true),
657    (GetTypeDefinition, GetTypeDefinitionResponse, true),
658    (GetImplementation, GetImplementationResponse, true),
659    (InlayHints, InlayHintsResponse, false),
660    (SemanticTokens, SemanticTokensResponse, true)
661);
662
663entity_messages!(
664    {project_id, ShareProject},
665    AddProjectCollaborator,
666    AddWorktree,
667    AllocateWorktreeId,
668    ApplyCodeAction,
669    ApplyCompletionAdditionalEdits,
670    BlameBuffer,
671    BufferReloaded,
672    BufferSaved,
673    CloseBuffer,
674    Commit,
675    RunGitHook,
676    GetColorPresentation,
677    CopyProjectEntry,
678    CreateBufferForPeer,
679    CreateFileForPeer,
680    CreateImageForPeer,
681    CreateProjectEntry,
682    GetDocumentColor,
683    GetDocumentLinks,
684    ResolveDocumentLink,
685    GetFoldingRanges,
686    DeleteProjectEntry,
687    TrashProjectEntry,
688    RestoreProjectEntry,
689    ExpandProjectEntry,
690    ExpandAllForProjectEntry,
691    FindSearchCandidates,
692    ApplyCodeActionKind,
693    FormatBuffers,
694    GetCodeActions,
695    GetCodeLens,
696    GetCompletions,
697    GetDefinition,
698    GetEditPredictionDefinition,
699    GetEditPredictionTypeDefinition,
700    GetDeclaration,
701    GetImplementation,
702    GetDocumentHighlights,
703    GetDocumentSymbols,
704    GetHover,
705    GetProjectSymbols,
706    GetReferences,
707    GetSignatureHelp,
708    OpenUnstagedDiff,
709    OpenUncommittedDiff,
710    GetTypeDefinition,
711    InlayHints,
712    SemanticTokens,
713    JoinProject,
714    LeaveProject,
715    SpawnKernel,
716    KillKernel,
717    LinkedEditingRange,
718    LoadCommitDiff,
719    LspQuery,
720    LspQueryResponse,
721    RestartLanguageServers,
722    StopLanguageServers,
723    OnTypeFormatting,
724    OpenNewBuffer,
725    OpenBufferById,
726    OpenBufferByPath,
727    OpenImageByPath,
728    OpenBufferForSymbol,
729    OpenCommitMessageBuffer,
730    PerformRename,
731    PrepareRename,
732    RefreshInlayHints,
733    RefreshSemanticTokens,
734    RefreshCodeLens,
735    RefreshDocumentColors,
736    RefreshDocumentLinks,
737    RefreshFoldingRanges,
738    RefreshDocumentSymbols,
739    ReloadBuffers,
740    RemoveProjectCollaborator,
741    RenameProjectEntry,
742    ResolveCompletionDocumentation,
743    ResolveInlayHint,
744    ResolveCodeAction,
745    SaveBuffer,
746    Stage,
747    StartLanguageServer,
748    SynchronizeBuffers,
749    TaskContextForLocation,
750    UnshareProject,
751    Unstage,
752    Stash,
753    StashPop,
754    StashApply,
755    StashDrop,
756    UpdateBuffer,
757    UpdateBufferFile,
758    UpdateDiagnosticSummary,
759    UpdateDiffBases,
760    UpdateLanguageServer,
761    UpdateProject,
762    UpdateProjectCollaborator,
763    UpdateWorktree,
764    UpdateRepository,
765    RemoveRepository,
766    UpdateWorktreeSettings,
767    UpdateUserSettings,
768    LspExtExpandMacro,
769    LspExtOpenDocs,
770    LspExtRunnables,
771    LspExtSwitchSourceHeader,
772    LspExtGoToParentModule,
773    LspExtCancelFlycheck,
774    LspExtRunFlycheck,
775    LspExtClearFlycheck,
776    LanguageServerLog,
777    TelemetryEvent,
778    Toast,
779    HideToast,
780    OpenServerSettings,
781    GetPermalinkToLine,
782    LanguageServerPromptRequest,
783    GitGetBranches,
784    UpdateGitBranch,
785    ListToolchains,
786    ActivateToolchain,
787    ActiveToolchain,
788    ResolveToolchain,
789    GetPathMetadata,
790    GetProcesses,
791    CancelLanguageServerWork,
792    RegisterBufferWithLanguageServers,
793    GitShow,
794    GitCreateCheckpoint,
795    GitRestoreCheckpoint,
796    GitCompareCheckpoints,
797    GitDiffCheckpoints,
798    GitReset,
799    GitDeleteBranch,
800    GitCheckoutFiles,
801    GitAddPathToGitignore,
802    GitAddPathToGitInfoExclude,
803    SetIndexText,
804    ToggleLspLogs,
805    GetDirectoryEnvironment,
806
807    Push,
808    Fetch,
809    GetRemotes,
810    Pull,
811    AskPassRequest,
812    GitChangeBranch,
813    GitRenameBranch,
814    GitCreateBranch,
815    GitCreateRemote,
816    GitRemoveRemote,
817    CheckForPushedCommits,
818    GitDiff,
819    GitInit,
820    BreakpointsForFile,
821    ToggleBreakpoint,
822    RunDebugLocators,
823    GetDebugAdapterBinary,
824    LogToDebugConsole,
825    GetDocumentDiagnostics,
826    PullWorkspaceDiagnostics,
827    GetDefaultBranch,
828    GetTreeDiff,
829    GetBlobContent,
830    LoadCommitTemplate,
831    GitClone,
832    GetAgentServerCommand,
833    GetContextServerCommand,
834    ExternalAgentsUpdated,
835    ExternalExtensionAgentsUpdated,
836    ExternalAgentLoadingStatusUpdated,
837    NewExternalAgentVersionAvailable,
838    GitGetWorktrees,
839    GitGetHeadSha,
840    GitEditRef,
841    GitRepairWorktrees,
842    GetCommitData,
843    GetInitialGraphData,
844    SearchCommits,
845    GitCreateArchiveCheckpoint,
846    GitRestoreArchiveCheckpoint,
847    GitCreateWorktree,
848    GitRemoveWorktree,
849    GitRenameWorktree,
850    GitWorktreeCreatedAt,
851    TrustWorktrees,
852    RestrictWorktrees,
853    FindSearchCandidatesChunk,
854    FindSearchCandidatesCancelled,
855    DownloadFileByPath,
856    GetRemoteProfilingData
857);
858
859entity_messages!(
860    {channel_id, Channel},
861    ChannelMessageSent,
862    ChannelMessageUpdate,
863    RemoveChannelMessage,
864    UpdateChannelMessage,
865    UpdateChannelBuffer,
866    UpdateChannelBufferCollaborators,
867);
868
869impl From<Timestamp> for SystemTime {
870    fn from(val: Timestamp) -> Self {
871        UNIX_EPOCH
872            .checked_add(Duration::new(val.seconds, val.nanos))
873            .unwrap()
874    }
875}
876
877impl From<SystemTime> for Timestamp {
878    fn from(time: SystemTime) -> Self {
879        let duration = time.duration_since(UNIX_EPOCH).unwrap_or_default();
880        Self {
881            seconds: duration.as_secs(),
882            nanos: duration.subsec_nanos(),
883        }
884    }
885}
886
887impl From<u128> for Nonce {
888    fn from(nonce: u128) -> Self {
889        let upper_half = (nonce >> 64) as u64;
890        let lower_half = nonce as u64;
891        Self {
892            upper_half,
893            lower_half,
894        }
895    }
896}
897
898impl From<Nonce> for u128 {
899    fn from(nonce: Nonce) -> Self {
900        let upper_half = (nonce.upper_half as u128) << 64;
901        let lower_half = nonce.lower_half as u128;
902        upper_half | lower_half
903    }
904}
905
906#[cfg(any(test, feature = "test-support"))]
907pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 2;
908#[cfg(not(any(test, feature = "test-support")))]
909pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 256;
910
911pub fn split_worktree_update(mut message: UpdateWorktree) -> impl Iterator<Item = UpdateWorktree> {
912    let mut done = false;
913
914    iter::from_fn(move || {
915        if done {
916            return None;
917        }
918
919        let updated_entries_chunk_size = cmp::min(
920            message.updated_entries.len(),
921            MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
922        );
923        let updated_entries: Vec<_> = message
924            .updated_entries
925            .drain(..updated_entries_chunk_size)
926            .collect();
927
928        let removed_entries_chunk_size = cmp::min(
929            message.removed_entries.len(),
930            MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
931        );
932        let removed_entries = message
933            .removed_entries
934            .drain(..removed_entries_chunk_size)
935            .collect();
936
937        let mut updated_repositories = Vec::new();
938        let mut limit = MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE;
939        while let Some(repo) = message.updated_repositories.first_mut() {
940            let updated_statuses_limit = cmp::min(repo.updated_statuses.len(), limit);
941            let removed_statuses_limit = cmp::min(repo.removed_statuses.len(), limit);
942
943            updated_repositories.push(RepositoryEntry {
944                repository_id: repo.repository_id,
945                branch_summary: repo.branch_summary.clone(),
946                updated_statuses: repo
947                    .updated_statuses
948                    .drain(..updated_statuses_limit)
949                    .collect(),
950                removed_statuses: repo
951                    .removed_statuses
952                    .drain(..removed_statuses_limit)
953                    .collect(),
954                current_merge_conflicts: repo.current_merge_conflicts.clone(),
955            });
956            if repo.removed_statuses.is_empty() && repo.updated_statuses.is_empty() {
957                message.updated_repositories.remove(0);
958            }
959            limit = limit.saturating_sub(removed_statuses_limit + updated_statuses_limit);
960            if limit == 0 {
961                break;
962            }
963        }
964
965        done = message.updated_entries.is_empty()
966            && message.removed_entries.is_empty()
967            && message.updated_repositories.is_empty();
968
969        let removed_repositories = if done {
970            mem::take(&mut message.removed_repositories)
971        } else {
972            Default::default()
973        };
974
975        Some(UpdateWorktree {
976            project_id: message.project_id,
977            worktree_id: message.worktree_id,
978            root_name: message.root_name.clone(),
979            abs_path: message.abs_path.clone(),
980            root_repo_common_dir: message.root_repo_common_dir.clone(),
981            root_repo_is_linked_worktree: message.root_repo_is_linked_worktree,
982            updated_entries,
983            removed_entries,
984            scan_id: message.scan_id,
985            is_last_update: done && message.is_last_update,
986            updated_repositories,
987            removed_repositories,
988        })
989    })
990}
991
992pub fn split_repository_update(
993    mut update: UpdateRepository,
994) -> impl Iterator<Item = UpdateRepository> {
995    let mut updated_statuses_iter = mem::take(&mut update.updated_statuses).into_iter().fuse();
996    let mut removed_statuses_iter = mem::take(&mut update.removed_statuses).into_iter().fuse();
997    let branch_list = mem::take(&mut update.branch_list);
998    let branch_list_error = update.branch_list_error.take();
999    std::iter::from_fn({
1000        let update = update.clone();
1001        move || {
1002            let updated_statuses = updated_statuses_iter
1003                .by_ref()
1004                .take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
1005                .collect::<Vec<_>>();
1006            let removed_statuses = removed_statuses_iter
1007                .by_ref()
1008                .take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
1009                .collect::<Vec<_>>();
1010            if updated_statuses.is_empty() && removed_statuses.is_empty() {
1011                return None;
1012            }
1013            Some(UpdateRepository {
1014                updated_statuses,
1015                removed_statuses,
1016                branch_list: Vec::new(),
1017                branch_list_error: None,
1018                is_last_update: false,
1019                ..update.clone()
1020            })
1021        }
1022    })
1023    .chain([UpdateRepository {
1024        updated_statuses: Vec::new(),
1025        removed_statuses: Vec::new(),
1026        branch_list,
1027        branch_list_error,
1028        is_last_update: true,
1029        ..update
1030    }])
1031}
1032
1033impl LspQuery {
1034    pub fn query_name_and_write_permissions(&self) -> (&str, bool) {
1035        match self.request {
1036            Some(lsp_query::Request::GetHover(_)) => ("GetHover", false),
1037            Some(lsp_query::Request::GetCodeActions(_)) => ("GetCodeActions", true),
1038            Some(lsp_query::Request::GetSignatureHelp(_)) => ("GetSignatureHelp", false),
1039            Some(lsp_query::Request::GetCodeLens(_)) => ("GetCodeLens", true),
1040            Some(lsp_query::Request::GetDocumentDiagnostics(_)) => {
1041                ("GetDocumentDiagnostics", false)
1042            }
1043            Some(lsp_query::Request::GetDefinition(_)) => ("GetDefinition", false),
1044            Some(lsp_query::Request::GetEditPredictionDefinition(_)) => {
1045                ("GetEditPredictionDefinition", false)
1046            }
1047            Some(lsp_query::Request::GetEditPredictionTypeDefinition(_)) => {
1048                ("GetEditPredictionTypeDefinition", false)
1049            }
1050            Some(lsp_query::Request::GetDeclaration(_)) => ("GetDeclaration", false),
1051            Some(lsp_query::Request::GetTypeDefinition(_)) => ("GetTypeDefinition", false),
1052            Some(lsp_query::Request::GetImplementation(_)) => ("GetImplementation", false),
1053            Some(lsp_query::Request::GetReferences(_)) => ("GetReferences", false),
1054            Some(lsp_query::Request::GetDocumentColor(_)) => ("GetDocumentColor", false),
1055            Some(lsp_query::Request::GetFoldingRanges(_)) => ("GetFoldingRanges", false),
1056            Some(lsp_query::Request::GetDocumentSymbols(_)) => ("GetDocumentSymbols", false),
1057            Some(lsp_query::Request::GetDocumentLinks(_)) => ("GetDocumentLinks", false),
1058            Some(lsp_query::Request::InlayHints(_)) => ("InlayHints", false),
1059            Some(lsp_query::Request::SemanticTokens(_)) => ("SemanticTokens", false),
1060            None => ("<unknown>", true),
1061        }
1062    }
1063}
1064
1065#[cfg(test)]
1066mod tests {
1067    use super::*;
1068
1069    #[test]
1070    fn test_converting_peer_id_from_and_to_u64() {
1071        let peer_id = PeerId {
1072            owner_id: 10,
1073            id: 3,
1074        };
1075        assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
1076        let peer_id = PeerId {
1077            owner_id: u32::MAX,
1078            id: 3,
1079        };
1080        assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
1081        let peer_id = PeerId {
1082            owner_id: 10,
1083            id: u32::MAX,
1084        };
1085        assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
1086        let peer_id = PeerId {
1087            owner_id: u32::MAX,
1088            id: u32::MAX,
1089        };
1090        assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
1091    }
1092
1093    #[test]
1094    fn test_split_repository_update_keeps_branch_list_on_final_chunk() {
1095        let update = UpdateRepository {
1096            updated_statuses: vec![
1097                StatusEntry::default(),
1098                StatusEntry::default(),
1099                StatusEntry::default(),
1100            ],
1101            branch_list: vec![Branch {
1102                ref_name: "refs/heads/main".into(),
1103                ..Default::default()
1104            }],
1105            branch_list_error: Some("partial branch scan".into()),
1106            ..Default::default()
1107        };
1108
1109        let chunks = split_repository_update(update).collect::<Vec<_>>();
1110
1111        assert_eq!(chunks.len(), 3);
1112        assert!(chunks[0].branch_list.is_empty());
1113        assert!(chunks[1].branch_list.is_empty());
1114        assert_eq!(chunks[2].branch_list.len(), 1);
1115        assert_eq!(chunks[2].branch_list[0].ref_name, "refs/heads/main");
1116        assert_eq!(chunks[0].branch_list_error, None);
1117        assert_eq!(chunks[1].branch_list_error, None);
1118        assert_eq!(
1119            chunks[2].branch_list_error.as_deref(),
1120            Some("partial branch scan")
1121        );
1122        assert!(!chunks[0].is_last_update);
1123        assert!(!chunks[1].is_last_update);
1124        assert!(chunks[2].is_last_update);
1125    }
1126}
1127
Served at tenant.openagents/omega Member data and write actions are omitted.