@mutagent/cli 0.1.390 → 0.1.392
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/dist/bin/cli.js +17 -5
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -18467,10 +18467,16 @@ function assertSecureHost(host) {
|
|
|
18467
18467
|
return;
|
|
18468
18468
|
throw new MutagentError("INVALID_ARGUMENTS", `Refusing to install from ${host}: plaintext HTTP to a non-loopback host.`, "checksums.txt and the binary come from the same origin, so an attacker who can rewrite one can rewrite the other. Use an https:// MUTAGENT_INSTALL_HOST.");
|
|
18469
18469
|
}
|
|
18470
|
-
|
|
18470
|
+
function helixInstallUserAgent(opts) {
|
|
18471
|
+
const { env } = opts;
|
|
18472
|
+
const ci = env.CI || env.GITHUB_ACTIONS ? 1 : 0;
|
|
18473
|
+
const internal = env.MUTAGENT_INTERNAL === "1" ? 1 : 0;
|
|
18474
|
+
return `mutagent-cli/${opts.cliVersion} (helix-install; ${opts.platform}; ch=${opts.channel}; ci=${String(ci)}; internal=${String(internal)})`;
|
|
18475
|
+
}
|
|
18476
|
+
async function fetchOrFail(fetchImpl, url, what, userAgent) {
|
|
18471
18477
|
let response;
|
|
18472
18478
|
try {
|
|
18473
|
-
response = await fetchImpl(url);
|
|
18479
|
+
response = await fetchImpl(url, { headers: { "User-Agent": userAgent } });
|
|
18474
18480
|
} catch (error3) {
|
|
18475
18481
|
const reason = error3 instanceof Error ? error3.message : String(error3);
|
|
18476
18482
|
throw new MutagentError("INSTALL_DOWNLOAD_FAILED", `Could not fetch ${what} from ${url}: ${reason}`, "Check your network connection, then run mutagent install helix again.");
|
|
@@ -18587,14 +18593,20 @@ async function installHelix(options, deps = {}) {
|
|
|
18587
18593
|
assertSecureHost(rawHost);
|
|
18588
18594
|
const host = rawHost.replace(/\/+$/, "");
|
|
18589
18595
|
const installDir = env.MUTAGENT_INSTALL_DIR !== undefined && env.MUTAGENT_INSTALL_DIR !== "" ? env.MUTAGENT_INSTALL_DIR : join10(deps.homeDir ?? homedir3(), ".mutagent", "bin");
|
|
18596
|
+
const userAgent = helixInstallUserAgent({
|
|
18597
|
+
cliVersion: deps.cliVersion ?? getCliVersion(),
|
|
18598
|
+
platform: asset.slice(`${HELIX_BINARY_NAME}-`.length),
|
|
18599
|
+
channel,
|
|
18600
|
+
env
|
|
18601
|
+
});
|
|
18590
18602
|
const base = `${host}/${channel}`;
|
|
18591
18603
|
const checksumsUrl = `${base}/checksums.txt`;
|
|
18592
|
-
const checksums = await (await fetchOrFail(fetchImpl, checksumsUrl, "checksums.txt")).text();
|
|
18604
|
+
const checksums = await (await fetchOrFail(fetchImpl, checksumsUrl, "checksums.txt", userAgent)).text();
|
|
18593
18605
|
const expected = findChecksum(checksums, asset);
|
|
18594
18606
|
if (expected === undefined) {
|
|
18595
18607
|
throw new MutagentError("INSTALL_ASSET_MISSING", `${asset} is not listed in ${checksumsUrl}.`, `The ${channel} channel has no build for this machine. Try --channel ${channel === "latest" ? "candidate" : "latest"}.`);
|
|
18596
18608
|
}
|
|
18597
|
-
const response = await fetchOrFail(fetchImpl, `${base}/${asset}`, asset);
|
|
18609
|
+
const response = await fetchOrFail(fetchImpl, `${base}/${asset}`, asset, userAgent);
|
|
18598
18610
|
try {
|
|
18599
18611
|
mkdirSync2(installDir, { recursive: true });
|
|
18600
18612
|
} catch (error3) {
|
|
@@ -31978,4 +31990,4 @@ if (isAgentInvocation(rawArgs)) {
|
|
|
31978
31990
|
program.parse(argvForCommander, { from: "user" });
|
|
31979
31991
|
}
|
|
31980
31992
|
|
|
31981
|
-
//# debugId=
|
|
31993
|
+
//# debugId=1168998AA50257B864756E2164756E21
|
package/package.json
CHANGED