open-agents-ai 0.103.53 → 0.103.54

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.
Files changed (2) hide show
  1. package/dist/index.js +84 -33
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12071,7 +12071,7 @@ var init_nexus = __esm({
12071
12071
  * Usage: node nexus-daemon.mjs <nexus-dir> <agent-name> [agent-type]
12072
12072
  */
12073
12073
 
12074
- import { NexusClient, createFileAuditHook } from 'open-agents-nexus';
12074
+ import { NexusClient } from 'open-agents-nexus';
12075
12075
  import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync, readdirSync, appendFileSync, watch as fsWatch } from 'node:fs';
12076
12076
  import { join } from 'node:path';
12077
12077
 
@@ -12961,6 +12961,24 @@ async function handleCmd(cmd) {
12961
12961
  tokens: inputTokens + outputTokens,
12962
12962
  },
12963
12963
  });
12964
+
12965
+ // Write metering record directly (createFileAuditHook does not capture token data)
12966
+ try {
12967
+ appendFileSync(meteringFile, JSON.stringify({
12968
+ timestamp: Date.now(),
12969
+ peerId: request.from || 'unknown',
12970
+ service: capName,
12971
+ capability: capName,
12972
+ model: model.name,
12973
+ direction: 'inbound',
12974
+ inputBytes: prompt.length,
12975
+ outputBytes: (output || '').length,
12976
+ tokens: inputTokens + outputTokens,
12977
+ inputTokens: inputTokens,
12978
+ outputTokens: outputTokens,
12979
+ durationMs: Date.now() - logEntry.ts,
12980
+ }) + '\\n');
12981
+ } catch (mErr) { dlog('metering write error: ' + (mErr.message || mErr)); }
12964
12982
  } catch (e) {
12965
12983
  dlog('expose: inference error: ' + (e.message || e));
12966
12984
  await swrite({
@@ -13020,9 +13038,11 @@ async function handleCmd(cmd) {
13020
13038
  gpuInfo.vramUtilization = gpuInfo.vramTotalMB > 0 ? Math.round((gpuInfo.vramUsedMB / gpuInfo.vramTotalMB) * 100) : 0;
13021
13039
  }
13022
13040
  } catch (ge) { /* no GPU */ }
13041
+ var cpuModel = '';
13042
+ try { var cpuInfoArr = os.cpus(); if (cpuInfoArr.length > 0) cpuModel = cpuInfoArr[0].model || ''; } catch {}
13023
13043
  var metricsPayload = {
13024
- cpu: { utilization: Math.min(100, Math.round((loads[0] / cores) * 100)), cores: cores },
13025
- memory: { utilization: Math.round((usedMem / totalMem) * 100), totalGB: Math.round((totalMem / (1024*1024*1024)) * 10) / 10 },
13044
+ cpu: { utilization: Math.min(100, Math.round((loads[0] / cores) * 100)), cores: cores, model: cpuModel },
13045
+ memory: { utilization: Math.round((usedMem / totalMem) * 100), totalGB: Math.round((totalMem / (1024*1024*1024)) * 10) / 10, usedGB: Math.round((usedMem / (1024*1024*1024)) * 10) / 10 },
13026
13046
  gpu: gpuInfo,
13027
13047
  timestamp: new Date().toISOString(),
13028
13048
  };
@@ -13185,12 +13205,9 @@ process.on('unhandledRejection', (reason) => {
13185
13205
  dlog('WARNING: could not patch node.dialProtocol \u2014 node=' + !!_patchNode);
13186
13206
  }
13187
13207
 
13188
- // v1.5.0: Setup metering audit hook
13189
- try {
13190
- if (nexus.metering && typeof nexus.metering.addHook === 'function') {
13191
- nexus.metering.addHook(createFileAuditHook(meteringFile));
13192
- }
13193
- } catch {}
13208
+ // v1.5.0: Metering is now written directly from inference handlers (with token counts).
13209
+ // createFileAuditHook was previously used but produced records with 0 bytes / no tokens.
13210
+ // Keep metering hooks for payment tracking only (below).
13194
13211
 
13195
13212
  // Write payment events to ledger.jsonl
13196
13213
  try {
@@ -28837,18 +28854,23 @@ ${this.formatConnectionInfo()}`);
28837
28854
  continue;
28838
28855
  try {
28839
28856
  const record = JSON.parse(line);
28840
- const recInputBytes = record.inputBytes || 0;
28841
- const recOutputBytes = record.outputBytes || 0;
28842
- const recTotalTokens = typeof record.tokens === "number" ? record.tokens : typeof record.tokens === "object" && record.tokens ? (record.tokens.input || 0) + (record.tokens.output || 0) : 0;
28843
- const totalBytes = recInputBytes + recOutputBytes;
28844
28857
  let tokIn = 0;
28845
28858
  let tokOut = 0;
28846
- if (recTotalTokens > 0 && totalBytes > 0) {
28847
- tokIn = Math.round(recTotalTokens * (recInputBytes / totalBytes));
28848
- tokOut = recTotalTokens - tokIn;
28849
- } else if (recTotalTokens > 0) {
28850
- tokIn = Math.round(recTotalTokens / 2);
28851
- tokOut = recTotalTokens - tokIn;
28859
+ if (typeof record.inputTokens === "number" && typeof record.outputTokens === "number") {
28860
+ tokIn = record.inputTokens;
28861
+ tokOut = record.outputTokens;
28862
+ } else {
28863
+ const recInputBytes = record.inputBytes || 0;
28864
+ const recOutputBytes = record.outputBytes || 0;
28865
+ const recTotalTokens = typeof record.tokens === "number" ? record.tokens : typeof record.tokens === "object" && record.tokens ? (record.tokens.input || 0) + (record.tokens.output || 0) : 0;
28866
+ const totalBytes = recInputBytes + recOutputBytes;
28867
+ if (recTotalTokens > 0 && totalBytes > 0) {
28868
+ tokIn = Math.round(recTotalTokens * (recInputBytes / totalBytes));
28869
+ tokOut = recTotalTokens - tokIn;
28870
+ } else if (recTotalTokens > 0) {
28871
+ tokIn = Math.round(recTotalTokens / 2);
28872
+ tokOut = recTotalTokens - tokIn;
28873
+ }
28852
28874
  }
28853
28875
  this._stats.totalTokensIn += tokIn;
28854
28876
  this._stats.totalTokensOut += tokOut;
@@ -44527,7 +44549,15 @@ var init_status_bar = __esm({
44527
44549
  _remoteMetricsTimer = null;
44528
44550
  /** Update remote host system metrics (from polling /v1/system/metrics) */
44529
44551
  setRemoteMetrics(metrics) {
44530
- this._remoteMetrics = metrics;
44552
+ this._remoteMetrics = {
44553
+ ...metrics,
44554
+ cpuCores: metrics.cpuCores ?? 0,
44555
+ cpuModel: metrics.cpuModel ?? "",
44556
+ vramUsedMB: metrics.vramUsedMB ?? 0,
44557
+ vramTotalMB: metrics.vramTotalMB ?? 0,
44558
+ memTotalGB: metrics.memTotalGB ?? 0,
44559
+ memUsedGB: metrics.memUsedGB ?? 0
44560
+ };
44531
44561
  if (this.active)
44532
44562
  this.renderFooterPreserveCursor();
44533
44563
  }
@@ -44598,10 +44628,16 @@ var init_status_bar = __esm({
44598
44628
  if (metricsData?.cpu) {
44599
44629
  this.setRemoteMetrics({
44600
44630
  cpuUtil: metricsData.cpu?.utilization ?? 0,
44631
+ cpuCores: metricsData.cpu?.cores ?? 0,
44632
+ cpuModel: metricsData.cpu?.model ?? "",
44601
44633
  gpuUtil: metricsData.gpu?.available ? metricsData.gpu.utilization ?? 0 : -1,
44602
44634
  gpuName: metricsData.gpu?.name ?? "",
44603
44635
  vramUtil: metricsData.gpu?.available ? metricsData.gpu.vramUtilization ?? 0 : -1,
44604
- memUtil: metricsData.memory?.utilization ?? 0
44636
+ vramUsedMB: metricsData.gpu?.vramUsedMB ?? 0,
44637
+ vramTotalMB: metricsData.gpu?.vramTotalMB ?? 0,
44638
+ memUtil: metricsData.memory?.utilization ?? 0,
44639
+ memTotalGB: metricsData.memory?.totalGB ?? 0,
44640
+ memUsedGB: metricsData.memory?.usedGB ?? 0
44605
44641
  });
44606
44642
  return;
44607
44643
  }
@@ -45003,29 +45039,44 @@ var init_status_bar = __esm({
45003
45039
  if (this._remoteMetrics) {
45004
45040
  const rm2 = this._remoteMetrics;
45005
45041
  const cpuColor = rm2.cpuUtil > 80 ? c2.red : rm2.cpuUtil > 50 ? c2.yellow : c2.green;
45006
- const cpuStr = `CPU:${cpuColor(rm2.cpuUtil + "%")}`;
45007
- const cpuW = 4 + `${rm2.cpuUtil}%`.length;
45008
- let gpuStr = "";
45009
- let gpuW = 0;
45042
+ const cpuCoresInfo = rm2.cpuCores > 0 ? ` (${rm2.cpuCores}c` + (rm2.cpuModel ? " " + rm2.cpuModel.replace(/\s+/g, " ").slice(0, 30) : "") + ")" : "";
45043
+ const cpuExpStr = `CPU:${cpuColor(rm2.cpuUtil + "%")}${c2.dim(cpuCoresInfo)}`;
45044
+ const cpuCompStr = `CPU:${cpuColor(rm2.cpuUtil + "%")}`;
45045
+ const cpuExpW = 4 + `${rm2.cpuUtil}%`.length + cpuCoresInfo.length;
45046
+ const cpuCompW = 4 + `${rm2.cpuUtil}%`.length;
45047
+ const memColor = rm2.memUtil > 80 ? c2.red : rm2.memUtil > 50 ? c2.yellow : c2.green;
45048
+ const memDetail = rm2.memTotalGB > 0 ? ` (${rm2.memUsedGB}/${rm2.memTotalGB}GB)` : "";
45049
+ const memExpStr = ` RAM:${memColor(rm2.memUtil + "%")}${c2.dim(memDetail)}`;
45050
+ const memCompStr = ` RAM:${memColor(rm2.memUtil + "%")}`;
45051
+ const memExpW = 5 + `${rm2.memUtil}%`.length + memDetail.length;
45052
+ const memCompW = 5 + `${rm2.memUtil}%`.length;
45053
+ let gpuExpStr = "";
45054
+ let gpuCompStr = "";
45055
+ let gpuExpW = 0;
45056
+ let gpuCompW = 0;
45010
45057
  if (rm2.gpuUtil >= 0) {
45011
45058
  const gpuColor = rm2.gpuUtil > 80 ? c2.red : rm2.gpuUtil > 50 ? c2.yellow : c2.green;
45012
- gpuStr = ` GPU:${gpuColor(rm2.gpuUtil + "%")}`;
45013
- gpuW = 5 + `${rm2.gpuUtil}%`.length;
45059
+ const gpuNameShort = rm2.gpuName ? ` (${rm2.gpuName.slice(0, 20)})` : "";
45060
+ gpuExpStr = ` GPU:${gpuColor(rm2.gpuUtil + "%")}${c2.dim(gpuNameShort)}`;
45061
+ gpuCompStr = ` GPU:${gpuColor(rm2.gpuUtil + "%")}`;
45062
+ gpuExpW = 5 + `${rm2.gpuUtil}%`.length + gpuNameShort.length;
45063
+ gpuCompW = 5 + `${rm2.gpuUtil}%`.length;
45014
45064
  }
45015
45065
  let vramStr = "";
45016
45066
  let vramW = 0;
45017
45067
  if (rm2.vramUtil >= 0) {
45018
45068
  const vramColor = rm2.vramUtil > 80 ? c2.red : rm2.vramUtil > 50 ? c2.yellow : c2.green;
45019
- vramStr = ` VRAM:${vramColor(rm2.vramUtil + "%")}`;
45020
- vramW = 6 + `${rm2.vramUtil}%`.length;
45069
+ const vramDetail = rm2.vramTotalMB > 0 ? ` (${rm2.vramUsedMB}/${rm2.vramTotalMB}MB)` : "";
45070
+ vramStr = ` VRAM:${vramColor(rm2.vramUtil + "%")}${c2.dim(vramDetail)}`;
45071
+ vramW = 6 + `${rm2.vramUtil}%`.length + vramDetail.length;
45021
45072
  }
45022
- const remoteExpanded = pastel2(117, "\u{1F4E1}") + " " + cpuStr + gpuStr + vramStr;
45023
- const remoteCompact = pastel2(117, "\u{1F4E1}") + " " + cpuStr + gpuStr;
45073
+ const remoteExpanded = pastel2(117, "\u{1F4E1}") + " " + cpuExpStr + memExpStr + gpuExpStr + vramStr;
45074
+ const remoteCompact = pastel2(117, "\u{1F4E1}") + " " + cpuCompStr + gpuCompStr;
45024
45075
  sections.push({
45025
45076
  expanded: remoteExpanded,
45026
45077
  compact: remoteCompact,
45027
- expandedW: 3 + cpuW + gpuW + vramW,
45028
- compactW: 3 + cpuW + gpuW,
45078
+ expandedW: 3 + cpuExpW + memExpW + gpuExpW + vramW,
45079
+ compactW: 3 + cpuCompW + gpuCompW,
45029
45080
  empty: false
45030
45081
  });
45031
45082
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.103.53",
3
+ "version": "0.103.54",
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",