Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(cli_agent): IDE lockfile dir derives from MACHINA_CLAUDE_DIR
trohitgae1cf7f6a432
diff --git a/server/config/ai_cli_providers.json b/server/config/ai_cli_providers.jsonindex 7763f8b9..78b391f1 100644--- a/server/config/ai_cli_providers.json+++ b/server/config/ai_cli_providers.json@@ -5,7 +5,6 @@"login_argv": ["claude", "login"],"auth_status_argv": ["claude", "--print", "-p", "ok"],"ide_lock_env_var": "CLAUDE_IDE_LOCK",- "ide_lockfile_dir": "~/.claude/ide","default_model": "claude-sonnet-4-6","default_max_turns": 10,"default_max_budget_usd": 5.0,diff --git a/server/main.py b/server/main.pyindex abac1386..f8c67974 100644--- a/server/main.py+++ b/server/main.py@@ -511,12 +511,22 @@ except Exception as exc: # pragma: no cover — defensive; MCP must not block s@app.on_event("startup")async def _sweep_cli_lockfiles_on_startup() -> None:try:- from services.cli_agent.config import list_provider_names, get_provider_config+ from services.cli_agent.config import list_provider_names+ from services.cli_agent.factory import create_cli_providerfrom services.cli_agent.lockfile import sweep_stale_lockfiles+ # Ask the provider class for its lockfile dir rather than the+ # raw JSON config — the provider is the source of truth (e.g.+ # the claude provider derives its dir from+ # ``MACHINA_CLAUDE_DIR/ide`` so it stays in sync with the+ # ``CLAUDE_CONFIG_DIR`` env var we set on spawn). Reading from+ # the config dict would miss provider-class-computed paths.for name in list_provider_names():- cfg = get_provider_config(name)- if cfg and cfg.ide_lockfile_dir:- sweep_stale_lockfiles(cfg.ide_lockfile_dir)+ try:+ provider = create_cli_provider(name)+ except Exception:+ continue+ if provider.ide_lockfile_dir:+ sweep_stale_lockfiles(provider.ide_lockfile_dir)except Exception as exc:logger.debug("[main] CLI lockfile sweep failed: %s", exc)diff --git a/server/services/cli_agent/protocol.py b/server/services/cli_agent/protocol.pyindex e666861d..c4b643db 100644--- a/server/services/cli_agent/protocol.py+++ b/server/services/cli_agent/protocol.py@@ -97,7 +97,7 @@ class AICliProvider(Protocol):package_name: str # npm packagebinary_name: str # "claude" | "codex" | "gemini"ide_lock_env_var: Optional[str] # CLAUDE_IDE_LOCK | GEMINI_IDE_LOCK | None- ide_lockfile_dir: Optional[Path] # ~/.claude/ide | <tmpdir>/gemini/ide+ ide_lockfile_dir: Optional[Path] # <MACHINA_CLAUDE_DIR>/ide | <tmpdir>/gemini/ide# ---- spawn surface ---------------------------------------------------diff --git a/server/services/cli_agent/providers/anthropic_claude.py b/server/services/cli_agent/providers/anthropic_claude.pyindex 47ef07bf..bb0ddc54 100644--- a/server/services/cli_agent/providers/anthropic_claude.py+++ b/server/services/cli_agent/providers/anthropic_claude.py@@ -83,7 +83,18 @@ class AnthropicClaudeProvider:self.package_name = cfg.package_nameself.binary_name = cfg.binary_nameself.ide_lock_env_var = cfg.ide_lock_env_var- self.ide_lockfile_dir = cfg.ide_lockfile_dir+ # IDE lockfile lives at ``<CLAUDE_CONFIG_DIR>/ide/<pid>.lock``+ # per claude's own resolution rules — there is no separate+ # "lockfile path" knob. We set+ # ``CLAUDE_CONFIG_DIR=MACHINA_CLAUDE_DIR`` on every spawn (see+ # ``service.py``, ``session.py``, ``claude_oauth.py``), so the+ # canonical lockfile dir is unambiguously+ # ``MACHINA_CLAUDE_DIR/ide``. Deriving it directly from the+ # single source of truth keeps the lockfile-write side (here)+ # in sync with the lockfile-read side (spawned claude) without+ # a duplicated JSON path that can drift.+ from services.claude_oauth import MACHINA_CLAUDE_DIR+ self.ide_lockfile_dir = MACHINA_CLAUDE_DIR / "ide"self._defaults = cfg.defaultsself._supports = cfg.supportsself._login_argv = cfg.login_argv