@integrity-labs/agt-cli 0.28.474 → 0.28.476

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",
@@ -33195,6 +33156,34 @@ var INTEGRATION_REGISTRY = [
33195
33156
  docs_url: "https://higgsfield.ai/mcp",
33196
33157
  beta: true
33197
33158
  },
33159
+ {
33160
+ id: "vercel",
33161
+ name: "Vercel",
33162
+ category: "infrastructure",
33163
+ description: "Check on Vercel app deployments \u2014 status, build/runtime logs \u2014 and search Vercel documentation. Remote streamable-HTTP MCP at https://mcp.vercel.com.",
33164
+ // Same OAuth pattern as Granola/Higgsfield: Claude Code brokers the
33165
+ // browser sign-in at runtime; nothing for the manager API to provision.
33166
+ supported_auth_types: ["none"],
33167
+ capabilities: [
33168
+ { id: "vercel:read-deployments", name: "Read Deployments", description: "List teams/projects, check deployment status, and read build/runtime logs.", access: "read" },
33169
+ { id: "vercel:search-docs", name: "Search Documentation", description: "Search Vercel platform documentation.", access: "read" }
33170
+ ],
33171
+ docs_url: "https://vercel.com/docs/agent-resources/vercel-mcp",
33172
+ // Beta until the headless OAuth flow (and Vercel's OAuth-client allowlist,
33173
+ // which is vendor-side and outside our control) is verified end-to-end.
33174
+ beta: true,
33175
+ // No `auth`/`headers` — host-brokered OAuth (Claude Code authenticates
33176
+ // directly with Vercel; nothing for us to inject). Declaring this here
33177
+ // (rather than a hardcoded buildMcpJson/writeIntegrations branch, the
33178
+ // pre-ENG-8035 Higgsfield-era pattern) lets the generic remote-MCP loop
33179
+ // render the `.mcp.json` entry AND enrolls 'vercel' in the
33180
+ // `registryRemoteMcpKeys` prune universe automatically, so an uninstall
33181
+ // actually removes the entry instead of leaving it stale.
33182
+ remoteMcp: {
33183
+ type: "http",
33184
+ url: "https://mcp.vercel.com"
33185
+ }
33186
+ },
33198
33187
  {
33199
33188
  id: "qmd",
33200
33189
  name: "QMD Memory Search",
@@ -33918,30 +33907,11 @@ function parseResetDateTime(humanDate, now) {
33918
33907
  return resolved;
33919
33908
  }
33920
33909
 
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
- }
33910
+ // ../core/dist/claude-code-usage/run-marker.js
33911
+ 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*-->/;
33912
+ var RUN_MARKER_RE_GLOBAL = new RegExp(RUN_MARKER_RE.source, "g");
33913
+
33914
+ // ../core/dist/claude-code-usage/usage-limit-notice-text.js
33945
33915
  function formatUtcClock(date3) {
33946
33916
  const hours = date3.getUTCHours();
33947
33917
  const minutes = date3.getUTCMinutes();
@@ -34876,42 +34846,6 @@ var FLAG_REGISTRY = [
34876
34846
  // projectDefinition, so setting it does not roll FLAGS_SCHEMA_VERSION.
34877
34847
  since: "0.28.421"
34878
34848
  },
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
34849
  {
34916
34850
  key: "slack-hot-thread-guard",
34917
34851
  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 +35552,20 @@ function deriveBindFailureQuarantineThreshold(provisioningMax) {
35618
35552
  }
35619
35553
  var MIN_PROVISIONING_MAX_FOR_QUARANTINE_ORDERING = BIND_FAILURE_QUARANTINE_THRESHOLD + 1;
35620
35554
 
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
35555
  // 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";
35556
+ import { readFileSync as readFileSync2 } from "fs";
35557
+ import { homedir as homedir2 } from "os";
35558
+ import { join as join2 } from "path";
35642
35559
  function accountEnforcementMarkerPath(codeName) {
35643
35560
  if (!codeName) return null;
35644
- return join3(homedir3(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
35561
+ return join2(homedir2(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
35645
35562
  }
35646
35563
  function readAccountEnforcementLevel(opts) {
35647
35564
  const path = opts.filePath ?? accountEnforcementMarkerPath(opts.codeName);
35648
35565
  if (!path) return null;
35649
35566
  let raw;
35650
35567
  try {
35651
- raw = readFileSync3(path, "utf-8");
35568
+ raw = readFileSync2(path, "utf-8");
35652
35569
  } catch {
35653
35570
  return null;
35654
35571
  }
@@ -35771,8 +35688,8 @@ function watchSuccessTextSlack(fileId, durationMs, reused) {
35771
35688
  }
35772
35689
 
35773
35690
  // src/ack-reaction.ts
35774
- import { readdirSync, readFileSync as readFileSync4, writeFileSync } from "fs";
35775
- import { join as join4 } from "path";
35691
+ import { readdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
35692
+ import { join as join3 } from "path";
35776
35693
  var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
35777
35694
  var ACK_STARTUP_GRACE_MS = 6e4;
35778
35695
  var ACK_PANE_FRESH_THRESHOLD_MS = 6e4;
@@ -35869,7 +35786,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
35869
35786
  function readGiveUpSignal(path, now = Date.now()) {
35870
35787
  if (!path) return null;
35871
35788
  try {
35872
- const raw = JSON.parse(readFileSync4(path, "utf8"));
35789
+ const raw = JSON.parse(readFileSync3(path, "utf8"));
35873
35790
  if (typeof raw.gave_up_at !== "string") return null;
35874
35791
  const t = Date.parse(raw.gave_up_at);
35875
35792
  if (!Number.isFinite(t) || t > now) return null;
@@ -35910,7 +35827,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
35910
35827
  if (!name.endsWith(".json")) continue;
35911
35828
  let receivedAt;
35912
35829
  try {
35913
- const raw = JSON.parse(readFileSync4(join4(dir, name), "utf-8"));
35830
+ const raw = JSON.parse(readFileSync3(join3(dir, name), "utf-8"));
35914
35831
  if (raw.discretionary === true) continue;
35915
35832
  if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
35916
35833
  receivedAt = raw.received_at;
@@ -35987,14 +35904,14 @@ function isMarkerGenuinelyAged(receivedAt, nowMs, thresholdMs) {
35987
35904
  }
35988
35905
  var DEFLECTION_COUNTER_SUFFIX = "-deflections.json";
35989
35906
  function deflectionCounterPath(agentDir, channel) {
35990
- return join4(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
35907
+ return join3(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
35991
35908
  }
35992
35909
  function recordChannelDeflection(agentDir, channel, cause) {
35993
35910
  if (!agentDir) return;
35994
35911
  const path = deflectionCounterPath(agentDir, channel);
35995
35912
  let counts = {};
35996
35913
  try {
35997
- const parsed = JSON.parse(readFileSync4(path, "utf-8"));
35914
+ const parsed = JSON.parse(readFileSync3(path, "utf-8"));
35998
35915
  if (parsed && typeof parsed === "object") counts = parsed;
35999
35916
  } catch {
36000
35917
  }
@@ -36058,15 +35975,15 @@ function probeAgentSessionCached(codeName, ttlMs = SESSION_PROBE_TTL_MS, now = D
36058
35975
  }
36059
35976
 
36060
35977
  // src/agent-config-state.ts
36061
- import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
36062
- import { join as join5 } from "path";
35978
+ import { existsSync as existsSync2, readFileSync as readFileSync4 } from "fs";
35979
+ import { join as join4 } from "path";
36063
35980
  var SESSION_STATE_FILENAME = "session-state.json";
36064
35981
  function readAgentSessionState(stateDir) {
36065
35982
  if (!stateDir) return null;
36066
- const path = join5(stateDir, SESSION_STATE_FILENAME);
35983
+ const path = join4(stateDir, SESSION_STATE_FILENAME);
36067
35984
  if (!existsSync2(path)) return null;
36068
35985
  try {
36069
- const parsed = JSON.parse(readFileSync5(path, "utf-8"));
35986
+ const parsed = JSON.parse(readFileSync4(path, "utf-8"));
36070
35987
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
36071
35988
  return parsed;
36072
35989
  } catch {
@@ -36273,10 +36190,10 @@ import { promisify } from "util";
36273
36190
  import { open, stat } from "fs/promises";
36274
36191
 
36275
36192
  // src/channel-attachments.ts
36276
- import { homedir as homedir4 } from "os";
36277
- import { join as join6, resolve, sep } from "path";
36193
+ import { homedir as homedir3 } from "os";
36194
+ import { join as join5, resolve, sep } from "path";
36278
36195
  function resolveChannelInboundDir(codeName, channelSlug) {
36279
- const base = join6(homedir4(), ".augmented");
36196
+ const base = join5(homedir3(), ".augmented");
36280
36197
  const allowedSegment = /^[A-Za-z0-9_-]+$/;
36281
36198
  if (!allowedSegment.test(codeName) || !allowedSegment.test(channelSlug)) {
36282
36199
  throw new Error(
@@ -36354,7 +36271,7 @@ function isPathInside(target, root) {
36354
36271
  return normalizedTarget === resolve(root) || normalizedTarget.startsWith(normalizedRoot);
36355
36272
  }
36356
36273
  function redactAugmentedPaths(msg) {
36357
- const homePrefix = homedir4().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36274
+ const homePrefix = homedir3().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36358
36275
  return msg.replaceAll(
36359
36276
  new RegExp(`${homePrefix}[\\\\/]\\.augmented(?:[\\\\/][^\\s'"\`]*)*`, "g"),
36360
36277
  "<augmented-path>"
@@ -36804,15 +36721,15 @@ function emitToolCallMarkupRedactionTelemetry(channel) {
36804
36721
  }
36805
36722
 
36806
36723
  // 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";
36724
+ import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync } from "fs";
36725
+ import { homedir as homedir4 } from "os";
36726
+ import { join as join6 } from "path";
36810
36727
  var DEFAULT_WATCH_MS = 5e3;
36811
36728
  var DEFAULT_POLL_MS = 400;
36812
36729
  function agentTranscriptDir(opts) {
36813
36730
  const cwd = opts?.cwd ?? process.cwd();
36814
- const home = opts?.home ?? homedir5();
36815
- return join7(home, ".claude", "projects", encodeClaudeProjectPath(cwd));
36731
+ const home = opts?.home ?? homedir4();
36732
+ return join6(home, ".claude", "projects", encodeClaudeProjectPath(cwd));
36816
36733
  }
36817
36734
  function classifyTranscriptSince(opts) {
36818
36735
  const dir = opts.transcriptDir ?? agentTranscriptDir({ cwd: opts.cwd, home: opts.home });
@@ -36825,7 +36742,7 @@ function classifyTranscriptSince(opts) {
36825
36742
  let newest = UNKNOWN_RATE_LIMIT;
36826
36743
  for (const name of entries) {
36827
36744
  if (!name.endsWith(".jsonl")) continue;
36828
- const path = join7(dir, name);
36745
+ const path = join6(dir, name);
36829
36746
  try {
36830
36747
  const st = statSync(path);
36831
36748
  if (!st.isFile() || st.mtimeMs < opts.sinceMs) continue;
@@ -36834,7 +36751,7 @@ function classifyTranscriptSince(opts) {
36834
36751
  }
36835
36752
  let content;
36836
36753
  try {
36837
- content = readFileSync6(path, "utf-8");
36754
+ content = readFileSync5(path, "utf-8");
36838
36755
  } catch {
36839
36756
  continue;
36840
36757
  }
@@ -36873,8 +36790,8 @@ async function watchForRateLimitRefusal(opts) {
36873
36790
  }
36874
36791
 
36875
36792
  // 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";
36793
+ import { readFileSync as readFileSync6, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
36794
+ import { join as join7 } from "path";
36878
36795
  function turnFailureNoticeEnabled(env2) {
36879
36796
  return resolveHostBooleanFlag({
36880
36797
  key: "wedge-transient-notice",
@@ -36903,7 +36820,7 @@ function classifyTurnFailureSince(opts) {
36903
36820
  const unrecognised = /* @__PURE__ */ new Set();
36904
36821
  for (const name of entries) {
36905
36822
  if (!name.endsWith(".jsonl")) continue;
36906
- const path = join8(dir, name);
36823
+ const path = join7(dir, name);
36907
36824
  let fingerprint;
36908
36825
  try {
36909
36826
  const st = statSync2(path);
@@ -36919,7 +36836,7 @@ function classifyTurnFailureSince(opts) {
36919
36836
  } else {
36920
36837
  let content;
36921
36838
  try {
36922
- content = readFileSync7(path, "utf-8");
36839
+ content = readFileSync6(path, "utf-8");
36923
36840
  } catch {
36924
36841
  continue;
36925
36842
  }
@@ -37017,19 +36934,14 @@ async function watchForTurnFailure(opts) {
37017
36934
 
37018
36935
  // src/usage-limit-reactive-decision.ts
37019
36936
  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;
36937
+ function shouldArmWatch(opts) {
36938
+ return !opts.isBot && opts.replyOwed;
37027
36939
  }
37028
36940
  function decideRefusalAction(opts) {
37029
36941
  const { refusal } = opts;
37030
36942
  if (!refusal || refusal.verdict !== "capped") return "none";
37031
36943
  if (!refusal.resetsAt) return "missing-reset";
37032
- return opts.mode === "shadow" ? "shadow-log" : "notify";
36944
+ return "notify";
37033
36945
  }
37034
36946
  function describeUnparsedRefusal(text) {
37035
36947
  if (!text) return "refusal=absent";
@@ -37040,8 +36952,8 @@ function describeUnparsedRefusal(text) {
37040
36952
  // src/reply-intent-runtime.ts
37041
36953
  import { execFile as execFile2 } from "child_process";
37042
36954
  import { existsSync as existsSync3, mkdirSync, writeFileSync as writeFileSync2 } from "fs";
37043
- import { homedir as homedir6 } from "os";
37044
- import { join as join9 } from "path";
36955
+ import { homedir as homedir5 } from "os";
36956
+ import { join as join8 } from "path";
37045
36957
  var DEFAULT_CLAUDE_EVAL_MODEL = "claude-haiku-4-5-20251001";
37046
36958
  var DEFAULT_ANTHROPIC_MESSAGES_URL = "https://api.anthropic.com/v1/messages";
37047
36959
  var ANTHROPIC_API_VERSION = "2023-06-01";
@@ -37140,12 +37052,12 @@ async function runAnthropicMessages(prompt, opts) {
37140
37052
  var emptyMcpConfigPath = null;
37141
37053
  function ensureEmptyMcpConfig() {
37142
37054
  if (emptyMcpConfigPath && existsSync3(emptyMcpConfigPath)) return emptyMcpConfigPath;
37143
- const dir = join9(homedir6(), ".augmented");
37055
+ const dir = join8(homedir5(), ".augmented");
37144
37056
  try {
37145
37057
  mkdirSync(dir, { recursive: true });
37146
37058
  } catch {
37147
37059
  }
37148
- const p2 = join9(dir, ".reply-intent-empty-mcp.json");
37060
+ const p2 = join8(dir, ".reply-intent-empty-mcp.json");
37149
37061
  writeFileSync2(p2, JSON.stringify({ mcpServers: {} }));
37150
37062
  emptyMcpConfigPath = p2;
37151
37063
  return p2;
@@ -37170,7 +37082,7 @@ function runClaudeP(prompt, model) {
37170
37082
  execFile2(
37171
37083
  "claude",
37172
37084
  args,
37173
- { cwd: homedir6(), timeout: CLASSIFY_TIMEOUT_MS, maxBuffer: 1 << 20 },
37085
+ { cwd: homedir5(), timeout: CLASSIFY_TIMEOUT_MS, maxBuffer: 1 << 20 },
37174
37086
  (err, stdout) => {
37175
37087
  if (err) {
37176
37088
  reject(err);
@@ -37324,7 +37236,7 @@ function emitUrlAsteriskStripTelemetry(channel, count = 0) {
37324
37236
 
37325
37237
  // src/slack-pending-inbound-cleanup.ts
37326
37238
  import { existsSync as existsSync4, readdirSync as readdirSync4, statSync as statSync3, unlinkSync } from "fs";
37327
- import { join as join10 } from "path";
37239
+ import { join as join9 } from "path";
37328
37240
  function sanitizeMarkerSegment(value) {
37329
37241
  return value.replace(/[^A-Za-z0-9_-]/g, "_");
37330
37242
  }
@@ -37340,7 +37252,7 @@ function applyToMatchingMarkers(dir, prefix, suffix, op) {
37340
37252
  try {
37341
37253
  for (const f of readdirSync4(dir)) {
37342
37254
  if (!f.startsWith(prefix) || !f.endsWith(suffix)) continue;
37343
- op(join10(dir, f));
37255
+ op(join9(dir, f));
37344
37256
  applied += 1;
37345
37257
  }
37346
37258
  } catch {
@@ -37370,7 +37282,7 @@ function clearOldestSlackPendingMarkerInChannel(dir, channel, clear = defaultCle
37370
37282
  const channelPrefix = `${sanitizeMarkerSegment(channel)}__`;
37371
37283
  try {
37372
37284
  const entries = readdirSync4(dir).filter((f) => f.startsWith(channelPrefix) && f.endsWith(".json")).map((f) => {
37373
- const full = join10(dir, f);
37285
+ const full = join9(dir, f);
37374
37286
  let mtime = 0;
37375
37287
  try {
37376
37288
  mtime = statSync3(full).mtimeMs;
@@ -37413,12 +37325,12 @@ function describePromiseStampOutcome(tally, replyToolName) {
37413
37325
 
37414
37326
  // src/recovery-ledger.ts
37415
37327
  import { existsSync as existsSync5, unlinkSync as unlinkSync2 } from "fs";
37416
- import { join as join11 } from "path";
37328
+ import { join as join10 } from "path";
37417
37329
  function recoveryLedgerEntryExists(ledgerDir, markerName, exists = (p2) => existsSync5(p2)) {
37418
37330
  if (!ledgerDir || !markerName) return false;
37419
37331
  if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return false;
37420
37332
  try {
37421
- return exists(join11(ledgerDir, markerName));
37333
+ return exists(join10(ledgerDir, markerName));
37422
37334
  } catch {
37423
37335
  return false;
37424
37336
  }
@@ -37429,7 +37341,7 @@ function removeRecoveryLedgerEntry(ledgerDir, markerName, unlink = (p2) => {
37429
37341
  if (!ledgerDir || !markerName) return;
37430
37342
  if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
37431
37343
  try {
37432
- unlink(join11(ledgerDir, markerName));
37344
+ unlink(join10(ledgerDir, markerName));
37433
37345
  } catch {
37434
37346
  }
37435
37347
  }
@@ -37666,18 +37578,18 @@ function applyHotThreadGuard(input) {
37666
37578
  }
37667
37579
 
37668
37580
  // src/slack-hot-thread-telemetry.ts
37669
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync3 } from "fs";
37670
- import { join as join12 } from "path";
37581
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync3 } from "fs";
37582
+ import { join as join11 } from "path";
37671
37583
  var HOT_THREAD_CLASSIFICATION_COUNTER_SUFFIX = "-hot-thread-classifications.json";
37672
37584
  function hotThreadKey(mode, outcome, proactive) {
37673
37585
  return `${mode}|${outcome}|${proactive ? "true" : "false"}`;
37674
37586
  }
37675
37587
  function recordHotThreadClassification(agentDir, channel, classification) {
37676
37588
  if (!agentDir || !channel) return;
37677
- const path = join12(agentDir, `${channel}${HOT_THREAD_CLASSIFICATION_COUNTER_SUFFIX}`);
37589
+ const path = join11(agentDir, `${channel}${HOT_THREAD_CLASSIFICATION_COUNTER_SUFFIX}`);
37678
37590
  let counts = {};
37679
37591
  try {
37680
- const parsed = JSON.parse(readFileSync8(path, "utf-8"));
37592
+ const parsed = JSON.parse(readFileSync7(path, "utf-8"));
37681
37593
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
37682
37594
  for (const [k, v] of Object.entries(parsed)) {
37683
37595
  if (typeof v === "number" && Number.isInteger(v) && v >= 0) counts[k] = v;
@@ -37694,7 +37606,7 @@ function recordHotThreadClassification(agentDir, channel, classification) {
37694
37606
  }
37695
37607
 
37696
37608
  // src/restart-confirm.ts
37697
- import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync9, renameSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync4 } from "fs";
37609
+ import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync8, renameSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync4 } from "fs";
37698
37610
  import { dirname } from "path";
37699
37611
  import { randomUUID } from "crypto";
37700
37612
  var RESTART_CONFIRM_MAX_AGE_MS = 10 * 60 * 1e3;
@@ -37720,7 +37632,7 @@ function writeRestartConfirmMarker(filePath, marker) {
37720
37632
  function readRestartConfirmMarker(filePath) {
37721
37633
  try {
37722
37634
  if (!existsSync6(filePath)) return null;
37723
- const parsed = JSON.parse(readFileSync9(filePath, "utf8"));
37635
+ const parsed = JSON.parse(readFileSync8(filePath, "utf8"));
37724
37636
  if (!parsed || typeof parsed !== "object") return null;
37725
37637
  return parsed;
37726
37638
  } catch {
@@ -37865,7 +37777,7 @@ import {
37865
37777
  ftruncateSync,
37866
37778
  mkdirSync as mkdirSync9,
37867
37779
  openSync,
37868
- readFileSync as readFileSync21,
37780
+ readFileSync as readFileSync20,
37869
37781
  readdirSync as readdirSync7,
37870
37782
  renameSync as renameSync5,
37871
37783
  statSync as statSync5,
@@ -37874,12 +37786,12 @@ import {
37874
37786
  writeFileSync as writeFileSync14,
37875
37787
  writeSync
37876
37788
  } from "fs";
37877
- import { basename, join as join21, resolve as resolve2 } from "path";
37878
- import { homedir as homedir7 } from "os";
37789
+ import { basename, join as join20, resolve as resolve2 } from "path";
37790
+ import { homedir as homedir6 } from "os";
37879
37791
  import { createHash as createHash3, randomUUID as randomUUID2 } from "crypto";
37880
37792
 
37881
37793
  // src/slack-thread-store.ts
37882
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
37794
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
37883
37795
  import { dirname as dirname2 } from "path";
37884
37796
  function isParticipatingThread(entry) {
37885
37797
  if (!entry) return false;
@@ -37894,7 +37806,7 @@ function loadThreadStore(filePath, opts = {}) {
37894
37806
  const ttlMs = ttlDays * 24 * 60 * 60 * 1e3;
37895
37807
  let raw;
37896
37808
  try {
37897
- raw = readFileSync10(filePath, "utf-8");
37809
+ raw = readFileSync9(filePath, "utf-8");
37898
37810
  } catch {
37899
37811
  return { threads: /* @__PURE__ */ new Map(), pruned: 0 };
37900
37812
  }
@@ -37995,7 +37907,7 @@ function isThreadEntry(value) {
37995
37907
  }
37996
37908
 
37997
37909
  // src/dm-restart-notice.ts
37998
- import { mkdirSync as mkdirSync4, readFileSync as readFileSync11, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
37910
+ import { mkdirSync as mkdirSync4, readFileSync as readFileSync10, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
37999
37911
  import { dirname as dirname3 } from "path";
38000
37912
  var RECENT_DM_VERSION = 1;
38001
37913
  var DEFAULT_RECENT_DM_TTL_MS = 30 * 60 * 1e3;
@@ -38019,7 +37931,7 @@ function loadRecentDms(filePath, opts = {}) {
38019
37931
  const ttlMs = opts.ttlMs ?? DEFAULT_RECENT_DM_TTL_MS;
38020
37932
  let raw;
38021
37933
  try {
38022
- raw = readFileSync11(filePath, "utf-8");
37934
+ raw = readFileSync10(filePath, "utf-8");
38023
37935
  } catch (err) {
38024
37936
  const code = err.code;
38025
37937
  if (code !== "ENOENT") {
@@ -38104,7 +38016,7 @@ var CHANNEL_ADD_RESTART_MAX_AGE_MS = 15 * 60 * 1e3;
38104
38016
  function readChannelAddRestartMarker(filePath) {
38105
38017
  let raw;
38106
38018
  try {
38107
- raw = readFileSync11(filePath, "utf-8");
38019
+ raw = readFileSync10(filePath, "utf-8");
38108
38020
  } catch {
38109
38021
  return null;
38110
38022
  }
@@ -38162,13 +38074,13 @@ async function runOrRetry(fn, opts) {
38162
38074
  }
38163
38075
 
38164
38076
  // 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";
38077
+ import { writeFileSync as writeFileSync7, readFileSync as readFileSync11, mkdirSync as mkdirSync5, renameSync as renameSync2 } from "fs";
38078
+ import { dirname as dirname4, join as join12 } from "path";
38167
38079
  var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
38168
38080
  var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
38169
38081
  var TURN_INITIATOR_LEDGER_FILENAME = ".turn-initiator-ledger.json";
38170
38082
  function turnInitiatorLedgerPath(singleSlotFile) {
38171
- return join13(dirname4(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
38083
+ return join12(dirname4(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
38172
38084
  }
38173
38085
  function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX_AGE_MS, maxEntries = TURN_INITIATOR_LEDGER_MAX_ENTRIES) {
38174
38086
  const now = marker.ts;
@@ -38193,7 +38105,7 @@ function updateTurnInitiatorLedger(singleSlotFile, marker) {
38193
38105
  const ledgerFile = turnInitiatorLedgerPath(singleSlotFile);
38194
38106
  let existing = null;
38195
38107
  try {
38196
- const parsed = JSON.parse(readFileSync12(ledgerFile, "utf8"));
38108
+ const parsed = JSON.parse(readFileSync11(ledgerFile, "utf8"));
38197
38109
  if (parsed && parsed.v === 1 && Array.isArray(parsed.entries)) existing = parsed;
38198
38110
  } catch {
38199
38111
  }
@@ -38220,7 +38132,7 @@ function writeTurnInitiatorMarker(input) {
38220
38132
  }
38221
38133
 
38222
38134
  // src/slack-bot-photo.ts
38223
- import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync13, writeFileSync as writeFileSync8 } from "fs";
38135
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync12, writeFileSync as writeFileSync8 } from "fs";
38224
38136
  import { dirname as dirname5 } from "path";
38225
38137
  async function applyBotPhoto(opts) {
38226
38138
  const fetchImpl = opts.fetchImpl ?? fetch;
@@ -38230,7 +38142,7 @@ async function applyBotPhoto(opts) {
38230
38142
  const { token, avatarUrl, markerPath } = opts;
38231
38143
  if (markerPath && existsSync7(markerPath)) {
38232
38144
  try {
38233
- if (readFileSync13(markerPath, "utf-8").trim() === avatarUrl) {
38145
+ if (readFileSync12(markerPath, "utf-8").trim() === avatarUrl) {
38234
38146
  return { status: "skipped-unchanged" };
38235
38147
  }
38236
38148
  } catch {
@@ -38355,8 +38267,8 @@ function conversationalLaneMeta(expectsReply = true) {
38355
38267
  }
38356
38268
 
38357
38269
  // src/inbound-lane-telemetry.ts
38358
- import { readFileSync as readFileSync14, writeFileSync as writeFileSync9 } from "fs";
38359
- import { join as join14 } from "path";
38270
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync9 } from "fs";
38271
+ import { join as join13 } from "path";
38360
38272
  var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
38361
38273
  var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
38362
38274
  var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
@@ -38373,10 +38285,10 @@ function isSuspectedMisclassification(lane, source) {
38373
38285
  }
38374
38286
  function recordLaneClassification(agentDir, channel, classification) {
38375
38287
  if (!agentDir) return;
38376
- const path = join14(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
38288
+ const path = join13(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
38377
38289
  let counts = {};
38378
38290
  try {
38379
- const parsed = JSON.parse(readFileSync14(path, "utf-8"));
38291
+ const parsed = JSON.parse(readFileSync13(path, "utf-8"));
38380
38292
  if (parsed && typeof parsed === "object") counts = parsed;
38381
38293
  } catch {
38382
38294
  }
@@ -38392,8 +38304,8 @@ function recordLaneClassification(agentDir, channel, classification) {
38392
38304
  }
38393
38305
 
38394
38306
  // src/slack-inbound-registry.ts
38395
- import { readdirSync as readdirSync5, readFileSync as readFileSync15 } from "fs";
38396
- import { join as join15 } from "path";
38307
+ import { readdirSync as readdirSync5, readFileSync as readFileSync14 } from "fs";
38308
+ import { join as join14 } from "path";
38397
38309
  var DEFAULT_MAX_ENTRIES = 500;
38398
38310
  var DEFAULT_CLEARED_TTL_MS = 6 * 60 * 60 * 1e3;
38399
38311
  function entryKey(channel, messageTs) {
@@ -38514,7 +38426,7 @@ function createInboundRegistry(opts = {}) {
38514
38426
  if (name.includes(".retry-") || name.includes(".poison")) continue;
38515
38427
  let marker;
38516
38428
  try {
38517
- marker = JSON.parse(readFileSync15(join15(dir, name), "utf-8"));
38429
+ marker = JSON.parse(readFileSync14(join14(dir, name), "utf-8"));
38518
38430
  } catch {
38519
38431
  continue;
38520
38432
  }
@@ -38559,8 +38471,8 @@ function slackInboundId(channel, threadTs, messageTs) {
38559
38471
  }
38560
38472
 
38561
38473
  // 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";
38474
+ import { existsSync as existsSync8, mkdirSync as mkdirSync7, readdirSync as readdirSync6, readFileSync as readFileSync15, renameSync as renameSync3, writeFileSync as writeFileSync10 } from "fs";
38475
+ import { join as join15 } from "path";
38564
38476
  function safeInboundId(inboundId) {
38565
38477
  return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
38566
38478
  }
@@ -38569,7 +38481,7 @@ var defaultDeps = {
38569
38481
  writeFile: (path, data) => writeFileSync10(path, data, "utf8"),
38570
38482
  rename: (from, to) => renameSync3(from, to),
38571
38483
  readdir: (dir) => readdirSync6(dir),
38572
- readFile: (path) => readFileSync16(path, "utf8"),
38484
+ readFile: (path) => readFileSync15(path, "utf8"),
38573
38485
  exists: (path) => existsSync8(path)
38574
38486
  };
38575
38487
  function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
@@ -38578,7 +38490,7 @@ function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
38578
38490
  if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
38579
38491
  try {
38580
38492
  deps.mkdir(dir);
38581
- const final = join16(dir, `${safe}.json`);
38493
+ const final = join15(dir, `${safe}.json`);
38582
38494
  const tmp = `${final}.tmp`;
38583
38495
  deps.writeFile(tmp, JSON.stringify(record2));
38584
38496
  deps.rename(tmp, final);
@@ -38759,8 +38671,8 @@ function describeSendOutcome(dest) {
38759
38671
  }
38760
38672
 
38761
38673
  // src/slack-reply-binding-telemetry.ts
38762
- import { readFileSync as readFileSync17, writeFileSync as writeFileSync11 } from "fs";
38763
- import { join as join17 } from "path";
38674
+ import { readFileSync as readFileSync16, writeFileSync as writeFileSync11 } from "fs";
38675
+ import { join as join16 } from "path";
38764
38676
  var REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX = "-reply-binding-classifications.json";
38765
38677
  var UNKNOWN_INBOUND_ID_KEY = "unknown_inbound_id";
38766
38678
  var CHANNEL_MISTARGET_CORRECTED_KEY = "channel_mistarget_corrected";
@@ -38775,10 +38687,10 @@ function slackReplyBindingMode() {
38775
38687
  }
38776
38688
  function recordReplyBindingClassification(agentDir, channel, input) {
38777
38689
  if (!agentDir) return;
38778
- const path = join17(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38690
+ const path = join16(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38779
38691
  let counts = {};
38780
38692
  try {
38781
- const parsed = JSON.parse(readFileSync17(path, "utf-8"));
38693
+ const parsed = JSON.parse(readFileSync16(path, "utf-8"));
38782
38694
  if (parsed && typeof parsed === "object") counts = parsed;
38783
38695
  } catch {
38784
38696
  }
@@ -38793,10 +38705,10 @@ function recordReplyBindingClassification(agentDir, channel, input) {
38793
38705
  }
38794
38706
  function recordScheduledChannelOverride(agentDir, channel, input) {
38795
38707
  if (!agentDir) return;
38796
- const path = join17(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38708
+ const path = join16(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38797
38709
  let counts = {};
38798
38710
  try {
38799
- const parsed = JSON.parse(readFileSync17(path, "utf-8"));
38711
+ const parsed = JSON.parse(readFileSync16(path, "utf-8"));
38800
38712
  if (parsed && typeof parsed === "object") counts = parsed;
38801
38713
  } catch {
38802
38714
  }
@@ -38809,10 +38721,10 @@ function recordScheduledChannelOverride(agentDir, channel, input) {
38809
38721
  }
38810
38722
  function recordChannelMistarget(agentDir, channel, input) {
38811
38723
  if (!agentDir) return;
38812
- const path = join17(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38724
+ const path = join16(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
38813
38725
  let counts = {};
38814
38726
  try {
38815
- const parsed = JSON.parse(readFileSync17(path, "utf-8"));
38727
+ const parsed = JSON.parse(readFileSync16(path, "utf-8"));
38816
38728
  if (parsed && typeof parsed === "object") counts = parsed;
38817
38729
  } catch {
38818
38730
  }
@@ -38827,8 +38739,8 @@ function recordChannelMistarget(agentDir, channel, input) {
38827
38739
  }
38828
38740
 
38829
38741
  // src/slack-reply-target-telemetry.ts
38830
- import { readFileSync as readFileSync18, writeFileSync as writeFileSync12 } from "fs";
38831
- import { join as join18 } from "path";
38742
+ import { readFileSync as readFileSync17, writeFileSync as writeFileSync12 } from "fs";
38743
+ import { join as join17 } from "path";
38832
38744
  var REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX = "-reply-target-classifications.json";
38833
38745
  function pendingThreadsBucket(n) {
38834
38746
  if (n <= 0) return "0";
@@ -38861,10 +38773,10 @@ function classifyReplyTarget(input) {
38861
38773
  }
38862
38774
  function recordReplyTargetClassification(agentDir, channel, classification) {
38863
38775
  if (!agentDir) return;
38864
- const path = join18(agentDir, `${channel}${REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX}`);
38776
+ const path = join17(agentDir, `${channel}${REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX}`);
38865
38777
  let counts = {};
38866
38778
  try {
38867
- const parsed = JSON.parse(readFileSync18(path, "utf-8"));
38779
+ const parsed = JSON.parse(readFileSync17(path, "utf-8"));
38868
38780
  if (parsed && typeof parsed === "object") counts = parsed;
38869
38781
  } catch {
38870
38782
  }
@@ -38880,8 +38792,8 @@ function recordReplyTargetClassification(agentDir, channel, classification) {
38880
38792
  }
38881
38793
 
38882
38794
  // src/scheduled-turn-marker.ts
38883
- import { readFileSync as readFileSync19, unlinkSync as unlinkSync5 } from "fs";
38884
- import { join as join19 } from "path";
38795
+ import { readFileSync as readFileSync18, unlinkSync as unlinkSync5 } from "fs";
38796
+ import { join as join18 } from "path";
38885
38797
  var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
38886
38798
  var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
38887
38799
  function validateScheduledTurnMarker(raw, now, maxAgeMs = SCHEDULED_TURN_MAX_AGE_MS) {
@@ -38919,7 +38831,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
38919
38831
  if (!agentDir) return null;
38920
38832
  try {
38921
38833
  const raw = JSON.parse(
38922
- readFileSync19(join19(agentDir, SCHEDULED_TURN_MARKER_FILENAME2), "utf8")
38834
+ readFileSync18(join18(agentDir, SCHEDULED_TURN_MARKER_FILENAME2), "utf8")
38923
38835
  );
38924
38836
  return validateScheduledTurnMarker(raw, now);
38925
38837
  } catch {
@@ -38929,7 +38841,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
38929
38841
  function clearScheduledTurnMarker(agentDir) {
38930
38842
  if (!agentDir) return;
38931
38843
  try {
38932
- unlinkSync5(join19(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
38844
+ unlinkSync5(join18(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
38933
38845
  } catch {
38934
38846
  }
38935
38847
  }
@@ -39731,14 +39643,14 @@ async function actuateHostRestart(opts) {
39731
39643
  import {
39732
39644
  existsSync as existsSync9,
39733
39645
  mkdirSync as mkdirSync8,
39734
- readFileSync as readFileSync20,
39646
+ readFileSync as readFileSync19,
39735
39647
  renameSync as renameSync4,
39736
39648
  statSync as statSync4,
39737
39649
  unlinkSync as unlinkSync6,
39738
39650
  utimesSync,
39739
39651
  writeFileSync as writeFileSync13
39740
39652
  } from "fs";
39741
- import { join as join20 } from "path";
39653
+ import { join as join19 } from "path";
39742
39654
  var STALE_LOCK_MS = 9e4;
39743
39655
  var HEARTBEAT_INTERVAL_MS = 3e4;
39744
39656
  function defaultIsPidAlive(pid) {
@@ -39761,7 +39673,7 @@ function acquireMcpSpawnLock(args) {
39761
39673
  const nowMs = options.nowMs ?? (() => Date.now());
39762
39674
  const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
39763
39675
  const staleMs = options.staleMs ?? STALE_LOCK_MS;
39764
- const path = join20(agentDir, basename2);
39676
+ const path = join19(agentDir, basename2);
39765
39677
  const existing = readLockHolder(path);
39766
39678
  if (existing) {
39767
39679
  if (existing.pid === selfPid) {
@@ -39828,7 +39740,7 @@ function defaultLockMtimeMs(path) {
39828
39740
  function readLockHolder(path) {
39829
39741
  if (!existsSync9(path)) return null;
39830
39742
  try {
39831
- const raw = readFileSync20(path, "utf8");
39743
+ const raw = readFileSync19(path, "utf8");
39832
39744
  const parsed = JSON.parse(raw);
39833
39745
  const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
39834
39746
  if (!Number.isFinite(pid) || pid <= 0) return null;
@@ -40063,24 +39975,17 @@ function armSlackUsageLimitWatch(args) {
40063
39975
  void (async () => {
40064
39976
  try {
40065
39977
  const refusal = await watchForRateLimitRefusal({ sinceMs: args.sinceMs });
40066
- const action = decideRefusalAction({ mode: args.mode, refusal });
39978
+ const action = decideRefusalAction({ refusal });
40067
39979
  if (action === "none") return;
40068
39980
  if (action === "missing-reset") {
40069
39981
  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
39982
+ `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
39983
  `
40072
39984
  );
40073
39985
  return;
40074
39986
  }
40075
39987
  const resetsAt = refusal?.resetsAt;
40076
39988
  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
39989
  await maybeSendUsageLimitNotice({
40085
39990
  channel: args.channel,
40086
39991
  senderId: args.senderId,
@@ -40277,8 +40182,8 @@ var SLACK_TEAM_PEER_USER_IDS = parseTeamPeerUserIdsEnv(
40277
40182
  process.env.SLACK_TEAM_PEER_USER_IDS
40278
40183
  );
40279
40184
  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;
40185
+ var SLACK_AGENT_DIR = AGENT_CODE_NAME ? join20(homedir6(), ".augmented", AGENT_CODE_NAME) : null;
40186
+ var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "project", ".mcp.json") : null;
40282
40187
  var liveAllowedUsersCache = null;
40283
40188
  function readLiveAllowedUsers() {
40284
40189
  if (!SLACK_MCP_CONFIG_PATH) return null;
@@ -40288,7 +40193,7 @@ function readLiveAllowedUsers() {
40288
40193
  return liveAllowedUsersCache.value;
40289
40194
  }
40290
40195
  const value = extractAllowedUsersFromMcpJson(
40291
- readFileSync21(SLACK_MCP_CONFIG_PATH, "utf-8")
40196
+ readFileSync20(SLACK_MCP_CONFIG_PATH, "utf-8")
40292
40197
  );
40293
40198
  if (value === null) return null;
40294
40199
  liveAllowedUsersCache = { mtimeMs, value };
@@ -40309,7 +40214,7 @@ function readLivePingAllowedUsers() {
40309
40214
  return livePingAllowedUsersCache.value;
40310
40215
  }
40311
40216
  const value = extractPingAllowedUsersFromMcpJson(
40312
- readFileSync21(SLACK_MCP_CONFIG_PATH, "utf-8")
40217
+ readFileSync20(SLACK_MCP_CONFIG_PATH, "utf-8")
40313
40218
  );
40314
40219
  if (value === null) return null;
40315
40220
  livePingAllowedUsersCache = { mtimeMs, value };
@@ -40321,17 +40226,17 @@ function readLivePingAllowedUsers() {
40321
40226
  function getEffectivePingAllowedUsers() {
40322
40227
  return readLivePingAllowedUsers() ?? PING_ALLOWED_USERS;
40323
40228
  }
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;
40229
+ var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-pending-inbound") : null;
40230
+ var SLACK_RESTART_CONTEXT_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-restart-context") : null;
40231
+ var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-recovery-outbox") : null;
40232
+ var SLACK_RECOVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, ".agt-slack-recovery-ledger") : null;
40233
+ var SLACK_DELIVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
40329
40234
  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;
40235
+ var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-restart-confirm.json") : null;
40236
+ var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-recent-dms.json") : null;
40237
+ var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-channel-add-restart.json") : null;
40333
40238
  var SLACK_MAX_RECOVERY_ATTEMPTS = 3;
40334
- var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
40239
+ var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
40335
40240
  function redactSlackId(id) {
40336
40241
  if (!id) return "<none>";
40337
40242
  return createHash3("sha256").update(id).digest("hex").slice(0, 8);
@@ -40342,7 +40247,7 @@ function safeSlackMarkerName(channel, threadTs, messageTs) {
40342
40247
  }
40343
40248
  function slackPendingInboundPath(channel, threadTs, messageTs) {
40344
40249
  if (!SLACK_PENDING_INBOUND_DIR) return null;
40345
- return join21(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
40250
+ return join20(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
40346
40251
  }
40347
40252
  function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undeliverable = false, discretionary = false, payload) {
40348
40253
  const path = slackPendingInboundPath(channel, threadTs, messageTs);
@@ -40399,7 +40304,7 @@ function markSlackMarkerPromisedInPlace(fullPath) {
40399
40304
  function markSlackMarkerEngagedInPlace(fullPath, opts) {
40400
40305
  let marker;
40401
40306
  try {
40402
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
40307
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
40403
40308
  } catch {
40404
40309
  return false;
40405
40310
  }
@@ -40414,7 +40319,7 @@ function markSlackMarkerEngagedInPlace(fullPath, opts) {
40414
40319
  rewriteSlackMarkerInPlace(fullPath, marker);
40415
40320
  if (!opts.promise) return false;
40416
40321
  try {
40417
- const readBack = JSON.parse(readFileSync21(fullPath, "utf-8"));
40322
+ const readBack = JSON.parse(readFileSync20(fullPath, "utf-8"));
40418
40323
  return typeof readBack.promised_at === "string" && readBack.promised_at.length > 0;
40419
40324
  } catch {
40420
40325
  return false;
@@ -40425,7 +40330,7 @@ function attachSlackReplayPayload(channel, threadTs, messageTs, payload) {
40425
40330
  if (!path) return;
40426
40331
  let marker;
40427
40332
  try {
40428
- marker = JSON.parse(readFileSync21(path, "utf-8"));
40333
+ marker = JSON.parse(readFileSync20(path, "utf-8"));
40429
40334
  } catch {
40430
40335
  return;
40431
40336
  }
@@ -40436,7 +40341,7 @@ function readSlackPendingInboundMarker(channel, threadTs, messageTs) {
40436
40341
  const path = slackPendingInboundPath(channel, threadTs, messageTs);
40437
40342
  if (!path || !existsSync10(path)) return null;
40438
40343
  try {
40439
- return JSON.parse(readFileSync21(path, "utf-8"));
40344
+ return JSON.parse(readFileSync20(path, "utf-8"));
40440
40345
  } catch {
40441
40346
  return null;
40442
40347
  }
@@ -40552,7 +40457,7 @@ function scheduleBusyAck(channel, threadTs, messageTs, isThreadReply, arrivedWhi
40552
40457
  let paneLogFreshAgeMs = null;
40553
40458
  if (SLACK_AGENT_DIR) {
40554
40459
  try {
40555
- const paneMtimeMs = statSync5(join21(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
40460
+ const paneMtimeMs = statSync5(join20(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
40556
40461
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
40557
40462
  } catch {
40558
40463
  }
@@ -40585,7 +40490,7 @@ function __resetSlackBusyAckNoticeThrottle() {
40585
40490
  function clearSlackMarkerFileWithHeal(fullPath) {
40586
40491
  let marker = null;
40587
40492
  try {
40588
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
40493
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
40589
40494
  } catch {
40590
40495
  }
40591
40496
  if (marker && decideRecoveryHeal({
@@ -40612,7 +40517,7 @@ var slackPromiseStampOutcome = { attempted: 0, stamped: 0 };
40612
40517
  function healThenEngageSlackMarker(fullPath, opts) {
40613
40518
  let marker = null;
40614
40519
  try {
40615
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
40520
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
40616
40521
  } catch {
40617
40522
  return false;
40618
40523
  }
@@ -40697,10 +40602,10 @@ function slackNextRetryName(filename) {
40697
40602
  async function processSlackRecoveryOutboxFile(filename) {
40698
40603
  if (!SLACK_RECOVERY_OUTBOX_DIR) return;
40699
40604
  if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
40700
- const fullPath = join21(SLACK_RECOVERY_OUTBOX_DIR, filename);
40605
+ const fullPath = join20(SLACK_RECOVERY_OUTBOX_DIR, filename);
40701
40606
  let payload;
40702
40607
  try {
40703
- payload = JSON.parse(readFileSync21(fullPath, "utf-8"));
40608
+ payload = JSON.parse(readFileSync20(fullPath, "utf-8"));
40704
40609
  } catch (err) {
40705
40610
  process.stderr.write(
40706
40611
  `slack-channel(${AGENT_CODE_NAME}): recovery outbox parse failed (${filename}): ${err.message}
@@ -40806,7 +40711,7 @@ async function processSlackRecoveryOutboxFile(filename) {
40806
40711
  const next = slackNextRetryName(filename);
40807
40712
  if (next) {
40808
40713
  try {
40809
- renameSync5(fullPath, join21(SLACK_RECOVERY_OUTBOX_DIR, next.next));
40714
+ renameSync5(fullPath, join20(SLACK_RECOVERY_OUTBOX_DIR, next.next));
40810
40715
  if (next.attempt >= SLACK_MAX_RECOVERY_ATTEMPTS) {
40811
40716
  process.stderr.write(
40812
40717
  `slack-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
@@ -40846,7 +40751,7 @@ function scanSlackRecoveryRetries() {
40846
40751
  if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
40847
40752
  let mtimeMs;
40848
40753
  try {
40849
- mtimeMs = statSync5(join21(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
40754
+ mtimeMs = statSync5(join20(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
40850
40755
  } catch {
40851
40756
  continue;
40852
40757
  }
@@ -40876,7 +40781,7 @@ function startSlackRecoveryOutboxWatcher() {
40876
40781
  const watcher = watch(SLACK_RECOVERY_OUTBOX_DIR, (event, filename) => {
40877
40782
  if (event !== "rename" || !filename) return;
40878
40783
  if (!isFirstAttemptSlackOutboxFile(filename)) return;
40879
- if (existsSync10(join21(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
40784
+ if (existsSync10(join20(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
40880
40785
  void processSlackRecoveryOutboxFile(filename);
40881
40786
  }
40882
40787
  });
@@ -40891,7 +40796,7 @@ function startSlackRecoveryOutboxWatcher() {
40891
40796
  retryTimer.unref?.();
40892
40797
  }
40893
40798
  startSlackRecoveryOutboxWatcher();
40894
- var SLACK_NOTICE_OUTBOX_DIR = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "slack-notice-outbox") : null;
40799
+ var SLACK_NOTICE_OUTBOX_DIR = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "slack-notice-outbox") : null;
40895
40800
  var SLACK_NOTICE_MAX_AGE_MS = 9e4;
40896
40801
  var SLACK_NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
40897
40802
  async function processSlackNoticeOutboxFile(filename) {
@@ -40899,7 +40804,7 @@ async function processSlackNoticeOutboxFile(filename) {
40899
40804
  if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
40900
40805
  if (SLACK_NOTICE_INFLIGHT.has(filename)) return;
40901
40806
  SLACK_NOTICE_INFLIGHT.add(filename);
40902
- const fullPath = join21(SLACK_NOTICE_OUTBOX_DIR, filename);
40807
+ const fullPath = join20(SLACK_NOTICE_OUTBOX_DIR, filename);
40903
40808
  try {
40904
40809
  let mtimeMs;
40905
40810
  try {
@@ -40916,7 +40821,7 @@ async function processSlackNoticeOutboxFile(filename) {
40916
40821
  }
40917
40822
  let payload;
40918
40823
  try {
40919
- const parsed = JSON.parse(readFileSync21(fullPath, "utf-8"));
40824
+ const parsed = JSON.parse(readFileSync20(fullPath, "utf-8"));
40920
40825
  if (!parsed || typeof parsed !== "object") throw new Error("not an object");
40921
40826
  payload = parsed;
40922
40827
  } catch {
@@ -41005,7 +40910,7 @@ function startSlackNoticeOutboxWatcher() {
41005
40910
  try {
41006
40911
  const watcher = watch(SLACK_NOTICE_OUTBOX_DIR, (event, filename) => {
41007
40912
  if (event !== "rename" || !filename) return;
41008
- if (existsSync10(join21(SLACK_NOTICE_OUTBOX_DIR, filename))) {
40913
+ if (existsSync10(join20(SLACK_NOTICE_OUTBOX_DIR, filename))) {
41009
40914
  void processSlackNoticeOutboxFile(filename);
41010
40915
  }
41011
40916
  });
@@ -41042,10 +40947,10 @@ function sweepSlackStaleMarkers(thresholdMs) {
41042
40947
  for (const filename of filenames) {
41043
40948
  if (!filename.endsWith(".json")) continue;
41044
40949
  if (filename.endsWith(".tmp")) continue;
41045
- const fullPath = join21(SLACK_PENDING_INBOUND_DIR, filename);
40950
+ const fullPath = join20(SLACK_PENDING_INBOUND_DIR, filename);
41046
40951
  let marker;
41047
40952
  try {
41048
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
40953
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
41049
40954
  } catch (err) {
41050
40955
  process.stderr.write(
41051
40956
  `slack-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactSlackId(filename)}: ${err.message}
@@ -41103,13 +41008,13 @@ var slackOrphanSweepTimer = setInterval(() => {
41103
41008
  checkSlackWatchdogGiveUpNotice();
41104
41009
  }, orphanSweepIntervalMs());
41105
41010
  slackOrphanSweepTimer.unref?.();
41106
- var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ? join21(SLACK_AGENT_DIR, "channel-progress-heartbeat.json") : null;
41011
+ var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ? join20(SLACK_AGENT_DIR, "channel-progress-heartbeat.json") : null;
41107
41012
  var slackTrackedProgress = null;
41108
41013
  var slackProgressTickRunning = false;
41109
41014
  function readSlackProgressHeartbeat() {
41110
41015
  if (!SLACK_PROGRESS_HEARTBEAT_PATH || !existsSync10(SLACK_PROGRESS_HEARTBEAT_PATH)) return null;
41111
41016
  try {
41112
- return parseProgressHeartbeat(readFileSync21(SLACK_PROGRESS_HEARTBEAT_PATH, "utf-8"));
41017
+ return parseProgressHeartbeat(readFileSync20(SLACK_PROGRESS_HEARTBEAT_PATH, "utf-8"));
41113
41018
  } catch {
41114
41019
  return null;
41115
41020
  }
@@ -41136,7 +41041,7 @@ function findSlackProgressTarget() {
41136
41041
  if (!name.endsWith(".json")) continue;
41137
41042
  let m;
41138
41043
  try {
41139
- m = JSON.parse(readFileSync21(join21(SLACK_PENDING_INBOUND_DIR, name), "utf-8"));
41044
+ m = JSON.parse(readFileSync20(join20(SLACK_PENDING_INBOUND_DIR, name), "utf-8"));
41140
41045
  } catch {
41141
41046
  continue;
41142
41047
  }
@@ -41287,7 +41192,7 @@ function listPendingSlackConversations() {
41287
41192
  if (!name.endsWith(".json")) continue;
41288
41193
  try {
41289
41194
  const marker = JSON.parse(
41290
- readFileSync21(join21(SLACK_PENDING_INBOUND_DIR, name), "utf8")
41195
+ readFileSync20(join20(SLACK_PENDING_INBOUND_DIR, name), "utf8")
41291
41196
  );
41292
41197
  if (typeof marker.channel !== "string" || !marker.channel) continue;
41293
41198
  if (typeof marker.thread_ts !== "string" || !marker.thread_ts) continue;
@@ -41428,7 +41333,7 @@ function postSlackWatchdogGiveUpNotice(channel, threadTs, isThreadReply, reason)
41428
41333
  }
41429
41334
  function checkSlackWatchdogGiveUpNotice() {
41430
41335
  if (!SLACK_AGENT_DIR) return;
41431
- const signal = readGiveUpSignal(join21(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
41336
+ const signal = readGiveUpSignal(join20(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
41432
41337
  const signalAtMs = signal?.atMs ?? null;
41433
41338
  const act = decideGiveUpNotice({
41434
41339
  signalAtMs,
@@ -41460,7 +41365,7 @@ function readRestartTopicForMarker(filename, channel, threadTs) {
41460
41365
  if (!SLACK_RESTART_CONTEXT_DIR) return null;
41461
41366
  let raw;
41462
41367
  try {
41463
- raw = readFileSync21(join21(SLACK_RESTART_CONTEXT_DIR, filename), "utf-8");
41368
+ raw = readFileSync20(join20(SLACK_RESTART_CONTEXT_DIR, filename), "utf-8");
41464
41369
  } catch {
41465
41370
  return null;
41466
41371
  }
@@ -41469,7 +41374,7 @@ function readRestartTopicForMarker(filename, channel, threadTs) {
41469
41374
  function removeRestartContextHint(filename) {
41470
41375
  if (!SLACK_RESTART_CONTEXT_DIR) return;
41471
41376
  try {
41472
- unlinkSync7(join21(SLACK_RESTART_CONTEXT_DIR, filename));
41377
+ unlinkSync7(join20(SLACK_RESTART_CONTEXT_DIR, filename));
41473
41378
  } catch {
41474
41379
  }
41475
41380
  }
@@ -41484,7 +41389,7 @@ function clearAllRestartContextHints() {
41484
41389
  for (const name of names) {
41485
41390
  if (!name.endsWith(".json")) continue;
41486
41391
  try {
41487
- unlinkSync7(join21(SLACK_RESTART_CONTEXT_DIR, name));
41392
+ unlinkSync7(join20(SLACK_RESTART_CONTEXT_DIR, name));
41488
41393
  } catch {
41489
41394
  }
41490
41395
  }
@@ -41511,10 +41416,10 @@ async function notifyStrandedInboundsOnFirstConnect() {
41511
41416
  let notified = 0;
41512
41417
  for (const filename of filenames) {
41513
41418
  if (!filename.endsWith(".json")) continue;
41514
- const fullPath = join21(SLACK_PENDING_INBOUND_DIR, filename);
41419
+ const fullPath = join20(SLACK_PENDING_INBOUND_DIR, filename);
41515
41420
  let marker;
41516
41421
  try {
41517
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
41422
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
41518
41423
  } catch {
41519
41424
  continue;
41520
41425
  }
@@ -41688,7 +41593,7 @@ function noteThreadActivityByMessageTs(channel, messageTs) {
41688
41593
  markSeenAllSlackPendingMarkersForThread2(channel, messageTs);
41689
41594
  markSeenSlackPendingMarkerByMessageTs2(channel, messageTs);
41690
41595
  }
41691
- var RESTART_FLAGS_DIR = join21(homedir7(), ".augmented", "restart-flags");
41596
+ var RESTART_FLAGS_DIR = join20(homedir6(), ".augmented", "restart-flags");
41692
41597
  function actuateHostRestartSlack() {
41693
41598
  return actuateHostRestart({
41694
41599
  agtHost: AGT_HOST,
@@ -42293,7 +42198,7 @@ async function handleSlashCommandEnvelope(payload) {
42293
42198
  if (!existsSync10(RESTART_FLAGS_DIR)) {
42294
42199
  mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
42295
42200
  }
42296
- const flagPath = join21(RESTART_FLAGS_DIR, `${codeName}.flag`);
42201
+ const flagPath = join20(RESTART_FLAGS_DIR, `${codeName}.flag`);
42297
42202
  const flag = {
42298
42203
  codeName,
42299
42204
  source: "slack",
@@ -42436,7 +42341,7 @@ async function handleRestartCommand(opts) {
42436
42341
  if (!existsSync10(RESTART_FLAGS_DIR)) {
42437
42342
  mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
42438
42343
  }
42439
- const flagPath = join21(RESTART_FLAGS_DIR, `${codeName}.flag`);
42344
+ const flagPath = join20(RESTART_FLAGS_DIR, `${codeName}.flag`);
42440
42345
  const flag = {
42441
42346
  codeName,
42442
42347
  source: "slack",
@@ -42558,7 +42463,7 @@ var SLACK_HOT_THREAD_WINDOW_MS = parseHotThreadWindowMs(
42558
42463
  );
42559
42464
  function resolveThreadStorePath() {
42560
42465
  if (!AGENT_CODE_NAME) return null;
42561
- return join21(homedir7(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
42466
+ return join20(homedir6(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
42562
42467
  }
42563
42468
  function parseTtlDays(raw) {
42564
42469
  if (!raw) return void 0;
@@ -42597,9 +42502,9 @@ if (!BOT_TOKEN || !APP_TOKEN) {
42597
42502
  var slackStderrLogStream = null;
42598
42503
  if (AGENT_CODE_NAME) {
42599
42504
  try {
42600
- const logDir = join21(homedir7(), ".augmented", AGENT_CODE_NAME);
42505
+ const logDir = join20(homedir6(), ".augmented", AGENT_CODE_NAME);
42601
42506
  mkdirSync9(logDir, { recursive: true });
42602
- slackStderrLogStream = createWriteStream(join21(logDir, "slack-channel-stderr.log"), {
42507
+ slackStderrLogStream = createWriteStream(join20(logDir, "slack-channel-stderr.log"), {
42603
42508
  flags: "a",
42604
42509
  mode: 384
42605
42510
  });
@@ -43520,7 +43425,7 @@ ${result.formatted}` : "No messages in range, or the bot is not a member of this
43520
43425
  isError: true
43521
43426
  };
43522
43427
  }
43523
- const allowedRoot = resolve2(homedir7(), ".augmented", AGENT_CODE_NAME, "project") + "/";
43428
+ const allowedRoot = resolve2(homedir6(), ".augmented", AGENT_CODE_NAME, "project") + "/";
43524
43429
  const resolvedPath = resolve2(path);
43525
43430
  if (!resolvedPath.startsWith(allowedRoot)) {
43526
43431
  return {
@@ -43542,7 +43447,7 @@ ${result.formatted}` : "No messages in range, or the bot is not a member of this
43542
43447
  };
43543
43448
  }
43544
43449
  size = stat2.size;
43545
- bytes = readFileSync21(resolvedPath);
43450
+ bytes = readFileSync20(resolvedPath);
43546
43451
  } catch (err) {
43547
43452
  return {
43548
43453
  content: [{ type: "text", text: `Failed to read file: ${err.message}` }],
@@ -44197,7 +44102,7 @@ function isDownloadableFileId(fileId, channel) {
44197
44102
  }
44198
44103
  function redactAugmentedPaths2(msg) {
44199
44104
  return msg.replaceAll(
44200
- new RegExp(`${homedir7().replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}/\\.augmented/[^\\s'"\`]*`, "g"),
44105
+ new RegExp(`${homedir6().replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}/\\.augmented/[^\\s'"\`]*`, "g"),
44201
44106
  "<augmented-path>"
44202
44107
  );
44203
44108
  }
@@ -44325,7 +44230,7 @@ async function replayPendingSlackMarkers() {
44325
44230
  let paneFreshAgeMs = null;
44326
44231
  if (SLACK_AGENT_DIR) {
44327
44232
  try {
44328
- paneFreshAgeMs = Math.max(0, now - statSync5(join21(SLACK_AGENT_DIR, "pane.log")).mtimeMs);
44233
+ paneFreshAgeMs = Math.max(0, now - statSync5(join20(SLACK_AGENT_DIR, "pane.log")).mtimeMs);
44329
44234
  } catch {
44330
44235
  }
44331
44236
  }
@@ -44333,10 +44238,10 @@ async function replayPendingSlackMarkers() {
44333
44238
  const entries = [];
44334
44239
  for (const name of filenames) {
44335
44240
  if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
44336
- const fullPath = join21(SLACK_PENDING_INBOUND_DIR, name);
44241
+ const fullPath = join20(SLACK_PENDING_INBOUND_DIR, name);
44337
44242
  let marker;
44338
44243
  try {
44339
- marker = JSON.parse(readFileSync21(fullPath, "utf-8"));
44244
+ marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
44340
44245
  } catch {
44341
44246
  continue;
44342
44247
  }
@@ -44803,26 +44708,6 @@ async function connectSocketMode() {
44803
44708
  }).catch((err) => {
44804
44709
  process.stderr.write(
44805
44710
  `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
44711
  `
44827
44712
  );
44828
44713
  });
@@ -44934,7 +44819,7 @@ async function connectSocketMode() {
44934
44819
  let paneLogFreshAgeMs = null;
44935
44820
  if (SLACK_AGENT_DIR) {
44936
44821
  try {
44937
- const paneMtimeMs = statSync5(join21(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
44822
+ const paneMtimeMs = statSync5(join20(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
44938
44823
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
44939
44824
  } catch {
44940
44825
  }
@@ -45105,14 +44990,8 @@ ${forwarded.text}` : forwarded.text;
45105
44990
  method: "notifications/claude/channel",
45106
44991
  params: replayPayload
45107
44992
  });
45108
- const watchMode = armedWatchMode({
45109
- mode: reactiveMode,
45110
- isBot: isFromBot,
45111
- replyOwed: shouldEngage
45112
- });
45113
- if (watchMode) {
44993
+ if (shouldArmWatch({ isBot: isFromBot, replyOwed: shouldEngage })) {
45114
44994
  armSlackUsageLimitWatch({
45115
- mode: watchMode,
45116
44995
  channel,
45117
44996
  senderId: evt.user,
45118
44997
  threadTs,