@integrity-labs/agt-cli 0.28.163 → 0.28.165

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
@@ -37,7 +37,7 @@ import {
37
37
  success,
38
38
  table,
39
39
  warn
40
- } from "../chunk-BEUGTZ7Z.js";
40
+ } from "../chunk-KBFXXA5U.js";
41
41
  import {
42
42
  CHANNEL_REGISTRY,
43
43
  DEFAULT_FRAMEWORK,
@@ -65,7 +65,7 @@ import {
65
65
  renderTemplate,
66
66
  resolveChannels,
67
67
  serializeManifestForSlackCli
68
- } from "../chunk-MTKFDGXO.js";
68
+ } from "../chunk-SDUFTHIF.js";
69
69
 
70
70
  // src/bin/agt.ts
71
71
  import { join as join22 } from "path";
@@ -4778,7 +4778,7 @@ import { execFileSync, execSync } from "child_process";
4778
4778
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4779
4779
  import chalk18 from "chalk";
4780
4780
  import ora16 from "ora";
4781
- var cliVersion = true ? "0.28.163" : "dev";
4781
+ var cliVersion = true ? "0.28.165" : "dev";
4782
4782
  async function fetchLatestVersion() {
4783
4783
  const host2 = getHost();
4784
4784
  if (!host2) return null;
@@ -5792,7 +5792,7 @@ function handleError(err) {
5792
5792
  }
5793
5793
 
5794
5794
  // src/bin/agt.ts
5795
- var cliVersion2 = true ? "0.28.163" : "dev";
5795
+ var cliVersion2 = true ? "0.28.165" : "dev";
5796
5796
  var program = new Command();
5797
5797
  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");
5798
5798
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -3,7 +3,7 @@ import {
3
3
  formatMissingVar,
4
4
  isClaudeFastMode,
5
5
  probeMcpEnvSubstitution
6
- } from "./chunk-MTKFDGXO.js";
6
+ } from "./chunk-SDUFTHIF.js";
7
7
  import {
8
8
  reapOrphanChannelMcps
9
9
  } from "./chunk-XWVM4KPK.js";
@@ -1588,4 +1588,4 @@ export {
1588
1588
  stopAllSessionsAndWait,
1589
1589
  getProjectDir
1590
1590
  };
1591
- //# sourceMappingURL=chunk-OW6ERQHP.js.map
1591
+ //# sourceMappingURL=chunk-6TIVVGA7.js.map
@@ -23,7 +23,7 @@ import {
23
23
  resolveConnectivityProbe,
24
24
  worseConnectivityOutcome,
25
25
  wrapScheduledTaskPrompt
26
- } from "./chunk-MTKFDGXO.js";
26
+ } from "./chunk-SDUFTHIF.js";
27
27
 
28
28
  // ../../packages/core/dist/integrations/registry.js
