Class ExecuteCommandExecutor

java.lang.Object
ai.nervemind.app.executor.ExecuteCommandExecutor
All Implemented Interfaces:
NodeExecutor

@Component public class ExecuteCommandExecutor extends Object implements 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

Execute command node configuration parameters
ParameterTypeDefaultDescription
commandString-Required. Command to execute
argumentsList[]Arguments to pass to command
workingDirectoryStringsystem tempWorking directory
timeoutInteger300Timeout in seconds
shellStringauto"cmd", "powershell", "bash", "sh"
environmentMap{}Environment variables to set
captureOutputBooleantrueCapture stdout/stderr
failOnErrorBooleantrueFail 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

Output keys added by this executor
KeyTypeDescription
exitCodeIntegerProcess exit code (0 = success)
stdoutStringStandard output captured from process
stderrStringStandard error captured from process
successBooleanTrue if exit code is 0
timedOutBooleanTrue if command exceeded timeout
durationMsLongExecution 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 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: NodeExecutor
      Executes the business logic for this node type.
      Specified by:
      execute in interface NodeExecutor
      Parameters:
      node - The node definition containing parameters and configuration. Use Node.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: Returning null is treated as an empty map.
    • getNodeType

      public String getNodeType()
      Description copied from interface: NodeExecutor
      Unique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.
      Specified by:
      getNodeType in interface NodeExecutor
      Returns:
      The unique type string (e.g., "httpRequest", "llmChat").