@integrity-labs/agt-cli 0.28.27 → 0.28.29

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.
@@ -14032,6 +14032,38 @@ function readDirectChatSessionState(agentDir, nowMs) {
14032
14032
  }
14033
14033
  }
14034
14034
 
14035
+ // src/direct-chat-channel-meta.ts
14036
+ function buildDirectChatChannelMeta(input) {
14037
+ return {
14038
+ session_id: input.sessionId,
14039
+ user: "webapp",
14040
+ source: "direct-chat",
14041
+ // String flag the agent's channel instructions (and the renderer) read:
14042
+ // 'false' = notice (do not reply), 'true' = normal message (reply expected).
14043
+ requires_reply: input.isNotice ? "false" : "true"
14044
+ };
14045
+ }
14046
+
14047
+ // src/direct-chat-poll-guard.ts
14048
+ function evaluatePollGuard(state, nowMs, stuckMs) {
14049
+ if (!state.inFlight) return { run: true, stuck: false };
14050
+ if (state.inFlightSinceMs != null && nowMs - state.inFlightSinceMs >= stuckMs) {
14051
+ return { run: true, stuck: true };
14052
+ }
14053
+ return { run: false, stuck: false };
14054
+ }
14055
+ async function fetchWithTimeout(input, init, timeoutMs, fetchImpl = fetch) {
14056
+ const controller = new AbortController();
14057
+ const timer = setTimeout(() => {
14058
+ controller.abort(new Error(`request timed out after ${timeoutMs}ms`));
14059
+ }, timeoutMs);
14060
+ try {
14061
+ return await fetchImpl(input, { ...init, signal: controller.signal });
14062
+ } finally {
14063
+ clearTimeout(timer);
14064
+ }
14065
+ }
14066
+
14035
14067
  // src/mcp-spawn-lock.ts
