Agent Zero AI framework
Remove scan queue and enable parallel plugin scans
frdel1eb78607c9ad
diff --git a/plugins/_plugin_scan/README.md b/plugins/_plugin_scan/README.mdindex e11fa68ae..7a3bfb23a 100644--- a/plugins/_plugin_scan/README.md+++ b/plugins/_plugin_scan/README.md@@ -11,11 +11,13 @@ This plugin builds a structured scanning prompt from a selectable checklist, run- **Prompt-driven scan**- Loads scan checks and a markdown prompt template from the plugin's `webui/` assets.- **Temporary scan context**- - Creates a temporary chat context, sends the generated prompt as a user message, waits for the model result, and then removes the chat.+ - Creates a temporary chat context, logs the generated prompt into it, starts the agent immediately, and waits for the model result.+- **Parallel-friendly execution**+ - Each scan runs in its own chat context; the plugin does not serialize scans behind a "wait for another scan" queue.- **Selectable checks**- Supports scanning all checks by default or only the subset selected by the caller.- **UI integration**- - Includes API endpoints and web UI files for queueing, starting, and running scans.+ - Includes API endpoints and web UI files for logging the prompt, starting the scan, and running scans synchronously.## Key Files@@ -24,8 +26,8 @@ This plugin builds a structured scanning prompt from a selectable checklist, run- **Prompt builder**- `helpers/prompt.py` loads check definitions and renders the final scan prompt.- **Additional APIs**- - `api/plugin_scan_queue.py`- - `api/plugin_scan_start.py`+ - `api/plugin_scan_queue.py` logs the prompt into the temporary chat.+ - `api/plugin_scan_start.py` starts the agent in that chat.## Configuration Scopediff --git a/plugins/_plugin_scan/api/plugin_scan_queue.py b/plugins/_plugin_scan/api/plugin_scan_queue.pyindex ffdcef3ce..0ffec963a 100644--- a/plugins/_plugin_scan/api/plugin_scan_queue.py+++ b/plugins/_plugin_scan/api/plugin_scan_queue.py@@ -4,12 +4,11 @@ from helpers import message_queue as mqclass PluginScanQueue(ApiHandler):- """Log the scan prompt into a chat. Optionally set progress to 'Queued'."""+ """Log the scan prompt into a chat before the scan starts."""async def process(self, input: Input, request: Request) -> Output:ctxid: str = input.get("context", "")text: str = input.get("text", "")- queued: bool = input.get("queued", False)if not ctxid or not text:return Response("Missing 'context' or 'text'.", 400)@@ -20,7 +19,4 @@ class PluginScanQueue(ApiHandler):mq.log_user_message(context, text, [])- if queued:- context.log.set_progress("icon://hourglass_empty Queued - waiting for another scan to finish", 0, True)-return {"ok": True, "context": ctxid}diff --git a/plugins/_plugin_scan/webui/plugin-scan-store.js b/plugins/_plugin_scan/webui/plugin-scan-store.jsindex 40c3b2a22..f5fc6c1e7 100644--- a/plugins/_plugin_scan/webui/plugin-scan-store.js+++ b/plugins/_plugin_scan/webui/plugin-scan-store.js@@ -67,10 +67,6 @@ function formatRatingIcons(ratings) {return Object.values(ratings).map((r) => r.icon).join("/");}let _pollGen = 0;-/** @type {{ gen: number, ctxId: string, prompt: string }[]} */-let _queue = [];-/** @type {{ gen: number, ctxId: string } | null} */-let _running = null;const POLL_INTERVAL = 2000;const MAX_POLL_MS = 10 * 60 * 1000;const SCAN_TITLE = "Plugin Scanner";@@ -86,7 +82,6 @@ export const store = createStore("pluginScan", {prompt: "",output: "",scanning: false,- queued: false,scanCtxId: "",get renderedOutput() {@@ -105,7 +100,6 @@ export const store = createStore("pluginScan", {async onOpen(url) {this.output = "";this.scanning = false;- this.queued = false;if (url) this.gitUrl = url;const cfg = await loadConfig();if (cfg && Object.keys(this.checks).length === 0) {@@ -171,11 +165,7 @@ export const store = createStore("pluginScan", {}},- /**- * Create a context immediately and either execute or queue the scan.- * Queued scans have their prompt logged to the chat + progress bar set to "Queued",- * but the agent is NOT started until it's their turn.- */+ /** Create a fresh context, log the prompt into it, and start the scan immediately. */async runScan() {if (!this.gitUrl.trim()) {void toastFrontendError("Please enter a Git URL", SCAN_TITLE);@@ -198,26 +188,15 @@ export const store = createStore("pluginScan", {}this.scanCtxId = ctxId;- if (_running) {- try {- await api.callJsonApi("/plugins/_plugin_scan/plugin_scan_queue", { context: ctxId, text: capturedPrompt, queued: true });- } catch { /* best-effort */ }- _queue.push({ gen, ctxId, prompt: capturedPrompt });- this.queued = true;- this.scanning = false;- } else {- try {- await api.callJsonApi("/plugins/_plugin_scan/plugin_scan_queue", { context: ctxId, text: capturedPrompt });- } catch { /* best-effort */ }- this.queued = false;- this.scanning = true;- this._runNext(gen, ctxId, capturedPrompt);- }+ try {+ await api.callJsonApi("/plugins/_plugin_scan/plugin_scan_queue", { context: ctxId, text: capturedPrompt });+ } catch { /* best-effort */ }+ this.scanning = true;+ this._runNext(gen, ctxId, capturedPrompt);},/** @param {number} gen @param {string} ctxId @param {string} prompt */async _runNext(gen, ctxId, prompt) {- _running = { gen, ctxId };try {await api.callJsonApi("/plugins/_plugin_scan/plugin_scan_start", { text: prompt, context: ctxId });await this._pollLoop(gen, ctxId);@@ -225,19 +204,6 @@ export const store = createStore("pluginScan", {if (gen === _pollGen) {void toastFrontendError(`Scan failed: ${formatErrorMessage(e)}`, SCAN_TITLE);this.scanning = false;- this.queued = false;- }- } finally {- _running = null;- while (_queue.length) {- const next = /** @type {{ gen: number, ctxId: string, prompt: string }} */ (_queue.shift());- if (!next || next.gen !== _pollGen) {- continue;- }- this.queued = false;- this.scanning = true;- this._runNext(next.gen, next.ctxId, next.prompt);- break;}}},diff --git a/plugins/_plugin_scan/webui/plugin-scan.html b/plugins/_plugin_scan/webui/plugin-scan.htmlindex 3e982984b..11dab22fe 100644--- a/plugins/_plugin_scan/webui/plugin-scan.html+++ b/plugins/_plugin_scan/webui/plugin-scan.html@@ -40,11 +40,9 @@<!-- Actions --><div class="scan-actions"><button class="button" @click="$store.pluginScan.copyPrompt()">Copy Prompt</button>- <button class="button confirm" @click="$store.pluginScan.runScan()"- :disabled="$store.pluginScan.scanning || $store.pluginScan.queued">- <span x-show="$store.pluginScan.queued"><span class="scan-spinner"></span>Queued…</span>- <span x-show="$store.pluginScan.scanning && !$store.pluginScan.queued"><span class="scan-spinner"></span>Scanning…</span>- <span x-show="!$store.pluginScan.scanning && !$store.pluginScan.queued">Run Scan</span>+ <button class="button confirm" @click="$store.pluginScan.runScan()">+ <span x-show="$store.pluginScan.scanning"><span class="scan-spinner"></span>Run Another Scan</span>+ <span x-show="!$store.pluginScan.scanning">Run Scan</span></button><button class="button" @click="$store.pluginScan.openChatInNewWindow()"x-show="$store.pluginScan.scanCtxId"