@integrity-labs/agt-cli 0.28.315 → 0.28.316

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-PNE62JL3.js";
41
+ } from "../chunk-J6H7R3Y4.js";
42
42
  import {
43
43
  CHANNEL_REGISTRY,
44
44
  DEFAULT_FRAMEWORK,
@@ -67,7 +67,7 @@ import {
67
67
  renderTemplate,
68
68
  resolveChannels,
69
69
  serializeManifestForSlackCli
70
- } from "../chunk-H6GG7WM3.js";
70
+ } from "../chunk-ORTMG5E3.js";
71
71
  import "../chunk-XWVM4KPK.js";
72
72
 
73
73
  // src/bin/agt.ts
@@ -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.315" : "dev";
4829
+ var cliVersion = true ? "0.28.316" : "dev";
4830
4830
  async function fetchLatestVersion() {
4831
4831
  const host2 = getHost();
4832
4832
  if (!host2) return null;
@@ -5843,7 +5843,7 @@ function handleError(err) {
5843
5843
  }
5844
5844
 
5845
5845
  // src/bin/agt.ts
5846
- var cliVersion2 = true ? "0.28.315" : "dev";
5846
+ var cliVersion2 = true ? "0.28.316" : "dev";
5847
5847
  var program = new Command();
5848
5848
  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");
5849
5849
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -18,7 +18,7 @@ import {
18
18
  resolveConnectivityProbe,
19
19
  worseConnectivityOutcome,
20
20
  wrapScheduledTaskPrompt
21
- } from "./chunk-H6GG7WM3.js";
21
+ } from "./chunk-ORTMG5E3.js";
22
22
  import {
23
23
  parsePsRows
24
24
  } from "./chunk-XWVM4KPK.js";
@@ -5900,7 +5900,7 @@ function requireHost() {
5900
5900
  }
5901
5901
 
5902
5902
  // src/lib/api-client.ts
5903
- var agtCliVersion = true ? "0.28.315" : "dev";
5903
+ var agtCliVersion = true ? "0.28.316" : "dev";
5904
5904
  var lastConfigHash = null;
