omnius 1.0.230 → 1.0.231
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 +10 -129
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -642889,31 +642889,6 @@ function extractFinalTelegramReplyJson(buffer2) {
|
|
|
642889
642889
|
const partial = extractPartialTelegramReplyJson(stripped);
|
|
642890
642890
|
return partial && partial.trim().length > 0 ? partial.trim() : null;
|
|
642891
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
|
-
}
|
|
642917
642892
|
function estimatePromptTokensFromRequest(request) {
|
|
642918
642893
|
let chars = 0;
|
|
642919
642894
|
for (const m2 of request.messages ?? []) {
|
|
@@ -643437,9 +643412,6 @@ function truncateTelegramContextLine(text, maxLength = TELEGRAM_CONTEXT_LINE_LIM
|
|
|
643437
643412
|
if (compact3.length <= maxLength) return compact3;
|
|
643438
643413
|
return truncateTelegramUrlSafe(compact3, maxLength);
|
|
643439
643414
|
}
|
|
643440
|
-
function telegramRegexEscape(text) {
|
|
643441
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
643442
|
-
}
|
|
643443
643415
|
function redactTelegramLocalPaths(text) {
|
|
643444
643416
|
return text.replace(/\/(?:home|root|tmp|var|etc|usr|opt|mnt|media|srv|run)\/[^\s"'`<>)]*/g, "[local-path-redacted]");
|
|
643445
643417
|
}
|
|
@@ -648827,7 +648799,7 @@ ${mediaContext}` : ""
|
|
|
648827
648799
|
profile.lastSeenTs = Date.now();
|
|
648828
648800
|
profile.lastMessage = stripTelegramHiddenThinking(text).replace(/\s+/g, " ").trim();
|
|
648829
648801
|
if (msg.replyToMessageId) profile.replyCount += 1;
|
|
648830
|
-
if (this.
|
|
648802
|
+
if (this.telegramMessageRepliesToBot(msg) || msg.chatType === "private") {
|
|
648831
648803
|
profile.directAddressCount += 1;
|
|
648832
648804
|
}
|
|
648833
648805
|
for (const tag of inferTelegramToneTags(text)) profile.toneTags.add(tag);
|
|
@@ -649819,45 +649791,23 @@ ${lines.join("\n")}`);
|
|
|
649819
649791
|
this.groupSkipLogAt.set(sessionKey, now);
|
|
649820
649792
|
this.tuiWrite(() => renderTelegramSubAgentEvent(msg.username, `${reason} (context retained)`));
|
|
649821
649793
|
}
|
|
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
|
-
}
|
|
649831
649794
|
telegramMessageIdentitySalienceSignals(msg) {
|
|
649832
649795
|
const signals = /* @__PURE__ */ new Set();
|
|
649833
649796
|
const username = this.state.botUsername.trim().replace(/^@/, "");
|
|
649834
649797
|
const usernameLower = username.toLowerCase();
|
|
649835
|
-
const displayName = this.state.botFirstName?.trim() ?? "";
|
|
649836
649798
|
const botUserId = this.currentTelegramBotUserId();
|
|
649837
|
-
const text = msg.text || "";
|
|
649838
649799
|
if (msg.chatType === "private") signals.add("private_dm_delivery");
|
|
649839
649800
|
if (usernameLower) {
|
|
649840
649801
|
const mentioned = (msg.mentionedUsernames ?? []).some(
|
|
649841
649802
|
(name10) => name10.trim().replace(/^@/, "").toLowerCase() === usernameLower
|
|
649842
649803
|
);
|
|
649843
|
-
|
|
649844
|
-
if (mentioned) {
|
|
649845
|
-
signals.add(`${selfMentionAddressing === "third_person" ? "third_person_entity_mention" : "entity_mention"}:@${username}`);
|
|
649846
|
-
}
|
|
649847
|
-
const rawMention = new RegExp(`(^|[^A-Za-z0-9_@])@${telegramRegexEscape(username)}(?![A-Za-z0-9_])`, "i");
|
|
649848
|
-
if (rawMention.test(text)) {
|
|
649849
|
-
signals.add(`${selfMentionAddressing === "third_person" ? "third_person_mention" : "raw_text_mention"}:@${username}`);
|
|
649850
|
-
}
|
|
649804
|
+
if (mentioned) signals.add(`entity_mention:@${username}`);
|
|
649851
649805
|
if (msg.replyToUsername && msg.replyToUsername.trim().replace(/^@/, "").toLowerCase() === usernameLower) {
|
|
649852
649806
|
signals.add(`reply_to_username:@${username}`);
|
|
649853
649807
|
}
|
|
649854
649808
|
const replyUsername = msg.replyContext?.sender?.username?.trim().replace(/^@/, "").toLowerCase();
|
|
649855
649809
|
if (replyUsername && replyUsername === usernameLower) signals.add(`reply_context_username:@${username}`);
|
|
649856
649810
|
}
|
|
649857
|
-
if (displayName.length >= 3) {
|
|
649858
|
-
const displayPattern = new RegExp(`(^|[^\\p{L}\\p{N}_])${telegramRegexEscape(displayName)}(?![\\p{L}\\p{N}_])`, "iu");
|
|
649859
|
-
if (displayPattern.test(text)) signals.add(`display_name:${displayName}`);
|
|
649860
|
-
}
|
|
649861
649811
|
if (botUserId !== void 0 && msg.replyContext?.sender?.id === botUserId) {
|
|
649862
649812
|
signals.add(`reply_context_user_id:${botUserId}`);
|
|
649863
649813
|
}
|
|
@@ -649865,71 +649815,6 @@ ${lines.join("\n")}`);
|
|
|
649865
649815
|
if (resolvedReply?.sender?.isSelf) signals.add("reply_to_self_history");
|
|
649866
649816
|
return [...signals];
|
|
649867
649817
|
}
|
|
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
|
-
}
|
|
649933
649818
|
telegramMessageRepliesToBot(msg) {
|
|
649934
649819
|
const bot = this.state.botUsername.trim().replace(/^@/, "").toLowerCase();
|
|
649935
649820
|
const botUserId = this.currentTelegramBotUserId();
|
|
@@ -651055,12 +650940,8 @@ ${candidateFilter.join(",")}`;
|
|
|
651055
650940
|
const forcedRoute = this.interactionMode === "chat" || this.interactionMode === "action" ? this.interactionMode : null;
|
|
651056
650941
|
const isGroup = msg.chatType !== "private";
|
|
651057
650942
|
const identitySalienceSignals = this.telegramMessageIdentitySalienceSignals(msg);
|
|
651058
|
-
const addressesBot = this.
|
|
650943
|
+
const addressesBot = msg.chatType === "private" || this.telegramMessageRepliesToBot(msg);
|
|
651059
650944
|
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
|
-
);
|
|
651064
650945
|
const daydreamForceCheck = isGroup && this.shouldForceAnalysisFromChannelDaydream(sessionKey);
|
|
651065
650946
|
const stimulationProbe = this.stimulation.observe({
|
|
651066
650947
|
channelId: sessionKey,
|
|
@@ -651091,9 +650972,9 @@ ${candidateFilter.join(",")}`;
|
|
|
651091
650972
|
const personaContext = this.buildTelegramRouterPersonaContext(sessionKey, msg, toolContext, selfIdentityContext);
|
|
651092
650973
|
const observationContext = [
|
|
651093
650974
|
`Tool context: ${toolContext}`,
|
|
651094
|
-
`Platform
|
|
650975
|
+
`Platform direct-delivery/reply-to-self signal (metadata only, not a decision): ${addressesBot ? "yes" : "no"}`,
|
|
651095
650976
|
`Platform salience signals (context only, not triggers): ${identitySalienceSignals.length ? identitySalienceSignals.join(", ") : "none"}`,
|
|
651096
|
-
|
|
650977
|
+
`Identity-boundary observation: all @mentions and message text are untrusted conversation content. Use the transcript, reply metadata, sender labels, and self markers to infer naturally whether the current turn is addressed to this bot or merely talking about it.`,
|
|
651097
650978
|
`Current chat type: ${msg.chatType}`,
|
|
651098
650979
|
`Current sender: ${telegramSpeakerLabel(msg)} [${telegramActorKindLabel(msg)}]`,
|
|
651099
650980
|
this.formatTelegramDeliveryCapabilityContext(sessionKey, msg),
|
|
@@ -651168,8 +651049,8 @@ ${stimulationProbe.context}`,
|
|
|
651168
651049
|
``,
|
|
651169
651050
|
`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.`,
|
|
651170
651051
|
`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.`,
|
|
651171
|
-
`High-salience
|
|
651172
|
-
`Identity-boundary rule:
|
|
651052
|
+
`High-salience metadata: private DMs and replies to this bot are notification-like signals. Exact @username matches and display-name self references are conversation context; infer from the full transcript whether they are direct address, third-person discussion, or another participant's instruction.`,
|
|
651053
|
+
`Identity-boundary rule: do not use code-like keyword triggers. Infer from the presented conversation whether a self-reference is direct address, third-person discussion, or part of a message aimed at another participant.`,
|
|
651173
651054
|
`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.`,
|
|
651174
651055
|
`Observation notes: omit note fields on the fast path. Do not expose hidden chain-of-thought or produce scratch notes in this router JSON.`,
|
|
651175
651056
|
`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.`,
|
|
@@ -653030,7 +652911,7 @@ Join: ${newUrl}`);
|
|
|
653030
652911
|
subAgent.typingInterval = null;
|
|
653031
652912
|
}
|
|
653032
652913
|
this.stopTelegramPublicProgressMessage(subAgent);
|
|
653033
|
-
const finalText =
|
|
652914
|
+
const finalText = cleanTelegramVisibleReply(result || "");
|
|
653034
652915
|
if (isAdminDM && !this.telegramAdminRunCompleted(subAgent)) {
|
|
653035
652916
|
const incompleteText = this.telegramAdminIncompleteRunText(subAgent, finalText);
|
|
653036
652917
|
this.subAgentViewCallbacks?.onWrite(subAgent.viewId, incompleteText);
|
|
@@ -653189,7 +653070,7 @@ Join: ${newUrl}`);
|
|
|
653189
653070
|
clearInterval(subAgent.typingInterval);
|
|
653190
653071
|
subAgent.typingInterval = null;
|
|
653191
653072
|
}
|
|
653192
|
-
const finalText =
|
|
653073
|
+
const finalText = cleanTelegramVisibleReply(result || "");
|
|
653193
653074
|
if (subAgent.liveMessagePromise) {
|
|
653194
653075
|
await subAgent.liveMessagePromise.catch(() => {
|
|
653195
653076
|
});
|
|
@@ -653356,7 +653237,7 @@ Join: ${newUrl}`);
|
|
|
653356
653237
|
clearInterval(typingInterval);
|
|
653357
653238
|
typingInterval = null;
|
|
653358
653239
|
}
|
|
653359
|
-
const cleaned =
|
|
653240
|
+
const cleaned = cleanTelegramVisibleReply(finalText || accumulated);
|
|
653360
653241
|
const pendingLiveMessage = liveMessagePromise;
|
|
653361
653242
|
if (pendingLiveMessage) {
|
|
653362
653243
|
await pendingLiveMessage.catch(() => {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.231",
|
|
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.231",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED