syntax = "proto3";
package cline;

import "cline/browser.proto";
import "cline/common.proto";
import "cline/models.proto";

option go_package = "github.com/cline/grpc-go/cline";
option java_multiple_files = true;
option java_package = "bot.cline.proto";

service StateService {
  rpc getLatestState(EmptyRequest) returns (State);
  rpc updateTerminalConnectionTimeout(UpdateTerminalConnectionTimeoutRequest) returns (UpdateTerminalConnectionTimeoutResponse);
  rpc updateTerminalReuseEnabled(BooleanRequest) returns (Empty);
  rpc getAvailableTerminalProfiles(EmptyRequest) returns (TerminalProfiles);
  rpc subscribeToState(EmptyRequest) returns (stream State);
  rpc toggleFavoriteModel(StringRequest) returns (Empty);
  rpc resetState(ResetStateRequest) returns (Empty);
  rpc togglePlanActModeProto(TogglePlanActModeRequest) returns (Boolean);
  rpc updateAutoApprovalSettings(AutoApprovalSettingsRequest) returns (Empty);
  rpc updateSettings(UpdateSettingsRequest) returns (Empty);
  rpc updateSettingsCli(UpdateSettingsRequestCli) returns (Empty);
  rpc updateTaskSettings(UpdateTaskSettingsRequest) returns (Empty);
  rpc updateTelemetrySetting(TelemetrySettingRequest) returns (Empty);
  rpc captureOnboardingProgress(OnboardingProgressRequest) returns (Empty);
  rpc setWelcomeViewCompleted(BooleanRequest) returns (Empty);
  rpc updateInfoBannerVersion(Int64Request) returns (Empty);
  rpc updateModelBannerVersion(Int64Request) returns (Empty);
  rpc updateCliBannerVersion(Int64Request) returns (Empty);
  rpc dismissBanner(StringRequest) returns (Empty);
  rpc trackBannerEvent(TrackBannerEventRequest) returns (Empty);
  rpc installClineCli(EmptyRequest) returns (Empty);
  rpc checkCliInstallation(EmptyRequest) returns (Boolean);
  rpc getProcessInfo(EmptyRequest) returns (ProcessInfo);
  rpc flushPendingState(EmptyRequest) returns (Empty);
}

message AutoApprovalActions {
  optional bool read_files = 1;
  optional bool read_files_externally = 2;
  optional bool edit_files = 3;
  optional bool edit_files_externally = 4;
  optional bool execute_safe_commands = 5;
  optional bool execute_all_commands = 6;
  optional bool use_browser = 7;
  optional bool use_mcp = 8;
}

// Auto approval settings for task execution
message AutoApprovalSettings {
  int32 version = 1;
  AutoApprovalActions actions = 2;
  optional bool enable_notifications = 3;
}

// NOTE: Add the new secret fields under SECRETS_KEYS in src/shared/storage/state-keys.ts
// and use the scripts/generate-state-proto.mjs script to regenerate this list.
message Secrets {
  optional string api_key = 1;
  optional string cline_account_id = 2;
  optional string open_router_api_key = 3;
  optional string aws_access_key = 4;
  optional string aws_secret_key = 5;
  optional string aws_session_token = 6;
  optional string aws_bedrock_api_key = 7;
  optional string open_ai_api_key = 8;
  optional string gemini_api_key = 9;
  optional string open_ai_native_api_key = 10;
  optional string ollama_api_key = 11;
  optional string deep_seek_api_key = 12;
  optional string requesty_api_key = 13;
  optional string together_api_key = 14;
  optional string fireworks_api_key = 15;
  optional string qwen_api_key = 16;
  optional string doubao_api_key = 17;
  optional string mistral_api_key = 18;
  optional string lite_llm_api_key = 19;
  optional string auth_nonce = 20;
  optional string asksage_api_key = 21;
  optional string xai_api_key = 22;
  optional string moonshot_api_key = 23;
  optional string zai_api_key = 24;
  optional string hugging_face_api_key = 25;
  optional string nebius_api_key = 26;
  optional string sambanova_api_key = 27;
  optional string cerebras_api_key = 28;
  optional string sap_ai_core_client_id = 29;
  optional string sap_ai_core_client_secret = 30;
  optional string groq_api_key = 31;
  optional string huawei_cloud_maas_api_key = 32;
  optional string baseten_api_key = 33;
  optional string vercel_ai_gateway_api_key = 34;
  optional string dify_api_key = 35;
  optional string minimax_api_key = 36;
  optional string hicap_api_key = 37;
  optional string aihubmix_api_key = 38;
  optional string nous_research_api_key = 39;
  optional string remote_lite_llm_api_key = 40;
  optional string oca_api_key = 41;
  optional string oca_refresh_token = 42;
  optional string mcp_o_auth_secrets = 43;
}

