mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 16:17:59 +00:00
Added mailboxes as local data sources (#1022)
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
This commit is contained in:
1 parent
93be539e50
commit
c4400c0ff6
343 files changed
+26051
-3122
No files matched your search
@@ -8,8 +8,11 @@ namespace AIStudio.Dialogs.Settings;
|
||||
|
||||
public partial class ToolSettingsExportDialog : SettingsDialogBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The ID of the collection whose settings to export. The ID of one of its tools stands for the whole collection.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string ToolId { get; set; } = string.Empty;
|
||||
public string CollectionId { get; set; } = string.Empty;
|
||||
|
||||
[Inject]
|
||||
private ToolRegistry ToolRegistry { get; init; } = null!;
|
||||
@@ -20,12 +23,11 @@ public partial class ToolSettingsExportDialog : SettingsDialogBase
|
||||
[Inject]
|
||||
private ILogger<ToolSettingsExportDialog> Logger { get; init; } = null!;
|
||||
|
||||
private ToolDefinition? toolDefinition;
|
||||
private IToolImplementation? implementation;
|
||||
private IReadOnlyList<ExportableSettings> areas = [];
|
||||
private ToolCatalogItem? item;
|
||||
private IReadOnlyList<ToolSettingsExportArea> areas = [];
|
||||
private HashSet<string> selectedAreaIds = new(StringComparer.Ordinal);
|
||||
private HashSet<string> configuredSecretFields = new(StringComparer.Ordinal);
|
||||
private HashSet<string> emptyFieldNames = new(StringComparer.Ordinal);
|
||||
private readonly HashSet<ToolField> configuredSecretFields = [];
|
||||
private readonly HashSet<ToolField> emptyFields = [];
|
||||
private ToolSettingsExportMode mode = ToolSettingsExportMode.LOCKED;
|
||||
private bool includeSecrets;
|
||||
private bool includeMinimumProviderConfidence = true;
|
||||
@@ -39,7 +41,7 @@ public partial class ToolSettingsExportDialog : SettingsDialogBase
|
||||
|
||||
private bool AllAreasSelected => this.areas.Count > 0 && this.areas.All(area => this.selectedAreaIds.Contains(area.Id));
|
||||
|
||||
private bool HasSelectedSecrets => this.areas.Any(area => this.selectedAreaIds.Contains(area.Id) && area.FieldNames.Any(this.configuredSecretFields.Contains));
|
||||
private bool HasSelectedSecrets => this.SelectedFields.Any(this.configuredSecretFields.Contains);
|
||||
|
||||
private bool CanIncludeSecrets => this.HasSelectedSecrets && PluginFactory.EnterpriseEncryption?.IsAvailable is true;
|
||||
|
||||
@@ -51,16 +53,20 @@ public partial class ToolSettingsExportDialog : SettingsDialogBase
|
||||
/// the administrator never filled in still exports. Locked, those empty values are what the
|
||||
/// recipient is left with and cannot change, which is worth saying before the export.
|
||||
/// </remarks>
|
||||
private int EmptySelectedFieldCount => this.areas
|
||||
private int EmptySelectedFieldCount => this.SelectedFields.Count(this.emptyFields.Contains);
|
||||
|
||||
/// <summary>
|
||||
/// The fields of all selected areas, each once.
|
||||
/// </summary>
|
||||
private IEnumerable<ToolField> SelectedFields => this.areas
|
||||
.Where(area => this.selectedAreaIds.Contains(area.Id))
|
||||
.SelectMany(area => area.FieldNames)
|
||||
.Distinct(StringComparer.Ordinal)
|
||||
.Count(this.emptyFieldNames.Contains);
|
||||
.SelectMany(area => area.Area.FieldNames.Select(fieldName => new ToolField(area.Tool.Definition.Id, fieldName)))
|
||||
.Distinct();
|
||||
|
||||
private bool WarnAboutEmptyLockedSettings => this.mode is ToolSettingsExportMode.LOCKED && this.EmptySelectedFieldCount > 0;
|
||||
|
||||
private bool CanExport => this.IsAdmin && !this.isLoading && !this.isExporting && !this.isDisposed &&
|
||||
this.toolDefinition is not null && this.implementation is not null && (this.selectedAreaIds.Count > 0 || this.includeMinimumProviderConfidence);
|
||||
this.item is not null && (this.selectedAreaIds.Count > 0 || this.includeMinimumProviderConfidence);
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -73,40 +79,38 @@ public partial class ToolSettingsExportDialog : SettingsDialogBase
|
||||
|
||||
try
|
||||
{
|
||||
this.toolDefinition = this.ToolRegistry.GetDefinition(this.ToolId);
|
||||
if (this.toolDefinition is null)
|
||||
this.item = await this.ToolRegistry.GetCatalogItemAsync(this.CollectionId);
|
||||
if (this.item is null)
|
||||
return;
|
||||
|
||||
this.implementation = this.ToolRegistry.GetImplementation(this.toolDefinition.ImplementationKey);
|
||||
if (this.implementation is null)
|
||||
return;
|
||||
|
||||
this.areas = this.implementation.GetExportableSettings(this.toolDefinition);
|
||||
this.areas = ToolSettingsService.GetExportAreas(this.item.Tools);
|
||||
this.selectedAreaIds = this.areas.Select(area => area.Id).ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
// Retain only field names, never the values themselves, so no plaintext secret lives
|
||||
// in this component. ExportAsync reads effective settings again when the
|
||||
// administrator exports.
|
||||
var values = await this.ToolSettingsService.GetSettingsAsync(this.toolDefinition);
|
||||
this.configuredSecretFields = this.toolDefinition.SettingsSchema.Properties
|
||||
.Where(property => property.Value.Secret && values.TryGetValue(property.Key, out var value) && !string.IsNullOrWhiteSpace(value))
|
||||
.Select(property => property.Key)
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
foreach (var tool in this.item.Tools)
|
||||
{
|
||||
var values = await this.ToolSettingsService.GetSettingsAsync(tool.Definition);
|
||||
var properties = tool.Definition.SettingsSchema.Properties;
|
||||
this.configuredSecretFields.UnionWith(properties
|
||||
.Where(property => property.Value.Secret && values.TryGetValue(property.Key, out var value) && !string.IsNullOrWhiteSpace(value))
|
||||
.Select(property => new ToolField(tool.Definition.Id, property.Key)));
|
||||
|
||||
// A field the export writes as an empty value: it has to be present, because a
|
||||
// missing one is skipped rather than exported, and it has to be a non-secret,
|
||||
// because an empty secret is skipped as well.
|
||||
this.emptyFieldNames = this.toolDefinition.SettingsSchema.Properties
|
||||
.Where(property => !property.Value.Secret && values.TryGetValue(property.Key, out var value) && string.IsNullOrWhiteSpace(value))
|
||||
.Select(property => property.Key)
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
// A field the export writes as an empty value: it has to be present, because a
|
||||
// missing one is skipped rather than exported, and it has to be a non-secret,
|
||||
// because an empty secret is skipped as well.
|
||||
this.emptyFields.UnionWith(properties
|
||||
.Where(property => !property.Value.Secret && values.TryGetValue(property.Key, out var value) && string.IsNullOrWhiteSpace(value))
|
||||
.Select(property => new ToolField(tool.Definition.Id, property.Key)));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// A runtime error may contain secret data, so it goes to the log for diagnosis but
|
||||
// never into the dialog:
|
||||
this.Logger.LogError(e, "Failed to load the configuration of the tool '{ToolId}' for export.", this.ToolId);
|
||||
this.toolDefinition = null;
|
||||
this.Logger.LogError(e, "Failed to load the configuration of the tool collection '{CollectionId}' for export.", this.CollectionId);
|
||||
this.item = null;
|
||||
this.message = T("The tool configuration could not be loaded. Please close this dialog and try again.");
|
||||
}
|
||||
finally
|
||||
@@ -142,13 +146,13 @@ public partial class ToolSettingsExportDialog : SettingsDialogBase
|
||||
|
||||
private string GetMinimumProviderConfidenceName()
|
||||
{
|
||||
var confidence = this.toolDefinition is null ? ConfidenceLevel.NONE : this.ToolRegistry.GetMinimumProviderConfidence(this.toolDefinition);
|
||||
var confidence = this.item is null ? ConfidenceLevel.NONE : this.ToolRegistry.GetMinimumProviderConfidence(this.item.Id);
|
||||
return confidence is ConfidenceLevel.NONE ? T("No minimum confidence level chosen") : confidence.GetName();
|
||||
}
|
||||
|
||||
private async Task Export()
|
||||
{
|
||||
if (!this.CanExport || this.toolDefinition is null || this.implementation is null)
|
||||
if (!this.CanExport || this.item is null)
|
||||
return;
|
||||
|
||||
this.isExporting = true;
|
||||
@@ -164,7 +168,7 @@ public partial class ToolSettingsExportDialog : SettingsDialogBase
|
||||
IncludeMinimumProviderConfidence = this.includeMinimumProviderConfidence,
|
||||
};
|
||||
|
||||
var result = await this.ToolSettingsService.ExportAsync(this.toolDefinition, this.implementation, options);
|
||||
var result = await this.ToolSettingsService.ExportAsync(this.item.Tools, options, this.item.Id, this.ToolRegistry.GetMinimumProviderConfidence(this.item.Id));
|
||||
if (this.isDisposed || !this.IsAdmin)
|
||||
return;
|
||||
|
||||
@@ -187,7 +191,7 @@ public partial class ToolSettingsExportDialog : SettingsDialogBase
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.Logger.LogError(e, "Failed to export the configuration of the tool '{ToolId}'.", this.ToolId);
|
||||
this.Logger.LogError(e, "Failed to export the configuration of the tool collection '{CollectionId}'.", this.CollectionId);
|
||||
this.message = T("The tool configuration could not be exported. Please try again.");
|
||||
}
|
||||
finally
|
||||
@@ -201,4 +205,9 @@ public partial class ToolSettingsExportDialog : SettingsDialogBase
|
||||
this.isDisposed = true;
|
||||
base.DisposeResources();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One settings field of one tool. A collection may hold two tools whose fields share a name.
|
||||
/// </summary>
|
||||
private readonly record struct ToolField(string ToolId, string FieldName);
|
||||
}
|
||||
Reference in new issue
Block a user