@integrity-labs/agt-cli 0.28.1206 → 0.28.1208

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.
Files changed (29) hide show
  1. package/dist/bin/agt.js +6 -6
  2. package/dist/{chunk-XNOYEQAX.js → chunk-D565LL6O.js} +2 -2
  3. package/dist/{chunk-4KVM4X2T.js → chunk-OU5XSJJX.js} +5 -5
  4. package/dist/{chunk-XMLBF6V3.js → chunk-POD2ZTMG.js} +3 -3
  5. package/dist/{chunk-DL7C7A67.js → chunk-R4EJS4TN.js} +23 -5
  6. package/dist/{chunk-DL7C7A67.js.map → chunk-R4EJS4TN.js.map} +1 -1
  7. package/dist/{chunk-YI3KCZXM.js → chunk-Y26MLRXC.js} +2 -2
  8. package/dist/{claude-code-updater-QZTNU4CD.js → claude-code-updater-P6ZC52QN.js} +3 -3
  9. package/dist/{claude-pair-runtime-GETOMHWO.js → claude-pair-runtime-4O5GIY7X.js} +3 -3
  10. package/dist/lib/manager-worker.js +193 -105
  11. package/dist/lib/manager-worker.js.map +1 -1
  12. package/dist/mcp/direct-chat-channel.js +22 -4
  13. package/dist/mcp/index.js +22 -4
  14. package/dist/mcp/origami.js +22 -4
  15. package/dist/mcp/slack-channel.js +22 -4
  16. package/dist/mcp/telegram-channel.js +22 -4
  17. package/dist/{persistent-session-7CQA4G4I.js → persistent-session-IXSNL2L3.js} +4 -4
  18. package/dist/{responsiveness-probe-FEJ4I6EB.js → responsiveness-probe-6WBSEIIK.js} +4 -4
  19. package/dist/{session-auth-dead-6GJ3PL4P.js → session-auth-dead-M6XDFGDM.js} +3 -3
  20. package/package.json +1 -1
  21. /package/dist/{chunk-XNOYEQAX.js.map → chunk-D565LL6O.js.map} +0 -0
  22. /package/dist/{chunk-4KVM4X2T.js.map → chunk-OU5XSJJX.js.map} +0 -0
  23. /package/dist/{chunk-XMLBF6V3.js.map → chunk-POD2ZTMG.js.map} +0 -0
  24. /package/dist/{chunk-YI3KCZXM.js.map → chunk-Y26MLRXC.js.map} +0 -0
  25. /package/dist/{claude-code-updater-QZTNU4CD.js.map → claude-code-updater-P6ZC52QN.js.map} +0 -0
  26. /package/dist/{claude-pair-runtime-GETOMHWO.js.map → claude-pair-runtime-4O5GIY7X.js.map} +0 -0
  27. /package/dist/{persistent-session-7CQA4G4I.js.map → persistent-session-IXSNL2L3.js.map} +0 -0
  28. /package/dist/{responsiveness-probe-FEJ4I6EB.js.map → responsiveness-probe-6WBSEIIK.js.map} +0 -0
  29. /package/dist/{session-auth-dead-6GJ3PL4P.js.map → session-auth-dead-M6XDFGDM.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  encodeClaudeProjectPath
3
- } from "./chunk-DL7C7A67.js";
3
+ } from "./chunk-R4EJS4TN.js";
4
4
 
5
5
  // src/lib/daily-session.ts
6
6
  import { randomUUID } from "crypto";
@@ -240,4 +240,4 @@ export {
240
240
  peekPreviousSession,
241
241
  readDailySessionPin
242
242
  };
243
- //# sourceMappingURL=chunk-YI3KCZXM.js.map
243
+ //# sourceMappingURL=chunk-Y26MLRXC.js.map
@@ -13,9 +13,9 @@ import {
13
13
  probeClaudeInstalls,
14
14
  readsAsNativeInstall,
15
15
  shouldRunClaudeCodeUpdater
16
- } from "./chunk-XNOYEQAX.js";
16
+ } from "./chunk-D565LL6O.js";
17
17
  import "./chunk-XWVM4KPK.js";
18
- import "./chunk-DL7C7A67.js";
18
+ import "./chunk-R4EJS4TN.js";
19
19
  import "./chunk-AIUIMEUS.js";
20
20
  import "./chunk-DGUM43GV.js";
21
21
  export {
@@ -34,4 +34,4 @@ export {
34
34
  readsAsNativeInstall,
35
35
  shouldRunClaudeCodeUpdater
36
36
  };
37
- //# sourceMappingURL=claude-code-updater-QZTNU4CD.js.map
37
+ //# sourceMappingURL=claude-code-updater-P6ZC52QN.js.map
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  redactPaneFrame,
10
10
  sanitizeTerminalFrame
11
- } from "./chunk-DL7C7A67.js";
11
+ } from "./chunk-R4EJS4TN.js";
12
12
  import {
13
13
  CLAUDE_CONFIG_DIR_ENV,
14
14
  claudeConfigDirFor,
@@ -321,7 +321,7 @@ async function spawnPairSession(session) {
321
321
  return { ok: true };
322
322
  } catch {
323
323
  }
324
- const { resolveClaudeBinary } = await import("./persistent-session-7CQA4G4I.js");
324
+ const { resolveClaudeBinary } = await import("./persistent-session-IXSNL2L3.js");
325
325
  const claudeBin = resolveClaudeBinary();
326
326
  const pairEnv = {
327
327
  ...process.env,
@@ -836,4 +836,4 @@ export {
836
836
  startClaudePair,
837
837
  submitClaudePairCode
838
838
  };
839
- //# sourceMappingURL=claude-pair-runtime-GETOMHWO.js.map
839
+ //# sourceMappingURL=claude-pair-runtime-4O5GIY7X.js.map
@@ -85,7 +85,7 @@ import {
85
85
  tripClass,
86
86
  writeEtcEnvironment,
87
87
  writeProfileDScript
88
- } from "../chunk-4KVM4X2T.js";
88
+ } from "../chunk-OU5XSJJX.js";
89
89
  import {
90
90
  CLAUDE_CODE_SECURITY_FLOOR,
91
91
  SELF_UPDATE_TIMEOUTS,
@@ -99,7 +99,7 @@ import {
99
99
  runSafeCleanup,
100
100
  tightestDiskStat,
101
101
  withPackageCacheLock
102
- } from "../chunk-XNOYEQAX.js";
102
+ } from "../chunk-D565LL6O.js";
103
103
  import {
104
104
  rewriteSupervisorApiKey,
105
105
  supervisorChannelsRefusing
@@ -192,7 +192,7 @@ import {
192
192
  webFetchBaselineValue,
193
193
  webFetchRestartNeeded,
194
194
  writeEgressAllowlist
195
- } from "../chunk-XMLBF6V3.js";
195
+ } from "../chunk-POD2ZTMG.js";
196
196
  import {
197
197
  isAgentIdle,
198
198
  isStaleForToday,
@@ -202,7 +202,7 @@ import {
202
202
  sessionTranscriptDir,
203
203
  subagentActivityAgeSeconds,
204
204
  transcriptActivityAgeSeconds
205
- } from "../chunk-YI3KCZXM.js";
205
+ } from "../chunk-Y26MLRXC.js";
206
206
  import {
207
207
  classifyUnanswerablePane,
208
208
  focusedConfirmDialogBlock,
@@ -330,7 +330,7 @@ import {
330
330
  stabiliseResetInstant,
331
331
  sumTranscriptUsageInWindow,
332
332
  summarizeTranscriptActivity
333
- } from "../chunk-DL7C7A67.js";
333
+ } from "../chunk-R4EJS4TN.js";
334
334
  import {
335
335
  CLAUDE_CONFIG_DIR_ENV,
336
336
  claudeConfigDirFor,
@@ -9701,6 +9701,26 @@ function pickHintVariant(rng = Math.random) {
9701
9701
  return HINT_VARIANTS[idx];
9702
9702
  }
9703
9703
 
9704
+ // src/lib/manager/channels/transient-retry.ts
9705
+ var MAX_DELIVERY_ATTEMPTS = 3;
9706
+ var DELIVERY_RETRY_BUDGET_MS = 2e4;
9707
+ var BACKOFF_MS = [500, 1500];
9708
+ var defaultSleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
9709
+ function deliveryRetryDeadline() {
9710
+ return Date.now() + DELIVERY_RETRY_BUDGET_MS;
9711
+ }
9712
+ async function withTransientRetry(attempt, options = {}) {
9713
+ const deadline = options.deadline ?? deliveryRetryDeadline();
9714
+ const sleep2 = options.sleep ?? defaultSleep;
9715
+ for (let n = 1; ; n += 1) {
9716
+ const result = await attempt();
9717
+ if (!result.transient || n >= MAX_DELIVERY_ATTEMPTS) return result.value;
9718
+ const waitMs = Math.max(BACKOFF_MS[n - 1] ?? 0, result.retryAfterMs ?? 0);
9719
+ if (Date.now() + waitMs > deadline) return result.value;
9720
+ await sleep2(waitMs);
9721
+ }
9722
+ }
9723
+
9704
9724
  // src/lib/manager/channels/slack.ts
9705
9725
  async function sendSlackWebhookMessage(text) {
9706
9726
  const alertSlackWebhook2 = getAlertSlackWebhook();
@@ -9728,44 +9748,88 @@ async function sendSlackWebhookMessage(text) {
9728
9748
  log(`Slack webhook error: ${err.message}`);
9729
9749
  }
9730
9750
  }
9731
- async function sendSlackChannelMessage(agentCodeName, channelId, text) {
9732
- const result = await postSlackChannelMessage(agentCodeName, channelId, text);
9733
- return result.ok;
9734
- }
9735
- async function postSlackChannelMessage(agentCodeName, channelId, text, threadTs) {
9751
+ async function postSlackChannelMessage(agentCodeName, channelId, text, threadTs, options = {}) {
9736
9752
  const botToken = agentChannelTokens.get(agentCodeName)?.slack;
9737
9753
  if (!botToken) {
9738
9754
  log(`No Slack bot token cached for '${agentCodeName}' \u2014 cannot post to ${channelId}`);
9739
9755
  return { ok: false };
9740
9756
  }
9757
+ const body = { channel: channelId, text };
9758
+ if (threadTs) body.thread_ts = threadTs;
9759
+ const attempt = async () => {
9760
+ const result = await slackApiAttempt(botToken, "chat.postMessage", body);
9761
+ if (!result.value.ok) {
9762
+ log(`Slack chat.postMessage failed for '${agentCodeName}' to ${channelId}: ${result.value.error}`);
9763
+ return { ...result, value: { ok: false, error: result.value.error } };
9764
+ }
9765
+ return { ...result, value: { ok: true, ts: result.value.ts } };
9766
+ };
9767
+ if (!options.retry) return (await attempt()).value;
9768
+ return withTransientRetry(attempt, { deadline: options.deadline });
9769
+ }
9770
+ async function openSlackDmChannel(agentCodeName, botToken, slackUserId, options = {}) {
9771
+ const opened = await withTransientRetry(async () => {
9772
+ const result = await slackApiAttempt(
9773
+ botToken,
9774
+ "conversations.open",
9775
+ { users: slackUserId }
9776
+ );
9777
+ if (!result.value.ok) {
9778
+ log(`Slack conversations.open failed for '${agentCodeName}': ${result.value.error}`);
9779
+ }
9780
+ return result;
9781
+ }, options);
9782
+ if (!opened.ok || !opened.channel?.id) return { ok: false, error: opened.error ?? "unknown" };
9783
+ return { ok: true, channelId: opened.channel.id };
9784
+ }
9785
+ var TRANSIENT_SLACK_ERRORS = /* @__PURE__ */ new Set([
9786
+ "ratelimited",
9787
+ "rate_limited",
9788
+ "internal_error",
9789
+ "fatal_error",
9790
+ "service_unavailable",
9791
+ "request_timeout"
9792
+ ]);
9793
+ function parseRetryAfterMs(header) {
9794
+ if (header === null) return void 0;
9795
+ const seconds = Number(header);
9796
+ return Number.isFinite(seconds) && seconds >= 0 ? seconds * 1e3 : void 0;
9797
+ }
9798
+ async function slackApiAttempt(botToken, method, body) {
9799
+ const fail = (error, transient, retryAfterMs) => ({
9800
+ value: { ok: false, error },
9801
+ transient,
9802
+ retryAfterMs
9803
+ });
9804
+ const controller = new AbortController();
9805
+ const timeout = setTimeout(() => controller.abort(), 5e3);
9741
9806
  try {
9742
- const controller = new AbortController();
9743
- const timeout = setTimeout(() => controller.abort(), 5e3);
9744
- try {
9745
- const body = { channel: channelId, text };
9746
- if (threadTs) body.thread_ts = threadTs;
9747
- const response = await fetch("https://slack.com/api/chat.postMessage", {
9748
- method: "POST",
9749
- headers: {
9750
- "Authorization": `Bearer ${botToken}`,
9751
- "Content-Type": "application/json"
9752
- },
9753
- body: JSON.stringify(body),
9754
- signal: controller.signal
9755
- });
9756
- clearTimeout(timeout);
9757
- const data = await response.json();
9758
- if (!data.ok) {
9759
- log(`Slack chat.postMessage failed for '${agentCodeName}' to ${channelId}: ${data.error}`);
9760
- return { ok: false, error: data.error };
9761
- }
9762
- return { ok: true, ts: data.ts };
9763
- } finally {
9764
- clearTimeout(timeout);
9807
+ const response = await fetch(`https://slack.com/api/${method}`, {
9808
+ method: "POST",
9809
+ headers: {
9810
+ "Authorization": `Bearer ${botToken}`,
9811
+ "Content-Type": "application/json; charset=utf-8"
9812
+ },
9813
+ body: JSON.stringify(body),
9814
+ signal: controller.signal
9815
+ });
9816
+ if (response.status === 429) {
9817
+ return fail("ratelimited", true, parseRetryAfterMs(response.headers.get("retry-after")));
9765
9818
  }
9819
+ if (response.status >= 500) return fail(`http_${response.status}`, true);
9820
+ if (!response.ok) return fail(`http_${response.status}`, false);
9821
+ const data = await response.json();
9822
+ return {
9823
+ value: data,
9824
+ transient: !data.ok && TRANSIENT_SLACK_ERRORS.has(data.error ?? ""),
9825
+ retryAfterMs: parseRetryAfterMs(response.headers.get("retry-after"))
9826
+ };
9766
9827
  } catch (err) {
9767
- log(`Slack channel message error for '${agentCodeName}': ${err.message}`);
9768
- return { ok: false };
9828
+ const name = err.name;
9829
+ if (name === "AbortError") return fail("timeout", true);
9830
+ return fail(name === "SyntaxError" ? "invalid_response" : "network_error", true);
9831
+ } finally {
9832
+ clearTimeout(timeout);
9769
9833
  }
9770
9834
  }
9771
9835
  async function maybePostSlackThreadHint(agentCodeName, channelId, primaryTs) {
@@ -9782,6 +9846,27 @@ async function maybePostSlackThreadHint(agentCodeName, channelId, primaryTs) {
9782
9846
 
9783
9847
  // src/lib/manager/channels/telegram.ts
9784
9848
  import https from "https";
9849
+ async function sendTelegramMessageWithRetry(botToken, body, options = {}) {
9850
+ let thrown;
9851
+ const result = await withTransientRetry(async () => {
9852
+ thrown = void 0;
9853
+ try {
9854
+ const value = await telegramApiCall(botToken, "sendMessage", body);
9855
+ const code = value.error_code ?? 0;
9856
+ const retryAfter = value.parameters?.retry_after;
9857
+ return {
9858
+ value,
9859
+ transient: !value.ok && (code === 429 || code >= 500),
9860
+ retryAfterMs: typeof retryAfter === "number" ? retryAfter * 1e3 : void 0
9861
+ };
9862
+ } catch (err) {
9863
+ thrown = err;
9864
+ return { value: null, transient: true };
9865
+ }
9866
+ }, options);
9867
+ if (result === null) throw thrown;
9868
+ return result;
9869
+ }
9785
9870
  function telegramApiCall(botToken, method, body) {
9786
9871
  return new Promise((resolve2, reject) => {
9787
9872
  const postData = JSON.stringify(body);
@@ -9984,8 +10069,9 @@ async function sendTaskNotification(agentCodeName, channel, to, text) {
9984
10069
  log(`No Slack bot token for '${agentCodeName}' \u2014 targeted notification dropped`);
9985
10070
  return { ok: false, error_code: "SLACK_NO_TOKEN" };
9986
10071
  }
9987
- const sent = await sendSlackChannelMessage(agentCodeName, channelId, text);
9988
- return sent ? { ok: true } : { ok: false, error_code: "SLACK_SEND_FAILED" };
10072
+ const sent = await postSlackChannelMessage(agentCodeName, channelId, text, void 0, { retry: true });
10073
+ if (sent.ok) return { ok: true };
10074
+ return { ok: false, error_code: sent.error ? `SLACK_SEND_FAILED:${sent.error}` : "SLACK_SEND_FAILED" };
9989
10075
  }
9990
10076
  if (channel === "telegram") {
9991
10077
  const botToken = tokens?.telegram;
@@ -10000,7 +10086,7 @@ async function sendTaskNotification(agentCodeName, channel, to, text) {
10000
10086
  return { ok: false, error_code: "TELEGRAM_CHAT_NOT_ALLOWED" };
10001
10087
  }
10002
10088
  try {
10003
- const result = await telegramApiCall(botToken, "sendMessage", { chat_id: chatId, text });
10089
+ const result = await sendTelegramMessageWithRetry(botToken, { chat_id: chatId, text });
10004
10090
  if (!result.ok) {
10005
10091
  log(`Telegram sendMessage failed for '${agentCodeName}': ${result.description}`);
10006
10092
  return { ok: false, error_code: `TELEGRAM_SEND_FAILED:${result.description ?? "unknown"}` };
@@ -10228,11 +10314,19 @@ async function enqueueScheduledTaskNotice(opts) {
10228
10314
 
10229
10315
  // src/lib/manager/delivery/scheduled-output.ts
10230
10316
  async function deliverScheduledTaskOutput(agentCodeName, agentId, rawTarget, body, taskId) {
10317
+ let last = null;
10318
+ await runDelivery(agentCodeName, agentId, rawTarget, body, taskId, async (report) => {
10319
+ last = report;
10320
+ await reportDeliveryStatus(agentId, taskId, report);
10321
+ });
10322
+ return last;
10323
+ }
10324
+ async function runDelivery(agentCodeName, agentId, rawTarget, body, taskId, report) {
10231
10325
  const withLink = (b, medium) => withScheduleLinkFooter({ body: b, medium, codeName: agentCodeName, agentId, taskId, log });
10232
10326
  if (typeof rawTarget === "string") {
10233
10327
  if (rawTarget.startsWith("channel:")) {
10234
10328
  const result = await sendTaskNotification(agentCodeName, "slack", rawTarget, withLink(body, "slack"));
10235
- await reportDeliveryStatus(agentId, taskId, {
10329
+ await report({
10236
10330
  status: result.ok ? "ok" : "failed",
10237
10331
  medium: "slack",
10238
10332
  error_code: result.ok ? null : result.error_code ?? "SLACK_SEND_FAILED"
@@ -10241,7 +10335,7 @@ async function deliverScheduledTaskOutput(agentCodeName, agentId, rawTarget, bod
10241
10335
  }
10242
10336
  if (rawTarget.startsWith("chat:")) {
10243
10337
  const result = await sendTaskNotification(agentCodeName, "telegram", rawTarget, withLink(body, "telegram"));
10244
- await reportDeliveryStatus(agentId, taskId, {
10338
+ await report({
10245
10339
  status: result.ok ? "ok" : "failed",
10246
10340
  medium: "telegram",
10247
10341
  error_code: result.ok ? null : result.error_code ?? "TELEGRAM_SEND_FAILED"
@@ -10249,27 +10343,28 @@ async function deliverScheduledTaskOutput(agentCodeName, agentId, rawTarget, bod
10249
10343
  return;
10250
10344
  }
10251
10345
  log(`[delivery] Unrecognised legacy delivery_to string for '${agentCodeName}': ${rawTarget.slice(0, 60)}`);
10252
- await reportDeliveryStatus(agentId, taskId, { status: "failed", error_code: "LEGACY_DELIVERY_TO_UNRECOGNISED" });
10346
+ await report({ status: "failed", error_code: "LEGACY_DELIVERY_TO_UNRECOGNISED" });
10253
10347
  return;
10254
10348
  }
10255
10349
  const parsed = parseDeliveryTarget(rawTarget);
10256
10350
  if (isParseError(parsed)) {
10257
10351
  log(`[delivery] Malformed delivery_to for '${agentCodeName}': ${parsed.code} \u2014 ${parsed.detail}`);
10258
- await reportDeliveryStatus(agentId, taskId, { status: "failed", error_code: parsed.code });
10352
+ await report({ status: "failed", error_code: parsed.code });
10259
10353
  return;
10260
10354
  }
10261
10355
  if (parsed.kind === "channel") {
10262
10356
  if (parsed.provider === "slack") {
10263
10357
  const channelId = parsed.channel_id ?? "";
10264
10358
  const threadTs = parsed.thread_ts;
10265
- let sent = await postSlackChannelMessage(agentCodeName, channelId, withLink(body, "slack"), threadTs);
10359
+ const retry = { retry: true, deadline: deliveryRetryDeadline() };
10360
+ let sent = await postSlackChannelMessage(agentCodeName, channelId, withLink(body, "slack"), threadTs, retry);
10266
10361
  let deliveredInThread = Boolean(threadTs);
10267
10362
  if (!sent.ok && threadTs && (sent.error === "thread_not_found" || sent.error === "message_not_found")) {
10268
10363
  log(`[delivery] Originating thread ${threadTs} gone in ${channelId} for '${agentCodeName}' \u2014 falling back to top-level post`);
10269
- sent = await postSlackChannelMessage(agentCodeName, channelId, withLink(body, "slack"));
10364
+ sent = await postSlackChannelMessage(agentCodeName, channelId, withLink(body, "slack"), void 0, retry);
10270
10365
  deliveredInThread = false;
10271
10366
  }
10272
- await reportDeliveryStatus(agentId, taskId, {
10367
+ await report({
10273
10368
  status: sent.ok ? "ok" : "failed",
10274
10369
  medium: "slack",
10275
10370
  // Preserve Slack's concrete failure code (channel_not_found,
@@ -10290,7 +10385,7 @@ async function deliverScheduledTaskOutput(agentCodeName, agentId, rawTarget, bod
10290
10385
  const chatId = parsed.chat_id ?? "";
10291
10386
  const toStr = `chat:${chatId}`;
10292
10387
  const result = await sendTaskNotification(agentCodeName, "telegram", toStr, withLink(body, "telegram"));
10293
- await reportDeliveryStatus(agentId, taskId, {
10388
+ await report({
10294
10389
  status: result.ok ? "ok" : "failed",
10295
10390
  medium: "telegram",
10296
10391
  error_code: result.ok ? null : result.error_code ?? "TELEGRAM_SEND_FAILED"
@@ -10304,13 +10399,13 @@ async function deliverScheduledTaskOutput(agentCodeName, agentId, rawTarget, bod
10304
10399
  const agentRow = agentInfoForDelivery.get(agentCodeName);
10305
10400
  if (!agentRow) {
10306
10401
  log(`[delivery] No agent metadata cached for '${agentCodeName}' \u2014 dropping DM`);
10307
- await reportDeliveryStatus(agentId, taskId, { status: "failed", error_code: "AGENT_METADATA_UNAVAILABLE" });
10402
+ await report({ status: "failed", error_code: "AGENT_METADATA_UNAVAILABLE" });
10308
10403
  return;
10309
10404
  }
10310
10405
  const resolved = resolveDmTarget(parsed, agentRow.resolverAgent, agentRow.peopleByPersonId);
10311
10406
  if (isResolveError(resolved)) {
10312
10407
  log(`[delivery] Cannot resolve DM target for '${agentCodeName}': ${resolved.code} \u2014 ${resolved.detail}`);
10313
- await reportDeliveryStatus(agentId, taskId, { status: "failed", error_code: resolved.code });
10408
+ await report({ status: "failed", error_code: resolved.code });
10314
10409
  return;
10315
10410
  }
10316
10411
  const attributionBody = appendDmFooter(
@@ -10323,47 +10418,24 @@ async function deliverScheduledTaskOutput(agentCodeName, agentId, rawTarget, bod
10323
10418
  const tokens = agentChannelTokens.get(agentCodeName);
10324
10419
  const botToken = tokens?.slack;
10325
10420
  if (!botToken) {
10326
- await reportDeliveryStatus(agentId, taskId, { status: "failed", error_code: "SLACK_MISSING_SCOPE", medium: "slack" });
10421
+ await report({ status: "failed", error_code: "SLACK_MISSING_SCOPE", medium: "slack" });
10327
10422
  log(`[delivery] No Slack bot token for '${agentCodeName}' \u2014 DM dropped`);
10328
10423
  return;
10329
10424
  }
10330
- try {
10331
- const controller = new AbortController();
10332
- const timeoutHandle = setTimeout(() => controller.abort(), 5e3);
10333
- let openJson;
10334
- try {
10335
- const openResp = await fetch("https://slack.com/api/conversations.open", {
10336
- method: "POST",
10337
- headers: {
10338
- Authorization: `Bearer ${botToken}`,
10339
- "Content-Type": "application/json; charset=utf-8"
10340
- },
10341
- body: JSON.stringify({ users: resolved.slack_user_id }),
10342
- signal: controller.signal
10343
- });
10344
- openJson = await openResp.json();
10345
- } finally {
10346
- clearTimeout(timeoutHandle);
10347
- }
10348
- if (!openJson.ok || !openJson.channel?.id) {
10349
- const errCode = openJson.error === "missing_scope" ? "SLACK_MISSING_SCOPE" : `SLACK_OPEN_FAILED:${openJson.error ?? "unknown"}`;
10350
- log(`[delivery] conversations.open failed for '${agentCodeName}': ${openJson.error}`);
10351
- await reportDeliveryStatus(agentId, taskId, { status: "failed", error_code: errCode, medium: "slack" });
10352
- return;
10353
- }
10354
- const sent = await postSlackChannelMessage(agentCodeName, openJson.channel.id, footeredBody);
10355
- await reportDeliveryStatus(agentId, taskId, {
10356
- status: sent.ok ? "ok" : "failed",
10357
- medium: "slack",
10358
- error_code: sent.ok ? null : "SLACK_SEND_FAILED"
10359
- });
10360
- if (sent.ok) await maybePostSlackThreadHint(agentCodeName, openJson.channel.id, sent.ts);
10361
- } catch (err) {
10362
- const isAbort = err.name === "AbortError";
10363
- const errCode = isAbort ? "SLACK_OPEN_TIMEOUT" : "SLACK_EXCEPTION";
10364
- log(`[delivery] Slack DM ${isAbort ? "timeout" : "failure"} for '${agentCodeName}': ${err.message}`);
10365
- await reportDeliveryStatus(agentId, taskId, { status: "failed", error_code: errCode, medium: "slack" });
10425
+ const deadline = deliveryRetryDeadline();
10426
+ const opened = await openSlackDmChannel(agentCodeName, botToken, resolved.slack_user_id, { deadline });
10427
+ if (!opened.ok || !opened.channelId) {
10428
+ const errCode = opened.error === "missing_scope" ? "SLACK_MISSING_SCOPE" : opened.error === "timeout" ? "SLACK_OPEN_TIMEOUT" : `SLACK_OPEN_FAILED:${opened.error ?? "unknown"}`;
10429
+ await report({ status: "failed", error_code: errCode, medium: "slack" });
10430
+ return;
10366
10431
  }
10432
+ const sent = await postSlackChannelMessage(agentCodeName, opened.channelId, footeredBody, void 0, { retry: true, deadline });
10433
+ await report({
10434
+ status: sent.ok ? "ok" : "failed",
10435
+ medium: "slack",
10436
+ error_code: sent.ok ? null : sent.error ? `SLACK_SEND_FAILED:${sent.error}` : "SLACK_SEND_FAILED"
10437
+ });
10438
+ if (sent.ok) await maybePostSlackThreadHint(agentCodeName, opened.channelId, sent.ts);
10367
10439
  return;
10368
10440
  }
10369
10441
  if (resolved.kind === "dm" && resolved.medium === "telegram") {
@@ -10371,24 +10443,24 @@ async function deliverScheduledTaskOutput(agentCodeName, agentId, rawTarget, bod
10371
10443
  const botToken = tokens?.telegram;
10372
10444
  if (!botToken) {
10373
10445
  log(`[delivery] No Telegram bot token for '${agentCodeName}' \u2014 DM dropped`);
10374
- await reportDeliveryStatus(agentId, taskId, { status: "failed", error_code: "TELEGRAM_NO_TOKEN", medium: "telegram" });
10446
+ await report({ status: "failed", error_code: "TELEGRAM_NO_TOKEN", medium: "telegram" });
10375
10447
  return;
10376
10448
  }
10377
10449
  try {
10378
- const result = await telegramApiCall(botToken, "sendMessage", {
10450
+ const result = await sendTelegramMessageWithRetry(botToken, {
10379
10451
  chat_id: resolved.telegram_chat_id,
10380
10452
  text: footeredBody
10381
10453
  });
10382
10454
  if (!result.ok) {
10383
10455
  log(`[delivery] Telegram DM failed for '${agentCodeName}': ${result.description}`);
10384
- await reportDeliveryStatus(agentId, taskId, { status: "failed", error_code: `TELEGRAM_SEND_FAILED:${result.description ?? "unknown"}`, medium: "telegram" });
10456
+ await report({ status: "failed", error_code: `TELEGRAM_SEND_FAILED:${result.description ?? "unknown"}`, medium: "telegram" });
10385
10457
  return;
10386
10458
  }
10387
- await reportDeliveryStatus(agentId, taskId, { status: "ok", medium: "telegram" });
10459
+ await report({ status: "ok", medium: "telegram" });
10388
10460
  await maybeSendTelegramFollowUpHint(agentCodeName, botToken, resolved.telegram_chat_id);
10389
10461
  } catch (err) {
10390
10462
  log(`[delivery] Telegram DM exception for '${agentCodeName}': ${err.message}`);
10391
- await reportDeliveryStatus(agentId, taskId, { status: "failed", error_code: "TELEGRAM_EXCEPTION", medium: "telegram" });
10463
+ await report({ status: "failed", error_code: "TELEGRAM_EXCEPTION", medium: "telegram" });
10392
10464
  }
10393
10465
  }
10394
10466
  }
@@ -10502,9 +10574,22 @@ async function runScheduledCardDelivery(codeName, agentId, cardId, completedBy,
10502
10574
  return "retry";
10503
10575
  }
10504
10576
  markScheduledCardDeliveryComplete(cardId);
10577
+ if (outcome.deliveryFailed) {
10578
+ log(`[scheduled-kanban] delivery: result from card ${cardId} (task '${task.name}') on '${codeName}' NOT delivered: ${outcome.deliveryFailed.error_code ?? "unknown"}`);
10579
+ await recordDeliveryFailureOnCard(codeName, agentId, cardId, outcome.deliveryFailed);
10580
+ return "delivered";
10581
+ }
10505
10582
  log(`[scheduled-kanban] Delivered result from card ${cardId} (task '${task.name}') for '${codeName}'`);
10506
10583
  return "delivered";
10507
10584
  }
10585
+ async function recordDeliveryFailureOnCard(codeName, agentId, cardId, failure) {
10586
+ const note = `Delivery failed: this result did not reach its destination on ${failure.medium ?? "its channel"} (${failure.error_code ?? "unknown"}). Automatic attempts are finished, so nothing will re-send it. The result is still on this card: re-send it by hand.`;
10587
+ try {
10588
+ await api.post("/host/kanban", { agent_id: agentId, update: [{ id: cardId, notes: note }] });
10589
+ } catch (err) {
10590
+ log(`[scheduled-kanban] delivery: could not record the failed delivery on card ${cardId} on '${codeName}': ${err.message}`);
10591
+ }
10592
+ }
10508
10593
  async function reconcileScheduledRuns(codeName, agentId, board) {
10509
10594
  const m = scheduledRunsByCode.get(codeName);
10510
10595
  if (!m || m.size === 0) return;
@@ -10770,13 +10855,16 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
10770
10855
  }
10771
10856
  }
10772
10857
  if (delivery?.mode === "announce" && delivery.to) {
10773
- await deliverScheduledTaskOutput(
10858
+ const report = await deliverScheduledTaskOutput(
10774
10859
  codeName,
10775
10860
  agentId,
10776
10861
  delivery.to,
10777
10862
  truncateForDelivery(output),
10778
10863
  delivery.taskId
10779
10864
  );
10865
+ if (report?.status === "failed") {
10866
+ return { ok: true, deliveryFailed: { medium: report.medium ?? null, error_code: report.error_code ?? null } };
10867
+ }
10780
10868
  }
10781
10869
  return { ok: true };
10782
10870
  } catch (err) {
@@ -15562,7 +15650,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
15562
15650
  var dayRolloverInboundHold = /* @__PURE__ */ new Map();
15563
15651
  var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
15564
15652
  async function channelInboundActivityAgeSecondsFor(codeName) {
15565
- const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-FEJ4I6EB.js");
15653
+ const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-6WBSEIIK.js");
15566
15654
  const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
15567
15655
  if (newest === null) return null;
15568
15656
  return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
@@ -16359,7 +16447,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
16359
16447
  var lastVersionCheckAt = 0;
16360
16448
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
16361
16449
  var lastResponsivenessProbeAt = 0;
16362
- var agtCliVersion = true ? "0.28.1206" : "dev";
16450
+ var agtCliVersion = true ? "0.28.1208" : "dev";
16363
16451
  function resolveBrewPath(execFileSync3) {
16364
16452
  try {
16365
16453
  const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -18263,7 +18351,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
18263
18351
  if (codeNames.length === 0) return;
18264
18352
  void (async () => {
18265
18353
  try {
18266
- const { collectDiagnostics } = await import("../persistent-session-7CQA4G4I.js");
18354
+ const { collectDiagnostics } = await import("../persistent-session-IXSNL2L3.js");
18267
18355
  await api.post("/host/heartbeat", {
18268
18356
  host_id: hostId,
18269
18357
  agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -18406,7 +18494,7 @@ async function pollCycleInner() {
18406
18494
  }
18407
18495
  try {
18408
18496
  const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
18409
- const { collectDiagnostics } = await import("../persistent-session-7CQA4G4I.js");
18497
+ const { collectDiagnostics } = await import("../persistent-session-IXSNL2L3.js");
18410
18498
  const diagCodeNames = [...agentState.persistentSessionAgents];
18411
18499
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
18412
18500
  let tailscaleHostname;
@@ -18664,7 +18752,7 @@ async function pollCycleInner() {
18664
18752
  }
18665
18753
  try {
18666
18754
  const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
18667
- const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-QZTNU4CD.js");
18755
+ const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-P6ZC52QN.js");
18668
18756
  const securityFloor = currentSecurityFloor();
18669
18757
  claudeUpdaterInFlight = true;
18670
18758
  if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
@@ -18699,7 +18787,7 @@ async function pollCycleInner() {
18699
18787
  collectPanelessActivityProbes,
18700
18788
  getResponsivenessIntervalMs,
18701
18789
  occupancyQualificationClassifications
18702
- } = await import("../responsiveness-probe-FEJ4I6EB.js");
18790
+ } = await import("../responsiveness-probe-6WBSEIIK.js");
18703
18791
  const probeIntervalMs = getResponsivenessIntervalMs();
18704
18792
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
18705
18793
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -18816,7 +18904,7 @@ async function pollCycleInner() {
18816
18904
  collectResponsivenessProbes,
18817
18905
  livePendingInboundOldestAgeSeconds,
18818
18906
  parkPendingInbound
18819
- } = await import("../responsiveness-probe-FEJ4I6EB.js");
18907
+ } = await import("../responsiveness-probe-6WBSEIIK.js");
18820
18908
  const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-M6AFZWNU.js");
18821
18909
  const wedgeNow = /* @__PURE__ */ new Date();
18822
18910
  const liveAgents = agentState.persistentSessionAgents;
@@ -19102,7 +19190,7 @@ async function pollCycleInner() {
19102
19190
  }
19103
19191
  }
19104
19192
  );
19105
- const { parkPendingInbound } = await import("../responsiveness-probe-FEJ4I6EB.js");
19193
+ const { parkPendingInbound } = await import("../responsiveness-probe-6WBSEIIK.js");
19106
19194
  const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
19107
19195
  paneFatalStreak.delete(codeName);
19108
19196
  paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
@@ -19133,7 +19221,7 @@ async function pollCycleInner() {
19133
19221
  TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
19134
19222
  bindSourceEscalations
19135
19223
  } = await import("../transcript-mount-health-OHE6IVJV.js");
19136
- const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-7CQA4G4I.js");
19224
+ const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-IXSNL2L3.js");
19137
19225
  const mountConfig = resolveTranscriptMountConfig();
19138
19226
  const liveAgents = agentState.persistentSessionAgents;
19139
19227
  for (const tracked of [
@@ -19298,7 +19386,7 @@ async function pollCycleInner() {
19298
19386
  }
19299
19387
  try {
19300
19388
  const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
19301
- const { probeSessionAuth } = await import("../session-auth-dead-6GJ3PL4P.js");
19389
+ const { probeSessionAuth } = await import("../session-auth-dead-M6XDFGDM.js");
19302
19390
  const observations = [];
19303
19391
  const pendingCacheCommits = [];
19304
19392
  const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
@@ -24028,7 +24116,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
24028
24116
  try {
24029
24117
  const freshId = rotateSessionForWedge(codeName);
24030
24118
  consecutiveWedgeCycles.delete(codeName);
24031
- const { parkPendingInbound: parkForRestart } = await import("../responsiveness-probe-FEJ4I6EB.js");
24119
+ const { parkPendingInbound: parkForRestart } = await import("../responsiveness-probe-6WBSEIIK.js");
24032
24120
  const { parked, deadLettered } = parkForRestart(codeName, /* @__PURE__ */ new Date());
24033
24121
  const parkNote = parked > 0 ? `, ${parked} inbound parked` : "";
24034
24122
  const deadNote = deadLettered > 0 ? `, ${deadLettered} undeliverable dead-lettered` : "";
@@ -24071,7 +24159,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
24071
24159
  void api.post("/host/restart-ack", { host_id: hostId, agent_id: agentId, restart_requested_at: requestedAt }).catch((err) => log(`[restart-lane] ack failed for '${codeName}': ${err.message}`));
24072
24160
  void (async () => {
24073
24161
  try {
24074
- const { collectDiagnostics } = await import("../persistent-session-7CQA4G4I.js");
24162
+ const { collectDiagnostics } = await import("../persistent-session-IXSNL2L3.js");
24075
24163
  await api.post("/host/heartbeat", {
24076
24164
  host_id: hostId,
24077
24165
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -24122,7 +24210,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
24122
24210
  }
24123
24211
  try {
24124
24212
  const hostId = await getHostId();
24125
- const { collectDiagnostics } = await import("../persistent-session-7CQA4G4I.js");
24213
+ const { collectDiagnostics } = await import("../persistent-session-IXSNL2L3.js");
24126
24214
  await api.post("/host/heartbeat", {
24127
24215
  host_id: hostId,
24128
24216
  agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
@@ -24824,7 +24912,7 @@ async function processClaudePairSessions(agents) {
24824
24912
  snapshotPairConfig,
24825
24913
  // ENG-11659: result -> report body + the manager.log line that records it.
24826
24914
  planPairStartReport
24827
- } = await import("../claude-pair-runtime-GETOMHWO.js");
24915
+ } = await import("../claude-pair-runtime-4O5GIY7X.js");
24828
24916
  const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
24829
24917
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
24830
24918
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);