donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
51 lines • 3.17 kB
TypeScript
import type { z } from 'zod/v4';
import type { CodeGenerationOptions } from '../models/CodeGenerationOptions';
import type { ProposedToolCall } from '../models/ProposedToolCall';
import type { ToolCall } from '../models/ToolCall';
import type { ToolCallContext } from '../models/ToolCallContext';
import type { ToolCallResult } from '../models/ToolCallResult';
/** Represents a tool call to be invoked by a DonobuFlow. */
export declare abstract class Tool<CallSchema extends z.ZodObject, CallFromGptSchema extends z.ZodObject> {
readonly name: string;
readonly description: string;
readonly inputSchema: CallSchema;
readonly inputSchemaForGpt: CallFromGptSchema;
readonly requiresGpt: boolean;
readonly controlPanelMessage: string;
readonly supportedTargets: string[];
/**
* @param name This is the name for the tool that will be shared with the LLM when making requests.
* @param description This is the description that will be shared with the LLM when making requests.
* @param inputSchema This is the JSON-schema for the tool when it is invoked by a non-LLM.
* @param inputSchemaForGpt This is the JSON-schema that will be shared with the LLM when making
* requests during autonomous flows.
* @param requiresGpt Set to true if this tool requires the usage of a GPT.
* @param controlPanelMessage This is the message that will be displayed in the front-end control
* panel when this tool is invoked, assuming the control panel is enabled.
* If not provided, it will be automatically generated from the name.
* @param supportedTargets The target types this tool is compatible with (e.g. `['web']`,
* `['mobile']`). An empty array means the tool is target-agnostic and
* can be used with any target type.
*/
protected constructor(name: string, description: string, inputSchema: CallSchema, inputSchemaForGpt: CallFromGptSchema, requiresGpt?: boolean, controlPanelMessage?: string, supportedTargets?: string[]);
/**
* Invoke the tool with the given context and parameters.
*/
abstract call(context: ToolCallContext, parameters: z.infer<CallSchema>): Promise<ToolCallResult>;
/**
* Invoke the tool as made from a GPT with the given context and parameters.
*/
abstract callFromGpt(context: ToolCallContext, parameters: z.infer<CallFromGptSchema>): Promise<ToolCallResult>;
/**
* Transform a completed tool call into a {@link ProposedToolCall} suitable
* for deterministic replay / code generation.
*
* The default implementation is a passthrough — `{ name, parameters }` —
* which is correct for tools that have no replay-specific logic
* (waits, assertions, markers, etc.). Tools that need to hoist
* selector metadata out of their outcome, strip LLM-only fields, or
* otherwise rewrite themselves override this method.
*/
prepareForRerun(toolCall: ToolCall, _options: CodeGenerationOptions): ProposedToolCall;
}
//# sourceMappingURL=Tool.d.ts.map