donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
48 lines • 2.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tool = void 0;
const VerbConverter_1 = require("../utils/VerbConverter");
/** Represents a tool call to be invoked by a DonobuFlow. */
class Tool {
/**
* @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.
*/
constructor(name, description, inputSchema, inputSchemaForGpt, requiresGpt = false, controlPanelMessage = VerbConverter_1.VerbConverter.toPresentTenseAction(name), supportedTargets = []) {
this.name = name;
this.description = description;
this.inputSchema = inputSchema;
this.inputSchemaForGpt = inputSchemaForGpt;
this.requiresGpt = requiresGpt;
this.controlPanelMessage = controlPanelMessage;
this.supportedTargets = supportedTargets;
}
/**
* 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, _options) {
return {
name: toolCall.toolName,
parameters: toolCall.parameters,
};
}
}
exports.Tool = Tool;
//# sourceMappingURL=Tool.js.map