open-agents-ai 0.186.16 → 0.186.17

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 +69 -32
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8895,36 +8895,13 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
8895
8895
  const currentScriptHash = createHash("sha256").update(DAEMON_SCRIPT).digest("hex").slice(0, 16);
8896
8896
  const existingPid = this.getDaemonPid();
8897
8897
  if (existingPid) {
8898
- const daemonPath2 = join14(this.nexusDir, "nexus-daemon.mjs");
8899
- let needsRestart = true;
8900
- if (existsSync11(daemonPath2)) {
8901
- try {
8902
- const onDisk = readFileSync8(daemonPath2, "utf8");
8903
- const diskHash = createHash("sha256").update(onDisk).digest("hex").slice(0, 16);
8904
- if (diskHash === currentScriptHash) {
8905
- needsRestart = false;
8906
- }
8907
- } catch {
8908
- }
8898
+ let processAlive = false;
8899
+ try {
8900
+ process.kill(existingPid, 0);
8901
+ processAlive = true;
8902
+ } catch {
8909
8903
  }
8910
- if (needsRestart) {
8911
- try {
8912
- process.kill(existingPid, "SIGTERM");
8913
- } catch {
8914
- }
8915
- await new Promise((r) => setTimeout(r, 1e3));
8916
- try {
8917
- process.kill(existingPid, 0);
8918
- process.kill(existingPid, "SIGKILL");
8919
- } catch {
8920
- }
8921
- for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
8922
- const p = join14(this.nexusDir, f);
8923
- if (existsSync11(p))
8924
- await unlink(p).catch(() => {
8925
- });
8926
- }
8927
- } else {
8904
+ if (processAlive) {
8928
8905
  const statusFile2 = join14(this.nexusDir, "status.json");
8929
8906
  if (existsSync11(statusFile2)) {
8930
8907
  try {
@@ -8933,14 +8910,46 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
8933
8910
  await this.ensureWallet();
8934
8911
  return `Already connected (pid: ${existingPid}, peerId: ${status.peerId})`;
8935
8912
  }
8913
+ if (status.error) {
8914
+ try {
8915
+ process.kill(existingPid, "SIGTERM");
8916
+ } catch {
8917
+ }
8918
+ await new Promise((r) => setTimeout(r, 500));
8919
+ }
8920
+ return await this.waitForDaemonReady(existingPid);
8936
8921
  } catch {
8937
8922
  }
8938
8923
  }
8924
+ for (let i = 0; i < 10; i++) {
8925
+ await new Promise((r) => setTimeout(r, 500));
8926
+ if (existsSync11(statusFile2)) {
8927
+ try {
8928
+ const status = JSON.parse(await readFile8(statusFile2, "utf8"));
8929
+ if (status.connected && status.peerId) {
8930
+ await this.ensureWallet();
8931
+ return `Already connected (pid: ${existingPid}, peerId: ${status.peerId})`;
8932
+ }
8933
+ } catch {
8934
+ }
8935
+ }
8936
+ }
8939
8937
  try {
8940
8938
  process.kill(existingPid, "SIGTERM");
8941
8939
  } catch {
8942
8940
  }
8943
8941
  await new Promise((r) => setTimeout(r, 500));
8942
+ try {
8943
+ process.kill(existingPid, 0);
8944
+ process.kill(existingPid, "SIGKILL");
8945
+ } catch {
8946
+ }
8947
+ }
8948
+ for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
8949
+ const p = join14(this.nexusDir, f);
8950
+ if (existsSync11(p))
8951
+ await unlink(p).catch(() => {
8952
+ });
8944
8953
  }
8945
8954
  }
8946
8955
  for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
@@ -9144,6 +9153,28 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
9144
9153
  }
9145
9154
  return `Daemon failed to start.${earlyError ? "\n" + earlyError : ""}${earlyOutput ? "\n" + earlyOutput : ""}`;
9146
9155
  }
9156
+ /** Wait for an already-spawned daemon to write connected status (up to 20s). */
9157
+ async waitForDaemonReady(pid) {
9158
+ const statusFile = join14(this.nexusDir, "status.json");
9159
+ for (let i = 0; i < 40; i++) {
9160
+ await new Promise((r) => setTimeout(r, 500));
9161
+ if (existsSync11(statusFile)) {
9162
+ try {
9163
+ const status = JSON.parse(await readFile8(statusFile, "utf8"));
9164
+ if (status.error)
9165
+ return `Nexus daemon failed: ${status.error}`;
9166
+ if (status.connected && status.peerId) {
9167
+ await this.ensureWallet();
9168
+ return `Connected to nexus P2P network.
9169
+ Peer ID: ${status.peerId}
9170
+ Daemon PID: ${status.pid}`;
9171
+ }
9172
+ } catch {
9173
+ }
9174
+ }
9175
+ }
9176
+ return `Daemon spawned (pid: ${pid}) but still connecting. Check status in a moment.`;
9177
+ }
9147
9178
  async doDisconnect() {
9148
9179
  const pid = this.getDaemonPid();
9149
9180
  if (!pid)
@@ -53183,9 +53214,15 @@ async function handleSponsoredEndpoint(ctx, local) {
53183
53214
  if (isConnected) {
53184
53215
  renderInfo("Using existing nexus connection...");
53185
53216
  } else {
53186
- renderInfo("Starting nexus daemon...");
53187
- await nexusTool.execute({ action: "connect" });
53188
- await new Promise((r) => setTimeout(r, 3e3));
53217
+ const hasPid = statusResult.includes("PID:") || statusResult.includes("pid:");
53218
+ if (!hasPid) {
53219
+ renderInfo("Starting nexus daemon...");
53220
+ await nexusTool.execute({ action: "connect" });
53221
+ await new Promise((r) => setTimeout(r, 3e3));
53222
+ } else {
53223
+ renderInfo("Waiting for nexus daemon to connect...");
53224
+ await new Promise((r) => setTimeout(r, 5e3));
53225
+ }
53189
53226
  }
53190
53227
  renderInfo("Querying sponsors on the mesh...");
53191
53228
  const discoverResult = await nexusTool.execute({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.186.16",
3
+ "version": "0.186.17",
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",