'use strict'; const os = require('os'); const path = require('path'); const IS_WINDOWS = process.platform === 'win32'; function windowsProgramData() { return process.env.PROGRAMDATA || 'C:\\ProgramData'; } function getConfigDir() { if (process.env.CLAWD_CONFIG_DIR) return process.env.CLAWD_CONFIG_DIR; if (IS_WINDOWS) return path.join(windowsProgramData(), 'OpenClaw', 'clawd'); return process.getuid && process.getuid() === 0 ? '/etc/clawd' : path.join(os.homedir(), '.clawd'); } function getPersistentFile(name) { return path.join(getConfigDir(), name); } function getOpenClawConfigCandidates() { if (IS_WINDOWS) { const candidates = [ path.join(os.homedir(), '.openclaw', 'openclaw.json'), path.join(windowsProgramData(), 'OpenClaw', 'openclaw.json'), path.join(windowsProgramData(), 'OpenClaw', 'config', 'openclaw.json'), ]; if (process.env.OPENCLAW_CONFIG) candidates.unshift(process.env.OPENCLAW_CONFIG); return candidates; } return [ path.join(os.homedir(), '.openclaw', 'openclaw.json'), '/home/sts/.openclaw/openclaw.json', '/root/.openclaw/openclaw.json', ]; } module.exports = { IS_WINDOWS, getConfigDir, getPersistentFile, getOpenClawConfigCandidates, };