fix: use STATE_DIR instead of hardcoded ~/.openclaw for identity and canvas (#4824)

* fix: use STATE_DIR instead of hardcoded ~/.openclaw for identity and canvas

device-identity.ts and canvas-host/server.ts used hardcoded
path.join(os.homedir(), '.openclaw', ...) ignoring OPENCLAW_STATE_DIR
env var and the resolveStateDir() logic from config/paths.ts.

This caused ~/.openclaw/identity and ~/.openclaw/canvas directories
to be created even when state dir was overridden or resided elsewhere.

* fix: format and remove duplicate imports

* fix: scope state-dir patch + add regression tests (#4824) (thanks @kossoy)

* fix: align state-dir fallbacks in hooks and agent paths (#4824) (thanks @kossoy)

---------

Co-authored-by: Gustavo Madeira Santana <gumadeiras@gmail.com>
This commit is contained in:
Oleg Kossoy
2026-02-08 05:16:59 +02:00
committed by GitHub
parent 0499656c59
commit ebe5730401
13 changed files with 140 additions and 16 deletions

View File

@@ -178,7 +178,8 @@ export function resolveAgentWorkspaceDir(cfg: OpenClawConfig, agentId: string) {
}
return DEFAULT_AGENT_WORKSPACE_DIR;
}
return path.join(os.homedir(), ".openclaw", `workspace-${id}`);
const stateDir = resolveStateDir(process.env, os.homedir);
return path.join(stateDir, `workspace-${id}`);
}
export function resolveAgentDir(cfg: OpenClawConfig, agentId: string) {