// NOTE: Add new fields under API_HANDLER_SETTINGS_FIELDS or USER_SETTINGS_FIELDS
// in src/shared/storage/state-keys.ts and use the scripts/generate-state-proto.mjs
// script to regenerate this list.
message Settings {
  optional string lite_llm_base_url = 1;
  optional bool lite_llm_use_prompt_cache = 2;
  optional string anthropic_base_url = 4;
  optional string open_router_provider_sorting = 5;
  optional string aws_region = 6;
  optional bool aws_use_cross_region_inference = 7;
  optional bool aws_use_global_inference = 8;
  optional bool aws_bedrock_use_prompt_cache = 9;
  optional string aws_authentication = 10;
  optional bool aws_use_profile = 11;
  optional string aws_profile = 12;
  optional string aws_bedrock_endpoint = 13;
  optional string claude_code_path = 14;
  optional string vertex_project_id = 15;
  optional string vertex_region = 16;
  optional string open_ai_base_url = 17;
  optional string ollama_base_url = 18;
  optional string ollama_api_options_ctx_num = 19;
  optional string lm_studio_base_url = 20;
  optional string lm_studio_max_tokens = 21;
  optional string gemini_base_url = 22;
  optional string requesty_base_url = 23;
  optional int32 fireworks_model_max_completion_tokens = 24;
  optional int32 fireworks_model_max_tokens = 25;
  optional string qwen_code_oauth_path = 26;
  optional string azure_api_version = 27;
  optional bool azure_identity = 28;
  optional string qwen_api_line = 29;
  optional string moonshot_api_line = 30;
  optional string asksage_api_url = 31;
  optional int32 request_timeout_ms = 32;
  optional string sap_ai_resource_group = 33;
  optional string sap_ai_core_token_url = 34;
  optional string sap_ai_core_base_url = 35;
  optional bool sap_ai_core_use_orchestration_mode = 36;
  optional string dify_base_url = 37;
  optional string zai_api_line = 38;
  optional string oca_base_url = 39;
  optional string minimax_api_line = 40;
  optional string oca_mode = 41;
  optional string aihubmix_base_url = 42;
  optional string aihubmix_app_code = 43;
  optional string plan_mode_api_model_id = 44;
  optional int64 plan_mode_thinking_budget_tokens = 45;
  optional string gemini_plan_mode_thinking_level = 46;
  optional string plan_mode_reasoning_effort = 47;
  optional string plan_mode_verbosity = 48;
  optional LanguageModelChatSelector plan_mode_vs_code_lm_model_selector = 49;
  optional bool plan_mode_aws_bedrock_custom_selected = 50;
  optional string plan_mode_aws_bedrock_custom_model_base_id = 51;
  optional string plan_mode_open_router_model_id = 52;
  optional OpenRouterModelInfo plan_mode_open_router_model_info = 53;
  optional string plan_mode_open_ai_model_id = 54;
  optional OpenAiCompatibleModelInfo plan_mode_open_ai_model_info = 55;
  optional string plan_mode_ollama_model_id = 56;
  optional string plan_mode_lm_studio_model_id = 57;
  optional string plan_mode_lite_llm_model_id = 58;
  optional LiteLLMModelInfo plan_mode_lite_llm_model_info = 59;
  optional string plan_mode_requesty_model_id = 60;
  optional OpenRouterModelInfo plan_mode_requesty_model_info = 61;
  optional string plan_mode_together_model_id = 62;
  optional string plan_mode_fireworks_model_id = 63;
  optional string plan_mode_sap_ai_core_model_id = 64;
  optional string plan_mode_sap_ai_core_deployment_id = 65;
  optional string plan_mode_groq_model_id = 66;
  optional OpenRouterModelInfo plan_mode_groq_model_info = 67;
  optional string plan_mode_baseten_model_id = 68;
  optional OpenRouterModelInfo plan_mode_baseten_model_info = 69;
  optional string plan_mode_hugging_face_model_id = 70;
  optional OpenRouterModelInfo plan_mode_hugging_face_model_info = 71;
  optional string plan_mode_huawei_cloud_maas_model_id = 72;
  optional OpenRouterModelInfo plan_mode_huawei_cloud_maas_model_info = 73;
  optional string plan_mode_oca_model_id = 74;
  optional OcaModelInfo plan_mode_oca_model_info = 75;
  optional string plan_mode_oca_reasoning_effort = 76;
  optional string plan_mode_aihubmix_model_id = 77;
  optional OpenAiCompatibleModelInfo plan_mode_aihubmix_model_info = 78;
  optional string plan_mode_hicap_model_id = 79;
  optional OpenRouterModelInfo plan_mode_hicap_model_info = 80;
  optional string plan_mode_nous_research_model_id = 81;
  optional string plan_mode_vercel_ai_gateway_model_id = 82;
  optional OpenRouterModelInfo plan_mode_vercel_ai_gateway_model_info = 83;
  optional string act_mode_api_model_id = 84;
  optional int64 act_mode_thinking_budget_tokens = 85;
  optional string gemini_act_mode_thinking_level = 86;
  optional string act_mode_reasoning_effort = 87;
  optional string act_mode_verbosity = 88;
  optional LanguageModelChatSelector act_mode_vs_code_lm_model_selector = 89;
  optional bool act_mode_aws_bedrock_custom_selected = 90;
  optional string act_mode_aws_bedrock_custom_model_base_id = 91;
  optional string act_mode_open_router_model_id = 92;
  optional OpenRouterModelInfo act_mode_open_router_model_info = 93;
  optional string act_mode_open_ai_model_id = 94;
  optional OpenAiCompatibleModelInfo act_mode_open_ai_model_info = 95;
  optional string act_mode_ollama_model_id = 96;
  optional string act_mode_lm_studio_model_id = 97;
  optional string act_mode_lite_llm_model_id = 98;
  optional LiteLLMModelInfo act_mode_lite_llm_model_info = 99;
  optional string act_mode_requesty_model_id = 100;
  optional OpenRouterModelInfo act_mode_requesty_model_info = 101;
  optional string act_mode_together_model_id = 102;
  optional string act_mode_fireworks_model_id = 103;
  optional string act_mode_sap_ai_core_model_id = 104;
  optional string act_mode_sap_ai_core_deployment_id = 105;
  optional string act_mode_groq_model_id = 106;
  optional OpenRouterModelInfo act_mode_groq_model_info = 107;
  optional string act_mode_baseten_model_id = 108;
  optional OpenRouterModelInfo act_mode_baseten_model_info = 109;
  optional string act_mode_hugging_face_model_id = 110;
  optional OpenRouterModelInfo act_mode_hugging_face_model_info = 111;
  optional string act_mode_huawei_cloud_maas_model_id = 112;
  optional OpenRouterModelInfo act_mode_huawei_cloud_maas_model_info = 113;
  optional string act_mode_oca_model_id = 114;
  optional OcaModelInfo act_mode_oca_model_info = 115;
  optional string act_mode_oca_reasoning_effort = 116;
  optional string act_mode_aihubmix_model_id = 117;
  optional OpenAiCompatibleModelInfo act_mode_aihubmix_model_info = 118;
  optional string act_mode_hicap_model_id = 119;
  optional OpenRouterModelInfo act_mode_hicap_model_info = 120;
  optional string act_mode_nous_research_model_id = 121;
  optional string act_mode_vercel_ai_gateway_model_id = 122;
  optional OpenRouterModelInfo act_mode_vercel_ai_gateway_model_info = 123;
  optional ApiProvider plan_mode_api_provider = 124;
  optional ApiProvider act_mode_api_provider = 125;
  optional string hicap_model_id = 126;
  optional string lm_studio_model_id = 127;
  optional AutoApprovalSettings auto_approval_settings = 128;
  optional string global_cline_rules_toggles = 129;
  optional string global_workflow_toggles = 130;
  optional string global_skills_toggles = 131;
  optional BrowserSettings browser_settings = 132;
  optional string telemetry_setting = 133;
  optional bool plan_act_separate_models_setting = 134;
  optional bool enable_checkpoints_setting = 135;
  optional int32 shell_integration_timeout = 136;
  optional string default_terminal_profile = 137;
  optional int32 terminal_output_line_limit = 138;
  optional int32 max_consecutive_mistakes = 139;
  optional int32 subagent_terminal_output_line_limit = 140;
  optional bool strict_plan_mode_enabled = 141;
  optional bool yolo_mode_toggled = 142;
  optional bool use_auto_condense = 143;
  optional bool cline_web_tools_enabled = 144;
  optional string preferred_language = 145;
  optional OpenaiReasoningEffort openai_reasoning_effort = 146;
  optional PlanActMode mode = 147;
  optional DictationSettings dictation_settings = 148;
  optional FocusChainSettings focus_chain_settings = 149;
  optional string custom_prompt = 150;
  optional double auto_condense_threshold = 151;
  optional bool hooks_enabled = 152;
  optional bool subagents_enabled = 153;
  optional bool enable_parallel_tool_calling = 154;
  optional bool background_edit_enabled = 155;
  optional bool skills_enabled = 156;
  optional bool opt_out_of_remote_config = 157;
  optional bool open_telemetry_enabled = 158;
  optional string open_telemetry_metrics_exporter = 159;
  optional string open_telemetry_logs_exporter = 160;
  optional string open_telemetry_otlp_protocol = 161;
  optional string open_telemetry_otlp_endpoint = 162;
  optional string open_telemetry_otlp_metrics_protocol = 163;
  optional string open_telemetry_otlp_metrics_endpoint = 164;
  optional string open_telemetry_otlp_logs_protocol = 165;
  optional string open_telemetry_otlp_logs_endpoint = 166;
  optional int32 open_telemetry_metric_export_interval = 167;
  optional bool open_telemetry_otlp_insecure = 168;
  optional int32 open_telemetry_log_batch_size = 169;
  optional int32 open_telemetry_log_batch_timeout = 170;
  optional int32 open_telemetry_log_max_queue_size = 171;
  optional bool worktrees_enabled = 172;
  map<string, string> open_ai_headers = 173;
}

