@szymonrybczak/playwright-mcp 0.0.2 → 0.0.4
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/index.d.ts +21 -8
- package/lib/cjs/_virtual/_commonjsHelpers.js +9 -0
- package/lib/cjs/_virtual/browser.js +11 -0
- package/lib/cjs/_virtual/browser2.js +7 -0
- package/lib/cjs/cloudflare/package.json.js +10 -0
- package/lib/cjs/index.js +28 -0
- package/lib/cjs/node_modules/debug/src/browser.js +290 -0
- package/lib/cjs/node_modules/debug/src/common.js +307 -0
- package/lib/cjs/node_modules/ms/index.js +176 -0
- package/lib/cjs/package.js +9 -0
- package/lib/cjs/src/browserContextFactory.js +240 -0
- package/lib/cjs/src/config.js +77 -0
- package/lib/cjs/src/connection.js +74 -0
- package/lib/cjs/src/context.js +281 -0
- package/lib/cjs/src/fileUtils.js +25 -0
- package/lib/cjs/src/index.js +15 -0
- package/lib/cjs/src/javascript.js +41 -0
- package/lib/cjs/src/manualPromise.js +39 -0
- package/lib/cjs/src/pageSnapshot.js +35 -0
- package/lib/cjs/src/tab.js +91 -0
- package/lib/cjs/src/tools/common.js +60 -0
- package/lib/cjs/src/tools/console.js +36 -0
- package/lib/cjs/src/tools/dialogs.js +44 -0
- package/lib/cjs/src/tools/files.js +43 -0
- package/lib/cjs/src/tools/install.js +49 -0
- package/lib/cjs/src/tools/keyboard.js +38 -0
- package/lib/cjs/src/tools/navigate.js +85 -0
- package/lib/cjs/src/tools/network.js +43 -0
- package/lib/cjs/src/tools/pdf.js +42 -0
- package/lib/cjs/src/tools/screenshot.js +69 -0
- package/lib/cjs/src/tools/snapshot.js +195 -0
- package/lib/cjs/src/tools/tabs.js +110 -0
- package/lib/cjs/src/tools/testing.js +52 -0
- package/lib/cjs/src/tools/tool.js +9 -0
- package/lib/cjs/src/tools/utils.js +75 -0
- package/lib/cjs/src/tools/vision.js +181 -0
- package/lib/cjs/src/tools/wait.js +51 -0
- package/lib/cjs/src/tools.js +54 -0
- package/lib/esm/_virtual/_commonjsHelpers.js +5 -0
- package/lib/esm/_virtual/browser.js +7 -0
- package/lib/esm/_virtual/browser2.js +3 -0
- package/lib/esm/cloudflare/package.json.js +5 -0
- package/lib/esm/index.js +24 -0
- package/lib/esm/node_modules/debug/src/browser.js +286 -0
- package/lib/esm/node_modules/debug/src/common.js +303 -0
- package/lib/esm/node_modules/ms/index.js +172 -0
- package/lib/esm/package.js +5 -0
- package/lib/esm/src/browserContextFactory.js +216 -0
- package/lib/esm/src/config.js +72 -0
- package/lib/esm/src/connection.js +69 -0
- package/lib/esm/src/context.js +277 -0
- package/lib/esm/src/fileUtils.js +20 -0
- package/lib/esm/src/index.js +11 -0
- package/lib/esm/src/javascript.js +35 -0
- package/lib/esm/src/manualPromise.js +35 -0
- package/lib/esm/src/pageSnapshot.js +31 -0
- package/lib/esm/src/tab.js +87 -0
- package/lib/esm/src/tools/common.js +56 -0
- package/lib/esm/src/tools/console.js +32 -0
- package/lib/esm/src/tools/dialogs.js +40 -0
- package/lib/esm/src/tools/files.js +39 -0
- package/lib/esm/src/tools/install.js +45 -0
- package/lib/esm/src/tools/keyboard.js +34 -0
- package/lib/esm/src/tools/navigate.js +81 -0
- package/lib/esm/src/tools/network.js +39 -0
- package/lib/esm/src/tools/pdf.js +38 -0
- package/lib/esm/src/tools/screenshot.js +65 -0
- package/lib/esm/src/tools/snapshot.js +191 -0
- package/lib/esm/src/tools/tabs.js +106 -0
- package/lib/esm/src/tools/testing.js +48 -0
- package/lib/esm/src/tools/tool.js +5 -0
- package/lib/esm/src/tools/utils.js +68 -0
- package/lib/esm/src/tools/vision.js +177 -0
- package/lib/esm/src/tools/wait.js +47 -0
- package/lib/esm/src/tools.js +49 -0
- package/package.json +15 -44
- package/LICENSE +0 -202
- package/README.md +0 -508
- package/cli.js +0 -18
- package/config.d.ts +0 -128
- package/index.js +0 -19
- package/lib/browserContextFactory.js +0 -227
- package/lib/browserServer.js +0 -151
- package/lib/config.js +0 -189
- package/lib/connection.js +0 -82
- package/lib/context.js +0 -291
- package/lib/fileUtils.js +0 -32
- package/lib/httpServer.js +0 -201
- package/lib/index.js +0 -36
- package/lib/javascript.js +0 -49
- package/lib/manualPromise.js +0 -111
- package/lib/package.js +0 -20
- package/lib/pageSnapshot.js +0 -43
- package/lib/program.js +0 -72
- package/lib/server.js +0 -48
- package/lib/tab.js +0 -101
- package/lib/tools/common.js +0 -68
- package/lib/tools/console.js +0 -44
- package/lib/tools/dialogs.js +0 -52
- package/lib/tools/files.js +0 -51
- package/lib/tools/install.js +0 -57
- package/lib/tools/keyboard.js +0 -46
- package/lib/tools/navigate.js +0 -93
- package/lib/tools/network.js +0 -51
- package/lib/tools/pdf.js +0 -49
- package/lib/tools/screenshot.js +0 -77
- package/lib/tools/snapshot.js +0 -204
- package/lib/tools/tabs.js +0 -118
- package/lib/tools/testing.js +0 -60
- package/lib/tools/tool.js +0 -18
- package/lib/tools/utils.js +0 -80
- package/lib/tools/vision.js +0 -189
- package/lib/tools/wait.js +0 -59
- package/lib/tools.js +0 -61
- package/lib/transport.js +0 -133
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const zod = require('zod');
|
|
6
|
+
const tool = require('./tool.js');
|
|
7
|
+
|
|
8
|
+
const generateTestSchema = zod.z.object({
|
|
9
|
+
name: zod.z.string().describe("The name of the test"),
|
|
10
|
+
description: zod.z.string().describe("The description of the test"),
|
|
11
|
+
steps: zod.z.array(zod.z.string()).describe("The steps of the test")
|
|
12
|
+
});
|
|
13
|
+
const generateTest = tool.defineTool({
|
|
14
|
+
capability: "testing",
|
|
15
|
+
schema: {
|
|
16
|
+
name: "browser_generate_playwright_test",
|
|
17
|
+
title: "Generate a Playwright test",
|
|
18
|
+
description: "Generate a Playwright test for given scenario",
|
|
19
|
+
inputSchema: generateTestSchema,
|
|
20
|
+
type: "readOnly"
|
|
21
|
+
},
|
|
22
|
+
handle: async (context, params) => {
|
|
23
|
+
return {
|
|
24
|
+
resultOverride: {
|
|
25
|
+
content: [{
|
|
26
|
+
type: "text",
|
|
27
|
+
text: instructions(params)
|
|
28
|
+
}]
|
|
29
|
+
},
|
|
30
|
+
code: [],
|
|
31
|
+
captureSnapshot: false,
|
|
32
|
+
waitForNetwork: false
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const instructions = (params) => [
|
|
37
|
+
`## Instructions`,
|
|
38
|
+
`- You are a playwright test generator.`,
|
|
39
|
+
`- You are given a scenario and you need to generate a playwright test for it.`,
|
|
40
|
+
"- DO NOT generate test code based on the scenario alone. DO run steps one by one using the tools provided instead.",
|
|
41
|
+
"- Only after all steps are completed, emit a Playwright TypeScript test that uses @playwright/test based on message history",
|
|
42
|
+
"- Save generated test file in the tests directory",
|
|
43
|
+
`Test name: ${params.name}`,
|
|
44
|
+
`Description: ${params.description}`,
|
|
45
|
+
`Steps:`,
|
|
46
|
+
...params.steps.map((step, index) => `- ${index + 1}. ${step}`)
|
|
47
|
+
].join("\n");
|
|
48
|
+
const testing = [
|
|
49
|
+
generateTest
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
exports.default = testing;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
async function waitForCompletion(context, tab, callback) {
|
|
6
|
+
const requests = /* @__PURE__ */ new Set();
|
|
7
|
+
let frameNavigated = false;
|
|
8
|
+
let waitCallback = () => {
|
|
9
|
+
};
|
|
10
|
+
const waitBarrier = new Promise((f) => {
|
|
11
|
+
waitCallback = f;
|
|
12
|
+
});
|
|
13
|
+
const requestListener = (request) => requests.add(request);
|
|
14
|
+
const requestFinishedListener = (request) => {
|
|
15
|
+
requests.delete(request);
|
|
16
|
+
if (!requests.size)
|
|
17
|
+
waitCallback();
|
|
18
|
+
};
|
|
19
|
+
const frameNavigateListener = (frame) => {
|
|
20
|
+
if (frame.parentFrame())
|
|
21
|
+
return;
|
|
22
|
+
frameNavigated = true;
|
|
23
|
+
dispose();
|
|
24
|
+
clearTimeout(timeout);
|
|
25
|
+
void tab.waitForLoadState("load").then(waitCallback);
|
|
26
|
+
};
|
|
27
|
+
const onTimeout = () => {
|
|
28
|
+
dispose();
|
|
29
|
+
waitCallback();
|
|
30
|
+
};
|
|
31
|
+
tab.page.on("request", requestListener);
|
|
32
|
+
tab.page.on("requestfinished", requestFinishedListener);
|
|
33
|
+
tab.page.on("framenavigated", frameNavigateListener);
|
|
34
|
+
const timeout = setTimeout(onTimeout, 1e4);
|
|
35
|
+
const dispose = () => {
|
|
36
|
+
tab.page.off("request", requestListener);
|
|
37
|
+
tab.page.off("requestfinished", requestFinishedListener);
|
|
38
|
+
tab.page.off("framenavigated", frameNavigateListener);
|
|
39
|
+
clearTimeout(timeout);
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
const result = await callback();
|
|
43
|
+
if (!requests.size && !frameNavigated)
|
|
44
|
+
waitCallback();
|
|
45
|
+
await waitBarrier;
|
|
46
|
+
await context.waitForTimeout(1e3);
|
|
47
|
+
return result;
|
|
48
|
+
} finally {
|
|
49
|
+
dispose();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function sanitizeForFilePath(s) {
|
|
53
|
+
const sanitize = (s2) => s2.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, "-");
|
|
54
|
+
const separator = s.lastIndexOf(".");
|
|
55
|
+
if (separator === -1)
|
|
56
|
+
return sanitize(s);
|
|
57
|
+
return sanitize(s.substring(0, separator)) + "." + sanitize(s.substring(separator + 1));
|
|
58
|
+
}
|
|
59
|
+
async function generateLocator(locator) {
|
|
60
|
+
try {
|
|
61
|
+
return await locator._generateLocatorString();
|
|
62
|
+
} catch (e) {
|
|
63
|
+
if (e instanceof Error && /locator._generateLocatorString: No element matching locator/.test(e.message))
|
|
64
|
+
throw new Error("Ref not found, likely because element was removed. Use browser_snapshot to see what elements are currently on the page.");
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function callOnPageNoTrace(page, callback) {
|
|
69
|
+
return await page._wrapApiCall(() => callback(page), { internal: true });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
exports.callOnPageNoTrace = callOnPageNoTrace;
|
|
73
|
+
exports.generateLocator = generateLocator;
|
|
74
|
+
exports.sanitizeForFilePath = sanitizeForFilePath;
|
|
75
|
+
exports.waitForCompletion = waitForCompletion;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const zod = require('zod');
|
|
6
|
+
const tool = require('./tool.js');
|
|
7
|
+
const javascript = require('../javascript.js');
|
|
8
|
+
|
|
9
|
+
const elementSchema = zod.z.object({
|
|
10
|
+
element: zod.z.string().describe("Human-readable element description used to obtain permission to interact with the element")
|
|
11
|
+
});
|
|
12
|
+
const screenshot = tool.defineTool({
|
|
13
|
+
capability: "core",
|
|
14
|
+
schema: {
|
|
15
|
+
name: "browser_screen_capture",
|
|
16
|
+
title: "Take a screenshot",
|
|
17
|
+
description: "Take a screenshot of the current page",
|
|
18
|
+
inputSchema: zod.z.object({}),
|
|
19
|
+
type: "readOnly"
|
|
20
|
+
},
|
|
21
|
+
handle: async (context) => {
|
|
22
|
+
const tab = await context.ensureTab();
|
|
23
|
+
const options = { type: "jpeg", quality: 50, scale: "css" };
|
|
24
|
+
const code = [
|
|
25
|
+
`// Take a screenshot of the current page`,
|
|
26
|
+
`await page.screenshot(${javascript.formatObject(options)});`
|
|
27
|
+
];
|
|
28
|
+
const action = () => tab.page.screenshot(options).then((buffer) => {
|
|
29
|
+
return {
|
|
30
|
+
content: [{ type: "image", data: buffer.toString("base64"), mimeType: "image/jpeg" }]
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
code,
|
|
35
|
+
action,
|
|
36
|
+
captureSnapshot: false,
|
|
37
|
+
waitForNetwork: false
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const moveMouse = tool.defineTool({
|
|
42
|
+
capability: "core",
|
|
43
|
+
schema: {
|
|
44
|
+
name: "browser_screen_move_mouse",
|
|
45
|
+
title: "Move mouse",
|
|
46
|
+
description: "Move mouse to a given position",
|
|
47
|
+
inputSchema: elementSchema.extend({
|
|
48
|
+
x: zod.z.coerce.number().describe("X coordinate"),
|
|
49
|
+
y: zod.z.coerce.number().describe("Y coordinate")
|
|
50
|
+
}),
|
|
51
|
+
type: "readOnly"
|
|
52
|
+
},
|
|
53
|
+
handle: async (context, params) => {
|
|
54
|
+
const tab = context.currentTabOrDie();
|
|
55
|
+
const code = [
|
|
56
|
+
`// Move mouse to (${params.x}, ${params.y})`,
|
|
57
|
+
`await page.mouse.move(${params.x}, ${params.y});`
|
|
58
|
+
];
|
|
59
|
+
const action = () => tab.page.mouse.move(params.x, params.y);
|
|
60
|
+
return {
|
|
61
|
+
code,
|
|
62
|
+
action,
|
|
63
|
+
captureSnapshot: false,
|
|
64
|
+
waitForNetwork: false
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const click = tool.defineTool({
|
|
69
|
+
capability: "core",
|
|
70
|
+
schema: {
|
|
71
|
+
name: "browser_screen_click",
|
|
72
|
+
title: "Click",
|
|
73
|
+
description: "Click left mouse button",
|
|
74
|
+
inputSchema: elementSchema.extend({
|
|
75
|
+
x: zod.z.coerce.number().describe("X coordinate"),
|
|
76
|
+
y: zod.z.coerce.number().describe("Y coordinate")
|
|
77
|
+
}),
|
|
78
|
+
type: "destructive"
|
|
79
|
+
},
|
|
80
|
+
handle: async (context, params) => {
|
|
81
|
+
const tab = context.currentTabOrDie();
|
|
82
|
+
const code = [
|
|
83
|
+
`// Click mouse at coordinates (${params.x}, ${params.y})`,
|
|
84
|
+
`await page.mouse.move(${params.x}, ${params.y});`,
|
|
85
|
+
`await page.mouse.down();`,
|
|
86
|
+
`await page.mouse.up();`
|
|
87
|
+
];
|
|
88
|
+
const action = async () => {
|
|
89
|
+
await tab.page.mouse.move(params.x, params.y);
|
|
90
|
+
await tab.page.mouse.down();
|
|
91
|
+
await tab.page.mouse.up();
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
code,
|
|
95
|
+
action,
|
|
96
|
+
captureSnapshot: false,
|
|
97
|
+
waitForNetwork: true
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const drag = tool.defineTool({
|
|
102
|
+
capability: "core",
|
|
103
|
+
schema: {
|
|
104
|
+
name: "browser_screen_drag",
|
|
105
|
+
title: "Drag mouse",
|
|
106
|
+
description: "Drag left mouse button",
|
|
107
|
+
inputSchema: elementSchema.extend({
|
|
108
|
+
startX: zod.z.coerce.number().describe("Start X coordinate"),
|
|
109
|
+
startY: zod.z.coerce.number().describe("Start Y coordinate"),
|
|
110
|
+
endX: zod.z.coerce.number().describe("End X coordinate"),
|
|
111
|
+
endY: zod.z.coerce.number().describe("End Y coordinate")
|
|
112
|
+
}),
|
|
113
|
+
type: "destructive"
|
|
114
|
+
},
|
|
115
|
+
handle: async (context, params) => {
|
|
116
|
+
const tab = context.currentTabOrDie();
|
|
117
|
+
const code = [
|
|
118
|
+
`// Drag mouse from (${params.startX}, ${params.startY}) to (${params.endX}, ${params.endY})`,
|
|
119
|
+
`await page.mouse.move(${params.startX}, ${params.startY});`,
|
|
120
|
+
`await page.mouse.down();`,
|
|
121
|
+
`await page.mouse.move(${params.endX}, ${params.endY});`,
|
|
122
|
+
`await page.mouse.up();`
|
|
123
|
+
];
|
|
124
|
+
const action = async () => {
|
|
125
|
+
await tab.page.mouse.move(params.startX, params.startY);
|
|
126
|
+
await tab.page.mouse.down();
|
|
127
|
+
await tab.page.mouse.move(params.endX, params.endY);
|
|
128
|
+
await tab.page.mouse.up();
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
code,
|
|
132
|
+
action,
|
|
133
|
+
captureSnapshot: false,
|
|
134
|
+
waitForNetwork: true
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const type = tool.defineTool({
|
|
139
|
+
capability: "core",
|
|
140
|
+
schema: {
|
|
141
|
+
name: "browser_screen_type",
|
|
142
|
+
title: "Type text",
|
|
143
|
+
description: "Type text",
|
|
144
|
+
inputSchema: zod.z.object({
|
|
145
|
+
text: zod.z.string().describe("Text to type into the element"),
|
|
146
|
+
submit: zod.z.coerce.boolean().optional().describe("Whether to submit entered text (press Enter after)")
|
|
147
|
+
}),
|
|
148
|
+
type: "destructive"
|
|
149
|
+
},
|
|
150
|
+
handle: async (context, params) => {
|
|
151
|
+
const tab = context.currentTabOrDie();
|
|
152
|
+
const code = [
|
|
153
|
+
`// Type ${params.text}`,
|
|
154
|
+
`await page.keyboard.type('${params.text}');`
|
|
155
|
+
];
|
|
156
|
+
const action = async () => {
|
|
157
|
+
await tab.page.keyboard.type(params.text);
|
|
158
|
+
if (params.submit)
|
|
159
|
+
await tab.page.keyboard.press("Enter");
|
|
160
|
+
};
|
|
161
|
+
if (params.submit) {
|
|
162
|
+
code.push(`// Submit text`);
|
|
163
|
+
code.push(`await page.keyboard.press('Enter');`);
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
code,
|
|
167
|
+
action,
|
|
168
|
+
captureSnapshot: false,
|
|
169
|
+
waitForNetwork: true
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
const vision = [
|
|
174
|
+
screenshot,
|
|
175
|
+
moveMouse,
|
|
176
|
+
click,
|
|
177
|
+
drag,
|
|
178
|
+
type
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
exports.default = vision;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const zod = require('zod');
|
|
6
|
+
const tool = require('./tool.js');
|
|
7
|
+
|
|
8
|
+
const wait = (captureSnapshot) => tool.defineTool({
|
|
9
|
+
capability: "wait",
|
|
10
|
+
schema: {
|
|
11
|
+
name: "browser_wait_for",
|
|
12
|
+
title: "Wait for",
|
|
13
|
+
description: "Wait for text to appear or disappear or a specified time to pass",
|
|
14
|
+
inputSchema: zod.z.object({
|
|
15
|
+
time: zod.z.coerce.number().optional().describe("The time to wait in seconds"),
|
|
16
|
+
text: zod.z.string().optional().describe("The text to wait for"),
|
|
17
|
+
textGone: zod.z.string().optional().describe("The text to wait for to disappear")
|
|
18
|
+
}),
|
|
19
|
+
type: "readOnly"
|
|
20
|
+
},
|
|
21
|
+
handle: async (context, params) => {
|
|
22
|
+
if (!params.text && !params.textGone && !params.time)
|
|
23
|
+
throw new Error("Either time, text or textGone must be provided");
|
|
24
|
+
const code = [];
|
|
25
|
+
if (params.time) {
|
|
26
|
+
code.push(`await new Promise(f => setTimeout(f, ${params.time} * 1000));`);
|
|
27
|
+
await new Promise((f) => setTimeout(f, Math.min(1e4, params.time * 1e3)));
|
|
28
|
+
}
|
|
29
|
+
const tab = context.currentTabOrDie();
|
|
30
|
+
const locator = params.text ? tab.page.getByText(params.text).first() : void 0;
|
|
31
|
+
const goneLocator = params.textGone ? tab.page.getByText(params.textGone).first() : void 0;
|
|
32
|
+
if (goneLocator) {
|
|
33
|
+
code.push(`await page.getByText(${JSON.stringify(params.textGone)}).first().waitFor({ state: 'hidden' });`);
|
|
34
|
+
await goneLocator.waitFor({ state: "hidden" });
|
|
35
|
+
}
|
|
36
|
+
if (locator) {
|
|
37
|
+
code.push(`await page.getByText(${JSON.stringify(params.text)}).first().waitFor({ state: 'visible' });`);
|
|
38
|
+
await locator.waitFor({ state: "visible" });
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
code,
|
|
42
|
+
captureSnapshot,
|
|
43
|
+
waitForNetwork: false
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const wait$1 = (captureSnapshot) => [
|
|
48
|
+
wait(captureSnapshot)
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
exports.default = wait$1;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const common = require('./tools/common.js');
|
|
6
|
+
const console = require('./tools/console.js');
|
|
7
|
+
const dialogs = require('./tools/dialogs.js');
|
|
8
|
+
const files = require('./tools/files.js');
|
|
9
|
+
const install = require('./tools/install.js');
|
|
10
|
+
const keyboard = require('./tools/keyboard.js');
|
|
11
|
+
const navigate = require('./tools/navigate.js');
|
|
12
|
+
const network = require('./tools/network.js');
|
|
13
|
+
const pdf = require('./tools/pdf.js');
|
|
14
|
+
const snapshot = require('./tools/snapshot.js');
|
|
15
|
+
const tabs = require('./tools/tabs.js');
|
|
16
|
+
const screenshot = require('./tools/screenshot.js');
|
|
17
|
+
const testing = require('./tools/testing.js');
|
|
18
|
+
const vision = require('./tools/vision.js');
|
|
19
|
+
const wait = require('./tools/wait.js');
|
|
20
|
+
|
|
21
|
+
const snapshotTools = [
|
|
22
|
+
...common.default(true),
|
|
23
|
+
...console.default,
|
|
24
|
+
...dialogs.default(true),
|
|
25
|
+
...files.default(true),
|
|
26
|
+
...install.default,
|
|
27
|
+
...keyboard.default(true),
|
|
28
|
+
...navigate.default(true),
|
|
29
|
+
...network.default,
|
|
30
|
+
...pdf.default,
|
|
31
|
+
...screenshot.default,
|
|
32
|
+
...snapshot.default,
|
|
33
|
+
...tabs.default(true),
|
|
34
|
+
...testing.default,
|
|
35
|
+
...wait.default(true)
|
|
36
|
+
];
|
|
37
|
+
const visionTools = [
|
|
38
|
+
...common.default(false),
|
|
39
|
+
...console.default,
|
|
40
|
+
...dialogs.default(false),
|
|
41
|
+
...files.default(false),
|
|
42
|
+
...install.default,
|
|
43
|
+
...keyboard.default(false),
|
|
44
|
+
...navigate.default(false),
|
|
45
|
+
...network.default,
|
|
46
|
+
...pdf.default,
|
|
47
|
+
...tabs.default(false),
|
|
48
|
+
...testing.default,
|
|
49
|
+
...vision.default,
|
|
50
|
+
...wait.default(false)
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
exports.snapshotTools = snapshotTools;
|
|
54
|
+
exports.visionTools = visionTools;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
|
|
2
|
+
import { __require as requireBrowser } from '../node_modules/debug/src/browser.js';
|
|
3
|
+
|
|
4
|
+
var browserExports = requireBrowser();
|
|
5
|
+
const debug = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
|
|
6
|
+
|
|
7
|
+
export { debug as default };
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { McpAgent } from 'agents/mcp';
|
|
2
|
+
import { endpointURLString } from '@szymonrybczak/patchright';
|
|
3
|
+
import { createConnection } from './src/index.js';
|
|
4
|
+
|
|
5
|
+
function createMcpAgent(endpoint, options) {
|
|
6
|
+
const cdpEndpoint = typeof endpoint === "string" ? endpoint : endpoint instanceof URL ? endpoint.toString() : endpointURLString(endpoint);
|
|
7
|
+
const connection = createConnection({
|
|
8
|
+
capabilities: ["core", "tabs", "pdf", "history", "wait", "files", "testing"],
|
|
9
|
+
browser: {
|
|
10
|
+
cdpEndpoint
|
|
11
|
+
},
|
|
12
|
+
...options
|
|
13
|
+
});
|
|
14
|
+
return class PlaywrightMcpAgent extends McpAgent {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.server = connection.then((server) => server.server);
|
|
18
|
+
}
|
|
19
|
+
async init() {
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { createMcpAgent };
|