@integrity-labs/agt-cli 0.28.474 → 0.28.475

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.
@@ -18906,7 +18906,7 @@ var require_filters = __commonJS({
18906
18906
  return r.copySafeness(str, res);
18907
18907
  }
18908
18908
  _exports.indent = indent;
18909
- function join22(arr, del, attr) {
18909
+ function join21(arr, del, attr) {
18910
18910
  del = del || "";
18911
18911
  if (attr) {
18912
18912
  arr = lib.map(arr, function(v) {
@@ -18915,7 +18915,7 @@ var require_filters = __commonJS({
18915
18915
  }
18916
18916
  return arr.join(del);
18917
18917
  }
18918
- _exports.join = join22;
18918
+ _exports.join = join21;
18919
18919
  function last(arr) {
18920
18920
  return arr[arr.length - 1];
18921
18921
  }
@@ -30432,40 +30432,6 @@ function resolveSlackScheduledChannelGuardMode(opts) {
30432
30432
  if (cached2 !== void 0) return clampScheduledChannelGuardMode(cached2);
30433
30433
  return "shadow";
30434
30434
  }
30435
- var USAGE_LIMIT_REACTIVE_FLAG_KEY = "usage-limit-reactive-notice";
30436
- function parseUsageLimitReactiveMode(raw) {
30437
- if (raw === void 0) return void 0;
30438
- const v = raw.trim().toLowerCase();
30439
- if (v === "") return void 0;
30440
- if (v === "off" || v === "shadow" || v === "enforce") return v;
30441
- const b = envBoolean(raw);
30442
- if (b === true) return "enforce";
30443
- if (b === false) return "off";
30444
- return void 0;
30445
- }
30446
- function cachedUsageLimitReactiveMode(path) {
30447
- try {
30448
- if (!existsSync(path)) return void 0;
30449
- const parsed = JSON.parse(readFileSync(path, "utf8"));
30450
- if (!parsed || typeof parsed !== "object") return void 0;
30451
- const flags = parsed.flags;
30452
- if (!flags || typeof flags !== "object") return void 0;
30453
- const value = flags[USAGE_LIMIT_REACTIVE_FLAG_KEY];
30454
- if (typeof value === "string") return parseUsageLimitReactiveMode(value);
30455
- if (typeof value === "boolean") return value ? "enforce" : "off";
30456
- return void 0;
30457
- } catch {
30458
- return void 0;
30459
- }
30460
- }
30461
- function resolveUsageLimitReactiveMode(opts) {
30462
- const env2 = opts?.env ?? process.env;
30463
- const modeOverride = parseUsageLimitReactiveMode(env2["AGT_USAGE_LIMIT_REACTIVE_MODE"]);
30464
- if (modeOverride !== void 0) return modeOverride;
30465
- const cached2 = cachedUsageLimitReactiveMode(opts?.cachePath ?? defaultFlagsCachePath());
30466
- if (cached2 !== void 0) return cached2;
30467
- return "off";
30468
- }
30469
30435
 
30470
30436
  // src/maintenance-mode.ts
30471
30437
  var FLAG_KEY = "platform-maintenance-mode";
@@ -30480,11 +30446,6 @@ function isMaintenanceModeActive(opts) {
30480
30446
  });
30481
30447
  }
30482
30448
 
30483
- // src/usage-limit-notice.ts
30484
- import { readFileSync as readFileSync2 } from "fs";
30485
- import { homedir as homedir2 } from "os";
30486
- import { join as join2 } from "path";
30487
-
30488
30449
  // ../core/dist/types/integration.js
30489
30450
  var HITL_TIER_ORDER = [
30490
30451
  "read",
@@ -33918,30 +33879,11 @@ function parseResetDateTime(humanDate, now) {
33918
33879
  return resolved;
33919
33880
  }
33920
33881
 
33921
- // ../core/dist/claude-code-usage/usage-limit-marker.js
33922
- var USAGE_LIMIT_MARKER_FILENAME = "claude-usage-limit.json";
33923
- var USAGE_LIMIT_MARKER_VERSION = 1;
33924
- function parseUsageLimitMarker(raw) {
33925
- let parsed;
33926
- try {
33927
- parsed = JSON.parse(raw);
33928
- } catch {
33929
- return null;
33930
- }
33931
- if (typeof parsed !== "object" || parsed === null || parsed.version !== USAGE_LIMIT_MARKER_VERSION) {
33932
- return null;
33933
- }
33934
- const until = parsed.limited_until;
33935
- if (typeof until !== "string" || !Number.isFinite(Date.parse(until)))
33936
- return null;
33937
- return { version: USAGE_LIMIT_MARKER_VERSION, limited_until: until };
33938
- }
33939
- function resolveUsageLimitUntil(marker, now) {
33940
- if (!marker)
33941
- return null;
33942
- const until = new Date(marker.limited_until);
33943
- return until.getTime() > now.getTime() ? until : null;
33944
- }
33882
+ // ../core/dist/claude-code-usage/run-marker.js
33883
+ var RUN_MARKER_RE = /<!--\s*agt-run:([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})\s*-->/;
33884
+ var RUN_MARKER_RE_GLOBAL = new RegExp(RUN_MARKER_RE.source, "g");
33885
+
33886
+ // ../core/dist/claude-code-usage/usage-limit-notice-text.js
33945
33887
  function formatUtcClock(date3) {
33946
33888
  const hours = date3.getUTCHours();
33947
33889
  const minutes = date3.getUTCMinutes();
@@ -34876,42 +34818,6 @@ var FLAG_REGISTRY = [
34876
34818
  // projectDefinition, so setting it does not roll FLAGS_SCHEMA_VERSION.
34877
34819
  since: "0.28.421"
34878
34820
  },
34879
- {
34880
- key: "usage-limit-reactive-notice",
34881
- description: "Report a Claude Code usage cap REACTIVELY instead of predicting it (ENG-8201). Today the manager guesses from the agent transcript that the next turn will be refused, writes a marker, and every channel MCP refuses to dispatch on the strength of that guess - so a wrong guess is a swallowed message, and because the notice is throttled per (channel, sender) while the DROP is not, the usual symptom is total silence rather than a wrong reply. A refused turn actually costs nothing (rejected in under a second, zero tokens) and Claude Code records it with the reset time in it, so there is no need to guess: dispatch, and report the refusal if one comes back. off = today behaviour (pre-dispatch marker gate, no watcher). shadow = still gate on the marker, but ALSO watch dispatched messages and log the refusal that would have been reported - measures the true-positive rate with no user-visible change. enforce = stop reading the marker before dispatch; every admitted human message reaches the agent and a refusal is answered in-thread with the reset time from the error itself. Read live from the heartbeat flags-cache (or the env override).",
34882
- flagType: "enum",
34883
- allowedValues: ["off", "shadow", "enforce"],
34884
- // Ships dark: off preserves today's gate byte-for-byte. shadow is a free
34885
- // local log line (the watch is a transcript read, no model spend), so it is a
34886
- // cheap soak; enforce changes what reaches the agent, so it is the audited
34887
- // per-org flip.
34888
- defaultValue: "off",
34889
- // Enum override AGT_USAGE_LIMIT_REACTIVE_MODE (off|shadow|enforce), resolved
34890
- // by resolveUsageLimitReactiveMode in the channel-server bundle.
34891
- envVar: "AGT_USAGE_LIMIT_REACTIVE_MODE",
34892
- // enforce sends a message to an agent the host currently believes is capped -
34893
- // a deliberate availability trade (the refusal is free, but it is still a
34894
- // dispatch the operator previously suppressed), so flipping toward it is an
34895
- // audited change (ADR-0022 sensitive-flag confirm).
34896
- sensitive: true,
34897
- // ENG-8149 / ENG-8229: the agt-cli that first carries
34898
- // resolveUsageLimitReactiveMode in ALL THREE channel servers - published from
34899
- // the ENG-8207 merge 0294fa1a8. Without this the flip-reach modal reports FULL
34900
- // reach, because an undefined `since` means "every host can honour it" - true
34901
- // for flags that predate the reach work, wrong for a NEW host-read flag whose
34902
- // reader older hosts simply do not have. Excluded from projectDefinition, so
34903
- // setting it does not roll FLAGS_SCHEMA_VERSION.
34904
- //
34905
- // Deliberately the LATER of the two versions this flag's reader shipped in.
34906
- // Unlike its siblings, this reader landed in two stages: direct-chat at the
34907
- // ENG-8201 Slice 2 publish, slack + telegram only at 0.28.450 (ENG-8207) - and
34908
- // `since` is one version per flag, so it cannot express "partially honoured".
34909
- // A host in between genuinely honours the flag for direct-chat and is still
34910
- // classified `stale`. That understates reach rather than overstating it, which
34911
- // is the safe direction, and it is the useful one while the flag sits at
34912
- // enforce and slack/telegram adoption is what an operator needs to track.
34913
- since: "0.28.450"
34914
- },
34915
34821
  {
34916
34822
  key: "slack-hot-thread-guard",
34917
34823
  description: "Server-side hot-thread guard on the slack.reply surface (ENG-7462). Prevents an agent posting a NEW top-level Slack message when it meant to reply inside the thread it is already working in - a prompt/memory rule proved insufficient (the agent had the rule and still slipped). When a reply would otherwise post to channel ROOT (no thread_ts / message_ts / inbound_id, no active kanban card) and the agent has a recent active thread in that channel (its last bot-posted thread, from the persisted trackedThreads cache, within a freshness window), the reply is redirected into that thread. proactive:true no longer implies channel root; posting at root becomes a deliberate action (the to_channel_root flag, or the thread_ts:null sentinel). off = guard never runs, replies with no coords root exactly as today (ships dark). shadow = compute + log the would-redirect but STILL post to root (measure the fire rate before acting). enforce = apply the redirect (a soft-block: redirect + inform, never a hard rejection). Read live from the heartbeat flags-cache (or the env override); enforce is a deliberate per-org flip after a shadow soak.",
@@ -35618,37 +35524,20 @@ function deriveBindFailureQuarantineThreshold(provisioningMax) {
35618
35524
  }
35619
35525
  var MIN_PROVISIONING_MAX_FOR_QUARANTINE_ORDERING = BIND_FAILURE_QUARANTINE_THRESHOLD + 1;
35620
35526
 
35621
- // src/usage-limit-notice.ts
35622
- function usageLimitMarkerPath(codeName) {
35623
- if (!codeName) return null;
35624
- return join2(homedir2(), ".augmented", codeName, USAGE_LIMIT_MARKER_FILENAME);
35625
- }
35626
- function readUsageLimitUntil(opts) {
35627
- const path = opts.filePath ?? usageLimitMarkerPath(opts.codeName);
35628
- if (!path) return null;
35629
- let raw;
35630
- try {
35631
- raw = readFileSync2(path, "utf-8");
35632
- } catch {
35633
- return null;
35634
- }
35635
- return resolveUsageLimitUntil(parseUsageLimitMarker(raw), opts.now ?? /* @__PURE__ */ new Date());
35636
- }
35637
-
35638
35527
  // src/account-enforcement-notice.ts
35639
- import { readFileSync as readFileSync3 } from "fs";
35640
- import { homedir as homedir3 } from "os";
35641
- import { join as join3 } from "path";
35528
+ import { readFileSync as readFileSync2 } from "fs";
35529
+ import { homedir as homedir2 } from "os";
35530
+ import { join as join2 } from "path";
35642
35531
  function accountEnforcementMarkerPath(codeName) {
35643
35532
  if (!codeName) return null;
35644
- return join3(homedir3(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
35533
+ return join2(homedir2(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
35645
35534
  }
35646
35535
  function readAccountEnforcementLevel(opts) {
35647
35536
  const path = opts.filePath ?? accountEnforcementMarkerPath(opts.codeName);
35648
35537
  if (!path) return null;
35649
35538
  let raw;
35650
35539
  try {
35651
- raw = readFileSync3(path, "utf-8");
35540
+ raw = readFileSync2(path, "utf-8");
35652
35541
  } catch {
35653
35542
  return null;
35654
35543
  }
@@ -35771,8 +35660,8 @@ function watchSuccessTextSlack(fileId, durationMs, reused) {
35771
35660
  }
35772
35661
 
35773
35662
  // src/ack-reaction.ts
35774
- import { readdirSync, readFileSync as readFileSync4, writeFileSync } from "fs";
35775
- import { join as join4 } from "path";
35663
+ import { readdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
35664
+ import { join as join3 } from "path";
35776
35665
  var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
35777
35666
  var ACK_STARTUP_GRACE_MS = 6e4;
35778
35667
  var ACK_PANE_FRESH_THRESHOLD_MS = 6e4;
@@ -35869,7 +35758,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
35869
35758
  function readGiveUpSignal(path, now = Date.now()) {
35870
35759
  if (!path) return null;
35871
35760
  try {
35872
- const raw = JSON.parse(readFileSync4(path, "utf8"));
35761
+ const raw = JSON.parse(readFileSync3(path, "utf8"));
35873
35762
  if (typeof raw.gave_up_at !== "string") return null;
35874
35763
  const t = Date.parse(raw.gave_up_at);
35875
35764
  if (!Number.isFinite(t) || t > now) return null;
@@ -35910,7 +35799,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
35910
35799
  if (!name.endsWith(".json")) continue;
35911
35800
  let receivedAt;
35912
35801
  try {
35913
- const raw = JSON.parse(readFileSync4(join4(dir, name), "utf-8"));
35802
+ const raw = JSON.parse(readFileSync3(join3(dir, name), "utf-8"));
35914
35803
  if (raw.discretionary === true) continue;
35915
35804
  if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
35916
35805
  receivedAt = raw.received_at;
@@ -35987,14 +35876,14 @@ function isMarkerGenuinelyAged(receivedAt, nowMs, thresholdMs) {
35987
35876
  }
35988
35877
  var DEFLECTION_COUNTER_SUFFIX = "-deflections.json";
35989
35878
  function deflectionCounterPath(agentDir, channel) {
35990
- return join4(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
35879
+ return join3(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
35991
35880
  }
35992
35881
  function recordChannelDeflection(agentDir, channel, cause) {
35993
35882
  if (!agentDir) return;
35994
35883
  const path = deflectionCounterPath(agentDir, channel);
35995
35884
  let counts = {};
35996
35885
  try {
35997
- const parsed = JSON.parse(readFileSync4(path, "utf-8"));
35886
+ const parsed = JSON.parse(readFileSync3(path, "utf-8"));
35998
35887
  if (parsed && typeof parsed === "object") counts = parsed;
35999
35888
  } catch {
36000
35889
  }
@@ -36058,15 +35947,15 @@ function probeAgentSessionCached(codeName, ttlMs = SESSION_PROBE_TTL_MS, now = D
36058
35947
  }
36059
35948
 
36060
35949
  // src/agent-config-state.ts
36061
- import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
36062
- import { join as join5 } from "path";
35950
+ import { existsSync as existsSync2, readFileSync as readFileSync4 } from "fs";
35951
+ import { join as join4 } from "path";
36063
35952
  var SESSION_STATE_FILENAME = "session-state.json";
36064
35953
  function readAgentSessionState(stateDir) {
36065
35954
  if (!stateDir) return null;
36066
- const path = join5(stateDir, SESSION_STATE_FILENAME);
35955
+ const path = join4(stateDir, SESSION_STATE_FILENAME);
36067
35956
  if (!existsSync2(path)) return null;
36068
35957
  try {
36069
- const parsed = JSON.parse(readFileSync5(path, "utf-8"));
35958
+ const parsed = JSON.parse(readFileSync4(path, "utf-8"));
36070
35959
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
36071
35960
  return parsed;
36072
35961
  } catch {
@@ -36273,10 +36162,10 @@ import { promisify } from "util";
36273
36162
  import { open, stat } from "fs/promises";
36274
36163
 
36275
36164
  // src/channel-attachments.ts
36276
- import { homedir as homedir4 } from "os";
36277
- import { join as join6, resolve, sep } from "path";
36165
+ import { homedir as homedir3 } from "os";
36166
+ import { join as join5, resolve, sep } from "path";
36278
36167
  function resolveChannelInboundDir(codeName, channelSlug) {
36279
- const base = join6(homedir4(), ".augmented");
36168
+ const base = join5(homedir3(), ".augmented");
36280
36169
  const allowedSegment = /^[A-Za-z0-9_-]+$/;
36281
36170
  if (!allowedSegment.test(codeName) || !allowedSegment.test(channelSlug)) {
36282
36171
  throw new Error(
@@ -36354,7 +36243,7 @@ function isPathInside(target, root) {
36354
36243
  return normalizedTarget === resolve(root) || normalizedTarget.startsWith(normalizedRoot);
36355
36244
  }
36356
36245
  function redactAugmentedPaths(msg) {
36357
- const homePrefix = homedir4().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36246
+ const homePrefix = homedir3().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36358
36247
  return msg.replaceAll(
36359
36248
  new RegExp(`${homePrefix}[\\\\/]\\.augmented(?:[\\\\/][^\\s'"\`]*)*`, "g"),
36360
36249
  "<augmented-path>"
@@ -36804,15 +36693,15 @@ function emitToolCallMarkupRedactionTelemetry(channel) {
36804
36693
  }
36805
36694
 
36806
36695
  // src/rate-limit-watch.ts
36807
- import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync } from "fs";
36808
- import { homedir as homedir5 } from "os";
36809
- import { join as join7 } from "path";
36696
+ import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync } from "fs";
36697
+ import { homedir as homedir4 } from "os";
36698
+ import { join as join6 } from "path";
36810
36699
  var DEFAULT_WATCH_MS = 5e3;
36811
36700
  var DEFAULT_POLL_MS = 400;
36812
36701
  function agentTranscriptDir(opts) {
36813
36702
  const cwd = opts?.cwd ?? process.cwd();
36814
- const home = opts?.home ?? homedir5();
36815
- return join7(home, ".claude", "projects", encodeClaudeProjectPath(cwd));
36703
+ const home = opts?.home ?? homedir4();
36704
+ return join6(home, ".claude", "projects", encodeClaudeProjectPath(cwd));
36816
36705
  }
36817
36706
  function classifyTranscriptSince(opts) {
36818
36707
  const dir = opts.transcriptDir ?? agentTranscriptDir({ cwd: opts.cwd, home: opts.home });
@@ -36825,7 +36714,7 @@ function classifyTranscriptSince(opts) {
36825
36714
  let newest = UNKNOWN_RATE_LIMIT;
36826
36715
  for (const name of entries) {
36827
36716
  if (!name.endsWith(".jsonl")) continue;
36828
- const path = join7(dir, name);
36717
+ const path = join6(dir, name);
36829
36718
  try {
36830
36719
  const st = statSync(path);
36831
36720
  if (!st.isFile() || st.mtimeMs < opts.sinceMs) continue;
@@ -36834,7 +36723,7 @@ function classifyTranscriptSince(opts) {
36834
36723
  }
36835
36724
  let content;
36836
36725
  try {
36837
- content = readFileSync6(path, "utf-8");
36726
+ content = readFileSync5(path, "utf-8");
36838
36727
  } catch {
36839
36728
  continue;
36840
36729
  }
@@ -36873,8 +36762,8 @@ async function watchForRateLimitRefusal(opts) {
36873
36762
  }
36874
36763
 
36875
36764
  // src/turn-failure-watch.ts
36876
- import { readFileSync as readFileSync7, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
36877
- import { join as join8 } from "path";
36765
+ import { readFileSync as readFileSync6, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
36766
+ import { join as join7 } from "path";
36878
36767
  function turnFailureNoticeEnabled(env2) {
36879
36768
  return resolveHostBooleanFlag({
36880
36769
  key: "wedge-transient-notice",
@@ -36903,7 +36792,7 @@ function classifyTurnFailureSince(opts) {
36903
36792
  const unrecognised = /* @__PURE__ */ new Set();
36904
36793
  for (const name of entries) {
36905
36794
  if (!name.endsWith(".jsonl")) continue;
36906
- const path = join8(dir, name);
36795
+ const path = join7(dir, name);
36907
36796
  let fingerprint;
36908
36797
  try {
36909
36798
  const st = statSync2(path);
@@ -36919,7 +36808,7 @@ function classifyTurnFailureSince(opts) {
36919
36808
  } else {
36920
36809
  let content;
36921
36810
  try {
36922
- content = readFileSync7(path, "utf-8");
36811
+ content = readFileSync6(path, "utf-8");
36923
36812
  } catch {
36924
36813
  continue;
36925
36814
  }
@@ -37017,19 +36906,14 @@ async function watchForTurnFailure(opts) {
37017
36906
 
37018
36907
  // src/usage-limit-reactive-decision.ts
37019
36908
  import { createHash } from "crypto";
37020
- function shouldReadPredictiveMarker(mode) {
37021
- return mode !== "enforce";
37022
- }
37023
- function armedWatchMode(opts) {
37024
- if (opts.mode === "off") return null;
37025
- if (opts.isBot || !opts.replyOwed) return null;
37026
- return opts.mode;
36909
+ function shouldArmWatch(opts) {
36910
+ return !opts.isBot && opts.replyOwed;
37027
36911
  }
37028
36912
  function decideRefusalAction(opts) {
37029
36913
  const { refusal } = opts;
37030
36914
  if (!refusal || refusal.verdict !== "capped") return "none";
37031
36915
  if (!refusal.resetsAt) return "missing-reset";
37032
- return opts.mode === "shadow" ? "shadow-log" : "notify";
36916
+ return "notify";
37033
36917
  }
37034
36918
  function describeUnparsedRefusal(text) {
37035
36919
  if (!text) return "refusal=absent";
@@ -37040,8 +36924,8 @@ function describeUnparsedRefusal(text) {
37040
36924
  // src/reply-intent-runtime.ts
37041
36925
  import { execFile as execFile2 } from "child_process";
37042
36926
  import { existsSync as existsSync3, mkdirSync, writeFileSync as writeFileSync2 } from "fs";
37043
- import { homedir as homedir6 } from "os";
37044
- import { join as join9 } from "path";
36927
+ import { homedir as homedir5 } from "os";
36928
+ import { join as join8 } from "path";
37045
36929
  var DEFAULT_CLAUDE_EVAL_MODEL = "claude-haiku-4-5-20251001";
37046
36930
  var DEFAULT_ANTHROPIC_MESSAGES_URL = "https://api.anthropic.com/v1/messages";
37047
36931
  var ANTHROPIC_API_VERSION = "2023-06-01";
@@ -37140,12 +37024,12 @@ async function runAnthropicMessages(prompt, opts) {
37140
37024
  var emptyMcpConfigPath = null;
37141
37025
  function ensureEmptyMcpConfig() {
37142
37026
  if (emptyMcpConfigPath && existsSync3(emptyMcpConfigPath)) return emptyMcpConfigPath;
37143
- const dir = join9(homedir6(), ".augmented");
37027
+ const dir = join8(homedir5(), ".augmented");
37144
37028
  try {
37145
37029
  mkdirSync(dir, { recursive: true });
37146
37030
  } catch {
37147
37031
  }
37148
- const p2 = join9(dir, ".reply-intent-empty-mcp.json");
37032
+ const p2 = join8(dir, ".reply-intent-empty-mcp.json");
37149
37033
  writeFileSync2(p2, JSON.stringify({ mcpServers: {} }));
37150
37034
  emptyMcpConfigPath = p2;
37151
37035
  return p2;
@@ -37170,7 +37054,7 @@ function runClaudeP(prompt, model) {
37170
37054
  execFile2(
37171
37055
  "claude",
37172
37056
  args,
37173
- { cwd: homedir6(), timeout: CLASSIFY_TIMEOUT_MS, maxBuffer: 1 << 20 },
37057
+ { cwd: homedir5(), timeout: CLASSIFY_TIMEOUT_MS, maxBuffer: 1 << 20 },
37174
37058
  (err, stdout) => {
37175
37059
  if (err) {
37176
37060
  reject(err);
@@ -37324,7 +37208,7 @@ function emitUrlAsteriskStripTelemetry(channel, count = 0) {
37324
37208
 
37325
37209
  // src/slack-pending-inbound-cleanup.ts
37326
37210
  import { existsSync as existsSync4, readdirSync as readdirSync4, statSync as statSync3, unlinkSync } from "fs";
37327
- import { join as join10 } from "path";
37211
+ import { join as join9 } from "path";
37328
37212
  function sanitizeMarkerSegment(value) {
37329
37213
  return value.replace(/[^A-Za-z0-9_-]/g, "_");
37330
37214
  }
@@ -37340,7 +37224,7 @@ function applyToMatchingMarkers(dir, prefix, suffix, op) {
37340
37224
  try {
37341
37225
  for (const f of readdirSync4(dir)) {
37342
37226
  if (!f.startsWith(prefix) || !f.endsWith(suffix)) continue;
37343
- op(join10(dir, f));
37227
+ op(join9(dir, f));
37344
37228
  applied += 1;
37345
37229
  }
37346
37230
  } catch {
@@ -37370,7 +37254,7 @@ function clearOldestSlackPendingMarkerInChannel(dir, channel, clear = defaultCle
37370
37254
  const channelPrefix = `${sanitizeMarkerSegment(channel)}__`;
37371
37255
  try {
37372
37256
  const entries = readdirSync4(dir).filter((f) => f.startsWith(channelPrefix) && f.endsWith(".json")).map((f) => {
37373
- const full = join10(dir, f);
37257
+ const full = join9(dir, f);
37374
37258
  let mtime = 0;
37375
37259
  try {
37376
37260
  mtime = statSync3(full).mtimeMs;
@@ -37413,12 +37297,12 @@ function describePromiseStampOutcome(tally, replyToolName) {
37413
37297
 
37414
37298
  // src/recovery-ledger.ts
37415
37299
  import { existsSync as existsSync5, unlinkSync as unlinkSync2 } from "fs";
37416
- import { join as join11 } from "path";
37300
+ import { join as join10 } from "path";
37417
37301
  function recoveryLedgerEntryExists(ledgerDir, markerName, exists = (p2) => existsSync5(p2)) {
37418
37302
  if (!ledgerDir || !markerName) return false;
37419
37303
  if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return false;
37420
37304
  try {
37421
- return exists(join11(ledgerDir, markerName));
37305
+ return exists(join10(ledgerDir, markerName));
37422
37306
  } catch {
37423
37307
  return false;
37424
37308
  }
@@ -37429,7 +37313,7 @@ function removeRecoveryLedgerEntry(ledgerDir, markerName, unlink = (p2) => {
37429
37313
  if (!ledgerDir || !markerName) return;
37430
37314
  if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
37431
37315
  try {
37432
- unlink(join11(ledgerDir, markerName));
37316
+ unlink(join10(ledgerDir, markerName));
37433
37317
  } catch {
37434
37318
  }
37435
37319
  }
@@ -37666,18 +37550,18 @@ function applyHotThreadGuard(input) {
37666
37550
  }
37667
37551
 
37668
37552
  // src/slack-hot-thread-telemetry.ts
37669
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync3 } from "fs";
37670
- import { join as join12 } from "path";
37553
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync3 } from "fs";
37554
+ import { join as join11 } from "path";
37671
37555
  var HOT_THREAD_CLASSIFICATION_COUNTER_SUFFIX = "-hot-thread-classifications.json";
37672
37556
  function hotThreadKey(mode, outcome, proactive) {
37673
37557
  return `${mode}|${outcome}|${proactive ? "true" : "false"}`;
37674
37558
  }
37675
37559
  function recordHotThreadClassification(agentDir, channel, classification) {
37676
37560
  if (!agentDir || !channel) return;
37677
- const path = join12(agentDir, `${channel}${HOT_THREAD_CLASSIFICATION_COUNTER_SUFFIX}`);
37561
+ const path = join11(agentDir, `${channel}${HOT_THREAD_CLASSIFICATION_COUNTER_SUFFIX}`);
37678
37562
  let counts = {};
37679
37563
  try {
37680
- const parsed = JSON.parse(readFileSync8(path, "utf-8"));
37564
+ const parsed = JSON.parse(readFileSync7(path, "utf-8"));
37681
37565
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
37682
37566
  for (const [k, v] of Object.entries(parsed)) {
37683
37567
  if (typeof v === "number" && Number.isInteger(v) && v >= 0) counts[k] = v;
@@ -37694,7 +37578,7 @@ function recordHotThreadClassification(agentDir, channel, classification) {
37694
37578
  }
37695
37579
 
37696
37580
  // src/restart-confirm.ts
37697
- import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync9, renameSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync4 } from "fs";
37581
+ import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync8, renameSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync4 } from "fs";
37698
37582
  import { dirname } from "path";
37699
37583
  import { randomUUID } from "crypto";
37700
37584
  var RESTART_CONFIRM_MAX_AGE_MS = 10 * 60 * 1e3;
@@ -37720,7 +37604,7 @@ function writeRestartConfirmMarker(filePath, marker) {
37720
37604
  function readRestartConfirmMarker(filePath) {
37721
37605
  try {
37722
37606
  if (!existsSync6(filePath)) return null;
37723
- const parsed = JSON.parse(readFileSync9(filePath, "utf8"));
37607
+ const parsed = JSON.parse(readFileSync8(filePath, "utf8"));
37724
37608
  if (!parsed || typeof parsed !== "object") return null;
37725
37609
  return parsed;
37726
37610
  } catch {
@@ -37865,7 +37749,7 @@ import {
37865
37749
  ftruncateSync,
37866
37750
  mkdirSync as mkdirSync9,
37867
37751
  openSync,
37868
- readFileSync as readFileSync21,
37752
+ readFileSync as readFileSync20,
37869
37753
  readdirSync as readdirSync7,
37870
37754
  renameSync as renameSync5,
37871
37755
  statSync as statSync5,
@@ -37874,12 +37758,12 @@ import {
37874
37758
  writeFileSync as writeFileSync14,
37875
37759
  writeSync
37876
37760
  } from "fs";
37877
- import { basename, join as join21, resolve as resolve2 } from "path";
37878
- import { homedir as homedir7 } from "os";
37761
+ import { basename, join as join20, resolve as resolve2 } from "path";
37762
+ import { homedir as homedir6 } from "os";
37879
37763
  import { createHash as createHash3, randomUUID as randomUUID2 } from "crypto";
37880
37764
 
37881
37765
  // src/slack-thread-store.ts
37882
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
37766
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
37883
37767
  import { dirname as dirname2 } from "path";
37884
37768
  function isParticipatingThread(entry) {
37885
37769
  if (!entry) return false;
@@ -37894,7 +37778,7 @@ function loadThreadStore(filePath, opts = {}) {
37894
37778
  const ttlMs = ttlDays * 24 * 60 * 60 * 1e3;
37895
37779
  let raw;
37896
37780
  try {
37897
- raw = readFileSync10(filePath, "utf-8");
37781
+ raw = readFileSync9(filePath, "utf-8");
37898
37782
  } catch {
37899
37783
  return { threads: /* @__PURE__ */ new Map(), pruned: 0 };
37900
37784
  }
@@ -37995,7 +37879,7 @@ function isThreadEntry(value) {
37995
37879
  }
37996
37880
 
37997
37881
  // src/dm-restart-notice.ts
37998
- import { mkdirSync as mkdirSync4, readFileSync as readFileSync11, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
37882
+ import { mkdirSync as mkdirSync4, readFileSync as readFileSync10, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
37999
37883
  import { dirname as dirname3 } from "path";
38000
37884
  var RECENT_DM_VERSION = 1;
38001
37885
  var DEFAULT_RECENT_DM_TTL_MS = 30 * 60 * 1e3;
@@ -38019,7 +37903,7 @@ function loadRecentDms(filePath, opts = {}) {
38019
37903
  const ttlMs = opts.ttlMs ?? DEFAULT_RECENT_DM_TTL_MS;
38020
37904
  let raw;
38021
37905
  try {
38022
- raw = readFileSync11(filePath, "utf-8");
37906
+ raw = readFileSync10(filePath, "utf-8");
38023
37907
  } catch (err) {
38024
37908
  const code = err.code;
38025
37909
  if (code !== "ENOENT") {
@@ -38104,7 +37988,7 @@ var CHANNEL_ADD_RESTART_MAX_AGE_MS = 15 * 60 * 1e3;
38104
37988
  function readChannelAddRestartMarker(filePath) {
38105
37989
  let raw;
38106
37990
  try {
38107
- raw = readFileSync11(filePath, "utf-8");
37991
+ raw = readFileSync10(filePath, "utf-8");
38108
37992
  } catch {
38109
37993
  return null;
38110
37994
  }
@@ -38162,13 +38046,13 @@ async function runOrRetry(fn, opts) {
38162
38046
  }
38163
38047
 
38164
38048
  // src/turn-initiator-marker.ts
38165
- import { writeFileSync as writeFileSync7, readFileSync as readFileSync12, mkdirSync as mkdirSync5, renameSync as renameSync2 } from "fs";
38166
- import { dirname as dirname4, join as join13 } from "path";
38049
+ import { writeFileSync as writeFileSync7, readFileSync as readFileSync11, mkdirSync as mkdirSync5, renameSync as renameSync2 } from "fs";
38050
+ import { dirname as dirname4, join as join12 } from "path";
38167
38051
  var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
38168
38052
  var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
38169
38053
  var TURN_INITIATOR_LEDGER_FILENAME = ".turn-initiator-ledger.json";
38170
38054
  function turnInitiatorLedgerPath(singleSlotFile) {
38171
- return join13(dirname4(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
38055
+ return join12(dirname4(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
38172
38056
  }
38173
38057
  function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX_AGE_MS, maxEntries = TURN_INITIATOR_LEDGER_MAX_ENTRIES) {
38174
38058
  const now = marker.ts;
@@ -38193,7 +38077,7 @@ function updateTurnInitiatorLedger(singleSlotFile, marker) {
38193
38077
  const ledgerFile = turnInitiatorLedgerPath(singleSlotFile);
38194
38078
  let existing = null;
38195
38079
  try {
38196
- const parsed = JSON.parse(readFileSync12(ledgerFile, "utf8"));
38080
+ const parsed = JSON.parse(readFileSync11(ledgerFile, "utf8"));
38197
38081
  if (parsed && parsed.v === 1 && Array.isArray(parsed.entries)) existing = parsed;
38198
38082
  } catch {
38199
38083
  }
@@ -38220,7 +38104,7 @@ function writeTurnInitiatorMarker(input) {
38220
38104
  }
38221
38105
 
38222
38106
  // src/slack-bot-photo.ts
38223
- import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync13, writeFileSync as writeFileSync8 } from "fs";
38107
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync12, writeFileSync as writeFileSync8 } from "fs";
38224
38108
  import { dirname as dirname5 } from "path";
38225
38109
  async function applyBotPhoto(opts) {
38226
38110
  const fetchImpl = opts.fetchImpl ?? fetch;
@@ -38230,7 +38114,7 @@ async function applyBotPhoto(opts) {
38230
38114
  const { token, avatarUrl, markerPath } = opts;
38231
38115
  if (markerPath && existsSync7(markerPath)) {
38232
38116
  try {
38233
- if (readFileSync13(markerPath, "utf-8").trim() === avatarUrl) {
38117
+ if (readFileSync12(markerPath, "utf-8").trim() === avatarUrl) {
38234
38118
  return { status: "skipped-unchanged" };
38235
38119
  }
38236
38120
  } catch {
@@ -38355,8 +38239,8 @@ function conversationalLaneMeta(expectsReply = true) {
38355
38239
  }
38356
38240
 
38357
38241
  // src/inbound-lane-telemetry.ts
38358
- import { readFileSync as readFileSync14, writeFileSync as writeFileSync9 } from "fs";
38359
- import { join as join14 } from "path";
38242
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync9 } from "fs";
38243
+ import { join as join13 } from "path";
38360
38244
  var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
38361
38245
  var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
38362
38246
  var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
@@ -38373,10 +38257,10 @@ function isSuspectedMisclassification(lane, source) {
38373
38257
  }
38374
38258
  function recordLaneClassification(agentDir, channel, classification) {
38375
38259
  if (!agentDir) return;
38376
- const path = join14(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
38260
+ const path = join13(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
38377
38261
  let counts = {};
38378
38262
  try {
38379
- const parsed = JSON.parse(readFileSync14(path, "utf-8"));
38263
+ const parsed = JSON.parse(readFileSync13(path, "utf-8"));
38380
38264
  if (parsed && typeof parsed === "object") counts = parsed;
38381
38265
  } catch {
38382
38266
  }
@@ -38392,8 +38276,8 @@ function recordLaneClassification(agentDir, channel, classification) {
38392
38276
  }
38393
38277
 
38394
38278
  // src/slack-inbound-registry.ts
38395
- import { readdirSync as readdirSync5, readFileSync as readFileSync15 } from "fs";
38396
- import { join as join15 } from "path";
38279
+ import { readdirSync as readdirSync5, readFileSync as readFileSync14 } from "fs";
38280
+ import { join as join14 } from "path";
38397
38281
  var DEFAULT_MAX_ENTRIES = 500;
38398
38282
  var DEFAULT_CLEARED_TTL_MS = 6 * 60 * 60 * 1e3;
38399
38283
  function entryKey(channel, messageTs) {
@@ -38514,7 +38398,7 @@ function createInboundRegistry(opts = {}) {
38514
38398
  if (name.includes(".retry-") || name.includes(".poison")) continue;
38515
38399
  let marker;
38516
38400
  try {
38517
- marker = JSON.parse(readFileSync15(join15(dir, name), "utf-8"));
38401
+ marker = JSON.parse(readFileSync14(join14(dir, name), "utf-8"));
38518
38402
  } catch {
38519
38403
  continue;
38520
38404
  }
@@ -38559,8 +38443,8 @@ function slackInboundId(channel, threadTs, messageTs) {
38559
38443
  }
38560
38444
 
38561
38445
  // src/inbound-delivery-ledger.ts
38562
- import { existsSync as existsSync8, mkdirSync as mkdirSync7, readdirSync as readdirSync6, readFileSync as readFileSync16, renameSync as renameSync3, writeFileSync as writeFileSync10 } from "fs";
38563
- import { join as join16 } from "path";
38446
+ import { existsSync as existsSync8, mkdirSync as mkdirSync7, readdirSync as readdirSync6, readFileSync as readFileSync15, renameSync as renameSync3, writeFileSync as writeFileSync10 } from "fs";
38447
+ import { join as join15 } from "path";
38564
38448
  function safeInboundId(inboundId) {
38565
38449
  return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
38566
38450
  }
@@ -38569,7 +38453,7 @@ var defaultDeps = {
38569
38453
  writeFile: (path, data) => writeFileSync10(path, data, "utf8"),
38570
38454
  rename: (from, to) => renameSync3(from, to),
38571
38455
  readdir: (dir) => readdirSync6(dir),
38572
- readFile: (path) => readFileSync16(path, "utf8"),
38456
+ readFile: (path) => readFileSync15(path, "utf8"),
38573
38457
  exists: (path) => existsSync8(path)
38574
38458
  };
38575
38459
  function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
@@ -38578,7 +38462,7 @@ function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
38578
38462
  if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
38579
38463
  try {
38580
38464
  deps.mkdir(dir);
38581
- const final = join16(dir, `${safe}.json`);
38465
+ const final = join15(dir, `${safe}.json`);
38582
38466
  const tmp = `${final}.tmp`;
38583
38467
  deps.writeFile(tmp, JSON.stringify(record2));
38584
38468
  deps.rename(tmp, final);
@@ -38759,8 +38643,8 @@ function describeSendOutcome(dest) {
38759
38643
  }
38760
38644
 
38761
38645
  // src/slack-reply-binding-telemetry.ts
38762
- import { readFileSync as readFileSync17, writeFileSync as writeFileSync11 } from "fs";
38763
- import { join as join17 } from "path";
38646
+ import { readFileSync as readFileSync16, writeFileSync as writeFileSync11 } from "fs";
38647
+ import { join as join16 } from "path";
38764
38648
  var REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX = "-reply-binding-classifications.json";
38765
38649
  var UNKNOWN_INBOUND_ID_KEY = "unknown_inbound_id";
38766
38650
  var CHANNEL_MISTARGET_CORRECTED_KEY = "channel_mistarget_corrected";
@@ -38775,10 +38659,10 @@ function slackReplyBindingMode() {
38775
38659
  }
38776
38660
  function recordReplyBindingClassification(agentDir, channel, input) {
38777
38661
  if (!agentDir) return;
38778
- const path = join17(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38662
+ const path = join16(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38779
38663
  let counts = {};
38780
38664
  try {
38781
- const parsed = JSON.parse(readFileSync17(path, "utf-8"));
38665
+ const parsed = JSON.parse(readFileSync16(path, "utf-8"));
38782
38666
  if (parsed && typeof parsed === "object") counts = parsed;
38783
38667
  } catch {
38784
38668
  }
@@ -38793,10 +38677,10 @@ function recordReplyBindingClassification(agentDir, channel, input) {
38793
38677
  }
38794
38678
  function recordScheduledChannelOverride(agentDir, channel, input) {
38795
38679
  if (!agentDir) return;
38796
- const path = join17(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38680
+ const path = join16(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38797
38681
  let counts = {};
38798
38682
  try {
38799
- const parsed = JSON.parse(readFileSync17(path, "utf-8"));
38683
+ const parsed = JSON.parse(readFileSync16(path, "utf-8"));
38800
38684
  if (parsed && typeof parsed === "object") counts = parsed;
38801
38685
  } catch {
38802
38686
  }
@@ -38809,10 +38693,10 @@ function recordScheduledChannelOverride(agentDir, channel, input) {
38809
38693
  }
38810
38694
  function recordChannelMistarget(agentDir, channel, input) {
38811
38695
  if (!agentDir) return;
38812
- const path = join17(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38696
+ const path = join16(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38813
38697
  let counts = {};
38814
38698
  try {
38815
- const parsed = JSON.parse(readFileSync17(path, "utf-8"));
38699
+ const parsed = JSON.parse(readFileSync16(path, "utf-8"));
38816
38700
  if (parsed && typeof parsed === "object") counts = parsed;
38817
38701
  } catch {
38818
38702
  }
@@ -38827,8 +38711,8 @@ function recordChannelMistarget(agentDir, channel, input) {
38827
38711
  }
38828
38712
 
38829
38713
  // src/slack-reply-target-telemetry.ts
38830
- import { readFileSync as readFileSync18, writeFileSync as writeFileSync12 } from "fs";
38831
- import { join as join18 } from "path";
38714
+ import { readFileSync as readFileSync17, writeFileSync as writeFileSync12 } from "fs";
38715
+ import { join as join17 } from "path";
38832
38716
  var REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX = "-reply-target-classifications.json";
38833
38717
  function pendingThreadsBucket(n) {
38834
38718
  if (n <= 0) return "0";
@@ -38861,10 +38745,10 @@ function classifyReplyTarget(input) {
38861
38745
  }
38862
38746
  function recordReplyTargetClassification(agentDir, channel, classification) {
38863
38747
  if (!agentDir) return;
38864
- const path = join18(agentDir, `${channel}${REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX}`);
38748
+ const path = join17(agentDir, `${channel}${REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX}`);
38865
38749
  let counts = {};
38866
38750
  try {
38867
- const parsed = JSON.parse(readFileSync18(path, "utf-8"));
38751
+ const parsed = JSON.parse(readFileSync17(path, "utf-8"));
38868
38752
  if (parsed && typeof parsed === "object") counts = parsed;
38869
38753
  } catch {
38870
38754
  }
@@ -38880,8 +38764,8 @@ function recordReplyTargetClassification(agentDir, channel, classification) {
38880
38764
  }
38881
38765
 
38882
38766
  // src/scheduled-turn-marker.ts
38883
- import { readFileSync as readFileSync19, unlinkSync as unlinkSync5 } from "fs";
38884
- import { join as join19 } from "path";
38767
+ import { readFileSync as readFileSync18, unlinkSync as unlinkSync5 } from "fs";
38768
+ import { join as join18 } from "path";
38885
38769
  var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
38886
38770
  var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
38887
38771
  function validateScheduledTurnMarker(raw, now, maxAgeMs = SCHEDULED_TURN_MAX_AGE_MS) {
@@ -38919,7 +38803,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
38919
38803
  if (!agentDir) return null;
38920
38804
  try {
38921
38805
  const raw = JSON.parse(
38922
- readFileSync19(join19(agentDir, SCHEDULED_TURN_MARKER_FILENAME2), "utf8")
38806
+ readFileSync18(join18(agentDir, SCHEDULED_TURN_MARKER_FILENAME2), "utf8")
38923
38807
  );
38924
38808
  return validateScheduledTurnMarker(raw, now);
38925
38809
  } catch {
@@ -38929,7 +38813,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
38929
38813
  function clearScheduledTurnMarker(agentDir) {
38930
38814
  if (!agentDir) return;
38931
38815
  try {
38932
- unlinkSync5(join19(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
38816
+ unlinkSync5(join18(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
38933
38817
  } catch {
38934
38818
  }
38935
38819
  }
@@ -39731,14 +39615,14 @@ async function actuateHostRestart(opts) {
39731
39615
  import {
39732
39616
  existsSync as existsSync9,
39733
39617
  mkdirSync as mkdirSync8,
39734
- readFileSync as readFileSync20,
39618
+ readFileSync as readFileSync19,
39735
39619
  renameSync as renameSync4,
39736
39620
  statSync as statSync4,
39737
39621
  unlinkSync as unlinkSync6,
39738
39622
  utimesSync,
39739
39623
  writeFileSync as writeFileSync13
39740
39624
  } from "fs";
39741
- import { join as join20 } from "path";
39625
+ import { join as join19 } from "path";
39742
39626
  var STALE_LOCK_MS = 9e4;
39743
39627
  var HEARTBEAT_INTERVAL_MS = 3e4;
39744
39628
  function defaultIsPidAlive(pid) {
@@ -39761,7 +39645,7 @@ function acquireMcpSpawnLock(args) {
39761
39645
  const nowMs = options.nowMs ?? (() => Date.now());
39762
39646
  const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
39763
39647
  const staleMs = options.staleMs ?? STALE_LOCK_MS;
39764
- const path = join20(agentDir, basename2);
39648
+ const path = join19(agentDir, basename2);
39765
39649
  const existing = readLockHolder(path);
39766
39650
  if (existing) {
39767
39651
  if (existing.pid === selfPid) {
@@ -39828,7 +39712,7 @@ function defaultLockMtimeMs(path) {
39828
39712
  function readLockHolder(path) {
39829
39713
  if (!existsSync9(path)) return null;
39830
39714
  try {
39831
- const raw = readFileSync20(path, "utf8");
39715
+ const raw = readFileSync19(path, "utf8");
39832
39716
  const parsed = JSON.parse(raw);
39833
39717
  const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
39834
39718
  if (!Number.isFinite(pid) || pid <= 0) return null;
@@ -40063,24 +39947,17 @@ function armSlackUsageLimitWatch(args) {
40063
39947
  void (async () => {
40064
39948
  try {
40065
39949
  const refusal = await watchForRateLimitRefusal({ sinceMs: args.sinceMs });
40066
- const action = decideRefusalAction({ mode: args.mode, refusal });
39950
+ const action = decideRefusalAction({ refusal });
40067
39951
  if (action === "none") return;
40068
39952
  if (action === "missing-reset") {
40069
39953
  process.stderr.write(
40070
- `slack-channel(${AGENT_CODE_NAME}): [usage-limit-reactive] mode=${args.mode} refusal detected for channel=${redactSlackId(args.channel)} but no reset time in it (${describeUnparsedRefusal(refusal?.text)}) - no notice
39954
+ `slack-channel(${AGENT_CODE_NAME}): [usage-limit-reactive] refusal detected for channel=${redactSlackId(args.channel)} but no reset time in it (${describeUnparsedRefusal(refusal?.text)}) - no notice
40071
39955
  `
40072
39956
  );
40073
39957
  return;
40074
39958
  }
40075
39959
  const resetsAt = refusal?.resetsAt;
40076
39960
  if (!resetsAt) return;
40077
- if (action === "shadow-log") {
40078
- process.stderr.write(
40079
- `slack-channel(${AGENT_CODE_NAME}): [usage-limit-reactive] mode=shadow WOULD notify channel=${redactSlackId(args.channel)} ts=${redactSlackId(args.messageTs)} resets=${resetsAt.toISOString()}
40080
- `
40081
- );
40082
- return;
40083
- }
40084
39961
  await maybeSendUsageLimitNotice({
40085
39962
  channel: args.channel,
40086
39963
  senderId: args.senderId,
@@ -40277,8 +40154,8 @@ var SLACK_TEAM_PEER_USER_IDS = parseTeamPeerUserIdsEnv(
40277
40154
  process.env.SLACK_TEAM_PEER_USER_IDS
40278
40155
  );
40279
40156
  var PEER_HINT_SEEN = /* @__PURE__ */ new Set();
40280
- var SLACK_AGENT_DIR = AGENT_CODE_NAME ? join21(homedir7(), ".augmented", AGENT_CODE_NAME) : null;
40281
- var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "project", ".mcp.json") : null;
40157
+ var SLACK_AGENT_DIR = AGENT_CODE_NAME ? join20(homedir6(), ".augmented", AGENT_CODE_NAME) : null;
40158
+ var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "project", ".mcp.json") : null;
40282
40159
  var liveAllowedUsersCache = null;
40283
40160
  function readLiveAllowedUsers() {
40284
40161
  if (!SLACK_MCP_CONFIG_PATH) return null;
@@ -40288,7 +40165,7 @@ function readLiveAllowedUsers() {
40288
40165
  return liveAllowedUsersCache.value;
40289
40166
  }
40290
40167
  const value = extractAllowedUsersFromMcpJson(
40291
- readFileSync21(SLACK_MCP_CONFIG_PATH, "utf-8")
40168
+ readFileSync20(SLACK_MCP_CONFIG_PATH, "utf-8")
40292
40169
  );
40293
40170
  if (value === null) return null;
40294
40171
  liveAllowedUsersCache = { mtimeMs, value };
@@ -40309,7 +40186,7 @@ function readLivePingAllowedUsers() {
40309
40186
  return livePingAllowedUsersCache.value;
40310
40187
  }
40311
40188
  const value = extractPingAllowedUsersFromMcpJson(
40312
- readFileSync21(SLACK_MCP_CONFIG_PATH, "utf-8")
40189
+ readFileSync20(SLACK_MCP_CONFIG_PATH, "utf-8")
40313
40190
  );
40314
40191
  if (value === null) return null;
40315
40192
  livePingAllowedUsersCache = { mtimeMs, value };
@@ -40321,17 +40198,17 @@ function readLivePingAllowedUsers() {
40321
40198
  function getEffectivePingAllowedUsers() {
40322
40199
  return readLivePingAllowedUsers() ?? PING_ALLOWED_USERS;
40323
40200
  }
40324
- var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "slack-pending-inbound") : null;
40325
- var SLACK_RESTART_CONTEXT_DIR = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "slack-restart-context") : null;
40326
- var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "slack-recovery-outbox") : null;
40327
- var SLACK_RECOVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, ".agt-slack-recovery-ledger") : null;
40328
- var SLACK_DELIVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
40201
+ var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-pending-inbound") : null;
40202
+ var SLACK_RESTART_CONTEXT_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-restart-context") : null;
40203
+ var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-recovery-outbox") : null;
40204
+ var SLACK_RECOVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, ".agt-slack-recovery-ledger") : null;
40205
+ var SLACK_DELIVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
40329
40206
  var slackInboundRegistry = createInboundRegistry();
40330
- var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "slack-restart-confirm.json") : null;
40331
- var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "slack-recent-dms.json") : null;
40332
- var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "slack-channel-add-restart.json") : null;
40207
+ var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-restart-confirm.json") : null;
40208
+ var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-recent-dms.json") : null;
40209
+ var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-channel-add-restart.json") : null;
40333
40210
  var SLACK_MAX_RECOVERY_ATTEMPTS = 3;
40334
- var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
40211
+ var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
40335
40212
  function redactSlackId(id) {
40336
40213
  if (!id) return "<none>";
40337
40214
  return createHash3("sha256").update(id).digest("hex").slice(0, 8);
@@ -40342,7 +40219,7 @@ function safeSlackMarkerName(channel, threadTs, messageTs) {
40342
40219
  }
40343
40220
  function slackPendingInboundPath(channel, threadTs, messageTs) {
40344
40221
  if (!SLACK_PENDING_INBOUND_DIR) return null;
40345
- return join21(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
40222
+ return join20(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
40346
40223
  }
40347
40224
  function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undeliverable = false, discretionary = false, payload) {
40348
40225
  const path = slackPendingInboundPath(channel, threadTs, messageTs);
@@ -40399,7 +40276,7 @@ function markSlackMarkerPromisedInPlace(fullPath) {
40399
40276
  function markSlackMarkerEngagedInPlace(fullPath, opts) {
40400
40277
  let marker;
40401
40278
  try {
40402
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
40279
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
40403
40280
  } catch {
40404
40281
  return false;
40405
40282
  }
@@ -40414,7 +40291,7 @@ function markSlackMarkerEngagedInPlace(fullPath, opts) {
40414
40291
  rewriteSlackMarkerInPlace(fullPath, marker);
40415
40292
  if (!opts.promise) return false;
40416
40293
  try {
40417
- const readBack = JSON.parse(readFileSync21(fullPath, "utf-8"));
40294
+ const readBack = JSON.parse(readFileSync20(fullPath, "utf-8"));
40418
40295
  return typeof readBack.promised_at === "string" && readBack.promised_at.length > 0;
40419
40296
  } catch {
40420
40297
  return false;
@@ -40425,7 +40302,7 @@ function attachSlackReplayPayload(channel, threadTs, messageTs, payload) {
40425
40302
  if (!path) return;
40426
40303
  let marker;
40427
40304
  try {
40428
- marker = JSON.parse(readFileSync21(path, "utf-8"));
40305
+ marker = JSON.parse(readFileSync20(path, "utf-8"));
40429
40306
  } catch {
40430
40307
  return;
40431
40308
  }
@@ -40436,7 +40313,7 @@ function readSlackPendingInboundMarker(channel, threadTs, messageTs) {
40436
40313
  const path = slackPendingInboundPath(channel, threadTs, messageTs);
40437
40314
  if (!path || !existsSync10(path)) return null;
40438
40315
  try {
40439
- return JSON.parse(readFileSync21(path, "utf-8"));
40316
+ return JSON.parse(readFileSync20(path, "utf-8"));
40440
40317
  } catch {
40441
40318
  return null;
40442
40319
  }
@@ -40552,7 +40429,7 @@ function scheduleBusyAck(channel, threadTs, messageTs, isThreadReply, arrivedWhi
40552
40429
  let paneLogFreshAgeMs = null;
40553
40430
  if (SLACK_AGENT_DIR) {
40554
40431
  try {
40555
- const paneMtimeMs = statSync5(join21(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
40432
+ const paneMtimeMs = statSync5(join20(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
40556
40433
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
40557
40434
  } catch {
40558
40435
  }
@@ -40585,7 +40462,7 @@ function __resetSlackBusyAckNoticeThrottle() {
40585
40462
  function clearSlackMarkerFileWithHeal(fullPath) {
40586
40463
  let marker = null;
40587
40464
  try {
40588
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
40465
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
40589
40466
  } catch {
40590
40467
  }
40591
40468
  if (marker && decideRecoveryHeal({
@@ -40612,7 +40489,7 @@ var slackPromiseStampOutcome = { attempted: 0, stamped: 0 };
40612
40489
  function healThenEngageSlackMarker(fullPath, opts) {
40613
40490
  let marker = null;
40614
40491
  try {
40615
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
40492
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
40616
40493
  } catch {
40617
40494
  return false;
40618
40495
  }
@@ -40697,10 +40574,10 @@ function slackNextRetryName(filename) {
40697
40574
  async function processSlackRecoveryOutboxFile(filename) {
40698
40575
  if (!SLACK_RECOVERY_OUTBOX_DIR) return;
40699
40576
  if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
40700
- const fullPath = join21(SLACK_RECOVERY_OUTBOX_DIR, filename);
40577
+ const fullPath = join20(SLACK_RECOVERY_OUTBOX_DIR, filename);
40701
40578
  let payload;
40702
40579
  try {
40703
- payload = JSON.parse(readFileSync21(fullPath, "utf-8"));
40580
+ payload = JSON.parse(readFileSync20(fullPath, "utf-8"));
40704
40581
  } catch (err) {
40705
40582
  process.stderr.write(
40706
40583
  `slack-channel(${AGENT_CODE_NAME}): recovery outbox parse failed (${filename}): ${err.message}
@@ -40806,7 +40683,7 @@ async function processSlackRecoveryOutboxFile(filename) {
40806
40683
  const next = slackNextRetryName(filename);
40807
40684
  if (next) {
40808
40685
  try {
40809
- renameSync5(fullPath, join21(SLACK_RECOVERY_OUTBOX_DIR, next.next));
40686
+ renameSync5(fullPath, join20(SLACK_RECOVERY_OUTBOX_DIR, next.next));
40810
40687
  if (next.attempt >= SLACK_MAX_RECOVERY_ATTEMPTS) {
40811
40688
  process.stderr.write(
40812
40689
  `slack-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
@@ -40846,7 +40723,7 @@ function scanSlackRecoveryRetries() {
40846
40723
  if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
40847
40724
  let mtimeMs;
40848
40725
  try {
40849
- mtimeMs = statSync5(join21(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
40726
+ mtimeMs = statSync5(join20(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
40850
40727
  } catch {
40851
40728
  continue;
40852
40729
  }
@@ -40876,7 +40753,7 @@ function startSlackRecoveryOutboxWatcher() {
40876
40753
  const watcher = watch(SLACK_RECOVERY_OUTBOX_DIR, (event, filename) => {
40877
40754
  if (event !== "rename" || !filename) return;
40878
40755
  if (!isFirstAttemptSlackOutboxFile(filename)) return;
40879
- if (existsSync10(join21(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
40756
+ if (existsSync10(join20(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
40880
40757
  void processSlackRecoveryOutboxFile(filename);
40881
40758
  }
40882
40759
  });
@@ -40891,7 +40768,7 @@ function startSlackRecoveryOutboxWatcher() {
40891
40768
  retryTimer.unref?.();
40892
40769
  }
40893
40770
  startSlackRecoveryOutboxWatcher();
40894
- var SLACK_NOTICE_OUTBOX_DIR = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "slack-notice-outbox") : null;
40771
+ var SLACK_NOTICE_OUTBOX_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-notice-outbox") : null;
40895
40772
  var SLACK_NOTICE_MAX_AGE_MS = 9e4;
40896
40773
  var SLACK_NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
40897
40774
  async function processSlackNoticeOutboxFile(filename) {
@@ -40899,7 +40776,7 @@ async function processSlackNoticeOutboxFile(filename) {
40899
40776
  if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
40900
40777
  if (SLACK_NOTICE_INFLIGHT.has(filename)) return;
40901
40778
  SLACK_NOTICE_INFLIGHT.add(filename);
40902
- const fullPath = join21(SLACK_NOTICE_OUTBOX_DIR, filename);
40779
+ const fullPath = join20(SLACK_NOTICE_OUTBOX_DIR, filename);
40903
40780
  try {
40904
40781
  let mtimeMs;
40905
40782
  try {
@@ -40916,7 +40793,7 @@ async function processSlackNoticeOutboxFile(filename) {
40916
40793
  }
40917
40794
  let payload;
40918
40795
  try {
40919
- const parsed = JSON.parse(readFileSync21(fullPath, "utf-8"));
40796
+ const parsed = JSON.parse(readFileSync20(fullPath, "utf-8"));
40920
40797
  if (!parsed || typeof parsed !== "object") throw new Error("not an object");
40921
40798
  payload = parsed;
40922
40799
  } catch {
@@ -41005,7 +40882,7 @@ function startSlackNoticeOutboxWatcher() {
41005
40882
  try {
41006
40883
  const watcher = watch(SLACK_NOTICE_OUTBOX_DIR, (event, filename) => {
41007
40884
  if (event !== "rename" || !filename) return;
41008
- if (existsSync10(join21(SLACK_NOTICE_OUTBOX_DIR, filename))) {
40885
+ if (existsSync10(join20(SLACK_NOTICE_OUTBOX_DIR, filename))) {
41009
40886
  void processSlackNoticeOutboxFile(filename);
41010
40887
  }
41011
40888
  });
@@ -41042,10 +40919,10 @@ function sweepSlackStaleMarkers(thresholdMs) {
41042
40919
  for (const filename of filenames) {
41043
40920
  if (!filename.endsWith(".json")) continue;
41044
40921
  if (filename.endsWith(".tmp")) continue;
41045
- const fullPath = join21(SLACK_PENDING_INBOUND_DIR, filename);
40922
+ const fullPath = join20(SLACK_PENDING_INBOUND_DIR, filename);
41046
40923
  let marker;
41047
40924
  try {
41048
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
40925
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
41049
40926
  } catch (err) {
41050
40927
  process.stderr.write(
41051
40928
  `slack-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactSlackId(filename)}: ${err.message}
@@ -41103,13 +40980,13 @@ var slackOrphanSweepTimer = setInterval(() => {
41103
40980
  checkSlackWatchdogGiveUpNotice();
41104
40981
  }, orphanSweepIntervalMs());
41105
40982
  slackOrphanSweepTimer.unref?.();
41106
- var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "channel-progress-heartbeat.json") : null;
40983
+ var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "channel-progress-heartbeat.json") : null;
41107
40984
  var slackTrackedProgress = null;
41108
40985
  var slackProgressTickRunning = false;
41109
40986
  function readSlackProgressHeartbeat() {
41110
40987
  if (!SLACK_PROGRESS_HEARTBEAT_PATH || !existsSync10(SLACK_PROGRESS_HEARTBEAT_PATH)) return null;
41111
40988
  try {
41112
- return parseProgressHeartbeat(readFileSync21(SLACK_PROGRESS_HEARTBEAT_PATH, "utf-8"));
40989
+ return parseProgressHeartbeat(readFileSync20(SLACK_PROGRESS_HEARTBEAT_PATH, "utf-8"));
41113
40990
  } catch {
41114
40991
  return null;
41115
40992
  }
@@ -41136,7 +41013,7 @@ function findSlackProgressTarget() {
41136
41013
  if (!name.endsWith(".json")) continue;
41137
41014
  let m;
41138
41015
  try {
41139
- m = JSON.parse(readFileSync21(join21(SLACK_PENDING_INBOUND_DIR, name), "utf-8"));
41016
+ m = JSON.parse(readFileSync20(join20(SLACK_PENDING_INBOUND_DIR, name), "utf-8"));
41140
41017
  } catch {
41141
41018
  continue;
41142
41019
  }
@@ -41287,7 +41164,7 @@ function listPendingSlackConversations() {
41287
41164
  if (!name.endsWith(".json")) continue;
41288
41165
  try {
41289
41166
  const marker = JSON.parse(
41290
- readFileSync21(join21(SLACK_PENDING_INBOUND_DIR, name), "utf8")
41167
+ readFileSync20(join20(SLACK_PENDING_INBOUND_DIR, name), "utf8")
41291
41168
  );
41292
41169
  if (typeof marker.channel !== "string" || !marker.channel) continue;
41293
41170
  if (typeof marker.thread_ts !== "string" || !marker.thread_ts) continue;
@@ -41428,7 +41305,7 @@ function postSlackWatchdogGiveUpNotice(channel, threadTs, isThreadReply, reason)
41428
41305
  }
41429
41306
  function checkSlackWatchdogGiveUpNotice() {
41430
41307
  if (!SLACK_AGENT_DIR) return;
41431
- const signal = readGiveUpSignal(join21(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
41308
+ const signal = readGiveUpSignal(join20(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
41432
41309
  const signalAtMs = signal?.atMs ?? null;
41433
41310
  const act = decideGiveUpNotice({
41434
41311
  signalAtMs,
@@ -41460,7 +41337,7 @@ function readRestartTopicForMarker(filename, channel, threadTs) {
41460
41337
  if (!SLACK_RESTART_CONTEXT_DIR) return null;
41461
41338
  let raw;
41462
41339
  try {
41463
- raw = readFileSync21(join21(SLACK_RESTART_CONTEXT_DIR, filename), "utf-8");
41340
+ raw = readFileSync20(join20(SLACK_RESTART_CONTEXT_DIR, filename), "utf-8");
41464
41341
  } catch {
41465
41342
  return null;
41466
41343
  }
@@ -41469,7 +41346,7 @@ function readRestartTopicForMarker(filename, channel, threadTs) {
41469
41346
  function removeRestartContextHint(filename) {
41470
41347
  if (!SLACK_RESTART_CONTEXT_DIR) return;
41471
41348
  try {
41472
- unlinkSync7(join21(SLACK_RESTART_CONTEXT_DIR, filename));
41349
+ unlinkSync7(join20(SLACK_RESTART_CONTEXT_DIR, filename));
41473
41350
  } catch {
41474
41351
  }
41475
41352
  }
@@ -41484,7 +41361,7 @@ function clearAllRestartContextHints() {
41484
41361
  for (const name of names) {
41485
41362
  if (!name.endsWith(".json")) continue;
41486
41363
  try {
41487
- unlinkSync7(join21(SLACK_RESTART_CONTEXT_DIR, name));
41364
+ unlinkSync7(join20(SLACK_RESTART_CONTEXT_DIR, name));
41488
41365
  } catch {
41489
41366
  }
41490
41367
  }
@@ -41511,10 +41388,10 @@ async function notifyStrandedInboundsOnFirstConnect() {
41511
41388
  let notified = 0;
41512
41389
  for (const filename of filenames) {
41513
41390
  if (!filename.endsWith(".json")) continue;
41514
- const fullPath = join21(SLACK_PENDING_INBOUND_DIR, filename);
41391
+ const fullPath = join20(SLACK_PENDING_INBOUND_DIR, filename);
41515
41392
  let marker;
41516
41393
  try {
41517
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
41394
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
41518
41395
  } catch {
41519
41396
  continue;
41520
41397
  }
@@ -41688,7 +41565,7 @@ function noteThreadActivityByMessageTs(channel, messageTs) {
41688
41565
  markSeenAllSlackPendingMarkersForThread2(channel, messageTs);
41689
41566
  markSeenSlackPendingMarkerByMessageTs2(channel, messageTs);
41690
41567
  }
41691
- var RESTART_FLAGS_DIR = join21(homedir7(), ".augmented", "restart-flags");
41568
+ var RESTART_FLAGS_DIR = join20(homedir6(), ".augmented", "restart-flags");
41692
41569
  function actuateHostRestartSlack() {
41693
41570
  return actuateHostRestart({
41694
41571
  agtHost: AGT_HOST,
@@ -42293,7 +42170,7 @@ async function handleSlashCommandEnvelope(payload) {
42293
42170
  if (!existsSync10(RESTART_FLAGS_DIR)) {
42294
42171
  mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
42295
42172
  }
42296
- const flagPath = join21(RESTART_FLAGS_DIR, `${codeName}.flag`);
42173
+ const flagPath = join20(RESTART_FLAGS_DIR, `${codeName}.flag`);
42297
42174
  const flag = {
42298
42175
  codeName,
42299
42176
  source: "slack",
@@ -42436,7 +42313,7 @@ async function handleRestartCommand(opts) {
42436
42313
  if (!existsSync10(RESTART_FLAGS_DIR)) {
42437
42314
  mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
42438
42315
  }
42439
- const flagPath = join21(RESTART_FLAGS_DIR, `${codeName}.flag`);
42316
+ const flagPath = join20(RESTART_FLAGS_DIR, `${codeName}.flag`);
42440
42317
  const flag = {
42441
42318
  codeName,
42442
42319
  source: "slack",
@@ -42558,7 +42435,7 @@ var SLACK_HOT_THREAD_WINDOW_MS = parseHotThreadWindowMs(
42558
42435
  );
42559
42436
  function resolveThreadStorePath() {
42560
42437
  if (!AGENT_CODE_NAME) return null;
42561
- return join21(homedir7(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
42438
+ return join20(homedir6(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
42562
42439
  }
42563
42440
  function parseTtlDays(raw) {
42564
42441
  if (!raw) return void 0;
@@ -42597,9 +42474,9 @@ if (!BOT_TOKEN || !APP_TOKEN) {
42597
42474
  var slackStderrLogStream = null;
42598
42475
  if (AGENT_CODE_NAME) {
42599
42476
  try {
42600
- const logDir = join21(homedir7(), ".augmented", AGENT_CODE_NAME);
42477
+ const logDir = join20(homedir6(), ".augmented", AGENT_CODE_NAME);
42601
42478
  mkdirSync9(logDir, { recursive: true });
42602
- slackStderrLogStream = createWriteStream(join21(logDir, "slack-channel-stderr.log"), {
42479
+ slackStderrLogStream = createWriteStream(join20(logDir, "slack-channel-stderr.log"), {
42603
42480
  flags: "a",
42604
42481
  mode: 384
42605
42482
  });
@@ -43520,7 +43397,7 @@ ${result.formatted}` : "No messages in range, or the bot is not a member of this
43520
43397
  isError: true
43521
43398
  };
43522
43399
  }
43523
- const allowedRoot = resolve2(homedir7(), ".augmented", AGENT_CODE_NAME, "project") + "/";
43400
+ const allowedRoot = resolve2(homedir6(), ".augmented", AGENT_CODE_NAME, "project") + "/";
43524
43401
  const resolvedPath = resolve2(path);
43525
43402
  if (!resolvedPath.startsWith(allowedRoot)) {
43526
43403
  return {
@@ -43542,7 +43419,7 @@ ${result.formatted}` : "No messages in range, or the bot is not a member of this
43542
43419
  };
43543
43420
  }
43544
43421
  size = stat2.size;
43545
- bytes = readFileSync21(resolvedPath);
43422
+ bytes = readFileSync20(resolvedPath);
43546
43423
  } catch (err) {
43547
43424
  return {
43548
43425
  content: [{ type: "text", text: `Failed to read file: ${err.message}` }],
@@ -44197,7 +44074,7 @@ function isDownloadableFileId(fileId, channel) {
44197
44074
  }
44198
44075
  function redactAugmentedPaths2(msg) {
44199
44076
  return msg.replaceAll(
44200
- new RegExp(`${homedir7().replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}/\\.augmented/[^\\s'"\`]*`, "g"),
44077
+ new RegExp(`${homedir6().replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}/\\.augmented/[^\\s'"\`]*`, "g"),
44201
44078
  "<augmented-path>"
44202
44079
  );
44203
44080
  }
@@ -44325,7 +44202,7 @@ async function replayPendingSlackMarkers() {
44325
44202
  let paneFreshAgeMs = null;
44326
44203
  if (SLACK_AGENT_DIR) {
44327
44204
  try {
44328
- paneFreshAgeMs = Math.max(0, now - statSync5(join21(SLACK_AGENT_DIR, "pane.log")).mtimeMs);
44205
+ paneFreshAgeMs = Math.max(0, now - statSync5(join20(SLACK_AGENT_DIR, "pane.log")).mtimeMs);
44329
44206
  } catch {
44330
44207
  }
44331
44208
  }
@@ -44333,10 +44210,10 @@ async function replayPendingSlackMarkers() {
44333
44210
  const entries = [];
44334
44211
  for (const name of filenames) {
44335
44212
  if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
44336
- const fullPath = join21(SLACK_PENDING_INBOUND_DIR, name);
44213
+ const fullPath = join20(SLACK_PENDING_INBOUND_DIR, name);
44337
44214
  let marker;
44338
44215
  try {
44339
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
44216
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
44340
44217
  } catch {
44341
44218
  continue;
44342
44219
  }
@@ -44803,26 +44680,6 @@ async function connectSocketMode() {
44803
44680
  }).catch((err) => {
44804
44681
  process.stderr.write(
44805
44682
  `slack-channel(${AGENT_CODE_NAME}): account-mute notice failed: ${err.message}
44806
- `
44807
- );
44808
- });
44809
- return;
44810
- }
44811
- const reactiveMode = resolveUsageLimitReactiveMode();
44812
- const usageLimitUntil = !isBot && shouldReadPredictiveMarker(reactiveMode) ? readUsageLimitUntil({ codeName: AGENT_CODE_NAME }) : null;
44813
- if (usageLimitUntil) {
44814
- process.stderr.write(
44815
- `slack-channel(${AGENT_CODE_NAME}): usage-limit active until ${usageLimitUntil.toISOString()} \u2014 notice, no dispatch (channel=${redactSlackId(evt.channel)})
44816
- `
44817
- );
44818
- await maybeSendUsageLimitNotice({
44819
- channel: evt.channel,
44820
- senderId: evt.user,
44821
- threadTs: evt.thread_ts,
44822
- limitedUntil: usageLimitUntil
44823
- }).catch((err) => {
44824
- process.stderr.write(
44825
- `slack-channel(${AGENT_CODE_NAME}): usage-limit notice failed: ${err.message}
44826
44683
  `
44827
44684
  );
44828
44685
  });
@@ -44934,7 +44791,7 @@ async function connectSocketMode() {
44934
44791
  let paneLogFreshAgeMs = null;
44935
44792
  if (SLACK_AGENT_DIR) {
44936
44793
  try {
44937
- const paneMtimeMs = statSync5(join21(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
44794
+ const paneMtimeMs = statSync5(join20(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
44938
44795
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
44939
44796
  } catch {
44940
44797
  }
@@ -45105,14 +44962,8 @@ ${forwarded.text}` : forwarded.text;
45105
44962
  method: "notifications/claude/channel",
45106
44963
  params: replayPayload
45107
44964
  });
45108
- const watchMode = armedWatchMode({
45109
- mode: reactiveMode,
45110
- isBot: isFromBot,
45111
- replyOwed: shouldEngage
45112
- });
45113
- if (watchMode) {
44965
+ if (shouldArmWatch({ isBot: isFromBot, replyOwed: shouldEngage })) {
45114
44966
  armSlackUsageLimitWatch({
45115
- mode: watchMode,
45116
44967
  channel,
45117
44968
  senderId: evt.user,
45118
44969
  threadTs,