open-agents-ai 0.103.52 → 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.
- package/dist/index.js +86 -33
- 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
|
|
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:
|
|
13189
|
-
|
|
13190
|
-
|
|
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 (
|
|
28847
|
-
tokIn =
|
|
28848
|
-
tokOut =
|
|
28849
|
-
} else
|
|
28850
|
-
|
|
28851
|
-
|
|
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;
|
|
@@ -37263,6 +37285,8 @@ function emotionColor(emotion, stark = false, autist = false) {
|
|
|
37263
37285
|
return "";
|
|
37264
37286
|
}
|
|
37265
37287
|
function describeToolCall(toolName, args, personality = 2, emotion, stark = false) {
|
|
37288
|
+
if (toolName === "task_complete")
|
|
37289
|
+
return "";
|
|
37266
37290
|
const path = args["path"];
|
|
37267
37291
|
const file = path ? path.split("/").pop() ?? path : "";
|
|
37268
37292
|
const tier = getTier(personality);
|
|
@@ -44525,7 +44549,15 @@ var init_status_bar = __esm({
|
|
|
44525
44549
|
_remoteMetricsTimer = null;
|
|
44526
44550
|
/** Update remote host system metrics (from polling /v1/system/metrics) */
|
|
44527
44551
|
setRemoteMetrics(metrics) {
|
|
44528
|
-
this._remoteMetrics =
|
|
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
|
+
};
|
|
44529
44561
|
if (this.active)
|
|
44530
44562
|
this.renderFooterPreserveCursor();
|
|
44531
44563
|
}
|
|
@@ -44596,10 +44628,16 @@ var init_status_bar = __esm({
|
|
|
44596
44628
|
if (metricsData?.cpu) {
|
|
44597
44629
|
this.setRemoteMetrics({
|
|
44598
44630
|
cpuUtil: metricsData.cpu?.utilization ?? 0,
|
|
44631
|
+
cpuCores: metricsData.cpu?.cores ?? 0,
|
|
44632
|
+
cpuModel: metricsData.cpu?.model ?? "",
|
|
44599
44633
|
gpuUtil: metricsData.gpu?.available ? metricsData.gpu.utilization ?? 0 : -1,
|
|
44600
44634
|
gpuName: metricsData.gpu?.name ?? "",
|
|
44601
44635
|
vramUtil: metricsData.gpu?.available ? metricsData.gpu.vramUtilization ?? 0 : -1,
|
|
44602
|
-
|
|
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
|
|
44603
44641
|
});
|
|
44604
44642
|
return;
|
|
44605
44643
|
}
|
|
@@ -45001,29 +45039,44 @@ var init_status_bar = __esm({
|
|
|
45001
45039
|
if (this._remoteMetrics) {
|
|
45002
45040
|
const rm2 = this._remoteMetrics;
|
|
45003
45041
|
const cpuColor = rm2.cpuUtil > 80 ? c2.red : rm2.cpuUtil > 50 ? c2.yellow : c2.green;
|
|
45004
|
-
const
|
|
45005
|
-
const
|
|
45006
|
-
|
|
45007
|
-
|
|
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;
|
|
45008
45057
|
if (rm2.gpuUtil >= 0) {
|
|
45009
45058
|
const gpuColor = rm2.gpuUtil > 80 ? c2.red : rm2.gpuUtil > 50 ? c2.yellow : c2.green;
|
|
45010
|
-
|
|
45011
|
-
|
|
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;
|
|
45012
45064
|
}
|
|
45013
45065
|
let vramStr = "";
|
|
45014
45066
|
let vramW = 0;
|
|
45015
45067
|
if (rm2.vramUtil >= 0) {
|
|
45016
45068
|
const vramColor = rm2.vramUtil > 80 ? c2.red : rm2.vramUtil > 50 ? c2.yellow : c2.green;
|
|
45017
|
-
|
|
45018
|
-
|
|
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;
|
|
45019
45072
|
}
|
|
45020
|
-
const remoteExpanded = pastel2(117, "\u{1F4E1}") + " " +
|
|
45021
|
-
const remoteCompact = pastel2(117, "\u{1F4E1}") + " " +
|
|
45073
|
+
const remoteExpanded = pastel2(117, "\u{1F4E1}") + " " + cpuExpStr + memExpStr + gpuExpStr + vramStr;
|
|
45074
|
+
const remoteCompact = pastel2(117, "\u{1F4E1}") + " " + cpuCompStr + gpuCompStr;
|
|
45022
45075
|
sections.push({
|
|
45023
45076
|
expanded: remoteExpanded,
|
|
45024
45077
|
compact: remoteCompact,
|
|
45025
|
-
expandedW: 3 +
|
|
45026
|
-
compactW: 3 +
|
|
45078
|
+
expandedW: 3 + cpuExpW + memExpW + gpuExpW + vramW,
|
|
45079
|
+
compactW: 3 + cpuCompW + gpuCompW,
|
|
45027
45080
|
empty: false
|
|
45028
45081
|
});
|
|
45029
45082
|
}
|
package/package.json
CHANGED