From a6d693c13e0e23e6ea9248b619c364c86e698b71 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Mon, 23 Nov 2026 18:11:49 -0500 Subject: [PATCH] Workflow parameters: types, defaults, checked before a run (#23, #11) #23 - Parameters can be text (default), number (min, max), select (options), boolean, or worker, with a default. The Run dialog shows a matching field, the allowed characters for text, and the range for numbers; worker parameters choose from the connected workers. - Values are checked before anything starts: in the dialog, naming the characters that are not allowed, and by the server (resolveParams), which answers 400 "Invalid parameters: ..." and creates no execution. A bad value used to fail mid-run as "Unsafe value for workflow parameter". Server errors now show in the dialog instead of a toast. #11 - Saving a workflow checks its shape (definitionErrors): known step types and their required fields, unique ids, prompt routes that match options, route conditions, and parameter definitions. Unknown step types were silently skipped at run time. - README documents the parameter types and the checks. Co-Authored-By: Claude Opus 5.5 --- README.md | 30 ++++-- lib/utils.js | 164 ++++++++++++++++++++++++++++- public/assets/pages/workflows.js | 125 +++++++++++++++++++--- server.js | 23 ++-- tests/integration/workflows.int.js | 31 +++++- tests/ui/workflows.ui.js | 38 +++++++ tests/utils.test.js | 104 ++++++++++++++++++ views/pages/workflows.ejs | 1 + 8 files changed, 477 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 2a66808..9e90b62 100644 --- a/README.md +++ b/README.md @@ -338,7 +338,10 @@ A workflow is a JSON definition with a list of steps, created on the **Workflows ```json { - "params": [{ "name": "host", "label": "Host", "required": true }], + "params": [ + { "name": "host", "label": "Host", "required": true }, + { "name": "service", "type": "select", "options": ["nginx", "myservice"], "default": "myservice" } + ], "steps": [ { "id": "probe", "type": "execute", "command": "ping -c 1 {{host}} >/dev/null && echo UP=yes || echo UP=no", "targets": ["node-01"] }, { "id": "read", "type": "parse" }, @@ -347,7 +350,7 @@ A workflow is a JSON definition with a list of steps, created on the **Workflows { "default": true, "goto": "ask" } ] }, { "id": "ask", "type": "prompt", "message": "{{host}} is down. Restart its service?", "options": ["Restart", "Skip"], "routes": { "Skip": "end" } }, - { "id": "restart", "type": "execute", "command": "systemctl restart myservice", "targets": ["node-01"], "retries": 2 } + { "id": "restart", "type": "execute", "command": "systemctl restart {{service}}", "targets": ["node-01"], "retries": 2 } ] } ``` @@ -360,8 +363,10 @@ A workflow is a JSON definition with a list of steps, created on the **Workflows | `prompt` | `message`, `options`, `key`, `routes` (`{ "