diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs index b435a4d1..c2368cd2 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs @@ -51,4 +51,6 @@ public interface IAgentService List GetAgentsByUser(string userId); PluginDef GetPlugin(string agentId); + + IEnumerable GetAgentTools(); } diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.cs index da1b8cf1..69e67c30 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Reflection; namespace BotSharp.Core.Agents.Services; @@ -53,4 +54,14 @@ public partial class AgentService : IAgentService var agents = _db.GetAgentsByUser(userId); return agents; } + + public IEnumerable GetAgentTools() + { + var tools = typeof(AgentTool).GetFields(BindingFlags.Public | BindingFlags.Static) + .Where(f => f.IsLiteral && f.FieldType == typeof(string)) + .Select(x => x.GetRawConstantValue()?.ToString()) + .ToList(); + + return tools; + } } diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs index a7b5652d..5d34ec77 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs @@ -140,4 +140,10 @@ public class AgentController : ControllerBase { return await _agentService.DeleteAgent(agentId); } + + [HttpGet("/agent/tools")] + public IEnumerable GetAgentTools() + { + return _agentService.GetAgentTools(); + } } \ No newline at end of file