message DictationSettings {
  bool feature_enabled = 1;
  bool dictation_enabled = 2;
  string dictation_language = 3;
}
message State {
  string state_json = 1;
}

message TerminalProfiles {
  repeated TerminalProfile profiles = 1;
}

message TerminalProfile {
  string id = 1;
  string name = 2;
  optional string path = 3;
  optional string description = 4;
}

message TerminalProfileUpdateResponse {
  int32 closed_count = 1;
  int32 busy_terminals_count = 2;
  bool has_busy_terminals = 3;
}

message TogglePlanActModeRequest {
  Metadata metadata = 1;
  PlanActMode mode = 2;
  optional ChatContent chat_content = 3;
}

enum PlanActMode {
  PLAN = 0;
  ACT = 1;
}

enum OpenaiReasoningEffort {
  LOW = 0;
  MEDIUM = 1;
  HIGH = 2;
  MINIMAL = 3;
}

enum McpDisplayMode {
  RICH = 0;
  PLAIN = 1;
  MARKDOWN = 2;
}

message ChatContent {
  optional string message = 1;
  repeated string images = 2;
  repeated string files = 3;
}

message ResetStateRequest {
  Metadata metadata = 1;
  optional bool global = 2;
}

message AutoApprovalSettingsRequest {
  Metadata metadata = 1;
  int32 version = 2;
  AutoApprovalActions actions = 3;
  bool enable_notifications = 4;
}

