@thinkingos/vsl-mcp-server 1.2.17 → 1.3.2

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/dist/index.js CHANGED
@@ -1,4 +1,2508 @@
1
1
  #!/usr/bin/env node
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 __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __esm = (fn, res) => function __init() {
15
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
+ };
17
+ var __commonJS = (cb, mod) => function __require2() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") {
26
+ for (let key of __getOwnPropNames(from))
27
+ if (!__hasOwnProp.call(to, key) && key !== except)
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
+ }
30
+ return to;
31
+ };
32
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
+ // If the importer is in node compatibility mode or this is not an ESM
34
+ // file that has been converted to a CommonJS file using a Babel-
35
+ // compatible transform (i.e. "__esModule" has not been set), then set
36
+ // "default" to the CommonJS "module.exports" for node compatibility.
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
+ mod
39
+ ));
40
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+
42
+ // node_modules/ms/index.js
43
+ var require_ms = __commonJS({
44
+ "node_modules/ms/index.js"(exports, module) {
45
+ "use strict";
46
+ var s = 1e3;
47
+ var m = s * 60;
48
+ var h = m * 60;
49
+ var d = h * 24;
50
+ var w = d * 7;
51
+ var y = d * 365.25;
52
+ module.exports = function(val, options) {
53
+ options = options || {};
54
+ var type = typeof val;
55
+ if (type === "string" && val.length > 0) {
56
+ return parse(val);
57
+ } else if (type === "number" && isFinite(val)) {
58
+ return options.long ? fmtLong(val) : fmtShort(val);
59
+ }
60
+ throw new Error(
61
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
62
+ );
63
+ };
64
+ function parse(str) {
65
+ str = String(str);
66
+ if (str.length > 100) {
67
+ return;
68
+ }
69
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
70
+ str
71
+ );
72
+ if (!match) {
73
+ return;
74
+ }
75
+ var n = parseFloat(match[1]);
76
+ var type = (match[2] || "ms").toLowerCase();
77
+ switch (type) {
78
+ case "years":
79
+ case "year":
80
+ case "yrs":
81
+ case "yr":
82
+ case "y":
83
+ return n * y;
84
+ case "weeks":
85
+ case "week":
86
+ case "w":
87
+ return n * w;
88
+ case "days":
89
+ case "day":
90
+ case "d":
91
+ return n * d;
92
+ case "hours":
93
+ case "hour":
94
+ case "hrs":
95
+ case "hr":
96
+ case "h":
97
+ return n * h;
98
+ case "minutes":
99
+ case "minute":
100
+ case "mins":
101
+ case "min":
102
+ case "m":
103
+ return n * m;
104
+ case "seconds":
105
+ case "second":
106
+ case "secs":
107
+ case "sec":
108
+ case "s":
109
+ return n * s;
110
+ case "milliseconds":
111
+ case "millisecond":
112
+ case "msecs":
113
+ case "msec":
114
+ case "ms":
115
+ return n;
116
+ default:
117
+ return void 0;
118
+ }
119
+ }
120
+ function fmtShort(ms) {
121
+ var msAbs = Math.abs(ms);
122
+ if (msAbs >= d) {
123
+ return Math.round(ms / d) + "d";
124
+ }
125
+ if (msAbs >= h) {
126
+ return Math.round(ms / h) + "h";
127
+ }
128
+ if (msAbs >= m) {
129
+ return Math.round(ms / m) + "m";
130
+ }
131
+ if (msAbs >= s) {
132
+ return Math.round(ms / s) + "s";
133
+ }
134
+ return ms + "ms";
135
+ }
136
+ function fmtLong(ms) {
137
+ var msAbs = Math.abs(ms);
138
+ if (msAbs >= d) {
139
+ return plural(ms, msAbs, d, "day");
140
+ }
141
+ if (msAbs >= h) {
142
+ return plural(ms, msAbs, h, "hour");
143
+ }
144
+ if (msAbs >= m) {
145
+ return plural(ms, msAbs, m, "minute");
146
+ }
147
+ if (msAbs >= s) {
148
+ return plural(ms, msAbs, s, "second");
149
+ }
150
+ return ms + " ms";
151
+ }
152
+ function plural(ms, msAbs, n, name) {
153
+ var isPlural = msAbs >= n * 1.5;
154
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
155
+ }
156
+ }
157
+ });
158
+
159
+ // node_modules/debug/src/common.js
160
+ var require_common = __commonJS({
161
+ "node_modules/debug/src/common.js"(exports, module) {
162
+ "use strict";
163
+ function setup(env) {
164
+ createDebug.debug = createDebug;
165
+ createDebug.default = createDebug;
166
+ createDebug.coerce = coerce;
167
+ createDebug.disable = disable;
168
+ createDebug.enable = enable;
169
+ createDebug.enabled = enabled;
170
+ createDebug.humanize = require_ms();
171
+ createDebug.destroy = destroy;
172
+ Object.keys(env).forEach((key) => {
173
+ createDebug[key] = env[key];
174
+ });
175
+ createDebug.names = [];
176
+ createDebug.skips = [];
177
+ createDebug.formatters = {};
178
+ function selectColor(namespace) {
179
+ let hash = 0;
180
+ for (let i = 0; i < namespace.length; i++) {
181
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
182
+ hash |= 0;
183
+ }
184
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
185
+ }
186
+ createDebug.selectColor = selectColor;
187
+ function createDebug(namespace) {
188
+ let prevTime;
189
+ let enableOverride = null;
190
+ let namespacesCache;
191
+ let enabledCache;
192
+ function debug3(...args) {
193
+ if (!debug3.enabled) {
194
+ return;
195
+ }
196
+ const self = debug3;
197
+ const curr = Number(/* @__PURE__ */ new Date());
198
+ const ms = curr - (prevTime || curr);
199
+ self.diff = ms;
200
+ self.prev = prevTime;
201
+ self.curr = curr;
202
+ prevTime = curr;
203
+ args[0] = createDebug.coerce(args[0]);
204
+ if (typeof args[0] !== "string") {
205
+ args.unshift("%O");
206
+ }
207
+ let index = 0;
208
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
209
+ if (match === "%%") {
210
+ return "%";
211
+ }
212
+ index++;
213
+ const formatter = createDebug.formatters[format];
214
+ if (typeof formatter === "function") {
215
+ const val = args[index];
216
+ match = formatter.call(self, val);
217
+ args.splice(index, 1);
218
+ index--;
219
+ }
220
+ return match;
221
+ });
222
+ createDebug.formatArgs.call(self, args);
223
+ const logFn = self.log || createDebug.log;
224
+ logFn.apply(self, args);
225
+ }
226
+ debug3.namespace = namespace;
227
+ debug3.useColors = createDebug.useColors();
228
+ debug3.color = createDebug.selectColor(namespace);
229
+ debug3.extend = extend;
230
+ debug3.destroy = createDebug.destroy;
231
+ Object.defineProperty(debug3, "enabled", {
232
+ enumerable: true,
233
+ configurable: false,
234
+ get: () => {
235
+ if (enableOverride !== null) {
236
+ return enableOverride;
237
+ }
238
+ if (namespacesCache !== createDebug.namespaces) {
239
+ namespacesCache = createDebug.namespaces;
240
+ enabledCache = createDebug.enabled(namespace);
241
+ }
242
+ return enabledCache;
243
+ },
244
+ set: (v) => {
245
+ enableOverride = v;
246
+ }
247
+ });
248
+ if (typeof createDebug.init === "function") {
249
+ createDebug.init(debug3);
250
+ }
251
+ return debug3;
252
+ }
253
+ function extend(namespace, delimiter) {
254
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
255
+ newDebug.log = this.log;
256
+ return newDebug;
257
+ }
258
+ function enable(namespaces) {
259
+ createDebug.save(namespaces);
260
+ createDebug.namespaces = namespaces;
261
+ createDebug.names = [];
262
+ createDebug.skips = [];
263
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
264
+ for (const ns of split) {
265
+ if (ns[0] === "-") {
266
+ createDebug.skips.push(ns.slice(1));
267
+ } else {
268
+ createDebug.names.push(ns);
269
+ }
270
+ }
271
+ }
272
+ function matchesTemplate(search, template) {
273
+ let searchIndex = 0;
274
+ let templateIndex = 0;
275
+ let starIndex = -1;
276
+ let matchIndex = 0;
277
+ while (searchIndex < search.length) {
278
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
279
+ if (template[templateIndex] === "*") {
280
+ starIndex = templateIndex;
281
+ matchIndex = searchIndex;
282
+ templateIndex++;
283
+ } else {
284
+ searchIndex++;
285
+ templateIndex++;
286
+ }
287
+ } else if (starIndex !== -1) {
288
+ templateIndex = starIndex + 1;
289
+ matchIndex++;
290
+ searchIndex = matchIndex;
291
+ } else {
292
+ return false;
293
+ }
294
+ }
295
+ while (templateIndex < template.length && template[templateIndex] === "*") {
296
+ templateIndex++;
297
+ }
298
+ return templateIndex === template.length;
299
+ }
300
+ function disable() {
301
+ const namespaces = [
302
+ ...createDebug.names,
303
+ ...createDebug.skips.map((namespace) => "-" + namespace)
304
+ ].join(",");
305
+ createDebug.enable("");
306
+ return namespaces;
307
+ }
308
+ function enabled(name) {
309
+ for (const skip of createDebug.skips) {
310
+ if (matchesTemplate(name, skip)) {
311
+ return false;
312
+ }
313
+ }
314
+ for (const ns of createDebug.names) {
315
+ if (matchesTemplate(name, ns)) {
316
+ return true;
317
+ }
318
+ }
319
+ return false;
320
+ }
321
+ function coerce(val) {
322
+ if (val instanceof Error) {
323
+ return val.stack || val.message;
324
+ }
325
+ return val;
326
+ }
327
+ function destroy() {
328
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
329
+ }
330
+ createDebug.enable(createDebug.load());
331
+ return createDebug;
332
+ }
333
+ module.exports = setup;
334
+ }
335
+ });
336
+
337
+ // node_modules/debug/src/browser.js
338
+ var require_browser = __commonJS({
339
+ "node_modules/debug/src/browser.js"(exports, module) {
340
+ "use strict";
341
+ exports.formatArgs = formatArgs;
342
+ exports.save = save;
343
+ exports.load = load2;
344
+ exports.useColors = useColors;
345
+ exports.storage = localstorage();
346
+ exports.destroy = /* @__PURE__ */ (() => {
347
+ let warned = false;
348
+ return () => {
349
+ if (!warned) {
350
+ warned = true;
351
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
352
+ }
353
+ };
354
+ })();
355
+ exports.colors = [
356
+ "#0000CC",
357
+ "#0000FF",
358
+ "#0033CC",
359
+ "#0033FF",
360
+ "#0066CC",
361
+ "#0066FF",
362
+ "#0099CC",
363
+ "#0099FF",
364
+ "#00CC00",
365
+ "#00CC33",
366
+ "#00CC66",
367
+ "#00CC99",
368
+ "#00CCCC",
369
+ "#00CCFF",
370
+ "#3300CC",
371
+ "#3300FF",
372
+ "#3333CC",
373
+ "#3333FF",
374
+ "#3366CC",
375
+ "#3366FF",
376
+ "#3399CC",
377
+ "#3399FF",
378
+ "#33CC00",
379
+ "#33CC33",
380
+ "#33CC66",
381
+ "#33CC99",
382
+ "#33CCCC",
383
+ "#33CCFF",
384
+ "#6600CC",
385
+ "#6600FF",
386
+ "#6633CC",
387
+ "#6633FF",
388
+ "#66CC00",
389
+ "#66CC33",
390
+ "#9900CC",
391
+ "#9900FF",
392
+ "#9933CC",
393
+ "#9933FF",
394
+ "#99CC00",
395
+ "#99CC33",
396
+ "#CC0000",
397
+ "#CC0033",
398
+ "#CC0066",
399
+ "#CC0099",
400
+ "#CC00CC",
401
+ "#CC00FF",
402
+ "#CC3300",
403
+ "#CC3333",
404
+ "#CC3366",
405
+ "#CC3399",
406
+ "#CC33CC",
407
+ "#CC33FF",
408
+ "#CC6600",
409
+ "#CC6633",
410
+ "#CC9900",
411
+ "#CC9933",
412
+ "#CCCC00",
413
+ "#CCCC33",
414
+ "#FF0000",
415
+ "#FF0033",
416
+ "#FF0066",
417
+ "#FF0099",
418
+ "#FF00CC",
419
+ "#FF00FF",
420
+ "#FF3300",
421
+ "#FF3333",
422
+ "#FF3366",
423
+ "#FF3399",
424
+ "#FF33CC",
425
+ "#FF33FF",
426
+ "#FF6600",
427
+ "#FF6633",
428
+ "#FF9900",
429
+ "#FF9933",
430
+ "#FFCC00",
431
+ "#FFCC33"
432
+ ];
433
+ function useColors() {
434
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
435
+ return true;
436
+ }
437
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
438
+ return false;
439
+ }
440
+ let m;
441
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
442
+ typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
443
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
444
+ typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
445
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
446
+ }
447
+ function formatArgs(args) {
448
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
449
+ if (!this.useColors) {
450
+ return;
451
+ }
452
+ const c = "color: " + this.color;
453
+ args.splice(1, 0, c, "color: inherit");
454
+ let index = 0;
455
+ let lastC = 0;
456
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
457
+ if (match === "%%") {
458
+ return;
459
+ }
460
+ index++;
461
+ if (match === "%c") {
462
+ lastC = index;
463
+ }
464
+ });
465
+ args.splice(lastC, 0, c);
466
+ }
467
+ exports.log = console.debug || console.log || (() => {
468
+ });
469
+ function save(namespaces) {
470
+ try {
471
+ if (namespaces) {
472
+ exports.storage.setItem("debug", namespaces);
473
+ } else {
474
+ exports.storage.removeItem("debug");
475
+ }
476
+ } catch (error) {
477
+ }
478
+ }
479
+ function load2() {
480
+ let r;
481
+ try {
482
+ r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
483
+ } catch (error) {
484
+ }
485
+ if (!r && typeof process !== "undefined" && "env" in process) {
486
+ r = process.env.DEBUG;
487
+ }
488
+ return r;
489
+ }
490
+ function localstorage() {
491
+ try {
492
+ return localStorage;
493
+ } catch (error) {
494
+ }
495
+ }
496
+ module.exports = require_common()(exports);
497
+ var { formatters } = module.exports;
498
+ formatters.j = function(v) {
499
+ try {
500
+ return JSON.stringify(v);
501
+ } catch (error) {
502
+ return "[UnexpectedJSONParseError]: " + error.message;
503
+ }
504
+ };
505
+ }
506
+ });
507
+
508
+ // node_modules/has-flag/index.js
509
+ var require_has_flag = __commonJS({
510
+ "node_modules/has-flag/index.js"(exports, module) {
511
+ "use strict";
512
+ module.exports = (flag, argv = process.argv) => {
513
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
514
+ const position = argv.indexOf(prefix + flag);
515
+ const terminatorPosition = argv.indexOf("--");
516
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
517
+ };
518
+ }
519
+ });
520
+
521
+ // node_modules/supports-color/index.js
522
+ var require_supports_color = __commonJS({
523
+ "node_modules/supports-color/index.js"(exports, module) {
524
+ "use strict";
525
+ var os2 = __require("os");
526
+ var tty = __require("tty");
527
+ var hasFlag = require_has_flag();
528
+ var { env } = process;
529
+ var forceColor;
530
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
531
+ forceColor = 0;
532
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
533
+ forceColor = 1;
534
+ }
535
+ if ("FORCE_COLOR" in env) {
536
+ if (env.FORCE_COLOR === "true") {
537
+ forceColor = 1;
538
+ } else if (env.FORCE_COLOR === "false") {
539
+ forceColor = 0;
540
+ } else {
541
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
542
+ }
543
+ }
544
+ function translateLevel(level) {
545
+ if (level === 0) {
546
+ return false;
547
+ }
548
+ return {
549
+ level,
550
+ hasBasic: true,
551
+ has256: level >= 2,
552
+ has16m: level >= 3
553
+ };
554
+ }
555
+ function supportsColor(haveStream, streamIsTTY) {
556
+ if (forceColor === 0) {
557
+ return 0;
558
+ }
559
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
560
+ return 3;
561
+ }
562
+ if (hasFlag("color=256")) {
563
+ return 2;
564
+ }
565
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
566
+ return 0;
567
+ }
568
+ const min = forceColor || 0;
569
+ if (env.TERM === "dumb") {
570
+ return min;
571
+ }
572
+ if (process.platform === "win32") {
573
+ const osRelease = os2.release().split(".");
574
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
575
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
576
+ }
577
+ return 1;
578
+ }
579
+ if ("CI" in env) {
580
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
581
+ return 1;
582
+ }
583
+ return min;
584
+ }
585
+ if ("TEAMCITY_VERSION" in env) {
586
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
587
+ }
588
+ if (env.COLORTERM === "truecolor") {
589
+ return 3;
590
+ }
591
+ if ("TERM_PROGRAM" in env) {
592
+ const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
593
+ switch (env.TERM_PROGRAM) {
594
+ case "iTerm.app":
595
+ return version >= 3 ? 3 : 2;
596
+ case "Apple_Terminal":
597
+ return 2;
598
+ }
599
+ }
600
+ if (/-256(color)?$/i.test(env.TERM)) {
601
+ return 2;
602
+ }
603
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
604
+ return 1;
605
+ }
606
+ if ("COLORTERM" in env) {
607
+ return 1;
608
+ }
609
+ return min;
610
+ }
611
+ function getSupportLevel(stream) {
612
+ const level = supportsColor(stream, stream && stream.isTTY);
613
+ return translateLevel(level);
614
+ }
615
+ module.exports = {
616
+ supportsColor: getSupportLevel,
617
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
618
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
619
+ };
620
+ }
621
+ });
622
+
623
+ // node_modules/debug/src/node.js
624
+ var require_node = __commonJS({
625
+ "node_modules/debug/src/node.js"(exports, module) {
626
+ "use strict";
627
+ var tty = __require("tty");
628
+ var util = __require("util");
629
+ exports.init = init;
630
+ exports.log = log;
631
+ exports.formatArgs = formatArgs;
632
+ exports.save = save;
633
+ exports.load = load2;
634
+ exports.useColors = useColors;
635
+ exports.destroy = util.deprecate(
636
+ () => {
637
+ },
638
+ "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
639
+ );
640
+ exports.colors = [6, 2, 3, 4, 5, 1];
641
+ try {
642
+ const supportsColor = require_supports_color();
643
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
644
+ exports.colors = [
645
+ 20,
646
+ 21,
647
+ 26,
648
+ 27,
649
+ 32,
650
+ 33,
651
+ 38,
652
+ 39,
653
+ 40,
654
+ 41,
655
+ 42,
656
+ 43,
657
+ 44,
658
+ 45,
659
+ 56,
660
+ 57,
661
+ 62,
662
+ 63,
663
+ 68,
664
+ 69,
665
+ 74,
666
+ 75,
667
+ 76,
668
+ 77,
669
+ 78,
670
+ 79,
671
+ 80,
672
+ 81,
673
+ 92,
674
+ 93,
675
+ 98,
676
+ 99,
677
+ 112,
678
+ 113,
679
+ 128,
680
+ 129,
681
+ 134,
682
+ 135,
683
+ 148,
684
+ 149,
685
+ 160,
686
+ 161,
687
+ 162,
688
+ 163,
689
+ 164,
690
+ 165,
691
+ 166,
692
+ 167,
693
+ 168,
694
+ 169,
695
+ 170,
696
+ 171,
697
+ 172,
698
+ 173,
699
+ 178,
700
+ 179,
701
+ 184,
702
+ 185,
703
+ 196,
704
+ 197,
705
+ 198,
706
+ 199,
707
+ 200,
708
+ 201,
709
+ 202,
710
+ 203,
711
+ 204,
712
+ 205,
713
+ 206,
714
+ 207,
715
+ 208,
716
+ 209,
717
+ 214,
718
+ 215,
719
+ 220,
720
+ 221
721
+ ];
722
+ }
723
+ } catch (error) {
724
+ }
725
+ exports.inspectOpts = Object.keys(process.env).filter((key) => {
726
+ return /^debug_/i.test(key);
727
+ }).reduce((obj, key) => {
728
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
729
+ return k.toUpperCase();
730
+ });
731
+ let val = process.env[key];
732
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
733
+ val = true;
734
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
735
+ val = false;
736
+ } else if (val === "null") {
737
+ val = null;
738
+ } else {
739
+ val = Number(val);
740
+ }
741
+ obj[prop] = val;
742
+ return obj;
743
+ }, {});
744
+ function useColors() {
745
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
746
+ }
747
+ function formatArgs(args) {
748
+ const { namespace: name, useColors: useColors2 } = this;
749
+ if (useColors2) {
750
+ const c = this.color;
751
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
752
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
753
+ args[0] = prefix + args[0].split("\n").join("\n" + prefix);
754
+ args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
755
+ } else {
756
+ args[0] = getDate() + name + " " + args[0];
757
+ }
758
+ }
759
+ function getDate() {
760
+ if (exports.inspectOpts.hideDate) {
761
+ return "";
762
+ }
763
+ return (/* @__PURE__ */ new Date()).toISOString() + " ";
764
+ }
765
+ function log(...args) {
766
+ return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
767
+ }
768
+ function save(namespaces) {
769
+ if (namespaces) {
770
+ process.env.DEBUG = namespaces;
771
+ } else {
772
+ delete process.env.DEBUG;
773
+ }
774
+ }
775
+ function load2() {
776
+ return process.env.DEBUG;
777
+ }
778
+ function init(debug3) {
779
+ debug3.inspectOpts = {};
780
+ const keys = Object.keys(exports.inspectOpts);
781
+ for (let i = 0; i < keys.length; i++) {
782
+ debug3.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
783
+ }
784
+ }
785
+ module.exports = require_common()(exports);
786
+ var { formatters } = module.exports;
787
+ formatters.o = function(v) {
788
+ this.inspectOpts.colors = this.useColors;
789
+ return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
790
+ };
791
+ formatters.O = function(v) {
792
+ this.inspectOpts.colors = this.useColors;
793
+ return util.inspect(v, this.inspectOpts);
794
+ };
795
+ }
796
+ });
797
+
798
+ // node_modules/debug/src/index.js
799
+ var require_src = __commonJS({
800
+ "node_modules/debug/src/index.js"(exports, module) {
801
+ "use strict";
802
+ if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
803
+ module.exports = require_browser();
804
+ } else {
805
+ module.exports = require_node();
806
+ }
807
+ }
808
+ });
809
+
810
+ // node_modules/playwright-extra/dist/index.esm.js
811
+ var index_esm_exports = {};
812
+ __export(index_esm_exports, {
813
+ PlaywrightExtra: () => PlaywrightExtra,
814
+ PlaywrightExtraClass: () => PlaywrightExtraClass,
815
+ PluginList: () => PluginList,
816
+ _android: () => _android,
817
+ _electron: () => _electron,
818
+ addExtra: () => addExtra,
819
+ chromium: () => chromium,
820
+ default: () => index_esm_default,
821
+ devices: () => devices,
822
+ errors: () => errors,
823
+ firefox: () => firefox,
824
+ request: () => request,
825
+ selectors: () => selectors,
826
+ webkit: () => webkit
827
+ });
828
+ function requirePackages(packageNames) {
829
+ for (const name of packageNames) {
830
+ try {
831
+ return __require(name);
832
+ } catch (_) {
833
+ continue;
834
+ }
835
+ }
836
+ return;
837
+ }
838
+ function addPuppeteerCompat(object) {
839
+ if (!object || typeof object !== "object") {
840
+ return object;
841
+ }
842
+ if (cache.objectToShim.has(object)) {
843
+ return cache.objectToShim.get(object);
844
+ }
845
+ if (isPuppeteerCompat(object)) {
846
+ return object;
847
+ }
848
+ debug("addPuppeteerCompat", cache.objectToShim.size);
849
+ if (isPlaywrightPage(object) || isPlaywrightFrame(object)) {
850
+ const shim = createPageShim(object);
851
+ cache.objectToShim.set(object, shim);
852
+ return shim;
853
+ }
854
+ if (isPlaywrightBrowser(object)) {
855
+ const shim = createBrowserShim(object);
856
+ cache.objectToShim.set(object, shim);
857
+ return shim;
858
+ }
859
+ debug("Received unknown object:", Reflect.ownKeys(object));
860
+ return object;
861
+ }
862
+ async function getPageCDPSession(page) {
863
+ let session = cache.cdpSession.page.get(page);
864
+ if (session) {
865
+ debug("getPageCDPSession: use existing");
866
+ return session;
867
+ }
868
+ debug("getPageCDPSession: use new");
869
+ const context = isPlaywrightFrame(page) ? page.page().context() : page.context();
870
+ try {
871
+ session = await context.newCDPSession(page);
872
+ cache.cdpSession.page.set(page, session);
873
+ return session;
874
+ } catch (err) {
875
+ debug("getPageCDPSession: error while creating session:", err.message);
876
+ debug("getPageCDPSession: Unable create CDP session (most likely a different browser than chromium) - returning a dummy");
877
+ }
878
+ return dummyCDPClient;
879
+ }
880
+ async function getBrowserCDPSession(browser) {
881
+ let session = cache.cdpSession.browser.get(browser);
882
+ if (session) {
883
+ debug("getBrowserCDPSession: use existing");
884
+ return session;
885
+ }
886
+ debug("getBrowserCDPSession: use new");
887
+ try {
888
+ session = await browser.newBrowserCDPSession();
889
+ cache.cdpSession.browser.set(browser, session);
890
+ return session;
891
+ } catch (err) {
892
+ debug("getBrowserCDPSession: error while creating session:", err.message);
893
+ debug("getBrowserCDPSession: Unable create CDP session (most likely a different browser than chromium) - returning a dummy");
894
+ }
895
+ return dummyCDPClient;
896
+ }
897
+ function createPageShim(page) {
898
+ const objId = Math.random().toString(36).substring(2, 7);
899
+ const shim = new Proxy(page, {
900
+ get(target, prop) {
901
+ if (prop === "isCompatShim" || prop === "isPlaywright") {
902
+ return true;
903
+ }
904
+ debug("page - get", objId, prop);
905
+ if (prop === "_client") {
906
+ return () => ({
907
+ send: async (method, params) => {
908
+ const session = await getPageCDPSession(page);
909
+ return await session.send(method, params);
910
+ },
911
+ on: (event, listener) => {
912
+ getPageCDPSession(page).then((session) => {
913
+ session.on(event, listener);
914
+ });
915
+ }
916
+ });
917
+ }
918
+ if (prop === "setBypassCSP") {
919
+ return async (enabled) => {
920
+ const session = await getPageCDPSession(page);
921
+ return await session.send("Page.setBypassCSP", {
922
+ enabled
923
+ });
924
+ };
925
+ }
926
+ if (prop === "setUserAgent") {
927
+ return async (userAgent, userAgentMetadata) => {
928
+ const session = await getPageCDPSession(page);
929
+ return await session.send("Emulation.setUserAgentOverride", {
930
+ userAgent,
931
+ userAgentMetadata
932
+ });
933
+ };
934
+ }
935
+ if (prop === "browser") {
936
+ if (isPlaywrightPage(page)) {
937
+ return () => {
938
+ let browser = page.context().browser();
939
+ if (!browser) {
940
+ debug("page.browser() - not available, most likely due to launchPersistentContext");
941
+ browser = page;
942
+ }
943
+ return addPuppeteerCompat(browser);
944
+ };
945
+ }
946
+ }
947
+ if (prop === "evaluateOnNewDocument") {
948
+ if (isPlaywrightPage(page)) {
949
+ return async function(pageFunction, ...args) {
950
+ return await page.addInitScript(pageFunction, args[0]);
951
+ };
952
+ }
953
+ }
954
+ if (prop === "userAgent") {
955
+ return async (enabled) => {
956
+ const session = await getPageCDPSession(page);
957
+ const data = await session.send("Browser.getVersion");
958
+ return data.userAgent;
959
+ };
960
+ }
961
+ return Reflect.get(target, prop);
962
+ }
963
+ });
964
+ return shim;
965
+ }
966
+ function createBrowserShim(browser) {
967
+ const objId = Math.random().toString(36).substring(2, 7);
968
+ const shim = new Proxy(browser, {
969
+ get(target, prop) {
970
+ if (prop === "isCompatShim" || prop === "isPlaywright") {
971
+ return true;
972
+ }
973
+ debug("browser - get", objId, prop);
974
+ if (prop === "pages") {
975
+ return () => browser.contexts().flatMap((c) => c.pages().map((page) => addPuppeteerCompat(page)));
976
+ }
977
+ if (prop === "userAgent") {
978
+ return async () => {
979
+ const session = await getBrowserCDPSession(browser);
980
+ const data = await session.send("Browser.getVersion");
981
+ return data.userAgent;
982
+ };
983
+ }
984
+ return Reflect.get(target, prop);
985
+ }
986
+ });
987
+ return shim;
988
+ }
989
+ var import_debug, Loader, playwrightLoader, debug, isPlaywrightPage, isPlaywrightFrame, isPlaywrightBrowser, isPuppeteerCompat, cache, dummyCDPClient, debug$1, PluginList, debug$2, PlaywrightExtraClass, PlaywrightExtra, addExtra, chromium, firefox, webkit, _android, _electron, request, selectors, devices, errors, moduleExports, index_esm_default;
990
+ var init_index_esm = __esm({
991
+ "node_modules/playwright-extra/dist/index.esm.js"() {
992
+ "use strict";
993
+ import_debug = __toESM(require_src());
994
+ Loader = class {
995
+ constructor(moduleName, packageNames) {
996
+ this.moduleName = moduleName;
997
+ this.packageNames = packageNames;
998
+ }
999
+ /**
1000
+ * Lazy load a top level export from another module by wrapping it in a JS proxy.
1001
+ *
1002
+ * This allows us to re-export e.g. `devices` from `playwright` while redirecting direct calls
1003
+ * to it to the module version the user has installed, rather than shipping with a hardcoded version.
1004
+ *
1005
+ * If we don't do this and the user doesn't have the target module installed we'd throw immediately when our code is imported.
1006
+ *
1007
+ * We use a "super" Proxy defining all traps, so calls like `Object.keys(playwright.devices).length` will return the correct value.
1008
+ */
1009
+ lazyloadExportOrDie(exportName) {
1010
+ const that = this;
1011
+ const trapHandler = Object.fromEntries(Object.getOwnPropertyNames(Reflect).map((name) => [
1012
+ name,
1013
+ function(target, ...args) {
1014
+ const moduleExport = that.loadModuleOrDie()[exportName];
1015
+ const customTarget = moduleExport;
1016
+ const result = Reflect[name](customTarget || target, ...args);
1017
+ return result;
1018
+ }
1019
+ ]));
1020
+ return new Proxy({}, trapHandler);
1021
+ }
1022
+ /** Load the module if possible */
1023
+ loadModule() {
1024
+ return requirePackages(this.packageNames);
1025
+ }
1026
+ /** Load the module if possible or throw */
1027
+ loadModuleOrDie() {
1028
+ const module = requirePackages(this.packageNames);
1029
+ if (module) {
1030
+ return module;
1031
+ }
1032
+ throw this.requireError;
1033
+ }
1034
+ get requireError() {
1035
+ const moduleNamePretty = this.moduleName.charAt(0).toUpperCase() + this.moduleName.slice(1);
1036
+ return new Error(`
1037
+ ${moduleNamePretty} is missing. :-)
1038
+
1039
+ I've tried loading ${this.packageNames.map((p) => `"${p}"`).join(", ")} - no luck.
1040
+
1041
+ Make sure you install one of those packages or use the named 'addExtra' export,
1042
+ to patch a specific (and maybe non-standard) implementation of ${moduleNamePretty}.
1043
+
1044
+ To get the latest stable version of ${moduleNamePretty} run:
1045
+ 'yarn add ${this.moduleName}' or 'npm i ${this.moduleName}'
1046
+ `);
1047
+ }
1048
+ };
1049
+ playwrightLoader = new Loader("playwright", [
1050
+ "playwright-core",
1051
+ "playwright"
1052
+ ]);
1053
+ debug = (0, import_debug.default)("playwright-extra:puppeteer-compat");
1054
+ isPlaywrightPage = (obj) => {
1055
+ return "unroute" in obj;
1056
+ };
1057
+ isPlaywrightFrame = (obj) => {
1058
+ return ["parentFrame", "frameLocator"].every((x) => x in obj);
1059
+ };
1060
+ isPlaywrightBrowser = (obj) => {
1061
+ return "newContext" in obj;
1062
+ };
1063
+ isPuppeteerCompat = (obj) => {
1064
+ return !!obj && typeof obj === "object" && !!obj.isCompatShim;
1065
+ };
1066
+ cache = {
1067
+ objectToShim: /* @__PURE__ */ new Map(),
1068
+ cdpSession: {
1069
+ page: /* @__PURE__ */ new Map(),
1070
+ browser: /* @__PURE__ */ new Map()
1071
+ }
1072
+ };
1073
+ dummyCDPClient = {
1074
+ send: async (...args) => {
1075
+ debug("dummy CDP client called", "send", args);
1076
+ },
1077
+ on: (...args) => {
1078
+ debug("dummy CDP client called", "on", args);
1079
+ }
1080
+ };
1081
+ debug$1 = (0, import_debug.default)("playwright-extra:plugins");
1082
+ PluginList = class {
1083
+ constructor() {
1084
+ this._plugins = [];
1085
+ this._dependencyDefaults = /* @__PURE__ */ new Map();
1086
+ this._dependencyResolution = /* @__PURE__ */ new Map();
1087
+ }
1088
+ /**
1089
+ * Get a list of all registered plugins.
1090
+ */
1091
+ get list() {
1092
+ return this._plugins;
1093
+ }
1094
+ /**
1095
+ * Get the names of all registered plugins.
1096
+ */
1097
+ get names() {
1098
+ return this._plugins.map((p) => p.name);
1099
+ }
1100
+ /**
1101
+ * Add a new plugin to the list (after checking if it's well-formed).
1102
+ *
1103
+ * @param plugin
1104
+ * @internal
1105
+ */
1106
+ add(plugin) {
1107
+ var _a;
1108
+ if (!this.isValidPluginInstance(plugin)) {
1109
+ return false;
1110
+ }
1111
+ if (!!plugin.onPluginRegistered) {
1112
+ plugin.onPluginRegistered({ framework: "playwright" });
1113
+ }
1114
+ if (!!plugin._registerChildClassMembers) {
1115
+ plugin._registerChildClassMembers(Object.getPrototypeOf(plugin));
1116
+ }
1117
+ if ((_a = plugin.requirements) === null || _a === void 0 ? void 0 : _a.has("dataFromPlugins")) {
1118
+ plugin.getDataFromPlugins = this.getData.bind(this);
1119
+ }
1120
+ this._plugins.push(plugin);
1121
+ return true;
1122
+ }
1123
+ /** Check if the shape of a plugin is correct or warn */
1124
+ isValidPluginInstance(plugin) {
1125
+ if (!plugin || typeof plugin !== "object" || !plugin._isPuppeteerExtraPlugin) {
1126
+ console.error(`Warning: Plugin is not derived from PuppeteerExtraPlugin, ignoring.`, plugin);
1127
+ return false;
1128
+ }
1129
+ if (!plugin.name) {
1130
+ console.error(`Warning: Plugin with no name registering, ignoring.`, plugin);
1131
+ return false;
1132
+ }
1133
+ return true;
1134
+ }
1135
+ /** Error callback in case calling a plugin method throws an error. Can be overwritten. */
1136
+ onPluginError(plugin, method, err) {
1137
+ console.warn(`An error occured while executing "${method}" in plugin "${plugin.name}":`, err);
1138
+ }
1139
+ /**
1140
+ * Define default values for plugins implicitly required through the `dependencies` plugin stanza.
1141
+ *
1142
+ * @param dependencyPath - The string by which the dependency is listed (not the plugin name)
1143
+ *
1144
+ * @example
1145
+ * chromium.use(stealth)
1146
+ * chromium.plugins.setDependencyDefaults('stealth/evasions/webgl.vendor', { vendor: 'Bob', renderer: 'Alice' })
1147
+ */
1148
+ setDependencyDefaults(dependencyPath, opts) {
1149
+ this._dependencyDefaults.set(dependencyPath, opts);
1150
+ return this;
1151
+ }
1152
+ /**
1153
+ * Define custom plugin modules for plugins implicitly required through the `dependencies` plugin stanza.
1154
+ *
1155
+ * Using this will prevent dynamic imports from being used, which JS bundlers often have issues with.
1156
+ *
1157
+ * @example
1158
+ * chromium.use(stealth)
1159
+ * chromium.plugins.setDependencyResolution('stealth/evasions/webgl.vendor', VendorPlugin)
1160
+ */
1161
+ setDependencyResolution(dependencyPath, pluginModule) {
1162
+ this._dependencyResolution.set(dependencyPath, pluginModule);
1163
+ return this;
1164
+ }
1165
+ /**
1166
+ * Prepare plugins to be used (resolve dependencies, ordering)
1167
+ * @internal
1168
+ */
1169
+ prepare() {
1170
+ this.resolveDependencies();
1171
+ this.order();
1172
+ }
1173
+ /** Return all plugins using the supplied method */
1174
+ filterByMethod(methodName) {
1175
+ return this._plugins.filter((plugin) => {
1176
+ if (!!plugin._childClassMembers && Array.isArray(plugin._childClassMembers)) {
1177
+ return plugin._childClassMembers.includes(methodName);
1178
+ }
1179
+ return methodName in plugin;
1180
+ });
1181
+ }
1182
+ /** Conditionally add puppeteer compatibility to values provided to the plugins */
1183
+ _addPuppeteerCompatIfNeeded(plugin, method, args) {
1184
+ const canUseShim = plugin._isPuppeteerExtraPlugin && !plugin.noPuppeteerShim;
1185
+ const methodWhitelist = [
1186
+ "onBrowser",
1187
+ "onPageCreated",
1188
+ "onPageClose",
1189
+ "afterConnect",
1190
+ "afterLaunch"
1191
+ ];
1192
+ const shouldUseShim = methodWhitelist.includes(method);
1193
+ if (!canUseShim || !shouldUseShim) {
1194
+ return args;
1195
+ }
1196
+ debug$1("add puppeteer compatibility", plugin.name, method);
1197
+ return [...args.map((arg) => addPuppeteerCompat(arg))];
1198
+ }
1199
+ /**
1200
+ * Dispatch plugin lifecycle events in a typesafe way.
1201
+ * Only Plugins that expose the supplied property will be called.
1202
+ *
1203
+ * Will not await results to dispatch events as fast as possible to all plugins.
1204
+ *
1205
+ * @param method - The lifecycle method name
1206
+ * @param args - Optional: Any arguments to be supplied to the plugin methods
1207
+ * @internal
1208
+ */
1209
+ dispatch(method, ...args) {
1210
+ var _a, _b;
1211
+ const plugins = this.filterByMethod(method);
1212
+ debug$1("dispatch", method, {
1213
+ all: this._plugins.length,
1214
+ filteredByMethod: plugins.length
1215
+ });
1216
+ for (const plugin of plugins) {
1217
+ try {
1218
+ args = this._addPuppeteerCompatIfNeeded.bind(this)(plugin, method, args);
1219
+ const fnType = (_b = (_a = plugin[method]) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name;
1220
+ debug$1("dispatch to plugin", {
1221
+ plugin: plugin.name,
1222
+ method,
1223
+ fnType
1224
+ });
1225
+ if (fnType === "AsyncFunction") {
1226
+ ;
1227
+ plugin[method](...args).catch((err) => this.onPluginError(plugin, method, err));
1228
+ } else {
1229
+ ;
1230
+ plugin[method](...args);
1231
+ }
1232
+ } catch (err) {
1233
+ this.onPluginError(plugin, method, err);
1234
+ }
1235
+ }
1236
+ }
1237
+ /**
1238
+ * Dispatch plugin lifecycle events in a typesafe way.
1239
+ * Only Plugins that expose the supplied property will be called.
1240
+ *
1241
+ * Can also be used to get a definite return value after passing it to plugins:
1242
+ * Calls plugins sequentially and passes on a value (waterfall style).
1243
+ *
1244
+ * The plugins can either modify the value or return an updated one.
1245
+ * Will return the latest, updated value which ran through all plugins.
1246
+ *
1247
+ * By convention only the first argument will be used as the updated value.
1248
+ *
1249
+ * @param method - The lifecycle method name
1250
+ * @param args - Optional: Any arguments to be supplied to the plugin methods
1251
+ * @internal
1252
+ */
1253
+ async dispatchBlocking(method, ...args) {
1254
+ const plugins = this.filterByMethod(method);
1255
+ debug$1("dispatchBlocking", method, {
1256
+ all: this._plugins.length,
1257
+ filteredByMethod: plugins.length
1258
+ });
1259
+ let retValue = null;
1260
+ for (const plugin of plugins) {
1261
+ try {
1262
+ args = this._addPuppeteerCompatIfNeeded.bind(this)(plugin, method, args);
1263
+ retValue = await plugin[method](...args);
1264
+ if (retValue !== void 0) {
1265
+ args[0] = retValue;
1266
+ }
1267
+ } catch (err) {
1268
+ this.onPluginError(plugin, method, err);
1269
+ return retValue;
1270
+ }
1271
+ }
1272
+ return retValue;
1273
+ }
1274
+ /**
1275
+ * Order plugins that have expressed a special placement requirement.
1276
+ *
1277
+ * This is useful/necessary for e.g. plugins that depend on the data from other plugins.
1278
+ *
1279
+ * @private
1280
+ */
1281
+ order() {
1282
+ debug$1("order:before", this.names);
1283
+ const runLast = this._plugins.filter((p) => {
1284
+ var _a;
1285
+ return (_a = p.requirements) === null || _a === void 0 ? void 0 : _a.has("runLast");
1286
+ }).map((p) => p.name);
1287
+ for (const name of runLast) {
1288
+ const index = this._plugins.findIndex((p) => p.name === name);
1289
+ this._plugins.push(this._plugins.splice(index, 1)[0]);
1290
+ }
1291
+ debug$1("order:after", this.names);
1292
+ }
1293
+ /**
1294
+ * Collects the exposed `data` property of all registered plugins.
1295
+ * Will be reduced/flattened to a single array.
1296
+ *
1297
+ * Can be accessed by plugins that listed the `dataFromPlugins` requirement.
1298
+ *
1299
+ * Implemented mainly for plugins that need data from other plugins (e.g. `user-preferences`).
1300
+ *
1301
+ * @see [PuppeteerExtraPlugin]/data
1302
+ * @param name - Filter data by optional name
1303
+ *
1304
+ * @private
1305
+ */
1306
+ getData(name) {
1307
+ const data = this._plugins.filter((p) => !!p.data).map((p) => Array.isArray(p.data) ? p.data : [p.data]).reduce((acc, arr) => [...acc, ...arr], []);
1308
+ return name ? data.filter((d) => d.name === name) : data;
1309
+ }
1310
+ /**
1311
+ * Handle `plugins` stanza (already instantiated plugins that don't require dynamic imports)
1312
+ */
1313
+ resolvePluginsStanza() {
1314
+ debug$1("resolvePluginsStanza");
1315
+ const pluginNames = new Set(this.names);
1316
+ this._plugins.filter((p) => !!p.plugins && p.plugins.length).filter((p) => !pluginNames.has(p.name)).forEach((parent) => {
1317
+ (parent.plugins || []).forEach((p) => {
1318
+ debug$1(parent.name, "adding missing plugin", p.name);
1319
+ this.add(p);
1320
+ });
1321
+ });
1322
+ }
1323
+ /**
1324
+ * Handle `dependencies` stanza (which requires dynamic imports)
1325
+ *
1326
+ * Plugins can define `dependencies` as a Set or Array of dependency paths, or a Map with additional opts
1327
+ *
1328
+ * @note
1329
+ * - The default opts for implicit dependencies can be defined using `setDependencyDefaults()`
1330
+ * - Dynamic imports can be avoided by providing plugin modules with `setDependencyResolution()`
1331
+ */
1332
+ resolveDependenciesStanza() {
1333
+ debug$1("resolveDependenciesStanza");
1334
+ const requireDependencyOrDie = (parentName, dependencyPath) => {
1335
+ if (this._dependencyResolution.has(dependencyPath)) {
1336
+ return this._dependencyResolution.get(dependencyPath);
1337
+ }
1338
+ const possiblePrefixes = ["puppeteer-extra-plugin-"];
1339
+ const isAlreadyPrefixed = possiblePrefixes.some((prefix) => dependencyPath.startsWith(prefix));
1340
+ const packagePaths = [];
1341
+ if (!isAlreadyPrefixed) {
1342
+ packagePaths.push(...possiblePrefixes.map((prefix) => prefix + dependencyPath));
1343
+ }
1344
+ packagePaths.push(dependencyPath);
1345
+ const pluginModule = requirePackages(packagePaths);
1346
+ if (pluginModule) {
1347
+ return pluginModule;
1348
+ }
1349
+ const explanation = `
1350
+ The plugin '${parentName}' listed '${dependencyPath}' as dependency,
1351
+ which could not be found. Please install it:
1352
+
1353
+ ${packagePaths.map((packagePath) => `yarn add ${packagePath.split("/")[0]}`).join(`
1354
+ or:
1355
+ `)}
1356
+
1357
+ Note: You don't need to require the plugin yourself,
1358
+ unless you want to modify it's default settings.
1359
+
1360
+ If your bundler has issues with dynamic imports take a look at '.plugins.setDependencyResolution()'.
1361
+ `;
1362
+ console.warn(explanation);
1363
+ throw new Error("Plugin dependency not found");
1364
+ };
1365
+ const existingPluginNames = new Set(this.names);
1366
+ const recursivelyLoadMissingDependencies = ({ name: parentName, dependencies }) => {
1367
+ if (!dependencies) {
1368
+ return;
1369
+ }
1370
+ const processDependency = (dependencyPath, opts) => {
1371
+ const pluginModule = requireDependencyOrDie(parentName, dependencyPath);
1372
+ opts = opts || this._dependencyDefaults.get(dependencyPath) || {};
1373
+ const plugin = pluginModule(opts);
1374
+ if (existingPluginNames.has(plugin.name)) {
1375
+ debug$1(parentName, "=> dependency already exists:", plugin.name);
1376
+ return;
1377
+ }
1378
+ existingPluginNames.add(plugin.name);
1379
+ debug$1(parentName, "=> adding new dependency:", plugin.name, opts);
1380
+ this.add(plugin);
1381
+ return recursivelyLoadMissingDependencies(plugin);
1382
+ };
1383
+ if (dependencies instanceof Set || Array.isArray(dependencies)) {
1384
+ return [...dependencies].forEach((dependencyPath) => processDependency(dependencyPath));
1385
+ }
1386
+ if (dependencies instanceof Map) {
1387
+ return dependencies.forEach((v, k) => processDependency(k, v));
1388
+ }
1389
+ };
1390
+ this.list.forEach(recursivelyLoadMissingDependencies);
1391
+ }
1392
+ /**
1393
+ * Lightweight plugin dependency management to require plugins and code mods on demand.
1394
+ * @private
1395
+ */
1396
+ resolveDependencies() {
1397
+ debug$1("resolveDependencies");
1398
+ this.resolvePluginsStanza();
1399
+ this.resolveDependenciesStanza();
1400
+ }
1401
+ };
1402
+ debug$2 = (0, import_debug.default)("playwright-extra");
1403
+ PlaywrightExtraClass = class {
1404
+ constructor(_launcher) {
1405
+ this._launcher = _launcher;
1406
+ this.plugins = new PluginList();
1407
+ }
1408
+ /**
1409
+ * The **main interface** to register plugins.
1410
+ *
1411
+ * Can be called multiple times to enable multiple plugins.
1412
+ *
1413
+ * Plugins derived from `PuppeteerExtraPlugin` will be used with a compatiblity layer.
1414
+ *
1415
+ * @example
1416
+ * chromium.use(plugin1).use(plugin2)
1417
+ * firefox.use(plugin1).use(plugin2)
1418
+ *
1419
+ * @see [PuppeteerExtraPlugin]
1420
+ *
1421
+ * @return The same `PlaywrightExtra` instance (for optional chaining)
1422
+ */
1423
+ use(plugin) {
1424
+ const isValid = plugin && "name" in plugin;
1425
+ if (!isValid) {
1426
+ throw new Error("A plugin must be provided to .use()");
1427
+ }
1428
+ if (this.plugins.add(plugin)) {
1429
+ debug$2("Plugin registered", plugin.name);
1430
+ }
1431
+ return this;
1432
+ }
1433
+ /**
1434
+ * In order to support a default export which will require vanilla playwright automatically,
1435
+ * as well as `addExtra` to patch a provided launcher, we need to so some gymnastics here.
1436
+ *
1437
+ * Otherwise this would throw immediately, even when only using the `addExtra` export with an arbitrary compatible launcher.
1438
+ *
1439
+ * The solution is to make the vanilla launcher optional and only throw once we try to effectively use and can't find it.
1440
+ *
1441
+ * @internal
1442
+ */
1443
+ get launcher() {
1444
+ if (!this._launcher) {
1445
+ throw playwrightLoader.requireError;
1446
+ }
1447
+ return this._launcher;
1448
+ }
1449
+ async launch(...args) {
1450
+ if (!this.launcher.launch) {
1451
+ throw new Error('Launcher does not support "launch"');
1452
+ }
1453
+ let [options] = args;
1454
+ options = Object.assign({ args: [] }, options || {});
1455
+ debug$2("launch", options);
1456
+ this.plugins.prepare();
1457
+ options = await this.plugins.dispatchBlocking("beforeLaunch", options) || options;
1458
+ debug$2("launch with options", options);
1459
+ if ("userDataDir" in options) {
1460
+ debug$2("A plugin defined userDataDir during .launch, which isn't supported by playwright - ignoring");
1461
+ delete options.userDataDir;
1462
+ }
1463
+ const browser = await this.launcher["launch"](options);
1464
+ await this.plugins.dispatchBlocking("onBrowser", browser);
1465
+ await this._bindBrowserEvents(browser);
1466
+ await this.plugins.dispatchBlocking("afterLaunch", browser);
1467
+ return browser;
1468
+ }
1469
+ async launchPersistentContext(...args) {
1470
+ if (!this.launcher.launchPersistentContext) {
1471
+ throw new Error('Launcher does not support "launchPersistentContext"');
1472
+ }
1473
+ let [userDataDir, options] = args;
1474
+ options = Object.assign({ args: [] }, options || {});
1475
+ debug$2("launchPersistentContext", options);
1476
+ this.plugins.prepare();
1477
+ options = await this.plugins.dispatchBlocking("beforeLaunch", options) || options;
1478
+ const context = await this.launcher["launchPersistentContext"](userDataDir, options);
1479
+ await this.plugins.dispatchBlocking("afterLaunch", context);
1480
+ this._bindBrowserContextEvents(context);
1481
+ return context;
1482
+ }
1483
+ async connect(wsEndpointOrOptions, wsOptions = {}) {
1484
+ if (!this.launcher.connect) {
1485
+ throw new Error('Launcher does not support "connect"');
1486
+ }
1487
+ this.plugins.prepare();
1488
+ let options = {};
1489
+ let wsEndpointAsString = false;
1490
+ if (typeof wsEndpointOrOptions === "object") {
1491
+ options = Object.assign(Object.assign({}, wsEndpointOrOptions), wsOptions);
1492
+ } else {
1493
+ wsEndpointAsString = true;
1494
+ options = Object.assign({ wsEndpoint: wsEndpointOrOptions }, wsOptions);
1495
+ }
1496
+ debug$2("connect", options);
1497
+ options = await this.plugins.dispatchBlocking("beforeConnect", options) || options;
1498
+ const args = [];
1499
+ const wsEndpoint = options.wsEndpoint;
1500
+ if (wsEndpointAsString) {
1501
+ delete options.wsEndpoint;
1502
+ args.push(wsEndpoint, options);
1503
+ } else {
1504
+ args.push(options);
1505
+ }
1506
+ const browser = await this.launcher["connect"](...args);
1507
+ await this.plugins.dispatchBlocking("onBrowser", browser);
1508
+ await this._bindBrowserEvents(browser);
1509
+ await this.plugins.dispatchBlocking("afterConnect", browser);
1510
+ return browser;
1511
+ }
1512
+ async connectOverCDP(wsEndpointOrOptions, wsOptions = {}) {
1513
+ if (!this.launcher.connectOverCDP) {
1514
+ throw new Error(`Launcher does not implement 'connectOverCDP'`);
1515
+ }
1516
+ this.plugins.prepare();
1517
+ let options = {};
1518
+ let wsEndpointAsString = false;
1519
+ if (typeof wsEndpointOrOptions === "object") {
1520
+ options = Object.assign(Object.assign({}, wsEndpointOrOptions), wsOptions);
1521
+ } else {
1522
+ wsEndpointAsString = true;
1523
+ options = Object.assign({ endpointURL: wsEndpointOrOptions }, wsOptions);
1524
+ }
1525
+ debug$2("connectOverCDP"), options;
1526
+ options = await this.plugins.dispatchBlocking("beforeConnect", options) || options;
1527
+ const args = [];
1528
+ const endpointURL = options.endpointURL;
1529
+ if (wsEndpointAsString) {
1530
+ delete options.endpointURL;
1531
+ args.push(endpointURL, options);
1532
+ } else {
1533
+ args.push(options);
1534
+ }
1535
+ const browser = await this.launcher["connectOverCDP"](...args);
1536
+ await this.plugins.dispatchBlocking("onBrowser", browser);
1537
+ await this._bindBrowserEvents(browser);
1538
+ await this.plugins.dispatchBlocking("afterConnect", browser);
1539
+ return browser;
1540
+ }
1541
+ async _bindBrowserContextEvents(context, contextOptions) {
1542
+ debug$2("_bindBrowserContextEvents");
1543
+ this.plugins.dispatch("onContextCreated", context, contextOptions);
1544
+ context.newPage = /* @__PURE__ */ ((originalMethod, ctx) => {
1545
+ return async () => {
1546
+ const page = await originalMethod.call(ctx);
1547
+ await page.goto("about:blank");
1548
+ return page;
1549
+ };
1550
+ })(context.newPage, context);
1551
+ context.on("close", () => {
1552
+ if (!context.browser()) {
1553
+ this.plugins.dispatch("onDisconnected");
1554
+ }
1555
+ });
1556
+ context.on("page", (page) => {
1557
+ this.plugins.dispatch("onPageCreated", page);
1558
+ page.on("close", () => {
1559
+ this.plugins.dispatch("onPageClose", page);
1560
+ });
1561
+ });
1562
+ }
1563
+ async _bindBrowserEvents(browser) {
1564
+ debug$2("_bindPlaywrightBrowserEvents");
1565
+ browser.on("disconnected", () => {
1566
+ this.plugins.dispatch("onDisconnected", browser);
1567
+ });
1568
+ browser.newContext = /* @__PURE__ */ ((originalMethod, ctx) => {
1569
+ return async (options = {}) => {
1570
+ const contextOptions = await this.plugins.dispatchBlocking("beforeContext", options, browser) || options;
1571
+ const context = await originalMethod.call(ctx, contextOptions);
1572
+ this._bindBrowserContextEvents(context, contextOptions);
1573
+ return context;
1574
+ };
1575
+ })(browser.newContext, browser);
1576
+ }
1577
+ };
1578
+ PlaywrightExtra = new Proxy(PlaywrightExtraClass, {
1579
+ construct(classTarget, args) {
1580
+ debug$2(`create instance of ${classTarget.name}`);
1581
+ const result = Reflect.construct(classTarget, args);
1582
+ return new Proxy(result, {
1583
+ get(target, prop) {
1584
+ if (prop in target) {
1585
+ return Reflect.get(target, prop);
1586
+ }
1587
+ debug$2("proxying property to original launcher: ", prop);
1588
+ return Reflect.get(target.launcher, prop);
1589
+ }
1590
+ });
1591
+ }
1592
+ });
1593
+ addExtra = (launcher) => new PlaywrightExtra(launcher);
1594
+ chromium = addExtra((playwrightLoader.loadModule() || {}).chromium);
1595
+ firefox = addExtra((playwrightLoader.loadModule() || {}).firefox);
1596
+ webkit = addExtra((playwrightLoader.loadModule() || {}).webkit);
1597
+ _android = playwrightLoader.lazyloadExportOrDie("_android");
1598
+ _electron = playwrightLoader.lazyloadExportOrDie("_electron");
1599
+ request = playwrightLoader.lazyloadExportOrDie("request");
1600
+ selectors = playwrightLoader.lazyloadExportOrDie("selectors");
1601
+ devices = playwrightLoader.lazyloadExportOrDie("devices");
1602
+ errors = playwrightLoader.lazyloadExportOrDie("errors");
1603
+ moduleExports = {
1604
+ // custom exports
1605
+ PlaywrightExtra,
1606
+ PlaywrightExtraClass,
1607
+ PluginList,
1608
+ addExtra,
1609
+ chromium,
1610
+ firefox,
1611
+ webkit,
1612
+ // vanilla exports
1613
+ _android,
1614
+ _electron,
1615
+ request,
1616
+ selectors,
1617
+ devices,
1618
+ errors
1619
+ };
1620
+ index_esm_default = moduleExports;
1621
+ }
1622
+ });
1623
+
1624
+ // node_modules/arr-union/index.js
1625
+ var require_arr_union = __commonJS({
1626
+ "node_modules/arr-union/index.js"(exports, module) {
1627
+ "use strict";
1628
+ module.exports = function union(init) {
1629
+ if (!Array.isArray(init)) {
1630
+ throw new TypeError("arr-union expects the first argument to be an array.");
1631
+ }
1632
+ var len = arguments.length;
1633
+ var i = 0;
1634
+ while (++i < len) {
1635
+ var arg = arguments[i];
1636
+ if (!arg) continue;
1637
+ if (!Array.isArray(arg)) {
1638
+ arg = [arg];
1639
+ }
1640
+ for (var j = 0; j < arg.length; j++) {
1641
+ var ele = arg[j];
1642
+ if (init.indexOf(ele) >= 0) {
1643
+ continue;
1644
+ }
1645
+ init.push(ele);
1646
+ }
1647
+ }
1648
+ return init;
1649
+ };
1650
+ }
1651
+ });
1652
+
1653
+ // node_modules/lazy-cache/index.js
1654
+ var require_lazy_cache = __commonJS({
1655
+ "node_modules/lazy-cache/index.js"(exports, module) {
1656
+ "use strict";
1657
+ function lazyCache(fn) {
1658
+ var cache2 = {};
1659
+ var proxy = function(mod, name) {
1660
+ name = name || camelcase(mod);
1661
+ if (process.env.UNLAZY === "true" || process.env.UNLAZY === true || process.env.TRAVIS) {
1662
+ cache2[name] = fn(mod);
1663
+ }
1664
+ Object.defineProperty(proxy, name, {
1665
+ enumerable: true,
1666
+ configurable: true,
1667
+ get: getter
1668
+ });
1669
+ function getter() {
1670
+ if (cache2.hasOwnProperty(name)) {
1671
+ return cache2[name];
1672
+ }
1673
+ return cache2[name] = fn(mod);
1674
+ }
1675
+ return getter;
1676
+ };
1677
+ return proxy;
1678
+ }
1679
+ function camelcase(str) {
1680
+ if (str.length === 1) {
1681
+ return str.toLowerCase();
1682
+ }
1683
+ str = str.replace(/^[\W_]+|[\W_]+$/g, "").toLowerCase();
1684
+ return str.replace(/[\W_]+(\w|$)/g, function(_, ch) {
1685
+ return ch.toUpperCase();
1686
+ });
1687
+ }
1688
+ module.exports = lazyCache;
1689
+ }
1690
+ });
1691
+
1692
+ // node_modules/for-in/index.js
1693
+ var require_for_in = __commonJS({
1694
+ "node_modules/for-in/index.js"(exports, module) {
1695
+ "use strict";
1696
+ module.exports = function forIn(obj, fn, thisArg) {
1697
+ for (var key in obj) {
1698
+ if (fn.call(thisArg, obj[key], key, obj) === false) {
1699
+ break;
1700
+ }
1701
+ }
1702
+ };
1703
+ }
1704
+ });
1705
+
1706
+ // node_modules/for-own/index.js
1707
+ var require_for_own = __commonJS({
1708
+ "node_modules/for-own/index.js"(exports, module) {
1709
+ "use strict";
1710
+ var forIn = require_for_in();
1711
+ var hasOwn = Object.prototype.hasOwnProperty;
1712
+ module.exports = function forOwn(obj, fn, thisArg) {
1713
+ forIn(obj, function(val, key) {
1714
+ if (hasOwn.call(obj, key)) {
1715
+ return fn.call(thisArg, obj[key], key, obj);
1716
+ }
1717
+ });
1718
+ };
1719
+ }
1720
+ });
1721
+
1722
+ // node_modules/clone-deep/utils.js
1723
+ var require_utils = __commonJS({
1724
+ "node_modules/clone-deep/utils.js"(exports, module) {
1725
+ "use strict";
1726
+ var utils = require_lazy_cache()(__require);
1727
+ var fn = __require;
1728
+ __require = utils;
1729
+ __require("is-plain-object", "isObject");
1730
+ __require("shallow-clone", "clone");
1731
+ __require("kind-of", "typeOf");
1732
+ require_for_own();
1733
+ __require = fn;
1734
+ module.exports = utils;
1735
+ }
1736
+ });
1737
+
1738
+ // node_modules/clone-deep/index.js
1739
+ var require_clone_deep = __commonJS({
1740
+ "node_modules/clone-deep/index.js"(exports, module) {
1741
+ "use strict";
1742
+ var utils = require_utils();
1743
+ function cloneDeep(val, instanceClone) {
1744
+ switch (utils.typeOf(val)) {
1745
+ case "object":
1746
+ return cloneObjectDeep(val, instanceClone);
1747
+ case "array":
1748
+ return cloneArrayDeep(val, instanceClone);
1749
+ default:
1750
+ return utils.clone(val);
1751
+ }
1752
+ }
1753
+ function cloneObjectDeep(obj, instanceClone) {
1754
+ if (utils.isObject(obj)) {
1755
+ var res = {};
1756
+ utils.forOwn(obj, function(obj2, key) {
1757
+ this[key] = cloneDeep(obj2, instanceClone);
1758
+ }, res);
1759
+ return res;
1760
+ } else if (instanceClone) {
1761
+ return instanceClone(obj);
1762
+ } else {
1763
+ return obj;
1764
+ }
1765
+ }
1766
+ function cloneArrayDeep(arr, instanceClone) {
1767
+ var len = arr.length, res = [];
1768
+ var i = -1;
1769
+ while (++i < len) {
1770
+ res[i] = cloneDeep(arr[i], instanceClone);
1771
+ }
1772
+ return res;
1773
+ }
1774
+ module.exports = cloneDeep;
1775
+ }
1776
+ });
1777
+
1778
+ // node_modules/is-buffer/index.js
1779
+ var require_is_buffer = __commonJS({
1780
+ "node_modules/is-buffer/index.js"(exports, module) {
1781
+ "use strict";
1782
+ module.exports = function(obj) {
1783
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer);
1784
+ };
1785
+ function isBuffer(obj) {
1786
+ return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
1787
+ }
1788
+ function isSlowBuffer(obj) {
1789
+ return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isBuffer(obj.slice(0, 0));
1790
+ }
1791
+ }
1792
+ });
1793
+
1794
+ // node_modules/kind-of/index.js
1795
+ var require_kind_of = __commonJS({
1796
+ "node_modules/kind-of/index.js"(exports, module) {
1797
+ "use strict";
1798
+ var isBuffer = require_is_buffer();
1799
+ var toString = Object.prototype.toString;
1800
+ module.exports = function kindOf(val) {
1801
+ if (typeof val === "undefined") {
1802
+ return "undefined";
1803
+ }
1804
+ if (val === null) {
1805
+ return "null";
1806
+ }
1807
+ if (val === true || val === false || val instanceof Boolean) {
1808
+ return "boolean";
1809
+ }
1810
+ if (typeof val === "string" || val instanceof String) {
1811
+ return "string";
1812
+ }
1813
+ if (typeof val === "number" || val instanceof Number) {
1814
+ return "number";
1815
+ }
1816
+ if (typeof val === "function" || val instanceof Function) {
1817
+ return "function";
1818
+ }
1819
+ if (typeof Array.isArray !== "undefined" && Array.isArray(val)) {
1820
+ return "array";
1821
+ }
1822
+ if (val instanceof RegExp) {
1823
+ return "regexp";
1824
+ }
1825
+ if (val instanceof Date) {
1826
+ return "date";
1827
+ }
1828
+ var type = toString.call(val);
1829
+ if (type === "[object RegExp]") {
1830
+ return "regexp";
1831
+ }
1832
+ if (type === "[object Date]") {
1833
+ return "date";
1834
+ }
1835
+ if (type === "[object Arguments]") {
1836
+ return "arguments";
1837
+ }
1838
+ if (type === "[object Error]") {
1839
+ return "error";
1840
+ }
1841
+ if (isBuffer(val)) {
1842
+ return "buffer";
1843
+ }
1844
+ if (type === "[object Set]") {
1845
+ return "set";
1846
+ }
1847
+ if (type === "[object WeakSet]") {
1848
+ return "weakset";
1849
+ }
1850
+ if (type === "[object Map]") {
1851
+ return "map";
1852
+ }
1853
+ if (type === "[object WeakMap]") {
1854
+ return "weakmap";
1855
+ }
1856
+ if (type === "[object Symbol]") {
1857
+ return "symbol";
1858
+ }
1859
+ if (type === "[object Int8Array]") {
1860
+ return "int8array";
1861
+ }
1862
+ if (type === "[object Uint8Array]") {
1863
+ return "uint8array";
1864
+ }
1865
+ if (type === "[object Uint8ClampedArray]") {
1866
+ return "uint8clampedarray";
1867
+ }
1868
+ if (type === "[object Int16Array]") {
1869
+ return "int16array";
1870
+ }
1871
+ if (type === "[object Uint16Array]") {
1872
+ return "uint16array";
1873
+ }
1874
+ if (type === "[object Int32Array]") {
1875
+ return "int32array";
1876
+ }
1877
+ if (type === "[object Uint32Array]") {
1878
+ return "uint32array";
1879
+ }
1880
+ if (type === "[object Float32Array]") {
1881
+ return "float32array";
1882
+ }
1883
+ if (type === "[object Float64Array]") {
1884
+ return "float64array";
1885
+ }
1886
+ return "object";
1887
+ };
1888
+ }
1889
+ });
1890
+
1891
+ // node_modules/merge-deep/index.js
1892
+ var require_merge_deep = __commonJS({
1893
+ "node_modules/merge-deep/index.js"(exports, module) {
1894
+ "use strict";
1895
+ var union = require_arr_union();
1896
+ var clone = require_clone_deep();
1897
+ var typeOf = require_kind_of();
1898
+ module.exports = function mergeDeep(orig, objects) {
1899
+ if (!isObject(orig) && !Array.isArray(orig)) {
1900
+ orig = {};
1901
+ }
1902
+ var target = clone(orig);
1903
+ var len = arguments.length;
1904
+ var idx = 0;
1905
+ while (++idx < len) {
1906
+ var val = arguments[idx];
1907
+ if (isObject(val) || Array.isArray(val)) {
1908
+ merge2(target, val);
1909
+ }
1910
+ }
1911
+ return target;
1912
+ };
1913
+ function merge2(target, obj) {
1914
+ for (var key in obj) {
1915
+ if (!isValidKey(key) || !hasOwn(obj, key)) {
1916
+ continue;
1917
+ }
1918
+ var oldVal = obj[key];
1919
+ var newVal = target[key];
1920
+ if (isObject(newVal) && isObject(oldVal)) {
1921
+ target[key] = merge2(newVal, oldVal);
1922
+ } else if (Array.isArray(newVal)) {
1923
+ target[key] = union([], newVal, oldVal);
1924
+ } else {
1925
+ target[key] = clone(oldVal);
1926
+ }
1927
+ }
1928
+ return target;
1929
+ }
1930
+ function hasOwn(obj, key) {
1931
+ return Object.prototype.hasOwnProperty.call(obj, key);
1932
+ }
1933
+ function isObject(val) {
1934
+ return typeOf(val) === "object" || typeOf(val) === "function";
1935
+ }
1936
+ function isValidKey(key) {
1937
+ return key !== "__proto__" && key !== "constructor" && key !== "prototype";
1938
+ }
1939
+ }
1940
+ });
1941
+
1942
+ // node_modules/puppeteer-extra-plugin/dist/index.esm.js
1943
+ var index_esm_exports2 = {};
1944
+ __export(index_esm_exports2, {
1945
+ PuppeteerExtraPlugin: () => PuppeteerExtraPlugin
1946
+ });
1947
+ var import_debug2, merge, PuppeteerExtraPlugin;
1948
+ var init_index_esm2 = __esm({
1949
+ "node_modules/puppeteer-extra-plugin/dist/index.esm.js"() {
1950
+ "use strict";
1951
+ import_debug2 = __toESM(require_src());
1952
+ merge = require_merge_deep();
1953
+ PuppeteerExtraPlugin = class {
1954
+ constructor(opts) {
1955
+ this._debugBase = (0, import_debug2.default)(`puppeteer-extra-plugin:base:${this.name}`);
1956
+ this._childClassMembers = [];
1957
+ this._opts = merge(this.defaults, opts || {});
1958
+ this._debugBase("Initialized.");
1959
+ }
1960
+ /**
1961
+ * Plugin name (required).
1962
+ *
1963
+ * Convention:
1964
+ * - Package: `puppeteer-extra-plugin-anonymize-ua`
1965
+ * - Name: `anonymize-ua`
1966
+ *
1967
+ * @example
1968
+ * get name () { return 'anonymize-ua' }
1969
+ */
1970
+ get name() {
1971
+ throw new Error('Plugin must override "name"');
1972
+ }
1973
+ /**
1974
+ * Plugin defaults (optional).
1975
+ *
1976
+ * If defined will be ([deep-](https://github.com/jonschlinkert/merge-deep))merged with the (optional) user supplied options (supplied during plugin instantiation).
1977
+ *
1978
+ * The result of merging defaults with user supplied options can be accessed through `this.opts`.
1979
+ *
1980
+ * @see [[opts]]
1981
+ *
1982
+ * @example
1983
+ * get defaults () {
1984
+ * return {
1985
+ * stripHeadless: true,
1986
+ * makeWindows: true,
1987
+ * customFn: null
1988
+ * }
1989
+ * }
1990
+ *
1991
+ * // Users can overwrite plugin defaults during instantiation:
1992
+ * puppeteer.use(require('puppeteer-extra-plugin-foobar')({ makeWindows: false }))
1993
+ */
1994
+ get defaults() {
1995
+ return {};
1996
+ }
1997
+ /**
1998
+ * Plugin requirements (optional).
1999
+ *
2000
+ * Signal certain plugin requirements to the base class and the user.
2001
+ *
2002
+ * Currently supported:
2003
+ * - `launch`
2004
+ * - If the plugin only supports locally created browser instances (no `puppeteer.connect()`),
2005
+ * will output a warning to the user.
2006
+ * - `headful`
2007
+ * - If the plugin doesn't work in `headless: true` mode,
2008
+ * will output a warning to the user.
2009
+ * - `dataFromPlugins`
2010
+ * - In case the plugin requires data from other plugins.
2011
+ * will enable usage of `this.getDataFromPlugins()`.
2012
+ * - `runLast`
2013
+ * - In case the plugin prefers to run after the others.
2014
+ * Useful when the plugin needs data from others.
2015
+ *
2016
+ * @example
2017
+ * get requirements () {
2018
+ * return new Set(['runLast', 'dataFromPlugins'])
2019
+ * }
2020
+ */
2021
+ get requirements() {
2022
+ return /* @__PURE__ */ new Set([]);
2023
+ }
2024
+ /**
2025
+ * Plugin dependencies (optional).
2026
+ *
2027
+ * Missing plugins will be required() by puppeteer-extra.
2028
+ *
2029
+ * @example
2030
+ * get dependencies () {
2031
+ * return new Set(['user-preferences'])
2032
+ * }
2033
+ * // Will ensure the 'puppeteer-extra-plugin-user-preferences' plugin is loaded.
2034
+ */
2035
+ get dependencies() {
2036
+ return /* @__PURE__ */ new Set([]);
2037
+ }
2038
+ /**
2039
+ * Plugin data (optional).
2040
+ *
2041
+ * Plugins can expose data (an array of objects), which in turn can be consumed by other plugins,
2042
+ * that list the `dataFromPlugins` requirement (by using `this.getDataFromPlugins()`).
2043
+ *
2044
+ * Convention: `[ {name: 'Any name', value: 'Any value'} ]`
2045
+ *
2046
+ * @see [[getDataFromPlugins]]
2047
+ *
2048
+ * @example
2049
+ * // plugin1.js
2050
+ * get data () {
2051
+ * return [
2052
+ * {
2053
+ * name: 'userPreferences',
2054
+ * value: { foo: 'bar' }
2055
+ * },
2056
+ * {
2057
+ * name: 'userPreferences',
2058
+ * value: { hello: 'world' }
2059
+ * }
2060
+ * ]
2061
+ *
2062
+ * // plugin2.js
2063
+ * get requirements () { return new Set(['dataFromPlugins']) }
2064
+ *
2065
+ * async beforeLaunch () {
2066
+ * const prefs = this.getDataFromPlugins('userPreferences').map(d => d.value)
2067
+ * this.debug(prefs) // => [ { foo: 'bar' }, { hello: 'world' } ]
2068
+ * }
2069
+ */
2070
+ get data() {
2071
+ return [];
2072
+ }
2073
+ /**
2074
+ * Access the plugin options (usually the `defaults` merged with user defined options)
2075
+ *
2076
+ * To skip the auto-merging of defaults with user supplied opts don't define a `defaults`
2077
+ * property and set the `this._opts` Object in your plugin constructor directly.
2078
+ *
2079
+ * @see [[defaults]]
2080
+ *
2081
+ * @example
2082
+ * get defaults () { return { foo: "bar" } }
2083
+ *
2084
+ * async onPageCreated (page) {
2085
+ * this.debug(this.opts.foo) // => bar
2086
+ * }
2087
+ */
2088
+ get opts() {
2089
+ return this._opts;
2090
+ }
2091
+ /**
2092
+ * Convenience debug logger based on the [debug] module.
2093
+ * Will automatically namespace the logging output to the plugin package name.
2094
+ * [debug]: https://www.npmjs.com/package/debug
2095
+ *
2096
+ * ```bash
2097
+ * # toggle output using environment variables
2098
+ * DEBUG=puppeteer-extra-plugin:<plugin_name> node foo.js
2099
+ * # to debug all the things:
2100
+ * DEBUG=puppeteer-extra,puppeteer-extra-plugin:* node foo.js
2101
+ * ```
2102
+ *
2103
+ * @example
2104
+ * this.debug('hello world')
2105
+ * // will output e.g. 'puppeteer-extra-plugin:anonymize-ua hello world'
2106
+ */
2107
+ get debug() {
2108
+ return (0, import_debug2.default)(`puppeteer-extra-plugin:${this.name}`);
2109
+ }
2110
+ /**
2111
+ * Before a new browser instance is created/launched.
2112
+ *
2113
+ * Can be used to modify the puppeteer launch options by modifying or returning them.
2114
+ *
2115
+ * Plugins using this method will be called in sequence to each
2116
+ * be able to update the launch options.
2117
+ *
2118
+ * @example
2119
+ * async beforeLaunch (options) {
2120
+ * if (this.opts.flashPluginPath) {
2121
+ * options.args.push(`--ppapi-flash-path=${this.opts.flashPluginPath}`)
2122
+ * }
2123
+ * }
2124
+ *
2125
+ * @param options - Puppeteer launch options
2126
+ */
2127
+ async beforeLaunch(options) {
2128
+ }
2129
+ /**
2130
+ * After the browser has launched.
2131
+ *
2132
+ * Note: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.
2133
+ * It's possible that `pupeeteer.launch` will be called multiple times and more than one browser created.
2134
+ * In order to make the plugins as stateless as possible don't store a reference to the browser instance
2135
+ * in the plugin but rather consider alternatives.
2136
+ *
2137
+ * E.g. when using `onPageCreated` you can get a browser reference by using `page.browser()`.
2138
+ *
2139
+ * Alternatively you could expose a class method that takes a browser instance as a parameter to work with:
2140
+ *
2141
+ * ```es6
2142
+ * const fancyPlugin = require('puppeteer-extra-plugin-fancy')()
2143
+ * puppeteer.use(fancyPlugin)
2144
+ * const browser = await puppeteer.launch()
2145
+ * await fancyPlugin.killBrowser(browser)
2146
+ * ```
2147
+ *
2148
+ * @param browser - The `puppeteer` browser instance.
2149
+ * @param opts.options - Puppeteer launch options used.
2150
+ *
2151
+ * @example
2152
+ * async afterLaunch (browser, opts) {
2153
+ * this.debug('browser has been launched', opts.options)
2154
+ * }
2155
+ */
2156
+ async afterLaunch(browser, opts = { options: {} }) {
2157
+ }
2158
+ /**
2159
+ * Before connecting to an existing browser instance.
2160
+ *
2161
+ * Can be used to modify the puppeteer connect options by modifying or returning them.
2162
+ *
2163
+ * Plugins using this method will be called in sequence to each
2164
+ * be able to update the launch options.
2165
+ *
2166
+ * @param {Object} options - Puppeteer connect options
2167
+ * @return {Object=}
2168
+ */
2169
+ async beforeConnect(options) {
2170
+ }
2171
+ /**
2172
+ * After connecting to an existing browser instance.
2173
+ *
2174
+ * > Note: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.
2175
+ *
2176
+ * @param browser - The `puppeteer` browser instance.
2177
+ * @param {Object} opts
2178
+ * @param {Object} opts.options - Puppeteer connect options used.
2179
+ *
2180
+ */
2181
+ async afterConnect(browser, opts = {}) {
2182
+ }
2183
+ /**
2184
+ * Called when a browser instance is available.
2185
+ *
2186
+ * This applies to both `puppeteer.launch()` and `puppeteer.connect()`.
2187
+ *
2188
+ * Convenience method created for plugins that need access to a browser instance
2189
+ * and don't mind if it has been created through `launch` or `connect`.
2190
+ *
2191
+ * > Note: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.
2192
+ *
2193
+ * @param browser - The `puppeteer` browser instance.
2194
+ */
2195
+ async onBrowser(browser, opts) {
2196
+ }
2197
+ /**
2198
+ * Called when a target is created, for example when a new page is opened by window.open or browser.newPage.
2199
+ *
2200
+ * > Note: This includes target creations in incognito browser contexts.
2201
+ *
2202
+ * > Note: This includes browser instances created through `.launch()` as well as `.connect()`.
2203
+ *
2204
+ * @param {Puppeteer.Target} target
2205
+ */
2206
+ async onTargetCreated(target) {
2207
+ }
2208
+ /**
2209
+ * Same as `onTargetCreated` but prefiltered to only contain Pages, for convenience.
2210
+ *
2211
+ * > Note: This includes page creations in incognito browser contexts.
2212
+ *
2213
+ * > Note: This includes browser instances created through `.launch()` as well as `.connect()`.
2214
+ *
2215
+ * @param {Puppeteer.Target} target
2216
+ *
2217
+ * @example
2218
+ * async onPageCreated (page) {
2219
+ * let ua = await page.browser().userAgent()
2220
+ * if (this.opts.stripHeadless) {
2221
+ * ua = ua.replace('HeadlessChrome/', 'Chrome/')
2222
+ * }
2223
+ * this.debug('new ua', ua)
2224
+ * await page.setUserAgent(ua)
2225
+ * }
2226
+ */
2227
+ async onPageCreated(page) {
2228
+ }
2229
+ /**
2230
+ * Called when the url of a target changes.
2231
+ *
2232
+ * > Note: This includes target changes in incognito browser contexts.
2233
+ *
2234
+ * > Note: This includes browser instances created through `.launch()` as well as `.connect()`.
2235
+ *
2236
+ * @param {Puppeteer.Target} target
2237
+ */
2238
+ async onTargetChanged(target) {
2239
+ }
2240
+ /**
2241
+ * Called when a target is destroyed, for example when a page is closed.
2242
+ *
2243
+ * > Note: This includes target destructions in incognito browser contexts.
2244
+ *
2245
+ * > Note: This includes browser instances created through `.launch()` as well as `.connect()`.
2246
+ *
2247
+ * @param {Puppeteer.Target} target
2248
+ */
2249
+ async onTargetDestroyed(target) {
2250
+ }
2251
+ /**
2252
+ * Called when Puppeteer gets disconnected from the Chromium instance.
2253
+ *
2254
+ * This might happen because of one of the following:
2255
+ * - Chromium is closed or crashed
2256
+ * - The `browser.disconnect` method was called
2257
+ */
2258
+ async onDisconnected() {
2259
+ }
2260
+ /**
2261
+ * **Deprecated:** Since puppeteer v1.6.0 `onDisconnected` has been improved
2262
+ * and should be used instead of `onClose`.
2263
+ *
2264
+ * In puppeteer < v1.6.0 `onDisconnected` was not catching all exit scenarios.
2265
+ * In order for plugins to clean up properly (e.g. deleting temporary files)
2266
+ * the `onClose` method had been introduced.
2267
+ *
2268
+ * > Note: Might be called multiple times on exit.
2269
+ *
2270
+ * > Note: This only includes browser instances created through `.launch()`.
2271
+ */
2272
+ async onClose() {
2273
+ }
2274
+ /**
2275
+ * After the plugin has been registered in `puppeteer-extra`.
2276
+ *
2277
+ * Normally right after `puppeteer.use(plugin)` is called
2278
+ */
2279
+ async onPluginRegistered() {
2280
+ }
2281
+ /**
2282
+ * Helper method to retrieve `data` objects from other plugins.
2283
+ *
2284
+ * A plugin needs to state the `dataFromPlugins` requirement
2285
+ * in order to use this method. Will be mapped to `puppeteer.getPluginData`.
2286
+ *
2287
+ * @param name - Filter data by `name` property
2288
+ *
2289
+ * @see [data]
2290
+ * @see [requirements]
2291
+ */
2292
+ getDataFromPlugins(name) {
2293
+ return [];
2294
+ }
2295
+ /**
2296
+ * Will match plugin dependencies against all currently registered plugins.
2297
+ * Is being called by `puppeteer-extra` and used to require missing dependencies.
2298
+ *
2299
+ * @param {Array<Object>} plugins
2300
+ * @return {Set} - list of missing plugin names
2301
+ *
2302
+ * @private
2303
+ */
2304
+ _getMissingDependencies(plugins) {
2305
+ const pluginNames = new Set(plugins.map((p) => p.name));
2306
+ const missing = new Set(Array.from(this.dependencies.values()).filter((x) => !pluginNames.has(x)));
2307
+ return missing;
2308
+ }
2309
+ /**
2310
+ * Conditionally bind browser/process events to class members.
2311
+ * The idea is to reduce event binding boilerplate in plugins.
2312
+ *
2313
+ * For efficiency we make sure the plugin is using the respective event
2314
+ * by checking the child class members before registering the listener.
2315
+ *
2316
+ * @param {<Puppeteer.Browser>} browser
2317
+ * @param {Object} opts - Options
2318
+ * @param {string} opts.context - Puppeteer context (launch/connect)
2319
+ * @param {Object} [opts.options] - Puppeteer launch or connect options
2320
+ * @param {Array<string>} [opts.defaultArgs] - The default flags that Chromium will be launched with
2321
+ *
2322
+ * @private
2323
+ */
2324
+ async _bindBrowserEvents(browser, opts = {}) {
2325
+ if (this._hasChildClassMember("onTargetCreated") || this._hasChildClassMember("onPageCreated")) {
2326
+ browser.on("targetcreated", this._onTargetCreated.bind(this));
2327
+ }
2328
+ if (this._hasChildClassMember("onTargetChanged") && this.onTargetChanged) {
2329
+ browser.on("targetchanged", this.onTargetChanged.bind(this));
2330
+ }
2331
+ if (this._hasChildClassMember("onTargetDestroyed") && this.onTargetDestroyed) {
2332
+ browser.on("targetdestroyed", this.onTargetDestroyed.bind(this));
2333
+ }
2334
+ if (this._hasChildClassMember("onDisconnected") && this.onDisconnected) {
2335
+ browser.on("disconnected", this.onDisconnected.bind(this));
2336
+ }
2337
+ if (opts.context === "launch" && this._hasChildClassMember("onClose")) {
2338
+ if (this.onClose) {
2339
+ process.on("exit", this.onClose.bind(this));
2340
+ browser.on("disconnected", this.onClose.bind(this));
2341
+ if (opts.options.handleSIGINT !== false) {
2342
+ process.on("SIGINT", this.onClose.bind(this));
2343
+ }
2344
+ if (opts.options.handleSIGTERM !== false) {
2345
+ process.on("SIGTERM", this.onClose.bind(this));
2346
+ }
2347
+ if (opts.options.handleSIGHUP !== false) {
2348
+ process.on("SIGHUP", this.onClose.bind(this));
2349
+ }
2350
+ }
2351
+ }
2352
+ if (opts.context === "launch" && this.afterLaunch) {
2353
+ await this.afterLaunch(browser, opts);
2354
+ }
2355
+ if (opts.context === "connect" && this.afterConnect) {
2356
+ await this.afterConnect(browser, opts);
2357
+ }
2358
+ if (this.onBrowser)
2359
+ await this.onBrowser(browser, opts);
2360
+ }
2361
+ /**
2362
+ * @private
2363
+ */
2364
+ async _onTargetCreated(target) {
2365
+ if (this.onTargetCreated)
2366
+ await this.onTargetCreated(target);
2367
+ if (target.type() === "page") {
2368
+ try {
2369
+ const page = await target.page();
2370
+ if (!page) {
2371
+ return;
2372
+ }
2373
+ const validPage = "isClosed" in page && !page.isClosed();
2374
+ if (this.onPageCreated && validPage) {
2375
+ await this.onPageCreated(page);
2376
+ }
2377
+ } catch (err) {
2378
+ console.error(err);
2379
+ }
2380
+ }
2381
+ }
2382
+ /**
2383
+ * @private
2384
+ */
2385
+ _register(prototype) {
2386
+ this._registerChildClassMembers(prototype);
2387
+ if (this.onPluginRegistered)
2388
+ this.onPluginRegistered();
2389
+ }
2390
+ /**
2391
+ * @private
2392
+ */
2393
+ _registerChildClassMembers(prototype) {
2394
+ this._childClassMembers = Object.getOwnPropertyNames(prototype);
2395
+ }
2396
+ /**
2397
+ * @private
2398
+ */
2399
+ _hasChildClassMember(name) {
2400
+ return !!this._childClassMembers.includes(name);
2401
+ }
2402
+ /**
2403
+ * @private
2404
+ */
2405
+ get _isPuppeteerExtraPlugin() {
2406
+ return true;
2407
+ }
2408
+ };
2409
+ }
2410
+ });
2411
+
2412
+ // node_modules/puppeteer-extra-plugin-stealth/index.js
2413
+ var require_puppeteer_extra_plugin_stealth = __commonJS({
2414
+ "node_modules/puppeteer-extra-plugin-stealth/index.js"(exports, module) {
2415
+ "use strict";
2416
+ var { PuppeteerExtraPlugin: PuppeteerExtraPlugin2 } = (init_index_esm2(), __toCommonJS(index_esm_exports2));
2417
+ var StealthPlugin = class extends PuppeteerExtraPlugin2 {
2418
+ constructor(opts = {}) {
2419
+ super(opts);
2420
+ }
2421
+ get name() {
2422
+ return "stealth";
2423
+ }
2424
+ get defaults() {
2425
+ const availableEvasions = /* @__PURE__ */ new Set([
2426
+ "chrome.app",
2427
+ "chrome.csi",
2428
+ "chrome.loadTimes",
2429
+ "chrome.runtime",
2430
+ "defaultArgs",
2431
+ "iframe.contentWindow",
2432
+ "media.codecs",
2433
+ "navigator.hardwareConcurrency",
2434
+ "navigator.languages",
2435
+ "navigator.permissions",
2436
+ "navigator.plugins",
2437
+ "navigator.webdriver",
2438
+ "sourceurl",
2439
+ "user-agent-override",
2440
+ "webgl.vendor",
2441
+ "window.outerdimensions"
2442
+ ]);
2443
+ return {
2444
+ availableEvasions,
2445
+ // Enable all available evasions by default
2446
+ enabledEvasions: /* @__PURE__ */ new Set([...availableEvasions])
2447
+ };
2448
+ }
2449
+ /**
2450
+ * Requires evasion techniques dynamically based on configuration.
2451
+ *
2452
+ * @private
2453
+ */
2454
+ get dependencies() {
2455
+ return new Set(
2456
+ [...this.opts.enabledEvasions].map((e) => `${this.name}/evasions/${e}`)
2457
+ );
2458
+ }
2459
+ /**
2460
+ * Get all available evasions.
2461
+ *
2462
+ * Please look into the [evasions directory](./evasions/) for an up to date list.
2463
+ *
2464
+ * @type {Set<string>} - A Set of all available evasions.
2465
+ *
2466
+ * @example
2467
+ * const pluginStealth = require('puppeteer-extra-plugin-stealth')()
2468
+ * console.log(pluginStealth.availableEvasions) // => Set { 'user-agent', 'console.debug' }
2469
+ * puppeteer.use(pluginStealth)
2470
+ */
2471
+ get availableEvasions() {
2472
+ return this.defaults.availableEvasions;
2473
+ }
2474
+ /**
2475
+ * Get all enabled evasions.
2476
+ *
2477
+ * Enabled evasions can be configured either through `opts` or by modifying this property.
2478
+ *
2479
+ * @type {Set<string>} - A Set of all enabled evasions.
2480
+ *
2481
+ * @example
2482
+ * // Remove specific evasion from enabled ones dynamically
2483
+ * const pluginStealth = require('puppeteer-extra-plugin-stealth')()
2484
+ * pluginStealth.enabledEvasions.delete('console.debug')
2485
+ * puppeteer.use(pluginStealth)
2486
+ */
2487
+ get enabledEvasions() {
2488
+ return this.opts.enabledEvasions;
2489
+ }
2490
+ /**
2491
+ * @private
2492
+ */
2493
+ set enabledEvasions(evasions) {
2494
+ this.opts.enabledEvasions = evasions;
2495
+ }
2496
+ async onBrowser(browser) {
2497
+ if (browser && browser.setMaxListeners) {
2498
+ browser.setMaxListeners(30);
2499
+ }
2500
+ }
2501
+ };
2502
+ var defaultExport = (opts) => new StealthPlugin(opts);
2503
+ module.exports = defaultExport;
2504
+ }
2505
+ });
2
2506
 
3
2507
  // src/index.ts
4
2508
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -21,7 +2525,11 @@ var DEFAULT_BROWSER_CONFIG = {
21
2525
  renderTimeout: 1e4,
22
2526
  downloadsPath: join(homedir(), ".vsl", "downloads"),
23
2527
  downloadTimeout: 6e4,
24
- acceptDownloads: true
2528
+ acceptDownloads: true,
2529
+ userDataDir: void 0,
2530
+ // Дефолт ~/.vsl/browser-profile применяется в manager.ts
2531
+ cdpPort: 9222
2532
+ // Дефолтный CDP port для подключения множественных агентов
25
2533
  };
26
2534
  function loadConfig() {
27
2535
  const fileConfig = loadConfigFile();
@@ -39,7 +2547,9 @@ function loadConfig() {
39
2547
  renderTimeout: process.env.VSL_RENDER_TIMEOUT ? parseInt(process.env.VSL_RENDER_TIMEOUT, 10) : fileConfig.browser?.renderTimeout ?? DEFAULT_BROWSER_CONFIG.renderTimeout,
40
2548
  downloadsPath: process.env.VSL_DOWNLOADS_PATH || fileConfig.browser?.downloadsPath || DEFAULT_BROWSER_CONFIG.downloadsPath,
41
2549
  downloadTimeout: process.env.VSL_DOWNLOAD_TIMEOUT ? parseInt(process.env.VSL_DOWNLOAD_TIMEOUT, 10) : fileConfig.browser?.downloadTimeout ?? DEFAULT_BROWSER_CONFIG.downloadTimeout,
42
- acceptDownloads: process.env.VSL_ACCEPT_DOWNLOADS ? process.env.VSL_ACCEPT_DOWNLOADS === "true" : fileConfig.browser?.acceptDownloads ?? DEFAULT_BROWSER_CONFIG.acceptDownloads
2550
+ acceptDownloads: process.env.VSL_ACCEPT_DOWNLOADS ? process.env.VSL_ACCEPT_DOWNLOADS === "true" : fileConfig.browser?.acceptDownloads ?? DEFAULT_BROWSER_CONFIG.acceptDownloads,
2551
+ userDataDir: process.env.VSL_USER_DATA_DIR || fileConfig.browser?.userDataDir || DEFAULT_BROWSER_CONFIG.userDataDir,
2552
+ cdpPort: process.env.VSL_CDP_PORT ? parseInt(process.env.VSL_CDP_PORT, 10) : fileConfig.browser?.cdpPort ?? DEFAULT_BROWSER_CONFIG.cdpPort
43
2553
  };
44
2554
  return {
45
2555
  vision: {
@@ -152,22 +2662,22 @@ function buildInjectionScript() {
152
2662
  }
153
2663
  };
154
2664
  }
155
- async function injectVslIdsIntoDom(browser, objects, semanticMap = /* @__PURE__ */ new Map()) {
156
- const page = await browser.getPage();
2665
+ async function injectVslIdsIntoDom(browser, objects, semanticMap = /* @__PURE__ */ new Map(), sessionId) {
2666
+ const page = await browser.getPage(sessionId);
157
2667
  await page.waitForTimeout(50);
158
2668
  const semanticMapObj = {};
159
2669
  for (const [key, value] of semanticMap) {
160
2670
  semanticMapObj[key] = value;
161
2671
  }
162
- await browser.evaluate(buildInjectionScript(), objects, semanticMapObj);
2672
+ await browser.evaluate(buildInjectionScript(), sessionId, objects, semanticMapObj);
163
2673
  }
164
- async function injectVslIdsIntoFrame(browser, frame, objects, semanticMap = /* @__PURE__ */ new Map()) {
2674
+ async function injectVslIdsIntoFrame(browser, frame, objects, semanticMap = /* @__PURE__ */ new Map(), sessionId) {
165
2675
  try {
166
2676
  const semanticMapObj = {};
167
2677
  for (const [key, value] of semanticMap) {
168
2678
  semanticMapObj[key] = value;
169
2679
  }
170
- await browser.evaluateInFrame(frame, buildInjectionScript(), objects, semanticMapObj);
2680
+ await browser.evaluateInFrame(frame, buildInjectionScript(), sessionId, objects, semanticMapObj);
171
2681
  } catch (error) {
172
2682
  console.warn("[VSL] Failed to inject data-vsl-id into iframe:", error);
173
2683
  }
@@ -561,6 +3071,7 @@ function countObjects(objects) {
561
3071
  function buildSemanticMap(elements) {
562
3072
  const map = /* @__PURE__ */ new Map();
563
3073
  function visit(el) {
3074
+ if (!el || typeof el !== "object") return;
564
3075
  const elem = el;
565
3076
  if (!elem.indexPath) return;
566
3077
  if (elem.role || elem.ariaLabel || elem.ariaLabelledBy) {
@@ -573,6 +3084,7 @@ function buildSemanticMap(elements) {
573
3084
  }
574
3085
  if (elem.children && Array.isArray(elem.children)) {
575
3086
  for (const child of elem.children) {
3087
+ if (!child || typeof child !== "object") continue;
576
3088
  visit(child);
577
3089
  }
578
3090
  }
@@ -753,17 +3265,51 @@ async function extractDomTreeFromFrame(browser, frame) {
753
3265
  }
754
3266
  return extraction;
755
3267
  }
756
- async function extractDomTree(browser) {
3268
+ async function extractDomTree(browser, sessionId) {
757
3269
  const extractionResult = await browser.evaluate(
758
- extractDomTreeInBrowser
3270
+ extractDomTreeInBrowser,
3271
+ sessionId
759
3272
  );
760
3273
  const extraction = Array.isArray(extractionResult) ? extractionResult[0] : void 0;
761
3274
  if (!extraction || !Array.isArray(extraction.elements)) {
762
3275
  throw new Error("Failed to extract DOM tree: empty result");
763
3276
  }
3277
+ const invalidCount = countMalformedElements(extraction.elements);
3278
+ if (invalidCount > 0) {
3279
+ console.warn(`[VSL] Filtering ${invalidCount} malformed elements (missing attributes) from DOM extraction`);
3280
+ extraction.elements = filterMalformedElements(extraction.elements);
3281
+ }
764
3282
  return extraction;
765
3283
  }
766
- async function handleGetSnapshot(args, browser, session, _config) {
3284
+ function countMalformedElements(elements) {
3285
+ let count = 0;
3286
+ for (const el of elements) {
3287
+ if (!el || typeof el !== "object" || !("attributes" in el)) {
3288
+ count++;
3289
+ }
3290
+ const children = el?.children;
3291
+ if (Array.isArray(children)) {
3292
+ count += countMalformedElements(children);
3293
+ }
3294
+ }
3295
+ return count;
3296
+ }
3297
+ function filterMalformedElements(elements) {
3298
+ const result = [];
3299
+ for (const el of elements) {
3300
+ if (!el || typeof el !== "object" || !("attributes" in el)) {
3301
+ continue;
3302
+ }
3303
+ const clean = { ...el };
3304
+ const children = clean.children;
3305
+ if (Array.isArray(children)) {
3306
+ clean.children = filterMalformedElements(children);
3307
+ }
3308
+ result.push(clean);
3309
+ }
3310
+ return result;
3311
+ }
3312
+ async function handleGetSnapshot(args, browser, session, _config, sessionId) {
767
3313
  const startTime = Date.now();
768
3314
  const detailLevel = args.detail_level || "medium";
769
3315
  const ttl = args.ttl ?? DEFAULT_SNAPSHOT_TTL_MS;
@@ -816,7 +3362,7 @@ async function handleGetSnapshot(args, browser, session, _config) {
816
3362
  }
817
3363
  }
818
3364
  if (args.url) {
819
- await browser.navigate(args.url);
3365
+ await browser.navigate(args.url, sessionId);
820
3366
  }
821
3367
  const isAvailable = await browser.isAvailable();
822
3368
  if (!isAvailable) {
@@ -825,13 +3371,21 @@ async function handleGetSnapshot(args, browser, session, _config) {
825
3371
  error: "Playwright is not installed. Install it with: npm install playwright"
826
3372
  };
827
3373
  }
828
- const extraction = await extractDomTree(browser);
3374
+ const extraction = await extractDomTree(browser, sessionId);
829
3375
  const extractedElements = extraction.elements;
830
3376
  const viewport = extraction.viewport;
831
- const url = args.url || await browser.evaluate(() => window.location.href);
832
- const title = await browser.evaluate(() => document.title);
833
- const semanticMap = buildSemanticMap(extractedElements);
834
- const iframeElementsRaw = await browser.evaluate(extractIframesInBrowser);
3377
+ const url = args.url || await browser.evaluate(() => window.location.href, sessionId);
3378
+ const title = await browser.evaluate(() => document.title, sessionId);
3379
+ let semanticMap = /* @__PURE__ */ new Map();
3380
+ let snapshotWarning;
3381
+ try {
3382
+ semanticMap = buildSemanticMap(extractedElements);
3383
+ } catch (error) {
3384
+ const msg = `buildSemanticMap failed (graceful degradation): ${error instanceof Error ? error.message : String(error)}`;
3385
+ console.error("[VSL]", msg, error);
3386
+ snapshotWarning = msg;
3387
+ }
3388
+ const iframeElementsRaw = await browser.evaluate(extractIframesInBrowser, sessionId);
835
3389
  const iframeElements = Array.isArray(iframeElementsRaw) ? iframeElementsRaw : [];
836
3390
  if (iframeElements.length > 0) {
837
3391
  console.error(`[VSL] Found ${iframeElements.length} iframe elements:`);
@@ -843,7 +3397,7 @@ async function handleGetSnapshot(args, browser, session, _config) {
843
3397
  for (const iframeInfo of iframeElements) {
844
3398
  if (!iframeInfo.url) continue;
845
3399
  try {
846
- const allFrames = await browser.getFrames();
3400
+ const allFrames = await browser.getFrames(sessionId);
847
3401
  const frame = allFrames.find((f) => {
848
3402
  const frameUrl = f.url();
849
3403
  return frameUrl === iframeInfo.url || frameUrl.includes(iframeInfo.url) || iframeInfo.url.includes(frameUrl);
@@ -908,7 +3462,13 @@ async function handleGetSnapshot(args, browser, session, _config) {
908
3462
  await injectVslIdsIntoFrame(browser, iframeInfo.frame, iframeInfo.doc.objects, semanticMap);
909
3463
  }
910
3464
  }
911
- await injectVslIdsIntoDom(browser, currentDoc.objects, semanticMap);
3465
+ try {
3466
+ await injectVslIdsIntoDom(browser, currentDoc.objects, semanticMap, sessionId);
3467
+ } catch (error) {
3468
+ const msg = `injectVslIdsIntoDom failed (graceful degradation): ${error instanceof Error ? error.message : String(error)}`;
3469
+ console.error("[VSL]", msg, error);
3470
+ snapshotWarning = snapshotWarning ? `${snapshotWarning}; ${msg}` : msg;
3471
+ }
912
3472
  const scrollContext = session.getScrollContext();
913
3473
  const win = computeVisibleWindow(currentDoc.canvas.viewport, scrollContext);
914
3474
  const scrollable = computeScrollable(currentDoc.canvas.viewport, scrollContext);
@@ -934,7 +3494,8 @@ async function handleGetSnapshot(args, browser, session, _config) {
934
3494
  total_objects_count: totalObjectsCount,
935
3495
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
936
3496
  execution_time_ms: executionTimeMs,
937
- scrollable
3497
+ scrollable,
3498
+ ...snapshotWarning ? { warning: snapshotWarning } : {}
938
3499
  };
939
3500
  if (ttl > 0) {
940
3501
  const cacheKey = args.url || "current";
@@ -973,7 +3534,7 @@ function computeToolMetrics(result, startTime) {
973
3534
  }
974
3535
 
975
3536
  // src/tools/navigate.ts
976
- async function handleNavigate(args, browser, session) {
3537
+ async function handleNavigate(args, browser, session, sessionId) {
977
3538
  const startTime = Date.now();
978
3539
  try {
979
3540
  if (!args.url || typeof args.url !== "string") {
@@ -997,13 +3558,13 @@ async function handleNavigate(args, browser, session) {
997
3558
  error: "Playwright is not installed. Install it with: npm install playwright"
998
3559
  };
999
3560
  }
1000
- await browser.navigate(args.url);
1001
- const title = await browser.evaluate(() => document.title);
3561
+ await browser.navigate(args.url, sessionId);
3562
+ const title = await browser.evaluate(() => document.title, sessionId);
1002
3563
  let snapshot;
1003
3564
  let snapshotWarning;
1004
3565
  let scrollableMeta;
1005
3566
  try {
1006
- const extraction = await extractDomTree(browser);
3567
+ const extraction = await extractDomTree(browser, sessionId);
1007
3568
  const input = {
1008
3569
  viewport: extraction.viewport,
1009
3570
  url: args.url,
@@ -1013,7 +3574,7 @@ async function handleNavigate(args, browser, session) {
1013
3574
  };
1014
3575
  session.snapshotFromElements(extraction.elements, input);
1015
3576
  const currentDoc = session.getSnapshot();
1016
- await injectVslIdsIntoDom(browser, currentDoc.objects);
3577
+ await injectVslIdsIntoDom(browser, currentDoc.objects, /* @__PURE__ */ new Map(), sessionId);
1017
3578
  const scrollContext = session.getScrollContext();
1018
3579
  const win = computeVisibleWindow(currentDoc.canvas.viewport, scrollContext);
1019
3580
  scrollableMeta = computeScrollable(currentDoc.canvas.viewport, scrollContext);
@@ -1074,6 +3635,7 @@ var VALID_ACTIONS = [
1074
3635
  "type",
1075
3636
  "fill",
1076
3637
  // alias for type — convenience for LLM agents
3638
+ "clear",
1077
3639
  "scroll",
1078
3640
  "select",
1079
3641
  "hover",
@@ -1083,11 +3645,23 @@ var VALID_ACTIONS = [
1083
3645
  "uncheck",
1084
3646
  "press",
1085
3647
  "download",
1086
- "upload"
3648
+ "upload",
3649
+ "drag",
3650
+ "drop",
3651
+ "submit",
3652
+ "reset",
3653
+ "open",
3654
+ "close",
3655
+ "expand",
3656
+ "collapse",
3657
+ "wait",
3658
+ "go_back",
3659
+ "go_forward",
3660
+ "refresh"
1087
3661
  ];
1088
- async function getStateAfterAction(session, browser, url) {
3662
+ async function getStateAfterAction(session, browser, url, sessionId) {
1089
3663
  try {
1090
- const extraction = await extractDomTree(browser);
3664
+ const extraction = await extractDomTree(browser, sessionId);
1091
3665
  const input = {
1092
3666
  viewport: extraction.viewport,
1093
3667
  url,
@@ -1153,7 +3727,7 @@ function buildScrollStateFromCache(session, scrollContext) {
1153
3727
  return { error: errorMessage };
1154
3728
  }
1155
3729
  }
1156
- async function handleExecuteAction(args, browser, session) {
3730
+ async function handleExecuteAction(args, browser, session, sessionId) {
1157
3731
  const startTime = Date.now();
1158
3732
  try {
1159
3733
  if (!args.action || typeof args.action !== "string") {
@@ -1228,16 +3802,16 @@ async function handleExecuteAction(args, browser, session) {
1228
3802
  const snapshot = session.getSnapshot();
1229
3803
  const snapshotUrl = snapshot.canvas.url;
1230
3804
  if (snapshotUrl) {
1231
- const currentUrl = await browser.evaluate(() => window.location.href);
3805
+ const currentUrl = await browser.evaluate(() => window.location.href, sessionId);
1232
3806
  if (currentUrl !== snapshotUrl) {
1233
- await browser.navigate(snapshotUrl);
3807
+ await browser.navigate(snapshotUrl, sessionId);
1234
3808
  }
1235
3809
  }
1236
3810
  const hasVslIds = await browser.evaluate(() => {
1237
3811
  return document.querySelector("[data-vsl-id]") !== null;
1238
- });
3812
+ }, sessionId);
1239
3813
  if (!hasVslIds) {
1240
- const extraction = await extractDomTree(browser);
3814
+ const extraction = await extractDomTree(browser, sessionId);
1241
3815
  const input = {
1242
3816
  viewport: extraction.viewport,
1243
3817
  url: snapshotUrl || "",
@@ -1261,7 +3835,7 @@ async function handleExecuteAction(args, browser, session) {
1261
3835
  error: `Frame iframe_${frameIndex} not found in registry. Call vsl_get_snapshot first.`
1262
3836
  };
1263
3837
  }
1264
- const frames = await browser.getFrames();
3838
+ const frames = await browser.getFrames(sessionId);
1265
3839
  targetFrame = frames.find((f) => {
1266
3840
  const u = f.url();
1267
3841
  return u === frameUrl || u.includes(frameUrl) || frameUrl.includes(u);
@@ -1277,7 +3851,7 @@ async function handleExecuteAction(args, browser, session) {
1277
3851
  const resolvedId = idMap.get(args.target_id) || localShortId;
1278
3852
  const localId = resolvedId;
1279
3853
  const selector = `[data-vsl-id="${localId}"], #${localId}, .${localId}`;
1280
- const page = await browser.getPage();
3854
+ const page = await browser.getPage(sessionId);
1281
3855
  const target = targetFrame || page;
1282
3856
  switch (args.action) {
1283
3857
  case "click": {
@@ -1347,7 +3921,7 @@ async function handleExecuteAction(args, browser, session) {
1347
3921
  const dy = scrollDir === "up" ? -scrollAmount : scrollDir === "down" ? scrollAmount : 0;
1348
3922
  await browser.evaluate(({ dx: dx2, dy: dy2 }) => {
1349
3923
  window.scrollBy(dx2, dy2);
1350
- }, { dx, dy });
3924
+ }, sessionId, { dx, dy });
1351
3925
  await page.waitForTimeout(50);
1352
3926
  const prevScroll = session.getScrollContext();
1353
3927
  let newScroll = null;
@@ -1357,7 +3931,7 @@ async function handleExecuteAction(args, browser, session) {
1357
3931
  y: window.scrollY,
1358
3932
  width: document.documentElement.scrollWidth,
1359
3933
  height: document.documentElement.scrollHeight
1360
- }));
3934
+ }), sessionId);
1361
3935
  const r = raw;
1362
3936
  if (r !== null && typeof r === "object" && typeof r.x === "number" && typeof r.y === "number" && typeof r.width === "number" && typeof r.height === "number") {
1363
3937
  newScroll = r;
@@ -1399,12 +3973,12 @@ async function handleExecuteAction(args, browser, session) {
1399
3973
  await browser.evaluateInFrame(targetFrame, ({ sel, val }) => {
1400
3974
  const el = document.querySelector(sel);
1401
3975
  if (el) el.value = val;
1402
- }, { sel: selector, val: args.value });
3976
+ }, sessionId, { sel: selector, val: args.value });
1403
3977
  } else {
1404
3978
  await browser.evaluate(({ sel, val }) => {
1405
3979
  const el = document.querySelector(sel);
1406
3980
  if (el) el.value = val;
1407
- }, { sel: selector, val: args.value });
3981
+ }, sessionId, { sel: selector, val: args.value });
1408
3982
  }
1409
3983
  break;
1410
3984
  case "hover":
@@ -1415,7 +3989,7 @@ async function handleExecuteAction(args, browser, session) {
1415
3989
  const event = new MouseEvent("mouseover", { bubbles: true });
1416
3990
  el.dispatchEvent(event);
1417
3991
  }
1418
- }, selector);
3992
+ }, sessionId, selector);
1419
3993
  } else {
1420
3994
  await browser.evaluate((sel) => {
1421
3995
  const el = document.querySelector(sel);
@@ -1423,7 +3997,7 @@ async function handleExecuteAction(args, browser, session) {
1423
3997
  const event = new MouseEvent("mouseover", { bubbles: true });
1424
3998
  el.dispatchEvent(event);
1425
3999
  }
1426
- }, selector);
4000
+ }, sessionId, selector);
1427
4001
  }
1428
4002
  break;
1429
4003
  case "blur":
@@ -1431,12 +4005,12 @@ async function handleExecuteAction(args, browser, session) {
1431
4005
  await browser.evaluateInFrame(targetFrame, (sel) => {
1432
4006
  const el = document.querySelector(sel);
1433
4007
  if (el) el.blur();
1434
- }, selector);
4008
+ }, sessionId, selector);
1435
4009
  } else {
1436
4010
  await browser.evaluate((sel) => {
1437
4011
  const el = document.querySelector(sel);
1438
4012
  if (el) el.blur();
1439
- }, selector);
4013
+ }, sessionId, selector);
1440
4014
  }
1441
4015
  break;
1442
4016
  case "focus":
@@ -1444,12 +4018,12 @@ async function handleExecuteAction(args, browser, session) {
1444
4018
  await browser.evaluateInFrame(targetFrame, (sel) => {
1445
4019
  const el = document.querySelector(sel);
1446
4020
  if (el) el.focus();
1447
- }, selector);
4021
+ }, sessionId, selector);
1448
4022
  } else {
1449
4023
  await browser.evaluate((sel) => {
1450
4024
  const el = document.querySelector(sel);
1451
4025
  if (el) el.focus();
1452
- }, selector);
4026
+ }, sessionId, selector);
1453
4027
  }
1454
4028
  break;
1455
4029
  case "press": {
@@ -1474,7 +4048,7 @@ async function handleExecuteAction(args, browser, session) {
1474
4048
  document.body.appendChild(a);
1475
4049
  a.click();
1476
4050
  document.body.removeChild(a);
1477
- }, args.value);
4051
+ }, sessionId, args.value);
1478
4052
  } else {
1479
4053
  await browser.evaluate((url) => {
1480
4054
  const a = document.createElement("a");
@@ -1483,19 +4057,19 @@ async function handleExecuteAction(args, browser, session) {
1483
4057
  document.body.appendChild(a);
1484
4058
  a.click();
1485
4059
  document.body.removeChild(a);
1486
- }, args.value);
4060
+ }, sessionId, args.value);
1487
4061
  }
1488
4062
  } else {
1489
4063
  if (targetFrame) {
1490
4064
  await browser.evaluateInFrame(targetFrame, (sel) => {
1491
4065
  const el = document.querySelector(sel);
1492
4066
  if (el) el.click();
1493
- }, selector);
4067
+ }, sessionId, selector);
1494
4068
  } else {
1495
4069
  await browser.evaluate((sel) => {
1496
4070
  const el = document.querySelector(sel);
1497
4071
  if (el) el.click();
1498
- }, selector);
4072
+ }, sessionId, selector);
1499
4073
  }
1500
4074
  }
1501
4075
  const pollDeadline = Date.now() + 5e3;
@@ -1505,7 +4079,7 @@ async function handleExecuteAction(args, browser, session) {
1505
4079
  (d) => !downloadsBefore.some((b) => b.downloadId === d.downloadId)
1506
4080
  );
1507
4081
  if (!newDownload) {
1508
- await browser.evaluate(() => new Promise((resolve) => setTimeout(resolve, 50)));
4082
+ await browser.evaluate(() => new Promise((resolve) => setTimeout(resolve, 50)), sessionId);
1509
4083
  }
1510
4084
  }
1511
4085
  if (!newDownload) {
@@ -1534,8 +4108,8 @@ async function handleExecuteAction(args, browser, session) {
1534
4108
  }
1535
4109
  };
1536
4110
  if (args.return_state !== false) {
1537
- const currentUrl = await browser.evaluate(() => window.location.href);
1538
- const state = await getStateAfterAction(session, browser, currentUrl);
4111
+ const currentUrl = await browser.evaluate(() => window.location.href, sessionId);
4112
+ const state = await getStateAfterAction(session, browser, currentUrl, sessionId);
1539
4113
  if (result2.data) {
1540
4114
  result2.data.state = state;
1541
4115
  if (state.error) {
@@ -1575,8 +4149,8 @@ async function handleExecuteAction(args, browser, session) {
1575
4149
  }
1576
4150
  };
1577
4151
  if (args.return_state !== false) {
1578
- const currentUrl = await browser.evaluate(() => window.location.href);
1579
- const state = await getStateAfterAction(session, browser, currentUrl);
4152
+ const currentUrl = await browser.evaluate(() => window.location.href, sessionId);
4153
+ const state = await getStateAfterAction(session, browser, currentUrl, sessionId);
1580
4154
  if (result2.data) {
1581
4155
  result2.data.state = state;
1582
4156
  if (state.error) {
@@ -1587,6 +4161,273 @@ async function handleExecuteAction(args, browser, session) {
1587
4161
  result2.metadata = computeToolMetrics(result2.data, startTime);
1588
4162
  return result2;
1589
4163
  }
4164
+ case "clear": {
4165
+ if (targetFrame) {
4166
+ await browser.evaluateInFrame(targetFrame, (sel) => {
4167
+ const el = document.querySelector(sel);
4168
+ if (el) {
4169
+ el.value = "";
4170
+ el.dispatchEvent(new Event("input", { bubbles: true }));
4171
+ el.dispatchEvent(new Event("change", { bubbles: true }));
4172
+ }
4173
+ }, sessionId, selector);
4174
+ } else {
4175
+ await browser.evaluate((sel) => {
4176
+ const el = document.querySelector(sel);
4177
+ if (el) {
4178
+ el.value = "";
4179
+ el.dispatchEvent(new Event("input", { bubbles: true }));
4180
+ el.dispatchEvent(new Event("change", { bubbles: true }));
4181
+ }
4182
+ }, sessionId, selector);
4183
+ }
4184
+ break;
4185
+ }
4186
+ case "drag": {
4187
+ if (!args.value) {
4188
+ return {
4189
+ status: "error",
4190
+ error: "value is required for drag action (destination element ID)"
4191
+ };
4192
+ }
4193
+ const destIdMap = session.getIdMap();
4194
+ const destResolvedId = destIdMap.get(args.value) || args.value;
4195
+ const destSelector = `[data-vsl-id="${destResolvedId}"], #${destResolvedId}, .${destResolvedId}`;
4196
+ if (targetFrame) {
4197
+ await browser.evaluateInFrame(targetFrame, ({ srcSel, dstSel }) => {
4198
+ const source = document.querySelector(srcSel);
4199
+ const destination = document.querySelector(dstSel);
4200
+ if (source && destination) {
4201
+ const dispatchDragEvent = (el, type) => {
4202
+ if (typeof DragEvent === "function") {
4203
+ el.dispatchEvent(new DragEvent(type, { bubbles: true, cancelable: true }));
4204
+ } else {
4205
+ el.dispatchEvent(new Event(type, { bubbles: true, cancelable: true }));
4206
+ }
4207
+ };
4208
+ dispatchDragEvent(source, "dragstart");
4209
+ dispatchDragEvent(destination, "dragenter");
4210
+ dispatchDragEvent(destination, "dragover");
4211
+ dispatchDragEvent(destination, "drop");
4212
+ dispatchDragEvent(source, "dragend");
4213
+ }
4214
+ }, sessionId, { srcSel: selector, dstSel: destSelector });
4215
+ } else {
4216
+ await browser.evaluate(({ srcSel, dstSel }) => {
4217
+ const source = document.querySelector(srcSel);
4218
+ const destination = document.querySelector(dstSel);
4219
+ if (source && destination) {
4220
+ const dispatchDragEvent = (el, type) => {
4221
+ if (typeof DragEvent === "function") {
4222
+ el.dispatchEvent(new DragEvent(type, { bubbles: true, cancelable: true }));
4223
+ } else {
4224
+ el.dispatchEvent(new Event(type, { bubbles: true, cancelable: true }));
4225
+ }
4226
+ };
4227
+ dispatchDragEvent(source, "dragstart");
4228
+ dispatchDragEvent(destination, "dragenter");
4229
+ dispatchDragEvent(destination, "dragover");
4230
+ dispatchDragEvent(destination, "drop");
4231
+ dispatchDragEvent(source, "dragend");
4232
+ }
4233
+ }, sessionId, { srcSel: selector, dstSel: destSelector });
4234
+ }
4235
+ break;
4236
+ }
4237
+ case "drop": {
4238
+ if (targetFrame) {
4239
+ await browser.evaluateInFrame(targetFrame, (sel) => {
4240
+ const el = document.querySelector(sel);
4241
+ if (el) {
4242
+ const dispatchDragEvent = (el2, type) => {
4243
+ if (typeof DragEvent === "function") {
4244
+ el2.dispatchEvent(new DragEvent(type, { bubbles: true, cancelable: true }));
4245
+ } else {
4246
+ el2.dispatchEvent(new Event(type, { bubbles: true, cancelable: true }));
4247
+ }
4248
+ };
4249
+ dispatchDragEvent(el, "dragover");
4250
+ dispatchDragEvent(el, "drop");
4251
+ }
4252
+ }, sessionId, selector);
4253
+ } else {
4254
+ await browser.evaluate((sel) => {
4255
+ const el = document.querySelector(sel);
4256
+ if (el) {
4257
+ const dispatchDragEvent = (el2, type) => {
4258
+ if (typeof DragEvent === "function") {
4259
+ el2.dispatchEvent(new DragEvent(type, { bubbles: true, cancelable: true }));
4260
+ } else {
4261
+ el2.dispatchEvent(new Event(type, { bubbles: true, cancelable: true }));
4262
+ }
4263
+ };
4264
+ dispatchDragEvent(el, "dragover");
4265
+ dispatchDragEvent(el, "drop");
4266
+ }
4267
+ }, sessionId, selector);
4268
+ }
4269
+ break;
4270
+ }
4271
+ case "submit": {
4272
+ if (targetFrame) {
4273
+ await browser.evaluateInFrame(targetFrame, (sel) => {
4274
+ const form = document.querySelector(sel);
4275
+ if (form) {
4276
+ form.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
4277
+ }
4278
+ }, sessionId, selector);
4279
+ } else {
4280
+ await browser.evaluate((sel) => {
4281
+ const form = document.querySelector(sel);
4282
+ if (form) {
4283
+ form.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
4284
+ }
4285
+ }, sessionId, selector);
4286
+ }
4287
+ break;
4288
+ }
4289
+ case "reset": {
4290
+ if (targetFrame) {
4291
+ await browser.evaluateInFrame(targetFrame, (sel) => {
4292
+ const form = document.querySelector(sel);
4293
+ if (form) {
4294
+ form.reset();
4295
+ }
4296
+ }, sessionId, selector);
4297
+ } else {
4298
+ await browser.evaluate((sel) => {
4299
+ const form = document.querySelector(sel);
4300
+ if (form) {
4301
+ form.reset();
4302
+ }
4303
+ }, sessionId, selector);
4304
+ }
4305
+ break;
4306
+ }
4307
+ case "open": {
4308
+ if (targetFrame) {
4309
+ await browser.evaluateInFrame(targetFrame, (sel) => {
4310
+ const el = document.querySelector(sel);
4311
+ if (typeof HTMLDialogElement !== "undefined" && el instanceof HTMLDialogElement) {
4312
+ el.showModal();
4313
+ } else if (el instanceof HTMLDetailsElement) {
4314
+ el.open = true;
4315
+ }
4316
+ }, sessionId, selector);
4317
+ } else {
4318
+ await browser.evaluate((sel) => {
4319
+ const el = document.querySelector(sel);
4320
+ if (typeof HTMLDialogElement !== "undefined" && el instanceof HTMLDialogElement) {
4321
+ el.showModal();
4322
+ } else if (el instanceof HTMLDetailsElement) {
4323
+ el.open = true;
4324
+ }
4325
+ }, sessionId, selector);
4326
+ }
4327
+ break;
4328
+ }
4329
+ case "close": {
4330
+ if (targetFrame) {
4331
+ await browser.evaluateInFrame(targetFrame, (sel) => {
4332
+ const el = document.querySelector(sel);
4333
+ if (typeof HTMLDialogElement !== "undefined" && el instanceof HTMLDialogElement) {
4334
+ el.close();
4335
+ } else if (el instanceof HTMLDetailsElement) {
4336
+ el.open = false;
4337
+ }
4338
+ }, sessionId, selector);
4339
+ } else {
4340
+ await browser.evaluate((sel) => {
4341
+ const el = document.querySelector(sel);
4342
+ if (typeof HTMLDialogElement !== "undefined" && el instanceof HTMLDialogElement) {
4343
+ el.close();
4344
+ } else if (el instanceof HTMLDetailsElement) {
4345
+ el.open = false;
4346
+ }
4347
+ }, sessionId, selector);
4348
+ }
4349
+ break;
4350
+ }
4351
+ case "expand": {
4352
+ if (targetFrame) {
4353
+ await browser.evaluateInFrame(targetFrame, (sel) => {
4354
+ const el = document.querySelector(sel);
4355
+ if (el) {
4356
+ if (el instanceof HTMLDetailsElement) {
4357
+ el.open = true;
4358
+ } else if (el.hasAttribute("aria-expanded")) {
4359
+ el.setAttribute("aria-expanded", "true");
4360
+ }
4361
+ }
4362
+ }, sessionId, selector);
4363
+ } else {
4364
+ await browser.evaluate((sel) => {
4365
+ const el = document.querySelector(sel);
4366
+ if (el) {
4367
+ if (el instanceof HTMLDetailsElement) {
4368
+ el.open = true;
4369
+ } else if (el.hasAttribute("aria-expanded")) {
4370
+ el.setAttribute("aria-expanded", "true");
4371
+ }
4372
+ }
4373
+ }, sessionId, selector);
4374
+ }
4375
+ break;
4376
+ }
4377
+ case "collapse": {
4378
+ if (targetFrame) {
4379
+ await browser.evaluateInFrame(targetFrame, (sel) => {
4380
+ const el = document.querySelector(sel);
4381
+ if (el) {
4382
+ if (el instanceof HTMLDetailsElement) {
4383
+ el.open = false;
4384
+ } else if (el.hasAttribute("aria-expanded")) {
4385
+ el.setAttribute("aria-expanded", "false");
4386
+ }
4387
+ }
4388
+ }, sessionId, selector);
4389
+ } else {
4390
+ await browser.evaluate((sel) => {
4391
+ const el = document.querySelector(sel);
4392
+ if (el) {
4393
+ if (el instanceof HTMLDetailsElement) {
4394
+ el.open = false;
4395
+ } else if (el.hasAttribute("aria-expanded")) {
4396
+ el.setAttribute("aria-expanded", "false");
4397
+ }
4398
+ }
4399
+ }, sessionId, selector);
4400
+ }
4401
+ break;
4402
+ }
4403
+ case "wait": {
4404
+ if (!args.value) {
4405
+ return {
4406
+ status: "error",
4407
+ error: 'value is required for wait action (selector or "idle")'
4408
+ };
4409
+ }
4410
+ const timeout = args.timeout || 5e3;
4411
+ const condition = args.value;
4412
+ if (condition === "idle") {
4413
+ await page.waitForLoadState("domcontentloaded", { timeout });
4414
+ } else {
4415
+ await page.waitForSelector(condition, { timeout, state: "attached" });
4416
+ }
4417
+ break;
4418
+ }
4419
+ case "go_back": {
4420
+ await page.goBack({ timeout: args.timeout || 5e3 });
4421
+ break;
4422
+ }
4423
+ case "go_forward": {
4424
+ await page.goForward({ timeout: args.timeout || 5e3 });
4425
+ break;
4426
+ }
4427
+ case "refresh": {
4428
+ await page.reload({ timeout: args.timeout || 5e3 });
4429
+ break;
4430
+ }
1590
4431
  default:
1591
4432
  return {
1592
4433
  status: "error",
@@ -1604,11 +4445,11 @@ async function handleExecuteAction(args, browser, session) {
1604
4445
  if (args.return_state !== false) {
1605
4446
  await browser.evaluate(() => {
1606
4447
  return new Promise((resolve) => {
1607
- setTimeout(() => resolve(), 100);
4448
+ setTimeout(resolve, 100);
1608
4449
  });
1609
- });
1610
- const currentUrl = await browser.evaluate(() => window.location.href);
1611
- const state = await getStateAfterAction(session, browser, currentUrl);
4450
+ }, sessionId);
4451
+ const currentUrl = await browser.evaluate(() => window.location.href, sessionId);
4452
+ const state = await getStateAfterAction(session, browser, currentUrl, sessionId);
1612
4453
  if (result.data) {
1613
4454
  result.data.state = state;
1614
4455
  if (state.error) {
@@ -1627,7 +4468,7 @@ async function handleExecuteAction(args, browser, session) {
1627
4468
  }
1628
4469
 
1629
4470
  // src/tools/getVisual.ts
1630
- async function handleGetVisual(args, browser, session) {
4471
+ async function handleGetVisual(args, browser, session, sessionId) {
1631
4472
  const startTime = Date.now();
1632
4473
  try {
1633
4474
  if (!args.element_id || typeof args.element_id !== "string") {
@@ -1658,7 +4499,7 @@ async function handleGetVisual(args, browser, session) {
1658
4499
  };
1659
4500
  }
1660
4501
  if (args.element_id === "root_0") {
1661
- const page2 = await browser.getPage();
4502
+ const page2 = await browser.getPage(sessionId);
1662
4503
  const screenshotBuffer2 = await page2.screenshot({ type: "png", fullPage: false });
1663
4504
  const base64Image2 = screenshotBuffer2.toString("base64");
1664
4505
  const result2 = {
@@ -1675,12 +4516,12 @@ async function handleGetVisual(args, browser, session) {
1675
4516
  const selector = `[data-vsl-id="${resolvedId}"], #${resolvedId}, [id="${resolvedId}"]`;
1676
4517
  let elementExists = await browser.evaluate((sel) => {
1677
4518
  return document.querySelector(sel) !== null;
1678
- }, selector);
4519
+ }, sessionId, selector);
1679
4520
  if (!elementExists && args.auto_refresh && session) {
1680
- await handleGetSnapshot({}, browser, session, { downloadsPath: "" });
4521
+ await handleGetSnapshot({}, browser, session, { downloadsPath: "" }, sessionId);
1681
4522
  elementExists = await browser.evaluate((sel) => {
1682
4523
  return document.querySelector(sel) !== null;
1683
- }, selector);
4524
+ }, sessionId, selector);
1684
4525
  }
1685
4526
  if (!elementExists) {
1686
4527
  const suggestions = [
@@ -1700,7 +4541,7 @@ async function handleGetVisual(args, browser, session) {
1700
4541
  suggestions
1701
4542
  };
1702
4543
  }
1703
- const page = await browser.getPage();
4544
+ const page = await browser.getPage(sessionId);
1704
4545
  const autoScroll = args.auto_scroll !== false;
1705
4546
  let scrolled = false;
1706
4547
  let scrollOffset;
@@ -1717,7 +4558,7 @@ async function handleGetVisual(args, browser, session) {
1717
4558
  }
1718
4559
  el.scrollIntoView({ block: "center", inline: "center", behavior: "instant" });
1719
4560
  return { needsScroll: true, scrolled: true };
1720
- }, selector);
4561
+ }, sessionId, selector);
1721
4562
  if (scrollResult.scrolled) {
1722
4563
  scrolled = true;
1723
4564
  await browser.evaluate(() => {
@@ -1728,10 +4569,10 @@ async function handleGetVisual(args, browser, session) {
1728
4569
  });
1729
4570
  });
1730
4571
  });
1731
- });
4572
+ }, sessionId);
1732
4573
  scrollOffset = await browser.evaluate(() => {
1733
4574
  return { x: window.scrollX, y: window.scrollY };
1734
- });
4575
+ }, sessionId);
1735
4576
  }
