const path = require('path'); /** * 聊天日志 JSON 路径:环境变量 CHAT_LOG_PATH(绝对路径或相对项目根),未设置则为 /chat_logs.json */ function resolveChatLogPath(rootDir) { const raw = process.env.CHAT_LOG_PATH; if (raw == null || !String(raw).trim()) { return path.join(rootDir, 'chat_logs.json'); } const p = String(raw).trim(); return path.isAbsolute(p) ? p : path.join(rootDir, p); } module.exports = { resolveChatLogPath };