@integrity-labs/agt-cli 0.28.492 → 0.28.494

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-KB5KVAWJ.js";
43
+ } from "../chunk-DJNJWFKI.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-34E3FHOS.js";
74
+ } from "../chunk-JHEJP3KC.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.492" : "dev";
4833
+ var cliVersion = true ? "0.28.494" : "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.492" : "dev";
6005
+ var cliVersion2 = true ? "0.28.494" : "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) => {
@@ -16,6 +16,7 @@ import {
16
16
  generateClaudeMd,
17
17
  getFlagDefinition,
18
18
  getFramework,
19
+ handshakeToolsListOutcome,
19
20
  isolationMode,
20
21
  listFlagDefinitions,
21
22
  mcpWildcardsForServers,
@@ -30,7 +31,7 @@ import {
30
31
  resolveConnectivityProbe,
31
32
  worseConnectivityOutcome,
32
33
  wrapScheduledTaskPrompt
33
- } from "./chunk-34E3FHOS.js";
34
+ } from "./chunk-JHEJP3KC.js";
34
35
  import {
35
36
  parsePsRows
36
37
  } from "./chunk-XWVM4KPK.js";
@@ -432,7 +433,7 @@ function mergeEnvIntegrationsContent(existing, args) {
432
433
  }
433
434
 
434
435
  // ../../packages/core/dist/provisioning/frameworks/claudecode/index.js
435
- import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync2, existsSync as existsSync3, chmodSync as chmodSync3, readdirSync, rmSync, copyFileSync, lstatSync, realpathSync, symlinkSync, readlinkSync } from "fs";
436
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync2, existsSync as existsSync3, chmodSync as chmodSync3, readdirSync, rmSync, copyFileSync, lstatSync, realpathSync, symlinkSync, readlinkSync, renameSync as renameSync3 } from "fs";
436
437
  import { join as join2, relative, dirname as dirname2 } from "path";
437
438
  import { homedir as homedir2 } from "os";
438
439
  import { execFile } from "child_process";
@@ -801,6 +802,64 @@ function ensureIdKeyedLayout(codeName, agentId) {
801
802
  symlinkSync(agentId, codeNamePath);
802
803
  return idPath;
803
804
  }
