BotSharp/src/Plugins/BotSharp.Plugin.WebDriver/Hooks/WebUtilityHook.cs

36 lines
1.1 KiB
C#
Raw Normal View History

2025-02-03 23:43:04 +00:00
namespace BotSharp.Plugin.WebDriver.Hooks;
public class WebUtilityHook : IAgentUtilityHook
{
private const string PREFIX = "util-web-";
2025-02-04 21:56:25 +00:00
private const string CLOSE_BROWSER_FN = $"{PREFIX}close_browser";
2025-02-03 23:43:04 +00:00
private const string GO_TO_PAGE_FN = $"{PREFIX}go_to_page";
2025-02-04 21:56:25 +00:00
private const string LOCATE_ELEMENT_FN = $"{PREFIX}locate_element";
2025-02-03 23:43:04 +00:00
private const string ACTION_ON_ELEMENT_FN = $"{PREFIX}action_on_element";
public void AddUtilities(List<AgentUtility> utilities)
{
var items = new List<AgentUtility>
{
new AgentUtility
{
Name = "web.tools",
Functions =
[
2025-02-04 21:56:25 +00:00
new(CLOSE_BROWSER_FN),
2025-02-03 23:43:04 +00:00
new(GO_TO_PAGE_FN),
2025-02-04 21:56:25 +00:00
new(LOCATE_ELEMENT_FN),
2025-02-03 23:43:04 +00:00
new(ACTION_ON_ELEMENT_FN)
],
Templates =
[
new($"{GO_TO_PAGE_FN}.fn"),
new($"{ACTION_ON_ELEMENT_FN}.fn")
]
}
};
utilities.AddRange(items);
}
}