Class TaskSolverRunner

java.lang.Object
neqsim.mcp.runners.TaskSolverRunner

public final class TaskSolverRunner extends Object
Task solver and multi-domain composition runner.

Two capabilities in one class:

  • solve_task — Takes a high-level engineering task description and structured parameters, classifies the task, builds a multi-step execution plan (sequence of existing runners), executes each step passing results between them, validates the combined output, and returns a structured engineering report.
  • compose_workflow — Chains multiple domain runners in sequence (e.g., Reservoir → Process → Pipeline → Economics) with automatic data flow between stages.
Version:
1.0
Author:
Even Solbraa
  • Field Details

    • GSON

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

    • TaskSolverRunner

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

    • solveTask

      public static String solveTask(String json)
      Solves a high-level engineering task by planning and executing a sequence of runner steps.

      Input JSON format:

      {
        "task": "Design a 3-stage compression system from 5 to 150 bara",
        "fluid": { "components": {...}, "eos": "srk", "temperature": 298.15, "pressure": 5.0 },
        "parameters": { "stages": 3, "outletPressure": 150.0, "intercoolerTemp": 40.0 },
        "validate": true
      }
      
      Parameters:
      json - the task description JSON
      Returns:
      JSON with classification, plan, step results, validation, and summary
    • composeWorkflow

      public static String composeWorkflow(String json)
      Composes a multi-domain workflow by chaining specified runners in sequence.

      Input JSON format:

      {
        "workflow": "reservoir-to-economics",
        "fluid": { ... },
        "steps": [
          { "runner": "flash", "input": { "temperature": 25, "pressure": 60 } },
          { "runner": "process", "input": { "process": [...] } },
          { "runner": "pipeline", "input": { "length": 50000, "diameter": 0.3 } }
        ]
      }
      
      Parameters:
      json - the workflow JSON
      Returns:
      JSON with all step results and combined output
    • classifyTask

      private static String classifyTask(String task, com.google.gson.JsonObject input)
      Classifies a task description into a category.
      Parameters:
      task - the task description
      input - the full input JSON
      Returns:
      the task category
    • buildPlan

      private static List<TaskSolverRunner.PlanStep> buildPlan(String taskType, com.google.gson.JsonObject input)
      Builds an execution plan based on task type.
      Parameters:
      taskType - the classified task type
      input - the full input JSON
      Returns:
      list of plan steps
    • buildStepInput

      private static String buildStepInput(TaskSolverRunner.PlanStep step, com.google.gson.JsonObject originalInput, com.google.gson.JsonObject carryForward)
      Builds input JSON for a specific step.
      Parameters:
      step - the plan step
      originalInput - the original task input
      carryForward - data carried from previous steps
      Returns:
      JSON input for the step runner
    • executeStep

      private static String executeStep(TaskSolverRunner.PlanStep step, String inputJson)
      Executes a single step by routing to the appropriate runner.
      Parameters:
      step - the plan step
      inputJson - the step input JSON
      Returns:
      the runner output JSON
    • buildTaskReport

      private static String buildTaskReport(String task, String taskType, List<TaskSolverRunner.PlanStep> plan, List<TaskSolverRunner.StepResult> results, com.google.gson.JsonObject carryForward, String validationReport, long totalTimeMs)
      Builds the final task report.
      Parameters:
      task - the original task description
      taskType - the classified type
      plan - the execution plan
      results - the step results
      carryForward - the combined data
      validationReport - the validation report JSON, or null
      totalTimeMs - total execution time
      Returns:
      the complete report JSON
    • errorJson

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