@integrity-labs/agt-cli 0.28.738 → 0.28.740

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
@@ -41,7 +41,7 @@ import {
41
41
  success,
42
42
  table,
43
43
  warn
44
- } from "../chunk-WTAZ5GOS.js";
44
+ } from "../chunk-WO3BES5W.js";
45
45
  import {
46
46
  getProjectDir,
47
47
  isSessionResumeDisabled,
@@ -5467,7 +5467,7 @@ import { execFileSync, execSync } from "child_process";
5467
5467
  import { existsSync as existsSync11, realpathSync as realpathSync2 } from "fs";
5468
5468
  import chalk18 from "chalk";
5469
5469
  import ora16 from "ora";
5470
- var cliVersion = true ? "0.28.738" : "dev";
5470
+ var cliVersion = true ? "0.28.740" : "dev";
5471
5471
  async function fetchLatestVersion() {
5472
5472
  const host2 = getHost();
5473
5473
  if (!host2) return null;
@@ -6654,7 +6654,7 @@ function handleError(err) {
6654
6654
  }
6655
6655
 
6656
6656
  // src/bin/agt.ts
6657
- var cliVersion2 = true ? "0.28.738" : "dev";
6657
+ var cliVersion2 = true ? "0.28.740" : "dev";
6658
6658
  var program = new Command();
6659
6659
  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");
6660
6660
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -6427,7 +6427,7 @@ function exchangeFailureKind(err) {
6427
6427
  }
6428
6428
 
6429
6429
  // src/lib/api-client.ts
6430
- var agtCliVersion = true ? "0.28.738" : "dev";
6430
+ var agtCliVersion = true ? "0.28.740" : "dev";
6431
6431
  var lastConfigHash = null;
6432
6432
  function setConfigHash(hash) {
6433
6433
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -10473,4 +10473,4 @@ export {
10473
10473
  managerInstallSystemUnitCommand,
10474
10474
  managerUninstallSystemUnitCommand
10475
10475
  };
10476
- //# sourceMappingURL=chunk-WTAZ5GOS.js.map
10476
+ //# sourceMappingURL=chunk-WO3BES5W.js.map
@@ -57,7 +57,7 @@ import {
57
57
  safeWriteJsonAtomic,
58
58
  setConfigHash,
59
59
  tripClass
60
- } from "../chunk-WTAZ5GOS.js";
60
+ } from "../chunk-WO3BES5W.js";
61
61
  import {
62
62
  getProjectDir as getProjectDir2,
63
63
  getReadyTasks,
@@ -5707,6 +5707,25 @@ function createFetchGate(ttlMs) {
5707
5707
  };
5708
5708
  }
5709
5709
 
5710
+ // src/lib/conditional-fetch.ts
5711
+ function stillHeld(quoted, live) {
5712
+ if (!quoted || !live) return void 0;
5713
+ return live.hash === quoted.hash ? live : void 0;
5714
+ }
5715
+ function resolveConditionalResponse(wire, hasCachedBody) {
5716
+ if (wire.unchanged === true) {
5717
+ return hasCachedBody ? { use: "cached" } : { use: "no-body" };
5718
+ }
5719
+ const token = wire.payload_hash;
5720
+ return {
5721
+ use: "wire",
5722
+ // An empty string is rejected as well as a non-string: it would round-trip
5723
+ // as a token the server can never match, so it is indistinguishable from
5724
+ // absent and should be stored as absent rather than as a hash of "".
5725
+ token: typeof token === "string" && token.length > 0 ? token : null
5726
+ };
5727
+ }
5728
+
5710
5729
  // src/lib/channel-hash-cache.ts
5711
5730
  import { existsSync as existsSync8, readFileSync as readFileSync19, writeFileSync as writeFileSync10 } from "fs";
5712
5731
  import { join as join25 } from "path";
@@ -13118,6 +13137,7 @@ function clearAgentCaches(agentId, codeName) {
13118
13137
  memoryFileHashes.delete(agentId);
13119
13138
  lastDownloadHash.delete(agentId);
13120
13139
  lastLocalFileHash.delete(agentId);
13140
+ lastMemoriesBody.delete(agentId);
13121
13141
  for (const key of taskDisplayInfo.keys()) {
13122
13142
  if (key.startsWith(`${codeName}:`)) taskDisplayInfo.delete(key);
13123
13143
  }
@@ -13134,7 +13154,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
13134
13154
  var lastVersionCheckAt = 0;
13135
13155
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
13136
13156
  var lastResponsivenessProbeAt = 0;
13137
- var agtCliVersion = true ? "0.28.738" : "dev";
13157
+ var agtCliVersion = true ? "0.28.740" : "dev";
13138
13158
  function resolveBrewPath(execFileSync3) {
13139
13159
  try {
13140
13160
  const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -14652,6 +14672,8 @@ var lastRefreshPayload = /* @__PURE__ */ new Map();
14652
14672
  var memoriesFetchGate = createFetchGate(DESIRED_STATE_FETCH_TTL_MS);
14653
14673
  var pollCycleFetches = 0;
14654
14674
  var pollCycleFetchSkips = 0;
14675
+ var pollCycleMemoriesUnchanged = 0;
14676
+ var pollCycleMemoriesFull = 0;
14655
14677
  function forceRefreshFetch() {
14656
14678
  refreshFetchGate.forceAll();
14657
14679
  memoriesFetchGate.forceAll();
@@ -15412,6 +15434,8 @@ async function pollCycleInner() {
15412
15434
  const cycleStartedAt = Date.now();
15413
15435
  pollCycleFetches = 0;
15414
15436
  pollCycleFetchSkips = 0;
15437
+ pollCycleMemoriesUnchanged = 0;
15438
+ pollCycleMemoriesFull = 0;
15415
15439
  for (const agent of processOrder) {
15416
15440
  if (restartInFlight.has(agent.agent_id)) {
15417
15441
  const existing = state8.agents.find((a) => a.agentId === agent.agent_id);
@@ -15451,7 +15475,7 @@ async function pollCycleInner() {
15451
15475
  }
15452
15476
  }
15453
15477
  log(
15454
- `[poll-cycle] agents=${processOrder.length} refresh_fetched=${pollCycleFetches} refresh_skipped=${pollCycleFetchSkips} duration_ms=${Date.now() - cycleStartedAt}`
15478
+ `[poll-cycle] agents=${processOrder.length} refresh_fetched=${pollCycleFetches} refresh_skipped=${pollCycleFetchSkips} memories_unchanged=${pollCycleMemoriesUnchanged} memories_full=${pollCycleMemoriesFull} duration_ms=${Date.now() - cycleStartedAt}`
15455
15479
  );
15456
15480
  void maybeReportActivityCache({ api, log });
15457
15481
  const crossAgentPrune = managedPruneLedger.summarize();
@@ -20114,6 +20138,7 @@ function generateArtifacts(agent, refreshData, adapter, renderIntegrationsSectio
20114
20138
  var memoryFileHashes = /* @__PURE__ */ new Map();
20115
20139
  var lastDownloadHash = /* @__PURE__ */ new Map();
20116
20140
  var lastLocalFileHash = /* @__PURE__ */ new Map();
20141
+ var lastMemoriesBody = /* @__PURE__ */ new Map();
20117
20142
  var memoryManifests = /* @__PURE__ */ new Map();
20118
20143
  function memoryRetirementDir(configDir, codeName) {
20119
20144
  return join40(configDir, "_memory-retirement", codeName);
@@ -20182,6 +20207,7 @@ function markAgentForFreshMemorySync(agentId) {
20182
20207
  memoryFileHashes.delete(agentId);
20183
20208
  lastDownloadHash.delete(agentId);
20184
20209
  lastLocalFileHash.delete(agentId);
20210
+ lastMemoriesBody.delete(agentId);
20185
20211
  }
20186
20212
  function parseMemoryFile(raw, fallbackName) {
20187
20213
  const trimmed = raw.trim();
@@ -20400,10 +20426,37 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
20400
20426
  return { status: "deferred", tombstones: null, truncated: false };
20401
20427
  }
20402
20428
  try {
20403
- const dbMemories = await api.post("/host/memories", {
20404
- agent_id: agent.agent_id
20429
+ const quoted = lastMemoriesBody.get(agent.agent_id);
20430
+ let wire = await api.post("/host/memories", {
20431
+ agent_id: agent.agent_id,
20432
+ ...quoted ? { known_hash: quoted.hash } : {}
20405
20433
  });
20406
20434
  memoriesFetchGate.markFetched(agent.agent_id, memoriesToken);
20435
+ let held = stillHeld(quoted, lastMemoriesBody.get(agent.agent_id));
20436
+ if (resolveConditionalResponse(wire, held !== void 0).use === "no-body") {
20437
+ log2(
20438
+ `Memory download for '${agent.code_name}': unchanged marker with no cached body (cache purged mid-flight?) \u2014 re-fetching in full`
20439
+ );
20440
+ wire = await api.post("/host/memories", { agent_id: agent.agent_id });
20441
+ held = void 0;
20442
+ }
20443
+ let dbMemories;
20444
+ const decision = resolveConditionalResponse(wire, held !== void 0);
20445
+ if (decision.use === "cached") {
20446
+ dbMemories = held.body;
20447
+ pollCycleMemoriesUnchanged += 1;
20448
+ } else if (decision.use === "no-body") {
20449
+ log2(`Memory download for '${agent.code_name}': server sent 'unchanged' for an untokened request`);
20450
+ return { status: "failed", tombstones: null, truncated: false };
20451
+ } else {
20452
+ dbMemories = wire;
20453
+ if (decision.token) {
20454
+ lastMemoriesBody.set(agent.agent_id, { hash: decision.token, body: dbMemories });
20455
+ } else {
20456
+ lastMemoriesBody.delete(agent.agent_id);
20457
+ }
20458
+ pollCycleMemoriesFull += 1;
20459
+ }
20407
20460
  const tombstones = Array.isArray(dbMemories.tombstones) ? dbMemories.tombstones : null;
20408
20461
  const responseHash = createHash19("sha256").update(JSON.stringify({ m: dbMemories.memories ?? [], t: tombstones })).digest("hex").slice(0, 16);
20409
20462
  if (!force && prevDownload && prevLocalHash === localListHash && lastDownloadHash.get(agent.agent_id) === responseHash) {