diff --git a/src/config/io.ts b/src/config/io.ts index 1b6fe79..045000e 100644 --- a/src/config/io.ts +++ b/src/config/io.ts @@ -143,14 +143,13 @@ export function configToEnv(config: LettaBotConfig): Record { } /** - * 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; } } diff --git a/src/main.ts b/src/main.ts index 9c92d55..cf61151 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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()}`);