venetian 0.1.0-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +52 -0
- data/Rakefile +14 -0
- data/exe/aarch64-linux/LICENSE +2946 -0
- data/exe/aarch64-linux/node +0 -0
- data/exe/aarch64-linux/package/LICENSE +202 -0
- data/exe/aarch64-linux/package/NOTICE +5 -0
- data/exe/aarch64-linux/package/README.md +3 -0
- data/exe/aarch64-linux/package/ThirdPartyNotices.txt +13 -0
- data/exe/aarch64-linux/package/api.json +1 -0
- data/exe/aarch64-linux/package/bin/install_media_pack.ps1 +5 -0
- data/exe/aarch64-linux/package/bin/install_webkit_wsl.ps1 +33 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_beta_linux.sh +42 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_beta_mac.sh +13 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_stable_linux.sh +42 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_stable_mac.sh +12 -0
- data/exe/aarch64-linux/package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_beta_linux.sh +48 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_beta_mac.sh +11 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_dev_linux.sh +48 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_dev_mac.sh +11 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_stable_linux.sh +48 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_stable_mac.sh +11 -0
- data/exe/aarch64-linux/package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- data/exe/aarch64-linux/package/browsers.json +81 -0
- data/exe/aarch64-linux/package/cli.js +21 -0
- data/exe/aarch64-linux/package/index.d.ts +17 -0
- data/exe/aarch64-linux/package/index.js +32 -0
- data/exe/aarch64-linux/package/index.mjs +28 -0
- data/exe/aarch64-linux/package/lib/bootstrap.js +77 -0
- data/exe/aarch64-linux/package/lib/coreBundle.js +69799 -0
- data/exe/aarch64-linux/package/lib/entry/cliDaemon.js +5 -0
- data/exe/aarch64-linux/package/lib/entry/dashboardApp.js +3 -0
- data/exe/aarch64-linux/package/lib/entry/mcp.js +10 -0
- data/exe/aarch64-linux/package/lib/entry/oopBrowserDownload.js +3 -0
- data/exe/aarch64-linux/package/lib/package.js +50 -0
- data/exe/aarch64-linux/package/lib/server/chromium/appIcon.png +0 -0
- data/exe/aarch64-linux/package/lib/server/deviceDescriptorsSource.json +1779 -0
- data/exe/aarch64-linux/package/lib/server/electron/loader.js +115 -0
- data/exe/aarch64-linux/package/lib/serverRegistry.js +7343 -0
- data/exe/aarch64-linux/package/lib/serverRegistry.js.LICENSE +354 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/channelSessions.js +141 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/cli.js +6 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/help.json +679 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/minimist.js +128 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/output.js +343 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/program.js +380 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/registry.js +176 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/session.js +265 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/SKILL.md +388 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/element-attributes.md +23 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/playwright-tests.md +39 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/request-mocking.md +87 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/running-code.md +241 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/session-management.md +225 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/spec-driven-testing.md +305 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/storage-state.md +275 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/test-generation.md +134 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/tracing.md +139 -0
- data/exe/aarch64-linux/package/lib/tools/cli-client/skill/references/video-recording.md +143 -0
- data/exe/aarch64-linux/package/lib/tools/dashboard/appIcon.png +0 -0
- data/exe/aarch64-linux/package/lib/tools/trace/SKILL.md +171 -0
- data/exe/aarch64-linux/package/lib/tools/utils/extension.js +78 -0
- data/exe/aarch64-linux/package/lib/tools/utils/socketConnection.js +108 -0
- data/exe/aarch64-linux/package/lib/utilsBundle.js +85418 -0
- data/exe/aarch64-linux/package/lib/utilsBundle.js.LICENSE +2002 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/index-BY2S1tHT.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/index-DpEq2p62.js +52 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/index.html +29 -0
- data/exe/aarch64-linux/package/lib/vite/dashboard/playwright-logo.svg +24 -0
- data/exe/aarch64-linux/package/lib/vite/htmlReport/index.html +16 -0
- data/exe/aarch64-linux/package/lib/vite/htmlReport/report.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/htmlReport/report.js +72 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/assets/codeMirrorModule-BHYmBp6h.js +32 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/assets/codeMirrorModule-DYBRYzYX.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/assets/index-4ZiSSCmn.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/assets/index-DA10QRaq.js +193 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/index.html +29 -0
- data/exe/aarch64-linux/package/lib/vite/recorder/playwright-logo.svg +9 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/assets/codeMirrorModule-Ds_H_9Yq.js +32 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/assets/defaultSettingsView-D31xz8zv.js +262 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/assets/urlMatch-BYQrIQwR.js +1 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/assets/xtermModule-CsJ4vdCR.js +9 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/codeMirrorModule.DYBRYzYX.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/defaultSettingsView.BDKsFU3c.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/index.BCnMPevh.js +2 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/index.CzXZzn5A.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/index.html +44 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/manifest.webmanifest +16 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/snapshot.html +10 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/snapshot.v8KI4P3m.js +2 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/sw.bundle.js +5 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/uiMode.Btcz36p_.css +1 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/uiMode.C2Efnu2P.js +6 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/uiMode.html +18 -0
- data/exe/aarch64-linux/package/lib/vite/traceViewer/xtermModule.DYP7pi_n.css +32 -0
- data/exe/aarch64-linux/package/lib/xdg-open +1066 -0
- data/exe/aarch64-linux/package/package.json +34 -0
- data/exe/aarch64-linux/package/protocol.yml +4884 -0
- data/exe/aarch64-linux/package/types/protocol.d.ts +24565 -0
- data/exe/aarch64-linux/package/types/structs.d.ts +45 -0
- data/exe/aarch64-linux/package/types/types.d.ts +24518 -0
- data/exe/playwright +11 -0
- data/lib/tasks/venetian.rake +11 -0
- data/lib/venetian/browser_installer.rb +26 -0
- data/lib/venetian/browser_runner_extensions.rb +17 -0
- data/lib/venetian/executable.rb +154 -0
- data/lib/venetian/gemspec.rb +7 -0
- data/lib/venetian/playwright_create_extensions.rb +11 -0
- data/lib/venetian/railtie.rb +9 -0
- data/lib/venetian/tasks.rb +3 -0
- data/lib/venetian/upstream.rb +45 -0
- data/lib/venetian/version.rb +5 -0
- data/lib/venetian.rb +29 -0
- metadata +185 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var program_exports = {};
|
|
30
|
+
__export(program_exports, {
|
|
31
|
+
calculateSha1: () => calculateSha1,
|
|
32
|
+
program: () => program
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(program_exports);
|
|
35
|
+
var import_child_process = require("child_process");
|
|
36
|
+
var import_crypto = __toESM(require("crypto"));
|
|
37
|
+
var import_os = __toESM(require("os"));
|
|
38
|
+
var import_path = __toESM(require("path"));
|
|
39
|
+
var import_channelSessions = require("./channelSessions");
|
|
40
|
+
var import_output = require("./output");
|
|
41
|
+
var import_registry = require("./registry");
|
|
42
|
+
var import_session = require("./session");
|
|
43
|
+
var import_package = require("../../package");
|
|
44
|
+
var import_serverRegistry = require("../../serverRegistry");
|
|
45
|
+
var import_minimist = require("./minimist");
|
|
46
|
+
const globalOptions = [
|
|
47
|
+
"json",
|
|
48
|
+
"raw",
|
|
49
|
+
"session"
|
|
50
|
+
];
|
|
51
|
+
const booleanOptions = [
|
|
52
|
+
"all",
|
|
53
|
+
"help",
|
|
54
|
+
"json",
|
|
55
|
+
"raw",
|
|
56
|
+
"version"
|
|
57
|
+
];
|
|
58
|
+
async function program(options) {
|
|
59
|
+
const clientInfo = (0, import_registry.createClientInfo)();
|
|
60
|
+
const help = require((0, import_package.libPath)("tools", "cli-client", "help.json"));
|
|
61
|
+
const argv = process.argv.slice(2);
|
|
62
|
+
const boolean = [...help.booleanOptions, ...booleanOptions];
|
|
63
|
+
const args = (0, import_minimist.minimist)(argv, { boolean, string: ["_"] });
|
|
64
|
+
if (args.s) {
|
|
65
|
+
args.session = args.s;
|
|
66
|
+
delete args.s;
|
|
67
|
+
}
|
|
68
|
+
const output = args.json ? new import_output.JsonOutput() : new import_output.TextOutput();
|
|
69
|
+
const commandName = args._?.[0];
|
|
70
|
+
if (args.version || args.v) {
|
|
71
|
+
output.version(options?.embedderVersion ?? clientInfo.version);
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}
|
|
74
|
+
const command = commandName && help.commands[commandName];
|
|
75
|
+
if (args.help || args.h || !commandName) {
|
|
76
|
+
if (command) {
|
|
77
|
+
output.help(command.help);
|
|
78
|
+
} else {
|
|
79
|
+
const lines = ["playwright-cli - run playwright mcp commands from terminal"];
|
|
80
|
+
if (process.env.CLAUDECODE || process.env.COPILOT_CLI)
|
|
81
|
+
lines.push(`Agent skill: ${import_path.default.relative(process.cwd(), (0, import_package.libPath)("tools", "cli-client", "skill", "SKILL.md"))}`);
|
|
82
|
+
lines.push(help.global);
|
|
83
|
+
output.help(lines.join("\n\n"));
|
|
84
|
+
}
|
|
85
|
+
process.exit(0);
|
|
86
|
+
}
|
|
87
|
+
if (!command)
|
|
88
|
+
output.errorUnknownCommand(commandName, help.global);
|
|
89
|
+
validateFlags(args, command, output);
|
|
90
|
+
validateArgs(args, command, output);
|
|
91
|
+
const registry = await import_registry.Registry.load();
|
|
92
|
+
const sessionName = (0, import_registry.resolveSessionName)(args.session);
|
|
93
|
+
switch (commandName) {
|
|
94
|
+
case "list": {
|
|
95
|
+
const data = await collectList(registry, clientInfo, !!args.all);
|
|
96
|
+
output.list(data);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
case "close-all": {
|
|
100
|
+
const entries = registry.entries(clientInfo);
|
|
101
|
+
const closed = [];
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
await new import_session.Session(entry).stop();
|
|
104
|
+
closed.push(entry.config.name);
|
|
105
|
+
}
|
|
106
|
+
output.closeAll(closed);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
case "delete-data": {
|
|
110
|
+
const entry = registry.entry(clientInfo, sessionName);
|
|
111
|
+
if (!entry) {
|
|
112
|
+
output.deleteData(sessionName, { existed: false, deletedUserDataDir: false });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const result = await new import_session.Session(entry).deleteData();
|
|
116
|
+
output.deleteData(sessionName, result);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
case "kill-all": {
|
|
120
|
+
const pids = await killAllDaemons();
|
|
121
|
+
output.killAll(pids);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
case "open": {
|
|
125
|
+
const { pid } = await startSession(sessionName, registry, clientInfo, args, "open");
|
|
126
|
+
const newEntry = await registry.loadEntry(clientInfo, sessionName);
|
|
127
|
+
const params = args._.slice(1);
|
|
128
|
+
const toolText = await runInSessionOrStop(newEntry, clientInfo, { _: ["goto", ...params.length ? params : ["about:blank"]] }, output);
|
|
129
|
+
output.open(sessionName, pid, toolText);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
case "attach": {
|
|
133
|
+
const attachTarget = args._[1];
|
|
134
|
+
if (attachTarget && (args.cdp || args.endpoint || args.extension))
|
|
135
|
+
output.errorAttachConflict();
|
|
136
|
+
if (attachTarget)
|
|
137
|
+
args.endpoint = attachTarget;
|
|
138
|
+
const extensionChannel = typeof args.extension === "string" ? args.extension : void 0;
|
|
139
|
+
if (extensionChannel) {
|
|
140
|
+
args.browser = extensionChannel;
|
|
141
|
+
args.extension = true;
|
|
142
|
+
}
|
|
143
|
+
const cdpChannel = typeof args.cdp === "string" && (0, import_channelSessions.isKnownChannel)(args.cdp) ? args.cdp : void 0;
|
|
144
|
+
const targetName = attachTarget ?? cdpChannel ?? extensionChannel ?? args.cdp;
|
|
145
|
+
if (!targetName)
|
|
146
|
+
output.errorAttachNoTarget();
|
|
147
|
+
const attachSessionName = (0, import_registry.explicitSessionName)(args.session) ?? attachTarget ?? cdpChannel ?? extensionChannel ?? sessionName;
|
|
148
|
+
args.session = attachSessionName;
|
|
149
|
+
const { pid } = await startSession(attachSessionName, registry, clientInfo, args, "attach");
|
|
150
|
+
const newEntry = await registry.loadEntry(clientInfo, attachSessionName);
|
|
151
|
+
const toolText = await runInSessionOrStop(newEntry, clientInfo, { _: ["snapshot"], filename: "<auto>" }, output);
|
|
152
|
+
output.attach(attachSessionName, pid, targetName, toolText);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
case "close": {
|
|
156
|
+
const closeEntry = registry.entry(clientInfo, sessionName);
|
|
157
|
+
const { wasOpen } = closeEntry ? await new import_session.Session(closeEntry).stop() : { wasOpen: false };
|
|
158
|
+
output.close(sessionName, wasOpen);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
case "detach": {
|
|
162
|
+
const detachEntry = registry.entry(clientInfo, sessionName);
|
|
163
|
+
if (detachEntry && !detachEntry.config.attached)
|
|
164
|
+
output.errorDetachNotAttached(sessionName);
|
|
165
|
+
const { wasOpen } = detachEntry ? await new import_session.Session(detachEntry).stop() : { wasOpen: false };
|
|
166
|
+
output.detach(sessionName, wasOpen);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
case "install":
|
|
170
|
+
await runInitWorkspace(args, output);
|
|
171
|
+
output.installed();
|
|
172
|
+
return;
|
|
173
|
+
case "install-browser":
|
|
174
|
+
await installBrowser();
|
|
175
|
+
output.installed();
|
|
176
|
+
return;
|
|
177
|
+
case "show": {
|
|
178
|
+
const daemonScript = (0, import_package.libPath)("entry", "dashboardApp.js");
|
|
179
|
+
const daemonArgs = [
|
|
180
|
+
daemonScript,
|
|
181
|
+
`--sessionName=${sessionName}`,
|
|
182
|
+
`--workspaceDir=${clientInfo.workspaceDir ?? ""}`
|
|
183
|
+
];
|
|
184
|
+
if (args.port !== void 0)
|
|
185
|
+
daemonArgs.push(`--port=${args.port}`);
|
|
186
|
+
if (args.host !== void 0)
|
|
187
|
+
daemonArgs.push(`--host=${args.host}`);
|
|
188
|
+
if (args.kill) {
|
|
189
|
+
daemonArgs.push(`--kill`);
|
|
190
|
+
const child2 = (0, import_child_process.spawn)(process.execPath, daemonArgs, { stdio: "ignore" });
|
|
191
|
+
await new Promise((resolve) => child2.on("exit", () => resolve()));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (args.annotate) {
|
|
195
|
+
const entry = registry.entry(clientInfo, sessionName);
|
|
196
|
+
if (!entry)
|
|
197
|
+
output.errorBrowserNotOpenForTool(sessionName);
|
|
198
|
+
args.raw = true;
|
|
199
|
+
const text = await runInSession(entry, clientInfo, args, output);
|
|
200
|
+
output.toolResult(text);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const foreground = args.port !== void 0;
|
|
204
|
+
const child = (0, import_child_process.spawn)(process.execPath, daemonArgs, {
|
|
205
|
+
detached: !foreground,
|
|
206
|
+
stdio: foreground ? "inherit" : "ignore"
|
|
207
|
+
});
|
|
208
|
+
if (foreground) {
|
|
209
|
+
await new Promise((resolve) => child.on("exit", () => resolve()));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
child.unref();
|
|
213
|
+
output.show(sessionName, child.pid);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
default: {
|
|
217
|
+
const entry = registry.entry(clientInfo, sessionName);
|
|
218
|
+
if (!entry)
|
|
219
|
+
output.errorBrowserNotOpenForTool(sessionName);
|
|
220
|
+
if (command.raw)
|
|
221
|
+
args.raw = true;
|
|
222
|
+
const text = await runInSession(entry, clientInfo, args, output);
|
|
223
|
+
output.toolResult(text);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async function startSession(sessionName, registry, clientInfo, args, mode) {
|
|
228
|
+
const entry = registry.entry(clientInfo, sessionName);
|
|
229
|
+
if (entry)
|
|
230
|
+
await new import_session.Session(entry).stop();
|
|
231
|
+
return await import_session.Session.startDaemon(clientInfo, args, mode);
|
|
232
|
+
}
|
|
233
|
+
async function runInSession(entry, clientInfo, args, output) {
|
|
234
|
+
const raw = !!args.raw;
|
|
235
|
+
for (const globalOption of globalOptions)
|
|
236
|
+
delete args[globalOption];
|
|
237
|
+
const session = new import_session.Session(entry);
|
|
238
|
+
const result = await session.run(clientInfo, args, { raw, json: output.json });
|
|
239
|
+
return result.text;
|
|
240
|
+
}
|
|
241
|
+
async function runInSessionOrStop(entry, clientInfo, args, output) {
|
|
242
|
+
try {
|
|
243
|
+
return await runInSession(entry, clientInfo, args, output);
|
|
244
|
+
} catch (e) {
|
|
245
|
+
await new import_session.Session(entry).stop().catch(() => {
|
|
246
|
+
});
|
|
247
|
+
throw e;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
async function runInitWorkspace(args, output) {
|
|
251
|
+
const cliPath = (0, import_package.libPath)("entry", "cliDaemon.js");
|
|
252
|
+
const daemonArgs = [cliPath, "--init-workspace", ...args.skills ? ["--init-skills", String(args.skills)] : []];
|
|
253
|
+
await new Promise((resolve, reject) => {
|
|
254
|
+
const child = (0, import_child_process.spawn)(process.execPath, daemonArgs, {
|
|
255
|
+
stdio: output.installStdio(),
|
|
256
|
+
cwd: process.cwd()
|
|
257
|
+
});
|
|
258
|
+
child.on("close", (code) => {
|
|
259
|
+
if (code === 0)
|
|
260
|
+
resolve();
|
|
261
|
+
else
|
|
262
|
+
reject(new Error(`Workspace initialization failed with exit code ${code}`));
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
async function installBrowser() {
|
|
267
|
+
const argv = process.argv.map((arg) => arg === "install-browser" ? "install" : arg);
|
|
268
|
+
const { libCli } = require("../../coreBundle.js");
|
|
269
|
+
const { program: program2 } = require("../../utilsBundle.js");
|
|
270
|
+
if (!program2.version())
|
|
271
|
+
libCli.decorateProgram(program2);
|
|
272
|
+
program2.parse(argv);
|
|
273
|
+
}
|
|
274
|
+
const daemonProcessPatterns = ["run-mcp-server", "run-cli-server", "cli-daemon", "cliDaemon.js", "dashboardApp.js"];
|
|
275
|
+
async function killAllDaemons() {
|
|
276
|
+
const platform = import_os.default.platform();
|
|
277
|
+
const pidFilterEnv = process.env.PWTEST_KILL_ALL_PID_FILTER_FOR_TEST;
|
|
278
|
+
const pidFilter = pidFilterEnv ? new Set(pidFilterEnv.split(",").map((p) => parseInt(p, 10)).filter((n) => !isNaN(n))) : void 0;
|
|
279
|
+
const killed = [];
|
|
280
|
+
try {
|
|
281
|
+
if (platform === "win32") {
|
|
282
|
+
const clauses = [`(${daemonProcessPatterns.map((p) => `$_.CommandLine -like '*${p}*'`).join(" -or ")})`];
|
|
283
|
+
if (pidFilter)
|
|
284
|
+
clauses.push(`(${[...pidFilter].map((p) => `$_.ProcessId -eq ${p}`).join(" -or ")})`);
|
|
285
|
+
const whereClause = clauses.join(" -and ");
|
|
286
|
+
const result = (0, import_child_process.execSync)(
|
|
287
|
+
`powershell -NoProfile -NonInteractive -Command "Get-CimInstance Win32_Process | Where-Object { ${whereClause} } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue; $_.ProcessId }"`,
|
|
288
|
+
{ encoding: "utf-8" }
|
|
289
|
+
);
|
|
290
|
+
const pids = result.split("\n").map((line) => line.trim()).filter((line) => /^\d+$/.test(line));
|
|
291
|
+
for (const pid of pids)
|
|
292
|
+
killed.push(parseInt(pid, 10));
|
|
293
|
+
} else {
|
|
294
|
+
const result = (0, import_child_process.execSync)("ps auxww", { encoding: "utf-8" });
|
|
295
|
+
const lines = result.split("\n");
|
|
296
|
+
for (const line of lines) {
|
|
297
|
+
if (daemonProcessPatterns.some((p) => line.includes(p))) {
|
|
298
|
+
const parts = line.trim().split(/\s+/);
|
|
299
|
+
const pid = parts[1];
|
|
300
|
+
if (pid && /^\d+$/.test(pid)) {
|
|
301
|
+
const numericPid = parseInt(pid, 10);
|
|
302
|
+
if (pidFilter && !pidFilter.has(numericPid))
|
|
303
|
+
continue;
|
|
304
|
+
try {
|
|
305
|
+
process.kill(numericPid, "SIGKILL");
|
|
306
|
+
killed.push(numericPid);
|
|
307
|
+
} catch {
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
} catch (e) {
|
|
314
|
+
}
|
|
315
|
+
return killed;
|
|
316
|
+
}
|
|
317
|
+
async function collectList(registry, clientInfo, all) {
|
|
318
|
+
const browsers = [];
|
|
319
|
+
const entries = registry.entryMap();
|
|
320
|
+
const serverEntries = await import_serverRegistry.serverRegistry.list();
|
|
321
|
+
const key = (0, import_registry.clientKey)(clientInfo);
|
|
322
|
+
for (const [workspaceKey, list] of entries) {
|
|
323
|
+
if (!all && workspaceKey !== key)
|
|
324
|
+
continue;
|
|
325
|
+
for (const entry of list) {
|
|
326
|
+
const session = new import_session.Session(entry);
|
|
327
|
+
const canConnect = await session.canConnect();
|
|
328
|
+
if (!canConnect) {
|
|
329
|
+
await session.deleteSessionConfig();
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
const config = session.config;
|
|
333
|
+
const channel = config.browser?.launchOptions.channel ?? config.browser?.browserName;
|
|
334
|
+
browsers.push({
|
|
335
|
+
name: session.name,
|
|
336
|
+
workspace: workspaceKey,
|
|
337
|
+
status: canConnect ? "open" : "closed",
|
|
338
|
+
browserType: channel,
|
|
339
|
+
userDataDir: config.browser?.userDataDir ?? null,
|
|
340
|
+
headed: config.browser ? !config.browser.launchOptions.headless : void 0,
|
|
341
|
+
persistent: !!config.cli.persistent,
|
|
342
|
+
attached: !!config.attached,
|
|
343
|
+
compatible: session.isCompatible(clientInfo),
|
|
344
|
+
version: config.version
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (!all)
|
|
349
|
+
return { all, browsers };
|
|
350
|
+
const servers = [...serverEntries.values()].flat();
|
|
351
|
+
return { all, browsers, servers, channelSessions: await (0, import_channelSessions.listChannelSessions)() };
|
|
352
|
+
}
|
|
353
|
+
function validateFlags(args, command, output) {
|
|
354
|
+
const unknownFlags = [];
|
|
355
|
+
for (const key of Object.keys(args)) {
|
|
356
|
+
if (key === "_")
|
|
357
|
+
continue;
|
|
358
|
+
if (globalOptions.includes(key))
|
|
359
|
+
continue;
|
|
360
|
+
if (!(key in command.flags))
|
|
361
|
+
unknownFlags.push(key);
|
|
362
|
+
}
|
|
363
|
+
if (unknownFlags.length)
|
|
364
|
+
output.errorUnknownOption(unknownFlags, command.help);
|
|
365
|
+
}
|
|
366
|
+
function validateArgs(args, command, output) {
|
|
367
|
+
const positional = args._.slice(1);
|
|
368
|
+
if (positional.length > command.args.length)
|
|
369
|
+
output.errorTooManyArguments(command.args.length, positional.length, command.help);
|
|
370
|
+
}
|
|
371
|
+
function calculateSha1(buffer) {
|
|
372
|
+
const hash = import_crypto.default.createHash("sha1");
|
|
373
|
+
hash.update(buffer);
|
|
374
|
+
return hash.digest("hex");
|
|
375
|
+
}
|
|
376
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
377
|
+
0 && (module.exports = {
|
|
378
|
+
calculateSha1,
|
|
379
|
+
program
|
|
380
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var registry_exports = {};
|
|
30
|
+
__export(registry_exports, {
|
|
31
|
+
Registry: () => Registry,
|
|
32
|
+
baseDaemonDir: () => baseDaemonDir,
|
|
33
|
+
clientKey: () => clientKey,
|
|
34
|
+
createClientInfo: () => createClientInfo,
|
|
35
|
+
explicitSessionName: () => explicitSessionName,
|
|
36
|
+
resolveSessionName: () => resolveSessionName
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(registry_exports);
|
|
39
|
+
var import_crypto = __toESM(require("crypto"));
|
|
40
|
+
var import_fs = __toESM(require("fs"));
|
|
41
|
+
var import_os = __toESM(require("os"));
|
|
42
|
+
var import_path = __toESM(require("path"));
|
|
43
|
+
var import_package = require("../../package");
|
|
44
|
+
function clientKey(clientInfo) {
|
|
45
|
+
return clientInfo.workspaceDir || clientInfo.workspaceDirHash;
|
|
46
|
+
}
|
|
47
|
+
class Registry {
|
|
48
|
+
constructor(files) {
|
|
49
|
+
this._files = files;
|
|
50
|
+
}
|
|
51
|
+
entry(clientInfo, sessionName) {
|
|
52
|
+
const key = clientKey(clientInfo);
|
|
53
|
+
const entries = this._files.get(key) || [];
|
|
54
|
+
return entries.find((entry) => entry.config.name === sessionName);
|
|
55
|
+
}
|
|
56
|
+
entries(clientInfo) {
|
|
57
|
+
return this._files.get(clientKey(clientInfo)) || [];
|
|
58
|
+
}
|
|
59
|
+
entryMap() {
|
|
60
|
+
return this._files;
|
|
61
|
+
}
|
|
62
|
+
async loadEntry(clientInfo, sessionName) {
|
|
63
|
+
const entry = await Registry._loadSessionEntry(clientInfo.daemonProfilesDir, sessionName + ".session");
|
|
64
|
+
if (!entry)
|
|
65
|
+
throw new Error(`Could not start the session "${sessionName}"`);
|
|
66
|
+
const key = clientKey(clientInfo);
|
|
67
|
+
let list = this._files.get(key);
|
|
68
|
+
if (!list) {
|
|
69
|
+
list = [];
|
|
70
|
+
this._files.set(key, list);
|
|
71
|
+
}
|
|
72
|
+
const oldIndex = list.findIndex((e) => e.config.name === sessionName);
|
|
73
|
+
if (oldIndex !== -1)
|
|
74
|
+
list.splice(oldIndex, 1);
|
|
75
|
+
list.push(entry);
|
|
76
|
+
return entry;
|
|
77
|
+
}
|
|
78
|
+
static async _loadSessionEntry(daemonDir, file) {
|
|
79
|
+
try {
|
|
80
|
+
const fileName = import_path.default.join(daemonDir, file);
|
|
81
|
+
const data = await import_fs.default.promises.readFile(fileName, "utf-8");
|
|
82
|
+
const config = JSON.parse(data);
|
|
83
|
+
if (!config.name)
|
|
84
|
+
config.name = import_path.default.basename(file, ".session");
|
|
85
|
+
if (!config.timestamp)
|
|
86
|
+
config.timestamp = 0;
|
|
87
|
+
return { file: fileName, config, daemonDir };
|
|
88
|
+
} catch {
|
|
89
|
+
return void 0;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
static async load() {
|
|
93
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
94
|
+
const hashDirs = await import_fs.default.promises.readdir(baseDaemonDir).catch(() => []);
|
|
95
|
+
for (const workspaceDirHash of hashDirs) {
|
|
96
|
+
const daemonDir = import_path.default.join(baseDaemonDir, workspaceDirHash);
|
|
97
|
+
const stat = await import_fs.default.promises.stat(daemonDir);
|
|
98
|
+
if (!stat.isDirectory())
|
|
99
|
+
continue;
|
|
100
|
+
const files = await import_fs.default.promises.readdir(daemonDir).catch(() => []);
|
|
101
|
+
for (const file of files) {
|
|
102
|
+
if (!file.endsWith(".session"))
|
|
103
|
+
continue;
|
|
104
|
+
const entry = await Registry._loadSessionEntry(daemonDir, file);
|
|
105
|
+
if (!entry)
|
|
106
|
+
continue;
|
|
107
|
+
const key = entry.config.workspaceDir || workspaceDirHash;
|
|
108
|
+
let list = sessions.get(key);
|
|
109
|
+
if (!list) {
|
|
110
|
+
list = [];
|
|
111
|
+
sessions.set(key, list);
|
|
112
|
+
}
|
|
113
|
+
list.push(entry);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return new Registry(sessions);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const baseDaemonDir = (() => {
|
|
120
|
+
if (process.env.PLAYWRIGHT_DAEMON_SESSION_DIR)
|
|
121
|
+
return process.env.PLAYWRIGHT_DAEMON_SESSION_DIR;
|
|
122
|
+
let localCacheDir;
|
|
123
|
+
if (process.platform === "linux")
|
|
124
|
+
localCacheDir = process.env.XDG_CACHE_HOME || import_path.default.join(import_os.default.homedir(), ".cache");
|
|
125
|
+
if (process.platform === "darwin")
|
|
126
|
+
localCacheDir = import_path.default.join(import_os.default.homedir(), "Library", "Caches");
|
|
127
|
+
if (process.platform === "win32")
|
|
128
|
+
localCacheDir = process.env.LOCALAPPDATA || import_path.default.join(import_os.default.homedir(), "AppData", "Local");
|
|
129
|
+
if (!localCacheDir)
|
|
130
|
+
throw new Error("Unsupported platform: " + process.platform);
|
|
131
|
+
return import_path.default.join(localCacheDir, "ms-playwright", "daemon");
|
|
132
|
+
})();
|
|
133
|
+
function createClientInfo() {
|
|
134
|
+
const workspaceDir = findWorkspaceDir(process.cwd());
|
|
135
|
+
const version = process.env.PLAYWRIGHT_CLI_VERSION_FOR_TEST || import_package.packageJSON.version;
|
|
136
|
+
const hash = import_crypto.default.createHash("sha1");
|
|
137
|
+
hash.update(workspaceDir || import_package.packageRoot);
|
|
138
|
+
const workspaceDirHash = hash.digest("hex").substring(0, 16);
|
|
139
|
+
return {
|
|
140
|
+
version,
|
|
141
|
+
workspaceDir,
|
|
142
|
+
workspaceDirHash,
|
|
143
|
+
daemonProfilesDir: daemonProfilesDir(workspaceDirHash),
|
|
144
|
+
homeDir: import_os.default.homedir()
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function findWorkspaceDir(startDir) {
|
|
148
|
+
let dir = startDir;
|
|
149
|
+
for (let i = 0; i < 10; i++) {
|
|
150
|
+
if (import_fs.default.existsSync(import_path.default.join(dir, ".playwright")))
|
|
151
|
+
return dir;
|
|
152
|
+
const parentDir = import_path.default.dirname(dir);
|
|
153
|
+
if (parentDir === dir)
|
|
154
|
+
break;
|
|
155
|
+
dir = parentDir;
|
|
156
|
+
}
|
|
157
|
+
return void 0;
|
|
158
|
+
}
|
|
159
|
+
const daemonProfilesDir = (workspaceDirHash) => {
|
|
160
|
+
return import_path.default.join(baseDaemonDir, workspaceDirHash);
|
|
161
|
+
};
|
|
162
|
+
function explicitSessionName(sessionName) {
|
|
163
|
+
return sessionName || process.env.PLAYWRIGHT_CLI_SESSION;
|
|
164
|
+
}
|
|
165
|
+
function resolveSessionName(sessionName) {
|
|
166
|
+
return explicitSessionName(sessionName) || "default";
|
|
167
|
+
}
|
|
168
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
169
|
+
0 && (module.exports = {
|
|
170
|
+
Registry,
|
|
171
|
+
baseDaemonDir,
|
|
172
|
+
clientKey,
|
|
173
|
+
createClientInfo,
|
|
174
|
+
explicitSessionName,
|
|
175
|
+
resolveSessionName
|
|
176
|
+
});
|