// Copyright (c) Microsoft. All rights reserved. using System.Collections.Generic; using Microsoft.Agents.AI; using Microsoft.Agents.AI.GitHub.Copilot; using Microsoft.Extensions.AI; using Microsoft.Shared.Diagnostics; namespace GitHub.Copilot.SDK; /// /// Provides extension methods for /// to simplify the creation of GitHub Copilot agents. /// /// /// These extensions bridge the gap between GitHub Copilot SDK client objects /// and the Microsoft Agent Framework. /// /// They allow developers to easily create AI agents that can interact /// with GitHub Copilot by handling the conversion from Copilot clients to /// instances that implement the interface. /// /// public static class CopilotClientExtensions { /// /// Retrieves an instance of for a GitHub Copilot client. /// /// The to use for the agent. /// Optional session configuration for the agent. /// Whether the agent owns the client and should dispose it. Default is false. /// The unique identifier for the agent. /// The name of the agent. /// The description of the agent. /// An instance backed by the GitHub Copilot client. public static AIAgent AsAIAgent( this CopilotClient client, SessionConfig? sessionConfig = null, bool ownsClient = false, string? id = null, string? name = null, string? description = null) { Throw.IfNull(client); return new GitHubCopilotAgent(client, sessionConfig, ownsClient, id, name, description); } /// /// Retrieves an instance of for a GitHub Copilot client. /// /// The to use for the agent. /// Whether the agent owns the client and should dispose it. Default is false. /// The unique identifier for the agent. /// The name of the agent. /// The description of the agent. /// The tools to make available to the agent. /// Optional instructions to append as a system message. /// An instance backed by the GitHub Copilot client. public static AIAgent AsAIAgent( this CopilotClient client, bool ownsClient = false, string? id = null, string? name = null, string? description = null, IList? tools = null, string? instructions = null) { Throw.IfNull(client); return new GitHubCopilotAgent(client, ownsClient, id, name, description, tools, instructions); } }