globalState.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import type { SecretKey, GlobalStateKey, ConfigurationKey, ConfigurationValues } from "../exports/roo-code"
  2. export type { SecretKey, GlobalStateKey, ConfigurationKey, ConfigurationValues }
  3. /**
  4. * For convenience we'd like the `RooCodeAPI` to define `SecretKey` and `GlobalStateKey`,
  5. * but since it is a type definition file we can't export constants without some
  6. * annoyances. In order to achieve proper type safety without using constants as
  7. * in the type definition we use this clever Check<>Exhaustiveness pattern.
  8. * If you extend the `SecretKey` or `GlobalStateKey` types, you will need to
  9. * update the `SECRET_KEYS` and `GLOBAL_STATE_KEYS` arrays to include the new
  10. * keys or a type error will be thrown.
  11. */
  12. export const SECRET_KEYS = [
  13. "apiKey",
  14. "glamaApiKey",
  15. "openRouterApiKey",
  16. "awsAccessKey",
  17. "awsSecretKey",
  18. "awsSessionToken",
  19. "openAiApiKey",
  20. "geminiApiKey",
  21. "openAiNativeApiKey",
  22. "deepSeekApiKey",
  23. "mistralApiKey",
  24. "unboundApiKey",
  25. "requestyApiKey",
  26. ] as const
  27. type CheckSecretKeysExhaustiveness = Exclude<SecretKey, (typeof SECRET_KEYS)[number]> extends never ? true : false
  28. const _checkSecretKeysExhaustiveness: CheckSecretKeysExhaustiveness = true
  29. export const GLOBAL_STATE_KEYS = [
  30. "apiProvider",
  31. "apiModelId",
  32. "glamaModelId",
  33. "glamaModelInfo",
  34. "awsRegion",
  35. "awsUseCrossRegionInference",
  36. "awsProfile",
  37. "awsUseProfile",
  38. "awsCustomArn",
  39. "vertexKeyFile",
  40. "vertexJsonCredentials",
  41. "vertexProjectId",
  42. "vertexRegion",
  43. "lastShownAnnouncementId",
  44. "customInstructions",
  45. "alwaysAllowReadOnly",
  46. "alwaysAllowWrite",
  47. "alwaysAllowExecute",
  48. "alwaysAllowBrowser",
  49. "alwaysAllowMcp",
  50. "alwaysAllowModeSwitch",
  51. "alwaysAllowSubtasks",
  52. "taskHistory",
  53. "openAiBaseUrl",
  54. "openAiModelId",
  55. "openAiCustomModelInfo",
  56. "openAiUseAzure",
  57. "ollamaModelId",
  58. "ollamaBaseUrl",
  59. "lmStudioModelId",
  60. "lmStudioBaseUrl",
  61. "anthropicBaseUrl",
  62. "modelMaxThinkingTokens",
  63. "azureApiVersion",
  64. "openAiStreamingEnabled",
  65. "openRouterModelId",
  66. "openRouterModelInfo",
  67. "openRouterBaseUrl",
  68. "openRouterUseMiddleOutTransform",
  69. "allowedCommands",
  70. "soundEnabled",
  71. "soundVolume",
  72. "diffEnabled",
  73. "enableCheckpoints",
  74. "checkpointStorage",
  75. "browserViewportSize",
  76. "screenshotQuality",
  77. "remoteBrowserHost",
  78. "fuzzyMatchThreshold",
  79. "writeDelayMs",
  80. "terminalOutputLineLimit",
  81. "mcpEnabled",
  82. "enableMcpServerCreation",
  83. "alwaysApproveResubmit",
  84. "requestDelaySeconds",
  85. "rateLimitSeconds",
  86. "currentApiConfigName",
  87. "listApiConfigMeta",
  88. "vsCodeLmModelSelector",
  89. "mode",
  90. "modeApiConfigs",
  91. "customModePrompts",
  92. "customSupportPrompts",
  93. "enhancementApiConfigId",
  94. "experiments", // Map of experiment IDs to their enabled state.
  95. "autoApprovalEnabled",
  96. "enableCustomModeCreation", // Enable the ability for Roo to create custom modes.
  97. "customModes", // Array of custom modes.
  98. "unboundModelId",
  99. "requestyModelId",
  100. "requestyModelInfo",
  101. "unboundModelInfo",
  102. "modelTemperature",
  103. "modelMaxTokens",
  104. "mistralCodestralUrl",
  105. "maxOpenTabsContext",
  106. "browserToolEnabled",
  107. "lmStudioSpeculativeDecodingEnabled",
  108. "lmStudioDraftModelId",
  109. "telemetrySetting",
  110. "showRooIgnoredFiles",
  111. "remoteBrowserEnabled",
  112. ] as const
  113. type CheckGlobalStateKeysExhaustiveness =
  114. Exclude<GlobalStateKey, (typeof GLOBAL_STATE_KEYS)[number]> extends never ? true : false
  115. const _checkGlobalStateKeysExhaustiveness: CheckGlobalStateKeysExhaustiveness = true
  116. export const isSecretKey = (key: string): key is SecretKey => SECRET_KEYS.includes(key as SecretKey)
  117. export const isGlobalStateKey = (key: string): key is GlobalStateKey =>
  118. GLOBAL_STATE_KEYS.includes(key as GlobalStateKey)