14036
14068
  import {
14037
14069
  existsSync as existsSync2,
@@ -14163,13 +14195,14 @@ if (!AGT_HOST || !AGT_API_KEY || !AGT_AGENT_ID) {
14163
14195
  }
14164
14196
  var authToken = null;
14165
14197
  var authExpiry = 0;
14198
+ var HTTP_TIMEOUT_MS = 2e4;
14166
14199
  async function getAuthToken() {
14167
14200
  if (authToken && Date.now() < authExpiry) return authToken;
14168
- const res = await fetch(`${AGT_HOST}/host/exchange`, {
14201
+ const res = await fetchWithTimeout(`${AGT_HOST}/host/exchange`, {
14169
14202
  method: "POST",
14170
14203
  headers: { "Content-Type": "application/json" },
14171
14204
  body: JSON.stringify({ host_key: AGT_API_KEY })
14172
- });
14205
+ }, HTTP_TIMEOUT_MS);
14173
14206
  if (!res.ok) {
14174
14207
  const body = await res.text().catch(() => "");
14175
14208
  throw new Error(`Auth exchange failed (${res.status}): ${body.slice(0, 200)}`);
@@ -14181,26 +14214,26 @@ async function getAuthToken() {
14181
14214
  }
14182
14215
  async function apiPost(path, body) {
14183
14216
  const token = await getAuthToken();
14184
- const res = await fetch(`${AGT_HOST}${path}`, {
14217
+ const res = await fetchWithTimeout(`${AGT_HOST}${path}`, {
14185
14218
  method: "POST",
14186
14219
  headers: {
14187
14220
  "Content-Type": "application/json",
14188
14221
  Authorization: `Bearer ${token}`
14189
14222
  },
14190
14223
  body: JSON.stringify(body)
14191
- });
14224
+ }, HTTP_TIMEOUT_MS);
14192
14225
  if (res.status === 401) {
14193
14226
  authToken = null;
14194
14227
  authExpiry = 0;
14195
14228
  const freshToken = await getAuthToken();
14196
- return fetch(`${AGT_HOST}${path}`, {
14229
+ return fetchWithTimeout(`${AGT_HOST}${path}`, {
14197
14230
  method: "POST",
14198
14231
  headers: {
14199
14232
  "Content-Type": "application/json",
14200
14233
  Authorization: `Bearer ${freshToken}`
14201
14234
  },
14202
14235
  body: JSON.stringify(body)
14203
- });
14236
+ }, HTTP_TIMEOUT_MS);
14204
14237
  }
14205
14238
  return res;
14206
14239
  }
@@ -14383,7 +14416,13 @@ async function pollForMessages(sinceMs) {
14383
14416
  agent_id: AGT_AGENT_ID,
14384
14417
  ...typeof sinceMs === "number" ? { since_ms: sinceMs } : {}
14385
14418
  });
14386
- if (!res.ok) return;
14419
+ if (!res.ok) {
14420
+ process.stderr.write(
14421
+ `direct-chat-channel: poll returned HTTP ${res.status} \u2014 pull skipped this tick
14422
+ `
14423
+ );
14424
+ return;
14425
+ }
14387
14426
  const data = await res.json();
14388
14427
  const markProcessed = (id) => {
14389
14428
  processedIds.add(id);
@@ -14403,12 +14442,7 @@ async function pollForMessages(sinceMs) {
14403
14442
  method: "notifications/claude/channel",
14404
14443
  params: {
14405
14444
  content: msg.content,
14406
- meta: {
14407
- session_id: msg.session_id,
14408
- user: "webapp",
14409
- source: "direct-chat",
14410
- requires_reply: !isNotice
14411
- }
14445
+ meta: buildDirectChatChannelMeta({ sessionId: msg.session_id, isNotice })
14412
14446
  }
14413
14447
  });
14414
14448
  if (isNotice) {
@@ -14467,14 +14501,24 @@ var DOORBELL_ENABLED = resolveHostBooleanFlag({
14467
14501
  });
14468
14502
  var DOORBELL_FILE = "direct-chat-doorbell";
14469
14503
  var SAFETY_NET_POLL_MS = 3e4;
14470
- var pollInFlight = false;
14504
+ var POLL_STUCK_MS = 9e4;
14505
+ var pollGuard = { inFlight: false, inFlightSinceMs: null };
14471
14506
  async function pollOnce(sinceMs) {
14472
- if (pollInFlight) return;
14473
- pollInFlight = true;
14507
+ const decision = evaluatePollGuard(pollGuard, Date.now(), POLL_STUCK_MS);
14508
+ if (!decision.run) return;
14509
+ if (decision.stuck) {
14510
+ process.stderr.write(
14511
+ `direct-chat-channel: previous poll wedged >${POLL_STUCK_MS}ms \u2014 superseding so the pull loop self-heals
14512
+ `
14513
+ );
14514
+ }
14515
+ pollGuard.inFlight = true;
14516
+ pollGuard.inFlightSinceMs = Date.now();
14474
14517
  try {
14475
14518
  await pollForMessages(sinceMs);
14476
14519
  } finally {
14477
- pollInFlight = false;
14520
+ pollGuard.inFlight = false;
14521
+ pollGuard.inFlightSinceMs = null;
14478
14522
  }
14479
14523
  }
14480
14524
  var doorbellWatcher = null;
@@ -25,8 +25,8 @@ import {
25
25
  takeZombieDetection,
26
26
  writeDirectChatSessionState,
27
27
  writePersistentClaudeWrapper
28
- } from "./chunk-IHPN6AX7.js";
29
- import "./chunk-SN2G4B2Z.js";
28
+ } from "./chunk-SR6RHUAV.js";
29
+ import "./chunk-VIIPFWE4.js";
30
30
  import "./chunk-XWVM4KPK.js";
31
31
  export {
32
32
  SEND_KEYS_ENTER_DELAY_MS,
@@ -56,4 +56,4 @@ export {
56
56
  writeDirectChatSessionState,
57
57
  writePersistentClaudeWrapper
58
58
  };
59
- //# sourceMappingURL=persistent-session-34CY65FC.js.map
59
+ //# sourceMappingURL=persistent-session-JHBXSNVW.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  paneLogPath
3
- } from "./chunk-IHPN6AX7.js";
4
- import "./chunk-SN2G4B2Z.js";
3
+ } from "./chunk-SR6RHUAV.js";
4
+ import "./chunk-VIIPFWE4.js";
5
5
  import "./chunk-XWVM4KPK.js";
6
6
 
7
7
  // src/lib/responsiveness-probe.ts
@@ -250,4 +250,4 @@ export {
250
250
  parkPendingInbound,
251
251
  readAndResetChannelDeflections
252
252
  };
253
- //# sourceMappingURL=responsiveness-probe-KKWPOZSX.js.map
253
+ //# sourceMappingURL=responsiveness-probe-SKVWT5CO.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.27",
3
+ "version": "0.28.29",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {