fix: route all four hardcoded ~/.openclaw paths through OPENCLAW_STATE_DIR#354
Merged
Conversation
…E_DIR - Add resolveOpenclawStateDir(env) helper to src/db/config.ts - Add largeFilesDir to LcmConfig and resolveLcmConfig (env: LCM_LARGE_FILES_DIR) - Fix engine.ts storeLargeFileContent to use this.config.largeFilesDir - Add stateDir to PluginEnvSnapshot in plugin/index.ts - Fix resolveAuthStorePaths to use stateDir instead of hardcoded ~/.openclaw - Fix resolveSecretRef to use stateDir instead of hardcoded ~/.openclaw - Add startup banner log line emitting the resolved state dir - Add 12 new tests for resolveOpenclawStateDir and largeFilesDir - Update openclaw.plugin.json with largeFilesDir schema - Update docs/configuration.md and skills reference with OPENCLAW_STATE_DIR docs Agent-Logs-Url: https://github.com/Martian-Engineering/lossless-claw/sessions/36f08751-1270-4614-8f71-4ce2e3d0c1a5 Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix hardcoded ~/.openclaw paths to respect OPENCLAW_STATE_DIR
fix: route all four hardcoded ~/.openclaw paths through OPENCLAW_STATE_DIR
Apr 10, 2026
Collaborator
|
Reviewed locally against current What I verified:
The only diff noise I saw was the expected package version bump in |
Update state-dir-sensitive database examples in the configuration docs, align manifest database path help text with the OPENCLAW_STATE_DIR default, and add a patch changeset for the multi-profile path isolation fix. Regeneration-Prompt: | Address the review follow-ups on PR 354 without changing the runtime fix itself. Keep the new OPENCLAW_STATE_DIR behavior intact, but make the operator-facing docs and manifest help text consistently describe the state-dir-aware database default, including examples that work for both default and non-default profiles. Because this is a user-visible multi-profile bug fix, add the appropriate patch changeset before pushing back to the PR branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four call sites in
engine.tsandplugin/index.tshardcoded~/.openclaw/…viahomedir(), bypassingOPENCLAW_STATE_DIR. On multi-profile hosts this causes the non-default gateway to open file handles on the default profile'slcm.db, write large-file payloads into the wrong state dir, and silently resolve auth/secrets from the wrong profile.Changes
src/db/config.ts— new helper + new config fieldresolveOpenclawStateDir(env): returnsenv.OPENCLAW_STATE_DIR ?? join(homedir(), ".openclaw")largeFilesDir: stringtoLcmConfig, resolved asLCM_LARGE_FILES_DIR ?? pc.largeFilesDir ?? join(stateDir, "lcm-files")databasePathfallback now usesresolveOpenclawStateDir(env)instead of barehomedir()src/engine.ts— large-file storage (worst offender)storeLargeFileContentnow writes tothis.config.largeFilesDirinstead of the hardcodedjoin(homedir(), ".openclaw", "lcm-files", …)src/plugin/index.ts— auth & secretsPluginEnvSnapshotgainsstateDir(populated viaresolveOpenclawStateDir)resolveAuthStorePaths: candidate path usesstateDirinstead ofjoin(home, ".openclaw", "agents/main/agent/auth-profiles.json")resolveSecretRef: legacysecrets.jsonpath usesstateDirinstead ofjoin(home, ".openclaw", "secrets.json")[lcm] State dir: …), making profile mismatches immediately visible in logsTests & docs
resolveOpenclawStateDirprecedence andlargeFilesDirresolutionopenclaw.plugin.jsonschema,docs/configuration.md, andskills/lossless-claw/references/config.mdupdated withOPENCLAW_STATE_DIR,largeFilesDir, andLCM_LARGE_FILES_DIR