"""SequentialWorkflow graph builder.""" from __future__ import annotations from typing import Any, Iterable from beaver.coordinator.models import ExecutionGraph from .base import WorkflowAgentSpec, build_graph_from_dependencies, parse_agents WORKFLOW_NAME = "SequentialWorkflow" def build_graph( *, task: str, agents: Iterable[WorkflowAgentSpec | dict[str, Any]], ) -> ExecutionGraph: del task parsed = parse_agents(agents) dependencies = {agent.name: [] for agent in parsed} for previous, current in zip(parsed, parsed[1:], strict=False): dependencies[current.name].append(previous.name) return build_graph_from_dependencies( workflow_name=WORKFLOW_NAME, strategy="sequence", agents=parsed, dependencies=dependencies, )