Package org.machanism.machai.gw.tools
The package is the integration boundary between an AI provider and a
project-scoped workflow. Implementations of
FunctionTools expose annotated methods
to the provider, while the processors in
ActProcessor and
AIFileProcessor perform the
corresponding workflow work. File and command paths are resolved against the
active project directory; asynchronous operations persist results under the
runtime temporary directory and return an identifier for later polling.
AI metadata and tool providers
Classes or methods annotated with
@Tool are Functional AI
Tools. Their names, parameter descriptions, default values, return
contracts, and failures are published as callable operations. Methods
annotated with @Prompt are
Prompt Templates; they supply reusable instructions from the
mcp-prompts resource bundle. This package currently declares no
classes or methods annotated with @Resource, so it provides no
Contextual Resources. Package-level Javadoc has no callable
parameters, return value, or thrown exception; those contracts are
documented on each public constructor and method.
Functional areas
ActFunctionToolsis the Act Functional AI Tool provider. It loads Act definitions, starts synchronous or asynchronous Act execution, polls serialized results, and exposes the Act Prompt Template.GuidanceFunctionToolsdiscovers files containing guidance tags, processes them synchronously or in the background, polls processing reports, and exposes the guidance-processing Prompt Template.FileFunctionToolslists files and folders, reads and writes project files, and applies validated unified or simplified patches throughPatchApplier.WebFunctionToolsretrieves HTTP(S) responses or project-scopedfile:content, supports CSS selection and text rendering, and performs REST requests with headers and Basic authentication.CommandFunctionToolsexecutes project-bounded operating-system commands, captures bounded output, and provides log paging and regular-expression search. It delegates policy checks toCommandSecurityChecker, whose deny-list violations produceDenyException. Command output and timing reports are maintained byLogBuilder.ProjectContextFunctionToolsstores, retrieves, pushes, and pops project-scoped workflow state. Values are shared by Acts and episodes but are not operating-system environment variables.ActSpecFunctionToolsis restricted to Act processing and signals episode navigation or repetition throughMoveToEpisodeExceptionandRepeatEpisodeException.CommandSpecFunctionToolsis restricted to file-processing workflows and signals task completion or application termination throughEndTaskExceptionandProcessTerminationException.
Typical usage
Register the provider applicable to the active processor, then invoke the
operation exposed by its @Tool metadata. A project-relative editing
workflow may read a source file, apply a targeted patch, and run an allowed
verification command:
read_file(path: "src/main/java/Example.java") apply_patch_to_file(file: "src/main/java/Example.java", patch: patchText) run_sys_command(command: "mvn test", dir: ".")
Callers must provide values matching each operation's @Param
declarations and handle its documented return value and exceptions. In
particular, command execution can reject unsafe input, while control-flow
exceptions intentionally request workflow transitions rather than indicating
ordinary tool failure. Asynchronous Act and guidance calls return a process
identifier; the corresponding result operation reports whether processing is
complete.
- Author:
- Viktor Tovstyi
-
ClassDescriptionProvides function tools for managing and executing Ghostwriter Acts within a project.Provides AI-callable functional tools for episode navigation and control within an
ActProcessorcontext.Provides function tools for executing and managing system commands within a project context.Functional interface used for handling stream read failures.Auto-closeable wrapper forExecutorServiceso it can be used with try-with-resources.Functional interface used for streaming output line processing.Loads and evaluates command deny-list rules used by host-side command execution tools.Provides function tools for task and process-execution control within anAIFileProcessorworkflow.Signals that a command has failed a deny-list security check and must not be executed.Exception used to signal the end of a task without terminating the application.Installs file-system tools into aProcessProvider.Provides function tools for discovering and processing files with guidance tags in project directories.AStringBuilder-like helper that retains only the lastmaxSizecharacters.Control-flow exception that requests navigation to a named or numbered Act episode.Applies unified and simplified search-and-replace diff patches to text files.Represents a patch hunk and its preferred zero-based starting position.Represents a parsed context, addition, or removal line in a patch hunk.Runtime control-flow exception that requests host application termination.Provides function tools for managing project-specific context variables.Runtime control-flow exception that requests repetition of the current Act episode.Provides host-side HTTP retrieval tools for aProcessProviderprovider.