Description

Open chrome

Opens Google Chrome on this machine.

Included in Version 5

Dynamically extracted tool implementation.
How to register OpenChromeToolcsharp
public sealed class OpenChromeTool : ApplicationOpenTool{    public const string Name = "open_chrome";    public static void Register(ToolRegistry registry) =>        ApplicationOpenTool.Register<OpenChromeTool>(registry);    public override string ToolName => Name;    protected override string ApplicationName => "Google Chrome";    protected override string GetExecutable()    {        if (OperatingSystem.IsWindows())        {            return ResolveWindowsChromePath() ?? "chrome";        }        if (OperatingSystem.IsMacOS())        {            return "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";        }        return "google-chrome";    }    private static string? ResolveWindowsChromePath()    {        string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);        string programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);        string programFilesX86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);        string[] candidates =        [            Path.Combine(localAppData, "Google", "Chrome", "Application", "chrome.exe"),            Path.Combine(programFiles, "Google", "Chrome", "Application", "chrome.exe"),            Path.Combine(programFilesX86, "Google", "Chrome", "Application", "chrome.exe"),        ];        return candidates.FirstOrDefault(File.Exists);    }}
Helper classes for OpenChromeToolcsharp
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}";        }    }}
Implementation of IApplicationOpencsharp
namespace Agent.Addons.Tools.Applications;/// <summary>Opens a desktop application when invoked as an agent tool.</summary>public interface IApplicationOpen{    string ToolName { get; }    string ToolDescription { get; }    string Open();}