donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
34 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomToolRunnerTool = void 0;
const Tool_1 = require("./Tool");
/**
* This is a special Tool implementation that wraps a CustomTool to be used in a
* flow.
*/
class CustomToolRunnerTool extends Tool_1.Tool {
constructor(customTool) {
super(customTool.name, customTool.description, 'object', 'object', false);
// Override the inputSchema that were set in the parent constructor
Object.defineProperty(this, 'inputSchema', {
value: customTool.inputSchema,
});
Object.defineProperty(this, 'inputSchemaForGpt', {
value: customTool.inputSchema,
});
this.javascript = customTool.javascript;
}
async call(context, parameters) {
const result = await context.page.evaluate(this.javascript, parameters);
return {
isSuccessful: true,
forLlm: '' + JSON.stringify(result),
metadata: null,
};
}
async callFromGpt(context, parameters) {
return this.call(context, parameters);
}
}
exports.CustomToolRunnerTool = CustomToolRunnerTool;
//# sourceMappingURL=CustomToolRunnerTool.js.map