UNPKG

@auto-browse/auto-browse

Version:
40 lines (39 loc) 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.browser_go_back = 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 back in browser history * Includes dummy property to satisfy Gemini's API requirement for non-empty object properties */ const goBackSchema = zod_1.z.object({ _: zod_1.z .string() .optional() .describe("No parameters required for this operation"), }); exports.browser_go_back = (0, tools_1.tool)(async () => { try { console.log(`[Go Back Tool] Starting operation`); const result = await test_1.test.step(`Go Back`, async () => { return await (0, utils_1.runAndWait)(context_1.context, "Navigated back", async (page) => { await page.goBack(); }, true); }); console.log(`[Go Back Tool] Operation completed`); return result; } catch (error) { const errorMessage = `Failed to go back: ${error instanceof Error ? error.message : "Unknown error"}`; console.error(`[Go Back Tool] Error:`, errorMessage); return errorMessage; } }, { name: "goBack", description: "Go back to the previous page", schema: goBackSchema, });