openclaw/src/agents/agent-paths.ts

20 lines
651 B
TypeScript
Raw Normal View History

2025-12-23 02:48:48 +01:00
import path from "node:path";
import { resolveConfigDir, resolveUserPath } from "../utils.js";
2025-12-23 02:48:48 +01:00
2026-01-04 14:32:47 +00:00
export function resolveClawdbotAgentDir(): string {
const defaultAgentDir = path.join(resolveConfigDir(), "agent");
2025-12-23 02:48:48 +01:00
const override =
2026-01-04 14:32:47 +00:00
process.env.CLAWDBOT_AGENT_DIR?.trim() ||
2025-12-23 02:48:48 +01:00
process.env.PI_CODING_AGENT_DIR?.trim() ||
defaultAgentDir;
2025-12-23 02:48:48 +01:00
return resolveUserPath(override);
}
2026-01-04 14:32:47 +00:00
export function ensureClawdbotAgentEnv(): string {
const dir = resolveClawdbotAgentDir();
if (!process.env.CLAWDBOT_AGENT_DIR) process.env.CLAWDBOT_AGENT_DIR = dir;
2025-12-23 02:48:48 +01:00
if (!process.env.PI_CODING_AGENT_DIR) process.env.PI_CODING_AGENT_DIR = dir;
return dir;
}