commit
2e18372f79
|
|
@ -25,6 +25,7 @@ public interface IWebBrowser
|
|||
Task<string> ExtractData(BrowserActionParams actionParams);
|
||||
Task<T> EvaluateScript<T>(string contextId, string script);
|
||||
Task CloseBrowser(string contextId);
|
||||
Task<bool> IsBrowserClosed(string contextId);
|
||||
Task<BrowserActionResult> CloseCurrentPage(MessageInfo message);
|
||||
Task<BrowserActionResult> SendHttpRequest(MessageInfo message, HttpRequestParams actionParams);
|
||||
Task<BrowserActionResult> GetAttributeValue(MessageInfo message, ElementLocatingArgs location);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
private readonly ILogger _logger;
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly IBotSharpRepository _db;
|
||||
private readonly IConversationSideCar _sidecar;
|
||||
private string _conversationId;
|
||||
/// <summary>
|
||||
/// States in the current round of conversation
|
||||
|
|
@ -41,12 +40,10 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
public ConversationStateService(
|
||||
IServiceProvider services,
|
||||
IBotSharpRepository db,
|
||||
IConversationSideCar sidecar,
|
||||
ILogger<ConversationStateService> logger)
|
||||
{
|
||||
_services = services;
|
||||
_db = db;
|
||||
_sidecar = sidecar;
|
||||
_logger = logger;
|
||||
_curStates = new ConversationState();
|
||||
_historyStates = new ConversationState();
|
||||
|
|
@ -142,8 +139,9 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
_conversationId = !isReadOnly ? conversationId : null;
|
||||
Reset();
|
||||
|
||||
var sidecar = _services.GetService<IConversationSideCar>();
|
||||
var endNodes = new Dictionary<string, string>();
|
||||
if (_sidecar?.IsEnabled() == true)
|
||||
if (sidecar?.IsEnabled() == true)
|
||||
{
|
||||
return endNodes;
|
||||
}
|
||||
|
|
@ -219,7 +217,8 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
|
||||
public void Save()
|
||||
{
|
||||
if (_conversationId == null || _sidecar?.IsEnabled() == true)
|
||||
var sidecar = _services.GetService<IConversationSideCar>();
|
||||
if (_conversationId == null || sidecar?.IsEnabled() == true)
|
||||
{
|
||||
Reset();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
|
|
@ -16,21 +16,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\agent.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\change_checkbox.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\change_list_value.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\check_radio_button.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\click_button.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\click_element.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\close_browser.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\extract_data_from_page.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\go_to_page.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\input_user_password.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\input_user_text.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\open_browser.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\scroll_page.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\send_http_request.json" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\take_screenshot.json" />
|
||||
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-web-action_on_element.fn.liquid" />
|
||||
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-web-go_to_page.fn.liquid" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\instructions\instruction.liquid" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\extract_data.liquid" />
|
||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\html_parser.liquid" />
|
||||
|
|
@ -38,9 +25,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-web-locate_element.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-web-action_on_element.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
@ -50,6 +34,9 @@
|
|||
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-web-go_to_page.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-web-locate_element.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-web-action_on_element.fn.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
@ -59,15 +46,6 @@
|
|||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\agent.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\instructions\instruction.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\extract_data.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\html_parser.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\change_checkbox.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
@ -110,6 +88,15 @@
|
|||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\take_screenshot.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\instructions\instruction.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\extract_data.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\html_parser.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ public class PlaywrightInstance : IDisposable
|
|||
}
|
||||
else
|
||||
{
|
||||
string userDataDir = args.UserDataDir ?? $"{Path.GetTempPath()}\\playwright\\{ctxId}";
|
||||
string localAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
string userDataDir = args.UserDataDir ?? $"{localAppDataFolder}\\playwright\\{ctxId}";
|
||||
_contexts[ctxId] = await _playwright.Chromium.LaunchPersistentContextAsync(userDataDir, new BrowserTypeLaunchPersistentContextOptions
|
||||
{
|
||||
Headless = args.Headless,
|
||||
|
|
|
|||
|
|
@ -15,9 +15,12 @@ public partial class PlaywrightWebDriver
|
|||
|
||||
if (page != null)
|
||||
{
|
||||
await page.EvaluateAsync(@"() => {
|
||||
window.open('', '_blank');
|
||||
}");
|
||||
if (page.Url != "about:blank")
|
||||
{
|
||||
await page.EvaluateAsync(@"() => {
|
||||
window.open('', '_blank');
|
||||
}");
|
||||
}
|
||||
|
||||
if (args.EnableResponseCallback)
|
||||
{
|
||||
|
|
@ -36,13 +39,6 @@ public partial class PlaywrightWebDriver
|
|||
else
|
||||
{
|
||||
page = await _instance.NewPage(message, args);
|
||||
|
||||
Serilog.Log.Information($"goto page: {args.Url}");
|
||||
|
||||
if (args.OpenNewTab && page != null && page.Url == "about:blank")
|
||||
{
|
||||
page = await _instance.NewPage(message, args);
|
||||
}
|
||||
}
|
||||
|
||||
if (page == null)
|
||||
|
|
@ -95,6 +91,7 @@ public partial class PlaywrightWebDriver
|
|||
}
|
||||
|
||||
result.ResponseStatusCode = response.Status;
|
||||
result.UrlAfterAction = page.Url;
|
||||
if (response.Status == 200)
|
||||
{
|
||||
result.IsSuccess = true;
|
||||
|
|
|
|||
|
|
@ -78,4 +78,9 @@ public partial class PlaywrightWebDriver : IWebBrowser
|
|||
await page.Keyboard.PressAsync(key);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> IsBrowserClosed(string contextId)
|
||||
{
|
||||
return !_instance.Contexts.ContainsKey(contextId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue