Skip to content

The agent that grows with you

refactor(auth): move external-process CLI lookup into auth_external_process to keep auth.py inside the size ratchet

Brooklyn Nicholsone894a7f82a73
diff --git a/hermes_cli/auth.py b/hermes_cli/auth.py
index 12547abc4fe..21ec72d97b3 100644
--- a/hermes_cli/auth.py
+++ b/hermes_cli/auth.py
@@ -2151,21 +2151,8 @@ 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 [])
- from hermes_platform.resolver import locate_command
- from hermes_platform.resolver.known_dirs import user_local_bin
- lookup = command
- if os.sep in command or (os.altsep and os.altsep in command):
- # An operator-configured relative path (./bin/copilot) means the launch cwd, as it did
- # under shutil.which; anchor it so the resolver's absolute-only explicit check accepts it.
- lookup = os.path.abspath(os.path.expandvars(os.path.expanduser(command)))
- found = locate_command(lookup, known_dirs=user_local_bin()).command if command else ()
- 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.
- from agent.anthropic_adapter import find_claude_code_cli
- resolved = find_claude_code_cli(command)
- return command, args, base_url, resolved, command_env_vars
+ from hermes_cli.auth_external_process import resolve_external_process_command
+ return command, args, base_url, resolve_external_process_command(command), command_env_vars
def get_external_process_provider_status(provider_id: str) -> Dict[str, Any]:
diff --git a/hermes_cli/auth_external_process.py b/hermes_cli/auth_external_process.py
new file mode 100644
index 00000000000..70de4624343
--- /dev/null
+++ b/hermes_cli/auth_external_process.py
@@ -0,0 +1,30 @@
+"""Executable lookup for ``external_process`` (ACP) providers.
+
+A GUI/service launch (LaunchAgent, Desktop backend, Desktop over SSH) has a bare PATH, so the
+profile's command resolves through PATH, then the user-local bin, then Claude Code's install
+prefixes."""
+
+from __future__ import annotations
+
+import os
+from typing import Optional
+
+
+def resolve_external_process_command(command: str) -> Optional[str]:
+ """Absolute path of the provider CLI ``command``, or ``None`` when nothing executable matches."""
+ if not command:
+ return None
+ from hermes_platform.resolver import locate_command
+ from hermes_platform.resolver.known_dirs import user_local_bin
+
+ lookup = command
+ if os.sep in command or (os.altsep and os.altsep in command):
+ # An operator-configured relative path (./bin/copilot) means the launch cwd, as it did
+ # under shutil.which; anchor it so the resolver's absolute-only explicit check accepts it.
+ lookup = os.path.abspath(os.path.expandvars(os.path.expanduser(command)))
+ found = locate_command(lookup, known_dirs=user_local_bin()).command
+ if found:
+ return found[0]
+ from agent.anthropic_adapter import find_claude_code_cli
+
+ return find_claude_code_cli(command)