mirror of
https://github.com/hanzoai/agents.git
synced 2026-10-30 18:48:36 +00:00
Transforms hanzoai/agents from a marketplace config repo into a full agent orchestration platform by merging the AgentField infrastructure: - Go control plane (K8s-like agent orchestration, service mesh, DAG workflows) - Python SDK (FastAPI-based agent framework, LiteLLM, memory, DID/VC) - TypeScript SDK (@hanzo/agents - Vercel AI SDK, MCP, workflows) - Go SDK (idiomatic agent builder + client) - React 19 embedded dashboard (XyFlow DAGs, Recharts, Radix UI) - Docker/K8s/Helm deployment configs - Examples: hello world, deep research, RAG, simulation, benchmarks - Functional test suite across Python/Go/TypeScript All references rebranded: AgentField → Hanzo Agents - Module: github.com/hanzoai/agents/control-plane - Python: hanzo_agents - TypeScript: @hanzo/agents - Go: github.com/hanzoai/agents/sdk/go - Env vars: HANZO_AGENTS_* - Config: hanzo-agents.yaml Previous marketplace configs moved to config/ directory.
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
import asyncio
|
|
import os
|
|
import shutil
|
|
from contextlib import asynccontextmanager
|
|
from dataclasses import dataclass
|
|
from typing import AsyncIterator, Iterable, Mapping, Optional
|
|
|
|
|
|
@dataclass
|
|
class GoAgentProcess:
|
|
name: str
|
|
process: asyncio.subprocess.Process
|
|
|
|
|
|
def get_go_agent_binary(agent_name: str) -> str:
|
|
binary_name = f"go-agent-{agent_name}"
|
|
path = shutil.which(binary_name)
|
|
if not path:
|
|
raise FileNotFoundError(f"{binary_name} not found on PATH")
|
|
return path
|
|
|
|
|
|
@asynccontextmanager
|
|
async def run_go_agent(
|
|
agent_name: str,
|
|
args: Optional[Iterable[str]] = None,
|
|
env: Optional[Mapping[str, str]] = None,
|
|
) -> AsyncIterator[GoAgentProcess]:
|
|
"""
|
|
Launch a Go agent binary as an async subprocess and ensure it is terminated
|
|
when the context exits.
|
|
"""
|
|
binary = get_go_agent_binary(agent_name)
|
|
cmd = [binary]
|
|
if args:
|
|
cmd.extend(args)
|
|
|
|
merged_env = {**os.environ}
|
|
if env:
|
|
merged_env.update(env)
|
|
|
|
process = await asyncio.create_subprocess_exec(
|
|
*cmd,
|
|
stdout=asyncio.subprocess.PIPE,
|
|
stderr=asyncio.subprocess.PIPE,
|
|
env=merged_env,
|
|
)
|
|
|
|
proc_info = GoAgentProcess(name=agent_name, process=process)
|
|
try:
|
|
yield proc_info
|
|
finally:
|
|
if process.returncode is None:
|
|
process.terminate()
|
|
try:
|
|
await asyncio.wait_for(process.wait(), timeout=10.0)
|
|
except asyncio.TimeoutError:
|
|
process.kill()
|