Skip to content

Agent Zero AI framework

plugins default config helper and frontend

Alessandro809771807e13
diff --git a/python/api/plugins.py b/python/api/plugins.py
index a6a9c7792..103ca198f 100644
--- a/python/api/plugins.py
+++ b/python/api/plugins.py
@@ -151,6 +151,13 @@ class Plugins(ApiHandler):
return {"ok": True}
+ if action == "get_default_config":
+ plugin_name = input.get("plugin_name", "")
+ if not plugin_name:
+ return Response(status=400, response="Missing plugin_name")
+ settings = plugins.get_default_plugin_config(plugin_name)
+ return {"ok": True, "data": settings or {}}
+
if action == "save_config":
plugin_name = input.get("plugin_name", "")
project_name = input.get("project_name", "")
diff --git a/python/helpers/plugins.py b/python/helpers/plugins.py
index 4b8dbc62e..5d010e25a 100644
--- a/python/helpers/plugins.py
+++ b/python/helpers/plugins.py
@@ -386,6 +386,15 @@ def get_plugin_config(
return None
+def get_default_plugin_config(plugin_name: str):
+ file_path = files.get_abs_path(find_plugin_dir(plugin_name), CONFIG_DEFAULT_FILE_NAME)
+ if file_path and files.exists(file_path):
+ return (
+ json.loads if file_path.lower().endswith(".json") else yaml_helper.loads
+ )(files.read_file(file_path))
+ return None
+
+
def save_plugin_config(
plugin_name: str, project_name: str, agent_profile: str, settings: dict
):
diff --git a/webui/components/plugins/plugin-settings-store.js b/webui/components/plugins/plugin-settings-store.js
index fd6dd6a8b..dd017f3d5 100644
--- a/webui/components/plugins/plugin-settings-store.js
+++ b/webui/components/plugins/plugin-settings-store.js
@@ -1,6 +1,8 @@
import { createStore } from "/js/AlpineStore.js";
+import { showConfirmDialog } from "/js/confirmDialog.js";
const fetchApi = globalThis.fetchApi;
+const justToast = globalThis.justToast;
const model = {
// which plugin this modal is showing
@@ -264,6 +266,27 @@ const model = {
}
},
+ async resetToDefault() {
+ if (!this.pluginName) return;
+ const confirmed = await showConfirmDialog({
+ title: "Reset to Default",
+ message: "This will replace the current settings with the plugin defaults. Any unsaved changes will be lost.",
+ confirmText: "Reset",
+ type: "warning",
+ });
+ if (!confirmed) return;
+ const response = await fetchApi("/plugins", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ action: "get_default_config", plugin_name: this.pluginName }),
+ });
+ const result = await response.json().catch(() => ({}));
+ if (result.ok) {
+ this.settings = result.data || {};
+ justToast("Settings reset to default.", "info");
+ }
+ },
+
async save() {
if (!this.pluginName) return;
diff --git a/webui/components/plugins/plugin-settings.html b/webui/components/plugins/plugin-settings.html
index 8ac718360..07a5af520 100644
--- a/webui/components/plugins/plugin-settings.html
+++ b/webui/components/plugins/plugin-settings.html
@@ -105,6 +105,11 @@
:disabled="$store.pluginSettings?.isSaving || $store.pluginSettings?.isLoading">
Save
</button>
+ <button class="btn"
+ @click="$store.pluginSettings.resetToDefault()"
+ :disabled="$store.pluginSettings?.isSaving || $store.pluginSettings?.isLoading">
+ Default
+ </button>
<button class="btn btn-cancel"
@click="window.closeModal?.()">
Cancel