@ejazullah/browser-mcp 0.0.56 → 0.0.57

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.
Files changed (62) hide show
  1. package/cli.js +1 -18
  2. package/index.js +1 -1060
  3. package/lib/auth.js +1 -82
  4. package/lib/browserContextFactory.js +1 -205
  5. package/lib/browserServerBackend.js +1 -125
  6. package/lib/config.js +1 -266
  7. package/lib/context.js +1 -232
  8. package/lib/databaseLogger.js +1 -264
  9. package/lib/extension/cdpRelay.js +1 -346
  10. package/lib/extension/extensionContextFactory.js +1 -56
  11. package/lib/extension/main.js +1 -26
  12. package/lib/fileUtils.js +1 -32
  13. package/lib/httpServer.js +1 -39
  14. package/lib/index.js +1 -39
  15. package/lib/javascript.js +1 -49
  16. package/lib/log.js +1 -21
  17. package/lib/loop/loop.js +1 -69
  18. package/lib/loop/loopClaude.js +1 -152
  19. package/lib/loop/loopOpenAI.js +1 -143
  20. package/lib/loop/main.js +1 -60
  21. package/lib/loopTools/context.js +1 -66
  22. package/lib/loopTools/main.js +1 -49
  23. package/lib/loopTools/perform.js +1 -32
  24. package/lib/loopTools/snapshot.js +1 -29
  25. package/lib/loopTools/tool.js +1 -18
  26. package/lib/manualPromise.js +1 -111
  27. package/lib/mcp/inProcessTransport.js +1 -72
  28. package/lib/mcp/server.js +1 -93
  29. package/lib/mcp/transport.js +1 -217
  30. package/lib/mongoDBLogger.js +1 -252
  31. package/lib/package.js +1 -20
  32. package/lib/program.js +1 -113
  33. package/lib/response.js +1 -172
  34. package/lib/sessionLog.js +1 -156
  35. package/lib/tab.js +1 -266
  36. package/lib/tools/cdp.js +1 -169
  37. package/lib/tools/common.js +1 -55
  38. package/lib/tools/console.js +1 -33
  39. package/lib/tools/dialogs.js +1 -47
  40. package/lib/tools/evaluate.js +1 -53
  41. package/lib/tools/extraction.js +1 -217
  42. package/lib/tools/files.js +1 -44
  43. package/lib/tools/forms.js +1 -180
  44. package/lib/tools/getext.js +1 -99
  45. package/lib/tools/install.js +1 -53
  46. package/lib/tools/interactions.js +1 -191
  47. package/lib/tools/keyboard.js +1 -86
  48. package/lib/tools/mouse.js +1 -99
  49. package/lib/tools/navigate.js +1 -70
  50. package/lib/tools/network.js +1 -41
  51. package/lib/tools/pdf.js +1 -40
  52. package/lib/tools/screenshot.js +1 -75
  53. package/lib/tools/selectors.js +1 -233
  54. package/lib/tools/snapshot.js +1 -169
  55. package/lib/tools/states.js +1 -147
  56. package/lib/tools/tabs.js +1 -87
  57. package/lib/tools/tool.js +1 -33
  58. package/lib/tools/utils.js +1 -74
  59. package/lib/tools/wait.js +1 -56
  60. package/lib/tools.js +1 -64
  61. package/lib/utils.js +1 -26
  62. package/package.json +5 -2
package/lib/auth.js CHANGED
@@ -1,82 +1 @@
1
- /**
2
- * External API Key Authentication
3
- *
4
- * Validates API keys against the external auth provider:
5
- * POST https://system-mangment-app.vercel.app/api/validate
6
- * Headers: { "X-API-KEY": "<key>" }
7
- */
8
- const VALIDATE_URL = process.env.VALIDATE_URL || 'https://nexviahub.vercel.app/functions/v1/api-keys';
9
- const CACHE_TTL_MS = 2 * 60 * 1000; // 2 minutes
10
- const validationCache = new Map();
11
- // ─── Core Validator ──────────────────────────────────────────────────────────
12
- /**
13
- * Validate an API key against the external auth provider.
14
- * Results are cached for 5 minutes to reduce external API calls.
15
- */
16
- export async function validateApiKey(apiKey) {
17
- const cached = validationCache.get(apiKey);
18
- if (cached && Date.now() < cached.expiresAt)
19
- return cached.valid;
20
- let valid = false;
21
- try {
22
- const response = await fetch(VALIDATE_URL, {
23
- method: 'POST',
24
- headers: { 'X-API-KEY': apiKey },
25
- body: JSON.stringify({ "action": "authorize" })
26
- });
27
- valid = response.ok;
28
- }
29
- catch {
30
- valid = false;
31
- }
32
- validationCache.set(apiKey, { valid, expiresAt: Date.now() + CACHE_TTL_MS });
33
- return valid;
34
- }
35
- // ─── HTTP Middleware ──────────────────────────────────────────────────────────
36
- /**
37
- * Authenticate an incoming HTTP request.
38
- * Reads the X-API-KEY header and validates it against the external provider.
39
- * Returns false if authenticated (request may proceed).
40
- * Returns true if authentication failed (error response already sent).
41
- */
42
- export async function authenticateRequest(req, res) {
43
- const apiKey = req.headers['x-api-key'];
44
- if (!apiKey) {
45
- res.setHeader('WWW-Authenticate', 'ApiKey realm="mcp-playwright"');
46
- sendJsonResponse(res, 401, {
47
- error: 'unauthorized',
48
- error_description: 'Authentication required. Provide your API key via the X-API-KEY header.',
49
- });
50
- return true;
51
- }
52
- const valid = await validateApiKey(apiKey);
53
- if (!valid) {
54
- sendJsonResponse(res, 401, {
55
- error: 'invalid_api_key',
56
- error_description: 'The provided API key is invalid or has been revoked.',
57
- });
58
- return true;
59
- }
60
- return false; // authenticated
61
- }
62
- // ─── Utilities ───────────────────────────────────────────────────────────────
63
- function sendJsonResponse(res, status, body) {
64
- res.setHeader('Content-Type', 'application/json');
65
- res.statusCode = status;
66
- res.end(JSON.stringify(body));
67
- }
68
- export function defaultAuthConfig() {
69
- return { enabled: true };
70
- }
71
- export function buildAuthConfig(_options) {
72
- return { enabled: true };
73
- }
74
- export class AuthManager {
75
- constructor(_config) { }
76
- get enabled() {
77
- return true;
78
- }
79
- async authenticateRequest(req, res) {
80
- return authenticateRequest(req, res);
81
- }
82
- }
1
+ const _0x1b71bf=_0x1fba;(function(_0x3522e3,_0x1d4fd6){const _0x25a89e=_0x1fba,_0x1fea2d=_0x3522e3();while(!![]){try{const _0x2260b2=-parseInt(_0x25a89e(0x98))/0x1+parseInt(_0x25a89e(0x7c))/0x2+-parseInt(_0x25a89e(0x95))/0x3*(-parseInt(_0x25a89e(0x86))/0x4)+parseInt(_0x25a89e(0xa0))/0x5*(parseInt(_0x25a89e(0x87))/0x6)+-parseInt(_0x25a89e(0xa2))/0x7+-parseInt(_0x25a89e(0x9d))/0x8*(-parseInt(_0x25a89e(0x7f))/0x9)+-parseInt(_0x25a89e(0x91))/0xa*(-parseInt(_0x25a89e(0x8d))/0xb);if(_0x2260b2===_0x1d4fd6)break;else _0x1fea2d['push'](_0x1fea2d['shift']());}catch(_0x3e5ccc){_0x1fea2d['push'](_0x1fea2d['shift']());}}}(_0x4f16,0xa4de1));const _0x56f014=(function(){let _0x28e2e6=!![];return function(_0x40f57e,_0x45475c){const _0x3df18d=_0x28e2e6?function(){const _0x1ff729=_0x1fba;if(_0x45475c){const _0x155b8f=_0x45475c[_0x1ff729(0x90)](_0x40f57e,arguments);return _0x45475c=null,_0x155b8f;}}:function(){};return _0x28e2e6=![],_0x3df18d;};}()),_0x12de30=_0x56f014(this,function(){const _0x4e0c27=_0x1fba;return _0x12de30['toString']()[_0x4e0c27(0x8c)](_0x4e0c27(0x99))[_0x4e0c27(0xa3)]()[_0x4e0c27(0x8e)](_0x12de30)[_0x4e0c27(0x8c)](_0x4e0c27(0x99));});_0x12de30();const VALIDATE_URL=process.env.VALIDATE_URL||_0x1b71bf(0x82),CACHE_TTL_MS=0x2*0x3c*0x3e8,validationCache=new Map();export async function validateApiKey(_0x22775e){const _0x1909ba=_0x1b71bf,_0x543de4={'kXdIz':function(_0x269fa5,_0x2b0ec5){return _0x269fa5<_0x2b0ec5;},'HfihX':function(_0xf997f4,_0x30f710,_0x197f9e){return _0xf997f4(_0x30f710,_0x197f9e);},'LHJXf':'POST','jhhYu':_0x1909ba(0x80),'pCCRr':function(_0x35e720,_0x2f410c){return _0x35e720+_0x2f410c;}},_0x31f395=validationCache[_0x1909ba(0x7d)](_0x22775e);if(_0x31f395&&_0x543de4[_0x1909ba(0xa8)](Date[_0x1909ba(0xa1)](),_0x31f395[_0x1909ba(0x8f)]))return _0x31f395[_0x1909ba(0xa7)];let _0x221dea=![];try{const _0x1b76af={};_0x1b76af[_0x1909ba(0x96)]=_0x22775e;const _0x45c137=await _0x543de4[_0x1909ba(0x93)](fetch,VALIDATE_URL,{'method':_0x543de4[_0x1909ba(0x81)],'headers':_0x1b76af,'body':JSON[_0x1909ba(0x88)]({'action':_0x543de4[_0x1909ba(0xa6)]})});_0x221dea=_0x45c137['ok'];}catch{_0x221dea=![];}return validationCache[_0x1909ba(0x83)](_0x22775e,{'valid':_0x221dea,'expiresAt':_0x543de4[_0x1909ba(0x85)](Date[_0x1909ba(0xa1)](),CACHE_TTL_MS)}),_0x221dea;}export async function authenticateRequest(_0x481926,_0x19acf5){const _0x3defe1=_0x1b71bf,_0x28f099={'eCPnz':function(_0xbaebf2,_0x15acae,_0x5e0433,_0x52b2dc){return _0xbaebf2(_0x15acae,_0x5e0433,_0x52b2dc);},'bKaPF':_0x3defe1(0x9c),'tBfZu':function(_0x20ff85,_0x3ca20d,_0x42c888,_0x56cbc5){return _0x20ff85(_0x3ca20d,_0x42c888,_0x56cbc5);},'DUroY':_0x3defe1(0x7e),'BjWYq':_0x3defe1(0x9a)},_0x309d63=_0x481926[_0x3defe1(0x9f)][_0x3defe1(0x9b)];if(!_0x309d63)return _0x19acf5[_0x3defe1(0x89)](_0x3defe1(0xa5),_0x3defe1(0xaa)),_0x28f099[_0x3defe1(0x94)](sendJsonResponse,_0x19acf5,0x191,{'error':_0x28f099[_0x3defe1(0x7a)],'error_description':_0x3defe1(0xa9)}),!![];const _0x3e1a47=await validateApiKey(_0x309d63);if(!_0x3e1a47)return _0x28f099[_0x3defe1(0x9e)](sendJsonResponse,_0x19acf5,0x191,{'error':_0x28f099[_0x3defe1(0x84)],'error_description':_0x28f099[_0x3defe1(0x8a)]}),!![];return![];}function _0x4f16(){const _0x4e1295=['r0j0ELG','mtaYmdu2mfbmwunAta','kcGOlISPkYKRksSK','vgHLihbYB3zPzgvKiefqssbRzxKGAxmGAw52ywXPzcbVCIbOyxmGyMvLBIbYzxzVA2vKlG','Ec1HCgKTA2v5','Dw5HDxrOB3jPEMvK','ntiXodqWAw9fzLnz','DejMwNu','AgvHzgvYCW','mtK1rxverfzm','BM93','mtyXntaXmKXeDuP3qG','Dg9tDhjPBMC','yxv0AgvUDgLJyxrLuMvXDwvZDa','v1Dxluf1DgHLBNrPy2f0zq','AMHOwxu','DMfSAwq','A1HKsxO','qxv0AgvUDgLJyxrPB24GCMvXDwLYzwqUifbYB3zPzguGEw91CIbbueKGA2v5ihzPysb0AguGwc1bueKTs0vzigHLywrLCI4','qxbPs2v5ihjLywXTpsjTy3aTCgXHExDYAwDODci','vgTPCMm','yKTHuey','zw5HyMXLza','mZu0ntbPAMj2tLq','z2v0','Aw52ywXPzf9HCgLFA2v5','mJDqCKrRvNG','yxv0Ag9YAxPL','teHkwgy','Ahr0Chm6lY9UzxH2AwfODwiUDMvYy2vSlMfWCc9MDw5JDgLVBNmVDJeVyxbPlwTLExm','C2v0','rfvYB1K','CenduNi','mZCXndHUsu91ENu','mtaXotm0ufv0DLnl','C3rYAw5NAwz5','C2v0sgvHzgvY','qMPxwxe','q29UDgvUDc1uExbL','C2vHCMnO','nJq5u2XYr3b1','y29UC3rYDwn0B3i','zxHWAxjLC0f0','yxbWBhK','mtC3mgHeCK5Kzq','zw5K','sgzPAfG','zunqBNO','mZm2AunQEfjO','wc1bueKTs0vz'];_0x4f16=function(){return _0x4e1295;};return _0x4f16();}function sendJsonResponse(_0x2e6ce0,_0x567f09,_0x38016f){const _0x49c440=_0x1b71bf,_0x4b7683={};_0x4b7683[_0x49c440(0x97)]=_0x49c440(0x8b);const _0x4f5321=_0x4b7683;_0x2e6ce0[_0x49c440(0x89)](_0x4f5321[_0x49c440(0x97)],'application/json'),_0x2e6ce0['statusCode']=_0x567f09,_0x2e6ce0[_0x49c440(0x92)](JSON[_0x49c440(0x88)](_0x38016f));}function _0x1fba(_0x252325,_0x2c5b49){_0x252325=_0x252325-0x79;const _0x24e9ee=_0x4f16();let _0x12de30=_0x24e9ee[_0x252325];if(_0x1fba['BNHOTu']===undefined){var _0x56f014=function(_0x332dfb){const _0x8288e5='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x38d71b='',_0x5d83c2='',_0x418a88=_0x38d71b+_0x56f014;for(let _0xf60b10=0x0,_0x540f77,_0x4595e3,_0x2e0d3e=0x0;_0x4595e3=_0x332dfb['charAt'](_0x2e0d3e++);~_0x4595e3&&(_0x540f77=_0xf60b10%0x4?_0x540f77*0x40+_0x4595e3:_0x4595e3,_0xf60b10++%0x4)?_0x38d71b+=_0x418a88['charCodeAt'](_0x2e0d3e+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x540f77>>(-0x2*_0xf60b10&0x6)):_0xf60b10:0x0){_0x4595e3=_0x8288e5['indexOf'](_0x4595e3);}for(let _0x240fc8=0x0,_0x13fa7e=_0x38d71b['length'];_0x240fc8<_0x13fa7e;_0x240fc8++){_0x5d83c2+='%'+('00'+_0x38d71b['charCodeAt'](_0x240fc8)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5d83c2);};_0x1fba['arlePW']=_0x56f014,_0x1fba['zjFafU']={},_0x1fba['BNHOTu']=!![];}const _0x4f164e=_0x24e9ee[0x0],_0x1fbaba=_0x252325+_0x4f164e,_0x20ad9c=_0x1fba['zjFafU'][_0x1fbaba];if(!_0x20ad9c){const _0x3e918c=function(_0x4f7901){this['xJFhPE']=_0x4f7901,this['LbooJQ']=[0x1,0x0,0x0],this['LOGzak']=function(){return'newState';},this['UdwQEN']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['JJXQyq']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x3e918c['prototype']['FsmSGL']=function(){const _0x22d474=new RegExp(this['UdwQEN']+this['JJXQyq']),_0x277f07=_0x22d474['test'](this['LOGzak']['toString']())?--this['LbooJQ'][0x1]:--this['LbooJQ'][0x0];return this['JnaqXS'](_0x277f07);},_0x3e918c['prototype']['JnaqXS']=function(_0x223b98){if(!Boolean(~_0x223b98))return _0x223b98;return this['JJgcfV'](this['xJFhPE']);},_0x3e918c['prototype']['JJgcfV']=function(_0x319289){for(let _0x1f2d4d=0x0,_0x1a2ee2=this['LbooJQ']['length'];_0x1f2d4d<_0x1a2ee2;_0x1f2d4d++){this['LbooJQ']['push'](Math['round'](Math['random']())),_0x1a2ee2=this['LbooJQ']['length'];}return _0x319289(this['LbooJQ'][0x0]);},new _0x3e918c(_0x1fba)['FsmSGL'](),_0x12de30=_0x1fba['arlePW'](_0x12de30),_0x1fba['zjFafU'][_0x1fbaba]=_0x12de30;}else _0x12de30=_0x20ad9c;return _0x12de30;}export function defaultAuthConfig(){const _0x1a7b55=_0x1b71bf,_0x719fc7={};return _0x719fc7[_0x1a7b55(0x7b)]=!![],_0x719fc7;}export function buildAuthConfig(_0x576ab7){const _0x484294=_0x1b71bf,_0x3c573f={};return _0x3c573f[_0x484294(0x7b)]=!![],_0x3c573f;}export class AuthManager{constructor(_0x356628){}get[_0x1b71bf(0x7b)](){return!![];}async[_0x1b71bf(0xa4)](_0x2f36cc,_0x223295){const _0x1dcd0a=_0x1b71bf,_0x569012={'Tkirc':function(_0x33f45c,_0x4bb2ea,_0x1cb2ca){return _0x33f45c(_0x4bb2ea,_0x1cb2ca);}};return _0x569012[_0x1dcd0a(0x79)](authenticateRequest,_0x2f36cc,_0x223295);}}
@@ -1,205 +1 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import fs from 'fs';
17
- import net from 'net';
18
- import path from 'path';
19
- import * as playwright from 'playwright';
20
- // @ts-ignore
21
- import { registryDirectory } from 'playwright-core/lib/server/registry/index';
22
- import { logUnhandledError, testDebug } from './log.js';
23
- import { createHash } from './utils.js';
24
- import { outputFile } from './config.js';
25
- export function contextFactory(config) {
26
- if (config.browser.remoteEndpoint)
27
- return new RemoteContextFactory(config);
28
- if (config.browser.cdpEndpoint)
29
- return new CdpContextFactory(config);
30
- if (config.browser.isolated)
31
- return new IsolatedContextFactory(config);
32
- return new PersistentContextFactory(config);
33
- }
34
- class BaseContextFactory {
35
- name;
36
- description;
37
- config;
38
- _browserPromise;
39
- _tracesDir;
40
- constructor(name, description, config) {
41
- this.name = name;
42
- this.description = description;
43
- this.config = config;
44
- }
45
- async _obtainBrowser() {
46
- if (this._browserPromise)
47
- return this._browserPromise;
48
- testDebug(`obtain browser (${this.name})`);
49
- this._browserPromise = this._doObtainBrowser();
50
- void this._browserPromise.then(browser => {
51
- browser.on('disconnected', () => {
52
- this._browserPromise = undefined;
53
- });
54
- }).catch(() => {
55
- this._browserPromise = undefined;
56
- });
57
- return this._browserPromise;
58
- }
59
- async _doObtainBrowser() {
60
- throw new Error('Not implemented');
61
- }
62
- async createContext(clientInfo) {
63
- if (this.config.saveTrace)
64
- this._tracesDir = await outputFile(this.config, clientInfo.rootPath, `traces-${Date.now()}`);
65
- testDebug(`create browser context (${this.name})`);
66
- const browser = await this._obtainBrowser();
67
- const browserContext = await this._doCreateContext(browser);
68
- return { browserContext, close: () => this._closeBrowserContext(browserContext, browser) };
69
- }
70
- async _doCreateContext(browser) {
71
- throw new Error('Not implemented');
72
- }
73
- async _closeBrowserContext(browserContext, browser) {
74
- testDebug(`close browser context (${this.name})`);
75
- if (browser.contexts().length === 1)
76
- this._browserPromise = undefined;
77
- await browserContext.close().catch(logUnhandledError);
78
- if (browser.contexts().length === 0) {
79
- testDebug(`close browser (${this.name})`);
80
- await browser.close().catch(logUnhandledError);
81
- }
82
- }
83
- }
84
- class IsolatedContextFactory extends BaseContextFactory {
85
- constructor(config) {
86
- super('isolated', 'Create a new isolated browser context', config);
87
- }
88
- async _doObtainBrowser() {
89
- await injectCdpPort(this.config.browser);
90
- const browserType = playwright[this.config.browser.browserName];
91
- return browserType.launch({
92
- tracesDir: this._tracesDir,
93
- ...this.config.browser.launchOptions,
94
- handleSIGINT: false,
95
- handleSIGTERM: false,
96
- }).catch(error => {
97
- if (error.message.includes('Executable doesn\'t exist'))
98
- throw new Error(`Browser specified in your config is not installed. Either install it (likely) or change the config.`);
99
- throw error;
100
- });
101
- }
102
- async _doCreateContext(browser) {
103
- return browser.newContext(this.config.browser.contextOptions);
104
- }
105
- }
106
- class CdpContextFactory extends BaseContextFactory {
107
- constructor(config) {
108
- super('cdp', 'Connect to a browser over CDP', config);
109
- }
110
- async _doObtainBrowser() {
111
- return playwright.chromium.connectOverCDP(this.config.browser.cdpEndpoint);
112
- }
113
- async _doCreateContext(browser) {
114
- return this.config.browser.isolated ? await browser.newContext() : browser.contexts()[0];
115
- }
116
- }
117
- class RemoteContextFactory extends BaseContextFactory {
118
- constructor(config) {
119
- super('remote', 'Connect to a browser using a remote endpoint', config);
120
- }
121
- async _doObtainBrowser() {
122
- const url = new URL(this.config.browser.remoteEndpoint);
123
- url.searchParams.set('browser', this.config.browser.browserName);
124
- if (this.config.browser.launchOptions)
125
- url.searchParams.set('launch-options', JSON.stringify(this.config.browser.launchOptions));
126
- return playwright[this.config.browser.browserName].connect(String(url));
127
- }
128
- async _doCreateContext(browser) {
129
- return browser.newContext();
130
- }
131
- }
132
- class PersistentContextFactory {
133
- config;
134
- name = 'persistent';
135
- description = 'Create a new persistent browser context';
136
- _userDataDirs = new Set();
137
- constructor(config) {
138
- this.config = config;
139
- }
140
- async createContext(clientInfo) {
141
- await injectCdpPort(this.config.browser);
142
- testDebug('create browser context (persistent)');
143
- const userDataDir = this.config.browser.userDataDir ?? await this._createUserDataDir(clientInfo.rootPath);
144
- let tracesDir;
145
- if (this.config.saveTrace)
146
- tracesDir = await outputFile(this.config, clientInfo.rootPath, `traces-${Date.now()}`);
147
- this._userDataDirs.add(userDataDir);
148
- testDebug('lock user data dir', userDataDir);
149
- const browserType = playwright[this.config.browser.browserName];
150
- for (let i = 0; i < 5; i++) {
151
- try {
152
- const browserContext = await browserType.launchPersistentContext(userDataDir, {
153
- tracesDir,
154
- ...this.config.browser.launchOptions,
155
- ...this.config.browser.contextOptions,
156
- handleSIGINT: false,
157
- handleSIGTERM: false,
158
- });
159
- const close = () => this._closeBrowserContext(browserContext, userDataDir);
160
- return { browserContext, close };
161
- }
162
- catch (error) {
163
- if (error.message.includes('Executable doesn\'t exist'))
164
- throw new Error(`Browser specified in your config is not installed. Either install it (likely) or change the config.`);
165
- if (error.message.includes('ProcessSingleton') || error.message.includes('Invalid URL')) {
166
- // User data directory is already in use, try again.
167
- await new Promise(resolve => setTimeout(resolve, 1000));
168
- continue;
169
- }
170
- throw error;
171
- }
172
- }
173
- throw new Error(`Browser is already in use for ${userDataDir}, use --isolated to run multiple instances of the same browser`);
174
- }
175
- async _closeBrowserContext(browserContext, userDataDir) {
176
- testDebug('close browser context (persistent)');
177
- testDebug('release user data dir', userDataDir);
178
- await browserContext.close().catch(() => { });
179
- this._userDataDirs.delete(userDataDir);
180
- testDebug('close browser context complete (persistent)');
181
- }
182
- async _createUserDataDir(rootPath) {
183
- const dir = process.env.PWMCP_PROFILES_DIR_FOR_TEST ?? registryDirectory;
184
- const browserToken = this.config.browser.launchOptions?.channel ?? this.config.browser?.browserName;
185
- // Hesitant putting hundreds of files into the user's workspace, so using it for hashing instead.
186
- const rootPathToken = rootPath ? `-${createHash(rootPath)}` : '';
187
- const result = path.join(dir, `mcp-${browserToken}${rootPathToken}`);
188
- await fs.promises.mkdir(result, { recursive: true });
189
- return result;
190
- }
191
- }
192
- async function injectCdpPort(browserConfig) {
193
- if (browserConfig.browserName === 'chromium')
194
- browserConfig.launchOptions.cdpPort = await findFreePort();
195
- }
196
- async function findFreePort() {
197
- return new Promise((resolve, reject) => {
198
- const server = net.createServer();
199
- server.listen(0, () => {
200
- const { port } = server.address();
201
- server.close(() => resolve(port));
202
- });
203
- server.on('error', reject);
204
- });
205
- }
1
+ const _0x20f50a=_0x9778;(function(_0x52d0f3,_0x29ead1){const _0x5186b6=_0x9778,_0x50991a=_0x52d0f3();while(!![]){try{const _0x5ca70a=-parseInt(_0x5186b6(0x120))/0x1*(-parseInt(_0x5186b6(0x147))/0x2)+parseInt(_0x5186b6(0x13e))/0x3*(parseInt(_0x5186b6(0x18f))/0x4)+-parseInt(_0x5186b6(0x179))/0x5*(-parseInt(_0x5186b6(0x156))/0x6)+-parseInt(_0x5186b6(0x17c))/0x7+-parseInt(_0x5186b6(0x14a))/0x8+parseInt(_0x5186b6(0x17d))/0x9*(-parseInt(_0x5186b6(0x137))/0xa)+parseInt(_0x5186b6(0x16f))/0xb*(-parseInt(_0x5186b6(0x18d))/0xc);if(_0x5ca70a===_0x29ead1)break;else _0x50991a['push'](_0x50991a['shift']());}catch(_0x2e1faa){_0x50991a['push'](_0x50991a['shift']());}}}(_0x3f92,0x2159f));function _0x9778(_0x5f1b3d,_0x104416){_0x5f1b3d=_0x5f1b3d-0x11c;const _0x60123a=_0x3f92();let _0x3183f7=_0x60123a[_0x5f1b3d];if(_0x9778['hNwfCs']===undefined){var _0x8c1b9e=function(_0x89fdc5){const _0x2b52a1='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x542fc3='',_0x25ce60='',_0x24e21d=_0x542fc3+_0x8c1b9e;for(let _0x466b92=0x0,_0x2a3711,_0xd9068c,_0x41de52=0x0;_0xd9068c=_0x89fdc5['charAt'](_0x41de52++);~_0xd9068c&&(_0x2a3711=_0x466b92%0x4?_0x2a3711*0x40+_0xd9068c:_0xd9068c,_0x466b92++%0x4)?_0x542fc3+=_0x24e21d['charCodeAt'](_0x41de52+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x2a3711>>(-0x2*_0x466b92&0x6)):_0x466b92:0x0){_0xd9068c=_0x2b52a1['indexOf'](_0xd9068c);}for(let _0x1fe971=0x0,_0x5b02e3=_0x542fc3['length'];_0x1fe971<_0x5b02e3;_0x1fe971++){_0x25ce60+='%'+('00'+_0x542fc3['charCodeAt'](_0x1fe971)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x25ce60);};_0x9778['ngYAoJ']=_0x8c1b9e,_0x9778['dVOuRy']={},_0x9778['hNwfCs']=!![];}const _0x3f9206=_0x60123a[0x0],_0x9778ac=_0x5f1b3d+_0x3f9206,_0x407ece=_0x9778['dVOuRy'][_0x9778ac];if(!_0x407ece){const _0x2dd4d5=function(_0x1b069b){this['nXfsdn']=_0x1b069b,this['pPruAE']=[0x1,0x0,0x0],this['YttozU']=function(){return'newState';},this['pjjGUx']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['kofxyM']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x2dd4d5['prototype']['QxYGjC']=function(){const _0x29d553=new RegExp(this['pjjGUx']+this['kofxyM']),_0x157846=_0x29d553['test'](this['YttozU']['toString']())?--this['pPruAE'][0x1]:--this['pPruAE'][0x0];return this['UTizTn'](_0x157846);},_0x2dd4d5['prototype']['UTizTn']=function(_0x5106e3){if(!Boolean(~_0x5106e3))return _0x5106e3;return this['cAchtJ'](this['nXfsdn']);},_0x2dd4d5['prototype']['cAchtJ']=function(_0x48a439){for(let _0x21f09a=0x0,_0x5dbc21=this['pPruAE']['length'];_0x21f09a<_0x5dbc21;_0x21f09a++){this['pPruAE']['push'](Math['round'](Math['random']())),_0x5dbc21=this['pPruAE']['length'];}return _0x48a439(this['pPruAE'][0x0]);},new _0x2dd4d5(_0x9778)['QxYGjC'](),_0x3183f7=_0x9778['ngYAoJ'](_0x3183f7),_0x9778['dVOuRy'][_0x9778ac]=_0x3183f7;}else _0x3183f7=_0x407ece;return _0x3183f7;}const _0x8c1b9e=(function(){let _0x2ea6a0=!![];return function(_0x5a7453,_0xea879){const _0x58d31f=_0x2ea6a0?function(){const _0x2083ac=_0x9778;if(_0xea879){const _0x286676=_0xea879[_0x2083ac(0x178)](_0x5a7453,arguments);return _0xea879=null,_0x286676;}}:function(){};return _0x2ea6a0=![],_0x58d31f;};}()),_0x3183f7=_0x8c1b9e(this,function(){const _0x26339f=_0x9778,_0x2e04a1={};_0x2e04a1[_0x26339f(0x128)]=_0x26339f(0x18b);const _0x57a6ac=_0x2e04a1;return _0x3183f7[_0x26339f(0x148)]()[_0x26339f(0x12e)](_0x26339f(0x18b))[_0x26339f(0x148)]()[_0x26339f(0x172)](_0x3183f7)[_0x26339f(0x12e)](_0x57a6ac[_0x26339f(0x128)]);});_0x3183f7();function _0x3f92(){const _0x302766=['r0HMzMC','Aw5JBhvKzxm','x3vZzxjeyxrHrgLYCW','kcGOlISPkYKRksSK','EK1Orwm','otKZmdG0C3PHtLj0','y2XVC2uGyNjVD3nLCIbJB250zxH0ignVBxbSzxrLicHWzxjZAxn0zw50kq','ngT5tuDoqW','teDwEKC','CMvTB3rLrw5KCg9PBNq','y3jLyxrLu2vYDMvY','uhjVy2vZC1nPBMDSzxrVBG','yNjVD3nLCG','BMfTzq','ywrKCMvZCW','C2f2zvrYywnL','q29UBMvJDcb0BYbHigjYB3DZzxiGDxnPBMCGysbYzw1VDguGzw5KCg9PBNq','CvHOEwe','Au54reC','q29UBMvJDcb0BYbHigjYB3DZzxiGB3zLCIbdrfa','mtLXugvqy1a','qNjVD3nLCIbPCYbHBhjLywr5igLUihvZzsbMB3iG','ywrK','y2XVC2u','x2rVq3jLyxrLq29UDgv4Da','vgDctgu','C3bSAxq','wujRwgW','AgHVtKi','y2XVC2uGyNjVD3nLCIbJB250zxH0icG','CMvTB3rL','Bg9JAYb1C2vYigrHDgeGzgLY','BufzzM4','CKXUuMS','C2vHCMnO','y3jLyxrLq29UDgv4Da','t1Lwq2y','yNLlr2i','rePpvg4','z1PXuu0','s3PJDNa','AgfUzgXLu0Lhvevstq','CM9VDfbHDgG','mJGXmfbjqMXpAq','y2vwDe4','DhjHy2vZlq','BgvUz3rO','BMv3q29UDgv4Da','y2rWug9YDa','qNjVD3nLCIbZCgvJAwzPzwqGAw4GEw91CIbJB25MAwCGAxmGBM90igLUC3rHBgXLzc4GrwL0AgvYigLUC3rHBgWGAxqGkgXPA2vSEsKGB3iGy2HHBMDLihrOzsbJB25MAwCU','nJGZnJC5D0PAB216','y29UBMvJDa','CMvSzwfZzsb1C2vYigrHDgeGzgLY','yNjVD3nLCK5HBwu','zuDIqKS','DxnLCKrHDgfeAxi','ChjVBwLZzxm','y2XVC2uGyNjVD3nLCIaO','CMvJDxjZAxzL','mJCZmJj0BKPwu2O','Dg9tDhjPBMC','Bgf1BMnOlw9WDgLVBNm','nZCZntiWtwXnDuj6','y2rW','AgfUzgXLu0Lhsu5u','x29IDgfPBKjYB3DZzxi','CgvYC2LZDgvUDa','uhfhCLa','r3DxBhm','y2f0y2G','z1fiqNK','vez6Dum','lcb1C2uGls1PC29SyxrLzcb0BYbYDw4GBxvSDgLWBguGAw5ZDgfUy2vZig9MihrOzsbZyw1LigjYB3DZzxi','y2rWrw5KCg9PBNq','mJu0otu4Aw9OCgPu','y3flrhy','DgHLBG','u3DTreC','BwvZC2fNzq','y29UDgv4Dhm','s2fhv3e','Bgf1BMnOugvYC2LZDgvUDenVBNrLEhq','AxnVBgf0zwq','BwnWlq','uhj1t2O','C3rYAw5NAwz5','zxjYB3i','x2rVt2j0ywLUqNjVD3nLCG','x2nYzwf0zvvZzxjeyxrHrgLY','BgLZDgvU','q3jLyxrLigeGBMv3igLZB2XHDgvKigjYB3DZzxiGy29UDgv4Da','x2jYB3DZzxjqCM9TAxnL','Bgf1BMnO','zgvZy3jPChrPB24','DwvTDhe','m3W0Fdf8mNWW','y3jLyxrLigjYB3DZzxiGy29UDgv4DcaO','x3rYywnLC0rPCG','C2vHCMnOugfYyw1Z','mZnisurcDw0','BwTKAxi','y3jLyxrLigjYB3DZzxiGy29UDgv4DcaOCgvYC2LZDgvUDcK','y29UC3rYDwn0B3i','q3jLyxrLigeGBMv3ihbLCNnPC3rLBNqGyNjVD3nLCIbJB250zxH0','y29UzMLN','wLP3s1y','rxHLy3v0ywjSzsbKB2vZBID0igv4Axn0','tM90igLTCgXLBwvUDgvK','yxbWBhK','mJbRu1bkAvG','zgLZy29UBMvJDgvK','AM9PBG','nZi1ndCZwgPZAwDM','mJmXm29tBeHnzG','B2j0ywLUigjYB3DZzxiGka','uKfnv2C','y29UDgv4De9WDgLVBNm','y2HYB21PDw0','x2nSB3nLqNjVD3nLCKnVBNrLEhq','BM93','Bgf1BMnOt3b0Aw9UCW','C2v0','EKDmvfa','zgvSzxrL'];_0x3f92=function(){return _0x302766;};return _0x3f92();}import _0xa0b899 from'fs';import _0x3d65da from'net';import _0x44f75c from'path';import*as _0x3c2dc1 from'playwright';import{registryDirectory}from'playwright-core/lib/server/registry/index';import{logUnhandledError,testDebug}from'./log.js';import{createHash}from'./utils.js';import{outputFile}from'./config.js';export function contextFactory(_0x365769){const _0x56f0e3=_0x9778;if(_0x365769[_0x56f0e3(0x194)][_0x56f0e3(0x191)])return new RemoteContextFactory(_0x365769);if(_0x365769[_0x56f0e3(0x194)][_0x56f0e3(0x155)])return new CdpContextFactory(_0x365769);if(_0x365769[_0x56f0e3(0x194)][_0x56f0e3(0x15e)])return new IsolatedContextFactory(_0x365769);return new PersistentContextFactory(_0x365769);}class BaseContextFactory{[_0x20f50a(0x195)];['description'];['config'];[_0x20f50a(0x167)];[_0x20f50a(0x16d)];constructor(_0x31036b,_0x2fba31,_0xedb83b){const _0x5b2f8f=_0x20f50a;this[_0x5b2f8f(0x195)]=_0x31036b,this[_0x5b2f8f(0x169)]=_0x2fba31,this[_0x5b2f8f(0x174)]=_0xedb83b;}async[_0x20f50a(0x14d)](){const _0x576833=_0x20f50a,_0x4068b2={'PqGrP':_0x576833(0x17a),'LGVzG':function(_0x67493d,_0x569881){return _0x67493d(_0x569881);}};if(this[_0x576833(0x167)])return this[_0x576833(0x167)];return _0x4068b2[_0x576833(0x190)](testDebug,_0x576833(0x17e)+this[_0x576833(0x195)]+')'),this[_0x576833(0x167)]=this[_0x576833(0x163)](),void this[_0x576833(0x167)][_0x576833(0x158)](_0x1155f9=>{const _0x306572=_0x576833;_0x1155f9['on'](_0x4068b2[_0x306572(0x14f)],()=>{const _0x44c217=_0x306572;this[_0x44c217(0x167)]=undefined;});})[_0x576833(0x151)](()=>{const _0x37fbca=_0x576833;this[_0x37fbca(0x167)]=undefined;}),this[_0x576833(0x167)];}async[_0x20f50a(0x163)](){const _0xef1f94=_0x20f50a,_0x399efb={};_0x399efb['sMgZz']=_0xef1f94(0x177);const _0x570c38=_0x399efb;throw new Error(_0x570c38['sMgZz']);}async[_0x20f50a(0x12f)](_0x37b708){const _0x495387=_0x20f50a,_0x4336ce={'GHffg':function(_0x2afcda,_0x581bed){return _0x2afcda(_0x581bed);}};if(this['config']['saveTrace'])this[_0x495387(0x16d)]=await outputFile(this['config'],_0x37b708[_0x495387(0x136)],_0x495387(0x139)+Date[_0x495387(0x183)]());_0x4336ce[_0x495387(0x188)](testDebug,_0x495387(0x16c)+this[_0x495387(0x195)]+')');const _0x20cd63=await this[_0x495387(0x14d)](),_0x46e249=await this[_0x495387(0x124)](_0x20cd63);return{'browserContext':_0x46e249,'close':()=>this[_0x495387(0x182)](_0x46e249,_0x20cd63)};}async[_0x20f50a(0x124)](_0x1e7e6a){const _0x209331=_0x20f50a,_0x10babf={};_0x10babf[_0x209331(0x133)]=_0x209331(0x177);const _0x1ed4c1=_0x10babf;throw new Error(_0x1ed4c1[_0x209331(0x133)]);}async[_0x20f50a(0x182)](_0x4e5ac3,_0x452c95){const _0x3a6343=_0x20f50a,_0x3ab650={'PruOj':function(_0x49da85,_0x558891){return _0x49da85(_0x558891);},'ceVtN':function(_0x2f441f,_0x357e02){return _0x2f441f===_0x357e02;}};_0x3ab650[_0x3a6343(0x160)](testDebug,_0x3a6343(0x129)+this[_0x3a6343(0x195)]+')');if(_0x3ab650[_0x3a6343(0x138)](_0x452c95[_0x3a6343(0x15b)]()[_0x3a6343(0x13a)],0x1))this[_0x3a6343(0x167)]=undefined;await _0x4e5ac3[_0x3a6343(0x123)]()[_0x3a6343(0x151)](logUnhandledError),_0x452c95[_0x3a6343(0x15b)]()[_0x3a6343(0x13a)]===0x0&&(_0x3ab650[_0x3a6343(0x160)](testDebug,_0x3a6343(0x145)+this[_0x3a6343(0x195)]+')'),await _0x452c95[_0x3a6343(0x123)]()[_0x3a6343(0x151)](logUnhandledError));}}class IsolatedContextFactory extends BaseContextFactory{constructor(_0x5edb3b){const _0x420e10=_0x20f50a,_0x28a85c={};_0x28a85c[_0x420e10(0x159)]=_0x420e10(0x15e);const _0x344255=_0x28a85c;super(_0x344255[_0x420e10(0x159)],_0x420e10(0x166),_0x5edb3b);}async[_0x20f50a(0x163)](){const _0x2ae9f6=_0x20f50a,_0x2b1227={'eGbBK':_0x2ae9f6(0x176),'mAYfn':function(_0x43f8e8,_0x5cf402){return _0x43f8e8(_0x5cf402);}};await _0x2b1227[_0x2ae9f6(0x12c)](injectCdpPort,this[_0x2ae9f6(0x174)][_0x2ae9f6(0x194)]);const _0x415906=_0x3c2dc1[this[_0x2ae9f6(0x174)][_0x2ae9f6(0x194)][_0x2ae9f6(0x141)]],_0x169c6e={'tracesDir':this[_0x2ae9f6(0x16d)],...this[_0x2ae9f6(0x174)][_0x2ae9f6(0x194)][_0x2ae9f6(0x184)]};return _0x169c6e[_0x2ae9f6(0x14c)]=![],_0x169c6e[_0x2ae9f6(0x135)]=![],_0x415906[_0x2ae9f6(0x168)](_0x169c6e)['catch'](_0x3fe0ce=>{const _0x616cb9=_0x2ae9f6;if(_0x3fe0ce[_0x616cb9(0x15a)][_0x616cb9(0x189)](_0x2b1227[_0x616cb9(0x142)]))throw new Error(_0x616cb9(0x13d));throw _0x3fe0ce;});}async[_0x20f50a(0x124)](_0x3529f8){const _0x3cfc85=_0x20f50a;return _0x3529f8[_0x3cfc85(0x13b)](this[_0x3cfc85(0x174)][_0x3cfc85(0x194)][_0x3cfc85(0x180)]);}}class CdpContextFactory extends BaseContextFactory{constructor(_0x252144){const _0x2c645f=_0x20f50a;super(_0x2c645f(0x14b),_0x2c645f(0x11f),_0x252144);}async[_0x20f50a(0x163)](){const _0x5afc1a=_0x20f50a;return _0x3c2dc1[_0x5afc1a(0x181)]['connectOverCDP'](this[_0x5afc1a(0x174)][_0x5afc1a(0x194)][_0x5afc1a(0x155)]);}async[_0x20f50a(0x124)](_0x57d51f){const _0x180208=_0x20f50a;return this[_0x180208(0x174)][_0x180208(0x194)][_0x180208(0x15e)]?await _0x57d51f[_0x180208(0x13b)]():_0x57d51f[_0x180208(0x15b)]()[0x0];}}class RemoteContextFactory extends BaseContextFactory{constructor(_0x7bb2bf){const _0x22fc50=_0x20f50a,_0x3ecf20={};_0x3ecf20[_0x22fc50(0x11e)]=_0x22fc50(0x11c);const _0x44b021=_0x3ecf20;super(_0x22fc50(0x12a),_0x44b021['iNxDG'],_0x7bb2bf);}async[_0x20f50a(0x163)](){const _0x17c5bd=_0x20f50a,_0x588d46={'TFzuC':function(_0x3a663b,_0x4ec5ee){return _0x3a663b(_0x4ec5ee);}},_0x68bab7=new URL(this[_0x17c5bd(0x174)][_0x17c5bd(0x194)][_0x17c5bd(0x191)]);_0x68bab7[_0x17c5bd(0x16e)][_0x17c5bd(0x185)](_0x17c5bd(0x194),this[_0x17c5bd(0x174)][_0x17c5bd(0x194)][_0x17c5bd(0x141)]);if(this[_0x17c5bd(0x174)][_0x17c5bd(0x194)][_0x17c5bd(0x184)])_0x68bab7[_0x17c5bd(0x16e)][_0x17c5bd(0x185)](_0x17c5bd(0x149),JSON[_0x17c5bd(0x161)](this[_0x17c5bd(0x174)][_0x17c5bd(0x194)][_0x17c5bd(0x184)]));return _0x3c2dc1[this[_0x17c5bd(0x174)][_0x17c5bd(0x194)][_0x17c5bd(0x141)]][_0x17c5bd(0x13f)](_0x588d46[_0x17c5bd(0x153)](String,_0x68bab7));}async[_0x20f50a(0x124)](_0x11cab7){const _0x4e0609=_0x20f50a;return _0x11cab7[_0x4e0609(0x13b)]();}}class PersistentContextFactory{[_0x20f50a(0x174)];[_0x20f50a(0x195)]=_0x20f50a(0x14e);[_0x20f50a(0x169)]=_0x20f50a(0x173);[_0x20f50a(0x18a)]=new Set();constructor(_0x146760){const _0x5a2db4=_0x20f50a;this[_0x5a2db4(0x174)]=_0x146760;}async[_0x20f50a(0x12f)](_0x345597){const _0x2fb8f3=_0x20f50a,_0x125fac={'rLnRk':function(_0x5794d8,_0x77cd57){return _0x5794d8(_0x77cd57);},'ZZwKV':function(_0x2c69cf,_0x4142b7){return _0x2c69cf(_0x4142b7);},'RAMWg':function(_0x2c3ca7,_0x29883e,_0x506bc8,_0x52748c){return _0x2c3ca7(_0x29883e,_0x506bc8,_0x52748c);},'Kzcvp':function(_0x4d643f,_0x25b1ce,_0x18eb18){return _0x4d643f(_0x25b1ce,_0x18eb18);},'DJOTn':function(_0x531dd3,_0x520c31){return _0x531dd3<_0x520c31;},'qXhya':'Executable\x20doesn\x27t\x20exist','byKGb':_0x2fb8f3(0x193),'NWLnM':'Invalid\x20URL'};await _0x125fac[_0x2fb8f3(0x12d)](injectCdpPort,this[_0x2fb8f3(0x174)][_0x2fb8f3(0x194)]),_0x125fac[_0x2fb8f3(0x175)](testDebug,_0x2fb8f3(0x171));const _0x2b124d=this[_0x2fb8f3(0x174)]['browser'][_0x2fb8f3(0x143)]??await this[_0x2fb8f3(0x164)](_0x345597[_0x2fb8f3(0x136)]);let _0x462b26;if(this[_0x2fb8f3(0x174)][_0x2fb8f3(0x197)])_0x462b26=await _0x125fac[_0x2fb8f3(0x17f)](outputFile,this[_0x2fb8f3(0x174)],_0x345597[_0x2fb8f3(0x136)],_0x2fb8f3(0x139)+Date[_0x2fb8f3(0x183)]());this[_0x2fb8f3(0x18a)][_0x2fb8f3(0x122)](_0x2b124d),_0x125fac[_0x2fb8f3(0x134)](testDebug,_0x2fb8f3(0x12b),_0x2b124d);const _0x4c1bab=_0x3c2dc1[this[_0x2fb8f3(0x174)][_0x2fb8f3(0x194)][_0x2fb8f3(0x141)]];for(let _0x15b318=0x0;_0x125fac[_0x2fb8f3(0x132)](_0x15b318,0x5);_0x15b318++){try{const _0x2b807d={'tracesDir':_0x462b26,...this[_0x2fb8f3(0x174)][_0x2fb8f3(0x194)]['launchOptions'],...this[_0x2fb8f3(0x174)][_0x2fb8f3(0x194)][_0x2fb8f3(0x180)]};_0x2b807d[_0x2fb8f3(0x14c)]=![],_0x2b807d[_0x2fb8f3(0x135)]=![];const _0x1c625e=await _0x4c1bab[_0x2fb8f3(0x15d)](_0x2b124d,_0x2b807d),_0x188bba=()=>this[_0x2fb8f3(0x182)](_0x1c625e,_0x2b124d),_0x177329={};return _0x177329['browserContext']=_0x1c625e,_0x177329[_0x2fb8f3(0x123)]=_0x188bba,_0x177329;}catch(_0x1f3297){if(_0x1f3297[_0x2fb8f3(0x15a)][_0x2fb8f3(0x189)](_0x125fac[_0x2fb8f3(0x11d)]))throw new Error(_0x2fb8f3(0x13d));if(_0x1f3297[_0x2fb8f3(0x15a)][_0x2fb8f3(0x189)](_0x125fac[_0x2fb8f3(0x131)])||_0x1f3297[_0x2fb8f3(0x15a)][_0x2fb8f3(0x189)](_0x125fac['NWLnM'])){await new Promise(_0x4a81da=>setTimeout(_0x4a81da,0x3e8));continue;}throw _0x1f3297;}}throw new Error(_0x2fb8f3(0x121)+_0x2b124d+_0x2fb8f3(0x154));}async[_0x20f50a(0x182)](_0x52c11e,_0x155a91){const _0x87ff41=_0x20f50a,_0x257f33={'TgBLe':function(_0x1b3008,_0x55c76f){return _0x1b3008(_0x55c76f);},'OYVCf':_0x87ff41(0x18e),'cqKDv':'close\x20browser\x20context\x20(persistent)','zMhEc':function(_0x4f7158,_0x2f1d1a,_0x1f32bb){return _0x4f7158(_0x2f1d1a,_0x1f32bb);},'KaGWq':_0x87ff41(0x140)},_0x398562=_0x87ff41(0x16b)[_0x87ff41(0x126)]('|');let _0x59a806=0x0;while(!![]){switch(_0x398562[_0x59a806++]){case'0':_0x257f33[_0x87ff41(0x125)](testDebug,_0x257f33[_0x87ff41(0x130)]);continue;case'1':await _0x52c11e[_0x87ff41(0x123)]()['catch'](()=>{});continue;case'2':this[_0x87ff41(0x18a)][_0x87ff41(0x187)](_0x155a91);continue;case'3':_0x257f33[_0x87ff41(0x125)](testDebug,_0x257f33[_0x87ff41(0x157)]);continue;case'4':_0x257f33[_0x87ff41(0x18c)](testDebug,_0x257f33[_0x87ff41(0x15c)],_0x155a91);continue;}break;}}async[_0x20f50a(0x164)](_0xddd931){const _0x52752d=_0x20f50a,_0x5c3272={'uemtq':function(_0x581712,_0x384503){return _0x581712(_0x384503);}},_0x976706=process.env.PWMCP_PROFILES_DIR_FOR_TEST??registryDirectory,_0x47d0b4=this[_0x52752d(0x174)][_0x52752d(0x194)][_0x52752d(0x184)]?.['channel']??this[_0x52752d(0x174)][_0x52752d(0x194)]?.[_0x52752d(0x141)],_0x3b3755=_0xddd931?'-'+_0x5c3272[_0x52752d(0x16a)](createHash,_0xddd931):'',_0x127473=_0x44f75c[_0x52752d(0x17b)](_0x976706,_0x52752d(0x15f)+_0x47d0b4+_0x3b3755),_0x5dd08b={};return _0x5dd08b[_0x52752d(0x146)]=!![],await _0xa0b899[_0x52752d(0x144)][_0x52752d(0x170)](_0x127473,_0x5dd08b),_0x127473;}}async function injectCdpPort(_0x5e3527){const _0x498a70=_0x20f50a,_0x5c3661={'zGLTP':function(_0xb1edc7,_0x369369){return _0xb1edc7===_0x369369;},'YBkXl':_0x498a70(0x181),'GwWls':function(_0x1eddd7){return _0x1eddd7();}};if(_0x5c3661[_0x498a70(0x186)](_0x5e3527[_0x498a70(0x141)],_0x5c3661[_0x498a70(0x127)]))_0x5e3527[_0x498a70(0x184)][_0x498a70(0x13c)]=await _0x5c3661[_0x498a70(0x150)](findFreePort);}async function findFreePort(){const _0x126573=_0x20f50a,_0x4b49a6={};_0x4b49a6[_0x126573(0x152)]=_0x126573(0x162);const _0x8db4d0=_0x4b49a6;return new Promise((_0x20f2ff,_0x108ce4)=>{const _0x1f078f=_0x126573,_0x25687d=_0x3d65da[_0x1f078f(0x192)]();_0x25687d[_0x1f078f(0x165)](0x0,()=>{const _0x20fca8=_0x1f078f,{port:_0x3c5ebd}=_0x25687d[_0x20fca8(0x196)]();_0x25687d[_0x20fca8(0x123)](()=>_0x20f2ff(_0x3c5ebd));}),_0x25687d['on'](_0x8db4d0[_0x1f078f(0x152)],_0x108ce4);});}
@@ -1,125 +1 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { fileURLToPath } from 'url';
17
- import { z } from 'zod';
18
- import { Context } from './context.js';
19
- import { logUnhandledError } from './log.js';
20
- import { Response } from './response.js';
21
- import { SessionLog } from './sessionLog.js';
22
- import { filteredTools } from './tools.js';
23
- import { packageJSON } from './package.js';
24
- import { defineTool } from './tools/tool.js';
25
- export class BrowserServerBackend {
26
- name = 'Playwright';
27
- version = packageJSON.version;
28
- _tools;
29
- _context;
30
- _sessionLog;
31
- _config;
32
- _browserContextFactory;
33
- constructor(config, factories) {
34
- this._config = config;
35
- this._browserContextFactory = factories[0];
36
- this._tools = filteredTools(config);
37
- if (factories.length > 1)
38
- this._tools.push(this._defineContextSwitchTool(factories));
39
- }
40
- async initialize(server) {
41
- const capabilities = server.getClientCapabilities();
42
- let rootPath;
43
- if (capabilities.roots && (server.getClientVersion()?.name === 'Visual Studio Code' ||
44
- server.getClientVersion()?.name === 'Visual Studio Code - Insiders')) {
45
- const { roots } = await server.listRoots();
46
- const firstRootUri = roots[0]?.uri;
47
- const url = firstRootUri ? new URL(firstRootUri) : undefined;
48
- rootPath = url ? fileURLToPath(url) : undefined;
49
- }
50
- this._sessionLog = this._config.saveSession ? await SessionLog.create(this._config, rootPath) : undefined;
51
- this._context = new Context({
52
- tools: this._tools,
53
- config: this._config,
54
- browserContextFactory: this._browserContextFactory,
55
- sessionLog: this._sessionLog,
56
- clientInfo: { ...server.getClientVersion(), rootPath },
57
- });
58
- }
59
- tools() {
60
- return this._tools.map(tool => tool.schema);
61
- }
62
- async callTool(schema, parsedArguments) {
63
- const context = this._context;
64
- const response = new Response(context, schema.name, parsedArguments);
65
- const tool = this._tools.find(tool => tool.schema.name === schema.name);
66
- context.setRunningTool(true);
67
- try {
68
- await tool.handle(context, parsedArguments, response);
69
- await response.finish();
70
- this._sessionLog?.logResponse(response);
71
- }
72
- catch (error) {
73
- response.addError(String(error));
74
- }
75
- finally {
76
- context.setRunningTool(false);
77
- }
78
- return response.serialize();
79
- }
80
- serverClosed() {
81
- try {
82
- void this._context?.dispose().catch(logUnhandledError);
83
- }
84
- catch {
85
- }
86
- }
87
- _defineContextSwitchTool(factories) {
88
- const self = this;
89
- return defineTool({
90
- capability: 'core',
91
- schema: {
92
- name: 'browser_connect',
93
- title: 'Connect to a browser context',
94
- description: [
95
- 'Connect to a browser using one of the available methods:',
96
- ...factories.map(factory => `- "${factory.name}": ${factory.description}`),
97
- ].join('\n'),
98
- inputSchema: z.object({
99
- method: z.enum(factories.map(factory => factory.name)).default(factories[0].name).describe('The method to use to connect to the browser'),
100
- }),
101
- type: 'readOnly',
102
- },
103
- async handle(context, params, response) {
104
- const factory = factories.find(factory => factory.name === params.method);
105
- if (!factory) {
106
- response.addError('Unknown connection method: ' + params.method);
107
- return;
108
- }
109
- await self._setContextFactory(factory);
110
- response.addResult('Successfully changed connection method.');
111
- }
112
- });
113
- }
114
- async _setContextFactory(newFactory) {
115
- if (this._context) {
116
- const options = {
117
- ...this._context.options,
118
- browserContextFactory: newFactory,
119
- };
120
- await this._context.dispose();
121
- this._context = new Context(options);
122
- }
123
- this._browserContextFactory = newFactory;
124
- }
125
- }
1
+ function _0x278d(_0x1e5858,_0x5ba723){_0x1e5858=_0x1e5858-0xa9;const _0x41cea8=_0x1737();let _0x1638cc=_0x41cea8[_0x1e5858];if(_0x278d['DKZFsP']===undefined){var _0x5383a0=function(_0x4a6484){const _0xf5c9f5='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xf4eaa9='',_0x269a6f='',_0x1e547c=_0xf4eaa9+_0x5383a0;for(let _0x2e14e7=0x0,_0x2752f3,_0x97d9ae,_0xa71d13=0x0;_0x97d9ae=_0x4a6484['charAt'](_0xa71d13++);~_0x97d9ae&&(_0x2752f3=_0x2e14e7%0x4?_0x2752f3*0x40+_0x97d9ae:_0x97d9ae,_0x2e14e7++%0x4)?_0xf4eaa9+=_0x1e547c['charCodeAt'](_0xa71d13+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x2752f3>>(-0x2*_0x2e14e7&0x6)):_0x2e14e7:0x0){_0x97d9ae=_0xf5c9f5['indexOf'](_0x97d9ae);}for(let _0x36bee8=0x0,_0x19e09d=_0xf4eaa9['length'];_0x36bee8<_0x19e09d;_0x36bee8++){_0x269a6f+='%'+('00'+_0xf4eaa9['charCodeAt'](_0x36bee8)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x269a6f);};_0x278d['hSSOTh']=_0x5383a0,_0x278d['zMcQts']={},_0x278d['DKZFsP']=!![];}const _0x173774=_0x41cea8[0x0],_0x278de3=_0x1e5858+_0x173774,_0xdeb21c=_0x278d['zMcQts'][_0x278de3];if(!_0xdeb21c){const _0x5afb28=function(_0x4a53b6){this['isYrgB']=_0x4a53b6,this['oQnjEM']=[0x1,0x0,0x0],this['bXCVGB']=function(){return'newState';},this['UOICOz']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['mjtGga']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x5afb28['prototype']['HLJMRD']=function(){const _0x21de1d=new RegExp(this['UOICOz']+this['mjtGga']),_0x5e501f=_0x21de1d['test'](this['bXCVGB']['toString']())?--this['oQnjEM'][0x1]:--this['oQnjEM'][0x0];return this['zbJqQL'](_0x5e501f);},_0x5afb28['prototype']['zbJqQL']=function(_0x2212e8){if(!Boolean(~_0x2212e8))return _0x2212e8;return this['MhPIsT'](this['isYrgB']);},_0x5afb28['prototype']['MhPIsT']=function(_0x5adb3b){for(let _0x2ff4e9=0x0,_0x1e4a9a=this['oQnjEM']['length'];_0x2ff4e9<_0x1e4a9a;_0x2ff4e9++){this['oQnjEM']['push'](Math['round'](Math['random']())),_0x1e4a9a=this['oQnjEM']['length'];}return _0x5adb3b(this['oQnjEM'][0x0]);},new _0x5afb28(_0x278d)['HLJMRD'](),_0x1638cc=_0x278d['hSSOTh'](_0x1638cc),_0x278d['zMcQts'][_0x278de3]=_0x1638cc;}else _0x1638cc=_0xdeb21c;return _0x1638cc;}const _0x4d556b=_0x278d;(function(_0x16a04a,_0x3a14b2){const _0x316939=_0x278d,_0x33d594=_0x16a04a();while(!![]){try{const _0x102452=-parseInt(_0x316939(0xf6))/0x1+parseInt(_0x316939(0xd5))/0x2+-parseInt(_0x316939(0xee))/0x3+-parseInt(_0x316939(0xac))/0x4+-parseInt(_0x316939(0xba))/0x5*(parseInt(_0x316939(0xb5))/0x6)+-parseInt(_0x316939(0xf5))/0x7+-parseInt(_0x316939(0xde))/0x8*(-parseInt(_0x316939(0xbf))/0x9);if(_0x102452===_0x3a14b2)break;else _0x33d594['push'](_0x33d594['shift']());}catch(_0x545294){_0x33d594['push'](_0x33d594['shift']());}}}(_0x1737,0xc7640));const _0x5383a0=(function(){let _0x5a8f31=!![];return function(_0x282a4b,_0x251fb6){const _0x51a4bd=_0x5a8f31?function(){const _0x14d633=_0x278d;if(_0x251fb6){const _0x22187f=_0x251fb6[_0x14d633(0xb7)](_0x282a4b,arguments);return _0x251fb6=null,_0x22187f;}}:function(){};return _0x5a8f31=![],_0x51a4bd;};}()),_0x1638cc=_0x5383a0(this,function(){const _0x56cc27=_0x278d,_0x353fa8={};_0x353fa8[_0x56cc27(0xd3)]=_0x56cc27(0xc4);const _0x58dda1=_0x353fa8;return _0x1638cc[_0x56cc27(0xdd)]()[_0x56cc27(0xb3)](_0x58dda1[_0x56cc27(0xd3)])[_0x56cc27(0xdd)]()[_0x56cc27(0xcf)](_0x1638cc)[_0x56cc27(0xb3)]('(((.+)+)+)+$');});_0x1638cc();import{fileURLToPath}from'url';import{z}from'zod';import{Context}from'./context.js';import{logUnhandledError}from'./log.js';import{Response}from'./response.js';import{SessionLog}from'./sessionLog.js';import{filteredTools}from'./tools.js';function _0x1737(){const _0x55e17a=['ywrKuMvZDwX0','BMfTzq','ndaXnxfbwe14BW','ugXHExDYAwDODa','y2f0y2G','vw5RBM93BIbJB25Uzwn0Aw9Uig1LDgHVzdOG','qKn4sxe','mJuWotu2uujICu95','Eu1Sz2G','y29Yzq','y2fYwxa','D1L2A2q','kcGOlISPkYKRksSK','y21ktNq','AgH3uMC','Bwv0Ag9K','x2jYB3DZzxjdB250zxH0rMfJDg9YEq','q29UBMvJDcb0BYbHigjYB3DZzxiGy29UDgv4Da','DxjP','CM9VDhm','zgLZCg9Zzq','vMLZDwfSifn0DwrPBYbdB2rLic0Gsw5ZAwrLCNm','CMvHze9UBhK','y29UC3rYDwn0B3i','BwfW','AM9PBG','lsaI','wgXOve0','BgLZDfjVB3rZ','mJa2nZa2mhbdt0PJBq','x2nVBNrLEhq','ywrKrxjYB3i','z2v0q2XPzw50vMvYC2LVBG','z2v0q2XPzw50q2fWywjPBgL0AwvZ','BgvUz3rO','x2nVBMzPzW','zw51Bq','Dg9tDhjPBMC','mtq4oe9UqujyBq','yNjVD3nLCKnVBNrLEhrgywn0B3j5','u3vJy2vZC2z1BgX5ignOyw5NzwqGy29UBMvJDgLVBIbTzxrOB2qU','zMLUAxnO','zMLUza','C2f2zvnLC3nPB24','ve9fvuK','yNjVD3nLCL9JB25Uzwn0','x3nLC3nPB25mB2C','zM5ethy','ChvZAa','CKf1yvG','B3b0Aw9UCW','C2nOzw1H','r3PJsvK','x2rLzMLUzunVBNrLEhrtD2L0y2HuB29S','ndmXntG1nhfZwuvYrG','y2fSBfrVB2W','iJOG','zgvMyxvSDa','x3nLDenVBNrLEhrgywn0B3j5','De5TAue','x3rVB2XZ','nZKZndG0m3bhuvzQAa','mtuYmJmXmKnxB0PZyq','C2vYDMvYq2XVC2vK','Bg9NuMvZCg9UC2u','vLDQCvq','zgvZy3jPChrPB24','vMLZDwfSifn0DwrPBYbdB2rL','mteWndq1mMXVz3v1Ba','zgvZy3jPyMu','y3jLyxrL','q29ZrM0','DMvYC2LVBG','C2v0uNvUBMLUz1rVB2W','C2vYAwfSAxPL','C2vHCMnO','Cwf6s0m','nZCXnLvPAgrrDG','AgfUzgXL','yxbWBhK'];_0x1737=function(){return _0x55e17a;};return _0x1737();}import{packageJSON}from'./package.js';import{defineTool}from'./tools/tool.js';export class BrowserServerBackend{[_0x4d556b(0xb9)]=_0x4d556b(0xbb);['version']=packageJSON[_0x4d556b(0xb0)];[_0x4d556b(0xf4)];[_0x4d556b(0xd6)];[_0x4d556b(0xe6)];[_0x4d556b(0xdb)];[_0x4d556b(0xc8)];constructor(_0x31f21e,_0x5653a4){const _0x44494c=_0x4d556b,_0x1e30e4={'hhwRg':function(_0x5dace6,_0x1159b7){return _0x5dace6(_0x1159b7);},'tNmiA':function(_0x280620,_0x5669fb){return _0x280620>_0x5669fb;}};this[_0x44494c(0xdb)]=_0x31f21e,this[_0x44494c(0xc8)]=_0x5653a4[0x0],this[_0x44494c(0xf4)]=_0x1e30e4[_0x44494c(0xc6)](filteredTools,_0x31f21e);if(_0x1e30e4[_0x44494c(0xf3)](_0x5653a4[_0x44494c(0xda)],0x1))this[_0x44494c(0xf4)][_0x44494c(0xe8)](this[_0x44494c(0xed)](_0x5653a4));}async['initialize'](_0x50ee24){const _0x3183d3=_0x4d556b,_0x53f772={'rAuaX':function(_0x43cbb5,_0xf8309d){return _0x43cbb5===_0xf8309d;},'fnDLv':_0x3183d3(0xab),'BCxIq':_0x3183d3(0xcd),'CosFm':function(_0x551155,_0x177411){return _0x551155(_0x177411);}},_0x353c77=_0x50ee24[_0x3183d3(0xd9)]();let _0x10fea5;if(_0x353c77[_0x3183d3(0xcb)]&&(_0x53f772[_0x3183d3(0xe9)](_0x50ee24[_0x3183d3(0xd8)]()?.[_0x3183d3(0xb9)],_0x53f772[_0x3183d3(0xe7)])||_0x53f772[_0x3183d3(0xe9)](_0x50ee24[_0x3183d3(0xd8)]()?.[_0x3183d3(0xb9)],_0x53f772[_0x3183d3(0xbe)]))){const {roots:_0xdb2c47}=await _0x50ee24[_0x3183d3(0xd4)](),_0x5dfac5=_0xdb2c47[0x0]?.[_0x3183d3(0xca)],_0x345dc1=_0x5dfac5?new URL(_0x5dfac5):undefined;_0x10fea5=_0x345dc1?_0x53f772[_0x3183d3(0xaf)](fileURLToPath,_0x345dc1):undefined;}this[_0x3183d3(0xe6)]=this[_0x3183d3(0xdb)][_0x3183d3(0xe3)]?await SessionLog[_0x3183d3(0xae)](this[_0x3183d3(0xdb)],_0x10fea5):undefined,this[_0x3183d3(0xd6)]=new Context({'tools':this[_0x3183d3(0xf4)],'config':this[_0x3183d3(0xdb)],'browserContextFactory':this[_0x3183d3(0xc8)],'sessionLog':this[_0x3183d3(0xe6)],'clientInfo':{..._0x50ee24[_0x3183d3(0xd8)](),'rootPath':_0x10fea5}});}['tools'](){const _0x46cc5a=_0x4d556b;return this[_0x46cc5a(0xf4)][_0x46cc5a(0xd0)](_0x162a9e=>_0x162a9e[_0x46cc5a(0xeb)]);}async[_0x4d556b(0xef)](_0xd27da9,_0x2191b9){const _0x2f4a7e=_0x4d556b,_0x2060b6=this[_0x2f4a7e(0xd6)],_0x13bd23=new Response(_0x2060b6,_0xd27da9[_0x2f4a7e(0xb9)],_0x2191b9),_0x16f220=this[_0x2f4a7e(0xf4)][_0x2f4a7e(0xe2)](_0x2c86f6=>_0x2c86f6[_0x2f4a7e(0xeb)][_0x2f4a7e(0xb9)]===_0xd27da9[_0x2f4a7e(0xb9)]);_0x2060b6[_0x2f4a7e(0xb1)](!![]);try{await _0x16f220[_0x2f4a7e(0xb6)](_0x2060b6,_0x2191b9,_0x13bd23),await _0x13bd23[_0x2f4a7e(0xe1)](),this[_0x2f4a7e(0xe6)]?.[_0x2f4a7e(0xf8)](_0x13bd23);}catch(_0x293023){_0x13bd23[_0x2f4a7e(0xd7)](String(_0x293023));}finally{_0x2060b6[_0x2f4a7e(0xb1)](![]);}return _0x13bd23[_0x2f4a7e(0xb2)]();}[_0x4d556b(0xf7)](){const _0x10abce=_0x4d556b;try{void this[_0x10abce(0xd6)]?.[_0x10abce(0xcc)]()[_0x10abce(0xbc)](logUnhandledError);}catch{}}[_0x4d556b(0xed)](_0x27f9d1){const _0xcf5648=_0x4d556b,_0x32c4e4={'GzcIY':function(_0x34605c,_0x28218c){return _0x34605c+_0x28218c;},'carYp':_0xcf5648(0xbd),'cmJNt':_0xcf5648(0xe0),'qazKC':function(_0x5e45f5,_0x3a3e43){return _0x5e45f5(_0x3a3e43);},'TOEUI':_0xcf5648(0xc1),'yMlgh':_0xcf5648(0xe5),'VWjqT':'Connect\x20to\x20a\x20browser\x20using\x20one\x20of\x20the\x20available\x20methods:','wYvkd':'The\x20method\x20to\x20use\x20to\x20connect\x20to\x20the\x20browser'},_0x3fcd2a=this;return _0x32c4e4[_0xcf5648(0xb4)](defineTool,{'capability':_0x32c4e4[_0xcf5648(0xe4)],'schema':{'name':_0x32c4e4[_0xcf5648(0xc0)],'title':_0xcf5648(0xc9),'description':[_0x32c4e4[_0xcf5648(0xa9)],..._0x27f9d1[_0xcf5648(0xd0)](_0x268603=>_0xcf5648(0xd2)+_0x268603[_0xcf5648(0xb9)]+_0xcf5648(0xf0)+_0x268603[_0xcf5648(0xaa)])][_0xcf5648(0xd1)]('\x0a'),'inputSchema':z['object']({'method':z[_0xcf5648(0xdc)](_0x27f9d1[_0xcf5648(0xd0)](_0x36337c=>_0x36337c[_0xcf5648(0xb9)]))[_0xcf5648(0xf1)](_0x27f9d1[0x0][_0xcf5648(0xb9)])[_0xcf5648(0xad)](_0x32c4e4[_0xcf5648(0xc3)])}),'type':_0xcf5648(0xce)},async 'handle'(_0x277a15,_0x1967ef,_0x313a01){const _0x584613=_0xcf5648,_0x4bf1e7=_0x27f9d1[_0x584613(0xe2)](_0x121cef=>_0x121cef[_0x584613(0xb9)]===_0x1967ef[_0x584613(0xc7)]);if(!_0x4bf1e7){_0x313a01[_0x584613(0xd7)](_0x32c4e4[_0x584613(0xec)](_0x32c4e4[_0x584613(0xc2)],_0x1967ef[_0x584613(0xc7)]));return;}await _0x3fcd2a[_0x584613(0xf2)](_0x4bf1e7),_0x313a01[_0x584613(0xb8)](_0x32c4e4[_0x584613(0xc5)]);}});}async[_0x4d556b(0xf2)](_0x622ca0){const _0x125e7e=_0x4d556b;if(this[_0x125e7e(0xd6)]){const _0x5ef985={...this[_0x125e7e(0xd6)][_0x125e7e(0xea)]};_0x5ef985[_0x125e7e(0xdf)]=_0x622ca0;const _0x2d0b01=_0x5ef985;await this[_0x125e7e(0xd6)][_0x125e7e(0xcc)](),this[_0x125e7e(0xd6)]=new Context(_0x2d0b01);}this[_0x125e7e(0xc8)]=_0x622ca0;}}