enum TelemetrySettingEnum {
  UNSET = 0;
  ENABLED = 1;
  DISABLED = 2;
}

message TelemetrySettingRequest {
  Metadata metadata = 1;
  TelemetrySettingEnum setting = 2;
}

// Browser settings for UpdateSettingsRequest
message BrowserSettingsUpdate {
  optional Viewport viewport = 1;
  optional string remote_browser_host = 2;
  optional bool remote_browser_enabled = 3;
  optional string chrome_executable_path = 4;
  optional bool disable_tool_use = 5;
  optional string custom_args = 6;
}

message UpdateSettingsRequestCli {
  Metadata metadata = 1;
  optional Settings settings = 2;
  optional Secrets secrets = 3;
  optional string environment = 4;
}

message UpdateTaskSettingsRequest {
  Metadata metadata = 1;
  optional Settings settings = 2;
  optional string task_id = 3;
}

// Message for updating settings
message UpdateSettingsRequest {
  Metadata metadata = 1;
  optional ModelsApiConfiguration api_configuration = 2;
  optional string telemetry_setting = 3;
  optional bool plan_act_separate_models_setting = 4;
  optional bool enable_checkpoints_setting = 5;
  optional bool mcp_marketplace_enabled = 6;
  optional int32 shell_integration_timeout = 8;
  optional bool terminal_reuse_enabled = 9;
  optional bool mcp_responses_collapsed = 10;
  optional McpDisplayMode mcp_display_mode = 11;
  optional int32 terminal_output_line_limit = 12;
  optional PlanActMode mode = 13;
  optional string preferred_language = 14;
  optional OpenaiReasoningEffort openai_reasoning_effort = 15;
  optional bool strict_plan_mode_enabled = 16;
  optional FocusChainSettings focus_chain_settings = 17;
  optional bool use_auto_condense = 18;
  optional string custom_prompt = 19;
  optional BrowserSettingsUpdate browser_settings = 20;
  optional string default_terminal_profile = 21;
  optional bool yolo_mode_toggled = 22;
  optional DictationSettings dictation_settings = 23;
  optional double auto_condense_threshold = 24;
  optional bool multi_root_enabled = 25;
  optional bool hooks_enabled = 26;
  optional string vscode_terminal_execution_mode = 27;
  optional int32 max_consecutive_mistakes = 28;
  optional bool subagents_enabled = 29;
  optional int32 subagent_terminal_output_line_limit = 30;
  optional string cline_env = 31;
  optional bool native_tool_call_enabled = 32;
  optional OnboardingModelGroup onboarding_models = 33;
  optional bool cline_web_tools_enabled = 34;
  optional bool enable_parallel_tool_calling = 35;
  optional bool background_edit_enabled = 36;
  optional string oca_reasoning_effort = 37;
  optional bool skills_enabled = 38;
  optional bool opt_out_of_remote_config = 39;
  optional bool worktrees_enabled = 40;
}

message UpdateTerminalConnectionTimeoutRequest {
  optional int32 timeout_ms = 1;
}

message FocusChainSettings {
  bool enabled = 1;
  int32 remind_cline_interval = 2;
}

message UpdateTerminalConnectionTimeoutResponse {
  optional int32 timeout_ms = 1;
}

message ProcessInfo {
  int32 process_id = 1;
  optional string version = 2;
  optional int64 uptime_ms = 3;
}

message OnboardingProgressRequest {
  int32 step = 1;
  optional string action = 2;
  optional bool completed = 3;
  optional string model_selected = 4;
}

message OnboardingModelGroup {
  repeated OnboardingModel models = 1;
}

message OnboardingModel {
  string id = 1;
  string name = 2;
  int32 score = 3;
  int32 latency = 4;
  string badge = 5;
  string group = 6;
  OpenRouterModelInfo info = 7;
}

message TrackBannerEventRequest {
  string banner_id = 1;
  string event_type = 2;
}
