Merge: align state-helpers with main; wire standalone secrets to keychain; fix cline-core toast

This commit is contained in:
kvyb
2025-09-19 16:04:59 +08:00
parent 927284c314
commit 1c79eeca6b
3 changed files with 14677 additions and 14576 deletions
+271 -204
View File
@@ -1,19 +1,17 @@
import { ApiProvider, BedrockModelId, ModelInfo } from "@shared/api"
import { ExtensionContext, LanguageModelChatSelector } from "vscode"
import { ApiProvider, fireworksDefaultModelId } from "@shared/api"
import { ExtensionContext } from "vscode"
import { Controller } from "@/core/controller"
import { AutoApprovalSettings, DEFAULT_AUTO_APPROVAL_SETTINGS } from "@/shared/AutoApprovalSettings"
import { BrowserSettings, DEFAULT_BROWSER_SETTINGS } from "@/shared/BrowserSettings"
import { DEFAULT_AUTO_APPROVAL_SETTINGS } from "@/shared/AutoApprovalSettings"
import { DEFAULT_BROWSER_SETTINGS } from "@/shared/BrowserSettings"
import { ClineRulesToggles } from "@/shared/cline-rules"
import { DEFAULT_FOCUS_CHAIN_SETTINGS, FocusChainSettings } from "@/shared/FocusChainSettings"
import { DEFAULT_MCP_DISPLAY_MODE, McpDisplayMode } from "@/shared/McpDisplayMode"
import { Mode, OpenaiReasoningEffort } from "@/shared/storage/types"
import { TelemetrySetting } from "@/shared/TelemetrySetting"
import { UserInfo } from "@/shared/UserInfo"
import { ClineStorage } from "../ClineStorage"
import { readTaskHistoryFromState } from "../disk"
import { GlobalState, LocalState, SecretKey, Secrets } from "../state-keys"
import { DEFAULT_FOCUS_CHAIN_SETTINGS } from "@/shared/FocusChainSettings"
import { DEFAULT_MCP_DISPLAY_MODE } from "@/shared/McpDisplayMode"
import { OpenaiReasoningEffort } from "@/shared/storage/types"
export async function readSecretsFromDisk(store: ClineStorage): Promise<Secrets> {
import { readTaskHistoryFromState } from "../disk"
import { GlobalStateAndSettings, LocalState, SecretKey, Secrets } from "../state-keys"
export async function readSecretsFromDisk(context: ExtensionContext): Promise<Secrets> {
const [
apiKey,
openRouterApiKey,
@@ -51,41 +49,41 @@ export async function readSecretsFromDisk(store: ClineStorage): Promise<Secrets>
difyApiKey,
authNonce,
] = await Promise.all([
store.get("apiKey") as Promise<string | undefined>,
store.get("openRouterApiKey") as Promise<string | undefined>,
store.get("clineAccountId") as Promise<string | undefined>,
store.get("awsAccessKey") as Promise<string | undefined>,
store.get("awsSecretKey") as Promise<string | undefined>,
store.get("awsSessionToken") as Promise<string | undefined>,
store.get("awsBedrockApiKey") as Promise<string | undefined>,
store.get("openAiApiKey") as Promise<string | undefined>,
store.get("geminiApiKey") as Promise<string | undefined>,
store.get("openAiNativeApiKey") as Promise<string | undefined>,
store.get("deepSeekApiKey") as Promise<string | undefined>,
store.get("requestyApiKey") as Promise<string | undefined>,
store.get("togetherApiKey") as Promise<string | undefined>,
store.get("qwenApiKey") as Promise<string | undefined>,
store.get("doubaoApiKey") as Promise<string | undefined>,
store.get("mistralApiKey") as Promise<string | undefined>,
store.get("fireworksApiKey") as Promise<string | undefined>,
store.get("liteLlmApiKey") as Promise<string | undefined>,
store.get("asksageApiKey") as Promise<string | undefined>,
store.get("xaiApiKey") as Promise<string | undefined>,
store.get("sambanovaApiKey") as Promise<string | undefined>,
store.get("cerebrasApiKey") as Promise<string | undefined>,
store.get("groqApiKey") as Promise<string | undefined>,
store.get("moonshotApiKey") as Promise<string | undefined>,
store.get("nebiusApiKey") as Promise<string | undefined>,
store.get("huggingFaceApiKey") as Promise<string | undefined>,
store.get("sapAiCoreClientId") as Promise<string | undefined>,
store.get("sapAiCoreClientSecret") as Promise<string | undefined>,
store.get("huaweiCloudMaasApiKey") as Promise<string | undefined>,
store.get("basetenApiKey") as Promise<string | undefined>,
store.get("zaiApiKey") as Promise<string | undefined>,
store.get("ollamaApiKey") as Promise<string | undefined>,
store.get("vercelAiGatewayApiKey") as Promise<string | undefined>,
store.get("difyApiKey") as Promise<string | undefined>,
store.get("authNonce") as Promise<string | undefined>,
context.secrets.get("apiKey") as Promise<Secrets["apiKey"]>,
context.secrets.get("openRouterApiKey") as Promise<Secrets["openRouterApiKey"]>,
context.secrets.get("clineAccountId") as Promise<Secrets["clineAccountId"]>,
context.secrets.get("awsAccessKey") as Promise<Secrets["awsAccessKey"]>,
context.secrets.get("awsSecretKey") as Promise<Secrets["awsSecretKey"]>,
context.secrets.get("awsSessionToken") as Promise<Secrets["awsSessionToken"]>,
context.secrets.get("awsBedrockApiKey") as Promise<Secrets["awsBedrockApiKey"]>,
context.secrets.get("openAiApiKey") as Promise<Secrets["openAiApiKey"]>,
context.secrets.get("geminiApiKey") as Promise<Secrets["geminiApiKey"]>,
context.secrets.get("openAiNativeApiKey") as Promise<Secrets["openAiNativeApiKey"]>,
context.secrets.get("deepSeekApiKey") as Promise<Secrets["deepSeekApiKey"]>,
context.secrets.get("requestyApiKey") as Promise<Secrets["requestyApiKey"]>,
context.secrets.get("togetherApiKey") as Promise<Secrets["togetherApiKey"]>,
context.secrets.get("qwenApiKey") as Promise<Secrets["qwenApiKey"]>,
context.secrets.get("doubaoApiKey") as Promise<Secrets["doubaoApiKey"]>,
context.secrets.get("mistralApiKey") as Promise<Secrets["mistralApiKey"]>,
context.secrets.get("fireworksApiKey") as Promise<Secrets["fireworksApiKey"]>,
context.secrets.get("liteLlmApiKey") as Promise<Secrets["liteLlmApiKey"]>,
context.secrets.get("asksageApiKey") as Promise<Secrets["asksageApiKey"]>,
context.secrets.get("xaiApiKey") as Promise<Secrets["xaiApiKey"]>,
context.secrets.get("sambanovaApiKey") as Promise<Secrets["sambanovaApiKey"]>,
context.secrets.get("cerebrasApiKey") as Promise<Secrets["cerebrasApiKey"]>,
context.secrets.get("groqApiKey") as Promise<Secrets["groqApiKey"]>,
context.secrets.get("moonshotApiKey") as Promise<Secrets["moonshotApiKey"]>,
context.secrets.get("nebiusApiKey") as Promise<Secrets["nebiusApiKey"]>,
context.secrets.get("huggingFaceApiKey") as Promise<Secrets["huggingFaceApiKey"]>,
context.secrets.get("sapAiCoreClientId") as Promise<Secrets["sapAiCoreClientId"]>,
context.secrets.get("sapAiCoreClientSecret") as Promise<Secrets["sapAiCoreClientSecret"]>,
context.secrets.get("huaweiCloudMaasApiKey") as Promise<Secrets["huaweiCloudMaasApiKey"]>,
context.secrets.get("basetenApiKey") as Promise<Secrets["basetenApiKey"]>,
context.secrets.get("zaiApiKey") as Promise<Secrets["zaiApiKey"]>,
context.secrets.get("ollamaApiKey") as Promise<Secrets["ollamaApiKey"]>,
context.secrets.get("vercelAiGatewayApiKey") as Promise<Secrets["vercelAiGatewayApiKey"]>,
context.secrets.get("difyApiKey") as Promise<Secrets["difyApiKey"]>,
context.secrets.get("authNonce") as Promise<Secrets["authNonce"]>,
])
return {
@@ -141,161 +139,230 @@ export async function readWorkspaceStateFromDisk(context: ExtensionContext): Pro
}
}
export async function readGlobalStateFromDisk(context: ExtensionContext): Promise<GlobalState> {
export async function readGlobalStateFromDisk(context: ExtensionContext): Promise<GlobalStateAndSettings> {
try {
// Get all global state values
const strictPlanModeEnabled = context.globalState.get("strictPlanModeEnabled") as boolean | undefined
const useAutoCondense = context.globalState.get("useAutoCondense") as boolean | undefined
const isNewUser = context.globalState.get("isNewUser") as boolean | undefined
const welcomeViewCompleted = context.globalState.get("welcomeViewCompleted") as boolean | undefined
const awsRegion = context.globalState.get("awsRegion") as string | undefined
const awsUseCrossRegionInference = context.globalState.get("awsUseCrossRegionInference") as boolean | undefined
const awsBedrockUsePromptCache = context.globalState.get("awsBedrockUsePromptCache") as boolean | undefined
const awsBedrockEndpoint = context.globalState.get("awsBedrockEndpoint") as string | undefined
const awsProfile = context.globalState.get("awsProfile") as string | undefined
const awsUseProfile = context.globalState.get("awsUseProfile") as boolean | undefined
const awsAuthentication = context.globalState.get("awsAuthentication") as string | undefined
const vertexProjectId = context.globalState.get("vertexProjectId") as string | undefined
const vertexRegion = context.globalState.get("vertexRegion") as string | undefined
const openAiBaseUrl = context.globalState.get("openAiBaseUrl") as string | undefined
const requestyBaseUrl = context.globalState.get("requestyBaseUrl") as string | undefined
const openAiHeaders = context.globalState.get("openAiHeaders") as Record<string, string> | undefined
const ollamaBaseUrl = context.globalState.get("ollamaBaseUrl") as string | undefined
const ollamaApiOptionsCtxNum = context.globalState.get("ollamaApiOptionsCtxNum") as string | undefined
const lmStudioBaseUrl = context.globalState.get("lmStudioBaseUrl") as string | undefined
const lmStudioMaxTokens = context.globalState.get("lmStudioMaxTokens") as string | undefined
const anthropicBaseUrl = context.globalState.get("anthropicBaseUrl") as string | undefined
const geminiBaseUrl = context.globalState.get("geminiBaseUrl") as string | undefined
const azureApiVersion = context.globalState.get("azureApiVersion") as string | undefined
const openRouterProviderSorting = context.globalState.get("openRouterProviderSorting") as string | undefined
const lastShownAnnouncementId = context.globalState.get("lastShownAnnouncementId") as string | undefined
const autoApprovalSettings = context.globalState.get("autoApprovalSettings") as AutoApprovalSettings | undefined
const browserSettings = context.globalState.get("browserSettings") as BrowserSettings | undefined
const liteLlmBaseUrl = context.globalState.get("liteLlmBaseUrl") as string | undefined
const liteLlmUsePromptCache = context.globalState.get("liteLlmUsePromptCache") as boolean | undefined
const fireworksModelMaxCompletionTokens = context.globalState.get("fireworksModelMaxCompletionTokens") as
| number
| undefined
const fireworksModelMaxTokens = context.globalState.get("fireworksModelMaxTokens") as number | undefined
const userInfo = context.globalState.get("userInfo") as UserInfo | undefined
const qwenApiLine = context.globalState.get("qwenApiLine") as string | undefined
const moonshotApiLine = context.globalState.get("moonshotApiLine") as string | undefined
const zaiApiLine = context.globalState.get("zaiApiLine") as string | undefined
const telemetrySetting = context.globalState.get("telemetrySetting") as TelemetrySetting | undefined
const asksageApiUrl = context.globalState.get("asksageApiUrl") as string | undefined
const planActSeparateModelsSettingRaw = context.globalState.get("planActSeparateModelsSetting") as boolean | undefined
const favoritedModelIds = context.globalState.get("favoritedModelIds") as string[] | undefined
const globalClineRulesToggles = context.globalState.get("globalClineRulesToggles") as ClineRulesToggles | undefined
const requestTimeoutMs = context.globalState.get("requestTimeoutMs") as number | undefined
const shellIntegrationTimeout = context.globalState.get("shellIntegrationTimeout") as number | undefined
const enableCheckpointsSettingRaw = context.globalState.get("enableCheckpointsSetting") as boolean | undefined
const mcpMarketplaceEnabledRaw = context.globalState.get("mcpMarketplaceEnabled") as boolean | undefined
const mcpDisplayMode = context.globalState.get("mcpDisplayMode") as McpDisplayMode | undefined
const mcpResponsesCollapsedRaw = context.globalState.get("mcpResponsesCollapsed") as boolean | undefined
const globalWorkflowToggles = context.globalState.get("globalWorkflowToggles") as ClineRulesToggles | undefined
const terminalReuseEnabled = context.globalState.get("terminalReuseEnabled") as boolean | undefined
const terminalOutputLineLimit = context.globalState.get("terminalOutputLineLimit") as number | undefined
const defaultTerminalProfile = context.globalState.get("defaultTerminalProfile") as string | undefined
const sapAiCoreBaseUrl = context.globalState.get("sapAiCoreBaseUrl") as string | undefined
const sapAiCoreTokenUrl = context.globalState.get("sapAiCoreTokenUrl") as string | undefined
const sapAiResourceGroup = context.globalState.get("sapAiResourceGroup") as string | undefined
const claudeCodePath = context.globalState.get("claudeCodePath") as string | undefined
const difyBaseUrl = context.globalState.get("difyBaseUrl") as string | undefined
const openaiReasoningEffort = context.globalState.get("openaiReasoningEffort") as OpenaiReasoningEffort | undefined
const preferredLanguage = context.globalState.get("preferredLanguage") as string | undefined
const focusChainSettings = context.globalState.get("focusChainSettings") as FocusChainSettings | undefined
const focusChainFeatureFlagEnabled = context.globalState.get("focusChainFeatureFlagEnabled") as boolean | undefined
const strictPlanModeEnabled =
context.globalState.get<GlobalStateAndSettings["strictPlanModeEnabled"]>("strictPlanModeEnabled")
const yoloModeToggled = context.globalState.get<GlobalStateAndSettings["yoloModeToggled"]>("yoloModeToggled")
const useAutoCondense = context.globalState.get<GlobalStateAndSettings["useAutoCondense"]>("useAutoCondense")
const isNewUser = context.globalState.get<GlobalStateAndSettings["isNewUser"]>("isNewUser")
const welcomeViewCompleted =
context.globalState.get<GlobalStateAndSettings["welcomeViewCompleted"]>("welcomeViewCompleted")
const awsRegion = context.globalState.get<GlobalStateAndSettings["awsRegion"]>("awsRegion")
const awsUseCrossRegionInference =
context.globalState.get<GlobalStateAndSettings["awsUseCrossRegionInference"]>("awsUseCrossRegionInference")
const awsBedrockUsePromptCache =
context.globalState.get<GlobalStateAndSettings["awsBedrockUsePromptCache"]>("awsBedrockUsePromptCache")
const awsBedrockEndpoint = context.globalState.get<GlobalStateAndSettings["awsBedrockEndpoint"]>("awsBedrockEndpoint")
const awsProfile = context.globalState.get<GlobalStateAndSettings["awsProfile"]>("awsProfile")
const awsUseProfile = context.globalState.get<GlobalStateAndSettings["awsUseProfile"]>("awsUseProfile")
const awsAuthentication = context.globalState.get<GlobalStateAndSettings["awsAuthentication"]>("awsAuthentication")
const vertexProjectId = context.globalState.get<GlobalStateAndSettings["vertexProjectId"]>("vertexProjectId")
const vertexRegion = context.globalState.get<GlobalStateAndSettings["vertexRegion"]>("vertexRegion")
const openAiBaseUrl = context.globalState.get<GlobalStateAndSettings["openAiBaseUrl"]>("openAiBaseUrl")
const requestyBaseUrl = context.globalState.get<GlobalStateAndSettings["requestyBaseUrl"]>("requestyBaseUrl")
const openAiHeaders = context.globalState.get<GlobalStateAndSettings["openAiHeaders"]>("openAiHeaders")
const ollamaBaseUrl = context.globalState.get<GlobalStateAndSettings["ollamaBaseUrl"]>("ollamaBaseUrl")
const ollamaApiOptionsCtxNum =
context.globalState.get<GlobalStateAndSettings["ollamaApiOptionsCtxNum"]>("ollamaApiOptionsCtxNum")
const lmStudioBaseUrl = context.globalState.get<GlobalStateAndSettings["lmStudioBaseUrl"]>("lmStudioBaseUrl")
const lmStudioMaxTokens = context.globalState.get<GlobalStateAndSettings["lmStudioMaxTokens"]>("lmStudioMaxTokens")
const anthropicBaseUrl = context.globalState.get<GlobalStateAndSettings["anthropicBaseUrl"]>("anthropicBaseUrl")
const geminiBaseUrl = context.globalState.get<GlobalStateAndSettings["geminiBaseUrl"]>("geminiBaseUrl")
const azureApiVersion = context.globalState.get<GlobalStateAndSettings["azureApiVersion"]>("azureApiVersion")
const openRouterProviderSorting =
context.globalState.get<GlobalStateAndSettings["openRouterProviderSorting"]>("openRouterProviderSorting")
const lastShownAnnouncementId =
context.globalState.get<GlobalStateAndSettings["lastShownAnnouncementId"]>("lastShownAnnouncementId")
const autoApprovalSettings =
context.globalState.get<GlobalStateAndSettings["autoApprovalSettings"]>("autoApprovalSettings")
const browserSettings = context.globalState.get<GlobalStateAndSettings["browserSettings"]>("browserSettings")
const liteLlmBaseUrl = context.globalState.get<GlobalStateAndSettings["liteLlmBaseUrl"]>("liteLlmBaseUrl")
const liteLlmUsePromptCache =
context.globalState.get<GlobalStateAndSettings["liteLlmUsePromptCache"]>("liteLlmUsePromptCache")
const fireworksModelMaxCompletionTokens = context.globalState.get<
GlobalStateAndSettings["fireworksModelMaxCompletionTokens"]
>("fireworksModelMaxCompletionTokens")
const fireworksModelMaxTokens =
context.globalState.get<GlobalStateAndSettings["fireworksModelMaxTokens"]>("fireworksModelMaxTokens")
const userInfo = context.globalState.get<GlobalStateAndSettings["userInfo"]>("userInfo")
const qwenApiLine = context.globalState.get<GlobalStateAndSettings["qwenApiLine"]>("qwenApiLine")
const moonshotApiLine = context.globalState.get<GlobalStateAndSettings["moonshotApiLine"]>("moonshotApiLine")
const zaiApiLine = context.globalState.get<GlobalStateAndSettings["zaiApiLine"]>("zaiApiLine")
const telemetrySetting = context.globalState.get<GlobalStateAndSettings["telemetrySetting"]>("telemetrySetting")
const asksageApiUrl = context.globalState.get<GlobalStateAndSettings["asksageApiUrl"]>("asksageApiUrl")
const planActSeparateModelsSettingRaw =
context.globalState.get<GlobalStateAndSettings["planActSeparateModelsSetting"]>("planActSeparateModelsSetting")
const favoritedModelIds = context.globalState.get<GlobalStateAndSettings["favoritedModelIds"]>("favoritedModelIds")
const globalClineRulesToggles =
context.globalState.get<GlobalStateAndSettings["globalClineRulesToggles"]>("globalClineRulesToggles")
const requestTimeoutMs = context.globalState.get<GlobalStateAndSettings["requestTimeoutMs"]>("requestTimeoutMs")
const shellIntegrationTimeout =
context.globalState.get<GlobalStateAndSettings["shellIntegrationTimeout"]>("shellIntegrationTimeout")
const enableCheckpointsSettingRaw =
context.globalState.get<GlobalStateAndSettings["enableCheckpointsSetting"]>("enableCheckpointsSetting")
const mcpMarketplaceEnabledRaw =
context.globalState.get<GlobalStateAndSettings["mcpMarketplaceEnabled"]>("mcpMarketplaceEnabled")
const mcpDisplayMode = context.globalState.get<GlobalStateAndSettings["mcpDisplayMode"]>("mcpDisplayMode")
const mcpResponsesCollapsedRaw =
context.globalState.get<GlobalStateAndSettings["mcpResponsesCollapsed"]>("mcpResponsesCollapsed")
const globalWorkflowToggles =
context.globalState.get<GlobalStateAndSettings["globalWorkflowToggles"]>("globalWorkflowToggles")
const terminalReuseEnabled =
context.globalState.get<GlobalStateAndSettings["terminalReuseEnabled"]>("terminalReuseEnabled")
const terminalOutputLineLimit =
context.globalState.get<GlobalStateAndSettings["terminalOutputLineLimit"]>("terminalOutputLineLimit")
const defaultTerminalProfile =
context.globalState.get<GlobalStateAndSettings["defaultTerminalProfile"]>("defaultTerminalProfile")
const sapAiCoreBaseUrl = context.globalState.get<GlobalStateAndSettings["sapAiCoreBaseUrl"]>("sapAiCoreBaseUrl")
const sapAiCoreTokenUrl = context.globalState.get<GlobalStateAndSettings["sapAiCoreTokenUrl"]>("sapAiCoreTokenUrl")
const sapAiResourceGroup = context.globalState.get<GlobalStateAndSettings["sapAiResourceGroup"]>("sapAiResourceGroup")
const claudeCodePath = context.globalState.get<GlobalStateAndSettings["claudeCodePath"]>("claudeCodePath")
const difyBaseUrl = context.globalState.get<GlobalStateAndSettings["difyBaseUrl"]>("difyBaseUrl")
const openaiReasoningEffort =
context.globalState.get<GlobalStateAndSettings["openaiReasoningEffort"]>("openaiReasoningEffort")
const preferredLanguage = context.globalState.get<GlobalStateAndSettings["preferredLanguage"]>("preferredLanguage")
const focusChainSettings = context.globalState.get<GlobalStateAndSettings["focusChainSettings"]>("focusChainSettings")
const mcpMarketplaceCatalog = context.globalState.get("mcpMarketplaceCatalog") as GlobalState["mcpMarketplaceCatalog"]
const qwenCodeOauthPath = context.globalState.get("qwenCodeOauthPath") as GlobalState["qwenCodeOauthPath"]
const customPrompt = context.globalState.get("customPrompt") as GlobalState["customPrompt"]
const mcpMarketplaceCatalog =
context.globalState.get<GlobalStateAndSettings["mcpMarketplaceCatalog"]>("mcpMarketplaceCatalog")
const qwenCodeOauthPath = context.globalState.get<GlobalStateAndSettings["qwenCodeOauthPath"]>("qwenCodeOauthPath")
const customPrompt = context.globalState.get<GlobalStateAndSettings["customPrompt"]>("customPrompt")
// Get mode-related configurations
const mode = context.globalState.get("mode") as Mode | undefined
const mode = context.globalState.get<GlobalStateAndSettings["mode"]>("mode")
// Plan mode configurations
const planModeApiProvider = context.globalState.get("planModeApiProvider") as ApiProvider | undefined
const planModeApiModelId = context.globalState.get("planModeApiModelId") as string | undefined
const planModeThinkingBudgetTokens = context.globalState.get("planModeThinkingBudgetTokens") as number | undefined
const planModeReasoningEffort = context.globalState.get("planModeReasoningEffort") as string | undefined
const planModeVsCodeLmModelSelector = context.globalState.get("planModeVsCodeLmModelSelector") as
| LanguageModelChatSelector
| undefined
const planModeAwsBedrockCustomSelected = context.globalState.get("planModeAwsBedrockCustomSelected") as
| boolean
| undefined
const planModeAwsBedrockCustomModelBaseId = context.globalState.get("planModeAwsBedrockCustomModelBaseId") as
| BedrockModelId
| undefined
const planModeOpenRouterModelId = context.globalState.get("planModeOpenRouterModelId") as string | undefined
const planModeOpenRouterModelInfo = context.globalState.get("planModeOpenRouterModelInfo") as ModelInfo | undefined
const planModeOpenAiModelId = context.globalState.get("planModeOpenAiModelId") as string | undefined
const planModeOpenAiModelInfo = context.globalState.get("planModeOpenAiModelInfo") as ModelInfo | undefined
const planModeOllamaModelId = context.globalState.get("planModeOllamaModelId") as string | undefined
const planModeLmStudioModelId = context.globalState.get("planModeLmStudioModelId") as string | undefined
const planModeLiteLlmModelId = context.globalState.get("planModeLiteLlmModelId") as string | undefined
const planModeLiteLlmModelInfo = context.globalState.get("planModeLiteLlmModelInfo") as ModelInfo | undefined
const planModeRequestyModelId = context.globalState.get("planModeRequestyModelId") as string | undefined
const planModeRequestyModelInfo = context.globalState.get("planModeRequestyModelInfo") as ModelInfo | undefined
const planModeTogetherModelId = context.globalState.get("planModeTogetherModelId") as string | undefined
const planModeFireworksModelId = context.globalState.get("planModeFireworksModelId") as string | undefined
const planModeSapAiCoreModelId = context.globalState.get("planModeSapAiCoreModelId") as string | undefined
const planModeSapAiCoreDeploymentId = context.globalState.get("planModeSapAiCoreDeploymentId") as string | undefined
const planModeGroqModelId = context.globalState.get("planModeGroqModelId") as string | undefined
const planModeGroqModelInfo = context.globalState.get("planModeGroqModelInfo") as ModelInfo | undefined
const planModeHuggingFaceModelId = context.globalState.get("planModeHuggingFaceModelId") as string | undefined
const planModeHuggingFaceModelInfo = context.globalState.get("planModeHuggingFaceModelInfo") as ModelInfo | undefined
const planModeHuaweiCloudMaasModelId = context.globalState.get("planModeHuaweiCloudMaasModelId") as string | undefined
const planModeHuaweiCloudMaasModelInfo = context.globalState.get("planModeHuaweiCloudMaasModelInfo") as
| ModelInfo
| undefined
const planModeBasetenModelId = context.globalState.get("planModeBasetenModelId") as string | undefined
const planModeBasetenModelInfo = context.globalState.get("planModeBasetenModelInfo") as ModelInfo | undefined
const planModeVercelAiGatewayModelId = context.globalState.get("planModeVercelAiGatewayModelId") as string | undefined
const planModeVercelAiGatewayModelInfo = context.globalState.get("planModeVercelAiGatewayModelInfo") as
| ModelInfo
| undefined
const planModeApiProvider = context.globalState.get<GlobalStateAndSettings["planModeApiProvider"]>("planModeApiProvider")
const planModeApiModelId = context.globalState.get<GlobalStateAndSettings["planModeApiModelId"]>("planModeApiModelId")
const planModeThinkingBudgetTokens =
context.globalState.get<GlobalStateAndSettings["planModeThinkingBudgetTokens"]>("planModeThinkingBudgetTokens")
const planModeReasoningEffort =
context.globalState.get<GlobalStateAndSettings["planModeReasoningEffort"]>("planModeReasoningEffort")
const planModeVsCodeLmModelSelector =
context.globalState.get<GlobalStateAndSettings["planModeVsCodeLmModelSelector"]>("planModeVsCodeLmModelSelector")
const planModeAwsBedrockCustomSelected = context.globalState.get<
GlobalStateAndSettings["planModeAwsBedrockCustomSelected"]
>("planModeAwsBedrockCustomSelected")
const planModeAwsBedrockCustomModelBaseId = context.globalState.get<
GlobalStateAndSettings["planModeAwsBedrockCustomModelBaseId"]
>("planModeAwsBedrockCustomModelBaseId")
const planModeOpenRouterModelId =
context.globalState.get<GlobalStateAndSettings["planModeOpenRouterModelId"]>("planModeOpenRouterModelId")
const planModeOpenRouterModelInfo =
context.globalState.get<GlobalStateAndSettings["planModeOpenRouterModelInfo"]>("planModeOpenRouterModelInfo")
const planModeOpenAiModelId =
context.globalState.get<GlobalStateAndSettings["planModeOpenAiModelId"]>("planModeOpenAiModelId")
const planModeOpenAiModelInfo =
context.globalState.get<GlobalStateAndSettings["planModeOpenAiModelInfo"]>("planModeOpenAiModelInfo")
const planModeOllamaModelId =
context.globalState.get<GlobalStateAndSettings["planModeOllamaModelId"]>("planModeOllamaModelId")
const planModeLmStudioModelId =
context.globalState.get<GlobalStateAndSettings["planModeLmStudioModelId"]>("planModeLmStudioModelId")
const planModeLiteLlmModelId =
context.globalState.get<GlobalStateAndSettings["planModeLiteLlmModelId"]>("planModeLiteLlmModelId")
const planModeLiteLlmModelInfo =
context.globalState.get<GlobalStateAndSettings["planModeLiteLlmModelInfo"]>("planModeLiteLlmModelInfo")
const planModeRequestyModelId =
context.globalState.get<GlobalStateAndSettings["planModeRequestyModelId"]>("planModeRequestyModelId")
const planModeRequestyModelInfo =
context.globalState.get<GlobalStateAndSettings["planModeRequestyModelInfo"]>("planModeRequestyModelInfo")
const planModeTogetherModelId =
context.globalState.get<GlobalStateAndSettings["planModeTogetherModelId"]>("planModeTogetherModelId")
const planModeFireworksModelId =
context.globalState.get<GlobalStateAndSettings["planModeFireworksModelId"]>("planModeFireworksModelId")
const planModeSapAiCoreModelId =
context.globalState.get<GlobalStateAndSettings["planModeSapAiCoreModelId"]>("planModeSapAiCoreModelId")
const planModeSapAiCoreDeploymentId =
context.globalState.get<GlobalStateAndSettings["planModeSapAiCoreDeploymentId"]>("planModeSapAiCoreDeploymentId")
const planModeGroqModelId = context.globalState.get<GlobalStateAndSettings["planModeGroqModelId"]>("planModeGroqModelId")
const planModeGroqModelInfo =
context.globalState.get<GlobalStateAndSettings["planModeGroqModelInfo"]>("planModeGroqModelInfo")
const planModeHuggingFaceModelId =
context.globalState.get<GlobalStateAndSettings["planModeHuggingFaceModelId"]>("planModeHuggingFaceModelId")
const planModeHuggingFaceModelInfo =
context.globalState.get<GlobalStateAndSettings["planModeHuggingFaceModelInfo"]>("planModeHuggingFaceModelInfo")
const planModeHuaweiCloudMaasModelId =
context.globalState.get<GlobalStateAndSettings["planModeHuaweiCloudMaasModelId"]>("planModeHuaweiCloudMaasModelId")
const planModeHuaweiCloudMaasModelInfo = context.globalState.get<
GlobalStateAndSettings["planModeHuaweiCloudMaasModelInfo"]
>("planModeHuaweiCloudMaasModelInfo")
const planModeBasetenModelId =
context.globalState.get<GlobalStateAndSettings["planModeBasetenModelId"]>("planModeBasetenModelId")
const planModeBasetenModelInfo =
context.globalState.get<GlobalStateAndSettings["planModeBasetenModelInfo"]>("planModeBasetenModelInfo")
const planModeVercelAiGatewayModelId =
context.globalState.get<GlobalStateAndSettings["planModeVercelAiGatewayModelId"]>("planModeVercelAiGatewayModelId")
const planModeVercelAiGatewayModelInfo = context.globalState.get<
GlobalStateAndSettings["planModeVercelAiGatewayModelInfo"]
>("planModeVercelAiGatewayModelInfo")
// Act mode configurations
const actModeApiProvider = context.globalState.get("actModeApiProvider") as ApiProvider | undefined
const actModeApiModelId = context.globalState.get("actModeApiModelId") as string | undefined
const actModeThinkingBudgetTokens = context.globalState.get("actModeThinkingBudgetTokens") as number | undefined
const actModeReasoningEffort = context.globalState.get("actModeReasoningEffort") as string | undefined
const actModeVsCodeLmModelSelector = context.globalState.get("actModeVsCodeLmModelSelector") as
| LanguageModelChatSelector
| undefined
const actModeAwsBedrockCustomSelected = context.globalState.get("actModeAwsBedrockCustomSelected") as boolean | undefined
const actModeAwsBedrockCustomModelBaseId = context.globalState.get("actModeAwsBedrockCustomModelBaseId") as
| BedrockModelId
| undefined
const actModeOpenRouterModelId = context.globalState.get("actModeOpenRouterModelId") as string | undefined
const actModeOpenRouterModelInfo = context.globalState.get("actModeOpenRouterModelInfo") as ModelInfo | undefined
const actModeOpenAiModelId = context.globalState.get("actModeOpenAiModelId") as string | undefined
const actModeOpenAiModelInfo = context.globalState.get("actModeOpenAiModelInfo") as ModelInfo | undefined
const actModeOllamaModelId = context.globalState.get("actModeOllamaModelId") as string | undefined
const actModeLmStudioModelId = context.globalState.get("actModeLmStudioModelId") as string | undefined
const actModeLiteLlmModelId = context.globalState.get("actModeLiteLlmModelId") as string | undefined
const actModeLiteLlmModelInfo = context.globalState.get("actModeLiteLlmModelInfo") as ModelInfo | undefined
const actModeRequestyModelId = context.globalState.get("actModeRequestyModelId") as string | undefined
const actModeRequestyModelInfo = context.globalState.get("actModeRequestyModelInfo") as ModelInfo | undefined
const actModeTogetherModelId = context.globalState.get("actModeTogetherModelId") as string | undefined
const actModeFireworksModelId = context.globalState.get("actModeFireworksModelId") as string | undefined
const actModeSapAiCoreModelId = context.globalState.get("actModeSapAiCoreModelId") as string | undefined
const actModeSapAiCoreDeploymentId = context.globalState.get("actModeSapAiCoreDeploymentId") as string | undefined
const actModeGroqModelId = context.globalState.get("actModeGroqModelId") as string | undefined
const actModeGroqModelInfo = context.globalState.get("actModeGroqModelInfo") as ModelInfo | undefined
const actModeHuggingFaceModelId = context.globalState.get("actModeHuggingFaceModelId") as string | undefined
const actModeHuggingFaceModelInfo = context.globalState.get("actModeHuggingFaceModelInfo") as ModelInfo | undefined
const actModeHuaweiCloudMaasModelId = context.globalState.get("actModeHuaweiCloudMaasModelId") as string | undefined
const actModeHuaweiCloudMaasModelInfo = context.globalState.get("actModeHuaweiCloudMaasModelInfo") as
| ModelInfo
| undefined
const actModeBasetenModelId = context.globalState.get("actModeBasetenModelId") as string | undefined
const actModeBasetenModelInfo = context.globalState.get("actModeBasetenModelInfo") as ModelInfo | undefined
const actModeVercelAiGatewayModelId = context.globalState.get("actModeVercelAiGatewayModelId") as string | undefined
const actModeVercelAiGatewayModelInfo = context.globalState.get("actModeVercelAiGatewayModelInfo") as
| ModelInfo
| undefined
const sapAiCoreUseOrchestrationMode = context.globalState.get("sapAiCoreUseOrchestrationMode") as boolean | undefined
const actModeApiProvider = context.globalState.get<GlobalStateAndSettings["actModeApiProvider"]>("actModeApiProvider")
const actModeApiModelId = context.globalState.get<GlobalStateAndSettings["actModeApiModelId"]>("actModeApiModelId")
const actModeThinkingBudgetTokens =
context.globalState.get<GlobalStateAndSettings["actModeThinkingBudgetTokens"]>("actModeThinkingBudgetTokens")
const actModeReasoningEffort =
context.globalState.get<GlobalStateAndSettings["actModeReasoningEffort"]>("actModeReasoningEffort")
const actModeVsCodeLmModelSelector =
context.globalState.get<GlobalStateAndSettings["actModeVsCodeLmModelSelector"]>("actModeVsCodeLmModelSelector")
const actModeAwsBedrockCustomSelected = context.globalState.get<
GlobalStateAndSettings["actModeAwsBedrockCustomSelected"]
>("actModeAwsBedrockCustomSelected")
const actModeAwsBedrockCustomModelBaseId = context.globalState.get<
GlobalStateAndSettings["actModeAwsBedrockCustomModelBaseId"]
>("actModeAwsBedrockCustomModelBaseId")
const actModeOpenRouterModelId =
context.globalState.get<GlobalStateAndSettings["actModeOpenRouterModelId"]>("actModeOpenRouterModelId")
const actModeOpenRouterModelInfo =
context.globalState.get<GlobalStateAndSettings["actModeOpenRouterModelInfo"]>("actModeOpenRouterModelInfo")
const actModeOpenAiModelId =
context.globalState.get<GlobalStateAndSettings["actModeOpenAiModelId"]>("actModeOpenAiModelId")
const actModeOpenAiModelInfo =
context.globalState.get<GlobalStateAndSettings["actModeOpenAiModelInfo"]>("actModeOpenAiModelInfo")
const actModeOllamaModelId =
context.globalState.get<GlobalStateAndSettings["actModeOllamaModelId"]>("actModeOllamaModelId")
const actModeLmStudioModelId =
context.globalState.get<GlobalStateAndSettings["actModeLmStudioModelId"]>("actModeLmStudioModelId")
const actModeLiteLlmModelId =
context.globalState.get<GlobalStateAndSettings["actModeLiteLlmModelId"]>("actModeLiteLlmModelId")
const actModeLiteLlmModelInfo =
context.globalState.get<GlobalStateAndSettings["actModeLiteLlmModelInfo"]>("actModeLiteLlmModelInfo")
const actModeRequestyModelId =
context.globalState.get<GlobalStateAndSettings["actModeRequestyModelId"]>("actModeRequestyModelId")
const actModeRequestyModelInfo =
context.globalState.get<GlobalStateAndSettings["actModeRequestyModelInfo"]>("actModeRequestyModelInfo")
const actModeTogetherModelId =
context.globalState.get<GlobalStateAndSettings["actModeTogetherModelId"]>("actModeTogetherModelId")
const actModeFireworksModelId =
context.globalState.get<GlobalStateAndSettings["actModeFireworksModelId"]>("actModeFireworksModelId")
const actModeSapAiCoreModelId =
context.globalState.get<GlobalStateAndSettings["actModeSapAiCoreModelId"]>("actModeSapAiCoreModelId")
const actModeSapAiCoreDeploymentId =
context.globalState.get<GlobalStateAndSettings["actModeSapAiCoreDeploymentId"]>("actModeSapAiCoreDeploymentId")
const actModeGroqModelId = context.globalState.get<GlobalStateAndSettings["actModeGroqModelId"]>("actModeGroqModelId")
const actModeGroqModelInfo =
context.globalState.get<GlobalStateAndSettings["actModeGroqModelInfo"]>("actModeGroqModelInfo")
const actModeHuggingFaceModelId =
context.globalState.get<GlobalStateAndSettings["actModeHuggingFaceModelId"]>("actModeHuggingFaceModelId")
const actModeHuggingFaceModelInfo =
context.globalState.get<GlobalStateAndSettings["actModeHuggingFaceModelInfo"]>("actModeHuggingFaceModelInfo")
const actModeHuaweiCloudMaasModelId =
context.globalState.get<GlobalStateAndSettings["actModeHuaweiCloudMaasModelId"]>("actModeHuaweiCloudMaasModelId")
const actModeHuaweiCloudMaasModelInfo = context.globalState.get<
GlobalStateAndSettings["actModeHuaweiCloudMaasModelInfo"]
>("actModeHuaweiCloudMaasModelInfo")
const actModeBasetenModelId =
context.globalState.get<GlobalStateAndSettings["actModeBasetenModelId"]>("actModeBasetenModelId")
const actModeBasetenModelInfo =
context.globalState.get<GlobalStateAndSettings["actModeBasetenModelInfo"]>("actModeBasetenModelInfo")
const actModeVercelAiGatewayModelId =
context.globalState.get<GlobalStateAndSettings["actModeVercelAiGatewayModelId"]>("actModeVercelAiGatewayModelId")
const actModeVercelAiGatewayModelInfo = context.globalState.get<
GlobalStateAndSettings["actModeVercelAiGatewayModelInfo"]
>("actModeVercelAiGatewayModelInfo")
const sapAiCoreUseOrchestrationMode =
context.globalState.get<GlobalStateAndSettings["sapAiCoreUseOrchestrationMode"]>("sapAiCoreUseOrchestrationMode")
let apiProvider: ApiProvider
if (planModeApiProvider) {
@@ -325,7 +392,7 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
const taskHistory = await readTaskHistoryFromState(context)
// Multi-root workspace support
const workspaceRoots = context.globalState.get<GlobalState["workspaceRoots"]>("workspaceRoots")
const workspaceRoots = context.globalState.get<GlobalStateAndSettings["workspaceRoots"]>("workspaceRoots")
/**
* Get primary root index from global state.
* The primary root is the main workspace folder that Cline focuses on when dealing with
@@ -333,8 +400,8 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
* and the primary root index indicates which folder (by its position in the array, 0-based)
* should be treated as the main/default working directory for operations.
*/
const primaryRootIndex = context.globalState.get<GlobalState["primaryRootIndex"]>("primaryRootIndex")
const multiRootEnabled = context.globalState.get<GlobalState["multiRootEnabled"]>("multiRootEnabled")
const primaryRootIndex = context.globalState.get<GlobalStateAndSettings["primaryRootIndex"]>("primaryRootIndex")
const multiRootEnabled = context.globalState.get<GlobalStateAndSettings["multiRootEnabled"]>("multiRootEnabled")
return {
// api configuration fields
@@ -367,13 +434,13 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
fireworksModelMaxCompletionTokens,
fireworksModelMaxTokens,
asksageApiUrl,
favoritedModelIds,
favoritedModelIds: favoritedModelIds || [],
requestTimeoutMs,
sapAiCoreBaseUrl,
sapAiCoreTokenUrl,
sapAiResourceGroup,
difyBaseUrl,
sapAiCoreUseOrchestrationMode,
sapAiCoreUseOrchestrationMode: sapAiCoreUseOrchestrationMode ?? true,
// Plan mode configurations
planModeApiProvider: planModeApiProvider || apiProvider,
planModeApiModelId,
@@ -393,7 +460,7 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
planModeRequestyModelId,
planModeRequestyModelInfo,
planModeTogetherModelId,
planModeFireworksModelId,
planModeFireworksModelId: planModeFireworksModelId || fireworksDefaultModelId,
planModeSapAiCoreModelId,
planModeSapAiCoreDeploymentId,
planModeGroqModelId,
@@ -425,7 +492,7 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
actModeRequestyModelId,
actModeRequestyModelInfo,
actModeTogetherModelId,
actModeFireworksModelId,
actModeFireworksModelId: actModeFireworksModelId || fireworksDefaultModelId,
actModeSapAiCoreModelId,
actModeSapAiCoreDeploymentId,
actModeGroqModelId,
@@ -441,8 +508,8 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
// Other global fields
focusChainSettings: focusChainSettings || DEFAULT_FOCUS_CHAIN_SETTINGS,
focusChainFeatureFlagEnabled: focusChainFeatureFlagEnabled ?? false,
strictPlanModeEnabled: strictPlanModeEnabled ?? true,
yoloModeToggled: yoloModeToggled ?? false,
useAutoCondense: useAutoCondense ?? false,
isNewUser: isNewUser ?? true,
welcomeViewCompleted,
@@ -459,7 +526,7 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis
mcpDisplayMode: mcpDisplayMode ?? DEFAULT_MCP_DISPLAY_MODE,
mcpResponsesCollapsed: mcpResponsesCollapsed,
telemetrySetting: telemetrySetting || "unset",
planActSeparateModelsSetting,
planActSeparateModelsSetting: planActSeparateModelsSetting ?? false,
enableCheckpointsSetting: enableCheckpointsSettingRaw ?? true,
shellIntegrationTimeout: shellIntegrationTimeout || 4000,
terminalReuseEnabled: terminalReuseEnabled ?? true,
+34
View File
@@ -28,6 +28,40 @@ export class SecretStore implements vscode.SecretStorage {
}
}
// A SecretStorage implementation that delegates to an injected storage
// (e.g., the cline secretStorage singleton backed by OS keychain).
export class DelegatingSecretStore implements vscode.SecretStorage {
private readonly _onDidChange = new EventEmitter<vscode.SecretStorageChangeEvent>()
private unsubscribe: { dispose(): void } | null = null
constructor(
private readonly delegate: {
get(key: string): Promise<string | undefined>
store(key: string, value: string): Promise<void>
delete(key: string): Promise<void>
onDidChange?: (listener: (e: { key: string }) => any) => { dispose(): void }
},
) {
if (this.delegate.onDidChange) {
this.unsubscribe = this.delegate.onDidChange(({ key }) => this._onDidChange.fire({ key }))
}
}
readonly onDidChange: vscode.Event<vscode.SecretStorageChangeEvent> = this._onDidChange.event
get(key: string): Thenable<string | undefined> {
return this.delegate.get(key)
}
store(key: string, value: string): Thenable<void> {
return this.delegate.store(key, value)
}
delete(key: string): Thenable<void> {
return this.delegate.delete(key)
}
}
// Create a class that implements Memento interface with the required setKeysForSync method
export class MementoStore implements vscode.Memento {
private data: JsonKeyValueStore<any>
+14372 -14372
View File
File diff suppressed because it is too large Load Diff