Tools/Applications/ApplicationOpenTool.cscsharp
using System.Diagnostics;using Agent.Core.ToolCalling;namespace Agent.Addons.Tools.Applications;/// <summary>Base for addon tools that launch a local application.</summary>public abstract class ApplicationOpenTool : IApplicationOpen{    public abstract string ToolName { get; }    protected abstract string ApplicationName { get; }    public virtual string ToolDescription => $"Opens {ApplicationName} on this machine.";    protected abstract string GetExecutable();    protected virtual string? Arguments => null;    public static void Register<TTool>(ToolRegistry registry)        where TTool : ApplicationOpenTool, new()    {        var tool = new TTool();        registry.Register(new AgentTool(            tool.ToolName,            tool.ToolDescription,            _ => tool.Open()));    }    public string Open()    {        string executable = GetExecutable();        if (string.IsNullOrWhiteSpace(executable))        {            return $"Error: Could not resolve executable for {ToolName}.";        }        try        {            var startInfo = new ProcessStartInfo            {                FileName = executable,                Arguments = Arguments ?? "",                UseShellExecute = true,            };            Process.Start(startInfo);            return $"Opened {ApplicationName}.";        }        catch (Exception ex)        {            return $"Failed to open {ApplicationName}: {ex.Message}";        }    }}