Skip to content

Self-improving AI Employees for everyone

refactor(cli_agent): Phase 1 — move claude provider + oauth into plugin folder

trohitgad8f3ea60b30
diff --git a/server/nodes/agent/claude_code_agent/__init__.py b/server/nodes/agent/claude_code_agent/__init__.py
index 1d12490c..66b7658c 100644
--- a/server/nodes/agent/claude_code_agent/__init__.py
+++ b/server/nodes/agent/claude_code_agent/__init__.py
@@ -37,6 +37,19 @@ logger = get_logger(__name__)
from services.cli_agent import ClaudeTaskSpec # noqa: E402
from services.cli_agent.types import SessionResultModel # noqa: E402
+# --- Self-registration -----------------------------------------------------
+#
+# Per the canonical plugin-folder pattern (see
+# ``docs-internal/plugin_system.md`` § "Self-contained plugin folders"),
+# the plugin folder owns its provider class + auth helpers + session
+# pool + skill materialiser. The generic framework
+# (``services/cli_agent/``) doesn't import from us — it asks the
+# ``register_provider`` registry for the provider class by name.
+from services.cli_agent.factory import register_provider # noqa: E402
+from ._provider import AnthropicClaudeProvider # noqa: E402
+
+register_provider("claude", AnthropicClaudeProvider)
+
# Claude Code-supported models. Per
# https://code.claude.com/docs/en/cli-reference the ``--model`` flag
diff --git a/server/services/claude_oauth.py b/server/nodes/agent/claude_code_agent/_oauth.py
similarity index 88%
rename from server/services/claude_oauth.py
rename to server/nodes/agent/claude_code_agent/_oauth.py
index 882a4374..57713a7c 100644
--- a/server/services/claude_oauth.py
+++ b/server/nodes/agent/claude_code_agent/_oauth.py
@@ -18,6 +18,13 @@ The CLI owns its own credentials file; we never read or write it.
``login`` is a long-running one-shot (waits for the browser flow to
complete) so callers schedule it as ``asyncio.create_task`` — same shape
Stripe uses for ``stripe login --complete``.
+
+This module lives alongside the ``claude_code_agent`` plugin so all
+claude-specific code stays in one folder per the canonical plugin
+pattern. The single source of truth for ``MACHINA_CLAUDE_DIR`` lives
+here; consumers in ``services/cli_agent/`` (the generic framework)
+and the plugin's other modules (``_provider``, ``_pool``, ``_skills``)
+import it from this module.
"""
from __future__ import annotations
@@ -35,8 +42,9 @@ from services.events.cli import run_cli_command
logger = get_logger(__name__)
-# server/services/claude_oauth.py -> parents[2] is the repo root.
-_PROJECT_ROOT = Path(__file__).resolve().parents[2]
+# This file: server/nodes/agent/claude_code_agent/_oauth.py
+# parents[4] is the repo root.
+_PROJECT_ROOT = Path(__file__).resolve().parents[4]
MACHINA_CLAUDE_DIR = (_PROJECT_ROOT / "data" / "claude-machina").resolve()
MACHINA_NPM_DIR = MACHINA_CLAUDE_DIR / "npm"
@@ -50,10 +58,10 @@ ONESHOT_TIMEOUT_SECONDS = 30.0
def claude_binary_path() -> str:
"""Return path to the project-local claude CLI, installing on miss.
- Single source of truth shared by the auth handler
- (``services/cli_agent/_handlers.py``) AND the agent spawn
- (``services/cli_agent/providers/anthropic_claude.py``) so both surfaces
- use the same binary + ``CLAUDE_CONFIG_DIR``-isolated credentials."""
+ Single source of truth shared by the auth handler (``_handlers.py``)
+ AND the agent spawn (``_provider.py``) so both surfaces use the
+ same binary + ``CLAUDE_CONFIG_DIR``-isolated credentials.
+ """
if sys.platform == "win32":
bin_path = MACHINA_NPM_DIR / "node_modules" / ".bin" / "claude.cmd"
else:
diff --git a/server/services/cli_agent/providers/anthropic_claude.py b/server/nodes/agent/claude_code_agent/_provider.py
similarity index 98%
rename from server/services/cli_agent/providers/anthropic_claude.py
rename to server/nodes/agent/claude_code_agent/_provider.py
index bb0ddc54..eb23aabd 100644
--- a/server/services/cli_agent/providers/anthropic_claude.py
+++ b/server/nodes/agent/claude_code_agent/_provider.py
@@ -40,7 +40,7 @@ on-disk JSONL gives us the same data without `-p`):
external monitors (Phase 2).
Binary + auth: shared with the auth surface via
-``services.claude_oauth.claude_binary_path()`` — single project-local
+``._oauth.claude_binary_path()`` — single project-local
install at ``<repo>/data/claude-machina/npm/`` and ``CLAUDE_CONFIG_DIR``
set on the spawn env so the agent picks up the same credentials the
Login button wrote.
@@ -60,8 +60,8 @@ from typing import Any, Dict, List, Optional
from core.logging import get_logger
-from services.claude_oauth import claude_binary_path
from services.cli_agent.config import get_provider_config
+from ._oauth import claude_binary_path, MACHINA_CLAUDE_DIR
from services.cli_agent.protocol import CanonicalUsage
from services.cli_agent.types import ClaudeTaskSpec
@@ -92,8 +92,9 @@ class AnthropicClaudeProvider:
# ``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
+ # a duplicated JSON path that can drift. ``MACHINA_CLAUDE_DIR``
+ # is imported at module top from ``_oauth`` (the canonical
+ # source of truth for this plugin's filesystem layout).
self.ide_lockfile_dir = MACHINA_CLAUDE_DIR / "ide"
self._defaults = cfg.defaults
self._supports = cfg.supports
@@ -105,7 +106,7 @@ class AnthropicClaudeProvider:
def binary_path(self) -> Path:
"""Resolve the project-local `claude` binary.
- Delegates to ``services.claude_oauth.claude_binary_path`` — same
+ Delegates to ``._oauth.claude_binary_path`` — same
path used by the credentials Login button. Lazy-installs into
``<repo>/data/claude-machina/npm/`` on first miss. Raises
``FileNotFoundError`` if ``npm`` isn't on PATH.
diff --git a/server/scripts/smoke_test_skills.py b/server/scripts/smoke_test_skills.py
new file mode 100644
index 00000000..0774204c
--- /dev/null
+++ b/server/scripts/smoke_test_skills.py
@@ -0,0 +1,175 @@
+"""Smoke test: verify claude code agent can see and invoke materialised
+skills from a per-workflow workspace.
+
+Spawns one cold-spawn claude subprocess via the pool, with one skill
+wired (``humanify-skill``). Asserts:
+
+ 1. The materialised SKILL.md exists at the expected path.
+ 2. ``Skill`` enters ``--allowedTools`` argv (paired with the wiring).
+ 3. The spawn succeeds (process opens stdin pipe, emits ``system/init``).
+ 4. Claude completes a turn that *uses* the skill (via slash command
+ ``/humanify-skill`` so we don't have to rely on autodiscovery).
+ 5. The session's ``result`` event lands and the response is non-empty.
+
+Run from ``server/``:
+ .venv/Scripts/python.exe scripts/smoke_test_skills.py
+
+Requires:
+ - Claude binary at ``data/claude-machina/npm/...`` (lazy-installed
+ by ``nodes.agent.claude_code_agent._oauth.claude_binary_path``).
+ - Claude auth (``data/claude-machina/`` is the project-local
+ CLAUDE_CONFIG_DIR; user must have logged in once).
+ - No active workflow consuming pool slot ``smoke-test-memory``.
+
+The test isolates itself: temp workspace dir, temp memory_node_id.
+On exit, terminates the pool entry it spawned.
+"""
+
+from __future__ import annotations
+
+import asyncio
+import os
+import sys
+import tempfile
+from pathlib import Path
+
+
+async def main() -> int:
+ # Make sure we're running from the server dir so `services.*` imports work.
+ server_dir = Path(__file__).resolve().parent.parent
+ sys.path.insert(0, str(server_dir))
+
+ from services.cli_agent._skills import materialise_skills
+ from services.cli_agent.session_pool import get_session_pool
+ from services.cli_agent.types import ClaudeTaskSpec
+ from nodes.agent.claude_code_agent._oauth import MACHINA_CLAUDE_DIR
+
+ repo_root = server_dir.parent
+ memory_node_id = "smoke-test-memory"
+ workflow_id = "smoke-test-wf"
+ skill_under_test = "humanify-skill"
+
+ with tempfile.TemporaryDirectory(prefix="machina_skills_smoke_") as tmp:
+ workspace = Path(tmp).resolve()
+ print(f"[smoke] workspace = {workspace}")
+ print(f"[smoke] repo_root = {repo_root}")
+
+ # Step 1 — materialise the skill into the workspace.
+ added, removed = await materialise_skills(
+ workspace, [skill_under_test],
+ previous_skill_names=None,
+ log_label="smoke",
+ )
+ skill_md = workspace / ".claude" / "skills" / skill_under_test / "SKILL.md"
+ assert added == 1 and removed == 0, f"materialise_skills returned ({added}, {removed})"
+ assert skill_md.exists(), f"SKILL.md not at {skill_md}"
+ print(f"[smoke] step 1 PASS — SKILL.md at {skill_md} ({skill_md.stat().st_size} bytes)")
+
+ # Step 2 — build argv and check Skill is in --allowedTools.
+ from services.cli_agent.factory import create_cli_provider
+ provider = create_cli_provider("claude")
+ spec = ClaudeTaskSpec(
+ prompt="Use the humanify-skill to format this list nicely: apples, bananas, cherries.",
+ add_dir=[str(workspace)],
+ timeout_seconds=60,
+ )
+ argv = provider.interactive_argv(
+ spec,
+ defaults={},
+ mcp_endpoint_url=None,
+ mcp_bearer_token=None,
+ connected_tool_names=[],
+ connected_skill_names=[skill_under_test],
+ include_prompt=False,
+ )
+ allowed_idx = argv.index("--allowedTools")
+ allowed = argv[allowed_idx + 1].split(",")
+ assert "Skill" in allowed, f"Skill missing from allowlist: {allowed}"
+ assert f"--add-dir" in argv and str(workspace) in argv, (
+ f"workspace not in --add-dir argv: {argv}"
+ )
+ print(f"[smoke] step 2 PASS — argv has Skill in allowlist + --add-dir {workspace.name}")
+
+ # Step 3 — spawn via the pool (cold spawn). Pool uses
+ # `cwd=repo_root` for memory-bound runs.
+ pool = get_session_pool()
+ env = {**os.environ, "PYTHONUNBUFFERED": "1"}
+ env["CLAUDE_CONFIG_DIR"] = str(MACHINA_CLAUDE_DIR)
+ env["MACHINA_PARENT_RUN_ID"] = f"{workflow_id}:{memory_node_id}:smoke"
+
+ # Make sure no stale pool entry. Idempotent.
+ await pool.terminate(memory_node_id)
+
+ try:
+ pooled = await pool.acquire(
+ memory_node_id,
+ spec=spec,
+ cwd=repo_root,
+ env=env,
+ defaults={},
+ mcp_endpoint_url=None,
+ mcp_bearer_token=None,
+ connected_tool_names=[],
+ connected_skill_names=[skill_under_test],
+ workspace_dir=workspace,
+ workflow_id=workflow_id,
+ )
+ print(f"[smoke] step 3 PASS — claude pid={pooled.process.pid}, "
+ f"workspace_dir bound, materialised_skills="
+ f"{set(pooled.materialised_skills)}")
+ assert skill_under_test in pooled.materialised_skills
+
+ # Step 4 — send a turn that should activate the skill.
+ # Using the /humanify-skill slash command bypasses LLM
+ # autodiscovery — the failure mode is much clearer if
+ # the skill isn't loadable.
+ print("[smoke] step 4 — sending turn (this calls the model)...")
+ result = await pool.send_turn(
+ pooled,
+ "/humanify-skill Briefly describe the number 42 in plain language.",
+ timeout_seconds=120,
+ workflow_id=workflow_id,
+ )
+ assert result.success, f"turn failed: {result.error}"
+ print(f"[smoke] step 4 PASS — session_id={result.session_id}, "
+ f"cost=${result.cost_usd}, num_turns={result.num_turns}, "
+ f"duration_ms={result.duration_ms}")
+ print(f"[smoke] response (first 400 chars):")
+ print(f" {result.response[:400]!r}")
+
+ # Step 5 — inspect the events for evidence of skill use.
+ # We look for: (a) the response is non-empty, (b) the
+ # session emitted assistant content that follows the skill's
+ # humanify guidance (plain language, no raw markdown). The
+ # weaker but more reliable signal is just "response was
+ # generated and the slash command didn't error."
+ assert result.response.strip(), "response was empty"
+ # If claude couldn't find the skill, it usually returns
+ # something like "I don't have access to humanify-skill"
+ # or an error event. Check for those markers.
+ error_markers = [
+ "skill not found",
+ "no such skill",
+ "i don't have a skill",
+ "unable to find the skill",
+ "unknown skill",
+ ]
+ response_lc = result.response.lower()
+ for marker in error_markers:
+ assert marker not in response_lc, (
+ f"response indicates skill not loaded: matched marker {marker!r}\n"
+ f"full response: {result.response[:1000]!r}"
+ )
+ print("[smoke] step 5 PASS — response present, no 'skill not found' markers")
+
+ finally:
+ await pool.terminate(memory_node_id)
+ print("[smoke] cleanup — pool entry terminated")
+
+ print()
+ print("[smoke] ===== ALL CHECKS PASSED =====")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(asyncio.run(main()))
diff --git a/server/services/cli_agent/__init__.py b/server/services/cli_agent/__init__.py
index b97df816..fd1be9fb 100644
--- a/server/services/cli_agent/__init__.py
+++ b/server/services/cli_agent/__init__.py
@@ -23,10 +23,10 @@ import logging as _logging
_logging.getLogger("services.cli_agent").setLevel(_logging.INFO)
from services.cli_agent.factory import (
- ALL_PROVIDERS,
- SUPPORTED_PROVIDERS,
create_cli_provider,
is_supported,
+ register_provider,
+ registered_provider_names,
)
from services.cli_agent.protocol import (
AICliProvider,
@@ -47,18 +47,41 @@ from services.cli_agent.types import (
)
# --- self-registration on import -------------------------------------------
+#
+# Framework-side: register codex (still lives under
+# ``services/cli_agent/providers/`` because the codex_agent plugin hasn't
+# been migrated to the plugin-folder layout yet — separate scope). Claude
+# is registered by its plugin folder
+# (``nodes/agent/claude_code_agent/__init__.py``), which imports + calls
+# ``register_provider("claude", AnthropicClaudeProvider)`` on its own
+# module load. We don't import the plugin here; it imports us.
from services.ws_handler_registry import register_ws_handlers
from services.cli_agent._handlers import WS_HANDLERS
register_ws_handlers(WS_HANDLERS)
+def _register_builtin_providers() -> None:
+ """Bind providers that still live under ``services/cli_agent/providers/``.
+
+ Plugins that have been migrated to the per-folder layout
+ (e.g. ``claude_code_agent``) self-register from their own
+ ``__init__.py``. This function only covers the ones that haven't
+ moved yet.
+ """
+ from services.cli_agent.providers.openai_codex import OpenAICodexProvider
+ register_provider("codex", OpenAICodexProvider)
+
+
+_register_builtin_providers()
+
+
__all__ = [
# Factory
"create_cli_provider",
"is_supported",
- "SUPPORTED_PROVIDERS",
- "ALL_PROVIDERS",
+ "register_provider",
+ "registered_provider_names",
# Protocol + dataclasses
"AICliProvider",
"CanonicalUsage",
diff --git a/server/services/cli_agent/_handlers.py b/server/services/cli_agent/_handlers.py
index 352cd0b2..618fd64e 100644
--- a/server/services/cli_agent/_handlers.py
+++ b/server/services/cli_agent/_handlers.py
@@ -93,7 +93,7 @@ async def _broadcast_credential_event(event_type: str, provider: str) -> None:
async def _finalize_claude_login() -> None:
"""Run ``claude auth login`` to completion, then store user info +
broadcast on success."""
- from services.claude_oauth import claude_auth_status_info, run_claude_login
+ from nodes.agent.claude_code_agent._oauth import claude_auth_status_info, run_claude_login
try:
envelope = await run_claude_login()
@@ -137,7 +137,7 @@ async def handle_claude_code_login(
"""Spawn ``claude auth login`` in the background; let the CLI open
the user's browser. Idempotent re-click syncs the marker without
re-running the flow."""
- from services.claude_oauth import claude_auth_status_info
+ from nodes.agent.claude_code_agent._oauth import claude_auth_status_info
info = await claude_auth_status_info()
if info.get("loggedIn"):
@@ -174,7 +174,7 @@ async def handle_claude_code_logout(
) -> Dict[str, Any]:
"""Run ``claude auth logout`` (CLI clears its own credentials), drop
the catalogue marker, broadcast ``.disconnected``."""
- from services.claude_oauth import claude_auth_logout
+ from nodes.agent.claude_code_agent._oauth import claude_auth_logout
try:
await claude_auth_logout()
diff --git a/server/services/cli_agent/factory.py b/server/services/cli_agent/factory.py
index ab5a3b1a..7222d582 100644
--- a/server/services/cli_agent/factory.py
+++ b/server/services/cli_agent/factory.py
@@ -1,12 +1,30 @@
-"""Factory for `AICliProvider` instances.
+"""Registry + factory for `AICliProvider` instances.
-Mirrors `services/llm/factory.py`: lazy imports keep optional providers
-from being loaded until first use. v1 ships Claude + Codex; calling
-`create_cli_provider("gemini")` raises `NotImplementedError` (v2).
+Plugins call :func:`register_provider` from their package
+``__init__.py`` so the framework can build an instance by provider
+name without importing from the plugin folder directly (which would
+be a ``services → nodes`` layering violation — forbidden by the
+plugin-folder pattern in
+[docs-internal/plugin_system.md](../../../../docs-internal/plugin_system.md)).
+
+The pattern matches the six existing per-plugin registries
+(``ws_handler_registry``, ``register_router``, etc.) — see
+:func:`services.ws_handler_registry.register_ws_handlers` for the
+template. Provider registration is idempotent: a second
+``register_provider("claude", AnthropicClaudeProvider)`` is a no-op
+when the binding already matches; mismatching bindings raise.
+
+Usage from a plugin's ``__init__.py``::
+
+ from services.cli_agent.factory import register_provider
+ from ._provider import AnthropicClaudeProvider
+ register_provider("claude", AnthropicClaudeProvider)
"""
from __future__ import annotations
+from typing import Callable, Dict, Type, Union
+
from core.logging import get_logger
from services.cli_agent.protocol import AICliProvider
@@ -14,35 +32,73 @@ from services.cli_agent.protocol import AICliProvider
logger = get_logger(__name__)
-SUPPORTED_PROVIDERS = frozenset({"claude", "codex"}) # v2 adds "gemini"
-ALL_PROVIDERS = frozenset({"claude", "codex", "gemini"}) # union of v1+v2 names
+# Bindings populated by plugin folders on import. ``Union[Type, Callable]``
+# because some plugins may want a zero-arg factory function instead of a
+# class — both shapes are valid as long as calling them returns an
+# ``AICliProvider``-conformant instance.
+_PROVIDER_REGISTRY: Dict[str, Union[Type[AICliProvider], Callable[[], AICliProvider]]] = {}
+
+
+def register_provider(
+ name: str,
+ provider_factory: Union[Type[AICliProvider], Callable[[], AICliProvider]],
+) -> None:
+ """Bind a provider name to its class / factory.
+
+ Called from the plugin folder's ``__init__.py`` on import. Idempotent
+ when the binding is unchanged; raises ``ValueError`` on conflict so
+ accidental double-registration with different classes is caught
+ instead of silently shadowing.
+ """
+ existing = _PROVIDER_REGISTRY.get(name)
+ if existing is not None and existing is not provider_factory:
+ raise ValueError(
+ f"CLI provider {name!r} already registered with {existing!r}; "
+ f"refusing to overwrite with {provider_factory!r}"
+ )
+ _PROVIDER_REGISTRY[name] = provider_factory
+ logger.debug("[cli_agent] registered provider %r -> %r", name, provider_factory)
+
+
+def unregister_provider(name: str) -> None:
+ """Drop a provider binding. Used by tests."""
+ _PROVIDER_REGISTRY.pop(name, None)
def create_cli_provider(name: str) -> AICliProvider:
"""Build a CLI provider by name.
Raises:
- NotImplementedError: for `gemini` until the v2 implementation lands.
+ NotImplementedError: for declared-but-deferred providers
+ (currently ``gemini``).
ValueError: for unknown names.
"""
- if name == "claude":
- from services.cli_agent.providers.anthropic_claude import AnthropicClaudeProvider
- return AnthropicClaudeProvider()
-
- if name == "codex":
- from services.cli_agent.providers.openai_codex import OpenAICodexProvider
- return OpenAICodexProvider()
+ factory = _PROVIDER_REGISTRY.get(name)
+ if factory is not None:
+ return factory()
+ # ``gemini`` is intentionally listed as a known-but-unsupported name
+ # so the frontend dropdown can show it greyed-out while the v2
+ # implementation is in flight. Surface a clean ``NotImplementedError``
+ # so factory consumers can detect the deferred state.
if name == "gemini":
- # v2 stub — surface a clean error so factory consumers can detect
- # the deferred state and offer the user an actionable hint.
raise NotImplementedError(
"gemini provider deferred to v2. Use 'claude' or 'codex' in v1."
)
- raise ValueError(f"Unknown CLI provider: {name!r}. Known: {sorted(ALL_PROVIDERS)}")
+ registered = sorted(_PROVIDER_REGISTRY.keys())
+ raise ValueError(
+ f"Unknown CLI provider: {name!r}. "
+ f"Registered: {registered}. "
+ f"Did the plugin's ``__init__.py`` call register_provider()?"
+ )
def is_supported(name: str) -> bool:
- """True if the provider is fully implemented in this version."""
- return name in SUPPORTED_PROVIDERS
+ """True if the provider is registered (plugin imported successfully)."""
+ return name in _PROVIDER_REGISTRY
+
+
+def registered_provider_names() -> frozenset[str]:
+ """Frozen snapshot of currently-registered provider names."""
+ return frozenset(_PROVIDER_REGISTRY.keys())
diff --git a/server/services/cli_agent/protocol.py b/server/services/cli_agent/protocol.py
index c4b643db..ae100529 100644
--- a/server/services/cli_agent/protocol.py
+++ b/server/services/cli_agent/protocol.py
@@ -88,7 +88,7 @@ class AICliProvider(Protocol):
"""Structural Protocol for an AI CLI provider.
Concrete classes:
- - `providers.anthropic_claude.AnthropicClaudeProvider`
+ - `nodes.agent.claude_code_agent._provider.AnthropicClaudeProvider`
- `providers.openai_codex.OpenAICodexProvider`
- `providers.google_gemini.GoogleGeminiProvider` (v2 stub)
"""
diff --git a/server/services/cli_agent/providers/__init__.py b/server/services/cli_agent/providers/__init__.py
index 8f2d3eec..cfb2e8e5 100644
--- a/server/services/cli_agent/providers/__init__.py
+++ b/server/services/cli_agent/providers/__init__.py
@@ -1,9 +1,13 @@
-"""Concrete `AICliProvider` implementations.
+"""Concrete `AICliProvider` implementations that still live under the
+generic framework (i.e. haven't been migrated to the canonical
+plugin-folder layout yet):
-- `anthropic_claude.AnthropicClaudeProvider` — full v1 surface
- `openai_codex.OpenAICodexProvider` — sandbox-first, no session
- `google_gemini.GoogleGeminiProvider` — v2 stub raising NotImplementedError
-Imports are intentionally not eager — `factory.create_cli_provider()`
-lazy-imports each one.
+The claude provider has moved to its plugin folder
+(``server/nodes/agent/claude_code_agent/_provider.py``) and is
+discovered via the ``register_provider`` registry. The codex
+provider will follow once `codex_agent` adopts the per-plugin
+folder structure.
"""
diff --git a/server/services/cli_agent/service.py b/server/services/cli_agent/service.py
index 5a0cf9fd..d451cfbc 100644
--- a/server/services/cli_agent/service.py
+++ b/server/services/cli_agent/service.py
@@ -427,7 +427,7 @@ class AICliService:
env = {**os.environ, "PYTHONUNBUFFERED": "1"}
# Project-local claude auth dir — same as ``AICliSession.env``.
- from services.claude_oauth import MACHINA_CLAUDE_DIR
+ from nodes.agent.claude_code_agent._oauth import MACHINA_CLAUDE_DIR
env["CLAUDE_CONFIG_DIR"] = str(MACHINA_CLAUDE_DIR)
# Composio-style parent-run-ID for MCP correlation.
env["MACHINA_PARENT_RUN_ID"] = (
diff --git a/server/services/cli_agent/session.py b/server/services/cli_agent/session.py
index 7e99f286..dd668165 100644
--- a/server/services/cli_agent/session.py
+++ b/server/services/cli_agent/session.py
@@ -207,7 +207,7 @@ class AICliSession(BaseProcessSupervisor):
# instead of the ones the credentials modal's Login button wrote.
e: Dict[str, str] = {**os.environ, "PYTHONUNBUFFERED": "1"}
if self._provider.name == "claude":
- from services.claude_oauth import MACHINA_CLAUDE_DIR
+ from nodes.agent.claude_code_agent._oauth import MACHINA_CLAUDE_DIR
e["CLAUDE_CONFIG_DIR"] = str(MACHINA_CLAUDE_DIR)
if self._lockfile_path and self._provider.ide_lock_env_var:
e[self._provider.ide_lock_env_var] = str(self._lockfile_path)
@@ -403,7 +403,7 @@ class AICliSession(BaseProcessSupervisor):
``data/claude-machina/projects/`` listing in the memory-bridge
research.
"""
- from services.claude_oauth import MACHINA_CLAUDE_DIR
+ from nodes.agent.claude_code_agent._oauth import MACHINA_CLAUDE_DIR
cwd = self.cwd() or self._repo_root
project_key = _PROJECT_KEY_RE.sub("-", str(cwd))