Add ITool + ToolRegistry + GetCurrentTimeTool

This commit is contained in:
2026-06-11 21:19:23 +00:00
parent 13d8773704
commit 9325d21f9e
6 changed files with 125 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
namespace backend.Tools;
public class ToolRegistry
{
private readonly Dictionary<string, ITool> _byName;
private readonly List<ITool> _all;
public ToolRegistry(IEnumerable<ITool> tools)
{
_all = tools.ToList();
_byName = _all.ToDictionary(t => t.Name);
}
public IReadOnlyList<ITool> All => _all;
public ITool? Get(string name) => _byName.GetValueOrDefault(name);
public IEnumerable<ITool> EnabledFor(IReadOnlySet<string> enabled)
=> _all.Where(t => enabled.Contains(t.Name));
}