open-agents-ai 0.103.45 → 0.103.46
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 +16 -48
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13645,16 +13645,15 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
13645
13645
|
const existingPid = this.getDaemonPid();
|
|
13646
13646
|
if (existingPid) {
|
|
13647
13647
|
const daemonPath2 = join30(this.nexusDir, "nexus-daemon.mjs");
|
|
13648
|
-
let needsRestart =
|
|
13648
|
+
let needsRestart = true;
|
|
13649
13649
|
if (existsSync23(daemonPath2)) {
|
|
13650
13650
|
try {
|
|
13651
13651
|
const onDisk = readFileSync16(daemonPath2, "utf8");
|
|
13652
13652
|
const diskHash = createHash("sha256").update(onDisk).digest("hex").slice(0, 16);
|
|
13653
|
-
if (diskHash
|
|
13654
|
-
needsRestart =
|
|
13653
|
+
if (diskHash === currentScriptHash) {
|
|
13654
|
+
needsRestart = false;
|
|
13655
13655
|
}
|
|
13656
13656
|
} catch {
|
|
13657
|
-
needsRestart = true;
|
|
13658
13657
|
}
|
|
13659
13658
|
}
|
|
13660
13659
|
if (needsRestart) {
|
|
@@ -28538,7 +28537,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
28538
28537
|
}
|
|
28539
28538
|
};
|
|
28540
28539
|
P2P_STATE_FILE_NAME = "expose-p2p-state.json";
|
|
28541
|
-
ExposeP2PGateway = class
|
|
28540
|
+
ExposeP2PGateway = class extends EventEmitter3 {
|
|
28542
28541
|
_nexusTool;
|
|
28543
28542
|
// NexusTool instance
|
|
28544
28543
|
_kind;
|
|
@@ -28686,51 +28685,20 @@ ${this.formatConnectionInfo()}`);
|
|
|
28686
28685
|
}
|
|
28687
28686
|
/**
|
|
28688
28687
|
* Check for and reconnect to a surviving P2P expose from a previous session.
|
|
28689
|
-
*
|
|
28690
|
-
*
|
|
28691
|
-
*
|
|
28688
|
+
*
|
|
28689
|
+
* IMPORTANT: We no longer blindly reconnect to surviving daemons because:
|
|
28690
|
+
* 1. The daemon script may be outdated (OA was updated since daemon spawned)
|
|
28691
|
+
* 2. The registered capabilities may be stale (e.g., local Ollama from a previous expose)
|
|
28692
|
+
* 3. Only a fresh start() → doConnect() → expose can guarantee correct state
|
|
28693
|
+
*
|
|
28694
|
+
* Instead, we clean up the stale state so the next /expose command starts fresh.
|
|
28692
28695
|
*/
|
|
28693
|
-
static async checkAndReconnect(
|
|
28694
|
-
const state = readP2PExposeState(
|
|
28695
|
-
if (
|
|
28696
|
-
|
|
28697
|
-
const nexusDir = nexusTool.getNexusDir();
|
|
28698
|
-
const statusPath = join35(nexusDir, "status.json");
|
|
28699
|
-
try {
|
|
28700
|
-
if (!existsSync27(statusPath)) {
|
|
28701
|
-
removeP2PExposeState(stateDir);
|
|
28702
|
-
return null;
|
|
28703
|
-
}
|
|
28704
|
-
const status = JSON.parse(readFileSync19(statusPath, "utf8"));
|
|
28705
|
-
if (!status.connected || !status.peerId) {
|
|
28706
|
-
removeP2PExposeState(stateDir);
|
|
28707
|
-
return null;
|
|
28708
|
-
}
|
|
28709
|
-
if (status.peerId !== state.peerId) {
|
|
28710
|
-
removeP2PExposeState(stateDir);
|
|
28711
|
-
return null;
|
|
28712
|
-
}
|
|
28713
|
-
} catch {
|
|
28714
|
-
removeP2PExposeState(stateDir);
|
|
28715
|
-
return null;
|
|
28696
|
+
static async checkAndReconnect(_stateDir, _nexusTool, _options) {
|
|
28697
|
+
const state = readP2PExposeState(_stateDir);
|
|
28698
|
+
if (state) {
|
|
28699
|
+
removeP2PExposeState(_stateDir);
|
|
28716
28700
|
}
|
|
28717
|
-
|
|
28718
|
-
kind: state.kind,
|
|
28719
|
-
targetUrl: state.targetUrl,
|
|
28720
|
-
authKey: state.authKey,
|
|
28721
|
-
stateDir,
|
|
28722
|
-
margin: state.margin,
|
|
28723
|
-
passthrough: state.passthrough,
|
|
28724
|
-
loadbalance: state.loadbalance,
|
|
28725
|
-
...options
|
|
28726
|
-
}, nexusTool);
|
|
28727
|
-
gateway._peerId = state.peerId;
|
|
28728
|
-
gateway._stats.status = "active";
|
|
28729
|
-
gateway._stats.startedAt = new Date(state.startedAt).getTime();
|
|
28730
|
-
gateway.emitStats();
|
|
28731
|
-
gateway.startMeteringPoll(nexusDir);
|
|
28732
|
-
options.onInfo?.(`P2P expose reconnected: ${state.peerId}`);
|
|
28733
|
-
return gateway;
|
|
28701
|
+
return null;
|
|
28734
28702
|
}
|
|
28735
28703
|
/** Poll the daemon's metering.jsonl and status.json for stats */
|
|
28736
28704
|
startMeteringPoll(nexusDir) {
|
package/package.json
CHANGED