ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / mcp / terminal / commands.js
Source Blame History 333 lines
f7eb47b… lmata 1 "use strict";
f7eb47b… lmata 2 var __defProp = Object.defineProperty;
f7eb47b… lmata 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
f7eb47b… lmata 4 var __getOwnPropNames = Object.getOwnPropertyNames;
f7eb47b… lmata 5 var __hasOwnProp = Object.prototype.hasOwnProperty;
f7eb47b… lmata 6 var __export = (target, all) => {
f7eb47b… lmata 7 for (var name in all)
f7eb47b… lmata 8 __defProp(target, name, { get: all[name], enumerable: true });
f7eb47b… lmata 9 };
f7eb47b… lmata 10 var __copyProps = (to, from, except, desc) => {
f7eb47b… lmata 11 if (from && typeof from === "object" || typeof from === "function") {
f7eb47b… lmata 12 for (let key of __getOwnPropNames(from))
f7eb47b… lmata 13 if (!__hasOwnProp.call(to, key) && key !== except)
f7eb47b… lmata 14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
f7eb47b… lmata 15 }
f7eb47b… lmata 16 return to;
f7eb47b… lmata 17 };
f7eb47b… lmata 18 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
f7eb47b… lmata 19 var commands_exports = {};
f7eb47b… lmata 20 __export(commands_exports, {
f7eb47b… lmata 21 commands: () => commands
f7eb47b… lmata 22 });
f7eb47b… lmata 23 module.exports = __toCommonJS(commands_exports);
f7eb47b… lmata 24 var import_mcpBundle = require("playwright-core/lib/mcpBundle");
f7eb47b… lmata 25 var import_command = require("./command");
f7eb47b… lmata 26 const click = (0, import_command.declareCommand)({
f7eb47b… lmata 27 name: "click",
f7eb47b… lmata 28 description: "Perform click on a web page",
f7eb47b… lmata 29 args: import_mcpBundle.z.object({
f7eb47b… lmata 30 ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
f7eb47b… lmata 31 }),
f7eb47b… lmata 32 options: import_mcpBundle.z.object({
f7eb47b… lmata 33 button: import_mcpBundle.z.string().optional().describe("Button to click, defaults to left"),
f7eb47b… lmata 34 modifiers: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe("Modifier keys to press")
f7eb47b… lmata 35 }),
f7eb47b… lmata 36 toolName: "browser_click",
f7eb47b… lmata 37 toolParams: ({ ref }, { button, modifiers }) => ({ ref, button, modifiers })
f7eb47b… lmata 38 });
f7eb47b… lmata 39 const doubleClick = (0, import_command.declareCommand)({
f7eb47b… lmata 40 name: "dblclick",
f7eb47b… lmata 41 description: "Perform double click on a web page",
f7eb47b… lmata 42 args: import_mcpBundle.z.object({
f7eb47b… lmata 43 ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
f7eb47b… lmata 44 }),
f7eb47b… lmata 45 options: import_mcpBundle.z.object({
f7eb47b… lmata 46 button: import_mcpBundle.z.string().optional().describe("Button to click, defaults to left"),
f7eb47b… lmata 47 modifiers: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe("Modifier keys to press")
f7eb47b… lmata 48 }),
f7eb47b… lmata 49 toolName: "browser_click",
f7eb47b… lmata 50 toolParams: ({ ref }, { button, modifiers }) => ({ ref, button, modifiers, doubleClick: true })
f7eb47b… lmata 51 });
f7eb47b… lmata 52 const close = (0, import_command.declareCommand)({
f7eb47b… lmata 53 name: "close",
f7eb47b… lmata 54 description: "Close the page",
f7eb47b… lmata 55 args: import_mcpBundle.z.object({}),
f7eb47b… lmata 56 toolName: "browser_close",
f7eb47b… lmata 57 toolParams: () => ({})
f7eb47b… lmata 58 });
f7eb47b… lmata 59 const consoleMessages = (0, import_command.declareCommand)({
f7eb47b… lmata 60 name: "console",
f7eb47b… lmata 61 description: "Returns all console messages",
f7eb47b… lmata 62 args: import_mcpBundle.z.object({
f7eb47b… lmata 63 level: import_mcpBundle.z.string().optional().describe('Level of the console messages to return. Each level includes the messages of more severe levels. Defaults to "info".')
f7eb47b… lmata 64 }),
f7eb47b… lmata 65 toolName: "browser_console_messages",
f7eb47b… lmata 66 toolParams: ({ level }) => ({ level })
f7eb47b… lmata 67 });
f7eb47b… lmata 68 const drag = (0, import_command.declareCommand)({
f7eb47b… lmata 69 name: "drag",
f7eb47b… lmata 70 description: "Perform drag and drop between two elements",
f7eb47b… lmata 71 args: import_mcpBundle.z.object({
f7eb47b… lmata 72 startRef: import_mcpBundle.z.string().describe("Exact source element reference from the page snapshot"),
f7eb47b… lmata 73 endRef: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
f7eb47b… lmata 74 }),
f7eb47b… lmata 75 options: import_mcpBundle.z.object({
f7eb47b… lmata 76 headed: import_mcpBundle.z.boolean().default(false).describe("Run browser in headed mode")
f7eb47b… lmata 77 }),
f7eb47b… lmata 78 toolName: "browser_drag",
f7eb47b… lmata 79 toolParams: ({ startRef, endRef }) => ({ startRef, endRef })
f7eb47b… lmata 80 });
f7eb47b… lmata 81 const evaluate = (0, import_command.declareCommand)({
f7eb47b… lmata 82 name: "evaluate",
f7eb47b… lmata 83 description: "Evaluate JavaScript expression on page or element",
f7eb47b… lmata 84 args: import_mcpBundle.z.object({
f7eb47b… lmata 85 function: import_mcpBundle.z.string().describe("() => { /* code */ } or (element) => { /* code */ } when element is provided"),
f7eb47b… lmata 86 ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot")
f7eb47b… lmata 87 }),
f7eb47b… lmata 88 toolName: "browser_evaluate",
f7eb47b… lmata 89 toolParams: ({ function: fn, ref }) => ({ function: fn, ref })
f7eb47b… lmata 90 });
f7eb47b… lmata 91 const fileUpload = (0, import_command.declareCommand)({
f7eb47b… lmata 92 name: "upload-file",
f7eb47b… lmata 93 description: "Upload one or multiple files",
f7eb47b… lmata 94 args: import_mcpBundle.z.object({}),
f7eb47b… lmata 95 options: import_mcpBundle.z.object({
f7eb47b… lmata 96 paths: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe("The absolute paths to the files to upload. Can be single file or multiple files. If omitted, file chooser is cancelled.")
f7eb47b… lmata 97 }),
f7eb47b… lmata 98 toolName: "browser_file_upload",
f7eb47b… lmata 99 toolParams: (_, { paths }) => ({ paths })
f7eb47b… lmata 100 });
f7eb47b… lmata 101 const handleDialog = (0, import_command.declareCommand)({
f7eb47b… lmata 102 name: "handle-dialog",
f7eb47b… lmata 103 description: "Handle a dialog",
f7eb47b… lmata 104 args: import_mcpBundle.z.object({
f7eb47b… lmata 105 accept: import_mcpBundle.z.boolean().describe("Whether to accept the dialog."),
f7eb47b… lmata 106 promptText: import_mcpBundle.z.string().optional().describe("The text of the prompt in case of a prompt dialog.")
f7eb47b… lmata 107 }),
f7eb47b… lmata 108 toolName: "browser_handle_dialog",
f7eb47b… lmata 109 toolParams: ({ accept, promptText }) => ({ accept, promptText })
f7eb47b… lmata 110 });
f7eb47b… lmata 111 const hover = (0, import_command.declareCommand)({
f7eb47b… lmata 112 name: "hover",
f7eb47b… lmata 113 description: "Hover over element on page",
f7eb47b… lmata 114 args: import_mcpBundle.z.object({
f7eb47b… lmata 115 ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
f7eb47b… lmata 116 }),
f7eb47b… lmata 117 toolName: "browser_hover",
f7eb47b… lmata 118 toolParams: ({ ref }) => ({ ref })
f7eb47b… lmata 119 });
f7eb47b… lmata 120 const open = (0, import_command.declareCommand)({
f7eb47b… lmata 121 name: "open",
f7eb47b… lmata 122 description: "Open URL",
f7eb47b… lmata 123 args: import_mcpBundle.z.object({
f7eb47b… lmata 124 url: import_mcpBundle.z.string().describe("The URL to navigate to")
f7eb47b… lmata 125 }),
f7eb47b… lmata 126 options: import_mcpBundle.z.object({
f7eb47b… lmata 127 headed: import_mcpBundle.z.boolean().default(false).describe("Run browser in headed mode")
f7eb47b… lmata 128 }),
f7eb47b… lmata 129 toolName: "browser_open",
f7eb47b… lmata 130 toolParams: ({ url }, { headed }) => ({ url, headed })
f7eb47b… lmata 131 });
f7eb47b… lmata 132 const navigateBack = (0, import_command.declareCommand)({
f7eb47b… lmata 133 name: "go-back",
f7eb47b… lmata 134 description: "Go back to the previous page",
f7eb47b… lmata 135 args: import_mcpBundle.z.object({}),
f7eb47b… lmata 136 toolName: "browser_navigate_back",
f7eb47b… lmata 137 toolParams: () => ({})
f7eb47b… lmata 138 });
f7eb47b… lmata 139 const networkRequests = (0, import_command.declareCommand)({
f7eb47b… lmata 140 name: "network-requests",
f7eb47b… lmata 141 description: "Returns all network requests since loading the page",
f7eb47b… lmata 142 args: import_mcpBundle.z.object({}),
f7eb47b… lmata 143 options: import_mcpBundle.z.object({
f7eb47b… lmata 144 includeStatic: import_mcpBundle.z.boolean().optional().describe("Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false.")
f7eb47b… lmata 145 }),
f7eb47b… lmata 146 toolName: "browser_network_requests",
f7eb47b… lmata 147 toolParams: (_, { includeStatic }) => ({ includeStatic })
f7eb47b… lmata 148 });
f7eb47b… lmata 149 const pressKey = (0, import_command.declareCommand)({
f7eb47b… lmata 150 name: "press",
f7eb47b… lmata 151 description: "Press a key on the keyboard",
f7eb47b… lmata 152 args: import_mcpBundle.z.object({
f7eb47b… lmata 153 key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
f7eb47b… lmata 154 }),
f7eb47b… lmata 155 toolName: "browser_press_key",
f7eb47b… lmata 156 toolParams: ({ key }) => ({ key })
f7eb47b… lmata 157 });
f7eb47b… lmata 158 const resize = (0, import_command.declareCommand)({
f7eb47b… lmata 159 name: "resize",
f7eb47b… lmata 160 description: "Resize the browser window",
f7eb47b… lmata 161 args: import_mcpBundle.z.object({
f7eb47b… lmata 162 width: import_mcpBundle.z.number().describe("Width of the browser window"),
f7eb47b… lmata 163 height: import_mcpBundle.z.number().describe("Height of the browser window")
f7eb47b… lmata 164 }),
f7eb47b… lmata 165 toolName: "browser_resize",
f7eb47b… lmata 166 toolParams: ({ width, height }) => ({ width, height })
f7eb47b… lmata 167 });
f7eb47b… lmata 168 const runCode = (0, import_command.declareCommand)({
f7eb47b… lmata 169 name: "run-code",
f7eb47b… lmata 170 description: "Run Playwright code snippet",
f7eb47b… lmata 171 args: import_mcpBundle.z.object({
f7eb47b… lmata 172 code: import_mcpBundle.z.string().describe("A JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction.")
f7eb47b… lmata 173 }),
f7eb47b… lmata 174 toolName: "browser_run_code",
f7eb47b… lmata 175 toolParams: ({ code }) => ({ code })
f7eb47b… lmata 176 });
f7eb47b… lmata 177 const selectOption = (0, import_command.declareCommand)({
f7eb47b… lmata 178 name: "select-option",
f7eb47b… lmata 179 description: "Select an option in a dropdown",
f7eb47b… lmata 180 args: import_mcpBundle.z.object({
f7eb47b… lmata 181 ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot"),
f7eb47b… lmata 182 values: import_mcpBundle.z.array(import_mcpBundle.z.string()).describe("Array of values to select in the dropdown. This can be a single value or multiple values.")
f7eb47b… lmata 183 }),
f7eb47b… lmata 184 toolName: "browser_select_option",
f7eb47b… lmata 185 toolParams: ({ ref, values }) => ({ ref, values })
f7eb47b… lmata 186 });
f7eb47b… lmata 187 const snapshot = (0, import_command.declareCommand)({
f7eb47b… lmata 188 name: "snapshot",
f7eb47b… lmata 189 description: "Capture accessibility snapshot of the current page, this is better than screenshot",
f7eb47b… lmata 190 args: import_mcpBundle.z.object({}),
f7eb47b… lmata 191 options: import_mcpBundle.z.object({
f7eb47b… lmata 192 filename: import_mcpBundle.z.string().optional().describe("Save snapshot to markdown file instead of returning it in the response.")
f7eb47b… lmata 193 }),
f7eb47b… lmata 194 toolName: "browser_snapshot",
f7eb47b… lmata 195 toolParams: (_, { filename }) => ({ filename })
f7eb47b… lmata 196 });
f7eb47b… lmata 197 const screenshot = (0, import_command.declareCommand)({
f7eb47b… lmata 198 name: "screenshot",
f7eb47b… lmata 199 description: "Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.",
f7eb47b… lmata 200 args: import_mcpBundle.z.object({
f7eb47b… lmata 201 ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot.")
f7eb47b… lmata 202 }),
f7eb47b… lmata 203 options: import_mcpBundle.z.object({
f7eb47b… lmata 204 filename: import_mcpBundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified."),
f7eb47b… lmata 205 fullPage: import_mcpBundle.z.boolean().optional().describe("When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.")
f7eb47b… lmata 206 }),
f7eb47b… lmata 207 toolName: "browser_take_screenshot",
f7eb47b… lmata 208 toolParams: ({ ref }, { filename, fullPage }) => ({ filename, ref, fullPage })
f7eb47b… lmata 209 });
f7eb47b… lmata 210 const type = (0, import_command.declareCommand)({
f7eb47b… lmata 211 name: "type",
f7eb47b… lmata 212 description: "Type text into editable element",
f7eb47b… lmata 213 args: import_mcpBundle.z.object({
f7eb47b… lmata 214 text: import_mcpBundle.z.string().describe("Text to type into the element")
f7eb47b… lmata 215 }),
f7eb47b… lmata 216 options: import_mcpBundle.z.object({
f7eb47b… lmata 217 submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)")
f7eb47b… lmata 218 }),
f7eb47b… lmata 219 toolName: "browser_press_sequentially",
f7eb47b… lmata 220 toolParams: ({ text }, { submit }) => ({ text, submit })
f7eb47b… lmata 221 });
f7eb47b… lmata 222 const waitFor = (0, import_command.declareCommand)({
f7eb47b… lmata 223 name: "wait-for",
f7eb47b… lmata 224 description: "Wait for text to appear or disappear or a specified time to pass",
f7eb47b… lmata 225 args: import_mcpBundle.z.object({}),
f7eb47b… lmata 226 options: import_mcpBundle.z.object({
f7eb47b… lmata 227 time: import_mcpBundle.z.number().optional().describe("The time to wait in seconds"),
f7eb47b… lmata 228 text: import_mcpBundle.z.string().optional().describe("The text to wait for"),
f7eb47b… lmata 229 textGone: import_mcpBundle.z.string().optional().describe("The text to wait for to disappear")
f7eb47b… lmata 230 }),
f7eb47b… lmata 231 toolName: "browser_wait_for",
f7eb47b… lmata 232 toolParams: (_, { time, text, textGone }) => ({ time, text, textGone })
f7eb47b… lmata 233 });
f7eb47b… lmata 234 const tab = (0, import_command.declareCommand)({
f7eb47b… lmata 235 name: "tab",
f7eb47b… lmata 236 description: "Close a browser tab",
f7eb47b… lmata 237 args: import_mcpBundle.z.object({
f7eb47b… lmata 238 action: import_mcpBundle.z.string().describe(`Action to perform on tabs, 'list' | 'new' | 'close' | 'select'`),
f7eb47b… lmata 239 index: import_mcpBundle.z.number().optional().describe("Tab index. If omitted, current tab is closed.")
f7eb47b… lmata 240 }),
f7eb47b… lmata 241 toolName: "browser_tabs",
f7eb47b… lmata 242 toolParams: ({ action, index }) => ({ action, index })
f7eb47b… lmata 243 });
f7eb47b… lmata 244 const mouseClickXy = (0, import_command.declareCommand)({
f7eb47b… lmata 245 name: "mouse-click-xy",
f7eb47b… lmata 246 description: "Click left mouse button at a given position",
f7eb47b… lmata 247 args: import_mcpBundle.z.object({
f7eb47b… lmata 248 x: import_mcpBundle.z.number().describe("X coordinate"),
f7eb47b… lmata 249 y: import_mcpBundle.z.number().describe("Y coordinate")
f7eb47b… lmata 250 }),
f7eb47b… lmata 251 toolName: "browser_mouse_click_xy",
f7eb47b… lmata 252 toolParams: ({ x, y }) => ({ x, y })
f7eb47b… lmata 253 });
f7eb47b… lmata 254 const mouseDragXy = (0, import_command.declareCommand)({
f7eb47b… lmata 255 name: "mouse-drag-xy",
f7eb47b… lmata 256 description: "Drag left mouse button to a given position",
f7eb47b… lmata 257 args: import_mcpBundle.z.object({
f7eb47b… lmata 258 startX: import_mcpBundle.z.number().describe("Start X coordinate"),
f7eb47b… lmata 259 startY: import_mcpBundle.z.number().describe("Start Y coordinate"),
f7eb47b… lmata 260 endX: import_mcpBundle.z.number().describe("End X coordinate"),
f7eb47b… lmata 261 endY: import_mcpBundle.z.number().describe("End Y coordinate")
f7eb47b… lmata 262 }),
f7eb47b… lmata 263 toolName: "browser_mouse_drag_xy",
f7eb47b… lmata 264 toolParams: ({ startX, startY, endX, endY }) => ({ startX, startY, endX, endY })
f7eb47b… lmata 265 });
f7eb47b… lmata 266 const mouseMoveXy = (0, import_command.declareCommand)({
f7eb47b… lmata 267 name: "mouse-move-xy",
f7eb47b… lmata 268 description: "Move mouse to a given position",
f7eb47b… lmata 269 args: import_mcpBundle.z.object({
f7eb47b… lmata 270 x: import_mcpBundle.z.number().describe("X coordinate"),
f7eb47b… lmata 271 y: import_mcpBundle.z.number().describe("Y coordinate")
f7eb47b… lmata 272 }),
f7eb47b… lmata 273 toolName: "browser_mouse_move_xy",
f7eb47b… lmata 274 toolParams: ({ x, y }) => ({ x, y })
f7eb47b… lmata 275 });
f7eb47b… lmata 276 const pdfSave = (0, import_command.declareCommand)({
f7eb47b… lmata 277 name: "pdf-save",
f7eb47b… lmata 278 description: "Save page as PDF",
f7eb47b… lmata 279 args: import_mcpBundle.z.object({}),
f7eb47b… lmata 280 options: import_mcpBundle.z.object({
f7eb47b… lmata 281 filename: import_mcpBundle.z.string().optional().describe("File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.")
f7eb47b… lmata 282 }),
f7eb47b… lmata 283 toolName: "browser_pdf_save",
f7eb47b… lmata 284 toolParams: (_, { filename }) => ({ filename })
f7eb47b… lmata 285 });
f7eb47b… lmata 286 const startTracing = (0, import_command.declareCommand)({
f7eb47b… lmata 287 name: "start-tracing",
f7eb47b… lmata 288 description: "Start trace recording",
f7eb47b… lmata 289 args: import_mcpBundle.z.object({}),
f7eb47b… lmata 290 toolName: "browser_start_tracing",
f7eb47b… lmata 291 toolParams: () => ({})
f7eb47b… lmata 292 });
f7eb47b… lmata 293 const stopTracing = (0, import_command.declareCommand)({
f7eb47b… lmata 294 name: "stop-tracing",
f7eb47b… lmata 295 description: "Stop trace recording",
f7eb47b… lmata 296 args: import_mcpBundle.z.object({}),
f7eb47b… lmata 297 toolName: "browser_stop_tracing",
f7eb47b… lmata 298 toolParams: () => ({})
f7eb47b… lmata 299 });
f7eb47b… lmata 300 const commandsArray = [
f7eb47b… lmata 301 click,
f7eb47b… lmata 302 close,
f7eb47b… lmata 303 doubleClick,
f7eb47b… lmata 304 consoleMessages,
f7eb47b… lmata 305 drag,
f7eb47b… lmata 306 evaluate,
f7eb47b… lmata 307 fileUpload,
f7eb47b… lmata 308 handleDialog,
f7eb47b… lmata 309 hover,
f7eb47b… lmata 310 open,
f7eb47b… lmata 311 navigateBack,
f7eb47b… lmata 312 networkRequests,
f7eb47b… lmata 313 pressKey,
f7eb47b… lmata 314 resize,
f7eb47b… lmata 315 runCode,
f7eb47b… lmata 316 selectOption,
f7eb47b… lmata 317 snapshot,
f7eb47b… lmata 318 screenshot,
f7eb47b… lmata 319 type,
f7eb47b… lmata 320 waitFor,
f7eb47b… lmata 321 tab,
f7eb47b… lmata 322 mouseClickXy,
f7eb47b… lmata 323 mouseDragXy,
f7eb47b… lmata 324 mouseMoveXy,
f7eb47b… lmata 325 pdfSave,
f7eb47b… lmata 326 startTracing,
f7eb47b… lmata 327 stopTracing
f7eb47b… lmata 328 ];
f7eb47b… lmata 329 const commands = Object.fromEntries(commandsArray.map((cmd) => [cmd.name, cmd]));
f7eb47b… lmata 330 // Annotate the CommonJS export names for ESM import in node:
f7eb47b… lmata 331 0 && (module.exports = {
f7eb47b… lmata 332 commands
f7eb47b… lmata 333 });

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button