Implementation:A9T9 RPA MacroAgentTools
| Knowledge Sources | |
|---|---|
| Domains | AI_Agent, MCP, Tool_Execution |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Concrete tool for executing AI-agent tool calls (macro creation, execution, inspection) against the Ui.Vision extension, provided by the Ui.Vision macro agent tools module.
Description
The MacroAgentTools class (`src/services/ai/macro_agent/tools.ts`) implements the tool layer used by both the built-in AI macro agent and the MCP bridge. It receives tool calls (by name + arguments) from the AI conversation or the MCP bridge and executes them against the extension.
The MACRO_AGENT_TOOLS array defines the tool schemas (name, description, JSON-schema parameters) exposed to the AI model. Tools include:
- `get_macro`: return the macro currently in the editor
- `set_macro`: apply changes to the editor's macro (JS script or command table)
- `create_macro`: create a new JS script macro in the "AI Generated" folder
- `run_macro`: run the current macro and return the execution log
- `browser_snapshot`: return the page as an accessibility tree or fields list (with `ref=N` locators)
- `click_at`: click a point (x, y) from the last screenshot (exploration only)
- `get_screenshot`: capture a screenshot
- `list_macros`: list stored macros
- `get_logs`: return recent log lines
- `get_authoring_guide`: return the uiv.* API authoring guide
The `executeToolCall(name, data)` method dispatches to the appropriate tool handler, which interacts with the editor (Redux store), the player, the script runner, and the screenshot service.
Usage
The class is instantiated by `MacroAgentService` and by `McpBridgeClient`. It is not called directly by user code — it is the execution backend for AI-driven automation.
Code Reference
Source Location
- Repository: A9T9/RPA
- File: src/services/ai/macro_agent/tools.ts
- Lines: L201-L400 (MACRO_AGENT_TOOLS definitions), L1481-L4301 (MacroAgentTools class with tool handlers)
Signature
export const MACRO_AGENT_TOOLS: Array<{
name: string,
description: string,
parameters: any
}>
class MacroAgentTools {
constructor(params: MacroAgentToolsParams)
executeToolCall(name: string, data: object): Promise<ToolResult>
// Individual tool handlers:
get_macro(): ToolResult
set_macro(data): ToolResult
create_macro(data): ToolResult
run_macro(data): ToolResult
browser_snapshot(data): ToolResult
get_screenshot(): ToolResult
list_macros(): ToolResult
get_logs(log_limit?: number): ToolResult
get_authoring_guide(): ToolResult
}
Import
import { MacroAgentTools, MACRO_AGENT_TOOLS } from '@/services/ai/macro_agent/tools'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Tool name (set_macro, run_macro, browser_snapshot, etc.) |
| data | object | Yes | Tool-specific arguments (script, name, log_limit, url, mode, find, etc.) |
Outputs
| Name | Type | Description |
|---|---|---|
| ToolResult | object | Result with content (text/image), isError flag, and optional metadata |
Usage Examples
Execute a Tool Call
import { MacroAgentTools } from '@/services/ai/macro_agent/tools'
const tools = new MacroAgentTools({
logMessage: (msg) => console.log(msg),
shouldStop: () => false,
captureScreenShotFunction: async () => new ArrayBuffer(0)
})
// Create a new macro:
const result = await tools.executeToolCall('create_macro', {
name: 'Login Test',
script: `uiv.goto('https://example.com'); uiv.page.fill('name=user', 'admin');`
})
// Run the macro:
const runResult = await tools.executeToolCall('run_macro', {})
// Inspect the page:
const snapshot = await tools.executeToolCall('browser_snapshot', { mode: 'tree' })