@integrity-labs/agt-cli 0.28.1192 → 0.28.1193

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.
package/dist/bin/agt.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  success,
41
41
  table,
42
42
  warn
43
- } from "../chunk-TCPX64GU.js";
43
+ } from "../chunk-ZTA7AGKM.js";
44
44
  import {
45
45
  getProjectDir,
46
46
  isSessionResumeDisabled,
@@ -5200,7 +5200,7 @@ import { execFileSync, execSync } from "child_process";
5200
5200
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
5201
5201
  import chalk17 from "chalk";
5202
5202
  import ora15 from "ora";
5203
- var cliVersion = true ? "0.28.1192" : "dev";
5203
+ var cliVersion = true ? "0.28.1193" : "dev";
5204
5204
  async function fetchLatestVersion() {
5205
5205
  const host2 = getHost();
5206
5206
  if (!host2) return null;
@@ -6460,7 +6460,7 @@ function handleError(err) {
6460
6460
  }
6461
6461
 
6462
6462
  // src/bin/agt.ts
6463
- var cliVersion2 = true ? "0.28.1192" : "dev";
6463
+ var cliVersion2 = true ? "0.28.1193" : "dev";
6464
6464
  var program = new Command();
6465
6465
  program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
6466
6466
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -8081,7 +8081,7 @@ function exchangeFailureKind(err) {
8081
8081
  }
8082
8082
 
8083
8083
  // src/lib/api-client.ts
8084
- var agtCliVersion = true ? "0.28.1192" : "dev";
8084
+ var agtCliVersion = true ? "0.28.1193" : "dev";
8085
8085
  var lastConfigHash = null;
8086
8086
  function setConfigHash(hash) {
8087
8087
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -13649,4 +13649,4 @@ export {
13649
13649
  managerInstallSystemUnitCommand,
13650
13650
  managerUninstallSystemUnitCommand
13651
13651
  };
13652
- //# sourceMappingURL=chunk-TCPX64GU.js.map
13652
+ //# sourceMappingURL=chunk-ZTA7AGKM.js.map
@@ -83,7 +83,7 @@ import {
83
83
  tripClass,
84
84
  writeEtcEnvironment,
85
85
  writeProfileDScript
86
- } from "../chunk-TCPX64GU.js";
86
+ } from "../chunk-ZTA7AGKM.js";
87
87
  import {
88
88
  CLAUDE_CODE_SECURITY_FLOOR,
89
89
  SELF_UPDATE_TIMEOUTS,
@@ -16297,7 +16297,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
16297
16297
  var lastVersionCheckAt = 0;
16298
16298
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
16299
16299
  var lastResponsivenessProbeAt = 0;
16300
- var agtCliVersion = true ? "0.28.1192" : "dev";
16300
+ var agtCliVersion = true ? "0.28.1193" : "dev";
16301
16301
  function resolveBrewPath(execFileSync3) {
16302
16302
  try {
16303
16303
  const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -47673,6 +47673,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
47673
47673
  let oldest = null;
47674
47674
  for (const name of names) {
47675
47675
  if (!name.endsWith(".json")) continue;
47676
+ if (opts?.exclude?.(name)) continue;
47676
47677
  let receivedAt;
47677
47678
  try {
47678
47679
  const raw = JSON.parse(readFileSync9(join10(dir, name), "utf-8"));
@@ -47691,8 +47692,8 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
47691
47692
  }
47692
47693
  return oldest;
47693
47694
  }
47694
- function hasInFlightInbound(dir, now = Date.now()) {
47695
- return oldestPendingMarkerAgeMs(dir, now, { includeSeen: true }) != null;
47695
+ function hasInFlightInbound(dir, now = Date.now(), opts) {
47696
+ return oldestPendingMarkerAgeMs(dir, now, { includeSeen: true, exclude: opts?.exclude }) != null;
47696
47697
  }
47697
47698
  function channelOrphanMarkerMs() {
47698
47699
  const raw = parseInt(process.env.AGT_CHANNEL_ORPHAN_MARKER_MS ?? "", 10);
@@ -41680,6 +41680,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
41680
41680
  let oldest = null;
41681
41681
  for (const name of names) {
41682
41682
  if (!name.endsWith(".json")) continue;
41683
+ if (opts?.exclude?.(name)) continue;
41683
41684
  let receivedAt;
41684
41685
  try {
41685
41686
  const raw = JSON.parse(readFileSync3(join3(dir, name), "utf-8"));
@@ -41698,8 +41699,8 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
41698
41699
  }
41699
41700
  return oldest;
41700
41701
  }
41701
- function hasInFlightInbound(dir, now = Date.now()) {
41702
- return oldestPendingMarkerAgeMs(dir, now, { includeSeen: true }) != null;
41702
+ function hasInFlightInbound(dir, now = Date.now(), opts) {
41703
+ return oldestPendingMarkerAgeMs(dir, now, { includeSeen: true, exclude: opts?.exclude }) != null;
41703
41704
  }
41704
41705
  function isPendingMarkerStale(receivedAt, nowMs, thresholdMs) {
41705
41706
  if (!receivedAt) return true;
@@ -43772,13 +43772,63 @@ function markerArrivalMs(fullPath) {
43772
43772
  return Number.POSITIVE_INFINITY;
43773
43773
  }
43774
43774
  }
43775
- function clearAllTelegramPendingMarkersForChat(pendingDir, chatId, clearMarkerFile, cutoffMs = Number.POSITIVE_INFINITY) {
43776
- return applyToChatMarkers(pendingDir, chatId, clearMarkerFile, cutoffMs);
43775
+ function clearAllTelegramPendingMarkersForChat(pendingDir, chatId, clearMarkerFile, cutoffMs = Number.POSITIVE_INFINITY, reachedSession) {
43776
+ return applyToChatMarkers(pendingDir, chatId, clearMarkerFile, cutoffMs, reachedSession);
43777
43777
  }
43778
- function markSeenAllTelegramPendingMarkersForChat(pendingDir, chatId, markSeen, cutoffMs = Number.POSITIVE_INFINITY) {
43779
- return applyToChatMarkers(pendingDir, chatId, markSeen, cutoffMs);
43778
+ function markSeenAllTelegramPendingMarkersForChat(pendingDir, chatId, markSeen, cutoffMs = Number.POSITIVE_INFINITY, reachedSession) {
43779
+ return applyToChatMarkers(pendingDir, chatId, markSeen, cutoffMs, reachedSession);
43780
43780
  }
43781
- function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
43781
+ function markerDrainable(i) {
43782
+ return i.pushedThisSession || !i.replayEnabled || !i.hasPayload;
43783
+ }
43784
+ function readFailureMeansNoPayload(err) {
43785
+ return err instanceof SyntaxError || err?.code === "ENOENT";
43786
+ }
43787
+ function markerMayDrain(i) {
43788
+ let hasPayload = false;
43789
+ try {
43790
+ if (i.dir) {
43791
+ const read = i.read ?? ((path) => readFileSync11(path, "utf-8"));
43792
+ hasPayload = Boolean(JSON.parse(read(join13(i.dir, i.filename))).payload);
43793
+ }
43794
+ } catch (err) {
43795
+ hasPayload = !readFailureMeansNoPayload(err);
43796
+ }
43797
+ return markerDrainable({ pushedThisSession: i.pushedThisSession, replayEnabled: i.replayEnabled, hasPayload });
43798
+ }
43799
+ function createSessionMarkerTracker() {
43800
+ const pushed = /* @__PURE__ */ new Set();
43801
+ const held = /* @__PURE__ */ new Set();
43802
+ return {
43803
+ /** The marker's push went to this session. Also ends any hold. */
43804
+ notePushed(filename) {
43805
+ pushed.add(filename);
43806
+ held.delete(filename);
43807
+ },
43808
+ /** The marker's file is gone. Its name won't come back, so stop tracking it. */
43809
+ release(filename) {
43810
+ pushed.delete(filename);
43811
+ held.delete(filename);
43812
+ },
43813
+ wasPushed(filename) {
43814
+ return pushed.has(filename);
43815
+ },
43816
+ /** {@link markerMayDrain}, recording a hold when the answer is no. */
43817
+ mayDrain(i) {
43818
+ const may = markerMayDrain({ ...i, pushedThisSession: pushed.has(i.filename) });
43819
+ if (may) held.delete(i.filename);
43820
+ else held.add(i.filename);
43821
+ return may;
43822
+ },
43823
+ isHeld(filename) {
43824
+ return held.has(filename);
43825
+ }
43826
+ };
43827
+ }
43828
+ function replayCountForSession(i) {
43829
+ return i.pushedThisSession ? i.replayCount : 0;
43830
+ }
43831
+ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs, reachedSession) {
43782
43832
  const prefix = `${chatId.replace(/[^A-Za-z0-9_-]/g, "_")}__`;
43783
43833
  const bounded = Number.isFinite(cutoffMs);
43784
43834
  let filenames;
@@ -43791,6 +43841,7 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
43791
43841
  for (const filename of filenames) {
43792
43842
  if (!filename.startsWith(prefix)) continue;
43793
43843
  if (!filename.endsWith(".json")) continue;
43844
+ if (reachedSession && !reachedSession(filename)) continue;
43794
43845
  const fullPath = join13(pendingDir, filename);
43795
43846
  if (bounded && markerArrivalMs(fullPath) > cutoffMs) continue;
43796
43847
  op(fullPath);
@@ -44584,6 +44635,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
44584
44635
  let oldest = null;
44585
44636
  for (const name of names) {
44586
44637
  if (!name.endsWith(".json")) continue;
44638
+ if (opts?.exclude?.(name)) continue;
44587
44639
  let receivedAt;
44588
44640
  try {
44589
44641
  const raw = JSON.parse(readFileSync14(join17(dir, name), "utf-8"));
@@ -44602,8 +44654,8 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
44602
44654
  }
44603
44655
  return oldest;
44604
44656
  }
44605
- function hasInFlightInbound(dir, now = Date.now()) {
44606
- return oldestPendingMarkerAgeMs(dir, now, { includeSeen: true }) != null;
44657
+ function hasInFlightInbound(dir, now = Date.now(), opts) {
44658
+ return oldestPendingMarkerAgeMs(dir, now, { includeSeen: true, exclude: opts?.exclude }) != null;
44607
44659
  }
44608
44660
  function isPendingMarkerStale(receivedAt, nowMs, thresholdMs) {
44609
44661
  if (!receivedAt) return true;
@@ -46342,6 +46394,17 @@ async function notifyDmUsersOnChannelAddRestart() {
46342
46394
  );
46343
46395
  }
46344
46396
  }
46397
+ var sessionMarkers = createSessionMarkerTracker();
46398
+ function noteMarkerAnsweredByRecovery(markerFilename) {
46399
+ if (markerFilename) sessionMarkers.notePushed(markerFilename);
46400
+ }
46401
+ function markerReachedThisSession(markerFilename) {
46402
+ return sessionMarkers.mayDrain({
46403
+ dir: PENDING_INBOUND_DIR,
46404
+ filename: markerFilename,
46405
+ replayEnabled: channelReplayEnabled()
46406
+ });
46407
+ }
46345
46408
  function safeMarkerName(chatId, messageId) {
46346
46409
  const safe = (s) => s.replace(/[^A-Za-z0-9_-]/g, "_");
46347
46410
  return `${safe(chatId)}__${safe(messageId)}.json`;
@@ -46410,6 +46473,7 @@ function clearTelegramMarkerFileWithHeal(fullPath) {
46410
46473
  }
46411
46474
  try {
46412
46475
  if (existsSync9(fullPath)) unlinkSync8(fullPath);
46476
+ sessionMarkers.release(basename(fullPath));
46413
46477
  } catch {
46414
46478
  }
46415
46479
  }
@@ -46424,6 +46488,7 @@ function clearTelegramMarkerFileSilently(fullPath) {
46424
46488
  }
46425
46489
  try {
46426
46490
  if (existsSync9(fullPath)) unlinkSync8(fullPath);
46491
+ sessionMarkers.release(basename(fullPath));
46427
46492
  } catch {
46428
46493
  }
46429
46494
  }
@@ -46564,6 +46629,7 @@ async function processRecoveryOutboxFile(filename) {
46564
46629
  }) + "\n"
46565
46630
  );
46566
46631
  if (decision.action === "suppress") {
46632
+ noteMarkerAnsweredByRecovery(payload.marker_name);
46567
46633
  clearPendingMessage(payload.chat_id, recoveryDrainCutoffMs);
46568
46634
  removeRecoveryLedgerEntry(RECOVERY_LEDGER_DIR, payload.marker_name);
46569
46635
  try {
@@ -46588,6 +46654,7 @@ async function processRecoveryOutboxFile(filename) {
46588
46654
  `telegram-channel(${AGENT_CODE_NAME}): ghost-reply recovery sent (chat=${redactId(payload.chat_id)} msg=${redactId(payload.message_id ?? "")})
46589
46655
  `
46590
46656
  );
46657
+ noteMarkerAnsweredByRecovery(payload.marker_name);
46591
46658
  clearPendingMessage(payload.chat_id, recoveryDrainCutoffMs);
46592
46659
  } else {
46593
46660
  process.stderr.write(
@@ -46845,6 +46912,7 @@ function sweepTelegramStaleMarkers(thresholdMs) {
46845
46912
  );
46846
46913
  try {
46847
46914
  unlinkSync8(fullPath);
46915
+ sessionMarkers.release(filename);
46848
46916
  } catch {
46849
46917
  }
46850
46918
  cleared++;
@@ -46870,6 +46938,7 @@ function sweepTelegramStaleMarkers(thresholdMs) {
46870
46938
  }
46871
46939
  try {
46872
46940
  unlinkSync8(fullPath);
46941
+ sessionMarkers.release(filename);
46873
46942
  } catch {
46874
46943
  }
46875
46944
  cleared++;
@@ -47240,7 +47309,8 @@ function clearPendingMessage(chatId, cutoffMs = Number.POSITIVE_INFINITY) {
47240
47309
  PENDING_INBOUND_DIR,
47241
47310
  chatId,
47242
47311
  clearTelegramMarkerFileWithHeal,
47243
- cutoffMs
47312
+ cutoffMs,
47313
+ markerReachedThisSession
47244
47314
  );
47245
47315
  }
47246
47316
  function consumePendingMessage(chatId, cutoffMs = Number.POSITIVE_INFINITY) {
@@ -47249,7 +47319,8 @@ function consumePendingMessage(chatId, cutoffMs = Number.POSITIVE_INFINITY) {
47249
47319
  PENDING_INBOUND_DIR,
47250
47320
  chatId,
47251
47321
  clearTelegramMarkerFileSilently,
47252
- cutoffMs
47322
+ cutoffMs,
47323
+ markerReachedThisSession
47253
47324
  );
47254
47325
  }
47255
47326
  function markSeenPendingMessage(chatId, cutoffMs = Number.POSITIVE_INFINITY) {
@@ -47258,7 +47329,8 @@ function markSeenPendingMessage(chatId, cutoffMs = Number.POSITIVE_INFINITY) {
47258
47329
  PENDING_INBOUND_DIR,
47259
47330
  chatId,
47260
47331
  markTelegramMarkerSeenWithHeal,
47261
- cutoffMs
47332
+ cutoffMs,
47333
+ markerReachedThisSession
47262
47334
  );
47263
47335
  }
47264
47336
  function markPromisedPendingMessage(chatId, cutoffMs = Number.POSITIVE_INFINITY) {
@@ -47269,7 +47341,8 @@ function markPromisedPendingMessage(chatId, cutoffMs = Number.POSITIVE_INFINITY)
47269
47341
  PENDING_INBOUND_DIR,
47270
47342
  chatId,
47271
47343
  markTelegramMarkerPromisedWithHeal,
47272
- cutoffMs
47344
+ cutoffMs,
47345
+ markerReachedThisSession
47273
47346
  );
47274
47347
  if (telegramPromiseStampOutcome.attempted > telegramPromiseStampOutcome.stamped) {
47275
47348
  process.stderr.write(
@@ -48277,6 +48350,18 @@ async function ackCallbackQuery(callbackQueryId, text, opts = {}) {
48277
48350
  );
48278
48351
  }
48279
48352
  }
48353
+ var resolveMcpInitialized = () => {
48354
+ };
48355
+ var mcpInitialized = new Promise((resolve3) => {
48356
+ resolveMcpInitialized = resolve3;
48357
+ });
48358
+ mcp.oninitialized = () => {
48359
+ resolveMcpInitialized();
48360
+ };
48361
+ var MCP_INITIALIZED_WAIT_MS = 3e4;
48362
+ function waitForMcpInitialized() {
48363
+ return Promise.race([mcpInitialized, sleep4(MCP_INITIALIZED_WAIT_MS)]);
48364
+ }
48280
48365
  await mcp.connect(new StdioServerTransport());
48281
48366
  var REPLAY_SCAN_INTERVAL_MS = 6e4;
48282
48367
  async function replayPendingTelegramMarkers() {
@@ -48325,7 +48410,10 @@ async function replayPendingTelegramMarkers() {
48325
48410
  hasPayload: Boolean(marker.payload),
48326
48411
  sessionState,
48327
48412
  markerAgeMs: ageMs,
48328
- replayCount: marker.replay_count ?? 0,
48413
+ replayCount: replayCountForSession({
48414
+ pushedThisSession: sessionMarkers.wasPushed(basename(path)),
48415
+ replayCount: marker.replay_count ?? 0
48416
+ }),
48329
48417
  paneFreshAgeMs,
48330
48418
  // ENG-7736: bound the pane-fresh defer (clamped under the orphan
48331
48419
  // window) so a perpetually-fresh pane can't hold off replay until GC.
@@ -48344,6 +48432,7 @@ async function replayPendingTelegramMarkers() {
48344
48432
  method: "notifications/claude/channel",
48345
48433
  params: replayParams
48346
48434
  });
48435
+ sessionMarkers.notePushed(basename(path));
48347
48436
  seedTelegramProgressHeartbeat();
48348
48437
  if (replayPayload.meta?.["source_role"] !== "agent") {
48349
48438
  peerPresence.noteInbound(marker.chat_id, "human", now);
@@ -48986,11 +49075,15 @@ async function pollLoop() {
48986
49075
  tmux: ackProbe.tmux,
48987
49076
  claude: ackProbe.claude,
48988
49077
  withinStartupGrace: process.uptime() * 1e3 < ACK_STARTUP_GRACE_MS,
48989
- oldestPendingAgeMs: oldestPendingMarkerAgeMs(PENDING_INBOUND_DIR),
49078
+ oldestPendingAgeMs: oldestPendingMarkerAgeMs(PENDING_INBOUND_DIR, Date.now(), {
49079
+ exclude: sessionMarkers.isHeld
49080
+ }),
48990
49081
  paneLogFreshAgeMs
48991
49082
  };
48992
49083
  const ackDecision = decideAckReaction(ackInputs);
48993
- const arrivedWhileBusy = hasInFlightInbound(PENDING_INBOUND_DIR);
49084
+ const arrivedWhileBusy = hasInFlightInbound(PENDING_INBOUND_DIR, Date.now(), {
49085
+ exclude: sessionMarkers.isHeld
49086
+ });
48994
49087
  if (ackDecision === "undeliverable") {
48995
49088
  const cause = classifyUndeliverableCause(ackInputs) ?? "unknown";
48996
49089
  recordChannelDeflection(AGENT_DIR, "telegram", cause);
@@ -49079,6 +49172,7 @@ async function pollLoop() {
49079
49172
  method: "notifications/claude/channel",
49080
49173
  params: channelPayload
49081
49174
  });
49175
+ sessionMarkers.notePushed(safeMarkerName(chatId, messageId));
49082
49176
  if (shouldArmWatch({
49083
49177
  isBot: isFromBot || !!peerAgentMeta,
49084
49178
  // Every Telegram inbound that reaches here owes a reply — there is no
@@ -49225,7 +49319,7 @@ void (async () => {
49225
49319
  })();
49226
49320
  void notifyRestartCompleteOnBoot();
49227
49321
  void notifyDmUsersOnChannelAddRestart();
49228
- pollLoop().catch((err) => {
49322
+ waitForMcpInitialized().then(pollLoop).catch((err) => {
49229
49323
  process.stderr.write(
49230
49324
  `telegram-channel(${AGENT_CODE_NAME}): poll loop died: ${err.message}
49231
49325
  `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.1192",
3
+ "version": "0.28.1193",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {