agent-browser 0.15.2 → 0.15.3
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.
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -187,46 +187,42 @@ async function fixUnixSymlink() {
|
|
|
187
187
|
* We overwrite them to invoke the native .exe directly.
|
|
188
188
|
*/
|
|
189
189
|
async function fixWindowsShims() {
|
|
190
|
-
// Check if this is a global install by looking for npm's global prefix
|
|
191
190
|
let npmBinDir;
|
|
192
191
|
try {
|
|
193
192
|
npmBinDir = execSync('npm prefix -g', { encoding: 'utf8' }).trim();
|
|
194
193
|
} catch {
|
|
195
|
-
return;
|
|
194
|
+
return;
|
|
196
195
|
}
|
|
197
196
|
|
|
198
|
-
// The shims are in the npm prefix directory (not prefix/bin on Windows)
|
|
199
197
|
const cmdShim = join(npmBinDir, 'agent-browser.cmd');
|
|
200
198
|
const ps1Shim = join(npmBinDir, 'agent-browser.ps1');
|
|
201
199
|
|
|
202
|
-
//
|
|
200
|
+
// Shims may not exist yet during postinstall (npm creates them after
|
|
201
|
+
// lifecycle scripts). If missing, fall back: the JS wrapper at
|
|
202
|
+
// bin/agent-browser.js handles Windows correctly via child_process.spawn.
|
|
203
203
|
if (!existsSync(cmdShim)) {
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
//
|
|
208
|
-
const
|
|
207
|
+
// Detect architecture so ARM64 Windows is handled correctly
|
|
208
|
+
const cpuArch = arch() === 'arm64' ? 'arm64' : 'x64';
|
|
209
|
+
const relativeBinaryPath = `node_modules\\agent-browser\\bin\\agent-browser-win32-${cpuArch}.exe`;
|
|
210
|
+
const absoluteBinaryPath = join(npmBinDir, relativeBinaryPath);
|
|
211
|
+
|
|
212
|
+
// Only rewrite shims if the native binary actually exists
|
|
213
|
+
if (!existsSync(absoluteBinaryPath)) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
209
216
|
|
|
210
217
|
try {
|
|
211
|
-
// Overwrite .cmd shim
|
|
212
218
|
const cmdContent = `@ECHO off\r\n"%~dp0${relativeBinaryPath}" %*\r\n`;
|
|
213
219
|
writeFileSync(cmdShim, cmdContent);
|
|
214
220
|
|
|
215
|
-
|
|
216
|
-
const ps1Content = `#!/usr/bin/env pwsh
|
|
217
|
-
$basedir = Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
218
|
-
$exe = ""
|
|
219
|
-
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
220
|
-
$exe = ".exe"
|
|
221
|
-
}
|
|
222
|
-
& "$basedir/${relativeBinaryPath.replace(/\\/g, '/')}" $args
|
|
223
|
-
exit $LASTEXITCODE
|
|
224
|
-
`;
|
|
221
|
+
const ps1Content = `#!/usr/bin/env pwsh\r\n$basedir = Split-Path $MyInvocation.MyCommand.Definition -Parent\r\n& "$basedir\\${relativeBinaryPath}" $args\r\nexit $LASTEXITCODE\r\n`;
|
|
225
222
|
writeFileSync(ps1Shim, ps1Content);
|
|
226
223
|
|
|
227
224
|
console.log('✓ Optimized: shims point to native binary (zero overhead)');
|
|
228
225
|
} catch (err) {
|
|
229
|
-
// Permission error or other issue - not critical, JS wrapper still works
|
|
230
226
|
console.log(`⚠ Could not optimize shims: ${err.message}`);
|
|
231
227
|
console.log(' CLI will work via Node.js wrapper (slightly slower startup)');
|
|
232
228
|
}
|