donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
45 lines • 1.92 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GoForwardOrBackTool = exports.GoForwardOrBackGptSchema = exports.GoForwardOrBackCoreSchema = void 0;
const v4_1 = require("zod/v4");
const ToolCallResult_1 = require("../models/ToolCallResult");
const ToolSchema_1 = require("../models/ToolSchema");
const TargetUtils_1 = require("../utils/TargetUtils");
const GoToWebpageTool_1 = require("./GoToWebpageTool");
const Tool_1 = require("./Tool");
exports.GoForwardOrBackCoreSchema = v4_1.z.object({
direction: v4_1.z
.enum(['FORWARD', 'BACK'])
.describe('The direction to navigate - either FORWARD or BACK'),
timeout: GoToWebpageTool_1.GoToWebpageToolCoreParameters.shape.timeout,
waitUntil: GoToWebpageTool_1.GoToWebpageToolCoreParameters.shape.waitUntil,
});
exports.GoForwardOrBackGptSchema = v4_1.z.object({
...ToolSchema_1.BaseGptArgsSchema.shape,
...exports.GoForwardOrBackCoreSchema.shape,
});
class GoForwardOrBackTool extends Tool_1.Tool {
constructor() {
super(GoForwardOrBackTool.NAME, 'Navigate forward or back in the webpage history.', exports.GoForwardOrBackCoreSchema, exports.GoForwardOrBackGptSchema, false, undefined, ['web']);
}
async call(context, parameters) {
const page = (0, TargetUtils_1.webPage)(context);
switch (parameters.direction) {
case 'FORWARD': {
await page.goForward(parameters);
break;
}
case 'BACK': {
await page.goBack(parameters);
break;
}
}
return ToolCallResult_1.ToolCallResult.successful();
}
async callFromGpt(context, parameters) {
return this.call(context, parameters);
}
}
exports.GoForwardOrBackTool = GoForwardOrBackTool;
GoForwardOrBackTool.NAME = 'goForwardOrBack';
//# sourceMappingURL=GoForwardOrBackTool.js.map