@integrity-labs/agt-cli 0.28.568 → 0.28.570

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.
@@ -53,7 +53,7 @@ import {
53
53
  safeWriteJsonAtomic,
54
54
  setConfigHash,
55
55
  tripClass
56
- } from "../chunk-VGMO43EI.js";
56
+ } from "../chunk-LNLLMDJJ.js";
57
57
  import {
58
58
  getProjectDir as getProjectDir2,
59
59
  getReadyTasks,
@@ -182,17 +182,17 @@ import {
182
182
  toOpencodeModel,
183
183
  transcriptActivityAgeSeconds,
184
184
  writeEgressAllowlist
185
- } from "../chunk-FSWAPB5J.js";
185
+ } from "../chunk-6XCGZUSS.js";
186
186
  import {
187
187
  reapOrphanChannelMcps
188
188
  } from "../chunk-XWVM4KPK.js";
189
189
 
190
190
  // src/lib/manager-worker.ts
191
191
  import { createHash as createHash17 } from "crypto";
192
- import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, mkdirSync as mkdirSync11, existsSync as existsSync14, rmSync as rmSync5, readdirSync as readdirSync9, statSync as statSync8, copyFileSync } from "fs";
192
+ import { readFileSync as readFileSync27, writeFileSync as writeFileSync14, mkdirSync as mkdirSync11, existsSync as existsSync14, rmSync as rmSync5, readdirSync as readdirSync9, statSync as statSync8, copyFileSync } from "fs";
193
193
  import { execFileSync as syncExecFile } from "child_process";
194
- import { join as join33, dirname as dirname9, delimiter as pathDelimiter } from "path";
195
- import { homedir as homedir15 } from "os";
194
+ import { join as join34, dirname as dirname9, delimiter as pathDelimiter } from "path";
195
+ import { homedir as homedir16 } from "os";
196
196
  import { fileURLToPath } from "url";
197
197
 
198
198
  // src/lib/claude-code-upgrade-throttle.ts
@@ -3504,20 +3504,55 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
3504
3504
  }
3505
3505
 
3506
3506
  // src/lib/tool-call-audit.ts
3507
- import { homedir as homedir9 } from "os";
3508
- import { join as join17 } from "path";
3507
+ import { homedir as homedir10 } from "os";
3508
+ import { join as join18 } from "path";
3509
+
3510
+ // src/lib/agent-logging-mode.ts
3511
+ import { readFileSync as readFileSync11 } from "fs";
3512
+ import { homedir as homedir7 } from "os";
3513
+ import { join as join14 } from "path";
3514
+ var LOGGING_MODES = ["hash-only", "redacted", "full-local"];
3515
+ function charterPath(codeName, homeDir) {
3516
+ const home = homeDir ?? (process.env["HOME"]?.trim() || homedir7());
3517
+ const key = agentRuntimeKey(codeName, homeDir);
3518
+ return join14(home, ".augmented", key, "provision", "CHARTER.md");
3519
+ }
3520
+ function readAgentLoggingMode(codeName, homeDir) {
3521
+ let raw;
3522
+ try {
3523
+ raw = readFileSync11(charterPath(codeName, homeDir), "utf-8");
3524
+ } catch {
3525
+ return { mode: null, reason: "no-charter" };
3526
+ }
3527
+ let frontmatter;
3528
+ try {
3529
+ frontmatter = extractFrontmatter(raw).frontmatter;
3530
+ } catch {
3531
+ return { mode: null, reason: "unparseable" };
3532
+ }
3533
+ if (!frontmatter) return { mode: null, reason: "unparseable" };
3534
+ const declared = frontmatter["logging_mode"];
3535
+ if (declared === void 0 || declared === null) return { mode: null, reason: "not-declared" };
3536
+ if (typeof declared !== "string" || !LOGGING_MODES.includes(declared)) {
3537
+ return { mode: null, reason: "unrecognised" };
3538
+ }
3539
+ return { mode: declared };
3540
+ }
3541
+ function loggingModeWithholdsTargets(reading) {
3542
+ return reading.mode === null || reading.mode === "hash-only";
3543
+ }
3509
3544
 
3510
3545
  // src/lib/tool-call-path-salt.ts
3511
3546
  import { randomBytes } from "crypto";
3512
- import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync11, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync6 } from "fs";
3513
- import { homedir as homedir7 } from "os";
3514
- import { dirname as dirname5, join as join14 } from "path";
3547
+ import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync12, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync6 } from "fs";
3548
+ import { homedir as homedir8 } from "os";
3549
+ import { dirname as dirname5, join as join15 } from "path";
3515
3550
  var SALT_BYTES = 32;
3516
3551
  var SALT_RE = /^[0-9a-f]{64}$/;
3517
3552
  function pathSaltPath(codeName, homeDir) {
3518
- const home = homeDir ?? (process.env["HOME"]?.trim() || homedir7());
3553
+ const home = homeDir ?? (process.env["HOME"]?.trim() || homedir8());
3519
3554
  const key = agentRuntimeKey(codeName, homeDir);
3520
- return join14(home, ".augmented", key, "tool-call-path-salt");
3555
+ return join15(home, ".augmented", key, "tool-call-path-salt");
3521
3556
  }
