omnius 1.0.704 → 1.0.706

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
@@ -83355,6 +83355,10 @@ var init_metabolism = __esm({
83355
83355
  // packages/memory/dist/maintenance.js
83356
83356
  import { appendFileSync as appendFileSync2, closeSync as closeSync2, existsSync as existsSync32, mkdirSync as mkdirSync25, openSync as openSync2, readFileSync as readFileSync27, readSync, readdirSync as readdirSync11, renameSync as renameSync10, statSync as statSync13, unlinkSync as unlinkSync9, writeFileSync as writeFileSync24 } from "node:fs";
83357
83357
  import { dirname as dirname15, join as join32 } from "node:path";
83358
+ function envInt(name10, fallback) {
83359
+ const raw = Number.parseInt(process.env[name10] ?? "", 10);
83360
+ return Number.isFinite(raw) && raw >= 0 ? raw : fallback;
83361
+ }
83358
83362
  function runMemoryMaintenance(options2) {
83359
83363
  const started = Date.now();
83360
83364
  const result = emptyResult(options2, started);
@@ -83793,7 +83797,7 @@ function maintainGraph(dbPath, options2, shouldStop) {
83793
83797
  stats.edgesDeduped = dedupeGraphEdges(db, options2.maxGraphDeletes ?? 2e3, !!options2.dryRun);
83794
83798
  }
83795
83799
  if (!shouldStop()) {
83796
- stats.inactiveEdgesDeleted = pruneInactiveEdges(db, options2.maxGraphDeletes ?? 2e3, !!options2.dryRun);
83800
+ stats.inactiveEdgesDeleted = pruneInactiveEdges(db, options2.maxInactiveEdgeDeletes ?? envInt("OMNIUS_KG_MAX_INACTIVE_EDGE_DELETES", 5e4), !!options2.dryRun, options2.supersededRetentionMs ?? envInt("OMNIUS_KG_SUPERSEDED_RETENTION_DAYS", 30) * DAY);
83797
83801
  }
83798
83802
  if (!shouldStop()) {
83799
83803
  stats.orphanNodesDeleted = pruneOrphanNodes(db, options2.maxGraphDeletes ?? 2e3, !!options2.dryRun);
@@ -83915,17 +83919,19 @@ function dedupeGraphEdges(db, limit2, dryRun) {
83915
83919
  return ids.length;
83916
83920
  return deleteById(db, "kg_edges", ids);
83917
83921
  }
83918
- function pruneInactiveEdges(db, limit2, dryRun) {
83919
- const cutoff = Date.now() - 14 * DAY;
83922
+ function pruneInactiveEdges(db, limit2, dryRun, supersededRetentionMs = 30 * DAY) {
83923
+ const now2 = Date.now();
83924
+ const lowConfidenceCutoff = now2 - 14 * DAY;
83925
+ const supersededCutoff = supersededRetentionMs > 0 ? now2 - supersededRetentionMs : null;
83920
83926
  let ids = [];
83921
83927
  try {
83922
83928
  ids = db.prepare(`SELECT id
83923
83929
  FROM kg_edges
83924
83930
  WHERE valid_until IS NOT NULL
83925
- AND valid_until < ?
83926
- AND COALESCE(confidence, 1) < 0.55
83931
+ AND ( (valid_until < ? AND COALESCE(confidence, 1) < 0.55)
83932
+ OR (? IS NOT NULL AND valid_until < ?) )
83927
83933
  ORDER BY valid_until ASC
83928
- LIMIT ?`).all(cutoff, Math.max(1, limit2)).map((row2) => row2.id);
83934
+ LIMIT ?`).all(lowConfidenceCutoff, supersededCutoff, supersededCutoff, Math.max(1, limit2)).map((row2) => row2.id);
83929
83935
  } catch {
83930
83936
  return 0;
83931
83937
  }
@@ -636053,7 +636059,7 @@ function renderTerminalTaskReport(report2, options2 = {}) {
636053
636059
  return `${outcome}${exit}${primary}${check.freshness !== "current" ? `; ${check.freshness}` : ""}: ${check.command}.`;
636054
636060
  }), omitted: report2.omitted.checks, weight: 0.23 },
636055
636061
  { label: "Files changed:", rows: report2.changes.map((change) => change.path), omitted: report2.omitted.changes, weight: 0.19 },
636056
- { label: "Observed work:", rows: report2.observations.map((observation) => `${observation.toolName}${observation.paths.length ? `: ${observation.paths.join(", ")}` : " completed"}.`), omitted: report2.omitted.observations, weight: 0.08 }
636062
+ { label: "Observed work:", rows: (options2.includeToolTelemetry === true ? report2.observations : report2.observations.filter((observation) => observation.paths.length > 0)).map((observation) => `${observation.toolName}${observation.paths.length ? `: ${observation.paths.join(", ")}` : " completed"}.`), omitted: report2.omitted.observations, weight: 0.08 }
636057
636063
  ].filter((item) => item.rows.length || item.omitted);
636058
636064
  const totalWeight = sections.reduce((sum2, item) => sum2 + item.weight, 0);
636059
636065
  const available = maxChars - headline.length - 30;
@@ -672615,13 +672621,30 @@ runtime_module_sha256=${record.runtimeProvenance.module.sha256 ?? "unknown"}`
672615
672621
  _legacyModelVisibleCompactionAllowed() {
672616
672622
  return this._memoryCompilationMode() !== "active";
672617
672623
  }
672624
+ /**
672625
+ * Capacity used for compaction accounting. Provider/observed limits remain
672626
+ * authoritative when available. When metadata is absent, use the existing
672627
+ * tier ceiling as an explicitly labeled working budget; do not add it to the
672628
+ * backend request or pretend it was provider-reported.
672629
+ */
672630
+ _contextBudget(request) {
672631
+ const known = this._contextAdmissionLimit(request);
672632
+ if (known.limit && known.source !== "unknown") {
672633
+ return { tokens: known.limit, source: known.source };
672634
+ }
672635
+ return {
672636
+ tokens: Math.max(1, this.effectiveContextWindow()),
672637
+ source: "tier_fallback"
672638
+ };
672639
+ }
672618
672640
  /** Build the exact budget for the payload which will be sent to the backend. */
672619
672641
  _outboundRequestBudget(request) {
672620
672642
  const rawRequest = request;
672643
+ const contextBudget = this._contextBudget(request);
672621
672644
  return compileOutboundRequestBudget({
672622
672645
  messages: Array.isArray(rawRequest["messages"]) ? rawRequest["messages"] : [],
672623
672646
  tools: Array.isArray(rawRequest["tools"]) ? rawRequest["tools"] : [],
672624
- modelContextTokens: typeof rawRequest["numCtx"] === "number" ? rawRequest["numCtx"] : typeof rawRequest["num_ctx"] === "number" ? rawRequest["num_ctx"] : 0,
672647
+ modelContextTokens: typeof rawRequest["numCtx"] === "number" ? rawRequest["numCtx"] : typeof rawRequest["num_ctx"] === "number" ? rawRequest["num_ctx"] : contextBudget.tokens,
672625
672648
  outputReservationTokens: typeof rawRequest["maxTokens"] === "number" ? rawRequest["maxTokens"] : typeof rawRequest["max_tokens"] === "number" ? rawRequest["max_tokens"] : 0,
672626
672649
  request: rawRequest
672627
672650
  });
@@ -672970,6 +672993,54 @@ ${read3.content}`;
672970
672993
  justification: "Inference-selected representations passed graph, artifact, and exact post-request budget validation."
672971
672994
  });
672972
672995
  }
672996
+ /** Publish a footer-only lifecycle around the active compiler boundary. */
672997
+ async _applyUnifiedMemoryCompilationWithLifecycle(request) {
672998
+ const preBudget = this._outboundRequestBudget(request);
672999
+ const shouldPublishLifecycle = this._memoryCompilationMode() === "active" && preBudget.compactionEligible;
673000
+ if (!shouldPublishLifecycle) {
673001
+ await this._applyUnifiedMemoryCompilation(request);
673002
+ return;
673003
+ }
673004
+ const contextBudget = this._contextBudget(request);
673005
+ this.emit({
673006
+ type: "status",
673007
+ content: "Compacting context",
673008
+ visibility: "user_progress",
673009
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
673010
+ compactionLifecycle: {
673011
+ state: "started",
673012
+ source: "unified",
673013
+ beforeTokens: preBudget.totalInputTokens,
673014
+ projectedTokens: preBudget.projectedTotalTokens,
673015
+ workingLimitTokens: contextBudget.tokens,
673016
+ limitSource: contextBudget.source
673017
+ }
673018
+ });
673019
+ let failed = true;
673020
+ try {
673021
+ await this._applyUnifiedMemoryCompilation(request);
673022
+ failed = false;
673023
+ } finally {
673024
+ const auditState = this._lastMemoryCompilationPlanAudit?.state;
673025
+ const state5 = failed ? "failed" : auditState === "applied" ? "applied" : auditState === "hold" ? "held" : auditState === "rejected" ? "rejected" : "failed";
673026
+ const afterTokens = state5 === "applied" ? this._outboundRequestBudget(request).totalInputTokens : void 0;
673027
+ this.emit({
673028
+ type: "status",
673029
+ content: `Context compaction ${state5}`,
673030
+ visibility: "user_progress",
673031
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
673032
+ compactionLifecycle: {
673033
+ state: state5,
673034
+ source: "unified",
673035
+ beforeTokens: preBudget.totalInputTokens,
673036
+ projectedTokens: preBudget.projectedTotalTokens,
673037
+ ...afterTokens !== void 0 ? { afterTokens } : {},
673038
+ workingLimitTokens: contextBudget.tokens,
673039
+ limitSource: contextBudget.source
673040
+ }
673041
+ });
673042
+ }
673043
+ }
672973
673044
  /**
672974
673045
  * Evaluate the graph compiler against an exact, already-rendered request.
672975
673046
  * This is shadow-only: it records a validated proposal but deliberately does
@@ -673882,19 +673953,13 @@ ${workflowStatus}` } : {}
673882
673953
  return result;
673883
673954
  }
673884
673955
  async _recordContextWindowDump(stage3, request, turn, attempt) {
673885
- await this._applyUnifiedMemoryCompilation(request);
673956
+ await this._applyUnifiedMemoryCompilationWithLifecycle(request);
673886
673957
  const compilationAudit = this._lastMemoryCompilationPlanAudit;
673887
673958
  this._applyContextAdmission(request);
673888
673959
  this._applyCanonicalOutboundProjection(request, turn);
673889
673960
  const agentType = this.options.artifactMode === "internal" ? "internal" : this.options.subAgent || this.options.recursionDepth > 0 ? "sub-agent" : "main";
673890
673961
  const rawRequest = snapshotOutboundRequest(request);
673891
- const exactBudget = compileOutboundRequestBudget({
673892
- messages: Array.isArray(rawRequest["messages"]) ? rawRequest["messages"] : [],
673893
- tools: Array.isArray(rawRequest["tools"]) ? rawRequest["tools"] : [],
673894
- modelContextTokens: typeof rawRequest["numCtx"] === "number" ? rawRequest["numCtx"] : typeof rawRequest["num_ctx"] === "number" ? rawRequest["num_ctx"] : 0,
673895
- outputReservationTokens: typeof rawRequest["maxTokens"] === "number" ? rawRequest["maxTokens"] : typeof rawRequest["max_tokens"] === "number" ? rawRequest["max_tokens"] : 0,
673896
- request: rawRequest
673897
- });
673962
+ const exactBudget = this._outboundRequestBudget(rawRequest);
673898
673963
  const memoryCompilerShadow = await this._runMemoryCompilerShadow(exactBudget);
673899
673964
  const planAuditApplies = compilationAudit ? {
673900
673965
  ...compilationAudit,
@@ -673933,6 +673998,7 @@ ${workflowStatus}` } : {}
673933
673998
  this.emit({
673934
673999
  type: "status",
673935
674000
  content: `Memory compiler shadow ${memoryCompilerShadow.decision}: ${memoryCompilerShadow.reason}`,
674001
+ visibility: "telemetry",
673936
674002
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
673937
674003
  });
673938
674004
  }
@@ -673950,6 +674016,7 @@ ${workflowStatus}` } : {}
673950
674016
  this.emit({
673951
674017
  type: "status",
673952
674018
  content: `Memory compiler v2 ${planAuditApplies.state}: ${planAuditApplies.justification ?? "no additional detail"}`,
674019
+ visibility: "telemetry",
673953
674020
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
673954
674021
  });
673955
674022
  }
@@ -688473,6 +688540,8 @@ ${memoryLines.join("\n")}`
688473
688540
  }
688474
688541
  return sum2 + chars + imageCount * IMAGE_TOKEN_ESTIMATE * 4;
688475
688542
  }, 0) / 4);
688543
+ const trackedContextTokens = turnPromptTokens > 0 ? turnPromptTokens : this._lastOutboundRequestBudget?.totalInputTokens ?? estimatedContextTokens;
688544
+ const contextBudget = this._contextBudget(chatRequest);
688476
688545
  this.emit({
688477
688546
  type: "token_usage",
688478
688547
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -688480,18 +688549,21 @@ ${memoryLines.join("\n")}`
688480
688549
  promptTokens,
688481
688550
  completionTokens,
688482
688551
  totalTokens,
688483
- estimatedContextTokens,
688552
+ estimatedContextTokens: trackedContextTokens,
688484
688553
  lastPromptTokens: turnPromptTokens,
688485
- lastCompletionTokens: turnCompletionTokens
688554
+ lastCompletionTokens: turnCompletionTokens,
688555
+ contextBudgetTokens: contextBudget.tokens,
688556
+ contextBudgetSource: contextBudget.source
688486
688557
  }
688487
688558
  });
688488
688559
  {
688489
- const { compactionThreshold: ctxThreshold } = this.contextLimits();
688490
- const utilPct = ctxThreshold > 0 ? Math.round(estimatedContextTokens / ctxThreshold * 100) : 0;
688560
+ const ctxBudgetTokens = contextBudget.tokens;
688561
+ const utilPct = ctxBudgetTokens > 0 ? Math.round(trackedContextTokens / ctxBudgetTokens * 100) : 0;
688491
688562
  if (utilPct > 50) {
688492
688563
  this.emit({
688493
688564
  type: "status",
688494
- content: `Context: ~${estimatedContextTokens}t / ${ctxThreshold}t (${utilPct}%)${utilPct > 85 ? " ⚠️ compaction imminent" : ""}`,
688565
+ content: `Context budget: ~${trackedContextTokens}t / ${ctxBudgetTokens}t (${utilPct}% used)`,
688566
+ visibility: "telemetry",
688495
688567
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
688496
688568
  });
688497
688569
  }
@@ -692808,6 +692880,8 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
692808
692880
  }
692809
692881
  return sum2 + chars + imgCount * 1500 * 4;
692810
692882
  }, 0) / 4);
692883
+ const trackedBfContextTokens = bfTurnPrompt > 0 ? bfTurnPrompt : this._lastOutboundRequestBudget?.totalInputTokens ?? bfEstCtx;
692884
+ const bfContextBudget = this._contextBudget(chatRequest);
692811
692885
  this.emit({
692812
692886
  type: "token_usage",
692813
692887
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -692815,9 +692889,11 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
692815
692889
  promptTokens,
692816
692890
  completionTokens,
692817
692891
  totalTokens,
692818
- estimatedContextTokens: bfEstCtx,
692892
+ estimatedContextTokens: trackedBfContextTokens,
692819
692893
  lastPromptTokens: bfTurnPrompt,
692820
- lastCompletionTokens: bfTurnCompletion
692894
+ lastCompletionTokens: bfTurnCompletion,
692895
+ contextBudgetTokens: bfContextBudget.tokens,
692896
+ contextBudgetSource: bfContextBudget.source
692821
692897
  }
692822
692898
  });
692823
692899
  const choice = response.choices[0];
@@ -733571,12 +733647,15 @@ function findModel(models, query) {
733571
733647
  const fuzzy = models.find((m2) => m2.name.includes(query));
733572
733648
  return fuzzy;
733573
733649
  }
733574
- async function queryModelContextSize(baseUrl3, modelName) {
733650
+ async function queryModelContextSize(baseUrl3, modelName, apiKey) {
733575
733651
  try {
733576
733652
  const normalized4 = normalizeBaseUrl(baseUrl3);
733577
733653
  const res = await fetch(`${normalized4}/api/show`, {
733578
733654
  method: "POST",
733579
- headers: { "Content-Type": "application/json" },
733655
+ headers: {
733656
+ "Content-Type": "application/json",
733657
+ ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
733658
+ },
733580
733659
  body: JSON.stringify({ name: modelName }),
733581
733660
  signal: AbortSignal.timeout(1e4)
733582
733661
  });
@@ -733763,7 +733842,7 @@ async function queryContextTelemetry(baseUrl3, modelName, apiKey) {
733763
733842
  capacitySource: "peer_default"
733764
733843
  };
733765
733844
  }
733766
- const ollamaSize = await queryModelContextSize(baseUrl3, modelName);
733845
+ const ollamaSize = await queryModelContextSize(baseUrl3, modelName, apiKey);
733767
733846
  if (ollamaSize) {
733768
733847
  return { endpoint, model: modelName, capacityTokens: ollamaSize, capacitySource: "ollama_show" };
733769
733848
  }
@@ -745882,6 +745961,7 @@ var init_status_bar = __esm({
745882
745961
  contextWindowSize: 0
745883
745962
  };
745884
745963
  _contextCapacity = { status: "unknown" };
745964
+ _contextCompaction = null;
745885
745965
  // ── Metrics tracking for Telegram stats ──
745886
745966
  _backend = "ollama";
745887
745967
  _inferenceCount = 0;
@@ -747330,6 +747410,11 @@ var init_status_bar = __esm({
747330
747410
  this.pushSpinnerContextMetrics();
747331
747411
  if (this.active) this.renderFooterPreserveCursor();
747332
747412
  }
747413
+ /** Show context-compaction progress in the footer without adding scrollback noise. */
747414
+ setContextCompaction(state5) {
747415
+ this._contextCompaction = state5;
747416
+ if (this.active) this.renderFooterPreserveCursor();
747417
+ }
747333
747418
  /** Set the current package version for display in the metrics row */
747334
747419
  setVersion(version5) {
747335
747420
  this._version = version5;
@@ -747836,10 +747921,17 @@ var init_status_bar = __esm({
747836
747921
  this.metrics.estimatedContextTokens = update2.estimatedContextTokens;
747837
747922
  if (update2.contextOutputReservationTokens !== void 0)
747838
747923
  this.metrics.contextOutputReservationTokens = update2.contextOutputReservationTokens;
747924
+ if (update2.contextBudgetTokens !== void 0)
747925
+ this.metrics.contextBudgetTokens = update2.contextBudgetTokens;
747926
+ if (update2.contextBudgetSource !== void 0)
747927
+ this.metrics.contextBudgetSource = update2.contextBudgetSource;
747839
747928
  if (update2.lastPromptTokens !== void 0)
747840
747929
  this.metrics.lastPromptTokens = update2.lastPromptTokens;
747841
747930
  if (update2.lastCompletionTokens !== void 0)
747842
747931
  this.metrics.lastCompletionTokens = update2.lastCompletionTokens;
747932
+ if (update2.estimatedContextTokens !== void 0 && this._contextCompaction?.state !== "started") {
747933
+ this._contextCompaction = null;
747934
+ }
747843
747935
  this._streamingTokens = 0;
747844
747936
  this._streamStartTime = 0;
747845
747937
  this.pushSpinnerContextMetrics();
@@ -747876,6 +747968,7 @@ var init_status_bar = __esm({
747876
747968
  this.metrics.estimatedContextTokens = 0;
747877
747969
  this.metrics.lastPromptTokens = 0;
747878
747970
  this.metrics.lastCompletionTokens = 0;
747971
+ this._contextCompaction = null;
747879
747972
  this._tokensPerSecond = 0;
747880
747973
  this.pushSpinnerContextMetrics();
747881
747974
  if (this.active) this.renderFooterPreserveCursor();
@@ -750054,16 +750147,21 @@ ${CONTENT_BG_SEQ}`);
750054
750147
  const circleChar = isPaused ? "●" : "◖";
750055
750148
  const circleColor = isPaused ? 120 : 183;
750056
750149
  const uptimeStr = `\x1B[38;5;${circleColor}m${circleChar} ${uptime2}\x1B[0m`;
750057
- const ctxUsed = m2.estimatedContextTokens;
750150
+ const lifecycle = this._contextCompaction;
750151
+ const ctxUsed = lifecycle?.afterTokens ?? lifecycle?.beforeTokens ?? m2.estimatedContextTokens;
750058
750152
  const ctxTotal = this.reportedContextTotal(
750059
750153
  m2.contextWindowSize,
750060
750154
  this.effectiveContextTotal(m2.contextWindowSize)
750061
750155
  );
750156
+ const fallbackTotal = lifecycle?.workingLimitTokens ?? m2.contextBudgetTokens ?? 0;
750157
+ const providerCapacityKnown = this._contextCapacity.status === "known" && ctxTotal > 0;
750158
+ const displayTotal = providerCapacityKnown ? ctxTotal : fallbackTotal;
750159
+ const estimatedCapacity = !providerCapacityKnown && displayTotal > 0;
750062
750160
  let ctxStr = "";
750063
- if (this._contextCapacity.status === "known" && ctxTotal > 0) {
750161
+ if (displayTotal > 0) {
750064
750162
  const pct2 = Math.max(
750065
750163
  0,
750066
- Math.min(100, Math.round((1 - ctxUsed / ctxTotal) * 100))
750164
+ Math.min(100, Math.round((1 - ctxUsed / displayTotal) * 100))
750067
750165
  );
750068
750166
  const barLen = 10;
750069
750167
  const filled = Math.round(pct2 / 100 * barLen);
@@ -750071,11 +750169,13 @@ ${CONTENT_BG_SEQ}`);
750071
750169
  const barColor = pct2 > 50 ? 120 : pct2 > 20 ? 222 : 210;
750072
750170
  const bar = `\x1B[38;5;${barColor}m${"█".repeat(filled)}\x1B[0m\x1B[38;5;240m${"░".repeat(empty2)}\x1B[0m`;
750073
750171
  const pctColor = pct2 > 50 ? 120 : pct2 > 20 ? 222 : 210;
750074
- ctxStr = `${bar} \x1B[38;5;${pctColor}m${pct2}%\x1B[0m`;
750172
+ const lifecycleLabel = lifecycle?.state === "started" ? "\x1B[38;5;222m⟳ compacting\x1B[0m " : lifecycle?.state === "applied" ? "\x1B[38;5;120m✓ compacted\x1B[0m " : lifecycle ? "\x1B[38;5;210m◇ compact held\x1B[0m " : estimatedCapacity ? "\x1B[38;5;245mCTX~\x1B[0m " : "";
750173
+ const estimateMark = estimatedCapacity ? "~" : "";
750174
+ ctxStr = `${lifecycleLabel}${bar} \x1B[38;5;${pctColor}m${estimateMark}${pct2}%\x1B[0m`;
750075
750175
  } else {
750076
750176
  const usage = ctxUsed >= 1024 ? `${(ctxUsed / 1024).toFixed(ctxUsed >= 1e4 ? 0 : 1)}K` : String(Math.max(0, Math.round(ctxUsed)));
750077
750177
  const reservation = m2.contextOutputReservationTokens && m2.contextOutputReservationTokens > 0 ? ` +${m2.contextOutputReservationTokens >= 1024 ? `${Math.round(m2.contextOutputReservationTokens / 1024)}K` : m2.contextOutputReservationTokens} rsv` : "";
750078
- ctxStr = `\x1B[38;5;245mCTX ? | ~${usage}${reservation}\x1B[0m`;
750178
+ ctxStr = `\x1B[38;5;245mCTX measuring | ~${usage} used${reservation}\x1B[0m`;
750079
750179
  }
750080
750180
  const arrow = `\x1B[38;5;240m▶\x1B[0m`;
750081
750181
  let rightSide;
@@ -750190,10 +750290,11 @@ ${CONTENT_BG_SEQ}`);
750190
750290
  /** Push current context window usage to the braille spinner */
750191
750291
  pushSpinnerContextMetrics() {
750192
750292
  const ctxUsed = this.metrics.estimatedContextTokens;
750193
- const ctxTotal = this.reportedContextTotal(
750293
+ const reportedTotal = this.reportedContextTotal(
750194
750294
  this.metrics.contextWindowSize,
750195
750295
  this.effectiveContextTotal(this.metrics.contextWindowSize)
750196
750296
  );
750297
+ const ctxTotal = this._contextCapacity.status === "known" ? reportedTotal : this.metrics.contextBudgetTokens ?? 0;
750197
750298
  const contextPct = ctxTotal > 0 ? Math.round(ctxUsed / ctxTotal * 100) : 0;
750198
750299
  this._brailleSpinner.setMetrics({ contextPct });
750199
750300
  }
@@ -797559,7 +797660,7 @@ function telegramCommittedTerminalMaterial(result, owner, modelReply) {
797559
797660
  readinessHash: result.completionReadiness?.readinessHash
797560
797661
  }) ? result.terminalReport : void 0;
797561
797662
  const report2 = validReport ? renderTerminalTaskReport(validReport) : "";
797562
- const reportEvidence = validReport ? renderTerminalTaskReport(validReport, { maxChars: 24e3 }) : "";
797663
+ const reportEvidence = validReport ? renderTerminalTaskReport(validReport, { maxChars: 24e3, includeToolTelemetry: true }) : "";
797563
797664
  if (!result.completed || result.status !== "completed") return { ...empty2, report: report2, reportEvidence };
797564
797665
  const accepted = result.acceptedUserReply;
797565
797666
  const acceptedReply = accepted && accepted.runId === owner.runId && accepted.taskEpoch === owner.taskEpoch && accepted.terminalReceiptId === result.terminalReceiptId && typeof accepted.toolCallId === "string" && accepted.toolCallId.trim() && typeof accepted.text === "string" ? accepted.text : "";
@@ -843640,7 +843741,14 @@ ${entry.fullContent}`
843640
843741
  case "status":
843641
843742
  if (_apiCallbacks?.onStatus)
843642
843743
  _apiCallbacks.onStatus(event.content ?? "");
843643
- if (event.content && event.toolName !== "shell" && inferenceBlocks?.has(mainInferenceBlockKey)) {
843744
+ if (event.compactionLifecycle) {
843745
+ statusBar?.setContextCompaction(event.compactionLifecycle);
843746
+ if (event.compactionLifecycle.state === "applied") {
843747
+ statusBar?.recordCompaction();
843748
+ }
843749
+ break;
843750
+ }
843751
+ if (event.content && event.visibility !== "telemetry" && event.toolName !== "shell" && inferenceBlocks?.has(mainInferenceBlockKey)) {
843644
843752
  inferenceBlocks.handling(
843645
843753
  mainInferenceBlockKey,
843646
843754
  getSecretRedactor().redactText(event.content)
@@ -2919,6 +2919,10 @@ import { appendFileSync, closeSync, existsSync as existsSync2, mkdirSync as mkdi
2919
2919
  import { dirname, join as join2 } from "node:path";
2920
2920
  var HOUR = 36e5;
2921
2921
  var DAY = 24 * HOUR;
2922
+ function envInt(name, fallback) {
2923
+ const raw = Number.parseInt(process.env[name] ?? "", 10);
2924
+ return Number.isFinite(raw) && raw >= 0 ? raw : fallback;
2925
+ }
2922
2926
  var DECAY_TAU2 = {
2923
2927
  session: HOUR,
2924
2928
  daily: DAY,
@@ -3363,7 +3367,7 @@ function maintainGraph(dbPath, options, shouldStop) {
3363
3367
  stats.edgesDeduped = dedupeGraphEdges(db, options.maxGraphDeletes ?? 2e3, !!options.dryRun);
3364
3368
  }
3365
3369
  if (!shouldStop()) {
3366
- stats.inactiveEdgesDeleted = pruneInactiveEdges(db, options.maxGraphDeletes ?? 2e3, !!options.dryRun);
3370
+ stats.inactiveEdgesDeleted = pruneInactiveEdges(db, options.maxInactiveEdgeDeletes ?? envInt("OMNIUS_KG_MAX_INACTIVE_EDGE_DELETES", 5e4), !!options.dryRun, options.supersededRetentionMs ?? envInt("OMNIUS_KG_SUPERSEDED_RETENTION_DAYS", 30) * DAY);
3367
3371
  }
3368
3372
  if (!shouldStop()) {
3369
3373
  stats.orphanNodesDeleted = pruneOrphanNodes(db, options.maxGraphDeletes ?? 2e3, !!options.dryRun);
@@ -3485,17 +3489,19 @@ function dedupeGraphEdges(db, limit, dryRun) {
3485
3489
  return ids.length;
3486
3490
  return deleteById(db, "kg_edges", ids);
3487
3491
  }
3488
- function pruneInactiveEdges(db, limit, dryRun) {
3489
- const cutoff = Date.now() - 14 * DAY;
3492
+ function pruneInactiveEdges(db, limit, dryRun, supersededRetentionMs = 30 * DAY) {
3493
+ const now = Date.now();
3494
+ const lowConfidenceCutoff = now - 14 * DAY;
3495
+ const supersededCutoff = supersededRetentionMs > 0 ? now - supersededRetentionMs : null;
3490
3496
  let ids = [];
3491
3497
  try {
3492
3498
  ids = db.prepare(`SELECT id
3493
3499
  FROM kg_edges
3494
3500
  WHERE valid_until IS NOT NULL
3495
- AND valid_until < ?
3496
- AND COALESCE(confidence, 1) < 0.55
3501
+ AND ( (valid_until < ? AND COALESCE(confidence, 1) < 0.55)
3502
+ OR (? IS NOT NULL AND valid_until < ?) )
3497
3503
  ORDER BY valid_until ASC
3498
- LIMIT ?`).all(cutoff, Math.max(1, limit)).map((row) => row.id);
3504
+ LIMIT ?`).all(lowConfidenceCutoff, supersededCutoff, supersededCutoff, Math.max(1, limit)).map((row) => row.id);
3499
3505
  } catch {
3500
3506
  return 0;
3501
3507
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.704",
3
+ "version": "1.0.706",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "omnius",
9
- "version": "1.0.704",
9
+ "version": "1.0.706",
10
10
  "bundleDependencies": [
11
11
  "image-to-ascii"
12
12
  ],
@@ -1081,9 +1081,9 @@
1081
1081
  "license": "Apache-2.0 OR MIT"
1082
1082
  },
1083
1083
  "node_modules/@libp2p/noise/node_modules/protons-runtime": {
1084
- "version": "7.0.0",
1085
- "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-7.0.0.tgz",
1086
- "integrity": "sha512-r/e72006xoVND4Uvf1aIs4OQOkJaASBU3ip4DzOWAktoKAkTiOYqKoS3TYMBm8HnnYU8+h0uEzr5gIRwk/pmTg==",
1084
+ "version": "7.1.0",
1085
+ "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-7.1.0.tgz",
1086
+ "integrity": "sha512-TAL8CpKEUK+k0KKZIQrDTBgyH86zZAjz3ZULcCjxrb9zvkTVEGJyVbATmTV4KpZmFFEH7ERWDNWxfiE+N3bOUQ==",
1087
1087
  "license": "Apache-2.0 OR MIT",
1088
1088
  "dependencies": {
1089
1089
  "uint8-varint": "^3.0.0",
@@ -1167,9 +1167,9 @@
1167
1167
  "license": "Apache-2.0 OR MIT"
1168
1168
  },
1169
1169
  "node_modules/@libp2p/peer-record/node_modules/protons-runtime": {
1170
- "version": "7.0.0",
1171
- "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-7.0.0.tgz",
1172
- "integrity": "sha512-r/e72006xoVND4Uvf1aIs4OQOkJaASBU3ip4DzOWAktoKAkTiOYqKoS3TYMBm8HnnYU8+h0uEzr5gIRwk/pmTg==",
1170
+ "version": "7.1.0",
1171
+ "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-7.1.0.tgz",
1172
+ "integrity": "sha512-TAL8CpKEUK+k0KKZIQrDTBgyH86zZAjz3ZULcCjxrb9zvkTVEGJyVbATmTV4KpZmFFEH7ERWDNWxfiE+N3bOUQ==",
1173
1173
  "license": "Apache-2.0 OR MIT",
1174
1174
  "dependencies": {
1175
1175
  "uint8-varint": "^3.0.0",
@@ -1277,9 +1277,9 @@
1277
1277
  "license": "Apache-2.0 OR MIT"
1278
1278
  },
1279
1279
  "node_modules/@libp2p/record/node_modules/protons-runtime": {
1280
- "version": "7.0.0",
1281
- "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-7.0.0.tgz",
1282
- "integrity": "sha512-r/e72006xoVND4Uvf1aIs4OQOkJaASBU3ip4DzOWAktoKAkTiOYqKoS3TYMBm8HnnYU8+h0uEzr5gIRwk/pmTg==",
1280
+ "version": "7.1.0",
1281
+ "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-7.1.0.tgz",
1282
+ "integrity": "sha512-TAL8CpKEUK+k0KKZIQrDTBgyH86zZAjz3ZULcCjxrb9zvkTVEGJyVbATmTV4KpZmFFEH7ERWDNWxfiE+N3bOUQ==",
1283
1283
  "license": "Apache-2.0 OR MIT",
1284
1284
  "dependencies": {
1285
1285
  "uint8-varint": "^3.0.0",
@@ -1515,9 +1515,9 @@
1515
1515
  "license": "Apache-2.0 OR MIT"
1516
1516
  },
1517
1517
  "node_modules/@libp2p/webrtc/node_modules/node-datachannel": {
1518
- "version": "0.33.2",
1519
- "resolved": "https://registry.npmjs.org/node-datachannel/-/node-datachannel-0.33.2.tgz",
1520
- "integrity": "sha512-WRL+uqYG2eSvpnKuCOKueaMiyKlDjkJFd6pFH/f2SbD/EiXLMXwmYNU5z+TDQPrAv+BMgkuC40UESeRRL+4zBw==",
1518
+ "version": "0.33.3",
1519
+ "resolved": "https://registry.npmjs.org/node-datachannel/-/node-datachannel-0.33.3.tgz",
1520
+ "integrity": "sha512-Tf7bbOjUXh7gPiWKTFpMDZXpippya6pdsEz3tgxsIJiW+BMLWSaX7O6F9kDjHu0GCan4vSmXlfA8l21O4D+K9Q==",
1521
1521
  "license": "MPL 2.0",
1522
1522
  "dependencies": {
1523
1523
  "detect-libc": "^2.0.4"
@@ -1538,9 +1538,9 @@
1538
1538
  }
1539
1539
  },
1540
1540
  "node_modules/@libp2p/webrtc/node_modules/protons-runtime": {
1541
- "version": "7.0.0",
1542
- "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-7.0.0.tgz",
1543
- "integrity": "sha512-r/e72006xoVND4Uvf1aIs4OQOkJaASBU3ip4DzOWAktoKAkTiOYqKoS3TYMBm8HnnYU8+h0uEzr5gIRwk/pmTg==",
1541
+ "version": "7.1.0",
1542
+ "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-7.1.0.tgz",
1543
+ "integrity": "sha512-TAL8CpKEUK+k0KKZIQrDTBgyH86zZAjz3ZULcCjxrb9zvkTVEGJyVbATmTV4KpZmFFEH7ERWDNWxfiE+N3bOUQ==",
1544
1544
  "license": "Apache-2.0 OR MIT",
1545
1545
  "dependencies": {
1546
1546
  "uint8-varint": "^3.0.0",
@@ -1636,13 +1636,13 @@
1636
1636
  }
1637
1637
  },
1638
1638
  "node_modules/@msgpack/msgpack": {
1639
- "version": "2.8.0",
1640
- "resolved": "https://registry.npmjs.org/@msgpack/msgpack/-/msgpack-2.8.0.tgz",
1641
- "integrity": "sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ==",
1639
+ "version": "3.1.3",
1640
+ "resolved": "https://registry.npmjs.org/@msgpack/msgpack/-/msgpack-3.1.3.tgz",
1641
+ "integrity": "sha512-47XIizs9XZXvuJgoaJUIE2lFoID8ugvc0jzSHP+Ptfk8nTbnR8g788wv48N03Kx0UkAv559HWRQ3yzOgzlRNUA==",
1642
1642
  "license": "ISC",
1643
1643
  "optional": true,
1644
1644
  "engines": {
1645
- "node": ">= 10"
1645
+ "node": ">= 18"
1646
1646
  }
1647
1647
  },
1648
1648
  "node_modules/@multiformats/dns": {
@@ -2426,12 +2426,12 @@
2426
2426
  }
2427
2427
  },
2428
2428
  "node_modules/@types/node": {
2429
- "version": "26.5.0",
2430
- "resolved": "https://registry.npmjs.org/@types/node/-/node-26.5.0.tgz",
2431
- "integrity": "sha512-dVSGpriSoCgz8WnDNTuSSuSv1PC/ALXihO4ulRZt7Md8k9mlbdin3lGOcDE8SnWOgf513ByWlXd7BK4azmyg/A==",
2429
+ "version": "22.20.2",
2430
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.2.tgz",
2431
+ "integrity": "sha512-xlvWf4Vs9n1PEVYwP1n4vvG07M6y8WgvJ2t0vbrWTmijsIHp1cS+uJ2kMIRdY3nHZK0nCYKrPeD171+SzF4/zw==",
2432
2432
  "license": "MIT",
2433
2433
  "dependencies": {
2434
- "undici-types": "~8.9.0"
2434
+ "undici-types": "~6.21.0"
2435
2435
  }
2436
2436
  },
2437
2437
  "node_modules/@types/sinon": {
@@ -4432,9 +4432,9 @@
4432
4432
  "license": "BSD-3-Clause"
4433
4433
  },
4434
4434
  "node_modules/ignore": {
4435
- "version": "7.0.8",
4436
- "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.8.tgz",
4437
- "integrity": "sha512-YYNsSlXBjMk92SKnkwvB5LOVSa6OznlFUGcsvrFgNJbJCd0M1XKeFVRc8ZByeCqz32FivYNHJVooLmdqrmvp/Q==",
4435
+ "version": "7.0.9",
4436
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.9.tgz",
4437
+ "integrity": "sha512-brTTsvFRt5C1gGHtPst/281UjPD5t9fBqbgoMPlVWy11ZLTPfu7HxK4ZYqO9H7o/yC9rSTCI85EaQ4OoY12qYw==",
4438
4438
  "license": "MIT",
4439
4439
  "engines": {
4440
4440
  "node": ">= 4"
@@ -5717,20 +5717,20 @@
5717
5717
  }
5718
5718
  },
5719
5719
  "node_modules/neovim": {
5720
- "version": "5.4.0",
5721
- "resolved": "https://registry.npmjs.org/neovim/-/neovim-5.4.0.tgz",
5722
- "integrity": "sha512-95YXs6d5p8M0k8xrmJHQ9aVLv9ebpM3ZQnmTaSpbJtPSdxFaKq7szCP1Ou+S8K++rEsh7BvTPwqdtdlwQfT0pw==",
5720
+ "version": "5.5.0",
5721
+ "resolved": "https://registry.npmjs.org/neovim/-/neovim-5.5.0.tgz",
5722
+ "integrity": "sha512-B68xdr5OUwLuUgD73aDa3yCg10Lg7gqroIDrSadvDpCJFC52pOD22iOI+omzQi+sgixTl5UyOHqnAd73E5RlEA==",
5723
5723
  "license": "MIT",
5724
5724
  "optional": true,
5725
5725
  "dependencies": {
5726
- "@msgpack/msgpack": "^2.8.0",
5726
+ "@msgpack/msgpack": "^3.1.3",
5727
5727
  "winston": "3.15.0"
5728
5728
  },
5729
5729
  "bin": {
5730
5730
  "neovim-node-host": "bin/cli.js"
5731
5731
  },
5732
5732
  "engines": {
5733
- "node": ">=10"
5733
+ "node": ">=14"
5734
5734
  }
5735
5735
  },
5736
5736
  "node_modules/netmask": {
@@ -7643,9 +7643,9 @@
7643
7643
  }
7644
7644
  },
7645
7645
  "node_modules/undici-types": {
7646
- "version": "8.9.0",
7647
- "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz",
7648
- "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==",
7646
+ "version": "6.21.0",
7647
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
7648
+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
7649
7649
  "license": "MIT"
7650
7650
  },
7651
7651
  "node_modules/universalify": {
@@ -8049,9 +8049,9 @@
8049
8049
  }
8050
8050
  },
8051
8051
  "node_modules/zod": {
8052
- "version": "4.5.4",
8053
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.5.4.tgz",
8054
- "integrity": "sha512-sC95tT5iHHH9gtpj6A81kh+NEaRAUFN+qlUPDUbRfOMvNf5QCBqsb3WgvnpVtK5Y+4UfA6KqufotuTvMGiTlsA==",
8052
+ "version": "4.6.2",
8053
+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.2.tgz",
8054
+ "integrity": "sha512-lh5RCAGFa1Cm2hjtNwLQhSs/AsqdWnTQaBER9fEwN/88pSh7KOtJavtBx/0VlkN/uFd61SwYmljLMDAsHlvzBQ==",
8055
8055
  "license": "MIT",
8056
8056
  "funding": {
8057
8057
  "url": "https://github.com/sponsors/colinhacks"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.704",
3
+ "version": "1.0.706",
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/library.js",