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.
99 lines
3.0 KiB
Python
99 lines
3.0 KiB
Python
import datetime
|
|
|
|
from hanzo_agents.did_manager import DIDManager, DIDIdentityPackage
|
|
|
|
|
|
def make_package():
|
|
return {
|
|
"agent_did": {
|
|
"did": "did:agent:123",
|
|
"private_key_jwk": "priv",
|
|
"public_key_jwk": "pub",
|
|
"derivation_path": "m/0",
|
|
"component_type": "agent",
|
|
},
|
|
"reasoner_dids": {
|
|
"reasoner_a": {
|
|
"did": "did:reasoner:a",
|
|
"private_key_jwk": "priv_a",
|
|
"public_key_jwk": "pub_a",
|
|
"derivation_path": "m/1",
|
|
"component_type": "reasoner",
|
|
}
|
|
},
|
|
"skill_dids": {
|
|
"skill_b": {
|
|
"did": "did:skill:b",
|
|
"private_key_jwk": "priv_b",
|
|
"public_key_jwk": "pub_b",
|
|
"derivation_path": "m/2",
|
|
"component_type": "skill",
|
|
}
|
|
},
|
|
"hanzo_agents_server_id": "hanzo_agents-1",
|
|
}
|
|
|
|
|
|
def test_register_agent_success(monkeypatch):
|
|
manager = DIDManager("http://hanzo_agents", "node")
|
|
|
|
class DummyResponse:
|
|
status_code = 200
|
|
|
|
@staticmethod
|
|
def json():
|
|
return {"success": True, "identity_package": make_package()}
|
|
|
|
monkeypatch.setattr("requests.post", lambda *a, **k: DummyResponse())
|
|
|
|
ok = manager.register_agent([], [])
|
|
assert ok is True
|
|
assert manager.is_enabled() is True
|
|
assert manager.get_agent_did() == "did:agent:123"
|
|
assert manager.get_function_did("reasoner_a") == "did:reasoner:a"
|
|
assert manager.get_function_did("unknown") == "did:agent:123"
|
|
|
|
|
|
def test_register_agent_failure_status(monkeypatch):
|
|
manager = DIDManager("http://hanzo_agents", "node")
|
|
|
|
class DummyResponse:
|
|
status_code = 500
|
|
text = "boom"
|
|
|
|
monkeypatch.setattr("requests.post", lambda *a, **k: DummyResponse())
|
|
ok = manager.register_agent([], [])
|
|
assert ok is False
|
|
assert manager.is_enabled() is False
|
|
|
|
|
|
def test_create_execution_context(monkeypatch):
|
|
manager = DIDManager("http://hanzo_agents", "node")
|
|
package = manager._parse_identity_package(make_package())
|
|
assert isinstance(package, DIDIdentityPackage)
|
|
manager.identity_package = package
|
|
manager.enabled = True
|
|
|
|
ctx = manager.create_execution_context(
|
|
execution_id="exec1",
|
|
workflow_id="wf1",
|
|
session_id="sess",
|
|
caller_function="reasoner_a",
|
|
target_function="skill_b",
|
|
)
|
|
assert ctx is not None
|
|
assert ctx.caller_did == "did:reasoner:a"
|
|
assert ctx.target_did == "did:skill:b"
|
|
assert isinstance(ctx.timestamp, datetime.datetime)
|
|
|
|
|
|
def test_create_execution_context_missing_identity():
|
|
manager = DIDManager("http://hanzo_agents", "node")
|
|
assert manager.create_execution_context("e", "w", "s", "a", "b") is None
|
|
|
|
|
|
def test_get_identity_summary_disabled():
|
|
manager = DIDManager("http://hanzo_agents", "node")
|
|
summary = manager.get_identity_summary()
|
|
assert summary["enabled"] is False
|