3522
3557
  function readToolCallPathSalt(codeName, homeDir) {
3523
3558
  let file;
@@ -3528,7 +3563,7 @@ function readToolCallPathSalt(codeName, homeDir) {
3528
3563
  }
3529
3564
  try {
3530
3565
  if (existsSync3(file)) {
3531
- const existing = readFileSync11(file, "utf-8").trim();
3566
+ const existing = readFileSync12(file, "utf-8").trim();
3532
3567
  if (SALT_RE.test(existing)) return existing;
3533
3568
  }
3534
3569
  } catch {
@@ -3554,7 +3589,7 @@ function readToolCallPathSalt(codeName, homeDir) {
3554
3589
  import { statSync as statSync4 } from "fs";
3555
3590
 
3556
3591
  // src/lib/host-archive-address.ts
3557
- import { readFileSync as readFileSync12 } from "fs";
3592
+ import { readFileSync as readFileSync13 } from "fs";
3558
3593
  var DEFAULT_ARCHIVE_ADDRESS_PATH = "/var/lib/augmented/session-archive-address.json";
3559
3594
  var CACHE_TTL_MS = 5 * 60 * 1e3;
3560
3595
  var cache = /* @__PURE__ */ new Map();
@@ -3570,7 +3605,7 @@ function readHostArchiveAddress(path) {
3570
3605
  if (hit && now - hit.at < CACHE_TTL_MS) return hit.value;
3571
3606
  let value = null;
3572
3607
  try {
3573
- const raw = readFileSync12(file, "utf-8");
3608
+ const raw = readFileSync13(file, "utf-8");
3574
3609
  const parsed = JSON.parse(raw);
3575
3610
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
3576
3611
  const obj = parsed;
@@ -3593,8 +3628,8 @@ function readHostArchiveAddress(path) {
3593
3628
  }
3594
3629
 
3595
3630
  // src/lib/tool-call-extractor.ts
3596
- import { closeSync, fstatSync, openSync, readFileSync as readFileSync13, readSync, readdirSync as readdirSync4 } from "fs";
3597
- import { basename, join as join15, relative } from "path";
3631
+ import { closeSync, fstatSync, openSync, readFileSync as readFileSync14, readSync, readdirSync as readdirSync4 } from "fs";
3632
+ import { basename, join as join16, relative } from "path";
3598
3633
  import { StringDecoder } from "string_decoder";
3599
3634
 
3600
3635
  // src/lib/tool-call-redaction.ts
@@ -3723,7 +3758,7 @@ function redactToolTargetInner(toolName, input, ctx) {
3723
3758
  var EXTRACTOR_VERSION = "e1";
3724
3759
  function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
3725
3760
  const files = [];
3726
- const mainAbs = join15(transcriptDir, `${sessionId}.jsonl`);
3761
+ const mainAbs = join16(transcriptDir, `${sessionId}.jsonl`);
3727
3762
  files.push({
3728
3763
  absPath: mainAbs,
3729
3764
  relPath: relative(projectsRoot, mainAbs),
@@ -3731,7 +3766,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
3731
3766
  isSubagent: false,
3732
3767
  subagentId: null
3733
3768
  });
3734
- const subDir = join15(transcriptDir, sessionId, "subagents");
3769
+ const subDir = join16(transcriptDir, sessionId, "subagents");
3735
3770
  let entries;
3736
3771
  try {
3737
3772
  entries = readdirSync4(subDir);
@@ -3740,7 +3775,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
3740
3775
  }
3741
3776
  for (const name of entries) {
3742
3777
  if (!name.endsWith(".jsonl")) continue;
3743
- const abs = join15(subDir, name);
3778
+ const abs = join16(subDir, name);
3744
3779
  const stem = basename(name, ".jsonl");
3745
3780
  files.push({
3746
3781
  absPath: abs,
@@ -3833,6 +3868,7 @@ function scanLines(lines, file, opts) {
3833
3868
  return { records: ordered, pending: pending2 };
3834
3869
  }
3835
3870
  var WINDOW_CHUNK_BYTES = 64 * 1024;
3871
+ var WINDOW_BUDGET_BYTES = 4 * 1024 * 1024;
3836
3872
  function extractTranscriptWindow(file, opts, from) {
3837
3873
  let fd;
3838
3874
  try {
@@ -3844,14 +3880,17 @@ function extractTranscriptWindow(file, opts, from) {
3844
3880
  endLine: from.lineOffset,
3845
3881
  unpaired: [],
3846
3882
  missing: true,
3847
- rewound: false
3883
+ rewound: false,
3884
+ truncated: false
3848
3885
  };
3849
3886
  }
3850
3887
  let startByte = from.byteOffset;
3851
3888
  let startLine = from.lineOffset;
3852
3889
  let rewound = false;
3890
+ let fileSize = null;
3853
3891
  try {
3854
3892
  const { size } = fstatSync(fd);
3893
+ fileSize = size;
3855
3894
  if (startByte > size) {
3856
3895
  startByte = 0;
3857
3896
  startLine = 0;
@@ -3859,15 +3898,22 @@ function extractTranscriptWindow(file, opts, from) {
3859
3898
  }
3860
3899
  } catch {
3861
3900
  }
3901
+ const requested = from.budgetBytes;
3902
+ const budget = typeof requested === "number" && Number.isFinite(requested) && requested >= 1 ? Math.floor(requested) : WINDOW_BUDGET_BYTES;
3862
3903
  const decoder = new StringDecoder("utf8");
3863
3904
  const buf = Buffer.allocUnsafe(WINDOW_CHUNK_BYTES);
3864
3905
  let position = startByte;
3865
3906
  let runningByte = startByte;
3866
3907
  let lineOffset = startLine;
3867
3908
  let carry = "";
3909
+ let hitBudget = false;
3868
3910
  const pairs = [];
3869
3911
  try {
3870
3912
  for (; ; ) {
3913
+ if (runningByte - startByte >= budget) {
3914
+ hitBudget = true;
3915
+ break;
3916
+ }
3871
3917
  const bytesRead = readSync(fd, buf, 0, WINDOW_CHUNK_BYTES, position);
3872
3918
  if (bytesRead <= 0) break;
3873
3919
  position += bytesRead;
@@ -3875,11 +3921,18 @@ function extractTranscriptWindow(file, opts, from) {
3875
3921
  let nl;
3876
3922
  while ((nl = carry.indexOf("\n")) !== -1) {
3877
3923
  const line = carry.slice(0, nl);
3924
+ const lineBytes = Buffer.byteLength(line, "utf8") + 1;
3925
+ const consumed = runningByte - startByte;
3926
+ if (consumed > 0 && consumed + lineBytes > budget) {
3927
+ hitBudget = true;
3928
+ break;
3929
+ }
3878
3930
  pairs.push([lineOffset, line, runningByte]);
3879
- runningByte += Buffer.byteLength(line, "utf8") + 1;
3931
+ runningByte += lineBytes;
3880
3932
  lineOffset += 1;
3881
3933
  carry = carry.slice(nl + 1);
3882
3934
  }
3935
+ if (hitBudget) break;
3883
3936
  }
3884
3937
  } catch {
3885
3938
  } finally {
@@ -3894,13 +3947,22 @@ function extractTranscriptWindow(file, opts, from) {
3894
3947
  byteStart: p.byteStart,
3895
3948
  lineOffset: p.record.line_offset
3896
3949
  })).sort((a, b) => a.byteStart - b.byteStart);
3897
- return { records, endByte: runningByte, endLine: lineOffset, unpaired, missing: false, rewound };
3950
+ const truncated = hitBudget && (fileSize === null || runningByte < fileSize);
3951
+ return {
3952
+ records,
3953
+ endByte: runningByte,
3954
+ endLine: lineOffset,
3955
+ unpaired,
3956
+ missing: false,
3957
+ rewound,
3958
+ truncated
3959
+ };
3898
3960
  }
3899
3961
 
3900
3962
  // src/lib/tool-call-cursor.ts
3901
- import { existsSync as existsSync4, readFileSync as readFileSync14 } from "fs";
3902
- import { homedir as homedir8 } from "os";
3903
- import { join as join16 } from "path";
3963
+ import { existsSync as existsSync4, readFileSync as readFileSync15 } from "fs";
3964
+ import { homedir as homedir9 } from "os";
3965
+ import { join as join17 } from "path";
3904
3966
  var COVERAGE_DISPOSITIONS = [
3905
3967
  "ok",
3906
3968
  "not_entitled",
@@ -3953,27 +4015,42 @@ function parseCursorKey(key) {
3953
4015
  return { sessionId: sessionId.length > 0 ? sessionId : null, transcriptRef: key.slice(i + 1) };
3954
4016
  }
3955
4017
  function cursorStatePath(codeName, homeDir) {
3956
- const home = homeDir ?? (process.env["HOME"]?.trim() || homedir8());
4018
+ const home = homeDir ?? (process.env["HOME"]?.trim() || homedir9());
3957
4019
  const key = agentRuntimeKey(codeName, homeDir);
3958
- return join16(home, ".augmented", key, "tool-call-cursors.json");
4020
+ return join17(home, ".augmented", key, "tool-call-cursors.json");
3959
4021
  }
3960
4022
  function loadCursors(path) {
3961
4023
  const out = /* @__PURE__ */ new Map();
3962
4024
  if (!existsSync4(path)) return out;
3963
4025
  try {
3964
- const parsed = JSON.parse(readFileSync14(path, "utf-8"));
4026
+ const parsed = JSON.parse(readFileSync15(path, "utf-8"));
3965
4027
  if (!parsed || parsed.version !== 1 || typeof parsed.files !== "object") return out;
3966
4028
  for (const [k, v] of Object.entries(parsed.files)) {
3967
4029
  if (!v || typeof v !== "object") continue;
3968
- const offsetsOk = ["byteOffset", "lineOffset", "startedFromLine", "callsExtracted"].every((f) => {
4030
+ const offsetsOk = [
4031
+ "byteOffset",
4032
+ "lineOffset",
4033
+ "startedFromLine",
4034
+ "startedFromByte",
4035
+ "scannedThroughByte",
4036
+ "scannedThroughLine",
4037
+ "rewindGeneration",
4038
+ "callsExtracted"
4039
+ ].every((f) => {
3969
4040
  const n = v[f];
3970
4041
  return n === void 0 || typeof n === "number" && Number.isSafeInteger(n) && n >= 0;
3971
4042
  });
3972
4043
  if (typeof v.byteOffset !== "number" || typeof v.lineOffset !== "number" || !offsetsOk) continue;
4044
+ const startedFromByte = typeof v.startedFromByte === "number" ? v.startedFromByte : v.byteOffset;
3973
4045
  out.set(k, {
3974
4046
  byteOffset: v.byteOffset,
3975
4047
  lineOffset: v.lineOffset,
3976
4048
  startedFromLine: typeof v.startedFromLine === "number" ? v.startedFromLine : 0,
4049
+ startedFromByte,
4050
+ scannedThroughByte: typeof v.scannedThroughByte === "number" ? v.scannedThroughByte : startedFromByte,
4051
+ scannedThroughLine: typeof v.scannedThroughLine === "number" ? v.scannedThroughLine : typeof v.startedFromLine === "number" ? v.startedFromLine : 0,
4052
+ rewindGeneration: typeof v.rewindGeneration === "number" ? v.rewindGeneration : 0,
4053
+ lastWindowTruncated: v.lastWindowTruncated === true,
3977
4054
  callsExtracted: typeof v.callsExtracted === "number" ? v.callsExtracted : 0,
3978
4055
  unpairedSince: typeof v.unpairedSince === "string" ? v.unpairedSince : null,
3979
4056
  lastDisposition: COVERAGE_DISPOSITIONS.includes(v.lastDisposition) ? v.lastDisposition : "ok",
@@ -3992,22 +4069,47 @@ function saveCursors(path, cursors) {
3992
4069
  atomicWriteFileSync(path, JSON.stringify({ version: 1, files }, null, 2));
3993
4070
  }
3994
4071
  function nextCursor(args) {
3995
- const { previous, endByte, endLine, earliestUnpaired, outcome, nowMs } = args;
4072
+ const { endByte, endLine, earliestUnpaired, outcome, nowMs } = args;
3996
4073
  const nowIso = new Date(nowMs).toISOString();
3997
4074
  const disposition = dispositionFor(outcome);
4075
+ const truncated = args.truncated === true;
4076
+ const previous = args.rewound ? {
4077
+ ...args.previous,
4078
+ byteOffset: 0,
4079
+ lineOffset: 0,
4080
+ scannedThroughByte: 0,
4081
+ scannedThroughLine: 0,
4082
+ startedFromByte: 0,
4083
+ startedFromLine: 0,
4084
+ rewindGeneration: args.previous.rewindGeneration + 1,
4085
+ // The call this was waiting on lived in the old file. Holding its clock
4086
+ // would apply an unrelated deadline to the new one.
4087
+ unpairedSince: null
4088
+ } : args.previous;
3998
4089
  if (!mayAdvance(outcome)) {
3999
- return { ...previous, lastDisposition: disposition, lastScanAt: nowIso };
4090
+ return {
4091
+ ...previous,
4092
+ lastDisposition: disposition,
4093
+ lastScanAt: nowIso,
4094
+ lastWindowTruncated: truncated
4095
+ };
4000
4096
  }
4001
4097
  const callsExtracted = previous.callsExtracted + args.callsExtracted;
4098
+ const covered = (throughByte, throughLine) => ({
4099
+ scannedThroughByte: Math.max(previous.scannedThroughByte, throughByte),
4100
+ scannedThroughLine: Math.max(previous.scannedThroughLine, throughLine)
4101
+ });
4002
4102
  if (!earliestUnpaired) {
4003
4103
  return {
4004
4104
  ...previous,
4005
4105
  byteOffset: endByte,
4006
4106
  lineOffset: endLine,
4107
+ ...covered(endByte, endLine),
4007
4108
  callsExtracted,
4008
4109
  unpairedSince: null,
4009
4110
  lastDisposition: disposition,
4010
- lastScanAt: nowIso
4111
+ lastScanAt: nowIso,
4112
+ lastWindowTruncated: truncated
4011
4113
  };
4012
4114
  }
4013
4115
  const since = previous.unpairedSince ?? nowIso;
@@ -4017,20 +4119,30 @@ function nextCursor(args) {
4017
4119
  ...previous,
4018
4120
  byteOffset: endByte,
4019
4121
  lineOffset: endLine,
4122
+ ...covered(endByte, endLine),
4020
4123
  callsExtracted,
4021
4124
  unpairedSince: null,
4022
4125
  lastDisposition: disposition,
4023
- lastScanAt: nowIso
4126
+ lastScanAt: nowIso,
4127
+ lastWindowTruncated: truncated
4024
4128
  };
4025
4129
  }
4130
+ const resumeByte = Math.max(previous.byteOffset, Math.min(endByte, earliestUnpaired.byteStart));
4131
+ const resumeLine = Math.max(previous.lineOffset, Math.min(endLine, earliestUnpaired.lineOffset));
4026
4132
  return {
4027
4133
  ...previous,
4028
- byteOffset: Math.max(previous.byteOffset, Math.min(endByte, earliestUnpaired.byteStart)),
4029
- lineOffset: Math.max(previous.lineOffset, Math.min(endLine, earliestUnpaired.lineOffset)),
4134
+ byteOffset: resumeByte,
4135
+ lineOffset: resumeLine,
4136
+ // Covered ground stops at the unpaired call: the calls from there on were
4137
+ // deliberately NOT sent (their `is_error` would be written null and
4138
+ // `ignoreDuplicates` makes that permanent), so claiming them would be
4139
+ // claiming rows the control plane has never been offered.
4140
+ ...covered(resumeByte, resumeLine),
4030
4141
  callsExtracted,
4031
4142
  unpairedSince: since,
4032
4143
  lastDisposition: disposition,
4033
- lastScanAt: nowIso
4144
+ lastScanAt: nowIso,
4145
+ lastWindowTruncated: truncated
4034
4146
  };
4035
4147
  }
4036
4148
  function initialCursor(args) {
@@ -4038,7 +4150,12 @@ function initialCursor(args) {
4038
4150
  return {
4039
4151
  byteOffset: args.startByte,
4040
4152
  lineOffset: args.startLine,
4153
+ scannedThroughByte: args.startByte,
4154
+ scannedThroughLine: args.startLine,
4041
4155
  startedFromLine: args.startLine,
4156
+ startedFromByte: args.startByte,
4157
+ rewindGeneration: 0,
4158
+ lastWindowTruncated: false,
4042
4159
  callsExtracted: 0,
4043
4160
  unpairedSince: null,
4044
4161
  lastDisposition: "ok",
@@ -4053,9 +4170,14 @@ function coverageRowFor(key, cursor, versions) {
4053
4170
  session_id: sessionId,
4054
4171
  transcript_ref: transcriptRef,
4055
4172
  transcript_rel_path: cursor.transcriptRelPath,
4056
- through_line: cursor.lineOffset,
4057
- through_byte: cursor.byteOffset,
4173
+ through_line: cursor.scannedThroughLine,
4174
+ through_byte: cursor.scannedThroughByte,
4058
4175
  started_from_line: cursor.startedFromLine,
4176
+ started_from_byte: cursor.startedFromByte,
4177
+ scan_position_byte: cursor.byteOffset,
4178
+ scan_position_line: cursor.lineOffset,
4179
+ scan_window_truncated: cursor.lastWindowTruncated,
4180
+ rewind_generation: cursor.rewindGeneration,
4059
4181
  calls_extracted: cursor.callsExtracted,
4060
4182
  last_disposition: cursor.lastDisposition,
4061
4183
  extractor_version: versions.extractor,
@@ -4150,7 +4272,8 @@ async function scanAgentToolCalls(args) {
4150
4272
  }
4151
4273
  const window = extractTranscriptWindow(file, extractOpts, {
4152
4274
  byteOffset: cursor.byteOffset,
4153
- lineOffset: cursor.lineOffset
4275
+ lineOffset: cursor.lineOffset,
4276
+ ...args.windowBudgetBytes === void 0 ? {} : { budgetBytes: args.windowBudgetBytes }
4154
4277
  });
4155
4278
  summary.filesScanned += 1;
4156
4279
  if (window.missing) {
@@ -4161,6 +4284,11 @@ async function scanAgentToolCalls(args) {
4161
4284
  if (window.rewound) {
4162
4285
  log2(`[tool-call-scan] ${file.relPath} ref=${file.ref} shrank below the cursor \u2014 re-reading from 0`);
4163
4286
  }
4287
+ if (window.truncated) {
4288
+ log2(
4289
+ `[tool-call-scan] ${file.relPath} ref=${file.ref} hit the window budget at byte ${window.endByte} \u2014 more remains, resuming next tick`
4290
+ );
4291
+ }
4164
4292
  summary.callsExtracted += window.records.length;
4165
4293
  const unpairedIds = new Set(window.unpaired.map((u) => u.toolUseId));
4166
4294
  const sendable = window.records.filter((r) => !unpairedIds.has(r.tool_use_id));
@@ -4183,7 +4311,9 @@ async function scanAgentToolCalls(args) {
4183
4311
  earliestUnpaired: window.unpaired[0] ?? null,
4184
4312
  outcome,
4185
4313
  callsExtracted: sendable.length,
4186
- nowMs: now()
4314
+ nowMs: now(),
4315
+ rewound: window.rewound,
4316
+ truncated: window.truncated
4187
4317
  });
4188
4318
  const advanced = attempted ? computed : { ...computed, lastDisposition: cursor.lastDisposition };
4189
4319
  if (advanced.byteOffset === cursor.byteOffset && outcome.kind === "ingest_failed") {
@@ -4260,12 +4390,19 @@ async function maybeScanToolCalls(args) {
4260
4390
  return;
4261
4391
  }
4262
4392
  state5.set(codeName, { lastCheckedAt: nowMs, notEntitledAt: existing?.notEntitledAt ?? null });
4393
+ const loggingMode = readAgentLoggingMode(codeName, args.homeDir);
4394
+ const hashOnly = loggingModeWithholdsTargets(loggingMode);
4395
+ if (loggingMode.mode === null) {
4396
+ log2(
4397
+ `[tool-call-audit] ${codeName}: charter logging_mode not established (${loggingMode.reason}) \u2014 withholding ALL targets for this agent`
4398
+ );
4399
+ }
4263
4400
  const salt = readToolCallPathSalt(codeName, args.homeDir);
4264
- if (!salt) {
4401
+ if (!salt && !hashOnly) {
4265
4402
  log2(`[tool-call-audit] ${codeName}: no path-hash salt available \u2014 file targets withheld`);
4266
4403
  }
4267
- const home = args.homeDir ?? (process.env["HOME"]?.trim() || homedir9());
4268
- const projectsRoot = args.projectsRoot ?? join17(home, ".claude", "projects");
4404
+ const home = args.homeDir ?? (process.env["HOME"]?.trim() || homedir10());
4405
+ const projectsRoot = args.projectsRoot ?? join18(home, ".claude", "projects");
4269
4406
  const transcriptDir = args.transcriptDir ?? sessionTranscriptDir(getProjectDir(codeName));
4270
4407
  const current = peekCurrentSession(codeName);
4271
4408
  const sessionIds = current ? [current.sessionId] : [];
@@ -4277,7 +4414,7 @@ async function maybeScanToolCalls(args) {
4277
4414
  projectsRoot,
4278
4415
  sessionIds,
4279
4416
  pathHashSalt: salt ?? "",
4280
- ...args.hashOnly === void 0 ? {} : { hashOnly: args.hashOnly },
4417
+ hashOnly,
4281
4418
  log: log2,
4282
4419
  now: nowFn,
4283
4420
  ...args.homeDir === void 0 ? {} : { homeDir: args.homeDir },
@@ -4294,11 +4431,11 @@ async function maybeScanToolCalls(args) {
4294
4431
  }
4295
4432
 
4296
4433
  // src/lib/activity-cache-monitor.ts
4297
- import { existsSync as existsSync5, readFileSync as readFileSync15 } from "fs";
4298
- import { homedir as homedir10 } from "os";
4299
- import { join as join18 } from "path";
4434
+ import { existsSync as existsSync5, readFileSync as readFileSync16 } from "fs";
4435
+ import { homedir as homedir11 } from "os";
4436
+ import { join as join19 } from "path";
4300
4437
  var MIN_CHECK_INTERVAL_MS7 = 6e4;
4301
- var STATS_CACHE_PATH = join18(homedir10(), ".claude", "stats-cache.json");
4438
+ var STATS_CACHE_PATH = join19(homedir11(), ".claude", "stats-cache.json");
4302
4439
  var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
4303
4440
  var state6 = { lastObservedDate: null, lastCheckedAt: 0 };
4304
4441
  function selectNewDailyRows(raw, lastObservedDate) {
@@ -4346,7 +4483,7 @@ async function maybeReportActivityCache(args) {
4346
4483
  }
4347
4484
  let raw;
4348
4485
  try {
4349
- raw = readFileSync15(STATS_CACHE_PATH, "utf-8");
4486
+ raw = readFileSync16(STATS_CACHE_PATH, "utf-8");
4350
4487
  } catch (err) {
4351
4488
  log2(`[activity-cache] readFileSync failed: ${err.message}`);
4352
4489
  return;
@@ -4571,18 +4708,18 @@ function computeChannelConfigHash(input) {
4571
4708
  }
4572
4709
 
4573
4710
  // src/lib/channel-hash-cache.ts
4574
- import { existsSync as existsSync6, readFileSync as readFileSync16, writeFileSync as writeFileSync7 } from "fs";
4575
- import { join as join19 } from "path";
4711
+ import { existsSync as existsSync6, readFileSync as readFileSync17, writeFileSync as writeFileSync7 } from "fs";
4712
+ import { join as join20 } from "path";
4576
4713
  var CACHE_FILENAME = "channel-hash-cache.json";
4577
4714
  function getChannelHashCacheFile(configDir) {
4578
- return join19(configDir, CACHE_FILENAME);
4715
+ return join20(configDir, CACHE_FILENAME);
4579
4716
  }
4580
4717
  function loadChannelHashCache(target, configDir) {
4581
4718
  const path = getChannelHashCacheFile(configDir);
4582
4719
  if (!existsSync6(path)) return;
4583
4720
  let parsed;
4584
4721
  try {
4585
- parsed = JSON.parse(readFileSync16(path, "utf-8"));
4722
+ parsed = JSON.parse(readFileSync17(path, "utf-8"));
4586
4723
  } catch {
4587
4724
  return;
4588
4725
  }
@@ -4602,8 +4739,8 @@ function saveChannelHashCache(source, configDir) {
4602
4739
  }
4603
4740
 
4604
4741
  // src/lib/sender-policy-baseline.ts
4605
- import { existsSync as existsSync7, readFileSync as readFileSync17 } from "fs";
4606
- import { join as join20 } from "path";
4742
+ import { existsSync as existsSync7, readFileSync as readFileSync18 } from "fs";
4743
+ import { join as join21 } from "path";
4607
4744
  var BASELINE_FILENAME = "sender-policy-baseline.json";
4608
4745
  var SENDER_POLICY_BASELINE_VERSION = 1;
4609
4746
  var BASELINE_CONCERNS = ["senderPolicy", "slackBehaviour", "msteamsBehaviour"];
@@ -4615,14 +4752,14 @@ function createDeliveryBaselineMaps() {
4615
4752
  };
4616
4753
  }
4617
4754
  function getSenderPolicyBaselineFile(configDir) {
4618
- return join20(configDir, BASELINE_FILENAME);
4755
+ return join21(configDir, BASELINE_FILENAME);
4619
4756
  }
4620
4757
  function loadSenderPolicyBaseline(target, configDir, log2) {
4621
4758
  const path = getSenderPolicyBaselineFile(configDir);
4622
4759
  if (!existsSync7(path)) return;
4623
4760
  let parsed;
4624
4761
  try {
4625
- parsed = JSON.parse(readFileSync17(path, "utf-8"));
4762
+ parsed = JSON.parse(readFileSync18(path, "utf-8"));
4626
4763
  } catch (err) {
4627
4764
  log2?.(
4628
4765
  `[sender-policy] discarding corrupt ${BASELINE_FILENAME} (${err.message}) - restrictive-policy agents will take one fail-closed restart`
@@ -5145,7 +5282,7 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash, options)
5145
5282
  }
5146
5283
 
5147
5284
  // src/lib/manager/integration-skill-cache.ts
5148
- import { join as join21 } from "path";
5285
+ import { join as join22 } from "path";
5149
5286
  function integrationSkillHashKey(agentId, skillId) {
5150
5287
  return `plugin-skill:${agentId}:${skillId}`;
5151
5288
  }
@@ -5161,21 +5298,21 @@ function forgetIntegrationSkill(cache3, agentId, skillId) {
5161
5298
  function removeIntegrationSkillFolder(opts) {
5162
5299
  forgetIntegrationSkill(opts.cache, opts.agentId, opts.entry);
5163
5300
  for (const dir of opts.dirs) {
5164
- opts.removeDir(join21(dir, opts.entry));
5301
+ opts.removeDir(join22(dir, opts.entry));
5165
5302
  }
5166
5303
  }
5167
5304
 
5168
5305
  // src/lib/manager/managed-skill-manifest.ts
5169
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync18, writeFileSync as writeFileSync8 } from "fs";
5170
- import { dirname as dirname6, join as join22 } from "path";
5306
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync19, writeFileSync as writeFileSync8 } from "fs";
5307
+ import { dirname as dirname6, join as join23 } from "path";
5171
5308
  var MANIFEST_VERSION = 1;
5172
5309
  function managedSkillManifestPath(agentRootDir) {
5173
- return join22(agentRootDir, "managed-skills.json");
5310
+ return join23(agentRootDir, "managed-skills.json");
5174
5311
  }
5175
5312
  function readManagedSkillManifest(path) {
5176
5313
  try {
5177
5314
  if (!existsSync8(path)) return /* @__PURE__ */ new Set();
5178
- const parsed = JSON.parse(readFileSync18(path, "utf-8"));
5315
+ const parsed = JSON.parse(readFileSync19(path, "utf-8"));
5179
5316
  const ids = Array.isArray(parsed?.globalSkillIds) ? parsed.globalSkillIds : [];
5180
5317
  return new Set(ids.filter((id) => typeof id === "string" && id.length > 0));
5181
5318
  } catch {
@@ -5288,8 +5425,8 @@ function resolveModelChain(refreshData) {
5288
5425
 
5289
5426
  // src/lib/manager/claude-auth.ts
5290
5427
  import { existsSync as existsSync9, rmSync as rmSync3 } from "fs";
5291
- import { join as join23 } from "path";
5292
- import { homedir as homedir11 } from "os";
5428
+ import { join as join24 } from "path";
5429
+ import { homedir as homedir12 } from "os";
5293
5430
  async function applyClaudeAuthToEnv(childEnv, label) {
5294
5431
  const apiKey = getApiKey();
5295
5432
  if (!apiKey) {
@@ -5301,9 +5438,9 @@ async function applyClaudeAuthToEnv(childEnv, label) {
5301
5438
  throw new Error("claude_auth_mode=api_key but /host/exchange returned no decrypted key");
5302
5439
  }
5303
5440
  childEnv.ANTHROPIC_API_KEY = exchange.anthropicApiKey;
5304
- const claudeDir = join23(homedir11(), ".claude");
5441
+ const claudeDir = join24(homedir12(), ".claude");
5305
5442
  for (const filename of [".credentials.json", "credentials.json"]) {
5306
- const p = join23(claudeDir, filename);
5443
+ const p = join24(claudeDir, filename);
5307
5444
  if (existsSync9(p)) {
5308
5445
  try {
5309
5446
  rmSync3(p, { force: true });
@@ -5385,8 +5522,8 @@ function heartbeatRuntimeAuthFields(probeVerdict) {
5385
5522
  }
5386
5523
 
5387
5524
  // src/lib/manager/kanban/parsers.ts
5388
- import { existsSync as existsSync10, readFileSync as readFileSync19 } from "fs";
5389
- import { join as join24 } from "path";
5525
+ import { existsSync as existsSync10, readFileSync as readFileSync20 } from "fs";
5526
+ import { join as join25 } from "path";
5390
5527
  var STANDUP_TEMPLATES = /* @__PURE__ */ new Set(["daily-standup", "end-of-day-summary"]);
5391
5528
  var TASK_UPDATE_TEMPLATES = /* @__PURE__ */ new Set(["hourly-status", "task-update"]);
5392
5529
  var PLAN_TEMPLATES = /* @__PURE__ */ new Set(["morning-plan"]);
@@ -5538,12 +5675,12 @@ function getBuiltInSkillContent(skillId) {
5538
5675
  if (builtInSkillCache.has(skillId)) return builtInSkillCache.get(skillId);
5539
5676
  try {
5540
5677
  const candidates = [
5541
- join24(process.cwd(), "skills", skillId, "SKILL.md"),
5542
- join24(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "..", "..", "skills", skillId, "SKILL.md")
5678
+ join25(process.cwd(), "skills", skillId, "SKILL.md"),
5679
+ join25(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "..", "..", "skills", skillId, "SKILL.md")
5543
5680
  ];
5544
5681
  for (const candidate of candidates) {
5545
5682
  if (existsSync10(candidate)) {
5546
- const content = readFileSync19(candidate, "utf-8");
5683
+ const content = readFileSync20(candidate, "utf-8");
5547
5684
  const files = [{ relativePath: "SKILL.md", content }];
5548
5685
  builtInSkillCache.set(skillId, files);
5549
5686
  return files;
@@ -5684,19 +5821,19 @@ function formatBoardForPrompt(items, template) {
5684
5821
  }
5685
5822
 
5686
5823
  // src/lib/manager/kanban/nudge-state-cache.ts
5687
- import { existsSync as existsSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync9 } from "fs";
5688
- import { join as join25 } from "path";
5824
+ import { existsSync as existsSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
5825
+ import { join as join26 } from "path";
5689
5826
  var CACHE_FILENAME2 = "kanban-nudge-state.json";
5690
5827
  var KANBAN_NUDGE_STATE_VERSION = 1;
5691
5828
  function getKanbanNudgeStateFile(configDir) {
5692
- return join25(configDir, CACHE_FILENAME2);
5829
+ return join26(configDir, CACHE_FILENAME2);
5693
5830
  }
5694
5831
  function loadKanbanNudgeState(target, configDir) {
5695
5832
  const path = getKanbanNudgeStateFile(configDir);
5696
5833
  if (!existsSync11(path)) return;
5697
5834
  let parsed;
5698
5835
  try {
5699
- parsed = JSON.parse(readFileSync20(path, "utf-8"));
5836
+ parsed = JSON.parse(readFileSync21(path, "utf-8"));
5700
5837
  } catch {
5701
5838
  return;
5702
5839
  }
@@ -6303,9 +6440,9 @@ function closeScheduledRunsForCode(codeName, outcome, reason) {
6303
6440
 
6304
6441
  // src/lib/manager/scheduler/kanban-route.ts
6305
6442
  import { createHash as createHash12 } from "crypto";
6306
- import { writeFileSync as writeFileSync10, renameSync as renameSync4, mkdirSync as mkdirSync7, readFileSync as readFileSync21, unlinkSync as unlinkSync2 } from "fs";
6307
- import { homedir as homedir12 } from "os";
6308
- import { join as join26, dirname as dirname7 } from "path";
6443
+ import { writeFileSync as writeFileSync10, renameSync as renameSync4, mkdirSync as mkdirSync7, readFileSync as readFileSync22, unlinkSync as unlinkSync2 } from "fs";
6444
+ import { homedir as homedir13 } from "os";
6445
+ import { join as join27, dirname as dirname7 } from "path";
6309
6446
 
6310
6447
  // src/lib/manager/scheduler/notify.ts
6311
6448
  import { createHash as createHash11 } from "crypto";
@@ -6664,7 +6801,7 @@ function resolveScheduledSlackTarget(task) {
6664
6801
  }
6665
6802
  function stampScheduledTurnMarker(codeName, taskId, target) {
6666
6803
  try {
6667
- const file = join26(homedir12(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
6804
+ const file = join27(homedir13(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
6668
6805
  const marker = { ts: Date.now(), task_id: taskId, ...target ? { target } : {} };
6669
6806
  const tmp = `${file}.tmp`;
6670
6807
  writeFileSync10(tmp, JSON.stringify(marker), "utf8");
@@ -6674,9 +6811,9 @@ function stampScheduledTurnMarker(codeName, taskId, target) {
6674
6811
  }
6675
6812
  }
6676
6813
  function clearScheduledTurnMarkerForTask(codeName, taskId) {
6677
- const file = join26(homedir12(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
6814
+ const file = join27(homedir13(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
6678
6815
  try {
6679
- const raw = JSON.parse(readFileSync21(file, "utf8"));
6816
+ const raw = JSON.parse(readFileSync22(file, "utf8"));
6680
6817
  if (typeof raw?.task_id !== "string" || raw.task_id !== taskId) return;
6681
6818
  unlinkSync2(file);
6682
6819
  log(`[scheduled-kanban] scheduled-turn marker cleared for '${codeName}' (task ${taskId} complete)`);
@@ -6736,7 +6873,7 @@ async function routeScheduledTaskViaKanban(codeName, agentId, task, prompt, dura
6736
6873
  return false;
6737
6874
  }
6738
6875
  try {
6739
- const doorbell = directChatDoorbellPath(agentId, homedir12());
6876
+ const doorbell = directChatDoorbellPath(agentId, homedir13());
6740
6877
  mkdirSync7(dirname7(doorbell), { recursive: true });
6741
6878
  writeFileSync10(doorbell, String(Date.now()));
6742
6879
  } catch (err) {
@@ -6888,12 +7025,12 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
6888
7025
 
6889
7026
  // src/lib/manager/scheduler/execution.ts
6890
7027
  import { createHash as createHash13 } from "crypto";
6891
- import { homedir as homedir13 } from "os";
6892
- import { join as join28 } from "path";
7028
+ import { homedir as homedir14 } from "os";
7029
+ import { join as join29 } from "path";
6893
7030
 
6894
7031
  // src/lib/agent-serving-probe.ts
6895
- import { readFileSync as readFileSync22, readdirSync as readdirSync5, statSync as statSync5 } from "fs";
6896
- import { join as join27 } from "path";
7032
+ import { readFileSync as readFileSync23, readdirSync as readdirSync5, statSync as statSync5 } from "fs";
7033
+ import { join as join28 } from "path";
6897
7034
  var RATE_LIMIT_WINDOW_MS = 6 * 60 * 60 * 1e3;
6898
7035
  function probeRateLimit(args) {
6899
7036
  const now = args.now ?? /* @__PURE__ */ new Date();
@@ -6909,7 +7046,7 @@ function probeRateLimit(args) {
6909
7046
  let newest = UNKNOWN_RATE_LIMIT;
6910
7047
  for (const name of entries) {
6911
7048
  if (!name.endsWith(".jsonl")) continue;
6912
- const path = join27(dir, name);
7049
+ const path = join28(dir, name);
6913
7050
  try {
6914
7051
  const st = statSync5(path);
6915
7052
  if (!st.isFile() || st.mtimeMs < startMs) continue;
@@ -6918,7 +7055,7 @@ function probeRateLimit(args) {
6918
7055
  }
6919
7056
  let content;
6920
7057
  try {
6921
- content = readFileSync22(path, "utf-8");
7058
+ content = readFileSync23(path, "utf-8");
6922
7059
  } catch {
6923
7060
  continue;
6924
7061
  }
@@ -6980,7 +7117,7 @@ function shouldLogUsageCapDeferral(site, codeName, limitedUntil) {
6980
7117
 
6981
7118
  // src/lib/manager/scheduler/execution.ts
6982
7119
  function claudePidFilePath() {
6983
- return join28(homedir13(), ".augmented", "manager-claude-pids.json");
7120
+ return join29(homedir14(), ".augmented", "manager-claude-pids.json");
6984
7121
  }
6985
7122
  var inFlightClaudePids = /* @__PURE__ */ new Map();
6986
7123
  function registerClaudeSpawn(record) {
@@ -7051,7 +7188,7 @@ async function syncAndCheckClaudeScheduler(agent, tasks, boardItems, refreshData
7051
7188
 
7052
7189
  // src/lib/occupancy-gate.ts
7053
7190
  import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync6, readSync as readSync2, statSync as statSync6 } from "fs";
7054
- import { join as join29 } from "path";
7191
+ import { join as join30 } from "path";
7055
7192
  var TAIL_BYTES = 256 * 1024;
7056
7193
  var MAX_RECORD_ALIGN_BYTES = 8 * 1024 * 1024;
7057
7194
  var GATE_MAX_BUCKET_AGE_MS = 30 * 6e4;
@@ -7137,10 +7274,10 @@ function candidateTranscriptPaths(dir) {
7137
7274
  let complete = true;
7138
7275
  for (const name of top) {
7139
7276
  if (name.endsWith(".jsonl")) {
7140
- paths.push(join29(dir, name));
7277
+ paths.push(join30(dir, name));
7141
7278
  continue;
7142
7279
  }
7143
- const subDir = join29(dir, name, "subagents");
7280
+ const subDir = join30(dir, name, "subagents");
7144
7281
  let subs;
7145
7282
  try {
7146
7283
  subs = readdirSync6(subDir);
@@ -7149,7 +7286,7 @@ function candidateTranscriptPaths(dir) {
7149
7286
  continue;
7150
7287
  }
7151
7288
  for (const sub of subs) {
7152
- if (sub.endsWith(".jsonl")) paths.push(join29(subDir, sub));
7289
+ if (sub.endsWith(".jsonl")) paths.push(join30(subDir, sub));
7153
7290
  }
7154
7291
  }
7155
7292
  return { paths, complete };
@@ -8422,9 +8559,9 @@ async function fireOpencodeScheduledTask(agent, task) {
8422
8559
 
8423
8560
  // src/lib/opencode-telegram-ingest.ts
8424
8561
  import { createHash as createHash16 } from "crypto";
8425
- import { existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync23, renameSync as renameSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync11 } from "fs";
8562
+ import { existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync24, renameSync as renameSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync11 } from "fs";
8426
8563
  import { randomUUID } from "crypto";
8427
- import { join as join30 } from "path";
8564
+ import { join as join31 } from "path";
8428
8565
 
8429
8566
  // src/lib/telegram-ingest.ts
8430
8567
  import https2 from "https";
@@ -8972,7 +9109,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
8972
9109
  let filePath;
8973
9110
  try {
8974
9111
  dir = getFramework("opencode").getAgentDir(codeName);
8975
- filePath = join30(dir, "telegram-getupdates-offset-opencode.json");
9112
+ filePath = join31(dir, "telegram-getupdates-offset-opencode.json");
8976
9113
  } catch {
8977
9114
  dir = null;
8978
9115
  filePath = null;
@@ -8981,7 +9118,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
8981
9118
  load() {
8982
9119
  if (!filePath) return 0;
8983
9120
  try {
8984
- const parsed = JSON.parse(readFileSync23(filePath, "utf-8"));
9121
+ const parsed = JSON.parse(readFileSync24(filePath, "utf-8"));
8985
9122
  if (currentBotId != null && typeof parsed?.bot_id === "number" && parsed.bot_id !== currentBotId) {
8986
9123
  log2(`[telegram-ingest:${codeName}] offset cursor belongs to a different bot; ignoring (bot swap)`);
8987
9124
  return 0;
@@ -9251,15 +9388,15 @@ function partitionActionableByPoison(actionable, states, config2) {
9251
9388
  }
9252
9389
 
9253
9390
  // src/lib/restart-flags.ts
9254
- import { existsSync as existsSync13, mkdirSync as mkdirSync9, readdirSync as readdirSync7, readFileSync as readFileSync24, renameSync as renameSync6, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "fs";
9255
- import { homedir as homedir14 } from "os";
9256
- import { join as join31 } from "path";
9391
+ import { existsSync as existsSync13, mkdirSync as mkdirSync9, readdirSync as readdirSync7, readFileSync as readFileSync25, renameSync as renameSync6, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "fs";
9392
+ import { homedir as homedir15 } from "os";
9393
+ import { join as join32 } from "path";
9257
9394
  import { randomUUID as randomUUID2 } from "crypto";
9258
9395
  function restartFlagsDir() {
9259
- return join31(homedir14(), ".augmented", "restart-flags");
9396
+ return join32(homedir15(), ".augmented", "restart-flags");
9260
9397
  }
9261
9398
  function flagPath(codeName) {
9262
- return join31(restartFlagsDir(), `${codeName}.flag`);
9399
+ return join32(restartFlagsDir(), `${codeName}.flag`);
9263
9400
  }
9264
9401
  function readRestartFlags() {
9265
9402
  const dir = restartFlagsDir();
@@ -9268,7 +9405,7 @@ function readRestartFlags() {
9268
9405
  for (const entry of readdirSync7(dir)) {
9269
9406
  if (!entry.endsWith(".flag")) continue;
9270
9407
  try {
9271
- const raw = readFileSync24(join31(dir, entry), "utf8");
9408
+ const raw = readFileSync25(join32(dir, entry), "utf8");
9272
9409
  const parsed = JSON.parse(raw);
9273
9410
  if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
9274
9411
  parsed.codeName = entry.replace(/\.flag$/, "");
@@ -9386,8 +9523,8 @@ async function sendError(flag, opts, text) {
9386
9523
  }
9387
9524
 
9388
9525
  // src/lib/restart-context.ts
9389
- import { readdirSync as readdirSync8, readFileSync as readFileSync25, writeFileSync as writeFileSync13, mkdirSync as mkdirSync10, unlinkSync as unlinkSync4 } from "fs";
9390
- import { dirname as dirname8, join as join32 } from "path";
9526
+ import { readdirSync as readdirSync8, readFileSync as readFileSync26, writeFileSync as writeFileSync13, mkdirSync as mkdirSync10, unlinkSync as unlinkSync4 } from "fs";
9527
+ import { dirname as dirname8, join as join33 } from "path";
9391
9528
  var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
9392
9529
  var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
9393
9530
  var MAX_TOPIC_CHARS = 140;
@@ -9399,10 +9536,10 @@ function augmentedAgentDir(codeName) {
9399
9536
  return dirname8(getProjectDir(codeName));
9400
9537
  }
9401
9538
  function slackPendingInboundDir(codeName) {
9402
- return join32(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
9539
+ return join33(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
9403
9540
  }
9404
9541
  function slackRestartContextDir(codeName) {
9405
- return join32(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
9542
+ return join33(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
9406
9543
  }
9407
9544
  function sanitizeTopic(raw) {
9408
9545
  const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
@@ -9444,7 +9581,7 @@ function safeReaddir(dir) {
9444
9581
  }
9445
9582
  function readStrandedMarker(path) {
9446
9583
  try {
9447
- const parsed = JSON.parse(readFileSync25(path, "utf-8"));
9584
+ const parsed = JSON.parse(readFileSync26(path, "utf-8"));
9448
9585
  if (typeof parsed.channel === "string" && typeof parsed.thread_ts === "string") {
9449
9586
  return { channel: parsed.channel, thread_ts: parsed.thread_ts };
9450
9587
  }
@@ -9462,7 +9599,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
9462
9599
  if (!filename.endsWith(".json")) continue;
9463
9600
  if (freshFilenames.has(filename)) continue;
9464
9601
  try {
9465
- unlinkSync4(join32(ctxDir, filename));
9602
+ unlinkSync4(join33(ctxDir, filename));
9466
9603
  } catch {
9467
9604
  }
9468
9605
  }
@@ -9483,7 +9620,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
9483
9620
  }
9484
9621
  const markers = [];
9485
9622
  for (const filename of markerFilenames.slice(0, cap)) {
9486
- const parsed = readStrandedMarker(join32(markerDir, filename));
9623
+ const parsed = readStrandedMarker(join33(markerDir, filename));
9487
9624
  if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
9488
9625
  }
9489
9626
  if (markers.length === 0) {
@@ -9497,7 +9634,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
9497
9634
  const freshFilenames = /* @__PURE__ */ new Set();
9498
9635
  for (const { filename, hint } of hints) {
9499
9636
  try {
9500
- writeHintFile(join32(ctxDir, filename), ctxDir, hint);
9637
+ writeHintFile(join33(ctxDir, filename), ctxDir, hint);
9501
9638
  freshFilenames.add(filename);
9502
9639
  } catch (err) {
9503
9640
  log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
@@ -11014,7 +11151,7 @@ var runningChannelSecretHashes = /* @__PURE__ */ new Map();
11014
11151
  var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
11015
11152
  function projectMcpHash(_codeName, projectDir) {
11016
11153
  try {
11017
- const raw = readFileSync26(join33(projectDir, ".mcp.json"), "utf-8");
11154
+ const raw = readFileSync27(join34(projectDir, ".mcp.json"), "utf-8");
11018
11155
  return createHash17("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
11019
11156
  } catch {
11020
11157
  return null;
@@ -11022,7 +11159,7 @@ function projectMcpHash(_codeName, projectDir) {
11022
11159
  }
11023
11160
  function projectMcpKeys(_codeName, projectDir) {
11024
11161
  try {
11025
- const raw = readFileSync26(join33(projectDir, ".mcp.json"), "utf-8");
11162
+ const raw = readFileSync27(join34(projectDir, ".mcp.json"), "utf-8");
11026
11163
  const parsed = JSON.parse(raw);
11027
11164
  const servers = parsed.mcpServers;
11028
11165
  if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
@@ -11040,7 +11177,7 @@ function seedSessionLaunchBaselines(codeName, projectDir) {
11040
11177
  else runningMcpServerKeys.delete(codeName);
11041
11178
  let launchStructure = null;
11042
11179
  try {
11043
- const raw = readFileSync26(join33(projectDir, ".mcp.json"), "utf-8");
11180
+ const raw = readFileSync27(join34(projectDir, ".mcp.json"), "utf-8");
11044
11181
  launchStructure = managedMcpStructureHashFromFile(
11045
11182
  JSON.parse(raw),
11046
11183
  isManagedMcpServerKey
@@ -11150,7 +11287,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
11150
11287
  if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
11151
11288
  let mcpJsonForRebind = null;
11152
11289
  try {
11153
- mcpJsonForRebind = JSON.parse(readFileSync26(join33(projectDir, ".mcp.json"), "utf-8"));
11290
+ mcpJsonForRebind = JSON.parse(readFileSync27(join34(projectDir, ".mcp.json"), "utf-8"));
11154
11291
  } catch {
11155
11292
  mcpJsonForRebind = null;
11156
11293
  }
@@ -11294,7 +11431,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
11294
11431
  function projectChannelSecretHash(projectDir) {
11295
11432
  try {
11296
11433
  const entries = parseEnvIntegrations(
11297
- readFileSync26(join33(projectDir, ".env.integrations"), "utf-8")
11434
+ readFileSync27(join34(projectDir, ".env.integrations"), "utf-8")
11298
11435
  );
11299
11436
  return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
11300
11437
  } catch {
@@ -11390,7 +11527,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
11390
11527
  var lastVersionCheckAt = 0;
11391
11528
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
11392
11529
  var lastResponsivenessProbeAt = 0;
11393
- var agtCliVersion = true ? "0.28.568" : "dev";
11530
+ var agtCliVersion = true ? "0.28.570" : "dev";
11394
11531
  function resolveBrewPath(execFileSync2) {
11395
11532
  try {
11396
11533
  const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -11723,7 +11860,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
11723
11860
  try {
11724
11861
  let settings = {};
11725
11862
  if (existsSync14(path)) {
11726
- const raw = readFileSync26(path, "utf-8").trim();
11863
+ const raw = readFileSync27(path, "utf-8").trim();
11727
11864
  if (raw) {
11728
11865
  let parsed;
11729
11866
  try {
@@ -11778,7 +11915,7 @@ async function ensureOpencodeBinary() {
11778
11915
  try {
11779
11916
  const prefix = execFileSync2("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
11780
11917
  if (prefix) {
11781
- const npmBin = join33(prefix, "bin");
11918
+ const npmBin = join34(prefix, "bin");
11782
11919
  const current = (process.env.PATH ?? "").split(pathDelimiter);
11783
11920
  if (!current.includes(npmBin)) {
11784
11921
  process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
@@ -11895,7 +12032,7 @@ ${r.stderr}`;
11895
12032
  }
11896
12033
  var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
11897
12034
  function selfUpdateAppliedMarkerPath() {
11898
- return join33(homedir15(), ".augmented", ".last-self-update-applied");
12035
+ return join34(homedir16(), ".augmented", ".last-self-update-applied");
11899
12036
  }
11900
12037
  var selfUpdateUpToDateLogged = false;
11901
12038
  var selfUpdatePinnedLogged = false;
@@ -11924,7 +12061,7 @@ async function checkAndUpdateCli(opts) {
11924
12061
  const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
11925
12062
  if (!isBrewFormula && !isNpmGlobal) return "noop";
11926
12063
  const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
11927
- const markerPath = join33(homedir15(), ".augmented", ".last-update-check");
12064
+ const markerPath = join34(homedir16(), ".augmented", ".last-update-check");
11928
12065
  if (!force) {
11929
12066
  try {
11930
12067
  const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
@@ -12330,7 +12467,7 @@ async function runClaudeRuntimeAuthProbe() {
12330
12467
  ];
12331
12468
  try {
12332
12469
  const { stdout, stderr } = await execFilePromiseLong(resolveClaudeBinary(), args, {
12333
- cwd: homedir15(),
12470
+ cwd: homedir16(),
12334
12471
  timeout: RUNTIME_AUTH_PROBE_TIMEOUT_MS,
12335
12472
  stdin: "ignore",
12336
12473
  env: childEnv,
@@ -12377,12 +12514,12 @@ async function checkClaudeAuth() {
12377
12514
  var evalEmptyMcpConfigPath = null;
12378
12515
  function ensureEvalEmptyMcpConfig() {
12379
12516
  if (evalEmptyMcpConfigPath && existsSync14(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
12380
- const dir = join33(homedir15(), ".augmented");
12517
+ const dir = join34(homedir16(), ".augmented");
12381
12518
  try {
12382
12519
  mkdirSync11(dir, { recursive: true });
12383
12520
  } catch {
12384
12521
  }
12385
- const p = join33(dir, ".eval-empty-mcp.json");
12522
+ const p = join34(dir, ".eval-empty-mcp.json");
12386
12523
  writeFileSync14(p, JSON.stringify({ mcpServers: {} }));
12387
12524
  evalEmptyMcpConfigPath = p;
12388
12525
  return p;
@@ -12408,7 +12545,7 @@ async function runEvalClaude(prompt, model) {
12408
12545
  ""
12409
12546
  ];
12410
12547
  const { stdout } = await execFilePromiseLong(resolveClaudeBinary(), args, {
12411
- cwd: homedir15(),
12548
+ cwd: homedir16(),
12412
12549
  timeout: 12e4,
12413
12550
  stdin: "ignore",
12414
12551
  env: childEnv,
@@ -12477,10 +12614,10 @@ function resolveConversationEvalBackend() {
12477
12614
  return conversationEvalBackend;
12478
12615
  }
12479
12616
  function getStateFile() {
12480
- return join33(config?.configDir ?? join33(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
12617
+ return join34(config?.configDir ?? join34(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
12481
12618
  }
12482
12619
  function channelHashCacheDir() {
12483
- return config?.configDir ?? join33(process.env["HOME"] ?? "/tmp", ".augmented");
12620
+ return config?.configDir ?? join34(process.env["HOME"] ?? "/tmp", ".augmented");
12484
12621
  }
12485
12622
  function loadChannelHashCache2() {
12486
12623
  loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
@@ -12534,7 +12671,7 @@ function removeDeliveryBaselineEntries(agentId) {
12534
12671
  var _channelQuarantineStore = null;
12535
12672
  function channelQuarantineStore() {
12536
12673
  if (!_channelQuarantineStore) {
12537
- const dir = config?.configDir ?? join33(process.env["HOME"] ?? "/tmp", ".augmented");
12674
+ const dir = config?.configDir ?? join34(process.env["HOME"] ?? "/tmp", ".augmented");
12538
12675
  _channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
12539
12676
  }
12540
12677
  return _channelQuarantineStore;
@@ -12551,7 +12688,7 @@ function claudeMdSizeFor(codeName) {
12551
12688
  var _hostFlagStore = null;
12552
12689
  function hostFlagStore() {
12553
12690
  if (!_hostFlagStore) {
12554
- const dir = config?.configDir ?? join33(process.env["HOME"] ?? "/tmp", ".augmented");
12691
+ const dir = config?.configDir ?? join34(process.env["HOME"] ?? "/tmp", ".augmented");
12555
12692
  _hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
12556
12693
  }
12557
12694
  return _hostFlagStore;
@@ -12625,12 +12762,12 @@ function parseSkillFrontmatter(content) {
12625
12762
  }
12626
12763
  async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
12627
12764
  const { readdirSync: readdirSync10, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync15 } = await import("fs");
12628
- const skillsDir = join33(configDir, codeName, "project", ".claude", "skills");
12629
- const claudeMdPath = join33(configDir, codeName, "project", "CLAUDE.md");
12765
+ const skillsDir = join34(configDir, codeName, "project", ".claude", "skills");
12766
+ const claudeMdPath = join34(configDir, codeName, "project", "CLAUDE.md");
12630
12767
  if (!ex(skillsDir) || !ex(claudeMdPath)) return;
12631
12768
  const entries = [];
12632
12769
  for (const dir of readdirSync10(skillsDir).sort()) {
12633
- const skillFile = join33(skillsDir, dir, "SKILL.md");
12770
+ const skillFile = join34(skillsDir, dir, "SKILL.md");
12634
12771
  if (!ex(skillFile)) continue;
12635
12772
  try {
12636
12773
  const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
@@ -12697,7 +12834,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
12697
12834
  if (codeNames.length === 0) return;
12698
12835
  void (async () => {
12699
12836
  try {
12700
- const { collectDiagnostics } = await import("../persistent-session-DVTSZAPE.js");
12837
+ const { collectDiagnostics } = await import("../persistent-session-HY6GUPBQ.js");
12701
12838
  await api.post("/host/heartbeat", {
12702
12839
  host_id: hostId,
12703
12840
  agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics)
@@ -12805,7 +12942,7 @@ async function pollCycle() {
12805
12942
  }
12806
12943
  try {
12807
12944
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
12808
- const { collectDiagnostics } = await import("../persistent-session-DVTSZAPE.js");
12945
+ const { collectDiagnostics } = await import("../persistent-session-HY6GUPBQ.js");
12809
12946
  const diagCodeNames = [...agentState.persistentSessionAgents];
12810
12947
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics) : void 0;
12811
12948
  let tailscaleHostname;
@@ -12928,7 +13065,7 @@ async function pollCycle() {
12928
13065
  collectPanelessActivityProbes,
12929
13066
  getResponsivenessIntervalMs,
12930
13067
  occupancyQualificationClassifications
12931
- } = await import("../responsiveness-probe-KEFPJXQ6.js");
13068
+ } = await import("../responsiveness-probe-6EEZKJVV.js");
12932
13069
  const probeIntervalMs = getResponsivenessIntervalMs();
12933
13070
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
12934
13071
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -13019,7 +13156,7 @@ async function pollCycle() {
13019
13156
  collectResponsivenessProbes,
13020
13157
  livePendingInboundOldestAgeSeconds,
13021
13158
  parkPendingInbound
13022
- } = await import("../responsiveness-probe-KEFPJXQ6.js");
13159
+ } = await import("../responsiveness-probe-6EEZKJVV.js");
13023
13160
  const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-NDP36U7O.js");
13024
13161
  const wedgeNow = /* @__PURE__ */ new Date();
13025
13162
  const liveAgents = agentState.persistentSessionAgents;
@@ -13108,13 +13245,13 @@ async function pollCycle() {
13108
13245
  );
13109
13246
  if (hostFlagStore().getBoolean("wedge-transient-notice")) {
13110
13247
  try {
13111
- const paneTail = readFileSync26(paneLogPath(codeName), "utf8").slice(-65536);
13248
+ const paneTail = readFileSync27(paneLogPath(codeName), "utf8").slice(-65536);
13112
13249
  const transient = detectTransientApiErrorInLog(paneTail);
13113
13250
  if (transient) {
13114
- const wedgeHome = join33(homedir15(), ".augmented", codeName);
13251
+ const wedgeHome = join34(homedir16(), ".augmented", codeName);
13115
13252
  if (existsSync14(wedgeHome)) {
13116
13253
  atomicWriteFileSync(
13117
- join33(wedgeHome, "watchdog-give-up.json"),
13254
+ join34(wedgeHome, "watchdog-give-up.json"),
13118
13255
  JSON.stringify({
13119
13256
  gave_up_at: wedgeNow.toISOString(),
13120
13257
  reason: "transient_overload"
@@ -13395,7 +13532,7 @@ async function pollCycle() {
13395
13532
  const adapter = resolveAgentFramework(prev.codeName);
13396
13533
  stopAgentRuntime2(prev.codeName, "removed-from-host");
13397
13534
  killAgentChannelProcesses(prev.codeName, { log });
13398
- const agentDir = join33(adapter.getAgentDir(prev.codeName), "provision");
13535
+ const agentDir = join34(adapter.getAgentDir(prev.codeName), "provision");
13399
13536
  await cleanupAgentFiles(prev.codeName, agentDir);
13400
13537
  clearAgentCaches(prev.agentId, prev.codeName);
13401
13538
  }
@@ -13482,10 +13619,10 @@ async function pollCycle() {
13482
13619
  // pending-inbound marker. Best-effort: a write failure is logged by
13483
13620
  // the watchdog, never fails the poll cycle.
13484
13621
  signalGiveUp: (codeName) => {
13485
- const dir = join33(homedir15(), ".augmented", codeName);
13622
+ const dir = join34(homedir16(), ".augmented", codeName);
13486
13623
  if (!existsSync14(dir)) return;
13487
13624
  atomicWriteFileSync(
13488
- join33(dir, "watchdog-give-up.json"),
13625
+ join34(dir, "watchdog-give-up.json"),
13489
13626
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
13490
13627
  );
13491
13628
  }
@@ -13641,7 +13778,7 @@ async function processAgent(agent, agentStates) {
13641
13778
  }
13642
13779
  const now = (/* @__PURE__ */ new Date()).toISOString();
13643
13780
  const adapter = resolveAgentFramework(agent.code_name);
13644
- let agentDir = join33(adapter.getAgentDir(agent.code_name), "provision");
13781
+ let agentDir = join34(adapter.getAgentDir(agent.code_name), "provision");
13645
13782
  if (agent.status === "draft" || agent.status === "paused") {
13646
13783
  if (previousKnownStatus !== agent.status) {
13647
13784
  log(`Agent '${agent.code_name}' is ${agent.status}, skipping provisioning`);
@@ -13815,7 +13952,7 @@ async function processAgent(agent, agentStates) {
13815
13952
  const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
13816
13953
  agentFrameworkCache.set(agent.code_name, frameworkId);
13817
13954
  const frameworkAdapter = getFramework(frameworkId);
13818
- agentDir = join33(frameworkAdapter.getAgentDir(agent.code_name), "provision");
13955
+ agentDir = join34(frameworkAdapter.getAgentDir(agent.code_name), "provision");
13819
13956
  cacheAgentDeliveryMetadata(agent.code_name, refreshData);
13820
13957
  agentRestartTimezoneInputs.set(agent.code_name, {
13821
13958
  agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
@@ -13864,7 +14001,7 @@ async function processAgent(agent, agentStates) {
13864
14001
  const changedFiles = [];
13865
14002
  mkdirSync11(agentDir, { recursive: true });
13866
14003
  for (const artifact of artifacts) {
13867
- const filePath = join33(agentDir, artifact.relativePath);
14004
+ const filePath = join34(agentDir, artifact.relativePath);
13868
14005
  let existingHash;
13869
14006
  let newHash;
13870
14007
  let writeContent = artifact.content;
@@ -13883,8 +14020,8 @@ async function processAgent(agent, agentStates) {
13883
14020
  };
13884
14021
  newHash = sha256(stripDynamicSections(artifact.content));
13885
14022
  try {
13886
- const projectClaudeMd = join33(config.configDir, agent.code_name, "project", "CLAUDE.md");
13887
- const existing = readFileSync26(projectClaudeMd, "utf-8");
14023
+ const projectClaudeMd = join34(config.configDir, agent.code_name, "project", "CLAUDE.md");
14024
+ const existing = readFileSync27(projectClaudeMd, "utf-8");
13888
14025
  existingHash = sha256(stripDynamicSections(existing));
13889
14026
  } catch {
13890
14027
  existingHash = null;
@@ -13902,7 +14039,7 @@ async function processAgent(agent, agentStates) {
13902
14039
  const generatorKeys = Object.keys(generatorServers);
13903
14040
  let existingRaw = "";
13904
14041
  try {
13905
- existingRaw = readFileSync26(filePath, "utf-8");
14042
+ existingRaw = readFileSync27(filePath, "utf-8");
13906
14043
  } catch {
13907
14044
  }
13908
14045
  const existingServers = parseMcp(existingRaw);
@@ -13918,7 +14055,7 @@ async function processAgent(agent, agentStates) {
13918
14055
  } else if (artifact.relativePath === "opencode.json") {
13919
14056
  let existingRaw = null;
13920
14057
  try {
13921
- existingRaw = readFileSync26(filePath, "utf-8");
14058
+ existingRaw = readFileSync27(filePath, "utf-8");
13922
14059
  } catch {
13923
14060
  }
13924
14061
  const mergeResult = mergeOpencodeConfigArtifact(artifact.content, existingRaw);
@@ -13934,12 +14071,12 @@ async function processAgent(agent, agentStates) {
13934
14071
  }
13935
14072
  }
13936
14073
  if (changedFiles.length > 0) {
13937
- const isFirst = !existsSync14(join33(agentDir, "CHARTER.md"));
14074
+ const isFirst = !existsSync14(join34(agentDir, "CHARTER.md"));
13938
14075
  const verb = isFirst ? "Provisioning" : "Updating";
13939
14076
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
13940
14077
  log(`${verb} '${agent.code_name}': ${fileNames}`);
13941
14078
  for (const file of changedFiles) {
13942
- const filePath = join33(agentDir, file.relativePath);
14079
+ const filePath = join34(agentDir, file.relativePath);
13943
14080
  mkdirSync11(dirname9(filePath), { recursive: true });
13944
14081
  if (file.relativePath === ".mcp.json") {
13945
14082
  safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
@@ -13948,12 +14085,12 @@ async function processAgent(agent, agentStates) {
13948
14085
  }
13949
14086
  }
13950
14087
  try {
13951
- const provSkillsDir = join33(agentDir, ".claude", "skills");
14088
+ const provSkillsDir = join34(agentDir, ".claude", "skills");
13952
14089
  if (existsSync14(provSkillsDir)) {
13953
14090
  for (const folder of readdirSync9(provSkillsDir)) {
13954
14091
  if (folder.startsWith("knowledge-")) {
13955
14092
  try {
13956
- rmSync5(join33(provSkillsDir, folder), { recursive: true });
14093
+ rmSync5(join34(provSkillsDir, folder), { recursive: true });
13957
14094
  } catch {
13958
14095
  }
13959
14096
  }
@@ -13966,7 +14103,7 @@ async function processAgent(agent, agentStates) {
13966
14103
  const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
13967
14104
  const hashes = /* @__PURE__ */ new Map();
13968
14105
  for (const file of trackedFiles2) {
13969
- const h = hashFile(join33(agentDir, file));
14106
+ const h = hashFile(join34(agentDir, file));
13970
14107
  if (h) hashes.set(file, h);
13971
14108
  }
13972
14109
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -13984,14 +14121,14 @@ async function processAgent(agent, agentStates) {
13984
14121
  }
13985
14122
  if (Array.isArray(refreshData.workflows)) {
13986
14123
  try {
13987
- const provWorkflowsDir = join33(agentDir, ".claude", "workflows");
14124
+ const provWorkflowsDir = join34(agentDir, ".claude", "workflows");
13988
14125
  if (existsSync14(provWorkflowsDir)) {
13989
14126
  const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
13990
14127
  for (const file of readdirSync9(provWorkflowsDir)) {
13991
14128
  if (!file.endsWith(".js")) continue;
13992
14129
  if (expected.has(file)) continue;
13993
14130
  try {
13994
- rmSync5(join33(provWorkflowsDir, file));
14131
+ rmSync5(join34(provWorkflowsDir, file));
13995
14132
  } catch {
13996
14133
  }
13997
14134
  }
@@ -14073,7 +14210,7 @@ async function processAgent(agent, agentStates) {
14073
14210
  if (written && existsSync14(agentDir)) {
14074
14211
  const driftedFiles = [];
14075
14212
  for (const [file, expectedHash] of written) {
14076
- const localHash = hashFile(join33(agentDir, file));
14213
+ const localHash = hashFile(join34(agentDir, file));
14077
14214
  if (localHash && localHash !== expectedHash) {
14078
14215
  driftedFiles.push(file);
14079
14216
  }
@@ -14084,7 +14221,7 @@ async function processAgent(agent, agentStates) {
14084
14221
  try {
14085
14222
  const localHashes = {};
14086
14223
  for (const file of driftedFiles) {
14087
- localHashes[file] = hashFile(join33(agentDir, file));
14224
+ localHashes[file] = hashFile(join34(agentDir, file));
14088
14225
  }
14089
14226
  await api.post("/host/drift", {
14090
14227
  agent_id: agent.agent_id,
@@ -14286,7 +14423,7 @@ async function processAgent(agent, agentStates) {
14286
14423
  const addedChannels = [...restartDecision.added];
14287
14424
  const writeDmNoticeMarkers = isChannelAddRestart ? () => {
14288
14425
  try {
14289
- const agentAugmentedDir = join33(homedir15(), ".augmented", agent.code_name);
14426
+ const agentAugmentedDir = join34(homedir16(), ".augmented", agent.code_name);
14290
14427
  mkdirSync11(agentAugmentedDir, { recursive: true });
14291
14428
  const markerJson = JSON.stringify({
14292
14429
  version: 1,
@@ -14294,7 +14431,7 @@ async function processAgent(agent, agentStates) {
14294
14431
  added: addedChannels
14295
14432
  });
14296
14433
  for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
14297
- atomicWriteFileSync(join33(agentAugmentedDir, file), markerJson);
14434
+ atomicWriteFileSync(join34(agentAugmentedDir, file), markerJson);
14298
14435
  }
14299
14436
  } catch (err) {
14300
14437
  log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
@@ -14483,18 +14620,18 @@ async function processAgent(agent, agentStates) {
14483
14620
  if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
14484
14621
  try {
14485
14622
  const agentProvisionDir = agentDir;
14486
- const projectDir = join33(homedir15(), ".augmented", agent.code_name, "project");
14623
+ const projectDir = join34(homedir16(), ".augmented", agent.code_name, "project");
14487
14624
  mkdirSync11(agentProvisionDir, { recursive: true });
14488
14625
  mkdirSync11(projectDir, { recursive: true });
14489
- const provisionMcpPath = join33(agentProvisionDir, ".mcp.json");
14490
- const projectMcpPath = join33(projectDir, ".mcp.json");
14626
+ const provisionMcpPath = join34(agentProvisionDir, ".mcp.json");
14627
+ const projectMcpPath = join34(projectDir, ".mcp.json");
14491
14628
  let mcpConfig = { mcpServers: {} };
14492
14629
  try {
14493
- mcpConfig = JSON.parse(readFileSync26(provisionMcpPath, "utf-8"));
14630
+ mcpConfig = JSON.parse(readFileSync27(provisionMcpPath, "utf-8"));
14494
14631
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
14495
14632
  } catch {
14496
14633
  }
14497
- const localDirectChatChannel = join33(homedir15(), ".augmented", "_mcp", "direct-chat-channel.js");
14634
+ const localDirectChatChannel = join34(homedir16(), ".augmented", "_mcp", "direct-chat-channel.js");
14498
14635
  const directChatTeamSettings = refreshData.team?.settings;
14499
14636
  const directChatTz = (() => {
14500
14637
  const tz = directChatTeamSettings?.["timezone"];
@@ -14520,7 +14657,7 @@ async function processAgent(agent, agentStates) {
14520
14657
  // ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
14521
14658
  // returns the agent root (NOT the /provision subdir `agentDir` points at),
14522
14659
  // so it byte-matches the broker readers' path.
14523
- AGT_TURN_INITIATOR_FILE: join33(
14660
+ AGT_TURN_INITIATOR_FILE: join34(
14524
14661
  frameworkAdapter.getAgentDir(agent.code_name),
14525
14662
  ".current-turn-initiator.json"
14526
14663
  )
@@ -14540,7 +14677,7 @@ async function processAgent(agent, agentStates) {
14540
14677
  log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
14541
14678
  }
14542
14679
  }
14543
- const staleChannelsPath = join33(projectDir, ".mcp-channels.json");
14680
+ const staleChannelsPath = join34(projectDir, ".mcp-channels.json");
14544
14681
  if (existsSync14(staleChannelsPath)) {
14545
14682
  try {
14546
14683
  rmSync5(staleChannelsPath, { force: true });
@@ -14630,7 +14767,7 @@ async function processAgent(agent, agentStates) {
14630
14767
  }
14631
14768
  if (hostFlagStore().getBoolean("connectivity-probe")) {
14632
14769
  try {
14633
- const probeProjectDir = join33(homedir15(), ".augmented", agent.code_name, "project");
14770
+ const probeProjectDir = join34(homedir16(), ".augmented", agent.code_name, "project");
14634
14771
  let probeSet = integrations;
14635
14772
  try {
14636
14773
  const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
@@ -14676,7 +14813,7 @@ async function processAgent(agent, agentStates) {
14676
14813
  const forceDue = attemptsLeft > 0;
14677
14814
  let probeRan = false;
14678
14815
  try {
14679
- const probeProjectDir = join33(homedir15(), ".augmented", agent.code_name, "project");
14816
+ const probeProjectDir = join34(homedir16(), ".augmented", agent.code_name, "project");
14680
14817
  probeRan = await runAgentSessionToolBindProbes(agent, integrations, probeProjectDir, { forceDue });
14681
14818
  } catch (err) {
14682
14819
  log(`Session-tool-bind probe failed for '${agent.code_name}': ${err.message}`);
@@ -14753,11 +14890,11 @@ async function processAgent(agent, agentStates) {
14753
14890
  const intHash = computeIntegrationsHash(integrations);
14754
14891
  const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
14755
14892
  if (intHash !== prevIntHash) {
14756
- const projectDir = join33(homedir15(), ".augmented", agent.code_name, "project");
14757
- const envIntPath = join33(projectDir, ".env.integrations");
14893
+ const projectDir = join34(homedir16(), ".augmented", agent.code_name, "project");
14894
+ const envIntPath = join34(projectDir, ".env.integrations");
14758
14895
  let preWriteEnv;
14759
14896
  try {
14760
- preWriteEnv = readFileSync26(envIntPath, "utf-8");
14897
+ preWriteEnv = readFileSync27(envIntPath, "utf-8");
14761
14898
  } catch {
14762
14899
  preWriteEnv = void 0;
14763
14900
  }
@@ -14776,9 +14913,9 @@ async function processAgent(agent, agentStates) {
14776
14913
  }
14777
14914
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
14778
14915
  try {
14779
- const projectMcpPath = join33(projectDir, ".mcp.json");
14780
- const postWriteEnv = readFileSync26(envIntPath, "utf-8");
14781
- const mcpContent = readFileSync26(projectMcpPath, "utf-8");
14916
+ const projectMcpPath = join34(projectDir, ".mcp.json");
14917
+ const postWriteEnv = readFileSync27(envIntPath, "utf-8");
14918
+ const mcpContent = readFileSync27(projectMcpPath, "utf-8");
14782
14919
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
14783
14920
  const mcpJsonForReap = JSON.parse(mcpContent);
14784
14921
  const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
@@ -15042,16 +15179,16 @@ async function processAgent(agent, agentStates) {
15042
15179
  }
15043
15180
  try {
15044
15181
  const { readdirSync: readdirSync10, rmSync: rmSync6 } = await import("fs");
15045
- const { homedir: homedir16 } = await import("os");
15182
+ const { homedir: homedir17 } = await import("os");
15046
15183
  const frameworkId2 = frameworkAdapter.id;
15047
15184
  const candidateSkillDirs = [
15048
15185
  // Claude Code — framework runtime tree
15049
- join33(homedir16(), ".augmented", agent.code_name, "skills"),
15186
+ join34(homedir17(), ".augmented", agent.code_name, "skills"),
15050
15187
  // Claude Code — project tree
15051
- join33(homedir16(), ".augmented", agent.code_name, "project", ".claude", "skills"),
15188
+ join34(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
15052
15189
  // Defensive: legacy provision-side path, not currently an
15053
15190
  // install target but cheap to sweep.
15054
- join33(agentDir, ".claude", "skills")
15191
+ join34(agentDir, ".claude", "skills")
15055
15192
  ];
15056
15193
  const existingDirs = candidateSkillDirs.filter((d) => existsSync14(d));
15057
15194
  const discoveredEntries = /* @__PURE__ */ new Set();
@@ -15092,7 +15229,7 @@ async function processAgent(agent, agentStates) {
15092
15229
  const sharedSkillsPayload = refreshAny.shared_skills;
15093
15230
  const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
15094
15231
  const manifestPath = managedSkillManifestPath(
15095
- join33(homedir15(), ".augmented", agent.code_name)
15232
+ join34(homedir16(), ".augmented", agent.code_name)
15096
15233
  );
15097
15234
  const prevIds = /* @__PURE__ */ new Set([
15098
15235
  ...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
@@ -15112,15 +15249,15 @@ async function processAgent(agent, agentStates) {
15112
15249
  }
15113
15250
  if (plan.removes.length) {
15114
15251
  const globalSkillDirs = [
15115
- join33(homedir15(), ".augmented", agent.code_name, "skills"),
15116
- join33(homedir15(), ".augmented", agent.code_name, "project", ".claude", "skills"),
15117
- join33(agentDir, ".claude", "skills")
15252
+ join34(homedir16(), ".augmented", agent.code_name, "skills"),
15253
+ join34(homedir16(), ".augmented", agent.code_name, "project", ".claude", "skills"),
15254
+ join34(agentDir, ".claude", "skills")
15118
15255
  ];
15119
15256
  for (const id of plan.removes) {
15120
15257
  let prunedAny = false;
15121
15258
  for (const dir of globalSkillDirs) {
15122
- const p = join33(dir, id);
15123
- if (existsSync14(p) && existsSync14(join33(p, "SKILL.md"))) {
15259
+ const p = join34(dir, id);
15260
+ if (existsSync14(p) && existsSync14(join34(p, "SKILL.md"))) {
15124
15261
  rmSync5(p, { recursive: true, force: true });
15125
15262
  prunedAny = true;
15126
15263
  }
@@ -15352,8 +15489,8 @@ async function processAgent(agent, agentStates) {
15352
15489
  const sess = getSessionState(agent.code_name);
15353
15490
  let mcpJsonParsed = null;
15354
15491
  try {
15355
- const mcpPath = join33(getProjectDir(agent.code_name), ".mcp.json");
15356
- mcpJsonParsed = JSON.parse(readFileSync26(mcpPath, "utf-8"));
15492
+ const mcpPath = join34(getProjectDir(agent.code_name), ".mcp.json");
15493
+ mcpJsonParsed = JSON.parse(readFileSync27(mcpPath, "utf-8"));
15357
15494
  } catch {
15358
15495
  }
15359
15496
  reapMissingMcpSessions({
@@ -15787,7 +15924,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
15787
15924
  if (trackedFiles.length > 0 && existsSync14(agentDir)) {
15788
15925
  const hashes = /* @__PURE__ */ new Map();
15789
15926
  for (const file of trackedFiles) {
15790
- const h = hashFile(join33(agentDir, file));
15927
+ const h = hashFile(join34(agentDir, file));
15791
15928
  if (h) hashes.set(file, h);
15792
15929
  }
15793
15930
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -15802,7 +15939,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
15802
15939
  refreshData.agent.onboarding_state
15803
15940
  );
15804
15941
  const obStep = obState.step;
15805
- const markerPath = join33(homedir15(), ".augmented", agent.code_name, "onboarding-drive.json");
15942
+ const markerPath = join34(homedir16(), ".augmented", agent.code_name, "onboarding-drive.json");
15806
15943
  const marker = readOnboardingDriveMarker(markerPath);
15807
15944
  const decision = decideOnboardingDrive(obStep, marker, Date.now(), obState.generation ?? 0);
15808
15945
  if (decision.clearMarker) {
@@ -15890,7 +16027,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
15890
16027
  }
15891
16028
  stopOpencodeSlackIngest(codeName, log);
15892
16029
  stopOpencodeTelegramIngest(codeName, log);
15893
- const opencodeProjectDir = join33(getFramework("opencode").getAgentDir(codeName), "provision");
16030
+ const opencodeProjectDir = join34(getFramework("opencode").getAgentDir(codeName), "provision");
15894
16031
  const serveEnv = {
15895
16032
  AGT_HOST: requireHost(),
15896
16033
  AGT_API_KEY: getApiKey() ?? void 0,
@@ -15945,8 +16082,8 @@ async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
15945
16082
  });
15946
16083
  }
15947
16084
  const projectDir = getProjectDir(codeName);
15948
- const mcpConfigPath = join33(projectDir, ".mcp.json");
15949
- const claudeMdPath = join33(projectDir, "CLAUDE.md");
16085
+ const mcpConfigPath = join34(projectDir, ".mcp.json");
16086
+ const claudeMdPath = join34(projectDir, "CLAUDE.md");
15950
16087
  if (restartBreaker.isTripped(codeName)) {
15951
16088
  const trip = restartBreaker.getTrip(codeName);
15952
16089
  return {
@@ -16578,7 +16715,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
16578
16715
  void api.post("/host/restart-ack", { host_id: hostId, agent_id: agentId, restart_requested_at: requestedAt }).catch((err) => log(`[restart-lane] ack failed for '${codeName}': ${err.message}`));
16579
16716
  void (async () => {
16580
16717
  try {
16581
- const { collectDiagnostics } = await import("../persistent-session-DVTSZAPE.js");
16718
+ const { collectDiagnostics } = await import("../persistent-session-HY6GUPBQ.js");
16582
16719
  await api.post("/host/heartbeat", {
16583
16720
  host_id: hostId,
16584
16721
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics)
@@ -16629,7 +16766,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
16629
16766
  }
16630
16767
  try {
16631
16768
  const hostId = await getHostId();
16632
- const { collectDiagnostics } = await import("../persistent-session-DVTSZAPE.js");
16769
+ const { collectDiagnostics } = await import("../persistent-session-HY6GUPBQ.js");
16633
16770
  await api.post("/host/heartbeat", {
16634
16771
  host_id: hostId,
16635
16772
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics)
@@ -16972,7 +17109,7 @@ async function processDirectChatMessage(agent, msg) {
16972
17109
  const useDoorbell = hostFlagStore().getBoolean("direct-chat-doorbell") || isolationMode(agent.codeName) === "docker";
16973
17110
  if (useDoorbell) {
16974
17111
  try {
16975
- const doorbell = directChatDoorbellPath(agent.agentId, homedir15());
17112
+ const doorbell = directChatDoorbellPath(agent.agentId, homedir16());
16976
17113
  mkdirSync11(dirname9(doorbell), { recursive: true });
16977
17114
  writeFileSync14(doorbell, String(Date.now()));
16978
17115
  log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
@@ -17101,7 +17238,7 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
17101
17238
  }
17102
17239
  if (run_id) openInjectedRunByCode.set(codeName, run_id);
17103
17240
  try {
17104
- const doorbell = directChatDoorbellPath(agentId, homedir15());
17241
+ const doorbell = directChatDoorbellPath(agentId, homedir16());
17105
17242
  mkdirSync11(dirname9(doorbell), { recursive: true });
17106
17243
  writeFileSync14(doorbell, String(Date.now()));
17107
17244
  } catch (err) {
@@ -17207,7 +17344,7 @@ async function processClaudePairSessions(agents) {
17207
17344
  killPairSession,
17208
17345
  pairTmuxSession,
17209
17346
  finalizeClaudePairOnboarding
17210
- } = await import("../claude-pair-runtime-4C5NQQHR.js");
17347
+ } = await import("../claude-pair-runtime-NSIF6AYH.js");
17211
17348
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
17212
17349
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
17213
17350
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -17461,8 +17598,8 @@ function parseMemoryFile(raw, fallbackName) {
17461
17598
  };
17462
17599
  }
17463
17600
  async function syncMemories(agent, configDir, log2) {
17464
- const projectDir = join33(configDir, agent.code_name, "project");
17465
- const memoryDir = join33(projectDir, "memory");
17601
+ const projectDir = join34(configDir, agent.code_name, "project");
17602
+ const memoryDir = join34(projectDir, "memory");
17466
17603
  const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
17467
17604
  if (isFreshSync) {
17468
17605
  log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
@@ -17480,7 +17617,7 @@ async function syncMemories(agent, configDir, log2) {
17480
17617
  for (const file of readdirSync9(memoryDir)) {
17481
17618
  if (!file.endsWith(".md")) continue;
17482
17619
  try {
17483
- const raw = readFileSync26(join33(memoryDir, file), "utf-8");
17620
+ const raw = readFileSync27(join34(memoryDir, file), "utf-8");
17484
17621
  const fileHash = createHash17("sha256").update(raw).digest("hex").slice(0, 16);
17485
17622
  currentHashes.set(file, fileHash);
17486
17623
  if (prevHashes.get(file) === fileHash) continue;
@@ -17505,7 +17642,7 @@ async function syncMemories(agent, configDir, log2) {
17505
17642
  } catch (err) {
17506
17643
  for (const mem of changedMemories) {
17507
17644
  for (const [file] of currentHashes) {
17508
- const parsed = parseMemoryFile(readFileSync26(join33(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
17645
+ const parsed = parseMemoryFile(readFileSync27(join34(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
17509
17646
  if (parsed?.name === mem.name) currentHashes.delete(file);
17510
17647
  }
17511
17648
  }
@@ -17540,7 +17677,7 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
17540
17677
  const mem = dbMemories.memories[i];
17541
17678
  const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
17542
17679
  const slug = rawSlug || `memory-${i}`;
17543
- const filePath = join33(memoryDir, `${slug}.md`);
17680
+ const filePath = join34(memoryDir, `${slug}.md`);
17544
17681
  const desired = `---
17545
17682
  name: ${JSON.stringify(mem.name)}
17546
17683
  type: ${mem.type}
@@ -17552,7 +17689,7 @@ ${mem.content}
17552
17689
  if (existsSync14(filePath)) {
17553
17690
  let existing = "";
17554
17691
  try {
17555
- existing = readFileSync26(filePath, "utf-8");
17692
+ existing = readFileSync27(filePath, "utf-8");
17556
17693
  } catch {
17557
17694
  }
17558
17695
  if (existing === desired) continue;
@@ -17816,7 +17953,7 @@ function startManager(opts) {
17816
17953
  try {
17817
17954
  const stateFile = getStateFile();
17818
17955
  if (existsSync14(stateFile)) {
17819
- const raw = readFileSync26(stateFile, "utf-8");
17956
+ const raw = readFileSync27(stateFile, "utf-8");
17820
17957
  const parsed = JSON.parse(raw);
17821
17958
  if (Array.isArray(parsed.agents)) {
17822
17959
  state7.agents = parsed.agents;
@@ -17843,7 +17980,7 @@ function startManager(opts) {
17843
17980
  log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
17844
17981
  }
17845
17982
  log(
17846
- `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join33(homedir15(), ".augmented", "manager.log")}`
17983
+ `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join34(homedir16(), ".augmented", "manager.log")}`
17847
17984
  );
17848
17985
  deployMcpAssets();
17849
17986
  reapOrphanChannelMcps({ log });
@@ -17872,7 +18009,7 @@ async function reapOrphanedClaudePids() {
17872
18009
  const looksLikeClaude = (pid) => {
17873
18010
  if (process.platform !== "linux") return true;
17874
18011
  try {
17875
- const comm = readFileSync26(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
18012
+ const comm = readFileSync27(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
17876
18013
  return comm.includes("claude");
17877
18014
  } catch {
17878
18015
  return false;
@@ -17969,14 +18106,14 @@ function restartRunningChannelMcps(basenames) {
17969
18106
  }
17970
18107
  }
17971
18108
  function deployMcpAssets() {
17972
- const targetDir = join33(homedir15(), ".augmented", "_mcp");
18109
+ const targetDir = join34(homedir16(), ".augmented", "_mcp");
17973
18110
  mkdirSync11(targetDir, { recursive: true });
17974
18111
  const moduleDir = dirname9(fileURLToPath(import.meta.url));
17975
18112
  let mcpSourceDir = "";
17976
18113
  let dir = moduleDir;
17977
18114
  for (let i = 0; i < 6; i++) {
17978
- const candidate = join33(dir, "dist", "mcp");
17979
- if (existsSync14(join33(candidate, "index.js"))) {
18115
+ const candidate = join34(dir, "dist", "mcp");
18116
+ if (existsSync14(join34(candidate, "index.js"))) {
17980
18117
  mcpSourceDir = candidate;
17981
18118
  break;
17982
18119
  }
@@ -17992,7 +18129,7 @@ function deployMcpAssets() {
17992
18129
  const fileHash = (p) => {
17993
18130
  try {
17994
18131
  if (!existsSync14(p)) return null;
17995
- return createHash17("sha256").update(readFileSync26(p)).digest("hex");
18132
+ return createHash17("sha256").update(readFileSync27(p)).digest("hex");
17996
18133
  } catch {
17997
18134
  return null;
17998
18135
  }
@@ -18063,8 +18200,8 @@ function deployMcpAssets() {
18063
18200
  // needs restarting to pick up a token rotation.
18064
18201
  "xero.js"
18065
18202
  ]) {
18066
- const src = join33(mcpSourceDir, file);
18067
- const dst = join33(targetDir, file);
18203
+ const src = join34(mcpSourceDir, file);
18204
+ const dst = join34(targetDir, file);
18068
18205
  if (!existsSync14(src)) continue;
18069
18206
  const before = fileHash(dst);
18070
18207
  try {
@@ -18082,16 +18219,16 @@ function deployMcpAssets() {
18082
18219
  log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
18083
18220
  restartRunningChannelMcps(changedBasenames);
18084
18221
  }
18085
- const localMcpPath = join33(targetDir, "index.js");
18222
+ const localMcpPath = join34(targetDir, "index.js");
18086
18223
  try {
18087
- const agentsDir = join33(homedir15(), ".augmented", "agents");
18224
+ const agentsDir = join34(homedir16(), ".augmented", "agents");
18088
18225
  if (existsSync14(agentsDir)) {
18089
18226
  for (const entry of readdirSync9(agentsDir, { withFileTypes: true })) {
18090
18227
  if (!entry.isDirectory()) continue;
18091
18228
  for (const subdir of ["provision", "project"]) {
18092
- const mcpJsonPath = join33(agentsDir, entry.name, subdir, ".mcp.json");
18229
+ const mcpJsonPath = join34(agentsDir, entry.name, subdir, ".mcp.json");
18093
18230
  try {
18094
- const raw = readFileSync26(mcpJsonPath, "utf-8");
18231
+ const raw = readFileSync27(mcpJsonPath, "utf-8");
18095
18232
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
18096
18233
  const mcpConfig = JSON.parse(raw);
18097
18234
  const augServer = mcpConfig.mcpServers?.["augmented"];