open-agents-ai 0.75.0 → 0.76.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 +75 -21
- package/dist/preinstall.cjs +45 -18
- package/package.json +1 -1
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
|
|
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
|
|
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
|
-
//
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
}
|
package/dist/preinstall.cjs
CHANGED
|
@@ -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
|
|
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!
|
|
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