omnius 1.0.662 → 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 +908 -224
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -663599,6 +663599,7 @@ ${notice}`;
|
|
|
663599
663599
|
}
|
|
663600
663600
|
_emitSteeringLifecycle(record, reason) {
|
|
663601
663601
|
const receipt2 = this._steeringReceipt(record);
|
|
663602
|
+
const reconciliation = record.state === "reconciled" && this._activeSteering?.input.inputId === record.inputId ? this._activeSteering.reconciliation : void 0;
|
|
663602
663603
|
this.emit({
|
|
663603
663604
|
type: "status",
|
|
663604
663605
|
content: `Steering ${record.inputId} ${record.state}: ${reason}`,
|
|
@@ -663613,6 +663614,7 @@ ${notice}`;
|
|
|
663613
663614
|
state: record.state,
|
|
663614
663615
|
taskEpoch: record.taskEpoch,
|
|
663615
663616
|
summary: reason,
|
|
663617
|
+
...reconciliation ? { reconciliation: { ...reconciliation } } : {},
|
|
663616
663618
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
663617
663619
|
});
|
|
663618
663620
|
appendSteeringLedgerEntry(this._workingDirectory || process.cwd(), {
|
|
@@ -663969,43 +663971,55 @@ ${notice}`;
|
|
|
663969
663971
|
const active = this._activeSteering;
|
|
663970
663972
|
if (!active || !active.requiresReconciliation || !content)
|
|
663971
663973
|
return false;
|
|
663972
|
-
const
|
|
663973
|
-
|
|
663974
|
-
|
|
663975
|
-
|
|
663976
|
-
|
|
663974
|
+
const marker = /\[STEERING_RECONCILIATION(?:\]|(?=[\s{]))/gi;
|
|
663975
|
+
const matches = [...content.matchAll(marker)];
|
|
663976
|
+
let selected = null;
|
|
663977
|
+
for (let index = 0; index < matches.length; index++) {
|
|
663978
|
+
const current = matches[index];
|
|
663979
|
+
const start2 = (current.index ?? 0) + current[0].length;
|
|
663980
|
+
const end = matches[index + 1]?.index ?? content.length;
|
|
663981
|
+
const candidate = this._firstJsonObject(content.slice(start2, end));
|
|
663982
|
+
if (!candidate)
|
|
663983
|
+
continue;
|
|
663984
|
+
try {
|
|
663985
|
+
const parsed = JSON.parse(candidate);
|
|
663986
|
+
const status = parsed["status"];
|
|
663987
|
+
const inputId = parsed["inputId"];
|
|
663988
|
+
if (inputId !== active.input.inputId || status !== "applied" && status !== "not_applicable" && status !== "needs_clarification") {
|
|
663989
|
+
continue;
|
|
663990
|
+
}
|
|
663991
|
+
const changedConstraints = Array.isArray(parsed["changedConstraints"]) ? parsed["changedConstraints"].filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean).slice(0, 12) : [];
|
|
663992
|
+
const revisedNextAction = typeof parsed["revisedNextAction"] === "string" ? parsed["revisedNextAction"].trim().slice(0, 1e3) : "";
|
|
663993
|
+
if (!revisedNextAction)
|
|
663994
|
+
continue;
|
|
663995
|
+
selected = {
|
|
663996
|
+
inputId: active.input.inputId,
|
|
663997
|
+
status,
|
|
663998
|
+
changedConstraints,
|
|
663999
|
+
revisedNextAction
|
|
664000
|
+
};
|
|
664001
|
+
} catch {
|
|
664002
|
+
continue;
|
|
664003
|
+
}
|
|
664004
|
+
}
|
|
664005
|
+
if (!selected)
|
|
663977
664006
|
return false;
|
|
663978
664007
|
try {
|
|
663979
|
-
|
|
663980
|
-
const status = parsed["status"];
|
|
663981
|
-
const inputId = parsed["inputId"];
|
|
663982
|
-
if (inputId !== active.input.inputId || status !== "applied" && status !== "not_applicable" && status !== "needs_clarification") {
|
|
663983
|
-
return false;
|
|
663984
|
-
}
|
|
663985
|
-
const changedConstraints = Array.isArray(parsed["changedConstraints"]) ? parsed["changedConstraints"].filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean).slice(0, 12) : [];
|
|
663986
|
-
const revisedNextAction = typeof parsed["revisedNextAction"] === "string" ? parsed["revisedNextAction"].trim().slice(0, 1e3) : "";
|
|
663987
|
-
if (!revisedNextAction)
|
|
663988
|
-
return false;
|
|
663989
|
-
active.reconciliation = {
|
|
663990
|
-
inputId: active.input.inputId,
|
|
663991
|
-
status,
|
|
663992
|
-
changedConstraints,
|
|
663993
|
-
revisedNextAction
|
|
663994
|
-
};
|
|
664008
|
+
active.reconciliation = selected;
|
|
663995
664009
|
active.reconciledTurn = turn;
|
|
663996
|
-
active.requiresReconciliation = status === "needs_clarification";
|
|
663997
|
-
active.gatesOldPlan = status === "needs_clarification";
|
|
663998
|
-
this._taskState.nextAction = revisedNextAction;
|
|
663999
|
-
if (changedConstraints.length > 0) {
|
|
664010
|
+
active.requiresReconciliation = selected.status === "needs_clarification";
|
|
664011
|
+
active.gatesOldPlan = selected.status === "needs_clarification";
|
|
664012
|
+
this._taskState.nextAction = selected.revisedNextAction;
|
|
664013
|
+
if (selected.changedConstraints.length > 0) {
|
|
664000
664014
|
this._taskState.steeringConstraints = [
|
|
664001
664015
|
.../* @__PURE__ */ new Set([
|
|
664002
664016
|
...this._taskState.steeringConstraints ?? [],
|
|
664003
|
-
...changedConstraints
|
|
664017
|
+
...selected.changedConstraints
|
|
664004
664018
|
])
|
|
664005
664019
|
].slice(-20);
|
|
664006
664020
|
}
|
|
664007
664021
|
active.input.state = "reconciled";
|
|
664008
|
-
this._emitSteeringLifecycle(active.input, `reconciled by model at turn ${turn}: ${status}`);
|
|
664022
|
+
this._emitSteeringLifecycle(active.input, `reconciled by model at turn ${turn}: ${selected.status}`);
|
|
664009
664023
|
return true;
|
|
664010
664024
|
} catch {
|
|
664011
664025
|
return false;
|
|
@@ -700714,50 +700728,181 @@ var init_conversation_context = __esm({
|
|
|
700714
700728
|
});
|
|
700715
700729
|
|
|
700716
700730
|
// packages/cli/src/tui/steering-stream-filter.ts
|
|
700717
|
-
|
|
700731
|
+
function firstBalancedJsonObject(text3) {
|
|
700732
|
+
const start2 = text3.indexOf("{");
|
|
700733
|
+
if (start2 < 0) return null;
|
|
700734
|
+
let depth = 0;
|
|
700735
|
+
let quoted = false;
|
|
700736
|
+
let escaped = false;
|
|
700737
|
+
for (let index = start2; index < text3.length; index++) {
|
|
700738
|
+
const char = text3[index];
|
|
700739
|
+
if (quoted) {
|
|
700740
|
+
if (escaped) escaped = false;
|
|
700741
|
+
else if (char === "\\") escaped = true;
|
|
700742
|
+
else if (char === '"') quoted = false;
|
|
700743
|
+
continue;
|
|
700744
|
+
}
|
|
700745
|
+
if (char === '"') quoted = true;
|
|
700746
|
+
else if (char === "{") depth++;
|
|
700747
|
+
else if (char === "}") {
|
|
700748
|
+
depth--;
|
|
700749
|
+
if (depth === 0) return { start: start2, end: index + 1 };
|
|
700750
|
+
}
|
|
700751
|
+
}
|
|
700752
|
+
return null;
|
|
700753
|
+
}
|
|
700754
|
+
function parseReconciliation(jsonText) {
|
|
700755
|
+
try {
|
|
700756
|
+
const parsed = JSON.parse(jsonText);
|
|
700757
|
+
const status = parsed["status"];
|
|
700758
|
+
if (status !== "applied" && status !== "not_applicable" && status !== "needs_clarification") {
|
|
700759
|
+
return null;
|
|
700760
|
+
}
|
|
700761
|
+
const revisedNextAction = typeof parsed["revisedNextAction"] === "string" ? parsed["revisedNextAction"].trim().slice(0, 2e3) : "";
|
|
700762
|
+
if (!revisedNextAction) return null;
|
|
700763
|
+
const inputId = typeof parsed["inputId"] === "string" ? parsed["inputId"].trim().slice(0, 500) : "";
|
|
700764
|
+
const changedConstraints = Array.isArray(parsed["changedConstraints"]) ? parsed["changedConstraints"].filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean).slice(0, 24) : [];
|
|
700765
|
+
return {
|
|
700766
|
+
...inputId ? { inputId } : {},
|
|
700767
|
+
status,
|
|
700768
|
+
changedConstraints,
|
|
700769
|
+
revisedNextAction
|
|
700770
|
+
};
|
|
700771
|
+
} catch {
|
|
700772
|
+
return null;
|
|
700773
|
+
}
|
|
700774
|
+
}
|
|
700775
|
+
function suffixMatchingMarkerPrefix(text3, marker) {
|
|
700776
|
+
const upper = text3.toUpperCase();
|
|
700777
|
+
for (let length4 = Math.min(upper.length, marker.length - 1); length4 > 0; length4--) {
|
|
700778
|
+
if (marker.startsWith(upper.slice(-length4))) return length4;
|
|
700779
|
+
}
|
|
700780
|
+
return 0;
|
|
700781
|
+
}
|
|
700782
|
+
function stripSteeringReconciliationEnvelopes(text3, onReconciliation) {
|
|
700783
|
+
if (!text3) return "";
|
|
700784
|
+
const filter2 = new SteeringReconciliationStreamFilter({ onReconciliation });
|
|
700785
|
+
return `${filter2.consume(text3)}${filter2.flush()}`;
|
|
700786
|
+
}
|
|
700787
|
+
var OPEN_STEM, CLOSE_STEM, SteeringReconciliationStreamFilter;
|
|
700718
700788
|
var init_steering_stream_filter = __esm({
|
|
700719
700789
|
"packages/cli/src/tui/steering-stream-filter.ts"() {
|
|
700720
|
-
|
|
700721
|
-
|
|
700790
|
+
OPEN_STEM = "[STEERING_RECONCILIATION";
|
|
700791
|
+
CLOSE_STEM = "[/STEERING_RECONCILIATION";
|
|
700722
700792
|
SteeringReconciliationStreamFilter = class {
|
|
700723
700793
|
constructor(options2 = {}) {
|
|
700724
700794
|
this.options = options2;
|
|
700725
700795
|
}
|
|
700726
700796
|
options;
|
|
700727
|
-
mode = "
|
|
700797
|
+
mode = "scan";
|
|
700728
700798
|
buffer = "";
|
|
700799
|
+
hasVisibleContent = false;
|
|
700800
|
+
separatorAfterEnvelope = false;
|
|
700729
700801
|
reset() {
|
|
700730
|
-
this.mode = "
|
|
700802
|
+
this.mode = "scan";
|
|
700731
700803
|
this.buffer = "";
|
|
700804
|
+
this.hasVisibleContent = false;
|
|
700805
|
+
this.separatorAfterEnvelope = false;
|
|
700732
700806
|
}
|
|
700733
700807
|
consume(chunk) {
|
|
700734
|
-
if (
|
|
700735
|
-
|
|
700736
|
-
|
|
700737
|
-
|
|
700738
|
-
|
|
700739
|
-
|
|
700740
|
-
if (!
|
|
700741
|
-
|
|
700808
|
+
if (chunk) this.buffer += chunk;
|
|
700809
|
+
return this.drain(false);
|
|
700810
|
+
}
|
|
700811
|
+
drain(final2) {
|
|
700812
|
+
let visible = "";
|
|
700813
|
+
const appendVisible = (text3) => {
|
|
700814
|
+
if (!text3) return;
|
|
700815
|
+
if (this.separatorAfterEnvelope) {
|
|
700816
|
+
if (!/^\s/.test(text3)) visible += " ";
|
|
700817
|
+
this.separatorAfterEnvelope = false;
|
|
700818
|
+
}
|
|
700819
|
+
visible += text3;
|
|
700820
|
+
if (text3.trim()) this.hasVisibleContent = true;
|
|
700821
|
+
};
|
|
700822
|
+
while (this.buffer) {
|
|
700823
|
+
if (this.mode === "discard") {
|
|
700742
700824
|
this.buffer = "";
|
|
700743
|
-
|
|
700744
|
-
return visible2;
|
|
700825
|
+
break;
|
|
700745
700826
|
}
|
|
700746
|
-
this.mode
|
|
700827
|
+
if (this.mode === "scan") {
|
|
700828
|
+
const upper2 = this.buffer.toUpperCase();
|
|
700829
|
+
let openAt = -1;
|
|
700830
|
+
let pendingOpenAt = -1;
|
|
700831
|
+
let searchAt = 0;
|
|
700832
|
+
while (searchAt < upper2.length) {
|
|
700833
|
+
const candidateAt = upper2.indexOf(OPEN_STEM, searchAt);
|
|
700834
|
+
if (candidateAt < 0) break;
|
|
700835
|
+
const after = upper2[candidateAt + OPEN_STEM.length];
|
|
700836
|
+
if (after === void 0 && !final2) {
|
|
700837
|
+
pendingOpenAt = candidateAt;
|
|
700838
|
+
break;
|
|
700839
|
+
}
|
|
700840
|
+
if (after === void 0 || after === "]" || after === "{" || /\s/.test(after)) {
|
|
700841
|
+
openAt = candidateAt;
|
|
700842
|
+
break;
|
|
700843
|
+
}
|
|
700844
|
+
searchAt = candidateAt + OPEN_STEM.length;
|
|
700845
|
+
}
|
|
700846
|
+
if (openAt >= 0) {
|
|
700847
|
+
const prefix = this.buffer.slice(0, openAt);
|
|
700848
|
+
if (prefix.trim()) appendVisible(prefix);
|
|
700849
|
+
this.separatorAfterEnvelope = this.hasVisibleContent;
|
|
700850
|
+
this.buffer = this.buffer.slice(openAt + OPEN_STEM.length);
|
|
700851
|
+
if (this.buffer.startsWith("]")) this.buffer = this.buffer.slice(1);
|
|
700852
|
+
this.mode = "capture";
|
|
700853
|
+
continue;
|
|
700854
|
+
}
|
|
700855
|
+
if (pendingOpenAt >= 0) {
|
|
700856
|
+
const prefix = this.buffer.slice(0, pendingOpenAt);
|
|
700857
|
+
if (prefix.trim()) appendVisible(prefix);
|
|
700858
|
+
this.separatorAfterEnvelope = this.hasVisibleContent;
|
|
700859
|
+
this.buffer = this.buffer.slice(pendingOpenAt);
|
|
700860
|
+
break;
|
|
700861
|
+
}
|
|
700862
|
+
const retained = final2 ? 0 : suffixMatchingMarkerPrefix(this.buffer, OPEN_STEM);
|
|
700863
|
+
if (retained > 0) {
|
|
700864
|
+
const prefix = this.buffer.slice(0, -retained);
|
|
700865
|
+
if (prefix.trim()) appendVisible(prefix);
|
|
700866
|
+
this.buffer = this.buffer.slice(-retained);
|
|
700867
|
+
} else {
|
|
700868
|
+
if (!(final2 && OPEN_STEM.startsWith(upper2))) {
|
|
700869
|
+
appendVisible(this.buffer);
|
|
700870
|
+
}
|
|
700871
|
+
this.buffer = "";
|
|
700872
|
+
}
|
|
700873
|
+
break;
|
|
700874
|
+
}
|
|
700875
|
+
if (this.mode === "capture") {
|
|
700876
|
+
const span = firstBalancedJsonObject(this.buffer);
|
|
700877
|
+
if (!span) {
|
|
700878
|
+
if (final2) this.buffer = "";
|
|
700879
|
+
break;
|
|
700880
|
+
}
|
|
700881
|
+
const parsed = parseReconciliation(
|
|
700882
|
+
this.buffer.slice(span.start, span.end)
|
|
700883
|
+
);
|
|
700884
|
+
if (parsed) this.options.onReconciliation?.(parsed);
|
|
700885
|
+
this.buffer = this.buffer.slice(span.end);
|
|
700886
|
+
this.mode = "after-json";
|
|
700887
|
+
continue;
|
|
700888
|
+
}
|
|
700889
|
+
const whitespace = this.buffer.match(/^\s*/)?.[0].length ?? 0;
|
|
700890
|
+
if (whitespace > 0) this.buffer = this.buffer.slice(whitespace);
|
|
700891
|
+
if (!this.buffer) break;
|
|
700892
|
+
const upper = this.buffer.toUpperCase();
|
|
700893
|
+
if (upper.startsWith(CLOSE_STEM)) {
|
|
700894
|
+
this.buffer = this.buffer.slice(CLOSE_STEM.length);
|
|
700895
|
+
if (this.buffer.startsWith("]")) this.buffer = this.buffer.slice(1);
|
|
700896
|
+
this.mode = this.options.suppressTrailingContent ? "discard" : "scan";
|
|
700897
|
+
continue;
|
|
700898
|
+
}
|
|
700899
|
+
if (!final2 && CLOSE_STEM.startsWith(upper)) break;
|
|
700900
|
+
this.mode = this.options.suppressTrailingContent ? "discard" : "scan";
|
|
700747
700901
|
}
|
|
700748
|
-
const closeAt = this.buffer.indexOf(CLOSE_MARKER);
|
|
700749
|
-
if (closeAt < 0) return "";
|
|
700750
|
-
const visible = this.options.suppressTrailingContent ? "" : this.buffer.slice(closeAt + CLOSE_MARKER.length);
|
|
700751
|
-
this.buffer = "";
|
|
700752
|
-
this.mode = this.options.suppressTrailingContent ? "suppress" : "show";
|
|
700753
700902
|
return visible;
|
|
700754
700903
|
}
|
|
700755
700904
|
flush() {
|
|
700756
|
-
|
|
700757
|
-
this.reset();
|
|
700758
|
-
return "";
|
|
700759
|
-
}
|
|
700760
|
-
const visible = this.buffer;
|
|
700905
|
+
const visible = this.drain(true);
|
|
700761
700906
|
this.reset();
|
|
700762
700907
|
return visible;
|
|
700763
700908
|
}
|
|
@@ -773479,6 +773624,157 @@ function codeBlock(code8, language = "") {
|
|
|
773479
773624
|
const inner = escapeHtml2(String(code8 ?? "").replace(/\s+$/, ""));
|
|
773480
773625
|
return language ? `<pre><code class="language-${escapeHtml2(language)}">${inner}</code></pre>` : `<pre>${inner}</pre>`;
|
|
773481
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(/"/g, '"').replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/\n[ \t]+/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
773777
|
+
}
|
|
773482
773778
|
function safeJson(v, pretty) {
|
|
773483
773779
|
try {
|
|
773484
773780
|
return pretty ? JSON.stringify(v, null, 2) : JSON.stringify(v);
|
|
@@ -773492,11 +773788,14 @@ function tokenizeTelegramHtml(html) {
|
|
|
773492
773788
|
let last2 = 0;
|
|
773493
773789
|
let m2;
|
|
773494
773790
|
while ((m2 = re.exec(html)) !== null) {
|
|
773495
|
-
if (m2.index > last2)
|
|
773791
|
+
if (m2.index > last2)
|
|
773792
|
+
tokens3.push({ type: "text", raw: html.slice(last2, m2.index) });
|
|
773496
773793
|
const closing = m2[1] === "/";
|
|
773497
773794
|
const tag = (m2[2] || "").toLowerCase();
|
|
773498
773795
|
if (SPAN_TAGS.has(tag)) {
|
|
773499
|
-
tokens3.push(
|
|
773796
|
+
tokens3.push(
|
|
773797
|
+
closing ? { type: "close", tag, raw: m2[0] } : { type: "open", tag, raw: m2[0] }
|
|
773798
|
+
);
|
|
773500
773799
|
} else {
|
|
773501
773800
|
tokens3.push({ type: "text", raw: m2[0] });
|
|
773502
773801
|
}
|
|
@@ -781653,6 +781952,44 @@ function convertMarkdownToTelegramHTML(md) {
|
|
|
781653
781952
|
function escapeTelegramHTML(text3) {
|
|
781654
781953
|
return text3.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
781655
781954
|
}
|
|
781955
|
+
function upsertTelegramSteeringReconciliation(target, value2) {
|
|
781956
|
+
const key = value2.inputId.trim();
|
|
781957
|
+
if (!key) return;
|
|
781958
|
+
target.delete(key);
|
|
781959
|
+
target.set(key, {
|
|
781960
|
+
inputId: key.slice(0, 500),
|
|
781961
|
+
status: value2.status,
|
|
781962
|
+
changedConstraints: value2.changedConstraints.map((item) => item.trim()).filter(Boolean).slice(0, 12),
|
|
781963
|
+
revisedNextAction: value2.revisedNextAction.trim().slice(0, 1e3)
|
|
781964
|
+
});
|
|
781965
|
+
while (target.size > 12) {
|
|
781966
|
+
const oldest = target.keys().next().value;
|
|
781967
|
+
if (!oldest) break;
|
|
781968
|
+
target.delete(oldest);
|
|
781969
|
+
}
|
|
781970
|
+
}
|
|
781971
|
+
function formatTelegramSteeringReconciliationHTML(values) {
|
|
781972
|
+
if (values.length === 0) return "";
|
|
781973
|
+
const sections = values.slice(-4).map((value2) => {
|
|
781974
|
+
const status = value2.status.replaceAll("_", " ");
|
|
781975
|
+
const constraints = value2.changedConstraints.length ? ["Changes:", ...value2.changedConstraints.map((item) => `• ${item}`)] : ["Changes: none"];
|
|
781976
|
+
return [
|
|
781977
|
+
`Status: ${status}`,
|
|
781978
|
+
...constraints,
|
|
781979
|
+
`Next: ${value2.revisedNextAction}`
|
|
781980
|
+
].join("\n");
|
|
781981
|
+
});
|
|
781982
|
+
return [
|
|
781983
|
+
"<b>Plan update</b>",
|
|
781984
|
+
`<blockquote expandable>${escapeTelegramHTML(sections.join("\n\n"))}</blockquote>`
|
|
781985
|
+
].join("\n");
|
|
781986
|
+
}
|
|
781987
|
+
function composeTelegramReplyWithSteeringHTML(replyText, reconciliations) {
|
|
781988
|
+
return [
|
|
781989
|
+
formatTelegramSteeringReconciliationHTML(reconciliations),
|
|
781990
|
+
replyText.trim() ? convertMarkdownToTelegramHTML(replyText) : ""
|
|
781991
|
+
].filter(Boolean).join("\n\n");
|
|
781992
|
+
}
|
|
781656
781993
|
function normalizeTelegramOutboundLinks(text3) {
|
|
781657
781994
|
if (!text3) return text3;
|
|
781658
781995
|
return text3.replace(
|
|
@@ -781763,7 +782100,7 @@ function isTelegramNoReplySentinel(text3) {
|
|
|
781763
782100
|
}
|
|
781764
782101
|
function telegramTextHasRunnerControlMarker(text3) {
|
|
781765
782102
|
const upper = text3.toUpperCase();
|
|
781766
|
-
return TELEGRAM_RUNNER_CONTROL_OPEN_MARKERS.some(
|
|
782103
|
+
return /\[\/?STEERING_RECONCILIATION(?:\]|(?=[\s{\[]))/i.test(text3) || TELEGRAM_RUNNER_CONTROL_OPEN_MARKERS.some(
|
|
781767
782104
|
(marker) => upper.includes(marker)
|
|
781768
782105
|
) || TELEGRAM_RUNNER_CONTROL_CLOSE_MARKERS.some(
|
|
781769
782106
|
(marker) => upper.includes(marker)
|
|
@@ -781771,35 +782108,32 @@ function telegramTextHasRunnerControlMarker(text3) {
|
|
|
781771
782108
|
}
|
|
781772
782109
|
function sanitizeTelegramModelFacingContext(text3) {
|
|
781773
782110
|
if (!text3) return "";
|
|
782111
|
+
const structurallySanitized = stripSteeringReconciliationEnvelopes(text3);
|
|
781774
782112
|
const kept = [];
|
|
781775
782113
|
let insideControlEnvelope = false;
|
|
781776
|
-
let
|
|
781777
|
-
for (const line of
|
|
782114
|
+
let oneLineControlRemainder = 0;
|
|
782115
|
+
for (const line of structurallySanitized.split(/\r?\n/)) {
|
|
781778
782116
|
const upper = line.toUpperCase();
|
|
781779
|
-
|
|
781780
|
-
|
|
781781
|
-
);
|
|
781782
|
-
const hasClose = TELEGRAM_RUNNER_CONTROL_CLOSE_MARKERS.some(
|
|
781783
|
-
(marker) => upper.includes(marker)
|
|
781784
|
-
);
|
|
781785
|
-
if (insideControlEnvelope) {
|
|
781786
|
-
if (hasClose) {
|
|
781787
|
-
insideControlEnvelope = false;
|
|
781788
|
-
quarantineTrailingRationale = true;
|
|
781789
|
-
}
|
|
782117
|
+
if (oneLineControlRemainder > 0) {
|
|
782118
|
+
oneLineControlRemainder--;
|
|
781790
782119
|
continue;
|
|
781791
782120
|
}
|
|
781792
|
-
|
|
781793
|
-
|
|
781794
|
-
|
|
781795
|
-
|
|
781796
|
-
|
|
781797
|
-
}
|
|
782121
|
+
const hasOpen = upper.includes("[ACTIVE USER STEERING]");
|
|
782122
|
+
const hasClose = upper.includes("[/ACTIVE USER STEERING]");
|
|
782123
|
+
if (insideControlEnvelope) {
|
|
782124
|
+
if (hasClose) insideControlEnvelope = false;
|
|
782125
|
+
continue;
|
|
781798
782126
|
}
|
|
781799
782127
|
if (hasOpen) {
|
|
781800
782128
|
if (!hasClose) insideControlEnvelope = true;
|
|
781801
782129
|
continue;
|
|
781802
782130
|
}
|
|
782131
|
+
if (/\[(?:STEERING_RECONCILIATION_REQUIRED|STEERING_REPLAN_TURN_REQUIRED|STEERING_CLARIFICATION_REQUIRED)\]/i.test(
|
|
782132
|
+
line
|
|
782133
|
+
)) {
|
|
782134
|
+
oneLineControlRemainder = 2;
|
|
782135
|
+
continue;
|
|
782136
|
+
}
|
|
781803
782137
|
if (/["']revisedNextAction["']\s*:/i.test(line) && /["'](?:inputId|status|changedConstraints)["']\s*:/i.test(line)) {
|
|
781804
782138
|
continue;
|
|
781805
782139
|
}
|
|
@@ -781839,6 +782173,7 @@ function isTelegramInternalStatusText(text3) {
|
|
|
781839
782173
|
))
|
|
781840
782174
|
return true;
|
|
781841
782175
|
if (/^no further action needed\b/i.test(compact6)) return true;
|
|
782176
|
+
if (/^no visible reply (?:is|was) warranted\.?$/i.test(compact6)) return true;
|
|
781842
782177
|
if (/^no action needed\b.{0,120}\b(task|complete|completed|done)\b/i.test(
|
|
781843
782178
|
compact6
|
|
781844
782179
|
))
|
|
@@ -781880,7 +782215,7 @@ function stripTelegramStuckSelfTalk(text3) {
|
|
|
781880
782215
|
}
|
|
781881
782216
|
function cleanTelegramVisibleReply(text3, options2 = {}) {
|
|
781882
782217
|
const clean7 = normalizeTelegramOutboundLinks(
|
|
781883
|
-
stripTelegramHiddenThinking(text3)
|
|
782218
|
+
stripSteeringReconciliationEnvelopes(stripTelegramHiddenThinking(text3))
|
|
781884
782219
|
).trim();
|
|
781885
782220
|
if (!clean7) return "";
|
|
781886
782221
|
if (options2.suppressPotentialNoReplyPrefix && isTelegramPotentialNoReplyPrefix(clean7))
|
|
@@ -782190,15 +782525,19 @@ function formatTelegramProgressEvent(event) {
|
|
|
782190
782525
|
}
|
|
782191
782526
|
return null;
|
|
782192
782527
|
}
|
|
782193
|
-
function renderTelegramLiveProgressHTML(progressLines, accumulated) {
|
|
782528
|
+
function renderTelegramLiveProgressHTML(progressLines, accumulated, steeringReconciliations = []) {
|
|
782529
|
+
const steeringHtml = formatTelegramSteeringReconciliationHTML(
|
|
782530
|
+
steeringReconciliations
|
|
782531
|
+
);
|
|
782194
782532
|
const draft = cleanTelegramVisibleReply(accumulated, {
|
|
782195
782533
|
suppressPotentialNoReplyPrefix: true
|
|
782196
782534
|
});
|
|
782197
782535
|
if (draft) {
|
|
782198
782536
|
const clipped = draft.length > 2e3 ? `${draft.slice(0, 1997).trimEnd()}...` : draft;
|
|
782199
|
-
return convertMarkdownToTelegramHTML(clipped);
|
|
782537
|
+
return [steeringHtml, convertMarkdownToTelegramHTML(clipped)].filter(Boolean).join("\n\n");
|
|
782200
782538
|
}
|
|
782201
|
-
|
|
782539
|
+
const progress = progressLines.slice(-6).map((line) => line.trim()).filter((line) => !isTelegramInternalStatusText(line)).filter(Boolean).join("\n");
|
|
782540
|
+
return [steeringHtml, progress].filter(Boolean).join("\n\n");
|
|
782202
782541
|
}
|
|
782203
782542
|
function telegramAdminLivePanelPageLabel(page2) {
|
|
782204
782543
|
if (page2 === "response") return "Reply";
|
|
@@ -782207,11 +782546,78 @@ function telegramAdminLivePanelPageLabel(page2) {
|
|
|
782207
782546
|
if (page2 === "evidence") return "Evidence";
|
|
782208
782547
|
return "Context";
|
|
782209
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
|
+
}
|
|
782210
782613
|
function trimTelegramAdminPanelLines(lines, max = 80) {
|
|
782211
782614
|
if (lines.length > max) lines.splice(0, lines.length - max);
|
|
782212
782615
|
}
|
|
782213
782616
|
function pushTelegramAdminPanelLine(state5, page2, line) {
|
|
782214
|
-
const clean7 =
|
|
782617
|
+
const clean7 = sanitizeTelegramProgressText(
|
|
782618
|
+
stripTelegramHiddenThinking(line).replace(/\s+/g, " ").trim(),
|
|
782619
|
+
1e3
|
|
782620
|
+
);
|
|
782215
782621
|
if (!clean7) return;
|
|
782216
782622
|
const target = page2 === "tools" ? state5.toolLines : page2 === "logs" ? state5.logLines : state5.mutationLines;
|
|
782217
782623
|
if (target[target.length - 1] !== clean7) target.push(clean7);
|
|
@@ -782220,7 +782626,10 @@ function pushTelegramAdminPanelLine(state5, page2, line) {
|
|
|
782220
782626
|
if (state5.activePage !== page2) state5.dirtyPages[page2] = true;
|
|
782221
782627
|
}
|
|
782222
782628
|
function pushTelegramAdminPanelMutationLine(state5, line) {
|
|
782223
|
-
const clean7 =
|
|
782629
|
+
const clean7 = sanitizeTelegramProgressText(
|
|
782630
|
+
stripTelegramHiddenThinking(line).replace(/\s+/g, " ").trim(),
|
|
782631
|
+
1e3
|
|
782632
|
+
);
|
|
782224
782633
|
if (!clean7) return;
|
|
782225
782634
|
if (state5.mutationLines[state5.mutationLines.length - 1] !== clean7)
|
|
782226
782635
|
state5.mutationLines.push(clean7);
|
|
@@ -782240,6 +782649,37 @@ function telegramAdminLivePanelIntakeText(requestPreview) {
|
|
|
782240
782649
|
void requestPreview;
|
|
782241
782650
|
return "";
|
|
782242
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
|
+
}
|
|
782243
782683
|
function renderTelegramHalftoneProgressBar(elapsedSec, width = 12) {
|
|
782244
782684
|
const safeWidth = Math.max(1, Math.floor(width));
|
|
782245
782685
|
const phase = Math.max(0, elapsedSec) % 60 / 60 * safeWidth;
|
|
@@ -782272,6 +782712,9 @@ function createTelegramAdminLivePanelState(args) {
|
|
|
782272
782712
|
requestPreview,
|
|
782273
782713
|
intakeText: telegramAdminLivePanelIntakeText(requestPreview),
|
|
782274
782714
|
responseText: "",
|
|
782715
|
+
responseSegments: [],
|
|
782716
|
+
responseSegmentSequence: 0,
|
|
782717
|
+
steeringReconciliations: [],
|
|
782275
782718
|
evidenceText: "",
|
|
782276
782719
|
toolLines: [],
|
|
782277
782720
|
mutationLines: [],
|
|
@@ -782281,24 +782724,40 @@ function createTelegramAdminLivePanelState(args) {
|
|
|
782281
782724
|
};
|
|
782282
782725
|
}
|
|
782283
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
|
+
}
|
|
782284
782734
|
if (event.type === "stream_token" && event.streamKind === "content" && event.content) {
|
|
782285
|
-
const
|
|
782286
|
-
|
|
782287
|
-
|
|
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
|
|
782288
782739
|
);
|
|
782289
|
-
|
|
782290
|
-
state5
|
|
782740
|
+
upsertTelegramAdminResponseSegment(
|
|
782741
|
+
state5,
|
|
782742
|
+
key,
|
|
782743
|
+
turn,
|
|
782744
|
+
`${existing?.rawText ?? ""}${event.content}`,
|
|
782745
|
+
false
|
|
782746
|
+
);
|
|
782747
|
+
if (state5.responseText) {
|
|
782291
782748
|
state5.updatedAt = Date.now();
|
|
782292
782749
|
if (state5.activePage !== "response") state5.dirtyPages.response = true;
|
|
782293
782750
|
}
|
|
782294
782751
|
return;
|
|
782295
782752
|
}
|
|
782296
782753
|
if ((event.type === "assistant_text" || event.type === "stream_end") && event.content) {
|
|
782297
|
-
const
|
|
782298
|
-
|
|
782299
|
-
|
|
782300
|
-
if (
|
|
782301
|
-
state5.
|
|
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) {
|
|
782302
782761
|
state5.updatedAt = Date.now();
|
|
782303
782762
|
if (state5.activePage !== "response") state5.dirtyPages.response = true;
|
|
782304
782763
|
}
|
|
@@ -782341,27 +782800,71 @@ function applyTelegramAdminLivePanelEvent(state5, event) {
|
|
|
782341
782800
|
}
|
|
782342
782801
|
}
|
|
782343
782802
|
function renderTelegramAdminLivePanelPayload(state5) {
|
|
782344
|
-
|
|
782345
|
-
|
|
782346
|
-
|
|
782347
|
-
|
|
782348
|
-
].filter(Boolean).join("\n");
|
|
782803
|
+
const metadata = [
|
|
782804
|
+
{ label: "Run status", value: state5.status },
|
|
782805
|
+
...state5.requestPreview ? [{ label: "Request", value: state5.requestPreview }] : []
|
|
782806
|
+
];
|
|
782349
782807
|
let body;
|
|
782808
|
+
let richHtml;
|
|
782350
782809
|
if (state5.activePage === "response") {
|
|
782351
782810
|
const response = state5.responseText.trim();
|
|
782352
782811
|
const clipped = response.length > 2600 ? `${response.slice(0, 2597).trimEnd()}...` : response;
|
|
782353
|
-
|
|
782812
|
+
const steeringHtml = formatTelegramSteeringReconciliationHTML(
|
|
782813
|
+
state5.steeringReconciliations
|
|
782814
|
+
);
|
|
782815
|
+
body = [
|
|
782816
|
+
steeringHtml,
|
|
782817
|
+
clipped ? convertMarkdownToTelegramHTML(clipped) : "<i>Working…</i>"
|
|
782818
|
+
].filter(Boolean).join("\n\n");
|
|
782354
782819
|
} else if (state5.activePage === "tools") {
|
|
782355
782820
|
const lines = state5.toolLines.slice(-12);
|
|
782356
|
-
|
|
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;
|
|
782357
782831
|
} else if (state5.activePage === "logs") {
|
|
782358
|
-
const
|
|
782359
|
-
|
|
782360
|
-
|
|
782361
|
-
|
|
782362
|
-
|
|
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;
|
|
782363
782853
|
} else if (state5.activePage === "evidence") {
|
|
782364
|
-
|
|
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;
|
|
782365
782868
|
} else {
|
|
782366
782869
|
const pageCount = state5.contextPages.length;
|
|
782367
782870
|
const pageIndex = Math.min(
|
|
@@ -782370,36 +782873,20 @@ function renderTelegramAdminLivePanelPayload(state5) {
|
|
|
782370
782873
|
);
|
|
782371
782874
|
state5.contextPageIndex = pageIndex;
|
|
782372
782875
|
const page2 = state5.contextPages[pageIndex];
|
|
782373
|
-
|
|
782374
|
-
|
|
782375
|
-
|
|
782376
|
-
|
|
782377
|
-
|
|
782378
|
-
|
|
782379
|
-
|
|
782380
|
-
|
|
782381
|
-
"",
|
|
782382
|
-
`<i>Context ${pageIndex + 1}/${pageCount}</i>`
|
|
782383
|
-
].filter(Boolean).join("\n");
|
|
782384
|
-
} else {
|
|
782385
|
-
body = "<i>Full context has not been captured yet.</i>";
|
|
782386
|
-
}
|
|
782876
|
+
const rendered = renderTelegramContextExplorerPagePayload(
|
|
782877
|
+
page2,
|
|
782878
|
+
pageIndex,
|
|
782879
|
+
pageCount,
|
|
782880
|
+
"Context"
|
|
782881
|
+
);
|
|
782882
|
+
body = rendered.text;
|
|
782883
|
+
richHtml = rendered.rich_html;
|
|
782387
782884
|
}
|
|
782388
|
-
const
|
|
782389
|
-
header,
|
|
782390
|
-
"",
|
|
782391
|
-
body,
|
|
782392
|
-
"",
|
|
782393
|
-
`<i>Page ${TELEGRAM_ADMIN_LIVE_PANEL_PAGES.indexOf(state5.activePage) + 1}/${TELEGRAM_ADMIN_LIVE_PANEL_PAGES.length}: ${telegramAdminLivePanelPageLabel(state5.activePage)}</i>`
|
|
782394
|
-
].join("\n");
|
|
782395
|
-
const text3 = truncateTelegramUrlSafe(
|
|
782396
|
-
panelText,
|
|
782397
|
-
3900,
|
|
782398
|
-
"\n\n<i>... (panel clipped)</i>"
|
|
782399
|
-
);
|
|
782885
|
+
const text3 = body;
|
|
782400
782886
|
const pageButtons = TELEGRAM_ADMIN_LIVE_PANEL_PAGES.map((page2) => ({
|
|
782401
782887
|
text: `${page2 === state5.activePage ? "●" : "○"} ${telegramAdminLivePanelPageLabel(page2)}${state5.dirtyPages[page2] ? " *" : ""}`,
|
|
782402
|
-
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" } : {}
|
|
782403
782890
|
}));
|
|
782404
782891
|
const keyboard = [
|
|
782405
782892
|
pageButtons.slice(0, 3),
|
|
@@ -782411,19 +782898,28 @@ function renderTelegramAdminLivePanelPayload(state5) {
|
|
|
782411
782898
|
keyboard.push([
|
|
782412
782899
|
{
|
|
782413
782900
|
text: "Prev",
|
|
782414
|
-
|
|
782901
|
+
...pageIndex > 0 ? {
|
|
782902
|
+
callback_data: `omni:v1:tgadmin:${state5.nonce}:ctx:${pageIndex - 1}`
|
|
782903
|
+
} : { disabled: {} }
|
|
782415
782904
|
},
|
|
782416
782905
|
{
|
|
782417
782906
|
text: `${pageIndex + 1}/${lastPage + 1}`,
|
|
782418
|
-
|
|
782907
|
+
disabled: {},
|
|
782908
|
+
style: "primary"
|
|
782419
782909
|
},
|
|
782420
782910
|
{
|
|
782421
782911
|
text: "Next",
|
|
782422
|
-
|
|
782912
|
+
...pageIndex < lastPage ? {
|
|
782913
|
+
callback_data: `omni:v1:tgadmin:${state5.nonce}:ctx:${pageIndex + 1}`
|
|
782914
|
+
} : { disabled: {} }
|
|
782423
782915
|
}
|
|
782424
782916
|
]);
|
|
782425
782917
|
}
|
|
782426
|
-
return {
|
|
782918
|
+
return {
|
|
782919
|
+
text: text3,
|
|
782920
|
+
...richHtml ? { rich_html: richHtml } : {},
|
|
782921
|
+
reply_markup: { inline_keyboard: keyboard }
|
|
782922
|
+
};
|
|
782427
782923
|
}
|
|
782428
782924
|
function splitTelegramReminderDue(raw) {
|
|
782429
782925
|
const text3 = raw.trim().replace(/^set\s+/i, "").trim();
|
|
@@ -793345,10 +793841,14 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
793345
793841
|
* Send a placeholder message that will be progressively edited with
|
|
793346
793842
|
* streamed content. Returns the message_id for subsequent edits.
|
|
793347
793843
|
*/
|
|
793348
|
-
async sendLiveMessage(chatId, initialText, replyToMessageId, replyMarkup) {
|
|
793844
|
+
async sendLiveMessage(chatId, initialText, replyToMessageId, replyMarkup, richHtml) {
|
|
793349
793845
|
const normalizedInitialText = normalizeTelegramOutboundLinks(initialText);
|
|
793846
|
+
const normalizedRichHtml = richHtml ? normalizeTelegramOutboundLinks(richHtml) : "";
|
|
793350
793847
|
try {
|
|
793351
|
-
const body = {
|
|
793848
|
+
const body = normalizedRichHtml ? {
|
|
793849
|
+
chat_id: chatId,
|
|
793850
|
+
rich_message: { html: normalizedRichHtml }
|
|
793851
|
+
} : {
|
|
793352
793852
|
chat_id: chatId,
|
|
793353
793853
|
text: normalizedInitialText,
|
|
793354
793854
|
parse_mode: "HTML"
|
|
@@ -793356,15 +793856,16 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
793356
793856
|
const replyParameters = telegramReplyParameters(replyToMessageId);
|
|
793357
793857
|
if (replyParameters) body["reply_parameters"] = replyParameters;
|
|
793358
793858
|
if (replyMarkup) body["reply_markup"] = replyMarkup;
|
|
793359
|
-
const
|
|
793859
|
+
const method = normalizedRichHtml ? "sendRichMessage" : "sendMessage";
|
|
793860
|
+
const result = await this.apiCall(method, body);
|
|
793360
793861
|
if (result.ok === false) {
|
|
793361
793862
|
throw new Error(
|
|
793362
|
-
String(result.description ||
|
|
793863
|
+
String(result.description || `Telegram ${method} failed`)
|
|
793363
793864
|
);
|
|
793364
793865
|
}
|
|
793365
793866
|
const messageId = result.result?.message_id;
|
|
793366
793867
|
if (!Number.isInteger(messageId)) {
|
|
793367
|
-
throw new Error(
|
|
793868
|
+
throw new Error(`Telegram ${method} returned no valid message_id`);
|
|
793368
793869
|
}
|
|
793369
793870
|
this.state.messagesSent++;
|
|
793370
793871
|
this.updateTelegramTextDeliveryCapability(chatId, {
|
|
@@ -793374,10 +793875,43 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
793374
793875
|
});
|
|
793375
793876
|
return messageId;
|
|
793376
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
|
+
}
|
|
793377
793910
|
try {
|
|
793911
|
+
const readablePlain = telegramHtmlToPlainText(normalizedInitialText);
|
|
793378
793912
|
const body = {
|
|
793379
793913
|
chat_id: chatId,
|
|
793380
|
-
text:
|
|
793914
|
+
text: readablePlain || "No displayable content."
|
|
793381
793915
|
};
|
|
793382
793916
|
const replyParameters = telegramReplyParameters(replyToMessageId);
|
|
793383
793917
|
if (replyParameters) body["reply_parameters"] = replyParameters;
|
|
@@ -793425,19 +793959,18 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
793425
793959
|
* Edit a live message with updated content. Used for progressive streaming.
|
|
793426
793960
|
* Handles rate limits and Telegram's "message is not modified" error silently.
|
|
793427
793961
|
*/
|
|
793428
|
-
async editLiveMessage(chatId, messageId, html, replyMarkup) {
|
|
793962
|
+
async editLiveMessage(chatId, messageId, html, replyMarkup, richHtml) {
|
|
793429
793963
|
const normalizedHtml = normalizeTelegramOutboundLinks(html);
|
|
793430
|
-
const
|
|
793431
|
-
|
|
793432
|
-
|
|
793433
|
-
|
|
793434
|
-
|
|
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;
|
|
793435
793969
|
try {
|
|
793436
793970
|
const result = await this.apiCall("editMessageText", {
|
|
793437
793971
|
chat_id: chatId,
|
|
793438
793972
|
message_id: messageId,
|
|
793439
|
-
text: truncated,
|
|
793440
|
-
parse_mode: "HTML",
|
|
793973
|
+
...normalizedRichHtml ? { rich_message: { html: normalizedRichHtml } } : { text: truncated, parse_mode: "HTML" },
|
|
793441
793974
|
...replyMarkup ? { reply_markup: replyMarkup } : {}
|
|
793442
793975
|
});
|
|
793443
793976
|
if (result.error_code === 400 && result.description?.includes("not modified"))
|
|
@@ -793449,8 +793982,24 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
793449
793982
|
);
|
|
793450
793983
|
return true;
|
|
793451
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
|
+
}
|
|
793452
794001
|
try {
|
|
793453
|
-
const plain = normalizedHtml
|
|
794002
|
+
const plain = telegramHtmlToPlainText(normalizedHtml);
|
|
793454
794003
|
const truncPlain = plain.length > 4e3 ? truncateTelegramUrlSafe(plain, 4e3, "\n\n... (streaming)") : plain;
|
|
793455
794004
|
const result = await this.apiCall("editMessageText", {
|
|
793456
794005
|
chat_id: chatId,
|
|
@@ -793565,24 +794114,32 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
793565
794114
|
async renderTelegramAdminLivePanel(state5, replyToMessageId) {
|
|
793566
794115
|
const payload = renderTelegramAdminLivePanelPayload(state5);
|
|
793567
794116
|
if (state5.messageId !== void 0) {
|
|
793568
|
-
|
|
794117
|
+
const delivered = await this.editLiveMessage(
|
|
793569
794118
|
state5.chatId,
|
|
793570
794119
|
state5.messageId,
|
|
793571
794120
|
payload.text,
|
|
793572
|
-
payload.reply_markup
|
|
794121
|
+
payload.reply_markup,
|
|
794122
|
+
payload.rich_html
|
|
793573
794123
|
);
|
|
794124
|
+
if (delivered) state5.dirtyPages[state5.activePage] = false;
|
|
794125
|
+
return delivered;
|
|
793574
794126
|
}
|
|
793575
794127
|
const messageId = await this.sendLiveMessage(
|
|
793576
794128
|
state5.chatId,
|
|
793577
794129
|
payload.text,
|
|
793578
794130
|
replyToMessageId,
|
|
793579
|
-
payload.reply_markup
|
|
794131
|
+
payload.reply_markup,
|
|
794132
|
+
payload.rich_html
|
|
793580
794133
|
);
|
|
793581
794134
|
state5.messageId = messageId;
|
|
794135
|
+
state5.dirtyPages[state5.activePage] = false;
|
|
793582
794136
|
return true;
|
|
793583
794137
|
}
|
|
793584
794138
|
updateTelegramAdminLivePanelFromEvent(subAgent, msg, event) {
|
|
793585
794139
|
const state5 = this.ensureTelegramAdminLivePanel(subAgent, msg);
|
|
794140
|
+
state5.steeringReconciliations = [
|
|
794141
|
+
...subAgent.steeringReconciliations.values()
|
|
794142
|
+
];
|
|
793586
794143
|
applyTelegramAdminLivePanelEvent(state5, event);
|
|
793587
794144
|
if (event.contextFrame || state5.contextPages.length === 0 && (subAgent.contextFrame || subAgent.promptSnapshot)) {
|
|
793588
794145
|
this.refreshTelegramAdminLivePanelContextPages(state5, subAgent, msg);
|
|
@@ -793606,13 +794163,18 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
793606
794163
|
async finalizeTelegramAdminLivePanel(subAgent, msg, replyText, status = "completed", evidenceText = "") {
|
|
793607
794164
|
const state5 = this.ensureTelegramAdminLivePanel(subAgent, msg);
|
|
793608
794165
|
state5.status = status;
|
|
794166
|
+
state5.steeringReconciliations = [
|
|
794167
|
+
...subAgent.steeringReconciliations.values()
|
|
794168
|
+
];
|
|
793609
794169
|
state5.responseText = replyText || (status === "failed" ? "I couldn't complete that request." : "Done.");
|
|
794170
|
+
state5.responseSegments = [];
|
|
794171
|
+
state5.activeResponseSegmentKey = void 0;
|
|
793610
794172
|
if (evidenceText.trim()) {
|
|
793611
794173
|
state5.evidenceText = evidenceText.trim();
|
|
793612
794174
|
state5.dirtyPages.evidence = true;
|
|
793613
794175
|
}
|
|
793614
|
-
state5.activePage
|
|
793615
|
-
state5.dirtyPages.response =
|
|
794176
|
+
if (state5.activePage === "response") state5.dirtyPages.response = false;
|
|
794177
|
+
else state5.dirtyPages.response = true;
|
|
793616
794178
|
state5.updatedAt = Date.now();
|
|
793617
794179
|
this.refreshTelegramAdminLivePanelContextPages(state5, subAgent, msg);
|
|
793618
794180
|
if (subAgent.liveMessagePromise)
|
|
@@ -793747,6 +794309,7 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
793747
794309
|
[
|
|
793748
794310
|
{
|
|
793749
794311
|
text: "Admin context",
|
|
794312
|
+
style: "primary",
|
|
793750
794313
|
callback_data: this.telegramContextExplorerCallbackData(
|
|
793751
794314
|
id2,
|
|
793752
794315
|
"open",
|
|
@@ -793765,35 +794328,36 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
793765
794328
|
[
|
|
793766
794329
|
{
|
|
793767
794330
|
text: "Prev",
|
|
793768
|
-
|
|
793769
|
-
|
|
793770
|
-
|
|
793771
|
-
|
|
793772
|
-
|
|
794331
|
+
...page2 > 0 ? {
|
|
794332
|
+
callback_data: this.telegramContextExplorerCallbackData(
|
|
794333
|
+
state5.id,
|
|
794334
|
+
"page",
|
|
794335
|
+
page2 - 1
|
|
794336
|
+
)
|
|
794337
|
+
} : { disabled: {} }
|
|
793773
794338
|
},
|
|
793774
794339
|
{
|
|
793775
794340
|
text: `${page2 + 1}/${lastPage + 1}`,
|
|
793776
|
-
|
|
793777
|
-
|
|
793778
|
-
"noop",
|
|
793779
|
-
page2
|
|
793780
|
-
)
|
|
794341
|
+
disabled: {},
|
|
794342
|
+
style: "primary"
|
|
793781
794343
|
},
|
|
793782
794344
|
{
|
|
793783
794345
|
text: "Next",
|
|
793784
|
-
|
|
793785
|
-
|
|
793786
|
-
|
|
793787
|
-
|
|
793788
|
-
|
|
794346
|
+
...page2 < lastPage ? {
|
|
794347
|
+
callback_data: this.telegramContextExplorerCallbackData(
|
|
794348
|
+
state5.id,
|
|
794349
|
+
"page",
|
|
794350
|
+
page2 + 1
|
|
794351
|
+
)
|
|
794352
|
+
} : { disabled: {} }
|
|
793789
794353
|
}
|
|
793790
794354
|
],
|
|
793791
794355
|
[
|
|
793792
794356
|
{
|
|
793793
|
-
text: "
|
|
794357
|
+
text: "Close context",
|
|
793794
794358
|
callback_data: this.telegramContextExplorerCallbackData(
|
|
793795
794359
|
state5.id,
|
|
793796
|
-
"
|
|
794360
|
+
"close",
|
|
793797
794361
|
page2
|
|
793798
794362
|
)
|
|
793799
794363
|
}
|
|
@@ -793804,7 +794368,7 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
793804
794368
|
splitTelegramContextBody(text3, maxLength = 2500) {
|
|
793805
794369
|
const cleaned = stripTelegramHiddenThinking(text3 || "").trim();
|
|
793806
794370
|
if (!cleaned) return [""];
|
|
793807
|
-
return
|
|
794371
|
+
return splitTelegramPlainText(cleaned, maxLength);
|
|
793808
794372
|
}
|
|
793809
794373
|
addTelegramContextExplorerPages(pages, title, source, body, metadata) {
|
|
793810
794374
|
const chunks = this.splitTelegramContextBody(body);
|
|
@@ -793844,7 +794408,7 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
793844
794408
|
"",
|
|
793845
794409
|
"Visible reply preview:",
|
|
793846
794410
|
cleanTelegramVisibleReply(finalText).slice(0, 900) || "(empty)"
|
|
793847
|
-
].
|
|
794411
|
+
].join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
793848
794412
|
pages.push({
|
|
793849
794413
|
title: "Overview",
|
|
793850
794414
|
source: "telegram.final_reply",
|
|
@@ -793855,6 +794419,23 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
793855
794419
|
`chat_id=${String(msg.chatId)}`
|
|
793856
794420
|
]
|
|
793857
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
|
+
}
|
|
793858
794439
|
if (frame2) {
|
|
793859
794440
|
for (const section of frame2.sections) {
|
|
793860
794441
|
this.addTelegramContextExplorerPages(
|
|
@@ -793945,23 +794526,43 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
793945
794526
|
[`count=${prompt.toolNames.length}`]
|
|
793946
794527
|
);
|
|
793947
794528
|
}
|
|
793948
|
-
|
|
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
|
+
];
|
|
793949
794552
|
}
|
|
793950
|
-
buildTelegramContextExplorerState(msg, subAgent,
|
|
794553
|
+
buildTelegramContextExplorerState(msg, subAgent, finalText) {
|
|
793951
794554
|
const pages = this.buildTelegramContextExplorerPages(
|
|
793952
794555
|
msg,
|
|
793953
794556
|
subAgent,
|
|
793954
794557
|
finalText
|
|
793955
794558
|
);
|
|
793956
794559
|
if (pages.length === 0) return null;
|
|
793957
|
-
const finalHtmlFirstChunk = splitTelegramMessageText(finalHtml, 3900)[0] ?? finalHtml;
|
|
793958
794560
|
const id2 = randomBytes29(6).toString("hex");
|
|
793959
794561
|
const now2 = Date.now();
|
|
793960
794562
|
return {
|
|
793961
794563
|
id: id2,
|
|
793962
|
-
|
|
793963
|
-
|
|
793964
|
-
finalHtml: finalHtmlFirstChunk,
|
|
794564
|
+
sourceChatId: msg.chatId,
|
|
794565
|
+
sourceMessageId: null,
|
|
793965
794566
|
activePage: 0,
|
|
793966
794567
|
pages,
|
|
793967
794568
|
createdAtMs: now2,
|
|
@@ -793974,20 +794575,10 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
793974
794575
|
Math.max(0, state5.pages.length - 1)
|
|
793975
794576
|
);
|
|
793976
794577
|
const page2 = state5.pages[pageIndex];
|
|
793977
|
-
|
|
793978
|
-
|
|
793979
|
-
|
|
793980
|
-
|
|
793981
|
-
[
|
|
793982
|
-
`<b>Context frame</b>`,
|
|
793983
|
-
`<i>Page ${pageIndex + 1}/${state5.pages.length}: ${escapeTelegramHTML(page2.title)}</i>`,
|
|
793984
|
-
`Source: <code>${escapeTelegramHTML(page2.source)}</code>`,
|
|
793985
|
-
meta,
|
|
793986
|
-
"",
|
|
793987
|
-
body
|
|
793988
|
-
].filter(Boolean).join("\n"),
|
|
793989
|
-
3900,
|
|
793990
|
-
"\n\n<i>... (context page clipped)</i>"
|
|
794578
|
+
return renderTelegramContextExplorerPagePayload(
|
|
794579
|
+
page2,
|
|
794580
|
+
pageIndex,
|
|
794581
|
+
state5.pages.length
|
|
793991
794582
|
);
|
|
793992
794583
|
}
|
|
793993
794584
|
async handleTelegramContextExplorerCallback(callback) {
|
|
@@ -794014,36 +794605,94 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
794014
794605
|
}
|
|
794015
794606
|
const action = parts[4];
|
|
794016
794607
|
const requestedPage = Number.parseInt(parts[5] ?? "0", 10);
|
|
794017
|
-
|
|
794018
|
-
|
|
794019
|
-
|
|
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.";
|
|
794020
794654
|
alert = true;
|
|
794021
794655
|
return;
|
|
794022
794656
|
}
|
|
794023
|
-
state5.messageId = messageId;
|
|
794024
794657
|
if (action === "noop") return;
|
|
794025
|
-
if (action === "
|
|
794026
|
-
await this.editLiveMessage(
|
|
794027
|
-
|
|
794028
|
-
|
|
794029
|
-
|
|
794030
|
-
this.telegramContextExplorerReplyMarkup(state5.id)
|
|
794658
|
+
if (action === "close") {
|
|
794659
|
+
const closed = await this.editLiveMessage(
|
|
794660
|
+
panelChatId,
|
|
794661
|
+
panelMessageId,
|
|
794662
|
+
"<b>Context panel closed.</b>"
|
|
794031
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;
|
|
794032
794672
|
return;
|
|
794033
794673
|
}
|
|
794034
|
-
if (action !== "
|
|
794674
|
+
if (action !== "page") {
|
|
794035
794675
|
answerText = "Unknown context frame action.";
|
|
794036
794676
|
alert = true;
|
|
794037
794677
|
return;
|
|
794038
794678
|
}
|
|
794039
794679
|
const maxPage = Math.max(0, state5.pages.length - 1);
|
|
794040
|
-
|
|
794041
|
-
|
|
794042
|
-
|
|
794043
|
-
|
|
794044
|
-
|
|
794045
|
-
|
|
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
|
|
794046
794690
|
);
|
|
794691
|
+
if (!edited) {
|
|
794692
|
+
state5.activePage = previousPage;
|
|
794693
|
+
answerText = "Telegram did not apply this context page. Try again.";
|
|
794694
|
+
alert = true;
|
|
794695
|
+
}
|
|
794047
794696
|
} catch (err) {
|
|
794048
794697
|
answerText = err instanceof Error ? err.message : String(err);
|
|
794049
794698
|
alert = true;
|
|
@@ -794616,7 +795265,8 @@ Join: ${newUrl}`
|
|
|
794616
795265
|
validatedMediaArtifacts: /* @__PURE__ */ new Set(),
|
|
794617
795266
|
deliveredArtifacts: [],
|
|
794618
795267
|
deliveredFileSends: /* @__PURE__ */ new Set(),
|
|
794619
|
-
surfacedToolCallFingerprints: /* @__PURE__ */ new Set()
|
|
795268
|
+
surfacedToolCallFingerprints: /* @__PURE__ */ new Set(),
|
|
795269
|
+
steeringReconciliations: /* @__PURE__ */ new Map()
|
|
794620
795270
|
};
|
|
794621
795271
|
this.subAgents.set(sessionKey, subAgent);
|
|
794622
795272
|
for (const intake of work.intakeRecords) {
|
|
@@ -794803,11 +795453,12 @@ Join: ${newUrl}`
|
|
|
794803
795453
|
}
|
|
794804
795454
|
const deliveredFinalText = finalText;
|
|
794805
795455
|
const adminEvidenceText = isAdminDM ? this.telegramAdminCompletionRunText(subAgent, finalText) : "";
|
|
794806
|
-
const finalHtml =
|
|
795456
|
+
const finalHtml = isAdminDM ? composeTelegramReplyWithSteeringHTML(deliveredFinalText, [
|
|
795457
|
+
...subAgent.steeringReconciliations.values()
|
|
795458
|
+
]) : convertMarkdownToTelegramHTML(deliveredFinalText);
|
|
794807
795459
|
const contextExplorerState = !isAdminDM && msg.chatType !== "private" && !msg.guestQueryId ? this.buildTelegramContextExplorerState(
|
|
794808
795460
|
msg,
|
|
794809
795461
|
subAgent,
|
|
794810
|
-
finalHtml,
|
|
794811
795462
|
deliveredFinalText
|
|
794812
795463
|
) : null;
|
|
794813
795464
|
const contextExplorerReplyMarkup = contextExplorerState ? this.telegramContextExplorerReplyMarkup(contextExplorerState.id) : void 0;
|
|
@@ -794825,7 +795476,7 @@ Join: ${newUrl}`
|
|
|
794825
795476
|
);
|
|
794826
795477
|
if (contextExplorerState && sentMessageId !== null) {
|
|
794827
795478
|
this.pruneTelegramContextExplorers();
|
|
794828
|
-
contextExplorerState.
|
|
795479
|
+
contextExplorerState.sourceMessageId = sentMessageId;
|
|
794829
795480
|
this.telegramContextExplorerStates.set(
|
|
794830
795481
|
contextExplorerState.id,
|
|
794831
795482
|
contextExplorerState
|
|
@@ -794967,7 +795618,8 @@ ${errMsg}`
|
|
|
794967
795618
|
validatedMediaArtifacts: /* @__PURE__ */ new Set(),
|
|
794968
795619
|
deliveredArtifacts: [],
|
|
794969
795620
|
deliveredFileSends: /* @__PURE__ */ new Set(),
|
|
794970
|
-
surfacedToolCallFingerprints: /* @__PURE__ */ new Set()
|
|
795621
|
+
surfacedToolCallFingerprints: /* @__PURE__ */ new Set(),
|
|
795622
|
+
steeringReconciliations: /* @__PURE__ */ new Map()
|
|
794971
795623
|
};
|
|
794972
795624
|
this.subAgents.set(sessionKey, subAgent);
|
|
794973
795625
|
const primaryIntake = this.telegramIntakeRecords.get(
|
|
@@ -795124,7 +795776,10 @@ ${errMsg}`
|
|
|
795124
795776
|
subAgent,
|
|
795125
795777
|
deliveredFinalText
|
|
795126
795778
|
);
|
|
795127
|
-
const finalHtml =
|
|
795779
|
+
const finalHtml = composeTelegramReplyWithSteeringHTML(
|
|
795780
|
+
deliveredFinalText,
|
|
795781
|
+
[...subAgent.steeringReconciliations.values()]
|
|
795782
|
+
);
|
|
795128
795783
|
const sentMessageId = !msg.guestQueryId ? await this.finalizeTelegramAdminLivePanel(
|
|
795129
795784
|
subAgent,
|
|
795130
795785
|
msg,
|
|
@@ -795681,6 +796336,20 @@ ${creativeWorkspace}` : ""
|
|
|
795681
796336
|
// ── WO #03 (Typed Gateway Event Stream): structured event feed ──
|
|
795682
796337
|
onTypedEvent: (event) => {
|
|
795683
796338
|
this.forwardTelegramRunnerIntakeLifecycle(event);
|
|
796339
|
+
if (event.type === "steering_lifecycle" && event.reconciliation) {
|
|
796340
|
+
upsertTelegramSteeringReconciliation(
|
|
796341
|
+
subAgent.steeringReconciliations,
|
|
796342
|
+
event.reconciliation
|
|
796343
|
+
);
|
|
796344
|
+
if (isAdminDM) {
|
|
796345
|
+
const state5 = this.ensureTelegramAdminLivePanel(subAgent, msg);
|
|
796346
|
+
state5.steeringReconciliations = [
|
|
796347
|
+
...subAgent.steeringReconciliations.values()
|
|
796348
|
+
];
|
|
796349
|
+
if (state5.activePage !== "response")
|
|
796350
|
+
state5.dirtyPages.response = true;
|
|
796351
|
+
}
|
|
796352
|
+
}
|
|
795684
796353
|
if (event.type === "run_finished") {
|
|
795685
796354
|
subAgent.runnerCompleted = event.success;
|
|
795686
796355
|
subAgent.runnerStatus = event.status;
|
|
@@ -795744,13 +796413,12 @@ ${creativeWorkspace}` : ""
|
|
|
795744
796413
|
);
|
|
795745
796414
|
}
|
|
795746
796415
|
runner.registerTools(tools);
|
|
795747
|
-
const telegramSteeringFilter = new SteeringReconciliationStreamFilter(
|
|
795748
|
-
suppressTrailingContent: true
|
|
795749
|
-
});
|
|
796416
|
+
const telegramSteeringFilter = new SteeringReconciliationStreamFilter();
|
|
795750
796417
|
runner.onEvent((event) => {
|
|
795751
796418
|
if (subAgent.aborted) return;
|
|
795752
796419
|
subAgent.lastActivityMs = Date.now();
|
|
795753
796420
|
let suppressExternalEvent = false;
|
|
796421
|
+
let telegramDisplayEvent = event;
|
|
795754
796422
|
if (event.contextFrame) {
|
|
795755
796423
|
subAgent.contextFrame = event.contextFrame;
|
|
795756
796424
|
}
|
|
@@ -795822,6 +796490,7 @@ ${creativeWorkspace}` : ""
|
|
|
795822
796490
|
}
|
|
795823
796491
|
} else if (event.type === "assistant_text" && event.content && event.source !== "task_complete_summary") {
|
|
795824
796492
|
subAgent.assistantText = cleanTelegramVisibleReply(event.content);
|
|
796493
|
+
telegramDisplayEvent = subAgent.assistantText ? { ...event, content: subAgent.assistantText } : null;
|
|
795825
796494
|
} else if (event.type === "stream_start") {
|
|
795826
796495
|
this.retainTelegramVisibleReplyFromCompletedStream(subAgent);
|
|
795827
796496
|
subAgent.accumulated = "";
|
|
@@ -795832,9 +796501,12 @@ ${creativeWorkspace}` : ""
|
|
|
795832
796501
|
const finalBuffered = telegramSteeringFilter.flush();
|
|
795833
796502
|
if (finalBuffered) subAgent.accumulated += finalBuffered;
|
|
795834
796503
|
subAgent.streamText = cleanTelegramVisibleReply(event.content);
|
|
796504
|
+
telegramDisplayEvent = subAgent.streamText ? { ...event, content: subAgent.streamText } : null;
|
|
795835
796505
|
}
|
|
795836
796506
|
if (event.type === "stream_token" && event.streamKind === "content" && event.content) {
|
|
795837
|
-
|
|
796507
|
+
const visibleChunk = telegramSteeringFilter.consume(event.content);
|
|
796508
|
+
subAgent.accumulated += visibleChunk;
|
|
796509
|
+
telegramDisplayEvent = visibleChunk ? { ...event, content: visibleChunk } : null;
|
|
795838
796510
|
}
|
|
795839
796511
|
if (event.type === "stream_token" && event.streamKind === "thinking" && event.content && this.telegramThinkingVisible) {
|
|
795840
796512
|
const trimmed = event.content.replace(/\s+/g, " ").slice(0, 200);
|
|
@@ -795849,7 +796521,13 @@ ${creativeWorkspace}` : ""
|
|
|
795849
796521
|
}
|
|
795850
796522
|
if (!msg.guestQueryId) {
|
|
795851
796523
|
if (isAdminDM) {
|
|
795852
|
-
|
|
796524
|
+
if (telegramDisplayEvent) {
|
|
796525
|
+
this.updateTelegramAdminLivePanelFromEvent(
|
|
796526
|
+
subAgent,
|
|
796527
|
+
msg,
|
|
796528
|
+
telegramDisplayEvent
|
|
796529
|
+
);
|
|
796530
|
+
}
|
|
795853
796531
|
return;
|
|
795854
796532
|
}
|
|
795855
796533
|
const html = renderTelegramLiveProgressHTML(
|
|
@@ -799689,8 +800367,14 @@ ${this.quoteTelegramContextBlock(msg.text, 800)}`,
|
|
|
799689
800367
|
return;
|
|
799690
800368
|
}
|
|
799691
800369
|
state5.messageId = messageId;
|
|
799692
|
-
await this.renderTelegramAdminLivePanel(state5);
|
|
799693
|
-
|
|
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
|
+
}
|
|
799694
800378
|
} catch (err) {
|
|
799695
800379
|
answerText2 = err instanceof Error ? err.message : String(err);
|
|
799696
800380
|
alert2 = true;
|