// Copyright (c) Microsoft. All rights reserved.
using Microsoft.Agents.AI.Workflows;
namespace Microsoft.Agents.AI.DurableTask.Workflows;
///
/// Live status payload written to the orchestration via SetCustomStatus.
///
///
///
/// This is the only orchestration state readable by external clients while the workflow
/// is still running. It is written after each superstep so that
/// can poll for new events.
/// On completion the framework clears it, so events are also
/// embedded in the output via .
///
///
/// When the workflow is paused at one or more nodes,
/// contains the request data for each.
///
///
internal sealed class DurableWorkflowLiveStatus
{
///
/// Gets or sets the pending request ports the workflow is waiting on. Empty when no input is needed.
///
public List PendingEvents { get; set; } = [];
///
/// Gets or sets the serialized workflow events emitted so far.
///
public List Events { get; set; } = [];
///
/// Attempts to deserialize a serialized custom status string into a .
///
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Deserializing durable workflow status.")]
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Deserializing durable workflow status.")]
internal static bool TryParse(string? serializedStatus, out DurableWorkflowLiveStatus result)
{
if (serializedStatus is null)
{
result = default!;
return false;
}
try
{
result = System.Text.Json.JsonSerializer.Deserialize(serializedStatus, DurableSerialization.Options)!;
return result is not null;
}
catch (System.Text.Json.JsonException)
{
result = default!;
return false;
}
}
}