fix: resolve the OpenClaw state dir consistently (md-mirror workspace map, CLI and workspace defaults) - #994
Draft
gorkem2020 wants to merge 1 commit into
Conversation
…LI and workspace defaults - md-mirror workspace map: read the keyed agents.entries form as well as the legacy agents.list array; fall back to OPENCLAW_CONFIG_PATH, then <state dir>/openclaw.json, never another instance's home config - src/openclaw-paths.ts: one resolver for the state dir (OPENCLAW_STATE_DIR, then OPENCLAW_HOME, then ~/.openclaw) and the config path; blank values count as unset - default db, workspace and md-mirror dirs, the CLI --openclaw-home default and OAuth path, and the workspace capability default all resolve through it - tests: openclaw-paths, mdmirror-workspace-map-entries (registered in the test chain and the CI manifest); dist rebuilt
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.
Problem
The plugin assumed a single OpenClaw instance living at
~/.openclaw:resolveAgentWorkspaceMap(md-mirror) only read the legacyagents.listarray. OpenClaw 2026.9 writes the keyedagents.entriesform, so the mirror loggedmdMirror: no agent workspaces foundand wrote every agent's mirror into the default directory.~/.openclaw/openclaw.json. On a host running a second instance (OPENCLAW_STATE_DIRpointing elsewhere) that is another instance's config; the observed effect was the second instance's mirror landing inside the first instance's main-agent workspace.--openclaw-homedefault and OAuth file path, and the workspace capability default were all rooted athomedir()/.openclawregardless ofOPENCLAW_STATE_DIR.Change
src/openclaw-paths.ts: one resolver. State dir =OPENCLAW_STATE_DIR, thenOPENCLAW_HOME, then~/.openclaw; config path =OPENCLAW_CONFIG_PATH, then<state dir>/openclaw.json. Blank or whitespace-only values count as unset.agents.entries(keyed) andagents.list(array), from the runtime config first and from the resolved config file second.Tests
test/openclaw-paths.test.mjs: precedence and blank-variable handling.test/mdmirror-workspace-map-entries.test.mjs: entries form, list form,OPENCLAW_CONFIG_PATHfallback, state-dir fallback, state-dir-rooted and home-rooted defaults.npm testchain and inscripts/ci-test-manifest.mjs(core-regression). Full suite, core-regression, cli-smoke, packaging-and-workflow andverify-package-runtimeare green locally; dist is rebuilt and committed.Verification on a live install
Running as a hotfix on a seven-agent OpenClaw 2026.9.2 install: the startup log went from
mdMirror: no agent workspaces foundtomdMirror: resolved 7 agent workspace(s), and mirror files land in each agent's own workspace.