diff --git a/app/Build/Commands/AssistantPluginHashCommand.cs b/app/Build/Commands/AssistantPluginHashCommand.cs new file mode 100644 index 00000000..8d7552e4 --- /dev/null +++ b/app/Build/Commands/AssistantPluginHashCommand.cs @@ -0,0 +1,47 @@ +using SharedTools; + +namespace Build.Commands; + +public sealed class AssistantPluginHashCommand +{ + [Command("assistant-plugin-hash", Description = "Compute the canonical assistant-plugin hash for a plugin directory")] + public void ComputeAssistantPluginHash( + [Argument(Description = "Path to the assistant plugin directory")] string pluginDir, + [Option("lua-snippet", Description = "Also print a Lua snippet for CONFIG[\"SETTINGS\"]")] bool luaSnippet = false) + { + if (!Environment.IsWorkingDirectoryValid()) + return; + + var resolvedPath = Path.GetFullPath(pluginDir, Directory.GetCurrentDirectory()); + if (!Directory.Exists(resolvedPath)) + { + Console.WriteLine($"- Error: The plugin directory '{resolvedPath}' does not exist."); + return; + } + + var pluginHash = AssistantPluginHash.Compute(resolvedPath); + if (string.IsNullOrWhiteSpace(pluginHash)) + { + Console.WriteLine($"- Error: No Lua files were found in '{resolvedPath}'."); + return; + } + + Console.WriteLine(pluginHash); + + if (!luaSnippet) + return; + + var displayName = Path.GetFileName(resolvedPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)); + var approvedAtUtc = DateTimeOffset.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"); + Console.WriteLine(); + Console.WriteLine("""CONFIG["SETTINGS"]["DataAssistantPluginAudit.EnterpriseApprovedPlugins"] = {"""); + Console.WriteLine(" {"); + Console.WriteLine($""" ["PluginHash"] = "{pluginHash}","""); + Console.WriteLine($""" ["DisplayName"] = "{displayName}","""); + Console.WriteLine(""" ["Comment"] = "","""); + Console.WriteLine(""" ["ApprovedBy"] = "","""); + Console.WriteLine($""" ["ApprovedAtUtc"] = "{approvedAtUtc}","""); + Console.WriteLine(" }"); + Console.WriteLine("}"); + } +} diff --git a/app/Build/Program.cs b/app/Build/Program.cs index e7744b36..f56078de 100644 --- a/app/Build/Program.cs +++ b/app/Build/Program.cs @@ -6,4 +6,5 @@ app.AddCommands(); app.AddCommands(); app.AddCommands(); app.AddCommands(); -app.Run(); \ No newline at end of file +app.AddCommands(); +app.Run(); diff --git a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua index db8484ce..9dc77466 100644 --- a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua +++ b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua @@ -2005,6 +2005,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T661906146"] = "The resul -- Show or hide the detailed security information. UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1045105126"] = "Show or hide the detailed security information." +-- This plugin is approved by your organization. A manual security audit is not required. +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1213338416"] = "This plugin is approved by your organization. A manual security audit is not required." + -- Assistant Audit UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1506922856"] = "Assistant Audit" @@ -2020,6 +2023,12 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1805629238" -- Assistant Security UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T1841954939"] = "Assistant Security" +-- Company approved +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2036497459"] = "Company approved" + +-- Approved name +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2282386733"] = "Approved name" + -- Required minimum UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2354026284"] = "Required minimum" @@ -2029,6 +2038,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2757790517" -- Technical Details UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2769062110"] = "Technical Details" +-- Approval comment +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T2906887599"] = "Approval comment" + -- No audit yet UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3138877447"] = "No audit yet" @@ -2044,21 +2056,39 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3448155331" -- No stored audit details are available yet. UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3647137899"] = "No stored audit details are available yet." +-- Enterprise approval is active +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3816183955"] = "Enterprise approval is active" + -- Current hash UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3896860082"] = "Current hash" +-- No user audit required +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T3916957031"] = "No user audit required" + -- Audited at UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4103354206"] = "Audited at" +-- Approved hash +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4170340306"] = "Approved hash" + -- No security findings were stored for this assistant plugin. UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4256679240"] = "No security findings were stored for this assistant plugin." +-- Status source +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T4289123040"] = "Status source" + -- Audit hash UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T53507304"] = "Audit hash" -- {0} Finding(s) UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T631393016"] = "{0} Finding(s)" +-- Approved by +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T894543751"] = "Approved by" + +-- Approved at +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTPLUGINSECURITYCARD::T978873131"] = "Approved at" + -- Click the paperclip to attach files, or click the number to see your attached files. UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T1358313858"] = "Click the paperclip to attach files, or click the number to see your attached files." @@ -3457,6 +3487,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3652671056"] = -- Unavailable UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3662391977"] = "Unavailable" +-- This assistant plugin is approved by your organization. A manual security audit is not required. +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T3680374624"] = "This assistant plugin is approved by your organization. A manual security audit is not required." + -- Plugin Structure UI_TEXT_CONTENT["AISTUDIO::DIALOGS::ASSISTANTPLUGINAUDITDIALOG::T371537943"] = "Plugin Structure" @@ -7627,6 +7660,12 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::DATAMODEL::ASSISTANT -- Button UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::DATAMODEL::ASSISTANTCOMPONENTTYPEEXTENSIONS::T864557713"] = "Button" +-- The ASSISTANT table contains an invalid LaunchBehavior value. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T109828905"] = "The ASSISTANT table contains an invalid LaunchBehavior value." + +-- The ASSISTANT table contains an unsupported LaunchBehavior value. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T1194373781"] = "The ASSISTANT table contains an unsupported LaunchBehavior value." + -- Failed to parse the UI render tree from the ASSISTANT lua table. UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T1318499252"] = "Failed to parse the UI render tree from the ASSISTANT lua table." @@ -7642,12 +7681,18 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T2 -- The ASSISTANT lua table does not exist or is not a valid table. UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3017816936"] = "The ASSISTANT lua table does not exist or is not a valid table." +-- The ASSISTANT table contains an empty WorkspaceName for LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME'. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3233001282"] = "The ASSISTANT table contains an empty WorkspaceName for LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME'." + -- The provided ASSISTANT lua table does not contain a valid system prompt. UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3402798667"] = "The provided ASSISTANT lua table does not contain a valid system prompt." -- The ASSISTANT table does not contain a valid system prompt. UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3723171842"] = "The ASSISTANT table does not contain a valid system prompt." +-- The ASSISTANT table contains the LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME' but no valid WorkspaceName. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T4215554842"] = "The ASSISTANT table contains the LaunchBehavior 'OPEN_WORKSPACE_CHAT_BY_NAME' but no valid WorkspaceName." + -- ASSISTANT.BuildPrompt exists but is not a Lua function or has invalid syntax. UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T683382975"] = "ASSISTANT.BuildPrompt exists but is not a Lua function or has invalid syntax." @@ -7690,6 +7735,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR -- The current audit result is '{0}', which is below your required minimum level '{1}'. Audit enforcement is currently disabled, so this assistant plugin can still be enabled or used. UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2774333862"] = "The current audit result is '{0}', which is below your required minimum level '{1}'. Audit enforcement is currently disabled, so this assistant plugin can still be enabled or used." +-- The current plugin hash matches an enterprise-managed approval. No manual security audit is required for activation or usage. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2824524534"] = "The current plugin hash matches an enterprise-managed approval. No manual security audit is required for activation or usage." + -- Not Audited UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T2828154864"] = "Not Audited" @@ -7699,12 +7747,18 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR -- Open Security Check UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T290241209"] = "Open Security Check" +-- User Audit +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3293963409"] = "User Audit" + -- Restricted UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3325062668"] = "Restricted" -- Unknown UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3424652889"] = "Unknown" +-- Approved by your organization +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3508214481"] = "Approved by your organization" + -- Unlocked UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3606159420"] = "Unlocked" @@ -7720,9 +7774,24 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECUR -- No security audit exists yet. Your current security settings do not require an audit before this assistant plugin may be used. UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T3899951594"] = "No security audit exists yet. Your current security settings do not require an audit before this assistant plugin may be used." +-- No Approval +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T515592229"] = "No Approval" + +-- This assistant was approved by your organization. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T538196816"] = "This assistant was approved by your organization." + +-- Safe +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T760494712"] = "Safe" + +-- Open Security Details +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T803119455"] = "Open Security Details" + -- Start Security Check UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T811648299"] = "Start Security Check" +-- This assistant was approved by your organization as '{0}'. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T834246718"] = "This assistant was approved by your organization as '{0}'." + -- This assistant currently has no stored audit. UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTSECURITYRESOLVER::T921972844"] = "This assistant currently has no stored audit." diff --git a/app/MindWork AI Studio/Components/AssistantBlock.razor b/app/MindWork AI Studio/Components/AssistantBlock.razor index b46711c5..efb7eee4 100644 --- a/app/MindWork AI Studio/Components/AssistantBlock.razor +++ b/app/MindWork AI Studio/Components/AssistantBlock.razor @@ -34,9 +34,18 @@ - - @this.ButtonText - + @if (this.HasStartAction) + { + + @this.ButtonText + + } + else + { + + @this.ButtonText + + } @if (this.HasSettingsPanel) { diff --git a/app/MindWork AI Studio/Components/AssistantBlock.razor.cs b/app/MindWork AI Studio/Components/AssistantBlock.razor.cs index 735b2974..985cf659 100644 --- a/app/MindWork AI Studio/Components/AssistantBlock.razor.cs +++ b/app/MindWork AI Studio/Components/AssistantBlock.razor.cs @@ -31,6 +31,9 @@ public partial class AssistantBlock : MSGComponentBase where TSetting [Parameter] public string Link { get; set; } = string.Empty; + [Parameter] + public EventCallback OnClick { get; set; } + [Parameter] public bool Disabled { get; set; } @@ -80,6 +83,8 @@ public partial class AssistantBlock : MSGComponentBase where TSetting private bool HasSettingsPanel => typeof(TSettings) != typeof(NoSettingsPanel); + private bool HasStartAction => this.OnClick.HasDelegate; + /// /// Gets the newest assistant session snapshot represented by this block. /// diff --git a/app/MindWork AI Studio/Components/AssistantPluginSecurityCard.razor b/app/MindWork AI Studio/Components/AssistantPluginSecurityCard.razor index 01012365..e3a77871 100644 --- a/app/MindWork AI Studio/Components/AssistantPluginSecurityCard.razor +++ b/app/MindWork AI Studio/Components/AssistantPluginSecurityCard.razor @@ -33,6 +33,12 @@ @state.AuditLabel + @if (!string.IsNullOrWhiteSpace(state.SourceLabel)) + { + + @state.SourceLabel + + } @if (!string.IsNullOrWhiteSpace(state.AvailabilityLabel)) { @@ -53,18 +59,28 @@ - - - @T("Confidence"): - - - @this.GetConfidenceLabel() - - + @if (state.IsEnterpriseApproved) + { + + + @T("Enterprise approval is active") + + } + else + { + + + @T("Confidence"): + + + @this.GetConfidenceLabel() + + + } @@ -104,12 +120,63 @@ @this.Plugin.Id + + + @T("Status source") + + @state.SourceLabel + @T("Current hash") @GetShortHash(state.CurrentHash) + @if (state.EnterpriseApproval is not null) + { + + + @T("Approved hash") + + @GetShortHash(state.EnterpriseApproval.PluginHash) + + @if (!string.IsNullOrWhiteSpace(state.EnterpriseApproval.DisplayName)) + { + + + @T("Approved name") + + @state.EnterpriseApproval.DisplayName + + } + @if (!string.IsNullOrWhiteSpace(state.EnterpriseApproval.ApprovedBy)) + { + + + @T("Approved by") + + @state.EnterpriseApproval.ApprovedBy + + } + @if (state.EnterpriseApproval.ApprovedAtUtc is not null) + { + + + @T("Approved at") + + @this.FormatFileTimestamp(state.EnterpriseApproval.ApprovedAtUtc.Value.ToLocalTime().DateTime) + + } + @if (!string.IsNullOrWhiteSpace(state.EnterpriseApproval.Comment)) + { + + + @T("Approval comment") + + @state.EnterpriseApproval.Comment + + } + } @if (state.Audit is not null) { @@ -156,9 +223,18 @@ @if (state.Audit is null) { - - @T("No stored audit details are available yet.") - + @if (state.IsEnterpriseApproved) + { + + @T("This plugin is approved by your organization. A manual security audit is not required.") + + } + else + { + + @T("No stored audit details are available yet.") + + } } else if (state.Audit.Findings.Count == 0) { diff --git a/app/MindWork AI Studio/Components/AssistantPluginSecurityCard.razor.cs b/app/MindWork AI Studio/Components/AssistantPluginSecurityCard.razor.cs index 412ca3e8..d1d56291 100644 --- a/app/MindWork AI Studio/Components/AssistantPluginSecurityCard.razor.cs +++ b/app/MindWork AI Studio/Components/AssistantPluginSecurityCard.razor.cs @@ -103,12 +103,23 @@ public partial class AssistantPluginSecurityCard : MSGComponentBase private string GetFindingSummary() { + if (this.SecurityState.IsEnterpriseApproved) + return this.T("No user audit required"); + var count = this.SecurityState.Audit?.Findings.Count ?? 0; return string.Format(this.T("{0} Finding(s)"), count); } private string GetAuditTimestampLabel() { + if (this.SecurityState.IsEnterpriseApproved) + { + var approvedAt = this.SecurityState.EnterpriseApproval?.ApprovedAtUtc; + return approvedAt is null + ? this.T("Company approved") + : this.FormatFileTimestamp(approvedAt.Value.ToLocalTime().DateTime); + } + var auditedAt = this.SecurityState.Audit?.AuditedAtUtc; return auditedAt is null ? this.T("No audit yet") diff --git a/app/MindWork AI Studio/Dialogs/AssistantPluginAuditDialog.razor b/app/MindWork AI Studio/Dialogs/AssistantPluginAuditDialog.razor index 637f3329..64867e09 100644 --- a/app/MindWork AI Studio/Dialogs/AssistantPluginAuditDialog.razor +++ b/app/MindWork AI Studio/Dialogs/AssistantPluginAuditDialog.razor @@ -12,9 +12,18 @@ else { - - @T("This security check uses a sample prompt preview. Empty or placeholder values in the preview are expected.") - + @if (this.securityState.IsEnterpriseApproved) + { + + @T("This assistant plugin is approved by your organization. A manual security audit is not required.") + + } + else + { + + @T("This security check uses a sample prompt preview. Empty or placeholder values in the preview are expected.") + + } @this.plugin.Name @@ -298,9 +307,12 @@ @(this.audit is null ? T("Cancel") : T("Close")) - - @T("Start Security Check") - + @if (!this.securityState.IsEnterpriseApproved) + { + + @T("Start Security Check") + + } @if (this.CanEnablePlugin) { diff --git a/app/MindWork AI Studio/Dialogs/AssistantPluginAuditDialog.razor.cs b/app/MindWork AI Studio/Dialogs/AssistantPluginAuditDialog.razor.cs index 122b6e40..2d85e400 100644 --- a/app/MindWork AI Studio/Dialogs/AssistantPluginAuditDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/AssistantPluginAuditDialog.razor.cs @@ -37,6 +37,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase private IReadOnlyCollection> fileSystemTreeItems = []; private CultureInfo currentCultureInfo = CultureInfo.InvariantCulture; private bool isAuditing; + private PluginAssistantSecurityState securityState = new(); private AIStudio.Settings.Provider CurrentProvider => this.SettingsManager.GetPreselectedProvider(Tools.Components.AGENT_ASSISTANT_PLUGIN_AUDIT, null, true); @@ -50,7 +51,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase private string MinimumLevelLabel => this.MinimumLevel.GetName(); - private bool CanRunAudit => this.plugin is not null && this.CurrentProvider != AIStudio.Settings.Provider.NONE && !this.isAuditing; + private bool CanRunAudit => this.plugin is not null && this.CurrentProvider != AIStudio.Settings.Provider.NONE && !this.isAuditing && !this.securityState.IsEnterpriseApproved; private bool IsAuditBelowMinimum => this.audit is not null && this.audit.Level < this.MinimumLevel; @@ -74,6 +75,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase .FirstOrDefault(x => x.Id == this.PluginId); if (this.plugin is not null) { + this.securityState = PluginAssistantSecurityResolver.Resolve(this.SettingsManager, this.plugin); this.promptPreview = await this.plugin.BuildAuditPromptPreviewAsync(); this.promptFallbackPreview = this.plugin.BuildAuditPromptFallbackPreview(); this.plugin.CreateAuditComponentSummary(); @@ -96,6 +98,7 @@ public partial class AssistantPluginAuditDialog : MSGComponentBase try { this.audit = await this.AssistantPluginAuditService.RunAuditAsync(this.plugin); + this.securityState = PluginAssistantSecurityResolver.Resolve(this.SettingsManager, this.plugin); } finally { diff --git a/app/MindWork AI Studio/Pages/Assistants.razor b/app/MindWork AI Studio/Pages/Assistants.razor index feca92fc..306406d1 100644 --- a/app/MindWork AI Studio/Pages/Assistants.razor +++ b/app/MindWork AI Studio/Pages/Assistants.razor @@ -42,13 +42,15 @@ @foreach (var assistantPlugin in this.AssistantPlugins) { var securityState = PluginAssistantSecurityResolver.Resolve(this.SettingsManager, assistantPlugin); + var launchLink = assistantPlugin.StartsChatDirectly ? string.Empty : $"{Routes.ASSISTANT_DYNAMIC}?assistantId={assistantPlugin.Id}"; + Link="@launchLink" + OnClick="@(() => this.StartAssistantPluginAsync(assistantPlugin))"> diff --git a/app/MindWork AI Studio/Pages/Assistants.razor.cs b/app/MindWork AI Studio/Pages/Assistants.razor.cs index f7668a1d..1d67cecb 100644 --- a/app/MindWork AI Studio/Pages/Assistants.razor.cs +++ b/app/MindWork AI Studio/Pages/Assistants.razor.cs @@ -1,3 +1,4 @@ +using AIStudio.Chat; using AIStudio.Components; using AIStudio.Agents.AssistantAudit; using AIStudio.Tools.PluginSystem; @@ -12,6 +13,12 @@ public partial class Assistants : MSGComponentBase [Inject] private AssistantPluginAuditService AssistantPluginAuditService { get; init; } = null!; + + [Inject] + private NavigationManager NavigationManager { get; init; } = null!; + + [Inject] + private ILogger Logger { get; init; } = null!; protected override async Task OnInitializedAsync() { @@ -81,6 +88,50 @@ public partial class Assistants : MSGComponentBase audits.Add(audit); } + private async Task StartAssistantPluginAsync(PluginAssistants assistantPlugin) + { + var securityState = PluginAssistantSecurityResolver.Resolve(this.SettingsManager, assistantPlugin); + if (!securityState.CanStartAssistant) + return; + + if (!assistantPlugin.StartsChatDirectly) + { + this.NavigationManager.NavigateTo($"{Routes.ASSISTANT_DYNAMIC}?assistantId={assistantPlugin.Id}"); + return; + } + + var chatThread = await this.TryCreateDirectChatThreadAsync(assistantPlugin); + if (chatThread is null) + return; + + MessageBus.INSTANCE.DeferMessage(this, Event.SEND_TO_CHAT, chatThread); + this.NavigationManager.NavigateTo(Routes.CHAT); + } + + private async Task TryCreateDirectChatThreadAsync(PluginAssistants assistantPlugin) + { + var workspaceId = await WorkspaceBehaviour.ResolveOrCreateWorkspaceIdByNameAsync(assistantPlugin.LaunchWorkspaceName); + if (workspaceId == Guid.Empty) + { + this.Logger.LogWarning("Assistant plugin '{PluginName}' could not resolve or create workspace '{WorkspaceName}'.", assistantPlugin.Name, assistantPlugin.LaunchWorkspaceName); + return null; + } + + return new ChatThread + { + IncludeDateTime = true, + SelectedProvider = string.Empty, + SelectedProfile = string.Empty, + SelectedChatTemplate = string.Empty, + SystemPrompt = SystemPrompts.DEFAULT, + WorkspaceId = workspaceId, + ChatId = Guid.NewGuid(), + Name = assistantPlugin.AssistantTitle, + DataSourceOptions = this.SettingsManager.ConfigurationData.Chat.PreselectedDataSourceOptions.CreateCopy(), + Blocks = [], + }; + } + protected override async Task ProcessIncomingMessage(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default { if (triggeredEvent is Event.PLUGINS_RELOADED) diff --git a/app/MindWork AI Studio/Plugins/assistants/README.md b/app/MindWork AI Studio/Plugins/assistants/README.md index 2ce0a9c7..dfef8c10 100644 --- a/app/MindWork AI Studio/Plugins/assistants/README.md +++ b/app/MindWork AI Studio/Plugins/assistants/README.md @@ -81,6 +81,9 @@ Each assistant plugin lives in its own directory under the assistants plugin roo ## Structure - `ASSISTANT` is the root table. It must contain `Title`, `Description`, `SystemPrompt`, `SubmitText`, `AllowProfiles`, and the nested `UI` definition. +- `ASSISTANT` may optionally define direct-launch metadata for assistant tiles: + - `LaunchBehavior = "OPEN_WORKSPACE_CHAT_BY_NAME"` + - `WorkspaceName = ""` - `UI.Type` is always `"FORM"` and `UI.Children` is a list of component tables. - Each component table declares `Type`, an optional `Children` array, and a `Props` table that feeds the component’s parameters. @@ -92,6 +95,8 @@ ASSISTANT = { ["SystemPrompt"] = "", ["SubmitText"] = "", ["AllowProfiles"] = true, + ["LaunchBehavior"] = "OPEN_WORKSPACE_CHAT_BY_NAME", + ["WorkspaceName"] = "", ["UI"] = { ["Type"] = "FORM", ["Children"] = { @@ -101,6 +106,29 @@ ASSISTANT = { } ``` +## Direct Launch to Workspace Chat +Assistant plugins can optionally skip the normal assistant page and open a chat directly from the tile. + +```lua +ASSISTANT = { + ["Title"] = "Open Chat", + ["Description"] = "Open a new chat in the XXX workspace.", + ["SystemPrompt"] = "", + ["SubmitText"] = "Start", + ["AllowProfiles"] = true, + ["LaunchBehavior"] = "OPEN_WORKSPACE_CHAT_BY_NAME", + ["WorkspaceName"] = "XXX", + ["UI"] = { + ["Type"] = "FORM", + ["Children"] = {} + } +} +``` + +- `WorkspaceName` is resolved case-insensitively after trimming. +- If the workspace does not exist yet, AI Studio creates it automatically. +- The opened chat uses the normal default chat settings of AI Studio. + #### Supported types (matching the Blazor UI components): diff --git a/app/MindWork AI Studio/Plugins/assistants/plugin.lua b/app/MindWork AI Studio/Plugins/assistants/plugin.lua index 36d22016..e3610bc2 100644 --- a/app/MindWork AI Studio/Plugins/assistants/plugin.lua +++ b/app/MindWork AI Studio/Plugins/assistants/plugin.lua @@ -62,6 +62,8 @@ ASSISTANT = { ["SystemPrompt"] = "", -- required ["SubmitText"] = "