Skip to content

Agent Zero AI framework

plugins: rename init to execute

Alessandro2a6820064ded
diff --git a/api/plugins.py b/api/plugins.py
index c602efa5e..6e43dc34a 100644
--- a/api/plugins.py
+++ b/api/plugins.py
@@ -17,7 +17,6 @@ class Plugins(ApiHandler):
async def process(self, input: dict, request: Request) -> dict | Response:
action = input.get("action", "")
- # Accept legacy aliases during migration.
if action == "get_config":
return self._get_config(input)
@@ -45,11 +44,11 @@ class Plugins(ApiHandler):
if action == "get_doc":
return self._get_doc(input)
- if action == "run_init_script":
- return self._run_init_script(input)
+ if action == "run_execute_script":
+ return self._run_execute_script(input)
- if action == "get_init_exec":
- return self._get_init_exec(input)
+ if action == "get_execute_record":
+ return self._get_execute_record(input)
return Response(status=400, response=f"Unknown action: {action}")
@@ -275,7 +274,7 @@ class Plugins(ApiHandler):
return {"ok": True, "content": files.read_file(file_path), "filename": filename}
@extension.extensible
- def _run_init_script(self, input: dict) -> dict | Response:
+ def _run_execute_script(self, input: dict) -> dict | Response:
plugin_name = input.get("plugin_name", "")
if not plugin_name:
return Response(status=400, response="Missing plugin_name")
@@ -284,14 +283,14 @@ class Plugins(ApiHandler):
if not plugin_dir:
return Response(status=404, response="Plugin not found")
- init_script = files.get_abs_path(plugin_dir, "execute.py")
- if not files.exists(init_script):
+ execute_script = files.get_abs_path(plugin_dir, "execute.py")
+ if not files.exists(execute_script):
return Response(status=404, response="execute.py not found")
executed_at = datetime.now(timezone.utc).isoformat()
try:
result = subprocess.run(
- [sys.executable, init_script],
+ [sys.executable, execute_script],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
@@ -307,12 +306,12 @@ class Plugins(ApiHandler):
exit_code = -1
output = f"Error: {str(e)}"
- exec_record = {"executed_at": executed_at, "exit_code": exit_code}
- exec_path = plugins.determine_plugin_asset_path(
- plugin_name, "", "", "init_exec.json"
+ execute_record = {"executed_at": executed_at, "exit_code": exit_code}
+ execute_record_path = plugins.determine_plugin_asset_path(
+ plugin_name, "", "", "execute_record.json"
)
- if exec_path:
- files.write_file(exec_path, json.dumps(exec_record))
+ if execute_record_path:
+ files.write_file(execute_record_path, json.dumps(execute_record))
return {
"ok": exit_code == 0,
@@ -322,17 +321,17 @@ class Plugins(ApiHandler):
}
@extension.extensible
- def _get_init_exec(self, input: dict) -> dict | Response:
+ def _get_execute_record(self, input: dict) -> dict | Response:
plugin_name = input.get("plugin_name", "")
if not plugin_name:
return Response(status=400, response="Missing plugin_name")
- exec_path = plugins.determine_plugin_asset_path(
- plugin_name, "", "", "init_exec.json"
+ execute_record_path = plugins.determine_plugin_asset_path(
+ plugin_name, "", "", "execute_record.json"
)
- if exec_path and files.exists(exec_path):
+ if execute_record_path and files.exists(execute_record_path):
try:
- data = json.loads(files.read_file(exec_path))
+ data = json.loads(files.read_file(execute_record_path))
return {"ok": True, "data": data}
except Exception:
pass
diff --git a/helpers/plugins.py b/helpers/plugins.py
index 1e850a0c9..3bad005ae 100644
--- a/helpers/plugins.py
+++ b/helpers/plugins.py
@@ -87,7 +87,7 @@ class PluginListItem(BaseModel):
has_config_screen: bool = False
has_readme: bool = False
has_license: bool = False
- has_init_script: bool = False
+ has_execute_script: bool = False
toggle_state: ToggleState = "disabled"
current_commit: str = ""
current_commit_timestamp: str = ""
@@ -162,7 +162,7 @@ def get_enhanced_plugins_list(
has_config_screen = files.exists(str(d / "webui" / "config.html"))
has_readme = files.exists(str(d / "README.md"))
has_license = files.exists(str(d / "LICENSE"))
- has_init_script = files.exists(str(d / "execute.py"))
+ has_execute_script = files.exists(str(d / "execute.py"))
toggle_state = get_toggle_state(d.name)
current_commit = ""
current_commit_timestamp = ""
@@ -187,7 +187,7 @@ def get_enhanced_plugins_list(
has_config_screen=has_config_screen,
has_readme=has_readme,
has_license=has_license,
- has_init_script=has_init_script,
+ has_execute_script=has_execute_script,
toggle_state=toggle_state,
current_commit=current_commit,
current_commit_timestamp=current_commit_timestamp,
diff --git a/plugins/_plugin_installer/webui/install-detail.html b/plugins/_plugin_installer/webui/install-detail.html
index ffd8d9066..c8fda7f8a 100644
--- a/plugins/_plugin_installer/webui/install-detail.html
+++ b/plugins/_plugin_installer/webui/install-detail.html
@@ -84,9 +84,9 @@
<span class="icon material-symbols-outlined">gavel</span> License
</button>
</template>
- <template x-if="$store.pluginInstallStore.installedPluginInfo.has_init_script">
+ <template x-if="$store.pluginInstallStore.installedPluginInfo.has_execute_script">
<button type="button" class="button"
- @click="$store.pluginInstallStore.handleOpenInit()">
+ @click="$store.pluginInstallStore.handleOpenExecute()">
<span class="icon material-symbols-outlined">terminal</span> Script
</button>
</template>
diff --git a/plugins/_plugin_installer/webui/pluginInstallStore.js b/plugins/_plugin_installer/webui/pluginInstallStore.js
index 347aece2f..865aad569 100644
--- a/plugins/_plugin_installer/webui/pluginInstallStore.js
+++ b/plugins/_plugin_installer/webui/pluginInstallStore.js
@@ -6,7 +6,7 @@ import { toastFrontendSuccess, toastFrontendError } from "/components/notificati
import { showConfirmDialog } from "/js/confirmDialog.js";
import { store as imageViewerStore } from "/components/modals/image-viewer/image-viewer-store.js";
import { store as pluginListStore } from "/components/plugins/list/pluginListStore.js";
-import { store as pluginInitStore } from "/components/plugins/list/plugin-init-store.js";
+import { store as pluginExecuteStore } from "/components/plugins/list/plugin-execute-store.js";
const PLUGIN_API = "plugins/_plugin_installer/plugin_install";
const PER_PAGE = 20;
@@ -611,9 +611,9 @@ const model = {
}
},
- handleOpenInit() {
+ handleOpenExecute() {
if (this.installedPluginInfo) {
- pluginInitStore.open(this.installedPluginInfo);
+ pluginExecuteStore.open(this.installedPluginInfo);
}
},
diff --git a/webui/components/plugins/list/plugin-init-modal.html b/webui/components/plugins/list/plugin-execute-modal.html
similarity index 60%
rename from webui/components/plugins/list/plugin-init-modal.html
rename to webui/components/plugins/list/plugin-execute-modal.html
index 5f4919681..0833d3eb5 100644
--- a/webui/components/plugins/list/plugin-init-modal.html
+++ b/webui/components/plugins/list/plugin-execute-modal.html
@@ -1,55 +1,55 @@
<html>
<head>
- <title>Plugin Init</title>
+ <title>Plugin Execute</title>
<script type="module">
- import { store } from "/components/plugins/list/plugin-init-store.js";
+ import { store } from "/components/plugins/list/plugin-execute-store.js";
</script>
</head>
<body>
<div x-data>
- <template x-if="$store.pluginInitStore">
- <div x-destroy="$store.pluginInitStore.cleanup()"
- x-create="$el.closest('.modal')?.querySelector('.modal-title') && ($el.closest('.modal').querySelector('.modal-title').textContent = 'Init: ' + $store.pluginInitStore.pluginDisplayName)"
- class="plugin-init-root">
+ <template x-if="$store.pluginExecuteStore">
+ <div x-destroy="$store.pluginExecuteStore.cleanup()"
+ x-create="$el.closest('.modal')?.querySelector('.modal-title') && ($el.closest('.modal').querySelector('.modal-title').textContent = 'Execute: ' + $store.pluginExecuteStore.pluginDisplayName)"
+ class="plugin-execute-root">
- <div class="plugin-init-idle"
- x-show="!$store.pluginInitStore.running && $store.pluginInitStore.exitCode === null && !$store.pluginInitStore.output">
+ <div class="plugin-execute-idle"
+ x-show="!$store.pluginExecuteStore.running && $store.pluginExecuteStore.exitCode === null && !$store.pluginExecuteStore.output">
<span class="material-symbols-outlined idle-icon">terminal</span>
<div class="idle-text">
- <span class="idle-headline">Press <strong>Run</strong> to initialize <strong x-text="$store.pluginInitStore.pluginDisplayName"></strong></span>
- <span class="idle-sub">This will execute the plugin's <code>execute.py</code> setup script.</span>
- <template x-if="$store.pluginInitStore.lastExec">
+ <span class="idle-headline">Press <strong>Run</strong> to execute <strong x-text="$store.pluginExecuteStore.pluginDisplayName"></strong></span>
+ <span class="idle-sub">This will run the plugin's <code>execute.py</code> script.</span>
+ <template x-if="$store.pluginExecuteStore.lastExecution">
<span class="last-exec-info">
Last run:
- <span x-text="new Date($store.pluginInitStore.lastExec.executed_at).toLocaleString()"></span>
+ <span x-text="new Date($store.pluginExecuteStore.lastExecution.executed_at).toLocaleString()"></span>
&nbsp;&mdash;&nbsp;
- <span :class="$store.pluginInitStore.lastExec.exit_code === 0 ? 'exit-ok' : 'exit-err'"
- x-text="$store.pluginInitStore.lastExec.exit_code === 0 ? 'succeeded' : 'failed (exit ' + $store.pluginInitStore.lastExec.exit_code + ')'">
+ <span :class="$store.pluginExecuteStore.lastExecution.exit_code === 0 ? 'exit-ok' : 'exit-err'"
+ x-text="$store.pluginExecuteStore.lastExecution.exit_code === 0 ? 'succeeded' : 'failed (exit ' + $store.pluginExecuteStore.lastExecution.exit_code + ')'">
</span>
</span>
</template>
- <template x-if="!$store.pluginInitStore.lastExec">
- <span class="last-exec-info never-run">Never initialized</span>
+ <template x-if="!$store.pluginExecuteStore.lastExecution">
+ <span class="last-exec-info never-run">Never executed</span>
</template>
</div>
</div>
- <div class="plugin-init-status" x-show="$store.pluginInitStore.running">
+ <div class="plugin-execute-status" x-show="$store.pluginExecuteStore.running">
<span class="material-symbols-outlined spin">progress_activity</span>
<span>Running execute.py...</span>
</div>
- <div class="plugin-init-exit" x-show="!$store.pluginInitStore.running && $store.pluginInitStore.exitCode !== null">
+ <div class="plugin-execute-exit" x-show="!$store.pluginExecuteStore.running && $store.pluginExecuteStore.exitCode !== null">
<span class="material-symbols-outlined"
- :class="$store.pluginInitStore.exitCode === 0 ? 'exit-ok' : 'exit-err'"
- x-text="$store.pluginInitStore.exitCode === 0 ? 'check_circle' : 'error'">
+ :class="$store.pluginExecuteStore.exitCode === 0 ? 'exit-ok' : 'exit-err'"
+ x-text="$store.pluginExecuteStore.exitCode === 0 ? 'check_circle' : 'error'">
</span>
- <span x-text="$store.pluginInitStore.exitCode === 0 ? 'Completed successfully (exit 0)' : 'Exited with code ' + $store.pluginInitStore.exitCode"></span>
+ <span x-text="$store.pluginExecuteStore.exitCode === 0 ? 'Completed successfully (exit 0)' : 'Exited with code ' + $store.pluginExecuteStore.exitCode"></span>
</div>
- <pre class="plugin-init-output"
- x-show="$store.pluginInitStore.output || $store.pluginInitStore.running"
- x-text="$store.pluginInitStore.output || ''"></pre>
+ <pre class="plugin-execute-output"
+ x-show="$store.pluginExecuteStore.output || $store.pluginExecuteStore.running"
+ x-text="$store.pluginExecuteStore.output || ''"></pre>
</div>
</template>
</div>
@@ -57,22 +57,22 @@
<div class="modal-footer" data-modal-footer>
<button class="btn btn-action footer-btn"
x-data
- :disabled="$store.pluginInitStore?.running"
- @click="$store.pluginInitStore?.run()">
+ :disabled="$store.pluginExecuteStore?.running"
+ @click="$store.pluginExecuteStore?.run()">
<span class="icon material-symbols-outlined">play_arrow</span>
- <span x-text="$store.pluginInitStore?.exitCode !== null || $store.pluginInitStore?.output ? 'Rerun' : 'Run'">Run</span>
+ <span x-text="$store.pluginExecuteStore?.exitCode !== null || $store.pluginExecuteStore?.output ? 'Rerun' : 'Run'">Run</span>
</button>
<button class="btn btn-cancel footer-btn" @click="window.closeModal?.()">Close</button>
</div>
<style>
- .plugin-init-root {
+ .plugin-execute-root {
display: flex;
flex-direction: column;
width: 100%;
}
- .plugin-init-idle {
+ .plugin-execute-idle {
display: flex;
align-items: flex-start;
gap: 1rem;
@@ -114,7 +114,7 @@
font-style: italic;
}
- .plugin-init-status {
+ .plugin-execute-status {
display: flex;
align-items: center;
gap: 0.5rem;
@@ -123,7 +123,7 @@
font-size: var(--font-size-small);
}
- .plugin-init-exit {
+ .plugin-execute-exit {
display: flex;
align-items: center;
gap: 0.5rem;
@@ -139,7 +139,7 @@
color: var(--color-error, #e74c3c);
}
- .plugin-init-output {
+ .plugin-execute-output {
font-family: "Courier New", Courier, monospace;
font-size: 0.82rem;
background: var(--color-bg-secondary, #1e1e1e);
diff --git a/webui/components/plugins/list/plugin-init-store.js b/webui/components/plugins/list/plugin-execute-store.js
similarity index 69%
rename from webui/components/plugins/list/plugin-init-store.js
rename to webui/components/plugins/list/plugin-execute-store.js
index 17797c898..1c06d4bbb 100644
--- a/webui/components/plugins/list/plugin-init-store.js
+++ b/webui/components/plugins/list/plugin-execute-store.js
@@ -11,7 +11,7 @@ const model = {
output: "",
running: false,
exitCode: null,
- lastExec: null,
+ lastExecution: null,
async open(plugin) {
if (!plugin?.name) return;
@@ -19,20 +19,20 @@ const model = {
this.pluginDisplayName = plugin.display_name || plugin.name;
this.output = "";
this.exitCode = null;
- this.lastExec = null;
- window.openModal?.("components/plugins/list/plugin-init-modal.html");
- await this.fetchLastExec();
+ this.lastExecution = null;
+ window.openModal?.("components/plugins/list/plugin-execute-modal.html");
+ await this.fetchLastExecution();
},
- async fetchLastExec() {
+ async fetchLastExecution() {
try {
const response = await api.callJsonApi("plugins", {
- action: "get_init_exec",
+ action: "get_execute_record",
plugin_name: this.pluginName,
});
- this.lastExec = response.data || null;
+ this.lastExecution = response.data || null;
} catch (e) {
- this.lastExec = null;
+ this.lastExecution = null;
}
},
@@ -43,22 +43,25 @@ const model = {
this.running = true;
try {
const response = await api.callJsonApi("plugins", {
- action: "run_init_script",
+ action: "run_execute_script",
plugin_name: this.pluginName,
});
this.output = response.output || "";
this.exitCode = response.exit_code ?? null;
if (response.executed_at) {
- this.lastExec = { executed_at: response.executed_at, exit_code: response.exit_code ?? null };
+ this.lastExecution = {
+ executed_at: response.executed_at,
+ exit_code: response.exit_code ?? null,
+ };
}
} catch (e) {
this.output = e.message || String(e);
this.exitCode = -1;
notificationStore.frontendError(
e.message || String(e),
- "Failed to run init script",
+ "Failed to run execute script",
3,
- "pluginInit",
+ "pluginExecute",
defaultPriority,
true,
);
@@ -73,8 +76,8 @@ const model = {
this.output = "";
this.running = false;
this.exitCode = null;
- this.lastExec = null;
+ this.lastExecution = null;
},
};
-export const store = createStore("pluginInitStore", model);
+export const store = createStore("pluginExecuteStore", model);
diff --git a/webui/components/plugins/list/plugin-list.html b/webui/components/plugins/list/plugin-list.html
index 598371ea9..ca7abf83d 100644
--- a/webui/components/plugins/list/plugin-list.html
+++ b/webui/components/plugins/list/plugin-list.html
@@ -107,11 +107,11 @@
<span class="icon material-symbols-outlined">settings</span> Config
</button>
</template>
- <template x-if="plugin.has_init_script">
+ <template x-if="plugin.has_execute_script">
<button type="button"
class="button"
title="Execute"
- @click="$store.pluginListStore.openPluginInit(plugin)">
+ @click="$store.pluginListStore.openPluginExecute(plugin)">
<span class="icon material-symbols-outlined">terminal</span> Execute
</button>
</template>
diff --git a/webui/components/plugins/list/pluginListStore.js b/webui/components/plugins/list/pluginListStore.js
index 3ae9f8c25..8db39725d 100644
--- a/webui/components/plugins/list/pluginListStore.js
+++ b/webui/components/plugins/list/pluginListStore.js
@@ -2,7 +2,7 @@ import { createStore } from "/js/AlpineStore.js";
import * as api from "/js/api.js";
import { store as pluginSettingsStore } from "/components/plugins/plugin-settings-store.js";
import { store as pluginToggleStore } from "/components/plugins/toggle/plugin-toggle-store.js";
-import { store as pluginInitStore } from "/components/plugins/list/plugin-init-store.js";
+import { store as pluginExecuteStore } from "/components/plugins/list/plugin-execute-store.js";
import { store as markdownModalStore } from "/components/modals/markdown/markdown-store.js";
import { callJsExtensions } from "/js/extensions.js";
import {
@@ -71,9 +71,9 @@ const model = {
window.openModal?.(`/plugins/${plugin.name}/webui/main.html`);
},
- openPluginInit(plugin) {
- if (!plugin?.name || !plugin?.has_init_script) return;
- pluginInitStore.open(plugin);
+ openPluginExecute(plugin) {
+ if (!plugin?.name || !plugin?.has_execute_script) return;
+ pluginExecuteStore.open(plugin);
},
async openPluginConfig(plugin) {