mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-13 07:13:48 +00:00
Improved local plugin handling (share, import, delete) (#900)
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 / 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 / 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
0eb747b386
commit
6e143aafaa
47 files changed
+3108
-1480
No files matched your search
@@ -58,7 +58,7 @@
|
||||
<AdditionalActions>
|
||||
@if (availablePlugin is not null)
|
||||
{
|
||||
<AssistantPluginDeleteAction Plugin="@availablePlugin" />
|
||||
<PluginDeleteAction Plugin="@availablePlugin" />
|
||||
}
|
||||
</AdditionalActions>
|
||||
<SecurityBadge>
|
||||
|
||||
@@ -158,6 +158,31 @@
|
||||
break;
|
||||
}
|
||||
|
||||
@*
|
||||
A staged test configuration speaks for the organization without anybody
|
||||
having deployed it. We report it without the details having to be expanded:
|
||||
*@
|
||||
@if (this.testConfigPlugins.Count > 0)
|
||||
{
|
||||
<MudText Typo="Typo.body1" Class="mt-2">
|
||||
@T("A test configuration is active. It acts like a configuration of your organization and may, for example, approve assistant plugins. AI Studio removes it the next time you start the app.")
|
||||
</MudText>
|
||||
@foreach (var testConfigPlugin in this.testConfigPlugins)
|
||||
{
|
||||
<ConfigPluginInfoCard HeaderIcon="@Icons.Material.Filled.Science"
|
||||
HeaderText="@testConfigPlugin.Name"
|
||||
Items="@this.BuildTestConfigurationItems(testConfigPlugin)"
|
||||
ShowWarning="@true"
|
||||
WarningText="@T("Test configuration: nobody deployed this configuration. It is valid until you restart AI Studio.")"/>
|
||||
}
|
||||
}
|
||||
else if (PluginFactory.RemovedTestConfigurationsAtStartup > 0)
|
||||
{
|
||||
<MudText Typo="Typo.body1" Class="mt-2">
|
||||
@string.Format(T("AI Studio removed {0} test configuration(s) while starting. A test configuration is valid for one session: place it again while AI Studio is running."), PluginFactory.RemovedTestConfigurationsAtStartup)
|
||||
</MudText>
|
||||
}
|
||||
|
||||
@if (this.HasEnterpriseConfigurationDetails)
|
||||
{
|
||||
<MudButton StartIcon="@(this.showEnterpriseConfigDetails ? Icons.Material.Filled.ExpandLess : Icons.Material.Filled.ExpandMore)"
|
||||
|
||||
@@ -107,10 +107,16 @@ public partial class Information : MSGComponentBase
|
||||
private bool showVectorStoreDetails;
|
||||
private bool showExternalHttpCustomRootCertificateDetails;
|
||||
|
||||
private List<IAvailablePlugin> configPlugins = PluginFactory.AvailablePlugins
|
||||
.Where(x => x.Type is PluginType.CONFIGURATION)
|
||||
.OfType<IAvailablePlugin>()
|
||||
.ToList();
|
||||
private List<IAvailablePlugin> configPlugins = [];
|
||||
|
||||
/// <summary>
|
||||
/// The configuration plugins an administrator staged for a test.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// They are kept apart from the other configuration plugins: nobody deployed them, yet they act
|
||||
/// on behalf of the organization while they are loaded. That deserves its own note.
|
||||
/// </remarks>
|
||||
private List<IAvailablePlugin> testConfigPlugins = [];
|
||||
|
||||
private List<EnterpriseEnvironment> enterpriseEnvironments = EnterpriseEnvironmentService.CURRENT_ENVIRONMENTS.ToList();
|
||||
|
||||
@@ -201,11 +207,14 @@ public partial class Information : MSGComponentBase
|
||||
|
||||
private void RefreshEnterpriseConfigurationState()
|
||||
{
|
||||
this.configPlugins = PluginFactory.AvailablePlugins
|
||||
var availableConfigPlugins = PluginFactory.AvailablePlugins
|
||||
.Where(x => x.Type is PluginType.CONFIGURATION)
|
||||
.OfType<IAvailablePlugin>()
|
||||
.ToList();
|
||||
|
||||
this.testConfigPlugins = availableConfigPlugins.Where(plugin => PluginFactory.IsEnterpriseTestConfigurationPath(plugin.LocalPath)).ToList();
|
||||
this.configPlugins = availableConfigPlugins.Except(this.testConfigPlugins).ToList();
|
||||
|
||||
this.enterpriseEnvironments = EnterpriseEnvironmentService.CURRENT_ENVIRONMENTS.ToList();
|
||||
this.mandatoryInfoPanels = PluginFactory.GetMandatoryInfos()
|
||||
.Select(info =>
|
||||
@@ -404,6 +413,27 @@ public partial class Information : MSGComponentBase
|
||||
return plugin.ManagedConfigurationId == configurationId && plugin.Id != configurationId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collects what a user needs to find and judge a staged test configuration.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// There is no enterprise environment behind it, so we show what identifies it instead: the plugin
|
||||
/// ID it claims and the directory it was staged in.
|
||||
/// </remarks>
|
||||
private IReadOnlyList<ConfigInfoRowItem> BuildTestConfigurationItems(IAvailablePlugin plugin) =>
|
||||
[
|
||||
new(Icons.Material.Filled.ArrowRightAlt,
|
||||
$"{T("Configuration plugin ID:")} {plugin.Id}",
|
||||
plugin.Id.ToString(),
|
||||
T("Copies the configuration plugin ID to the clipboard")),
|
||||
|
||||
new(Icons.Material.Filled.ArrowRightAlt,
|
||||
$"{T("Plugin directory:")} {plugin.LocalPath}",
|
||||
plugin.LocalPath,
|
||||
T("Copies the plugin directory to the clipboard"),
|
||||
"margin-top: 4px;"),
|
||||
];
|
||||
|
||||
private string ExternalHttpCustomRootCertificateWarningText
|
||||
{
|
||||
get
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</MudText>
|
||||
<MudSpacer />
|
||||
<LockableButton Text="@T("Import")"
|
||||
Tooltip="@T("Import assistant plugin")"
|
||||
Tooltip="@T("Import plugin from a file")"
|
||||
Icon="@IMPORT_ICON"
|
||||
ButtonVariant="Variant.Outlined"
|
||||
ButtonColor="Color.Default"
|
||||
@@ -138,7 +138,7 @@
|
||||
|
||||
@if (context is IAvailablePlugin availablePlugin)
|
||||
{
|
||||
<AssistantPluginDeleteAction Plugin="@availablePlugin" />
|
||||
<PluginDeleteAction Plugin="@availablePlugin" />
|
||||
}
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
|
||||
@@ -36,7 +36,7 @@ public partial class Plugins : MSGComponentBase
|
||||
private RustService RustService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private AssistantPluginInstallService AssistantPluginInstallService { get; init; } = null!;
|
||||
private PluginInstallService PluginInstallService { get; init; } = null!;
|
||||
|
||||
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger(nameof(Plugins));
|
||||
|
||||
@@ -236,11 +236,16 @@ public partial class Plugins : MSGComponentBase
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sharing is limited to assistant plugins because the import accepts only those. Otherwise,
|
||||
/// users would create archives nobody can install. Widen this once the import supports more
|
||||
/// plugin types.
|
||||
/// The plugin types users may share. This list has to match what the import accepts, otherwise
|
||||
/// users would create archives nobody can install.
|
||||
/// </summary>
|
||||
private static bool CanSharePlugin(IAvailablePlugin plugin) => plugin is { IsInternal: false, IsManagedByConfigServer: false, Type: PluginType.ASSISTANT } && !string.IsNullOrWhiteSpace(plugin.LocalPath);
|
||||
private static readonly PluginType[] SHAREABLE_PLUGIN_TYPES = [PluginType.ASSISTANT, PluginType.CONFIGURATION, PluginType.LANGUAGE];
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a plugin may be shared or exported as an archive. Plugins shipped with
|
||||
/// AI Studio and plugins deployed by an organization stay with their owner.
|
||||
/// </summary>
|
||||
private static bool CanSharePlugin(IAvailablePlugin plugin) => plugin is { IsInternal: false, IsManagedByConfigServer: false } && SHAREABLE_PLUGIN_TYPES.Contains(plugin.Type) && !string.IsNullOrWhiteSpace(plugin.LocalPath);
|
||||
|
||||
/// <summary>
|
||||
/// Highlights the plugin table while the user drags a file over the page, so it is visible
|
||||
@@ -354,7 +359,7 @@ public partial class Plugins : MSGComponentBase
|
||||
if (!this.AllowPluginImport)
|
||||
return;
|
||||
|
||||
var selection = await this.RustService.SelectFile(this.T("Import assistant plugin"), [FileTypes.PLUGIN_ARCHIVE]);
|
||||
var selection = await this.RustService.SelectFile(this.T("Import plugin"), [FileTypes.PLUGIN_ARCHIVE]);
|
||||
if (selection.UserCancelled)
|
||||
return;
|
||||
|
||||
@@ -379,7 +384,7 @@ public partial class Plugins : MSGComponentBase
|
||||
|
||||
try
|
||||
{
|
||||
var result = await this.AssistantPluginInstallService.InstallArchiveAsync(archivePath, this.ConfirmPluginImportAsync, CancellationToken.None);
|
||||
var result = await this.PluginInstallService.InstallArchiveAsync(archivePath, this.ConfirmPluginImportAsync, CancellationToken.None);
|
||||
if (result.Cancelled)
|
||||
return;
|
||||
|
||||
@@ -394,8 +399,8 @@ public partial class Plugins : MSGComponentBase
|
||||
}
|
||||
|
||||
var message = result.ReplacedExisting
|
||||
? this.T("Assistant updated.")
|
||||
: this.T("Assistant installed.");
|
||||
? this.T("Plugin updated.")
|
||||
: this.T("Plugin installed.");
|
||||
|
||||
// We do not announce the reload ourselves: a successful installation ran LoadAll, which
|
||||
// already sent PLUGINS_RELOADED. The import changes no settings either, so there is
|
||||
|
||||
Reference in new issue
Block a user