|
f7eb47b…
|
lmata
|
1 |
"use strict"; |
|
f7eb47b…
|
lmata
|
2 |
var __create = Object.create; |
|
f7eb47b…
|
lmata
|
3 |
var __defProp = Object.defineProperty; |
|
f7eb47b…
|
lmata
|
4 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
f7eb47b…
|
lmata
|
5 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
f7eb47b…
|
lmata
|
6 |
var __getProtoOf = Object.getPrototypeOf; |
|
f7eb47b…
|
lmata
|
7 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
f7eb47b…
|
lmata
|
8 |
var __export = (target, all) => { |
|
f7eb47b…
|
lmata
|
9 |
for (var name in all) |
|
f7eb47b…
|
lmata
|
10 |
__defProp(target, name, { get: all[name], enumerable: true }); |
|
f7eb47b…
|
lmata
|
11 |
}; |
|
f7eb47b…
|
lmata
|
12 |
var __copyProps = (to, from, except, desc) => { |
|
f7eb47b…
|
lmata
|
13 |
if (from && typeof from === "object" || typeof from === "function") { |
|
f7eb47b…
|
lmata
|
14 |
for (let key of __getOwnPropNames(from)) |
|
f7eb47b…
|
lmata
|
15 |
if (!__hasOwnProp.call(to, key) && key !== except) |
|
f7eb47b…
|
lmata
|
16 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
f7eb47b…
|
lmata
|
17 |
} |
|
f7eb47b…
|
lmata
|
18 |
return to; |
|
f7eb47b…
|
lmata
|
19 |
}; |
|
f7eb47b…
|
lmata
|
20 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
|
f7eb47b…
|
lmata
|
21 |
// If the importer is in node compatibility mode or this is not an ESM |
|
f7eb47b…
|
lmata
|
22 |
// file that has been converted to a CommonJS file using a Babel- |
|
f7eb47b…
|
lmata
|
23 |
// compatible transform (i.e. "__esModule" has not been set), then set |
|
f7eb47b…
|
lmata
|
24 |
// "default" to the CommonJS "module.exports" for node compatibility. |
|
f7eb47b…
|
lmata
|
25 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
|
f7eb47b…
|
lmata
|
26 |
mod |
|
f7eb47b…
|
lmata
|
27 |
)); |
|
f7eb47b…
|
lmata
|
28 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
f7eb47b…
|
lmata
|
29 |
var testBackend_exports = {}; |
|
f7eb47b…
|
lmata
|
30 |
__export(testBackend_exports, { |
|
f7eb47b…
|
lmata
|
31 |
TestServerBackend: () => TestServerBackend |
|
f7eb47b…
|
lmata
|
32 |
}); |
|
f7eb47b…
|
lmata
|
33 |
module.exports = __toCommonJS(testBackend_exports); |
|
f7eb47b…
|
lmata
|
34 |
var import_mcpBundle = require("playwright-core/lib/mcpBundle"); |
|
f7eb47b…
|
lmata
|
35 |
var mcp = __toESM(require("../sdk/exports")); |
|
f7eb47b…
|
lmata
|
36 |
var import_testContext = require("./testContext"); |
|
f7eb47b…
|
lmata
|
37 |
var testTools = __toESM(require("./testTools.js")); |
|
f7eb47b…
|
lmata
|
38 |
var generatorTools = __toESM(require("./generatorTools.js")); |
|
f7eb47b…
|
lmata
|
39 |
var plannerTools = __toESM(require("./plannerTools.js")); |
|
f7eb47b…
|
lmata
|
40 |
var import_tools = require("../browser/tools"); |
|
f7eb47b…
|
lmata
|
41 |
class TestServerBackend { |
|
f7eb47b…
|
lmata
|
42 |
constructor(configPath, options) { |
|
f7eb47b…
|
lmata
|
43 |
this.name = "Playwright"; |
|
f7eb47b…
|
lmata
|
44 |
this.version = "0.0.1"; |
|
f7eb47b…
|
lmata
|
45 |
this._tools = [ |
|
f7eb47b…
|
lmata
|
46 |
plannerTools.saveTestPlan, |
|
f7eb47b…
|
lmata
|
47 |
plannerTools.setupPage, |
|
f7eb47b…
|
lmata
|
48 |
plannerTools.submitTestPlan, |
|
f7eb47b…
|
lmata
|
49 |
generatorTools.setupPage, |
|
f7eb47b…
|
lmata
|
50 |
generatorTools.generatorReadLog, |
|
f7eb47b…
|
lmata
|
51 |
generatorTools.generatorWriteTest, |
|
f7eb47b…
|
lmata
|
52 |
testTools.listTests, |
|
f7eb47b…
|
lmata
|
53 |
testTools.runTests, |
|
f7eb47b…
|
lmata
|
54 |
testTools.debugTest, |
|
f7eb47b…
|
lmata
|
55 |
...import_tools.browserTools.map((tool) => wrapBrowserTool(tool)) |
|
f7eb47b…
|
lmata
|
56 |
]; |
|
f7eb47b…
|
lmata
|
57 |
this._options = options || {}; |
|
f7eb47b…
|
lmata
|
58 |
this._configPath = configPath; |
|
f7eb47b…
|
lmata
|
59 |
} |
|
f7eb47b…
|
lmata
|
60 |
async initialize(clientInfo) { |
|
f7eb47b…
|
lmata
|
61 |
this._context = new import_testContext.TestContext(clientInfo, this._configPath, this._options); |
|
f7eb47b…
|
lmata
|
62 |
} |
|
f7eb47b…
|
lmata
|
63 |
async listTools() { |
|
f7eb47b…
|
lmata
|
64 |
return this._tools.map((tool) => mcp.toMcpTool(tool.schema)); |
|
f7eb47b…
|
lmata
|
65 |
} |
|
f7eb47b…
|
lmata
|
66 |
async callTool(name, args) { |
|
f7eb47b…
|
lmata
|
67 |
const tool = this._tools.find((tool2) => tool2.schema.name === name); |
|
f7eb47b…
|
lmata
|
68 |
if (!tool) |
|
f7eb47b…
|
lmata
|
69 |
throw new Error(`Tool not found: ${name}. Available tools: ${this._tools.map((tool2) => tool2.schema.name).join(", ")}`); |
|
f7eb47b…
|
lmata
|
70 |
try { |
|
f7eb47b…
|
lmata
|
71 |
return await tool.handle(this._context, tool.schema.inputSchema.parse(args || {})); |
|
f7eb47b…
|
lmata
|
72 |
} catch (e) { |
|
f7eb47b…
|
lmata
|
73 |
return { content: [{ type: "text", text: String(e) }], isError: true }; |
|
f7eb47b…
|
lmata
|
74 |
} |
|
f7eb47b…
|
lmata
|
75 |
} |
|
f7eb47b…
|
lmata
|
76 |
serverClosed() { |
|
f7eb47b…
|
lmata
|
77 |
void this._context?.close(); |
|
f7eb47b…
|
lmata
|
78 |
} |
|
f7eb47b…
|
lmata
|
79 |
} |
|
f7eb47b…
|
lmata
|
80 |
const typesWithIntent = ["action", "assertion", "input"]; |
|
f7eb47b…
|
lmata
|
81 |
function wrapBrowserTool(tool) { |
|
f7eb47b…
|
lmata
|
82 |
const inputSchema = typesWithIntent.includes(tool.schema.type) ? tool.schema.inputSchema.extend({ |
|
f7eb47b…
|
lmata
|
83 |
intent: import_mcpBundle.z.string().describe("The intent of the call, for example the test step description plan idea") |
|
f7eb47b…
|
lmata
|
84 |
}) : tool.schema.inputSchema; |
|
f7eb47b…
|
lmata
|
85 |
return { |
|
f7eb47b…
|
lmata
|
86 |
schema: { |
|
f7eb47b…
|
lmata
|
87 |
...tool.schema, |
|
f7eb47b…
|
lmata
|
88 |
inputSchema |
|
f7eb47b…
|
lmata
|
89 |
}, |
|
f7eb47b…
|
lmata
|
90 |
handle: async (context, params) => { |
|
f7eb47b…
|
lmata
|
91 |
const response = await context.sendMessageToPausedTest({ callTool: { name: tool.schema.name, arguments: params } }); |
|
f7eb47b…
|
lmata
|
92 |
return response.callTool; |
|
f7eb47b…
|
lmata
|
93 |
} |
|
f7eb47b…
|
lmata
|
94 |
}; |
|
f7eb47b…
|
lmata
|
95 |
} |
|
f7eb47b…
|
lmata
|
96 |
// Annotate the CommonJS export names for ESM import in node: |
|
f7eb47b…
|
lmata
|
97 |
0 && (module.exports = { |
|
f7eb47b…
|
lmata
|
98 |
TestServerBackend |
|
f7eb47b…
|
lmata
|
99 |
}); |