playwright 1.58.0-alpha-1763757971000 → 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.
- package/ThirdPartyNotices.txt +208 -1
- package/lib/agents/agent.js +85 -0
- package/lib/agents/agentParser.js +89 -0
- package/lib/agents/generateAgents.js +26 -73
- package/lib/agents/performTask.js +60 -0
- package/lib/index.js +6 -0
- package/lib/mcp/browser/browserContextFactory.js +15 -2
- package/lib/mcp/sdk/bundle.js +3 -0
- package/lib/mcp/sdk/proxyBackend.js +1 -1
- package/lib/mcp/sdk/server.js +11 -1
- package/lib/mcp/test/browserBackend.js +2 -12
- package/lib/mcp/test/testBackend.js +4 -4
- package/lib/mcpBundleImpl.js +18 -15
- package/package.json +2 -2
|
@@ -29,7 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var browserContextFactory_exports = {};
|
|
30
30
|
__export(browserContextFactory_exports, {
|
|
31
31
|
SharedContextFactory: () => SharedContextFactory,
|
|
32
|
-
contextFactory: () => contextFactory
|
|
32
|
+
contextFactory: () => contextFactory,
|
|
33
|
+
identityBrowserContextFactory: () => identityBrowserContextFactory
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(browserContextFactory_exports);
|
|
35
36
|
var import_crypto = __toESM(require("crypto"));
|
|
@@ -53,6 +54,17 @@ function contextFactory(config) {
|
|
|
53
54
|
return new IsolatedContextFactory(config);
|
|
54
55
|
return new PersistentContextFactory(config);
|
|
55
56
|
}
|
|
57
|
+
function identityBrowserContextFactory(browserContext) {
|
|
58
|
+
return {
|
|
59
|
+
createContext: async (clientInfo, abortSignal, toolName) => {
|
|
60
|
+
return {
|
|
61
|
+
browserContext,
|
|
62
|
+
close: async () => {
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
56
68
|
class BaseContextFactory {
|
|
57
69
|
constructor(name, config) {
|
|
58
70
|
this._logName = name;
|
|
@@ -292,5 +304,6 @@ async function computeTracesDir(config, clientInfo) {
|
|
|
292
304
|
// Annotate the CommonJS export names for ESM import in node:
|
|
293
305
|
0 && (module.exports = {
|
|
294
306
|
SharedContextFactory,
|
|
295
|
-
contextFactory
|
|
307
|
+
contextFactory,
|
|
308
|
+
identityBrowserContextFactory
|
|
296
309
|
});
|
package/lib/mcp/sdk/bundle.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(bundle_exports, {
|
|
|
32
32
|
Client: () => Client,
|
|
33
33
|
ListRootsRequestSchema: () => ListRootsRequestSchema,
|
|
34
34
|
ListToolsRequestSchema: () => ListToolsRequestSchema,
|
|
35
|
+
Loop: () => Loop,
|
|
35
36
|
PingRequestSchema: () => PingRequestSchema,
|
|
36
37
|
ProgressNotificationSchema: () => ProgressNotificationSchema,
|
|
37
38
|
SSEClientTransport: () => SSEClientTransport,
|
|
@@ -60,6 +61,7 @@ const ListRootsRequestSchema = bundle.ListRootsRequestSchema;
|
|
|
60
61
|
const ProgressNotificationSchema = bundle.ProgressNotificationSchema;
|
|
61
62
|
const ListToolsRequestSchema = bundle.ListToolsRequestSchema;
|
|
62
63
|
const PingRequestSchema = bundle.PingRequestSchema;
|
|
64
|
+
const Loop = bundle.Loop;
|
|
63
65
|
const z = bundle.z;
|
|
64
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
67
|
0 && (module.exports = {
|
|
@@ -67,6 +69,7 @@ const z = bundle.z;
|
|
|
67
69
|
Client,
|
|
68
70
|
ListRootsRequestSchema,
|
|
69
71
|
ListToolsRequestSchema,
|
|
72
|
+
Loop,
|
|
70
73
|
PingRequestSchema,
|
|
71
74
|
ProgressNotificationSchema,
|
|
72
75
|
SSEClientTransport,
|
|
@@ -116,7 +116,7 @@ Error: ${error}
|
|
|
116
116
|
});
|
|
117
117
|
client.setRequestHandler(mcpBundle.ListRootsRequestSchema, () => ({ roots: this._clientInfo?.roots || [] }));
|
|
118
118
|
client.setRequestHandler(mcpBundle.PingRequestSchema, () => ({}));
|
|
119
|
-
const transport =
|
|
119
|
+
const transport = factory.connect();
|
|
120
120
|
await client.connect(transport);
|
|
121
121
|
this._currentClient = client;
|
|
122
122
|
return client;
|
package/lib/mcp/sdk/server.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(server_exports, {
|
|
|
32
32
|
createServer: () => createServer,
|
|
33
33
|
firstRootPath: () => firstRootPath,
|
|
34
34
|
start: () => start,
|
|
35
|
+
wrapInClient: () => wrapInClient,
|
|
35
36
|
wrapInProcess: () => wrapInProcess
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(server_exports);
|
|
@@ -46,10 +47,18 @@ async function connect(factory, transport, runHeartbeat) {
|
|
|
46
47
|
const server = createServer(factory.name, factory.version, factory.create(), runHeartbeat);
|
|
47
48
|
await server.connect(transport);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
function wrapInProcess(backend) {
|
|
50
51
|
const server = createServer("Internal", "0.0.0", backend, false);
|
|
51
52
|
return new import_inProcessTransport.InProcessTransport(server);
|
|
52
53
|
}
|
|
54
|
+
async function wrapInClient(backend, options) {
|
|
55
|
+
const server = createServer("Internal", "0.0.0", backend, false);
|
|
56
|
+
const transport = new import_inProcessTransport.InProcessTransport(server);
|
|
57
|
+
const client = new mcpBundle.Client({ name: options.name, version: options.version });
|
|
58
|
+
await client.connect(transport);
|
|
59
|
+
await client.ping();
|
|
60
|
+
return client;
|
|
61
|
+
}
|
|
53
62
|
function createServer(name, version, backend, runHeartbeat) {
|
|
54
63
|
const server = new mcpBundle.Server({ name, version }, {
|
|
55
64
|
capabilities: {
|
|
@@ -194,5 +203,6 @@ function mergeTextParts(result) {
|
|
|
194
203
|
createServer,
|
|
195
204
|
firstRootPath,
|
|
196
205
|
start,
|
|
206
|
+
wrapInClient,
|
|
197
207
|
wrapInProcess
|
|
198
208
|
});
|
|
@@ -25,13 +25,14 @@ var import_config = require("../browser/config");
|
|
|
25
25
|
var import_browserServerBackend = require("../browser/browserServerBackend");
|
|
26
26
|
var import_tab = require("../browser/tab");
|
|
27
27
|
var import_util = require("../../util");
|
|
28
|
+
var import_browserContextFactory = require("../browser/browserContextFactory");
|
|
28
29
|
function createCustomMessageHandler(testInfo, context) {
|
|
29
30
|
let backend;
|
|
30
31
|
return async (data) => {
|
|
31
32
|
if (data.initialize) {
|
|
32
33
|
if (backend)
|
|
33
34
|
throw new Error("MCP backend is already initialized");
|
|
34
|
-
backend = new import_browserServerBackend.BrowserServerBackend({ ...import_config.defaultConfig, capabilities: ["testing"] },
|
|
35
|
+
backend = new import_browserServerBackend.BrowserServerBackend({ ...import_config.defaultConfig, capabilities: ["testing"] }, (0, import_browserContextFactory.identityBrowserContextFactory)(context));
|
|
35
36
|
await backend.initialize(data.initialize.clientInfo);
|
|
36
37
|
const pausedMessage = await generatePausedMessage(testInfo, context);
|
|
37
38
|
return { initialize: { pausedMessage } };
|
|
@@ -91,17 +92,6 @@ async function generatePausedMessage(testInfo, context) {
|
|
|
91
92
|
lines.push(`### Task`, `Try recovering from the error prior to continuing`);
|
|
92
93
|
return lines.join("\n");
|
|
93
94
|
}
|
|
94
|
-
function identityFactory(browserContext) {
|
|
95
|
-
return {
|
|
96
|
-
createContext: async (clientInfo, abortSignal, toolName) => {
|
|
97
|
-
return {
|
|
98
|
-
browserContext,
|
|
99
|
-
close: async () => {
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
106
96
|
0 && (module.exports = {
|
|
107
97
|
createCustomMessageHandler
|
|
@@ -39,7 +39,7 @@ var plannerTools = __toESM(require("./plannerTools.js"));
|
|
|
39
39
|
var import_tools = require("../browser/tools");
|
|
40
40
|
var import_bundle = require("../sdk/bundle");
|
|
41
41
|
class TestServerBackend {
|
|
42
|
-
constructor(
|
|
42
|
+
constructor(configPath, options) {
|
|
43
43
|
this.name = "Playwright";
|
|
44
44
|
this.version = "0.0.1";
|
|
45
45
|
this._tools = [
|
|
@@ -55,10 +55,10 @@ class TestServerBackend {
|
|
|
55
55
|
...import_tools.browserTools.map((tool) => wrapBrowserTool(tool))
|
|
56
56
|
];
|
|
57
57
|
this._options = options || {};
|
|
58
|
-
this.
|
|
58
|
+
this._configPath = configPath;
|
|
59
59
|
}
|
|
60
60
|
async initialize(clientInfo) {
|
|
61
|
-
this._context = new import_testContext.TestContext(clientInfo, this.
|
|
61
|
+
this._context = new import_testContext.TestContext(clientInfo, this._configPath, this._options);
|
|
62
62
|
}
|
|
63
63
|
async listTools() {
|
|
64
64
|
return this._tools.map((tool) => mcp.toMcpTool(tool.schema));
|
|
@@ -74,7 +74,7 @@ class TestServerBackend {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
serverClosed() {
|
|
77
|
-
void this._context
|
|
77
|
+
void this._context?.close();
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
const typesWithIntent = ["action", "assertion", "input"];
|