skip dialog and audit automatically if this is what the settings demand

This commit is contained in:
krut_ni 2026-04-07 16:54:33 +02:00
parent b6a174929a
commit 67d39557bb
No known key found for this signature in database
GPG Key ID: A5C0151B4DDB172C
3 changed files with 30 additions and 1 deletions

View File

@ -23,6 +23,9 @@ public partial class Plugins : MSGComponentBase
[Inject]
private IDialogService DialogService { get; init; } = null!;
[Inject]
private AssistantPluginAuditService AssistantPluginAuditService { get; init; } = null!;
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
@ -72,6 +75,31 @@ public partial class Plugins : MSGComponentBase
return;
var securityState = PluginAssistantSecurityResolver.Resolve(this.SettingsManager, assistantPlugin);
if (securityState.RequiresAudit)
{
if (this.AssistantPluginAuditSettings.AutomaticallyAuditAssistants)
{
var audit = await this.AssistantPluginAuditService.RunAuditAsync(assistantPlugin);
if (audit.Level is AssistantAuditLevel.UNKNOWN)
{
await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.SettingsSuggest, string.Format(T("The Audit returned an invalid result, please try again."))));
await this.OpenAssistantAuditDialogAsync(pluginMeta.Id);
return;
}
this.UpsertAuditCard(audit);
await this.SettingsManager.StoreSettings();
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
securityState = PluginAssistantSecurityResolver.Resolve(this.SettingsManager, assistantPlugin);
}
else
{
await this.OpenAssistantAuditDialogAsync(pluginMeta.Id);
return;
}
}
if (securityState.RequiresAudit)
{
await this.OpenAssistantAuditDialogAsync(pluginMeta.Id);

View File

@ -4,6 +4,7 @@ using AIStudio.Settings;
using AIStudio.Tools.Databases;
using AIStudio.Tools.Databases.Qdrant;
using AIStudio.Tools.PluginSystem;
using AIStudio.Tools.PluginSystem.Assistants;
using AIStudio.Tools.Services;
using Microsoft.AspNetCore.Server.Kestrel.Core;
@ -178,6 +179,7 @@ internal sealed class Program
builder.Services.AddTransient<AgentRetrievalContextValidation>();
builder.Services.AddTransient<AgentTextContentCleaner>();
builder.Services.AddTransient<AssistantAuditAgent>();
builder.Services.AddTransient<AssistantPluginAuditService>();
builder.Services.AddHostedService<UpdateService>();
builder.Services.AddHostedService<TemporaryChatService>();
builder.Services.AddHostedService<EnterpriseEnvironmentService>();

View File

@ -254,7 +254,6 @@ public static partial class PluginFactory
wasConfigurationChanged = true;
// Check if security audits are invoked automatically and transparent for the user
// TODO: USE THIS SETTING
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.AssistantPluginAudit, x => x.AutomaticallyAuditAssistants, AVAILABLE_PLUGINS))
wasConfigurationChanged = true;