From c28eae3a33199c3e8cdaa6f97692f9a2922384a6 Mon Sep 17 00:00:00 2001 From: Stefan Ernst <24554551+stefan-ernst@users.noreply.github.com> Date: Fri, 13 Nov 2026 22:41:58 +0100 Subject: [PATCH 1/5] feat(actions): run Sobek scripts as the action executor (WI-2174) Add an execute_script action node that runs an author-supplied JavaScript function body in a fresh Sobek runtime bound to the effective action executor. Scripts reach the canonical v2 REST API through a synchronous windshift.api.request({ method, path, body }) helper backed by a short-lived temporary bearer token minted for that executor and revoked in node cleanup. Security boundaries: - Identity is always the effective executor (actor override, otherwise the triggering user); scripts cannot choose or read an identity, and a missing or inactive executor fails closed before any dispatch. - The minted token carries a fixed, server-owned scope allowlist with no delete, admin, action-authoring, asset, test, agent-run, or MCP scope. - Only validated relative v2 paths on this instance are accepted; the bridge rejects alternate hosts, redirects, path escapes, encoded traversal, fragments, and unsupported methods before minting. - An initial resource allowlist keeps token-minting, delegation, and admin routes out of reach even when the executor could reach them. - Requests run through the real mounted v2 handler, so bearer auth, token scopes, rate limits, and handler authorization still apply. Runtime and product: - Compile the function body once and run it exactly once; no retry-as-IIFE fallback that could repeat side effects. - Detached JSON inputs and results, explicit output variable, bounded console capture, safe errors, and strict limits on source, runtime, API calls, response and result size/depth. - Preserve action/execution/node/revision provenance, cascade depth, and private-trigger protection across the in-process REST calls. - Catalog registration with save-time syntax validation, a flow-editor node plus config/reference panel, and localized palette labels. - Document that in-process Sobek has no hard per-script heap limit and that trusted authors are required unless process isolation is added. Tests cover executor-scoped credentials, fail-closed identity, fatal uncatchable policy violations, call budgets, timeouts, unsupported results, path policy, response truncation, scope exclusions, catalog validation, and an end-to-end create-comment/failed-probe workflow. --- .../features/actions/ActionFlowEditor.svelte | 9 + .../features/actions/ScriptConfigPanel.svelte | 138 +++++ .../actions/nodes/ExecuteScriptNode.svelte | 10 + frontend/src/lib/locales/ar/actions.js | 1 + frontend/src/lib/locales/de/actions.js | 1 + frontend/src/lib/locales/en/actions.js | 1 + frontend/src/lib/locales/es/actions.js | 1 + frontend/src/lib/locales/fa/actions.js | 1 + frontend/src/lib/locales/fr/actions.js | 1 + frontend/src/lib/locales/it/actions.js | 1 + frontend/src/lib/locales/ko/actions.js | 3 +- frontend/src/lib/locales/pl/actions.js | 1 + frontend/src/lib/locales/pt-BR/actions.js | 1 + frontend/src/lib/locales/ru/actions.js | 1 + frontend/src/lib/locales/zh-CN/actions.js | 1 + internal/models/integration.go | 25 + internal/restapi/v2/comments.go | 2 +- internal/restapi/v2/router.go | 1 + internal/server/server.go | 8 + internal/services/action_script_bridge.go | 241 ++++++++ .../services/action_script_credentials.go | 103 ++++ internal/services/action_script_executor.go | 568 ++++++++++++++++++ internal/services/action_script_provenance.go | 81 +++ internal/services/action_service.go | 18 +- internal/services/actioncatalog/catalog.go | 9 + internal/services/actioncatalog/validate.go | 36 ++ internal/services/comment_service.go | 35 +- internal/services/event_coordinator.go | 17 +- internal/services/item_application_service.go | 27 +- .../item_update_application_service.go | 12 +- 30 files changed, 1336 insertions(+), 18 deletions(-) create mode 100644 frontend/src/lib/features/actions/ScriptConfigPanel.svelte create mode 100644 frontend/src/lib/features/actions/nodes/ExecuteScriptNode.svelte create mode 100644 internal/services/action_script_bridge.go create mode 100644 internal/services/action_script_credentials.go create mode 100644 internal/services/action_script_executor.go create mode 100644 internal/services/action_script_provenance.go diff --git a/frontend/src/lib/features/actions/ActionFlowEditor.svelte b/frontend/src/lib/features/actions/ActionFlowEditor.svelte index 0449323d6..29d0fb53b 100644 --- a/frontend/src/lib/features/actions/ActionFlowEditor.svelte +++ b/frontend/src/lib/features/actions/ActionFlowEditor.svelte @@ -17,6 +17,7 @@ import Send from '@lucide/svelte/icons/send'; import FileText from '@lucide/svelte/icons/file-text'; import Tag from '@lucide/svelte/icons/tag'; + import Code from '@lucide/svelte/icons/code'; import X from '@lucide/svelte/icons/x'; import { toHotkeyString, getShortcutDisplay } from '../../utils/keyboardShortcuts.js'; import { actionCapabilities } from '../../api/ai.js'; @@ -48,7 +49,9 @@ import NotifyCustomerNode from './nodes/NotifyCustomerNode.svelte'; import InsertCannedResponseNode from './nodes/InsertCannedResponseNode.svelte'; import AdjustLabelsNode from './nodes/AdjustLabelsNode.svelte'; + import ExecuteScriptNode from './nodes/ExecuteScriptNode.svelte'; import CreateMilestoneConfigPanel from './CreateMilestoneConfigPanel.svelte'; + import ScriptConfigPanel from './ScriptConfigPanel.svelte'; import UpdateAssetConfigPanel from './UpdateAssetConfigPanel.svelte'; import CreateAssetConfigPanel from './CreateAssetConfigPanel.svelte'; import PlaceholderReferenceModal from './PlaceholderReferenceModal.svelte'; @@ -130,6 +133,7 @@ notify_customer: NotifyCustomerNode, insert_canned_response: InsertCannedResponseNode, adjust_labels: AdjustLabelsNode, + execute_script: ExecuteScriptNode, }; // Mirror each node's accentColor in the minimap so the overview reflects @@ -154,6 +158,7 @@ notify_customer: 'magenta', insert_canned_response: 'orange', adjust_labels: 'purple', + execute_script: 'cyan', }; function minimapNodeColor(node) { @@ -192,6 +197,7 @@ notify_customer: Send, insert_canned_response: FileText, adjust_labels: Tag, + execute_script: Code, }; // i18n keys for node types. When a type isn't in this map, the palette @@ -216,6 +222,7 @@ notify_customer: 'actions.nodes.notifyCustomer', insert_canned_response: 'actions.nodes.insertCannedResponse', adjust_labels: 'actions.nodes.adjustLabels', + execute_script: 'actions.nodes.executeScript', }; // nodePalette is built from the catalog response on mount. Trigger nodes @@ -1110,6 +1117,8 @@ {:else if selectedNode.type === 'create_milestone'} + {:else if selectedNode.type === 'execute_script'} + {:else if selectedNode.type === 'notify_customer'}
diff --git a/frontend/src/lib/features/actions/ScriptConfigPanel.svelte b/frontend/src/lib/features/actions/ScriptConfigPanel.svelte new file mode 100644 index 000000000..f03fdae43 --- /dev/null +++ b/frontend/src/lib/features/actions/ScriptConfigPanel.svelte @@ -0,0 +1,138 @@ + + +
+
+ +