@auto-browse/auto-browse
Version:
AI-powered browser automation
40 lines (39 loc) • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.browser_go_forward = void 0;
const tools_1 = require("@langchain/core/tools");
const zod_1 = require("zod");
const test_1 = require("@playwright/test");
const utils_1 = require("./utils");
const context_1 = require("../browser/context");
/**
* Schema for going forward in browser history
* Includes dummy property to satisfy Gemini's API requirement for non-empty object properties
*/
const goForwardSchema = zod_1.z.object({
_: zod_1.z
.string()
.optional()
.describe("No parameters required for this operation"),
});
exports.browser_go_forward = (0, tools_1.tool)(async () => {
try {
console.log(`[Go Forward Tool] Starting operation`);
const result = await test_1.test.step(`Go Forward`, async () => {
return await (0, utils_1.runAndWait)(context_1.context, "Navigated forward", async (page) => {
await page.goForward();
}, true);
});
console.log(`[Go Forward Tool] Operation completed`);
return result;
}
catch (error) {
const errorMessage = `Failed to go forward: ${error instanceof Error ? error.message : "Unknown error"}`;
console.error(`[Go Forward Tool] Error:`, errorMessage);
return errorMessage;
}
}, {
name: "goForward",
description: "Go forward to the next page",
schema: goForwardSchema,
});