Class ActFunctionTools

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

public class ActFunctionTools extends Object implements FunctionTools
  • Constructor Details

    • ActFunctionTools

      public ActFunctionTools()
  • Method Details

    • applyTools

      public void applyTools(Genai provider)
      Specified by:
      applyTools in interface FunctionTools
    • getActList

      public Object getActList(com.fasterxml.jackson.databind.JsonNode params, File workingDir) throws IOException
      Lists all available Act TOML files in the specified directory or built-in directory.
      Throws:
      IOException
    • getBaseActList

      public Set<String> getBaseActList() throws IOException
      Throws:
      IOException
    • getActDetails

      public Object getActDetails(com.fasterxml.jackson.databind.JsonNode props, File workingDir) throws IOException
      Throws:
      IOException
    • moveToEpisode

      public Object moveToEpisode(com.fasterxml.jackson.databind.JsonNode props, File workingDir)
      Moves to the next episode, or to the episode specified by 'id' if provided.
      Parameters:
      params - The first argument is expected to be a JsonNode containing an optional 'id' property. The second argument is a File representing the project directory.
      Returns:
      Never returns normally; always throws MoveToEpisodeException.
    • repeateEpisode

      public Object repeateEpisode(com.fasterxml.jackson.databind.JsonNode props, File workingDir)
      Repeats the current episode by throwing a RepeatEpisodeException.
      Parameters:
      props - The first argument is expected to be a JsonNode (can be empty or contain context).
      workingDir - The project directory.
      Returns:
      Never returns normally; always throws RepeatEpisodeException.
    • performAct

      public Object performAct(com.fasterxml.jackson.databind.JsonNode props, File workingDir) throws IOException
      Performs an act operation based on the provided properties and working directory.

      This method configures act execution using the supplied JSON properties and a working directory. It logs the operation, parses environment properties, sets up the act processor, and scans documents in the specified directory. The act name and other configuration parameters are extracted from the props JSON node.

      Properties in props:

      • actName (required): The name of the act to perform.
      • properties (optional): A string containing environment-style key-value pairs (e.g., "KEY1=VALUE1;KEY2=VALUE2").
        • model (GWConstants.MODEL_PROP_NAME): The model to use for act processing. If not specified, defaults to null.
        • scanDir (GWConstants.SCAN_DIR_PROP_NAME): The directory to scan for documents. If not specified, defaults to the provided workingDir path.
        • actsLocation (GWConstants.ACTS_LOCATION_PROP_NAME): The location of act definitions. If not specified, defaults to null.

      Example:

       JsonNode props = ...; // JSON with "actName" and optional "properties"
       File workingDir = new File("/path/to/dir");
       Object result = performAct(props, workingDir);
       

      Parameters:
      props - JSON node containing act configuration, including "actName" and optional "properties" string
      workingDir - the directory in which to perform the act operation
      Returns:
      a result object indicating the outcome of the act operation (typically "success")
      Throws:
      IOException - if an I/O error occurs during document scanning or act processing
    • setConfigurator

      public void setConfigurator(Configurator configurator)
      Specified by:
      setConfigurator in interface FunctionTools