playwright 1.56.0-alpha-2025-09-03 → 1.56.0-alpha-2025-09-04
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.
- package/README.md +2 -2
- package/ThirdPartyNotices.txt +3 -3
- package/lib/index.js +2 -2
- package/lib/matchers/toBeTruthy.js +3 -3
- package/lib/matchers/toEqual.js +3 -3
- package/lib/matchers/toMatchText.js +3 -3
- package/lib/mcp/browser/actions.d.js +16 -0
- package/lib/mcp/browser/browserContextFactory.js +227 -0
- package/lib/mcp/browser/browserServerBackend.js +82 -0
- package/lib/mcp/browser/codegen.js +64 -0
- package/lib/mcp/browser/config.js +279 -0
- package/lib/mcp/browser/context.js +229 -0
- package/lib/mcp/browser/response.js +163 -0
- package/lib/mcp/browser/sessionLog.js +160 -0
- package/lib/mcp/browser/tab.js +256 -0
- package/lib/mcp/browser/tools/common.js +63 -0
- package/lib/mcp/browser/tools/console.js +41 -0
- package/lib/mcp/browser/tools/dialogs.js +55 -0
- package/lib/mcp/browser/tools/evaluate.js +70 -0
- package/lib/mcp/browser/tools/files.js +52 -0
- package/lib/mcp/browser/tools/form.js +73 -0
- package/lib/mcp/browser/tools/install.js +69 -0
- package/lib/mcp/browser/tools/keyboard.js +95 -0
- package/lib/mcp/browser/tools/mouse.js +107 -0
- package/lib/mcp/browser/tools/navigate.js +62 -0
- package/lib/mcp/browser/tools/network.js +49 -0
- package/lib/mcp/{sdk/call.js → browser/tools/pdf.js} +27 -18
- package/lib/mcp/browser/tools/screenshot.js +94 -0
- package/lib/mcp/browser/tools/snapshot.js +162 -0
- package/lib/mcp/browser/tools/tabs.js +67 -0
- package/lib/mcp/browser/tools/tool.js +49 -0
- package/lib/mcp/browser/tools/utils.js +90 -0
- package/lib/mcp/browser/tools/verify.js +154 -0
- package/lib/mcp/browser/tools/wait.js +63 -0
- package/lib/mcp/browser/tools.js +42 -83
- package/lib/mcp/config.d.js +16 -0
- package/lib/mcp/extension/cdpRelay.js +348 -0
- package/lib/mcp/extension/extensionContextFactory.js +75 -0
- package/lib/mcp/{browser/tool.js → extension/protocol.js} +6 -8
- package/lib/mcp/index.js +61 -0
- package/lib/mcp/log.js +35 -0
- package/lib/mcp/program.js +96 -0
- package/lib/mcp/sdk/bundle.js +11 -1
- package/lib/mcp/sdk/exports.js +2 -2
- package/lib/mcp/sdk/http.js +21 -6
- package/lib/mcp/sdk/mdb.js +16 -15
- package/lib/mcp/sdk/proxyBackend.js +7 -6
- package/lib/mcp/sdk/server.js +6 -6
- package/lib/mcp/sdk/tool.js +1 -1
- package/lib/mcp/{browser/backend.js → test/browserBackend.js} +7 -9
- package/lib/mcp/test/browserTool.js +30 -0
- package/lib/mcp/test/browserTools.js +120 -0
- package/lib/mcp/test/{backend.js → testBackend.js} +12 -12
- package/lib/mcp/test/{context.js → testContext.js} +6 -6
- package/lib/mcp/test/{tool.js → testTool.js} +6 -6
- package/lib/mcp/test/{tools.js → testTools.js} +7 -7
- package/lib/mcpBundleImpl.js +11 -11
- package/lib/program.js +4 -4
- package/package.json +6 -3
|
@@ -0,0 +1,52 @@
|
|
|
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 files_exports = {};
|
|
20
|
+
__export(files_exports, {
|
|
21
|
+
default: () => files_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(files_exports);
|
|
24
|
+
var import_bundle = require("../../sdk/bundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const uploadFile = (0, import_tool.defineTabTool)({
|
|
27
|
+
capability: "core",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_file_upload",
|
|
30
|
+
title: "Upload files",
|
|
31
|
+
description: "Upload one or multiple files",
|
|
32
|
+
inputSchema: import_bundle.z.object({
|
|
33
|
+
paths: import_bundle.z.array(import_bundle.z.string()).describe("The absolute paths to the files to upload. Can be a single file or multiple files.")
|
|
34
|
+
}),
|
|
35
|
+
type: "destructive"
|
|
36
|
+
},
|
|
37
|
+
handle: async (tab, params, response) => {
|
|
38
|
+
response.setIncludeSnapshot();
|
|
39
|
+
const modalState = tab.modalStates().find((state) => state.type === "fileChooser");
|
|
40
|
+
if (!modalState)
|
|
41
|
+
throw new Error("No file chooser visible");
|
|
42
|
+
response.addCode(`await fileChooser.setFiles(${JSON.stringify(params.paths)})`);
|
|
43
|
+
tab.clearModalState(modalState);
|
|
44
|
+
await tab.waitForCompletion(async () => {
|
|
45
|
+
await modalState.fileChooser.setFiles(params.paths);
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
clearsModalState: "fileChooser"
|
|
49
|
+
});
|
|
50
|
+
var files_default = [
|
|
51
|
+
uploadFile
|
|
52
|
+
];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var form_exports = {};
|
|
30
|
+
__export(form_exports, {
|
|
31
|
+
default: () => form_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(form_exports);
|
|
34
|
+
var import_bundle = require("../../sdk/bundle");
|
|
35
|
+
var import_tool = require("./tool");
|
|
36
|
+
var import_utils = require("./utils");
|
|
37
|
+
var javascript = __toESM(require("../codegen"));
|
|
38
|
+
const fillForm = (0, import_tool.defineTabTool)({
|
|
39
|
+
capability: "core",
|
|
40
|
+
schema: {
|
|
41
|
+
name: "browser_fill_form",
|
|
42
|
+
title: "Fill form",
|
|
43
|
+
description: "Fill multiple form fields",
|
|
44
|
+
inputSchema: import_bundle.z.object({
|
|
45
|
+
fields: import_bundle.z.array(import_bundle.z.object({
|
|
46
|
+
name: import_bundle.z.string().describe("Human-readable field name"),
|
|
47
|
+
type: import_bundle.z.enum(["textbox", "checkbox", "radio", "combobox", "slider"]).describe("Type of the field"),
|
|
48
|
+
ref: import_bundle.z.string().describe("Exact target field reference from the page snapshot"),
|
|
49
|
+
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.")
|
|
50
|
+
})).describe("Fields to fill in")
|
|
51
|
+
}),
|
|
52
|
+
type: "destructive"
|
|
53
|
+
},
|
|
54
|
+
handle: async (tab, params, response) => {
|
|
55
|
+
for (const field of params.fields) {
|
|
56
|
+
const locator = await tab.refLocator({ element: field.name, ref: field.ref });
|
|
57
|
+
const locatorSource = `await page.${await (0, import_utils.generateLocator)(locator)}`;
|
|
58
|
+
if (field.type === "textbox" || field.type === "slider") {
|
|
59
|
+
await locator.fill(field.value);
|
|
60
|
+
response.addCode(`${locatorSource}.fill(${javascript.quote(field.value)});`);
|
|
61
|
+
} else if (field.type === "checkbox" || field.type === "radio") {
|
|
62
|
+
await locator.setChecked(field.value === "true");
|
|
63
|
+
response.addCode(`${locatorSource}.setChecked(${javascript.quote(field.value)});`);
|
|
64
|
+
} else if (field.type === "combobox") {
|
|
65
|
+
await locator.selectOption({ label: field.value });
|
|
66
|
+
response.addCode(`${locatorSource}.selectOption(${javascript.quote(field.value)});`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
var form_default = [
|
|
72
|
+
fillForm
|
|
73
|
+
];
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var install_exports = {};
|
|
30
|
+
__export(install_exports, {
|
|
31
|
+
default: () => install_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(install_exports);
|
|
34
|
+
var import_child_process = require("child_process");
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_bundle = require("../../sdk/bundle");
|
|
37
|
+
var import_tool = require("./tool");
|
|
38
|
+
const install = (0, import_tool.defineTool)({
|
|
39
|
+
capability: "core-install",
|
|
40
|
+
schema: {
|
|
41
|
+
name: "browser_install",
|
|
42
|
+
title: "Install the browser specified in the config",
|
|
43
|
+
description: "Install the browser specified in the config. Call this if you get an error about the browser not being installed.",
|
|
44
|
+
inputSchema: import_bundle.z.object({}),
|
|
45
|
+
type: "destructive"
|
|
46
|
+
},
|
|
47
|
+
handle: async (context, params, response) => {
|
|
48
|
+
const channel = context.config.browser?.launchOptions?.channel ?? context.config.browser?.browserName ?? "chrome";
|
|
49
|
+
const cliPath = import_path.default.join(require.resolve("playwright/package.json"), "../cli.js");
|
|
50
|
+
const child = (0, import_child_process.fork)(cliPath, ["install", channel], {
|
|
51
|
+
stdio: "pipe"
|
|
52
|
+
});
|
|
53
|
+
const output = [];
|
|
54
|
+
child.stdout?.on("data", (data) => output.push(data.toString()));
|
|
55
|
+
child.stderr?.on("data", (data) => output.push(data.toString()));
|
|
56
|
+
await new Promise((resolve, reject) => {
|
|
57
|
+
child.on("close", (code) => {
|
|
58
|
+
if (code === 0)
|
|
59
|
+
resolve();
|
|
60
|
+
else
|
|
61
|
+
reject(new Error(`Failed to install browser: ${output.join("")}`));
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
response.setIncludeTabs();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
var install_default = [
|
|
68
|
+
install
|
|
69
|
+
];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var keyboard_exports = {};
|
|
30
|
+
__export(keyboard_exports, {
|
|
31
|
+
default: () => keyboard_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(keyboard_exports);
|
|
34
|
+
var import_bundle = require("../../sdk/bundle");
|
|
35
|
+
var import_tool = require("./tool");
|
|
36
|
+
var import_snapshot = require("./snapshot");
|
|
37
|
+
var import_utils = require("./utils");
|
|
38
|
+
var javascript = __toESM(require("../codegen"));
|
|
39
|
+
const pressKey = (0, import_tool.defineTabTool)({
|
|
40
|
+
capability: "core",
|
|
41
|
+
schema: {
|
|
42
|
+
name: "browser_press_key",
|
|
43
|
+
title: "Press a key",
|
|
44
|
+
description: "Press a key on the keyboard",
|
|
45
|
+
inputSchema: import_bundle.z.object({
|
|
46
|
+
key: import_bundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
|
|
47
|
+
}),
|
|
48
|
+
type: "destructive"
|
|
49
|
+
},
|
|
50
|
+
handle: async (tab, params, response) => {
|
|
51
|
+
response.setIncludeSnapshot();
|
|
52
|
+
response.addCode(`// Press ${params.key}`);
|
|
53
|
+
response.addCode(`await page.keyboard.press('${params.key}');`);
|
|
54
|
+
await tab.waitForCompletion(async () => {
|
|
55
|
+
await tab.page.keyboard.press(params.key);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const typeSchema = import_snapshot.elementSchema.extend({
|
|
60
|
+
text: import_bundle.z.string().describe("Text to type into the element"),
|
|
61
|
+
submit: import_bundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)"),
|
|
62
|
+
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.")
|
|
63
|
+
});
|
|
64
|
+
const type = (0, import_tool.defineTabTool)({
|
|
65
|
+
capability: "core",
|
|
66
|
+
schema: {
|
|
67
|
+
name: "browser_type",
|
|
68
|
+
title: "Type text",
|
|
69
|
+
description: "Type text into editable element",
|
|
70
|
+
inputSchema: typeSchema,
|
|
71
|
+
type: "destructive"
|
|
72
|
+
},
|
|
73
|
+
handle: async (tab, params, response) => {
|
|
74
|
+
const locator = await tab.refLocator(params);
|
|
75
|
+
await tab.waitForCompletion(async () => {
|
|
76
|
+
if (params.slowly) {
|
|
77
|
+
response.setIncludeSnapshot();
|
|
78
|
+
response.addCode(`await page.${await (0, import_utils.generateLocator)(locator)}.pressSequentially(${javascript.quote(params.text)});`);
|
|
79
|
+
await locator.pressSequentially(params.text);
|
|
80
|
+
} else {
|
|
81
|
+
response.addCode(`await page.${await (0, import_utils.generateLocator)(locator)}.fill(${javascript.quote(params.text)});`);
|
|
82
|
+
await locator.fill(params.text);
|
|
83
|
+
}
|
|
84
|
+
if (params.submit) {
|
|
85
|
+
response.setIncludeSnapshot();
|
|
86
|
+
response.addCode(`await page.${await (0, import_utils.generateLocator)(locator)}.press('Enter');`);
|
|
87
|
+
await locator.press("Enter");
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
var keyboard_default = [
|
|
93
|
+
pressKey,
|
|
94
|
+
type
|
|
95
|
+
];
|
|
@@ -0,0 +1,107 @@
|
|
|
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 mouse_exports = {};
|
|
20
|
+
__export(mouse_exports, {
|
|
21
|
+
default: () => mouse_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(mouse_exports);
|
|
24
|
+
var import_bundle = require("../../sdk/bundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const elementSchema = import_bundle.z.object({
|
|
27
|
+
element: import_bundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element")
|
|
28
|
+
});
|
|
29
|
+
const mouseMove = (0, import_tool.defineTabTool)({
|
|
30
|
+
capability: "vision",
|
|
31
|
+
schema: {
|
|
32
|
+
name: "browser_mouse_move_xy",
|
|
33
|
+
title: "Move mouse",
|
|
34
|
+
description: "Move mouse to a given position",
|
|
35
|
+
inputSchema: elementSchema.extend({
|
|
36
|
+
x: import_bundle.z.number().describe("X coordinate"),
|
|
37
|
+
y: import_bundle.z.number().describe("Y coordinate")
|
|
38
|
+
}),
|
|
39
|
+
type: "readOnly"
|
|
40
|
+
},
|
|
41
|
+
handle: async (tab, params, response) => {
|
|
42
|
+
response.addCode(`// Move mouse to (${params.x}, ${params.y})`);
|
|
43
|
+
response.addCode(`await page.mouse.move(${params.x}, ${params.y});`);
|
|
44
|
+
await tab.waitForCompletion(async () => {
|
|
45
|
+
await tab.page.mouse.move(params.x, params.y);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const mouseClick = (0, import_tool.defineTabTool)({
|
|
50
|
+
capability: "vision",
|
|
51
|
+
schema: {
|
|
52
|
+
name: "browser_mouse_click_xy",
|
|
53
|
+
title: "Click",
|
|
54
|
+
description: "Click left mouse button at a given position",
|
|
55
|
+
inputSchema: elementSchema.extend({
|
|
56
|
+
x: import_bundle.z.number().describe("X coordinate"),
|
|
57
|
+
y: import_bundle.z.number().describe("Y coordinate")
|
|
58
|
+
}),
|
|
59
|
+
type: "destructive"
|
|
60
|
+
},
|
|
61
|
+
handle: async (tab, params, response) => {
|
|
62
|
+
response.setIncludeSnapshot();
|
|
63
|
+
response.addCode(`// Click mouse at coordinates (${params.x}, ${params.y})`);
|
|
64
|
+
response.addCode(`await page.mouse.move(${params.x}, ${params.y});`);
|
|
65
|
+
response.addCode(`await page.mouse.down();`);
|
|
66
|
+
response.addCode(`await page.mouse.up();`);
|
|
67
|
+
await tab.waitForCompletion(async () => {
|
|
68
|
+
await tab.page.mouse.move(params.x, params.y);
|
|
69
|
+
await tab.page.mouse.down();
|
|
70
|
+
await tab.page.mouse.up();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const mouseDrag = (0, import_tool.defineTabTool)({
|
|
75
|
+
capability: "vision",
|
|
76
|
+
schema: {
|
|
77
|
+
name: "browser_mouse_drag_xy",
|
|
78
|
+
title: "Drag mouse",
|
|
79
|
+
description: "Drag left mouse button to a given position",
|
|
80
|
+
inputSchema: elementSchema.extend({
|
|
81
|
+
startX: import_bundle.z.number().describe("Start X coordinate"),
|
|
82
|
+
startY: import_bundle.z.number().describe("Start Y coordinate"),
|
|
83
|
+
endX: import_bundle.z.number().describe("End X coordinate"),
|
|
84
|
+
endY: import_bundle.z.number().describe("End Y coordinate")
|
|
85
|
+
}),
|
|
86
|
+
type: "destructive"
|
|
87
|
+
},
|
|
88
|
+
handle: async (tab, params, response) => {
|
|
89
|
+
response.setIncludeSnapshot();
|
|
90
|
+
response.addCode(`// Drag mouse from (${params.startX}, ${params.startY}) to (${params.endX}, ${params.endY})`);
|
|
91
|
+
response.addCode(`await page.mouse.move(${params.startX}, ${params.startY});`);
|
|
92
|
+
response.addCode(`await page.mouse.down();`);
|
|
93
|
+
response.addCode(`await page.mouse.move(${params.endX}, ${params.endY});`);
|
|
94
|
+
response.addCode(`await page.mouse.up();`);
|
|
95
|
+
await tab.waitForCompletion(async () => {
|
|
96
|
+
await tab.page.mouse.move(params.startX, params.startY);
|
|
97
|
+
await tab.page.mouse.down();
|
|
98
|
+
await tab.page.mouse.move(params.endX, params.endY);
|
|
99
|
+
await tab.page.mouse.up();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
var mouse_default = [
|
|
104
|
+
mouseMove,
|
|
105
|
+
mouseClick,
|
|
106
|
+
mouseDrag
|
|
107
|
+
];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var navigate_exports = {};
|
|
20
|
+
__export(navigate_exports, {
|
|
21
|
+
default: () => navigate_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(navigate_exports);
|
|
24
|
+
var import_bundle = require("../../sdk/bundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const navigate = (0, import_tool.defineTool)({
|
|
27
|
+
capability: "core",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_navigate",
|
|
30
|
+
title: "Navigate to a URL",
|
|
31
|
+
description: "Navigate to a URL",
|
|
32
|
+
inputSchema: import_bundle.z.object({
|
|
33
|
+
url: import_bundle.z.string().describe("The URL to navigate to")
|
|
34
|
+
}),
|
|
35
|
+
type: "destructive"
|
|
36
|
+
},
|
|
37
|
+
handle: async (context, params, response) => {
|
|
38
|
+
const tab = await context.ensureTab();
|
|
39
|
+
await tab.navigate(params.url);
|
|
40
|
+
response.setIncludeSnapshot();
|
|
41
|
+
response.addCode(`await page.goto('${params.url}');`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const goBack = (0, import_tool.defineTabTool)({
|
|
45
|
+
capability: "core",
|
|
46
|
+
schema: {
|
|
47
|
+
name: "browser_navigate_back",
|
|
48
|
+
title: "Go back",
|
|
49
|
+
description: "Go back to the previous page",
|
|
50
|
+
inputSchema: import_bundle.z.object({}),
|
|
51
|
+
type: "readOnly"
|
|
52
|
+
},
|
|
53
|
+
handle: async (tab, params, response) => {
|
|
54
|
+
await tab.page.goBack();
|
|
55
|
+
response.setIncludeSnapshot();
|
|
56
|
+
response.addCode(`await page.goBack();`);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
var navigate_default = [
|
|
60
|
+
navigate,
|
|
61
|
+
goBack
|
|
62
|
+
];
|
|
@@ -0,0 +1,49 @@
|
|
|
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 network_exports = {};
|
|
20
|
+
__export(network_exports, {
|
|
21
|
+
default: () => network_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(network_exports);
|
|
24
|
+
var import_bundle = require("../../sdk/bundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const requests = (0, import_tool.defineTabTool)({
|
|
27
|
+
capability: "core",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_network_requests",
|
|
30
|
+
title: "List network requests",
|
|
31
|
+
description: "Returns all network requests since loading the page",
|
|
32
|
+
inputSchema: import_bundle.z.object({}),
|
|
33
|
+
type: "readOnly"
|
|
34
|
+
},
|
|
35
|
+
handle: async (tab, params, response) => {
|
|
36
|
+
const requests2 = tab.requests();
|
|
37
|
+
[...requests2.entries()].forEach(([req, res]) => response.addResult(renderRequest(req, res)));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
function renderRequest(request, response) {
|
|
41
|
+
const result = [];
|
|
42
|
+
result.push(`[${request.method().toUpperCase()}] ${request.url()}`);
|
|
43
|
+
if (response)
|
|
44
|
+
result.push(`=> [${response.status()}] ${response.statusText()}`);
|
|
45
|
+
return result.join(" ");
|
|
46
|
+
}
|
|
47
|
+
var network_default = [
|
|
48
|
+
requests
|
|
49
|
+
];
|
|
@@ -26,24 +26,33 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
29
|
+
var pdf_exports = {};
|
|
30
|
+
__export(pdf_exports, {
|
|
31
|
+
default: () => pdf_default
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
module.exports = __toCommonJS(pdf_exports);
|
|
34
|
+
var import_bundle = require("../../sdk/bundle");
|
|
35
|
+
var import_tool = require("./tool");
|
|
36
|
+
var javascript = __toESM(require("../codegen"));
|
|
37
|
+
const pdfSchema = import_bundle.z.object({
|
|
38
|
+
filename: import_bundle.z.string().optional().describe("File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.")
|
|
39
|
+
});
|
|
40
|
+
const pdf = (0, import_tool.defineTabTool)({
|
|
41
|
+
capability: "pdf",
|
|
42
|
+
schema: {
|
|
43
|
+
name: "browser_pdf_save",
|
|
44
|
+
title: "Save as PDF",
|
|
45
|
+
description: "Save page as PDF",
|
|
46
|
+
inputSchema: pdfSchema,
|
|
47
|
+
type: "readOnly"
|
|
48
|
+
},
|
|
49
|
+
handle: async (tab, params, response) => {
|
|
50
|
+
const fileName = await tab.context.outputFile(params.filename ?? `page-${(/* @__PURE__ */ new Date()).toISOString()}.pdf`);
|
|
51
|
+
response.addCode(`await page.pdf(${javascript.formatObject({ path: fileName })});`);
|
|
52
|
+
response.addResult(`Saved page as ${fileName}`);
|
|
53
|
+
await tab.page.pdf({ path: fileName });
|
|
44
54
|
}
|
|
45
|
-
}
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
callTool
|
|
49
55
|
});
|
|
56
|
+
var pdf_default = [
|
|
57
|
+
pdf
|
|
58
|
+
];
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var screenshot_exports = {};
|
|
30
|
+
__export(screenshot_exports, {
|
|
31
|
+
default: () => screenshot_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(screenshot_exports);
|
|
34
|
+
var import_bundle = require("../../sdk/bundle");
|
|
35
|
+
var import_tool = require("./tool");
|
|
36
|
+
var javascript = __toESM(require("../codegen"));
|
|
37
|
+
var import_utils = require("./utils");
|
|
38
|
+
const screenshotSchema = import_bundle.z.object({
|
|
39
|
+
type: import_bundle.z.enum(["png", "jpeg"]).default("png").describe("Image format for the screenshot. Default is png."),
|
|
40
|
+
filename: import_bundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified."),
|
|
41
|
+
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."),
|
|
42
|
+
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."),
|
|
43
|
+
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.")
|
|
44
|
+
}).refine((data) => {
|
|
45
|
+
return !!data.element === !!data.ref;
|
|
46
|
+
}, {
|
|
47
|
+
message: "Both element and ref must be provided or neither.",
|
|
48
|
+
path: ["ref", "element"]
|
|
49
|
+
}).refine((data) => {
|
|
50
|
+
return !(data.fullPage && (data.element || data.ref));
|
|
51
|
+
}, {
|
|
52
|
+
message: "fullPage cannot be used with element screenshots.",
|
|
53
|
+
path: ["fullPage"]
|
|
54
|
+
});
|
|
55
|
+
const screenshot = (0, import_tool.defineTabTool)({
|
|
56
|
+
capability: "core",
|
|
57
|
+
schema: {
|
|
58
|
+
name: "browser_take_screenshot",
|
|
59
|
+
title: "Take a screenshot",
|
|
60
|
+
description: `Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.`,
|
|
61
|
+
inputSchema: screenshotSchema,
|
|
62
|
+
type: "readOnly"
|
|
63
|
+
},
|
|
64
|
+
handle: async (tab, params, response) => {
|
|
65
|
+
const fileType = params.type || "png";
|
|
66
|
+
const fileName = await tab.context.outputFile(params.filename ?? `page-${(/* @__PURE__ */ new Date()).toISOString()}.${fileType}`);
|
|
67
|
+
const options = {
|
|
68
|
+
type: fileType,
|
|
69
|
+
quality: fileType === "png" ? void 0 : 90,
|
|
70
|
+
scale: "css",
|
|
71
|
+
path: fileName,
|
|
72
|
+
...params.fullPage !== void 0 && { fullPage: params.fullPage }
|
|
73
|
+
};
|
|
74
|
+
const isElementScreenshot = params.element && params.ref;
|
|
75
|
+
const screenshotTarget = isElementScreenshot ? params.element : params.fullPage ? "full page" : "viewport";
|
|
76
|
+
response.addCode(`// Screenshot ${screenshotTarget} and save it as ${fileName}`);
|
|
77
|
+
const locator = params.ref ? await tab.refLocator({ element: params.element || "", ref: params.ref }) : null;
|
|
78
|
+
if (locator)
|
|
79
|
+
response.addCode(`await page.${await (0, import_utils.generateLocator)(locator)}.screenshot(${javascript.formatObject(options)});`);
|
|
80
|
+
else
|
|
81
|
+
response.addCode(`await page.screenshot(${javascript.formatObject(options)});`);
|
|
82
|
+
const buffer = locator ? await locator.screenshot(options) : await tab.page.screenshot(options);
|
|
83
|
+
response.addResult(`Took the ${screenshotTarget} screenshot and saved it as ${fileName}`);
|
|
84
|
+
if (!params.fullPage) {
|
|
85
|
+
response.addImage({
|
|
86
|
+
contentType: fileType === "png" ? "image/png" : "image/jpeg",
|
|
87
|
+
data: buffer
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
var screenshot_default = [
|
|
93
|
+
screenshot
|
|
94
|
+
];
|