omnius 1.0.425 → 1.0.426
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 +42 -8
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29383,9 +29383,19 @@ function _extractSponsorFromMeshMessage(msg) {
|
|
|
29383
29383
|
if (payload.type === 'sponsor.announce') return payload;
|
|
29384
29384
|
return null;
|
|
29385
29385
|
}
|
|
29386
|
+
var _profilePublishInFlight = false;
|
|
29387
|
+
var _profilePublishLastAt = 0;
|
|
29386
29388
|
async function _publishAgentProfileSnapshot() {
|
|
29387
29389
|
try {
|
|
29388
29390
|
if (!connected || !nexus.network || !nexus.network.dht || !nexus.network.dht.registry) return;
|
|
29391
|
+
// DHT publishes on congested networks time out (observed as repeated
|
|
29392
|
+
// [dht:registry] TimeoutError storms). Promise.race below does NOT cancel
|
|
29393
|
+
// the underlying query, so overlapping calls stack concurrent DHT walks
|
|
29394
|
+
// and burn CPU. Single-flight + a 60s floor keeps one publish at a time.
|
|
29395
|
+
var _ppNow = Date.now();
|
|
29396
|
+
if (_profilePublishInFlight || _ppNow - _profilePublishLastAt < 60000) return;
|
|
29397
|
+
_profilePublishInFlight = true;
|
|
29398
|
+
_profilePublishLastAt = _ppNow;
|
|
29389
29399
|
var node = nexus.network.node;
|
|
29390
29400
|
var caps = typeof nexus.getRegisteredCapabilities === 'function' ? nexus.getRegisteredCapabilities() : [];
|
|
29391
29401
|
var profile = {
|
|
@@ -29407,6 +29417,8 @@ async function _publishAgentProfileSnapshot() {
|
|
|
29407
29417
|
]);
|
|
29408
29418
|
} catch (err) {
|
|
29409
29419
|
dlog('profile publish failed: ' + (err.message || err));
|
|
29420
|
+
} finally {
|
|
29421
|
+
_profilePublishInFlight = false;
|
|
29410
29422
|
}
|
|
29411
29423
|
}
|
|
29412
29424
|
async function _publishCapabilityRecord(name, details) {
|
|
@@ -31286,9 +31298,11 @@ async function handleCmd(cmd) {
|
|
|
31286
31298
|
|
|
31287
31299
|
// Wait for input data to arrive (invoke protocol sends data after accept)
|
|
31288
31300
|
var waitMs = 0;
|
|
31301
|
+
// 50ms poll (was a 10ms spin) — bounded to 5s; input latency is
|
|
31302
|
+
// network-dominated so the coarser tick is invisible.
|
|
31289
31303
|
while (!inputDone && dataChunks.length === 0 && waitMs < 5000) {
|
|
31290
|
-
await new Promise(function(r) { setTimeout(r,
|
|
31291
|
-
waitMs +=
|
|
31304
|
+
await new Promise(function(r) { setTimeout(r, 50); });
|
|
31305
|
+
waitMs += 50;
|
|
31292
31306
|
}
|
|
31293
31307
|
prompt = dataChunks.join('');
|
|
31294
31308
|
dlog('expose: received ' + dataChunks.length + ' chunks, prompt_len=' + prompt.length + ' inputDone=' + inputDone);
|
|
@@ -32228,8 +32242,11 @@ async function handleCmd(cmd) {
|
|
|
32228
32242
|
}
|
|
32229
32243
|
}
|
|
32230
32244
|
|
|
32231
|
-
// Command
|
|
32232
|
-
//
|
|
32245
|
+
// Command intake: fs.watch on the nexus dir delivers cmd.json changes
|
|
32246
|
+
// instantly (registered below); this interval is only a fallback for
|
|
32247
|
+
// platforms/filesystems where fs.watch drops events. 50ms polling here was
|
|
32248
|
+
// measured pinning CPU on deployed boxes — 1s fallback costs nothing since
|
|
32249
|
+
// the watcher provides the low-latency path.
|
|
32233
32250
|
let lastCmdId = '';
|
|
32234
32251
|
function checkCmd() {
|
|
32235
32252
|
try {
|
|
@@ -32243,7 +32260,7 @@ function checkCmd() {
|
|
|
32243
32260
|
});
|
|
32244
32261
|
} catch {}
|
|
32245
32262
|
}
|
|
32246
|
-
setInterval(checkCmd,
|
|
32263
|
+
setInterval(checkCmd, 1000);
|
|
32247
32264
|
// Also watch for cmd.json changes for instant notification (best-effort)
|
|
32248
32265
|
try {
|
|
32249
32266
|
fsWatch(nexusDir, { persistent: false }, function(evType, filename) {
|
|
@@ -32629,18 +32646,35 @@ process.on('unhandledRejection', (reason) => {
|
|
|
32629
32646
|
} catch {}
|
|
32630
32647
|
try {
|
|
32631
32648
|
if (nexus.nats && typeof nexus.nats.subscribe === 'function') {
|
|
32649
|
+
var _peersFileLastWrite = 0;
|
|
32632
32650
|
nexus.nats.subscribe(function(announcement) {
|
|
32633
32651
|
if (!announcement || !announcement.peerId) return;
|
|
32634
32652
|
if (announcement.peerId === nexus.peerId) return; // skip self
|
|
32635
|
-
|
|
32653
|
+
// Peers re-announce every 10-30s. Persisting the full JSON map and
|
|
32654
|
+
// logging on EVERY announcement turned steady-state discovery into
|
|
32655
|
+
// constant file I/O + log churn. Only react to NEW peers or
|
|
32656
|
+
// material changes; lastSeen bumps persist on a 30s throttle.
|
|
32657
|
+
var prev = discoveredPeers[announcement.peerId];
|
|
32658
|
+
var next = {
|
|
32636
32659
|
peerId: announcement.peerId,
|
|
32637
32660
|
agentName: announcement.agentName || '',
|
|
32638
32661
|
capabilities: announcement.capabilities || [],
|
|
32639
32662
|
multiaddrs: announcement.multiaddrs || [],
|
|
32640
32663
|
lastSeen: Date.now(),
|
|
32641
32664
|
};
|
|
32642
|
-
|
|
32643
|
-
|
|
32665
|
+
var changed = !prev
|
|
32666
|
+
|| prev.agentName !== next.agentName
|
|
32667
|
+
|| JSON.stringify(prev.capabilities) !== JSON.stringify(next.capabilities)
|
|
32668
|
+
|| JSON.stringify(prev.multiaddrs) !== JSON.stringify(next.multiaddrs);
|
|
32669
|
+
discoveredPeers[announcement.peerId] = next;
|
|
32670
|
+
var nowMs = Date.now();
|
|
32671
|
+
if (changed || nowMs - _peersFileLastWrite >= 30000) {
|
|
32672
|
+
_peersFileLastWrite = nowMs;
|
|
32673
|
+
try { writeFileSync(discoveredPeersFile, JSON.stringify(discoveredPeers, null, 2)); } catch {}
|
|
32674
|
+
}
|
|
32675
|
+
if (changed) {
|
|
32676
|
+
dlog('NATS peer discovered: ' + String(announcement.peerId).slice(0, 20) + ' caps=' + (announcement.capabilities || []).length);
|
|
32677
|
+
}
|
|
32644
32678
|
});
|
|
32645
32679
|
dlog('NATS peer discovery subscription active');
|
|
32646
32680
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.426",
|
|
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.426",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED