open-agents-ai 0.103.44 → 0.103.45

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.
Files changed (2) hide show
  1. package/dist/index.js +55 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12601,6 +12601,18 @@ async function handleCmd(cmd) {
12601
12601
 
12602
12602
  // \u2500\u2500 Metered Inference Exposure \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
12603
12603
  case 'expose': {
12604
+ // Clear old inference capabilities before registering new ones
12605
+ // (prevents stale local Ollama models when switching to passthrough, or vice versa)
12606
+ if (typeof nexus.getRegisteredCapabilities === 'function' && typeof nexus.unregisterCapability === 'function') {
12607
+ var oldCaps = nexus.getRegisteredCapabilities();
12608
+ for (var oci = 0; oci < oldCaps.length; oci++) {
12609
+ if (oldCaps[oci].startsWith('inference:') || oldCaps[oci] === 'system_metrics' || oldCaps[oci] === '__list_capabilities') {
12610
+ try { nexus.unregisterCapability(oldCaps[oci]); } catch {}
12611
+ }
12612
+ }
12613
+ dlog('expose: cleared ' + oldCaps.length + ' old capabilities');
12614
+ }
12615
+
12604
12616
  // Auth key for gating inference access (passed from ExposeP2PGateway)
12605
12617
  var exposeAuthKey = args.auth_key || '';
12606
12618
  if (exposeAuthKey) {
@@ -13629,23 +13641,57 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
13629
13641
  // =========================================================================
13630
13642
  async doConnect(args) {
13631
13643
  await this.ensureDir();
13644
+ const currentScriptHash = createHash("sha256").update(DAEMON_SCRIPT).digest("hex").slice(0, 16);
13632
13645
  const existingPid = this.getDaemonPid();
13633
13646
  if (existingPid) {
13634
- const statusFile2 = join30(this.nexusDir, "status.json");
13635
- if (existsSync23(statusFile2)) {
13647
+ const daemonPath2 = join30(this.nexusDir, "nexus-daemon.mjs");
13648
+ let needsRestart = false;
13649
+ if (existsSync23(daemonPath2)) {
13636
13650
  try {
13637
- const status = JSON.parse(await readFile13(statusFile2, "utf8"));
13638
- if (status.connected && status.peerId) {
13639
- return `Already connected (pid: ${existingPid}, peerId: ${status.peerId})`;
13651
+ const onDisk = readFileSync16(daemonPath2, "utf8");
13652
+ const diskHash = createHash("sha256").update(onDisk).digest("hex").slice(0, 16);
13653
+ if (diskHash !== currentScriptHash) {
13654
+ needsRestart = true;
13640
13655
  }
13641
13656
  } catch {
13657
+ needsRestart = true;
13642
13658
  }
13643
13659
  }
13644
- try {
13645
- process.kill(existingPid, "SIGTERM");
13646
- } catch {
13660
+ if (needsRestart) {
13661
+ try {
13662
+ process.kill(existingPid, "SIGTERM");
13663
+ } catch {
13664
+ }
13665
+ await new Promise((r) => setTimeout(r, 1e3));
13666
+ try {
13667
+ process.kill(existingPid, 0);
13668
+ process.kill(existingPid, "SIGKILL");
13669
+ } catch {
13670
+ }
13671
+ for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
13672
+ const p = join30(this.nexusDir, f);
13673
+ if (existsSync23(p))
13674
+ await unlink(p).catch(() => {
13675
+ });
13676
+ }
13677
+ } else {
13678
+ const statusFile2 = join30(this.nexusDir, "status.json");
13679
+ if (existsSync23(statusFile2)) {
13680
+ try {
13681
+ const status = JSON.parse(await readFile13(statusFile2, "utf8"));
13682
+ if (status.connected && status.peerId) {
13683
+ await this.ensureWallet();
13684
+ return `Already connected (pid: ${existingPid}, peerId: ${status.peerId})`;
13685
+ }
13686
+ } catch {
13687
+ }
13688
+ }
13689
+ try {
13690
+ process.kill(existingPid, "SIGTERM");
13691
+ } catch {
13692
+ }
13693
+ await new Promise((r) => setTimeout(r, 500));
13647
13694
  }
13648
- await new Promise((r) => setTimeout(r, 500));
13649
13695
  }
13650
13696
  for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
13651
13697
  const p = join30(this.nexusDir, f);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.103.44",
3
+ "version": "0.103.45",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",