// Copyright (c) Microsoft. All rights reserved.
using A2A;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
namespace AgentWebChat.Web;
///
/// Interface for clients that can interact with agents and provide streaming responses.
///
internal abstract class AgentClientBase
{
///
/// Runs an agent with the specified messages and returns a streaming response.
///
/// The name of the agent to run.
/// The messages to send to the agent.
/// Optional thread identifier for conversation continuity.
/// Cancellation token.
/// An asynchronous enumerable of agent response updates.
public abstract IAsyncEnumerable RunStreamingAsync(
string agentName,
IList messages,
string? threadId = null,
CancellationToken cancellationToken = default);
///
/// Gets the agent card for the specified agent (A2A protocol only).
///
/// The name of the agent.
/// Cancellation token.
/// The agent card if supported, null otherwise.
public virtual Task GetAgentCardAsync(string agentName, CancellationToken cancellationToken = default)
=> Task.FromResult(null);
}
///
/// Helper class to create a thread-like wrapper for agent clients.
///
public class AgentClientThread
{
public string ThreadId { get; }
public AgentClientThread(string? threadId = null)
{
this.ThreadId = threadId ?? Guid.NewGuid().ToString("N");
}
}