@one2x/playwright 1.57.0-alpha.1

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 (331) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +168 -0
  4. package/ThirdPartyNotices.txt +6277 -0
  5. package/cli.js +19 -0
  6. package/index.d.ts +17 -0
  7. package/index.js +17 -0
  8. package/index.mjs +18 -0
  9. package/jsx-runtime.js +42 -0
  10. package/jsx-runtime.mjs +21 -0
  11. package/lib/agents/copilot-setup-steps.yml +34 -0
  12. package/lib/agents/generateAgents.js +394 -0
  13. package/lib/agents/generateAgents.js.map +7 -0
  14. package/lib/agents/playwright-test-coverage.prompt.md +31 -0
  15. package/lib/agents/playwright-test-generate.prompt.md +8 -0
  16. package/lib/agents/playwright-test-generator.agent.md +88 -0
  17. package/lib/agents/playwright-test-heal.prompt.md +6 -0
  18. package/lib/agents/playwright-test-healer.agent.md +55 -0
  19. package/lib/agents/playwright-test-plan.prompt.md +9 -0
  20. package/lib/agents/playwright-test-planner.agent.md +117 -0
  21. package/lib/common/config.js +280 -0
  22. package/lib/common/config.js.map +7 -0
  23. package/lib/common/configLoader.js +344 -0
  24. package/lib/common/configLoader.js.map +7 -0
  25. package/lib/common/esmLoaderHost.js +102 -0
  26. package/lib/common/esmLoaderHost.js.map +7 -0
  27. package/lib/common/expectBundle.js +52 -0
  28. package/lib/common/expectBundle.js.map +7 -0
  29. package/lib/common/expectBundleImpl.js +389 -0
  30. package/lib/common/expectBundleImpl.js.map +7 -0
  31. package/lib/common/fixtures.js +302 -0
  32. package/lib/common/fixtures.js.map +7 -0
  33. package/lib/common/globals.js +58 -0
  34. package/lib/common/globals.js.map +7 -0
  35. package/lib/common/ipc.js +60 -0
  36. package/lib/common/ipc.js.map +7 -0
  37. package/lib/common/poolBuilder.js +85 -0
  38. package/lib/common/poolBuilder.js.map +7 -0
  39. package/lib/common/process.js +104 -0
  40. package/lib/common/process.js.map +7 -0
  41. package/lib/common/suiteUtils.js +140 -0
  42. package/lib/common/suiteUtils.js.map +7 -0
  43. package/lib/common/test.js +321 -0
  44. package/lib/common/test.js.map +7 -0
  45. package/lib/common/testLoader.js +101 -0
  46. package/lib/common/testLoader.js.map +7 -0
  47. package/lib/common/testType.js +298 -0
  48. package/lib/common/testType.js.map +7 -0
  49. package/lib/common/validators.js +68 -0
  50. package/lib/common/validators.js.map +7 -0
  51. package/lib/fsWatcher.js +67 -0
  52. package/lib/fsWatcher.js.map +7 -0
  53. package/lib/index.js +682 -0
  54. package/lib/index.js.map +7 -0
  55. package/lib/internalsForTest.js +42 -0
  56. package/lib/internalsForTest.js.map +7 -0
  57. package/lib/isomorphic/events.js +77 -0
  58. package/lib/isomorphic/events.js.map +7 -0
  59. package/lib/isomorphic/folders.js +30 -0
  60. package/lib/isomorphic/folders.js.map +7 -0
  61. package/lib/isomorphic/stringInternPool.js +69 -0
  62. package/lib/isomorphic/stringInternPool.js.map +7 -0
  63. package/lib/isomorphic/teleReceiver.js +508 -0
  64. package/lib/isomorphic/teleReceiver.js.map +7 -0
  65. package/lib/isomorphic/teleSuiteUpdater.js +137 -0
  66. package/lib/isomorphic/teleSuiteUpdater.js.map +7 -0
  67. package/lib/isomorphic/testServerConnection.js +211 -0
  68. package/lib/isomorphic/testServerConnection.js.map +7 -0
  69. package/lib/isomorphic/testServerInterface.js +16 -0
  70. package/lib/isomorphic/testServerInterface.js.map +7 -0
  71. package/lib/isomorphic/testTree.js +334 -0
  72. package/lib/isomorphic/testTree.js.map +7 -0
  73. package/lib/isomorphic/types.d.js +16 -0
  74. package/lib/isomorphic/types.d.js.map +7 -0
  75. package/lib/loader/loaderMain.js +59 -0
  76. package/lib/loader/loaderMain.js.map +7 -0
  77. package/lib/matchers/expect.js +325 -0
  78. package/lib/matchers/expect.js.map +7 -0
  79. package/lib/matchers/matcherHint.js +87 -0
  80. package/lib/matchers/matcherHint.js.map +7 -0
  81. package/lib/matchers/matchers.js +366 -0
  82. package/lib/matchers/matchers.js.map +7 -0
  83. package/lib/matchers/toBeTruthy.js +73 -0
  84. package/lib/matchers/toBeTruthy.js.map +7 -0
  85. package/lib/matchers/toEqual.js +99 -0
  86. package/lib/matchers/toEqual.js.map +7 -0
  87. package/lib/matchers/toHaveURL.js +102 -0
  88. package/lib/matchers/toHaveURL.js.map +7 -0
  89. package/lib/matchers/toMatchAriaSnapshot.js +159 -0
  90. package/lib/matchers/toMatchAriaSnapshot.js.map +7 -0
  91. package/lib/matchers/toMatchSnapshot.js +341 -0
  92. package/lib/matchers/toMatchSnapshot.js.map +7 -0
  93. package/lib/matchers/toMatchText.js +99 -0
  94. package/lib/matchers/toMatchText.js.map +7 -0
  95. package/lib/mcp/browser/actions.d.js +16 -0
  96. package/lib/mcp/browser/actions.d.js.map +7 -0
  97. package/lib/mcp/browser/browserContextFactory.js +357 -0
  98. package/lib/mcp/browser/browserContextFactory.js.map +7 -0
  99. package/lib/mcp/browser/browserServerBackend.js +76 -0
  100. package/lib/mcp/browser/browserServerBackend.js.map +7 -0
  101. package/lib/mcp/browser/codegen.js +66 -0
  102. package/lib/mcp/browser/codegen.js.map +7 -0
  103. package/lib/mcp/browser/config.js +425 -0
  104. package/lib/mcp/browser/config.js.map +7 -0
  105. package/lib/mcp/browser/context.js +287 -0
  106. package/lib/mcp/browser/context.js.map +7 -0
  107. package/lib/mcp/browser/response.js +228 -0
  108. package/lib/mcp/browser/response.js.map +7 -0
  109. package/lib/mcp/browser/sessionLog.js +160 -0
  110. package/lib/mcp/browser/sessionLog.js.map +7 -0
  111. package/lib/mcp/browser/tab.js +280 -0
  112. package/lib/mcp/browser/tab.js.map +7 -0
  113. package/lib/mcp/browser/tools/actionRetry.js +40 -0
  114. package/lib/mcp/browser/tools/actionRetry.js.map +7 -0
  115. package/lib/mcp/browser/tools/common.js +63 -0
  116. package/lib/mcp/browser/tools/common.js.map +7 -0
  117. package/lib/mcp/browser/tools/console.js +44 -0
  118. package/lib/mcp/browser/tools/console.js.map +7 -0
  119. package/lib/mcp/browser/tools/dialogs.js +60 -0
  120. package/lib/mcp/browser/tools/dialogs.js.map +7 -0
  121. package/lib/mcp/browser/tools/evaluate.js +69 -0
  122. package/lib/mcp/browser/tools/evaluate.js.map +7 -0
  123. package/lib/mcp/browser/tools/files.js +58 -0
  124. package/lib/mcp/browser/tools/files.js.map +7 -0
  125. package/lib/mcp/browser/tools/form.js +79 -0
  126. package/lib/mcp/browser/tools/form.js.map +7 -0
  127. package/lib/mcp/browser/tools/install.js +69 -0
  128. package/lib/mcp/browser/tools/install.js.map +7 -0
  129. package/lib/mcp/browser/tools/keyboard.js +84 -0
  130. package/lib/mcp/browser/tools/keyboard.js.map +7 -0
  131. package/lib/mcp/browser/tools/mouse.js +107 -0
  132. package/lib/mcp/browser/tools/mouse.js.map +7 -0
  133. package/lib/mcp/browser/tools/navigate.js +62 -0
  134. package/lib/mcp/browser/tools/navigate.js.map +7 -0
  135. package/lib/mcp/browser/tools/network.js +54 -0
  136. package/lib/mcp/browser/tools/network.js.map +7 -0
  137. package/lib/mcp/browser/tools/pdf.js +59 -0
  138. package/lib/mcp/browser/tools/pdf.js.map +7 -0
  139. package/lib/mcp/browser/tools/screenshot.js +106 -0
  140. package/lib/mcp/browser/tools/screenshot.js.map +7 -0
  141. package/lib/mcp/browser/tools/snapshot.js +312 -0
  142. package/lib/mcp/browser/tools/snapshot.js.map +7 -0
  143. package/lib/mcp/browser/tools/tabs.js +67 -0
  144. package/lib/mcp/browser/tools/tabs.js.map +7 -0
  145. package/lib/mcp/browser/tools/tool.js +49 -0
  146. package/lib/mcp/browser/tools/tool.js.map +7 -0
  147. package/lib/mcp/browser/tools/tracing.js +74 -0
  148. package/lib/mcp/browser/tools/tracing.js.map +7 -0
  149. package/lib/mcp/browser/tools/utils.js +96 -0
  150. package/lib/mcp/browser/tools/utils.js.map +7 -0
  151. package/lib/mcp/browser/tools/verify.js +153 -0
  152. package/lib/mcp/browser/tools/verify.js.map +7 -0
  153. package/lib/mcp/browser/tools/wait.js +63 -0
  154. package/lib/mcp/browser/tools/wait.js.map +7 -0
  155. package/lib/mcp/browser/tools.js +80 -0
  156. package/lib/mcp/browser/tools.js.map +7 -0
  157. package/lib/mcp/browser/watchdog.js +44 -0
  158. package/lib/mcp/browser/watchdog.js.map +7 -0
  159. package/lib/mcp/config.d.js +16 -0
  160. package/lib/mcp/config.d.js.map +7 -0
  161. package/lib/mcp/extension/cdpRelay.js +351 -0
  162. package/lib/mcp/extension/cdpRelay.js.map +7 -0
  163. package/lib/mcp/extension/extensionContextFactory.js +75 -0
  164. package/lib/mcp/extension/extensionContextFactory.js.map +7 -0
  165. package/lib/mcp/extension/protocol.js +28 -0
  166. package/lib/mcp/extension/protocol.js.map +7 -0
  167. package/lib/mcp/index.js +61 -0
  168. package/lib/mcp/index.js.map +7 -0
  169. package/lib/mcp/log.js +35 -0
  170. package/lib/mcp/log.js.map +7 -0
  171. package/lib/mcp/program.js +118 -0
  172. package/lib/mcp/program.js.map +7 -0
  173. package/lib/mcp/sdk/bundle.js +81 -0
  174. package/lib/mcp/sdk/bundle.js.map +7 -0
  175. package/lib/mcp/sdk/exports.js +32 -0
  176. package/lib/mcp/sdk/exports.js.map +7 -0
  177. package/lib/mcp/sdk/http.js +276 -0
  178. package/lib/mcp/sdk/http.js.map +7 -0
  179. package/lib/mcp/sdk/inProcessTransport.js +71 -0
  180. package/lib/mcp/sdk/inProcessTransport.js.map +7 -0
  181. package/lib/mcp/sdk/mdb.js +208 -0
  182. package/lib/mcp/sdk/mdb.js.map +7 -0
  183. package/lib/mcp/sdk/proxyBackend.js +128 -0
  184. package/lib/mcp/sdk/proxyBackend.js.map +7 -0
  185. package/lib/mcp/sdk/server.js +190 -0
  186. package/lib/mcp/sdk/server.js.map +7 -0
  187. package/lib/mcp/sdk/tool.js +51 -0
  188. package/lib/mcp/sdk/tool.js.map +7 -0
  189. package/lib/mcp/test/browserBackend.js +98 -0
  190. package/lib/mcp/test/browserBackend.js.map +7 -0
  191. package/lib/mcp/test/generatorTools.js +122 -0
  192. package/lib/mcp/test/generatorTools.js.map +7 -0
  193. package/lib/mcp/test/plannerTools.js +46 -0
  194. package/lib/mcp/test/plannerTools.js.map +7 -0
  195. package/lib/mcp/test/seed.js +82 -0
  196. package/lib/mcp/test/seed.js.map +7 -0
  197. package/lib/mcp/test/streams.js +41 -0
  198. package/lib/mcp/test/streams.js.map +7 -0
  199. package/lib/mcp/test/testBackend.js +97 -0
  200. package/lib/mcp/test/testBackend.js.map +7 -0
  201. package/lib/mcp/test/testContext.js +216 -0
  202. package/lib/mcp/test/testContext.js.map +7 -0
  203. package/lib/mcp/test/testTool.js +30 -0
  204. package/lib/mcp/test/testTool.js.map +7 -0
  205. package/lib/mcp/test/testTools.js +111 -0
  206. package/lib/mcp/test/testTools.js.map +7 -0
  207. package/lib/mcpBundleImpl.js +41 -0
  208. package/lib/mcpBundleImpl.js.map +7 -0
  209. package/lib/plugins/gitCommitInfoPlugin.js +198 -0
  210. package/lib/plugins/gitCommitInfoPlugin.js.map +7 -0
  211. package/lib/plugins/index.js +28 -0
  212. package/lib/plugins/index.js.map +7 -0
  213. package/lib/plugins/webServerPlugin.js +233 -0
  214. package/lib/plugins/webServerPlugin.js.map +7 -0
  215. package/lib/program.js +412 -0
  216. package/lib/program.js.map +7 -0
  217. package/lib/reporters/base.js +609 -0
  218. package/lib/reporters/base.js.map +7 -0
  219. package/lib/reporters/blob.js +135 -0
  220. package/lib/reporters/blob.js.map +7 -0
  221. package/lib/reporters/dot.js +82 -0
  222. package/lib/reporters/dot.js.map +7 -0
  223. package/lib/reporters/empty.js +32 -0
  224. package/lib/reporters/empty.js.map +7 -0
  225. package/lib/reporters/github.js +128 -0
  226. package/lib/reporters/github.js.map +7 -0
  227. package/lib/reporters/html.js +623 -0
  228. package/lib/reporters/html.js.map +7 -0
  229. package/lib/reporters/internalReporter.js +130 -0
  230. package/lib/reporters/internalReporter.js.map +7 -0
  231. package/lib/reporters/json.js +254 -0
  232. package/lib/reporters/json.js.map +7 -0
  233. package/lib/reporters/junit.js +232 -0
  234. package/lib/reporters/junit.js.map +7 -0
  235. package/lib/reporters/line.js +113 -0
  236. package/lib/reporters/line.js.map +7 -0
  237. package/lib/reporters/list.js +231 -0
  238. package/lib/reporters/list.js.map +7 -0
  239. package/lib/reporters/listModeReporter.js +69 -0
  240. package/lib/reporters/listModeReporter.js.map +7 -0
  241. package/lib/reporters/markdown.js +144 -0
  242. package/lib/reporters/markdown.js.map +7 -0
  243. package/lib/reporters/merge.js +541 -0
  244. package/lib/reporters/merge.js.map +7 -0
  245. package/lib/reporters/multiplexer.js +104 -0
  246. package/lib/reporters/multiplexer.js.map +7 -0
  247. package/lib/reporters/reporterV2.js +102 -0
  248. package/lib/reporters/reporterV2.js.map +7 -0
  249. package/lib/reporters/teleEmitter.js +298 -0
  250. package/lib/reporters/teleEmitter.js.map +7 -0
  251. package/lib/reporters/versions/blobV1.js +16 -0
  252. package/lib/reporters/versions/blobV1.js.map +7 -0
  253. package/lib/runner/dispatcher.js +491 -0
  254. package/lib/runner/dispatcher.js.map +7 -0
  255. package/lib/runner/failureTracker.js +72 -0
  256. package/lib/runner/failureTracker.js.map +7 -0
  257. package/lib/runner/lastRun.js +77 -0
  258. package/lib/runner/lastRun.js.map +7 -0
  259. package/lib/runner/loadUtils.js +334 -0
  260. package/lib/runner/loadUtils.js.map +7 -0
  261. package/lib/runner/loaderHost.js +89 -0
  262. package/lib/runner/loaderHost.js.map +7 -0
  263. package/lib/runner/processHost.js +161 -0
  264. package/lib/runner/processHost.js.map +7 -0
  265. package/lib/runner/projectUtils.js +241 -0
  266. package/lib/runner/projectUtils.js.map +7 -0
  267. package/lib/runner/rebase.js +189 -0
  268. package/lib/runner/rebase.js.map +7 -0
  269. package/lib/runner/reporters.js +138 -0
  270. package/lib/runner/reporters.js.map +7 -0
  271. package/lib/runner/runner.js +110 -0
  272. package/lib/runner/sigIntWatcher.js +96 -0
  273. package/lib/runner/sigIntWatcher.js.map +7 -0
  274. package/lib/runner/taskRunner.js +127 -0
  275. package/lib/runner/taskRunner.js.map +7 -0
  276. package/lib/runner/tasks.js +410 -0
  277. package/lib/runner/tasks.js.map +7 -0
  278. package/lib/runner/testGroups.js +117 -0
  279. package/lib/runner/testGroups.js.map +7 -0
  280. package/lib/runner/testRunner.js +390 -0
  281. package/lib/runner/testRunner.js.map +7 -0
  282. package/lib/runner/testServer.js +267 -0
  283. package/lib/runner/testServer.js.map +7 -0
  284. package/lib/runner/uiModeReporter.js +30 -0
  285. package/lib/runner/uiModeReporter.js.map +7 -0
  286. package/lib/runner/vcs.js +72 -0
  287. package/lib/runner/vcs.js.map +7 -0
  288. package/lib/runner/watchMode.js +395 -0
  289. package/lib/runner/watchMode.js.map +7 -0
  290. package/lib/runner/workerHost.js +95 -0
  291. package/lib/runner/workerHost.js.map +7 -0
  292. package/lib/third_party/pirates.js +62 -0
  293. package/lib/third_party/pirates.js.map +7 -0
  294. package/lib/third_party/tsconfig-loader.js +103 -0
  295. package/lib/third_party/tsconfig-loader.js.map +7 -0
  296. package/lib/transform/babelBundle.js +43 -0
  297. package/lib/transform/babelBundle.js.map +7 -0
  298. package/lib/transform/babelBundleImpl.js +461 -0
  299. package/lib/transform/babelBundleImpl.js.map +7 -0
  300. package/lib/transform/compilationCache.js +272 -0
  301. package/lib/transform/compilationCache.js.map +7 -0
  302. package/lib/transform/esmLoader.js +104 -0
  303. package/lib/transform/esmLoader.js.map +7 -0
  304. package/lib/transform/portTransport.js +67 -0
  305. package/lib/transform/portTransport.js.map +7 -0
  306. package/lib/transform/transform.js +293 -0
  307. package/lib/transform/transform.js.map +7 -0
  308. package/lib/util.js +403 -0
  309. package/lib/util.js.map +7 -0
  310. package/lib/utilsBundle.js +43 -0
  311. package/lib/utilsBundle.js.map +7 -0
  312. package/lib/utilsBundleImpl.js +100 -0
  313. package/lib/utilsBundleImpl.js.map +7 -0
  314. package/lib/worker/fixtureRunner.js +258 -0
  315. package/lib/worker/fixtureRunner.js.map +7 -0
  316. package/lib/worker/testInfo.js +514 -0
  317. package/lib/worker/testInfo.js.map +7 -0
  318. package/lib/worker/testTracing.js +344 -0
  319. package/lib/worker/testTracing.js.map +7 -0
  320. package/lib/worker/timeoutManager.js +174 -0
  321. package/lib/worker/timeoutManager.js.map +7 -0
  322. package/lib/worker/util.js +31 -0
  323. package/lib/worker/util.js.map +7 -0
  324. package/lib/worker/workerMain.js +520 -0
  325. package/lib/worker/workerMain.js.map +7 -0
  326. package/package.json +74 -0
  327. package/test.d.ts +18 -0
  328. package/test.js +24 -0
  329. package/test.mjs +33 -0
  330. package/types/test.d.ts +10196 -0
  331. package/types/testReporter.d.ts +821 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/mcp/sdk/server.ts"],
