using MAF1.Tools; using MAF1.Utils; using Microsoft.Agents.AI.Workflows; namespace MAF1.Route; /// 把图编译成 WithHandoff 工作流并跑一轮。 public static class RouteOrchestrator { public static async Task RunAsync( AgentFactory factory, WeatherTools weatherTools, RouteGraph graph, RouteUserInput input) { string task = input.ToTask(); Console.WriteLine("模式 route:方案 C + MAF WithHandoff(图 = 白名单,边 = 允许交接)"); Console.WriteLine($"图节点: {string.Join("、", graph.Nodes.Select(DescribeNode))}"); Console.WriteLine(graph.HasEdges ? $"专家之间的边: {string.Join("、", graph.Edges.Select(e => $"{e.From}->{e.To}" + (string.IsNullOrWhiteSpace(e.When) ? "" : $" [{e.When}]")))}" : "专家之间无边"); Console.WriteLine($"主管可第一跳: {string.Join("、", graph.Nodes.Select(n => n.Id))}(按用户原话选择,不必先抽城市)"); Console.WriteLine($"输入: {input.Describe()}"); Console.WriteLine(); Workflow workflow = HandoffGraphBuilder.Build(factory, weatherTools, graph, input); await HandoffRun.RunAsync(workflow, task); } private static string DescribeNode(RouteNode node) { string title = string.IsNullOrWhiteSpace(node.Title) ? node.Type : node.Title; return $"{node.Id}:{title}"; } }