omnius 1.0.228 → 1.0.230
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 +207 -48
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -587431,6 +587431,7 @@ var init_model_picker = __esm({
|
|
|
587431
587431
|
var render_exports = {};
|
|
587432
587432
|
__export(render_exports, {
|
|
587433
587433
|
SLASH_COMMANDS: () => SLASH_COMMANDS2,
|
|
587434
|
+
breakTelegramCoalesce: () => breakTelegramCoalesce,
|
|
587434
587435
|
c: () => c3,
|
|
587435
587436
|
fileLink: () => fileLink,
|
|
587436
587437
|
formatInlineMarkdown: () => formatInlineMarkdown,
|
|
@@ -587457,6 +587458,7 @@ __export(render_exports, {
|
|
|
587457
587458
|
renderTaskAborted: () => renderTaskAborted,
|
|
587458
587459
|
renderTaskComplete: () => renderTaskComplete,
|
|
587459
587460
|
renderTaskIncomplete: () => renderTaskIncomplete,
|
|
587461
|
+
renderTelegramCoalescedRow: () => renderTelegramCoalescedRow,
|
|
587460
587462
|
renderThinking: () => renderThinking,
|
|
587461
587463
|
renderToolCallStart: () => renderToolCallStart,
|
|
587462
587464
|
renderToolLine: () => renderToolLine,
|
|
@@ -587599,6 +587601,7 @@ ${accentFg()}▹\x1B[0m ${c3.bold(text)}
|
|
|
587599
587601
|
}
|
|
587600
587602
|
function renderAssistantText(text) {
|
|
587601
587603
|
if (!text.trim()) return;
|
|
587604
|
+
breakTelegramCoalesce();
|
|
587602
587605
|
const formatted = formatMarkdownBlock(text);
|
|
587603
587606
|
const lines = formatted.split("\n");
|
|
587604
587607
|
for (const line of lines) {
|
|
@@ -587861,6 +587864,44 @@ function renderToolDynamicBlock(kind, render2, opts) {
|
|
|
587861
587864
|
}
|
|
587862
587865
|
process.stdout.write(text);
|
|
587863
587866
|
}
|
|
587867
|
+
function breakTelegramCoalesce() {
|
|
587868
|
+
_telegramCoalesce = null;
|
|
587869
|
+
}
|
|
587870
|
+
function renderTelegramCoalescedRow(row, opts) {
|
|
587871
|
+
const colorCode = opts?.colorCode ?? 45;
|
|
587872
|
+
const title = opts?.title ?? "✈ Telegram";
|
|
587873
|
+
const redir = _contentWriteHook?.redirect?.();
|
|
587874
|
+
const host = _contentWriteHook?.dynamicBlockHost?.() ?? null;
|
|
587875
|
+
if (redir || !host || typeof host.refreshDynamicBlocks !== "function") {
|
|
587876
|
+
_telegramCoalesce = null;
|
|
587877
|
+
renderToolDynamicBlock(
|
|
587878
|
+
"tool-result",
|
|
587879
|
+
(width) => buildToolBoxLines({
|
|
587880
|
+
title,
|
|
587881
|
+
metrics: "",
|
|
587882
|
+
body: [{ text: row, mode: "wrap", kind: "plain" }],
|
|
587883
|
+
colorCode
|
|
587884
|
+
}, width),
|
|
587885
|
+
{}
|
|
587886
|
+
);
|
|
587887
|
+
return;
|
|
587888
|
+
}
|
|
587889
|
+
if (_telegramCoalesce) {
|
|
587890
|
+
_telegramCoalesce.lines.push(row);
|
|
587891
|
+
host.refreshDynamicBlocks();
|
|
587892
|
+
return;
|
|
587893
|
+
}
|
|
587894
|
+
const id = `tg-coalesce-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
587895
|
+
const state = { id, lines: [row], colorCode };
|
|
587896
|
+
_telegramCoalesce = state;
|
|
587897
|
+
host.registerDynamicBlock(id, (width) => buildToolBoxLines({
|
|
587898
|
+
title,
|
|
587899
|
+
metrics: state.lines.length > 1 ? `${state.lines.length} events` : "",
|
|
587900
|
+
body: state.lines.map((text) => ({ text, mode: "wrap", kind: "plain" })),
|
|
587901
|
+
colorCode: state.colorCode
|
|
587902
|
+
}, width));
|
|
587903
|
+
host.appendDynamicBlock(id);
|
|
587904
|
+
}
|
|
587864
587905
|
function appendContextBoxSection(body, label, value2) {
|
|
587865
587906
|
const text = String(value2 ?? "").trim();
|
|
587866
587907
|
if (!text) return;
|
|
@@ -587880,6 +587921,7 @@ function appendContextBoxList(body, label, values) {
|
|
|
587880
587921
|
}
|
|
587881
587922
|
}
|
|
587882
587923
|
function renderContextIntakeBox(opts) {
|
|
587924
|
+
breakTelegramCoalesce();
|
|
587883
587925
|
const body = [];
|
|
587884
587926
|
appendContextBoxSection(body, "Added context:", opts.rawText);
|
|
587885
587927
|
appendContextBoxSection(body, "Triage:", opts.inference);
|
|
@@ -588111,6 +588153,7 @@ function detectToolArtifacts(output) {
|
|
|
588111
588153
|
return [...out].slice(0, 12);
|
|
588112
588154
|
}
|
|
588113
588155
|
function renderToolCallStart(toolName, args, verboseOrOpts) {
|
|
588156
|
+
breakTelegramCoalesce();
|
|
588114
588157
|
const opts = normalizeToolOpts(verboseOrOpts);
|
|
588115
588158
|
const frozenArgs = { ...args ?? {} };
|
|
588116
588159
|
renderToolDynamicBlock(
|
|
@@ -588125,6 +588168,7 @@ function renderToolLine(content, isLast = false) {
|
|
|
588125
588168
|
`);
|
|
588126
588169
|
}
|
|
588127
588170
|
function renderToolResult(toolName, success, output, verboseOrOpts) {
|
|
588171
|
+
breakTelegramCoalesce();
|
|
588128
588172
|
const opts = normalizeToolOpts(verboseOrOpts);
|
|
588129
588173
|
const frozenOutput = String(output ?? "");
|
|
588130
588174
|
renderToolDynamicBlock(
|
|
@@ -588134,6 +588178,7 @@ function renderToolResult(toolName, success, output, verboseOrOpts) {
|
|
|
588134
588178
|
);
|
|
588135
588179
|
}
|
|
588136
588180
|
function renderBoxedBlock(opts) {
|
|
588181
|
+
breakTelegramCoalesce();
|
|
588137
588182
|
const mode = opts.mode ?? "wrap";
|
|
588138
588183
|
const kind = opts.kind ?? "plain";
|
|
588139
588184
|
const body = (opts.lines.length > 0 ? opts.lines : [""]).map((text) => ({
|
|
@@ -588187,6 +588232,7 @@ function highlightToolOutput(line) {
|
|
|
588187
588232
|
return c3.dim(line);
|
|
588188
588233
|
}
|
|
588189
588234
|
function renderTaskComplete(arg1, turns, toolCalls, durationMs, tokens) {
|
|
588235
|
+
breakTelegramCoalesce();
|
|
588190
588236
|
const opts = typeof arg1 === "string" ? {
|
|
588191
588237
|
summary: arg1,
|
|
588192
588238
|
turns: turns ?? 0,
|
|
@@ -588298,6 +588344,7 @@ function setContentWriteHook(hook) {
|
|
|
588298
588344
|
_contentWriteHook = hook;
|
|
588299
588345
|
}
|
|
588300
588346
|
function renderError(message2) {
|
|
588347
|
+
breakTelegramCoalesce();
|
|
588301
588348
|
const redir = _contentWriteHook?.redirect?.();
|
|
588302
588349
|
const icon = _emojisEnabled ? "\x1B[38;5;198m✖\x1B[0m" : "\x1B[38;5;198mE\x1B[0m";
|
|
588303
588350
|
const text = `
|
|
@@ -588312,6 +588359,7 @@ ${icon} \x1B[38;5;198m${message2}\x1B[0m
|
|
|
588312
588359
|
_contentWriteHook?.end();
|
|
588313
588360
|
}
|
|
588314
588361
|
function renderInfo(message2) {
|
|
588362
|
+
breakTelegramCoalesce();
|
|
588315
588363
|
const redir = _contentWriteHook?.redirect?.();
|
|
588316
588364
|
const dim = dimFg();
|
|
588317
588365
|
const icon = `${dim}∙\x1B[0m`;
|
|
@@ -588326,6 +588374,7 @@ function renderInfo(message2) {
|
|
|
588326
588374
|
_contentWriteHook?.end();
|
|
588327
588375
|
}
|
|
588328
588376
|
function renderWarning(message2) {
|
|
588377
|
+
breakTelegramCoalesce();
|
|
588329
588378
|
const redir = _contentWriteHook?.redirect?.();
|
|
588330
588379
|
const icon = "\x1B[38;5;214m!\x1B[0m";
|
|
588331
588380
|
const text = `${icon} \x1B[38;5;214m${message2}\x1B[0m
|
|
@@ -588339,6 +588388,7 @@ function renderWarning(message2) {
|
|
|
588339
588388
|
_contentWriteHook?.end();
|
|
588340
588389
|
}
|
|
588341
588390
|
function renderVerbose(message2) {
|
|
588391
|
+
breakTelegramCoalesce();
|
|
588342
588392
|
const redir = _contentWriteHook?.redirect?.();
|
|
588343
588393
|
const text = ` ${accentFg()}▹\x1B[0m ${c3.dim(message2)}
|
|
588344
588394
|
`;
|
|
@@ -588487,7 +588537,7 @@ function formatDuration4(ms) {
|
|
|
588487
588537
|
const secs = Math.floor(totalSecs % 60);
|
|
588488
588538
|
return `${mins}m ${secs}s`;
|
|
588489
588539
|
}
|
|
588490
|
-
var c3, ui, pastel, _emojisEnabled, _colorsEnabled, MD, TOOL_ICONS, TOOL_LABELS, TOOL_COLOR_CODES, TOOL_ERROR_COLOR_CODE, BOX_TL2, BOX_TR2, BOX_BL2, BOX_BR2, BOX_H2, BOX_V2, BOX_TJ_L2, BOX_TJ_R2, RESET2, DIFF_LINE_RE, _contentWriteHook, HINTS, TOOL_NAMES, COMMAND_NAMES, SLASH_COMMANDS2;
|
|
588540
|
+
var c3, ui, pastel, _emojisEnabled, _colorsEnabled, MD, TOOL_ICONS, TOOL_LABELS, TOOL_COLOR_CODES, TOOL_ERROR_COLOR_CODE, BOX_TL2, BOX_TR2, BOX_BL2, BOX_BR2, BOX_H2, BOX_V2, BOX_TJ_L2, BOX_TJ_R2, RESET2, _telegramCoalesce, DIFF_LINE_RE, _contentWriteHook, HINTS, TOOL_NAMES, COMMAND_NAMES, SLASH_COMMANDS2;
|
|
588491
588541
|
var init_render = __esm({
|
|
588492
588542
|
"packages/cli/src/tui/render.ts"() {
|
|
588493
588543
|
"use strict";
|
|
@@ -588679,6 +588729,7 @@ var init_render = __esm({
|
|
|
588679
588729
|
BOX_TJ_L2 = "├";
|
|
588680
588730
|
BOX_TJ_R2 = "┤";
|
|
588681
588731
|
RESET2 = "\x1B[0m";
|
|
588732
|
+
_telegramCoalesce = null;
|
|
588682
588733
|
DIFF_LINE_RE = /^\s*\d+\s([-+])\s/;
|
|
588683
588734
|
_contentWriteHook = null;
|
|
588684
588735
|
HINTS = [
|
|
@@ -642838,6 +642889,31 @@ function extractFinalTelegramReplyJson(buffer2) {
|
|
|
642838
642889
|
const partial = extractPartialTelegramReplyJson(stripped);
|
|
642839
642890
|
return partial && partial.trim().length > 0 ? partial.trim() : null;
|
|
642840
642891
|
}
|
|
642892
|
+
function normalizeTelegramEchoComparableText(text) {
|
|
642893
|
+
return stripTelegramHiddenThinking(text).toLowerCase().replace(/https?:\/\/\S+/g, " ").replace(/@[a-z0-9_]{3,32}/gi, " @user ").replace(/[^\p{L}\p{N}@]+/gu, " ").replace(/\s+/g, " ").trim();
|
|
642894
|
+
}
|
|
642895
|
+
function telegramVisibleReplyNearEcho(incoming, outgoing) {
|
|
642896
|
+
const source = normalizeTelegramEchoComparableText(incoming);
|
|
642897
|
+
const reply = normalizeTelegramEchoComparableText(outgoing);
|
|
642898
|
+
if (source.length < 20 || reply.length < 20) return false;
|
|
642899
|
+
if (source === reply) return true;
|
|
642900
|
+
const sourceTokens = source.split(" ").filter(Boolean);
|
|
642901
|
+
const replyTokens = reply.split(" ").filter(Boolean);
|
|
642902
|
+
if (sourceTokens.length < 4 || replyTokens.length < 4) return false;
|
|
642903
|
+
const lengthRatio = Math.min(source.length, reply.length) / Math.max(source.length, reply.length);
|
|
642904
|
+
if (lengthRatio < 0.72) return false;
|
|
642905
|
+
const sourceSet = new Set(sourceTokens);
|
|
642906
|
+
const replySet = new Set(replyTokens);
|
|
642907
|
+
let overlap = 0;
|
|
642908
|
+
for (const token of replySet) {
|
|
642909
|
+
if (sourceSet.has(token)) overlap += 1;
|
|
642910
|
+
}
|
|
642911
|
+
const dice = 2 * overlap / (sourceSet.size + replySet.size);
|
|
642912
|
+
return dice >= 0.9;
|
|
642913
|
+
}
|
|
642914
|
+
function telegramMentionMatchesUsername(mention, usernameLower) {
|
|
642915
|
+
return mention.trim().replace(/^@/, "").toLowerCase() === usernameLower;
|
|
642916
|
+
}
|
|
642841
642917
|
function estimatePromptTokensFromRequest(request) {
|
|
642842
642918
|
let chars = 0;
|
|
642843
642919
|
for (const m2 of request.messages ?? []) {
|
|
@@ -644538,62 +644614,35 @@ function renderTelegramStop(state) {
|
|
|
644538
644614
|
}
|
|
644539
644615
|
function renderTelegramMessage(username, text) {
|
|
644540
644616
|
const preview = text.length > 80 ? text.slice(0, 77) + "..." : text;
|
|
644541
|
-
|
|
644542
|
-
`);
|
|
644617
|
+
renderTelegramCoalescedRow(`${c3.bold(`@${username}`)}: ${preview}`);
|
|
644543
644618
|
}
|
|
644544
644619
|
function renderTelegramIngressMessage(msg) {
|
|
644545
644620
|
const body = (msg.text || summarizeTelegramMessageAttachments(msg) || "[non-text Telegram message]").replace(/\s+/g, " ").trim();
|
|
644546
644621
|
const preview = body.length > 96 ? body.slice(0, 93) + "..." : body;
|
|
644547
644622
|
const chat = msg.chatType !== "private" ? ` ${c3.dim(`[${msg.chatTitle || msg.chatType}]`)}` : "";
|
|
644548
|
-
|
|
644549
|
-
|
|
644550
|
-
`
|
|
644623
|
+
renderTelegramCoalescedRow(
|
|
644624
|
+
`${c3.dim("heard")}${chat} ${c3.bold(`@${msg.username || "unknown"}`)} ${c3.dim(`[${telegramActorKindLabel(msg)}]`)}: ${preview}`
|
|
644551
644625
|
);
|
|
644552
644626
|
}
|
|
644553
644627
|
function renderTelegramSubAgentStart(username, text, isAdmin) {
|
|
644554
644628
|
const preview = text.length > 60 ? text.slice(0, 57) + "..." : text;
|
|
644555
644629
|
const mode = isAdmin ? c3.green("admin") : c3.yellow("public");
|
|
644556
|
-
|
|
644557
|
-
${c3.cyan("✈")} ${c3.bold(`Sub-agent`)} [${mode}] for @${username}
|
|
644558
|
-
`);
|
|
644559
|
-
process.stdout.write(` ${c3.dim("│")} ${preview}
|
|
644560
|
-
`);
|
|
644630
|
+
renderTelegramCoalescedRow(`${c3.bold("sub-agent")} [${mode}] ${c3.bold(`@${username}`)}: ${preview}`);
|
|
644561
644631
|
}
|
|
644562
644632
|
function renderTelegramSubAgentEvent(username, detail) {
|
|
644563
|
-
|
|
644564
|
-
title: `✈ @${username}`,
|
|
644565
|
-
lines: [detail],
|
|
644566
|
-
colorCode: 45
|
|
644567
|
-
});
|
|
644633
|
+
renderTelegramCoalescedRow(`${c3.bold(`@${username}`)}: ${detail}`);
|
|
644568
644634
|
}
|
|
644569
644635
|
function renderTelegramSubAgentToolCall(username, toolName, args) {
|
|
644570
644636
|
const preview = args.length > 50 ? args.slice(0, 47) + "..." : args;
|
|
644571
|
-
|
|
644572
|
-
title: `✈ @${username}`,
|
|
644573
|
-
metrics: toolName,
|
|
644574
|
-
lines: [`${c3.bold(toolName)}(${c3.dim(preview)})`],
|
|
644575
|
-
colorCode: 45
|
|
644576
|
-
});
|
|
644637
|
+
renderTelegramCoalescedRow(`${c3.bold(`@${username}`)} ${c3.bold(toolName)}(${c3.dim(preview)})`);
|
|
644577
644638
|
}
|
|
644578
644639
|
function renderTelegramSubAgentComplete(username, summary) {
|
|
644579
644640
|
const preview = summary.length > 80 ? summary.slice(0, 77) + "..." : summary;
|
|
644580
|
-
|
|
644581
|
-
title: `✔ @${username}`,
|
|
644582
|
-
lines: [preview],
|
|
644583
|
-
kind: "success",
|
|
644584
|
-
colorCode: 42
|
|
644585
|
-
// green
|
|
644586
|
-
});
|
|
644641
|
+
renderTelegramCoalescedRow(`${c3.green("✔")} ${c3.bold(`@${username}`)}: ${c3.dim(preview)}`);
|
|
644587
644642
|
}
|
|
644588
644643
|
function renderTelegramSubAgentError(username, error) {
|
|
644589
644644
|
const preview = error.length > 80 ? error.slice(0, 77) + "..." : error;
|
|
644590
|
-
|
|
644591
|
-
title: `✘ @${username}`,
|
|
644592
|
-
lines: [preview],
|
|
644593
|
-
kind: "error",
|
|
644594
|
-
colorCode: 198
|
|
644595
|
-
// magenta
|
|
644596
|
-
});
|
|
644645
|
+
renderTelegramCoalescedRow(`${c3.red("✘")} ${c3.bold(`@${username}`)}: ${c3.dim(preview)}`);
|
|
644597
644646
|
}
|
|
644598
644647
|
var TELEGRAM_TOOL_ACTION_GROUPS, TELEGRAM_TOOL_ACTION_GROUP, TELEGRAM_TOOL_MUTATING_GROUPS, DEFAULT_TELEGRAM_TOOL_GROUP_POLICY, TELEGRAM_TOOL_BUTTON_LABELS, TELEGRAM_SAFETY_PROMPT, ADMIN_DM_PROMPT, ADMIN_GROUP_PROMPT, TELEGRAM_PUBLIC_SOUL_PROFILE, TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT, TELEGRAM_PUBLIC_MEMORY_SCOPE_CONTRACT, TELEGRAM_PUBLIC_VISION_STACK_CONTRACT, GROUP_REPLY_DISCRETION_PROMPT, TELEGRAM_CHAT_MODE_PROMPT, ADMIN_CHAT_PROFILE_PROMPT, TELEGRAM_ACTION_RESPONSE_CONTRACT, TELEGRAM_EXTERNAL_ACQUISITION_CONTRACT, TELEGRAM_LINK_INTEGRITY_CONTRACT, TELEGRAM_INTERACTION_DECISION_RESPONSE_FORMAT, TELEGRAM_INTERACTION_DECISION_MINIMAL_SCHEMA, TELEGRAM_INTERACTION_DECISION_REPAIR_SCHEMA, TELEGRAM_CHAT_REPLY_RESPONSE_FORMAT, TELEGRAM_SPACED_URL_RE, TELEGRAM_HTTP_URL_RE, TELEGRAM_STUCK_SELF_TALK_PREFIXES, TELEGRAM_CHAT_HISTORY_LIMIT, TELEGRAM_CONTEXT_RECENT_DEFAULT, TELEGRAM_CONTEXT_LINE_LIMIT, TELEGRAM_CONTEXT_SAMPLE_LIMIT, TELEGRAM_MEMORY_CARD_LIMIT, TELEGRAM_MEMORY_NOTE_LIMIT, TELEGRAM_ASSOCIATIVE_FACT_LIMIT, TELEGRAM_ASSOCIATIVE_USER_FACT_LIMIT, TELEGRAM_ASSOCIATIVE_ACTION_LIMIT, TELEGRAM_ASSOCIATIVE_RELATION_LIMIT, TELEGRAM_MEMORY_STOPWORDS, TELEGRAM_MEMORY_GENERIC_QUERY_TOKENS, TELEGRAM_SUB_AGENT_BOUNDED_OPTIONS, TELEGRAM_PUBLIC_FAST_OPTIONS, TELEGRAM_ADMIN_EVIDENCE_OPTIONS, TELEGRAM_SUB_AGENT_DEFAULT_LIMIT, TELEGRAM_SUB_AGENT_MAX_LIMIT, TELEGRAM_SUB_AGENT_BURST_CONTEXT_LIMIT, TELEGRAM_ADMIN_LIVE_PANEL_PAGES, TELEGRAM_ADMIN_LIVE_MUTATION_TOOLS, TELEGRAM_PUBLIC_HELP_COMMANDS2, TELEGRAM_REMINDER_SLASH_COMMANDS, TELEGRAM_REFLECTION_SLASH_COMMANDS, TELEGRAM_PUBLIC_BOT_COMMAND_NAMES, TELEGRAM_IMAGE_EXTENSIONS, MEDIA_CACHE_TTL_MS, TELEGRAM_CHANNEL_DMN_SWEEP_MS, TELEGRAM_CHANNEL_DMN_IDLE_AFTER_MS, TELEGRAM_CHANNEL_DMN_MIN_INTERVAL_MS, TELEGRAM_CHANNEL_DMN_MIN_MESSAGES, TELEGRAM_ALLOWED_UPDATES, TELEGRAM_DEFAULT_LONG_POLL_TIMEOUT_SECONDS, TELEGRAM_ROUTER_AUTO_MIN_PARAMETERS_B, TELEGRAM_PUBLIC_TOOL_QUOTAS, TelegramBridge;
|
|
644599
644648
|
var init_telegram_bridge = __esm({
|
|
@@ -644847,6 +644896,8 @@ Rules:
|
|
|
644847
644896
|
7. Do not claim older chat is unavailable when the context stream contains it. If asked what you see, summarize the supplied transcript, speakers, and relationship/tone signals.
|
|
644848
644897
|
8. Mirror the current sender's tone and directness while staying safe and clear.
|
|
644849
644898
|
9. Never send router decisions, skip explanations, memory-stage notes, task-complete summaries, or "no_reply" as chat text.
|
|
644899
|
+
10. Never impersonate another Telegram bot or answer as a bot named in the user's message. If the current turn is addressed to another bot, do not write a visible reply for that bot.
|
|
644900
|
+
11. Do not echo, quote back, or lightly rephrase the current incoming message as the reply. If the best output would be a near-copy of the user text, send no visible reply.
|
|
644850
644901
|
|
|
644851
644902
|
Output discipline (your assistant message is sent verbatim to Telegram, ALL of it):
|
|
644852
644903
|
- Emit ONLY the final reply text. Do not narrate your reasoning, summarize what you found, organize bullet-point notes, or write phrases like "Let me summarize", "Let me send the reply", "Now I have enough", "Based on the research", "Here's my response:" before the actual reply. Those are scratch-pad phrases that leak when emitted as visible text.
|
|
@@ -645472,6 +645523,23 @@ Telegram link integrity contract:
|
|
|
645472
645523
|
botUserId !== void 0 ? `telegram_user_id:${botUserId}` : ""
|
|
645473
645524
|
];
|
|
645474
645525
|
}
|
|
645526
|
+
telegramUsernameIsSelf(username) {
|
|
645527
|
+
const bot = this.state.botUsername.trim().replace(/^@/, "").toLowerCase();
|
|
645528
|
+
const candidate = username?.trim().replace(/^@/, "").toLowerCase();
|
|
645529
|
+
return Boolean(bot && candidate && candidate === bot);
|
|
645530
|
+
}
|
|
645531
|
+
telegramParticipantIsSelf(profile) {
|
|
645532
|
+
const botUserId = this.currentTelegramBotUserId();
|
|
645533
|
+
return Boolean(
|
|
645534
|
+
this.telegramUsernameIsSelf(profile.username) || botUserId !== void 0 && profile.fromUserId === botUserId
|
|
645535
|
+
);
|
|
645536
|
+
}
|
|
645537
|
+
telegramHistoryEntryIsSelf(entry) {
|
|
645538
|
+
const botUserId = this.currentTelegramBotUserId();
|
|
645539
|
+
return Boolean(
|
|
645540
|
+
entry.role === "assistant" || this.telegramUsernameIsSelf(entry.username) || botUserId !== void 0 && entry.fromUserId === botUserId
|
|
645541
|
+
);
|
|
645542
|
+
}
|
|
645475
645543
|
buildTelegramSelfIdentityContext() {
|
|
645476
645544
|
const username = this.state.botUsername.trim().replace(/^@/, "");
|
|
645477
645545
|
const firstName = this.state.botFirstName?.trim() ?? "";
|
|
@@ -645484,7 +645552,9 @@ Telegram link integrity contract:
|
|
|
645484
645552
|
return [
|
|
645485
645553
|
`Telegram bot self identity: ${detail}.`,
|
|
645486
645554
|
`Known self identity signals (context only, not triggers): ${formatTelegramIdentitySignals(this.telegramSelfIdentitySignals())}.`,
|
|
645487
|
-
`Use these signals to infer whether heard text is probably aimed at this bot; identity matches raise salience but never force should_reply
|
|
645555
|
+
`Use these signals to infer whether heard text is probably aimed at this bot; identity matches raise salience but never force should_reply.`,
|
|
645556
|
+
`Identity boundary: you are ONLY ${username ? `@${username}` : "the Telegram bot self"} (${botUserId !== void 0 ? `user_id ${botUserId}` : "user_id unknown"}). Other [bot] actors are separate participants; never speak as, impersonate, or adopt another bot's identity.`,
|
|
645557
|
+
`A message addressed to another bot, or mentioning this bot handle in third person, is not a request to reply as that other bot.`
|
|
645488
645558
|
].join("\n");
|
|
645489
645559
|
}
|
|
645490
645560
|
beginAdminAuthChallenge(ttlMs = 5 * 60 * 1e3) {
|
|
@@ -648757,7 +648827,7 @@ ${mediaContext}` : ""
|
|
|
648757
648827
|
profile.lastSeenTs = Date.now();
|
|
648758
648828
|
profile.lastMessage = stripTelegramHiddenThinking(text).replace(/\s+/g, " ").trim();
|
|
648759
648829
|
if (msg.replyToMessageId) profile.replyCount += 1;
|
|
648760
|
-
if (this.
|
|
648830
|
+
if (this.telegramIdentitySalienceAddressesBot(this.telegramMessageIdentitySalienceSignals(msg))) {
|
|
648761
648831
|
profile.directAddressCount += 1;
|
|
648762
648832
|
}
|
|
648763
648833
|
for (const tag of inferTelegramToneTags(text)) profile.toneTags.add(tag);
|
|
@@ -649606,6 +649676,7 @@ ${lines.join("\n")}`;
|
|
|
649606
649676
|
});
|
|
649607
649677
|
const selected = sortedByBenefit.slice(0, tier1Count);
|
|
649608
649678
|
const participantLines = selected.map((profile) => {
|
|
649679
|
+
const selfMark = this.telegramParticipantIsSelf(profile) ? " (self)" : "";
|
|
649609
649680
|
const label = profile.username && profile.username !== "unknown" ? `@${profile.username}` : profile.firstName || `user:${profile.fromUserId}`;
|
|
649610
649681
|
const tones = [...profile.toneTags].slice(0, 5).join(", ") || "neutral";
|
|
649611
649682
|
const direct = profile.directAddressCount ? `, direct-addresses:${profile.directAddressCount}` : "";
|
|
@@ -649614,7 +649685,7 @@ ${lines.join("\n")}`;
|
|
|
649614
649685
|
key: `tier1.participant.${profile.username ?? profile.fromUserId}`,
|
|
649615
649686
|
needle: profile.username ?? String(profile.fromUserId)
|
|
649616
649687
|
});
|
|
649617
|
-
return `- ${label} [${telegramActorKindLabel(profile)}]: messages:${profile.messageCount}${direct}${replies}; tone:${tones}; last=${telegramContextJsonString(profile.lastMessage, 180)}`;
|
|
649688
|
+
return `- ${label} [${telegramActorKindLabel(profile)}]${selfMark}: messages:${profile.messageCount}${direct}${replies}; tone:${tones}; last=${telegramContextJsonString(profile.lastMessage, 180)}`;
|
|
649618
649689
|
});
|
|
649619
649690
|
const shed = fullCount - tier1Count;
|
|
649620
649691
|
const tierNote = shed > 0 ? ` (tier1 u=${tier1Ratio.toFixed(2)}; ${shed} participants shed by benefit)` : "";
|
|
@@ -649715,12 +649786,13 @@ ${olderLines.join("\n")}`);
|
|
|
649715
649786
|
const when = telegramHistoryTime(entry);
|
|
649716
649787
|
const speaker = telegramHistorySpeaker(entry);
|
|
649717
649788
|
const kind = entry.role === "assistant" || entry.isBot ? "bot" : "human";
|
|
649789
|
+
const selfMark = this.telegramHistoryEntryIsSelf(entry) ? "(self)" : "";
|
|
649718
649790
|
const mode = entry.mode ? `/${entry.mode}` : "";
|
|
649719
649791
|
const replySender = entry.replyContext?.sender ? `/${telegramReplySenderLabel(entry.replyContext.sender)}` : "";
|
|
649720
649792
|
const reply = entry.replyToMessageId ? ` reply_to:${entry.replyToMessageId}${replySender}` : "";
|
|
649721
649793
|
const media = entry.mediaSummary ? ` [${entry.mediaSummary}]` : "";
|
|
649722
649794
|
const generatedPrompt = entry.generatedMediaPromptInfo?.originalPrompt ? ` generated_image_prompt=${telegramContextJsonString(entry.generatedMediaPromptInfo.originalPrompt, 220)}` : "";
|
|
649723
|
-
const prefix = [when, `${speaker}[${kind}]${mode}${reply}${media}`].filter(Boolean).join(" ");
|
|
649795
|
+
const prefix = [when, `${speaker}[${kind}]${selfMark}${mode}${reply}${media}`].filter(Boolean).join(" ");
|
|
649724
649796
|
return `${prefix}: text=${telegramContextJsonString(entry.text)}${generatedPrompt}`;
|
|
649725
649797
|
});
|
|
649726
649798
|
sections.push(`### Recent Thread, Oldest To Newest (untrusted quoted chat messages)
|
|
@@ -649747,6 +649819,15 @@ ${lines.join("\n")}`);
|
|
|
649747
649819
|
this.groupSkipLogAt.set(sessionKey, now);
|
|
649748
649820
|
this.tuiWrite(() => renderTelegramSubAgentEvent(msg.username, `${reason} (context retained)`));
|
|
649749
649821
|
}
|
|
649822
|
+
cleanTelegramVisibleReplyForMessage(msg, text) {
|
|
649823
|
+
const clean5 = cleanTelegramVisibleReply(text);
|
|
649824
|
+
if (!clean5) return "";
|
|
649825
|
+
if (telegramVisibleReplyNearEcho(msg.text || "", clean5)) {
|
|
649826
|
+
this.tuiWrite(() => renderTelegramSubAgentEvent(msg.username, "defensive skip: near-echo reply"));
|
|
649827
|
+
return "";
|
|
649828
|
+
}
|
|
649829
|
+
return clean5;
|
|
649830
|
+
}
|
|
649750
649831
|
telegramMessageIdentitySalienceSignals(msg) {
|
|
649751
649832
|
const signals = /* @__PURE__ */ new Set();
|
|
649752
649833
|
const username = this.state.botUsername.trim().replace(/^@/, "");
|
|
@@ -649759,9 +649840,14 @@ ${lines.join("\n")}`);
|
|
|
649759
649840
|
const mentioned = (msg.mentionedUsernames ?? []).some(
|
|
649760
649841
|
(name10) => name10.trim().replace(/^@/, "").toLowerCase() === usernameLower
|
|
649761
649842
|
);
|
|
649762
|
-
|
|
649843
|
+
const selfMentionAddressing = this.telegramSelfMentionAddressing(msg, username);
|
|
649844
|
+
if (mentioned) {
|
|
649845
|
+
signals.add(`${selfMentionAddressing === "third_person" ? "third_person_entity_mention" : "entity_mention"}:@${username}`);
|
|
649846
|
+
}
|
|
649763
649847
|
const rawMention = new RegExp(`(^|[^A-Za-z0-9_@])@${telegramRegexEscape(username)}(?![A-Za-z0-9_])`, "i");
|
|
649764
|
-
if (rawMention.test(text))
|
|
649848
|
+
if (rawMention.test(text)) {
|
|
649849
|
+
signals.add(`${selfMentionAddressing === "third_person" ? "third_person_mention" : "raw_text_mention"}:@${username}`);
|
|
649850
|
+
}
|
|
649765
649851
|
if (msg.replyToUsername && msg.replyToUsername.trim().replace(/^@/, "").toLowerCase() === usernameLower) {
|
|
649766
649852
|
signals.add(`reply_to_username:@${username}`);
|
|
649767
649853
|
}
|
|
@@ -649779,6 +649865,71 @@ ${lines.join("\n")}`);
|
|
|
649779
649865
|
if (resolvedReply?.sender?.isSelf) signals.add("reply_to_self_history");
|
|
649780
649866
|
return [...signals];
|
|
649781
649867
|
}
|
|
649868
|
+
telegramIdentitySalienceAddressesBot(signals) {
|
|
649869
|
+
return signals.some(
|
|
649870
|
+
(signal) => !signal.startsWith("third_person_mention:") && !signal.startsWith("third_person_entity_mention:")
|
|
649871
|
+
);
|
|
649872
|
+
}
|
|
649873
|
+
telegramCurrentMessageAddressedToOtherBot(msg) {
|
|
649874
|
+
const username = this.state.botUsername.trim().replace(/^@/, "").toLowerCase();
|
|
649875
|
+
const replyUsername = msg.replyToUsername?.trim().replace(/^@/, "").toLowerCase();
|
|
649876
|
+
if (replyUsername && replyUsername !== username && msg.replyToBot) {
|
|
649877
|
+
return `@${msg.replyToUsername.trim().replace(/^@/, "")}`;
|
|
649878
|
+
}
|
|
649879
|
+
const replySender = msg.replyContext?.sender;
|
|
649880
|
+
const replyContextUsername = replySender?.username?.trim().replace(/^@/, "").toLowerCase();
|
|
649881
|
+
if (replyContextUsername && replyContextUsername !== username && replySender?.isBot) {
|
|
649882
|
+
return `@${replySender.username.trim().replace(/^@/, "")}`;
|
|
649883
|
+
}
|
|
649884
|
+
const text = msg.text || "";
|
|
649885
|
+
const firstMention = text.match(/(^|[^A-Za-z0-9_@])@([A-Za-z0-9_]{3,32})(?![A-Za-z0-9_])/);
|
|
649886
|
+
if (firstMention?.[2] && firstMention[2].toLowerCase() !== username) {
|
|
649887
|
+
const mentioned = (msg.mentionedUsernames ?? []).find(
|
|
649888
|
+
(name10) => telegramMentionMatchesUsername(name10, firstMention[2].toLowerCase())
|
|
649889
|
+
);
|
|
649890
|
+
if (mentioned) return `@${firstMention[2]}`;
|
|
649891
|
+
}
|
|
649892
|
+
return null;
|
|
649893
|
+
}
|
|
649894
|
+
telegramSelfMentionAddressing(msg, username) {
|
|
649895
|
+
if (msg.chatType === "private") return "direct";
|
|
649896
|
+
if (this.telegramMessageRepliesToBot(msg)) return "direct";
|
|
649897
|
+
const usernameLower = username.toLowerCase();
|
|
649898
|
+
const text = msg.text || "";
|
|
649899
|
+
const mentionRegex = new RegExp(`(^|[^A-Za-z0-9_@])@${telegramRegexEscape(username)}(?![A-Za-z0-9_])`, "ig");
|
|
649900
|
+
const mentions = [];
|
|
649901
|
+
let match;
|
|
649902
|
+
while ((match = mentionRegex.exec(text)) !== null) {
|
|
649903
|
+
const delimiterLength = match[1]?.length ?? 0;
|
|
649904
|
+
const start2 = match.index + delimiterLength;
|
|
649905
|
+
mentions.push({
|
|
649906
|
+
start: start2,
|
|
649907
|
+
before: text.slice(0, start2),
|
|
649908
|
+
after: text.slice(start2 + username.length + 1)
|
|
649909
|
+
});
|
|
649910
|
+
}
|
|
649911
|
+
const hasSelfMention = mentions.length > 0 || (msg.mentionedUsernames ?? []).some(
|
|
649912
|
+
(name10) => telegramMentionMatchesUsername(name10, usernameLower)
|
|
649913
|
+
);
|
|
649914
|
+
if (!hasSelfMention) return "direct";
|
|
649915
|
+
const addressedOther = this.telegramCurrentMessageAddressedToOtherBot(msg);
|
|
649916
|
+
const anyDirect = mentions.some(({ before, after }) => {
|
|
649917
|
+
const prefix = before.trim().toLowerCase();
|
|
649918
|
+
const suffix = after.trimStart();
|
|
649919
|
+
const prefixIsVocative = /^(hey|hi|hello|yo|ok|okay|please|pls|sir|omg|btw)[\s,:-]*$/i.test(prefix);
|
|
649920
|
+
const prefixIsEmpty = prefix.length === 0;
|
|
649921
|
+
const suffixLooksAddressed = suffix.length === 0 || /^[,;:!?-]/.test(suffix) || /^(can|could|would|will|are|do|does|did|please|pls|help|tell|show|explain|check|look|stop|start|reply|respond)\b/i.test(suffix);
|
|
649922
|
+
return (prefixIsEmpty || prefixIsVocative) && suffixLooksAddressed;
|
|
649923
|
+
});
|
|
649924
|
+
if (anyDirect && !addressedOther) return "direct";
|
|
649925
|
+
const thirdPersonPattern = new RegExp(
|
|
649926
|
+
`\\b(to|about|for|from|with|against|via|using|mentioning|mentions|mentioned|tagging|tagged|responding\\s+to|replying\\s+to|talking\\s+to|talking\\s+about|stop\\s+responding\\s+to)\\s+@${telegramRegexEscape(username)}\\b`,
|
|
649927
|
+
"i"
|
|
649928
|
+
);
|
|
649929
|
+
if (thirdPersonPattern.test(text)) return "third_person";
|
|
649930
|
+
if (addressedOther) return "third_person";
|
|
649931
|
+
return anyDirect ? "direct" : "third_person";
|
|
649932
|
+
}
|
|
649782
649933
|
telegramMessageRepliesToBot(msg) {
|
|
649783
649934
|
const bot = this.state.botUsername.trim().replace(/^@/, "").toLowerCase();
|
|
649784
649935
|
const botUserId = this.currentTelegramBotUserId();
|
|
@@ -650904,8 +651055,12 @@ ${candidateFilter.join(",")}`;
|
|
|
650904
651055
|
const forcedRoute = this.interactionMode === "chat" || this.interactionMode === "action" ? this.interactionMode : null;
|
|
650905
651056
|
const isGroup = msg.chatType !== "private";
|
|
650906
651057
|
const identitySalienceSignals = this.telegramMessageIdentitySalienceSignals(msg);
|
|
650907
|
-
const addressesBot = identitySalienceSignals
|
|
651058
|
+
const addressesBot = this.telegramIdentitySalienceAddressesBot(identitySalienceSignals);
|
|
650908
651059
|
const sessionKey = this.sessionKeyForMessage(msg);
|
|
651060
|
+
const addressedOtherBot = this.telegramCurrentMessageAddressedToOtherBot(msg);
|
|
651061
|
+
const thirdPersonSelfMention = identitySalienceSignals.some(
|
|
651062
|
+
(signal) => signal.startsWith("third_person_mention:") || signal.startsWith("third_person_entity_mention:")
|
|
651063
|
+
);
|
|
650909
651064
|
const daydreamForceCheck = isGroup && this.shouldForceAnalysisFromChannelDaydream(sessionKey);
|
|
650910
651065
|
const stimulationProbe = this.stimulation.observe({
|
|
650911
651066
|
channelId: sessionKey,
|
|
@@ -650938,6 +651093,7 @@ ${candidateFilter.join(",")}`;
|
|
|
650938
651093
|
`Tool context: ${toolContext}`,
|
|
650939
651094
|
`Platform notification/direct-address signal (salience evidence only, not a decision): ${addressesBot ? "yes" : "no"}`,
|
|
650940
651095
|
`Platform salience signals (context only, not triggers): ${identitySalienceSignals.length ? identitySalienceSignals.join(", ") : "none"}`,
|
|
651096
|
+
addressedOtherBot && thirdPersonSelfMention ? `Identity-boundary observation: addressed to ${addressedOtherBot}; references this bot only in third person, so a visible reply from this bot is likely not expected.` : addressedOtherBot ? `Identity-boundary observation: addressed to ${addressedOtherBot}, a separate bot actor; do not answer as that bot.` : thirdPersonSelfMention ? `Identity-boundary observation: this bot is mentioned in third person; infer whether silence is more natural than replying.` : "",
|
|
650941
651097
|
`Current chat type: ${msg.chatType}`,
|
|
650942
651098
|
`Current sender: ${telegramSpeakerLabel(msg)} [${telegramActorKindLabel(msg)}]`,
|
|
650943
651099
|
this.formatTelegramDeliveryCapabilityContext(sessionKey, msg),
|
|
@@ -651013,6 +651169,7 @@ ${stimulationProbe.context}`,
|
|
|
651013
651169
|
`Reply discretion: make a human-like attention decision from the full social context. Observe the message, relationship stream, reply graph, conversation momentum, prior bot involvement, speaker intent, and notification-like signals, then decide whether a visible reply would be natural.`,
|
|
651014
651170
|
`No hard triggers: direct address, @mentions, name/identity references, private-chat delivery, replies, active threads, and stimulation score are evidence only. They may raise or lower salience, but none guarantees should_reply=true or should_reply=false.`,
|
|
651015
651171
|
`High-salience evidence: private DMs, exact @username matches, display-name self references, and replies to this bot are notification-like signals. They should usually move attention toward deeper processing and a likely response unless the surrounding context makes silence more natural.`,
|
|
651172
|
+
`Identity-boundary rule: third-person references to this bot, especially inside messages addressed to another bot, are context only and must not be treated as direct address.`,
|
|
651016
651173
|
`No keyword routing: do not use static keyword rules. Infer whether identity references are actually aimed at this bot from syntax, tone, recent turns, and relationships.`,
|
|
651017
651174
|
`Observation notes: omit note fields on the fast path. Do not expose hidden chain-of-thought or produce scratch notes in this router JSON.`,
|
|
651018
651175
|
`Reply-mode preference capture: if and only if the current sender explicitly expresses a durable preference for reply cadence/order, populate reply_mode_preference as a typed update. Do not infer this from style, keywords, tone, or one-off task shape. Use null otherwise.`,
|
|
@@ -652873,7 +653030,7 @@ Join: ${newUrl}`);
|
|
|
652873
653030
|
subAgent.typingInterval = null;
|
|
652874
653031
|
}
|
|
652875
653032
|
this.stopTelegramPublicProgressMessage(subAgent);
|
|
652876
|
-
const finalText =
|
|
653033
|
+
const finalText = this.cleanTelegramVisibleReplyForMessage(msg, result || "");
|
|
652877
653034
|
if (isAdminDM && !this.telegramAdminRunCompleted(subAgent)) {
|
|
652878
653035
|
const incompleteText = this.telegramAdminIncompleteRunText(subAgent, finalText);
|
|
652879
653036
|
this.subAgentViewCallbacks?.onWrite(subAgent.viewId, incompleteText);
|
|
@@ -653032,7 +653189,7 @@ Join: ${newUrl}`);
|
|
|
653032
653189
|
clearInterval(subAgent.typingInterval);
|
|
653033
653190
|
subAgent.typingInterval = null;
|
|
653034
653191
|
}
|
|
653035
|
-
const finalText =
|
|
653192
|
+
const finalText = this.cleanTelegramVisibleReplyForMessage(msg, result || "");
|
|
653036
653193
|
if (subAgent.liveMessagePromise) {
|
|
653037
653194
|
await subAgent.liveMessagePromise.catch(() => {
|
|
653038
653195
|
});
|
|
@@ -653199,7 +653356,7 @@ Join: ${newUrl}`);
|
|
|
653199
653356
|
clearInterval(typingInterval);
|
|
653200
653357
|
typingInterval = null;
|
|
653201
653358
|
}
|
|
653202
|
-
const cleaned =
|
|
653359
|
+
const cleaned = this.cleanTelegramVisibleReplyForMessage(msg, finalText || accumulated);
|
|
653203
653360
|
const pendingLiveMessage = liveMessagePromise;
|
|
653204
653361
|
if (pendingLiveMessage) {
|
|
653205
653362
|
await pendingLiveMessage.catch(() => {
|
|
@@ -687409,7 +687566,8 @@ ${result.summary}`
|
|
|
687409
687566
|
redirect: () => isOverlayActive() ? overlayWrite : isNeovimActive() ? writeToNeovimOutput : null,
|
|
687410
687567
|
dynamicBlockHost: () => statusBar.isActive && !isOverlayActive() && !isNeovimActive() ? {
|
|
687411
687568
|
registerDynamicBlock: (id, render2) => statusBar.registerDynamicBlock(id, render2),
|
|
687412
|
-
appendDynamicBlock: (id) => statusBar.appendDynamicBlock(id)
|
|
687569
|
+
appendDynamicBlock: (id) => statusBar.appendDynamicBlock(id),
|
|
687570
|
+
refreshDynamicBlocks: () => statusBar.refreshDisplay()
|
|
687413
687571
|
} : null
|
|
687414
687572
|
});
|
|
687415
687573
|
}
|
|
@@ -687419,7 +687577,8 @@ ${result.summary}`
|
|
|
687419
687577
|
redirect: () => isNeovimActive() ? writeToNeovimOutput : null,
|
|
687420
687578
|
dynamicBlockHost: () => statusBar.isActive && !isOverlayActive() && !isNeovimActive() ? {
|
|
687421
687579
|
registerDynamicBlock: (id, render2) => statusBar.registerDynamicBlock(id, render2),
|
|
687422
|
-
appendDynamicBlock: (id) => statusBar.appendDynamicBlock(id)
|
|
687580
|
+
appendDynamicBlock: (id) => statusBar.appendDynamicBlock(id),
|
|
687581
|
+
refreshDynamicBlocks: () => statusBar.refreshDisplay()
|
|
687423
687582
|
} : null
|
|
687424
687583
|
});
|
|
687425
687584
|
let resolvedContextWindowSize = 0;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.230",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.230",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED