MCPcopy
hub / github.com/stephengpope/thepopebot / getConfig

Function getConfig

lib/config.js:95–147  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

93 * @returns {string|undefined}
94 */
95export function getConfig(key) {
96 let value;
97
98 // OAuth tokens: multi-token support with LRU rotation
99 if (key === 'CLAUDE_CODE_OAUTH_TOKEN') {
100 return getOAuthTokenCount('claudeCode') > 0 ? getNextOAuthToken('claudeCode') : null;
101 }
102 if (key === 'CODEX_OAUTH_TOKEN') {
103 return getOAuthTokenCount('codex') > 0 ? getNextOAuthToken('codex') : null;
104 }
105
106 // Check if this is a custom provider's API key
107 if (key === 'CUSTOM_API_KEY') {
108 const providerSlug = getConfig('LLM_PROVIDER');
109 if (providerSlug && !BUILTIN_PROVIDERS[providerSlug]) {
110 const custom = getCustomProvider(providerSlug);
111 value = custom?.apiKey || undefined;
112 }
113 }
114 // Try DB (secret or plain config)
115 else if (SECRET_KEYS.has(key)) {
116 value = getConfigSecret(key) || undefined;
117 } else if (CONFIG_KEYS.has(key)) {
118 value = getConfigValue(key) || undefined;
119 }
120
121 // Infrastructure keys: fall back to .env (these live in .env, not exclusively in DB)
122 if (value === undefined) {
123 const ENV_KEYS = [
124 'GH_OWNER',
125 'GH_REPO',
126 'GH_TOKEN',
127 'APP_URL',
128 'APP_HOSTNAME',
129 ];
130 if (ENV_KEYS.includes(key)) {
131 value = process.env[key];
132 }
133 }
134
135 // Fall back to defaults
136 if (value === undefined && key in DEFAULTS) {
137 value = DEFAULTS[key];
138 }
139
140 // Special default: LLM_MODEL depends on LLM_PROVIDER
141 if (value === undefined && key === 'LLM_MODEL') {
142 const provider = getConfig('LLM_PROVIDER');
143 value = getDefaultModel(provider);
144 }
145
146 return value;
147}

Callers 15

getTokenFunction · 0.90
isAssemblyAIEnabledFunction · 0.90
transcribeAudioFunction · 0.90
runInteractiveContainerFunction · 0.90
buildAgentAuthEnvFunction · 0.90
runHeadlessContainerFunction · 0.90
runCommandContainerFunction · 0.90
runAgentJobContainerFunction · 0.90
githubApiFunction · 0.90
triggerWorkflowDispatchFunction · 0.90
fetchAgentJobLogFunction · 0.90

Calls 6

getOAuthTokenCountFunction · 0.90
getNextOAuthTokenFunction · 0.90
getCustomProviderFunction · 0.90
getConfigSecretFunction · 0.90
getConfigValueFunction · 0.90
getDefaultModelFunction · 0.90

Tested by

no test coverage detected