Update npm packages (73 packages including @jqhtml 2.3.36)

Update npm registry domain from privatenpm.hanson.xyz to npm.internal.hanson.xyz

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2026-02-20 11:31:28 +00:00
parent d01a6179aa
commit b5eb27a827
1690 changed files with 47348 additions and 16848 deletions

296
node_modules/playwright/lib/mcp/terminal/cli.js generated vendored Normal file
View File

@@ -0,0 +1,296 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var import_child_process = require("child_process");
var import_crypto = __toESM(require("crypto"));
var import_fs = __toESM(require("fs"));
var import_net = __toESM(require("net"));
var import_os = __toESM(require("os"));
var import_path = __toESM(require("path"));
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_socketConnection = require("./socketConnection");
const debugCli = (0, import_utilsBundle.debug)("pw:cli");
const packageJSON = require("../../../package.json");
async function runCliCommand(sessionName, args) {
const session = await connectToDaemon(sessionName);
const result = await session.runCliCommand(args);
console.log(result);
session.dispose();
}
async function socketExists(socketPath) {
try {
const stat = await import_fs.default.promises.stat(socketPath);
if (stat?.isSocket())
return true;
} catch (e) {
}
return false;
}
class SocketSession {
constructor(connection) {
this._nextMessageId = 1;
this._callbacks = /* @__PURE__ */ new Map();
this._connection = connection;
this._connection.onmessage = (message) => this._onMessage(message);
this._connection.onclose = () => this.dispose();
}
async callTool(name, args) {
return this._send(name, args);
}
async runCliCommand(args) {
return await this._send("runCliCommand", { args });
}
async _send(method, params = {}) {
const messageId = this._nextMessageId++;
const message = {
id: messageId,
method,
params
};
await this._connection.send(message);
return new Promise((resolve, reject) => {
this._callbacks.set(messageId, { resolve, reject });
});
}
dispose() {
for (const callback of this._callbacks.values())
callback.reject(new Error("Disposed"));
this._callbacks.clear();
this._connection.close();
}
_onMessage(object) {
if (object.id && this._callbacks.has(object.id)) {
const callback = this._callbacks.get(object.id);
this._callbacks.delete(object.id);
if (object.error)
callback.reject(new Error(object.error));
else
callback.resolve(object.result);
} else if (object.id) {
throw new Error(`Unexpected message id: ${object.id}`);
} else {
throw new Error(`Unexpected message without id: ${JSON.stringify(object)}`);
}
}
}
function localCacheDir() {
if (process.platform === "linux")
return process.env.XDG_CACHE_HOME || import_path.default.join(import_os.default.homedir(), ".cache");
if (process.platform === "darwin")
return import_path.default.join(import_os.default.homedir(), "Library", "Caches");
if (process.platform === "win32")
return process.env.LOCALAPPDATA || import_path.default.join(import_os.default.homedir(), "AppData", "Local");
throw new Error("Unsupported platform: " + process.platform);
}
function playwrightCacheDir() {
return import_path.default.join(localCacheDir(), "ms-playwright");
}
function calculateSha1(buffer) {
const hash = import_crypto.default.createHash("sha1");
hash.update(buffer);
return hash.digest("hex");
}
function socketDirHash() {
return calculateSha1(__dirname);
}
function daemonSocketDir() {
return import_path.default.resolve(playwrightCacheDir(), "daemon", socketDirHash());
}
function daemonSocketPath(sessionName) {
const socketName = `${sessionName}.sock`;
if (import_os.default.platform() === "win32")
return `\\\\.\\pipe\\${socketDirHash()}-${socketName}`;
return import_path.default.resolve(daemonSocketDir(), socketName);
}
async function connectToDaemon(sessionName) {
const socketPath = daemonSocketPath(sessionName);
debugCli(`Connecting to daemon at ${socketPath}`);
if (await socketExists(socketPath)) {
debugCli(`Socket file exists, attempting to connect...`);
try {
return await connectToSocket(socketPath);
} catch (e) {
if (import_os.default.platform() !== "win32")
await import_fs.default.promises.unlink(socketPath).catch(() => {
});
}
}
const cliPath = import_path.default.join(__dirname, "../../../cli.js");
debugCli(`Will launch daemon process: ${cliPath}`);
const userDataDir = import_path.default.resolve(daemonSocketDir(), `${sessionName}-user-data`);
const child = (0, import_child_process.spawn)(process.execPath, [cliPath, "run-mcp-server", `--daemon=${socketPath}`, `--user-data-dir=${userDataDir}`], {
detached: true,
stdio: "ignore",
cwd: process.cwd()
// Will be used as root.
});
child.unref();
const maxRetries = 50;
const retryDelay = 100;
for (let i = 0; i < maxRetries; i++) {
await new Promise((resolve) => setTimeout(resolve, 100));
try {
return await connectToSocket(socketPath);
} catch (e) {
if (e.code !== "ENOENT")
throw e;
debugCli(`Retrying to connect to daemon at ${socketPath} (${i + 1}/${maxRetries})`);
}
}
throw new Error(`Failed to connect to daemon at ${socketPath} after ${maxRetries * retryDelay}ms`);
}
async function connectToSocket(socketPath) {
const socket = await new Promise((resolve, reject) => {
const socket2 = import_net.default.createConnection(socketPath, () => {
debugCli(`Connected to daemon at ${socketPath}`);
resolve(socket2);
});
socket2.on("error", reject);
});
return new SocketSession(new import_socketConnection.SocketConnection(socket));
}
function currentSessionPath() {
return import_path.default.resolve(daemonSocketDir(), "current-session");
}
async function getCurrentSession() {
try {
const session = await import_fs.default.promises.readFile(currentSessionPath(), "utf-8");
return session.trim() || "default";
} catch {
return "default";
}
}
async function setCurrentSession(sessionName) {
await import_fs.default.promises.mkdir(daemonSocketDir(), { recursive: true });
await import_fs.default.promises.writeFile(currentSessionPath(), sessionName);
}
async function canConnectToSocket(socketPath) {
return new Promise((resolve) => {
const socket = import_net.default.createConnection(socketPath, () => {
socket.destroy();
resolve(true);
});
socket.on("error", () => {
resolve(false);
});
});
}
async function listSessions() {
const dir = daemonSocketDir();
try {
const files = await import_fs.default.promises.readdir(dir);
const sessions = [];
for (const file of files) {
if (file.endsWith("-user-data")) {
const sessionName = file.slice(0, -"-user-data".length);
const socketPath = daemonSocketPath(sessionName);
const live = await canConnectToSocket(socketPath);
sessions.push({ name: sessionName, live });
}
}
return sessions;
} catch {
return [];
}
}
function resolveSessionName(args) {
if (args.session)
return args.session;
if (process.env.PLAYWRIGHT_CLI_SESSION)
return process.env.PLAYWRIGHT_CLI_SESSION;
return "default";
}
async function handleSessionCommand(args) {
const subcommand = args._[1];
if (!subcommand) {
const current = await getCurrentSession();
console.log(current);
return;
}
if (subcommand === "list") {
const sessions = await listSessions();
const current = await getCurrentSession();
console.log("Sessions:");
for (const session of sessions) {
const marker = session.name === current ? "->" : " ";
const liveMarker = session.live ? " (live)" : "";
console.log(`${marker} ${session.name}${liveMarker}`);
}
if (sessions.length === 0)
console.log(" (no sessions)");
return;
}
if (subcommand === "set") {
const sessionName = args._[2];
if (!sessionName) {
console.error("Usage: playwright-cli session set <session-name>");
process.exit(1);
}
await setCurrentSession(sessionName);
console.log(`Current session set to: ${sessionName}`);
return;
}
console.error(`Unknown session subcommand: ${subcommand}`);
process.exit(1);
}
async function main() {
const argv = process.argv.slice(2);
const args = require("minimist")(argv);
const help = require("./help.json");
const commandName = args._[0];
if (args.version || args.v) {
console.log(packageJSON.version);
process.exit(0);
}
if (commandName === "session") {
await handleSessionCommand(args);
return;
}
const command = help.commands[commandName];
if (args.help || args.h) {
if (command) {
console.log(command);
} else {
console.log("playwright-cli - run playwright mcp commands from terminal\n");
console.log(help.global);
}
process.exit(0);
}
if (!command) {
console.error(`Unknown command: ${commandName}
`);
console.log(help.global);
process.exit(1);
}
let sessionName = resolveSessionName(args);
if (sessionName === "default" && !args.session && !process.env.PLAYWRIGHT_CLI_SESSION)
sessionName = await getCurrentSession();
runCliCommand(sessionName, args).catch((e) => {
console.error(e.message);
process.exit(1);
});
}
main().catch((e) => {
console.error(e.message);
process.exit(1);
});

56
node_modules/playwright/lib/mcp/terminal/command.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var command_exports = {};
__export(command_exports, {
declareCommand: () => declareCommand,
parseCommand: () => parseCommand
});
module.exports = __toCommonJS(command_exports);
function declareCommand(command) {
return command;
}
function parseCommand(command, args) {
const shape = command.args ? command.args.shape : {};
const argv = args["_"];
const options = command.options?.parse({ ...args, _: void 0 }) ?? {};
const argsObject = {};
let i = 0;
for (const name of Object.keys(shape))
argsObject[name] = argv[++i];
let parsedArgsObject = {};
try {
parsedArgsObject = command.args?.parse(argsObject) ?? {};
} catch (e) {
throw new Error(formatZodError(e));
}
const toolName = typeof command.toolName === "function" ? command.toolName(parsedArgsObject, options) : command.toolName;
const toolParams = command.toolParams(parsedArgsObject, options);
return { toolName, toolParams };
}
function formatZodError(error) {
const issue = error.issues[0];
if (issue.code === "invalid_type")
return `${issue.message} in <${issue.path.join(".")}>`;
return error.issues.map((i) => i.message).join("\n");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
declareCommand,
parseCommand
});

333
node_modules/playwright/lib/mcp/terminal/commands.js generated vendored Normal file
View File

@@ -0,0 +1,333 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var commands_exports = {};
__export(commands_exports, {
commands: () => commands
});
module.exports = __toCommonJS(commands_exports);
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
var import_command = require("./command");
const click = (0, import_command.declareCommand)({
name: "click",
description: "Perform click on a web page",
args: import_mcpBundle.z.object({
ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
}),
options: import_mcpBundle.z.object({
button: import_mcpBundle.z.string().optional().describe("Button to click, defaults to left"),
modifiers: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe("Modifier keys to press")
}),
toolName: "browser_click",
toolParams: ({ ref }, { button, modifiers }) => ({ ref, button, modifiers })
});
const doubleClick = (0, import_command.declareCommand)({
name: "dblclick",
description: "Perform double click on a web page",
args: import_mcpBundle.z.object({
ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
}),
options: import_mcpBundle.z.object({
button: import_mcpBundle.z.string().optional().describe("Button to click, defaults to left"),
modifiers: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe("Modifier keys to press")
}),
toolName: "browser_click",
toolParams: ({ ref }, { button, modifiers }) => ({ ref, button, modifiers, doubleClick: true })
});
const close = (0, import_command.declareCommand)({
name: "close",
description: "Close the page",
args: import_mcpBundle.z.object({}),
toolName: "browser_close",
toolParams: () => ({})
});
const consoleMessages = (0, import_command.declareCommand)({
name: "console",
description: "Returns all console messages",
args: import_mcpBundle.z.object({
level: import_mcpBundle.z.string().optional().describe('Level of the console messages to return. Each level includes the messages of more severe levels. Defaults to "info".')
}),
toolName: "browser_console_messages",
toolParams: ({ level }) => ({ level })
});
const drag = (0, import_command.declareCommand)({
name: "drag",
description: "Perform drag and drop between two elements",
args: import_mcpBundle.z.object({
startRef: import_mcpBundle.z.string().describe("Exact source element reference from the page snapshot"),
endRef: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
}),
options: import_mcpBundle.z.object({
headed: import_mcpBundle.z.boolean().default(false).describe("Run browser in headed mode")
}),
toolName: "browser_drag",
toolParams: ({ startRef, endRef }) => ({ startRef, endRef })
});
const evaluate = (0, import_command.declareCommand)({
name: "evaluate",
description: "Evaluate JavaScript expression on page or element",
args: import_mcpBundle.z.object({
function: import_mcpBundle.z.string().describe("() => { /* code */ } or (element) => { /* code */ } when element is provided"),
ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot")
}),
toolName: "browser_evaluate",
toolParams: ({ function: fn, ref }) => ({ function: fn, ref })
});
const fileUpload = (0, import_command.declareCommand)({
name: "upload-file",
description: "Upload one or multiple files",
args: import_mcpBundle.z.object({}),
options: import_mcpBundle.z.object({
paths: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe("The absolute paths to the files to upload. Can be single file or multiple files. If omitted, file chooser is cancelled.")
}),
toolName: "browser_file_upload",
toolParams: (_, { paths }) => ({ paths })
});
const handleDialog = (0, import_command.declareCommand)({
name: "handle-dialog",
description: "Handle a dialog",
args: import_mcpBundle.z.object({
accept: import_mcpBundle.z.boolean().describe("Whether to accept the dialog."),
promptText: import_mcpBundle.z.string().optional().describe("The text of the prompt in case of a prompt dialog.")
}),
toolName: "browser_handle_dialog",
toolParams: ({ accept, promptText }) => ({ accept, promptText })
});
const hover = (0, import_command.declareCommand)({
name: "hover",
description: "Hover over element on page",
args: import_mcpBundle.z.object({
ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
}),
toolName: "browser_hover",
toolParams: ({ ref }) => ({ ref })
});
const open = (0, import_command.declareCommand)({
name: "open",
description: "Open URL",
args: import_mcpBundle.z.object({
url: import_mcpBundle.z.string().describe("The URL to navigate to")
}),
options: import_mcpBundle.z.object({
headed: import_mcpBundle.z.boolean().default(false).describe("Run browser in headed mode")
}),
toolName: "browser_open",
toolParams: ({ url }, { headed }) => ({ url, headed })
});
const navigateBack = (0, import_command.declareCommand)({
name: "go-back",
description: "Go back to the previous page",
args: import_mcpBundle.z.object({}),
toolName: "browser_navigate_back",
toolParams: () => ({})
});
const networkRequests = (0, import_command.declareCommand)({
name: "network-requests",
description: "Returns all network requests since loading the page",
args: import_mcpBundle.z.object({}),
options: import_mcpBundle.z.object({
includeStatic: import_mcpBundle.z.boolean().optional().describe("Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false.")
}),
toolName: "browser_network_requests",
toolParams: (_, { includeStatic }) => ({ includeStatic })
});
const pressKey = (0, import_command.declareCommand)({
name: "press",
description: "Press a key on the keyboard",
args: import_mcpBundle.z.object({
key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
}),
toolName: "browser_press_key",
toolParams: ({ key }) => ({ key })
});
const resize = (0, import_command.declareCommand)({
name: "resize",
description: "Resize the browser window",
args: import_mcpBundle.z.object({
width: import_mcpBundle.z.number().describe("Width of the browser window"),
height: import_mcpBundle.z.number().describe("Height of the browser window")
}),
toolName: "browser_resize",
toolParams: ({ width, height }) => ({ width, height })
});
const runCode = (0, import_command.declareCommand)({
name: "run-code",
description: "Run Playwright code snippet",
args: import_mcpBundle.z.object({
code: import_mcpBundle.z.string().describe("A JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction.")
}),
toolName: "browser_run_code",
toolParams: ({ code }) => ({ code })
});
const selectOption = (0, import_command.declareCommand)({
name: "select-option",
description: "Select an option in a dropdown",
args: import_mcpBundle.z.object({
ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot"),
values: import_mcpBundle.z.array(import_mcpBundle.z.string()).describe("Array of values to select in the dropdown. This can be a single value or multiple values.")
}),
toolName: "browser_select_option",
toolParams: ({ ref, values }) => ({ ref, values })
});
const snapshot = (0, import_command.declareCommand)({
name: "snapshot",
description: "Capture accessibility snapshot of the current page, this is better than screenshot",
args: import_mcpBundle.z.object({}),
options: import_mcpBundle.z.object({
filename: import_mcpBundle.z.string().optional().describe("Save snapshot to markdown file instead of returning it in the response.")
}),
toolName: "browser_snapshot",
toolParams: (_, { filename }) => ({ filename })
});
const screenshot = (0, import_command.declareCommand)({
name: "screenshot",
description: "Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.",
args: import_mcpBundle.z.object({
ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot.")
}),
options: import_mcpBundle.z.object({
filename: import_mcpBundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified."),
fullPage: import_mcpBundle.z.boolean().optional().describe("When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.")
}),
toolName: "browser_take_screenshot",
toolParams: ({ ref }, { filename, fullPage }) => ({ filename, ref, fullPage })
});
const type = (0, import_command.declareCommand)({
name: "type",
description: "Type text into editable element",
args: import_mcpBundle.z.object({
text: import_mcpBundle.z.string().describe("Text to type into the element")
}),
options: import_mcpBundle.z.object({
submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)")
}),
toolName: "browser_press_sequentially",
toolParams: ({ text }, { submit }) => ({ text, submit })
});
const waitFor = (0, import_command.declareCommand)({
name: "wait-for",
description: "Wait for text to appear or disappear or a specified time to pass",
args: import_mcpBundle.z.object({}),
options: import_mcpBundle.z.object({
time: import_mcpBundle.z.number().optional().describe("The time to wait in seconds"),
text: import_mcpBundle.z.string().optional().describe("The text to wait for"),
textGone: import_mcpBundle.z.string().optional().describe("The text to wait for to disappear")
}),
toolName: "browser_wait_for",
toolParams: (_, { time, text, textGone }) => ({ time, text, textGone })
});
const tab = (0, import_command.declareCommand)({
name: "tab",
description: "Close a browser tab",
args: import_mcpBundle.z.object({
action: import_mcpBundle.z.string().describe(`Action to perform on tabs, 'list' | 'new' | 'close' | 'select'`),
index: import_mcpBundle.z.number().optional().describe("Tab index. If omitted, current tab is closed.")
}),
toolName: "browser_tabs",
toolParams: ({ action, index }) => ({ action, index })
});
const mouseClickXy = (0, import_command.declareCommand)({
name: "mouse-click-xy",
description: "Click left mouse button at a given position",
args: import_mcpBundle.z.object({
x: import_mcpBundle.z.number().describe("X coordinate"),
y: import_mcpBundle.z.number().describe("Y coordinate")
}),
toolName: "browser_mouse_click_xy",
toolParams: ({ x, y }) => ({ x, y })
});
const mouseDragXy = (0, import_command.declareCommand)({
name: "mouse-drag-xy",
description: "Drag left mouse button to a given position",
args: import_mcpBundle.z.object({
startX: import_mcpBundle.z.number().describe("Start X coordinate"),
startY: import_mcpBundle.z.number().describe("Start Y coordinate"),
endX: import_mcpBundle.z.number().describe("End X coordinate"),
endY: import_mcpBundle.z.number().describe("End Y coordinate")
}),
toolName: "browser_mouse_drag_xy",
toolParams: ({ startX, startY, endX, endY }) => ({ startX, startY, endX, endY })
});
const mouseMoveXy = (0, import_command.declareCommand)({
name: "mouse-move-xy",
description: "Move mouse to a given position",
args: import_mcpBundle.z.object({
x: import_mcpBundle.z.number().describe("X coordinate"),
y: import_mcpBundle.z.number().describe("Y coordinate")
}),
toolName: "browser_mouse_move_xy",
toolParams: ({ x, y }) => ({ x, y })
});
const pdfSave = (0, import_command.declareCommand)({
name: "pdf-save",
description: "Save page as PDF",
args: import_mcpBundle.z.object({}),
options: import_mcpBundle.z.object({
filename: import_mcpBundle.z.string().optional().describe("File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.")
}),
toolName: "browser_pdf_save",
toolParams: (_, { filename }) => ({ filename })
});
const startTracing = (0, import_command.declareCommand)({
name: "start-tracing",
description: "Start trace recording",
args: import_mcpBundle.z.object({}),
toolName: "browser_start_tracing",
toolParams: () => ({})
});
const stopTracing = (0, import_command.declareCommand)({
name: "stop-tracing",
description: "Stop trace recording",
args: import_mcpBundle.z.object({}),
toolName: "browser_stop_tracing",
toolParams: () => ({})
});
const commandsArray = [
click,
close,
doubleClick,
consoleMessages,
drag,
evaluate,
fileUpload,
handleDialog,
hover,
open,
navigateBack,
networkRequests,
pressKey,
resize,
runCode,
selectOption,
snapshot,
screenshot,
type,
waitFor,
tab,
mouseClickXy,
mouseDragXy,
mouseMoveXy,
pdfSave,
startTracing,
stopTracing
];
const commands = Object.fromEntries(commandsArray.map((cmd) => [cmd.name, cmd]));
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
commands
});

129
node_modules/playwright/lib/mcp/terminal/daemon.js generated vendored Normal file
View File

@@ -0,0 +1,129 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var daemon_exports = {};
__export(daemon_exports, {
startMcpDaemonServer: () => startMcpDaemonServer
});
module.exports = __toCommonJS(daemon_exports);
var import_promises = __toESM(require("fs/promises"));
var import_net = __toESM(require("net"));
var import_os = __toESM(require("os"));
var import_path = __toESM(require("path"));
var import_url = __toESM(require("url"));
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_socketConnection = require("./socketConnection");
var import_commands = require("./commands");
var import_command = require("./command");
const daemonDebug = (0, import_utilsBundle.debug)("pw:daemon");
async function socketExists(socketPath) {
try {
const stat = await import_promises.default.stat(socketPath);
if (stat?.isSocket())
return true;
} catch (e) {
}
return false;
}
async function startMcpDaemonServer(socketPath, serverBackendFactory) {
if (import_os.default.platform() !== "win32" && await socketExists(socketPath)) {
daemonDebug(`Socket already exists, removing: ${socketPath}`);
try {
await import_promises.default.unlink(socketPath);
} catch (error) {
daemonDebug(`Failed to remove existing socket: ${error}`);
throw error;
}
}
const backend = serverBackendFactory.create();
const cwd = import_url.default.pathToFileURL(process.cwd()).href;
await backend.initialize?.({
name: "playwright-cli",
version: "1.0.0",
roots: [{
uri: cwd,
name: "cwd"
}],
timestamp: Date.now()
});
await import_promises.default.mkdir(import_path.default.dirname(socketPath), { recursive: true });
const server = import_net.default.createServer((socket) => {
daemonDebug("new client connection");
const connection = new import_socketConnection.SocketConnection(socket);
connection.onclose = () => {
daemonDebug("client disconnected");
};
connection.onmessage = async (message) => {
const { id, method, params } = message;
try {
daemonDebug("received command", method);
if (method === "runCliCommand") {
const { toolName, toolParams } = parseCliCommand(params.args);
const response = await backend.callTool(toolName, toolParams, () => {
});
await connection.send({ id, result: formatResult(response) });
} else {
throw new Error(`Unknown method: ${method}`);
}
} catch (e) {
daemonDebug("command failed", e);
await connection.send({ id, error: e.message });
}
};
});
return new Promise((resolve, reject) => {
server.on("error", (error) => {
daemonDebug(`server error: ${error.message}`);
reject(error);
});
server.listen(socketPath, () => {
daemonDebug(`daemon server listening on ${socketPath}`);
resolve(socketPath);
});
});
}
function formatResult(result) {
const lines = [];
for (const content of result.content) {
if (content.type === "text")
lines.push(content.text);
else
lines.push(`<${content.type} content>`);
}
return lines.join("\n");
}
function parseCliCommand(args) {
const command = import_commands.commands[args._[0]];
if (!command)
throw new Error("Command is required");
return (0, import_command.parseCommand)(command, args);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
startMcpDaemonServer
});

32
node_modules/playwright/lib/mcp/terminal/help.json generated vendored Normal file
View File

@@ -0,0 +1,32 @@
{
"global": "Usage: playwright-cli <command> [options]\nCommands:\n click <ref> perform click on a web page\n close close the page\n dblclick <ref> perform double click on a web page\n console <level> returns all console messages\n drag <startRef> <endRef> perform drag and drop between two elements\n evaluate <function> <ref> evaluate javascript expression on page or element\n upload-file upload one or multiple files\n handle-dialog <accept> <promptText> handle a dialog\n hover <ref> hover over element on page\n open <url> open url\n go-back go back to the previous page\n network-requests returns all network requests since loading the page\n press <key> press a key on the keyboard\n resize <width> <height> resize the browser window\n run-code <code> run playwright code snippet\n select-option <ref> <values> select an option in a dropdown\n snapshot capture accessibility snapshot of the current page, this is better than screenshot\n screenshot <ref> take a screenshot of the current page. you can't perform actions based on the screenshot, use browser_snapshot for actions.\n type <text> type text into editable element\n wait-for wait for text to appear or disappear or a specified time to pass\n tab <action> <index> close a browser tab\n mouse-click-xy <x> <y> click left mouse button at a given position\n mouse-drag-xy <startX> <startY> <endX> <endY> drag left mouse button to a given position\n mouse-move-xy <x> <y> move mouse to a given position\n pdf-save save page as pdf\n start-tracing start trace recording\n stop-tracing stop trace recording",
"commands": {
"click": "playwright-cli click <ref>\n\nPerform click on a web page\n\nArguments:\n <ref>\tExact target element reference from the page snapshot\nOptions:\n --button\tbutton to click, defaults to left\n --modifiers\tmodifier keys to press",
"close": "playwright-cli close \n\nClose the page\n",
"dblclick": "playwright-cli dblclick <ref>\n\nPerform double click on a web page\n\nArguments:\n <ref>\tExact target element reference from the page snapshot\nOptions:\n --button\tbutton to click, defaults to left\n --modifiers\tmodifier keys to press",
"console": "playwright-cli console <level>\n\nReturns all console messages\n\nArguments:\n <level>\tLevel of the console messages to return. Each level includes the messages of more severe levels. Defaults to \"info\".",
"drag": "playwright-cli drag <startRef> <endRef>\n\nPerform drag and drop between two elements\n\nArguments:\n <startRef>\tExact source element reference from the page snapshot\n <endRef>\tExact target element reference from the page snapshot\nOptions:\n --headed\trun browser in headed mode",
"evaluate": "playwright-cli evaluate <function> <ref>\n\nEvaluate JavaScript expression on page or element\n\nArguments:\n <function>\t() => { /* code */ } or (element) => { /* code */ } when element is provided\n <ref>\tExact target element reference from the page snapshot",
"upload-file": "playwright-cli upload-file \n\nUpload one or multiple files\n\nOptions:\n --paths\tthe absolute paths to the files to upload. can be single file or multiple files. if omitted, file chooser is cancelled.",
"handle-dialog": "playwright-cli handle-dialog <accept> <promptText>\n\nHandle a dialog\n\nArguments:\n <accept>\tWhether to accept the dialog.\n <promptText>\tThe text of the prompt in case of a prompt dialog.",
"hover": "playwright-cli hover <ref>\n\nHover over element on page\n\nArguments:\n <ref>\tExact target element reference from the page snapshot",
"open": "playwright-cli open <url>\n\nOpen URL\n\nArguments:\n <url>\tThe URL to navigate to\nOptions:\n --headed\trun browser in headed mode",
"go-back": "playwright-cli go-back \n\nGo back to the previous page\n",
"network-requests": "playwright-cli network-requests \n\nReturns all network requests since loading the page\n\nOptions:\n --includeStatic\twhether to include successful static resources like images, fonts, scripts, etc. defaults to false.",
"press": "playwright-cli press <key>\n\nPress a key on the keyboard\n\nArguments:\n <key>\tName of the key to press or a character to generate, such as `ArrowLeft` or `a`",
"resize": "playwright-cli resize <width> <height>\n\nResize the browser window\n\nArguments:\n <width>\tWidth of the browser window\n <height>\tHeight of the browser window",
"run-code": "playwright-cli run-code <code>\n\nRun Playwright code snippet\n\nArguments:\n <code>\tA JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction.",
"select-option": "playwright-cli select-option <ref> <values>\n\nSelect an option in a dropdown\n\nArguments:\n <ref>\tExact target element reference from the page snapshot\n <values>\tArray of values to select in the dropdown. This can be a single value or multiple values.",
"snapshot": "playwright-cli snapshot \n\nCapture accessibility snapshot of the current page, this is better than screenshot\n\nOptions:\n --filename\tsave snapshot to markdown file instead of returning it in the response.",
"screenshot": "playwright-cli screenshot <ref>\n\nTake a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.\n\nArguments:\n <ref>\tExact target element reference from the page snapshot.\nOptions:\n --filename\tfile name to save the screenshot to. defaults to `page-{timestamp}.{png|jpeg}` if not specified.\n --fullPage\twhen true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.",
"type": "playwright-cli type <text>\n\nType text into editable element\n\nArguments:\n <text>\tText to type into the element\nOptions:\n --submit\twhether to submit entered text (press enter after)",
"wait-for": "playwright-cli wait-for \n\nWait for text to appear or disappear or a specified time to pass\n\nOptions:\n --time\tthe time to wait in seconds\n --text\tthe text to wait for\n --textGone\tthe text to wait for to disappear",
"tab": "playwright-cli tab <action> <index>\n\nClose a browser tab\n\nArguments:\n <action>\tAction to perform on tabs, 'list' | 'new' | 'close' | 'select'\n <index>\tTab index. If omitted, current tab is closed.",
"mouse-click-xy": "playwright-cli mouse-click-xy <x> <y>\n\nClick left mouse button at a given position\n\nArguments:\n <x>\tX coordinate\n <y>\tY coordinate",
"mouse-drag-xy": "playwright-cli mouse-drag-xy <startX> <startY> <endX> <endY>\n\nDrag left mouse button to a given position\n\nArguments:\n <startX>\tStart X coordinate\n <startY>\tStart Y coordinate\n <endX>\tEnd X coordinate\n <endY>\tEnd Y coordinate",
"mouse-move-xy": "playwright-cli mouse-move-xy <x> <y>\n\nMove mouse to a given position\n\nArguments:\n <x>\tX coordinate\n <y>\tY coordinate",
"pdf-save": "playwright-cli pdf-save \n\nSave page as PDF\n\nOptions:\n --filename\tfile name to save the pdf to. defaults to `page-{timestamp}.pdf` if not specified.",
"start-tracing": "playwright-cli start-tracing \n\nStart trace recording\n",
"stop-tracing": "playwright-cli stop-tracing \n\nStop trace recording\n"
}
}

