Skip to content

Agent Zero AI framework

toggling inheritance (match configs)

Alessandro601a5277ce72
diff --git a/python/api/plugins.py b/python/api/plugins.py
index aad05266c..a6a9c7792 100644
--- a/python/api/plugins.py
+++ b/python/api/plugins.py
@@ -51,6 +51,54 @@ class Plugins(ApiHandler):
"data": settings,
}
+ if action == "get_toggle_status":
+ plugin_name = input.get("plugin_name", "")
+ project_name = input.get("project_name", "")
+ agent_profile = input.get("agent_profile", "")
+ if not plugin_name:
+ return Response(status=400, response="Missing plugin_name")
+
+ meta = plugins.get_plugin_meta(plugin_name)
+ if not meta:
+ return Response(status=404, response="Plugin not found")
+
+ if meta.always_enabled:
+ return {
+ "ok": True,
+ "status": "enabled",
+ "loaded_project_name": project_name,
+ "loaded_agent_profile": agent_profile,
+ "loaded_path": "",
+ }
+
+ result = plugins.find_plugin_assets(
+ plugins.TOGGLE_FILE_PATTERN,
+ plugin_name=plugin_name,
+ project_name=project_name,
+ agent_profile=agent_profile,
+ only_first=True,
+ )
+
+ if result:
+ entry = result[0]
+ path = entry.get("path", "")
+ status = "enabled" if path.endswith(plugins.ENABLED_FILE_NAME) else "disabled"
+ return {
+ "ok": True,
+ "status": status,
+ "loaded_project_name": entry.get("project_name", ""),
+ "loaded_agent_profile": entry.get("agent_profile", ""),
+ "loaded_path": path,
+ }
+
+ return {
+ "ok": True,
+ "status": "enabled",
+ "loaded_project_name": "",
+ "loaded_agent_profile": "",
+ "loaded_path": "",
+ }
+
if action == "list_configs":
plugin_name = input.get("plugin_name", "")
asset_type = input.get("asset_type", "config")
diff --git a/webui/components/plugins/toggle/plugin-toggle-store.js b/webui/components/plugins/toggle/plugin-toggle-store.js
index 648469992..00edf93fe 100644
--- a/webui/components/plugins/toggle/plugin-toggle-store.js
+++ b/webui/components/plugins/toggle/plugin-toggle-store.js
@@ -22,8 +22,13 @@ const model = {
alwaysEnabled: false,
perProjectConfig: true,
perAgentConfig: true,
- explicitPath: null,
hasExplicitRuleForScope: false,
+
+ // Where the effective toggle was actually resolved (mirrors plugin-settings-store loadedXxx fields)
+ loadedPath: "",
+ loadedProjectName: "",
+ loadedAgentProfile: "",
+
configs: [],
async open(plugin) {
@@ -34,6 +39,9 @@ const model = {
this.projectName = "";
this.agentProfileKey = "";
this.configs = [];
+ this.loadedPath = "";
+ this.loadedProjectName = "";
+ this.loadedAgentProfile = "";
const pluginName = typeof plugin === 'string' ? plugin : plugin?.name;
this.pluginName = pluginName;
@@ -61,6 +69,9 @@ const model = {
this.alwaysEnabled = false;
this.hasConfigScreen = false;
this.hasExplicitRuleForScope = false;
+ this.loadedPath = "";
+ this.loadedProjectName = "";
+ this.loadedAgentProfile = "";
},
async loadProjects() {
@@ -106,7 +117,7 @@ const model = {
});
const result = await response.json().catch(() => ({}));
this.configs = result.ok ? (result.data || []) : [];
- this.calculateStatus();
+ await this.loadToggleStatus();
} catch (e) {
this.error = e?.message || "Failed to load configurations";
} finally {
@@ -114,6 +125,46 @@ const model = {
}
},
+ async loadToggleStatus() {
+ if (!this.pluginName) return;
+
+ if (this.alwaysEnabled) {
+ this.status = 'enabled';
+ this.hasExplicitRuleForScope = true;
+ this.loadedPath = "";
+ this.loadedProjectName = this.projectName || "";
+ this.loadedAgentProfile = this.agentProfileKey || "";
+ return;
+ }
+
+ try {
+ const response = await fetchApi("/plugins", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ action: "get_toggle_status",
+ plugin_name: this.pluginName,
+ project_name: this.projectName || "",
+ agent_profile: this.agentProfileKey || "",
+ }),
+ });
+ const result = await response.json().catch(() => ({}));
+ if (result.ok) {
+ this.status = result.status || 'enabled';
+ this.loadedPath = result.loaded_path || "";
+ this.loadedProjectName = result.loaded_project_name || "";
+ this.loadedAgentProfile = result.loaded_agent_profile || "";
+ const p = this.projectName || "";
+ const a = this.agentProfileKey || "";
+ this.hasExplicitRuleForScope = !!(this.loadedPath) &&
+ this.loadedProjectName === p &&
+ this.loadedAgentProfile === a;
+ }
+ } catch (e) {
+ this.error = e?.message || "Failed to load toggle status";
+ }
+ },
+
async openConfigWithScope() {
if (!this.pluginName) return;
@@ -172,31 +223,6 @@ const model = {
}
},
- calculateStatus() {
- if (this.alwaysEnabled) {
- this.explicitPath = null;
- this.hasExplicitRuleForScope = true;
- this.status = 'enabled';
- return;
- }
-
- const p = this.projectName || "";
- const a = this.agentProfileKey || "";
- const explicit = this.configs.find(
- c => (c.project_name||"") === p && (c.agent_profile||"") === a
- );
-
- if (explicit) {
- this.explicitPath = explicit.path;
- this.hasExplicitRuleForScope = true;
- this.status = explicit.path.endsWith(".toggle-1") ? 'enabled' : 'disabled';
- } else {
- this.explicitPath = null;
- this.hasExplicitRuleForScope = false;
- this.status = 'enabled'; // default when no explicit config
- }
- },
-
async setEnabled(enabled) {
if (!this.pluginName || this.alwaysEnabled) return;
this.isSaving = true;
@@ -224,7 +250,7 @@ const model = {
},
async onScopeChanged() {
- this.calculateStatus();
+ await this.loadToggleStatus();
// Sync scope with settings store so its loadSettings picks up the right context
settingsStore.projectName = this.projectName || "";
@@ -254,9 +280,19 @@ const model = {
get noScopeRuleMessage() {
if (this.alwaysEnabled || this.isLoading) return "";
- if (this.configs.length === 0) return "No activation rules configured. Plugin defaults to ON.";
- if (!this.explicitPath) return "No rule set for this scope. Status defaults to ON.";
- return "";
+ if (this.hasExplicitRuleForScope) return "";
+
+ if (!this.loadedPath) {
+ return this.configs.length === 0
+ ? "No activation rules configured. Plugin defaults to ON."
+ : "No rule for this scope. Defaults to ON.";
+ }
+
+ // Inherited from a parent scope - mirrors plugin-settings-store scopeMismatchMessage
+ const pLabel = this.projectLabel(this.loadedProjectName || "");
+ const aLabel = this.agentProfileLabel(this.loadedAgentProfile || "");
+ const state = this.status === 'enabled' ? 'ON' : 'OFF';
+ return `No rule for this scope. Inheriting from ${pLabel}, ${aLabel}: ${state}.`;
}
};