open-agents-ai 0.103.46 → 0.103.47

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 +45 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28537,7 +28537,7 @@ ${this.formatConnectionInfo()}`);
28537
28537
  }
28538
28538
  };
28539
28539
  P2P_STATE_FILE_NAME = "expose-p2p-state.json";
28540
- ExposeP2PGateway = class extends EventEmitter3 {
28540
+ ExposeP2PGateway = class _ExposeP2PGateway extends EventEmitter3 {
28541
28541
  _nexusTool;
28542
28542
  // NexusTool instance
28543
28543
  _kind;
@@ -28669,6 +28669,7 @@ ${this.formatConnectionInfo()}`);
28669
28669
  margin: this._margin,
28670
28670
  passthrough: this._passthrough || void 0,
28671
28671
  loadbalance: this._loadbalance || void 0,
28672
+ endpointAuth: this._endpointAuth,
28672
28673
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
28673
28674
  });
28674
28675
  }
@@ -28685,20 +28686,51 @@ ${this.formatConnectionInfo()}`);
28685
28686
  }
28686
28687
  /**
28687
28688
  * Check for and reconnect to a surviving P2P expose from a previous session.
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.
28689
+ * The daemon survives OA restarts, but we MUST re-verify it on reconnect:
28690
+ * 1. doConnect() checks script hash kills + respawns if daemon code is stale
28691
+ * 2. Re-sends the expose command to clear old capabilities and register fresh ones
28692
+ * This guarantees the correct models are exposed (Chutes vs Ollama) even after OA restart.
28695
28693
  */
28696
- static async checkAndReconnect(_stateDir, _nexusTool, _options) {
28697
- const state = readP2PExposeState(_stateDir);
28698
- if (state) {
28699
- removeP2PExposeState(_stateDir);
28694
+ static async checkAndReconnect(stateDir, nexusTool, options) {
28695
+ const state = readP2PExposeState(stateDir);
28696
+ if (!state)
28697
+ return null;
28698
+ const nexusDir = nexusTool.getNexusDir();
28699
+ const statusPath = join35(nexusDir, "status.json");
28700
+ try {
28701
+ if (!existsSync27(statusPath)) {
28702
+ removeP2PExposeState(stateDir);
28703
+ return null;
28704
+ }
28705
+ const status = JSON.parse(readFileSync19(statusPath, "utf8"));
28706
+ if (!status.connected || !status.peerId) {
28707
+ removeP2PExposeState(stateDir);
28708
+ return null;
28709
+ }
28710
+ } catch {
28711
+ removeP2PExposeState(stateDir);
28712
+ return null;
28713
+ }
28714
+ const gateway = new _ExposeP2PGateway({
28715
+ kind: state.kind,
28716
+ targetUrl: state.targetUrl,
28717
+ authKey: state.authKey,
28718
+ stateDir,
28719
+ margin: state.margin,
28720
+ passthrough: state.passthrough,
28721
+ loadbalance: state.loadbalance,
28722
+ endpointAuth: state.endpointAuth,
28723
+ ...options
28724
+ }, nexusTool);
28725
+ try {
28726
+ await gateway.start();
28727
+ options.onInfo?.(`P2P expose reconnected: ${gateway._peerId ?? state.peerId}`);
28728
+ return gateway;
28729
+ } catch (err) {
28730
+ removeP2PExposeState(stateDir);
28731
+ options.onError?.(`P2P expose reconnect failed: ${err instanceof Error ? err.message : String(err)}`);
28732
+ return null;
28700
28733
  }
28701
- return null;
28702
28734
  }
28703
28735
  /** Poll the daemon's metering.jsonl and status.json for stats */
28704
28736
  startMeteringPoll(nexusDir) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.103.46",
3
+ "version": "0.103.47",
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",