@integrity-labs/agt-cli 0.24.6 → 0.24.8

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.
@@ -14224,7 +14224,7 @@ function decideSlackMessageForward(evt) {
14224
14224
  return { forward: true };
14225
14225
  }
14226
14226
  function decideSlackEngagement(input) {
14227
- const isExplicitMention = input.type === "app_mention" || input.botUserId.length > 0 && input.text.includes(`<@${input.botUserId}>`);
14227
+ const isExplicitMention = input.type === "app_mention" || !!input.botUserId && input.text.includes(`<@${input.botUserId}>`);
14228
14228
  return !(input.isAutoFollowed && !isExplicitMention);
14229
14229
  }
14230
14230
  function decideSlackAckReaction(input) {
@@ -15483,6 +15483,35 @@ function createSlackBotUserIdClient(args) {
15483
15483
  return false;
15484
15484
  }
15485
15485
  }
15486
+ let lastReportedHealth = null;
15487
+ async function emitHealth(healthy) {
15488
+ const post = async () => {
15489
+ const token = await getToken();
15490
+ return fetchImpl(`${base}/host/channel-health`, {
15491
+ method: "POST",
15492
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
15493
+ body: JSON.stringify({ agent_id: agentId, channel_id: "slack", healthy }),
15494
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS2)
15495
+ });
15496
+ };
15497
+ try {
15498
+ let resp = await post();
15499
+ if (resp.status === 401) {
15500
+ cachedToken = null;
15501
+ cachedTokenExpiresAt = 0;
15502
+ resp = await post();
15503
+ }
15504
+ if (!resp.ok) {
15505
+ const body = await resp.text().catch(() => "");
15506
+ log(`channel-health: POST failed (${resp.status}) healthy=${healthy}: ${body.slice(0, 200)}`);
15507
+ return false;
15508
+ }
15509
+ return true;
15510
+ } catch (err) {
15511
+ log(`channel-health: emit threw healthy=${healthy}: ${err.message}`);
15512
+ return false;
15513
+ }
15514
+ }
15486
15515
  return {
15487
15516
  report(botUserId2) {
15488
15517
  if (reportedFor === botUserId2) return;
@@ -15494,6 +15523,14 @@ function createSlackBotUserIdClient(args) {
15494
15523
  reportedFor = null;
15495
15524
  }
15496
15525
  });
15526
+ },
15527
+ reportAuthHealth(healthy) {
15528
+ if (lastReportedHealth === healthy) return;
15529
+ const snapshot = healthy;
15530
+ lastReportedHealth = snapshot;
15531
+ void emitHealth(healthy).then((ok) => {
15532
+ if (!ok && lastReportedHealth === snapshot) lastReportedHealth = null;
15533
+ });
15497
15534
  }
15498
15535
  };
15499
15536
  }
@@ -15885,7 +15922,12 @@ async function postSlackMessage(body) {
15885
15922
  signal: AbortSignal.timeout(SLACK_DOWNLOAD_TIMEOUT_MS)
15886
15923
  });
15887
15924
  const data = await res.json();
15888
- if (data.ok) recordActivity("reply");
15925
+ if (data.ok) {
15926
+ recordActivity("reply");
15927
+ slackBotUserIdClient?.reportAuthHealth(true);
15928
+ } else if (data.error && SLACK_AUTH_FAILURE_CODES.has(data.error)) {
15929
+ slackBotUserIdClient?.reportAuthHealth(false);
15930
+ }
15889
15931
  return data;
15890
15932
  } catch (err) {
15891
15933
  const isTimeout = err.name === "TimeoutError" || err.name === "AbortError";
@@ -16248,29 +16290,38 @@ if (AGENT_CODE_NAME) {
16248
16290
  } catch {
16249
16291
  }
16250
16292
  }
16293
+ var SLACK_AUTH_FAILURE_CODES = /* @__PURE__ */ new Set([
16294
+ "invalid_auth",
16295
+ "token_revoked",
16296
+ "token_expired",
16297
+ "account_inactive",
16298
+ "not_authed"
16299
+ ]);
16251
16300
  async function getBotUserId() {
16252
16301
  try {
16253
16302
  const res = await fetch("https://slack.com/api/auth.test", {
16254
16303
  headers: { Authorization: `Bearer ${BOT_TOKEN}` }
16255
16304
  });
16256
16305
  const data = await res.json();
16257
- return data.ok ? data.user_id ?? null : null;
16306
+ if (data.ok) return { id: data.user_id ?? null, authFailed: false };
16307
+ return { id: null, authFailed: !!data.error && SLACK_AUTH_FAILURE_CODES.has(data.error) };
16258
16308
  } catch {
16259
- return null;
16309
+ return { id: null, authFailed: false };
16260
16310
  }
16261
16311
  }
16262
16312
  async function resolveBotUserIdOrThrow() {
16313
+ let sawAuthFailure = false;
16263
16314
  for (let attempt = 1; attempt <= 5; attempt++) {
16264
- const id = await getBotUserId();
16315
+ const { id, authFailed } = await getBotUserId();
16265
16316
  if (id) return id;
16317
+ if (authFailed) sawAuthFailure = true;
16266
16318
  await new Promise((r) => setTimeout(r, attempt * 1e3));
16267
16319
  }
16268
- throw new Error("slack-channel: failed to resolve bot user_id via auth.test after 5 attempts");
16320
+ const err = new Error("slack-channel: failed to resolve bot user_id via auth.test after 5 attempts");
16321
+ err.authFailed = sawAuthFailure;
16322
+ throw err;
16269
16323
  }
16270
- var botUserId = await resolveBotUserIdOrThrow();
16271
- var botUserIdForLog = `${botUserId.slice(0, 2)}***${botUserId.slice(-2)}`;
16272
- process.stderr.write(`slack-channel: Bot user ID resolved (${botUserIdForLog})
16273
- `);
16324
+ var botUserId = null;
16274
16325
  var slackBotUserIdClient = createSlackBotUserIdClient({
16275
16326
  agtHost: AGT_HOST,
16276
16327
  agtApiKey: AGT_API_KEY,
@@ -16278,8 +16329,21 @@ var slackBotUserIdClient = createSlackBotUserIdClient({
16278
16329
  log: (line) => process.stderr.write(`slack-channel: ${line}
16279
16330
  `)
16280
16331
  });
16281
- slackBotUserIdClient?.report(botUserId);
16282
- var selfIdentityInstruction = `Your own Slack user_id is ${botUserId}. Treat <@${botUserId}> mentions as directed at you, even inside auto_followed threads.`;
16332
+ void resolveBotUserIdOrThrow().then((id) => {
16333
+ botUserId = id;
16334
+ process.stderr.write(`slack-channel: Bot user ID resolved (${id.slice(0, 2)}***${id.slice(-2)})
16335
+ `);
16336
+ slackBotUserIdClient?.report(id);
16337
+ slackBotUserIdClient?.reportAuthHealth(true);
16338
+ }).catch((err) => {
16339
+ const authFailed = !!err.authFailed;
16340
+ process.stderr.write(
16341
+ `slack-channel: bot user_id resolve failed \u2014 continuing degraded${authFailed ? " (invalid_auth \u2014 channel needs reconnect)" : " (transient)"}: ${err.message}
16342
+ `
16343
+ );
16344
+ if (authFailed) slackBotUserIdClient?.reportAuthHealth(false);
16345
+ });
16346
+ var selfIdentityInstruction = `Mentions of your own Slack bot user are directed at you, even inside auto_followed threads.`;
16283
16347
  var mcp = new Server(
16284
16348
  { name: "slack", version: "0.1.0" },
16285
16349
  {
@@ -22,8 +22,8 @@ import {
22
22
  stopPersistentSession,
23
23
  takeZombieDetection,
24
24
  writePersistentClaudeWrapper
25
- } from "./chunk-PNTLQKLO.js";
26
- import "./chunk-ECDTRQLA.js";
25
+ } from "./chunk-3A2PMQM4.js";
26
+ import "./chunk-53TCAGCM.js";
27
27
  export {
28
28
  _internals,
29
29
  collectDiagnostics,
@@ -49,4 +49,4 @@ export {
49
49
  takeZombieDetection,
50
50
  writePersistentClaudeWrapper
51
51
  };
52
- //# sourceMappingURL=persistent-session-JUJY46HW.js.map
52
+ //# sourceMappingURL=persistent-session-XJYOPFIP.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  paneLogPath
3
- } from "./chunk-PNTLQKLO.js";
4
- import "./chunk-ECDTRQLA.js";
3
+ } from "./chunk-3A2PMQM4.js";
4
+ import "./chunk-53TCAGCM.js";
5
5
 
6
6
  // src/lib/responsiveness-probe.ts
7
7
  import { statSync } from "fs";
@@ -29,4 +29,4 @@ export {
29
29
  collectResponsivenessProbes,
30
30
  getResponsivenessIntervalMs
31
31
  };
32
- //# sourceMappingURL=responsiveness-probe-XOEC7J5D.js.map
32
+ //# sourceMappingURL=responsiveness-probe-EWZNGMTX.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.24.6",
3
+ "version": "0.24.8",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {