Class ExecuteCommandExecutor
java.lang.Object
ai.nervemind.app.executor.ExecuteCommandExecutor
- All Implemented Interfaces:
NodeExecutor
Executor for the "executeCommand" node type - runs shell commands on the host
system.
Executes operating system commands with support for multiple shells, argument interpolation, environment variables, and output capture. Use with caution as this allows arbitrary command execution.
Node Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| command | String | - | Required. Command to execute |
| arguments | List | [] | Arguments to pass to command |
| workingDirectory | String | system temp | Working directory |
| timeout | Integer | 300 | Timeout in seconds |
| shell | String | auto | "cmd", "powershell", "bash", "sh" |
| environment | Map | {} | Environment variables to set |
| captureOutput | Boolean | true | Capture stdout/stderr |
| failOnError | Boolean | true | Fail if exit code is non-zero |
Variable Interpolation
Commands and arguments support ${variableName} syntax:
{
"command": "curl ${url}",
"arguments": ["-o", "${outputFile}"]
}
Shell Detection
- Windows: Defaults to "cmd" (cmd.exe /c)
- Linux/Mac: Defaults to "sh" (sh -c)
- powershell: Uses PowerShell with -NoProfile -NonInteractive
- bash: Uses bash -c
Output Data
| Key | Type | Description |
|---|---|---|
| exitCode | Integer | Process exit code (0 = success) |
| stdout | String | Standard output captured from process |
| stderr | String | Standard error captured from process |
| success | Boolean | True if exit code is 0 |
| timedOut | Boolean | True if command exceeded timeout |
| durationMs | Long | Execution time in milliseconds |
Security Warning
CAUTION: This executor runs arbitrary commands on the host system. Never use untrusted input in commands. Consider sandboxing in production.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Executes the business logic for this node type.Unique identifier for the node type this executor handles.
-
Constructor Details
-
ExecuteCommandExecutor
public ExecuteCommandExecutor()Default constructor for ExecuteCommandExecutor.
-
-
Method Details
-
execute
public Map<String,Object> execute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Description copied from interface:NodeExecutorExecutes the business logic for this node type.- Specified by:
executein interfaceNodeExecutor- Parameters:
node- The node definition containing parameters and configuration. UseNode.parameters()to access user settings.input- Combined output from all upstream nodes that connected to this node. For simple flows, this contains the direct predecessor's output. For merge nodes, it contains combined data.context- Verification context providing access to workflow-scoped services, logger, and execution metadata.- Returns:
- A Map containing the results of this node's execution.
Keys in this map become available variables for downstream nodes.
Note: Returningnullis treated as an empty map.
-
getNodeType
Description copied from interface:NodeExecutorUnique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.- Specified by:
getNodeTypein interfaceNodeExecutor- Returns:
- The unique type string (e.g., "httpRequest", "llmChat").
-