Class ActFunctionTools
- All Implemented Interfaces:
FunctionTools
This class exposes methods for:
- Loading Act template details (including instructions, input templates, and configuration options)
- Asynchronously performing an Act and storing the result for later retrieval
- Retrieving the result of a previously started Act by process ID
- Supplying prompt templates for Act execution
Acts are reusable, named workflows or actions defined in the project or classpath. This class supports both custom and built-in Act definitions, and handles asynchronous execution and result management using temporary files and process IDs.
Methods in this class are typically invoked by an AI provider or workflow engine to enable dynamic, tool-augmented project automation.
- Author:
- Viktor Tovstyi
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final org.slf4j.LoggerLogger for shell tool execution and diagnostics.(package private) final ResourceBundleResource bundle supplying prompt templates for generators. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactPrompts(String actName) AI prompt template that instructs the caller to execute an Act identified by name.getActDetails(String actName, File projectDir, Configurator configurator) AI functional tool that loads the details of a specific Act template, including its instructions, input template, and configuration options.getActResult(String processId) AI functional tool that retrieves the result of a previously started Act by its GUID.private StringgetFileName(String processId) performAct(String actName, File projectDir, Map<String, String> properties, boolean async, Configurator config) AI functional tool that performs the specified Act by name.
-
Field Details
-
ACT_FOLDER_NAME
- See Also:
-
logger
private static final org.slf4j.Logger loggerLogger for shell tool execution and diagnostics. -
mcpPromptBundle
Resource bundle supplying prompt templates for generators.
-
-
Constructor Details
-
ActFunctionTools
public ActFunctionTools()
-
-
Method Details
-
getActDetails
public Object getActDetails(String actName, File projectDir, Configurator configurator) throws IOException AI functional tool that loads the details of a specific Act template, including its instructions, input template, and configuration options. It searches both project-specific and built-in Act definitions and reports the matching definitions to the caller.- Parameters:
actName- The name of the Act to load.projectDir- The project directory containing custom Act definitions.configurator- The configuration used to locate custom Act definitions.- Returns:
- A map containing the matching custom and/or built-in Act details, or a message indicating that the Act was not found.
- Throws:
IOException- If an error occurs while loading an Act definition.
-
performAct
public Object performAct(String actName, File projectDir, Map<String, String> properties, boolean async, Configurator config) throws IOExceptionAI functional tool that performs the specified Act by name.Use this tool to trigger a predefined action or workflow identified by the given Act name. This method supports both synchronous and asynchronous execution modes based on the `async` parameter.
- Parameters:
actName- The name of the Act to perform.projectDir- The project directory where the Act will be executed.properties- Act properties to override default configuration values; may benull.async- Iftrue, the Act will be executed asynchronously, and the method will return immediately with a process ID. Iffalse, the Act will be executed synchronously, and the method will return the Act's result.config- The configuration object.- Returns:
- A response object containing the Act's result (for synchronous execution) or a process ID and status (for asynchronous execution).
- Throws:
IOException- If an error occurs during Act processing.
-
getFileName
-
getActResult
AI functional tool that retrieves the result of a previously started Act by its GUID.This method reconstructs the path to the temporary file where the Act result was stored, using the provided GUID and the system's temporary directory. If the result file exists, it reads and returns the result. If the file does not exist, it returns a status indicating that the result is still processing or unavailable.
- Parameters:
processId- The GUID returned when the Act was started. Used to identify the result file.- Returns:
- A map containing:
- guid: The provided GUID.
- status: "done" if the result is available, "processing" otherwise.
- result: The Act result object if available.
- message: An informational message if the result is not ready.
- Throws:
IOException- If there is an error reading the result from the temp file.
-
actPrompts
AI prompt template that instructs the caller to execute an Act identified by name. The returned template is resolved from the MCP prompt resource bundle.- Parameters:
actName- The name of the Act to perform.- Returns:
- The prompt template used to perform the Act.
-