diff --git a/packages/types/src/global-settings.ts b/packages/types/src/global-settings.ts index 9373ac78860..bbf9b35d21e 100644 --- a/packages/types/src/global-settings.ts +++ b/packages/types/src/global-settings.ts @@ -1,6 +1,6 @@ import { z } from "zod" -import { type Keys, keysOf } from "./type-fu.js" +import { type Keys } from "./type-fu.js" import { type ProviderSettings, PROVIDER_SETTINGS_KEYS, @@ -112,96 +112,7 @@ export const globalSettingsSchema = z.object({ export type GlobalSettings = z.infer -export const GLOBAL_SETTINGS_KEYS = keysOf()([ - "currentApiConfigName", - "listApiConfigMeta", - "pinnedApiConfigs", - - "lastShownAnnouncementId", - "customInstructions", - "taskHistory", - - "condensingApiConfigId", - "customCondensingPrompt", - - "autoApprovalEnabled", - "alwaysAllowReadOnly", - "alwaysAllowReadOnlyOutsideWorkspace", - "alwaysAllowWrite", - "alwaysAllowWriteOutsideWorkspace", - "writeDelayMs", - "alwaysAllowBrowser", - "alwaysApproveResubmit", - "requestDelaySeconds", - "alwaysAllowMcp", - "alwaysAllowModeSwitch", - "alwaysAllowSubtasks", - "alwaysAllowExecute", - "allowedCommands", - "allowedMaxRequests", - "autoCondenseContext", - "autoCondenseContextPercent", - "maxConcurrentFileReads", - - "browserToolEnabled", - "browserViewportSize", - "screenshotQuality", - "remoteBrowserEnabled", - "remoteBrowserHost", - - "enableCheckpoints", - - "ttsEnabled", - "ttsSpeed", - "soundEnabled", - "soundVolume", - - "maxOpenTabsContext", - "maxWorkspaceFiles", - "showRooIgnoredFiles", - "maxReadFileLine", - - "terminalOutputLineLimit", - "terminalShellIntegrationTimeout", - "terminalShellIntegrationDisabled", - "terminalCommandDelay", - "terminalPowershellCounter", - "terminalZshClearEolMark", - "terminalZshOhMy", - "terminalZshP10k", - "terminalZdotdir", - "terminalCompressProgressBar", - - "rateLimitSeconds", - "diffEnabled", - "fuzzyMatchThreshold", - "experiments", - - "codebaseIndexModels", - "codebaseIndexConfig", - - "language", - - "telemetrySetting", - "mcpEnabled", - "enableMcpServerCreation", - "mcpMarketplaceCatalog", // kilocode_change - - "mode", - "modeApiConfigs", - "customModes", - "customModePrompts", - "customSupportPrompts", - "enhancementApiConfigId", - "cachedChromeHostUrl", - "historyPreviewCollapsed", - - "showAutoApproveMenu", // kilocode_change - "localWorkflowToggles", // kilocode_change - "globalWorkflowToggles", // kilocode_change - "localRulesToggles", // kilocode_change - "globalRulesToggles", // kilocode_change -]) +export const GLOBAL_SETTINGS_KEYS = globalSettingsSchema.keyof().options /** * RooCodeSettings @@ -214,33 +125,7 @@ export type RooCodeSettings = GlobalSettings & ProviderSettings /** * SecretState */ - -export type SecretState = Pick< - ProviderSettings, - | "apiKey" - | "glamaApiKey" - | "openRouterApiKey" - | "awsAccessKey" - | "awsSecretKey" - | "awsSessionToken" - | "openAiApiKey" - | "geminiApiKey" - | "openAiNativeApiKey" - | "deepSeekApiKey" - | "mistralApiKey" - | "unboundApiKey" - | "requestyApiKey" - | "xaiApiKey" - | "groqApiKey" - | "chutesApiKey" - | "litellmApiKey" - | "codeIndexOpenAiKey" - | "codeIndexQdrantApiKey" - | "kilocodeToken" // kilocode_change - | "codebaseIndexOpenAiCompatibleApiKey" -> - -export const SECRET_STATE_KEYS = keysOf()([ +export const SECRET_STATE_KEYS = [ "apiKey", "glamaApiKey", "openRouterApiKey", @@ -262,7 +147,8 @@ export const SECRET_STATE_KEYS = keysOf()([ "codeIndexQdrantApiKey", "kilocodeToken", // kilocode_change "codebaseIndexOpenAiCompatibleApiKey", -]) +] as const satisfies readonly (keyof ProviderSettings)[] +export type SecretState = Pick export const isSecretStateKey = (key: string): key is Keys => SECRET_STATE_KEYS.includes(key as Keys) diff --git a/packages/types/src/provider-settings.ts b/packages/types/src/provider-settings.ts index 2a18002b9a1..7f21fb2c43b 100644 --- a/packages/types/src/provider-settings.ts +++ b/packages/types/src/provider-settings.ts @@ -1,6 +1,5 @@ import { z } from "zod" -import { keysOf } from "./type-fu.js" import { reasoningEffortsSchema, modelInfoSchema } from "./model.js" import { codebaseIndexProviderSchema } from "./codebase-index.js" @@ -284,114 +283,7 @@ export const providerSettingsSchema = z.object({ }) export type ProviderSettings = z.infer - -export const PROVIDER_SETTINGS_KEYS = keysOf()([ - "apiProvider", - // Anthropic - "apiModelId", - "apiKey", - "anthropicBaseUrl", - "anthropicUseAuthToken", - // Glama - "glamaModelId", - "glamaApiKey", - // OpenRouter - "openRouterApiKey", - "openRouterModelId", - "openRouterBaseUrl", - "openRouterSpecificProvider", - "openRouterUseMiddleOutTransform", - // Amazon Bedrock - "awsAccessKey", - "awsSecretKey", - "awsSessionToken", - "awsRegion", - "awsUseCrossRegionInference", - "awsUsePromptCache", - "awsProfile", - "awsUseProfile", - "awsCustomArn", - "awsModelContextWindow", - "awsBedrockEndpointEnabled", - "awsBedrockEndpoint", - // Google Vertex - "vertexKeyFile", - "vertexJsonCredentials", - "vertexProjectId", - "vertexRegion", - // OpenAI - "openAiBaseUrl", - "openAiApiKey", - "openAiLegacyFormat", - "openAiR1FormatEnabled", - "openAiModelId", - "openAiCustomModelInfo", - "openAiUseAzure", - "azureApiVersion", - "openAiStreamingEnabled", - "openAiHostHeader", // Keep temporarily for backward compatibility during migration. - "openAiHeaders", - // Ollama - "ollamaModelId", - "ollamaBaseUrl", - // VS Code LM - "vsCodeLmModelSelector", - "lmStudioModelId", - "lmStudioBaseUrl", - "lmStudioDraftModelId", - "lmStudioSpeculativeDecodingEnabled", - // Gemini - "geminiApiKey", - "googleGeminiBaseUrl", - // OpenAI Native - "openAiNativeApiKey", - "openAiNativeBaseUrl", - // Mistral - "mistralApiKey", - "mistralCodestralUrl", - // DeepSeek - "deepSeekBaseUrl", - "deepSeekApiKey", - // Unbound - "unboundApiKey", - "unboundModelId", - // Requesty - "requestyApiKey", - "requestyModelId", - // Code Index - "codeIndexOpenAiKey", - "codeIndexQdrantApiKey", - "codebaseIndexOpenAiCompatibleBaseUrl", - "codebaseIndexOpenAiCompatibleApiKey", - "codebaseIndexOpenAiCompatibleModelDimension", - // Reasoning - "enableReasoningEffort", - "reasoningEffort", - "modelMaxTokens", - "modelMaxThinkingTokens", - // Generic - "includeMaxTokens", - "diffEnabled", - "fuzzyMatchThreshold", - "modelTemperature", - "rateLimitSeconds", - // Fake AI - "fakeAi", - // X.AI (Grok) - "xaiApiKey", - // Groq - "groqApiKey", - // Chutes AI - "chutesApiKey", - // LiteLLM - "litellmBaseUrl", - "litellmApiKey", - "litellmModelId", - "fireworksApiKey", // kilocode_change - "fireworksModelId", // kilocode_change - "kilocodeToken", // kilocode_change - "kilocodeModel", // kilocode_change -]) +export const PROVIDER_SETTINGS_KEYS = providerSettingsSchema.keyof().options export const MODEL_ID_KEYS: Partial[] = [ "apiModelId", diff --git a/packages/types/src/type-fu.ts b/packages/types/src/type-fu.ts index f5962de6f03..0014e9b187d 100644 --- a/packages/types/src/type-fu.ts +++ b/packages/types/src/type-fu.ts @@ -9,13 +9,3 @@ export type Values = T[keyof T] export type Equals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? true : false export type AssertEqual = T - -/** - * Creates a type-safe keys array that enforces ALL keys from type T are present. - * Returns a compile-time error if any keys are missing or extra keys are provided. - */ -export function keysOf() { - return ( - keys: keyof T extends U[number] ? (U[number] extends keyof T ? U : never) : never, - ): U => keys -}