From b97b28746271f42b9e0a64a4978f8701be6ecb11 Mon Sep 17 00:00:00 2001 From: Sarah Wooders Date: Wed, 28 Jan 2026 23:10:47 -0800 Subject: [PATCH] YAML config takes priority over .env --- src/config/io.ts | 7 +++---- src/main.ts | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) 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()}`);