donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
37 lines • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GoForwardOrBackTool = exports.Direction = void 0;
const Tool_1 = require("./Tool");
const ToolCallResult_1 = require("../models/ToolCallResult");
const PlaywrightUtils_1 = require("../utils/PlaywrightUtils");
var Direction;
(function (Direction) {
Direction["FORWARD"] = "FORWARD";
Direction["BACK"] = "BACK";
})(Direction || (exports.Direction = Direction = {}));
class GoForwardOrBackTool extends Tool_1.Tool {
constructor() {
super(GoForwardOrBackTool.NAME, 'Navigate forward or back in the webpage history.', 'GoForwardOrBackToolCoreParameters', 'GoForwardOrBackToolGptParameters');
}
async call(context, parameters) {
const page = context.page;
switch (parameters.direction) {
case Direction.FORWARD: {
await page.goForward();
break;
}
case Direction.BACK: {
await page.goBack();
break;
}
}
await PlaywrightUtils_1.PlaywrightUtils.waitForPageStability(page);
return ToolCallResult_1.ToolCallResult.successful();
}
async callFromGpt(context, parameters) {
return this.call(context, parameters);
}
}
exports.GoForwardOrBackTool = GoForwardOrBackTool;
GoForwardOrBackTool.NAME = 'goForwardOrBack';
//# sourceMappingURL=GoForwardOrBackTool.js.map