@integrity-labs/agt-cli 0.28.281 → 0.28.282

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
@@ -38,7 +38,7 @@ import {
38
38
  success,
39
39
  table,
40
40
  warn
41
- } from "../chunk-QVAOI4TB.js";
41
+ } from "../chunk-6SRVCYKR.js";
42
42
  import {
43
43
  CHANNEL_REGISTRY,
44
44
  DEFAULT_FRAMEWORK,
@@ -4826,7 +4826,7 @@ import { execFileSync, execSync } from "child_process";
4826
4826
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4827
4827
  import chalk18 from "chalk";
4828
4828
  import ora16 from "ora";
4829
- var cliVersion = true ? "0.28.281" : "dev";
4829
+ var cliVersion = true ? "0.28.282" : "dev";
4830
4830
  async function fetchLatestVersion() {
4831
4831
  const host2 = getHost();
4832
4832
  if (!host2) return null;
@@ -5840,7 +5840,7 @@ function handleError(err) {
5840
5840
  }
5841
5841
 
5842
5842
  // src/bin/agt.ts
5843
- var cliVersion2 = true ? "0.28.281" : "dev";
5843
+ var cliVersion2 = true ? "0.28.282" : "dev";
5844
5844
  var program = new Command();
5845
5845
  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");
5846
5846
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -5882,7 +5882,7 @@ function requireHost() {
5882
5882
  }
5883
5883
 
5884
5884
  // src/lib/api-client.ts
5885
- var agtCliVersion = true ? "0.28.281" : "dev";
5885
+ var agtCliVersion = true ? "0.28.282" : "dev";
5886
5886
  var lastConfigHash = null;
5887
5887
  function setConfigHash(hash) {
5888
5888
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -8162,4 +8162,4 @@ export {
8162
8162
  managerInstallSystemUnitCommand,
8163
8163
  managerUninstallSystemUnitCommand
8164
8164
  };
8165
- //# sourceMappingURL=chunk-QVAOI4TB.js.map
8165
+ //# sourceMappingURL=chunk-6SRVCYKR.js.map
@@ -38,7 +38,7 @@ import {
38
38
  requireHost,
39
39
  safeWriteJsonAtomic,
40
40
  setConfigHash
41
- } from "../chunk-QVAOI4TB.js";
41
+ } from "../chunk-6SRVCYKR.js";
42
42
  import {
43
43
  getProjectDir as getProjectDir2,
44
44
  getReadyTasks,
@@ -186,6 +186,29 @@ function managedMcpStructureHash(entries) {
186
186
  const basis = entries.slice().sort((a, b) => a.serverId.localeCompare(b.serverId)).map((e) => `${e.serverId}|${Object.keys(e.headers ?? {}).sort().join(",")}`).join("\n");
187
187
  return createHash("sha256").update(basis).digest("hex").slice(0, 16);
188
188
  }
189
+ function managedMcpStructureHashFromFile(mcpConfig, isManagedKey) {
190
+ if (!mcpConfig || typeof mcpConfig !== "object") return null;
191
+ const servers = mcpConfig.mcpServers;
192
+ if (!servers || typeof servers !== "object") return managedMcpStructureHash([]);
193
+ const entries = [];
194
+ for (const [key, value] of Object.entries(servers)) {
195
+ if (!isManagedKey(key)) continue;
196
+ const headers = value && typeof value === "object" && value.headers && typeof value.headers === "object" ? value.headers : void 0;
197
+ entries.push({ serverId: key, headers });
198
+ }
199
+ return managedMcpStructureHash(entries);
200
+ }
201
+ function decideManagedMcpRestart(input) {
202
+ const { prevStructureHash, structureHash, launchStructureHash, sessionHealthy, flapping } = input;
203
+ if (prevStructureHash === void 0) return { kind: "skip-first-convergence" };
204
+ if (structureHash === prevStructureHash) return { kind: "skip-no-change" };
205
+ if (!sessionHealthy) return { kind: "skip-unhealthy" };
206
+ if (flapping) return { kind: "skip-flapping" };
207
+ if (launchStructureHash != null && launchStructureHash === structureHash) {
208
+ return { kind: "suppress-already-live" };
209
+ }
210
+ return { kind: "restart" };
211
+ }
189
212
  function channelSecretValueHash(envEntries, channelSecretKeys) {
190
213
  if (!envEntries) return null;
191
214
  const basis = channelSecretKeys.slice().sort().filter((k) => Object.prototype.hasOwnProperty.call(envEntries, k)).map((k) => `${k}=${envEntries[k]}`).join("\n");
@@ -6343,6 +6366,7 @@ function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-
6343
6366
  stopPersistentSession(codeName, log);
6344
6367
  markRestartStopped(codeName, log);
6345
6368
  runningMcpHashes.delete(codeName);
6369
+ sessionLaunchManagedStructure.delete(codeName);
6346
6370
  recordRestartForBreaker(codeName, breakerReason);
6347
6371
  log(`[hot-reload] Session stopped for '${codeName}' \u2014 will respawn with ${reason}`);
6348
6372
  const bindsNewMcp = restartReasonBindsNewMcp(breakerReason);
@@ -6521,6 +6545,7 @@ function isHostBusyForForcedUpdate() {
6521
6545
  var runningMcpHashes = /* @__PURE__ */ new Map();
6522
6546
  var runningMcpServerKeys = /* @__PURE__ */ new Map();
6523
6547
  var runningChannelSecretHashes = /* @__PURE__ */ new Map();
6548
+ var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
6524
6549
  function projectMcpHash(_codeName, projectDir) {
6525
6550
  try {
6526
6551
  const raw = readFileSync15(join17(projectDir, ".mcp.json"), "utf-8");
@@ -6540,6 +6565,28 @@ function projectMcpKeys(_codeName, projectDir) {
6540
6565
  return null;
6541
6566
  }
6542
6567
  }
6568
+ function seedSessionLaunchBaselines(codeName, projectDir) {
6569
+ const hash = projectMcpHash(codeName, projectDir);
6570
+ const keys = projectMcpKeys(codeName, projectDir);
6571
+ if (hash) runningMcpHashes.set(codeName, hash);
6572
+ else runningMcpHashes.delete(codeName);
6573
+ if (keys) runningMcpServerKeys.set(codeName, keys);
6574
+ else runningMcpServerKeys.delete(codeName);
6575
+ let launchStructure = null;
6576
+ try {
6577
+ const raw = readFileSync15(join17(projectDir, ".mcp.json"), "utf-8");
6578
+ launchStructure = managedMcpStructureHashFromFile(
6579
+ JSON.parse(raw),
6580
+ isManagedMcpServerKey
6581
+ );
6582
+ } catch {
6583
+ }
6584
+ if (launchStructure !== null) {
6585
+ sessionLaunchManagedStructure.set(codeName, launchStructure);
6586
+ } else {
6587
+ sessionLaunchManagedStructure.delete(codeName);
6588
+ }
6589
+ }
6543
6590
  async function runAgentConnectivityProbes(agent, integrations, projectDir) {
6544
6591
  if (integrations.length === 0) return;
6545
6592
  const probeEnv = buildProbeEnv(projectDir);
@@ -6665,6 +6712,7 @@ function stopPersistentSessionAndForgetMcpBaseline(codeName, breakerReason, gate
6665
6712
  runningMcpHashes.delete(codeName);
6666
6713
  runningMcpServerKeys.delete(codeName);
6667
6714
  runningChannelSecretHashes.delete(codeName);
6715
+ sessionLaunchManagedStructure.delete(codeName);
6668
6716
  closeInjectedRunIfOpen(codeName, "cancelled", `session stopped (${breakerReason ?? "deprovision"})`);
6669
6717
  closeScheduledRunsForCode(codeName, "cancelled", `session stopped (${breakerReason ?? "deprovision"})`);
6670
6718
  if (breakerReason) {
@@ -6838,7 +6886,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
6838
6886
  var lastVersionCheckAt = 0;
6839
6887
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
6840
6888
  var lastResponsivenessProbeAt = 0;
6841
- var agtCliVersion = true ? "0.28.281" : "dev";
6889
+ var agtCliVersion = true ? "0.28.282" : "dev";
6842
6890
  function resolveBrewPath(execFileSync2) {
6843
6891
  try {
6844
6892
  const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -9608,12 +9656,19 @@ async function processAgent(agent, agentStates) {
9608
9656
  }
9609
9657
  agentState.knownManagedMcpHashes.set(agent.agent_id, mcpHash);
9610
9658
  agentState.knownManagedMcpStructure.set(agent.agent_id, structureHash);
9611
- if (prevStructureHash !== void 0 && structureHash !== prevStructureHash && fwForMcp === "claude-code" && isSessionHealthy(agent.code_name) && // ENG-6123: hold the restart + inject-notice while the managed-MCP
9612
- // membership is oscillating. The .mcp.json above was still written
9613
- // (the file converges to the live set); we only withhold the
9614
- // opus-facing notice + the session reload — the two per-flip burns.
9615
- // When the set settles, the next structural change restarts once.
9616
- !mcpFlap.flapping) {
9659
+ const mcpRestartDecision = fwForMcp === "claude-code" && prevStructureHash !== void 0 && structureHash !== prevStructureHash ? decideManagedMcpRestart({
9660
+ prevStructureHash,
9661
+ structureHash,
9662
+ launchStructureHash: sessionLaunchManagedStructure.get(agent.code_name),
9663
+ sessionHealthy: isSessionHealthy(agent.code_name),
9664
+ flapping: mcpFlap.flapping
9665
+ }) : null;
9666
+ if (mcpRestartDecision?.kind === "suppress-already-live") {
9667
+ log(
9668
+ `[hot-reload] Restart suppressed for '${agent.code_name}': the managed MCP structure change is already live in the running session (launched with it) - no respawn needed (ENG-7576)`
9669
+ );
9670
+ }
9671
+ if (mcpRestartDecision?.kind === "restart") {
9617
9672
  const mcpNames = agentToolkits.map((tk) => tk.toolkit_name).join(", ") || "none (all removed)";
9618
9673
  log(`[hot-reload] MCP servers changed for '${agent.code_name}': ${mcpNames} \u2014 restarting session`);
9619
9674
  const restartNotice = agentToolkits.length > 0 ? `New MCP tool servers have been configured: ${mcpNames}. Note: MCP servers require a session restart to connect. Your manager will restart your session shortly.` : "Managed MCP tool servers were removed. Your manager will restart your session shortly so the session drops those tools.";
@@ -10619,6 +10674,7 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash11("sha256")
10619
10674
  });
10620
10675
  agentState.persistentSessionAgents.add(codeName);
10621
10676
  claudeAuthTupleBySession.set(codeName, currentAuthTuple);
10677
+ seedSessionLaunchBaselines(codeName, projectDir);
10622
10678
  return {
10623
10679
  decision: "spawn",
10624
10680
  spawnAttempted: true,