← All source files

V10 / 66cebf3528e0

ProviderClient.WebResearch.cs

Lilith/Core/Providers/ProviderClient.WebResearch.cs

Unchanged from the preceding version
CS
using Lilith.Core.WebResearch;

namespace Lilith.Core.Providers;

public abstract partial class ProviderClient
{
    private bool? _seleniumHeadless;
    public event Action<ResearchBrowserFrame>? ResearchBrowserFrameCaptured;
    public bool SeleniumHeadless => _seleniumHeadless ?? BrowserResearchOptions.Load().Headless;

    public bool SetSeleniumHeadless(bool? enabled)
    {
        using var operation = EnterOperation();
        _seleniumHeadless = enabled ?? !SeleniumHeadless;
        return _seleniumHeadless.Value;
    }

    internal IResearchBrowser CreateResearchBrowser()
    {
        if (ResearchBrowser is not null) return ResearchBrowser;
        var options = BrowserResearchOptions.Load();
        return new SeleniumResearchBrowser(options with { Headless = _seleniumHeadless ?? options.Headless },
            reportLifecycle: message => Logger.WriteInfo("Selenium", message),
            captureFrame: ResearchBrowserFrameCaptured is null ? null : frame => ResearchBrowserFrameCaptured?.Invoke(frame));
    }
}