@integrity-labs/agt-cli 0.27.162 → 0.27.163

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.
@@ -14345,8 +14345,47 @@ function decideInboundAccess(input) {
14345
14345
  }
14346
14346
 
14347
14347
  // src/ack-reaction.ts
14348
- import { readdirSync, readFileSync } from "fs";
14348
+ import { readdirSync, readFileSync as readFileSync2 } from "fs";
14349
+ import { join as join2 } from "path";
14350
+
14351
+ // src/flags-cache-read.ts
14352
+ import { existsSync, readFileSync } from "fs";
14353
+ import { homedir } from "os";
14349
14354
  import { join } from "path";
14355
+ function defaultFlagsCachePath() {
14356
+ return join(homedir(), ".augmented", "flags-cache.json");
14357
+ }
14358
+ function envBoolean(raw) {
14359
+ if (raw === void 0) return void 0;
14360
+ const v = raw.trim().toLowerCase();
14361
+ if (v === "") return void 0;
14362
+ if (v === "1" || v === "true" || v === "yes" || v === "on") return true;
14363
+ if (v === "0" || v === "false" || v === "no" || v === "off") return false;
14364
+ return void 0;
14365
+ }
14366
+ function cachedBoolean(key2, path) {
14367
+ try {
14368
+ if (!existsSync(path)) return void 0;
14369
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
14370
+ if (!parsed || typeof parsed !== "object") return void 0;
14371
+ const flags = parsed.flags;
14372
+ if (!flags || typeof flags !== "object") return void 0;
14373
+ const value = flags[key2];
14374
+ return typeof value === "boolean" ? value : void 0;
14375
+ } catch {
14376
+ return void 0;
14377
+ }
14378
+ }
14379
+ function resolveHostBooleanFlag(opts) {
14380
+ const env = opts.env ?? process.env;
14381
+ const envValue = envBoolean(env[opts.envVar]);
14382
+ if (envValue !== void 0) return envValue;
14383
+ const cached2 = cachedBoolean(opts.key, opts.cachePath ?? defaultFlagsCachePath());
14384
+ if (cached2 !== void 0) return cached2;
14385
+ return opts.defaultValue;
14386
+ }
14387
+
14388
+ // src/ack-reaction.ts
14350
14389
  var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
14351
14390
  var ACK_STARTUP_GRACE_MS = 6e4;
14352
14391
  var ACK_PANE_FRESH_THRESHOLD_MS = 6e4;
