Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 5 additions & 111 deletions packages/types/src/global-settings.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -106,89 +106,7 @@ export const globalSettingsSchema = z.object({

export type GlobalSettings = z.infer<typeof globalSettingsSchema>

export const GLOBAL_SETTINGS_KEYS = keysOf<GlobalSettings>()([
"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",

"mode",
"modeApiConfigs",
"customModes",
"customModePrompts",
"customSupportPrompts",
"enhancementApiConfigId",
"cachedChromeHostUrl",
"historyPreviewCollapsed",
])
export const GLOBAL_SETTINGS_KEYS = globalSettingsSchema.keyof().options

/**
* RooCodeSettings
Expand All @@ -201,32 +119,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"
| "codebaseIndexOpenAiCompatibleApiKey"
>

export const SECRET_STATE_KEYS = keysOf<SecretState>()([
export const SECRET_STATE_KEYS = [
"apiKey",
"glamaApiKey",
"openRouterApiKey",
Expand All @@ -247,7 +140,8 @@ export const SECRET_STATE_KEYS = keysOf<SecretState>()([
"codeIndexOpenAiKey",
"codeIndexQdrantApiKey",
"codebaseIndexOpenAiCompatibleApiKey",
])
] as const satisfies readonly (keyof ProviderSettings)[]
export type SecretState = Pick<ProviderSettings, (typeof SECRET_STATE_KEYS)[number]>

export const isSecretStateKey = (key: string): key is Keys<SecretState> =>
SECRET_STATE_KEYS.includes(key as Keys<SecretState>)
Expand Down
106 changes: 1 addition & 105 deletions packages/types/src/provider-settings.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -259,110 +258,7 @@ export const providerSettingsSchema = z.object({
})

export type ProviderSettings = z.infer<typeof providerSettingsSchema>

export const PROVIDER_SETTINGS_KEYS = keysOf<ProviderSettings>()([
"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",
])
export const PROVIDER_SETTINGS_KEYS = providerSettingsSchema.keyof().options

export const MODEL_ID_KEYS: Partial<keyof ProviderSettings>[] = [
"apiModelId",
Expand Down
10 changes: 0 additions & 10 deletions packages/types/src/type-fu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,3 @@ export type Values<T> = T[keyof T]
export type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false

export type AssertEqual<T extends true> = 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<T>() {
return <const U extends readonly (keyof T)[]>(
keys: keyof T extends U[number] ? (U[number] extends keyof T ? U : never) : never,
): U => keys
}
Loading