5905
5905
  function setConfigHash(hash) {
5906
5906
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -6135,10 +6135,12 @@ function readFlagsCache(path) {
6135
6135
  const obj = parsed;
6136
6136
  const flags = obj["flags"];
6137
6137
  if (!flags || typeof flags !== "object") return null;
6138
+ const perAgent = obj["notify_dispatch_by_agent"];
6138
6139
  return {
6139
6140
  schema_version: typeof obj["schema_version"] === "string" ? obj["schema_version"] : "",
6140
6141
  updated_at: typeof obj["updated_at"] === "string" ? obj["updated_at"] : "",
6141
- flags: { ...flags }
6142
+ flags: { ...flags },
6143
+ notify_dispatch_by_agent: perAgent && typeof perAgent === "object" ? { ...perAgent } : {}
6142
6144
  };
6143
6145
  } catch {
6144
6146
  return null;
@@ -6183,6 +6185,22 @@ function resolveAllFlags(heartbeatFlags, env = process.env) {
6183
6185
  }
6184
6186
  var HostFlagStore = class {
6185
6187
  heartbeatFlags = {};
6188
+ /**
6189
+ * ENG-7682 follow-up: per-agent notify-dispatch values from the heartbeat,
6190
+ * keyed by agent_id. Only agents whose resolved value DIFFERS from the
6191
+ * host-wide value appear here; everyone else falls back to the host-wide
6192
+ * `notify-dispatch` entry. This is what stops one agent's opt-in from fanning
6193
+ * out to every agent the host runs. Held in memory only (re-sent every
6194
+ * heartbeat), not persisted to the flags cache, which is a host-wide map.
6195
+ */
6196
+ notifyDispatchByAgent = {};
6197
+ /**
6198
+ * The `flags_schema_version` from the most recent heartbeat, retained so a
6199
+ * per-agent-map write (which carries no schema version of its own) persists
6200
+ * the same schema string the host-wide map was last written with rather than
6201
+ * clobbering it to empty. Hydrated from the cache on init().
6202
+ */
6203
+ lastSchemaVersion = "";
6186
6204
  cachePath;
6187
6205
  log;
6188
6206
  env;
@@ -6216,6 +6234,8 @@ var HostFlagStore = class {
6216
6234
  return;
6217
6235
  }
6218
6236
  this.heartbeatFlags = { ...cached.flags };
6237
+ this.notifyDispatchByAgent = { ...cached.notify_dispatch_by_agent ?? {} };
6238
+ this.lastSchemaVersion = cached.schema_version || "";
6219
6239
  const ageSeconds = flagsCacheAgeSeconds(cached, this.cachePath, now);
6220
6240
  const age = ageSeconds === null ? "unknown" : `${Math.round(ageSeconds)}s`;
6221
6241
  const schema = cached.schema_version || "unknown";
@@ -6256,11 +6276,23 @@ var HostFlagStore = class {
6256
6276
  }
6257
6277
  }
6258
6278
  this.heartbeatFlags = { ...map };
6279
+ this.lastSchemaVersion = schemaVersion ?? "";
6280
+ this.persistCache();
6281
+ }
6282
+ /**
6283
+ * Persist the host-wide flag map AND the per-agent notify-dispatch map to the
6284
+ * last-known-good cache in a single atomic write, so a restart hydrates both
6285
+ * from the same snapshot (ENG-7682 follow-up). Called by every mutator that
6286
+ * changes either map. A write failure is logged and swallowed: the in-memory
6287
+ * state stays authoritative and the next successful heartbeat re-persists.
6288
+ */
6289
+ persistCache() {
6259
6290
  try {
6260
6291
  writeFlagsCache(this.cachePath, {
6261
- schema_version: schemaVersion ?? "",
6292
+ schema_version: this.lastSchemaVersion,
6262
6293
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
6263
- flags: this.heartbeatFlags
6294
+ flags: this.heartbeatFlags,
6295
+ notify_dispatch_by_agent: this.notifyDispatchByAgent
6264
6296
  });
6265
6297
  } catch (err) {
6266
6298
  this.log(`[flags] cache write failed: ${err.message}`);
@@ -6296,6 +6328,53 @@ var HostFlagStore = class {
6296
6328
  if (resolved && typeof resolved.value === "string") return resolved.value;
6297
6329
  return definition?.flagType === "enum" ? definition.defaultValue : "";
6298
6330
  }
6331
+ /**
6332
+ * ENG-7682 follow-up: merge the heartbeat's per-agent notify-dispatch map.
6333
+ * A missing/non-object map REPLACES with an empty map so a clear (agent
6334
+ * override removed → API stops sending the entry) takes effect within one
6335
+ * poll rather than pinning a stale opt-in. Values that aren't valid
6336
+ * notify-dispatch members are dropped (registry skew / malformed payload).
6337
+ */
6338
+ applyNotifyDispatchByAgent(map) {
6339
+ const definition = getFlagDefinition("notify-dispatch");
6340
+ if (!map || typeof map !== "object" || !definition) {
6341
+ this.notifyDispatchByAgent = {};
6342
+ this.persistCache();
6343
+ return;
6344
+ }
6345
+ const next = {};
6346
+ for (const [agentId, raw] of Object.entries(map)) {
6347
+ const value = normalizeFlagValue(definition, raw);
6348
+ if (value !== void 0) next[agentId] = value;
6349
+ }
6350
+ this.notifyDispatchByAgent = next;
6351
+ this.persistCache();
6352
+ }
6353
+ /**
6354
+ * ENG-7682 follow-up: resolve an enum flag FOR A SPECIFIC AGENT. Precedence:
6355
+ *
6356
+ * env override -> per-agent heartbeat value -> host-wide value (getString)
6357
+ *
6358
+ * The env override still wins (AGT_NOTIFY_DISPATCH stays the per-process
6359
+ * operator escape hatch); otherwise a per-agent heartbeat value beats the
6360
+ * host-wide one, and an agent with no per-agent entry inherits the host-wide
6361
+ * value unchanged. Only notify-dispatch is threaded per-agent today; other
6362
+ * enum flags stay host-wide, so a non-notify key just delegates to getString.
6363
+ */
6364
+ getStringForAgent(key, agentId) {
6365
+ const definition = getFlagDefinition(key);
6366
+ if (!definition || definition.flagType !== "enum") return this.getString(key);
6367
+ const envValue = definition.envVar ? coerceEnvValue(definition, this.env[definition.envVar]) : void 0;
6368
+ if (envValue !== void 0 && typeof envValue === "string") return envValue;
6369
+ if (agentId && key === "notify-dispatch") {
6370
+ const perAgent = this.notifyDispatchByAgent[agentId];
6371
+ if (typeof perAgent === "string") {
6372
+ const normalized = normalizeFlagValue(definition, perAgent);
6373
+ if (typeof normalized === "string") return normalized;
6374
+ }
6375
+ }
6376
+ return this.getString(key);
6377
+ }
6299
6378
  };
6300
6379
 
6301
6380
  // src/lib/stale-mcp-reaper.ts
@@ -8199,4 +8278,4 @@ export {
8199
8278
  managerInstallSystemUnitCommand,
8200
8279
  managerUninstallSystemUnitCommand
8201
8280
  };
8202
- //# sourceMappingURL=chunk-PNE62JL3.js.map
8281
+ //# sourceMappingURL=chunk-J6H7R3Y4.js.map