@integrity-labs/agt-cli 0.28.505 → 0.28.506

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-3SKLJE7C.js";
43
+ } from "../chunk-43UIRCO7.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-3BRI7LJZ.js";
74
+ } from "../chunk-SMHHGXI5.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.505" : "dev";
4833
+ var cliVersion = true ? "0.28.506" : "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.505" : "dev";
6005
+ var cliVersion2 = true ? "0.28.506" : "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) => {
@@ -7,6 +7,7 @@ import {
7
7
  MIN_PROVISIONING_MAX_FOR_QUARANTINE_ORDERING,
8
8
  OAUTH_PROVIDERS,
9
9
  REMOTE_MCP_PROXY_ENV,
10
+ RESTART_BREAKER_OPERATOR_MAX,
10
11
  RESTART_BREAKER_PROVISIONING_MAX,
11
12
  RESTART_BREAKER_PROVISIONING_WINDOW_MS,
12
13
  bestConnectivityEvidence,
@@ -42,7 +43,7 @@ import {
42
43
  resolveConnectivityProbe,
43
44
  worseConnectivityOutcome,
44
45
  wrapScheduledTaskPrompt
45
- } from "./chunk-3BRI7LJZ.js";
46
+ } from "./chunk-SMHHGXI5.js";
46
47
  import {
47
48
  parsePsRows
48
49
  } from "./chunk-XWVM4KPK.js";
@@ -5061,7 +5062,7 @@ function exchangeFailureKind(err) {
5061
5062
  }
5062
5063
 
5063
5064
  // src/lib/api-client.ts
5064
- var agtCliVersion = true ? "0.28.505" : "dev";
5065
+ var agtCliVersion = true ? "0.28.506" : "dev";
5065
5066
  var lastConfigHash = null;
