"""Message router node helpers (minimal actor-first stub)."""

from __future__ import annotations

from typing import Any

from cleveragents.langgraph.nodes import Edge, NodeConfig, NodeType


def build_message_router_node(name: str, rules: list[dict[str, Any]]) -> NodeConfig:
    return NodeConfig(
        name=name, type=NodeType.MESSAGE_ROUTER, metadata={"rules": rules}
    )


def build_message_router_edges(name: str, rules: list[dict[str, Any]]) -> list[Edge]:
    edges: list[Edge] = []
    for rule in rules:
        target = rule.get("target")
        if target:
            edges.append(
                Edge(source=name, target=target, condition=rule.get("condition"))
            )
    edges.append(Edge(source=name, target="end"))
    return edges
