open-agents-ai 0.103.47 → 0.103.49
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 +64 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12122,6 +12122,27 @@ if (hasX402Key) {
|
|
|
12122
12122
|
}
|
|
12123
12123
|
const nexus = new NexusClient(nexusOpts);
|
|
12124
12124
|
|
|
12125
|
+
// Monkey-patch dialPeerProtocol to convert string multiaddrs to proper Multiaddr objects.
|
|
12126
|
+
// libp2p v3 (3.1.x) requires Multiaddr objects (with .getComponents()), but
|
|
12127
|
+
// open-agents-nexus resolves multiaddrs as plain strings. This shim wraps
|
|
12128
|
+
// node.dialProtocol to auto-convert strings before they reach libp2p's getPeerAddress().
|
|
12129
|
+
if (nexus.node && typeof nexus.node.dialProtocol === 'function') {
|
|
12130
|
+
var _origDialProtocol = nexus.node.dialProtocol.bind(nexus.node);
|
|
12131
|
+
nexus.node.dialProtocol = async function patchedDialProtocol(peer, protocols, options) {
|
|
12132
|
+
// If peer is a string (multiaddr), convert to a proper Multiaddr object
|
|
12133
|
+
if (typeof peer === 'string' && peer.startsWith('/')) {
|
|
12134
|
+
try {
|
|
12135
|
+
var { multiaddr: maFromStr } = await import('@multiformats/multiaddr');
|
|
12136
|
+
peer = maFromStr(peer);
|
|
12137
|
+
} catch (convErr) {
|
|
12138
|
+
dlog('multiaddr conversion failed: ' + (convErr.message || convErr));
|
|
12139
|
+
}
|
|
12140
|
+
}
|
|
12141
|
+
return _origDialProtocol(peer, protocols, options);
|
|
12142
|
+
};
|
|
12143
|
+
dlog('patched node.dialProtocol for multiaddr string conversion');
|
|
12144
|
+
}
|
|
12145
|
+
|
|
12125
12146
|
const rooms = new Map();
|
|
12126
12147
|
let connected = false;
|
|
12127
12148
|
const blockedPeers = [];
|
|
@@ -28691,7 +28712,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
28691
28712
|
* 2. Re-sends the expose command to clear old capabilities and register fresh ones
|
|
28692
28713
|
* This guarantees the correct models are exposed (Chutes vs Ollama) even after OA restart.
|
|
28693
28714
|
*/
|
|
28694
|
-
static async checkAndReconnect(stateDir, nexusTool, options) {
|
|
28715
|
+
static async checkAndReconnect(stateDir, nexusTool, options, currentConfig) {
|
|
28695
28716
|
const state = readP2PExposeState(stateDir);
|
|
28696
28717
|
if (!state)
|
|
28697
28718
|
return null;
|
|
@@ -28711,15 +28732,30 @@ ${this.formatConnectionInfo()}`);
|
|
|
28711
28732
|
removeP2PExposeState(stateDir);
|
|
28712
28733
|
return null;
|
|
28713
28734
|
}
|
|
28735
|
+
let effectiveState = { ...state };
|
|
28736
|
+
if (currentConfig) {
|
|
28737
|
+
const currentUrl = currentConfig.backendUrl;
|
|
28738
|
+
const isCurrentLocal = currentUrl.includes("127.0.0.1") || currentUrl.includes("localhost");
|
|
28739
|
+
const isCurrentPeer = currentUrl.startsWith("peer://");
|
|
28740
|
+
if (state.passthrough) {
|
|
28741
|
+
const normalizedUrl = currentUrl.replace(/\/+$/, "").replace(/\/chat\/completions$/, "").replace(/\/completions$/, "").replace(/\/models(\/.*)?$/, "").replace(/\/v1$/, "").replace(/\/+$/, "");
|
|
28742
|
+
effectiveState.targetUrl = normalizedUrl;
|
|
28743
|
+
effectiveState.endpointAuth = currentConfig.apiKey;
|
|
28744
|
+
} else if (!isCurrentLocal && !isCurrentPeer && state.kind === "ollama") {
|
|
28745
|
+
removeP2PExposeState(stateDir);
|
|
28746
|
+
options.onInfo?.("P2P expose skipped: endpoint changed (use /expose forward for remote backends)");
|
|
28747
|
+
return null;
|
|
28748
|
+
}
|
|
28749
|
+
}
|
|
28714
28750
|
const gateway = new _ExposeP2PGateway({
|
|
28715
|
-
kind:
|
|
28716
|
-
targetUrl:
|
|
28717
|
-
authKey:
|
|
28751
|
+
kind: effectiveState.kind,
|
|
28752
|
+
targetUrl: effectiveState.targetUrl,
|
|
28753
|
+
authKey: effectiveState.authKey,
|
|
28718
28754
|
stateDir,
|
|
28719
|
-
margin:
|
|
28720
|
-
passthrough:
|
|
28721
|
-
loadbalance:
|
|
28722
|
-
endpointAuth:
|
|
28755
|
+
margin: effectiveState.margin,
|
|
28756
|
+
passthrough: effectiveState.passthrough,
|
|
28757
|
+
loadbalance: effectiveState.loadbalance,
|
|
28758
|
+
endpointAuth: effectiveState.endpointAuth,
|
|
28723
28759
|
...options
|
|
28724
28760
|
}, nexusTool);
|
|
28725
28761
|
try {
|
|
@@ -44243,19 +44279,26 @@ var init_status_bar = __esm({
|
|
|
44243
44279
|
const raw = await sendCommand("invoke_capability", {
|
|
44244
44280
|
target_peer: peerId,
|
|
44245
44281
|
capability: "system_metrics",
|
|
44246
|
-
|
|
44282
|
+
input: queryData
|
|
44247
44283
|
}, 8e3);
|
|
44248
|
-
const
|
|
44249
|
-
if (
|
|
44250
|
-
|
|
44251
|
-
|
|
44252
|
-
|
|
44253
|
-
|
|
44254
|
-
|
|
44255
|
-
|
|
44256
|
-
|
|
44257
|
-
|
|
44258
|
-
|
|
44284
|
+
const parsed = JSON.parse(raw);
|
|
44285
|
+
if (parsed) {
|
|
44286
|
+
let metricsData = null;
|
|
44287
|
+
if (typeof parsed === "object" && parsed.result) {
|
|
44288
|
+
metricsData = typeof parsed.result === "string" ? JSON.parse(parsed.result) : parsed.result;
|
|
44289
|
+
} else if (typeof parsed === "object" && parsed.cpu) {
|
|
44290
|
+
metricsData = parsed;
|
|
44291
|
+
}
|
|
44292
|
+
if (metricsData?.cpu) {
|
|
44293
|
+
this.setRemoteMetrics({
|
|
44294
|
+
cpuUtil: metricsData.cpu?.utilization ?? 0,
|
|
44295
|
+
gpuUtil: metricsData.gpu?.available ? metricsData.gpu.utilization ?? 0 : -1,
|
|
44296
|
+
gpuName: metricsData.gpu?.name ?? "",
|
|
44297
|
+
vramUtil: metricsData.gpu?.available ? metricsData.gpu.vramUtilization ?? 0 : -1,
|
|
44298
|
+
memUtil: metricsData.memory?.utilization ?? 0
|
|
44299
|
+
});
|
|
44300
|
+
return;
|
|
44301
|
+
}
|
|
44259
44302
|
}
|
|
44260
44303
|
} catch {
|
|
44261
44304
|
}
|
|
@@ -46424,7 +46467,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
46424
46467
|
const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(oaDir, new NexusTool(repoRoot), {
|
|
46425
46468
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
46426
46469
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
46427
|
-
});
|
|
46470
|
+
}, { backendUrl: currentConfig.backendUrl, apiKey: currentConfig.apiKey });
|
|
46428
46471
|
if (reconnectedP2P) {
|
|
46429
46472
|
p2pGateway = reconnectedP2P;
|
|
46430
46473
|
reconnectedP2P.on("stats", (stats) => {
|
package/package.json
CHANGED