5066
5067
  function setConfigHash(hash) {
5067
5068
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -6432,6 +6433,9 @@ var KNOWN_REASON_CLASS_MAP = {
6432
6433
  crash: true,
6433
6434
  provisioning: true,
6434
6435
  "credential-rotation": true,
6436
+ // ENG-8388: provisioning reloads a human demonstrably asked for. Same
6437
+ // Record-not-Set reasoning as above — a new class cannot be silently omitted.
6438
+ "operator-config": true,
6435
6439
  // ENG-8215: the self-healing class (bind-remediation - the manager's OWN
6436
6440
  // repair attempts, which must never count toward a trip). Adding it here is
6437
6441
  // forced by the Record type, which is exactly why that shape was chosen over
@@ -6478,9 +6482,19 @@ var SELF_HEALING_REASONS = /* @__PURE__ */ new Set([
6478
6482
  function isSelfHealingReason(reason) {
6479
6483
  return SELF_HEALING_REASONS.has(reason);
6480
6484
  }
6485
+ var OPERATOR_CONFIG_REASONS = /* @__PURE__ */ new Set([
6486
+ "operator-integration-change"
6487
+ ]);
6488
+ function isOperatorConfigReason(reason) {
6489
+ return OPERATOR_CONFIG_REASONS.has(reason);
6490
+ }
6491
+ function isIntegrationBucketedReason(reason) {
6492
+ return isProvisioningReloadReason(reason) || isOperatorConfigReason(reason);
6493
+ }
6481
6494
  function restartReasonClass(reason) {
6482
6495
  if (isCredentialRotationReason(reason)) return "credential-rotation";
6483
6496
  if (isSelfHealingReason(reason)) return "self-healing";
6497
+ if (isOperatorConfigReason(reason)) return "operator-config";
6484
6498
  return isProvisioningReloadReason(reason) ? "provisioning" : "crash";
6485
6499
  }
6486
6500
  function countByClass(events) {
@@ -6488,24 +6502,30 @@ function countByClass(events) {
6488
6502
  let provisioning = 0;
6489
6503
  let credentialRotation = 0;
6490
6504
  let selfHealing = 0;
6505
+ let operatorConfig = 0;
6491
6506
  for (const e of events) {
6492
6507
  const klass = restartReasonClass(e.reason);
6493
6508
  if (klass === "provisioning") provisioning += 1;
6494
6509
  else if (klass === "credential-rotation") credentialRotation += 1;
6495
6510
  else if (klass === "self-healing") selfHealing += 1;
6511
+ else if (klass === "operator-config") operatorConfig += 1;
6496
6512
  else crash += 1;
6497
6513
  }
6498
6514
  return {
6499
6515
  crash,
6500
6516
  provisioning,
6501
6517
  "credential-rotation": credentialRotation,
6502
- "self-healing": selfHealing
6518
+ "self-healing": selfHealing,
6519
+ "operator-config": operatorConfig
6503
6520
  };
6504
6521
  }
6505
6522
  function maxProvisioningBucket(events) {
6523
+ return maxBucketWhere(events, isProvisioningReloadReason);
6524
+ }
6525
+ function maxBucketWhere(events, matches) {
6506
6526
  const buckets = /* @__PURE__ */ new Map();
6507
6527
  for (const e of events) {
6508
- if (!isProvisioningReloadReason(e.reason)) continue;
6528
+ if (!matches(e.reason)) continue;
6509
6529
  const key = e.integrationKey ?? "";
6510
6530
  buckets.set(key, (buckets.get(key) ?? 0) + 1);
6511
6531
  }
@@ -6524,6 +6544,7 @@ var DEFAULT_MAX = 2;
6524
6544
  var DEFAULT_WINDOW_MS = 6e5;
6525
6545
  var DEFAULT_PROVISIONING_MAX = RESTART_BREAKER_PROVISIONING_MAX;
6526
6546
  var DEFAULT_PROVISIONING_WINDOW_MS = RESTART_BREAKER_PROVISIONING_WINDOW_MS;
6547
+ var DEFAULT_OPERATOR_MAX = RESTART_BREAKER_OPERATOR_MAX;
6527
6548
  function readEnvNumber(name, fallback) {
6528
6549
  const raw = process.env[name];
6529
6550
  if (!raw) return fallback;
@@ -6545,6 +6566,12 @@ var RestartBreaker = class {
6545
6566
  */
6546
6567
  provisioningMax;
6547
6568
  provisioningWindowMs;
6569
+ /**
6570
+ * ENG-8388: the looser operator-config budget. Shares provisioningWindowMs.
6571
+ * NOT readonly - the constructor floors it at `provisioningMax` so setting one
6572
+ * env var without the other cannot invert the two tallies.
6573
+ */
6574
+ operatorMax;
6548
6575
  /** Longest window either tally needs — how long the events log must retain. */
6549
6576
  retentionMs;
6550
6577
  now;
@@ -6564,6 +6591,7 @@ var RestartBreaker = class {
6564
6591
  this.windowMs = opts.windowMs ?? readEnvNumber("AGT_RESTART_BREAKER_WINDOW_MS", DEFAULT_WINDOW_MS);
6565
6592
  this.provisioningMax = opts.provisioningMax ?? readEnvNumber("AGT_RESTART_BREAKER_PROVISIONING_MAX", DEFAULT_PROVISIONING_MAX);
6566
6593
  this.provisioningWindowMs = opts.provisioningWindowMs ?? readEnvNumber("AGT_RESTART_BREAKER_PROVISIONING_WINDOW_MS", DEFAULT_PROVISIONING_WINDOW_MS);
6594
+ this.operatorMax = opts.operatorMax ?? readEnvNumber("AGT_RESTART_BREAKER_OPERATOR_MAX", DEFAULT_OPERATOR_MAX);
6567
6595
  this.now = opts.now ?? Date.now;
6568
6596
  this.runtimeKey = opts.runtimeKey ?? ((codeName) => codeName);
6569
6597
  if (!Number.isFinite(this.max) || this.max < 1) {
@@ -6575,6 +6603,12 @@ var RestartBreaker = class {
6575
6603
  if (!Number.isFinite(this.provisioningMax) || this.provisioningMax < 1) {
6576
6604
  throw new Error("restart-breaker provisioningMax must be a finite number >= 1");
6577
6605
  }
6606
+ if (!Number.isFinite(this.operatorMax) || this.operatorMax < 1) {
6607
+ throw new Error("restart-breaker operatorMax must be a finite number >= 1");
6608
+ }
6609
+ if (this.operatorMax < this.provisioningMax) {
6610
+ this.operatorMax = this.provisioningMax;
6611
+ }
6578
6612
  if (this.provisioningMax < MIN_PROVISIONING_MAX_FOR_QUARANTINE_ORDERING) {
6579
6613
  this.quarantineOrderingClamped = {
6580
6614
  requested: this.provisioningMax,
@@ -6657,9 +6691,8 @@ var RestartBreaker = class {
6657
6691
  const at = this.now();
6658
6692
  const retentionCutoff = at - this.retentionMs;
6659
6693
  const prior = (this.events.get(key) ?? []).filter((e) => e.at >= retentionCutoff);
6660
- prior.push(
6661
- isProvisioningReloadReason(reason) && integrationKey ? { reason, at, integrationKey } : { reason, at }
6662
- );
6694
+ const bucketed = isIntegrationBucketedReason(reason);
6695
+ prior.push(bucketed && integrationKey ? { reason, at, integrationKey } : { reason, at });
6663
6696
  this.events.set(key, prior);
6664
6697
  const crashCount = prior.filter(
6665
6698
  (e) => e.at >= at - this.windowMs && restartReasonClass(e.reason) === "crash"
@@ -6673,33 +6706,45 @@ var RestartBreaker = class {
6673
6706
  const selfHealCount = prior.filter(
6674
6707
  (e) => e.at >= at - this.provisioningWindowMs && isSelfHealingReason(e.reason)
6675
6708
  ).length;
6709
+ const operatorEvents = prior.filter(
6710
+ (e) => e.at >= at - this.provisioningWindowMs && isOperatorConfigReason(e.reason)
6711
+ );
6676
6712
  const windowCount = prior.filter((e) => e.at >= at - this.windowMs).length;
6677
6713
  const classCounts = {
6678
6714
  crash: crashCount,
6679
6715
  provisioning: provEvents.length,
6680
6716
  "credential-rotation": credRotCount,
6681
- "self-healing": selfHealCount
6717
+ "self-healing": selfHealCount,
6718
+ "operator-config": operatorEvents.length
6682
6719
  };
6683
6720
  const provBucket = maxProvisioningBucket(provEvents);
6721
+ const operatorBucket = maxBucketWhere(operatorEvents, isOperatorConfigReason);
6684
6722
  let trippedClass;
6685
6723
  let tripEvents;
6686
6724
  let tripWindowMs = this.windowMs;
6725
+ let tripBucketKey = "";
6687
6726
  if (crashCount > this.max) {
6688
6727
  trippedClass = "crash";
6689
6728
  tripEvents = prior.filter(
6690
6729
  (e) => e.at >= at - this.windowMs && restartReasonClass(e.reason) === "crash"
6691
6730
  );
6692
6731
  tripWindowMs = this.windowMs;
6732
+ } else if (operatorBucket.count > this.operatorMax) {
6733
+ trippedClass = "operator-config";
6734
+ tripEvents = operatorEvents.filter((e) => (e.integrationKey ?? "") === operatorBucket.key);
6735
+ tripWindowMs = this.provisioningWindowMs;
6736
+ tripBucketKey = operatorBucket.key;
6693
6737
  } else if (provBucket.count > this.provisioningMax) {
6694
6738
  trippedClass = "provisioning";
6695
6739
  tripEvents = provEvents.filter((e) => (e.integrationKey ?? "") === provBucket.key);
6696
6740
  tripWindowMs = this.provisioningWindowMs;
6741
+ tripBucketKey = provBucket.key;
6697
6742
  }
6698
6743
  if (trippedClass && tripEvents) {
6699
6744
  const trip = {
6700
6745
  trippedAt: at,
6701
6746
  eventsAtTrip: [...tripEvents],
6702
- statusMessage: formatStatusMessage(tripEvents, tripWindowMs, trippedClass, provBucket.key),
6747
+ statusMessage: formatStatusMessage(tripEvents, tripWindowMs, trippedClass, tripBucketKey),
6703
6748
  // ENG-7577: persist the tripping class so the recovery path can gate on
6704
6749
  // it after a manager restart, without re-deriving it from prose.
6705
6750
  trippedClass
@@ -6768,8 +6813,8 @@ function formatStatusMessage(events, windowMs, klass = "crash", integrationKey =
6768
6813
  const reasonCounts = /* @__PURE__ */ new Map();
6769
6814
  for (const e of events) reasonCounts.set(e.reason, (reasonCounts.get(e.reason) ?? 0) + 1);
6770
6815
  const breakdown = Array.from(reasonCounts.entries()).map(([r, n]) => `${r}=${n}`).join(", ");
6771
- const classLabel = klass === "provisioning" ? "provisioning-reload " : "";
6772
- const integrationLabel = klass === "provisioning" && integrationKey ? ` for integration '${integrationKey}'` : "";
6816
+ const classLabel = klass === "provisioning" ? "provisioning-reload " : klass === "operator-config" ? "operator-requested config-reload " : "";
6817
+ const integrationLabel = (klass === "provisioning" || klass === "operator-config") && integrationKey ? ` for integration '${integrationKey}'` : "";
6773
6818
  return `Circuit breaker tripped: ${events.length} ${classLabel}restarts in ${windowLabel}${integrationLabel} (${breakdown}); most recent=${last.reason} at ${new Date(last.at).toISOString()}`;
6774
6819
  }
6775
6820
 
@@ -8295,6 +8340,7 @@ export {
8295
8340
  reapMissingMcpSessions,
8296
8341
  reaperRestartBreakerReason,
8297
8342
  isProvisioningReloadReason,
8343
+ isIntegrationBucketedReason,
8298
8344
  tripClass,
8299
8345
  readEnvNumber,
8300
8346
  RestartBreaker,
@@ -8322,4 +8368,4 @@ export {
8322
8368
  managerInstallSystemUnitCommand,
8323
8369
  managerUninstallSystemUnitCommand
8324
8370
  };
8325
- //# sourceMappingURL=chunk-3SKLJE7C.js.map
8371
+ //# sourceMappingURL=chunk-43UIRCO7.js.map