4
+ "sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { fileURLToPath } from 'url';\n\nimport { debug } from 'playwright-core/lib/utilsBundle';\n\nimport * as mcpBundle from './bundle';\nimport { installHttpTransport, startHttpServer } from './http';\nimport { InProcessTransport } from './inProcessTransport';\n\nimport type { Tool, CallToolResult, CallToolRequest, Root } from '@modelcontextprotocol/sdk/types.js';\nimport type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';\nexport type { Server } from '@modelcontextprotocol/sdk/server/index.js';\nexport type { Tool, CallToolResult, CallToolRequest, Root } from '@modelcontextprotocol/sdk/types.js';\nimport type { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport type { FullConfig } from '../browser/config';\n\nconst serverDebug = debug('pw:mcp:server');\n\nexport type ClientInfo = {\n name: string;\n version: string;\n roots: Root[];\n timestamp: number;\n};\n\nexport type ProgressParams = { message?: string, progress?: number, total?: number };\nexport type ProgressCallback = (params: ProgressParams) => void;\n\nexport interface ServerBackend {\n initialize?(server: Server, clientInfo: ClientInfo): Promise<void>;\n listTools(): Promise<Tool[]>;\n afterCallTool?(name: string, args: CallToolRequest['params']['arguments'], result: CallToolResult): Promise<void>;\n callTool(name: string, args: CallToolRequest['params']['arguments'], progress: ProgressCallback): Promise<CallToolResult>;\n serverClosed?(server: Server): void;\n}\n\nexport type ServerBackendFactory = {\n name: string;\n nameInConfig: string;\n version: string;\n config: FullConfig;\n create: (config: FullConfig) => ServerBackend;\n};\n\nexport async function connect(factory: ServerBackendFactory, transport: Transport, runHeartbeat: boolean, config?: FullConfig) {\n const backend = factory.create(config || factory.config);\n const server = createServer(factory.name, factory.version, backend, runHeartbeat);\n await server.connect(transport);\n}\n\nexport async function wrapInProcess(backend: ServerBackend): Promise<Transport> {\n const server = createServer('Internal', '0.0.0', backend, false);\n return new InProcessTransport(server);\n}\n\nexport function createServer(name: string, version: string, backend: ServerBackend, runHeartbeat: boolean): Server {\n const server = new mcpBundle.Server({ name, version }, {\n capabilities: {\n tools: {},\n }\n });\n\n server.setRequestHandler(mcpBundle.ListToolsRequestSchema, async () => {\n serverDebug('listTools');\n const tools = await backend.listTools();\n return { tools };\n });\n\n let initializePromise: Promise<void> | undefined;\n server.setRequestHandler(mcpBundle.CallToolRequestSchema, async (request, extra) => {\n serverDebug('callTool', request);\n\n const progressToken = request.params._meta?.progressToken;\n let progressCounter = 0;\n\n const progress = progressToken ? (params: ProgressParams) => {\n extra.sendNotification({\n method: 'notifications/progress',\n params: {\n progressToken,\n progress: params.progress ?? ++progressCounter,\n total: params.total,\n message: params.message,\n },\n }).catch(serverDebug);\n } : () => {};\n\n try {\n if (!initializePromise)\n initializePromise = initializeServer(server, backend, runHeartbeat);\n await initializePromise;\n return mergeTextParts(await backend.callTool(request.params.name, request.params.arguments || {}, progress));\n } catch (error) {\n return {\n content: [{ type: 'text', text: '### Result\\n' + String(error) }],\n isError: true,\n };\n }\n });\n addServerListener(server, 'close', () => backend.serverClosed?.(server));\n return server;\n}\n\nconst initializeServer = async (server: Server, backend: ServerBackend, runHeartbeat: boolean) => {\n const capabilities = server.getClientCapabilities();\n let clientRoots: Root[] = [];\n if (capabilities?.roots) {\n const { roots } = await server.listRoots().catch(e => {\n serverDebug(e);\n return { roots: [] };\n });\n clientRoots = roots;\n }\n\n const clientInfo: ClientInfo = {\n name: server.getClientVersion()?.name ?? 'unknown',\n version: server.getClientVersion()?.version ?? 'unknown',\n roots: clientRoots,\n timestamp: Date.now(),\n };\n\n await backend.initialize?.(server, clientInfo);\n if (runHeartbeat)\n startHeartbeat(server);\n};\n\nconst startHeartbeat = (server: Server) => {\n const beat = () => {\n Promise.race([\n server.ping(),\n new Promise((_, reject) => setTimeout(() => reject(new Error('ping timeout')), 5000)),\n ]).then(() => {\n setTimeout(beat, 3000);\n }).catch(() => {\n void server.close();\n });\n };\n\n beat();\n};\n\nfunction addServerListener(server: Server, event: 'close' | 'initialized', listener: () => void) {\n const oldListener = server[`on${event}`];\n server[`on${event}`] = () => {\n oldListener?.();\n listener();\n };\n}\n\nexport async function start(serverBackendFactory: ServerBackendFactory, options: { host?: string; port?: number, allowedHosts?: string[] }) {\n if (options.port === undefined) {\n await connect(serverBackendFactory, new mcpBundle.StdioServerTransport(), false);\n return;\n }\n\n const httpServer = await startHttpServer(options);\n const url = await installHttpTransport(httpServer, serverBackendFactory, false, options.allowedHosts);\n\n const mcpConfig: any = { mcpServers: { } };\n mcpConfig.mcpServers[serverBackendFactory.nameInConfig] = {\n url: `${url}/mcp`\n };\n const message = [\n `Listening on ${url}`,\n 'Put this in your client config:',\n JSON.stringify(mcpConfig, undefined, 2),\n 'For legacy SSE transport support, you can use the /sse endpoint instead.',\n ].join('\\n');\n // eslint-disable-next-line no-console\n console.error(message);\n}\n\nexport function firstRootPath(clientInfo: ClientInfo): string | undefined {\n if (clientInfo.roots.length === 0)\n return undefined;\n const firstRootUri = clientInfo.roots[0]?.uri;\n const url = firstRootUri ? new URL(firstRootUri) : undefined;\n return url ? fileURLToPath(url) : undefined;\n}\n\nfunction mergeTextParts(result: CallToolResult): CallToolResult {\n const content: CallToolResult['content'] = [];\n const testParts: string[] = [];\n for (const part of result.content) {\n if (part.type === 'text') {\n testParts.push(part.text);\n continue;\n }\n if (testParts.length > 0) {\n content.push({ type: 'text', text: testParts.join('\\n') });\n testParts.length = 0;\n }\n content.push(part);\n }\n if (testParts.length > 0)\n content.push({ type: 'text', text: testParts.join('\\n') });\n return {\n ...result,\n content,\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,iBAA8B;AAE9B,yBAAsB;AAEtB,gBAA2B;AAC3B,kBAAsD;AACtD,gCAAmC;AASnC,MAAM,kBAAc,0BAAM,eAAe;AA4BzC,eAAsB,QAAQ,SAA+B,WAAsB,cAAuB,QAAqB;AAC7H,QAAM,UAAU,QAAQ,OAAO,UAAU,QAAQ,MAAM;AACvD,QAAM,SAAS,aAAa,QAAQ,MAAM,QAAQ,SAAS,SAAS,YAAY;AAChF,QAAM,OAAO,QAAQ,SAAS;AAChC;AAEA,eAAsB,cAAc,SAA4C;AAC9E,QAAM,SAAS,aAAa,YAAY,SAAS,SAAS,KAAK;AAC/D,SAAO,IAAI,6CAAmB,MAAM;AACtC;AAEO,SAAS,aAAa,MAAc,SAAiB,SAAwB,cAA+B;AACjH,QAAM,SAAS,IAAI,UAAU,OAAO,EAAE,MAAM,QAAQ,GAAG;AAAA,IACrD,cAAc;AAAA,MACZ,OAAO,CAAC;AAAA,IACV;AAAA,EACF,CAAC;AAED,SAAO,kBAAkB,UAAU,wBAAwB,YAAY;AACrE,gBAAY,WAAW;AACvB,UAAM,QAAQ,MAAM,QAAQ,UAAU;AACtC,WAAO,EAAE,MAAM;AAAA,EACjB,CAAC;AAED,MAAI;AACJ,SAAO,kBAAkB,UAAU,uBAAuB,OAAO,SAAS,UAAU;AAClF,gBAAY,YAAY,OAAO;AAE/B,UAAM,gBAAgB,QAAQ,OAAO,OAAO;AAC5C,QAAI,kBAAkB;AAEtB,UAAM,WAAW,gBAAgB,CAAC,WAA2B;AAC3D,YAAM,iBAAiB;AAAA,QACrB,QAAQ;AAAA,QACR,QAAQ;AAAA,UACN;AAAA,UACA,UAAU,OAAO,YAAY,EAAE;AAAA,UAC/B,OAAO,OAAO;AAAA,UACd,SAAS,OAAO;AAAA,QAClB;AAAA,MACF,CAAC,EAAE,MAAM,WAAW;AAAA,IACtB,IAAI,MAAM;AAAA,IAAC;AAEX,QAAI;AACF,UAAI,CAAC;AACH,4BAAoB,iBAAiB,QAAQ,SAAS,YAAY;AACpE,YAAM;AACN,aAAO,eAAe,MAAM,QAAQ,SAAS,QAAQ,OAAO,MAAM,QAAQ,OAAO,aAAa,CAAC,GAAG,QAAQ,CAAC;AAAA,IAC7G,SAAS,OAAO;AACd,aAAO;AAAA,QACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,iBAAiB,OAAO,KAAK,EAAE,CAAC;AAAA,QAChE,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAC;AACD,oBAAkB,QAAQ,SAAS,MAAM,QAAQ,eAAe,MAAM,CAAC;AACvE,SAAO;AACT;AAEA,MAAM,mBAAmB,OAAO,QAAgB,SAAwB,iBAA0B;AAChG,QAAM,eAAe,OAAO,sBAAsB;AAClD,MAAI,cAAsB,CAAC;AAC3B,MAAI,cAAc,OAAO;AACvB,UAAM,EAAE,MAAM,IAAI,MAAM,OAAO,UAAU,EAAE,MAAM,OAAK;AACpD,kBAAY,CAAC;AACb,aAAO,EAAE,OAAO,CAAC,EAAE;AAAA,IACrB,CAAC;AACD,kBAAc;AAAA,EAChB;AAEA,QAAM,aAAyB;AAAA,IAC7B,MAAM,OAAO,iBAAiB,GAAG,QAAQ;AAAA,IACzC,SAAS,OAAO,iBAAiB,GAAG,WAAW;AAAA,IAC/C,OAAO;AAAA,IACP,WAAW,KAAK,IAAI;AAAA,EACtB;AAEA,QAAM,QAAQ,aAAa,QAAQ,UAAU;AAC7C,MAAI;AACF,mBAAe,MAAM;AACzB;AAEA,MAAM,iBAAiB,CAAC,WAAmB;AACzC,QAAM,OAAO,MAAM;AACjB,YAAQ,KAAK;AAAA,MACX,OAAO,KAAK;AAAA,MACZ,IAAI,QAAQ,CAAC,GAAG,WAAW,WAAW,MAAM,OAAO,IAAI,MAAM,cAAc,CAAC,GAAG,GAAI,CAAC;AAAA,IACtF,CAAC,EAAE,KAAK,MAAM;AACZ,iBAAW,MAAM,GAAI;AAAA,IACvB,CAAC,EAAE,MAAM,MAAM;AACb,WAAK,OAAO,MAAM;AAAA,IACpB,CAAC;AAAA,EACH;AAEA,OAAK;AACP;AAEA,SAAS,kBAAkB,QAAgB,OAAgC,UAAsB;AAC/F,QAAM,cAAc,OAAO,KAAK,KAAK,EAAE;AACvC,SAAO,KAAK,KAAK,EAAE,IAAI,MAAM;AAC3B,kBAAc;AACd,aAAS;AAAA,EACX;AACF;AAEA,eAAsB,MAAM,sBAA4C,SAAoE;AAC1I,MAAI,QAAQ,SAAS,QAAW;AAC9B,UAAM,QAAQ,sBAAsB,IAAI,UAAU,qBAAqB,GAAG,KAAK;AAC/E;AAAA,EACF;AAEA,QAAM,aAAa,UAAM,6BAAgB,OAAO;AAChD,QAAM,MAAM,UAAM,kCAAqB,YAAY,sBAAsB,OAAO,QAAQ,YAAY;AAEpG,QAAM,YAAiB,EAAE,YAAY,CAAE,EAAE;AACzC,YAAU,WAAW,qBAAqB,YAAY,IAAI;AAAA,IACxD,KAAK,GAAG,GAAG;AAAA,EACb;AACA,QAAM,UAAU;AAAA,IACd,gBAAgB,GAAG;AAAA,IACnB;AAAA,IACA,KAAK,UAAU,WAAW,QAAW,CAAC;AAAA,IACtC;AAAA,EACF,EAAE,KAAK,IAAI;AAEX,UAAQ,MAAM,OAAO;AACvB;AAEO,SAAS,cAAc,YAA4C;AACxE,MAAI,WAAW,MAAM,WAAW;AAC9B,WAAO;AACT,QAAM,eAAe,WAAW,MAAM,CAAC,GAAG;AAC1C,QAAM,MAAM,eAAe,IAAI,IAAI,YAAY,IAAI;AACnD,SAAO,UAAM,0BAAc,GAAG,IAAI;AACpC;AAEA,SAAS,eAAe,QAAwC;AAC9D,QAAM,UAAqC,CAAC;AAC5C,QAAM,YAAsB,CAAC;AAC7B,aAAW,QAAQ,OAAO,SAAS;AACjC,QAAI,KAAK,SAAS,QAAQ;AACxB,gBAAU,KAAK,KAAK,IAAI;AACxB;AAAA,IACF;AACA,QAAI,UAAU,SAAS,GAAG;AACxB,cAAQ,KAAK,EAAE,MAAM,QAAQ,MAAM,UAAU,KAAK,IAAI,EAAE,CAAC;AACzD,gBAAU,SAAS;AAAA,IACrB;AACA,YAAQ,KAAK,IAAI;AAAA,EACnB;AACA,MAAI,UAAU,SAAS;AACrB,YAAQ,KAAK,EAAE,MAAM,QAAQ,MAAM,UAAU,KAAK,IAAI,EAAE,CAAC;AAC3D,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,51 @@
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 tool_exports = {};
20
+ __export(tool_exports, {
21
+ defineToolSchema: () => defineToolSchema,
22
+ toMcpTool: () => toMcpTool
23
+ });
24
+ module.exports = __toCommonJS(tool_exports);
25
+ var import_bundle = require("../sdk/bundle");
26
+ const typesWithIntent = ["action", "assertion", "input"];
27
+ function toMcpTool(tool, options) {
28
+ const inputSchema = options?.addIntent && typesWithIntent.includes(tool.type) ? tool.inputSchema.extend({
29
+ intent: import_bundle.z.string().describe("The intent of the call, for example the test step description plan idea")
30
+ }) : tool.inputSchema;
31
+ const readOnly = tool.type === "readOnly" || tool.type === "assertion";
32
+ return {
33
+ name: tool.name,
34
+ description: tool.description,
35
+ inputSchema: (0, import_bundle.zodToJsonSchema)(inputSchema, { strictUnions: true }),
36
+ annotations: {
37
+ title: tool.title,
38
+ readOnlyHint: readOnly,
39
+ destructiveHint: !readOnly,
40
+ openWorldHint: true
41
+ }
42
+ };
43
+ }
44
+ function defineToolSchema(tool) {
45
+ return tool;
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ defineToolSchema,
50
+ toMcpTool
51
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/mcp/sdk/tool.ts"],
4
+ "sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { z as zod, zodToJsonSchema } from '../sdk/bundle';\n\nimport type { z } from 'zod';\nimport type * as mcpServer from './server';\n\nexport type ToolSchema<Input extends z.Schema> = {\n name: string;\n title: string;\n description: string;\n inputSchema: Input;\n type: 'input' | 'assertion' | 'action' | 'readOnly';\n};\n\nconst typesWithIntent = ['action', 'assertion', 'input'];\n\nexport function toMcpTool(tool: ToolSchema<any>, options?: { addIntent?: boolean }): mcpServer.Tool {\n const inputSchema = options?.addIntent && typesWithIntent.includes(tool.type) ? tool.inputSchema.extend({\n intent: zod.string().describe('The intent of the call, for example the test step description plan idea')\n }) : tool.inputSchema;\n const readOnly = tool.type === 'readOnly' || tool.type === 'assertion';\n return {\n name: tool.name,\n description: tool.description,\n inputSchema: zodToJsonSchema(inputSchema, { strictUnions: true }) as mcpServer.Tool['inputSchema'],\n annotations: {\n title: tool.title,\n readOnlyHint: readOnly,\n destructiveHint: !readOnly,\n openWorldHint: true,\n },\n };\n}\n\nexport function defineToolSchema<Input extends z.Schema>(tool: ToolSchema<Input>): ToolSchema<Input> {\n return tool;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,oBAA2C;AAa3C,MAAM,kBAAkB,CAAC,UAAU,aAAa,OAAO;AAEhD,SAAS,UAAU,MAAuB,SAAmD;AAClG,QAAM,cAAc,SAAS,aAAa,gBAAgB,SAAS,KAAK,IAAI,IAAI,KAAK,YAAY,OAAO;AAAA,IACtG,QAAQ,cAAAA,EAAI,OAAO,EAAE,SAAS,yEAAyE;AAAA,EACzG,CAAC,IAAI,KAAK;AACV,QAAM,WAAW,KAAK,SAAS,cAAc,KAAK,SAAS;AAC3D,SAAO;AAAA,IACL,MAAM,KAAK;AAAA,IACX,aAAa,KAAK;AAAA,IAClB,iBAAa,+BAAgB,aAAa,EAAE,cAAc,KAAK,CAAC;AAAA,IAChE,aAAa;AAAA,MACX,OAAO,KAAK;AAAA,MACZ,cAAc;AAAA,MACd,iBAAiB,CAAC;AAAA,MAClB,eAAe;AAAA,IACjB;AAAA,EACF;AACF;AAEO,SAAS,iBAAyC,MAA4C;AACnG,SAAO;AACT;",
6
+ "names": ["zod"]
7
+ }
@@ -0,0 +1,98 @@
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 browserBackend_exports = {};
30
+ __export(browserBackend_exports, {
31
+ runBrowserBackendAtEnd: () => runBrowserBackendAtEnd
32
+ });
33
+ module.exports = __toCommonJS(browserBackend_exports);
34
+ var mcp = __toESM(require("../sdk/exports"));
35
+ var import_globals = require("../../common/globals");
36
+ var import_util = require("../../util");
37
+ var import_config = require("../browser/config");
38
+ var import_browserServerBackend = require("../browser/browserServerBackend");
39
+ var import_tab = require("../browser/tab");
40
+ async function runBrowserBackendAtEnd(context, errorMessage) {
41
+ const testInfo = (0, import_globals.currentTestInfo)();
42
+ if (!testInfo)
43
+ return;
44
+ const shouldPause = errorMessage ? testInfo?._pauseOnError() : testInfo?._pauseAtEnd();
45
+ if (!shouldPause)
46
+ return;
47
+ const lines = [];
48
+ if (errorMessage)
49
+ lines.push(`### Paused on error:`, (0, import_util.stripAnsiEscapes)(errorMessage));
50
+ else
51
+ lines.push(`### Paused at end of test. ready for interaction`);
52
+ for (let i = 0; i < context.pages().length; i++) {
53
+ const page = context.pages()[i];
54
+ const stateSuffix = context.pages().length > 1 ? i + 1 + " of " + context.pages().length : "state";
55
+ lines.push(
56
+ "",
57
+ `### Page ${stateSuffix}`,
58
+ `- Page URL: ${page.url()}`,
59
+ `- Page Title: ${await page.title()}`.trim()
60
+ );
61
+ let console = errorMessage ? await import_tab.Tab.collectConsoleMessages(page) : [];
62
+ console = console.filter((msg) => !msg.type || msg.type === "error");
63
+ if (console.length) {
64
+ lines.push("- Console Messages:");
65
+ for (const message of console)
66
+ lines.push(` - ${message.toString()}`);
67
+ }
68
+ lines.push(
69
+ `- Page Snapshot:`,
70
+ "```yaml",
71
+ await page._snapshotForAI(),
72
+ "```"
73
+ );
74
+ }
75
+ lines.push("");
76
+ if (errorMessage)
77
+ lines.push(`### Task`, `Try recovering from the error prior to continuing`);
78
+ const config = {
79
+ ...import_config.defaultConfig,
80
+ capabilities: ["testing"]
81
+ };
82
+ await mcp.runOnPauseBackendLoop(new import_browserServerBackend.BrowserServerBackend(config, identityFactory(context)), lines.join("\n"));
83
+ }
84
+ function identityFactory(browserContext) {
85
+ return {
86
+ createContext: async (clientInfo, abortSignal, toolName) => {
87
+ return {
88
+ browserContext,
89
+ close: async () => {
90
+ }
91
+ };
92
+ }
93
+ };
94
+ }
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ runBrowserBackendAtEnd
98
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/mcp/test/browserBackend.ts"],
4
+ "sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as mcp from '../sdk/exports';\nimport { currentTestInfo } from '../../common/globals';\nimport { stripAnsiEscapes } from '../../util';\nimport { defaultConfig, FullConfig } from '../browser/config';\nimport { BrowserServerBackend } from '../browser/browserServerBackend';\nimport { Tab } from '../browser/tab';\n\nimport type * as playwright from '../../../index';\nimport type { Page } from '../../../../playwright-core/src/client/page';\nimport type { BrowserContextFactory } from '../browser/browserContextFactory';\nimport type { ClientInfo } from '../sdk/server';\n\nexport async function runBrowserBackendAtEnd(context: playwright.BrowserContext, errorMessage?: string) {\n const testInfo = currentTestInfo();\n if (!testInfo)\n return;\n\n const shouldPause = errorMessage ? testInfo?._pauseOnError() : testInfo?._pauseAtEnd();\n if (!shouldPause)\n return;\n\n const lines: string[] = [];\n if (errorMessage)\n lines.push(`### Paused on error:`, stripAnsiEscapes(errorMessage));\n else\n lines.push(`### Paused at end of test. ready for interaction`);\n\n for (let i = 0; i < context.pages().length; i++) {\n const page = context.pages()[i];\n const stateSuffix = context.pages().length > 1 ? (i + 1) + ' of ' + (context.pages().length) : 'state';\n lines.push(\n '',\n `### Page ${stateSuffix}`,\n `- Page URL: ${page.url()}`,\n `- Page Title: ${await page.title()}`.trim()\n );\n // Only print console errors when pausing on error, not when everything works as expected.\n let console = errorMessage ? await Tab.collectConsoleMessages(page) : [];\n console = console.filter(msg => !msg.type || msg.type === 'error');\n if (console.length) {\n lines.push('- Console Messages:');\n for (const message of console)\n lines.push(` - ${message.toString()}`);\n }\n lines.push(\n `- Page Snapshot:`,\n '```yaml',\n await (page as Page)._snapshotForAI(),\n '```',\n );\n }\n\n lines.push('');\n if (errorMessage)\n lines.push(`### Task`, `Try recovering from the error prior to continuing`);\n\n const config: FullConfig = {\n ...defaultConfig,\n capabilities: ['testing'],\n };\n\n await mcp.runOnPauseBackendLoop(new BrowserServerBackend(config, identityFactory(context)), lines.join('\\n'));\n}\n\nfunction identityFactory(browserContext: playwright.BrowserContext): BrowserContextFactory {\n return {\n createContext: async (clientInfo: ClientInfo, abortSignal: AbortSignal, toolName: string | undefined) => {\n return {\n browserContext,\n close: async () => {}\n };\n }\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,UAAqB;AACrB,qBAAgC;AAChC,kBAAiC;AACjC,oBAA0C;AAC1C,kCAAqC;AACrC,iBAAoB;AAOpB,eAAsB,uBAAuB,SAAoC,cAAuB;AACtG,QAAM,eAAW,gCAAgB;AACjC,MAAI,CAAC;AACH;AAEF,QAAM,cAAc,eAAe,UAAU,cAAc,IAAI,UAAU,YAAY;AACrF,MAAI,CAAC;AACH;AAEF,QAAM,QAAkB,CAAC;AACzB,MAAI;AACF,UAAM,KAAK,4BAAwB,8BAAiB,YAAY,CAAC;AAAA;AAEjE,UAAM,KAAK,kDAAkD;AAE/D,WAAS,IAAI,GAAG,IAAI,QAAQ,MAAM,EAAE,QAAQ,KAAK;AAC/C,UAAM,OAAO,QAAQ,MAAM,EAAE,CAAC;AAC9B,UAAM,cAAc,QAAQ,MAAM,EAAE,SAAS,IAAK,IAAI,IAAK,SAAU,QAAQ,MAAM,EAAE,SAAU;AAC/F,UAAM;AAAA,MACF;AAAA,MACA,YAAY,WAAW;AAAA,MACvB,eAAe,KAAK,IAAI,CAAC;AAAA,MACzB,iBAAiB,MAAM,KAAK,MAAM,CAAC,GAAG,KAAK;AAAA,IAC/C;AAEA,QAAI,UAAU,eAAe,MAAM,eAAI,uBAAuB,IAAI,IAAI,CAAC;AACvE,cAAU,QAAQ,OAAO,SAAO,CAAC,IAAI,QAAQ,IAAI,SAAS,OAAO;AACjE,QAAI,QAAQ,QAAQ;AAClB,YAAM,KAAK,qBAAqB;AAChC,iBAAW,WAAW;AACpB,cAAM,KAAK,OAAO,QAAQ,SAAS,CAAC,EAAE;AAAA,IAC1C;AACA,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA,MAAO,KAAc,eAAe;AAAA,MACpC;AAAA,IACJ;AAAA,EACF;AAEA,QAAM,KAAK,EAAE;AACb,MAAI;AACF,UAAM,KAAK,YAAY,mDAAmD;AAE5E,QAAM,SAAqB;AAAA,IACzB,GAAG;AAAA,IACH,cAAc,CAAC,SAAS;AAAA,EAC1B;AAEA,QAAM,IAAI,sBAAsB,IAAI,iDAAqB,QAAQ,gBAAgB,OAAO,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC;AAC9G;AAEA,SAAS,gBAAgB,gBAAkE;AACzF,SAAO;AAAA,IACL,eAAe,OAAO,YAAwB,aAA0B,aAAiC;AACvG,aAAO;AAAA,QACL;AAAA,QACA,OAAO,YAAY;AAAA,QAAC;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,122 @@
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 generatorTools_exports = {};
30
+ __export(generatorTools_exports, {
31
+ generatorReadLog: () => generatorReadLog,
32
+ generatorWriteTest: () => generatorWriteTest,
33
+ setupPage: () => setupPage
34
+ });
35
+ module.exports = __toCommonJS(generatorTools_exports);
36
+ var import_fs = __toESM(require("fs"));
37
+ var import_path = __toESM(require("path"));
38
+ var import_bundle = require("../sdk/bundle");
39
+ var import_testTool = require("./testTool");
40
+ var import_testContext = require("./testContext");
41
+ const setupPage = (0, import_testTool.defineTestTool)({
42
+ schema: {
43
+ name: "generator_setup_page",
44
+ title: "Setup generator page",
45
+ description: "Setup the page for test.",
46
+ inputSchema: import_bundle.z.object({
47
+ plan: import_bundle.z.string().describe("The plan for the test. This should be the actual test plan with all the steps."),
48
+ project: import_bundle.z.string().optional().describe('Project to use for setup. For example: "chromium", if no project is provided uses the first project in the config.'),
49
+ seedFile: import_bundle.z.string().optional().describe('A seed file contains a single test that is used to setup the page for testing, for example: "tests/seed.spec.ts". If no seed file is provided, a default seed file is created.')
50
+ }),
51
+ type: "readOnly"
52
+ },
53
+ handle: async (context, params, progress) => {
54
+ const seed = await context.getOrCreateSeedFile(params.seedFile, params.project);
55
+ context.generatorJournal = new import_testContext.GeneratorJournal(context.rootPath, params.plan, seed);
56
+ await context.runSeedTest(seed.file, seed.projectName, progress);
57
+ return { content: [] };
58
+ }
59
+ });
60
+ const generatorReadLog = (0, import_testTool.defineTestTool)({
61
+ schema: {
62
+ name: "generator_read_log",
63
+ title: "Retrieve test log",
64
+ description: "Retrieve the performed test log",
65
+ inputSchema: import_bundle.z.object({}),
66
+ type: "readOnly"
67
+ },
68
+ handle: async (context) => {
69
+ if (!context.generatorJournal)
70
+ throw new Error(`Please setup page using "${setupPage.schema.name}" first.`);
71
+ const result = context.generatorJournal.journal();
72
+ return { content: [{
73
+ type: "text",
74
+ text: result
75
+ }] };
76
+ }
77
+ });
78
+ const generatorWriteTest = (0, import_testTool.defineTestTool)({
79
+ schema: {
80
+ name: "generator_write_test",
81
+ title: "Write test",
82
+ description: "Write the generated test to the test file",
83
+ inputSchema: import_bundle.z.object({
84
+ fileName: import_bundle.z.string().describe("The file to write the test to"),
85
+ code: import_bundle.z.string().describe("The generated test code")
86
+ }),
87
+ type: "readOnly"
88
+ },
89
+ handle: async (context, params) => {
90
+ if (!context.generatorJournal)
91
+ throw new Error(`Please setup page using "${setupPage.schema.name}" first.`);
92
+ const testRunner = context.existingTestRunner();
93
+ if (!testRunner)
94
+ throw new Error("No test runner found, please setup page and perform actions first.");
95
+ const config = await testRunner.loadConfig();
96
+ const dirs = [];
97
+ for (const project of config.projects) {
98
+ const testDir = import_path.default.relative(context.rootPath, project.project.testDir).replace(/\\/g, "/");
99
+ const fileName = params.fileName.replace(/\\/g, "/");
100
+ if (fileName.startsWith(testDir)) {
101
+ const resolvedFile = import_path.default.resolve(context.rootPath, fileName);
102
+ await import_fs.default.promises.mkdir(import_path.default.dirname(resolvedFile), { recursive: true });
103
+ await import_fs.default.promises.writeFile(resolvedFile, params.code);
104
+ return {
105
+ content: [{
106
+ type: "text",
107
+ text: `### Result
108
+ Test written to ${params.fileName}`
109
+ }]
110
+ };
111
+ }
112
+ dirs.push(testDir);
113
+ }
114
+ throw new Error(`Test file did not match any of the test dirs: ${dirs.join(", ")}`);
115
+ }
116
+ });
117
+ // Annotate the CommonJS export names for ESM import in node:
118
+ 0 && (module.exports = {
119
+ generatorReadLog,
120
+ generatorWriteTest,
121
+ setupPage
122
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/mcp/test/generatorTools.ts"],
4
+ "sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { z } from '../sdk/bundle';\nimport { defineTestTool } from './testTool';\nimport { GeneratorJournal } from './testContext';\n\nexport const setupPage = defineTestTool({\n schema: {\n name: 'generator_setup_page',\n title: 'Setup generator page',\n description: 'Setup the page for test.',\n inputSchema: z.object({\n plan: z.string().describe('The plan for the test. This should be the actual test plan with all the steps.'),\n project: z.string().optional().describe('Project to use for setup. For example: \"chromium\", if no project is provided uses the first project in the config.'),\n seedFile: z.string().optional().describe('A seed file contains a single test that is used to setup the page for testing, for example: \"tests/seed.spec.ts\". If no seed file is provided, a default seed file is created.'),\n }),\n type: 'readOnly',\n },\n\n handle: async (context, params, progress) => {\n const seed = await context.getOrCreateSeedFile(params.seedFile, params.project);\n context.generatorJournal = new GeneratorJournal(context.rootPath, params.plan, seed);\n await context.runSeedTest(seed.file, seed.projectName, progress);\n return { content: [] };\n },\n});\n\nexport const generatorReadLog = defineTestTool({\n schema: {\n name: 'generator_read_log',\n title: 'Retrieve test log',\n description: 'Retrieve the performed test log',\n inputSchema: z.object({}),\n type: 'readOnly',\n },\n\n handle: async context => {\n if (!context.generatorJournal)\n throw new Error(`Please setup page using \"${setupPage.schema.name}\" first.`);\n const result = context.generatorJournal.journal();\n return { content: [{\n type: 'text',\n text: result,\n }] };\n },\n});\n\nexport const generatorWriteTest = defineTestTool({\n schema: {\n name: 'generator_write_test',\n title: 'Write test',\n description: 'Write the generated test to the test file',\n inputSchema: z.object({\n fileName: z.string().describe('The file to write the test to'),\n code: z.string().describe('The generated test code'),\n }),\n type: 'readOnly',\n },\n\n handle: async (context, params) => {\n if (!context.generatorJournal)\n throw new Error(`Please setup page using \"${setupPage.schema.name}\" first.`);\n\n const testRunner = context.existingTestRunner();\n if (!testRunner)\n throw new Error('No test runner found, please setup page and perform actions first.');\n const config = await testRunner.loadConfig();\n\n const dirs: string[] = [];\n for (const project of config.projects) {\n const testDir = path.relative(context.rootPath, project.project.testDir).replace(/\\\\/g, '/');\n const fileName = params.fileName.replace(/\\\\/g, '/');\n if (fileName.startsWith(testDir)) {\n const resolvedFile = path.resolve(context.rootPath, fileName);\n await fs.promises.mkdir(path.dirname(resolvedFile), { recursive: true });\n await fs.promises.writeFile(resolvedFile, params.code);\n return {\n content: [{\n type: 'text',\n text: `### Result\\nTest written to ${params.fileName}`,\n }]\n };\n }\n dirs.push(testDir);\n }\n throw new Error(`Test file did not match any of the test dirs: ${dirs.join(', ')}`);\n },\n});\n"],
5
+ "mappings": "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",
6
+ "names": ["path", "fs"]
7
+ }
@@ -0,0 +1,46 @@
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 plannerTools_exports = {};
20
+ __export(plannerTools_exports, {
21
+ setupPage: () => setupPage
22
+ });
23
+ module.exports = __toCommonJS(plannerTools_exports);
24
+ var import_bundle = require("../sdk/bundle");
25
+ var import_testTool = require("./testTool");
26
+ const setupPage = (0, import_testTool.defineTestTool)({
27
+ schema: {
28
+ name: "planner_setup_page",
29
+ title: "Setup planner page",
30
+ description: "Setup the page for test planning",
31
+ inputSchema: import_bundle.z.object({
32
+ project: import_bundle.z.string().optional().describe('Project to use for setup. For example: "chromium", if no project is provided uses the first project in the config.'),
33
+ seedFile: import_bundle.z.string().optional().describe('A seed file contains a single test that is used to setup the page for testing, for example: "tests/seed.spec.ts". If no seed file is provided, a default seed file is created.')
34
+ }),
35
+ type: "readOnly"
36
+ },
37
+ handle: async (context, params, progress) => {
38
+ const seed = await context.getOrCreateSeedFile(params.seedFile, params.project);
39
+ await context.runSeedTest(seed.file, seed.projectName, progress);
40
+ return { content: [] };
41
+ }
42
+ });
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ setupPage
46
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/mcp/test/plannerTools.ts"],
4
+ "sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { z } from '../sdk/bundle';\nimport { defineTestTool } from './testTool';\n\nexport const setupPage = defineTestTool({\n schema: {\n name: 'planner_setup_page',\n title: 'Setup planner page',\n description: 'Setup the page for test planning',\n inputSchema: z.object({\n project: z.string().optional().describe('Project to use for setup. For example: \"chromium\", if no project is provided uses the first project in the config.'),\n seedFile: z.string().optional().describe('A seed file contains a single test that is used to setup the page for testing, for example: \"tests/seed.spec.ts\". If no seed file is provided, a default seed file is created.'),\n }),\n type: 'readOnly',\n },\n\n handle: async (context, params, progress) => {\n const seed = await context.getOrCreateSeedFile(params.seedFile, params.project);\n await context.runSeedTest(seed.file, seed.projectName, progress);\n return { content: [] };\n },\n});\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,oBAAkB;AAClB,sBAA+B;AAExB,MAAM,gBAAY,gCAAe;AAAA,EACtC,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,IACb,aAAa,gBAAE,OAAO;AAAA,MACpB,SAAS,gBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,oHAAoH;AAAA,MAC5J,UAAU,gBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gLAAgL;AAAA,IAC3N,CAAC;AAAA,IACD,MAAM;AAAA,EACR;AAAA,EAEA,QAAQ,OAAO,SAAS,QAAQ,aAAa;AAC3C,UAAM,OAAO,MAAM,QAAQ,oBAAoB,OAAO,UAAU,OAAO,OAAO;AAC9E,UAAM,QAAQ,YAAY,KAAK,MAAM,KAAK,aAAa,QAAQ;AAC/D,WAAO,EAAE,SAAS,CAAC,EAAE;AAAA,EACvB;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,82 @@
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 seed_exports = {};
30
+ __export(seed_exports, {
31
+ defaultSeedFile: () => defaultSeedFile,
32
+ ensureSeedFile: () => ensureSeedFile,
33
+ findSeedFile: () => findSeedFile,
34
+ seedFileContent: () => seedFileContent,
35
+ seedProject: () => seedProject
36
+ });
37
+ module.exports = __toCommonJS(seed_exports);
38
+ var import_fs = __toESM(require("fs"));
39
+ var import_path = __toESM(require("path"));
40
+ var import_utils = require("playwright-core/lib/utils");
41
+ var import_projectUtils = require("../../runner/projectUtils");
42
+ function seedProject(config, projectName) {
43
+ if (!projectName)
44
+ return (0, import_projectUtils.findTopLevelProjects)(config)[0];
45
+ const project = config.projects.find((p) => p.project.name === projectName);
46
+ if (!project)
47
+ throw new Error(`Project ${projectName} not found`);
48
+ return project;
49
+ }
50
+ async function findSeedFile(project) {
51
+ const files = await (0, import_projectUtils.collectFilesForProject)(project);
52
+ return files.find((file) => import_path.default.basename(file).includes("seed"));
53
+ }
54
+ function defaultSeedFile(project) {
55
+ const testDir = project.project.testDir;
56
+ return import_path.default.resolve(testDir, "seed.spec.ts");
57
+ }
58
+ async function ensureSeedFile(project) {
59
+ const seedFile = await findSeedFile(project);
60
+ if (seedFile)
61
+ return seedFile;
62
+ const seedFilePath = defaultSeedFile(project);
63
+ await (0, import_utils.mkdirIfNeeded)(seedFilePath);
64
+ await import_fs.default.promises.writeFile(seedFilePath, seedFileContent);
65
+ return seedFilePath;
66
+ }
67
+ const seedFileContent = `import { test, expect } from '@playwright/test';
68
+
69
+ test.describe('Test group', () => {
70
+ test('seed', async ({ page }) => {
71
+ // generate code here.
72
+ });
73
+ });
74
+ `;
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ defaultSeedFile,
78
+ ensureSeedFile,
79
+ findSeedFile,
80
+ seedFileContent,
81
+ seedProject
82
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/mcp/test/seed.ts"],
4
+ "sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { mkdirIfNeeded } from 'playwright-core/lib/utils';\nimport { collectFilesForProject, findTopLevelProjects } from '../../runner/projectUtils';\n\nimport type { FullConfigInternal, FullProjectInternal } from '../../common/config';\n\nexport function seedProject(config: FullConfigInternal, projectName?: string) {\n if (!projectName)\n return findTopLevelProjects(config)[0];\n const project = config.projects.find(p => p.project.name === projectName);\n if (!project)\n throw new Error(`Project ${projectName} not found`);\n return project;\n}\n\nexport async function findSeedFile(project: FullProjectInternal) {\n const files = await collectFilesForProject(project);\n return files.find(file => path.basename(file).includes('seed'));\n}\n\nexport function defaultSeedFile(project: FullProjectInternal) {\n const testDir = project.project.testDir;\n return path.resolve(testDir, 'seed.spec.ts');\n}\n\nexport async function ensureSeedFile(project: FullProjectInternal) {\n const seedFile = await findSeedFile(project);\n if (seedFile)\n return seedFile;\n const seedFilePath = defaultSeedFile(project);\n await mkdirIfNeeded(seedFilePath);\n await fs.promises.writeFile(seedFilePath, seedFileContent);\n return seedFilePath;\n}\n\nexport const seedFileContent = `import { test, expect } from '@playwright/test';\n\ntest.describe('Test group', () => {\n test('seed', async ({ page }) => {\n // generate code here.\n });\n});\n`;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,gBAAe;AACf,kBAAiB;AAEjB,mBAA8B;AAC9B,0BAA6D;AAItD,SAAS,YAAY,QAA4B,aAAsB;AAC5E,MAAI,CAAC;AACH,eAAO,0CAAqB,MAAM,EAAE,CAAC;AACvC,QAAM,UAAU,OAAO,SAAS,KAAK,OAAK,EAAE,QAAQ,SAAS,WAAW;AACxE,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,WAAW,WAAW,YAAY;AACpD,SAAO;AACT;AAEA,eAAsB,aAAa,SAA8B;AAC/D,QAAM,QAAQ,UAAM,4CAAuB,OAAO;AAClD,SAAO,MAAM,KAAK,UAAQ,YAAAA,QAAK,SAAS,IAAI,EAAE,SAAS,MAAM,CAAC;AAChE;AAEO,SAAS,gBAAgB,SAA8B;AAC5D,QAAM,UAAU,QAAQ,QAAQ;AAChC,SAAO,YAAAA,QAAK,QAAQ,SAAS,cAAc;AAC7C;AAEA,eAAsB,eAAe,SAA8B;AACjE,QAAM,WAAW,MAAM,aAAa,OAAO;AAC3C,MAAI;AACF,WAAO;AACT,QAAM,eAAe,gBAAgB,OAAO;AAC5C,YAAM,4BAAc,YAAY;AAChC,QAAM,UAAAC,QAAG,SAAS,UAAU,cAAc,eAAe;AACzD,SAAO;AACT;AAEO,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
6
+ "names": ["path", "fs"]
7
+ }
@@ -0,0 +1,41 @@
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 streams_exports = {};
20
+ __export(streams_exports, {
21
+ StringWriteStream: () => StringWriteStream
22
+ });
23
+ module.exports = __toCommonJS(streams_exports);
24
+ var import_stream = require("stream");
25
+ var import_util = require("../../util");
26
+ class StringWriteStream extends import_stream.Writable {
27
+ constructor(progress, stdio) {
28
+ super();
29
+ this._progress = progress;
30
+ this._prefix = stdio === "stdout" ? "" : "[err] ";
31
+ }
32
+ _write(chunk, encoding, callback) {
33
+ const text = (0, import_util.stripAnsiEscapes)(chunk.toString());
34
+ this._progress({ message: `${this._prefix}${text.endsWith("\n") ? text.slice(0, -1) : text}` });
35
+ callback();
36
+ }
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ StringWriteStream
41
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/mcp/test/streams.ts"],
4
+ "sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Writable } from 'stream';\n\nimport { stripAnsiEscapes } from '../../util';\n\nimport type { ProgressCallback } from '../sdk/server';\n\nexport class StringWriteStream extends Writable {\n private _progress: ProgressCallback;\n private _prefix: string;\n\n constructor(progress: ProgressCallback, stdio: 'stdout' | 'stderr') {\n super();\n this._progress = progress;\n this._prefix = stdio === 'stdout' ? '' : '[err] ';\n }\n\n override _write(chunk: any, encoding: any, callback: any) {\n const text = stripAnsiEscapes(chunk.toString());\n // Progress wraps these as individual messages.\n this._progress({ message: `${this._prefix}${text.endsWith('\\n') ? text.slice(0, -1) : text}` });\n callback();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,oBAAyB;AAEzB,kBAAiC;AAI1B,MAAM,0BAA0B,uBAAS;AAAA,EAI9C,YAAY,UAA4B,OAA4B;AAClE,UAAM;AACN,SAAK,YAAY;AACjB,SAAK,UAAU,UAAU,WAAW,KAAK;AAAA,EAC3C;AAAA,EAES,OAAO,OAAY,UAAe,UAAe;AACxD,UAAM,WAAO,8BAAiB,MAAM,SAAS,CAAC;AAE9C,SAAK,UAAU,EAAE,SAAS,GAAG,KAAK,OAAO,GAAG,KAAK,SAAS,IAAI,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI,IAAI,GAAG,CAAC;AAC9F,aAAS;AAAA,EACX;AACF;",
6
+ "names": []
7
+ }