patchright-bun-core 1.58.2 → 1.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ThirdPartyNotices.txt +126 -650
- package/browsers.json +16 -14
- package/lib/bootstrap.js +77 -0
- package/lib/cli/browserActions.js +308 -0
- package/lib/cli/driver.js +3 -2
- package/lib/cli/installActions.js +171 -0
- package/lib/cli/program.js +47 -411
- package/lib/client/android.js +4 -4
- package/lib/client/api.js +3 -3
- package/lib/client/browser.js +8 -0
- package/lib/client/browserContext.js +18 -37
- package/lib/client/browserType.js +19 -51
- package/lib/client/cdpSession.js +6 -2
- package/lib/client/channelOwner.js +1 -1
- package/lib/client/{webSocket.js → connect.js} +57 -7
- package/lib/client/connection.js +8 -4
- package/lib/client/consoleMessage.js +3 -0
- package/lib/client/debugger.js +57 -0
- package/lib/client/dialog.js +8 -1
- package/lib/client/disposable.js +76 -0
- package/lib/client/electron.js +1 -0
- package/lib/client/elementHandle.js +1 -4
- package/lib/client/events.js +3 -3
- package/lib/client/fetch.js +0 -1
- package/lib/client/frame.js +0 -5
- package/lib/client/harRouter.js +13 -1
- package/lib/client/jsHandle.js +0 -4
- package/lib/client/locator.js +5 -7
- package/lib/client/network.js +14 -11
- package/lib/client/page.js +34 -48
- package/lib/client/platform.js +0 -3
- package/lib/client/screencast.js +88 -0
- package/lib/client/selectors.js +3 -1
- package/lib/client/tracing.js +11 -4
- package/lib/client/video.js +13 -20
- package/lib/generated/bindingsControllerSource.js +1 -1
- package/lib/generated/clockSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/generated/storageScriptSource.js +1 -1
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/mcpBundle.js +0 -6
- package/lib/mcpBundleImpl.js +91 -0
- package/lib/protocol/validator.js +216 -118
- package/lib/protocol/validatorPrimitives.js +1 -1
- package/lib/remote/playwrightConnection.js +10 -8
- package/lib/remote/playwrightPipeServer.js +100 -0
- package/lib/remote/playwrightServer.js +13 -8
- package/lib/remote/playwrightWebSocketServer.js +73 -0
- package/lib/remote/serverTransport.js +96 -0
- package/lib/server/android/android.js +2 -2
- package/lib/server/bidi/bidiBrowser.js +30 -8
- package/lib/server/bidi/bidiChromium.js +18 -5
- package/lib/server/bidi/bidiNetworkManager.js +39 -11
- package/lib/server/bidi/bidiPage.js +31 -15
- package/lib/server/bidi/third_party/firefoxPrefs.js +3 -1
- package/lib/server/browser.js +84 -21
- package/lib/server/browserContext.js +97 -58
- package/lib/server/browserType.js +14 -12
- package/lib/server/chromium/chromium.js +15 -13
- package/lib/server/chromium/crBrowser.js +18 -10
- package/lib/server/chromium/crNetworkManager.js +4 -4
- package/lib/server/chromium/crPage.js +26 -64
- package/lib/server/chromium/crServiceWorker.js +5 -4
- package/lib/server/clock.js +33 -33
- package/lib/server/console.js +5 -1
- package/lib/server/debugController.js +12 -6
- package/lib/server/debugger.js +40 -47
- package/lib/server/deviceDescriptorsSource.json +137 -137
- package/lib/server/dispatchers/browserContextDispatcher.js +27 -30
- package/lib/server/dispatchers/browserDispatcher.js +11 -5
- package/lib/server/dispatchers/browserTypeDispatcher.js +7 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +4 -1
- package/lib/server/dispatchers/debuggerDispatcher.js +84 -0
- package/lib/server/dispatchers/dispatcher.js +1 -1
- package/lib/server/dispatchers/disposableDispatcher.js +39 -0
- package/lib/server/dispatchers/electronDispatcher.js +2 -1
- package/lib/server/dispatchers/frameDispatcher.js +3 -3
- package/lib/server/dispatchers/localUtilsDispatcher.js +37 -1
- package/lib/server/dispatchers/networkDispatchers.js +6 -5
- package/lib/server/dispatchers/pageDispatcher.js +101 -38
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +4 -5
- package/lib/server/disposable.js +41 -0
- package/lib/server/dom.js +44 -26
- package/lib/server/download.js +3 -2
- package/lib/server/electron/electron.js +12 -7
- package/lib/server/firefox/ffBrowser.js +9 -19
- package/lib/server/firefox/ffInput.js +21 -5
- package/lib/server/firefox/ffNetworkManager.js +2 -2
- package/lib/server/firefox/ffPage.js +24 -27
- package/lib/server/frames.js +40 -11
- package/lib/server/har/harRecorder.js +2 -2
- package/lib/server/har/harTracer.js +5 -4
- package/lib/server/input.js +49 -4
- package/lib/server/instrumentation.js +5 -0
- package/lib/server/launchApp.js +0 -1
- package/lib/server/localUtils.js +6 -6
- package/lib/server/network.js +9 -8
- package/lib/server/overlay.js +138 -0
- package/lib/server/page.js +111 -51
- package/lib/server/progress.js +6 -0
- package/lib/server/recorder/recorderApp.js +9 -8
- package/lib/server/recorder.js +76 -40
- package/lib/server/registry/index.js +54 -81
- package/lib/server/registry/nativeDeps.js +1 -0
- package/lib/server/screencast.js +90 -143
- package/lib/server/trace/recorder/snapshotter.js +2 -2
- package/lib/server/trace/recorder/tracing.js +87 -36
- package/lib/server/trace/viewer/traceViewer.js +3 -4
- package/lib/server/usKeyboardLayout.js +7 -0
- package/lib/server/utils/comparators.js +1 -1
- package/lib/server/utils/disposable.js +32 -0
- package/lib/server/utils/eventsHelper.js +3 -1
- package/lib/server/utils/fileUtils.js +16 -2
- package/lib/server/utils/happyEyeballs.js +15 -12
- package/lib/server/utils/hostPlatform.js +0 -15
- package/lib/server/utils/httpServer.js +5 -3
- package/lib/server/utils/network.js +2 -1
- package/lib/server/utils/nodePlatform.js +0 -6
- package/lib/server/utils/processLauncher.js +8 -6
- package/lib/server/utils/zipFile.js +2 -2
- package/lib/server/videoRecorder.js +82 -12
- package/lib/server/webkit/wkBrowser.js +1 -6
- package/lib/server/webkit/wkPage.js +27 -25
- package/lib/server/webkit/wkWorkers.js +2 -1
- package/lib/serverRegistry.js +156 -0
- package/lib/tools/backend/browserBackend.js +79 -0
- package/lib/tools/backend/common.js +63 -0
- package/lib/tools/backend/config.js +41 -0
- package/lib/tools/backend/console.js +66 -0
- package/lib/tools/backend/context.js +296 -0
- package/lib/tools/backend/cookies.js +152 -0
- package/lib/tools/backend/devtools.js +69 -0
- package/lib/tools/backend/dialogs.js +59 -0
- package/lib/tools/backend/evaluate.js +64 -0
- package/lib/tools/backend/files.js +60 -0
- package/lib/tools/backend/form.js +64 -0
- package/lib/tools/backend/keyboard.js +155 -0
- package/lib/tools/backend/logFile.js +95 -0
- package/lib/tools/backend/mouse.js +168 -0
- package/lib/tools/backend/navigate.js +106 -0
- package/lib/tools/backend/network.js +135 -0
- package/lib/tools/backend/pdf.js +48 -0
- package/lib/tools/backend/response.js +305 -0
- package/lib/tools/backend/route.js +140 -0
- package/lib/tools/backend/runCode.js +77 -0
- package/lib/tools/backend/screenshot.js +88 -0
- package/lib/tools/backend/sessionLog.js +74 -0
- package/lib/tools/backend/snapshot.js +208 -0
- package/lib/tools/backend/storage.js +68 -0
- package/lib/tools/backend/tab.js +445 -0
- package/lib/tools/backend/tabs.js +67 -0
- package/lib/tools/backend/tool.js +47 -0
- package/lib/tools/backend/tools.js +102 -0
- package/lib/tools/backend/tracing.js +78 -0
- package/lib/tools/backend/utils.js +83 -0
- package/lib/tools/backend/verify.js +151 -0
- package/lib/tools/backend/video.js +98 -0
- package/lib/tools/backend/wait.js +63 -0
- package/lib/tools/backend/webstorage.js +223 -0
- package/lib/tools/cli-client/cli.js +6 -0
- package/lib/tools/cli-client/help.json +399 -0
- package/lib/tools/cli-client/minimist.js +128 -0
- package/lib/tools/cli-client/program.js +350 -0
- package/lib/tools/cli-client/registry.js +176 -0
- package/lib/tools/cli-client/session.js +289 -0
- package/lib/tools/cli-client/skill/SKILL.md +328 -0
- package/lib/tools/cli-client/skill/references/element-attributes.md +23 -0
- package/lib/tools/cli-client/skill/references/playwright-tests.md +39 -0
- package/lib/tools/cli-client/skill/references/request-mocking.md +87 -0
- package/lib/tools/cli-client/skill/references/running-code.md +231 -0
- package/lib/tools/cli-client/skill/references/session-management.md +169 -0
- package/lib/tools/cli-client/skill/references/storage-state.md +275 -0
- package/lib/tools/cli-client/skill/references/test-generation.md +88 -0
- package/lib/tools/cli-client/skill/references/tracing.md +139 -0
- package/lib/tools/cli-client/skill/references/video-recording.md +143 -0
- package/lib/tools/cli-daemon/command.js +73 -0
- package/lib/tools/cli-daemon/commands.js +956 -0
- package/lib/tools/cli-daemon/daemon.js +157 -0
- package/lib/tools/cli-daemon/helpGenerator.js +177 -0
- package/lib/tools/cli-daemon/program.js +129 -0
- package/lib/tools/dashboard/appIcon.png +0 -0
- package/lib/tools/dashboard/dashboardApp.js +284 -0
- package/lib/tools/dashboard/dashboardController.js +296 -0
- package/lib/tools/exports.js +60 -0
- package/lib/tools/mcp/browserFactory.js +233 -0
- package/lib/tools/mcp/cdpRelay.js +352 -0
- package/lib/tools/mcp/cli-stub.js +7 -0
- package/lib/tools/mcp/config.d.js +16 -0
- package/lib/tools/mcp/config.js +446 -0
- package/lib/tools/mcp/configIni.js +189 -0
- package/lib/tools/mcp/extensionContextFactory.js +55 -0
- package/lib/tools/mcp/index.js +62 -0
- package/lib/tools/mcp/log.js +35 -0
- package/lib/tools/mcp/program.js +107 -0
- package/lib/tools/mcp/protocol.js +28 -0
- package/lib/tools/mcp/watchdog.js +44 -0
- package/lib/tools/trace/SKILL.md +171 -0
- package/lib/{server/trace/viewer/traceParser.js → tools/trace/installSkill.js} +15 -39
- package/lib/tools/trace/traceActions.js +142 -0
- package/lib/tools/trace/traceAttachments.js +69 -0
- package/lib/tools/trace/traceCli.js +87 -0
- package/lib/tools/trace/traceConsole.js +97 -0
- package/lib/tools/trace/traceErrors.js +55 -0
- package/lib/tools/trace/traceOpen.js +69 -0
- package/lib/tools/trace/traceParser.js +96 -0
- package/lib/tools/trace/traceRequests.js +182 -0
- package/lib/tools/trace/traceScreenshot.js +68 -0
- package/lib/tools/trace/traceSnapshot.js +149 -0
- package/lib/tools/trace/traceUtils.js +153 -0
- package/lib/tools/utils/connect.js +32 -0
- package/lib/tools/utils/mcp/http.js +152 -0
- package/lib/tools/utils/mcp/server.js +230 -0
- package/lib/tools/utils/mcp/tool.js +47 -0
- package/lib/tools/utils/socketConnection.js +108 -0
- package/lib/utils/isomorphic/formatUtils.js +64 -0
- package/lib/utils/isomorphic/jsonSchema.js +89 -0
- package/lib/utils/isomorphic/mimeType.js +7 -2
- package/lib/utils/isomorphic/protocolFormatter.js +2 -2
- package/lib/utils/isomorphic/protocolMetainfo.js +127 -106
- package/lib/utils/isomorphic/stringUtils.js +3 -3
- package/lib/utils/isomorphic/timeoutRunner.js +3 -3
- package/lib/utils/isomorphic/trace/snapshotRenderer.js +35 -42
- package/lib/utils/isomorphic/trace/traceLoader.js +15 -14
- package/lib/utils/isomorphic/trace/traceModel.js +3 -2
- package/lib/utils/isomorphic/trace/traceModernizer.js +1 -0
- package/lib/utils/isomorphic/urlMatch.js +54 -1
- package/lib/utils/isomorphic/utilityScriptSerializers.js +11 -0
- package/lib/utils.js +6 -2
- package/lib/utilsBundle.js +3 -21
- package/lib/utilsBundleImpl/index.js +132 -133
- package/lib/vite/dashboard/assets/index-BAOybkp8.js +50 -0
- package/lib/vite/dashboard/assets/index-CZAYOG76.css +1 -0
- package/lib/vite/dashboard/index.html +28 -0
- package/lib/vite/htmlReport/index.html +2 -70
- package/lib/vite/htmlReport/report.css +1 -0
- package/lib/vite/htmlReport/report.js +72 -0
- package/lib/vite/recorder/assets/{codeMirrorModule-DadYNm1I.js → codeMirrorModule-C8KMvO9L.js} +20 -20
- package/lib/vite/recorder/assets/index-CqAYX1I3.js +193 -0
- package/lib/vite/recorder/index.html +1 -1
- package/lib/vite/traceViewer/assets/{codeMirrorModule-a5XoALAZ.js → codeMirrorModule-DS0FLvoc.js} +20 -20
- package/lib/vite/traceViewer/assets/defaultSettingsView-GTWI-W_B.js +262 -0
- package/lib/vite/traceViewer/defaultSettingsView.B4dS75f0.css +1 -0
- package/lib/vite/traceViewer/{index.BVu7tZDe.css → index.CzXZzn5A.css} +1 -1
- package/lib/vite/traceViewer/{index.BDwrLSGN.js → index.Dtstcb7U.js} +1 -1
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/sw.bundle.js +4 -4
- package/lib/vite/traceViewer/uiMode.Vipi55dB.js +6 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/lib/zipBundleImpl.js +2 -2
- package/lib/zodBundle.js +39 -0
- package/lib/zodBundleImpl.js +40 -0
- package/package.json +6 -1
- package/types/protocol.d.ts +947 -51
- package/types/types.d.ts +854 -74
- package/lib/client/pageAgent.js +0 -64
- package/lib/mcpBundleImpl/index.js +0 -147
- package/lib/server/agent/actionRunner.js +0 -335
- package/lib/server/agent/actions.js +0 -128
- package/lib/server/agent/codegen.js +0 -111
- package/lib/server/agent/context.js +0 -150
- package/lib/server/agent/expectTools.js +0 -156
- package/lib/server/agent/pageAgent.js +0 -204
- package/lib/server/agent/performTools.js +0 -262
- package/lib/server/agent/tool.js +0 -109
- package/lib/server/dispatchers/pageAgentDispatcher.js +0 -96
- package/lib/vite/recorder/assets/index-BhTWtUlo.js +0 -193
- package/lib/vite/traceViewer/assets/defaultSettingsView-CJSZINFr.js +0 -266
- package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +0 -1
- package/lib/vite/traceViewer/uiMode.CQJ9SCIQ.js +0 -5
- /package/lib/{server/utils → utils/isomorphic}/imageUtils.js +0 -0
- /package/lib/utils/isomorphic/{traceUtils.js → trace/traceUtils.js} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var mcp_exports = {};
|
|
20
|
+
__export(mcp_exports, {
|
|
21
|
+
createConnection: () => createConnection
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(mcp_exports);
|
|
24
|
+
var import_config = require("./config");
|
|
25
|
+
var import_tools = require("../backend/tools");
|
|
26
|
+
var import_browserFactory = require("./browserFactory");
|
|
27
|
+
var import_browserBackend = require("../backend/browserBackend");
|
|
28
|
+
var import_server = require("../utils/mcp/server");
|
|
29
|
+
const packageJSON = require("../../../package.json");
|
|
30
|
+
async function createConnection(userConfig = {}, contextGetter) {
|
|
31
|
+
const config = await (0, import_config.resolveConfig)(userConfig);
|
|
32
|
+
const tools = (0, import_tools.filteredTools)(config);
|
|
33
|
+
const backendFactory = {
|
|
34
|
+
name: "api",
|
|
35
|
+
nameInConfig: "api",
|
|
36
|
+
version: packageJSON.version,
|
|
37
|
+
toolSchemas: tools.map((tool) => tool.schema),
|
|
38
|
+
create: async (clientInfo) => {
|
|
39
|
+
const browser = contextGetter ? new SimpleBrowser(await contextGetter()) : await (0, import_browserFactory.createBrowser)(config, clientInfo);
|
|
40
|
+
const context = config.browser.isolated ? await browser.newContext(config.browser.contextOptions) : browser.contexts()[0];
|
|
41
|
+
return new import_browserBackend.BrowserBackend(config, context, tools);
|
|
42
|
+
},
|
|
43
|
+
disposed: async () => {
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return (0, import_server.createServer)("api", packageJSON.version, backendFactory, false);
|
|
47
|
+
}
|
|
48
|
+
class SimpleBrowser {
|
|
49
|
+
constructor(context) {
|
|
50
|
+
this._context = context;
|
|
51
|
+
}
|
|
52
|
+
contexts() {
|
|
53
|
+
return [this._context];
|
|
54
|
+
}
|
|
55
|
+
async newContext() {
|
|
56
|
+
throw new Error("Creating a new context is not supported in SimpleBrowserContextFactory.");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
createConnection
|
|
62
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var log_exports = {};
|
|
20
|
+
__export(log_exports, {
|
|
21
|
+
logUnhandledError: () => logUnhandledError,
|
|
22
|
+
testDebug: () => testDebug
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(log_exports);
|
|
25
|
+
var import_utilsBundle = require("../../utilsBundle");
|
|
26
|
+
const errorDebug = (0, import_utilsBundle.debug)("pw:mcp:error");
|
|
27
|
+
function logUnhandledError(error) {
|
|
28
|
+
errorDebug(error);
|
|
29
|
+
}
|
|
30
|
+
const testDebug = (0, import_utilsBundle.debug)("pw:mcp:test");
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
logUnhandledError,
|
|
34
|
+
testDebug
|
|
35
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
decorateMCPCommand: () => decorateMCPCommand
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(program_exports);
|
|
34
|
+
var import_utilsBundle = require("../../utilsBundle");
|
|
35
|
+
var mcpServer = __toESM(require("../utils/mcp/server"));
|
|
36
|
+
var import_config = require("./config");
|
|
37
|
+
var import_watchdog = require("./watchdog");
|
|
38
|
+
var import_browserFactory = require("./browserFactory");
|
|
39
|
+
var import_browserBackend = require("../backend/browserBackend");
|
|
40
|
+
var import_tools = require("../backend/tools");
|
|
41
|
+
var import_log = require("./log");
|
|
42
|
+
const version = require("../../../package.json").version;
|
|
43
|
+
function decorateMCPCommand(command) {
|
|
44
|
+
command.option("--allowed-hosts <hosts...>", "comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '*' to disable the host check.", import_config.commaSeparatedList).option("--allowed-origins <origins>", "semicolon-separated list of TRUSTED origins to allow the browser to request. Default is to allow all.\nImportant: *does not* serve as a security boundary and *does not* affect redirects. ", import_config.semicolonSeparatedList).option("--allow-unrestricted-file-access", "allow access to files outside of the workspace roots. Also allows unrestricted access to file:// URLs. By default access to file system is restricted to workspace root directories (or cwd if no roots are configured) only, and navigation to file:// URLs is blocked.").option("--blocked-origins <origins>", "semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed.\nImportant: *does not* serve as a security boundary and *does not* affect redirects.", import_config.semicolonSeparatedList).option("--block-service-workers", "block service workers").option("--browser <browser>", "browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.").option("--caps <caps>", "comma-separated list of additional capabilities to enable, possible values: vision, pdf, devtools.", import_config.commaSeparatedList).option("--cdp-endpoint <endpoint>", "CDP endpoint to connect to.").option("--cdp-header <headers...>", "CDP headers to send with the connect request, multiple can be specified.", import_config.headerParser).option("--cdp-timeout <timeout>", "timeout in milliseconds for connecting to CDP endpoint, defaults to 30000ms", import_config.numberParser).option("--codegen <lang>", 'specify the language to use for code generation, possible values: "typescript", "none". Default is "typescript".', import_config.enumParser.bind(null, "--codegen", ["none", "typescript"])).option("--config <path>", "path to the configuration file.").option("--console-level <level>", 'level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels.', import_config.enumParser.bind(null, "--console-level", ["error", "warning", "info", "debug"])).option("--device <device>", 'device to emulate, for example: "iPhone 15"').option("--executable-path <path>", "path to the browser executable.").option("--extension", 'Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.').option("--endpoint <endpoint>", "Bound browser endpoint to connect to.").option("--grant-permissions <permissions...>", 'List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write".', import_config.commaSeparatedList).option("--headless", "run browser in headless mode, headed by default").option("--host <host>", "host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.").option("--ignore-https-errors", "ignore https errors").option("--init-page <path...>", "path to TypeScript file to evaluate on Playwright page object").option("--init-script <path...>", "path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times.").option("--isolated", "keep the browser profile in memory, do not save it to disk.").option("--image-responses <mode>", 'whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".', import_config.enumParser.bind(null, "--image-responses", ["allow", "omit"])).option("--no-sandbox", "disable the sandbox for all process types that are normally sandboxed.").option("--output-dir <path>", "path to the directory for output files.").option("--output-mode <mode>", 'whether to save snapshots, console messages, network logs to a file or to the standard output. Can be "file" or "stdout". Default is "stdout".', import_config.enumParser.bind(null, "--output-mode", ["file", "stdout"])).option("--port <port>", "port to listen on for SSE transport.").option("--proxy-bypass <bypass>", 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option("--proxy-server <proxy>", 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"').option("--sandbox", "enable the sandbox for all process types that are normally not sandboxed.").option("--save-session", "Whether to save the Playwright MCP session into the output directory.").option("--secrets <path>", "path to a file containing secrets in the dotenv format", import_config.dotenvFileLoader).option("--shared-browser-context", "reuse the same browser context between all connected HTTP clients.").option("--snapshot-mode <mode>", 'when taking snapshots for responses, specifies the mode to use. Can be "full" or "none". Default is "full".').option("--storage-state <path>", "path to the storage state file for isolated sessions.").option("--test-id-attribute <attribute>", 'specify the attribute to use for test ids, defaults to "data-testid"').option("--timeout-action <timeout>", "specify action timeout in milliseconds, defaults to 5000ms", import_config.numberParser).option("--timeout-navigation <timeout>", "specify navigation timeout in milliseconds, defaults to 60000ms", import_config.numberParser).option("--user-agent <ua string>", "specify user agent string").option("--user-data-dir <path>", "path to the user data directory. If not specified, a temporary directory will be created.").option("--viewport-size <size>", 'specify browser viewport size in pixels, for example "1280x720"', import_config.resolutionParser.bind(null, "--viewport-size")).addOption(new import_utilsBundle.ProgramOption("--vision", "Legacy option, use --caps=vision instead").hideHelp()).action(async (options) => {
|
|
45
|
+
options.sandbox = options.sandbox === true ? void 0 : false;
|
|
46
|
+
(0, import_watchdog.setupExitWatchdog)();
|
|
47
|
+
if (options.vision) {
|
|
48
|
+
console.error("The --vision option is deprecated, use --caps=vision instead");
|
|
49
|
+
options.caps = "vision";
|
|
50
|
+
}
|
|
51
|
+
if (options.caps?.includes("tracing"))
|
|
52
|
+
options.caps.push("devtools");
|
|
53
|
+
const config = await (0, import_config.resolveCLIConfigForMCP)(options);
|
|
54
|
+
const tools = (0, import_tools.filteredTools)(config);
|
|
55
|
+
if (config.extension) {
|
|
56
|
+
const serverBackendFactory = {
|
|
57
|
+
name: "Playwright w/ extension",
|
|
58
|
+
nameInConfig: "playwright-extension",
|
|
59
|
+
version,
|
|
60
|
+
toolSchemas: tools.map((tool) => tool.schema),
|
|
61
|
+
create: async (clientInfo) => {
|
|
62
|
+
const browser = await (0, import_browserFactory.createBrowser)(config, clientInfo);
|
|
63
|
+
const browserContext = browser.contexts()[0];
|
|
64
|
+
return new import_browserBackend.BrowserBackend(config, browserContext, tools);
|
|
65
|
+
},
|
|
66
|
+
disposed: async () => {
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
await mcpServer.start(serverBackendFactory, config.server);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const useSharedBrowser = config.sharedBrowserContext || config.browser.isolated;
|
|
73
|
+
let sharedBrowser;
|
|
74
|
+
let clientCount = 0;
|
|
75
|
+
const factory = {
|
|
76
|
+
name: "Playwright",
|
|
77
|
+
nameInConfig: "playwright",
|
|
78
|
+
version,
|
|
79
|
+
toolSchemas: tools.map((tool) => tool.schema),
|
|
80
|
+
create: async (clientInfo) => {
|
|
81
|
+
if (useSharedBrowser && clientCount === 0)
|
|
82
|
+
sharedBrowser = await (0, import_browserFactory.createBrowser)(config, clientInfo);
|
|
83
|
+
clientCount++;
|
|
84
|
+
const browser = sharedBrowser || await (0, import_browserFactory.createBrowser)(config, clientInfo);
|
|
85
|
+
const browserContext = config.browser.isolated ? await browser.newContext(config.browser.contextOptions) : browser.contexts()[0];
|
|
86
|
+
return new import_browserBackend.BrowserBackend(config, browserContext, tools);
|
|
87
|
+
},
|
|
88
|
+
disposed: async (backend) => {
|
|
89
|
+
clientCount--;
|
|
90
|
+
if (sharedBrowser && clientCount > 0)
|
|
91
|
+
return;
|
|
92
|
+
(0, import_log.testDebug)("close browser");
|
|
93
|
+
sharedBrowser = void 0;
|
|
94
|
+
const browserContext = backend.browserContext;
|
|
95
|
+
await browserContext.close().catch(() => {
|
|
96
|
+
});
|
|
97
|
+
await browserContext.browser().close().catch(() => {
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
await mcpServer.start(factory, config.server);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
decorateMCPCommand
|
|
107
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var protocol_exports = {};
|
|
20
|
+
__export(protocol_exports, {
|
|
21
|
+
VERSION: () => VERSION
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(protocol_exports);
|
|
24
|
+
const VERSION = 1;
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
VERSION
|
|
28
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var watchdog_exports = {};
|
|
20
|
+
__export(watchdog_exports, {
|
|
21
|
+
setupExitWatchdog: () => setupExitWatchdog
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(watchdog_exports);
|
|
24
|
+
var import_utils = require("../../utils");
|
|
25
|
+
var import_log = require("./log");
|
|
26
|
+
function setupExitWatchdog() {
|
|
27
|
+
let isExiting = false;
|
|
28
|
+
const handleExit = async (signal) => {
|
|
29
|
+
if (isExiting)
|
|
30
|
+
return;
|
|
31
|
+
isExiting = true;
|
|
32
|
+
setTimeout(() => process.exit(0), 15e3);
|
|
33
|
+
(0, import_log.testDebug)("gracefully closing " + import_utils.gracefullyCloseSet.size);
|
|
34
|
+
await (0, import_utils.gracefullyCloseAll)();
|
|
35
|
+
process.exit(0);
|
|
36
|
+
};
|
|
37
|
+
process.stdin.on("close", () => handleExit("close"));
|
|
38
|
+
process.on("SIGINT", () => handleExit("SIGINT"));
|
|
39
|
+
process.on("SIGTERM", () => handleExit("SIGTERM"));
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
setupExitWatchdog
|
|
44
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright-trace
|
|
3
|
+
description: Inspect Playwright trace files from the command line — list actions, view requests, console, errors, snapshots and screenshots.
|
|
4
|
+
allowed-tools: Bash(npx:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Playwright Trace CLI
|
|
8
|
+
|
|
9
|
+
Inspect `.zip` trace files produced by Playwright tests without opening a browser.
|
|
10
|
+
|
|
11
|
+
## Workflow
|
|
12
|
+
|
|
13
|
+
1. Start with `trace open <trace.zip>` to extract the trace and see its metadata.
|
|
14
|
+
2. Use `trace actions` to see all actions with their action IDs.
|
|
15
|
+
3. Use `trace action <action-id>` to drill into a specific action — see parameters, logs, source location, and available snapshots.
|
|
16
|
+
4. Use `trace requests`, `trace console`, or `trace errors` for cross-cutting views.
|
|
17
|
+
5. Use `trace snapshot <action-id>` to get the DOM snapshot, or run a browser command against it.
|
|
18
|
+
6. Use `trace close` to remove the extracted trace data when done.
|
|
19
|
+
|
|
20
|
+
All commands after `open` operate on the currently opened trace — no need to pass the trace file again. Opening a new trace replaces the previous one.
|
|
21
|
+
|
|
22
|
+
## Commands
|
|
23
|
+
|
|
24
|
+
### Open a trace
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Extract trace and show metadata: browser, viewport, duration, action/error counts
|
|
28
|
+
npx playwright trace open <trace.zip>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Close a trace
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Remove extracted trace data
|
|
35
|
+
npx playwright trace close
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Actions
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# List all actions as a tree with action IDs and timing
|
|
42
|
+
npx playwright trace actions
|
|
43
|
+
|
|
44
|
+
# Filter by action title (regex, case-insensitive)
|
|
45
|
+
npx playwright trace actions --grep "click"
|
|
46
|
+
|
|
47
|
+
# Only failed actions
|
|
48
|
+
npx playwright trace actions --errors-only
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Action details
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Show full details for one action: params, result, logs, source, snapshots
|
|
55
|
+
npx playwright trace action <action-id>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The `action` command displays available snapshot phases (before, input, after) and the exact command to extract them.
|
|
59
|
+
|
|
60
|
+
### Requests
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# All network requests: method, status, URL, duration, size
|
|
64
|
+
npx playwright trace requests
|
|
65
|
+
|
|
66
|
+
# Filter by URL pattern
|
|
67
|
+
npx playwright trace requests --grep "api"
|
|
68
|
+
|
|
69
|
+
# Filter by HTTP method
|
|
70
|
+
npx playwright trace requests --method POST
|
|
71
|
+
|
|
72
|
+
# Only failed requests (status >= 400)
|
|
73
|
+
npx playwright trace requests --failed
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Request details
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Show full details for one request: headers, body, security
|
|
80
|
+
npx playwright trace request <request-id>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Console
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# All console messages and stdout/stderr
|
|
87
|
+
npx playwright trace console
|
|
88
|
+
|
|
89
|
+
# Only errors
|
|
90
|
+
npx playwright trace console --errors-only
|
|
91
|
+
|
|
92
|
+
# Only browser console (no stdout/stderr)
|
|
93
|
+
npx playwright trace console --browser
|
|
94
|
+
|
|
95
|
+
# Only stdout/stderr (no browser console)
|
|
96
|
+
npx playwright trace console --stdio
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Errors
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# All errors with stack traces and associated actions
|
|
103
|
+
npx playwright trace errors
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Snapshots
|
|
107
|
+
|
|
108
|
+
The `snapshot` command loads the DOM snapshot for an action into a headless browser and runs a single browser command against it. Without a browser command, it returns the accessibility snapshot.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Get the accessibility snapshot (default)
|
|
112
|
+
npx playwright trace snapshot <action-id>
|
|
113
|
+
|
|
114
|
+
# Use a specific phase
|
|
115
|
+
npx playwright trace snapshot <action-id> --name before
|
|
116
|
+
|
|
117
|
+
# Run eval to query the DOM
|
|
118
|
+
npx playwright trace snapshot <action-id> -- eval "document.title"
|
|
119
|
+
npx playwright trace snapshot <action-id> -- eval "document.querySelector('#error').textContent"
|
|
120
|
+
|
|
121
|
+
# Eval on a specific element ref (from the snapshot)
|
|
122
|
+
npx playwright trace snapshot <action-id> -- eval "el => el.getAttribute('data-testid')" e5
|
|
123
|
+
|
|
124
|
+
# Take a screenshot of the snapshot
|
|
125
|
+
npx playwright trace snapshot <action-id> -- screenshot
|
|
126
|
+
|
|
127
|
+
# Redirect output to a file
|
|
128
|
+
npx playwright trace snapshot <action-id> -- eval "document.body.outerHTML" --filename=page.html
|
|
129
|
+
npx playwright trace snapshot <action-id> -- screenshot --filename=screenshot.png
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Only three browser commands are useful on a frozen snapshot: `snapshot`, `eval`, and `screenshot`.
|
|
133
|
+
|
|
134
|
+
### Attachments
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# List all trace attachments
|
|
138
|
+
npx playwright trace attachments
|
|
139
|
+
|
|
140
|
+
# Extract an attachment by its number
|
|
141
|
+
npx playwright trace attachment 1
|
|
142
|
+
npx playwright trace attachment 1 -o out.png
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Typical investigation
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# 1. Open the trace and see what's inside
|
|
149
|
+
npx playwright trace open test-results/my-test/trace.zip
|
|
150
|
+
|
|
151
|
+
# 2. What actions ran?
|
|
152
|
+
npx playwright trace actions
|
|
153
|
+
|
|
154
|
+
# 3. Which action failed?
|
|
155
|
+
npx playwright trace actions --errors-only
|
|
156
|
+
|
|
157
|
+
# 4. What went wrong?
|
|
158
|
+
npx playwright trace action 12
|
|
159
|
+
|
|
160
|
+
# 5. What did the page look like at that moment?
|
|
161
|
+
npx playwright trace snapshot 12
|
|
162
|
+
|
|
163
|
+
# 6. Query the DOM for more detail
|
|
164
|
+
npx playwright trace snapshot 12 -- eval "document.querySelector('.error-message').textContent"
|
|
165
|
+
|
|
166
|
+
# 7. Any relevant network failures?
|
|
167
|
+
npx playwright trace requests --failed
|
|
168
|
+
|
|
169
|
+
# 8. Any console errors?
|
|
170
|
+
npx playwright trace console --errors-only
|
|
171
|
+
```
|
|
@@ -26,47 +26,23 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
29
|
+
var installSkill_exports = {};
|
|
30
|
+
__export(installSkill_exports, {
|
|
31
|
+
installSkill: () => installSkill
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
traceURL() {
|
|
45
|
-
return import_url.default.pathToFileURL(this._traceFile).toString();
|
|
46
|
-
}
|
|
47
|
-
async entryNames() {
|
|
48
|
-
return await this._zipFile.entries();
|
|
49
|
-
}
|
|
50
|
-
async hasEntry(entryName) {
|
|
51
|
-
const entries = await this.entryNames();
|
|
52
|
-
return entries.includes(entryName);
|
|
53
|
-
}
|
|
54
|
-
async readText(entryName) {
|
|
55
|
-
try {
|
|
56
|
-
const buffer = await this._zipFile.read(entryName);
|
|
57
|
-
return buffer.toString("utf-8");
|
|
58
|
-
} catch {
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async readBlob(entryName) {
|
|
62
|
-
try {
|
|
63
|
-
const buffer = await this._zipFile.read(entryName);
|
|
64
|
-
return new Blob([new Uint8Array(buffer)]);
|
|
65
|
-
} catch {
|
|
66
|
-
}
|
|
67
|
-
}
|
|
33
|
+
module.exports = __toCommonJS(installSkill_exports);
|
|
34
|
+
var import_fs = __toESM(require("fs"));
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
async function installSkill() {
|
|
37
|
+
const cwd = process.cwd();
|
|
38
|
+
const skillSource = import_path.default.join(__dirname, "SKILL.md");
|
|
39
|
+
const destDir = import_path.default.join(cwd, ".claude", "skills", "playwright-trace");
|
|
40
|
+
await import_fs.default.promises.mkdir(destDir, { recursive: true });
|
|
41
|
+
const destFile = import_path.default.join(destDir, "SKILL.md");
|
|
42
|
+
await import_fs.default.promises.copyFile(skillSource, destFile);
|
|
43
|
+
console.log(`\u2705 Skill installed to \`${import_path.default.relative(cwd, destFile)}\`.`);
|
|
68
44
|
}
|
|
69
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
46
|
0 && (module.exports = {
|
|
71
|
-
|
|
47
|
+
installSkill
|
|
72
48
|
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var traceActions_exports = {};
|
|
20
|
+
__export(traceActions_exports, {
|
|
21
|
+
traceAction: () => traceAction,
|
|
22
|
+
traceActions: () => traceActions
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(traceActions_exports);
|
|
25
|
+
var import_traceModel = require("../../utils/isomorphic/trace/traceModel");
|
|
26
|
+
var import_locatorGenerators = require("../../utils/isomorphic/locatorGenerators");
|
|
27
|
+
var import_traceUtils = require("./traceUtils");
|
|
28
|
+
var import_formatUtils = require("../../utils/isomorphic/formatUtils");
|
|
29
|
+
async function traceActions(options) {
|
|
30
|
+
const trace = await (0, import_traceUtils.loadTrace)();
|
|
31
|
+
const actions = filterActions(trace.model.actions, options);
|
|
32
|
+
const { rootItem } = (0, import_traceModel.buildActionTree)(actions);
|
|
33
|
+
console.log(` ${"#".padStart(4)} ${"Time".padEnd(9)} ${"Action".padEnd(55)} ${"Duration".padStart(8)}`);
|
|
34
|
+
console.log(` ${"\u2500".repeat(4)} ${"\u2500".repeat(9)} ${"\u2500".repeat(55)} ${"\u2500".repeat(8)}`);
|
|
35
|
+
const visit = (item, indent) => {
|
|
36
|
+
const action = item.action;
|
|
37
|
+
const ordinal = trace.callIdToOrdinal.get(action.callId) ?? "?";
|
|
38
|
+
const ts = (0, import_traceUtils.formatTimestamp)(action.startTime, trace.model.startTime);
|
|
39
|
+
const duration = action.endTime ? (0, import_formatUtils.msToString)(action.endTime - action.startTime) : "running";
|
|
40
|
+
const title = (0, import_traceUtils.actionTitle)(action);
|
|
41
|
+
const locator = actionLocator(action);
|
|
42
|
+
const error = action.error ? " \u2717" : "";
|
|
43
|
+
const prefix = ` ${(ordinal + ".").padStart(4)} ${ts} ${indent}`;
|
|
44
|
+
console.log(`${prefix}${title.padEnd(Math.max(1, 55 - indent.length))} ${duration.padStart(8)}${error}`);
|
|
45
|
+
if (locator)
|
|
46
|
+
console.log(`${" ".repeat(prefix.length)}${locator}`);
|
|
47
|
+
for (const child of item.children)
|
|
48
|
+
visit(child, indent + " ");
|
|
49
|
+
};
|
|
50
|
+
for (const child of rootItem.children)
|
|
51
|
+
visit(child, "");
|
|
52
|
+
}
|
|
53
|
+
function filterActions(actions, options) {
|
|
54
|
+
let result = actions.filter((a) => a.group !== "configuration");
|
|
55
|
+
if (options.grep) {
|
|
56
|
+
const pattern = new RegExp(options.grep, "i");
|
|
57
|
+
result = result.filter((a) => pattern.test((0, import_traceUtils.actionTitle)(a)) || pattern.test(actionLocator(a) || ""));
|
|
58
|
+
}
|
|
59
|
+
if (options.errorsOnly)
|
|
60
|
+
result = result.filter((a) => !!a.error);
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
function actionLocator(action, sdkLanguage) {
|
|
64
|
+
return action.params.selector ? (0, import_locatorGenerators.asLocatorDescription)(sdkLanguage || "javascript", action.params.selector) : void 0;
|
|
65
|
+
}
|
|
66
|
+
async function traceAction(actionId) {
|
|
67
|
+
const trace = await (0, import_traceUtils.loadTrace)();
|
|
68
|
+
const action = trace.resolveActionId(actionId);
|
|
69
|
+
if (!action) {
|
|
70
|
+
console.error(`Action '${actionId}' not found. Use 'trace actions' to see available action IDs.`);
|
|
71
|
+
process.exitCode = 1;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const title = (0, import_traceUtils.actionTitle)(action);
|
|
75
|
+
console.log(`
|
|
76
|
+
${title}
|
|
77
|
+
`);
|
|
78
|
+
console.log(" Time");
|
|
79
|
+
console.log(` start: ${(0, import_traceUtils.formatTimestamp)(action.startTime, trace.model.startTime)}`);
|
|
80
|
+
const duration = action.endTime ? (0, import_formatUtils.msToString)(action.endTime - action.startTime) : action.error ? "Timed Out" : "Running";
|
|
81
|
+
console.log(` duration: ${duration}`);
|
|
82
|
+
const paramKeys = Object.keys(action.params).filter((name) => name !== "info");
|
|
83
|
+
if (paramKeys.length) {
|
|
84
|
+
console.log("\n Parameters");
|
|
85
|
+
for (const key of paramKeys) {
|
|
86
|
+
const value = formatParamValue(action.params[key]);
|
|
87
|
+
console.log(` ${key}: ${value}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (action.result) {
|
|
91
|
+
console.log("\n Return value");
|
|
92
|
+
for (const [key, value] of Object.entries(action.result))
|
|
93
|
+
console.log(` ${key}: ${formatParamValue(value)}`);
|
|
94
|
+
}
|
|
95
|
+
if (action.error) {
|
|
96
|
+
console.log("\n Error");
|
|
97
|
+
console.log(` ${action.error.message}`);
|
|
98
|
+
}
|
|
99
|
+
if (action.log.length) {
|
|
100
|
+
console.log("\n Log");
|
|
101
|
+
for (const entry of action.log) {
|
|
102
|
+
const time = entry.time !== -1 ? (0, import_traceUtils.formatTimestamp)(entry.time, trace.model.startTime) : "";
|
|
103
|
+
console.log(` ${time.padEnd(12)} ${entry.message}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (action.stack?.length) {
|
|
107
|
+
console.log("\n Source");
|
|
108
|
+
for (const frame of action.stack.slice(0, 5)) {
|
|
109
|
+
const file = frame.file.replace(/.*[/\\](.*)/, "$1");
|
|
110
|
+
console.log(` ${file}:${frame.line}:${frame.column}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const snapshots = [];
|
|
114
|
+
if (action.beforeSnapshot)
|
|
115
|
+
snapshots.push("before");
|
|
116
|
+
if (action.inputSnapshot)
|
|
117
|
+
snapshots.push("input");
|
|
118
|
+
if (action.afterSnapshot)
|
|
119
|
+
snapshots.push("after");
|
|
120
|
+
if (snapshots.length) {
|
|
121
|
+
console.log("\n Snapshots");
|
|
122
|
+
console.log(` available: ${snapshots.join(", ")}`);
|
|
123
|
+
console.log(` usage: npx playwright trace snapshot ${actionId} --name <${snapshots.join("|")}>`);
|
|
124
|
+
}
|
|
125
|
+
console.log("");
|
|
126
|
+
}
|
|
127
|
+
function formatParamValue(value) {
|
|
128
|
+
if (value === void 0 || value === null)
|
|
129
|
+
return String(value);
|
|
130
|
+
if (typeof value === "string")
|
|
131
|
+
return `"${value}"`;
|
|
132
|
+
if (typeof value !== "object")
|
|
133
|
+
return String(value);
|
|
134
|
+
if (value.guid)
|
|
135
|
+
return "<handle>";
|
|
136
|
+
return JSON.stringify(value).slice(0, 1e3);
|
|
137
|
+
}
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
traceAction,
|
|
141
|
+
traceActions
|
|
142
|
+
});
|