common.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 common_exports = {};
  20. __export(common_exports, {
  21. default: () => common_default
  22. });
  23. module.exports = __toCommonJS(common_exports);
  24. var import_bundle = require("../../sdk/bundle");
  25. var import_tool = require("./tool");
  26. const close = (0, import_tool.defineTool)({
  27. capability: "core",
  28. schema: {
  29. name: "browser_close",
  30. title: "Close browser",
  31. description: "Close the page",
  32. inputSchema: import_bundle.z.object({}),
  33. type: "action"
  34. },
  35. handle: async (context, params, response) => {
  36. await context.closeBrowserContext();
  37. response.setIncludeTabs();
  38. response.addCode(`await page.close()`);
  39. }
  40. });
  41. const resize = (0, import_tool.defineTabTool)({
  42. capability: "core",
  43. schema: {
  44. name: "browser_resize",
  45. title: "Resize browser window",
  46. description: "Resize the browser window",
  47. inputSchema: import_bundle.z.object({
  48. width: import_bundle.z.number().describe("Width of the browser window"),
  49. height: import_bundle.z.number().describe("Height of the browser window")
  50. }),
  51. type: "action"
  52. },
  53. handle: async (tab, params, response) => {
  54. response.addCode(`await page.setViewportSize({ width: ${params.width}, height: ${params.height} });`);
  55. await tab.waitForCompletion(async () => {
  56. await tab.page.setViewportSize({ width: params.width, height: params.height });
  57. });
  58. }
  59. });
  60. var common_default = [
  61. close,
  62. resize
  63. ];