playwright 1.58.0-alpha-2025-12-07 → 1.58.0-alpha-2025-12-08

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -14,7 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- const playwright = require('playwright-core');
18
- const { decoratePage } = require('./lib/agents/pageDecorator');
19
- decoratePage(playwright);
20
- module.exports = playwright;
17
+ module.exports = require('playwright-core');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright",
3
- "version": "1.58.0-alpha-2025-12-07",
3
+ "version": "1.58.0-alpha-2025-12-08",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "license": "Apache-2.0",
66
66
  "dependencies": {
67
- "playwright-core": "1.58.0-alpha-2025-12-07"
67
+ "playwright-core": "1.58.0-alpha-2025-12-08"
68
68
  },
69
69
  "optionalDependencies": {
70
70
  "fsevents": "2.3.2"
@@ -1,91 +0,0 @@
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 pageDecorator_exports = {};
20
- __export(pageDecorator_exports, {
21
- decoratePage: () => decoratePage
22
- });
23
- module.exports = __toCommonJS(pageDecorator_exports);
24
- var import_utilsBundle = require("playwright-core/lib/utilsBundle");
25
- var import_mcpBundle = require("playwright-core/lib/mcpBundle");
26
- var import_browserContextFactory = require("../mcp/browser/browserContextFactory");
27
- var import_browserServerBackend = require("../mcp/browser/browserServerBackend");
28
- var import_config = require("../mcp/browser/config");
29
- var import_server = require("../mcp/sdk/server");
30
- function decoratePage(playwright) {
31
- playwright._instrumentation.addListener({
32
- onPage: (page) => {
33
- page.perform = pagePerform.bind(null, page);
34
- page.extract = pageExtract.bind(null, page);
35
- }
36
- });
37
- }
38
- async function pagePerform(page, userTask, options = {}) {
39
- const resultSchema = {
40
- type: "object",
41
- properties: {
42
- code: { type: "string" }
43
- },
44
- required: ["code"]
45
- };
46
- await perform(page, userTask, resultSchema, options);
47
- }
48
- async function pageExtract(page, query, schema, options = {}) {
49
- const task = `
50
- ### Instructions
51
- Extract the following information from the page. Do not perform any actions, just extract the information.
52
-
53
- ### Query
54
- ${query}`;
55
- return await perform(page, task, (0, import_mcpBundle.zodToJsonSchema)(schema), options);
56
- }
57
- async function perform(page, userTask, resultSchema, options = {}) {
58
- const context = page.context();
59
- if (!context._options.agent)
60
- throw new Error(`page.perform() and page.extract() require the agent to be set on the browser context`);
61
- const { full } = await page._snapshotForAI();
62
- const backend = new import_browserServerBackend.BrowserServerBackend(import_config.defaultConfig, (0, import_browserContextFactory.identityBrowserContextFactory)(context));
63
- const client = await (0, import_server.wrapInClient)(backend, { name: "Internal", version: "0.0.0" });
64
- const callTool = async (params) => {
65
- return await client.callTool(params);
66
- };
67
- const loop = new import_mcpBundle.Loop(context._options.agent.provider, {
68
- model: context._options.agent.model,
69
- summarize: true,
70
- debug: import_utilsBundle.debug,
71
- callTool,
72
- tools: await backend.listTools(),
73
- ...options
74
- });
75
- const task = `${userTask}
76
-
77
- ### Page snapshot
78
- ${full}
79
- `;
80
- try {
81
- return await loop.run(task, {
82
- resultSchema
83
- });
84
- } finally {
85
- await client.close();
86
- }
87
- }
88
- // Annotate the CommonJS export names for ESM import in node:
89
- 0 && (module.exports = {
90
- decoratePage
91
- });