1736
4577
  }
1737
4578
  const rect = await browser.evaluate((sel) => {
@@ -1744,7 +4585,7 @@ async function handleGetVisual(args, browser, session) {
1744
4585
  width: r.width,
1745
4586
  height: r.height
1746
4587
  };
1747
- }, selector);
4588
+ }, sessionId, selector);
1748
4589
  if (!rect) {
1749
4590
  return {
1750
4591
  content: [{ type: "text", text: `Error: Could not get bounding box for element: ${args.element_id}` }],
@@ -2051,7 +4892,7 @@ function determineActions(type, state, $el) {
2051
4892
  }
2052
4893
 
2053
4894
  // src/tools/readPage.ts
2054
- async function handleReadPage(args, browser, session, _config) {
4895
+ async function handleReadPage(args, browser, session, _config, sessionId) {
2055
4896
  const startTime = Date.now();
2056
4897
  if (!args.url || typeof args.url !== "string" || args.url.trim() === "") {
2057
4898
  return {
@@ -2099,12 +4940,12 @@ async function handleReadPage(args, browser, session, _config) {
2099
4940
  error: "Playwright is not installed. Install it with: npm install playwright\nStatic pages can still be read via HTTP path (no browser required)."
2100
4941
  };
2101
4942
  }
2102
- await browser.navigate(args.url);
2103
- const html = await browser.getContent();
4943
+ await browser.navigate(args.url, sessionId);
4944
+ const html = await browser.getContent(sessionId);
2104
4945
  const isSpa = detectSpa(html);
2105
4946
  const hadPreviousSnapshot2 = session.hasSnapshot();
2106
4947
  try {
2107
- const extraction = await extractDomTree(browser);
4948
+ const extraction = await extractDomTree(browser, sessionId);
2108
4949
  session.snapshotFromElements(extraction.elements, {
2109
4950
  viewport: extraction.viewport,
2110
4951
  url: args.url,
@@ -2112,10 +4953,10 @@ async function handleReadPage(args, browser, session, _config) {
2112
4953
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2113
4954
  scroll: extraction.scroll
2114
4955
  });
2115
- await injectVslIdsIntoDom(browser, session.getSnapshot().objects);
4956
+ await injectVslIdsIntoDom(browser, session.getSnapshot().objects, /* @__PURE__ */ new Map(), sessionId);
2116
4957
  } catch (extractError) {
2117
4958
  console.error("[vsl_read_page] SDK extraction failed, falling back to legacy extraction:", extractError);
2118
- const fallbackDoc = await extractVslFromPage(browser);
4959
+ const fallbackDoc = await extractVslFromPage(browser, sessionId);
2119
4960
  session.setSnapshot(fallbackDoc);
2120
4961
  }
2121
4962
  const hasDiff2 = hadPreviousSnapshot2;
@@ -2141,7 +4982,7 @@ async function handleReadPage(args, browser, session, _config) {
2141
4982
  url: args.url,
2142
4983
  mode: "render",
2143
4984
  content,
2144
- vslDocument: rawSnapshot2,
4985
+ vslDocument: replaceIdsInDocument(rawSnapshot2, reverseIdMap2),
2145
4986
  snapshot: finalSnapshot2,
2146
4987
  diff: finalDiff2,
2147
4988
  hasDiff: hasDiff2,
@@ -2187,7 +5028,7 @@ async function handleReadPage(args, browser, session, _config) {
2187
5028
  url: args.url,
2188
5029
  mode: "http",
2189
5030
  content: httpResult.textContent,
2190
- vslDocument: httpResult.vslDocument,
5031
+ vslDocument: replaceIdsInDocument(rawSnapshot, reverseIdMap),
2191
5032
  snapshot: finalSnapshot,
2192
5033
  diff: finalDiff,
2193
5034
  hasDiff,
@@ -2198,7 +5039,9 @@ async function handleReadPage(args, browser, session, _config) {
2198
5039
  readableApplied: httpResult.readableApplied,
2199
5040
  detail_level: detailLevel,
2200
5041
  ...computeVslMetrics(fullSnapshot),
2201
- scrollable
5042
+ scrollable,
5043
+ id_scheme: "counter",
5044
+ warning: "HTTP path: IDs are sequential counters (e.g., btn_0, inp_1). These IDs are NOT compatible with vsl_execute_action. For interactive actions, use vsl_get_snapshot to get browser DOM IDs."
2202
5045
  }
2203
5046
  };
2204
5047
  return {
@@ -2216,7 +5059,7 @@ Stack: ${stack}`
2216
5059
  };
2217
5060
  }
2218
5061
  }
2219
- async function extractVslFromPage(browser) {
5062
+ async function extractVslFromPage(browser, sessionId) {
2220
5063
  let domTree = null;
2221
5064
  try {
2222
5065
  domTree = await browser.evaluate(() => {
@@ -2246,7 +5089,7 @@ async function extractVslFromPage(browser) {
2246
5089
  };
2247
5090
  };
2248
5091
  return extractElement(document.documentElement);
2249
- });
5092
+ }, sessionId);
2250
5093
  } catch (error) {
2251
5094
  console.error("extractVslFromPage: browser.evaluate failed:", error);
2252
5095
  domTree = null;
@@ -2366,7 +5209,7 @@ async function handleGetTextBlock(args, session) {
2366
5209
  }
2367
5210
 
2368
5211
  // src/tools/clickCoordinates.ts
2369
- async function handleClickCoordinates(args, browser, session) {
5212
+ async function handleClickCoordinates(args, browser, session, sessionId) {
2370
5213
  const startTime = Date.now();
2371
5214
  try {
2372
5215
  let findObjectById2 = function(objects, targetId) {
@@ -2412,13 +5255,11 @@ async function handleClickCoordinates(args, browser, session) {
2412
5255
  error: "Playwright is not installed. Install it with: npm install playwright"
2413
5256
  };
2414
5257
  }
2415
- const page = await browser.getPage();
5258
+ const page = await browser.getPage(sessionId);
2416
5259
  let targetFrame = null;
2417
- let localShortId = args.target_id;
2418
5260
  const frameMatch = args.target_id.match(/^iframe_(\d+):(.+)$/);
2419
5261
  if (frameMatch) {
2420
5262
  const frameIndex = parseInt(frameMatch[1], 10);
2421
- localShortId = frameMatch[2];
2422
5263
  const frameUrl = iframeFrameRegistry.get(frameIndex);
2423
5264
  if (!frameUrl) {
2424
5265
  return {
@@ -2426,7 +5267,7 @@ async function handleClickCoordinates(args, browser, session) {
2426
5267
  error: `Frame iframe_${frameIndex} not found in registry. Call vsl_get_snapshot first.`
2427
5268
  };
2428
5269
  }
2429
- const frames = await browser.getFrames();
5270
+ const frames = await browser.getFrames(sessionId);
2430
5271
  targetFrame = frames.find((f) => {
2431
5272
  const u = f.url();
2432
5273
  return u === frameUrl || u.includes(frameUrl) || frameUrl.includes(u);
@@ -2439,36 +5280,33 @@ async function handleClickCoordinates(args, browser, session) {
2439
5280
  }
2440
5281
  }
2441
5282
  const idMap = session.getIdMap();
2442
- const resolvedId = idMap.get(args.target_id) || localShortId;
5283
+ const longId = idMap.get(args.target_id);
5284
+ if (!longId) {
5285
+ return {
5286
+ status: "error",
5287
+ error: `Short ID "${args.target_id}" not found in idMap. Available short IDs: ${Array.from(idMap.keys()).join(", ")}`
5288
+ };
5289
+ }
2443
5290
  const snapshotDoc = session.getSnapshot();
2444
5291
  const snapshotObjects = snapshotDoc.objects ?? [];
2445
- const snapshotObj = findObjectById2(snapshotObjects, resolvedId);
2446
- if (!snapshotObj || !snapshotObj.rect) {
5292
+ const snapshotObj = findObjectById2(snapshotObjects, longId);
5293
+ if (!snapshotObj || !snapshotObj.p || !snapshotObj.s) {
2447
5294
  return {
2448
5295
  status: "error",
2449
- error: `Element "${args.target_id}" (resolved: "${resolvedId}") not found in snapshot or has no rect. Call vsl_get_snapshot first.`
5296
+ error: `Element "${args.target_id}" (resolved: ${longId}) not found in snapshot or has no position/size. Call vsl_get_snapshot first.`
2450
5297
  };
2451
5298
  }
2452
- const elementRect = snapshotObj.rect;
2453
- const target = targetFrame || page;
5299
+ const elementRect = {
5300
+ x: snapshotObj.p[0] - snapshotObj.s[0] / 2,
5301
+ y: snapshotObj.p[1] - snapshotObj.s[1] / 2,
5302
+ width: snapshotObj.s[0],
5303
+ height: snapshotObj.s[1]
5304
+ };
2454
5305
  let actionsCompleted = 0;
2455
5306
  for (const click of args.clicks) {
2456
5307
  const absoluteX = elementRect.x + click.x;
2457
5308
  const absoluteY = elementRect.y + click.y;
2458
- const elementFound = await target.evaluate(
2459
- ([x, y]) => {
2460
- const el = document.elementFromPoint(x, y);
2461
- if (el) {
2462
- el.click();
2463
- return true;
2464
- }
2465
- return false;
2466
- },
2467
- [absoluteX, absoluteY]
2468
- );
2469
- if (!elementFound) {
2470
- console.warn(`[vsl_click_coordinates] No element found at (${absoluteX}, ${absoluteY}), skipping`);
2471
- }
5309
+ await page.mouse.click(absoluteX, absoluteY);
2472
5310
  actionsCompleted++;
2473
5311
  if (click.delay_after_ms && click.delay_after_ms > 0) {
2474
5312
  await page.waitForTimeout(click.delay_after_ms);
@@ -2487,8 +5325,8 @@ async function handleClickCoordinates(args, browser, session) {
2487
5325
  )
2488
5326
  };
2489
5327
  if (returnState) {
2490
- const currentUrl = await browser.evaluate(() => window.location.href);
2491
- const state = await getStateAfterAction(session, browser, currentUrl);
5328
+ const currentUrl = await browser.evaluate(() => window.location.href, sessionId);
5329
+ const state = await getStateAfterAction(session, browser, currentUrl, sessionId);
2492
5330
  if (state.error) {
2493
5331
  result.data.diff = void 0;
2494
5332
  result.data.snapshot = void 0;
@@ -2604,7 +5442,7 @@ var VSL_TOOLS = [
2604
5442
  },
2605
5443
  {
2606
5444
  name: "vsl_get_visual",
2607
- description: "\u041F\u043E\u043B\u0443\u0447\u0438\u0442\u044C visual fragment (\u0441\u043A\u0440\u0438\u043D\u0448\u043E\u0442) \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64 WebP. \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u0434\u043B\u044F \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u0441\u043B\u043E\u0436\u043D\u043E \u043A\u043B\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043F\u043E \u0442\u0435\u043A\u0441\u0442\u0443 (\u0438\u043A\u043E\u043D\u043A\u0438, \u0433\u0440\u0430\u0444\u0438\u043A\u0438, \u043A\u0430\u0441\u0442\u043E\u043C\u043D\u044B\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044B). \u0412\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 {mediaType:image/webp, data:base64data}. \u041F\u0440\u0438\u043C\u0435\u0440: {element_id: img_5}. \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 auto_refresh=true \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0438 \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0435\u0442 snapshot \u043F\u0435\u0440\u0435\u0434 \u043F\u043E\u0438\u0441\u043A\u043E\u043C \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430.",
5445
+ description: "\u041F\u043E\u043B\u0443\u0447\u0438\u0442\u044C visual fragment (\u0441\u043A\u0440\u0438\u043D\u0448\u043E\u0442) \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64 WebP. \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u0434\u043B\u044F \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u0441\u043B\u043E\u0436\u043D\u043E \u043A\u043B\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043F\u043E \u0442\u0435\u043A\u0441\u0442\u0443 (\u0438\u043A\u043E\u043D\u043A\u0438, \u0433\u0440\u0430\u0444\u0438\u043A\u0438, \u043A\u0430\u0441\u0442\u043E\u043C\u043D\u044B\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044B). \u0412\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 {mediaType:image/webp, data:base64data}. \u041F\u0440\u0438\u043C\u0435\u0440: {element_id: img_5}. \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 auto_refresh=true \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0438 \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0435\u0442 snapshot \u043F\u0435\u0440\u0435\u0434 \u043F\u043E\u0438\u0441\u043A\u043E\u043C \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430. \u0412\u0410\u0416\u041D\u041E: \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u0442\u043E\u043B\u044C\u043A\u043E \u0441 ID \u0438\u0437 vsl_get_snapshot (browser DOM). \u041D\u0415 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u0441 ID \u0438\u0437 vsl_read_page (semantic IDs) \u2014 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 vsl_get_snapshot \u0434\u043B\u044F \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u044F \u0441\u043E\u0432\u043C\u0435\u0441\u0442\u0438\u043C\u044B\u0445 ID.",
2608
5446
  inputSchema: {
2609
5447
  type: "object",
2610
5448
  properties: {
@@ -2690,36 +5528,37 @@ function registerTools(server, config, sessionManager) {
2690
5528
  tools: VSL_TOOLS
2691
5529
  };
2692
5530
  });
2693
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
2694
- const { name, arguments: args, _meta } = request.params;
5531
+ server.setRequestHandler(CallToolRequestSchema, async (request2) => {
5532
+ const { name, arguments: args, _meta } = request2.params;
2695
5533
  const sessionId = _meta?.sessionId ?? sessionManager.getDefaultSessionId();
2696
- const { browser, session } = sessionManager.getSession(sessionId);
5534
+ const { session } = sessionManager.getSession(sessionId);
5535
+ const browser = sessionManager.getBrowserManager();
2697
5536
  try {
2698
5537
  let result;
2699
5538
  switch (name) {
2700
5539
  case "vsl_get_snapshot":
2701
- result = await handleGetSnapshot(args, browser, session, config);
5540
+ result = await handleGetSnapshot(args, browser, session, config, sessionId);
2702
5541
  break;
2703
5542
  case "vsl_execute_action":
2704
- result = await handleExecuteAction(args, browser, session);
5543
+ result = await handleExecuteAction(args, browser, session, sessionId);
2705
5544
  break;
2706
5545
  case "vsl_navigate":
2707
- result = await handleNavigate(args, browser, session);
5546
+ result = await handleNavigate(args, browser, session, sessionId);
2708
5547
  break;
2709
5548
  case "vsl_clear_cache":
2710
5549
  result = await handleClearCache(session);
2711
5550
  break;
2712
5551
  case "vsl_get_visual":
2713
- result = await handleGetVisual(args, browser, session);
5552
+ result = await handleGetVisual(args, browser, session, sessionId);
2714
5553
  break;
2715
5554
  case "vsl_read_page":
2716
- result = await handleReadPage(args, browser, session, config);
5555
+ result = await handleReadPage(args, browser, session, config, sessionId);
2717
5556
  break;
2718
5557
  case "vsl_get_text_block":
2719
5558
  result = await handleGetTextBlock(args, session);
2720
5559
  break;
2721
5560
  case "vsl_click_coordinates":
2722
- result = await handleClickCoordinates(args, browser, session);
5561
+ result = await handleClickCoordinates(args, browser, session, sessionId);
2723
5562
  break;
2724
5563
  default:
2725
5564
  return {
@@ -2786,9 +5625,9 @@ function registerResources(server, _config, sessionManager) {
2786
5625
  resources: VSL_RESOURCES
2787
5626
  };
2788
5627
  });
2789
- server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
2790
- const { uri } = request.params;
2791
- const sessionId = request.params._meta?.sessionId ?? sessionManager.getDefaultSessionId();
5628
+ server.setRequestHandler(ReadResourceRequestSchema, async (request2) => {
5629
+ const { uri } = request2.params;
5630
+ const sessionId = request2.params._meta?.sessionId ?? sessionManager.getDefaultSessionId();
2792
5631
  const { session } = sessionManager.getSession(sessionId);
2793
5632
  ensureSubscribed(sessionId, session);
2794
5633
  switch (uri) {
@@ -2880,9 +5719,11 @@ import os from "os";
2880
5719
  var BrowserManager = class {
2881
5720
  browser = null;
2882
5721
  context = null;
2883
- page = null;
5722
+ pages = /* @__PURE__ */ new Map();
2884
5723
  playwright = null;
2885
5724
  config;
5725
+ /** Флаг: браузер подключён через CDP (не закрывать при close()). */
5726
+ connectedViaCDP = false;
2886
5727
  /** Активные загрузки: downloadId -> PlaywrightDownload. */
2887
5728
  activeDownloads = /* @__PURE__ */ new Map();
2888
5729
  constructor(config) {
@@ -2895,62 +5736,108 @@ var BrowserManager = class {
2895
5736
  async loadPlaywright() {
2896
5737
  if (this.playwright) return this.playwright;
2897
5738
  try {
2898
- const pw = await import("playwright");
2899
- this.playwright = pw;
5739
+ const pwExtra = await Promise.resolve().then(() => (init_index_esm(), index_esm_exports));
5740
+ const stealthModule = await Promise.resolve().then(() => __toESM(require_puppeteer_extra_plugin_stealth(), 1));
5741
+ const stealth = stealthModule.default ?? stealthModule;
5742
+ const chromium2 = pwExtra.chromium;
5743
+ chromium2.use(stealth());
5744
+ this.playwright = { chromium: chromium2 };
2900
5745
  return this.playwright;
2901
5746
  } catch {
2902
- return null;
5747
+ try {
5748
+ const pw = await import("playwright");
5749
+ this.playwright = pw;
5750
+ return this.playwright;
5751
+ } catch {
5752
+ return null;
5753
+ }
2903
5754
  }
2904
5755
  }
2905
5756
  /**
2906
5757
  * Запускает браузер (lazy, при первом вызове).
2907
- * Создаёт BrowserContext с настройками для download.
5758
+ * Логика для множественных агентов:
5759
+ * 1. Если cdpPort задан → пробуем connectOverCDP (подключиться к уже запущенному браузеру)
5760
+ * 2. Если connectOverCDP упал (браузер не запущен) → запускаем launchPersistentContext с --remote-debugging-port
5761
+ * 3. Если cdpPort НЕ задан → просто launchPersistentContext без CDP
2908
5762
  * @throws Error если Playwright не установлен
2909
5763
  */
2910
5764
  async launch() {
2911
- if (this.browser) return;
5765
+ if (this.browser || this.context) return;
2912
5766
  const pw = await this.loadPlaywright();
2913
5767
  if (!pw) {
2914
5768
  throw new Error(
2915
5769
  "Playwright is not installed. Install it with: npm install playwright"
2916
5770
  );
2917
5771
  }
2918
- this.browser = await pw.chromium.launch({
2919
- headless: this.config.headless
2920
- });
2921
- const contextOptions = {
5772
+ if (this.config.cdpPort) {
5773
+ try {
5774
+ this.browser = await pw.chromium.connectOverCDP({
5775
+ endpointURL: `http://localhost:${this.config.cdpPort}`
5776
+ });
5777
+ this.connectedViaCDP = true;
5778
+ const contexts = this.browser.contexts();
5779
+ if (contexts.length > 0 && contexts[0]) {
5780
+ this.context = contexts[0];
5781
+ } else {
5782
+ const contextOptions = {
5783
+ acceptDownloads: this.config.acceptDownloads ?? true
5784
+ };
5785
+ if (this.config.downloadsPath) {
5786
+ contextOptions.downloadsPath = this.config.downloadsPath;
5787
+ }
5788
+ this.context = await this.browser.newContext(contextOptions);
5789
+ }
5790
+ return;
5791
+ } catch {
5792
+ }
5793
+ }
5794
+ const userDataDir = this.config.userDataDir ?? path.join(os.homedir(), ".vsl", "browser-profile");
5795
+ const persistentOptions = {
5796
+ headless: this.config.headless,
2922
5797
  acceptDownloads: this.config.acceptDownloads ?? true
2923
5798
  };
2924
5799
  if (this.config.downloadsPath) {
2925
- contextOptions.downloadsPath = this.config.downloadsPath;
5800
+ persistentOptions.downloadsPath = this.config.downloadsPath;
5801
+ }
5802
+ if (this.config.cdpPort) {
5803
+ persistentOptions.args = [`--remote-debugging-port=${this.config.cdpPort}`];
2926
5804
  }
2927
- this.context = await this.browser.newContext(contextOptions);
5805
+ this.context = await pw.chromium.launchPersistentContext(
5806
+ userDataDir,
5807
+ persistentOptions
5808
+ );
5809
+ this.browser = null;
2928
5810
  }
2929
5811
  /**
2930
- * Возвращает страницу (создаёт новую из context, если нет).
5812
+ * Возвращает страницу для указанной сессии (создаёт новую из context, если нет).
5813
+ * @param sessionId - ID сессии для изоляции страниц
2931
5814
  * @throws Error если браузер не запущен
2932
5815
  */
2933
- async getPage() {
2934
- if (!this.browser) {
5816
+ async getPage(sessionId) {
5817
+ if (!this.browser && !this.context) {
2935
5818
  await this.launch();
2936
5819
  }
2937
- if (!this.browser || !this.context) {
5820
+ if (!this.context) {
2938
5821
  throw new Error("Browser not available");
2939
5822
  }
2940
- if (!this.page) {
2941
- this.page = await this.context.newPage();
5823
+ let page = this.pages.get(sessionId);
5824
+ if (!page) {
5825
+ page = await this.context.newPage();
5826
+ this.pages.set(sessionId, page);
2942
5827
  this.context.on("download", (download) => {
2943
5828
  const downloadId = `download_${Date.now()}_${Math.random().toString(36).slice(2)}`;
2944
5829
  this.activeDownloads.set(downloadId, download);
2945
5830
  });
2946
5831
  }
2947
- return this.page;
5832
+ return page;
2948
5833
  }
2949
5834
  /**
2950
5835
  * Переходит по URL.
5836
+ * @param url - URL для навигации
5837
+ * @param sessionId - ID сессии для получения правильной страницы
2951
5838
  */
2952
- async navigate(url) {
2953
- const page = await this.getPage();
5839
+ async navigate(url, sessionId) {
5840
+ const page = await this.getPage(sessionId);
2954
5841
  await page.goto(url, {
2955
5842
  timeout: this.config.navigationTimeout,
2956
5843
  waitUntil: "domcontentloaded"
@@ -2958,26 +5845,27 @@ var BrowserManager = class {
2958
5845
  }
2959
5846
  /**
2960
5847
  * Получает HTML-контент текущей страницы.
5848
+ * @param sessionId - ID сессии
2961
5849
  */
2962
- async getContent() {
2963
- const page = await this.getPage();
5850
+ async getContent(sessionId) {
5851
+ const page = await this.getPage(sessionId);
2964
5852
  return page.content();
2965
5853
  }
2966
- /**
2967
- * Выполняет JavaScript в контексте страницы.
2968
- */
2969
5854
  /**
2970
5855
  * Возвращает все фреймы на странице (включая iframe).
5856
+ * @param sessionId - ID сессии
2971
5857
  */
2972
- async getFrames() {
2973
- const page = await this.getPage();
5858
+ async getFrames(sessionId) {
5859
+ const page = await this.getPage(sessionId);
2974
5860
  return page.frames();
2975
5861
  }
2976
5862
  /**
2977
5863
  * Находит фрейм по URL или имени.
5864
+ * @param urlOrName - URL или имя фрейма
5865
+ * @param sessionId - ID сессии
2978
5866
  */
2979
- async getFrame(urlOrName) {
2980
- const page = await this.getPage();
5867
+ async getFrame(urlOrName, sessionId) {
5868
+ const page = await this.getPage(sessionId);
2981
5869
  return page.frame(urlOrName);
2982
5870
  }
2983
5871
  /**
@@ -2993,16 +5881,23 @@ var BrowserManager = class {
2993
5881
  async locatorInFrame(frame, selector) {
2994
5882
  return frame.locator(selector);
2995
5883
  }
5884
+ /**
5885
+ * Выполняет JavaScript в контексте страницы.
5886
+ * @param fn - Функция или строка кода для выполнения
5887
+ * @param sessionId - ID сессии
5888
+ */
2996
5889
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2997
- async evaluate(fn, ...args) {
2998
- const page = await this.getPage();
5890
+ async evaluate(fn, sessionId, ...args) {
5891
+ const page = await this.getPage(sessionId);
2999
5892
  return page.evaluate(fn, ...args);
3000
5893
  }
3001
5894
  /**
3002
5895
  * Делает скриншот страницы.
5896
+ * @param options - Опции скриншота
5897
+ * @param sessionId - ID сессии (опционально, по умолчанию 'default')
3003
5898
  */
3004
- async screenshot(options) {
3005
- const page = await this.getPage();
5899
+ async screenshot(options, sessionId) {
5900
+ const page = await this.getPage(sessionId ?? "default");
3006
5901
  return page.screenshot({ type: "png", fullPage: options?.fullPage, clip: options?.clip });
3007
5902
  }
3008
5903
  /**
@@ -3117,10 +6012,11 @@ var BrowserManager = class {
3117
6012
  * относительно CWD с path traversal проверкой.
3118
6013
  * @param selector - CSS-селектор input[type=file] элемента
3119
6014
  * @param filePaths - Массив путей к файлам (абсолютные или относительные)
6015
+ * @param sessionId - ID сессии
3120
6016
  * @throws Error если путь выходит за допустимые границы или файл не существует
3121
6017
  */
3122
- async uploadFile(selector, filePaths) {
3123
- const page = await this.getPage();
6018
+ async uploadFile(selector, filePaths, sessionId) {
6019
+ const page = await this.getPage(sessionId);
3124
6020
  if (filePaths.length === 0) {
3125
6021
  throw new Error("filePaths must contain at least one file path");
3126
6022
  }
@@ -3143,35 +6039,48 @@ var BrowserManager = class {
3143
6039
  /**
3144
6040
  * Ожидает появления file chooser dialog (для кастомных file picker'ов).
3145
6041
  * Возвращает FileChooser, через который можно установить файлы.
6042
+ * @param sessionId - ID сессии
3146
6043
  * @param timeout - Таймаут ожидания в мс (по умолчанию из config.downloadTimeout)
3147
6044
  * @returns PlaywrightFileChooser для установки файлов
3148
6045
  */
3149
- async waitForFileChooser(timeout) {
3150
- const page = await this.getPage();
6046
+ async waitForFileChooser(sessionId, timeout) {
6047
+ const page = await this.getPage(sessionId);
3151
6048
  const waitTimeout = timeout ?? this.config.downloadTimeout ?? 6e4;
3152
6049
  const fileChooser = await page.waitForEvent("filechooser", { timeout: waitTimeout });
3153
6050
  return fileChooser;
3154
6051
  }
3155
6052
  /**
3156
6053
  * Закрывает браузер и очищает ресурсы.
6054
+ * Если браузер подключён через CDP — закрывает только context,
6055
+ * сам браузер не закрывается (сохраняет сессию пользователя).
3157
6056
  */
3158
6057
  async close() {
3159
6058
  this.activeDownloads.clear();
6059
+ for (const page of this.pages.values()) {
6060
+ try {
6061
+ await page.close();
6062
+ } catch (error) {
6063
+ console.error("[BrowserManager] Error closing page:", error);
6064
+ }
6065
+ }
6066
+ this.pages.clear();
3160
6067
  try {
3161
6068
  if (this.context) {
3162
6069
  await this.context.close();
3163
6070
  this.context = null;
3164
6071
  }
3165
- if (this.browser) {
6072
+ if (this.browser && !this.connectedViaCDP) {
3166
6073
  await this.browser.close();
3167
6074
  this.browser = null;
6075
+ } else if (this.connectedViaCDP) {
6076
+ this.browser = null;
3168
6077
  }
3169
6078
  } catch (error) {
3170
6079
  console.error("[BrowserManager] Error during close():", error);
3171
6080
  this.context = null;
3172
6081
  this.browser = null;
3173
6082
  }
3174
- this.page = null;
6083
+ this.connectedViaCDP = false;
3175
6084
  }
3176
6085
  };
3177
6086
 
@@ -3384,6 +6293,8 @@ var SessionManager = class {
3384
6293
  sessionTtlMs;
3385
6294
  defaultSessionId;
3386
6295
  cleanupTimer = null;
6296
+ /** Singleton BrowserManager — один браузер на все сессии. */
6297
+ browserManager = null;
3387
6298
  constructor(browserConfig, options) {
3388
6299
  this.browserConfig = browserConfig;
3389
6300
  this.cleanupIntervalMs = options?.cleanupIntervalMs ?? 6e4;
@@ -3398,16 +6309,27 @@ var SessionManager = class {
3398
6309
  getDefaultSessionId() {
3399
6310
  return this.defaultSessionId;
3400
6311
  }
6312
+ /**
6313
+ * Возвращает singleton BrowserManager (создаёт при первом вызове).
6314
+ * Все сессии делят один браузер — это стандартный паттерн Playwright
6315
+ * для multi-tenant scenarios.
6316
+ */
6317
+ getBrowserManager() {
6318
+ if (!this.browserManager) {
6319
+ this.browserManager = new BrowserManager(this.browserConfig);
6320
+ }
6321
+ return this.browserManager;
6322
+ }
3401
6323
  /**
3402
6324
  * Получает или создаёт сессию по sessionId.
3403
- * Если сессия не существует — создаёт новую с собственным BrowserManager и ServerSession.
6325
+ * Если сессия не существует — создаёт новую с ServerSession.
6326
+ * Все сессии делят ОДИН BrowserManager (singleton).
3404
6327
  */
3405
6328
  getSession(sessionId) {
3406
6329
  const normalizedId = sessionId || this.defaultSessionId;
3407
6330
  if (!this.sessions.has(normalizedId)) {
3408
6331
  const context2 = {
3409
6332
  sessionId: normalizedId,
3410
- browser: new BrowserManager(this.browserConfig),
3411
6333
  session: new ServerSession(),
3412
6334
  createdAt: Date.now(),
3413
6335
  lastAccessedAt: Date.now()
@@ -3425,29 +6347,29 @@ var SessionManager = class {
3425
6347
  return this.sessions.has(sessionId || this.defaultSessionId);
3426
6348
  }
3427
6349
  /**
3428
- * Закрывает сессию и освобождает ресурсы (browser, cache).
6350
+ * Закрывает сессию и освобождает ресурсы (cache).
6351
+ * Браузер НЕ закрывается — он общий для всех сессий.
3429
6352
  */
3430
6353
  async closeSession(sessionId) {
3431
6354
  const normalizedId = sessionId || this.defaultSessionId;
3432
6355
  const context = this.sessions.get(normalizedId);
3433
6356
  if (context) {
3434
- await context.browser.close();
3435
6357
  this.sessions.delete(normalizedId);
3436
6358
  }
3437
6359
  }
3438
6360
  /**
3439
- * Закрывает все сессии (при shutdown сервера).
6361
+ * Закрывает все сессии и браузер (при shutdown сервера).
3440
6362
  */
3441
6363
  async closeAll() {
3442
6364
  this.stopCleanup();
3443
- const closePromises = Array.from(this.sessions.values()).map(async (context) => {
6365
+ if (this.browserManager) {
3444
6366
  try {
3445
- await context.browser.close();
6367
+ await this.browserManager.close();
3446
6368
  } catch (error) {
3447
- console.error("[SessionManager] Error closing browser session:", error);
6369
+ console.error("[SessionManager] Error closing browser:", error);
3448
6370
  }
3449
- });
3450
- await Promise.allSettled(closePromises);
6371
+ this.browserManager = null;
6372
+ }
3451
6373
  this.sessions.clear();
3452
6374
  }
3453
6375
  /**
@@ -3506,7 +6428,7 @@ var SessionManager = class {
3506
6428
  };
3507
6429
 
3508
6430
  // src/version.ts
3509
- var VSL_MCP_SERVER_VERSION = "1.2.17";
6431
+ var VSL_MCP_SERVER_VERSION = "1.3.2";
3510
6432
 
3511
6433
  // src/index.ts
3512
6434
  async function main() {
@@ -3555,4 +6477,52 @@ main().catch((error) => {
3555
6477
  console.error("[VSL MCP Server] Fatal error:", error);
3556
6478
  process.exit(1);
3557
6479
  });
6480
+ /*! Bundled license information:
6481
+
6482
+ playwright-extra/dist/index.esm.js:
6483
+ (*!
6484
+ * playwright-extra v4.3.5 by berstend
6485
+ * https://github.com/berstend/puppeteer-extra/tree/master/packages/playwright-extra#readme
6486
+ * @license MIT
6487
+ *)
6488
+
6489
+ for-in/index.js:
6490
+ (*!
6491
+ * for-in <https://github.com/jonschlinkert/for-in>
6492
+ *
6493
+ * Copyright (c) 2014-2017, Jon Schlinkert.
6494
+ * Released under the MIT License.
6495
+ *)
6496
+
6497
+ for-own/index.js:
6498
+ (*!
6499
+ * for-own <https://github.com/jonschlinkert/for-own>
6500
+ *
6501
+ * Copyright (c) 2014-2017, Jon Schlinkert.
6502
+ * Released under the MIT License.
6503
+ *)
6504
+
6505
+ is-buffer/index.js:
6506
+ (*!
6507
+ * Determine if an object is a Buffer
6508
+ *
6509
+ * @author Feross Aboukhadijeh <https://feross.org>
6510
+ * @license MIT
6511
+ *)
6512
+
6513
+ merge-deep/index.js:
6514
+ (*!
6515
+ * merge-deep <https://github.com/jonschlinkert/merge-deep>
6516
+ *
6517
+ * Copyright (c) 2014-2015, Jon Schlinkert.
6518
+ * Licensed under the MIT License.
6519
+ *)
6520
+
6521
+ puppeteer-extra-plugin/dist/index.esm.js:
6522
+ (*!
6523
+ * puppeteer-extra-plugin v3.2.2 by berstend
6524
+ * https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin
6525
+ * @license MIT
6526
+ *)
6527
+ */
3558
6528
  //# sourceMappingURL=index.js.map