checkExistApiConfig.ts 813 B

1234567891011121314151617181920212223242526
  1. import { SECRET_STATE_KEYS, ProviderSettings } from "@roo-code/types"
  2. export function checkExistKey(config: ProviderSettings | undefined) {
  3. if (!config) {
  4. return false
  5. }
  6. // Special case for human-relay and fake-ai providers which don't need any configuration.
  7. if (config.apiProvider === "human-relay" || config.apiProvider === "fake-ai") {
  8. return true
  9. }
  10. // Check all secret keys from the centralized SECRET_STATE_KEYS array.
  11. const hasSecretKey = SECRET_STATE_KEYS.some((key) => config[key] !== undefined)
  12. // Check additional non-secret configuration properties
  13. const hasOtherConfig = [
  14. config.awsRegion,
  15. config.vertexProjectId,
  16. config.ollamaModelId,
  17. config.lmStudioModelId,
  18. config.vsCodeLmModelSelector,
  19. ].some((value) => value !== undefined)
  20. return hasSecretKey || hasOtherConfig
  21. }