using AIStudio.Settings.DataModel; using Lua; namespace AIStudio.Tools.PluginSystem; /// /// Describes one type of configuration object which configuration plugins provide, such as LLM /// providers or chat templates. /// /// /// Whatever treats every type of configuration object alike goes through these descriptors, so that /// none of these places can forget a type: reading the objects from a configuration plugin, removing /// those a plugin no longer defines, and leaving all of them out of a backup. A new type of /// configuration object needs a descriptor in PluginConfigurationObjectDescriptors, and every such place /// handles it. /// public abstract class PluginConfigurationObjectDescriptor { /// /// The type of the configuration objects. /// public abstract PluginConfigurationObjectType Type { get; } /// /// Reads the configuration objects of this type which a configuration plugin defines, and stores /// them in the settings unless the plugin is only checked. /// /// The main table of the configuration plugin. /// The configuration plugin. /// The list to which every object read is added. /// Whether the plugin is only checked, e.g., before an import. Nothing is stored then. /// The directory of the plugin, which paths in the objects are relative to. /// True when the plugin defines a table for this type. public abstract bool TryParse(LuaTable mainTable, Guid configPluginId, List configObjects, bool dryRun, string pluginPath); /// /// Removes the configuration objects of this type which belong to a configuration plugin that is /// gone or no longer defines them, along with their secrets and tokenizers. /// /// The plugins AI Studio found. /// The configuration plugins an organization deployed, including those which could not be loaded. /// The configuration plugins which were loaded, but did not start. /// The configuration objects all running configuration plugins define. /// True when the settings changed. public abstract Task CleanLeftOverAsync(IList availablePlugins, IReadOnlySet deployedEnterpriseConfigPluginIds, IReadOnlySet notStartedConfigPluginIds, IList configObjectList); /// /// Removes the configuration objects of this type which a configuration plugin manages. /// /// The settings to change, e.g., a copy for a backup. Never the settings AI Studio runs with. /// How many objects were removed. public abstract int RemovePluginObjects(Data settings); }