Skip to content

The agent that grows with you

fix(auth): discover external CLIs in user-local bin

KoNit-K3126389d9824
diff --git a/hermes_cli/auth.py b/hermes_cli/auth.py
index cb8cd0fc206..488d69bd721 100644
--- a/hermes_cli/auth.py
+++ b/hermes_cli/auth.py
@@ -2151,10 +2151,16 @@ def _external_process_spec(
or str(getattr(profile, "process_command", "") or ""))
raw_args = os.getenv(args_env_var, "").strip() if args_env_var else ""
args = shlex.split(raw_args) if raw_args else list(getattr(profile, "process_args", ()) or [])
- resolved = shutil.which(command) if command else None
+ resolved = None
+ if command:
+ from hermes_platform.resolver import locate_command
+ from hermes_platform.resolver.known_dirs import user_local_bin
+
+ found = locate_command(command, known_dirs=user_local_bin()).command
+ resolved = found[0] if found else None
if command and not resolved:
# A GUI/service launch (LaunchAgent, Desktop backend) has a bare PATH: probe Claude Code's
- # install prefixes as the Anthropic adapter does. Any other command stays PATH-only.
+ # install prefixes as the Anthropic adapter does.
from agent.anthropic_adapter import find_claude_code_cli
resolved = find_claude_code_cli(command)
return command, args, base_url, resolved, command_env_vars
diff --git a/tests/hermes_cli/test_external_process_auth_status.py b/tests/hermes_cli/test_external_process_auth_status.py
index 36d8cadc18a..ec00aa393b7 100644
--- a/tests/hermes_cli/test_external_process_auth_status.py
+++ b/tests/hermes_cli/test_external_process_auth_status.py
@@ -20,6 +20,7 @@ import pytest
from hermes_cli.auth import (
get_auth_status,
get_external_process_provider_status,
+ resolve_external_process_provider_credentials,
)
@@ -60,6 +61,25 @@ def test_get_auth_status_dispatches_external_process_by_auth_type(
assert "auth_verified" in status
+def test_external_process_status_finds_user_local_cli_outside_backend_path(
+ tmp_path, monkeypatch, _clean_copilot_env
+):
+ """Desktop SSH inventory must discover a CLI installed in the user's local bin."""
+ local_bin = tmp_path / ".local" / "bin"
+ local_bin.mkdir(parents=True)
+ cli = local_bin / "copilot"
+ cli.write_text("", encoding="utf-8")
+ cli.chmod(0o755)
+ monkeypatch.setenv("HOME", str(tmp_path))
+ monkeypatch.setenv("PATH", str(tmp_path / "backend-bin"))
+
+ status = get_external_process_provider_status("copilot-acp")
+
+ assert status["configured"] is True
+ assert status["resolved_command"] == str(cli)
+ assert resolve_external_process_provider_credentials("copilot-acp")["command"] == str(cli)
+
+
def test_external_process_status_rejects_wrong_auth_type():
# A provider that exists but is not external_process must be refused —
# the generic dispatcher relies on this guard.