| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- import { z } from "zod"
- import { type Keys } from "./type-fu.js"
- import {
- type ProviderSettings,
- PROVIDER_SETTINGS_KEYS,
- providerSettingsEntrySchema,
- providerSettingsSchema,
- } from "./provider-settings.js"
- import { historyItemSchema } from "./history.js"
- import { codebaseIndexModelsSchema, codebaseIndexConfigSchema } from "./codebase-index.js"
- import { experimentsSchema } from "./experiment.js"
- import { telemetrySettingsSchema } from "./telemetry.js"
- import { modeConfigSchema } from "./mode.js"
- import { customModePromptsSchema, customSupportPromptsSchema } from "./mode.js"
- import { languagesSchema } from "./vscode.js"
- /**
- * GlobalSettings
- */
- export const globalSettingsSchema = z.object({
- currentApiConfigName: z.string().optional(),
- listApiConfigMeta: z.array(providerSettingsEntrySchema).optional(),
- pinnedApiConfigs: z.record(z.string(), z.boolean()).optional(),
- lastShownAnnouncementId: z.string().optional(),
- customInstructions: z.string().optional(),
- taskHistory: z.array(historyItemSchema).optional(),
- condensingApiConfigId: z.string().optional(),
- customCondensingPrompt: z.string().optional(),
- autoApprovalEnabled: z.boolean().optional(),
- alwaysAllowReadOnly: z.boolean().optional(),
- alwaysAllowReadOnlyOutsideWorkspace: z.boolean().optional(),
- alwaysAllowWrite: z.boolean().optional(),
- alwaysAllowWriteOutsideWorkspace: z.boolean().optional(),
- alwaysAllowWriteProtected: z.boolean().optional(),
- writeDelayMs: z.number().optional(),
- alwaysAllowBrowser: z.boolean().optional(),
- alwaysApproveResubmit: z.boolean().optional(),
- requestDelaySeconds: z.number().optional(),
- alwaysAllowMcp: z.boolean().optional(),
- alwaysAllowModeSwitch: z.boolean().optional(),
- alwaysAllowSubtasks: z.boolean().optional(),
- alwaysAllowExecute: z.boolean().optional(),
- allowedCommands: z.array(z.string()).optional(),
- allowedMaxRequests: z.number().nullish(),
- autoCondenseContext: z.boolean().optional(),
- autoCondenseContextPercent: z.number().optional(),
- maxConcurrentFileReads: z.number().optional(),
- browserToolEnabled: z.boolean().optional(),
- browserViewportSize: z.string().optional(),
- screenshotQuality: z.number().optional(),
- remoteBrowserEnabled: z.boolean().optional(),
- remoteBrowserHost: z.string().optional(),
- cachedChromeHostUrl: z.string().optional(),
- enableCheckpoints: z.boolean().optional(),
- ttsEnabled: z.boolean().optional(),
- ttsSpeed: z.number().optional(),
- soundEnabled: z.boolean().optional(),
- soundVolume: z.number().optional(),
- maxOpenTabsContext: z.number().optional(),
- maxWorkspaceFiles: z.number().optional(),
- showRooIgnoredFiles: z.boolean().optional(),
- maxReadFileLine: z.number().optional(),
- terminalOutputLineLimit: z.number().optional(),
- terminalShellIntegrationTimeout: z.number().optional(),
- terminalShellIntegrationDisabled: z.boolean().optional(),
- terminalCommandDelay: z.number().optional(),
- terminalPowershellCounter: z.boolean().optional(),
- terminalZshClearEolMark: z.boolean().optional(),
- terminalZshOhMy: z.boolean().optional(),
- terminalZshP10k: z.boolean().optional(),
- terminalZdotdir: z.boolean().optional(),
- terminalCompressProgressBar: z.boolean().optional(),
- rateLimitSeconds: z.number().optional(),
- diffEnabled: z.boolean().optional(),
- fuzzyMatchThreshold: z.number().optional(),
- experiments: experimentsSchema.optional(),
- codebaseIndexModels: codebaseIndexModelsSchema.optional(),
- codebaseIndexConfig: codebaseIndexConfigSchema.optional(),
- language: languagesSchema.optional(),
- telemetrySetting: telemetrySettingsSchema.optional(),
- mcpEnabled: z.boolean().optional(),
- enableMcpServerCreation: z.boolean().optional(),
- mode: z.string().optional(),
- modeApiConfigs: z.record(z.string(), z.string()).optional(),
- customModes: z.array(modeConfigSchema).optional(),
- customModePrompts: customModePromptsSchema.optional(),
- customSupportPrompts: customSupportPromptsSchema.optional(),
- enhancementApiConfigId: z.string().optional(),
- historyPreviewCollapsed: z.boolean().optional(),
- })
- export type GlobalSettings = z.infer<typeof globalSettingsSchema>
- export const GLOBAL_SETTINGS_KEYS = globalSettingsSchema.keyof().options
- /**
- * RooCodeSettings
- */
- export const rooCodeSettingsSchema = providerSettingsSchema.merge(globalSettingsSchema)
- export type RooCodeSettings = GlobalSettings & ProviderSettings
- /**
- * SecretState
- */
- export const SECRET_STATE_KEYS = [
- "apiKey",
- "glamaApiKey",
- "openRouterApiKey",
- "awsAccessKey",
- "awsSecretKey",
- "awsSessionToken",
- "openAiApiKey",
- "geminiApiKey",
- "openAiNativeApiKey",
- "deepSeekApiKey",
- "mistralApiKey",
- "unboundApiKey",
- "requestyApiKey",
- "xaiApiKey",
- "groqApiKey",
- "chutesApiKey",
- "litellmApiKey",
- "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>)
- /**
- * GlobalState
- */
- export type GlobalState = Omit<RooCodeSettings, Keys<SecretState>>
- export const GLOBAL_STATE_KEYS = [...GLOBAL_SETTINGS_KEYS, ...PROVIDER_SETTINGS_KEYS].filter(
- (key: Keys<RooCodeSettings>) => !SECRET_STATE_KEYS.includes(key as Keys<SecretState>),
- ) as Keys<GlobalState>[]
- export const isGlobalStateKey = (key: string): key is Keys<GlobalState> =>
- GLOBAL_STATE_KEYS.includes(key as Keys<GlobalState>)
- /**
- * Evals
- */
- // Default settings when running evals (unless overridden).
- export const EVALS_SETTINGS: RooCodeSettings = {
- apiProvider: "openrouter",
- openRouterUseMiddleOutTransform: false,
- lastShownAnnouncementId: "may-29-2025-3-19",
- pinnedApiConfigs: {},
- autoApprovalEnabled: true,
- alwaysAllowReadOnly: true,
- alwaysAllowReadOnlyOutsideWorkspace: false,
- alwaysAllowWrite: true,
- alwaysAllowWriteOutsideWorkspace: false,
- alwaysAllowWriteProtected: false,
- writeDelayMs: 1000,
- alwaysAllowBrowser: true,
- alwaysApproveResubmit: true,
- requestDelaySeconds: 10,
- alwaysAllowMcp: true,
- alwaysAllowModeSwitch: true,
- alwaysAllowSubtasks: true,
- alwaysAllowExecute: true,
- allowedCommands: ["*"],
- browserToolEnabled: false,
- browserViewportSize: "900x600",
- screenshotQuality: 75,
- remoteBrowserEnabled: false,
- ttsEnabled: false,
- ttsSpeed: 1,
- soundEnabled: false,
- soundVolume: 0.5,
- terminalOutputLineLimit: 500,
- terminalShellIntegrationTimeout: 30000,
- terminalCommandDelay: 0,
- terminalPowershellCounter: false,
- terminalZshOhMy: true,
- terminalZshClearEolMark: true,
- terminalZshP10k: false,
- terminalZdotdir: true,
- terminalCompressProgressBar: true,
- terminalShellIntegrationDisabled: true,
- diffEnabled: true,
- fuzzyMatchThreshold: 1,
- enableCheckpoints: false,
- rateLimitSeconds: 0,
- maxOpenTabsContext: 20,
- maxWorkspaceFiles: 200,
- showRooIgnoredFiles: true,
- maxReadFileLine: -1, // -1 to enable full file reading.
- language: "en",
- telemetrySetting: "enabled",
- mcpEnabled: false,
- mode: "code",
- customModes: [],
- }
- export const EVALS_TIMEOUT = 5 * 60 * 1_000
|