@integrity-labs/agt-cli 0.28.503 → 0.28.504

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
@@ -40,7 +40,7 @@ import {
40
40
  success,
41
41
  table,
42
42
  warn
43
- } from "../chunk-GR375XXG.js";
43
+ } from "../chunk-GXEXHVNW.js";
44
44
  import {
45
45
  AnchorSessionClient,
46
46
  CHANNEL_REGISTRY,
@@ -71,7 +71,7 @@ import {
71
71
  requiredMcpWildcard,
72
72
  resolveChannels,
73
73
  serializeManifestForSlackCli
74
- } from "../chunk-GBSMIV4P.js";
74
+ } from "../chunk-HEUDF73X.js";
75
75
  import "../chunk-XWVM4KPK.js";
76
76
 
77
77
  // src/bin/agt.ts
@@ -4830,7 +4830,7 @@ import { execFileSync, execSync } from "child_process";
4830
4830
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4831
4831
  import chalk18 from "chalk";
4832
4832
  import ora16 from "ora";
4833
- var cliVersion = true ? "0.28.503" : "dev";
4833
+ var cliVersion = true ? "0.28.504" : "dev";
4834
4834
  async function fetchLatestVersion() {
4835
4835
  const host2 = getHost();
4836
4836
  if (!host2) return null;
@@ -6002,7 +6002,7 @@ function handleError(err) {
6002
6002
  }
6003
6003
 
6004
6004
  // src/bin/agt.ts
6005
- var cliVersion2 = true ? "0.28.503" : "dev";
6005
+ var cliVersion2 = true ? "0.28.504" : "dev";
6006
6006
  var program = new Command();
6007
6007
  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");
6008
6008
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -42,7 +42,7 @@ import {
42
42
  resolveConnectivityProbe,
43
43
  worseConnectivityOutcome,
44
44
  wrapScheduledTaskPrompt
45
- } from "./chunk-GBSMIV4P.js";
45
+ } from "./chunk-HEUDF73X.js";
46
46
  import {
47
47
  parsePsRows
48
48
  } from "./chunk-XWVM4KPK.js";
@@ -5061,7 +5061,7 @@ function exchangeFailureKind(err) {
5061
5061
  }
5062
5062
 
5063
5063
  // src/lib/api-client.ts
5064
- var agtCliVersion = true ? "0.28.503" : "dev";
5064
+ var agtCliVersion = true ? "0.28.504" : "dev";
5065
5065
  var lastConfigHash = null;
