@integrity-labs/agt-cli 0.27.125 → 0.27.127

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.
@@ -14180,6 +14180,47 @@ var Server = class extends Protocol {
14180
14180
  }
14181
14181
  };
14182
14182
 
14183
+ // src/restart-confirm.ts
14184
+ import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "fs";
14185
+ import { dirname } from "path";
14186
+ import { randomUUID } from "crypto";
14187
+ var RESTART_CONFIRM_MAX_AGE_MS = 10 * 60 * 1e3;
14188
+ function shouldPostRestartConfirm(marker, processBootMs, nowMs) {
14189
+ if (!marker) return false;
14190
+ const requestedAt = marker.requested_at;
14191
+ if (typeof requestedAt !== "number" || !Number.isFinite(requestedAt)) return false;
14192
+ if (requestedAt >= processBootMs) return false;
14193
+ if (nowMs - requestedAt > RESTART_CONFIRM_MAX_AGE_MS) return false;
14194
+ return true;
14195
+ }
14196
+ function buildBackOnlineText(name) {
14197
+ const trimmed = typeof name === "string" ? name.trim() : "";
14198
+ return trimmed ? `Hey ${trimmed}, I'm back online after my restart. \u{1F7E2}` : `I'm back online after my restart. \u{1F7E2}`;
14199
+ }
14200
+ function writeRestartConfirmMarker(filePath, marker) {
14201
+ const dir = dirname(filePath);
14202
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true, mode: 448 });
14203
+ const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
14204
+ writeFileSync(tmpPath, JSON.stringify(marker) + "\n", { encoding: "utf8", mode: 384 });
14205
+ renameSync(tmpPath, filePath);
14206
+ }
14207
+ function readRestartConfirmMarker(filePath) {
14208
+ try {
14209
+ if (!existsSync(filePath)) return null;
14210
+ const parsed = JSON.parse(readFileSync(filePath, "utf8"));
14211
+ if (!parsed || typeof parsed !== "object") return null;
14212
+ return parsed;
14213
+ } catch {
14214
+ return null;
14215
+ }
14216
+ }
14217
+ function clearRestartConfirmMarker(filePath) {
14218
+ try {
14219
+ if (existsSync(filePath)) unlinkSync(filePath);
14220
+ } catch {
14221
+ }
14222
+ }
14223
+
14183
14224
  // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
14184
14225
  import process2 from "process";
14185
14226
 
@@ -14274,18 +14315,18 @@ var StdioServerTransport = class {
14274
14315
 
14275
14316
  // src/telegram-channel.ts
14276
14317
  import https from "https";
14277
- import { createHash, randomUUID } from "crypto";
14318
+ import { createHash, randomUUID as randomUUID2 } from "crypto";
14278
14319
  import {
14279
14320
  createWriteStream,
14280
- existsSync as existsSync2,
14281
- mkdirSync as mkdirSync3,
14282
- readFileSync as readFileSync3,
14321
+ existsSync as existsSync3,
14322
+ mkdirSync as mkdirSync4,
14323
+ readFileSync as readFileSync4,
14283
14324
  readdirSync as readdirSync2,
14284
- renameSync as renameSync3,
14325
+ renameSync as renameSync4,
14285
14326
  statSync,
14286
- unlinkSync as unlinkSync3,
14327
+ unlinkSync as unlinkSync4,
14287
14328
  watch,
14288
- writeFileSync as writeFileSync3
14329
+ writeFileSync as writeFileSync4
14289
14330
  } from "fs";
14290
14331
  import { homedir as homedir2 } from "os";
14291
14332
  import { join as join4 } from "path";
@@ -14412,7 +14453,7 @@ function redactAugmentedPaths(msg) {
14412
14453
  }
14413
14454
 
14414
14455
  // src/telegram-attachments.ts
14415
- import { mkdirSync, writeFileSync, chmodSync, renameSync, unlinkSync } from "fs";
14456
+ import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, chmodSync, renameSync as renameSync2, unlinkSync as unlinkSync2 } from "fs";
14416
14457
  function resolveTelegramInboundDir(codeName) {
14417
14458
  return resolveChannelInboundDir(codeName, "telegram-inbound");
14418
14459
  }
