// Copyright (c) Microsoft. All rights reserved.
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.Extensions.AI.Agents.Runtime;
// TODO: Why is this interface needed? It's inherited by IAgentRuntime and IRuntimeActor.
// Is the former needed (does IAgentRuntime need to not only persist every actor but do so via
// this interface)? If not, these methods could be moved to IRuntimeActor.
///
/// Defines a contract for saving and loading the state of an object as JSON.
///
public interface ISaveState
{
///
/// Saves the current state of the object.
///
/// A token to cancel the operation if needed.
///
/// A task representing the asynchronous operation, returning a dictionary
/// containing the saved state. The structure of the state is implementation-defined
/// but must be JSON serializable.
///
ValueTask SaveStateAsync(CancellationToken cancellationToken = default);
///
/// Loads a previously saved state into the object.
///
///
/// A dictionary representing the saved state. The structure of the state
/// is implementation-defined but must be JSON serializable.
///
/// A token to cancel the operation if needed.
/// A task representing the asynchronous operation.
ValueTask LoadStateAsync(JsonElement state, CancellationToken cancellationToken = default);
}