805
+ function stagedMigrationLinkPath(home, codeName) {
806
+ return join2(home, ".augmented", `.${codeName}.migrating`);
807
+ }
808
+ function cleanupStaleStagedLink(staged) {
809
+ try {
810
+ if (lstatSync(staged).isSymbolicLink())
811
+ rmSync(staged, { force: true });
812
+ } catch {
813
+ }
814
+ }
815
+ function isSymlinkTo(path, target) {
816
+ try {
817
+ return lstatSync(path).isSymbolicLink() && readlinkSync(path) === target;
818
+ } catch {
819
+ return false;
820
+ }
821
+ }
822
+ function migrateAgentDirToIdKeyed(codeName, agentId, opts = {}) {
823
+ assertValidCodeName(codeName);
824
+ assertValidAgentId(agentId);
825
+ const home = opts.home ?? getHomeDir();
826
+ const codeNamePath = join2(home, ".augmented", codeName);
827
+ const idPath = join2(home, ".augmented", agentId);
828
+ const staged = stagedMigrationLinkPath(home, codeName);
829
+ let codeNameKind;
830
+ try {
831
+ codeNameKind = lstatSync(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
832
+ } catch {
833
+ codeNameKind = "absent";
834
+ }
835
+ const idExists = existsSync3(idPath);
836
+ if (codeNameKind === "symlink") {
837
+ const target = readlinkSync(codeNamePath);
838
+ if (target !== agentId) {
839
+ throw new Error(`Codename symlink ${codeNamePath} points at "${target}", expected "${agentId}"; refusing to migrate.`);
840
+ }
841
+ return "already-id-keyed";
842
+ }
843
+ if (codeNameKind === "absent" && idExists) {
844
+ if (isSymlinkTo(staged, agentId)) {
845
+ renameSync3(staged, codeNamePath);
846
+ } else {
847
+ cleanupStaleStagedLink(staged);
848
+ symlinkSync(agentId, codeNamePath);
849
+ }
850
+ return "recovered";
851
+ }
852
+ if (codeNameKind === "absent")
853
+ return "no-agent";
854
+ if (idExists) {
855
+ return "conflict";
856
+ }
857
+ cleanupStaleStagedLink(staged);
858
+ symlinkSync(agentId, staged);
859
+ renameSync3(codeNamePath, idPath);
860
+ renameSync3(staged, codeNamePath);
861
+ return "migrated";
862
+ }
804
863
  function getAgentDir(codeName) {
805
864
  assertValidCodeName(codeName);
806
865
  return resolveRealAgentPath(join2(getHomeDir(), ".augmented", codeName));
@@ -4964,7 +5023,7 @@ function exchangeFailureKind(err) {
4964
5023
  }
4965
5024
 
4966
5025
  // src/lib/api-client.ts
4967
- var agtCliVersion = true ? "0.28.492" : "dev";
5026
+ var agtCliVersion = true ? "0.28.494" : "dev";
4968
5027
  var lastConfigHash = null;
4969
5028
  function setConfigHash(hash) {
4970
5029
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -5197,7 +5256,7 @@ async function getHostId() {
5197
5256
  }
5198
5257
 
5199
5258
  // src/lib/atomic-write.ts
5200
- import { closeSync, fsyncSync, openSync, writeSync, renameSync as renameSync3, mkdirSync as mkdirSync4 } from "fs";
5259
+ import { closeSync, fsyncSync, openSync, writeSync, renameSync as renameSync4, mkdirSync as mkdirSync4 } from "fs";
5201
5260
  import { dirname as dirname3 } from "path";
5202
5261
  function atomicWriteFileSync(path, data) {
5203
5262
  const dirPath = dirname3(path);
@@ -5216,7 +5275,7 @@ function atomicWriteFileSync(path, data) {
5216
5275
  } finally {
5217
5276
  closeSync(fd);
5218
5277
  }
5219
- renameSync3(tmpPath, path);
5278
+ renameSync4(tmpPath, path);
5220
5279
  try {
5221
5280
  const dirFd = openSync(dirPath, "r");
5222
5281
  try {
@@ -5301,6 +5360,18 @@ var HostFlagStore = class {
5301
5360
  * heartbeat), not persisted to the flags cache, which is a host-wide map.
5302
5361
  */
5303
5362
  notifyDispatchByAgent = {};
5363
+ /**
5364
+ * ENG-7891 / ADR-0049 slice 3: per-agent boolean overrides from the heartbeat,
5365
+ * keyed `agent_id -> flag_key -> bool`. This is the generic per-agent seam
5366
+ * `getBooleanForAgent` reads so a boolean gate (today only
5367
+ * `id-keyed-layout-migration`) can be armed one agent at a time. Held in
5368
+ * memory only and re-sent every heartbeat - deliberately NOT persisted to the
5369
+ * flags cache (which is a host-wide map), so a restart cleanly falls back to
5370
+ * the host-wide value until the next heartbeat rather than pinning a stale
5371
+ * per-agent opt-in. Empty until the API sends `feature_flags_by_agent` (the
5372
+ * flag ships dark, so it stays empty and every agent resolves host-wide).
5373
+ */
5374
+ booleanFlagsByAgent = {};
5304
5375
  /**
5305
5376
  * The `flags_schema_version` from the most recent heartbeat, retained so a
5306
5377
  * per-agent-map write (which carries no schema version of its own) persists
@@ -5425,6 +5496,30 @@ var HostFlagStore = class {
5425
5496
  if (resolved && typeof resolved.value === "boolean") return resolved.value;
5426
5497
  return definition?.flagType === "boolean" ? definition.defaultValue : false;
5427
5498
  }
5499
+ /**
5500
+ * ENG-7891 / ADR-0049 slice 3: resolve a BOOLEAN flag FOR A SPECIFIC AGENT.
5501
+ * Precedence mirrors {@link getStringForAgent}:
5502
+ *
5503
+ * env override -> per-agent heartbeat value -> host-wide value (getBoolean)
5504
+ *
5505
+ * The env override (if the flag declares one) stays highest precedence and
5506
+ * host-wide; otherwise a per-agent heartbeat override beats the host-wide
5507
+ * value, and an agent with no per-agent entry inherits the host-wide value.
5508
+ * A non-boolean/unknown key delegates to getBoolean. This lets a one-way-door
5509
+ * gate be armed one agent at a time (id-keyed-layout-migration) without an
5510
+ * opt-in fanning out to every agent on the host.
5511
+ */
5512
+ getBooleanForAgent(key, agentId) {
5513
+ const definition = getFlagDefinition(key);
5514
+ if (!definition || definition.flagType !== "boolean") return this.getBoolean(key);
5515
+ const envValue = definition.envVar ? coerceEnvValue(definition, this.env[definition.envVar]) : void 0;
5516
+ if (typeof envValue === "boolean") return envValue;
5517
+ if (agentId) {
5518
+ const perAgent = this.booleanFlagsByAgent[agentId]?.[key];
5519
+ if (typeof perAgent === "boolean") return perAgent;
5520
+ }
5521
+ return this.getBoolean(key);
5522
+ }
5428
5523
  /**
5429
5524
  * Typed string accessor for enum flags. Falls back to the registry default
5430
5525
  * (and to `''` for an unknown/non-enum key).
@@ -5457,6 +5552,34 @@ var HostFlagStore = class {
5457
5552
  this.notifyDispatchByAgent = next;
5458
5553
  this.persistCache();
5459
5554
  }
5555
+ /**
5556
+ * ENG-7891 / ADR-0049 slice 3: merge the heartbeat's per-agent BOOLEAN
5557
+ * override map (`agent_id -> flag_key -> bool`), read by getBooleanForAgent.
5558
+ * A missing/non-object map REPLACES with an empty map so a cleared per-agent
5559
+ * override takes effect within one poll rather than pinning a stale opt-in.
5560
+ * Only registered boolean keys with an actual boolean value are kept (registry
5561
+ * skew / malformed payloads are dropped). In-memory only - deliberately not
5562
+ * persisted (unlike notify-dispatch), so a restart falls back to the host-wide
5563
+ * value until the next heartbeat rather than rehydrating a stale opt-in for a
5564
+ * one-way-door migration.
5565
+ */
5566
+ applyBooleanFlagsByAgent(map) {
5567
+ if (!map || typeof map !== "object") {
5568
+ this.booleanFlagsByAgent = {};
5569
+ return;
5570
+ }
5571
+ const next = {};
5572
+ for (const [agentId, perAgent] of Object.entries(map)) {
5573
+ if (!perAgent || typeof perAgent !== "object") continue;
5574
+ for (const [key, raw] of Object.entries(perAgent)) {
5575
+ const definition = getFlagDefinition(key);
5576
+ if (!definition || definition.flagType !== "boolean") continue;
5577
+ if (typeof raw !== "boolean") continue;
5578
+ (next[agentId] ??= {})[key] = raw;
5579
+ }
5580
+ }
5581
+ this.booleanFlagsByAgent = next;
5582
+ }
5460
5583
  /**
5461
5584
  * ENG-7682 follow-up: resolve an enum flag FOR A SPECIFIC AGENT. Precedence:
5462
5585
  *
@@ -6377,11 +6500,7 @@ async function probeMcpStdio(config) {
6377
6500
  details: { ...toolCount !== void 0 ? { toolCount } : {}, testTool }
6378
6501
  });
6379
6502
  }
6380
- finish({
6381
- status: "ok",
6382
- message: toolCount !== void 0 ? `${toolCount} tools` : "reachable",
6383
- ...toolCount !== void 0 ? { details: { toolCount } } : {}
6384
- });
6503
+ finish(handshakeToolsListOutcome(toolCount));
6385
6504
  })();
6386
6505
  });
6387
6506
  }
@@ -7642,6 +7761,7 @@ export {
7642
7761
  safeWriteJsonAtomic,
7643
7762
  extractCommandNotFound,
7644
7763
  CHANNEL_SECRET_ENV_KEYS,
7764
+ migrateAgentDirToIdKeyed,
7645
7765
  provisionStopHook,
7646
7766
  provisionIsolationHook,
7647
7767
  provisionAutoKanbanProgressHook,
@@ -7712,4 +7832,4 @@ export {
7712
7832
  managerInstallSystemUnitCommand,
7713
7833
  managerUninstallSystemUnitCommand
7714
7834
  };
7715
- //# sourceMappingURL=chunk-KB5KVAWJ.js.map
7835
+ //# sourceMappingURL=chunk-DJNJWFKI.js.map