@@ -14501,18 +14542,18 @@ async function downloadTelegramFile(fileId, opts) {
14501
14542
  if (!isPathInside(savedPath, dir)) {
14502
14543
  throw new Error(`refusing to write ${savedPath} outside ${dir}`);
14503
14544
  }
14504
- mkdirSync(dir, { recursive: true });
14545
+ mkdirSync2(dir, { recursive: true });
14505
14546
  const tempPath = `${savedPath}.${process.pid}.${Date.now()}.tmp`;
14506
14547
  try {
14507
- writeFileSync(tempPath, bytes, { mode: 384, flag: "wx" });
14548
+ writeFileSync2(tempPath, bytes, { mode: 384, flag: "wx" });
14508
14549
  try {
14509
14550
  chmodSync(tempPath, 384);
14510
14551
  } catch {
14511
14552
  }
14512
- renameSync(tempPath, savedPath);
14553
+ renameSync2(tempPath, savedPath);
14513
14554
  } catch (err) {
14514
14555
  try {
14515
- unlinkSync(tempPath);
14556
+ unlinkSync2(tempPath);
14516
14557
  } catch {
14517
14558
  }
14518
14559
  throw err;
@@ -15733,12 +15774,12 @@ var TELEGRAM_EGRESS_TOOLS = /* @__PURE__ */ new Set([
15733
15774
 
15734
15775
  // src/mcp-spawn-lock.ts
15735
15776
  import {
15736
- existsSync,
15737
- mkdirSync as mkdirSync2,
15738
- readFileSync,
15739
- renameSync as renameSync2,
15740
- unlinkSync as unlinkSync2,
15741
- writeFileSync as writeFileSync2
15777
+ existsSync as existsSync2,
15778
+ mkdirSync as mkdirSync3,
15779
+ readFileSync as readFileSync2,
15780
+ renameSync as renameSync3,
15781
+ unlinkSync as unlinkSync3,
15782
+ writeFileSync as writeFileSync3
15742
15783
  } from "fs";
15743
15784
  import { join as join2 } from "path";
15744
15785
  function defaultIsPidAlive(pid) {
@@ -15768,11 +15809,11 @@ function acquireMcpSpawnLock(args) {
15768
15809
  return { kind: "blocked", path, holder: existing };
15769
15810
  }
15770
15811
  }
15771
- mkdirSync2(agentDir, { recursive: true, mode: 448 });
15812
+ mkdirSync3(agentDir, { recursive: true, mode: 448 });
15772
15813
  const tmpPath = `${path}.${selfPid}.tmp`;
15773
15814
  const payload = { pid: selfPid, started_at: now() };
15774
- writeFileSync2(tmpPath, JSON.stringify(payload), { mode: 384 });
15775
- renameSync2(tmpPath, path);
15815
+ writeFileSync3(tmpPath, JSON.stringify(payload), { mode: 384 });
15816
+ renameSync3(tmpPath, path);
15776
15817
  return { kind: "acquired", path };
15777
15818
  }
15778
15819
  function releaseMcpSpawnLock(lockPath, opts = {}) {
@@ -15782,14 +15823,14 @@ function releaseMcpSpawnLock(lockPath, opts = {}) {
15782
15823
  if (!existing) return;
15783
15824
  if (existing.pid !== selfPid) return;
15784
15825
  try {
15785
- unlinkSync2(lockPath);
15826
+ unlinkSync3(lockPath);
15786
15827
  } catch {
15787
15828
  }
15788
15829
  }
15789
15830
  function readLockHolder(path) {
15790
- if (!existsSync(path)) return null;
15831
+ if (!existsSync2(path)) return null;
15791
15832
  try {
15792
- const raw = readFileSync(path, "utf8");
15833
+ const raw = readFileSync2(path, "utf8");
15793
15834
  const parsed = JSON.parse(raw);
15794
15835
  const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
15795
15836
  if (!Number.isFinite(pid) || pid <= 0) return null;
@@ -15801,7 +15842,7 @@ function readLockHolder(path) {
15801
15842
  }
15802
15843
 
15803
15844
  // src/ack-reaction.ts
15804
- import { readdirSync, readFileSync as readFileSync2 } from "fs";
15845
+ import { readdirSync, readFileSync as readFileSync3 } from "fs";
15805
15846
  import { join as join3 } from "path";
15806
15847
  var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
15807
15848
  var ACK_STARTUP_GRACE_MS = 6e4;
@@ -15860,7 +15901,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
15860
15901
  function readGiveUpSignalAtMs(path, now = Date.now()) {
15861
15902
  if (!path) return null;
15862
15903
  try {
15863
- const raw = JSON.parse(readFileSync2(path, "utf8"));
15904
+ const raw = JSON.parse(readFileSync3(path, "utf8"));
15864
15905
  if (typeof raw.gave_up_at !== "string") return null;
15865
15906
  const t = Date.parse(raw.gave_up_at);
15866
15907
  if (!Number.isFinite(t) || t > now) return null;
@@ -15892,7 +15933,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now()) {
15892
15933
  if (!name.endsWith(".json")) continue;
15893
15934
  let receivedAt;
15894
15935
  try {
15895
- const raw = JSON.parse(readFileSync2(join3(dir, name), "utf-8"));
15936
+ const raw = JSON.parse(readFileSync3(join3(dir, name), "utf-8"));
15896
15937
  receivedAt = raw.received_at;
15897
15938
  } catch {
15898
15939
  continue;
@@ -16035,7 +16076,7 @@ var stderrLogStream = null;
16035
16076
  if (AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown") {
16036
16077
  try {
16037
16078
  const logDir = join4(homedir2(), ".augmented", AGENT_CODE_NAME);
16038
- mkdirSync3(logDir, { recursive: true });
16079
+ mkdirSync4(logDir, { recursive: true });
16039
16080
  stderrLogStream = createWriteStream(join4(logDir, "telegram-channel-stderr.log"), {
16040
16081
  flags: "a",
16041
16082
  mode: 384
@@ -16249,6 +16290,66 @@ function __resetBusyAckNoticeThrottle() {
16249
16290
  lastBusyAckNoticeAt.clear();
16250
16291
  }
16251
16292
  var RESTART_FLAGS_DIR = join4(homedir2(), ".augmented", "restart-flags");
16293
+ function writeTelegramRestartConfirm(reply, requesterName) {
16294
+ if (!RESTART_CONFIRM_FILE) return;
16295
+ const marker = {
16296
+ source: "telegram",
16297
+ requested_at: Date.now(),
16298
+ ...requesterName ? { requester_name: requesterName } : {},
16299
+ reply
16300
+ };
16301
+ try {
16302
+ writeRestartConfirmMarker(RESTART_CONFIRM_FILE, marker);
16303
+ } catch (err) {
16304
+ process.stderr.write(
16305
+ `telegram-channel(${AGENT_CODE_NAME}): restart-confirm marker write failed: ${redactAugmentedPaths(err.message)}
16306
+ `
16307
+ );
16308
+ }
16309
+ }
16310
+ async function notifyRestartCompleteOnBoot() {
16311
+ if (!RESTART_CONFIRM_FILE) return;
16312
+ const marker = readRestartConfirmMarker(RESTART_CONFIRM_FILE);
16313
+ if (!shouldPostRestartConfirm(marker, TELEGRAM_PROCESS_BOOT_MS, Date.now())) {
16314
+ if (marker) clearRestartConfirmMarker(RESTART_CONFIRM_FILE);
16315
+ return;
16316
+ }
16317
+ const chatId = marker.reply["chat_id"];
16318
+ if (chatId == null) {
16319
+ clearRestartConfirmMarker(RESTART_CONFIRM_FILE);
16320
+ return;
16321
+ }
16322
+ const messageId = marker.reply["message_id"];
16323
+ try {
16324
+ const resp = await telegramApiCall(
16325
+ "sendMessage",
16326
+ {
16327
+ chat_id: chatId,
16328
+ text: buildBackOnlineText(marker.requester_name),
16329
+ // Thread under the original /restart command when we have its id.
16330
+ ...messageId != null ? { reply_to_message_id: Number(messageId), allow_sending_without_reply: true } : {}
16331
+ },
16332
+ 1e4
16333
+ );
16334
+ if (resp.ok) {
16335
+ clearRestartConfirmMarker(RESTART_CONFIRM_FILE);
16336
+ process.stderr.write(
16337
+ `telegram-channel(${AGENT_CODE_NAME}): posted back-online confirmation after restart
16338
+ `
16339
+ );
16340
+ } else {
16341
+ process.stderr.write(
16342
+ `telegram-channel(${AGENT_CODE_NAME}): back-online confirmation rejected (chat=${redactId(chatId)}): ${resp.description ?? "unknown"}
16343
+ `
16344
+ );
16345
+ }
16346
+ } catch (err) {
16347
+ process.stderr.write(
16348
+ `telegram-channel(${AGENT_CODE_NAME}): back-online confirmation send failed: ${redactAugmentedPaths(err.message)}
16349
+ `
16350
+ );
16351
+ }
16352
+ }
16252
16353
  function buildTelegramHelpMessage(codeName) {
16253
16354
  return [
16254
16355
  `\u{1F916} *Available commands for \`${codeName}\`*`,
@@ -16286,19 +16387,23 @@ async function handleHelpCommand(opts) {
16286
16387
  }
16287
16388
  async function handleRestartCommand(opts) {
16288
16389
  try {
16289
- if (!existsSync2(RESTART_FLAGS_DIR)) {
16290
- mkdirSync3(RESTART_FLAGS_DIR, { recursive: true });
16390
+ if (!existsSync3(RESTART_FLAGS_DIR)) {
16391
+ mkdirSync4(RESTART_FLAGS_DIR, { recursive: true });
16291
16392
  }
16292
16393
  const flagPath = join4(RESTART_FLAGS_DIR, `${AGENT_CODE_NAME}.flag`);
16394
+ writeTelegramRestartConfirm(
16395
+ { chat_id: opts.chatId, message_id: opts.messageId },
16396
+ opts.requesterName
16397
+ );
16293
16398
  const flag = {
16294
16399
  codeName: AGENT_CODE_NAME,
16295
16400
  source: "telegram",
16296
16401
  ts: Date.now(),
16297
16402
  reply: { chat_id: opts.chatId, message_id: opts.messageId }
16298
16403
  };
16299
- const tmpPath = `${flagPath}.${process.pid}.${randomUUID()}.tmp`;
16300
- writeFileSync3(tmpPath, JSON.stringify(flag) + "\n", "utf8");
16301
- renameSync3(tmpPath, flagPath);
16404
+ const tmpPath = `${flagPath}.${process.pid}.${randomUUID2()}.tmp`;
16405
+ writeFileSync4(tmpPath, JSON.stringify(flag) + "\n", "utf8");
16406
+ renameSync4(tmpPath, flagPath);
16302
16407
  process.stderr.write(
16303
16408
  `telegram-channel(${AGENT_CODE_NAME}): /restart queued from chat ${redactId(opts.chatId)}
16304
16409
  `
@@ -16663,6 +16768,8 @@ async function classifyRestartCommand(text) {
16663
16768
  var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join4(homedir2(), ".augmented", AGENT_CODE_NAME) : null;
16664
16769
  var PENDING_INBOUND_DIR = AGENT_DIR ? join4(AGENT_DIR, "telegram-pending-inbound") : null;
16665
16770
  var RECOVERY_OUTBOX_DIR = AGENT_DIR ? join4(AGENT_DIR, "telegram-recovery-outbox") : null;
16771
+ var RESTART_CONFIRM_FILE = AGENT_DIR ? join4(AGENT_DIR, "telegram-restart-confirm.json") : null;
16772
+ var TELEGRAM_PROCESS_BOOT_MS = Date.now();
16666
16773
  function safeMarkerName(chatId, messageId) {
16667
16774
  const safe = (s) => s.replace(/[^A-Za-z0-9_-]/g, "_");
16668
16775
  return `${safe(chatId)}__${safe(messageId)}.json`;
@@ -16686,8 +16793,8 @@ function writePendingInboundMarker(chatId, messageId, chatType, undeliverable =
16686
16793
  ...payload ? { payload } : {}
16687
16794
  };
16688
16795
  try {
16689
- mkdirSync3(PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
16690
- writeFileSync3(path, JSON.stringify(marker), { mode: 384 });
16796
+ mkdirSync4(PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
16797
+ writeFileSync4(path, JSON.stringify(marker), { mode: 384 });
16691
16798
  } catch (err) {
16692
16799
  process.stderr.write(
16693
16800
  `telegram-channel(${AGENT_CODE_NAME}): pending-inbound marker write failed: ${err.message}
@@ -16698,7 +16805,7 @@ function writePendingInboundMarker(chatId, messageId, chatType, undeliverable =
16698
16805
  function clearTelegramMarkerFileWithHeal(fullPath) {
16699
16806
  let marker = null;
16700
16807
  try {
16701
- marker = JSON.parse(readFileSync3(fullPath, "utf-8"));
16808
+ marker = JSON.parse(readFileSync4(fullPath, "utf-8"));
16702
16809
  } catch {
16703
16810
  }
16704
16811
  if (marker && decideRecoveryHeal({
@@ -16708,7 +16815,7 @@ function clearTelegramMarkerFileWithHeal(fullPath) {
16708
16815
  notifyBackOnline(marker.chat_id);
16709
16816
  }
16710
16817
  try {
16711
- if (existsSync2(fullPath)) unlinkSync3(fullPath);
16818
+ if (existsSync3(fullPath)) unlinkSync4(fullPath);
16712
16819
  } catch {
16713
16820
  }
16714
16821
  }
@@ -16719,9 +16826,9 @@ function clearPendingInboundMarker(chatId, messageId) {
16719
16826
  }
16720
16827
  function readPendingInboundMarker(chatId, messageId) {
16721
16828
  const path = pendingInboundPath(chatId, messageId);
16722
- if (!path || !existsSync2(path)) return null;
16829
+ if (!path || !existsSync3(path)) return null;
16723
16830
  try {
16724
- return JSON.parse(readFileSync3(path, "utf-8"));
16831
+ return JSON.parse(readFileSync4(path, "utf-8"));
16725
16832
  } catch {
16726
16833
  return null;
16727
16834
  }
@@ -16744,7 +16851,7 @@ async function processRecoveryOutboxFile(filename) {
16744
16851
  const fullPath = join4(RECOVERY_OUTBOX_DIR, filename);
16745
16852
  let payload;
16746
16853
  try {
16747
- const raw = readFileSync3(fullPath, "utf-8");
16854
+ const raw = readFileSync4(fullPath, "utf-8");
16748
16855
  payload = JSON.parse(raw);
16749
16856
  } catch (err) {
16750
16857
  process.stderr.write(
@@ -16752,7 +16859,7 @@ async function processRecoveryOutboxFile(filename) {
16752
16859
  `
16753
16860
  );
16754
16861
  try {
16755
- renameSync3(fullPath, `${fullPath}.parse-error.poison`);
16862
+ renameSync4(fullPath, `${fullPath}.parse-error.poison`);
16756
16863
  } catch {
16757
16864
  }
16758
16865
  return;
@@ -16763,7 +16870,7 @@ async function processRecoveryOutboxFile(filename) {
16763
16870
  `
16764
16871
  );
16765
16872
  try {
16766
- renameSync3(fullPath, `${fullPath}.malformed.poison`);
16873
+ renameSync4(fullPath, `${fullPath}.malformed.poison`);
16767
16874
  } catch {
16768
16875
  }
16769
16876
  return;
@@ -16799,7 +16906,7 @@ async function processRecoveryOutboxFile(filename) {
16799
16906
  }
16800
16907
  if (sendSucceeded) {
16801
16908
  try {
16802
- unlinkSync3(fullPath);
16909
+ unlinkSync4(fullPath);
16803
16910
  } catch {
16804
16911
  }
16805
16912
  return;
@@ -16807,7 +16914,7 @@ async function processRecoveryOutboxFile(filename) {
16807
16914
  const next = nextRetryName(filename);
16808
16915
  if (next) {
16809
16916
  try {
16810
- renameSync3(fullPath, join4(RECOVERY_OUTBOX_DIR, next.next));
16917
+ renameSync4(fullPath, join4(RECOVERY_OUTBOX_DIR, next.next));
16811
16918
  if (next.attempt >= MAX_RECOVERY_ATTEMPTS) {
16812
16919
  process.stderr.write(
16813
16920
  `telegram-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
@@ -16859,7 +16966,7 @@ function scanRecoveryRetries() {
16859
16966
  function startRecoveryOutboxWatcher() {
16860
16967
  if (!RECOVERY_OUTBOX_DIR) return;
16861
16968
  try {
16862
- mkdirSync3(RECOVERY_OUTBOX_DIR, { recursive: true, mode: 448 });
16969
+ mkdirSync4(RECOVERY_OUTBOX_DIR, { recursive: true, mode: 448 });
16863
16970
  } catch (err) {
16864
16971
  process.stderr.write(
16865
16972
  `telegram-channel(${AGENT_CODE_NAME}): recovery outbox mkdir failed: ${err.message}
@@ -16877,7 +16984,7 @@ function startRecoveryOutboxWatcher() {
16877
16984
  const watcher = watch(RECOVERY_OUTBOX_DIR, (event, filename) => {
16878
16985
  if (event !== "rename" || !filename) return;
16879
16986
  if (!isFirstAttemptOutboxFile(filename)) return;
16880
- if (existsSync2(join4(RECOVERY_OUTBOX_DIR, filename))) {
16987
+ if (existsSync3(join4(RECOVERY_OUTBOX_DIR, filename))) {
16881
16988
  void processRecoveryOutboxFile(filename);
16882
16989
  }
16883
16990
  });
@@ -16898,7 +17005,7 @@ function trackPendingMessage(chatId, messageId, chatType, undeliverable = false,
16898
17005
  }
16899
17006
  function sweepTelegramStaleMarkers(thresholdMs) {
16900
17007
  if (!PENDING_INBOUND_DIR) return;
16901
- if (!existsSync2(PENDING_INBOUND_DIR)) return;
17008
+ if (!existsSync3(PENDING_INBOUND_DIR)) return;
16902
17009
  let filenames;
16903
17010
  try {
16904
17011
  filenames = readdirSync2(PENDING_INBOUND_DIR);
@@ -16917,14 +17024,14 @@ function sweepTelegramStaleMarkers(thresholdMs) {
16917
17024
  const fullPath = join4(PENDING_INBOUND_DIR, filename);
16918
17025
  let marker;
16919
17026
  try {
16920
- marker = JSON.parse(readFileSync3(fullPath, "utf-8"));
17027
+ marker = JSON.parse(readFileSync4(fullPath, "utf-8"));
16921
17028
  } catch (err) {
16922
17029
  process.stderr.write(
16923
17030
  `telegram-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactId(filename)}: ${err.message}
16924
17031
  `
16925
17032
  );
16926
17033
  try {
16927
- unlinkSync3(fullPath);
17034
+ unlinkSync4(fullPath);
16928
17035
  } catch {
16929
17036
  }
16930
17037
  cleared++;
@@ -16933,7 +17040,7 @@ function sweepTelegramStaleMarkers(thresholdMs) {
16933
17040
  const { chat_id, message_id, received_at } = marker;
16934
17041
  if (!chat_id || !message_id || isPendingMarkerStale(received_at, now, thresholdMs)) {
16935
17042
  try {
16936
- unlinkSync3(fullPath);
17043
+ unlinkSync4(fullPath);
16937
17044
  } catch {
16938
17045
  }
16939
17046
  cleared++;
@@ -16956,14 +17063,14 @@ var orphanSweepTimer = setInterval(() => {
16956
17063
  orphanSweepTimer.unref?.();
16957
17064
  var lastGiveUpHandledAtMs = null;
16958
17065
  function listPendingInboundChatIds() {
16959
- if (!PENDING_INBOUND_DIR || !existsSync2(PENDING_INBOUND_DIR)) return [];
17066
+ if (!PENDING_INBOUND_DIR || !existsSync3(PENDING_INBOUND_DIR)) return [];
16960
17067
  const chats = /* @__PURE__ */ new Set();
16961
17068
  try {
16962
17069
  for (const name of readdirSync2(PENDING_INBOUND_DIR)) {
16963
17070
  if (!name.endsWith(".json")) continue;
16964
17071
  try {
16965
17072
  const marker = JSON.parse(
16966
- readFileSync3(join4(PENDING_INBOUND_DIR, name), "utf8")
17073
+ readFileSync4(join4(PENDING_INBOUND_DIR, name), "utf8")
16967
17074
  );
16968
17075
  if (typeof marker.chat_id === "string" && marker.chat_id) chats.add(marker.chat_id);
16969
17076
  } catch {
@@ -17082,7 +17189,7 @@ function clearPendingMessage(chatId, messageId) {
17082
17189
  clearPendingInboundMarker(chatId, messageId);
17083
17190
  return;
17084
17191
  }
17085
- if (!PENDING_INBOUND_DIR || !existsSync2(PENDING_INBOUND_DIR)) return;
17192
+ if (!PENDING_INBOUND_DIR || !existsSync3(PENDING_INBOUND_DIR)) return;
17086
17193
  const safeChatId = chatId.replace(/[^A-Za-z0-9_-]/g, "_");
17087
17194
  const prefix = `${safeChatId}__`;
17088
17195
  let filenames;
@@ -17693,7 +17800,7 @@ await mcp.connect(new StdioServerTransport());
17693
17800
  var REPLAY_SCAN_INTERVAL_MS = 6e4;
17694
17801
  async function replayPendingTelegramMarkers() {
17695
17802
  if (!channelReplayEnabled()) return;
17696
- if (!PENDING_INBOUND_DIR || !existsSync2(PENDING_INBOUND_DIR)) return;
17803
+ if (!PENDING_INBOUND_DIR || !existsSync3(PENDING_INBOUND_DIR)) return;
17697
17804
  const probe = process.env.TMUX && AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? probeAgentSessionCached(AGENT_CODE_NAME) : { tmux: "unknown", claude: "unknown" };
17698
17805
  const sessionAlive = probe.tmux === "alive" && probe.claude === "alive";
17699
17806
  if (!sessionAlive) return;
@@ -17710,7 +17817,7 @@ async function replayPendingTelegramMarkers() {
17710
17817
  const fullPath = join4(PENDING_INBOUND_DIR, name);
17711
17818
  let marker;
17712
17819
  try {
17713
- marker = JSON.parse(readFileSync3(fullPath, "utf-8"));
17820
+ marker = JSON.parse(readFileSync4(fullPath, "utf-8"));
17714
17821
  } catch {
17715
17822
  continue;
17716
17823
  }
@@ -17742,12 +17849,12 @@ async function replayPendingTelegramMarkers() {
17742
17849
  continue;
17743
17850
  }
17744
17851
  try {
17745
- if (existsSync2(path)) {
17852
+ if (existsSync3(path)) {
17746
17853
  const updated = {
17747
17854
  ...marker,
17748
17855
  replay_count: (marker.replay_count ?? 0) + 1
17749
17856
  };
17750
- writeFileSync3(path, JSON.stringify(updated), { mode: 384 });
17857
+ writeFileSync4(path, JSON.stringify(updated), { mode: 384 });
17751
17858
  }
17752
17859
  } catch {
17753
17860
  }
@@ -17906,7 +18013,9 @@ async function pollLoop() {
17906
18013
  if (disposition === "act") {
17907
18014
  await handleRestartCommand({
17908
18015
  chatId,
17909
- messageId: String(msg.message_id)
18016
+ messageId: String(msg.message_id),
18017
+ // ENG-6194: first_name personalises the back-online confirmation.
18018
+ requesterName: msg.from?.first_name?.trim() || void 0
17910
18019
  });
17911
18020
  } else if (disposition === "verification_failed") {
17912
18021
  try {
@@ -18229,6 +18338,7 @@ void (async () => {
18229
18338
  }
18230
18339
  }
18231
18340
  })();
18341
+ void notifyRestartCompleteOnBoot();
18232
18342
  pollLoop().catch((err) => {
18233
18343
  process.stderr.write(
18234
18344
  `telegram-channel(${AGENT_CODE_NAME}): poll loop died: ${err.message}
@@ -25,8 +25,8 @@ import {
25
25
  takeAcpxExecFailureCount,
26
26
  takeZombieDetection,
27
27
  writePersistentClaudeWrapper
28
- } from "./chunk-AZEYTJ4L.js";
29
- import "./chunk-Z6JJRLHH.js";
28
+ } from "./chunk-QON5CU3L.js";
29
+ import "./chunk-MH7HA6QV.js";
30
30
  import "./chunk-XWVM4KPK.js";
31
31
  export {
32
32
  SEND_KEYS_ENTER_DELAY_MS,
@@ -56,4 +56,4 @@ export {
56
56
  takeZombieDetection,
57
57
  writePersistentClaudeWrapper
58
58
  };
59
- //# sourceMappingURL=persistent-session-YWGDREIZ.js.map
59
+ //# sourceMappingURL=persistent-session-PJQZYG2L.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  paneLogPath
3
- } from "./chunk-AZEYTJ4L.js";
4
- import "./chunk-Z6JJRLHH.js";
3
+ } from "./chunk-QON5CU3L.js";
4
+ import "./chunk-MH7HA6QV.js";
5
5
  import "./chunk-XWVM4KPK.js";
6
6
 
7
7
  // src/lib/responsiveness-probe.ts
@@ -154,4 +154,4 @@ export {
154
154
  livePendingInboundOldestAgeSeconds,
155
155
  oldestLivePendingInboundMtimeMs
156
156
  };
157
- //# sourceMappingURL=responsiveness-probe-6YYCQAFI.js.map
157
+ //# sourceMappingURL=responsiveness-probe-MGMZQSP7.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.27.125",
3
+ "version": "0.27.127",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {