Skip to content

Agent Zero AI framework

fix file not found error when deleting custom plugins

Alessandro8c90ad54aeaf
diff --git a/python/api/plugins.py b/python/api/plugins.py
index 48914d765..e42439127 100644
--- a/python/api/plugins.py
+++ b/python/api/plugins.py
@@ -155,6 +155,25 @@ class Plugins(ApiHandler):
return {"ok": True}
+ if action == "delete_plugin":
+ plugin_name = input.get("plugin_name", "")
+ path = input.get("path", "")
+ if not plugin_name:
+ return Response(status=400, response="Missing plugin_name")
+ if not path:
+ return Response(status=400, response="Missing path")
+
+ # Validate that the plugin is actually a custom plugin
+ custom_plugins_dir = files.get_abs_path(files.USER_DIR, files.PLUGINS_DIR)
+ if not os.path.abspath(path).startswith(os.path.abspath(custom_plugins_dir)):
+ return Response(status=400, response="Only custom plugins can be deleted")
+
+ try:
+ files.delete_dir(path)
+ except Exception as e:
+ return Response(status=500, response=f"Failed to delete plugin: {str(e)}")
+ return {"ok": True}
+
if action == "get_default_config":
plugin_name = input.get("plugin_name", "")
if not plugin_name:
diff --git a/webui/components/plugins/list/pluginListStore.js b/webui/components/plugins/list/pluginListStore.js
index 85a1d9f51..e037f5e78 100644
--- a/webui/components/plugins/list/pluginListStore.js
+++ b/webui/components/plugins/list/pluginListStore.js
@@ -163,9 +163,10 @@ const model = {
}
try {
- const response = await api.callJsonApi("delete_work_dir_file", {
+ const response = await api.callJsonApi("plugins", {
+ action: "delete_plugin",
+ plugin_name: plugin.name,
path: plugin.path,
- currentPath: "/",
});
if (response?.error) {
throw new Error(response.error);