open-agents-ai 0.186.34 → 0.186.36
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 +26 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5933,7 +5933,7 @@ async function handleCmd(cmd) {
|
|
|
5933
5933
|
}
|
|
5934
5934
|
}
|
|
5935
5935
|
|
|
5936
|
-
writeResp(id, { ok: true, output:
|
|
5936
|
+
writeResp(id, { ok: true, output: JSON.stringify({ sponsors: unique, count: unique.length }) });
|
|
5937
5937
|
break;
|
|
5938
5938
|
}
|
|
5939
5939
|
case 'discover_peers': {
|
|
@@ -49420,6 +49420,10 @@ function startSponsorHeartbeat(payload, getExposeGateway) {
|
|
|
49420
49420
|
if (gw.tunnelUrl && gw.tunnelUrl !== _lastRegisteredSponsorPayload.tunnelUrl) {
|
|
49421
49421
|
_lastRegisteredSponsorPayload.tunnelUrl = gw.tunnelUrl;
|
|
49422
49422
|
}
|
|
49423
|
+
if (gw.peerId && (!_lastRegisteredSponsorPayload.peerId || _lastRegisteredSponsorPayload.peerId === "unknown" || String(_lastRegisteredSponsorPayload.peerId).startsWith("oa-"))) {
|
|
49424
|
+
_lastRegisteredSponsorPayload.peerId = gw.peerId;
|
|
49425
|
+
_lastRegisteredSponsorPayload.libp2pPeerId = gw.peerId;
|
|
49426
|
+
}
|
|
49423
49427
|
if (gw.models && Array.isArray(gw.models)) {
|
|
49424
49428
|
_lastRegisteredSponsorPayload.models = gw.models;
|
|
49425
49429
|
}
|
|
@@ -49427,8 +49431,24 @@ function startSponsorHeartbeat(payload, getExposeGateway) {
|
|
|
49427
49431
|
}
|
|
49428
49432
|
} catch {
|
|
49429
49433
|
}
|
|
49430
|
-
if (!_lastRegisteredSponsorPayload.
|
|
49431
|
-
|
|
49434
|
+
if (!_lastRegisteredSponsorPayload.peerId || _lastRegisteredSponsorPayload.peerId === "unknown" || String(_lastRegisteredSponsorPayload.peerId).startsWith("oa-")) {
|
|
49435
|
+
try {
|
|
49436
|
+
const { existsSync: _fe, readFileSync: _rf } = __require("node:fs");
|
|
49437
|
+
const { join: _pj } = __require("node:path");
|
|
49438
|
+
for (const base of [process.cwd(), __require("node:os").homedir() + "/.open-agents"]) {
|
|
49439
|
+
const sf = _pj(base, ".oa", "nexus", "status.json");
|
|
49440
|
+
if (_fe(sf)) {
|
|
49441
|
+
const st = JSON.parse(_rf(sf, "utf8"));
|
|
49442
|
+
if (st.connected && st.peerId && st.peerId.startsWith("12D3KooW")) {
|
|
49443
|
+
_lastRegisteredSponsorPayload.peerId = st.peerId;
|
|
49444
|
+
_lastRegisteredSponsorPayload.libp2pPeerId = st.peerId;
|
|
49445
|
+
break;
|
|
49446
|
+
}
|
|
49447
|
+
}
|
|
49448
|
+
}
|
|
49449
|
+
} catch {
|
|
49450
|
+
}
|
|
49451
|
+
}
|
|
49432
49452
|
try {
|
|
49433
49453
|
await fetch("https://openagents.nexus/api/v1/sponsors", {
|
|
49434
49454
|
method: "POST",
|
|
@@ -53492,9 +53512,10 @@ async function handleSponsoredEndpoint(ctx, local) {
|
|
|
53492
53512
|
action: "sponsor_discover",
|
|
53493
53513
|
timeout_ms: "5000"
|
|
53494
53514
|
});
|
|
53495
|
-
|
|
53515
|
+
const discoverOutput = typeof discoverResult === "object" && discoverResult?.output ? String(discoverResult.output) : typeof discoverResult === "string" ? discoverResult : "";
|
|
53516
|
+
if (discoverOutput) {
|
|
53496
53517
|
try {
|
|
53497
|
-
const parsed = JSON.parse(
|
|
53518
|
+
const parsed = JSON.parse(discoverOutput);
|
|
53498
53519
|
const nexusSponsors = parsed.sponsors || [];
|
|
53499
53520
|
for (const ns of nexusSponsors) {
|
|
53500
53521
|
sponsors.push({
|
package/package.json
CHANGED