@integrity-labs/agt-cli 0.28.618 → 0.28.620

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.
@@ -333,16 +333,35 @@ function mergeToolsListInto(ct, text) {
333
333
  }
334
334
  }
335
335
  }
336
+ function toolsListNames(ct, text) {
337
+ const names = [];
338
+ for (const m of extractJsonRpcMessages(ct, text)) {
339
+ for (const t of extractToolsArray(m)) {
340
+ const n = toolName(t);
341
+ if (n) names.push(n);
342
+ }
343
+ }
344
+ return names;
345
+ }
346
+ function claimGroupTools(listNames, group, seen, groupByName) {
347
+ for (const nm of listNames) {
348
+ if (seen.has(nm)) continue;
349
+ seen.add(nm);
350
+ if (!groupByName.has(nm)) groupByName.set(nm, group);
351
+ }
352
+ }
336
353
  function ensureUnionManifest(token) {
337
354
  if (unionOnce) return unionOnce;
338
355
  const build = (async () => {
339
356
  let reached = false;
340
357
  let clean = true;
358
+ const seenNames = /* @__PURE__ */ new Set();
341
359
  try {
342
360
  const seed = await postRpc(token, buildToolsListRequest());
343
361
  if (seed.ok) {
344
362
  reached = true;
345
363
  mergeToolsListInto(seed.ct, seed.text);
364
+ for (const nm of toolsListNames(seed.ct, seed.text)) seenNames.add(nm);
346
365
  } else {
347
366
  clean = false;
348
367
  logErr(`union: seed tools/list HTTP ${seed.status}`);
@@ -367,6 +386,7 @@ function ensureUnionManifest(token) {
367
386
  const li = await postRpc(token, buildToolsListRequest());
368
387
  if (li.ok) {
369
388
  mergeToolsListInto(li.ct, li.text);
389
+ claimGroupTools(toolsListNames(li.ct, li.text), group, seenNames, toolGroupByName);
370
390
  } else {
371
391
  clean = false;
372
392
  logErr(`union: post-enable tools/list "${group}" HTTP ${li.status}`);
@@ -540,6 +560,7 @@ export {
540
560
  buildForwardHeaders,
541
561
  buildToolsListRequest,
542
562
  callRefusal,
563
+ claimGroupTools,
543
564
  extractJsonRpcMessages,
544
565
  extractToolsArray,
545
566
  filterToolsListMessage,
@@ -30250,14 +30250,23 @@ var ALLOWED_MESSAGE_SUBTYPES = /* @__PURE__ */ new Set([
30250
30250
  "file_share",
30251
30251
  "thread_broadcast"
30252
30252
  ]);
30253
- function decideSlackMessageForward(evt) {
30253
+ function matchesThirdPartyGrant(evt, thirdPartyBots) {
30254
+ const botId = evt.bot_id;
30255
+ if (!botId || !thirdPartyBots?.length)
30256
+ return false;
30257
+ return thirdPartyBots.some((b) => b.bot_id === botId || b.bot_user_id === botId);
30258
+ }
30259
+ function decideSlackMessageForward(evt, thirdPartyBots) {
30254
30260
  if (evt.type !== "message") {
30255
30261
  return { forward: true };
30256
30262
  }
30263
+ const granted = matchesThirdPartyGrant(evt, thirdPartyBots);
30257
30264
  if (!ALLOWED_MESSAGE_SUBTYPES.has(evt.subtype)) {
30258
- return { forward: false, reason: "subtype" };
30265
+ if (!granted || evt.subtype !== "bot_message") {
30266
+ return { forward: false, reason: "subtype" };
30267
+ }
30259
30268
  }
30260
- if (!evt.user) {
30269
+ if (!evt.user && !granted) {
30261
30270
  return { forward: false, reason: "no_user" };
30262
30271
  }
30263
30272
  const hasText = typeof evt.text === "string" && evt.text.trim().length > 0;
@@ -40594,7 +40603,13 @@ function classifyPeerMessage(msg, cfg, self) {
40594
40603
  }
40595
40604
  const peer = cfg.peers.find((p2) => p2.bot_user_id === msg.user);
40596
40605
  if (!peer) {
40597
- const thirdParty = cfg.third_party_bots?.find((b) => b.bot_user_id === msg.user);
40606
+ const thirdParty = cfg.third_party_bots?.find((b) => {
40607
+ if (msg.user && b.bot_user_id === msg.user)
40608
+ return true;
40609
+ if (!msg.bot_id)
40610
+ return false;
40611
+ return b.bot_id === msg.bot_id || b.bot_user_id === msg.bot_id;
40612
+ });
40598
40613
  if (thirdParty) {
40599
40614
  if (cfg.peer_disabled_mode === "cross_team_only") {
40600
40615
  return { kind: "drop", reason: "peer_disabled_cross_team" };
@@ -40734,7 +40749,13 @@ function parseThirdPartyBotsEnv(raw) {
40734
40749
  continue;
40735
40750
  const channels = rec["channel_ids"].filter((c) => typeof c === "string" && c.trim() !== "").map((c) => c.trim());
40736
40751
  const label = typeof rec["label"] === "string" && rec["label"].trim() ? rec["label"].trim() : void 0;
40737
- out.push({ bot_user_id: botUserId2, channel_ids: channels, ...label ? { label } : {} });
40752
+ const botId = typeof rec["bot_id"] === "string" && rec["bot_id"].trim() ? rec["bot_id"].trim() : void 0;
40753
+ out.push({
40754
+ bot_user_id: botUserId2,
40755
+ channel_ids: channels,
40756
+ ...botId ? { bot_id: botId } : {},
40757
+ ...label ? { label } : {}
40758
+ });
40738
40759
  }
40739
40760
  return out;
40740
40761
  }
@@ -46244,7 +46265,10 @@ async function connectSocketMode() {
46244
46265
  return;
46245
46266
  }
46246
46267
  const isBot = Boolean(evt.bot_id);
46247
- const filterDecision = decideSlackMessageForward(evt);
46268
+ const filterDecision = decideSlackMessageForward(
46269
+ evt,
46270
+ SLACK_PEER_CLASSIFIER_CONFIG.third_party_bots
46271
+ );
46248
46272
  const senderPolicyDecision = decideSenderPolicyForward(evt, SLACK_SENDER_POLICY);
46249
46273
  const policyBlockReason = senderPolicyDecision.forward ? void 0 : classifySlackPolicyBlock(evt, SLACK_SENDER_POLICY);
46250
46274
  const peerClassification = isBot ? classifyPeerMessage(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.618",
3
+ "version": "0.28.620",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {