Show only On and Off for Brave Mode

This commit is contained in:
Peer Hogeterp committed 2026-09-23 13:18:48 +02:00
1 parent 672abb4082
commit 465497592b
6 files changed
+29 -5

No files matched your search

@@ -41,7 +41,7 @@ public sealed class ReadWebPageTool(WebPageRetrievalService webPageRetrievalServ
.Optional(TIMEOUT_SECONDS_SETTING)
.Optional(MAX_CONTENT_CHARACTERS_SETTING)
.Optional(ALLOWED_PRIVATE_HOSTS_SETTING)
.OptionalEnum(BRAVE_MODE_SETTING, BRAVE_MODE_OFF, BRAVE_MODE_ON)
.OptionalEnumWithDefault(BRAVE_MODE_SETTING, BRAVE_MODE_OFF, BRAVE_MODE_OFF, BRAVE_MODE_ON)
.Build(),
SystemPromptInstructions = BuildSystemPromptInstructions(BRAVE_MODE_OFF),
@@ -13,6 +13,12 @@ public sealed class ToolSettingsFieldDefinition
[JsonPropertyName("enum")]
public List<string> EnumValues { get; init; } = [];
/// <summary>
/// Value shown and saved for an optional choice when no value has been stored yet.
/// A choice with a default does not offer a separate "Not set" option.
/// </summary>
public string DefaultValue { get; init; } = string.Empty;
/// <summary>
/// Name of a list of options the app maintains, as an alternative to spelling them out in
/// the enum field. See the tool settings option sources for the available names.
@@ -44,4 +50,4 @@ public sealed class ToolSettingsFieldDefinition
public IReadOnlyList<ToolSettingsOption> GetOptions() => string.IsNullOrWhiteSpace(this.OptionSource)
? this.EnumValues.Select(value => new ToolSettingsOption(value, value)).ToList()
: ToolSettingsOptionSources.Resolve(this.OptionSource);
}
}
@@ -61,6 +61,9 @@ public sealed class ToolSettingsSchemaBuilder
/// </remarks>
public ToolSettingsSchemaBuilder OptionalEnum(string name, params string[] values) => this.Add(name, isRequired: false, enumValues: values);
public ToolSettingsSchemaBuilder OptionalEnumWithDefault(string name, string defaultValue, params string[] values) =>
this.Add(name, isRequired: false, enumValues: values, defaultValue: defaultValue);
/// <summary>
/// A field kept in the operating system's keyring rather than in the settings file.
/// </summary>
@@ -74,12 +77,13 @@ public sealed class ToolSettingsSchemaBuilder
Required = [..this.requiredNames],
};
private ToolSettingsSchemaBuilder Add(string name, bool isRequired, string optionSource = "", bool isSecret = false, IReadOnlyList<string>? enumValues = null)
private ToolSettingsSchemaBuilder Add(string name, bool isRequired, string optionSource = "", bool isSecret = false, IReadOnlyList<string>? enumValues = null, string defaultValue = "")
{
this.properties[name] = new ToolSettingsFieldDefinition
{
OptionSource = optionSource,
EnumValues = enumValues?.ToList() ?? [],
DefaultValue = defaultValue,
Secret = isSecret,
Group = this.currentGroup,
};
@@ -89,4 +93,4 @@ public sealed class ToolSettingsSchemaBuilder
return this;
}
}
}