@integrity-labs/agt-cli 0.28.1267 → 0.28.1269

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.
Files changed (33) hide show
  1. package/dist/{api-client-NGXHG4YA.js → api-client-54VZB3MY.js} +3 -3
  2. package/dist/bin/agt.js +7 -7
  3. package/dist/{chunk-UA2UPXYC.js → chunk-BM4Q7VW6.js} +86 -4
  4. package/dist/chunk-BM4Q7VW6.js.map +1 -0
  5. package/dist/{chunk-DCI6M6TF.js → chunk-ES3U3RIS.js} +3 -3
  6. package/dist/{chunk-BMO6GCK2.js → chunk-GLIROXKE.js} +2 -2
  7. package/dist/{chunk-W2GHPRPZ.js → chunk-LTQTHV7E.js} +1 -1
  8. package/dist/chunk-LTQTHV7E.js.map +1 -0
  9. package/dist/{chunk-X2FBQPNR.js → chunk-RNA2BFCX.js} +2 -2
  10. package/dist/{chunk-SR72T5SB.js → chunk-YB4W3NF3.js} +5 -5
  11. package/dist/{claude-code-updater-XISTQTZX.js → claude-code-updater-OHXLB7WR.js} +3 -3
  12. package/dist/{claude-pair-runtime-ASGVKZ5N.js → claude-pair-runtime-XTRWHN5Q.js} +3 -3
  13. package/dist/lib/manager-worker.js +461 -192
  14. package/dist/lib/manager-worker.js.map +1 -1
  15. package/dist/mcp/direct-chat-channel.js +178 -127
  16. package/dist/mcp/slack-channel.js +6 -1
  17. package/dist/mcp/telegram-channel.js +6 -1
  18. package/dist/{persistent-session-FMY2FZEL.js → persistent-session-MX6UHWLR.js} +18 -4
  19. package/dist/{responsiveness-probe-26TFNDWB.js → responsiveness-probe-GXI34QDS.js} +4 -4
  20. package/dist/{session-auth-dead-U62KZ342.js → session-auth-dead-UM6LYQ2W.js} +3 -3
  21. package/package.json +1 -1
  22. package/dist/chunk-UA2UPXYC.js.map +0 -1
  23. package/dist/chunk-W2GHPRPZ.js.map +0 -1
  24. /package/dist/{api-client-NGXHG4YA.js.map → api-client-54VZB3MY.js.map} +0 -0
  25. /package/dist/{chunk-DCI6M6TF.js.map → chunk-ES3U3RIS.js.map} +0 -0
  26. /package/dist/{chunk-BMO6GCK2.js.map → chunk-GLIROXKE.js.map} +0 -0
  27. /package/dist/{chunk-X2FBQPNR.js.map → chunk-RNA2BFCX.js.map} +0 -0
  28. /package/dist/{chunk-SR72T5SB.js.map → chunk-YB4W3NF3.js.map} +0 -0
  29. /package/dist/{claude-code-updater-XISTQTZX.js.map → claude-code-updater-OHXLB7WR.js.map} +0 -0
  30. /package/dist/{claude-pair-runtime-ASGVKZ5N.js.map → claude-pair-runtime-XTRWHN5Q.js.map} +0 -0
  31. /package/dist/{persistent-session-FMY2FZEL.js.map → persistent-session-MX6UHWLR.js.map} +0 -0
  32. /package/dist/{responsiveness-probe-26TFNDWB.js.map → responsiveness-probe-GXI34QDS.js.map} +0 -0
  33. /package/dist/{session-auth-dead-U62KZ342.js.map → session-auth-dead-UM6LYQ2W.js.map} +0 -0
@@ -18867,7 +18867,7 @@ var require_filters = __commonJS({
18867
18867
  return r.copySafeness(str2, res);
18868
18868
  }
18869
18869
  _exports.indent = indent;
18870
- function join19(arr, del, attr) {
18870
+ function join20(arr, del, attr) {
18871
18871
  del = del || "";
18872
18872
  if (attr) {
18873
18873
  arr = lib.map(arr, function(v) {
@@ -18876,7 +18876,7 @@ var require_filters = __commonJS({
18876
18876
  }
18877
18877
  return arr.join(del);
18878
18878
  }
18879
- _exports.join = join19;
18879
+ _exports.join = join20;
18880
18880
  function last(arr) {
18881
18881
  return arr[arr.length - 1];
18882
18882
  }
@@ -28844,6 +28844,40 @@ var require_lib3 = __commonJS({
28844
28844
  }
28845
28845
  });
28846
28846
 
28847
+ // ../core/dist/runtime/direct-chat-inflight.js
28848
+ import { renameSync, readFileSync, writeFileSync } from "fs";
28849
+ import { join } from "path";
28850
+ var DIRECT_CHAT_INFLIGHT_FILE = "direct-chat-inflight.json";
28851
+ var DIRECT_CHAT_INFLIGHT_MAX_AGE_MS = 5 * 6e4;
28852
+ function directChatInflightPath(agentDir) {
28853
+ return join(agentDir, DIRECT_CHAT_INFLIGHT_FILE);
28854
+ }
28855
+ function buildDirectChatInflightMarker(claims, pid) {
28856
+ if (claims.length === 0)
28857
+ return { ids: [], since_ms: 0, pid };
28858
+ return {
28859
+ ids: claims.map((c) => c.message_id),
28860
+ since_ms: Math.max(...claims.map((c) => c.claimed_at_ms)),
28861
+ pid
28862
+ };
28863
+ }
28864
+ function writeDirectChatInflightMarker(path, marker, fs = { writeFileSync, renameSync }) {
28865
+ const tmp = `${path}.${process.pid}.tmp`;
28866
+ try {
28867
+ fs.writeFileSync(tmp, JSON.stringify(marker), { mode: 384 });
28868
+ fs.renameSync(tmp, path);
28869
+ return true;
28870
+ } catch {
28871
+ return false;
28872
+ }
28873
+ }
28874
+ function publishDirectChatClaimsChange(snapshot, deps) {
28875
+ deps.saveClaims(snapshot);
28876
+ if (deps.inflightPath) {
28877
+ (deps.write ?? writeDirectChatInflightMarker)(deps.inflightPath, buildDirectChatInflightMarker(snapshot, deps.pid));
28878
+ }
28879
+ }
28880
+
28847
28881
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js
28848
28882
  var NEVER = Object.freeze({
28849
28883
  status: "aborted"
@@ -36458,8 +36492,8 @@ var DirectChatClaimTracker = class {
36458
36492
  };
36459
36493
 
36460
36494
  // src/direct-chat-rehand.ts
36461
- import { readFileSync } from "fs";
36462
- import { join } from "path";
36495
+ import { readFileSync as readFileSync2 } from "fs";
36496
+ import { join as join2 } from "path";
36463
36497
  var MARKER = /message_id="([^"]+)"/g;
36464
36498
  function collectStrings(v, out) {
36465
36499
  if (typeof v === "string") out.push(v);
@@ -36504,9 +36538,9 @@ function planRehand(claims, transcriptText, sessionStartedAtMs) {
36504
36538
  };
36505
36539
  }
36506
36540
  function transcriptPathFor(transcriptDir, transcriptId) {
36507
- return join(transcriptDir, `${transcriptId}.jsonl`);
36541
+ return join2(transcriptDir, `${transcriptId}.jsonl`);
36508
36542
  }
36509
- function readTranscriptText(path, read = (p2) => readFileSync(p2, "utf8")) {
36543
+ function readTranscriptText(path, read = (p2) => readFileSync2(p2, "utf8")) {
36510
36544
  try {
36511
36545
  return read(path);
36512
36546
  } catch {
@@ -36548,7 +36582,7 @@ function rehandSummaryLine(restored, plan, returned) {
36548
36582
  // src/rate-limit-watch.ts
36549
36583
  import { closeSync, fstatSync, openSync, readSync, readdirSync, statSync } from "fs";
36550
36584
  import { homedir } from "os";
36551
- import { join as join2 } from "path";
36585
+ import { join as join3 } from "path";
36552
36586
 
36553
36587
  // ../core/dist/types/agent.js
36554
36588
  var FRAMEWORK_MODEL_SLOTS = {
@@ -47719,7 +47753,7 @@ function oldestTimestampMs(text) {
47719
47753
  function agentTranscriptDir(opts) {
47720
47754
  const cwd = opts?.cwd ?? process.cwd();
47721
47755
  const home = opts?.home ?? homedir();
47722
- return join2(home, ".claude", "projects", encodeClaudeProjectPath(cwd));
47756
+ return join3(home, ".claude", "projects", encodeClaudeProjectPath(cwd));
47723
47757
  }
47724
47758
  function classifyTranscriptSince(opts) {
47725
47759
  const dir = opts.transcriptDir ?? agentTranscriptDir({ cwd: opts.cwd, home: opts.home });
@@ -47732,7 +47766,7 @@ function classifyTranscriptSince(opts) {
47732
47766
  let newest = UNKNOWN_RATE_LIMIT;
47733
47767
  for (const name of entries) {
47734
47768
  if (!name.endsWith(".jsonl")) continue;
47735
- const path = join2(dir, name);
47769
+ const path = join3(dir, name);
47736
47770
  try {
47737
47771
  const st = statSync(path);
47738
47772
  if (!st.isFile() || st.mtimeMs < opts.sinceMs) continue;
@@ -47778,21 +47812,21 @@ async function watchForRateLimitRefusal(opts) {
47778
47812
  }
47779
47813
 
47780
47814
  // src/direct-chat-claim-store.ts
47781
- import { mkdirSync, readFileSync as readFileSync2, renameSync, writeFileSync } from "fs";
47782
- import { dirname, join as join3 } from "path";
47815
+ import { mkdirSync, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "fs";
47816
+ import { dirname, join as join4 } from "path";
47783
47817
  var DIRECT_CHAT_CLAIMS_FILE = "direct-chat-claims.json";
47784
47818
  var DEFAULT_CLAIM_MAX_AGE_MS = 6 * 60 * 60 * 1e3;
47785
47819
  var DEFAULT_CLAIM_MAX_ENTRIES = 1e3;
47786
47820
  var realFs = {
47787
- readFile: (p2) => readFileSync2(p2, "utf8"),
47788
- writeFile: (p2, d) => writeFileSync(p2, d, "utf8"),
47789
- rename: (a, b) => renameSync(a, b),
47821
+ readFile: (p2) => readFileSync3(p2, "utf8"),
47822
+ writeFile: (p2, d) => writeFileSync2(p2, d, "utf8"),
47823
+ rename: (a, b) => renameSync2(a, b),
47790
47824
  mkdir: (d) => {
47791
47825
  mkdirSync(d, { recursive: true });
47792
47826
  }
47793
47827
  };
47794
47828
  function directChatClaimsPath(dir) {
47795
- return dir ? join3(dir, DIRECT_CHAT_CLAIMS_FILE) : null;
47829
+ return dir ? join4(dir, DIRECT_CHAT_CLAIMS_FILE) : null;
47796
47830
  }
47797
47831
  function isEntry(v) {
47798
47832
  if (!v || typeof v !== "object") return false;
@@ -48036,14 +48070,14 @@ function renderHistoryResult(result, requestedNotices) {
48036
48070
  }
48037
48071
 
48038
48072
  // src/direct-chat-session-state.ts
48039
- import { existsSync, readFileSync as readFileSync3 } from "fs";
48040
- import { join as join4 } from "path";
48073
+ import { existsSync, readFileSync as readFileSync4 } from "fs";
48074
+ import { join as join5 } from "path";
48041
48075
  function readDirectChatSessionState(agentDir, nowMs) {
48042
- const path = join4(agentDir, "direct-chat-session.json");
48076
+ const path = join5(agentDir, "direct-chat-session.json");
48043
48077
  const fallback = { fresh: false, startedAtMs: nowMs, markerRead: false, sessionId: null };
48044
48078
  try {
48045
48079
  if (!existsSync(path)) return fallback;
48046
- const parsed = JSON.parse(readFileSync3(path, "utf8"));
48080
+ const parsed = JSON.parse(readFileSync4(path, "utf8"));
48047
48081
  if (!parsed || typeof parsed !== "object") return fallback;
48048
48082
  const o = parsed;
48049
48083
  const fresh = o.fresh === true;
@@ -48090,12 +48124,12 @@ function buildDirectChatChannelMeta(input) {
48090
48124
  }
48091
48125
 
48092
48126
  // src/turn-context.ts
48093
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync6 } from "fs";
48127
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync7 } from "fs";
48094
48128
  import { homedir as homedir2 } from "os";
48095
- import { dirname as dirname3, join as join8 } from "path";
48129
+ import { dirname as dirname3, join as join9 } from "path";
48096
48130
 
48097
48131
  // ../core/dist/provisioning/frameworks/claudecode/agent-dir-alias.js
48098
- import { isAbsolute, join as join5, relative, sep } from "path";
48132
+ import { isAbsolute, join as join6, relative, sep } from "path";
48099
48133
  var VALID_CODE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
48100
48134
  var VALID_AGENT_ID = /^[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}$/;
48101
48135
  var INITIATOR_BASENAME = ".current-turn-initiator.json";
@@ -48103,7 +48137,7 @@ function isSafeAgentSegment(segment) {
48103
48137
  return VALID_CODE_NAME.test(segment) || VALID_AGENT_ID.test(segment);
48104
48138
  }
48105
48139
  function initiatorDirSegment(initiatorFile, homeDir) {
48106
- const rel = relative(join5(homeDir, ".augmented"), initiatorFile);
48140
+ const rel = relative(join6(homeDir, ".augmented"), initiatorFile);
48107
48141
  if (!rel || isAbsolute(rel))
48108
48142
  return null;
48109
48143
  const parts = rel.split(sep);
@@ -48118,29 +48152,29 @@ function resolveAgentDirAlias(input) {
48118
48152
  const { codeName, turnInitiatorFile, agentId, homeDir } = input;
48119
48153
  const codeNameTrimmed = typeof codeName === "string" ? codeName.trim() : "";
48120
48154
  if (codeNameTrimmed && VALID_CODE_NAME.test(codeNameTrimmed)) {
48121
- return join5(homeDir, ".augmented", codeNameTrimmed);
48155
+ return join6(homeDir, ".augmented", codeNameTrimmed);
48122
48156
  }
48123
48157
  const initiator = typeof turnInitiatorFile === "string" ? turnInitiatorFile.trim() : "";
48124
48158
  if (initiator) {
48125
48159
  const segment = initiatorDirSegment(initiator, homeDir);
48126
48160
  if (segment)
48127
- return join5(homeDir, ".augmented", segment);
48161
+ return join6(homeDir, ".augmented", segment);
48128
48162
  }
48129
48163
  const agentIdTrimmed = typeof agentId === "string" ? agentId.trim() : "";
48130
48164
  if (agentIdTrimmed && VALID_AGENT_ID.test(agentIdTrimmed)) {
48131
- return join5(homeDir, ".augmented", agentIdTrimmed);
48165
+ return join6(homeDir, ".augmented", agentIdTrimmed);
48132
48166
  }
48133
48167
  return null;
48134
48168
  }
48135
48169
 
48136
48170
  // src/turn-initiator-marker.ts
48137
- import { writeFileSync as writeFileSync2, readFileSync as readFileSync4, mkdirSync as mkdirSync2, renameSync as renameSync2 } from "fs";
48138
- import { dirname as dirname2, join as join6 } from "path";
48171
+ import { writeFileSync as writeFileSync3, readFileSync as readFileSync5, mkdirSync as mkdirSync2, renameSync as renameSync3 } from "fs";
48172
+ import { dirname as dirname2, join as join7 } from "path";
48139
48173
  var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
48140
48174
  var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
48141
48175
  var TURN_INITIATOR_LEDGER_FILENAME = ".turn-initiator-ledger.json";
48142
48176
  function turnInitiatorLedgerPath(singleSlotFile) {
48143
- return join6(dirname2(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
48177
+ return join7(dirname2(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
48144
48178
  }
48145
48179
  function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX_AGE_MS, maxEntries = TURN_INITIATOR_LEDGER_MAX_ENTRIES) {
48146
48180
  const now = marker.ts;
@@ -48170,14 +48204,14 @@ function updateTurnInitiatorLedger(singleSlotFile, marker) {
48170
48204
  const ledgerFile = turnInitiatorLedgerPath(singleSlotFile);
48171
48205
  let existing = null;
48172
48206
  try {
48173
- const parsed = JSON.parse(readFileSync4(ledgerFile, "utf8"));
48207
+ const parsed = JSON.parse(readFileSync5(ledgerFile, "utf8"));
48174
48208
  if (parsed && parsed.v === 1 && Array.isArray(parsed.entries)) existing = parsed;
48175
48209
  } catch {
48176
48210
  }
48177
48211
  const next = foldTurnInitiatorLedger(existing, marker);
48178
48212
  const tmp = `${ledgerFile}.${process.pid}.${Date.now()}.tmp`;
48179
- writeFileSync2(tmp, JSON.stringify(next), "utf8");
48180
- renameSync2(tmp, ledgerFile);
48213
+ writeFileSync3(tmp, JSON.stringify(next), "utf8");
48214
+ renameSync3(tmp, ledgerFile);
48181
48215
  }
48182
48216
  function writeTurnInitiatorMarker(input) {
48183
48217
  const file = process.env["AGT_TURN_INITIATOR_FILE"];
@@ -48186,8 +48220,8 @@ function writeTurnInitiatorMarker(input) {
48186
48220
  mkdirSync2(dirname2(file), { recursive: true });
48187
48221
  const marker = { ...input, ts: Date.now() };
48188
48222
  const tmp = `${file}.tmp`;
48189
- writeFileSync2(tmp, JSON.stringify(marker), "utf8");
48190
- renameSync2(tmp, file);
48223
+ writeFileSync3(tmp, JSON.stringify(marker), "utf8");
48224
+ renameSync3(tmp, file);
48191
48225
  try {
48192
48226
  updateTurnInitiatorLedger(file, marker);
48193
48227
  } catch {
@@ -48197,14 +48231,14 @@ function writeTurnInitiatorMarker(input) {
48197
48231
  }
48198
48232
 
48199
48233
  // src/scheduled-turn-marker.ts
48200
- import { readFileSync as readFileSync5, unlinkSync } from "fs";
48201
- import { join as join7 } from "path";
48234
+ import { readFileSync as readFileSync6, unlinkSync } from "fs";
48235
+ import { join as join8 } from "path";
48202
48236
  var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
48203
48237
  var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
48204
48238
  function clearScheduledTurnMarker(agentDir) {
48205
48239
  if (!agentDir) return;
48206
48240
  try {
48207
- unlinkSync(join7(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
48241
+ unlinkSync(join8(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
48208
48242
  } catch {
48209
48243
  }
48210
48244
  }
@@ -48240,7 +48274,7 @@ function resolveTurnInitiatorFile(env2 = process.env, home = homedir2()) {
48240
48274
  turnInitiatorFile: null,
48241
48275
  homeDir: home
48242
48276
  });
48243
- return dir ? join8(dir, TURN_INITIATOR_MARKER_FILENAME) : null;
48277
+ return dir ? join9(dir, TURN_INITIATOR_MARKER_FILENAME) : null;
48244
48278
  }
48245
48279
 
48246
48280
  // src/direct-chat-turn-marker.ts
@@ -48276,12 +48310,12 @@ import {
48276
48310
  existsSync as existsSync2,
48277
48311
  mkdirSync as mkdirSync4,
48278
48312
  readdirSync as readdirSync2,
48279
- readFileSync as readFileSync7,
48280
- renameSync as renameSync3,
48313
+ readFileSync as readFileSync8,
48314
+ renameSync as renameSync4,
48281
48315
  unlinkSync as unlinkSync2,
48282
- writeFileSync as writeFileSync3
48316
+ writeFileSync as writeFileSync4
48283
48317
  } from "fs";
48284
- import { join as join9 } from "path";
48318
+ import { join as join10 } from "path";
48285
48319
  function hexEncodeSegment(value) {
48286
48320
  return Buffer.from(value, "utf8").toString("hex");
48287
48321
  }
@@ -48308,10 +48342,10 @@ function writeDirectChatPendingInboundMarker(dir, sessionId, messageId) {
48308
48342
  received_at: (/* @__PURE__ */ new Date()).toISOString(),
48309
48343
  inbound_id: directChatInboundId(sessionId, messageId)
48310
48344
  };
48311
- const final = join9(dir, directChatMarkerName(sessionId, messageId));
48345
+ const final = join10(dir, directChatMarkerName(sessionId, messageId));
48312
48346
  const tmp = `${final}.tmp`;
48313
- writeFileSync3(tmp, JSON.stringify(marker), "utf8");
48314
- renameSync3(tmp, final);
48347
+ writeFileSync4(tmp, JSON.stringify(marker), "utf8");
48348
+ renameSync4(tmp, final);
48315
48349
  } catch {
48316
48350
  }
48317
48351
  }
@@ -48327,15 +48361,15 @@ function clearDirectChatPendingMarkersForSession(dir, sessionId, op = defaultCle
48327
48361
  }
48328
48362
  for (const name of names) {
48329
48363
  if (!name.startsWith(prefix) || !name.endsWith(".json")) continue;
48330
- op(join9(dir, name));
48364
+ op(join10(dir, name));
48331
48365
  cleared += 1;
48332
48366
  }
48333
48367
  return cleared;
48334
48368
  }
48335
- function readDirectChatPendingInboundMarker(dir, sessionId, messageId, readFileImpl = (path) => readFileSync7(path, "utf8")) {
48369
+ function readDirectChatPendingInboundMarker(dir, sessionId, messageId, readFileImpl = (path) => readFileSync8(path, "utf8")) {
48336
48370
  if (!dir || !sessionId || !messageId) return null;
48337
48371
  try {
48338
- const raw = readFileImpl(join9(dir, directChatMarkerName(sessionId, messageId)));
48372
+ const raw = readFileImpl(join10(dir, directChatMarkerName(sessionId, messageId)));
48339
48373
  return JSON.parse(raw);
48340
48374
  } catch {
48341
48375
  return null;
@@ -48358,7 +48392,7 @@ function sweepAgedDirectChatMarkers(dir, deps) {
48358
48392
  }
48359
48393
  for (const name of names) {
48360
48394
  if (!name.endsWith(".json") || name.startsWith(".")) continue;
48361
- const full = join9(dir, name);
48395
+ const full = join10(dir, name);
48362
48396
  let marker;
48363
48397
  try {
48364
48398
  marker = JSON.parse(deps.readFile(full));
@@ -48457,17 +48491,17 @@ async function consumeDirectChatRecoveryFile(fullPath, filename, deps) {
48457
48491
  }
48458
48492
 
48459
48493
  // src/inbound-delivery-ledger.ts
48460
- import { existsSync as existsSync3, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as readFileSync8, renameSync as renameSync4, writeFileSync as writeFileSync4 } from "fs";
48461
- import { join as join10 } from "path";
48494
+ import { existsSync as existsSync3, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as readFileSync9, renameSync as renameSync5, writeFileSync as writeFileSync5 } from "fs";
48495
+ import { join as join11 } from "path";
48462
48496
  function safeInboundId(inboundId) {
48463
48497
  return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
48464
48498
  }
48465
48499
  var defaultDeps = {
48466
48500
  mkdir: (dir) => mkdirSync5(dir, { recursive: true }),
48467
- writeFile: (path, data) => writeFileSync4(path, data, "utf8"),
48468
- rename: (from, to) => renameSync4(from, to),
48501
+ writeFile: (path, data) => writeFileSync5(path, data, "utf8"),
48502
+ rename: (from, to) => renameSync5(from, to),
48469
48503
  readdir: (dir) => readdirSync3(dir),
48470
- readFile: (path) => readFileSync8(path, "utf8"),
48504
+ readFile: (path) => readFileSync9(path, "utf8"),
48471
48505
  exists: (path) => existsSync3(path)
48472
48506
  };
48473
48507
  function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
@@ -48476,7 +48510,7 @@ function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
48476
48510
  if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
48477
48511
  try {
48478
48512
  deps.mkdir(dir);
48479
- const final = join10(dir, `${safe}.json`);
48513
+ const final = join11(dir, `${safe}.json`);
48480
48514
  const tmp = `${final}.tmp`;
48481
48515
  deps.writeFile(tmp, JSON.stringify(record2));
48482
48516
  deps.rename(tmp, final);
@@ -48488,24 +48522,24 @@ function inboundDeliveryLedgerHas(dir, inboundId, deps = defaultDeps) {
48488
48522
  const safe = safeInboundId(inboundId);
48489
48523
  if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return false;
48490
48524
  try {
48491
- return deps.exists(join10(dir, `${safe}.json`));
48525
+ return deps.exists(join11(dir, `${safe}.json`));
48492
48526
  } catch {
48493
48527
  return false;
48494
48528
  }
48495
48529
  }
48496
48530
 
48497
48531
  // src/ack-reaction.ts
48498
- import { readdirSync as readdirSync4, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
48499
- import { join as join12 } from "path";
48532
+ import { readdirSync as readdirSync4, readFileSync as readFileSync11, writeFileSync as writeFileSync6 } from "fs";
48533
+ import { join as join13 } from "path";
48500
48534
 
48501
48535
  // src/flags-cache-read.ts
48502
- import { existsSync as existsSync4, readFileSync as readFileSync9 } from "fs";
48536
+ import { existsSync as existsSync4, readFileSync as readFileSync10 } from "fs";
48503
48537
  import { homedir as homedir3 } from "os";
48504
- import { join as join11 } from "path";
48538
+ import { join as join12 } from "path";
48505
48539
  function hasUsableFlags(path) {
48506
48540
  try {
48507
48541
  if (!existsSync4(path)) return false;
48508
- const parsed = JSON.parse(readFileSync9(path, "utf8"));
48542
+ const parsed = JSON.parse(readFileSync10(path, "utf8"));
48509
48543
  if (!parsed || typeof parsed !== "object") return false;
48510
48544
  const flags = parsed.flags;
48511
48545
  return !!flags && typeof flags === "object" && !Array.isArray(flags);
@@ -48516,7 +48550,7 @@ function hasUsableFlags(path) {
48516
48550
  function cacheUpdatedAt(path) {
48517
48551
  try {
48518
48552
  if (!existsSync4(path)) return void 0;
48519
- const parsed = JSON.parse(readFileSync9(path, "utf8"));
48553
+ const parsed = JSON.parse(readFileSync10(path, "utf8"));
48520
48554
  if (!parsed || typeof parsed !== "object") return void 0;
48521
48555
  const u = parsed.updated_at;
48522
48556
  return typeof u === "string" && u.length > 0 ? u : void 0;
@@ -48525,10 +48559,10 @@ function cacheUpdatedAt(path) {
48525
48559
  }
48526
48560
  }
48527
48561
  function defaultFlagsCachePath(env2 = process.env) {
48528
- const hostWide = join11(homedir3(), ".augmented", "flags-cache.json");
48562
+ const hostWide = join12(homedir3(), ".augmented", "flags-cache.json");
48529
48563
  const agentId = env2["AGT_AGENT_ID"]?.trim();
48530
48564
  if (!agentId) return hostWide;
48531
- const perAgent = join11(homedir3(), ".augmented", agentId, "flags-cache.json");
48565
+ const perAgent = join12(homedir3(), ".augmented", agentId, "flags-cache.json");
48532
48566
  if (!hasUsableFlags(perAgent)) return hostWide;
48533
48567
  const hostWideAt = cacheUpdatedAt(hostWide);
48534
48568
  const perAgentAt = cacheUpdatedAt(perAgent);
@@ -48546,7 +48580,7 @@ function envBoolean(raw) {
48546
48580
  function cachedBoolean(key, path) {
48547
48581
  try {
48548
48582
  if (!existsSync4(path)) return void 0;
48549
- const parsed = JSON.parse(readFileSync9(path, "utf8"));
48583
+ const parsed = JSON.parse(readFileSync10(path, "utf8"));
48550
48584
  if (!parsed || typeof parsed !== "object") return void 0;
48551
48585
  const flags = parsed.flags;
48552
48586
  if (!flags || typeof flags !== "object") return void 0;
@@ -48578,7 +48612,7 @@ function parseMaintenanceMode(raw) {
48578
48612
  function cachedMaintenanceMode(path) {
48579
48613
  try {
48580
48614
  if (!existsSync4(path)) return void 0;
48581
- const parsed = JSON.parse(readFileSync9(path, "utf8"));
48615
+ const parsed = JSON.parse(readFileSync10(path, "utf8"));
48582
48616
  if (!parsed || typeof parsed !== "object") return void 0;
48583
48617
  const flags = parsed.flags;
48584
48618
  if (!flags || typeof flags !== "object") return void 0;
@@ -48661,7 +48695,7 @@ function undeliverableNoticeTextForRepeat(i) {
48661
48695
  }
48662
48696
  return null;
48663
48697
  }
48664
- function channelInboundGateOpen(readFile = (p2) => readFileSync10(p2, "utf-8")) {
48698
+ function channelInboundGateOpen(readFile = (p2) => readFileSync11(p2, "utf-8")) {
48665
48699
  const path = process.platform === "darwin" ? "/Library/Application Support/ClaudeCode/managed-settings.json" : "/etc/claude-code/managed-settings.json";
48666
48700
  let raw;
48667
48701
  try {
@@ -48726,7 +48760,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
48726
48760
  function readGiveUpSignal(path, now = Date.now()) {
48727
48761
  if (!path) return null;
48728
48762
  try {
48729
- const raw = JSON.parse(readFileSync10(path, "utf8"));
48763
+ const raw = JSON.parse(readFileSync11(path, "utf8"));
48730
48764
  if (typeof raw.gave_up_at !== "string") return null;
48731
48765
  const t = Date.parse(raw.gave_up_at);
48732
48766
  if (!Number.isFinite(t) || t > now) return null;
@@ -48740,12 +48774,12 @@ function readGiveUpSignal(path, now = Date.now()) {
48740
48774
  var USAGE_LIMIT_LIVE_WINDOW_MS = 3 * 6e4;
48741
48775
  function readUsageLimitForBusyAck(agentDir, now = Date.now()) {
48742
48776
  if (!agentDir) return null;
48743
- const path = join12(agentDir, GIVE_UP_SIGNAL_FILENAME);
48777
+ const path = join13(agentDir, GIVE_UP_SIGNAL_FILENAME);
48744
48778
  const sig = readGiveUpSignal(path, now);
48745
48779
  if (sig?.reason !== "usage_limit") return null;
48746
48780
  let lastSeenMs = null;
48747
48781
  try {
48748
- const raw = JSON.parse(readFileSync10(path, "utf8"));
48782
+ const raw = JSON.parse(readFileSync11(path, "utf8"));
48749
48783
  if (typeof raw.usage_limit_last_seen_at === "string") {
48750
48784
  const t = Date.parse(raw.usage_limit_last_seen_at);
48751
48785
  if (Number.isFinite(t) && t <= now) lastSeenMs = t;
@@ -48764,7 +48798,7 @@ function readBlockedPromptForBusyAck(agentDir, now = Date.now()) {
48764
48798
  if (!agentDir) return null;
48765
48799
  let raw;
48766
48800
  try {
48767
- raw = JSON.parse(readFileSync10(join12(agentDir, BLOCKED_PROMPT_SIGNAL_FILENAME), "utf8"));
48801
+ raw = JSON.parse(readFileSync11(join13(agentDir, BLOCKED_PROMPT_SIGNAL_FILENAME), "utf8"));
48768
48802
  } catch {
48769
48803
  return null;
48770
48804
  }
@@ -48818,7 +48852,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
48818
48852
  if (opts?.exclude?.(name)) continue;
48819
48853
  let receivedAt;
48820
48854
  try {
48821
- const raw = JSON.parse(readFileSync10(join12(dir, name), "utf-8"));
48855
+ const raw = JSON.parse(readFileSync11(join13(dir, name), "utf-8"));
48822
48856
  if (markerOwesNoReply(raw)) continue;
48823
48857
  if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
48824
48858
  receivedAt = raw.received_at;
@@ -48872,27 +48906,27 @@ function isMarkerGenuinelyAged(receivedAt, nowMs, thresholdMs) {
48872
48906
  }
48873
48907
  var DEFLECTION_COUNTER_SUFFIX = "-deflections.json";
48874
48908
  function deflectionCounterPath(agentDir, channel) {
48875
- return join12(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
48909
+ return join13(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
48876
48910
  }
48877
48911
  function recordChannelDeflection(agentDir, channel, cause) {
48878
48912
  if (!agentDir) return;
48879
48913
  const path = deflectionCounterPath(agentDir, channel);
48880
48914
  let counts = {};
48881
48915
  try {
48882
- const parsed = JSON.parse(readFileSync10(path, "utf-8"));
48916
+ const parsed = JSON.parse(readFileSync11(path, "utf-8"));
48883
48917
  if (parsed && typeof parsed === "object") counts = parsed;
48884
48918
  } catch {
48885
48919
  }
48886
48920
  counts[cause] = (counts[cause] ?? 0) + 1;
48887
48921
  try {
48888
- writeFileSync5(path, JSON.stringify(counts), { mode: 384 });
48922
+ writeFileSync6(path, JSON.stringify(counts), { mode: 384 });
48889
48923
  } catch {
48890
48924
  }
48891
48925
  }
48892
48926
 
48893
48927
  // src/turn-failure-watch.ts
48894
48928
  import { readdirSync as readdirSync5, statSync as statSync2 } from "fs";
48895
- import { join as join13 } from "path";
48929
+ import { join as join14 } from "path";
48896
48930
  function turnFailureNoticeEnabled(env2) {
48897
48931
  return resolveHostBooleanFlag({
48898
48932
  key: "wedge-transient-notice",
@@ -48922,7 +48956,7 @@ function classifyTurnFailureSince(opts) {
48922
48956
  const unrecognised = /* @__PURE__ */ new Set();
48923
48957
  for (const name of entries) {
48924
48958
  if (!name.endsWith(".jsonl")) continue;
48925
- const path = join13(dir, name);
48959
+ const path = join14(dir, name);
48926
48960
  let fingerprint;
48927
48961
  try {
48928
48962
  const st = statSync2(path);
@@ -49062,10 +49096,11 @@ function tmuxSessionTarget(session) {
49062
49096
  if (n.endsWith(":")) n = n.slice(0, -1);
49063
49097
  return `=${n}`;
49064
49098
  }
49099
+ var TMUX_SESSION_ABSENT = /can't find session|no server running|error connecting to .* \(No such file or directory\)/i;
49065
49100
  function probeTmuxSession(tmuxSession) {
49066
49101
  try {
49067
49102
  execFileSync("tmux", ["has-session", "-t", tmuxSessionTarget(tmuxSession)], {
49068
- stdio: "ignore",
49103
+ stdio: ["ignore", "ignore", "pipe"],
49069
49104
  timeout: 3e3
49070
49105
  });
49071
49106
  return "alive";
@@ -49073,6 +49108,10 @@ function probeTmuxSession(tmuxSession) {
49073
49108
  const e = err;
49074
49109
  const timedOut = e?.code === "ETIMEDOUT" || e?.error?.code === "ETIMEDOUT";
49075
49110
  if (e?.code === "ENOENT" || e?.error?.code === "ENOENT" || timedOut) return "unknown";
49111
+ const status = e.status;
49112
+ if (typeof status !== "number") return "unknown";
49113
+ const stderr = String(e.stderr ?? "").trim();
49114
+ if (stderr && !TMUX_SESSION_ABSENT.test(stderr)) return "unknown";
49076
49115
  return "dead";
49077
49116
  }
49078
49117
  }
@@ -49171,14 +49210,14 @@ var PollFollowUps = class {
49171
49210
  import {
49172
49211
  existsSync as existsSync5,
49173
49212
  mkdirSync as mkdirSync6,
49174
- readFileSync as readFileSync11,
49175
- renameSync as renameSync5,
49213
+ readFileSync as readFileSync12,
49214
+ renameSync as renameSync6,
49176
49215
  statSync as statSync3,
49177
49216
  unlinkSync as unlinkSync3,
49178
49217
  utimesSync,
49179
- writeFileSync as writeFileSync6
49218
+ writeFileSync as writeFileSync7
49180
49219
  } from "fs";
49181
- import { join as join14 } from "path";
49220
+ import { join as join15 } from "path";
49182
49221
  var STALE_LOCK_MS = 9e4;
49183
49222
  var HEARTBEAT_INTERVAL_MS = 3e4;
49184
49223
  function defaultIsPidAlive(pid) {
@@ -49201,7 +49240,7 @@ function acquireMcpSpawnLock(args) {
49201
49240
  const nowMs = options.nowMs ?? (() => Date.now());
49202
49241
  const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
49203
49242
  const staleMs = options.staleMs ?? STALE_LOCK_MS;
49204
- const path = join14(agentDir, basename3);
49243
+ const path = join15(agentDir, basename3);
49205
49244
  const existing = readLockHolder(path);
49206
49245
  if (existing) {
49207
49246
  if (existing.pid === selfPid) {
@@ -49218,8 +49257,8 @@ function acquireMcpSpawnLock(args) {
49218
49257
  mkdirSync6(agentDir, { recursive: true, mode: 448 });
49219
49258
  const tmpPath = `${path}.${selfPid}.tmp`;
49220
49259
  const payload = { pid: selfPid, started_at: now() };
49221
- writeFileSync6(tmpPath, JSON.stringify(payload), { mode: 384 });
49222
- renameSync5(tmpPath, path);
49260
+ writeFileSync7(tmpPath, JSON.stringify(payload), { mode: 384 });
49261
+ renameSync6(tmpPath, path);
49223
49262
  return { kind: "acquired", path };
49224
49263
  }
49225
49264
  function releaseMcpSpawnLock(lockPath, opts = {}) {
@@ -49268,7 +49307,7 @@ function defaultLockMtimeMs(path) {
49268
49307
  function readLockHolder(path) {
49269
49308
  if (!existsSync5(path)) return null;
49270
49309
  try {
49271
- const raw = readFileSync11(path, "utf8");
49310
+ const raw = readFileSync12(path, "utf8");
49272
49311
  const parsed = JSON.parse(raw);
49273
49312
  const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
49274
49313
  if (!Number.isFinite(pid) || pid <= 0) return null;
@@ -49281,16 +49320,16 @@ function readLockHolder(path) {
49281
49320
 
49282
49321
  // src/direct-chat-channel.ts
49283
49322
  import { homedir as homedir5 } from "os";
49284
- import { basename as basename2, join as join18 } from "path";
49323
+ import { basename as basename2, join as join19 } from "path";
49285
49324
  import { randomUUID } from "crypto";
49286
49325
  import {
49287
49326
  watch,
49288
49327
  mkdirSync as mkdirSync7,
49289
- writeFileSync as writeFileSync8,
49290
- readFileSync as readFileSync14,
49328
+ writeFileSync as writeFileSync9,
49329
+ readFileSync as readFileSync15,
49291
49330
  readdirSync as readdirSync6,
49292
49331
  existsSync as existsSync6,
49293
- renameSync as renameSync6,
49332
+ renameSync as renameSync7,
49294
49333
  unlinkSync as unlinkSync4,
49295
49334
  rmSync,
49296
49335
  statSync as statSync4,
@@ -49298,7 +49337,7 @@ import {
49298
49337
  } from "fs";
49299
49338
 
49300
49339
  // src/direct-chat-inbound-attachments.ts
49301
- import { join as join15 } from "path";
49340
+ import { join as join16 } from "path";
49302
49341
 
49303
49342
  // ../../node_modules/.pnpm/postal-mime@4.0.5/node_modules/postal-mime/dist/esm/decode-strings.js
49304
49343
  var textEncoder2 = new TextEncoder();
@@ -54543,7 +54582,7 @@ var OVER_CAP_ERROR = `exceeds the ${formatUploadSize(MAX_INBOUND_ATTACHMENT_BYTE
54543
54582
  var INBOUND_ATTACHMENTS_SUBDIR = "direct-chat-inbound";
54544
54583
  function resolveInboundAttachmentsDir(input) {
54545
54584
  const alias = resolveAgentDirAlias(input);
54546
- return alias === null ? null : join15(alias, INBOUND_ATTACHMENTS_SUBDIR);
54585
+ return alias === null ? null : join16(alias, INBOUND_ATTACHMENTS_SUBDIR);
54547
54586
  }
54548
54587
  function isImageContentType(contentType) {
54549
54588
  return typeof contentType === "string" && contentType.toLowerCase().startsWith("image/");
@@ -55503,19 +55542,19 @@ function shouldSendToolsOfflineNotice(opts) {
55503
55542
  var TOOLS_OFFLINE_USER_NOTICE = "Heads up \u2014 Ninjafy is in a maintenance window right now, so I can't save anything: no tasks, canvases, notes or scheduled items. I can still talk things through, and you can ask me to set it up once maintenance is done.";
55504
55543
 
55505
55544
  // src/account-enforcement-notice.ts
55506
- import { readFileSync as readFileSync12 } from "fs";
55545
+ import { readFileSync as readFileSync13 } from "fs";
55507
55546
  import { homedir as homedir4 } from "os";
55508
- import { join as join16 } from "path";
55547
+ import { join as join17 } from "path";
55509
55548
  function accountEnforcementMarkerPath(codeName) {
55510
55549
  if (!codeName) return null;
55511
- return join16(homedir4(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
55550
+ return join17(homedir4(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
55512
55551
  }
55513
55552
  function readAccountEnforcementMarker(opts) {
55514
55553
  const path = opts.filePath ?? accountEnforcementMarkerPath(opts.codeName);
55515
55554
  if (!path) return null;
55516
55555
  let raw;
55517
55556
  try {
55518
- raw = readFileSync12(path, "utf-8");
55557
+ raw = readFileSync13(path, "utf-8");
55519
55558
  } catch {
55520
55559
  return null;
55521
55560
  }
@@ -55541,8 +55580,8 @@ function shouldSendAccountWarn(opts) {
55541
55580
  }
55542
55581
 
55543
55582
  // ../core/dist/direct-chat/cursor-advance-telemetry.js
55544
- import { readFileSync as readFileSync13, writeFileSync as writeFileSync7 } from "fs";
55545
- import { join as join17 } from "path";
55583
+ import { readFileSync as readFileSync14, writeFileSync as writeFileSync8 } from "fs";
55584
+ import { join as join18 } from "path";
55546
55585
  var CURSOR_SHORTFALL_COUNTER_SUFFIX = "-cursor-advance-classifications.json";
55547
55586
  function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
55548
55587
  if (!agentDir)
@@ -55550,10 +55589,10 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
55550
55589
  const key = cursorAdvanceCounterKey(route, verdict);
55551
55590
  if (key === null)
55552
55591
  return;
55553
- const path = join17(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
55592
+ const path = join18(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
55554
55593
  const counts = {};
55555
55594
  try {
55556
- const parsed = JSON.parse(readFileSync13(path, "utf-8"));
55595
+ const parsed = JSON.parse(readFileSync14(path, "utf-8"));
55557
55596
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
55558
55597
  for (const [k, v] of Object.entries(parsed)) {
55559
55598
  if (typeof v === "number" && Number.isInteger(v) && v >= 0)
@@ -55564,7 +55603,7 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
55564
55603
  }
55565
55604
  counts[key] = (counts[key] ?? 0) + 1;
55566
55605
  try {
55567
- writeFileSync7(path, JSON.stringify(counts), { mode: 384 });
55606
+ writeFileSync8(path, JSON.stringify(counts), { mode: 384 });
55568
55607
  } catch {
55569
55608
  }
55570
55609
  }
@@ -55690,7 +55729,7 @@ var DIRECT_CHAT_ACCOUNT_WARN_COOLDOWN_MS = (() => {
55690
55729
  var AGT_HOST = process.env.AGT_HOST;
55691
55730
  var AGT_API_KEY = process.env.AGT_API_KEY;
55692
55731
  var AGT_AGENT_ID = process.env.AGT_AGENT_ID;
55693
- var DIRECT_CHAT_AGENT_DIR = AGT_AGENT_ID ? join18(homedir5(), ".augmented", AGT_AGENT_ID) : null;
55732
+ var DIRECT_CHAT_AGENT_DIR = AGT_AGENT_ID ? join19(homedir5(), ".augmented", AGT_AGENT_ID) : null;
55694
55733
  var INBOUND_ATTACHMENTS_DIR = resolveInboundAttachmentsDir({
55695
55734
  codeName: process.env.AGT_AGENT_CODE_NAME,
55696
55735
  turnInitiatorFile: process.env.AGT_TURN_INITIATOR_FILE,
@@ -55707,10 +55746,10 @@ var AGT_AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME;
55707
55746
  var directChatStderrLogStream = null;
55708
55747
  if (AGT_AGENT_CODE_NAME) {
55709
55748
  try {
55710
- const logDir = join18(homedir5(), ".augmented", AGT_AGENT_CODE_NAME);
55749
+ const logDir = join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME);
55711
55750
  mkdirSync7(logDir, { recursive: true });
55712
55751
  directChatStderrLogStream = createWriteStream(
55713
- join18(logDir, "direct-chat-channel-stderr.log"),
55752
+ join19(logDir, "direct-chat-channel-stderr.log"),
55714
55753
  { flags: "a", mode: 384 }
55715
55754
  );
55716
55755
  directChatStderrLogStream.on("error", () => {
@@ -55729,10 +55768,10 @@ if (AGT_AGENT_CODE_NAME) {
55729
55768
  } catch {
55730
55769
  }
55731
55770
  }
55732
- var PROGRESS_HEARTBEAT_PATH = AGT_AGENT_CODE_NAME ? join18(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, "channel-progress-heartbeat.json") : null;
55733
- var DIRECT_CHAT_PENDING_INBOUND_DIR = AGT_AGENT_CODE_NAME ? join18(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, "direct-chat-pending-inbound") : null;
55734
- var DIRECT_CHAT_DELIVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ? join18(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, ".agt-inbound-delivery-ledger") : null;
55735
- var DIRECT_CHAT_CODE_NAME_AGENT_DIR = AGT_AGENT_CODE_NAME ? join18(homedir5(), ".augmented", AGT_AGENT_CODE_NAME) : null;
55771
+ var PROGRESS_HEARTBEAT_PATH = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, "channel-progress-heartbeat.json") : null;
55772
+ var DIRECT_CHAT_PENDING_INBOUND_DIR = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, "direct-chat-pending-inbound") : null;
55773
+ var DIRECT_CHAT_DELIVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, ".agt-inbound-delivery-ledger") : null;
55774
+ var DIRECT_CHAT_CODE_NAME_AGENT_DIR = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME) : null;
55736
55775
  var DIRECT_CHAT_STALE_MARKER_MS = 24 * 60 * 60 * 1e3;
55737
55776
  function judgeCursorAdvance(input, ctx) {
55738
55777
  const verdict = classifyCursorAdvance(input);
@@ -55752,8 +55791,8 @@ function recordDirectChatDelivery(sessionId, messageIds) {
55752
55791
  delivered_at: (/* @__PURE__ */ new Date()).toISOString()
55753
55792
  });
55754
55793
  }
55755
- var DIRECT_CHAT_RECOVERY_OUTBOX_DIR = AGT_AGENT_CODE_NAME ? join18(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, "direct-chat-recovery-outbox") : null;
55756
- var DIRECT_CHAT_RECOVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ? join18(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, ".agt-direct-chat-recovery-ledger") : null;
55794
+ var DIRECT_CHAT_RECOVERY_OUTBOX_DIR = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, "direct-chat-recovery-outbox") : null;
55795
+ var DIRECT_CHAT_RECOVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, ".agt-direct-chat-recovery-ledger") : null;
55757
55796
  var progressReceivedAt = /* @__PURE__ */ new Map();
55758
55797
  var directChatProgressState = { tracked: null };
55759
55798
  var directChatProgressTickRunning = false;
@@ -55772,7 +55811,7 @@ var directChatKanbanCardClient = createKanbanCardActiveClient({
55772
55811
  function readProgressHeartbeat() {
55773
55812
  if (!PROGRESS_HEARTBEAT_PATH || !existsSync6(PROGRESS_HEARTBEAT_PATH)) return null;
55774
55813
  try {
55775
- return parseProgressHeartbeat(readFileSync14(PROGRESS_HEARTBEAT_PATH, "utf-8"));
55814
+ return parseProgressHeartbeat(readFileSync15(PROGRESS_HEARTBEAT_PATH, "utf-8"));
55776
55815
  } catch {
55777
55816
  return null;
55778
55817
  }
@@ -55781,9 +55820,9 @@ function seedProgressHeartbeat() {
55781
55820
  if (!PROGRESS_HEARTBEAT_PATH) return;
55782
55821
  const tmp = `${PROGRESS_HEARTBEAT_PATH}.${process.pid}.tmp`;
55783
55822
  try {
55784
- mkdirSync7(join18(homedir5(), ".augmented", AGT_AGENT_CODE_NAME), { recursive: true });
55785
- writeFileSync8(tmp, serializeProgressHeartbeat(SEED_PROGRESS_STEP, Date.now()), { mode: 384 });
55786
- renameSync6(tmp, PROGRESS_HEARTBEAT_PATH);
55823
+ mkdirSync7(join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME), { recursive: true });
55824
+ writeFileSync9(tmp, serializeProgressHeartbeat(SEED_PROGRESS_STEP, Date.now()), { mode: 384 });
55825
+ renameSync7(tmp, PROGRESS_HEARTBEAT_PATH);
55787
55826
  } catch {
55788
55827
  try {
55789
55828
  unlinkSync4(tmp);
@@ -56012,8 +56051,8 @@ var inboundAttachmentDeps = {
56012
56051
  fetchUrl: (url, expectedBytes) => fetchWithTransferDeadline(url, inboundDownloadTimeoutMs(expectedBytes)),
56013
56052
  ensureDir: (dir) => mkdirSync7(dir, { recursive: true }),
56014
56053
  removeDir: (dir) => rmSync(dir, { recursive: true, force: true }),
56015
- writeFile: (path, bytes) => writeFileSync8(path, bytes, { mode: 384 }),
56016
- joinPath: (...parts) => join18(...parts),
56054
+ writeFile: (path, bytes) => writeFileSync9(path, bytes, { mode: 384 }),
56055
+ joinPath: (...parts) => join19(...parts),
56017
56056
  warn: (msg) => process.stderr.write(`${msg}
56018
56057
  `)
56019
56058
  };
@@ -56049,10 +56088,16 @@ var mcp = new Server(
56049
56088
  );
56050
56089
  var DIRECT_CHAT_CLAIMS_PATH = directChatClaimsPath(DIRECT_CHAT_AGENT_DIR);
56051
56090
  var claimsTranscriptId = null;
56091
+ var DIRECT_CHAT_INFLIGHT_PATH = DIRECT_CHAT_AGENT_DIR ? directChatInflightPath(DIRECT_CHAT_AGENT_DIR) : null;
56052
56092
  var claimTracker = new DirectChatClaimTracker({
56053
- onChange: (t) => {
56054
- saveDirectChatClaims(DIRECT_CHAT_CLAIMS_PATH, claimsTranscriptId, t.snapshot(), Date.now());
56055
- }
56093
+ // ENG-12100: also writes the in-flight marker the manager-restart gate reads,
56094
+ // on every claim change (empty once the push resolves), independent of the
56095
+ // doorbell binding the claims store depends on.
56096
+ onChange: (t) => publishDirectChatClaimsChange(t.snapshot(), {
56097
+ saveClaims: (snapshot) => saveDirectChatClaims(DIRECT_CHAT_CLAIMS_PATH, claimsTranscriptId, snapshot, Date.now()),
56098
+ inflightPath: DIRECT_CHAT_INFLIGHT_PATH,
56099
+ pid: process.pid
56100
+ })
56056
56101
  });
56057
56102
  mcp.setRequestHandler(ListToolsRequestSchema, async () => ({
56058
56103
  tools: [
@@ -56531,7 +56576,7 @@ function directChatSessionReplayFacts(sessionId) {
56531
56576
  sessionId,
56532
56577
  (fullPath) => {
56533
56578
  try {
56534
- const marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
56579
+ const marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
56535
56580
  found.push({ hasPayload: Boolean(marker.payload), discretionary: marker.discretionary });
56536
56581
  } catch {
56537
56582
  found.push({ hasPayload: false });
@@ -56590,7 +56635,7 @@ function scheduleDirectChatBusyAck(sessionId, messageId, arrivedWhileBusy) {
56590
56635
  let paneLogFreshAgeMs = null;
56591
56636
  if (DIRECT_CHAT_CODE_NAME_AGENT_DIR) {
56592
56637
  try {
56593
- const paneMtimeMs = statSync4(join18(DIRECT_CHAT_CODE_NAME_AGENT_DIR, "pane.log")).mtimeMs;
56638
+ const paneMtimeMs = statSync4(join19(DIRECT_CHAT_CODE_NAME_AGENT_DIR, "pane.log")).mtimeMs;
56594
56639
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
56595
56640
  } catch {
56596
56641
  }
@@ -57049,6 +57094,9 @@ var stopLockHeartbeat = null;
57049
57094
  stopLockHeartbeat = startMcpSpawnLockHeartbeat(acquiredLockPath);
57050
57095
  }
57051
57096
  }
57097
+ if (DIRECT_CHAT_INFLIGHT_PATH) {
57098
+ writeDirectChatInflightMarker(DIRECT_CHAT_INFLIGHT_PATH, buildDirectChatInflightMarker(claimTracker.snapshot(), process.pid));
57099
+ }
57052
57100
  var DOORBELL_ENABLED = resolveHostBooleanFlag({
57053
57101
  key: "direct-chat-doorbell",
57054
57102
  envVar: "AGT_DIRECT_CHAT_DOORBELL_ENABLED",
@@ -57132,6 +57180,9 @@ if (DOORBELL_ENABLED && DIRECT_CHAT_AGENT_DIR) {
57132
57180
  const transcriptText = recovered.length > 0 && claimPlan.bindTo ? readTranscriptText(transcriptPathFor(agentTranscriptDir(), claimPlan.bindTo)) : null;
57133
57181
  const plan = recovered.length > 0 ? planRehand(recovered, transcriptText, sessionState.startedAtMs) : null;
57134
57182
  claimTracker.restore(recovered, { unpushed: plan?.rehand ?? [] });
57183
+ if (DIRECT_CHAT_INFLIGHT_PATH && recovered.length > 0) {
57184
+ writeDirectChatInflightMarker(DIRECT_CHAT_INFLIGHT_PATH, buildDirectChatInflightMarker(claimTracker.snapshot(), process.pid));
57185
+ }
57135
57186
  rehandPlan = plan ? { restored: recovered.length, plan } : null;
57136
57187
  if (recovered.length > 0) {
57137
57188
  process.stderr.write(
@@ -57235,7 +57286,7 @@ function sweepAgedDirectChatMarkersNow(thresholdMs) {
57235
57286
  const now = Date.now();
57236
57287
  const res = sweepAgedDirectChatMarkers(DIRECT_CHAT_PENDING_INBOUND_DIR, {
57237
57288
  readdir: (dir) => readdirSync6(dir),
57238
- readFile: (p2) => readFileSync14(p2, "utf8"),
57289
+ readFile: (p2) => readFileSync15(p2, "utf8"),
57239
57290
  unlink: (p2) => {
57240
57291
  if (existsSync6(p2)) unlinkSync4(p2);
57241
57292
  },
@@ -57284,8 +57335,8 @@ function sanitizeRecoveryText(text) {
57284
57335
  }
57285
57336
  function directChatRecoveryDeps() {
57286
57337
  return {
57287
- readFile: (p2) => readFileSync14(p2, "utf-8"),
57288
- renameFile: (from, to) => renameSync6(from, to),
57338
+ readFile: (p2) => readFileSync15(p2, "utf-8"),
57339
+ renameFile: (from, to) => renameSync7(from, to),
57289
57340
  unlinkFile: (p2) => {
57290
57341
  if (existsSync6(p2)) unlinkSync4(p2);
57291
57342
  },
@@ -57297,7 +57348,7 @@ function directChatRecoveryDeps() {
57297
57348
  if (!DIRECT_CHAT_RECOVERY_LEDGER_DIR) return;
57298
57349
  if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
57299
57350
  try {
57300
- const p2 = join18(DIRECT_CHAT_RECOVERY_LEDGER_DIR, markerName);
57351
+ const p2 = join19(DIRECT_CHAT_RECOVERY_LEDGER_DIR, markerName);
57301
57352
  if (existsSync6(p2)) unlinkSync4(p2);
57302
57353
  } catch {
57303
57354
  }
@@ -57348,7 +57399,7 @@ async function processDirectChatRecoveryOutboxFile(filename) {
57348
57399
  if (!enabled) return;
57349
57400
  directChatRecoveryInFlight.add(filename);
57350
57401
  try {
57351
- const fullPath = join18(DIRECT_CHAT_RECOVERY_OUTBOX_DIR, filename);
57402
+ const fullPath = join19(DIRECT_CHAT_RECOVERY_OUTBOX_DIR, filename);
57352
57403
  await consumeDirectChatRecoveryFile(fullPath, filename, directChatRecoveryDeps());
57353
57404
  } catch (err) {
57354
57405
  process.stderr.write(
@@ -57376,7 +57427,7 @@ if (DIRECT_CHAT_RECOVERY_OUTBOX_DIR) {
57376
57427
  if (!filename) return;
57377
57428
  const name = filename.toString();
57378
57429
  if (!name.endsWith(".json")) return;
57379
- if (existsSync6(join18(DIRECT_CHAT_RECOVERY_OUTBOX_DIR, name))) {
57430
+ if (existsSync6(join19(DIRECT_CHAT_RECOVERY_OUTBOX_DIR, name))) {
57380
57431
  void processDirectChatRecoveryOutboxFile(name);
57381
57432
  }
57382
57433
  });