Renamed the settings of AI tasks (#1239)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-27 12:08:00 +01:00
1 parent d19d3d431b
commit a117074972
109 files changed
+3929 -538

No files matched your search

@@ -14,10 +14,10 @@ internal sealed class AssistantWebContentReader : StatefulAssistantComponentBase
set => this.Props[nameof(this.Preselect)] = value;
}
public bool PreselectContentCleanerAgent
public bool PreselectContentCleaner
{
get => this.Props.TryGetValue(nameof(this.PreselectContentCleanerAgent), out var v) && v is true;
set => this.Props[nameof(this.PreselectContentCleanerAgent)] = value;
get => this.Props.TryGetValue(nameof(this.PreselectContentCleaner), out var v) && v is true;
set => this.Props[nameof(this.PreselectContentCleaner)] = value;
}
public string Class
@@ -41,7 +41,7 @@ internal sealed class AssistantWebContentReader : StatefulAssistantComponentBase
state.WebContent[this.Name] = new WebContentState
{
Preselect = this.Preselect,
PreselectContentCleanerAgent = this.PreselectContentCleanerAgent,
PreselectContentCleaner = this.PreselectContentCleaner,
};
}
}
@@ -77,8 +77,13 @@ public static class ComponentPropSpecs
),
[AssistantComponentType.WEB_CONTENT_READER] = new(
required: ["Name"],
optional: ["UserPrompt", "Preselect", "PreselectContentCleanerAgent", "Class", "Style"],
nonWriteable: ["Name", "UserPrompt", "Class", "Style" ]
optional: ["UserPrompt", "Preselect", "PreselectContentCleaner", "Class", "Style"],
nonWriteable: ["Name", "UserPrompt", "Class", "Style" ],
formerNames: new Dictionary<string, string>
{
// The name before v26.11.2, when the content cleaner was called an agent:
["PreselectContentCleanerAgent"] = "PreselectContentCleaner",
}
),
[AssistantComponentType.FILE_CONTENT_READER] = new(
required: ["Name"],
@@ -1,5 +1,7 @@
using System.Collections.Immutable;
using Lua;
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class PropSpec(
@@ -7,7 +9,8 @@ public class PropSpec(
IEnumerable<string> optional,
IEnumerable<string>? nonReadable = null,
IEnumerable<string>? nonWriteable = null,
IEnumerable<string>? confidential = null)
IEnumerable<string>? confidential = null,
IReadOnlyDictionary<string, string>? formerNames = null)
{
public ImmutableArray<string> Required { get; } = MaterializeDistinct(required);
public ImmutableArray<string> Optional { get; } = MaterializeDistinct(optional);
@@ -15,6 +18,56 @@ public class PropSpec(
public ImmutableArray<string> NonReadable { get; } = MaterializeDistinct((nonReadable ?? []).Concat(confidential ?? []));
public ImmutableArray<string> NonWriteable { get; } = MaterializeDistinct((nonWriteable ?? []).Concat(confidential ?? []));
/// <summary>
/// The current name of each prop which had another name before, by that former name.
/// </summary>
/// <remarks>
/// Plugins keep using a former name for good, also in the props their callbacks return: a plugin
/// which changes it needs a new security audit. When a plugin uses both names, the current one
/// wins. Callbacks see a prop under its current name only.
/// </remarks>
public ImmutableDictionary<string, string> FormerNames { get; } = (formerNames ?? ImmutableDictionary<string, string>.Empty).ToImmutableDictionary(StringComparer.Ordinal);
/// <summary>
/// Reads a prop from the props of a component, under its current name or under a former name
/// which the plugin still uses.
/// </summary>
/// <param name="propsTable">The props of the component, as the plugin defines them.</param>
/// <param name="name">The current name of the prop.</param>
/// <param name="value">The value of the prop, when the plugin defines it.</param>
/// <returns>True, when the plugin defines the prop.</returns>
public bool TryGetValue(LuaTable propsTable, string name, out LuaValue value)
{
if (propsTable.TryGetValue(name, out value))
return true;
foreach (var (formerName, currentName) in this.FormerNames)
if (string.Equals(currentName, name, StringComparison.Ordinal) && propsTable.TryGetValue(formerName, out value))
return true;
return false;
}
/// <summary>
/// Determines the current name of a prop which a plugin names in its props, e.g., in an update
/// a callback returns.
/// </summary>
/// <param name="name">The name the plugin uses.</param>
/// <param name="propsTable">The props in which the plugin uses the name.</param>
/// <param name="currentName">The current name of the prop. It is the given name, unless that is a former one.</param>
/// <returns>False, when the plugin uses a former name next to the current one, which wins.</returns>
public bool TryGetCurrentName(string name, LuaTable propsTable, out string currentName)
{
if (!this.FormerNames.TryGetValue(name, out var nameAfterRenaming))
{
currentName = name;
return true;
}
currentName = nameAfterRenaming;
return !propsTable.TryGetValue(currentName, out _);
}
private static ImmutableArray<string> MaterializeDistinct(IEnumerable<string> source)
{
return source.Distinct(StringComparer.Ordinal).ToImmutableArray();