omnius 1.0.663 → 1.0.664

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.
package/dist/index.js CHANGED
@@ -773624,6 +773624,157 @@ function codeBlock(code8, language = "") {
773624
773624
  const inner = escapeHtml2(String(code8 ?? "").replace(/\s+$/, ""));
773625
773625
  return language ? `<pre><code class="language-${escapeHtml2(language)}">${inner}</code></pre>` : `<pre>${inner}</pre>`;
773626
773626
  }
773627
+ function telegramRichText(text3) {
773628
+ return escapeHtml2(text3).replace(/\r?\n/g, "<br>");
773629
+ }
773630
+ function renderTelegramPanelPage(input) {
773631
+ const metadata = (input.metadata ?? []).map((item) => ({
773632
+ label: String(item.label ?? "").trim(),
773633
+ value: String(item.value ?? "").trim()
773634
+ })).filter((item) => item.label && item.value);
773635
+ const sections = input.sections.map((section) => ({
773636
+ title: section.title?.trim() || "",
773637
+ packets: section.packets.map((packet) => ({
773638
+ title: packet.title.trim() || "Details",
773639
+ body: packet.body.trim(),
773640
+ open: packet.open === true
773641
+ })).filter((packet) => packet.body)
773642
+ })).filter((section) => section.packets.length > 0);
773643
+ const emptyText = input.emptyText?.trim() || "No data is available yet.";
773644
+ const fallback = [`<b>${escapeHtml2(input.title)}</b>`];
773645
+ if (input.subtitle?.trim()) {
773646
+ fallback.push(`<i>${escapeHtml2(input.subtitle.trim())}</i>`);
773647
+ }
773648
+ if (metadata.length > 0) {
773649
+ fallback.push(
773650
+ "<b>Details</b>",
773651
+ `<blockquote>${escapeHtml2(metadata.map((item) => `${item.label}: ${item.value}`).join("\n"))}</blockquote>`
773652
+ );
773653
+ }
773654
+ if (sections.length === 0) {
773655
+ fallback.push(`<i>${escapeHtml2(emptyText)}</i>`);
773656
+ } else {
773657
+ for (const section of sections) {
773658
+ if (section.title) fallback.push(`<b>${escapeHtml2(section.title)}</b>`);
773659
+ for (const packet of section.packets) {
773660
+ const expandable = !packet.open && (packet.body.length > 180 || packet.body.split(/\r?\n/).length > 3);
773661
+ fallback.push(
773662
+ `<b>${escapeHtml2(packet.title)}</b>`,
773663
+ `<blockquote${expandable ? " expandable" : ""}>${escapeHtml2(packet.body)}</blockquote>`
773664
+ );
773665
+ }
773666
+ }
773667
+ }
773668
+ if (input.footer?.trim()) {
773669
+ fallback.push(`<i>${escapeHtml2(input.footer.trim())}</i>`);
773670
+ }
773671
+ const rich = [`<h3>${escapeHtml2(input.title)}</h3>`];
773672
+ if (input.subtitle?.trim()) {
773673
+ rich.push(`<p><i>${telegramRichText(input.subtitle.trim())}</i></p>`);
773674
+ }
773675
+ if (metadata.length > 0) {
773676
+ rich.push(
773677
+ [
773678
+ "<table bordered striped compact>",
773679
+ "<tr><th>Field</th><th>Value</th></tr>",
773680
+ ...metadata.map(
773681
+ (item) => `<tr><td>${telegramRichText(item.label)}</td><td>${telegramRichText(item.value)}</td></tr>`
773682
+ ),
773683
+ "</table>"
773684
+ ].join("")
773685
+ );
773686
+ }
773687
+ if (sections.length === 0) {
773688
+ rich.push(`<p><i>${telegramRichText(emptyText)}</i></p>`);
773689
+ } else {
773690
+ for (const section of sections) {
773691
+ if (section.title) rich.push(`<h4>${escapeHtml2(section.title)}</h4>`);
773692
+ for (const packet of section.packets) {
773693
+ rich.push(
773694
+ `<details${packet.open ? " open" : ""}><summary>${escapeHtml2(packet.title)}</summary><p>${telegramRichText(packet.body)}</p></details>`
773695
+ );
773696
+ }
773697
+ }
773698
+ }
773699
+ if (input.footer?.trim()) {
773700
+ rich.push(`<footer>${telegramRichText(input.footer.trim())}</footer>`);
773701
+ }
773702
+ return { html: fallback.join("\n\n"), richHtml: rich.join("\n") };
773703
+ }
773704
+ function telegramTitledTextPackets(text3, fallbackTitle = "Details", maxPackets = 16) {
773705
+ const source = String(text3 ?? "").trim();
773706
+ if (!source) return [];
773707
+ const packets = [];
773708
+ let currentTitle = "";
773709
+ let currentLines = [];
773710
+ const flush3 = () => {
773711
+ const body = currentLines.join("\n").trim();
773712
+ if (body) {
773713
+ packets.push({
773714
+ title: currentTitle || fallbackTitle,
773715
+ body
773716
+ });
773717
+ }
773718
+ currentTitle = "";
773719
+ currentLines = [];
773720
+ };
773721
+ for (const line of source.split(/\r?\n/)) {
773722
+ const heading = line.match(/^([^:\n]{1,100}):\s*$/);
773723
+ if (heading) {
773724
+ flush3();
773725
+ currentTitle = heading[1].trim();
773726
+ } else {
773727
+ currentLines.push(line);
773728
+ }
773729
+ }
773730
+ flush3();
773731
+ if (packets.length <= 1 && !/^([^:\n]{1,100}):\s*$/m.test(source)) {
773732
+ const paragraphs = source.split(/\r?\n\s*\r?\n+/).map((paragraph) => paragraph.trim()).filter(Boolean);
773733
+ packets.length = 0;
773734
+ packets.push(
773735
+ ...paragraphs.map((paragraph, index) => ({
773736
+ title: paragraphs.length === 1 ? fallbackTitle : `${fallbackTitle} ${index + 1}`,
773737
+ body: paragraph
773738
+ }))
773739
+ );
773740
+ }
773741
+ if (packets.length <= maxPackets) return packets;
773742
+ const retained = packets.slice(0, Math.max(1, maxPackets - 1));
773743
+ retained.push({
773744
+ title: `${fallbackTitle} ${maxPackets}`,
773745
+ body: packets.slice(Math.max(1, maxPackets - 1)).map((packet) => `${packet.title}
773746
+ ${packet.body}`).join("\n\n")
773747
+ });
773748
+ return retained;
773749
+ }
773750
+ function splitTelegramPlainText(text3, maxLength = 2500) {
773751
+ const chunks = [];
773752
+ let remaining = String(text3 ?? "").trim();
773753
+ const limit2 = Math.max(200, Math.floor(maxLength));
773754
+ while (remaining.length > limit2) {
773755
+ let cut = remaining.lastIndexOf("\n\n", limit2);
773756
+ if (cut < limit2 * 0.4) cut = remaining.lastIndexOf("\n", limit2);
773757
+ if (cut < limit2 * 0.4) cut = remaining.lastIndexOf(". ", limit2);
773758
+ if (cut < limit2 * 0.4) cut = remaining.lastIndexOf(" ", limit2);
773759
+ if (cut < limit2 * 0.4) cut = limit2;
773760
+ const chunk = remaining.slice(0, cut).trim();
773761
+ if (chunk) chunks.push(chunk);
773762
+ remaining = remaining.slice(cut).trim();
773763
+ }
773764
+ if (remaining || chunks.length === 0) chunks.push(remaining);
773765
+ return chunks;
773766
+ }
773767
+ function telegramHtmlToPlainText(html) {
773768
+ return String(html ?? "").replace(/<br\s*\/?>/gi, "\n").replace(
773769
+ /<\/(?:p|h[1-6]|blockquote|details|summary|table|tr|ul|ol|li|footer)>/gi,
773770
+ "\n"
773771
+ ).replace(/<hr\s*\/?>/gi, "\n").replace(/<[^>]+>/g, "").replace(/&#(x[0-9a-f]+|\d+);/gi, (_match, value2) => {
773772
+ const radix = value2[0]?.toLowerCase() === "x" ? 16 : 10;
773773
+ const raw = radix === 16 ? value2.slice(1) : value2;
773774
+ const codePoint = Number.parseInt(raw, radix);
773775
+ return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : "";
773776
+ }).replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/\n[ \t]+/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
773777
+ }
773627
773778
  function safeJson(v, pretty) {
773628
773779
  try {
773629
773780
  return pretty ? JSON.stringify(v, null, 2) : JSON.stringify(v);
@@ -773637,11 +773788,14 @@ function tokenizeTelegramHtml(html) {
773637
773788
  let last2 = 0;
773638
773789
  let m2;
773639
773790
  while ((m2 = re.exec(html)) !== null) {
773640
- if (m2.index > last2) tokens3.push({ type: "text", raw: html.slice(last2, m2.index) });
773791
+ if (m2.index > last2)
773792
+ tokens3.push({ type: "text", raw: html.slice(last2, m2.index) });
773641
773793
  const closing = m2[1] === "/";
773642
773794
  const tag = (m2[2] || "").toLowerCase();
773643
773795
  if (SPAN_TAGS.has(tag)) {
773644
- tokens3.push(closing ? { type: "close", tag, raw: m2[0] } : { type: "open", tag, raw: m2[0] });
773796
+ tokens3.push(
773797
+ closing ? { type: "close", tag, raw: m2[0] } : { type: "open", tag, raw: m2[0] }
773798
+ );
773645
773799
  } else {
773646
773800
  tokens3.push({ type: "text", raw: m2[0] });
773647
773801
  }
@@ -781818,10 +781972,7 @@ function formatTelegramSteeringReconciliationHTML(values) {
781818
781972
  if (values.length === 0) return "";
781819
781973
  const sections = values.slice(-4).map((value2) => {
781820
781974
  const status = value2.status.replaceAll("_", " ");
781821
- const constraints = value2.changedConstraints.length ? [
781822
- "Changes:",
781823
- ...value2.changedConstraints.map((item) => `• ${item}`)
781824
- ] : ["Changes: none"];
781975
+ const constraints = value2.changedConstraints.length ? ["Changes:", ...value2.changedConstraints.map((item) => `• ${item}`)] : ["Changes: none"];
781825
781976
  return [
781826
781977
  `Status: ${status}`,
781827
781978
  ...constraints,
@@ -782395,11 +782546,78 @@ function telegramAdminLivePanelPageLabel(page2) {
782395
782546
  if (page2 === "evidence") return "Evidence";
782396
782547
  return "Context";
782397
782548
  }
782549
+ function telegramPanelHtmlFallback(html) {
782550
+ const chunks = segmentTelegramHtml(html, 3600);
782551
+ if (chunks.length <= 1) return chunks[0] ?? "";
782552
+ return `${chunks[0]}
782553
+
782554
+ <i>... (additional packet detail requires Rich Message support)</i>`;
782555
+ }
782556
+ function telegramAdminLinePackets(lines, fallbackTitle) {
782557
+ return lines.map((line, index) => {
782558
+ const structured = line.match(
782559
+ /^([→✓✗])\s+([^\s:]+)(?::\s*|\s+)?([\s\S]*)$/
782560
+ );
782561
+ if (!structured) {
782562
+ return { title: `${fallbackTitle} ${index + 1}`, body: line };
782563
+ }
782564
+ const marker = structured[1];
782565
+ const toolName = structured[2] || "tool";
782566
+ const detail = structured[3]?.trim();
782567
+ const phase = marker === "→" ? "Call" : marker === "✓" ? "Result" : "Failure";
782568
+ return {
782569
+ title: `${phase} · ${toolName}`,
782570
+ body: detail || (marker === "→" ? "Request admitted." : marker === "✓" ? "Completed." : "The tool reported a failure.")
782571
+ };
782572
+ });
782573
+ }
782574
+ function telegramContextMetadata(page2, pageIndex, pageCount) {
782575
+ return [
782576
+ { label: "Packet", value: `${pageIndex + 1} / ${pageCount}` },
782577
+ { label: "Source", value: page2.source },
782578
+ ...page2.metadata.map((line, index) => {
782579
+ const equalsAt = line.indexOf("=");
782580
+ return equalsAt > 0 ? {
782581
+ label: line.slice(0, equalsAt).trim(),
782582
+ value: line.slice(equalsAt + 1).trim()
782583
+ } : { label: `Detail ${index + 1}`, value: line };
782584
+ })
782585
+ ];
782586
+ }
782587
+ function renderTelegramContextExplorerPagePayload(page2, pageIndex, pageCount, title = "Context used for this reply") {
782588
+ if (!page2) {
782589
+ const empty2 = renderTelegramPanelPage({
782590
+ title,
782591
+ sections: [],
782592
+ emptyText: "No context packets are available."
782593
+ });
782594
+ return { text: empty2.html, rich_html: empty2.richHtml };
782595
+ }
782596
+ const rendered = renderTelegramPanelPage({
782597
+ title,
782598
+ subtitle: page2.title,
782599
+ metadata: telegramContextMetadata(page2, pageIndex, pageCount),
782600
+ sections: [
782601
+ {
782602
+ packets: telegramTitledTextPackets(page2.body, "Content")
782603
+ }
782604
+ ],
782605
+ emptyText: "This context packet is empty.",
782606
+ footer: `Context packet ${pageIndex + 1} of ${pageCount}`
782607
+ });
782608
+ return {
782609
+ text: telegramPanelHtmlFallback(rendered.html),
782610
+ rich_html: rendered.richHtml
782611
+ };
782612
+ }
782398
782613
  function trimTelegramAdminPanelLines(lines, max = 80) {
782399
782614
  if (lines.length > max) lines.splice(0, lines.length - max);
782400
782615
  }
782401
782616
  function pushTelegramAdminPanelLine(state5, page2, line) {
782402
- const clean7 = stripTelegramHiddenThinking(line).replace(/\s+/g, " ").trim();
782617
+ const clean7 = sanitizeTelegramProgressText(
782618
+ stripTelegramHiddenThinking(line).replace(/\s+/g, " ").trim(),
782619
+ 1e3
782620
+ );
782403
782621
  if (!clean7) return;
782404
782622
  const target = page2 === "tools" ? state5.toolLines : page2 === "logs" ? state5.logLines : state5.mutationLines;
782405
782623
  if (target[target.length - 1] !== clean7) target.push(clean7);
@@ -782408,7 +782626,10 @@ function pushTelegramAdminPanelLine(state5, page2, line) {
782408
782626
  if (state5.activePage !== page2) state5.dirtyPages[page2] = true;
782409
782627
  }
782410
782628
  function pushTelegramAdminPanelMutationLine(state5, line) {
782411
- const clean7 = stripTelegramHiddenThinking(line).replace(/\s+/g, " ").trim();
782629
+ const clean7 = sanitizeTelegramProgressText(
782630
+ stripTelegramHiddenThinking(line).replace(/\s+/g, " ").trim(),
782631
+ 1e3
782632
+ );
782412
782633
  if (!clean7) return;
782413
782634
  if (state5.mutationLines[state5.mutationLines.length - 1] !== clean7)
782414
782635
  state5.mutationLines.push(clean7);
@@ -782428,6 +782649,37 @@ function telegramAdminLivePanelIntakeText(requestPreview) {
782428
782649
  void requestPreview;
782429
782650
  return "";
782430
782651
  }
782652
+ function telegramAdminEventTurn(event) {
782653
+ const turn = event.turn;
782654
+ return typeof turn === "number" && Number.isFinite(turn) ? turn : void 0;
782655
+ }
782656
+ function syncTelegramAdminResponseText(state5) {
782657
+ state5.responseText = state5.responseSegments.map(
782658
+ (segment) => cleanTelegramVisibleReply(segment.rawText, {
782659
+ suppressPotentialNoReplyPrefix: true
782660
+ })
782661
+ ).filter(Boolean).join("\n\n");
782662
+ }
782663
+ function upsertTelegramAdminResponseSegment(state5, key, turn, rawText, complete) {
782664
+ const existing = state5.responseSegments.find(
782665
+ (segment) => segment.key === key
782666
+ );
782667
+ if (existing) {
782668
+ existing.rawText = rawText;
782669
+ existing.complete = complete;
782670
+ } else {
782671
+ state5.responseSegments.push({
782672
+ key,
782673
+ ...turn !== void 0 ? { turn } : {},
782674
+ rawText,
782675
+ complete
782676
+ });
782677
+ }
782678
+ if (state5.responseSegments.length > 8) {
782679
+ state5.responseSegments.splice(0, state5.responseSegments.length - 8);
782680
+ }
782681
+ syncTelegramAdminResponseText(state5);
782682
+ }
782431
782683
  function renderTelegramHalftoneProgressBar(elapsedSec, width = 12) {
782432
782684
  const safeWidth = Math.max(1, Math.floor(width));
782433
782685
  const phase = Math.max(0, elapsedSec) % 60 / 60 * safeWidth;
@@ -782460,6 +782712,8 @@ function createTelegramAdminLivePanelState(args) {
782460
782712
  requestPreview,
782461
782713
  intakeText: telegramAdminLivePanelIntakeText(requestPreview),
782462
782714
  responseText: "",
782715
+ responseSegments: [],
782716
+ responseSegmentSequence: 0,
782463
782717
  steeringReconciliations: [],
782464
782718
  evidenceText: "",
782465
782719
  toolLines: [],
@@ -782470,24 +782724,40 @@ function createTelegramAdminLivePanelState(args) {
782470
782724
  };
782471
782725
  }
782472
782726
  function applyTelegramAdminLivePanelEvent(state5, event) {
782727
+ if (event.type === "stream_start") {
782728
+ const turn = telegramAdminEventTurn(event);
782729
+ const key = turn !== void 0 ? `turn:${turn}` : `stream:${++state5.responseSegmentSequence}`;
782730
+ upsertTelegramAdminResponseSegment(state5, key, turn, "", false);
782731
+ state5.activeResponseSegmentKey = key;
782732
+ return;
782733
+ }
782473
782734
  if (event.type === "stream_token" && event.streamKind === "content" && event.content) {
782474
- const next = cleanTelegramVisibleReply(
782475
- `${state5.responseText}${event.content}`,
782476
- { suppressPotentialNoReplyPrefix: true }
782735
+ const turn = telegramAdminEventTurn(event);
782736
+ const key = state5.activeResponseSegmentKey ?? (turn !== void 0 ? `turn:${turn}` : `stream:${++state5.responseSegmentSequence}`);
782737
+ const existing = state5.responseSegments.find(
782738
+ (segment) => segment.key === key
782477
782739
  );
782478
- if (next) {
782479
- state5.responseText = next;
782740
+ upsertTelegramAdminResponseSegment(
782741
+ state5,
782742
+ key,
782743
+ turn,
782744
+ `${existing?.rawText ?? ""}${event.content}`,
782745
+ false
782746
+ );
782747
+ if (state5.responseText) {
782480
782748
  state5.updatedAt = Date.now();
782481
782749
  if (state5.activePage !== "response") state5.dirtyPages.response = true;
782482
782750
  }
782483
782751
  return;
782484
782752
  }
782485
782753
  if ((event.type === "assistant_text" || event.type === "stream_end") && event.content) {
782486
- const next = cleanTelegramVisibleReply(event.content, {
782487
- suppressPotentialNoReplyPrefix: true
782488
- });
782489
- if (next) {
782490
- state5.responseText = next;
782754
+ const turn = telegramAdminEventTurn(event);
782755
+ const key = turn !== void 0 ? `turn:${turn}` : state5.activeResponseSegmentKey ?? `event:${++state5.responseSegmentSequence}`;
782756
+ upsertTelegramAdminResponseSegment(state5, key, turn, event.content, true);
782757
+ if (state5.activeResponseSegmentKey === key) {
782758
+ state5.activeResponseSegmentKey = void 0;
782759
+ }
782760
+ if (state5.responseText) {
782491
782761
  state5.updatedAt = Date.now();
782492
782762
  if (state5.activePage !== "response") state5.dirtyPages.response = true;
782493
782763
  }
@@ -782530,12 +782800,12 @@ function applyTelegramAdminLivePanelEvent(state5, event) {
782530
782800
  }
782531
782801
  }
782532
782802
  function renderTelegramAdminLivePanelPayload(state5) {
782533
- state5.dirtyPages[state5.activePage] = false;
782534
- const header = [
782535
- `<b>Admin run:</b> <code>${escapeTelegramHTML(state5.status)}</code>`,
782536
- state5.requestPreview ? `<i>${escapeTelegramHTML(state5.requestPreview)}</i>` : ""
782537
- ].filter(Boolean).join("\n");
782803
+ const metadata = [
782804
+ { label: "Run status", value: state5.status },
782805
+ ...state5.requestPreview ? [{ label: "Request", value: state5.requestPreview }] : []
782806
+ ];
782538
782807
  let body;
782808
+ let richHtml;
782539
782809
  if (state5.activePage === "response") {
782540
782810
  const response = state5.responseText.trim();
782541
782811
  const clipped = response.length > 2600 ? `${response.slice(0, 2597).trimEnd()}...` : response;
@@ -782548,15 +782818,53 @@ function renderTelegramAdminLivePanelPayload(state5) {
782548
782818
  ].filter(Boolean).join("\n\n");
782549
782819
  } else if (state5.activePage === "tools") {
782550
782820
  const lines = state5.toolLines.slice(-12);
782551
- body = lines.length > 0 ? `<blockquote>${escapeTelegramHTML(lines.join("\n"))}</blockquote>` : "<i>No tool calls yet.</i>";
782821
+ const rendered = renderTelegramPanelPage({
782822
+ title: "Tools",
782823
+ subtitle: `${lines.length} recent tool event${lines.length === 1 ? "" : "s"}. Newest is last.`,
782824
+ metadata,
782825
+ sections: [{ packets: telegramAdminLinePackets(lines, "Tool event") }],
782826
+ emptyText: "No tool calls yet.",
782827
+ footer: "Page 2 of 5 · Tools"
782828
+ });
782829
+ body = telegramPanelHtmlFallback(rendered.html);
782830
+ richHtml = rendered.richHtml;
782552
782831
  } else if (state5.activePage === "logs") {
782553
- const lines = [
782554
- ...state5.mutationLines.slice(-8),
782555
- ...state5.logLines.slice(-10)
782556
- ];
782557
- body = lines.length > 0 ? `<blockquote expandable>${escapeTelegramHTML(lines.join("\n"))}</blockquote>` : "<i>No mutations or logs yet.</i>";
782832
+ const mutations = state5.mutationLines.slice(-8);
782833
+ const logs = state5.logLines.slice(-10);
782834
+ const rendered = renderTelegramPanelPage({
782835
+ title: "Activity",
782836
+ subtitle: `${mutations.length} workspace change event${mutations.length === 1 ? "" : "s"}; ${logs.length} runner event${logs.length === 1 ? "" : "s"}.`,
782837
+ metadata,
782838
+ sections: [
782839
+ {
782840
+ title: "Workspace changes",
782841
+ packets: telegramAdminLinePackets(mutations, "Change")
782842
+ },
782843
+ {
782844
+ title: "Run activity",
782845
+ packets: telegramAdminLinePackets(logs, "Event")
782846
+ }
782847
+ ],
782848
+ emptyText: "No workspace changes or runner activity yet.",
782849
+ footer: "Page 3 of 5 · Activity"
782850
+ });
782851
+ body = telegramPanelHtmlFallback(rendered.html);
782852
+ richHtml = rendered.richHtml;
782558
782853
  } else if (state5.activePage === "evidence") {
782559
- body = state5.evidenceText.trim() ? `<blockquote expandable>${escapeTelegramHTML(state5.evidenceText.trim())}</blockquote>` : "<i>No completion evidence yet.</i>";
782854
+ const packets = telegramTitledTextPackets(
782855
+ state5.evidenceText,
782856
+ "Completion evidence"
782857
+ );
782858
+ const rendered = renderTelegramPanelPage({
782859
+ title: "Evidence",
782860
+ subtitle: `${packets.length} completion evidence packet${packets.length === 1 ? "" : "s"}.`,
782861
+ metadata,
782862
+ sections: [{ packets }],
782863
+ emptyText: "No completion evidence yet.",
782864
+ footer: "Page 4 of 5 · Evidence"
782865
+ });
782866
+ body = telegramPanelHtmlFallback(rendered.html);
782867
+ richHtml = rendered.richHtml;
782560
782868
  } else {
782561
782869
  const pageCount = state5.contextPages.length;
782562
782870
  const pageIndex = Math.min(
@@ -782565,36 +782873,20 @@ function renderTelegramAdminLivePanelPayload(state5) {
782565
782873
  );
782566
782874
  state5.contextPageIndex = pageIndex;
782567
782875
  const page2 = state5.contextPages[pageIndex];
782568
- if (page2) {
782569
- const meta = page2.metadata.map((line) => `<code>${escapeTelegramHTML(line)}</code>`).join("\n");
782570
- body = [
782571
- `<b>${escapeTelegramHTML(page2.title)}</b>`,
782572
- `Source: <code>${escapeTelegramHTML(page2.source)}</code>`,
782573
- meta,
782574
- "",
782575
- page2.body.trim() ? `<blockquote expandable>${escapeTelegramHTML(page2.body)}</blockquote>` : "<i>Section was empty.</i>",
782576
- "",
782577
- `<i>Context ${pageIndex + 1}/${pageCount}</i>`
782578
- ].filter(Boolean).join("\n");
782579
- } else {
782580
- body = "<i>Full context has not been captured yet.</i>";
782581
- }
782876
+ const rendered = renderTelegramContextExplorerPagePayload(
782877
+ page2,
782878
+ pageIndex,
782879
+ pageCount,
782880
+ "Context"
782881
+ );
782882
+ body = rendered.text;
782883
+ richHtml = rendered.rich_html;
782582
782884
  }
782583
- const panelText = state5.activePage === "response" ? body : [
782584
- header,
782585
- "",
782586
- body,
782587
- "",
782588
- `<i>Page ${TELEGRAM_ADMIN_LIVE_PANEL_PAGES.indexOf(state5.activePage) + 1}/${TELEGRAM_ADMIN_LIVE_PANEL_PAGES.length}: ${telegramAdminLivePanelPageLabel(state5.activePage)}</i>`
782589
- ].join("\n");
782590
- const text3 = truncateTelegramUrlSafe(
782591
- panelText,
782592
- 3900,
782593
- "\n\n<i>... (panel clipped)</i>"
782594
- );
782885
+ const text3 = body;
782595
782886
  const pageButtons = TELEGRAM_ADMIN_LIVE_PANEL_PAGES.map((page2) => ({
782596
782887
  text: `${page2 === state5.activePage ? "●" : "○"} ${telegramAdminLivePanelPageLabel(page2)}${state5.dirtyPages[page2] ? " *" : ""}`,
782597
- callback_data: `omni:v1:tgadmin:${state5.nonce}:page:${page2}`
782888
+ callback_data: `omni:v1:tgadmin:${state5.nonce}:page:${page2}`,
782889
+ ...page2 === state5.activePage ? { style: "primary" } : {}
782598
782890
  }));
782599
782891
  const keyboard = [
782600
782892
  pageButtons.slice(0, 3),
@@ -782606,19 +782898,28 @@ function renderTelegramAdminLivePanelPayload(state5) {
782606
782898
  keyboard.push([
782607
782899
  {
782608
782900
  text: "Prev",
782609
- callback_data: `omni:v1:tgadmin:${state5.nonce}:ctx:${Math.max(0, pageIndex - 1)}`
782901
+ ...pageIndex > 0 ? {
782902
+ callback_data: `omni:v1:tgadmin:${state5.nonce}:ctx:${pageIndex - 1}`
782903
+ } : { disabled: {} }
782610
782904
  },
782611
782905
  {
782612
782906
  text: `${pageIndex + 1}/${lastPage + 1}`,
782613
- callback_data: `omni:v1:tgadmin:${state5.nonce}:ctx:${pageIndex}`
782907
+ disabled: {},
782908
+ style: "primary"
782614
782909
  },
782615
782910
  {
782616
782911
  text: "Next",
782617
- callback_data: `omni:v1:tgadmin:${state5.nonce}:ctx:${Math.min(lastPage, pageIndex + 1)}`
782912
+ ...pageIndex < lastPage ? {
782913
+ callback_data: `omni:v1:tgadmin:${state5.nonce}:ctx:${pageIndex + 1}`
782914
+ } : { disabled: {} }
782618
782915
  }
782619
782916
  ]);
782620
782917
  }
782621
- return { text: text3, reply_markup: { inline_keyboard: keyboard } };
782918
+ return {
782919
+ text: text3,
782920
+ ...richHtml ? { rich_html: richHtml } : {},
782921
+ reply_markup: { inline_keyboard: keyboard }
782922
+ };
782622
782923
  }
782623
782924
  function splitTelegramReminderDue(raw) {
782624
782925
  const text3 = raw.trim().replace(/^set\s+/i, "").trim();
@@ -793540,10 +793841,14 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
793540
793841
  * Send a placeholder message that will be progressively edited with
793541
793842
  * streamed content. Returns the message_id for subsequent edits.
793542
793843
  */
793543
- async sendLiveMessage(chatId, initialText, replyToMessageId, replyMarkup) {
793844
+ async sendLiveMessage(chatId, initialText, replyToMessageId, replyMarkup, richHtml) {
793544
793845
  const normalizedInitialText = normalizeTelegramOutboundLinks(initialText);
793846
+ const normalizedRichHtml = richHtml ? normalizeTelegramOutboundLinks(richHtml) : "";
793545
793847
  try {
793546
- const body = {
793848
+ const body = normalizedRichHtml ? {
793849
+ chat_id: chatId,
793850
+ rich_message: { html: normalizedRichHtml }
793851
+ } : {
793547
793852
  chat_id: chatId,
793548
793853
  text: normalizedInitialText,
793549
793854
  parse_mode: "HTML"
@@ -793551,15 +793856,16 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
793551
793856
  const replyParameters = telegramReplyParameters(replyToMessageId);
793552
793857
  if (replyParameters) body["reply_parameters"] = replyParameters;
793553
793858
  if (replyMarkup) body["reply_markup"] = replyMarkup;
793554
- const result = await this.apiCall("sendMessage", body);
793859
+ const method = normalizedRichHtml ? "sendRichMessage" : "sendMessage";
793860
+ const result = await this.apiCall(method, body);
793555
793861
  if (result.ok === false) {
793556
793862
  throw new Error(
793557
- String(result.description || "Telegram sendMessage failed")
793863
+ String(result.description || `Telegram ${method} failed`)
793558
793864
  );
793559
793865
  }
793560
793866
  const messageId = result.result?.message_id;
793561
793867
  if (!Number.isInteger(messageId)) {
793562
- throw new Error("Telegram sendMessage returned no valid message_id");
793868
+ throw new Error(`Telegram ${method} returned no valid message_id`);
793563
793869
  }
793564
793870
  this.state.messagesSent++;
793565
793871
  this.updateTelegramTextDeliveryCapability(chatId, {
@@ -793569,10 +793875,43 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
793569
793875
  });
793570
793876
  return messageId;
793571
793877
  } catch {
793878
+ if (normalizedRichHtml) {
793879
+ try {
793880
+ const body = {
793881
+ chat_id: chatId,
793882
+ text: normalizedInitialText,
793883
+ parse_mode: "HTML"
793884
+ };
793885
+ const replyParameters = telegramReplyParameters(replyToMessageId);
793886
+ if (replyParameters) body["reply_parameters"] = replyParameters;
793887
+ if (replyMarkup) body["reply_markup"] = replyMarkup;
793888
+ const result = await this.apiCall("sendMessage", body);
793889
+ if (result.ok === false) {
793890
+ throw new Error(
793891
+ String(result.description || "Telegram sendMessage failed")
793892
+ );
793893
+ }
793894
+ const messageId = result.result?.message_id;
793895
+ if (!Number.isInteger(messageId)) {
793896
+ throw new Error(
793897
+ "Telegram sendMessage returned no valid message_id"
793898
+ );
793899
+ }
793900
+ this.state.messagesSent++;
793901
+ this.updateTelegramTextDeliveryCapability(chatId, {
793902
+ status: "allowed",
793903
+ canSendText: true,
793904
+ source: "sendLiveMessage.html_fallback"
793905
+ });
793906
+ return messageId;
793907
+ } catch {
793908
+ }
793909
+ }
793572
793910
  try {
793911
+ const readablePlain = telegramHtmlToPlainText(normalizedInitialText);
793573
793912
  const body = {
793574
793913
  chat_id: chatId,
793575
- text: normalizedInitialText
793914
+ text: readablePlain || "No displayable content."
793576
793915
  };
793577
793916
  const replyParameters = telegramReplyParameters(replyToMessageId);
793578
793917
  if (replyParameters) body["reply_parameters"] = replyParameters;
@@ -793620,19 +793959,18 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
793620
793959
  * Edit a live message with updated content. Used for progressive streaming.
793621
793960
  * Handles rate limits and Telegram's "message is not modified" error silently.
793622
793961
  */
793623
- async editLiveMessage(chatId, messageId, html, replyMarkup) {
793962
+ async editLiveMessage(chatId, messageId, html, replyMarkup, richHtml) {
793624
793963
  const normalizedHtml = normalizeTelegramOutboundLinks(html);
793625
- const truncated = normalizedHtml.length > 4e3 ? truncateTelegramUrlSafe(
793626
- normalizedHtml,
793627
- 4e3,
793628
- "\n\n<i>... (streaming)</i>"
793629
- ) : normalizedHtml;
793964
+ const normalizedRichHtml = richHtml ? normalizeTelegramOutboundLinks(richHtml) : "";
793965
+ const htmlSegments = segmentTelegramHtml(normalizedHtml, 3600);
793966
+ const truncated = htmlSegments.length > 1 ? `${htmlSegments[0]}
793967
+
793968
+ <i>... (additional detail clipped)</i>` : htmlSegments[0] ?? normalizedHtml;
793630
793969
  try {
793631
793970
  const result = await this.apiCall("editMessageText", {
793632
793971
  chat_id: chatId,
793633
793972
  message_id: messageId,
793634
- text: truncated,
793635
- parse_mode: "HTML",
793973
+ ...normalizedRichHtml ? { rich_message: { html: normalizedRichHtml } } : { text: truncated, parse_mode: "HTML" },
793636
793974
  ...replyMarkup ? { reply_markup: replyMarkup } : {}
793637
793975
  });
793638
793976
  if (result.error_code === 400 && result.description?.includes("not modified"))
@@ -793644,8 +793982,24 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
793644
793982
  );
793645
793983
  return true;
793646
793984
  } catch {
793985
+ if (normalizedRichHtml) {
793986
+ try {
793987
+ const result = await this.apiCall("editMessageText", {
793988
+ chat_id: chatId,
793989
+ message_id: messageId,
793990
+ text: truncated,
793991
+ parse_mode: "HTML",
793992
+ ...replyMarkup ? { reply_markup: replyMarkup } : {}
793993
+ });
793994
+ if (result.error_code === 400 && result.description?.includes("not modified"))
793995
+ return true;
793996
+ if (result.error_code === 429) return false;
793997
+ if (result.ok !== false) return true;
793998
+ } catch {
793999
+ }
794000
+ }
793647
794001
  try {
793648
- const plain = normalizedHtml.replace(/<[^>]+>/g, "");
794002
+ const plain = telegramHtmlToPlainText(normalizedHtml);
793649
794003
  const truncPlain = plain.length > 4e3 ? truncateTelegramUrlSafe(plain, 4e3, "\n\n... (streaming)") : plain;
793650
794004
  const result = await this.apiCall("editMessageText", {
793651
794005
  chat_id: chatId,
@@ -793760,20 +794114,25 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
793760
794114
  async renderTelegramAdminLivePanel(state5, replyToMessageId) {
793761
794115
  const payload = renderTelegramAdminLivePanelPayload(state5);
793762
794116
  if (state5.messageId !== void 0) {
793763
- return this.editLiveMessage(
794117
+ const delivered = await this.editLiveMessage(
793764
794118
  state5.chatId,
793765
794119
  state5.messageId,
793766
794120
  payload.text,
793767
- payload.reply_markup
794121
+ payload.reply_markup,
794122
+ payload.rich_html
793768
794123
  );
794124
+ if (delivered) state5.dirtyPages[state5.activePage] = false;
794125
+ return delivered;
793769
794126
  }
793770
794127
  const messageId = await this.sendLiveMessage(
793771
794128
  state5.chatId,
793772
794129
  payload.text,
793773
794130
  replyToMessageId,
793774
- payload.reply_markup
794131
+ payload.reply_markup,
794132
+ payload.rich_html
793775
794133
  );
793776
794134
  state5.messageId = messageId;
794135
+ state5.dirtyPages[state5.activePage] = false;
793777
794136
  return true;
793778
794137
  }
793779
794138
  updateTelegramAdminLivePanelFromEvent(subAgent, msg, event) {
@@ -793808,12 +794167,14 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
793808
794167
  ...subAgent.steeringReconciliations.values()
793809
794168
  ];
793810
794169
  state5.responseText = replyText || (status === "failed" ? "I couldn't complete that request." : "Done.");
794170
+ state5.responseSegments = [];
794171
+ state5.activeResponseSegmentKey = void 0;
793811
794172
  if (evidenceText.trim()) {
793812
794173
  state5.evidenceText = evidenceText.trim();
793813
794174
  state5.dirtyPages.evidence = true;
793814
794175
  }
793815
- state5.activePage = "response";
793816
- state5.dirtyPages.response = false;
794176
+ if (state5.activePage === "response") state5.dirtyPages.response = false;
794177
+ else state5.dirtyPages.response = true;
793817
794178
  state5.updatedAt = Date.now();
793818
794179
  this.refreshTelegramAdminLivePanelContextPages(state5, subAgent, msg);
793819
794180
  if (subAgent.liveMessagePromise)
@@ -793948,6 +794309,7 @@ ${signals || summary || "Canonical runner status reported completed."}`
793948
794309
  [
793949
794310
  {
793950
794311
  text: "Admin context",
794312
+ style: "primary",
793951
794313
  callback_data: this.telegramContextExplorerCallbackData(
793952
794314
  id2,
793953
794315
  "open",
@@ -793966,35 +794328,36 @@ ${signals || summary || "Canonical runner status reported completed."}`
793966
794328
  [
793967
794329
  {
793968
794330
  text: "Prev",
793969
- callback_data: this.telegramContextExplorerCallbackData(
793970
- state5.id,
793971
- "page",
793972
- Math.max(0, page2 - 1)
793973
- )
794331
+ ...page2 > 0 ? {
794332
+ callback_data: this.telegramContextExplorerCallbackData(
794333
+ state5.id,
794334
+ "page",
794335
+ page2 - 1
794336
+ )
794337
+ } : { disabled: {} }
793974
794338
  },
793975
794339
  {
793976
794340
  text: `${page2 + 1}/${lastPage + 1}`,
793977
- callback_data: this.telegramContextExplorerCallbackData(
793978
- state5.id,
793979
- "noop",
793980
- page2
793981
- )
794341
+ disabled: {},
794342
+ style: "primary"
793982
794343
  },
793983
794344
  {
793984
794345
  text: "Next",
793985
- callback_data: this.telegramContextExplorerCallbackData(
793986
- state5.id,
793987
- "page",
793988
- Math.min(lastPage, page2 + 1)
793989
- )
794346
+ ...page2 < lastPage ? {
794347
+ callback_data: this.telegramContextExplorerCallbackData(
794348
+ state5.id,
794349
+ "page",
794350
+ page2 + 1
794351
+ )
794352
+ } : { disabled: {} }
793990
794353
  }
793991
794354
  ],
793992
794355
  [
793993
794356
  {
793994
- text: "Reply",
794357
+ text: "Close context",
793995
794358
  callback_data: this.telegramContextExplorerCallbackData(
793996
794359
  state5.id,
793997
- "reply",
794360
+ "close",
793998
794361
  page2
793999
794362
  )
794000
794363
  }
@@ -794005,7 +794368,7 @@ ${signals || summary || "Canonical runner status reported completed."}`
794005
794368
  splitTelegramContextBody(text3, maxLength = 2500) {
794006
794369
  const cleaned = stripTelegramHiddenThinking(text3 || "").trim();
794007
794370
  if (!cleaned) return [""];
794008
- return splitTelegramMessageText(cleaned, maxLength);
794371
+ return splitTelegramPlainText(cleaned, maxLength);
794009
794372
  }
794010
794373
  addTelegramContextExplorerPages(pages, title, source, body, metadata) {
794011
794374
  const chunks = this.splitTelegramContextBody(body);
@@ -794045,7 +794408,7 @@ ${signals || summary || "Canonical runner status reported completed."}`
794045
794408
  "",
794046
794409
  "Visible reply preview:",
794047
794410
  cleanTelegramVisibleReply(finalText).slice(0, 900) || "(empty)"
794048
- ].filter((line) => line !== "").join("\n");
794411
+ ].join("\n").replace(/\n{3,}/g, "\n\n").trim();
794049
794412
  pages.push({
794050
794413
  title: "Overview",
794051
794414
  source: "telegram.final_reply",
@@ -794056,6 +794419,23 @@ ${signals || summary || "Canonical runner status reported completed."}`
794056
794419
  `chat_id=${String(msg.chatId)}`
794057
794420
  ]
794058
794421
  });
794422
+ const reconciliations = [...subAgent.steeringReconciliations.values()];
794423
+ if (reconciliations.length > 0) {
794424
+ this.addTelegramContextExplorerPages(
794425
+ pages,
794426
+ "Plan updates",
794427
+ "runner.steering_reconciliation",
794428
+ reconciliations.map(
794429
+ (value2, index) => [
794430
+ `Update ${index + 1}:`,
794431
+ `Status: ${value2.status.replaceAll("_", " ")}`,
794432
+ ...value2.changedConstraints.length > 0 ? value2.changedConstraints.map((item) => `Change: ${item}`) : ["Change: none"],
794433
+ `Next: ${value2.revisedNextAction}`
794434
+ ].join("\n")
794435
+ ).join("\n\n"),
794436
+ [`count=${reconciliations.length}`, "visibility=admin-only"]
794437
+ );
794438
+ }
794059
794439
  if (frame2) {
794060
794440
  for (const section of frame2.sections) {
794061
794441
  this.addTelegramContextExplorerPages(
@@ -794146,23 +794526,43 @@ ${signals || summary || "Canonical runner status reported completed."}`
794146
794526
  [`count=${prompt.toolNames.length}`]
794147
794527
  );
794148
794528
  }
794149
- return pages;
794529
+ const redactor = getSecretRedactor();
794530
+ const redactedPages = pages.map((page2) => ({
794531
+ title: redactor.redactText(page2.title),
794532
+ source: redactor.redactText(page2.source),
794533
+ body: redactor.redactText(page2.body),
794534
+ metadata: page2.metadata.map((line) => redactor.redactText(line))
794535
+ }));
794536
+ const maxPages = 64;
794537
+ if (redactedPages.length <= maxPages) return redactedPages;
794538
+ const omitted = redactedPages.length - (maxPages - 1);
794539
+ return [
794540
+ ...redactedPages.slice(0, maxPages - 1),
794541
+ {
794542
+ title: "Omitted context packets",
794543
+ source: "telegram.context_budget",
794544
+ body: `${omitted} additional packet${omitted === 1 ? " was" : "s were"} omitted from this interactive view.`,
794545
+ metadata: [
794546
+ `retained=${maxPages - 1}`,
794547
+ `omitted=${omitted}`,
794548
+ `total=${redactedPages.length}`
794549
+ ]
794550
+ }
794551
+ ];
794150
794552
  }
794151
- buildTelegramContextExplorerState(msg, subAgent, finalHtml, finalText) {
794553
+ buildTelegramContextExplorerState(msg, subAgent, finalText) {
794152
794554
  const pages = this.buildTelegramContextExplorerPages(
794153
794555
  msg,
794154
794556
  subAgent,
794155
794557
  finalText
794156
794558
  );
794157
794559
  if (pages.length === 0) return null;
794158
- const finalHtmlFirstChunk = splitTelegramMessageText(finalHtml, 3900)[0] ?? finalHtml;
794159
794560
  const id2 = randomBytes29(6).toString("hex");
794160
794561
  const now2 = Date.now();
794161
794562
  return {
794162
794563
  id: id2,
794163
- chatId: msg.chatId,
794164
- messageId: null,
794165
- finalHtml: finalHtmlFirstChunk,
794564
+ sourceChatId: msg.chatId,
794565
+ sourceMessageId: null,
794166
794566
  activePage: 0,
794167
794567
  pages,
794168
794568
  createdAtMs: now2,
@@ -794175,20 +794575,10 @@ ${signals || summary || "Canonical runner status reported completed."}`
794175
794575
  Math.max(0, state5.pages.length - 1)
794176
794576
  );
794177
794577
  const page2 = state5.pages[pageIndex];
794178
- if (!page2) return "<b>Context frame</b>\n<i>No pages available.</i>";
794179
- const meta = page2.metadata.map((line) => `<code>${escapeTelegramHTML(line)}</code>`).join("\n");
794180
- const body = page2.body.trim() ? `<blockquote expandable>${escapeTelegramHTML(page2.body)}</blockquote>` : "<i>Section was empty.</i>";
794181
- return truncateTelegramUrlSafe(
794182
- [
794183
- `<b>Context frame</b>`,
794184
- `<i>Page ${pageIndex + 1}/${state5.pages.length}: ${escapeTelegramHTML(page2.title)}</i>`,
794185
- `Source: <code>${escapeTelegramHTML(page2.source)}</code>`,
794186
- meta,
794187
- "",
794188
- body
794189
- ].filter(Boolean).join("\n"),
794190
- 3900,
794191
- "\n\n<i>... (context page clipped)</i>"
794578
+ return renderTelegramContextExplorerPagePayload(
794579
+ page2,
794580
+ pageIndex,
794581
+ state5.pages.length
794192
794582
  );
794193
794583
  }
794194
794584
  async handleTelegramContextExplorerCallback(callback) {
@@ -794215,36 +794605,94 @@ ${signals || summary || "Canonical runner status reported completed."}`
794215
794605
  }
794216
794606
  const action = parts[4];
794217
794607
  const requestedPage = Number.parseInt(parts[5] ?? "0", 10);
794218
- const messageId = state5.messageId ?? callback.messageId;
794219
- if (messageId === void 0) {
794220
- answerText = "Cannot identify context frame message.";
794608
+ if (action === "open") {
794609
+ if (callback.chatId !== state5.sourceChatId || callback.messageId !== state5.sourceMessageId) {
794610
+ answerText = "This context button is not bound to this message.";
794611
+ alert = true;
794612
+ return;
794613
+ }
794614
+ const maxPage2 = Math.max(0, state5.pages.length - 1);
794615
+ const nextPage2 = Number.isFinite(requestedPage) ? Math.min(maxPage2, Math.max(0, requestedPage)) : 0;
794616
+ const previousPage2 = state5.activePage;
794617
+ state5.activePage = nextPage2;
794618
+ const payload2 = this.renderTelegramContextExplorerPage(state5);
794619
+ const markup = this.telegramContextExplorerPageMarkup(state5);
794620
+ try {
794621
+ if (state5.panelMessageId !== void 0 && state5.panelChatId === callback.fromUserId) {
794622
+ const edited2 = await this.editLiveMessage(
794623
+ callback.fromUserId,
794624
+ state5.panelMessageId,
794625
+ payload2.text,
794626
+ markup,
794627
+ payload2.rich_html
794628
+ );
794629
+ if (!edited2) throw new Error("Telegram did not apply the DM edit");
794630
+ } else {
794631
+ state5.panelMessageId = await this.sendLiveMessage(
794632
+ callback.fromUserId,
794633
+ payload2.text,
794634
+ void 0,
794635
+ markup,
794636
+ payload2.rich_html
794637
+ );
794638
+ }
794639
+ } catch {
794640
+ state5.activePage = previousPage2;
794641
+ answerText = `Open a private chat with @${this.state.botUsername || "omnius_agent_bot"}, press Start, then try again.`;
794642
+ alert = true;
794643
+ return;
794644
+ }
794645
+ state5.viewerUserId = callback.fromUserId;
794646
+ state5.panelChatId = callback.fromUserId;
794647
+ answerText = "Opened the context packets in your private chat.";
794648
+ return;
794649
+ }
794650
+ const panelChatId = state5.panelChatId;
794651
+ const panelMessageId = state5.panelMessageId;
794652
+ if (state5.viewerUserId !== callback.fromUserId || panelChatId === void 0 || panelMessageId === void 0 || callback.chatId !== panelChatId || callback.messageId !== panelMessageId) {
794653
+ answerText = "This private context panel is not bound to this callback.";
794221
794654
  alert = true;
794222
794655
  return;
794223
794656
  }
794224
- state5.messageId = messageId;
794225
794657
  if (action === "noop") return;
794226
- if (action === "reply") {
794227
- await this.editLiveMessage(
794228
- state5.chatId,
794229
- messageId,
794230
- state5.finalHtml,
794231
- this.telegramContextExplorerReplyMarkup(state5.id)
794658
+ if (action === "close") {
794659
+ const closed = await this.editLiveMessage(
794660
+ panelChatId,
794661
+ panelMessageId,
794662
+ "<b>Context panel closed.</b>"
794232
794663
  );
794664
+ if (!closed) {
794665
+ answerText = "Telegram did not close this context panel. Try again.";
794666
+ alert = true;
794667
+ return;
794668
+ }
794669
+ state5.panelMessageId = void 0;
794670
+ state5.panelChatId = void 0;
794671
+ state5.viewerUserId = void 0;
794233
794672
  return;
794234
794673
  }
794235
- if (action !== "open" && action !== "page") {
794674
+ if (action !== "page") {
794236
794675
  answerText = "Unknown context frame action.";
794237
794676
  alert = true;
794238
794677
  return;
794239
794678
  }
794240
794679
  const maxPage = Math.max(0, state5.pages.length - 1);
794241
- state5.activePage = Number.isFinite(requestedPage) ? Math.min(maxPage, Math.max(0, requestedPage)) : 0;
794242
- await this.editLiveMessage(
794243
- state5.chatId,
794244
- messageId,
794245
- this.renderTelegramContextExplorerPage(state5),
794246
- this.telegramContextExplorerPageMarkup(state5)
794680
+ const nextPage = Number.isFinite(requestedPage) ? Math.min(maxPage, Math.max(0, requestedPage)) : 0;
794681
+ const previousPage = state5.activePage;
794682
+ state5.activePage = nextPage;
794683
+ const payload = this.renderTelegramContextExplorerPage(state5);
794684
+ const edited = await this.editLiveMessage(
794685
+ panelChatId,
794686
+ panelMessageId,
794687
+ payload.text,
794688
+ this.telegramContextExplorerPageMarkup(state5),
794689
+ payload.rich_html
794247
794690
  );
794691
+ if (!edited) {
794692
+ state5.activePage = previousPage;
794693
+ answerText = "Telegram did not apply this context page. Try again.";
794694
+ alert = true;
794695
+ }
794248
794696
  } catch (err) {
794249
794697
  answerText = err instanceof Error ? err.message : String(err);
794250
794698
  alert = true;
@@ -795005,14 +795453,12 @@ Join: ${newUrl}`
795005
795453
  }
795006
795454
  const deliveredFinalText = finalText;
795007
795455
  const adminEvidenceText = isAdminDM ? this.telegramAdminCompletionRunText(subAgent, finalText) : "";
795008
- const finalHtml = composeTelegramReplyWithSteeringHTML(
795009
- deliveredFinalText,
795010
- [...subAgent.steeringReconciliations.values()]
795011
- );
795456
+ const finalHtml = isAdminDM ? composeTelegramReplyWithSteeringHTML(deliveredFinalText, [
795457
+ ...subAgent.steeringReconciliations.values()
795458
+ ]) : convertMarkdownToTelegramHTML(deliveredFinalText);
795012
795459
  const contextExplorerState = !isAdminDM && msg.chatType !== "private" && !msg.guestQueryId ? this.buildTelegramContextExplorerState(
795013
795460
  msg,
795014
795461
  subAgent,
795015
- finalHtml,
795016
795462
  deliveredFinalText
795017
795463
  ) : null;
795018
795464
  const contextExplorerReplyMarkup = contextExplorerState ? this.telegramContextExplorerReplyMarkup(contextExplorerState.id) : void 0;
@@ -795030,7 +795476,7 @@ Join: ${newUrl}`
795030
795476
  );
795031
795477
  if (contextExplorerState && sentMessageId !== null) {
795032
795478
  this.pruneTelegramContextExplorers();
795033
- contextExplorerState.messageId = sentMessageId;
795479
+ contextExplorerState.sourceMessageId = sentMessageId;
795034
795480
  this.telegramContextExplorerStates.set(
795035
795481
  contextExplorerState.id,
795036
795482
  contextExplorerState
@@ -796086,8 +796532,7 @@ ${creativeWorkspace}` : ""
796086
796532
  }
796087
796533
  const html = renderTelegramLiveProgressHTML(
796088
796534
  subAgent.intermediateLines,
796089
- subAgent.visibleReplyText || subAgent.accumulated,
796090
- [...subAgent.steeringReconciliations.values()]
796535
+ subAgent.visibleReplyText || subAgent.accumulated
796091
796536
  );
796092
796537
  if (!html.trim()) return;
796093
796538
  const now2 = Date.now();
@@ -799922,8 +800367,14 @@ ${this.quoteTelegramContextBlock(msg.text, 800)}`,
799922
800367
  return;
799923
800368
  }
799924
800369
  state5.messageId = messageId;
799925
- await this.renderTelegramAdminLivePanel(state5);
799926
- answerText2 = "";
800370
+ const delivered = await this.renderTelegramAdminLivePanel(state5);
800371
+ if (!delivered) {
800372
+ state5.dirtyPages[state5.activePage] = true;
800373
+ answerText2 = "Telegram did not apply this panel update. Try again.";
800374
+ alert2 = true;
800375
+ } else {
800376
+ answerText2 = "";
800377
+ }
799927
800378
  } catch (err) {
799928
800379
  answerText2 = err instanceof Error ? err.message : String(err);
799929
800380
  alert2 = true;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.663",
3
+ "version": "1.0.664",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "omnius",
9
- "version": "1.0.663",
9
+ "version": "1.0.664",
10
10
  "bundleDependencies": [
11
11
  "image-to-ascii"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.663",
3
+ "version": "1.0.664",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/library.js",