open-agents-ai 0.75.0 → 0.77.0

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/launcher.cjs CHANGED
@@ -4,6 +4,13 @@
4
4
  var nodeVersion = parseInt(process.versions.node, 10);
5
5
 
6
6
  if (nodeVersion < 22) {
7
+ // Prevent infinite loop: if we're inside a self-triggered reinstall, bail
8
+ if (process.env.OA_SELF_UPGRADE === "1") {
9
+ console.error(" [launcher] Skipping — already inside a self-upgrade.");
10
+ console.error(" Open a new terminal with Node 22 and run: oa");
11
+ process.exit(1);
12
+ }
13
+
7
14
  var os = require("os");
8
15
  var path = require("path");
9
16
  var fs = require("fs");
@@ -150,7 +157,7 @@ if (nodeVersion < 22) {
150
157
  if (a === "n" || a === "no") {
151
158
  bail(
152
159
  "\n Install manually:\n" +
153
- " nvm install 20 && nvm alias default 20\n" +
160
+ " nvm install 22 && nvm alias default 22\n" +
154
161
  " npm i -g open-agents-ai\n"
155
162
  );
156
163
  return;
@@ -162,7 +169,7 @@ if (nodeVersion < 22) {
162
169
  "nvm install 22 && nvm use 22 && nvm alias default 22";
163
170
  var ok = run(shell + " -c '" + cmd + "'");
164
171
  if (!ok) {
165
- bail("\n Node 20 install failed.\n");
172
+ bail("\n Node 22 install failed.\n");
166
173
  return;
167
174
  }
168
175
  console.log("");
@@ -170,6 +177,45 @@ if (nodeVersion < 22) {
170
177
  });
171
178
  }
172
179
 
180
+ // Find the Node 22 binary installed by nvm
181
+ function findNode22Bin() {
182
+ // Check nvm versions directory for a v22.x binary
183
+ var versionsDir = path.join(nvmDir, "versions", "node");
184
+ try {
185
+ var versions = fs.readdirSync(versionsDir).filter(function(v) {
186
+ return v.startsWith("v22");
187
+ }).sort().reverse();
188
+ if (versions.length > 0) {
189
+ var bin = path.join(versionsDir, versions[0], "bin", "node");
190
+ try { fs.statSync(bin); return bin; } catch (e) {}
191
+ }
192
+ } catch (e) {}
193
+ // Fallback: ask nvm which node 22 is
194
+ try {
195
+ var shell = process.env.SHELL || "/bin/bash";
196
+ var result = childProcess.execSync(
197
+ shell + ' -c \'export NVM_DIR="' + nvmDir + '" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && nvm which 22\'',
198
+ { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"], timeout: 10000 }
199
+ ).trim();
200
+ if (result && fs.existsSync(result)) return result;
201
+ } catch (e) {}
202
+ return null;
203
+ }
204
+
205
+ // Find the oa launcher script under a given node prefix
206
+ function findOaBin(nodeBin) {
207
+ // nodeBin = .../bin/node → prefix = .../
208
+ var binDir = path.dirname(nodeBin);
209
+ var candidates = [
210
+ path.join(binDir, "oa"),
211
+ path.join(binDir, "open-agents"),
212
+ ];
213
+ for (var i = 0; i < candidates.length; i++) {
214
+ try { fs.statSync(candidates[i]); return candidates[i]; } catch (e) {}
215
+ }
216
+ return null;
217
+ }
218
+
173
219
  function doReinstall() {
174
220
  ask(" Reinstall open-agents under Node 22? [Y/n] ", function(a) {
175
221
  if (a === "n" || a === "no") {
@@ -183,7 +229,7 @@ if (nodeVersion < 22) {
183
229
  }
184
230
  console.log("");
185
231
  var shell = process.env.SHELL || "/bin/bash";
186
- var cmd = 'export NVM_DIR="' + nvmDir + '" && ' +
232
+ var cmd = 'export OA_SELF_UPGRADE=1 && export NVM_DIR="' + nvmDir + '" && ' +
187
233
  '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && ' +
188
234
  "nvm use 22 && npm i -g open-agents-ai";
189
235
  var ok = run(shell + " -c '" + cmd + "'");
@@ -197,27 +243,35 @@ if (nodeVersion < 22) {
197
243
  return;
198
244
  }
199
245
  console.log("");
200
- console.log(" ┌─────────────────────────────────────────────────┐");
201
- console.log(" │ Done! Launching open-agents... │");
202
- console.log(" └─────────────────────────────────────────────────┘");
203
- console.log("");
204
246
  rl.close();
205
247
 
206
- // Auto-source shell config and re-exec oa — no "open a new terminal" needed
207
- var rcFile = shell.indexOf("zsh") !== -1 ? "~/.zshrc" : "~/.bashrc";
208
- var relaunchCmd = 'export NVM_DIR="' + nvmDir + '" && ' +
209
- '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && ' +
210
- "source " + rcFile + " 2>/dev/null; " +
211
- "exec oa";
212
- try {
213
- childProcess.execSync(shell + " -c '" + relaunchCmd + "'", {
214
- stdio: "inherit",
215
- env: process.env,
216
- });
217
- } catch (e) {
218
- // Fallback: tell user to open new terminal only if re-exec fails
219
- console.log("\n If oa didn't launch, run: source " + rcFile + " && oa\n");
248
+ // Try to auto-relaunch under Node 22 — no new terminal needed
249
+ var node22 = findNode22Bin();
250
+ if (node22) {
251
+ var oaBin = findOaBin(node22);
252
+ if (oaBin) {
253
+ console.log(" ┌─────────────────────────────────────────────────┐");
254
+ console.log(" │ Done! Launching open-agents with Node 22... │");
255
+ console.log(" └─────────────────────────────────────────────────┘");
256
+ console.log("");
257
+ // Replace this process with Node 22 running the new oa launcher
258
+ try {
259
+ childProcess.execFileSync(node22, [oaBin], {
260
+ stdio: "inherit",
261
+ env: process.env,
262
+ });
263
+ } catch (e) {
264
+ // execFileSync throws when the child exits — that's normal
265
+ }
266
+ process.exit(0);
267
+ }
220
268
  }
269
+
270
+ // Fallback if we can't find Node 22 binary or oa script
271
+ console.log(" ┌─────────────────────────────────────────────────┐");
272
+ console.log(" │ Done! Open a new terminal and run: oa │");
273
+ console.log(" └─────────────────────────────────────────────────┘");
274
+ console.log("");
221
275
  process.exit(0);
222
276
  });
223
277
  }
@@ -247,7 +301,87 @@ if (nodeVersion < 22) {
247
301
  });
248
302
  });
249
303
  } else {
250
- // Node >= 22 — load the ESM bundle
304
+ // Node >= 22 — check sub-dependencies before loading the ESM bundle
305
+ var _path = require("path");
306
+ var _fs = require("fs");
307
+ var _cp = require("child_process");
308
+
309
+ // Resolve the package root (where package.json lives)
310
+ var _pkgDir = _path.dirname(__dirname.endsWith("dist") ? _path.dirname(__dirname) : __dirname);
311
+ // If we're in .../lib/node_modules/open-agents-ai/dist/, go up to the package root
312
+ var _pkgJson = _path.join(_pkgDir, "package.json");
313
+ if (!_fs.existsSync(_pkgJson)) {
314
+ _pkgDir = _path.resolve(__dirname, "..");
315
+ _pkgJson = _path.join(_pkgDir, "package.json");
316
+ }
317
+
318
+ // Dependencies to verify — both required and optional
319
+ var _criticalDeps = ["better-sqlite3", "ws", "zod", "glob", "ignore"];
320
+ var _optionalDeps = ["open-agents-nexus", "nats.ws", "moondream", "aiwg"];
321
+ var _missing = [];
322
+ var _missingOptional = [];
323
+
324
+ function _canResolve(name) {
325
+ try {
326
+ // Check if the module exists in the package's node_modules
327
+ var modDir = _path.join(_pkgDir, "node_modules", name);
328
+ if (_fs.existsSync(modDir)) return true;
329
+ // Also try require.resolve from the package dir
330
+ require.resolve(name, { paths: [_pkgDir] });
331
+ return true;
332
+ } catch (e) {
333
+ return false;
334
+ }
335
+ }
336
+
337
+ for (var _i = 0; _i < _criticalDeps.length; _i++) {
338
+ if (!_canResolve(_criticalDeps[_i])) _missing.push(_criticalDeps[_i]);
339
+ }
340
+ for (var _j = 0; _j < _optionalDeps.length; _j++) {
341
+ if (!_canResolve(_optionalDeps[_j])) _missingOptional.push(_optionalDeps[_j]);
342
+ }
343
+
344
+ var _allMissing = _missing.concat(_missingOptional);
345
+
346
+ if (_allMissing.length > 0) {
347
+ var _label = _missing.length > 0 ? "required" : "optional";
348
+ console.log(" Installing " + _allMissing.length + " missing " + _label + " sub-dependencies...");
349
+ console.log(" Missing: " + _allMissing.join(", "));
350
+ console.log("");
351
+
352
+ // Run npm install in the package directory to restore all deps
353
+ try {
354
+ _cp.execSync("npm install --no-audit --no-fund", {
355
+ cwd: _pkgDir,
356
+ stdio: ["pipe", "pipe", "pipe"],
357
+ timeout: 120000,
358
+ env: Object.assign({}, process.env, { OA_SELF_UPGRADE: "1" }),
359
+ });
360
+ console.log(" Sub-dependencies installed.");
361
+ console.log("");
362
+ } catch (e) {
363
+ // If full install fails, try installing each missing dep individually
364
+ for (var _k = 0; _k < _allMissing.length; _k++) {
365
+ var _dep = _allMissing[_k];
366
+ try {
367
+ var _isOpt = _missingOptional.indexOf(_dep) !== -1;
368
+ console.log(" Installing " + _dep + (_isOpt ? " (optional)" : "") + "...");
369
+ _cp.execSync("npm install " + _dep + " --no-audit --no-fund" + (_isOpt ? " --save-optional" : ""), {
370
+ cwd: _pkgDir,
371
+ stdio: ["pipe", "pipe", "pipe"],
372
+ timeout: 60000,
373
+ });
374
+ } catch (e2) {
375
+ if (_missing.indexOf(_dep) !== -1) {
376
+ console.error(" WARNING: Failed to install required dep: " + _dep);
377
+ }
378
+ // Optional deps failing is fine
379
+ }
380
+ }
381
+ }
382
+ }
383
+
384
+ // Load the ESM bundle
251
385
  import("./index.js").catch(function(err) {
252
386
  console.error("Failed to load open-agents:", err.message || err);
253
387
  process.exit(1);
@@ -10,6 +10,14 @@ if (nodeVersion >= 22) {
10
10
  process.exit(0);
11
11
  }
12
12
 
13
+ // Prevent infinite loop: if we're inside a self-triggered reinstall, bail
14
+ if (process.env.OA_SELF_UPGRADE === "1") {
15
+ console.log(" [preinstall] Skipping — already inside a self-upgrade.");
16
+ console.log(" If this Node is still too old, open a new terminal with Node 22 and run:");
17
+ console.log(" npm i -g open-agents-ai");
18
+ process.exit(1);
19
+ }
20
+
13
21
  var os = require("os");
14
22
  var path = require("path");
15
23
  var fs = require("fs");
@@ -167,7 +175,7 @@ function doInstallNode(next) {
167
175
  "nvm install 22 && nvm alias default 22";
168
176
  var ok = run(shell + " -c '" + cmd + "'");
169
177
  if (!ok) {
170
- bail("\n Node 20 install failed.\n");
178
+ bail("\n Node 22 install failed.\n");
171
179
  return;
172
180
  }
173
181
  console.log("");
@@ -175,6 +183,29 @@ function doInstallNode(next) {
175
183
  });
176
184
  }
177
185
 
186
+ // Find the Node 22 binary installed by nvm
187
+ function findNode22Bin() {
188
+ var versionsDir = path.join(nvmDir, "versions", "node");
189
+ try {
190
+ var versions = fs.readdirSync(versionsDir).filter(function(v) {
191
+ return v.startsWith("v22");
192
+ }).sort().reverse();
193
+ if (versions.length > 0) {
194
+ var bin = path.join(versionsDir, versions[0], "bin", "node");
195
+ try { fs.statSync(bin); return bin; } catch (e) {}
196
+ }
197
+ } catch (e) {}
198
+ try {
199
+ var shell = process.env.SHELL || "/bin/bash";
200
+ var result = childProcess.execSync(
201
+ shell + ' -c \'export NVM_DIR="' + nvmDir + '" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && nvm which 22\'',
202
+ { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"], timeout: 10000 }
203
+ ).trim();
204
+ if (result && fs.existsSync(result)) return result;
205
+ } catch (e) {}
206
+ return null;
207
+ }
208
+
178
209
  function doReinstall() {
179
210
  ask(" Reinstall open-agents under Node 22? [Y/n] ", function(a) {
180
211
  if (a === "n" || a === "no") {
@@ -188,7 +219,7 @@ function doReinstall() {
188
219
  }
189
220
  console.log("");
190
221
  var shell = process.env.SHELL || "/bin/bash";
191
- var cmd = 'export NVM_DIR="' + nvmDir + '" && ' +
222
+ var cmd = 'export OA_SELF_UPGRADE=1 && export NVM_DIR="' + nvmDir + '" && ' +
192
223
  '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && ' +
193
224
  "nvm use 22 && npm i -g open-agents-ai";
194
225
  var ok = run(shell + " -c '" + cmd + "'");
@@ -202,26 +233,22 @@ function doReinstall() {
202
233
  return;
203
234
  }
204
235
  console.log("");
236
+
237
+ // Tell the user exactly how to launch — resolve the Node 22 path for them
238
+ var node22 = findNode22Bin();
239
+ var binHint = node22 ? path.dirname(node22) : "~/.nvm/versions/node/v22.x.x/bin";
205
240
  console.log(" ┌─────────────────────────────────────────────────┐");
206
- console.log(" │ Done! Launching open-agents... │");
241
+ console.log(" │ Done! Node 22 installed + open-agents ready. │");
207
242
  console.log(" └─────────────────────────────────────────────────┘");
208
243
  console.log("");
244
+ console.log(" To launch immediately (no new terminal needed):");
245
+ console.log(" " + binHint + "/oa");
246
+ console.log("");
247
+ console.log(" Or source your shell config first:");
248
+ var rcFile = (process.env.SHELL || "").indexOf("zsh") !== -1 ? "~/.zshrc" : "~/.bashrc";
249
+ console.log(" source " + rcFile + " && oa");
250
+ console.log("");
209
251
  rl.close();
210
-
211
- // Auto-source shell config and launch oa — no "open a new terminal" needed
212
- var rcFile2 = shell.indexOf("zsh") !== -1 ? "~/.zshrc" : "~/.bashrc";
213
- var relaunchCmd = 'export NVM_DIR="' + nvmDir + '" && ' +
214
- '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && ' +
215
- "source " + rcFile2 + " 2>/dev/null; " +
216
- "exec oa";
217
- try {
218
- childProcess.execSync(shell + " -c '" + relaunchCmd + "'", {
219
- stdio: "inherit",
220
- env: process.env,
221
- });
222
- } catch (e2) {
223
- console.log("\n If oa didn't launch, run: source " + rcFile2 + " && oa\n");
224
- }
225
252
  process.exit(0);
226
253
  });
227
254
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.75.0",
3
+ "version": "0.77.0",
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",