2026-09-04 15:48:07 +02:00
|
|
|
using AIStudio.Provider;
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Tools.Web;
|
|
|
|
|
|
|
|
|
|
public sealed class WebPageRetrievalOptions
|
|
|
|
|
{
|
|
|
|
|
public required int TimeoutSeconds { get; init; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether the user named this exact URL, as opposed to a model asking for it.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// Lifts the restrictions on which targets may be reached — private networks, loopback, and
|
|
|
|
|
/// hosts named localhost — because those exist to keep a model from reaching into the user's
|
|
|
|
|
/// network, and the user is not a model. The network-level protections stay: the connection
|
|
|
|
|
/// is still bound to validated addresses, redirects are still checked, the response size is
|
2026-09-23 22:21:09 +02:00
|
|
|
/// still capped, and only HTML and text content are still accepted.<br/><br/>
|
2026-09-04 15:48:07 +02:00
|
|
|
/// Never set this for a URL that reached AI Studio through a model, however plausible it
|
|
|
|
|
/// looks.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
public bool TargetChosenByUser { get; init; }
|
|
|
|
|
|
|
|
|
|
public bool PublicTargetsOnly { get; init; }
|
|
|
|
|
|
2026-10-18 19:39:55 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Whether every request has to reach non-public addresses only, the counterpart of
|
|
|
|
|
/// PublicTargetsOnly.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// For an address the model chose on a host which counts as internal, such as one of the
|
|
|
|
|
/// allowed private hosts, while its chat may not send data to third parties. A host name says
|
|
|
|
|
/// nothing about where it leads: a pattern such as *.example.org matches public hosts as well,
|
|
|
|
|
/// and an intranet server may redirect anywhere. Every request is therefore checked, redirects
|
|
|
|
|
/// included, and one which would reach a public address is refused before anything is sent.
|
|
|
|
|
/// <br/><br/>
|
|
|
|
|
/// Holds whoever chose the address, because it guards what the address may carry rather than
|
|
|
|
|
/// where the user may go.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
public bool NonPublicTargetsOnly { get; init; }
|
|
|
|
|
|
2026-09-04 15:48:07 +02:00
|
|
|
public ConfidenceLevel ProviderConfidence { get; init; } = ConfidenceLevel.NONE;
|
|
|
|
|
|
|
|
|
|
public bool UseOsSso { get; init; }
|
|
|
|
|
|
|
|
|
|
public Func<string, bool>? IsPrivateHostAllowed { get; init; }
|
|
|
|
|
|
2026-09-23 17:17:37 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Decides for every URL, the first one as well as each redirect target, whether it may be
|
|
|
|
|
/// requested at all. It runs before anything is sent, so a refused target never sees the URL.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Func<Uri, bool>? IsTargetAllowed { get; init; }
|
|
|
|
|
|
2026-09-04 15:48:07 +02:00
|
|
|
public Func<Uri, ConfidenceLevel, Task>? OnPrivateHostProviderBlockAsync { get; init; }
|
|
|
|
|
}
|