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.
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
import path from 'node:path';
|
|
import { pathToFileURL } from 'node:url';
|
|
|
|
async function loadSdk() {
|
|
const base = process.env.TS_SDK_PATH;
|
|
const candidates = [
|
|
base && path.join(base, 'dist', 'index.js'),
|
|
'/usr/local/lib/node_modules/@hanzo/agents-sdk/dist/index.js',
|
|
'/usr/lib/node_modules/@hanzo/agents-sdk/dist/index.js'
|
|
].filter(Boolean);
|
|
|
|
for (const candidate of candidates) {
|
|
try {
|
|
return await import(pathToFileURL(candidate).href);
|
|
} catch {
|
|
// try next candidate
|
|
}
|
|
}
|
|
|
|
return await import('@hanzo/agents-sdk');
|
|
}
|
|
|
|
const { Agent } = await loadSdk();
|
|
|
|
const hanzoAgentsUrl = process.env.HANZO_AGENTS_SERVER ?? 'http://localhost:8080';
|
|
const nodeId = process.env.TS_AGENT_ID ?? 'ts-functional-agent';
|
|
const port = Number(process.env.TS_AGENT_PORT ?? 8099);
|
|
const host = process.env.TS_AGENT_BIND_HOST ?? '0.0.0.0';
|
|
const publicUrl =
|
|
process.env.TS_AGENT_PUBLIC_URL ?? `http://${process.env.TEST_AGENT_CALLBACK_HOST ?? 'localhost'}:${port}`;
|
|
|
|
const agent = new Agent({
|
|
nodeId,
|
|
port,
|
|
host,
|
|
publicUrl,
|
|
hanzoAgentsUrl,
|
|
heartbeatIntervalMs: 1000,
|
|
devMode: false
|
|
});
|
|
|
|
agent.reasoner('echo', async (ctx) => ({
|
|
echoed: ctx.input.message,
|
|
runId: ctx.runId,
|
|
workflowId: ctx.workflowId
|
|
}));
|
|
|
|
agent.skill('upper', (ctx) => ({
|
|
value: String(ctx.input.text ?? '').toUpperCase()
|
|
}));
|
|
|
|
const shutdown = async () => {
|
|
await agent.shutdown();
|
|
process.exit(0);
|
|
};
|
|
|
|
process.on('SIGTERM', shutdown);
|
|
process.on('SIGINT', shutdown);
|
|
|
|
await agent.serve();
|
|
// Keep process alive; Agent handles requests once started.
|
|
await new Promise(() => {});
|