5066
5066
  function setConfigHash(hash) {
5067
5067
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -6530,6 +6530,11 @@ function readEnvNumber(name, fallback) {
6530
6530
  const parsed = Number(raw);
6531
6531
  return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
6532
6532
  }
6533
+ function migrateMapKey(map, from, to) {
6534
+ if (map.has(to) || !map.has(from)) return;
6535
+ map.set(to, map.get(from));
6536
+ map.delete(from);
6537
+ }
6533
6538
  var RestartBreaker = class {
6534
6539
  max;
6535
6540
  windowMs;
@@ -6543,6 +6548,8 @@ var RestartBreaker = class {
6543
6548
  /** Longest window either tally needs — how long the events log must retain. */
6544
6549
  retentionMs;
6545
6550
  now;
6551
+ /** ENG-7891 slice 5b: code_name → durable runtime key (agent_id when id-keyed). Identity on the legacy fleet. */
6552
+ runtimeKey;
6546
6553
  events = /* @__PURE__ */ new Map();
6547
6554
  trips = /* @__PURE__ */ new Map();
6548
6555
  /**
@@ -6558,6 +6565,7 @@ var RestartBreaker = class {
6558
6565
  this.provisioningMax = opts.provisioningMax ?? readEnvNumber("AGT_RESTART_BREAKER_PROVISIONING_MAX", DEFAULT_PROVISIONING_MAX);
6559
6566
  this.provisioningWindowMs = opts.provisioningWindowMs ?? readEnvNumber("AGT_RESTART_BREAKER_PROVISIONING_WINDOW_MS", DEFAULT_PROVISIONING_WINDOW_MS);
6560
6567
  this.now = opts.now ?? Date.now;
6568
+ this.runtimeKey = opts.runtimeKey ?? ((codeName) => codeName);
6561
6569
  if (!Number.isFinite(this.max) || this.max < 1) {
6562
6570
  throw new Error("restart-breaker max must be a finite number >= 1");
6563
6571
  }
@@ -6588,12 +6596,40 @@ var RestartBreaker = class {
6588
6596
  getQuarantineOrderingClamp() {
6589
6597
  return this.quarantineOrderingClamped;
6590
6598
  }
6599
+ /**
6600
+ * ENG-7891 slice 5b: the DURABLE key for this agent's events/trips entries.
6601
+ * Resolves the code_name to the runtime key (agent_id on id-keyed hosts) and,
6602
+ * when they differ, lazily migrates a legacy code_name-keyed entry onto it — so
6603
+ * a trip persisted under the old key by a pre-arming manager (or from before a
6604
+ * codename rename) is found under the new key instead of being lost. Identity on
6605
+ * the legacy fleet ⇒ from === to ⇒ no migration and no behaviour change. Both
6606
+ * maps migrate together so events and a trip for the same agent never split
6607
+ * across keys mid-generation (a migration can flip the resolver mid-process).
6608
+ *
6609
+ * BOUNDARY — a pure-LEGACY rename (a host that was never armed) still strands a
6610
+ * held trip, exactly as it did before slice 5b: with no symlink there is no
6611
+ * agent_id to bridge the old codename to the new, so the runtime key stays the
6612
+ * (new) codename and the trip persisted under the old codename is not found.
6613
+ * That is unchanged, pre-existing behaviour and it is benign — the fresh
6614
+ * generation re-evaluates the agent under its new name and a still-pathological
6615
+ * agent simply re-trips within the window. The rename-survival guarantee this
6616
+ * slice adds is an id-keyed-only, post-arming property (the symlink is the
6617
+ * bridge); it is deliberately NOT retrofitted onto the legacy path.
6618
+ */
6619
+ keyFor(codeName) {
6620
+ const key = this.runtimeKey(codeName);
6621
+ if (key !== codeName) {
6622
+ migrateMapKey(this.events, codeName, key);
6623
+ migrateMapKey(this.trips, codeName, key);
6624
+ }
6625
+ return key;
6626
+ }
6591
6627
  /** True if this agent's breaker is currently tripped (manager must skip spawn). */
6592
6628
  isTripped(codeName) {
6593
- return this.trips.has(codeName);
6629
+ return this.trips.has(this.keyFor(codeName));
6594
6630
  }
6595
6631
  getTrip(codeName) {
6596
- return this.trips.get(codeName);
6632
+ return this.trips.get(this.keyFor(codeName));
6597
6633
  }
6598
6634
  /**
6599
6635
  * Record a restart event. If recording this event puts the count
@@ -6605,7 +6641,8 @@ var RestartBreaker = class {
6605
6641
  * via the decision-log for forensics.
6606
6642
  */
6607
6643
  record(codeName, reason, integrationKey) {
6608
- const existing = this.trips.get(codeName);
6644
+ const key = this.keyFor(codeName);
6645
+ const existing = this.trips.get(key);
6609
6646
  if (existing) {
6610
6647
  const bucket = maxProvisioningBucket(existing.eventsAtTrip);
6611
6648
  return {
@@ -6619,11 +6656,11 @@ var RestartBreaker = class {
6619
6656
  }
6620
6657
  const at = this.now();
6621
6658
  const retentionCutoff = at - this.retentionMs;
6622
- const prior = (this.events.get(codeName) ?? []).filter((e) => e.at >= retentionCutoff);
6659
+ const prior = (this.events.get(key) ?? []).filter((e) => e.at >= retentionCutoff);
6623
6660
  prior.push(
6624
6661
  isProvisioningReloadReason(reason) && integrationKey ? { reason, at, integrationKey } : { reason, at }
6625
6662
  );
6626
- this.events.set(codeName, prior);
6663
+ this.events.set(key, prior);
6627
6664
  const crashCount = prior.filter(
6628
6665
  (e) => e.at >= at - this.windowMs && restartReasonClass(e.reason) === "crash"
6629
6666
  ).length;
@@ -6667,8 +6704,8 @@ var RestartBreaker = class {
6667
6704
  // it after a manager restart, without re-deriving it from prose.
6668
6705
  trippedClass
6669
6706
  };
6670
- this.trips.set(codeName, trip);
6671
- this.events.delete(codeName);
6707
+ this.trips.set(key, trip);
6708
+ this.events.delete(key);
6672
6709
  return {
6673
6710
  tripped: true,
6674
6711
  trip,
@@ -6689,8 +6726,13 @@ var RestartBreaker = class {
6689
6726
  }
6690
6727
  /** Operator-initiated reset: drops the trip + the events log for this agent. */
6691
6728
  clear(codeName) {
6692
- this.trips.delete(codeName);
6693
- this.events.delete(codeName);
6729
+ const key = this.keyFor(codeName);
6730
+ this.trips.delete(key);
6731
+ this.events.delete(key);
6732
+ if (key !== codeName) {
6733
+ this.trips.delete(codeName);
6734
+ this.events.delete(codeName);
6735
+ }
6694
6736
  }
6695
6737
  /** Snapshot tripped agents for `manager-state.json`. */
6696
6738
  serialize() {
@@ -6717,7 +6759,7 @@ var RestartBreaker = class {
6717
6759
  /** Test helper — current in-window event count for `codeName`. */
6718
6760
  windowCount(codeName) {
6719
6761
  const cutoff = this.now() - this.windowMs;
6720
- return (this.events.get(codeName) ?? []).filter((e) => e.at >= cutoff).length;
6762
+ return (this.events.get(this.keyFor(codeName)) ?? []).filter((e) => e.at >= cutoff).length;
6721
6763
  }
6722
6764
  };
6723
6765
  function formatStatusMessage(events, windowMs, klass = "crash", integrationKey = "") {
@@ -8280,4 +8322,4 @@ export {
8280
8322
  managerInstallSystemUnitCommand,
8281
8323
  managerUninstallSystemUnitCommand
8282
8324
  };
8283
- //# sourceMappingURL=chunk-GR375XXG.js.map
8325
+ //# sourceMappingURL=chunk-GXEXHVNW.js.map