@cotestdev/mcp_playwright 0.0.44 → 0.0.45
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/lib/mcp/browser/tools/runCode.js +2 -23
- package/lib/mcp/cli.js +8 -5
- package/package.json +1 -1
|
@@ -33,7 +33,6 @@ __export(runCode_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(runCode_exports);
|
|
34
34
|
var import_vm = __toESM(require("vm"));
|
|
35
35
|
var import_utils = require("playwright-core/lib/utils");
|
|
36
|
-
var import_test = require("playwright/test");
|
|
37
36
|
var import_mcpBundle = require("../../../mcpBundle");
|
|
38
37
|
var import_ai_runner_fake = require("@cotestdev/ai-runner-fake");
|
|
39
38
|
var import_tool = require("./tool");
|
|
@@ -91,30 +90,10 @@ const runScript = (0, import_tool.defineTabTool)({
|
|
|
91
90
|
},
|
|
92
91
|
handle: async (tab, params, response) => {
|
|
93
92
|
response.setIncludeSnapshot();
|
|
94
|
-
const __end__ = new import_utils.ManualPromise();
|
|
95
93
|
const runner = import_ai_runner_fake.Runner.NewInstance(params.projectId, params.testId);
|
|
96
94
|
await runner.init(tab.page, tab.page.content(), params.params);
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
context: tab.page.context(),
|
|
100
|
-
expect: import_test.expect,
|
|
101
|
-
runner,
|
|
102
|
-
__end__
|
|
103
|
-
};
|
|
104
|
-
import_vm.default.createContext(context);
|
|
105
|
-
await tab.waitForCompletion(async () => {
|
|
106
|
-
const snippet = `(async () => {
|
|
107
|
-
try {
|
|
108
|
-
const result = await (${params.code})(page);
|
|
109
|
-
__end__.resolve(JSON.stringify(result));
|
|
110
|
-
} catch (e) {
|
|
111
|
-
__end__.reject(e);
|
|
112
|
-
}
|
|
113
|
-
})()`;
|
|
114
|
-
await import_vm.default.runInContext(snippet, context);
|
|
115
|
-
await __end__;
|
|
116
|
-
response.addTextResult(`Out Parameters: ${JSON.stringify(runner.getAll())}`);
|
|
117
|
-
});
|
|
95
|
+
const result = await runner.runScript(params.testId, params.code);
|
|
96
|
+
response.addTextResult(`Out Parameters: ${JSON.stringify(result)}`);
|
|
118
97
|
}
|
|
119
98
|
});
|
|
120
99
|
var runCode_default = [
|
package/lib/mcp/cli.js
CHANGED
|
@@ -12,14 +12,17 @@ try {
|
|
|
12
12
|
process.exit(1);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
// If so, treat it as direct MCP server invocation
|
|
15
|
+
// Default to mcp-server command if no command is specified
|
|
17
16
|
const args = process.argv.slice(2);
|
|
18
17
|
const firstArg = args[0];
|
|
19
|
-
const isDirectOption = firstArg && (firstArg.startsWith('--') || firstArg === '-h' || firstArg === '--help');
|
|
20
18
|
|
|
21
|
-
//
|
|
22
|
-
|
|
19
|
+
// Check if first argument is a help/version flag (global options that should not add mcp-server)
|
|
20
|
+
const isHelpOrVersion = firstArg && (firstArg === '-h' || firstArg === '--help' || firstArg === '-V' || firstArg === '--version');
|
|
21
|
+
|
|
22
|
+
// Add 'mcp-server' if no args, or if first arg is an option (but not help/version)
|
|
23
|
+
const shouldAddMcpServer = !firstArg || (firstArg.startsWith('-') && !isHelpOrVersion);
|
|
24
|
+
|
|
25
|
+
if (shouldAddMcpServer) {
|
|
23
26
|
process.argv.splice(2, 0, 'mcp-server');
|
|
24
27
|
}
|
|
25
28
|
|