chore: update external connector deployment flow
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from beaver.coordinator.models import AgentDescriptor, ExecutionGraph, ExecutionNode
|
||||
from beaver.coordinator.registry import AgentRegistry, RegisteredAgent, TargetResolver
|
||||
from beaver.tasks import TaskRecord
|
||||
@ -20,22 +22,64 @@ def _task() -> TaskRecord:
|
||||
)
|
||||
|
||||
|
||||
def test_registry_seeds_builtin_agents_and_filters_disabled(tmp_path) -> None:
|
||||
def test_registry_starts_empty_and_filters_disabled(tmp_path) -> None:
|
||||
registry = AgentRegistry(tmp_path)
|
||||
|
||||
assert {agent.agent_id for agent in registry.list_active_agents()} >= {
|
||||
"researcher",
|
||||
"implementer",
|
||||
"reviewer",
|
||||
"tester",
|
||||
"documenter",
|
||||
}
|
||||
assert registry.list_agents() == []
|
||||
|
||||
registry.upsert_agent(
|
||||
RegisteredAgent(
|
||||
agent_id="tester",
|
||||
name="tester",
|
||||
display_name="Tester",
|
||||
role="testing",
|
||||
description="Runs checks.",
|
||||
system_prompt="test",
|
||||
)
|
||||
)
|
||||
registry.disable_agent("tester")
|
||||
|
||||
assert "tester" not in {agent.agent_id for agent in registry.list_active_agents()}
|
||||
|
||||
|
||||
def test_registry_drops_legacy_builtin_agents(tmp_path) -> None:
|
||||
registry_path = tmp_path / "agents" / "registry.json"
|
||||
registry_path.parent.mkdir(parents=True)
|
||||
registry_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"version": 1,
|
||||
"agents": [
|
||||
{
|
||||
"agent_id": "researcher",
|
||||
"name": "researcher",
|
||||
"display_name": "Researcher",
|
||||
"role": "research",
|
||||
"description": "legacy builtin",
|
||||
"system_prompt": "research",
|
||||
"source": "builtin",
|
||||
},
|
||||
{
|
||||
"agent_id": "workspace-agent",
|
||||
"name": "workspace-agent",
|
||||
"display_name": "Workspace Agent",
|
||||
"role": "workspace",
|
||||
"description": "user configured",
|
||||
"system_prompt": "work",
|
||||
"source": "workspace",
|
||||
},
|
||||
],
|
||||
}
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
registry = AgentRegistry(tmp_path)
|
||||
|
||||
assert [agent.agent_id for agent in registry.list_agents()] == ["workspace-agent"]
|
||||
|
||||
|
||||
def test_resolver_selects_registered_agent_by_role_and_capabilities(tmp_path) -> None:
|
||||
registry = AgentRegistry(tmp_path)
|
||||
registry.upsert_agent(
|
||||
@ -88,4 +132,3 @@ def test_resolver_falls_back_to_ephemeral_agent_when_no_match(tmp_path) -> None:
|
||||
assert resolved.nodes[0].agent.name == "rare"
|
||||
assert resolved.nodes[0].agent.metadata["resolution"] == "fallback_ephemeral"
|
||||
assert reports[0].fallback_used is True
|
||||
|
||||
|
||||
@ -59,8 +59,9 @@ class ImmediateConnectedSidecarClient(FakeSidecarClient):
|
||||
return session
|
||||
|
||||
|
||||
def test_weixin_connector_starts_connector_session(tmp_path) -> None:
|
||||
def test_weixin_connector_starts_connector_session(tmp_path, monkeypatch) -> None:
|
||||
async def run() -> None:
|
||||
monkeypatch.setenv("EXTERNAL_CONNECTOR_CALLBACK_BASE_URL", "http://app-instance-jaychen:8080")
|
||||
connection_store = ChannelConnectionStore(tmp_path / "connections.json")
|
||||
credential_store = CredentialStore(tmp_path / "credentials.json")
|
||||
client = FakeSidecarClient()
|
||||
@ -77,6 +78,7 @@ def test_weixin_connector_starts_connector_session(tmp_path) -> None:
|
||||
assert view["connectionId"].startswith("conn_")
|
||||
assert client.started[0]["kind"] == "weixin"
|
||||
assert client.started[0]["connectionId"].startswith("conn_")
|
||||
assert client.started[0]["callbackBaseUrl"] == "http://app-instance-jaychen:8080"
|
||||
assert connection_store.list()[0].kind == "weixin"
|
||||
assert connection_store.list()[0].status == "pairing"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user