// Copyright (c) Microsoft. All rights reserved.
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;
namespace Microsoft.Agents.AI;
///
/// Marks a method as a skill script that is automatically discovered by .
///
///
///
/// Apply this attribute to methods in an subclass to register them as
/// skill scripts. The method's parameters and return type are automatically marshaled via
/// AIFunctionFactory.
///
///
/// To provide a description for the script, apply
/// to the same method.
///
///
/// Methods can be instance or static, and may have any visibility (public, private, etc.).
/// Methods with an parameter support dependency injection.
///
///
/// This attribute is compatible with Native AOT when used with .
/// Alternatively, override the property and use
/// instead.
///
///
///
///
/// public class MySkill : AgentClassSkill<MySkill>
/// {
/// public override AgentSkillFrontmatter Frontmatter { get; } = new("my-skill", "A skill.");
/// protected override string Instructions => "Use this skill to do something.";
///
/// [AgentSkillScript("do-something")]
/// [Description("Converts the input to upper case.")]
/// private static string DoSomething(string input) => input.ToUpperInvariant();
/// }
///
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
[Experimental(DiagnosticIds.Experiments.AgentsAIExperiments)]
public sealed class AgentSkillScriptAttribute : Attribute
{
///
/// Initializes a new instance of the class.
/// The script name defaults to the method name.
///
public AgentSkillScriptAttribute()
{
}
///
/// Initializes a new instance of the class
/// with an explicit script name.
///
/// The script name used to identify this script.
public AgentSkillScriptAttribute(string name)
{
this.Name = name;
}
///
/// Gets the script name, or to use the method name.
///
public string? Name { get; }
}