navigate.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var navigate_exports = {};
  20. __export(navigate_exports, {
  21. default: () => navigate_default
  22. });
  23. module.exports = __toCommonJS(navigate_exports);
  24. var import_bundle = require("../../sdk/bundle");
  25. var import_tool = require("./tool");
  26. const navigate = (0, import_tool.defineTool)({
  27. capability: "core",
  28. schema: {
  29. name: "browser_navigate",
  30. title: "Navigate to a URL",
  31. description: "Navigate to a URL",
  32. inputSchema: import_bundle.z.object({
  33. url: import_bundle.z.string().describe("The URL to navigate to")
  34. }),
  35. type: "action"
  36. },
  37. handle: async (context, params, response) => {
  38. const tab = await context.ensureTab();
  39. await tab.navigate(params.url);
  40. response.setIncludeSnapshot();
  41. response.addCode(`await page.goto('${params.url}');`);
  42. }
  43. });
  44. const goBack = (0, import_tool.defineTabTool)({
  45. capability: "core",
  46. schema: {
  47. name: "browser_navigate_back",
  48. title: "Go back",
  49. description: "Go back to the previous page",
  50. inputSchema: import_bundle.z.object({}),
  51. type: "action"
  52. },
  53. handle: async (tab, params, response) => {
  54. await tab.page.goBack();
  55. response.setIncludeSnapshot();
  56. response.addCode(`await page.goBack();`);
  57. }
  58. });
  59. var navigate_default = [
  60. navigate,
  61. goBack
  62. ];