mcp-chrome-bridger 1.0.10 → 1.0.12
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.
|
@@ -11,45 +11,15 @@ const constant_1 = require("./constant");
|
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
12
|
// Check if this script is run directly
|
|
13
13
|
const isDirectRun = require.main === module;
|
|
14
|
-
//
|
|
15
|
-
function
|
|
16
|
-
//
|
|
17
|
-
|
|
14
|
+
// Check if we're in a monorepo/workspace development environment
|
|
15
|
+
function isWorkspaceDev() {
|
|
16
|
+
// If we're inside a .pnpm store or node_modules of a workspace, skip auto-register
|
|
17
|
+
// This prevents overwriting developer's local native host config during pnpm install
|
|
18
|
+
if (__dirname.includes('/node_modules/.pnpm/') || __dirname.includes('\\node_modules\\.pnpm\\')) {
|
|
18
19
|
return true;
|
|
19
20
|
}
|
|
20
|
-
// pnpm detection methods
|
|
21
|
-
// Method 1: Check if PNPM_HOME is set and current path contains it
|
|
22
|
-
if (process.env.PNPM_HOME && __dirname.includes(process.env.PNPM_HOME)) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
// Method 2: Check if we're in a global pnpm directory structure
|
|
26
|
-
// pnpm global packages are typically installed in ~/.local/share/pnpm/global/5/node_modules
|
|
27
|
-
// Windows: %APPDATA%\pnpm\global\5\node_modules
|
|
28
|
-
const globalPnpmPatterns = process.platform === 'win32'
|
|
29
|
-
? ['\\pnpm\\global\\', '\\pnpm-global\\', '\\AppData\\Roaming\\pnpm\\']
|
|
30
|
-
: ['/pnpm/global/', '/.local/share/pnpm/', '/pnpm-global/'];
|
|
31
|
-
if (globalPnpmPatterns.some((pattern) => __dirname.includes(pattern))) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
// Method 3: Check npm_config_prefix for pnpm
|
|
35
|
-
if (process.env.npm_config_prefix && __dirname.includes(process.env.npm_config_prefix)) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
// Method 4: Windows-specific global installation paths
|
|
39
|
-
if (process.platform === 'win32') {
|
|
40
|
-
const windowsGlobalPatterns = [
|
|
41
|
-
'\\npm\\node_modules\\',
|
|
42
|
-
'\\AppData\\Roaming\\npm\\node_modules\\',
|
|
43
|
-
'\\Program Files\\nodejs\\node_modules\\',
|
|
44
|
-
'\\nodejs\\node_modules\\',
|
|
45
|
-
];
|
|
46
|
-
if (windowsGlobalPatterns.some((pattern) => __dirname.includes(pattern))) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
21
|
return false;
|
|
51
22
|
}
|
|
52
|
-
const isGlobalInstall = detectGlobalInstall();
|
|
53
23
|
/**
|
|
54
24
|
* Write Node.js path for run_host scripts to avoid fragile relative paths
|
|
55
25
|
*/
|
|
@@ -131,27 +101,19 @@ async function ensureWindowsFilePermissions() {
|
|
|
131
101
|
async function tryRegisterNativeHost() {
|
|
132
102
|
try {
|
|
133
103
|
console.log((0, utils_1.colorText)('Attempting to register Chrome Native Messaging host...', 'blue'));
|
|
134
|
-
// Always ensure execution permissions
|
|
104
|
+
// Always ensure execution permissions
|
|
135
105
|
await ensureExecutionPermissions();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
console.log((0, utils_1.colorText)('Please run the following command for system-level installation:', 'blue'));
|
|
143
|
-
console.log(` ${constant_1.COMMAND_NAME} register --system`);
|
|
144
|
-
printManualInstructions();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
// Local installation mode, don't attempt automatic registration
|
|
149
|
-
console.log((0, utils_1.colorText)('Local installation detected, skipping automatic registration', 'yellow'));
|
|
106
|
+
// Try user-level installation (no elevated permissions required)
|
|
107
|
+
const userLevelSuccess = await (0, utils_1.tryRegisterUserLevelHost)();
|
|
108
|
+
if (!userLevelSuccess) {
|
|
109
|
+
console.log((0, utils_1.colorText)('User-level installation failed, system-level installation may be needed', 'yellow'));
|
|
110
|
+
console.log((0, utils_1.colorText)('Please run the following command for system-level installation:', 'blue'));
|
|
111
|
+
console.log(` ${constant_1.COMMAND_NAME} register --system`);
|
|
150
112
|
printManualInstructions();
|
|
151
113
|
}
|
|
152
114
|
}
|
|
153
115
|
catch (error) {
|
|
154
|
-
console.log((0, utils_1.colorText)(
|
|
116
|
+
console.log((0, utils_1.colorText)(`Registration error: ${error instanceof Error ? error.message : String(error)}`, 'red'));
|
|
155
117
|
printManualInstructions();
|
|
156
118
|
}
|
|
157
119
|
}
|
|
@@ -161,38 +123,15 @@ async function tryRegisterNativeHost() {
|
|
|
161
123
|
function printManualInstructions() {
|
|
162
124
|
console.log('\n' + (0, utils_1.colorText)('===== Manual Registration Guide =====', 'blue'));
|
|
163
125
|
console.log((0, utils_1.colorText)('1. Try user-level installation (recommended):', 'yellow'));
|
|
164
|
-
|
|
165
|
-
console.log(` ${constant_1.COMMAND_NAME} register`);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
console.log(` npx ${constant_1.COMMAND_NAME} register`);
|
|
169
|
-
}
|
|
126
|
+
console.log(` ${constant_1.COMMAND_NAME} register`);
|
|
170
127
|
console.log((0, utils_1.colorText)('\n2. If user-level installation fails, try system-level installation:', 'yellow'));
|
|
171
|
-
console.log((0, utils_1.colorText)(' Use --system parameter (auto-elevate permissions):', 'yellow'));
|
|
172
|
-
if (isGlobalInstall) {
|
|
173
|
-
console.log(` ${constant_1.COMMAND_NAME} register --system`);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
console.log(` npx ${constant_1.COMMAND_NAME} register --system`);
|
|
177
|
-
}
|
|
178
|
-
console.log((0, utils_1.colorText)('\n Or use administrator privileges directly:', 'yellow'));
|
|
179
128
|
if (os_1.default.platform() === 'win32') {
|
|
180
|
-
console.log((0, utils_1.colorText)('
|
|
181
|
-
|
|
182
|
-
console.log(` ${constant_1.COMMAND_NAME} register`);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
console.log(` npx ${constant_1.COMMAND_NAME} register`);
|
|
186
|
-
}
|
|
129
|
+
console.log((0, utils_1.colorText)(' Run Command Prompt as Administrator:', 'yellow'));
|
|
130
|
+
console.log(` ${constant_1.COMMAND_NAME} register --system`);
|
|
187
131
|
}
|
|
188
132
|
else {
|
|
189
|
-
console.log((0, utils_1.colorText)('
|
|
190
|
-
|
|
191
|
-
console.log(` sudo ${constant_1.COMMAND_NAME} register`);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
console.log(` sudo npx ${constant_1.COMMAND_NAME} register`);
|
|
195
|
-
}
|
|
133
|
+
console.log((0, utils_1.colorText)(' Run with sudo:', 'yellow'));
|
|
134
|
+
console.log(` sudo ${constant_1.COMMAND_NAME} register`);
|
|
196
135
|
}
|
|
197
136
|
console.log('\n' +
|
|
198
137
|
(0, utils_1.colorText)('Ensure Chrome extension is installed and refresh the extension to connect to local service.', 'blue'));
|
|
@@ -202,25 +141,18 @@ function printManualInstructions() {
|
|
|
202
141
|
*/
|
|
203
142
|
async function main() {
|
|
204
143
|
console.log((0, utils_1.colorText)(`Installing ${constant_1.COMMAND_NAME}...`, 'green'));
|
|
205
|
-
//
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
console.log(` isGlobalInstall: ${isGlobalInstall}`);
|
|
144
|
+
// Skip auto-registration in workspace/monorepo development
|
|
145
|
+
if (isWorkspaceDev()) {
|
|
146
|
+
console.log((0, utils_1.colorText)('Workspace development detected, skipping auto-registration', 'yellow'));
|
|
147
|
+
console.log((0, utils_1.colorText)(`Run "${constant_1.COMMAND_NAME} register" manually if needed`, 'blue'));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
212
150
|
// Always ensure execution permissions first
|
|
213
151
|
await ensureExecutionPermissions();
|
|
214
152
|
// Write Node.js path for run_host scripts to use
|
|
215
153
|
await writeNodePath();
|
|
216
|
-
//
|
|
217
|
-
|
|
218
|
-
await tryRegisterNativeHost();
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
console.log((0, utils_1.colorText)('Local installation detected', 'yellow'));
|
|
222
|
-
printManualInstructions();
|
|
223
|
-
}
|
|
154
|
+
// Always try to register - user-level registration is safe and what users expect
|
|
155
|
+
await tryRegisterNativeHost();
|
|
224
156
|
}
|
|
225
157
|
// Only execute main function when running this script directly
|
|
226
158
|
if (isDirectRun) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postinstall.js","sourceRoot":"","sources":["../../src/scripts/postinstall.ts"],"names":[],"mappings":";;;;;;AAEA,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,yCAA0C;AAC1C,mCAA8D;AAE9D,uCAAuC;AACvC,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;AAE5C,
|
|
1
|
+
{"version":3,"file":"postinstall.js","sourceRoot":"","sources":["../../src/scripts/postinstall.ts"],"names":[],"mappings":";;;;;;AAEA,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,yCAA0C;AAC1C,mCAA8D;AAE9D,uCAAuC;AACvC,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;AAE5C,iEAAiE;AACjE,SAAS,cAAc;IACrB,mFAAmF;IACnF,qFAAqF;IACrF,IAAI,SAAS,CAAC,QAAQ,CAAC,sBAAsB,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,CAAC;QAChG,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,aAAa;IAC1B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;QAEjE,OAAO,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