29
29
  var INTEGRATION_REGISTRY = [
@@ -7948,7 +7948,7 @@ function requireHost() {
7948
7948
  }
7949
7949
 
7950
7950
  // src/lib/api-client.ts
7951
- var agtCliVersion = true ? "0.28.163" : "dev";
7951
+ var agtCliVersion = true ? "0.28.165" : "dev";
7952
7952
  var lastConfigHash = null;
7953
7953
  function setConfigHash(hash) {
7954
7954
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -9253,4 +9253,4 @@ export {
9253
9253
  managerInstallSystemUnitCommand,
9254
9254
  managerUninstallSystemUnitCommand
9255
9255
  };
9256
- //# sourceMappingURL=chunk-BEUGTZ7Z.js.map
9256
+ //# sourceMappingURL=chunk-KBFXXA5U.js.map
@@ -6529,4 +6529,4 @@ export {
6529
6529
  parseEnvIntegrations,
6530
6530
  probeMcpEnvSubstitution
6531
6531
  };
6532
- //# sourceMappingURL=chunk-MTKFDGXO.js.map
6532
+ //# sourceMappingURL=chunk-SDUFTHIF.js.map
@@ -100,7 +100,7 @@ async function spawnPairSession(session) {
100
100
  return { ok: true };
101
101
  } catch {
102
102
  }
103
- const { resolveClaudeBinary } = await import("./persistent-session-3ACIT7F5.js");
103
+ const { resolveClaudeBinary } = await import("./persistent-session-XIW3I5CQ.js");
104
104
  const claudeBin = resolveClaudeBinary();
105
105
  const pairEnv = {
106
106
  ...process.env,
@@ -373,4 +373,4 @@ export {
373
373
  startClaudePair,
374
374
  submitClaudePairCode
375
375
  };
376
- //# sourceMappingURL=claude-pair-runtime-WEKLV5X5.js.map
376
+ //# sourceMappingURL=claude-pair-runtime-6ZLSPL6Z.js.map
@@ -28,7 +28,7 @@ import {
28
28
  requireHost,
29
29
  safeWriteJsonAtomic,
30
30
  setConfigHash
31
- } from "../chunk-BEUGTZ7Z.js";
31
+ } from "../chunk-KBFXXA5U.js";
32
32
  import {
33
33
  getProjectDir as getProjectDir2,
34
34
  getReadyTasks,
@@ -70,7 +70,7 @@ import {
70
70
  takeZombieDetection,
71
71
  transcriptActivityAgeSeconds,
72
72
  writeEgressAllowlist
73
- } from "../chunk-OW6ERQHP.js";
73
+ } from "../chunk-6TIVVGA7.js";
74
74
  import {
75
75
  CONVERSATION_FAILURE_CATEGORIES,
76
76
  DEFAULT_FRAMEWORK,
@@ -111,7 +111,7 @@ import {
111
111
  resolveChannels,
112
112
  resolveDmTarget,
113
113
  sumTranscriptUsageInWindow
114
- } from "../chunk-MTKFDGXO.js";
114
+ } from "../chunk-SDUFTHIF.js";
115
115
  import {
116
116
  parsePsRows,
117
117
  reapOrphanChannelMcps
@@ -6878,7 +6878,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
6878
6878
  var lastVersionCheckAt = 0;
6879
6879
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
6880
6880
  var lastResponsivenessProbeAt = 0;
6881
- var agtCliVersion = true ? "0.28.163" : "dev";
6881
+ var agtCliVersion = true ? "0.28.165" : "dev";
6882
6882
  function resolveBrewPath(execFileSync4) {
6883
6883
  try {
6884
6884
  const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -8011,7 +8011,7 @@ async function pollCycle() {
8011
8011
  }
8012
8012
  try {
8013
8013
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
8014
- const { collectDiagnostics } = await import("../persistent-session-3ACIT7F5.js");
8014
+ const { collectDiagnostics } = await import("../persistent-session-XIW3I5CQ.js");
8015
8015
  const diagCodeNames = [...agentState.persistentSessionAgents];
8016
8016
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
8017
8017
  let tailscaleHostname;
@@ -8159,7 +8159,7 @@ async function pollCycle() {
8159
8159
  const {
8160
8160
  collectResponsivenessProbes,
8161
8161
  getResponsivenessIntervalMs
8162
- } = await import("../responsiveness-probe-5OCWCS3M.js");
8162
+ } = await import("../responsiveness-probe-7JTG6QMB.js");
8163
8163
  const probeIntervalMs = getResponsivenessIntervalMs();
8164
8164
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
8165
8165
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -8191,7 +8191,7 @@ async function pollCycle() {
8191
8191
  collectResponsivenessProbes,
8192
8192
  livePendingInboundOldestAgeSeconds,
8193
8193
  parkPendingInbound
8194
- } = await import("../responsiveness-probe-5OCWCS3M.js");
8194
+ } = await import("../responsiveness-probe-7JTG6QMB.js");
8195
8195
  const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
8196
8196
  const wedgeNow = /* @__PURE__ */ new Date();
8197
8197
  const liveAgents = agentState.persistentSessionAgents;
@@ -11692,7 +11692,7 @@ async function processClaudePairSessions(agents) {
11692
11692
  killPairSession,
11693
11693
  pairTmuxSession,
11694
11694
  finalizeClaudePairOnboarding
11695
- } = await import("../claude-pair-runtime-WEKLV5X5.js");
11695
+ } = await import("../claude-pair-runtime-6ZLSPL6Z.js");
11696
11696
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
11697
11697
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
11698
11698
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -14182,6 +14182,204 @@ var Server = class extends Protocol {
14182
14182
  }
14183
14183
  };
14184
14184
 
14185
+ // src/slack-rich-text.ts
14186
+ var MAX_DEPTH = 12;
14187
+ function isRecord(v) {
14188
+ return typeof v === "object" && v !== null && !Array.isArray(v);
14189
+ }
14190
+ function asString(v) {
14191
+ return typeof v === "string" ? v : "";
14192
+ }
14193
+ function asArray(v) {
14194
+ return Array.isArray(v) ? v : [];
14195
+ }
14196
+ function isTableElement(el) {
14197
+ return isRecord(el) && asString(el.type).includes("table");
14198
+ }
14199
+ function renderEmoji(el) {
14200
+ const unicode = asString(el.unicode);
14201
+ if (unicode) {
14202
+ try {
14203
+ const cps = unicode.split("-").map((h) => parseInt(h, 16));
14204
+ if (cps.every((n) => Number.isFinite(n) && n >= 0 && n <= 1114111)) {
14205
+ return String.fromCodePoint(...cps);
14206
+ }
14207
+ } catch {
14208
+ }
14209
+ }
14210
+ const name = asString(el.name);
14211
+ return name ? `:${name}:` : "";
14212
+ }
14213
+ function renderLeaf(el) {
14214
+ if (!isRecord(el)) return "";
14215
+ switch (asString(el.type)) {
14216
+ case "text":
14217
+ return asString(el.text);
14218
+ case "link": {
14219
+ const label = asString(el.text);
14220
+ const url = asString(el.url);
14221
+ if (label && url && label !== url) return `${label} (${url})`;
14222
+ return label || url;
14223
+ }
14224
+ case "emoji":
14225
+ return renderEmoji(el);
14226
+ case "user":
14227
+ return `<@${asString(el.user_id)}>`;
14228
+ case "usergroup":
14229
+ return `<!subteam^${asString(el.usergroup_id)}>`;
14230
+ case "channel":
14231
+ return `<#${asString(el.channel_id)}>`;
14232
+ case "broadcast":
14233
+ return `@${asString(el.range) || "channel"}`;
14234
+ case "date":
14235
+ return asString(el.fallback) || asString(el.timestamp);
14236
+ default:
14237
+ if (Array.isArray(el.elements)) return renderInline(el.elements);
14238
+ return asString(el.text);
14239
+ }
14240
+ }
14241
+ function renderInline(elements) {
14242
+ return elements.map(renderLeaf).join("");
14243
+ }
14244
+ function deepText(node, depth) {
14245
+ if (depth > MAX_DEPTH) return "";
14246
+ if (typeof node === "string") return node;
14247
+ if (Array.isArray(node)) return node.map((n) => deepText(n, depth + 1)).join("");
14248
+ if (!isRecord(node)) return "";
14249
+ const type = asString(node.type);
14250
+ if (type && type !== "rich_text" && !type.startsWith("rich_text_") && !type.includes("table")) {
14251
+ return renderLeaf(node);
14252
+ }
14253
+ if (Array.isArray(node.elements)) return node.elements.map((n) => deepText(n, depth + 1)).join("");
14254
+ if (Array.isArray(node.rows)) return node.rows.map((n) => deepText(n, depth + 1)).join(" ");
14255
+ return asString(node.text);
14256
+ }
14257
+ function renderCell(cell) {
14258
+ if (!isRecord(cell)) return deepText(cell, 0).replace(/\s*\n\s*/g, " ").trim();
14259
+ const inner = Array.isArray(cell.elements) ? renderSection(cell, 0) : deepText(cell, 0);
14260
+ return inner.replace(/\s*\n\s*/g, " ").trim();
14261
+ }
14262
+ function renderTable(el) {
14263
+ const rawRows = asArray(el.elements).length ? asArray(el.elements) : asArray(el.rows);
14264
+ const rows = [];
14265
+ for (const row of rawRows) {
14266
+ if (!isRecord(row) && !Array.isArray(row)) continue;
14267
+ const rawCells = Array.isArray(row) ? row : asArray(row.elements).length ? asArray(row.elements) : asArray(row.cells);
14268
+ if (rawCells.length === 0) continue;
14269
+ rows.push(rawCells.map(renderCell));
14270
+ }
14271
+ if (rows.length === 0) {
14272
+ const fallback = deepText(el, 0).replace(/[ \t]+\n/g, "\n").trim();
14273
+ return fallback;
14274
+ }
14275
+ const colCount = rows.reduce((max, r) => Math.max(max, r.length), 0);
14276
+ const pad = (r) => {
14277
+ const cells = r.slice();
14278
+ while (cells.length < colCount) cells.push("");
14279
+ return cells.map((c) => c.replace(/\|/g, "\\|"));
14280
+ };
14281
+ const lines = [];
14282
+ const header = rows[0] ?? [];
14283
+ const body = rows.slice(1);
14284
+ lines.push(`| ${pad(header).join(" | ")} |`);
14285
+ lines.push(`| ${Array.from({ length: colCount }, () => "---").join(" | ")} |`);
14286
+ for (const r of body) lines.push(`| ${pad(r).join(" | ")} |`);
14287
+ return lines.join("\n");
14288
+ }
14289
+ function renderSection(section, depth) {
14290
+ if (depth > MAX_DEPTH || !isRecord(section)) return "";
14291
+ const type = asString(section.type);
14292
+ if (isTableElement(section)) return renderTable(section);
14293
+ switch (type) {
14294
+ case "rich_text_section":
14295
+ return renderInline(asArray(section.elements));
14296
+ case "rich_text_preformatted": {
14297
+ const code = renderInline(asArray(section.elements));
14298
+ return code ? `\`\`\`
14299
+ ${code}
14300
+ \`\`\`` : "";
14301
+ }
14302
+ case "rich_text_quote": {
14303
+ const quoted = renderInline(asArray(section.elements));
14304
+ return quoted ? quoted.split("\n").map((l) => `> ${l}`).join("\n") : "";
14305
+ }
14306
+ case "rich_text_list": {
14307
+ const ordered = asString(section.style) === "ordered";
14308
+ const items = asArray(section.elements).map((item, i) => {
14309
+ const body = renderSection(item, depth + 1) || renderInline(asArray(item?.elements));
14310
+ const marker = ordered ? `${i + 1}.` : "-";
14311
+ return `${marker} ${body}`.trimEnd();
14312
+ });
14313
+ return items.join("\n");
14314
+ }
14315
+ default:
14316
+ if (Array.isArray(section.elements)) return renderInline(asArray(section.elements));
14317
+ return deepText(section, depth + 1);
14318
+ }
14319
+ }
14320
+ function renderSlackBlocks(blocks) {
14321
+ let hadTable = false;
14322
+ const out = [];
14323
+ try {
14324
+ for (const block of asArray(blocks)) {
14325
+ if (!isRecord(block) || asString(block.type) !== "rich_text") continue;
14326
+ for (const section of asArray(block.elements)) {
14327
+ if (isTableElement(section)) hadTable = true;
14328
+ const rendered = renderSection(section, 0);
14329
+ if (rendered.trim().length > 0) out.push(rendered);
14330
+ }
14331
+ }
14332
+ } catch {
14333
+ }
14334
+ const text = out.join("\n\n").replace(/[ \t]+$/gm, "").replace(/\n{3,}/g, "\n\n").trim();
14335
+ return { text, hadTable };
14336
+ }
14337
+ function mergeInboundText(text, blocks) {
14338
+ const { text: rendered, hadTable } = renderSlackBlocks(blocks);
14339
+ if (!hadTable) return { content: text, recoveredTable: false };
14340
+ const content = rendered.length > 0 ? rendered : text;
14341
+ return { content, recoveredTable: rendered.length > 0 && content !== text };
14342
+ }
14343
+
14344
+ // src/slack-forwarded.ts
14345
+ function asTrimmed(v) {
14346
+ return typeof v === "string" ? v.trim() : "";
14347
+ }
14348
+ function extractForwardedContent(attachments) {
14349
+ if (!Array.isArray(attachments)) return { text: "", files: [] };
14350
+ const parts = [];
14351
+ const files = [];
14352
+ for (const raw of attachments) {
14353
+ if (!raw || typeof raw !== "object") continue;
14354
+ const att = raw;
14355
+ let body = asTrimmed(att.text) || asTrimmed(att.fallback);
14356
+ if (!body && Array.isArray(att.message_blocks)) {
14357
+ for (const mb of att.message_blocks) {
14358
+ const rendered = renderSlackBlocks(mb?.message?.blocks).text.trim();
14359
+ if (rendered) {
14360
+ body = rendered;
14361
+ break;
14362
+ }
14363
+ }
14364
+ }
14365
+ const title = asTrimmed(att.title);
14366
+ const link = asTrimmed(att.title_link) || asTrimmed(att.from_url);
14367
+ const imageUrl = asTrimmed(att.image_url) || asTrimmed(att.thumb_url);
14368
+ const lines = [];
14369
+ if (body) lines.push(body);
14370
+ if (title && title !== body) lines.push(title);
14371
+ if (link) lines.push(link);
14372
+ if (imageUrl) lines.push(`[image] ${imageUrl}`);
14373
+ if (lines.length) parts.push(lines.join("\n"));
14374
+ if (Array.isArray(att.files)) files.push(...att.files);
14375
+ }
14376
+ return { text: parts.join("\n\n"), files };
14377
+ }
14378
+ function hasForwardedContent(attachments) {
14379
+ const { text, files } = extractForwardedContent(attachments);
14380
+ return text.length > 0 || files.length > 0;
14381
+ }
14382
+
14185
14383
  // src/slack-inbound-filter.ts
14186
14384
  var ALLOWED_MESSAGE_SUBTYPES = /* @__PURE__ */ new Set([
14187
14385
  void 0,
@@ -14201,7 +14399,8 @@ function decideSlackMessageForward(evt) {
14201
14399
  const hasText = typeof evt.text === "string" && evt.text.trim().length > 0;
14202
14400
  const hasFiles = Array.isArray(evt.files) && evt.files.length > 0;
14203
14401
  const hasBlocks = Array.isArray(evt.blocks) && evt.blocks.length > 0;
14204
- if (!hasText && !hasFiles && !hasBlocks) {
14402
+ const hasAttachments = hasForwardedContent(evt.attachments);
14403
+ if (!hasText && !hasFiles && !hasBlocks && !hasAttachments) {
14205
14404
  return { forward: false, reason: "empty" };
14206
14405
  }
14207
14406
  return { forward: true };
@@ -14562,8 +14761,8 @@ function shouldPostUndeliverableNotice(lastNoticeAtMs, nowMs, throttleMs = UNDEL
14562
14761
  function undeliverableNoticeText(replayEnabled = channelReplayEnabled()) {
14563
14762
  return replayEnabled ? "\u23F3 I can't get to this right now \u2014 no need to resend; I'll pick it up automatically as soon as I'm free." : "\u23F3 I can't get to this right now. Please resend in a few minutes \u2014 I may not see this one.";
14564
14763
  }
14565
- var BUSY_ACK_THRESHOLD_MS = 9e4;
14566
- var BUSY_ACK_NOTICE_THROTTLE_MS = 10 * 60 * 1e3;
14764
+ var BUSY_ACK_THRESHOLD_MS = 12e4;
14765
+ var BUSY_ACK_NOTICE_THROTTLE_MS = 20 * 60 * 1e3;
14567
14766
  function channelBusyAckEnabled() {
14568
14767
  return resolveHostBooleanFlag({
14569
14768
  key: "channel-busy-ack",
@@ -14620,7 +14819,7 @@ function decideGiveUpNotice(input) {
14620
14819
  function giveUpNoticeText() {
14621
14820
  return "\u26A0\uFE0F I couldn't read your last message \u2014 please resend it.";
14622
14821
  }
14623
- function oldestPendingMarkerAgeMs(dir, now = Date.now()) {
14822
+ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
14624
14823
  if (!dir) return null;
14625
14824
  let names;
14626
14825
  try {
@@ -14635,7 +14834,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now()) {
14635
14834
  try {
14636
14835
  const raw = JSON.parse(readFileSync2(join2(dir, name), "utf-8"));
14637
14836
  if (raw.discretionary === true) continue;
14638
- if (typeof raw.seen_at === "string" && raw.seen_at) continue;
14837
+ if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
14639
14838
  receivedAt = raw.received_at;
14640
14839
  } catch {
14641
14840
  continue;
@@ -14649,6 +14848,9 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now()) {
14649
14848
  }
14650
14849
  return oldest;
14651
14850
  }
14851
+ function hasInFlightInbound(dir, now = Date.now()) {
14852
+ return oldestPendingMarkerAgeMs(dir, now, { includeSeen: true }) != null;
14853
+ }
14652
14854
  function isPendingMarkerStale(receivedAt, nowMs, thresholdMs) {
14653
14855
  if (!receivedAt) return true;
14654
14856
  const t = Date.parse(receivedAt);
@@ -16116,165 +16318,6 @@ function buildSafeInboundPath2(codeName, fileId, mimetype) {
16116
16318
  return buildSafeInboundPath(resolveSlackInboundDir(codeName), fileId, mimetype);
16117
16319
  }
16118
16320
 
16119
- // src/slack-rich-text.ts
16120
- var MAX_DEPTH = 12;
16121
- function isRecord(v) {
16122
- return typeof v === "object" && v !== null && !Array.isArray(v);
16123
- }
16124
- function asString(v) {
16125
- return typeof v === "string" ? v : "";
16126
- }
16127
- function asArray(v) {
16128
- return Array.isArray(v) ? v : [];
16129
- }
16130
- function isTableElement(el) {
16131
- return isRecord(el) && asString(el.type).includes("table");
16132
- }
16133
- function renderEmoji(el) {
16134
- const unicode = asString(el.unicode);
16135
- if (unicode) {
16136
- try {
16137
- const cps = unicode.split("-").map((h) => parseInt(h, 16));
16138
- if (cps.every((n) => Number.isFinite(n) && n >= 0 && n <= 1114111)) {
16139
- return String.fromCodePoint(...cps);
16140
- }
16141
- } catch {
16142
- }
16143
- }
16144
- const name = asString(el.name);
16145
- return name ? `:${name}:` : "";
16146
- }
16147
- function renderLeaf(el) {
16148
- if (!isRecord(el)) return "";
16149
- switch (asString(el.type)) {
16150
- case "text":
16151
- return asString(el.text);
16152
- case "link": {
16153
- const label = asString(el.text);
16154
- const url = asString(el.url);
16155
- if (label && url && label !== url) return `${label} (${url})`;
16156
- return label || url;
16157
- }
16158
- case "emoji":
16159
- return renderEmoji(el);
16160
- case "user":
16161
- return `<@${asString(el.user_id)}>`;
16162
- case "usergroup":
16163
- return `<!subteam^${asString(el.usergroup_id)}>`;
16164
- case "channel":
16165
- return `<#${asString(el.channel_id)}>`;
16166
- case "broadcast":
16167
- return `@${asString(el.range) || "channel"}`;
16168
- case "date":
16169
- return asString(el.fallback) || asString(el.timestamp);
16170
- default:
16171
- if (Array.isArray(el.elements)) return renderInline(el.elements);
16172
- return asString(el.text);
16173
- }
16174
- }
16175
- function renderInline(elements) {
16176
- return elements.map(renderLeaf).join("");
16177
- }
16178
- function deepText(node, depth) {
16179
- if (depth > MAX_DEPTH) return "";
16180
- if (typeof node === "string") return node;
16181
- if (Array.isArray(node)) return node.map((n) => deepText(n, depth + 1)).join("");
16182
- if (!isRecord(node)) return "";
16183
- const type = asString(node.type);
16184
- if (type && type !== "rich_text" && !type.startsWith("rich_text_") && !type.includes("table")) {
16185
- return renderLeaf(node);
16186
- }
16187
- if (Array.isArray(node.elements)) return node.elements.map((n) => deepText(n, depth + 1)).join("");
16188
- if (Array.isArray(node.rows)) return node.rows.map((n) => deepText(n, depth + 1)).join(" ");
16189
- return asString(node.text);
16190
- }
16191
- function renderCell(cell) {
16192
- if (!isRecord(cell)) return deepText(cell, 0).replace(/\s*\n\s*/g, " ").trim();
16193
- const inner = Array.isArray(cell.elements) ? renderSection(cell, 0) : deepText(cell, 0);
16194
- return inner.replace(/\s*\n\s*/g, " ").trim();
16195
- }
16196
- function renderTable(el) {
16197
- const rawRows = asArray(el.elements).length ? asArray(el.elements) : asArray(el.rows);
16198
- const rows = [];
16199
- for (const row of rawRows) {
16200
- if (!isRecord(row) && !Array.isArray(row)) continue;
16201
- const rawCells = Array.isArray(row) ? row : asArray(row.elements).length ? asArray(row.elements) : asArray(row.cells);
16202
- if (rawCells.length === 0) continue;
16203
- rows.push(rawCells.map(renderCell));
16204
- }
16205
- if (rows.length === 0) {
16206
- const fallback = deepText(el, 0).replace(/[ \t]+\n/g, "\n").trim();
16207
- return fallback;
16208
- }
16209
- const colCount = rows.reduce((max, r) => Math.max(max, r.length), 0);
16210
- const pad = (r) => {
16211
- const cells = r.slice();
16212
- while (cells.length < colCount) cells.push("");
16213
- return cells.map((c) => c.replace(/\|/g, "\\|"));
16214
- };
16215
- const lines = [];
16216
- const header = rows[0] ?? [];
16217
- const body = rows.slice(1);
16218
- lines.push(`| ${pad(header).join(" | ")} |`);
16219
- lines.push(`| ${Array.from({ length: colCount }, () => "---").join(" | ")} |`);
16220
- for (const r of body) lines.push(`| ${pad(r).join(" | ")} |`);
16221
- return lines.join("\n");
16222
- }
16223
- function renderSection(section, depth) {
16224
- if (depth > MAX_DEPTH || !isRecord(section)) return "";
16225
- const type = asString(section.type);
16226
- if (isTableElement(section)) return renderTable(section);
16227
- switch (type) {
16228
- case "rich_text_section":
16229
- return renderInline(asArray(section.elements));
16230
- case "rich_text_preformatted": {
16231
- const code = renderInline(asArray(section.elements));
16232
- return code ? `\`\`\`
16233
- ${code}
16234
- \`\`\`` : "";
16235
- }
16236
- case "rich_text_quote": {
16237
- const quoted = renderInline(asArray(section.elements));
16238
- return quoted ? quoted.split("\n").map((l) => `> ${l}`).join("\n") : "";
16239
- }
16240
- case "rich_text_list": {
16241
- const ordered = asString(section.style) === "ordered";
16242
- const items = asArray(section.elements).map((item, i) => {
16243
- const body = renderSection(item, depth + 1) || renderInline(asArray(item?.elements));
16244
- const marker = ordered ? `${i + 1}.` : "-";
16245
- return `${marker} ${body}`.trimEnd();
16246
- });
16247
- return items.join("\n");
16248
- }
16249
- default:
16250
- if (Array.isArray(section.elements)) return renderInline(asArray(section.elements));
16251
- return deepText(section, depth + 1);
16252
- }
16253
- }
16254
- function renderSlackBlocks(blocks) {
16255
- let hadTable = false;
16256
- const out = [];
16257
- try {
16258
- for (const block of asArray(blocks)) {
16259
- if (!isRecord(block) || asString(block.type) !== "rich_text") continue;
16260
- for (const section of asArray(block.elements)) {
16261
- if (isTableElement(section)) hadTable = true;
16262
- const rendered = renderSection(section, 0);
16263
- if (rendered.trim().length > 0) out.push(rendered);
16264
- }
16265
- }
16266
- } catch {
16267
- }
16268
- const text = out.join("\n\n").replace(/[ \t]+$/gm, "").replace(/\n{3,}/g, "\n\n").trim();
16269
- return { text, hadTable };
16270
- }
16271
- function mergeInboundText(text, blocks) {
16272
- const { text: rendered, hadTable } = renderSlackBlocks(blocks);
16273
- if (!hadTable) return { content: text, recoveredTable: false };
16274
- const content = rendered.length > 0 ? rendered : text;
16275
- return { content, recoveredTable: rendered.length > 0 && content !== text };
16276
- }
16277
-
16278
16321
  // src/inbound-dedup.ts
16279
16322
  var DEFAULT_TTL_MS = 5 * 6e4;
16280
16323
  var MAX_ENTRIES = 2e3;
@@ -20830,6 +20873,7 @@ async function connectSocketMode() {
20830
20873
  paneLogFreshAgeMs
20831
20874
  };
20832
20875
  const ackDecision = decideAckReaction(ackInputs);
20876
+ const arrivedWhileBusy = hasInFlightInbound(SLACK_PENDING_INBOUND_DIR);
20833
20877
  if (ackDecision === "undeliverable") {
20834
20878
  const cause = classifyUndeliverableCause(ackInputs) ?? "unknown";
20835
20879
  recordChannelDeflection(SLACK_AGENT_DIR, "slack", cause);
@@ -20861,12 +20905,17 @@ async function connectSocketMode() {
20861
20905
  threadTs,
20862
20906
  ts,
20863
20907
  isThreadReply,
20864
- ackInputs.oldestPendingAgeMs != null
20908
+ arrivedWhileBusy
20865
20909
  );
20866
20910
  }
20867
20911
  }
20868
20912
  const userName = await resolveUserName(user);
20869
- const fileMeta = await buildInboundFileMeta(evt.files, AGENT_CODE_NAME, channel);
20913
+ const forwarded = extractForwardedContent(evt.attachments);
20914
+ const fileMeta = await buildInboundFileMeta(
20915
+ [...evt.files ?? [], ...forwarded.files],
20916
+ AGENT_CODE_NAME,
20917
+ channel
20918
+ );
20870
20919
  const downloadedImages = fileMeta.filter(
20871
20920
  (f) => f.kind === "image" && typeof f.path === "string"
20872
20921
  );
@@ -20894,10 +20943,20 @@ async function connectSocketMode() {
20894
20943
  );
20895
20944
  }
20896
20945
  }
20897
- const { content: inboundContent, recoveredTable } = mergeInboundText(text, evt.blocks);
20946
+ const { content: mergedText, recoveredTable } = mergeInboundText(text, evt.blocks);
20898
20947
  if (recoveredTable) {
20899
20948
  process.stderr.write(
20900
20949
  `slack-channel(${AGENT_CODE_NAME}): recovered rich_text table from blocks (channel=${redactSlackId(channel)} ts=${redactSlackId(ts)})
20950
+ `
20951
+ );
20952
+ }
20953
+ let inboundContent = mergedText;
20954
+ if (forwarded.text) {
20955
+ inboundContent = mergedText.trim().length > 0 ? `${mergedText}
20956
+
20957
+ ${forwarded.text}` : forwarded.text;
20958
+ process.stderr.write(
20959
+ `slack-channel(${AGENT_CODE_NAME}): recovered forwarded message content (channel=${redactSlackId(channel)} ts=${redactSlackId(ts)})
20901
20960
  `
20902
20961
  );
20903
20962
  }
@@ -16733,8 +16733,8 @@ function shouldPostUndeliverableNotice(lastNoticeAtMs, nowMs, throttleMs = UNDEL
16733
16733
  function undeliverableNoticeText(replayEnabled = channelReplayEnabled()) {
16734
16734
  return replayEnabled ? "\u23F3 I can't get to this right now \u2014 no need to resend; I'll pick it up automatically as soon as I'm free." : "\u23F3 I can't get to this right now. Please resend in a few minutes \u2014 I may not see this one.";
16735
16735
  }
16736
- var BUSY_ACK_THRESHOLD_MS = 9e4;
16737
- var BUSY_ACK_NOTICE_THROTTLE_MS = 10 * 60 * 1e3;
16736
+ var BUSY_ACK_THRESHOLD_MS = 12e4;
16737
+ var BUSY_ACK_NOTICE_THROTTLE_MS = 20 * 60 * 1e3;
16738
16738
  function channelBusyAckEnabled() {
16739
16739
  return resolveHostBooleanFlag({
16740
16740
  key: "channel-busy-ack",
@@ -16791,7 +16791,7 @@ function decideGiveUpNotice(input) {
16791
16791
  function giveUpNoticeText() {
16792
16792
  return "\u26A0\uFE0F I couldn't read your last message \u2014 please resend it.";
16793
16793
  }
16794
- function oldestPendingMarkerAgeMs(dir, now = Date.now()) {
16794
+ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
16795
16795
  if (!dir) return null;
16796
16796
  let names;
16797
16797
  try {
@@ -16806,7 +16806,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now()) {
16806
16806
  try {
16807
16807
  const raw = JSON.parse(readFileSync9(join7(dir, name), "utf-8"));
16808
16808
  if (raw.discretionary === true) continue;
16809
- if (typeof raw.seen_at === "string" && raw.seen_at) continue;
16809
+ if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
16810
16810
  receivedAt = raw.received_at;
16811
16811
  } catch {
16812
16812
  continue;
@@ -16820,6 +16820,9 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now()) {
16820
16820
  }
16821
16821
  return oldest;
16822
16822
  }
16823
+ function hasInFlightInbound(dir, now = Date.now()) {
16824
+ return oldestPendingMarkerAgeMs(dir, now, { includeSeen: true }) != null;
16825
+ }
16823
16826
  function isPendingMarkerStale(receivedAt, nowMs, thresholdMs) {
16824
16827
  if (!receivedAt) return true;
16825
16828
  const t = Date.parse(receivedAt);
@@ -19798,6 +19801,7 @@ async function pollLoop() {
19798
19801
  paneLogFreshAgeMs
19799
19802
  };
19800
19803
  const ackDecision = decideAckReaction(ackInputs);
19804
+ const arrivedWhileBusy = hasInFlightInbound(PENDING_INBOUND_DIR);
19801
19805
  if (ackDecision === "undeliverable") {
19802
19806
  const cause = classifyUndeliverableCause(ackInputs) ?? "unknown";
19803
19807
  recordChannelDeflection(AGENT_DIR, "telegram", cause);
@@ -19876,7 +19880,7 @@ async function pollLoop() {
19876
19880
  channelPayload
19877
19881
  );
19878
19882
  if (ackDecision === "ack") {
19879
- scheduleBusyAck(chatId, messageId, ackInputs.oldestPendingAgeMs != null);
19883
+ scheduleBusyAck(chatId, messageId, arrivedWhileBusy);
19880
19884
  }
19881
19885
  await mcp.notification({
19882
19886
  method: "notifications/claude/channel",
@@ -34,8 +34,8 @@ import {
34
34
  writeDirectChatSessionState,
35
35
  writeEgressAllowlist,
36
36
  writePersistentClaudeWrapper
37
- } from "./chunk-OW6ERQHP.js";
38
- import "./chunk-MTKFDGXO.js";
37
+ } from "./chunk-6TIVVGA7.js";
38
+ import "./chunk-SDUFTHIF.js";
39
39
  import "./chunk-XWVM4KPK.js";
40
40
  export {
41
41
  EGRESS_BASELINE_DOMAINS,
@@ -74,4 +74,4 @@ export {
74
74
  writeEgressAllowlist,
75
75
  writePersistentClaudeWrapper
76
76
  };
77
- //# sourceMappingURL=persistent-session-3ACIT7F5.js.map
77
+ //# sourceMappingURL=persistent-session-XIW3I5CQ.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  paneLogPath
3
- } from "./chunk-OW6ERQHP.js";
4
- import "./chunk-MTKFDGXO.js";
3
+ } from "./chunk-6TIVVGA7.js";
4
+ import "./chunk-SDUFTHIF.js";
5
5
  import "./chunk-XWVM4KPK.js";
6
6
 
7
7
  // src/lib/responsiveness-probe.ts
@@ -304,4 +304,4 @@ export {
304
304
  readAndResetChannelDeflections,
305
305
  readAndResetChannelLaneClassifications
306
306
  };
307
- //# sourceMappingURL=responsiveness-probe-5OCWCS3M.js.map
307
+ //# sourceMappingURL=responsiveness-probe-7JTG6QMB.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.163",
3
+ "version": "0.28.165",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {