Update npm packages (73 packages including @jqhtml 2.3.36)
Update npm registry domain from privatenpm.hanson.xyz to npm.internal.hanson.xyz 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
14
node_modules/playwright/lib/mcp/browser/tools/common.js
generated
vendored
14
node_modules/playwright/lib/mcp/browser/tools/common.js
generated
vendored
@@ -21,20 +21,22 @@ __export(common_exports, {
|
||||
default: () => common_default
|
||||
});
|
||||
module.exports = __toCommonJS(common_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
var import_response = require("../response");
|
||||
const close = (0, import_tool.defineTool)({
|
||||
capability: "core",
|
||||
schema: {
|
||||
name: "browser_close",
|
||||
title: "Close browser",
|
||||
description: "Close the page",
|
||||
inputSchema: import_bundle.z.object({}),
|
||||
inputSchema: import_mcpBundle.z.object({}),
|
||||
type: "action"
|
||||
},
|
||||
handle: async (context, params, response) => {
|
||||
await context.closeBrowserContext();
|
||||
response.setIncludeTabs();
|
||||
const result = (0, import_response.renderTabsMarkdown)([]);
|
||||
response.addTextResult(result.join("\n"));
|
||||
response.addCode(`await page.close()`);
|
||||
}
|
||||
});
|
||||
@@ -44,9 +46,9 @@ const resize = (0, import_tool.defineTabTool)({
|
||||
name: "browser_resize",
|
||||
title: "Resize browser window",
|
||||
description: "Resize the browser window",
|
||||
inputSchema: import_bundle.z.object({
|
||||
width: import_bundle.z.number().describe("Width of the browser window"),
|
||||
height: import_bundle.z.number().describe("Height of the browser window")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
width: import_mcpBundle.z.number().describe("Width of the browser window"),
|
||||
height: import_mcpBundle.z.number().describe("Height of the browser window")
|
||||
}),
|
||||
type: "action"
|
||||
},
|
||||
|
||||
12
node_modules/playwright/lib/mcp/browser/tools/console.js
generated
vendored
12
node_modules/playwright/lib/mcp/browser/tools/console.js
generated
vendored
@@ -21,7 +21,7 @@ __export(console_exports, {
|
||||
default: () => console_default
|
||||
});
|
||||
module.exports = __toCommonJS(console_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
const console = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
@@ -29,14 +29,16 @@ const console = (0, import_tool.defineTabTool)({
|
||||
name: "browser_console_messages",
|
||||
title: "Get console messages",
|
||||
description: "Returns all console messages",
|
||||
inputSchema: import_bundle.z.object({
|
||||
onlyErrors: import_bundle.z.boolean().optional().describe("Only return error messages")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
level: import_mcpBundle.z.enum(["error", "warning", "info", "debug"]).default("info").describe('Level of the console messages to return. Each level includes the messages of more severe levels. Defaults to "info".'),
|
||||
filename: import_mcpBundle.z.string().optional().describe("Filename to save the console messages to. If not provided, messages are returned as text.")
|
||||
}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (tab, params, response) => {
|
||||
const messages = await tab.consoleMessages(params.onlyErrors ? "error" : void 0);
|
||||
messages.map((message) => response.addResult(message.toString()));
|
||||
const messages = await tab.consoleMessages(params.level);
|
||||
const text = messages.map((message) => message.toString()).join("\n");
|
||||
await response.addResult({ text, suggestedFilename: params.filename });
|
||||
}
|
||||
});
|
||||
var console_default = [
|
||||
|
||||
8
node_modules/playwright/lib/mcp/browser/tools/dialogs.js
generated
vendored
8
node_modules/playwright/lib/mcp/browser/tools/dialogs.js
generated
vendored
@@ -22,7 +22,7 @@ __export(dialogs_exports, {
|
||||
handleDialog: () => handleDialog
|
||||
});
|
||||
module.exports = __toCommonJS(dialogs_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
const handleDialog = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
@@ -30,9 +30,9 @@ const handleDialog = (0, import_tool.defineTabTool)({
|
||||
name: "browser_handle_dialog",
|
||||
title: "Handle a dialog",
|
||||
description: "Handle a dialog",
|
||||
inputSchema: import_bundle.z.object({
|
||||
accept: import_bundle.z.boolean().describe("Whether to accept the dialog."),
|
||||
promptText: import_bundle.z.string().optional().describe("The text of the prompt in case of a prompt dialog.")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
accept: import_mcpBundle.z.boolean().describe("Whether to accept the dialog."),
|
||||
promptText: import_mcpBundle.z.string().optional().describe("The text of the prompt in case of a prompt dialog.")
|
||||
}),
|
||||
type: "action"
|
||||
},
|
||||
|
||||
30
node_modules/playwright/lib/mcp/browser/tools/evaluate.js
generated
vendored
30
node_modules/playwright/lib/mcp/browser/tools/evaluate.js
generated
vendored
@@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
@@ -17,27 +15,20 @@ var __copyProps = (to, from, except, desc) => {
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var evaluate_exports = {};
|
||||
__export(evaluate_exports, {
|
||||
default: () => evaluate_default
|
||||
});
|
||||
module.exports = __toCommonJS(evaluate_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var import_tool = require("./tool");
|
||||
var javascript = __toESM(require("../codegen"));
|
||||
const evaluateSchema = import_bundle.z.object({
|
||||
function: import_bundle.z.string().describe("() => { /* code */ } or (element) => { /* code */ } when element is provided"),
|
||||
element: import_bundle.z.string().optional().describe("Human-readable element description used to obtain permission to interact with the element"),
|
||||
ref: import_bundle.z.string().optional().describe("Exact target element reference from the page snapshot")
|
||||
const evaluateSchema = import_mcpBundle.z.object({
|
||||
function: import_mcpBundle.z.string().describe("() => { /* code */ } or (element) => { /* code */ } when element is provided"),
|
||||
element: import_mcpBundle.z.string().optional().describe("Human-readable element description used to obtain permission to interact with the element"),
|
||||
ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot"),
|
||||
filename: import_mcpBundle.z.string().optional().describe("Filename to save the result to. If not provided, result is returned as JSON string.")
|
||||
});
|
||||
const evaluate = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
@@ -53,14 +44,15 @@ const evaluate = (0, import_tool.defineTabTool)({
|
||||
let locator;
|
||||
if (params.ref && params.element) {
|
||||
locator = await tab.refLocator({ ref: params.ref, element: params.element });
|
||||
response.addCode(`await page.${locator.resolved}.evaluate(${javascript.quote(params.function)});`);
|
||||
response.addCode(`await page.${locator.resolved}.evaluate(${(0, import_utils.escapeWithQuotes)(params.function)});`);
|
||||
} else {
|
||||
response.addCode(`await page.evaluate(${javascript.quote(params.function)});`);
|
||||
response.addCode(`await page.evaluate(${(0, import_utils.escapeWithQuotes)(params.function)});`);
|
||||
}
|
||||
await tab.waitForCompletion(async () => {
|
||||
const receiver = locator?.locator ?? tab.page;
|
||||
const result = await receiver._evaluateFunction(params.function);
|
||||
response.addResult(JSON.stringify(result, null, 2) || "undefined");
|
||||
const text = JSON.stringify(result, null, 2) || "undefined";
|
||||
await response.addResult({ text, suggestedFilename: params.filename });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
6
node_modules/playwright/lib/mcp/browser/tools/files.js
generated
vendored
6
node_modules/playwright/lib/mcp/browser/tools/files.js
generated
vendored
@@ -22,7 +22,7 @@ __export(files_exports, {
|
||||
uploadFile: () => uploadFile
|
||||
});
|
||||
module.exports = __toCommonJS(files_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
const uploadFile = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
@@ -30,8 +30,8 @@ const uploadFile = (0, import_tool.defineTabTool)({
|
||||
name: "browser_file_upload",
|
||||
title: "Upload files",
|
||||
description: "Upload one or multiple files",
|
||||
inputSchema: import_bundle.z.object({
|
||||
paths: import_bundle.z.array(import_bundle.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.")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
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.")
|
||||
}),
|
||||
type: "action"
|
||||
},
|
||||
|
||||
28
node_modules/playwright/lib/mcp/browser/tools/form.js
generated
vendored
28
node_modules/playwright/lib/mcp/browser/tools/form.js
generated
vendored
@@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
@@ -17,35 +15,27 @@ var __copyProps = (to, from, except, desc) => {
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var form_exports = {};
|
||||
__export(form_exports, {
|
||||
default: () => form_default
|
||||
});
|
||||
module.exports = __toCommonJS(form_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var import_tool = require("./tool");
|
||||
var codegen = __toESM(require("../codegen"));
|
||||
const fillForm = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
schema: {
|
||||
name: "browser_fill_form",
|
||||
title: "Fill form",
|
||||
description: "Fill multiple form fields",
|
||||
inputSchema: import_bundle.z.object({
|
||||
fields: import_bundle.z.array(import_bundle.z.object({
|
||||
name: import_bundle.z.string().describe("Human-readable field name"),
|
||||
type: import_bundle.z.enum(["textbox", "checkbox", "radio", "combobox", "slider"]).describe("Type of the field"),
|
||||
ref: import_bundle.z.string().describe("Exact target field reference from the page snapshot"),
|
||||
value: import_bundle.z.string().describe("Value to fill in the field. If the field is a checkbox, the value should be `true` or `false`. If the field is a combobox, the value should be the text of the option.")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
fields: import_mcpBundle.z.array(import_mcpBundle.z.object({
|
||||
name: import_mcpBundle.z.string().describe("Human-readable field name"),
|
||||
type: import_mcpBundle.z.enum(["textbox", "checkbox", "radio", "combobox", "slider"]).describe("Type of the field"),
|
||||
ref: import_mcpBundle.z.string().describe("Exact target field reference from the page snapshot"),
|
||||
value: import_mcpBundle.z.string().describe("Value to fill in the field. If the field is a checkbox, the value should be `true` or `false`. If the field is a combobox, the value should be the text of the option.")
|
||||
})).describe("Fields to fill in")
|
||||
}),
|
||||
type: "input"
|
||||
@@ -63,7 +53,7 @@ const fillForm = (0, import_tool.defineTabTool)({
|
||||
response.addCode(`${locatorSource}.setChecked(${field.value});`);
|
||||
} else if (field.type === "combobox") {
|
||||
await locator.selectOption({ label: field.value });
|
||||
response.addCode(`${locatorSource}.selectOption(${codegen.quote(field.value)});`);
|
||||
response.addCode(`${locatorSource}.selectOption(${(0, import_utils.escapeWithQuotes)(field.value)});`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
9
node_modules/playwright/lib/mcp/browser/tools/install.js
generated
vendored
9
node_modules/playwright/lib/mcp/browser/tools/install.js
generated
vendored
@@ -33,15 +33,16 @@ __export(install_exports, {
|
||||
module.exports = __toCommonJS(install_exports);
|
||||
var import_child_process = require("child_process");
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
var import_response = require("../response");
|
||||
const install = (0, import_tool.defineTool)({
|
||||
capability: "core-install",
|
||||
schema: {
|
||||
name: "browser_install",
|
||||
title: "Install the browser specified in the config",
|
||||
description: "Install the browser specified in the config. Call this if you get an error about the browser not being installed.",
|
||||
inputSchema: import_bundle.z.object({}),
|
||||
inputSchema: import_mcpBundle.z.object({}),
|
||||
type: "action"
|
||||
},
|
||||
handle: async (context, params, response) => {
|
||||
@@ -61,7 +62,9 @@ const install = (0, import_tool.defineTool)({
|
||||
reject(new Error(`Failed to install browser: ${output.join("")}`));
|
||||
});
|
||||
});
|
||||
response.setIncludeTabs();
|
||||
const tabHeaders = await Promise.all(context.tabs().map((tab) => tab.headerSnapshot()));
|
||||
const result = (0, import_response.renderTabsMarkdown)(tabHeaders);
|
||||
response.addTextResult(result.join("\n"));
|
||||
}
|
||||
});
|
||||
var install_default = [
|
||||
|
||||
45
node_modules/playwright/lib/mcp/browser/tools/keyboard.js
generated
vendored
45
node_modules/playwright/lib/mcp/browser/tools/keyboard.js
generated
vendored
@@ -21,7 +21,7 @@ __export(keyboard_exports, {
|
||||
default: () => keyboard_default
|
||||
});
|
||||
module.exports = __toCommonJS(keyboard_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
var import_snapshot = require("./snapshot");
|
||||
const pressKey = (0, import_tool.defineTabTool)({
|
||||
@@ -30,24 +30,46 @@ const pressKey = (0, import_tool.defineTabTool)({
|
||||
name: "browser_press_key",
|
||||
title: "Press a key",
|
||||
description: "Press a key on the keyboard",
|
||||
inputSchema: import_bundle.z.object({
|
||||
key: import_bundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
|
||||
}),
|
||||
type: "input"
|
||||
},
|
||||
handle: async (tab, params, response) => {
|
||||
response.setIncludeSnapshot();
|
||||
response.addCode(`// Press ${params.key}`);
|
||||
response.addCode(`await page.keyboard.press('${params.key}');`);
|
||||
await tab.waitForCompletion(async () => {
|
||||
await tab.page.keyboard.press(params.key);
|
||||
});
|
||||
await tab.page.keyboard.press(params.key);
|
||||
}
|
||||
});
|
||||
const pressSequentially = (0, import_tool.defineTabTool)({
|
||||
capability: "internal",
|
||||
schema: {
|
||||
name: "browser_press_sequentially",
|
||||
title: "Press sequentially",
|
||||
description: "Press text sequentially on the keyboard",
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
text: import_mcpBundle.z.string().describe("Text to press sequentially"),
|
||||
submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)")
|
||||
}),
|
||||
type: "input"
|
||||
},
|
||||
handle: async (tab, params, response) => {
|
||||
response.addCode(`// Press ${params.text}`);
|
||||
response.addCode(`await page.keyboard.type('${params.text}');`);
|
||||
await tab.page.keyboard.type(params.text);
|
||||
if (params.submit) {
|
||||
response.addCode(`await page.keyboard.press('Enter');`);
|
||||
response.setIncludeSnapshot();
|
||||
await tab.waitForCompletion(async () => {
|
||||
await tab.page.keyboard.press("Enter");
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
const typeSchema = import_snapshot.elementSchema.extend({
|
||||
text: import_bundle.z.string().describe("Text to type into the element"),
|
||||
submit: import_bundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)"),
|
||||
slowly: import_bundle.z.boolean().optional().describe("Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.")
|
||||
text: import_mcpBundle.z.string().describe("Text to type into the element"),
|
||||
submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)"),
|
||||
slowly: import_mcpBundle.z.boolean().optional().describe("Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.")
|
||||
});
|
||||
const type = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
@@ -80,5 +102,6 @@ const type = (0, import_tool.defineTabTool)({
|
||||
});
|
||||
var keyboard_default = [
|
||||
pressKey,
|
||||
type
|
||||
type,
|
||||
pressSequentially
|
||||
];
|
||||
|
||||
22
node_modules/playwright/lib/mcp/browser/tools/mouse.js
generated
vendored
22
node_modules/playwright/lib/mcp/browser/tools/mouse.js
generated
vendored
@@ -21,10 +21,10 @@ __export(mouse_exports, {
|
||||
default: () => mouse_default
|
||||
});
|
||||
module.exports = __toCommonJS(mouse_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
const elementSchema = import_bundle.z.object({
|
||||
element: import_bundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element")
|
||||
const elementSchema = import_mcpBundle.z.object({
|
||||
element: import_mcpBundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element")
|
||||
});
|
||||
const mouseMove = (0, import_tool.defineTabTool)({
|
||||
capability: "vision",
|
||||
@@ -33,8 +33,8 @@ const mouseMove = (0, import_tool.defineTabTool)({
|
||||
title: "Move mouse",
|
||||
description: "Move mouse to a given position",
|
||||
inputSchema: elementSchema.extend({
|
||||
x: import_bundle.z.number().describe("X coordinate"),
|
||||
y: import_bundle.z.number().describe("Y coordinate")
|
||||
x: import_mcpBundle.z.number().describe("X coordinate"),
|
||||
y: import_mcpBundle.z.number().describe("Y coordinate")
|
||||
}),
|
||||
type: "input"
|
||||
},
|
||||
@@ -53,8 +53,8 @@ const mouseClick = (0, import_tool.defineTabTool)({
|
||||
title: "Click",
|
||||
description: "Click left mouse button at a given position",
|
||||
inputSchema: elementSchema.extend({
|
||||
x: import_bundle.z.number().describe("X coordinate"),
|
||||
y: import_bundle.z.number().describe("Y coordinate")
|
||||
x: import_mcpBundle.z.number().describe("X coordinate"),
|
||||
y: import_mcpBundle.z.number().describe("Y coordinate")
|
||||
}),
|
||||
type: "input"
|
||||
},
|
||||
@@ -78,10 +78,10 @@ const mouseDrag = (0, import_tool.defineTabTool)({
|
||||
title: "Drag mouse",
|
||||
description: "Drag left mouse button to a given position",
|
||||
inputSchema: elementSchema.extend({
|
||||
startX: import_bundle.z.number().describe("Start X coordinate"),
|
||||
startY: import_bundle.z.number().describe("Start Y coordinate"),
|
||||
endX: import_bundle.z.number().describe("End X coordinate"),
|
||||
endY: import_bundle.z.number().describe("End Y coordinate")
|
||||
startX: import_mcpBundle.z.number().describe("Start X coordinate"),
|
||||
startY: import_mcpBundle.z.number().describe("Start Y coordinate"),
|
||||
endX: import_mcpBundle.z.number().describe("End X coordinate"),
|
||||
endY: import_mcpBundle.z.number().describe("End Y coordinate")
|
||||
}),
|
||||
type: "input"
|
||||
},
|
||||
|
||||
19
node_modules/playwright/lib/mcp/browser/tools/navigate.js
generated
vendored
19
node_modules/playwright/lib/mcp/browser/tools/navigate.js
generated
vendored
@@ -21,7 +21,7 @@ __export(navigate_exports, {
|
||||
default: () => navigate_default
|
||||
});
|
||||
module.exports = __toCommonJS(navigate_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
const navigate = (0, import_tool.defineTool)({
|
||||
capability: "core",
|
||||
@@ -29,14 +29,23 @@ const navigate = (0, import_tool.defineTool)({
|
||||
name: "browser_navigate",
|
||||
title: "Navigate to a URL",
|
||||
description: "Navigate to a URL",
|
||||
inputSchema: import_bundle.z.object({
|
||||
url: import_bundle.z.string().describe("The URL to navigate to")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
url: import_mcpBundle.z.string().describe("The URL to navigate to")
|
||||
}),
|
||||
type: "action"
|
||||
},
|
||||
handle: async (context, params, response) => {
|
||||
const tab = await context.ensureTab();
|
||||
await tab.navigate(params.url);
|
||||
let url = params.url;
|
||||
try {
|
||||
new URL(url);
|
||||
} catch (e) {
|
||||
if (url.startsWith("localhost"))
|
||||
url = "http://" + url;
|
||||
else
|
||||
url = "https://" + url;
|
||||
}
|
||||
await tab.navigate(url);
|
||||
response.setIncludeSnapshot();
|
||||
response.addCode(`await page.goto('${params.url}');`);
|
||||
}
|
||||
@@ -47,7 +56,7 @@ const goBack = (0, import_tool.defineTabTool)({
|
||||
name: "browser_navigate_back",
|
||||
title: "Go back",
|
||||
description: "Go back to the previous page",
|
||||
inputSchema: import_bundle.z.object({}),
|
||||
inputSchema: import_mcpBundle.z.object({}),
|
||||
type: "action"
|
||||
},
|
||||
handle: async (tab, params, response) => {
|
||||
|
||||
31
node_modules/playwright/lib/mcp/browser/tools/network.js
generated
vendored
31
node_modules/playwright/lib/mcp/browser/tools/network.js
generated
vendored
@@ -21,7 +21,7 @@ __export(network_exports, {
|
||||
default: () => network_default
|
||||
});
|
||||
module.exports = __toCommonJS(network_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
const requests = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
@@ -29,24 +29,33 @@ const requests = (0, import_tool.defineTabTool)({
|
||||
name: "browser_network_requests",
|
||||
title: "List network requests",
|
||||
description: "Returns all network requests since loading the page",
|
||||
inputSchema: import_bundle.z.object({}),
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
includeStatic: import_mcpBundle.z.boolean().default(false).describe("Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false."),
|
||||
filename: import_mcpBundle.z.string().optional().describe("Filename to save the network requests to. If not provided, requests are returned as text.")
|
||||
}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (tab, params, response) => {
|
||||
const requests2 = await tab.requests();
|
||||
for (const request of requests2)
|
||||
response.addResult(await renderRequest(request));
|
||||
const text = [];
|
||||
for (const request of requests2) {
|
||||
const rendered = await renderRequest(request, params.includeStatic);
|
||||
if (rendered)
|
||||
text.push(rendered);
|
||||
}
|
||||
await response.addResult({ text: text.join("\n"), suggestedFilename: params.filename });
|
||||
}
|
||||
});
|
||||
async function renderRequest(request) {
|
||||
async function renderRequest(request, includeStatic) {
|
||||
const response = request._hasResponse ? await request.response() : void 0;
|
||||
const isStaticRequest = ["document", "stylesheet", "image", "media", "font", "script", "manifest"].includes(request.resourceType());
|
||||
const isSuccessfulRequest = !response || response.status() < 400;
|
||||
if (isStaticRequest && isSuccessfulRequest && !includeStatic)
|
||||
return void 0;
|
||||
const result = [];
|
||||
result.push(`[${request.method().toUpperCase()}] ${request.url()}`);
|
||||
const hasResponse = request._hasResponse;
|
||||
if (hasResponse) {
|
||||
const response = await request.response();
|
||||
if (response)
|
||||
result.push(`=> [${response.status()}] ${response.statusText()}`);
|
||||
}
|
||||
if (response)
|
||||
result.push(`=> [${response.status()}] ${response.statusText()}`);
|
||||
return result.join(" ");
|
||||
}
|
||||
var network_default = [
|
||||
|
||||
57
node_modules/playwright/lib/mcp/browser/tools/open.js
generated
vendored
Normal file
57
node_modules/playwright/lib/mcp/browser/tools/open.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var open_exports = {};
|
||||
__export(open_exports, {
|
||||
default: () => open_default
|
||||
});
|
||||
module.exports = __toCommonJS(open_exports);
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
const open = (0, import_tool.defineTool)({
|
||||
capability: "internal",
|
||||
schema: {
|
||||
name: "browser_open",
|
||||
title: "Open URL",
|
||||
description: "Open a URL in the browser",
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
url: import_mcpBundle.z.string().describe("The URL to open"),
|
||||
headed: import_mcpBundle.z.boolean().optional().describe("Run browser in headed mode")
|
||||
}),
|
||||
type: "action"
|
||||
},
|
||||
handle: async (context, params, response) => {
|
||||
const forceHeadless = params.headed ? "headed" : "headless";
|
||||
const tab = await context.ensureTab({ forceHeadless });
|
||||
let url = params.url;
|
||||
try {
|
||||
new URL(url);
|
||||
} catch (e) {
|
||||
if (url.startsWith("localhost"))
|
||||
url = "http://" + url;
|
||||
else
|
||||
url = "https://" + url;
|
||||
}
|
||||
await tab.navigate(url);
|
||||
response.setIncludeSnapshot();
|
||||
response.addCode(`await page.goto('${params.url}');`);
|
||||
}
|
||||
});
|
||||
var open_default = [
|
||||
open
|
||||
];
|
||||
28
node_modules/playwright/lib/mcp/browser/tools/pdf.js
generated
vendored
28
node_modules/playwright/lib/mcp/browser/tools/pdf.js
generated
vendored
@@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
@@ -17,26 +15,18 @@ var __copyProps = (to, from, except, desc) => {
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var pdf_exports = {};
|
||||
__export(pdf_exports, {
|
||||
default: () => pdf_default
|
||||
});
|
||||
module.exports = __toCommonJS(pdf_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var import_tool = require("./tool");
|
||||
var javascript = __toESM(require("../codegen"));
|
||||
var import_utils = require("./utils");
|
||||
const pdfSchema = import_bundle.z.object({
|
||||
filename: import_bundle.z.string().optional().describe("File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified. Prefer relative file names to stay within the output directory.")
|
||||
var import_utils2 = require("./utils");
|
||||
const pdfSchema = import_mcpBundle.z.object({
|
||||
filename: import_mcpBundle.z.string().optional().describe("File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified. Prefer relative file names to stay within the output directory.")
|
||||
});
|
||||
const pdf = (0, import_tool.defineTabTool)({
|
||||
capability: "pdf",
|
||||
@@ -48,10 +38,10 @@ const pdf = (0, import_tool.defineTabTool)({
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (tab, params, response) => {
|
||||
const fileName = await tab.context.outputFile(params.filename ?? (0, import_utils.dateAsFileName)("pdf"), { origin: "llm", reason: "Saving PDF" });
|
||||
response.addCode(`await page.pdf(${javascript.formatObject({ path: fileName })});`);
|
||||
response.addResult(`Saved page as ${fileName}`);
|
||||
await tab.page.pdf({ path: fileName });
|
||||
const data = await tab.page.pdf();
|
||||
const suggestedFilename = params.filename ?? (0, import_utils2.dateAsFileName)("pdf");
|
||||
await response.addResult({ data, title: "Page as pdf", suggestedFilename });
|
||||
response.addCode(`await page.pdf(${(0, import_utils.formatObject)({ path: suggestedFilename })});`);
|
||||
}
|
||||
});
|
||||
var pdf_default = [
|
||||
|
||||
19
node_modules/playwright/lib/mcp/browser/tools/runCode.js
generated
vendored
19
node_modules/playwright/lib/mcp/browser/tools/runCode.js
generated
vendored
@@ -33,10 +33,11 @@ __export(runCode_exports, {
|
||||
module.exports = __toCommonJS(runCode_exports);
|
||||
var import_vm = __toESM(require("vm"));
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
const codeSchema = import_bundle.z.object({
|
||||
code: import_bundle.z.string().describe(`Playwright code snippet to run. The snippet should access the \`page\` object to interact with the page. Can make multiple statements. For example: \`await page.getByRole('button', { name: 'Submit' }).click();\``)
|
||||
const codeSchema = import_mcpBundle.z.object({
|
||||
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. For example: \`async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }\``),
|
||||
filename: import_mcpBundle.z.string().optional().describe("Filename to save the result to. If not provided, result is returned as JSON string.")
|
||||
});
|
||||
const runCode = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
@@ -49,7 +50,7 @@ const runCode = (0, import_tool.defineTabTool)({
|
||||
},
|
||||
handle: async (tab, params, response) => {
|
||||
response.setIncludeSnapshot();
|
||||
response.addCode(params.code);
|
||||
response.addCode(`await (${params.code})(page);`);
|
||||
const __end__ = new import_utils.ManualPromise();
|
||||
const context = {
|
||||
page: tab.page,
|
||||
@@ -59,14 +60,16 @@ const runCode = (0, import_tool.defineTabTool)({
|
||||
await tab.waitForCompletion(async () => {
|
||||
const snippet = `(async () => {
|
||||
try {
|
||||
${params.code};
|
||||
__end__.resolve();
|
||||
const result = await (${params.code})(page);
|
||||
__end__.resolve(JSON.stringify(result));
|
||||
} catch (e) {
|
||||
__end__.reject(e);
|
||||
}
|
||||
})()`;
|
||||
import_vm.default.runInContext(snippet, context);
|
||||
await __end__;
|
||||
await import_vm.default.runInContext(snippet, context);
|
||||
const result = await __end__;
|
||||
if (typeof result === "string")
|
||||
await response.addResult({ text: result, suggestedFilename: params.filename });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
45
node_modules/playwright/lib/mcp/browser/tools/screenshot.js
generated
vendored
45
node_modules/playwright/lib/mcp/browser/tools/screenshot.js
generated
vendored
@@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var screenshot_exports = {};
|
||||
__export(screenshot_exports, {
|
||||
@@ -32,19 +22,18 @@ __export(screenshot_exports, {
|
||||
scaleImageToFitMessage: () => scaleImageToFitMessage
|
||||
});
|
||||
module.exports = __toCommonJS(screenshot_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_utils2 = require("playwright-core/lib/utils");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
var javascript = __toESM(require("../codegen"));
|
||||
var import_utils2 = require("./utils");
|
||||
const screenshotSchema = import_bundle.z.object({
|
||||
type: import_bundle.z.enum(["png", "jpeg"]).default("png").describe("Image format for the screenshot. Default is png."),
|
||||
filename: import_bundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified. Prefer relative file names to stay within the output directory."),
|
||||
element: import_bundle.z.string().optional().describe("Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too."),
|
||||
ref: import_bundle.z.string().optional().describe("Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too."),
|
||||
fullPage: import_bundle.z.boolean().optional().describe("When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Cannot be used with element screenshots.")
|
||||
var import_utils3 = require("./utils");
|
||||
const screenshotSchema = import_mcpBundle.z.object({
|
||||
type: import_mcpBundle.z.enum(["png", "jpeg"]).default("png").describe("Image format for the screenshot. Default is png."),
|
||||
filename: import_mcpBundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified. Prefer relative file names to stay within the output directory."),
|
||||
element: import_mcpBundle.z.string().optional().describe("Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too."),
|
||||
ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too."),
|
||||
fullPage: import_mcpBundle.z.boolean().optional().describe("When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Cannot be used with element screenshots.")
|
||||
});
|
||||
const screenshot = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
@@ -61,7 +50,6 @@ const screenshot = (0, import_tool.defineTabTool)({
|
||||
if (params.fullPage && params.ref)
|
||||
throw new Error("fullPage cannot be used with element screenshots.");
|
||||
const fileType = params.type || "png";
|
||||
const fileName = await tab.context.outputFile(params.filename || (0, import_utils2.dateAsFileName)(fileType), { origin: "llm", reason: "Saving screenshot" });
|
||||
const options = {
|
||||
type: fileType,
|
||||
quality: fileType === "png" ? void 0 : 90,
|
||||
@@ -70,19 +58,18 @@ const screenshot = (0, import_tool.defineTabTool)({
|
||||
};
|
||||
const isElementScreenshot = params.element && params.ref;
|
||||
const screenshotTarget = isElementScreenshot ? params.element : params.fullPage ? "full page" : "viewport";
|
||||
response.addCode(`// Screenshot ${screenshotTarget} and save it as ${fileName}`);
|
||||
const ref = params.ref ? await tab.refLocator({ element: params.element || "", ref: params.ref }) : null;
|
||||
const data = ref ? await ref.locator.screenshot(options) : await tab.page.screenshot(options);
|
||||
const fileName = params.filename || (0, import_utils3.dateAsFileName)(fileType);
|
||||
response.addCode(`// Screenshot ${screenshotTarget} and save it as ${fileName}`);
|
||||
if (ref)
|
||||
response.addCode(`await page.${ref.resolved}.screenshot(${javascript.formatObject(options)});`);
|
||||
response.addCode(`await page.${ref.resolved}.screenshot(${(0, import_utils2.formatObject)({ ...options, path: fileName })});`);
|
||||
else
|
||||
response.addCode(`await page.screenshot(${javascript.formatObject(options)});`);
|
||||
const buffer = ref ? await ref.locator.screenshot(options) : await tab.page.screenshot(options);
|
||||
await (0, import_utils.mkdirIfNeeded)(fileName);
|
||||
await import_fs.default.promises.writeFile(fileName, buffer);
|
||||
response.addResult(`Took the ${screenshotTarget} screenshot and saved it as ${fileName}`);
|
||||
response.addCode(`await page.screenshot(${(0, import_utils2.formatObject)({ ...options, path: fileName })});`);
|
||||
await response.addResult({ data, title: `Screenshot of ${screenshotTarget}`, suggestedFilename: fileName });
|
||||
response.addImage({
|
||||
contentType: fileType === "png" ? "image/png" : "image/jpeg",
|
||||
data: scaleImageToFitMessage(buffer, fileType)
|
||||
data: scaleImageToFitMessage(data, fileType)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
50
node_modules/playwright/lib/mcp/browser/tools/snapshot.js
generated
vendored
50
node_modules/playwright/lib/mcp/browser/tools/snapshot.js
generated
vendored
@@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var snapshot_exports = {};
|
||||
__export(snapshot_exports, {
|
||||
@@ -32,31 +22,33 @@ __export(snapshot_exports, {
|
||||
elementSchema: () => elementSchema
|
||||
});
|
||||
module.exports = __toCommonJS(snapshot_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var import_tool = require("./tool");
|
||||
var javascript = __toESM(require("../codegen"));
|
||||
const snapshot = (0, import_tool.defineTool)({
|
||||
capability: "core",
|
||||
schema: {
|
||||
name: "browser_snapshot",
|
||||
title: "Page snapshot",
|
||||
description: "Capture accessibility snapshot of the current page, this is better than screenshot",
|
||||
inputSchema: import_bundle.z.object({}),
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
filename: import_mcpBundle.z.string().optional().describe("Save snapshot to markdown file instead of returning it in the response.")
|
||||
}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context, params, response) => {
|
||||
await context.ensureTab();
|
||||
response.setIncludeSnapshot("full");
|
||||
response.setIncludeFullSnapshot(params.filename);
|
||||
}
|
||||
});
|
||||
const elementSchema = import_bundle.z.object({
|
||||
element: import_bundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element"),
|
||||
ref: import_bundle.z.string().describe("Exact target element reference from the page snapshot")
|
||||
const elementSchema = import_mcpBundle.z.object({
|
||||
element: import_mcpBundle.z.string().optional().describe("Human-readable element description used to obtain permission to interact with the element"),
|
||||
ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
|
||||
});
|
||||
const clickSchema = elementSchema.extend({
|
||||
doubleClick: import_bundle.z.boolean().optional().describe("Whether to perform a double click instead of a single click"),
|
||||
button: import_bundle.z.enum(["left", "right", "middle"]).optional().describe("Button to click, defaults to left"),
|
||||
modifiers: import_bundle.z.array(import_bundle.z.enum(["Alt", "Control", "ControlOrMeta", "Meta", "Shift"])).optional().describe("Modifier keys to press")
|
||||
doubleClick: import_mcpBundle.z.boolean().optional().describe("Whether to perform a double click instead of a single click"),
|
||||
button: import_mcpBundle.z.enum(["left", "right", "middle"]).optional().describe("Button to click, defaults to left"),
|
||||
modifiers: import_mcpBundle.z.array(import_mcpBundle.z.enum(["Alt", "Control", "ControlOrMeta", "Meta", "Shift"])).optional().describe("Modifier keys to press")
|
||||
});
|
||||
const click = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
@@ -74,7 +66,7 @@ const click = (0, import_tool.defineTabTool)({
|
||||
button: params.button,
|
||||
modifiers: params.modifiers
|
||||
};
|
||||
const formatted = javascript.formatObject(options, " ", "oneline");
|
||||
const formatted = (0, import_utils.formatObject)(options, " ", "oneline");
|
||||
const optionsAttr = formatted !== "{}" ? formatted : "";
|
||||
if (params.doubleClick)
|
||||
response.addCode(`await page.${resolved}.dblclick(${optionsAttr});`);
|
||||
@@ -94,11 +86,11 @@ const drag = (0, import_tool.defineTabTool)({
|
||||
name: "browser_drag",
|
||||
title: "Drag mouse",
|
||||
description: "Perform drag and drop between two elements",
|
||||
inputSchema: import_bundle.z.object({
|
||||
startElement: import_bundle.z.string().describe("Human-readable source element description used to obtain the permission to interact with the element"),
|
||||
startRef: import_bundle.z.string().describe("Exact source element reference from the page snapshot"),
|
||||
endElement: import_bundle.z.string().describe("Human-readable target element description used to obtain the permission to interact with the element"),
|
||||
endRef: import_bundle.z.string().describe("Exact target element reference from the page snapshot")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
startElement: import_mcpBundle.z.string().describe("Human-readable source element description used to obtain the permission to interact with the element"),
|
||||
startRef: import_mcpBundle.z.string().describe("Exact source element reference from the page snapshot"),
|
||||
endElement: import_mcpBundle.z.string().describe("Human-readable target element description used to obtain the permission to interact with the element"),
|
||||
endRef: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
|
||||
}),
|
||||
type: "input"
|
||||
},
|
||||
@@ -133,7 +125,7 @@ const hover = (0, import_tool.defineTabTool)({
|
||||
}
|
||||
});
|
||||
const selectOptionSchema = elementSchema.extend({
|
||||
values: import_bundle.z.array(import_bundle.z.string()).describe("Array of values to select in the dropdown. This can be a single value or multiple values.")
|
||||
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.")
|
||||
});
|
||||
const selectOption = (0, import_tool.defineTabTool)({
|
||||
capability: "core",
|
||||
@@ -147,7 +139,7 @@ const selectOption = (0, import_tool.defineTabTool)({
|
||||
handle: async (tab, params, response) => {
|
||||
response.setIncludeSnapshot();
|
||||
const { locator, resolved } = await tab.refLocator(params);
|
||||
response.addCode(`await page.${resolved}.selectOption(${javascript.formatObject(params.values)});`);
|
||||
response.addCode(`await page.${resolved}.selectOption(${(0, import_utils.formatObject)(params.values)});`);
|
||||
await tab.waitForCompletion(async () => {
|
||||
await locator.selectOption(params.values);
|
||||
});
|
||||
@@ -164,7 +156,7 @@ const pickLocator = (0, import_tool.defineTabTool)({
|
||||
},
|
||||
handle: async (tab, params, response) => {
|
||||
const { resolved } = await tab.refLocator(params);
|
||||
response.addResult(resolved);
|
||||
response.addTextResult(resolved);
|
||||
}
|
||||
});
|
||||
var snapshot_default = [
|
||||
|
||||
24
node_modules/playwright/lib/mcp/browser/tools/tabs.js
generated
vendored
24
node_modules/playwright/lib/mcp/browser/tools/tabs.js
generated
vendored
@@ -21,17 +21,18 @@ __export(tabs_exports, {
|
||||
default: () => tabs_default
|
||||
});
|
||||
module.exports = __toCommonJS(tabs_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
var import_response = require("../response");
|
||||
const browserTabs = (0, import_tool.defineTool)({
|
||||
capability: "core-tabs",
|
||||
schema: {
|
||||
name: "browser_tabs",
|
||||
title: "Manage tabs",
|
||||
description: "List, create, close, or select a browser tab.",
|
||||
inputSchema: import_bundle.z.object({
|
||||
action: import_bundle.z.enum(["list", "new", "close", "select"]).describe("Operation to perform"),
|
||||
index: import_bundle.z.number().optional().describe("Tab index, used for close/select. If omitted for close, current tab is closed.")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
action: import_mcpBundle.z.enum(["list", "new", "close", "select"]).describe("Operation to perform"),
|
||||
index: import_mcpBundle.z.number().optional().describe("Tab index, used for close/select. If omitted for close, current tab is closed.")
|
||||
}),
|
||||
type: "action"
|
||||
},
|
||||
@@ -39,27 +40,26 @@ const browserTabs = (0, import_tool.defineTool)({
|
||||
switch (params.action) {
|
||||
case "list": {
|
||||
await context.ensureTab();
|
||||
response.setIncludeTabs();
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case "new": {
|
||||
await context.newTab();
|
||||
response.setIncludeTabs();
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case "close": {
|
||||
await context.closeTab(params.index);
|
||||
response.setIncludeSnapshot("full");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case "select": {
|
||||
if (params.index === void 0)
|
||||
throw new Error("Tab index is required");
|
||||
await context.selectTab(params.index);
|
||||
response.setIncludeSnapshot("full");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const tabHeaders = await Promise.all(context.tabs().map((tab) => tab.headerSnapshot()));
|
||||
const result = (0, import_response.renderTabsMarkdown)(tabHeaders);
|
||||
response.addTextResult(result.join("\n"));
|
||||
}
|
||||
});
|
||||
var tabs_default = [
|
||||
|
||||
6
node_modules/playwright/lib/mcp/browser/tools/tool.js
generated
vendored
6
node_modules/playwright/lib/mcp/browser/tools/tool.js
generated
vendored
@@ -32,11 +32,9 @@ function defineTabTool(tool) {
|
||||
const tab = await context.ensureTab();
|
||||
const modalStates = tab.modalStates().map((state) => state.type);
|
||||
if (tool.clearsModalState && !modalStates.includes(tool.clearsModalState))
|
||||
response.addError(`Error: The tool "${tool.schema.name}" can only be used when there is related modal state present.
|
||||
` + tab.modalStatesMarkdown().join("\n"));
|
||||
response.addError(`Error: The tool "${tool.schema.name}" can only be used when there is related modal state present.`);
|
||||
else if (!tool.clearsModalState && modalStates.length)
|
||||
response.addError(`Error: Tool "${tool.schema.name}" does not handle the modal state.
|
||||
` + tab.modalStatesMarkdown().join("\n"));
|
||||
response.addError(`Error: Tool "${tool.schema.name}" does not handle the modal state.`);
|
||||
else
|
||||
return tool.handle(tab, params, response);
|
||||
}
|
||||
|
||||
12
node_modules/playwright/lib/mcp/browser/tools/tracing.js
generated
vendored
12
node_modules/playwright/lib/mcp/browser/tools/tracing.js
generated
vendored
@@ -21,7 +21,7 @@ __export(tracing_exports, {
|
||||
default: () => tracing_default
|
||||
});
|
||||
module.exports = __toCommonJS(tracing_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
const tracingStart = (0, import_tool.defineTool)({
|
||||
capability: "tracing",
|
||||
@@ -29,12 +29,12 @@ const tracingStart = (0, import_tool.defineTool)({
|
||||
name: "browser_start_tracing",
|
||||
title: "Start tracing",
|
||||
description: "Start trace recording",
|
||||
inputSchema: import_bundle.z.object({}),
|
||||
inputSchema: import_mcpBundle.z.object({}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context, params, response) => {
|
||||
const browserContext = await context.ensureBrowserContext();
|
||||
const tracesDir = await context.outputFile(`traces`, { origin: "code", reason: "Collecting trace" });
|
||||
const tracesDir = await context.outputFile(`traces`, { origin: "code", title: "Collecting trace" });
|
||||
const name = "trace-" + Date.now();
|
||||
await browserContext.tracing.start({
|
||||
name,
|
||||
@@ -45,7 +45,7 @@ const tracingStart = (0, import_tool.defineTool)({
|
||||
const traceLegend = `- Action log: ${tracesDir}/${name}.trace
|
||||
- Network log: ${tracesDir}/${name}.network
|
||||
- Resources with content by sha1: ${tracesDir}/resources`;
|
||||
response.addResult(`Tracing started, saving to ${tracesDir}.
|
||||
response.addTextResult(`Tracing started, saving to ${tracesDir}.
|
||||
${traceLegend}`);
|
||||
browserContext.tracing[traceLegendSymbol] = traceLegend;
|
||||
}
|
||||
@@ -56,14 +56,14 @@ const tracingStop = (0, import_tool.defineTool)({
|
||||
name: "browser_stop_tracing",
|
||||
title: "Stop tracing",
|
||||
description: "Stop trace recording",
|
||||
inputSchema: import_bundle.z.object({}),
|
||||
inputSchema: import_mcpBundle.z.object({}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context, params, response) => {
|
||||
const browserContext = await context.ensureBrowserContext();
|
||||
await browserContext.tracing.stop();
|
||||
const traceLegend = browserContext.tracing[traceLegendSymbol];
|
||||
response.addResult(`Tracing stopped.
|
||||
response.addTextResult(`Tracing stopped.
|
||||
${traceLegend}`);
|
||||
}
|
||||
});
|
||||
|
||||
93
node_modules/playwright/lib/mcp/browser/tools/utils.js
generated
vendored
93
node_modules/playwright/lib/mcp/browser/tools/utils.js
generated
vendored
@@ -20,59 +20,44 @@ var utils_exports = {};
|
||||
__export(utils_exports, {
|
||||
callOnPageNoTrace: () => callOnPageNoTrace,
|
||||
dateAsFileName: () => dateAsFileName,
|
||||
eventWaiter: () => eventWaiter,
|
||||
waitForCompletion: () => waitForCompletion
|
||||
});
|
||||
module.exports = __toCommonJS(utils_exports);
|
||||
async function waitForCompletion(tab, callback) {
|
||||
const requests = /* @__PURE__ */ new Set();
|
||||
let frameNavigated = false;
|
||||
let waitCallback = () => {
|
||||
};
|
||||
const waitBarrier = new Promise((f) => {
|
||||
waitCallback = f;
|
||||
});
|
||||
const responseListener = (request) => {
|
||||
requests.delete(request);
|
||||
if (!requests.size)
|
||||
waitCallback();
|
||||
};
|
||||
const requestListener = (request) => {
|
||||
requests.add(request);
|
||||
void request.response().then(() => responseListener(request)).catch(() => {
|
||||
});
|
||||
};
|
||||
const frameNavigateListener = (frame) => {
|
||||
if (frame.parentFrame())
|
||||
return;
|
||||
frameNavigated = true;
|
||||
dispose();
|
||||
clearTimeout(timeout);
|
||||
void tab.waitForLoadState("load").then(waitCallback);
|
||||
};
|
||||
const onTimeout = () => {
|
||||
dispose();
|
||||
waitCallback();
|
||||
const requests = [];
|
||||
const requestListener = (request) => requests.push(request);
|
||||
const disposeListeners = () => {
|
||||
tab.page.off("request", requestListener);
|
||||
};
|
||||
tab.page.on("request", requestListener);
|
||||
tab.page.on("requestfailed", responseListener);
|
||||
tab.page.on("framenavigated", frameNavigateListener);
|
||||
const timeout = setTimeout(onTimeout, 1e4);
|
||||
const dispose = () => {
|
||||
tab.page.off("request", requestListener);
|
||||
tab.page.off("requestfailed", responseListener);
|
||||
tab.page.off("framenavigated", frameNavigateListener);
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
let result;
|
||||
try {
|
||||
const result = await callback();
|
||||
if (!requests.size && !frameNavigated)
|
||||
waitCallback();
|
||||
await waitBarrier;
|
||||
await tab.waitForTimeout(1e3);
|
||||
return result;
|
||||
result = await callback();
|
||||
await tab.waitForTimeout(500);
|
||||
} finally {
|
||||
dispose();
|
||||
disposeListeners();
|
||||
}
|
||||
const requestedNavigation = requests.some((request) => request.isNavigationRequest());
|
||||
if (requestedNavigation) {
|
||||
await tab.page.mainFrame().waitForLoadState("load", { timeout: 1e4 }).catch(() => {
|
||||
});
|
||||
return result;
|
||||
}
|
||||
const promises = [];
|
||||
for (const request of requests) {
|
||||
if (["document", "stylesheet", "script", "xhr", "fetch"].includes(request.resourceType()))
|
||||
promises.push(request.response().then((r) => r?.finished()).catch(() => {
|
||||
}));
|
||||
else
|
||||
promises.push(request.response().catch(() => {
|
||||
}));
|
||||
}
|
||||
const timeout = new Promise((resolve) => setTimeout(resolve, 5e3));
|
||||
await Promise.race([Promise.all(promises), timeout]);
|
||||
if (requests.length)
|
||||
await tab.waitForTimeout(500);
|
||||
return result;
|
||||
}
|
||||
async function callOnPageNoTrace(page, callback) {
|
||||
return await page._wrapApiCall(() => callback(page), { internal: true });
|
||||
@@ -81,9 +66,29 @@ function dateAsFileName(extension) {
|
||||
const date = /* @__PURE__ */ new Date();
|
||||
return `page-${date.toISOString().replace(/[:.]/g, "-")}.${extension}`;
|
||||
}
|
||||
function eventWaiter(page, event, timeout) {
|
||||
const disposables = [];
|
||||
const eventPromise = new Promise((resolve, reject) => {
|
||||
page.on(event, resolve);
|
||||
disposables.push(() => page.off(event, resolve));
|
||||
});
|
||||
let abort;
|
||||
const abortPromise = new Promise((resolve, reject) => {
|
||||
abort = () => resolve(void 0);
|
||||
});
|
||||
const timeoutPromise = new Promise((f) => {
|
||||
const timeoutId = setTimeout(() => f(void 0), timeout);
|
||||
disposables.push(() => clearTimeout(timeoutId));
|
||||
});
|
||||
return {
|
||||
promise: Promise.race([eventPromise, abortPromise, timeoutPromise]).finally(() => disposables.forEach((dispose) => dispose())),
|
||||
abort
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
callOnPageNoTrace,
|
||||
dateAsFileName,
|
||||
eventWaiter,
|
||||
waitForCompletion
|
||||
});
|
||||
|
||||
58
node_modules/playwright/lib/mcp/browser/tools/verify.js
generated
vendored
58
node_modules/playwright/lib/mcp/browser/tools/verify.js
generated
vendored
@@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
@@ -17,32 +15,24 @@ var __copyProps = (to, from, except, desc) => {
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var verify_exports = {};
|
||||
__export(verify_exports, {
|
||||
default: () => verify_default
|
||||
});
|
||||
module.exports = __toCommonJS(verify_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var import_tool = require("./tool");
|
||||
var javascript = __toESM(require("../codegen"));
|
||||
const verifyElement = (0, import_tool.defineTabTool)({
|
||||
capability: "testing",
|
||||
schema: {
|
||||
name: "browser_verify_element_visible",
|
||||
title: "Verify element visible",
|
||||
description: "Verify element is visible on the page",
|
||||
inputSchema: import_bundle.z.object({
|
||||
role: import_bundle.z.string().describe('ROLE of the element. Can be found in the snapshot like this: `- {ROLE} "Accessible Name":`'),
|
||||
accessibleName: import_bundle.z.string().describe('ACCESSIBLE_NAME of the element. Can be found in the snapshot like this: `- role "{ACCESSIBLE_NAME}"`')
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
role: import_mcpBundle.z.string().describe('ROLE of the element. Can be found in the snapshot like this: `- {ROLE} "Accessible Name":`'),
|
||||
accessibleName: import_mcpBundle.z.string().describe('ACCESSIBLE_NAME of the element. Can be found in the snapshot like this: `- role "{ACCESSIBLE_NAME}"`')
|
||||
}),
|
||||
type: "assertion"
|
||||
},
|
||||
@@ -52,8 +42,8 @@ const verifyElement = (0, import_tool.defineTabTool)({
|
||||
response.addError(`Element with role "${params.role}" and accessible name "${params.accessibleName}" not found`);
|
||||
return;
|
||||
}
|
||||
response.addCode(`await expect(page.getByRole(${javascript.escapeWithQuotes(params.role)}, { name: ${javascript.escapeWithQuotes(params.accessibleName)} })).toBeVisible();`);
|
||||
response.addResult("Done");
|
||||
response.addCode(`await expect(page.getByRole(${(0, import_utils.escapeWithQuotes)(params.role)}, { name: ${(0, import_utils.escapeWithQuotes)(params.accessibleName)} })).toBeVisible();`);
|
||||
response.addTextResult("Done");
|
||||
}
|
||||
});
|
||||
const verifyText = (0, import_tool.defineTabTool)({
|
||||
@@ -62,8 +52,8 @@ const verifyText = (0, import_tool.defineTabTool)({
|
||||
name: "browser_verify_text_visible",
|
||||
title: "Verify text visible",
|
||||
description: `Verify text is visible on the page. Prefer ${verifyElement.schema.name} if possible.`,
|
||||
inputSchema: import_bundle.z.object({
|
||||
text: import_bundle.z.string().describe('TEXT to verify. Can be found in the snapshot like this: `- role "Accessible Name": {TEXT}` or like this: `- text: {TEXT}`')
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
text: import_mcpBundle.z.string().describe('TEXT to verify. Can be found in the snapshot like this: `- role "Accessible Name": {TEXT}` or like this: `- text: {TEXT}`')
|
||||
}),
|
||||
type: "assertion"
|
||||
},
|
||||
@@ -73,8 +63,8 @@ const verifyText = (0, import_tool.defineTabTool)({
|
||||
response.addError("Text not found");
|
||||
return;
|
||||
}
|
||||
response.addCode(`await expect(page.getByText(${javascript.escapeWithQuotes(params.text)})).toBeVisible();`);
|
||||
response.addResult("Done");
|
||||
response.addCode(`await expect(page.getByText(${(0, import_utils.escapeWithQuotes)(params.text)})).toBeVisible();`);
|
||||
response.addTextResult("Done");
|
||||
}
|
||||
});
|
||||
const verifyList = (0, import_tool.defineTabTool)({
|
||||
@@ -83,10 +73,10 @@ const verifyList = (0, import_tool.defineTabTool)({
|
||||
name: "browser_verify_list_visible",
|
||||
title: "Verify list visible",
|
||||
description: "Verify list is visible on the page",
|
||||
inputSchema: import_bundle.z.object({
|
||||
element: import_bundle.z.string().describe("Human-readable list description"),
|
||||
ref: import_bundle.z.string().describe("Exact target element reference that points to the list"),
|
||||
items: import_bundle.z.array(import_bundle.z.string()).describe("Items to verify")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
element: import_mcpBundle.z.string().describe("Human-readable list description"),
|
||||
ref: import_mcpBundle.z.string().describe("Exact target element reference that points to the list"),
|
||||
items: import_mcpBundle.z.array(import_mcpBundle.z.string()).describe("Items to verify")
|
||||
}),
|
||||
type: "assertion"
|
||||
},
|
||||
@@ -103,10 +93,10 @@ const verifyList = (0, import_tool.defineTabTool)({
|
||||
}
|
||||
const ariaSnapshot = `\`
|
||||
- list:
|
||||
${itemTexts.map((t) => ` - listitem: ${javascript.escapeWithQuotes(t, '"')}`).join("\n")}
|
||||
${itemTexts.map((t) => ` - listitem: ${(0, import_utils.escapeWithQuotes)(t, '"')}`).join("\n")}
|
||||
\``;
|
||||
response.addCode(`await expect(page.locator('body')).toMatchAriaSnapshot(${ariaSnapshot});`);
|
||||
response.addResult("Done");
|
||||
response.addTextResult("Done");
|
||||
}
|
||||
});
|
||||
const verifyValue = (0, import_tool.defineTabTool)({
|
||||
@@ -115,11 +105,11 @@ const verifyValue = (0, import_tool.defineTabTool)({
|
||||
name: "browser_verify_value",
|
||||
title: "Verify value",
|
||||
description: "Verify element value",
|
||||
inputSchema: import_bundle.z.object({
|
||||
type: import_bundle.z.enum(["textbox", "checkbox", "radio", "combobox", "slider"]).describe("Type of the element"),
|
||||
element: import_bundle.z.string().describe("Human-readable element description"),
|
||||
ref: import_bundle.z.string().describe("Exact target element reference that points to the element"),
|
||||
value: import_bundle.z.string().describe('Value to verify. For checkbox, use "true" or "false".')
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
type: import_mcpBundle.z.enum(["textbox", "checkbox", "radio", "combobox", "slider"]).describe("Type of the element"),
|
||||
element: import_mcpBundle.z.string().describe("Human-readable element description"),
|
||||
ref: import_mcpBundle.z.string().describe("Exact target element reference that points to the element"),
|
||||
value: import_mcpBundle.z.string().describe('Value to verify. For checkbox, use "true" or "false".')
|
||||
}),
|
||||
type: "assertion"
|
||||
},
|
||||
@@ -132,7 +122,7 @@ const verifyValue = (0, import_tool.defineTabTool)({
|
||||
response.addError(`Expected value "${params.value}", but got "${value}"`);
|
||||
return;
|
||||
}
|
||||
response.addCode(`await expect(${locatorSource}).toHaveValue(${javascript.quote(params.value)});`);
|
||||
response.addCode(`await expect(${locatorSource}).toHaveValue(${(0, import_utils.escapeWithQuotes)(params.value)});`);
|
||||
} else if (params.type === "checkbox" || params.type === "radio") {
|
||||
const value = await locator.isChecked();
|
||||
if (value !== (params.value === "true")) {
|
||||
@@ -142,7 +132,7 @@ const verifyValue = (0, import_tool.defineTabTool)({
|
||||
const matcher = value ? "toBeChecked" : "not.toBeChecked";
|
||||
response.addCode(`await expect(${locatorSource}).${matcher}();`);
|
||||
}
|
||||
response.addResult("Done");
|
||||
response.addTextResult("Done");
|
||||
}
|
||||
});
|
||||
var verify_default = [
|
||||
|
||||
12
node_modules/playwright/lib/mcp/browser/tools/wait.js
generated
vendored
12
node_modules/playwright/lib/mcp/browser/tools/wait.js
generated
vendored
@@ -21,7 +21,7 @@ __export(wait_exports, {
|
||||
default: () => wait_default
|
||||
});
|
||||
module.exports = __toCommonJS(wait_exports);
|
||||
var import_bundle = require("../../sdk/bundle");
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
var import_tool = require("./tool");
|
||||
const wait = (0, import_tool.defineTool)({
|
||||
capability: "core",
|
||||
@@ -29,10 +29,10 @@ const wait = (0, import_tool.defineTool)({
|
||||
name: "browser_wait_for",
|
||||
title: "Wait for",
|
||||
description: "Wait for text to appear or disappear or a specified time to pass",
|
||||
inputSchema: import_bundle.z.object({
|
||||
time: import_bundle.z.number().optional().describe("The time to wait in seconds"),
|
||||
text: import_bundle.z.string().optional().describe("The text to wait for"),
|
||||
textGone: import_bundle.z.string().optional().describe("The text to wait for to disappear")
|
||||
inputSchema: import_mcpBundle.z.object({
|
||||
time: import_mcpBundle.z.number().optional().describe("The time to wait in seconds"),
|
||||
text: import_mcpBundle.z.string().optional().describe("The text to wait for"),
|
||||
textGone: import_mcpBundle.z.string().optional().describe("The text to wait for to disappear")
|
||||
}),
|
||||
type: "assertion"
|
||||
},
|
||||
@@ -54,7 +54,7 @@ const wait = (0, import_tool.defineTool)({
|
||||
response.addCode(`await page.getByText(${JSON.stringify(params.text)}).first().waitFor({ state: 'visible' });`);
|
||||
await locator.waitFor({ state: "visible" });
|
||||
}
|
||||
response.addResult(`Waited for ${params.text || params.textGone || params.time}`);
|
||||
response.addTextResult(`Waited for ${params.text || params.textGone || params.time}`);
|
||||
response.setIncludeSnapshot();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user