rae-playwright-mcp 0.0.1 → 0.0.2
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 +63 -21
- package/cli.js +7 -3
- package/index.js +1 -1
- package/lib/common/config.js +282 -0
- package/lib/common/config.js.map +7 -0
- package/lib/common/configLoader.js +345 -0
- package/lib/common/configLoader.js.map +7 -0
- package/lib/common/esmLoaderHost.js +105 -0
- package/lib/common/esmLoaderHost.js.map +7 -0
- package/lib/common/expectBundle.js +44 -0
- package/lib/common/expectBundle.js.map +7 -0
- package/lib/common/expectBundleImpl.js +15781 -0
- package/lib/common/expectBundleImpl.js.map +7 -0
- package/lib/common/fixtures.js +303 -0
- package/lib/common/fixtures.js.map +7 -0
- package/lib/common/globals.js +59 -0
- package/lib/common/globals.js.map +7 -0
- package/lib/common/ipc.js +61 -0
- package/lib/common/ipc.js.map +7 -0
- package/lib/common/poolBuilder.js +86 -0
- package/lib/common/poolBuilder.js.map +7 -0
- package/lib/common/process.js +133 -0
- package/lib/common/process.js.map +7 -0
- package/lib/common/suiteUtils.js +141 -0
- package/lib/common/suiteUtils.js.map +7 -0
- package/lib/common/test.js +323 -0
- package/lib/common/test.js.map +7 -0
- package/lib/common/testLoader.js +102 -0
- package/lib/common/testLoader.js.map +7 -0
- package/lib/common/testType.js +299 -0
- package/lib/common/testType.js.map +7 -0
- package/lib/common/validators.js +69 -0
- package/lib/common/validators.js.map +7 -0
- package/lib/mcp/browser/actions.d.js +17 -0
- package/lib/mcp/browser/actions.d.js.map +7 -0
- package/lib/mcp/browser/browserContextFactory.js +343 -0
- package/lib/mcp/browser/browserContextFactory.js.map +7 -0
- package/lib/mcp/browser/browserServerBackend.js +78 -0
- package/lib/mcp/browser/browserServerBackend.js.map +7 -0
- package/lib/mcp/browser/config.js +421 -0
- package/lib/mcp/browser/config.js.map +7 -0
- package/lib/mcp/browser/context.js +287 -0
- package/lib/mcp/browser/context.js.map +7 -0
- package/lib/mcp/browser/response.js +353 -0
- package/lib/mcp/browser/response.js.map +7 -0
- package/lib/mcp/browser/sessionLog.js +161 -0
- package/lib/mcp/browser/sessionLog.js.map +7 -0
- package/lib/mcp/browser/tab.js +329 -0
- package/lib/mcp/browser/tab.js.map +7 -0
- package/lib/mcp/browser/tools/common.js +64 -0
- package/lib/mcp/browser/tools/common.js.map +7 -0
- package/lib/mcp/browser/tools/console.js +45 -0
- package/lib/mcp/browser/tools/console.js.map +7 -0
- package/lib/mcp/browser/tools/dialogs.js +61 -0
- package/lib/mcp/browser/tools/dialogs.js.map +7 -0
- package/lib/mcp/browser/tools/evaluate.js +60 -0
- package/lib/mcp/browser/tools/evaluate.js.map +7 -0
- package/lib/mcp/browser/tools/files.js +59 -0
- package/lib/mcp/browser/tools/files.js.map +7 -0
- package/lib/mcp/browser/tools/form.js +64 -0
- package/lib/mcp/browser/tools/form.js.map +7 -0
- package/lib/mcp/browser/tools/install.js +70 -0
- package/lib/mcp/browser/tools/install.js.map +7 -0
- package/lib/mcp/browser/tools/keyboard.js +85 -0
- package/lib/mcp/browser/tools/keyboard.js.map +7 -0
- package/lib/mcp/browser/tools/mouse.js +108 -0
- package/lib/mcp/browser/tools/mouse.js.map +7 -0
- package/lib/mcp/browser/tools/navigate.js +63 -0
- package/lib/mcp/browser/tools/navigate.js.map +7 -0
- package/lib/mcp/browser/tools/network.js +61 -0
- package/lib/mcp/browser/tools/network.js.map +7 -0
- package/lib/mcp/browser/tools/pdf.js +49 -0
- package/lib/mcp/browser/tools/pdf.js.map +7 -0
- package/lib/mcp/browser/tools/runCode.js +78 -0
- package/lib/mcp/browser/tools/runCode.js.map +7 -0
- package/lib/mcp/browser/tools/screenshot.js +106 -0
- package/lib/mcp/browser/tools/screenshot.js.map +7 -0
- package/lib/mcp/browser/tools/snapshot.js +192 -0
- package/lib/mcp/browser/tools/snapshot.js.map +7 -0
- package/lib/mcp/browser/tools/tabs.js +68 -0
- package/lib/mcp/browser/tools/tabs.js.map +7 -0
- package/lib/mcp/browser/tools/tool.js +51 -0
- package/lib/mcp/browser/tools/tool.js.map +7 -0
- package/lib/mcp/browser/tools/tracing.js +76 -0
- package/lib/mcp/browser/tools/tracing.js.map +7 -0
- package/lib/mcp/browser/tools/utils.js +95 -0
- package/lib/mcp/browser/tools/utils.js.map +7 -0
- package/lib/mcp/browser/tools/verify.js +144 -0
- package/lib/mcp/browser/tools/verify.js.map +7 -0
- package/lib/mcp/browser/tools/wait.js +64 -0
- package/lib/mcp/browser/tools/wait.js.map +7 -0
- package/lib/mcp/browser/tools.js +83 -0
- package/lib/mcp/browser/tools.js.map +7 -0
- package/lib/mcp/browser/watchdog.js +45 -0
- package/lib/mcp/browser/watchdog.js.map +7 -0
- package/lib/mcp/config.d.js +17 -0
- package/lib/mcp/config.d.js.map +7 -0
- package/lib/mcp/config.d.ts +197 -0
- package/lib/mcp/extension/cdpRelay.js +352 -0
- package/lib/mcp/extension/cdpRelay.js.map +7 -0
- package/lib/mcp/extension/extensionContextFactory.js +77 -0
- package/lib/mcp/extension/extensionContextFactory.js.map +7 -0
- package/lib/mcp/extension/protocol.js +29 -0
- package/lib/mcp/extension/protocol.js.map +7 -0
- package/lib/mcp/index.js +62 -0
- package/lib/mcp/index.js.map +7 -0
- package/lib/mcp/log.js +36 -0
- package/lib/mcp/log.js.map +7 -0
- package/lib/mcp/program.js +94 -0
- package/lib/mcp/program.js.map +7 -0
- package/lib/mcp/sdk/exports.js +29 -0
- package/lib/mcp/sdk/exports.js.map +7 -0
- package/lib/mcp/sdk/http.js +153 -0
- package/lib/mcp/sdk/http.js.map +7 -0
- package/lib/mcp/sdk/inProcessTransport.js +72 -0
- package/lib/mcp/sdk/inProcessTransport.js.map +7 -0
- package/lib/mcp/sdk/server.js +208 -0
- package/lib/mcp/sdk/server.js.map +7 -0
- package/lib/mcp/sdk/tool.js +48 -0
- package/lib/mcp/sdk/tool.js.map +7 -0
- package/lib/mcp/test/browserBackend.js +99 -0
- package/lib/mcp/test/browserBackend.js.map +7 -0
- package/lib/mcp/test/generatorTools.js +123 -0
- package/lib/mcp/test/generatorTools.js.map +7 -0
- package/lib/mcp/test/plannerTools.js +145 -0
- package/lib/mcp/test/plannerTools.js.map +7 -0
- package/lib/mcp/test/seed.js +83 -0
- package/lib/mcp/test/seed.js.map +7 -0
- package/lib/mcp/test/streams.js +45 -0
- package/lib/mcp/test/streams.js.map +7 -0
- package/lib/mcp/test/testBackend.js +100 -0
- package/lib/mcp/test/testBackend.js.map +7 -0
- package/lib/mcp/test/testContext.js +280 -0
- package/lib/mcp/test/testContext.js.map +7 -0
- package/lib/mcp/test/testTool.js +31 -0
- package/lib/mcp/test/testTool.js.map +7 -0
- package/lib/mcp/test/testTools.js +109 -0
- package/lib/mcp/test/testTools.js.map +7 -0
- package/lib/third_party/pirates.js +63 -0
- package/lib/third_party/pirates.js.map +7 -0
- package/lib/third_party/tsconfig-loader.js +104 -0
- package/lib/third_party/tsconfig-loader.js.map +7 -0
- package/lib/transform/babelBundle.js +44 -0
- package/lib/transform/babelBundle.js.map +7 -0
- package/lib/transform/babelBundleImpl.js +68726 -0
- package/lib/transform/babelBundleImpl.js.map +7 -0
- package/lib/transform/babelHighlightUtils.js +64 -0
- package/lib/transform/babelHighlightUtils.js.map +7 -0
- package/lib/transform/compilationCache.js +273 -0
- package/lib/transform/compilationCache.js.map +7 -0
- package/lib/transform/esmLoader.js +104 -0
- package/lib/transform/esmLoader.js.map +7 -0
- package/lib/transform/portTransport.js +68 -0
- package/lib/transform/portTransport.js.map +7 -0
- package/lib/transform/transform.js +297 -0
- package/lib/transform/transform.js.map +7 -0
- package/lib/util.js +404 -0
- package/lib/utilsBundle.js +44 -0
- package/lib/utilsBundleImpl.js +13122 -0
- package/package.json +4 -3
|
@@ -0,0 +1,145 @@
|
|
|
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 plannerTools_exports = {};
|
|
30
|
+
__export(plannerTools_exports, {
|
|
31
|
+
saveTestPlan: () => saveTestPlan,
|
|
32
|
+
setupPage: () => setupPage,
|
|
33
|
+
submitTestPlan: () => submitTestPlan
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(plannerTools_exports);
|
|
36
|
+
var import_fs = __toESM(require("fs"));
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
39
|
+
var import_testTool = require("./testTool");
|
|
40
|
+
const setupPage = (0, import_testTool.defineTestTool)({
|
|
41
|
+
schema: {
|
|
42
|
+
name: "planner_setup_page",
|
|
43
|
+
title: "Setup planner page",
|
|
44
|
+
description: "Setup the page for test planning",
|
|
45
|
+
inputSchema: import_mcpBundle.z.object({
|
|
46
|
+
project: import_mcpBundle.z.string().optional().describe('Project to use for setup. For example: "chromium", if no project is provided uses the first project in the config.'),
|
|
47
|
+
seedFile: import_mcpBundle.z.string().optional().describe('A seed file contains a single test that is used to setup the page for testing, for example: "tests/seed.spec.ts". If no seed file is provided, a default seed file is created.')
|
|
48
|
+
}),
|
|
49
|
+
type: "readOnly"
|
|
50
|
+
},
|
|
51
|
+
handle: async (context, params) => {
|
|
52
|
+
const seed = await context.getOrCreateSeedFile(params.seedFile, params.project);
|
|
53
|
+
const { output, status } = await context.runSeedTest(seed.file, seed.projectName);
|
|
54
|
+
return { content: [{ type: "text", text: output }], isError: status !== "paused" };
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const planSchema = import_mcpBundle.z.object({
|
|
58
|
+
overview: import_mcpBundle.z.string().describe("A brief overview of the application to be tested"),
|
|
59
|
+
suites: import_mcpBundle.z.array(import_mcpBundle.z.object({
|
|
60
|
+
name: import_mcpBundle.z.string().describe("The name of the suite"),
|
|
61
|
+
seedFile: import_mcpBundle.z.string().describe("A seed file that was used to setup the page for testing."),
|
|
62
|
+
tests: import_mcpBundle.z.array(import_mcpBundle.z.object({
|
|
63
|
+
name: import_mcpBundle.z.string().describe("The name of the test"),
|
|
64
|
+
file: import_mcpBundle.z.string().describe('The file the test should be saved to, for example: "tests/<suite-name>/<test-name>.spec.ts".'),
|
|
65
|
+
steps: import_mcpBundle.z.array(import_mcpBundle.z.string().describe(`The steps to be executed to perform the test. For example: 'Click on the "Submit" button'`)),
|
|
66
|
+
expectedResults: import_mcpBundle.z.array(import_mcpBundle.z.string().describe("The expected results of the steps for test to verify."))
|
|
67
|
+
}))
|
|
68
|
+
}))
|
|
69
|
+
});
|
|
70
|
+
const submitTestPlan = (0, import_testTool.defineTestTool)({
|
|
71
|
+
schema: {
|
|
72
|
+
name: "planner_submit_plan",
|
|
73
|
+
title: "Submit test plan",
|
|
74
|
+
description: "Submit the test plan to the test planner",
|
|
75
|
+
inputSchema: planSchema,
|
|
76
|
+
type: "readOnly"
|
|
77
|
+
},
|
|
78
|
+
handle: async (context, params) => {
|
|
79
|
+
return {
|
|
80
|
+
content: [{
|
|
81
|
+
type: "text",
|
|
82
|
+
text: JSON.stringify(params, null, 2)
|
|
83
|
+
}]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const saveTestPlan = (0, import_testTool.defineTestTool)({
|
|
88
|
+
schema: {
|
|
89
|
+
name: "planner_save_plan",
|
|
90
|
+
title: "Save test plan as markdown file",
|
|
91
|
+
description: "Save the test plan as a markdown file",
|
|
92
|
+
inputSchema: planSchema.extend({
|
|
93
|
+
name: import_mcpBundle.z.string().describe('The name of the test plan, for example: "Test Plan".'),
|
|
94
|
+
fileName: import_mcpBundle.z.string().describe('The file to save the test plan to, for example: "spec/test.plan.md". Relative to the workspace root.')
|
|
95
|
+
}),
|
|
96
|
+
type: "readOnly"
|
|
97
|
+
},
|
|
98
|
+
handle: async (context, params) => {
|
|
99
|
+
const lines = [];
|
|
100
|
+
lines.push(`# ${params.name}`);
|
|
101
|
+
lines.push(``);
|
|
102
|
+
lines.push(`## Application Overview`);
|
|
103
|
+
lines.push(``);
|
|
104
|
+
lines.push(params.overview);
|
|
105
|
+
lines.push(``);
|
|
106
|
+
lines.push(`## Test Scenarios`);
|
|
107
|
+
for (let i = 0; i < params.suites.length; i++) {
|
|
108
|
+
lines.push(``);
|
|
109
|
+
const suite = params.suites[i];
|
|
110
|
+
lines.push(`### ${i + 1}. ${suite.name}`);
|
|
111
|
+
lines.push(``);
|
|
112
|
+
lines.push(`**Seed:** \`${suite.seedFile}\``);
|
|
113
|
+
for (let j = 0; j < suite.tests.length; j++) {
|
|
114
|
+
lines.push(``);
|
|
115
|
+
const test = suite.tests[j];
|
|
116
|
+
lines.push(`#### ${i + 1}.${j + 1}. ${test.name}`);
|
|
117
|
+
lines.push(``);
|
|
118
|
+
lines.push(`**File:** \`${test.file}\``);
|
|
119
|
+
lines.push(``);
|
|
120
|
+
lines.push(`**Steps:**`);
|
|
121
|
+
for (let k = 0; k < test.steps.length; k++)
|
|
122
|
+
lines.push(` ${k + 1}. ${test.steps[k]}`);
|
|
123
|
+
lines.push(``);
|
|
124
|
+
lines.push(`**Expected Results:**`);
|
|
125
|
+
for (const result of test.expectedResults)
|
|
126
|
+
lines.push(` - ${result}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
lines.push(``);
|
|
130
|
+
await import_fs.default.promises.writeFile(import_path.default.resolve(context.rootPath, params.fileName), lines.join("\n"));
|
|
131
|
+
return {
|
|
132
|
+
content: [{
|
|
133
|
+
type: "text",
|
|
134
|
+
text: `Test plan saved to ${params.fileName}`
|
|
135
|
+
}]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
140
|
+
0 && (module.exports = {
|
|
141
|
+
saveTestPlan,
|
|
142
|
+
setupPage,
|
|
143
|
+
submitTestPlan
|
|
144
|
+
});
|
|
145
|
+
//# sourceMappingURL=plannerTools.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/test/plannerTools.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { z } from 'playwright-core/lib/mcpBundle';\nimport { defineTestTool } from './testTool';\n\nexport const setupPage = defineTestTool({\n schema: {\n name: 'planner_setup_page',\n title: 'Setup planner page',\n description: 'Setup the page for test planning',\n inputSchema: z.object({\n project: z.string().optional().describe('Project to use for setup. For example: \"chromium\", if no project is provided uses the first project in the config.'),\n seedFile: z.string().optional().describe('A seed file contains a single test that is used to setup the page for testing, for example: \"tests/seed.spec.ts\". If no seed file is provided, a default seed file is created.'),\n }),\n type: 'readOnly',\n },\n\n handle: async (context, params) => {\n const seed = await context.getOrCreateSeedFile(params.seedFile, params.project);\n const { output, status } = await context.runSeedTest(seed.file, seed.projectName);\n return { content: [{ type: 'text', text: output }], isError: status !== 'paused' };\n },\n});\n\nconst planSchema = z.object({\n overview: z.string().describe('A brief overview of the application to be tested'),\n suites: z.array(z.object({\n name: z.string().describe('The name of the suite'),\n seedFile: z.string().describe('A seed file that was used to setup the page for testing.'),\n tests: z.array(z.object({\n name: z.string().describe('The name of the test'),\n file: z.string().describe('The file the test should be saved to, for example: \"tests/<suite-name>/<test-name>.spec.ts\".'),\n steps: z.array(z.string().describe(`The steps to be executed to perform the test. For example: 'Click on the \"Submit\" button'`)),\n expectedResults: z.array(z.string().describe('The expected results of the steps for test to verify.')),\n })),\n })),\n});\n\nexport const submitTestPlan = defineTestTool({\n schema: {\n name: 'planner_submit_plan',\n title: 'Submit test plan',\n description: 'Submit the test plan to the test planner',\n inputSchema: planSchema,\n type: 'readOnly',\n },\n\n handle: async (context, params) => {\n return {\n content: [{\n type: 'text',\n text: JSON.stringify(params, null, 2),\n }],\n };\n },\n});\n\nexport const saveTestPlan = defineTestTool({\n schema: {\n name: 'planner_save_plan',\n title: 'Save test plan as markdown file',\n description: 'Save the test plan as a markdown file',\n inputSchema: planSchema.extend({\n name: z.string().describe('The name of the test plan, for example: \"Test Plan\".'),\n fileName: z.string().describe('The file to save the test plan to, for example: \"spec/test.plan.md\". Relative to the workspace root.'),\n }),\n type: 'readOnly',\n },\n\n handle: async (context, params) => {\n const lines: string[] = [];\n lines.push(`# ${params.name}`);\n lines.push(``);\n lines.push(`## Application Overview`);\n lines.push(``);\n lines.push(params.overview);\n lines.push(``);\n lines.push(`## Test Scenarios`);\n for (let i = 0; i < params.suites.length; i++) {\n lines.push(``);\n const suite = params.suites[i];\n lines.push(`### ${i + 1}. ${suite.name}`);\n lines.push(``);\n lines.push(`**Seed:** \\`${suite.seedFile}\\``);\n for (let j = 0; j < suite.tests.length; j++) {\n lines.push(``);\n const test = suite.tests[j];\n lines.push(`#### ${i + 1}.${j + 1}. ${test.name}`);\n lines.push(``);\n lines.push(`**File:** \\`${test.file}\\``);\n lines.push(``);\n lines.push(`**Steps:**`);\n for (let k = 0; k < test.steps.length; k++)\n lines.push(` ${k + 1}. ${test.steps[k]}`);\n lines.push(``);\n lines.push(`**Expected Results:**`);\n for (const result of test.expectedResults)\n lines.push(` - ${result}`);\n }\n }\n lines.push(``);\n await fs.promises.writeFile(path.resolve(context.rootPath, params.fileName), lines.join('\\n'));\n return {\n content: [{\n type: 'text',\n text: `Test plan saved to ${params.fileName}`,\n }],\n };\n },\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,gBAAe;AACf,kBAAiB;AAEjB,uBAAkB;AAClB,sBAA+B;AAExB,MAAM,gBAAY,gCAAe;AAAA,EACtC,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,IACb,aAAa,mBAAE,OAAO;AAAA,MACpB,SAAS,mBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,oHAAoH;AAAA,MAC5J,UAAU,mBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gLAAgL;AAAA,IAC3N,CAAC;AAAA,IACD,M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AAE;AACb,cAAM,KAAK,uBAAuB;AAClC,mBAAW,UAAU,KAAK;AACxB,gBAAM,KAAK,OAAO,MAAM,EAAE;AAAA,MAC9B;AAAA,IACF;AACA,UAAM,KAAK,EAAE;AACb,UAAM,UAAAA,QAAG,SAAS,UAAU,YAAAC,QAAK,QAAQ,QAAQ,UAAU,OAAO,QAAQ,GAAG,MAAM,KAAK,IAAI,CAAC;AAC7F,WAAO;AAAA,MACL,SAAS,CAAC;AAAA,QACR,MAAM;AAAA,QACN,MAAM,sBAAsB,OAAO,QAAQ;AAAA,MAC7C,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;",
|
|
6
|
+
"names": ["fs", "path"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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 seed_exports = {};
|
|
30
|
+
__export(seed_exports, {
|
|
31
|
+
defaultSeedFile: () => defaultSeedFile,
|
|
32
|
+
ensureSeedFile: () => ensureSeedFile,
|
|
33
|
+
findSeedFile: () => findSeedFile,
|
|
34
|
+
seedFileContent: () => seedFileContent,
|
|
35
|
+
seedProject: () => seedProject
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(seed_exports);
|
|
38
|
+
var import_fs = __toESM(require("fs"));
|
|
39
|
+
var import_path = __toESM(require("path"));
|
|
40
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
41
|
+
var import_projectUtils = require("../../runner/projectUtils");
|
|
42
|
+
function seedProject(config, projectName) {
|
|
43
|
+
if (!projectName)
|
|
44
|
+
return (0, import_projectUtils.findTopLevelProjects)(config)[0];
|
|
45
|
+
const project = config.projects.find((p) => p.project.name === projectName);
|
|
46
|
+
if (!project)
|
|
47
|
+
throw new Error(`Project ${projectName} not found`);
|
|
48
|
+
return project;
|
|
49
|
+
}
|
|
50
|
+
async function findSeedFile(project) {
|
|
51
|
+
const files = await (0, import_projectUtils.collectFilesForProject)(project);
|
|
52
|
+
return files.find((file) => import_path.default.basename(file).includes("seed"));
|
|
53
|
+
}
|
|
54
|
+
function defaultSeedFile(project) {
|
|
55
|
+
const testDir = project.project.testDir;
|
|
56
|
+
return import_path.default.resolve(testDir, "seed.spec.ts");
|
|
57
|
+
}
|
|
58
|
+
async function ensureSeedFile(project) {
|
|
59
|
+
const seedFile = await findSeedFile(project);
|
|
60
|
+
if (seedFile)
|
|
61
|
+
return seedFile;
|
|
62
|
+
const seedFilePath = defaultSeedFile(project);
|
|
63
|
+
await (0, import_utils.mkdirIfNeeded)(seedFilePath);
|
|
64
|
+
await import_fs.default.promises.writeFile(seedFilePath, seedFileContent);
|
|
65
|
+
return seedFilePath;
|
|
66
|
+
}
|
|
67
|
+
const seedFileContent = `import { test, expect } from '@playwright/test';
|
|
68
|
+
|
|
69
|
+
test.describe('Test group', () => {
|
|
70
|
+
test('seed', async ({ page }) => {
|
|
71
|
+
// generate code here.
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
`;
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
defaultSeedFile,
|
|
78
|
+
ensureSeedFile,
|
|
79
|
+
findSeedFile,
|
|
80
|
+
seedFileContent,
|
|
81
|
+
seedProject
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=seed.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/test/seed.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { mkdirIfNeeded } from 'playwright-core/lib/utils';\nimport { collectFilesForProject, findTopLevelProjects } from '../../runner/projectUtils';\n\nimport type { FullConfigInternal, FullProjectInternal } from '../../common/config';\n\nexport function seedProject(config: FullConfigInternal, projectName?: string) {\n if (!projectName)\n return findTopLevelProjects(config)[0];\n const project = config.projects.find(p => p.project.name === projectName);\n if (!project)\n throw new Error(`Project ${projectName} not found`);\n return project;\n}\n\nexport async function findSeedFile(project: FullProjectInternal) {\n const files = await collectFilesForProject(project);\n return files.find(file => path.basename(file).includes('seed'));\n}\n\nexport function defaultSeedFile(project: FullProjectInternal) {\n const testDir = project.project.testDir;\n return path.resolve(testDir, 'seed.spec.ts');\n}\n\nexport async function ensureSeedFile(project: FullProjectInternal) {\n const seedFile = await findSeedFile(project);\n if (seedFile)\n return seedFile;\n const seedFilePath = defaultSeedFile(project);\n await mkdirIfNeeded(seedFilePath);\n await fs.promises.writeFile(seedFilePath, seedFileContent);\n return seedFilePath;\n}\n\nexport const seedFileContent = `import { test, expect } from '@playwright/test';\n\ntest.describe('Test group', () => {\n test('seed', async ({ page }) => {\n // generate code here.\n });\n});\n`;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,gBAAe;AACf,kBAAiB;AAEjB,mBAA8B;AAC9B,0BAA6D;AAItD,SAAS,YAAY,QAA4B,aAAsB;AAC5E,MAAI,CAAC;AACH,eAAO,0CAAqB,MAAM,EAAE,CAAC;AACvC,QAAM,UAAU,OAAO,SAAS,KAAK,OAAK,EAAE,QAAQ,SAAS,WAAW;AACxE,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,WAAW,WAAW,YAAY;AACpD,SAAO;AACT;AAEA,eAAsB,aAAa,SAA8B;AAC/D,QAAM,QAAQ,UAAM,4CAAuB,OAAO;AAClD,SAAO,MAAM,KAAK,UAAQ,YAAAA,QAAK,SAAS,IAAI,EAAE,SAAS,MAAM,CAAC;AAChE;AAEO,SAAS,gBAAgB,SAA8B;AAC5D,QAAM,UAAU,QAAQ,QAAQ;AAChC,SAAO,YAAAA,QAAK,QAAQ,SAAS,cAAc;AAC7C;AAEA,eAAsB,eAAe,SAA8B;AACjE,QAAM,WAAW,MAAM,aAAa,OAAO;AAC3C,MAAI;AACF,WAAO;AACT,QAAM,eAAe,gBAAgB,OAAO;AAC5C,YAAM,4BAAc,YAAY;AAChC,QAAM,UAAAC,QAAG,SAAS,UAAU,cAAc,eAAe;AACzD,SAAO;AACT;AAEO,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": ["path", "fs"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 streams_exports = {};
|
|
20
|
+
__export(streams_exports, {
|
|
21
|
+
StringWriteStream: () => StringWriteStream
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(streams_exports);
|
|
24
|
+
var import_stream = require("stream");
|
|
25
|
+
var import_util = require("../../util");
|
|
26
|
+
class StringWriteStream extends import_stream.Writable {
|
|
27
|
+
constructor(output, stdio) {
|
|
28
|
+
super();
|
|
29
|
+
this._output = output;
|
|
30
|
+
this._prefix = stdio === "stdout" ? "" : "[err] ";
|
|
31
|
+
}
|
|
32
|
+
_write(chunk, encoding, callback) {
|
|
33
|
+
let text = (0, import_util.stripAnsiEscapes)(chunk.toString());
|
|
34
|
+
if (text.endsWith("\n"))
|
|
35
|
+
text = text.slice(0, -1);
|
|
36
|
+
if (text)
|
|
37
|
+
this._output.push(this._prefix + text);
|
|
38
|
+
callback();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
StringWriteStream
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=streams.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/test/streams.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Writable } from 'stream';\n\nimport { stripAnsiEscapes } from '../../util';\n\nexport class StringWriteStream extends Writable {\n private _output: string[];\n private _prefix: string;\n\n constructor(output: string[], stdio: 'stdout' | 'stderr') {\n super();\n this._output = output;\n this._prefix = stdio === 'stdout' ? '' : '[err] ';\n }\n\n override _write(chunk: any, encoding: any, callback: any) {\n let text = stripAnsiEscapes(chunk.toString());\n if (text.endsWith('\\n'))\n text = text.slice(0, -1);\n if (text)\n this._output.push(this._prefix + text);\n callback();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,oBAAyB;AAEzB,kBAAiC;AAE1B,MAAM,0BAA0B,uBAAS;AAAA,EAI9C,YAAY,QAAkB,OAA4B;AACxD,UAAM;AACN,SAAK,UAAU;AACf,SAAK,UAAU,UAAU,WAAW,KAAK;AAAA,EAC3C;AAAA,EAES,OAAO,OAAY,UAAe,UAAe;AACxD,QAAI,WAAO,8BAAiB,MAAM,SAAS,CAAC;AAC5C,QAAI,KAAK,SAAS,IAAI;AACpB,aAAO,KAAK,MAAM,GAAG,EAAE;AACzB,QAAI;AACF,WAAK,QAAQ,KAAK,KAAK,UAAU,IAAI;AACvC,aAAS;AAAA,EACX;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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 testBackend_exports = {};
|
|
30
|
+
__export(testBackend_exports, {
|
|
31
|
+
TestServerBackend: () => TestServerBackend
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(testBackend_exports);
|
|
34
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
35
|
+
var mcp = __toESM(require("../sdk/exports"));
|
|
36
|
+
var import_testContext = require("./testContext");
|
|
37
|
+
var testTools = __toESM(require("./testTools.js"));
|
|
38
|
+
var generatorTools = __toESM(require("./generatorTools.js"));
|
|
39
|
+
var plannerTools = __toESM(require("./plannerTools.js"));
|
|
40
|
+
var import_tools = require("../browser/tools");
|
|
41
|
+
class TestServerBackend {
|
|
42
|
+
constructor(configPath, options) {
|
|
43
|
+
this.name = "Playwright";
|
|
44
|
+
this.version = "0.0.1";
|
|
45
|
+
this._tools = [
|
|
46
|
+
plannerTools.saveTestPlan,
|
|
47
|
+
plannerTools.setupPage,
|
|
48
|
+
plannerTools.submitTestPlan,
|
|
49
|
+
generatorTools.setupPage,
|
|
50
|
+
generatorTools.generatorReadLog,
|
|
51
|
+
generatorTools.generatorWriteTest,
|
|
52
|
+
testTools.listTests,
|
|
53
|
+
testTools.runTests,
|
|
54
|
+
testTools.debugTest,
|
|
55
|
+
...import_tools.browserTools.map((tool) => wrapBrowserTool(tool))
|
|
56
|
+
];
|
|
57
|
+
this._options = options || {};
|
|
58
|
+
this._configPath = configPath;
|
|
59
|
+
}
|
|
60
|
+
async initialize(clientInfo) {
|
|
61
|
+
this._context = new import_testContext.TestContext(clientInfo, this._configPath, this._options);
|
|
62
|
+
}
|
|
63
|
+
async listTools() {
|
|
64
|
+
return this._tools.map((tool) => mcp.toMcpTool(tool.schema));
|
|
65
|
+
}
|
|
66
|
+
async callTool(name, args) {
|
|
67
|
+
const tool = this._tools.find((tool2) => tool2.schema.name === name);
|
|
68
|
+
if (!tool)
|
|
69
|
+
throw new Error(`Tool not found: ${name}. Available tools: ${this._tools.map((tool2) => tool2.schema.name).join(", ")}`);
|
|
70
|
+
try {
|
|
71
|
+
return await tool.handle(this._context, tool.schema.inputSchema.parse(args || {}));
|
|
72
|
+
} catch (e) {
|
|
73
|
+
return { content: [{ type: "text", text: String(e) }], isError: true };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
serverClosed() {
|
|
77
|
+
void this._context?.close();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const typesWithIntent = ["action", "assertion", "input"];
|
|
81
|
+
function wrapBrowserTool(tool) {
|
|
82
|
+
const inputSchema = typesWithIntent.includes(tool.schema.type) ? tool.schema.inputSchema.extend({
|
|
83
|
+
intent: import_mcpBundle.z.string().describe("The intent of the call, for example the test step description plan idea")
|
|
84
|
+
}) : tool.schema.inputSchema;
|
|
85
|
+
return {
|
|
86
|
+
schema: {
|
|
87
|
+
...tool.schema,
|
|
88
|
+
inputSchema
|
|
89
|
+
},
|
|
90
|
+
handle: async (context, params) => {
|
|
91
|
+
const response = await context.sendMessageToPausedTest({ callTool: { name: tool.schema.name, arguments: params } });
|
|
92
|
+
return response.callTool;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
TestServerBackend
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=testBackend.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/test/testBackend.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { z as zod } from 'playwright-core/lib/mcpBundle';\n\nimport * as mcp from '../sdk/exports';\nimport { TestContext } from './testContext';\nimport * as testTools from './testTools.js';\nimport * as generatorTools from './generatorTools.js';\nimport * as plannerTools from './plannerTools.js';\nimport { browserTools } from '../browser/tools';\n\nimport type { TestTool } from './testTool';\nimport type { Tool as BrowserTool } from '../browser/tools/tool';\n\nexport class TestServerBackend implements mcp.ServerBackend {\n readonly name = 'Playwright';\n readonly version = '0.0.1';\n private _tools: TestTool<any>[] = [\n plannerTools.saveTestPlan,\n plannerTools.setupPage,\n plannerTools.submitTestPlan,\n generatorTools.setupPage,\n generatorTools.generatorReadLog,\n generatorTools.generatorWriteTest,\n testTools.listTests,\n testTools.runTests,\n testTools.debugTest,\n ...browserTools.map(tool => wrapBrowserTool(tool)),\n ];\n private _options: { muteConsole?: boolean, headless?: boolean };\n private _context: TestContext | undefined;\n private _configPath: string | undefined;\n\n constructor(configPath: string | undefined, options?: { muteConsole?: boolean, headless?: boolean }) {\n this._options = options || {};\n this._configPath = configPath;\n }\n\n async initialize(clientInfo: mcp.ClientInfo): Promise<void> {\n this._context = new TestContext(clientInfo, this._configPath, this._options);\n }\n\n async listTools(): Promise<mcp.Tool[]> {\n return this._tools.map(tool => mcp.toMcpTool(tool.schema));\n }\n\n async callTool(name: string, args: mcp.CallToolRequest['params']['arguments']): Promise<mcp.CallToolResult> {\n const tool = this._tools.find(tool => tool.schema.name === name);\n if (!tool)\n throw new Error(`Tool not found: ${name}. Available tools: ${this._tools.map(tool => tool.schema.name).join(', ')}`);\n try {\n return await tool.handle(this._context!, tool.schema.inputSchema.parse(args || {}));\n } catch (e) {\n return { content: [{ type: 'text', text: String(e) }], isError: true };\n }\n }\n\n serverClosed() {\n void this._context?.close();\n }\n}\n\nconst typesWithIntent = ['action', 'assertion', 'input'];\n\nfunction wrapBrowserTool(tool: BrowserTool): TestTool {\n const inputSchema = typesWithIntent.includes(tool.schema.type) ? (tool.schema.inputSchema as any).extend({\n intent: zod.string().describe('The intent of the call, for example the test step description plan idea')\n }) : tool.schema.inputSchema;\n return {\n schema: {\n ...tool.schema,\n inputSchema,\n },\n handle: async (context: TestContext, params: any) => {\n const response = await context.sendMessageToPausedTest({ callTool: { name: tool.schema.name, arguments: params } });\n return response.callTool!;\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,uBAAyB;AAEzB,UAAqB;AACrB,yBAA4B;AAC5B,gBAA2B;AAC3B,qBAAgC;AAChC,mBAA8B;AAC9B,mBAA6B;AAKtB,MAAM,kBAA+C;AAAA,EAmB1D,YAAY,YAAgC,SAAyD;AAlBrG,SAAS,OAAO;AAChB,SAAS,UAAU;AACnB,SAAQ,SAA0B;AAAA,MAChC,aAAa;AAAA,MACb,aAAa;AAAA,MACb,aAAa;AAAA,MACb,eAAe;AAAA,MACf,eAAe;AAAA,MACf,eAAe;AAAA,MACf,UAAU;AAAA,MACV,UAAU;AAAA,MACV,UAAU;AAAA,MACV,GAAG,0BAAa,IAAI,UAAQ,gBAAgB,IAAI,CAAC;AAAA,IACnD;AAME,SAAK,WAAW,WAAW,CAAC;AAC5B,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,WAAW,YAA2C;AAC1D,SAAK,WAAW,IAAI,+BAAY,YAAY,KAAK,aAAa,KAAK,QAAQ;AAAA,EAC7E;AAAA,EAEA,MAAM,YAAiC;AACrC,WAAO,KAAK,OAAO,IAAI,UAAQ,I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