// Copyright (c) Microsoft. All rights reserved.
using Microsoft.Agents.AI.DurableTask.Workflows;
using Microsoft.Agents.AI.Workflows;
namespace Microsoft.Agents.AI.Hosting.AzureFunctions;
///
/// Extension methods for to configure Azure Functions HTTP trigger options.
///
public static class DurableWorkflowOptionsExtensions
{
///
/// Adds a workflow and optionally exposes a status HTTP endpoint for querying pending HITL requests.
///
/// The workflow options to add the workflow to.
/// The workflow instance to add.
/// If , a GET endpoint is generated at workflows/{name}/status/{runId}.
public static void AddWorkflow(this DurableWorkflowOptions options, Workflow workflow, bool exposeStatusEndpoint)
{
ArgumentNullException.ThrowIfNull(options);
options.AddWorkflow(workflow);
if (exposeStatusEndpoint && options.ParentOptions is FunctionsDurableOptions functionsOptions)
{
functionsOptions.EnableStatusEndpoint(workflow.Name!);
}
}
///
/// Adds a workflow and configures whether to expose a status HTTP endpoint and/or an MCP tool trigger.
///
/// The workflow options to add the workflow to.
/// The workflow instance to add.
/// If , a GET endpoint is generated at workflows/{name}/status/{runId}.
/// If , an MCP tool trigger is generated for the workflow.
public static void AddWorkflow(this DurableWorkflowOptions options, Workflow workflow, bool exposeStatusEndpoint, bool exposeMcpToolTrigger)
{
ArgumentNullException.ThrowIfNull(options);
options.AddWorkflow(workflow);
if (options.ParentOptions is FunctionsDurableOptions functionsOptions)
{
if (exposeStatusEndpoint)
{
functionsOptions.EnableStatusEndpoint(workflow.Name!);
}
if (exposeMcpToolTrigger)
{
functionsOptions.EnableMcpToolTrigger(workflow.Name!);
}
}
}
}