@integrity-labs/agt-cli 0.19.17 → 0.19.18

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.
@@ -22,7 +22,7 @@ import {
22
22
  resolveChannels,
23
23
  resolveDmTarget,
24
24
  wrapScheduledTaskPrompt
25
- } from "../chunk-AYSU35A4.js";
25
+ } from "../chunk-WTFROCJ3.js";
26
26
  import {
27
27
  findTaskByTemplate,
28
28
  getProjectDir,
@@ -52,7 +52,7 @@ import {
52
52
  } from "../chunk-3K3RO5NS.js";
53
53
 
54
54
  // src/lib/manager-worker.ts
55
- import { createHash } from "crypto";
55
+ import { createHash as createHash2 } from "crypto";
56
56
  import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, appendFileSync, mkdirSync as mkdirSync2, chmodSync, existsSync as existsSync3, rmSync as rmSync2, readdirSync as readdirSync2, statSync, unlinkSync, copyFileSync } from "fs";
57
57
  import https from "https";
58
58
  import { execFileSync as syncExecFile } from "child_process";
@@ -68,6 +68,27 @@ function decideMcpDriftAction(currentHash, knownHash) {
68
68
  return { kind: "drift", previous: knownHash, current: currentHash };
69
69
  }
70
70
 
71
+ // src/lib/integration-hash.ts
72
+ import { createHash } from "crypto";
73
+ function canonicalize(value) {
74
+ if (Array.isArray(value)) return value.map(canonicalize);
75
+ if (value && typeof value === "object") {
76
+ const obj = value;
77
+ const out = {};
78
+ for (const key of Object.keys(obj).sort()) {
79
+ out[key] = canonicalize(obj[key]);
80
+ }
81
+ return out;
82
+ }
83
+ return value;
84
+ }
85
+ function computeIntegrationsHash(integrations) {
86
+ const payload = integrations.map(
87
+ (i) => `${i.definition_id}:${JSON.stringify(canonicalize(i.credentials ?? {}))}:${JSON.stringify(canonicalize(i.config ?? {}))}`
88
+ );
89
+ return createHash("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
90
+ }
91
+
71
92
  // src/lib/stale-mcp-reaper.ts
72
93
  import { execFileSync } from "child_process";
73
94
  function parseEnvIntegrationsEntries(content) {
@@ -1826,7 +1847,7 @@ var knownSecretsHashes = /* @__PURE__ */ new Map();
1826
1847
  var runningMcpHashes = /* @__PURE__ */ new Map();
1827
1848
  function projectMcpHash(codeName, projectDir) {
1828
1849
  try {
1829
- return createHash("sha256").update(readFileSync3(join4(projectDir, ".mcp.json"))).digest("hex");
1850
+ return createHash2("sha256").update(readFileSync3(join4(projectDir, ".mcp.json"))).digest("hex");
1830
1851
  } catch {
1831
1852
  return null;
1832
1853
  }
@@ -1929,7 +1950,7 @@ function clearAgentCaches(agentId, codeName) {
1929
1950
  var cachedFrameworkVersion = null;
1930
1951
  var lastVersionCheckAt = 0;
1931
1952
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
1932
- var agtCliVersion = true ? "0.19.17" : "dev";
1953
+ var agtCliVersion = true ? "0.19.18" : "dev";
1933
1954
  function resolveBrewPath(execFileSync3) {
1934
1955
  try {
1935
1956
  const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -2454,7 +2475,7 @@ function log(msg) {
2454
2475
  }
2455
2476
  }
2456
2477
  function sha256(content) {
2457
- return createHash("sha256").update(content, "utf8").digest("hex");
2478
+ return createHash2("sha256").update(content, "utf8").digest("hex");
2458
2479
  }
2459
2480
  function hashFile(filePath) {
2460
2481
  try {
@@ -2862,7 +2883,7 @@ async function pollCycle() {
2862
2883
  claudeAuth = await detectClaudeAuth();
2863
2884
  } catch (err) {
2864
2885
  const errText = err instanceof Error ? err.message : String(err);
2865
- const errId = createHash("sha256").update(errText).digest("hex").slice(0, 12);
2886
+ const errId = createHash2("sha256").update(errText).digest("hex").slice(0, 12);
2866
2887
  log(`Claude auth detection failed (error_id=${errId})`);
2867
2888
  }
2868
2889
  await api.post("/host/heartbeat", {
@@ -3408,7 +3429,7 @@ async function processAgent(agent, agentStates) {
3408
3429
  activeChannels.set(channelId, /* @__PURE__ */ new Set());
3409
3430
  }
3410
3431
  activeChannels.get(channelId).add(agent.code_name);
3411
- const configHash = createHash("sha256").update(canonicalJson(entry.config)).digest("hex");
3432
+ const configHash = createHash2("sha256").update(canonicalJson(entry.config)).digest("hex");
3412
3433
  const cacheKey = `${agent.agent_id}:${channelId}`;
3413
3434
  let onDiskPresent = true;
3414
3435
  try {
@@ -3567,7 +3588,7 @@ async function processAgent(agent, agentStates) {
3567
3588
  }
3568
3589
  }
3569
3590
  if (integrations.length > 0) {
3570
- const intHash = createHash("sha256").update(JSON.stringify(integrations.map((i) => `${i.definition_id}:${JSON.stringify(i.credentials)}`))).digest("hex").slice(0, 16);
3591
+ const intHash = computeIntegrationsHash(integrations);
3571
3592
  const prevIntHash = knownIntegrationHashes.get(agent.agent_id);
3572
3593
  if (intHash !== prevIntHash) {
3573
3594
  const projectDir = join4(homedir3(), ".augmented", agent.code_name, "project");
@@ -3635,15 +3656,15 @@ async function processAgent(agent, agentStates) {
3635
3656
  desiredEntries.push({ serverId, url, headers: mcpHeaders, name: tk.toolkit_name });
3636
3657
  }
3637
3658
  const hashBasis = desiredEntries.slice().sort((a, b) => a.serverId.localeCompare(b.serverId)).map((e) => {
3638
- const headersHash = createHash("sha256").update(canonicalJson(e.headers ?? {})).digest("hex").slice(0, 16);
3659
+ const headersHash = createHash2("sha256").update(canonicalJson(e.headers ?? {})).digest("hex").slice(0, 16);
3639
3660
  return `${e.serverId}|${e.url}|${headersHash}`;
3640
3661
  }).join("\n");
3641
- const mcpHash = createHash("sha256").update(hashBasis).digest("hex").slice(0, 16);
3662
+ const mcpHash = createHash2("sha256").update(hashBasis).digest("hex").slice(0, 16);
3642
3663
  const prevMcpHash = knownManagedMcpHashes.get(agent.agent_id);
3643
3664
  if (mcpHash !== prevMcpHash) {
3644
3665
  for (const e of desiredEntries) {
3645
3666
  frameworkAdapter.writeMcpServer(agent.code_name, e.serverId, { url: e.url, headers: e.headers });
3646
- const urlHash = createHash("sha256").update(e.url).digest("hex").slice(0, 12);
3667
+ const urlHash = createHash2("sha256").update(e.url).digest("hex").slice(0, 12);
3647
3668
  log(`[managed-toolkit] ${agent.code_name}: wrote '${e.name}' (serverId=${e.serverId}, url_hash=${urlHash})`);
3648
3669
  }
3649
3670
  if (frameworkAdapter.removeMcpServer && frameworkAdapter.getMcpPath) {
@@ -3765,7 +3786,7 @@ async function processAgent(agent, agentStates) {
3765
3786
  if (frameworkAdapter.installSkillFiles) {
3766
3787
  const currentIntegrationSkillIds = /* @__PURE__ */ new Set();
3767
3788
  const installedIntegrationSkills = [];
3768
- const { createHash: createHash2 } = await import("crypto");
3789
+ const { createHash: createHash3 } = await import("crypto");
3769
3790
  const refreshAny = refreshData;
3770
3791
  const contexts = refreshAny.integration_contexts ?? refreshAny.plugin_contexts ?? [];
3771
3792
  const contextBySlug = /* @__PURE__ */ new Map();
@@ -3794,7 +3815,7 @@ async function processAgent(agent, agentStates) {
3794
3815
  )
3795
3816
  }));
3796
3817
  const bundle = buildIntegrationBundle(renderedScopes);
3797
- const contentHash = createHash2("sha256").update(bundleFingerprint(bundle.files)).digest("hex").slice(0, 12);
3818
+ const contentHash = createHash3("sha256").update(bundleFingerprint(bundle.files)).digest("hex").slice(0, 12);
3798
3819
  const hashKey = `plugin-skill:${agent.agent_id}:${integrationSkillId}`;
3799
3820
  if (knownSkillHashes.get(hashKey) === contentHash) continue;
3800
3821
  frameworkAdapter.installSkillFiles(agent.code_name, integrationSkillId, bundle.files);
@@ -3863,7 +3884,7 @@ async function processAgent(agent, agentStates) {
3863
3884
  const slug = hook.integration_slug ?? hook.plugin_slug;
3864
3885
  if (!slug) continue;
3865
3886
  try {
3866
- const scriptHash = createHash2("sha256").update(hook.script).digest("hex").slice(0, 12);
3887
+ const scriptHash = createHash3("sha256").update(hook.script).digest("hex").slice(0, 12);
3867
3888
  const hookKey = `${agent.agent_id}:${frameworkAdapter.id}:plugin-hook:${slug}:on_install`;
3868
3889
  if (knownSkillHashes.get(hookKey) === scriptHash) continue;
3869
3890
  const result = await frameworkAdapter.executePluginHook({
@@ -3878,9 +3899,9 @@ async function processAgent(agent, agentStates) {
3878
3899
  } else if (result.timedOut) {
3879
3900
  log(`Integration hook on_install '${slug}' TIMED OUT for '${agent.code_name}' after ${result.durationMs}ms`);
3880
3901
  } else {
3881
- const stderrHash = createHash2("sha256").update(result.stderr).digest("hex").slice(0, 12);
3902
+ const stderrHash = createHash3("sha256").update(result.stderr).digest("hex").slice(0, 12);
3882
3903
  const missingCmd = result.exitCode === 127 ? extractCommandNotFound(result.stderr) : null;
3883
- const missingCmdHash = missingCmd ? createHash2("sha256").update(missingCmd).digest("hex").slice(0, 8) : null;
3904
+ const missingCmdHash = missingCmd ? createHash3("sha256").update(missingCmd).digest("hex").slice(0, 8) : null;
3884
3905
  log(
3885
3906
  `Integration hook on_install '${slug}' exited ${result.exitCode} for '${agent.code_name}' ` + (missingCmdHash ? `[missing_command_hash=${missingCmdHash}] ` : "") + `[stderr_hash=${stderrHash} stderr_len=${result.stderr.length}]`
3886
3907
  );
@@ -3939,10 +3960,10 @@ async function processAgent(agent, agentStates) {
3939
3960
  } else if (agentFw === "claude-code" && tasks.length > 0) {
3940
3961
  await syncAndCheckClaudeScheduler(agent, tasks, boardItems, refreshData);
3941
3962
  } else if (frameworkAdapter.syncScheduledTasks && gatewayRunning && gatewayPort) {
3942
- const stableTasksHash = createHash("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
3943
- const boardHash = boardItems.length > 0 ? createHash("sha256").update(JSON.stringify(boardItems.map((b) => ({ id: b.id, title: b.title, status: b.status, priority: b.priority, deliverable: b.deliverable })))).digest("hex").slice(0, 16) : "empty";
3963
+ const stableTasksHash = createHash2("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
3964
+ const boardHash = boardItems.length > 0 ? createHash2("sha256").update(JSON.stringify(boardItems.map((b) => ({ id: b.id, title: b.title, status: b.status, priority: b.priority, deliverable: b.deliverable })))).digest("hex").slice(0, 16) : "empty";
3944
3965
  const resolvedModels = resolveModelChain(refreshData);
3945
- const modelsHash = createHash("sha256").update(JSON.stringify(resolvedModels)).digest("hex").slice(0, 16);
3966
+ const modelsHash = createHash2("sha256").update(JSON.stringify(resolvedModels)).digest("hex").slice(0, 16);
3946
3967
  const combinedHash = `${stableTasksHash}:${boardHash}:${modelsHash}`;
3947
3968
  const prevTasksHash = knownTasksHashes.get(agent.agent_id);
3948
3969
  if (combinedHash !== prevTasksHash) {
@@ -4307,10 +4328,10 @@ var MAX_CLAUDE_CONCURRENCY = 2;
4307
4328
  var claudeSchedulerStates = /* @__PURE__ */ new Map();
4308
4329
  async function syncAndCheckClaudeScheduler(agent, tasks, boardItems, refreshData) {
4309
4330
  const codeName = agent.code_name;
4310
- const stableTasksHash = createHash("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
4311
- const boardHash = boardItems.length > 0 ? createHash("sha256").update(JSON.stringify(boardItems.map((b) => ({ id: b.id, title: b.title, status: b.status, priority: b.priority, deliverable: b.deliverable })))).digest("hex").slice(0, 16) : "empty";
4331
+ const stableTasksHash = createHash2("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
4332
+ const boardHash = boardItems.length > 0 ? createHash2("sha256").update(JSON.stringify(boardItems.map((b) => ({ id: b.id, title: b.title, status: b.status, priority: b.priority, deliverable: b.deliverable })))).digest("hex").slice(0, 16) : "empty";
4312
4333
  const resolvedModels = resolveModelChain(refreshData);
4313
- const modelsHash = createHash("sha256").update(JSON.stringify(resolvedModels)).digest("hex").slice(0, 16);
4334
+ const modelsHash = createHash2("sha256").update(JSON.stringify(resolvedModels)).digest("hex").slice(0, 16);
4314
4335
  const combinedHash = `${stableTasksHash}:${boardHash}:${modelsHash}`;
4315
4336
  const prevHash = knownTasksHashes.get(agent.agent_id);
4316
4337
  if (combinedHash !== prevHash) {
@@ -4388,7 +4409,7 @@ async function startRun(opts) {
4388
4409
  return { run_id: res.run_id ?? null, kanban_item_id: res.kanban_item_id ?? null };
4389
4410
  } catch (err) {
4390
4411
  const errText = err instanceof Error ? err.message : String(err);
4391
- const errId = createHash("sha256").update(errText).digest("hex").slice(0, 12);
4412
+ const errId = createHash2("sha256").update(errText).digest("hex").slice(0, 12);
4392
4413
  log(`[runs] start failed for agent_id=${opts.agent_id} source_type=${opts.source_type} error_id=${errId}`);
4393
4414
  return { run_id: null, kanban_item_id: null };
4394
4415
  }
@@ -4405,7 +4426,7 @@ async function finishRun(runId, outcome, options = {}) {
4405
4426
  });
4406
4427
  } catch (err) {
4407
4428
  const errText = err instanceof Error ? err.message : String(err);
4408
- const errId = createHash("sha256").update(errText).digest("hex").slice(0, 12);
4429
+ const errId = createHash2("sha256").update(errText).digest("hex").slice(0, 12);
4409
4430
  log(`[runs] finish failed for run_id=${runId} outcome=${outcome} error_id=${errId}`);
4410
4431
  }
4411
4432
  }
@@ -4422,7 +4443,7 @@ async function fetchPriorScheduledRuns(agentId, taskId) {
4422
4443
  return rows.filter((r) => typeof r.output_text === "string" && r.output_text.length > 0).map((r) => ({ startedAt: r.started_at, output: r.output_text }));
4423
4444
  } catch (err) {
4424
4445
  const errText = err instanceof Error ? err.message : String(err);
4425
- const errId = createHash("sha256").update(errText).digest("hex").slice(0, 12);
4446
+ const errId = createHash2("sha256").update(errText).digest("hex").slice(0, 12);
4426
4447
  log(`[runs] prior-runs lookup failed for task_id=${taskId} error_id=${errId}`);
4427
4448
  return [];
4428
4449
  }
@@ -4556,10 +4577,10 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
4556
4577
  const classification = classifyOutput(rawOutput);
4557
4578
  if (classification.action === "suppress") {
4558
4579
  const trimmed = (rawOutput ?? "").trim();
4559
- const outputHash = trimmed.length === 0 ? "empty" : createHash("sha256").update(trimmed).digest("hex").slice(0, 12);
4580
+ const outputHash = trimmed.length === 0 ? "empty" : createHash2("sha256").update(trimmed).digest("hex").slice(0, 12);
4560
4581
  log(`[claude-scheduler] Suppressing delivery for '${codeName}' (template=${templateId}, task=${delivery?.taskId ?? "n/a"}) \u2014 output_len=${trimmed.length} output_hash=${outputHash}`);
4561
4582
  if (classification.suppressedNotes) {
4562
- const notesHash = createHash("sha256").update(classification.suppressedNotes).digest("hex").slice(0, 12);
4583
+ const notesHash = createHash2("sha256").update(classification.suppressedNotes).digest("hex").slice(0, 12);
4563
4584
  log(`[claude-scheduler] Suppressed notes for '${codeName}' (task=${delivery?.taskId ?? "n/a"}) \u2014 notes_len=${classification.suppressedNotes.length} notes_hash=${notesHash}`);
4564
4585
  }
4565
4586
  if (delivery?.mode === "announce" && delivery.to) {
@@ -4734,7 +4755,7 @@ async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
4734
4755
  const ctx = getLastFailureContext(codeName);
4735
4756
  const recovery = prepareForRespawn(codeName);
4736
4757
  const tailSummary = !ctx.tail ? "" : KNOWN_SAFE_TAIL_SIGNATURES.has(ctx.signature) ? `; last pane output (${PANE_TAIL_PREVIEW_LINES} of ~20 lines):
4737
- ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash("sha256").update(ctx.tail).digest("hex").slice(0, 12)} (raw at ~/.augmented/${codeName}/pane.log)`;
4758
+ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash2("sha256").update(ctx.tail).digest("hex").slice(0, 12)} (raw at ~/.augmented/${codeName}/pane.log)`;
4738
4759
  const sigSummary = ctx.signature !== "unknown" ? `; signature=${ctx.signature}` : "";
4739
4760
  const recoverySummary = recovery ? `; recovery=${recovery}` : "";
4740
4761
  log(
@@ -4772,7 +4793,7 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash("sha256").u
4772
4793
  if (!claudeAuthTupleBySession.has(codeName)) {
4773
4794
  claudeAuthTupleBySession.set(codeName, currentAuthTuple);
4774
4795
  }
4775
- const stableTasksHash = createHash("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
4796
+ const stableTasksHash = createHash2("sha256").update(JSON.stringify(tasks)).digest("hex").slice(0, 16);
4776
4797
  const prevHash = knownTasksHashes.get(agent.agent_id);
4777
4798
  if (stableTasksHash !== prevHash) {
4778
4799
  const taskInputs = tasks.map((t) => ({
@@ -5245,7 +5266,7 @@ ${escapeXml(msg.content)}
5245
5266
  log(`[direct-chat] Reply sent for '${agent.codeName}'`);
5246
5267
  } catch (err) {
5247
5268
  const errMsg = err instanceof Error ? err.message : String(err);
5248
- const errorId = createHash("sha256").update(errMsg).digest("hex").slice(0, 12);
5269
+ const errorId = createHash2("sha256").update(errMsg).digest("hex").slice(0, 12);
5249
5270
  log(`[direct-chat] Failed to process message for '${agent.codeName}': error_id=${errorId} error=${errMsg.slice(0, 500)}`);
5250
5271
  try {
5251
5272
  await api.post("/host/direct-chat/reply", {
@@ -6395,7 +6416,7 @@ async function syncMemories(agent, configDir, log2) {
6395
6416
  if (!file.endsWith(".md")) continue;
6396
6417
  try {
6397
6418
  const raw = readFileSync3(join4(memoryDir, file), "utf-8");
6398
- const fileHash = createHash("sha256").update(raw).digest("hex").slice(0, 16);
6419
+ const fileHash = createHash2("sha256").update(raw).digest("hex").slice(0, 16);
6399
6420
  currentHashes.set(file, fileHash);
6400
6421
  if (prevHashes.get(file) === fileHash) continue;
6401
6422
  const parsed = parseMemoryFile(raw, file.replace(/\.md$/, ""));
@@ -6433,14 +6454,14 @@ async function syncMemories(agent, configDir, log2) {
6433
6454
  }
6434
6455
  async function downloadMemories(agent, memoryDir, log2, { force }) {
6435
6456
  const localFiles = existsSync3(memoryDir) ? readdirSync2(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
6436
- const localListHash = createHash("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
6457
+ const localListHash = createHash2("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
6437
6458
  const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
6438
6459
  const prevDownload = lastDownloadHash.get(agent.agent_id);
6439
6460
  try {
6440
6461
  const dbMemories = await api.post("/host/memories", {
6441
6462
  agent_id: agent.agent_id
6442
6463
  });
6443
- const responseHash = createHash("sha256").update(JSON.stringify(dbMemories.memories ?? [])).digest("hex").slice(0, 16);
6464
+ const responseHash = createHash2("sha256").update(JSON.stringify(dbMemories.memories ?? [])).digest("hex").slice(0, 16);
6444
6465
  if (!force && prevDownload && prevLocalHash === localListHash && lastDownloadHash.get(agent.agent_id) === responseHash) {
6445
6466
  return true;
6446
6467
  }
@@ -6479,7 +6500,7 @@ ${mem.content}
6479
6500
  }
6480
6501
  if (written > 0 || overwritten > 0) {
6481
6502
  const updatedFiles = readdirSync2(memoryDir).filter((f) => f.endsWith(".md")).sort();
6482
- lastLocalFileHash.set(agent.agent_id, createHash("sha256").update(updatedFiles.join(",")).digest("hex").slice(0, 16));
6503
+ lastLocalFileHash.set(agent.agent_id, createHash2("sha256").update(updatedFiles.join(",")).digest("hex").slice(0, 16));
6483
6504
  log2(`Memory download for '${agent.code_name}': wrote ${written} new, overwrote ${overwritten} stale`);
6484
6505
  }
6485
6506
  }
@@ -6743,7 +6764,7 @@ function deployMcpAssets() {
6743
6764
  const fileHash = (p) => {
6744
6765
  try {
6745
6766
  if (!existsSync3(p)) return null;
6746
- return createHash("sha256").update(readFileSync3(p)).digest("hex");
6767
+ return createHash2("sha256").update(readFileSync3(p)).digest("hex");
6747
6768
  } catch {
6748
6769
  return null;
6749
6770
  }