(explicitApiKey: string | undefined)
| 8 | export type CliSettings = Z.infer<typeof SettingsSchema>; |
| 9 | |
| 10 | export function getSettings(explicitApiKey: string | undefined): CliSettings { |
| 11 | const env = _loadEnv(); |
| 12 | const systemFile = _loadSystemFile(); |
| 13 | const defaults = _loadDefaults(); |
| 14 | |
| 15 | _legacyEnvVarWarning(); |
| 16 | |
| 17 | _envVarsInfo(); |
| 18 | |
| 19 | return { |
| 20 | auth: { |
| 21 | apiKey: |
| 22 | explicitApiKey || |
| 23 | env.LINGO_API_KEY || |
| 24 | env.LINGODOTDEV_API_KEY || |
| 25 | systemFile.auth?.apiKey || |
| 26 | systemFile.auth?.vnext?.apiKey || |
| 27 | defaults.auth.apiKey, |
| 28 | apiUrl: |
| 29 | env.LINGO_API_URL || |
| 30 | env.LINGODOTDEV_API_URL || |
| 31 | systemFile.auth?.apiUrl || |
| 32 | defaults.auth.apiUrl, |
| 33 | webUrl: |
| 34 | env.LINGODOTDEV_WEB_URL || |
| 35 | systemFile.auth?.webUrl || |
| 36 | defaults.auth.webUrl, |
| 37 | }, |
| 38 | llm: { |
| 39 | openaiApiKey: env.OPENAI_API_KEY || systemFile.llm?.openaiApiKey, |
| 40 | anthropicApiKey: env.ANTHROPIC_API_KEY || systemFile.llm?.anthropicApiKey, |
| 41 | groqApiKey: env.GROQ_API_KEY || systemFile.llm?.groqApiKey, |
| 42 | googleApiKey: env.GOOGLE_API_KEY || systemFile.llm?.googleApiKey, |
| 43 | openrouterApiKey: |
| 44 | env.OPENROUTER_API_KEY || systemFile.llm?.openrouterApiKey, |
| 45 | mistralApiKey: env.MISTRAL_API_KEY || systemFile.llm?.mistralApiKey, |
| 46 | }, |
| 47 | }; |
| 48 | } |
| 49 | |
| 50 | export function saveSettings(settings: CliSettings): void { |
| 51 | _saveSystemFile(settings); |
no test coverage detected