@integrity-labs/agt-cli 0.28.643 → 0.28.645

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.
@@ -29641,6 +29641,75 @@ function emitToolCallMarkupRedactionTelemetry(channel) {
29641
29641
  }
29642
29642
  }
29643
29643
 
29644
+ // src/http-failure-summary.ts
29645
+ var MAX_EXCERPT = 300;
29646
+ var MAX_BODY_BYTES = 16 * 1024;
29647
+ var CONTROL_CHARS = /[\x00-\x1F\x7F-\x9F]/g;
29648
+ function utf8Bytes(s) {
29649
+ return Buffer.byteLength(s, "utf8");
29650
+ }
29651
+ function summariseFailureBody(raw, size) {
29652
+ const totalBytes = size?.totalBytes ?? utf8Bytes(raw);
29653
+ const atLeast = size?.atLeast ?? false;
29654
+ const flattened = raw.replace(/\s+/g, " ").replace(CONTROL_CHARS, "").trim();
29655
+ if (flattened.length === 0) {
29656
+ return "<empty body>";
29657
+ }
29658
+ const excerpt = flattened.length > MAX_EXCERPT ? `${flattened.slice(0, MAX_EXCERPT)}\u2026 (${atLeast ? "\u2265" : ""}${totalBytes} bytes total)` : flattened;
29659
+ if (isHtml(flattened)) {
29660
+ return `non-JSON HTML body (NOT from our API \u2014 every API error is JSON): ${excerpt}`;
29661
+ }
29662
+ return excerpt;
29663
+ }
29664
+ function isHtml(flattened) {
29665
+ const head = flattened.slice(0, 200).toLowerCase();
29666
+ return head.startsWith("<!doctype html") || head.startsWith("<html") || head.startsWith("<?xml");
29667
+ }
29668
+ async function readBoundedBody(res) {
29669
+ const body = res.body;
29670
+ if (!body || typeof body.getReader !== "function") {
29671
+ if (typeof res.text !== "function") {
29672
+ return { text: "", size: { totalBytes: 0, atLeast: false } };
29673
+ }
29674
+ const whole = await res.text();
29675
+ return { text: whole, size: { totalBytes: utf8Bytes(whole), atLeast: false } };
29676
+ }
29677
+ const reader = body.getReader();
29678
+ const decoder = new TextDecoder();
29679
+ const parts = [];
29680
+ let bytes = 0;
29681
+ let capped = false;
29682
+ try {
29683
+ for (; ; ) {
29684
+ const { done, value } = await reader.read();
29685
+ if (done) break;
29686
+ bytes += value.byteLength;
29687
+ if (bytes > MAX_BODY_BYTES) {
29688
+ const keep = value.byteLength - (bytes - MAX_BODY_BYTES);
29689
+ if (keep > 0) parts.push(decoder.decode(value.subarray(0, keep), { stream: true }));
29690
+ capped = true;
29691
+ break;
29692
+ }
29693
+ parts.push(decoder.decode(value, { stream: true }));
29694
+ }
29695
+ } finally {
29696
+ if (capped) {
29697
+ await reader.cancel().catch(() => {
29698
+ });
29699
+ }
29700
+ }
29701
+ parts.push(decoder.decode());
29702
+ return { text: parts.join(""), size: { totalBytes: bytes, atLeast: capped } };
29703
+ }
29704
+ async function describeFailedResponse(res) {
29705
+ try {
29706
+ const { text, size } = await readBoundedBody(res);
29707
+ return summariseFailureBody(text, size);
29708
+ } catch (err) {
29709
+ return `<body unreadable: ${err instanceof Error ? err.message : String(err)}>`;
29710
+ }
29711
+ }
29712
+
29644
29713
  // src/transient-api-error.ts
29645
29714
  var CODE_KIND = {
29646
29715
  "429": "rate_limit",
@@ -37686,8 +37755,7 @@ async function getAuthToken() {
37686
37755
  body: JSON.stringify({ host_key: AGT_API_KEY, agent_id: AGT_AGENT_ID })
37687
37756
  }, HTTP_TIMEOUT_MS);
37688
37757
  if (!res.ok) {
37689
- const body = await res.text().catch(() => "");
37690
- throw new Error(`Auth exchange failed (${res.status}): ${body.slice(0, 200)}`);
37758
+ throw new Error(`Auth exchange failed (${res.status}): ${await describeFailedResponse(res)}`);
37691
37759
  }
37692
37760
  const data = await res.json();
37693
37761
  authToken = data.token;
@@ -38317,7 +38385,7 @@ async function pollForMessages(sinceMs) {
38317
38385
  });
38318
38386
  if (!res.ok) {
38319
38387
  process.stderr.write(
38320
- `direct-chat-channel: poll returned HTTP ${res.status} \u2014 pull skipped this tick
38388
+ `direct-chat-channel: poll returned HTTP ${res.status} \u2014 pull skipped this tick \u2014 ${await describeFailedResponse(res)}
38321
38389
  `
38322
38390
  );
38323
38391
  return;
@@ -43,8 +43,8 @@ import {
43
43
  writeDirectChatSessionState,
44
44
  writeEgressAllowlist,
45
45
  writePersistentClaudeWrapper
46
- } from "./chunk-HYLJPTKL.js";
47
- import "./chunk-REWZFCUX.js";
46
+ } from "./chunk-Z2SA7JLD.js";
47
+ import "./chunk-2MDR3ZHP.js";
48
48
  import "./chunk-XWVM4KPK.js";
49
49
  export {
50
50
  EGRESS_BASELINE_DOMAINS,
@@ -92,4 +92,4 @@ export {
92
92
  writeEgressAllowlist,
93
93
  writePersistentClaudeWrapper
94
94
  };
95
- //# sourceMappingURL=persistent-session-JJ7L23KO.js.map
95
+ //# sourceMappingURL=persistent-session-ZXOO6LYN.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  paneLogPath
3
- } from "./chunk-HYLJPTKL.js";
4
- import "./chunk-REWZFCUX.js";
3
+ } from "./chunk-Z2SA7JLD.js";
4
+ import "./chunk-2MDR3ZHP.js";
5
5
  import "./chunk-XWVM4KPK.js";
6
6
 
7
7
  // src/lib/responsiveness-probe.ts
@@ -712,4 +712,4 @@ export {
712
712
  readAndResetSlackReplyBindingClassifications,
713
713
  readAndResetSlackReplyTargetClassifications
714
714
  };
715
- //# sourceMappingURL=responsiveness-probe-JAME5YLS.js.map
715
+ //# sourceMappingURL=responsiveness-probe-RQCDK5LF.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sessionTranscriptDir
3
- } from "./chunk-REWZFCUX.js";
3
+ } from "./chunk-2MDR3ZHP.js";
4
4
 
5
5
  // src/lib/session-auth-dead.ts
6
6
  import { closeSync, openSync, readSync, readdirSync, statSync } from "fs";
@@ -203,4 +203,4 @@ export {
203
203
  decideSessionAuthState,
204
204
  probeSessionAuth
205
205
  };
206
- //# sourceMappingURL=session-auth-dead-WX47XEZJ.js.map
206
+ //# sourceMappingURL=session-auth-dead-DPY5S3RZ.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.643",
3
+ "version": "0.28.645",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {