donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
44 lines • 2.23 kB
TypeScript
import type { z } from 'zod/v4';
import type { ToolCall } from '../models/ToolCall';
import type { ToolCallContext } from '../models/ToolCallContext';
import type { ToolTemplateDataSource } from '../models/ToolTemplateDataSource';
import type { Tool } from '../tools/Tool';
/**
* Executes tool calls against a given list of tools.
*
* Construct with the specific tool set a flow is allowed to use. Tool
* *discovery* (which tools exist, defaults, plugins) is handled by
* {@link ToolRegistry} — this class only cares about *execution*.
*/
export declare class ToolManager {
readonly tools: Tool<z.ZodObject, z.ZodObject>[];
constructor(tools: Tool<z.ZodObject, z.ZodObject>[]);
/**
* Invokes a tool by name with the provided parameters.
*
* This method handles the entire tool execution lifecycle including:
* - Finding the appropriate tool by name
* - Processing any template strings in parameter values using the {{...}} syntax
* - Executing the tool with the processed parameters
* - Capturing screenshots after tool execution
* - Error handling and logging
*
* @param context - The context object containing page, persistence, metadata and other execution context
* @param toolName - The name of the tool to invoke
* @param toolParameters - Parameters to pass to the tool (template strings will be interpolated)
* @param isFromGpt - Whether this tool call is initiated from a GPT
*
* @returns A Promise resolving to a ToolCall object containing execution details and results
*/
invokeTool(context: ToolCallContext, toolName: string, toolParameters: Record<string, any>, isFromGpt: boolean): Promise<ToolCall>;
}
/**
* Builds a data source for template interpolation that includes the
* interpolated parameters of previous tool calls.
*
* The first tool call in the given history is assumed to require no
* interpolation; each subsequent call can reference the results of the
* ones before it via `{{$.calls[n].result}}` syntax.
*/
export declare function buildToolInterpolationDataSource(envData: Record<string, string>, previousToolCalls: ToolCall[]): ToolTemplateDataSource;
//# sourceMappingURL=ToolManager.d.ts.map