using System; using System.Collections.Generic; using Microsoft.Extensions.AI; namespace OnDeviceAgent.AgentCore { public sealed class ToolDefinition { public string Name; public string HandlerName; public string Description; public Dictionary Properties = new Dictionary(StringComparer.OrdinalIgnoreCase); } public sealed class ToolRegistry { readonly object m_Lock = new object(); readonly Dictionary m_Tools = new Dictionary(StringComparer.OrdinalIgnoreCase); public void Register(IAgentTool tool) { if (tool == null) throw new ArgumentNullException("tool"); lock (m_Lock) m_Tools[tool.Name] = tool; } public IReadOnlyList BuildAITools( bool enableBuiltins, AgentToolContext context) { if (context == null) throw new ArgumentNullException("context"); var result = new List(); if (!enableBuiltins) return result; List snapshot; lock (m_Lock) snapshot = new List(m_Tools.Values); foreach (var tool in snapshot) result.Add(tool.ToAIFunction(context)); return result; } } }