@integrity-labs/agt-cli 0.27.84 → 0.27.86

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.
@@ -14202,6 +14202,75 @@ function startMsteamsInboundPuller(args) {
14202
14202
  };
14203
14203
  }
14204
14204
 
14205
+ // src/inbound-context-client.ts
14206
+ var REQUEST_TIMEOUT_MS2 = 1e4;
14207
+ function createInboundContextClient(args) {
14208
+ if (!args.agtHost || !args.agtApiKey || !args.agentId) return null;
14209
+ const fetchImpl = args.fetchImpl ?? fetch;
14210
+ const log = args.log ?? (() => {
14211
+ });
14212
+ const base = args.agtHost.replace(/\/+$/, "");
14213
+ const agentId = args.agentId;
14214
+ const apiKey = args.agtApiKey;
14215
+ let cachedToken = null;
14216
+ let cachedTokenExpiresAt = 0;
14217
+ async function getToken() {
14218
+ if (cachedToken && Date.now() < cachedTokenExpiresAt) return cachedToken;
14219
+ const resp = await fetchImpl(`${base}/host/exchange`, {
14220
+ method: "POST",
14221
+ headers: { "Content-Type": "application/json" },
14222
+ body: JSON.stringify({ host_key: apiKey }),
14223
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS2)
14224
+ });
14225
+ if (!resp.ok) {
14226
+ const body = await resp.text().catch(() => "");
14227
+ throw new Error(`/host/exchange failed (${resp.status}): ${body.slice(0, 200)}`);
14228
+ }
14229
+ const data = await resp.json();
14230
+ cachedToken = data.token;
14231
+ cachedTokenExpiresAt = data.expires_at ? new Date(data.expires_at).getTime() - 12e4 : Date.now() + 55 * 6e4;
14232
+ return cachedToken;
14233
+ }
14234
+ async function postOnce(body) {
14235
+ const token = await getToken();
14236
+ return fetchImpl(`${base}/host/inbound-context`, {
14237
+ method: "POST",
14238
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
14239
+ body: JSON.stringify(body),
14240
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS2)
14241
+ });
14242
+ }
14243
+ async function emit(args2) {
14244
+ const body = {
14245
+ agent_id: agentId,
14246
+ source_integration: args2.sourceIntegration,
14247
+ source_external_id: args2.sourceExternalId,
14248
+ ...args2.sourceUrl ? { source_url: args2.sourceUrl } : {}
14249
+ };
14250
+ try {
14251
+ let resp = await postOnce(body);
14252
+ if (resp.status === 401) {
14253
+ cachedToken = null;
14254
+ cachedTokenExpiresAt = 0;
14255
+ resp = await postOnce(body);
14256
+ }
14257
+ if (!resp.ok) {
14258
+ const text = await resp.text().catch(() => "");
14259
+ log(
14260
+ `inbound-context: POST failed (${resp.status}) integration=${args2.sourceIntegration}: ${text.slice(0, 200)}`
14261
+ );
14262
+ }
14263
+ } catch (err) {
14264
+ log(`inbound-context: emit threw integration=${args2.sourceIntegration}: ${err.message}`);
14265
+ }
14266
+ }
14267
+ return {
14268
+ recordInbound(args2) {
14269
+ void emit(args2);
14270
+ }
14271
+ };
14272
+ }
14273
+
14205
14274
  // src/teams-channel-info.ts
14206
14275
  function buildChannelInfoResult(input) {
14207
14276
  if (input.members === null) {
@@ -14558,6 +14627,13 @@ var KNOWN_PEER_BOT_IDS = parsePeerBotIdsEnv(process.env.MSTEAMS_KNOWN_PEER_BOT_I
14558
14627
  var PEER_TEAM_IDS = parsePeerTeamIdsEnv(process.env.MSTEAMS_PEER_TEAM_IDS);
14559
14628
  var AGT_TEAM_ID = process.env.AGT_TEAM_ID ?? null;
14560
14629
  var AGT_AGENT_ID = process.env.AGT_AGENT_ID ?? null;
14630
+ var inboundContextClient = createInboundContextClient({
14631
+ agtHost: process.env["AGT_HOST"]?.trim() || "https://api.augmented.team",
14632
+ agtApiKey: process.env.AGT_API_KEY ?? null,
14633
+ agentId: AGT_AGENT_ID,
14634
+ log: (line) => process.stderr.write(`teams-channel: ${line}
14635
+ `)
14636
+ });
14561
14637
  var MSTEAMS_SENDER_POLICY = (() => {
14562
14638
  const raw = (process.env.MSTEAMS_SENDER_POLICY ?? "all").trim().toLowerCase();
14563
14639
  const internalOnly = process.env.MSTEAMS_INTERNAL_ONLY === "true";
@@ -14886,6 +14962,16 @@ async function processPendingFile(filename) {
14886
14962
  resetThread(activity.conversation.id, throttleKey);
14887
14963
  }
14888
14964
  const isPeerListen = peerDecision.classification === "peer_agent" && peerDecision.action === "forward_listen";
14965
+ if (peerDecision.classification === "human" && activity.conversation?.id && activity.serviceUrl) {
14966
+ const rootActivityId = activity.replyToId ?? activity.id;
14967
+ if (rootActivityId) {
14968
+ inboundContextClient?.recordInbound({
14969
+ sourceIntegration: "msteams",
14970
+ sourceExternalId: `${activity.conversation.id}#${rootActivityId}`,
14971
+ sourceUrl: activity.serviceUrl
14972
+ });
14973
+ }
14974
+ }
14889
14975
  writePendingMarker(activity);
14890
14976
  await emitChannelNotification(activity, { isPeerListen });
14891
14977
  }
@@ -21,8 +21,8 @@ import {
21
21
  stopPersistentSession,
22
22
  takeZombieDetection,
23
23
  writePersistentClaudeWrapper
24
- } from "./chunk-S2QLE5BQ.js";
25
- import "./chunk-TXE2LLKI.js";
24
+ } from "./chunk-4LHN3FAL.js";
25
+ import "./chunk-5IWPCN3V.js";
26
26
  import "./chunk-XWVM4KPK.js";
27
27
  export {
28
28
  SEND_KEYS_ENTER_DELAY_MS,
@@ -48,4 +48,4 @@ export {
48
48
  takeZombieDetection,
49
49
  writePersistentClaudeWrapper
50
50
  };
51
- //# sourceMappingURL=persistent-session-BTXWOKJ6.js.map
51
+ //# sourceMappingURL=persistent-session-YNVCVUK3.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  paneLogPath
3
- } from "./chunk-S2QLE5BQ.js";
4
- import "./chunk-TXE2LLKI.js";
3
+ } from "./chunk-4LHN3FAL.js";
4
+ import "./chunk-5IWPCN3V.js";
5
5
  import "./chunk-XWVM4KPK.js";
6
6
 
7
7
  // src/lib/responsiveness-probe.ts
@@ -70,4 +70,4 @@ export {
70
70
  collectResponsivenessProbes,
71
71
  getResponsivenessIntervalMs
72
72
  };
73
- //# sourceMappingURL=responsiveness-probe-Y6TCM6T4.js.map
73
+ //# sourceMappingURL=responsiveness-probe-5ICEBNCM.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.27.84",
3
+ "version": "0.27.86",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {