@integrity-labs/agt-cli 0.28.137 → 0.28.138

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/agt.js CHANGED
@@ -37,7 +37,7 @@ import {
37
37
  success,
38
38
  table,
39
39
  warn
40
- } from "../chunk-PU44HJCM.js";
40
+ } from "../chunk-QJCTWNIJ.js";
41
41
  import {
42
42
  CHANNEL_REGISTRY,
43
43
  DEPLOYMENT_TEMPLATES,
@@ -4777,7 +4777,7 @@ import { execFileSync, execSync } from "child_process";
4777
4777
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4778
4778
  import chalk18 from "chalk";
4779
4779
  import ora16 from "ora";
4780
- var cliVersion = true ? "0.28.137" : "dev";
4780
+ var cliVersion = true ? "0.28.138" : "dev";
4781
4781
  async function fetchLatestVersion() {
4782
4782
  const host2 = getHost();
4783
4783
  if (!host2) return null;
@@ -5791,7 +5791,7 @@ function handleError(err) {
5791
5791
  }
5792
5792
 
5793
5793
  // src/bin/agt.ts
5794
- var cliVersion2 = true ? "0.28.137" : "dev";
5794
+ var cliVersion2 = true ? "0.28.138" : "dev";
5795
5795
  var program = new Command();
5796
5796
  program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
5797
5797
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -7746,7 +7746,7 @@ function requireHost() {
7746
7746
  }
7747
7747
 
7748
7748
  // src/lib/api-client.ts
7749
- var agtCliVersion = true ? "0.28.137" : "dev";
7749
+ var agtCliVersion = true ? "0.28.138" : "dev";
7750
7750
  var lastConfigHash = null;
7751
7751
  function setConfigHash(hash) {
7752
7752
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -9043,4 +9043,4 @@ export {
9043
9043
  managerInstallSystemUnitCommand,
9044
9044
  managerUninstallSystemUnitCommand
9045
9045
  };
9046
- //# sourceMappingURL=chunk-PU44HJCM.js.map
9046
+ //# sourceMappingURL=chunk-QJCTWNIJ.js.map
@@ -28,7 +28,7 @@ import {
28
28
  requireHost,
29
29
  safeWriteJsonAtomic,
30
30
  setConfigHash
31
- } from "../chunk-PU44HJCM.js";
31
+ } from "../chunk-QJCTWNIJ.js";
32
32
  import {
33
33
  getProjectDir as getProjectDir2,
34
34
  getReadyTasks,
@@ -1676,6 +1676,9 @@ function decideMaintenanceWindowGate(opts) {
1676
1676
  if (!opts.window) return "proceed";
1677
1677
  return isWithinMaintenanceWindow(opts.window, opts.now) ? "proceed" : "defer";
1678
1678
  }
1679
+ function shouldConsumeForcedUpdate(outcome) {
1680
+ return outcome !== "failed";
1681
+ }
1679
1682
  function decideForcedUpdate(opts) {
1680
1683
  const { requestedAt, lastProcessedAt, hostBusy } = opts;
1681
1684
  if (!requestedAt) return "none";
@@ -7067,7 +7070,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
7067
7070
  var lastVersionCheckAt = 0;
7068
7071
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
7069
7072
  var lastResponsivenessProbeAt = 0;
7070
- var agtCliVersion = true ? "0.28.137" : "dev";
7073
+ var agtCliVersion = true ? "0.28.138" : "dev";
7071
7074
  function resolveBrewPath(execFileSync4) {
7072
7075
  try {
7073
7076
  const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -7370,12 +7373,12 @@ var pendingUpgradeVersion = null;
7370
7373
  var selfUpdateInFlight = false;
7371
7374
  async function checkAndUpdateCli(opts) {
7372
7375
  const force = opts?.force ?? false;
7373
- if (selfUpdateInFlight) return;
7376
+ if (selfUpdateInFlight) return "failed";
7374
7377
  selfUpdateInFlight = true;
7375
7378
  try {
7376
7379
  const cliPath = process.argv[1] ?? "";
7377
7380
  const isDevMode = cliPath.includes("/src/") || cliPath.includes("tsx");
7378
- if (isDevMode) return;
7381
+ if (isDevMode) return "noop";
7379
7382
  let resolvedPath = cliPath;
7380
7383
  try {
7381
7384
  const { realpathSync } = await import("fs");
@@ -7384,13 +7387,13 @@ async function checkAndUpdateCli(opts) {
7384
7387
  }
7385
7388
  const isBrewFormula = /\/Cellar\/[^/]+\//.test(resolvedPath);
7386
7389
  const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
7387
- if (!isBrewFormula && !isNpmGlobal) return;
7390
+ if (!isBrewFormula && !isNpmGlobal) return "noop";
7388
7391
  const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
7389
7392
  const markerPath = join16(homedir9(), ".augmented", ".last-update-check");
7390
7393
  if (!force) {
7391
7394
  try {
7392
7395
  const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
7393
- if (Date.now() - lastCheck < UPDATE_CHECK_INTERVAL_MS) return;
7396
+ if (Date.now() - lastCheck < UPDATE_CHECK_INTERVAL_MS) return "noop";
7394
7397
  } catch {
7395
7398
  }
7396
7399
  }
@@ -7398,15 +7401,12 @@ async function checkAndUpdateCli(opts) {
7398
7401
  writeF(markerPath, String(Date.now()));
7399
7402
  } catch {
7400
7403
  }
7401
- if (isBrewFormula) {
7402
- await checkAndUpdateCliViaBrew(force);
7403
- } else {
7404
- await checkAndUpdateCliViaNpm(force);
7405
- }
7404
+ const outcome = isBrewFormula ? await checkAndUpdateCliViaBrew(force) : await checkAndUpdateCliViaNpm(force);
7406
7405
  try {
7407
7406
  writeF(markerPath, String(Date.now()));
7408
7407
  } catch {
7409
7408
  }
7409
+ return outcome;
7410
7410
  } finally {
7411
7411
  selfUpdateInFlight = false;
7412
7412
  }
@@ -7414,10 +7414,12 @@ async function checkAndUpdateCli(opts) {
7414
7414
  async function checkAndUpdateCliViaBrew(force = false) {
7415
7415
  const { execFileSync: execFileSync4 } = await import("child_process");
7416
7416
  const brewPath = resolveBrewPath(execFileSync4);
7417
- if (!brewPath) return;
7417
+ if (!brewPath) return "noop";
7418
+ let metadataFresh = true;
7418
7419
  try {
7419
7420
  execFileSync4(brewPath, ["update", "--quiet"], { timeout: 6e4, stdio: "pipe" });
7420
7421
  } catch (err) {
7422
+ metadataFresh = false;
7421
7423
  log(`[self-update] brew update failed (continuing with stale cache): ${err.message}`);
7422
7424
  }
7423
7425
  try {
@@ -7434,7 +7436,7 @@ async function checkAndUpdateCliViaBrew(force = false) {
7434
7436
  log(
7435
7437
  `[self-update] agt CLI ${installed} \u2192 ${latest} (brew) deferred \u2014 ` + formatWindowDeferLogLine(cachedMaintenanceWindow ?? {}, /* @__PURE__ */ new Date())
7436
7438
  );
7437
- return;
7439
+ return "noop";
7438
7440
  }
7439
7441
  const coalesceWindowMs = resolveCoalesceWindowMs();
7440
7442
  const coalesce = decideSelfUpdateCoalesce({
@@ -7450,7 +7452,7 @@ async function checkAndUpdateCliViaBrew(force = false) {
7450
7452
  remainingMs: coalesce.remainingMs,
7451
7453
  windowMs: coalesceWindowMs
7452
7454
  }));
7453
- return;
7455
+ return "noop";
7454
7456
  }
7455
7457
  log(`[self-update] agt CLI update available: ${installed} \u2192 ${latest}. Upgrading via brew${force ? " (forced \u2014 Update CLI now)" : ""}...`);
7456
7458
  try {
@@ -7462,19 +7464,23 @@ async function checkAndUpdateCliViaBrew(force = false) {
7462
7464
  stampLastSelfUpdateApplied(selfUpdateAppliedMarkerPath());
7463
7465
  restartAfterUpgrade = true;
7464
7466
  pendingUpgradeVersion = latest;
7467
+ return "updated";
7465
7468
  } catch (err) {
7466
7469
  log(`[self-update] brew upgrade failed: ${err.message}`);
7470
+ return "failed";
7467
7471
  }
7468
7472
  } else if (!selfUpdateUpToDateLogged) {
7469
7473
  log(`[self-update] agt CLI is up to date (brew, ${agtCliVersion})`);
7470
7474
  selfUpdateUpToDateLogged = true;
7471
7475
  }
7476
+ return metadataFresh ? "noop" : "failed";
7472
7477
  } catch (err) {
7473
7478
  log(`[self-update] brew outdated failed: ${err.message}`);
7479
+ return "failed";
7474
7480
  }
7475
7481
  }
7476
7482
  async function checkAndUpdateCliViaNpm(force = false) {
7477
- if (agtCliVersion === "dev") return;
7483
+ if (agtCliVersion === "dev") return "noop";
7478
7484
  const channel = process.env.AGT_CLI_RELEASE_CHANNEL || "latest";
7479
7485
  let latest;
7480
7486
  try {
@@ -7487,17 +7493,17 @@ async function checkAndUpdateCliViaNpm(force = false) {
7487
7493
  );
7488
7494
  if (!res.ok) {
7489
7495
  log(`[self-update] npm registry returned ${res.status} (channel=${channel})`);
7490
- return;
7496
+ return "failed";
7491
7497
  }
7492
7498
  const body = await res.json();
7493
7499
  if (!body.version) {
7494
7500
  log(`[self-update] npm registry response missing version field`);
7495
- return;
7501
+ return "failed";
7496
7502
  }
7497
7503
  latest = body.version;
7498
7504
  } catch (err) {
7499
7505
  log(`[self-update] npm registry fetch failed: ${err.message}`);
7500
- return;
7506
+ return "failed";
7501
7507
  }
7502
7508
  const urgentTarget = await fetchUrgentDistTagVersion();
7503
7509
  if (isUrgentUpgrade({
@@ -7508,8 +7514,7 @@ async function checkAndUpdateCliViaNpm(force = false) {
7508
7514
  log(
7509
7515
  `[self-update] URGENT agt CLI hotfix ${agtCliVersion} \u2192 ${urgentTarget} (overrides channel=${channel} + maintenance window). Upgrading via npm...`
7510
7516
  );
7511
- await installAgtCliViaNpm(urgentTarget, "urgent");
7512
- return;
7517
+ return await installAgtCliViaNpm(urgentTarget, "urgent");
7513
7518
  }
7514
7519
  let shouldUpdate;
7515
7520
  if (channel === "latest") {
@@ -7529,13 +7534,13 @@ async function checkAndUpdateCliViaNpm(force = false) {
7529
7534
  log(`[self-update] agt CLI is up to date (npm, channel=${channel}, ${agtCliVersion})`);
7530
7535
  selfUpdateUpToDateLogged = true;
7531
7536
  }
7532
- return;
7537
+ return "noop";
7533
7538
  }
7534
7539
  if (!force && decideMaintenanceWindowGate({ window: cachedMaintenanceWindow, now: /* @__PURE__ */ new Date() }) === "defer") {
7535
7540
  log(
7536
7541
  `[self-update] agt CLI ${agtCliVersion} \u2192 ${latest} (channel=${channel}) deferred \u2014 ` + formatWindowDeferLogLine(cachedMaintenanceWindow ?? {}, /* @__PURE__ */ new Date())
7537
7542
  );
7538
- return;
7543
+ return "noop";
7539
7544
  }
7540
7545
  const coalesceWindowMs = resolveCoalesceWindowMs();
7541
7546
  const coalesce = decideSelfUpdateCoalesce({
@@ -7551,10 +7556,10 @@ async function checkAndUpdateCliViaNpm(force = false) {
7551
7556
  remainingMs: coalesce.remainingMs,
7552
7557
  windowMs: coalesceWindowMs
7553
7558
  }));
7554
- return;
7559
+ return "noop";
7555
7560
  }
7556
7561
  log(`[self-update] agt CLI update available: ${agtCliVersion} \u2192 ${latest} (channel=${channel}). Upgrading via npm...`);
7557
- await installAgtCliViaNpm(latest, `channel=${channel}`);
7562
+ return await installAgtCliViaNpm(latest, `channel=${channel}`);
7558
7563
  }
7559
7564
  async function fetchUrgentDistTagVersion() {
7560
7565
  try {
@@ -7584,7 +7589,7 @@ async function installAgtCliViaNpm(version, reasonLabel) {
7584
7589
  execFileSync4(cmd, args, { timeout: 18e4, stdio: "pipe" });
7585
7590
  } catch (err) {
7586
7591
  log(`[self-update] npm upgrade failed: ${err.message}`);
7587
- return;
7592
+ return "failed";
7588
7593
  }
7589
7594
  let smokeOk = false;
7590
7595
  try {
@@ -7600,13 +7605,14 @@ async function installAgtCliViaNpm(version, reasonLabel) {
7600
7605
  `[self-update] smoke check failed: \`agt --version\` would not run after install (${err.message}). The binary may be dangling; NOT restarting. systemd ExecStartPre will repair on the next start if needed.`
7601
7606
  );
7602
7607
  }
7603
- if (!smokeOk) return;
7608
+ if (!smokeOk) return "failed";
7604
7609
  log(
7605
7610
  `[self-update] agt CLI upgraded to ${version} (${reasonLabel}). Scheduling manager restart so the new binary takes effect.`
7606
7611
  );
7607
7612
  stampLastSelfUpdateApplied(selfUpdateAppliedMarkerPath());
7608
7613
  restartAfterUpgrade = true;
7609
7614
  pendingUpgradeVersion = version;
7615
+ return "updated";
7610
7616
  }
7611
7617
  function isPrereleaseVersion(v) {
7612
7618
  return v.replace(/^v/, "").split("+")[0].includes("-");
@@ -8294,26 +8300,31 @@ async function pollCycle() {
8294
8300
  `[self-update] "Update CLI now" requested at ${requestedUpdateAt} \u2014 deferring: a self-update is already in flight. Retrying next poll.`
8295
8301
  );
8296
8302
  } else {
8303
+ log(
8304
+ `[self-update] "Update CLI now" requested at ${requestedUpdateAt} \u2014 running window-bypassing self-update now (host idle).`
8305
+ );
8297
8306
  const prevProcessedAt = state6.lastUpdateRequestProcessedAt ?? null;
8298
- state6.lastUpdateRequestProcessedAt = requestedUpdateAt;
8299
- let persisted = true;
8300
- try {
8301
- atomicWriteFileSync(getStateFile(), JSON.stringify(state6, null, 2));
8302
- } catch (err) {
8303
- persisted = false;
8304
- state6.lastUpdateRequestProcessedAt = prevProcessedAt;
8305
- log(
8306
- `[self-update] failed to persist update-request ack; retrying next heartbeat: ${err.message}`
8307
- );
8308
- }
8309
- if (persisted) {
8307
+ void checkAndUpdateCli({ force: true }).then((outcome) => {
8308
+ if (!shouldConsumeForcedUpdate(outcome)) {
8309
+ log(
8310
+ `[self-update] "Update CLI now" did not complete (no install ran) \u2014 leaving the request pending; the next idle heartbeat retries.`
8311
+ );
8312
+ return;
8313
+ }
8314
+ state6.lastUpdateRequestProcessedAt = requestedUpdateAt;
8315
+ try {
8316
+ atomicWriteFileSync(getStateFile(), JSON.stringify(state6, null, 2));
8317
+ } catch (err) {
8318
+ state6.lastUpdateRequestProcessedAt = prevProcessedAt;
8319
+ log(
8320
+ `[self-update] failed to persist update-request ack; retrying next heartbeat: ${err.message}`
8321
+ );
8322
+ }
8323
+ }).catch((err) => {
8310
8324
  log(
8311
- `[self-update] "Update CLI now" requested at ${requestedUpdateAt} \u2014 running window-bypassing self-update now (host idle).`
8312
- );
8313
- void checkAndUpdateCli({ force: true }).catch(
8314
- (err) => log(`[self-update] forced check failed: ${err.message}`)
8325
+ `[self-update] forced check failed: ${err.message} \u2014 leaving the request pending for retry.`
8315
8326
  );
8316
- }
8327
+ });
8317
8328
  }
8318
8329
  }
8319
8330
  if (hbResp?.feature_flags) {