agentworth 0.1.7 → 0.1.8
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/lib/resolver.js +29 -2
- package/package.json +1 -1
package/lib/resolver.js
CHANGED
|
@@ -186,6 +186,27 @@ export function downloadFile(url, destPath, redirects = 5) {
|
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* True when the binary at `binPath` reports `expected`. Used to stop a stale
|
|
192
|
+
* install on PATH from answering for an explicitly requested version.
|
|
193
|
+
* Any failure to ask — missing binary, wrong arch, timeout — counts as "no",
|
|
194
|
+
* so we fall through to the download rather than trusting an unknown.
|
|
195
|
+
*/
|
|
196
|
+
function pathBinaryMatchesVersion(binPath, expected) {
|
|
197
|
+
if (!expected) return true;
|
|
198
|
+
try {
|
|
199
|
+
const out = execFileSync(binPath, ['--version'], {
|
|
200
|
+
encoding: 'utf8',
|
|
201
|
+
timeout: 5000,
|
|
202
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
203
|
+
});
|
|
204
|
+
return out.includes(expected);
|
|
205
|
+
} catch (_) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
189
210
|
/**
|
|
190
211
|
* Downloads and extracts the precompiled native binary from GitHub Releases into the user's local cache.
|
|
191
212
|
*
|
|
@@ -370,12 +391,18 @@ export function resolveBinary(options = {}) {
|
|
|
370
391
|
};
|
|
371
392
|
}
|
|
372
393
|
|
|
373
|
-
// 3. System PATH
|
|
394
|
+
// 3. System PATH — but only when it agrees with the version we are.
|
|
374
395
|
// Skipped when already inside a launcher: the only thing PATH could offer is us.
|
|
396
|
+
//
|
|
397
|
+
// `npx agentworth@0.1.6` used to run whatever agentworth happened to be on
|
|
398
|
+
// PATH, silently, so pinning a version did nothing for anyone with a local
|
|
399
|
+
// install. A stale 0.1.2 in ~/.cargo/bin answered for 0.1.6 with no warning.
|
|
400
|
+
// A PATH binary now has to report the version this launcher ships before it
|
|
401
|
+
// gets to serve; otherwise we fall through and fetch the matching release.
|
|
375
402
|
const currentBin = path.resolve(baseDir, '..', 'bin', 'agentworth.js');
|
|
376
403
|
if (env.PATH !== undefined && !env.AGENTWORTH_LAUNCHER_ACTIVE) {
|
|
377
404
|
const pathBin = findPathBinary(binName, env.PATH, currentBin);
|
|
378
|
-
if (pathBin) {
|
|
405
|
+
if (pathBin && pathBinaryMatchesVersion(pathBin, getPackageVersion(baseDir))) {
|
|
379
406
|
return {
|
|
380
407
|
found: true,
|
|
381
408
|
path: pathBin,
|