This commit is contained in:
2026-10-08 18:29:45 -07:00
parent 8eedf03486
commit 5725de2dac
35 changed files with 3360 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import os
from typing import Dict, List, Optional
from .base import BaseAgent
from .antigravity import AntigravityAgent
from .hermes import HermesAgent
_REGISTERED_AGENTS: List[BaseAgent] = [
AntigravityAgent(),
HermesAgent(),
]
_LOOKUP_MAP: Dict[str, BaseAgent] = {}
for agent in _REGISTERED_AGENTS:
_LOOKUP_MAP[agent.name.lower()] = agent
for alias in agent.aliases:
_LOOKUP_MAP[alias.lower()] = agent
def list_agents() -> List[BaseAgent]:
"""Return list of all registered agent instances."""
return list(_REGISTERED_AGENTS)
def get_agent(name_or_alias: str) -> Optional[BaseAgent]:
"""Look up an agent by its primary name or any alias."""
return _LOOKUP_MAP.get(name_or_alias.strip().lower())
def get_default_agent() -> BaseAgent:
"""
Resolve the default agent to use:
1. Check TASK_AGENT environment variable.
2. Fall back to the first available agent CLI found on PATH.
3. If none installed, return the first registered agent (which will report not found on launch).
"""
env_agent = os.environ.get("TASK_AGENT")
if env_agent:
matched = get_agent(env_agent)
if matched:
return matched
else:
raise ValueError(
f"Unknown agent specified in TASK_AGENT='{env_agent}'. "
f"Available agents: {', '.join([a.name for a in _REGISTERED_AGENTS])}"
)
# Auto-detect available agent
for agent in _REGISTERED_AGENTS:
if agent.is_available():
return agent
return _REGISTERED_AGENTS[0]

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,25 @@
import os
import shutil
from typing import List, Optional
from .base import BaseAgent
class AntigravityAgent(BaseAgent):
"""Adapter for Google Antigravity CLI (agy)."""
name = "antigravity"
aliases = ["agy"]
def is_available(self) -> bool:
return shutil.which("agy") is not None
def launch(self, prompt: str, extra_args: Optional[List[str]] = None) -> None:
bin_path = shutil.which("agy")
if not bin_path:
raise FileNotFoundError("Antigravity CLI ('agy') is not found on PATH.")
cmd = [bin_path, "-i", prompt]
if extra_args:
cmd.extend(extra_args)
os.execvp(bin_path, cmd)

View File

@@ -0,0 +1,22 @@
from abc import ABC, abstractmethod
from typing import List, Optional
class BaseAgent(ABC):
"""Abstract base class for AI CLI agents."""
name: str = ""
aliases: List[str] = []
@abstractmethod
def is_available(self) -> bool:
"""Check if the agent CLI binary is installed and reachable in PATH."""
pass
@abstractmethod
def launch(self, prompt: str, extra_args: Optional[List[str]] = None) -> None:
"""Launch the agent interactively with the pre-seeded prompt."""
pass
def __repr__(self) -> str:
return f"<{self.__class__.__name__} name={self.name}>"

View File

@@ -0,0 +1,25 @@
import os
import shutil
from typing import List, Optional
from .base import BaseAgent
class HermesAgent(BaseAgent):
"""Adapter for Hermes Agent CLI."""
name = "hermes"
aliases = ["hermes-agent"]
def is_available(self) -> bool:
return shutil.which("hermes") is not None
def launch(self, prompt: str, extra_args: Optional[List[str]] = None) -> None:
bin_path = shutil.which("hermes")
if not bin_path:
raise FileNotFoundError("Hermes CLI ('hermes') is not found on PATH.")
cmd = [bin_path, "chat", "-q", prompt]
if extra_args:
cmd.extend(extra_args)
os.execvp(bin_path, cmd)