omp-conductor 0.3.3 → 0.3.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/escalate.ts +14 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-conductor",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "A 24/7 dispatcher that takes ready GitHub issues to green, mergeable PRs using omp coding sessions, with tiered escalation first to an orchestrator session and then to a human.",
package/src/escalate.ts CHANGED
@@ -233,22 +233,32 @@ async function sendTelegram(token: string, chatId: string, text: string): Promis
233
233
  throw new Error(`telegram sendMessage failed: ${redact(reason, token)}`);
234
234
  }
235
235
 
236
- const payload = redact(await res.text().catch(() => ""), token).slice(0, 400);
236
+ // The raw body is what gets parsed; `diagnostic` is only ever for humans.
237
+ // These were one variable once, and the bug that produced was expensive: the
238
+ // 400-char cap meant for a log line was applied first, so `JSON.parse` was
239
+ // handed a truncated object and threw. Telegram echoes the whole message back
240
+ // inside `result.text`, so every page long enough to matter overflowed and was
241
+ // reported as rejected *after being delivered* — with the dedup marker only
242
+ // written on success, that also re-sent the same page every tick. Redaction
243
+ // stays out of the parse for the same reason: it rewrites the very bytes the
244
+ // decision is read from.
245
+ const raw = await res.text().catch(() => "");
246
+ const diagnostic = redact(raw, token).slice(0, 400);
237
247
  if (!res.ok) {
238
- throw new Error(`telegram sendMessage failed: HTTP ${res.status} ${payload}`);
248
+ throw new Error(`telegram sendMessage failed: HTTP ${res.status} ${diagnostic}`);
239
249
  }
240
250
 
241
251
  // Telegram answers 200 with `{"ok":false}` for plenty of real failures
242
252
  // (kicked from the chat, bad chat_id), so the status alone proves nothing.
243
253
  let ok = false;
244
254
  try {
245
- const parsed: unknown = JSON.parse(payload);
255
+ const parsed: unknown = JSON.parse(raw);
246
256
  ok = typeof parsed === "object" && parsed !== null && "ok" in parsed && parsed.ok === true;
247
257
  } catch {
248
258
  ok = false;
249
259
  }
250
260
  if (!ok) {
251
- throw new Error(`telegram sendMessage rejected: ${payload}`);
261
+ throw new Error(`telegram sendMessage rejected: ${diagnostic}`);
252
262
  }
253
263
  }
254
264