// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Agents.AI.Workflows;
///
/// Provides extension methods for configuring and building workflows using the WorkflowBuilder type.
///
/// These extension methods simplify the process of connecting executors, adding external calls, and
/// constructing workflows with output aggregation. They are intended to streamline workflow graph construction and
/// promote common patterns for chaining and aggregating workflow steps.
public static class WorkflowBuilderExtensions
{
///
/// Adds edges to the workflow that forward messages of the specified type from the source executor to
/// one or more target executors.
///
/// The type of message to forward.
/// The to which the edges will be added.
/// The source executor from which messages will be forwarded.
/// The target executors to which messages will be forwarded.
/// The updated instance.
public static WorkflowBuilder ForwardMessage(this WorkflowBuilder builder, ExecutorIsh source, params IEnumerable executors)
=> builder.ForwardMessage(source, condition: null, executors);
///
/// Adds edges to the workflow that forward messages of the specified type from the source executor to
/// one or more target executors.
///
/// The type of message to forward.
/// The to which the edges will be added.
/// The source executor from which messages will be forwarded.
/// An optional condition that messages must satisfy to be forwarded. If ,
/// all messages of type will be forwarded.
/// The target executors to which messages will be forwarded.
/// The updated instance.
public static WorkflowBuilder ForwardMessage(this WorkflowBuilder builder, ExecutorIsh source, Func? condition = null, params IEnumerable executors)
{
Throw.IfNull(executors);
Func