omnius 1.0.139 → 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 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 sections = [];
623365
+ const lines = [];
623366
+ const userFactIds = /* @__PURE__ */ new Set();
623343
623367
  if (userEntries.length > 0) {
623344
- const lines = userEntries.map(([, user]) => {
623345
- const facts = user.facts.slice(0, 6).map((fact) => ` - ${telegramContextJsonString(fact.text, 220)}`).join("\n");
623346
- const hints = user.relationshipHints.slice(-4).map((hint) => ` - relation=${telegramContextJsonString(hint, 200)}`).join("\n");
623347
- const topics = user.recentTopics.slice(-8).join(", ") || "none";
623348
- return [
623349
- `- ${user.username && user.username !== "unknown" ? `@${user.username}` : user.displayName || "user"} [${telegramActorKindLabel(user)}]${user.userId ? ` id:${user.userId}` : ""}: messages:${user.messageCount}, direct:${user.directAddressCount}, replies:${user.replyCount}, topics:${topics}`,
623350
- facts,
623351
- hints
623352
- ].filter(Boolean).join("\n");
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 lines = scoredFacts.map(
623359
- ({ fact, score }) => `- (${score.toFixed(2)}) ${telegramContextJsonString(fact.text, 260)}${fact.messageIds.length ? ` [messages:${fact.messageIds.slice(-4).join(",")}]` : ""}`
623360
- );
623361
- sections.push(`### Durable Associative Memory Recall
623362
- ${lines.join("\n")}`);
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 lines = relationshipFacts.map((fact) => `- ${telegramContextJsonString(fact.text, 240)}`);
623366
- sections.push(`### Durable Relationship Recall
623367
- ${lines.join("\n")}`);
623368
- }
623369
- if (recentActions.length > 0) {
623370
- const lines = recentActions.map(
623371
- (action) => `- ${telegramHistoryTime({ ts: action.ts, role: action.role, text: action.text })} ${action.speaker} [${telegramActorKindLabel({ isBot: action.role === "assistant" || action.isBot })}]/${action.role}${action.mode ? `/${action.mode}` : ""}: ${telegramContextJsonString(action.text, 220)}`
623372
- );
623373
- sections.push(`### Durable Recent Action Ledger Recall
623374
- ${lines.join("\n")}`);
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
- return sections.join("\n\n");
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 {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.139",
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.139",
9
+ "version": "1.0.140",
10
10
  "bundleDependencies": [
11
11
  "image-to-ascii"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.139",
3
+ "version": "1.0.140",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",