View File

@@ -0,0 +1,88 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_commands = require("./commands");
function generateCommandHelp(command) {
const args = [];
const shape = command.args ? command.args.shape : {};
for (const [name, schema] of Object.entries(shape)) {
const zodSchema = schema;
const description = zodSchema.description ?? "";
args.push({ name, description });
}
const lines = [
`playwright-cli ${command.name} ${Object.keys(shape).map((k) => `<${k}>`).join(" ")}`,
"",
command.description,
""
];
if (args.length) {
lines.push("Arguments:");
lines.push(...args.map(({ name, description }) => ` <${name}> ${description}`));
}
if (command.options) {
lines.push("Options:");
const optionsShape = command.options.shape;
for (const [name, schema] of Object.entries(optionsShape)) {
const zodSchema = schema;
const description = (zodSchema.description ?? "").toLowerCase();
lines.push(` --${name} ${description}`);
}
}
return lines.join("\n");
}
function generateHelp() {
const lines = [];
lines.push("Usage: playwright-cli <command> [options]");
lines.push("Commands:");
for (const command of Object.values(import_commands.commands))
lines.push(" " + generateHelpEntry(command));
return lines.join("\n");
}
function generateHelpEntry(command) {
const args = [];
const shape = command.args.shape;
for (const [name, schema] of Object.entries(shape)) {
const zodSchema = schema;
const description = zodSchema.description ?? "";
args.push({ name, description });
}
const prefix = `${command.name} ${Object.keys(shape).map((k) => `<${k}>`).join(" ")}`;
const suffix = command.description.toLowerCase();
const padding = " ".repeat(Math.max(1, 40 - prefix.length));
return prefix + padding + suffix;
}
async function main() {
const help = {
global: generateHelp(),
commands: Object.fromEntries(
Object.entries(import_commands.commands).map(([name, command]) => [name, generateCommandHelp(command)])
)
};
const fileName = import_path.default.resolve(__dirname, "help.json").replace("lib", "src");
console.log("Writing ", import_path.default.relative(process.cwd(), fileName));
await import_fs.default.promises.writeFile(fileName, JSON.stringify(help, null, 2));
}
void main();

View File

@@ -0,0 +1,80 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var socketConnection_exports = {};
__export(socketConnection_exports, {
SocketConnection: () => SocketConnection
});
module.exports = __toCommonJS(socketConnection_exports);
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
const daemonDebug = (0, import_utilsBundle.debug)("pw:daemon");
class SocketConnection {
constructor(socket) {
this._pendingBuffers = [];
this._socket = socket;
socket.on("data", (buffer) => this._onData(buffer));
socket.on("close", () => {
this.onclose?.();
});
socket.on("error", (e) => daemonDebug(`error: ${e.message}`));
}
async send(message) {
await new Promise((resolve, reject) => {
this._socket.write(`${JSON.stringify(message)}
`, (error) => {
if (error)
reject(error);
else
resolve(void 0);
});
});
}
close() {
this._socket.destroy();
}
_onData(buffer) {
let end = buffer.indexOf("\n");
if (end === -1) {
this._pendingBuffers.push(buffer);
return;
}
this._pendingBuffers.push(buffer.slice(0, end));
const message = Buffer.concat(this._pendingBuffers).toString();
this._dispatchMessage(message);
let start = end + 1;
end = buffer.indexOf("\n", start);
while (end !== -1) {
const message2 = buffer.toString(void 0, start, end);
this._dispatchMessage(message2);
start = end + 1;
end = buffer.indexOf("\n", start);
}
this._pendingBuffers = [buffer.slice(start)];
}
_dispatchMessage(message) {
try {
this.onmessage?.(JSON.parse(message));
} catch (e) {
daemonDebug("failed to dispatch message", e);
}
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SocketConnection
});