@integrity-labs/agt-cli 0.28.59 → 0.28.61

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.
@@ -14175,7 +14175,39 @@ function resolveHostBooleanFlag(opts) {
14175
14175
  return opts.defaultValue;
14176
14176
  }
14177
14177
 
14178
+ // src/maintenance-mode.ts
14179
+ var FLAG_KEY = "platform-maintenance-mode";
14180
+ var MAINTENANCE_OFFLINE_MESSAGE = "The Augmented Team platform is offline for scheduled maintenance right now, so I can't pick this up \u2014 please try again shortly.";
14181
+ function isMaintenanceModeActive(opts) {
14182
+ return resolveHostBooleanFlag({
14183
+ key: FLAG_KEY,
14184
+ envVar: "",
14185
+ defaultValue: false,
14186
+ cachePath: opts?.cachePath,
14187
+ env: opts?.env
14188
+ });
14189
+ }
14190
+
14191
+ // src/sender-policy-decline.ts
14192
+ function decideDeclineReply(input) {
14193
+ const last = input.cache.get(input.key);
14194
+ if (last !== void 0) {
14195
+ const elapsed = input.now - last;
14196
+ if (elapsed < input.cooldownMs) {
14197
+ return { reply: false, remainingMs: input.cooldownMs - elapsed };
14198
+ }
14199
+ }
14200
+ input.cache.set(input.key, input.now);
14201
+ return { reply: true };
14202
+ }
14203
+
14178
14204
  // src/direct-chat-channel.ts
14205
+ var DIRECT_CHAT_MAINTENANCE_CACHE = /* @__PURE__ */ new Map();
14206
+ var DIRECT_CHAT_MAINTENANCE_COOLDOWN_MS = (() => {
14207
+ const raw = process.env["DIRECT_CHAT_MAINTENANCE_NOTICE_COOLDOWN_SEC"];
14208
+ const n = raw ? Number(raw) : NaN;
14209
+ return Number.isFinite(n) && n >= 0 ? n * 1e3 : 1800 * 1e3;
14210
+ })();
14179
14211
  var AGT_HOST = process.env.AGT_HOST;
14180
14212
  var AGT_API_KEY = process.env.AGT_API_KEY;
14181
14213
  var AGT_AGENT_ID = process.env.AGT_AGENT_ID;
@@ -14434,10 +14466,42 @@ async function pollForMessages(sinceMs) {
14434
14466
  for (const msg of data.messages ?? []) {
14435
14467
  if (processedIds.has(msg.id)) continue;
14436
14468
  const isNotice = msg.kind === "notice";
14437
- if (!isNotice) {
14469
+ const maintenanceActive = !isNotice && isMaintenanceModeActive();
14470
+ if (!isNotice && !maintenanceActive) {
14438
14471
  markProcessed(msg.id);
14439
14472
  claimTracker.track(msg.session_id, msg.id);
14440
14473
  }
14474
+ if (maintenanceActive) {
14475
+ const throttleKey = `${msg.session_id}|maintenance`;
14476
+ const throttle = decideDeclineReply({
14477
+ cache: DIRECT_CHAT_MAINTENANCE_CACHE,
14478
+ key: throttleKey,
14479
+ cooldownMs: DIRECT_CHAT_MAINTENANCE_COOLDOWN_MS,
14480
+ now: Date.now()
14481
+ });
14482
+ const route = throttle.reply ? "/host/direct-chat/reply" : "/host/direct-chat/consume";
14483
+ const body = throttle.reply ? { agent_id: AGT_AGENT_ID, session_id: msg.session_id, content: MAINTENANCE_OFFLINE_MESSAGE, message_ids: [msg.id] } : { agent_id: AGT_AGENT_ID, session_id: msg.session_id, message_ids: [msg.id] };
14484
+ try {
14485
+ const res2 = await apiPost(route, body);
14486
+ const data2 = await res2.json().catch(() => ({}));
14487
+ if (res2.ok && data2.error == null) {
14488
+ markProcessed(msg.id);
14489
+ } else {
14490
+ if (throttle.reply) DIRECT_CHAT_MAINTENANCE_CACHE.delete(throttleKey);
14491
+ process.stderr.write(
14492
+ `direct-chat-channel: maintenance ${throttle.reply ? "reply" : "consume"} failed: ${data2.error ?? `HTTP ${res2.status}`}
14493
+ `
14494
+ );
14495
+ }
14496
+ } catch (err) {
14497
+ if (throttle.reply) DIRECT_CHAT_MAINTENANCE_CACHE.delete(throttleKey);
14498
+ process.stderr.write(
14499
+ `direct-chat-channel: maintenance offline reply failed: ${err.message}
14500
+ `
14501
+ );
14502
+ }
14503
+ continue;
14504
+ }
14441
14505
  await mcp.notification({
14442
14506
  method: "notifications/claude/channel",
14443
14507
  params: {
@@ -14353,6 +14353,56 @@ function decideInboundAccess(input) {
14353
14353
  return { kind: "admit" };
14354
14354
  }
14355
14355
 
14356
+ // src/flags-cache-read.ts
14357
+ import { existsSync, readFileSync } from "fs";
14358
+ import { homedir } from "os";
14359
+ import { join } from "path";
14360
+ function defaultFlagsCachePath() {
14361
+ return join(homedir(), ".augmented", "flags-cache.json");
14362
+ }
14363
+ function envBoolean(raw) {
14364
+ if (raw === void 0) return void 0;
14365
+ const v = raw.trim().toLowerCase();
14366
+ if (v === "") return void 0;
14367
+ if (v === "1" || v === "true" || v === "yes" || v === "on") return true;
14368
+ if (v === "0" || v === "false" || v === "no" || v === "off") return false;
14369
+ return void 0;
14370
+ }
14371
+ function cachedBoolean(key2, path) {
14372
+ try {
14373
+ if (!existsSync(path)) return void 0;
14374
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
14375
+ if (!parsed || typeof parsed !== "object") return void 0;
14376
+ const flags = parsed.flags;
14377
+ if (!flags || typeof flags !== "object") return void 0;
14378
+ const value = flags[key2];
14379
+ return typeof value === "boolean" ? value : void 0;
14380
+ } catch {
14381
+ return void 0;
14382
+ }
14383
+ }
14384
+ function resolveHostBooleanFlag(opts) {
14385
+ const env = opts.env ?? process.env;
14386
+ const envValue = envBoolean(env[opts.envVar]);
14387
+ if (envValue !== void 0) return envValue;
14388
+ const cached2 = cachedBoolean(opts.key, opts.cachePath ?? defaultFlagsCachePath());
14389
+ if (cached2 !== void 0) return cached2;
14390
+ return opts.defaultValue;
14391
+ }
14392
+
14393
+ // src/maintenance-mode.ts
14394
+ var FLAG_KEY = "platform-maintenance-mode";
14395
+ var MAINTENANCE_OFFLINE_MESSAGE = "The Augmented Team platform is offline for scheduled maintenance right now, so I can't pick this up \u2014 please try again shortly.";
14396
+ function isMaintenanceModeActive(opts) {
14397
+ return resolveHostBooleanFlag({
14398
+ key: FLAG_KEY,
14399
+ envVar: "",
14400
+ defaultValue: false,
14401
+ cachePath: opts?.cachePath,
14402
+ env: opts?.env
14403
+ });
14404
+ }
14405
+
14356
14406
  // src/watch-command.ts
14357
14407
  var WATCH_DEFAULT_DURATION_MS = 2 * 60 * 60 * 1e3;
14358
14408
  var WATCH_MAX_DURATION_MS = 7 * 24 * 60 * 60 * 1e3;
@@ -14460,45 +14510,6 @@ function watchSuccessTextSlack(fileId, durationMs, reused) {
14460
14510
  // src/ack-reaction.ts
14461
14511
  import { readdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
14462
14512
  import { join as join2 } from "path";
14463
-
14464
- // src/flags-cache-read.ts
14465
- import { existsSync, readFileSync } from "fs";
14466
- import { homedir } from "os";
14467
- import { join } from "path";
14468
- function defaultFlagsCachePath() {
14469
- return join(homedir(), ".augmented", "flags-cache.json");
14470
- }
14471
- function envBoolean(raw) {
14472
- if (raw === void 0) return void 0;
14473
- const v = raw.trim().toLowerCase();
14474
- if (v === "") return void 0;
14475
- if (v === "1" || v === "true" || v === "yes" || v === "on") return true;
14476
- if (v === "0" || v === "false" || v === "no" || v === "off") return false;
14477
- return void 0;
14478
- }
14479
- function cachedBoolean(key2, path) {
14480
- try {
14481
- if (!existsSync(path)) return void 0;
14482
- const parsed = JSON.parse(readFileSync(path, "utf8"));
14483
- if (!parsed || typeof parsed !== "object") return void 0;
14484
- const flags = parsed.flags;
14485
- if (!flags || typeof flags !== "object") return void 0;
14486
- const value = flags[key2];
14487
- return typeof value === "boolean" ? value : void 0;
14488
- } catch {
14489
- return void 0;
14490
- }
14491
- }
14492
- function resolveHostBooleanFlag(opts) {
14493
- const env = opts.env ?? process.env;
14494
- const envValue = envBoolean(env[opts.envVar]);
14495
- if (envValue !== void 0) return envValue;
14496
- const cached2 = cachedBoolean(opts.key, opts.cachePath ?? defaultFlagsCachePath());
14497
- if (cached2 !== void 0) return cached2;
14498
- return opts.defaultValue;
14499
- }
14500
-
14501
- // src/ack-reaction.ts
14502
14513
  var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
14503
14514
  var ACK_STARTUP_GRACE_MS = 6e4;
14504
14515
  var ACK_PANE_FRESH_THRESHOLD_MS = 6e4;
@@ -16763,8 +16774,52 @@ async function maybeSendSenderPolicyDecline(args) {
16763
16774
  clearTimeout(timeoutId);
16764
16775
  }
16765
16776
  }
16766
- var BLOCK_KIT_ENABLED = process.env.SLACK_BLOCK_KIT_ENABLED === "true";
16767
- var BLOCK_KIT_ASK_USER_ENABLED = process.env.SLACK_BLOCK_KIT_ASK_USER_ENABLED === "true";
16777
+ var SLACK_MAINTENANCE_NOTICE_CACHE = /* @__PURE__ */ new Map();
16778
+ async function maybeSendMaintenanceNotice(args) {
16779
+ if (!BOT_TOKEN) return;
16780
+ if (!args.channel || !args.senderId) return;
16781
+ const key2 = `${args.channel}|${args.senderId}|maintenance`;
16782
+ const decision = decideDeclineReply({
16783
+ cache: SLACK_MAINTENANCE_NOTICE_CACHE,
16784
+ key: key2,
16785
+ cooldownMs: SLACK_POLICY_DECLINE_COOLDOWN_MS,
16786
+ now: Date.now()
16787
+ });
16788
+ if (!decision.reply) {
16789
+ process.stderr.write(
16790
+ `slack-channel(${AGENT_CODE_NAME}): maintenance notice suppressed by cooldown (channel=${redactSlackId(args.channel)}, sender=${redactSlackId(args.senderId)}, remaining=${decision.remainingMs}ms)
16791
+ `
16792
+ );
16793
+ return;
16794
+ }
16795
+ const controller = new AbortController();
16796
+ const timeoutId = setTimeout(() => controller.abort(), 1e4);
16797
+ try {
16798
+ const res = await fetch("https://slack.com/api/chat.postMessage", {
16799
+ method: "POST",
16800
+ signal: controller.signal,
16801
+ headers: {
16802
+ "Content-Type": "application/json",
16803
+ Authorization: `Bearer ${BOT_TOKEN}`
16804
+ },
16805
+ body: JSON.stringify({
16806
+ channel: args.channel,
16807
+ text: MAINTENANCE_OFFLINE_MESSAGE,
16808
+ ...args.threadTs ? { thread_ts: args.threadTs } : {}
16809
+ })
16810
+ });
16811
+ const data = await res.json();
16812
+ if (!data.ok) {
16813
+ SLACK_MAINTENANCE_NOTICE_CACHE.delete(key2);
16814
+ process.stderr.write(
16815
+ `slack-channel(${AGENT_CODE_NAME}): maintenance notice post failed: ${data.error ?? "unknown"}
16816
+ `
16817
+ );
16818
+ }
16819
+ } finally {
16820
+ clearTimeout(timeoutId);
16821
+ }
16822
+ }
16768
16823
  var BLOCK_KIT_DISABLED = process.env.SLACK_BLOCK_KIT_DISABLED === "true";
16769
16824
  var ALLOWED_USERS = parseAllowedUsersCsv(process.env.SLACK_ALLOWED_USERS);
16770
16825
  var THREAD_AUTO_FOLLOW = process.env.SLACK_THREAD_AUTO_FOLLOW ?? "off";
@@ -19155,10 +19210,10 @@ async function handleChannelInfo(args) {
19155
19210
  };
19156
19211
  }
19157
19212
  function blockKitToolsAvailable() {
19158
- return BLOCK_KIT_ENABLED && !BLOCK_KIT_DISABLED;
19213
+ return !BLOCK_KIT_DISABLED;
19159
19214
  }
19160
19215
  function askUserToolAvailable() {
19161
- return blockKitToolsAvailable() && BLOCK_KIT_ASK_USER_ENABLED && Boolean(AGT_HOST && AGT_API_KEY && AGT_AGENT_ID);
19216
+ return blockKitToolsAvailable() && Boolean(AGT_HOST && AGT_API_KEY && AGT_AGENT_ID);
19162
19217
  }
19163
19218
  function interactiveHostAvailable() {
19164
19219
  return blockKitToolsAvailable() && Boolean(AGT_HOST && AGT_API_KEY && AGT_AGENT_ID);
@@ -19203,7 +19258,7 @@ async function getPermalink(channel, ts) {
19203
19258
  async function handleSendStructured(args) {
19204
19259
  if (!blockKitToolsAvailable()) {
19205
19260
  return {
19206
- content: [{ type: "text", text: "slack.send_structured is disabled by team configuration." }],
19261
+ content: [{ type: "text", text: "slack.send_structured is disabled by the SLACK_BLOCK_KIT_DISABLED fleet kill switch." }],
19207
19262
  isError: true
19208
19263
  };
19209
19264
  }
@@ -19951,6 +20006,23 @@ async function connectSocketMode() {
19951
20006
  }
19952
20007
  return;
19953
20008
  }
20009
+ if (!isBot && isMaintenanceModeActive()) {
20010
+ process.stderr.write(
20011
+ `slack-channel(${AGENT_CODE_NAME}): maintenance-mode active \u2014 offline notice, no dispatch (channel=${redactSlackId(evt.channel)})
20012
+ `
20013
+ );
20014
+ await maybeSendMaintenanceNotice({
20015
+ channel: evt.channel,
20016
+ senderId: evt.user,
20017
+ threadTs: evt.thread_ts
20018
+ }).catch((err) => {
20019
+ process.stderr.write(
20020
+ `slack-channel(${AGENT_CODE_NAME}): maintenance notice failed: ${err.message}
20021
+ `
20022
+ );
20023
+ });
20024
+ return;
20025
+ }
19954
20026
  const isDirectMessage = evt.channel?.startsWith("D");
19955
20027
  const isThreadReply = !!evt.thread_ts && evt.thread_ts !== evt.ts;
19956
20028
  const trackTs = evt.thread_ts ?? evt.ts ?? "";
@@ -14982,6 +14982,17 @@ function politeDeclineCopy(reason) {
14982
14982
  return "Sorry, I only respond to other agents in this channel.";
14983
14983
  }
14984
14984
  }
14985
+ function decideDeclineReply(input) {
14986
+ const last = input.cache.get(input.key);
14987
+ if (last !== void 0) {
14988
+ const elapsed = input.now - last;
14989
+ if (elapsed < input.cooldownMs) {
14990
+ return { reply: false, remainingMs: input.cooldownMs - elapsed };
14991
+ }
14992
+ }
14993
+ input.cache.set(input.key, input.now);
14994
+ return { reply: true };
14995
+ }
14985
14996
 
14986
14997
  // src/inbound-access.ts
14987
14998
  function decideInboundAccess(input) {
@@ -15022,6 +15033,56 @@ function decideInboundAccess(input) {
15022
15033
  return { kind: "admit" };
15023
15034
  }
15024
15035
 
15036
+ // src/flags-cache-read.ts
15037
+ import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
15038
+ import { homedir as homedir2 } from "os";
15039
+ import { join as join2 } from "path";
15040
+ function defaultFlagsCachePath() {
15041
+ return join2(homedir2(), ".augmented", "flags-cache.json");
15042
+ }
15043
+ function envBoolean(raw) {
15044
+ if (raw === void 0) return void 0;
15045
+ const v = raw.trim().toLowerCase();
15046
+ if (v === "") return void 0;
15047
+ if (v === "1" || v === "true" || v === "yes" || v === "on") return true;
15048
+ if (v === "0" || v === "false" || v === "no" || v === "off") return false;
15049
+ return void 0;
15050
+ }
15051
+ function cachedBoolean(key2, path) {
15052
+ try {
15053
+ if (!existsSync2(path)) return void 0;
15054
+ const parsed = JSON.parse(readFileSync3(path, "utf8"));
15055
+ if (!parsed || typeof parsed !== "object") return void 0;
15056
+ const flags = parsed.flags;
15057
+ if (!flags || typeof flags !== "object") return void 0;
15058
+ const value = flags[key2];
15059
+ return typeof value === "boolean" ? value : void 0;
15060
+ } catch {
15061
+ return void 0;
15062
+ }
15063
+ }
15064
+ function resolveHostBooleanFlag(opts) {
15065
+ const env = opts.env ?? process.env;
15066
+ const envValue = envBoolean(env[opts.envVar]);
15067
+ if (envValue !== void 0) return envValue;
15068
+ const cached2 = cachedBoolean(opts.key, opts.cachePath ?? defaultFlagsCachePath());
15069
+ if (cached2 !== void 0) return cached2;
15070
+ return opts.defaultValue;
15071
+ }
15072
+
15073
+ // src/maintenance-mode.ts
15074
+ var FLAG_KEY = "platform-maintenance-mode";
15075
+ var MAINTENANCE_OFFLINE_MESSAGE = "The Augmented Team platform is offline for scheduled maintenance right now, so I can't pick this up \u2014 please try again shortly.";
15076
+ function isMaintenanceModeActive(opts) {
15077
+ return resolveHostBooleanFlag({
15078
+ key: FLAG_KEY,
15079
+ envVar: "",
15080
+ defaultValue: false,
15081
+ cachePath: opts?.cachePath,
15082
+ env: opts?.env
15083
+ });
15084
+ }
15085
+
15025
15086
  // src/watch-command.ts
15026
15087
  var WATCH_DEFAULT_DURATION_MS = 2 * 60 * 60 * 1e3;
15027
15088
  var WATCH_MAX_DURATION_MS = 7 * 24 * 60 * 60 * 1e3;
@@ -15633,15 +15694,15 @@ function buildCommandRegistrations() {
15633
15694
  }
15634
15695
 
15635
15696
  // src/agent-config-state.ts
15636
- import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
15637
- import { join as join2 } from "path";
15697
+ import { existsSync as existsSync3, readFileSync as readFileSync4 } from "fs";
15698
+ import { join as join3 } from "path";
15638
15699
  var SESSION_STATE_FILENAME = "session-state.json";
15639
15700
  function readAgentSessionState(stateDir) {
15640
15701
  if (!stateDir) return null;
15641
- const path = join2(stateDir, SESSION_STATE_FILENAME);
15642
- if (!existsSync2(path)) return null;
15702
+ const path = join3(stateDir, SESSION_STATE_FILENAME);
15703
+ if (!existsSync3(path)) return null;
15643
15704
  try {
15644
- const parsed = JSON.parse(readFileSync3(path, "utf-8"));
15705
+ const parsed = JSON.parse(readFileSync4(path, "utf-8"));
15645
15706
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
15646
15707
  return parsed;
15647
15708
  } catch {
@@ -16155,11 +16216,11 @@ var TELEGRAM_EGRESS_TOOLS = /* @__PURE__ */ new Set([
16155
16216
  ]);
16156
16217
 
16157
16218
  // src/telegram-pending-inbound-cleanup.ts
16158
- import { readdirSync, readFileSync as readFileSync4, statSync } from "fs";
16159
- import { join as join3 } from "path";
16219
+ import { readdirSync, readFileSync as readFileSync5, statSync } from "fs";
16220
+ import { join as join4 } from "path";
16160
16221
  function markerArrivalMs(fullPath) {
16161
16222
  try {
16162
- const received = JSON.parse(readFileSync4(fullPath, "utf-8")).received_at;
16223
+ const received = JSON.parse(readFileSync5(fullPath, "utf-8")).received_at;
16163
16224
  const parsed = received ? Date.parse(received) : Number.NaN;
16164
16225
  if (Number.isFinite(parsed)) return parsed;
16165
16226
  } catch {
@@ -16183,7 +16244,7 @@ function clearAllTelegramPendingMarkersForChat(pendingDir, chatId, clearMarkerFi
16183
16244
  for (const filename of filenames) {
16184
16245
  if (!filename.startsWith(prefix)) continue;
16185
16246
  if (!filename.endsWith(".json")) continue;
16186
- const fullPath = join3(pendingDir, filename);
16247
+ const fullPath = join4(pendingDir, filename);
16187
16248
  if (bounded && markerArrivalMs(fullPath) > cutoffMs) continue;
16188
16249
  clearMarkerFile(fullPath);
16189
16250
  cleared++;
@@ -16193,14 +16254,14 @@ function clearAllTelegramPendingMarkersForChat(pendingDir, chatId, clearMarkerFi
16193
16254
 
16194
16255
  // src/mcp-spawn-lock.ts
16195
16256
  import {
16196
- existsSync as existsSync3,
16257
+ existsSync as existsSync4,
16197
16258
  mkdirSync as mkdirSync4,
16198
- readFileSync as readFileSync5,
16259
+ readFileSync as readFileSync6,
16199
16260
  renameSync as renameSync3,
16200
16261
  unlinkSync as unlinkSync4,
16201
16262
  writeFileSync as writeFileSync4
16202
16263
  } from "fs";
16203
- import { join as join4 } from "path";
16264
+ import { join as join5 } from "path";
16204
16265
  function defaultIsPidAlive(pid) {
16205
16266
  if (!Number.isFinite(pid) || pid <= 0) return false;
16206
16267
  try {
@@ -16218,7 +16279,7 @@ function acquireMcpSpawnLock(args) {
16218
16279
  const isPidAlive = options.isPidAlive ?? defaultIsPidAlive;
16219
16280
  const selfPid = options.selfPid ?? process.pid;
16220
16281
  const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
16221
- const path = join4(agentDir, basename);
16282
+ const path = join5(agentDir, basename);
16222
16283
  const existing = readLockHolder(path);
16223
16284
  if (existing) {
16224
16285
  if (existing.pid === selfPid) {
@@ -16247,9 +16308,9 @@ function releaseMcpSpawnLock(lockPath, opts = {}) {
16247
16308
  }
16248
16309
  }
16249
16310
  function readLockHolder(path) {
16250
- if (!existsSync3(path)) return null;
16311
+ if (!existsSync4(path)) return null;
16251
16312
  try {
16252
- const raw = readFileSync5(path, "utf8");
16313
+ const raw = readFileSync6(path, "utf8");
16253
16314
  const parsed = JSON.parse(raw);
16254
16315
  const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
16255
16316
  if (!Number.isFinite(pid) || pid <= 0) return null;
@@ -16263,45 +16324,6 @@ function readLockHolder(path) {
16263
16324
  // src/ack-reaction.ts
16264
16325
  import { readdirSync as readdirSync2, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
16265
16326
  import { join as join6 } from "path";
16266
-
16267
- // src/flags-cache-read.ts
16268
- import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
16269
- import { homedir as homedir2 } from "os";
16270
- import { join as join5 } from "path";
16271
- function defaultFlagsCachePath() {
16272
- return join5(homedir2(), ".augmented", "flags-cache.json");
16273
- }
16274
- function envBoolean(raw) {
16275
- if (raw === void 0) return void 0;
16276
- const v = raw.trim().toLowerCase();
16277
- if (v === "") return void 0;
16278
- if (v === "1" || v === "true" || v === "yes" || v === "on") return true;
16279
- if (v === "0" || v === "false" || v === "no" || v === "off") return false;
16280
- return void 0;
16281
- }
16282
- function cachedBoolean(key2, path) {
16283
- try {
16284
- if (!existsSync4(path)) return void 0;
16285
- const parsed = JSON.parse(readFileSync6(path, "utf8"));
16286
- if (!parsed || typeof parsed !== "object") return void 0;
16287
- const flags = parsed.flags;
16288
- if (!flags || typeof flags !== "object") return void 0;
16289
- const value = flags[key2];
16290
- return typeof value === "boolean" ? value : void 0;
16291
- } catch {
16292
- return void 0;
16293
- }
16294
- }
16295
- function resolveHostBooleanFlag(opts) {
16296
- const env = opts.env ?? process.env;
16297
- const envValue = envBoolean(env[opts.envVar]);
16298
- if (envValue !== void 0) return envValue;
16299
- const cached2 = cachedBoolean(opts.key, opts.cachePath ?? defaultFlagsCachePath());
16300
- if (cached2 !== void 0) return cached2;
16301
- return opts.defaultValue;
16302
- }
16303
-
16304
- // src/ack-reaction.ts
16305
16327
  var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
16306
16328
  var ACK_STARTUP_GRACE_MS = 6e4;
16307
16329
  var ACK_PANE_FRESH_THRESHOLD_MS = 6e4;
@@ -16667,6 +16689,53 @@ function telegramApiCall(method, body, timeoutMs) {
16667
16689
  req.end();
16668
16690
  });
16669
16691
  }
16692
+ var TELEGRAM_MAINTENANCE_NOTICE_CACHE = /* @__PURE__ */ new Map();
16693
+ var TELEGRAM_MAINTENANCE_COOLDOWN_MS = (() => {
16694
+ const raw = process.env["TELEGRAM_MAINTENANCE_NOTICE_COOLDOWN_SEC"];
16695
+ const n = raw ? Number(raw) : NaN;
16696
+ return Number.isFinite(n) && n >= 0 ? n * 1e3 : 1800 * 1e3;
16697
+ })();
16698
+ async function maybeSendTelegramMaintenanceNotice(args) {
16699
+ if (args.senderId === void 0) return;
16700
+ const key2 = `${args.chatId}|${args.senderId}|maintenance`;
16701
+ const decision = decideDeclineReply({
16702
+ cache: TELEGRAM_MAINTENANCE_NOTICE_CACHE,
16703
+ key: key2,
16704
+ cooldownMs: TELEGRAM_MAINTENANCE_COOLDOWN_MS,
16705
+ now: Date.now()
16706
+ });
16707
+ if (!decision.reply) {
16708
+ process.stderr.write(
16709
+ `telegram-channel(${AGENT_CODE_NAME}): maintenance notice suppressed by cooldown (chat=${redactId(String(args.chatId))}, remaining=${decision.remainingMs}ms)
16710
+ `
16711
+ );
16712
+ return;
16713
+ }
16714
+ try {
16715
+ const resp = await telegramApiCall(
16716
+ "sendMessage",
16717
+ {
16718
+ chat_id: args.chatId,
16719
+ text: MAINTENANCE_OFFLINE_MESSAGE,
16720
+ ...args.messageThreadId != null ? { message_thread_id: args.messageThreadId } : {}
16721
+ },
16722
+ 1e4
16723
+ );
16724
+ if (!resp.ok) {
16725
+ TELEGRAM_MAINTENANCE_NOTICE_CACHE.delete(key2);
16726
+ process.stderr.write(
16727
+ `telegram-channel(${AGENT_CODE_NAME}): maintenance notice rejected (chat=${redactId(String(args.chatId))}): ${resp.description ?? "unknown"}
16728
+ `
16729
+ );
16730
+ }
16731
+ } catch (err) {
16732
+ TELEGRAM_MAINTENANCE_NOTICE_CACHE.delete(key2);
16733
+ process.stderr.write(
16734
+ `telegram-channel(${AGENT_CODE_NAME}): maintenance notice failed: ${err.message}
16735
+ `
16736
+ );
16737
+ }
16738
+ }
16670
16739
  var ACK_EMOJI = (process.env.TELEGRAM_ACK_REACTION ?? "").trim() || "\u{1F440}";
16671
16740
  var TELEGRAM_SKIP_REACTION = (process.env.TELEGRAM_SKIP_REACTION ?? "").trim();
16672
16741
  async function setMessageReaction(chatId, messageId, emoji2) {
@@ -18908,6 +18977,18 @@ async function pollLoop() {
18908
18977
  }
18909
18978
  continue;
18910
18979
  }
18980
+ if (!isFromBot && isMaintenanceModeActive()) {
18981
+ process.stderr.write(
18982
+ `telegram-channel(${AGENT_CODE_NAME}): maintenance-mode active \u2014 offline notice, no dispatch (chat=${redactId(chatId)})
18983
+ `
18984
+ );
18985
+ await maybeSendTelegramMaintenanceNotice({
18986
+ chatId,
18987
+ senderId: userId,
18988
+ messageThreadId: msg.message_thread_id
18989
+ });
18990
+ continue;
18991
+ }
18911
18992
  if (isFromBot && classification?.kind === "peer-ingress") {
18912
18993
  const limit = await peerRateLimiter.recordInboundPeer(
18913
18994
  chatId,
@@ -25,8 +25,8 @@ import {
25
25
  takeZombieDetection,
26
26
  writeDirectChatSessionState,
27
27
  writePersistentClaudeWrapper
28
- } from "./chunk-UA3LEZL4.js";
29
- import "./chunk-OEZEWEEG.js";
28
+ } from "./chunk-YYOFXUCK.js";
29
+ import "./chunk-BJ26X4HJ.js";
30
30
  import "./chunk-XWVM4KPK.js";
31
31
  export {
32
32
  SEND_KEYS_ENTER_DELAY_MS,
@@ -56,4 +56,4 @@ export {
56
56
  writeDirectChatSessionState,
57
57
  writePersistentClaudeWrapper
58
58
  };
59
- //# sourceMappingURL=persistent-session-42V6NGMR.js.map
59
+ //# sourceMappingURL=persistent-session-WSKVRZZD.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  paneLogPath
3
- } from "./chunk-UA3LEZL4.js";
4
- import "./chunk-OEZEWEEG.js";
3
+ } from "./chunk-YYOFXUCK.js";
4
+ import "./chunk-BJ26X4HJ.js";
5
5
  import "./chunk-XWVM4KPK.js";
6
6
 
7
7
  // src/lib/responsiveness-probe.ts
@@ -250,4 +250,4 @@ export {
250
250
  parkPendingInbound,
251
251
  readAndResetChannelDeflections
252
252
  };
253
- //# sourceMappingURL=responsiveness-probe-YSSYWWTG.js.map
253
+ //# sourceMappingURL=responsiveness-probe-HTPGYQPY.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.59",
3
+ "version": "0.28.61",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {