@integrity-labs/agt-cli 0.14.8 → 0.14.12

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.
@@ -13769,6 +13769,31 @@ var Server = class extends Protocol {
13769
13769
  }
13770
13770
  };
13771
13771
 
13772
+ // src/slack-inbound-filter.ts
13773
+ var ALLOWED_MESSAGE_SUBTYPES = /* @__PURE__ */ new Set([
13774
+ void 0,
13775
+ "file_share",
13776
+ "thread_broadcast"
13777
+ ]);
13778
+ function decideSlackMessageForward(evt) {
13779
+ if (evt.type !== "message") {
13780
+ return { forward: true };
13781
+ }
13782
+ if (!ALLOWED_MESSAGE_SUBTYPES.has(evt.subtype)) {
13783
+ return { forward: false, reason: "subtype" };
13784
+ }
13785
+ if (!evt.user) {
13786
+ return { forward: false, reason: "no_user" };
13787
+ }
13788
+ const hasText = typeof evt.text === "string" && evt.text.trim().length > 0;
13789
+ const hasFiles = Array.isArray(evt.files) && evt.files.length > 0;
13790
+ const hasBlocks = Array.isArray(evt.blocks) && evt.blocks.length > 0;
13791
+ if (!hasText && !hasFiles && !hasBlocks) {
13792
+ return { forward: false, reason: "empty" };
13793
+ }
13794
+ return { forward: true };
13795
+ }
13796
+
13772
13797
  // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
13773
13798
  import process2 from "process";
13774
13799
 
@@ -13866,6 +13891,23 @@ import { readFileSync, statSync } from "fs";
13866
13891
  import { basename, resolve } from "path";
13867
13892
  import { homedir } from "os";
13868
13893
 
13894
+ // src/safe-async.ts
13895
+ async function runOrRetry(fn, opts) {
13896
+ try {
13897
+ await fn();
13898
+ } catch (err) {
13899
+ opts.onError(err);
13900
+ if (!opts.shouldRetry()) return;
13901
+ const schedule = opts.scheduleRetry ?? ((f, ms) => {
13902
+ const t = setTimeout(f, ms);
13903
+ t.unref?.();
13904
+ });
13905
+ schedule(() => {
13906
+ void runOrRetry(fn, opts);
13907
+ }, opts.retryDelayMs);
13908
+ }
13909
+ }
13910
+
13869
13911
  // src/slack-response-mode.ts
13870
13912
  var MODES = [
13871
13913
  "mention_only",
@@ -14333,6 +14375,16 @@ async function resolveUserName(userId) {
14333
14375
  }
14334
14376
  var currentWs = null;
14335
14377
  var isShuttingDown = false;
14378
+ function connectSocketModeSafely() {
14379
+ void runOrRetry(connectSocketMode, {
14380
+ retryDelayMs: 1e4,
14381
+ onError: (err) => process.stderr.write(
14382
+ `slack-channel: Socket Mode connect failed: ${err.message} \u2014 retrying in 10s
14383
+ `
14384
+ ),
14385
+ shouldRetry: () => !isShuttingDown
14386
+ });
14387
+ }
14336
14388
  async function connectSocketMode() {
14337
14389
  if (isShuttingDown) return;
14338
14390
  const res = await fetch("https://slack.com/api/apps.connections.open", {
@@ -14344,7 +14396,7 @@ async function connectSocketMode() {
14344
14396
  if (!data.ok || !data.url) {
14345
14397
  process.stderr.write(`slack-channel: Socket Mode connection failed: ${data.error}
14346
14398
  `);
14347
- if (!isShuttingDown) setTimeout(connectSocketMode, 1e4);
14399
+ if (!isShuttingDown) setTimeout(connectSocketModeSafely, 1e4).unref?.();
14348
14400
  return;
14349
14401
  }
14350
14402
  const ws = new WebSocket(data.url);
@@ -14369,6 +14421,12 @@ async function connectSocketMode() {
14369
14421
  const evt = msg.payload.event;
14370
14422
  if (evt.user === botUserId) return;
14371
14423
  if (evt.type !== "app_mention" && evt.type !== "message") return;
14424
+ const filterDecision = decideSlackMessageForward(evt);
14425
+ if (!filterDecision.forward) {
14426
+ process.stderr.write(`slack-channel: dropped message event (reason=${filterDecision.reason}, subtype=${evt.subtype ?? "none"}, ts=${evt.ts ?? "n/a"})
14427
+ `);
14428
+ return;
14429
+ }
14372
14430
  const isDirectMessage = evt.channel?.startsWith("D");
14373
14431
  const isThreadReply = !!evt.thread_ts && evt.thread_ts !== evt.ts;
14374
14432
  const threadKey = evt.thread_ts ?? evt.ts ?? "";
@@ -14430,7 +14488,7 @@ async function connectSocketMode() {
14430
14488
  if (currentWs === ws) currentWs = null;
14431
14489
  if (isShuttingDown) return;
14432
14490
  process.stderr.write("slack-channel: Socket Mode disconnected, reconnecting...\n");
14433
- setTimeout(connectSocketMode, 5e3);
14491
+ setTimeout(connectSocketModeSafely, 5e3).unref?.();
14434
14492
  };
14435
14493
  ws.onerror = (err) => {
14436
14494
  process.stderr.write(`slack-channel: WebSocket error: ${err}
@@ -14453,7 +14511,12 @@ process.stdin.on("end", () => shutdown("stdin ended"));
14453
14511
  process.on("SIGTERM", () => shutdown("SIGTERM"));
14454
14512
  process.on("SIGINT", () => shutdown("SIGINT"));
14455
14513
  process.on("SIGHUP", () => shutdown("SIGHUP"));
14514
+ process.on("unhandledRejection", (reason) => {
14515
+ const msg = reason instanceof Error ? reason.message : String(reason);
14516
+ process.stderr.write(`slack-channel: unhandledRejection (continuing): ${msg}
14517
+ `);
14518
+ });
14456
14519
  botUserId = await getBotUserId();
14457
14520
  process.stderr.write(`slack-channel: Bot user ID: ${botUserId}
14458
14521
  `);
14459
- connectSocketMode();
14522
+ connectSocketModeSafely();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.14.8",
3
+ "version": "0.14.12",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {