syntax = "proto3";
package zed.messages;

import "ai.proto";
import "app.proto";
import "buffer.proto";
import "call.proto";
import "channel.proto";
import "core.proto";
import "debugger.proto";
import "download.proto";
import "git.proto";
import "image.proto";
import "lsp.proto";
import "notification.proto";
import "task.proto";
import "toolchain.proto";
import "worktree.proto";

// Looking for a number? Search "// current max"
message Envelope {
  uint32 id = 1;
  optional uint32 responding_to = 2;
  optional PeerId original_sender_id = 3;
  optional uint32 ack_id = 266;

  oneof payload {
    Hello hello = 4;
    Ack ack = 5;
    Error error = 6;
    Ping ping = 7;
    Test test = 8;
    EndStream end_stream = 165;

    CreateRoom create_room = 9;
    CreateRoomResponse create_room_response = 10;
    JoinRoom join_room = 11;
    JoinRoomResponse join_room_response = 12;
    RejoinRoom rejoin_room = 13;
    RejoinRoomResponse rejoin_room_response = 14;
    LeaveRoom leave_room = 15;
    Call call = 16;
    IncomingCall incoming_call = 17;
    CallCanceled call_canceled = 18;
    CancelCall cancel_call = 19;
    DeclineCall decline_call = 20;
    UpdateParticipantLocation update_participant_location = 21;
    RoomUpdated room_updated = 22;

    ShareProject share_project = 23;
    ShareProjectResponse share_project_response = 24;
    UnshareProject unshare_project = 25;
    JoinProject join_project = 26;
    JoinProjectResponse join_project_response = 27;
    LeaveProject leave_project = 28;
    AddProjectCollaborator add_project_collaborator = 29;
    UpdateProjectCollaborator update_project_collaborator = 30;
    RemoveProjectCollaborator remove_project_collaborator = 31;

    GetDefinition get_definition = 32;
    GetDefinitionResponse get_definition_response = 33;
    GetDeclaration get_declaration = 237;
    GetDeclarationResponse get_declaration_response = 238;
    GetTypeDefinition get_type_definition = 34;
    GetTypeDefinitionResponse get_type_definition_response = 35;

    GetReferences get_references = 36;
    GetReferencesResponse get_references_response = 37;
    GetDocumentHighlights get_document_highlights = 38;
    GetDocumentHighlightsResponse get_document_highlights_response = 39;
    GetProjectSymbols get_project_symbols = 40;
    GetProjectSymbolsResponse get_project_symbols_response = 41;
    OpenBufferForSymbol open_buffer_for_symbol = 42;
    OpenBufferForSymbolResponse open_buffer_for_symbol_response = 43;

    UpdateProject update_project = 44;
    UpdateWorktree update_worktree = 45;

    CreateProjectEntry create_project_entry = 46;
    RenameProjectEntry rename_project_entry = 47;
    CopyProjectEntry copy_project_entry = 48;
    DeleteProjectEntry delete_project_entry = 49;
    ProjectEntryResponse project_entry_response = 50;
    ExpandProjectEntry expand_project_entry = 51;
    ExpandProjectEntryResponse expand_project_entry_response = 52;
    ExpandAllForProjectEntry expand_all_for_project_entry = 291;
    ExpandAllForProjectEntryResponse expand_all_for_project_entry_response = 292;
    UpdateDiagnosticSummary update_diagnostic_summary = 53;
    StartLanguageServer start_language_server = 54;
    UpdateLanguageServer update_language_server = 55;

    OpenBufferById open_buffer_by_id = 56;
    OpenBufferByPath open_buffer_by_path = 57;
    OpenBufferResponse open_buffer_response = 58;
    CreateBufferForPeer create_buffer_for_peer = 59;
    UpdateBuffer update_buffer = 60;
    UpdateBufferFile update_buffer_file = 61;
    SaveBuffer save_buffer = 62;
    BufferSaved buffer_saved = 63;
    BufferReloaded buffer_reloaded = 64;
    ReloadBuffers reload_buffers = 65;
    ReloadBuffersResponse reload_buffers_response = 66;
    SynchronizeBuffers synchronize_buffers = 67;
    SynchronizeBuffersResponse synchronize_buffers_response = 68;
    FormatBuffers format_buffers = 69;
    FormatBuffersResponse format_buffers_response = 70;
    GetCompletions get_completions = 71;
    GetCompletionsResponse get_completions_response = 72;
    ResolveCompletionDocumentation resolve_completion_documentation = 73;
    ResolveCompletionDocumentationResponse resolve_completion_documentation_response = 74;
    ApplyCompletionAdditionalEdits apply_completion_additional_edits = 75;
    ApplyCompletionAdditionalEditsResponse apply_completion_additional_edits_response = 76;
    GetCodeActions get_code_actions = 77;
    GetCodeActionsResponse get_code_actions_response = 78;
    GetHover get_hover = 79;
    GetHoverResponse get_hover_response = 80;
    ApplyCodeAction apply_code_action = 81;
    ApplyCodeActionResponse apply_code_action_response = 82;
    PrepareRename prepare_rename = 83;
    PrepareRenameResponse prepare_rename_response = 84;
    PerformRename perform_rename = 85;
    PerformRenameResponse perform_rename_response = 86;

    UpdateContacts update_contacts = 89;
    ShowContacts show_contacts = 91;

    GetUsers get_users = 92;
    FuzzySearchUsers fuzzy_search_users = 93;
    UsersResponse users_response = 94;
    RequestContact request_contact = 95;
    RespondToContactRequest respond_to_contact_request = 96;
    RemoveContact remove_contact = 97;

    Follow follow = 98;
    FollowResponse follow_response = 99;
    UpdateFollowers update_followers = 100;
    Unfollow unfollow = 101;
    UpdateDiffBases update_diff_bases = 104;

    OnTypeFormatting on_type_formatting = 105;
    OnTypeFormattingResponse on_type_formatting_response = 106;

    UpdateWorktreeSettings update_worktree_settings = 107;

    InlayHints inlay_hints = 108;
    InlayHintsResponse inlay_hints_response = 109;
    ResolveInlayHint resolve_inlay_hint = 110;
    ResolveInlayHintResponse resolve_inlay_hint_response = 111;
    RefreshInlayHints refresh_inlay_hints = 112;

    CreateChannel create_channel = 113;
    CreateChannelResponse create_channel_response = 114;
    InviteChannelMember invite_channel_member = 115;
    RemoveChannelMember remove_channel_member = 116;
    RespondToChannelInvite respond_to_channel_invite = 117;
    UpdateChannels update_channels = 118;
    JoinChannel join_channel = 119;
    DeleteChannel delete_channel = 120;
    GetChannelMembers get_channel_members = 121;
    GetChannelMembersResponse get_channel_members_response = 122;
    SetChannelMemberRole set_channel_member_role = 123;
    RenameChannel rename_channel = 124;
    RenameChannelResponse rename_channel_response = 125;
    SubscribeToChannels subscribe_to_channels = 207;

    JoinChannelBuffer join_channel_buffer = 126;
    JoinChannelBufferResponse join_channel_buffer_response = 127;
    UpdateChannelBuffer update_channel_buffer = 128;
    LeaveChannelBuffer leave_channel_buffer = 129;
    UpdateChannelBufferCollaborators update_channel_buffer_collaborators = 130;
    RejoinChannelBuffers rejoin_channel_buffers = 131;
    RejoinChannelBuffersResponse rejoin_channel_buffers_response = 132;
    AckBufferOperation ack_buffer_operation = 133;

    JoinChannelChat join_channel_chat = 134;
    JoinChannelChatResponse join_channel_chat_response = 135;
    LeaveChannelChat leave_channel_chat = 136;
    SendChannelMessage send_channel_message = 137;
    SendChannelMessageResponse send_channel_message_response = 138;
    ChannelMessageSent channel_message_sent = 139;
    GetChannelMessages get_channel_messages = 140;
    GetChannelMessagesResponse get_channel_messages_response = 141;
    RemoveChannelMessage remove_channel_message = 142;
    AckChannelMessage ack_channel_message = 143;
    GetChannelMessagesById get_channel_messages_by_id = 144;

    MoveChannel move_channel = 147;
    ReorderChannel reorder_channel = 349;
    SetChannelVisibility set_channel_visibility = 148;

    AddNotification add_notification = 149;
    GetNotifications get_notifications = 150;
    GetNotificationsResponse get_notifications_response = 151;
    DeleteNotification delete_notification = 152;
    MarkNotificationRead mark_notification_read = 153;
    LspExtExpandMacro lsp_ext_expand_macro = 154;
    LspExtExpandMacroResponse lsp_ext_expand_macro_response = 155;
    SetRoomParticipantRole set_room_participant_role = 156;

    UpdateUserChannels update_user_channels = 157;

    GetImplementation get_implementation = 162;
    GetImplementationResponse get_implementation_response = 163;

    UpdateChannelMessage update_channel_message = 170;
    ChannelMessageUpdate channel_message_update = 171;

    BlameBuffer blame_buffer = 172;
    BlameBufferResponse blame_buffer_response = 173;

    UpdateNotification update_notification = 174;

    RestartLanguageServers restart_language_servers = 208;

    RejoinRemoteProjects rejoin_remote_projects = 186;
    RejoinRemoteProjectsResponse rejoin_remote_projects_response = 187;

    OpenNewBuffer open_new_buffer = 196;

    TaskContextForLocation task_context_for_location = 203;
    TaskContext task_context = 204;

    LinkedEditingRange linked_editing_range = 209;
    LinkedEditingRangeResponse linked_editing_range_response = 210;

    GetSignatureHelp get_signature_help = 217;
    GetSignatureHelpResponse get_signature_help_response = 218;

    ListRemoteDirectory list_remote_directory = 219;
    ListRemoteDirectoryResponse list_remote_directory_response = 220;
    AddWorktree add_worktree = 222;
    AddWorktreeResponse add_worktree_response = 223;

    LspExtSwitchSourceHeader lsp_ext_switch_source_header = 241;
    LspExtSwitchSourceHeaderResponse lsp_ext_switch_source_header_response = 242;

    FindSearchCandidates find_search_candidates = 243;

    CloseBuffer close_buffer = 245;

    ShutdownRemoteServer shutdown_remote_server = 257;

    RemoveWorktree remove_worktree = 258;

    LanguageServerLog language_server_log = 260;

    Toast toast = 261;
    HideToast hide_toast = 262;

    OpenServerSettings open_server_settings = 263;

    GetPermalinkToLine get_permalink_to_line = 264;
    GetPermalinkToLineResponse get_permalink_to_line_response = 265;

    FlushBufferedMessages flush_buffered_messages = 267;

    LanguageServerPromptRequest language_server_prompt_request = 268;
    LanguageServerPromptResponse language_server_prompt_response = 269;

    GitBranchesResponse git_branches_response = 271;

    UpdateGitBranch update_git_branch = 272;

    ListToolchains list_toolchains = 273;
    ListToolchainsResponse list_toolchains_response = 274;
    ActivateToolchain activate_toolchain = 275;
    ActiveToolchain active_toolchain = 276;
    ActiveToolchainResponse active_toolchain_response = 277;

    GetPathMetadata get_path_metadata = 278;
    GetPathMetadataResponse get_path_metadata_response = 279;

    CancelLanguageServerWork cancel_language_server_work = 282;

    LspExtOpenDocs lsp_ext_open_docs = 283;
    LspExtOpenDocsResponse lsp_ext_open_docs_response = 284;

    SyncExtensions sync_extensions = 285;
    SyncExtensionsResponse sync_extensions_response = 286;
    InstallExtension install_extension = 287;

    OpenUnstagedDiff open_unstaged_diff = 288;
    OpenUnstagedDiffResponse open_unstaged_diff_response = 289;

    RegisterBufferWithLanguageServers register_buffer_with_language_servers = 290;

    Stage stage = 293;
    Unstage unstage = 294;
    Commit commit = 295;
    OpenCommitMessageBuffer open_commit_message_buffer = 296;

    OpenUncommittedDiff open_uncommitted_diff = 297;
    OpenUncommittedDiffResponse open_uncommitted_diff_response = 298;

    SetIndexText set_index_text = 299;

    GitShow git_show = 300;
    GitReset git_reset = 301;
    GitCommitDetails git_commit_details = 302;
    GitCheckoutFiles git_checkout_files = 303;

    Push push = 304;
    Fetch fetch = 305;
    GetRemotes get_remotes = 306;
    GetRemotesResponse get_remotes_response = 307;
    Pull pull = 308;

    ApplyCodeActionKind apply_code_action_kind = 309;
    ApplyCodeActionKindResponse apply_code_action_kind_response = 310;

    RemoteMessageResponse remote_message_response = 311;

    GitGetBranches git_get_branches = 312;
    GitCreateBranch git_create_branch = 313;
    GitChangeBranch git_change_branch = 314;

    CheckForPushedCommits check_for_pushed_commits = 315;
    CheckForPushedCommitsResponse check_for_pushed_commits_response = 316;

    AskPassRequest ask_pass_request = 317;
    AskPassResponse ask_pass_response = 318;

    GitDiff git_diff = 319;
    GitDiffResponse git_diff_response = 320;
    GitInit git_init = 321;

    CodeLens code_lens = 322;
    GetCodeLens get_code_lens = 323;
    GetCodeLensResponse get_code_lens_response = 324;
    RefreshCodeLens refresh_code_lens = 325;

    ToggleBreakpoint toggle_breakpoint = 326;
    BreakpointsForFile breakpoints_for_file = 327;

    UpdateRepository update_repository = 328;
    RemoveRepository remove_repository = 329;

    GetDocumentSymbols get_document_symbols = 330;
    GetDocumentSymbolsResponse get_document_symbols_response = 331;

    LoadCommitDiff load_commit_diff = 334;
    LoadCommitDiffResponse load_commit_diff_response = 335;

    StopLanguageServers stop_language_servers = 336;

    LspExtRunnables lsp_ext_runnables = 337;
    LspExtRunnablesResponse lsp_ext_runnables_response = 338;

    GetDebugAdapterBinary get_debug_adapter_binary = 339;
    DebugAdapterBinary debug_adapter_binary = 340;
    RunDebugLocators run_debug_locators = 341;
    DebugRequest debug_request = 342;

    LspExtGoToParentModule lsp_ext_go_to_parent_module = 343;
    LspExtGoToParentModuleResponse lsp_ext_go_to_parent_module_response = 344;
    LspExtCancelFlycheck lsp_ext_cancel_flycheck = 345;
    LspExtRunFlycheck lsp_ext_run_flycheck = 346;
    LspExtClearFlycheck lsp_ext_clear_flycheck = 347;

    LogToDebugConsole log_to_debug_console = 348;

    GetDocumentDiagnostics get_document_diagnostics = 350;
    GetDocumentDiagnosticsResponse get_document_diagnostics_response = 351;
    PullWorkspaceDiagnostics pull_workspace_diagnostics = 352;

    GetDocumentColor get_document_color = 353;
    GetDocumentColorResponse get_document_color_response = 354;
    GetColorPresentation get_color_presentation = 355;
    GetColorPresentationResponse get_color_presentation_response = 356;

    Stash stash = 357;
    StashPop stash_pop = 358;

    GetDefaultBranch get_default_branch = 359;
    GetDefaultBranchResponse get_default_branch_response = 360;

    GetCrashFiles get_crash_files = 361;
    GetCrashFilesResponse get_crash_files_response = 362;

    GitClone git_clone = 363;
    GitCloneResponse git_clone_response = 364;

    LspQuery lsp_query = 365;
    LspQueryResponse lsp_query_response = 366;
    ToggleLspLogs toggle_lsp_logs = 367;

    UpdateUserSettings update_user_settings = 368;

    GetProcesses get_processes = 369;
    GetProcessesResponse get_processes_response = 370;

    ResolveToolchain resolve_toolchain = 371;
    ResolveToolchainResponse resolve_toolchain_response = 372;

    GetAgentServerCommand get_agent_server_command = 373;
    AgentServerCommand agent_server_command = 374;

    ExternalAgentsUpdated external_agents_updated = 375;
    ExternalAgentLoadingStatusUpdated external_agent_loading_status_updated = 376;
    NewExternalAgentVersionAvailable new_external_agent_version_available = 377;

    StashDrop stash_drop = 378;
    StashApply stash_apply = 379;

    GitRenameBranch git_rename_branch = 380;

    RemoteStarted remote_started = 381;

    GetDirectoryEnvironment get_directory_environment = 382;
    DirectoryEnvironment directory_environment = 383;

    GetTreeDiff get_tree_diff = 384;
    GetTreeDiffResponse get_tree_diff_response = 385;

    GetBlobContent get_blob_content = 386;
    GetBlobContentResponse get_blob_content_response = 387;

    GitWorktreesResponse git_worktrees_response = 388;
    GitGetWorktrees git_get_worktrees = 389;
    GitCreateWorktree git_create_worktree = 390;

    OpenImageByPath open_image_by_path = 391;
    OpenImageResponse open_image_response = 392;
    CreateImageForPeer create_image_for_peer = 393;

    RunGitHook run_git_hook = 399;

    GitDeleteBranch git_delete_branch = 400;

    ExternalExtensionAgentsUpdated external_extension_agents_updated = 401;

    GitCreateRemote git_create_remote = 402;
    GitRemoveRemote git_remove_remote = 403;

    TrustWorktrees trust_worktrees = 404;
    RestrictWorktrees restrict_worktrees = 405;

    ShareAgentThread share_agent_thread = 406;
    GetSharedAgentThread get_shared_agent_thread = 407;
    GetSharedAgentThreadResponse get_shared_agent_thread_response = 408;

    FindSearchCandidatesChunk find_search_candidates_chunk = 409;
    FindSearchCandidatesCancelled find_search_candidates_cancelled = 410;
    GetContextServerCommand get_context_server_command = 411;
    ContextServerCommand context_server_command = 412;

    AllocateWorktreeId allocate_worktree_id = 413;
    AllocateWorktreeIdResponse allocate_worktree_id_response = 414;

    DownloadFileByPath download_file_by_path = 415;
    DownloadFileResponse download_file_response = 416;
    CreateFileForPeer create_file_for_peer = 417;

    SemanticTokens semantic_tokens = 418;
    SemanticTokensResponse semantic_tokens_response = 419;
    RefreshSemanticTokens refresh_semantic_tokens = 420;
    GetFoldingRanges get_folding_ranges = 421;
    GetFoldingRangesResponse get_folding_ranges_response = 422;

    GetRemoteProfilingData get_remote_profiling_data = 423;
    GetRemoteProfilingDataResponse get_remote_profiling_data_response = 424;

    SpawnKernel spawn_kernel = 426;
    SpawnKernelResponse spawn_kernel_response = 427;
    KillKernel kill_kernel = 428;
    GitRemoveWorktree git_remove_worktree = 431;
    GitRenameWorktree git_rename_worktree = 432;
    GitCreateCheckpoint git_create_checkpoint = 433;
    GitCreateCheckpointResponse git_create_checkpoint_response = 434;
    GitRestoreCheckpoint git_restore_checkpoint = 435;
    GitCompareCheckpoints git_compare_checkpoints = 436;
    GitCompareCheckpointsResponse git_compare_checkpoints_response = 437;
    GitDiffCheckpoints git_diff_checkpoints = 438;
    GitDiffCheckpointsResponse git_diff_checkpoints_response = 439;
    GitGetHeadSha git_get_head_sha = 440;
    GitGetHeadShaResponse git_get_head_sha_response = 441;
    GitRepairWorktrees git_repair_worktrees = 442;
    GitEditRef git_edit_ref = 443;
    GitCreateArchiveCheckpoint git_create_archive_checkpoint = 444;
    GitCreateArchiveCheckpointResponse git_create_archive_checkpoint_response = 445;
    GitRestoreArchiveCheckpoint git_restore_archive_checkpoint = 446;
    GetCommitData get_commit_data = 447;
    GetCommitDataResponse get_commit_data_response = 448;
    SearchCommits search_commits = 449;
    SearchCommitsResponse search_commits_response = 450;
    GetInitialGraphData get_initial_graph_data = 451;
    GetInitialGraphDataResponse get_initial_graph_data_response = 452;
    GetDocumentLinks get_document_links = 453;
    GetDocumentLinksResponse get_document_links_response = 454;
    ResolveDocumentLink resolve_document_link = 455;
    ResolveDocumentLinkResponse resolve_document_link_response = 456; // current max
  }

  reserved 87 to 88;
  reserved 90;
  reserved 102 to 103;
  reserved 158 to 161;
  reserved 164;
  reserved 166 to 169;
  reserved 175 to 185;
  reserved 188 to 195;
  reserved 197;
  reserved 198 to 202;
  reserved 205 to 206;
  reserved 221;
  reserved 224 to 231;
  reserved 234 to 236;
  reserved 239 to 240;
  reserved 244;
  reserved 246 to 256;
  reserved 259;
  reserved 270;
  reserved 280 to 281;
  reserved 332 to 333;
  reserved 394 to 396;
  reserved 429 to 430;
  reserved 211 to 216, 232 to 233;
  reserved 397 to 398;
}

message Hello {
  PeerId peer_id = 1;
}

message Ping {}

message Ack {}

message Error {
  string message = 1;
  ErrorCode code = 2;
  repeated string tags = 3;
}

enum ErrorCode {
  Internal = 0;
  NoSuchChannel = 1;
  Disconnected = 2;
  SignedOut = 3;
  UpgradeRequired = 4;
  Forbidden = 5;
  NeedsCla = 7;
  NotARootChannel = 8;
  BadPublicNesting = 9;
  CircularNesting = 10;
  WrongMoveTarget = 11;
  UnsharedItem = 12;
  NoSuchProject = 13;
  DevServerProjectPathDoesNotExist = 16;
  RemoteUpgradeRequired = 17;
  RateLimitExceeded = 18;
  CommitFailed = 19;
  reserved 6;
  reserved 14 to 15;
}

message EndStream {}

message Test {
  uint64 id = 1;
}

message FlushBufferedMessages {}

message FlushBufferedMessagesResponse {}

message RemoteStarted {}

message SpawnKernel {
  string kernel_name = 1;
  string working_directory = 2;
  uint64 project_id = 3;
  string command = 4;
  repeated string args = 5;
}

message SpawnKernelResponse {
  string kernel_id = 1;
  string connection_file = 2;
}

message KillKernel {
  string kernel_id = 1;
  uint64 project_id = 2;
}
