This commit is contained in:
Wilkins 2026-01-29 21:53:38 -05:00 committed by GitHub
commit b51bafc098
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 1 deletions

View File

@ -34,4 +34,23 @@ describe("resolveGatewayStateDir", () => {
const env = { CLAWDBOT_STATE_DIR: "C:\\State\\moltbot" }; const env = { CLAWDBOT_STATE_DIR: "C:\\State\\moltbot" };
expect(resolveGatewayStateDir(env)).toBe("C:\\State\\moltbot"); expect(resolveGatewayStateDir(env)).toBe("C:\\State\\moltbot");
}); });
it("uses MOLTBOT_STATE_DIR when provided", () => {
const env = { HOME: "/Users/test", MOLTBOT_STATE_DIR: "/var/lib/moltbot" };
expect(resolveGatewayStateDir(env)).toBe(path.resolve("/var/lib/moltbot"));
});
it("prefers MOLTBOT_STATE_DIR over CLAWDBOT_STATE_DIR", () => {
const env = {
HOME: "/Users/test",
MOLTBOT_STATE_DIR: "/var/lib/moltbot-new",
CLAWDBOT_STATE_DIR: "/var/lib/moltbot-old",
};
expect(resolveGatewayStateDir(env)).toBe(path.resolve("/var/lib/moltbot-new"));
});
it("expands ~ in MOLTBOT_STATE_DIR", () => {
const env = { HOME: "/Users/test", MOLTBOT_STATE_DIR: "~/.moltbot" };
expect(resolveGatewayStateDir(env)).toBe(path.resolve("/Users/test/.moltbot"));
});
}); });

View File

@ -26,7 +26,7 @@ export function resolveUserPathWithHome(input: string, home?: string): string {
} }
export function resolveGatewayStateDir(env: Record<string, string | undefined>): string { export function resolveGatewayStateDir(env: Record<string, string | undefined>): string {
const override = env.CLAWDBOT_STATE_DIR?.trim(); const override = env.MOLTBOT_STATE_DIR?.trim() || env.CLAWDBOT_STATE_DIR?.trim();
if (override) { if (override) {
const home = override.startsWith("~") ? resolveHomeDir(env) : undefined; const home = override.startsWith("~") ? resolveHomeDir(env) : undefined;
return resolveUserPathWithHome(override, home); return resolveUserPathWithHome(override, home);

View File

@ -140,6 +140,7 @@ export function buildServiceEnvironment(params: {
HOME: env.HOME, HOME: env.HOME,
PATH: buildMinimalServicePath({ env }), PATH: buildMinimalServicePath({ env }),
CLAWDBOT_PROFILE: profile, CLAWDBOT_PROFILE: profile,
MOLTBOT_STATE_DIR: env.MOLTBOT_STATE_DIR,
CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR, CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR,
CLAWDBOT_CONFIG_PATH: env.CLAWDBOT_CONFIG_PATH, CLAWDBOT_CONFIG_PATH: env.CLAWDBOT_CONFIG_PATH,
CLAWDBOT_GATEWAY_PORT: String(port), CLAWDBOT_GATEWAY_PORT: String(port),
@ -159,6 +160,7 @@ export function buildNodeServiceEnvironment(params: {
return { return {
HOME: env.HOME, HOME: env.HOME,
PATH: buildMinimalServicePath({ env }), PATH: buildMinimalServicePath({ env }),
MOLTBOT_STATE_DIR: env.MOLTBOT_STATE_DIR,
CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR, CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR,
CLAWDBOT_CONFIG_PATH: env.CLAWDBOT_CONFIG_PATH, CLAWDBOT_CONFIG_PATH: env.CLAWDBOT_CONFIG_PATH,
CLAWDBOT_LAUNCHD_LABEL: resolveNodeLaunchAgentLabel(), CLAWDBOT_LAUNCHD_LABEL: resolveNodeLaunchAgentLabel(),