@@ -14381,8 +14420,11 @@ function undeliverableNoticeText() {
14381
14420
  var BUSY_ACK_THRESHOLD_MS = 9e4;
14382
14421
  var BUSY_ACK_NOTICE_THROTTLE_MS = 10 * 60 * 1e3;
14383
14422
  function channelBusyAckEnabled() {
14384
- const v = process.env.AGT_CHANNEL_BUSY_ACK_ENABLED;
14385
- return v === "1" || v === "true";
14423
+ return resolveHostBooleanFlag({
14424
+ key: "channel-busy-ack",
14425
+ envVar: "AGT_CHANNEL_BUSY_ACK_ENABLED",
14426
+ defaultValue: false
14427
+ });
14386
14428
  }
14387
14429
  function channelBusyAckThresholdMs() {
14388
14430
  const raw = parseInt(process.env.AGT_CHANNEL_BUSY_ACK_THRESHOLD_MS ?? "", 10);
@@ -14406,7 +14448,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
14406
14448
  function readGiveUpSignalAtMs(path, now = Date.now()) {
14407
14449
  if (!path) return null;
14408
14450
  try {
14409
- const raw = JSON.parse(readFileSync(path, "utf8"));
14451
+ const raw = JSON.parse(readFileSync2(path, "utf8"));
14410
14452
  if (typeof raw.gave_up_at !== "string") return null;
14411
14453
  const t = Date.parse(raw.gave_up_at);
14412
14454
  if (!Number.isFinite(t) || t > now) return null;
@@ -14438,7 +14480,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now()) {
14438
14480
  if (!name.endsWith(".json")) continue;
14439
14481
  let receivedAt;
14440
14482
  try {
14441
- const raw = JSON.parse(readFileSync(join(dir, name), "utf-8"));
14483
+ const raw = JSON.parse(readFileSync2(join2(dir, name), "utf-8"));
14442
14484
  receivedAt = raw.received_at;
14443
14485
  } catch {
14444
14486
  continue;
@@ -14521,15 +14563,15 @@ function probeAgentSessionCached(codeName, ttlMs = SESSION_PROBE_TTL_MS, now = D
14521
14563
  }
14522
14564
 
14523
14565
  // src/agent-config-state.ts
14524
- import { existsSync, readFileSync as readFileSync2 } from "fs";
14525
- import { join as join2 } from "path";
14566
+ import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
14567
+ import { join as join3 } from "path";
14526
14568
  var SESSION_STATE_FILENAME = "session-state.json";
14527
14569
  function readAgentSessionState(stateDir) {
14528
14570
  if (!stateDir) return null;
14529
- const path = join2(stateDir, SESSION_STATE_FILENAME);
14530
- if (!existsSync(path)) return null;
14571
+ const path = join3(stateDir, SESSION_STATE_FILENAME);
14572
+ if (!existsSync2(path)) return null;
14531
14573
  try {
14532
- const parsed = JSON.parse(readFileSync2(path, "utf-8"));
14574
+ const parsed = JSON.parse(readFileSync3(path, "utf-8"));
14533
14575
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
14534
14576
  return parsed;
14535
14577
  } catch {
@@ -14601,10 +14643,10 @@ import { promisify } from "util";
14601
14643
  import { open, stat } from "fs/promises";
14602
14644
 
14603
14645
  // src/channel-attachments.ts
14604
- import { homedir } from "os";
14605
- import { join as join3, resolve, sep } from "path";
14646
+ import { homedir as homedir2 } from "os";
14647
+ import { join as join4, resolve, sep } from "path";
14606
14648
  function resolveChannelInboundDir(codeName, channelSlug) {
14607
- const base = join3(homedir(), ".augmented");
14649
+ const base = join4(homedir2(), ".augmented");
14608
14650
  const allowedSegment = /^[A-Za-z0-9_-]+$/;
14609
14651
  if (!allowedSegment.test(codeName) || !allowedSegment.test(channelSlug)) {
14610
14652
  throw new Error(
@@ -14682,7 +14724,7 @@ function isPathInside(target, root) {
14682
14724
  return normalizedTarget === resolve(root) || normalizedTarget.startsWith(normalizedRoot);
14683
14725
  }
14684
14726
  function redactAugmentedPaths(msg) {
14685
- const homePrefix = homedir().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
14727
+ const homePrefix = homedir2().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
14686
14728
  return msg.replaceAll(
14687
14729
  new RegExp(`${homePrefix}[\\\\/]\\.augmented(?:[\\\\/][^\\s'"\`]*)*`, "g"),
14688
14730
  "<augmented-path>"
@@ -15030,14 +15072,14 @@ var SLACK_EGRESS_TOOLS = /* @__PURE__ */ new Set([
15030
15072
  ]);
15031
15073
 
15032
15074
  // src/slack-pending-inbound-cleanup.ts
15033
- import { existsSync as existsSync2, readdirSync as readdirSync2, statSync, unlinkSync } from "fs";
15034
- import { join as join4 } from "path";
15075
+ import { existsSync as existsSync3, readdirSync as readdirSync2, statSync, unlinkSync } from "fs";
15076
+ import { join as join5 } from "path";
15035
15077
  function sanitizeMarkerSegment(value) {
15036
15078
  return value.replace(/[^A-Za-z0-9_-]/g, "_");
15037
15079
  }
15038
15080
  var defaultClearMarkerFile = (fullPath) => {
15039
15081
  try {
15040
- if (existsSync2(fullPath)) unlinkSync(fullPath);
15082
+ if (existsSync3(fullPath)) unlinkSync(fullPath);
15041
15083
  } catch {
15042
15084
  }
15043
15085
  };
@@ -15048,7 +15090,7 @@ function clearAllSlackPendingMarkersForThread(dir, channel, threadTs, clear = de
15048
15090
  try {
15049
15091
  for (const f of readdirSync2(dir)) {
15050
15092
  if (!f.startsWith(prefix) || !f.endsWith(".json")) continue;
15051
- clear(join4(dir, f));
15093
+ clear(join5(dir, f));
15052
15094
  cleared += 1;
15053
15095
  }
15054
15096
  } catch {
@@ -15063,7 +15105,7 @@ function clearSlackPendingMarkerByMessageTs(dir, channel, messageTs, clear = def
15063
15105
  try {
15064
15106
  for (const f of readdirSync2(dir)) {
15065
15107
  if (!f.startsWith(channelPrefix) || !f.endsWith(messageSuffix)) continue;
15066
- clear(join4(dir, f));
15108
+ clear(join5(dir, f));
15067
15109
  cleared += 1;
15068
15110
  }
15069
15111
  } catch {
@@ -15075,7 +15117,7 @@ function clearOldestSlackPendingMarkerInChannel(dir, channel, clear = defaultCle
15075
15117
  const channelPrefix = `${sanitizeMarkerSegment(channel)}__`;
15076
15118
  try {
15077
15119
  const entries = readdirSync2(dir).filter((f) => f.startsWith(channelPrefix) && f.endsWith(".json")).map((f) => {
15078
- const full = join4(dir, f);
15120
+ const full = join5(dir, f);
15079
15121
  let mtime = 0;
15080
15122
  try {
15081
15123
  mtime = statSync(full).mtimeMs;
@@ -15103,7 +15145,7 @@ function resolveReplyThreadTs(input) {
15103
15145
  }
15104
15146
 
15105
15147
  // src/restart-confirm.ts
15106
- import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, renameSync, unlinkSync as unlinkSync2, writeFileSync } from "fs";
15148
+ import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync4, renameSync, unlinkSync as unlinkSync2, writeFileSync } from "fs";
15107
15149
  import { dirname } from "path";
15108
15150
  import { randomUUID } from "crypto";
15109
15151
  var RESTART_CONFIRM_MAX_AGE_MS = 10 * 60 * 1e3;
@@ -15121,15 +15163,15 @@ function buildBackOnlineText(name) {
15121
15163
  }
15122
15164
  function writeRestartConfirmMarker(filePath, marker) {
15123
15165
  const dir = dirname(filePath);
15124
- if (!existsSync3(dir)) mkdirSync(dir, { recursive: true, mode: 448 });
15166
+ if (!existsSync4(dir)) mkdirSync(dir, { recursive: true, mode: 448 });
15125
15167
  const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
15126
15168
  writeFileSync(tmpPath, JSON.stringify(marker) + "\n", { encoding: "utf8", mode: 384 });
15127
15169
  renameSync(tmpPath, filePath);
15128
15170
  }
15129
15171
  function readRestartConfirmMarker(filePath) {
15130
15172
  try {
15131
- if (!existsSync3(filePath)) return null;
15132
- const parsed = JSON.parse(readFileSync3(filePath, "utf8"));
15173
+ if (!existsSync4(filePath)) return null;
15174
+ const parsed = JSON.parse(readFileSync4(filePath, "utf8"));
15133
15175
  if (!parsed || typeof parsed !== "object") return null;
15134
15176
  return parsed;
15135
15177
  } catch {
@@ -15138,7 +15180,7 @@ function readRestartConfirmMarker(filePath) {
15138
15180
  }
15139
15181
  function clearRestartConfirmMarker(filePath) {
15140
15182
  try {
15141
- if (existsSync3(filePath)) unlinkSync2(filePath);
15183
+ if (existsSync4(filePath)) unlinkSync2(filePath);
15142
15184
  } catch {
15143
15185
  }
15144
15186
  }
@@ -15239,9 +15281,9 @@ var StdioServerTransport = class {
15239
15281
  import {
15240
15282
  chmodSync,
15241
15283
  createWriteStream,
15242
- existsSync as existsSync6,
15284
+ existsSync as existsSync7,
15243
15285
  mkdirSync as mkdirSync5,
15244
- readFileSync as readFileSync7,
15286
+ readFileSync as readFileSync8,
15245
15287
  readdirSync as readdirSync3,
15246
15288
  renameSync as renameSync3,
15247
15289
  statSync as statSync2,
@@ -15249,12 +15291,12 @@ import {
15249
15291
  watch,
15250
15292
  writeFileSync as writeFileSync5
15251
15293
  } from "fs";
15252
- import { basename, join as join6, resolve as resolve2 } from "path";
15253
- import { homedir as homedir2 } from "os";
15294
+ import { basename, join as join7, resolve as resolve2 } from "path";
15295
+ import { homedir as homedir3 } from "os";
15254
15296
  import { createHash, randomUUID as randomUUID2 } from "crypto";
15255
15297
 
15256
15298
  // src/slack-thread-store.ts
15257
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
15299
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
15258
15300
  import { dirname as dirname2 } from "path";
15259
15301
  var FILE_VERSION = 1;
15260
15302
  var DEFAULT_TTL_DAYS = 30;
@@ -15265,7 +15307,7 @@ function loadThreadStore(filePath, opts = {}) {
15265
15307
  const ttlMs = ttlDays * 24 * 60 * 60 * 1e3;
15266
15308
  let raw;
15267
15309
  try {
15268
- raw = readFileSync4(filePath, "utf-8");
15310
+ raw = readFileSync5(filePath, "utf-8");
15269
15311
  } catch {
15270
15312
  return { threads: /* @__PURE__ */ new Map(), pruned: 0 };
15271
15313
  }
@@ -15379,7 +15421,7 @@ async function runOrRetry(fn, opts) {
15379
15421
  }
15380
15422
 
15381
15423
  // src/slack-bot-photo.ts
15382
- import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
15424
+ import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
15383
15425
  import { dirname as dirname3 } from "path";
15384
15426
  async function applyBotPhoto(opts) {
15385
15427
  const fetchImpl = opts.fetchImpl ?? fetch;
@@ -15387,9 +15429,9 @@ async function applyBotPhoto(opts) {
15387
15429
  process.stderr.write(m);
15388
15430
  });
15389
15431
  const { token, avatarUrl, markerPath } = opts;
15390
- if (markerPath && existsSync4(markerPath)) {
15432
+ if (markerPath && existsSync5(markerPath)) {
15391
15433
  try {
15392
- if (readFileSync5(markerPath, "utf-8").trim() === avatarUrl) {
15434
+ if (readFileSync6(markerPath, "utf-8").trim() === avatarUrl) {
15393
15435
  return { status: "skipped-unchanged" };
15394
15436
  }
15395
15437
  } catch {
@@ -16182,14 +16224,14 @@ function createSlackBotUserIdClient(args) {
16182
16224
 
16183
16225
  // src/mcp-spawn-lock.ts
16184
16226
  import {
16185
- existsSync as existsSync5,
16227
+ existsSync as existsSync6,
16186
16228
  mkdirSync as mkdirSync4,
16187
- readFileSync as readFileSync6,
16229
+ readFileSync as readFileSync7,
16188
16230
  renameSync as renameSync2,
16189
16231
  unlinkSync as unlinkSync3,
16190
16232
  writeFileSync as writeFileSync4
16191
16233
  } from "fs";
16192
- import { join as join5 } from "path";
16234
+ import { join as join6 } from "path";
16193
16235
  function defaultIsPidAlive(pid) {
16194
16236
  if (!Number.isFinite(pid) || pid <= 0) return false;
16195
16237
  try {
@@ -16207,7 +16249,7 @@ function acquireMcpSpawnLock(args) {
16207
16249
  const isPidAlive = options.isPidAlive ?? defaultIsPidAlive;
16208
16250
  const selfPid = options.selfPid ?? process.pid;
16209
16251
  const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
16210
- const path = join5(agentDir, basename2);
16252
+ const path = join6(agentDir, basename2);
16211
16253
  const existing = readLockHolder(path);
16212
16254
  if (existing) {
16213
16255
  if (existing.pid === selfPid) {
@@ -16236,9 +16278,9 @@ function releaseMcpSpawnLock(lockPath, opts = {}) {
16236
16278
  }
16237
16279
  }
16238
16280
  function readLockHolder(path) {
16239
- if (!existsSync5(path)) return null;
16281
+ if (!existsSync6(path)) return null;
16240
16282
  try {
16241
- const raw = readFileSync6(path, "utf8");
16283
+ const raw = readFileSync7(path, "utf8");
16242
16284
  const parsed = JSON.parse(raw);
16243
16285
  const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
16244
16286
  if (!Number.isFinite(pid) || pid <= 0) return null;
@@ -16414,8 +16456,8 @@ var SLACK_PEER_CLASSIFIER_CONFIG = {
16414
16456
  peers: parsePeersEnv(process.env.SLACK_PEERS, process.env.SLACK_PEERS_GATE),
16415
16457
  peer_disabled_mode: SLACK_PEER_DISABLED_MODE
16416
16458
  };
16417
- var SLACK_AGENT_DIR = AGENT_CODE_NAME ? join6(homedir2(), ".augmented", AGENT_CODE_NAME) : null;
16418
- var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ? join6(SLACK_AGENT_DIR, "project", ".mcp.json") : null;
16459
+ var SLACK_AGENT_DIR = AGENT_CODE_NAME ? join7(homedir3(), ".augmented", AGENT_CODE_NAME) : null;
16460
+ var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ? join7(SLACK_AGENT_DIR, "project", ".mcp.json") : null;
16419
16461
  var liveAllowedUsersCache = null;
16420
16462
  function readLiveAllowedUsers() {
16421
16463
  if (!SLACK_MCP_CONFIG_PATH) return null;
@@ -16425,7 +16467,7 @@ function readLiveAllowedUsers() {
16425
16467
  return liveAllowedUsersCache.value;
16426
16468
  }
16427
16469
  const value = extractAllowedUsersFromMcpJson(
16428
- readFileSync7(SLACK_MCP_CONFIG_PATH, "utf-8")
16470
+ readFileSync8(SLACK_MCP_CONFIG_PATH, "utf-8")
16429
16471
  );
16430
16472
  if (value === null) return null;
16431
16473
  liveAllowedUsersCache = { mtimeMs, value };
@@ -16437,11 +16479,11 @@ function readLiveAllowedUsers() {
16437
16479
  function getEffectiveAllowedUsers() {
16438
16480
  return readLiveAllowedUsers() ?? ALLOWED_USERS;
16439
16481
  }
16440
- var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ? join6(SLACK_AGENT_DIR, "slack-pending-inbound") : null;
16441
- var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ? join6(SLACK_AGENT_DIR, "slack-recovery-outbox") : null;
16442
- var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ? join6(SLACK_AGENT_DIR, "slack-restart-confirm.json") : null;
16482
+ var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ? join7(SLACK_AGENT_DIR, "slack-pending-inbound") : null;
16483
+ var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ? join7(SLACK_AGENT_DIR, "slack-recovery-outbox") : null;
16484
+ var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ? join7(SLACK_AGENT_DIR, "slack-restart-confirm.json") : null;
16443
16485
  var SLACK_MAX_RECOVERY_ATTEMPTS = 3;
16444
- var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join6(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
16486
+ var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join7(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
16445
16487
  function redactSlackId(id) {
16446
16488
  if (!id) return "<none>";
16447
16489
  return createHash("sha256").update(id).digest("hex").slice(0, 8);
@@ -16452,7 +16494,7 @@ function safeSlackMarkerName(channel, threadTs, messageTs) {
16452
16494
  }
16453
16495
  function slackPendingInboundPath(channel, threadTs, messageTs) {
16454
16496
  if (!SLACK_PENDING_INBOUND_DIR) return null;
16455
- return join6(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
16497
+ return join7(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
16456
16498
  }
16457
16499
  function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undeliverable = false) {
16458
16500
  const path = slackPendingInboundPath(channel, threadTs, messageTs);
@@ -16477,9 +16519,9 @@ function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undelivera
16477
16519
  }
16478
16520
  function readSlackPendingInboundMarker(channel, threadTs, messageTs) {
16479
16521
  const path = slackPendingInboundPath(channel, threadTs, messageTs);
16480
- if (!path || !existsSync6(path)) return null;
16522
+ if (!path || !existsSync7(path)) return null;
16481
16523
  try {
16482
- return JSON.parse(readFileSync7(path, "utf-8"));
16524
+ return JSON.parse(readFileSync8(path, "utf-8"));
16483
16525
  } catch {
16484
16526
  return null;
16485
16527
  }
@@ -16573,7 +16615,7 @@ function scheduleBusyAck(channel, threadTs, messageTs, isThreadReply) {
16573
16615
  let paneLogFreshAgeMs = null;
16574
16616
  if (SLACK_AGENT_DIR) {
16575
16617
  try {
16576
- const paneMtimeMs = statSync2(join6(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
16618
+ const paneMtimeMs = statSync2(join7(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
16577
16619
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
16578
16620
  } catch {
16579
16621
  }
@@ -16598,7 +16640,7 @@ function __resetSlackBusyAckNoticeThrottle() {
16598
16640
  function clearSlackMarkerFileWithHeal(fullPath) {
16599
16641
  let marker = null;
16600
16642
  try {
16601
- marker = JSON.parse(readFileSync7(fullPath, "utf-8"));
16643
+ marker = JSON.parse(readFileSync8(fullPath, "utf-8"));
16602
16644
  } catch {
16603
16645
  }
16604
16646
  if (marker && decideRecoveryHeal({
@@ -16608,7 +16650,7 @@ function clearSlackMarkerFileWithHeal(fullPath) {
16608
16650
  healSlackUndeliverable(marker.channel, marker.message_ts);
16609
16651
  }
16610
16652
  try {
16611
- if (existsSync6(fullPath)) unlinkSync4(fullPath);
16653
+ if (existsSync7(fullPath)) unlinkSync4(fullPath);
16612
16654
  } catch {
16613
16655
  }
16614
16656
  }
@@ -16649,10 +16691,10 @@ function slackNextRetryName(filename) {
16649
16691
  async function processSlackRecoveryOutboxFile(filename) {
16650
16692
  if (!SLACK_RECOVERY_OUTBOX_DIR) return;
16651
16693
  if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
16652
- const fullPath = join6(SLACK_RECOVERY_OUTBOX_DIR, filename);
16694
+ const fullPath = join7(SLACK_RECOVERY_OUTBOX_DIR, filename);
16653
16695
  let payload;
16654
16696
  try {
16655
- payload = JSON.parse(readFileSync7(fullPath, "utf-8"));
16697
+ payload = JSON.parse(readFileSync8(fullPath, "utf-8"));
16656
16698
  } catch (err) {
16657
16699
  process.stderr.write(
16658
16700
  `slack-channel(${AGENT_CODE_NAME}): recovery outbox parse failed (${filename}): ${err.message}
@@ -16726,7 +16768,7 @@ async function processSlackRecoveryOutboxFile(filename) {
16726
16768
  const next = slackNextRetryName(filename);
16727
16769
  if (next) {
16728
16770
  try {
16729
- renameSync3(fullPath, join6(SLACK_RECOVERY_OUTBOX_DIR, next.next));
16771
+ renameSync3(fullPath, join7(SLACK_RECOVERY_OUTBOX_DIR, next.next));
16730
16772
  if (next.attempt >= SLACK_MAX_RECOVERY_ATTEMPTS) {
16731
16773
  process.stderr.write(
16732
16774
  `slack-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
@@ -16765,7 +16807,7 @@ function scanSlackRecoveryRetries() {
16765
16807
  if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
16766
16808
  let mtimeMs;
16767
16809
  try {
16768
- mtimeMs = statSync2(join6(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
16810
+ mtimeMs = statSync2(join7(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
16769
16811
  } catch {
16770
16812
  continue;
16771
16813
  }
@@ -16795,7 +16837,7 @@ function startSlackRecoveryOutboxWatcher() {
16795
16837
  const watcher = watch(SLACK_RECOVERY_OUTBOX_DIR, (event, filename) => {
16796
16838
  if (event !== "rename" || !filename) return;
16797
16839
  if (!isFirstAttemptSlackOutboxFile(filename)) return;
16798
- if (existsSync6(join6(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
16840
+ if (existsSync7(join7(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
16799
16841
  void processSlackRecoveryOutboxFile(filename);
16800
16842
  }
16801
16843
  });
@@ -16816,7 +16858,7 @@ function trackPendingMessage(channel, threadTs, messageTs, undeliverable = false
16816
16858
  }
16817
16859
  function sweepSlackStaleMarkers(thresholdMs) {
16818
16860
  if (!SLACK_PENDING_INBOUND_DIR) return;
16819
- if (!existsSync6(SLACK_PENDING_INBOUND_DIR)) return;
16861
+ if (!existsSync7(SLACK_PENDING_INBOUND_DIR)) return;
16820
16862
  let filenames;
16821
16863
  try {
16822
16864
  filenames = readdirSync3(SLACK_PENDING_INBOUND_DIR);
@@ -16832,10 +16874,10 @@ function sweepSlackStaleMarkers(thresholdMs) {
16832
16874
  for (const filename of filenames) {
16833
16875
  if (!filename.endsWith(".json")) continue;
16834
16876
  if (filename.endsWith(".tmp")) continue;
16835
- const fullPath = join6(SLACK_PENDING_INBOUND_DIR, filename);
16877
+ const fullPath = join7(SLACK_PENDING_INBOUND_DIR, filename);
16836
16878
  let marker;
16837
16879
  try {
16838
- marker = JSON.parse(readFileSync7(fullPath, "utf-8"));
16880
+ marker = JSON.parse(readFileSync8(fullPath, "utf-8"));
16839
16881
  } catch (err) {
16840
16882
  process.stderr.write(
16841
16883
  `slack-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactSlackId(filename)}: ${err.message}
@@ -16874,14 +16916,14 @@ var slackOrphanSweepTimer = setInterval(() => {
16874
16916
  slackOrphanSweepTimer.unref?.();
16875
16917
  var lastSlackGiveUpHandledAtMs = null;
16876
16918
  function listPendingSlackConversations() {
16877
- if (!SLACK_PENDING_INBOUND_DIR || !existsSync6(SLACK_PENDING_INBOUND_DIR)) return [];
16919
+ if (!SLACK_PENDING_INBOUND_DIR || !existsSync7(SLACK_PENDING_INBOUND_DIR)) return [];
16878
16920
  const byKey = /* @__PURE__ */ new Map();
16879
16921
  try {
16880
16922
  for (const name of readdirSync3(SLACK_PENDING_INBOUND_DIR)) {
16881
16923
  if (!name.endsWith(".json")) continue;
16882
16924
  try {
16883
16925
  const marker = JSON.parse(
16884
- readFileSync7(join6(SLACK_PENDING_INBOUND_DIR, name), "utf8")
16926
+ readFileSync8(join7(SLACK_PENDING_INBOUND_DIR, name), "utf8")
16885
16927
  );
16886
16928
  if (typeof marker.channel !== "string" || !marker.channel) continue;
16887
16929
  if (typeof marker.thread_ts !== "string" || !marker.thread_ts) continue;
@@ -16931,7 +16973,7 @@ function postSlackWatchdogGiveUpNotice(channel, threadTs, isThreadReply) {
16931
16973
  }
16932
16974
  function checkSlackWatchdogGiveUpNotice() {
16933
16975
  if (!SLACK_AGENT_DIR) return;
16934
- const signalAtMs = readGiveUpSignalAtMs(join6(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
16976
+ const signalAtMs = readGiveUpSignalAtMs(join7(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
16935
16977
  const act = decideGiveUpNotice({
16936
16978
  signalAtMs,
16937
16979
  lastHandledAtMs: lastSlackGiveUpHandledAtMs,
@@ -16958,7 +17000,7 @@ async function notifyStrandedInboundsOnFirstConnect() {
16958
17000
  strandedInboundNoticeInFlight = true;
16959
17001
  let hadFailure = false;
16960
17002
  try {
16961
- if (!SLACK_PENDING_INBOUND_DIR || !existsSync6(SLACK_PENDING_INBOUND_DIR)) return;
17003
+ if (!SLACK_PENDING_INBOUND_DIR || !existsSync7(SLACK_PENDING_INBOUND_DIR)) return;
16962
17004
  let filenames;
16963
17005
  try {
16964
17006
  filenames = readdirSync3(SLACK_PENDING_INBOUND_DIR);
@@ -16971,10 +17013,10 @@ async function notifyStrandedInboundsOnFirstConnect() {
16971
17013
  let notified = 0;
16972
17014
  for (const filename of filenames) {
16973
17015
  if (!filename.endsWith(".json")) continue;
16974
- const fullPath = join6(SLACK_PENDING_INBOUND_DIR, filename);
17016
+ const fullPath = join7(SLACK_PENDING_INBOUND_DIR, filename);
16975
17017
  let marker;
16976
17018
  try {
16977
- marker = JSON.parse(readFileSync7(fullPath, "utf-8"));
17019
+ marker = JSON.parse(readFileSync8(fullPath, "utf-8"));
16978
17020
  } catch {
16979
17021
  continue;
16980
17022
  }
@@ -17101,7 +17143,7 @@ function noteThreadActivityByMessageTs(channel, messageTs) {
17101
17143
  if (!channel || !messageTs) return;
17102
17144
  clearPendingMessage(channel, messageTs);
17103
17145
  if (!SLACK_PENDING_INBOUND_DIR) return;
17104
- if (!existsSync6(SLACK_PENDING_INBOUND_DIR)) return;
17146
+ if (!existsSync7(SLACK_PENDING_INBOUND_DIR)) return;
17105
17147
  let filenames;
17106
17148
  try {
17107
17149
  filenames = readdirSync3(SLACK_PENDING_INBOUND_DIR);
@@ -17115,10 +17157,10 @@ function noteThreadActivityByMessageTs(channel, messageTs) {
17115
17157
  for (const filename of filenames) {
17116
17158
  if (!filename.startsWith(channelPrefix)) continue;
17117
17159
  if (!filename.endsWith(messageSuffix)) continue;
17118
- clearSlackMarkerFileWithHeal(join6(SLACK_PENDING_INBOUND_DIR, filename));
17160
+ clearSlackMarkerFileWithHeal(join7(SLACK_PENDING_INBOUND_DIR, filename));
17119
17161
  }
17120
17162
  }
17121
- var RESTART_FLAGS_DIR = join6(homedir2(), ".augmented", "restart-flags");
17163
+ var RESTART_FLAGS_DIR = join7(homedir3(), ".augmented", "restart-flags");
17122
17164
  function buildAugmentedSlackMetadata() {
17123
17165
  if (!AGT_TEAM_ID) return void 0;
17124
17166
  return {
@@ -17504,10 +17546,10 @@ async function handleSlashCommandEnvelope(payload) {
17504
17546
  return;
17505
17547
  }
17506
17548
  try {
17507
- if (!existsSync6(RESTART_FLAGS_DIR)) {
17549
+ if (!existsSync7(RESTART_FLAGS_DIR)) {
17508
17550
  mkdirSync5(RESTART_FLAGS_DIR, { recursive: true });
17509
17551
  }
17510
- const flagPath = join6(RESTART_FLAGS_DIR, `${codeName}.flag`);
17552
+ const flagPath = join7(RESTART_FLAGS_DIR, `${codeName}.flag`);
17511
17553
  writeSlackRestartConfirm(
17512
17554
  {
17513
17555
  channel: payload.channel_id,
@@ -17622,10 +17664,10 @@ async function handleHelpCommand(opts) {
17622
17664
  async function handleRestartCommand(opts) {
17623
17665
  const codeName = AGENT_CODE_NAME ?? "unknown";
17624
17666
  try {
17625
- if (!existsSync6(RESTART_FLAGS_DIR)) {
17667
+ if (!existsSync7(RESTART_FLAGS_DIR)) {
17626
17668
  mkdirSync5(RESTART_FLAGS_DIR, { recursive: true });
17627
17669
  }
17628
- const flagPath = join6(RESTART_FLAGS_DIR, `${codeName}.flag`);
17670
+ const flagPath = join7(RESTART_FLAGS_DIR, `${codeName}.flag`);
17629
17671
  writeSlackRestartConfirm(
17630
17672
  {
17631
17673
  channel: opts.channel,
@@ -17691,7 +17733,7 @@ var THREAD_STORE_TTL_DAYS = parseTtlDays(process.env.SLACK_THREAD_FOLLOW_TTL_DAY
17691
17733
  var threadPersister = null;
17692
17734
  function resolveThreadStorePath() {
17693
17735
  if (!AGENT_CODE_NAME) return null;
17694
- return join6(homedir2(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
17736
+ return join7(homedir3(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
17695
17737
  }
17696
17738
  function parseTtlDays(raw) {
17697
17739
  if (!raw) return void 0;
@@ -17726,9 +17768,9 @@ if (!BOT_TOKEN || !APP_TOKEN) {
17726
17768
  var slackStderrLogStream = null;
17727
17769
  if (AGENT_CODE_NAME) {
17728
17770
  try {
17729
- const logDir = join6(homedir2(), ".augmented", AGENT_CODE_NAME);
17771
+ const logDir = join7(homedir3(), ".augmented", AGENT_CODE_NAME);
17730
17772
  mkdirSync5(logDir, { recursive: true });
17731
- slackStderrLogStream = createWriteStream(join6(logDir, "slack-channel-stderr.log"), {
17773
+ slackStderrLogStream = createWriteStream(join7(logDir, "slack-channel-stderr.log"), {
17732
17774
  flags: "a",
17733
17775
  mode: 384
17734
17776
  });
@@ -18285,7 +18327,7 @@ ${result.formatted}` : "Thread is empty or not found."
18285
18327
  isError: true
18286
18328
  };
18287
18329
  }
18288
- const allowedRoot = resolve2(homedir2(), ".augmented", AGENT_CODE_NAME, "project") + "/";
18330
+ const allowedRoot = resolve2(homedir3(), ".augmented", AGENT_CODE_NAME, "project") + "/";
18289
18331
  const resolvedPath = resolve2(path);
18290
18332
  if (!resolvedPath.startsWith(allowedRoot)) {
18291
18333
  return {
@@ -18307,7 +18349,7 @@ ${result.formatted}` : "Thread is empty or not found."
18307
18349
  };
18308
18350
  }
18309
18351
  size = stat2.size;
18310
- bytes = readFileSync7(resolvedPath);
18352
+ bytes = readFileSync8(resolvedPath);
18311
18353
  } catch (err) {
18312
18354
  return {
18313
18355
  content: [{ type: "text", text: `Failed to read file: ${err.message}` }],
@@ -18894,7 +18936,7 @@ function isDownloadableFileId(fileId, channel) {
18894
18936
  }
18895
18937
  function redactAugmentedPaths2(msg) {
18896
18938
  return msg.replaceAll(
18897
- new RegExp(`${homedir2().replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}/\\.augmented/[^\\s'"\`]*`, "g"),
18939
+ new RegExp(`${homedir3().replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}/\\.augmented/[^\\s'"\`]*`, "g"),
18898
18940
  "<augmented-path>"
18899
18941
  );
18900
18942
  }
@@ -19286,7 +19328,7 @@ async function connectSocketMode() {
19286
19328
  let paneLogFreshAgeMs = null;
19287
19329
  if (SLACK_AGENT_DIR) {
19288
19330
  try {
19289
- const paneMtimeMs = statSync2(join6(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
19331
+ const paneMtimeMs = statSync2(join7(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
19290
19332
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
19291
19333
  } catch {
19292
19334
  }