Class AutomationRunner

java.lang.Object
neqsim.mcp.runners.AutomationRunner

public class AutomationRunner extends Object
Stateless automation and lifecycle runner for MCP integration.

Provides string-addressable variable access via ProcessAutomation and lifecycle state management via ProcessSystemState. Designed for agentic workflows where LLMs need to discover, read, and write simulation variables without navigating Java class hierarchies.

Version:
1.0
Author:
Even Solbraa
  • Field Details

    • GSON

      private static final com.google.gson.Gson GSON
  • Constructor Details

    • AutomationRunner

      private AutomationRunner()
      Private constructor — all methods are static.
  • Method Details

    • listUnits

      public static String listUnits(String processJson)
      Runs a process from JSON and returns the list of equipment unit names.

      Builds and runs the process, then queries ProcessAutomation.getUnitList() to discover all addressable equipment.

      Parameters:
      processJson - the JSON process definition
      Returns:
      JSON string with list of unit names and their types
    • listVariables

      public static String listVariables(String processJson, String unitName)
      Runs a process from JSON and returns all variables for a specific equipment unit with self-healing. If the unit name is incorrect, attempts fuzzy matching and returns suggestions.
      Parameters:
      processJson - the JSON process definition
      unitName - the equipment unit name to query variables for
      Returns:
      JSON string with list of variables including address, type, unit, and description
    • getVariable

      public static String getVariable(String processJson, String address, String unit)
      Runs a process from JSON and reads a specific variable value with self-healing. If the address is incorrect, attempts fuzzy matching and auto-correction, returning suggestions in the response.
      Parameters:
      processJson - the JSON process definition
      address - the dot-notation variable address (e.g., "HP Sep.gasOutStream.temperature")
      unit - the desired unit of measurement (e.g., "C", "bara", "kg/hr")
      Returns:
      JSON string with the variable value, auto-correction info, or diagnostic suggestions
    • setVariableAndRun

      public static String setVariableAndRun(String processJson, String address, double value, String unit)
      Runs a process from JSON, modifies a variable with self-healing, re-runs, and returns the updated results. If the address is incorrect, attempts fuzzy matching and auto-correction. Also validates values against physical bounds before setting.
      Parameters:
      processJson - the JSON process definition
      address - the dot-notation variable address to modify
      value - the new value to set
      unit - the unit of the value
      Returns:
      JSON string with the updated simulation results or diagnostic info
    • saveState

      public static String saveState(String processJson, String stateName, String stateVersion)
      Runs a process from JSON and saves its state as a lifecycle snapshot.
      Parameters:
      processJson - the JSON process definition
      stateName - name for the snapshot
      stateVersion - version string for the snapshot
      Returns:
      JSON string with the serialized process state
    • compareStates

      public static String compareStates(String stateJson1, String stateJson2)
      Compares two process states and returns the differences.
      Parameters:
      stateJson1 - the first process state as JSON
      stateJson2 - the second process state as JSON
      Returns:
      JSON string with the differences between the two states
    • diagnose

      public static String diagnose(String processJson, String failedAddress, String operation)
      Diagnoses a failed automation operation and returns suggestions for fixing it. This is the entry point agents should call when an automation operation returns an error to get actionable remediation hints.
      Parameters:
      processJson - the JSON process definition
      failedAddress - the address that failed (e.g., "HP separator.gasOut.temp")
      operation - the operation that failed ("get", "set", or "list")
      Returns:
      JSON string with diagnostic information including suggestions and auto-corrections
    • getLearningReport

      public static String getLearningReport(String processJson)
      Returns the learning report from operation history, summarizing success rates, error patterns, learned corrections, and recommendations.
      Parameters:
      processJson - the JSON process definition (used to initialize the automation)
      Returns:
      JSON string with learning statistics and recommendations
    • errorJson

      private static String errorJson(String code, String message)
      Builds a standard error JSON response.
      Parameters:
      code - the error code
      message - the error message
      Returns:
      JSON error string