🚀 Auto-deploy: BotVPS atualizado em 02/05/2026 15:37:40
This commit is contained in:
73
node_modules/playwright-core/lib/tools/cli-daemon/command.js
generated
vendored
Normal file
73
node_modules/playwright-core/lib/tools/cli-daemon/command.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"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);
|
||||
var import_zodBundle = require("../../zodBundle");
|
||||
function declareCommand(command) {
|
||||
return command;
|
||||
}
|
||||
const kEmptyOptions = import_zodBundle.z.object({});
|
||||
const kEmptyArgs = import_zodBundle.z.object({});
|
||||
function parseCommand(command, args) {
|
||||
const optionsObject = { ...args };
|
||||
delete optionsObject["_"];
|
||||
const optionsSchema = (command.options ?? kEmptyOptions).strict();
|
||||
const options = zodParse(optionsSchema, optionsObject, "option");
|
||||
const argsSchema = (command.args ?? kEmptyArgs).strict();
|
||||
const argNames = [...Object.keys(argsSchema.shape)];
|
||||
const argv = args["_"].slice(1);
|
||||
if (argv.length > argNames.length)
|
||||
throw new Error(`error: too many arguments: expected ${argNames.length}, received ${argv.length}`);
|
||||
const argsObject = {};
|
||||
argNames.forEach((name, index) => argsObject[name] = argv[index]);
|
||||
const parsedArgsObject = zodParse(argsSchema, argsObject, "argument");
|
||||
const toolName = typeof command.toolName === "function" ? command.toolName({ ...parsedArgsObject, ...options }) : command.toolName;
|
||||
const toolParams = command.toolParams({ ...parsedArgsObject, ...options });
|
||||
return { toolName, toolParams };
|
||||
}
|
||||
function zodParse(schema, data, type) {
|
||||
try {
|
||||
return schema.parse(data);
|
||||
} catch (e) {
|
||||
throw new Error(e.issues.map((issue) => {
|
||||
const keys = issue.code === "unrecognized_keys" ? issue.keys : [""];
|
||||
const props = keys.map((key) => [...issue.path, key].filter(Boolean).join("."));
|
||||
return props.map((prop) => {
|
||||
const label = type === "option" ? `'--${prop}' option` : `'${prop}' argument`;
|
||||
switch (issue.code) {
|
||||
case "invalid_type":
|
||||
return "error: " + label + ": " + issue.message.replace(/Invalid input:/, "").trim();
|
||||
case "unrecognized_keys":
|
||||
return "error: unknown " + label;
|
||||
default:
|
||||
return "error: " + label + ": " + issue.message;
|
||||
}
|
||||
});
|
||||
}).flat().join("\n"));
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
declareCommand,
|
||||
parseCommand
|
||||
});
|
||||
956
node_modules/playwright-core/lib/tools/cli-daemon/commands.js
generated
vendored
Normal file
956
node_modules/playwright-core/lib/tools/cli-daemon/commands.js
generated
vendored
Normal file
@@ -0,0 +1,956 @@
|
||||
"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_zodBundle = require("../../zodBundle");
|
||||
var import_command = require("./command");
|
||||
const numberArg = import_zodBundle.z.preprocess((val, ctx) => {
|
||||
const number = Number(val);
|
||||
if (Number.isNaN(number)) {
|
||||
ctx.issues.push({
|
||||
code: "custom",
|
||||
message: `expected number, received '${val}'`,
|
||||
input: val
|
||||
});
|
||||
}
|
||||
return number;
|
||||
}, import_zodBundle.z.number());
|
||||
function asRef(refOrSelector) {
|
||||
if (refOrSelector === void 0)
|
||||
return {};
|
||||
if (refOrSelector.match(/^(f\d+)?e\d+$/))
|
||||
return { ref: refOrSelector };
|
||||
return { ref: "", selector: refOrSelector };
|
||||
}
|
||||
const open = (0, import_command.declareCommand)({
|
||||
name: "open",
|
||||
description: "Open the browser",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
url: import_zodBundle.z.string().optional().describe("The URL to navigate to")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
browser: import_zodBundle.z.string().optional().describe("Browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge."),
|
||||
config: import_zodBundle.z.string().optional().describe("Path to the configuration file, defaults to .playwright/cli.config.json"),
|
||||
extension: import_zodBundle.z.boolean().optional().describe("Connect to browser extension"),
|
||||
headed: import_zodBundle.z.boolean().optional().describe("Run browser in headed mode"),
|
||||
persistent: import_zodBundle.z.boolean().optional().describe("Use persistent browser profile"),
|
||||
profile: import_zodBundle.z.string().optional().describe("Use persistent browser profile, store profile in specified directory.")
|
||||
}),
|
||||
toolName: ({ url }) => url ? "browser_navigate" : "browser_snapshot",
|
||||
toolParams: ({ url }) => url ? { url: url || "about:blank" } : { filename: "<auto>" }
|
||||
});
|
||||
const attach = (0, import_command.declareCommand)({
|
||||
name: "attach",
|
||||
description: "Attach to a running Playwright browser",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
name: import_zodBundle.z.string().describe("Name or endpoint of the browser to attach to")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
config: import_zodBundle.z.string().optional().describe("Path to the configuration file, defaults to .playwright/cli.config.json"),
|
||||
session: import_zodBundle.z.string().optional().describe("Session name alias (defaults to the attach target name)")
|
||||
}),
|
||||
toolName: "browser_snapshot",
|
||||
toolParams: () => ({ filename: "<auto>" })
|
||||
});
|
||||
const close = (0, import_command.declareCommand)({
|
||||
name: "close",
|
||||
description: "Close the browser",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const goto = (0, import_command.declareCommand)({
|
||||
name: "goto",
|
||||
description: "Navigate to a URL",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
url: import_zodBundle.z.string().describe("The URL to navigate to")
|
||||
}),
|
||||
toolName: "browser_navigate",
|
||||
toolParams: ({ url }) => ({ url })
|
||||
});
|
||||
const goBack = (0, import_command.declareCommand)({
|
||||
name: "go-back",
|
||||
description: "Go back to the previous page",
|
||||
category: "navigation",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_navigate_back",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const goForward = (0, import_command.declareCommand)({
|
||||
name: "go-forward",
|
||||
description: "Go forward to the next page",
|
||||
category: "navigation",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_navigate_forward",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const reload = (0, import_command.declareCommand)({
|
||||
name: "reload",
|
||||
description: "Reload the current page",
|
||||
category: "navigation",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_reload",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const pressKey = (0, import_command.declareCommand)({
|
||||
name: "press",
|
||||
description: "Press a key on the keyboard, `a`, `ArrowLeft`",
|
||||
category: "keyboard",
|
||||
args: import_zodBundle.z.object({
|
||||
key: import_zodBundle.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 type = (0, import_command.declareCommand)({
|
||||
name: "type",
|
||||
description: "Type text into editable element",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
text: import_zodBundle.z.string().describe("Text to type into the element")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
submit: import_zodBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)")
|
||||
}),
|
||||
toolName: "browser_press_sequentially",
|
||||
toolParams: ({ text, submit }) => ({ text, submit })
|
||||
});
|
||||
const keydown = (0, import_command.declareCommand)({
|
||||
name: "keydown",
|
||||
description: "Press a key down on the keyboard",
|
||||
category: "keyboard",
|
||||
args: import_zodBundle.z.object({
|
||||
key: import_zodBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
|
||||
}),
|
||||
toolName: "browser_keydown",
|
||||
toolParams: ({ key }) => ({ key })
|
||||
});
|
||||
const keyup = (0, import_command.declareCommand)({
|
||||
name: "keyup",
|
||||
description: "Press a key up on the keyboard",
|
||||
category: "keyboard",
|
||||
args: import_zodBundle.z.object({
|
||||
key: import_zodBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
|
||||
}),
|
||||
toolName: "browser_keyup",
|
||||
toolParams: ({ key }) => ({ key })
|
||||
});
|
||||
const mouseMove = (0, import_command.declareCommand)({
|
||||
name: "mousemove",
|
||||
description: "Move mouse to a given position",
|
||||
category: "mouse",
|
||||
args: import_zodBundle.z.object({
|
||||
x: numberArg.describe("X coordinate"),
|
||||
y: numberArg.describe("Y coordinate")
|
||||
}),
|
||||
toolName: "browser_mouse_move_xy",
|
||||
toolParams: ({ x, y }) => ({ x, y })
|
||||
});
|
||||
const mouseDown = (0, import_command.declareCommand)({
|
||||
name: "mousedown",
|
||||
description: "Press mouse down",
|
||||
category: "mouse",
|
||||
args: import_zodBundle.z.object({
|
||||
button: import_zodBundle.z.string().optional().describe("Button to press, defaults to left")
|
||||
}),
|
||||
toolName: "browser_mouse_down",
|
||||
toolParams: ({ button }) => ({ button })
|
||||
});
|
||||
const mouseUp = (0, import_command.declareCommand)({
|
||||
name: "mouseup",
|
||||
description: "Press mouse up",
|
||||
category: "mouse",
|
||||
args: import_zodBundle.z.object({
|
||||
button: import_zodBundle.z.string().optional().describe("Button to press, defaults to left")
|
||||
}),
|
||||
toolName: "browser_mouse_up",
|
||||
toolParams: ({ button }) => ({ button })
|
||||
});
|
||||
const mouseWheel = (0, import_command.declareCommand)({
|
||||
name: "mousewheel",
|
||||
description: "Scroll mouse wheel",
|
||||
category: "mouse",
|
||||
args: import_zodBundle.z.object({
|
||||
dx: numberArg.describe("X delta"),
|
||||
dy: numberArg.describe("Y delta")
|
||||
}),
|
||||
toolName: "browser_mouse_wheel",
|
||||
toolParams: ({ dx: deltaX, dy: deltaY }) => ({ deltaX, deltaY })
|
||||
});
|
||||
const click = (0, import_command.declareCommand)({
|
||||
name: "click",
|
||||
description: "Perform click on a web page",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
target: import_zodBundle.z.string().describe("Exact target element reference from the page snapshot, or a unique element selector"),
|
||||
button: import_zodBundle.z.string().optional().describe("Button to click, defaults to left")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
modifiers: import_zodBundle.z.array(import_zodBundle.z.string()).optional().describe("Modifier keys to press")
|
||||
}),
|
||||
toolName: "browser_click",
|
||||
toolParams: ({ target, button, modifiers }) => ({ ...asRef(target), button, modifiers })
|
||||
});
|
||||
const doubleClick = (0, import_command.declareCommand)({
|
||||
name: "dblclick",
|
||||
description: "Perform double click on a web page",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
target: import_zodBundle.z.string().describe("Exact target element reference from the page snapshot, or a unique element selector"),
|
||||
button: import_zodBundle.z.string().optional().describe("Button to click, defaults to left")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
modifiers: import_zodBundle.z.array(import_zodBundle.z.string()).optional().describe("Modifier keys to press")
|
||||
}),
|
||||
toolName: "browser_click",
|
||||
toolParams: ({ target, button, modifiers }) => ({ ...asRef(target), button, modifiers, doubleClick: true })
|
||||
});
|
||||
const drag = (0, import_command.declareCommand)({
|
||||
name: "drag",
|
||||
description: "Perform drag and drop between two elements",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
startElement: import_zodBundle.z.string().describe("Exact source element reference from the page snapshot, or a unique element selector"),
|
||||
endElement: import_zodBundle.z.string().describe("Exact target element reference from the page snapshot, or a unique element selector")
|
||||
}),
|
||||
toolName: "browser_drag",
|
||||
toolParams: ({ startElement, endElement }) => {
|
||||
const start = asRef(startElement);
|
||||
const end = asRef(endElement);
|
||||
return { startRef: start.ref, startSelector: start.selector, endRef: end.ref, endSelector: end.selector };
|
||||
}
|
||||
});
|
||||
const fill = (0, import_command.declareCommand)({
|
||||
name: "fill",
|
||||
description: "Fill text into editable element",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
target: import_zodBundle.z.string().describe("Exact target element reference from the page snapshot, or a unique element selector"),
|
||||
text: import_zodBundle.z.string().describe("Text to fill into the element")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
submit: import_zodBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)")
|
||||
}),
|
||||
toolName: "browser_type",
|
||||
toolParams: ({ target, text, submit }) => ({ ...asRef(target), text, submit })
|
||||
});
|
||||
const hover = (0, import_command.declareCommand)({
|
||||
name: "hover",
|
||||
description: "Hover over element on page",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
target: import_zodBundle.z.string().describe("Exact target element reference from the page snapshot, or a unique element selector")
|
||||
}),
|
||||
toolName: "browser_hover",
|
||||
toolParams: ({ target }) => ({ ...asRef(target) })
|
||||
});
|
||||
const select = (0, import_command.declareCommand)({
|
||||
name: "select",
|
||||
description: "Select an option in a dropdown",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
target: import_zodBundle.z.string().describe("Exact target element reference from the page snapshot, or a unique element selector"),
|
||||
val: import_zodBundle.z.string().describe("Value to select in the dropdown")
|
||||
}),
|
||||
toolName: "browser_select_option",
|
||||
toolParams: ({ target, val: value }) => ({ ...asRef(target), values: [value] })
|
||||
});
|
||||
const fileUpload = (0, import_command.declareCommand)({
|
||||
name: "upload",
|
||||
description: "Upload one or multiple files",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
file: import_zodBundle.z.string().describe("The absolute paths to the files to upload")
|
||||
}),
|
||||
toolName: "browser_file_upload",
|
||||
toolParams: ({ file }) => ({ paths: [file] })
|
||||
});
|
||||
const check = (0, import_command.declareCommand)({
|
||||
name: "check",
|
||||
description: "Check a checkbox or radio button",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
target: import_zodBundle.z.string().describe("Exact target element reference from the page snapshot, or a unique element selector")
|
||||
}),
|
||||
toolName: "browser_check",
|
||||
toolParams: ({ target }) => ({ ...asRef(target) })
|
||||
});
|
||||
const uncheck = (0, import_command.declareCommand)({
|
||||
name: "uncheck",
|
||||
description: "Uncheck a checkbox or radio button",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
target: import_zodBundle.z.string().describe("Exact target element reference from the page snapshot, or a unique element selector")
|
||||
}),
|
||||
toolName: "browser_uncheck",
|
||||
toolParams: ({ target }) => ({ ...asRef(target) })
|
||||
});
|
||||
const snapshot = (0, import_command.declareCommand)({
|
||||
name: "snapshot",
|
||||
description: "Capture page snapshot to obtain element ref",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
element: import_zodBundle.z.string().optional().describe("Element selector of the root element to capture a partial snapshot instead of the whole page")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
filename: import_zodBundle.z.string().optional().describe("Save snapshot to markdown file instead of returning it in the response."),
|
||||
depth: numberArg.optional().describe("Limit snapshot depth, unlimited by default.")
|
||||
}),
|
||||
toolName: "browser_snapshot",
|
||||
toolParams: ({ filename, element, depth }) => ({ filename, selector: element, depth })
|
||||
});
|
||||
const evaluate = (0, import_command.declareCommand)({
|
||||
name: "eval",
|
||||
description: "Evaluate JavaScript expression on page or element",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
func: import_zodBundle.z.string().describe("() => { /* code */ } or (element) => { /* code */ } when element is provided"),
|
||||
element: import_zodBundle.z.string().optional().describe("Exact target element reference from the page snapshot, or a unique element selector")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
filename: import_zodBundle.z.string().optional().describe("Save evaluation result to a file instead of returning it in the response.")
|
||||
}),
|
||||
toolName: "browser_evaluate",
|
||||
toolParams: ({ func, element, filename }) => ({ function: func, filename, ...asRef(element) })
|
||||
});
|
||||
const dialogAccept = (0, import_command.declareCommand)({
|
||||
name: "dialog-accept",
|
||||
description: "Accept a dialog",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
prompt: import_zodBundle.z.string().optional().describe("The text of the prompt in case of a prompt dialog.")
|
||||
}),
|
||||
toolName: "browser_handle_dialog",
|
||||
toolParams: ({ prompt: promptText }) => ({ accept: true, promptText })
|
||||
});
|
||||
const dialogDismiss = (0, import_command.declareCommand)({
|
||||
name: "dialog-dismiss",
|
||||
description: "Dismiss a dialog",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_handle_dialog",
|
||||
toolParams: () => ({ accept: false })
|
||||
});
|
||||
const resize = (0, import_command.declareCommand)({
|
||||
name: "resize",
|
||||
description: "Resize the browser window",
|
||||
category: "core",
|
||||
args: import_zodBundle.z.object({
|
||||
w: numberArg.describe("Width of the browser window"),
|
||||
h: numberArg.describe("Height of the browser window")
|
||||
}),
|
||||
toolName: "browser_resize",
|
||||
toolParams: ({ w: width, h: height }) => ({ width, height })
|
||||
});
|
||||
const runCode = (0, import_command.declareCommand)({
|
||||
name: "run-code",
|
||||
description: "Run Playwright code snippet",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({
|
||||
code: import_zodBundle.z.string().optional().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.")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
filename: import_zodBundle.z.string().optional().describe("Load code from the specified file.")
|
||||
}),
|
||||
toolName: "browser_run_code",
|
||||
toolParams: ({ code, filename }) => ({ code, filename })
|
||||
});
|
||||
const tabList = (0, import_command.declareCommand)({
|
||||
name: "tab-list",
|
||||
description: "List all tabs",
|
||||
category: "tabs",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_tabs",
|
||||
toolParams: () => ({ action: "list" })
|
||||
});
|
||||
const tabNew = (0, import_command.declareCommand)({
|
||||
name: "tab-new",
|
||||
description: "Create a new tab",
|
||||
category: "tabs",
|
||||
args: import_zodBundle.z.object({
|
||||
url: import_zodBundle.z.string().optional().describe("The URL to navigate to in the new tab. If omitted, the new tab will be blank.")
|
||||
}),
|
||||
toolName: "browser_tabs",
|
||||
toolParams: ({ url }) => ({ action: "new", url })
|
||||
});
|
||||
const tabClose = (0, import_command.declareCommand)({
|
||||
name: "tab-close",
|
||||
description: "Close a browser tab",
|
||||
category: "tabs",
|
||||
args: import_zodBundle.z.object({
|
||||
index: numberArg.optional().describe("Tab index. If omitted, current tab is closed.")
|
||||
}),
|
||||
toolName: "browser_tabs",
|
||||
toolParams: ({ index }) => ({ action: "close", index })
|
||||
});
|
||||
const tabSelect = (0, import_command.declareCommand)({
|
||||
name: "tab-select",
|
||||
description: "Select a browser tab",
|
||||
category: "tabs",
|
||||
args: import_zodBundle.z.object({
|
||||
index: numberArg.describe("Tab index")
|
||||
}),
|
||||
toolName: "browser_tabs",
|
||||
toolParams: ({ index }) => ({ action: "select", index })
|
||||
});
|
||||
const stateLoad = (0, import_command.declareCommand)({
|
||||
name: "state-load",
|
||||
description: "Loads browser storage (authentication) state from a file",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
filename: import_zodBundle.z.string().describe("File name to load the storage state from.")
|
||||
}),
|
||||
toolName: "browser_set_storage_state",
|
||||
toolParams: ({ filename }) => ({ filename })
|
||||
});
|
||||
const stateSave = (0, import_command.declareCommand)({
|
||||
name: "state-save",
|
||||
description: "Saves the current storage (authentication) state to a file",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
filename: import_zodBundle.z.string().optional().describe("File name to save the storage state to.")
|
||||
}),
|
||||
toolName: "browser_storage_state",
|
||||
toolParams: ({ filename }) => ({ filename })
|
||||
});
|
||||
const cookieList = (0, import_command.declareCommand)({
|
||||
name: "cookie-list",
|
||||
description: "List all cookies (optionally filtered by domain/path)",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({}),
|
||||
options: import_zodBundle.z.object({
|
||||
domain: import_zodBundle.z.string().optional().describe("Filter cookies by domain"),
|
||||
path: import_zodBundle.z.string().optional().describe("Filter cookies by path")
|
||||
}),
|
||||
toolName: "browser_cookie_list",
|
||||
toolParams: ({ domain, path }) => ({ domain, path })
|
||||
});
|
||||
const cookieGet = (0, import_command.declareCommand)({
|
||||
name: "cookie-get",
|
||||
description: "Get a specific cookie by name",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
name: import_zodBundle.z.string().describe("Cookie name")
|
||||
}),
|
||||
toolName: "browser_cookie_get",
|
||||
toolParams: ({ name }) => ({ name })
|
||||
});
|
||||
const cookieSet = (0, import_command.declareCommand)({
|
||||
name: "cookie-set",
|
||||
description: "Set a cookie with optional flags",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
name: import_zodBundle.z.string().describe("Cookie name"),
|
||||
value: import_zodBundle.z.string().describe("Cookie value")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
domain: import_zodBundle.z.string().optional().describe("Cookie domain"),
|
||||
path: import_zodBundle.z.string().optional().describe("Cookie path"),
|
||||
expires: numberArg.optional().describe("Cookie expiration as Unix timestamp"),
|
||||
httpOnly: import_zodBundle.z.boolean().optional().describe("Whether the cookie is HTTP only"),
|
||||
secure: import_zodBundle.z.boolean().optional().describe("Whether the cookie is secure"),
|
||||
sameSite: import_zodBundle.z.enum(["Strict", "Lax", "None"]).optional().describe("Cookie SameSite attribute")
|
||||
}),
|
||||
toolName: "browser_cookie_set",
|
||||
toolParams: ({ name, value, domain, path, expires, httpOnly, secure, sameSite }) => ({ name, value, domain, path, expires, httpOnly, secure, sameSite })
|
||||
});
|
||||
const cookieDelete = (0, import_command.declareCommand)({
|
||||
name: "cookie-delete",
|
||||
description: "Delete a specific cookie",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
name: import_zodBundle.z.string().describe("Cookie name")
|
||||
}),
|
||||
toolName: "browser_cookie_delete",
|
||||
toolParams: ({ name }) => ({ name })
|
||||
});
|
||||
const cookieClear = (0, import_command.declareCommand)({
|
||||
name: "cookie-clear",
|
||||
description: "Clear all cookies",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_cookie_clear",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const localStorageList = (0, import_command.declareCommand)({
|
||||
name: "localstorage-list",
|
||||
description: "List all localStorage key-value pairs",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_localstorage_list",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const localStorageGet = (0, import_command.declareCommand)({
|
||||
name: "localstorage-get",
|
||||
description: "Get a localStorage item by key",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
key: import_zodBundle.z.string().describe("Key to get")
|
||||
}),
|
||||
toolName: "browser_localstorage_get",
|
||||
toolParams: ({ key }) => ({ key })
|
||||
});
|
||||
const localStorageSet = (0, import_command.declareCommand)({
|
||||
name: "localstorage-set",
|
||||
description: "Set a localStorage item",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
key: import_zodBundle.z.string().describe("Key to set"),
|
||||
value: import_zodBundle.z.string().describe("Value to set")
|
||||
}),
|
||||
toolName: "browser_localstorage_set",
|
||||
toolParams: ({ key, value }) => ({ key, value })
|
||||
});
|
||||
const localStorageDelete = (0, import_command.declareCommand)({
|
||||
name: "localstorage-delete",
|
||||
description: "Delete a localStorage item",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
key: import_zodBundle.z.string().describe("Key to delete")
|
||||
}),
|
||||
toolName: "browser_localstorage_delete",
|
||||
toolParams: ({ key }) => ({ key })
|
||||
});
|
||||
const localStorageClear = (0, import_command.declareCommand)({
|
||||
name: "localstorage-clear",
|
||||
description: "Clear all localStorage",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_localstorage_clear",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const sessionStorageList = (0, import_command.declareCommand)({
|
||||
name: "sessionstorage-list",
|
||||
description: "List all sessionStorage key-value pairs",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_sessionstorage_list",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const sessionStorageGet = (0, import_command.declareCommand)({
|
||||
name: "sessionstorage-get",
|
||||
description: "Get a sessionStorage item by key",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
key: import_zodBundle.z.string().describe("Key to get")
|
||||
}),
|
||||
toolName: "browser_sessionstorage_get",
|
||||
toolParams: ({ key }) => ({ key })
|
||||
});
|
||||
const sessionStorageSet = (0, import_command.declareCommand)({
|
||||
name: "sessionstorage-set",
|
||||
description: "Set a sessionStorage item",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
key: import_zodBundle.z.string().describe("Key to set"),
|
||||
value: import_zodBundle.z.string().describe("Value to set")
|
||||
}),
|
||||
toolName: "browser_sessionstorage_set",
|
||||
toolParams: ({ key, value }) => ({ key, value })
|
||||
});
|
||||
const sessionStorageDelete = (0, import_command.declareCommand)({
|
||||
name: "sessionstorage-delete",
|
||||
description: "Delete a sessionStorage item",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({
|
||||
key: import_zodBundle.z.string().describe("Key to delete")
|
||||
}),
|
||||
toolName: "browser_sessionstorage_delete",
|
||||
toolParams: ({ key }) => ({ key })
|
||||
});
|
||||
const sessionStorageClear = (0, import_command.declareCommand)({
|
||||
name: "sessionstorage-clear",
|
||||
description: "Clear all sessionStorage",
|
||||
category: "storage",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_sessionstorage_clear",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const routeMock = (0, import_command.declareCommand)({
|
||||
name: "route",
|
||||
description: "Mock network requests matching a URL pattern",
|
||||
category: "network",
|
||||
args: import_zodBundle.z.object({
|
||||
pattern: import_zodBundle.z.string().describe('URL pattern to match (e.g., "**/api/users")')
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
status: numberArg.optional().describe("HTTP status code (default: 200)"),
|
||||
body: import_zodBundle.z.string().optional().describe("Response body (text or JSON string)"),
|
||||
["content-type"]: import_zodBundle.z.string().optional().describe("Content-Type header"),
|
||||
header: import_zodBundle.z.union([import_zodBundle.z.string(), import_zodBundle.z.array(import_zodBundle.z.string())]).optional().transform((v) => v ? Array.isArray(v) ? v : [v] : void 0).describe('Header to add in "Name: Value" format (repeatable)'),
|
||||
["remove-header"]: import_zodBundle.z.string().optional().describe("Comma-separated header names to remove")
|
||||
}),
|
||||
toolName: "browser_route",
|
||||
toolParams: ({ pattern, status, body, ["content-type"]: contentType, header: headers, ["remove-header"]: removeHeaders }) => ({
|
||||
pattern,
|
||||
status,
|
||||
body,
|
||||
contentType,
|
||||
headers,
|
||||
removeHeaders
|
||||
})
|
||||
});
|
||||
const routeList = (0, import_command.declareCommand)({
|
||||
name: "route-list",
|
||||
description: "List all active network routes",
|
||||
category: "network",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_route_list",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const unroute = (0, import_command.declareCommand)({
|
||||
name: "unroute",
|
||||
description: "Remove routes matching a pattern (or all routes)",
|
||||
category: "network",
|
||||
args: import_zodBundle.z.object({
|
||||
pattern: import_zodBundle.z.string().optional().describe("URL pattern to unroute (omit to remove all)")
|
||||
}),
|
||||
toolName: "browser_unroute",
|
||||
toolParams: ({ pattern }) => ({ pattern })
|
||||
});
|
||||
const networkStateSet = (0, import_command.declareCommand)({
|
||||
name: "network-state-set",
|
||||
description: "Set the browser network state to online or offline",
|
||||
category: "network",
|
||||
args: import_zodBundle.z.object({
|
||||
state: import_zodBundle.z.enum(["online", "offline"]).describe('Set to "offline" to simulate offline mode, "online" to restore network connectivity')
|
||||
}),
|
||||
toolName: "browser_network_state_set",
|
||||
toolParams: ({ state }) => ({ state })
|
||||
});
|
||||
const screenshot = (0, import_command.declareCommand)({
|
||||
name: "screenshot",
|
||||
description: "screenshot of the current page or element",
|
||||
category: "export",
|
||||
args: import_zodBundle.z.object({
|
||||
target: import_zodBundle.z.string().optional().describe("Exact target element reference from the page snapshot, or a unique element selector.")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
filename: import_zodBundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified."),
|
||||
["full-page"]: import_zodBundle.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: ({ target, filename, ["full-page"]: fullPage }) => ({ filename, ...asRef(target), fullPage })
|
||||
});
|
||||
const pdfSave = (0, import_command.declareCommand)({
|
||||
name: "pdf",
|
||||
description: "Save page as PDF",
|
||||
category: "export",
|
||||
args: import_zodBundle.z.object({}),
|
||||
options: import_zodBundle.z.object({
|
||||
filename: import_zodBundle.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 consoleList = (0, import_command.declareCommand)({
|
||||
name: "console",
|
||||
description: "List console messages",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({
|
||||
["min-level"]: import_zodBundle.z.string().optional().describe('Level of the console messages to return. Each level includes the messages of more severe levels. Defaults to "info".')
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
clear: import_zodBundle.z.boolean().optional().describe("Whether to clear the console list")
|
||||
}),
|
||||
toolName: ({ clear }) => clear ? "browser_console_clear" : "browser_console_messages",
|
||||
toolParams: ({ ["min-level"]: level, clear }) => clear ? {} : { level }
|
||||
});
|
||||
const networkRequests = (0, import_command.declareCommand)({
|
||||
name: "network",
|
||||
description: "List all network requests since loading the page",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({}),
|
||||
options: import_zodBundle.z.object({
|
||||
static: import_zodBundle.z.boolean().optional().describe("Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false."),
|
||||
["request-body"]: import_zodBundle.z.boolean().optional().describe("Whether to include request body. Defaults to false."),
|
||||
["request-headers"]: import_zodBundle.z.boolean().optional().describe("Whether to include request headers. Defaults to false."),
|
||||
filter: import_zodBundle.z.string().optional().describe('Only return requests whose URL matches this regexp (e.g. "/api/.*user").'),
|
||||
clear: import_zodBundle.z.boolean().optional().describe("Whether to clear the network list")
|
||||
}),
|
||||
toolName: ({ clear }) => clear ? "browser_network_clear" : "browser_network_requests",
|
||||
toolParams: ({ static: s, "request-body": requestBody, "request-headers": requestHeaders, filter, clear }) => clear ? {} : { static: s, requestBody, requestHeaders, filter }
|
||||
});
|
||||
const tracingStart = (0, import_command.declareCommand)({
|
||||
name: "tracing-start",
|
||||
description: "Start trace recording",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_start_tracing",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const tracingStop = (0, import_command.declareCommand)({
|
||||
name: "tracing-stop",
|
||||
description: "Stop trace recording",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_stop_tracing",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const videoStart = (0, import_command.declareCommand)({
|
||||
name: "video-start",
|
||||
description: "Start video recording",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({
|
||||
filename: import_zodBundle.z.string().optional().describe("Filename to save the video.")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
size: import_zodBundle.z.string().optional().describe('Video frame size, e.g. "800x600". If not specified, the size of the recorded video will fit 800x800.')
|
||||
}),
|
||||
toolName: "browser_start_video",
|
||||
toolParams: ({ filename, size }) => {
|
||||
const parsedSize = size ? size.split("x").map(Number) : void 0;
|
||||
return { filename, size: parsedSize ? { width: parsedSize[0], height: parsedSize[1] } : void 0 };
|
||||
}
|
||||
});
|
||||
const videoStop = (0, import_command.declareCommand)({
|
||||
name: "video-stop",
|
||||
description: "Stop video recording",
|
||||
category: "devtools",
|
||||
toolName: "browser_stop_video",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const videoChapter = (0, import_command.declareCommand)({
|
||||
name: "video-chapter",
|
||||
description: "Add a chapter marker to the video recording",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({
|
||||
title: import_zodBundle.z.string().describe("Chapter title.")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
description: import_zodBundle.z.string().optional().describe("Chapter description."),
|
||||
duration: numberArg.optional().describe("Duration in milliseconds to show the chapter card.")
|
||||
}),
|
||||
toolName: "browser_video_chapter",
|
||||
toolParams: ({ title, description, duration }) => ({ title, description, duration })
|
||||
});
|
||||
const devtoolsShow = (0, import_command.declareCommand)({
|
||||
name: "show",
|
||||
description: "Show browser DevTools",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const resume = (0, import_command.declareCommand)({
|
||||
name: "resume",
|
||||
description: "Resume the test execution",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_resume",
|
||||
toolParams: ({ step }) => ({ step })
|
||||
});
|
||||
const stepOver = (0, import_command.declareCommand)({
|
||||
name: "step-over",
|
||||
description: "Step over the next call in the test",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({}),
|
||||
toolName: "browser_resume",
|
||||
toolParams: ({}) => ({ step: true })
|
||||
});
|
||||
const pauseAt = (0, import_command.declareCommand)({
|
||||
name: "pause-at",
|
||||
description: "Run the test up to a specific location and pause there",
|
||||
category: "devtools",
|
||||
args: import_zodBundle.z.object({
|
||||
location: import_zodBundle.z.string().describe('Location to pause at. Format is <file>:<line>, e.g. "example.spec.ts:42".')
|
||||
}),
|
||||
toolName: "browser_resume",
|
||||
toolParams: ({ location }) => ({ location })
|
||||
});
|
||||
const sessionList = (0, import_command.declareCommand)({
|
||||
name: "list",
|
||||
description: "List browser sessions",
|
||||
category: "browsers",
|
||||
args: import_zodBundle.z.object({}),
|
||||
options: import_zodBundle.z.object({
|
||||
all: import_zodBundle.z.boolean().optional().describe("List all browser sessions across all workspaces")
|
||||
}),
|
||||
toolName: "",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const sessionCloseAll = (0, import_command.declareCommand)({
|
||||
name: "close-all",
|
||||
description: "Close all browser sessions",
|
||||
category: "browsers",
|
||||
toolName: "",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const killAll = (0, import_command.declareCommand)({
|
||||
name: "kill-all",
|
||||
description: "Forcefully kill all browser sessions (for stale/zombie processes)",
|
||||
category: "browsers",
|
||||
toolName: "",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const deleteData = (0, import_command.declareCommand)({
|
||||
name: "delete-data",
|
||||
description: "Delete session data",
|
||||
category: "core",
|
||||
toolName: "",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const configPrint = (0, import_command.declareCommand)({
|
||||
name: "config-print",
|
||||
description: "Print the final resolved config after merging CLI options, environment variables and config file.",
|
||||
category: "config",
|
||||
hidden: true,
|
||||
toolName: "browser_get_config",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const install = (0, import_command.declareCommand)({
|
||||
name: "install",
|
||||
description: "Initialize workspace",
|
||||
category: "install",
|
||||
args: import_zodBundle.z.object({}),
|
||||
options: import_zodBundle.z.object({
|
||||
skills: import_zodBundle.z.string().optional().describe('Install skills to ".claude" (default) or ".agents" dir')
|
||||
}),
|
||||
toolName: "",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const installBrowser = (0, import_command.declareCommand)({
|
||||
name: "install-browser",
|
||||
description: "Install browser",
|
||||
category: "install",
|
||||
args: import_zodBundle.z.object({
|
||||
browser: import_zodBundle.z.string().optional().describe("Browser to install")
|
||||
}),
|
||||
options: import_zodBundle.z.object({
|
||||
["with-deps"]: import_zodBundle.z.boolean().optional().describe("Install system dependencies for browsers"),
|
||||
["dry-run"]: import_zodBundle.z.boolean().optional().describe("Do not execute installation, only print information"),
|
||||
list: import_zodBundle.z.boolean().optional().describe("Prints list of browsers from all Playwright installations"),
|
||||
force: import_zodBundle.z.boolean().optional().describe("Force reinstall of already installed browsers"),
|
||||
["only-shell"]: import_zodBundle.z.boolean().optional().describe("Only install headless shell when installing Chromium"),
|
||||
["no-shell"]: import_zodBundle.z.boolean().optional().describe("Do not install Chromium headless shell")
|
||||
}),
|
||||
toolName: "",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const tray = (0, import_command.declareCommand)({
|
||||
name: "tray",
|
||||
description: "Run tray",
|
||||
category: "config",
|
||||
hidden: true,
|
||||
toolName: "",
|
||||
toolParams: () => ({})
|
||||
});
|
||||
const commandsArray = [
|
||||
// core category
|
||||
open,
|
||||
attach,
|
||||
close,
|
||||
goto,
|
||||
type,
|
||||
click,
|
||||
doubleClick,
|
||||
fill,
|
||||
drag,
|
||||
hover,
|
||||
select,
|
||||
fileUpload,
|
||||
check,
|
||||
uncheck,
|
||||
snapshot,
|
||||
evaluate,
|
||||
consoleList,
|
||||
dialogAccept,
|
||||
dialogDismiss,
|
||||
resize,
|
||||
runCode,
|
||||
deleteData,
|
||||
// navigation category
|
||||
goBack,
|
||||
goForward,
|
||||
reload,
|
||||
// keyboard category
|
||||
pressKey,
|
||||
keydown,
|
||||
keyup,
|
||||
// mouse category
|
||||
mouseMove,
|
||||
mouseDown,
|
||||
mouseUp,
|
||||
mouseWheel,
|
||||
// export category
|
||||
screenshot,
|
||||
pdfSave,
|
||||
// tabs category
|
||||
tabList,
|
||||
tabNew,
|
||||
tabClose,
|
||||
tabSelect,
|
||||
// storage category
|
||||
stateLoad,
|
||||
stateSave,
|
||||
cookieList,
|
||||
cookieGet,
|
||||
cookieSet,
|
||||
cookieDelete,
|
||||
cookieClear,
|
||||
localStorageList,
|
||||
localStorageGet,
|
||||
localStorageSet,
|
||||
localStorageDelete,
|
||||
localStorageClear,
|
||||
sessionStorageList,
|
||||
sessionStorageGet,
|
||||
sessionStorageSet,
|
||||
sessionStorageDelete,
|
||||
sessionStorageClear,
|
||||
// network category
|
||||
routeMock,
|
||||
routeList,
|
||||
unroute,
|
||||
networkStateSet,
|
||||
// config category
|
||||
configPrint,
|
||||
// install category
|
||||
install,
|
||||
installBrowser,
|
||||
// devtools category
|
||||
networkRequests,
|
||||
tracingStart,
|
||||
tracingStop,
|
||||
videoStart,
|
||||
videoStop,
|
||||
videoChapter,
|
||||
devtoolsShow,
|
||||
pauseAt,
|
||||
resume,
|
||||
stepOver,
|
||||
// session category
|
||||
sessionList,
|
||||
sessionCloseAll,
|
||||
killAll,
|
||||
// Hidden commands
|
||||
tray
|
||||
];
|
||||
const commands = Object.fromEntries(commandsArray.map((cmd) => [cmd.name, cmd]));
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
commands
|
||||
});
|
||||
157
node_modules/playwright-core/lib/tools/cli-daemon/daemon.js
generated
vendored
Normal file
157
node_modules/playwright-core/lib/tools/cli-daemon/daemon.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
"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, {
|
||||
startCliDaemonServer: () => startCliDaemonServer
|
||||
});
|
||||
module.exports = __toCommonJS(daemon_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_net = __toESM(require("net"));
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_network = require("../../server/utils/network");
|
||||
var import_fileUtils = require("../../server/utils/fileUtils");
|
||||
var import_processLauncher = require("../../server/utils/processLauncher");
|
||||
var import_browserBackend = require("../backend/browserBackend");
|
||||
var import_tools = require("../backend/tools");
|
||||
var import_command = require("./command");
|
||||
var import_commands = require("./commands");
|
||||
var import_socketConnection = require("../utils/socketConnection");
|
||||
var import_registry = require("../cli-client/registry");
|
||||
async function socketExists(socketPath) {
|
||||
try {
|
||||
const stat = await import_fs.default.promises.stat(socketPath);
|
||||
if (stat?.isSocket())
|
||||
return true;
|
||||
} catch (e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
async function startCliDaemonServer(sessionName, browserContext, browserInfo, contextConfig = {}, clientInfo = (0, import_registry.createClientInfo)(), options) {
|
||||
const sessionConfig = createSessionConfig(clientInfo, sessionName, browserInfo, options);
|
||||
const { socketPath } = sessionConfig;
|
||||
if (process.platform !== "win32" && await socketExists(socketPath)) {
|
||||
try {
|
||||
await import_fs.default.promises.unlink(socketPath);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const backend = new import_browserBackend.BrowserBackend(contextConfig, browserContext, import_tools.browserTools);
|
||||
await backend.initialize({ cwd: process.cwd() });
|
||||
if (browserContext.isClosed())
|
||||
throw new Error("Browser context was closed before the daemon could start");
|
||||
const server = import_net.default.createServer((socket) => {
|
||||
const connection = new import_socketConnection.SocketConnection(socket);
|
||||
connection.onmessage = async (message) => {
|
||||
const { id, method, params } = message;
|
||||
try {
|
||||
if (method === "stop") {
|
||||
await deleteSessionFile(clientInfo, sessionConfig);
|
||||
const sendAck = async () => connection.send({ id, result: "ok" }).catch(() => {
|
||||
});
|
||||
if (options?.exitOnClose)
|
||||
(0, import_processLauncher.gracefullyProcessExitDoNotHang)(0, () => sendAck());
|
||||
else
|
||||
await sendAck();
|
||||
} else if (method === "run") {
|
||||
const { toolName, toolParams } = parseCliCommand(params.args);
|
||||
if (params.cwd)
|
||||
toolParams._meta = { cwd: params.cwd };
|
||||
const response = await backend.callTool(toolName, toolParams);
|
||||
await connection.send({ id, result: formatResult(response) });
|
||||
} else {
|
||||
throw new Error(`Unknown method: ${method}`);
|
||||
}
|
||||
} catch (e) {
|
||||
const error = process.env.PWDEBUGIMPL ? e.stack || e.message : e.message;
|
||||
connection.send({ id, error }).catch(() => {
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
(0, import_network.decorateServer)(server);
|
||||
browserContext.on("close", () => Promise.resolve().then(async () => {
|
||||
await deleteSessionFile(clientInfo, sessionConfig);
|
||||
if (options?.exitOnClose)
|
||||
(0, import_processLauncher.gracefullyProcessExitDoNotHang)(0);
|
||||
}));
|
||||
await new Promise((resolve, reject) => {
|
||||
server.on("error", reject);
|
||||
server.listen(socketPath, () => resolve());
|
||||
});
|
||||
await saveSessionFile(clientInfo, sessionConfig);
|
||||
return socketPath;
|
||||
}
|
||||
async function saveSessionFile(clientInfo, sessionConfig) {
|
||||
await import_fs.default.promises.mkdir(clientInfo.daemonProfilesDir, { recursive: true });
|
||||
const sessionFile = import_path.default.join(clientInfo.daemonProfilesDir, `${sessionConfig.name}.session`);
|
||||
await import_fs.default.promises.writeFile(sessionFile, JSON.stringify(sessionConfig, null, 2));
|
||||
}
|
||||
async function deleteSessionFile(clientInfo, sessionConfig) {
|
||||
await import_fs.default.promises.unlink(sessionConfig.socketPath).catch(() => {
|
||||
});
|
||||
if (!sessionConfig.cli.persistent) {
|
||||
const sessionFile = import_path.default.join(clientInfo.daemonProfilesDir, `${sessionConfig.name}.session`);
|
||||
await import_fs.default.promises.rm(sessionFile).catch(() => {
|
||||
});
|
||||
}
|
||||
}
|
||||
function formatResult(result) {
|
||||
const isError = result.isError;
|
||||
const text = result.content[0].type === "text" ? result.content[0].text : void 0;
|
||||
return { isError, text };
|
||||
}
|
||||
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);
|
||||
}
|
||||
function daemonSocketPath(clientInfo, sessionName) {
|
||||
return (0, import_fileUtils.makeSocketPath)("cli", `${clientInfo.workspaceDirHash}-${sessionName}`);
|
||||
}
|
||||
function createSessionConfig(clientInfo, sessionName, browserInfo, options = {}) {
|
||||
return {
|
||||
name: sessionName,
|
||||
version: clientInfo.version,
|
||||
timestamp: Date.now(),
|
||||
socketPath: daemonSocketPath(clientInfo, sessionName),
|
||||
workspaceDir: clientInfo.workspaceDir,
|
||||
cli: { persistent: options.persistent },
|
||||
browser: {
|
||||
browserName: browserInfo.browserName,
|
||||
launchOptions: browserInfo.launchOptions,
|
||||
userDataDir: browserInfo.userDataDir
|
||||
}
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
startCliDaemonServer
|
||||
});
|
||||
177
node_modules/playwright-core/lib/tools/cli-daemon/helpGenerator.js
generated
vendored
Normal file
177
node_modules/playwright-core/lib/tools/cli-daemon/helpGenerator.js
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
"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 helpGenerator_exports = {};
|
||||
__export(helpGenerator_exports, {
|
||||
generateHelp: () => generateHelp,
|
||||
generateHelpJSON: () => generateHelpJSON,
|
||||
generateReadme: () => generateReadme
|
||||
});
|
||||
module.exports = __toCommonJS(helpGenerator_exports);
|
||||
var import_zodBundle = require("../../zodBundle");
|
||||
var import_commands = require("./commands");
|
||||
function commandArgs(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, optional: zodSchema.safeParse(void 0).success });
|
||||
}
|
||||
return args;
|
||||
}
|
||||
function commandArgsText(args) {
|
||||
return args.map((a) => a.optional ? `[${a.name}]` : `<${a.name}>`).join(" ");
|
||||
}
|
||||
function generateCommandHelp(command) {
|
||||
const args = commandArgs(command);
|
||||
const lines = [
|
||||
`playwright-cli ${command.name} ${commandArgsText(args)}`,
|
||||
"",
|
||||
command.description,
|
||||
""
|
||||
];
|
||||
if (args.length) {
|
||||
lines.push("Arguments:");
|
||||
lines.push(...args.map((a) => formatWithGap(` ${a.optional ? `[${a.name}]` : `<${a.name}>`}`, a.description.toLowerCase())));
|
||||
}
|
||||
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(formatWithGap(` --${name}`, description));
|
||||
}
|
||||
}
|
||||
return lines.join("\n");
|
||||
}
|
||||
const categories = [
|
||||
{ name: "core", title: "Core" },
|
||||
{ name: "navigation", title: "Navigation" },
|
||||
{ name: "keyboard", title: "Keyboard" },
|
||||
{ name: "mouse", title: "Mouse" },
|
||||
{ name: "export", title: "Save as" },
|
||||
{ name: "tabs", title: "Tabs" },
|
||||
{ name: "storage", title: "Storage" },
|
||||
{ name: "network", title: "Network" },
|
||||
{ name: "devtools", title: "DevTools" },
|
||||
{ name: "install", title: "Install" },
|
||||
{ name: "config", title: "Configuration" },
|
||||
{ name: "browsers", title: "Browser sessions" }
|
||||
];
|
||||
function generateHelp() {
|
||||
const lines = [];
|
||||
lines.push("Usage: playwright-cli <command> [args] [options]");
|
||||
lines.push("Usage: playwright-cli -s=<session> <command> [args] [options]");
|
||||
const commandsByCategory = /* @__PURE__ */ new Map();
|
||||
for (const c of categories)
|
||||
commandsByCategory.set(c.name, []);
|
||||
for (const command of Object.values(import_commands.commands)) {
|
||||
if (command.hidden)
|
||||
continue;
|
||||
commandsByCategory.get(command.category).push(command);
|
||||
}
|
||||
for (const c of categories) {
|
||||
const cc = commandsByCategory.get(c.name);
|
||||
if (!cc.length)
|
||||
continue;
|
||||
lines.push(`
|
||||
${c.title}:`);
|
||||
for (const command of cc)
|
||||
lines.push(generateHelpEntry(command));
|
||||
}
|
||||
lines.push("\nGlobal options:");
|
||||
lines.push(formatWithGap(" --help [command]", "print help"));
|
||||
lines.push(formatWithGap(" --version", "print version"));
|
||||
return lines.join("\n");
|
||||
}
|
||||
function generateReadme() {
|
||||
const lines = [];
|
||||
lines.push("\n## Commands");
|
||||
const commandsByCategory = /* @__PURE__ */ new Map();
|
||||
for (const c of categories)
|
||||
commandsByCategory.set(c.name, []);
|
||||
for (const command of Object.values(import_commands.commands))
|
||||
commandsByCategory.get(command.category).push(command);
|
||||
for (const c of categories) {
|
||||
const cc = commandsByCategory.get(c.name);
|
||||
if (!cc.length)
|
||||
continue;
|
||||
lines.push(`
|
||||
### ${c.title}
|
||||
`);
|
||||
lines.push("```bash");
|
||||
for (const command of cc)
|
||||
lines.push(generateReadmeEntry(command));
|
||||
lines.push("```");
|
||||
}
|
||||
return lines.join("\n");
|
||||
}
|
||||
function generateHelpEntry(command) {
|
||||
const args = commandArgs(command);
|
||||
const prefix = ` ${command.name} ${commandArgsText(args)}`;
|
||||
const suffix = command.description.toLowerCase();
|
||||
return formatWithGap(prefix, suffix);
|
||||
}
|
||||
function generateReadmeEntry(command) {
|
||||
const args = commandArgs(command);
|
||||
const prefix = `playwright-cli ${command.name} ${commandArgsText(args)}`;
|
||||
const suffix = "# " + command.description.toLowerCase();
|
||||
return formatWithGap(prefix, suffix, 40);
|
||||
}
|
||||
function unwrapZodType(schema) {
|
||||
if ("unwrap" in schema && typeof schema.unwrap === "function")
|
||||
return unwrapZodType(schema.unwrap());
|
||||
return schema;
|
||||
}
|
||||
function isBooleanSchema(schema) {
|
||||
return unwrapZodType(schema) instanceof import_zodBundle.z.ZodBoolean;
|
||||
}
|
||||
function generateHelpJSON() {
|
||||
const booleanOptions = /* @__PURE__ */ new Set();
|
||||
const commandEntries = {};
|
||||
for (const [name, command] of Object.entries(import_commands.commands)) {
|
||||
const flags = {};
|
||||
if (command.options) {
|
||||
const optionsShape = command.options.shape;
|
||||
for (const [flagName, schema] of Object.entries(optionsShape)) {
|
||||
const isBoolean = isBooleanSchema(schema);
|
||||
flags[flagName] = isBoolean ? "boolean" : "string";
|
||||
if (isBoolean)
|
||||
booleanOptions.add(flagName);
|
||||
}
|
||||
}
|
||||
commandEntries[name] = { help: generateCommandHelp(command), flags };
|
||||
}
|
||||
return {
|
||||
global: generateHelp(),
|
||||
commands: commandEntries,
|
||||
booleanOptions: [...booleanOptions]
|
||||
};
|
||||
}
|
||||
function formatWithGap(prefix, text, threshold = 30) {
|
||||
const indent = Math.max(1, threshold - prefix.length);
|
||||
return prefix + " ".repeat(indent) + text;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
generateHelp,
|
||||
generateHelpJSON,
|
||||
generateReadme
|
||||
});
|
||||
129
node_modules/playwright-core/lib/tools/cli-daemon/program.js
generated
vendored
Normal file
129
node_modules/playwright-core/lib/tools/cli-daemon/program.js
generated
vendored
Normal 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 __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_os = __toESM(require("os"));
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_daemon = require("./daemon");
|
||||
var import_watchdog = require("../mcp/watchdog");
|
||||
var import_browserFactory = require("../mcp/browserFactory");
|
||||
var configUtils = __toESM(require("../mcp/config"));
|
||||
var import_registry = require("../cli-client/registry");
|
||||
var import_utilsBundle = require("../../utilsBundle");
|
||||
var import_registry2 = require("../../server/registry/index");
|
||||
import_utilsBundle.program.argument("[session-name]", "name of the session to create or connect to", "default").option("--headed", "run in headed mode (non-headless)").option("--extension", "run with the extension").option("--browser <name>", "browser to use (chromium, chrome, firefox, webkit)").option("--persistent", "use a persistent browser context").option("--profile <path>", "path to the user data dir").option("--config <path>", "path to the config file; by default uses .playwright/cli.config.json in the project directory and ~/.playwright/cli.config.json as global config").option("--endpoint <endpoint>", "attach to a running Playwright browser endpoint").option("--init-workspace", "initialize workspace").option("--init-skills <value>", 'install skills for the given agent type ("claude" or "agents")').action(async (sessionName, options) => {
|
||||
if (options.initWorkspace) {
|
||||
await initWorkspace(options.initSkills);
|
||||
return;
|
||||
}
|
||||
(0, import_watchdog.setupExitWatchdog)();
|
||||
const clientInfo = (0, import_registry.createClientInfo)();
|
||||
const mcpConfig = await configUtils.resolveCLIConfigForCLI(clientInfo.daemonProfilesDir, sessionName, options);
|
||||
const clientInfoEx = {
|
||||
cwd: process.cwd(),
|
||||
sessionName,
|
||||
workspaceDir: clientInfo.workspaceDir
|
||||
};
|
||||
try {
|
||||
const { browser, browserInfo } = await (0, import_browserFactory.createBrowserWithInfo)(mcpConfig, clientInfoEx);
|
||||
const browserContext = mcpConfig.browser.isolated ? await browser.newContext(mcpConfig.browser.contextOptions) : browser.contexts()[0];
|
||||
if (!browserContext)
|
||||
throw new Error("Error: unable to connect to a browser that does not have any contexts");
|
||||
const persistent = options.persistent || options.profile || mcpConfig.browser.userDataDir ? true : void 0;
|
||||
const socketPath = await (0, import_daemon.startCliDaemonServer)(sessionName, browserContext, browserInfo, mcpConfig, clientInfo, { persistent, exitOnClose: true });
|
||||
console.log(`### Success
|
||||
Daemon listening on ${socketPath}`);
|
||||
console.log("<EOF>");
|
||||
} catch (error) {
|
||||
const message = process.env.PWDEBUGIMPL ? error.stack || error.message : error.message;
|
||||
console.log(`### Error
|
||||
${message}`);
|
||||
console.log("<EOF>");
|
||||
}
|
||||
});
|
||||
void import_utilsBundle.program.parseAsync();
|
||||
function defaultConfigFile() {
|
||||
return import_path.default.resolve(".playwright", "cli.config.json");
|
||||
}
|
||||
function globalConfigFile() {
|
||||
return import_path.default.join(process.env["PWTEST_CLI_GLOBAL_CONFIG"] ?? import_os.default.homedir(), ".playwright", "cli.config.json");
|
||||
}
|
||||
async function initWorkspace(initSkills) {
|
||||
const cwd = process.cwd();
|
||||
const playwrightDir = import_path.default.join(cwd, ".playwright");
|
||||
await import_fs.default.promises.mkdir(playwrightDir, { recursive: true });
|
||||
console.log(`\u2705 Workspace initialized at \`${cwd}\`.`);
|
||||
if (initSkills) {
|
||||
const skillSourceDir = import_path.default.join(__dirname, "../cli-client/skill");
|
||||
const target = initSkills === "agents" ? "agents" : "claude";
|
||||
const skillDestDir = import_path.default.join(cwd, `.${target}`, "skills", "playwright-cli");
|
||||
if (!import_fs.default.existsSync(skillSourceDir)) {
|
||||
console.error("\u274C Skills source directory not found:", skillSourceDir);
|
||||
process.exit(1);
|
||||
}
|
||||
await import_fs.default.promises.cp(skillSourceDir, skillDestDir, { recursive: true });
|
||||
console.log(`\u2705 Skills installed to \`${import_path.default.relative(cwd, skillDestDir)}\`.`);
|
||||
}
|
||||
await ensureConfiguredBrowserInstalled();
|
||||
}
|
||||
async function ensureConfiguredBrowserInstalled() {
|
||||
if (import_fs.default.existsSync(defaultConfigFile()) || import_fs.default.existsSync(globalConfigFile())) {
|
||||
const clientInfo = (0, import_registry.createClientInfo)();
|
||||
const config = await configUtils.resolveCLIConfigForCLI(clientInfo.daemonProfilesDir, "default", {});
|
||||
const browserName = config.browser.browserName;
|
||||
const channel = config.browser.launchOptions.channel;
|
||||
if (!channel || channel.startsWith("chromium")) {
|
||||
const executable = import_registry2.registry.findExecutable(channel ?? browserName);
|
||||
if (executable && !import_fs.default.existsSync(executable.executablePath()))
|
||||
await import_registry2.registry.install([executable]);
|
||||
}
|
||||
} else {
|
||||
const channel = await findOrInstallDefaultBrowser();
|
||||
if (channel !== "chrome")
|
||||
await createDefaultConfig(channel);
|
||||
}
|
||||
}
|
||||
async function findOrInstallDefaultBrowser() {
|
||||
const channels = ["chrome", "msedge"];
|
||||
for (const channel of channels) {
|
||||
const executable = import_registry2.registry.findExecutable(channel);
|
||||
if (!executable?.executablePath())
|
||||
continue;
|
||||
console.log(`\u2705 Found ${channel}, will use it as the default browser.`);
|
||||
return channel;
|
||||
}
|
||||
const chromiumExecutable = import_registry2.registry.findExecutable("chromium");
|
||||
if (!import_fs.default.existsSync(chromiumExecutable?.executablePath()))
|
||||
await import_registry2.registry.install([chromiumExecutable]);
|
||||
return "chromium";
|
||||
}
|
||||
async function createDefaultConfig(channel) {
|
||||
const config = {
|
||||
browser: {
|
||||
browserName: "chromium",
|
||||
launchOptions: { channel }
|
||||
}
|
||||
};
|
||||
await import_fs.default.promises.writeFile(defaultConfigFile(), JSON.stringify(config, null, 2));
|
||||
console.log(`\u2705 Created default config for ${channel} at ${import_path.default.relative(process.cwd(), defaultConfigFile())}.`);
|
||||
}
|
||||
Reference in New Issue
Block a user