@capyclaw/browser-suite 0.2.36 → 0.2.37

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.
Files changed (187) hide show
  1. package/composition.lock.json +3 -3
  2. package/contract/browser-contract.json +1 -1
  3. package/dsh-suite.json +5 -5
  4. package/node_modules/@capyclaw/asset-service/src/index.mjs +86 -5
  5. package/node_modules/@capyclaw/browser-skill-api/contract/browser-contract.json +1 -1
  6. package/node_modules/@capyclaw/browser-skill-api/skills/browser-api/references/tool-contract.md +1 -1
  7. package/node_modules/@capyclaw/browser-skill-browser/contract/browser-contract.json +1 -1
  8. package/node_modules/@capyclaw/browser-skill-ops/contract/browser-contract.json +1 -1
  9. package/node_modules/@capyclaw/browser-workbench/contract/browser-contract.json +1 -1
  10. package/node_modules/@capyclaw/browser-workbench/package.json +1 -1
  11. package/node_modules/@capyclaw/browser-workbench/server/contract.mjs +1 -1
  12. package/node_modules/@capyclaw/browser-workbench/server/session-engines.mjs +39 -0
  13. package/node_modules/@capyclaw/document-workbench/src/session/context.mjs +17 -5
  14. package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +11 -10
  15. package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +8 -1
  16. package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +31 -3
  17. package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +13 -6
  18. package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +31 -15
  19. package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +28 -4
  20. package/node_modules/@capyclaw/tool-host/src/index.mjs +32 -6
  21. package/package.json +5 -6
  22. package/node_modules/playwright/LICENSE +0 -202
  23. package/node_modules/playwright/NOTICE +0 -5
  24. package/node_modules/playwright/README.md +0 -318
  25. package/node_modules/playwright/ThirdPartyNotices.txt +0 -14
  26. package/node_modules/playwright/cli.js +0 -19
  27. package/node_modules/playwright/index.d.ts +0 -17
  28. package/node_modules/playwright/index.js +0 -17
  29. package/node_modules/playwright/index.mjs +0 -18
  30. package/node_modules/playwright/lib/agents/agentParser.js +0 -89
  31. package/node_modules/playwright/lib/agents/copilot-setup-steps.yml +0 -34
  32. package/node_modules/playwright/lib/agents/generateAgents.js +0 -395
  33. package/node_modules/playwright/lib/agents/playwright-test-coverage.prompt.md +0 -31
  34. package/node_modules/playwright/lib/agents/playwright-test-generate.prompt.md +0 -8
  35. package/node_modules/playwright/lib/agents/playwright-test-generator.agent.md +0 -88
  36. package/node_modules/playwright/lib/agents/playwright-test-heal.prompt.md +0 -6
  37. package/node_modules/playwright/lib/agents/playwright-test-healer.agent.md +0 -56
  38. package/node_modules/playwright/lib/agents/playwright-test-plan.prompt.md +0 -9
  39. package/node_modules/playwright/lib/agents/playwright-test-planner.agent.md +0 -74
  40. package/node_modules/playwright/lib/cli/reportActions.js +0 -78
  41. package/node_modules/playwright/lib/cli/testActions.js +0 -217
  42. package/node_modules/playwright/lib/common/index.js +0 -2937
  43. package/node_modules/playwright/lib/common/index.js.txt +0 -33
  44. package/node_modules/playwright/lib/errorContext.js +0 -129
  45. package/node_modules/playwright/lib/globals.js +0 -58
  46. package/node_modules/playwright/lib/index.js +0 -827
  47. package/node_modules/playwright/lib/isomorphic.js +0 -260
  48. package/node_modules/playwright/lib/isomorphic.js.txt +0 -9
  49. package/node_modules/playwright/lib/loader/loaderProcessEntry.js +0 -34
  50. package/node_modules/playwright/lib/loader/loaderProcessEntry.js.txt +0 -9
  51. package/node_modules/playwright/lib/matchers/expect.js +0 -13496
  52. package/node_modules/playwright/lib/matchers/expect.js.LICENSE +0 -640
  53. package/node_modules/playwright/lib/matchers/expect.js.txt +0 -67
  54. package/node_modules/playwright/lib/package.js +0 -47
  55. package/node_modules/playwright/lib/program.js +0 -242
  56. package/node_modules/playwright/lib/runner/index.js +0 -8721
  57. package/node_modules/playwright/lib/runner/index.js.txt +0 -62
  58. package/node_modules/playwright/lib/transform/babelBundle.js +0 -72490
  59. package/node_modules/playwright/lib/transform/babelBundle.js.LICENSE +0 -2384
  60. package/node_modules/playwright/lib/transform/babelBundle.js.txt +0 -328
  61. package/node_modules/playwright/lib/transform/esmLoader.js +0 -8066
  62. package/node_modules/playwright/lib/transform/esmLoader.js.LICENSE +0 -355
  63. package/node_modules/playwright/lib/transform/esmLoader.js.txt +0 -60
  64. package/node_modules/playwright/lib/util.js +0 -373
  65. package/node_modules/playwright/lib/worker/workerProcessEntry.js +0 -1860
  66. package/node_modules/playwright/lib/worker/workerProcessEntry.js.txt +0 -19
  67. package/node_modules/playwright/package.json +0 -50
  68. package/node_modules/playwright/test.d.ts +0 -18
  69. package/node_modules/playwright/test.js +0 -24
  70. package/node_modules/playwright/test.mjs +0 -35
  71. package/node_modules/playwright/types/test.d.ts +0 -11191
  72. package/node_modules/playwright/types/testReporter.d.ts +0 -950
  73. package/node_modules/playwright-core/LICENSE +0 -202
  74. package/node_modules/playwright-core/NOTICE +0 -5
  75. package/node_modules/playwright-core/README.md +0 -3
  76. package/node_modules/playwright-core/ThirdPartyNotices.txt +0 -13
  77. package/node_modules/playwright-core/bin/install_media_pack.ps1 +0 -5
  78. package/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +0 -33
  79. package/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +0 -42
  80. package/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +0 -13
  81. package/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +0 -24
  82. package/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +0 -42
  83. package/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +0 -12
  84. package/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +0 -24
  85. package/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +0 -48
  86. package/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +0 -11
  87. package/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +0 -23
  88. package/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +0 -48
  89. package/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +0 -11
  90. package/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +0 -23
  91. package/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +0 -48
  92. package/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +0 -11
  93. package/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +0 -24
  94. package/node_modules/playwright-core/browsers.json +0 -52
  95. package/node_modules/playwright-core/cli.js +0 -22
  96. package/node_modules/playwright-core/index.d.ts +0 -17
  97. package/node_modules/playwright-core/index.js +0 -17
  98. package/node_modules/playwright-core/index.mjs +0 -28
  99. package/node_modules/playwright-core/lib/bootstrap.js +0 -149
  100. package/node_modules/playwright-core/lib/coreBundle.js +0 -78041
  101. package/node_modules/playwright-core/lib/entry/cliDaemon.js +0 -5
  102. package/node_modules/playwright-core/lib/entry/dashboardApp.js +0 -3
  103. package/node_modules/playwright-core/lib/entry/mcp.js +0 -10
  104. package/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +0 -3
  105. package/node_modules/playwright-core/lib/package.js +0 -50
  106. package/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
  107. package/node_modules/playwright-core/lib/server/electron/loader.js +0 -123
  108. package/node_modules/playwright-core/lib/serverRegistry.js +0 -1939
  109. package/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +0 -65
  110. package/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +0 -141
  111. package/node_modules/playwright-core/lib/tools/cli-client/cli.js +0 -7
  112. package/node_modules/playwright-core/lib/tools/cli-client/help.json +0 -808
  113. package/node_modules/playwright-core/lib/tools/cli-client/minimist.js +0 -128
  114. package/node_modules/playwright-core/lib/tools/cli-client/output.js +0 -352
  115. package/node_modules/playwright-core/lib/tools/cli-client/program.js +0 -422
  116. package/node_modules/playwright-core/lib/tools/cli-client/registry.js +0 -180
  117. package/node_modules/playwright-core/lib/tools/cli-client/session.js +0 -261
  118. package/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
  119. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/SKILL.md +0 -493
  120. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +0 -23
  121. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +0 -39
  122. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/pr-attachments.md +0 -60
  123. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +0 -87
  124. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/running-code.md +0 -245
  125. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/session-management.md +0 -227
  126. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/storage-state.md +0 -275
  127. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/test-generation.md +0 -433
  128. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/tracing.md +0 -139
  129. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/video-recording.md +0 -216
  130. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/SKILL.md +0 -136
  131. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +0 -144
  132. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/migration.md +0 -89
  133. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/react.md +0 -69
  134. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/typing.md +0 -173
  135. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/vue.md +0 -77
  136. package/node_modules/playwright-core/lib/tools/skills/playwright-trace/SKILL.md +0 -174
  137. package/node_modules/playwright-core/lib/tools/utils/extension.js +0 -112
  138. package/node_modules/playwright-core/lib/tools/utils/socketConnection.js +0 -108
  139. package/node_modules/playwright-core/lib/utilsBundle.js +0 -86078
  140. package/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +0 -1890
  141. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +0 -1
  142. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +0 -32
  143. package/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  144. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +0 -1
  145. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +0 -1
  146. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +0 -1
  147. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +0 -1
  148. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +0 -12
  149. package/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +0 -1
  150. package/node_modules/playwright-core/lib/vite/dashboard/index.html +0 -29
  151. package/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +0 -24
  152. package/node_modules/playwright-core/lib/vite/htmlReport/index.html +0 -16
  153. package/node_modules/playwright-core/lib/vite/htmlReport/report.css +0 -2
  154. package/node_modules/playwright-core/lib/vite/htmlReport/report.js +0 -32
  155. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +0 -1
  156. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +0 -32
  157. package/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  158. package/node_modules/playwright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +0 -1
  159. package/node_modules/playwright-core/lib/vite/recorder/assets/index-Cn0mmDuv.js +0 -129
  160. package/node_modules/playwright-core/lib/vite/recorder/index.html +0 -29
  161. package/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +0 -9
  162. package/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +0 -32
  163. package/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +0 -184
  164. package/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +0 -1
  165. package/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +0 -7
  166. package/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +0 -1
  167. package/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  168. package/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +0 -1
  169. package/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +0 -1
  170. package/node_modules/playwright-core/lib/vite/traceViewer/index.html +0 -44
  171. package/node_modules/playwright-core/lib/vite/traceViewer/index.oNry3Hjv.js +0 -1
  172. package/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +0 -16
  173. package/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +0 -9
  174. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +0 -1
  175. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +0 -10
  176. package/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +0 -4
  177. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CYwC_gH1.js +0 -5
  178. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +0 -1
  179. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +0 -18
  180. package/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +0 -1
  181. package/node_modules/playwright-core/lib/webp_codec.LICENSE +0 -173
  182. package/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
  183. package/node_modules/playwright-core/lib/xdg-open +0 -1267
  184. package/node_modules/playwright-core/package.json +0 -34
  185. package/node_modules/playwright-core/types/protocol.d.ts +0 -24776
  186. package/node_modules/playwright-core/types/structs.d.ts +0 -52
  187. package/node_modules/playwright-core/types/types.d.ts +0 -27167
@@ -1,422 +0,0 @@
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
- var import_bootstrap = require("../../bootstrap");
47
- const globalOptions = [
48
- "json",
49
- "raw",
50
- "session"
51
- ];
52
- const booleanOptions = [
53
- "all",
54
- "g",
55
- "help",
56
- "json",
57
- "raw",
58
- "version"
59
- ];
60
- async function program(options) {
61
- const clientInfo = (0, import_registry.createClientInfo)();
62
- const help = require((0, import_package.libPath)("tools", "cli-client", "help.json"));
63
- const argv = process.argv.slice(2);
64
- const boolean = [...help.booleanOptions, ...booleanOptions];
65
- const args = (0, import_minimist.minimist)(argv, { boolean, string: ["_"] });
66
- if (args.s) {
67
- args.session = args.s;
68
- delete args.s;
69
- }
70
- if (args.g) {
71
- args.global = true;
72
- delete args.g;
73
- }
74
- const output = args.json ? new import_output.JsonOutput() : new import_output.TextOutput();
75
- const commandName = args._?.[0];
76
- if (args.version || args.v) {
77
- output.version(options?.embedderVersion ?? clientInfo.version);
78
- (0, import_bootstrap.processExit)(0);
79
- }
80
- const command = commandName && help.commands[commandName];
81
- if (args.help || args.h || !commandName) {
82
- if (command) {
83
- output.help(command.help);
84
- } else {
85
- const lines = ["playwright-cli - run playwright mcp commands from terminal"];
86
- if (process.env.CLAUDECODE || process.env.COPILOT_CLI)
87
- lines.push(`Agent skill: ${import_path.default.relative(process.cwd(), (0, import_package.libPath)("tools", "skills", "playwright-cli", "SKILL.md"))}`);
88
- lines.push(help.global);
89
- output.help(lines.join("\n\n"));
90
- }
91
- (0, import_bootstrap.processExit)(0);
92
- }
93
- if (!command)
94
- output.errorUnknownCommand(commandName, help.global);
95
- validateFlags(args, command, output);
96
- validateArgs(args, command, output);
97
- const registry = await import_registry.Registry.load();
98
- const sessionName = (0, import_registry.resolveSessionName)(args.session);
99
- switch (commandName) {
100
- case "list": {
101
- const data = await collectList(registry, clientInfo, !!args.all);
102
- output.list(data);
103
- return;
104
- }
105
- case "close-all": {
106
- const entries = registry.entries(clientInfo);
107
- const closed = [];
108
- for (const entry of entries) {
109
- await new import_session.Session(entry).stop();
110
- closed.push(entry.config.name);
111
- }
112
- output.closeAll(closed);
113
- return;
114
- }
115
- case "delete-data": {
116
- const entry = registry.entry(clientInfo, sessionName);
117
- if (!entry) {
118
- output.deleteData(sessionName, { existed: false, deletedUserDataDir: false });
119
- return;
120
- }
121
- const result = await new import_session.Session(entry).deleteData();
122
- output.deleteData(sessionName, result);
123
- return;
124
- }
125
- case "kill-all": {
126
- const pids = await killAllDaemons();
127
- output.killAll(pids);
128
- return;
129
- }
130
- case "open": {
131
- const { pid } = await startSession(sessionName, registry, clientInfo, args, "open");
132
- const newEntry = await registry.loadEntry(clientInfo, sessionName);
133
- const params = args._.slice(1);
134
- const toolText = await runInSessionOrStop(newEntry, clientInfo, { _: ["goto", ...params.length ? params : ["about:blank"]] }, output);
135
- output.open(sessionName, pid, toolText);
136
- return;
137
- }
138
- case "attach": {
139
- const attachTarget = args._[1];
140
- const targetCount = (attachTarget ? 1 : 0) + (args.cdp ? 1 : 0) + (args.endpoint ? 1 : 0) + (args.extension ? 1 : 0);
141
- if (targetCount > 1)
142
- output.errorAttachConflict();
143
- if (attachTarget)
144
- args.endpoint = attachTarget;
145
- const extensionChannel = typeof args.extension === "string" ? args.extension : void 0;
146
- if (extensionChannel) {
147
- args.browser = extensionChannel;
148
- args.extension = true;
149
- }
150
- const cdpChannel = typeof args.cdp === "string" && (0, import_channelSessions.isKnownChannel)(args.cdp) ? args.cdp : void 0;
151
- const targetName = attachTarget ?? cdpChannel ?? extensionChannel ?? args.endpoint ?? args.cdp;
152
- if (!targetName)
153
- output.errorAttachNoTarget();
154
- const attachSessionName = (0, import_registry.explicitSessionName)(args.session) ?? attachTarget ?? cdpChannel ?? extensionChannel ?? sessionName;
155
- args.session = attachSessionName;
156
- const { pid } = await startSession(attachSessionName, registry, clientInfo, args, "attach");
157
- const newEntry = await registry.loadEntry(clientInfo, attachSessionName);
158
- const toolText = await runInSessionOrStop(newEntry, clientInfo, { _: ["snapshot"], filename: "<auto>" }, output);
159
- output.attach(attachSessionName, pid, targetName, toolText);
160
- return;
161
- }
162
- case "close": {
163
- const closeEntry = registry.entry(clientInfo, sessionName);
164
- const { wasOpen } = closeEntry ? await new import_session.Session(closeEntry).stop() : { wasOpen: false };
165
- output.close(sessionName, wasOpen);
166
- return;
167
- }
168
- case "detach": {
169
- const detachEntry = registry.entry(clientInfo, sessionName);
170
- if (detachEntry && !detachEntry.config.attached)
171
- output.errorDetachNotAttached(sessionName);
172
- const { wasOpen } = detachEntry ? await new import_session.Session(detachEntry).stop() : { wasOpen: false };
173
- output.detach(sessionName, wasOpen);
174
- return;
175
- }
176
- case "install":
177
- if (args.global && !args.skills)
178
- output.errorInstallGlobalRequiresSkills();
179
- await runInitWorkspace(args, output);
180
- output.installed();
181
- return;
182
- case "install-browser":
183
- await installBrowser();
184
- output.installed();
185
- return;
186
- case "show": {
187
- const daemonScript = (0, import_package.libPath)("entry", "dashboardApp.js");
188
- const daemonArgs = [
189
- daemonScript,
190
- `--workspaceDir=${clientInfo.workspaceDir ?? ""}`
191
- ];
192
- const explicit = (0, import_registry.explicitSessionName)(args.session);
193
- if (explicit)
194
- daemonArgs.push(`--sessionName=${explicit}`);
195
- if (args.port !== void 0)
196
- daemonArgs.push(`--port=${args.port}`);
197
- if (args.host !== void 0)
198
- daemonArgs.push(`--host=${args.host}`);
199
- if (args.kill) {
200
- daemonArgs.push(`--kill`);
201
- const child2 = (0, import_child_process.spawn)(process.execPath, daemonArgs, { stdio: "ignore" });
202
- await new Promise((resolve) => child2.on("exit", () => resolve()));
203
- return;
204
- }
205
- if (args.annotate) {
206
- const entry = registry.entry(clientInfo, sessionName);
207
- if (!entry)
208
- output.errorBrowserNotOpenForTool(sessionName);
209
- args.raw = true;
210
- const text = await runInSession(entry, clientInfo, args, output);
211
- output.toolResult(text);
212
- return;
213
- }
214
- const foreground = args.port !== void 0;
215
- const child = (0, import_child_process.spawn)(process.execPath, daemonArgs, {
216
- detached: !foreground,
217
- stdio: foreground ? "inherit" : ["pipe", "pipe", "ignore"],
218
- windowsHide: true
219
- });
220
- if (foreground) {
221
- await new Promise((resolve) => child.on("exit", () => resolve()));
222
- return;
223
- }
224
- const timer = setTimeout(() => child.stdin.destroy(), 6e4);
225
- child.unref();
226
- let daemonPid;
227
- try {
228
- await new Promise((resolve, reject) => {
229
- let outLog = "";
230
- child.stdout.on("data", (data) => {
231
- outLog += data.toString();
232
- const match = outLog.match(/Dashboard is running pid=(\d+)/);
233
- if (match) {
234
- daemonPid = Number(match[1]);
235
- resolve();
236
- }
237
- });
238
- child.once("exit", (code, signal) => reject(new Error(`Dashboard daemon exited (code=${code}, signal=${signal}) before signaling READY${outLog ? "\n" + outLog : ""}`)));
239
- });
240
- } finally {
241
- clearTimeout(timer);
242
- child.removeAllListeners("exit");
243
- child.stdin.destroy();
244
- child.stdout.destroy();
245
- }
246
- output.show(sessionName, daemonPid);
247
- return;
248
- }
249
- default: {
250
- const entry = registry.entry(clientInfo, sessionName);
251
- if (!entry)
252
- output.errorBrowserNotOpenForTool(sessionName);
253
- if (command.raw)
254
- args.raw = true;
255
- const text = await runInSession(entry, clientInfo, args, output);
256
- output.toolResult(text);
257
- }
258
- }
259
- }
260
- async function startSession(sessionName, registry, clientInfo, args, mode) {
261
- const entry = registry.entry(clientInfo, sessionName);
262
- if (entry)
263
- await new import_session.Session(entry).stop();
264
- return await import_session.Session.startDaemon(clientInfo, args, mode);
265
- }
266
- async function runInSession(entry, clientInfo, args, output) {
267
- const raw = !!args.raw;
268
- for (const globalOption of globalOptions)
269
- delete args[globalOption];
270
- const session = new import_session.Session(entry);
271
- const result = await session.run(clientInfo, args, { raw, json: output.json });
272
- if (result.isError)
273
- process.exitCode = 1;
274
- return result.text;
275
- }
276
- async function runInSessionOrStop(entry, clientInfo, args, output) {
277
- try {
278
- return await runInSession(entry, clientInfo, args, output);
279
- } catch (e) {
280
- await new import_session.Session(entry).stop().catch(() => {
281
- });
282
- throw e;
283
- }
284
- }
285
- async function runInitWorkspace(args, output) {
286
- const cliPath = (0, import_package.libPath)("entry", "cliDaemon.js");
287
- const daemonArgs = [
288
- cliPath,
289
- "--init-workspace",
290
- ...args.skills ? [args.global ? "--init-skills-global" : "--init-skills", String(args.skills)] : []
291
- ];
292
- await new Promise((resolve, reject) => {
293
- const child = (0, import_child_process.spawn)(process.execPath, daemonArgs, {
294
- stdio: output.installStdio(),
295
- cwd: process.cwd()
296
- });
297
- child.on("close", (code) => {
298
- if (code === 0)
299
- resolve();
300
- else
301
- reject(new Error(`Workspace initialization failed with exit code ${code}`));
302
- });
303
- });
304
- }
305
- async function installBrowser() {
306
- const argv = process.argv.map((arg) => arg === "install-browser" ? "install" : arg);
307
- const { libCli } = require("../../coreBundle.js");
308
- const { program: program2 } = require("../../utilsBundle.js");
309
- if (!program2.version())
310
- libCli.decorateProgram(program2);
311
- program2.parse(argv);
312
- }
313
- const daemonProcessPatterns = ["run-mcp-server", "run-cli-server", "cli-daemon", "cliDaemon.js", "dashboardApp.js"];
314
- async function killAllDaemons() {
315
- const platform = import_os.default.platform();
316
- const pidFilterEnv = process.env.PWTEST_KILL_ALL_PID_FILTER_FOR_TEST;
317
- const pidFilter = pidFilterEnv ? new Set(pidFilterEnv.split(",").map((p) => parseInt(p, 10)).filter((n) => !isNaN(n))) : void 0;
318
- const killed = [];
319
- try {
320
- if (platform === "win32") {
321
- const clauses = [`(${daemonProcessPatterns.map((p) => `$_.CommandLine -like '*${p}*'`).join(" -or ")})`];
322
- if (pidFilter)
323
- clauses.push(`(${[...pidFilter].map((p) => `$_.ProcessId -eq ${p}`).join(" -or ")})`);
324
- const whereClause = clauses.join(" -and ");
325
- const result = (0, import_child_process.execSync)(
326
- `powershell -NoProfile -NonInteractive -Command "Get-CimInstance Win32_Process | Where-Object { ${whereClause} } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue; $_.ProcessId }"`,
327
- { encoding: "utf-8" }
328
- );
329
- const pids = result.split("\n").map((line) => line.trim()).filter((line) => /^\d+$/.test(line));
330
- for (const pid of pids)
331
- killed.push(parseInt(pid, 10));
332
- } else {
333
- const result = (0, import_child_process.execSync)("ps auxww", { encoding: "utf-8" });
334
- const lines = result.split("\n");
335
- for (const line of lines) {
336
- if (daemonProcessPatterns.some((p) => line.includes(p))) {
337
- const parts = line.trim().split(/\s+/);
338
- const pid = parts[1];
339
- if (pid && /^\d+$/.test(pid)) {
340
- const numericPid = parseInt(pid, 10);
341
- if (pidFilter && !pidFilter.has(numericPid))
342
- continue;
343
- try {
344
- process.kill(numericPid, "SIGKILL");
345
- killed.push(numericPid);
346
- } catch {
347
- }
348
- }
349
- }
350
- }
351
- }
352
- } catch (e) {
353
- }
354
- return killed;
355
- }
356
- async function collectList(registry, clientInfo, all) {
357
- const browsers = [];
358
- const entries = registry.entryMap();
359
- const serverEntries = await import_serverRegistry.serverRegistry.list();
360
- const key = (0, import_registry.clientKey)(clientInfo);
361
- for (const [workspaceKey, list] of entries) {
362
- if (!all && workspaceKey !== key)
363
- continue;
364
- for (const entry of list) {
365
- const session = new import_session.Session(entry);
366
- const canConnect = await session.canConnect();
367
- if (!canConnect) {
368
- await session.deleteSessionConfig();
369
- continue;
370
- }
371
- const config = session.config;
372
- const channel = config.browser?.launchOptions.channel ?? config.browser?.browserName;
373
- browsers.push({
374
- name: session.name,
375
- workspace: workspaceKey,
376
- status: canConnect ? "open" : "closed",
377
- browserType: channel,
378
- userDataDir: config.browser?.userDataDir ?? null,
379
- headed: config.browser ? !config.browser.launchOptions.headless : void 0,
380
- persistent: !!config.cli.persistent,
381
- attached: !!config.attached,
382
- compatible: session.isCompatible(clientInfo),
383
- version: config.version
384
- });
385
- }
386
- }
387
- if (!all)
388
- return { all, browsers };
389
- const servers = [...serverEntries.values()].flat();
390
- return { all, browsers, servers, channelSessions: await (0, import_channelSessions.listChannelSessions)() };
391
- }
392
- function validateFlags(args, command, output) {
393
- const unknownFlags = [];
394
- for (const key of Object.keys(args)) {
395
- if (key === "_")
396
- continue;
397
- if (globalOptions.includes(key))
398
- continue;
399
- if (key in command.flags)
400
- continue;
401
- if (args[key] === false && `no-${key}` in command.flags)
402
- continue;
403
- unknownFlags.push(key);
404
- }
405
- if (unknownFlags.length)
406
- output.errorUnknownOption(unknownFlags, command.help);
407
- }
408
- function validateArgs(args, command, output) {
409
- const positional = args._.slice(1);
410
- if (positional.length > command.args.length && !command.variadicArg)
411
- output.errorTooManyArguments(command.args.length, positional.length, command.help);
412
- }
413
- function calculateSha1(buffer) {
414
- const hash = import_crypto.default.createHash("sha1");
415
- hash.update(buffer);
416
- return hash.digest("hex");
417
- }
418
- // Annotate the CommonJS export names for ESM import in node:
419
- 0 && (module.exports = {
420
- calculateSha1,
421
- program
422
- });
@@ -1,180 +0,0 @@
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
- function computeBaseDaemonDir() {
120
- if (process.env.PWTEST_DAEMON_SESSION_DIR)
121
- return process.env.PWTEST_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
- let _baseDaemonDir;
134
- function baseDaemonDir() {
135
- return _baseDaemonDir ??= computeBaseDaemonDir();
136
- }
137
- function createClientInfo() {
138
- const workspaceDir = findWorkspaceDir(process.cwd());
139
- const version = process.env.PLAYWRIGHT_CLI_VERSION_FOR_TEST || import_package.packageJSON.version;
140
- const hash = import_crypto.default.createHash("sha1");
141
- hash.update(workspaceDir || import_package.packageRoot);
142
- const workspaceDirHash = hash.digest("hex").substring(0, 16);
143
- return {
144
- version,
145
- workspaceDir,
146
- workspaceDirHash,
147
- daemonProfilesDir: daemonProfilesDir(workspaceDirHash),
148
- homeDir: import_os.default.homedir()
149
- };
150
- }
151
- function findWorkspaceDir(startDir) {
152
- let dir = startDir;
153
- for (let i = 0; i < 10; i++) {
154
- if (import_fs.default.existsSync(import_path.default.join(dir, ".playwright")))
155
- return dir;
156
- const parentDir = import_path.default.dirname(dir);
157
- if (parentDir === dir)
158
- break;
159
- dir = parentDir;
160
- }
161
- return void 0;
162
- }
163
- const daemonProfilesDir = (workspaceDirHash) => {
164
- return import_path.default.join(baseDaemonDir(), workspaceDirHash);
165
- };
166
- function explicitSessionName(sessionName) {
167
- return sessionName || process.env.PLAYWRIGHT_CLI_SESSION;
168
- }
169
- function resolveSessionName(sessionName) {
170
- return explicitSessionName(sessionName) || "default";
171
- }
172
- // Annotate the CommonJS export names for ESM import in node:
173
- 0 && (module.exports = {
174
- Registry,
175
- baseDaemonDir,
176
- clientKey,
177
- createClientInfo,
178
- explicitSessionName,
179
- resolveSessionName
180
- });