YAML config takes priority over .env

This commit is contained in:
Sarah Wooders
2026-01-28 23:10:47 -08:00
parent 5e41fac3e0
commit b97b287462
2 changed files with 6 additions and 5 deletions

View File

@@ -143,14 +143,13 @@ export function configToEnv(config: LettaBotConfig): Record<string, string> {
}
/**
* Apply config to process.env
* Apply config to process.env (YAML config takes priority over .env)
*/
export function applyConfigToEnv(config: LettaBotConfig): void {
const env = configToEnv(config);
for (const [key, value] of Object.entries(env)) {
if (!process.env[key]) {
process.env[key] = value;
}
// YAML config always takes priority
process.env[key] = value;
}
}

View File

@@ -5,13 +5,15 @@
* Chat continues seamlessly between Telegram, Slack, and WhatsApp.
*/
// Load .env first for backwards compatibility
import 'dotenv/config';
import { createServer } from 'node:http';
import { existsSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
import { resolve } from 'node:path';
import { spawn } from 'node:child_process';
// Load YAML config and apply to process.env (before other imports)
// Load YAML config and apply to process.env (overrides .env values)
import { loadConfig, applyConfigToEnv, syncProviders, resolveConfigPath } from './config/index.js';
const yamlConfig = loadConfig();
console.log(`[Config] Loaded from ${resolveConfigPath()}`);