omnius 1.0.138 → 1.0.140
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 +118 -40
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -534044,6 +534044,14 @@ var init_episodeStore = __esm({
|
|
|
534044
534044
|
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_ep_tool ON episodes(tool_name)`);
|
|
534045
534045
|
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_ep_decay ON episodes(decay_class)`);
|
|
534046
534046
|
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_ep_hash ON episodes(content_hash, session_id)`);
|
|
534047
|
+
try {
|
|
534048
|
+
this.db.exec(`
|
|
534049
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_ep_hash_unique
|
|
534050
|
+
ON episodes(content_hash, COALESCE(session_id, ''), COALESCE(tool_name, ''))
|
|
534051
|
+
WHERE content_hash IS NOT NULL AND content_hash != ''
|
|
534052
|
+
`);
|
|
534053
|
+
} catch {
|
|
534054
|
+
}
|
|
534047
534055
|
try {
|
|
534048
534056
|
this.db.exec(`ALTER TABLE episodes ADD COLUMN clip_embedding BLOB`);
|
|
534049
534057
|
} catch {
|
|
@@ -534371,6 +534379,21 @@ var init_temporalGraph = __esm({
|
|
|
534371
534379
|
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_kge_src ON kg_edges(src_id)`);
|
|
534372
534380
|
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_kge_dst ON kg_edges(dst_id)`);
|
|
534373
534381
|
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_kge_valid ON kg_edges(valid_from, valid_until)`);
|
|
534382
|
+
try {
|
|
534383
|
+
this.db.exec(`
|
|
534384
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_kgn_unique
|
|
534385
|
+
ON kg_nodes(LOWER(text), node_type)
|
|
534386
|
+
`);
|
|
534387
|
+
} catch {
|
|
534388
|
+
}
|
|
534389
|
+
try {
|
|
534390
|
+
this.db.exec(`
|
|
534391
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_kge_active_unique
|
|
534392
|
+
ON kg_edges(src_id, dst_id, relation, COALESCE(fact, ''), COALESCE(modality, 'text'))
|
|
534393
|
+
WHERE valid_until IS NULL
|
|
534394
|
+
`);
|
|
534395
|
+
} catch {
|
|
534396
|
+
}
|
|
534374
534397
|
this.db.pragma("journal_mode = WAL");
|
|
534375
534398
|
this.db.pragma("synchronous = NORMAL");
|
|
534376
534399
|
}
|
|
@@ -623339,41 +623362,52 @@ ${mediaContext}` : ""
|
|
|
623339
623362
|
const recentActions = memory.actions.filter(
|
|
623340
623363
|
(action) => action.userId === msg.fromUserId || !!currentUsername && action.username?.replace(/^@/, "").toLowerCase() === currentUsername || action.role === "assistant"
|
|
623341
623364
|
).slice(-8);
|
|
623342
|
-
const
|
|
623365
|
+
const lines = [];
|
|
623366
|
+
const userFactIds = /* @__PURE__ */ new Set();
|
|
623343
623367
|
if (userEntries.length > 0) {
|
|
623344
|
-
|
|
623345
|
-
|
|
623346
|
-
const
|
|
623347
|
-
const topics = user.recentTopics.slice(-
|
|
623348
|
-
|
|
623349
|
-
|
|
623350
|
-
|
|
623351
|
-
|
|
623352
|
-
|
|
623353
|
-
});
|
|
623354
|
-
sections.push(`### Durable Associative User Memory
|
|
623355
|
-
${lines.join("\n")}`);
|
|
623368
|
+
lines.push("**Per-user memory (compact):**");
|
|
623369
|
+
for (const [, user] of userEntries) {
|
|
623370
|
+
const label = user.username && user.username !== "unknown" ? `@${user.username}` : user.displayName || "user";
|
|
623371
|
+
const topics = user.recentTopics.slice(-3).join(", ") || "—";
|
|
623372
|
+
const factCount = user.facts.length;
|
|
623373
|
+
const relCount = user.relationshipHints.length;
|
|
623374
|
+
lines.push(`- ${label} [${telegramActorKindLabel(user)}]${user.userId ? ` id:${user.userId}` : ""}: msgs:${user.messageCount}, facts:${factCount}, relations:${relCount}, topics:${topics}`);
|
|
623375
|
+
for (const f2 of user.facts) userFactIds.add(f2.id ?? f2.text);
|
|
623376
|
+
}
|
|
623356
623377
|
}
|
|
623357
623378
|
if (scoredFacts.length > 0) {
|
|
623358
|
-
const
|
|
623359
|
-
|
|
623360
|
-
)
|
|
623361
|
-
|
|
623362
|
-
|
|
623379
|
+
const seenText = /* @__PURE__ */ new Set();
|
|
623380
|
+
const factLines = [];
|
|
623381
|
+
for (const { fact, score } of scoredFacts) {
|
|
623382
|
+
const text = fact.text;
|
|
623383
|
+
if (!text || seenText.has(text)) continue;
|
|
623384
|
+
seenText.add(text);
|
|
623385
|
+
factLines.push(`- (${score.toFixed(2)}) ${telegramContextJsonString(text, 260)}`);
|
|
623386
|
+
}
|
|
623387
|
+
if (factLines.length > 0) {
|
|
623388
|
+
if (lines.length > 0) lines.push("");
|
|
623389
|
+
lines.push("**Top scored facts:**");
|
|
623390
|
+
lines.push(...factLines);
|
|
623391
|
+
}
|
|
623363
623392
|
}
|
|
623364
623393
|
if (relationshipFacts.length > 0) {
|
|
623365
|
-
const
|
|
623366
|
-
|
|
623367
|
-
|
|
623368
|
-
|
|
623369
|
-
|
|
623370
|
-
|
|
623371
|
-
|
|
623372
|
-
)
|
|
623373
|
-
|
|
623374
|
-
|
|
623394
|
+
const seenText = /* @__PURE__ */ new Set();
|
|
623395
|
+
const relLines = [];
|
|
623396
|
+
for (const f2 of relationshipFacts.slice(0, 4)) {
|
|
623397
|
+
if (!f2.text || seenText.has(f2.text)) continue;
|
|
623398
|
+
seenText.add(f2.text);
|
|
623399
|
+
relLines.push(`- ${telegramContextJsonString(f2.text, 240)}`);
|
|
623400
|
+
}
|
|
623401
|
+
if (relLines.length > 0) {
|
|
623402
|
+
if (lines.length > 0) lines.push("");
|
|
623403
|
+
lines.push("**Relationship edges:**");
|
|
623404
|
+
lines.push(...relLines);
|
|
623405
|
+
}
|
|
623375
623406
|
}
|
|
623376
|
-
|
|
623407
|
+
void recentActions;
|
|
623408
|
+
if (lines.length === 0) return "";
|
|
623409
|
+
return `### Associative Memory (deduplicated single view)
|
|
623410
|
+
${lines.join("\n")}`;
|
|
623377
623411
|
}
|
|
623378
623412
|
relevantTelegramSqliteMirrorContext(sessionKey, msg, limit = 12) {
|
|
623379
623413
|
const db = this.telegramDb();
|
|
@@ -625011,6 +625045,39 @@ ${stimulationProbe.context}`,
|
|
|
625011
625045
|
`Current Telegram message text (untrusted user data):
|
|
625012
625046
|
${this.quoteTelegramContextBlock(msg.text, 1200)}`
|
|
625013
625047
|
].filter(Boolean).join("\n");
|
|
625048
|
+
if (process.env["OMNIUS_TG_DUMP_PROMPT"]) {
|
|
625049
|
+
try {
|
|
625050
|
+
const dumpDir = process.env["OMNIUS_TG_DUMP_PROMPT"] === "1" ? "/tmp" : process.env["OMNIUS_TG_DUMP_PROMPT"];
|
|
625051
|
+
const fs11 = await import("node:fs");
|
|
625052
|
+
const path12 = await import("node:path");
|
|
625053
|
+
try {
|
|
625054
|
+
fs11.mkdirSync(dumpDir, { recursive: true });
|
|
625055
|
+
} catch {
|
|
625056
|
+
}
|
|
625057
|
+
const filename = `omnius-router-prompt-${Date.now()}-${sessionKey.replace(/[^a-zA-Z0-9_-]/g, "_")}.txt`;
|
|
625058
|
+
const dumpFile = path12.join(dumpDir, filename);
|
|
625059
|
+
const sections = userPrompt.split(/\n(?=## |### )/);
|
|
625060
|
+
const breakdown = sections.map((s2) => {
|
|
625061
|
+
const firstLine = s2.split("\n")[0].slice(0, 80);
|
|
625062
|
+
return ` [${s2.length.toString().padStart(6)} bytes / ~${Math.ceil(s2.length / 4).toString().padStart(5)} tok] ${firstLine}`;
|
|
625063
|
+
}).join("\n");
|
|
625064
|
+
const header = [
|
|
625065
|
+
`# Omnius Telegram Router Prompt Dump`,
|
|
625066
|
+
`# session_key: ${sessionKey}`,
|
|
625067
|
+
`# msg.username: ${msg.username || "(none)"}`,
|
|
625068
|
+
`# msg.chatType: ${msg.chatType}`,
|
|
625069
|
+
`# msg.text: ${JSON.stringify((msg.text || "").slice(0, 200))}`,
|
|
625070
|
+
`# total user-prompt bytes: ${userPrompt.length}`,
|
|
625071
|
+
`# total user-prompt tokens (est, 4 char/tok): ~${Math.ceil(userPrompt.length / 4)}`,
|
|
625072
|
+
`# section breakdown (descending size will identify the largest emitter):`,
|
|
625073
|
+
breakdown,
|
|
625074
|
+
`# ─────────────────────────────────────────────────────`,
|
|
625075
|
+
``
|
|
625076
|
+
].join("\n");
|
|
625077
|
+
fs11.writeFileSync(dumpFile, header + userPrompt, "utf8");
|
|
625078
|
+
} catch {
|
|
625079
|
+
}
|
|
625080
|
+
}
|
|
625014
625081
|
const diagnostics = {};
|
|
625015
625082
|
const routerStartMs = Date.now();
|
|
625016
625083
|
try {
|
|
@@ -626338,11 +626405,7 @@ Join: ${newUrl}`);
|
|
|
626338
626405
|
lastEditMs = now;
|
|
626339
626406
|
const html = renderTelegramLiveProgressHTML(progressLines, accumulated);
|
|
626340
626407
|
if (!html.trim()) return;
|
|
626341
|
-
|
|
626342
|
-
msg.chatId,
|
|
626343
|
-
liveMessageId,
|
|
626344
|
-
html
|
|
626345
|
-
).catch(() => {
|
|
626408
|
+
void this.editLiveMessage(msg.chatId, liveMessageId, html).catch(() => {
|
|
626346
626409
|
});
|
|
626347
626410
|
} else if (!liveMessageId && !liveMessagePromise && !msg.guestQueryId) {
|
|
626348
626411
|
const html = renderTelegramLiveProgressHTML(progressLines, accumulated);
|
|
@@ -626358,7 +626421,6 @@ Join: ${newUrl}`);
|
|
|
626358
626421
|
}).finally(() => {
|
|
626359
626422
|
liveMessagePromise = null;
|
|
626360
626423
|
});
|
|
626361
|
-
await liveMessagePromise;
|
|
626362
626424
|
}
|
|
626363
626425
|
}
|
|
626364
626426
|
}
|
|
@@ -626496,6 +626558,7 @@ ${conversationStream}`
|
|
|
626496
626558
|
try {
|
|
626497
626559
|
if (stream && typeof stream[Symbol.asyncIterator] === "function") {
|
|
626498
626560
|
try {
|
|
626561
|
+
let lastTokenEmitMs = 0;
|
|
626499
626562
|
for await (const chunk of stream) {
|
|
626500
626563
|
if (chunk.type !== "content") continue;
|
|
626501
626564
|
const piece = chunk.content;
|
|
@@ -626512,8 +626575,19 @@ ${conversationStream}`
|
|
|
626512
626575
|
} else {
|
|
626513
626576
|
this.bumpTelegramInferenceTokens(inferenceId, 1, 0);
|
|
626514
626577
|
accumulated += piece;
|
|
626515
|
-
const
|
|
626516
|
-
if (
|
|
626578
|
+
const now = Date.now();
|
|
626579
|
+
if (now - lastTokenEmitMs > 120) {
|
|
626580
|
+
lastTokenEmitMs = now;
|
|
626581
|
+
const partial = extractPartialTelegramReplyJson(accumulated);
|
|
626582
|
+
if (partial !== null) void onToken(partial);
|
|
626583
|
+
}
|
|
626584
|
+
}
|
|
626585
|
+
}
|
|
626586
|
+
const finalPartial = extractPartialTelegramReplyJson(accumulated);
|
|
626587
|
+
if (finalPartial !== null) {
|
|
626588
|
+
try {
|
|
626589
|
+
await onToken(finalPartial);
|
|
626590
|
+
} catch {
|
|
626517
626591
|
}
|
|
626518
626592
|
}
|
|
626519
626593
|
} catch (err) {
|
|
@@ -630042,7 +630116,7 @@ ${caption}\r
|
|
|
630042
630116
|
}
|
|
630043
630117
|
}
|
|
630044
630118
|
/** Make a Telegram Bot API call with rate-limit retry */
|
|
630045
|
-
async apiCall(method, body) {
|
|
630119
|
+
async apiCall(method, body, _retryDepth = 0) {
|
|
630046
630120
|
const url = `https://api.telegram.org/bot${this.botToken}/${method}`;
|
|
630047
630121
|
const options2 = {
|
|
630048
630122
|
method: "POST",
|
|
@@ -630060,9 +630134,13 @@ ${caption}\r
|
|
|
630060
630134
|
const res = await fetch(url, options2);
|
|
630061
630135
|
const data = await res.json();
|
|
630062
630136
|
if (data["error_code"] === 429 && data["parameters"]?.retry_after) {
|
|
630063
|
-
const waitSec = data["parameters"].retry_after;
|
|
630137
|
+
const waitSec = Math.min(3, data["parameters"].retry_after);
|
|
630138
|
+
const isLiveEdit = method === "editMessageText";
|
|
630139
|
+
if (isLiveEdit || _retryDepth >= 1) {
|
|
630140
|
+
return data;
|
|
630141
|
+
}
|
|
630064
630142
|
await new Promise((r2) => setTimeout(r2, waitSec * 1e3));
|
|
630065
|
-
return this.apiCall(method, body);
|
|
630143
|
+
return this.apiCall(method, body, _retryDepth + 1);
|
|
630066
630144
|
}
|
|
630067
630145
|
return data;
|
|
630068
630146
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.140",
|
|
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.140",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED