agentworth 0.1.11 → 0.1.13
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/bin/agentworth.js +7 -1
- package/lib/resolver.js +33 -17
- package/package.json +1 -1
package/bin/agentworth.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import path from 'node:path';
|
|
3
4
|
import { run } from '../lib/resolver.js';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
// Both npm bin entries ('agentworth' and 'agwt', see package.json) point at this same
|
|
7
|
+
// script -- process.argv[1] carries the name the shell actually resolved (the .bin
|
|
8
|
+
// symlink), which is how we tell the two invocations apart without a second script.
|
|
9
|
+
const invokedAs = path.basename(process.argv[1] || '').replace(/\.(js|cjs|mjs)$/, '');
|
|
10
|
+
|
|
11
|
+
const exitCode = run(process.argv.slice(2), { invokedAs });
|
|
6
12
|
process.exit(exitCode);
|
package/lib/resolver.js
CHANGED
|
@@ -35,9 +35,10 @@ export function getTargetTriple(platform = process.platform, arch = process.arch
|
|
|
35
35
|
// Windows dropped 2026-09-02: release.yml no longer builds x86_64-pc-windows-msvc, so
|
|
36
36
|
// this would 404 against the downloader even if it matched. The recurring failure was
|
|
37
37
|
// GNU tar on Windows misparsing a "C:\..." archive path as a remote "host:path" tar
|
|
38
|
-
// spec --
|
|
39
|
-
// nobody here can test a real Windows box to catch it before it ships. A
|
|
40
|
-
// this on Windows can still build it themselves: `cargo build --release
|
|
38
|
+
// spec -- no clean fix ever stuck (a --force-local attempt just broke macOS's BSD tar
|
|
39
|
+
// instead), and nobody here can test a real Windows box to catch it before it ships. A
|
|
40
|
+
// user who wants this on Windows can still build it themselves: `cargo build --release
|
|
41
|
+
// -p agentworth-cli`.
|
|
41
42
|
return null;
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -76,11 +77,19 @@ export function getCacheDir(version, homeDir) {
|
|
|
76
77
|
/**
|
|
77
78
|
* Returns the expected native binary name for the target platform.
|
|
78
79
|
*
|
|
80
|
+
* `invokedAs` selects between the two native binaries the release tarball ships
|
|
81
|
+
* (`agentworth` and its `agwt` alias, see apps/cli/Cargo.toml's two [[bin]] targets) --
|
|
82
|
+
* anything other than exactly 'agwt' resolves to the `agentworth` binary, so an
|
|
83
|
+
* unrecognized or missing invocation name still gets the primary binary rather than
|
|
84
|
+
* silently 404ing on a name nobody built.
|
|
85
|
+
*
|
|
79
86
|
* @param {string} [platform=process.platform]
|
|
87
|
+
* @param {string} [invokedAs] - basename the launcher was invoked as ('agentworth' or 'agwt')
|
|
80
88
|
* @returns {string}
|
|
81
89
|
*/
|
|
82
|
-
export function getBinaryName(platform = process.platform) {
|
|
83
|
-
|
|
90
|
+
export function getBinaryName(platform = process.platform, invokedAs) {
|
|
91
|
+
const base = invokedAs === 'agwt' ? 'agwt' : 'agentworth';
|
|
92
|
+
return platform === 'win32' ? `${base}.exe` : base;
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
/**
|
|
@@ -221,6 +230,7 @@ function pathBinaryMatchesVersion(binPath, expected) {
|
|
|
221
230
|
* @param {string} [options.version]
|
|
222
231
|
* @param {string} [options.homeDir]
|
|
223
232
|
* @param {boolean} [options.silent=false]
|
|
233
|
+
* @param {string} [options.invokedAs] - 'agentworth' or 'agwt'; picks which extracted binary is returned
|
|
224
234
|
* @returns {Promise<string>} Path to extracted binary
|
|
225
235
|
*/
|
|
226
236
|
export async function downloadAndExtractBinary(options = {}) {
|
|
@@ -228,7 +238,7 @@ export async function downloadAndExtractBinary(options = {}) {
|
|
|
228
238
|
const arch = options.arch || process.arch;
|
|
229
239
|
const version = options.version || getPackageVersion();
|
|
230
240
|
const targetTriple = getTargetTriple(platform, arch);
|
|
231
|
-
const binName = getBinaryName(platform);
|
|
241
|
+
const binName = getBinaryName(platform, options.invokedAs);
|
|
232
242
|
|
|
233
243
|
if (!targetTriple) {
|
|
234
244
|
throw new Error(`Unsupported platform/architecture: ${platform}-${arch}`);
|
|
@@ -254,12 +264,12 @@ export async function downloadAndExtractBinary(options = {}) {
|
|
|
254
264
|
|
|
255
265
|
await downloadFile(url, archivePath);
|
|
256
266
|
|
|
257
|
-
//
|
|
258
|
-
//
|
|
259
|
-
//
|
|
260
|
-
//
|
|
267
|
+
// No --force-local here: it was a Windows-only GNU tar workaround, and Windows
|
|
268
|
+
// support was dropped in 8b837c3. BSD tar (macOS's default) doesn't recognize
|
|
269
|
+
// the flag and fails every extraction with it present -- v0.1.11 shipped this
|
|
270
|
+
// exact break. Keep it off; there's no platform left where it does anything.
|
|
261
271
|
try {
|
|
262
|
-
execFileSync('tar', ['
|
|
272
|
+
execFileSync('tar', ['-xzf', archivePath, '-C', cacheDir]);
|
|
263
273
|
} catch (err) {
|
|
264
274
|
throw new Error(`Failed to extract ${archiveName}: ${err.message}`);
|
|
265
275
|
} finally {
|
|
@@ -368,6 +378,7 @@ export function findPathBinary(binName = getBinaryName(), pathEnv = process.env.
|
|
|
368
378
|
* @param {NodeJS.ProcessEnv} [options.env=process.env]
|
|
369
379
|
* @param {string} [options.baseDir=__dirname]
|
|
370
380
|
* @param {string} [options.homeDir]
|
|
381
|
+
* @param {string} [options.invokedAs] - 'agentworth' or 'agwt'; selects which native binary to look for
|
|
371
382
|
* @returns {{ found: boolean, path?: string, source?: string, error?: string }}
|
|
372
383
|
*/
|
|
373
384
|
export function resolveBinary(options = {}) {
|
|
@@ -377,7 +388,7 @@ export function resolveBinary(options = {}) {
|
|
|
377
388
|
const env = options.env || process.env;
|
|
378
389
|
const baseDir = options.baseDir || __dirname;
|
|
379
390
|
const homeDir = options.homeDir || (env.HOME ? env.HOME : os.homedir());
|
|
380
|
-
const binName = getBinaryName(platform);
|
|
391
|
+
const binName = getBinaryName(platform, options.invokedAs);
|
|
381
392
|
const platformKey = getPlatformKey(platform, arch);
|
|
382
393
|
|
|
383
394
|
// 1. Explicit environment variable override
|
|
@@ -509,11 +520,14 @@ export function formatMissingBinaryMessage(platformKey = getPlatformKey()) {
|
|
|
509
520
|
'',
|
|
510
521
|
'AgentWorth requires the native binary to run. You can install or build it via:',
|
|
511
522
|
'',
|
|
512
|
-
' \x1b[36m•
|
|
513
|
-
'
|
|
523
|
+
' \x1b[36m• Standalone install script:\x1b[0m',
|
|
524
|
+
' curl -fsSL https://agentworth.dev/install.sh | sh',
|
|
525
|
+
'',
|
|
526
|
+
' \x1b[36m• Cargo:\x1b[0m',
|
|
527
|
+
' cargo install agentworth-cli',
|
|
514
528
|
'',
|
|
515
|
-
' \x1b[36m•
|
|
516
|
-
'
|
|
529
|
+
' \x1b[36m• Zero-install via npx:\x1b[0m',
|
|
530
|
+
' npx -y agentworth',
|
|
517
531
|
'',
|
|
518
532
|
' \x1b[36m• Download the release for your platform:\x1b[0m',
|
|
519
533
|
` https://github.com/unfoundbox-crew/agentworth/releases/latest`,
|
|
@@ -546,6 +560,7 @@ export function buildChildEnv(baseEnv, npmVersion) {
|
|
|
546
560
|
*
|
|
547
561
|
* @param {string[]} [argv=process.argv.slice(2)]
|
|
548
562
|
* @param {Object} [options={}]
|
|
563
|
+
* @param {string} [options.invokedAs] - 'agentworth' or 'agwt'; which native binary to resolve
|
|
549
564
|
* @returns {number} Exit code
|
|
550
565
|
*/
|
|
551
566
|
export function run(argv = process.argv.slice(2), options = {}) {
|
|
@@ -561,7 +576,8 @@ export function run(argv = process.argv.slice(2), options = {}) {
|
|
|
561
576
|
await downloadAndExtractBinary({
|
|
562
577
|
platform: ${JSON.stringify(options.platform || process.platform)},
|
|
563
578
|
arch: ${JSON.stringify(options.arch || process.arch)},
|
|
564
|
-
homeDir: ${JSON.stringify(options.homeDir || (options.env && options.env.HOME) || '')}
|
|
579
|
+
homeDir: ${JSON.stringify(options.homeDir || (options.env && options.env.HOME) || '')},
|
|
580
|
+
invokedAs: ${JSON.stringify(options.invokedAs || '')}
|
|
565
581
|
});
|
|
566
582
|
`;
|
|
567
583
|
const dlResult = spawnSync(process.execPath, ['--input-type=module', '-e', syncDownloadScript], {
|