Class CommandSpecFunctionTools

java.lang.Object
org.machanism.machai.gw.tools.CommandSpecFunctionTools
All Implemented Interfaces:
FunctionTools

public class CommandSpecFunctionTools extends Object implements FunctionTools
Provides function tools for task and process-execution control within an AIFileProcessor workflow.

The tool infrastructure exposes the annotated methods to the AI provider. Invoking a tool signals task completion or application termination by throwing the corresponding control-flow exception; the workflow host is responsible for handling that signal.

Author:
Viktor Tovstyi
  • Field Details

    • TASK_TERMINATED_BY_FUNCTION_TOOL_MESSAGE

      private static final String TASK_TERMINATED_BY_FUNCTION_TOOL_MESSAGE
      Default explanatory message used when a control-flow tool is invoked without an explicit message.
      See Also:
  • Constructor Details

    • CommandSpecFunctionTools

      public CommandSpecFunctionTools()
  • Method Details

    • terminateExecution

      public String terminateExecution(String message, int exitCode, File projectDir)
      Requests application termination by throwing a ProcessTerminationException. The exception carries the supplied message and exit code for handling by the workflow host. When omitted by the caller, the tool infrastructure supplies the annotation-defined defaults for message and exitCode.

      The projectDir argument is supplied by the tool infrastructure as invocation context and is not used when constructing the termination request.

      Parameters:
      message - human-readable message exposed to the host
      exitCode - process exit code requested from the host
      projectDir - project directory provided as invocation context; unused
      Returns:
      never returns normally because it always requests termination
      Throws:
      ProcessTerminationException - always, to request process termination
    • endTask

      public String endTask(String message)
      Completes the current task by throwing an EndTaskException. The host remains active and can accept subsequent tasks. When no message is supplied, the tool infrastructure uses its annotation-defined default message.
      Parameters:
      message - human-readable message describing task completion
      Returns:
      never returns normally because it always signals task completion
      Throws:
      EndTaskException - always, to request task completion