@integrity-labs/agt-cli 0.28.557 → 0.28.559

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-KEZEMDUB.js";
43
+ } from "../chunk-FIOLFAYB.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-AD26EE7A.js";
74
+ } from "../chunk-TBP245GG.js";
75
75
  import "../chunk-XWVM4KPK.js";
76
76
 
77
77
  // src/bin/agt.ts
@@ -4834,7 +4834,7 @@ import { execFileSync, execSync } from "child_process";
4834
4834
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4835
4835
  import chalk18 from "chalk";
4836
4836
  import ora16 from "ora";
4837
- var cliVersion = true ? "0.28.557" : "dev";
4837
+ var cliVersion = true ? "0.28.559" : "dev";
4838
4838
  async function fetchLatestVersion() {
4839
4839
  const host2 = getHost();
4840
4840
  if (!host2) return null;
@@ -6009,7 +6009,7 @@ function handleError(err) {
6009
6009
  }
6010
6010
 
6011
6011
  // src/bin/agt.ts
6012
- var cliVersion2 = true ? "0.28.557" : "dev";
6012
+ var cliVersion2 = true ? "0.28.559" : "dev";
6013
6013
  var program = new Command();
6014
6014
  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");
6015
6015
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -7,6 +7,8 @@ import {
7
7
  MIN_PROVISIONING_MAX_FOR_QUARANTINE_ORDERING,
8
8
  OAUTH_PROVIDERS,
9
9
  REMOTE_MCP_PROXY_ENV,
10
+ RESTART_BREAKER_NEW_AGENT_GRACE_CEILING,
11
+ RESTART_BREAKER_NEW_AGENT_GRACE_MS,
10
12
  RESTART_BREAKER_OPERATOR_MAX,
11
13
  RESTART_BREAKER_PROVISIONING_MAX,
12
14
  RESTART_BREAKER_PROVISIONING_WINDOW_MS,
@@ -43,7 +45,7 @@ import {
43
45
  resolveConnectivityProbe,
44
46
  worseConnectivityOutcome,
45
47
  wrapScheduledTaskPrompt
46
- } from "./chunk-AD26EE7A.js";
48
+ } from "./chunk-TBP245GG.js";
47
49
  import {
48
50
  parsePsRows
49
51
  } from "./chunk-XWVM4KPK.js";
@@ -5641,7 +5643,7 @@ function exchangeFailureKind(err) {
5641
5643
  }
5642
5644
 
5643
5645
  // src/lib/api-client.ts
5644
- var agtCliVersion = true ? "0.28.557" : "dev";
5646
+ var agtCliVersion = true ? "0.28.559" : "dev";
5645
5647
  var lastConfigHash = null;
5646
5648
  function setConfigHash(hash) {
5647
5649
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -7119,6 +7121,7 @@ function tripClass(trip) {
7119
7121
  if (!Array.isArray(trip.eventsAtTrip) || trip.eventsAtTrip.length === 0) return "crash";
7120
7122
  return trip.eventsAtTrip.every((e) => isProvisioningReloadReason(e.reason)) ? "provisioning" : "crash";
7121
7123
  }
7124
+ var MAX_NEW_AGENT_GRACE_MS = 365 * 24 * 60 * 60 * 1e3;
7122
7125
  var DEFAULT_MAX = 2;
7123
7126
  var DEFAULT_WINDOW_MS = 6e5;
7124
7127
  var DEFAULT_PROVISIONING_MAX = RESTART_BREAKER_PROVISIONING_MAX;
@@ -7156,6 +7159,12 @@ var RestartBreaker = class {
7156
7159
  now;
7157
7160
  /** ENG-7891 slice 5b: code_name → durable runtime key (agent_id when id-keyed). Identity on the legacy fleet. */
7158
7161
  runtimeKey;
7162
+ /** ENG-8690: agent creation time lookup; undefined result ⇒ no grace. */
7163
+ agentCreatedAt;
7164
+ /** ENG-8690: grace duration; 0 disables. */
7165
+ newAgentGraceMs;
7166
+ /** ENG-8690: the bound the grace does NOT lift. NOT readonly - floored below. */
7167
+ newAgentGraceCeiling;
7159
7168
  events = /* @__PURE__ */ new Map();
7160
7169
  trips = /* @__PURE__ */ new Map();
7161
7170
  /**
@@ -7173,6 +7182,15 @@ var RestartBreaker = class {
7173
7182
  this.operatorMax = opts.operatorMax ?? readEnvNumber("AGT_RESTART_BREAKER_OPERATOR_MAX", DEFAULT_OPERATOR_MAX);
7174
7183
  this.now = opts.now ?? Date.now;
7175
7184
  this.runtimeKey = opts.runtimeKey ?? ((codeName) => codeName);
7185
+ this.agentCreatedAt = opts.agentCreatedAt ?? (() => void 0);
7186
+ const graceMs = opts.newAgentGraceMs ?? readEnvNumber("AGT_RESTART_BREAKER_NEW_AGENT_GRACE_MS", RESTART_BREAKER_NEW_AGENT_GRACE_MS);
7187
+ const cappedGrace = Math.min(graceMs, MAX_NEW_AGENT_GRACE_MS);
7188
+ this.newAgentGraceMs = Number.isFinite(graceMs) && graceMs > 0 ? cappedGrace : 0;
7189
+ const ceiling = opts.newAgentGraceCeiling ?? readEnvNumber(
7190
+ "AGT_RESTART_BREAKER_NEW_AGENT_GRACE_CEILING",
7191
+ RESTART_BREAKER_NEW_AGENT_GRACE_CEILING
7192
+ );
7193
+ this.newAgentGraceCeiling = Number.isFinite(ceiling) && ceiling > 0 ? ceiling : RESTART_BREAKER_NEW_AGENT_GRACE_CEILING;
7176
7194
  if (!Number.isFinite(this.max) || this.max < 1) {
7177
7195
  throw new Error("restart-breaker max must be a finite number >= 1");
7178
7196
  }
@@ -7199,6 +7217,10 @@ var RestartBreaker = class {
7199
7217
  if (!Number.isFinite(this.provisioningWindowMs) || this.provisioningWindowMs < 1e3) {
7200
7218
  throw new Error("restart-breaker provisioningWindowMs must be a finite number >= 1000");
7201
7219
  }
7220
+ const minimumGraceCeiling = Math.max(this.provisioningMax, this.operatorMax);
7221
+ if (this.newAgentGraceCeiling < minimumGraceCeiling) {
7222
+ this.newAgentGraceCeiling = minimumGraceCeiling;
7223
+ }
7202
7224
  this.retentionMs = Math.max(this.windowMs, this.provisioningWindowMs);
7203
7225
  }
7204
7226
  /**
@@ -7298,6 +7320,14 @@ var RestartBreaker = class {
7298
7320
  };
7299
7321
  const provBucket = maxProvisioningBucket(provEvents);
7300
7322
  const operatorBucket = maxBucketWhere(operatorEvents, isOperatorConfigReason);
7323
+ const createdAt = this.newAgentGraceMs > 0 ? this.agentCreatedAt(codeName) : void 0;
7324
+ const age = typeof createdAt === "number" && Number.isFinite(createdAt) ? at - createdAt : void 0;
7325
+ const newAgentGraceActive = age !== void 0 && age >= 0 && age < this.newAgentGraceMs;
7326
+ const newAgentGraceExpiresAt = newAgentGraceActive && typeof createdAt === "number" ? createdAt + this.newAgentGraceMs : void 0;
7327
+ const graceCeilingEvents = newAgentGraceActive ? prior.filter(
7328
+ (e) => e.at >= at - this.provisioningWindowMs && (isProvisioningReloadReason(e.reason) || isOperatorConfigReason(e.reason))
7329
+ ) : [];
7330
+ const graceCeilingExceeded = newAgentGraceActive && graceCeilingEvents.length > this.newAgentGraceCeiling;
7301
7331
  let trippedClass;
7302
7332
  let tripEvents;
7303
7333
  let tripWindowMs = this.windowMs;
@@ -7308,6 +7338,12 @@ var RestartBreaker = class {
7308
7338
  (e) => e.at >= at - this.windowMs && restartReasonClass(e.reason) === "crash"
7309
7339
  );
7310
7340
  tripWindowMs = this.windowMs;
7341
+ } else if (newAgentGraceActive && graceCeilingExceeded) {
7342
+ trippedClass = "provisioning";
7343
+ tripEvents = graceCeilingEvents;
7344
+ tripWindowMs = this.provisioningWindowMs;
7345
+ tripBucketKey = "";
7346
+ } else if (newAgentGraceActive) {
7311
7347
  } else if (operatorBucket.count > this.operatorMax) {
7312
7348
  trippedClass = "operator-config";
7313
7349
  tripEvents = operatorEvents.filter((e) => (e.integrationKey ?? "") === operatorBucket.key);
@@ -7320,10 +7356,13 @@ var RestartBreaker = class {
7320
7356
  tripBucketKey = provBucket.key;
7321
7357
  }
7322
7358
  if (trippedClass && tripEvents) {
7359
+ const baseMessage = graceCeilingExceeded ? formatStatusMessage(tripEvents, tripWindowMs) : formatStatusMessage(tripEvents, tripWindowMs, trippedClass, tripBucketKey);
7360
+ const graceHours = Math.round(this.newAgentGraceMs / 36e5 * 10) / 10;
7361
+ const statusMessage = graceCeilingExceeded ? `${baseMessage} \u2014 paused DESPITE the new-agent grace: ${graceCeilingEvents.length} provisioning-shaped restarts (provisioning + operator-config) exceeded the grace ceiling of ${this.newAgentGraceCeiling} (ENG-8690). The agent is inside its ${graceHours}h grace and is doing little except restarting.` : baseMessage;
7323
7362
  const trip = {
7324
7363
  trippedAt: at,
7325
7364
  eventsAtTrip: [...tripEvents],
7326
- statusMessage: formatStatusMessage(tripEvents, tripWindowMs, trippedClass, tripBucketKey),
7365
+ statusMessage,
7327
7366
  // ENG-7577: persist the tripping class so the recovery path can gate on
7328
7367
  // it after a manager restart, without re-deriving it from prose.
7329
7368
  trippedClass
@@ -7337,15 +7376,31 @@ var RestartBreaker = class {
7337
7376
  classCounts,
7338
7377
  trippedClass,
7339
7378
  maxProvisioningBucket: provBucket.count,
7340
- maxProvisioningBucketKey: provBucket.key
7379
+ maxProvisioningBucketKey: provBucket.key,
7380
+ ...graceCeilingExceeded ? { newAgentGraceCeilingExceeded: true } : {}
7341
7381
  };
7342
7382
  }
7383
+ const suppressedOperator = operatorBucket.count > this.operatorMax;
7384
+ const suppressedProvisioning = !suppressedOperator && provBucket.count > this.provisioningMax;
7385
+ const wouldHaveTripped = suppressedOperator || suppressedProvisioning;
7343
7386
  return {
7344
7387
  tripped: false,
7345
7388
  windowCount,
7346
7389
  classCounts,
7347
7390
  maxProvisioningBucket: provBucket.count,
7348
- maxProvisioningBucketKey: provBucket.key
7391
+ maxProvisioningBucketKey: provBucket.key,
7392
+ ...newAgentGraceActive ? {
7393
+ newAgentGraceSuppressedTrip: wouldHaveTripped,
7394
+ ...newAgentGraceExpiresAt !== void 0 ? { newAgentGraceExpiresAt } : {},
7395
+ ...wouldHaveTripped ? {
7396
+ newAgentGraceSuppressed: {
7397
+ class: suppressedOperator ? "operator-config" : "provisioning",
7398
+ bucketKey: suppressedOperator ? operatorBucket.key : provBucket.key,
7399
+ bucketCount: suppressedOperator ? operatorBucket.count : provBucket.count,
7400
+ agentAgeMs: age ?? 0
7401
+ }
7402
+ } : {}
7403
+ } : {}
7349
7404
  };
7350
7405
  }
7351
7406
  /** Operator-initiated reset: drops the trip + the events log for this agent. */
@@ -8953,4 +9008,4 @@ export {
8953
9008
  managerInstallSystemUnitCommand,
8954
9009
  managerUninstallSystemUnitCommand
8955
9010
  };
8956
- //# sourceMappingURL=chunk-KEZEMDUB.js.map
9011
+ //# sourceMappingURL=chunk-FIOLFAYB.js.map