omnius 1.0.130 → 1.0.131
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 +117 -47
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -617912,6 +617912,8 @@ External acquisition contract:
|
|
|
617912
617912
|
adminUserId = null;
|
|
617913
617913
|
/** Active sub-agents by chat/guest session key */
|
|
617914
617914
|
subAgents = /* @__PURE__ */ new Map();
|
|
617915
|
+
/** Debounced live-context packets for messages arriving during a runner. */
|
|
617916
|
+
telegramSubAgentContextBuffers = /* @__PURE__ */ new Map();
|
|
617915
617917
|
/** Active direct chat completions, counted with Telegram activity in the TUI */
|
|
617916
617918
|
activeChatViews = /* @__PURE__ */ new Set();
|
|
617917
617919
|
/** Lightweight chat history by chat/guest session key */
|
|
@@ -618431,6 +618433,101 @@ No scoped reflection artifact exists yet for this chat. Use <code>/reflect</code
|
|
|
618431
618433
|
canUseChatActions(msg) {
|
|
618432
618434
|
return !msg.guestQueryId && (typeof msg.chatId === "number" || String(msg.chatId).startsWith("@"));
|
|
618433
618435
|
}
|
|
618436
|
+
telegramSubAgentContextFlushMs() {
|
|
618437
|
+
const raw = process.env["OMNIUS_TG_SUBAGENT_CONTEXT_FLUSH_MS"];
|
|
618438
|
+
if (raw === "off") return 0;
|
|
618439
|
+
const parsed = raw !== void 0 ? Number(raw) : 650;
|
|
618440
|
+
if (!Number.isFinite(parsed)) return 650;
|
|
618441
|
+
return Math.max(0, Math.min(5e3, Math.floor(parsed)));
|
|
618442
|
+
}
|
|
618443
|
+
clearTelegramSubAgentContextBuffer(sessionKey) {
|
|
618444
|
+
const buffer2 = this.telegramSubAgentContextBuffers.get(sessionKey);
|
|
618445
|
+
if (buffer2?.timer) clearTimeout(buffer2.timer);
|
|
618446
|
+
this.telegramSubAgentContextBuffers.delete(sessionKey);
|
|
618447
|
+
}
|
|
618448
|
+
clearAllTelegramSubAgentContextBuffers() {
|
|
618449
|
+
for (const key of this.telegramSubAgentContextBuffers.keys()) {
|
|
618450
|
+
this.clearTelegramSubAgentContextBuffer(key);
|
|
618451
|
+
}
|
|
618452
|
+
}
|
|
618453
|
+
formatTelegramSubAgentContextPacket(messages2) {
|
|
618454
|
+
const recent = messages2.slice(-12);
|
|
618455
|
+
const dropped = messages2.length - recent.length;
|
|
618456
|
+
return [
|
|
618457
|
+
"[Telegram live context update]",
|
|
618458
|
+
"These Telegram messages arrived while this runner was already active. Treat them as added context, not a new task. Continue the current work and only adjust the reply if the update is directly relevant.",
|
|
618459
|
+
dropped > 0 ? `Older buffered updates omitted from this packet: ${dropped}.` : "",
|
|
618460
|
+
...recent.map((message2, index) => `### Update ${index + 1}
|
|
618461
|
+
${message2}`)
|
|
618462
|
+
].filter(Boolean).join("\n\n");
|
|
618463
|
+
}
|
|
618464
|
+
enqueueTelegramSubAgentContext(sessionKey, subAgent, context2, username) {
|
|
618465
|
+
let buffer2 = this.telegramSubAgentContextBuffers.get(sessionKey);
|
|
618466
|
+
if (!buffer2) {
|
|
618467
|
+
buffer2 = { messages: [], timer: null };
|
|
618468
|
+
this.telegramSubAgentContextBuffers.set(sessionKey, buffer2);
|
|
618469
|
+
}
|
|
618470
|
+
buffer2.messages.push(context2);
|
|
618471
|
+
const flushMs = this.telegramSubAgentContextFlushMs();
|
|
618472
|
+
if (buffer2.timer) return;
|
|
618473
|
+
buffer2.timer = setTimeout(() => {
|
|
618474
|
+
this.flushTelegramSubAgentContextBuffer(sessionKey, username);
|
|
618475
|
+
}, flushMs);
|
|
618476
|
+
if (typeof buffer2.timer.unref === "function") buffer2.timer.unref();
|
|
618477
|
+
this.subAgentViewCallbacks?.onWrite(
|
|
618478
|
+
subAgent.viewId,
|
|
618479
|
+
`live context queued (${buffer2.messages.length} buffered)`
|
|
618480
|
+
);
|
|
618481
|
+
}
|
|
618482
|
+
flushTelegramSubAgentContextBuffer(sessionKey, username = "telegram") {
|
|
618483
|
+
const buffer2 = this.telegramSubAgentContextBuffers.get(sessionKey);
|
|
618484
|
+
if (!buffer2) return;
|
|
618485
|
+
if (buffer2.timer) clearTimeout(buffer2.timer);
|
|
618486
|
+
this.telegramSubAgentContextBuffers.delete(sessionKey);
|
|
618487
|
+
if (buffer2.messages.length === 0) return;
|
|
618488
|
+
const subAgent = this.subAgents.get(sessionKey);
|
|
618489
|
+
if (!subAgent || subAgent.aborted) return;
|
|
618490
|
+
const packet = this.formatTelegramSubAgentContextPacket(buffer2.messages);
|
|
618491
|
+
if (subAgent.runner) {
|
|
618492
|
+
subAgent.runner.injectUserMessage(packet);
|
|
618493
|
+
this.tuiWrite(() => renderTelegramSubAgentEvent(
|
|
618494
|
+
username,
|
|
618495
|
+
`live context consolidated (${buffer2.messages.length} message${buffer2.messages.length === 1 ? "" : "s"})`
|
|
618496
|
+
));
|
|
618497
|
+
this.subAgentViewCallbacks?.onWrite(
|
|
618498
|
+
subAgent.viewId,
|
|
618499
|
+
`live context injected (${buffer2.messages.length} message${buffer2.messages.length === 1 ? "" : "s"})`
|
|
618500
|
+
);
|
|
618501
|
+
} else {
|
|
618502
|
+
subAgent.pendingMessages.push(packet);
|
|
618503
|
+
this.subAgentViewCallbacks?.onWrite(
|
|
618504
|
+
subAgent.viewId,
|
|
618505
|
+
`live context staged (${buffer2.messages.length} message${buffer2.messages.length === 1 ? "" : "s"})`
|
|
618506
|
+
);
|
|
618507
|
+
}
|
|
618508
|
+
}
|
|
618509
|
+
async enqueueTelegramMessageForExistingSubAgent(msg, subAgent) {
|
|
618510
|
+
const sessionKey = this.sessionKeyForMessage(msg);
|
|
618511
|
+
let mediaContext = "";
|
|
618512
|
+
if (msg.media || msg.replyToMedia) {
|
|
618513
|
+
mediaContext = await this.processMediaContextForMessage(msg);
|
|
618514
|
+
}
|
|
618515
|
+
const isGroup = msg.chatType !== "private";
|
|
618516
|
+
const chatLabel = isGroup ? ` in group "${msg.chatTitle || "unknown"}"` : "";
|
|
618517
|
+
const context2 = this.formatTelegramCurrentMessageForPrompt(
|
|
618518
|
+
sessionKey,
|
|
618519
|
+
msg,
|
|
618520
|
+
`Telegram live context from @${msg.username}${chatLabel}`,
|
|
618521
|
+
mediaContext
|
|
618522
|
+
);
|
|
618523
|
+
if (isGroup) {
|
|
618524
|
+
this.markLastTelegramUserMessageMode(msg, "steering");
|
|
618525
|
+
} else {
|
|
618526
|
+
this.recordTelegramUserMessage(msg, "steering", context2);
|
|
618527
|
+
}
|
|
618528
|
+
this.enqueueTelegramSubAgentContext(sessionKey, subAgent, context2, msg.username);
|
|
618529
|
+
this.tuiWrite(() => renderTelegramSubAgentEvent(msg.username, "live context queued for active Telegram runner"));
|
|
618530
|
+
}
|
|
618434
618531
|
async replyWithTelegramHelp(msg, isAdmin) {
|
|
618435
618532
|
const scope = isAdmin ? "admin" : "public";
|
|
618436
618533
|
const menu = renderHelpMenu(scope);
|
|
@@ -622559,6 +622656,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`);
|
|
|
622559
622656
|
}
|
|
622560
622657
|
this.stopTelegramSubAgentWatchdog();
|
|
622561
622658
|
this.cancelTelegramRouterSessionState("bridge stop");
|
|
622659
|
+
this.clearAllTelegramSubAgentContextBuffers();
|
|
622562
622660
|
this.telegramActiveInferences.clear();
|
|
622563
622661
|
if (this.telegramSqliteDb && this.telegramSqliteDb !== false) {
|
|
622564
622662
|
try {
|
|
@@ -622887,50 +622985,7 @@ Join: ${newUrl}`);
|
|
|
622887
622985
|
}
|
|
622888
622986
|
const existing = this.subAgents.get(sessionKey);
|
|
622889
622987
|
if (existing && !existing.aborted) {
|
|
622890
|
-
|
|
622891
|
-
if (isGroup) {
|
|
622892
|
-
const attentionViewId2 = this.registerTelegramAttentionView(msg, existing.toolContext || toolContext, "active Telegram thread");
|
|
622893
|
-
const decision3 = await this.inferTelegramInteractionDecisionCoalesced(msg, existing.toolContext || toolContext);
|
|
622894
|
-
this.deliverTelegramAttentionDecision(
|
|
622895
|
-
sessionKey,
|
|
622896
|
-
msg,
|
|
622897
|
-
attentionViewId2,
|
|
622898
|
-
decision3,
|
|
622899
|
-
this.telegramMessageIdentitySalienceSignals(msg),
|
|
622900
|
-
this.markLatestTelegramDaydreamOpportunitiesConsidered(sessionKey, msg)
|
|
622901
|
-
);
|
|
622902
|
-
this.markLastTelegramUserMessageMode(msg, decision3.shouldReply ? "steering" : "ambient");
|
|
622903
|
-
this.subAgentViewCallbacks?.onWrite(
|
|
622904
|
-
existing.viewId,
|
|
622905
|
-
`live steering: ${decision3.shouldReply ? decision3.route : "no_reply"} (${decision3.source}, confidence ${decision3.confidence.toFixed(2)}): ${decision3.reason}`
|
|
622906
|
-
);
|
|
622907
|
-
if (!decision3.shouldReply) {
|
|
622908
|
-
this.maybeLogTelegramGroupSkip(msg, `live inference: no steering — ${decision3.reason}`);
|
|
622909
|
-
return;
|
|
622910
|
-
}
|
|
622911
|
-
}
|
|
622912
|
-
let mediaContext = "";
|
|
622913
|
-
if (msg.media || msg.replyToMedia) {
|
|
622914
|
-
mediaContext = await this.processMediaContextForMessage(msg);
|
|
622915
|
-
}
|
|
622916
|
-
const steeringText = this.formatTelegramCurrentMessageForPrompt(
|
|
622917
|
-
sessionKey,
|
|
622918
|
-
msg,
|
|
622919
|
-
`Telegram steering message from @${msg.username}`,
|
|
622920
|
-
mediaContext
|
|
622921
|
-
);
|
|
622922
|
-
if (isGroup) {
|
|
622923
|
-
this.markLastTelegramUserMessageMode(msg, "steering");
|
|
622924
|
-
} else {
|
|
622925
|
-
this.recordTelegramUserMessage(msg, "steering", steeringText);
|
|
622926
|
-
}
|
|
622927
|
-
if (existing.runner) {
|
|
622928
|
-
existing.runner.injectUserMessage(steeringText);
|
|
622929
|
-
this.tuiWrite(() => renderTelegramSubAgentEvent(msg.username, "mid-conversation steering injected"));
|
|
622930
|
-
} else {
|
|
622931
|
-
existing.pendingMessages.push(steeringText);
|
|
622932
|
-
this.tuiWrite(() => renderTelegramSubAgentEvent(msg.username, `queued (${existing.pendingMessages.length} pending)`));
|
|
622933
|
-
}
|
|
622988
|
+
await this.enqueueTelegramMessageForExistingSubAgent(msg, existing);
|
|
622934
622989
|
return;
|
|
622935
622990
|
}
|
|
622936
622991
|
const attentionViewId = this.registerTelegramAttentionView(msg, toolContext);
|
|
@@ -622952,7 +623007,20 @@ Join: ${newUrl}`);
|
|
|
622952
623007
|
this.maybeLogTelegramGroupSkip(msg, `live inference: no reply — ${decision2.reason}`);
|
|
622953
623008
|
return;
|
|
622954
623009
|
}
|
|
622955
|
-
|
|
623010
|
+
const existingAfterDecision = this.subAgents.get(sessionKey);
|
|
623011
|
+
if (existingAfterDecision && !existingAfterDecision.aborted) {
|
|
623012
|
+
this.subAgentViewCallbacks?.onWrite(
|
|
623013
|
+
existingAfterDecision.viewId,
|
|
623014
|
+
`live route consolidated: ${decision2.route} (${decision2.source}, confidence ${decision2.confidence.toFixed(2)}): ${decision2.reason}`
|
|
623015
|
+
);
|
|
623016
|
+
await this.enqueueTelegramMessageForExistingSubAgent(
|
|
623017
|
+
msg,
|
|
623018
|
+
existingAfterDecision
|
|
623019
|
+
);
|
|
623020
|
+
return;
|
|
623021
|
+
}
|
|
623022
|
+
const subAgentProfile = decision2.route === "chat" ? "chat" : "action";
|
|
623023
|
+
if (decision2.route === "chat" && msg.chatType === "private") {
|
|
622956
623024
|
await this.handleTelegramChatCompletion(msg, toolContext);
|
|
622957
623025
|
return;
|
|
622958
623026
|
}
|
|
@@ -623005,7 +623073,7 @@ Join: ${newUrl}`);
|
|
|
623005
623073
|
if (msg.media || msg.replyToMedia) {
|
|
623006
623074
|
mediaContext = await this.processMediaContextForMessage(msg);
|
|
623007
623075
|
}
|
|
623008
|
-
const result = await this.runSubAgent(msg, subAgent, mediaContext);
|
|
623076
|
+
const result = await this.runSubAgent(msg, subAgent, mediaContext, subAgentProfile);
|
|
623009
623077
|
if (subAgent.typingInterval) {
|
|
623010
623078
|
clearInterval(subAgent.typingInterval);
|
|
623011
623079
|
subAgent.typingInterval = null;
|
|
@@ -623031,7 +623099,7 @@ Join: ${newUrl}`);
|
|
|
623031
623099
|
}
|
|
623032
623100
|
const finalHtml = convertMarkdownToTelegramHTML(finalText);
|
|
623033
623101
|
const sentMessageId = await this.sendOrEditFinalTelegramHTML(msg, finalHtml, subAgent.liveMessageId);
|
|
623034
|
-
this.recordTelegramAssistantMessage(msg, finalText,
|
|
623102
|
+
this.recordTelegramAssistantMessage(msg, finalText, subAgentProfile, {
|
|
623035
623103
|
messageId: sentMessageId,
|
|
623036
623104
|
replyToMessageId: msg.chatType !== "private" ? msg.messageId : void 0
|
|
623037
623105
|
});
|
|
@@ -623062,6 +623130,7 @@ Join: ${newUrl}`);
|
|
|
623062
623130
|
});
|
|
623063
623131
|
}
|
|
623064
623132
|
} finally {
|
|
623133
|
+
this.clearTelegramSubAgentContextBuffer(sessionKey);
|
|
623065
623134
|
this.subAgents.delete(sessionKey);
|
|
623066
623135
|
this.refreshActiveTelegramInteractionCount();
|
|
623067
623136
|
this.subAgentViewCallbacks?.onComplete(subAgent.viewId);
|
|
@@ -623172,6 +623241,7 @@ Join: ${newUrl}`);
|
|
|
623172
623241
|
});
|
|
623173
623242
|
}
|
|
623174
623243
|
} finally {
|
|
623244
|
+
this.clearTelegramSubAgentContextBuffer(sessionKey);
|
|
623175
623245
|
this.subAgents.delete(sessionKey);
|
|
623176
623246
|
this.refreshActiveTelegramInteractionCount();
|
|
623177
623247
|
this.subAgentViewCallbacks?.onComplete(subAgent.viewId);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.131",
|
|
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.131",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED