@smoothdeploy/playwright-core 1.57.1 → 1.58.1-beta-1770452953000
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.
Potentially problematic release.
This version of @smoothdeploy/playwright-core might be problematic. Click here for more details.
- package/ThirdPartyNotices.txt +3223 -308
- package/browsers.json +21 -22
- package/lib/cli/program.js +4 -5
- package/lib/client/api.js +3 -0
- package/lib/client/browser.js +3 -5
- package/lib/client/browserContext.js +35 -0
- package/lib/client/browserType.js +4 -3
- package/lib/client/channelOwner.js +4 -3
- package/lib/client/clientInstrumentation.js +10 -0
- package/lib/client/connection.js +4 -0
- package/lib/client/elementHandle.js +3 -0
- package/lib/client/events.js +3 -0
- package/lib/client/fetch.js +3 -4
- package/lib/client/frame.js +1 -0
- package/lib/client/page.js +28 -1
- package/lib/client/pageAgent.js +64 -0
- package/lib/client/platform.js +3 -0
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/mcpBundle.js +84 -0
- package/lib/mcpBundleImpl/index.js +147 -0
- package/lib/protocol/serializers.js +5 -0
- package/lib/protocol/validator.js +92 -3
- package/lib/remote/playwrightServer.js +1 -2
- package/lib/server/agent/actionRunner.js +335 -0
- package/lib/server/agent/actions.js +128 -0
- package/lib/server/agent/codegen.js +111 -0
- package/lib/server/agent/context.js +150 -0
- package/lib/server/agent/expectTools.js +156 -0
- package/lib/server/agent/pageAgent.js +204 -0
- package/lib/server/agent/performTools.js +262 -0
- package/lib/server/agent/tool.js +109 -0
- package/lib/server/artifact.js +1 -1
- package/lib/server/bidi/bidiBrowser.js +56 -12
- package/lib/server/bidi/bidiChromium.js +6 -11
- package/lib/server/bidi/bidiConnection.js +1 -0
- package/lib/server/bidi/bidiDeserializer.js +116 -0
- package/lib/server/bidi/bidiExecutionContext.js +75 -29
- package/lib/server/bidi/bidiFirefox.js +6 -8
- package/lib/server/bidi/bidiNetworkManager.js +1 -1
- package/lib/server/bidi/bidiPage.js +39 -28
- package/lib/server/bidi/third_party/bidiProtocolCore.js +1 -0
- package/lib/server/browserContext.js +32 -25
- package/lib/server/browserType.js +12 -4
- package/lib/server/chromium/chromium.js +14 -21
- package/lib/server/chromium/chromiumSwitches.js +2 -2
- package/lib/server/chromium/crBrowser.js +22 -12
- package/lib/server/chromium/crConnection.js +0 -5
- package/lib/server/chromium/crDevTools.js +0 -2
- package/lib/server/chromium/crNetworkManager.js +43 -2
- package/lib/server/chromium/crPage.js +19 -87
- package/lib/server/codegen/javascript.js +6 -29
- package/lib/server/deviceDescriptorsSource.json +56 -56
- package/lib/server/dispatchers/browserContextDispatcher.js +3 -0
- package/lib/server/dispatchers/dispatcher.js +6 -13
- package/lib/server/dispatchers/frameDispatcher.js +1 -1
- package/lib/server/dispatchers/pageAgentDispatcher.js +96 -0
- package/lib/server/dispatchers/pageDispatcher.js +4 -0
- package/lib/server/dom.js +12 -3
- package/lib/server/electron/electron.js +5 -2
- package/lib/server/firefox/ffBrowser.js +10 -20
- package/lib/server/firefox/ffConnection.js +0 -5
- package/lib/server/firefox/ffNetworkManager.js +2 -2
- package/lib/server/firefox/ffPage.js +15 -18
- package/lib/server/firefox/firefox.js +6 -8
- package/lib/server/frameSelectors.js +9 -3
- package/lib/server/frames.js +49 -33
- package/lib/server/instrumentation.js +3 -0
- package/lib/server/network.js +50 -12
- package/lib/server/page.js +33 -89
- package/lib/server/progress.js +26 -6
- package/lib/server/recorder/recorderApp.js +79 -100
- package/lib/server/recorder.js +55 -0
- package/lib/server/registry/browserFetcher.js +6 -4
- package/lib/server/registry/index.js +172 -149
- package/lib/server/registry/oopDownloadBrowserMain.js +3 -0
- package/lib/server/screencast.js +190 -0
- package/lib/server/screenshotCompositor.js +153 -0
- package/lib/server/trace/recorder/snapshotterInjected.js +21 -1
- package/lib/server/trace/recorder/tracing.js +21 -21
- package/lib/server/trace/viewer/traceParser.js +72 -0
- package/lib/server/trace/viewer/traceViewer.js +17 -13
- package/lib/server/utils/expectUtils.js +87 -2
- package/lib/server/utils/httpServer.js +4 -19
- package/lib/server/utils/network.js +37 -28
- package/lib/server/utils/nodePlatform.js +6 -0
- package/lib/server/videoRecorder.js +124 -0
- package/lib/server/webkit/webkit.js +4 -6
- package/lib/server/webkit/wkBrowser.js +2 -6
- package/lib/server/webkit/wkConnection.js +1 -6
- package/lib/server/webkit/wkInterceptableRequest.js +29 -1
- package/lib/server/webkit/wkPage.js +75 -46
- package/lib/utils/isomorphic/ariaSnapshot.js +60 -2
- package/lib/utils/isomorphic/lruCache.js +51 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +9 -1
- package/lib/utils/isomorphic/stringUtils.js +49 -0
- package/lib/utils/isomorphic/trace/entries.js +16 -0
- package/lib/utils/isomorphic/trace/snapshotRenderer.js +499 -0
- package/lib/utils/isomorphic/trace/snapshotServer.js +120 -0
- package/lib/utils/isomorphic/trace/snapshotStorage.js +89 -0
- package/lib/utils/isomorphic/trace/traceLoader.js +131 -0
- package/lib/utils/isomorphic/trace/traceModel.js +365 -0
- package/lib/utils/isomorphic/trace/traceModernizer.js +400 -0
- package/lib/utils/isomorphic/trace/versions/traceV3.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV4.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV5.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV6.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV7.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV8.js +16 -0
- package/lib/utils/isomorphic/yaml.js +84 -0
- package/lib/utils.js +2 -0
- package/lib/utilsBundle.js +2 -5
- package/lib/utilsBundleImpl/index.js +165 -165
- package/lib/vite/htmlReport/index.html +21 -21
- package/lib/vite/recorder/assets/{codeMirrorModule-C3UTv-Ge.css → codeMirrorModule-DYBRYzYX.css} +1 -1
- package/lib/vite/recorder/assets/codeMirrorModule-DadYNm1I.js +32 -0
- package/lib/vite/recorder/assets/{index-Ri0uHF7I.css → index-BSjZa4pk.css} +1 -1
- package/lib/vite/recorder/assets/index-BhTWtUlo.js +193 -0
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-8UJPCtp4.js +16884 -0
- package/lib/vite/{recorder/assets/codeMirrorModule-BoWUGj0J.js → traceViewer/assets/codeMirrorModule-BNr6yhVP.js} +1 -1
- package/lib/vite/traceViewer/assets/codeMirrorModule-Dimjuz94.js +32 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-DkmsYcws.js +32 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-DySgctgr.js +16884 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-B1vuWQsF.js +266 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-CtEsdeVH.js +266 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-D4fm31R-.js +34087 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-JtyB0yzL.js +34087 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-tEZf-LNj.js +266 -0
- package/lib/vite/traceViewer/assets/xtermModule-DDw6eROI.js +6168 -0
- package/lib/vite/traceViewer/codeMirrorModule.DYBRYzYX.css +1 -0
- package/lib/vite/traceViewer/codeMirrorModule.DuST8d_k.css +344 -0
- package/lib/vite/traceViewer/defaultSettingsView.5FCqBwKs.css +3986 -0
- package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +1 -0
- package/lib/vite/traceViewer/index.BQs8gGhY.js +249 -0
- package/lib/vite/traceViewer/index.BVu7tZDe.css +1 -0
- package/lib/vite/traceViewer/index.BoLn624r.js +2 -0
- package/lib/vite/traceViewer/index.Bq_EaK8x.js +249 -0
- package/lib/vite/traceViewer/index.C8YVh4B5.js +2 -0
- package/lib/vite/traceViewer/index.Cr7-GRf8.js +2 -0
- package/lib/vite/traceViewer/index.G-7UhDxt.css +164 -0
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/sw.bundle.js +5 -3
- package/lib/vite/traceViewer/uiMode.-Kflt2XM.css +1440 -0
- package/lib/vite/traceViewer/uiMode.BTRKnokb.js +5 -0
- package/lib/vite/traceViewer/uiMode.CEZ5RVHh.js +5 -0
- package/lib/vite/traceViewer/uiMode.CIWF23si.js +1829 -0
- package/lib/vite/traceViewer/uiMode.Wi-DvIEY.js +1829 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/lib/vite/traceViewer/uiMode.zEH1ejvz.js +5 -0
- package/lib/vite/traceViewer/xtermModule.BKlWQB97.css +218 -0
- package/package.json +3 -1
- package/types/protocol.d.ts +738 -159
- package/types/types.d.ts +25 -38
- package/lib/vite/recorder/assets/index-DJqDAOZp.js +0 -193
|
@@ -0,0 +1,262 @@
|
|
|
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 performTools_exports = {};
|
|
20
|
+
__export(performTools_exports, {
|
|
21
|
+
default: () => performTools_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(performTools_exports);
|
|
24
|
+
var import_mcpBundle = require("../../mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const navigateSchema = import_mcpBundle.z.object({
|
|
27
|
+
url: import_mcpBundle.z.string().describe("URL to navigate to")
|
|
28
|
+
});
|
|
29
|
+
const navigate = (0, import_tool.defineTool)({
|
|
30
|
+
schema: {
|
|
31
|
+
name: "browser_navigate",
|
|
32
|
+
title: "Navigate to URL",
|
|
33
|
+
description: "Navigate to a URL",
|
|
34
|
+
inputSchema: navigateSchema
|
|
35
|
+
},
|
|
36
|
+
handle: async (progress, context, params) => {
|
|
37
|
+
return await context.runActionNoWait(progress, {
|
|
38
|
+
method: "navigate",
|
|
39
|
+
url: params.url
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const snapshot = (0, import_tool.defineTool)({
|
|
44
|
+
schema: {
|
|
45
|
+
name: "browser_snapshot",
|
|
46
|
+
title: "Page snapshot",
|
|
47
|
+
description: "Capture accessibility snapshot of the current page, this is better than screenshot",
|
|
48
|
+
inputSchema: import_mcpBundle.z.object({})
|
|
49
|
+
},
|
|
50
|
+
handle: async (progress, context, params) => {
|
|
51
|
+
return await context.snapshotResult(progress);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const elementSchema = import_mcpBundle.z.object({
|
|
55
|
+
element: import_mcpBundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element"),
|
|
56
|
+
ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
|
|
57
|
+
});
|
|
58
|
+
const clickSchema = elementSchema.extend({
|
|
59
|
+
doubleClick: import_mcpBundle.z.boolean().optional().describe("Whether to perform a double click instead of a single click"),
|
|
60
|
+
button: import_mcpBundle.z.enum(["left", "right", "middle"]).optional().describe("Button to click, defaults to left"),
|
|
61
|
+
modifiers: import_mcpBundle.z.array(import_mcpBundle.z.enum(["Alt", "Control", "ControlOrMeta", "Meta", "Shift"])).optional().describe("Modifier keys to press")
|
|
62
|
+
});
|
|
63
|
+
const click = (0, import_tool.defineTool)({
|
|
64
|
+
schema: {
|
|
65
|
+
name: "browser_click",
|
|
66
|
+
title: "Click",
|
|
67
|
+
description: "Perform click on a web page",
|
|
68
|
+
inputSchema: clickSchema
|
|
69
|
+
},
|
|
70
|
+
handle: async (progress, context, params) => {
|
|
71
|
+
const [selector] = await context.refSelectors(progress, [params]);
|
|
72
|
+
return await context.runActionAndWait(progress, {
|
|
73
|
+
method: "click",
|
|
74
|
+
selector,
|
|
75
|
+
button: params.button,
|
|
76
|
+
modifiers: params.modifiers,
|
|
77
|
+
clickCount: params.doubleClick ? 2 : void 0
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const drag = (0, import_tool.defineTool)({
|
|
82
|
+
schema: {
|
|
83
|
+
name: "browser_drag",
|
|
84
|
+
title: "Drag mouse",
|
|
85
|
+
description: "Perform drag and drop between two elements",
|
|
86
|
+
inputSchema: import_mcpBundle.z.object({
|
|
87
|
+
startElement: import_mcpBundle.z.string().describe("Human-readable source element description used to obtain the permission to interact with the element"),
|
|
88
|
+
startRef: import_mcpBundle.z.string().describe("Exact source element reference from the page snapshot"),
|
|
89
|
+
endElement: import_mcpBundle.z.string().describe("Human-readable target element description used to obtain the permission to interact with the element"),
|
|
90
|
+
endRef: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
|
|
91
|
+
})
|
|
92
|
+
},
|
|
93
|
+
handle: async (progress, context, params) => {
|
|
94
|
+
const [sourceSelector, targetSelector] = await context.refSelectors(progress, [
|
|
95
|
+
{ ref: params.startRef, element: params.startElement },
|
|
96
|
+
{ ref: params.endRef, element: params.endElement }
|
|
97
|
+
]);
|
|
98
|
+
return await context.runActionAndWait(progress, {
|
|
99
|
+
method: "drag",
|
|
100
|
+
sourceSelector,
|
|
101
|
+
targetSelector
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
const hoverSchema = elementSchema.extend({
|
|
106
|
+
modifiers: import_mcpBundle.z.array(import_mcpBundle.z.enum(["Alt", "Control", "ControlOrMeta", "Meta", "Shift"])).optional().describe("Modifier keys to press")
|
|
107
|
+
});
|
|
108
|
+
const hover = (0, import_tool.defineTool)({
|
|
109
|
+
schema: {
|
|
110
|
+
name: "browser_hover",
|
|
111
|
+
title: "Hover mouse",
|
|
112
|
+
description: "Hover over element on page",
|
|
113
|
+
inputSchema: hoverSchema
|
|
114
|
+
},
|
|
115
|
+
handle: async (progress, context, params) => {
|
|
116
|
+
const [selector] = await context.refSelectors(progress, [params]);
|
|
117
|
+
return await context.runActionAndWait(progress, {
|
|
118
|
+
method: "hover",
|
|
119
|
+
selector,
|
|
120
|
+
modifiers: params.modifiers
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
const selectOptionSchema = elementSchema.extend({
|
|
125
|
+
values: import_mcpBundle.z.array(import_mcpBundle.z.string()).describe("Array of values to select in the dropdown. This can be a single value or multiple values.")
|
|
126
|
+
});
|
|
127
|
+
const selectOption = (0, import_tool.defineTool)({
|
|
128
|
+
schema: {
|
|
129
|
+
name: "browser_select_option",
|
|
130
|
+
title: "Select option",
|
|
131
|
+
description: "Select an option in a dropdown",
|
|
132
|
+
inputSchema: selectOptionSchema
|
|
133
|
+
},
|
|
134
|
+
handle: async (progress, context, params) => {
|
|
135
|
+
const [selector] = await context.refSelectors(progress, [params]);
|
|
136
|
+
return await context.runActionAndWait(progress, {
|
|
137
|
+
method: "selectOption",
|
|
138
|
+
selector,
|
|
139
|
+
labels: params.values
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const pressKey = (0, import_tool.defineTool)({
|
|
144
|
+
schema: {
|
|
145
|
+
name: "browser_press_key",
|
|
146
|
+
title: "Press a key",
|
|
147
|
+
description: "Press a key on the keyboard",
|
|
148
|
+
inputSchema: import_mcpBundle.z.object({
|
|
149
|
+
key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`"),
|
|
150
|
+
modifiers: import_mcpBundle.z.array(import_mcpBundle.z.enum(["Alt", "Control", "ControlOrMeta", "Meta", "Shift"])).optional().describe("Modifier keys to press")
|
|
151
|
+
})
|
|
152
|
+
},
|
|
153
|
+
handle: async (progress, context, params) => {
|
|
154
|
+
return await context.runActionAndWait(progress, {
|
|
155
|
+
method: "pressKey",
|
|
156
|
+
key: params.modifiers ? [...params.modifiers, params.key].join("+") : params.key
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
const typeSchema = elementSchema.extend({
|
|
161
|
+
text: import_mcpBundle.z.string().describe("Text to type into the element"),
|
|
162
|
+
submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)"),
|
|
163
|
+
slowly: import_mcpBundle.z.boolean().optional().describe("Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.")
|
|
164
|
+
});
|
|
165
|
+
const type = (0, import_tool.defineTool)({
|
|
166
|
+
schema: {
|
|
167
|
+
name: "browser_type",
|
|
168
|
+
title: "Type text",
|
|
169
|
+
description: "Type text into editable element",
|
|
170
|
+
inputSchema: typeSchema
|
|
171
|
+
},
|
|
172
|
+
handle: async (progress, context, params) => {
|
|
173
|
+
const [selector] = await context.refSelectors(progress, [params]);
|
|
174
|
+
if (params.slowly) {
|
|
175
|
+
return await context.runActionAndWait(progress, {
|
|
176
|
+
method: "pressSequentially",
|
|
177
|
+
selector,
|
|
178
|
+
text: params.text,
|
|
179
|
+
submit: params.submit
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
return await context.runActionAndWait(progress, {
|
|
183
|
+
method: "fill",
|
|
184
|
+
selector,
|
|
185
|
+
text: params.text,
|
|
186
|
+
submit: params.submit
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
const fillForm = (0, import_tool.defineTool)({
|
|
192
|
+
schema: {
|
|
193
|
+
name: "browser_fill_form",
|
|
194
|
+
title: "Fill form",
|
|
195
|
+
description: "Fill multiple form fields. Always use this tool when you can fill more than one field at a time.",
|
|
196
|
+
inputSchema: import_mcpBundle.z.object({
|
|
197
|
+
fields: import_mcpBundle.z.array(import_mcpBundle.z.object({
|
|
198
|
+
name: import_mcpBundle.z.string().describe("Human-readable field name"),
|
|
199
|
+
type: import_mcpBundle.z.enum(["textbox", "checkbox", "radio", "combobox", "slider"]).describe("Type of the field"),
|
|
200
|
+
ref: import_mcpBundle.z.string().describe("Exact target field reference from the page snapshot"),
|
|
201
|
+
value: import_mcpBundle.z.string().describe("Value to fill in the field. If the field is a checkbox, the value should be `true` or `false`. If the field is a combobox, the value should be the text of the option.")
|
|
202
|
+
})).describe("Fields to fill in")
|
|
203
|
+
})
|
|
204
|
+
},
|
|
205
|
+
handle: async (progress, context, params) => {
|
|
206
|
+
const actions = [];
|
|
207
|
+
for (const field of params.fields) {
|
|
208
|
+
const [selector] = await context.refSelectors(progress, [{ ref: field.ref, element: field.name }]);
|
|
209
|
+
if (field.type === "textbox" || field.type === "slider") {
|
|
210
|
+
actions.push({
|
|
211
|
+
method: "fill",
|
|
212
|
+
selector,
|
|
213
|
+
text: field.value
|
|
214
|
+
});
|
|
215
|
+
} else if (field.type === "checkbox" || field.type === "radio") {
|
|
216
|
+
actions.push({
|
|
217
|
+
method: "setChecked",
|
|
218
|
+
selector,
|
|
219
|
+
checked: field.value === "true"
|
|
220
|
+
});
|
|
221
|
+
} else if (field.type === "combobox") {
|
|
222
|
+
actions.push({
|
|
223
|
+
method: "selectOption",
|
|
224
|
+
selector,
|
|
225
|
+
labels: [field.value]
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return await context.runActionsAndWait(progress, actions);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
const setCheckedSchema = elementSchema.extend({
|
|
233
|
+
checked: import_mcpBundle.z.boolean().describe("Whether to check the checkbox")
|
|
234
|
+
});
|
|
235
|
+
const setChecked = (0, import_tool.defineTool)({
|
|
236
|
+
schema: {
|
|
237
|
+
name: "browser_set_checked",
|
|
238
|
+
title: "Set checked",
|
|
239
|
+
description: "Set the checked state of a checkbox",
|
|
240
|
+
inputSchema: setCheckedSchema
|
|
241
|
+
},
|
|
242
|
+
handle: async (progress, context, params) => {
|
|
243
|
+
const [selector] = await context.refSelectors(progress, [params]);
|
|
244
|
+
return await context.runActionAndWait(progress, {
|
|
245
|
+
method: "setChecked",
|
|
246
|
+
selector,
|
|
247
|
+
checked: params.checked
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
var performTools_default = [
|
|
252
|
+
navigate,
|
|
253
|
+
snapshot,
|
|
254
|
+
click,
|
|
255
|
+
drag,
|
|
256
|
+
hover,
|
|
257
|
+
selectOption,
|
|
258
|
+
pressKey,
|
|
259
|
+
type,
|
|
260
|
+
fillForm,
|
|
261
|
+
setChecked
|
|
262
|
+
];
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
defineTool: () => defineTool,
|
|
22
|
+
toolsForLoop: () => toolsForLoop
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(tool_exports);
|
|
25
|
+
var import_mcpBundle = require("../../mcpBundle");
|
|
26
|
+
var import_stringUtils = require("../../utils/isomorphic/stringUtils");
|
|
27
|
+
function defineTool(tool) {
|
|
28
|
+
return tool;
|
|
29
|
+
}
|
|
30
|
+
function toolsForLoop(progress, context, toolDefinitions, options = {}) {
|
|
31
|
+
const tools = toolDefinitions.map((tool) => {
|
|
32
|
+
const result = {
|
|
33
|
+
name: tool.schema.name,
|
|
34
|
+
description: tool.schema.description,
|
|
35
|
+
inputSchema: import_mcpBundle.z.toJSONSchema(tool.schema.inputSchema)
|
|
36
|
+
};
|
|
37
|
+
return result;
|
|
38
|
+
});
|
|
39
|
+
if (options.resultSchema) {
|
|
40
|
+
tools.push({
|
|
41
|
+
name: "report_result",
|
|
42
|
+
description: "Report the result of the task.",
|
|
43
|
+
inputSchema: options.resultSchema
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (options.refuseToPerform === "allow") {
|
|
47
|
+
tools.push({
|
|
48
|
+
name: "refuse_to_perform",
|
|
49
|
+
description: "Refuse to perform action.",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
reason: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description: `Call this when you believe that you can't perform the action because something is wrong with the page. The reason will be reported to the user.`
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
required: ["reason"]
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
let reportedResult;
|
|
63
|
+
let refusedToPerformReason;
|
|
64
|
+
const callTool = async (params) => {
|
|
65
|
+
if (params.name === "report_result") {
|
|
66
|
+
reportedResult = params.arguments;
|
|
67
|
+
return {
|
|
68
|
+
content: [{ type: "text", text: "Done" }],
|
|
69
|
+
isError: false
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (params.name === "refuse_to_perform") {
|
|
73
|
+
refusedToPerformReason = params.arguments.reason;
|
|
74
|
+
return {
|
|
75
|
+
content: [{ type: "text", text: "Done" }],
|
|
76
|
+
isError: false
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const tool = toolDefinitions.find((t) => t.schema.name === params.name);
|
|
80
|
+
if (!tool) {
|
|
81
|
+
return {
|
|
82
|
+
content: [{
|
|
83
|
+
type: "text",
|
|
84
|
+
text: `Tool ${params.name} not found. Available tools: ${toolDefinitions.map((t) => t.schema.name)}`
|
|
85
|
+
}],
|
|
86
|
+
isError: true
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
return await tool.handle(progress, context, params.arguments);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return {
|
|
93
|
+
content: [{ type: "text", text: (0, import_stringUtils.stripAnsiEscapes)(error.message) }],
|
|
94
|
+
isError: true
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
tools,
|
|
100
|
+
callTool,
|
|
101
|
+
reportedResult: options.resultSchema ? () => reportedResult : void 0,
|
|
102
|
+
refusedToPerformReason: () => refusedToPerformReason
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
defineTool,
|
|
108
|
+
toolsForLoop
|
|
109
|
+
});
|
package/lib/server/artifact.js
CHANGED
|
@@ -103,7 +103,7 @@ class Artifact extends import_instrumentation.SdkObject {
|
|
|
103
103
|
if (!this._unaccessibleErrorMessage)
|
|
104
104
|
await import_fs.default.promises.unlink(this._localPath).catch((e) => {
|
|
105
105
|
});
|
|
106
|
-
await this.reportFinished(new import_errors.TargetClosedError());
|
|
106
|
+
await this.reportFinished(new import_errors.TargetClosedError(this.closeReason()));
|
|
107
107
|
}
|
|
108
108
|
async reportFinished(error) {
|
|
109
109
|
if (this._finished)
|
|
@@ -130,10 +130,13 @@ class BidiBrowser extends import_browser.Browser {
|
|
|
130
130
|
const page2 = this._findPageForFrame(parentFrameId);
|
|
131
131
|
if (page2) {
|
|
132
132
|
page2._session.addFrameBrowsingContext(event.context);
|
|
133
|
-
page2._page.frameManager.frameAttached(event.context, parentFrameId);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
const frame = page2._page.frameManager.frameAttached(event.context, parentFrameId);
|
|
134
|
+
frame._url = event.url;
|
|
135
|
+
page2._getFrameNode(frame).then((node) => {
|
|
136
|
+
const attributes = node?.value?.attributes;
|
|
137
|
+
frame._name = attributes?.name ?? attributes?.id ?? "";
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
137
140
|
}
|
|
138
141
|
return;
|
|
139
142
|
}
|
|
@@ -142,6 +145,7 @@ class BidiBrowser extends import_browser.Browser {
|
|
|
142
145
|
context = this._defaultContext;
|
|
143
146
|
if (!context)
|
|
144
147
|
return;
|
|
148
|
+
context.doGrantGlobalPermissionsForURL(event.url);
|
|
145
149
|
const session = this._connection.createMainFrameBrowsingContextSession(event.context);
|
|
146
150
|
const opener = event.originalOpener && this._findPageForFrame(event.originalOpener);
|
|
147
151
|
const page = new import_bidiPage.BidiPage(context, session, opener || null);
|
|
@@ -217,6 +221,8 @@ class BidiBrowserContext extends import_browserContext.BrowserContext {
|
|
|
217
221
|
}
|
|
218
222
|
if (this._options.extraHTTPHeaders)
|
|
219
223
|
promises.push(this.doUpdateExtraHTTPHeaders());
|
|
224
|
+
if (this._options.permissions)
|
|
225
|
+
promises.push(this.doGrantPermissions("*", this._options.permissions));
|
|
220
226
|
await Promise.all(promises);
|
|
221
227
|
}
|
|
222
228
|
possiblyUninitializedPages() {
|
|
@@ -275,17 +281,34 @@ class BidiBrowserContext extends import_browserContext.BrowserContext {
|
|
|
275
281
|
);
|
|
276
282
|
}
|
|
277
283
|
async doGrantPermissions(origin, permissions) {
|
|
284
|
+
if (origin === "null")
|
|
285
|
+
return;
|
|
278
286
|
const currentPermissions = this._originToPermissions.get(origin) || [];
|
|
279
287
|
const toGrant = permissions.filter((permission) => !currentPermissions.includes(permission));
|
|
280
288
|
this._originToPermissions.set(origin, [...currentPermissions, ...toGrant]);
|
|
281
|
-
|
|
289
|
+
if (origin === "*") {
|
|
290
|
+
await Promise.all(this._bidiPages().flatMap(
|
|
291
|
+
(page) => page._page.frames().map(
|
|
292
|
+
(frame) => this.doGrantPermissions(new URL(frame._url).origin, permissions)
|
|
293
|
+
)
|
|
294
|
+
));
|
|
295
|
+
} else {
|
|
296
|
+
await Promise.all(toGrant.map((permission) => this._setPermission(origin, permission, bidi.Permissions.PermissionState.Granted)));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
async doGrantGlobalPermissionsForURL(url) {
|
|
300
|
+
const permissions = this._originToPermissions.get("*");
|
|
301
|
+
if (!permissions)
|
|
302
|
+
return;
|
|
303
|
+
await this.doGrantPermissions(new URL(url).origin, permissions);
|
|
282
304
|
}
|
|
283
305
|
async doClearPermissions() {
|
|
284
306
|
const currentPermissions = [...this._originToPermissions.entries()];
|
|
285
307
|
this._originToPermissions = /* @__PURE__ */ new Map();
|
|
286
|
-
await Promise.all(currentPermissions.
|
|
287
|
-
|
|
288
|
-
|
|
308
|
+
await Promise.all(currentPermissions.flatMap(([origin, permissions]) => {
|
|
309
|
+
if (origin !== "*")
|
|
310
|
+
return permissions.map((p) => this._setPermission(origin, p, bidi.Permissions.PermissionState.Prompt));
|
|
311
|
+
}));
|
|
289
312
|
}
|
|
290
313
|
async _setPermission(origin, permission, state) {
|
|
291
314
|
await this._browser._browserSession.send("permissions.setPermission", {
|
|
@@ -349,21 +372,42 @@ class BidiBrowserContext extends import_browserContext.BrowserContext {
|
|
|
349
372
|
await Promise.all(ids.map((script) => this._browser._browserSession.send("script.removePreloadScript", { script })));
|
|
350
373
|
}
|
|
351
374
|
async doUpdateRequestInterception() {
|
|
375
|
+
if (this.requestInterceptors.length > 0 && !this._interceptId) {
|
|
376
|
+
const { intercept } = await this._browser._browserSession.send("network.addIntercept", {
|
|
377
|
+
phases: [bidi.Network.InterceptPhase.BeforeRequestSent],
|
|
378
|
+
urlPatterns: [{ type: "pattern" }]
|
|
379
|
+
});
|
|
380
|
+
this._interceptId = intercept;
|
|
381
|
+
}
|
|
382
|
+
if (this.requestInterceptors.length === 0 && this._interceptId) {
|
|
383
|
+
const intercept = this._interceptId;
|
|
384
|
+
this._interceptId = void 0;
|
|
385
|
+
await this._browser._browserSession.send("network.removeIntercept", { intercept });
|
|
386
|
+
}
|
|
352
387
|
}
|
|
353
388
|
async doUpdateDefaultViewport() {
|
|
354
|
-
if (!this._options.viewport)
|
|
389
|
+
if (!this._options.viewport && !this._options.screen)
|
|
355
390
|
return;
|
|
391
|
+
const screenSize = this._options.screen || this._options.viewport;
|
|
392
|
+
const viewportSize = this._options.viewport || this._options.screen;
|
|
356
393
|
await Promise.all([
|
|
357
394
|
this._browser._browserSession.send("browsingContext.setViewport", {
|
|
358
395
|
viewport: {
|
|
359
|
-
width:
|
|
360
|
-
height:
|
|
396
|
+
width: viewportSize.width,
|
|
397
|
+
height: viewportSize.height
|
|
361
398
|
},
|
|
362
399
|
devicePixelRatio: this._options.deviceScaleFactor || 1,
|
|
363
400
|
userContexts: [this._userContextId()]
|
|
364
401
|
}),
|
|
365
402
|
this._browser._browserSession.send("emulation.setScreenOrientationOverride", {
|
|
366
|
-
screenOrientation: getScreenOrientation(!!this._options.isMobile,
|
|
403
|
+
screenOrientation: getScreenOrientation(!!this._options.isMobile, screenSize),
|
|
404
|
+
userContexts: [this._userContextId()]
|
|
405
|
+
}),
|
|
406
|
+
this._browser._browserSession.send("emulation.setScreenSettingsOverride", {
|
|
407
|
+
screenArea: {
|
|
408
|
+
width: screenSize.width,
|
|
409
|
+
height: screenSize.height
|
|
410
|
+
},
|
|
367
411
|
userContexts: [this._userContextId()]
|
|
368
412
|
})
|
|
369
413
|
]);
|
|
@@ -56,14 +56,12 @@ class BidiChromium extends import_browserType.BrowserType {
|
|
|
56
56
|
throw e;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
doRewriteStartupLog(
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return error;
|
|
66
|
-
error.logs = [
|
|
59
|
+
doRewriteStartupLog(logs) {
|
|
60
|
+
if (logs.includes("Missing X server"))
|
|
61
|
+
logs = "\n" + (0, import_ascii.wrapInASCIIBox)(import_browserType.kNoXServerRunningError, 1);
|
|
62
|
+
if (!logs.includes("crbug.com/357670") && !logs.includes("No usable sandbox!") && !logs.includes("crbug.com/638180"))
|
|
63
|
+
return logs;
|
|
64
|
+
return [
|
|
67
65
|
`Chromium sandboxing failed!`,
|
|
68
66
|
`================================`,
|
|
69
67
|
`To avoid the sandboxing issue, do either of the following:`,
|
|
@@ -72,7 +70,6 @@ class BidiChromium extends import_browserType.BrowserType {
|
|
|
72
70
|
`================================`,
|
|
73
71
|
``
|
|
74
72
|
].join("\n");
|
|
75
|
-
return error;
|
|
76
73
|
}
|
|
77
74
|
amendEnvironment(env) {
|
|
78
75
|
return env;
|
|
@@ -112,8 +109,6 @@ class BidiChromium extends import_browserType.BrowserType {
|
|
|
112
109
|
if (import_os.default.platform() === "darwin") {
|
|
113
110
|
chromeArguments.push("--enable-unsafe-swiftshader");
|
|
114
111
|
}
|
|
115
|
-
if (options.devtools)
|
|
116
|
-
chromeArguments.push("--auto-open-devtools-for-tabs");
|
|
117
112
|
if (options.headless) {
|
|
118
113
|
chromeArguments.push("--headless");
|
|
119
114
|
chromeArguments.push(
|
|
@@ -173,6 +173,7 @@ class BidiSession extends import_events.EventEmitter {
|
|
|
173
173
|
this._browsingContexts.clear();
|
|
174
174
|
for (const callback of this._callbacks.values()) {
|
|
175
175
|
callback.error.type = this._crashed ? "crashed" : "closed";
|
|
176
|
+
callback.error.setMessage(`Internal server error, session ${callback.error.type}.`);
|
|
176
177
|
callback.error.logs = this.connection._browserDisconnectedLogs;
|
|
177
178
|
callback.reject(callback.error);
|
|
178
179
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
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 bidiDeserializer_exports = {};
|
|
20
|
+
__export(bidiDeserializer_exports, {
|
|
21
|
+
deserializeBidiValue: () => deserializeBidiValue
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(bidiDeserializer_exports);
|
|
24
|
+
var import_javascript = require("../javascript");
|
|
25
|
+
function deserializeBidiValue(result, internalIdMap = /* @__PURE__ */ new Map()) {
|
|
26
|
+
switch (result.type) {
|
|
27
|
+
case "undefined":
|
|
28
|
+
return void 0;
|
|
29
|
+
case "null":
|
|
30
|
+
return null;
|
|
31
|
+
case "number":
|
|
32
|
+
return typeof result.value === "number" ? result.value : (0, import_javascript.parseUnserializableValue)(result.value);
|
|
33
|
+
case "boolean":
|
|
34
|
+
return Boolean(result.value);
|
|
35
|
+
case "string":
|
|
36
|
+
return result.value;
|
|
37
|
+
case "bigint":
|
|
38
|
+
return BigInt(result.value);
|
|
39
|
+
case "array":
|
|
40
|
+
return deserializeBidiList(result, internalIdMap);
|
|
41
|
+
case "arraybuffer":
|
|
42
|
+
return getValue(result, internalIdMap, () => ({}));
|
|
43
|
+
case "date":
|
|
44
|
+
return getValue(result, internalIdMap, () => new Date(result.value));
|
|
45
|
+
case "error":
|
|
46
|
+
return getValue(result, internalIdMap, () => {
|
|
47
|
+
const error = new Error();
|
|
48
|
+
error.stack = "";
|
|
49
|
+
return error;
|
|
50
|
+
});
|
|
51
|
+
case "function":
|
|
52
|
+
return void 0;
|
|
53
|
+
case "generator":
|
|
54
|
+
return getValue(result, internalIdMap, () => ({}));
|
|
55
|
+
case "htmlcollection":
|
|
56
|
+
return { ...deserializeBidiList(result, internalIdMap) };
|
|
57
|
+
case "map":
|
|
58
|
+
return getValue(result, internalIdMap, () => ({}));
|
|
59
|
+
case "node":
|
|
60
|
+
return "ref: <Node>";
|
|
61
|
+
case "nodelist":
|
|
62
|
+
return { ...deserializeBidiList(result, internalIdMap) };
|
|
63
|
+
case "object":
|
|
64
|
+
return deserializeBidiMapping(result, internalIdMap);
|
|
65
|
+
case "promise":
|
|
66
|
+
return getValue(result, internalIdMap, () => ({}));
|
|
67
|
+
case "proxy":
|
|
68
|
+
return getValue(result, internalIdMap, () => ({}));
|
|
69
|
+
case "regexp":
|
|
70
|
+
return getValue(result, internalIdMap, () => new RegExp(result.value.pattern, result.value.flags));
|
|
71
|
+
case "set":
|
|
72
|
+
return getValue(result, internalIdMap, () => ({}));
|
|
73
|
+
case "symbol":
|
|
74
|
+
return void 0;
|
|
75
|
+
case "typedarray":
|
|
76
|
+
return void 0;
|
|
77
|
+
case "weakmap":
|
|
78
|
+
return getValue(result, internalIdMap, () => ({}));
|
|
79
|
+
case "weakset":
|
|
80
|
+
return getValue(result, internalIdMap, () => ({}));
|
|
81
|
+
case "window":
|
|
82
|
+
return "ref: <Window>";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function getValue(bidiValue, internalIdMap, defaultValue) {
|
|
86
|
+
if ("internalId" in bidiValue && bidiValue.internalId) {
|
|
87
|
+
if (internalIdMap.has(bidiValue.internalId)) {
|
|
88
|
+
return internalIdMap.get(bidiValue.internalId);
|
|
89
|
+
} else {
|
|
90
|
+
const value = defaultValue();
|
|
91
|
+
internalIdMap.set(bidiValue.internalId, value);
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
return defaultValue();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function deserializeBidiList(bidiValue, internalIdMap) {
|
|
99
|
+
const result = getValue(bidiValue, internalIdMap, () => []);
|
|
100
|
+
for (const val of bidiValue.value || [])
|
|
101
|
+
result.push(deserializeBidiValue(val, internalIdMap));
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
function deserializeBidiMapping(bidiValue, internalIdMap) {
|
|
105
|
+
const result = getValue(bidiValue, internalIdMap, () => ({}));
|
|
106
|
+
for (const [serializedKey, serializedValue] of bidiValue.value || []) {
|
|
107
|
+
const key = typeof serializedKey === "string" ? serializedKey : deserializeBidiValue(serializedKey, internalIdMap);
|
|
108
|
+
const value = deserializeBidiValue(serializedValue, internalIdMap);
|
|
109
|
+
result[key] = value;
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
114
|
+
0 && (module.exports = {
|
|
115
|
+
deserializeBidiValue
|
|
116
|
+
});
|