@theholocron/cli 5.0.0-alpha.585 → 5.0.0-alpha.586

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/cli.mjs CHANGED
@@ -11890,7 +11890,7 @@ function credentialsFromValues(values, environment) {
11890
11890
  } };
11891
11891
  }
11892
11892
  // src/commands/doctor-github-app/delivery-row.ts
11893
- const DAY_MS$1 = 864e5;
11893
+ const DAY_MS$2 = 864e5;
11894
11894
  /** The most failed deliveries a row names; the rest are counted. */
11895
11895
  const MAX_NAMED = 10;
11896
11896
  /**
@@ -11911,7 +11911,7 @@ async function deliveryRow(name, creds, api, now, secrets) {
11911
11911
  };
11912
11912
  let failed;
11913
11913
  try {
11914
- failed = failedDeliveries(await api.listAppDeliveries(creds, { since: (/* @__PURE__ */ new Date(now - DAY_MS$1)).toISOString() }));
11914
+ failed = failedDeliveries(await api.listAppDeliveries(creds, { since: (/* @__PURE__ */ new Date(now - DAY_MS$2)).toISOString() }));
11915
11915
  } catch (err) {
11916
11916
  return {
11917
11917
  id,
@@ -12661,7 +12661,57 @@ function readAgentToken(path, fs) {
12661
12661
  return {
12662
12662
  status: "ok",
12663
12663
  path,
12664
- token
12664
+ token,
12665
+ ...file.mtimeMs === void 0 ? {} : { modifiedAt: new Date(file.mtimeMs) }
12666
+ };
12667
+ }
12668
+ // src/commands/doctor-agent/agent-token-age/agent-token-age.ts
12669
+ const DAY_MS$1 = 864e5;
12670
+ /**
12671
+ * The `doctor agent` row for how old the Service Account's token is. The token file holds no date, so its age is how
12672
+ * long ago the file was last changed: a proxy, because copying or restoring the file starts the count again and the real
12673
+ * creation date is in 1Password. The policy is the repository's default rotation (`DEFAULT_TOKEN_ROTATION`, 90 days,
12674
+ * warned 14 days ahead), so the row passes under day 76 and fails from there, naming how many days are left, and fails
12675
+ * once past 90. Only a count of days and a date are printed, never the token.
12676
+ *
12677
+ * @param modifiedAt - When the file was last changed, or `undefined` when the file system did not say.
12678
+ * @param now - The current time.
12679
+ * @param rotation - The policy; the repository default when left out.
12680
+ * @returns The row `agent-token-age`.
12681
+ */
12682
+ function agentTokenAgeRow(modifiedAt, now, rotation = DEFAULT_TOKEN_ROTATION) {
12683
+ const title = "the Service Account token's age";
12684
+ if (!modifiedAt) return {
12685
+ id: "agent-token-age",
12686
+ title,
12687
+ status: "skip",
12688
+ detail: "the file's modified time is not known, so its age cannot be told",
12689
+ problems: []
12690
+ };
12691
+ const age = Math.floor((now.getTime() - modifiedAt.getTime()) / DAY_MS$1);
12692
+ const since = modifiedAt.toISOString().slice(0, 10);
12693
+ const left = rotation.maxAgeDays - age;
12694
+ const proxy = `from the file's modified time, ${since}`;
12695
+ if (age > rotation.maxAgeDays) return {
12696
+ id: "agent-token-age",
12697
+ title,
12698
+ status: "fail",
12699
+ detail: `${age} days old (${proxy}), over the ${rotation.maxAgeDays} days allowed`,
12700
+ problems: ["make a new Service Account, replace the token file, then delete the old account"]
12701
+ };
12702
+ if (left < rotation.warnDays) return {
12703
+ id: "agent-token-age",
12704
+ title,
12705
+ status: "fail",
12706
+ detail: `${age} days old (${proxy}), due for rotation in ${left} days (warns under ${rotation.warnDays})`,
12707
+ problems: ["make a new Service Account, replace the token file, then delete the old account"]
12708
+ };
12709
+ return {
12710
+ id: "agent-token-age",
12711
+ title,
12712
+ status: "ok",
12713
+ detail: `${age} days old (${proxy}); rotate after ${rotation.maxAgeDays}`,
12714
+ problems: []
12665
12715
  };
12666
12716
  }
12667
12717
  // src/commands/probe/probe-token/choose-token.ts
@@ -13056,6 +13106,7 @@ async function runDoctorAgent(input) {
13056
13106
  return finish();
13057
13107
  }
13058
13108
  rows.push(row$30("agent-token-file", "the Service Account's token file", "ok", `${path} (mode 600, in a private directory)`));
13109
+ rows.push(agentTokenAgeRow(file.modifiedAt, (input.now ?? (() => /* @__PURE__ */ new Date()))()));
13059
13110
  if (!ports.opInstalled()) {
13060
13111
  rows.push(row$30("agent-op", "the 1Password CLI", "fail", "`op` is not installed: brew install 1password-cli"));
13061
13112
  return finish();