playwright 1.58.0-alpha-2025-11-21 → 1.58.0-alpha-2025-11-22

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.
@@ -207,6 +207,7 @@ This project incorporates components from the projects listed below. The origina
207
207
  - statuses@2.0.2 (https://github.com/jshttp/statuses)
208
208
  - stoppable@1.1.0 (https://github.com/hunterloftis/stoppable)
209
209
  - supports-color@7.2.0 (https://github.com/chalk/supports-color)
210
+ - tiny-loop@0.0.6 (https://github.com/pavelfeldman/tiny-loop)
210
211
  - to-regex-range@5.0.1 (https://github.com/micromatch/to-regex-range)
211
212
  - toidentifier@1.0.1 (https://github.com/component/toidentifier)
212
213
  - type-is@2.0.1 (https://github.com/jshttp/type-is)
@@ -5883,6 +5884,212 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
5883
5884
  =========================================
5884
5885
  END OF supports-color@7.2.0 AND INFORMATION
5885
5886
 
5887
+ %% tiny-loop@0.0.6 NOTICES AND INFORMATION BEGIN HERE
5888
+ =========================================
5889
+ Apache License
5890
+ Version 2.0, January 2004
5891
+ http://www.apache.org/licenses/
5892
+
5893
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
5894
+
5895
+ 1. Definitions.
5896
+
5897
+ "License" shall mean the terms and conditions for use, reproduction,
5898
+ and distribution as defined by Sections 1 through 9 of this document.
5899
+
5900
+ "Licensor" shall mean the copyright owner or entity authorized by
5901
+ the copyright owner that is granting the License.
5902
+
5903
+ "Legal Entity" shall mean the union of the acting entity and all
5904
+ other entities that control, are controlled by, or are under common
5905
+ control with that entity. For the purposes of this definition,
5906
+ "control" means (i) the power, direct or indirect, to cause the
5907
+ direction or management of such entity, whether by contract or
5908
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
5909
+ outstanding shares, or (iii) beneficial ownership of such entity.
5910
+
5911
+ "You" (or "Your") shall mean an individual or Legal Entity
5912
+ exercising permissions granted by this License.
5913
+
5914
+ "Source" form shall mean the preferred form for making modifications,
5915
+ including but not limited to software source code, documentation
5916
+ source, and configuration files.
5917
+
5918
+ "Object" form shall mean any form resulting from mechanical
5919
+ transformation or translation of a Source form, including but
5920
+ not limited to compiled object code, generated documentation,
5921
+ and conversions to other media types.
5922
+
5923
+ "Work" shall mean the work of authorship, whether in Source or
5924
+ Object form, made available under the License, as indicated by a
5925
+ copyright notice that is included in or attached to the work
5926
+ (an example is provided in the Appendix below).
5927
+
5928
+ "Derivative Works" shall mean any work, whether in Source or Object
5929
+ form, that is based on (or derived from) the Work and for which the
5930
+ editorial revisions, annotations, elaborations, or other modifications
5931
+ represent, as a whole, an original work of authorship. For the purposes
5932
+ of this License, Derivative Works shall not include works that remain
5933
+ separable from, or merely link (or bind by name) to the interfaces of,
5934
+ the Work and Derivative Works thereof.
5935
+
5936
+ "Contribution" shall mean any work of authorship, including
5937
+ the original version of the Work and any modifications or additions
5938
+ to that Work or Derivative Works thereof, that is intentionally
5939
+ submitted to Licensor for inclusion in the Work by the copyright owner
5940
+ or by an individual or Legal Entity authorized to submit on behalf of
5941
+ the copyright owner. For the purposes of this definition, "submitted"
5942
+ means any form of electronic, verbal, or written communication sent
5943
+ to the Licensor or its representatives, including but not limited to
5944
+ communication on electronic mailing lists, source code control systems,
5945
+ and issue tracking systems that are managed by, or on behalf of, the
5946
+ Licensor for the purpose of discussing and improving the Work, but
5947
+ excluding communication that is conspicuously marked or otherwise
5948
+ designated in writing by the copyright owner as "Not a Contribution."
5949
+
5950
+ "Contributor" shall mean Licensor and any individual or Legal Entity
5951
+ on behalf of whom a Contribution has been received by Licensor and
5952
+ subsequently incorporated within the Work.
5953
+
5954
+ 2. Grant of Copyright License. Subject to the terms and conditions of
5955
+ this License, each Contributor hereby grants to You a perpetual,
5956
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
5957
+ copyright license to reproduce, prepare Derivative Works of,
5958
+ publicly display, publicly perform, sublicense, and distribute the
5959
+ Work and such Derivative Works in Source or Object form.
5960
+
5961
+ 3. Grant of Patent License. Subject to the terms and conditions of
5962
+ this License, each Contributor hereby grants to You a perpetual,
5963
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
5964
+ (except as stated in this section) patent license to make, have made,
5965
+ use, offer to sell, sell, import, and otherwise transfer the Work,
5966
+ where such license applies only to those patent claims licensable
5967
+ by such Contributor that are necessarily infringed by their
5968
+ Contribution(s) alone or by combination of their Contribution(s)
5969
+ with the Work to which such Contribution(s) was submitted. If You
5970
+ institute patent litigation against any entity (including a
5971
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
5972
+ or a Contribution incorporated within the Work constitutes direct
5973
+ or contributory patent infringement, then any patent licenses
5974
+ granted to You under this License for that Work shall terminate
5975
+ as of the date such litigation is filed.
5976
+
5977
+ 4. Redistribution. You may reproduce and distribute copies of the
5978
+ Work or Derivative Works thereof in any medium, with or without
5979
+ modifications, and in Source or Object form, provided that You
5980
+ meet the following conditions:
5981
+
5982
+ (a) You must give any other recipients of the Work or
5983
+ Derivative Works a copy of this License; and
5984
+
5985
+ (b) You must cause any modified files to carry prominent notices
5986
+ stating that You changed the files; and
5987
+
5988
+ (c) You must retain, in the Source form of any Derivative Works
5989
+ that You distribute, all copyright, patent, trademark, and
5990
+ attribution notices from the Source form of the Work,
5991
+ excluding those notices that do not pertain to any part of
5992
+ the Derivative Works; and
5993
+
5994
+ (d) If the Work includes a "NOTICE" text file as part of its
5995
+ distribution, then any Derivative Works that You distribute must
5996
+ include a readable copy of the attribution notices contained
5997
+ within such NOTICE file, excluding those notices that do not
5998
+ pertain to any part of the Derivative Works, in at least one
5999
+ of the following places: within a NOTICE text file distributed
6000
+ as part of the Derivative Works; within the Source form or
6001
+ documentation, if provided along with the Derivative Works; or,
6002
+ within a display generated by the Derivative Works, if and
6003
+ wherever such third-party notices normally appear. The contents
6004
+ of the NOTICE file are for informational purposes only and
6005
+ do not modify the License. You may add Your own attribution
6006
+ notices within Derivative Works that You distribute, alongside
6007
+ or as an addendum to the NOTICE text from the Work, provided
6008
+ that such additional attribution notices cannot be construed
6009
+ as modifying the License.
6010
+
6011
+ You may add Your own copyright statement to Your modifications and
6012
+ may provide additional or different license terms and conditions
6013
+ for use, reproduction, or distribution of Your modifications, or
6014
+ for any such Derivative Works as a whole, provided Your use,
6015
+ reproduction, and distribution of the Work otherwise complies with
6016
+ the conditions stated in this License.
6017
+
6018
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
6019
+ any Contribution intentionally submitted for inclusion in the Work
6020
+ by You to the Licensor shall be under the terms and conditions of
6021
+ this License, without any additional terms or conditions.
6022
+ Notwithstanding the above, nothing herein shall supersede or modify
6023
+ the terms of any separate license agreement you may have executed
6024
+ with Licensor regarding such Contributions.
6025
+
6026
+ 6. Trademarks. This License does not grant permission to use the trade
6027
+ names, trademarks, service marks, or product names of the Licensor,
6028
+ except as required for reasonable and customary use in describing the
6029
+ origin of the Work and reproducing the content of the NOTICE file.
6030
+
6031
+ 7. Disclaimer of Warranty. Unless required by applicable law or
6032
+ agreed to in writing, Licensor provides the Work (and each
6033
+ Contributor provides its Contributions) on an "AS IS" BASIS,
6034
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
6035
+ implied, including, without limitation, any warranties or conditions
6036
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
6037
+ PARTICULAR PURPOSE. You are solely responsible for determining the
6038
+ appropriateness of using or redistributing the Work and assume any
6039
+ risks associated with Your exercise of permissions under this License.
6040
+
6041
+ 8. Limitation of Liability. In no event and under no legal theory,
6042
+ whether in tort (including negligence), contract, or otherwise,
6043
+ unless required by applicable law (such as deliberate and grossly
6044
+ negligent acts) or agreed to in writing, shall any Contributor be
6045
+ liable to You for damages, including any direct, indirect, special,
6046
+ incidental, or consequential damages of any character arising as a
6047
+ result of this License or out of the use or inability to use the
6048
+ Work (including but not limited to damages for loss of goodwill,
6049
+ work stoppage, computer failure or malfunction, or any and all
6050
+ other commercial damages or losses), even if such Contributor
6051
+ has been advised of the possibility of such damages.
6052
+
6053
+ 9. Accepting Warranty or Additional Liability. While redistributing
6054
+ the Work or Derivative Works thereof, You may choose to offer,
6055
+ and charge a fee for, acceptance of support, warranty, indemnity,
6056
+ or other liability obligations and/or rights consistent with this
6057
+ License. However, in accepting such obligations, You may act only
6058
+ on Your own behalf and on Your sole responsibility, not on behalf
6059
+ of any other Contributor, and only if You agree to indemnify,
6060
+ defend, and hold each Contributor harmless for any liability
6061
+ incurred by, or claims asserted against, such Contributor by reason
6062
+ of your accepting any such warranty or additional liability.
6063
+
6064
+ END OF TERMS AND CONDITIONS
6065
+
6066
+ APPENDIX: How to apply the Apache License to your work.
6067
+
6068
+ To apply the Apache License to your work, attach the following
6069
+ boilerplate notice, with the fields enclosed by brackets "[]"
6070
+ replaced with your own identifying information. (Don't include
6071
+ the brackets!) The text should be enclosed in the appropriate
6072
+ comment syntax for the file format. We also recommend that a
6073
+ file or class name and description of purpose be included on the
6074
+ same "printed page" as the copyright notice for easier
6075
+ identification within third-party archives.
6076
+
6077
+ Copyright (c) Microsoft Corporation.
6078
+
6079
+ Licensed under the Apache License, Version 2.0 (the "License");
6080
+ you may not use this file except in compliance with the License.
6081
+ You may obtain a copy of the License at
6082
+
6083
+ http://www.apache.org/licenses/LICENSE-2.0
6084
+
6085
+ Unless required by applicable law or agreed to in writing, software
6086
+ distributed under the License is distributed on an "AS IS" BASIS,
6087
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6088
+ See the License for the specific language governing permissions and
6089
+ limitations under the License.
6090
+ =========================================
6091
+ END OF tiny-loop@0.0.6 AND INFORMATION
6092
+
5886
6093
  %% to-regex-range@5.0.1 NOTICES AND INFORMATION BEGIN HERE
5887
6094
  =========================================
5888
6095
  The MIT License (MIT)
@@ -6192,6 +6399,6 @@ END OF zod@3.25.76 AND INFORMATION
6192
6399
 
6193
6400
  SUMMARY BEGIN HERE
6194
6401
  =========================================
6195
- Total Packages: 216
6402
+ Total Packages: 217
6196
6403
  =========================================
6197
6404
  END OF SUMMARY
@@ -0,0 +1,85 @@
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 agent_exports = {};
20
+ __export(agent_exports, {
21
+ Agent: () => Agent
22
+ });
23
+ module.exports = __toCommonJS(agent_exports);
24
+ var import_bundle = require("../mcp/sdk/bundle");
25
+ class Agent {
26
+ constructor(loopName, spec, clients, resultSchema) {
27
+ this.loop = new import_bundle.Loop(loopName);
28
+ this.spec = spec;
29
+ this.clients = clients;
30
+ this.resultSchema = resultSchema;
31
+ }
32
+ async runTask(task, params, options) {
33
+ const { clients, tools, callTool } = await this._initClients();
34
+ const prompt = this.spec.description;
35
+ try {
36
+ return await this.loop.run(`${prompt}
37
+
38
+ Task:
39
+ ${task}
40
+
41
+ Params:
42
+ ${JSON.stringify(params, null, 2)}`, {
43
+ ...options,
44
+ tools,
45
+ callTool,
46
+ resultSchema: this.resultSchema
47
+ });
48
+ } finally {
49
+ await this._disconnectFromServers(clients);
50
+ }
51
+ }
52
+ async _initClients() {
53
+ const clients = {};
54
+ const agentToolNames = new Set(this.spec.tools);
55
+ const tools = [];
56
+ for (const [name, client] of this.clients.entries()) {
57
+ const list = await client.listTools();
58
+ for (const tool of list.tools) {
59
+ if (!agentToolNames.has(name + "/" + tool.name))
60
+ continue;
61
+ agentToolNames.delete(name + "/" + tool.name);
62
+ tools.push({ ...tool, name: name + "__" + tool.name });
63
+ }
64
+ clients[name] = client;
65
+ }
66
+ if (agentToolNames.size > 0)
67
+ throw new Error(`Required tools not found: ${Array.from(agentToolNames).join(", ")}`);
68
+ const callTool = async (params) => {
69
+ const [serverName, toolName] = params.name.split("__");
70
+ const client = clients[serverName];
71
+ if (!client)
72
+ throw new Error(`Unknown server: ${serverName}`);
73
+ return await client.callTool({ name: toolName, arguments: params.arguments });
74
+ };
75
+ return { clients, tools, callTool };
76
+ }
77
+ async _disconnectFromServers(clients) {
78
+ for (const client of Object.values(clients))
79
+ await client.close();
80
+ }
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ Agent
85
+ });
@@ -0,0 +1,89 @@
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 agentParser_exports = {};
30
+ __export(agentParser_exports, {
31
+ parseAgentSpec: () => parseAgentSpec
32
+ });
33
+ module.exports = __toCommonJS(agentParser_exports);
34
+ var import_fs = __toESM(require("fs"));
35
+ var import_utilsBundle = require("playwright-core/lib/utilsBundle");
36
+ async function parseAgentSpec(filePath) {
37
+ const source = await import_fs.default.promises.readFile(filePath, "utf-8");
38
+ const { header, content } = extractYamlAndContent(source);
39
+ const { instructions, examples } = extractInstructionsAndExamples(content);
40
+ return {
41
+ ...header,
42
+ instructions,
43
+ examples
44
+ };
45
+ }
46
+ function extractYamlAndContent(markdown) {
47
+ const lines = markdown.split("\n");
48
+ if (lines[0] !== "---")
49
+ throw new Error("Markdown file must start with YAML front matter (---)");
50
+ let yamlEndIndex = -1;
51
+ for (let i = 1; i < lines.length; i++) {
52
+ if (lines[i] === "---") {
53
+ yamlEndIndex = i;
54
+ break;
55
+ }
56
+ }
57
+ if (yamlEndIndex === -1)
58
+ throw new Error("YAML front matter must be closed with ---");
59
+ const yamlLines = lines.slice(1, yamlEndIndex);
60
+ const yamlRaw = yamlLines.join("\n");
61
+ const contentLines = lines.slice(yamlEndIndex + 1);
62
+ const content = contentLines.join("\n");
63
+ let header;
64
+ try {
65
+ header = import_utilsBundle.yaml.parse(yamlRaw);
66
+ } catch (error) {
67
+ throw new Error(`Failed to parse YAML header: ${error.message}`);
68
+ }
69
+ if (!header.name)
70
+ throw new Error('YAML header must contain a "name" field');
71
+ if (!header.description)
72
+ throw new Error('YAML header must contain a "description" field');
73
+ return { header, content };
74
+ }
75
+ function extractInstructionsAndExamples(content) {
76
+ const examples = [];
77
+ const instructions = content.split("<example>")[0].trim();
78
+ const exampleRegex = /<example>([\s\S]*?)<\/example>/g;
79
+ let match;
80
+ while ((match = exampleRegex.exec(content)) !== null) {
81
+ const example = match[1].trim();
82
+ examples.push(example.replace(/[\n]/g, " ").replace(/ +/g, " "));
83
+ }
84
+ return { instructions, examples };
85
+ }
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ parseAgentSpec
89
+ });
@@ -39,67 +39,20 @@ var import_path = __toESM(require("path"));
39
39
  var import_utilsBundle = require("playwright-core/lib/utilsBundle");
40
40
  var import_utils = require("playwright-core/lib/utils");
41
41
  var import_seed = require("../mcp/test/seed");
42
- class AgentParser {
43
- static async loadAgents() {
44
- const files = await import_fs.default.promises.readdir(__dirname);
45
- return Promise.all(files.filter((file) => file.endsWith(".agent.md")).map((file) => AgentParser.parseFile(import_path.default.join(__dirname, file))));
46
- }
47
- static async parseFile(filePath) {
48
- const source = await import_fs.default.promises.readFile(filePath, "utf-8");
49
- const { header, content } = this.extractYamlAndContent(source);
50
- const { instructions, examples } = this.extractInstructionsAndExamples(content);
51
- return { header, instructions, examples };
52
- }
53
- static extractYamlAndContent(markdown) {
54
- const lines = markdown.split("\n");
55
- if (lines[0] !== "---")
56
- throw new Error("Markdown file must start with YAML front matter (---)");
57
- let yamlEndIndex = -1;
58
- for (let i = 1; i < lines.length; i++) {
59
- if (lines[i] === "---") {
60
- yamlEndIndex = i;
61
- break;
62
- }
63
- }
64
- if (yamlEndIndex === -1)
65
- throw new Error("YAML front matter must be closed with ---");
66
- const yamlLines = lines.slice(1, yamlEndIndex);
67
- const yamlRaw = yamlLines.join("\n");
68
- const contentLines = lines.slice(yamlEndIndex + 1);
69
- const content = contentLines.join("\n");
70
- let header;
71
- try {
72
- header = import_utilsBundle.yaml.parse(yamlRaw);
73
- } catch (error) {
74
- throw new Error(`Failed to parse YAML header: ${error.message}`);
75
- }
76
- if (!header.name)
77
- throw new Error('YAML header must contain a "name" field');
78
- if (!header.description)
79
- throw new Error('YAML header must contain a "description" field');
80
- return { header, content };
81
- }
82
- static extractInstructionsAndExamples(content) {
83
- const examples = [];
84
- const instructions = content.split("<example>")[0].trim();
85
- const exampleRegex = /<example>([\s\S]*?)<\/example>/g;
86
- let match;
87
- while ((match = exampleRegex.exec(content)) !== null) {
88
- const example = match[1].trim();
89
- examples.push(example.replace(/[\n]/g, " ").replace(/ +/g, " "));
90
- }
91
- return { instructions, examples };
92
- }
42
+ var import_agentParser = require("./agentParser");
43
+ async function loadAgentSpecs() {
44
+ const files = await import_fs.default.promises.readdir(__dirname);
45
+ return Promise.all(files.filter((file) => file.endsWith(".agent.md")).map((file) => (0, import_agentParser.parseAgentSpec)(import_path.default.join(__dirname, file))));
93
46
  }
94
47
  class ClaudeGenerator {
95
48
  static async init(config, projectName, prompts) {
96
49
  await initRepo(config, projectName, {
97
50
  promptsFolder: prompts ? ".claude/prompts" : void 0
98
51
  });
99
- const agents = await AgentParser.loadAgents();
52
+ const agents = await loadAgentSpecs();
100
53
  await import_fs.default.promises.mkdir(".claude/agents", { recursive: true });
101
54
  for (const agent of agents)
102
- await writeFile(`.claude/agents/${agent.header.name}.md`, ClaudeGenerator.agentSpec(agent), "\u{1F916}", "agent definition");
55
+ await writeFile(`.claude/agents/${agent.name}.md`, ClaudeGenerator.agentSpec(agent), "\u{1F916}", "agent definition");
103
56
  await writeFile(".mcp.json", JSON.stringify({
104
57
  mcpServers: {
105
58
  "playwright-test": {
@@ -124,11 +77,11 @@ class ClaudeGenerator {
124
77
  const examples = agent.examples.length ? ` Examples: ${agent.examples.map((example) => `<example>${example}</example>`).join("")}` : "";
125
78
  const lines = [];
126
79
  const header = {
127
- name: agent.header.name,
128
- description: agent.header.description + examples,
129
- tools: agent.header.tools.map((tool) => asClaudeTool(tool)).join(", "),
130
- model: agent.header.model,
131
- color: agent.header.color
80
+ name: agent.name,
81
+ description: agent.description + examples,
82
+ tools: agent.tools.map((tool) => asClaudeTool(tool)).join(", "),
83
+ model: agent.model,
84
+ color: agent.color
132
85
  };
133
86
  lines.push(`---`);
134
87
  lines.push(import_utilsBundle.yaml.stringify(header, { lineWidth: 1e5 }) + `---`);
@@ -143,12 +96,12 @@ class OpencodeGenerator {
143
96
  defaultAgentName: "Build",
144
97
  promptsFolder: prompts ? ".opencode/prompts" : void 0
145
98
  });
146
- const agents = await AgentParser.loadAgents();
99
+ const agents = await loadAgentSpecs();
147
100
  for (const agent of agents) {
148
101
  const prompt = [agent.instructions];
149
102
  prompt.push("");
150
103
  prompt.push(...agent.examples.map((example) => `<example>${example}</example>`));
151
- await writeFile(`.opencode/prompts/${agent.header.name}.md`, prompt.join("\n"), "\u{1F916}", "agent definition");
104
+ await writeFile(`.opencode/prompts/${agent.name}.md`, prompt.join("\n"), "\u{1F916}", "agent definition");
152
105
  }
153
106
  await writeFile("opencode.json", OpencodeGenerator.configuration(agents), "\u{1F527}", "opencode configuration");
154
107
  initRepoDone();
@@ -176,13 +129,13 @@ class OpencodeGenerator {
176
129
  result["agent"] = {};
177
130
  for (const agent of agents) {
178
131
  const tools = {};
179
- result["agent"][agent.header.name] = {
180
- description: agent.header.description,
132
+ result["agent"][agent.name] = {
133
+ description: agent.description,
181
134
  mode: "subagent",
182
- prompt: `{file:.opencode/prompts/${agent.header.name}.md}`,
135
+ prompt: `{file:.opencode/prompts/${agent.name}.md}`,
183
136
  tools
184
137
  };
185
- for (const tool of agent.header.tools)
138
+ for (const tool of agent.tools)
186
139
  asOpencodeTool(tools, tool);
187
140
  }
188
141
  result["mcp"]["playwright-test"] = {
@@ -200,10 +153,10 @@ class CopilotGenerator {
200
153
  promptsFolder: prompts ? ".github/prompts" : void 0,
201
154
  promptSuffix: "prompt"
202
155
  });
203
- const agents = await AgentParser.loadAgents();
156
+ const agents = await loadAgentSpecs();
204
157
  await import_fs.default.promises.mkdir(".github/agents", { recursive: true });
205
158
  for (const agent of agents)
206
- await writeFile(`.github/agents/${agent.header.name}.agent.md`, CopilotGenerator.agentSpec(agent), "\u{1F916}", "agent definition");
159
+ await writeFile(`.github/agents/${agent.name}.agent.md`, CopilotGenerator.agentSpec(agent), "\u{1F916}", "agent definition");
207
160
  await deleteFile(`.github/chatmodes/ \u{1F3AD} planner.chatmode.md`, "legacy planner chatmode");
208
161
  await deleteFile(`.github/chatmodes/\u{1F3AD} generator.chatmode.md`, "legacy generator chatmode");
209
162
  await deleteFile(`.github/chatmodes/\u{1F3AD} healer.chatmode.md`, "legacy healer chatmode");
@@ -228,9 +181,9 @@ class CopilotGenerator {
228
181
  const examples = agent.examples.length ? ` Examples: ${agent.examples.map((example) => `<example>${example}</example>`).join("")}` : "";
229
182
  const lines = [];
230
183
  const header = {
231
- "name": agent.header.name,
232
- "description": agent.header.description + examples,
233
- "tools": agent.header.tools,
184
+ "name": agent.name,
185
+ "description": agent.description + examples,
186
+ "tools": agent.tools,
234
187
  "model": "Claude Sonnet 4",
235
188
  "mcp-servers": CopilotGenerator.mcpServers
236
189
  };
@@ -260,7 +213,7 @@ class VSCodeGenerator {
260
213
  await initRepo(config, projectName, {
261
214
  promptsFolder: void 0
262
215
  });
263
- const agents = await AgentParser.loadAgents();
216
+ const agents = await loadAgentSpecs();
264
217
  const nameMap = /* @__PURE__ */ new Map([
265
218
  ["playwright-test-planner", " \u{1F3AD} planner"],
266
219
  ["playwright-test-generator", "\u{1F3AD} generator"],
@@ -268,7 +221,7 @@ class VSCodeGenerator {
268
221
  ]);
269
222
  await import_fs.default.promises.mkdir(".github/chatmodes", { recursive: true });
270
223
  for (const agent of agents)
271
- await writeFile(`.github/chatmodes/${nameMap.get(agent.header.name)}.chatmode.md`, VSCodeGenerator.agentSpec(agent), "\u{1F916}", "chatmode definition");
224
+ await writeFile(`.github/chatmodes/${nameMap.get(agent.name)}.chatmode.md`, VSCodeGenerator.agentSpec(agent), "\u{1F916}", "chatmode definition");
272
225
  await VSCodeGenerator.appendToMCPJson();
273
226
  initRepoDone();
274
227
  }
@@ -307,7 +260,7 @@ class VSCodeGenerator {
307
260
  return `${vscodeMcpName}/${second}`;
308
261
  return vscodeToolMap.get(first) || first;
309
262
  }
310
- const tools = agent.header.tools.map(asVscodeTool).flat().sort((a, b) => {
263
+ const tools = agent.tools.map(asVscodeTool).flat().sort((a, b) => {
311
264
  const indexA = vscodeToolsOrder.indexOf(a);
312
265
  const indexB = vscodeToolsOrder.indexOf(b);
313
266
  if (indexA === -1 && indexB === -1)
@@ -320,7 +273,7 @@ class VSCodeGenerator {
320
273
  }).map((tool) => `'${tool}'`).join(", ");
321
274
  const lines = [];
322
275
  lines.push(`---`);
323
- lines.push(`description: ${agent.header.description}.`);
276
+ lines.push(`description: ${agent.description}.`);
324
277
  lines.push(`tools: [${tools}]`);
325
278
  lines.push(`---`);
326
279
  lines.push("");
@@ -0,0 +1,60 @@
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 performTask_exports = {};
20
+ __export(performTask_exports, {
21
+ performTask: () => performTask
22
+ });
23
+ module.exports = __toCommonJS(performTask_exports);
24
+ var import_utils = require("playwright-core/lib/utils");
25
+ var import_browserContextFactory = require("../mcp/browser/browserContextFactory");
26
+ var import_browserServerBackend = require("../mcp/browser/browserServerBackend");
27
+ var import_config = require("../mcp/browser/config");
28
+ var import_bundle = require("../mcp/sdk/bundle");
29
+ var import_server = require("../mcp/sdk/server");
30
+ async function performTask(context, task) {
31
+ const backend = new import_browserServerBackend.BrowserServerBackend(import_config.defaultConfig, (0, import_browserContextFactory.identityBrowserContextFactory)(context));
32
+ const client = await (0, import_server.wrapInClient)(backend, { name: "Internal", version: "0.0.0" });
33
+ const loop = new import_bundle.Loop("copilot");
34
+ const callTool = async (params) => {
35
+ return await client.callTool(params);
36
+ };
37
+ try {
38
+ return await loop.run(task, {
39
+ tools: await backend.listTools(),
40
+ callTool,
41
+ logger
42
+ });
43
+ } finally {
44
+ await client.close();
45
+ }
46
+ }
47
+ function logger(category, text, details = "") {
48
+ const trimmedText = trim(text, 100);
49
+ const trimmedDetails = trim(details, 100 - trimmedText.length - 1);
50
+ console.log(import_utils.colors.bold(import_utils.colors.green(category)), trimmedText, import_utils.colors.dim(trimmedDetails));
51
+ }
52
+ function trim(text, maxLength) {
53
+ if (text.length <= maxLength)
54
+ return text;
55
+ return text.slice(0, maxLength - 3) + "...";
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ performTask
60
+ });
package/lib/index.js CHANGED
@@ -43,6 +43,7 @@ var import_utils = require("playwright-core/lib/utils");
43
43
  var import_globals = require("./common/globals");
44
44
  var import_testType = require("./common/testType");
45
45
  var import_browserBackend = require("./mcp/test/browserBackend");
46
+ var import_performTask = require("./agents/performTask");
46
47
  var import_expect = require("./matchers/expect");
47
48
  var import_configLoader = require("./common/configLoader");
48
49
  var import_testType2 = require("./common/testType");
@@ -415,6 +416,11 @@ const playwrightFixtures = {
415
416
  } else {
416
417
  await request.dispose();
417
418
  }
419
+ },
420
+ _perform: async ({ context }, use) => {
421
+ await use(async (task) => {
422
+ await (0, import_performTask.performTask)(context, task);
423
+ });
418
424
  }
419
425
  };
420
426
  function normalizeVideoMode(video) {