Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
feat(schema): Wave 6 Phase 5.a - backend node-groups index endpoint
trohitg6ef271db905c
diff --git a/server/routers/schemas.py b/server/routers/schemas.pyindex c00f8376..5e652f86 100644--- a/server/routers/schemas.py+++ b/server/routers/schemas.py@@ -17,7 +17,7 @@ from services.node_output_schemas import (get_node_output_schema,list_node_types_with_schema,)-from services.node_spec import get_node_spec, list_node_types_with_spec+from services.node_spec import get_node_spec, list_node_groups, list_node_types_with_specrouter = APIRouter(prefix="/api/schemas", tags=["schemas"])@@ -114,3 +114,15 @@ async def list_load_options():from services.node_option_loaders import list_load_options_methodsreturn {"methods": list_load_options_methods()}++[email protected]("/nodes/groups")+async def get_node_groups(response: Response):+ """Wave 6 Phase 5: {group_name: [node_type, ...]} index derived from+ every NodeSpec's ``group`` array. Replaces the 34 hand-rolled+ ``*_NODE_TYPES`` arrays scattered across the frontend - palette+ filters, console sink detection, tool-capability checks, etc all+ read from one TanStack Query against this endpoint."""++ response.headers["Cache-Control"] = _LONG_CACHE+ return {"groups": list_node_groups()}diff --git a/server/routers/websocket.py b/server/routers/websocket.pyindex 4f253cc9..57b93738 100644--- a/server/routers/websocket.py+++ b/server/routers/websocket.py@@ -309,6 +309,18 @@ async def handle_list_load_options_methods(return {"methods": list_load_options_methods()}+@ws_handler()+async def handle_get_node_groups(+ data: Dict[str, Any], websocket: WebSocket+) -> Dict[str, Any]:+ """Wave 6 Phase 5: {group_name: [node_type, ...]} index derived from+ every NodeSpec's ``group`` array. Replaces the 34 hand-rolled+ ``*_NODE_TYPES`` arrays scattered across the frontend."""+ from services.node_spec import list_node_groups++ return {"groups": list_node_groups()}++# ============================================================================# Credential Registry Handler (Nango-style bulk fetch for 20 -> 5000 providers)# ============================================================================@@ -3222,6 +3234,8 @@ MESSAGE_HANDLERS: Dict[str, MessageHandler] = {# Wave 6 Phase 4: generic loadOptionsMethod dispatcher."load_options": handle_load_options,"list_load_options_methods": handle_list_load_options_methods,+ # Wave 6 Phase 5: node-groups index (replaces *_NODE_TYPES helpers).+ "get_node_groups": handle_get_node_groups,# Credential registry (Nango-style bulk catalogue for credentials panel)"get_credential_catalogue": handle_get_credential_catalogue,diff --git a/server/services/node_spec.py b/server/services/node_spec.pyindex 272c27c5..613db2ab 100644--- a/server/services/node_spec.py+++ b/server/services/node_spec.py@@ -79,3 +79,23 @@ def list_node_types_with_spec() -> list[str]:types it can probe without 404s."""return sorted(set(NODE_INPUT_MODELS.keys()) | set(NODE_OUTPUT_SCHEMAS.keys()))+++def list_node_groups() -> dict[str, list[str]]:+ """Wave 6 Phase 5: invert the per-spec ``group`` arrays into a+ {group_name: [node_type, ...]} index. Replaces the 34 hand-rolled+ ``*_NODE_TYPES`` arrays scattered across the frontend.++ Editor consumers (`useNodeGroup('tool')`, palette filters, console+ sink detection, etc.) read from a single TanStack Query backed by+ this endpoint instead of importing per-category constants.+ """++ index: dict[str, set[str]] = {}+ for node_type in list_node_types_with_spec():+ spec = get_node_spec(node_type)+ if not spec:+ continue+ for group in spec.get("group", []):+ index.setdefault(group, set()).add(node_type)+ return {group: sorted(types) for group, types in sorted(index.items())}diff --git a/server/tests/test_node_spec.py b/server/tests/test_node_spec.pyindex 8c6aca5b..67f1ac78 100644--- a/server/tests/test_node_spec.py+++ b/server/tests/test_node_spec.py@@ -382,3 +382,37 @@ class TestPhase4LoadOptions:from services.node_option_loaders import dispatch_load_optionsresult = await dispatch_load_options("unknown", {"group_id": "abc"})assert result == []+++class TestPhase5NodeGroups:+ """Wave 6 Phase 5: backend-derived node-groups index that replaces+ the 34 frontend ``*_NODE_TYPES`` arrays."""++ def test_returns_dict(self):+ from services.node_spec import list_node_groups+ groups = list_node_groups()+ assert isinstance(groups, dict)+ assert len(groups) > 0++ def test_known_groups_present(self):+ from services.node_spec import list_node_groups+ groups = list_node_groups()+ for expected in ["agent", "trigger", "tool", "model", "android", "social"]:+ assert expected in groups, f"Missing group {expected!r}"++ def test_tool_group_includes_known_tools(self):+ from services.node_spec import list_node_groups+ tools = set(list_node_groups().get("tool", []))+ for expected in ["pythonExecutor", "javascriptExecutor", "httpRequest"]:+ assert expected in tools++ def test_trigger_group_includes_known_triggers(self):+ from services.node_spec import list_node_groups+ triggers = set(list_node_groups().get("trigger", []))+ for expected in ["webhookTrigger", "chatTrigger", "telegramReceive", "twitterReceive"]:+ assert expected in triggers++ def test_each_group_alphabetised(self):+ from services.node_spec import list_node_groups+ for group, types in list_node_groups().items():+ assert types == sorted(types), f"Group {group!r} not sorted: {types}"