@integrity-labs/agt-cli 0.28.1020 → 0.28.1022

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.
@@ -39287,10 +39287,55 @@ function decideBusyAck(i) {
39287
39287
  const paneFreshThreshold = i.paneFreshThresholdMs ?? ACK_PANE_FRESH_THRESHOLD_MS;
39288
39288
  return i.paneLogFreshAgeMs != null && i.paneLogFreshAgeMs <= paneFreshThreshold;
39289
39289
  }
39290
- function busyAckNoticeText() {
39290
+ function busyAckNoticeText(usageLimit) {
39291
+ if (usageLimit) return giveUpNoticeText("usage_limit", usageLimit.resetsHint);
39291
39292
  return "\u{1F6E0}\uFE0F I'm in the middle of something right now \u2014 I'll follow up on this as soon as I'm free.";
39292
39293
  }
39294
+ var GIVE_UP_SIGNAL_FILENAME = "watchdog-give-up.json";
39293
39295
  var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
39296
+ function readGiveUpSignal(path, now = Date.now()) {
39297
+ if (!path) return null;
39298
+ try {
39299
+ const raw = JSON.parse(readFileSync7(path, "utf8"));
39300
+ if (typeof raw.gave_up_at !== "string") return null;
39301
+ const t = Date.parse(raw.gave_up_at);
39302
+ if (!Number.isFinite(t) || t > now) return null;
39303
+ const reason = raw.reason === "transient_overload" ? "transient_overload" : raw.reason === "usage_limit" ? "usage_limit" : null;
39304
+ const hint = typeof raw.resets_hint === "string" && raw.resets_hint.trim().length > 0 ? raw.resets_hint.trim().slice(0, 40) : null;
39305
+ return { atMs: t, reason, resetsHint: hint };
39306
+ } catch {
39307
+ return null;
39308
+ }
39309
+ }
39310
+ var USAGE_LIMIT_LIVE_WINDOW_MS = 3 * 6e4;
39311
+ function readUsageLimitForBusyAck(agentDir, now = Date.now()) {
39312
+ if (!agentDir) return null;
39313
+ const path = join7(agentDir, GIVE_UP_SIGNAL_FILENAME);
39314
+ const sig = readGiveUpSignal(path, now);
39315
+ if (sig?.reason !== "usage_limit") return null;
39316
+ let lastSeenMs = null;
39317
+ try {
39318
+ const raw = JSON.parse(readFileSync7(path, "utf8"));
39319
+ if (typeof raw.usage_limit_last_seen_at === "string") {
39320
+ const t = Date.parse(raw.usage_limit_last_seen_at);
39321
+ if (Number.isFinite(t) && t <= now) lastSeenMs = t;
39322
+ }
39323
+ } catch {
39324
+ return null;
39325
+ }
39326
+ if (lastSeenMs === null) return null;
39327
+ if (now - lastSeenMs > USAGE_LIMIT_LIVE_WINDOW_MS) return null;
39328
+ return { resetsHint: sig.resetsHint };
39329
+ }
39330
+ function giveUpNoticeText(reason = null, resetsHint = null) {
39331
+ if (reason === "usage_limit") {
39332
+ return resetsHint ? `\u23F3 I've reached my usage limit for now, so I can't reply until ${resetsHint}. Your message is queued \u2014 I'll pick it up then, no need to resend.` : "\u23F3 I've reached my usage limit for now, so I can't reply just yet. Your message is queued \u2014 I'll pick it up as soon as it lifts, no need to resend.";
39333
+ }
39334
+ if (reason === "transient_overload") {
39335
+ return "\u26A0\uFE0F I hit a brief overload and couldn\u2019t finish your last message \u2014 please resend it in a moment.";
39336
+ }
39337
+ return "\u26A0\uFE0F I couldn't read your last message \u2014 please resend it.";
39338
+ }
39294
39339
  function turnFailedNoticeText(failureClass) {
39295
39340
  const cause = failureClass === "overloaded" ? "the service I run on is overloaded right now \u2014 nothing to do with you or what you asked for" : failureClass === "server_error" ? "something upstream of me is failing right now \u2014 nothing to do with you or what you asked for" : null;
39296
39341
  if (cause === null) {
@@ -41263,7 +41308,10 @@ function postDirectChatBusyAckNotice(sessionId) {
41263
41308
  }
41264
41309
  lastBusyAckNoticeAt.set(sessionId, now);
41265
41310
  void (async () => {
41266
- const ok = await postDirectChatNoticeMessage(sessionId, busyAckNoticeText());
41311
+ const ok = await postDirectChatNoticeMessage(
41312
+ sessionId,
41313
+ busyAckNoticeText(readUsageLimitForBusyAck(DIRECT_CHAT_CODE_NAME_AGENT_DIR))
41314
+ );
41267
41315
  if (!ok) {
41268
41316
  lastBusyAckNoticeAt.delete(sessionId);
41269
41317
  process.stderr.write(
@@ -39967,7 +39967,8 @@ function decideBusyAck(i) {
39967
39967
  const paneFreshThreshold = i.paneFreshThresholdMs ?? ACK_PANE_FRESH_THRESHOLD_MS;
39968
39968
  return i.paneLogFreshAgeMs != null && i.paneLogFreshAgeMs <= paneFreshThreshold;
39969
39969
  }
39970
- function busyAckNoticeText() {
39970
+ function busyAckNoticeText(usageLimit) {
39971
+ if (usageLimit) return giveUpNoticeText("usage_limit", usageLimit.resetsHint);
39971
39972
  return "\u{1F6E0}\uFE0F I'm in the middle of something right now \u2014 I'll follow up on this as soon as I'm free.";
39972
39973
  }
39973
39974
  var GIVE_UP_SIGNAL_FILENAME = "watchdog-give-up.json";
@@ -39986,6 +39987,26 @@ function readGiveUpSignal(path, now = Date.now()) {
39986
39987
  return null;
39987
39988
  }
39988
39989
  }
39990
+ var USAGE_LIMIT_LIVE_WINDOW_MS = 3 * 6e4;
39991
+ function readUsageLimitForBusyAck(agentDir, now = Date.now()) {
39992
+ if (!agentDir) return null;
39993
+ const path = join3(agentDir, GIVE_UP_SIGNAL_FILENAME);
39994
+ const sig = readGiveUpSignal(path, now);
39995
+ if (sig?.reason !== "usage_limit") return null;
39996
+ let lastSeenMs = null;
39997
+ try {
39998
+ const raw = JSON.parse(readFileSync3(path, "utf8"));
39999
+ if (typeof raw.usage_limit_last_seen_at === "string") {
40000
+ const t = Date.parse(raw.usage_limit_last_seen_at);
40001
+ if (Number.isFinite(t) && t <= now) lastSeenMs = t;
40002
+ }
40003
+ } catch {
40004
+ return null;
40005
+ }
40006
+ if (lastSeenMs === null) return null;
40007
+ if (now - lastSeenMs > USAGE_LIMIT_LIVE_WINDOW_MS) return null;
40008
+ return { resetsHint: sig.resetsHint };
40009
+ }
39989
40010
  function decideGiveUpNotice(input) {
39990
40011
  const maxAge = input.maxAgeMs ?? GIVE_UP_SIGNAL_MAX_AGE_MS;
39991
40012
  if (input.signalAtMs == null) return false;
@@ -45435,7 +45456,8 @@ function postBusyAckNotice(channel, threadTs, isThreadReply) {
45435
45456
  },
45436
45457
  body: JSON.stringify({
45437
45458
  channel,
45438
- text: busyAckNoticeText(),
45459
+ // ENG-10972: say RATE-LIMITED rather than "busy" when that is the truth.
45460
+ text: busyAckNoticeText(readUsageLimitForBusyAck(SLACK_AGENT_DIR)),
45439
45461
  ...threadTs ? { thread_ts: threadTs } : {}
45440
45462
  }),
45441
45463
  // Bound the request so a hung Slack call can't dangle to the platform
@@ -42689,7 +42689,8 @@ function decideBusyAck(i) {
42689
42689
  const paneFreshThreshold = i.paneFreshThresholdMs ?? ACK_PANE_FRESH_THRESHOLD_MS;
42690
42690
  return i.paneLogFreshAgeMs != null && i.paneLogFreshAgeMs <= paneFreshThreshold;
42691
42691
  }
42692
- function busyAckNoticeText() {
42692
+ function busyAckNoticeText(usageLimit) {
42693
+ if (usageLimit) return giveUpNoticeText("usage_limit", usageLimit.resetsHint);
42693
42694
  return "\u{1F6E0}\uFE0F I'm in the middle of something right now \u2014 I'll follow up on this as soon as I'm free.";
42694
42695
  }
42695
42696
  var GIVE_UP_SIGNAL_FILENAME = "watchdog-give-up.json";
@@ -42708,6 +42709,26 @@ function readGiveUpSignal(path, now = Date.now()) {
42708
42709
  return null;
42709
42710
  }
42710
42711
  }
42712
+ var USAGE_LIMIT_LIVE_WINDOW_MS = 3 * 6e4;
42713
+ function readUsageLimitForBusyAck(agentDir, now = Date.now()) {
42714
+ if (!agentDir) return null;
42715
+ const path = join15(agentDir, GIVE_UP_SIGNAL_FILENAME);
42716
+ const sig = readGiveUpSignal(path, now);
42717
+ if (sig?.reason !== "usage_limit") return null;
42718
+ let lastSeenMs = null;
42719
+ try {
42720
+ const raw = JSON.parse(readFileSync13(path, "utf8"));
42721
+ if (typeof raw.usage_limit_last_seen_at === "string") {
42722
+ const t = Date.parse(raw.usage_limit_last_seen_at);
42723
+ if (Number.isFinite(t) && t <= now) lastSeenMs = t;
42724
+ }
42725
+ } catch {
42726
+ return null;
42727
+ }
42728
+ if (lastSeenMs === null) return null;
42729
+ if (now - lastSeenMs > USAGE_LIMIT_LIVE_WINDOW_MS) return null;
42730
+ return { resetsHint: sig.resetsHint };
42731
+ }
42711
42732
  function decideGiveUpNotice(input) {
42712
42733
  const maxAge = input.maxAgeMs ?? GIVE_UP_SIGNAL_MAX_AGE_MS;
42713
42734
  if (input.signalAtMs == null) return false;
@@ -43541,7 +43562,8 @@ function postBusyAckNotice(chatId, messageId) {
43541
43562
  "sendMessage",
43542
43563
  {
43543
43564
  chat_id: chatId,
43544
- text: busyAckNoticeText(),
43565
+ // ENG-10972: say RATE-LIMITED rather than "busy" when that is the truth.
43566
+ text: busyAckNoticeText(readUsageLimitForBusyAck(TELEGRAM_AGENT_DIR)),
43545
43567
  reply_to_message_id: Number(messageId),
43546
43568
  allow_sending_without_reply: true
43547
43569
  },
@@ -65,7 +65,7 @@ import {
65
65
  writeDirectChatSessionState,
66
66
  writeEgressAllowlist,
67
67
  writePersistentClaudeWrapper
68
- } from "./chunk-CVQDMHOP.js";
68
+ } from "./chunk-QXJWRE64.js";
69
69
  import "./chunk-X7SX25N6.js";
70
70
  import "./chunk-DHWNVVX4.js";
71
71
  import "./chunk-XWVM4KPK.js";
@@ -139,4 +139,4 @@ export {
139
139
  writeEgressAllowlist,
140
140
  writePersistentClaudeWrapper
141
141
  };
142
- //# sourceMappingURL=persistent-session-UZBB7EOS.js.map
142
+ //# sourceMappingURL=persistent-session-ZQDNCKQH.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  paneLogPath
3
- } from "./chunk-CVQDMHOP.js";
3
+ } from "./chunk-QXJWRE64.js";
4
4
  import "./chunk-X7SX25N6.js";
5
5
  import "./chunk-DHWNVVX4.js";
6
6
  import "./chunk-XWVM4KPK.js";
@@ -802,4 +802,4 @@ export {
802
802
  readAndResetSlackReplyBindingClassifications,
803
803
  readAndResetSlackReplyTargetClassifications
804
804
  };
805
- //# sourceMappingURL=responsiveness-probe-KLOUFBM5.js.map
805
+ //# sourceMappingURL=responsiveness-probe-Q27WU2MW.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.1020",
3
+ "version": "0.28.1022",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {