Support multiple web search backends: SearXNG, Staan, and Tavily (#948)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-09-04 22:14:29 +02:00
1 parent 4d8d30e15e
commit 4141e7c504
57 files changed
+3734 -1088

No files matched your search

@@ -15,8 +15,24 @@ public sealed class ToolSettingsSchemaBuilder
private readonly Dictionary<string, ToolSettingsFieldDefinition> properties = new(StringComparer.Ordinal);
private readonly HashSet<string> requiredNames = new(StringComparer.Ordinal);
private string currentGroup = string.Empty;
public static ToolSettingsSchemaBuilder Create() => new();
/// <summary>
/// Puts every field declared after this call into one group.
/// </summary>
/// <remarks>
/// Call it again with another name to start the next group, or with an empty name to
/// leave grouping behind. Groups are shown in the order in which they first appear here,
/// and so are the fields within them.
/// </remarks>
public ToolSettingsSchemaBuilder InGroup(string groupKey)
{
this.currentGroup = groupKey;
return this;
}
/// <summary>
/// A field the tool cannot work without.
/// </summary>
@@ -35,6 +51,16 @@ public sealed class ToolSettingsSchemaBuilder
public ToolSettingsSchemaBuilder OptionalChoice(string name, string optionSource) => this.Add(name, isRequired: false, optionSource: optionSource);
/// <summary>
/// An optional field whose value is picked from a short list the tool spells out itself.
/// </summary>
/// <remarks>
/// Use this for values only one tool knows, such as the markets a single search service
/// offers. Anything the app maintains elsewhere belongs in an option source instead, which
/// also gives the user a translated name rather than the raw value.
/// </remarks>
public ToolSettingsSchemaBuilder OptionalEnum(string name, params string[] values) => this.Add(name, isRequired: false, enumValues: values);
/// <summary>
/// A field kept in the operating system's keyring rather than in the settings file.
/// </summary>
@@ -48,12 +74,14 @@ public sealed class ToolSettingsSchemaBuilder
Required = [..this.requiredNames],
};
private ToolSettingsSchemaBuilder Add(string name, bool isRequired, string optionSource = "", bool isSecret = false)
private ToolSettingsSchemaBuilder Add(string name, bool isRequired, string optionSource = "", bool isSecret = false, IReadOnlyList<string>? enumValues = null)
{
this.properties[name] = new ToolSettingsFieldDefinition
{
OptionSource = optionSource,
EnumValues = enumValues?.ToList() ?? [],
Secret = isSecret,
Group = this.currentGroup,
};
if (isRequired)