@pedropaulovc/playwright 1.59.0-alpha-1769214875000

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +170 -0
  4. package/ThirdPartyNotices.txt +5042 -0
  5. package/cli.js +19 -0
  6. package/index.d.ts +17 -0
  7. package/index.js +17 -0
  8. package/index.mjs +18 -0
  9. package/jsx-runtime.js +42 -0
  10. package/jsx-runtime.mjs +21 -0
  11. package/lib/agents/agentParser.js +89 -0
  12. package/lib/agents/copilot-setup-steps.yml +34 -0
  13. package/lib/agents/generateAgents.js +348 -0
  14. package/lib/agents/playwright-test-coverage.prompt.md +31 -0
  15. package/lib/agents/playwright-test-generate.prompt.md +8 -0
  16. package/lib/agents/playwright-test-generator.agent.md +88 -0
  17. package/lib/agents/playwright-test-heal.prompt.md +6 -0
  18. package/lib/agents/playwright-test-healer.agent.md +55 -0
  19. package/lib/agents/playwright-test-plan.prompt.md +9 -0
  20. package/lib/agents/playwright-test-planner.agent.md +73 -0
  21. package/lib/common/config.js +281 -0
  22. package/lib/common/configLoader.js +344 -0
  23. package/lib/common/esmLoaderHost.js +104 -0
  24. package/lib/common/expectBundle.js +28 -0
  25. package/lib/common/expectBundleImpl.js +407 -0
  26. package/lib/common/fixtures.js +302 -0
  27. package/lib/common/globals.js +58 -0
  28. package/lib/common/ipc.js +60 -0
  29. package/lib/common/poolBuilder.js +85 -0
  30. package/lib/common/process.js +132 -0
  31. package/lib/common/suiteUtils.js +140 -0
  32. package/lib/common/test.js +321 -0
  33. package/lib/common/testLoader.js +101 -0
  34. package/lib/common/testType.js +298 -0
  35. package/lib/common/validators.js +68 -0
  36. package/lib/fsWatcher.js +67 -0
  37. package/lib/index.js +726 -0
  38. package/lib/internalsForTest.js +42 -0
  39. package/lib/isomorphic/events.js +77 -0
  40. package/lib/isomorphic/folders.js +30 -0
  41. package/lib/isomorphic/stringInternPool.js +69 -0
  42. package/lib/isomorphic/teleReceiver.js +520 -0
  43. package/lib/isomorphic/teleSuiteUpdater.js +157 -0
  44. package/lib/isomorphic/testServerConnection.js +225 -0
  45. package/lib/isomorphic/testServerInterface.js +16 -0
  46. package/lib/isomorphic/testTree.js +329 -0
  47. package/lib/isomorphic/types.d.js +16 -0
  48. package/lib/loader/loaderMain.js +59 -0
  49. package/lib/matchers/expect.js +311 -0
  50. package/lib/matchers/matcherHint.js +44 -0
  51. package/lib/matchers/matchers.js +383 -0
  52. package/lib/matchers/toBeTruthy.js +75 -0
  53. package/lib/matchers/toEqual.js +100 -0
  54. package/lib/matchers/toHaveURL.js +101 -0
  55. package/lib/matchers/toMatchAriaSnapshot.js +159 -0
  56. package/lib/matchers/toMatchSnapshot.js +342 -0
  57. package/lib/matchers/toMatchText.js +99 -0
  58. package/lib/mcp/browser/browserContextFactory.js +329 -0
  59. package/lib/mcp/browser/browserServerBackend.js +89 -0
  60. package/lib/mcp/browser/config.js +421 -0
  61. package/lib/mcp/browser/context.js +244 -0
  62. package/lib/mcp/browser/response.js +284 -0
  63. package/lib/mcp/browser/sessionLog.js +75 -0
  64. package/lib/mcp/browser/tab.js +351 -0
  65. package/lib/mcp/browser/tools/common.js +63 -0
  66. package/lib/mcp/browser/tools/console.js +61 -0
  67. package/lib/mcp/browser/tools/dialogs.js +59 -0
  68. package/lib/mcp/browser/tools/evaluate.js +61 -0
  69. package/lib/mcp/browser/tools/files.js +58 -0
  70. package/lib/mcp/browser/tools/form.js +63 -0
  71. package/lib/mcp/browser/tools/install.js +72 -0
  72. package/lib/mcp/browser/tools/keyboard.js +151 -0
  73. package/lib/mcp/browser/tools/mouse.js +159 -0
  74. package/lib/mcp/browser/tools/navigate.js +136 -0
  75. package/lib/mcp/browser/tools/network.js +78 -0
  76. package/lib/mcp/browser/tools/pdf.js +49 -0
  77. package/lib/mcp/browser/tools/runCode.js +76 -0
  78. package/lib/mcp/browser/tools/screenshot.js +87 -0
  79. package/lib/mcp/browser/tools/snapshot.js +207 -0
  80. package/lib/mcp/browser/tools/tabs.js +67 -0
  81. package/lib/mcp/browser/tools/tool.js +47 -0
  82. package/lib/mcp/browser/tools/tracing.js +74 -0
  83. package/lib/mcp/browser/tools/utils.js +94 -0
  84. package/lib/mcp/browser/tools/verify.js +143 -0
  85. package/lib/mcp/browser/tools/wait.js +63 -0
  86. package/lib/mcp/browser/tools.js +82 -0
  87. package/lib/mcp/browser/watchdog.js +44 -0
  88. package/lib/mcp/config.d.js +16 -0
  89. package/lib/mcp/extension/cdpRelay.js +351 -0
  90. package/lib/mcp/extension/extensionContextFactory.js +76 -0
  91. package/lib/mcp/extension/protocol.js +28 -0
  92. package/lib/mcp/index.js +61 -0
  93. package/lib/mcp/log.js +35 -0
  94. package/lib/mcp/program.js +109 -0
  95. package/lib/mcp/sdk/exports.js +28 -0
  96. package/lib/mcp/sdk/http.js +152 -0
  97. package/lib/mcp/sdk/inProcessTransport.js +71 -0
  98. package/lib/mcp/sdk/server.js +223 -0
  99. package/lib/mcp/sdk/tool.js +47 -0
  100. package/lib/mcp/terminal/SKILL.md +158 -0
  101. package/lib/mcp/terminal/cli.js +7 -0
  102. package/lib/mcp/terminal/command.js +56 -0
  103. package/lib/mcp/terminal/commands.js +519 -0
  104. package/lib/mcp/terminal/daemon.js +131 -0
  105. package/lib/mcp/terminal/help.json +47 -0
  106. package/lib/mcp/terminal/helpGenerator.js +115 -0
  107. package/lib/mcp/terminal/program.js +365 -0
  108. package/lib/mcp/terminal/socketConnection.js +80 -0
  109. package/lib/mcp/test/browserBackend.js +98 -0
  110. package/lib/mcp/test/generatorTools.js +122 -0
  111. package/lib/mcp/test/plannerTools.js +145 -0
  112. package/lib/mcp/test/seed.js +82 -0
  113. package/lib/mcp/test/streams.js +44 -0
  114. package/lib/mcp/test/testBackend.js +99 -0
  115. package/lib/mcp/test/testContext.js +285 -0
  116. package/lib/mcp/test/testTool.js +30 -0
  117. package/lib/mcp/test/testTools.js +108 -0
  118. package/lib/plugins/gitCommitInfoPlugin.js +198 -0
  119. package/lib/plugins/index.js +28 -0
  120. package/lib/plugins/webServerPlugin.js +237 -0
  121. package/lib/program.js +418 -0
  122. package/lib/reporters/base.js +638 -0
  123. package/lib/reporters/blob.js +138 -0
  124. package/lib/reporters/dot.js +99 -0
  125. package/lib/reporters/empty.js +32 -0
  126. package/lib/reporters/github.js +128 -0
  127. package/lib/reporters/html.js +633 -0
  128. package/lib/reporters/internalReporter.js +138 -0
  129. package/lib/reporters/json.js +254 -0
  130. package/lib/reporters/junit.js +232 -0
  131. package/lib/reporters/line.js +131 -0
  132. package/lib/reporters/list.js +253 -0
  133. package/lib/reporters/listModeReporter.js +69 -0
  134. package/lib/reporters/markdown.js +144 -0
  135. package/lib/reporters/merge.js +558 -0
  136. package/lib/reporters/multiplexer.js +112 -0
  137. package/lib/reporters/reporterV2.js +102 -0
  138. package/lib/reporters/teleEmitter.js +317 -0
  139. package/lib/reporters/versions/blobV1.js +16 -0
  140. package/lib/runner/dispatcher.js +530 -0
  141. package/lib/runner/failureTracker.js +72 -0
  142. package/lib/runner/lastRun.js +77 -0
  143. package/lib/runner/loadUtils.js +334 -0
  144. package/lib/runner/loaderHost.js +89 -0
  145. package/lib/runner/processHost.js +180 -0
  146. package/lib/runner/projectUtils.js +241 -0
  147. package/lib/runner/rebase.js +189 -0
  148. package/lib/runner/reporters.js +138 -0
  149. package/lib/runner/sigIntWatcher.js +96 -0
  150. package/lib/runner/storage.js +91 -0
  151. package/lib/runner/taskRunner.js +127 -0
  152. package/lib/runner/tasks.js +410 -0
  153. package/lib/runner/testGroups.js +125 -0
  154. package/lib/runner/testRunner.js +398 -0
  155. package/lib/runner/testServer.js +269 -0
  156. package/lib/runner/uiModeReporter.js +30 -0
  157. package/lib/runner/vcs.js +72 -0
  158. package/lib/runner/watchMode.js +396 -0
  159. package/lib/runner/workerHost.js +104 -0
  160. package/lib/third_party/pirates.js +62 -0
  161. package/lib/third_party/tsconfig-loader.js +103 -0
  162. package/lib/transform/babelBundle.js +46 -0
  163. package/lib/transform/babelBundleImpl.js +461 -0
  164. package/lib/transform/compilationCache.js +274 -0
  165. package/lib/transform/esmLoader.js +103 -0
  166. package/lib/transform/md.js +221 -0
  167. package/lib/transform/portTransport.js +67 -0
  168. package/lib/transform/transform.js +303 -0
  169. package/lib/util.js +400 -0
  170. package/lib/utilsBundle.js +50 -0
  171. package/lib/utilsBundleImpl.js +103 -0
  172. package/lib/worker/fixtureRunner.js +262 -0
  173. package/lib/worker/testInfo.js +536 -0
  174. package/lib/worker/testTracing.js +345 -0
  175. package/lib/worker/timeoutManager.js +174 -0
  176. package/lib/worker/util.js +31 -0
  177. package/lib/worker/workerMain.js +530 -0
  178. package/package.json +73 -0
  179. package/test.d.ts +18 -0
  180. package/test.js +24 -0
  181. package/test.mjs +34 -0
  182. package/types/test.d.ts +10287 -0
  183. package/types/testReporter.d.ts +822 -0
@@ -0,0 +1,56 @@
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 command_exports = {};
20
+ __export(command_exports, {
21
+ declareCommand: () => declareCommand,
22
+ parseCommand: () => parseCommand
23
+ });
24
+ module.exports = __toCommonJS(command_exports);
25
+ function declareCommand(command) {
26
+ return command;
27
+ }
28
+ function parseCommand(command, args) {
29
+ const shape = command.args ? command.args.shape : {};
30
+ const argv = args["_"];
31
+ const options = command.options?.parse({ ...args, _: void 0 }) ?? {};
32
+ const argsObject = {};
33
+ let i = 0;
34
+ for (const name of Object.keys(shape))
35
+ argsObject[name] = argv[++i];
36
+ let parsedArgsObject = {};
37
+ try {
38
+ parsedArgsObject = command.args?.parse(argsObject) ?? {};
39
+ } catch (e) {
40
+ throw new Error(formatZodError(e));
41
+ }
42
+ const toolName = typeof command.toolName === "function" ? command.toolName({ ...parsedArgsObject, ...options }) : command.toolName;
43
+ const toolParams = command.toolParams({ ...parsedArgsObject, ...options });
44
+ return { toolName, toolParams };
45
+ }
46
+ function formatZodError(error) {
47
+ const issue = error.issues[0];
48
+ if (issue.code === "invalid_type")
49
+ return `${issue.message} in <${issue.path.join(".")}>`;
50
+ return error.issues.map((i) => i.message).join("\n");
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ declareCommand,
55
+ parseCommand
56
+ });
@@ -0,0 +1,519 @@
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 commands_exports = {};
20
+ __export(commands_exports, {
21
+ commands: () => commands
22
+ });
23
+ module.exports = __toCommonJS(commands_exports);
24
+ var import_mcpBundle = require("playwright-core/lib/mcpBundle");
25
+ var import_command = require("./command");
26
+ const open = (0, import_command.declareCommand)({
27
+ name: "open",
28
+ description: "Open URL",
29
+ category: "core",
30
+ args: import_mcpBundle.z.object({
31
+ url: import_mcpBundle.z.string().describe("The URL to navigate to")
32
+ }),
33
+ options: import_mcpBundle.z.object({
34
+ headed: import_mcpBundle.z.boolean().default(false).describe("Run browser in headed mode")
35
+ }),
36
+ toolName: "browser_open",
37
+ toolParams: ({ url, headed }) => ({ url, headed })
38
+ });
39
+ const close = (0, import_command.declareCommand)({
40
+ name: "close",
41
+ description: "Close the page",
42
+ category: "core",
43
+ args: import_mcpBundle.z.object({}),
44
+ toolName: "browser_close",
45
+ toolParams: () => ({})
46
+ });
47
+ const goBack = (0, import_command.declareCommand)({
48
+ name: "go-back",
49
+ description: "Go back to the previous page",
50
+ category: "navigation",
51
+ args: import_mcpBundle.z.object({}),
52
+ toolName: "browser_navigate_back",
53
+ toolParams: () => ({})
54
+ });
55
+ const goForward = (0, import_command.declareCommand)({
56
+ name: "go-forward",
57
+ description: "Go forward to the next page",
58
+ category: "navigation",
59
+ args: import_mcpBundle.z.object({}),
60
+ toolName: "browser_navigate_forward",
61
+ toolParams: () => ({})
62
+ });
63
+ const reload = (0, import_command.declareCommand)({
64
+ name: "reload",
65
+ description: "Reload the current page",
66
+ category: "navigation",
67
+ args: import_mcpBundle.z.object({}),
68
+ toolName: "browser_reload",
69
+ toolParams: () => ({})
70
+ });
71
+ const pressKey = (0, import_command.declareCommand)({
72
+ name: "press",
73
+ description: "Press a key on the keyboard, `a`, `ArrowLeft`",
74
+ category: "keyboard",
75
+ args: import_mcpBundle.z.object({
76
+ key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
77
+ }),
78
+ toolName: "browser_press_key",
79
+ toolParams: ({ key }) => ({ key })
80
+ });
81
+ const type = (0, import_command.declareCommand)({
82
+ name: "type",
83
+ description: "Type text into editable element",
84
+ category: "core",
85
+ args: import_mcpBundle.z.object({
86
+ text: import_mcpBundle.z.string().describe("Text to type into the element")
87
+ }),
88
+ options: import_mcpBundle.z.object({
89
+ submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)")
90
+ }),
91
+ toolName: "browser_press_sequentially",
92
+ toolParams: ({ text, submit }) => ({ text, submit })
93
+ });
94
+ const keydown = (0, import_command.declareCommand)({
95
+ name: "keydown",
96
+ description: "Press a key down on the keyboard",
97
+ category: "keyboard",
98
+ args: import_mcpBundle.z.object({
99
+ key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
100
+ }),
101
+ toolName: "browser_keydown",
102
+ toolParams: ({ key }) => ({ key })
103
+ });
104
+ const keyup = (0, import_command.declareCommand)({
105
+ name: "keyup",
106
+ description: "Press a key up on the keyboard",
107
+ category: "keyboard",
108
+ args: import_mcpBundle.z.object({
109
+ key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
110
+ }),
111
+ toolName: "browser_keyup",
112
+ toolParams: ({ key }) => ({ key })
113
+ });
114
+ const mouseMove = (0, import_command.declareCommand)({
115
+ name: "mousemove",
116
+ description: "Move mouse to a given position",
117
+ category: "mouse",
118
+ args: import_mcpBundle.z.object({
119
+ x: import_mcpBundle.z.number().describe("X coordinate"),
120
+ y: import_mcpBundle.z.number().describe("Y coordinate")
121
+ }),
122
+ toolName: "browser_mouse_move_xy",
123
+ toolParams: ({ x, y }) => ({ x, y })
124
+ });
125
+ const mouseDown = (0, import_command.declareCommand)({
126
+ name: "mousedown",
127
+ description: "Press mouse down",
128
+ category: "mouse",
129
+ args: import_mcpBundle.z.object({
130
+ button: import_mcpBundle.z.string().optional().describe("Button to press, defaults to left")
131
+ }),
132
+ toolName: "browser_mouse_down",
133
+ toolParams: ({ button }) => ({ button })
134
+ });
135
+ const mouseUp = (0, import_command.declareCommand)({
136
+ name: "mouseup",
137
+ description: "Press mouse up",
138
+ category: "mouse",
139
+ args: import_mcpBundle.z.object({
140
+ button: import_mcpBundle.z.string().optional().describe("Button to press, defaults to left")
141
+ }),
142
+ toolName: "browser_mouse_up",
143
+ toolParams: ({ button }) => ({ button })
144
+ });
145
+ const mouseWheel = (0, import_command.declareCommand)({
146
+ name: "mousewheel",
147
+ description: "Scroll mouse wheel",
148
+ category: "mouse",
149
+ args: import_mcpBundle.z.object({
150
+ dx: import_mcpBundle.z.number().describe("Y delta"),
151
+ dy: import_mcpBundle.z.number().describe("X delta")
152
+ }),
153
+ toolName: "browser_mouse_wheel",
154
+ toolParams: ({ dx: deltaY, dy: deltaX }) => ({ deltaY, deltaX })
155
+ });
156
+ const click = (0, import_command.declareCommand)({
157
+ name: "click",
158
+ description: "Perform click on a web page",
159
+ category: "core",
160
+ args: import_mcpBundle.z.object({
161
+ ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot"),
162
+ button: import_mcpBundle.z.string().optional().describe("Button to click, defaults to left")
163
+ }),
164
+ options: import_mcpBundle.z.object({
165
+ modifiers: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe("Modifier keys to press")
166
+ }),
167
+ toolName: "browser_click",
168
+ toolParams: ({ ref, button, modifiers }) => ({ ref, button, modifiers })
169
+ });
170
+ const doubleClick = (0, import_command.declareCommand)({
171
+ name: "dblclick",
172
+ description: "Perform double click on a web page",
173
+ category: "core",
174
+ args: import_mcpBundle.z.object({
175
+ ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot"),
176
+ button: import_mcpBundle.z.string().optional().describe("Button to click, defaults to left")
177
+ }),
178
+ options: import_mcpBundle.z.object({
179
+ modifiers: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe("Modifier keys to press")
180
+ }),
181
+ toolName: "browser_click",
182
+ toolParams: ({ ref, button, modifiers }) => ({ ref, button, modifiers, doubleClick: true })
183
+ });
184
+ const drag = (0, import_command.declareCommand)({
185
+ name: "drag",
186
+ description: "Perform drag and drop between two elements",
187
+ category: "core",
188
+ args: import_mcpBundle.z.object({
189
+ startRef: import_mcpBundle.z.string().describe("Exact source element reference from the page snapshot"),
190
+ endRef: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
191
+ }),
192
+ options: import_mcpBundle.z.object({
193
+ headed: import_mcpBundle.z.boolean().default(false).describe("Run browser in headed mode")
194
+ }),
195
+ toolName: "browser_drag",
196
+ toolParams: ({ startRef, endRef }) => ({ startRef, endRef })
197
+ });
198
+ const fill = (0, import_command.declareCommand)({
199
+ name: "fill",
200
+ description: "Fill text into editable element",
201
+ category: "core",
202
+ args: import_mcpBundle.z.object({
203
+ ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot"),
204
+ text: import_mcpBundle.z.string().describe("Text to fill into the element")
205
+ }),
206
+ options: import_mcpBundle.z.object({
207
+ submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)")
208
+ }),
209
+ toolName: "browser_type",
210
+ toolParams: ({ ref, text, submit }) => ({ ref, text, submit })
211
+ });
212
+ const hover = (0, import_command.declareCommand)({
213
+ name: "hover",
214
+ description: "Hover over element on page",
215
+ category: "core",
216
+ args: import_mcpBundle.z.object({
217
+ ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
218
+ }),
219
+ toolName: "browser_hover",
220
+ toolParams: ({ ref }) => ({ ref })
221
+ });
222
+ const select = (0, import_command.declareCommand)({
223
+ name: "select",
224
+ description: "Select an option in a dropdown",
225
+ category: "core",
226
+ args: import_mcpBundle.z.object({
227
+ ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot"),
228
+ val: import_mcpBundle.z.string().describe("Value to select in the dropdown")
229
+ }),
230
+ toolName: "browser_select_option",
231
+ toolParams: ({ ref, val: value }) => ({ ref, values: [value] })
232
+ });
233
+ const fileUpload = (0, import_command.declareCommand)({
234
+ name: "upload",
235
+ description: "Upload one or multiple files",
236
+ category: "core",
237
+ args: import_mcpBundle.z.object({
238
+ file: import_mcpBundle.z.string().describe("The absolute paths to the files to upload")
239
+ }),
240
+ toolName: "browser_file_upload",
241
+ toolParams: ({ file }) => ({ paths: [file] })
242
+ });
243
+ const check = (0, import_command.declareCommand)({
244
+ name: "check",
245
+ description: "Check a checkbox or radio button",
246
+ category: "core",
247
+ args: import_mcpBundle.z.object({
248
+ ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
249
+ }),
250
+ toolName: "browser_check",
251
+ toolParams: ({ ref }) => ({ ref })
252
+ });
253
+ const uncheck = (0, import_command.declareCommand)({
254
+ name: "uncheck",
255
+ description: "Uncheck a checkbox or radio button",
256
+ category: "core",
257
+ args: import_mcpBundle.z.object({
258
+ ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
259
+ }),
260
+ toolName: "browser_uncheck",
261
+ toolParams: ({ ref }) => ({ ref })
262
+ });
263
+ const snapshot = (0, import_command.declareCommand)({
264
+ name: "snapshot",
265
+ description: "Capture page snapshot to obtain element ref",
266
+ category: "core",
267
+ args: import_mcpBundle.z.object({}),
268
+ options: import_mcpBundle.z.object({
269
+ filename: import_mcpBundle.z.string().optional().describe("Save snapshot to markdown file instead of returning it in the response.")
270
+ }),
271
+ toolName: "browser_snapshot",
272
+ toolParams: ({ filename }) => ({ filename })
273
+ });
274
+ const evaluate = (0, import_command.declareCommand)({
275
+ name: "eval",
276
+ description: "Evaluate JavaScript expression on page or element",
277
+ category: "core",
278
+ args: import_mcpBundle.z.object({
279
+ func: import_mcpBundle.z.string().describe("() => { /* code */ } or (element) => { /* code */ } when element is provided"),
280
+ ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot")
281
+ }),
282
+ toolName: "browser_evaluate",
283
+ toolParams: ({ func, ref }) => ({ function: func, ref })
284
+ });
285
+ const dialogAccept = (0, import_command.declareCommand)({
286
+ name: "dialog-accept",
287
+ description: "Accept a dialog",
288
+ category: "core",
289
+ args: import_mcpBundle.z.object({
290
+ prompt: import_mcpBundle.z.string().optional().describe("The text of the prompt in case of a prompt dialog.")
291
+ }),
292
+ toolName: "browser_handle_dialog",
293
+ toolParams: ({ prompt: promptText }) => ({ accept: true, promptText })
294
+ });
295
+ const dialogDismiss = (0, import_command.declareCommand)({
296
+ name: "dialog-dismiss",
297
+ description: "Dismiss a dialog",
298
+ category: "core",
299
+ args: import_mcpBundle.z.object({}),
300
+ toolName: "browser_handle_dialog",
301
+ toolParams: () => ({ accept: false })
302
+ });
303
+ const resize = (0, import_command.declareCommand)({
304
+ name: "resize",
305
+ description: "Resize the browser window",
306
+ category: "core",
307
+ args: import_mcpBundle.z.object({
308
+ w: import_mcpBundle.z.number().describe("Width of the browser window"),
309
+ h: import_mcpBundle.z.number().describe("Height of the browser window")
310
+ }),
311
+ toolName: "browser_resize",
312
+ toolParams: ({ w: width, h: height }) => ({ width, height })
313
+ });
314
+ const tabList = (0, import_command.declareCommand)({
315
+ name: "tab-list",
316
+ description: "List all tabs",
317
+ category: "tabs",
318
+ args: import_mcpBundle.z.object({}),
319
+ toolName: "browser_tabs",
320
+ toolParams: () => ({ action: "list" })
321
+ });
322
+ const tabNew = (0, import_command.declareCommand)({
323
+ name: "tab-new",
324
+ description: "Create a new tab",
325
+ category: "tabs",
326
+ args: import_mcpBundle.z.object({
327
+ url: import_mcpBundle.z.string().optional().describe("The URL to navigate to in the new tab. If omitted, the new tab will be blank.")
328
+ }),
329
+ toolName: "browser_tabs",
330
+ toolParams: ({ url }) => ({ action: "new", url })
331
+ });
332
+ const tabClose = (0, import_command.declareCommand)({
333
+ name: "tab-close",
334
+ description: "Close a browser tab",
335
+ category: "tabs",
336
+ args: import_mcpBundle.z.object({
337
+ index: import_mcpBundle.z.number().optional().describe("Tab index. If omitted, current tab is closed.")
338
+ }),
339
+ toolName: "browser_tabs",
340
+ toolParams: ({ index }) => ({ action: "close", index })
341
+ });
342
+ const tabSelect = (0, import_command.declareCommand)({
343
+ name: "tab-select",
344
+ description: "Select a browser tab",
345
+ category: "tabs",
346
+ args: import_mcpBundle.z.object({
347
+ index: import_mcpBundle.z.number().describe("Tab index")
348
+ }),
349
+ toolName: "browser_tabs",
350
+ toolParams: ({ index }) => ({ action: "select", index })
351
+ });
352
+ const screenshot = (0, import_command.declareCommand)({
353
+ name: "screenshot",
354
+ description: "screenshot of the current page or element",
355
+ category: "export",
356
+ args: import_mcpBundle.z.object({
357
+ ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot.")
358
+ }),
359
+ options: import_mcpBundle.z.object({
360
+ filename: import_mcpBundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified."),
361
+ ["full-page"]: import_mcpBundle.z.boolean().optional().describe("When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.")
362
+ }),
363
+ toolName: "browser_take_screenshot",
364
+ toolParams: ({ ref, filename, ["full-page"]: fullPage }) => ({ filename, ref, fullPage })
365
+ });
366
+ const pdfSave = (0, import_command.declareCommand)({
367
+ name: "pdf",
368
+ description: "Save page as PDF",
369
+ category: "export",
370
+ args: import_mcpBundle.z.object({}),
371
+ options: import_mcpBundle.z.object({
372
+ filename: import_mcpBundle.z.string().optional().describe("File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.")
373
+ }),
374
+ toolName: "browser_pdf_save",
375
+ toolParams: ({ filename }) => ({ filename })
376
+ });
377
+ const consoleList = (0, import_command.declareCommand)({
378
+ name: "console",
379
+ description: "List console messages",
380
+ category: "devtools",
381
+ args: import_mcpBundle.z.object({
382
+ ["min-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".')
383
+ }),
384
+ options: import_mcpBundle.z.object({
385
+ clear: import_mcpBundle.z.boolean().optional().describe("Whether to clear the console list")
386
+ }),
387
+ toolName: ({ clear }) => clear ? "browser_console_clear" : "browser_console_messages",
388
+ toolParams: ({ ["min-level"]: level, clear }) => clear ? {} : { level }
389
+ });
390
+ const networkRequests = (0, import_command.declareCommand)({
391
+ name: "network",
392
+ description: "List all network requests since loading the page",
393
+ category: "devtools",
394
+ args: import_mcpBundle.z.object({}),
395
+ options: import_mcpBundle.z.object({
396
+ static: import_mcpBundle.z.boolean().optional().describe("Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false."),
397
+ clear: import_mcpBundle.z.boolean().optional().describe("Whether to clear the network list")
398
+ }),
399
+ toolName: ({ clear }) => clear ? "browser_network_clear" : "browser_network_requests",
400
+ toolParams: ({ static: includeStatic, clear }) => clear ? {} : { includeStatic }
401
+ });
402
+ const runCode = (0, import_command.declareCommand)({
403
+ name: "run-code",
404
+ description: "Run Playwright code snippet",
405
+ category: "devtools",
406
+ args: import_mcpBundle.z.object({
407
+ 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.")
408
+ }),
409
+ toolName: "browser_run_code",
410
+ toolParams: ({ code }) => ({ code })
411
+ });
412
+ const tracingStart = (0, import_command.declareCommand)({
413
+ name: "tracing-start",
414
+ description: "Start trace recording",
415
+ category: "devtools",
416
+ args: import_mcpBundle.z.object({}),
417
+ toolName: "browser_start_tracing",
418
+ toolParams: () => ({})
419
+ });
420
+ const tracingStop = (0, import_command.declareCommand)({
421
+ name: "tracing-stop",
422
+ description: "Stop trace recording",
423
+ category: "devtools",
424
+ args: import_mcpBundle.z.object({}),
425
+ toolName: "browser_stop_tracing",
426
+ toolParams: () => ({})
427
+ });
428
+ const sessionList = (0, import_command.declareCommand)({
429
+ name: "session-list",
430
+ description: "List all sessions",
431
+ category: "session",
432
+ args: import_mcpBundle.z.object({}),
433
+ toolName: "",
434
+ toolParams: () => ({})
435
+ });
436
+ const sessionStop = (0, import_command.declareCommand)({
437
+ name: "session-stop",
438
+ description: "Stop session",
439
+ category: "session",
440
+ args: import_mcpBundle.z.object({
441
+ name: import_mcpBundle.z.string().optional().describe("Name of the session to stop. If omitted, current session is stopped.")
442
+ }),
443
+ toolName: "",
444
+ toolParams: () => ({})
445
+ });
446
+ const sessionStopAll = (0, import_command.declareCommand)({
447
+ name: "session-stop-all",
448
+ description: "Stop all sessions",
449
+ category: "session",
450
+ toolName: "",
451
+ toolParams: () => ({})
452
+ });
453
+ const sessionDelete = (0, import_command.declareCommand)({
454
+ name: "session-delete",
455
+ description: "Delete session data",
456
+ category: "session",
457
+ args: import_mcpBundle.z.object({
458
+ name: import_mcpBundle.z.string().optional().describe("Name of the session to delete. If omitted, current session is deleted.")
459
+ }),
460
+ toolName: "",
461
+ toolParams: ({ name }) => ({ name })
462
+ });
463
+ const commandsArray = [
464
+ // core category
465
+ open,
466
+ close,
467
+ type,
468
+ click,
469
+ doubleClick,
470
+ fill,
471
+ drag,
472
+ hover,
473
+ select,
474
+ fileUpload,
475
+ check,
476
+ uncheck,
477
+ snapshot,
478
+ evaluate,
479
+ consoleList,
480
+ dialogAccept,
481
+ dialogDismiss,
482
+ resize,
483
+ // navigation category
484
+ goBack,
485
+ goForward,
486
+ reload,
487
+ // keyboard category
488
+ pressKey,
489
+ keydown,
490
+ keyup,
491
+ // mouse category
492
+ mouseMove,
493
+ mouseDown,
494
+ mouseUp,
495
+ mouseWheel,
496
+ // export category
497
+ screenshot,
498
+ pdfSave,
499
+ // tabs category
500
+ tabList,
501
+ tabNew,
502
+ tabClose,
503
+ tabSelect,
504
+ // devtools category
505
+ networkRequests,
506
+ runCode,
507
+ tracingStart,
508
+ tracingStop,
509
+ // session category
510
+ sessionList,
511
+ sessionStop,
512
+ sessionStopAll,
513
+ sessionDelete
514
+ ];
515
+ const commands = Object.fromEntries(commandsArray.map((cmd) => [cmd.name, cmd]));
516
+ // Annotate the CommonJS export names for ESM import in node:
517
+ 0 && (module.exports = {
518
+ commands
519
+ });